Skip to content

Commit 55ad06a

Browse files
committed
fix: Update RegisteredTool to use 'handler' instead of 'callback' (SDK API change)
1 parent aec100a commit 55ad06a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/app-bridge.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ describe("App <-> AppBridge integration", () => {
655655
sendRequest: async () => ({}),
656656
} as any;
657657

658-
await expect((tool.callback as any)(mockExtra)).rejects.toThrow(
658+
await expect((tool.handler as any)(mockExtra)).rejects.toThrow(
659659
"Tool test-tool is disabled",
660660
);
661661
});
@@ -683,12 +683,12 @@ describe("App <-> AppBridge integration", () => {
683683

684684
// Valid input should work
685685
await expect(
686-
(tool.callback as any)({ name: "Alice" }, mockExtra),
686+
(tool.handler as any)({ name: "Alice" }, mockExtra),
687687
).resolves.toBeDefined();
688688

689689
// Invalid input should fail
690690
await expect(
691-
(tool.callback as any)({ invalid: "field" }, mockExtra),
691+
(tool.handler as any)({ invalid: "field" }, mockExtra),
692692
).rejects.toThrow("Invalid input for tool greet");
693693
});
694694

@@ -715,7 +715,7 @@ describe("App <-> AppBridge integration", () => {
715715
} as any;
716716

717717
// Valid output should work
718-
await expect((tool.callback as any)(mockExtra)).resolves.toBeDefined();
718+
await expect((tool.handler as any)(mockExtra)).resolves.toBeDefined();
719719
});
720720

721721
it("tool enable/disable/update/remove trigger sendToolListChanged", async () => {
@@ -856,7 +856,7 @@ describe("App <-> AppBridge integration", () => {
856856

857857
app.oncalltool = async (params, extra) => {
858858
if (params.name === "greet") {
859-
return await (tool.callback as any)(params.arguments || {}, extra);
859+
return await (tool.handler as any)(params.arguments || {}, extra);
860860
}
861861
throw new Error(`Unknown tool: ${params.name}`);
862862
};

src/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
297297
delete app._registeredTools[name];
298298
app.sendToolListChanged();
299299
},
300-
callback: (async (args: any, extra: RequestHandlerExtra) => {
300+
handler: (async (args: any, extra: RequestHandlerExtra) => {
301301
if (!registeredTool.enabled) {
302302
throw new Error(`Tool ${name} is disabled`);
303303
}
@@ -313,7 +313,7 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
313313
}
314314
args = parseResult.data;
315315
}
316-
const result = await cb(args, extra);
316+
const result = await cb(args, extra as any);
317317
if (config.outputSchema) {
318318
const parseResult = await safeParseAsync(
319319
config.outputSchema as any,
@@ -348,7 +348,7 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
348348
if (!tool) {
349349
throw new Error(`Tool ${params.name} not found`);
350350
}
351-
return tool.callback(params.arguments as any, extra);
351+
return (tool.handler as any)(params.arguments as any, extra);
352352
};
353353
this.onlisttools = async (_params, _extra) => {
354354
const tools: Tool[] = Object.entries(this._registeredTools)

0 commit comments

Comments
 (0)