@happyvertical/smrt-core 0.51.33 → 0.51.35

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.
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-core",
6
- "packageVersion": "0.51.33",
6
+ "packageVersion": "0.51.35",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "0e598c41a70d94e0f311ca2c6c717499d7d360bfde2a10c982e722bd8cc6e928",
11
- "packageJson": "624a187e41615d1b71afb40c725502618367487547cf4fe00127265c02c2c2cc",
10
+ "manifest": "6be0fd61ff5fc92bf9d39e9213fce85c46106c59c8efdc7c9a4ce3fdd35ce185",
11
+ "packageJson": "a0d622f309739c5d88315db5d638d15383b2a37ddbcc20a7adb2e2141668d93d",
12
12
  "agents": "79356014d92fdf656f648e5c765374913104445a5542243f4819ef362c77a8e5",
13
13
  "moduleDoc:agents/object-runtime.md": "34a4e740c109467cd5486c4af0e3bf4b63915697721ab584df0e5506ea9290ca",
14
14
  "moduleDoc:agents/revision-guard.md": "aa6b1ddb5b6b49fa27ebbe575ec7fcd6d5ceb35ee25acc702f877a226eb9a99a",
@@ -71,7 +71,6 @@
71
71
  "oxc-transform": "0.150.0",
72
72
  "pluralize": "^8.0.0",
73
73
  "tsx": "^4.23.13",
74
- "vite": "8.1.4",
75
74
  "yaml": "^2.9.1",
76
75
  "@faker-js/faker": "^10.6.0",
77
76
  "@huggingface/transformers": ">=3.0.0 <5.0.0",
@@ -83,6 +82,7 @@
83
82
  "svelte": "^5.57.1",
84
83
  "svelte-check": "^4.7.6",
85
84
  "typescript": "6.0.3",
85
+ "vite": "8.1.4",
86
86
  "vitest": "4.1.10"
87
87
  },
