MCPcopy Index your code
hub / github.com/coder/mux / emitToolCall

Function emitToolCall

src/node/services/sessionTimingService.test.ts:140–185  ·  view source on GitHub ↗
(
    params: {
      workspaceId?: string;
      messageId?: string;
      toolCallId?: string;
      toolName?: string;
      args?: Record<string, unknown>;
      tokens?: number;
      startTimestamp?: number;
      endTimestamp?: number;
      replay?: true;
      deferEnd?: true;
    } = {}
  )

Source from the content-addressed store, hash-verified

138 }
139
140 function emitToolCall(
141 params: {
142 workspaceId?: string;
143 messageId?: string;
144 toolCallId?: string;
145 toolName?: string;
146 args?: Record<string, unknown>;
147 tokens?: number;
148 startTimestamp?: number;
149 endTimestamp?: number;
150 replay?: true;
151 deferEnd?: true;
152 } = {}
153 ): void | (() => void) {
154 const workspaceId = params.workspaceId ?? "test-workspace";
155 const messageId = params.messageId ?? "m1";
156 const toolCallId = params.toolCallId ?? "t1";
157 const toolName = params.toolName ?? "bash";
158
159 service.handleToolCallStart({
160 type: "tool-call-start",
161 workspaceId,
162 messageId,
163 toolCallId,
164 toolName,
165 args: params.args ?? { cmd: "echo hi" },
166 tokens: params.tokens ?? 3,
167 timestamp: params.startTimestamp ?? 1_002_000,
168 ...(params.replay != null ? { replay: params.replay } : {}),
169 });
170 const emitEnd = () =>
171 service.handleToolCallEnd({
172 type: "tool-call-end",
173 workspaceId,
174 messageId,
175 toolCallId,
176 toolName,
177 result: { ok: true },
178 timestamp: params.endTimestamp ?? 1_003_000,
179 ...(params.replay != null ? { replay: params.replay } : {}),
180 });
181 if (params.deferEnd) {
182 return emitEnd;
183 }
184 emitEnd();
185 }
186
187 function emitStreamEnd(
188 params: {

Calls 2

emitEndFunction · 0.85
handleToolCallStartMethod · 0.65

Tested by

no test coverage detected