MCPcopy Index your code
hub / github.com/anus-dev/ANUS / MockToolInvocation

Class MockToolInvocation

packages/core/src/test-utils/tools.ts:23–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21} from '../tools/modifiable-tool.js';
22
23class MockToolInvocation extends BaseToolInvocation<
24 { [key: string]: unknown },
25 ToolResult
26> {
27 constructor(
28 private readonly tool: MockTool,
29 params: { [key: string]: unknown },
30 ) {
31 super(params);
32 }
33
34 async execute(_abortSignal: AbortSignal): Promise<ToolResult> {
35 const result = this.tool.executeFn(this.params);
36 return (
37 result ?? {
38 llmContent: `Tool ${this.tool.name} executed successfully.`,
39 returnDisplay: `Tool ${this.tool.name} executed successfully.`,
40 }
41 );
42 }
43
44 override async shouldConfirmExecute(
45 _abortSignal: AbortSignal,
46 ): Promise<ToolCallConfirmationDetails | false> {
47 if (this.tool.shouldConfirm) {
48 return {
49 type: 'exec' as const,
50 title: `Confirm ${this.tool.displayName}`,
51 command: this.tool.name,
52 rootCommand: this.tool.name,
53 onConfirm: async () => {},
54 };
55 }
56 return false;
57 }
58
59 getDescription(): string {
60 return `A mock tool invocation for ${this.tool.name}`;
61 }
62}
63
64/**
65 * A highly configurable mock tool for testing purposes.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected