@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.
Files changed (311) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/README.md +46 -317
  3. package/bin/codex-orchestrator.js +161 -0
  4. package/codex.orchestrator.json +149 -13
  5. package/dist/bin/codex-orchestrator.js +797 -1154
  6. package/dist/orchestrator/src/cli/adapters/CommandBuilder.js +50 -0
  7. package/dist/orchestrator/src/cli/adapters/CommandPlanner.js +22 -4
  8. package/dist/orchestrator/src/cli/adapters/CommandReviewer.js +3 -3
  9. package/dist/orchestrator/src/cli/adapters/CommandTester.js +2 -2
  10. package/dist/orchestrator/src/cli/adapters/cloudFailureDiagnostics.js +295 -11
  11. package/dist/orchestrator/src/cli/coStatusAttachCliShell.js +402 -0
  12. package/dist/orchestrator/src/cli/coStatusCliShell.js +451 -0
  13. package/dist/orchestrator/src/cli/coStatusOperatorAutopilotCliShell.js +120 -0
  14. package/dist/orchestrator/src/cli/codexCliShell.js +119 -0
  15. package/dist/orchestrator/src/cli/codexDefaultsSetup.js +265 -36
  16. package/dist/orchestrator/src/cli/config/delegationConfig.js +317 -5
  17. package/dist/orchestrator/src/cli/config/repoConfigPolicy.js +2 -3
  18. package/dist/orchestrator/src/cli/config/userConfig.js +28 -13
  19. package/dist/orchestrator/src/cli/control/authenticatedControlRouteGate.js +69 -0
  20. package/dist/orchestrator/src/cli/control/authenticatedRouteComposition.js +267 -0
  21. package/dist/orchestrator/src/cli/control/authenticatedRouteController.js +5 -0
  22. package/dist/orchestrator/src/cli/control/authenticatedRouteDispatcher.js +41 -0
  23. package/dist/orchestrator/src/cli/control/compatibilityIssuePresenter.js +1035 -0
  24. package/dist/orchestrator/src/cli/control/confirmationApproveController.js +62 -0
  25. package/dist/orchestrator/src/cli/control/confirmationCreateController.js +69 -0
  26. package/dist/orchestrator/src/cli/control/confirmationIssueConsumeController.js +43 -0
  27. package/dist/orchestrator/src/cli/control/confirmationListController.js +22 -0
  28. package/dist/orchestrator/src/cli/control/confirmationValidateController.js +58 -0
  29. package/dist/orchestrator/src/cli/control/confirmations.js +25 -3
  30. package/dist/orchestrator/src/cli/control/controlActionCancelConfirmation.js +65 -0
  31. package/dist/orchestrator/src/cli/control/controlActionController.js +77 -0
  32. package/dist/orchestrator/src/cli/control/controlActionControllerSequencing.js +161 -0
  33. package/dist/orchestrator/src/cli/control/controlActionExecution.js +142 -0
  34. package/dist/orchestrator/src/cli/control/controlActionFinalization.js +43 -0
  35. package/dist/orchestrator/src/cli/control/controlActionOutcome.js +60 -0
  36. package/dist/orchestrator/src/cli/control/controlActionPreflight.js +476 -0
  37. package/dist/orchestrator/src/cli/control/controlAuthenticatedRouteHandoff.js +57 -0
  38. package/dist/orchestrator/src/cli/control/controlBootstrapAssembly.js +39 -0
  39. package/dist/orchestrator/src/cli/control/controlBootstrapMetadataPersistence.js +16 -0
  40. package/dist/orchestrator/src/cli/control/controlEventTransport.js +49 -0
  41. package/dist/orchestrator/src/cli/control/controlExpiryLifecycle.js +102 -0
  42. package/dist/orchestrator/src/cli/control/controlHostOwnership.js +480 -0
  43. package/dist/orchestrator/src/cli/control/controlHostSupervision.js +630 -0
  44. package/dist/orchestrator/src/cli/control/controlOversightFacade.js +8 -0
  45. package/dist/orchestrator/src/cli/control/controlOversightReadContract.js +1 -0
  46. package/dist/orchestrator/src/cli/control/controlOversightReadService.js +16 -0
  47. package/dist/orchestrator/src/cli/control/controlOversightUpdateContract.js +1 -0
  48. package/dist/orchestrator/src/cli/control/controlPersistenceFiles.js +6 -0
  49. package/dist/orchestrator/src/cli/control/controlQuestionChildResolution.js +18 -0
  50. package/dist/orchestrator/src/cli/control/controlRequestContext.js +42 -0
  51. package/dist/orchestrator/src/cli/control/controlRequestController.js +9 -0
  52. package/dist/orchestrator/src/cli/control/controlRequestPredispatch.js +17 -0
  53. package/dist/orchestrator/src/cli/control/controlRequestRouteDispatch.js +44 -0
  54. package/dist/orchestrator/src/cli/control/controlRuntime.js +1003 -0
  55. package/dist/orchestrator/src/cli/control/controlServer.js +23 -1456
  56. package/dist/orchestrator/src/cli/control/controlServerAuditAndErrorHelpers.js +115 -0
  57. package/dist/orchestrator/src/cli/control/controlServerAuthenticatedRouteBranch.js +29 -0
  58. package/dist/orchestrator/src/cli/control/controlServerBootstrapLifecycle.js +30 -0
  59. package/dist/orchestrator/src/cli/control/controlServerBootstrapStartSequence.js +21 -0
  60. package/dist/orchestrator/src/cli/control/controlServerOwnedRuntimeLifecycle.js +67 -0
  61. package/dist/orchestrator/src/cli/control/controlServerPublicLifecycle.js +756 -0
  62. package/dist/orchestrator/src/cli/control/controlServerPublicRouteHelpers.js +86 -0
  63. package/dist/orchestrator/src/cli/control/controlServerReadyInstanceLifecycle.js +25 -0
  64. package/dist/orchestrator/src/cli/control/controlServerReadyInstanceStartup.js +18 -0
  65. package/dist/orchestrator/src/cli/control/controlServerRequestBodyHelpers.js +37 -0
  66. package/dist/orchestrator/src/cli/control/controlServerRequestShell.js +40 -0
  67. package/dist/orchestrator/src/cli/control/controlServerRequestShellBinding.js +17 -0
  68. package/dist/orchestrator/src/cli/control/controlServerSeedLoading.js +27 -0
  69. package/dist/orchestrator/src/cli/control/controlServerSeededRuntimeAssembly.js +186 -0
  70. package/dist/orchestrator/src/cli/control/controlServerStartupInputPreparation.js +31 -0
  71. package/dist/orchestrator/src/cli/control/controlServerStartupSequence.js +49 -0
  72. package/dist/orchestrator/src/cli/control/controlState.js +233 -2
  73. package/dist/orchestrator/src/cli/control/controlStatusDashboard.js +1904 -0
  74. package/dist/orchestrator/src/cli/control/controlTelegramBridgeBootstrapLifecycle.js +22 -0
  75. package/dist/orchestrator/src/cli/control/controlTelegramBridgeLifecycle.js +67 -0
  76. package/dist/orchestrator/src/cli/control/controlTelegramBridgeOversightFacadeFactory.js +8 -0
  77. package/dist/orchestrator/src/cli/control/controlTelegramCommandController.js +49 -0
  78. package/dist/orchestrator/src/cli/control/controlTelegramDispatchRead.js +40 -0
  79. package/dist/orchestrator/src/cli/control/controlTelegramPollingController.js +89 -0
  80. package/dist/orchestrator/src/cli/control/controlTelegramProjectionNotificationController.js +29 -0
  81. package/dist/orchestrator/src/cli/control/controlTelegramPushState.js +63 -0
  82. package/dist/orchestrator/src/cli/control/controlTelegramQuestionRead.js +13 -0
  83. package/dist/orchestrator/src/cli/control/controlTelegramReadController.js +216 -0
  84. package/dist/orchestrator/src/cli/control/controlTelegramUpdateHandler.js +63 -0
  85. package/dist/orchestrator/src/cli/control/controlWatcher.js +73 -5
  86. package/dist/orchestrator/src/cli/control/delegationRegisterController.js +35 -0
  87. package/dist/orchestrator/src/cli/control/dynamicToolBridgePolicy.js +139 -0
  88. package/dist/orchestrator/src/cli/control/eventsSseController.js +12 -0
  89. package/dist/orchestrator/src/cli/control/linearBudgetState.js +1789 -0
  90. package/dist/orchestrator/src/cli/control/linearDispatchSource.js +1137 -0
  91. package/dist/orchestrator/src/cli/control/linearGraphqlClient.js +150 -0
  92. package/dist/orchestrator/src/cli/control/linearRateLimit.js +102 -0
  93. package/dist/orchestrator/src/cli/control/linearWebhookController.js +499 -0
  94. package/dist/orchestrator/src/cli/control/liveLinearAdvisoryRuntime.js +70 -0
  95. package/dist/orchestrator/src/cli/control/observabilityApiController.js +173 -0
  96. package/dist/orchestrator/src/cli/control/observabilityReadModel.js +500 -0
  97. package/dist/orchestrator/src/cli/control/observabilitySurface.js +284 -0
  98. package/dist/orchestrator/src/cli/control/observabilityUpdateNotifier.js +22 -0
  99. package/dist/orchestrator/src/cli/control/operatorDashboardPresenter.js +252 -0
  100. package/dist/orchestrator/src/cli/control/providerAgentCapacity.js +70 -0
  101. package/dist/orchestrator/src/cli/control/providerControlHostFreshnessGauge.js +1068 -0
  102. package/dist/orchestrator/src/cli/control/providerIntakeState.js +473 -0
  103. package/dist/orchestrator/src/cli/control/providerIssueHandoff.js +6811 -0
  104. package/dist/orchestrator/src/cli/control/providerIssueObservability.js +1348 -0
  105. package/dist/orchestrator/src/cli/control/providerIssueRetryQueue.js +84 -0
  106. package/dist/orchestrator/src/cli/control/providerLinearRuntimeProof.js +588 -0
  107. package/dist/orchestrator/src/cli/control/providerLinearScreenshotProof.js +473 -0
  108. package/dist/orchestrator/src/cli/control/providerLinearWorkerTruth.js +383 -0
  109. package/dist/orchestrator/src/cli/control/providerLinearWorkflowAudit.js +254 -0
  110. package/dist/orchestrator/src/cli/control/providerLinearWorkflowFacade.js +5573 -0
  111. package/dist/orchestrator/src/cli/control/providerLinearWorkflowStates.js +115 -0
  112. package/dist/orchestrator/src/cli/control/providerMergeCloseout.js +1868 -0
  113. package/dist/orchestrator/src/cli/control/providerOperatorAutopilot.js +1580 -0
  114. package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLifecycle.js +154 -0
  115. package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLocalRolloutExecution.js +1006 -0
  116. package/dist/orchestrator/src/cli/control/providerPollingHealth.js +435 -0
  117. package/dist/orchestrator/src/cli/control/providerTerminalCleanup.js +516 -0
  118. package/dist/orchestrator/src/cli/control/providerWorkerHosts.js +191 -0
  119. package/dist/orchestrator/src/cli/control/providerWorkflowConfigStore.js +515 -0
  120. package/dist/orchestrator/src/cli/control/questionChildResolutionAdapter.js +361 -0
  121. package/dist/orchestrator/src/cli/control/questionQueueController.js +181 -0
  122. package/dist/orchestrator/src/cli/control/questionReadRetryDeduplication.js +9 -0
  123. package/dist/orchestrator/src/cli/control/questionReadSequence.js +10 -0
  124. package/dist/orchestrator/src/cli/control/securityViolationController.js +27 -0
  125. package/dist/orchestrator/src/cli/control/selectedRunProjection.js +1885 -0
  126. package/dist/orchestrator/src/cli/control/telegramOversightApiClient.js +48 -0
  127. package/dist/orchestrator/src/cli/control/telegramOversightBridge.js +180 -0
  128. package/dist/orchestrator/src/cli/control/telegramOversightBridgeProjectionDeliveryQueue.js +25 -0
  129. package/dist/orchestrator/src/cli/control/telegramOversightBridgeRuntimeLifecycle.js +45 -0
  130. package/dist/orchestrator/src/cli/control/telegramOversightBridgeStateStore.js +77 -0
  131. package/dist/orchestrator/src/cli/control/telegramOversightControlActionApiClient.js +45 -0
  132. package/dist/orchestrator/src/cli/control/trackerDispatchPilot.js +439 -0
  133. package/dist/orchestrator/src/cli/control/uiDataController.js +34 -0
  134. package/dist/orchestrator/src/cli/control/uiSessionController.js +100 -0
  135. package/dist/orchestrator/src/cli/controlHostCliShell.js +860 -0
  136. package/dist/orchestrator/src/cli/controlHostFreshnessGaugeCliShell.js +129 -0
  137. package/dist/orchestrator/src/cli/controlHostSupervisionCliShell.js +2127 -0
  138. package/dist/orchestrator/src/cli/delegationCliShell.js +62 -0
  139. package/dist/orchestrator/src/cli/delegationServer.js +567 -678
  140. package/dist/orchestrator/src/cli/delegationServerCliShell.js +52 -0
  141. package/dist/orchestrator/src/cli/delegationServerQuestionFlowShell.js +228 -0
  142. package/dist/orchestrator/src/cli/delegationServerToolDispatchShell.js +411 -0
  143. package/dist/orchestrator/src/cli/delegationServerTransport.js +274 -0
  144. package/dist/orchestrator/src/cli/delegationSetup.js +51 -171
  145. package/dist/orchestrator/src/cli/devtoolsCliShell.js +34 -0
  146. package/dist/orchestrator/src/cli/doctor.js +678 -164
  147. package/dist/orchestrator/src/cli/doctorCliRequestShell.js +72 -0
  148. package/dist/orchestrator/src/cli/doctorCliShell.js +138 -0
  149. package/dist/orchestrator/src/cli/doctorUsage.js +119 -15
  150. package/dist/orchestrator/src/cli/exec/experience.js +16 -2
  151. package/dist/orchestrator/src/cli/exec/summary.js +3 -0
  152. package/dist/orchestrator/src/cli/execCliShell.js +51 -0
  153. package/dist/orchestrator/src/cli/flowCliRequestShell.js +44 -0
  154. package/dist/orchestrator/src/cli/flowCliShell.js +239 -0
  155. package/dist/orchestrator/src/cli/frontendTestCliRequestShell.js +80 -0
  156. package/dist/orchestrator/src/cli/frontendTestCliShell.js +41 -0
  157. package/dist/orchestrator/src/cli/init.js +95 -1
  158. package/dist/orchestrator/src/cli/initCliShell.js +50 -0
  159. package/dist/orchestrator/src/cli/linearCliShell.js +1200 -0
  160. package/dist/orchestrator/src/cli/mcpEnableCliShell.js +132 -0
  161. package/dist/orchestrator/src/cli/metrics/metricsAggregator.js +3 -2
  162. package/dist/orchestrator/src/cli/metrics/metricsRecorder.js +56 -0
  163. package/dist/orchestrator/src/cli/orchestrator.js +66 -1376
  164. package/dist/orchestrator/src/cli/planCliShell.js +19 -0
  165. package/dist/orchestrator/src/cli/prCliShell.js +41 -0
  166. package/dist/orchestrator/src/cli/providerLinearChildLanePhaseContract.js +204 -0
  167. package/dist/orchestrator/src/cli/providerLinearChildLaneRunner.js +1835 -0
  168. package/dist/orchestrator/src/cli/providerLinearChildLaneShell.js +2420 -0
  169. package/dist/orchestrator/src/cli/providerLinearChildStreamShell.js +385 -0
  170. package/dist/orchestrator/src/cli/providerLinearWorkerRunner.js +6834 -0
  171. package/dist/orchestrator/src/cli/resumeCliShell.js +14 -0
  172. package/dist/orchestrator/src/cli/reviewCliLaunchShell.js +72 -0
  173. package/dist/orchestrator/src/cli/rlm/alignment.js +3 -3
  174. package/dist/orchestrator/src/cli/rlm/context.js +94 -7
  175. package/dist/orchestrator/src/cli/rlm/rlmCodexRuntimeShell.js +546 -0
  176. package/dist/orchestrator/src/cli/rlm/symbolic.js +4 -2
  177. package/dist/orchestrator/src/cli/rlmCliRequestShell.js +42 -0
  178. package/dist/orchestrator/src/cli/rlmCompletionCliShell.js +46 -0
  179. package/dist/orchestrator/src/cli/rlmLaunchCliShell.js +51 -0
  180. package/dist/orchestrator/src/cli/rlmRunner.js +83 -523
  181. package/dist/orchestrator/src/cli/run/blockMemory.js +500 -0
  182. package/dist/orchestrator/src/cli/run/manifest.js +410 -73
  183. package/dist/orchestrator/src/cli/run/manifestPersister.js +45 -14
  184. package/dist/orchestrator/src/cli/run/runMemoryController.js +216 -0
  185. package/dist/orchestrator/src/cli/run/source0.js +690 -0
  186. package/dist/orchestrator/src/cli/run/workspacePath.js +101 -0
  187. package/dist/orchestrator/src/cli/runtime/mode.js +2 -1
  188. package/dist/orchestrator/src/cli/runtime/provider.js +39 -2
  189. package/dist/orchestrator/src/cli/selfCheckCliShell.js +12 -0
  190. package/dist/orchestrator/src/cli/services/commandRunner.js +698 -18
  191. package/dist/orchestrator/src/cli/services/execRuntime.js +66 -1
  192. package/dist/orchestrator/src/cli/services/orchestratorAutoScoutEvidenceRecorder.js +71 -0
  193. package/dist/orchestrator/src/cli/services/orchestratorCloudBranchResolution.js +8 -0
  194. package/dist/orchestrator/src/cli/services/orchestratorCloudEnvironmentResolution.js +22 -0
  195. package/dist/orchestrator/src/cli/services/orchestratorCloudExecutionLifecycleShell.js +39 -0
  196. package/dist/orchestrator/src/cli/services/orchestratorCloudPromptBuilder.js +37 -0
  197. package/dist/orchestrator/src/cli/services/orchestratorCloudRouteFallbackContract.js +45 -0
  198. package/dist/orchestrator/src/cli/services/orchestratorCloudRouteShell.js +36 -0
  199. package/dist/orchestrator/src/cli/services/orchestratorCloudTargetExecutor.js +277 -0
  200. package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycle.js +98 -0
  201. package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycleShell.js +54 -0
  202. package/dist/orchestrator/src/cli/services/orchestratorExecutionLifecycle.js +112 -0
  203. package/dist/orchestrator/src/cli/services/orchestratorExecutionModePolicy.js +27 -0
  204. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteAdapterShell.js +59 -0
  205. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteDecisionShell.js +57 -0
  206. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteState.js +21 -0
  207. package/dist/orchestrator/src/cli/services/orchestratorExecutionRouter.js +2 -0
  208. package/dist/orchestrator/src/cli/services/orchestratorLocalPipelineExecutor.js +149 -0
  209. package/dist/orchestrator/src/cli/services/orchestratorLocalRouteShell.js +63 -0
  210. package/dist/orchestrator/src/cli/services/orchestratorPlanShell.js +54 -0
  211. package/dist/orchestrator/src/cli/services/orchestratorPlanTargetTracker.js +16 -0
  212. package/dist/orchestrator/src/cli/services/orchestratorResumePreparationShell.js +84 -0
  213. package/dist/orchestrator/src/cli/services/orchestratorResumeTokenValidation.js +15 -0
  214. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleCompletion.js +31 -0
  215. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleExecutionRegistration.js +37 -0
  216. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleOrchestrationShell.js +83 -0
  217. package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleTaskManagerShell.js +37 -0
  218. package/dist/orchestrator/src/cli/services/orchestratorRuntimeManifestMutation.js +20 -0
  219. package/dist/orchestrator/src/cli/services/orchestratorStartPreparationShell.js +56 -0
  220. package/dist/orchestrator/src/cli/services/orchestratorStatusShell.js +70 -0
  221. package/dist/orchestrator/src/cli/services/pipelineResolver.js +7 -3
  222. package/dist/orchestrator/src/cli/services/plannerMemory.js +119 -0
  223. package/dist/orchestrator/src/cli/services/runPreparation.js +7 -3
  224. package/dist/orchestrator/src/cli/services/runSummaryWriter.js +9 -0
  225. package/dist/orchestrator/src/cli/setupBootstrapShell.js +114 -0
  226. package/dist/orchestrator/src/cli/setupCliShell.js +51 -0
  227. package/dist/orchestrator/src/cli/skillsCliShell.js +56 -0
  228. package/dist/orchestrator/src/cli/startCliRequestShell.js +53 -0
  229. package/dist/orchestrator/src/cli/startCliShell.js +68 -0
  230. package/dist/orchestrator/src/cli/statusCliShell.js +22 -0
  231. package/dist/orchestrator/src/cli/utils/authProvenanceFingerprint.js +27 -0
  232. package/dist/orchestrator/src/cli/utils/cloudPreflight.js +285 -7
  233. package/dist/orchestrator/src/cli/utils/codexFeatures.js +60 -0
  234. package/dist/orchestrator/src/cli/utils/delegationConfigParser.js +250 -0
  235. package/dist/orchestrator/src/cli/utils/delegationMcpHealth.js +1382 -0
  236. package/dist/orchestrator/src/cli/utils/devtools.js +2 -54
  237. package/dist/orchestrator/src/cli/utils/mcpServerEntry.js +53 -0
  238. package/dist/orchestrator/src/cli/utils/packageProgramResolver.js +151 -0
  239. package/dist/orchestrator/src/cli/utils/providerOverrideEnv.js +71 -0
  240. package/dist/orchestrator/src/cli/utils/trailingJsonObject.js +59 -0
  241. package/dist/orchestrator/src/learning/crystalizer.js +2 -2
  242. package/dist/orchestrator/src/manager.js +74 -4
  243. package/dist/orchestrator/src/persistence/ExperienceStore.js +233 -49
  244. package/dist/orchestrator/src/persistence/TaskStateStore.js +6 -6
  245. package/dist/orchestrator/src/persistence/lockFile.js +70 -4
  246. package/dist/orchestrator/src/persistence/sanitizeIdentifier.js +39 -0
  247. package/dist/orchestrator/src/sync/createCloudSyncWorker.js +3 -2
  248. package/dist/orchestrator/src/utils/atomicWrite.js +17 -2
  249. package/dist/packages/orchestrator/src/exec/unified-exec.js +99 -6
  250. package/dist/packages/orchestrator/src/instructions/promptPacks.js +150 -19
  251. package/dist/packages/sdk-node/src/orchestrator.js +137 -13
  252. package/dist/packages/shared/config/designConfig.js +8 -1
  253. package/dist/packages/shared/streams/stdio.js +1 -1
  254. package/dist/scripts/design/pipeline/permit.js +15 -0
  255. package/dist/scripts/lib/docs-catalog.js +399 -0
  256. package/dist/scripts/lib/docs-helpers.js +87 -5
  257. package/dist/scripts/lib/pr-watch-merge.js +1088 -80
  258. package/dist/scripts/lib/provider-run-contract.js +26 -0
  259. package/dist/scripts/lib/review-command-intent-classification.js +532 -0
  260. package/dist/scripts/lib/review-command-probe-classification.js +385 -0
  261. package/dist/scripts/lib/review-execution-boundary-preflight.js +279 -0
  262. package/dist/scripts/lib/review-execution-runtime.js +753 -0
  263. package/dist/scripts/lib/review-execution-state.js +1144 -0
  264. package/dist/scripts/lib/review-execution-telemetry.js +215 -0
  265. package/dist/scripts/lib/review-inspection-target-parsing.js +78 -0
  266. package/dist/scripts/lib/review-launch-attempt.js +601 -0
  267. package/dist/scripts/lib/review-meta-surface-boundary-analysis.js +300 -0
  268. package/dist/scripts/lib/review-meta-surface-normalization.js +746 -0
  269. package/dist/scripts/lib/review-non-interactive-handoff.js +61 -0
  270. package/dist/scripts/lib/review-prompt-context.js +376 -0
  271. package/dist/scripts/lib/review-scope-advisory.js +286 -0
  272. package/dist/scripts/lib/review-scope-paths.js +123 -0
  273. package/dist/scripts/lib/review-shell-command-parser.js +389 -0
  274. package/dist/scripts/lib/review-shell-env-interpreter.js +340 -0
  275. package/dist/scripts/lib/run-manifests.js +192 -36
  276. package/dist/scripts/lib/spark-policy-classifier.js +593 -0
  277. package/dist/scripts/run-review.js +507 -1777
  278. package/docs/README.md +43 -20
  279. package/docs/book/README.md +19 -0
  280. package/docs/book/codex-cli-0124-adoption.md +68 -0
  281. package/docs/book/local-hook-impact.md +73 -0
  282. package/docs/book/operations.md +60 -0
  283. package/docs/book/public-posture.md +34 -0
  284. package/docs/book/setup.md +91 -0
  285. package/docs/book/skills.md +11 -0
  286. package/docs/guides/codex-version-policy.md +104 -0
  287. package/docs/public/downstream-setup.md +113 -0
  288. package/docs/public/provider-onboarding.md +173 -0
  289. package/package.json +23 -10
  290. package/plugins/codex-orchestrator/.codex-plugin/plugin.json +30 -0
  291. package/plugins/codex-orchestrator/.mcp.json +13 -0
  292. package/plugins/codex-orchestrator/launcher.mjs +361 -0
  293. package/schemas/manifest.json +411 -0
  294. package/skills/README.md +26 -0
  295. package/skills/collab-subagents-first/SKILL.md +1 -1
  296. package/skills/delegation-usage/DELEGATION_GUIDE.md +30 -12
  297. package/skills/delegation-usage/SKILL.md +25 -14
  298. package/skills/land/SKILL.md +77 -0
  299. package/skills/linear/SKILL.md +255 -0
  300. package/skills/release/SKILL.md +47 -3
  301. package/skills/standalone-review/SKILL.md +6 -1
  302. package/templates/README.md +4 -2
  303. package/templates/codex/.codex/agents/awaiter-high.toml +2 -2
  304. package/templates/codex/.codex/agents/worker-complex.toml +1 -1
  305. package/templates/codex/.codex/config.toml +3 -4
  306. package/templates/codex/.codex/providers/README.md +13 -0
  307. package/templates/codex/.codex/providers/control.example.json +18 -0
  308. package/templates/codex/.codex/providers/provider.env.example +15 -0
  309. package/templates/codex/AGENTS.md +15 -8
  310. package/templates/codex/mcp-client.json +5 -1
  311. package/docs/assets/setup.gif +0 -0
