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

Function registerMainToolCall

apps/sim/lib/copilot/request/handlers/tool.ts:415–451  ·  view source on GitHub ↗
(
  context: StreamingContext,
  toolCallId: string,
  toolName: string,
  args: Record<string, unknown> | undefined,
  existing: ToolCallState | undefined,
  ui: { title?: string; phaseLabel?: string; hidden?: boolean }
)

Source from the content-addressed store, hash-verified

413}
414
415function registerMainToolCall(
416 context: StreamingContext,
417 toolCallId: string,
418 toolName: string,
419 args: Record<string, unknown> | undefined,
420 existing: ToolCallState | undefined,
421 ui: { title?: string; phaseLabel?: string; hidden?: boolean }
422): void {
423 const hideFromUi = isToolHiddenInUi(toolName) || ui.hidden === true
424 if (existing) {
425 if (args && !existing.params) existing.params = args
426 applyToolDisplay(existing)
427 if (hideFromUi) {
428 removeToolCallContentBlock(context, toolCallId)
429 return
430 }
431 if (
432 !hideFromUi &&
433 !context.contentBlocks.some((b) => b.type === 'tool_call' && b.toolCall?.id === toolCallId)
434 ) {
435 addContentBlock(context, { type: 'tool_call', toolCall: existing })
436 }
437 } else {
438 const created: ToolCallState = {
439 id: toolCallId,
440 name: toolName,
441 status: 'pending',
442 params: args,
443 startTime: Date.now(),
444 }
445 applyToolDisplay(created)
446 context.toolCalls.set(toolCallId, created)
447 if (!hideFromUi) {
448 addContentBlock(context, { type: 'tool_call', toolCall: created })
449 }
450 }
451}
452
453async function dispatchToolExecution(
454 toolCall: ToolCallState,

Callers 1

handleCallPhaseFunction · 0.85

Calls 5

isToolHiddenInUiFunction · 0.90
addContentBlockFunction · 0.90
applyToolDisplayFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected