( flowId: string, updater: (current: AutonomyFlowRecord) => AutonomyFlowRecord, rootDir: string = getProjectRoot(), )
| 438 | } |
| 439 | |
| 440 | async function updateAutonomyFlowById( |
| 441 | flowId: string, |
| 442 | updater: (current: AutonomyFlowRecord) => AutonomyFlowRecord, |
| 443 | rootDir: string = getProjectRoot(), |
| 444 | ): Promise<AutonomyFlowRecord | null> { |
| 445 | return withAutonomyPersistenceLock(rootDir, async () => { |
| 446 | const flows = await listAutonomyFlows(rootDir) |
| 447 | const index = flows.findIndex(flow => flow.flowId === flowId) |
| 448 | if (index === -1) { |
| 449 | return null |
| 450 | } |
| 451 | const next = normalizeFlowRecord(updater(cloneFlowRecord(flows[index]!))) |
| 452 | flows[index] = next |
| 453 | await writeAutonomyFlows(flows, rootDir) |
| 454 | return next |
| 455 | }) |
| 456 | } |
| 457 | |
| 458 | export function createManagedAutonomyFlowKey(params: { |
| 459 | trigger: AutonomyTriggerKind |
no test coverage detected