@happyvertical/smrt-core 0.51.32 → 0.51.34

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 (172) hide show
  1. package/agents/build-knowledge.md +13 -0
  2. package/dist/__tests__/fixtures/collection-coverage-fixtures.d.ts +8 -0
  3. package/dist/__tests__/fixtures/inheritance-resolver-fixtures.d.ts +9 -0
  4. package/dist/__tests__/fixtures/inheritance-test-classes.d.ts +5 -0
  5. package/dist/__tests__/fixtures/object-ai-memory-fixtures.d.ts +10 -0
  6. package/dist/__typechecks__/collection-read-plan.d.ts +2 -2
  7. package/dist/adapters/ai-usage.d.ts +5 -2
  8. package/dist/adapters/cost-rates.d.ts +1 -1
  9. package/dist/adapters/metrics.d.ts +7 -1
  10. package/dist/adapters/pubsub.d.ts +7 -1
  11. package/dist/cascade.d.ts +69 -3
  12. package/dist/change-feed-authz.d.ts +85 -2
  13. package/dist/change-feed.d.ts +133 -2
  14. package/dist/change-signals.d.ts +66 -1
  15. package/dist/child-accessors.d.ts +39 -1
  16. package/dist/class.d.ts +8 -8
  17. package/dist/collection-cache.d.ts +47 -1
  18. package/dist/collection-read-plan.d.ts +3 -3
  19. package/dist/collection.d.ts +4 -3
  20. package/dist/config.d.ts +15 -6
  21. package/dist/consumer-plugin/index.d.ts +7 -3
  22. package/dist/consumer-plugin/index.d.ts.map +1 -1
  23. package/dist/consumer-plugin/index.js +2 -0
  24. package/dist/consumer-plugin/index.js.map +1 -1
  25. package/dist/data-query.d.ts +12 -1
  26. package/dist/database.d.ts +10 -2
  27. package/dist/decisions.d.ts +9 -2
  28. package/dist/decorators/index.d.ts +11 -5
  29. package/dist/dispatch/bus.d.ts +27 -2
  30. package/dist/dispatch/collections/DispatchSubscriptions.d.ts +7 -2
  31. package/dist/dispatch/collections/Dispatches.d.ts +8 -3
  32. package/dist/dispatch/models/Dispatch.d.ts +7 -1
  33. package/dist/dispatch/types.d.ts +7 -2
  34. package/dist/embedded-write-queue.d.ts +1 -1
  35. package/dist/embeddings/provider.d.ts +8 -1
  36. package/dist/embeddings/storage.d.ts +8 -2
  37. package/dist/filesystem-loader.d.ts +16 -1
  38. package/dist/generators/changes-route.d.ts +34 -1
  39. package/dist/generators/custom-action.d.ts +10 -2
  40. package/dist/generators/events-route.d.ts +41 -4
  41. package/dist/generators/mcp-runtime-template.d.ts +13 -2
  42. package/dist/generators/mcp.d.ts +6 -1
  43. package/dist/generators/rest.d.ts +10 -5
  44. package/dist/generators/tool-schema.d.ts +1 -1
  45. package/dist/hierarchical.d.ts +37 -1
  46. package/dist/interceptors.d.ts +45 -1
  47. package/dist/junction.d.ts +24 -0
  48. package/dist/knowledge-config.d.ts +1 -1
  49. package/dist/knowledge-discovery.d.ts +2 -25
  50. package/dist/knowledge-discovery.d.ts.map +1 -1
  51. package/dist/knowledge-discovery.js +1 -53
  52. package/dist/knowledge-graph.d.ts +2 -94
  53. package/dist/knowledge-graph.d.ts.map +1 -1
  54. package/dist/knowledge-graph.js +1 -267
  55. package/dist/knowledge.d.ts +4 -23
  56. package/dist/knowledge.d.ts.map +1 -1
  57. package/dist/knowledge.js +3 -52
  58. package/dist/knowledge.js.map +1 -1
  59. package/dist/learning/memory.d.ts +21 -1
  60. package/dist/manifest/generator.d.ts +5 -1
  61. package/dist/manifest/index.d.ts +5 -1
  62. package/dist/manifest/manager.d.ts +1 -1
  63. package/dist/manifest/manifest-loader.d.ts +24 -2
  64. package/dist/manifest/sources/composite.d.ts +17 -1
  65. package/dist/manifest/sources/embedded.d.ts +10 -1
  66. package/dist/manifest/sources/explicit-paths.d.ts +13 -1
  67. package/dist/manifest/sources/fallback.d.ts +15 -1
  68. package/dist/manifest/sources/local-test.d.ts +10 -1
  69. package/dist/manifest/sources/static.d.ts +12 -1
  70. package/dist/manifest/sources/test.d.ts +9 -1
  71. package/dist/manifest/sources/types.d.ts +7 -1
  72. package/dist/manifest/static-manifest.d.ts +6 -1
  73. package/dist/manifest/static-manifest.js +1 -1
  74. package/dist/manifest/static-manifest.js.map +1 -1
  75. package/dist/manifest/store.d.ts +22 -3
  76. package/dist/manifest/store.js +1 -1
  77. package/dist/manifest.json +1 -1
  78. package/dist/migrations/backfill-tracker.d.ts +15 -1
  79. package/dist/migrations/differ.d.ts +8 -2
  80. package/dist/migrations/framework-base-tables.d.ts +57 -2
  81. package/dist/migrations/generator.d.ts +8 -2
  82. package/dist/migrations/integer-width.d.ts +10 -2
  83. package/dist/migrations/minor-units.d.ts +40 -1
  84. package/dist/migrations/null-equal-indexes.d.ts +3 -2
  85. package/dist/migrations/orchestrate.d.ts +15 -3
  86. package/dist/migrations/sqlite-rebuild.d.ts +67 -2
  87. package/dist/migrations/tracker.d.ts +9 -3
  88. package/dist/migrations/types.d.ts +7 -2
  89. package/dist/object.d.ts +7 -6
  90. package/dist/polymorphic-association.d.ts +44 -1
  91. package/dist/postgres-permissions.d.ts +1 -1
  92. package/dist/prebuild/index.d.ts +5 -1
  93. package/dist/query-bounds.d.ts +26 -0
  94. package/dist/registry/cache-config.d.ts +10 -1
  95. package/dist/registry/class-registration.d.ts +10 -2
  96. package/dist/registry/collection-resolution.d.ts +1 -1
  97. package/dist/registry/embedding-manager.d.ts +9 -1
  98. package/dist/registry/inheritance-resolver.d.ts +8 -3
  99. package/dist/registry/manifest-field-merge.d.ts +2 -2
  100. package/dist/registry/name-resolver.d.ts +22 -2
  101. package/dist/registry/relationship-graph.d.ts +9 -1
  102. package/dist/registry/schema-builder.d.ts +8 -3
  103. package/dist/registry/shared-state.d.ts +12 -2
  104. package/dist/registry/types.d.ts +15 -7
  105. package/dist/registry/validator.d.ts +10 -2
  106. package/dist/registry.d.ts +40 -11
  107. package/dist/relationship-loader.d.ts +1 -1
  108. package/dist/run-once.d.ts +110 -1
  109. package/dist/runtime/client.d.ts +4 -1
  110. package/dist/runtime/server.d.ts +5 -2
  111. package/dist/scanner/import-scanner.d.ts +1 -1
  112. package/dist/scanner/manifest-generator.d.ts +4 -1
  113. package/dist/scanner/types.d.ts +4 -1
  114. package/dist/schema/code-generator.d.ts +6 -2
  115. package/dist/schema/column-data-probes.d.ts +27 -2
  116. package/dist/schema/ddl/base-strategy.d.ts +8 -2
  117. package/dist/schema/ddl/duckdb-strategy.d.ts +14 -2
  118. package/dist/schema/ddl/index.d.ts +2 -2
  119. package/dist/schema/ddl/json-duckdb-strategy.d.ts +10 -2
  120. package/dist/schema/ddl/materialize-manifest.d.ts +1 -1
  121. package/dist/schema/ddl/null-equal-index.d.ts +1 -1
  122. package/dist/schema/ddl/postgres-strategy.d.ts +12 -2
  123. package/dist/schema/ddl/sqlite-strategy.d.ts +12 -2
  124. package/dist/schema/ddl/types.d.ts +10 -1
  125. package/dist/schema/foreign-key-ddl.d.ts +2 -2
  126. package/dist/schema/foreign-key-orphan-report.d.ts +25 -3
  127. package/dist/schema/foreign-key-planner.d.ts +2 -2
  128. package/dist/schema/foreign-key-policy.d.ts +1 -1
  129. package/dist/schema/generator.d.ts +7 -3
  130. package/dist/schema/index-utils.d.ts +11 -2
  131. package/dist/schema/live-parity.d.ts +27 -3
  132. package/dist/schema/manifest-schema.d.ts +21 -2
  133. package/dist/schema/schema-aggregator.d.ts +35 -2
  134. package/dist/schema/schema-manager.d.ts +13 -4
  135. package/dist/schema/system-table-shapes.d.ts +20 -1
  136. package/dist/schema/table-verifier.d.ts +1 -1
  137. package/dist/schema/text-cast-probe.d.ts +24 -1
  138. package/dist/schema/utils.d.ts +13 -4
  139. package/dist/schema/uuid-convergence.d.ts +32 -1
  140. package/dist/signals/bus.d.ts +8 -2
  141. package/dist/signals/sanitizer.d.ts +7 -1
  142. package/dist/smrt-knowledge.json +8 -9
  143. package/dist/system/bootstrap.d.ts +2 -1
  144. package/dist/system/compatibility.d.ts +1 -1
  145. package/dist/system/diagnostics.d.ts +17 -2
  146. package/dist/system/retention.d.ts +46 -1
  147. package/dist/system/schema.d.ts +7 -1
  148. package/dist/system-fields.d.ts +9 -1
  149. package/dist/test-utils.d.ts +7 -1
  150. package/dist/testing/database.d.ts +18 -1
  151. package/dist/testing/notifications-stub.d.ts +15 -1
  152. package/dist/tools/tool-executor.d.ts +6 -1
  153. package/dist/tools/tool-generator.d.ts +8 -2
  154. package/dist/utils/json.d.ts +9 -1
  155. package/dist/utils/qualified-names.d.ts +10 -1
  156. package/dist/utils/scanner-module.d.ts +2 -2
  157. package/dist/utils.d.ts +1 -1
  158. package/dist/vite-plugin/api-client-entries.d.ts +9 -1
  159. package/dist/vite-plugin/changes-route.d.ts +33 -2
  160. package/dist/vite-plugin/dev-plane-route.d.ts +12 -1
  161. package/dist/vite-plugin/events-route.d.ts +37 -2
  162. package/dist/vite-plugin/generated-client.d.ts +9 -1
  163. package/dist/vite-plugin/index.d.ts +9 -5
  164. package/dist/vite-plugin/resources-route.d.ts +82 -1
  165. package/dist/vite-plugin/sveltekit-generator.d.ts +8 -4
  166. package/dist/vite-plugin/sveltekit-route-coordinator.d.ts +3 -3
  167. package/dist/vite-plugin/sync-apply-route.d.ts +19 -2
  168. package/dist/vite-plugin/web-collections.d.ts +25 -2
  169. package/dist/vite-plugin/worker-registration.d.ts +21 -1
  170. package/package.json +7 -8
  171. package/dist/knowledge-discovery.js.map +0 -1
  172. package/dist/knowledge-graph.js.map +0 -1
