nexus-ai-pro 2.2.0 → 2.3.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 (135) hide show
  1. package/API_STABILITY.md +39 -0
  2. package/CHANGELOG.md +142 -1
  3. package/README.md +10 -5
  4. package/dist/agent/capabilities.d.ts +39 -0
  5. package/dist/agent/capabilities.js +36 -0
  6. package/dist/agent/create-agent.d.ts +61 -11
  7. package/dist/agent/create-agent.js +136 -22
  8. package/dist/agent/index.d.ts +3 -2
  9. package/dist/agent/index.js +1 -1
  10. package/dist/agent/middleware/approval.d.ts +26 -0
  11. package/dist/agent/middleware/approval.js +23 -0
  12. package/dist/agent/{middleware.d.ts → middleware/basic.d.ts} +5 -4
  13. package/dist/agent/{middleware.js → middleware/basic.js} +3 -5
  14. package/dist/agent/middleware/context-editor.d.ts +52 -0
  15. package/dist/agent/middleware/context-editor.js +66 -0
  16. package/dist/agent/middleware/filesystem.d.ts +44 -0
  17. package/dist/agent/middleware/filesystem.js +83 -0
  18. package/dist/agent/middleware/index.d.ts +19 -0
  19. package/dist/agent/middleware/index.js +9 -0
  20. package/dist/agent/middleware/limits.d.ts +42 -0
  21. package/dist/agent/middleware/limits.js +52 -0
  22. package/dist/agent/middleware/models.d.ts +48 -0
  23. package/dist/agent/middleware/models.js +44 -0
  24. package/dist/agent/middleware/pii.d.ts +67 -0
  25. package/dist/agent/middleware/pii.js +173 -0
  26. package/dist/agent/middleware/retry.d.ts +66 -0
  27. package/dist/agent/middleware/retry.js +59 -0
  28. package/dist/agent/middleware/shared.d.ts +41 -0
  29. package/dist/agent/middleware/shared.js +73 -0
  30. package/dist/agent/middleware/tool-selector.d.ts +64 -0
  31. package/dist/agent/middleware/tool-selector.js +106 -0
  32. package/dist/agent/permissions.d.ts +113 -0
  33. package/dist/agent/permissions.js +180 -0
  34. package/dist/agent/sandbox.d.ts +151 -0
  35. package/dist/agent/sandbox.js +257 -0
  36. package/dist/agent/tool.d.ts +8 -3
  37. package/dist/agent/tool.js +14 -3
  38. package/dist/deep-agent/index.d.ts +109 -0
  39. package/dist/deep-agent/index.js +216 -0
  40. package/dist/graph/functional.d.ts +9 -0
  41. package/dist/graph/functional.js +20 -3
  42. package/dist/graph/graph.js +25 -4
  43. package/dist/graph/lint.d.ts +4 -1
  44. package/dist/graph/lint.js +35 -0
  45. package/dist/postgres/fulltext.d.ts +67 -0
  46. package/dist/postgres/fulltext.js +91 -0
  47. package/dist/rag/elasticsearch.d.ts +71 -0
  48. package/dist/rag/elasticsearch.js +130 -0
  49. package/dist/rag/pipeline.d.ts +140 -0
  50. package/dist/rag/pipeline.js +187 -0
  51. package/dist/rag/rerankers.d.ts +92 -0
  52. package/dist/rag/rerankers.js +97 -0
  53. package/dist/rag/retrievers.d.ts +12 -1
  54. package/dist/server/assistant.d.ts +5 -1
  55. package/dist/server/assistant.js +4 -2
  56. package/dist/server/auth.d.ts +250 -0
  57. package/dist/server/auth.js +392 -0
  58. package/dist/store/memory.d.ts +10 -0
  59. package/dist/store/memory.js +10 -0
  60. package/dist/types/graph.d.ts +38 -0
  61. package/dist/types/messages.d.ts +36 -2
  62. package/dist/types/principal.d.ts +21 -0
  63. package/dist/types/principal.js +1 -0
  64. package/dist/types/server.d.ts +2 -9
  65. package/dist/utils/tenant.d.ts +11 -0
  66. package/dist/utils/tenant.js +14 -0
  67. package/dist/version.d.ts +1 -1
  68. package/dist/version.js +1 -1
  69. package/dist-cjs/agent/capabilities.d.ts +39 -0
  70. package/dist-cjs/agent/capabilities.js +41 -0
  71. package/dist-cjs/agent/create-agent.d.ts +61 -11
  72. package/dist-cjs/agent/create-agent.js +136 -22
  73. package/dist-cjs/agent/index.d.ts +3 -2
  74. package/dist-cjs/agent/index.js +4 -4
  75. package/dist-cjs/agent/middleware/approval.d.ts +26 -0
  76. package/dist-cjs/agent/middleware/approval.js +26 -0
  77. package/dist-cjs/agent/{middleware.d.ts → middleware/basic.d.ts} +5 -4
  78. package/dist-cjs/agent/{middleware.js → middleware/basic.js} +3 -5
  79. package/dist-cjs/agent/middleware/context-editor.d.ts +52 -0
  80. package/dist-cjs/agent/middleware/context-editor.js +70 -0
  81. package/dist-cjs/agent/middleware/filesystem.d.ts +44 -0
  82. package/dist-cjs/agent/middleware/filesystem.js +86 -0
  83. package/dist-cjs/agent/middleware/index.d.ts +19 -0
  84. package/dist-cjs/agent/middleware/index.js +28 -0
  85. package/dist-cjs/agent/middleware/limits.d.ts +42 -0
  86. package/dist-cjs/agent/middleware/limits.js +57 -0
  87. package/dist-cjs/agent/middleware/models.d.ts +48 -0
  88. package/dist-cjs/agent/middleware/models.js +48 -0
  89. package/dist-cjs/agent/middleware/pii.d.ts +67 -0
  90. package/dist-cjs/agent/middleware/pii.js +178 -0
  91. package/dist-cjs/agent/middleware/retry.d.ts +66 -0
  92. package/dist-cjs/agent/middleware/retry.js +63 -0
  93. package/dist-cjs/agent/middleware/shared.d.ts +41 -0
  94. package/dist-cjs/agent/middleware/shared.js +83 -0
  95. package/dist-cjs/agent/middleware/tool-selector.d.ts +64 -0
  96. package/dist-cjs/agent/middleware/tool-selector.js +109 -0
  97. package/dist-cjs/agent/permissions.d.ts +113 -0
  98. package/dist-cjs/agent/permissions.js +189 -0
  99. package/dist-cjs/agent/sandbox.d.ts +151 -0
  100. package/dist-cjs/agent/sandbox.js +297 -0
  101. package/dist-cjs/agent/tool.d.ts +8 -3
  102. package/dist-cjs/agent/tool.js +14 -3
  103. package/dist-cjs/deep-agent/index.d.ts +109 -0
  104. package/dist-cjs/deep-agent/index.js +219 -0
  105. package/dist-cjs/graph/functional.d.ts +9 -0
  106. package/dist-cjs/graph/functional.js +20 -3
  107. package/dist-cjs/graph/graph.js +25 -4
  108. package/dist-cjs/graph/lint.d.ts +4 -1
  109. package/dist-cjs/graph/lint.js +35 -0
  110. package/dist-cjs/postgres/fulltext.d.ts +67 -0
  111. package/dist-cjs/postgres/fulltext.js +129 -0
  112. package/dist-cjs/rag/elasticsearch.d.ts +71 -0
  113. package/dist-cjs/rag/elasticsearch.js +135 -0
  114. package/dist-cjs/rag/pipeline.d.ts +140 -0
  115. package/dist-cjs/rag/pipeline.js +191 -0
  116. package/dist-cjs/rag/rerankers.d.ts +92 -0
  117. package/dist-cjs/rag/rerankers.js +107 -0
  118. package/dist-cjs/rag/retrievers.d.ts +12 -1
  119. package/dist-cjs/server/assistant.d.ts +5 -1
  120. package/dist-cjs/server/assistant.js +4 -2
  121. package/dist-cjs/server/auth.d.ts +250 -0
  122. package/dist-cjs/server/auth.js +402 -0
  123. package/dist-cjs/store/memory.d.ts +10 -0
  124. package/dist-cjs/store/memory.js +10 -0
  125. package/dist-cjs/types/graph.d.ts +38 -0
  126. package/dist-cjs/types/messages.d.ts +36 -2
  127. package/dist-cjs/types/principal.d.ts +21 -0
  128. package/dist-cjs/types/principal.js +2 -0
  129. package/dist-cjs/types/server.d.ts +2 -9
  130. package/dist-cjs/utils/tenant.d.ts +11 -0
  131. package/dist-cjs/utils/tenant.js +15 -0
  132. package/dist-cjs/version.d.ts +1 -1
  133. package/dist-cjs/version.js +1 -1
  134. package/llms.txt +4 -3
  135. package/package.json +118 -1
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TenantIdError = void 0;
4
4
  exports.assertTenantId = assertTenantId;
