MCPcopy
hub / github.com/coder/mux / buildWorkflowRunToolPart

Function buildWorkflowRunToolPart

src/common/utils/workflowRunMessages.ts:174–206  ·  view source on GitHub ↗
(
  input: WorkflowRunCardInput,
  result: WorkflowRunCardResult,
  now = Date.now()
)

Source from the content-addressed store, hash-verified

172}
173
174export function buildWorkflowRunToolPart(
175 input: WorkflowRunCardInput,
176 result: WorkflowRunCardResult,
177 now = Date.now()
178): WorkflowRunToolPart {
179 const scriptPath = input.scriptPath ?? input.name;
180 const hasPath = scriptPath != null && scriptPath.length > 0;
181 const hasSource = input.scriptSource != null && input.scriptSource.length > 0;
182 assert(
183 hasPath !== hasSource,
184 "buildWorkflowRunToolPart: provide exactly one workflow scriptPath or scriptSource"
185 );
186 assert(result.runId.length > 0, "buildWorkflowRunToolPart: runId is required");
187
188 return {
189 type: "dynamic-tool",
190 toolCallId: `workflow-run-${result.runId}`,
191 toolName: "workflow_run",
192 state: "output-available",
193 input: {
194 ...(hasPath ? { script_path: scriptPath } : { script_source: input.scriptSource }),
195 args: input.args,
196 run_in_background: true,
197 },
198 output: {
199 status: result.status,
200 runId: result.runId,
201 result: result.result,
202 ...(result.run != null ? { run: result.run } : {}),
203 },
204 timestamp: now,
205 };
206}
207
208export function buildWorkflowRunCardMessage(
209 input: WorkflowRunCardInput,

Callers 2

Calls 1

assertFunction · 0.70

Tested by

no test coverage detected