@@ -1,8 +1,12 @@
1
- import { DomainKnowledgeAgentSurface, DomainKnowledgeConfig } from '@happyvertical/smrt-types';
2
- import { Plugin } from 'vite';
3
- import { SmrtGenerationSnapshotOptions } from '../generation-snapshot.js';
4
- import { SmartObjectManifest } from '../scanner/types.js';
5
- import { ScannerAgentSurface, ScannerModule } from '../utils/scanner-module.js';
1
+ /**
2
+ * Vite plugin for automatic SMRT service generation
3
+ * Provides virtual modules for REST, MCP, and other services
4
+ */
5
+ import type { DomainKnowledgeAgentSurface, DomainKnowledgeConfig } from '@happyvertical/smrt-types';
6
+ import type { Plugin } from 'vite';
7
+ import { type SmrtGenerationSnapshotOptions } from '../generation-snapshot.js';
8
+ import { type SmartObjectManifest } from '../scanner/types.js';
9
+ import type { ScannerAgentSurface, ScannerModule } from '../utils/scanner-module.js';
6
10
  export { loadVerifiedSmrtGenerationSnapshot, type SerializeSmrtGenerationSnapshotOptions, type SmrtGenerationSnapshotArtifact, type SmrtGenerationSnapshotOptions, type SmrtGenerationSnapshotView, serializeSmrtGenerationSnapshot, sha256SmrtGenerationSnapshot, } from '../generation-snapshot.js';
