nexus-prime 4.8.2 → 4.9.0

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 (94) hide show
  1. package/README.md +18 -7
  2. package/dist/agents/adapters/mcp.d.ts.map +1 -1
  3. package/dist/agents/adapters/mcp.js +203 -11
  4. package/dist/agents/adapters/mcp.js.map +1 -1
  5. package/dist/agents/adapters.d.ts.map +1 -1
  6. package/dist/agents/adapters.js +2 -1
  7. package/dist/agents/adapters.js.map +1 -1
  8. package/dist/architects/bootstrap.d.ts +2 -0
  9. package/dist/architects/bootstrap.d.ts.map +1 -1
  10. package/dist/architects/bootstrap.js +26 -4
  11. package/dist/architects/bootstrap.js.map +1 -1
  12. package/dist/architects/db/client.d.ts +22 -3
  13. package/dist/architects/db/client.d.ts.map +1 -1
  14. package/dist/architects/db/client.js +81 -6
  15. package/dist/architects/db/client.js.map +1 -1
  16. package/dist/architects/mcp-tools.d.ts.map +1 -1
  17. package/dist/architects/mcp-tools.js +11 -1
  18. package/dist/architects/mcp-tools.js.map +1 -1
  19. package/dist/architects/types.d.ts +2 -0
  20. package/dist/architects/types.d.ts.map +1 -1
  21. package/dist/cli-setup.d.ts.map +1 -1
  22. package/dist/cli-setup.js +10 -7
  23. package/dist/cli-setup.js.map +1 -1
  24. package/dist/cli.js +223 -108
  25. package/dist/cli.js.map +1 -1
  26. package/dist/core/types.d.ts +3 -0
  27. package/dist/core/types.d.ts.map +1 -1
  28. package/dist/dashboard/contract.d.ts +11 -0
  29. package/dist/dashboard/contract.d.ts.map +1 -0
  30. package/dist/dashboard/contract.js +49 -0
  31. package/dist/dashboard/contract.js.map +1 -0
  32. package/dist/dashboard/index.html +112 -8
  33. package/dist/dashboard/server.d.ts +6 -0
  34. package/dist/dashboard/server.d.ts.map +1 -1
  35. package/dist/dashboard/server.js +115 -44
  36. package/dist/dashboard/server.js.map +1 -1
  37. package/dist/engines/client-bootstrap.d.ts +2 -2
  38. package/dist/engines/client-bootstrap.d.ts.map +1 -1
  39. package/dist/engines/client-bootstrap.js +24 -15
  40. package/dist/engines/client-bootstrap.js.map +1 -1
  41. package/dist/engines/instruction-gateway.d.ts.map +1 -1
  42. package/dist/engines/instruction-gateway.js +5 -4
  43. package/dist/engines/instruction-gateway.js.map +1 -1
  44. package/dist/engines/memory.d.ts.map +1 -1
  45. package/dist/engines/memory.js +6 -3
  46. package/dist/engines/memory.js.map +1 -1
  47. package/dist/engines/orchestrator.js +1 -1
  48. package/dist/engines/orchestrator.js.map +1 -1
  49. package/dist/engines/runtime-health.d.ts +91 -0
  50. package/dist/engines/runtime-health.d.ts.map +1 -0
  51. package/dist/engines/runtime-health.js +129 -0
  52. package/dist/engines/runtime-health.js.map +1 -0
  53. package/dist/engines/runtime-registry.js +6 -5
  54. package/dist/engines/runtime-registry.js.map +1 -1
  55. package/dist/engines/runtime-supervisor.d.ts +32 -0
  56. package/dist/engines/runtime-supervisor.d.ts.map +1 -0
  57. package/dist/engines/runtime-supervisor.js +137 -0
  58. package/dist/engines/runtime-supervisor.js.map +1 -0
  59. package/dist/engines/workspace-resolver.d.ts +51 -0
  60. package/dist/engines/workspace-resolver.d.ts.map +1 -0
  61. package/dist/engines/workspace-resolver.js +210 -0
  62. package/dist/engines/workspace-resolver.js.map +1 -0
  63. package/dist/index.d.ts +37 -0
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +153 -11
  66. package/dist/index.js.map +1 -1
  67. package/dist/phantom/runtime.js +5 -5
  68. package/dist/phantom/runtime.js.map +1 -1
  69. package/dist/postinstall-bootstrap.js +4 -2
  70. package/dist/postinstall-bootstrap.js.map +1 -1
  71. package/dist/synapse/bootstrap.d.ts +2 -0
  72. package/dist/synapse/bootstrap.d.ts.map +1 -1
  73. package/dist/synapse/bootstrap.js +26 -4
  74. package/dist/synapse/bootstrap.js.map +1 -1
  75. package/dist/synapse/db/client.d.ts +22 -3
  76. package/dist/synapse/db/client.d.ts.map +1 -1
  77. package/dist/synapse/db/client.js +81 -6
  78. package/dist/synapse/db/client.js.map +1 -1
  79. package/dist/synapse/db/schema.d.ts +1 -1
  80. package/dist/synapse/db/schema.d.ts.map +1 -1
  81. package/dist/synapse/db/schema.js +2 -2
  82. package/dist/synapse/db/schema.js.map +1 -1
  83. package/dist/synapse/field-reports/ledger.d.ts.map +1 -1
  84. package/dist/synapse/field-reports/ledger.js +3 -1
  85. package/dist/synapse/field-reports/ledger.js.map +1 -1
  86. package/dist/synapse/field-reports/restorer.d.ts.map +1 -1
  87. package/dist/synapse/field-reports/restorer.js +2 -1
  88. package/dist/synapse/field-reports/restorer.js.map +1 -1
  89. package/dist/synapse/mcp-tools.d.ts.map +1 -1
  90. package/dist/synapse/mcp-tools.js +11 -1
  91. package/dist/synapse/mcp-tools.js.map +1 -1
  92. package/dist/synapse/types.d.ts +2 -0
  93. package/dist/synapse/types.d.ts.map +1 -1
  94. package/package.json +2 -2
