diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 93ebcca..509494c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -58,7 +58,7 @@ jobs: - name: Build if: steps.version-check.outputs.changed == 'true' - run: bun run build:lib + run: bun run build:plugin - name: Publish if: steps.version-check.outputs.changed == 'true' diff --git a/client.ts b/client.ts index fbb71a4..f2050b2 100644 --- a/client.ts +++ b/client.ts @@ -58,7 +58,7 @@ export class SupermemoryClient { customId?: string, containerTag?: string, entityContext?: string, - ): Promise<{ id: string }> { + ): Promise<{ id: string; status: string }> { const cleaned = sanitizeContent(content) const tag = containerTag ?? this.containerTag @@ -81,8 +81,17 @@ export class SupermemoryClient { ...(clampedCtx && { entityContext: clampedCtx }), }) - log.debugResponse("add", { id: result.id }) - return { id: result.id } + log.debugResponse("add", { id: result.id, status: result.status }) + + if (result.status === "failed") { + log.warn( + `add returned status="failed" for id=${result.id}` + + (customId ? ` customId=${customId}` : "") + + ` (contentLength=${cleaned.length}, containerTag=${tag})`, + ) + } + + return { id: result.id, status: result.status } } async search( diff --git a/commands/slash.ts b/commands/slash.ts index ff7e74f..a7df83b 100644 --- a/commands/slash.ts +++ b/commands/slash.ts @@ -52,7 +52,7 @@ export function registerCommands( try { const category = detectCategory(text) const sk = getSessionKey() - await client.addMemory( + const { status } = await client.addMemory( text, { type: category, source: "openclaw_command" }, sk ? buildDocumentId(sk) : undefined, @@ -61,6 +61,11 @@ export function registerCommands( ) const preview = text.length > 60 ? `${text.slice(0, 60)}…` : text + if (status === "failed") { + return { + text: `Memory store failed (server returned status="failed") for: "${preview}"`, + } + } return { text: `Remembered: "${preview}"` } } catch (err) { log.error("/remember failed", err) diff --git a/package.json b/package.json index 4e1dcbc..895c256 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,15 @@ { "name": "@supermemory/openclaw-supermemory", - "version": "2.1.11", + "version": "2.1.12", "type": "module", "description": "OpenClaw Supermemory memory plugin", "license": "MIT", + "files": [ + "dist", + "openclaw.plugin.json", + "README.md", + "types" + ], "dependencies": { "supermemory": "^4.0.0", "@sinclair/typebox": "0.34.47" @@ -12,14 +18,16 @@ "check-types": "tsc --noEmit", "lint": "bunx @biomejs/biome ci .", "lint:fix": "bunx @biomejs/biome check --write .", - "build:lib": "esbuild lib/validate.ts --bundle --minify --format=esm --platform=node --target=es2022 --external:node:crypto --outfile=lib/validate.js" + "build:plugin": "esbuild index.ts --bundle --format=esm --platform=node --target=es2022 --external:openclaw --external:openclaw/* --external:supermemory --external:@sinclair/typebox --outfile=dist/index.js", + "build": "bun run build:plugin", + "prepack": "bun run build" }, "peerDependencies": { "openclaw": ">=2026.2.17" }, "openclaw": { "extensions": [ - "./index.ts" + "./dist/index.js" ] }, "repository": { diff --git a/tools/store.ts b/tools/store.ts index 4c688ae..75eaf20 100644 --- a/tools/store.ts +++ b/tools/store.ts @@ -44,7 +44,7 @@ export function registerStoreTool( `store tool: category="${category}" customId="${customId}" containerTag="${params.containerTag ?? "default"}"`, ) - await client.addMemory( + const { status } = await client.addMemory( params.text, { type: category, source: "openclaw_tool" }, customId, @@ -55,6 +55,17 @@ export function registerStoreTool( const preview = params.text.length > 80 ? `${params.text.slice(0, 80)}…` : params.text + if (status === "failed") { + return { + content: [ + { + type: "text" as const, + text: `Memory store failed (server returned status="failed") for: "${preview}"`, + }, + ], + } + } + return { content: [{ type: "text" as const, text: `Stored: "${preview}"` }], }