nexus-ai-pro 1.22.0 → 1.23.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 (54) hide show
  1. package/API_STABILITY.md +12 -0
  2. package/CHANGELOG.md +36 -1
  3. package/README.md +26 -9
  4. package/dist/context-hub/diff.d.ts +32 -0
  5. package/dist/context-hub/diff.js +64 -0
  6. package/dist/context-hub/hub.d.ts +268 -0
  7. package/dist/context-hub/hub.js +313 -0
  8. package/dist/context-hub/index.d.ts +46 -0
  9. package/dist/context-hub/index.js +55 -0
  10. package/dist/evaluate/cache.d.ts +70 -0
  11. package/dist/evaluate/cache.js +73 -0
  12. package/dist/evaluate/index.d.ts +1 -0
  13. package/dist/evaluate/index.js +1 -0
  14. package/dist/evaluate/run.d.ts +13 -0
  15. package/dist/evaluate/run.js +40 -11
  16. package/dist/insights/clusters.d.ts +98 -0
  17. package/dist/insights/clusters.js +153 -0
  18. package/dist/insights/index.d.ts +8 -0
  19. package/dist/insights/index.js +3 -0
  20. package/dist/insights/proposals.d.ts +229 -0
  21. package/dist/insights/proposals.js +241 -0
  22. package/dist/insights/regressions.d.ts +65 -0
  23. package/dist/insights/regressions.js +128 -0
  24. package/dist/prompts/evaluate.d.ts +3 -1
  25. package/dist/prompts/evaluate.js +4 -0
  26. package/dist/prompts/gates.d.ts +10 -1
  27. package/dist/prompts/gates.js +38 -37
  28. package/dist/types/evaluate.d.ts +10 -0
  29. package/dist-cjs/context-hub/diff.d.ts +32 -0
  30. package/dist-cjs/context-hub/diff.js +68 -0
  31. package/dist-cjs/context-hub/hub.d.ts +268 -0
  32. package/dist-cjs/context-hub/hub.js +323 -0
  33. package/dist-cjs/context-hub/index.d.ts +46 -0
  34. package/dist-cjs/context-hub/index.js +105 -0
  35. package/dist-cjs/evaluate/cache.d.ts +70 -0
  36. package/dist-cjs/evaluate/cache.js +113 -0
  37. package/dist-cjs/evaluate/index.d.ts +1 -0
  38. package/dist-cjs/evaluate/index.js +6 -1
  39. package/dist-cjs/evaluate/run.d.ts +13 -0
  40. package/dist-cjs/evaluate/run.js +40 -11
  41. package/dist-cjs/insights/clusters.d.ts +98 -0
  42. package/dist-cjs/insights/clusters.js +159 -0
  43. package/dist-cjs/insights/index.d.ts +8 -0
  44. package/dist-cjs/insights/index.js +16 -0
  45. package/dist-cjs/insights/proposals.d.ts +229 -0
  46. package/dist-cjs/insights/proposals.js +282 -0
  47. package/dist-cjs/insights/regressions.d.ts +65 -0
  48. package/dist-cjs/insights/regressions.js +131 -0
  49. package/dist-cjs/prompts/evaluate.d.ts +3 -1
  50. package/dist-cjs/prompts/evaluate.js +4 -0
  51. package/dist-cjs/prompts/gates.d.ts +10 -1
  52. package/dist-cjs/prompts/gates.js +39 -37
  53. package/dist-cjs/types/evaluate.d.ts +10 -0
  54. package/package.json +49 -3
package/API_STABILITY.md CHANGED
@@ -456,6 +456,18 @@ with nexus-ai-pro and declares the core versions it works with as a peer depende
456
456
  - The access rules are a guarantee: loopback binding by default, a token on every request, the token
457
457
  in a header for every change, and loopback hosts only unless others are allowed.
458
458
 
459
+ ## Team platform stage (1.23.0)
460
+
461
+ The context hub (`nexus-ai-pro/context-hub`), insights (`nexus-ai-pro/insights`), and the studio's
462
+ accounts are experimental in production readiness. Their contracts follow the 1.x rules.
463
+
464
+ - A bundle's content version covers its name, description, prompts, instructions, tools, skills, and
465
+ config, and is stable across 1.x, so the same content is the same version in every release.
466
+ - The export format is `nexus-context-bundle`, format version 1; a later release reads it.
467
+ - A cached evaluation output is keyed by the fingerprint, the example's id and inputs, and the
468
+ repetition. The key's derivation is stable across 1.x, so a cache survives an upgrade.
469
+ - The studio's roles keep their order and meaning; new actions are assigned to an existing role.
470
+
459
471
  ## Retrieval breadth stage (1.22.0)