5
5
  exports.tenantPrefix = tenantPrefix;
6
+ exports.withPrincipal = withPrincipal;
6
7
  class TenantIdError extends RangeError {
7
8
  code = 'TENANT_ID_INVALID';
8
9
  constructor(tenantId) {
@@ -20,3 +21,17 @@ function assertTenantId(tenantId) {
20
21
  function tenantPrefix(tenantId) {
21
22
  return `tenant/${assertTenantId(tenantId)}/`;
22
23
  }
24
+ function withPrincipal(runOptions) {
25
+ const principal = runOptions.principal;
26
+ if (!principal)
27
+ return runOptions;
28
+ const tenantId = principal.tenantId;
29
+ if (tenantId !== undefined && runOptions.tenantId !== undefined && tenantId !== runOptions.tenantId) {
30
+ throw new TypeError("The run's tenantId and its principal's tenant differ");
31
+ }
32
+ return {
33
+ ...runOptions,
34
+ ...(tenantId !== undefined && runOptions.tenantId === undefined ? { tenantId } : {}),
35
+ ...(principal.userId !== undefined ? { metadata: { ...runOptions.metadata, userId: principal.userId } } : {}),
36
+ };
37
+ }
@@ -2,4 +2,4 @@
2
2
  * This package's version, recorded where provenance matters, such as on every experiment. A test
3
3
  * keeps it equal to `package.json`.
4
4
  */
5
- export declare const NEXUS_VERSION = "2.2.0";
5
+ export declare const NEXUS_VERSION = "2.3.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NEXUS_VERSION = void 0;
4
- exports.NEXUS_VERSION = '2.2.0';
4
+ exports.NEXUS_VERSION = '2.3.0';
package/llms.txt CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  > The typed AI framework for TypeScript. One API for provider routing and failover, agent graphs and workflows that run branches in parallel and survive a restart, retrieval over any vector store, MCP, durable background operations, guardrails, cost control, images, voice, and evals — with a studio a team can share.
4
4
 
5
- Import only what you use. The root import is the client and nothing else, and every other capability has its own entry point with a size budget CI enforces; [the packaging guide](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/packaging.md) publishes what each one costs. The package has no required dependencies: a graph-only application loads 78 KB, and installs nothing but this package.
5
+ Import only what you use. The root import is the client and nothing else, and every other capability has its own entry point with a size budget CI enforces; [the packaging guide](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/packaging.md) publishes what each one costs. The package has no required dependencies: a graph-only application loads 80 KB, and installs nothing but this package.
6
6
 
7
7
  - Install with `npm install nexus-ai-pro`. It needs Node.js 22 or newer, and ships ESM and CommonJS builds with shared types. License: MIT.
8
- - It has 143 entry points. `nexus-ai-pro` itself is the client, and every other capability has its own subpath, such as `nexus-ai-pro/graph`.
8
+ - It has 152 entry points. `nexus-ai-pro` itself is the client, and every other capability has its own subpath, such as `nexus-ai-pro/graph`.
9
9
  - Nothing is a required dependency. Install only the optional peers you use: `@anthropic-ai/sdk`, `@types/node`, `ajv`, `ajv-formats`, `ollama`, `openai`, `zod`.
10
10
  - Each guide explains every export of its entry points, then lists them in a reference generated from the doc comments.
11
11
 
@@ -16,7 +16,8 @@ Import only what you use. The root import is the client and nothing else, and ev
16
16
  - [Providers and routing](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/providers.md): The twelve completion providers, routing and failover, the model registry
17
17
  - [Guardrails](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/security.md): Injection, PII, secrets, schema validation, output redaction
18
18
  - [Graphs](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/graphs.md): Parallel branches, interrupts, checkpoints, time travel, subgraphs, caching, diagrams
19
- - [Agents and tools](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/agents.md): Graph-based agents with approvals and middleware, and the simple tool loop
19
+ - [Agents and tools](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/agents.md): Graph-based agents with approvals, capabilities and permission policies, a sandbox contract, the middleware catalog, and the simple tool loop
20
+ - [The deep-agent preset](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/deep-agents.md): Long, multi-step agents: a plan, a sandboxed workspace, helpers, skills, and a context that stays small
20
21
  - [Long-term memory](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/memory.md): Namespaced memory with semantic search, in memory or Redis
21
22
  - [MCP](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/mcp.md): Borrowing tools from MCP servers, a registry of many, and serving your own
22
23
  - [Traces](https://raw.githubusercontent.com/mkhitar-abrahamyan/nexus-ai/main/docs/tracing.md): Run trees, queries, feedback, comparison, and alerts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexus-ai-pro",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Typed AI framework for TypeScript: provider routing and failover, durable agent graphs and workflows, retrieval over any vector store, MCP, evals, guardrails, and cost control",
5
5
  "type": "module",
6
6
  "main": "dist-cjs/index.js",
@@ -540,6 +540,46 @@
540
540
  "default": "./dist-cjs/agent/index.js"
541
541
  }
542
542
  },
543
+ "./agent/permissions": {
544
+ "import": {
545
+ "types": "./dist/agent/permissions.d.ts",
546
+ "default": "./dist/agent/permissions.js"
547
+ },
548
+ "require": {
549
+ "types": "./dist-cjs/agent/permissions.d.ts",
550
+ "default": "./dist-cjs/agent/permissions.js"
551
+ }
552
+ },
553
+ "./agent/sandbox": {
554
+ "import": {
555
+ "types": "./dist/agent/sandbox.d.ts",
556
+ "default": "./dist/agent/sandbox.js"
557
+ },
558
+ "require": {
559
+ "types": "./dist-cjs/agent/sandbox.d.ts",
560
+ "default": "./dist-cjs/agent/sandbox.js"
561
+ }
562
+ },
563
+ "./agent/middleware": {
564
+ "import": {
565
+ "types": "./dist/agent/middleware/index.d.ts",
566
+ "default": "./dist/agent/middleware/index.js"
567
+ },
568
+ "require": {
569
+ "types": "./dist-cjs/agent/middleware/index.d.ts",
570
+ "default": "./dist-cjs/agent/middleware/index.js"
571
+ }
572
+ },
573
+ "./deep-agent": {
574
+ "import": {
575
+ "types": "./dist/deep-agent/index.d.ts",
576
+ "default": "./dist/deep-agent/index.js"
577
+ },
578
+ "require": {
579
+ "types": "./dist-cjs/deep-agent/index.d.ts",
580
+ "default": "./dist-cjs/deep-agent/index.js"
581
+ }
582
+ },
543
583
  "./store": {
544
584
  "import": {
545
585
  "types": "./dist/store/index.d.ts",
@@ -670,6 +710,16 @@
670
710
  "default": "./dist-cjs/postgres/vectors.js"
671
711
  }
672
712
  },
713
+ "./postgres/fulltext": {
714
+ "import": {
715
+ "types": "./dist/postgres/fulltext.d.ts",
716
+ "default": "./dist/postgres/fulltext.js"
717
+ },
718
+ "require": {
719
+ "types": "./dist-cjs/postgres/fulltext.d.ts",
720
+ "default": "./dist-cjs/postgres/fulltext.js"
721
+ }
722
+ },
673
723
  "./postgres/traces": {
674
724
  "import": {
675
725
  "types": "./dist/postgres/traces.d.ts",
@@ -840,6 +890,16 @@
840
890
  "default": "./dist-cjs/server/tenancy.js"
841
891
  }
842
892
  },
893
+ "./server/auth": {
894
+ "import": {
895
+ "types": "./dist/server/auth.d.ts",
896
+ "default": "./dist/server/auth.js"
897
+ },
898
+ "require": {
899
+ "types": "./dist-cjs/server/auth.d.ts",
900
+ "default": "./dist-cjs/server/auth.js"
901
+ }
902
+ },
843
903
  "./tenancy": {
844
904
  "import": {
845
905
  "types": "./dist/tenancy/index.d.ts",
@@ -1350,6 +1410,16 @@
1350
1410
  "default": "./dist-cjs/rag/chroma.js"
1351
1411
  }
1352
1412
  },
1413
+ "./rag/elasticsearch": {
1414
+ "import": {
1415
+ "types": "./dist/rag/elasticsearch.d.ts",
1416
+ "default": "./dist/rag/elasticsearch.js"
1417
+ },
1418
+ "require": {
1419
+ "types": "./dist-cjs/rag/elasticsearch.d.ts",
1420
+ "default": "./dist-cjs/rag/elasticsearch.js"
1421
+ }
1422
+ },
1353
1423
  "./rag/retrievers": {
1354
1424
  "import": {
1355
1425
  "types": "./dist/rag/retrievers.d.ts",
@@ -1360,6 +1430,26 @@
1360
1430
  "default": "./dist-cjs/rag/retrievers.js"
1361
1431
  }
1362
1432
  },
1433
+ "./rag/rerankers": {
1434
+ "import": {
1435
+ "types": "./dist/rag/rerankers.d.ts",
1436
+ "default": "./dist/rag/rerankers.js"
1437
+ },
1438
+ "require": {
1439
+ "types": "./dist-cjs/rag/rerankers.d.ts",
1440
+ "default": "./dist-cjs/rag/rerankers.js"
1441
+ }
1442
+ },
1443
+ "./rag/pipeline": {
1444
+ "import": {
1445
+ "types": "./dist/rag/pipeline.d.ts",
1446
+ "default": "./dist/rag/pipeline.js"
1447
+ },
1448
+ "require": {
1449
+ "types": "./dist-cjs/rag/pipeline.d.ts",
1450
+ "default": "./dist-cjs/rag/pipeline.js"
1451
+ }
1452
+ },
1363
1453
  "./evals": {
1364
1454
  "import": {
1365
1455
  "types": "./dist/evals/index.d.ts",
@@ -1812,6 +1902,18 @@
1812
1902
  "agent": [
1813
1903
  "dist-cjs/agent/index.d.ts"
1814
1904
  ],
1905
+ "agent/permissions": [
1906
+ "dist-cjs/agent/permissions.d.ts"
1907
+ ],
1908
+ "agent/sandbox": [
1909
+ "dist-cjs/agent/sandbox.d.ts"
1910
+ ],
1911
+ "agent/middleware": [
1912
+ "dist-cjs/agent/middleware/index.d.ts"
1913
+ ],
1914
+ "deep-agent": [
1915
+ "dist-cjs/deep-agent/index.d.ts"
1916
+ ],
1815
1917
  "store": [
1816
1918
  "dist-cjs/store/index.d.ts"
1817
1919
  ],
@@ -1845,6 +1947,9 @@
1845
1947
  "postgres/vectors": [
1846
1948
  "dist-cjs/postgres/vectors.d.ts"
1847
1949
  ],
1950
+ "postgres/fulltext": [
1951
+ "dist-cjs/postgres/fulltext.d.ts"
1952
+ ],
1848
1953
  "postgres/traces": [
1849
1954
  "dist-cjs/postgres/traces.d.ts"
1850
1955
  ],
@@ -1896,6 +2001,9 @@
1896
2001
  "server/tenancy": [
1897
2002
  "dist-cjs/server/tenancy.d.ts"
1898
2003
  ],
2004
+ "server/auth": [
2005
+ "dist-cjs/server/auth.d.ts"
2006
+ ],
1899
2007
  "tenancy": [
1900
2008
  "dist-cjs/tenancy/index.d.ts"
1901
2009
  ],
@@ -2070,9 +2178,18 @@
2070
2178
  "rag/chroma": [
2071
2179
  "dist-cjs/rag/chroma.d.ts"
2072
2180
  ],
2181
+ "rag/elasticsearch": [
2182
+ "dist-cjs/rag/elasticsearch.d.ts"
2183
+ ],
2073
2184
  "rag/retrievers": [
2074
2185
  "dist-cjs/rag/retrievers.d.ts"
2075
2186
  ],
2187
+ "rag/rerankers": [
2188
+ "dist-cjs/rag/rerankers.d.ts"
2189
+ ],
2190
+ "rag/pipeline": [
2191
+ "dist-cjs/rag/pipeline.d.ts"
2192
+ ],
2076
2193
  "sqlite/vectors": [
2077
2194
  "dist-cjs/sqlite/vectors.d.ts"
2078
2195
  ],