(input: MissionWorkflowLoadInput)
| 104 | } |
| 105 | |
| 106 | load(input: MissionWorkflowLoadInput): LoadedMissionWorkflow { |
| 107 | const resolvedPath = this.resolvePath(input); |
| 108 | if (!resolvedPath || !fs.existsSync(resolvedPath)) { |
| 109 | return this.createBuiltInWorkflow(resolvedPath); |
| 110 | } |
| 111 | |
| 112 | const rawText = fs.readFileSync(resolvedPath, 'utf8'); |
| 113 | const { frontMatter, body } = splitWorkflowFrontMatter(rawText); |
| 114 | const parsedFrontMatter = parseWorkflowFrontMatter(frontMatter, resolvedPath); |
| 115 | const validated = validateWorkflowFrontMatter(parsedFrontMatter, resolvedPath); |
| 116 | |
| 117 | return { |
| 118 | source: { |
| 119 | kind: 'file', |
| 120 | path: resolvedPath, |
| 121 | label: resolvedPath, |
| 122 | }, |
| 123 | hash: hashMissionWorkflowText(rawText), |
| 124 | policy: { |
| 125 | version: 1, |
| 126 | maxTurns: validated.maxTurns ?? null, |
| 127 | maxAttempts: validated.maxAttempts ?? null, |
| 128 | maxRuntimeMs: validated.maxRuntimeMinutes !== undefined |
| 129 | ? validated.maxRuntimeMinutes * 60_000 |
| 130 | : null, |
| 131 | maxArtifactCount: validated.maxArtifactCount ?? null, |
| 132 | maxArtifactBytes: validated.maxArtifactBytes ?? null, |
| 133 | continuation: validated.continuation ?? 'allow', |
| 134 | requirePlanUpdate: validated.requirePlanUpdate ?? true, |
| 135 | requireWorkpadUpdate: validated.requireWorkpadUpdate ?? true, |
| 136 | defaultHandoffState: validated.defaultHandoffState ?? 'needs_human', |
| 137 | stopConditions: [...(validated.stopConditions ?? [])], |
| 138 | finalReportSections: [...(validated.finalReportSections ?? ['summary', 'verification', 'artifacts', 'next_steps'])], |
| 139 | promptBody: body, |
| 140 | }, |
| 141 | rawFrontMatter: parsedFrontMatter, |
| 142 | rawText, |
| 143 | }; |
| 144 | } |
| 145 | |
| 146 | tryLoad(input: MissionWorkflowLoadInput): |
| 147 | | { workflow: LoadedMissionWorkflow; error: null } |
no test coverage detected