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

Function buildExecuteResponsePayload

apps/sim/app/api/mothership/execute/route.ts:52–76  ·  view source on GitHub ↗
(
  result: Awaited<ReturnType<typeof runHeadlessCopilotLifecycle>>,
  effectiveChatId: string,
  integrationTools: Array<{ name: string }>
)

Source from the content-addressed store, hash-verified

50}
51
52function buildExecuteResponsePayload(
53 result: Awaited<ReturnType<typeof runHeadlessCopilotLifecycle>>,
54 effectiveChatId: string,
55 integrationTools: Array<{ name: string }>
56) {
57 const clientToolNames = new Set(integrationTools.map((t) => t.name))
58 const clientToolCalls = (result.toolCalls || []).filter(
59 (tc: { name: string }) => clientToolNames.has(tc.name) || tc.name.startsWith('mcp-')
60 )
61
62 return {
63 content: result.content,
64 model: 'mothership',
65 conversationId: effectiveChatId,
66 tokens: result.usage
67 ? {
68 prompt: result.usage.prompt,
69 completion: result.usage.completion,
70 total: (result.usage.prompt || 0) + (result.usage.completion || 0),
71 }
72 : {},
73 cost: result.cost || undefined,
74 toolCalls: clientToolCalls,
75 }
76}
77
78/**
79 * POST /api/mothership/execute

Callers 2

startFunction · 0.85
route.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected