Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/task/__tests__/Task.persistence.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/core/task/__tests__/truncated-native-tool-args.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)", () => {
/**
Expand Down Expand Up @@ -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: {},
Expand All @@ -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: {},
Expand All @@ -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: {},
Expand Down
64 changes: 32 additions & 32 deletions src/core/tools/__tests__/attemptCompletionTool.spec.ts
Original file line number Diff line number Diff line change
@@ -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", () => ({
Expand Down Expand Up @@ -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" },
Expand All @@ -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" },
Expand All @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -494,7 +494,7 @@ describe("attemptCompletionTool", () => {
const persistenceReady = new Promise<boolean>((resolve) => {
markPersistenceReady = () => resolve(true)
})
const block: AttemptCompletionToolUse = {
const block: ToolUse<"attempt_completion"> = {
type: "tool_use",
name: "attempt_completion",
params: { result: "9" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand All @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down
14 changes: 0 additions & 14 deletions src/shared/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,6 @@ export interface McpToolUse {
partial: boolean
}

/**
* @public
*/
export interface AttemptCompletionToolUse extends ToolUse<"attempt_completion"> {
name: "attempt_completion"
params: Partial<Pick<Record<ToolParamName, string>, "result">>
}

/** @internal Type used by tool-argument regression tests. */
export interface WriteToFileToolUse extends ToolUse<"write_to_file"> {
name: "write_to_file"
params: Partial<Pick<Record<ToolParamName, string>, "path" | "content">>
}

// Define tool group configuration
export type ToolGroupConfig = {
tools: readonly string[]
Expand Down
Loading