@kbediako/codex-orchestrator 0.1.38 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/README.md +70 -301
  3. package/bin/codex-orchestrator.js +161 -0
  4. package/codex.orchestrator.json +149 -13
  5. package/dist/bin/codex-orchestrator.js +795 -1154
  6. package/dist/orchestrator/src/cli/adapters/CommandPlanner.js +22 -4
  7. package/dist/orchestrator/src/cli/adapters/CommandReviewer.js +3 -3
  8. package/dist/orchestrator/src/cli/adapters/CommandTester.js +2 -2
  9. package/dist/orchestrator/src/cli/adapters/cloudFailureDiagnostics.js +183 -11
  10. package/dist/orchestrator/src/cli/coStatusAttachCliShell.js +402 -0
  11. package/dist/orchestrator/src/cli/coStatusCliShell.js +429 -0
  12. package/dist/orchestrator/src/cli/coStatusOperatorAutopilotCliShell.js +120 -0
  13. package/dist/orchestrator/src/cli/codexCliShell.js +72 -0
  14. package/dist/orchestrator/src/cli/codexDefaultsSetup.js +49 -11
  15. package/dist/orchestrator/src/cli/config/delegationConfig.js +317 -5
  16. package/dist/orchestrator/src/cli/config/repoConfigPolicy.js +2 -3
  17. package/dist/orchestrator/src/cli/config/userConfig.js +28 -13
  18. package/dist/orchestrator/src/cli/control/authenticatedControlRouteGate.js +69 -0
  19. package/dist/orchestrator/src/cli/control/authenticatedRouteComposition.js +267 -0
  20. package/dist/orchestrator/src/cli/control/authenticatedRouteController.js +5 -0
  21. package/dist/orchestrator/src/cli/control/authenticatedRouteDispatcher.js +41 -0
  22. package/dist/orchestrator/src/cli/control/compatibilityIssuePresenter.js +1035 -0
  23. package/dist/orchestrator/src/cli/control/confirmationApproveController.js +62 -0
  24. package/dist/orchestrator/src/cli/control/confirmationCreateController.js +69 -0
  25. package/dist/orchestrator/src/cli/control/confirmationIssueConsumeController.js +43 -0
  26. package/dist/orchestrator/src/cli/control/confirmationListController.js +22 -0
  27. package/dist/orchestrator/src/cli/control/confirmationValidateController.js +58 -0
  28. package/dist/orchestrator/src/cli/control/confirmations.js +25 -3
  29. package/dist/orchestrator/src/cli/control/controlActionCancelConfirmation.js +65 -0
  30. package/dist/orchestrator/src/cli/control/controlActionController.js +77 -0
  31. package/dist/orchestrator/src/cli/control/controlActionControllerSequencing.js +161 -0
  32. package/dist/orchestrator/src/cli/control/controlActionExecution.js +142 -0
  33. package/dist/orchestrator/src/cli/control/controlActionFinalization.js +43 -0
  34. package/dist/orchestrator/src/cli/control/controlActionOutcome.js +60 -0
  35. package/dist/orchestrator/src/cli/control/controlActionPreflight.js +476 -0
  36. package/dist/orchestrator/src/cli/control/controlAuthenticatedRouteHandoff.js +57 -0
  37. package/dist/orchestrator/src/cli/control/controlBootstrapAssembly.js +39 -0
  38. package/dist/orchestrator/src/cli/control/controlBootstrapMetadataPersistence.js +16 -0
  39. package/dist/orchestrator/src/cli/control/controlEventTransport.js +49 -0
  40. package/dist/orchestrator/src/cli/control/controlExpiryLifecycle.js +102 -0
  41. package/dist/orchestrator/src/cli/control/controlHostOwnership.js +480 -0
  42. package/dist/orchestrator/src/cli/control/controlHostSupervision.js +608 -0
  43. package/dist/orchestrator/src/cli/control/controlOversightFacade.js +8 -0
  44. package/dist/orchestrator/src/cli/control/controlOversightReadContract.js +1 -0
  45. package/dist/orchestrator/src/cli/control/controlOversightReadService.js +16 -0
  46. package/dist/orchestrator/src/cli/control/controlOversightUpdateContract.js +1 -0
  47. package/dist/orchestrator/src/cli/control/controlPersistenceFiles.js +6 -0
  48. package/dist/orchestrator/src/cli/control/controlQuestionChildResolution.js +18 -0
  49. package/dist/orchestrator/src/cli/control/controlRequestContext.js +42 -0
  50. package/dist/orchestrator/src/cli/control/controlRequestController.js +9 -0
  51. package/dist/orchestrator/src/cli/control/controlRequestPredispatch.js +17 -0
  52. package/dist/orchestrator/src/cli/control/controlRequestRouteDispatch.js +44 -0
  53. package/dist/orchestrator/src/cli/control/controlRuntime.js +992 -0
  54. package/dist/orchestrator/src/cli/control/controlServer.js +23 -1456
  55. package/dist/orchestrator/src/cli/control/controlServerAuditAndErrorHelpers.js +115 -0
  56. package/dist/orchestrator/src/cli/control/controlServerAuthenticatedRouteBranch.js +29 -0
  57. package/dist/orchestrator/src/cli/control/controlServerBootstrapLifecycle.js +30 -0
  58. package/dist/orchestrator/src/cli/control/controlServerBootstrapStartSequence.js +21 -0
  59. package/dist/orchestrator/src/cli/control/controlServerOwnedRuntimeLifecycle.js +67 -0
  60. package/dist/orchestrator/src/cli/control/controlServerPublicLifecycle.js +756 -0
  61. package/dist/orchestrator/src/cli/control/controlServerPublicRouteHelpers.js +86 -0
  62. package/dist/orchestrator/src/cli/control/controlServerReadyInstanceLifecycle.js +25 -0
  63. package/dist/orchestrator/src/cli/control/controlServerReadyInstanceStartup.js +18 -0
  64. package/dist/orchestrator/src/cli/control/controlServerRequestBodyHelpers.js +37 -0
  65. package/dist/orchestrator/src/cli/control/controlServerRequestShell.js +40 -0
  66. package/dist/orchestrator/src/cli/control/controlServerRequestShellBinding.js +17 -0
  67. package/dist/orchestrator/src/cli/control/controlServerSeedLoading.js +27 -0
  68. package/dist/orchestrator/src/cli/control/controlServerSeededRuntimeAssembly.js +186 -0
  69. package/dist/orchestrator/src/cli/control/controlServerStartupInputPreparation.js +31 -0
  70. package/dist/orchestrator/src/cli/control/controlServerStartupSequence.js +49 -0
  71. package/dist/orchestrator/src/cli/control/controlState.js +233 -2
  72. package/dist/orchestrator/src/cli/control/controlStatusDashboard.js +1899 -0
  73. package/dist/orchestrator/src/cli/control/controlTelegramBridgeBootstrapLifecycle.js +22 -0
  74. package/dist/orchestrator/src/cli/control/controlTelegramBridgeLifecycle.js +67 -0
  75. package/dist/orchestrator/src/cli/control/controlTelegramBridgeOversightFacadeFactory.js +8 -0
  76. package/dist/orchestrator/src/cli/control/controlTelegramCommandController.js +49 -0
  77. package/dist/orchestrator/src/cli/control/controlTelegramDispatchRead.js +40 -0
  78. package/dist/orchestrator/src/cli/control/controlTelegramPollingController.js +89 -0
  79. package/dist/orchestrator/src/cli/control/controlTelegramProjectionNotificationController.js +29 -0
  80. package/dist/orchestrator/src/cli/control/controlTelegramPushState.js +63 -0
  81. package/dist/orchestrator/src/cli/control/controlTelegramQuestionRead.js +13 -0
  82. package/dist/orchestrator/src/cli/control/controlTelegramReadController.js +216 -0
  83. package/dist/orchestrator/src/cli/control/controlTelegramUpdateHandler.js +63 -0
  84. package/dist/orchestrator/src/cli/control/controlWatcher.js +73 -5
  85. package/dist/orchestrator/src/cli/control/delegationRegisterController.js +35 -0
  86. package/dist/orchestrator/src/cli/control/dynamicToolBridgePolicy.js +139 -0
  87. package/dist/orchestrator/src/cli/control/eventsSseController.js +12 -0
  88. package/dist/orchestrator/src/cli/control/linearBudgetState.js +1789 -0
  89. package/dist/orchestrator/src/cli/control/linearDispatchSource.js +1137 -0
  90. package/dist/orchestrator/src/cli/control/linearGraphqlClient.js +150 -0
  91. package/dist/orchestrator/src/cli/control/linearRateLimit.js +102 -0
  92. package/dist/orchestrator/src/cli/control/linearWebhookController.js +499 -0
  93. package/dist/orchestrator/src/cli/control/liveLinearAdvisoryRuntime.js +70 -0
  94. package/dist/orchestrator/src/cli/control/observabilityApiController.js +173 -0
  95. package/dist/orchestrator/src/cli/control/observabilityReadModel.js +500 -0
  96. package/dist/orchestrator/src/cli/control/observabilitySurface.js +284 -0
  97. package/dist/orchestrator/src/cli/control/observabilityUpdateNotifier.js +22 -0
  98. package/dist/orchestrator/src/cli/control/operatorDashboardPresenter.js +252 -0
  99. package/dist/orchestrator/src/cli/control/providerAgentCapacity.js +70 -0
  100. package/dist/orchestrator/src/cli/control/providerControlHostFreshnessGauge.js +1068 -0
  101. package/dist/orchestrator/src/cli/control/providerIntakeState.js +473 -0
  102. package/dist/orchestrator/src/cli/control/providerIssueHandoff.js +6811 -0
  103. package/dist/orchestrator/src/cli/control/providerIssueObservability.js +1348 -0
  104. package/dist/orchestrator/src/cli/control/providerIssueRetryQueue.js +84 -0
  105. package/dist/orchestrator/src/cli/control/providerLinearRuntimeProof.js +588 -0
  106. package/dist/orchestrator/src/cli/control/providerLinearScreenshotProof.js +473 -0
  107. package/dist/orchestrator/src/cli/control/providerLinearWorkerTruth.js +383 -0
  108. package/dist/orchestrator/src/cli/control/providerLinearWorkflowAudit.js +254 -0
  109. package/dist/orchestrator/src/cli/control/providerLinearWorkflowFacade.js +5573 -0
  110. package/dist/orchestrator/src/cli/control/providerLinearWorkflowStates.js +115 -0
  111. package/dist/orchestrator/src/cli/control/providerMergeCloseout.js +1868 -0
  112. package/dist/orchestrator/src/cli/control/providerOperatorAutopilot.js +1580 -0
  113. package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLifecycle.js +154 -0
  114. package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLocalRolloutExecution.js +1006 -0
  115. package/dist/orchestrator/src/cli/control/providerPollingHealth.js +435 -0
  116. package/dist/orchestrator/src/cli/control/providerTerminalCleanup.js +516 -0
  117. package/dist/orchestrator/src/cli/control/providerWorkerHosts.js +191 -0
  118. package/dist/orchestrator/src/cli/control/providerWorkflowConfigStore.js +515 -0
  119. package/dist/orchestrator/src/cli/control/questionChildResolutionAdapter.js +361 -0
  120. package/dist/orchestrator/src/cli/control/questionQueueController.js +181 -0
  121. package/dist/orchestrator/src/cli/control/questionReadRetryDeduplication.js +9 -0
  122. package/dist/orchestrator/src/cli/control/questionReadSequence.js +10 -0
  123. package/dist/orchestrator/src/cli/control/securityViolationController.js +27 -0
  124. package/dist/orchestrator/src/cli/control/selectedRunProjection.js +1838 -0
  125. package/dist/orchestrator/src/cli/control/telegramOversightApiClient.js +48 -0
  126. package/dist/orchestrator/src/cli/control/telegramOversightBridge.js +180 -0
  127. package/dist/orchestrator/src/cli/control/telegramOversightBridgeProjectionDeliveryQueue.js +25 -0
  128. package/dist/orchestrator/src/cli/control/telegramOversightBridgeRuntimeLifecycle.js +45 -0
  129. package/dist/orchestrator/src/cli/control/telegramOversightBridgeStateStore.js +77 -0
  130. package/dist/orchestrator/src/cli/control/telegramOversightControlActionApiClient.js +45 -0
  131. package/dist/orchestrator/src/cli/control/trackerDispatchPilot.js +439 -0
  132. package/dist/orchestrator/src/cli/control/uiDataController.js +34 -0
  133. package/dist/orchestrator/src/cli/control/uiSessionController.js +100 -0
  134. package/dist/orchestrator/src/cli/controlHostCliShell.js +860 -0
  135. package/dist/orchestrator/src/cli/controlHostFreshnessGaugeCliShell.js +129 -0
  136. package/dist/orchestrator/src/cli/controlHostSupervisionCliShell.js +2127 -0
  137. package/dist/orchestrator/src/cli/delegationCliShell.js +62 -0
  138. package/dist/orchestrator/src/cli/delegationServer.js +567 -678
  139. package/dist/orchestrator/src/cli/delegationServerCliShell.js +52 -0
  140. package/dist/orchestrator/src/cli/delegationServerQuestionFlowShell.js +228 -0
  141. package/dist/orchestrator/src/cli/delegationServerToolDispatchShell.js +411 -0
  142. package/dist/orchestrator/src/cli/delegationServerTransport.js +274 -0
  143. package/dist/orchestrator/src/cli/delegationSetup.js +51 -171
  144. package/dist/orchestrator/src/cli/devtoolsCliShell.js +34 -0
  145. package/dist/orchestrator/src/cli/doctor.js +542 -122
  146. package/dist/orchestrator/src/cli/doctorCliRequestShell.js +72 -0
  147. package/dist/orchestrator/src/cli/doctorCliShell.js +138 -0
  148. package/dist/orchestrator/src/cli/doctorUsage.js +119 -15
  149. package/dist/orchestrator/src/cli/exec/experience.js +16 -2
  150. package/dist/orchestrator/src/cli/exec/summary.js +3 -0
  151. package/dist/orchestrator/src/cli/execCliShell.js +51 -0
  152. package/dist/orchestrator/src/cli/flowCliRequestShell.js +44 -0
  153. package/dist/orchestrator/src/cli/flowCliShell.js +239 -0
  154. package/dist/orchestrator/src/cli/frontendTestCliRequestShell.js +80 -0
  155. package/dist/orchestrator/src/cli/frontendTestCliShell.js +41 -0
  156. package/dist/orchestrator/src/cli/init.js +1 -0
  157. package/dist/orchestrator/src/cli/initCliShell.js +50 -0
  158. package/dist/orchestrator/src/cli/linearCliShell.js +1200 -0
  159. package/dist/orchestrator/src/cli/mcpEnableCliShell.js +132 -0
  160. package/dist/orchestrator/src/cli/metrics/metricsAggregator.js +3 -2
  161. package/dist/orchestrator/src/cli/metrics/metricsRecorder.js +56 -0
  162. package/dist/orchestrator/src/cli/orchestrator.js +66 -1376
  163. package/dist/orchestrator/src/cli/planCliShell.js +19 -0
  164. package/dist/orchestrator/src/cli/prCliShell.js +41 -0
  165. package/dist/orchestrator/src/cli/providerLinearChildLanePhaseContract.js +204 -0
  166. package/dist/orchestrator/src/cli/providerLinearChildLaneRunner.js +1772 -0
  167. package/dist/orchestrator/src/cli/providerLinearChildLaneShell.js +2420 -0
  168. package/dist/orchestrator/src/cli/providerLinearChildStreamShell.js +385 -0
  169. package/dist/orchestrator/src/cli/providerLinearWorkerRunner.js +5738 -0
  170. package/dist/orchestrator/src/cli/resumeCliShell.js +14 -0
  171. package/dist/orchestrator/src/cli/reviewCliLaunchShell.js +72 -0
  172. package/dist/orchestrator/src/cli/rlm/alignment.js +3 -3
  173. package/dist/orchestrator/src/cli/rlm/context.js +94 -7
  174. package/dist/orchestrator/src/cli/rlm/rlmCodexRuntimeShell.js +546 -0
  175. package/dist/orchestrator/src/cli/rlm/symbolic.js +4 -2
  176. package/dist/orchestrator/src/cli/rlmCliRequestShell.js +42 -0
  177. package/dist/orchestrator/src/cli/rlmCompletionCliShell.js +46 -0
  178. package/dist/orchestrator/src/cli/rlmLaunchCliShell.js +51 -0
  179. package/dist/orchestrator/src/cli/rlmRunner.js +83 -523
  180. package/dist/orchestrator/src/cli/run/blockMemory.js +500 -0
  181. package/dist/orchestrator/src/cli/run/manifest.js +410 -73
  182. package/dist/orchestrator/src/cli/run/manifestPersister.js +45 -14
  183. package/dist/orchestrator/src/cli/run/runMemoryController.js +216 -0
  184. package/dist/orchestrator/src/cli/run/source0.js +690 -0
  185. package/dist/orchestrator/src/cli/run/workspacePath.js +101 -0
  186. package/dist/orchestrator/src/cli/runtime/mode.js +2 -1
  187. package/dist/orchestrator/src/cli/runtime/provider.js +39 -2
  188. package/dist/orchestrator/src/cli/selfCheckCliShell.js +12 -0
  189. package/dist/orchestrator/src/cli/services/commandRunner.js +667 -18
  190. package/dist/orchestrator/src/cli/services/execRuntime.js +66 -1
  191. package/dist/orchestrator/src/cli/services/orchestratorAutoScoutEvidenceRecorder.js +71 -0
  192. package/dist/orchestrator/src/cli/services/orchestratorCloudBranchResolution.js +8 -0
  193. package/dist/orchestrator/src/cli/services/orchestratorCloudEnvironmentResolution.js +22 -0
  194. package/dist/orchestrator/src/cli/services/orchestratorCloudExecutionLifecycleShell.js +39 -0
  195. package/dist/orchestrator/src/cli/services/orchestratorCloudPromptBuilder.js +37 -0
  196. package/dist/orchestrator/src/cli/services/orchestratorCloudRouteFallbackContract.js +45 -0
  197. package/dist/orchestrator/src/cli/services/orchestratorCloudRouteShell.js +36 -0
  198. package/dist/orchestrator/src/cli/services/orchestratorCloudTargetExecutor.js +277 -0
  199. package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycle.js +98 -0
  200. package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycleShell.js +54 -0
  201. package/dist/orchestrator/src/cli/services/orchestratorExecutionLifecycle.js +112 -0
  202. package/dist/orchestrator/src/cli/services/orchestratorExecutionModePolicy.js +27 -0
  203. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteAdapterShell.js +59 -0
  204. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteDecisionShell.js +57 -0
  205. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteState.js +21 -0
  206. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouter.js +2 -0
  207. package/dist/orchestrator/src/cli/services/orchestratorLocalPipelineExecutor.js +149 -0
  208. package/dist/orchestrator/src/cli/services/orchestratorLocalRouteShell.js +63 -0
  209. package/dist/orchestrator/src/cli/services/orchestratorPlanShell.js +54 -0
  210. package/dist/orchestrator/src/cli/services/orchestratorPlanTargetTracker.js +16 -0
  211. package/dist/orchestrator/src/cli/services/orchestratorResumePreparationShell.js +84 -0
  212. package/dist/orchestrator/src/cli/services/orchestratorResumeTokenValidation.js +15 -0
  213. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleCompletion.js +31 -0
  214. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleExecutionRegistration.js +37 -0
  215. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleOrchestrationShell.js +83 -0
  216. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleTaskManagerShell.js +37 -0
  217. package/dist/orchestrator/src/cli/services/orchestratorRuntimeManifestMutation.js +20 -0
  218. package/dist/orchestrator/src/cli/services/orchestratorStartPreparationShell.js +56 -0
  219. package/dist/orchestrator/src/cli/services/orchestratorStatusShell.js +70 -0
  220. package/dist/orchestrator/src/cli/services/pipelineResolver.js +7 -3
  221. package/dist/orchestrator/src/cli/services/plannerMemory.js +119 -0
  222. package/dist/orchestrator/src/cli/services/runPreparation.js +7 -3
  223. package/dist/orchestrator/src/cli/services/runSummaryWriter.js +9 -0
  224. package/dist/orchestrator/src/cli/setupBootstrapShell.js +114 -0
  225. package/dist/orchestrator/src/cli/setupCliShell.js +51 -0
  226. package/dist/orchestrator/src/cli/skillsCliShell.js +56 -0
  227. package/dist/orchestrator/src/cli/startCliRequestShell.js +53 -0
  228. package/dist/orchestrator/src/cli/startCliShell.js +68 -0
  229. package/dist/orchestrator/src/cli/statusCliShell.js +22 -0
  230. package/dist/orchestrator/src/cli/utils/authProvenanceFingerprint.js +27 -0
  231. package/dist/orchestrator/src/cli/utils/cloudPreflight.js +83 -1
  232. package/dist/orchestrator/src/cli/utils/delegationConfigParser.js +250 -0
  233. package/dist/orchestrator/src/cli/utils/delegationMcpHealth.js +1382 -0
  234. package/dist/orchestrator/src/cli/utils/devtools.js +2 -54
  235. package/dist/orchestrator/src/cli/utils/mcpServerEntry.js +53 -0
  236. package/dist/orchestrator/src/cli/utils/packageProgramResolver.js +151 -0
  237. package/dist/orchestrator/src/cli/utils/providerOverrideEnv.js +71 -0
  238. package/dist/orchestrator/src/cli/utils/trailingJsonObject.js +59 -0
  239. package/dist/orchestrator/src/learning/crystalizer.js +2 -2
  240. package/dist/orchestrator/src/persistence/ExperienceStore.js +233 -49
  241. package/dist/orchestrator/src/persistence/TaskStateStore.js +6 -6
  242. package/dist/orchestrator/src/persistence/lockFile.js +70 -4
  243. package/dist/orchestrator/src/persistence/sanitizeIdentifier.js +39 -0
  244. package/dist/orchestrator/src/sync/createCloudSyncWorker.js +3 -2
  245. package/dist/orchestrator/src/utils/atomicWrite.js +17 -2
  246. package/dist/packages/orchestrator/src/exec/unified-exec.js +99 -6
  247. package/dist/packages/orchestrator/src/instructions/promptPacks.js +150 -19
  248. package/dist/packages/sdk-node/src/orchestrator.js +137 -13
  249. package/dist/packages/shared/config/designConfig.js +8 -1
  250. package/dist/packages/shared/streams/stdio.js +1 -1
  251. package/dist/scripts/design/pipeline/permit.js +15 -0
  252. package/dist/scripts/lib/docs-catalog.js +365 -0
  253. package/dist/scripts/lib/docs-helpers.js +87 -5
  254. package/dist/scripts/lib/pr-watch-merge.js +1088 -80
  255. package/dist/scripts/lib/provider-run-contract.js +26 -0
  256. package/dist/scripts/lib/review-command-intent-classification.js +532 -0
  257. package/dist/scripts/lib/review-command-probe-classification.js +385 -0
  258. package/dist/scripts/lib/review-execution-boundary-preflight.js +279 -0
  259. package/dist/scripts/lib/review-execution-runtime.js +753 -0
  260. package/dist/scripts/lib/review-execution-state.js +1144 -0
  261. package/dist/scripts/lib/review-execution-telemetry.js +215 -0
  262. package/dist/scripts/lib/review-inspection-target-parsing.js +78 -0
  263. package/dist/scripts/lib/review-launch-attempt.js +601 -0
  264. package/dist/scripts/lib/review-meta-surface-boundary-analysis.js +300 -0
  265. package/dist/scripts/lib/review-meta-surface-normalization.js +746 -0
  266. package/dist/scripts/lib/review-non-interactive-handoff.js +61 -0
  267. package/dist/scripts/lib/review-prompt-context.js +376 -0
  268. package/dist/scripts/lib/review-scope-advisory.js +286 -0
  269. package/dist/scripts/lib/review-scope-paths.js +123 -0
  270. package/dist/scripts/lib/review-shell-command-parser.js +389 -0
  271. package/dist/scripts/lib/review-shell-env-interpreter.js +340 -0
  272. package/dist/scripts/lib/run-manifests.js +192 -36
  273. package/dist/scripts/lib/spark-policy-classifier.js +593 -0
  274. package/dist/scripts/run-review.js +507 -1777
  275. package/docs/public/downstream-setup.md +106 -0
  276. package/docs/public/provider-onboarding.md +173 -0
  277. package/package.json +20 -10
  278. package/plugins/codex-orchestrator/.codex-plugin/plugin.json +30 -0
  279. package/plugins/codex-orchestrator/.mcp.json +13 -0
  280. package/plugins/codex-orchestrator/launcher.mjs +359 -0
  281. package/schemas/manifest.json +394 -0
  282. package/skills/collab-subagents-first/SKILL.md +1 -1
  283. package/skills/delegation-usage/DELEGATION_GUIDE.md +24 -11
  284. package/skills/delegation-usage/SKILL.md +19 -13
  285. package/skills/land/SKILL.md +77 -0
  286. package/skills/linear/SKILL.md +255 -0
  287. package/skills/release/SKILL.md +47 -3
  288. package/skills/standalone-review/SKILL.md +6 -1
  289. package/templates/README.md +4 -2
  290. package/templates/codex/.codex/agents/awaiter-high.toml +2 -2
  291. package/templates/codex/.codex/agents/worker-complex.toml +1 -1
  292. package/templates/codex/.codex/config.toml +3 -4
  293. package/templates/codex/.codex/providers/README.md +13 -0
  294. package/templates/codex/.codex/providers/control.example.json +18 -0
  295. package/templates/codex/.codex/providers/provider.env.example +15 -0
  296. package/templates/codex/AGENTS.md +12 -7
  297. package/templates/codex/mcp-client.json +5 -1
  298. package/docs/README.md +0 -310
  299. package/docs/assets/setup.gif +0 -0
