nexus-ai-pro 1.16.0 → 1.18.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 (137) hide show
  1. package/API_STABILITY.md +30 -0
  2. package/CHANGELOG.md +98 -1
  3. package/README.md +40 -2316
  4. package/dist/cli/db.js +1 -1
  5. package/dist/cli.js +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/operations/runner.js +11 -1
  8. package/dist/postgres/index.d.ts +2 -1
  9. package/dist/postgres/index.js +4 -1
  10. package/dist/postgres/prompts.d.ts +50 -0
  11. package/dist/postgres/prompts.js +102 -0
  12. package/dist/prompts/client.d.ts +79 -0
  13. package/dist/prompts/client.js +133 -0
  14. package/dist/prompts/diff.d.ts +53 -0
  15. package/dist/prompts/diff.js +108 -0
  16. package/dist/prompts/errors.d.ts +73 -0
  17. package/dist/prompts/errors.js +59 -0
  18. package/dist/prompts/evaluate.d.ts +26 -0
  19. package/dist/prompts/evaluate.js +22 -0
  20. package/dist/prompts/file.d.ts +45 -0
  21. package/dist/prompts/file.js +117 -0
  22. package/dist/prompts/gates.d.ts +38 -0
  23. package/dist/prompts/gates.js +65 -0
  24. package/dist/prompts/index.d.ts +12 -0
  25. package/dist/prompts/index.js +4 -0
  26. package/dist/prompts/memory.d.ts +44 -0
  27. package/dist/prompts/memory.js +62 -0
  28. package/dist/prompts/redis.d.ts +78 -0
  29. package/dist/prompts/redis.js +96 -0
  30. package/dist/prompts/registry-entry.d.ts +13 -0
  31. package/dist/prompts/registry-entry.js +6 -0
  32. package/dist/prompts/registry.d.ts +168 -0
  33. package/dist/prompts/registry.js +231 -0
  34. package/dist/prompts/template.d.ts +112 -0
  35. package/dist/prompts/template.js +149 -0
  36. package/dist/prompts/variant.d.ts +7 -0
  37. package/dist/prompts/variant.js +22 -0
  38. package/dist/prompts/version.d.ts +15 -0
  39. package/dist/prompts/version.js +24 -0
  40. package/dist/prompts/webhooks.d.ts +11 -0
  41. package/dist/prompts/webhooks.js +24 -0
  42. package/dist/server/assistant.d.ts +52 -0
  43. package/dist/server/assistant.js +45 -0
  44. package/dist/server/cron.d.ts +69 -0
  45. package/dist/server/cron.js +172 -0
  46. package/dist/server/errors.d.ts +56 -0
  47. package/dist/server/errors.js +56 -0
  48. package/dist/server/events.d.ts +91 -0
  49. package/dist/server/events.js +103 -0
  50. package/dist/server/http.d.ts +34 -0
  51. package/dist/server/http.js +73 -0
  52. package/dist/server/index.d.ts +18 -0
  53. package/dist/server/index.js +8 -0
  54. package/dist/server/node.d.ts +43 -0
  55. package/dist/server/node.js +86 -0
  56. package/dist/server/remote.d.ts +73 -0
  57. package/dist/server/remote.js +163 -0
  58. package/dist/server/runs.d.ts +116 -0
  59. package/dist/server/runs.js +310 -0
  60. package/dist/server/server.d.ts +54 -0
  61. package/dist/server/server.js +248 -0
  62. package/dist/server/state.d.ts +44 -0
  63. package/dist/server/state.js +40 -0
  64. package/dist/tracing/instrument.js +1 -0
  65. package/dist/types/messages.d.ts +22 -2
  66. package/dist/types/prompts.d.ts +182 -0
  67. package/dist/types/prompts.js +1 -0
  68. package/dist/types/server.d.ts +185 -0
  69. package/dist/types/server.js +1 -0
  70. package/dist/types/voice.d.ts +2 -2
  71. package/dist-cjs/cli/db.js +1 -1
  72. package/dist-cjs/index.d.ts +1 -1
  73. package/dist-cjs/operations/runner.js +11 -1
  74. package/dist-cjs/postgres/index.d.ts +2 -1
  75. package/dist-cjs/postgres/index.js +7 -2
  76. package/dist-cjs/postgres/prompts.d.ts +50 -0
  77. package/dist-cjs/postgres/prompts.js +107 -0
  78. package/dist-cjs/prompts/client.d.ts +79 -0
  79. package/dist-cjs/prompts/client.js +137 -0
  80. package/dist-cjs/prompts/diff.d.ts +53 -0
  81. package/dist-cjs/prompts/diff.js +113 -0
  82. package/dist-cjs/prompts/errors.d.ts +73 -0
  83. package/dist-cjs/prompts/errors.js +68 -0
  84. package/dist-cjs/prompts/evaluate.d.ts +26 -0
  85. package/dist-cjs/prompts/evaluate.js +58 -0
  86. package/dist-cjs/prompts/file.d.ts +45 -0
  87. package/dist-cjs/prompts/file.js +124 -0
  88. package/dist-cjs/prompts/gates.d.ts +38 -0
  89. package/dist-cjs/prompts/gates.js +102 -0
  90. package/dist-cjs/prompts/index.d.ts +12 -0
  91. package/dist-cjs/prompts/index.js +19 -0
  92. package/dist-cjs/prompts/memory.d.ts +44 -0
  93. package/dist-cjs/prompts/memory.js +66 -0
  94. package/dist-cjs/prompts/redis.d.ts +78 -0
  95. package/dist-cjs/prompts/redis.js +100 -0
  96. package/dist-cjs/prompts/registry-entry.d.ts +13 -0
  97. package/dist-cjs/prompts/registry-entry.js +19 -0
  98. package/dist-cjs/prompts/registry.d.ts +168 -0
  99. package/dist-cjs/prompts/registry.js +268 -0
  100. package/dist-cjs/prompts/template.d.ts +112 -0
  101. package/dist-cjs/prompts/template.js +154 -0
  102. package/dist-cjs/prompts/variant.d.ts +7 -0
  103. package/dist-cjs/prompts/variant.js +25 -0
  104. package/dist-cjs/prompts/version.d.ts +15 -0
  105. package/dist-cjs/prompts/version.js +28 -0
  106. package/dist-cjs/prompts/webhooks.d.ts +11 -0
  107. package/dist-cjs/prompts/webhooks.js +28 -0
  108. package/dist-cjs/server/assistant.d.ts +52 -0
  109. package/dist-cjs/server/assistant.js +49 -0
  110. package/dist-cjs/server/cron.d.ts +69 -0
  111. package/dist-cjs/server/cron.js +177 -0
  112. package/dist-cjs/server/errors.d.ts +56 -0
  113. package/dist-cjs/server/errors.js +66 -0
  114. package/dist-cjs/server/events.d.ts +91 -0
  115. package/dist-cjs/server/events.js +108 -0
  116. package/dist-cjs/server/http.d.ts +34 -0
  117. package/dist-cjs/server/http.js +81 -0
  118. package/dist-cjs/server/index.d.ts +18 -0
  119. package/dist-cjs/server/index.js +29 -0
  120. package/dist-cjs/server/node.d.ts +43 -0
  121. package/dist-cjs/server/node.js +89 -0
  122. package/dist-cjs/server/remote.d.ts +73 -0
  123. package/dist-cjs/server/remote.js +166 -0
  124. package/dist-cjs/server/runs.d.ts +116 -0
  125. package/dist-cjs/server/runs.js +314 -0
  126. package/dist-cjs/server/server.d.ts +54 -0
  127. package/dist-cjs/server/server.js +251 -0
  128. package/dist-cjs/server/state.d.ts +44 -0
  129. package/dist-cjs/server/state.js +45 -0
  130. package/dist-cjs/tracing/instrument.js +1 -0
  131. package/dist-cjs/types/messages.d.ts +22 -2
  132. package/dist-cjs/types/prompts.d.ts +182 -0
  133. package/dist-cjs/types/prompts.js +2 -0
  134. package/dist-cjs/types/server.d.ts +185 -0
  135. package/dist-cjs/types/server.js +2 -0
  136. package/dist-cjs/types/voice.d.ts +2 -2
  137. package/package.json +110 -2