88
88
  "smrtDependencies": [
@@ -0,0 +1,15 @@
1
+ type ViteModule = typeof import('vite');
2
+ /**
3
+ * Imports the Vite installed in the application at `projectRoot` (absolute,
4
+ * or relative to the current working directory).
5
+ *
6
+ * smrt-core does not depend on Vite at runtime (happyvertical/smrt#3181): a
7
+ * `vite` dependency makes pnpm resolve smrt-core once per peer set of Vite's
8
+ * optional peers, which duplicates the object registries. The Vite-only code
9
+ * paths (plugin worker registration, loading `vite.config.ts`) therefore
10
+ * resolve Vite from the application, which must have it installed, instead of
11
+ * from smrt-core's own location.
12
+ */
13
+ export declare function importProjectVite(projectRoot: string, purpose: string): Promise<ViteModule>;
14
+ export {};
15
+ //# sourceMappingURL=import-project-vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-project-vite.d.ts","sourceRoot":"","sources":["../../src/utils/import-project-vite.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,cAAc,MAAM,CAAC,CAAC;AAcxC;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC,CAkCrB"}
@@ -0,0 +1,46 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ //#region src/utils/import-project-vite.ts
6
+ /** Picks the ESM entry of a package `exports["."]` target (string or conditions). */
7
+ function esmEntry(target) {
8
+ if (typeof target === "string") return target;
9
+ if (!target || typeof target !== "object") return null;
10
+ for (const condition of [
11
+ "node",
12
+ "import",
13
+ "default"
14
+ ]) {
15
+ const entry = esmEntry(target[condition]);
16
+ if (entry) return entry;
17
+ }
18
+ return null;
19
+ }
20
+ /**
21
+ * Imports the Vite installed in the application at `projectRoot` (absolute,
22
+ * or relative to the current working directory).
23
+ *
24
+ * smrt-core does not depend on Vite at runtime (happyvertical/smrt#3181): a
25
+ * `vite` dependency makes pnpm resolve smrt-core once per peer set of Vite's
26
+ * optional peers, which duplicates the object registries. The Vite-only code
27
+ * paths (plugin worker registration, loading `vite.config.ts`) therefore
28
+ * resolve Vite from the application, which must have it installed, instead of
29
+ * from smrt-core's own location.
30
+ */
31
+ async function importProjectVite(projectRoot, purpose) {
32
+ const manifestPath = (createRequire(resolve(projectRoot, "package.json")).resolve.paths("vite") ?? []).map((dir) => join(dir, "vite", "package.json")).find((candidate) => existsSync(candidate));
33
+ if (!manifestPath) throw new Error(`[smrt] ${purpose} needs Vite, but 'vite' is not installed in ${projectRoot}. Add vite to the application's devDependencies.`);
34
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
35
+ const exportsField = manifest.exports;
36
+ const entry = esmEntry(exportsField && typeof exportsField === "object" && "." in exportsField ? exportsField["."] : exportsField) ?? manifest.module ?? manifest.main;
37
+ if (!entry) throw new Error(`[smrt] ${purpose}: cannot find the entry point of vite at ${dirname(manifestPath)}.`);
38
+ return await import(
39
+ /* @vite-ignore */
40
+ pathToFileURL(resolve(dirname(manifestPath), entry)).href
41
+ );
42
+ }
43
+ //#endregion
44
+ export { importProjectVite };
45
+
46
+ //# sourceMappingURL=import-project-vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-project-vite.js","names":[],"sources":["../../src/utils/import-project-vite.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\ntype ViteModule = typeof import('vite');\ntype ExportTarget = string | { [condition: string]: ExportTarget } | null;\n\n/** Picks the ESM entry of a package `exports[\".\"]` target (string or conditions). */\nfunction esmEntry(target: ExportTarget | undefined): string | null {\n if (typeof target === 'string') return target;\n if (!target || typeof target !== 'object') return null;\n for (const condition of ['node', 'import', 'default']) {\n const entry = esmEntry(target[condition]);\n if (entry) return entry;\n }\n return null;\n}\n\n/**\n * Imports the Vite installed in the application at `projectRoot` (absolute,\n * or relative to the current working directory).\n *\n * smrt-core does not depend on Vite at runtime (happyvertical/smrt#3181): a\n * `vite` dependency makes pnpm resolve smrt-core once per peer set of Vite's\n * optional peers, which duplicates the object registries. The Vite-only code\n * paths (plugin worker registration, loading `vite.config.ts`) therefore\n * resolve Vite from the application, which must have it installed, instead of\n * from smrt-core's own location.\n */\nexport async function importProjectVite(\n projectRoot: string,\n purpose: string,\n): Promise<ViteModule> {\n // Node's own lookup order from the application root (its node_modules\n // ancestors, then global folders). Finding the package directory directly\n // does not depend on vite exporting `./package.json`.\n const lookup =\n createRequire(resolve(projectRoot, 'package.json')).resolve.paths('vite') ??\n [];\n const manifestPath = lookup\n .map((dir) => join(dir, 'vite', 'package.json'))\n .find((candidate) => existsSync(candidate));\n if (!manifestPath) {\n throw new Error(\n `[smrt] ${purpose} needs Vite, but 'vite' is not installed in ${projectRoot}. Add vite to the application's devDependencies.`,\n );\n }\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as {\n exports?: ExportTarget | { '.': ExportTarget };\n module?: string;\n main?: string;\n };\n const exportsField = manifest.exports;\n const rootExport =\n exportsField && typeof exportsField === 'object' && '.' in exportsField\n ? (exportsField as { '.': ExportTarget })['.']\n : (exportsField as ExportTarget | undefined);\n const entry = esmEntry(rootExport) ?? manifest.module ?? manifest.main;\n if (!entry) {\n throw new Error(\n `[smrt] ${purpose}: cannot find the entry point of vite at ${dirname(manifestPath)}.`,\n );\n }\n return (await import(\n /* @vite-ignore */ pathToFileURL(resolve(dirname(manifestPath), entry)).href\n )) as ViteModule;\n}\n"],"mappings":";;;;;;AASA,SAAS,SAAS,QAAiD;CACjE,IAAI,OAAO,WAAW,UAAU,OAAO;CACvC,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAO;CAClD,KAAK,MAAM,aAAa;EAAC;EAAQ;EAAU;CAAS,GAAG;EACrD,MAAM,QAAQ,SAAS,OAAO,UAAU;EACxC,IAAI,OAAO,OAAO;CACpB;CACA,OAAO;AACT;;;;;;;;;;;;AAaA,eAAsB,kBACpB,aACA,SACqB;CAOrB,MAAM,gBAFJ,cAAc,QAAQ,aAAa,cAAc,CAAC,CAAC,CAAC,QAAQ,MAAM,MAAM,KACxE,CAAC,EAAA,CAEA,KAAK,QAAQ,KAAK,KAAK,QAAQ,cAAc,CAAC,CAAC,CAC/C,MAAM,cAAc,WAAW,SAAS,CAAC;CAC5C,IAAI,CAAC,cACH,MAAM,IAAI,MACR,UAAU,QAAQ,8CAA8C,YAAY,iDAC9E;CAEF,MAAM,WAAW,KAAK,MAAM,aAAa,cAAc,MAAM,CAAC;CAK9D,MAAM,eAAe,SAAS;CAK9B,MAAM,QAAQ,SAHZ,gBAAgB,OAAO,iBAAiB,YAAY,OAAO,eACtD,aAAuC,OACvC,YAC0B,KAAK,SAAS,UAAU,SAAS;CAClE,IAAI,CAAC,OACH,MAAM,IAAI,MACR,UAAU,QAAQ,2CAA2C,QAAQ,YAAY,EAAE,EACrF;CAEF,OAAQ,MAAM;;EACO,cAAc,QAAQ,QAAQ,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC;;AAE5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"worker-registration.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/worker-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAElD,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,8DAA8D;AAC9D,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,8BAA4D,CAAC;AASlG;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,GACpC,KAAK,EAAE,CAOT;AASD;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAQzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,iFAAiF;IACjF,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;CAClE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,MAAM,CAAC,CA2CjB"}
1
+ {"version":3,"file":"worker-registration.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/worker-registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGlD,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,8DAA8D;AAC9D,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,8BAA4D,CAAC;AASlG;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,GACpC,KAAK,EAAE,CAOT;AASD;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAQzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,iFAAiF;IACjF,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;CAClE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,MAAM,CAAC,CA2CjB"}
@@ -1,3 +1,4 @@
1
+ import { importProjectVite } from "../utils/import-project-vite.js";
1
2
  import { isAbsolute, join, relative, resolve } from "node:path";
2
3
  //#region src/vite-plugin/worker-registration.ts
3
4
  /**
@@ -66,7 +67,7 @@ async function buildWorkerRegistration(options) {
66
67
  const { projectRoot, registrationFile, resolvedConfig } = options;
67
68
  const outDir = resolve(projectRoot, WORKER_REGISTRATION_DIR);
68
69
  const aliases = projectSourceAliases(projectRoot, resolvedConfig.resolve.alias);
69
- const { build } = await import("vite");
70
+ const { build } = await importProjectVite(projectRoot, "Worker registration");
70
71
  await build({
71
72
  configFile: false,
72
73
  envFile: false,
@@ -1 +1 @@
1
- {"version":3,"file":"worker-registration.js","names":[],"sources":["../../src/vite-plugin/worker-registration.ts"],"sourcesContent":["/**\n * Compiled application registration for out-of-bundle Node processes (#3117).\n *\n * A SvelteKit app registers its own `@smrt()` objects through the generated\n * `smrt-register.ts`, which only the Vite build compiles — and adapter-node\n * re-bundles the server from its own entries, so that module never exists as\n * an importable file in `build/`. A deployed task or schedule worker is plain\n * ESM run by `node`, so without this artifact `ObjectRegistry.getClass()`\n * cannot resolve any application object and every app-defined job throws\n * `Unknown object type` before its method runs.\n *\n * After a production build, this compiles that same generated module into\n * `.smrt/runtime/register.js`: one ESM entry that registers the app's local\n * objects AND its consumed packages' objects (via the `.smrt/register.js` it\n * imports), with each class's package-qualified identity and isolated\n * manifest exactly as the web server registers them. Application sources are\n * bundled; every package import stays external and is resolved from\n * `node_modules` at runtime, like the rest of the deployed image — so the\n * worker and `@happyvertical/smrt-core` share one registry.\n */\n\nimport { isAbsolute, join, relative, resolve } from 'node:path';\nimport type { Alias, ResolvedConfig } from 'vite';\n\n/** Directory (under the project root) the compiled registration is written to. */\nexport const WORKER_REGISTRATION_DIR = '.smrt/runtime';\n\n/** Entry file name inside {@link WORKER_REGISTRATION_DIR}. */\nexport const WORKER_REGISTRATION_ENTRY = 'register.js';\n\n/** Project-relative path a worker imports: `.smrt/runtime/register.js`. */\nexport const WORKER_REGISTRATION_PATH = `${WORKER_REGISTRATION_DIR}/${WORKER_REGISTRATION_ENTRY}`;\n\n/** Is `child` the project root or inside it (and not under node_modules)? */\nfunction isProjectSource(projectRoot: string, child: string): boolean {\n const rel = relative(projectRoot, child);\n if (rel.startsWith('..') || isAbsolute(rel)) return false;\n return !rel.split(/[\\\\/]/).includes('node_modules');\n}\n\n/**\n * The resolved aliases that point at the application's own sources (e.g.\n * SvelteKit's `$lib` → `src/lib`). Aliases that map a package name elsewhere\n * are dropped: the compiled registration must import packages exactly as the\n * deployed process resolves them, from `node_modules`.\n */\nexport function projectSourceAliases(\n projectRoot: string,\n aliases: readonly Alias[] | undefined,\n): Alias[] {\n return (aliases ?? []).filter(\n (alias) =>\n typeof alias.replacement === 'string' &&\n isAbsolute(alias.replacement) &&\n isProjectSource(projectRoot, alias.replacement),\n );\n}\n\nfunction matchesAlias(id: string, alias: Alias): boolean {\n const { find } = alias;\n if (typeof find === 'string') return id === find || id.startsWith(`${find}/`);\n find.lastIndex = 0;\n return find.test(id);\n}\n\n/**\n * Rollup `external` predicate: bundle relative, absolute (resolved), virtual,\n * and project-alias imports; keep every other bare specifier external.\n */\nexport function createWorkerRegistrationExternal(\n aliases: readonly Alias[],\n): (id: string) => boolean {\n return (id) => {\n if (id.startsWith('.') || id.startsWith('\\0') || isAbsolute(id)) {\n return false;\n }\n if (aliases.some((alias) => matchesAlias(id, alias))) return false;\n return true;\n };\n}\n\nexport interface BuildWorkerRegistrationOptions {\n /** The application root (where `.smrt/` lives). */\n projectRoot: string;\n /** The generated `smrt-register.ts` to compile. */\n registrationFile: string;\n /** The consumer build's resolved config (aliases, decorator transform, mode). */\n resolvedConfig: Pick<ResolvedConfig, 'mode' | 'oxc' | 'resolve'>;\n}\n\n/**\n * Compile the generated registration into `.smrt/runtime/register.js`.\n * Returns the absolute output path. Throws on failure: a worker without it\n * cannot run any application-defined job, so the build must fail closed.\n */\nexport async function buildWorkerRegistration(\n options: BuildWorkerRegistrationOptions,\n): Promise<string> {\n const { projectRoot, registrationFile, resolvedConfig } = options;\n const outDir = resolve(projectRoot, WORKER_REGISTRATION_DIR);\n const aliases = projectSourceAliases(\n projectRoot,\n resolvedConfig.resolve.alias,\n );\n const { build } = await import('vite');\n await build({\n configFile: false,\n envFile: false,\n root: projectRoot,\n mode: resolvedConfig.mode,\n logLevel: 'warn',\n clearScreen: false,\n publicDir: false,\n // No consumer plugins: the generated module is plain TypeScript over the\n // app's decorated classes, and re-running smrtPlugin here would recurse.\n plugins: [],\n resolve: { alias: aliases },\n oxc: resolvedConfig.oxc,\n // Externalization is decided by `external` below, not Vite's SSR\n // heuristics, so a package import can never be inlined into the bundle.\n ssr: { target: 'node', noExternal: true },\n build: {\n ssr: registrationFile,\n outDir,\n emptyOutDir: true,\n copyPublicDir: false,\n minify: false,\n sourcemap: true,\n reportCompressedSize: false,\n rollupOptions: {\n external: createWorkerRegistrationExternal(aliases),\n output: {\n format: 'es',\n entryFileNames: WORKER_REGISTRATION_ENTRY,\n chunkFileNames: 'chunks/[name]-[hash].js',\n },\n },\n },\n });\n return join(outDir, WORKER_REGISTRATION_ENTRY);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,0BAA0B;;AAGvC,IAAa,4BAA4B;AAGD,GAAG,wBAAH,EAA8B,0BAA9B;;AAGxC,SAAS,gBAAgB,aAAqB,OAAwB;CACpE,MAAM,MAAM,SAAS,aAAa,KAAK;CACvC,IAAI,IAAI,WAAW,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO;CACpD,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,SAAS,cAAc;AACpD;;;;;;;AAQA,SAAgB,qBACd,aACA,SACS;CACT,QAAQ,WAAW,CAAC,EAAA,CAAG,QACpB,UACC,OAAO,MAAM,gBAAgB,YAC7B,WAAW,MAAM,WAAW,KAC5B,gBAAgB,aAAa,MAAM,WAAW,CAClD;AACF;AAEA,SAAS,aAAa,IAAY,OAAuB;CACvD,MAAM,EAAE,SAAS;CACjB,IAAI,OAAO,SAAS,UAAU,OAAO,OAAO,QAAQ,GAAG,WAAW,GAAG,KAAK,EAAE;CAC5E,KAAK,YAAY;CACjB,OAAO,KAAK,KAAK,EAAE;AACrB;;;;;AAMA,SAAgB,iCACd,SACyB;CACzB,QAAQ,OAAO;EACb,IAAI,GAAG,WAAW,GAAG,KAAK,GAAG,WAAW,IAAI,KAAK,WAAW,EAAE,GAC5D,OAAO;EAET,IAAI,QAAQ,MAAM,UAAU,aAAa,IAAI,KAAK,CAAC,GAAG,OAAO;EAC7D,OAAO;CACT;AACF;;;;;;AAgBA,eAAsB,wBACpB,SACiB;CACjB,MAAM,EAAE,aAAa,kBAAkB,mBAAmB;CAC1D,MAAM,SAAS,QAAQ,aAAa,uBAAuB;CAC3D,MAAM,UAAU,qBACd,aACA,eAAe,QAAQ,KACzB;CACA,MAAM,EAAE,UAAU,MAAM,OAAO;CAC/B,MAAM,MAAM;EACV,YAAY;EACZ,SAAS;EACT,MAAM;EACN,MAAM,eAAe;EACrB,UAAU;EACV,aAAa;EACb,WAAW;EAGX,SAAS,CAAC;EACV,SAAS,EAAE,OAAO,QAAQ;EAC1B,KAAK,eAAe;EAGpB,KAAK;GAAE,QAAQ;GAAQ,YAAY;EAAK;EACxC,OAAO;GACL,KAAK;GACL;GACA,aAAa;GACb,eAAe;GACf,QAAQ;GACR,WAAW;GACX,sBAAsB;GACtB,eAAe;IACb,UAAU,iCAAiC,OAAO;IAClD,QAAQ;KACN,QAAQ;KACR,gBAAgB;KAChB,gBAAgB;IAClB;GACF;EACF;CACF,CAAC;CACD,OAAO,KAAK,QAAQ,yBAAyB;AAC/C"}
1
+ {"version":3,"file":"worker-registration.js","names":[],"sources":["../../src/vite-plugin/worker-registration.ts"],"sourcesContent":["/**\n * Compiled application registration for out-of-bundle Node processes (#3117).\n *\n * A SvelteKit app registers its own `@smrt()` objects through the generated\n * `smrt-register.ts`, which only the Vite build compiles — and adapter-node\n * re-bundles the server from its own entries, so that module never exists as\n * an importable file in `build/`. A deployed task or schedule worker is plain\n * ESM run by `node`, so without this artifact `ObjectRegistry.getClass()`\n * cannot resolve any application object and every app-defined job throws\n * `Unknown object type` before its method runs.\n *\n * After a production build, this compiles that same generated module into\n * `.smrt/runtime/register.js`: one ESM entry that registers the app's local\n * objects AND its consumed packages' objects (via the `.smrt/register.js` it\n * imports), with each class's package-qualified identity and isolated\n * manifest exactly as the web server registers them. Application sources are\n * bundled; every package import stays external and is resolved from\n * `node_modules` at runtime, like the rest of the deployed image — so the\n * worker and `@happyvertical/smrt-core` share one registry.\n */\n\nimport { isAbsolute, join, relative, resolve } from 'node:path';\nimport type { Alias, ResolvedConfig } from 'vite';\nimport { importProjectVite } from '../utils/import-project-vite.js';\n\n/** Directory (under the project root) the compiled registration is written to. */\nexport const WORKER_REGISTRATION_DIR = '.smrt/runtime';\n\n/** Entry file name inside {@link WORKER_REGISTRATION_DIR}. */\nexport const WORKER_REGISTRATION_ENTRY = 'register.js';\n\n/** Project-relative path a worker imports: `.smrt/runtime/register.js`. */\nexport const WORKER_REGISTRATION_PATH = `${WORKER_REGISTRATION_DIR}/${WORKER_REGISTRATION_ENTRY}`;\n\n/** Is `child` the project root or inside it (and not under node_modules)? */\nfunction isProjectSource(projectRoot: string, child: string): boolean {\n const rel = relative(projectRoot, child);\n if (rel.startsWith('..') || isAbsolute(rel)) return false;\n return !rel.split(/[\\\\/]/).includes('node_modules');\n}\n\n/**\n * The resolved aliases that point at the application's own sources (e.g.\n * SvelteKit's `$lib` → `src/lib`). Aliases that map a package name elsewhere\n * are dropped: the compiled registration must import packages exactly as the\n * deployed process resolves them, from `node_modules`.\n */\nexport function projectSourceAliases(\n projectRoot: string,\n aliases: readonly Alias[] | undefined,\n): Alias[] {\n return (aliases ?? []).filter(\n (alias) =>\n typeof alias.replacement === 'string' &&\n isAbsolute(alias.replacement) &&\n isProjectSource(projectRoot, alias.replacement),\n );\n}\n\nfunction matchesAlias(id: string, alias: Alias): boolean {\n const { find } = alias;\n if (typeof find === 'string') return id === find || id.startsWith(`${find}/`);\n find.lastIndex = 0;\n return find.test(id);\n}\n\n/**\n * Rollup `external` predicate: bundle relative, absolute (resolved), virtual,\n * and project-alias imports; keep every other bare specifier external.\n */\nexport function createWorkerRegistrationExternal(\n aliases: readonly Alias[],\n): (id: string) => boolean {\n return (id) => {\n if (id.startsWith('.') || id.startsWith('\\0') || isAbsolute(id)) {\n return false;\n }\n if (aliases.some((alias) => matchesAlias(id, alias))) return false;\n return true;\n };\n}\n\nexport interface BuildWorkerRegistrationOptions {\n /** The application root (where `.smrt/` lives). */\n projectRoot: string;\n /** The generated `smrt-register.ts` to compile. */\n registrationFile: string;\n /** The consumer build's resolved config (aliases, decorator transform, mode). */\n resolvedConfig: Pick<ResolvedConfig, 'mode' | 'oxc' | 'resolve'>;\n}\n\n/**\n * Compile the generated registration into `.smrt/runtime/register.js`.\n * Returns the absolute output path. Throws on failure: a worker without it\n * cannot run any application-defined job, so the build must fail closed.\n */\nexport async function buildWorkerRegistration(\n options: BuildWorkerRegistrationOptions,\n): Promise<string> {\n const { projectRoot, registrationFile, resolvedConfig } = options;\n const outDir = resolve(projectRoot, WORKER_REGISTRATION_DIR);\n const aliases = projectSourceAliases(\n projectRoot,\n resolvedConfig.resolve.alias,\n );\n const { build } = await importProjectVite(projectRoot, 'Worker registration');\n await build({\n configFile: false,\n envFile: false,\n root: projectRoot,\n mode: resolvedConfig.mode,\n logLevel: 'warn',\n clearScreen: false,\n publicDir: false,\n // No consumer plugins: the generated module is plain TypeScript over the\n // app's decorated classes, and re-running smrtPlugin here would recurse.\n plugins: [],\n resolve: { alias: aliases },\n oxc: resolvedConfig.oxc,\n // Externalization is decided by `external` below, not Vite's SSR\n // heuristics, so a package import can never be inlined into the bundle.\n ssr: { target: 'node', noExternal: true },\n build: {\n ssr: registrationFile,\n outDir,\n emptyOutDir: true,\n copyPublicDir: false,\n minify: false,\n sourcemap: true,\n reportCompressedSize: false,\n rollupOptions: {\n external: createWorkerRegistrationExternal(aliases),\n output: {\n format: 'es',\n entryFileNames: WORKER_REGISTRATION_ENTRY,\n chunkFileNames: 'chunks/[name]-[hash].js',\n },\n },\n },\n });\n return join(outDir, WORKER_REGISTRATION_ENTRY);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,0BAA0B;;AAGvC,IAAa,4BAA4B;AAGD,GAAG,wBAAH,EAA8B,0BAA9B;;AAGxC,SAAS,gBAAgB,aAAqB,OAAwB;CACpE,MAAM,MAAM,SAAS,aAAa,KAAK;CACvC,IAAI,IAAI,WAAW,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO;CACpD,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,SAAS,cAAc;AACpD;;;;;;;AAQA,SAAgB,qBACd,aACA,SACS;CACT,QAAQ,WAAW,CAAC,EAAA,CAAG,QACpB,UACC,OAAO,MAAM,gBAAgB,YAC7B,WAAW,MAAM,WAAW,KAC5B,gBAAgB,aAAa,MAAM,WAAW,CAClD;AACF;AAEA,SAAS,aAAa,IAAY,OAAuB;CACvD,MAAM,EAAE,SAAS;CACjB,IAAI,OAAO,SAAS,UAAU,OAAO,OAAO,QAAQ,GAAG,WAAW,GAAG,KAAK,EAAE;CAC5E,KAAK,YAAY;CACjB,OAAO,KAAK,KAAK,EAAE;AACrB;;;;;AAMA,SAAgB,iCACd,SACyB;CACzB,QAAQ,OAAO;EACb,IAAI,GAAG,WAAW,GAAG,KAAK,GAAG,WAAW,IAAI,KAAK,WAAW,EAAE,GAC5D,OAAO;EAET,IAAI,QAAQ,MAAM,UAAU,aAAa,IAAI,KAAK,CAAC,GAAG,OAAO;EAC7D,OAAO;CACT;AACF;;;;;;AAgBA,eAAsB,wBACpB,SACiB;CACjB,MAAM,EAAE,aAAa,kBAAkB,mBAAmB;CAC1D,MAAM,SAAS,QAAQ,aAAa,uBAAuB;CAC3D,MAAM,UAAU,qBACd,aACA,eAAe,QAAQ,KACzB;CACA,MAAM,EAAE,UAAU,MAAM,kBAAkB,aAAa,qBAAqB;CAC5E,MAAM,MAAM;EACV,YAAY;EACZ,SAAS;EACT,MAAM;EACN,MAAM,eAAe;EACrB,UAAU;EACV,aAAa;EACb,WAAW;EAGX,SAAS,CAAC;EACV,SAAS,EAAE,OAAO,QAAQ;EAC1B,KAAK,eAAe;EAGpB,KAAK;GAAE,QAAQ;GAAQ,YAAY;EAAK;EACxC,OAAO;GACL,KAAK;GACL;GACA,aAAa;GACb,eAAe;GACf,QAAQ;GACR,WAAW;GACX,sBAAsB;GACtB,eAAe;IACb,UAAU,iCAAiC,OAAO;IAClD,QAAQ;KACN,QAAQ;KACR,gBAAgB;KAChB,gBAAgB;IAClB;GACF;EACF;CACF,CAAC;CACD,OAAO,KAAK,QAAQ,yBAAyB;AAC/C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-core",
3
- "version": "0.51.33",
3
+ "version": "0.51.35",
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.33",
158
- "@happyvertical/smrt-scanner": "0.51.33",
159
- "@happyvertical/smrt-types": "0.51.33",
157
+ "@happyvertical/smrt-config": "0.51.35",
158
+ "@happyvertical/smrt-scanner": "0.51.35",
159
+ "@happyvertical/smrt-types": "0.51.35",
160
160
  "@happyvertical/sql": "^0.94.1",
161
161
  "@happyvertical/utils": "^0.94.1",
162
162
  "@oxc-project/runtime": "^0.150.0",
@@ -166,7 +166,6 @@
166
166
  "oxc-transform": "0.150.0",
167
167
  "pluralize": "^8.0.0",
168
168
  "tsx": "^4.23.13",
169
- "vite": "8.1.4",
170
169
  "yaml": "^2.9.1"
171
170
  },
172
171
  "peerDependencies": {
@@ -192,6 +191,7 @@
192
191
  "svelte": "^5.57.1",
193
192
  "svelte-check": "^4.7.6",
194
193
  "typescript": "6.0.3",
194
+ "vite": "8.1.4",
195
195
  "vitest": "4.1.10"
196
196
  },
197
197
  "publishConfig": {