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

Function runCopilotLifecycle

apps/sim/lib/copilot/request/lifecycle/run.ts:81–234  ·  view source on GitHub ↗
(
  requestPayload: Record<string, unknown>,
  options: CopilotLifecycleOptions
)

Source from the content-addressed store, hash-verified

79}
80
81export async function runCopilotLifecycle(
82 requestPayload: Record<string, unknown>,
83 options: CopilotLifecycleOptions
84): Promise<OrchestratorResult> {
85 const {
86 userId,
87 workflowId,
88 workspaceId,
89 chatId,
90 executionId,
91 runId,
92 goRoute = '/api/copilot',
93 } = options
94 const payloadMsgId =
95 typeof requestPayload?.messageId === 'string' ? requestPayload.messageId : generateId()
96 const runIdentity = await ensureHeadlessRunIdentity({
97 requestPayload,
98 userId,
99 workflowId,
100 workspaceId,
101 chatId,
102 executionId,
103 runId,
104 messageId: payloadMsgId,
105 })
106 const resolvedExecutionId = runIdentity.executionId ?? executionId
107 const resolvedRunId = runIdentity.runId ?? runId
108 const lifecycleOptions: CopilotLifecycleOptions = {
109 ...options,
110 executionId: resolvedExecutionId,
111 runId: resolvedRunId,
112 ...(options.executionContext
113 ? {
114 executionContext: {
115 ...options.executionContext,
116 messageId: payloadMsgId,
117 executionId: resolvedExecutionId,
118 runId: resolvedRunId,
119 abortSignal: options.abortSignal,
120 },
121 }
122 : {}),
123 }
124
125 const execContext =
126 lifecycleOptions.executionContext ??
127 (await buildExecutionContext(requestPayload, {
128 userId,
129 workflowId,
130 workspaceId,
131 chatId,
132 executionId: resolvedExecutionId,
133 runId: resolvedRunId,
134 abortSignal: lifecycleOptions.abortSignal,
135 }))
136
137 const context = createStreamingContext({
138 chatId,

Callers 3

startFunction · 0.90
run.test.tsFile · 0.90

Calls 9

generateIdFunction · 0.90
createStreamingContextFunction · 0.90
buildToolCallSummariesFunction · 0.90
toErrorFunction · 0.90
buildExecutionContextFunction · 0.85
runCheckpointLoopFunction · 0.85
resultContentFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected