@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.
- package/.agents/plugins/marketplace.json +20 -0
- package/README.md +70 -301
- package/bin/codex-orchestrator.js +161 -0
- package/codex.orchestrator.json +149 -13
- package/dist/bin/codex-orchestrator.js +795 -1154
- package/dist/orchestrator/src/cli/adapters/CommandPlanner.js +22 -4
- package/dist/orchestrator/src/cli/adapters/CommandReviewer.js +3 -3
- package/dist/orchestrator/src/cli/adapters/CommandTester.js +2 -2
- package/dist/orchestrator/src/cli/adapters/cloudFailureDiagnostics.js +183 -11
- package/dist/orchestrator/src/cli/coStatusAttachCliShell.js +402 -0
- package/dist/orchestrator/src/cli/coStatusCliShell.js +429 -0
- package/dist/orchestrator/src/cli/coStatusOperatorAutopilotCliShell.js +120 -0
- package/dist/orchestrator/src/cli/codexCliShell.js +72 -0
- package/dist/orchestrator/src/cli/codexDefaultsSetup.js +49 -11
- package/dist/orchestrator/src/cli/config/delegationConfig.js +317 -5
- package/dist/orchestrator/src/cli/config/repoConfigPolicy.js +2 -3
- package/dist/orchestrator/src/cli/config/userConfig.js +28 -13
- package/dist/orchestrator/src/cli/control/authenticatedControlRouteGate.js +69 -0
- package/dist/orchestrator/src/cli/control/authenticatedRouteComposition.js +267 -0
- package/dist/orchestrator/src/cli/control/authenticatedRouteController.js +5 -0
- package/dist/orchestrator/src/cli/control/authenticatedRouteDispatcher.js +41 -0
- package/dist/orchestrator/src/cli/control/compatibilityIssuePresenter.js +1035 -0
- package/dist/orchestrator/src/cli/control/confirmationApproveController.js +62 -0
- package/dist/orchestrator/src/cli/control/confirmationCreateController.js +69 -0
- package/dist/orchestrator/src/cli/control/confirmationIssueConsumeController.js +43 -0
- package/dist/orchestrator/src/cli/control/confirmationListController.js +22 -0
- package/dist/orchestrator/src/cli/control/confirmationValidateController.js +58 -0
- package/dist/orchestrator/src/cli/control/confirmations.js +25 -3
- package/dist/orchestrator/src/cli/control/controlActionCancelConfirmation.js +65 -0
- package/dist/orchestrator/src/cli/control/controlActionController.js +77 -0
- package/dist/orchestrator/src/cli/control/controlActionControllerSequencing.js +161 -0
- package/dist/orchestrator/src/cli/control/controlActionExecution.js +142 -0
- package/dist/orchestrator/src/cli/control/controlActionFinalization.js +43 -0
- package/dist/orchestrator/src/cli/control/controlActionOutcome.js +60 -0
- package/dist/orchestrator/src/cli/control/controlActionPreflight.js +476 -0
- package/dist/orchestrator/src/cli/control/controlAuthenticatedRouteHandoff.js +57 -0
- package/dist/orchestrator/src/cli/control/controlBootstrapAssembly.js +39 -0
- package/dist/orchestrator/src/cli/control/controlBootstrapMetadataPersistence.js +16 -0
- package/dist/orchestrator/src/cli/control/controlEventTransport.js +49 -0
- package/dist/orchestrator/src/cli/control/controlExpiryLifecycle.js +102 -0
- package/dist/orchestrator/src/cli/control/controlHostOwnership.js +480 -0
- package/dist/orchestrator/src/cli/control/controlHostSupervision.js +608 -0
- package/dist/orchestrator/src/cli/control/controlOversightFacade.js +8 -0
- package/dist/orchestrator/src/cli/control/controlOversightReadContract.js +1 -0
- package/dist/orchestrator/src/cli/control/controlOversightReadService.js +16 -0
- package/dist/orchestrator/src/cli/control/controlOversightUpdateContract.js +1 -0
- package/dist/orchestrator/src/cli/control/controlPersistenceFiles.js +6 -0
- package/dist/orchestrator/src/cli/control/controlQuestionChildResolution.js +18 -0
- package/dist/orchestrator/src/cli/control/controlRequestContext.js +42 -0
- package/dist/orchestrator/src/cli/control/controlRequestController.js +9 -0
- package/dist/orchestrator/src/cli/control/controlRequestPredispatch.js +17 -0
- package/dist/orchestrator/src/cli/control/controlRequestRouteDispatch.js +44 -0
- package/dist/orchestrator/src/cli/control/controlRuntime.js +992 -0
- package/dist/orchestrator/src/cli/control/controlServer.js +23 -1456
- package/dist/orchestrator/src/cli/control/controlServerAuditAndErrorHelpers.js +115 -0
- package/dist/orchestrator/src/cli/control/controlServerAuthenticatedRouteBranch.js +29 -0
- package/dist/orchestrator/src/cli/control/controlServerBootstrapLifecycle.js +30 -0
- package/dist/orchestrator/src/cli/control/controlServerBootstrapStartSequence.js +21 -0
- package/dist/orchestrator/src/cli/control/controlServerOwnedRuntimeLifecycle.js +67 -0
- package/dist/orchestrator/src/cli/control/controlServerPublicLifecycle.js +756 -0
- package/dist/orchestrator/src/cli/control/controlServerPublicRouteHelpers.js +86 -0
- package/dist/orchestrator/src/cli/control/controlServerReadyInstanceLifecycle.js +25 -0
- package/dist/orchestrator/src/cli/control/controlServerReadyInstanceStartup.js +18 -0
- package/dist/orchestrator/src/cli/control/controlServerRequestBodyHelpers.js +37 -0
- package/dist/orchestrator/src/cli/control/controlServerRequestShell.js +40 -0
- package/dist/orchestrator/src/cli/control/controlServerRequestShellBinding.js +17 -0
- package/dist/orchestrator/src/cli/control/controlServerSeedLoading.js +27 -0
- package/dist/orchestrator/src/cli/control/controlServerSeededRuntimeAssembly.js +186 -0
- package/dist/orchestrator/src/cli/control/controlServerStartupInputPreparation.js +31 -0
- package/dist/orchestrator/src/cli/control/controlServerStartupSequence.js +49 -0
- package/dist/orchestrator/src/cli/control/controlState.js +233 -2
- package/dist/orchestrator/src/cli/control/controlStatusDashboard.js +1899 -0
- package/dist/orchestrator/src/cli/control/controlTelegramBridgeBootstrapLifecycle.js +22 -0
- package/dist/orchestrator/src/cli/control/controlTelegramBridgeLifecycle.js +67 -0
- package/dist/orchestrator/src/cli/control/controlTelegramBridgeOversightFacadeFactory.js +8 -0
- package/dist/orchestrator/src/cli/control/controlTelegramCommandController.js +49 -0
- package/dist/orchestrator/src/cli/control/controlTelegramDispatchRead.js +40 -0
- package/dist/orchestrator/src/cli/control/controlTelegramPollingController.js +89 -0
- package/dist/orchestrator/src/cli/control/controlTelegramProjectionNotificationController.js +29 -0
- package/dist/orchestrator/src/cli/control/controlTelegramPushState.js +63 -0
- package/dist/orchestrator/src/cli/control/controlTelegramQuestionRead.js +13 -0
- package/dist/orchestrator/src/cli/control/controlTelegramReadController.js +216 -0
- package/dist/orchestrator/src/cli/control/controlTelegramUpdateHandler.js +63 -0
- package/dist/orchestrator/src/cli/control/controlWatcher.js +73 -5
- package/dist/orchestrator/src/cli/control/delegationRegisterController.js +35 -0
- package/dist/orchestrator/src/cli/control/dynamicToolBridgePolicy.js +139 -0
- package/dist/orchestrator/src/cli/control/eventsSseController.js +12 -0
- package/dist/orchestrator/src/cli/control/linearBudgetState.js +1789 -0
- package/dist/orchestrator/src/cli/control/linearDispatchSource.js +1137 -0
- package/dist/orchestrator/src/cli/control/linearGraphqlClient.js +150 -0
- package/dist/orchestrator/src/cli/control/linearRateLimit.js +102 -0
- package/dist/orchestrator/src/cli/control/linearWebhookController.js +499 -0
- package/dist/orchestrator/src/cli/control/liveLinearAdvisoryRuntime.js +70 -0
- package/dist/orchestrator/src/cli/control/observabilityApiController.js +173 -0
- package/dist/orchestrator/src/cli/control/observabilityReadModel.js +500 -0
- package/dist/orchestrator/src/cli/control/observabilitySurface.js +284 -0
- package/dist/orchestrator/src/cli/control/observabilityUpdateNotifier.js +22 -0
- package/dist/orchestrator/src/cli/control/operatorDashboardPresenter.js +252 -0
- package/dist/orchestrator/src/cli/control/providerAgentCapacity.js +70 -0
- package/dist/orchestrator/src/cli/control/providerControlHostFreshnessGauge.js +1068 -0
- package/dist/orchestrator/src/cli/control/providerIntakeState.js +473 -0
- package/dist/orchestrator/src/cli/control/providerIssueHandoff.js +6811 -0
- package/dist/orchestrator/src/cli/control/providerIssueObservability.js +1348 -0
- package/dist/orchestrator/src/cli/control/providerIssueRetryQueue.js +84 -0
- package/dist/orchestrator/src/cli/control/providerLinearRuntimeProof.js +588 -0
- package/dist/orchestrator/src/cli/control/providerLinearScreenshotProof.js +473 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkerTruth.js +383 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkflowAudit.js +254 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkflowFacade.js +5573 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkflowStates.js +115 -0
- package/dist/orchestrator/src/cli/control/providerMergeCloseout.js +1868 -0
- package/dist/orchestrator/src/cli/control/providerOperatorAutopilot.js +1580 -0
- package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLifecycle.js +154 -0
- package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLocalRolloutExecution.js +1006 -0
- package/dist/orchestrator/src/cli/control/providerPollingHealth.js +435 -0
- package/dist/orchestrator/src/cli/control/providerTerminalCleanup.js +516 -0
- package/dist/orchestrator/src/cli/control/providerWorkerHosts.js +191 -0
- package/dist/orchestrator/src/cli/control/providerWorkflowConfigStore.js +515 -0
- package/dist/orchestrator/src/cli/control/questionChildResolutionAdapter.js +361 -0
- package/dist/orchestrator/src/cli/control/questionQueueController.js +181 -0
- package/dist/orchestrator/src/cli/control/questionReadRetryDeduplication.js +9 -0
- package/dist/orchestrator/src/cli/control/questionReadSequence.js +10 -0
- package/dist/orchestrator/src/cli/control/securityViolationController.js +27 -0
- package/dist/orchestrator/src/cli/control/selectedRunProjection.js +1838 -0
- package/dist/orchestrator/src/cli/control/telegramOversightApiClient.js +48 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridge.js +180 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridgeProjectionDeliveryQueue.js +25 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridgeRuntimeLifecycle.js +45 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridgeStateStore.js +77 -0
- package/dist/orchestrator/src/cli/control/telegramOversightControlActionApiClient.js +45 -0
- package/dist/orchestrator/src/cli/control/trackerDispatchPilot.js +439 -0
- package/dist/orchestrator/src/cli/control/uiDataController.js +34 -0
- package/dist/orchestrator/src/cli/control/uiSessionController.js +100 -0
- package/dist/orchestrator/src/cli/controlHostCliShell.js +860 -0
- package/dist/orchestrator/src/cli/controlHostFreshnessGaugeCliShell.js +129 -0
- package/dist/orchestrator/src/cli/controlHostSupervisionCliShell.js +2127 -0
- package/dist/orchestrator/src/cli/delegationCliShell.js +62 -0
- package/dist/orchestrator/src/cli/delegationServer.js +567 -678
- package/dist/orchestrator/src/cli/delegationServerCliShell.js +52 -0
- package/dist/orchestrator/src/cli/delegationServerQuestionFlowShell.js +228 -0
- package/dist/orchestrator/src/cli/delegationServerToolDispatchShell.js +411 -0
- package/dist/orchestrator/src/cli/delegationServerTransport.js +274 -0
- package/dist/orchestrator/src/cli/delegationSetup.js +51 -171
- package/dist/orchestrator/src/cli/devtoolsCliShell.js +34 -0
- package/dist/orchestrator/src/cli/doctor.js +542 -122
- package/dist/orchestrator/src/cli/doctorCliRequestShell.js +72 -0
- package/dist/orchestrator/src/cli/doctorCliShell.js +138 -0
- package/dist/orchestrator/src/cli/doctorUsage.js +119 -15
- package/dist/orchestrator/src/cli/exec/experience.js +16 -2
- package/dist/orchestrator/src/cli/exec/summary.js +3 -0
- package/dist/orchestrator/src/cli/execCliShell.js +51 -0
- package/dist/orchestrator/src/cli/flowCliRequestShell.js +44 -0
- package/dist/orchestrator/src/cli/flowCliShell.js +239 -0
- package/dist/orchestrator/src/cli/frontendTestCliRequestShell.js +80 -0
- package/dist/orchestrator/src/cli/frontendTestCliShell.js +41 -0
- package/dist/orchestrator/src/cli/init.js +1 -0
- package/dist/orchestrator/src/cli/initCliShell.js +50 -0
- package/dist/orchestrator/src/cli/linearCliShell.js +1200 -0
- package/dist/orchestrator/src/cli/mcpEnableCliShell.js +132 -0
- package/dist/orchestrator/src/cli/metrics/metricsAggregator.js +3 -2
- package/dist/orchestrator/src/cli/metrics/metricsRecorder.js +56 -0
- package/dist/orchestrator/src/cli/orchestrator.js +66 -1376
- package/dist/orchestrator/src/cli/planCliShell.js +19 -0
- package/dist/orchestrator/src/cli/prCliShell.js +41 -0
- package/dist/orchestrator/src/cli/providerLinearChildLanePhaseContract.js +204 -0
- package/dist/orchestrator/src/cli/providerLinearChildLaneRunner.js +1772 -0
- package/dist/orchestrator/src/cli/providerLinearChildLaneShell.js +2420 -0
- package/dist/orchestrator/src/cli/providerLinearChildStreamShell.js +385 -0
- package/dist/orchestrator/src/cli/providerLinearWorkerRunner.js +5738 -0
- package/dist/orchestrator/src/cli/resumeCliShell.js +14 -0
- package/dist/orchestrator/src/cli/reviewCliLaunchShell.js +72 -0
- package/dist/orchestrator/src/cli/rlm/alignment.js +3 -3
- package/dist/orchestrator/src/cli/rlm/context.js +94 -7
- package/dist/orchestrator/src/cli/rlm/rlmCodexRuntimeShell.js +546 -0
- package/dist/orchestrator/src/cli/rlm/symbolic.js +4 -2
- package/dist/orchestrator/src/cli/rlmCliRequestShell.js +42 -0
- package/dist/orchestrator/src/cli/rlmCompletionCliShell.js +46 -0
- package/dist/orchestrator/src/cli/rlmLaunchCliShell.js +51 -0
- package/dist/orchestrator/src/cli/rlmRunner.js +83 -523
- package/dist/orchestrator/src/cli/run/blockMemory.js +500 -0
- package/dist/orchestrator/src/cli/run/manifest.js +410 -73
- package/dist/orchestrator/src/cli/run/manifestPersister.js +45 -14
- package/dist/orchestrator/src/cli/run/runMemoryController.js +216 -0
- package/dist/orchestrator/src/cli/run/source0.js +690 -0
- package/dist/orchestrator/src/cli/run/workspacePath.js +101 -0
- package/dist/orchestrator/src/cli/runtime/mode.js +2 -1
- package/dist/orchestrator/src/cli/runtime/provider.js +39 -2
- package/dist/orchestrator/src/cli/selfCheckCliShell.js +12 -0
- package/dist/orchestrator/src/cli/services/commandRunner.js +667 -18
- package/dist/orchestrator/src/cli/services/execRuntime.js +66 -1
- package/dist/orchestrator/src/cli/services/orchestratorAutoScoutEvidenceRecorder.js +71 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudBranchResolution.js +8 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudEnvironmentResolution.js +22 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudExecutionLifecycleShell.js +39 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudPromptBuilder.js +37 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudRouteFallbackContract.js +45 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudRouteShell.js +36 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudTargetExecutor.js +277 -0
- package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycle.js +98 -0
- package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycleShell.js +54 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionLifecycle.js +112 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionModePolicy.js +27 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteAdapterShell.js +59 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteDecisionShell.js +57 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteState.js +21 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouter.js +2 -0
- package/dist/orchestrator/src/cli/services/orchestratorLocalPipelineExecutor.js +149 -0
- package/dist/orchestrator/src/cli/services/orchestratorLocalRouteShell.js +63 -0
- package/dist/orchestrator/src/cli/services/orchestratorPlanShell.js +54 -0
- package/dist/orchestrator/src/cli/services/orchestratorPlanTargetTracker.js +16 -0
- package/dist/orchestrator/src/cli/services/orchestratorResumePreparationShell.js +84 -0
- package/dist/orchestrator/src/cli/services/orchestratorResumeTokenValidation.js +15 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleCompletion.js +31 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleExecutionRegistration.js +37 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleOrchestrationShell.js +83 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleTaskManagerShell.js +37 -0
- package/dist/orchestrator/src/cli/services/orchestratorRuntimeManifestMutation.js +20 -0
- package/dist/orchestrator/src/cli/services/orchestratorStartPreparationShell.js +56 -0
- package/dist/orchestrator/src/cli/services/orchestratorStatusShell.js +70 -0
- package/dist/orchestrator/src/cli/services/pipelineResolver.js +7 -3
- package/dist/orchestrator/src/cli/services/plannerMemory.js +119 -0
- package/dist/orchestrator/src/cli/services/runPreparation.js +7 -3
- package/dist/orchestrator/src/cli/services/runSummaryWriter.js +9 -0
- package/dist/orchestrator/src/cli/setupBootstrapShell.js +114 -0
- package/dist/orchestrator/src/cli/setupCliShell.js +51 -0
- package/dist/orchestrator/src/cli/skillsCliShell.js +56 -0
- package/dist/orchestrator/src/cli/startCliRequestShell.js +53 -0
- package/dist/orchestrator/src/cli/startCliShell.js +68 -0
- package/dist/orchestrator/src/cli/statusCliShell.js +22 -0
- package/dist/orchestrator/src/cli/utils/authProvenanceFingerprint.js +27 -0
- package/dist/orchestrator/src/cli/utils/cloudPreflight.js +83 -1
- package/dist/orchestrator/src/cli/utils/delegationConfigParser.js +250 -0
- package/dist/orchestrator/src/cli/utils/delegationMcpHealth.js +1382 -0
- package/dist/orchestrator/src/cli/utils/devtools.js +2 -54
- package/dist/orchestrator/src/cli/utils/mcpServerEntry.js +53 -0
- package/dist/orchestrator/src/cli/utils/packageProgramResolver.js +151 -0
- package/dist/orchestrator/src/cli/utils/providerOverrideEnv.js +71 -0
- package/dist/orchestrator/src/cli/utils/trailingJsonObject.js +59 -0
- package/dist/orchestrator/src/learning/crystalizer.js +2 -2
- package/dist/orchestrator/src/persistence/ExperienceStore.js +233 -49
- package/dist/orchestrator/src/persistence/TaskStateStore.js +6 -6
- package/dist/orchestrator/src/persistence/lockFile.js +70 -4
- package/dist/orchestrator/src/persistence/sanitizeIdentifier.js +39 -0
- package/dist/orchestrator/src/sync/createCloudSyncWorker.js +3 -2
- package/dist/orchestrator/src/utils/atomicWrite.js +17 -2
- package/dist/packages/orchestrator/src/exec/unified-exec.js +99 -6
- package/dist/packages/orchestrator/src/instructions/promptPacks.js +150 -19
- package/dist/packages/sdk-node/src/orchestrator.js +137 -13
- package/dist/packages/shared/config/designConfig.js +8 -1
- package/dist/packages/shared/streams/stdio.js +1 -1
- package/dist/scripts/design/pipeline/permit.js +15 -0
- package/dist/scripts/lib/docs-catalog.js +365 -0
- package/dist/scripts/lib/docs-helpers.js +87 -5
- package/dist/scripts/lib/pr-watch-merge.js +1088 -80
- package/dist/scripts/lib/provider-run-contract.js +26 -0
- package/dist/scripts/lib/review-command-intent-classification.js +532 -0
- package/dist/scripts/lib/review-command-probe-classification.js +385 -0
- package/dist/scripts/lib/review-execution-boundary-preflight.js +279 -0
- package/dist/scripts/lib/review-execution-runtime.js +753 -0
- package/dist/scripts/lib/review-execution-state.js +1144 -0
- package/dist/scripts/lib/review-execution-telemetry.js +215 -0
- package/dist/scripts/lib/review-inspection-target-parsing.js +78 -0
- package/dist/scripts/lib/review-launch-attempt.js +601 -0
- package/dist/scripts/lib/review-meta-surface-boundary-analysis.js +300 -0
- package/dist/scripts/lib/review-meta-surface-normalization.js +746 -0
- package/dist/scripts/lib/review-non-interactive-handoff.js +61 -0
- package/dist/scripts/lib/review-prompt-context.js +376 -0
- package/dist/scripts/lib/review-scope-advisory.js +286 -0
- package/dist/scripts/lib/review-scope-paths.js +123 -0
- package/dist/scripts/lib/review-shell-command-parser.js +389 -0
- package/dist/scripts/lib/review-shell-env-interpreter.js +340 -0
- package/dist/scripts/lib/run-manifests.js +192 -36
- package/dist/scripts/lib/spark-policy-classifier.js +593 -0
- package/dist/scripts/run-review.js +507 -1777
- package/docs/public/downstream-setup.md +106 -0
- package/docs/public/provider-onboarding.md +173 -0
- package/package.json +20 -10
- package/plugins/codex-orchestrator/.codex-plugin/plugin.json +30 -0
- package/plugins/codex-orchestrator/.mcp.json +13 -0
- package/plugins/codex-orchestrator/launcher.mjs +359 -0
- package/schemas/manifest.json +394 -0
- package/skills/collab-subagents-first/SKILL.md +1 -1
- package/skills/delegation-usage/DELEGATION_GUIDE.md +24 -11
- package/skills/delegation-usage/SKILL.md +19 -13
- package/skills/land/SKILL.md +77 -0
- package/skills/linear/SKILL.md +255 -0
- package/skills/release/SKILL.md +47 -3
- package/skills/standalone-review/SKILL.md +6 -1
- package/templates/README.md +4 -2
- package/templates/codex/.codex/agents/awaiter-high.toml +2 -2
- package/templates/codex/.codex/agents/worker-complex.toml +1 -1
- package/templates/codex/.codex/config.toml +3 -4
- package/templates/codex/.codex/providers/README.md +13 -0
- package/templates/codex/.codex/providers/control.example.json +18 -0
- package/templates/codex/.codex/providers/provider.env.example +15 -0
- package/templates/codex/AGENTS.md +12 -7
- package/templates/codex/mcp-client.json +5 -1
- package/docs/README.md +0 -310
- package/docs/assets/setup.gif +0 -0
|
@@ -18,6 +18,7 @@ const sessionManager = new ExecSessionManager({
|
|
|
18
18
|
});
|
|
19
19
|
const privacyGuard = new PrivacyGuard({ mode: resolvePrivacyGuardMode() });
|
|
20
20
|
const handleService = new RemoteExecHandleService({ guard: privacyGuard, now: () => new Date() });
|
|
21
|
+
const POST_EXIT_STDIO_DRAIN_TIMEOUT_MS = 500;
|
|
21
22
|
const cliExecutor = async (request) => {
|
|
22
23
|
const hasExplicitArgs = Array.isArray(request.args);
|
|
23
24
|
const child = spawn(request.command, request.args ?? [], {
|
|
@@ -34,19 +35,83 @@ const cliExecutor = async (request) => {
|
|
|
34
35
|
child.stdout.on('data', request.onStdout);
|
|
35
36
|
child.stderr.on('data', request.onStderr);
|
|
36
37
|
return await new Promise((resolve, reject) => {
|
|
37
|
-
|
|
38
|
+
let settled = false;
|
|
39
|
+
let exited = false;
|
|
40
|
+
let exitCode = null;
|
|
41
|
+
let signal = null;
|
|
42
|
+
let stdoutEnded = false;
|
|
43
|
+
let stderrEnded = false;
|
|
44
|
+
let drainTimeout = null;
|
|
45
|
+
const finalize = () => {
|
|
46
|
+
if (settled) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
settled = true;
|
|
38
50
|
cleanup();
|
|
39
51
|
resolve({ exitCode, signal });
|
|
40
52
|
};
|
|
53
|
+
const setExitState = (nextExitCode, nextSignal) => {
|
|
54
|
+
if (exited) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
exited = true;
|
|
58
|
+
exitCode = nextExitCode;
|
|
59
|
+
signal = nextSignal;
|
|
60
|
+
};
|
|
61
|
+
const maybeFinalizeAfterExit = () => {
|
|
62
|
+
if (!exited || !stdoutEnded || !stderrEnded) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
finalize();
|
|
66
|
+
};
|
|
67
|
+
const armDrainTimeout = () => {
|
|
68
|
+
if (drainTimeout) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
drainTimeout = setTimeout(() => {
|
|
72
|
+
finalize();
|
|
73
|
+
}, POST_EXIT_STDIO_DRAIN_TIMEOUT_MS);
|
|
74
|
+
drainTimeout.unref?.();
|
|
75
|
+
};
|
|
76
|
+
const handleExit = (nextExitCode, nextSignal) => {
|
|
77
|
+
setExitState(nextExitCode, nextSignal);
|
|
78
|
+
if (stdoutEnded && stderrEnded) {
|
|
79
|
+
finalize();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
armDrainTimeout();
|
|
83
|
+
};
|
|
84
|
+
const handleClose = (nextExitCode, nextSignal) => {
|
|
85
|
+
setExitState(nextExitCode, nextSignal);
|
|
86
|
+
finalize();
|
|
87
|
+
};
|
|
41
88
|
const handleError = (error) => {
|
|
42
89
|
cleanup();
|
|
43
90
|
reject(error);
|
|
44
91
|
};
|
|
92
|
+
const handleStdoutEnd = () => {
|
|
93
|
+
stdoutEnded = true;
|
|
94
|
+
maybeFinalizeAfterExit();
|
|
95
|
+
};
|
|
96
|
+
const handleStderrEnd = () => {
|
|
97
|
+
stderrEnded = true;
|
|
98
|
+
maybeFinalizeAfterExit();
|
|
99
|
+
};
|
|
45
100
|
const cleanup = () => {
|
|
101
|
+
child.stdout.off('end', handleStdoutEnd);
|
|
102
|
+
child.stderr.off('end', handleStderrEnd);
|
|
46
103
|
child.off('exit', handleExit);
|
|
104
|
+
child.off('close', handleClose);
|
|
47
105
|
child.off('error', handleError);
|
|
106
|
+
if (drainTimeout) {
|
|
107
|
+
clearTimeout(drainTimeout);
|
|
108
|
+
drainTimeout = null;
|
|
109
|
+
}
|
|
48
110
|
};
|
|
111
|
+
child.stdout.once('end', handleStdoutEnd);
|
|
112
|
+
child.stderr.once('end', handleStderrEnd);
|
|
49
113
|
child.once('exit', handleExit);
|
|
114
|
+
child.once('close', handleClose);
|
|
50
115
|
child.once('error', handleError);
|
|
51
116
|
});
|
|
52
117
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { writeJsonAtomic } from '../utils/fs.js';
|
|
4
|
+
import { buildAutoScoutEvidence } from '../utils/advancedAutopilot.js';
|
|
5
|
+
import { isoTimestamp } from '../utils/time.js';
|
|
6
|
+
import { relativeToRepo } from '../run/runPaths.js';
|
|
7
|
+
import { resolveCloudBranch } from './orchestratorCloudBranchResolution.js';
|
|
8
|
+
import { resolveCloudEnvironmentId } from './orchestratorCloudEnvironmentResolution.js';
|
|
9
|
+
const DEFAULT_AUTO_SCOUT_TIMEOUT_MS = 4000;
|
|
10
|
+
function readCloudNumber(raw, fallback) {
|
|
11
|
+
if (!raw) {
|
|
12
|
+
return fallback;
|
|
13
|
+
}
|
|
14
|
+
const parsed = Number.parseInt(raw, 10);
|
|
15
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
return parsed;
|
|
19
|
+
}
|
|
20
|
+
export async function recordOrchestratorAutoScoutEvidence(params) {
|
|
21
|
+
const mergedEnv = { ...process.env, ...(params.envOverrides ?? {}) };
|
|
22
|
+
const timeoutMs = readCloudNumber(mergedEnv.CODEX_ORCHESTRATOR_AUTO_SCOUT_TIMEOUT_MS, DEFAULT_AUTO_SCOUT_TIMEOUT_MS);
|
|
23
|
+
const work = async () => {
|
|
24
|
+
const cloudEnvironmentId = resolveCloudEnvironmentId(params.task, params.target, params.envOverrides);
|
|
25
|
+
const cloudBranch = resolveCloudBranch(params.envOverrides);
|
|
26
|
+
const cloudRequested = params.mode === 'cloud' || params.manifest.cloud_fallback?.mode_requested === 'cloud';
|
|
27
|
+
const evidence = buildAutoScoutEvidence({
|
|
28
|
+
taskId: params.manifest.task_id,
|
|
29
|
+
pipelineId: params.pipeline.id,
|
|
30
|
+
targetId: params.target.id,
|
|
31
|
+
targetDescription: params.target.description,
|
|
32
|
+
executionMode: params.mode,
|
|
33
|
+
cloudRequested,
|
|
34
|
+
advanced: params.advancedDecision,
|
|
35
|
+
cloudEnvironmentId,
|
|
36
|
+
cloudBranch,
|
|
37
|
+
env: mergedEnv,
|
|
38
|
+
generatedAt: isoTimestamp()
|
|
39
|
+
});
|
|
40
|
+
const evidencePath = join(params.paths.runDir, 'auto-scout.json');
|
|
41
|
+
await writeJsonAtomic(evidencePath, evidence);
|
|
42
|
+
return { status: 'recorded', path: relativeToRepo(params.env, evidencePath) };
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
let timeoutHandle = null;
|
|
46
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
47
|
+
timeoutHandle = setTimeout(() => {
|
|
48
|
+
resolve({
|
|
49
|
+
status: 'timeout',
|
|
50
|
+
message: `timed out after ${Math.round(timeoutMs / 1000)}s`
|
|
51
|
+
});
|
|
52
|
+
}, timeoutMs);
|
|
53
|
+
timeoutHandle.unref?.();
|
|
54
|
+
});
|
|
55
|
+
const workPromise = work().catch((error) => ({
|
|
56
|
+
status: 'error',
|
|
57
|
+
message: error?.message ?? String(error)
|
|
58
|
+
}));
|
|
59
|
+
const result = await Promise.race([workPromise, timeoutPromise]);
|
|
60
|
+
if (timeoutHandle) {
|
|
61
|
+
clearTimeout(timeoutHandle);
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
status: 'error',
|
|
68
|
+
message: error?.message ?? String(error)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
function readCloudBranchString(value) {
|
|
3
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
|
|
4
|
+
}
|
|
5
|
+
export function resolveCloudBranch(envOverrides) {
|
|
6
|
+
return (readCloudBranchString(envOverrides?.CODEX_CLOUD_BRANCH) ??
|
|
7
|
+
readCloudBranchString(process.env.CODEX_CLOUD_BRANCH));
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
function readCloudEnvironmentString(value) {
|
|
3
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
|
|
4
|
+
}
|
|
5
|
+
export function resolveCloudEnvironmentId(task, target, envOverrides) {
|
|
6
|
+
const metadata = (target.metadata ?? {});
|
|
7
|
+
const taskMetadata = (task.metadata ?? {});
|
|
8
|
+
const taskCloud = (taskMetadata.cloud ?? null);
|
|
9
|
+
const candidates = [
|
|
10
|
+
readCloudEnvironmentString(metadata.cloudEnvId),
|
|
11
|
+
readCloudEnvironmentString(metadata.cloud_env_id),
|
|
12
|
+
readCloudEnvironmentString(metadata.envId),
|
|
13
|
+
readCloudEnvironmentString(metadata.environmentId),
|
|
14
|
+
readCloudEnvironmentString(taskCloud?.envId),
|
|
15
|
+
readCloudEnvironmentString(taskCloud?.environmentId),
|
|
16
|
+
readCloudEnvironmentString(taskMetadata.cloudEnvId),
|
|
17
|
+
readCloudEnvironmentString(taskMetadata.cloud_env_id),
|
|
18
|
+
readCloudEnvironmentString(envOverrides?.CODEX_CLOUD_ENV_ID),
|
|
19
|
+
readCloudEnvironmentString(process.env.CODEX_CLOUD_ENV_ID)
|
|
20
|
+
];
|
|
21
|
+
return candidates.find((candidate) => candidate !== null) ?? null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { executeOrchestratorCloudTarget } from './orchestratorCloudTargetExecutor.js';
|
|
3
|
+
import { runOrchestratorExecutionLifecycle } from './orchestratorExecutionLifecycle.js';
|
|
4
|
+
export async function runOrchestratorCloudExecutionLifecycleShell(options) {
|
|
5
|
+
const { env, pipeline, manifest, paths, runEvents, target, task, envOverrides } = options;
|
|
6
|
+
return runOrchestratorExecutionLifecycle({
|
|
7
|
+
env,
|
|
8
|
+
pipeline,
|
|
9
|
+
manifest,
|
|
10
|
+
paths,
|
|
11
|
+
mode: options.mode,
|
|
12
|
+
target,
|
|
13
|
+
task,
|
|
14
|
+
runEvents,
|
|
15
|
+
eventStream: options.eventStream,
|
|
16
|
+
onEventEntry: options.onEventEntry,
|
|
17
|
+
persister: options.persister,
|
|
18
|
+
envOverrides,
|
|
19
|
+
advancedDecisionEnv: { ...process.env, ...(envOverrides ?? {}) },
|
|
20
|
+
defaultFailureStatusDetail: 'cloud-execution-failed',
|
|
21
|
+
runAutoScout: options.runAutoScout,
|
|
22
|
+
executeBody: async ({ notes, controlWatcher, schedulePersist }) => {
|
|
23
|
+
const cloudResult = await executeOrchestratorCloudTarget({
|
|
24
|
+
env,
|
|
25
|
+
pipeline,
|
|
26
|
+
manifest,
|
|
27
|
+
paths,
|
|
28
|
+
target,
|
|
29
|
+
task,
|
|
30
|
+
envOverrides,
|
|
31
|
+
runEvents,
|
|
32
|
+
controlWatcher,
|
|
33
|
+
schedulePersist
|
|
34
|
+
});
|
|
35
|
+
notes.push(...cloudResult.notes);
|
|
36
|
+
return cloudResult.success;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { buildRunMemoryPromptLines, selectRunMemoryForRole } from '../run/runMemoryController.js';
|
|
2
|
+
import { readPromptPackIdFromTaskMemoryRefId, readSelectedMemoryRefs, TASK_MEMORY_SOURCE0_REF_ID } from './plannerMemory.js';
|
|
3
|
+
export function buildCloudPrompt(params) {
|
|
4
|
+
const lines = [
|
|
5
|
+
`Task ID: ${params.task.id}`,
|
|
6
|
+
`Task title: ${params.task.title}`,
|
|
7
|
+
params.task.description ? `Task description: ${params.task.description}` : null,
|
|
8
|
+
`Pipeline: ${params.pipeline.id}`,
|
|
9
|
+
`Target stage: ${params.stage.id} (${params.target.description})`,
|
|
10
|
+
'',
|
|
11
|
+
'Apply the required repository changes for this target stage and produce a diff.'
|
|
12
|
+
].filter((line) => Boolean(line));
|
|
13
|
+
const selectedMemoryRefs = readSelectedMemoryRefs(params.target);
|
|
14
|
+
const includeSource0 = selectedMemoryRefs.length === 0 || selectedMemoryRefs.includes(TASK_MEMORY_SOURCE0_REF_ID);
|
|
15
|
+
const preferredPromptPackIds = selectedMemoryRefs
|
|
16
|
+
.map((refId) => readPromptPackIdFromTaskMemoryRefId(refId))
|
|
17
|
+
.filter((packId) => packId !== null);
|
|
18
|
+
const runMemoryPromptLines = buildRunMemoryPromptLines(selectRunMemoryForRole({
|
|
19
|
+
role: 'executor',
|
|
20
|
+
manifest: params.manifest,
|
|
21
|
+
hints: [
|
|
22
|
+
params.pipeline.id,
|
|
23
|
+
params.pipeline.title,
|
|
24
|
+
...(params.pipeline.tags ?? []),
|
|
25
|
+
params.target.id,
|
|
26
|
+
params.target.description ?? '',
|
|
27
|
+
params.stage.id,
|
|
28
|
+
params.stage.title
|
|
29
|
+
],
|
|
30
|
+
include_source_0: includeSource0,
|
|
31
|
+
preferred_prompt_pack_ids: preferredPromptPackIds
|
|
32
|
+
}));
|
|
33
|
+
if (runMemoryPromptLines.length > 0) {
|
|
34
|
+
lines.push('', ...runMemoryPromptLines);
|
|
35
|
+
}
|
|
36
|
+
return lines.join('\n');
|
|
37
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { isoTimestamp } from '../utils/time.js';
|
|
3
|
+
function readCloudString(value) {
|
|
4
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
|
|
5
|
+
}
|
|
6
|
+
function normalizeCloudFallbackIssues(issues) {
|
|
7
|
+
return issues.map((issue) => ({ code: issue.code, message: issue.message }));
|
|
8
|
+
}
|
|
9
|
+
export function allowCloudFallback(envOverrides) {
|
|
10
|
+
const raw = readCloudString(envOverrides?.CODEX_ORCHESTRATOR_CLOUD_FALLBACK) ??
|
|
11
|
+
readCloudString(process.env.CODEX_ORCHESTRATOR_CLOUD_FALLBACK);
|
|
12
|
+
if (!raw) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
const normalized = raw.toLowerCase();
|
|
16
|
+
return !['0', 'false', 'off', 'deny', 'disabled', 'never', 'strict'].includes(normalized);
|
|
17
|
+
}
|
|
18
|
+
export function buildCloudPreflightFailureContract(input, issues) {
|
|
19
|
+
const issueSummary = issues.map((issue) => issue.message).join(' ');
|
|
20
|
+
if (!allowCloudFallback(input.envOverrides)) {
|
|
21
|
+
return {
|
|
22
|
+
outcome: 'fail',
|
|
23
|
+
detail: `Cloud preflight failed and cloud fallback is disabled. ${issueSummary}`
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const detail = `Cloud preflight failed; falling back to mcp. ${issueSummary}`;
|
|
27
|
+
return {
|
|
28
|
+
outcome: 'fallback',
|
|
29
|
+
detail,
|
|
30
|
+
manifestFallback: {
|
|
31
|
+
mode_requested: 'cloud',
|
|
32
|
+
mode_used: 'mcp',
|
|
33
|
+
reason: detail,
|
|
34
|
+
issues: normalizeCloudFallbackIssues(issues),
|
|
35
|
+
checked_at: isoTimestamp()
|
|
36
|
+
},
|
|
37
|
+
reroute: {
|
|
38
|
+
mode: 'mcp',
|
|
39
|
+
executionModeOverride: 'mcp',
|
|
40
|
+
runtimeModeRequested: input.runtimeModeRequested,
|
|
41
|
+
runtimeModeSource: input.runtimeModeSource,
|
|
42
|
+
envOverrides: input.envOverrides
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { logger } from '../../logger.js';
|
|
2
|
+
import { appendSummary } from '../run/manifest.js';
|
|
3
|
+
import { buildCloudPreflightRequest, runCloudPreflight } from '../utils/cloudPreflight.js';
|
|
4
|
+
import { resolveCloudBranch } from './orchestratorCloudBranchResolution.js';
|
|
5
|
+
import { resolveCloudEnvironmentId } from './orchestratorCloudEnvironmentResolution.js';
|
|
6
|
+
import { buildCloudPreflightFailureContract } from './orchestratorCloudRouteFallbackContract.js';
|
|
7
|
+
function buildExecutionRouteCloudPreflightRequest(options) {
|
|
8
|
+
const environmentId = resolveCloudEnvironmentId(options.task, options.target, options.state.effectiveEnvOverrides);
|
|
9
|
+
const branch = resolveCloudBranch(options.state.effectiveEnvOverrides);
|
|
10
|
+
return buildCloudPreflightRequest({
|
|
11
|
+
repoRoot: options.repoRoot,
|
|
12
|
+
environmentId,
|
|
13
|
+
branch,
|
|
14
|
+
env: options.state.effectiveMergedEnv
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export async function executeOrchestratorCloudRouteShell(options) {
|
|
18
|
+
const preflight = await runCloudPreflight(buildExecutionRouteCloudPreflightRequest(options));
|
|
19
|
+
if (!preflight.ok) {
|
|
20
|
+
const contract = buildCloudPreflightFailureContract({
|
|
21
|
+
runtimeModeRequested: options.state.runtimeSelection.selected_mode,
|
|
22
|
+
runtimeModeSource: options.state.runtimeSelection.source,
|
|
23
|
+
envOverrides: options.state.effectiveEnvOverrides
|
|
24
|
+
}, preflight.issues);
|
|
25
|
+
if (contract.outcome === 'fail') {
|
|
26
|
+
return options.failExecutionRoute('cloud-preflight-failed', contract.detail);
|
|
27
|
+
}
|
|
28
|
+
options.manifest.cloud_fallback = contract.manifestFallback;
|
|
29
|
+
appendSummary(options.manifest, contract.detail);
|
|
30
|
+
logger.warn(contract.detail);
|
|
31
|
+
const fallback = await options.reroute(contract.reroute);
|
|
32
|
+
fallback.notes.unshift(contract.detail);
|
|
33
|
+
return fallback;
|
|
34
|
+
}
|
|
35
|
+
return await options.executeCloudPipeline(options.state.effectiveEnvOverrides);
|
|
36
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { appendSummary } from '../run/manifest.js';
|
|
3
|
+
import { isoTimestamp } from '../utils/time.js';
|
|
4
|
+
import { resolveCodexCliBin } from '../utils/codexCli.js';
|
|
5
|
+
import { resolveCloudBranch } from './orchestratorCloudBranchResolution.js';
|
|
6
|
+
import { resolveCloudEnvironmentId } from './orchestratorCloudEnvironmentResolution.js';
|
|
7
|
+
import { buildCloudPrompt } from './orchestratorCloudPromptBuilder.js';
|
|
8
|
+
import { CodexCloudTaskExecutor } from '../../cloud/CodexCloudTaskExecutor.js';
|
|
9
|
+
const DEFAULT_CLOUD_POLL_INTERVAL_SECONDS = 10;
|
|
10
|
+
const DEFAULT_CLOUD_TIMEOUT_SECONDS = 1800;
|
|
11
|
+
const DEFAULT_CLOUD_ATTEMPTS = 1;
|
|
12
|
+
const DEFAULT_CLOUD_STATUS_RETRY_LIMIT = 12;
|
|
13
|
+
const DEFAULT_CLOUD_STATUS_RETRY_BACKOFF_MS = 1500;
|
|
14
|
+
function readCloudString(value) {
|
|
15
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
|
|
16
|
+
}
|
|
17
|
+
function readCloudNumber(raw, fallback) {
|
|
18
|
+
if (!raw) {
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
21
|
+
const parsed = Number.parseInt(raw, 10);
|
|
22
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
return parsed;
|
|
26
|
+
}
|
|
27
|
+
function readCloudFeatureList(raw) {
|
|
28
|
+
if (!raw) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
const features = [];
|
|
33
|
+
for (const token of raw.split(/[,\s]+/u)) {
|
|
34
|
+
const feature = token.trim();
|
|
35
|
+
if (!feature || seen.has(feature)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
seen.add(feature);
|
|
39
|
+
features.push(feature);
|
|
40
|
+
}
|
|
41
|
+
return features;
|
|
42
|
+
}
|
|
43
|
+
function resolveCloudTargetStage(params) {
|
|
44
|
+
const metadataStageId = typeof params.target.metadata?.stageId === 'string' ? params.target.metadata.stageId : null;
|
|
45
|
+
let targetStageId = null;
|
|
46
|
+
if (metadataStageId && params.pipeline.stages.some((stage) => stage.id === metadataStageId)) {
|
|
47
|
+
targetStageId = metadataStageId;
|
|
48
|
+
}
|
|
49
|
+
else if (params.target.id.includes(':')) {
|
|
50
|
+
const suffix = params.target.id.split(':').pop() ?? null;
|
|
51
|
+
if (suffix && params.pipeline.stages.some((stage) => stage.id === suffix)) {
|
|
52
|
+
targetStageId = suffix;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (params.pipeline.stages.some((stage) => stage.id === params.target.id)) {
|
|
56
|
+
targetStageId = params.target.id;
|
|
57
|
+
}
|
|
58
|
+
const targetStage = targetStageId
|
|
59
|
+
? params.pipeline.stages.find((stage) => stage.id === targetStageId)
|
|
60
|
+
: undefined;
|
|
61
|
+
const targetEntry = targetStageId
|
|
62
|
+
? params.manifest.commands.find((command) => command.id === targetStageId)
|
|
63
|
+
: undefined;
|
|
64
|
+
return { targetStageId, targetStage, targetEntry };
|
|
65
|
+
}
|
|
66
|
+
async function prepareCloudTargetPreflight(params) {
|
|
67
|
+
const notes = [];
|
|
68
|
+
const { targetStageId, targetStage, targetEntry } = resolveCloudTargetStage({
|
|
69
|
+
target: params.target,
|
|
70
|
+
pipeline: params.pipeline,
|
|
71
|
+
manifest: params.manifest
|
|
72
|
+
});
|
|
73
|
+
await params.controlWatcher.sync();
|
|
74
|
+
await params.controlWatcher.waitForResume();
|
|
75
|
+
if (params.controlWatcher.isCanceled()) {
|
|
76
|
+
params.manifest.status_detail = 'run-canceled';
|
|
77
|
+
return { success: false, notes };
|
|
78
|
+
}
|
|
79
|
+
if (!targetStageId || !targetStage || targetStage.kind !== 'command' || !targetEntry) {
|
|
80
|
+
const detail = targetStageId
|
|
81
|
+
? `Cloud execution target "${targetStageId}" could not be resolved to a command stage.`
|
|
82
|
+
: `Cloud execution target "${params.target.id}" could not be resolved.`;
|
|
83
|
+
params.manifest.status_detail = 'cloud-target-missing';
|
|
84
|
+
appendSummary(params.manifest, detail);
|
|
85
|
+
notes.push(detail);
|
|
86
|
+
return { success: false, notes };
|
|
87
|
+
}
|
|
88
|
+
for (let i = 0; i < params.manifest.commands.length; i += 1) {
|
|
89
|
+
const entry = params.manifest.commands[i];
|
|
90
|
+
if (!entry || entry.id === targetStageId) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
entry.status = 'skipped';
|
|
94
|
+
entry.started_at = entry.started_at ?? isoTimestamp();
|
|
95
|
+
entry.completed_at = isoTimestamp();
|
|
96
|
+
entry.summary = `Skipped in cloud mode (target stage: ${targetStageId}).`;
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
targetStage,
|
|
101
|
+
targetEntry
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function buildCloudTaskExecutorRequest(params) {
|
|
105
|
+
const prompt = buildCloudPrompt({
|
|
106
|
+
task: params.task,
|
|
107
|
+
target: params.target,
|
|
108
|
+
pipeline: params.pipeline,
|
|
109
|
+
stage: params.stage,
|
|
110
|
+
manifest: params.manifest
|
|
111
|
+
});
|
|
112
|
+
const pollIntervalSeconds = readCloudNumber(params.envOverrides?.CODEX_CLOUD_POLL_INTERVAL_SECONDS ?? process.env.CODEX_CLOUD_POLL_INTERVAL_SECONDS, DEFAULT_CLOUD_POLL_INTERVAL_SECONDS);
|
|
113
|
+
const timeoutSeconds = readCloudNumber(params.envOverrides?.CODEX_CLOUD_TIMEOUT_SECONDS ?? process.env.CODEX_CLOUD_TIMEOUT_SECONDS, DEFAULT_CLOUD_TIMEOUT_SECONDS);
|
|
114
|
+
const attempts = readCloudNumber(params.envOverrides?.CODEX_CLOUD_EXEC_ATTEMPTS ?? process.env.CODEX_CLOUD_EXEC_ATTEMPTS, DEFAULT_CLOUD_ATTEMPTS);
|
|
115
|
+
const statusRetryLimit = readCloudNumber(params.envOverrides?.CODEX_CLOUD_STATUS_RETRY_LIMIT ?? process.env.CODEX_CLOUD_STATUS_RETRY_LIMIT, DEFAULT_CLOUD_STATUS_RETRY_LIMIT);
|
|
116
|
+
const statusRetryBackoffMs = readCloudNumber(params.envOverrides?.CODEX_CLOUD_STATUS_RETRY_BACKOFF_MS ?? process.env.CODEX_CLOUD_STATUS_RETRY_BACKOFF_MS, DEFAULT_CLOUD_STATUS_RETRY_BACKOFF_MS);
|
|
117
|
+
const branch = resolveCloudBranch(params.envOverrides);
|
|
118
|
+
const enableFeatures = readCloudFeatureList(readCloudString(params.envOverrides?.CODEX_CLOUD_ENABLE_FEATURES) ??
|
|
119
|
+
readCloudString(process.env.CODEX_CLOUD_ENABLE_FEATURES));
|
|
120
|
+
const disableFeatures = readCloudFeatureList(readCloudString(params.envOverrides?.CODEX_CLOUD_DISABLE_FEATURES) ??
|
|
121
|
+
readCloudString(process.env.CODEX_CLOUD_DISABLE_FEATURES));
|
|
122
|
+
const codexBin = resolveCodexCliBin({ ...process.env, ...(params.envOverrides ?? {}) });
|
|
123
|
+
const cloudEnvOverrides = {
|
|
124
|
+
...(params.envOverrides ?? {}),
|
|
125
|
+
CODEX_NON_INTERACTIVE: readCloudString(params.envOverrides?.CODEX_NON_INTERACTIVE) ??
|
|
126
|
+
readCloudString(process.env.CODEX_NON_INTERACTIVE) ??
|
|
127
|
+
'1',
|
|
128
|
+
CODEX_NO_INTERACTIVE: readCloudString(params.envOverrides?.CODEX_NO_INTERACTIVE) ??
|
|
129
|
+
readCloudString(process.env.CODEX_NO_INTERACTIVE) ??
|
|
130
|
+
'1',
|
|
131
|
+
CODEX_INTERACTIVE: readCloudString(params.envOverrides?.CODEX_INTERACTIVE) ??
|
|
132
|
+
readCloudString(process.env.CODEX_INTERACTIVE) ??
|
|
133
|
+
'0'
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
codexBin,
|
|
137
|
+
prompt,
|
|
138
|
+
environmentId: params.environmentId,
|
|
139
|
+
repoRoot: params.env.repoRoot,
|
|
140
|
+
runDir: params.runDir,
|
|
141
|
+
pollIntervalSeconds,
|
|
142
|
+
timeoutSeconds,
|
|
143
|
+
attempts,
|
|
144
|
+
statusRetryLimit,
|
|
145
|
+
statusRetryBackoffMs,
|
|
146
|
+
branch,
|
|
147
|
+
enableFeatures,
|
|
148
|
+
disableFeatures,
|
|
149
|
+
env: cloudEnvOverrides
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function applyMissingCloudEnvironmentFailure(params) {
|
|
153
|
+
const detail = 'Cloud execution requested but no environment id is configured. Set CODEX_CLOUD_ENV_ID or provide target metadata.cloudEnvId.';
|
|
154
|
+
params.manifest.status_detail = 'cloud-env-missing';
|
|
155
|
+
params.manifest.cloud_execution = {
|
|
156
|
+
task_id: null,
|
|
157
|
+
environment_id: null,
|
|
158
|
+
status: 'failed',
|
|
159
|
+
status_url: null,
|
|
160
|
+
submitted_at: null,
|
|
161
|
+
completed_at: isoTimestamp(),
|
|
162
|
+
last_polled_at: null,
|
|
163
|
+
poll_count: 0,
|
|
164
|
+
poll_interval_seconds: DEFAULT_CLOUD_POLL_INTERVAL_SECONDS,
|
|
165
|
+
timeout_seconds: DEFAULT_CLOUD_TIMEOUT_SECONDS,
|
|
166
|
+
attempts: DEFAULT_CLOUD_ATTEMPTS,
|
|
167
|
+
diff_path: null,
|
|
168
|
+
diff_url: null,
|
|
169
|
+
diff_status: 'unavailable',
|
|
170
|
+
apply_status: 'not_requested',
|
|
171
|
+
log_path: null,
|
|
172
|
+
error: detail
|
|
173
|
+
};
|
|
174
|
+
appendSummary(params.manifest, detail);
|
|
175
|
+
params.notes.push(detail);
|
|
176
|
+
params.targetEntry.status = 'failed';
|
|
177
|
+
params.targetEntry.started_at = params.targetEntry.started_at ?? isoTimestamp();
|
|
178
|
+
params.targetEntry.completed_at = isoTimestamp();
|
|
179
|
+
params.targetEntry.exit_code = 1;
|
|
180
|
+
params.targetEntry.summary = detail;
|
|
181
|
+
}
|
|
182
|
+
async function startCloudTargetAndBuildUpdateHandler(params) {
|
|
183
|
+
params.targetEntry.status = 'running';
|
|
184
|
+
params.targetEntry.started_at = isoTimestamp();
|
|
185
|
+
await params.schedulePersist({ manifest: true, force: true });
|
|
186
|
+
params.runEvents?.stageStarted({
|
|
187
|
+
stageId: params.targetStage.id,
|
|
188
|
+
stageIndex: params.targetEntry.index,
|
|
189
|
+
title: params.targetStage.title,
|
|
190
|
+
kind: 'command',
|
|
191
|
+
logPath: params.targetEntry.log_path,
|
|
192
|
+
status: params.targetEntry.status
|
|
193
|
+
});
|
|
194
|
+
return async (cloudExecution) => {
|
|
195
|
+
params.manifest.cloud_execution = cloudExecution;
|
|
196
|
+
params.targetEntry.log_path = cloudExecution.log_path;
|
|
197
|
+
await params.schedulePersist({ manifest: true, force: true });
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
async function applyCloudTargetCompletion(params) {
|
|
201
|
+
params.manifest.cloud_execution = params.cloudResult.cloudExecution;
|
|
202
|
+
params.targetEntry.log_path = params.cloudResult.cloudExecution.log_path;
|
|
203
|
+
params.targetEntry.completed_at = isoTimestamp();
|
|
204
|
+
params.targetEntry.exit_code = params.cloudResult.success ? 0 : 1;
|
|
205
|
+
params.targetEntry.status = params.cloudResult.success ? 'succeeded' : 'failed';
|
|
206
|
+
params.targetEntry.summary = params.cloudResult.summary;
|
|
207
|
+
if (!params.cloudResult.success) {
|
|
208
|
+
params.manifest.status_detail = `cloud:${params.targetStage.id}:failed`;
|
|
209
|
+
appendSummary(params.manifest, params.cloudResult.summary);
|
|
210
|
+
}
|
|
211
|
+
await params.schedulePersist({ manifest: true, force: true });
|
|
212
|
+
params.runEvents?.stageCompleted({
|
|
213
|
+
stageId: params.targetStage.id,
|
|
214
|
+
stageIndex: params.targetEntry.index,
|
|
215
|
+
title: params.targetStage.title,
|
|
216
|
+
kind: 'command',
|
|
217
|
+
status: params.targetEntry.status,
|
|
218
|
+
exitCode: params.targetEntry.exit_code,
|
|
219
|
+
summary: params.targetEntry.summary,
|
|
220
|
+
logPath: params.targetEntry.log_path
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
export async function executeOrchestratorCloudTarget(options) {
|
|
224
|
+
const notes = [];
|
|
225
|
+
let success = true;
|
|
226
|
+
const { manifest, pipeline, target, task, runEvents, controlWatcher, schedulePersist } = options;
|
|
227
|
+
const preflight = await prepareCloudTargetPreflight({
|
|
228
|
+
manifest,
|
|
229
|
+
pipeline,
|
|
230
|
+
target,
|
|
231
|
+
controlWatcher
|
|
232
|
+
});
|
|
233
|
+
if (!preflight.success) {
|
|
234
|
+
return preflight;
|
|
235
|
+
}
|
|
236
|
+
const { targetStage, targetEntry } = preflight;
|
|
237
|
+
const environmentId = resolveCloudEnvironmentId(task, target, options.envOverrides);
|
|
238
|
+
if (!environmentId) {
|
|
239
|
+
success = false;
|
|
240
|
+
applyMissingCloudEnvironmentFailure({ manifest, notes, targetEntry });
|
|
241
|
+
return { success, notes };
|
|
242
|
+
}
|
|
243
|
+
const onUpdate = await startCloudTargetAndBuildUpdateHandler({
|
|
244
|
+
manifest,
|
|
245
|
+
targetStage,
|
|
246
|
+
targetEntry,
|
|
247
|
+
schedulePersist,
|
|
248
|
+
runEvents
|
|
249
|
+
});
|
|
250
|
+
const request = buildCloudTaskExecutorRequest({
|
|
251
|
+
env: options.env,
|
|
252
|
+
runDir: options.paths.runDir,
|
|
253
|
+
task,
|
|
254
|
+
target,
|
|
255
|
+
pipeline,
|
|
256
|
+
stage: targetStage,
|
|
257
|
+
manifest,
|
|
258
|
+
environmentId,
|
|
259
|
+
envOverrides: options.envOverrides
|
|
260
|
+
});
|
|
261
|
+
const executor = new CodexCloudTaskExecutor();
|
|
262
|
+
const cloudResult = await executor.execute({
|
|
263
|
+
...request,
|
|
264
|
+
onUpdate
|
|
265
|
+
});
|
|
266
|
+
success = cloudResult.success;
|
|
267
|
+
notes.push(...cloudResult.notes);
|
|
268
|
+
await applyCloudTargetCompletion({
|
|
269
|
+
manifest,
|
|
270
|
+
targetStage,
|
|
271
|
+
targetEntry,
|
|
272
|
+
cloudResult,
|
|
273
|
+
schedulePersist,
|
|
274
|
+
runEvents
|
|
275
|
+
});
|
|
276
|
+
return { success, notes };
|
|
277
|
+
}
|