( input: ResolveWorkflowScriptInput )
| 46 | const INLINE_SCRIPT_PATH_PREFIX = "inline://"; |
| 47 | |
| 48 | export async function resolveWorkflowScript( |
| 49 | input: ResolveWorkflowScriptInput |
| 50 | ): Promise<ResolvedWorkflowScript> { |
| 51 | const hasPath = input.scriptPath != null; |
| 52 | const hasSource = input.scriptSource != null; |
| 53 | assert( |
| 54 | hasPath !== hasSource, |
| 55 | "resolveWorkflowScript: provide exactly one of scriptPath or scriptSource" |
| 56 | ); |
| 57 | assert(input.workspacePath.length > 0, "resolveWorkflowScript: workspacePath is required"); |
| 58 | |
| 59 | if (hasSource) { |
| 60 | assert(input.scriptSource != null, "resolveWorkflowScript: scriptSource is required"); |
| 61 | return buildInlineWorkflowScript({ |
| 62 | source: input.scriptSource, |
| 63 | projectTrusted: input.projectTrusted, |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | assert(input.scriptPath != null, "resolveWorkflowScript: scriptPath is required"); |
| 68 | const scriptPath = input.scriptPath.trim(); |
| 69 | assert(scriptPath.length > 0, "resolveWorkflowScript: scriptPath is required"); |
| 70 | if (scriptPath.startsWith(INLINE_SCRIPT_PATH_PREFIX)) { |
| 71 | throw new Error("inline:// workflow paths are provenance only; use script_source instead"); |
| 72 | } |
| 73 | |
| 74 | if (scriptPath.startsWith(SKILL_SCRIPT_PATH_PREFIX)) { |
| 75 | return await resolveSkillWorkflowScript({ ...input, scriptPath }); |
| 76 | } |
| 77 | |
| 78 | return await resolveWorkspaceFileWorkflowScript({ ...input, scriptPath }); |
| 79 | } |
| 80 | |
| 81 | function buildInlineWorkflowScript(input: { |
| 82 | source: string; |
no test coverage detected