@happyvertical/smrt-core 0.54.2 → 0.54.4

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 (207) hide show
  1. package/AGENTS.md +6 -1
  2. package/README.md +8 -0
  3. package/agents/change-feed.md +7 -12
  4. package/agents/generators.md +13 -0
  5. package/agents/object-runtime.md +8 -0
  6. package/agents/schema-paths.md +14 -0
  7. package/dist/__typechecks__/collection-read-plan.d.ts +2 -2
  8. package/dist/__typechecks__/collection-read-plan.d.ts.map +1 -1
  9. package/dist/audit-context.d.ts +4 -0
  10. package/dist/audit-context.d.ts.map +1 -0
  11. package/dist/audit-context.js +16 -0
  12. package/dist/audit-context.js.map +1 -0
  13. package/dist/audit.d.ts +34 -0
  14. package/dist/audit.d.ts.map +1 -0
  15. package/dist/audit.js +63 -0
  16. package/dist/audit.js.map +1 -0
  17. package/dist/browser.d.ts +19 -18
  18. package/dist/browser.d.ts.map +1 -1
  19. package/dist/browser.js +4 -3
  20. package/dist/cascade.d.ts +1 -1
  21. package/dist/cascade.d.ts.map +1 -1
  22. package/dist/cascade.js +10 -7
  23. package/dist/cascade.js.map +1 -1
  24. package/dist/change-feed.js +1 -1
  25. package/dist/child-accessors.d.ts +1 -1
  26. package/dist/child-accessors.d.ts.map +1 -1
  27. package/dist/collection-read-plan.d.ts +3 -3
  28. package/dist/collection-read-plan.d.ts.map +1 -1
  29. package/dist/collection.d.ts +13 -6
  30. package/dist/collection.d.ts.map +1 -1
  31. package/dist/collection.js +59 -4
  32. package/dist/collection.js.map +1 -1
  33. package/dist/data-query.d.ts +1 -1
  34. package/dist/data-query.d.ts.map +1 -1
  35. package/dist/embedded-write-queue.d.ts +2 -0
  36. package/dist/embedded-write-queue.d.ts.map +1 -1
  37. package/dist/embedded-write-queue.js +12 -5
  38. package/dist/embedded-write-queue.js.map +1 -1
  39. package/dist/embeddings/index.d.ts +5 -5
  40. package/dist/embeddings/index.d.ts.map +1 -1
  41. package/dist/embeddings/provider.d.ts +1 -1
  42. package/dist/embeddings/provider.d.ts.map +1 -1
  43. package/dist/embeddings/storage.d.ts +1 -1
  44. package/dist/embeddings/storage.d.ts.map +1 -1
  45. package/dist/generated-collection-access.d.ts +3 -3
  46. package/dist/generated-collection-access.d.ts.map +1 -1
  47. package/dist/generators/changes-route.js +1 -1
  48. package/dist/generators/index.d.ts +12 -12
  49. package/dist/generators/index.d.ts.map +1 -1
  50. package/dist/generators/mcp-runtime-template.d.ts +2 -0
  51. package/dist/generators/mcp-runtime-template.d.ts.map +1 -1
  52. package/dist/generators/mcp-runtime-template.js +18 -16
  53. package/dist/generators/mcp-runtime-template.js.map +1 -1
  54. package/dist/generators/mcp-tool-name.d.ts +6 -0
  55. package/dist/generators/mcp-tool-name.d.ts.map +1 -1
  56. package/dist/generators/mcp-tool-name.js.map +1 -1
  57. package/dist/generators/mcp.d.ts +34 -1
  58. package/dist/generators/mcp.d.ts.map +1 -1
  59. package/dist/generators/mcp.js +148 -110
  60. package/dist/generators/mcp.js.map +1 -1
  61. package/dist/generators/rest.d.ts +4 -4
  62. package/dist/generators/rest.d.ts.map +1 -1
  63. package/dist/generators/rest.js +16 -7
  64. package/dist/generators/rest.js.map +1 -1
  65. package/dist/hierarchical.d.ts +2 -2
  66. package/dist/hierarchical.d.ts.map +1 -1
  67. package/dist/index.d.ts +68 -66
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +9 -7
  70. package/dist/junction.d.ts +31 -12
  71. package/dist/junction.d.ts.map +1 -1
  72. package/dist/junction.js +31 -12
  73. package/dist/junction.js.map +1 -1
  74. package/dist/knowledge.js +1 -1
  75. package/dist/knowledge.js.map +1 -1
  76. package/dist/manifest/index.d.ts +7 -7
  77. package/dist/manifest/index.d.ts.map +1 -1
  78. package/dist/manifest/manifest-loader.d.ts.map +1 -1
  79. package/dist/manifest/manifest-loader.js +1 -1
  80. package/dist/manifest/manifest-loader.js.map +1 -1
  81. package/dist/manifest/static-manifest.d.ts.map +1 -1
  82. package/dist/manifest/static-manifest.js +106 -9
  83. package/dist/manifest/static-manifest.js.map +1 -1
  84. package/dist/manifest/store.d.ts +8 -0
  85. package/dist/manifest/store.d.ts.map +1 -1
  86. package/dist/manifest/store.js +12 -2
  87. package/dist/manifest/store.js.map +1 -1
  88. package/dist/manifest.json +119 -9
  89. package/dist/migrations/differ.d.ts +3 -3
  90. package/dist/migrations/differ.d.ts.map +1 -1
  91. package/dist/migrations/differ.js +8 -4
  92. package/dist/migrations/differ.js.map +1 -1
  93. package/dist/object.d.ts +8 -7
  94. package/dist/object.d.ts.map +1 -1
  95. package/dist/object.js +19 -7
  96. package/dist/object.js.map +1 -1
  97. package/dist/polymorphic-association.d.ts +1 -1
  98. package/dist/polymorphic-association.d.ts.map +1 -1
  99. package/dist/prebuild/index.d.ts +1 -1
  100. package/dist/prebuild/index.d.ts.map +1 -1
  101. package/dist/query-bounds.d.ts +1 -1
  102. package/dist/query-bounds.d.ts.map +1 -1
  103. package/dist/registry/cache-config.d.ts +1 -1
  104. package/dist/registry/cache-config.d.ts.map +1 -1
  105. package/dist/registry/class-registration.d.ts +1 -1
  106. package/dist/registry/class-registration.d.ts.map +1 -1
  107. package/dist/registry/class-registration.js +75 -10
  108. package/dist/registry/class-registration.js.map +1 -1
  109. package/dist/registry/collection-resolution.d.ts +3 -3
  110. package/dist/registry/collection-resolution.d.ts.map +1 -1
  111. package/dist/registry/collection-resolution.js +2 -1
  112. package/dist/registry/collection-resolution.js.map +1 -1
  113. package/dist/registry/collision-policy.d.ts +8 -0
  114. package/dist/registry/collision-policy.d.ts.map +1 -1
  115. package/dist/registry/collision-policy.js +2 -2
  116. package/dist/registry/collision-policy.js.map +1 -1
  117. package/dist/registry/embedding-manager.d.ts +1 -1
  118. package/dist/registry/embedding-manager.d.ts.map +1 -1
  119. package/dist/registry/framework-base-classes.d.ts.map +1 -1
  120. package/dist/registry/framework-base-classes.js +2 -1
  121. package/dist/registry/framework-base-classes.js.map +1 -1
  122. package/dist/registry/index.d.ts +6 -6
  123. package/dist/registry/index.d.ts.map +1 -1
  124. package/dist/registry/inheritance-resolver.d.ts +2 -2
  125. package/dist/registry/inheritance-resolver.d.ts.map +1 -1
  126. package/dist/registry/manifest-field-merge.d.ts +1 -1
  127. package/dist/registry/manifest-field-merge.d.ts.map +1 -1
  128. package/dist/registry/name-resolver.d.ts +1 -1
  129. package/dist/registry/name-resolver.d.ts.map +1 -1
  130. package/dist/registry/qualified-name-aliases.d.ts +1 -1
  131. package/dist/registry/qualified-name-aliases.d.ts.map +1 -1
  132. package/dist/registry/relationship-graph.d.ts +1 -1
  133. package/dist/registry/relationship-graph.d.ts.map +1 -1
  134. package/dist/registry/runtime-overrides.d.ts +1 -1
  135. package/dist/registry/runtime-overrides.d.ts.map +1 -1
  136. package/dist/registry/schema-builder.d.ts.map +1 -1
  137. package/dist/registry/schema-builder.js +33 -4
  138. package/dist/registry/schema-builder.js.map +1 -1
  139. package/dist/registry/shared-state.d.ts +9 -3
  140. package/dist/registry/shared-state.d.ts.map +1 -1
  141. package/dist/registry/shared-state.js +12 -1
  142. package/dist/registry/shared-state.js.map +1 -1
  143. package/dist/registry/types.d.ts +11 -5
  144. package/dist/registry/types.d.ts.map +1 -1
  145. package/dist/registry/validator.d.ts +1 -1
  146. package/dist/registry/validator.d.ts.map +1 -1
  147. package/dist/registry.d.ts +19 -13
  148. package/dist/registry.d.ts.map +1 -1
  149. package/dist/registry.js +25 -3
  150. package/dist/registry.js.map +1 -1
  151. package/dist/relationship-loader.d.ts +1 -1
  152. package/dist/relationship-loader.d.ts.map +1 -1
  153. package/dist/runtime/client.d.ts +1 -1
  154. package/dist/runtime/client.d.ts.map +1 -1
  155. package/dist/runtime/index.d.ts +5 -5
  156. package/dist/runtime/index.d.ts.map +1 -1
  157. package/dist/runtime/server.d.ts +1 -1
  158. package/dist/runtime/server.d.ts.map +1 -1
  159. package/dist/scanner/manifest-generator.d.ts.map +1 -1
  160. package/dist/scanner/manifest-generator.js +5 -1
  161. package/dist/scanner/manifest-generator.js.map +1 -1
  162. package/dist/scanner/types.d.ts +8 -0
  163. package/dist/scanner/types.d.ts.map +1 -1
  164. package/dist/scanner/types.js.map +1 -1
  165. package/dist/schema/ddl/duckdb-strategy.d.ts.map +1 -1
  166. package/dist/schema/ddl/duckdb-strategy.js +1 -0
  167. package/dist/schema/ddl/duckdb-strategy.js.map +1 -1
  168. package/dist/schema/ddl/null-equal-index.d.ts.map +1 -1
  169. package/dist/schema/ddl/null-equal-index.js +4 -2
  170. package/dist/schema/ddl/null-equal-index.js.map +1 -1
  171. package/dist/schema/ddl/types.d.ts +1 -1
  172. package/dist/schema/ddl/types.d.ts.map +1 -1
  173. package/dist/schema/generator.d.ts +3 -0
  174. package/dist/schema/generator.d.ts.map +1 -1
  175. package/dist/schema/generator.js +38 -0
  176. package/dist/schema/generator.js.map +1 -1
  177. package/dist/smrt-knowledge.json +74 -20
  178. package/dist/sync/apply.d.ts +2 -0
  179. package/dist/sync/apply.d.ts.map +1 -1
  180. package/dist/sync/apply.js +7 -3
  181. package/dist/sync/apply.js.map +1 -1
  182. package/dist/utils/scanner-module.d.ts +9 -0
  183. package/dist/utils/scanner-module.d.ts.map +1 -1
  184. package/dist/utils.d.ts +1 -1
  185. package/dist/utils.d.ts.map +1 -1
  186. package/dist/vite-plugin/changes-route.d.ts +1 -1
  187. package/dist/vite-plugin/changes-route.d.ts.map +1 -1
  188. package/dist/vite-plugin/events-route.d.ts +1 -1
  189. package/dist/vite-plugin/events-route.d.ts.map +1 -1
  190. package/dist/vite-plugin/index.d.ts +14 -0
  191. package/dist/vite-plugin/index.d.ts.map +1 -1
  192. package/dist/vite-plugin/index.js +58 -18
  193. package/dist/vite-plugin/index.js.map +1 -1
  194. package/dist/vite-plugin/package-stamp.d.ts +41 -0
  195. package/dist/vite-plugin/package-stamp.d.ts.map +1 -0
  196. package/dist/vite-plugin/package-stamp.js +33 -0
  197. package/dist/vite-plugin/package-stamp.js.map +1 -0
  198. package/dist/vite-plugin/sveltekit-generator.d.ts +1 -1
  199. package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
  200. package/dist/vite-plugin/sveltekit-generator.js +5 -3
  201. package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
  202. package/dist/vite-plugin/sync-apply-route.d.ts +1 -1
  203. package/dist/vite-plugin/sync-apply-route.d.ts.map +1 -1
  204. package/dist/vite-plugin/sync-apply-route.js +10 -0
  205. package/dist/vite-plugin/sync-apply-route.js.map +1 -1
  206. package/dist/vite-plugin.js +2 -2
  207. package/package.json +10 -10
