This commit is contained in:
seb
2026-10-06 04:43:35 +02:00
parent 75ab6ce171
commit fe5990af9f
8 changed files with 571 additions and 104 deletions

View File

@@ -23,6 +23,7 @@ import { createAnalyzeImageTool } from '../tools/analyze-image.js';
import { createWebSearchTool } from '../tools/web-search.js';
import { createUrlGetTool } from '../tools/url-get.js';
import { createPdfReadTool } from '../tools/pdf-read.js';
import { createSearchArticlesTool } from '../tools/search-articles.js';
import { resolveOpenRouterKey, resolveDefaultModel, RETIRED_MODELS, hasConfiguredOpenRouterKey } from '../tools/llm-key.js';
const KEEP_ALIVE_MS = 20_000;
@@ -123,6 +124,7 @@ async function buildSystemPrompt(vfsRoot, googleAuthId) {
'12. reset_vfs: Delete VFS files/artifacts. Preserves SKILL files.',
'13. rm: Delete single VFS file (used to delete SKILL files or specific artifacts).',
'14. apisuggestionsorissues: Report missing API endpoints, bugs, or issues for triage.',
'15. search_articles: Search articles across name, brand, EAN, SKU, and supplier SKU. Returns window of full articles (default 3, max 20), offset, and total count.',
'',
'VIRTUAL FILESYSTEM:',
'- Persistent per-company VFS. Paths are root-relative forward-slash (e.g. "labels/sheet1.png").',
@@ -138,15 +140,24 @@ async function buildSystemPrompt(vfsRoot, googleAuthId) {
'',
'IMAGES:',
'- Evaluate images via analyze_image; report model findings.',
'- Flow: search_images("query") → analyze_image({ paths: [...], prompt: "…" }) → upload via dashback_request.',
'- Flow: search_images("query") → analyze_image({ paths: [...], prompt: "…" }) → upload via fetch in javascript_execute.',
'- `image/` is READ-ONLY database storage. Write generated images elsewhere (e.g. "images/…").',
'',
'OPERATING GUIDELINES:',
'- GROSS vs NET PRICES: User prices are almost always GROSS (incl. VAT); API requires NET. Formula: `net = gross / (1 + taxRate / 100)`. Compute in javascript_execute with high precision (4–6 decimals) to prevent rounding error.',
'- DISPLAYING GENERATED IMAGES: Inline markdown images supported. Embed written VFS image paths: `![descriptive alt](artifacts/example.png)`. Other files (PDF, JSON, CSV) do not render inline; provide download links.',
'- LABEL TEMPLATES (/labeltemplate): Must use Dashback JSON schema `{ "objects": [ ... ] }`. Do NOT use ZPL.',
'- Format output with markdown tables, bullet points, or bold key-value pairs.',
...(routesDoc ? ['', 'DASHBACK API ROUTES:', routesDoc] : []),
'- Always Format output with markdown and emoji.',
...(routesDoc ? [
'',
'DASHBACK API ROUTES:',
'Binary image upload routes (use via fetch() in javascript_execute with image/avif buffer body):',
'- POST /article/{sku}/image (Params: sku: str, body: image/avif -> 201 { image: { picId: int, sort: int, full: { w, h, size }, thumb: { w, h }, hash: str, thumbHash: str } })',
'- POST /category/{id}/image (Params: id: int, body: image/avif -> 201 { category: { id: int, thumbW: int, thumbH: int, thumbHash: str } })',
'- POST /brand/{id}/image (Params: id: int, body: image/avif -> 201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: [...] } })',
'',
routesDoc,
] : []),
].join('\n');
const sections = [];
@@ -632,6 +643,7 @@ export class ConversationManager {
createPdfReadTool({ googleAuthId }),
createResetVfsTool({ googleAuthId }),
createApiSuggestionsOrIssuesTool({ googleAuthId, companyId: this.companyId }),
createSearchArticlesTool({ googleAuthId, companyId: this.companyId }),
],
});