@ornexus/neocortex 4.60.71 → 4.60.73

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 (243) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1211 -1217
  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 +212 -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 +417 -2
  18. package/packages/client/dist/agent/update-agent-yaml.js +102 -1
  19. package/packages/client/dist/agent/update-description.js +251 -1
  20. package/packages/client/dist/cache/crypto-utils.js +78 -1
  21. package/packages/client/dist/cache/encrypted-cache.js +108 -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 +7200 -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.js +156 -3
  73. package/packages/client/dist/commands/shared-architecture-non-ui.js +24 -1
  74. package/packages/client/dist/commands/story-checkpoint.js +171 -1
  75. package/packages/client/dist/config/profile-directory.js +13 -1
  76. package/packages/client/dist/config/resolver-selection.js +278 -1
  77. package/packages/client/dist/config/secure-config.js +281 -12
  78. package/packages/client/dist/config.js +223 -2
  79. package/packages/client/dist/constants.js +25 -1
  80. package/packages/client/dist/context/context-collector.js +222 -2
  81. package/packages/client/dist/context/context-sanitizer.js +145 -1
  82. package/packages/client/dist/continuity/autonomous-governance.js +285 -1
  83. package/packages/client/dist/continuity/continuity-client-state-store.js +1587 -1
  84. package/packages/client/dist/continuity/invoke-hooks.js +129 -1
  85. package/packages/client/dist/continuity/migrations/001-initial-schema.js +12 -2
  86. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +12 -2
  87. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +12 -2
  88. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +12 -2
  89. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +12 -2
  90. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +10 -2
  91. package/packages/client/dist/continuity/native-agent-store.js +69 -1
  92. package/packages/client/dist/continuity/native-agent-types.js +90 -1
  93. package/packages/client/dist/continuity/outbox.js +117 -1
  94. package/packages/client/dist/continuity/runner-bootstrap-policy.js +172 -1
  95. package/packages/client/dist/continuity/sqlite-store.d.ts +22 -1
  96. package/packages/client/dist/continuity/sqlite-store.js +2612 -81
  97. package/packages/client/dist/effects/invoke-effect-gateways.js +62 -1
  98. package/packages/client/dist/errors/error-messages.js +228 -2
  99. package/packages/client/dist/errors/frontmatter-diagnostics.js +125 -1
  100. package/packages/client/dist/evidence/collector.js +347 -1
  101. package/packages/client/dist/evidence/index.js +1 -1
  102. package/packages/client/dist/evidence/types.js +2 -0
  103. package/packages/client/dist/fs/atomic-state-replace.js +152 -1
  104. package/packages/client/dist/generated/command-registry.generated.js +4076 -1
  105. package/packages/client/dist/generated/public-projections.generated.js +149 -1
  106. package/packages/client/dist/git/direct-yolo-c01-retry.js +138 -4
  107. package/packages/client/dist/git/direct-yolo-checkpoint.js +1234 -4
  108. package/packages/client/dist/git/epic-operational-state.d.ts +198 -0
  109. package/packages/client/dist/git/epic-operational-state.js +672 -0
  110. package/packages/client/dist/git/git-lifecycle-step-ids.js +14 -1
  111. package/packages/client/dist/git/git-lifecycle-store.d.ts +9 -1
  112. package/packages/client/dist/git/git-lifecycle-store.js +1981 -9
  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/secure-filesystem-boundary.js +182 -5
  117. package/packages/client/dist/graph-retrieval/pre-command-hook.js +284 -1
  118. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +237 -1
  119. package/packages/client/dist/i18n/first-run.js +60 -2
  120. package/packages/client/dist/index.js +47 -1
  121. package/packages/client/dist/invocation/invoke-input.js +24 -1
  122. package/packages/client/dist/license/index.js +5 -1
  123. package/packages/client/dist/license/license-client.js +304 -1
  124. package/packages/client/dist/machine/fingerprint.js +163 -2
  125. package/packages/client/dist/machine/index.js +5 -1
  126. package/packages/client/dist/memory/project-memory-path-scope.js +62 -1
  127. package/packages/client/dist/memory/project-memory-writer.js +1007 -40
  128. package/packages/client/dist/memory/shared-project-memory-types.js +253 -2
  129. package/packages/client/dist/migrations/epic-lifecycle-backfill.d.ts +97 -0
  130. package/packages/client/dist/migrations/epic-lifecycle-backfill.js +1060 -0
  131. package/packages/client/dist/migrations/project-identity-capability.js +50 -1
  132. package/packages/client/dist/migrations/project-identity.js +493 -7
  133. package/packages/client/dist/migrations/state-json.d.ts +22 -0
  134. package/packages/client/dist/migrations/state-json.js +393 -4
  135. package/packages/client/dist/policy/architecture-policy.js +184 -2
  136. package/packages/client/dist/policy/index.js +7 -1
  137. package/packages/client/dist/policy/shared-policy-types.js +38 -0
  138. package/packages/client/dist/policy/subagent-approval-policy.js +55 -1
  139. package/packages/client/dist/private-execution/clean-baseline.js +279 -2
  140. package/packages/client/dist/private-execution/codex-executor.js +574 -4
  141. package/packages/client/dist/private-execution/codex-host-runtime.js +137 -1
  142. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +97 -1
  143. package/packages/client/dist/private-execution/codex-scoped-permissions.js +128 -1
  144. package/packages/client/dist/private-execution/delivery.js +410 -13
  145. package/packages/client/dist/private-execution/diagnosis-root-review.js +294 -2
  146. package/packages/client/dist/private-execution/frozen-handoff.js +19 -6
  147. package/packages/client/dist/private-execution/implementation-validation.js +106 -2
  148. package/packages/client/dist/private-execution/isolated-admission.js +1432 -23
  149. package/packages/client/dist/private-execution/isolated-session.js +725 -5
  150. package/packages/client/dist/private-execution/isolated-workspace.js +122 -1
  151. package/packages/client/dist/private-execution/pact-consumer-runtime.js +409 -3
  152. package/packages/client/dist/private-execution/pact-test-source.js +258 -1
  153. package/packages/client/dist/private-execution/pact-toolchain.js +290 -3
  154. package/packages/client/dist/private-execution/pact-write-set.js +172 -1
  155. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +406 -5
  156. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +462 -5
  157. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +139 -3
  158. package/packages/client/dist/private-execution/planning-research-checkpoint.js +325 -4
  159. package/packages/client/dist/private-execution/private-report-store.js +42 -1
  160. package/packages/client/dist/private-execution/property-test-candidate.js +103 -1
  161. package/packages/client/dist/private-execution/property-test-choices.js +147 -3
  162. package/packages/client/dist/private-execution/property-test-plan.js +271 -7
  163. package/packages/client/dist/private-execution/property-test-review.js +258 -4
  164. package/packages/client/dist/private-execution/property-test-runtime.js +372 -9
  165. package/packages/client/dist/private-execution/property-test-source.js +139 -1
  166. package/packages/client/dist/private-execution/root-checkpoint.js +80 -1
  167. package/packages/client/dist/private-execution/root-memory-git-evidence.js +135 -3
  168. package/packages/client/dist/private-execution/root-memory-recovery.js +93 -1
  169. package/packages/client/dist/private-execution/root-memory-request.js +29 -1
  170. package/packages/client/dist/private-execution/root-memory-scope.js +178 -1
  171. package/packages/client/dist/private-execution/root-memory-writer.js +102 -1
  172. package/packages/client/dist/private-execution/session-lease.js +63 -1
  173. package/packages/client/dist/private-execution/shared-private-admission-types.js +50 -1
  174. package/packages/client/dist/private-execution/shared-project-validation.js +66 -1
  175. package/packages/client/dist/private-execution/shared-root-memory-types.js +61 -1
  176. package/packages/client/dist/private-execution/ux-source-validation.js +372 -1
  177. package/packages/client/dist/private-execution/ux-write-set.js +191 -2
  178. package/packages/client/dist/registry/registry-reconciliation.js +234 -1
  179. package/packages/client/dist/resilience/circuit-breaker.js +170 -1
  180. package/packages/client/dist/resilience/degradation-manager.js +164 -1
  181. package/packages/client/dist/resilience/freshness-indicator.js +100 -1
  182. package/packages/client/dist/resilience/index.js +8 -1
  183. package/packages/client/dist/resilience/recovery-detector.js +74 -1
  184. package/packages/client/dist/resolvers/asset-resolver.js +13 -0
  185. package/packages/client/dist/resolvers/local-resolver.js +255 -8
  186. package/packages/client/dist/resolvers/remote-resolver.js +233 -1
  187. package/packages/client/dist/runner/binary.js +404 -1
  188. package/packages/client/dist/runner/cli.js +1571 -17
  189. package/packages/client/dist/runner/headless/adapters.js +49 -1
  190. package/packages/client/dist/runner/headless/claude-code-adapter.js +79 -1
  191. package/packages/client/dist/runner/headless/continuous-story-workspace.js +1628 -11
  192. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +69 -1
  193. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +110 -2
  194. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +1236 -8
  195. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +318 -2
  196. package/packages/client/dist/runner/headless/fake-adapter.js +62 -1
  197. package/packages/client/dist/runner/headless/managed-profile.js +132 -1
  198. package/packages/client/dist/runner/headless/opencode-adapter.js +145 -2
  199. package/packages/client/dist/runner/headless/prepared-story-bundle.js +43 -1
  200. package/packages/client/dist/runner/headless/resolver.js +231 -1
  201. package/packages/client/dist/runner/headless/run-yolo.js +885 -1
  202. package/packages/client/dist/runner/headless/run-yoloop.js +2574 -2
  203. package/packages/client/dist/runner/headless/types.js +574 -2
  204. package/packages/client/dist/runner/local-console.js +396 -13
  205. package/packages/client/dist/runner/portal-sync-worker.js +1487 -1
  206. package/packages/client/dist/runner/project-identity.js +106 -1
  207. package/packages/client/dist/runner/scheduler.js +995 -7
  208. package/packages/client/dist/runner-cli.js +18 -2
  209. package/packages/client/dist/state/invocation-shape.js +13 -1
  210. package/packages/client/dist/state/project-state-snapshot.d.ts +8 -0
  211. package/packages/client/dist/state/project-state-snapshot.js +1731 -1
  212. package/packages/client/dist/state/state-json-repair.js +785 -3
  213. package/packages/client/dist/state/structural-dag-projection.js +118 -1
  214. package/packages/client/dist/telemetry/index.js +5 -1
  215. package/packages/client/dist/telemetry/offline-queue.js +131 -1
  216. package/packages/client/dist/tier/index.js +5 -1
  217. package/packages/client/dist/tier/tier-aware-client.js +405 -1
  218. package/packages/client/dist/types/index.js +38 -1
  219. package/packages/client/dist/version.js +27 -1
  220. package/packages/client/dist/yolo/change-evidence-collector.js +126 -1
  221. package/packages/client/dist/yolo/invoke-envelope-capability.js +62 -1
  222. package/packages/client/dist/yolo/spec-envelope-collector.js +184 -5
  223. package/packages/client/dist/yoloop/discovery-hook.js +300 -2
  224. package/packages/client/dist/yoloop/index.js +8 -1
  225. package/packages/client/dist/yoloop/invoke-hooks.js +669 -12
  226. package/packages/client/dist/yoloop/shared-discover-epics.js +1007 -1
  227. package/packages/client/dist/yoloop/shared-yoloop-types.d.ts +65 -1
  228. package/packages/client/dist/yoloop/shared-yoloop-types.js +33 -1
  229. package/packages/client/dist/yoloop/target-normalization.js +180 -1
  230. package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +8 -0
  231. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1920 -1
  232. package/packages/shared/dist/yolo/spec-envelope.js +3 -6
  233. package/targets-stubs/antigravity/gemini.md +1 -1
  234. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  235. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  236. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  237. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  238. package/targets-stubs/claude-code/neocortex.md +2 -2
  239. package/targets-stubs/codex/AGENTS.md +1 -1
  240. package/targets-stubs/cursor/agent.md +2 -2
  241. package/targets-stubs/gemini-cli/agent.md +2 -2
  242. package/targets-stubs/opencode/neocortex-root.md +1 -1
  243. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1 +1,118 @@