@@ -0,0 +1,284 @@
1
+ import { isoTimestamp } from '../utils/time.js';
2
+ import { serializeProviderIntakeSummary } from './observabilityReadModel.js';
3
+ import { findCompatibilityProjectionIssueRecord } from './compatibilityIssuePresenter.js';
4
+ import { buildCompatibilityIssueRecordLookups, resolveRetryIssueRecord, resolveRunningIssueRecord } from './operatorDashboardPresenter.js';
5
+ const READ_ONLY_COMPAT_ACTION = 'refresh';
6
+ const COMPATIBILITY_MUTATING_ACTIONS = new Set(['pause', 'resume', 'cancel', 'fail', 'rerun']);
7
+ const JSON_HEADERS = { 'Content-Type': 'application/json' };
8
+ export function buildCompatibilityErrorResponse(input) {
9
+ return {
10
+ status: input.status,
11
+ headers: JSON_HEADERS,
12
+ body: {
13
+ error: {
14
+ code: input.code,
15
+ message: input.message,
16
+ ...(input.details ? { details: input.details } : {})
17
+ },
18
+ ...(input.traceability ? { traceability: input.traceability } : {})
19
+ }
20
+ };
21
+ }
22
+ export function buildCompatibilityMethodNotAllowedResponse(context, allowedMethod, issueIdentifier) {
23
+ return buildCompatibilityErrorResponse({
24
+ status: 405,
25
+ code: 'method_not_allowed',
26
+ message: 'Method not allowed',
27
+ details: {
28
+ surface: 'api_v1',
29
+ allowed_method: allowedMethod,
30
+ ...(issueIdentifier ? { issue_identifier: issueIdentifier } : {})
31
+ },
32
+ traceability: buildCompatibilityTraceability(context, {
33
+ decision: 'rejected',
34
+ reason: 'method_not_allowed',
35
+ ...(issueIdentifier ? { issueIdentifier } : {})
36
+ })
37
+ });
38
+ }
39
+ export function buildCompatibilityIssueNotFoundResponse(context, issueIdentifier) {
40
+ return buildCompatibilityErrorResponse({
41
+ status: 404,
42
+ code: 'issue_not_found',
43
+ message: 'Issue not found',
44
+ details: {
45
+ surface: 'api_v1',
46
+ issue_identifier: issueIdentifier
47
+ },
48
+ traceability: buildCompatibilityTraceability(context, {
49
+ decision: 'rejected',
50
+ reason: 'issue_not_found',
51
+ issueIdentifier
52
+ })
53
+ });
54
+ }
55
+ export function buildCompatibilityNotFoundResponse(context) {
56
+ return buildCompatibilityErrorResponse({
57
+ status: 404,
58
+ code: 'not_found',
59
+ message: 'Route not found',
60
+ details: {
61
+ surface: 'api_v1'
62
+ },
63
+ traceability: buildCompatibilityTraceability(context, {
64
+ decision: 'rejected',
65
+ reason: 'route_not_found'
66
+ })
67
+ });
68
+ }
69
+ export function buildCompatibilityRefreshRejectedResponse(context, rejection) {
70
+ return buildCompatibilityErrorResponse({
71
+ status: resolveCompatibilityRefreshRejectionStatus(rejection.reason),
72
+ code: 'read_only_action_rejected',
73
+ message: 'Compatibility surface is read-only; only refresh acknowledgements are supported.',
74
+ details: {
75
+ surface: 'api_v1',
76
+ mode: 'read_only',
77
+ reason: rejection.reason,
78
+ allowed_actions: ['refresh'],
79
+ allowed_tools: [],
80
+ requested_action: rejection.requestAction,
81
+ requested_tool: rejection.requestTool
82
+ },
83
+ traceability: buildCompatibilityTraceability(context, {
84
+ decision: 'rejected',
85
+ reason: rejection.reason,
86
+ requestAction: rejection.requestAction,
87
+ requestTool: rejection.requestTool
88
+ })
89
+ });
90
+ }
91
+ // `/api/v1/dispatch` is a CO-specific extension over the Symphony-aligned
92
+ // compatibility surface, so keep the dispatch payload seam explicit.
93
+ export async function readDispatchExtension(context) {
94
+ const { issueIdentifier, evaluation } = await context.readDispatchEvaluation();
95
+ if (evaluation.failure) {
96
+ return {
97
+ kind: 'fail_closed',
98
+ issueIdentifier,
99
+ evaluation,
100
+ failure: evaluation.failure,
101
+ details: {
102
+ surface: 'api_v1',
103
+ mode: 'read_only',
104
+ advisory_only: true,
105
+ reason: evaluation.failure.reason,
106
+ dispatch_pilot: evaluation.summary
107
+ }
108
+ };
109
+ }
110
+ return {
111
+ kind: 'ok',
112
+ issueIdentifier,
113
+ evaluation,
114
+ payload: {
115
+ generated_at: isoTimestamp(),
116
+ mode: 'read_only',
117
+ advisory_only: true,
118
+ dispatch_pilot: evaluation.summary,
119
+ recommendation: evaluation.recommendation
120
+ }
121
+ };
122
+ }
123
+ export async function readCompatibilityRefresh(context, body = {}) {
124
+ const rejection = resolveCompatibilityActionEnvelopeRejection(body);
125
+ if (rejection) {
126
+ return {
127
+ kind: 'rejected',
128
+ reason: rejection.reason,
129
+ requestAction: rejection.requestAction,
130
+ requestTool: rejection.requestTool
131
+ };
132
+ }
133
+ const refreshAcknowledgement = normalizeRefreshAcknowledgement(await context.requestRefresh());
134
+ const requestBody = isRecordLike(body) ? body : {};
135
+ const requestedAction = readStringValue(requestBody, 'action');
136
+ return {
137
+ kind: 'accepted',
138
+ payload: {
139
+ ...refreshAcknowledgement,
140
+ traceability: buildCompatibilityTraceability(context, {
141
+ decision: 'acknowledged',
142
+ reason: 'refresh_requested',
143
+ requestAction: requestedAction ? requestedAction.toLowerCase() : READ_ONLY_COMPAT_ACTION
144
+ })
145
+ }
146
+ };
147
+ }
148
+ function normalizeRefreshAcknowledgement(value) {
149
+ return {
150
+ queued: value?.queued ?? true,
151
+ coalesced: value?.coalesced ?? false,
152
+ requested_at: value?.requested_at ?? isoTimestamp(),
153
+ operations: value?.operations ?? ['poll', 'reconcile'],
154
+ stuck: value?.stuck ?? false,
155
+ restart_required: value?.restart_required ?? false,
156
+ reason: value?.reason ?? null
157
+ };
158
+ }
159
+ export function buildCompatibilityTraceability(context, input) {
160
+ const snapshot = context.controlStore.snapshot();
161
+ return {
162
+ task_id: resolveTaskIdFromManifestPath(context.paths.manifestPath),
163
+ run_id: snapshot.run_id,
164
+ manifest_path: context.paths.manifestPath,
165
+ surface: 'api_v1',
166
+ issue_identifier: input.issueIdentifier ?? null,
167
+ requested_action: input.requestAction ?? null,
168
+ requested_tool: input.requestTool ?? null,
169
+ decision: input.decision,
170
+ reason: input.reason,
171
+ timestamp: isoTimestamp()
172
+ };
173
+ }
174
+ export async function readCompatibilityState(context) {
175
+ const projection = await context.readCompatibilityProjection();
176
+ const generatedAt = isoTimestamp();
177
+ const issueRecordLookups = buildCompatibilityIssueRecordLookups(projection.issues);
178
+ return {
179
+ generated_at: generatedAt,
180
+ counts: { running: projection.running.length, retrying: projection.retrying.length },
181
+ running_ids: projection.running.map((entry) => resolveRunningIssueRecord(entry, issueRecordLookups)?.issueIdentifier ?? entry.issue_identifier),
182
+ retrying_ids: projection.retrying.map((entry) => resolveRetryIssueRecord(entry, issueRecordLookups)?.issueIdentifier ?? entry.issue_identifier),
183
+ running: projection.running,
184
+ retrying: projection.retrying,
185
+ codex_totals: projection.codexTotals,
186
+ rate_limits: projection.rateLimits,
187
+ selected: projection.selected,
188
+ ...(projection.providerIntake
189
+ ? { provider_intake: serializeProviderIntakeSummary(projection.providerIntake) }
190
+ : {}),
191
+ ...(projection.providerWorkflow ? { provider_workflow: projection.providerWorkflow } : {}),
192
+ ...(projection.polling ? { polling: projection.polling } : {}),
193
+ ...(projection.dispatchPilot ? { dispatch_pilot: projection.dispatchPilot } : {}),
194
+ ...(projection.tracked ? { tracked: projection.tracked } : {})
195
+ };
196
+ }
197
+ export async function readCompatibilityIssue(context, issueIdentifier) {
198
+ const projection = await context.readCompatibilityProjection();
199
+ const issue = findCompatibilityProjectionIssueRecord(projection, issueIdentifier);
200
+ if (!issue) {
201
+ return { kind: 'issue_not_found' };
202
+ }
203
+ return {
204
+ kind: 'ok',
205
+ payload: issue.payload
206
+ };
207
+ }
208
+ function resolveCompatibilityActionEnvelopeRejection(body) {
209
+ if (!isRecordLike(body)) {
210
+ return {
211
+ reason: 'malformed_action_request',
212
+ requestAction: null,
213
+ requestTool: null
214
+ };
215
+ }
216
+ const hasAction = Object.prototype.hasOwnProperty.call(body, 'action');
217
+ const hasTool = Object.prototype.hasOwnProperty.call(body, 'tool');
218
+ if (!hasAction && !hasTool) {
219
+ return null;
220
+ }
221
+ const actionValue = readStringValue(body, 'action');
222
+ const normalizedAction = actionValue ? actionValue.toLowerCase() : null;
223
+ const toolValue = readStringValue(body, 'tool');
224
+ const normalizedTool = toolValue ? toolValue.toLowerCase() : null;
225
+ if (hasAction && !normalizedAction) {
226
+ return {
227
+ reason: 'malformed_action_request',
228
+ requestAction: null,
229
+ requestTool: normalizedTool
230
+ };
231
+ }
232
+ if (normalizedAction && COMPATIBILITY_MUTATING_ACTIONS.has(normalizedAction)) {
233
+ return {
234
+ reason: 'forbidden_mutating_action',
235
+ requestAction: normalizedAction,
236
+ requestTool: normalizedTool
237
+ };
238
+ }
239
+ if (normalizedAction && normalizedAction !== READ_ONLY_COMPAT_ACTION) {
240
+ return {
241
+ reason: 'unsupported_action',
242
+ requestAction: normalizedAction,
243
+ requestTool: normalizedTool
244
+ };
245
+ }
246
+ if (hasTool) {
247
+ return {
248
+ reason: 'unsupported_tool',
249
+ requestAction: normalizedAction,
250
+ requestTool: normalizedTool
251
+ };
252
+ }
253
+ return null;
254
+ }
255
+ function resolveCompatibilityRefreshRejectionStatus(reason) {
256
+ switch (reason) {
257
+ case 'forbidden_mutating_action':
258
+ case 'unsupported_tool':
259
+ return 403;
260
+ case 'malformed_action_request':
261
+ case 'unsupported_action':
262
+ return 400;
263
+ }
264
+ }
265
+ function isRecordLike(value) {
266
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
267
+ }
268
+ function resolveTaskIdFromManifestPath(manifestPath) {
269
+ const normalizedPath = manifestPath.replace(/\\/g, '/');
270
+ const match = normalizedPath.match(/\.runs\/([^/]+)\/cli\//);
271
+ return match?.[1] ?? null;
272
+ }
273
+ function readStringValue(record, ...keys) {
274
+ for (const key of keys) {
275
+ const value = record[key];
276
+ if (typeof value === 'string') {
277
+ const trimmed = value.trim();
278
+ if (trimmed.length > 0) {
279
+ return trimmed;
280
+ }
281
+ }
282
+ }
283
+ return undefined;
284
+ }
@@ -0,0 +1,22 @@
1
+ import { logger } from '../../logger.js';
2
+ export function createObservabilityUpdateNotifier() {
3
+ const listeners = new Set();
4
+ return {
5
+ publish(input) {
6
+ const snapshot = Array.from(listeners);
7
+ for (const listener of snapshot) {
8
+ Promise.resolve()
9
+ .then(() => listener(input))
10
+ .catch((error) => {
11
+ logger.warn(`Failed to handle observability update: ${error?.message ?? String(error)}`);
12
+ });
13
+ }
14
+ },
15
+ subscribe(listener) {
16
+ listeners.add(listener);
17
+ return () => {
18
+ listeners.delete(listener);
19
+ };
20
+ }
21
+ };
22
+ }
@@ -0,0 +1,252 @@
1
+ import { hostname } from 'node:os';
2
+ import { resolveProviderWorkerHost } from './observabilityReadModel.js';
3
+ import { isoTimestamp } from '../utils/time.js';
4
+ const LOCAL_HOSTNAME = hostname();
5
+ export function buildUiDataset(input) {
6
+ const generatedAt = input.generatedAt ?? isoTimestamp();
7
+ const selectedIssueIdentifier = input.projection.selected?.issue_identifier ?? null;
8
+ const issueRecords = input.projection.issues;
9
+ const issuePayloads = issueRecords.map((record) => record.payload);
10
+ const issueRecordLookups = buildCompatibilityIssueRecordLookups(issueRecords);
11
+ return {
12
+ generated_at: generatedAt,
13
+ mode: 'operator_dashboard',
14
+ read_only: true,
15
+ host: LOCAL_HOSTNAME,
16
+ counts: {
17
+ running: input.projection.running.length,
18
+ retrying: input.projection.retrying.length,
19
+ issues: issuePayloads.length,
20
+ max_allowed: input.projection.maxConcurrentAgents ?? null
21
+ },
22
+ totals: input.projection.codexTotals,
23
+ rate_limits: input.projection.rateLimits,
24
+ polling: input.projection.polling ?? null,
25
+ selected_issue_identifier: selectedIssueIdentifier,
26
+ selected: input.projection.selected,
27
+ running: input.projection.running.map((entry) => buildRunningSessionPayload(entry, resolveRunningIssueRecord(entry, issueRecordLookups))),
28
+ retrying: input.projection.retrying.map((entry) => buildRetryQueuePayload(entry, resolveRetryIssueRecord(entry, issueRecordLookups))),
29
+ issues: issuePayloads.map((issue) => buildIssuePayload(issue, issue.issue_identifier === selectedIssueIdentifier)),
30
+ ...(input.projection.providerWorkflow ? { provider_workflow: input.projection.providerWorkflow } : {}),
31
+ ...(input.projection.providerIntake ? { provider_intake: input.projection.providerIntake } : {}),
32
+ ...(input.projection.dispatchPilot ? { dispatch_pilot: input.projection.dispatchPilot } : {}),
33
+ ...(input.projection.tracked ? { tracked: input.projection.tracked } : {})
34
+ };
35
+ }
36
+ export function buildCompatibilityIssueRecordLookups(issueRecords) {
37
+ const records = issueRecords ?? [];
38
+ return {
39
+ byId: new Map(records.flatMap((issue) => issue.payload.issue_id === null ? [] : [[issue.payload.issue_id, issue]])),
40
+ byRunId: new Map(records.flatMap((issue) => issue.payload.run_id === null ? [] : [[issue.payload.run_id, issue]])),
41
+ byIdentifier: new Map(records.map((issue) => [issue.payload.issue_identifier, issue]))
42
+ };
43
+ }
44
+ export async function readUiDataset(context) {
45
+ const projection = await context.readCompatibilityProjection();
46
+ return buildUiDataset({
47
+ projection
48
+ });
49
+ }
50
+ function buildIssuePayload(issue, isSelected) {
51
+ const proof = issue.provider_linear_worker_proof ?? null;
52
+ const trackedLinear = issue.tracked && 'linear' in issue.tracked ? issue.tracked.linear : null;
53
+ const running = issue.running ?? null;
54
+ const stageStartedAt = running?.started_at ??
55
+ issue.retry?.started_at ??
56
+ issue.provider_debug_snapshot?.claim?.launch_started_at ??
57
+ null;
58
+ const workerHost = issue.worker_host ??
59
+ resolveProviderWorkerHost({
60
+ providerLinearWorkerProof: proof,
61
+ providerDebugSnapshot: issue.provider_debug_snapshot ?? null,
62
+ stageStartedAt
63
+ });
64
+ return {
65
+ issue_identifier: issue.issue_identifier,
66
+ issue_id: issue.issue_id,
67
+ task_id: issue.task_id,
68
+ run_id: issue.run_id,
69
+ status: issue.status,
70
+ raw_status: issue.raw_status,
71
+ display_status: issue.display_status,
72
+ status_reason: issue.status_reason,
73
+ title: trackedLinear?.title ?? null,
74
+ url: trackedLinear?.url ?? null,
75
+ workspace: {
76
+ path: issue.workspace.path ?? proof?.workspace_path ?? null,
77
+ host: LOCAL_HOSTNAME
78
+ },
79
+ ...(workerHost !== null ? { worker_host: workerHost } : {}),
80
+ session: {
81
+ session_id: proof?.latest_session_id ?? running?.session_id ?? issue.retry?.session_id ?? null,
82
+ thread_id: proof?.thread_id ?? null,
83
+ turn_count: proof?.turn_count ?? running?.turn_count ?? null
84
+ },
85
+ owner: {
86
+ phase: proof?.owner_phase ?? null,
87
+ status: proof?.owner_status ?? null
88
+ },
89
+ tokens: proof?.tokens ?? running?.tokens ?? null,
90
+ rate_limits: proof?.rate_limits ?? null,
91
+ summary: issue.summary,
92
+ last_error: issue.last_error,
93
+ latest_event: issue.latest_event,
94
+ recent_agent_activity: normalizeRecentAgentActivity(issue, proof),
95
+ linear_activity: normalizeLinearActivity(trackedLinear?.recent_activity),
96
+ running: issue.running,
97
+ retry: issue.retry,
98
+ attempts: issue.attempts,
99
+ tracked: issue.tracked,
100
+ provider_linear_worker_proof: proof,
101
+ provider_debug_snapshot: issue.provider_debug_snapshot ?? null,
102
+ is_selected: isSelected
103
+ };
104
+ }
105
+ function buildRunningSessionPayload(entry, issueRecord) {
106
+ const issue = issueRecord?.payload ?? null;
107
+ const proof = issue?.provider_linear_worker_proof ?? null;
108
+ const workerHost = entry.worker_host ??
109
+ issue?.worker_host ??
110
+ resolveProviderWorkerHost({
111
+ providerLinearWorkerProof: proof,
112
+ providerDebugSnapshot: issue?.provider_debug_snapshot ?? null,
113
+ stageStartedAt: entry.started_at ??
114
+ issue?.running?.started_at ??
115
+ issue?.provider_debug_snapshot?.claim?.launch_started_at ??
116
+ null
117
+ });
118
+ return {
119
+ issue_identifier: entry.issue_identifier,
120
+ issue_id: entry.issue_id,
121
+ id: issueRecord?.issueIdentifier ?? entry.issue_identifier,
122
+ bucket: 'running',
123
+ state: entry.state,
124
+ reason: entry.status_reason,
125
+ aliases: resolveCompatibilityAliases({
126
+ issueRecord,
127
+ issueIdentifier: entry.issue_identifier,
128
+ issueId: entry.issue_id,
129
+ taskId: issue?.task_id ?? null,
130
+ runId: issue?.run_id ?? null
131
+ }),
132
+ task_id: issue?.task_id ?? null,
133
+ run_id: issue?.run_id ?? null,
134
+ summary: issue?.summary ?? null,
135
+ display_state: entry.display_state,
136
+ status_reason: entry.status_reason,
137
+ pid: proof === null ? (entry.pid ?? null) : (proof.pid ?? null),
138
+ session_id: proof?.latest_session_id ?? entry.session_id,
139
+ thread_id: proof?.thread_id ?? null,
140
+ turn_count: proof?.turn_count ?? entry.turn_count,
141
+ workspace_path: issue?.workspace.path ?? proof?.workspace_path ?? null,
142
+ host: LOCAL_HOSTNAME,
143
+ ...(workerHost !== null ? { worker_host: workerHost } : {}),
144
+ last_event: entry.last_event,
145
+ last_message: entry.last_message,
146
+ display_event: entry.display_event ?? null,
147
+ started_at: entry.started_at,
148
+ last_event_at: entry.last_event_at,
149
+ tokens: proof?.tokens ?? entry.tokens
150
+ };
151
+ }
152
+ function buildRetryQueuePayload(entry, issueRecord) {
153
+ const issue = issueRecord?.payload ?? null;
154
+ const proof = issue?.provider_linear_worker_proof ?? null;
155
+ const workerHost = entry.worker_host ??
156
+ issue?.worker_host ??
157
+ resolveProviderWorkerHost({
158
+ providerLinearWorkerProof: proof,
159
+ providerDebugSnapshot: issue?.provider_debug_snapshot ?? null,
160
+ stageStartedAt: entry.started_at ??
161
+ issue?.retry?.started_at ??
162
+ issue?.provider_debug_snapshot?.claim?.launch_started_at ??
163
+ null
164
+ });
165
+ return {
166
+ issue_identifier: entry.issue_identifier,
167
+ issue_id: entry.issue_id,
168
+ id: issueRecord?.issueIdentifier ?? entry.issue_identifier,
169
+ bucket: 'retrying',
170
+ state: entry.state,
171
+ reason: entry.status_reason,
172
+ aliases: resolveCompatibilityAliases({
173
+ issueRecord,
174
+ issueIdentifier: entry.issue_identifier,
175
+ issueId: entry.issue_id,
176
+ taskId: entry.task_id ?? issue?.task_id ?? null,
177
+ runId: entry.run_id ?? issue?.run_id ?? null
178
+ }),
179
+ task_id: entry.task_id ?? issue?.task_id ?? null,
180
+ run_id: entry.run_id ?? issue?.run_id ?? null,
181
+ summary: issue?.summary ?? null,
182
+ display_state: entry.display_state,
183
+ status_reason: entry.status_reason,
184
+ session_id: entry.session_id,
185
+ thread_id: entry.thread_id ?? null,
186
+ turn_count: entry.turn_count ?? null,
187
+ workspace_path: entry.workspace_path ?? null,
188
+ host: LOCAL_HOSTNAME,
189
+ ...(workerHost !== null ? { worker_host: workerHost } : {}),
190
+ attempt: entry.attempt,
191
+ due_at: entry.due_at,
192
+ error: entry.error,
193
+ last_event: entry.last_event,
194
+ last_message: entry.last_message,
195
+ started_at: entry.started_at,
196
+ last_event_at: entry.last_event_at
197
+ };
198
+ }
199
+ export function resolveRunningIssueRecord(entry, issueRecordLookups) {
200
+ if (entry.issue_id !== null) {
201
+ const issueById = issueRecordLookups.byId.get(entry.issue_id);
202
+ if (issueById) {
203
+ return issueById;
204
+ }
205
+ }
206
+ return issueRecordLookups.byIdentifier.get(entry.issue_identifier) ?? null;
207
+ }
208
+ export function resolveRetryIssueRecord(entry, issueRecordLookups) {
209
+ if (entry.run_id) {
210
+ const issueByRunId = issueRecordLookups.byRunId.get(entry.run_id);
211
+ if (issueByRunId) {
212
+ return issueByRunId;
213
+ }
214
+ }
215
+ if (entry.issue_id !== null) {
216
+ const issueById = issueRecordLookups.byId.get(entry.issue_id);
217
+ if (issueById) {
218
+ return issueById;
219
+ }
220
+ }
221
+ return issueRecordLookups.byIdentifier.get(entry.issue_identifier) ?? null;
222
+ }
223
+ function resolveCompatibilityAliases(input) {
224
+ const aliases = [
225
+ ...(input.issueRecord?.aliases ?? []),
226
+ input.issueIdentifier,
227
+ input.issueId,
228
+ input.taskId,
229
+ input.runId
230
+ ];
231
+ return Array.from(new Set(aliases.filter((alias) => typeof alias === 'string' && alias.length > 0)));
232
+ }
233
+ function normalizeRecentAgentActivity(issue, proof) {
234
+ if (issue.recent_events.length > 0) {
235
+ return issue.recent_events;
236
+ }
237
+ const event = issue.latest_event?.event ?? proof?.last_event ?? null;
238
+ const message = issue.latest_event?.message ?? proof?.last_message ?? null;
239
+ if (!event && !message) {
240
+ return [];
241
+ }
242
+ return [
243
+ {
244
+ at: issue.latest_event?.at ?? proof?.last_event_at ?? null,
245
+ event,
246
+ message
247
+ }
248
+ ];
249
+ }
250
+ function normalizeLinearActivity(recentActivity) {
251
+ return Array.isArray(recentActivity) ? recentActivity : [];
252
+ }
@@ -0,0 +1,70 @@
1
+ import { normalizeProviderLinearWorkflowState } from './providerLinearWorkflowStates.js';
2
+ export const DEFAULT_PROVIDER_MAX_CONCURRENT_AGENTS = 10;
3
+ export const DEFAULT_LOCAL_PROVIDER_MAX_CONCURRENT_AGENTS = 3;
4
+ export function resolveProviderPollDispatchLimits(featureToggles, options = {}) {
5
+ const agentConfig = readProviderPollAgentConfig(featureToggles);
6
+ const explicitMaxConcurrentAgents = readPositiveIntegerValue(agentConfig, 'max_concurrent_agents', 'maxConcurrentAgents');
7
+ const maxConcurrentAgentsByState = readPositiveIntegerMap(agentConfig, 'max_concurrent_agents_by_state', 'maxConcurrentAgentsByState');
8
+ return {
9
+ maxConcurrentAgents: explicitMaxConcurrentAgents ??
10
+ (options.localWorkerOnly === true
11
+ ? DEFAULT_LOCAL_PROVIDER_MAX_CONCURRENT_AGENTS
12
+ : DEFAULT_PROVIDER_MAX_CONCURRENT_AGENTS),
13
+ maxConcurrentAgentsByState
14
+ };
15
+ }
16
+ function readProviderPollAgentConfig(featureToggles) {
17
+ const direct = readRecordValue(featureToggles, 'agent');
18
+ const nested = readRecordValue(readRecordValue(featureToggles, 'coordinator'), 'agent');
19
+ if (!direct && !nested) {
20
+ return null;
21
+ }
22
+ return {
23
+ ...(nested ?? {}),
24
+ ...(direct ?? {})
25
+ };
26
+ }
27
+ function readPositiveIntegerMap(record, ...keys) {
28
+ const value = readRecordValue(record, ...keys);
29
+ if (!value) {
30
+ return new Map();
31
+ }
32
+ const entries = new Map();
33
+ for (const [rawKey, rawValue] of Object.entries(value)) {
34
+ const normalizedKey = normalizeProviderLinearWorkflowState(rawKey);
35
+ const parsedValue = readPositiveIntegerValue({ value: rawValue }, 'value');
36
+ if (!normalizedKey || parsedValue === null) {
37
+ continue;
38
+ }
39
+ entries.set(normalizedKey, parsedValue);
40
+ }
41
+ return entries;
42
+ }
43
+ function readPositiveIntegerValue(record, ...keys) {
44
+ for (const key of keys) {
45
+ const value = record?.[key];
46
+ if (typeof value === 'number' && Number.isInteger(value) && value > 0) {
47
+ return value;
48
+ }
49
+ if (typeof value === 'string') {
50
+ const trimmed = value.trim();
51
+ if (!trimmed || !/^\d+$/.test(trimmed)) {
52
+ continue;
53
+ }
54
+ const parsed = Number.parseInt(trimmed, 10);
55
+ if (Number.isInteger(parsed) && parsed > 0) {
56
+ return parsed;
57
+ }
58
+ }
59
+ }
60
+ return null;
61
+ }
62
+ function readRecordValue(record, ...keys) {
63
+ for (const key of keys) {
64
+ const value = record?.[key];
65
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
66
+ return value;
67
+ }
68
+ }
69
+ return null;
70
+ }