@happyvertical/smrt-core 0.55.18 → 0.55.19
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/schema-paths.md +15 -0
- package/dist/browser.js +3 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- package/dist/collection.js.map +1 -1
- package/dist/cookbook/engine/schemas.d.ts.map +1 -1
- package/dist/cookbook/engine/schemas.js +2 -4
- package/dist/cookbook/engine/schemas.js.map +1 -1
- package/dist/generators/mcp.js +1 -1
- package/dist/index.js +3 -3
- package/dist/manifest/manifest-loader.js +1 -1
- package/dist/manifest/static-manifest.js +1 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +2 -2
- package/dist/manifest.json +1 -1
- package/dist/migrations/qualified-name-aliases.js +1 -1
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +7 -1
- package/dist/object.js.map +1 -1
- package/dist/registry/class-registration.js +2 -2
- package/dist/registry/name-resolver.js +1 -1
- package/dist/registry/qualified-name-aliases.js +1 -1
- package/dist/registry/runtime-overrides.js +1 -1
- package/dist/registry/schema-builder.d.ts.map +1 -1
- package/dist/registry/schema-builder.js +22 -29
- package/dist/registry/schema-builder.js.map +1 -1
- package/dist/registry/table-mappings.d.ts +23 -0
- package/dist/registry/table-mappings.d.ts.map +1 -0
- package/dist/registry/table-mappings.js +151 -0
- package/dist/registry/table-mappings.js.map +1 -0
- package/dist/registry.js +4 -4
- package/dist/scanner/manifest-generator.js +1 -1
- package/dist/smrt-knowledge.json +5 -5
- package/dist/testing/database.js +2 -2
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/cookbook/engine/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAC;AA8BpB;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/cookbook/engine/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAC;AA8BpB;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,EAAE,CAwPvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG;IACtD,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;CACzB,CA+BA;AAgBD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,OAAO,EACd,IAAI,SAAU,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiG1C;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;AAEvE,yCAAyC;AACzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAIrE"}
|
|
@@ -172,10 +172,8 @@ function buildCommandTools(catalog) {
|
|
|
172
172
|
description: "Light, dark or follow the device."
|
|
173
173
|
},
|
|
174
174
|
fontFamily: {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
minLength: 1
|
|
178
|
-
}, { type: "null" }],
|
|
175
|
+
type: ["string", "null"],
|
|
176
|
+
minLength: 1,
|
|
179
177
|
description: "Font key. Null restores the preset font."
|
|
180
178
|
}
|
|
181
179
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","names":[],"sources":["../../../src/cookbook/engine/schemas.ts"],"sourcesContent":["import { DEFAULT_THEME_PRESETS, MAX_TERMS_LENGTH } from './defaults.js';\nimport type {\n CommandName,\n CommandTool,\n EngineCatalog,\n JsonSchema,\n} from './types.js';\n\nconst ids = (description: string, values?: readonly string[]): JsonSchema => ({\n type: 'array',\n description,\n minItems: 1,\n maxItems: 50,\n items: values?.length\n ? { type: 'string', enum: [...values] }\n : { type: 'string', minLength: 1 },\n});\n\nconst text = (description: string, extra: JsonSchema = {}): JsonSchema => ({\n type: 'string',\n description,\n minLength: 1,\n maxLength: 200,\n ...extra,\n});\n\nconst object = (\n properties: Record<string, JsonSchema>,\n required: string[] = [],\n): JsonSchema => ({\n type: 'object',\n properties,\n ...(required.length ? { required } : {}),\n additionalProperties: false,\n});\n\n/**\n * Every command as an MCP/LLM tool definition (`inputSchema` is JSON Schema\n * 2020-12). Recipe and cookbook ids become enums from the catalog, so\n * grammar-constrained decoding cannot name one that does not exist.\n */\nexport function buildCommandTools(catalog: EngineCatalog): CommandTool[] {\n const recipeIds = catalog.recipes.map((r) => r.id);\n const cookbookIds = (catalog.cookbooks ?? []).map((c) => c.id);\n const presets = catalog.themePresets ?? DEFAULT_THEME_PRESETS;\n const cookbookId = (description: string): JsonSchema => ({\n type: 'string',\n description,\n ...(cookbookIds.length ? { enum: [...cookbookIds] } : { minLength: 1 }),\n });\n const entryId = (what: string): JsonSchema =>\n text(`The id of ${what}, as the plan snapshot's \"sections\" lists it.`);\n const replace: JsonSchema = {\n type: 'boolean',\n description: 'Confirm replacing what is there.',\n };\n return [\n {\n name: 'add_recipes',\n description:\n 'Switch recipes on. Recipes they require come along. Returns what was added.',\n inputSchema: object({ ids: ids('Recipe ids to add.', recipeIds) }, [\n 'ids',\n ]),\n },\n {\n name: 'remove_recipes',\n description:\n 'Switch recipes off. A recipe another one needs is kept and reported.',\n inputSchema: object({ ids: ids('Recipe ids to remove.', recipeIds) }, [\n 'ids',\n ]),\n },\n {\n name: 'add_features',\n description:\n 'Add single models no recipe covers, by qualified name (`@scope/pkg:Class`).',\n inputSchema: object({ ids: ids('Qualified model names to add.') }, [\n 'ids',\n ]),\n },\n {\n name: 'remove_features',\n description: 'Remove single models added with add_features.',\n inputSchema: object({ ids: ids('Qualified model names to remove.') }, [\n 'ids',\n ]),\n },\n {\n name: 'add_cookbook',\n description:\n 'Add the recipes and features of a ready-made cookbook to the current app. Nothing is replaced.',\n inputSchema: object({ id: cookbookId('The cookbook to add.') }, ['id']),\n },\n {\n name: 'remove_cookbook',\n description:\n 'Remove the recipes and features a ready-made cookbook adds. Ones another recipe needs are kept.',\n inputSchema: object({ id: cookbookId('The cookbook to remove.') }, [\n 'id',\n ]),\n },\n {\n name: 'apply_cookbook',\n description:\n 'Select a ready-made cookbook: replace the whole app (recipes, options, menu, theme) with it. When the app has anything in it, replace must be true.',\n inputSchema: object(\n { id: cookbookId('The cookbook to set up.'), replace },\n ['id'],\n ),\n },\n {\n name: 'import_cookbook',\n description:\n 'Replace the whole app with a cookbook document (version 1). Checked strictly; nothing is applied if it is invalid. When the app has anything in it, replace must be true.',\n inputSchema: object(\n {\n document: {\n type: 'object',\n description: 'A cookbook document, version 1.',\n },\n replace,\n },\n ['document'],\n ),\n },\n {\n name: 'set_settings',\n description:\n 'Change app settings: currency, default tax rate (percent), default payment terms. Applies to new records only.',\n inputSchema: object({\n currency: catalog.currencies?.length\n ? {\n type: 'string',\n description: 'ISO 4217 code, e.g. CAD.',\n enum: [...catalog.currencies],\n }\n : {\n type: 'string',\n description: 'ISO 4217 code, e.g. CAD.',\n pattern: '^[A-Z]{3}$',\n },\n taxRate: {\n type: 'number',\n description: 'Default tax rate in percent, 0 to 100.',\n minimum: 0,\n maximum: 100,\n },\n paymentTerms: {\n type: 'string',\n description: 'Default payment terms, e.g. \"Net 30\".',\n minLength: 1,\n maxLength: MAX_TERMS_LENGTH,\n },\n }),\n },\n {\n name: 'set_policy',\n description:\n \"Set one field's policy: default value, visibility, label or help. The model must be covered by a recipe or feature that is on. null clears a part.\",\n inputSchema: object(\n {\n model: text(\n 'Qualified model name, e.g. @happyvertical/smrt-commerce:Order.',\n ),\n field: text('The model field name.'),\n defaultValue: {\n description:\n 'The default as a JSON value (a string, number or boolean). null clears it.',\n },\n visibility: {\n enum: ['basic', 'advanced', 'hidden', null],\n description: 'Whether the field shows in forms and lists.',\n },\n label: {\n type: ['string', 'null'],\n description: 'A different label.',\n maxLength: 120,\n },\n help: {\n type: ['string', 'null'],\n description: 'Help text under the field.',\n maxLength: 400,\n },\n },\n ['model', 'field'],\n ),\n },\n {\n name: 'set_theme',\n description:\n 'Change the look: a preset, a brand colour, light or dark. A preset replaces a brand colour.',\n inputSchema: object({\n preset: { enum: [...presets], description: 'A built-in theme.' },\n primary: {\n type: 'string',\n description: 'Brand colour as #rrggbb.',\n pattern: '^#[0-9a-fA-F]{6}$',\n },\n colorScheme: {\n enum: ['light', 'dark', 'system'],\n description: 'Light, dark or follow the device.',\n },\n fontFamily: {\n anyOf: [{ type: 'string', minLength: 1 }, { type: 'null' }],\n description: 'Font key. Null restores the preset font.',\n },\n }),\n },\n {\n name: 'reset_theme',\n description: 'Go back to the default look.',\n inputSchema: object({}),\n },\n {\n name: 'set_name',\n description: 'Name and describe the app. null clears a part.',\n inputSchema: object({\n name: { type: ['string', 'null'], minLength: 1, maxLength: 60 },\n description: {\n type: ['string', 'null'],\n minLength: 1,\n maxLength: 400,\n },\n }),\n },\n {\n name: 'rename_section',\n description: 'Rename a menu section.',\n inputSchema: object(\n {\n id: entryId('the section'),\n label: text('The new name.', { maxLength: 60 }),\n },\n ['id', 'label'],\n ),\n },\n {\n name: 'rename_item',\n description: 'Rename a menu entry. A null label restores its own name.',\n inputSchema: object(\n {\n id: entryId('the entry'),\n label: { type: ['string', 'null'], minLength: 1, maxLength: 60 },\n },\n ['id', 'label'],\n ),\n },\n {\n name: 'hide',\n description: 'Hide a menu section or entry. Nothing is deleted.',\n inputSchema: object({ id: entryId('the section or entry') }, ['id']),\n },\n {\n name: 'show',\n description: 'Show a hidden menu section or entry again.',\n inputSchema: object({ id: entryId('the section or entry') }, ['id']),\n },\n {\n name: 'validate',\n description:\n 'Check the current cookbook against the catalog and report typed diagnostics. Changes nothing.',\n inputSchema: object({}),\n },\n {\n name: 'export_cookbook',\n description:\n 'The cookbook as a <name>.cookbook.json file (text in the result). Changes nothing.',\n inputSchema: object({\n name: text('A name for the file.', { maxLength: 60 }),\n }),\n },\n {\n name: 'undo',\n description:\n 'Undo an earlier change by the undoId its receipt carried. Refused with a conflict when the plan changed since, unless force is true.',\n inputSchema: object(\n {\n undoId: text('The undoId from a receipt.'),\n force: {\n type: 'boolean',\n description: 'Undo even after later edits.',\n },\n },\n ['undoId'],\n ),\n },\n ];\n}\n\n/**\n * The batch envelope as a tool definition: several commands, applied\n * all-or-nothing. Commands inside are validated against their own schemas.\n */\nexport function buildBatchTool(catalog: EngineCatalog): {\n name: 'run_batch';\n description: string;\n inputSchema: JsonSchema;\n} {\n return {\n name: 'run_batch',\n description:\n 'Run several commands as one atomic batch: all apply or none does. A failure names the command and leaves the plan unchanged.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', minLength: 1, maxLength: 200 },\n expectedRevision: { type: 'integer', minimum: 0 },\n commands: {\n type: 'array',\n minItems: 1,\n maxItems: 50,\n items: {\n oneOf: buildCommandTools(catalog).map((tool) => ({\n type: 'object',\n properties: {\n name: { const: tool.name },\n input: tool.inputSchema,\n },\n required: ['name'],\n additionalProperties: false,\n })),\n },\n },\n },\n required: ['commands'],\n additionalProperties: false,\n },\n };\n}\n\nconst typeOf = (value: unknown): string =>\n value === null\n ? 'null'\n : Array.isArray(value)\n ? 'array'\n : Number.isInteger(value)\n ? 'integer'\n : typeof value;\n\nfunction typeMatches(wanted: string, value: unknown): boolean {\n const actual = typeOf(value);\n return actual === wanted || (wanted === 'number' && actual === 'integer');\n}\n\n/**\n * Check a value against a command schema (the subset the commands use). One\n * validator for runtime and exported schemas, so they cannot drift. Returns\n * the first problem as `{ path, message }`, or null.\n */\nexport function checkSchema(\n schema: JsonSchema,\n value: unknown,\n path = 'input',\n): { path: string; message: string } | null {\n const bad = (message: string) => ({ path, message: `${path} ${message}` });\n const type = schema.type as string | string[] | undefined;\n if (type) {\n const wanted = Array.isArray(type) ? type : [type];\n if (!wanted.some((t) => typeMatches(t, value))) {\n return bad(`must be ${wanted.join(' or ')}`);\n }\n }\n const choices = schema.enum as unknown[] | undefined;\n if (choices && !choices.includes(value)) {\n return bad(\n choices.length > 12\n ? 'is not a known value'\n : `must be one of ${choices.map((c) => JSON.stringify(c)).join(', ')}`,\n );\n }\n if (typeof value === 'string') {\n const { minLength, maxLength, pattern } = schema as {\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n };\n if (minLength !== undefined && value.length < minLength) {\n return bad('must not be empty');\n }\n if (maxLength !== undefined && value.length > maxLength) {\n return bad(`must be at most ${maxLength} characters`);\n }\n if (pattern && !new RegExp(pattern).test(value)) {\n return bad('has the wrong format');\n }\n }\n if (typeof value === 'number') {\n const { minimum, maximum } = schema as {\n minimum?: number;\n maximum?: number;\n };\n if (!Number.isFinite(value)) return bad('must be a finite number');\n if (minimum !== undefined && value < minimum) {\n return bad(`must be at least ${minimum}`);\n }\n if (maximum !== undefined && value > maximum) {\n return bad(`must be at most ${maximum}`);\n }\n }\n if (Array.isArray(value)) {\n const { minItems, maxItems, items } = schema as {\n minItems?: number;\n maxItems?: number;\n items?: JsonSchema;\n };\n if (minItems !== undefined && value.length < minItems) {\n return bad(`needs at least ${minItems} item${minItems === 1 ? '' : 's'}`);\n }\n if (maxItems !== undefined && value.length > maxItems) {\n return bad(`takes at most ${maxItems} items`);\n }\n if (items) {\n for (const [index, item] of value.entries()) {\n const problem = checkSchema(items, item, `${path}[${index}]`);\n if (problem) return problem;\n }\n }\n }\n if (typeOf(value) === 'object') {\n const object = value as Record<string, unknown>;\n const { properties, required, additionalProperties } = schema as {\n properties?: Record<string, JsonSchema>;\n required?: string[];\n additionalProperties?: boolean;\n };\n for (const key of required ?? []) {\n if (object[key] === undefined) {\n return {\n path: `${path}.${key}`,\n message: `${path}.${key} is required`,\n };\n }\n }\n for (const [key, entry] of Object.entries(object)) {\n const child = properties?.[key];\n if (!child) {\n if (additionalProperties === false) {\n return {\n path: `${path}.${key}`,\n message: `${path}.${key} is not an option of this command`,\n };\n }\n continue;\n }\n if (entry === undefined) continue;\n const problem = checkSchema(child, entry, `${path}.${key}`);\n if (problem) return problem;\n }\n }\n return null;\n}\n\nexport type CommandSchemas = Readonly<Record<CommandName, JsonSchema>>;\n\n/** The input schemas by command name. */\nexport function commandSchemas(catalog: EngineCatalog): CommandSchemas {\n return Object.fromEntries(\n buildCommandTools(catalog).map((tool) => [tool.name, tool.inputSchema]),\n ) as CommandSchemas;\n}\n"],"mappings":";;AAQA,IAAM,OAAO,aAAqB,YAA4C;CAC5E,MAAM;CACN;CACA,UAAU;CACV,UAAU;CACV,OAAO,QAAQ,SACX;EAAE,MAAM;EAAU,MAAM,CAAC,GAAG,MAAM;CAAE,IACpC;EAAE,MAAM;EAAU,WAAW;CAAE;AACrC;AAEA,IAAM,QAAQ,aAAqB,QAAoB,CAAC,OAAmB;CACzE,MAAM;CACN;CACA,WAAW;CACX,WAAW;CACX,GAAG;AACL;AAEA,IAAM,UACJ,YACA,WAAqB,CAAC,OACN;CAChB,MAAM;CACN;CACA,GAAI,SAAS,SAAS,EAAE,SAAS,IAAI,CAAC;CACtC,sBAAsB;AACxB;;;;;;AAOA,SAAgB,kBAAkB,SAAuC;CACvE,MAAM,YAAY,QAAQ,QAAQ,KAAK,MAAM,EAAE,EAAE;CACjD,MAAM,eAAe,QAAQ,aAAa,CAAC,EAAA,CAAG,KAAK,MAAM,EAAE,EAAE;CAC7D,MAAM,UAAU,QAAQ,gBAAgB;CACxC,MAAM,cAAc,iBAAqC;EACvD,MAAM;EACN;EACA,GAAI,YAAY,SAAS,EAAE,MAAM,CAAC,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;CACvE;CACA,MAAM,WAAW,SACf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ook/engine/schemas.ts"],"sourcesContent":["import { DEFAULT_THEME_PRESETS, MAX_TERMS_LENGTH } from './defaults.js';\nimport type {\n CommandName,\n CommandTool,\n EngineCatalog,\n JsonSchema,\n} from './types.js';\n\nconst ids = (description: string, values?: readonly string[]): JsonSchema => ({\n type: 'array',\n description,\n minItems: 1,\n maxItems: 50,\n items: values?.length\n ? { type: 'string', enum: [...values] }\n : { type: 'string', minLength: 1 },\n});\n\nconst text = (description: string, extra: JsonSchema = {}): JsonSchema => ({\n type: 'string',\n description,\n minLength: 1,\n maxLength: 200,\n ...extra,\n});\n\nconst object = (\n properties: Record<string, JsonSchema>,\n required: string[] = [],\n): JsonSchema => ({\n type: 'object',\n properties,\n ...(required.length ? { required } : {}),\n additionalProperties: false,\n});\n\n/**\n * Every command as an MCP/LLM tool definition (`inputSchema` is JSON Schema\n * 2020-12). Recipe and cookbook ids become enums from the catalog, so\n * grammar-constrained decoding cannot name one that does not exist.\n */\nexport function buildCommandTools(catalog: EngineCatalog): CommandTool[] {\n const recipeIds = catalog.recipes.map((r) => r.id);\n const cookbookIds = (catalog.cookbooks ?? []).map((c) => c.id);\n const presets = catalog.themePresets ?? DEFAULT_THEME_PRESETS;\n const cookbookId = (description: string): JsonSchema => ({\n type: 'string',\n description,\n ...(cookbookIds.length ? { enum: [...cookbookIds] } : { minLength: 1 }),\n });\n const entryId = (what: string): JsonSchema =>\n text(`The id of ${what}, as the plan snapshot's \"sections\" lists it.`);\n const replace: JsonSchema = {\n type: 'boolean',\n description: 'Confirm replacing what is there.',\n };\n return [\n {\n name: 'add_recipes',\n description:\n 'Switch recipes on. Recipes they require come along. Returns what was added.',\n inputSchema: object({ ids: ids('Recipe ids to add.', recipeIds) }, [\n 'ids',\n ]),\n },\n {\n name: 'remove_recipes',\n description:\n 'Switch recipes off. A recipe another one needs is kept and reported.',\n inputSchema: object({ ids: ids('Recipe ids to remove.', recipeIds) }, [\n 'ids',\n ]),\n },\n {\n name: 'add_features',\n description:\n 'Add single models no recipe covers, by qualified name (`@scope/pkg:Class`).',\n inputSchema: object({ ids: ids('Qualified model names to add.') }, [\n 'ids',\n ]),\n },\n {\n name: 'remove_features',\n description: 'Remove single models added with add_features.',\n inputSchema: object({ ids: ids('Qualified model names to remove.') }, [\n 'ids',\n ]),\n },\n {\n name: 'add_cookbook',\n description:\n 'Add the recipes and features of a ready-made cookbook to the current app. Nothing is replaced.',\n inputSchema: object({ id: cookbookId('The cookbook to add.') }, ['id']),\n },\n {\n name: 'remove_cookbook',\n description:\n 'Remove the recipes and features a ready-made cookbook adds. Ones another recipe needs are kept.',\n inputSchema: object({ id: cookbookId('The cookbook to remove.') }, [\n 'id',\n ]),\n },\n {\n name: 'apply_cookbook',\n description:\n 'Select a ready-made cookbook: replace the whole app (recipes, options, menu, theme) with it. When the app has anything in it, replace must be true.',\n inputSchema: object(\n { id: cookbookId('The cookbook to set up.'), replace },\n ['id'],\n ),\n },\n {\n name: 'import_cookbook',\n description:\n 'Replace the whole app with a cookbook document (version 1). Checked strictly; nothing is applied if it is invalid. When the app has anything in it, replace must be true.',\n inputSchema: object(\n {\n document: {\n type: 'object',\n description: 'A cookbook document, version 1.',\n },\n replace,\n },\n ['document'],\n ),\n },\n {\n name: 'set_settings',\n description:\n 'Change app settings: currency, default tax rate (percent), default payment terms. Applies to new records only.',\n inputSchema: object({\n currency: catalog.currencies?.length\n ? {\n type: 'string',\n description: 'ISO 4217 code, e.g. CAD.',\n enum: [...catalog.currencies],\n }\n : {\n type: 'string',\n description: 'ISO 4217 code, e.g. CAD.',\n pattern: '^[A-Z]{3}$',\n },\n taxRate: {\n type: 'number',\n description: 'Default tax rate in percent, 0 to 100.',\n minimum: 0,\n maximum: 100,\n },\n paymentTerms: {\n type: 'string',\n description: 'Default payment terms, e.g. \"Net 30\".',\n minLength: 1,\n maxLength: MAX_TERMS_LENGTH,\n },\n }),\n },\n {\n name: 'set_policy',\n description:\n \"Set one field's policy: default value, visibility, label or help. The model must be covered by a recipe or feature that is on. null clears a part.\",\n inputSchema: object(\n {\n model: text(\n 'Qualified model name, e.g. @happyvertical/smrt-commerce:Order.',\n ),\n field: text('The model field name.'),\n defaultValue: {\n description:\n 'The default as a JSON value (a string, number or boolean). null clears it.',\n },\n visibility: {\n enum: ['basic', 'advanced', 'hidden', null],\n description: 'Whether the field shows in forms and lists.',\n },\n label: {\n type: ['string', 'null'],\n description: 'A different label.',\n maxLength: 120,\n },\n help: {\n type: ['string', 'null'],\n description: 'Help text under the field.',\n maxLength: 400,\n },\n },\n ['model', 'field'],\n ),\n },\n {\n name: 'set_theme',\n description:\n 'Change the look: a preset, a brand colour, light or dark. A preset replaces a brand colour.',\n inputSchema: object({\n preset: { enum: [...presets], description: 'A built-in theme.' },\n primary: {\n type: 'string',\n description: 'Brand colour as #rrggbb.',\n pattern: '^#[0-9a-fA-F]{6}$',\n },\n colorScheme: {\n enum: ['light', 'dark', 'system'],\n description: 'Light, dark or follow the device.',\n },\n fontFamily: {\n type: ['string', 'null'],\n minLength: 1,\n description: 'Font key. Null restores the preset font.',\n },\n }),\n },\n {\n name: 'reset_theme',\n description: 'Go back to the default look.',\n inputSchema: object({}),\n },\n {\n name: 'set_name',\n description: 'Name and describe the app. null clears a part.',\n inputSchema: object({\n name: { type: ['string', 'null'], minLength: 1, maxLength: 60 },\n description: {\n type: ['string', 'null'],\n minLength: 1,\n maxLength: 400,\n },\n }),\n },\n {\n name: 'rename_section',\n description: 'Rename a menu section.',\n inputSchema: object(\n {\n id: entryId('the section'),\n label: text('The new name.', { maxLength: 60 }),\n },\n ['id', 'label'],\n ),\n },\n {\n name: 'rename_item',\n description: 'Rename a menu entry. A null label restores its own name.',\n inputSchema: object(\n {\n id: entryId('the entry'),\n label: { type: ['string', 'null'], minLength: 1, maxLength: 60 },\n },\n ['id', 'label'],\n ),\n },\n {\n name: 'hide',\n description: 'Hide a menu section or entry. Nothing is deleted.',\n inputSchema: object({ id: entryId('the section or entry') }, ['id']),\n },\n {\n name: 'show',\n description: 'Show a hidden menu section or entry again.',\n inputSchema: object({ id: entryId('the section or entry') }, ['id']),\n },\n {\n name: 'validate',\n description:\n 'Check the current cookbook against the catalog and report typed diagnostics. Changes nothing.',\n inputSchema: object({}),\n },\n {\n name: 'export_cookbook',\n description:\n 'The cookbook as a <name>.cookbook.json file (text in the result). Changes nothing.',\n inputSchema: object({\n name: text('A name for the file.', { maxLength: 60 }),\n }),\n },\n {\n name: 'undo',\n description:\n 'Undo an earlier change by the undoId its receipt carried. Refused with a conflict when the plan changed since, unless force is true.',\n inputSchema: object(\n {\n undoId: text('The undoId from a receipt.'),\n force: {\n type: 'boolean',\n description: 'Undo even after later edits.',\n },\n },\n ['undoId'],\n ),\n },\n ];\n}\n\n/**\n * The batch envelope as a tool definition: several commands, applied\n * all-or-nothing. Commands inside are validated against their own schemas.\n */\nexport function buildBatchTool(catalog: EngineCatalog): {\n name: 'run_batch';\n description: string;\n inputSchema: JsonSchema;\n} {\n return {\n name: 'run_batch',\n description:\n 'Run several commands as one atomic batch: all apply or none does. A failure names the command and leaves the plan unchanged.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', minLength: 1, maxLength: 200 },\n expectedRevision: { type: 'integer', minimum: 0 },\n commands: {\n type: 'array',\n minItems: 1,\n maxItems: 50,\n items: {\n oneOf: buildCommandTools(catalog).map((tool) => ({\n type: 'object',\n properties: {\n name: { const: tool.name },\n input: tool.inputSchema,\n },\n required: ['name'],\n additionalProperties: false,\n })),\n },\n },\n },\n required: ['commands'],\n additionalProperties: false,\n },\n };\n}\n\nconst typeOf = (value: unknown): string =>\n value === null\n ? 'null'\n : Array.isArray(value)\n ? 'array'\n : Number.isInteger(value)\n ? 'integer'\n : typeof value;\n\nfunction typeMatches(wanted: string, value: unknown): boolean {\n const actual = typeOf(value);\n return actual === wanted || (wanted === 'number' && actual === 'integer');\n}\n\n/**\n * Check a value against a command schema (the subset the commands use). One\n * validator for runtime and exported schemas, so they cannot drift. Returns\n * the first problem as `{ path, message }`, or null.\n */\nexport function checkSchema(\n schema: JsonSchema,\n value: unknown,\n path = 'input',\n): { path: string; message: string } | null {\n const bad = (message: string) => ({ path, message: `${path} ${message}` });\n const type = schema.type as string | string[] | undefined;\n if (type) {\n const wanted = Array.isArray(type) ? type : [type];\n if (!wanted.some((t) => typeMatches(t, value))) {\n return bad(`must be ${wanted.join(' or ')}`);\n }\n }\n const choices = schema.enum as unknown[] | undefined;\n if (choices && !choices.includes(value)) {\n return bad(\n choices.length > 12\n ? 'is not a known value'\n : `must be one of ${choices.map((c) => JSON.stringify(c)).join(', ')}`,\n );\n }\n if (typeof value === 'string') {\n const { minLength, maxLength, pattern } = schema as {\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n };\n if (minLength !== undefined && value.length < minLength) {\n return bad('must not be empty');\n }\n if (maxLength !== undefined && value.length > maxLength) {\n return bad(`must be at most ${maxLength} characters`);\n }\n if (pattern && !new RegExp(pattern).test(value)) {\n return bad('has the wrong format');\n }\n }\n if (typeof value === 'number') {\n const { minimum, maximum } = schema as {\n minimum?: number;\n maximum?: number;\n };\n if (!Number.isFinite(value)) return bad('must be a finite number');\n if (minimum !== undefined && value < minimum) {\n return bad(`must be at least ${minimum}`);\n }\n if (maximum !== undefined && value > maximum) {\n return bad(`must be at most ${maximum}`);\n }\n }\n if (Array.isArray(value)) {\n const { minItems, maxItems, items } = schema as {\n minItems?: number;\n maxItems?: number;\n items?: JsonSchema;\n };\n if (minItems !== undefined && value.length < minItems) {\n return bad(`needs at least ${minItems} item${minItems === 1 ? '' : 's'}`);\n }\n if (maxItems !== undefined && value.length > maxItems) {\n return bad(`takes at most ${maxItems} items`);\n }\n if (items) {\n for (const [index, item] of value.entries()) {\n const problem = checkSchema(items, item, `${path}[${index}]`);\n if (problem) return problem;\n }\n }\n }\n if (typeOf(value) === 'object') {\n const object = value as Record<string, unknown>;\n const { properties, required, additionalProperties } = schema as {\n properties?: Record<string, JsonSchema>;\n required?: string[];\n additionalProperties?: boolean;\n };\n for (const key of required ?? []) {\n if (object[key] === undefined) {\n return {\n path: `${path}.${key}`,\n message: `${path}.${key} is required`,\n };\n }\n }\n for (const [key, entry] of Object.entries(object)) {\n const child = properties?.[key];\n if (!child) {\n if (additionalProperties === false) {\n return {\n path: `${path}.${key}`,\n message: `${path}.${key} is not an option of this command`,\n };\n }\n continue;\n }\n if (entry === undefined) continue;\n const problem = checkSchema(child, entry, `${path}.${key}`);\n if (problem) return problem;\n }\n }\n return null;\n}\n\nexport type CommandSchemas = Readonly<Record<CommandName, JsonSchema>>;\n\n/** The input schemas by command name. */\nexport function commandSchemas(catalog: EngineCatalog): CommandSchemas {\n return Object.fromEntries(\n buildCommandTools(catalog).map((tool) => [tool.name, tool.inputSchema]),\n ) as CommandSchemas;\n}\n"],"mappings":";;AAQA,IAAM,OAAO,aAAqB,YAA4C;CAC5E,MAAM;CACN;CACA,UAAU;CACV,UAAU;CACV,OAAO,QAAQ,SACX;EAAE,MAAM;EAAU,MAAM,CAAC,GAAG,MAAM;CAAE,IACpC;EAAE,MAAM;EAAU,WAAW;CAAE;AACrC;AAEA,IAAM,QAAQ,aAAqB,QAAoB,CAAC,OAAmB;CACzE,MAAM;CACN;CACA,WAAW;CACX,WAAW;CACX,GAAG;AACL;AAEA,IAAM,UACJ,YACA,WAAqB,CAAC,OACN;CAChB,MAAM;CACN;CACA,GAAI,SAAS,SAAS,EAAE,SAAS,IAAI,CAAC;CACtC,sBAAsB;AACxB;;;;;;AAOA,SAAgB,kBAAkB,SAAuC;CACvE,MAAM,YAAY,QAAQ,QAAQ,KAAK,MAAM,EAAE,EAAE;CACjD,MAAM,eAAe,QAAQ,aAAa,CAAC,EAAA,CAAG,KAAK,MAAM,EAAE,EAAE;CAC7D,MAAM,UAAU,QAAQ,gBAAgB;CACxC,MAAM,cAAc,iBAAqC;EACvD,MAAM;EACN;EACA,GAAI,YAAY,SAAS,EAAE,MAAM,CAAC,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;CACvE;CACA,MAAM,WAAW,S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it, resolveListOffset } from "../query-bounds.js";
|
|
2
|
-
import { SmrtCollection } from "../collection.js";
|
|
3
2
|
import { isQualifiedName } from "../utils/qualified-names.js";
|
|
4
3
|
import { isFrameworkBaseClass } from "../registry/framework-base-classes.js";
|
|
4
|
+
import { SmrtCollection } from "../collection.js";
|
|
5
5
|
import { readFieldEnum } from "../registry/manifest-field-merge.js";
|
|
6
6
|
import { ObjectRegistry } from "../registry.js";
|
|
7
7
|
import { SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, buildCustomActionInvocationArgs, customActionParameterInputName, isCrudOperation, isCrudToolAction, isFrameworkLifecycleMethod, normalizeCustomActionFailure, resolveCustomActionMetadata } from "./custom-action.js";
|
package/dist/index.js
CHANGED
|
@@ -34,19 +34,19 @@ import { DEFAULT_EMBEDDING_CONFIG, EmbeddingProvider } from "./embeddings/provid
|
|
|
34
34
|
import { CosineSimilarity } from "./embeddings/similarity.js";
|
|
35
35
|
import { EmbeddingStorage } from "./embeddings/storage.js";
|
|
36
36
|
import { DEFAULT_LIST_LIMIT, DEFAULT_LIST_ORDER_BY, MAX_LIST_LIMIT, QueryBoundsError, QueryOrderByError, buildDefaultListOrderBy, resolveListLimit, resolveListOffset } from "./query-bounds.js";
|
|
37
|
+
import { assertScopedPackageName, createQualifiedName, getClassName, getPackageFromQualifiedName, isFromPackage, isQualifiedName, isScopedPackageName, isType, parseQualifiedName, qualifiedNamesEqual } from "./utils/qualified-names.js";
|
|
38
|
+
import { SMRT_COLLECTION_BASE_NAMES, isSmrtCollectionExtendsName } from "./registry/collection-resolution.js";
|
|
39
|
+
import { isFrameworkBaseClass } from "./registry/framework-base-classes.js";
|
|
37
40
|
import { resetVerifiedTables } from "./table-cache.js";
|
|
38
41
|
import { DEFAULT_FACET_LIMIT, EmbeddingUnavailableError, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_STI_READ_SCOPE_TYPES, SmrtCollection } from "./collection.js";
|
|
39
42
|
import { applyPendingDecoratorRegistrations, registerCompatibleFieldDecorator, registerCompatibleMethodDecorator } from "./decorators/compatibility.js";
|
|
40
43
|
import { clone, getAdapterInfo, isValid, parse, safeParse, safeStringify, stringify } from "./utils/json.js";
|
|
41
|
-
import { assertScopedPackageName, createQualifiedName, getClassName, getPackageFromQualifiedName, isFromPackage, isQualifiedName, isScopedPackageName, isType, parseQualifiedName, qualifiedNamesEqual } from "./utils/qualified-names.js";
|
|
42
44
|
import { discoverManifestEntry, findManifestEntryByQualifiedName, loadExternalManifest, loadExternalManifestSync, loadLocalTestManifestSync, loadManifestFromPathSync } from "./manifest/manifest-loader.js";
|
|
43
45
|
import { ContentHasher } from "./embeddings/hash.js";
|
|
44
46
|
import { POSTGRES_REVISION_GUARD_EXPRESSION, postgresRevisionCandidates, postgresRevisionCondition } from "./revision-guard.js";
|
|
45
47
|
import { executeToolCall, executeToolCalls, formatToolResults, validateToolCall } from "./tools/tool-executor.js";
|
|
46
48
|
import { SmrtObject } from "./object.js";
|
|
47
|
-
import { isFrameworkBaseClass } from "./registry/framework-base-classes.js";
|
|
48
49
|
import { isDatabaseInterface, resolveDatabase } from "./database.js";
|
|
49
|
-
import { SMRT_COLLECTION_BASE_NAMES, isSmrtCollectionExtendsName } from "./registry/collection-resolution.js";
|
|
50
50
|
import { ObjectRegistry, smrt } from "./registry.js";
|
|
51
51
|
import { auditChanges, auditSnapshot, getActiveAuditOptions, isAudited, requireAuditOptions, writeAudit } from "./audit.js";
|
|
52
52
|
import { withAuditContext } from "./audit-context.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createQualifiedName, isQualifiedName, parseQualifiedName } from "../utils/qualified-names.js";
|
|
1
2
|
import { bumpRegistryGeneration } from "../registry/generation.js";
|
|
2
3
|
import "../scanner/types.js";
|
|
3
4
|
import { parse } from "../utils/json.js";
|
|
4
|
-
import { createQualifiedName, isQualifiedName, parseQualifiedName } from "../utils/qualified-names.js";
|
|
5
5
|
import { isDecoratorRuntimeFramePath, isDecoratorRuntimePackageName, isModuleRunnerFramePath, isSmrtCoreFramePath } from "../utils/stack-frames.js";
|
|
6
6
|
import { getLocalTestManifestCache as getLocalTestManifestCache$1, getManifestCache, getStaticManifestCache as getStaticManifestCache$1, getTestManifestCache as getTestManifestCache$1, isTestEnvironment as isTestEnvironment$1, shouldLoadCoreTestManifest } from "./store.js";
|
|
7
7
|
import { dirname, existsSync, join, readFileSync, readdirSync, require, statSync } from "./node-host.js";
|