package/API_STABILITY.md CHANGED
@@ -412,6 +412,36 @@ The `nexus-ai-pro/postgres` subpaths, `nexus-ai-pro/ops/circuit-store`, and
412
412
  so recordings made with one release keep replaying with the next. A change that would invalidate
413
413
  recordings waits for 2.0.
414
414
 
415
+ ## Prompt stages (1.17.0)
416
+
417
+ The `nexus-ai-pro/prompts` subpaths and `nexus-ai-pro/postgres/prompts` are experimental in
418
+ production readiness, as the image family is: their exported types, functions, and classes follow the
419
+ 1.x semantic versioning rules, and the experimental label does not permit an incompatible minor or
420
+ patch release. None is exported from the root.
421
+
422
+ - The content version algorithm is a guarantee. `promptVersion()` gives the same version for the
423
+ same content in every 1.x release, so an upgrade never re-versions a committed prompt.
424
+ - Version, label, and history records only gain fields in the 1.x line, and the Postgres schema
425
+ follows the additive rule above.
426
+ - The wording of gate reasons, of the note a forced promotion records, and of `formatPromptDiff()`
427
+ output is for people and may improve in any release.
428
+
429
+ ## Agent server stage (1.18.0)
430
+
431
+ The `nexus-ai-pro/server` subpaths are experimental in production readiness, as the image and prompt
432
+ families are: their exported types, functions, and classes follow the 1.x semantic versioning rules,
433
+ and the experimental label does not permit an incompatible minor or patch release. Neither is exported
434
+ from the root.
435
+
436
+ - The routes listed in the server guide, their status codes, and the shape of `RunRecord`,
437
+ `ThreadRecord`, and `RunEvent` follow the 1.x rules. A minor release may add routes and fields.
438
+ - Event ids are per run and strictly increasing, which is what `Last-Event-ID` depends on. A client
439
+ that reconnects with an id never receives it again.
440
+ - The server is not a security boundary on its own: authentication, authorization beyond tenancy and
441
+ scopes, and rate limiting are the application's, through the hooks.
442
+ - Recovery re-runs a whole run rather than the step it died on, so an assistant with side effects
443
+ should be idempotent or be left at a single attempt.
444
+
415
445
  ## Deprecation process