@@ -10,7 +10,7 @@
10
10
  * adapters supply the schema and perform those responsibilities separately.
11
11
  */
12
12
  import type { DataQueryRequest, DataQueryResult, DataQuerySchema } from '@happyvertical/smrt-types';
13
- import { ValidationError } from './errors';
13
+ import { ValidationError } from "./errors.js";
14
14
  /** Default and hard ceilings for normalized data-query input and output. */
15
15
  export declare const DEFAULT_DATA_QUERY_PAGE_LIMIT = 50;
16
16
  export declare const MAX_DATA_QUERY_PAGE_LIMIT = 1000;
@@ -1 +1 @@
1
- {"version":3,"file":"data-query.d.ts","sourceRoot":"","sources":["../src/data-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAUV,gBAAgB,EAChB,eAAe,EAGf,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,4EAA4E;AAC5E,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAC/C,eAAO,MAAM,+BAA+B,UAAY,CAAC;AACzD,eAAO,MAAM,2BAA2B,WAAa,CAAC;AACtD,eAAO,MAAM,4BAA4B,SAAU,CAAC;AACpD,eAAO,MAAM,qBAAqB,UAAY,CAAC;AAC/C,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,wBAA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AAO,GACd,MAAM,CAER;AAuLD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,OAAO,EACrB,WAAW,EAAE,OAAO,GACnB,eAAe,CAuLjB"}
@@ -1,4 +1,6 @@
1
1
  import { type DatabaseInterface } from '@happyvertical/sql';
2
+ /** Whether this exact handle belongs to a currently active framework transaction. */
3
+ export declare function isFrameworkTransactionHandle(db: DatabaseInterface): boolean;
2
4
  interface QueueableDatabase {
3
5
  url?: string;
4
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"embedded-write-queue.d.ts","sourceRoot":"","sources":["../src/embedded-write-queue.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AA0C5B,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAG3E;AA0BD;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAwBZ;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,CAAC,EAClD,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,CAAC,WAAW,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACzD,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,CAAC,CAAC,CAgCZ"}
1
+ {"version":3,"file":"embedded-write-queue.d.ts","sourceRoot":"","sources":["../src/embedded-write-queue.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AA6C5B,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAE3E;AAED,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAG3E;AA0BD;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAwBZ;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,CAAC,EAClD,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,CAAC,WAAW,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACzD,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,CAAC,CAAC,CAqCZ"}
@@ -1,5 +1,5 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
1
  import { NestedTransactionError } from "@happyvertical/sql";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/embedded-write-queue.ts
4
4
  /**
5
5
  * In-process write serialization for embedded database engines (#2360).
@@ -39,6 +39,11 @@ import { NestedTransactionError } from "@happyvertical/sql";
39
39
  var urlQueues = /* @__PURE__ */ new Map();
40
40
  var handleQueues = /* @__PURE__ */ new WeakMap();
41
41
  var activeQueueKeys = new AsyncLocalStorage();
42
+ var frameworkTransactions = new AsyncLocalStorage();
43
+ /** Whether this exact handle belongs to a currently active framework transaction. */
44
+ function isFrameworkTransactionHandle(db) {
45
+ return frameworkTransactions.getStore()?.has(db) === true;
46
+ }
42
47
  /**
43
48
  * Whether `db` is an embedded engine (SQLite/DuckDB/JSON — anything that is
44
49
  * not PostgreSQL). Handles without a URL are treated as embedded: serializing
@@ -127,9 +132,11 @@ async function withEmbeddedWriteTransaction(db, serialize, operation, reuseUnsup
127
132
  try {
128
133
  return await transaction((bound) => {
129
134
  entered = true;
130
- if (!serialize) return operation(bound);
131
- const active = activeQueueKeys.getStore();
132
- return activeQueueKeys.run(/* @__PURE__ */ new Set([...active ?? [], queueKey(bound)]), () => operation(bound));
135
+ return frameworkTransactions.run(/* @__PURE__ */ new Set([...frameworkTransactions.getStore() ?? [], bound]), () => {
136
+ if (!serialize) return operation(bound);
137
+ const active = activeQueueKeys.getStore();
138
+ return activeQueueKeys.run(/* @__PURE__ */ new Set([...active ?? [], queueKey(bound)]), () => operation(bound));
139
+ });
133
140
  });
