MCPcopy Index your code
hub / github.com/simstudioai/sim / handleClientCompletion

Function handleClientCompletion

apps/sim/lib/copilot/request/handlers/types.ts:194–223  ·  view source on GitHub ↗
(
  toolCall: ToolCallState,
  toolCallId: string,
  completion: AsyncTerminalCompletionSnapshot | null
)

Source from the content-addressed store, hash-verified

192 * Shared by both main and subagent scopes.
193 */
194export function handleClientCompletion(
195 toolCall: ToolCallState,
196 toolCallId: string,
197 completion: AsyncTerminalCompletionSnapshot | null
198): void {
199 if (completion?.status === ASYNC_TOOL_CONFIRMATION_STATUS.background) {
200 setTerminalToolCallState(toolCall, {
201 status: MothershipStreamV1ToolOutcome.skipped,
202 ...(completion.data !== undefined ? { output: completion.data } : {}),
203 })
204 markToolResultSeen(toolCallId)
205 return
206 }
207 if (completion?.status === MothershipStreamV1ToolOutcome.cancelled) {
208 setTerminalToolCallState(toolCall, {
209 status: MothershipStreamV1ToolOutcome.cancelled,
210 ...(completion.data !== undefined ? { output: completion.data } : {}),
211 error: completion.message || 'Tool cancelled',
212 })
213 markToolResultSeen(toolCallId)
214 return
215 }
216 const success = completion?.status === MothershipStreamV1ToolOutcome.success
217 setTerminalToolCallState(toolCall, {
218 status: success ? MothershipStreamV1ToolOutcome.success : MothershipStreamV1ToolOutcome.error,
219 ...(completion?.data !== undefined ? { output: completion.data } : {}),
220 ...(success ? {} : { error: completion?.message || 'Tool failed' }),
221 })
222 markToolResultSeen(toolCallId)
223}
224
225/**
226 * Emit a synthetic tool_result SSE event to the client after a client-executable

Callers 1

dispatchToolExecutionFunction · 0.90

Calls 2

setTerminalToolCallStateFunction · 0.90
markToolResultSeenFunction · 0.90

Tested by

no test coverage detected