diff options
| author | Shoubhit Dash <[email protected]> | 2026-01-30 21:08:11 +0530 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2026-01-30 21:09:12 -0700 |
| commit | 05ecc18e4f0eef6d3b88b0e459b43ad9f13ce8cf (patch) | |
| tree | 84d930a7fccccff3a6d54295ee8ecec8d0acedb0 /packages/tools/src | |
| parent | done (diff) | |
| download | supermemory-01-30-mastra_integration.tar.xz supermemory-01-30-mastra_integration.zip | |
format and lint01-30-mastra_integration
Diffstat (limited to 'packages/tools/src')
| -rw-r--r-- | packages/tools/src/claude-memory.ts | 17 | ||||
| -rw-r--r-- | packages/tools/src/mastra/processor.ts | 4 | ||||
| -rw-r--r-- | packages/tools/src/shared/memory-client.ts | 10 | ||||
| -rw-r--r-- | packages/tools/src/tools.test.ts | 8 |
4 files changed, 19 insertions, 20 deletions
diff --git a/packages/tools/src/claude-memory.ts b/packages/tools/src/claude-memory.ts index 08d49e63..b65c8ff9 100644 --- a/packages/tools/src/claude-memory.ts +++ b/packages/tools/src/claude-memory.ts @@ -57,15 +57,6 @@ export class ClaudeMemoryTool { .replace(/\./g, "_") // Replace . with _ } - /** - * Convert customId back to file path - * Note: This is lossy since we can't distinguish _ from . or / - * We rely on metadata.file_path for accurate path reconstruction - */ - private customIdToPath(customId: string): string { - return "/" + customId.replace(/_/g, "/") - } - constructor(apiKey: string, config?: ClaudeMemoryConfig) { this.client = new Supermemory({ apiKey, @@ -182,7 +173,7 @@ export class ClaudeMemoryTool { // If path ends with / or is exactly /memories, it's a directory listing request if (path.endsWith("/") || path === "/memories") { // Normalize path to end with / - const dirPath = path.endsWith("/") ? path : path + "/" + const dirPath = path.endsWith("/") ? path : `${path}/` return await this.listDirectory(dirPath) } @@ -227,7 +218,7 @@ export class ClaudeMemoryTool { const slashIndex = relativePath.indexOf("/") if (slashIndex > 0) { // It's a subdirectory - dirs.add(relativePath.substring(0, slashIndex) + "/") + dirs.add(`${relativePath.substring(0, slashIndex)}/`) } else if (relativePath !== "") { // It's a file in this directory files.push(relativePath) @@ -335,7 +326,7 @@ export class ClaudeMemoryTool { try { const normalizedId = this.normalizePathToCustomId(filePath) - const response = await this.client.add({ + const _response = await this.client.add({ content: fileText, customId: normalizedId, containerTags: this.containerTags, @@ -394,7 +385,7 @@ export class ClaudeMemoryTool { // Update the document const normalizedId = this.normalizePathToCustomId(filePath) - const updateResponse = await this.client.add({ + const _updateResponse = await this.client.add({ content: newContent, customId: normalizedId, containerTags: this.containerTags, diff --git a/packages/tools/src/mastra/processor.ts b/packages/tools/src/mastra/processor.ts index a75d1efc..d2975127 100644 --- a/packages/tools/src/mastra/processor.ts +++ b/packages/tools/src/mastra/processor.ts @@ -301,7 +301,9 @@ export class SupermemoryOutputProcessor implements Processor { const textParts = content.parts .filter( (part): part is { type: "text"; text: string } => - part.type === "text" && "text" in part && typeof part.text === "string", + part.type === "text" && + "text" in part && + typeof part.text === "string", ) .map((part) => ({ type: "text" as const, diff --git a/packages/tools/src/shared/memory-client.ts b/packages/tools/src/shared/memory-client.ts index 5308d3de..d55926c0 100644 --- a/packages/tools/src/shared/memory-client.ts +++ b/packages/tools/src/shared/memory-client.ts @@ -214,7 +214,10 @@ export const extractQueryText = ( .join(" ") } - const objContent = content as unknown as { content?: string; parts?: Array<{ type: string; text?: string }> } + const objContent = content as unknown as { + content?: string + parts?: Array<{ type: string; text?: string }> + } if (typeof objContent === "object" && objContent !== null) { if ("content" in objContent && typeof objContent.content === "string") { return objContent.content @@ -261,7 +264,10 @@ export const getLastUserMessageText = ( .join(" ") } - const objContent = content as unknown as { content?: string; parts?: Array<{ type: string; text?: string }> } + const objContent = content as unknown as { + content?: string + parts?: Array<{ type: string; text?: string }> + } if (typeof objContent === "object" && objContent !== null) { if ("content" in objContent && typeof objContent.content === "string") { return objContent.content diff --git a/packages/tools/src/tools.test.ts b/packages/tools/src/tools.test.ts index 32a49a2e..ab6f9b84 100644 --- a/packages/tools/src/tools.test.ts +++ b/packages/tools/src/tools.test.ts @@ -165,16 +165,16 @@ describe("@supermemory/tools", () => { (d) => d.function.name === "searchMemories", ) expect(searchTool).toBeDefined() - expect(searchTool!.type).toBe("function") - expect(searchTool!.function.parameters?.required).toContain( + expect(searchTool?.type).toBe("function") + expect(searchTool?.function.parameters?.required).toContain( "informationToGet", ) // Check addMemory const addTool = definitions.find((d) => d.function.name === "addMemory") expect(addTool).toBeDefined() - expect(addTool!.type).toBe("function") - expect(addTool!.function.parameters?.required).toContain("memory") + expect(addTool?.type).toBe("function") + expect(addTool?.function.parameters?.required).toContain("memory") }) }) |