460
472
 
461
473
  The loaders (`nexus-ai-pro/loaders/*`), the Redis, Pinecone, Weaviate, Chroma, and SQLite vector
package/CHANGELOG.md CHANGED
@@ -4,6 +4,40 @@ Notable changes to this project are recorded here. The format follows [Keep a Ch
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.23.0] - 2026-09-30
8
+
9
+ The team engineering platform. The studio becomes something a team shares, and it starts finding
10
+ problems on its own.
11
+
12
+ ### Added
13
+
14
+ - **A shared studio.** Accounts through an authenticator — personal links, identity headers from a
15
+ signing-in proxy, or bearer tokens verified by your function, such as OIDC — with four roles
16
+ (viewer, reviewer, editor, admin), an audit log of every change and every refused attempt, comments
17
+ on runs, review items, proposals, threads, and bundles, per-person page tokens for changes, and
18
+ `Secure` cookies behind HTTPS. Local, token-only use stays the default. The CLI gains `--users` and
19
+ `--journal`, and a config module may export `options`.
20
+ - **The context hub** on `nexus-ai-pro/context-hub`: prompts, instructions, tool sets, skills, and
21
+ settings versioned together as bundles, committed by content, labelled, promoted through evaluation
22
+ gates, diffed, rolled back, and exported with their prompts to move between projects. Bundles live in
23
+ any prompt store. The studio shows them.
24
+ - **Insights** on `nexus-ai-pro/insights`: failing and slow runs clustered by error, trajectory, or
25
+ meaning; regressions between two time windows; and, opt-in, a proposed fix — a candidate prompt or
26
+ bundle version — evaluated against the dataset before it waits in the studio's inbox for a person
27
+ to promote, with an optional pull request through an injected client.
28
+ - **Evaluation caching**: `evaluate()` reuses a target's outputs when the example and the target's
29
+ fingerprint are unchanged, so a comparison re-runs only what changed; evaluators always run again.
30
+ `MemoryEvaluationCache`, `FileEvaluationCache`, and `fingerprintOf()` on `nexus-ai-pro/evaluate`;
31
+ `evaluatePrompt()` fingerprints the prompt version itself.
32
+
33
+ ### Changed
34
+
35
+ - The guides are rewritten for readability: each says what its feature is for before its options,
36
+ options and fields are in tables, and long sentences are split. Every export is still explained.
37
+ - `nexus-ai-pro-studio` requires nexus-ai-pro 1.23 or newer.
38
+ - The studio's development type paths map each entry point to the file it publishes, so studio tests
39
+ exercise what the package ships.
40
+
7
41
  ## [1.22.0] - 2026-09-29
8
42
 
9
43
  Retrieval and integration breadth. Getting documents in, finding the right ones, and reaching the
@@ -1118,7 +1152,8 @@ shared policy vocabulary is in place for a future release that revisits this.
1118
1152
  - URL fetching rejects unsafe private-network targets and limits response reads.
1119
1153
  - CLI and audit findings no longer disclose detected secret values.
1120
1154
 
