@ornexus/neocortex 4.60.68 → 4.60.70

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 (232) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1194 -1194
  3. package/install.ps1 +1 -1
  4. package/install.sh +1 -1
  5. package/package.json +3 -3
  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 -212
  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 -417
  18. package/packages/client/dist/agent/update-agent-yaml.js +1 -102
  19. package/packages/client/dist/agent/update-description.js +1 -251
  20. package/packages/client/dist/cache/crypto-utils.js +1 -78
  21. package/packages/client/dist/cache/encrypted-cache.js +1 -108
  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 +3 -290
  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.d.ts +6 -0
  38. package/packages/client/dist/commands/invoke.js +142 -7140
  39. package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
  40. package/packages/client/dist/commands/legacy-story-branch.js +1 -96
  41. package/packages/client/dist/commands/legacy-story-pr.js +1 -276
  42. package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
  43. package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
  44. package/packages/client/dist/commands/mutation-qa-git.js +1 -41
  45. package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
  46. package/packages/client/dist/commands/mutation-qa-run.js +3 -219
  47. package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
  48. package/packages/client/dist/commands/mutation-qa.js +1 -220
  49. package/packages/client/dist/commands/native-agent.js +2 -136
  50. package/packages/client/dist/commands/planning-diagnosis.js +1 -43
  51. package/packages/client/dist/commands/planning-generation.js +1 -53
  52. package/packages/client/dist/commands/planning-memory.js +1 -40
  53. package/packages/client/dist/commands/planning-research.js +1 -42
  54. package/packages/client/dist/commands/private-session.js +1 -75
  55. package/packages/client/dist/commands/property-qa.js +1 -139
  56. package/packages/client/dist/commands/qa-control.js +1 -16
  57. package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
  58. package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
  59. package/packages/client/dist/commands/qa-scan-capture.js +5 -663
  60. package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
  61. package/packages/client/dist/commands/qa-scan-review.js +5 -826
  62. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
  63. package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
  64. package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
  65. package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
  66. package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
  67. package/packages/client/dist/commands/refactor-characterization.js +21 -671
  68. package/packages/client/dist/commands/refactor-commit.js +13 -399
  69. package/packages/client/dist/commands/refactor-control.js +3 -142
  70. package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
  71. package/packages/client/dist/commands/refactor-review.js +5 -283
  72. package/packages/client/dist/commands/refactor-root.js +7 -588
  73. package/packages/client/dist/commands/refresh-memory.js +3 -156
  74. package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
  75. package/packages/client/dist/commands/story-checkpoint.js +1 -171
  76. package/packages/client/dist/config/profile-directory.js +1 -13
  77. package/packages/client/dist/config/resolver-selection.js +1 -278
  78. package/packages/client/dist/config/secure-config.js +12 -281
  79. package/packages/client/dist/config.js +2 -223
  80. package/packages/client/dist/constants.js +1 -25
  81. package/packages/client/dist/context/context-collector.js +2 -222
  82. package/packages/client/dist/context/context-sanitizer.js +1 -145
  83. package/packages/client/dist/continuity/autonomous-governance.js +1 -285
  84. package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
  85. package/packages/client/dist/continuity/invoke-hooks.js +1 -129
  86. package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
  87. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
  88. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
  89. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
  90. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
  91. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
  92. package/packages/client/dist/continuity/native-agent-store.js +1 -69
  93. package/packages/client/dist/continuity/native-agent-types.js +1 -90
  94. package/packages/client/dist/continuity/outbox.js +1 -117
  95. package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
  96. package/packages/client/dist/continuity/sqlite-store.js +81 -2536
  97. package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
  98. package/packages/client/dist/errors/error-messages.js +2 -228
  99. package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
  100. package/packages/client/dist/evidence/collector.js +1 -347
  101. package/packages/client/dist/evidence/index.js +1 -1
  102. package/packages/client/dist/evidence/types.js +0 -2
  103. package/packages/client/dist/fs/atomic-state-replace.js +1 -152
  104. package/packages/client/dist/generated/command-registry.generated.js +1 -4076
  105. package/packages/client/dist/generated/public-projections.generated.js +1 -149
  106. package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
  107. package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -1234
  108. package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
  109. package/packages/client/dist/git/git-lifecycle-store.js +9 -1938
  110. package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
  111. package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
  112. package/packages/client/dist/git/legacy-story-pr.js +70 -3538
  113. package/packages/client/dist/git/secure-filesystem-boundary.js +5 -182
  114. package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
  115. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
  116. package/packages/client/dist/i18n/first-run.js +2 -60
  117. package/packages/client/dist/index.js +1 -47
  118. package/packages/client/dist/invocation/invoke-input.js +1 -24
  119. package/packages/client/dist/license/index.js +1 -5
  120. package/packages/client/dist/license/license-client.js +1 -304
  121. package/packages/client/dist/machine/fingerprint.js +2 -163
  122. package/packages/client/dist/machine/index.js +1 -5
  123. package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
  124. package/packages/client/dist/memory/project-memory-writer.js +40 -1007
  125. package/packages/client/dist/memory/shared-project-memory-types.js +2 -253
  126. package/packages/client/dist/migrations/project-identity-capability.js +1 -50
  127. package/packages/client/dist/migrations/project-identity.js +7 -493
  128. package/packages/client/dist/migrations/state-json.js +4 -344
  129. package/packages/client/dist/policy/architecture-policy.js +2 -184
  130. package/packages/client/dist/policy/index.js +1 -7
  131. package/packages/client/dist/policy/shared-policy-types.js +0 -38
  132. package/packages/client/dist/policy/subagent-approval-policy.js +1 -55
  133. package/packages/client/dist/private-execution/clean-baseline.js +2 -279
  134. package/packages/client/dist/private-execution/codex-executor.js +4 -574
  135. package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
  136. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
  137. package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
  138. package/packages/client/dist/private-execution/delivery.js +13 -410
  139. package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
  140. package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
  141. package/packages/client/dist/private-execution/implementation-validation.js +2 -106
  142. package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
  143. package/packages/client/dist/private-execution/isolated-session.js +5 -725
  144. package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
  145. package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
  146. package/packages/client/dist/private-execution/pact-test-source.js +1 -258
  147. package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
  148. package/packages/client/dist/private-execution/pact-write-set.js +1 -172
  149. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
  150. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
  151. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
  152. package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
  153. package/packages/client/dist/private-execution/private-report-store.js +1 -42
  154. package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
  155. package/packages/client/dist/private-execution/property-test-choices.js +3 -147
  156. package/packages/client/dist/private-execution/property-test-plan.js +7 -271
  157. package/packages/client/dist/private-execution/property-test-review.js +4 -258
  158. package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
  159. package/packages/client/dist/private-execution/property-test-source.js +1 -139
  160. package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
  161. package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
  162. package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
  163. package/packages/client/dist/private-execution/root-memory-request.js +1 -29
  164. package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
  165. package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
  166. package/packages/client/dist/private-execution/session-lease.js +1 -63
  167. package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
  168. package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
  169. package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
  170. package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
  171. package/packages/client/dist/private-execution/ux-write-set.js +2 -191
  172. package/packages/client/dist/resilience/circuit-breaker.js +1 -170
  173. package/packages/client/dist/resilience/degradation-manager.js +1 -164
  174. package/packages/client/dist/resilience/freshness-indicator.js +1 -100
  175. package/packages/client/dist/resilience/index.js +1 -8
  176. package/packages/client/dist/resilience/recovery-detector.js +1 -74
  177. package/packages/client/dist/resolvers/asset-resolver.js +0 -13
  178. package/packages/client/dist/resolvers/local-resolver.js +8 -255
  179. package/packages/client/dist/resolvers/remote-resolver.js +1 -233
  180. package/packages/client/dist/runner/binary.js +1 -404
  181. package/packages/client/dist/runner/cli.js +17 -1571
  182. package/packages/client/dist/runner/headless/adapters.js +1 -49
  183. package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
  184. package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1628
  185. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
  186. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -110
  187. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +8 -1236
  188. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -318
  189. package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
  190. package/packages/client/dist/runner/headless/managed-profile.js +1 -132
  191. package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
  192. package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
  193. package/packages/client/dist/runner/headless/resolver.js +1 -231
  194. package/packages/client/dist/runner/headless/run-yolo.js +1 -885
  195. package/packages/client/dist/runner/headless/run-yoloop.js +2 -2574
  196. package/packages/client/dist/runner/headless/types.js +2 -574
  197. package/packages/client/dist/runner/local-console.js +13 -396
  198. package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
  199. package/packages/client/dist/runner/project-identity.js +1 -106
  200. package/packages/client/dist/runner/scheduler.js +7 -995
  201. package/packages/client/dist/runner-cli.js +2 -18
  202. package/packages/client/dist/state/invocation-shape.js +1 -13
  203. package/packages/client/dist/state/project-state-snapshot.js +1 -1677
  204. package/packages/client/dist/state/state-json-repair.js +3 -785
  205. package/packages/client/dist/state/structural-dag-projection.js +1 -118
  206. package/packages/client/dist/telemetry/index.js +1 -5
  207. package/packages/client/dist/telemetry/offline-queue.js +1 -131
  208. package/packages/client/dist/tier/index.js +1 -5
  209. package/packages/client/dist/tier/tier-aware-client.js +1 -405
  210. package/packages/client/dist/types/index.js +1 -38
  211. package/packages/client/dist/version.js +1 -27
  212. package/packages/client/dist/yolo/change-evidence-collector.js +1 -126
  213. package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -62
  214. package/packages/client/dist/yolo/spec-envelope-collector.js +5 -185
  215. package/packages/client/dist/yoloop/discovery-hook.js +2 -300
  216. package/packages/client/dist/yoloop/index.js +1 -8
  217. package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
  218. package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
  219. package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
  220. package/packages/client/dist/yoloop/target-normalization.js +1 -180
  221. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1723
  222. package/targets-stubs/antigravity/gemini.md +1 -1
  223. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  224. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  225. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  226. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  227. package/targets-stubs/claude-code/neocortex.md +2 -2
  228. package/targets-stubs/codex/AGENTS.md +1 -1
  229. package/targets-stubs/cursor/agent.md +2 -2
  230. package/targets-stubs/gemini-cli/agent.md +2 -2
  231. package/targets-stubs/opencode/neocortex-root.md +1 -1
  232. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1,251 +1 @@
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 - Agent Description Updater (Multi-Platform)
15
- *
16
- * Updates the installed agent description across ALL supported platforms
17
- * with dynamic values: version, tier, and branding.
18
- *
19
- * Patches THREE surfaces per file (when present):
20
- * 1. YAML frontmatter `description: "..."` or Markdown H1 `# ...`
21
- * 2. ASCII banner version line: `│ ### ######## vX.X.X ...│`
22
- * 3. ASCII banner tier line: `│ ## ### ###### ## OrNexus Team (Tier) ...│`
23
- *
24
- * Supported platforms (home-level):
25
- * - Claude Code: ~/.claude/agents/neocortex/neocortex.md (YAML frontmatter)
26
- * - Gemini CLI: ~/.gemini/agents/agent.md (YAML frontmatter)
27
- *
28
- * Supported platforms (project-level, discovered via git root):
29
- * - Cursor: <root>/.cursor/agents/neocortex.md (YAML frontmatter)
30
- * - VSCode: <root>/.github/agents/neocortex.md (YAML frontmatter)
31
- * - Codex: <root>/AGENTS.md (Markdown H1)
32
- * - Antigravity: <root>/.agent/skills/neocortex/SKILL.md (YAML frontmatter)
33
- *
34
- * Called after:
35
- * - License activation (activate.ts)
36
- * - Install (install.sh via sed fallback for all platforms)
37
- *
38
- * Format: 🧠 Neocortex vX.X.X (Tier) | OrNexus Team
39
- */
40
- import { readFileSync, writeFileSync, existsSync } from 'node:fs';
41
- import { execSync } from 'node:child_process';
42
- import { join } from 'node:path';
43
- import { homedir } from 'node:os';
44
- // ── Constants ─────────────────────────────────────────────────────────────
45
- const CONFIG_FILE = join(homedir(), '.neocortex', 'config.json');
46
- const TIER_LABELS = {
47
- free: 'Free',
48
- pro: 'Pro',
49
- enterprise: 'Enterprise',
50
- };
51
- /**
52
- * Banner frame geometry.
53
- * Frame is 62 chars wide: │ + 60 inner chars + │
54
- * Both dynamic lines have a 25-char inner prefix (after the leading │).
55
- */
56
- const BANNER_INNER_WIDTH = 60;
57
- const BANNER_PREFIX_INNER = 25; // chars after leading │, before dynamic content
58
- // YAML frontmatter: description: "..."
59
- const YAML_DESCRIPTION_PATTERN = /^description:\s*".*"$/m;
60
- // Markdown H1: # 🧠 Neocortex vX.X.X (Tier) | OrNexus Team
61
- // Also matches legacy format: # 🧠 Neocortex vX.X.X - Development Orchestrator | OrNexus Team (Tier)
62
- const H1_DESCRIPTION_PATTERN = /^# 🧠 Neocortex v[\d.]+(?:\s*\([^)]+\)\s*\| OrNexus Team|\s*-\s*Development Orchestrator \| OrNexus Team \([^)]+\))$/m;
63
- // Banner version line: │ ### ######## vX.X.X<spaces>│
64
- const BANNER_VERSION_PATTERN = /^│ ### ######## v[\d.]+\s*│$/m;
65
- // Banner tier line: │ ## ### ###### ## OrNexus Team (<Tier>)<spaces>│
66
- const BANNER_TIER_PATTERN = /^│ ## ### ###### ## OrNexus Team \([^)]*\)\s*│$/m;
67
- /**
68
- * All known home-directory agent files, grouped by description format.
69
- */
70
- const HOME_AGENT_FILES = [
71
- // Claude Code (home-level)
72
- { path: join(homedir(), '.claude', 'agents', 'neocortex', 'neocortex.md'), type: 'yaml' },
73
- // Gemini CLI (home-level)
74
- { path: join(homedir(), '.gemini', 'agents', 'agent.md'), type: 'yaml' },
75
- ];
76
- /**
77
- * Known project-level agent file paths (relative to project root).
78
- * These are patched after license activation so the tier reflects reality.
79
- */
80
- const PROJECT_AGENT_FILES = [
81
- // Cursor
82
- { relativePath: join('.cursor', 'agents', 'neocortex.md'), type: 'yaml' },
83
- // VSCode / GitHub Copilot
84
- { relativePath: join('.github', 'agents', 'neocortex.md'), type: 'yaml' },
85
- // Codex
86
- { relativePath: 'AGENTS.md', type: 'h1' },
87
- // Antigravity
88
- { relativePath: join('.agent', 'skills', 'neocortex', 'SKILL.md'), type: 'yaml' },
89
- ];
90
- // ── Project Root Discovery ────────────────────────────────────────────────
91
- /**
92
- * Discover the git project root, or null if not in a git repo.
93
- * Never throws -- returns null on any failure.
94
- */
95
- function discoverProjectRoot() {
96
- try {
97
- const root = execSync('git rev-parse --show-toplevel', {
98
- encoding: 'utf-8',
99
- timeout: 5000,
100
- stdio: ['pipe', 'pipe', 'pipe'],
101
- }).trim();
102
- return root || null;
103
- }
104
- catch {
105
- return null;
106
- }
107
- }
108
- // ── Banner Helpers ────────────────────────────────────────────────────────
109
- /**
110
- * Build a right-padded banner line.
111
- * Prefix is the fixed art portion INCLUDING the leading │ (26 chars).
112
- * Content is the dynamic text. Padding fills to inner width, then closing │.
113
- *
114
- * Total: │(1) + prefixInner(25) + content + pad + │(1) = 62 chars.
115
- */
116
- function buildBannerLine(prefix, content) {
117
- const padLen = BANNER_INNER_WIDTH - BANNER_PREFIX_INNER - content.length;
118
- const padding = padLen > 0 ? ' '.repeat(padLen) : '';
119
- return `${prefix}${content}${padding}\u2502`; // \u2502 = │
120
- }
121
- /**
122
- * Build the banner version line with correct padding.
123
- */
124
- export function buildBannerVersionLine(version) {
125
- return buildBannerLine('\u2502 ### ######## ', `v${version}`);
126
- }
127
- /**
128
- * Build the banner tier line with correct padding.
129
- */
130
- export function buildBannerTierLine(tier) {
131
- const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
132
- return buildBannerLine('\u2502 ## ### ###### ## ', `OrNexus Team (${label})`);
133
- }
134
- // ── Public API ────────────────────────────────────────────────────────────
135
- /**
136
- * Build the dynamic description string (without quotes/prefix).
137
- */
138
- export function buildDescription(version, tier) {
139
- const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
140
- return `\u{1F9E0} Neocortex v${version} (${label}) | OrNexus Team`;
141
- }
142
- /**
143
- * Read the current tier from ~/.neocortex/config.json.
144
- * Returns 'free' if config doesn't exist or tier is missing.
145
- */
146
- export function readTierFromConfig() {
147
- try {
148
- if (existsSync(CONFIG_FILE)) {
149
- const raw = readFileSync(CONFIG_FILE, 'utf-8');
150
- const config = JSON.parse(raw);
151
- return config.tier ?? 'free';
152
- }
153
- }
154
- catch {
155
- // Config missing or corrupted
156
- }
157
- return 'free';
158
- }
159
- /**
160
- * Patch ASCII banner lines (version + tier) in file content.
161
- * Returns the patched content, or the original if no banner found.
162
- */
163
- function patchBannerLines(content, version, tier) {
164
- let patched = content;
165
- // Patch version line
166
- if (BANNER_VERSION_PATTERN.test(patched)) {
167
- patched = patched.replace(BANNER_VERSION_PATTERN, buildBannerVersionLine(version));
168
- }
169
- // Patch tier line
170
- if (BANNER_TIER_PATTERN.test(patched)) {
171
- patched = patched.replace(BANNER_TIER_PATTERN, buildBannerTierLine(tier));
172
- }
173
- return patched;
174
- }
175
- /**
176
- * Update a single file's description and banner.
177
- * Supports YAML frontmatter, H1 header, and ASCII banner lines.
178
- *
179
- * Never throws -- description update is non-critical.
180
- */
181
- function updateFile(filePath, type, description, version, tier) {
182
- try {
183
- if (!existsSync(filePath)) {
184
- return false;
185
- }
186
- let content = readFileSync(filePath, 'utf-8');
187
- const original = content;
188
- // 1. Patch description (YAML frontmatter or H1 header)
189
- if (type === 'yaml') {
190
- if (YAML_DESCRIPTION_PATTERN.test(content)) {
191
- content = content.replace(YAML_DESCRIPTION_PATTERN, `description: "${description}"`);
192
- }
193
- }
194
- else {
195
- if (H1_DESCRIPTION_PATTERN.test(content)) {
196
- content = content.replace(H1_DESCRIPTION_PATTERN, `# ${description}`);
197
- }
198
- }
199
- // 2. Patch ASCII banner lines (version + tier) if present
200
- content = patchBannerLines(content, version, tier);
201
- if (content === original) {
202
- return false; // Already up to date
203
- }
204
- writeFileSync(filePath, content, 'utf-8');
205
- return true;
206
- }
207
- catch {
208
- return false;
209
- }
210
- }
211
- /**
212
- * Update agent descriptions across ALL known platform files:
213
- * 1. Home-level files (Claude Code, Gemini CLI)
214
- * 2. Project-level files (Cursor, VSCode, Codex, Antigravity) -- discovered via git root
215
- *
216
- * Never throws -- description update is non-critical.
217
- * Returns count of files updated.
218
- */
219
- export function updateAgentDescription(version, tier) {
220
- const resolvedTier = tier ?? readTierFromConfig();
221
- const description = buildDescription(version, resolvedTier);
222
- let updated = 0;
223
- // 1. Home-level files (existing behavior)
224
- for (const { path, type } of HOME_AGENT_FILES) {
225
- if (updateFile(path, type, description, version, resolvedTier)) {
226
- updated++;
227
- }
228
- }
229
- // 2. Project-level files (discover git root, then check known paths)
230
- const projectRoot = discoverProjectRoot();
231
- if (projectRoot) {
232
- for (const { relativePath, type } of PROJECT_AGENT_FILES) {
233
- const fullPath = join(projectRoot, relativePath);
234
- if (updateFile(fullPath, type, description, version, resolvedTier)) {
235
- updated++;
236
- }
237
- }
238
- }
239
- return updated;
240
- }
241
- /**
242
- * Update agent description for a specific file path (used by install scripts
243
- * for project-level files where paths are dynamic).
244
- *
245
- * Never throws -- description update is non-critical.
246
- */
247
- export function updateAgentDescriptionAt(filePath, type, version, tier) {
248
- const resolvedTier = tier ?? readTierFromConfig();
249
- const description = buildDescription(version, resolvedTier);
250
- return updateFile(filePath, type, description, version, resolvedTier);
251
- }
1
+ import{readFileSync as l,writeFileSync as _,existsSync as f}from"node:fs";import{execSync as A}from"node:child_process";import{join as c}from"node:path";import{homedir as p}from"node:os";const m=c(p(),".neocortex","config.json"),d={free:"Free",pro:"Pro",enterprise:"Enterprise"},I=60,L=25,N=/^description:\s*".*"$/m,E=/^# 🧠 Neocortex v[\d.]+(?:\s*\([^)]+\)\s*\| OrNexus Team|\s*-\s*Development Orchestrator \| OrNexus Team \([^)]+\))$/m,T=/^│ ### ######## v[\d.]+\s*│$/m,x=/^│ ## ### ###### ## OrNexus Team \([^)]*\)\s*│$/m,P=[{path:c(p(),".claude","agents","neocortex","neocortex.md"),type:"yaml"},{path:c(p(),".gemini","agents","agent.md"),type:"yaml"}],F=[{relativePath:c(".cursor","agents","neocortex.md"),type:"yaml"},{relativePath:c(".github","agents","neocortex.md"),type:"yaml"},{relativePath:"AGENTS.md",type:"h1"},{relativePath:c(".agent","skills","neocortex","SKILL.md"),type:"yaml"}];function O(){try{return A("git rev-parse --show-toplevel",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function y(e,o){const t=I-L-o.length,r=t>0?" ".repeat(t):"";return`${e}${o}${r}\u2502`}function S(e){return y("\u2502 ### ######## ",`v${e}`)}function $(e){const o=d[e.toLowerCase()]??"Free";return y("\u2502 ## ### ###### ## ",`OrNexus Team (${o})`)}function g(e,o){const t=d[o.toLowerCase()]??"Free";return`\u{1F9E0} Neocortex v${e} (${t}) | OrNexus Team`}function R(){try{if(f(m)){const e=l(m,"utf-8");return JSON.parse(e).tier??"free"}}catch{}return"free"}function v(e,o,t){let r=e;return T.test(r)&&(r=r.replace(T,S(o))),x.test(r)&&(r=r.replace(x,$(t))),r}function u(e,o,t,r,i){try{if(!f(e))return!1;let n=l(e,"utf-8");const s=n;return o==="yaml"?N.test(n)&&(n=n.replace(N,`description: "${t}"`)):E.test(n)&&(n=n.replace(E,`# ${t}`)),n=v(n,r,i),n===s?!1:(_(e,n,"utf-8"),!0)}catch{return!1}}function w(e,o){const t=o??R(),r=g(e,t);let i=0;for(const{path:s,type:a}of P)u(s,a,r,e,t)&&i++;const n=O();if(n)for(const{relativePath:s,type:a}of F){const h=c(n,s);u(h,a,r,e,t)&&i++}return i}function j(e,o,t,r){const i=r??R(),n=g(t,i);return u(e,o,n,t,i)}export{$ as buildBannerTierLine,S as buildBannerVersionLine,g as buildDescription,R as readTierFromConfig,w as updateAgentDescription,j as updateAgentDescriptionAt};
@@ -1,78 +1 @@
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 - Crypto Utilities
15
- *
16
- * AES-256-GCM encryption/decryption with PBKDF2 key derivation.
17
- * Used by EncryptedCache to protect cached assets at rest.
18
- *
19
- * Security design:
20
- * - IV: 12 bytes (NIST SP 800-38D recommended for GCM)
21
- * - Salt: 32 bytes random per entry
22
- * - Key: PBKDF2 with 100k iterations, SHA-512
23
- * - expiresAt is inside the encrypted payload (authenticated by GCM tag)
24
- */
25
- import { randomBytes, pbkdf2Sync, createCipheriv, createDecipheriv } from 'node:crypto';
26
- import { assertPublicSafeCachePayload } from './protected-pi-boundary.js';
27
- // ── Constants ────────────────────────────────────────────────────────────
28
- const ALGORITHM = 'aes-256-gcm';
29
- const IV_LENGTH = 12; // NIST SP 800-38D recommended for AES-GCM
30
- const SALT_LENGTH = 32;
31
- const KEY_LENGTH = 32;
32
- const AUTH_TAG_LENGTH = 16;
33
- const PBKDF2_ITERATIONS = 100_000;
34
- const PBKDF2_DIGEST = 'sha512';
35
- // ── Key Derivation ───────────────────────────────────────────────────────
36
- export function deriveKey(passphrase, salt) {
37
- return pbkdf2Sync(passphrase, salt, PBKDF2_ITERATIONS, KEY_LENGTH, PBKDF2_DIGEST);
38
- }
39
- // ── Encrypt ──────────────────────────────────────────────────────────────
40
- export function encrypt(plaintext, passphrase, ttlMs) {
41
- assertPublicSafeCachePayload(plaintext);
42
- const iv = randomBytes(IV_LENGTH);
43
- const salt = randomBytes(SALT_LENGTH);
44
- const key = deriveKey(passphrase, salt);
45
- const expiresAt = ttlMs != null ? Date.now() + ttlMs : null;
46
- const payload = { plaintext, expiresAt };
47
- const payloadJson = JSON.stringify(payload);
48
- const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
49
- const encrypted = Buffer.concat([cipher.update(payloadJson, 'utf8'), cipher.final()]);
50
- const tag = cipher.getAuthTag();
51
- const envelope = {
52
- iv: iv.toString('base64'),
53
- salt: salt.toString('base64'),
54
- tag: tag.toString('base64'),
55
- data: encrypted.toString('base64'),
56
- };
57
- return JSON.stringify(envelope);
58
- }
59
- export function decrypt(envelopeJson, passphrase) {
60
- const raw = JSON.parse(envelopeJson);
61
- if (!raw.iv || !raw.salt || !raw.tag || !raw.data) {
62
- throw new Error('Invalid cache envelope: missing required fields');
63
- }
64
- const iv = Buffer.from(raw.iv, 'base64');
65
- const salt = Buffer.from(raw.salt, 'base64');
66
- const tag = Buffer.from(raw.tag, 'base64');
67
- const data = Buffer.from(raw.data, 'base64');
68
- const key = deriveKey(passphrase, salt);
69
- const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
70
- decipher.setAuthTag(tag);
71
- const decrypted = Buffer.concat([decipher.update(data), decipher.final()]);
72
- const payload = JSON.parse(decrypted.toString('utf8'));
73
- const expired = payload.expiresAt != null && Date.now() > payload.expiresAt;
74
- return {
75
- plaintext: payload.plaintext,
76
- expired,
77
- };
78
- }
1
+ import{randomBytes as d,pbkdf2Sync as h,createCipheriv as S,createDecipheriv as m}from"node:crypto";import{assertPublicSafeCachePayload as v}from"./protected-pi-boundary.js";const l="aes-256-gcm",b=12,A=32,B=32,g=16,N=1e5,x="sha512";function y(e,n){return h(e,n,N,B,x)}function _(e,n,t){v(e);const s=d(b),c=d(A),i=y(n,c),f=t!=null?Date.now()+t:null,a=JSON.stringify({plaintext:e,expiresAt:f}),o=S(l,i,s,{authTagLength:g}),r=Buffer.concat([o.update(a,"utf8"),o.final()]),p=o.getAuthTag(),T={iv:s.toString("base64"),salt:c.toString("base64"),tag:p.toString("base64"),data:r.toString("base64")};return JSON.stringify(T)}function G(e,n){const t=JSON.parse(e);if(!t.iv||!t.salt||!t.tag||!t.data)throw new Error("Invalid cache envelope: missing required fields");const s=Buffer.from(t.iv,"base64"),c=Buffer.from(t.salt,"base64"),i=Buffer.from(t.tag,"base64"),f=Buffer.from(t.data,"base64"),u=y(n,c),a=m(l,u,s,{authTagLength:g});a.setAuthTag(i);const o=Buffer.concat([a.update(f),a.final()]),r=JSON.parse(o.toString("utf8")),p=r.expiresAt!=null&&Date.now()>r.expiresAt;return{plaintext:r.plaintext,expired:p}}export{G as decrypt,y as deriveKey,_ as encrypt};
@@ -1,108 +1 @@
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 - EncryptedCache
15
- *
16
- * Filesystem-backed encrypted cache implementing the CacheProvider interface.
17
- * Stores assets as AES-256-GCM encrypted files with PBKDF2 key derivation.
18
- * Cache keys are hashed with SHA-256 to produce safe filenames.
19
- *
20
- * PI boundary (P176.05): values may contain public metadata, hashes, counts,
21
- * sizes, or bounded encrypted data only. Synthetic protected prompt/workflow/
22
- * step-body markers and explicit protected JSON field names are rejected before
23
- * disk write. Default TTL is caller-owned and remains [TBD].
24
- *
25
- * All public methods are designed to never throw - cache failures are
26
- * silently handled since caching is a non-critical optimization.
27
- */
28
- import { mkdir, writeFile, readFile, rm, readdir } from 'node:fs/promises';
29
- import { join } from 'node:path';
30
- import { createHash } from 'node:crypto';
31
- import { encrypt, decrypt } from './crypto-utils.js';
32
- import { setSecureFilePermissions } from '../config/secure-config.js';
33
- import { hasProtectedCachePayloadMarker } from './protected-pi-boundary.js';
34
- // ── Constants ────────────────────────────────────────────────────────────
35
- const CACHE_FILE_EXTENSION = '.enc';
36
- // ── EncryptedCache Implementation ────────────────────────────────────────
37
- export class EncryptedCache {
38
- cacheDir;
39
- passphrase;
40
- strictReadOnly;
41
- initPromise = null;
42
- constructor(options) {
43
- this.cacheDir = options.cacheDir;
44
- this.passphrase = options.passphrase;
45
- this.strictReadOnly = options.strictReadOnly ?? false;
46
- }
47
- async get(key) {
48
- try {
49
- const filePath = this.keyToPath(key);
50
- const raw = await readFile(filePath, 'utf8');
51
- const result = decrypt(raw, this.passphrase);
52
- if (result.expired) {
53
- if (!this.strictReadOnly)
54
- await rm(filePath, { force: true }).catch(() => { });
55
- return null;
56
- }
57
- return result.plaintext;
58
- }
59
- catch {
60
- return null;
61
- }
62
- }
63
- async set(key, value, ttlMs) {
64
- if (this.strictReadOnly)
65
- return;
66
- try {
67
- if (hasProtectedCachePayloadMarker(value))
68
- return;
69
- await this.ensureDir();
70
- const filePath = this.keyToPath(key);
71
- const encrypted = encrypt(value, this.passphrase, ttlMs);
72
- await writeFile(filePath, encrypted, 'utf8');
73
- // Story 66.1 AC6: Apply restrictive permissions on .enc files
74
- setSecureFilePermissions(filePath);
75
- }
76
- catch {
77
- // Cache write failures are non-critical
78
- }
79
- }
80
- async clear() {
81
- if (this.strictReadOnly)
82
- return;
83
- try {
84
- const entries = await readdir(this.cacheDir).catch(() => []);
85
- const removals = entries
86
- .filter((entry) => entry.endsWith(CACHE_FILE_EXTENSION))
87
- .map((entry) => rm(join(this.cacheDir, entry), { force: true }).catch(() => { }));
88
- await Promise.all(removals);
89
- }
90
- catch {
91
- // Clear failures are non-critical
92
- }
93
- }
94
- // ── Private Methods ─────────────────────────────────────────────────
95
- keyToPath(key) {
96
- const hash = createHash('sha256').update(key).digest('hex');
97
- return join(this.cacheDir, `${hash}${CACHE_FILE_EXTENSION}`);
98
- }
99
- ensureDir() {
100
- if (!this.initPromise) {
101
- this.initPromise = mkdir(this.cacheDir, { recursive: true }).then(() => undefined).catch((err) => {
102
- this.initPromise = null; // allow retry on next call
103
- throw err;
104
- });
105
- }
106
- return this.initPromise;
107
- }
108
- }
1
+ import{mkdir as n,writeFile as o,readFile as l,rm as s,readdir as u}from"node:fs/promises";import{join as a}from"node:path";import{createHash as m}from"node:crypto";import{encrypt as p,decrypt as d}from"./crypto-utils.js";import{setSecureFilePermissions as f}from"../config/secure-config.js";import{hasProtectedCachePayloadMarker as y}from"./protected-pi-boundary.js";const c=".enc";class x{cacheDir;passphrase;strictReadOnly;initPromise=null;constructor(t){this.cacheDir=t.cacheDir,this.passphrase=t.passphrase,this.strictReadOnly=t.strictReadOnly??!1}async get(t){try{const r=this.keyToPath(t),e=await l(r,"utf8"),i=d(e,this.passphrase);return i.expired?(this.strictReadOnly||await s(r,{force:!0}).catch(()=>{}),null):i.plaintext}catch{return null}}async set(t,r,e){if(!this.strictReadOnly)try{if(y(r))return;await this.ensureDir();const i=this.keyToPath(t),h=p(r,this.passphrase,e);await o(i,h,"utf8"),f(i)}catch{}}async clear(){if(!this.strictReadOnly)try{const r=(await u(this.cacheDir).catch(()=>[])).filter(e=>e.endsWith(c)).map(e=>s(a(this.cacheDir,e),{force:!0}).catch(()=>{}));await Promise.all(r)}catch{}}keyToPath(t){const r=m("sha256").update(t).digest("hex");return a(this.cacheDir,`${r}${c}`)}ensureDir(){return this.initPromise||(this.initPromise=n(this.cacheDir,{recursive:!0}).then(()=>{}).catch(t=>{throw this.initPromise=null,t})),this.initPromise}}export{x as EncryptedCache};
@@ -1,73 +1 @@
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
- import { hasProtectedCachePayloadMarker } from './protected-pi-boundary.js';
14
- const DEFAULT_MAX_SIZE = 50;
15
- const DEFAULT_TTL_MS = 5 * 60 * 1000;
16
- export class InMemoryAssetCache {
17
- store = new Map();
18
- maxSize;
19
- ttlMs;
20
- constructor(options = {}) {
21
- this.maxSize = options.maxSize ?? DEFAULT_MAX_SIZE;
22
- this.ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
23
- }
24
- /**
25
- * Retrieve a value by key. Returns null if missing or expired.
26
- * Accessing a key moves it to the end of the LRU ordering.
27
- */
28
- async get(key) {
29
- const entry = this.store.get(key);
30
- if (!entry)
31
- return null;
32
- if (Date.now() >= entry.expiresAt) {
33
- this.store.delete(key);
34
- return null;
35
- }
36
- // LRU: move to end (most recently used)
37
- this.store.delete(key);
38
- this.store.set(key, entry);
39
- return entry.value;
40
- }
41
- /**
42
- * Store a value by key. Evicts the least-recently-used entry if the
43
- * cache is at capacity.
44
- *
45
- * @param ttlMs - optional override of the default TTL
46
- */
47
- async set(key, value, ttlMs) {
48
- if (hasProtectedCachePayloadMarker(value))
49
- return;
50
- const ttl = ttlMs ?? this.ttlMs;
51
- const expiresAt = Date.now() + ttl;
52
- if (this.store.has(key)) {
53
- // Overwrite keeps insertion order fresh -- delete then set.
54
- this.store.delete(key);
55
- }
56
- else if (this.store.size >= this.maxSize) {
57
- // LRU eviction: delete oldest entry (first in insertion order).
58
- const oldestKey = this.store.keys().next().value;
59
- if (oldestKey !== undefined) {
60
- this.store.delete(oldestKey);
61
- }
62
- }
63
- this.store.set(key, { value, expiresAt });
64
- }
65
- /** Drop all entries. Safe to call at any time. */
66
- async clear() {
67
- this.store.clear();
68
- }
69
- /** Internal: number of live entries (for diagnostics / tests). */
70
- size() {
71
- return this.store.size;
72
- }
73
- }
1
+ import{hasProtectedCachePayloadMarker as n}from"./protected-pi-boundary.js";const a=50,h=300*1e3;class u{store=new Map;maxSize;ttlMs;constructor(t={}){this.maxSize=t.maxSize??a,this.ttlMs=t.ttlMs??h}async get(t){const e=this.store.get(t);return e?Date.now()>=e.expiresAt?(this.store.delete(t),null):(this.store.delete(t),this.store.set(t,e),e.value):null}async set(t,e,r){if(n(e))return;const i=r??this.ttlMs,o=Date.now()+i;if(this.store.has(t))this.store.delete(t);else if(this.store.size>=this.maxSize){const s=this.store.keys().next().value;s!==void 0&&this.store.delete(s)}this.store.set(t,{value:e,expiresAt:o})}async clear(){this.store.clear()}size(){return this.store.size}}export{u as InMemoryAssetCache};
@@ -1,13 +1 @@
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
- export { EncryptedCache } from './encrypted-cache.js';
1
+ import{EncryptedCache as c}from"./encrypted-cache.js";export{c as EncryptedCache};
@@ -1,44 +1 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * Public-safe client cache PI boundary checks.
6
- */
7
- /** Public reason code used when a synthetic protected PI marker is detected. */
8
- export const PROTECTED_CACHE_PAYLOAD_REASON = 'protected-cache-payload-rejected';
9
- const SYNTHETIC_PROTECTED_MARKER = /P176_SYNTHETIC_PROTECTED_(?:PROMPT|PROMPT_BODY|WORKFLOW|WORKFLOW_GRAPH|STEP_BODY|RAW_LOG|PRIVATE_URL|SECRET|PROPRIETARY_ASSET)/i;
10
- const PROTECTED_FIELD_NAME = /^(?:promptBody|workflowBody|workflowGraph|stepBody|privateUrl|rawLog|secret|credential|licenseKey|apiKey|internalRouting|serverOnly|proprietary|protected)$/i;
11
- function hasProtectedField(value) {
12
- if (!value || typeof value !== 'object')
13
- return false;
14
- if (Array.isArray(value))
15
- return value.some(hasProtectedField);
16
- return Object.entries(value).some(([key, child]) => (PROTECTED_FIELD_NAME.test(key) || hasProtectedField(child)));
17
- }
18
- /**
19
- * Returns true only for synthetic protected markers or explicit protected field
20
- * names. Generic words like "prompt" or "workflow" are intentionally not
21
- * rejected because cache keys and README-grade metadata may use them safely.
22
- */
23
- export function hasProtectedCachePayloadMarker(value) {
24
- if (SYNTHETIC_PROTECTED_MARKER.test(value))
25
- return true;
26
- try {
27
- return hasProtectedField(JSON.parse(value));
28
- }
29
- catch {
30
- return false;
31
- }
32
- }
33
- export class ProtectedCachePayloadError extends Error {
34
- code = PROTECTED_CACHE_PAYLOAD_REASON;
35
- constructor() {
36
- super(PROTECTED_CACHE_PAYLOAD_REASON);
37
- this.name = 'ProtectedCachePayloadError';
38
- }
39
- }
40
- export function assertPublicSafeCachePayload(value) {
41
- if (hasProtectedCachePayloadMarker(value)) {
42
- throw new ProtectedCachePayloadError();
43
- }
44
- }
1
+ const t="protected-cache-payload-rejected",a=/P176_SYNTHETIC_PROTECTED_(?:PROMPT|PROMPT_BODY|WORKFLOW|WORKFLOW_GRAPH|STEP_BODY|RAW_LOG|PRIVATE_URL|SECRET|PROPRIETARY_ASSET)/i,n=/^(?:promptBody|workflowBody|workflowGraph|stepBody|privateUrl|rawLog|secret|credential|licenseKey|apiKey|internalRouting|serverOnly|proprietary|protected)$/i;function r(e){return!e||typeof e!="object"?!1:Array.isArray(e)?e.some(r):Object.entries(e).some(([o,c])=>n.test(o)||r(c))}function s(e){if(a.test(e))return!0;try{return r(JSON.parse(e))}catch{return!1}}class E extends Error{code=t;constructor(){super(t),this.name="ProtectedCachePayloadError"}}function P(e){if(s(e))throw new E}export{t as PROTECTED_CACHE_PAYLOAD_REASON,E as ProtectedCachePayloadError,P as assertPublicSafeCachePayload,s as hasProtectedCachePayloadMarker};