1
- class c extends Error{code;publicDetails;constructor(t,o){super(t),this.code=t,this.publicDetails=o,this.name="StructuralDagError"}}const g=1e4,m=5e4,U=1024,h=192*1024;function w(s){if(s.depends_on===void 0)return[];if(!Array.isArray(s.depends_on)||s.depends_on.some(t=>typeof t!="string"||t.length===0))throw new c("STRUCTURAL_DEPENDENCY_MISSING",{nodes:0,edges:0,malformedDependencies:1});return[...new Set(s.depends_on)].sort((t,o)=>t.localeCompare(o,"en"))}function L(s,t,o={}){const a=o.maxNodes??g,E=o.maxEdges??m,D=o.maxDepth??U,f=o.maxBytes??h,T=new Map,p=[];let n=0,r=0,_=0,i=0;const l=(e,d)=>{const u=T.get(e)??0;if(u===2)return;if(u===1)throw new c("STRUCTURAL_DEPENDENCY_CYCLE",{nodes:r,edges:n,cycles:1});const A=s[e];if(!A)throw new c("STRUCTURAL_DEPENDENCY_MISSING",{nodes:r,edges:n,missingDependencies:1});if(d>D)throw new c("STRUCTURAL_CONTEXT_TOO_LARGE",{nodes:r,edges:n,maxDepth:D,observedDepth:d});T.set(e,1),r+=1,i=Math.max(i,d);const C=w(A);if(_+=Buffer.byteLength(JSON.stringify({id:e,depends_on:C}),"utf8"),r>a)throw new c("STRUCTURAL_CONTEXT_TOO_LARGE",{nodes:r,edges:n,maxNodes:a,maxEdges:E});if(_>f)throw new c("STRUCTURAL_CONTEXT_TOO_LARGE",{nodes:r,edges:n,structuralBytes:_,maxBytes:f});for(const S of C){if(n+=1,n>E)throw new c("STRUCTURAL_CONTEXT_TOO_LARGE",{nodes:r,edges:n,maxNodes:a,maxEdges:E});l(S,d+1)}T.set(e,2),p.push(e)},R=t===void 0?Object.keys(s).sort((e,d)=>e.localeCompare(d,"en")):[...new Set(t)].sort((e,d)=>e.localeCompare(d,"en"));for(const e of R)l(e,1);return Object.freeze({orderedIds:Object.freeze(p),edgeCount:n,structuralBytes:_,maxDepth:i})}export{c as StructuralDagError,L as analyzeDependencyDag};
1
+ export class StructuralDagError extends Error {
2
+ code;
3
+ publicDetails;
4
+ constructor(code, publicDetails) {
5
+ super(code);
6
+ this.code = code;
7
+ this.publicDetails = publicDetails;
8
+ this.name = 'StructuralDagError';
9
+ }
10
+ }
11
+ const DEFAULT_MAX_NODES = 10_000;
12
+ const DEFAULT_MAX_EDGES = 50_000;
13
+ const DEFAULT_MAX_DEPTH = 1_024;
14
+ const DEFAULT_MAX_BYTES = 192 * 1024;
15
+ function dependencyIds(node) {
16
+ if (node.depends_on === undefined)
17
+ return [];
18
+ if (!Array.isArray(node.depends_on)
19
+ || node.depends_on.some((value) => typeof value !== 'string' || value.length === 0)) {
20
+ throw new StructuralDagError('STRUCTURAL_DEPENDENCY_MISSING', {
21
+ nodes: 0,
22
+ edges: 0,
23
+ malformedDependencies: 1,
24
+ });
25
+ }
26
+ return [...new Set(node.depends_on)].sort((left, right) => left.localeCompare(right, 'en'));
27
+ }
28
+ /**
29
+ * Deterministic three-colour traversal used by YOLO and yoloop projections.
30
+ * Public diagnostics expose counts only; node names can contain customer data
31
+ * and must not escape through errors or telemetry.
32
+ */
33
+ export function analyzeDependencyDag(nodes, roots, budgets = {}) {
34
+ const maxNodes = budgets.maxNodes ?? DEFAULT_MAX_NODES;
35
+ const maxEdges = budgets.maxEdges ?? DEFAULT_MAX_EDGES;
36
+ const depthBudget = budgets.maxDepth ?? DEFAULT_MAX_DEPTH;
37
+ const byteBudget = budgets.maxBytes ?? DEFAULT_MAX_BYTES;
38
+ const colors = new Map();
39
+ const orderedIds = [];
40
+ let edgeCount = 0;
41
+ let visitedCount = 0;
42
+ let structuralBytes = 0;
43
+ let observedMaxDepth = 0;
44
+ const visit = (id, depth) => {
45
+ const color = colors.get(id) ?? 0;
46
+ if (color === 2)
47
+ return;
48
+ if (color === 1) {
49
+ throw new StructuralDagError('STRUCTURAL_DEPENDENCY_CYCLE', {
50
+ nodes: visitedCount,
51
+ edges: edgeCount,
52
+ cycles: 1,
53
+ });
54
+ }
55
+ const node = nodes[id];
56
+ if (!node) {
57
+ throw new StructuralDagError('STRUCTURAL_DEPENDENCY_MISSING', {
58
+ nodes: visitedCount,
59
+ edges: edgeCount,
60
+ missingDependencies: 1,
61
+ });
62
+ }
63
+ if (depth > depthBudget) {
64
+ throw new StructuralDagError('STRUCTURAL_CONTEXT_TOO_LARGE', {
65
+ nodes: visitedCount,
66
+ edges: edgeCount,
67
+ maxDepth: depthBudget,
68
+ observedDepth: depth,
69
+ });
70
+ }
71
+ colors.set(id, 1);
72
+ visitedCount += 1;
73
+ observedMaxDepth = Math.max(observedMaxDepth, depth);
74
+ const dependencies = dependencyIds(node);
75
+ structuralBytes += Buffer.byteLength(JSON.stringify({ id, depends_on: dependencies }), 'utf8');
76
+ if (visitedCount > maxNodes) {
77
+ throw new StructuralDagError('STRUCTURAL_CONTEXT_TOO_LARGE', {
78
+ nodes: visitedCount,
79
+ edges: edgeCount,
80
+ maxNodes,
81
+ maxEdges,
82
+ });
83
+ }
84
+ if (structuralBytes > byteBudget) {
85
+ throw new StructuralDagError('STRUCTURAL_CONTEXT_TOO_LARGE', {
86
+ nodes: visitedCount,
87
+ edges: edgeCount,
88
+ structuralBytes,
89
+ maxBytes: byteBudget,
90
+ });
91
+ }
92
+ for (const dependencyId of dependencies) {
93
+ edgeCount += 1;
94
+ if (edgeCount > maxEdges) {
95
+ throw new StructuralDagError('STRUCTURAL_CONTEXT_TOO_LARGE', {
96
+ nodes: visitedCount,
97
+ edges: edgeCount,
98
+ maxNodes,
99
+ maxEdges,
100
+ });
101
+ }
102
+ visit(dependencyId, depth + 1);
103
+ }
104
+ colors.set(id, 2);
105
+ orderedIds.push(id);
106
+ };
107
+ const selectedRoots = roots === undefined
108
+ ? Object.keys(nodes).sort((left, right) => left.localeCompare(right, 'en'))
109
+ : [...new Set(roots)].sort((left, right) => left.localeCompare(right, 'en'));
110
+ for (const root of selectedRoots)
111
+ visit(root, 1);
112
+ return Object.freeze({
113
+ orderedIds: Object.freeze(orderedIds),
114
+ edgeCount,
115
+ structuralBytes,
116
+ maxDepth: observedMaxDepth,
117
+ });
118
+ }
@@ -1 +1,5 @@
1
- import{OfflineTelemetryQueue as r}from"./offline-queue.js";export{r as OfflineTelemetryQueue};
1
+ /**
2
+ * @license FSL-1.1
3
+ * Copyright (c) 2026 OrNexus AI
4
+ */
5
+ export { OfflineTelemetryQueue } from './offline-queue.js';
@@ -1 +1,131 @@
1
- import{readFile as a,writeFile as n,mkdir as r}from"node:fs/promises";import{dirname as u}from"node:path";import{join as c}from"node:path";import{homedir as o}from"node:os";const h={queueFilePath:c(o(),".neocortex",".telemetry-queue"),maxEvents:1e3,maxSizeBytes:5242880};class d{config;constructor(t){this.config={...h,...t}}async enqueue(t){try{const e=await this.loadQueue();for(e.push(t);e.length>this.config.maxEvents;)e.shift();let i=JSON.stringify(e);for(;Buffer.byteLength(i,"utf8")>this.config.maxSizeBytes&&e.length>0;)e.shift(),i=JSON.stringify(e);await this.saveQueue(e)}catch{}}async flush(t){try{const e=await this.loadQueue();return e.length===0?{sent:0,failed:0}:await t(e)?(await this.saveQueue([]),{sent:e.length,failed:0}):{sent:0,failed:e.length}}catch{return{sent:0,failed:0}}}async getStats(){try{const t=await this.loadQueue(),e=JSON.stringify(t);return{count:t.length,sizeBytes:Buffer.byteLength(e,"utf8")}}catch{return{count:0,sizeBytes:0}}}async clear(){try{await this.saveQueue([])}catch{}}async loadQueue(){try{const t=await a(this.config.queueFilePath,"utf8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}async saveQueue(t){const e=u(this.config.queueFilePath);await r(e,{recursive:!0});const i=`${this.config.queueFilePath}.tmp`;await n(i,JSON.stringify(t),"utf8");const{rename:s}=await import("node:fs/promises");await s(i,this.config.queueFilePath)}}export{d as OfflineTelemetryQueue};
1
+ /**
2
+ * @license FSL-1.1
3
+ * Copyright (c) 2026 OrNexus AI
4
+ *
5
+ * This file is part of Neocortex CLI, licensed under the
6
+ * Functional Source License, Version 1.1 (FSL-1.1).
7
+ *
8
+ * Change Date: February 20, 2029
9
+ * Change License: MIT
10
+ *
11
+ * See the LICENSE file in the project root for full license text.
12
+ */
13
+ /**
14
+ * @neocortex/client - Offline Telemetry Queue
15
+ *
16
+ * Persistent FIFO queue for telemetry events when the CLI operates offline.
17
+ * Events are stored in a JSON file and flushed when connection is restored.
18
+ * Respects configurable limits on event count (1000) and file size (5MB).
19
+ *
20
+ * Story 42.9
21
+ */
22
+ import { readFile, writeFile, mkdir } from 'node:fs/promises';
23
+ import { dirname } from 'node:path';
24
+ import { join } from 'node:path';
25
+ import { homedir } from 'node:os';
26
+ // ── Defaults ──────────────────────────────────────────────────────────────
27
+ const DEFAULT_CONFIG = {
28
+ queueFilePath: join(homedir(), '.neocortex', '.telemetry-queue'),
29
+ maxEvents: 1_000,
30
+ maxSizeBytes: 5_242_880, // 5MB
31
+ };
32
+ // ── OfflineTelemetryQueue ────────────────────────────────────────────────
33
+ export class OfflineTelemetryQueue {
34
+ config;
35
+ constructor(config) {
36
+ this.config = { ...DEFAULT_CONFIG, ...config };
37
+ }
38
+ /**
39
+ * Add a telemetry event to the queue.
40
+ * Evicts oldest events if limits are reached.
41
+ */
42
+ async enqueue(event) {
43
+ try {
44
+ const events = await this.loadQueue();
45
+ events.push(event);
46
+ // Evict oldest events if count limit exceeded
47
+ while (events.length > this.config.maxEvents) {
48
+ events.shift();
49
+ }
50
+ // Evict oldest events if size limit exceeded
51
+ let serialized = JSON.stringify(events);
52
+ while (Buffer.byteLength(serialized, 'utf8') > this.config.maxSizeBytes && events.length > 0) {
53
+ events.shift();
54
+ serialized = JSON.stringify(events);
55
+ }
56
+ await this.saveQueue(events);
57
+ }
58
+ catch {
59
+ // Queue write failures are non-critical
60
+ }
61
+ }
62
+ /**
63
+ * Flush all queued events using the provided send function.
64
+ * Returns count of sent and failed events.
65
+ */
66
+ async flush(sendFn) {
67
+ try {
68
+ const events = await this.loadQueue();
69
+ if (events.length === 0) {
70
+ return { sent: 0, failed: 0 };
71
+ }
72
+ const success = await sendFn(events);
73
+ if (success) {
74
+ await this.saveQueue([]);
75
+ return { sent: events.length, failed: 0 };
76
+ }
77
+ return { sent: 0, failed: events.length };
78
+ }
79
+ catch {
80
+ return { sent: 0, failed: 0 };
81
+ }
82
+ }
83
+ /**
84
+ * Get queue statistics.
85
+ */
86
+ async getStats() {
87
+ try {
88
+ const events = await this.loadQueue();
89
+ const serialized = JSON.stringify(events);
90
+ return {
91
+ count: events.length,
92
+ sizeBytes: Buffer.byteLength(serialized, 'utf8'),
93
+ };
94
+ }
95
+ catch {
96
+ return { count: 0, sizeBytes: 0 };
97
+ }
98
+ }
99
+ /**
100
+ * Clear all queued events.
101
+ */
102
+ async clear() {
103
+ try {
104
+ await this.saveQueue([]);
105
+ }
106
+ catch {
107
+ // Clear failures are non-critical
108
+ }
109
+ }
110
+ // ── Private ─────────────────────────────────────────────────────────
111
+ async loadQueue() {
112
+ try {
113
+ const raw = await readFile(this.config.queueFilePath, 'utf8');
114
+ const data = JSON.parse(raw);
115
+ if (!Array.isArray(data))
116
+ return [];
117
+ return data;
118
+ }
119
+ catch {
120
+ return [];
121
+ }
122
+ }
123
+ async saveQueue(events) {
124
+ const dir = dirname(this.config.queueFilePath);
125
+ await mkdir(dir, { recursive: true });
126
+ const tmpPath = `${this.config.queueFilePath}.tmp`;
127
+ await writeFile(tmpPath, JSON.stringify(events), 'utf8');
128
+ const { rename } = await import('node:fs/promises');
129
+ await rename(tmpPath, this.config.queueFilePath);
130
+ }
131
+ }
@@ -1 +1,5 @@
1
- import{TierAwareClient as i}from"./tier-aware-client.js";export{i as TierAwareClient};
1
+ /**
2
+ * @license FSL-1.1
3
+ * Copyright (c) 2026 OrNexus AI
4
+ */
5
+ export { TierAwareClient, } from './tier-aware-client.js';