package/README.md CHANGED
@@ -630,15 +630,26 @@ Inventory Snapshot: 109 skills · 64 workflows · 9 hooks · 5 automations · 7
630
630
  ## 📜 Release History
631
631
 
632
632
  <details open>
633
- <summary><b>v4.8.0</b> · 2026-03-31 · Seamless Intelligence Upgradesmarter runtime routing, durable memory controls, and governed work graphs</summary>
633
+ <summary><b>v4.9.0</b> · 2026-04-01 · Release QA Hardeningrepo-root upgrade safety, truthful degraded startup, and deterministic ship gates</summary>
634
634
 
635
- - **Bootstrap truth for Codex and MCP clients**: Managed docs and bootstrap detection now describe `nexus_session_bootstrap` and `nexus_orchestrate` as MCP tool invocations, not shell commands.
636
- - **Runtime intelligence surfaces**: Scheduled automations, execution presets, session search, and governed skill distribution/promotion now extend the operator control plane.
637
- - **Durable control-plane governance**: Work claims, scoped approvals, and scoped budgets now preserve ancestry and lease semantics across missions and operatives.
638
- - **Memory control upgrades**: Actor-scoped memory CRUD, history, feedback, and retention hints now complement the existing project-aware memory engine.
639
- - **Channel ingress contract**: Slack, Telegram, and Feishu/Lark mappings now have a normalized gateway surface for thread identity, artifacts, and status exchange.
635
+ - **Repo-root upgrade safety**: Synapse and Architects now follow the resolved runtime storage plan, migrate stale schemas in place when possible, and quarantine broken local DBs into workspace-scoped fallback storage instead of crashing startup.
636
+ - **Truthful degraded diagnostics**: `nexus_runtime_health`, `nexus_doctor`, `nexus_autofix`, `nexus-prime status`, and the terminal cockpit now surface requested vs active engine roots, fallback state, and quarantine paths consistently.
637
+ - **Bounded operator reads**: Runtime run artifacts are workspace-scoped, so `status`, `doctor`, and dashboard health no longer inherit slow global temp history from unrelated runs.
638
+ - **Deterministic release QA**: Release smoke now covers stale-schema repo boots, broken-engine degraded doctor paths, corrupt vocabulary repair, and dashboard startup after fallback using isolated fixtures.
640
639
 
