Skip to content

Commit 4b862ac

Browse files
committed
Restore tool metadata responses
1 parent ca5cb66 commit 4b862ac

7 files changed

Lines changed: 47 additions & 29 deletions

File tree

apps/cli/src/main.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,29 +1065,28 @@ const runCallHelp = (
10651065
? tools.find((tool) => tool.id === inspection.exactPath)
10661066
: undefined;
10671067

1068-
const exactToolSchema = exactTool
1069-
? yield* client.tools
1070-
.schema({
1071-
params: {
1072-
scopeId: scopeInfo.id,
1073-
toolId: exactTool.id,
1074-
},
1075-
})
1076-
.pipe(Effect.catchCause(() => Effect.succeed(undefined)))
1077-
: undefined;
1078-
10791068
if (exactTool && inspection.children.length === 0) {
1069+
const schema = yield* client.tools
1070+
.schema({
1071+
params: {
1072+
scopeId: scopeInfo.id,
1073+
toolId: exactTool.id,
1074+
},
1075+
})
1076+
.pipe(
1077+
Effect.map((result) => ({
1078+
inputTypeScript: result.inputTypeScript,
1079+
outputTypeScript: result.outputTypeScript,
1080+
})),
1081+
Effect.catchCause(() => Effect.succeed(undefined)),
1082+
);
1083+
10801084
yield* printCallLeafHelp({
10811085
tool: {
10821086
id: exactTool.id,
1083-
description: exactToolSchema?.description,
1087+
description: exactTool.description,
10841088
},
1085-
schema: exactToolSchema
1086-
? {
1087-
inputTypeScript: exactToolSchema.inputTypeScript,
1088-
outputTypeScript: exactToolSchema.outputTypeScript,
1089-
}
1090-
: undefined,
1089+
schema,
10911090
});
10921091
return;
10931092
}
@@ -1107,7 +1106,7 @@ const runCallHelp = (
11071106
exactTool: exactTool
11081107
? {
11091108
id: exactTool.id,
1110-
description: exactToolSchema?.description,
1109+
description: exactTool.description,
11111110
}
11121111
: undefined,
11131112
});

apps/cloud/src/services/sources-refresh.node.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ describe("sources.refresh (HTTP)", () => {
123123
}),
124124
);
125125
expect(beforeTools.length).toBe(1);
126-
expect(beforeTools.some((t) => t.id.startsWith(`${namespace}.ping.`))).toBe(true);
127-
expect(beforeTools.some((t) => t.id.startsWith(`${namespace}.pong.`))).toBe(false);
126+
expect(beforeTools.some((t) => t.name.startsWith("ping"))).toBe(true);
127+
expect(beforeTools.some((t) => t.name.startsWith("pong"))).toBe(false);
128128

129129
// Flip the remote to v2 (adds `pong`) and trigger refresh.
130130
server.setSpec(specV2);
@@ -144,8 +144,8 @@ describe("sources.refresh (HTTP)", () => {
144144
}),
145145
);
146146
expect(afterTools.length).toBe(2);
147-
expect(afterTools.some((t) => t.id.startsWith(`${namespace}.ping.`))).toBe(true);
148-
expect(afterTools.some((t) => t.id.startsWith(`${namespace}.pong.`))).toBe(true);
147+
expect(afterTools.some((t) => t.name.startsWith("ping"))).toBe(true);
148+
expect(afterTools.some((t) => t.name.startsWith("pong"))).toBe(true);
149149
}),
150150
),
151151
);

apps/cloud/src/services/tenant-isolation.node.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ describe("tenant isolation (HTTP)", () => {
140140
const orgBTools = yield* asOrg(orgB, (client) =>
141141
client.tools.list({ params: { scopeId: ScopeId.make(orgB) } }),
142142
);
143+
expect(orgBTools.map((t) => t.sourceId)).not.toContain(namespaceA);
143144
for (const id of orgBTools.map((t) => t.id)) {
144145
expect(id).not.toContain(namespaceA);
145146
}

packages/core/api/src/handlers/sources.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ export const SourcesHandlers = HttpApiBuilder.group(ExecutorApi, "sources", (han
6161
});
6262
return tools.map((t) => ({
6363
id: ToolId.make(t.id),
64-
...(t.annotations?.requiresApproval !== undefined
65-
? { requiresApproval: t.annotations.requiresApproval }
66-
: {}),
64+
pluginId: t.pluginId,
65+
sourceId: t.sourceId,
66+
name: t.name,
67+
description: t.description,
68+
mayElicit: t.annotations?.mayElicit,
69+
requiresApproval: t.annotations?.requiresApproval,
70+
approvalDescription: t.annotations?.approvalDescription,
6771
}));
6872
}),
6973
),

packages/core/api/src/handlers/tools.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ export const ToolsHandlers = HttpApiBuilder.group(ExecutorApi, "tools", (handler
2121
});
2222
return tools.map((t) => ({
2323
id: ToolId.make(t.id),
24-
...(t.annotations?.requiresApproval !== undefined
25-
? { requiresApproval: t.annotations.requiresApproval }
26-
: {}),
24+
pluginId: t.pluginId,
25+
sourceId: t.sourceId,
26+
name: t.name,
27+
description: t.description,
28+
mayElicit: t.annotations?.mayElicit,
29+
requiresApproval: t.annotations?.requiresApproval,
2730
}));
2831
}),
2932
),

packages/core/api/src/sources/api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@ const SourceRefreshResponse = Schema.Struct({
4040

4141
const ToolMetadataResponse = Schema.Struct({
4242
id: ToolId,
43+
pluginId: Schema.String,
44+
sourceId: Schema.String,
45+
name: Schema.String,
46+
description: Schema.optional(Schema.String),
47+
mayElicit: Schema.optional(Schema.Boolean),
4348
/** Plugin-derived default approval annotation. Surfaces in the UI as
4449
* the "default" policy when no user `tool_policy` rule matches. */
4550
requiresApproval: Schema.optional(Schema.Boolean),
51+
approvalDescription: Schema.optional(Schema.String),
4652
});
4753

4854
const DetectRequest = Schema.Struct({

packages/core/api/src/tools/api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const PathParams = {
1717

1818
const ToolMetadataResponse = Schema.Struct({
1919
id: ToolId,
20+
pluginId: Schema.String,
21+
sourceId: Schema.String,
22+
name: Schema.String,
23+
description: Schema.optional(Schema.String),
24+
mayElicit: Schema.optional(Schema.Boolean),
2025
requiresApproval: Schema.optional(Schema.Boolean),
2126
});
2227

0 commit comments

Comments
 (0)