@happyvertical/smrt-core 0.51.31 → 0.51.33

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 (187) 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/browser.d.ts +1 -0
  12. package/dist/browser.d.ts.map +1 -1
  13. package/dist/browser.js +2 -1
  14. package/dist/cascade.d.ts +69 -3
  15. package/dist/change-feed-authz.d.ts +85 -2
  16. package/dist/change-feed.d.ts +133 -2
  17. package/dist/change-signals.d.ts +66 -1
  18. package/dist/child-accessors.d.ts +39 -1
  19. package/dist/class.d.ts +17 -8
  20. package/dist/class.d.ts.map +1 -1
  21. package/dist/class.js +22 -0
  22. package/dist/class.js.map +1 -1
  23. package/dist/collection-cache.d.ts +47 -1
  24. package/dist/collection-read-plan.d.ts +3 -3
  25. package/dist/collection.d.ts +4 -3
  26. package/dist/config.d.ts +15 -6
  27. package/dist/consumer-plugin/index.d.ts +7 -3
  28. package/dist/consumer-plugin/index.d.ts.map +1 -1
  29. package/dist/consumer-plugin/index.js +2 -0
  30. package/dist/consumer-plugin/index.js.map +1 -1
  31. package/dist/data-query.d.ts +12 -1
  32. package/dist/database.d.ts +10 -2
  33. package/dist/decisions.d.ts +24 -2
  34. package/dist/decisions.d.ts.map +1 -1
  35. package/dist/decisions.js +71 -1
  36. package/dist/decisions.js.map +1 -1
  37. package/dist/decorators/index.d.ts +11 -5
  38. package/dist/dispatch/bus.d.ts +27 -2
  39. package/dist/dispatch/collections/DispatchSubscriptions.d.ts +7 -2
  40. package/dist/dispatch/collections/Dispatches.d.ts +8 -3
  41. package/dist/dispatch/models/Dispatch.d.ts +7 -1
  42. package/dist/dispatch/types.d.ts +7 -2
  43. package/dist/embedded-write-queue.d.ts +1 -1
  44. package/dist/embeddings/provider.d.ts +8 -1
  45. package/dist/embeddings/storage.d.ts +8 -2
  46. package/dist/filesystem-loader.d.ts +16 -1
  47. package/dist/generators/changes-route.d.ts +34 -1
  48. package/dist/generators/custom-action.d.ts +10 -2
  49. package/dist/generators/events-route.d.ts +41 -4
  50. package/dist/generators/mcp-runtime-template.d.ts +13 -2
  51. package/dist/generators/mcp.d.ts +6 -1
  52. package/dist/generators/rest.d.ts +10 -5
  53. package/dist/generators/tool-schema.d.ts +1 -1
  54. package/dist/hierarchical.d.ts +37 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -1
  58. package/dist/interceptors.d.ts +45 -1
  59. package/dist/junction.d.ts +24 -0
  60. package/dist/knowledge-config.d.ts +1 -1
  61. package/dist/knowledge-discovery.d.ts +2 -25
  62. package/dist/knowledge-discovery.d.ts.map +1 -1
  63. package/dist/knowledge-discovery.js +1 -53
  64. package/dist/knowledge-graph.d.ts +2 -94
  65. package/dist/knowledge-graph.d.ts.map +1 -1
  66. package/dist/knowledge-graph.js +1 -267
  67. package/dist/knowledge.d.ts +4 -23
  68. package/dist/knowledge.d.ts.map +1 -1
  69. package/dist/knowledge.js +3 -52
  70. package/dist/knowledge.js.map +1 -1
  71. package/dist/learning/memory.d.ts +21 -1
  72. package/dist/manifest/generator.d.ts +5 -1
  73. package/dist/manifest/index.d.ts +5 -1
  74. package/dist/manifest/manager.d.ts +1 -1
  75. package/dist/manifest/manifest-loader.d.ts +24 -2
  76. package/dist/manifest/sources/composite.d.ts +17 -1
  77. package/dist/manifest/sources/embedded.d.ts +10 -1
  78. package/dist/manifest/sources/explicit-paths.d.ts +13 -1
  79. package/dist/manifest/sources/fallback.d.ts +15 -1
  80. package/dist/manifest/sources/local-test.d.ts +10 -1
  81. package/dist/manifest/sources/static.d.ts +12 -1
  82. package/dist/manifest/sources/test.d.ts +9 -1
  83. package/dist/manifest/sources/types.d.ts +7 -1
  84. package/dist/manifest/static-manifest.d.ts +6 -1
  85. package/dist/manifest/static-manifest.js +1 -1
  86. package/dist/manifest/static-manifest.js.map +1 -1
  87. package/dist/manifest/store.d.ts +22 -3
  88. package/dist/manifest/store.js +1 -1
  89. package/dist/manifest.json +1 -1
  90. package/dist/migrations/backfill-tracker.d.ts +15 -1
  91. package/dist/migrations/differ.d.ts +8 -2
  92. package/dist/migrations/framework-base-tables.d.ts +57 -2
  93. package/dist/migrations/generator.d.ts +8 -2
  94. package/dist/migrations/integer-width.d.ts +10 -2
  95. package/dist/migrations/minor-units.d.ts +40 -1
  96. package/dist/migrations/null-equal-indexes.d.ts +3 -2
  97. package/dist/migrations/orchestrate.d.ts +15 -3
  98. package/dist/migrations/sqlite-rebuild.d.ts +67 -2
  99. package/dist/migrations/tracker.d.ts +9 -3
  100. package/dist/migrations/types.d.ts +7 -2
  101. package/dist/object.d.ts +7 -6
  102. package/dist/object.d.ts.map +1 -1
  103. package/dist/object.js +6 -17
  104. package/dist/object.js.map +1 -1
  105. package/dist/polymorphic-association.d.ts +44 -1
  106. package/dist/postgres-permissions.d.ts +1 -1
  107. package/dist/prebuild/index.d.ts +5 -1
  108. package/dist/query-bounds.d.ts +26 -0
  109. package/dist/registry/cache-config.d.ts +10 -1
  110. package/dist/registry/class-registration.d.ts +10 -2
  111. package/dist/registry/collection-resolution.d.ts +1 -1
  112. package/dist/registry/embedding-manager.d.ts +9 -1
  113. package/dist/registry/inheritance-resolver.d.ts +8 -3
  114. package/dist/registry/manifest-field-merge.d.ts +2 -2
  115. package/dist/registry/name-resolver.d.ts +22 -2
  116. package/dist/registry/relationship-graph.d.ts +9 -1
  117. package/dist/registry/schema-builder.d.ts +8 -3
  118. package/dist/registry/shared-state.d.ts +12 -2
  119. package/dist/registry/types.d.ts +15 -7
  120. package/dist/registry/validator.d.ts +10 -2
  121. package/dist/registry.d.ts +40 -11
  122. package/dist/relationship-loader.d.ts +1 -1
  123. package/dist/run-once.d.ts +110 -1
  124. package/dist/runtime/client.d.ts +4 -1
  125. package/dist/runtime/server.d.ts +5 -2
  126. package/dist/scanner/import-scanner.d.ts +1 -1
  127. package/dist/scanner/manifest-generator.d.ts +4 -1
  128. package/dist/scanner/types.d.ts +4 -1
  129. package/dist/schema/code-generator.d.ts +6 -2
  130. package/dist/schema/column-data-probes.d.ts +27 -2
  131. package/dist/schema/ddl/base-strategy.d.ts +8 -2
  132. package/dist/schema/ddl/duckdb-strategy.d.ts +14 -2
  133. package/dist/schema/ddl/index.d.ts +2 -2
  134. package/dist/schema/ddl/json-duckdb-strategy.d.ts +10 -2
  135. package/dist/schema/ddl/materialize-manifest.d.ts +1 -1
  136. package/dist/schema/ddl/null-equal-index.d.ts +1 -1
  137. package/dist/schema/ddl/postgres-strategy.d.ts +12 -2
  138. package/dist/schema/ddl/sqlite-strategy.d.ts +12 -2
  139. package/dist/schema/ddl/types.d.ts +10 -1
  140. package/dist/schema/foreign-key-ddl.d.ts +2 -2
  141. package/dist/schema/foreign-key-orphan-report.d.ts +25 -3
  142. package/dist/schema/foreign-key-planner.d.ts +2 -2
  143. package/dist/schema/foreign-key-policy.d.ts +1 -1
  144. package/dist/schema/generator.d.ts +7 -3
  145. package/dist/schema/index-utils.d.ts +11 -2
  146. package/dist/schema/live-parity.d.ts +27 -3
  147. package/dist/schema/manifest-schema.d.ts +21 -2
  148. package/dist/schema/schema-aggregator.d.ts +35 -2
  149. package/dist/schema/schema-manager.d.ts +13 -4
  150. package/dist/schema/system-table-shapes.d.ts +20 -1
  151. package/dist/schema/table-verifier.d.ts +1 -1
  152. package/dist/schema/text-cast-probe.d.ts +24 -1
  153. package/dist/schema/utils.d.ts +13 -4
  154. package/dist/schema/uuid-convergence.d.ts +32 -1
  155. package/dist/signals/bus.d.ts +8 -2
  156. package/dist/signals/sanitizer.d.ts +7 -1
  157. package/dist/smrt-knowledge.json +8 -9
  158. package/dist/system/bootstrap.d.ts +2 -1
  159. package/dist/system/compatibility.d.ts +1 -1
  160. package/dist/system/diagnostics.d.ts +17 -2
  161. package/dist/system/retention.d.ts +46 -1
  162. package/dist/system/schema.d.ts +7 -1
  163. package/dist/system-fields.d.ts +9 -1
  164. package/dist/test-utils.d.ts +7 -1
  165. package/dist/testing/database.d.ts +18 -1
  166. package/dist/testing/notifications-stub.d.ts +15 -1
  167. package/dist/tools/tool-executor.d.ts +6 -1
  168. package/dist/tools/tool-generator.d.ts +8 -2
  169. package/dist/utils/json.d.ts +9 -1
  170. package/dist/utils/qualified-names.d.ts +10 -1
  171. package/dist/utils/scanner-module.d.ts +2 -2
  172. package/dist/utils.d.ts +1 -1
  173. package/dist/vite-plugin/api-client-entries.d.ts +9 -1
  174. package/dist/vite-plugin/changes-route.d.ts +33 -2
  175. package/dist/vite-plugin/dev-plane-route.d.ts +12 -1
  176. package/dist/vite-plugin/events-route.d.ts +37 -2
  177. package/dist/vite-plugin/generated-client.d.ts +9 -1
  178. package/dist/vite-plugin/index.d.ts +9 -5
  179. package/dist/vite-plugin/resources-route.d.ts +82 -1
  180. package/dist/vite-plugin/sveltekit-generator.d.ts +8 -4
  181. package/dist/vite-plugin/sveltekit-route-coordinator.d.ts +3 -3
  182. package/dist/vite-plugin/sync-apply-route.d.ts +19 -2
  183. package/dist/vite-plugin/web-collections.d.ts +25 -2
  184. package/dist/vite-plugin/worker-registration.d.ts +21 -1
  185. package/package.json +7 -8
  186. package/dist/knowledge-discovery.js.map +0 -1
  187. package/dist/knowledge-graph.js.map +0 -1
@@ -1,4 +1,49 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
1
+ /**
2
+ * System-table retention — bounded growth for framework-owned tables (#2375).
3
+ *
4
+ * Several `_smrt_*` tables are append-only by construction and were, until
5
+ * this module, unbounded by default: `_smrt_changes` grew one row per
6
+ * framework save/delete, `_smrt_ai_usage` one row per AI call (persistence is
7
+ * on by default, see `config.ts`), `_smrt_contexts` accumulated rows whose
8
+ * `expires_at` nothing ever enforced, `_smrt_dispatch` retained completed
9
+ * work until an operator remembered to run `smrt dispatch:cleanup`, and
10
+ * `_smrt_run_once_claims` (#3080) gains one row per `runOnce()` submission
11
+ * with nothing pruning completed ones.
12
+ *
13
+ * This module supplies the missing half:
14
+ *
15
+ * - {@link pruneAiUsage} — the retention API `_smrt_ai_usage` never had.
16
+ * - {@link pruneExpiredContexts} — enforcement for `_smrt_contexts.expires_at`.
17
+ * - {@link runRetentionSweep} — one entry point that applies a documented,
18
+ * opt-out {@link RetentionPolicy} across every framework-owned table, plus
19
+ * any task other packages contribute via {@link registerRetentionTask}
20
+ * (`@happyvertical/smrt-jobs` registers job/job-event cleanup;
21
+ * `@happyvertical/smrt-users` registers session and token expiry).
22
+ *
23
+ * Scheduling is the caller's: `smrt db:prune` is the cron entry point, and a
24
+ * running `TaskRunner` sweeps on an interval unless configured otherwise.
25
+ *
26
+ * ## Failure policy
27
+ *
28
+ * A sweep is maintenance, not a transaction. One failing task never aborts the
29
+ * rest — the failure is captured on that task's {@link RetentionTaskResult}
30
+ * and the sweep continues. Callers decide what a partial sweep means; the CLI
31
+ * exits non-zero when any task failed.
32
+ *
33
+ * ## Predicate indexes
34
+ *
35
+ * Every predicate below is indexed by the system DDL in `system/schema.ts`
36
+ * (`_smrt_contexts(expires_at)`, `_smrt_ai_usage(tenant_id, created_at)`,
37
+ * `_smrt_dispatch(status, processed_at)` / `(status, updated_at)`,
38
+ * `_smrt_run_once_claims(status, completed_at)`) or by the jobs compatibility
39
+ * path in `system/compatibility.ts` (`_smrt_jobs(status, completed_at)`,
40
+ * `_smrt_job_events(created_at)`). A new retention predicate must ship with
41
+ * its index.
42
+ *
43
+ * @see https://github.com/happyvertical/smrt/issues/2375
44
+ * @packageDocumentation
45
+ */
46
+ import type { DatabaseInterface } from '@happyvertical/sql';
2
47
  /** Retention for the append-only change feed (`_smrt_changes`). */