7
11
  export type { CliApiCoherenceViolation, SvelteKitOptions, } from './sveltekit-generator.js';
8
12
  export { findCliApiCoherenceViolations, generateSvelteKitRoutes, methodNameToKebab, resolveApiActionRouteConfig, resolveApiActionSet, validateCliIncludeAgainstApi, } from './sveltekit-generator.js';
@@ -1,4 +1,85 @@
1
- import { SvelteKitOptions } from './sveltekit-generator.js';
1
+ /**
2
+ * SvelteKit `_resources` route generation — CLI discovery endpoint (#2663;
3
+ * parent epic #2655).
4
+ *
5
+ * Emits `{routesDir}/_resources/+server.ts`: `GET /api/_resources`, the
6
+ * endpoint the distributable CLI (`@happyvertical/smrt-app-cli`) reads to
7
+ * learn which resources and commands it can invoke. Every other generated
8
+ * route lives in `sveltekit-generator.ts` or a sibling emitter; this one is
9
+ * kept in its own module for the same reason `changes-route.ts` and
10
+ * `events-route.ts` are — a one-line registration hook in the shared
11
+ * generator file.
12
+ *
13
+ * ## The dependency constraint
14
+ *
15
+ * The handler this route delegates to, `createResourceListHandler`, lives in
16
+ * `@happyvertical/smrt-users` — and `smrt-users` depends on `smrt-core`, not
17
+ * the reverse, so core cannot import it directly. That is not a problem for
18
+ * *emitting* the import: the generated file is written into the consumer's
19
+ * own `src/routes/`, where `@happyvertical/smrt-users` resolves through the
20
+ * consumer's own dependency graph, exactly like the `@happyvertical/smrt-tenancy`
21
+ * import `sveltekit-generator.ts`'s `generateTenantContextHelper` already
22
+ * emits into tenant-scoped routes (see the comment above that function). The
23
+ * only question is *when* it is safe to emit — a consumer that never took a
24
+ * dependency on `smrt-users` must never receive a route whose import cannot
25
+ * resolve, or a working build turns red.
26
+ *
27
+ * ## Detection mechanism
28
+ *
29
+ * Unlike the tenancy guard — which reads a semantic signal already present in
30
+ * the manifest (whether any object is `@TenantScoped`, which itself implies
31
+ * the app depends on `smrt-tenancy`) — nothing in the manifest indicates
32
+ * whether a consumer has taken on `smrt-users`. Objects don't declare an
33
+ * auth dependency; the app does, at the package level.
34
+ *
35
+ * So this route uses a **resolvable-dependency check**: does the exact
36
+ * subpath the generated file imports — `@happyvertical/smrt-users/sveltekit`
37
+ * — resolve from the consumer's `projectRoot`, via a `createRequire` rooted
38
+ * at the consumer's own `package.json`? That is stronger than reading
39
+ * `package.json`'s `dependencies` block (which can list a package that was
40
+ * never installed) and, unlike a single hardcoded
41
+ * `node_modules/@happyvertical/smrt-users/package.json` path, it uses
42
+ * Node's real module resolution — so it also finds the package when a
43
+ * workspace hoists shared dependencies to an ancestor `node_modules` (npm/
44
+ * yarn workspaces, or pnpm with `node-linker=hoisted`) rather than
45
+ * installing them directly under the consumer's own `projectRoot`.
46
+ * Resolving the `/sveltekit` subpath specifically, rather than the
47
+ * package's bare `package.json`, matters too: `smrt-users`'s `exports` map
48
+ * does not list `./package.json`, so resolving that path would throw
49
+ * `ERR_PACKAGE_PATH_NOT_EXPORTED` even when the package is genuinely
50
+ * installed — resolving the subpath the route actually imports sidesteps
51
+ * that and checks precisely the thing that must succeed at build time.
52
+ *
53
+ * An explicit `sveltekit: { resourcesRoute: { enabled: false } }` escape
54
+ * hatch is also available, matching `changesRoute`/`eventsRoute`, for a
55
+ * consumer that has `smrt-users` installed but wants to keep hand-writing
56
+ * (or omit) `_resources`.
57
+ *
58
+ * ## Preserving a hand-written route
59
+ *
60
+ * Every consumer today hand-writes this route (the reference implementation
61
+ * in the issue). `clearGeneratedRouteFiles` (in `sveltekit-generator.ts`)
62
+ * already only deletes `+server.ts` files that start with
63
+ * {@link AUTO_GENERATED_ROUTE_HEADER}, so a hand-written `_resources` route —
64
+ * which never carries that header — survives the pre-generation sweep
65
+ * untouched. This emitter additionally checks `existsSync` on the target
66
+ * path before writing: by the time it runs, anything still there is
67
+ * necessarily hand-written (a generator-owned copy would already have been
68
+ * swept), so its mere presence is sufficient to skip generation and leave it
69
+ * alone.
70
+ *
71
+ * Once a consumer's `_resources` route IS generator-owned (no hand-written
72
+ * file present, `smrt-users` resolvable), its path is generator-owned for
73
+ * `.gitignore` purposes too — it is included in `generatedRoutePaths` like
74
+ * any other emitted route, so `updateGitignore` puts it in the managed
75
+ * block. A project that migrated from a hand-written route to a fully
76
+ * generated one may still carry a stale `# Application-owned rule` comment
77
+ * above the same literal path from before the migration; `updateGitignore`
78
+ * only ever touches its own managed block, so that stale comment is left as
79
+ * project history for the consumer to clean up — the same way any other
80
+ * manual `.gitignore` edit outside the managed block is preserved.
81
+ */
82
+ import type { SvelteKitOptions } from './sveltekit-generator.js';
2
83
  /**
3
84
  * Whether `@happyvertical/smrt-users/sveltekit` — the exact subpath the
4
85
  * generated route imports — is resolvable from the consumer at
@@ -1,7 +1,11 @@
1
- import { DomainKnowledgeConfig } from '@happyvertical/smrt-types';
2
- import { ApiMethodExposure, WireabilityOptions } from '../generators/custom-action.js';
3
- import { ApiHttpMethod } from '../registry/types.js';
4
- import { MethodDefinition, SmartObjectDefinition, SmartObjectManifest } from '../scanner/types';
1
+ /**
2
+ * SvelteKit route auto-generation from SMRT objects
3
+ * Generates real TypeScript files in src/routes/api/ based on discovered SMRT objects
4
+ */
5
+ import type { DomainKnowledgeConfig } from '@happyvertical/smrt-types';
6
+ import { type ApiMethodExposure, type WireabilityOptions } from '../generators/custom-action.js';
7
+ import type { ApiHttpMethod } from '../registry/types.js';
8
+ import type { MethodDefinition, SmartObjectDefinition, SmartObjectManifest } from '../scanner/types';
5
9
  export interface SvelteKitOptions {
6
10
  enabled: boolean;
7
11
  routesDir: string;
@@ -1,6 +1,6 @@
1
- import { ConfigEnv, Plugin } from 'vite';
2
- import { SmartObjectManifest } from '../scanner/types.js';
3
- import { SvelteKitOptions } from './sveltekit-generator.js';
1
+ import type { ConfigEnv, Plugin } from 'vite';
2
+ import type { SmartObjectManifest } from '../scanner/types.js';
3
+ import { type SvelteKitOptions } from './sveltekit-generator.js';
4
4
  export type SvelteKitRouteOwner = 'producer' | 'consumer';
5
5
  interface RouteContribution {
6
6
  owner: SvelteKitRouteOwner;
@@ -1,5 +1,22 @@
1
- import { SmartObjectManifest } from '../scanner/types';
2
- import { SvelteKitOptions } from './sveltekit-generator.js';
1
+ /**
2
+ * SvelteKit generator for the sync-apply batch write route (#1759).
3
+ *
4
+ * Emits ONE route — `{routesDir}/sync/apply/+server.ts` — implementing the
5
+ * shared web/mobile write contract for every syncable model in the manifest
6
+ * (models whose API config exposes at least one of create/update/delete). The
7
+ * generated file is deliberately thin: it maps `object` segments to
8
+ * collections plus per-model policy data, and delegates all batch processing
9
+ * to `processSyncApplyBatch` from `@happyvertical/smrt-core` — the same
10
+ * engine the runtime REST generator uses, so the two transports cannot drift.
11
+ *
12
+ * This lives in its own module (rather than sveltekit-generator.ts) so the
13
+ * shared generator file only needs a one-line registration hook; sibling
14
+ * work (#1757, #1758) touches the same generator files in parallel.
15
+ *
16
+ * Contract documentation: docs/content/architecture/sync-apply-contract.md
17
+ */
18
+ import type { SmartObjectManifest } from '../scanner/types';
19
+ import type { SvelteKitOptions } from './sveltekit-generator.js';
3
20
  declare const MUTATING_ACTIONS: readonly ["create", "update", "delete"];
4
21
  type MutatingAction = (typeof MUTATING_ACTIONS)[number];
5
22
  /** Per-model data embedded into the generated route. */
@@ -1,5 +1,28 @@
1
- import { ToolDescriptor, ToolIdType, ToolRouteDescriptor } from '../generators/tool-schema.js';
2
- import { FieldDefinition, FieldUIHints, SmartObjectDefinition, SmartObjectManifest } from '../scanner/types.js';
1
+ /**
2
+ * Manifest → web collection selection (single source of truth).
3
+ *
4
+ * The browser client data runtime (`@happyvertical/smrt-web`, #1761) consumes
5
+ * one typed collection definition per API-exposed REST collection. Four
6
+ * co-managed emission surfaces need the SAME selection and field rules, or the
7
+ * emitted runtime values and their declared types drift apart:
8
+ *
9
+ * - the `\0smrt:web` runtime virtual module (JSON literal — {@link generateWebModule})
10
+ * - the `@happyvertical/smrt-virt-web` ambient d.ts (vite-plugin)
11
+ * - the physical `@smrt/web` d.ts (prebuild, for `tsc`-only consumers)
12
+ * - the dependency-free type mirror in `@happyvertical/smrt-web`
13
+ *
14
+ * The three generated sites import {@link selectWebCollectionEntries} from
15
+ * here so the value emission and the type emission can never disagree. The hand-written mirror
16
+ * is deliberately smrt-dependency-free, so its copy cannot import these types;
17
+ * keep it textually in sync when the shape here changes. The per-collection SHAPE
18
+ * (name/objectRef/className/endpoint/idField/actions/fields/relationships) is built by the
19
+ * ONE {@link buildWebCollectionDefinition}, shared by the runtime emission AND
20
+ * the #1764 {@link computeWebManifestHash} shape digest — so the emitted shape
21
+ * and the hashed shape can never drift (a drift would let the hash under-cover a
22
+ * change → stale client caches).
23
+ */
24
+ import { type ToolDescriptor, type ToolIdType, type ToolRouteDescriptor } from '../generators/tool-schema.js';
25
+ import type { FieldDefinition, FieldUIHints, SmartObjectDefinition, SmartObjectManifest } from '../scanner/types.js';
3
26
  /**
4
27
  * The field types that actually reach an emitted web collection definition:
5
28
  * everything {@link buildWebFieldDefinitions} does not skip. Relationship
@@ -1,4 +1,24 @@
1
- import { Alias, ResolvedConfig } from 'vite';
1
+ /**
2
+ * Compiled application registration for out-of-bundle Node processes (#3117).
3
+ *
4
+ * A SvelteKit app registers its own `@smrt()` objects through the generated
5
+ * `smrt-register.ts`, which only the Vite build compiles — and adapter-node
6
+ * re-bundles the server from its own entries, so that module never exists as
7
+ * an importable file in `build/`. A deployed task or schedule worker is plain
8
+ * ESM run by `node`, so without this artifact `ObjectRegistry.getClass()`
9
+ * cannot resolve any application object and every app-defined job throws
10
+ * `Unknown object type` before its method runs.
11
+ *
12
+ * After a production build, this compiles that same generated module into
13
+ * `.smrt/runtime/register.js`: one ESM entry that registers the app's local
14
+ * objects AND its consumed packages' objects (via the `.smrt/register.js` it
15
+ * imports), with each class's package-qualified identity and isolated
16
+ * manifest exactly as the web server registers them. Application sources are
17
+ * bundled; every package import stays external and is resolved from
18
+ * `node_modules` at runtime, like the rest of the deployed image — so the
19
+ * worker and `@happyvertical/smrt-core` share one registry.
20
+ */
21
+ import type { Alias, ResolvedConfig } from 'vite';
2
22
  /** Directory (under the project root) the compiled registration is written to. */
3
23
  export declare const WORKER_REGISTRATION_DIR = ".smrt/runtime";
4
24
  /** Entry file name inside {@link WORKER_REGISTRATION_DIR}. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-core",
3
- "version": "0.51.32",
3
+ "version": "0.51.34",
4
4
  "description": "Core AI agent framework with standardized collections, object-relational mapping, and code generators",
5
5
  "author": "HappyVertical",
6
6
  "type": "module",
@@ -154,9 +154,9 @@
154
154
  "@happyvertical/files": "^0.94.1",
155
155
  "@happyvertical/json": "^0.94.1",
156
156
  "@happyvertical/logger": "^0.94.1",
157
- "@happyvertical/smrt-config": "0.51.32",
158
- "@happyvertical/smrt-scanner": "0.51.32",
159
- "@happyvertical/smrt-types": "0.51.32",
157
+ "@happyvertical/smrt-config": "0.51.34",
158
+ "@happyvertical/smrt-scanner": "0.51.34",
159
+ "@happyvertical/smrt-types": "0.51.34",
160
160
  "@happyvertical/sql": "^0.94.1",
161
161
  "@happyvertical/utils": "^0.94.1",
162
162
  "@oxc-project/runtime": "^0.150.0",
@@ -166,6 +166,7 @@
166
166
  "oxc-transform": "0.150.0",
167
167
  "pluralize": "^8.0.0",
168
168
  "tsx": "^4.23.13",
169
+ "vite": "8.1.4",
169
170
  "yaml": "^2.9.1"
170
171
  },
171
172
  "peerDependencies": {
@@ -189,10 +190,8 @@
189
190
  "@types/pluralize": "^0.0.33",
190
191
  "@xenova/transformers": "^2.17.2",
191
192
  "svelte": "^5.57.1",
192
- "svelte-check": "4.7.6",
193
- "typescript": "5.9.3",
194
- "vite": "8.1.4",
195
- "vite-plugin-dts": "5.1.0",
193
+ "svelte-check": "^4.7.6",
194
+ "typescript": "6.0.3",
196
195
  "vitest": "4.1.10"
197
196
  },
198
197
  "publishConfig": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"knowledge-discovery.js","names":[],"sources":["../src/knowledge-discovery.ts"],"sourcesContent":["/** Filesystem-only discovery shared by docs snapshots and knowledge indexing. */\nimport type { Dirent } from 'node:fs';\nimport { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport interface ScopedPackageDirectory {\n /** Scope entry name; consumers may select by alias rather than manifest name. */\n name: string;\n /** Original node_modules path, retained for workspace-relative reporting. */\n directory: string;\n /** Resolved path for identity comparisons or absolute snapshot links. */\n realDirectory: string;\n}\n\n/**\n * Enumerate scope entries without descending into pnpm's linked dependency graph.\n * Selection, workspace discovery and enrichment remain caller policies.\n */\nexport function discoverScopedPackageDirectories(\n scopeDirectories: string[],\n): ScopedPackageDirectory[] {\n const packages: ScopedPackageDirectory[] = [];\n for (const scopeDirectory of new Set(scopeDirectories)) {\n let entries: Dirent[];\n try {\n entries = readdirSync(scopeDirectory, { withFileTypes: true });\n } catch {\n continue;\n }\n for (const entry of entries) {\n if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;\n const directory = join(scopeDirectory, entry.name);\n try {\n packages.push({\n name: entry.name,\n directory,\n realDirectory: realpathSync(directory),\n });\n } catch {\n // Dangling links are not installed packages.\n }\n }\n }\n return packages;\n}\n\n/** Read authored docs only; never load artifacts, package code or object scans. */\nexport function readPackageAgentDoc(\n directory: string,\n options: { inspectAdapter?: boolean } = {},\n) {\n const agentsPath = join(directory, 'AGENTS.md');\n const claudePath = join(directory, 'CLAUDE.md');\n const hasAgentsMd = existsSync(agentsPath);\n const hasClaudeMd = existsSync(claudePath);\n const agentsContent = hasAgentsMd ? readFileSync(agentsPath, 'utf8') : '';\n const claudeContent =\n hasClaudeMd && (!hasAgentsMd || options.inspectAdapter)\n ? readFileSync(claudePath, 'utf8')\n : '';\n const hasClaudeShim = hasClaudeMd && claudeContent.trim() === '@AGENTS.md';\n const source: 'AGENTS.md' | 'CLAUDE.md' | null = hasAgentsMd\n ? 'AGENTS.md'\n : hasClaudeMd && !hasClaudeShim\n ? 'CLAUDE.md'\n : null;\n return {\n hasAgentsMd,\n hasClaudeMd,\n hasClaudeShim,\n agentsContent,\n claudeContent,\n source,\n content: hasAgentsMd ? agentsContent : source ? claudeContent : null,\n };\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,iCACd,kBAC0B;CAC1B,MAAM,WAAqC,CAAC;CAC5C,KAAK,MAAM,kBAAkB,IAAI,IAAI,gBAAgB,GAAG;EACtD,IAAI;EACJ,IAAI;GACF,UAAU,YAAY,gBAAgB,EAAE,eAAe,KAAK,CAAC;EAC/D,QAAQ;GACN;EACF;EACA,KAAK,MAAM,SAAS,SAAS;GAC3B,IAAI,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,eAAe,GAAG;GACrD,MAAM,YAAY,KAAK,gBAAgB,MAAM,IAAI;GACjD,IAAI;IACF,SAAS,KAAK;KACZ,MAAM,MAAM;KACZ;KACA,eAAe,aAAa,SAAS;IACvC,CAAC;GACH,QAAQ,CAER;EACF;CACF;CACA,OAAO;AACT;;AAGA,SAAgB,oBACd,WACA,UAAwC,CAAC,GACzC;CACA,MAAM,aAAa,KAAK,WAAW,WAAW;CAC9C,MAAM,aAAa,KAAK,WAAW,WAAW;CAC9C,MAAM,cAAc,WAAW,UAAU;CACzC,MAAM,cAAc,WAAW,UAAU;CACzC,MAAM,gBAAgB,cAAc,aAAa,YAAY,MAAM,IAAI;CACvE,MAAM,gBACJ,gBAAgB,CAAC,eAAe,QAAQ,kBACpC,aAAa,YAAY,MAAM,IAC/B;CACN,MAAM,gBAAgB,eAAe,cAAc,KAAK,MAAM;CAC9D,MAAM,SAA2C,cAC7C,cACA,eAAe,CAAC,gBACd,cACA;CACN,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,cAAc,gBAAgB,SAAS,gBAAgB;CAClE;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"knowledge-graph.js","names":[],"sources":["../src/knowledge-graph.ts"],"sourcesContent":["/**\n * Cross-package knowledge graph (#2863).\n *\n * Each package's own `smrt-knowledge.json` (see `knowledge.ts`) is a\n * per-package projection. Nothing merges them, so cross-package invariants\n * that the scanner manifest already carries — `@crossPackageRef` targets, STI\n * parent/child pairs, junction/hierarchical/polymorphic base usage, and\n * `_smrt_` system-table ownership — live only as prose in the root\n * `AGENTS.md`. This module builds the merged, deterministic root artifact\n * (`.smrt/smrt-knowledge-graph.json`) from whichever per-package artifacts\n * are present, and checks it for staleness the same way `knowledge.ts` checks\n * a package artifact: by comparing recorded `sourceHashes` against the\n * current file content.\n *\n * This module never invents an edge: every edge is a direct read of a field\n * already emitted into a package's `DomainKnowledgeManifest` (`related`,\n * `tableStrategy`, `extends`, `relationshipFeatures`, `tableName`).\n */\n\nimport { createHash } from 'node:crypto';\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type {\n DomainKnowledgeManifest,\n DomainKnowledgeObject,\n} from '@happyvertical/smrt-types';\n\n/**\n * Discovers every currently-buildable per-package artifact path under\n * `<rootDir>/packages/*`, preferring the published `dist/smrt-knowledge.json`\n * over the local dev `.smrt/smrt-knowledge.json` when both exist. Shared by\n * the generator (which needs the manifest content) and the freshness check\n * (which only needs to know whether the current SET of artifacts matches\n * what the graph was built from — a newly built package, or a package that\n * newly started exporting `./smrt-knowledge.json`, must mark the graph stale\n * even though every artifact the graph already knows about is unchanged).\n */\nexport function discoverKnowledgeArtifactPaths(rootDir: string): string[] {\n const packagesDir = join(rootDir, 'packages');\n if (!existsSync(packagesDir)) return [];\n const paths: string[] = [];\n for (const entry of readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const packageDir = join(packagesDir, entry.name);\n const candidates = [\n join(packageDir, 'dist', 'smrt-knowledge.json'),\n join(packageDir, '.smrt', 'smrt-knowledge.json'),\n ];\n const found = candidates.find((path) => existsSync(path));\n if (found) paths.push(relative(rootDir, found).split('\\\\').join('/'));\n }\n return paths.sort();\n}\n\n/** One package's `smrt-knowledge.json`, located relative to the graph root. */\nexport interface KnowledgeGraphInput {\n /** Path to the artifact, relative to the repo root, POSIX-separated. */\n artifactPath: string;\n manifest: DomainKnowledgeManifest;\n}\n\nexport interface KnowledgeGraphPackageNode {\n name: string;\n version?: string;\n artifactPath: string;\n tags: string[];\n risks: string[];\n summary?: string;\n objectCount: number;\n}\n\nexport interface KnowledgeGraphObjectNode {\n /** `<packageName>#<qualifiedName-or-name>`, this graph's stable object id. */\n id: string;\n packageName: string;\n name: string;\n qualifiedName?: string;\n collection: string;\n tableName?: string;\n tableStrategy?: 'cti' | 'sti';\n extends?: string;\n}\n\nexport type KnowledgeGraphEdgeType =\n | 'crossPackageRef'\n | 'sti'\n | 'junction'\n | 'hierarchical'\n | 'polymorphic'\n | 'systemTable';\n\nexport interface KnowledgeGraphEdge {\n type: KnowledgeGraphEdgeType;\n /** Object id (or `<packageName>#<extends>`-style unresolved target) this edge starts from. */\n from: string;\n /**\n * Object id the edge points to when resolvable against a scanned object;\n * otherwise the raw declared target (e.g. a qualified name this run did\n * not scan), so the edge is still readable rather than dropped.\n */\n to?: string;\n /** Declaring field name, for `crossPackageRef` edges. */\n field?: string;\n}\n\nexport interface SmrtKnowledgeGraph {\n schemaVersion: 1;\n generatedAt: string;\n /** `artifactPath -> sha256(content)`, sorted by key; the freshness input. */\n sourceHashes: Record<string, string>;\n packages: KnowledgeGraphPackageNode[];\n objects: KnowledgeGraphObjectNode[];\n edges: KnowledgeGraphEdge[];\n}\n\nfunction hashContent(content: string): string {\n return createHash('sha256').update(content).digest('hex');\n}\n\nfunction objectId(packageName: string, object: DomainKnowledgeObject): string {\n return `${packageName}#${object.qualifiedName ?? object.name}`;\n}\n\nexport interface BuildKnowledgeGraphOptions {\n /**\n * The graph currently on disk, when regenerating. `generatedAt` is\n * preserved from it rather than reset to the clock whenever the rebuilt\n * graph is otherwise semantically identical — the same pattern\n * `preserveKnowledgeGeneratedAt` uses for per-package artifacts\n * (`packages/core/src/vite-plugin/index.ts`) — so re-running the generator\n * with nothing merged actually changed does not churn the file (#2872\n * review).\n */\n previousGraph?: SmrtKnowledgeGraph;\n}\n\n/** Builds the merged graph. Deterministic: every array is sorted. */\nexport function buildKnowledgeGraph(\n inputs: KnowledgeGraphInput[],\n options: BuildKnowledgeGraphOptions = {},\n): SmrtKnowledgeGraph {\n const sortedInputs = [...inputs].sort((a, b) =>\n a.artifactPath.localeCompare(b.artifactPath),\n );\n\n const sourceHashes: Record<string, string> = {};\n const packages: KnowledgeGraphPackageNode[] = [];\n const objects: KnowledgeGraphObjectNode[] = [];\n const edges: KnowledgeGraphEdge[] = [];\n\n // Qualified-name -> object id, so a crossPackageRef/STI target declared in\n // one package can be resolved to the node emitted by whichever package\n // scanned it, regardless of scan order.\n const idByQualifiedName = new Map<string, string>();\n // Distinct ids per simple name, not a plain array: the same external\n // object can appear in more than one input (e.g. a package artifact and a\n // smrtConsumer aggregate that also scanned it), and counting the\n // duplicate would make resolveTarget's `.length === 1` uniqueness check\n // see a false ambiguity for an otherwise-unique name (#2872 review).\n const idBySimpleName = new Map<string, Set<string>>();\n // A `tableStrategy: 'sti'` object's `extends` is an unqualified simple name\n // (its own package's base class, never a cross-package reference — STI\n // shares one table within a package), so a same-package simple-name match\n // must win over an ambiguous or wrong-package GLOBAL simple-name match:\n // two packages both declaring `Account` must not point one package's\n // subclass at the other package's `Account` (#2863 review).\n const idBySimpleNamePerPackage = new Map<string, Map<string, string>>();\n\n for (const input of sortedInputs) {\n const manifestPackageName =\n input.manifest.packageName ?? input.artifactPath;\n for (const object of input.manifest.objects) {\n // A merged consumer manifest (`smrtConsumer`) aggregates objects\n // scanned from multiple external packages under one local artifact;\n // each object then carries its own `packageName` and that must own\n // the id, or every external object misattributes to the local\n // project and edges resolve to the wrong node (#2872 review).\n const packageName = object.packageName ?? manifestPackageName;\n const perPackage =\n idBySimpleNamePerPackage.get(packageName) ?? new Map<string, string>();\n const id = objectId(packageName, object);\n idByQualifiedName.set(object.qualifiedName ?? id, id);\n const bySimple = idBySimpleName.get(object.name) ?? new Set<string>();\n bySimple.add(id);\n idBySimpleName.set(object.name, bySimple);\n perPackage.set(object.name, id);\n idBySimpleNamePerPackage.set(packageName, perPackage);\n }\n }\n\n const resolveTarget = (\n raw: string | undefined,\n declaringPackageName?: string,\n ): string | undefined => {\n if (!raw) return undefined;\n if (idByQualifiedName.has(raw)) return idByQualifiedName.get(raw);\n if (declaringPackageName) {\n const sameId = idBySimpleNamePerPackage\n .get(declaringPackageName)\n ?.get(raw);\n if (sameId) return sameId;\n }\n const bySimple = idBySimpleName.get(raw);\n if (bySimple && bySimple.size === 1) return [...bySimple][0];\n return undefined;\n };\n\n const seenObjectIds = new Set<string>();\n for (const input of sortedInputs) {\n sourceHashes[input.artifactPath] = hashContent(\n stableStringify(input.manifest),\n );\n const packageName = input.manifest.packageName ?? input.artifactPath;\n\n packages.push({\n name: packageName,\n version: input.manifest.packageVersion,\n artifactPath: input.artifactPath,\n tags: [...input.manifest.tags].sort(),\n risks: [...input.manifest.risks].sort(),\n summary: input.manifest.summary,\n objectCount: input.manifest.objects.length,\n });\n\n for (const object of input.manifest.objects) {\n // See the id-map pass above: an aggregated consumer manifest attributes\n // each object to its own scanned package, not the local project.\n const objectPackageName = object.packageName ?? packageName;\n const id = objectId(objectPackageName, object);\n if (!seenObjectIds.has(id)) {\n seenObjectIds.add(id);\n objects.push({\n id,\n packageName: objectPackageName,\n name: object.name,\n qualifiedName: object.qualifiedName,\n collection: object.collection,\n tableName: object.tableName,\n tableStrategy: object.tableStrategy,\n extends: object.extends,\n });\n }\n\n for (const field of object.relationships) {\n if (field.type !== 'crossPackageRef') continue;\n edges.push({\n type: 'crossPackageRef',\n from: id,\n to: resolveTarget(field.related) ?? field.related,\n field: field.name,\n });\n }\n\n if (object.tableStrategy === 'sti' && object.extends) {\n edges.push({\n type: 'sti',\n from: id,\n to:\n resolveTarget(object.extends, objectPackageName) ??\n `${objectPackageName}#${object.extends}`,\n });\n }\n\n for (const feature of object.relationshipFeatures) {\n if (feature === 'SmrtJunction') {\n edges.push({ type: 'junction', from: id });\n } else if (feature === 'SmrtHierarchical') {\n edges.push({ type: 'hierarchical', from: id });\n } else if (feature === 'SmrtPolymorphicAssociation') {\n edges.push({ type: 'polymorphic', from: id });\n }\n }\n\n if (object.tableName?.startsWith('_smrt_')) {\n edges.push({ type: 'systemTable', from: id, to: object.tableName });\n }\n }\n }\n\n packages.sort((a, b) => a.name.localeCompare(b.name));\n objects.sort((a, b) => a.id.localeCompare(b.id));\n edges.sort((a, b) => {\n const key = (edge: KnowledgeGraphEdge) =>\n `${edge.type}|${edge.from}|${edge.to ?? ''}|${edge.field ?? ''}`;\n return key(a).localeCompare(key(b));\n });\n\n const graph: SmrtKnowledgeGraph = {\n schemaVersion: 1,\n generatedAt: new Date().toISOString(),\n sourceHashes: sortRecord(sourceHashes),\n packages,\n objects,\n edges,\n };\n\n const { previousGraph } = options;\n if (\n previousGraph &&\n semanticGraphJson(previousGraph) === semanticGraphJson(graph)\n ) {\n return { ...graph, generatedAt: previousGraph.generatedAt };\n }\n return graph;\n}\n\nfunction semanticGraphJson(graph: SmrtKnowledgeGraph): string {\n const { generatedAt: _generatedAt, ...rest } = graph;\n return stableStringify(rest);\n}\n\n/** Deterministic `JSON.stringify` — object keys are sorted at every level. */\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(sortValue(value));\n}\n\nfunction sortValue(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortValue);\n if (value && typeof value === 'object') {\n // Null-prototype target: on an ordinary `{}`, assigning the key\n // `\"__proto__\"` through bracket notation invokes `Object.prototype`'s\n // `__proto__` accessor instead of creating an own property, so that key\n // silently vanishes from the result and `JSON.stringify()` never emits\n // it — two inputs that differ only by an own `\"__proto__\"` key (which\n // `JSON.parse()` does create as a real own property) then serialize\n // identically. An object with no prototype has no such accessor to\n // shadow the assignment, so every own key — including `\"__proto__\"` —\n // becomes a real own data property. `JSON.stringify()` does not care\n // about an object's prototype, only its own enumerable properties, so\n // this changes no other output.\n const sorted: Record<string, unknown> = Object.create(null);\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n sorted[key] = sortValue((value as Record<string, unknown>)[key]);\n }\n return sorted;\n }\n return value;\n}\n\nfunction sortRecord(record: Record<string, string>): Record<string, string> {\n const sorted: Record<string, string> = {};\n for (const key of Object.keys(record).sort()) sorted[key] = record[key];\n return sorted;\n}\n\nexport interface KnowledgeGraphFreshnessIssue {\n severity: 'error' | 'warning';\n code:\n | 'missing-knowledge-graph'\n | 'stale-knowledge-graph'\n | 'knowledge-graph-source-missing';\n message: string;\n file?: string;\n}\n\n/**\n * Checks the merged graph's recorded `sourceHashes` against the current\n * content of each per-package artifact it was built from — the same pattern\n * `knowledge.ts`/`smrt-dev-mcp` use for a single package's `sourceHashes`.\n *\n * `graphPath` and each `artifactPath` in the graph are resolved relative to\n * `rootDir` (the repo root).\n */\nexport function checkKnowledgeGraphFreshness(\n rootDir: string,\n graphPath: string,\n options: { requireArtifact?: boolean } = {},\n): KnowledgeGraphFreshnessIssue[] {\n const issues: KnowledgeGraphFreshnessIssue[] = [];\n const absoluteGraphPath = `${rootDir}/${graphPath}`;\n if (!existsSync(absoluteGraphPath)) {\n if (!options.requireArtifact) return issues;\n issues.push({\n severity: 'error',\n code: 'missing-knowledge-graph',\n message: `${graphPath} does not exist; run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n return issues;\n }\n\n let graph: SmrtKnowledgeGraph;\n try {\n graph = JSON.parse(readFileSync(absoluteGraphPath, 'utf8'));\n } catch (error) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${graphPath} is not valid JSON: ${\n error instanceof Error ? error.message : String(error)\n }`,\n file: graphPath,\n });\n return issues;\n }\n\n const recordedPaths = Object.keys(graph.sourceHashes ?? {});\n for (const [artifactPath, expectedHash] of Object.entries(\n graph.sourceHashes ?? {},\n )) {\n const absoluteArtifactPath = `${rootDir}/${artifactPath}`;\n if (!existsSync(absoluteArtifactPath)) {\n issues.push({\n severity: 'error',\n code: 'knowledge-graph-source-missing',\n message: `${artifactPath} used to build ${graphPath} no longer exists`,\n file: graphPath,\n });\n continue;\n }\n let manifest: unknown;\n try {\n manifest = JSON.parse(readFileSync(absoluteArtifactPath, 'utf8'));\n } catch (error) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${artifactPath} is not valid JSON (${\n error instanceof Error ? error.message : String(error)\n }); run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n continue;\n }\n const actualHash = hashContent(stableStringify(manifest));\n if (actualHash !== expectedHash) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${artifactPath} changed since ${graphPath} was generated; run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n }\n }\n\n // A per-key hash comparison alone cannot see an ADDED artifact: a package\n // that just finished its first build, or just started exporting\n // `./smrt-knowledge.json`, contributes a path the graph never recorded, so\n // every recorded hash still matches. Compare the current discoverable SET\n // against the recorded set to catch that (#2863 review).\n const currentPaths = discoverKnowledgeArtifactPaths(rootDir);\n const recordedSet = new Set(recordedPaths);\n const newPaths = currentPaths.filter((path) => !recordedSet.has(path));\n if (newPaths.length > 0) {\n issues.push({\n severity: 'error',\n code: 'stale-knowledge-graph',\n message: `${newPaths.join(', ')} ${\n newPaths.length === 1\n ? 'is a new package artifact'\n : 'are new package artifacts'\n } not yet merged into ${graphPath}; run \\`pnpm knowledge:graph\\``,\n file: graphPath,\n });\n }\n\n return issues;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,+BAA+B,SAA2B;CACxE,MAAM,cAAc,KAAK,SAAS,UAAU;CAC5C,IAAI,CAAC,WAAW,WAAW,GAAG,OAAO,CAAC;CACtC,MAAM,QAAkB,CAAC;CACzB,KAA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