11import { RooCodeEventName , TodoItem } from "@roo-code/types"
22
3- import { AttemptCompletionToolUse } from "../../../shared/tools"
3+ import { ToolUse } from "../../../shared/tools"
44
55// Mock the formatResponse module before importing the tool
66vi . mock ( "../../prompts/responses" , ( ) => ( {
@@ -82,7 +82,7 @@ describe("attemptCompletionTool", () => {
8282
8383 describe ( "todo list validation" , ( ) => {
8484 it ( "should allow completion when there is no todo list" , async ( ) => {
85- const block : AttemptCompletionToolUse = {
85+ const block : ToolUse < "attempt_completion" > = {
8686 type : "tool_use" ,
8787 name : "attempt_completion" ,
8888 params : { result : "Task completed successfully" } ,
@@ -108,7 +108,7 @@ describe("attemptCompletionTool", () => {
108108 } )
109109
110110 it ( "should allow completion when todo list is empty" , async ( ) => {
111- const block : AttemptCompletionToolUse = {
111+ const block : ToolUse < "attempt_completion" > = {
112112 type : "tool_use" ,
113113 name : "attempt_completion" ,
114114 params : { result : "Task completed successfully" } ,
@@ -133,7 +133,7 @@ describe("attemptCompletionTool", () => {
133133 } )
134134
135135 it ( "should allow completion when all todos are completed" , async ( ) => {
136- const block : AttemptCompletionToolUse = {
136+ const block : ToolUse < "attempt_completion" > = {
137137 type : "tool_use" ,
138138 name : "attempt_completion" ,
139139 params : { result : "Task completed successfully" } ,
@@ -163,7 +163,7 @@ describe("attemptCompletionTool", () => {
163163 } )
164164
165165 it ( "should prevent completion when there are pending todos" , async ( ) => {
166- const block : AttemptCompletionToolUse = {
166+ const block : ToolUse < "attempt_completion" > = {
167167 type : "tool_use" ,
168168 name : "attempt_completion" ,
169169 params : { result : "Task completed successfully" } ,
@@ -206,7 +206,7 @@ describe("attemptCompletionTool", () => {
206206 } )
207207
208208 it ( "should prevent completion when there are in-progress todos" , async ( ) => {
209- const block : AttemptCompletionToolUse = {
209+ const block : ToolUse < "attempt_completion" > = {
210210 type : "tool_use" ,
211211 name : "attempt_completion" ,
212212 params : { result : "Task completed successfully" } ,
@@ -249,7 +249,7 @@ describe("attemptCompletionTool", () => {
249249 } )
250250
251251 it ( "should prevent completion when there are mixed incomplete todos" , async ( ) => {
252- const block : AttemptCompletionToolUse = {
252+ const block : ToolUse < "attempt_completion" > = {
253253 type : "tool_use" ,
254254 name : "attempt_completion" ,
255255 params : { result : "Task completed successfully" } ,
@@ -293,7 +293,7 @@ describe("attemptCompletionTool", () => {
293293 } )
294294
295295 it ( "should allow completion when setting is disabled even with incomplete todos" , async ( ) => {
296- const block : AttemptCompletionToolUse = {
296+ const block : ToolUse < "attempt_completion" > = {
297297 type : "tool_use" ,
298298 name : "attempt_completion" ,
299299 params : { result : "Task completed successfully" } ,
@@ -337,7 +337,7 @@ describe("attemptCompletionTool", () => {
337337 } )
338338
339339 it ( "should prevent completion when setting is enabled with incomplete todos" , async ( ) => {
340- const block : AttemptCompletionToolUse = {
340+ const block : ToolUse < "attempt_completion" > = {
341341 type : "tool_use" ,
342342 name : "attempt_completion" ,
343343 params : { result : "Task completed successfully" } ,
@@ -381,7 +381,7 @@ describe("attemptCompletionTool", () => {
381381 } )
382382
383383 it ( "should allow completion when setting is enabled but all todos are completed" , async ( ) => {
384- const block : AttemptCompletionToolUse = {
384+ const block : ToolUse < "attempt_completion" > = {
385385 type : "tool_use" ,
386386 name : "attempt_completion" ,
387387 params : { result : "Task completed successfully" } ,
@@ -426,7 +426,7 @@ describe("attemptCompletionTool", () => {
426426
427427 describe ( "tool failure guardrail" , ( ) => {
428428 it ( "should prevent completion when a previous tool failed in the current turn" , async ( ) => {
429- const block : AttemptCompletionToolUse = {
429+ const block : ToolUse < "attempt_completion" > = {
430430 type : "tool_use" ,
431431 name : "attempt_completion" ,
432432 params : { result : "Task completed successfully" } ,
@@ -461,7 +461,7 @@ describe("attemptCompletionTool", () => {
461461 } )
462462
463463 it ( "should allow completion when no tools failed" , async ( ) => {
464- const block : AttemptCompletionToolUse = {
464+ const block : ToolUse < "attempt_completion" > = {
465465 type : "tool_use" ,
466466 name : "attempt_completion" ,
467467 params : { result : "Task completed successfully" } ,
@@ -494,7 +494,7 @@ describe("attemptCompletionTool", () => {
494494 const persistenceReady = new Promise < boolean > ( ( resolve ) => {
495495 markPersistenceReady = ( ) => resolve ( true )
496496 } )
497- const block : AttemptCompletionToolUse = {
497+ const block : ToolUse < "attempt_completion" > = {
498498 type : "tool_use" ,
499499 name : "attempt_completion" ,
500500 params : { result : "9" } ,
@@ -572,7 +572,7 @@ describe("attemptCompletionTool", () => {
572572
573573 it ( "does not delegate or emit completion when child history persistence fails" , async ( ) => {
574574 const persistenceError = new Error ( "history unavailable" )
575- const block : AttemptCompletionToolUse = {
575+ const block : ToolUse < "attempt_completion" > = {
576576 type : "tool_use" ,
577577 name : "attempt_completion" ,
578578 params : { result : "9" } ,
@@ -621,7 +621,7 @@ describe("attemptCompletionTool", () => {
621621 } )
622622
623623 it ( "does not delegate or report an error when child history persistence is cancelled" , async ( ) => {
624- const block : AttemptCompletionToolUse = {
624+ const block : ToolUse < "attempt_completion" > = {
625625 type : "tool_use" ,
626626 name : "attempt_completion" ,
627627 params : { result : "9" } ,
@@ -670,7 +670,7 @@ describe("attemptCompletionTool", () => {
670670 } )
671671
672672 it ( "does not reopen the parent when persistence is cancelled during approval" , async ( ) => {
673- const block : AttemptCompletionToolUse = {
673+ const block : ToolUse < "attempt_completion" > = {
674674 type : "tool_use" ,
675675 name : "attempt_completion" ,
676676 params : { result : "9" } ,
@@ -722,7 +722,7 @@ describe("attemptCompletionTool", () => {
722722 } )
723723
724724 it ( "falls through to standalone completion when parent delegation becomes stale after approval" , async ( ) => {
725- const block : AttemptCompletionToolUse = {
725+ const block : ToolUse < "attempt_completion" > = {
726726 type : "tool_use" ,
727727 name : "attempt_completion" ,
728728 params : { result : "9" } ,
@@ -782,7 +782,7 @@ describe("attemptCompletionTool", () => {
782782 } )
783783
784784 it ( "does not resume the parent when the parent is no longer awaiting this child" , async ( ) => {
785- const block : AttemptCompletionToolUse = {
785+ const block : ToolUse < "attempt_completion" > = {
786786 type : "tool_use" ,
787787 name : "attempt_completion" ,
788788 params : { result : "9" } ,
@@ -832,7 +832,7 @@ describe("attemptCompletionTool", () => {
832832 } )
833833
834834 it ( "delegates an interrupted subtask completion when the parent is still delegated and awaiting that child" , async ( ) => {
835- const block : AttemptCompletionToolUse = {
835+ const block : ToolUse < "attempt_completion" > = {
836836 type : "tool_use" ,
837837 name : "attempt_completion" ,
838838 params : { result : "9" } ,
@@ -886,7 +886,7 @@ describe("attemptCompletionTool", () => {
886886 } )
887887
888888 it ( "does not resume the parent when the parent is active but awaiting a different child" , async ( ) => {
889- const block : AttemptCompletionToolUse = {
889+ const block : ToolUse < "attempt_completion" > = {
890890 type : "tool_use" ,
891891 name : "attempt_completion" ,
892892 params : { result : "9" } ,
@@ -936,7 +936,7 @@ describe("attemptCompletionTool", () => {
936936 } )
937937
938938 it ( "emits TaskCompleted only when completion is accepted" , async ( ) => {
939- const block : AttemptCompletionToolUse = {
939+ const block : ToolUse < "attempt_completion" > = {
940940 type : "tool_use" ,
941941 name : "attempt_completion" ,
942942 params : { result : "2" } ,
@@ -973,7 +973,7 @@ describe("attemptCompletionTool", () => {
973973 } )
974974
975975 it ( "does not emit TaskCompleted when persistence is cancelled" , async ( ) => {
976- const block : AttemptCompletionToolUse = {
976+ const block : ToolUse < "attempt_completion" > = {
977977 type : "tool_use" ,
978978 name : "attempt_completion" ,
979979 params : { result : "2" } ,
@@ -1003,7 +1003,7 @@ describe("attemptCompletionTool", () => {
10031003
10041004 it ( "reports accepted-completion persistence failures with persistence context" , async ( ) => {
10051005 const persistenceError = new Error ( "history write failed" )
1006- const block : AttemptCompletionToolUse = {
1006+ const block : ToolUse < "attempt_completion" > = {
10071007 type : "tool_use" ,
10081008 name : "attempt_completion" ,
10091009 params : { result : "2" } ,
@@ -1032,7 +1032,7 @@ describe("attemptCompletionTool", () => {
10321032 } )
10331033
10341034 it ( "reports telemetry but does not emit the public TaskCompleted event when user provides follow-up feedback" , async ( ) => {
1035- const block : AttemptCompletionToolUse = {
1035+ const block : ToolUse < "attempt_completion" > = {
10361036 type : "tool_use" ,
10371037 name : "attempt_completion" ,
10381038 params : { result : "2" } ,
@@ -1074,7 +1074,7 @@ describe("attemptCompletionTool", () => {
10741074 } )
10751075
10761076 it ( "durably persists queued completion feedback before continuing" , async ( ) => {
1077- const block : AttemptCompletionToolUse = {
1077+ const block : ToolUse < "attempt_completion" > = {
10781078 type : "tool_use" ,
10791079 name : "attempt_completion" ,
10801080 params : { result : "Done" } ,
@@ -1105,7 +1105,7 @@ describe("attemptCompletionTool", () => {
11051105 } )
11061106
11071107 it ( "does not continue when queued completion feedback persistence fails" , async ( ) => {
1108- const block : AttemptCompletionToolUse = {
1108+ const block : ToolUse < "attempt_completion" > = {
11091109 type : "tool_use" ,
11101110 name : "attempt_completion" ,
11111111 params : { result : "Done" } ,
@@ -1136,7 +1136,7 @@ describe("attemptCompletionTool", () => {
11361136 } )
11371137
11381138 it ( "records image-only completion feedback before continuing" , async ( ) => {
1139- const block : AttemptCompletionToolUse = {
1139+ const block : ToolUse < "attempt_completion" > = {
11401140 type : "tool_use" ,
11411141 name : "attempt_completion" ,
11421142 params : { result : "Done" } ,
@@ -1162,7 +1162,7 @@ describe("attemptCompletionTool", () => {
11621162 } )
11631163
11641164 it ( "does not clear pending metadata when stale delegation continues without an action id" , async ( ) => {
1165- const block : AttemptCompletionToolUse = {
1165+ const block : ToolUse < "attempt_completion" > = {
11661166 type : "tool_use" ,
11671167 name : "attempt_completion" ,
11681168 params : { result : "Done" } ,
@@ -1232,7 +1232,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
12321232 }
12331233
12341234 it ( "does not emit a duplicate telemetry installment when replaying an already-completed subtask from history" , async ( ) => {
1235- const block : AttemptCompletionToolUse = {
1235+ const block : ToolUse < "attempt_completion" > = {
12361236 type : "tool_use" ,
12371237 name : "attempt_completion" ,
12381238 params : { result : "done" } ,
@@ -1269,7 +1269,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
12691269 } )
12701270
12711271 it ( "does not emit the public TaskCompleted event when replaying an already-completed subtask from history" , async ( ) => {
1272- const block : AttemptCompletionToolUse = {
1272+ const block : ToolUse < "attempt_completion" > = {
12731273 type : "tool_use" ,
12741274 name : "attempt_completion" ,
12751275 params : { result : "done" } ,
@@ -1310,7 +1310,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
13101310 } )
13111311
13121312 it ( "emits the public TaskCompleted API event only when completion is accepted, but reports telemetry either way" , async ( ) => {
1313- const block : AttemptCompletionToolUse = {
1313+ const block : ToolUse < "attempt_completion" > = {
13141314 type : "tool_use" ,
13151315 name : "attempt_completion" ,
13161316 params : { result : "done" } ,
@@ -1342,7 +1342,7 @@ describe("attemptCompletionTool telemetry invariants", () => {
13421342 } )
13431343
13441344 it ( "still reports telemetry for a model-initiated completion even when the user provides follow-up feedback instead of accepting" , async ( ) => {
1345- const block : AttemptCompletionToolUse = {
1345+ const block : ToolUse < "attempt_completion" > = {
13461346 type : "tool_use" ,
13471347 name : "attempt_completion" ,
13481348 params : { result : "done" } ,
0 commit comments