416
446
 
417
447
  Deprecated APIs are marked with `@deprecated` in declarations and described in the changelog. Removals
package/CHANGELOG.md CHANGED
@@ -4,6 +4,101 @@ Notable changes to this project are recorded here. The format follows [Keep a Ch
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.18.0] - 2026-09-25
8
+
9
+ A server you can host. Assistants get an HTTP surface — threads, background runs, resumable event
10
+ streams, and cron jobs — on top of the durability that already existed: a run is an operation, so it
11
+ outlives the request that started it and the worker that was running it.
12
+
13
+ ### Added
14
+
15
+ - **The agent server** (`nexus-ai-pro/server`, experimental). `createAgentServer()` serves assistants,
16
+ threads, runs, and cron jobs as one `Request`-to-`Response` handler. `toNodeListener()` runs it on
17
+ Node's `http`, and as Express or Fastify middleware.
18
+ - **Assistants are structural.** `graphAssistant()` serves a compiled graph, mapping threads to graph
19
+ threads; `functionAssistant()` serves a plain function. The entry point imports neither runtime.
20
+ - **Runs are durable operations**, so leases, heartbeats, retries, idempotency, dead-lettering, and
21
+ webhooks come from the operations family. A run abandoned by a crashed worker is re-claimed by
22
+ another replica through `start()` or `runs.recover()`.
23
+ - **Resumable streaming.** `GET /runs/:id/events` is a server-sent event stream whose events carry
24
+ their log id, so a client reconnects with `Last-Event-ID` and gets exactly what it missed.
25
+ `MemoryRunEventLog` covers one replica; `RedisRunEventLog` lets a client reconnect to any replica.
26
+ - **A busy thread is configurable**: `reject`, `enqueue`, `interrupt`, or `rollback`, per server or
27
+ per run.
28
+ - **Cron jobs.** `CronScheduler` fires `{ everyMs }` or five-field cron schedules, parsed by
29
+ `parseCron()`. Every replica ticks and every firing carries the idempotency key `<job>:<slot>`, so a
30
+ job runs once however many replicas are up, with no lock and no leader election.
31
+ - **Authentication and tenancy hooks.** `authenticate` returns a `Principal`; threads, runs, and cron
32
+ jobs record their tenant, and another tenant's resource is a `404`.
33
+ - **`createRemoteGraph()`** (`nexus-ai-pro/server/remote`), the client: `invoke()`, `stream()` with
34
+ reconnection, `resume()`, and `asNode()`, which makes a deployed assistant a node in a local graph.
35
+ - **Deployment templates**: `deploy/Dockerfile`, `deploy/compose.yaml` for two replicas behind Redis,
36
+ and an nginx configuration that does not buffer event streams. `examples/agent-server.ts` is a
37
+ runnable server.
38
+
39
+ ### Changed
40
+
41
+ - **Every feature's exports are documented in that feature's guide.** A guide can now claim exports by
42
+ source directory, so features reachable only from the root — guardrails, grounding, workflows,
43
+ metrics, conformance, routing — no longer pile into the client guide, which drops from 249 exports
44
+ to 141. Retrieval, citations, and verification get a guide of their own, and the agents, batch,
45
+ caching, and client guides now explain every export they cover.
46
+
47
+ ### Fixed
48
+
49
+ - An operation whose record was settled by another worker — after its lease lapsed and the work was
50
+ taken over — crashed the original worker with an unhandled `OperationTransitionError` from its
51
+ heartbeat. The heartbeat now stops and fails its local run instead, and a heartbeat that throws for
52
+ any other reason no longer becomes an unhandled rejection.
53
+
54
+ ## [1.17.0] - 2026-09-23
55
+
56
+ Prompt versioning, and documentation you can navigate. Prompts are defined with typed variables,
57
+ versioned by their content, promoted between labels only after their gates agree, and served through
58
+ registry outages; every feature now has its own guide, and the README is an overview that links to them.
59
+
60
+ ### Added
61
+
62
+ - **Prompt templates** (`nexus-ai-pro/prompts`). `definePrompt()` types a prompt's variables from its
63
+ template text, so a missing or misspelled variable is a compile-time error. Templates support dot
64
+ paths, partials, placeholders for whole messages, defaults, and a request configuration versioned
65
+ with the prompt. `promptVersion()` derives a version from the content, identical in every runtime.
66
+ - **A prompt registry** (`nexus-ai-pro/prompts/registry`). `PromptRegistry` commits versions, points
67
+ labels such as `staging` and `production` at them, and records every change. `promote()` runs the
68
+ gates registered for the destination label: `experimentGate()` requires a passing experiment for
69
+ the exact version, with thresholds and an optional no-regression check, and `servedByGate()` requires
70
+ a version to be served by another label first. `rollback()`, `split()` for sticky A/B tests, and
71
+ `diff()` with `formatPromptDiff()` complete it. Label writes are compare-and-set, and changes can be
72
+ posted to signed webhooks, verified with `verifyPromptWebhook()`.
73
+ - **`evaluatePrompt()`**, the headless playground: runs a prompt version over a dataset and stores an
74
+ experiment tagged with that version, which is what `experimentGate()` looks for.
75
+ - **A serving client** (`nexus-ai-pro/prompts/client`). `PromptClient` caches labels with a TTL and a
76
+ stale-while-revalidate window, shares concurrent refreshes, keeps serving the last version seen when
77
+ the registry is unreachable, falls back to prompts bundled in code on a cold start, and picks a
78
+ sticky A/B arm per key.
79
+ - **Prompt stores**: `MemoryPromptStore`, `FilePromptStore` (`/prompts/file`), `RedisPromptStore`
80
+ (`/prompts/redis`), and `PostgresPromptStore` (`/postgres/prompts`), all tested against one
81
+ contract. `postgresMigration()` and `nexus db sql` include the prompt tables.
82
+ - A model call traced with `traceModelClient()` records the prompt name, version, label, and arm it
83
+ was rendered from.
84
+ - **A guide for every feature**, under `docs/`. Each guide covers every export of its entry points and
85
+ ends with a reference generated from the doc comments. `npm run docs:guides` fails when an export
86
+ is not named in a guide or a reference is stale, and runs in `npm test`; `npm run docs:update`
87
+ regenerates the references.
88
+ - `BinaryBuffer`: Node's `Buffer` when Node's types are loaded, otherwise `Uint8Array`.
89
+
90
+ ### Changed
91
+
92
+ - The README is an overview that links to the guides; the moved sections live in `docs/`, and the
93
+ size table is in `docs/packaging.md`.
94
+ - The combined Postgres migration creates three more tables, for prompts.
95
+
96
+ ### Fixed
97
+
98
+ - The message types referred to Node's `Buffer` and `NodeJS.ReadableStream`, so a project without
99
+ Node's type definitions, such as a browser app, failed to type-check anything that reached them.
100
+ They now compile either way, and are unchanged for Node projects.
101
+
7
102
  ## [1.16.0] - 2026-09-22
8
103
 
9
104
  Shared state and the command line. Everything that has to outlive a process or be shared between
@@ -846,7 +941,9 @@ shared policy vocabulary is in place for a future release that revisits this.
846
941
  - URL fetching rejects unsafe private-network targets and limits response reads.
847
942
  - CLI and audit findings no longer disclose detected secret values.
848
943
 
849
- [Unreleased]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.16.0...HEAD
944
+ [Unreleased]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.18.0...HEAD
945
+ [1.18.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.17.0...v1.18.0
946
+ [1.17.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.16.0...v1.17.0
850
947
  [1.16.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.15.0...v1.16.0
851
948
  [1.15.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.14.0...v1.15.0
852
949
  [1.14.0]: https://github.com/mkhitar-abrahamyan/nexus-ai/compare/v1.12.0...v1.14.0