134
141
  } catch (error) {
135
142
  if (reuseUnsupportedNested && !entered && error instanceof NestedTransactionError) return operation(db);
@@ -138,6 +145,6 @@ async function withEmbeddedWriteTransaction(db, serialize, operation, reuseUnsup
138
145
  });
139
146
  }
140
147
  //#endregion
141
- export { isEmbeddedDatabase, isPostgresDatabase, usesEmbeddedRevisionFallback, withEmbeddedWriteQueue, withEmbeddedWriteTransaction };
148
+ export { isEmbeddedDatabase, isFrameworkTransactionHandle, isPostgresDatabase, usesEmbeddedRevisionFallback, withEmbeddedWriteQueue, withEmbeddedWriteTransaction };
142
149
 
143
150
  //# sourceMappingURL=embedded-write-queue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"embedded-write-queue.js","names":[],"sources":["../src/embedded-write-queue.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport {\n type DatabaseInterface,\n NestedTransactionError,\n} from '@happyvertical/sql';\n\n/**\n * In-process write serialization for embedded database engines (#2360).\n *\n * File-backed SQLite (libsql) allows one writer at a time and the SDK opens a\n * NEW connection for every null-aware upsert attempt (`transaction(\"write\")`),\n * with no busy timeout on either connection. Any other write on the root\n * connection while such a transaction is open — most commonly the change-feed\n * append that follows every model save — collides as `SQLITE_BUSY`, and under\n * sustained concurrency (a `Promise.all` of creates) the two sides livelock\n * through every retry tier. Before the tenant-led conflict target (#2360) the\n * null-aware path was rare (custom conflict keys with NULL values, #1246);\n * with `tenant_id` leading every tenant-scoped default key, EVERY NULL-tenant\n * (global) create takes it, so the collision became the steady state.\n *\n * The queue makes the process a single writer per embedded database for:\n *\n * - a `save()` whose upsert conflict values contain NULL (the only shape the\n * SDK routes through a second-connection transaction), and\n * - the change-feed append (a root-connection write that follows every save).\n * - every model save and delete, so the embedded revision-CAS compare/upsert\n * fallback cannot race an ordinary save, natural-key create, or delete.\n * - a complete root `SmrtObject.withTransaction()` callback, with writes on\n * its bound handle re-entering the same hold instead of self-deadlocking.\n *\n * Ordinary save/delete holds contain database calls only — never an\n * interceptor or hook. Explicit transaction callbacks are caller-controlled,\n * so their bound model writes re-enter the existing hold. PostgreSQL is never\n * serialized here:\n * its null-aware upsert already arbitrates through advisory locks\n * server-side, and cross-process writers exist that an in-process queue could\n * not order anyway (which is also why this queue is a mitigation for embedded\n * engines' in-process writers, not a cross-process guarantee — embedded\n * engines have no cross-process writers in supported deployments).\n */\n\n/** Queue tail per database identity (URL string, or the handle itself). */\nconst urlQueues = new Map<string, Promise<unknown>>();\nconst handleQueues = new WeakMap<object, Promise<unknown>>();\nconst activeQueueKeys = new AsyncLocalStorage<ReadonlySet<string | object>>();\n\ninterface QueueableDatabase {\n url?: string;\n}\n\n/**\n * Whether `db` is an embedded engine (SQLite/DuckDB/JSON — anything that is\n * not PostgreSQL). Handles without a URL are treated as embedded: serializing\n * them is at worst a throughput cost, while not serializing an embedded\n * handle reintroduces the livelock.\n */\nexport function isEmbeddedDatabase(db: QueueableDatabase): boolean {\n return !isPostgresDatabase(db);\n}\n\n/**\n * Whether `db` is a PostgreSQL handle.\n *\n * The revision compare-and-swap predicate is dialect-specific (#2620): only\n * PostgreSQL needs the millisecond-truncating, timezone-tolerant guard, and\n * only PostgreSQL can evaluate `date_trunc`.\n */\nexport function isPostgresDatabase(db: QueueableDatabase): boolean {\n return /^postgres(?:ql)?:/iu.test(db?.url ?? '');\n}\n\n/**\n * Whether revision compare-and-swap needs the process-local read/upsert path.\n *\n * DuckDB/JSON cannot express the timestamp predicate through the generic\n * update API, and local SQLite has only the process's writers in supported\n * deployments. Remote LibSQL/Turso is different: other processes may write\n * the same database, so it must use one conditional UPDATE at the server.\n */\nexport function usesEmbeddedRevisionFallback(db: QueueableDatabase): boolean {\n const url = db?.url ?? '';\n return isEmbeddedDatabase(db) && !/^(?:https?|libsql):\\/\\//iu.test(url);\n}\n\n/**\n * Whether `url` identifies a SQLite/DuckDB in-memory database that is\n * private to its own connection, as opposed to shared state.\n *\n * Bare `:memory:` and `file::memory:` (no query string) each mint a fresh,\n * connection-private database -- `resolveDuckDBUrl(':memory:')` returns it\n * unchanged, with no per-instance suffix -- so two independent handles that\n * both happen to carry this literal string are NOT the same database and\n * must not share a write-queue identity (#2707). A `cache=shared` query\n * parameter (e.g. `file::memory:?cache=shared`) is the opposite case: it is\n * SQLite's own mechanism for making an in-memory database genuinely shared\n * across connections in the process, so a URL carrying it must keep the\n * ordinary string-keyed (shared) behavior.\n */\nfunction isPerConnectionMemoryUrl(url: string): boolean {\n if (url.includes('cache=shared')) return false;\n return url === ':memory:' || url === 'file::memory:';\n}\n\nfunction queueKey(db: QueueableDatabase): string | object {\n if (typeof db?.url !== 'string' || db.url.length === 0) return db;\n return isPerConnectionMemoryUrl(db.url) ? db : db.url;\n}\n\n/**\n * Run `operation` after every previously queued write on the same database\n * has settled. When `serialize` is false the operation runs immediately.\n */\nexport async function withEmbeddedWriteQueue<T>(\n db: QueueableDatabase,\n serialize: boolean,\n operation: () => Promise<T>,\n): Promise<T> {\n if (!serialize) return operation();\n\n const key = queueKey(db);\n const active = activeQueueKeys.getStore();\n if (active?.has(key)) return operation();\n const previous =\n (typeof key === 'string' ? urlQueues.get(key) : handleQueues.get(key)) ??\n Promise.resolve();\n const run = () =>\n activeQueueKeys.run(new Set([...(active ?? []), key]), operation);\n const next = previous.then(run, run);\n // The stored tail must never reject, or one failed write would poison the\n // queue for every later writer.\n const tail = next.catch(() => undefined);\n if (typeof key === 'string') {\n urlQueues.set(key, tail);\n void tail.finally(() => {\n if (urlQueues.get(key) === tail) urlQueues.delete(key);\n });\n } else {\n handleQueues.set(key, tail);\n }\n return next;\n}\n\n/**\n * Serialize a complete embedded root transaction with ordinary model writes.\n * The transaction handle is registered as a reentrant alias so saves and\n * change-feed appends inside the callback do not queue behind their own root\n * transaction.\n */\nexport async function withEmbeddedWriteTransaction<T>(\n db: DatabaseInterface,\n serialize: boolean,\n operation: (transaction: DatabaseInterface) => Promise<T>,\n reuseUnsupportedNested = false,\n): Promise<T> {\n const transaction = db.transaction?.bind(db);\n if (!transaction) {\n throw new Error('Database transaction support is required');\n }\n return withEmbeddedWriteQueue(db, serialize, async () => {\n let entered = false;\n try {\n return await transaction((bound) => {\n entered = true;\n if (!serialize) return operation(bound);\n const active = activeQueueKeys.getStore();\n return activeQueueKeys.run(\n new Set([...(active ?? []), queueKey(bound)]),\n () => operation(bound),\n );\n });\n } catch (error) {\n // The SDK explicitly refuses no-savepoint nesting before invoking the\n // callback or touching the enclosing transaction. A helper that needs\n // the caller's atomic scope can use that existing handle directly. Never\n // replay work when the callback ran, even if it threw the same error.\n if (\n reuseUnsupportedNested &&\n !entered &&\n error instanceof NestedTransactionError\n ) {\n return operation(db);\n }\n throw error;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,4BAAY,IAAI,IAA8B;AACpD,IA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AAU,OAAO,GAAG;EACvD,CAAC;CACH,OACE,aAAa,IAAI,KAAK,IAAI;CAE5B,OAAO;AACT;;;;;;;AAQA,eAAsB,6BACpB,IACA,WACA,WACA,yBAAyB,OACb;CACZ,MAAM,cAAc,GAAG,aAAa,KAAK,EAAE;CAC3C,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,0CAA0C;CAE5D,OAAO,uBAAuB,IAAI,WAAW,YAAY;EACvD,IAAI,UAAU;EACd,IAAI;GACF,OAAO,MAAM,aAAa,UAAU;IAClC,UAAU;IACV,IAAI,CAAC,WAAW,OAAO,UAAU,KAAK;IACtC,MAAM,SAAS,gBAAgB,SAAS;IACxC,OAAO,gBAAgB,oBACrB,IAAI,IAAI,CAAC,GAAI,UAAU,CAAC,GAAI,SAAS,KAAK,CAAC,CAAC,SACtC,UAAU,KAAK,CACvB;GACF,CAAC;EACH,SAAS,OAAO;GAKd,IACE,0BACA,CAAC,WACD,iBAAiB,wBAEjB,OAAO,UAAU,EAAE;GAErB,MAAM;EACR;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"embedded-write-queue.js","names":[],"sources":["../src/embedded-write-queue.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport {\n type DatabaseInterface,\n NestedTransactionError,\n} from '@happyvertical/sql';\n\n/**\n * In-process write serialization for embedded database engines (#2360).\n *\n * File-backed SQLite (libsql) allows one writer at a time and the SDK opens a\n * NEW connection for every null-aware upsert attempt (`transaction(\"write\")`),\n * with no busy timeout on either connection. Any other write on the root\n * connection while such a transaction is open — most commonly the change-feed\n * append that follows every model save — collides as `SQLITE_BUSY`, and under\n * sustained concurrency (a `Promise.all` of creates) the two sides livelock\n * through every retry tier. Before the tenant-led conflict target (#2360) the\n * null-aware path was rare (custom conflict keys with NULL values, #1246);\n * with `tenant_id` leading every tenant-scoped default key, EVERY NULL-tenant\n * (global) create takes it, so the collision became the steady state.\n *\n * The queue makes the process a single writer per embedded database for:\n *\n * - a `save()` whose upsert conflict values contain NULL (the only shape the\n * SDK routes through a second-connection transaction), and\n * - the change-feed append (a root-connection write that follows every save).\n * - every model save and delete, so the embedded revision-CAS compare/upsert\n * fallback cannot race an ordinary save, natural-key create, or delete.\n * - a complete root `SmrtObject.withTransaction()` callback, with writes on\n * its bound handle re-entering the same hold instead of self-deadlocking.\n *\n * Ordinary save/delete holds contain database calls only — never an\n * interceptor or hook. Explicit transaction callbacks are caller-controlled,\n * so their bound model writes re-enter the existing hold. PostgreSQL is never\n * serialized here:\n * its null-aware upsert already arbitrates through advisory locks\n * server-side, and cross-process writers exist that an in-process queue could\n * not order anyway (which is also why this queue is a mitigation for embedded\n * engines' in-process writers, not a cross-process guarantee — embedded\n * engines have no cross-process writers in supported deployments).\n */\n\n/** Queue tail per database identity (URL string, or the handle itself). */\nconst urlQueues = new Map<string, Promise<unknown>>();\nconst handleQueues = new WeakMap<object, Promise<unknown>>();\nconst activeQueueKeys = new AsyncLocalStorage<ReadonlySet<string | object>>();\nconst frameworkTransactions = new AsyncLocalStorage<\n ReadonlySet<DatabaseInterface>\n>();\n\n/** Whether this exact handle belongs to a currently active framework transaction. */\nexport function isFrameworkTransactionHandle(db: DatabaseInterface): boolean {\n return frameworkTransactions.getStore()?.has(db) === true;\n}\n\ninterface QueueableDatabase {\n url?: string;\n}\n\n/**\n * Whether `db` is an embedded engine (SQLite/DuckDB/JSON — anything that is\n * not PostgreSQL). Handles without a URL are treated as embedded: serializing\n * them is at worst a throughput cost, while not serializing an embedded\n * handle reintroduces the livelock.\n */\nexport function isEmbeddedDatabase(db: QueueableDatabase): boolean {\n return !isPostgresDatabase(db);\n}\n\n/**\n * Whether `db` is a PostgreSQL handle.\n *\n * The revision compare-and-swap predicate is dialect-specific (#2620): only\n * PostgreSQL needs the millisecond-truncating, timezone-tolerant guard, and\n * only PostgreSQL can evaluate `date_trunc`.\n */\nexport function isPostgresDatabase(db: QueueableDatabase): boolean {\n return /^postgres(?:ql)?:/iu.test(db?.url ?? '');\n}\n\n/**\n * Whether revision compare-and-swap needs the process-local read/upsert path.\n *\n * DuckDB/JSON cannot express the timestamp predicate through the generic\n * update API, and local SQLite has only the process's writers in supported\n * deployments. Remote LibSQL/Turso is different: other processes may write\n * the same database, so it must use one conditional UPDATE at the server.\n */\nexport function usesEmbeddedRevisionFallback(db: QueueableDatabase): boolean {\n const url = db?.url ?? '';\n return isEmbeddedDatabase(db) && !/^(?:https?|libsql):\\/\\//iu.test(url);\n}\n\n/**\n * Whether `url` identifies a SQLite/DuckDB in-memory database that is\n * private to its own connection, as opposed to shared state.\n *\n * Bare `:memory:` and `file::memory:` (no query string) each mint a fresh,\n * connection-private database -- `resolveDuckDBUrl(':memory:')` returns it\n * unchanged, with no per-instance suffix -- so two independent handles that\n * both happen to carry this literal string are NOT the same database and\n * must not share a write-queue identity (#2707). A `cache=shared` query\n * parameter (e.g. `file::memory:?cache=shared`) is the opposite case: it is\n * SQLite's own mechanism for making an in-memory database genuinely shared\n * across connections in the process, so a URL carrying it must keep the\n * ordinary string-keyed (shared) behavior.\n */\nfunction isPerConnectionMemoryUrl(url: string): boolean {\n if (url.includes('cache=shared')) return false;\n return url === ':memory:' || url === 'file::memory:';\n}\n\nfunction queueKey(db: QueueableDatabase): string | object {\n if (typeof db?.url !== 'string' || db.url.length === 0) return db;\n return isPerConnectionMemoryUrl(db.url) ? db : db.url;\n}\n\n/**\n * Run `operation` after every previously queued write on the same database\n * has settled. When `serialize` is false the operation runs immediately.\n */\nexport async function withEmbeddedWriteQueue<T>(\n db: QueueableDatabase,\n serialize: boolean,\n operation: () => Promise<T>,\n): Promise<T> {\n if (!serialize) return operation();\n\n const key = queueKey(db);\n const active = activeQueueKeys.getStore();\n if (active?.has(key)) return operation();\n const previous =\n (typeof key === 'string' ? urlQueues.get(key) : handleQueues.get(key)) ??\n Promise.resolve();\n const run = () =>\n activeQueueKeys.run(new Set([...(active ?? []), key]), operation);\n const next = previous.then(run, run);\n // The stored tail must never reject, or one failed write would poison the\n // queue for every later writer.\n const tail = next.catch(() => undefined);\n if (typeof key === 'string') {\n urlQueues.set(key, tail);\n void tail.finally(() => {\n if (urlQueues.get(key) === tail) urlQueues.delete(key);\n });\n } else {\n handleQueues.set(key, tail);\n }\n return next;\n}\n\n/**\n * Serialize a complete embedded root transaction with ordinary model writes.\n * The transaction handle is registered as a reentrant alias so saves and\n * change-feed appends inside the callback do not queue behind their own root\n * transaction.\n */\nexport async function withEmbeddedWriteTransaction<T>(\n db: DatabaseInterface,\n serialize: boolean,\n operation: (transaction: DatabaseInterface) => Promise<T>,\n reuseUnsupportedNested = false,\n): Promise<T> {\n const transaction = db.transaction?.bind(db);\n if (!transaction) {\n throw new Error('Database transaction support is required');\n }\n return withEmbeddedWriteQueue(db, serialize, async () => {\n let entered = false;\n try {\n return await transaction((bound) => {\n entered = true;\n return frameworkTransactions.run(\n new Set([...(frameworkTransactions.getStore() ?? []), bound]),\n () => {\n if (!serialize) return operation(bound);\n const active = activeQueueKeys.getStore();\n return activeQueueKeys.run(\n new Set([...(active ?? []), queueKey(bound)]),\n () => operation(bound),\n );\n },\n );\n });\n } catch (error) {\n // The SDK explicitly refuses no-savepoint nesting before invoking the\n // callback or touching the enclosing transaction. A helper that needs\n // the caller's atomic scope can use that existing handle directly. Never\n // replay work when the callback ran, even if it threw the same error.\n if (\n reuseUnsupportedNested &&\n !entered &&\n error instanceof NestedTransactionError\n ) {\n return operation(db);\n }\n throw error;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,4BAAY,IAAI,IAA8B;AACpD,IAAM,+BAAe,IAAI,QAAkC;AAC3D,IAAM,kBAAkB,IAAI,kBAAgD;AAC5E,IAAM,wBAAwB,IAAI,kBAEhC;;AAGF,SAAgB,6BAA6B,IAAgC;CAC3E,OAAO,sBAAsB,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM;AACvD;;;;;;;AAYA,SAAgB,mBAAmB,IAAgC;CACjE,OAAO,CAAC,m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,WACA,yBAAyB,OACb;CACZ,MAAM,cAAc,GAAG,aAAa,KAAK,EAAE;CAC3C,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,0CAA0C;CAE5D,OAAO,uBAAuB,IAAI,WAAW,YAAY;EACvD,IAAI,UAAU;EACd,IAAI;GACF,OAAO,MAAM,aAAa,UAAU;IAClC,UAAU;IACV,OAAO,sBAAsB,oBAC3B,IAAI,IAAI,CAAC,GAAI,sBAAsB,SAAS,KAAK,CAAC,GAAI,KAAK,CAAC,SACtD;KACJ,IAAI,CAAC,WAAW,OAAO,UAAU,KAAK;KACtC,MAAM,SAAS,gBAAgB,SAAS;KACxC,OAAO,gBAAgB,oBACrB,IAAI,IAAI,CAAC,GAAI,UAAU,CAAC,GAAI,SAAS,KAAK,CAAC,CAAC,SACtC,UAAU,KAAK,CACvB;IACF,CACF;GACF,CAAC;EACH,SAAS,OAAO;GAKd,IACE,0BACA,CAAC,WACD,iBAAiB,wBAEjB,OAAO,UAAU,EAAE;GAErB,MAAM;EACR;CACF,CAAC;AACH"}
