diff --git a/src/core/task/__tests__/Task.persistence.spec.ts b/src/core/task/__tests__/Task.persistence.spec.ts index 109eee8dc0..fb7a4e8cc6 100644 --- a/src/core/task/__tests__/Task.persistence.spec.ts +++ b/src/core/task/__tests__/Task.persistence.spec.ts @@ -20,7 +20,7 @@ import { ClineProvider } from "../../webview/ClineProvider" import { ContextProxy } from "../../config/ContextProxy" import { providerIdentifiers } from "@roo-code/types/provider-identifiers" import { attemptCompletionTool, type AttemptCompletionCallbacks } from "../../tools/AttemptCompletionTool" -import type { AttemptCompletionToolUse } from "../../../shared/tools" +import type { ToolUse } from "../../../shared/tools" type TaskPersistenceAccess = { addToApiConversationHistory: (message: Anthropic.MessageParam) => Promise @@ -533,7 +533,7 @@ describe("Task persistence", () => { completionEmitted = true }) - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", id: completionCallId, name: "attempt_completion", diff --git a/src/core/task/__tests__/truncated-native-tool-args.spec.ts b/src/core/task/__tests__/truncated-native-tool-args.spec.ts index 4cc6f313e6..898e1a7426 100644 --- a/src/core/task/__tests__/truncated-native-tool-args.spec.ts +++ b/src/core/task/__tests__/truncated-native-tool-args.spec.ts @@ -21,7 +21,7 @@ */ import { isValidToolName } from "../../tools/validateToolUse" -import type { ToolUse, WriteToFileToolUse } from "../../../shared/tools" +import type { ToolUse } from "../../../shared/tools" describe("Truncated native tool-call args on finalize failure (issue #1221)", () => { /** @@ -60,7 +60,7 @@ describe("Truncated native tool-call args on finalize failure (issue #1221)", () // A write_to_file call whose `content` was cut off mid-stream - exactly // the scenario in #1221. The streaming phase already populated nativeArgs // from the incomplete partial-json parse before finalize failed. - const truncated: WriteToFileToolUse = { + const truncated: ToolUse<"write_to_file"> = { type: "tool_use", name: "write_to_file", params: {}, @@ -76,7 +76,7 @@ describe("Truncated native tool-call args on finalize failure (issue #1221)", () }) it("companion: without the fix, the same truncated call would NOT have been blocked", () => { - const truncated: WriteToFileToolUse = { + const truncated: ToolUse<"write_to_file"> = { type: "tool_use", name: "write_to_file", params: {}, @@ -100,7 +100,7 @@ describe("Truncated native tool-call args on finalize failure (issue #1221)", () // with the freshly-finalized one instead of taking this branch at all - // this test just confirms a complete, valid nativeArgs is never touched // by wouldBeBlocked's guard simulation. - const complete: WriteToFileToolUse = { + const complete: ToolUse<"write_to_file"> = { type: "tool_use", name: "write_to_file", params: {}, diff --git a/src/core/tools/__tests__/attemptCompletionTool.spec.ts b/src/core/tools/__tests__/attemptCompletionTool.spec.ts index c1c235fe7f..29580ef203 100644 --- a/src/core/tools/__tests__/attemptCompletionTool.spec.ts +++ b/src/core/tools/__tests__/attemptCompletionTool.spec.ts @@ -1,6 +1,6 @@ import { RooCodeEventName, TodoItem } from "@roo-code/types" -import { AttemptCompletionToolUse } from "../../../shared/tools" +import { ToolUse } from "../../../shared/tools" // Mock the formatResponse module before importing the tool vi.mock("../../prompts/responses", () => ({ @@ -82,7 +82,7 @@ describe("attemptCompletionTool", () => { describe("todo list validation", () => { it("should allow completion when there is no todo list", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -108,7 +108,7 @@ describe("attemptCompletionTool", () => { }) it("should allow completion when todo list is empty", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -133,7 +133,7 @@ describe("attemptCompletionTool", () => { }) it("should allow completion when all todos are completed", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -163,7 +163,7 @@ describe("attemptCompletionTool", () => { }) it("should prevent completion when there are pending todos", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -206,7 +206,7 @@ describe("attemptCompletionTool", () => { }) it("should prevent completion when there are in-progress todos", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -249,7 +249,7 @@ describe("attemptCompletionTool", () => { }) it("should prevent completion when there are mixed incomplete todos", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -293,7 +293,7 @@ describe("attemptCompletionTool", () => { }) it("should allow completion when setting is disabled even with incomplete todos", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -337,7 +337,7 @@ describe("attemptCompletionTool", () => { }) it("should prevent completion when setting is enabled with incomplete todos", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -381,7 +381,7 @@ describe("attemptCompletionTool", () => { }) it("should allow completion when setting is enabled but all todos are completed", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -426,7 +426,7 @@ describe("attemptCompletionTool", () => { describe("tool failure guardrail", () => { it("should prevent completion when a previous tool failed in the current turn", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -461,7 +461,7 @@ describe("attemptCompletionTool", () => { }) it("should allow completion when no tools failed", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Task completed successfully" }, @@ -494,7 +494,7 @@ describe("attemptCompletionTool", () => { const persistenceReady = new Promise((resolve) => { markPersistenceReady = () => resolve(true) }) - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -572,7 +572,7 @@ describe("attemptCompletionTool", () => { it("does not delegate or emit completion when child history persistence fails", async () => { const persistenceError = new Error("history unavailable") - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -621,7 +621,7 @@ describe("attemptCompletionTool", () => { }) it("does not delegate or report an error when child history persistence is cancelled", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -670,7 +670,7 @@ describe("attemptCompletionTool", () => { }) it("does not reopen the parent when persistence is cancelled during approval", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -722,7 +722,7 @@ describe("attemptCompletionTool", () => { }) it("falls through to standalone completion when parent delegation becomes stale after approval", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -782,7 +782,7 @@ describe("attemptCompletionTool", () => { }) it("does not resume the parent when the parent is no longer awaiting this child", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -832,7 +832,7 @@ describe("attemptCompletionTool", () => { }) it("delegates an interrupted subtask completion when the parent is still delegated and awaiting that child", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -886,7 +886,7 @@ describe("attemptCompletionTool", () => { }) it("does not resume the parent when the parent is active but awaiting a different child", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "9" }, @@ -936,7 +936,7 @@ describe("attemptCompletionTool", () => { }) it("emits TaskCompleted only when completion is accepted", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "2" }, @@ -973,7 +973,7 @@ describe("attemptCompletionTool", () => { }) it("does not emit TaskCompleted when persistence is cancelled", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "2" }, @@ -1003,7 +1003,7 @@ describe("attemptCompletionTool", () => { it("reports accepted-completion persistence failures with persistence context", async () => { const persistenceError = new Error("history write failed") - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "2" }, @@ -1032,7 +1032,7 @@ describe("attemptCompletionTool", () => { }) it("reports telemetry but does not emit the public TaskCompleted event when user provides follow-up feedback", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "2" }, @@ -1074,7 +1074,7 @@ describe("attemptCompletionTool", () => { }) it("durably persists queued completion feedback before continuing", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Done" }, @@ -1105,7 +1105,7 @@ describe("attemptCompletionTool", () => { }) it("does not continue when queued completion feedback persistence fails", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Done" }, @@ -1136,7 +1136,7 @@ describe("attemptCompletionTool", () => { }) it("records image-only completion feedback before continuing", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Done" }, @@ -1162,7 +1162,7 @@ describe("attemptCompletionTool", () => { }) it("does not clear pending metadata when stale delegation continues without an action id", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "Done" }, @@ -1232,7 +1232,7 @@ describe("attemptCompletionTool telemetry invariants", () => { } it("does not emit a duplicate telemetry installment when replaying an already-completed subtask from history", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "done" }, @@ -1269,7 +1269,7 @@ describe("attemptCompletionTool telemetry invariants", () => { }) it("does not emit the public TaskCompleted event when replaying an already-completed subtask from history", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "done" }, @@ -1310,7 +1310,7 @@ describe("attemptCompletionTool telemetry invariants", () => { }) it("emits the public TaskCompleted API event only when completion is accepted, but reports telemetry either way", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "done" }, @@ -1342,7 +1342,7 @@ describe("attemptCompletionTool telemetry invariants", () => { }) it("still reports telemetry for a model-initiated completion even when the user provides follow-up feedback instead of accepting", async () => { - const block: AttemptCompletionToolUse = { + const block: ToolUse<"attempt_completion"> = { type: "tool_use", name: "attempt_completion", params: { result: "done" }, diff --git a/src/shared/tools.ts b/src/shared/tools.ts index 8730fd4446..4185380341 100644 --- a/src/shared/tools.ts +++ b/src/shared/tools.ts @@ -182,20 +182,6 @@ export interface McpToolUse { partial: boolean } -/** - * @public - */ -export interface AttemptCompletionToolUse extends ToolUse<"attempt_completion"> { - name: "attempt_completion" - params: Partial, "result">> -} - -/** @internal Type used by tool-argument regression tests. */ -export interface WriteToFileToolUse extends ToolUse<"write_to_file"> { - name: "write_to_file" - params: Partial, "path" | "content">> -} - // Define tool group configuration export type ToolGroupConfig = { tools: readonly string[]