@ornexus/neocortex 4.60.78 → 4.60.80

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 (247) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1193 -1206
  3. package/install.ps1 +1 -1
  4. package/install.sh +1 -1
  5. package/package.json +2 -2
  6. package/packages/client/dist/adapters/adapter-registry.js +108 -1
  7. package/packages/client/dist/adapters/antigravity-adapter.js +77 -2
  8. package/packages/client/dist/adapters/claude-code-adapter.js +79 -3
  9. package/packages/client/dist/adapters/codex-adapter.js +80 -2
  10. package/packages/client/dist/adapters/cursor-adapter.js +115 -4
  11. package/packages/client/dist/adapters/gemini-adapter.js +71 -2
  12. package/packages/client/dist/adapters/grok-adapter.js +42 -2
  13. package/packages/client/dist/adapters/index.js +22 -1
  14. package/packages/client/dist/adapters/platform-detector.js +214 -1
  15. package/packages/client/dist/adapters/target-adapter.js +12 -0
  16. package/packages/client/dist/adapters/vscode-adapter.js +72 -2
  17. package/packages/client/dist/agent/refresh-stubs.js +443 -2
  18. package/packages/client/dist/agent/update-agent-yaml.js +102 -1
  19. package/packages/client/dist/agent/update-description.js +260 -1
  20. package/packages/client/dist/cache/crypto-utils.js +78 -1
  21. package/packages/client/dist/cache/encrypted-cache.js +338 -1
  22. package/packages/client/dist/cache/in-memory-asset-cache.js +73 -1
  23. package/packages/client/dist/cache/index.js +13 -1
  24. package/packages/client/dist/cache/protected-pi-boundary.js +44 -1
  25. package/packages/client/dist/checkpoint/checkpoint-client-reader.js +127 -2
  26. package/packages/client/dist/checkpoint/index.js +11 -1
  27. package/packages/client/dist/checkpoint/shared-checkpoint-types.js +32 -1
  28. package/packages/client/dist/cli.js +358 -5
  29. package/packages/client/dist/commands/activate.js +394 -8
  30. package/packages/client/dist/commands/architecture-answers.js +274 -7
  31. package/packages/client/dist/commands/architecture-memory-terminal.js +253 -4
  32. package/packages/client/dist/commands/architecture-non-ui-continuation.js +100 -1
  33. package/packages/client/dist/commands/architecture-root-binding.js +51 -1
  34. package/packages/client/dist/commands/cache-status.js +112 -2
  35. package/packages/client/dist/commands/config.js +88 -1
  36. package/packages/client/dist/commands/doctor.js +635 -2
  37. package/packages/client/dist/commands/invoke.js +7712 -143
  38. package/packages/client/dist/commands/legacy-epic-terminal.js +71 -1
  39. package/packages/client/dist/commands/legacy-story-branch.js +96 -1
  40. package/packages/client/dist/commands/legacy-story-pr.js +276 -1
  41. package/packages/client/dist/commands/mutation-qa-checkpoint.js +285 -5
  42. package/packages/client/dist/commands/mutation-qa-gate.js +54 -1
  43. package/packages/client/dist/commands/mutation-qa-git.js +41 -1
  44. package/packages/client/dist/commands/mutation-qa-policy.js +102 -1
  45. package/packages/client/dist/commands/mutation-qa-run.js +219 -3
  46. package/packages/client/dist/commands/mutation-qa-verdict.js +149 -1
  47. package/packages/client/dist/commands/mutation-qa.js +220 -1
  48. package/packages/client/dist/commands/native-agent.js +136 -2
  49. package/packages/client/dist/commands/planning-diagnosis.js +43 -1
  50. package/packages/client/dist/commands/planning-generation.js +53 -1
  51. package/packages/client/dist/commands/planning-memory.js +40 -1
  52. package/packages/client/dist/commands/planning-research.js +42 -1
  53. package/packages/client/dist/commands/private-session.js +75 -1
  54. package/packages/client/dist/commands/property-qa.js +139 -1
  55. package/packages/client/dist/commands/qa-control.js +16 -1
  56. package/packages/client/dist/commands/qa-scan-browser-launch.js +55 -1
  57. package/packages/client/dist/commands/qa-scan-browser-route.js +28 -1
  58. package/packages/client/dist/commands/qa-scan-capture.js +663 -5
  59. package/packages/client/dist/commands/qa-scan-discovery.js +376 -3
  60. package/packages/client/dist/commands/qa-scan-review.js +826 -5
  61. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +266 -1
  62. package/packages/client/dist/commands/qa-synthetic-backend-review.js +297 -1
  63. package/packages/client/dist/commands/qa-synthetic-backend.js +340 -2
  64. package/packages/client/dist/commands/qa-synthetic-broker-port.js +85 -1
  65. package/packages/client/dist/commands/qa-synthetic-browser.js +39 -1
  66. package/packages/client/dist/commands/refactor-characterization.js +671 -21
  67. package/packages/client/dist/commands/refactor-commit.js +399 -13
  68. package/packages/client/dist/commands/refactor-control.js +142 -3
  69. package/packages/client/dist/commands/refactor-cpp-assertions.js +93 -3
  70. package/packages/client/dist/commands/refactor-review.js +283 -5
  71. package/packages/client/dist/commands/refactor-root.js +588 -7
  72. package/packages/client/dist/commands/refresh-memory.d.ts +3 -1
  73. package/packages/client/dist/commands/refresh-memory.js +174 -3
  74. package/packages/client/dist/commands/shared-architecture-non-ui.js +24 -1
  75. package/packages/client/dist/commands/story-checkpoint.js +171 -1
  76. package/packages/client/dist/config/host-auth-broker.js +60 -1
  77. package/packages/client/dist/config/host-auth-reference.js +93 -1
  78. package/packages/client/dist/config/profile-directory.js +13 -1
  79. package/packages/client/dist/config/resolver-selection.js +278 -1
  80. package/packages/client/dist/config/secure-config.js +281 -12
  81. package/packages/client/dist/config.js +223 -2
  82. package/packages/client/dist/constants.js +25 -1
  83. package/packages/client/dist/context/context-collector.js +222 -2
  84. package/packages/client/dist/context/context-sanitizer.js +145 -1
  85. package/packages/client/dist/continuity/autonomous-governance.js +285 -1
  86. package/packages/client/dist/continuity/continuity-client-state-store.js +1587 -1
  87. package/packages/client/dist/continuity/invoke-hooks.js +129 -1
  88. package/packages/client/dist/continuity/migrations/001-initial-schema.js +12 -2
  89. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +12 -2
  90. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +12 -2
  91. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +12 -2
  92. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +12 -2
  93. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +10 -2
  94. package/packages/client/dist/continuity/native-agent-store.js +69 -1
  95. package/packages/client/dist/continuity/native-agent-types.js +105 -1
  96. package/packages/client/dist/continuity/outbox.js +117 -1
  97. package/packages/client/dist/continuity/runner-bootstrap-policy.js +172 -1
  98. package/packages/client/dist/continuity/sqlite-store.js +2612 -81
  99. package/packages/client/dist/effects/invoke-effect-gateways.js +62 -1
  100. package/packages/client/dist/errors/error-messages.js +258 -2
  101. package/packages/client/dist/errors/frontmatter-diagnostics.js +125 -1
  102. package/packages/client/dist/evidence/collector.js +347 -1
  103. package/packages/client/dist/evidence/index.js +1 -1
  104. package/packages/client/dist/evidence/types.js +2 -0
  105. package/packages/client/dist/fs/atomic-state-replace.js +152 -1
  106. package/packages/client/dist/generated/command-registry.generated.js +4076 -1
  107. package/packages/client/dist/generated/public-projections.generated.js +149 -1
  108. package/packages/client/dist/git/direct-yolo-c01-retry.js +138 -4
  109. package/packages/client/dist/git/direct-yolo-checkpoint.js +1456 -4
  110. package/packages/client/dist/git/epic-operational-state.js +672 -2
  111. package/packages/client/dist/git/git-lifecycle-step-ids.js +14 -1
  112. package/packages/client/dist/git/git-lifecycle-store.js +2188 -10
  113. package/packages/client/dist/git/legacy-story-branch-checkpoint.js +259 -9
  114. package/packages/client/dist/git/legacy-story-branch-setup.js +348 -4
  115. package/packages/client/dist/git/legacy-story-pr.js +3538 -70
  116. package/packages/client/dist/git/neocortex-trailers.d.ts +26 -0
  117. package/packages/client/dist/git/neocortex-trailers.js +53 -0
  118. package/packages/client/dist/git/secure-filesystem-boundary.js +182 -5
  119. package/packages/client/dist/graph-retrieval/pre-command-hook.js +284 -1
  120. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +237 -1
  121. package/packages/client/dist/i18n/first-run.js +60 -2
  122. package/packages/client/dist/index.js +50 -1
  123. package/packages/client/dist/invocation/invoke-input.js +24 -1
  124. package/packages/client/dist/license/host-auth-recovery.js +401 -1
  125. package/packages/client/dist/license/index.js +5 -1
  126. package/packages/client/dist/license/license-client.js +337 -1
  127. package/packages/client/dist/machine/fingerprint.js +163 -2
  128. package/packages/client/dist/machine/index.js +5 -1
  129. package/packages/client/dist/memory/project-memory-path-scope.js +62 -1
  130. package/packages/client/dist/memory/project-memory-writer.d.ts +16 -1
  131. package/packages/client/dist/memory/project-memory-writer.js +1117 -41
  132. package/packages/client/dist/memory/shared-project-memory-types.js +259 -2
  133. package/packages/client/dist/migrations/epic-lifecycle-backfill.js +1060 -3
  134. package/packages/client/dist/migrations/project-identity-capability.js +50 -1
  135. package/packages/client/dist/migrations/project-identity.js +493 -7
  136. package/packages/client/dist/migrations/state-json.js +393 -4
  137. package/packages/client/dist/policy/architecture-policy.js +184 -2
  138. package/packages/client/dist/policy/index.js +7 -1
  139. package/packages/client/dist/policy/shared-policy-types.js +38 -0
  140. package/packages/client/dist/policy/subagent-approval-policy.js +55 -1
  141. package/packages/client/dist/private-execution/clean-baseline.js +279 -2
  142. package/packages/client/dist/private-execution/codex-executor.js +574 -4
  143. package/packages/client/dist/private-execution/codex-host-runtime.js +137 -1
  144. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +97 -1
  145. package/packages/client/dist/private-execution/codex-scoped-permissions.js +128 -1
  146. package/packages/client/dist/private-execution/delivery.js +410 -13
  147. package/packages/client/dist/private-execution/diagnosis-root-review.js +294 -2
  148. package/packages/client/dist/private-execution/frozen-handoff.js +19 -6
  149. package/packages/client/dist/private-execution/implementation-validation.js +106 -2
  150. package/packages/client/dist/private-execution/isolated-admission.js +1432 -23
  151. package/packages/client/dist/private-execution/isolated-session.js +725 -5
  152. package/packages/client/dist/private-execution/isolated-workspace.js +122 -1
  153. package/packages/client/dist/private-execution/pact-consumer-runtime.js +409 -3
  154. package/packages/client/dist/private-execution/pact-test-source.js +258 -1
  155. package/packages/client/dist/private-execution/pact-toolchain.js +290 -3
  156. package/packages/client/dist/private-execution/pact-write-set.js +172 -1
  157. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +406 -5
  158. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +462 -5
  159. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +139 -3
  160. package/packages/client/dist/private-execution/planning-research-checkpoint.js +325 -4
  161. package/packages/client/dist/private-execution/private-report-store.js +42 -1
  162. package/packages/client/dist/private-execution/property-test-candidate.js +103 -1
  163. package/packages/client/dist/private-execution/property-test-choices.js +147 -3
  164. package/packages/client/dist/private-execution/property-test-plan.js +271 -7
  165. package/packages/client/dist/private-execution/property-test-review.js +258 -4
  166. package/packages/client/dist/private-execution/property-test-runtime.js +372 -9
  167. package/packages/client/dist/private-execution/property-test-source.js +139 -1
  168. package/packages/client/dist/private-execution/root-checkpoint.js +80 -1
  169. package/packages/client/dist/private-execution/root-memory-git-evidence.js +135 -3
  170. package/packages/client/dist/private-execution/root-memory-recovery.js +93 -1
  171. package/packages/client/dist/private-execution/root-memory-request.js +29 -1
  172. package/packages/client/dist/private-execution/root-memory-scope.js +178 -1
  173. package/packages/client/dist/private-execution/root-memory-writer.js +102 -1
  174. package/packages/client/dist/private-execution/session-lease.js +63 -1
  175. package/packages/client/dist/private-execution/shared-private-admission-types.js +50 -1
  176. package/packages/client/dist/private-execution/shared-project-validation.js +66 -1
  177. package/packages/client/dist/private-execution/shared-root-memory-types.js +61 -1
  178. package/packages/client/dist/private-execution/ux-source-validation.js +372 -1
  179. package/packages/client/dist/private-execution/ux-write-set.js +191 -2
  180. package/packages/client/dist/registry/registry-reconciliation.js +234 -1
  181. package/packages/client/dist/resilience/circuit-breaker.js +170 -1
  182. package/packages/client/dist/resilience/degradation-manager.js +164 -1
  183. package/packages/client/dist/resilience/freshness-indicator.js +100 -1
  184. package/packages/client/dist/resilience/index.js +8 -1
  185. package/packages/client/dist/resilience/recovery-detector.js +74 -1
  186. package/packages/client/dist/resolvers/asset-resolver.js +13 -0
  187. package/packages/client/dist/resolvers/local-resolver.js +255 -8
  188. package/packages/client/dist/resolvers/remote-resolver.js +233 -1
  189. package/packages/client/dist/runner/binary.js +404 -1
  190. package/packages/client/dist/runner/cli.js +1571 -17
  191. package/packages/client/dist/runner/epic-background-dispatcher.js +124 -1
  192. package/packages/client/dist/runner/headless/adapters.js +49 -1
  193. package/packages/client/dist/runner/headless/background-root.js +85 -1
  194. package/packages/client/dist/runner/headless/claude-code-adapter.js +79 -1
  195. package/packages/client/dist/runner/headless/continuous-story-workspace.js +1628 -11
  196. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +69 -1
  197. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +111 -2
  198. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +1464 -10
  199. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +357 -2
  200. package/packages/client/dist/runner/headless/fake-adapter.js +62 -1
  201. package/packages/client/dist/runner/headless/managed-environment-cleanup.js +274 -1
  202. package/packages/client/dist/runner/headless/managed-profile.js +149 -1
  203. package/packages/client/dist/runner/headless/opencode-adapter.js +145 -2
  204. package/packages/client/dist/runner/headless/prepared-story-bundle.js +43 -1
  205. package/packages/client/dist/runner/headless/resolver.js +231 -1
  206. package/packages/client/dist/runner/headless/run-yolo.js +886 -1
  207. package/packages/client/dist/runner/headless/run-yoloop.js +2586 -2
  208. package/packages/client/dist/runner/headless/types.js +575 -2
  209. package/packages/client/dist/runner/host-capacity.js +59 -1
  210. package/packages/client/dist/runner/local-console.js +396 -13
  211. package/packages/client/dist/runner/portal-sync-worker.js +1487 -1
  212. package/packages/client/dist/runner/project-identity.js +106 -1
  213. package/packages/client/dist/runner/scheduler.js +995 -7
  214. package/packages/client/dist/runner-cli.js +18 -2
  215. package/packages/client/dist/state/invocation-shape.js +13 -1
  216. package/packages/client/dist/state/project-state-snapshot.js +1751 -1
  217. package/packages/client/dist/state/state-json-repair.js +785 -3
  218. package/packages/client/dist/state/structural-dag-projection.js +118 -1
  219. package/packages/client/dist/telemetry/index.js +5 -1
  220. package/packages/client/dist/telemetry/offline-queue.js +131 -1
  221. package/packages/client/dist/tier/index.js +5 -1
  222. package/packages/client/dist/tier/tier-aware-client.js +405 -1
  223. package/packages/client/dist/types/index.js +38 -1
  224. package/packages/client/dist/version.js +27 -1
  225. package/packages/client/dist/yolo/change-evidence-collector.d.ts +1 -1
  226. package/packages/client/dist/yolo/change-evidence-collector.js +245 -1
  227. package/packages/client/dist/yolo/invoke-envelope-capability.js +62 -1
  228. package/packages/client/dist/yolo/spec-envelope-collector.js +184 -5
  229. package/packages/client/dist/yoloop/discovery-hook.js +300 -2
  230. package/packages/client/dist/yoloop/index.js +8 -1
  231. package/packages/client/dist/yoloop/invoke-hooks.js +669 -12
  232. package/packages/client/dist/yoloop/shared-discover-epics.js +1007 -1
  233. package/packages/client/dist/yoloop/shared-yoloop-types.js +33 -1
  234. package/packages/client/dist/yoloop/target-normalization.js +180 -1
  235. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1920 -1
  236. package/packages/shared/dist/yoloop/epic-terminal-git.js +12 -0
  237. package/targets-stubs/antigravity/gemini.md +1 -1
  238. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  239. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  240. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  241. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  242. package/targets-stubs/claude-code/neocortex.md +2 -2
  243. package/targets-stubs/codex/AGENTS.md +1 -1
  244. package/targets-stubs/cursor/agent.md +2 -2
  245. package/targets-stubs/gemini-cli/agent.md +2 -2
  246. package/targets-stubs/opencode/neocortex-root.md +1 -1
  247. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1 +1,124 @@