@@ -28,9 +28,9 @@
28
28
  * const results = CosineSimilarity.rankBySimilarity(queryEmbedding, candidates);
29
29
  * ```
30
30
  */
31
- export { ContentHasher } from './hash';
32
- export { DEFAULT_EMBEDDING_CONFIG, EmbeddingProvider } from './provider';
33
- export { CosineSimilarity } from './similarity';
34
- export { EmbeddingStorage } from './storage';
35
- export type { BatchGenerateOptions, BatchGenerateResult, BatchProgressCallback, ClassEmbeddingConfig, EmbeddingProviderType, FindSimilarOptions, GenerateEmbeddingsOptions, ProjectEmbeddingConfig, ResolvedEmbeddingConfig, SemanticSearchOptions, StoredEmbedding, } from './types';
31
+ export { ContentHasher } from "./hash.js";
32
+ export { DEFAULT_EMBEDDING_CONFIG, EmbeddingProvider } from "./provider.js";
33
+ export { CosineSimilarity } from "./similarity.js";
34
+ export { EmbeddingStorage } from "./storage.js";
35
+ export type { BatchGenerateOptions, BatchGenerateResult, BatchProgressCallback, ClassEmbeddingConfig, EmbeddingProviderType, FindSimilarOptions, GenerateEmbeddingsOptions, ProjectEmbeddingConfig, ResolvedEmbeddingConfig, SemanticSearchOptions, StoredEmbedding, } from "./types.js";
36
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embeddings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,GAChB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embeddings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAQ,CAAC;AAEvC,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,eAAY,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAc,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAW,CAAC;AAE7C,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,GAChB,MAAM,YAAS,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Supports transformers.js packages for local inference and @happyvertical/ai
6
6
  * for cloud embeddings.
7
7
  */
8
- import type { EmbeddingProviderType, ProjectEmbeddingConfig } from './types';
8
+ import type { EmbeddingProviderType, ProjectEmbeddingConfig } from "./types.js";
9
9
  export type OptionalModuleImporter = (moduleName: string) => Promise<unknown>;
10
10
  export declare const LOCAL_TRANSFORMERS_PACKAGES: readonly ["@huggingface/transformers", "@xenova/transformers"];
11
11
  export type LocalTransformersPackage = (typeof LOCAL_TRANSFORMERS_PACKAGES)[number];
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/embeddings/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAe7E,MAAM,MAAM,sBAAsB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9E,eAAO,MAAM,2BAA2B,gEAG9B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAClC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,wBAAwB,CAAC;CACvC;AAmBD,wBAAsB,8BAA8B,CAClD,YAAY,GAAE,sBAAuC,GACpD,OAAO,CAAC,4BAA4B,CAAC,CAavC;AAoBD;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,aAAa,CAA0C;IAC/D,OAAO,CAAC,oBAAoB,CACrB;IACP,OAAO,CAAC,MAAM,CAAyB;IACvC,OA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vC;AAmBD,wBAAsB,8BAA8B,CAClD,YAAY,GAAE,sBAAuC,GACpD,OAAO,CAAC,4BAA4B,CAAC,CAavC;AAoBD;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,aAAa,CAA0C;IAC/D,OAAO,CAAC,oBAAoB,CACrB;IACP,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,EAAE,CAA4B;IAEtC;;;;;OAKG;gBACS,MAAM,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,OAAO;IAcxD;;;;;;OAMG;IACG,KAAK,CACT,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,gBAAgB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IAuBtB;;OAEG;YACW,UAAU;IAMxB;;OAEG;YACW,gBAAgB;IAoB9B;;OAEG;YACW,iBAAiB;IAc/B;;OAEG;YACW,WAAW;IAiBzB;;OAEG;IACH,YAAY,IAAI,MAAM;IAUtB;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAS1C;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,sBAKtC,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Supports both JSON-based and native vector storage strategies.
6
6
  */
7
7
  import type { DatabaseInterface, VectorCapabilities } from '@happyvertical/sql';
8
- import type { StoredEmbedding } from './types';
8
+ import type { StoredEmbedding } from "./types.js";
9
9
  /**
10
10
  * Storage operations for embeddings in _smrt_embeddings table
11
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/embeddings/storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIhF,OAAO,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IAqB7B;;;;;;;OAOG;WACU,0BAA0B,CACrC,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,EAAE,CAAC;IAWpB;;;;;;OAMG;WACU,eAAe,CAC1B,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;;;;;OAQG;WACU,MAAM,CACjB,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;OAKG;WACU,WAAW,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IASjE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ;CAexB"}
@@ -12,9 +12,9 @@
12
12
  * `database-rls` isolation the runtime's collection options carry the
13
13
  * request's transaction-bound database, which must never outlive the request.
14
14
  */
15
- import type { SmrtClassOptions } from './class';
16
- import type { SmrtCollection } from './collection';
17
- import type { SmrtObject } from './object';
15
+ import type { SmrtClassOptions } from "./class.js";
16
+ import type { SmrtCollection } from "./collection.js";
17
+ import type { SmrtObject } from "./object.js";
18
18
  /** The part of an application runtime that generated routes need. */
19
19
  export interface GeneratedCollectionRuntime {
20
20
  /** A collection built from the per-request class options. */
@@ -1 +1 @@
1
- {"version":3,"file":"generated-collection-access.d.ts","sourceRoot":"","sources":["../src/generated-collection-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACzC,6DAA6D;IAC7D,aAAa,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAC7C,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,yEAAyE;IACzE,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACnD;AAED,iEAAiE;AACjE,MAAM,WAAW,yBAAyB;IACxC,aAAa,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAC7C,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACpD;AAkDD;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC7C,iBAAiB,EAAE,OAAO,EAC1B,MAAM,EAAE,MAAM,GACb,yBAAyB,CA0B3B"}
1
+ {"version":3,"file":"generated-collection-access.d.ts","sourceRoot":"","sources":["../src/generated-collection-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAS,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAc,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAU,CAAC;AAE3C,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACzC,6DAA6D;IAC7D,aAAa,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAC7C,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,yEAAyE;IACzE,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACnD;AAED,iEAAiE;AACjE,MAAM,WAAW,yBAAyB;IACxC,aAAa,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAC7C,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACpD;AAkDD;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC7C,iBAAiB,EAAE,OAAO,EAC1B,MAAM,EAAE,MAAM,GACb,yBAAyB,CA0B3B"}
@@ -1,6 +1,6 @@
1
1
  import { ensureChangeFeedTable } from "../change-feed.js";
2
- import { getAuthorizedTenantScopedChangesSince } from "../change-feed-authz.js";
3
2
  import { applyPostgresRuntimeTimeouts } from "../postgres-timeouts.js";
3
+ import { getAuthorizedTenantScopedChangesSince } from "../change-feed-authz.js";
4
4
  import { createLogger } from "@happyvertical/logger";
5
5
  import { getDatabase } from "@happyvertical/sql";
6
6
  //#region src/generators/changes-route.ts
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * @smrt/core generators - Create REST APIs and MCP servers from SMRT objects
3
3
  */
4
- export { canonicalReadRepresentation, computeBodyEtag, computeTableVersionEtag, conditionalJsonResponse, ifNoneMatchHasConcreteMatch, ifNoneMatchSatisfied, PRIVATE_READ_CACHE_CONTROL, type ReadCacheControlOptions, resolveReadCacheControl, resolveTenantEtagDiscriminator, versionConditionalResponse, warnIfSharedCacheNeutralized, } from './conditional-get';
5
- export { type ApiMethodExposure, type ApiMethodRejectionCode, buildCustomActionInputSchema, buildCustomActionInvocationArgs, CRUD_OPERATIONS, type CustomActionFailure, type CustomActionMetadata, type CustomActionScope, classifyMethodWireability, classifyParameterWireability, coerceCustomActionArgument, createClassNamePredicate, createManifestClassNamePredicate, customActionParameterInputName, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, type EffectiveActionMetadata, type ExposableMethod, isCrudOperation, isCrudToolAction, type MethodDecoratorConfig, normalizeCustomActionFailure, queryStringDecoderFor, type ResolveApiMethodExposureOptions, type ResolveCustomActionMetadataOptions, type ResolvedCustomActionMetadata, readMethodDecoratorConfig, resolveApiMethodExposure, resolveCustomActionMetadata, resolveDeclaredScopeMismatch, resolveEffectiveActionMetadata, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, type ToolEffect, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber, type WireabilityOptions, type WireabilityVerdict, type WireableParameter, } from './custom-action';
6
- export { buildChangeEventStream, type ChangeEventStreamOptions, changeEventSubscribersAtCapacity, DEFAULT_EVENTS_HEARTBEAT_MS, DEFAULT_EVENTS_MAX_SUBSCRIBERS, DEFAULT_EVENTS_RETRY_AFTER_SECONDS, eventStreamCapacityExceededResponse, normalizeEventsMaxSubscribers, signalVisibleToTenant, tryReserveChangeEventSubscriberSlot, } from './events-route';
7
- export type { MCPConfig, MCPContext, MCPRequest, MCPResponse, MCPTool, MCPToolListCacheHint, MCPToolListCacheOptions, } from './mcp';
8
- export { MCP_STABLE_CATALOG_TTL_MS, MCPGenerator, resolveMCPToolListCacheHint, sortMCPTools, } from './mcp';
9
- export { handlePlaybookPreflightRoute, isApiActionEnabledForObject, isRestActionRoutable, isRestRoutePublic, PLAYBOOK_PREFLIGHT_CAPABILITY, PLAYBOOK_PREFLIGHT_ROUTE_SEGMENT, type PlaybookPreflightProvider, type PlaybookPreflightRouteOptions, type PlaybookPreflightRouteRequest, resolveRegisteredObjectName, restFieldReadPermissions, restMethodForApiAction, } from './preflight-route';
10
- export type { APIConfig, APIContext, RestServerConfig } from './rest';
11
- export { APIGenerator, computeRuntimeWebManifestHash, createRestServer, startRestServer, } from './rest';
12
- export type { OpenAPIConfig } from './swagger';
13
- export { generateOpenAPISpec, setupSwaggerUI, } from './swagger';
14
- export { runWithTenantGate, setTenantEntryPointRunner, type TenantEntryPointRunner, type TenantGateOptions, } from './tenant-gate';
15
- export { normalizeTypedHttpError, type TypedHttpFailure, } from './typed-http-error';
4
+ export { canonicalReadRepresentation, computeBodyEtag, computeTableVersionEtag, conditionalJsonResponse, ifNoneMatchHasConcreteMatch, ifNoneMatchSatisfied, PRIVATE_READ_CACHE_CONTROL, type ReadCacheControlOptions, resolveReadCacheControl, resolveTenantEtagDiscriminator, versionConditionalResponse, warnIfSharedCacheNeutralized, } from "./conditional-get.js";
5
+ export { type ApiMethodExposure, type ApiMethodRejectionCode, buildCustomActionInputSchema, buildCustomActionInvocationArgs, CRUD_OPERATIONS, type CustomActionFailure, type CustomActionMetadata, type CustomActionScope, classifyMethodWireability, classifyParameterWireability, coerceCustomActionArgument, createClassNamePredicate, createManifestClassNamePredicate, customActionParameterInputName, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, type EffectiveActionMetadata, type ExposableMethod, isCrudOperation, isCrudToolAction, type MethodDecoratorConfig, normalizeCustomActionFailure, queryStringDecoderFor, type ResolveApiMethodExposureOptions, type ResolveCustomActionMetadataOptions, type ResolvedCustomActionMetadata, readMethodDecoratorConfig, resolveApiMethodExposure, resolveCustomActionMetadata, resolveDeclaredScopeMismatch, resolveEffectiveActionMetadata, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, type ToolEffect, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber, type WireabilityOptions, type WireabilityVerdict, type WireableParameter, } from "./custom-action.js";
6
+ export { buildChangeEventStream, type ChangeEventStreamOptions, changeEventSubscribersAtCapacity, DEFAULT_EVENTS_HEARTBEAT_MS, DEFAULT_EVENTS_MAX_SUBSCRIBERS, DEFAULT_EVENTS_RETRY_AFTER_SECONDS, eventStreamCapacityExceededResponse, normalizeEventsMaxSubscribers, signalVisibleToTenant, tryReserveChangeEventSubscriberSlot, } from "./events-route.js";
7
+ export type { MCPConfig, MCPContext, MCPRequest, MCPResponse, MCPTool, MCPToolListCacheHint, MCPToolListCacheOptions, } from "./mcp.js";
8
+ export { MCP_STABLE_CATALOG_TTL_MS, MCPGenerator, resolveMCPToolListCacheHint, sortMCPTools, } from "./mcp.js";
9
+ export { handlePlaybookPreflightRoute, isApiActionEnabledForObject, isRestActionRoutable, isRestRoutePublic, PLAYBOOK_PREFLIGHT_CAPABILITY, PLAYBOOK_PREFLIGHT_ROUTE_SEGMENT, type PlaybookPreflightProvider, type PlaybookPreflightRouteOptions, type PlaybookPreflightRouteRequest, resolveRegisteredObjectName, restFieldReadPermissions, restMethodForApiAction, } from "./preflight-route.js";
10
+ export type { APIConfig, APIContext, RestServerConfig } from "./rest.js";
11
+ export { APIGenerator, computeRuntimeWebManifestHash, createRestServer, startRestServer, } from "./rest.js";
12
+ export type { OpenAPIConfig } from "./swagger.js";
13
+ export { generateOpenAPISpec, setupSwaggerUI, } from "./swagger.js";
14
+ export { runWithTenantGate, setTenantEntryPointRunner, type TenantEntryPointRunner, type TenantGateOptions, } from "./tenant-gate.js";
15
+ export { normalizeTypedHttpError, type TypedHttpFailure, } from "./typed-http-error.js";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACL,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,+BAA+B,EAC/B,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,eAAe,EACf,gBAAgB,EAChB,KAAK,qBAAq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,WAAW,CAAC;AAEnB,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACL,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,sBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,+BAA+B,EAC/B,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,eAAe,EACf,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,4BAA4B,EAC5B,qBAAqB,EACrB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,4BAA4B,EACjC,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,8BAA8B,EAC9B,qCAAqC,EACrC,KAAK,UAAU,EACf,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,oBAAiB,CAAC;AAKzB,OAAO,EACL,sBAAsB,EACtB,KAAK,wBAAwB,EAC7B,gCAAgC,EAChC,2BAA2B,EAC3B,8BAA8B,EAC9B,kCAAkC,EAClC,mCAAmC,EACnC,6BAA6B,EAC7B,qBAAqB,EACrB,mCAAmC,GACpC,MAAM,mBAAgB,CAAC;AACxB,YAAY,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,EACX,OAAO,EACP,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,UAAO,CAAC;AAEf,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,2BAA2B,EAC3B,YAAY,GACb,MAAM,UAAO,CAAC;AAIf,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,EAC7B,gCAAgC,EAChC,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,sBAAmB,CAAC;AAC3B,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAQ,CAAC;AAEtE,OAAO,EACL,YAAY,EACZ,6BAA6B,EAC7B,gBAAgB,EAChB,eAAe,GAChB,MAAM,WAAQ,CAAC;AAChB,YAAY,EAAE,aAAa,EAAE,MAAM,cAAW,CAAC;AAE/C,OAAO,EACL,mBAAmB,EACnB,cAAc,GACf,MAAM,cAAW,CAAC;AAEnB,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,kBAAe,CAAC;AAEvB,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,uBAAoB,CAAC"}
@@ -67,6 +67,8 @@ export interface RuntimeOptions {
67
67
  taskActions?: Record<string, {
68
68
  objectName: string;
69
69
  objectType: string;
70
+ /** Registry identity of the task's class (#3490). */
71
+ registryKey?: string;
70
72
  }>;
71
73
  /**
72
74
  * Lowercased simple names of objects that are `@TenantScoped` (#1554). When
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-runtime-template.d.ts","sourceRoot":"","sources":["../../src/generators/mcp-runtime-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AASxD,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,kCAAkC;IAClC,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,UAAU,CAAC;IAErB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,wDAAwD;IACxD,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvC,WAAW,CAAC,EAAE;YACZ,YAAY,EAAE,OAAO,CAAC;YACtB,eAAe,EAAE,OAAO,CAAC;YACzB,cAAc,EAAE,OAAO,CAAC;YACxB,aAAa,EAAE,OAAO,CAAC;SACxB,CAAC;QACF,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,KAAK,CAAC;YACZ,GAAG,EAAE,MAAM,CAAC;YACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,KAAK,CAAC,EAAE,MA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AA6B,GACxC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,CASR;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,CA6GR"}
1
+ {"version":3,"file":"mcp-runtime-template.d.ts","sourceRoot":"","sources":["../../src/generators/mcp-runtime-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AASxD,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,kCAAkC;IAClC,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,UAAU,CAAC;IAErB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,wDAAwD;IACxD,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvC,WAAW,CAAC,EAAE;YACZ,YAAY,EAAE,OAAO,CAAC;YACtB,eAAe,EAAE,OAAO,CAAC;YACzB,cAAc,EAAE,OAAO,CAAC;YACxB,aAAa,EAAE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D;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;CACjD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,cAAmB,GAAG,MAAM,CAswB7E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,GAAE,MAA6B,GACxC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,CASR;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,CA6GR"}
@@ -44,6 +44,7 @@ function generateRuntimeBootstrap(options = {}) {
44
44
  return tools.map((tool) => {
45
45
  const objectName = toolTargets[tool.name].objectName.toLowerCase();
46
46
  const action = toolTargets[tool.name].action;
47
+ const lookup = toolTargets[tool.name].registryKey ?? toolTargets[tool.name].objectName;
47
48
  switch (action) {
48
49
  case "list": return `${indent}case '${tool.name}': {
49
50
  ${indent} const limit = resolveListBound(args.limit, 'limit', 50, ${MAX_LIST_LIMIT});
@@ -54,7 +55,7 @@ ${indent} // lets successive pages repeat and skip rows on PostgreSQL.
54
55
  ${indent} const orderBy = args.orderBy ?? ${JSON.stringify(listOrderBy[objectName] ?? DEFAULT_LIST_ORDER_BY)};
55
56
  ${indent} const where = args.where ?? {};
56
57
 
57
- ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(toolTargets[tool.name].objectName)}, {
58
+ ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(lookup)}, {
58
59
  ${indent} persistence: { type: process.env.DATABASE_TYPE || 'sqlite', url: process.env.DATABASE_URL || ':memory:' },
59
60
  ${indent} ai: aiConfig
60
61
  ${indent} });
