test(tools): type scoped operation results

This commit is contained in:
shamAnimates 2026-08-16 08:14:26 +05:30
parent da19beafb2
commit d09b7026f9

View file

@ -30,9 +30,15 @@ import * as openAi from "./openai/tools"
const API_KEY = "sm_test_key"
type ToolWithExecute = { execute: (args: Record<string, unknown>) => unknown }
type ToolExecutionResult = { success: boolean; error?: string }
type ToolWithExecute = {
execute: (args: Record<string, unknown>) => Promise<ToolExecutionResult>
}
function executeTool(tool: unknown, args: Record<string, unknown>) {
function executeTool(
tool: unknown,
args: Record<string, unknown>,
): Promise<ToolExecutionResult> {
return (tool as ToolWithExecute).execute(args)
}
@ -57,7 +63,7 @@ describe("configured container scope", () => {
const fetchMock = vi.fn()
vi.stubGlobal("fetch", fetchMock)
const results = (await Promise.all([
const results: ToolExecutionResult[] = await Promise.all([
executeTool(aiSdk.getProfileTool(API_KEY, config), {
containerTag: "tenant-b",
}),
@ -87,7 +93,7 @@ describe("configured container scope", () => {
containerTag: "tenant-b",
memoryId: "mem_1",
}),
])) as Array<{ success: boolean; error?: string }>
])
expect(results).toHaveLength(6)
for (const result of results) {