( input: WorkflowRunCardInput, result: WorkflowRunCardResult, now = Date.now() )
| 172 | } |
| 173 | |
| 174 | export 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 | |
| 208 | export function buildWorkflowRunCardMessage( |
| 209 | input: WorkflowRunCardInput, |
no test coverage detected