@@ -72,7 +73,7 @@ ${indent} if (!args.id && !args.slug) {
72
73
  ${indent} throw new Error('Either id or slug is required');
73
74
  ${indent} }
74
75
 
75
- ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(toolTargets[tool.name].objectName)}, {
76
+ ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(lookup)}, {
76
77
  ${indent} persistence: { type: process.env.DATABASE_TYPE || 'sqlite', url: process.env.DATABASE_URL || ':memory:' },
77
78
  ${indent} ai: aiConfig
78
79
  ${indent} });
@@ -87,10 +88,9 @@ ${indent} }
87
88
  ${indent} return successResult(item.toPublicJSON(PUBLIC_JSON_OPTIONS));
88
89
  ${indent}}`;
89
90
  case "create": return `${indent}case '${tool.name}': {
90
- ${indent} const { collection, objectName: targetObjectName } = await resolveCreateTarget(${JSON.stringify(objectName)}, args, aiConfig);
91
+ ${indent} const { collection, objectName: targetObjectName } = await resolveCreateTarget(${JSON.stringify(objectName)}, ${JSON.stringify(lookup)}, args, aiConfig);
91
92
 
92
93
  ${indent} const newItem = await collection.create(applyWritablePolicy(targetObjectName, args));
93
- ${indent} await newItem.save();
94
94
 
95
95
  ${indent} return successResult(newItem.toPublicJSON(PUBLIC_JSON_OPTIONS));
96
96
  ${indent}}`;
@@ -100,7 +100,7 @@ ${indent} if (!id) {
100
100
  ${indent} throw new Error('ID is required for update');
101
101
  ${indent} }
102
102
 
103
- ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(toolTargets[tool.name].objectName)}, {
103
+ ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(lookup)}, {
104
104
  ${indent} persistence: { type: process.env.DATABASE_TYPE || 'sqlite', url: process.env.DATABASE_URL || ':memory:' },
105
105
  ${indent} ai: aiConfig
106
106
  ${indent} });
@@ -110,8 +110,10 @@ ${indent} if (!existing) {
110
110
  ${indent} throw new Error('Object not found');
111
111
  ${indent} }
112
112
 
113
- ${indent} Object.assign(existing, applyWritablePolicy(${JSON.stringify(toolTargets[tool.name].objectName)}, updateData));
114
- ${indent} await existing.save();
113
+ ${indent} await collection.withAuditMutation(existing, 'updated', async (bound) => {
114
+ ${indent} Object.assign(bound, applyWritablePolicy(${JSON.stringify(lookup)}, updateData));
115
+ ${indent} await bound.save();
116
+ ${indent} });
115
117
 
116
118
  ${indent} return successResult(existing.toPublicJSON(PUBLIC_JSON_OPTIONS));
117
119
  ${indent}}`;
