MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / makeTool

Function makeTool

packages/agent-core/test/tools/ask-user.test.ts:36–62  ·  view source on GitHub ↗
(
  options: {
    readonly mode?: PermissionMode;
    readonly requestQuestion?: (
      request: QuestionRequest,
      options: { readonly signal?: AbortSignal },
    ) => Promise<QuestionResult>;
  } = {},
)

Source from the content-addressed store, hash-verified

34}
35
36function makeTool(
37 options: {
38 readonly mode?: PermissionMode;
39 readonly requestQuestion?: (
40 request: QuestionRequest,
41 options: { readonly signal?: AbortSignal },
42 ) => Promise<QuestionResult>;
43 } = {},
44): {
45 readonly tool: AskUserQuestionTool;
46 readonly requestQuestion: ReturnType<typeof vi.fn>;
47 readonly telemetryTrack: ReturnType<typeof vi.fn>;
48} {
49 const requestQuestion = vi.fn(
50 options.requestQuestion ??
51 (async () => ({
52 Postgres: true,
53 })),
54 );
55 const telemetryTrack = vi.fn();
56 const agent = {
57 permission: { mode: options.mode ?? 'manual' },
58 rpc: { requestQuestion },
59 telemetry: { track: telemetryTrack },
60 } as unknown as Agent;
61 return { tool: new AskUserQuestionTool(agent), requestQuestion, telemetryTrack };
62}
63
64describe('AskUserQuestionTool', () => {
65 afterEach(() => {

Callers 1

ask-user.test.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected