@ornexus/neocortex 4.61.4 → 4.61.6

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 (254) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1193 -1193
  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 +1 -108
  7. package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
  8. package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
  9. package/packages/client/dist/adapters/codex-adapter.js +2 -80
  10. package/packages/client/dist/adapters/cursor-adapter.js +4 -115
  11. package/packages/client/dist/adapters/gemini-adapter.js +2 -71
  12. package/packages/client/dist/adapters/grok-adapter.js +2 -42
  13. package/packages/client/dist/adapters/index.js +1 -22
  14. package/packages/client/dist/adapters/platform-detector.js +1 -220
  15. package/packages/client/dist/adapters/target-adapter.js +0 -12
  16. package/packages/client/dist/adapters/vscode-adapter.js +2 -72
  17. package/packages/client/dist/agent/refresh-stubs.js +2 -443
  18. package/packages/client/dist/agent/update-agent-yaml.js +1 -102
  19. package/packages/client/dist/agent/update-description.js +1 -260
  20. package/packages/client/dist/cache/crypto-utils.js +1 -78
  21. package/packages/client/dist/cache/encrypted-cache.js +1 -338
  22. package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
  23. package/packages/client/dist/cache/index.js +1 -13
  24. package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
  25. package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
  26. package/packages/client/dist/checkpoint/index.js +1 -11
  27. package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
  28. package/packages/client/dist/cli.js +5 -364
  29. package/packages/client/dist/commands/activate.js +8 -394
  30. package/packages/client/dist/commands/architecture-answers.js +7 -274
  31. package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
  32. package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
  33. package/packages/client/dist/commands/architecture-root-binding.js +1 -51
  34. package/packages/client/dist/commands/cache-status.js +2 -112
  35. package/packages/client/dist/commands/config.js +1 -88
  36. package/packages/client/dist/commands/doctor.js +2 -635
  37. package/packages/client/dist/commands/invoke.js +148 -7822
  38. package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
  39. package/packages/client/dist/commands/legacy-story-branch.js +1 -96
  40. package/packages/client/dist/commands/legacy-story-pr.js +1 -276
  41. package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
  42. package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
  43. package/packages/client/dist/commands/mutation-qa-git.js +1 -41
  44. package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
  45. package/packages/client/dist/commands/mutation-qa-run.js +3 -219
  46. package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
  47. package/packages/client/dist/commands/mutation-qa.js +1 -220
  48. package/packages/client/dist/commands/native-agent.js +2 -136
  49. package/packages/client/dist/commands/planning-diagnosis.js +1 -43
  50. package/packages/client/dist/commands/planning-generation.js +1 -53
  51. package/packages/client/dist/commands/planning-memory.js +1 -40
  52. package/packages/client/dist/commands/planning-research.js +1 -42
  53. package/packages/client/dist/commands/private-session.js +1 -75
  54. package/packages/client/dist/commands/property-qa.js +1 -139
  55. package/packages/client/dist/commands/qa-control.js +1 -16
  56. package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
  57. package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
  58. package/packages/client/dist/commands/qa-scan-capture.js +5 -663
  59. package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
  60. package/packages/client/dist/commands/qa-scan-review.js +5 -826
  61. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
  62. package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
  63. package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
  64. package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
  65. package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
  66. package/packages/client/dist/commands/refactor-characterization.js +21 -671
  67. package/packages/client/dist/commands/refactor-commit.js +13 -399
  68. package/packages/client/dist/commands/refactor-control.js +3 -142
  69. package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
  70. package/packages/client/dist/commands/refactor-review.js +5 -283
  71. package/packages/client/dist/commands/refactor-root.js +7 -588
  72. package/packages/client/dist/commands/refresh-memory.js +3 -174
  73. package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
  74. package/packages/client/dist/commands/story-checkpoint.d.ts +5 -1
  75. package/packages/client/dist/commands/story-checkpoint.js +1 -203
  76. package/packages/client/dist/commands/story-worktree.js +5 -258
  77. package/packages/client/dist/config/host-auth-broker.js +1 -60
  78. package/packages/client/dist/config/host-auth-reference.js +1 -93
  79. package/packages/client/dist/config/profile-directory.js +1 -13
  80. package/packages/client/dist/config/resolver-selection.js +1 -278
  81. package/packages/client/dist/config/secure-config.js +12 -281
  82. package/packages/client/dist/config.js +2 -224
  83. package/packages/client/dist/constants.js +1 -25
  84. package/packages/client/dist/context/context-collector.js +2 -222
  85. package/packages/client/dist/context/context-sanitizer.js +1 -145
  86. package/packages/client/dist/continuity/autonomous-governance.js +1 -285
  87. package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
  88. package/packages/client/dist/continuity/invoke-hooks.js +1 -129
  89. package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
  90. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
  91. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
  92. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
  93. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
  94. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
  95. package/packages/client/dist/continuity/native-agent-store.js +1 -69
  96. package/packages/client/dist/continuity/native-agent-types.js +1 -105
  97. package/packages/client/dist/continuity/outbox.js +1 -117
  98. package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
  99. package/packages/client/dist/continuity/sqlite-store.js +81 -2612
  100. package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
  101. package/packages/client/dist/errors/error-messages.js +2 -258
  102. package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
  103. package/packages/client/dist/evidence/collector.js +1 -347
  104. package/packages/client/dist/evidence/index.js +1 -1
  105. package/packages/client/dist/evidence/types.js +0 -2
  106. package/packages/client/dist/fs/atomic-state-replace.js +1 -152
  107. package/packages/client/dist/generated/command-registry.generated.js +1 -4076
  108. package/packages/client/dist/generated/public-projections.generated.js +1 -149
  109. package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
  110. package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +70 -0
  111. package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -1592
  112. package/packages/client/dist/git/epic-operational-state.js +2 -672
  113. package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
  114. package/packages/client/dist/git/git-lifecycle-store.d.ts +22 -0
  115. package/packages/client/dist/git/git-lifecycle-store.js +8 -2500
  116. package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
  117. package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
  118. package/packages/client/dist/git/legacy-story-pr.js +70 -3538
  119. package/packages/client/dist/git/neocortex-trailers.js +2 -53
  120. package/packages/client/dist/git/secure-filesystem-boundary.js +5 -182
  121. package/packages/client/dist/git/story-worktree-cleanup.js +4 -1058
  122. package/packages/client/dist/git/story-worktree-integration.d.ts +62 -0
  123. package/packages/client/dist/git/story-worktree-integration.js +3 -603
  124. package/packages/client/dist/git/story-worktree-manager.js +3 -843
  125. package/packages/client/dist/git/story-worktree-paths.js +1 -150
  126. package/packages/client/dist/git/story-write-set-extension.d.ts +44 -0
  127. package/packages/client/dist/git/story-write-set-extension.js +1 -0
  128. package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
  129. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
  130. package/packages/client/dist/i18n/first-run.js +2 -60
  131. package/packages/client/dist/index.js +1 -50
  132. package/packages/client/dist/invocation/invoke-input.js +1 -24
  133. package/packages/client/dist/license/host-auth-recovery.js +1 -401
  134. package/packages/client/dist/license/index.js +1 -5
  135. package/packages/client/dist/license/license-client.js +1 -337
  136. package/packages/client/dist/machine/fingerprint.js +2 -163
  137. package/packages/client/dist/machine/index.js +1 -5
  138. package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
  139. package/packages/client/dist/memory/project-memory-writer.js +41 -1117
  140. package/packages/client/dist/memory/shared-project-memory-types.js +2 -259
  141. package/packages/client/dist/migrations/epic-lifecycle-backfill.js +3 -1060
  142. package/packages/client/dist/migrations/project-identity-capability.js +1 -50
  143. package/packages/client/dist/migrations/project-identity.js +7 -493
  144. package/packages/client/dist/migrations/state-json.js +4 -393
  145. package/packages/client/dist/policy/architecture-policy.js +2 -184
  146. package/packages/client/dist/policy/index.js +1 -7
  147. package/packages/client/dist/policy/shared-policy-types.js +0 -38
  148. package/packages/client/dist/policy/subagent-approval-policy.js +1 -57
  149. package/packages/client/dist/private-execution/clean-baseline.js +2 -279
  150. package/packages/client/dist/private-execution/codex-executor.js +4 -574
  151. package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
  152. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
  153. package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
  154. package/packages/client/dist/private-execution/delivery.js +13 -410
  155. package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
  156. package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
  157. package/packages/client/dist/private-execution/implementation-validation.js +2 -106
  158. package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
  159. package/packages/client/dist/private-execution/isolated-session.js +5 -725
  160. package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
  161. package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
  162. package/packages/client/dist/private-execution/pact-test-source.js +1 -258
  163. package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
  164. package/packages/client/dist/private-execution/pact-write-set.js +1 -172
  165. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
  166. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
  167. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
  168. package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
  169. package/packages/client/dist/private-execution/private-report-store.js +1 -42
  170. package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
  171. package/packages/client/dist/private-execution/property-test-choices.js +3 -147
  172. package/packages/client/dist/private-execution/property-test-plan.js +7 -271
  173. package/packages/client/dist/private-execution/property-test-review.js +4 -258
  174. package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
  175. package/packages/client/dist/private-execution/property-test-source.js +1 -139
  176. package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
  177. package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
  178. package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
  179. package/packages/client/dist/private-execution/root-memory-request.js +1 -29
  180. package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
  181. package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
  182. package/packages/client/dist/private-execution/session-lease.js +1 -63
  183. package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
  184. package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
  185. package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
  186. package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
  187. package/packages/client/dist/private-execution/ux-write-set.js +2 -191
  188. package/packages/client/dist/registry/registry-reconciliation.js +1 -234
  189. package/packages/client/dist/resilience/circuit-breaker.js +1 -170
  190. package/packages/client/dist/resilience/degradation-manager.js +1 -164
  191. package/packages/client/dist/resilience/freshness-indicator.js +1 -100
  192. package/packages/client/dist/resilience/index.js +1 -8
  193. package/packages/client/dist/resilience/recovery-detector.js +1 -74
  194. package/packages/client/dist/resolvers/asset-resolver.js +0 -13
  195. package/packages/client/dist/resolvers/local-resolver.js +8 -255
  196. package/packages/client/dist/resolvers/remote-resolver.js +1 -233
  197. package/packages/client/dist/runner/binary.js +1 -404
  198. package/packages/client/dist/runner/cli.js +17 -1571
  199. package/packages/client/dist/runner/epic-background-dispatcher.js +1 -124
  200. package/packages/client/dist/runner/headless/adapters.js +1 -49
  201. package/packages/client/dist/runner/headless/background-root.js +1 -85
  202. package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
  203. package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1776
  204. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
  205. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -111
  206. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +10 -1464
  207. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -357
  208. package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
  209. package/packages/client/dist/runner/headless/managed-environment-cleanup.js +1 -274
  210. package/packages/client/dist/runner/headless/managed-profile.js +1 -149
  211. package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
  212. package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
  213. package/packages/client/dist/runner/headless/resolver.js +1 -231
  214. package/packages/client/dist/runner/headless/run-yolo.js +1 -886
  215. package/packages/client/dist/runner/headless/run-yoloop.js +2 -2657
  216. package/packages/client/dist/runner/headless/types.js +2 -575
  217. package/packages/client/dist/runner/host-capacity.js +1 -59
  218. package/packages/client/dist/runner/local-console.js +13 -396
  219. package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
  220. package/packages/client/dist/runner/project-identity.js +1 -106
  221. package/packages/client/dist/runner/scheduler.js +7 -995
  222. package/packages/client/dist/runner-cli.js +2 -18
  223. package/packages/client/dist/state/invocation-shape.js +1 -13
  224. package/packages/client/dist/state/project-state-snapshot.js +1 -1754
  225. package/packages/client/dist/state/state-json-repair.js +3 -785
  226. package/packages/client/dist/state/structural-dag-projection.js +1 -118
  227. package/packages/client/dist/telemetry/index.js +1 -5
  228. package/packages/client/dist/telemetry/offline-queue.js +1 -131
  229. package/packages/client/dist/tier/index.js +1 -5
  230. package/packages/client/dist/tier/tier-aware-client.js +1 -405
  231. package/packages/client/dist/types/index.js +1 -38
  232. package/packages/client/dist/version.js +1 -27
  233. package/packages/client/dist/yolo/change-evidence-collector.d.ts +10 -0
  234. package/packages/client/dist/yolo/change-evidence-collector.js +1 -245
  235. package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -65
  236. package/packages/client/dist/yolo/spec-envelope-collector.js +5 -184
  237. package/packages/client/dist/yoloop/discovery-hook.js +2 -300
  238. package/packages/client/dist/yoloop/index.js +1 -8
  239. package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
  240. package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
  241. package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
  242. package/packages/client/dist/yoloop/target-normalization.js +1 -180
  243. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1920
  244. package/targets-stubs/antigravity/gemini.md +1 -1
  245. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  246. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  247. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  248. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  249. package/targets-stubs/claude-code/neocortex.md +2 -2
  250. package/targets-stubs/codex/AGENTS.md +1 -1
  251. package/targets-stubs/cursor/agent.md +2 -2
  252. package/targets-stubs/gemini-cli/agent.md +2 -2
  253. package/targets-stubs/opencode/neocortex-root.md +1 -1
  254. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1,124 +1 @@
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
+ 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,49 +1 @@
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
+ 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,85 +1 @@
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
+ 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,79 +1 @@
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
- }
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};