1121
- [Unreleased]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.22.0...HEAD
1155
+ [Unreleased]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.23.0...HEAD
1156
+ [1.23.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.22.0...v1.23.0
1122
1157
  [1.22.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.21.0...v1.22.0
1123
1158
  [1.21.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.20.0...v1.21.0
1124
1159
  [1.20.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.19.0...v1.20.0
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # nexus-ai-pro
2
2
 
3
- The typed AI framework for TypeScript. One API for provider routing and failover, agent graphs that
4
- run branches in parallel and survive a restart, durable background operations, guardrails, cost
5
- control, images, voice, and evals.
3
+ The typed AI framework for TypeScript. One API for provider routing and failover, agent graphs and
4
+ workflows that run branches in parallel and survive a restart, retrieval over any vector store, MCP,
5
+ durable background operations, guardrails, cost control, images, voice, and evals — with a studio a
6
+ team can share.
6
7
 
7
8
  Import the whole runtime, or one piece: every capability has its own entry point with a size budget
8
9
  CI enforces, and [the packaging guide](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/packaging.md) publishes what each one costs. A graph-only application loads 49 KB
@@ -90,6 +91,14 @@ You can still pass a plain `NexusAIConfig` to `new NexusAI(...)` when you want f
90
91
  - embed text through the same routing, caching, batching, budget, retry, and metrics as a completion
91
92
  - run long operations that survive a restart, with leases, retries, dead-lettering, and signed webhooks
92
93
  - build stateful graphs with cycles, fan-out, subgraphs, human approval, and resumable checkpoints
94
+ - make ordinary async functions durable step by step, and recover a crashed run at the step it died on
95
+ - load files, web pages, sitemaps, and Git repositories into retrieval, over memory, Postgres, SQLite,
96
+ Redis, Qdrant, Pinecone, Weaviate, or Chroma
97
+ - retrieve with hybrid keyword and vector search, reranking, and diversity, and measure it with evals
98
+ - reach tools from many MCP servers under one configuration, with allowlists and credentials from the
99
+ environment
100
+ - version prompts, instructions, tools, and skills together, and promote them through evaluation gates
101
+ - find failing and slow runs, detect regressions, and review evaluated fix proposals in a shared studio
93
102
  - trip routing away from a failing provider, and share one rate-limit budget across workers
94
103
  - reach the providers' half-price asynchronous batch tier behind one operation handle
95
104
  - persist generated media to disk or S3 with tenant isolation, retention, and checksums
@@ -112,6 +121,8 @@ from the doc comments. The guides live in the repository, so these links go to G
112
121
  | [MCP](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/mcp.md) | Borrowing tools from MCP servers, a registry of many, and serving your own |
113
122
  | [Traces](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/tracing.md) | Run trees, queries, feedback, comparison, and alerts |
114
123
  | [Evaluation](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/evaluation.md) | Datasets, evaluators, experiments, comparisons with a verdict, review queues, LLM judges |
124
+ | [Context hub](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/context-hub.md) | Prompts, instructions, tools, and skills versioned together, promoted through gates, and moved between projects |
125
+ | [Insights](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/insights.md) | Failing and slow runs clustered, regressions between time windows, and evaluated fix proposals |
115
126
  | [Prompts](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/prompts.md) | Typed templates, content versions, gated promotion, rollback, A/B splits, serving through outages |
116
127
  | [Postgres](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/postgres.md) | One adapter family for operations, memory, traces, evaluation, circuits, and prompts |
117
128
  | [SQLite](https://github.com/mkhitar-abrahamyan/nexus-ai/blob/main/docs/sqlite.md) | Durable operations, checkpoints, and memory on one machine, over any SQLite driver |
@@ -179,10 +190,11 @@ interface, or enum, has no doc comment, and `npm run docs:guides` fails when a g
179
190
  every export of the entry points it covers, or its generated reference is stale. Both hold at 100%;
180
191
  `--list` names what is missing, and `npm run docs:update` regenerates the references.
181
192
 
182
- Real provider conformance is opt-in:
193
+ Real provider conformance, and the vector store contract against real servers, are opt-in:
183
194
 
184
195
  ```bash
185
196
  npm run test:conformance:real
197
+ npm run test:vectors:live
186
198
  ```
187
199
 
188
200
  ## Roadmap
@@ -201,11 +213,16 @@ Shipped so far:
201
213
  - record and replay of provider traffic;
202
214
  - prompt versioning: typed templates, content versions, gated promotion, and serving through outages;
203
215
  - a self-hosted agent server, and a local studio as a separate package;
204
- - per-entry-point size budgets.
205
-
206
- Next: durable functional workflows and step-level recovery, then retrieval and integration breadth,
207
- a shared team studio, and self-managed deployment at scale, before 2.0.0 consolidates. The image
208
- family leaves experimental once recorded live conformance passes on all three backends.
216
+ - per-entry-point size budgets;
217
+ - vector stores behind one contract, and deprecation warnings at run time;
218
+ - durable functional workflows, step-level recovery in the server, SQLite persistence, and diagrams
219
+ as images;
220
+ - document loaders, five more vector stores, hybrid retrieval with reranking, and an MCP registry;
221
+ - a shared studio with accounts, roles, an audit log, and comments; a context hub; insights with
222
+ evaluated fix proposals; and evaluation caching.
223
+
224
+ Next: self-managed deployment at scale, before 2.0.0 consolidates. The image family leaves experimental once recorded live
225
+ conformance passes on all three backends.
209
226
 
210
227
  ## Before Production
211
228
 
@@ -0,0 +1,32 @@
1
+ import { type PromptLineChange } from '../prompts/diff.js';
2
+ import type { ContextBundle } from './hub.js';
3
+ /** One entry that differs between two bundle versions. */
4
+ export interface ContextChange {
5
+ /** The part of the bundle. */
6
+ section: 'description' | 'prompts' | 'instructions' | 'tools' | 'skills' | 'config';
7
+ /** The entry within it: a prompt role, an instruction or skill name, a tool name, or a config key. */
8
+ key: string;
9
+ /** Whether the entry was added, removed, or changed. */
10
+ change: 'added' | 'removed' | 'changed';
11
+ /** Line by line, for text: an instruction, a skill's instructions, or the description. */
12
+ lines?: PromptLineChange[];
13
+ /** The entry before, for anything that is not text. */
14
+ before?: unknown;
15
+ /** The entry after, for anything that is not text. */
16
+ after?: unknown;
17
+ }
18
+ /** What changed between two versions of a bundle. */
19
+ export interface ContextDiff {
20
+ /** The bundle. */
21
+ name: string;
22
+ /** The earlier version. */
23
+ from: string;
24
+ /** The later version. */
25
+ to: string;
26
+ /** Every entry that differs, section by section. */
27
+ changes: ContextChange[];
28
+ }
29
+ /** Compares two versions of a bundle, entry by entry, with line diffs for text. */
30
+ export declare function diffContexts(from: ContextBundle, to: ContextBundle): ContextDiff;
31
+ /** A diff as text, one line per change and `+`/`-` lines for text, for a terminal or a pull request. */
32
+ export declare function formatContextDiff(diff: ContextDiff): string;
@@ -0,0 +1,64 @@
1
+ import { diffLines } from '../prompts/diff.js';
2
+ import { canonicalJson } from '../prompts/version.js';
3
+ export function diffContexts(from, to) {
4
+ const changes = [];
5
+ if ((from.description ?? '') !== (to.description ?? '')) {
6
+ changes.push({
7
+ section: 'description',
8
+ key: 'description',
9
+ change: from.description === undefined ? 'added' : to.description === undefined ? 'removed' : 'changed',
10
+ lines: diffLines(from.description ?? '', to.description ?? ''),
11
+ });
12
+ }
13
+ compare(changes, 'prompts', from.prompts, to.prompts);
14
+ compare(changes, 'instructions', from.instructions, to.instructions, (value) => value);
15
+ compare(changes, 'tools', Object.fromEntries((from.tools ?? []).map((tool) => [tool.name, tool])), Object.fromEntries((to.tools ?? []).map((tool) => [tool.name, tool])));
16
+ compare(changes, 'skills', from.skills, to.skills, (value) => {
17
+ const skill = value;
18
+ return `${skill.description}\n\n${skill.instructions}${Object.entries(skill.resources ?? {})
19
+ .map(([name, text]) => `\n\n[${name}]\n${text}`)
20
+ .join('')}`;
21
+ });
22
+ compare(changes, 'config', from.config, to.config);
23
+ return { name: to.name, from: from.version, to: to.version, changes };
24
+ }
25
+ export function formatContextDiff(diff) {
26
+ const lines = [`${diff.name}: ${diff.from} -> ${diff.to}`];
27
+ if (diff.changes.length === 0)
28
+ lines.push(' no changes');
29
+ for (const change of diff.changes) {
30
+ lines.push(` ${change.change} ${change.section}.${change.key}`);
31
+ for (const line of change.lines ?? []) {
32
+ if (line.op !== '=')
33
+ lines.push(` ${line.op} ${line.text}`);
34
+ }
35
+ if (!change.lines && change.change === 'changed') {
36
+ lines.push(` - ${canonicalJson(change.before)}`, ` + ${canonicalJson(change.after)}`);
37
+ }
38
+ }
39
+ return lines.join('\n');
40
+ }
41
+ function compare(changes, section, before, after, asText) {
42
+ const keys = [...new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})])].sort();
43
+ for (const key of keys) {
44
+ const was = before?.[key];
45
+ const is = after?.[key];
46
+ if (was !== undefined && is !== undefined && canonicalJson(was) === canonicalJson(is))
47
+ continue;
48
+ const change = was === undefined ? 'added' : is === undefined ? 'removed' : 'changed';
49
+ changes.push(asText
50
+ ? {
51
+ section,
52
+ key,
53
+ change,
54
+ lines: diffLines(was === undefined ? '' : asText(was), is === undefined ? '' : asText(is)),
55
+ }
56
+ : {
57
+ section,
58
+ key,
59
+ change,
60
+ ...(was === undefined ? {} : { before: was }),
61
+ ...(is === undefined ? {} : { after: is }),
62
+ });
63
+ }
64
+ }
@@ -0,0 +1,268 @@
1
+ import type { GateResult } from '../prompts/errors.js';
2
+ import type { PromptRegistry } from '../prompts/registry.js';
3
+ import type { PromptHistoryEntry, PromptLabel, PromptStore, PromptVersion, RenderedPrompt, RenderOptions } from '../types/prompts.js';
4
+ import { type ContextDiff } from './diff.js';
5
+ /** A prompt a bundle uses, pinned to one content version of the prompt registry. */
6
+ export interface ContextPromptPin {
7
+ /** The prompt's name in the registry. */
8
+ name: string;
9
+ /** Its content version, such as `p3f9a1c02b7de`. */
10
+ version: string;
11
+ }
12
+ /** A tool a bundle offers: its name, description, and argument schema. The implementation stays in code. */
13
+ export interface ContextTool {
14
+ /** The tool's name, as the model sees it. */
15
+ name: string;
16
+ /** What the tool does, for the model. */
17
+ description?: string;
18
+ /** JSON Schema for its arguments. */
19
+ parameters?: Record<string, unknown>;
20
+ }
21
+ /** A skill: instructions for one kind of task, with the reference material it needs. */
22
+ export interface ContextSkill {
23
+ /** When the skill applies, so an agent or a router can choose it. */
24
+ description: string;
25
+ /** How to do the task. */
26
+ instructions: string;
27
+ /** Reference material by name, such as a style guide or a schema. */
28
+ resources?: Record<string, string>;
29
+ }
30
+ /**
31
+ * Everything an agent runs with, versioned together: pinned prompts, named instructions, tool
32
+ * definitions, skills, and configuration. A change to any part is a new version of the whole.
33
+ */
34
+ export interface ContextBundleDefinition {
35
+ /** The bundle's name, such as `support-agent`. */
36
+ name: string;
37
+ /** What the bundle is for. */
38
+ description?: string;
39
+ /** Prompts by role, such as `{ answer: { name: 'support-answer', version: 'p…' } }`. */
40
+ prompts?: Record<string, ContextPromptPin>;
41
+ /** Named instructions, such as a system policy or a tone guide. */
42
+ instructions?: Record<string, string>;
43
+ /** The tools the agent is offered. */
44
+ tools?: ContextTool[];
45
+ /** Skills by name. */
46
+ skills?: Record<string, ContextSkill>;
47
+ /** Settings the application reads, such as a model or a temperature. */
48
+ config?: Record<string, unknown>;
49
+ /** Application data. Not part of the version, so describing a bundle differently does not change it. */
50
+ metadata?: Record<string, unknown>;
51
+ }
52
+ /** A committed bundle version. */
53
+ export interface ContextBundle extends ContextBundleDefinition {
54
+ /** Its content version: `c` and 12 hex digits of a SHA-256 over everything but `metadata`. */
55
+ version: string;
56
+ /** ISO-8601 time it was committed. */
57
+ createdAt: string;
58
+ /** Why it changed, from the commit. */
59
+ message?: string;
60
+ /** Who committed it. */
61
+ author?: string;
62
+ /** The version that was newest before it. */
63
+ parent?: string;
64
+ }
65
+ /** Which bundle version is being used, as experiments and traces record it. */
66
+ export interface ContextReference {
67
+ /** The bundle's name. */
68
+ name: string;
69
+ /** Its content version. */
70
+ version: string;
71
+ /** The label it was resolved through, when it was. */
72
+ label?: string;
73
+ }
74
+ /** A label pointing at a bundle version. The same shape as a prompt label. */
75
+ export type ContextLabel = PromptLabel;
76
+ /** One recorded change to a bundle. The same shape as a prompt history entry. */
77
+ export type ContextHistoryEntry = PromptHistoryEntry;
78
+ /** What a context promotion gate is asked to judge. */
79
+ export interface ContextPromotionContext {
80
+ /** The bundle. */
81
+ name: string;
82
+ /** The version being promoted. */
83
+ bundle: ContextBundle;
84
+ /** The label it is being promoted to. */
85
+ to: string;
86
+ /** The label it is being promoted from, when the promotion names one. */
87
+ from?: string;
88
+ /** The version `to` serves now, if any. */
89
+ current?: ContextBundle;
90
+ /** The hub, for gates that look things up. */
91
+ hub: ContextHub;
92
+ }
93
+ /** Decides whether a bundle version may be promoted to a label. */
94
+ export type ContextPromotionGate = (context: ContextPromotionContext) => Promise<GateResult> | GateResult;
95
+ /** The outcome of a promotion. */
96
+ export interface ContextPromotionResult {
97
+ /** The label after the promotion. */
98
+ label: ContextLabel;
99
+ /** Every gate's verdict. */
100
+ results: GateResult[];
101
+ /** False when the label already served the version, so nothing moved. */
102
+ changed: boolean;
103
+ }
104
+ /** A bundle with the prompts it pins, as one document that moves between projects. */
105
+ export interface ContextBundleExport {
106
+ /** Always `nexus-context-bundle`. */
107
+ format: 'nexus-context-bundle';
108
+ /** The export format's version. */
109
+ formatVersion: 1;
110
+ /** The bundle version. */
111
+ bundle: ContextBundle;
112
+ /** Every pinned prompt version, when the hub has a prompt registry. */
113
+ prompts: PromptVersion[];
114
+ }
115
+ /** Options for a `ContextHub`. */
116
+ export interface ContextHubOptions {
117
+ /**
118
+ * Where bundle versions, labels, and history live: any prompt store — memory, files, Redis, or
119
+ * Postgres — given to the hub alone. Defaults to a `MemoryPromptStore`.
120
+ */
121
+ store?: PromptStore;
122
+ /** The prompt registry pinned prompts come from. Commits check each pin exists; exports carry them. */
123
+ prompts?: PromptRegistry;
124
+ /** Gates run before a promotion, by the label promoted to. */
125
+ gates?: Record<string, readonly ContextPromotionGate[]>;
126
+ /** Called after every recorded change. */
127
+ onChange?: (entry: ContextHistoryEntry) => void | Promise<void>;
128
+ /** Replaces the system clock, for tests. */
129
+ now?: () => Date;
130
+ }
131
+ /** Base class for context hub errors, each with a stable `code`. */
132
+ export declare class ContextHubError extends Error {
133
+ /** Stable code, such as `CONTEXT_NOT_FOUND`. */
134
+ readonly code: string;
135
+ constructor(message: string,
136
+ /** Stable code, such as `CONTEXT_NOT_FOUND`. */
137
+ code: string);
138
+ }
139
+ /** Raised for a bundle, version, or label that does not exist. */
140
+ export declare class ContextNotFoundError extends ContextHubError {
141
+ /** The bundle. */
142
+ readonly bundle: string;
143
+ /** The version or label asked for. */
144
+ readonly ref: string;
145
+ constructor(
146
+ /** The bundle. */
147
+ bundle: string,
148
+ /** The version or label asked for. */
149
+ ref: string);
150
+ }
151
+ /** Raised when a label moved while it was being changed. */
152
+ export declare class ContextConflictError extends ContextHubError {
153
+ constructor(bundle: string, label: string);
154
+ }
155
+ /** Raised when a gate refuses a promotion. `results` holds every gate's verdict. */
156
+ export declare class ContextPromotionError extends ContextHubError {
157
+ /** Every gate's verdict. */
158
+ readonly results: GateResult[];
159
+ constructor(bundle: string, to: string,
160
+ /** Every gate's verdict. */
161
+ results: GateResult[]);
162
+ }
163
+ /** Raised when a bundle definition, a pin, or an import is invalid. */
164
+ export declare class ContextDefinitionError extends ContextHubError {
165
+ constructor(message: string);
166
+ }
167
+ /**
168
+ * The content version of a bundle: `c` and the first 12 hex digits of a SHA-256 over its name,
169
+ * description, prompts, instructions, tools, skills, and configuration. Metadata is left out.
170
+ */
171
+ export declare function contextVersion(definition: ContextBundleDefinition): Promise<string>;
172
+ /**
173
+ * Versioned context bundles: prompts, instructions, tool sets, and skills versioned together,
174
+ * labelled, promoted through gates, diffed, rolled back, and exported to move between projects.
175
+ *
176
+ * It works as the prompt registry does — `commit()` stores content under its version, so committing
177
+ * unchanged content is a no-op; labels point at versions; every change is recorded — and it keeps its
178
+ * state in a prompt store, so every adapter the prompt family has serves bundles too.
179
+ */
180
+ export declare class ContextHub {
181
+ private readonly options;
182
+ /** Where versions, labels, and history live. */
183
+ readonly store: PromptStore;
184
+ private readonly now;
185
+ constructor(options?: ContextHubOptions);
186
+ /**
187
+ * Commits a bundle and returns its version. Unchanged content returns the existing version and
188
+ * records nothing; `label` points labels at the version either way. With a prompt registry, every
189
+ * pinned prompt version must exist in it.
190
+ */
191
+ commit(definition: ContextBundleDefinition, options?: {
192
+ message?: string;
193
+ author?: string;
194
+ label?: string | readonly string[];
195
+ }): Promise<ContextBundle>;
196
+ /** A version by content version, label, or `latest`, the default. Throws `ContextNotFoundError` when there is none. */
197
+ get(name: string, ref?: string): Promise<ContextBundle>;
198
+ /** A version with the reference experiments and traces record for it. */
199
+ resolve(name: string, ref?: string): Promise<{
200
+ bundle: ContextBundle;
201
+ reference: ContextReference;
202
+ }>;
203
+ /**
204
+ * Renders the prompt a bundle pins for a role, through the prompt registry, recording the bundle in
205
+ * the request's `metadata.context` beside the prompt's own reference.
206
+ */
207
+ renderPrompt(bundle: ContextBundle, role: string, variables?: Record<string, unknown>, options?: RenderOptions): Promise<RenderedPrompt>;
208
+ /** Points a label at a version, without gates. Throws `ContextConflictError` if the label moved meanwhile. */
209
+ label(name: string, label: string, ref: string, options?: {
210
+ by?: string;
211
+ note?: string;
212
+ }): Promise<ContextLabel>;
213
+ /** Removes a label. Resolves false when there was none. */
214
+ unlabel(name: string, label: string, options?: {
215
+ by?: string;
216
+ note?: string;
217
+ }): Promise<boolean>;
218
+ /**
219
+ * Moves `to` to a version — named directly, or whatever `from` serves — once every gate for `to`
220
+ * allows it. Throws `ContextPromotionError` when a gate refuses, unless `force` is set, in which case
221
+ * the refusals are still reported and recorded in the note.
222
+ */
223
+ promote(name: string, options: {
224
+ to: string;
225
+ from?: string;
226
+ version?: string;
227
+ by?: string;
228
+ note?: string;
229
+ force?: boolean;
230
+ }): Promise<ContextPromotionResult>;
231
+ /** Moves a label back to where it pointed before its last change. */
232
+ rollback(name: string, label: string, options?: {
233
+ by?: string;
234
+ note?: string;
235
+ }): Promise<ContextLabel>;
236
+ /** A bundle's changes, newest first, optionally for one label. */
237
+ history(name: string, options?: {
238
+ label?: string;
239
+ limit?: number;
240
+ }): Promise<ContextHistoryEntry[]>;
241
+ /** A bundle's versions, newest first. */
242
+ versions(name: string, options?: {
243
+ limit?: number;
244
+ }): Promise<ContextBundle[]>;
245
+ /** A bundle's labels. */
246
+ labels(name: string): Promise<ContextLabel[]>;
247
+ /** Every bundle's name, sorted. */
248
+ names(): Promise<string[]>;
249
+ /** What changed between two versions or labels of a bundle. */
250
+ diff(name: string, from: string, to: string): Promise<ContextDiff>;
251
+ /**
252
+ * A bundle version as one document, with every prompt version it pins when the hub has a prompt
253
+ * registry, so importing it elsewhere needs nothing else.
254
+ */
255
+ export(name: string, ref?: string): Promise<ContextBundleExport>;
256
+ /**
257
+ * Commits an exported bundle, and the prompts it carries into the hub's registry. Each prompt must
258
+ * still have the version it was exported with, and the bundle its version, so an export edited by
259
+ * hand is refused rather than imported under a version that no longer describes it.
260
+ */
261
+ import(exported: ContextBundleExport, options?: {
262
+ label?: string | readonly string[];
263
+ by?: string;
264
+ }): Promise<ContextBundle>;
265
+ private read;
266
+ private pointer;
267
+ private record;
268
+ }