@@ -0,0 +1,98 @@
1
+ import process from 'node:process';
2
+ import { logger } from '../../logger.js';
3
+ import { loadDelegationConfigFiles, computeEffectiveDelegationConfig, parseDelegationConfigOverride, splitDelegationConfigOverrides } from '../config/delegationConfig.js';
4
+ import { ControlServer } from '../control/controlServer.js';
5
+ import { RunEventStream, attachRunEventAdapter } from '../events/runEventStream.js';
6
+ const CONFIG_OVERRIDE_ENV_KEYS = ['CODEX_CONFIG_OVERRIDES', 'CODEX_MCP_CONFIG_OVERRIDES'];
7
+ function collectDelegationEnvOverrides(env = process.env) {
8
+ const layers = [];
9
+ for (const key of CONFIG_OVERRIDE_ENV_KEYS) {
10
+ const raw = env[key];
11
+ if (!raw) {
12
+ continue;
13
+ }
14
+ const values = splitDelegationConfigOverrides(raw);
15
+ for (const value of values) {
16
+ try {
17
+ const layer = parseDelegationConfigOverride(value, 'env');
18
+ if (layer) {
19
+ layers.push(layer);
20
+ }
21
+ }
22
+ catch (error) {
23
+ logger.warn(`Invalid delegation config override (env): ${error?.message ?? String(error)}`);
24
+ }
25
+ }
26
+ }
27
+ return layers;
28
+ }
29
+ export async function startOrchestratorControlPlaneLifecycle(options) {
30
+ const eventStream = await RunEventStream.create({
31
+ paths: options.paths,
32
+ taskId: options.taskId,
33
+ runId: options.runId,
34
+ pipelineId: options.pipeline.id,
35
+ pipelineTitle: options.pipeline.title
36
+ });
37
+ let controlServer = null;
38
+ let detachStream = null;
39
+ const onEventEntry = (entry) => {
40
+ controlServer?.broadcast(entry);
41
+ };
42
+ const close = async () => {
43
+ if (detachStream) {
44
+ try {
45
+ detachStream();
46
+ }
47
+ catch (error) {
48
+ logger.warn(`Failed to detach run event stream: ${error?.message ?? String(error)}`);
49
+ }
50
+ detachStream = null;
51
+ }
52
+ if (controlServer) {
53
+ try {
54
+ await controlServer.close();
55
+ }
56
+ catch (error) {
57
+ logger.warn(`Failed to close control server: ${error?.message ?? String(error)}`);
58
+ }
59
+ controlServer = null;
60
+ }
61
+ try {
62
+ await eventStream.close();
63
+ }
64
+ catch (error) {
65
+ logger.warn(`Failed to close run event stream: ${error?.message ?? String(error)}`);
66
+ }
67
+ };
68
+ try {
69
+ const configFiles = await loadDelegationConfigFiles({ repoRoot: options.repoRoot });
70
+ const envOverrideLayers = collectDelegationEnvOverrides();
71
+ const layers = [configFiles.global, configFiles.repo, ...envOverrideLayers].filter(Boolean);
72
+ const effectiveConfig = computeEffectiveDelegationConfig({
73
+ repoRoot: options.repoRoot,
74
+ layers
75
+ });
76
+ controlServer = effectiveConfig.ui.controlEnabled
77
+ ? await ControlServer.start({
78
+ paths: options.paths,
79
+ config: effectiveConfig,
80
+ eventStream,
81
+ runId: options.runId
82
+ })
83
+ : null;
84
+ const onStreamError = (error, payload) => {
85
+ logger.warn(`Failed to append run event ${payload.event}: ${error.message}`);
86
+ };
87
+ detachStream = attachRunEventAdapter(options.emitter, eventStream, onEventEntry, onStreamError);
88
+ return {
89
+ eventStream,
90
+ onEventEntry,
91
+ close
92
+ };
93
+ }
94
+ catch (error) {
95
+ await close();
96
+ throw error;
97
+ }
98
+ }
@@ -0,0 +1,54 @@
1
+ import { RunEventEmitter, RunEventPublisher } from '../events/runEvents.js';
2
+ import { startOrchestratorControlPlaneLifecycle } from './orchestratorControlPlaneLifecycle.js';
3
+ function createOrchestratorRunEventPublisher(params) {
4
+ if (!params.emitter) {
5
+ return undefined;
6
+ }
7
+ return new RunEventPublisher(params.emitter, {
8
+ taskId: params.manifest.task_id,
9
+ runId: params.manifest.run_id,
10
+ pipelineId: params.pipeline.id,
11
+ pipelineTitle: params.pipeline.title,
12
+ manifestPath: params.paths.manifestPath,
13
+ logPath: params.paths.logPath
14
+ });
15
+ }
16
+ export async function runOrchestratorControlPlaneLifecycleShell(params) {
17
+ const emitter = params.emitter ?? new RunEventEmitter();
18
+ const startLifecycle = params.startLifecycle ?? startOrchestratorControlPlaneLifecycle;
19
+ let controlPlaneLifecycle = null;
20
+ try {
21
+ try {
22
+ controlPlaneLifecycle = await startLifecycle({
23
+ repoRoot: params.repoRoot,
24
+ paths: params.paths,
25
+ taskId: params.manifest.task_id,
26
+ runId: params.manifest.run_id,
27
+ pipeline: params.pipeline,
28
+ emitter
29
+ });
30
+ }
31
+ catch (error) {
32
+ if (params.onStartFailure) {
33
+ await params.onStartFailure();
34
+ }
35
+ throw error;
36
+ }
37
+ const runEvents = createOrchestratorRunEventPublisher({
38
+ pipeline: params.pipeline,
39
+ manifest: params.manifest,
40
+ paths: params.paths,
41
+ emitter
42
+ });
43
+ return await params.runWithLifecycle({
44
+ runEvents,
45
+ eventStream: controlPlaneLifecycle.eventStream,
46
+ onEventEntry: controlPlaneLifecycle.onEventEntry
47
+ });
48
+ }
49
+ finally {
50
+ if (controlPlaneLifecycle) {
51
+ await controlPlaneLifecycle.close();
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,112 @@
1
+ import { logger } from '../../logger.js';
2
+ import { ControlWatcher } from '../control/controlWatcher.js';
3
+ import { snapshotStages } from '../events/runEvents.js';
4
+ import { appendMetricsEntry } from '../metrics/metricsRecorder.js';
5
+ import { appendSummary, finalizeStatus, updateHeartbeat } from '../run/manifest.js';
6
+ import { ManifestPersister } from '../run/manifestPersister.js';
7
+ import { relativeToRepo } from '../run/runPaths.js';
8
+ import { persistPipelineExperience } from './pipelineExperience.js';
9
+ import { resolveAdvancedAutopilotDecision } from '../utils/advancedAutopilot.js';
10
+ export async function runOrchestratorExecutionLifecycle(options) {
11
+ const { env, pipeline, manifest, paths, runEvents } = options;
12
+ const notes = [];
13
+ manifest.guardrail_status = undefined;
14
+ const persister = options.persister ??
15
+ new ManifestPersister({
16
+ manifest,
17
+ paths,
18
+ persistIntervalMs: Math.max(1000, manifest.heartbeat_interval_seconds * 1000)
19
+ });
20
+ const schedulePersist = (persistOptions = {}) => persister.schedule(persistOptions);
21
+ const pushHeartbeat = (forceManifest = false) => {
22
+ updateHeartbeat(manifest);
23
+ // Keep manifest.json current during long-running stages so raw manifest
24
+ // readers do not misclassify active runs as stale while only the sidecar
25
+ // heartbeat file advances.
26
+ return schedulePersist({ manifest: true, heartbeat: true, force: forceManifest });
27
+ };
28
+ const controlWatcher = new ControlWatcher({
29
+ paths,
30
+ manifest,
31
+ eventStream: options.eventStream,
32
+ onEntry: options.onEventEntry,
33
+ persist: () => schedulePersist({ manifest: true, force: true })
34
+ });
35
+ const context = { notes, persister, controlWatcher, schedulePersist };
36
+ await options.beforeStart?.(context);
37
+ manifest.status = 'in_progress';
38
+ updateHeartbeat(manifest);
39
+ const advancedDecision = resolveAdvancedAutopilotDecision({
40
+ pipelineId: pipeline.id,
41
+ targetMetadata: (options.target.metadata ?? null),
42
+ taskMetadata: (options.task.metadata ?? null),
43
+ env: options.advancedDecisionEnv
44
+ });
45
+ if (advancedDecision.enabled || advancedDecision.source !== 'default') {
46
+ const advancedSummary = `Advanced mode (${advancedDecision.mode}) ${advancedDecision.enabled ? 'enabled' : 'disabled'}: ${advancedDecision.reason}.`;
47
+ appendSummary(manifest, advancedSummary);
48
+ notes.push(advancedSummary);
49
+ if (options.mode === 'cloud') {
50
+ await schedulePersist({ manifest: true, force: true });
51
+ }
52
+ }
53
+ await schedulePersist({ manifest: true, heartbeat: true, force: true });
54
+ runEvents?.runStarted(snapshotStages(manifest, pipeline), manifest.status);
55
+ if (advancedDecision.autoScout) {
56
+ const scoutOutcome = await options.runAutoScout({
57
+ env,
58
+ paths,
59
+ manifest,
60
+ mode: options.mode,
61
+ pipeline,
62
+ target: options.target,
63
+ task: options.task,
64
+ envOverrides: options.envOverrides,
65
+ advancedDecision
66
+ });
67
+ const scoutMessage = scoutOutcome.status === 'recorded'
68
+ ? `Auto scout: evidence recorded at ${scoutOutcome.path}.`
69
+ : `Auto scout: ${scoutOutcome.message} (non-blocking).`;
70
+ appendSummary(manifest, scoutMessage);
71
+ notes.push(scoutMessage);
72
+ await schedulePersist({ manifest: true, force: true });
73
+ }
74
+ const heartbeatInterval = setInterval(() => {
75
+ void pushHeartbeat(false).catch((error) => {
76
+ logger.warn(`Heartbeat update failed for run ${manifest.run_id}: ${error?.message ?? String(error)}`);
77
+ });
78
+ }, manifest.heartbeat_interval_seconds * 1000);
79
+ let success = true;
80
+ try {
81
+ success = await options.executeBody(context);
82
+ }
83
+ finally {
84
+ clearInterval(heartbeatInterval);
85
+ await schedulePersist({ force: true });
86
+ }
87
+ await controlWatcher.sync();
88
+ if (controlWatcher.isCanceled()) {
89
+ finalizeStatus(manifest, 'cancelled', manifest.status_detail ?? 'run-canceled');
90
+ }
91
+ else if (success) {
92
+ finalizeStatus(manifest, 'succeeded');
93
+ }
94
+ else {
95
+ finalizeStatus(manifest, 'failed', manifest.status_detail ?? options.defaultFailureStatusDetail);
96
+ }
97
+ await options.afterFinalize?.(context);
98
+ updateHeartbeat(manifest);
99
+ await schedulePersist({ manifest: true, heartbeat: true, force: true }).catch((error) => {
100
+ logger.warn(`Heartbeat update failed for run ${manifest.run_id}: ${error?.message ?? String(error)}`);
101
+ });
102
+ await persistPipelineExperience({ env, pipeline, manifest, paths });
103
+ await schedulePersist({ force: true });
104
+ await appendMetricsEntry(env, paths, manifest, persister);
105
+ return {
106
+ success,
107
+ notes,
108
+ manifest,
109
+ manifestPath: relativeToRepo(env, paths.manifestPath),
110
+ logPath: relativeToRepo(env, paths.logPath)
111
+ };
112
+ }
@@ -0,0 +1,27 @@
1
+ import { CLI_EXECUTION_MODE_PARSER, resolveRequiresCloudPolicy } from '../../utils/executionMode.js';
2
+ export function requiresCloudOrchestratorExecution(task, subtask) {
3
+ const requiresCloudFlag = resolveRequiresCloudPolicy({
4
+ boolFlags: [subtask.requires_cloud, subtask.requiresCloud],
5
+ metadata: {
6
+ executionMode: typeof subtask.metadata?.executionMode === 'string'
7
+ ? subtask.metadata.executionMode
8
+ : null,
9
+ mode: typeof subtask.metadata?.mode === 'string' ? subtask.metadata.mode : null
10
+ },
11
+ metadataOrder: ['executionMode', 'mode'],
12
+ parseMode: CLI_EXECUTION_MODE_PARSER
13
+ });
14
+ if (requiresCloudFlag !== null) {
15
+ return requiresCloudFlag;
16
+ }
17
+ return Boolean(task.metadata?.execution?.parallel);
18
+ }
19
+ export function determineOrchestratorExecutionMode(task, subtask, overrideMode) {
20
+ if (overrideMode) {
21
+ return overrideMode;
22
+ }
23
+ if (requiresCloudOrchestratorExecution(task, subtask)) {
24
+ return 'cloud';
25
+ }
26
+ return 'mcp';
27
+ }
@@ -0,0 +1,59 @@
1
+ import { TaskManager } from '../../manager.js';
2
+ import { RunManifestWriter } from '../../persistence/RunManifestWriter.js';
3
+ import { TaskStateStore } from '../../persistence/TaskStateStore.js';
4
+ import { CommandPlanner, CommandBuilder, CommandTester, CommandReviewer } from '../adapters/index.js';
5
+ import { determineOrchestratorExecutionMode } from './orchestratorExecutionModePolicy.js';
6
+ import { routeOrchestratorExecution } from './orchestratorExecutionRouter.js';
7
+ import { runOrchestratorCloudExecutionLifecycleShell } from './orchestratorCloudExecutionLifecycleShell.js';
8
+ export function buildOrchestratorTaskManagerOptions(params) {
9
+ const planner = params.plannerInstance ?? new CommandPlanner(params.pipeline);
10
+ const builder = new CommandBuilder(params.executePipeline);
11
+ const tester = new CommandTester(params.getResult);
12
+ const reviewer = new CommandReviewer(params.getResult);
13
+ const stateStore = new TaskStateStore({ outDir: params.env.outRoot, runsDir: params.env.runsRoot });
14
+ const manifestWriter = new RunManifestWriter({ runsDir: params.env.runsRoot });
15
+ return {
16
+ planner,
17
+ builder,
18
+ tester,
19
+ reviewer,
20
+ runIdFactory: () => params.runId,
21
+ modePolicy: (task, subtask) => determineOrchestratorExecutionMode(task, subtask, params.modeOverride),
22
+ persistence: { autoStart: true, stateStore, manifestWriter }
23
+ };
24
+ }
25
+ export function createOrchestratorTaskManager(params) {
26
+ return new TaskManager(buildOrchestratorTaskManagerOptions(params));
27
+ }
28
+ export async function executeOrchestratorPipelineWithRouteAdapter(params) {
29
+ const routeExecution = params.routeExecution ?? routeOrchestratorExecution;
30
+ return routeExecution({
31
+ ...params.options,
32
+ applyRuntimeSelection: params.applyRuntimeSelection,
33
+ executeCloudPipeline: (options) => params.executeCloudPipeline(options),
34
+ runAutoScout: params.runAutoScout,
35
+ startSubpipeline: params.startSubpipeline
36
+ });
37
+ }
38
+ export async function executeOrchestratorPipelineRouteEntryShell(params) {
39
+ const executePipelineWithRouteAdapter = params.executePipelineWithRouteAdapter ?? executeOrchestratorPipelineWithRouteAdapter;
40
+ const runCloudExecutionLifecycle = params.runCloudExecutionLifecycleShell ?? runOrchestratorCloudExecutionLifecycleShell;
41
+ return executePipelineWithRouteAdapter({
42
+ options: params.options,
43
+ applyRuntimeSelection: params.applyRuntimeSelection,
44
+ executeCloudPipeline: (options) => runCloudExecutionLifecycle({
45
+ ...options,
46
+ runAutoScout: params.runAutoScout
47
+ }),
48
+ runAutoScout: params.runAutoScout,
49
+ startSubpipeline: ({ pipelineId, executionModeOverride, runtimeModeRequested }) => params.startPipeline({
50
+ taskId: params.options.env.taskId,
51
+ pipelineId,
52
+ parentRunId: params.options.manifest.run_id,
53
+ format: 'json',
54
+ executionMode: executionModeOverride,
55
+ runtimeMode: runtimeModeRequested
56
+ }),
57
+ routeExecution: params.routeExecution
58
+ });
59
+ }
@@ -0,0 +1,57 @@
1
+ import { logger } from '../../logger.js';
2
+ import { appendSummary, finalizeStatus } from '../run/manifest.js';
3
+ import { executeOrchestratorCloudRouteShell } from './orchestratorCloudRouteShell.js';
4
+ import { resolveOrchestratorExecutionRouteState } from './orchestratorExecutionRouteState.js';
5
+ import { executeOrchestratorLocalRouteShell } from './orchestratorLocalRouteShell.js';
6
+ function failExecutionRoute(options, statusDetail, detail) {
7
+ finalizeStatus(options.manifest, 'failed', statusDetail);
8
+ appendSummary(options.manifest, detail);
9
+ logger.error(detail);
10
+ return {
11
+ success: false,
12
+ notes: [detail],
13
+ manifest: options.manifest,
14
+ manifestPath: options.paths.manifestPath,
15
+ logPath: options.paths.logPath
16
+ };
17
+ }
18
+ async function executeCloudRoute(options, state) {
19
+ return await executeOrchestratorCloudRouteShell({
20
+ repoRoot: options.env.repoRoot,
21
+ task: options.task,
22
+ target: options.target,
23
+ manifest: options.manifest,
24
+ state,
25
+ executeCloudPipeline: (envOverrides) => options.executeCloudPipeline({ ...options, envOverrides }),
26
+ reroute: (reroute) => routeOrchestratorExecution({
27
+ ...options,
28
+ ...reroute
29
+ }),
30
+ failExecutionRoute: (statusDetail, detail) => failExecutionRoute(options, statusDetail, detail)
31
+ });
32
+ }
33
+ async function executeLocalRoute(options, state) {
34
+ return executeOrchestratorLocalRouteShell({ ...options, state });
35
+ }
36
+ export async function routeOrchestratorExecution(options) {
37
+ let state;
38
+ try {
39
+ state = await resolveOrchestratorExecutionRouteState({
40
+ repoRoot: options.env.repoRoot,
41
+ manifest: options.manifest,
42
+ mode: options.mode,
43
+ runtimeModeRequested: options.runtimeModeRequested,
44
+ runtimeModeSource: options.runtimeModeSource,
45
+ envOverrides: options.envOverrides,
46
+ applyRuntimeSelection: options.applyRuntimeSelection
47
+ });
48
+ }
49
+ catch (error) {
50
+ const detail = `Runtime selection failed: ${error?.message ?? String(error)}`;
51
+ return failExecutionRoute(options, 'runtime-selection-failed', detail);
52
+ }
53
+ if (options.mode === 'cloud') {
54
+ return await executeCloudRoute(options, state);
55
+ }
56
+ return await executeLocalRoute(options, state);
57
+ }
@@ -0,0 +1,21 @@
1
+ import process from 'node:process';
2
+ import { resolveRuntimeSelection } from '../runtime/index.js';
3
+ export async function resolveOrchestratorExecutionRouteState(options) {
4
+ const baseEnvOverrides = { ...(options.envOverrides ?? {}) };
5
+ const mergedEnv = { ...process.env, ...baseEnvOverrides };
6
+ const runtimeSelection = await resolveRuntimeSelection({
7
+ requestedMode: options.runtimeModeRequested,
8
+ source: options.runtimeModeSource,
9
+ executionMode: options.mode,
10
+ repoRoot: options.repoRoot,
11
+ env: mergedEnv,
12
+ runId: options.manifest.run_id
13
+ });
14
+ options.applyRuntimeSelection(options.manifest, runtimeSelection);
15
+ const effectiveEnvOverrides = {
16
+ ...baseEnvOverrides,
17
+ ...runtimeSelection.env_overrides
18
+ };
19
+ const effectiveMergedEnv = { ...process.env, ...effectiveEnvOverrides };
20
+ return { runtimeSelection, effectiveEnvOverrides, effectiveMergedEnv };
21
+ }
@@ -0,0 +1,2 @@
1
+ export { routeOrchestratorExecution } from './orchestratorExecutionRouteDecisionShell.js';
2
+ export { determineOrchestratorExecutionMode, requiresCloudOrchestratorExecution } from './orchestratorExecutionModePolicy.js';
@@ -0,0 +1,149 @@
1
+ import { runCommandStage } from './commandRunner.js';
2
+ import { appendSummary, removeStageFailureSummary, removeSubpipelineFailureSummary } from '../run/manifest.js';
3
+ import { relativeToRepo, resolveRunPaths } from '../run/runPaths.js';
4
+ import { isoTimestamp } from '../utils/time.js';
5
+ export async function executeOrchestratorLocalPipeline(options) {
6
+ const notes = [];
7
+ const { env, pipeline, manifest, paths, persister, envOverrides, runtimeMode, runtimeSessionId, runEvents, controlWatcher, schedulePersist, startSubpipeline } = options;
8
+ let success = true;
9
+ for (let i = 0; i < pipeline.stages.length; i += 1) {
10
+ await controlWatcher.sync();
11
+ await controlWatcher.waitForResume();
12
+ if (controlWatcher.isCanceled()) {
13
+ manifest.status_detail = 'run-canceled';
14
+ success = false;
15
+ break;
16
+ }
17
+ const stage = pipeline.stages[i];
18
+ const entry = manifest.commands[i];
19
+ if (!entry) {
20
+ continue;
21
+ }
22
+ if (entry.status === 'succeeded' || entry.status === 'skipped') {
23
+ notes.push(`${stage.title}: ${entry.status}`);
24
+ continue;
25
+ }
26
+ entry.status = 'pending';
27
+ entry.started_at = isoTimestamp();
28
+ void schedulePersist({ manifest: true });
29
+ if (stage.kind === 'command') {
30
+ try {
31
+ const result = await runCommandStage({
32
+ env,
33
+ paths,
34
+ manifest,
35
+ stage,
36
+ index: entry.index,
37
+ events: runEvents,
38
+ persister,
39
+ envOverrides,
40
+ runtimeMode,
41
+ runtimeSessionId
42
+ });
43
+ notes.push(`${stage.title}: ${result.summary}`);
44
+ const updatedEntry = manifest.commands[i];
45
+ if (updatedEntry?.status === 'failed') {
46
+ manifest.status_detail = `stage:${stage.id}:failed`;
47
+ appendSummary(manifest, `Stage '${stage.title}' failed with exit code ${result.exitCode}.`);
48
+ success = false;
49
+ await schedulePersist({ manifest: true, force: true });
50
+ break;
51
+ }
52
+ removeStageFailureSummary(manifest, stage.title);
53
+ }
54
+ catch (error) {
55
+ entry.status = 'failed';
56
+ entry.completed_at = isoTimestamp();
57
+ entry.summary = `Execution error: ${error?.message ?? String(error)}`;
58
+ manifest.status_detail = `stage:${stage.id}:error`;
59
+ appendSummary(manifest, entry.summary);
60
+ await schedulePersist({ manifest: true, force: true });
61
+ runEvents?.stageCompleted({
62
+ stageId: stage.id,
63
+ stageIndex: entry.index,
64
+ title: stage.title,
65
+ kind: 'command',
66
+ status: entry.status,
67
+ exitCode: entry.exit_code,
68
+ summary: entry.summary,
69
+ logPath: entry.log_path
70
+ });
71
+ success = false;
72
+ break;
73
+ }
74
+ continue;
75
+ }
76
+ entry.status = 'running';
77
+ await schedulePersist({ manifest: true, force: true });
78
+ runEvents?.stageStarted({
79
+ stageId: stage.id,
80
+ stageIndex: entry.index,
81
+ title: stage.title,
82
+ kind: 'subpipeline',
83
+ logPath: entry.log_path,
84
+ status: entry.status
85
+ });
86
+ try {
87
+ const child = await startSubpipeline(stage.pipeline);
88
+ entry.completed_at = isoTimestamp();
89
+ entry.sub_run_id = child.manifest.run_id;
90
+ entry.summary = child.runSummary.review.summary ?? null;
91
+ entry.status =
92
+ child.manifest.status === 'succeeded' ? 'succeeded' : stage.optional ? 'skipped' : 'failed';
93
+ entry.command = null;
94
+ manifest.child_runs.push({
95
+ run_id: child.manifest.run_id,
96
+ pipeline_id: stage.pipeline,
97
+ status: child.manifest.status,
98
+ manifest: relativeToRepo(env, resolveRunPaths(env, child.manifest.run_id).manifestPath)
99
+ });
100
+ notes.push(`${stage.title}: ${entry.status}`);
101
+ await schedulePersist({ manifest: true, force: true });
102
+ runEvents?.stageCompleted({
103
+ stageId: stage.id,
104
+ stageIndex: entry.index,
105
+ title: stage.title,
106
+ kind: 'subpipeline',
107
+ status: entry.status,
108
+ exitCode: entry.exit_code,
109
+ summary: entry.summary,
110
+ logPath: entry.log_path,
111
+ subRunId: entry.sub_run_id
112
+ });
113
+ if (!stage.optional && entry.status === 'failed') {
114
+ manifest.status_detail = `subpipeline:${stage.pipeline}:failed`;
115
+ appendSummary(manifest, `Sub-pipeline '${stage.pipeline}' failed.`);
116
+ await schedulePersist({ manifest: true, force: true });
117
+ success = false;
118
+ break;
119
+ }
120
+ removeSubpipelineFailureSummary(manifest, stage.pipeline);
121
+ }
122
+ catch (error) {
123
+ entry.completed_at = isoTimestamp();
124
+ entry.summary = `Sub-pipeline error: ${error?.message ?? String(error)}`;
125
+ entry.status = stage.optional ? 'skipped' : 'failed';
126
+ entry.command = null;
127
+ manifest.status_detail = `subpipeline:${stage.pipeline}:error`;
128
+ appendSummary(manifest, entry.summary);
129
+ notes.push(`${stage.title}: ${entry.status}`);
130
+ await schedulePersist({ manifest: true, force: true });
131
+ runEvents?.stageCompleted({
132
+ stageId: stage.id,
133
+ stageIndex: entry.index,
134
+ title: stage.title,
135
+ kind: 'subpipeline',
136
+ status: entry.status,
137
+ exitCode: entry.exit_code,
138
+ summary: entry.summary,
139
+ logPath: entry.log_path,
140
+ subRunId: entry.sub_run_id
141
+ });
142
+ if (!stage.optional) {
143
+ success = false;
144
+ break;
145
+ }
146
+ }
147
+ }
148
+ return { success, notes };
149
+ }
@@ -0,0 +1,63 @@
1
+ import { appendSummary, ensureGuardrailStatus } from '../run/manifest.js';
2
+ import { runOrchestratorExecutionLifecycle } from './orchestratorExecutionLifecycle.js';
3
+ import { executeOrchestratorLocalPipeline } from './orchestratorLocalPipelineExecutor.js';
4
+ export async function executeOrchestratorLocalRouteShell(options) {
5
+ const { env, pipeline, manifest, paths, runEvents, state } = options;
6
+ return runOrchestratorExecutionLifecycle({
7
+ env,
8
+ pipeline,
9
+ manifest,
10
+ paths,
11
+ mode: options.mode,
12
+ target: options.target,
13
+ task: options.task,
14
+ runEvents,
15
+ eventStream: options.eventStream,
16
+ onEventEntry: options.onEventEntry,
17
+ persister: options.persister,
18
+ envOverrides: state.effectiveEnvOverrides,
19
+ advancedDecisionEnv: state.effectiveMergedEnv,
20
+ defaultFailureStatusDetail: 'pipeline-failed',
21
+ beforeStart: ({ notes }) => {
22
+ if (state.runtimeSelection.fallback.occurred) {
23
+ const fallbackCode = state.runtimeSelection.fallback.code ?? 'runtime-fallback';
24
+ const fallbackReason = state.runtimeSelection.fallback.reason ?? 'runtime fallback occurred';
25
+ const fallbackSummary = `Runtime fallback (${fallbackCode}): ${fallbackReason}`;
26
+ appendSummary(manifest, fallbackSummary);
27
+ notes.push(fallbackSummary);
28
+ }
29
+ },
30
+ runAutoScout: (autoScoutOptions) => options.runAutoScout({
31
+ ...autoScoutOptions,
32
+ envOverrides: state.effectiveEnvOverrides
33
+ }),
34
+ executeBody: async ({ notes, persister, controlWatcher, schedulePersist }) => {
35
+ const localResult = await executeOrchestratorLocalPipeline({
36
+ env,
37
+ pipeline,
38
+ manifest,
39
+ paths,
40
+ persister,
41
+ envOverrides: state.effectiveEnvOverrides,
42
+ runtimeMode: state.runtimeSelection.selected_mode,
43
+ runtimeSessionId: state.runtimeSelection.runtime_session_id,
44
+ runEvents,
45
+ controlWatcher,
46
+ schedulePersist,
47
+ startSubpipeline: (pipelineId) => options.startSubpipeline({
48
+ pipelineId,
49
+ executionModeOverride: options.executionModeOverride,
50
+ runtimeModeRequested: state.runtimeSelection.selected_mode
51
+ })
52
+ });
53
+ notes.push(...localResult.notes);
54
+ return localResult.success;
55
+ },
56
+ afterFinalize: () => {
57
+ const guardrailStatus = ensureGuardrailStatus(manifest);
58
+ if (guardrailStatus.recommendation) {
59
+ appendSummary(manifest, guardrailStatus.recommendation);
60
+ }
61
+ }
62
+ });
63
+ }