@kbediako/codex-orchestrator 0.1.38 → 0.2.1
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 +46 -317
- package/bin/codex-orchestrator.js +161 -0
- package/codex.orchestrator.json +149 -13
- package/dist/bin/codex-orchestrator.js +797 -1154
- package/dist/orchestrator/src/cli/adapters/CommandBuilder.js +50 -0
- 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 +295 -11
- package/dist/orchestrator/src/cli/coStatusAttachCliShell.js +402 -0
- package/dist/orchestrator/src/cli/coStatusCliShell.js +451 -0
- package/dist/orchestrator/src/cli/coStatusOperatorAutopilotCliShell.js +120 -0
- package/dist/orchestrator/src/cli/codexCliShell.js +119 -0
- package/dist/orchestrator/src/cli/codexDefaultsSetup.js +265 -36
- 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 +630 -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 +1003 -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 +1904 -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 +1885 -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 +678 -164
- 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 +95 -1
- 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 +1835 -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 +6834 -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 +698 -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 +285 -7
- package/dist/orchestrator/src/cli/utils/codexFeatures.js +60 -0
- 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/manager.js +74 -4
- 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 +399 -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/README.md +43 -20
- package/docs/book/README.md +19 -0
- package/docs/book/codex-cli-0124-adoption.md +68 -0
- package/docs/book/local-hook-impact.md +73 -0
- package/docs/book/operations.md +60 -0
- package/docs/book/public-posture.md +34 -0
- package/docs/book/setup.md +91 -0
- package/docs/book/skills.md +11 -0
- package/docs/guides/codex-version-policy.md +104 -0
- package/docs/public/downstream-setup.md +113 -0
- package/docs/public/provider-onboarding.md +173 -0
- package/package.json +23 -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 +361 -0
- package/schemas/manifest.json +411 -0
- package/skills/README.md +26 -0
- package/skills/collab-subagents-first/SKILL.md +1 -1
- package/skills/delegation-usage/DELEGATION_GUIDE.md +30 -12
- package/skills/delegation-usage/SKILL.md +25 -14
- 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 +15 -8
- package/templates/codex/mcp-client.json +5 -1
- package/docs/assets/setup.gif +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable patterns/prefer-logger-over-console */
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { splitDelegationConfigOverrides } from './config/delegationConfig.js';
|
|
4
|
+
import { startDelegationServer } from './delegationServer.js';
|
|
5
|
+
const DEFAULT_DEPENDENCIES = {
|
|
6
|
+
startDelegationServer,
|
|
7
|
+
getCwd: () => process.cwd(),
|
|
8
|
+
getEnvMode: () => process.env.CODEX_DELEGATE_MODE,
|
|
9
|
+
warn: (line) => console.warn(line)
|
|
10
|
+
};
|
|
11
|
+
export async function runDelegationServerCliShell(params, overrides = {}) {
|
|
12
|
+
const dependencies = { ...DEFAULT_DEPENDENCIES, ...overrides };
|
|
13
|
+
if (isHelpRequest(params.positionals, params.flags)) {
|
|
14
|
+
params.printHelp();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const repoRoot = readStringFlag(params.flags, 'repo') ?? dependencies.getCwd();
|
|
18
|
+
const modeFlag = readStringFlag(params.flags, 'mode');
|
|
19
|
+
const overrideFlag = readStringFlag(params.flags, 'config') ?? readStringFlag(params.flags, 'config-override');
|
|
20
|
+
const envMode = dependencies.getEnvMode()?.trim();
|
|
21
|
+
const resolvedMode = modeFlag ?? envMode;
|
|
22
|
+
let mode;
|
|
23
|
+
if (resolvedMode) {
|
|
24
|
+
if (isDelegationMode(resolvedMode)) {
|
|
25
|
+
mode = resolvedMode;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
dependencies.warn(`Invalid delegate mode "${resolvedMode}". Falling back to config default.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const configOverrides = overrideFlag
|
|
32
|
+
? splitDelegationConfigOverrides(overrideFlag).map((value) => ({
|
|
33
|
+
source: 'cli',
|
|
34
|
+
value
|
|
35
|
+
}))
|
|
36
|
+
: [];
|
|
37
|
+
await dependencies.startDelegationServer({ repoRoot, mode, configOverrides });
|
|
38
|
+
}
|
|
39
|
+
function isHelpRequest(positionals, flags) {
|
|
40
|
+
if (flags['help'] !== undefined) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
const first = positionals[0];
|
|
44
|
+
return first === 'help' || first === '--help' || first === '-h';
|
|
45
|
+
}
|
|
46
|
+
function readStringFlag(flags, key) {
|
|
47
|
+
const value = flags[key];
|
|
48
|
+
return typeof value === 'string' ? value : undefined;
|
|
49
|
+
}
|
|
50
|
+
function isDelegationMode(value) {
|
|
51
|
+
return value === 'full' || value === 'question_only' || value === 'status_only';
|
|
52
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
export const QUESTION_POLL_INTERVAL_MS = 500;
|
|
5
|
+
export const MAX_QUESTION_POLL_WAIT_MS = 10_000;
|
|
6
|
+
export async function handleDelegationServerQuestionEnqueue(input, request, allowedRoots, allowedHosts, expiryFallback, deps) {
|
|
7
|
+
const parentManifestPath = deps.resolveParentManifestPath(input, allowedRoots);
|
|
8
|
+
if (!parentManifestPath) {
|
|
9
|
+
throw new Error('parent_manifest_path is required');
|
|
10
|
+
}
|
|
11
|
+
const delegationToken = await resolveDelegationTokenValue(request, allowedRoots, {
|
|
12
|
+
retryMs: deps.defaultDelegationTokenRetryMs,
|
|
13
|
+
intervalMs: deps.defaultDelegationTokenRetryIntervalMs
|
|
14
|
+
}, deps);
|
|
15
|
+
const childRunId = process.env.CODEX_ORCHESTRATOR_RUN_ID ?? deps.readStringValue(input, 'from_run_id', 'fromRunId') ?? '';
|
|
16
|
+
if (!delegationToken) {
|
|
17
|
+
throw new Error('delegation_token missing');
|
|
18
|
+
}
|
|
19
|
+
const autoPause = deps.readBooleanValue(input, 'auto_pause', 'autoPause') ?? true;
|
|
20
|
+
const manifestFromEnv = process.env.CODEX_ORCHESTRATOR_MANIFEST_PATH;
|
|
21
|
+
const manifestFromInput = deps.readStringValue(input, 'from_manifest_path', 'fromManifestPath');
|
|
22
|
+
const childManifestPath = manifestFromEnv ?? manifestFromInput;
|
|
23
|
+
const result = await deps.callControlEndpointWithRetry(parentManifestPath, '/questions/enqueue', {
|
|
24
|
+
parent_run_id: deps.readStringValue(input, 'parent_run_id', 'parentRunId') ?? '',
|
|
25
|
+
parent_task_id: deps.readStringValue(input, 'parent_task_id', 'parentTaskId') ?? null,
|
|
26
|
+
from_run_id: childRunId,
|
|
27
|
+
from_manifest_path: childManifestPath ?? null,
|
|
28
|
+
prompt: deps.requireString(deps.readStringValue(input, 'prompt'), 'prompt'),
|
|
29
|
+
urgency: deps.readStringValue(input, 'urgency') ?? 'med',
|
|
30
|
+
expires_in_ms: deps.readNumberValue(input, 'expires_in_ms', 'expiresInMs'),
|
|
31
|
+
auto_pause: autoPause,
|
|
32
|
+
expiry_fallback: expiryFallback
|
|
33
|
+
}, {
|
|
34
|
+
[deps.delegationTokenHeader]: delegationToken,
|
|
35
|
+
[deps.delegationRunHeader]: childRunId
|
|
36
|
+
}, {
|
|
37
|
+
allowedHosts,
|
|
38
|
+
allowedRoots,
|
|
39
|
+
retryMs: deps.defaultDelegationTokenRetryMs,
|
|
40
|
+
retryIntervalMs: deps.defaultDelegationTokenRetryIntervalMs
|
|
41
|
+
});
|
|
42
|
+
if (autoPause && manifestFromEnv) {
|
|
43
|
+
const resolvedManifest = deps.resolveRunManifestPath(manifestFromEnv, allowedRoots, 'manifest_path');
|
|
44
|
+
await deps.callControlEndpoint(resolvedManifest, '/control/action', {
|
|
45
|
+
action: 'pause',
|
|
46
|
+
requested_by: 'delegate',
|
|
47
|
+
reason: 'awaiting_question_answer'
|
|
48
|
+
}, undefined, { allowedHosts, allowedRoots });
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
...result,
|
|
52
|
+
fallback_action: expiryFallback
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export async function handleDelegationServerQuestionPoll(input, request, allowedRoots, allowedHosts, expiryFallback, deps) {
|
|
56
|
+
const parentManifestPath = deps.resolveParentManifestPath(input, allowedRoots);
|
|
57
|
+
if (!parentManifestPath) {
|
|
58
|
+
throw new Error('parent_manifest_path is required');
|
|
59
|
+
}
|
|
60
|
+
const delegationToken = await resolveDelegationTokenValue(request, allowedRoots, {
|
|
61
|
+
retryMs: deps.defaultDelegationTokenRetryMs,
|
|
62
|
+
intervalMs: deps.defaultDelegationTokenRetryIntervalMs
|
|
63
|
+
}, deps);
|
|
64
|
+
const childRunId = process.env.CODEX_ORCHESTRATOR_RUN_ID ?? deps.readStringValue(input, 'from_run_id', 'fromRunId') ?? '';
|
|
65
|
+
if (!delegationToken) {
|
|
66
|
+
throw new Error('delegation_token missing');
|
|
67
|
+
}
|
|
68
|
+
const questionId = deps.requireString(deps.readStringValue(input, 'question_id', 'questionId'), 'question_id');
|
|
69
|
+
const requestedWaitMs = deps.readNumberValue(input, 'wait_ms', 'waitMs') ?? 0;
|
|
70
|
+
const waitMs = clampQuestionPollWaitMs(requestedWaitMs);
|
|
71
|
+
const deadline = Date.now() + waitMs;
|
|
72
|
+
const maxIterations = waitMs > 0 ? Math.max(1, Math.ceil(waitMs / QUESTION_POLL_INTERVAL_MS)) : 1;
|
|
73
|
+
for (let iteration = 0; iteration < maxIterations; iteration += 1) {
|
|
74
|
+
const remainingMs = waitMs > 0 ? Math.max(0, deadline - Date.now()) : null;
|
|
75
|
+
const timeoutMs = remainingMs === null ? undefined : Math.max(1, Math.min(deps.defaultControlEndpointTimeoutMs, remainingMs));
|
|
76
|
+
const retryMs = remainingMs === null
|
|
77
|
+
? deps.defaultDelegationTokenRetryMs
|
|
78
|
+
: Math.min(deps.defaultDelegationTokenRetryMs, remainingMs);
|
|
79
|
+
const record = await deps.callControlEndpointWithRetry(parentManifestPath, `/questions/${questionId}`, null, {
|
|
80
|
+
[deps.delegationTokenHeader]: delegationToken,
|
|
81
|
+
[deps.delegationRunHeader]: childRunId
|
|
82
|
+
}, {
|
|
83
|
+
allowedHosts,
|
|
84
|
+
allowedRoots,
|
|
85
|
+
retryMs,
|
|
86
|
+
retryIntervalMs: deps.defaultDelegationTokenRetryIntervalMs,
|
|
87
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {})
|
|
88
|
+
});
|
|
89
|
+
const status = deps.readStringValue(record, 'status');
|
|
90
|
+
if (status !== 'queued' || waitMs <= 0 || Date.now() >= deadline) {
|
|
91
|
+
const expiresAt = deps.readStringValue(record, 'expires_at', 'expiresAt');
|
|
92
|
+
if (status === 'expired') {
|
|
93
|
+
await applyDelegationQuestionFallback(expiryFallback, allowedHosts, allowedRoots, deps);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
...record,
|
|
97
|
+
expired_at: status === 'expired' ? expiresAt ?? null : null,
|
|
98
|
+
fallback_action: status === 'expired' ? expiryFallback : null
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
await deps.delay(QUESTION_POLL_INTERVAL_MS);
|
|
102
|
+
}
|
|
103
|
+
const remainingMs = waitMs > 0 ? Math.max(0, deadline - Date.now()) : null;
|
|
104
|
+
const timeoutMs = remainingMs === null ? undefined : Math.max(1, Math.min(deps.defaultControlEndpointTimeoutMs, remainingMs));
|
|
105
|
+
const record = await deps.callControlEndpoint(parentManifestPath, `/questions/${questionId}`, null, {
|
|
106
|
+
[deps.delegationTokenHeader]: delegationToken,
|
|
107
|
+
[deps.delegationRunHeader]: childRunId
|
|
108
|
+
}, {
|
|
109
|
+
allowedHosts,
|
|
110
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {})
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
...record,
|
|
114
|
+
expired_at: null,
|
|
115
|
+
fallback_action: null
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export async function resolveDelegationTokenValue(request, allowedRoots, options, deps) {
|
|
119
|
+
const privateToken = request.codex_private?.delegation_token;
|
|
120
|
+
if (privateToken) {
|
|
121
|
+
return String(privateToken);
|
|
122
|
+
}
|
|
123
|
+
const tokenPath = resolveDelegationTokenPath(allowedRoots, deps);
|
|
124
|
+
if (!tokenPath) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const retryMs = options.retryMs ?? 0;
|
|
128
|
+
const intervalMs = options.intervalMs ?? deps.defaultDelegationTokenRetryIntervalMs;
|
|
129
|
+
const deadline = Date.now() + retryMs;
|
|
130
|
+
let token = await readDelegationTokenFile(tokenPath, deps.safeJsonParse);
|
|
131
|
+
while (!token && Date.now() < deadline) {
|
|
132
|
+
await deps.delay(intervalMs);
|
|
133
|
+
token = await readDelegationTokenFile(tokenPath, deps.safeJsonParse);
|
|
134
|
+
}
|
|
135
|
+
return token;
|
|
136
|
+
}
|
|
137
|
+
export function clampQuestionPollWaitMs(value) {
|
|
138
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
return Math.min(value, MAX_QUESTION_POLL_WAIT_MS);
|
|
142
|
+
}
|
|
143
|
+
export async function applyDelegationQuestionFallback(fallback, allowedHosts, allowedRoots, deps) {
|
|
144
|
+
const manifestPath = process.env.CODEX_ORCHESTRATOR_MANIFEST_PATH;
|
|
145
|
+
if (!manifestPath) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const shouldResolve = await isDelegationRunAwaitingQuestion(manifestPath, allowedRoots, deps);
|
|
149
|
+
if (!shouldResolve) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const action = fallback === 'pause' ? 'pause' : fallback === 'resume' ? 'resume' : 'fail';
|
|
153
|
+
try {
|
|
154
|
+
await deps.callControlEndpoint(deps.resolveRunManifestPath(manifestPath, allowedRoots, 'manifest_path'), '/control/action', {
|
|
155
|
+
action,
|
|
156
|
+
requested_by: 'delegate',
|
|
157
|
+
reason: 'question_expired'
|
|
158
|
+
}, undefined, { allowedHosts, allowedRoots });
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// ignore
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function isDelegationRunAwaitingQuestion(manifestPath, allowedRoots, deps) {
|
|
165
|
+
try {
|
|
166
|
+
const resolvedManifest = deps.resolveRunManifestPath(manifestPath, allowedRoots, 'manifest_path');
|
|
167
|
+
const controlPath = resolve(dirname(resolvedManifest), 'control.json');
|
|
168
|
+
const raw = await readFile(controlPath, 'utf8');
|
|
169
|
+
const snapshot = deps.safeJsonParse(raw);
|
|
170
|
+
const latest = snapshot && snapshot.latest_action && typeof snapshot.latest_action === 'object'
|
|
171
|
+
? snapshot.latest_action
|
|
172
|
+
: null;
|
|
173
|
+
if (!latest) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return latest.action === 'pause' && latest.reason === 'awaiting_question_answer';
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function resolveDelegationTokenPath(allowedRoots, deps) {
|
|
183
|
+
const explicit = process.env.CODEX_DELEGATION_TOKEN_PATH?.trim();
|
|
184
|
+
const manifestPath = process.env.CODEX_ORCHESTRATOR_MANIFEST_PATH?.trim();
|
|
185
|
+
let runDir = null;
|
|
186
|
+
if (manifestPath) {
|
|
187
|
+
try {
|
|
188
|
+
const resolvedManifest = deps.resolveRunManifestPath(manifestPath, allowedRoots, 'manifest_path');
|
|
189
|
+
runDir = dirname(resolvedManifest);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (explicit) {
|
|
196
|
+
if (!runDir && !isAbsolute(explicit)) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
const resolvedToken = runDir && !isAbsolute(explicit) ? resolve(runDir, explicit) : resolve(explicit);
|
|
200
|
+
if (runDir) {
|
|
201
|
+
if (!deps.isPathWithinRoots(resolvedToken, [runDir])) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (allowedRoots && allowedRoots.length > 0 && !deps.isPathWithinRoots(resolvedToken, allowedRoots)) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
return resolvedToken;
|
|
209
|
+
}
|
|
210
|
+
if (runDir) {
|
|
211
|
+
return resolve(runDir, deps.delegationTokenFile);
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
async function readDelegationTokenFile(tokenPath, safeJsonParse) {
|
|
216
|
+
try {
|
|
217
|
+
const raw = await readFile(tokenPath, 'utf8');
|
|
218
|
+
const parsed = safeJsonParse(raw);
|
|
219
|
+
const tokenValue = parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
220
|
+
? parsed.token
|
|
221
|
+
: null;
|
|
222
|
+
const token = typeof tokenValue === 'string' && tokenValue.trim().length > 0 ? tokenValue.trim() : raw.trim();
|
|
223
|
+
return token || null;
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
const CLOSED_WORLD_READ_ONLY = {
|
|
2
|
+
readOnlyHint: true,
|
|
3
|
+
openWorldHint: false
|
|
4
|
+
};
|
|
5
|
+
const CLOSED_WORLD_ADDITIVE_WRITE = {
|
|
6
|
+
readOnlyHint: false,
|
|
7
|
+
destructiveHint: false,
|
|
8
|
+
idempotentHint: false,
|
|
9
|
+
openWorldHint: false
|
|
10
|
+
};
|
|
11
|
+
const CLOSED_WORLD_DESTRUCTIVE_WRITE = {
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
destructiveHint: true,
|
|
14
|
+
idempotentHint: false,
|
|
15
|
+
openWorldHint: false
|
|
16
|
+
};
|
|
17
|
+
const OPEN_WORLD_READ_ONLY = {
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
openWorldHint: true
|
|
20
|
+
};
|
|
21
|
+
const OPEN_WORLD_ADDITIVE_WRITE = {
|
|
22
|
+
readOnlyHint: false,
|
|
23
|
+
destructiveHint: false,
|
|
24
|
+
idempotentHint: false,
|
|
25
|
+
openWorldHint: true
|
|
26
|
+
};
|
|
27
|
+
const OPEN_WORLD_DESTRUCTIVE_WRITE = {
|
|
28
|
+
readOnlyHint: false,
|
|
29
|
+
destructiveHint: true,
|
|
30
|
+
idempotentHint: false,
|
|
31
|
+
openWorldHint: true
|
|
32
|
+
};
|
|
33
|
+
const TOOL_METADATA_BY_NAME = {
|
|
34
|
+
'delegate.spawn': {
|
|
35
|
+
title: 'Spawn Delegated Run',
|
|
36
|
+
annotations: OPEN_WORLD_ADDITIVE_WRITE
|
|
37
|
+
},
|
|
38
|
+
'delegate.pause': {
|
|
39
|
+
title: 'Pause Or Resume Run',
|
|
40
|
+
annotations: CLOSED_WORLD_ADDITIVE_WRITE
|
|
41
|
+
},
|
|
42
|
+
'delegate.cancel': {
|
|
43
|
+
title: 'Cancel Run',
|
|
44
|
+
annotations: CLOSED_WORLD_DESTRUCTIVE_WRITE
|
|
45
|
+
},
|
|
46
|
+
'delegate.status': {
|
|
47
|
+
title: 'Fetch Run Status',
|
|
48
|
+
annotations: CLOSED_WORLD_READ_ONLY
|
|
49
|
+
},
|
|
50
|
+
'delegate.question.enqueue': {
|
|
51
|
+
title: 'Enqueue Parent Question',
|
|
52
|
+
annotations: CLOSED_WORLD_ADDITIVE_WRITE
|
|
53
|
+
},
|
|
54
|
+
'delegate.question.poll': {
|
|
55
|
+
title: 'Poll Parent Question',
|
|
56
|
+
annotations: CLOSED_WORLD_ADDITIVE_WRITE
|
|
57
|
+
},
|
|
58
|
+
'coordinator.status': {
|
|
59
|
+
title: 'Coordinator Status Bridge',
|
|
60
|
+
annotations: CLOSED_WORLD_READ_ONLY
|
|
61
|
+
},
|
|
62
|
+
'coordinator.pause': {
|
|
63
|
+
title: 'Coordinator Pause Bridge',
|
|
64
|
+
annotations: CLOSED_WORLD_ADDITIVE_WRITE
|
|
65
|
+
},
|
|
66
|
+
'coordinator.resume': {
|
|
67
|
+
title: 'Coordinator Resume Bridge',
|
|
68
|
+
annotations: CLOSED_WORLD_ADDITIVE_WRITE
|
|
69
|
+
},
|
|
70
|
+
'coordinator.cancel': {
|
|
71
|
+
title: 'Coordinator Cancel Bridge',
|
|
72
|
+
annotations: CLOSED_WORLD_DESTRUCTIVE_WRITE
|
|
73
|
+
},
|
|
74
|
+
'github.open_pr': {
|
|
75
|
+
title: 'Open GitHub Pull Request',
|
|
76
|
+
annotations: OPEN_WORLD_ADDITIVE_WRITE
|
|
77
|
+
},
|
|
78
|
+
'github.comment': {
|
|
79
|
+
title: 'Create GitHub Comment',
|
|
80
|
+
annotations: OPEN_WORLD_ADDITIVE_WRITE
|
|
81
|
+
},
|
|
82
|
+
'github.review': {
|
|
83
|
+
title: 'Submit GitHub Review',
|
|
84
|
+
annotations: OPEN_WORLD_ADDITIVE_WRITE
|
|
85
|
+
},
|
|
86
|
+
'github.get_checks': {
|
|
87
|
+
title: 'Fetch GitHub Checks',
|
|
88
|
+
annotations: OPEN_WORLD_READ_ONLY
|
|
89
|
+
},
|
|
90
|
+
'github.merge': {
|
|
91
|
+
title: 'Merge GitHub Pull Request',
|
|
92
|
+
annotations: OPEN_WORLD_DESTRUCTIVE_WRITE
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export function createDelegationServerRpcHandler(options) {
|
|
96
|
+
const serverInfo = options.serverInfo ?? { name: 'codex-delegation', version: '0.1.0' };
|
|
97
|
+
return async (request) => {
|
|
98
|
+
switch (request.method) {
|
|
99
|
+
case 'initialize':
|
|
100
|
+
return {
|
|
101
|
+
protocolVersion: options.protocolVersion,
|
|
102
|
+
serverInfo,
|
|
103
|
+
capabilities: { tools: {} }
|
|
104
|
+
};
|
|
105
|
+
case 'tools/list':
|
|
106
|
+
return { tools: options.tools };
|
|
107
|
+
case 'tools/call':
|
|
108
|
+
return await options.handleToolCall(request);
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`Unsupported method: ${request.method}`);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export function buildToolList(options) {
|
|
115
|
+
const tools = [];
|
|
116
|
+
const includeFull = options.mode === 'full';
|
|
117
|
+
const includeQuestionAndGithub = options.mode !== 'status_only';
|
|
118
|
+
if (includeFull) {
|
|
119
|
+
tools.push(toolDefinition('delegate.spawn', 'Spawn a delegated run', {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
task_id: { type: 'string' },
|
|
123
|
+
pipeline: { type: 'string' },
|
|
124
|
+
repo: { type: 'string' },
|
|
125
|
+
parent_run_id: { type: 'string' },
|
|
126
|
+
parent_manifest_path: { type: 'string' },
|
|
127
|
+
env: { type: 'object', additionalProperties: { type: 'string' } },
|
|
128
|
+
delegate_mode: { type: 'string', enum: ['full', 'question_only', 'status_only'] },
|
|
129
|
+
start_only: { type: 'boolean' }
|
|
130
|
+
},
|
|
131
|
+
required: ['pipeline', 'repo']
|
|
132
|
+
}));
|
|
133
|
+
tools.push(toolDefinition('delegate.pause', 'Pause or resume a run', {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
manifest_path: { type: 'string' },
|
|
137
|
+
paused: { type: 'boolean' },
|
|
138
|
+
intent_id: { type: 'string' },
|
|
139
|
+
request_id: { type: 'string' },
|
|
140
|
+
transport: { type: 'string', enum: ['discord', 'telegram'] },
|
|
141
|
+
actor_id: { type: 'string' },
|
|
142
|
+
actor_source: { type: 'string' },
|
|
143
|
+
transport_principal: { type: 'string' },
|
|
144
|
+
transport_nonce: { type: 'string' },
|
|
145
|
+
transport_nonce_expires_at: { type: 'string' }
|
|
146
|
+
},
|
|
147
|
+
required: ['manifest_path', 'paused']
|
|
148
|
+
}));
|
|
149
|
+
tools.push(toolDefinition('delegate.cancel', 'Cancel a run (confirmation required)', {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
manifest_path: { type: 'string' },
|
|
153
|
+
intent_id: { type: 'string' },
|
|
154
|
+
request_id: { type: 'string' },
|
|
155
|
+
transport: { type: 'string', enum: ['discord', 'telegram'] },
|
|
156
|
+
actor_id: { type: 'string' },
|
|
157
|
+
actor_source: { type: 'string' },
|
|
158
|
+
transport_principal: { type: 'string' },
|
|
159
|
+
transport_nonce: { type: 'string' },
|
|
160
|
+
transport_nonce_expires_at: { type: 'string' }
|
|
161
|
+
},
|
|
162
|
+
required: ['manifest_path']
|
|
163
|
+
}));
|
|
164
|
+
tools.push(toolDefinition('coordinator.status', 'Experimental coordinator dynamic-tool status bridge', {
|
|
165
|
+
type: 'object',
|
|
166
|
+
properties: {
|
|
167
|
+
manifest_path: { type: 'string' },
|
|
168
|
+
intent_id: { type: 'string' },
|
|
169
|
+
request_id: { type: 'string' },
|
|
170
|
+
...dynamicToolBridgeSourceSchemaProperties()
|
|
171
|
+
},
|
|
172
|
+
required: ['manifest_path']
|
|
173
|
+
}));
|
|
174
|
+
tools.push(toolDefinition('coordinator.pause', 'Experimental coordinator dynamic-tool pause bridge', {
|
|
175
|
+
type: 'object',
|
|
176
|
+
properties: {
|
|
177
|
+
manifest_path: { type: 'string' },
|
|
178
|
+
intent_id: { type: 'string' },
|
|
179
|
+
request_id: { type: 'string' },
|
|
180
|
+
transport: { type: 'string', enum: ['discord', 'telegram'] },
|
|
181
|
+
actor_id: { type: 'string' },
|
|
182
|
+
actor_source: { type: 'string' },
|
|
183
|
+
transport_principal: { type: 'string' },
|
|
184
|
+
transport_nonce: { type: 'string' },
|
|
185
|
+
transport_nonce_expires_at: { type: 'string' },
|
|
186
|
+
...dynamicToolBridgeSourceSchemaProperties()
|
|
187
|
+
},
|
|
188
|
+
required: ['manifest_path']
|
|
189
|
+
}));
|
|
190
|
+
tools.push(toolDefinition('coordinator.resume', 'Experimental coordinator dynamic-tool resume bridge', {
|
|
191
|
+
type: 'object',
|
|
192
|
+
properties: {
|
|
193
|
+
manifest_path: { type: 'string' },
|
|
194
|
+
intent_id: { type: 'string' },
|
|
195
|
+
request_id: { type: 'string' },
|
|
196
|
+
transport: { type: 'string', enum: ['discord', 'telegram'] },
|
|
197
|
+
actor_id: { type: 'string' },
|
|
198
|
+
actor_source: { type: 'string' },
|
|
199
|
+
transport_principal: { type: 'string' },
|
|
200
|
+
transport_nonce: { type: 'string' },
|
|
201
|
+
transport_nonce_expires_at: { type: 'string' },
|
|
202
|
+
...dynamicToolBridgeSourceSchemaProperties()
|
|
203
|
+
},
|
|
204
|
+
required: ['manifest_path']
|
|
205
|
+
}));
|
|
206
|
+
tools.push(toolDefinition('coordinator.cancel', 'Experimental coordinator dynamic-tool cancel bridge', {
|
|
207
|
+
type: 'object',
|
|
208
|
+
properties: {
|
|
209
|
+
manifest_path: { type: 'string' },
|
|
210
|
+
intent_id: { type: 'string' },
|
|
211
|
+
request_id: { type: 'string' },
|
|
212
|
+
transport: { type: 'string', enum: ['discord', 'telegram'] },
|
|
213
|
+
actor_id: { type: 'string' },
|
|
214
|
+
actor_source: { type: 'string' },
|
|
215
|
+
transport_principal: { type: 'string' },
|
|
216
|
+
transport_nonce: { type: 'string' },
|
|
217
|
+
transport_nonce_expires_at: { type: 'string' },
|
|
218
|
+
...dynamicToolBridgeSourceSchemaProperties()
|
|
219
|
+
},
|
|
220
|
+
required: ['manifest_path']
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
tools.push(toolDefinition('delegate.status', 'Fetch run status', {
|
|
224
|
+
type: 'object',
|
|
225
|
+
properties: {
|
|
226
|
+
manifest_path: { type: 'string' },
|
|
227
|
+
intent_id: { type: 'string' },
|
|
228
|
+
request_id: { type: 'string' }
|
|
229
|
+
},
|
|
230
|
+
required: ['manifest_path']
|
|
231
|
+
}));
|
|
232
|
+
if (includeQuestionAndGithub) {
|
|
233
|
+
tools.push(toolDefinition('delegate.question.enqueue', 'Enqueue a question to the parent run', {
|
|
234
|
+
type: 'object',
|
|
235
|
+
properties: {
|
|
236
|
+
parent_manifest_path: { type: 'string' },
|
|
237
|
+
parent_run_id: { type: 'string' },
|
|
238
|
+
parent_task_id: { type: 'string' },
|
|
239
|
+
from_manifest_path: { type: 'string' },
|
|
240
|
+
prompt: { type: 'string' },
|
|
241
|
+
urgency: { type: 'string', enum: ['low', 'med', 'high'] },
|
|
242
|
+
expires_in_ms: { type: 'number' },
|
|
243
|
+
auto_pause: { type: 'boolean' }
|
|
244
|
+
},
|
|
245
|
+
required: ['parent_manifest_path', 'prompt']
|
|
246
|
+
}));
|
|
247
|
+
tools.push(toolDefinition('delegate.question.poll', 'Poll for a question answer', {
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
parent_manifest_path: { type: 'string' },
|
|
251
|
+
question_id: { type: 'string' },
|
|
252
|
+
wait_ms: { type: 'number' }
|
|
253
|
+
},
|
|
254
|
+
required: ['parent_manifest_path', 'question_id']
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
if (includeQuestionAndGithub && options.githubEnabled) {
|
|
258
|
+
if (options.allowedGithubOps.has('open_pr')) {
|
|
259
|
+
tools.push(toolDefinition('github.open_pr', 'Open a pull request', {
|
|
260
|
+
type: 'object',
|
|
261
|
+
properties: {
|
|
262
|
+
repo: { type: 'string' },
|
|
263
|
+
title: { type: 'string' },
|
|
264
|
+
body: { type: 'string' },
|
|
265
|
+
base: { type: 'string' },
|
|
266
|
+
head: { type: 'string' },
|
|
267
|
+
draft: { type: 'boolean' }
|
|
268
|
+
},
|
|
269
|
+
required: ['title']
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
if (options.allowedGithubOps.has('comment')) {
|
|
273
|
+
tools.push(toolDefinition('github.comment', 'Create a PR/issue comment', {
|
|
274
|
+
type: 'object',
|
|
275
|
+
properties: {
|
|
276
|
+
repo: { type: 'string' },
|
|
277
|
+
issue_number: { type: 'number' },
|
|
278
|
+
body: { type: 'string' }
|
|
279
|
+
},
|
|
280
|
+
required: ['issue_number', 'body']
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
if (options.allowedGithubOps.has('review')) {
|
|
284
|
+
tools.push(toolDefinition('github.review', 'Submit a PR review', {
|
|
285
|
+
type: 'object',
|
|
286
|
+
properties: {
|
|
287
|
+
repo: { type: 'string' },
|
|
288
|
+
pull_number: { type: 'number' },
|
|
289
|
+
event: { type: 'string', enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'] },
|
|
290
|
+
body: { type: 'string' }
|
|
291
|
+
},
|
|
292
|
+
required: ['pull_number', 'event']
|
|
293
|
+
}));
|
|
294
|
+
}
|
|
295
|
+
if (options.allowedGithubOps.has('get_checks')) {
|
|
296
|
+
tools.push(toolDefinition('github.get_checks', 'Fetch PR checks', {
|
|
297
|
+
type: 'object',
|
|
298
|
+
properties: {
|
|
299
|
+
repo: { type: 'string' },
|
|
300
|
+
pull_number: { type: 'number' }
|
|
301
|
+
},
|
|
302
|
+
required: ['pull_number']
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
if (options.allowedGithubOps.has('merge')) {
|
|
306
|
+
tools.push(toolDefinition('github.merge', 'Merge a PR', {
|
|
307
|
+
type: 'object',
|
|
308
|
+
properties: {
|
|
309
|
+
manifest_path: { type: 'string' },
|
|
310
|
+
repo: { type: 'string' },
|
|
311
|
+
pull_number: { type: 'number' },
|
|
312
|
+
method: { type: 'string', enum: ['merge', 'squash', 'rebase'] },
|
|
313
|
+
delete_branch: { type: 'boolean' }
|
|
314
|
+
},
|
|
315
|
+
required: ['pull_number']
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return tools;
|
|
320
|
+
}
|
|
321
|
+
export async function handleDelegationServerToolCall(request, context, deps) {
|
|
322
|
+
const params = deps.asRecord(request.params);
|
|
323
|
+
const toolName = deps.readStringValue(params, 'name');
|
|
324
|
+
if (!toolName) {
|
|
325
|
+
throw new Error('Invalid tool call: missing name');
|
|
326
|
+
}
|
|
327
|
+
const input = deps.asRecord(params.arguments);
|
|
328
|
+
const delegateModeViolationMessage = deps.getDelegateModeViolationMessage(context.mode, toolName);
|
|
329
|
+
if (delegateModeViolationMessage) {
|
|
330
|
+
await deps.reportSecurityViolation('delegate_mode_violation', delegateModeViolationMessage, toolName, context.allowedHosts);
|
|
331
|
+
throw new Error(context.mode === 'question_only' ? 'delegate_mode_forbidden' : delegateModeViolationMessage);
|
|
332
|
+
}
|
|
333
|
+
if (deps.containsSecret(input, 'confirm_nonce') || deps.containsSecret(input, 'confirmNonce')) {
|
|
334
|
+
await deps.reportSecurityViolation('confirm_nonce_present', 'Model supplied confirm_nonce.', toolName, context.allowedHosts);
|
|
335
|
+
throw new Error('confirm_nonce must be injected by the runner');
|
|
336
|
+
}
|
|
337
|
+
if (deps.containsSecret(input, 'delegation_token') || deps.containsSecret(input, 'delegationToken')) {
|
|
338
|
+
await deps.reportSecurityViolation('delegation_token_present', 'Model supplied delegation_token.', toolName, context.allowedHosts);
|
|
339
|
+
throw new Error('delegation_token must be injected by the runner');
|
|
340
|
+
}
|
|
341
|
+
switch (toolName) {
|
|
342
|
+
case 'delegate.status':
|
|
343
|
+
return wrapResult(await deps.handleDelegateStatus(input, context.allowedRoots, context.allowedHosts));
|
|
344
|
+
case 'delegate.pause':
|
|
345
|
+
return wrapResult(await deps.handleDelegatePause(input, context.allowedRoots, context.allowedHosts));
|
|
346
|
+
case 'delegate.cancel':
|
|
347
|
+
return wrapResult(await deps.handleDelegateCancel(input, request, context.allowedRoots, context.allowedHosts));
|
|
348
|
+
case 'delegate.spawn':
|
|
349
|
+
return wrapResult(await deps.handleDelegateSpawn(input, context.repoRoot, context.allowNested, context.allowedRoots, context.allowedHosts, context.toolProfile));
|
|
350
|
+
case 'delegate.question.enqueue':
|
|
351
|
+
return wrapResult(await deps.handleQuestionEnqueue(input, request, context.allowedRoots, context.allowedHosts, context.expiryFallback));
|
|
352
|
+
case 'delegate.question.poll':
|
|
353
|
+
return wrapResult(await deps.handleQuestionPoll(input, request, context.allowedRoots, context.allowedHosts, context.expiryFallback));
|
|
354
|
+
case 'coordinator.status':
|
|
355
|
+
case 'coordinator.pause':
|
|
356
|
+
case 'coordinator.resume':
|
|
357
|
+
case 'coordinator.cancel':
|
|
358
|
+
return wrapResult(await deps.handleCoordinatorDynamicToolCall(toolName, input, request, context.allowedRoots, context.allowedHosts));
|
|
359
|
+
case 'github.open_pr':
|
|
360
|
+
case 'github.comment':
|
|
361
|
+
case 'github.review':
|
|
362
|
+
case 'github.get_checks':
|
|
363
|
+
case 'github.merge':
|
|
364
|
+
return wrapResult(await deps.handleGithubCall(toolName, input, request, context));
|
|
365
|
+
default:
|
|
366
|
+
throw new Error(`Unknown tool: ${toolName}`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function toolDefinition(name, description, inputSchema) {
|
|
370
|
+
const metadata = TOOL_METADATA_BY_NAME[name];
|
|
371
|
+
if (!metadata) {
|
|
372
|
+
return { name, description, inputSchema };
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
375
|
+
name,
|
|
376
|
+
title: metadata.title,
|
|
377
|
+
description,
|
|
378
|
+
inputSchema,
|
|
379
|
+
annotations: metadata.annotations
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
function dynamicToolBridgeSourceSchemaProperties() {
|
|
383
|
+
return {
|
|
384
|
+
source: {
|
|
385
|
+
type: 'object',
|
|
386
|
+
properties: {
|
|
387
|
+
id: { type: 'string' },
|
|
388
|
+
source_id: { type: 'string' },
|
|
389
|
+
sourceId: { type: 'string' },
|
|
390
|
+
bridge_source: { type: 'string' },
|
|
391
|
+
bridgeSource: { type: 'string' }
|
|
392
|
+
},
|
|
393
|
+
additionalProperties: true
|
|
394
|
+
},
|
|
395
|
+
source_id: { type: 'string' },
|
|
396
|
+
sourceId: { type: 'string' },
|
|
397
|
+
bridge_source: { type: 'string' },
|
|
398
|
+
bridgeSource: { type: 'string' }
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function wrapResult(payload) {
|
|
402
|
+
return {
|
|
403
|
+
content: [
|
|
404
|
+
{
|
|
405
|
+
type: 'text',
|
|
406
|
+
text: typeof payload === 'string' ? payload : JSON.stringify(payload, null, 2)
|
|
407
|
+
}
|
|
408
|
+
],
|
|
409
|
+
isError: false
|
|
410
|
+
};
|
|
411
|
+
}
|