@@ -120,7 +122,7 @@ ${indent} if (!args.id) {
120
122
  ${indent} throw new Error('ID is required for delete');
121
123
  ${indent} }
122
124
 
123
- ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(toolTargets[tool.name].objectName)}, {
125
+ ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(lookup)}, {
124
126
  ${indent} persistence: { type: process.env.DATABASE_TYPE || 'sqlite', url: process.env.DATABASE_URL || ':memory:' },
125
127
  ${indent} ai: aiConfig
126
128
  ${indent} });
@@ -130,7 +132,7 @@ ${indent} if (!toDelete) {
130
132
  ${indent} throw new Error('Object not found');
131
133
  ${indent} }
132
134
 
133
- ${indent} await toDelete.delete();
135
+ ${indent} await collection.delete(args.id);
134
136
 
135
137
  ${indent} return successResult({ success: true, message: 'Object deleted successfully' });
136
138
  ${indent}}`;
@@ -145,7 +147,7 @@ ${indent} if (actionMeta.scope === 'collection' && id) {
145
147
  ${indent} throw new Error(${JSON.stringify(`Custom action ${action} is collection-scoped and does not accept an ID`)});
146
148
  ${indent} }
147
149
 
148
- ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(toolTargets[tool.name].objectName)}, {
150
+ ${indent} const collection = await ObjectRegistry.getCollection(${JSON.stringify(lookup)}, {
149
151
  ${indent} persistence: { type: process.env.DATABASE_TYPE || 'sqlite', url: process.env.DATABASE_URL || ':memory:' },
150
152
  ${indent} ai: aiConfig
151
153
  ${indent} });
@@ -153,7 +155,7 @@ ${indent} });
153
155
  ${indent} const target = actionMeta.scope === 'item'
154
156
  ${indent} ? await collection.get(id)
155
157
  ${indent} : actionMeta.isStatic
156
- ${indent} ? ObjectRegistry.getClass(${JSON.stringify(toolTargets[tool.name].objectName)})?.constructor
158
+ ${indent} ? ObjectRegistry.getClass(${JSON.stringify(lookup)})?.constructor
157
159
  ${indent} : collection;
158
160
  ${indent} if (!target) {
159
161
  ${indent} throw new Error(actionMeta.scope === 'item' ? 'Object not found' : 'Custom action target not found');
@@ -227,7 +229,7 @@ const DEBUG = ${debug};
227
229
  // Static tool definitions (generated at build time)
228
230
  const TOOLS = ${toolsCode};
229
231
  const TOOL_LIST_CACHE_HINT = ${JSON.stringify(toolListCacheHint)};
230
- const TOOL_TARGETS: Record<string, { objectName: string; action: string }> = ${JSON.stringify(toolTargets)};
232
+ const TOOL_TARGETS: Record<string, { objectName: string; action: string; registryKey?: string }> = ${JSON.stringify(toolTargets)};
231
233
  const CUSTOM_ACTIONS = ${JSON.stringify(customActions)};
232
234
  const TASK_ACTIONS = ${JSON.stringify(taskActions)};
233
235
  const STI_TARGETS: Record<string, Record<string, string>> = ${JSON.stringify(stiTargets)};
@@ -299,10 +301,10 @@ function applyWritablePolicy(objectName: string, data: any): Record<string, any>
299
301
  }
300
302
 
301
303
  /** Resolve an advertised STI discriminator to its registered subtype collection. */
302
- async function resolveCreateTarget(baseObjectName: string, args: Record<string, any>, aiConfig: any) {
304
+ async function resolveCreateTarget(stiKey: string, baseObjectName: string, args: Record<string, any>, aiConfig: any) {
303
305
  let objectName = baseObjectName;
304
306
  const discriminator = args._meta_type;
305
- const targets = STI_TARGETS[baseObjectName];
307
+ const targets = STI_TARGETS[stiKey];
306
308
  if (typeof discriminator === 'string' && targets) {
307
309
  const target = targets[discriminator];
308
310
  if (!target) throw new Error('Unknown STI discriminator: ' + discriminator);
@@ -440,9 +442,9 @@ function jsonRpcError(id: any, code: number, message: string, data?: any) {
440
442
  async function getTaskRuntime() {
441
443
  if (!taskRuntime) {
442
444
  taskRuntime = (async () => {
443
- const firstAction = Object.values(TASK_ACTIONS)[0] as { objectName: string } | undefined;
445
+ const firstAction = Object.values(TASK_ACTIONS)[0] as { objectName: string; registryKey?: string } | undefined;
444
446
  if (!firstAction) throw new Error('No task-enabled MCP action is configured');
445
- const collection = await ObjectRegistry.getCollection(firstAction.objectName, {
447
+ const collection = await ObjectRegistry.getCollection(firstAction.registryKey ?? firstAction.objectName, {
446
448
  persistence: { type: process.env.DATABASE_TYPE || 'sqlite', url: process.env.DATABASE_URL || ':memory:' },
447
449
  });
448
450
  const db = collection.db;