Skip to content

Commit 058c4ad

Browse files
committed
refactor: Rename sendCallTool/sendListTools to callTool/listTools
Avoid double-verb naming pattern for consistency with existing API.
1 parent 55ad06a commit 058c4ad

2 files changed

Lines changed: 38 additions & 38 deletions

File tree

src/app-bridge.test.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ describe("App <-> AppBridge integration", () => {
742742
await bridge.connect(bridgeTransport);
743743
});
744744

745-
it("bridge.sendCallTool calls app.oncalltool handler", async () => {
745+
it("bridge.callTool calls app.oncalltool handler", async () => {
746746
// App needs tool capabilities to handle tool calls
747747
const appCapabilities = { tools: {} };
748748
app = new App(testAppInfo, appCapabilities, { autoResize: false });
@@ -758,7 +758,7 @@ describe("App <-> AppBridge integration", () => {
758758

759759
await app.connect(appTransport);
760760

761-
const result = await bridge.sendCallTool({
761+
const result = await bridge.callTool({
762762
name: "test-tool",
763763
arguments: { foo: "bar" },
764764
});
@@ -773,7 +773,7 @@ describe("App <-> AppBridge integration", () => {
773773
]);
774774
});
775775

776-
it("bridge.sendListTools calls app.onlisttools handler", async () => {
776+
it("bridge.listTools calls app.onlisttools handler", async () => {
777777
// App needs tool capabilities to handle tool list requests
778778
const appCapabilities = { tools: {} };
779779
app = new App(testAppInfo, appCapabilities, { autoResize: false });
@@ -805,7 +805,7 @@ describe("App <-> AppBridge integration", () => {
805805

806806
await app.connect(appTransport);
807807

808-
const result = await bridge.sendListTools({});
808+
const result = await bridge.listTools({});
809809

810810
expect(receivedCalls).toHaveLength(1);
811811
expect(result.tools).toHaveLength(3);
@@ -831,7 +831,7 @@ describe("App <-> AppBridge integration", () => {
831831
await bridge.connect(bridgeTransport);
832832
await app.connect(appTransport);
833833

834-
await bridge.sendCallTool({
834+
await bridge.callTool({
835835
name: "test-tool",
836836
arguments: {},
837837
});
@@ -864,7 +864,7 @@ describe("App <-> AppBridge integration", () => {
864864
await bridge.connect(bridgeTransport);
865865
await app.connect(appTransport);
866866

867-
const result = await bridge.sendCallTool({
867+
const result = await bridge.callTool({
868868
name: "greet",
869869
arguments: { name: "Alice" },
870870
});
@@ -898,7 +898,7 @@ describe("App <-> AppBridge integration", () => {
898898
await app.connect(appTransport);
899899

900900
// Call the tool through bridge - should work automatically
901-
const result = await bridge.sendCallTool({
901+
const result = await bridge.callTool({
902902
name: "greet",
903903
arguments: { name: "Bob" },
904904
});
@@ -919,7 +919,7 @@ describe("App <-> AppBridge integration", () => {
919919

920920
// Try to call a tool that doesn't exist
921921
await expect(
922-
bridge.sendCallTool({
922+
bridge.callTool({
923923
name: "nonexistent",
924924
arguments: {},
925925
}),
@@ -968,7 +968,7 @@ describe("App <-> AppBridge integration", () => {
968968
await app.connect(appTransport);
969969

970970
// Call first tool
971-
const addResult = await bridge.sendCallTool({
971+
const addResult = await bridge.callTool({
972972
name: "add",
973973
arguments: { a: 5, b: 3 },
974974
});
@@ -977,7 +977,7 @@ describe("App <-> AppBridge integration", () => {
977977
]);
978978

979979
// Call second tool
980-
const multiplyResult = await bridge.sendCallTool({
980+
const multiplyResult = await bridge.callTool({
981981
name: "multiply",
982982
arguments: { a: 5, b: 3 },
983983
});
@@ -1004,15 +1004,15 @@ describe("App <-> AppBridge integration", () => {
10041004

10051005
// Should work when enabled
10061006
await expect(
1007-
bridge.sendCallTool({ name: "test-tool", arguments: {} }),
1007+
bridge.callTool({ name: "test-tool", arguments: {} }),
10081008
).resolves.toBeDefined();
10091009

10101010
// Disable tool
10111011
tool.disable();
10121012

10131013
// Should throw when disabled
10141014
await expect(
1015-
bridge.sendCallTool({ name: "test-tool", arguments: {} }),
1015+
bridge.callTool({ name: "test-tool", arguments: {} }),
10161016
).rejects.toThrow("Tool test-tool is disabled");
10171017
});
10181018

@@ -1038,15 +1038,15 @@ describe("App <-> AppBridge integration", () => {
10381038

10391039
// Valid input should work
10401040
await expect(
1041-
bridge.sendCallTool({
1041+
bridge.callTool({
10421042
name: "strict-tool",
10431043
arguments: { required: "hello" },
10441044
}),
10451045
).resolves.toBeDefined();
10461046

10471047
// Invalid input should fail
10481048
await expect(
1049-
bridge.sendCallTool({
1049+
bridge.callTool({
10501050
name: "strict-tool",
10511051
arguments: { wrong: "field" },
10521052
}),
@@ -1074,7 +1074,7 @@ describe("App <-> AppBridge integration", () => {
10741074
await app.connect(appTransport);
10751075

10761076
// Valid output should work
1077-
const result = await bridge.sendCallTool({
1077+
const result = await bridge.callTool({
10781078
name: "validated-output",
10791079
arguments: {},
10801080
});
@@ -1096,7 +1096,7 @@ describe("App <-> AppBridge integration", () => {
10961096
await app.connect(appTransport);
10971097

10981098
// First version
1099-
let result = await bridge.sendCallTool({
1099+
let result = await bridge.callTool({
11001100
name: "dynamic-tool",
11011101
arguments: {},
11021102
});
@@ -1107,7 +1107,7 @@ describe("App <-> AppBridge integration", () => {
11071107

11081108
// Should fail after removal
11091109
await expect(
1110-
bridge.sendCallTool({ name: "dynamic-tool", arguments: {} }),
1110+
bridge.callTool({ name: "dynamic-tool", arguments: {} }),
11111111
).rejects.toThrow("Tool dynamic-tool not found");
11121112

11131113
// Re-register with different behavior
@@ -1116,7 +1116,7 @@ describe("App <-> AppBridge integration", () => {
11161116
}));
11171117

11181118
// Should work with new version
1119-
result = await bridge.sendCallTool({
1119+
result = await bridge.callTool({
11201120
name: "dynamic-tool",
11211121
arguments: {},
11221122
});
@@ -1142,7 +1142,7 @@ describe("App <-> AppBridge integration", () => {
11421142

11431143
await app.connect(appTransport);
11441144

1145-
const result = await bridge.sendListTools({});
1145+
const result = await bridge.listTools({});
11461146

11471147
expect(result.tools).toHaveLength(3);
11481148
expect(result.tools.map((t) => t.name)).toContain("tool1");
@@ -1165,7 +1165,7 @@ describe("App <-> AppBridge integration", () => {
11651165
// Remove the tool after connecting
11661166
dummyTool.remove();
11671167

1168-
const result = await bridge.sendListTools({});
1168+
const result = await bridge.listTools({});
11691169

11701170
expect(result.tools).toEqual([]);
11711171
});
@@ -1184,7 +1184,7 @@ describe("App <-> AppBridge integration", () => {
11841184
dummy.remove();
11851185

11861186
// Initially no tools
1187-
let result = await bridge.sendListTools({});
1187+
let result = await bridge.listTools({});
11881188
expect(result.tools).toEqual([]);
11891189

11901190
// Add a tool
@@ -1193,7 +1193,7 @@ describe("App <-> AppBridge integration", () => {
11931193
}));
11941194

11951195
// Should now include the new tool
1196-
result = await bridge.sendListTools({});
1196+
result = await bridge.listTools({});
11971197
expect(result.tools.map((t) => t.name)).toEqual(["new-tool"]);
11981198

11991199
// Add another tool
@@ -1202,7 +1202,7 @@ describe("App <-> AppBridge integration", () => {
12021202
}));
12031203

12041204
// Should now include both tools
1205-
result = await bridge.sendListTools({});
1205+
result = await bridge.listTools({});
12061206
expect(result.tools).toHaveLength(2);
12071207
expect(result.tools.map((t) => t.name)).toContain("new-tool");
12081208
expect(result.tools.map((t) => t.name)).toContain("another-tool");
@@ -1225,14 +1225,14 @@ describe("App <-> AppBridge integration", () => {
12251225
await app.connect(appTransport);
12261226

12271227
// Initially all three tools
1228-
let result = await bridge.sendListTools({});
1228+
let result = await bridge.listTools({});
12291229
expect(result.tools).toHaveLength(3);
12301230

12311231
// Remove one tool
12321232
tool2.remove();
12331233

12341234
// Should now have two tools
1235-
result = await bridge.sendListTools({});
1235+
result = await bridge.listTools({});
12361236
expect(result.tools).toHaveLength(2);
12371237
expect(result.tools.map((t) => t.name)).toContain("tool1");
12381238
expect(result.tools.map((t) => t.name)).toContain("tool3");
@@ -1242,7 +1242,7 @@ describe("App <-> AppBridge integration", () => {
12421242
tool1.remove();
12431243

12441244
// Should now have one tool
1245-
result = await bridge.sendListTools({});
1245+
result = await bridge.listTools({});
12461246
expect(result.tools.map((t) => t.name)).toEqual(["tool3"]);
12471247
});
12481248

@@ -1270,7 +1270,7 @@ describe("App <-> AppBridge integration", () => {
12701270
// Disable one tool after connecting
12711271
tool2.disable();
12721272

1273-
const result = await bridge.sendListTools({});
1273+
const result = await bridge.listTools({});
12741274

12751275
// Only enabled tool should be in the list
12761276
expect(result.tools).toHaveLength(1);
@@ -1299,11 +1299,11 @@ describe("App <-> AppBridge integration", () => {
12991299
);
13001300

13011301
// List should include the tool
1302-
let listResult = await bridge.sendListTools({});
1302+
let listResult = await bridge.listTools({});
13031303
expect(listResult.tools.map((t) => t.name)).toContain("counter");
13041304

13051305
// Call the tool
1306-
let callResult = await bridge.sendCallTool({
1306+
let callResult = await bridge.callTool({
13071307
name: "counter",
13081308
arguments: {},
13091309
});
@@ -1315,7 +1315,7 @@ describe("App <-> AppBridge integration", () => {
13151315
tool.update({ description: "An updated counter tool" });
13161316

13171317
// Should still be callable
1318-
callResult = await bridge.sendCallTool({
1318+
callResult = await bridge.callTool({
13191319
name: "counter",
13201320
arguments: {},
13211321
});
@@ -1325,12 +1325,12 @@ describe("App <-> AppBridge integration", () => {
13251325
tool.remove();
13261326

13271327
// Should no longer be in list
1328-
listResult = await bridge.sendListTools({});
1328+
listResult = await bridge.listTools({});
13291329
expect(listResult.tools.map((t) => t.name)).not.toContain("counter");
13301330

13311331
// Should no longer be callable
13321332
await expect(
1333-
bridge.sendCallTool({ name: "counter", arguments: {} }),
1333+
bridge.callTool({ name: "counter", arguments: {} }),
13341334
).rejects.toThrow("Tool counter not found");
13351335
});
13361336

@@ -1381,19 +1381,19 @@ describe("App <-> AppBridge integration", () => {
13811381
await app2.connect(app2Transport);
13821382

13831383
// Each app should only see its own tools
1384-
const list1 = await bridge1.sendListTools({});
1384+
const list1 = await bridge1.listTools({});
13851385
expect(list1.tools.map((t) => t.name)).toEqual(["app1-tool"]);
13861386

1387-
const list2 = await bridge2.sendListTools({});
1387+
const list2 = await bridge2.listTools({});
13881388
expect(list2.tools.map((t) => t.name)).toEqual(["app2-tool"]);
13891389

13901390
// Each app should only be able to call its own tools
13911391
await expect(
1392-
bridge1.sendCallTool({ name: "app1-tool", arguments: {} }),
1392+
bridge1.callTool({ name: "app1-tool", arguments: {} }),
13931393
).resolves.toBeDefined();
13941394

13951395
await expect(
1396-
bridge1.sendCallTool({ name: "app2-tool", arguments: {} }),
1396+
bridge1.callTool({ name: "app2-tool", arguments: {} }),
13971397
).rejects.toThrow("Tool app2-tool not found");
13981398

13991399
// Clean up

src/app-bridge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,15 +1247,15 @@ export class AppBridge extends Protocol<
12471247
/** @deprecated Use {@link teardownResource} instead */
12481248
sendResourceTeardown: AppBridge["teardownResource"] = this.teardownResource;
12491249

1250-
sendCallTool(params: CallToolRequest["params"], options?: RequestOptions) {
1250+
callTool(params: CallToolRequest["params"], options?: RequestOptions) {
12511251
return this.request(
12521252
{ method: "tools/call", params },
12531253
CallToolResultSchema,
12541254
options,
12551255
);
12561256
}
12571257

1258-
sendListTools(params: ListToolsRequest["params"], options?: RequestOptions) {
1258+
listTools(params: ListToolsRequest["params"], options?: RequestOptions) {
12591259
return this.request(
12601260
{ method: "tools/list", params },
12611261
ListToolsResultSchema,

0 commit comments

Comments
 (0)