mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-01 02:01:40 +00:00
fix(tools): resolve test type errors and stale module imports (#1545)
This commit is contained in:
parent
c927c98f2c
commit
7b0fed3fb2
9 changed files with 66 additions and 15 deletions
|
|
@ -6,7 +6,10 @@
|
|||
* 2. Anthropic SDK integration
|
||||
*/
|
||||
|
||||
import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory"
|
||||
import {
|
||||
createClaudeMemoryTool,
|
||||
type MemoryCommand,
|
||||
} from "../src/claude-memory"
|
||||
|
||||
// =====================================================
|
||||
// Example 1: Direct TypeScript/fetch Integration
|
||||
|
|
@ -67,8 +70,7 @@ export async function directFetchExample() {
|
|||
]
|
||||
|
||||
// Execute each command
|
||||
for (let i = 0; i < commands.length; i++) {
|
||||
const command = commands[i]
|
||||
for (const [i, command] of commands.entries()) {
|
||||
console.log(
|
||||
`\n📝 Step ${i + 1}: ${command.command.toUpperCase()} ${command.path}`,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
* This shows actual tool call handling based on real Claude API responses
|
||||
*/
|
||||
|
||||
import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory"
|
||||
import {
|
||||
createClaudeMemoryTool,
|
||||
type MemoryCommand,
|
||||
} from "../src/claude-memory"
|
||||
|
||||
// =====================================================
|
||||
// Real Claude API Integration
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { describe, it, expect, beforeEach } from "vitest"
|
||||
import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory"
|
||||
import {
|
||||
createClaudeMemoryTool,
|
||||
type MemoryCommand,
|
||||
} from "../src/claude-memory"
|
||||
import "dotenv/config"
|
||||
|
||||
// Test configuration
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -153,6 +154,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -192,6 +194,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -234,6 +237,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList: createIntegrationMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args1)
|
||||
|
|
@ -248,6 +252,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList: createIntegrationMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args2)
|
||||
|
|
@ -283,6 +288,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -314,6 +320,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList: createIntegrationMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -347,6 +354,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList: createIntegrationMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -385,6 +393,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
requestContext,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -418,6 +427,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await input.processInput(inputArgs)
|
||||
|
|
@ -431,6 +441,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList: createIntegrationMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await output.processOutputResult(outputArgs)
|
||||
|
|
@ -471,6 +482,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await inputProcessor.processInput(args)
|
||||
|
|
@ -535,6 +547,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -559,6 +572,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList: createIntegrationMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -593,6 +607,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
const result = await processor.processInput(args)
|
||||
|
|
@ -617,6 +632,7 @@ describe.skipIf(!shouldRunIntegration)(
|
|||
messageList: createIntegrationMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await expect(processor.processOutputResult(args)).resolves.toBeDefined()
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -227,6 +228,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args1)
|
||||
|
|
@ -238,6 +240,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args2)
|
||||
|
|
@ -270,6 +273,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args1)
|
||||
|
|
@ -281,6 +285,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args2)
|
||||
|
|
@ -302,6 +307,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
const result = await processor.processInput(args)
|
||||
|
|
@ -333,6 +339,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
const result = await processor.processInput(args)
|
||||
|
|
@ -360,6 +367,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -390,6 +398,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
requestContext,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -432,6 +441,7 @@ describe("SupermemoryInputProcessor", () => {
|
|||
messageList,
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processInput(args)
|
||||
|
|
@ -499,6 +509,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -539,6 +550,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -567,6 +579,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -603,6 +616,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
requestContext,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -636,6 +650,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -672,6 +687,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -727,6 +743,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
@ -760,6 +777,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
// Should not throw
|
||||
|
|
@ -779,6 +797,7 @@ describe("SupermemoryOutputProcessor", () => {
|
|||
messageList: createMockMessageList(),
|
||||
abort: vi.fn() as never,
|
||||
retryCount: 0,
|
||||
state: {},
|
||||
}
|
||||
|
||||
await processor.processOutputResult(args)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ describe("OpenAI middleware memory context", () => {
|
|||
}),
|
||||
}),
|
||||
)
|
||||
const originalCreate = vi.fn(() =>
|
||||
const originalCreate = vi.fn((_body?: unknown) =>
|
||||
Object.assign(Promise.resolve({ choices: [] }), {
|
||||
asResponse: async () => new Response(),
|
||||
}),
|
||||
|
|
@ -53,8 +53,11 @@ describe("OpenAI middleware memory context", () => {
|
|||
],
|
||||
})
|
||||
|
||||
const forwarded = originalCreate.mock.calls[0]?.[0]
|
||||
const content = String(forwarded.messages[0].content)
|
||||
const forwarded = originalCreate.mock.calls[0]?.[0] as
|
||||
| { messages: Array<{ role: string; content: unknown }> }
|
||||
| undefined
|
||||
expect(forwarded).toBeDefined()
|
||||
const content = String(forwarded?.messages[0]?.content)
|
||||
expect(content).toContain("Be helpful.")
|
||||
expect(content).toContain("Fresh profile fact")
|
||||
expect(content).not.toContain("Stale profile fact")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
* Run with: bun run src/test-memory-tool.ts
|
||||
*/
|
||||
|
||||
import { createClaudeMemoryTool, type MemoryCommand } from "./claude-memory"
|
||||
import {
|
||||
createClaudeMemoryTool,
|
||||
type MemoryCommand,
|
||||
} from "../src/claude-memory"
|
||||
import "dotenv/config"
|
||||
|
||||
async function testMemoryTool() {
|
||||
|
|
@ -140,8 +143,7 @@ async function testMemoryTool() {
|
|||
let passed = 0
|
||||
let failed = 0
|
||||
|
||||
for (let i = 0; i < testCases.length; i++) {
|
||||
const testCase = testCases[i]
|
||||
for (const [i, testCase] of testCases.entries()) {
|
||||
console.log(`\\n🔄 Test ${i + 1}/${testCases.length}: ${testCase.name}`)
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -36,10 +36,13 @@ describe("VoltAgent memory context", () => {
|
|||
parts: [],
|
||||
},
|
||||
],
|
||||
} as Parameters<NonNullable<typeof hooks.onPrepareMessages>>[0]
|
||||
} as unknown as Parameters<NonNullable<typeof hooks.onPrepareMessages>>[0]
|
||||
const result = await hooks.onPrepareMessages?.(args)
|
||||
|
||||
const content = String(result?.messages?.[0]?.content ?? "")
|
||||
const firstMessage = result?.messages?.[0] as
|
||||
| Record<string, unknown>
|
||||
| undefined
|
||||
const content = String(firstMessage?.content ?? "")
|
||||
expect(content).toContain("Be helpful.")
|
||||
expect(content).toContain("Fresh profile fact")
|
||||
expect(content).not.toContain("Stale profile fact")
|
||||
|
|
|
|||
|
|
@ -561,8 +561,8 @@ describe("Unit: withSupermemory", () => {
|
|||
usage: {
|
||||
inputTokens: 1,
|
||||
outputTokens: 1,
|
||||
totalTokens: 2,
|
||||
},
|
||||
rawCall: { rawPrompt: [], rawSettings: {} },
|
||||
warnings: [],
|
||||
})
|
||||
|
||||
|
|
@ -626,8 +626,8 @@ describe("Unit: withSupermemory", () => {
|
|||
usage: {
|
||||
inputTokens: 1,
|
||||
outputTokens: 1,
|
||||
totalTokens: 2,
|
||||
},
|
||||
rawCall: { rawPrompt: [], rawSettings: {} },
|
||||
warnings: [],
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue