This commit is contained in:
seb
2026-10-12 13:52:13 +02:00
parent 1f09e620e3
commit 280ed1b2b8

View File

@@ -1,9 +1,39 @@
import * as dbCompanySetting from '../db/companysetting.js'; import * as dbCompanySetting from '../db/companysetting.js';
import { listSkillFiles } from './skill.js'; import { listSkillFiles } from './skill.js';
// #region Tool Prompts & Descriptions // #region System Prompt
const NOTE_DESC = 'Status message shown to the user during execution.'; export const SYSTEM_PROMPT_RULES = [
'RULES & VFS:',
'- VFS: Persistent root-relative paths ("labels/sheet1.png"). Uploads land in "attachments/..." ([ATTACHMENT name= path= type=]); inspect via read_file, pdf_read, analyze_image, or javascript_execute + ExcelJS. Can host static sites.',
'- Links: Web links use "https://..." or domains; relative paths format as [label](relative/path). Inline images: ![alt](images/path.avif). Other files require download links.',
'- SKILLS: Flat root "<slug>.SKILL" markdown files. ALWAYS read_file matching skill BEFORE executing covered tasks. Exempt from reset_vfs.',
'- API: Routes are not inlined. BEFORE dashback_request, read_file the api-<section>.SKILL for parameters and response structures. api-binary-streaming-routes.SKILL covers fetch()-only upload/stream endpoints.',
'- Types: T<n> refers to globally shared object schemas across skills.',
'- Images: Pipeline: search_images -> analyze_image -> upload via fetch() in javascript_execute. "image/" is read-only; write generated assets to "images/...".',
'- Labels: Use Dashback JSON `{ "objects": [ ... ] }` for /labeltemplate. Never use ZPL.',
'- Navigation: Call set_user_route when the user asks to open or view any page/entity.',
].join('\n');
export const SYSTEM_PROMPT_ROUTE_MATRIX = [
'ROUTE MATRIX (client German, API skills = api-<section>):',
'- Search: /artikel?target={query}&filter={filter}&offset={n} -> article, category, brand',
'- Article Detail: /artikel/${sku} -> article, category, brand, attributename, propertyname, unit, supplier, printer, labeltemplate, ledger',
'- Warehouse / Stock: /artikel/lager -> warehouse, stock, ledger',
'- Brands: /artikel/marken -> brand',
'- Label Templates: /artikel/vorlagen -> labeltemplate, printer',
'- Attributes: /artikel/merkmale -> attributename, attributevalue, propertyname',
'- Categories: /kategorien | /kategorien/${slug1}/${slug2} -> category, article',
'- Deliveries: /lieferung | /lieferung/neu | /lieferung/${deliveryId} | /lieferung/lieferanten -> delivery, supplier, article, warehouse, stock, ledger',
'- Quotes: /auftrag | /auftrag/neu | /auftrag/${quoteId} -> quote, entity, article',
'- Orders: /auftrag/bestellung | /auftrag/bestellung/neu | /auftrag/bestellung/${orderId} -> order, entity, account, payment, shipping, package',
'- Customers: /kunde | /kunde/neu | /kunde/${entityId} | /kunde/gruppen -> entity, customergroup, number',
'- History & Stats: /infos/articlehistory | /infos/globalhistory | /infos/statistics -> article, company, order, delivery, ledger',
].join('\n');
// #endregion
// #region Tool Prompts
/** /**
* Descriptions for all tools registered in the agent's toolbelt. * Descriptions for all tools registered in the agent's toolbelt.
@@ -58,7 +88,7 @@ export const TOOL_DESCRIPTIONS = {
'Search articles by name, brand, EAN, SKU, or supplier SKU (AND logic, ordered by name).', 'Search articles by name, brand, EAN, SKU, or supplier SKU (AND logic, ordered by name).',
edit_image: edit_image:
'Generate or edit images via modelslugimage. Supports reference image attachments, size tier, ratio, and VFS AVIF output.', 'Generate or edit images via a vision model. Supports reference image attachments, size tier, ratio, and VFS AVIF output.',
ean_checksum: ean_checksum:
'Validate or calculate check digits for EAN-13, EAN-8, UPC-A, and GTIN-14 barcodes.', 'Validate or calculate check digits for EAN-13, EAN-8, UPC-A, and GTIN-14 barcodes.',
@@ -70,7 +100,11 @@ export const TOOL_DESCRIPTIONS = {
'Navigate user to a frontend route when asked to view/open an entity or page (see ROUTE MATRIX in prompt).', 'Navigate user to a frontend route when asked to view/open an entity or page (see ROUTE MATRIX in prompt).',
}; };
// #region Tool Parameter Descriptions // #endregion
// #region Tool Parameters
const NOTE_DESC = 'Status message shown to the user during execution.';
/** /**
* Descriptions for tool input parameters across src/tools/*. * Descriptions for tool input parameters across src/tools/*.
@@ -213,47 +247,10 @@ export const TOOL_PARAMETER_DESCRIPTIONS = {
export const PATCH_PARAMETER_DESCRIPTIONS = TOOL_PARAMETER_DESCRIPTIONS.patch; export const PATCH_PARAMETER_DESCRIPTIONS = TOOL_PARAMETER_DESCRIPTIONS.patch;
export const PATCH_PARAM_DESCRIPTIONS = TOOL_PARAMETER_DESCRIPTIONS.patch; export const PATCH_PARAM_DESCRIPTIONS = TOOL_PARAMETER_DESCRIPTIONS.patch;
// #endregion
// #region Tool-specific Subprompts
export const ANALYZE_IMAGE_VISION_COMPARE_PROMPT = export const ANALYZE_IMAGE_VISION_COMPARE_PROMPT =
'Compare these images, evaluate visual quality, flag watermarks/overlays/defects, and state the best candidate with rationale.'; 'Compare these images, evaluate visual quality, flag watermarks/overlays/defects, and state the best candidate with rationale.';
export const ANALYZE_IMAGE_VISION_DESCRIBE_PROMPT = export const ANALYZE_IMAGE_VISION_DESCRIBE_PROMPT =
'Describe this image, evaluate visual quality, flag watermarks/overlays/defects, and verify suitability as a product/category image.'; 'Describe this image, evaluate visual quality, flag watermarks/overlays/defects, and verify suitability as a product/category image.';
// #endregion
// #endregion
// #region System Prompt Components
export const SYSTEM_PROMPT_RULES = [
'RULES & VFS:',
'- VFS: Persistent root-relative paths ("labels/sheet1.png"). Uploads land in "attachments/..." ([ATTACHMENT name= path= type=]); inspect via read_file, pdf_read, analyze_image, or javascript_execute + ExcelJS. Can host static sites.',
'- Links: Web links use "https://..." or domains; relative paths format as [label](relative/path). Inline images: ![alt](images/path.avif). Other files require download links.',
'- SKILLS: Flat root "<slug>.SKILL" markdown files. ALWAYS read_file matching skill BEFORE executing covered tasks. Exempt from reset_vfs.',
'- API: Routes are not inlined. BEFORE dashback_request, read_file the api-<section>.SKILL for parameters and response structures. api-binary-streaming-routes.SKILL covers fetch()-only upload/stream endpoints.',
'- Types: T<n> refers to globally shared object schemas across skills.',
'- Images: Pipeline: search_images -> analyze_image -> upload via fetch() in javascript_execute. "image/" is read-only; write generated assets to "images/...".',
'- Labels: Use Dashback JSON `{ "objects": [ ... ] }` for /labeltemplate. Never use ZPL.',
'- Navigation: Call set_user_route when the user asks to open or view any page/entity.',
].join('\n');
export const SYSTEM_PROMPT_ROUTE_MATRIX = [
'ROUTE MATRIX (client German, API skills = api-<section>):',
'- Search: /artikel?target={query}&filter={filter}&offset={n} -> article, category, brand',
'- Article Detail: /artikel/${sku} -> article, category, brand, attributename, propertyname, unit, supplier, printer, labeltemplate, ledger',
'- Warehouse / Stock: /artikel/lager -> warehouse, stock, ledger',
'- Brands: /artikel/marken -> brand',
'- Label Templates: /artikel/vorlagen -> labeltemplate, printer',
'- Attributes: /artikel/merkmale -> attributename, attributevalue, propertyname',
'- Categories: /kategorien | /kategorien/${slug1}/${slug2} -> category, article',
'- Deliveries: /lieferung | /lieferung/neu | /lieferung/${deliveryId} | /lieferung/lieferanten -> delivery, supplier, article, warehouse, stock, ledger',
'- Quotes: /auftrag | /auftrag/neu | /auftrag/${quoteId} -> quote, entity, article',
'- Orders: /auftrag/bestellung | /auftrag/bestellung/neu | /auftrag/bestellung/${orderId} -> order, entity, account, payment, shipping, package',
'- Customers: /kunde | /kunde/neu | /kunde/${entityId} | /kunde/gruppen -> entity, customergroup, number',
'- History & Stats: /infos/articlehistory | /infos/globalhistory | /infos/statistics -> article, company, order, delivery, ledger',
].join('\n');
// #endregion // #endregion
@@ -290,7 +287,7 @@ export function buildSkillIndex(vfsRoot) {
// #endregion // #endregion
// #region System Prompt // #region Factory
/** /**
* System prompt: base instructions and contextual index. * System prompt: base instructions and contextual index.