1
- import{isNativeBackgroundDispatchContractV1 as b,isNativeDispatchBindingV1 as h,isNativeHostAttestationV1 as I}from"../continuity/native-agent-types.js";const i=Object.freeze({CONTRACT_INVALID:"directive-background-contract-invalid",BINDING_MISSING:"directive-background-binding-missing",WAVE_MISMATCH:"directive-background-wave-mismatch",GRAPH_STALE:"directive-background-graph-stale",CAPABILITY_UNVALIDATED:"native-background-capability-unvalidated",DEPTH_DENIED:"native-background-depth-denied",SETTLEMENT_INVALID:"native-background-settlement-invalid"}),v=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/,f=/^\*yolo @docs\/stories\/([A-Za-z0-9._-]+)\.story\.md(?: branchless-preparation)?$/,y=/^(?:sha256:)?[a-f0-9]{64}$/i;function D(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function C(e,t){return e.schemaVersion===t.schemaVersion&&e.storyId===t.storyId&&e.graphRevision.toLowerCase()===t.graphRevision.toLowerCase()&&e.dispatchKey.toLowerCase()===t.dispatchKey.toLowerCase()&&e.requiredCapability===t.requiredCapability&&e.maxDepth===t.maxDepth&&e.publicSafe===t.publicSafe}function p(e){return e.toLowerCase().replace(/^sha256:/,"")}function T(e,t,n){return Object.freeze({storyId:e,prompt:t,binding:Object.freeze({...n})})}function _(e){if(!e.supportsTaskDelegation||e.taskDelegationCapability!=="native_safe"||!I(e.hostAttestation))return Object.freeze({kind:"inline",reasonCode:i.CAPABILITY_UNVALIDATED});if(!D(e.directive)||e.directive.kind!=="task"||e.directive.subagentType!=="neocortex"||!b(e.directive.backgroundDispatch))return Object.freeze({kind:"denied",reasonCode:i.CONTRACT_INVALID});if(!h(e.directive.dispatchBinding)||!Array.isArray(e.directive.dispatchBindings)||e.directive.dispatchBindings.length===0||!e.directive.dispatchBindings.every(h))return Object.freeze({kind:"denied",reasonCode:i.BINDING_MISSING});if(!y.test(e.currentGraphRevision))return Object.freeze({kind:"denied",reasonCode:i.GRAPH_STALE});const t=e.directive.storyIds,n=e.directive.promptTemplates,a=e.directive.dispatchBindings;if(!Array.isArray(t)||!Array.isArray(n)||t.length===0||t.length!==n.length||t.length!==a.length||new Set(t).size!==t.length||new Set(a.map(r=>r.dispatchKey)).size!==a.length||!C(e.directive.dispatchBinding,a[0]))return Object.freeze({kind:"denied",reasonCode:i.WAVE_MISMATCH});const g=p(e.currentGraphRevision),c=[];for(let r=0;r<t.length;r+=1){const s=t[r],d=n[r],o=a[r],A=typeof d=="string"?d.match(f):null;if(typeof s!="string"||!v.test(s)||!A||A[1]!==s||o.storyId!==s)return Object.freeze({kind:"denied",reasonCode:i.WAVE_MISMATCH});if(p(o.graphRevision)!==g)return Object.freeze({kind:"denied",reasonCode:i.GRAPH_STALE});if(o.maxDepth!==1||e.directive.backgroundDispatch.maxDepth!==1)return Object.freeze({kind:"denied",reasonCode:i.DEPTH_DENIED});c.push(T(s,d,o))}return Object.freeze({kind:"launch",entries:Object.freeze(c),hostAttestation:Object.freeze({...e.hostAttestation})})}export{i as NATIVE_BACKGROUND_REASON_CODES,_ as planEpicBackgroundDispatch};
1
+ /**
2
+ * Contract-first admission for root-owned native background execution.
3
+ *
4
+ * This module deliberately does not spawn, persist tracked state, select graph
5
+ * work, or perform Git effects. It only converts an exact server-owned task
6
+ * directive into closed per-story entries for the host root.
7
+ */
8
+ import { isNativeBackgroundDispatchContractV1, isNativeDispatchBindingV1, isNativeHostAttestationV1, } from '../continuity/native-agent-types.js';
9
+ export const NATIVE_BACKGROUND_REASON_CODES = Object.freeze({
10
+ CONTRACT_INVALID: 'directive-background-contract-invalid',
11
+ BINDING_MISSING: 'directive-background-binding-missing',
12
+ WAVE_MISMATCH: 'directive-background-wave-mismatch',
13
+ GRAPH_STALE: 'directive-background-graph-stale',
14
+ CAPABILITY_UNVALIDATED: 'native-background-capability-unvalidated',
15
+ DEPTH_DENIED: 'native-background-depth-denied',
16
+ SETTLEMENT_INVALID: 'native-background-settlement-invalid',
17
+ });
18
+ const STORY_ID = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;
19
+ const STORY_PROMPT = /^\*yolo @docs\/stories\/([A-Za-z0-9._-]+)\.story\.md(?: branchless-preparation)?$/;
20
+ const GRAPH_REVISION = /^(?:sha256:)?[a-f0-9]{64}$/i;
21
+ function record(value) {
22
+ return !!value && typeof value === 'object' && !Array.isArray(value);
23
+ }
24
+ function sameBinding(left, right) {
25
+ return left.schemaVersion === right.schemaVersion
26
+ && left.storyId === right.storyId
27
+ && left.graphRevision.toLowerCase() === right.graphRevision.toLowerCase()
28
+ && left.dispatchKey.toLowerCase() === right.dispatchKey.toLowerCase()
29
+ && left.requiredCapability === right.requiredCapability
30
+ && left.maxDepth === right.maxDepth
31
+ && left.publicSafe === right.publicSafe;
32
+ }
33
+ function normalizeRevision(value) {
34
+ return value.toLowerCase().replace(/^sha256:/, '');
35
+ }
36
+ function freezeEntry(storyId, prompt, binding) {
37
+ return Object.freeze({ storyId, prompt, binding: Object.freeze({ ...binding }) });
38
+ }
39
+ /**
40
+ * Admit only the exact P224-CON-DISPATCH chain. Missing native authority is an
41
+ * explicit inline fallback; malformed or stale authority is denied.
42
+ */
43
+ export function planEpicBackgroundDispatch(input) {
44
+ if (!input.supportsTaskDelegation || input.taskDelegationCapability !== 'native_safe'
45
+ || !isNativeHostAttestationV1(input.hostAttestation)) {
46
+ return Object.freeze({
47
+ kind: 'inline',
48
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.CAPABILITY_UNVALIDATED,
49
+ });
50
+ }
51
+ if (!record(input.directive)
52
+ || input.directive.kind !== 'task'
53
+ || input.directive.subagentType !== 'neocortex'
54
+ || !isNativeBackgroundDispatchContractV1(input.directive.backgroundDispatch)) {
55
+ return Object.freeze({
56
+ kind: 'denied',
57
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.CONTRACT_INVALID,
58
+ });
59
+ }
60
+ if (!isNativeDispatchBindingV1(input.directive.dispatchBinding)
61
+ || !Array.isArray(input.directive.dispatchBindings)
62
+ || input.directive.dispatchBindings.length === 0
63
+ || !input.directive.dispatchBindings.every(isNativeDispatchBindingV1)) {
64
+ return Object.freeze({
65
+ kind: 'denied',
66
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.BINDING_MISSING,
67
+ });
68
+ }
69
+ if (!GRAPH_REVISION.test(input.currentGraphRevision)) {
70
+ return Object.freeze({
71
+ kind: 'denied',
72
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.GRAPH_STALE,
73
+ });
74
+ }
75
+ const storyIds = input.directive.storyIds;
76
+ const promptTemplates = input.directive.promptTemplates;
77
+ const bindings = input.directive.dispatchBindings;
78
+ if (!Array.isArray(storyIds) || !Array.isArray(promptTemplates)
79
+ || storyIds.length === 0
80
+ || storyIds.length !== promptTemplates.length
81
+ || storyIds.length !== bindings.length
82
+ || new Set(storyIds).size !== storyIds.length
83
+ || new Set(bindings.map((binding) => binding.dispatchKey)).size !== bindings.length
84
+ || !sameBinding(input.directive.dispatchBinding, bindings[0])) {
85
+ return Object.freeze({
86
+ kind: 'denied',
87
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.WAVE_MISMATCH,
88
+ });
89
+ }
90
+ const graphRevision = normalizeRevision(input.currentGraphRevision);
91
+ const entries = [];
92
+ for (let index = 0; index < storyIds.length; index += 1) {
93
+ const storyId = storyIds[index];
94
+ const prompt = promptTemplates[index];
95
+ const binding = bindings[index];
96
+ const promptMatch = typeof prompt === 'string' ? prompt.match(STORY_PROMPT) : null;
97
+ if (typeof storyId !== 'string' || !STORY_ID.test(storyId)
98
+ || !promptMatch || promptMatch[1] !== storyId
99
+ || binding.storyId !== storyId) {
100
+ return Object.freeze({
101
+ kind: 'denied',
102
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.WAVE_MISMATCH,
103
+ });
104
+ }
105
+ if (normalizeRevision(binding.graphRevision) !== graphRevision) {
106
+ return Object.freeze({
107
+ kind: 'denied',
108
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.GRAPH_STALE,
109
+ });
110
+ }
111
+ if (binding.maxDepth !== 1 || input.directive.backgroundDispatch.maxDepth !== 1) {
112
+ return Object.freeze({
113
+ kind: 'denied',
114
+ reasonCode: NATIVE_BACKGROUND_REASON_CODES.DEPTH_DENIED,
115
+ });
116
+ }
117
+ entries.push(freezeEntry(storyId, prompt, binding));
118
+ }
119
+ return Object.freeze({
120
+ kind: 'launch',
121
+ entries: Object.freeze(entries),
122
+ hostAttestation: Object.freeze({ ...input.hostAttestation }),
123
+ });
124
+ }
@@ -1 +1,49 @@
1
- import{HEADLESS_ADAPTER_IDS as o,HEADLESS_REASON_CODES as s,isHeadlessAdapterId as a,redaction as p}from"./types.js";import{createClaudeCodeHeadlessAdapter as i}from"./claude-code-adapter.js";import{createFakeHeadlessAdapter as d}from"./fake-adapter.js";import{createOpenCodeHeadlessAdapter as n}from"./opencode-adapter.js";class u{adapters;constructor(e){const r=new Map;for(const t of e)a(t.id)&&r.set(t.id,t);this.adapters=r}listAdapterIds(){return o.filter(e=>this.adapters.has(e))}hasAdapter(e){return a(e)&&this.adapters.has(e)}getAdapter(e){return!a(e)||!this.adapters.has(e)?{ok:!1,reasonCode:s.RUNTIME_UNTRUSTED,reasonCodes:[s.RUNTIME_UNTRUSTED],publicSummary:"Headless adapter id is not allowlisted.",redactionSummary:[p("runtimeId","unsafe_key","value-denied")],publicSafe:!0}:{ok:!0,adapter:this.adapters.get(e),publicSafe:!0}}}function S(){return new u([d("fake"),d("test"),n(),i()])}export{u as HeadlessAdapterRegistry,S as createDefaultHeadlessAdapterRegistry};
1
+ /**
2
+ * @license FSL-1.1
3
+ * Copyright (c) 2026 OrNexus AI
4
+ *
5
+ * P190.04 -- allowlisted headless adapter registry.
6
+ */
7
+ import { HEADLESS_ADAPTER_IDS, HEADLESS_REASON_CODES, isHeadlessAdapterId, redaction, } from './types.js';
8
+ import { createClaudeCodeHeadlessAdapter } from './claude-code-adapter.js';
9
+ import { createFakeHeadlessAdapter } from './fake-adapter.js';
10
+ import { createOpenCodeHeadlessAdapter } from './opencode-adapter.js';
11
+ export class HeadlessAdapterRegistry {
12
+ adapters;
13
+ constructor(adapters) {
14
+ const map = new Map();
15
+ for (const adapter of adapters) {
16
+ if (!isHeadlessAdapterId(adapter.id))
17
+ continue;
18
+ map.set(adapter.id, adapter);
19
+ }
20
+ this.adapters = map;
21
+ }
22
+ listAdapterIds() {
23
+ return HEADLESS_ADAPTER_IDS.filter((id) => this.adapters.has(id));
24
+ }
25
+ hasAdapter(id) {
26
+ return isHeadlessAdapterId(id) && this.adapters.has(id);
27
+ }
28
+ getAdapter(id) {
29
+ if (!isHeadlessAdapterId(id) || !this.adapters.has(id)) {
30
+ return {
31
+ ok: false,
32
+ reasonCode: HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED,
33
+ reasonCodes: [HEADLESS_REASON_CODES.RUNTIME_UNTRUSTED],
34
+ publicSummary: 'Headless adapter id is not allowlisted.',
35
+ redactionSummary: [redaction('runtimeId', 'unsafe_key', 'value-denied')],
36
+ publicSafe: true,
37
+ };
38
+ }
39
+ return { ok: true, adapter: this.adapters.get(id), publicSafe: true };
40
+ }
41
+ }
42
+ export function createDefaultHeadlessAdapterRegistry() {
43
+ return new HeadlessAdapterRegistry([
44
+ createFakeHeadlessAdapter('fake'),
45
+ createFakeHeadlessAdapter('test'),
46
+ createOpenCodeHeadlessAdapter(),
47
+ createClaudeCodeHeadlessAdapter(),
48
+ ]);
49
+ }
@@ -1 +1,85 @@
1
- import{isNativeAgentDispatchReceiptV1 as m,NATIVE_AGENT_TERMINAL_STATES as g}from"../../continuity/native-agent-types.js";import{NATIVE_BACKGROUND_REASON_CODES as d}from"../epic-background-dispatcher.js";const w=30;class c extends Error{reasonCode;constructor(a){super(a),this.reasonCode=a,this.name="NativeBackgroundRootError"}}function u(e,a){if(!m(e)||e.storyId!==a.storyId||e.dispatchKey!==a.binding.dispatchKey||e.graphRevision.replace(/^sha256:/,"").toLowerCase()!==a.binding.graphRevision.replace(/^sha256:/,"").toLowerCase()||e.topology!=="native-agent")throw new c(d.SETTLEMENT_INVALID);return e}async function T(e,a,r,o={}){if(e.length===0)throw new c(d.WAVE_MISMATCH);const n=await r.preflight(e,a);if(!n.ok)throw new c(n.reasonCode);const i=await Promise.all(e.map(t=>r.reserve(t,a))),E=await Promise.all(e.map(async(t,l)=>{const s=i[l];if(u(s.receipt,t),s.action==="reconcile-existing")return u(await r.reconcileExisting(t,s),t);const h=await r.launch(t);return u(await r.recordSpawned(t,s,h),t)}));let f;try{f=await Promise.any(E.map((t,l)=>r.awaitSettlement(e[l],t,{maxPolls:w,...o.signal?{signal:o.signal}:{}}).then(s=>{const h=u(s,e[l]);if(!g.has(h.state))throw new c(d.SETTLEMENT_INVALID);return h})))}catch{throw new c(d.SETTLEMENT_INVALID)}return Object.freeze({kind:"settled",settlement:f,started:Object.freeze([...E]),publicSafe:!0})}async function A(e,a={}){const r=Math.max(1,Math.min(w,a.maxPolls??w));let o=null,n=0;for(let i=1;i<=r&&!a.signal?.aborted;i+=1)if(o=await e(i),n=i,o&&g.has(o.state))return Object.freeze({receipt:o,polls:n,exhausted:!1});return Object.freeze({receipt:o,polls:n,exhausted:n>=r})}export{w as NATIVE_BACKGROUND_MAX_POLLS,c as NativeBackgroundRootError,A as boundedNativeBackgroundPoll,T as runNativeBackgroundRoot};
1
+ /**
2
+ * Root-owned execution of an already admitted native background frontier.
3
+ * Host-specific APIs are injected; raw handles never leave the launch/observe
4
+ * bridge and are absent from this module's public result.
5
+ */
6
+ import { isNativeAgentDispatchReceiptV1, NATIVE_AGENT_TERMINAL_STATES, } from '../../continuity/native-agent-types.js';
7
+ import { NATIVE_BACKGROUND_REASON_CODES, } from '../epic-background-dispatcher.js';
8
+ export const NATIVE_BACKGROUND_MAX_POLLS = 30;
9
+ export class NativeBackgroundRootError extends Error {
10
+ reasonCode;
11
+ constructor(reasonCode) {
12
+ super(reasonCode);
13
+ this.reasonCode = reasonCode;
14
+ this.name = 'NativeBackgroundRootError';
15
+ }
16
+ }
17
+ function assertReceipt(receipt, entry) {
18
+ if (!isNativeAgentDispatchReceiptV1(receipt)
19
+ || receipt.storyId !== entry.storyId
20
+ || receipt.dispatchKey !== entry.binding.dispatchKey
21
+ || receipt.graphRevision.replace(/^sha256:/, '').toLowerCase()
22
+ !== entry.binding.graphRevision.replace(/^sha256:/, '').toLowerCase()
23
+ || receipt.topology !== 'native-agent') {
24
+ throw new NativeBackgroundRootError(NATIVE_BACKGROUND_REASON_CODES.SETTLEMENT_INVALID);
25
+ }
26
+ return receipt;
27
+ }
28
+ /**
29
+ * Reserve the whole frontier, launch only `spawn-once` entries, reconcile
30
+ * existing dispatches, then begin settlement. No settlement is awaited before
31
+ * every entry has produced a launch/reconciliation receipt.
32
+ */
33
+ export async function runNativeBackgroundRoot(entries, hostAttestation, ports, options = {}) {
34
+ if (entries.length === 0) {
35
+ throw new NativeBackgroundRootError(NATIVE_BACKGROUND_REASON_CODES.WAVE_MISMATCH);
36
+ }
37
+ const preflight = await ports.preflight(entries, hostAttestation);
38
+ if (!preflight.ok)
39
+ throw new NativeBackgroundRootError(preflight.reasonCode);
40
+ const reservations = await Promise.all(entries.map((entry) => ports.reserve(entry, hostAttestation)));
41
+ const started = await Promise.all(entries.map(async (entry, index) => {
42
+ const reservation = reservations[index];
43
+ assertReceipt(reservation.receipt, entry);
44
+ if (reservation.action === 'reconcile-existing') {
45
+ return assertReceipt(await ports.reconcileExisting(entry, reservation), entry);
46
+ }
47
+ const launched = await ports.launch(entry);
48
+ return assertReceipt(await ports.recordSpawned(entry, reservation, launched), entry);
49
+ }));
50
+ let settlement;
51
+ try {
52
+ settlement = await Promise.any(started.map((receipt, index) => ports.awaitSettlement(entries[index], receipt, { maxPolls: NATIVE_BACKGROUND_MAX_POLLS, ...(options.signal ? { signal: options.signal } : {}) }).then((candidate) => {
53
+ const accepted = assertReceipt(candidate, entries[index]);
54
+ if (!NATIVE_AGENT_TERMINAL_STATES.has(accepted.state)) {
55
+ throw new NativeBackgroundRootError(NATIVE_BACKGROUND_REASON_CODES.SETTLEMENT_INVALID);
56
+ }
57
+ return accepted;
58
+ })));
59
+ }
60
+ catch {
61
+ throw new NativeBackgroundRootError(NATIVE_BACKGROUND_REASON_CODES.SETTLEMENT_INVALID);
62
+ }
63
+ return Object.freeze({
64
+ kind: 'settled',
65
+ settlement,
66
+ started: Object.freeze([...started]),
67
+ publicSafe: true,
68
+ });
69
+ }
70
+ /** Sequential by construction: at most one poll is in flight for one dispatch. */
71
+ export async function boundedNativeBackgroundPoll(poll, options = {}) {
72
+ const maxPolls = Math.max(1, Math.min(NATIVE_BACKGROUND_MAX_POLLS, options.maxPolls ?? NATIVE_BACKGROUND_MAX_POLLS));
73
+ let last = null;
74
+ let polls = 0;
75
+ for (let attempt = 1; attempt <= maxPolls; attempt += 1) {
76
+ if (options.signal?.aborted)
77
+ break;
78
+ last = await poll(attempt);
79
+ polls = attempt;
80
+ if (last && NATIVE_AGENT_TERMINAL_STATES.has(last.state)) {
81
+ return Object.freeze({ receipt: last, polls, exhausted: false });
82
+ }
83
+ }
84
+ return Object.freeze({ receipt: last, polls, exhausted: polls >= maxPolls });
85
+ }
@@ -1 +1,79 @@
1
- import{createRejectedExecutionResult as c,createUnavailableExecutionResult as m,normalizeHeadlessCommandResult as l,runHeadlessCommand as v,validateHeadlessAdapterExecutionInput as s}from"./types.js";import{checkRuntimeAvailability as f}from"./opencode-adapter.js";import{governedPreflightFailureResult as C,preflightManagedHeadlessProfile as I,withGovernedHeadlessEvidence as u}from"./managed-profile.js";const a="claude-code",o="claude",b="neocortex";function y(){return{id:a,displayName:"Claude Code Headless Adapter",async checkAvailability(i={}){return f(a,o,i,{realpathBasenamePolicy:"claude-code-versioned",versionEvidence:"claude-code"})},buildInvocation(i){const e=s(i,a);return e.ok?{ok:!0,invocation:{adapterId:a,commandName:o,args:h(e.prompt,e.input.modelId),promptHash:e.promptHash,...e.input.modelId?{modelId:e.input.modelId}:{},timeoutMs:e.input.timeoutMs??600*1e3,publicSafe:!0},publicSafe:!0}:e},async execute(i,e={}){const t=s(i,a);if(!t.ok)return c(a,a,t);const d=I(a,e);if(!d.ok)return C(a,t.input,d);if(e.signal?.aborted)return u(l(a,t.input,{exitCode:null,signal:"SIGTERM",timedOut:!1,cancelled:!0,durationMs:0,stdout:"",stderr:"",stdoutBytes:0,stderrBytes:0}));const r=await this.checkAvailability(e);if(!r.ok)return u(m(a,t.input,r));const n=this.buildInvocation(t.input);if(!n.ok)return c(a,a,n);const p=await(e.commandRunner??v)(r.executablePath??o,n.invocation.args,{cwd:e.cwd,env:e.env,timeoutMs:n.invocation.timeoutMs,maxOutputBytes:e.maxOutputBytes,signal:e.signal,...t.input.receipt?.jobId?{localConsole:{projectRoot:e.cwd,jobId:t.input.receipt.jobId,attemptId:t.input.receipt.attemptId,executionId:t.input.receipt.executionId,publicSafe:!0}}:{}});return u(l(a,t.input,p))}}}function h(i,e){const t=["--agent",b];return e&&t.push("--model",e),t.push("-p",i),t}export{y as createClaudeCodeHeadlessAdapter};
1
+ /**
2
+ * @license FSL-1.1
3
+ * Copyright (c) 2026 OrNexus AI
4
+ *
5
+ * P190.04 -- trusted Claude Code headless adapter interface.
6
+ */
7
+ import { createRejectedExecutionResult, createUnavailableExecutionResult, normalizeHeadlessCommandResult, runHeadlessCommand, validateHeadlessAdapterExecutionInput, } from './types.js';
8
+ import { checkRuntimeAvailability } from './opencode-adapter.js';
9
+ import { governedPreflightFailureResult, preflightManagedHeadlessProfile, withGovernedHeadlessEvidence, } from './managed-profile.js';
10
+ const CLAUDE_CODE_ADAPTER_ID = 'claude-code';
11
+ const CLAUDE_CODE_COMMAND = 'claude';
12
+ const CLAUDE_CODE_AGENT_PROFILE = 'neocortex';
13
+ export function createClaudeCodeHeadlessAdapter() {
14
+ return {
15
+ id: CLAUDE_CODE_ADAPTER_ID,
16
+ displayName: 'Claude Code Headless Adapter',
17
+ async checkAvailability(options = {}) {
18
+ return checkRuntimeAvailability(CLAUDE_CODE_ADAPTER_ID, CLAUDE_CODE_COMMAND, options, {
19
+ realpathBasenamePolicy: 'claude-code-versioned',
20
+ versionEvidence: 'claude-code',
21
+ });
22
+ },
23
+ buildInvocation(input) {
24
+ const validation = validateHeadlessAdapterExecutionInput(input, CLAUDE_CODE_ADAPTER_ID);
25
+ if (!validation.ok)
26
+ return validation;
27
+ return {
28
+ ok: true,
29
+ invocation: {
30
+ adapterId: CLAUDE_CODE_ADAPTER_ID,
31
+ commandName: CLAUDE_CODE_COMMAND,
32
+ args: buildClaudeCodeArgs(validation.prompt, validation.input.modelId),
33
+ promptHash: validation.promptHash,
34
+ ...(validation.input.modelId ? { modelId: validation.input.modelId } : {}),
35
+ timeoutMs: validation.input.timeoutMs ?? 10 * 60 * 1000,
36
+ publicSafe: true,
37
+ },
38
+ publicSafe: true,
39
+ };
40
+ },
41
+ async execute(input, options = {}) {
42
+ const validation = validateHeadlessAdapterExecutionInput(input, CLAUDE_CODE_ADAPTER_ID);
43
+ if (!validation.ok)
44
+ return createRejectedExecutionResult(CLAUDE_CODE_ADAPTER_ID, CLAUDE_CODE_ADAPTER_ID, validation);
45
+ const preflight = preflightManagedHeadlessProfile(CLAUDE_CODE_ADAPTER_ID, options);
46
+ if (!preflight.ok)
47
+ return governedPreflightFailureResult(CLAUDE_CODE_ADAPTER_ID, validation.input, preflight);
48
+ if (options.signal?.aborted) {
49
+ return withGovernedHeadlessEvidence(normalizeHeadlessCommandResult(CLAUDE_CODE_ADAPTER_ID, validation.input, {
50
+ exitCode: null, signal: 'SIGTERM', timedOut: false, cancelled: true, durationMs: 0,
51
+ stdout: '', stderr: '', stdoutBytes: 0, stderrBytes: 0,
52
+ }));
53
+ }
54
+ const availability = await this.checkAvailability(options);
55
+ if (!availability.ok)
56
+ return withGovernedHeadlessEvidence(createUnavailableExecutionResult(CLAUDE_CODE_ADAPTER_ID, validation.input, availability));
57
+ const invocation = this.buildInvocation(validation.input);
58
+ if (!invocation.ok)
59
+ return createRejectedExecutionResult(CLAUDE_CODE_ADAPTER_ID, CLAUDE_CODE_ADAPTER_ID, invocation);
60
+ const runner = options.commandRunner ?? runHeadlessCommand;
61
+ const result = await runner(availability.executablePath ?? CLAUDE_CODE_COMMAND, invocation.invocation.args, {
62
+ cwd: options.cwd,
63
+ env: options.env,
64
+ timeoutMs: invocation.invocation.timeoutMs,
65
+ maxOutputBytes: options.maxOutputBytes,
66
+ signal: options.signal,
67
+ ...(validation.input.receipt?.jobId ? { localConsole: { projectRoot: options.cwd, jobId: validation.input.receipt.jobId, attemptId: validation.input.receipt.attemptId, executionId: validation.input.receipt.executionId, publicSafe: true } } : {}),
68
+ });
69
+ return withGovernedHeadlessEvidence(normalizeHeadlessCommandResult(CLAUDE_CODE_ADAPTER_ID, validation.input, result));
70
+ },
71
+ };
72
+ }
73
+ function buildClaudeCodeArgs(prompt, modelId) {
74
+ const args = ['--agent', CLAUDE_CODE_AGENT_PROFILE];
75
+ if (modelId)
76
+ args.push('--model', modelId);
77
+ args.push('-p', prompt);
78
+ return args;
79
+ }