Skip to content

Commit c078b37

Browse files
committed
refactor: ♻️
1 parent 451b704 commit c078b37

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

extensions/cli/src/permissions/permissionChecker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export function checkToolPermission(
147147
}
148148

149149
// Check if tool has dynamic policy evaluation
150-
const tool = ALL_BUILT_IN_TOOLS.find((t) => t.name === toolCall.name);
150+
const tool = ALL_BUILT_IN_TOOLS.find(
151+
(t) => t.function.name === toolCall.name,
152+
);
151153
if (tool?.evaluateToolCallPolicy) {
152154
// Convert CLI permission to core policy
153155
const basePolicy = permissionPolicyToToolPolicy(basePermission);

extensions/cli/src/services/ToolPermissionService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ export class ToolPermissionService
143143
}));
144144
policies.push(...allowed);
145145
const specificBuiltInSet = new Set(specificBuiltIns);
146-
const notMentioned = ALL_BUILT_IN_TOOLS.map((t) => t.name).filter(
147-
(name) => !specificBuiltInSet.has(name),
148-
);
146+
const notMentioned = ALL_BUILT_IN_TOOLS.map(
147+
(t) => t.function.name,
148+
).filter((name) => !specificBuiltInSet.has(name));
149149
const disallowed: ToolPermissionPolicy[] = notMentioned.map((tool) => ({
150150
tool,
151151
permission: "exclude",

extensions/cli/src/stream/streamChatResponse.helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ export async function preprocessStreamedToolCalls(
319319
const startTime = Date.now();
320320
try {
321321
const availableTools: Tool[] = await getAllAvailableTools(isHeadless);
322-
const tool = availableTools.find((t) => t.name === toolCall.name);
322+
const tool = availableTools.find(
323+
(t) => t.function.name === toolCall.name,
324+
);
323325
if (!tool) {
324326
throw new Error(`Tool ${toolCall.name} not found`);
325327
}

extensions/cli/src/tools/fetch.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ describe("fetchTool", () => {
134134
});
135135

136136
it("should have correct tool metadata", () => {
137-
expect(fetchTool.name).toBe("Fetch");
138-
expect(fetchTool.displayName).toBe("Fetch");
139-
expect(fetchTool.description).toBe(
137+
expect(fetchTool.function.name).toBe("Fetch");
138+
expect(fetchTool.displayTitle).toBe("Fetch");
139+
expect(fetchTool.function.description).toBe(
140140
"Fetches content from a URL, converts to markdown, and handles long content with truncation",
141141
);
142142
expect(fetchTool.readonly).toBe(true);
143143
expect(fetchTool.isBuiltIn).toBe(true);
144-
expect(fetchTool.parameters).toEqual({
144+
expect(fetchTool.function.parameters).toEqual({
145145
type: "object",
146146
required: ["url"],
147147
properties: {

extensions/cli/src/tools/writeChecklist.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ describe("writeChecklistTool", () => {
1212
});
1313

1414
it("should have correct tool properties", () => {
15-
expect(writeChecklistTool.name).toBe("Checklist");
16-
expect(writeChecklistTool.displayName).toBe("Checklist");
15+
expect(writeChecklistTool.function.name).toBe("Checklist");
16+
expect(writeChecklistTool.displayTitle).toBe("Checklist");
1717
expect(writeChecklistTool.readonly).toBe(false);
1818
expect(writeChecklistTool.isBuiltIn).toBe(true);
19-
expect(writeChecklistTool.parameters.required?.includes("checklist")).toBe(
20-
true,
21-
);
19+
expect(
20+
writeChecklistTool.function.parameters?.required?.includes("checklist"),
21+
).toBe(true);
2222
});
2323
});

0 commit comments

Comments
 (0)