(params: {
flowId: string
rootDir?: string
nowMs?: number
})
| 874 | } |
| 875 | |
| 876 | export async function resumeManagedAutonomyFlow(params: { |
| 877 | flowId: string |
| 878 | rootDir?: string |
| 879 | nowMs?: number |
| 880 | }): Promise<ManagedAutonomyFlowAdvanceResult | null> { |
| 881 | const rootDir = resolve(params.rootDir ?? getProjectRoot()) |
| 882 | const nowMs = params.nowMs ?? Date.now() |
| 883 | return updateAutonomyFlowById( |
| 884 | params.flowId, |
| 885 | current => { |
| 886 | if ( |
| 887 | current.status !== 'waiting' || |
| 888 | !current.stateJson || |
| 889 | !current.waitJson |
| 890 | ) { |
| 891 | return current |
| 892 | } |
| 893 | if (current.cancelRequestedAt) { |
| 894 | return { |
| 895 | ...current, |
| 896 | revision: current.revision + 1, |
| 897 | status: 'cancelled', |
| 898 | updatedAt: nowMs, |
| 899 | endedAt: nowMs, |
| 900 | currentStep: undefined, |
| 901 | waitJson: undefined, |
| 902 | lastError: undefined, |
| 903 | } |
| 904 | } |
| 905 | const state = cloneManagedState(current.stateJson)! |
| 906 | state.currentStepIndex = current.waitJson.stepIndex |
| 907 | return { |
| 908 | ...current, |
| 909 | revision: current.revision + 1, |
| 910 | status: 'queued', |
| 911 | updatedAt: nowMs, |
| 912 | endedAt: undefined, |
| 913 | currentStep: current.waitJson.stepName, |
| 914 | waitJson: undefined, |
| 915 | stateJson: state, |
| 916 | lastError: undefined, |
| 917 | } |
| 918 | }, |
| 919 | rootDir, |
| 920 | ).then(flow => |
| 921 | flow |
| 922 | ? { |
| 923 | flow, |
| 924 | ...(flow.status === 'queued' && flow.stateJson |
| 925 | ? { |
| 926 | nextStep: buildQueueInstruction( |
| 927 | flow, |
| 928 | flow.stateJson.currentStepIndex, |
| 929 | ), |
| 930 | } |
| 931 | : {}), |
| 932 | } |
| 933 | : null, |
no test coverage detected