diff options
| -rw-r--r-- | apps/docs/test.ts | 6 | ||||
| -rw-r--r-- | packages/tools/package.json | 2 | ||||
| -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 | ||||
| -rw-r--r-- | packages/tools/test/anthropic-example.ts | 6 | ||||
| -rw-r--r-- | packages/tools/test/claude-memory-examples.ts | 6 | ||||
| -rw-r--r-- | packages/tools/test/claude-memory-real-example.ts | 4 | ||||
| -rw-r--r-- | packages/tools/test/mastra/integration.test.ts | 16 | ||||
| -rw-r--r-- | packages/tools/test/mastra/unit.test.ts | 5 |
11 files changed, 45 insertions, 39 deletions
diff --git a/apps/docs/test.ts b/apps/docs/test.ts index 21c8bb8e..8eab02ff 100644 --- a/apps/docs/test.ts +++ b/apps/docs/test.ts @@ -15,7 +15,7 @@ const conversation = [ // Get user profile + relevant memories for context const profile = await client.profile({ containerTag: USER_ID, - q: conversation.at(-1)!.content, + q: conversation.at(-1)?.content, }) const context = `Static profile: @@ -25,10 +25,10 @@ Dynamic profile: ${profile.profile.dynamic.join("\n")} Relevant memories: -${profile.searchResults?.results.map((r) => r["content"]).join("\n")}` +${profile.searchResults?.results.map((r) => r.content).join("\n")}` // Build messages with memory-enriched context -const messages = [ +const _messages = [ { role: "system", content: `User context:\n${context}` }, ...conversation, ] diff --git a/packages/tools/package.json b/packages/tools/package.json index 4aff1972..39cde98d 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -1,7 +1,7 @@ { "name": "@supermemory/tools", "type": "module", - "version": "1.3.68", + "version": "1.4.00", "description": "Memory tools for AI SDK and OpenAI function calling with supermemory", "scripts": { "build": "tsdown", 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") }) }) diff --git a/packages/tools/test/anthropic-example.ts b/packages/tools/test/anthropic-example.ts index cfb82ddb..0da95b77 100644 --- a/packages/tools/test/anthropic-example.ts +++ b/packages/tools/test/anthropic-example.ts @@ -97,7 +97,7 @@ async function chatWithMemoryTool() { if (memoryResult.content) { console.log( "📄 Content preview:", - memoryResult.content.substring(0, 100) + "...", + `${memoryResult.content.substring(0, 100)}...`, ) } } @@ -256,7 +256,7 @@ async function testMemoryOperations() { } else if (result.content) { console.log( "📄 Result:", - result.content.substring(0, 150) + "... (truncated)", + `${result.content.substring(0, 150)}... (truncated)`, ) } } else { @@ -275,7 +275,7 @@ async function testMemoryOperations() { // Run the examples async function main() { await testMemoryOperations() - console.log("\n" + "=".repeat(70) + "\n") + console.log(`\n${"=".repeat(70)}\n`) await chatWithMemoryTool() } diff --git a/packages/tools/test/claude-memory-examples.ts b/packages/tools/test/claude-memory-examples.ts index 6921d151..f37a47fa 100644 --- a/packages/tools/test/claude-memory-examples.ts +++ b/packages/tools/test/claude-memory-examples.ts @@ -314,14 +314,14 @@ export async function runAllExamples() { try { await directFetchExample() - console.log("\\n" + "=".repeat(70) + "\\n") + console.log(`\\n${"=".repeat(70)}\\n`) await anthropicSdkExample() - console.log("\\n" + "=".repeat(70)) + console.log(`\\n${"=".repeat(70)}`) console.log("📋 Real Anthropic SDK Integration Template:") console.log(anthropicIntegrationTemplate) - console.log("\\n" + "=".repeat(70)) + console.log(`\\n${"=".repeat(70)}`) console.log("🔧 cURL Examples for Direct API Testing:") console.log(curlExamples) } catch (error) { diff --git a/packages/tools/test/claude-memory-real-example.ts b/packages/tools/test/claude-memory-real-example.ts index 06ebb546..1124faa8 100644 --- a/packages/tools/test/claude-memory-real-example.ts +++ b/packages/tools/test/claude-memory-real-example.ts @@ -326,7 +326,7 @@ export async function runRealExamples() { // Test with the actual tool call first await testWithRealToolCall() - console.log("\\n" + "=".repeat(70) + "\\n") + console.log(`\\n${"=".repeat(70)}\\n`) // Show web integration example console.log("🌐 Web Framework Integration Example:") @@ -334,7 +334,7 @@ export async function runRealExamples() { // Only run full API example if both keys are present if (process.env.ANTHROPIC_API_KEY && process.env.SUPERMEMORY_API_KEY) { - console.log("\\n" + "=".repeat(70) + "\\n") + console.log(`\\n${"=".repeat(70)}\\n`) await realClaudeMemoryExample() } else { console.log( diff --git a/packages/tools/test/mastra/integration.test.ts b/packages/tools/test/mastra/integration.test.ts index 82c0f168..f33b974e 100644 --- a/packages/tools/test/mastra/integration.test.ts +++ b/packages/tools/test/mastra/integration.test.ts @@ -3,8 +3,11 @@ * Tests processors and wrapper with real Supermemory API calls */ -import { describe, it, expect, vi, beforeEach, afterEach } from "vitest" -import { RequestContext, MASTRA_THREAD_ID_KEY } from "@mastra/core/request-context" +import { describe, it, expect, vi } from "vitest" +import { + RequestContext, + MASTRA_THREAD_ID_KEY, +} from "@mastra/core/request-context" import { SupermemoryInputProcessor, SupermemoryOutputProcessor, @@ -141,7 +144,10 @@ describe.skipIf(!shouldRunIntegration)( const messageList = createIntegrationMessageList() const args: ProcessInputArgs = { messages: [ - createMessage("user", "What are my favorite programming languages?"), + createMessage( + "user", + "What are my favorite programming languages?", + ), ], systemMessages: [], messageList, @@ -633,9 +639,7 @@ describe.skipIf(!shouldRunIntegration)( retryCount: 0, } - await expect( - processor.processOutputResult(args), - ).resolves.toBeDefined() + await expect(processor.processOutputResult(args)).resolves.toBeDefined() }) }) }, diff --git a/packages/tools/test/mastra/unit.test.ts b/packages/tools/test/mastra/unit.test.ts index 26a4f6d7..0161546d 100644 --- a/packages/tools/test/mastra/unit.test.ts +++ b/packages/tools/test/mastra/unit.test.ts @@ -4,7 +4,10 @@ */ import { describe, it, expect, beforeEach, vi, afterEach } from "vitest" -import { RequestContext, MASTRA_THREAD_ID_KEY } from "@mastra/core/request-context" +import { + RequestContext, + MASTRA_THREAD_ID_KEY, +} from "@mastra/core/request-context" import { SupermemoryInputProcessor, SupermemoryOutputProcessor, |