Skip to content

Commit 3232ca8

Browse files
committed
refactor: ♻️
1 parent 0836a8f commit 3232ca8

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
@@ -138,9 +138,9 @@ export class ToolPermissionService
138138
}));
139139
policies.push(...allowed);
140140
const specificBuiltInSet = new Set(specificBuiltIns);
141-
const notMentioned = ALL_BUILT_IN_TOOLS.map((t) => t.name).filter(
142-
(name) => !specificBuiltInSet.has(name),
143-
);
141+
const notMentioned = ALL_BUILT_IN_TOOLS.map(
142+
(t) => t.function.name,
143+
).filter((name) => !specificBuiltInSet.has(name));
144144
const disallowed: ToolPermissionPolicy[] = notMentioned.map((tool) => ({
145145
tool,
146146
permission: "exclude",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ export async function preprocessStreamedToolCalls(
314314
const startTime = Date.now();
315315
try {
316316
const availableTools: Tool[] = await getAllAvailableTools(isHeadless);
317-
const tool = availableTools.find((t) => t.name === toolCall.name);
317+
const tool = availableTools.find(
318+
(t) => t.function.name === toolCall.name,
319+
);
318320
if (!tool) {
319321
throw new Error(`Tool ${toolCall.name} not found`);
320322
}

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

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

138138
it("should have correct tool metadata", () => {
139-
expect(fetchTool.name).toBe("Fetch");
140-
expect(fetchTool.displayName).toBe("Fetch");
141-
expect(fetchTool.description).toBe(
139+
expect(fetchTool.function.name).toBe("Fetch");
140+
expect(fetchTool.displayTitle).toBe("Fetch");
141+
expect(fetchTool.function.description).toBe(
142142
"Fetches content from a URL, converts to markdown, and handles long content with truncation",
143143
);
144144
expect(fetchTool.readonly).toBe(true);
145145
expect(fetchTool.isBuiltIn).toBe(true);
146-
expect(fetchTool.parameters).toEqual({
146+
expect(fetchTool.function.parameters).toEqual({
147147
type: "object",
148148
required: ["url"],
149149
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)