From 7f28a05ed3cce03871514ea46a89cb13939351e2 Mon Sep 17 00:00:00 2001 From: seb Date: Fri, 16 Oct 2026 16:36:32 +0200 Subject: [PATCH] u --- ...rocess-incoming-product-and-invoices.SKILL | 95 +------------------ src/services/conversationManager.js | 2 + src/tools/draft-delivery-manifest.js | 87 +++++++++++++++++ src/tools/subagent.js | 2 + 4 files changed, 93 insertions(+), 93 deletions(-) create mode 100644 src/tools/draft-delivery-manifest.js diff --git a/src/defaultSkills/process-incoming-product-and-invoices.SKILL b/src/defaultSkills/process-incoming-product-and-invoices.SKILL index 6215e1f..5c20992 100644 --- a/src/defaultSkills/process-incoming-product-and-invoices.SKILL +++ b/src/defaultSkills/process-incoming-product-and-invoices.SKILL @@ -1,96 +1,5 @@ -Process Incoming Product and Invoices: Document Extraction & Manifests +Process Incoming Product and Invoices: use draft_delivery_manifest tool to store parsed invoice # Overview -This skill guides the automated and interactive processing of inbound supplier documents (invoices / *Rechnungen* and delivery notes / *Lieferscheine*). -It covers: -- **Document Data Extraction**: Extracting structured metadata, packaging units (VPE), units of measurement, line items, and notes from document text or images. -- **Delta & Batching Updates**: Formatting and returning extracted product and document metadata via the `output_manifest` tool. - ---- - -# 2. Extraction Tool Specification (`output_manifest`) - -The extraction engine outputs structured findings via the `output_manifest` tool call. - -```json -{ - "name": "output_manifest", - "description": "Stores extracted invoice/delivery-note data: header metadata (basedata), notes, and product line items. Each component is strictly optional — only include the ones that carry new data.", - "strict": false, - "parameters": { - "type": "object", - "additionalProperties": false, - "required": [], - "properties": { - "basedata": { - "anyOf": [ - { - "type": "object", - "additionalProperties": false, - "properties": { - "date": { "type": ["string", "null"], "description": "Document date (ISO 8601, YYYY-MM-DD)" }, - "lieferant_id": { "type": ["number", "null"], "description": "Lieferant ID if matched, else null" }, - "lieferantName": { "type": "string", "description": "Supplier name" }, - "manifestNr": { "type": ["string", "null"], "description": "Lieferscheinnummer or Rechnungsnummer" }, - "manifestType": { - "anyOf": [ - { "type": "string", "enum": ["rechnung", "lieferschein"] }, - { "type": "null" } - ], - "description": "Document type" - } - } - }, - { "type": "null" } - ], - "description": "Header/metadata. Only include fields that are currently missing or changed." - }, - "notes": { - "anyOf": [ - { "type": "array", "items": { "type": "string" } }, - { "type": "null" } - ], - "description": "New noteworthy details (in German), for a human to double-check the result." - }, - "items": { - "anyOf": [ - { - "type": "object", - "additionalProperties": false, - "properties": { - "numberOfItemsToAdd": { "type": "number", "description": "Number of NEW line items being added in this call." }, - "items": { - "type": "array", - "description": "Invoice/delivery product line items", - "items": { - "type": "object", - "additionalProperties": false, - "required": ["position", "count", "vpe", "unit", "articleName", "liefArtNr", "mwst", "eknetto"], - "properties": { - "position": { "type": "number", "description": "Position number" }, - "count": { "type": "number", "description": "Quantity (Menge)" }, - "vpe": { "type": "number", "description": "Packaging unit size (VPE). Default: 1." }, - "unit": { "type": "string", "description": "Unit of the individual sellable item. NEVER 'VE' or 'VPE'." }, - "articleName": { "type": "string", "description": "Article name" }, - "liefArtNr": { "type": "string", "description": "Supplier article number" }, - "mwst": { - "anyOf": [{ "type": "string", "enum": ["7", "19"] }, { "type": "null" }], - "description": "VAT rate percentage; null if delivery note or missing" - }, - "eknetto": { "type": ["number", "null"], "description": "Net purchase price per VPE in euro cents; null if missing" } - } - } - } - } - }, - { "type": "null" } - ], - "description": "New product line items." - } - } - } -} -``` - - +use draft_delivery_manifest tool to store parsed invoice \ No newline at end of file diff --git a/src/services/conversationManager.js b/src/services/conversationManager.js index 60c4ae2..80071f3 100644 --- a/src/services/conversationManager.js +++ b/src/services/conversationManager.js @@ -28,6 +28,7 @@ import { createSearchArticlesTool } from '../tools/search-articles.js'; import { createEanChecksumTool } from '../tools/ean-checksum.js'; import { createNetGrossCalcTool } from '../tools/net-gross-calc.js'; import { createSetUserRouteTool } from '../tools/set-user-route.js'; +import { createDraftDeliveryManifestTool } from '../tools/draft-delivery-manifest.js'; import { createSubagentTool } from '../tools/subagent.js'; import { resolveOpenRouterKey, resolveDefaultModel, resolveModelReasoning, RETIRED_MODELS, hasConfiguredOpenRouterKey } from '../tools/llm-key.js'; @@ -759,6 +760,7 @@ export class ConversationManager { this.broadcast('route', { route }); }, }), + createDraftDeliveryManifestTool(), createSubagentTool({ googleAuthId, companyId: this.companyId, diff --git a/src/tools/draft-delivery-manifest.js b/src/tools/draft-delivery-manifest.js new file mode 100644 index 0000000..7a139ce --- /dev/null +++ b/src/tools/draft-delivery-manifest.js @@ -0,0 +1,87 @@ +import { defineTool } from 'libllmorbiter'; + +/** + * Creates the draft_delivery_manifest tool. + * Stores extracted invoice/delivery-note data: header metadata (basedata), notes, and product line items. + */ +export function createDraftDeliveryManifestTool() { + return defineTool({ + name: 'draft_delivery_manifest', + description: + 'Stores extracted invoice/delivery-note data: header metadata (basedata), notes, and product line items. Each component is strictly optional — only include the ones that carry new data.', + strict: false, + parameters: { + type: 'object', + additionalProperties: false, + required: [], + properties: { + basedata: { + anyOf: [ + { + type: 'object', + additionalProperties: false, + properties: { + date: { type: ['string', 'null'], description: 'Document date (ISO 8601)' }, + lieferant_id: { type: ['number', 'null'], description: 'Lieferant ID' }, + lieferantName: { type: 'string', description: 'Lieferant name' }, + manifestNr: { type: ['string', 'null'], description: 'Lieferscheinnummer or Rechnungsnummer' }, + manifestType: { + anyOf: [ + { type: 'string', enum: ['rechnung', 'lieferschein'] }, + { type: 'null' }, + ], + description: 'Document type', + }, + }, + }, + { type: 'null' }, + ], + description: 'Header/metadata. Only include fields that are currently missing or changed.', + }, + notes: { + anyOf: [ + { type: 'array', items: { type: 'string' } }, + { type: 'null' }, + ], + description: 'New noteworthy details (in German), for a human to double-check the result.', + }, + items: { + anyOf: [ + { + type: 'object', + additionalProperties: false, + properties: { + numberOfItemsToAdd: { type: 'number', description: 'Number of NEW line items being added in this call.' }, + items: { + type: 'array', + description: 'Invoice/delivery product line items', + items: { + type: 'object', + additionalProperties: false, + required: ['position', 'count', 'vpe', 'unit', 'articleName', 'liefArtNr', 'mwst', 'eknetto'], + properties: { + position: { type: 'number', description: 'Position' }, + count: { type: 'number', description: 'Quantity (Menge)' }, + vpe: { type: 'number', description: 'Packaging unit size (VPE). Default: 1.' }, + unit: { type: 'string', description: 'Unit of the individual sellable item. NEVER "VE" or "VPE".' }, + articleName: { type: 'string', description: 'Article name' }, + liefArtNr: { type: 'string', description: 'Supplier article number' }, + mwst: { + anyOf: [{ type: 'string', enum: ['7', '19'] }, { type: 'null' }], + description: 'VAT rate; null if missing', + }, + eknetto: { type: ['number', 'null'], description: 'Net price per vpe in euro cents; null if missing' }, + }, + }, + }, + }, + }, + { type: 'null' }, + ], + description: 'New product line items.', + }, + }, + }, + invoke: async () => ({ success: true }), + }); +} diff --git a/src/tools/subagent.js b/src/tools/subagent.js index 5bd526f..e6654d9 100644 --- a/src/tools/subagent.js +++ b/src/tools/subagent.js @@ -28,6 +28,7 @@ import { createApiSuggestionsOrIssuesTool } from './apisuggestionsorissues.js'; import { createSearchArticlesTool } from './search-articles.js'; import { createEanChecksumTool } from './ean-checksum.js'; import { createNetGrossCalcTool } from './net-gross-calc.js'; +import { createDraftDeliveryManifestTool } from './draft-delivery-manifest.js'; /** * subagent — delegates a self-contained task to an isolated LLMOrbiter run that lives in @@ -179,6 +180,7 @@ function createSubagentTools({ googleAuthId, companyId, model }) { createSearchArticlesTool({ googleAuthId, companyId }), createEanChecksumTool(), createNetGrossCalcTool(), + createDraftDeliveryManifestTool(), ]; }