3
48
  export interface ChangeFeedRetentionPolicy {
4
49
  /** Run this task (default `true`). */
@@ -1,4 +1,10 @@
1
- import { DatabaseEngine } from '../schema/ddl/types.js';
1
+ /**
2
+ * SMRT System Tables Schema
3
+ *
4
+ * System tables use _smrt_ prefix to avoid conflicts with user tables.
5
+ * All system tables are created in the same database as user data.
6
+ */
7
+ import type { DatabaseEngine } from '../schema/ddl/types.js';
2
8
  /**
3
9
  * Context memory storage
4
10
  * Stores remembered context (learned strategies, patterns, selectors) for reuse
@@ -1,4 +1,12 @@
1
- import { FieldDefinition } from './scanner/types.js';
1
+ /**
2
+ * Canonical SMRT system fields inherited from `SmrtObject`.
3
+ *
4
+ * These fields exist on every persistent object at runtime even when they are
5
+ * not declared in a child class manifest. Keep this definition lightweight:
6
+ * presence matters for metadata consumers, while schema generation still owns
7
+ * the exact SQL defaults and constraints for these columns.
8
+ */
9
+ import type { FieldDefinition } from './scanner/types.js';
2
10
  export declare const SMRT_SYSTEM_FIELDS: Readonly<Record<string, FieldDefinition>>;
3
11
  export declare function isInjectedSmrtSystemField(field: unknown): boolean;
4
12
  export declare function cloneSmrtSystemFields(): Record<string, FieldDefinition>;
@@ -1,4 +1,10 @@
1
- import { Mock } from 'vitest';
1
+ /**
2
+ * Comprehensive test utilities for SMRT framework testing
3
+ *
4
+ * Provides unified mocking for collections, objects, and database operations
5
+ * to support both CLI and API generator testing scenarios.
6
+ */
7
+ import { type Mock } from 'vitest';
2
8
  /**
3
9
  * Snapshot ObjectRegistry state and return a restore function for manifest-heavy
4
10
  * tests that mutate registry internals at runtime.
@@ -1,4 +1,21 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
1
+ /**
2
+ * Test database utilities for SMRT framework
3
+ *
4
+ * Provides `getTestDatabase()` which creates an in-memory database with all
5
+ * registered SMRT object schemas. Uses the same schema generation logic as
6
+ * the migration system to ensure consistency between test and production.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { getTestDatabase } from '@happyvertical/smrt-core/testing';
11
+ *
12
+ * beforeEach(async () => {
13
+ * const db = await getTestDatabase();
14
+ * collection = await MyCollection.create({ db });
15
+ * });
16
+ * ```
17
+ */
18
+ import type { DatabaseInterface } from '@happyvertical/sql';
2
19
  /**
3
20
  * Options for creating a test database
4
21
  */
@@ -1,4 +1,18 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
1
+ /**
2
+ * In-process test double for the sql package's optional notification
3
+ * capability (`db.notifications`, e.g. Postgres LISTEN/NOTIFY).
4
+ *
5
+ * Attaches a push-driven `notify`/`listen` pair to a database handle so tests
6
+ * can exercise the cross-process / cross-replica paths of the collection cache
7
+ * (#1498) and the change-signal bus (#1763) against a real in-memory SQLite
8
+ * database that has no native notification support. `notify` records every
9
+ * broadcast; `listen` exposes an async iterable that yields whatever `push`
10
+ * delivers.
11
+ *
12
+ * Extracted from `__tests__/issue-1498-collection-cache.test.ts` so the same
13
+ * double backs the change-signal bus tests without duplicating the stub.
14
+ */
15
+ import type { DatabaseInterface } from '@happyvertical/sql';
2
16
  /** One notification as delivered over the stubbed channel. */
3
17
  export interface StubNotification {
4
18
  channel: string;
@@ -1,4 +1,9 @@
1
- import { SignalBus } from '../signals/bus.js';
1
+ /**
2
+ * Tool Call Execution for AI Function Calling
3
+ *
4
+ * This module handles runtime execution of AI tool calls on SMRT object instances.
5
+ */
6
+ import type { SignalBus } from '../signals/bus.js';
2
7
  /**
3
8
  * A dynamically-dispatched tool target (typically a SmrtObject instance, but
4
9
  * typed structurally so any object whose method names are resolved at runtime
@@ -1,5 +1,11 @@
1
- import { AITool } from '@happyvertical/ai';
2
- import { MethodDefinition } from '../scanner/types.js';
1
+ /**
2
+ * Tool Manifest Generation for AI Function Calling
3
+ *
4
+ * This module converts TypeScript method definitions from the AST scanner
5
+ * into AI tool format at build time for use with LLM function calling.
6
+ */
7
+ import type { AITool } from '@happyvertical/ai';
8
+ import type { MethodDefinition } from '../scanner/types.js';
3
9
  /**
4
10
  * A JSON Schema fragment. The shape is open-ended (different keywords appear
5
11
  * for primitives, arrays, unions, etc.), so values are `unknown`; callers
@@ -1,4 +1,12 @@
1
- import { JSONAdapter, ParseError, Result, StringifyError } from '@happyvertical/json';
1
+ /**
2
+ * JSON utilities with optional SIMD acceleration
3
+ *
4
+ * Uses @happyvertical/json for faster parsing when available,
5
+ * with automatic fallback to native JSON.
6
+ *
7
+ * Performance: 2-3x faster parsing on large JSON files (680KB manifests)
8
+ */
9
+ import { type JSONAdapter, type ParseError, type Result, type StringifyError } from '@happyvertical/json';
2
10
  /**
3
11
  * Parse JSON string with optional SIMD acceleration
4
12
  *
@@ -1,4 +1,13 @@
1
- import { QualifiedClassName } from '../scanner/types.js';
1
+ /**
2
+ * Utilities for working with qualified class names in the SMRT framework.
3
+ *
4
+ * Qualified names follow the format: "@package/name:ClassName"
5
+ * Example: "@happyvertical/smrt-core:Product"
6
+ *
7
+ * This format uniquely identifies classes across packages, eliminating
8
+ * name collisions when multiple packages define classes with the same name.
9
+ */
10
+ import type { QualifiedClassName } from '../scanner/types.js';
2
11
  /**
3
12
  * Creates a qualified class name from package name and class name.
4
13
  *
@@ -1,5 +1,5 @@
1
- import { CapabilityClassification, DomainKnowledgePlaybookStep } from '@happyvertical/smrt-types';
2
- import { SmartObjectManifest } from '../scanner/types.js';
1
+ import type { CapabilityClassification, DomainKnowledgePlaybookStep } from '@happyvertical/smrt-types';
2
+ import type { SmartObjectManifest } from '../scanner/types.js';
3
3
  /**
4
4
  * The scanner's declared agent surface (#2591), mirrored structurally like the
5
5
  * rest of this module.
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SmrtObject } from './object';
1
+ import type { SmrtObject } from './object';
2
2
  import { classnameToTablename, pluralize, toSnakeCase } from './utils/naming.js';
3
3
  import { toSafeBooleanInteger, toSafeInteger } from './utils/safe-integer.js';
4
4
  export { classnameToTablename, pluralize, toSafeBooleanInteger, toSafeInteger, toSnakeCase, };
@@ -1,4 +1,12 @@
1
- import { SmartObjectDefinition, SmartObjectManifest } from '../scanner/types.js';
1
+ /**
2
+ * Manifest -> generated API-client entry selection.
3
+ *
4
+ * Runtime client values, Vite ambient declarations, and physical prebuild
5
+ * declarations must agree on which manifest object owns a collection's
6
+ * canonical endpoint. Collection classes describe access methods, not row
7
+ * payloads, so a populated model always wins the shared collection key.
8
+ */
9
+ import type { SmartObjectDefinition, SmartObjectManifest } from '../scanner/types.js';
2
10
  export type ApiClientCrudMethod = 'list' | 'get' | 'create' | 'update' | 'delete' | 'search';
3
11
  export interface ApiClientEntry {
4
12
  /** Original key in manifest.objects. */
@@ -1,5 +1,36 @@
1
- import { SmartObjectManifest } from '../scanner/types';
2
- import { SvelteKitOptions } from './sveltekit-generator.js';
1
+ /**
2
+ * SvelteKit `_changes` route generation for the change feed (issue #1758).
3
+ *
4
+ * Emits `{routesDir}/_changes/+server.ts` — an auth-guarded, tenant-scoped
5
+ * GET endpoint over the `_smrt_changes` log, part of the client/mobile sync
6
+ * contract (PRD #1755). Kept in its own module so `sveltekit-generator.ts`
7
+ * only carries a one-line registration.
8
+ *
9
+ * Design notes:
10
+ * - **Fail-closed auth** (#1540 posture): the handler requires an
11
+ * authenticated principal on `locals`. The feed spans every table, so
12
+ * per-model `api: { public }` opt-outs deliberately do not apply.
13
+ * - **Tenant scoping**: when the project has tenant-scoped objects, the
14
+ * route establishes tenant context from `locals` exactly like generated
15
+ * collection routes, then reads through
16
+ * `getAuthorizedTenantScopedChangesSince()` — a tenant only ever sees its
17
+ * own changes plus global rows.
18
+ * - **Table/row authorization** (#3020): the same call additionally applies
19
+ * the consumer-supplied `authorizeChangeFeed`/`isChangeFeedEntryVisible`
20
+ * hooks (`@happyvertical/smrt-core`'s `change-feed-authz.ts`), if
21
+ * registered — a table-level and row-level seam beyond tenant scope (e.g. a
22
+ * station principal reading only its own rows of a table the office can
23
+ * read in full). Unregistered, behavior is unchanged from pre-#3020.
24
+ * - **Database resolution**: the route anchors on the project's first
25
+ * generated collection (alphabetical) via the consumer's existing
26
+ * `getCollection()` helper, inheriting its configuration, request-scoped
27
+ * database support and system-table bootstrap. Multi-database projects
28
+ * (per-object `db` overrides) see the anchor collection's feed.
29
+ * - Cleanup rides the existing generated-route sweep: the emitted file
30
+ * starts with {@link AUTO_GENERATED_ROUTE_HEADER}.
31
+ */
32
+ import type { SmartObjectManifest } from '../scanner/types';
33
+ import type { SvelteKitOptions } from './sveltekit-generator.js';
3
34
  /**
4
35
  * Pick the class the route resolves its database through: the first
5
36
  * non-collection object by sorted manifest key, for determinism across
@@ -1,4 +1,15 @@
1
- import { SvelteKitOptions } from './sveltekit-generator.js';
1
+ /**
2
+ * Generated `_dev/[...tool]/+server.ts` route: the in-app runtime dev-plane
3
+ * (#2782). Opt-in via `svelteKit: { devPlaneRoute: { enabled: true } }`.
4
+ *
5
+ * The route is dev-only twice over: it 404s unless SvelteKit's `dev` flag is
6
+ * set, and it refuses to start without `SMRT_DEV_MCP_TOKEN`. Everything else
7
+ * — loopback checks, bearer auth, the positive read-only catalog, the MCP
8
+ * endpoint — lives in `@happyvertical/smrt-dev-mcp/dev-plane`, which the
9
+ * generated file imports at consumer runtime. Like `_resources`, the route is
10
+ * only emitted when that subpath resolves from the consumer.
11
+ */
12
+ import type { SvelteKitOptions } from './sveltekit-generator.js';
2
13
  /** Whether `@happyvertical/smrt-dev-mcp/dev-plane` resolves from the consumer. */
3
14
  export declare function consumerHasSmrtDevMcp(projectRoot: string): boolean;
4
15
  /** Whether this invocation will own the `_dev/[...tool]` output file. */
@@ -1,5 +1,40 @@
1
- import { SmartObjectManifest } from '../scanner/types';
2
- import { SvelteKitOptions } from './sveltekit-generator.js';
1
+ /**
2
+ * SvelteKit `_events` route generation — live change signals (issue #1763,
3
+ * SERVER half; parent PRD #1755).
4
+ *
5
+ * Emits `{routesDir}/_events/+server.ts` — an auth-guarded, tenant-scoped
6
+ * Server-Sent-Events endpoint that streams coarse change signals (no row
7
+ * payloads). It is the push companion to the generated `_changes` route
8
+ * (#1758). Kept in its own module so `sveltekit-generator.ts` only carries a
9
+ * one-line registration.
10
+ *
11
+ * The stream lifecycle (subscribe, catch-up, heartbeat, teardown) lives in
12
+ * core's `buildChangeEventStream`, imported by the generated file — so the
13
+ * emitted route stays THIN and the stream logic is written and tested once.
14
+ *
15
+ * Design notes (mirror `changes-route.ts`):
16
+ * - **Fail-closed auth** (#1540 posture): the handler requires an authenticated
17
+ * principal on `locals`. The signal stream spans every table, so per-model
18
+ * `api: { public }` opt-outs deliberately do not apply.
19
+ * - **Tenant scoping**: when the project has tenant-scoped objects, the route
20
+ * establishes tenant context from `locals` exactly like the `_changes` route,
21
+ * then captures the resolved scope ONCE at connection open and passes it to
22
+ * the stream (delivery filters against that fixed value — it cannot
23
+ * re-resolve per signal outside the request's ALS context).
24
+ * - **Table/row authorization** (#3020): `locals` is forwarded to
25
+ * `buildChangeEventStream`, which — if the consumer registered
26
+ * `authorizeChangeFeed`/`isChangeFeedEntryVisible`
27
+ * (`@happyvertical/smrt-core`'s `change-feed-authz.ts`) — resolves the
28
+ * allowed tables ONCE at connection open (same reasoning as tenant scope)
29
+ * and applies both hooks to catch-up replay AND every live signal before it
30
+ * is enqueued. Unregistered, behavior is unchanged from pre-#3020.
31
+ * - **Database resolution**: anchors on the project's first generated
32
+ * collection (alphabetical) via `getCollection()`, exactly as `_changes`.
33
+ * - Cleanup rides the generated-route sweep: the file starts with
34
+ * {@link AUTO_GENERATED_ROUTE_HEADER}.
35
+ */
36
+ import type { SmartObjectManifest } from '../scanner/types';
37
+ import type { SvelteKitOptions } from './sveltekit-generator.js';
3
38
  /**
4
39
  * Generate the `_events/+server.ts` route. Returns true when a route was
5
40
  * written. Disabled with `sveltekit: { eventsRoute: { enabled: false } }`;
@@ -1,4 +1,12 @@
1
- import { SmartObjectManifest } from '../scanner/types.js';
1
+ /**
2
+ * Shared runtime generator for producer and consumer `@smrt/client` modules.
3
+ *
4
+ * Keep runtime values on the same manifest-derived contract as physical and
5
+ * virtual declarations. In particular, disabled objects, partial CRUD
6
+ * allowlists, stable collection keys, and custom route signatures must not
7
+ * diverge between the two plugin entry points.
8
+ */
9
+ import type { SmartObjectManifest } from '../scanner/types.js';
2
10
  export declare const GENERATED_CLIENT_CRUD_METHODS: Set<string>;
3
11
  export declare const GENERATED_CLIENT_BASE_METHODS: Set<string>;
4
12
  export declare function generateClientModule(manifest: SmartObjectManifest, options?: {
@@ -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.31",
3
+ "version": "0.51.33",
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.31",
158
- "@happyvertical/smrt-scanner": "0.51.31",
159
- "@happyvertical/smrt-types": "0.51.31",
157
+ "@happyvertical/smrt-config": "0.51.33",
158
+ "@happyvertical/smrt-scanner": "0.51.33",
159
+ "@happyvertical/smrt-types": "0.51.33",
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"}