641
- Full notes: [releases/v4.8.0.md](./releases/v4.8.0.md) · Full history: [CHANGELOG.md](./CHANGELOG.md)
640
+ Full notes: [releases/v4.9.0.md](./releases/v4.9.0.md) · Full history: [CHANGELOG.md](./CHANGELOG.md)
641
+ </details>
642
+
643
+ <details>
644
+ <summary><b>v4.8.2</b> · 2026-04-01 · Runtime Truth Stabilization — unified health, safer bootstrap state, and operator repair flows</summary>
645
+
646
+ - **Unified runtime truth**: Dashboard health, MCP diagnostics, and the terminal cockpit now read from the same runtime envelope instead of maintaining split compatibility logic.
647
+ - **Workspace-safe bootstrap state**: Bootstrap manifests, instruction packets, and engine fallback paths now resolve from the workspace context instead of drifting to ambient cwd or first-run `/tmp` state.
648
+ - **Operator repair surfaces**: `nexus_runtime_health`, `nexus_doctor`, `nexus_autofix`, `nexus_memory_hygiene`, plus matching CLI commands now expose safer diagnostics and self-healing flows.
649
+ - **Dashboard contract hardening**: Creator-only investor telemetry stays permission-gated, unknown routes stay JSON-safe, compatible listeners reuse correctly, and idle Architects worklists render explicitly.
650
+ - **Control-plane resilience**: Synapse ledger storage now follows the same fallback root as the DB, and code-review gates no longer fail a good run just because one verifier worktree went stale.
651
+
652
+ Full notes: [releases/v4.8.2.md](./releases/v4.8.2.md) · Full history: [CHANGELOG.md](./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C;IAOxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3B,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAYlD,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;CAOzC"}
@@ -30,6 +30,8 @@ import { getGstackBridge } from '../../engines/gstack-bridge.js';
30
30
  import { getSharedContextDiscovery } from '../../engines/context-discovery.js';
31
31
  import { MiddlewarePipeline } from '../../engines/middleware-pipeline.js';
32
32
  import { applyExecutionPreset, listExecutionPresets, resolveExecutionPreset } from '../../engines/execution-presets.js';
33
+ import { ensureBootstrap } from '../../engines/client-bootstrap.js';
34
+ import { resolveWorkspaceContext } from '../../engines/workspace-resolver.js';
33
35
  import { synapseToolDefinitions, handleSynapseToolCall } from '../../synapse/index.js';
34
36
  import { architectsToolDefinitions, handleArchitectsToolCall } from '../../architects/index.js';
35
37
  const tokenEngine = new TokenSupremacyEngine();
@@ -42,8 +44,13 @@ const federation = new FederationEngine();
42
44
  // Lazy-initialized fallback runtime to avoid leaking a phantom runtime at module load
43
45
  let _fallbackRuntime = null;
44
46
  function getFallbackRuntime() {
45
- if (!_fallbackRuntime)
46
- _fallbackRuntime = createSubAgentRuntime({ repoRoot: process.cwd() });
47
+ if (!_fallbackRuntime) {
48
+ const workspace = resolveWorkspaceContext();
49
+ _fallbackRuntime = createSubAgentRuntime({
50
+ repoRoot: workspace.repoRoot,
51
+ artifactsRoot: path.join(workspace.stateRoot, 'runs'),
52
+ });
53
+ }
47
54
  return _fallbackRuntime;
48
55
  }
49
56
  // Lazy-initialized Graph Engine (separate DB from core memory)
@@ -98,6 +105,11 @@ const AUTONOMOUS_TOOL_ORDER = [
98
105
  'nexus_list_crews',
99
106
  'nexus_federation_status',
100
107
  'nexus_run_status',
108
+ 'nexus_runtime_health',
109
+ 'nexus_doctor',
110
+ 'nexus_autofix',
111
+ 'nexus_memory_hygiene',
112
+ 'nexus_selection_ledger',
101
113
  ];
102
114
  const AUTONOMOUS_TOOL_SET = new Set(AUTONOMOUS_TOOL_ORDER);
103
115
  const MANUAL_OR_DIAGNOSTIC_TOOLS = new Set([
@@ -149,6 +161,16 @@ const MANUAL_OR_DIAGNOSTIC_TOOLS = new Set([
149
161
  'nexus_knowledge_provenance',
150
162
  'nexus_openclaw_memory_sync',
151
163
  ]);
164
+ const PRE_BOOTSTRAP_ALLOWED_TOOLS = new Set([
165
+ 'nexus_session_bootstrap',
166
+ 'nexus_memory_stats',
167
+ 'nexus_runtime_health',
168
+ 'nexus_doctor',
169
+ 'nexus_autofix',
170
+ 'nexus_describe_tool',
171
+ 'nexus_federation_status',
172
+ 'nexus_status',
173
+ ]);
152
174
  /** Session-level telemetry tracker */
153
175
  class SessionTelemetry {
154
176
  startTime = Date.now();
@@ -165,6 +187,7 @@ class SessionTelemetry {
165
187
  callsSinceOrchestrate = 0;
166
188
  fileIntentPaths = new Set();
167
189
  tokenAutoApplied = false;
190
+ stickyTokenOptimization = false;
168
191
  bootstrapped = false;
169
192
  recordCall() {
170
193
  this.callCount++;
@@ -200,8 +223,15 @@ class SessionTelemetry {
200
223
  this.lifecyclePhase = nextPhase;
201
224
  if (nextPhase === 'bootstrapped' || nextPhase === 'orchestrated') {
202
225
  this.resetFileIntentTracking();
203
- this.optimizeTokensCalled = false;
204
- this.tokenAutoApplied = false;
226
+ if (this.stickyTokenOptimization) {
227
+ this.optimizeTokensCalled = true;
228
+ this.tokenAutoApplied = true;
229
+ this.stickyTokenOptimization = false;
230
+ }
231
+ else {
232
+ this.optimizeTokensCalled = false;
233
+ this.tokenAutoApplied = false;
234
+ }
205
235
  }
206
236
  if (nextPhase === 'orchestrated') {
207
237
  this.mindkitCheckCalled = false;
@@ -271,6 +301,7 @@ class SessionTelemetry {
271
301
  markTokenAutoApplied() {
272
302
  this.tokenAutoApplied = true;
273
303
  this.optimizeTokensCalled = true;
304
+ this.stickyTokenOptimization = true;
274
305
  }
275
306
  needsStoreMemory(currentToolName) {
276
307
  if (currentToolName === 'nexus_store_memory')
@@ -1043,6 +1074,38 @@ export class MCPAdapter {
1043
1074
  required: ['id'],
1044
1075
  },
1045
1076
  },
1077
+ {
1078
+ name: 'nexus_runtime_health',
1079
+ description: 'Return the unified runtime health envelope shared by MCP, dashboard, and terminal cockpit surfaces.',
1080
+ inputSchema: { type: 'object', properties: {}, required: [] },
1081
+ },
1082
+ {
1083
+ name: 'nexus_doctor',
1084
+ description: 'Run a structured runtime doctor pass covering workspace resolution, client bootstrap drift, mandatory engine readiness, and worktree health.',
1085
+ inputSchema: { type: 'object', properties: {}, required: [] },
1086
+ },
1087
+ {
1088
+ name: 'nexus_autofix',
1089
+ description: 'Apply safe self-healing steps: refresh bootstrap state, compact noisy memory, and report any remaining runtime issues.',
1090
+ inputSchema: { type: 'object', properties: {}, required: [] },
1091
+ },
1092
+ {
1093
+ name: 'nexus_memory_hygiene',
1094
+ description: 'Summarize and optionally run memory hygiene so duplicate, quarantined, and low-signal memories do not pollute active recall surfaces.',
1095
+ inputSchema: {
1096
+ type: 'object',
1097
+ properties: {
1098
+ apply: { type: 'boolean', description: 'When true, run memory maintenance before returning the hygiene report' },
1099
+ limit: { type: 'number', description: 'Optional audit sample size (default 80)' },
1100
+ },
1101
+ required: [],
1102
+ },
1103
+ },
1104
+ {
1105
+ name: 'nexus_selection_ledger',
1106
+ description: 'Inspect the latest selection ledger: candidate assets, chosen assets, rejected assets, and execution-ledger reasoning.',
1107
+ inputSchema: { type: 'object', properties: {}, required: [] },
1108
+ },
1046
1109
  {
1047
1110
  name: 'nexus_session_bootstrap',
1048
1111
  description: 'Read-only session-start summary. Returns current client identity, memory recall summary, memory stats, recommended next step, recommended execution mode, shortlist recommendations, and whether token optimization will be required.',
@@ -1870,11 +1933,8 @@ export class MCPAdapter {
1870
1933
  const args = request.params.arguments ?? (request.params.arguments = {});
1871
1934
  // Gate: block non-bootstrap tools BEFORE executing them to avoid wasted work and side effects
1872
1935
  if (!this.telemetry.bootstrapped &&
1873
- toolName !== 'nexus_session_bootstrap' &&
1874
- toolName !== 'nexus_memory_stats' &&
1875
- !toolName.startsWith('nexus_list_') &&
1876
- toolName !== 'nexus_federation_status' &&
1877
- toolName !== 'nexus_status') {
1936
+ !PRE_BOOTSTRAP_ALLOWED_TOOLS.has(toolName) &&
1937
+ !toolName.startsWith('nexus_list_')) {
1878
1938
  return {
1879
1939
  content: [{
1880
1940
  type: 'text',
@@ -2023,7 +2083,7 @@ export class MCPAdapter {
2023
2083
  }
2024
2084
  // Auto-generate a project-scoped memory on bootstrap so dashboard always has something to show
2025
2085
  try {
2026
- this.nexusRef.storeMemory(`Session bootstrap: ${bootstrapGoal || 'interactive session'}. Memory: prefrontal=${bootstrap.memoryStats?.prefrontal ?? 0}, hippocampus=${bootstrap.memoryStats?.hippocampus ?? 0}, cortex=${bootstrap.memoryStats?.cortex ?? 0}.`, 0.5, ['#session-start', '#auto', '#project']);
2086
+ this.nexusRef.storeMemory(`Session bootstrap: ${bootstrapGoal || 'interactive session'}. Memory: prefrontal=${bootstrap.memoryStats?.prefrontal ?? 0}, hippocampus=${bootstrap.memoryStats?.hippocampus ?? 0}, cortex=${bootstrap.memoryStats?.cortex ?? 0}.`, 0.22, ['#session-start', '#auto', '#system-hidden']);
2027
2087
  }
2028
2088
  catch { /* best-effort */ }
2029
2089
  const payload = {
@@ -2154,7 +2214,7 @@ export class MCPAdapter {
2154
2214
  // Auto-store run summary memory so dashboard and future sessions can see what happened
2155
2215
  try {
2156
2216
  const modifiedFiles = execution.workerResults.flatMap((w) => w.modifiedFiles);
2157
- this.nexusRef.storeMemory(`Run ${execution.runId} ${execution.state}: ${summarizeExecution(execution)}. Workers: ${verifiedWorkers}/${execution.workerResults.length} verified. Files modified: ${modifiedFiles.slice(0, 5).join(', ') || 'none'}.`, 0.7, ['#run-summary', '#auto', '#project']);
2217
+ this.nexusRef.storeMemory(`Run ${execution.runId} ${execution.state}: ${summarizeExecution(execution)}. Workers: ${verifiedWorkers}/${execution.workerResults.length} verified. Files modified: ${modifiedFiles.slice(0, 5).join(', ') || 'none'}.`, 0.34, ['#run-summary', '#auto', '#system-hidden']);
2158
2218
  }
2159
2219
  catch { /* best-effort */ }
2160
2220
  execution.activeSkills.forEach((skill) => this.sessionDNA.recordSkill(skill.name));
@@ -2604,6 +2664,138 @@ export class MCPAdapter {
2604
2664
  }],
2605
2665
  };
2606
2666
  }
2667
+ case 'nexus_runtime_health': {
2668
+ const envelope = this.nexusRef.getRuntimeHealthEnvelope();
2669
+ return {
2670
+ content: [{
2671
+ type: 'text',
2672
+ text: [
2673
+ `Runtime health: ${envelope.status}`,
2674
+ formatBullets([
2675
+ `Workspace: ${envelope.workspace.workspaceRoot}`,
2676
+ `Repo root: ${envelope.workspace.repoRoot}`,
2677
+ `Synapse: ${envelope.engines.synapse.mode} (${envelope.engines.synapse.storageRoot || 'n/a'})`,
2678
+ `Architects: ${envelope.engines.architects.mode} (${envelope.engines.architects.storageRoot || 'n/a'})`,
2679
+ `Primary client: ${envelope.clients.primaryClientId || 'none'}`,
2680
+ ]),
2681
+ formatJsonDetails('Structured details', envelope),
2682
+ ].join('\n\n'),
2683
+ }],
2684
+ };
2685
+ }
2686
+ case 'nexus_doctor': {
2687
+ const envelope = this.nexusRef.getRuntimeHealthEnvelope();
2688
+ const bootstrap = this.getRuntime().getUsageSnapshot()?.bootstrapManifestStatus;
2689
+ const issues = [
2690
+ ...envelope.degradedReasons,
2691
+ ...(bootstrap?.clients ?? [])
2692
+ .filter((client) => client.state !== 'installed')
2693
+ .map((client) => `${client.label}: ${client.summary}`),
2694
+ ];
2695
+ return {
2696
+ content: [{
2697
+ type: 'text',
2698
+ text: [
2699
+ `Runtime doctor ${issues.length ? 'found issues' : 'reports nominal state'}.`,
2700
+ formatBullets([
2701
+ `Status: ${envelope.status}`,
2702
+ `Workspace source: ${envelope.workspace.source}`,
2703
+ `Issues: ${issues.length}`,
2704
+ `Synapse storage: ${envelope.engines.synapse.requestedStorageRoot || 'n/a'} -> ${envelope.engines.synapse.storageRoot || 'n/a'}`,
2705
+ `Architects storage: ${envelope.engines.architects.requestedStorageRoot || 'n/a'} -> ${envelope.engines.architects.storageRoot || 'n/a'}`,
2706
+ ]),
2707
+ formatJsonDetails('Structured details', {
2708
+ envelope,
2709
+ issues,
2710
+ remediation: [
2711
+ 'Refresh workspace bootstrap artifacts with nexus_autofix or nexus-prime bootstrap runtime.',
2712
+ 'Inspect runtime health storage paths if Synapse or Architects are degraded.',
2713
+ 'Keep bootstrap/orchestrate as the first MCP sequence before manual tool use.',
2714
+ ],
2715
+ }),
2716
+ ].join('\n\n'),
2717
+ }],
2718
+ };
2719
+ }
2720
+ case 'nexus_autofix': {
2721
+ const manifest = ensureBootstrap({
2722
+ packageRoot: PROJECT_ROOT,
2723
+ workspaceRoot: this.nexusRef.getWorkspaceContext().workspaceRoot,
2724
+ phase: 'runtime',
2725
+ silent: true,
2726
+ });
2727
+ const memoryMaintenance = this.nexusRef.maintainMemory();
2728
+ this.getRuntime().recordBootstrapManifestStatus?.(manifest);
2729
+ const envelope = this.nexusRef.getRuntimeHealthEnvelope();
2730
+ return {
2731
+ content: [{
2732
+ type: 'text',
2733
+ text: [
2734
+ 'Autofix completed.',
2735
+ formatBullets([
2736
+ `Bootstrap clients tracked: ${manifest.clients.length}`,
2737
+ `Memory expired: ${Number(memoryMaintenance?.expired || 0)}`,
2738
+ `Memory quarantined: ${Number(memoryMaintenance?.quarantined || 0)}`,
2739
+ `Runtime status: ${envelope.status}`,
2740
+ ]),
2741
+ formatJsonDetails('Structured details', {
2742
+ manifest,
2743
+ memoryMaintenance,
2744
+ envelope,
2745
+ }),
2746
+ ].join('\n\n'),
2747
+ }],
2748
+ };
2749
+ }
2750
+ case 'nexus_memory_hygiene': {
2751
+ const limit = Number(request.params.arguments?.limit ?? 80);
2752
+ const apply = Boolean(request.params.arguments?.apply);
2753
+ const maintenance = apply ? this.nexusRef.maintainMemory() : null;
2754
+ const audit = this.getRuntime().auditMemory(limit) ?? { scanned: 0, quarantined: [], findings: [] };
2755
+ const health = this.getRuntime().getMemoryHealth();
2756
+ return {
2757
+ content: [{
2758
+ type: 'text',
2759
+ text: [
2760
+ 'Memory hygiene report ready.',
2761
+ formatBullets([
2762
+ `Scanned: ${Number(audit.scanned || 0)}`,
2763
+ `Quarantined: ${Number(audit.quarantined?.length || 0)}`,
2764
+ `Promoted: ${Number(health.promoted || 0)}`,
2765
+ `Shared: ${Number(health.shared || 0)}`,
2766
+ ]),
2767
+ formatJsonDetails('Structured details', {
2768
+ applied: apply,
2769
+ maintenance,
2770
+ audit,
2771
+ health,
2772
+ }),
2773
+ ].join('\n\n'),
2774
+ }],
2775
+ };
2776
+ }
2777
+ case 'nexus_selection_ledger': {
2778
+ const usage = this.getRuntime().getUsageSnapshot();
2779
+ const payload = {
2780
+ selectionAudit: usage?.artifactSelectionAudit ?? { selected: [], rejected: [], summary: 'No selection audit recorded yet.' },
2781
+ executionLedger: usage?.executionLedger ?? null,
2782
+ instructionPacket: usage?.instructionPacket ?? null,
2783
+ };
2784
+ return {
2785
+ content: [{
2786
+ type: 'text',
2787
+ text: [
2788
+ 'Selection ledger ready.',
2789
+ formatBullets([
2790
+ `Selected assets: ${payload.selectionAudit.selected?.length || 0}`,
2791
+ `Rejected assets: ${payload.selectionAudit.rejected?.length || 0}`,
2792
+ `Ledger present: ${payload.executionLedger ? 'yes' : 'no'}`,
2793
+ ]),
2794
+ formatJsonDetails('Structured details', payload),
2795
+ ].join('\n\n'),
2796
+ }],
2797
+ };
2798
+ }
2607
2799
  case 'nexus_describe_tool': {
2608
2800
  const requestedTool = String(request.params.arguments?.tool_name ?? '');
2609
2801
  if (!requestedTool) {