@happyvertical/smrt-core 0.57.43 → 0.57.45
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.
- package/agents/build-knowledge.md +8 -0
- package/dist/manifest/static-manifest.js +1 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +5 -5
- package/dist/vite-plugin/host-tool-names.d.ts +41 -0
- package/dist/vite-plugin/host-tool-names.d.ts.map +1 -0
- package/dist/vite-plugin/host-tool-names.js +40 -0
- package/dist/vite-plugin/host-tool-names.js.map +1 -0
- package/dist/vite-plugin/index.d.ts +9 -0
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js +8 -2
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/vite-plugin.js +2 -1
- package/dist/vite-preset/index.d.ts +9 -0
- package/dist/vite-preset/index.d.ts.map +1 -1
- package/dist/vite-preset/index.js +1 -0
- package/dist/vite-preset/index.js.map +1 -1
- package/package.json +4 -4
package/dist/vite-plugin.js
CHANGED
|
@@ -2,5 +2,6 @@ import { findCliApiCoherenceViolations, generateSvelteKitRoutes, methodNameToKeb
|
|
|
2
2
|
import { buildWebMcpToolDefinitions } from "./vite-plugin/web-collections.js";
|
|
3
3
|
import { smrtAssetUrlCompatibility } from "./vite-plugin/asset-url-compatibility.js";
|
|
4
4
|
import { loadVerifiedSmrtGenerationSnapshot, serializeSmrtGenerationSnapshot, sha256SmrtGenerationSnapshot } from "./generation-snapshot.js";
|
|
5
|
+
import { assertNoHostToolNameCollisions, checkHostToolNameCollisions } from "./vite-plugin/host-tool-names.js";
|
|
5
6
|
import { collectAgentSurfaceToolNameCollisions, generateInlineRegisterModule, generateTypeDeclarationFile, isRegisterShimModuleId, smrtPlugin, stampPackageModule, stampedLibraryManifest, toKnowledgeAgentSurface } from "./vite-plugin/index.js";
|
|
6
|
-
export { buildWebMcpToolDefinitions, collectAgentSurfaceToolNameCollisions, findCliApiCoherenceViolations, generateInlineRegisterModule, generateSvelteKitRoutes, generateTypeDeclarationFile, isRegisterShimModuleId, loadVerifiedSmrtGenerationSnapshot, methodNameToKebab, resolveApiActionRouteConfig, resolveApiActionSet, serializeSmrtGenerationSnapshot, sha256SmrtGenerationSnapshot, smrtAssetUrlCompatibility, smrtPlugin, stampPackageModule, stampedLibraryManifest, toKnowledgeAgentSurface, validateCliIncludeAgainstApi };
|
|
7
|
+
export { assertNoHostToolNameCollisions, buildWebMcpToolDefinitions, checkHostToolNameCollisions, collectAgentSurfaceToolNameCollisions, findCliApiCoherenceViolations, generateInlineRegisterModule, generateSvelteKitRoutes, generateTypeDeclarationFile, isRegisterShimModuleId, loadVerifiedSmrtGenerationSnapshot, methodNameToKebab, resolveApiActionRouteConfig, resolveApiActionSet, serializeSmrtGenerationSnapshot, sha256SmrtGenerationSnapshot, smrtAssetUrlCompatibility, smrtPlugin, stampPackageModule, stampedLibraryManifest, toKnowledgeAgentSurface, validateCliIncludeAgainstApi };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* explicit package list, and `smrtPlugin({...})` with the SvelteKit path
|
|
7
7
|
* options. `smrtConsumer` and `smrtPlugin` stay public and unchanged.
|
|
8
8
|
*/
|
|
9
|
+
import { type HostToolNameDeclaration } from '../vite-plugin/index.js';
|
|
9
10
|
import type { SmrtVitePlugin } from '../vite-plugin/plugin-contract.js';
|
|
10
11
|
export interface SmrtPresetOptions {
|
|
11
12
|
/**
|
|
@@ -47,6 +48,14 @@ export interface SmrtPresetOptions {
|
|
|
47
48
|
* under `oxc.decorator` itself are never overwritten.
|
|
48
49
|
*/
|
|
49
50
|
decorators?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Host-declared agent tool names (workflow, bespoke WebMCP and MCP tools),
|
|
53
|
+
* forwarded unchanged to `smrtPlugin({ hostToolNames })`. A name two
|
|
54
|
+
* different declarations claim, or that shadows a generated model tool,
|
|
55
|
+
* fails the build; one operation (`declaredBy`) on several surfaces is
|
|
56
|
+
* allowed. Omit to skip the check.
|
|
57
|
+
*/
|
|
58
|
+
hostToolNames?: readonly HostToolNameDeclaration[];
|
|
50
59
|
}
|
|
51
60
|
export declare const SMRT_PRESET_DEFAULTS: {
|
|
52
61
|
readonly objectsDir: "src/lib/objects";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-preset/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-preset/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,KAAK,uBAAuB,EAG7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,mCAAmC,CAAC;AAG3C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACpD;AAED,eAAO,MAAM,oBAAoB;;;;;;;CAOvB,CAAC;AAiEX;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,4BAA6B,CAAC;AAiCvE;;;;GAIG;AACH,wBAAsB,IAAI,CACxB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAkEpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/vite-preset/index.ts"],"sourcesContent":["/**\n * Single-plugin Vite preset for SMRT applications.\n *\n * `plugins: [sveltekit(), smrt()]` replaces the hand-copied glue every app\n * carried: the Oxc legacy-decorator block, `smrtConsumer({...})` with an\n * explicit package list, and `smrtPlugin({...})` with the SvelteKit path\n * options. `smrtConsumer` and `smrtPlugin` stay public and unchanged.\n */\n\nimport { smrtConsumer } from '../consumer-plugin/index.js';\nimport { type SmrtPluginOptions, smrtPlugin } from '../vite-plugin/index.js';\nimport type {\n SmrtDecoratorConfig,\n SmrtUserConfig,\n SmrtVitePlugin,\n} from '../vite-plugin/plugin-contract.js';\nimport { resolveCookbookHostedObjects } from './cookbook-exposure.js';\n\nexport interface SmrtPresetOptions {\n /**\n * SMRT packages whose object manifests this app consumes. Takes precedence\n * over `consumer.packages` in `smrt.config.ts`. An empty array declares that\n * the app consumes none. Tooling/UI packages must not be listed.\n */\n packages?: readonly string[];\n /**\n * Consumed package models to host over generated REST routes, as\n * provider-qualified refs (`@scope/pkg:Model`). This is an HTTP exposure\n * boundary: each model's own `api` config still applies, so an `api: false`\n * model stays closed. Omit to derive it from `smrt.cookbook.json` (the models\n * of its recipes and `features`, minus those its `exposure` turns off for\n * `api`); without a cookbook nothing is hosted. `[]` hosts nothing.\n */\n expose?: readonly string[];\n /**\n * Project root. Omit to follow the root Vite/SvelteKit resolve (the launch\n * cwd); `smrt.config.ts` is searched from this value or `process.cwd()`.\n */\n projectRoot?: string;\n /** Directory of the app's own `@smrt()` objects. Default `src/lib/objects`. */\n objectsDir?: string;\n /** Generated type declarations. Default `src/lib/types/smrt-generated`. */\n typesDir?: string;\n /** Generated API routes. Default `src/routes/api`. */\n routesDir?: string;\n /** Directory holding the generated runtime config module. Default `src/lib/server`. */\n configPath?: string;\n /** File name of that module. Default `smrt.ts`. */\n configFileName?: string;\n /** Source globs scanned for objects. Default `<objectsDir>/**\\/*.ts`. */\n include?: string[];\n /** Source globs excluded from the scan. Default test and spec files. */\n exclude?: string[];\n /**\n * Apply the Oxc legacy-decorator config. Default `true`. Values the app sets\n * under `oxc.decorator` itself are never overwritten.\n */\n decorators?: boolean;\n}\n\nexport const SMRT_PRESET_DEFAULTS = {\n objectsDir: 'src/lib/objects',\n typesDir: 'src/lib/types/smrt-generated',\n routesDir: 'src/routes/api',\n configPath: 'src/lib/server',\n configFileName: 'smrt.ts',\n exclude: ['**/*.test.ts', '**/*.spec.ts'],\n} as const;\n\nfunction validatePackages(value: unknown, source: string): string[] {\n if (\n !Array.isArray(value) ||\n value.some((p) => typeof p !== 'string' || p.trim() === '')\n ) {\n throw new Error(\n `[smrt] ${source} must be an array of non-empty package names, got ${JSON.stringify(value)}.`,\n );\n }\n return [...new Set(value.map((p: string) => p.trim()))];\n}\n\n/** Resolve the declared consumer package list: option first, then smrt.config. */\nasync function resolvePackages(\n options: SmrtPresetOptions,\n searchFrom: string,\n): Promise<string[]> {\n if (options.packages !== undefined) {\n return validatePackages(options.packages, 'smrt({ packages })');\n }\n\n let declared: unknown;\n try {\n const { loadConfig } = await import('@happyvertical/smrt-config');\n const config = await loadConfig({ cache: false, searchFrom });\n declared = config.consumer?.packages;\n } catch (error) {\n throw new Error(\n `[smrt] Could not read smrt.config to resolve consumer packages: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (declared === undefined) {\n throw new Error(\n '[smrt] No consumer package list declared. Set `consumer: { packages: [...] }` in smrt.config.ts ' +\n '(use [] when the app consumes no SMRT packages) or pass `smrt({ packages })`. ' +\n 'The list is explicit so runtime registration is deterministic; it is never inferred from package.json.',\n );\n }\n return validatePackages(declared, 'smrt.config `consumer.packages`');\n}\n\nfunction decoratorPlugin(): SmrtVitePlugin {\n return {\n name: 'smrt:decorators',\n // Vite merges a hook's result over the user config, so fill only the\n // values the app has not set itself.\n config(user: SmrtUserConfig) {\n const decorator = user.oxc ? user.oxc.decorator : undefined;\n const fill: SmrtDecoratorConfig = {};\n if (decorator?.legacy === undefined) fill.legacy = true;\n if (decorator?.emitDecoratorMetadata === undefined) {\n fill.emitDecoratorMetadata = true;\n }\n return Object.keys(fill).length\n ? { oxc: { decorator: fill } }\n : undefined;\n },\n };\n}\n\n/**\n * Packages SMRT's SvelteKit entries share with the app by identity. SvelteKit\n * recognizes `redirect()`/`fail()` results by class, so a server entry such as\n * `@happyvertical/smrt-app-runtime/sveltekit` must import the app's own copy.\n * Deduping selects the app peer for linked/workspace packages. The runtime\n * must also enter the SSR bundle: adapter-node bundles Kit itself, so leaving\n * runtime external would import a second Kit class through Node even when\n * both resolve to the same installed version.\n */\nexport const SMRT_SHARED_RUNTIME_PACKAGES = ['@sveltejs/kit'] as const;\n\nfunction sharedRuntimePlugin(): SmrtVitePlugin {\n let isBuild = false;\n return {\n name: 'smrt:shared-runtime',\n enforce: 'pre',\n resolveId(id, _importer, options) {\n // ssr.external on the package root would externalize every subpath.\n // Keep only this exact entry external, preserving native dependencies.\n if (isBuild && options.ssr && id === '@happyvertical/smrt-app-runtime') {\n return { id, external: true };\n }\n },\n config(_user, { command }) {\n // Only adapter builds need this split. Dev import analysis ignores a\n // resolver's external flag, so it must retain normal externalization.\n isBuild = command === 'build';\n return {\n resolve: { dedupe: [...SMRT_SHARED_RUNTIME_PACKAGES] },\n ...(isBuild\n ? {\n ssr: {\n noExternal: ['@happyvertical/smrt-app-runtime'],\n external: ['@happyvertical/smrt-app-runtime/sveltekit-runtime'],\n },\n }\n : {}),\n };\n },\n };\n}\n\n/**\n * SMRT Vite preset: decorators, dependency manifests, and app object\n * generation in one entry. Returns a promise because the package list is read\n * from `smrt.config.ts`; Vite accepts promised plugins.\n */\nexport async function smrt(\n options: SmrtPresetOptions = {},\n): Promise<SmrtVitePlugin<unknown>[]> {\n const D = SMRT_PRESET_DEFAULTS;\n const objectsDir = options.objectsDir ?? D.objectsDir;\n const typesDir = options.typesDir ?? D.typesDir;\n const routesDir = options.routesDir ?? D.routesDir;\n const configPath = options.configPath ?? D.configPath;\n const configFileName = options.configFileName ?? D.configFileName;\n const rootOption = options.projectRoot\n ? { projectRoot: options.projectRoot }\n : {};\n\n const packages = await resolvePackages(\n options,\n options.projectRoot ?? process.cwd(),\n );\n\n const plugins: SmrtVitePlugin<unknown>[] = [];\n if (options.decorators !== false) plugins.push(decoratorPlugin());\n plugins.push(sharedRuntimePlugin());\n // smrtConsumer must precede smrtPlugin, as in the template's hand-written form.\n // With no declared packages there is nothing to consume, and an empty list\n // would otherwise trigger dependency discovery.\n if (packages.length > 0) {\n const hosted = options.expose\n ? validatePackages(options.expose, 'smrt({ expose })')\n : resolveCookbookHostedObjects(\n options.projectRoot ?? process.cwd(),\n packages,\n );\n plugins.push(\n smrtConsumer({\n ...rootOption,\n packages,\n generateTypes: true,\n typesDir,\n svelteKit:\n hosted.length > 0\n ? {\n objects: hosted,\n routesDir,\n objectsDir,\n configPath,\n configFileName,\n }\n : true,\n }),\n );\n }\n const pluginOptions: SmrtPluginOptions = {\n ...rootOption,\n include: options.include ?? [`${objectsDir}/**/*.ts`],\n exclude: options.exclude ?? [...D.exclude],\n generateTypes: true,\n typeDeclarationsPath: typesDir,\n svelteKit: {\n enabled: true,\n routesDir,\n objectsDir,\n configPath,\n configFileName,\n },\n };\n plugins.push(smrtPlugin(pluginOptions));\n return plugins;\n}\n"],"mappings":";;;;;;;;;;;;AA4DA,IAAa,uBAAuB;CAClC,YAAY;CACZ,UAAU;CACV,WAAW;CACX,YAAY;CACZ,gBAAgB;CAChB,SAAS,CAAC,gBAAgB,cAAc;AAC1C;A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AAE,OAAO;EACzC,eAAe;EACf,sBAAsB;EACtB,WAAW;GACT,SAAS;GACT;GACA;GACA;GACA;EACF;CACF;CACA,QAAQ,KAAK,WAAW,aAAa,CAAC;CACtC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/vite-preset/index.ts"],"sourcesContent":["/**\n * Single-plugin Vite preset for SMRT applications.\n *\n * `plugins: [sveltekit(), smrt()]` replaces the hand-copied glue every app\n * carried: the Oxc legacy-decorator block, `smrtConsumer({...})` with an\n * explicit package list, and `smrtPlugin({...})` with the SvelteKit path\n * options. `smrtConsumer` and `smrtPlugin` stay public and unchanged.\n */\n\nimport { smrtConsumer } from '../consumer-plugin/index.js';\nimport {\n type HostToolNameDeclaration,\n type SmrtPluginOptions,\n smrtPlugin,\n} from '../vite-plugin/index.js';\nimport type {\n SmrtDecoratorConfig,\n SmrtUserConfig,\n SmrtVitePlugin,\n} from '../vite-plugin/plugin-contract.js';\nimport { resolveCookbookHostedObjects } from './cookbook-exposure.js';\n\nexport interface SmrtPresetOptions {\n /**\n * SMRT packages whose object manifests this app consumes. Takes precedence\n * over `consumer.packages` in `smrt.config.ts`. An empty array declares that\n * the app consumes none. Tooling/UI packages must not be listed.\n */\n packages?: readonly string[];\n /**\n * Consumed package models to host over generated REST routes, as\n * provider-qualified refs (`@scope/pkg:Model`). This is an HTTP exposure\n * boundary: each model's own `api` config still applies, so an `api: false`\n * model stays closed. Omit to derive it from `smrt.cookbook.json` (the models\n * of its recipes and `features`, minus those its `exposure` turns off for\n * `api`); without a cookbook nothing is hosted. `[]` hosts nothing.\n */\n expose?: readonly string[];\n /**\n * Project root. Omit to follow the root Vite/SvelteKit resolve (the launch\n * cwd); `smrt.config.ts` is searched from this value or `process.cwd()`.\n */\n projectRoot?: string;\n /** Directory of the app's own `@smrt()` objects. Default `src/lib/objects`. */\n objectsDir?: string;\n /** Generated type declarations. Default `src/lib/types/smrt-generated`. */\n typesDir?: string;\n /** Generated API routes. Default `src/routes/api`. */\n routesDir?: string;\n /** Directory holding the generated runtime config module. Default `src/lib/server`. */\n configPath?: string;\n /** File name of that module. Default `smrt.ts`. */\n configFileName?: string;\n /** Source globs scanned for objects. Default `<objectsDir>/**\\/*.ts`. */\n include?: string[];\n /** Source globs excluded from the scan. Default test and spec files. */\n exclude?: string[];\n /**\n * Apply the Oxc legacy-decorator config. Default `true`. Values the app sets\n * under `oxc.decorator` itself are never overwritten.\n */\n decorators?: boolean;\n /**\n * Host-declared agent tool names (workflow, bespoke WebMCP and MCP tools),\n * forwarded unchanged to `smrtPlugin({ hostToolNames })`. A name two\n * different declarations claim, or that shadows a generated model tool,\n * fails the build; one operation (`declaredBy`) on several surfaces is\n * allowed. Omit to skip the check.\n */\n hostToolNames?: readonly HostToolNameDeclaration[];\n}\n\nexport const SMRT_PRESET_DEFAULTS = {\n objectsDir: 'src/lib/objects',\n typesDir: 'src/lib/types/smrt-generated',\n routesDir: 'src/routes/api',\n configPath: 'src/lib/server',\n configFileName: 'smrt.ts',\n exclude: ['**/*.test.ts', '**/*.spec.ts'],\n} as const;\n\nfunction validatePackages(value: unknown, source: string): string[] {\n if (\n !Array.isArray(value) ||\n value.some((p) => typeof p !== 'string' || p.trim() === '')\n ) {\n throw new Error(\n `[smrt] ${source} must be an array of non-empty package names, got ${JSON.stringify(value)}.`,\n );\n }\n return [...new Set(value.map((p: string) => p.trim()))];\n}\n\n/** Resolve the declared consumer package list: option first, then smrt.config. */\nasync function resolvePackages(\n options: SmrtPresetOptions,\n searchFrom: string,\n): Promise<string[]> {\n if (options.packages !== undefined) {\n return validatePackages(options.packages, 'smrt({ packages })');\n }\n\n let declared: unknown;\n try {\n const { loadConfig } = await import('@happyvertical/smrt-config');\n const config = await loadConfig({ cache: false, searchFrom });\n declared = config.consumer?.packages;\n } catch (error) {\n throw new Error(\n `[smrt] Could not read smrt.config to resolve consumer packages: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (declared === undefined) {\n throw new Error(\n '[smrt] No consumer package list declared. Set `consumer: { packages: [...] }` in smrt.config.ts ' +\n '(use [] when the app consumes no SMRT packages) or pass `smrt({ packages })`. ' +\n 'The list is explicit so runtime registration is deterministic; it is never inferred from package.json.',\n );\n }\n return validatePackages(declared, 'smrt.config `consumer.packages`');\n}\n\nfunction decoratorPlugin(): SmrtVitePlugin {\n return {\n name: 'smrt:decorators',\n // Vite merges a hook's result over the user config, so fill only the\n // values the app has not set itself.\n config(user: SmrtUserConfig) {\n const decorator = user.oxc ? user.oxc.decorator : undefined;\n const fill: SmrtDecoratorConfig = {};\n if (decorator?.legacy === undefined) fill.legacy = true;\n if (decorator?.emitDecoratorMetadata === undefined) {\n fill.emitDecoratorMetadata = true;\n }\n return Object.keys(fill).length\n ? { oxc: { decorator: fill } }\n : undefined;\n },\n };\n}\n\n/**\n * Packages SMRT's SvelteKit entries share with the app by identity. SvelteKit\n * recognizes `redirect()`/`fail()` results by class, so a server entry such as\n * `@happyvertical/smrt-app-runtime/sveltekit` must import the app's own copy.\n * Deduping selects the app peer for linked/workspace packages. The runtime\n * must also enter the SSR bundle: adapter-node bundles Kit itself, so leaving\n * runtime external would import a second Kit class through Node even when\n * both resolve to the same installed version.\n */\nexport const SMRT_SHARED_RUNTIME_PACKAGES = ['@sveltejs/kit'] as const;\n\nfunction sharedRuntimePlugin(): SmrtVitePlugin {\n let isBuild = false;\n return {\n name: 'smrt:shared-runtime',\n enforce: 'pre',\n resolveId(id, _importer, options) {\n // ssr.external on the package root would externalize every subpath.\n // Keep only this exact entry external, preserving native dependencies.\n if (isBuild && options.ssr && id === '@happyvertical/smrt-app-runtime') {\n return { id, external: true };\n }\n },\n config(_user, { command }) {\n // Only adapter builds need this split. Dev import analysis ignores a\n // resolver's external flag, so it must retain normal externalization.\n isBuild = command === 'build';\n return {\n resolve: { dedupe: [...SMRT_SHARED_RUNTIME_PACKAGES] },\n ...(isBuild\n ? {\n ssr: {\n noExternal: ['@happyvertical/smrt-app-runtime'],\n external: ['@happyvertical/smrt-app-runtime/sveltekit-runtime'],\n },\n }\n : {}),\n };\n },\n };\n}\n\n/**\n * SMRT Vite preset: decorators, dependency manifests, and app object\n * generation in one entry. Returns a promise because the package list is read\n * from `smrt.config.ts`; Vite accepts promised plugins.\n */\nexport async function smrt(\n options: SmrtPresetOptions = {},\n): Promise<SmrtVitePlugin<unknown>[]> {\n const D = SMRT_PRESET_DEFAULTS;\n const objectsDir = options.objectsDir ?? D.objectsDir;\n const typesDir = options.typesDir ?? D.typesDir;\n const routesDir = options.routesDir ?? D.routesDir;\n const configPath = options.configPath ?? D.configPath;\n const configFileName = options.configFileName ?? D.configFileName;\n const rootOption = options.projectRoot\n ? { projectRoot: options.projectRoot }\n : {};\n\n const packages = await resolvePackages(\n options,\n options.projectRoot ?? process.cwd(),\n );\n\n const plugins: SmrtVitePlugin<unknown>[] = [];\n if (options.decorators !== false) plugins.push(decoratorPlugin());\n plugins.push(sharedRuntimePlugin());\n // smrtConsumer must precede smrtPlugin, as in the template's hand-written form.\n // With no declared packages there is nothing to consume, and an empty list\n // would otherwise trigger dependency discovery.\n if (packages.length > 0) {\n const hosted = options.expose\n ? validatePackages(options.expose, 'smrt({ expose })')\n : resolveCookbookHostedObjects(\n options.projectRoot ?? process.cwd(),\n packages,\n );\n plugins.push(\n smrtConsumer({\n ...rootOption,\n packages,\n generateTypes: true,\n typesDir,\n svelteKit:\n hosted.length > 0\n ? {\n objects: hosted,\n routesDir,\n objectsDir,\n configPath,\n configFileName,\n }\n : true,\n }),\n );\n }\n const pluginOptions: SmrtPluginOptions = {\n ...rootOption,\n include: options.include ?? [`${objectsDir}/**/*.ts`],\n exclude: options.exclude ?? [...D.exclude],\n generateTypes: true,\n typeDeclarationsPath: typesDir,\n svelteKit: {\n enabled: true,\n routesDir,\n objectsDir,\n configPath,\n configFileName,\n },\n };\n if (options.hostToolNames)\n pluginOptions.hostToolNames = options.hostToolNames;\n plugins.push(smrtPlugin(pluginOptions));\n return plugins;\n}\n"],"mappings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EACR,CAAC,CACH;CACF;CACA,MAAM,gBAAmC;EACvC,GAAG;EACH,SAAS,QAAQ,WAAW,CAAC,GAAG,WAAW,SAAS;EACpD,SAAS,QAAQ,WAAW,CAAC,GAAG,EAAE,OAAO;EACzC,eAAe;EACf,sBAAsB;EACtB,WAAW;GACT,SAAS;GACT;GACA;GACA;GACA;EACF;CACF;CACA,IAAI,QAAQ,eACV,cAAc,gBAAgB,QAAQ;CACxC,QAAQ,KAAK,WAAW,aAAa,CAAC;CACtC,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-core",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.45",
|
|
4
4
|
"description": "Core SMRT framework for business objects, persistence, and generated REST, CLI, MCP, and AI interfaces",
|
|
5
5
|
"author": "HappyVertical",
|
|
6
6
|
"type": "module",
|
|
@@ -199,9 +199,9 @@
|
|
|
199
199
|
"@happyvertical/files": "^0.111.0",
|
|
200
200
|
"@happyvertical/json": "^0.111.0",
|
|
201
201
|
"@happyvertical/logger": "^0.111.0",
|
|
202
|
-
"@happyvertical/smrt-config": "0.57.
|
|
203
|
-
"@happyvertical/smrt-scanner": "0.57.
|
|
204
|
-
"@happyvertical/smrt-types": "0.57.
|
|
202
|
+
"@happyvertical/smrt-config": "0.57.45",
|
|
203
|
+
"@happyvertical/smrt-scanner": "0.57.45",
|
|
204
|
+
"@happyvertical/smrt-types": "0.57.45",
|
|
205
205
|
"@happyvertical/sql": "^0.111.0",
|
|
206
206
|
"@happyvertical/utils": "^0.111.0",
|
|
207
207
|
"@noble/hashes": "^2.4.0",
|