nexus-prime 6.6.2 → 7.0.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 (108) hide show
  1. package/README.md +8 -0
  2. package/dist/adapters/admin/authoring.d.ts +14 -0
  3. package/dist/adapters/admin/authoring.js +116 -0
  4. package/dist/adapters/admin/control.d.ts +39 -0
  5. package/dist/adapters/admin/control.js +41 -0
  6. package/dist/adapters/admin/index.d.ts +38 -0
  7. package/dist/adapters/admin/index.js +39 -0
  8. package/dist/adapters/admin/types.d.ts +45 -0
  9. package/dist/adapters/admin/types.js +8 -0
  10. package/dist/adapters/cli/index.d.ts +12 -0
  11. package/dist/adapters/cli/index.js +12 -0
  12. package/dist/adapters/hooks/context.d.ts +27 -0
  13. package/dist/adapters/hooks/context.js +28 -0
  14. package/dist/adapters/hooks/execution.d.ts +14 -0
  15. package/dist/adapters/hooks/execution.js +21 -0
  16. package/dist/adapters/hooks/health.d.ts +12 -0
  17. package/dist/adapters/hooks/health.js +14 -0
  18. package/dist/adapters/hooks/index.d.ts +83 -0
  19. package/dist/adapters/hooks/index.js +118 -0
  20. package/dist/adapters/hooks/memory.d.ts +32 -0
  21. package/dist/adapters/hooks/memory.js +23 -0
  22. package/dist/adapters/hooks/types.d.ts +34 -0
  23. package/dist/adapters/hooks/types.js +23 -0
  24. package/dist/adapters/mcp/index.d.ts +12 -0
  25. package/dist/adapters/mcp/index.js +12 -0
  26. package/dist/adapters/shared/formatters/branded-response.d.ts +13 -0
  27. package/dist/adapters/shared/formatters/branded-response.js +12 -0
  28. package/dist/adapters/shared/formatters/bullets.d.ts +7 -0
  29. package/dist/adapters/shared/formatters/bullets.js +9 -0
  30. package/dist/adapters/shared/formatters/index.d.ts +12 -0
  31. package/dist/adapters/shared/formatters/index.js +11 -0
  32. package/dist/adapters/shared/formatters/json-details.d.ts +7 -0
  33. package/dist/adapters/shared/formatters/json-details.js +9 -0
  34. package/dist/adapters/shared/formatters/response-envelope.d.ts +20 -0
  35. package/dist/adapters/shared/formatters/response-envelope.js +37 -0
  36. package/dist/adapters/shared/index.d.ts +8 -0
  37. package/dist/adapters/shared/index.js +8 -0
  38. package/dist/adapters/shared/types.d.ts +40 -0
  39. package/dist/adapters/shared/types.js +10 -0
  40. package/dist/agents/adapters/mcp/definitions.d.ts +19 -0
  41. package/dist/agents/adapters/mcp/definitions.js +99 -105
  42. package/dist/agents/adapters/mcp/dispatch.js +6 -0
  43. package/dist/agents/adapters/mcp/handlers/governance.js +4 -4
  44. package/dist/agents/adapters/mcp/handlers/kernel-execution.d.ts +26 -0
  45. package/dist/agents/adapters/mcp/handlers/kernel-execution.js +98 -0
  46. package/dist/agents/adapters/mcp/handlers/memory.js +0 -76
  47. package/dist/agents/adapters/mcp/handlers/misc.js +1 -169
  48. package/dist/agents/adapters/mcp/handlers/orchestration.js +42 -16
  49. package/dist/agents/adapters/mcp/helpers.d.ts +2 -4
  50. package/dist/agents/adapters/mcp/helpers.js +4 -13
  51. package/dist/agents/adapters/mcp.js +2 -12
  52. package/dist/cli/kernel-exec.d.ts +18 -0
  53. package/dist/cli/kernel-exec.js +57 -0
  54. package/dist/cli.js +33 -15
  55. package/dist/dashboard/app/index.html +0 -7
  56. package/dist/dashboard/app/main.js +2 -7
  57. package/dist/dashboard/app/state.js +0 -1
  58. package/dist/dashboard/app/views/workforce.js +1 -1
  59. package/dist/dashboard/app/widgets/runtime-badge.js +1 -6
  60. package/dist/dashboard/routes/architects.js +2 -10
  61. package/dist/dashboard/routes/assets.js +3 -62
  62. package/dist/dashboard/routes/authoring.js +0 -136
  63. package/dist/dashboard/routes/governance.js +2 -115
  64. package/dist/dashboard/routes/health.js +1 -2
  65. package/dist/dashboard/routes/license.js +4 -43
  66. package/dist/dashboard/routes/memory.js +5 -66
  67. package/dist/dashboard/server.js +13 -0
  68. package/dist/dashboard/types.d.ts +2 -0
  69. package/dist/engines/event-bus.d.ts +4 -1
  70. package/dist/engines/memory/store.js +2 -0
  71. package/dist/engines/memory.d.ts +9 -0
  72. package/dist/engines/memory.js +32 -11
  73. package/dist/engines/nxl-interpreter.js +2 -2
  74. package/dist/engines/orchestrator.d.ts +1 -1
  75. package/dist/engines/orchestrator.js +31 -16
  76. package/dist/kernel/context/contracts.d.ts +12 -0
  77. package/dist/kernel/context/contracts.js +9 -0
  78. package/dist/kernel/context/index.d.ts +25 -0
  79. package/dist/kernel/context/index.js +44 -0
  80. package/dist/kernel/context/service.d.ts +73 -0
  81. package/dist/kernel/context/service.js +183 -0
  82. package/dist/kernel/context/types.d.ts +69 -0
  83. package/dist/kernel/context/types.js +11 -0
  84. package/dist/kernel/execution/contracts.d.ts +21 -0
  85. package/dist/kernel/execution/contracts.js +10 -0
  86. package/dist/kernel/execution/index.d.ts +13 -0
  87. package/dist/kernel/execution/index.js +9 -0
  88. package/dist/kernel/execution/ledger.d.ts +32 -0
  89. package/dist/kernel/execution/ledger.js +96 -0
  90. package/dist/kernel/execution/service.d.ts +79 -0
  91. package/dist/kernel/execution/service.js +629 -0
  92. package/dist/kernel/execution/types.d.ts +131 -0
  93. package/dist/kernel/execution/types.js +13 -0
  94. package/dist/kernel/index.d.ts +54 -0
  95. package/dist/kernel/index.js +63 -0
  96. package/dist/kernel/runtime/backend.d.ts +20 -0
  97. package/dist/kernel/runtime/backend.js +55 -0
  98. package/dist/kernel/runtime/contracts.d.ts +35 -0
  99. package/dist/kernel/runtime/contracts.js +12 -0
  100. package/dist/kernel/runtime/index.d.ts +10 -0
  101. package/dist/kernel/runtime/index.js +8 -0
  102. package/dist/kernel/runtime/types.d.ts +44 -0
  103. package/dist/kernel/runtime/types.js +8 -0
  104. package/dist/licensing/license-sync.d.ts +3 -0
  105. package/dist/licensing/license-sync.js +7 -0
  106. package/package.json +10 -2
  107. package/dist/dashboard/app/styles/authoring.css +0 -199
  108. package/dist/dashboard/app/views/authoring.js +0 -295
package/README.md CHANGED
@@ -137,6 +137,8 @@ That's it. Memory, budgeting, and safe execution are already on.
137
137
 
138
138
  Prefer one-liner installs? `curl -fsSL https://nexus-prime.cfd/install.sh | bash`
139
139
 
140
+ Your agent calls `nexus_session_bootstrap` + `nexus_orchestrate` automatically. Auto-bootstrap runs on first non-bootstrap call, so you never have to wire the packet by hand.
141
+
140
142
  ---
141
143
 
142
144
  ## Features
@@ -253,6 +255,12 @@ Or just wire everything: **`nexus-prime setup all`**
253
255
 
254
256
  ---
255
257
 
258
+ ## Competitive position
259
+
260
+ Nexus Prime is the only control plane that remembers the repo, budgets the tokens, and ghost-passes every mutation — locally, in one process. Compare head-to-head on [nexus-prime.cfd/comparison.html](https://nexus-prime.cfd/comparison.html) or read the full docs on [nexus-prime.cfd/knowledge-base.html](https://nexus-prime.cfd/knowledge-base.html).
261
+
262
+ ---
263
+
256
264
  ## What users see
257
265
 
258
266
  Numbers from real users running real workflows on their own machines:
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Admin adapter — authoring.
3
+ *
4
+ * Programmatic specialist / skill file creation. Authoritative home for
5
+ * the markdown builders that used to live in
6
+ * `src/dashboard/routes/authoring.ts` (POST handlers are being retired
7
+ * in PR7 Phase 3). Reachable from CLI and hosts without going through MCP.
8
+ */
9
+ import type { CreateSpecialistInput, CreateSpecialistResult, CreateSkillInput, CreateSkillResult } from './types.js';
10
+ export interface AuthoringAdmin {
11
+ createSpecialist(input: CreateSpecialistInput): Promise<CreateSpecialistResult>;
12
+ createSkill(input: CreateSkillInput): Promise<CreateSkillResult>;
13
+ }
14
+ export declare function createAuthoringAdmin(repoRoot: string): AuthoringAdmin;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Admin adapter — authoring.
3
+ *
4
+ * Programmatic specialist / skill file creation. Authoritative home for
5
+ * the markdown builders that used to live in
6
+ * `src/dashboard/routes/authoring.ts` (POST handlers are being retired
7
+ * in PR7 Phase 3). Reachable from CLI and hosts without going through MCP.
8
+ */
9
+ import * as fs from 'node:fs';
10
+ import * as path from 'node:path';
11
+ /** Sanitize an id to safe filesystem characters. */
12
+ function safeId(raw) {
13
+ return raw.replace(/[^a-z0-9._-]/gi, '-').toLowerCase().slice(0, 120);
14
+ }
15
+ /**
16
+ * Render a specialist definition to markdown in the format expected by
17
+ * the specialist detail loader at `.agents/specialists/<id>.md`.
18
+ */
19
+ function specialistToMarkdown(input) {
20
+ const name = input.name;
21
+ const division = input.division ?? 'custom';
22
+ const description = input.description ?? '';
23
+ const emoji = input.emoji ?? '🤖';
24
+ const authority = input.authority ?? 'advisory';
25
+ const domains = input.domains ?? [];
26
+ const mission = input.mission ?? '';
27
+ const rules = input.rules ?? [];
28
+ const workflow = input.workflow ?? [];
29
+ const deliverables = input.deliverables ?? [];
30
+ const lines = [
31
+ `# ${emoji} ${name}`,
32
+ '',
33
+ `**Division**: ${division} `,
34
+ `**Authority**: ${authority} `,
35
+ `**Domains**: ${domains.join(', ') || '—'} `,
36
+ '',
37
+ '## Description',
38
+ '',
39
+ description || '_No description provided._',
40
+ '',
41
+ '## Mission',
42
+ '',
43
+ mission || '_No mission provided._',
44
+ '',
45
+ ];
46
+ if (rules.length) {
47
+ lines.push('## Rules', '');
48
+ rules.forEach((r) => lines.push(`- ${r}`));
49
+ lines.push('');
50
+ }
51
+ if (workflow.length) {
52
+ lines.push('## Workflow', '');
53
+ workflow.forEach((w) => lines.push(`- ${w}`));
54
+ lines.push('');
55
+ }
56
+ if (deliverables.length) {
57
+ lines.push('## Deliverables', '');
58
+ deliverables.forEach((d) => lines.push(`- ${d}`));
59
+ lines.push('');
60
+ }
61
+ return lines.join('\n');
62
+ }
63
+ /**
64
+ * Render a skill definition to markdown for `.agents/skills/<id>.md`.
65
+ */
66
+ function skillToMarkdown(input) {
67
+ const name = input.name;
68
+ const description = input.description ?? '';
69
+ const trigger = input.trigger ?? '';
70
+ const steps = input.steps ?? [];
71
+ const lines = [
72
+ `# ${name}`,
73
+ '',
74
+ description || '_No description provided._',
75
+ '',
76
+ ];
77
+ if (trigger) {
78
+ lines.push('## Trigger', '', trigger, '');
79
+ }
80
+ if (steps.length) {
81
+ lines.push('## Steps', '');
82
+ steps.forEach((s) => lines.push(`- ${s}`));
83
+ lines.push('');
84
+ }
85
+ return lines.join('\n');
86
+ }
87
+ function requireName(name, kind) {
88
+ if (typeof name !== 'string' || name.trim().length === 0) {
89
+ throw new Error(`admin.createAuthoring: ${kind} name is required`);
90
+ }
91
+ return name.trim();
92
+ }
93
+ export function createAuthoringAdmin(repoRoot) {
94
+ return {
95
+ async createSpecialist(input) {
96
+ const name = requireName(input.name, 'specialist');
97
+ const specialistId = safeId(name);
98
+ const dir = path.join(repoRoot, '.agents', 'specialists');
99
+ const filePath = path.join(dir, `${specialistId}.md`);
100
+ const content = specialistToMarkdown({ ...input, name });
101
+ await fs.promises.mkdir(dir, { recursive: true });
102
+ await fs.promises.writeFile(filePath, content, 'utf8');
103
+ return { ok: true, specialistId, filePath };
104
+ },
105
+ async createSkill(input) {
106
+ const name = requireName(input.name, 'skill');
107
+ const skillId = safeId(name);
108
+ const dir = path.join(repoRoot, '.agents', 'skills');
109
+ const filePath = path.join(dir, `${skillId}.md`);
110
+ const content = skillToMarkdown({ ...input, name });
111
+ await fs.promises.mkdir(dir, { recursive: true });
112
+ await fs.promises.writeFile(filePath, content, 'utf8');
113
+ return { ok: true, skillId, filePath };
114
+ },
115
+ };
116
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Admin adapter — control.
3
+ *
4
+ * Thin facade over operator-grade runtime actions: license management and
5
+ * memory export/import. Exposes what already exists in the engines as a
6
+ * library call so hosts can trigger it without going through MCP JSON-RPC.
7
+ */
8
+ import type { LicenseStatus } from '../../licensing/index.js';
9
+ import type { MemoryEngine, MemoryExportBundle, MemoryImportResult, MemoryItem } from '../../engines/memory.js';
10
+ export interface MemoryExportOptions {
11
+ limit?: number;
12
+ scope?: MemoryItem['scope'];
13
+ state?: MemoryItem['state'];
14
+ sessionId?: string;
15
+ }
16
+ export interface ControlLicenseAdmin {
17
+ /** Current license status (no I/O). */
18
+ status(): LicenseStatus;
19
+ /** Validate + persist a license key. Returns updated status. */
20
+ activate(token: string): LicenseStatus;
21
+ /** Remove the license key and reset to free tier. */
22
+ deactivate(): void;
23
+ /** Sync with the licensing backend. Requires network. */
24
+ sync(): Promise<LicenseStatus>;
25
+ }
26
+ export interface ControlMemoryAdmin {
27
+ /** Export in-memory items to a bundle. Requires ctx.memory. */
28
+ export(options?: MemoryExportOptions): MemoryExportBundle;
29
+ /** Import a bundle (from path or object). Requires ctx.memory. */
30
+ import(input: {
31
+ path?: string;
32
+ bundle?: MemoryExportBundle;
33
+ }): Promise<MemoryImportResult>;
34
+ }
35
+ export interface ControlAdmin {
36
+ license: ControlLicenseAdmin;
37
+ memory: ControlMemoryAdmin;
38
+ }
39
+ export declare function createControlAdmin(_repoRoot: string, memory?: MemoryEngine): ControlAdmin;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Admin adapter — control.
3
+ *
4
+ * Thin facade over operator-grade runtime actions: license management and
5
+ * memory export/import. Exposes what already exists in the engines as a
6
+ * library call so hosts can trigger it without going through MCP JSON-RPC.
7
+ */
8
+ import { getSharedLicenseManager, syncLicense } from '../../licensing/index.js';
9
+ function requireMemory(memory) {
10
+ if (!memory) {
11
+ throw new Error('admin.control.memory: ctx.memory required — pass a MemoryEngine instance to createAdmin()');
12
+ }
13
+ }
14
+ export function createControlAdmin(_repoRoot, memory) {
15
+ return {
16
+ license: {
17
+ status() {
18
+ return getSharedLicenseManager().getStatus();
19
+ },
20
+ activate(token) {
21
+ return getSharedLicenseManager().activate(token);
22
+ },
23
+ deactivate() {
24
+ getSharedLicenseManager().deactivate();
25
+ },
26
+ sync() {
27
+ return syncLicense();
28
+ },
29
+ },
30
+ memory: {
31
+ export(options = {}) {
32
+ requireMemory(memory);
33
+ return memory.exportBundle(options);
34
+ },
35
+ async import(input) {
36
+ requireMemory(memory);
37
+ return memory.importBundle(input);
38
+ },
39
+ },
40
+ };
41
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Admin adapter — barrel.
3
+ *
4
+ * Operator-grade, in-process host surface for authoring (specialist/skill
5
+ * file creation) and control-plane actions (license management, memory
6
+ * export/import) that don't belong on the observer-only dashboard and
7
+ * don't need to go through MCP JSON-RPC.
8
+ *
9
+ * import { createAdmin } from 'nexus-prime/admin';
10
+ *
11
+ * const admin = createAdmin({ repoRoot });
12
+ * await admin.authoring.createSpecialist({ name: 'Fix Auth', ... });
13
+ * admin.control.license.activate(token);
14
+ * admin.control.memory.export(); // requires ctx.memory
15
+ *
16
+ * Layering:
17
+ * - may import from `src/kernel/**`, `src/engines/**`, `src/adapters/shared/**`.
18
+ * - MUST NOT import from `src/agents/adapters/mcp/**` or `src/dashboard/**`.
19
+ * Enforced by `test/adapter-boundary.test.ts`.
20
+ */
21
+ import { type AuthoringAdmin } from './authoring.js';
22
+ import { type ControlAdmin } from './control.js';
23
+ import type { AdminContext } from './types.js';
24
+ export type { AdminContext, CreateSpecialistInput, CreateSpecialistResult, CreateSkillInput, CreateSkillResult, } from './types.js';
25
+ export type { AuthoringAdmin, } from './authoring.js';
26
+ export type { ControlAdmin, ControlLicenseAdmin, ControlMemoryAdmin, MemoryExportOptions, } from './control.js';
27
+ export interface Admin {
28
+ authoring: AuthoringAdmin;
29
+ control: ControlAdmin;
30
+ }
31
+ /**
32
+ * Compose an admin surface bound to an absolute repoRoot. Fail-fast: throws
33
+ * if `ctx.repoRoot` is missing or not absolute, mirroring the hooks adapter
34
+ * contract from PR6.
35
+ *
36
+ * Pass `ctx.memory` to enable admin.control.memory.* methods.
37
+ */
38
+ export declare function createAdmin(ctx: AdminContext): Admin;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Admin adapter — barrel.
3
+ *
4
+ * Operator-grade, in-process host surface for authoring (specialist/skill
5
+ * file creation) and control-plane actions (license management, memory
6
+ * export/import) that don't belong on the observer-only dashboard and
7
+ * don't need to go through MCP JSON-RPC.
8
+ *
9
+ * import { createAdmin } from 'nexus-prime/admin';
10
+ *
11
+ * const admin = createAdmin({ repoRoot });
12
+ * await admin.authoring.createSpecialist({ name: 'Fix Auth', ... });
13
+ * admin.control.license.activate(token);
14
+ * admin.control.memory.export(); // requires ctx.memory
15
+ *
16
+ * Layering:
17
+ * - may import from `src/kernel/**`, `src/engines/**`, `src/adapters/shared/**`.
18
+ * - MUST NOT import from `src/agents/adapters/mcp/**` or `src/dashboard/**`.
19
+ * Enforced by `test/adapter-boundary.test.ts`.
20
+ */
21
+ import * as path from 'node:path';
22
+ import { createAuthoringAdmin } from './authoring.js';
23
+ import { createControlAdmin } from './control.js';
24
+ /**
25
+ * Compose an admin surface bound to an absolute repoRoot. Fail-fast: throws
26
+ * if `ctx.repoRoot` is missing or not absolute, mirroring the hooks adapter
27
+ * contract from PR6.
28
+ *
29
+ * Pass `ctx.memory` to enable admin.control.memory.* methods.
30
+ */
31
+ export function createAdmin(ctx) {
32
+ if (!ctx.repoRoot || !path.isAbsolute(ctx.repoRoot)) {
33
+ throw new Error('createAdmin: ctx.repoRoot must be an absolute path');
34
+ }
35
+ return {
36
+ authoring: createAuthoringAdmin(ctx.repoRoot),
37
+ control: createControlAdmin(ctx.repoRoot, ctx.memory),
38
+ };
39
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Admin adapter — shared input/output shapes.
3
+ *
4
+ * Operator-grade library surface for authoring and control-plane actions
5
+ * that do not belong on the observer-only dashboard and don't need to
6
+ * go through MCP JSON-RPC. Consumed by CLI, hosts, and future tooling.
7
+ */
8
+ import type { MemoryEngine } from '../../engines/memory.js';
9
+ export interface AdminContext {
10
+ /** Absolute path to the repo root the admin surface operates on. */
11
+ repoRoot: string;
12
+ /**
13
+ * MemoryEngine instance for admin.control.memory.* methods.
14
+ * Optional — authoring and license control work without it.
15
+ */
16
+ memory?: MemoryEngine;
17
+ }
18
+ export interface CreateSpecialistInput {
19
+ name: string;
20
+ division?: string;
21
+ description?: string;
22
+ emoji?: string;
23
+ authority?: string;
24
+ domains?: string[];
25
+ mission?: string;
26
+ rules?: string[];
27
+ workflow?: string[];
28
+ deliverables?: string[];
29
+ }
30
+ export interface CreateSpecialistResult {
31
+ ok: true;
32
+ specialistId: string;
33
+ filePath: string;
34
+ }
35
+ export interface CreateSkillInput {
36
+ name: string;
37
+ description?: string;
38
+ trigger?: string;
39
+ steps?: string[];
40
+ }
41
+ export interface CreateSkillResult {
42
+ ok: true;
43
+ skillId: string;
44
+ filePath: string;
45
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Admin adapter — shared input/output shapes.
3
+ *
4
+ * Operator-grade library surface for authoring and control-plane actions
5
+ * that do not belong on the observer-only dashboard and don't need to
6
+ * go through MCP JSON-RPC. Consumed by CLI, hosts, and future tooling.
7
+ */
8
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * CLI adapter entry point.
3
+ *
4
+ * Re-exports the CLI program from `src/cli.ts` so that tooling can
5
+ * import from the canonical adapter path (`src/adapters/cli/index.ts`)
6
+ * while the implementation continues to live in `src/cli.ts` during
7
+ * the PR4+5 migration.
8
+ *
9
+ * PR4+5 W3: once the full adapter split lands, the CLI body will move
10
+ * here and `src/cli.ts` will become the shim.
11
+ */
12
+ export * from '../../cli.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * CLI adapter entry point.
3
+ *
4
+ * Re-exports the CLI program from `src/cli.ts` so that tooling can
5
+ * import from the canonical adapter path (`src/adapters/cli/index.ts`)
6
+ * while the implementation continues to live in `src/cli.ts` during
7
+ * the PR4+5 migration.
8
+ *
9
+ * PR4+5 W3: once the full adapter split lands, the CLI body will move
10
+ * here and `src/cli.ts` will become the shim.
11
+ */
12
+ export * from '../../cli.js';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Hooks adapter — context namespace.
3
+ *
4
+ * Direct pass-through over `kernel.run.*` context methods. No reimplementation,
5
+ * no side logic. Exists so hosts have a typed in-process surface that never
6
+ * imports MCP or dashboard code.
7
+ */
8
+ import type { AssemblyResult, BudgetConfig, CompiledContextPack, CompiledContextRequest, ContextDelta, FileRef, ReadingPlan, SessionSummary, TokenBudget } from '../../kernel/context/index.js';
9
+ export declare const ContextHooks: {
10
+ readonly init: () => Promise<void>;
11
+ readonly compile: (request: CompiledContextRequest) => Promise<CompiledContextPack>;
12
+ readonly hypertuneMax: (task: string, files: FileRef[], graphConnectivity?: (chunk: {
13
+ source: string;
14
+ label: string;
15
+ }) => number) => {
16
+ plan: ReadingPlan;
17
+ assembly: AssemblyResult;
18
+ budgetConfig: BudgetConfig;
19
+ };
20
+ readonly differential: (prev: SessionSummary, curr: FileRef[]) => ContextDelta;
21
+ readonly loadLatestSessionSummary: () => Promise<SessionSummary | null>;
22
+ readonly allocateBudget: (workers: Array<{
23
+ id: string;
24
+ estimatedValue: number;
25
+ estimatedCost: number;
26
+ }>, totalBudget?: number) => TokenBudget;
27
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Hooks adapter — context namespace.
3
+ *
4
+ * Direct pass-through over `kernel.run.*` context methods. No reimplementation,
5
+ * no side logic. Exists so hosts have a typed in-process surface that never
6
+ * imports MCP or dashboard code.
7
+ */
8
+ import { kernel } from '../../kernel/index.js';
9
+ export const ContextHooks = {
10
+ init() {
11
+ return kernel.run.init();
12
+ },
13
+ compile(request) {
14
+ return kernel.run.compileContext(request);
15
+ },
16
+ hypertuneMax(task, files, graphConnectivity) {
17
+ return kernel.run.hypertuneMax(task, files, graphConnectivity);
18
+ },
19
+ differential(prev, curr) {
20
+ return kernel.run.differential(prev, curr);
21
+ },
22
+ loadLatestSessionSummary() {
23
+ return kernel.run.loadLatestSessionSummary();
24
+ },
25
+ allocateBudget(workers, totalBudget) {
26
+ return kernel.run.allocateBudget(workers, totalBudget);
27
+ },
28
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Hooks adapter — execution namespace.
3
+ *
4
+ * Direct pass-through over `kernel.run.step/verify/merge/execute`. The kernel
5
+ * owns the step→verify→merge invariants; hooks only adapt the call shape.
6
+ */
7
+ import type { RunMergeRequest, RunMergeResult, RunStepRequest, RunStepResult, RunVerifyRequest, RunVerifyResult } from '../../kernel/execution/index.js';
8
+ import type { ExecutedStep, RuntimeExecuteInput } from '../../kernel/runtime/index.js';
9
+ export declare const ExecutionHooks: {
10
+ readonly step: (request: RunStepRequest) => Promise<RunStepResult>;
11
+ readonly verify: (request: RunVerifyRequest) => Promise<RunVerifyResult>;
12
+ readonly merge: (request: RunMergeRequest) => Promise<RunMergeResult>;
13
+ readonly execute: (request: RuntimeExecuteInput) => Promise<ExecutedStep>;
14
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Hooks adapter — execution namespace.
3
+ *
4
+ * Direct pass-through over `kernel.run.step/verify/merge/execute`. The kernel
5
+ * owns the step→verify→merge invariants; hooks only adapt the call shape.
6
+ */
7
+ import { kernel } from '../../kernel/index.js';
8
+ export const ExecutionHooks = {
9
+ step(request) {
10
+ return kernel.run.step(request);
11
+ },
12
+ verify(request) {
13
+ return kernel.run.verify(request);
14
+ },
15
+ merge(request) {
16
+ return kernel.run.merge(request);
17
+ },
18
+ execute(request) {
19
+ return kernel.run.execute(request);
20
+ },
21
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hooks adapter — health namespace.
3
+ *
4
+ * Thin wrapper that asks a host-supplied provider for the current
5
+ * RuntimeHealthEnvelope. The envelope construction lives in
6
+ * `src/engines/runtime-health.ts`; hooks just forwards the read.
7
+ */
8
+ import type { RuntimeHealthEnvelope } from '../../engines/runtime-health.js';
9
+ export interface HealthHooks {
10
+ runtime(): Promise<RuntimeHealthEnvelope>;
11
+ }
12
+ export declare function createHealthHooks(provider: () => RuntimeHealthEnvelope | Promise<RuntimeHealthEnvelope>): HealthHooks;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Hooks adapter — health namespace.
3
+ *
4
+ * Thin wrapper that asks a host-supplied provider for the current
5
+ * RuntimeHealthEnvelope. The envelope construction lives in
6
+ * `src/engines/runtime-health.ts`; hooks just forwards the read.
7
+ */
8
+ export function createHealthHooks(provider) {
9
+ return {
10
+ async runtime() {
11
+ return await provider();
12
+ },
13
+ };
14
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Hooks adapter — barrel.
3
+ *
4
+ * In-process host surface over `kernel.run.*` and selected engine services.
5
+ * Consumers should import from this module:
6
+ *
7
+ * import { Hooks, createHooks } from '../../adapters/hooks/index.js';
8
+ *
9
+ * const hooks = createHooks({ repoRoot, memory, runtimeHealth });
10
+ * await hooks.context.init();
11
+ * const pack = await hooks.context.compile({ runId, host: 'cli', ... });
12
+ *
13
+ * The statically-exported `Hooks` namespace is a convenience for hosts that
14
+ * don't need multi-repo isolation — it uses kernel singletons rooted at
15
+ * process.cwd(). `createHooks()` returns a composed surface bound to the
16
+ * supplied `ctx.repoRoot` so hosts that manage multiple repos can isolate
17
+ * reads and mutations to the right working tree.
18
+ */
19
+ import { ContextHooks } from './context.js';
20
+ import { ExecutionHooks } from './execution.js';
21
+ import { type HealthHooks } from './health.js';
22
+ import { type MemoryHooks } from './memory.js';
23
+ import type { HooksContext } from './types.js';
24
+ import { type RunMergeRequest, type RunMergeResult, type RunStepRequest, type RunStepResult, type RunVerifyRequest, type RunVerifyResult } from '../../kernel/execution/index.js';
25
+ import type { ExecutedStep, RuntimeExecuteInput } from '../../kernel/runtime/index.js';
26
+ import type { CompiledContextRequest, FileRef } from '../../kernel/context/index.js';
27
+ export type { HooksContext, HookResult } from './types.js';
28
+ /**
29
+ * Stateless hooks that don't need a HooksContext.
30
+ * - Context + Execution delegate directly to kernel singletons rooted at
31
+ * process.cwd(). Use `createHooks()` for multi-repo hosts.
32
+ */
33
+ export declare const Hooks: {
34
+ readonly context: {
35
+ readonly init: () => Promise<void>;
36
+ readonly compile: (request: CompiledContextRequest) => Promise<import("../../kernel/index.js").CompiledContextPack>;
37
+ readonly hypertuneMax: (task: string, files: FileRef[], graphConnectivity?: (chunk: {
38
+ source: string;
39
+ label: string;
40
+ }) => number) => {
41
+ plan: import("../../engines/token-supremacy.js").ReadingPlan;
42
+ assembly: import("../../engines/context-assembler.js").AssemblyResult;
43
+ budgetConfig: import("../../engines/context-assembler.js").BudgetConfig;
44
+ };
45
+ readonly differential: (prev: import("../../engines/token-supremacy.js").SessionSummary, curr: FileRef[]) => import("../../engines/token-supremacy.js").ContextDelta;
46
+ readonly loadLatestSessionSummary: () => Promise<import("../../engines/token-supremacy.js").SessionSummary | null>;
47
+ readonly allocateBudget: (workers: Array<{
48
+ id: string;
49
+ estimatedValue: number;
50
+ estimatedCost: number;
51
+ }>, totalBudget?: number) => import("../../engines/token-supremacy.js").TokenBudget;
52
+ };
53
+ readonly execution: {
54
+ readonly step: (request: RunStepRequest) => Promise<RunStepResult>;
55
+ readonly verify: (request: RunVerifyRequest) => Promise<RunVerifyResult>;
56
+ readonly merge: (request: RunMergeRequest) => Promise<RunMergeResult>;
57
+ readonly execute: (request: RuntimeExecuteInput) => Promise<ExecutedStep>;
58
+ };
59
+ };
60
+ export type BoundContextHooks = typeof ContextHooks;
61
+ export type BoundExecutionHooks = typeof ExecutionHooks;
62
+ export interface ComposedHooks {
63
+ context: BoundContextHooks;
64
+ execution: BoundExecutionHooks;
65
+ health: HealthHooks;
66
+ memory: MemoryHooks;
67
+ }
68
+ /**
69
+ * Compose a fully-wired hooks namespace for a host that has memory + runtime
70
+ * providers. Throws at construction time if required providers are missing —
71
+ * fail-fast contract so hosts catch wiring errors early.
72
+ *
73
+ * Context + execution are bound to `ctx.repoRoot`:
74
+ * - context.compile / hypertuneMax / differential pre-resolve relative paths
75
+ * against repoRoot before calling the kernel.
76
+ * - execution uses a dedicated KernelExecutionServiceImpl rooted at repoRoot;
77
+ * the process-wide kernel singleton is left untouched.
78
+ */
79
+ export declare function createHooks(ctx: HooksContext): ComposedHooks;
80
+ export { ContextHooks } from './context.js';
81
+ export { ExecutionHooks } from './execution.js';
82
+ export type { HealthHooks } from './health.js';
83
+ export type { MemoryHooks } from './memory.js';