@things-factory/ai-assistant 10.1.207 → 10.1.210
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/client/components/assistant-chat.ts +238 -9
- package/client/components/assistant-dock.ts +9 -4
- package/client/components/assistant-invite.ts +138 -0
- package/client/components/assistant-session-manager.ts +53 -12
- package/client/components/proposal-request.test.ts +10 -0
- package/client/components/roster-identity.test.ts +2 -12
- package/client/components/roster-identity.ts +0 -6
- package/client/setup-assistant-dock.ts +1 -0
- package/client/utils/assistant-session-actions.ts +3 -1
- package/client/utils/assistant-session-admin.ts +9 -2
- package/client/utils/assistant-session-controller.ts +1 -1
- package/client/utils/assistant-typing.test.ts +33 -0
- package/client/utils/assistant-typing.ts +53 -0
- package/dist-client/components/assistant-chat.d.ts +28 -0
- package/dist-client/components/assistant-chat.js +259 -8
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/components/assistant-dock.js +12 -4
- package/dist-client/components/assistant-dock.js.map +1 -1
- package/dist-client/components/assistant-invite.d.ts +39 -0
- package/dist-client/components/assistant-invite.js +150 -0
- package/dist-client/components/assistant-invite.js.map +1 -0
- package/dist-client/components/assistant-session-manager.d.ts +5 -1
- package/dist-client/components/assistant-session-manager.js +40 -10
- package/dist-client/components/assistant-session-manager.js.map +1 -1
- package/dist-client/components/proposal-request.test.js +8 -0
- package/dist-client/components/proposal-request.test.js.map +1 -1
- package/dist-client/components/roster-identity.d.ts +0 -2
- package/dist-client/components/roster-identity.js +0 -7
- package/dist-client/components/roster-identity.js.map +1 -1
- package/dist-client/components/roster-identity.test.js +2 -13
- package/dist-client/components/roster-identity.test.js.map +1 -1
- package/dist-client/setup-assistant-dock.js +1 -0
- package/dist-client/setup-assistant-dock.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/assistant-session-actions.d.ts +1 -0
- package/dist-client/utils/assistant-session-actions.js +3 -1
- package/dist-client/utils/assistant-session-actions.js.map +1 -1
- package/dist-client/utils/assistant-session-admin.d.ts +5 -2
- package/dist-client/utils/assistant-session-admin.js +3 -0
- package/dist-client/utils/assistant-session-admin.js.map +1 -1
- package/dist-client/utils/assistant-session-controller.d.ts +1 -1
- package/dist-client/utils/assistant-session-controller.js.map +1 -1
- package/dist-client/utils/assistant-typing.d.ts +20 -0
- package/dist-client/utils/assistant-typing.js +48 -0
- package/dist-client/utils/assistant-typing.js.map +1 -0
- package/dist-client/utils/assistant-typing.test.d.ts +1 -0
- package/dist-client/utils/assistant-typing.test.js +30 -0
- package/dist-client/utils/assistant-typing.test.js.map +1 -0
- package/dist-server/service/assistant-chat-resolver.js +5 -12
- package/dist-server/service/assistant-chat-resolver.js.map +1 -1
- package/dist-server/service/assistant-mode/index.d.ts +1 -1
- package/dist-server/service/assistant-mode/index.js +4 -1
- package/dist-server/service/assistant-mode/index.js.map +1 -1
- package/dist-server/service/assistant-mode/mode-categories.js +9 -2
- package/dist-server/service/assistant-mode/mode-categories.js.map +1 -1
- package/dist-server/service/assistant-mode/screen-rules.d.ts +19 -0
- package/dist-server/service/assistant-mode/screen-rules.js +40 -6
- package/dist-server/service/assistant-mode/screen-rules.js.map +1 -1
- package/dist-server/service/chat-message/chat-message-room.js +3 -1
- package/dist-server/service/chat-message/chat-message-room.js.map +1 -1
- package/dist-server/service/chat-message/chat-typing-subscription.d.ts +10 -0
- package/dist-server/service/chat-message/chat-typing-subscription.js +68 -0
- package/dist-server/service/chat-message/chat-typing-subscription.js.map +1 -0
- package/dist-server/service/chat-message/chat-typing.d.ts +28 -0
- package/dist-server/service/chat-message/chat-typing.js +40 -0
- package/dist-server/service/chat-message/chat-typing.js.map +1 -0
- package/dist-server/service/chat-session/attachment-tool-result.d.ts +1 -0
- package/dist-server/service/chat-session/attachment-tool-result.js +6 -0
- package/dist-server/service/chat-session/attachment-tool-result.js.map +1 -1
- package/dist-server/service/chat-session/attachment-tools.js +2 -2
- package/dist-server/service/chat-session/attachment-tools.js.map +1 -1
- package/dist-server/service/chat-session/chat-session.d.ts +2 -1
- package/dist-server/service/chat-session/chat-session.js +1 -1
- package/dist-server/service/chat-session/chat-session.js.map +1 -1
- package/dist-server/service/chat-session/session-activity-broadcast.d.ts +12 -0
- package/dist-server/service/chat-session/session-activity-broadcast.js +15 -0
- package/dist-server/service/chat-session/session-activity-broadcast.js.map +1 -1
- package/dist-server/service/chat-session/session-activity-publish.d.ts +2 -0
- package/dist-server/service/chat-session/session-activity-publish.js +5 -2
- package/dist-server/service/chat-session/session-activity-publish.js.map +1 -1
- package/dist-server/service/chat-session/session-visibility.d.ts +17 -2
- package/dist-server/service/chat-session/session-visibility.js +28 -3
- package/dist-server/service/chat-session/session-visibility.js.map +1 -1
- package/dist-server/service/chat-session/session-write-gate.d.ts +1 -1
- package/dist-server/service/chat-session/session-write-gate.js +1 -1
- package/dist-server/service/chat-session/session-write-gate.js.map +1 -1
- package/dist-server/service/chat-session-participant/index.d.ts +1 -0
- package/dist-server/service/chat-session-participant/index.js +4 -1
- package/dist-server/service/chat-session-participant/index.js.map +1 -1
- package/dist-server/service/chat-session-participant/invite-notification.d.ts +16 -1
- package/dist-server/service/chat-session-participant/invite-notification.js +34 -5
- package/dist-server/service/chat-session-participant/invite-notification.js.map +1 -1
- package/dist-server/service/chat-session-participant/mention-invite.d.ts +30 -4
- package/dist-server/service/chat-session-participant/mention-invite.js +78 -31
- package/dist-server/service/chat-session-participant/mention-invite.js.map +1 -1
- package/dist-server/service/chat-session-participant/read-roster.js +5 -2
- package/dist-server/service/chat-session-participant/read-roster.js.map +1 -1
- package/dist-server/service/chat-session-resolver.d.ts +27 -0
- package/dist-server/service/chat-session-resolver.js +226 -25
- package/dist-server/service/chat-session-resolver.js.map +1 -1
- package/dist-server/service/data-entry/entry-target.d.ts +19 -0
- package/dist-server/service/data-entry/entry-target.js +20 -5
- package/dist-server/service/data-entry/entry-target.js.map +1 -1
- package/dist-server/service/data-entry/entry-tools.js +2 -2
- package/dist-server/service/data-entry/entry-tools.js.map +1 -1
- package/dist-server/service/data-entry/entry-update.d.ts +2 -1
- package/dist-server/service/data-entry/entry-update.js +5 -3
- package/dist-server/service/data-entry/entry-update.js.map +1 -1
- package/dist-server/service/data-read/list-read.d.ts +10 -0
- package/dist-server/service/data-read/list-read.js +12 -0
- package/dist-server/service/data-read/list-read.js.map +1 -1
- package/dist-server/service/data-read/read-target.d.ts +7 -0
- package/dist-server/service/data-read/read-target.js +2 -2
- package/dist-server/service/data-read/read-target.js.map +1 -1
- package/dist-server/service/data-read/read-tools.js +1 -1
- package/dist-server/service/data-read/read-tools.js.map +1 -1
- package/dist-server/service/index.d.ts +4 -2
- package/dist-server/service/index.js +9 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/testing/conversation-script.d.ts +1 -1
- package/dist-server/service/testing/conversation-script.js.map +1 -1
- package/dist-server/service/testing/mode-conformance.js +4 -0
- package/dist-server/service/testing/mode-conformance.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/server/explicit-graphql-types.test.ts +1 -1
- package/server/service/assistant-chat-resolver.ts +7 -12
- package/server/service/assistant-mode/index.ts +1 -1
- package/server/service/assistant-mode/mode-categories.ts +11 -3
- package/server/service/assistant-mode/mode-front.test.ts +53 -1
- package/server/service/assistant-mode/resolve.test.ts +2 -1
- package/server/service/assistant-mode/screen-rules.test.ts +41 -3
- package/server/service/assistant-mode/screen-rules.ts +44 -5
- package/server/service/chat-message/chat-message-room.test.ts +7 -2
- package/server/service/chat-message/chat-message-room.ts +3 -1
- package/server/service/chat-message/chat-typing-subscription.ts +52 -0
- package/server/service/chat-message/chat-typing.test.ts +45 -0
- package/server/service/chat-message/chat-typing.ts +48 -0
- package/server/service/chat-message/fold-history-window.test.ts +1 -1
- package/server/service/chat-session/attachment-tool-result.test.ts +9 -1
- package/server/service/chat-session/attachment-tool-result.ts +7 -0
- package/server/service/chat-session/attachment-tools.ts +3 -3
- package/server/service/chat-session/chat-session.ts +3 -2
- package/server/service/chat-session/group-room.test.ts +233 -0
- package/server/service/chat-session/session-activity-broadcast.ts +20 -0
- package/server/service/chat-session/session-activity-publish.ts +6 -1
- package/server/service/chat-session/session-activity-receivers.test.ts +26 -0
- package/server/service/chat-session/session-visibility.test.ts +32 -1
- package/server/service/chat-session/session-visibility.ts +33 -4
- package/server/service/chat-session/session-write-gate.test.ts +7 -1
- package/server/service/chat-session/session-write-gate.ts +2 -2
- package/server/service/chat-session-participant/index.ts +2 -0
- package/server/service/chat-session-participant/invite-notification.test.ts +36 -1
- package/server/service/chat-session-participant/invite-notification.ts +43 -5
- package/server/service/chat-session-participant/mention-invite.test.ts +49 -1
- package/server/service/chat-session-participant/mention-invite.ts +82 -28
- package/server/service/chat-session-participant/read-roster.test.ts +13 -4
- package/server/service/chat-session-participant/read-roster.ts +6 -3
- package/server/service/chat-session-resolver.ts +204 -27
- package/server/service/data-entry/data-entry-update.test.ts +19 -0
- package/server/service/data-entry/data-entry.test.ts +65 -1
- package/server/service/data-entry/entry-target.ts +36 -5
- package/server/service/data-entry/entry-tools.ts +2 -2
- package/server/service/data-entry/entry-update.ts +6 -3
- package/server/service/data-read/list-missing.test.ts +49 -0
- package/server/service/data-read/list-read.ts +18 -0
- package/server/service/data-read/read-target.ts +10 -3
- package/server/service/data-read/read-tools.ts +1 -1
- package/server/service/data-read/record-keys.test.ts +36 -0
- package/server/service/index.ts +6 -1
- package/server/service/testing/conversation-script.ts +1 -1
- package/server/service/testing/mode-conformance.ts +2 -0
- package/test/assistant-dock.test.ts +5 -1
- package/test/assistant-session-manager.test.ts +4 -2
- package/test/open-doors.test.ts +10 -5
- package/translations/en.json +29 -4
- package/translations/es.json +29 -4
- package/translations/ja.json +29 -4
- package/translations/ko.json +30 -5
- package/translations/ms.json +29 -4
- package/translations/zh.json +29 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-target.js","sourceRoot":"","sources":["../../../server/service/data-entry/entry-target.ts"],"names":[],"mappings":";;;AAi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istant can enter its records\n * (operato-application/design/ai/data-entry.md).\n *\n * A person hands the conversation what the records are made of - a bank export, a photo of a receipt,\n * lines pasted from a mail - and the assistant turns it into rows of one of the application's records.\n * Nothing is written by the model. It proposes the rows; the card shows them with what was wrong in\n * each and where each came from; a correction is said in the conversation and the model proposes again;\n * the person presses the button; the server enters each row **through the application's own GraphQL\n * mutation**, run with the person's request state - the same door, directives and checks as entering by hand.\n * There is no second way into the record.\n *\n * This file is pure - no framework, no database - so the rules a row passes are tested without a server.\n */\nimport { parse } from 'graphql'\n\nexport type EntryFieldType = 'string' | 'text' | 'number' | 'integer' | 'date' | 'datetime' | 'boolean' | 'enum' | 'reference'\n\nexport interface EntryField {\n name: string\n type: EntryFieldType\n required?: boolean\n /** The allowed values of an `enum` field. */\n values?: string[]\n /** What the model reads about the field - English, like every tool description. */\n description?: string\n /** i18n key of the column heading on the card. Absent: the field name. */\n labelKey?: string\n /** A number field the card sums - and compares with the total the material prints (§ totals). */\n total?: boolean\n /** An enum's values on the card: `<prefix><value in lowercase>` - `text.expense-payment-` shows PERSONAL_CARD as 개인카드. */\n valueKeyPrefix?: string\n /**\n * A `reference` field points at another record - a loan, an item, a location. The model knows it by a name or\n * a code; the server finds it through the application's query, as the person, and keeps its id. One match is\n * taken; none or several keep the row out and say so - the server never picks among several.\n */\n reference?: EntryReference\n}\n\nexport interface EntryReference {\n query: string\n /** The query's variables for what the model wrote - \"기업은행\", \"A-100\". */\n variables(text: string): Record<string, unknown>\n /** The records the answer holds that the text names - the application filters, the server does not guess. */\n recordsOf(data: any, text: string): { id: string; label?: string }[]\n}\n\n/** A resolved reference, as a row keeps it. */\nexport interface ReferenceValue {\n id: string\n label?: string\n}\n\n/** Where a row came from - which file, and where in it. Shown on the card beside the row. */\nexport interface EntrySource {\n attachmentId?: string\n /** \"row 3\", \"the receipt photo\" - the model's words, in the person's language. */\n where?: string\n /** The value came from what the person said in the conversation - shown in the screen's own words, never the model's. */\n person?: boolean\n}\n\nexport interface EntryIssue {\n /** The field it is about. Absent: the row as a whole. */\n field?: string\n /** A code the screen translates: `ai-assistant.entry.issue.<code>`, or the target's own `messageKey`. */\n code: string\n messageKey?: string\n params?: Record<string, unknown>\n /** A param that is a code the screen words - { status: 'text.state-' } shows `down` as 고장. */\n paramKeys?: Record<string, string>\n /** A blocking issue keeps the row out when the person presses the button. */\n blocking: boolean\n}\n\nexport interface EntryRowInput {\n values?: Record<string, unknown>\n sources?: EntrySource[]\n}\n\nexport interface EntryRow {\n index: number\n values: Record<string, unknown>\n sources: EntrySource[]\n issues: EntryIssue[]\n /** The line of a text source where this row's numbers and dates were all found - the server's check, not the model's word. */\n evidence?: { attachmentId: string; line: number }\n}\n\nexport interface EntryContext {\n /** The request state - domain, user, and when writing, `tx` and `afterCommit`. */\n state: any\n}\n\nexport interface EntryApplied {\n /** The created record's id, when there is one. */\n id?: string\n /** A short name for the conversation line - \"2026-09-12 · 택시 · ₩12,400\". */\n label?: string\n}\n\n/** What happened, for an application that writes down every assistant call (office's AI audit). */\nexport interface EntryEvent {\n phase: 'propose' | 'apply'\n tool: string\n rows: number\n ok: boolean\n applied?: number\n missed?: number\n error?: string\n /** propose: the rows as the model gave them; apply: the proposal key and each row's result. */\n detail?: unknown\n}\n\nexport interface EntryTarget {\n /** `<app>.<record>` - `office.expense-line`. */\n key: string\n /** i18n key of the record's name on the card. */\n labelKey: string\n /** What one row is, for the model. */\n description: string\n fields: EntryField[]\n /**\n * The application's own mutation that enters one record, as a GraphQL document with one root field -\n * `mutation ($line: NewExpenseLine!) { addExpenseLine(line: $line) { id } }`. Its root field is the door:\n * the propose tool is offered only to someone who passes it, and each row is entered by running it with\n * the person's request state, so `@privilege`, `@transaction` and the door's own checks apply as they do\n * to a person typing it in.\n */\n mutation: string\n /** The mutation's variables for one row. Absent when the target enters rows by group (below). */\n variables?(row: EntryRow): Record<string, unknown>\n /** What the conversation says of an entered row - its id and a short name. */\n appliedOf?(data: any, row: EntryRow): EntryApplied | undefined\n /**\n * A record with lines - one order, several item lines. Rows that share the value of `by` (the order number) are one\n * record, entered by one call of the mutation with `variables(rows)`. If any row of a group is kept out, the whole\n * group is: an order missing a line must not go in unseen.\n */\n group?: {\n by: string\n variables(rows: EntryRow[]): Record<string, unknown>\n appliedOf?(data: any, rows: EntryRow[]): EntryApplied | undefined\n }\n /** At most this many rows in one proposal. Default 200. */\n maxRows?: number\n /**\n * Read-only checks the application owns - a duplicate of what is already entered, a code that does not\n * exist. Asked when the rows are proposed and again when they are entered: the records may have moved.\n * Returns one list per row, in order.\n */\n check?(rows: EntryRow[], context: EntryContext): EntryIssue[][] | Promise<EntryIssue[][]>\n /** Told of every proposal and every entering - an application that audits its assistant writes it down. A throw is ignored. */\n record?(event: EntryEvent, context: EntryContext): void | Promise<void>\n /** Changing records that exist (design/ai/data-entry.md §5-1). Absent: this target only enters new ones. */\n update?: EntryUpdate\n}\n\n/** One record as the application's read query answers it - an `id` and the fields. */\nexport type EntryRecord = { id: string } & Record<string, unknown>\n\n/**\n * How records of a target are changed - every step through the application's API, as the person.\n *\n * Which record is meant is the server's to settle, never the model's memory: whichever way it was picked\n * (on screen, selected, described), the server reads it with `read` before a card is made and again before\n * it is written.\n */\nexport interface EntryUpdate {\n /** Reads the records by id, as the person - one they may not see is not found. */\n read: { query: string; variables(ids: string[]): Record<string, unknown>; recordsOf(data: any, ids: string[]): EntryRecord[] }\n /** Finds candidates from what the person said - \"last week's 12,400 taxi\". */\n find?: { query: string; variables(criteria: Record<string, unknown>): Record<string, unknown>; recordsOf(data: any, criteria: Record<string, unknown>): EntryRecord[]; criteria: EntryField[] }\n /** The application's own mutation that changes one record. */\n mutation: string\n variables(change: { id: string; record: EntryRecord; values: Record<string, unknown> }): Record<string, unknown>\n /** How a record is named on the card - \"2026-09-12 · 카카오T\". */\n labelOf?(record: EntryRecord): string\n /** The fields that may change. Default: every declared field. */\n fields?: string[]\n /**\n * Read-only checks of the changes - a new name that another record already has. Asked when the card is made and\n * again when it is pressed, like an entry's check; one issue list per row. Without it a clash is caught only by\n * the database's own refusal.\n */\n check?(rows: { id: string; record?: EntryRecord; values: Record<string, unknown> }[], context: EntryContext): EntryIssue[][] | Promise<EntryIssue[][]>\n}\n\n/**\n * `Mutation.<root field>` of the target's mutation - the one declaration both the tool's gate and the\n * entering read. A document that is not one mutation with one root field is refused at boot.\n */\nexport function entryDoorOf(mutation: string): string {\n return rootFieldOf(mutation, 'mutation')\n}\n\n/** `Query.<field>` or `Mutation.<field>` of a document with one operation and one root field. */\nexport function rootFieldOf(document: string, operation: 'query' | 'mutation'): string {\n const doc = parse(document)\n const operations = doc.definitions.filter((one: any) => one.kind === 'OperationDefinition') as any[]\n if (operations.length !== 1 || operations[0].operation !== operation) throw new Error(`is not one ${operation}`)\n const fields = operations[0].selectionSet.selections.filter((one: any) => one.kind === 'Field')\n if (fields.length !== 1) throw new Error('must have exactly one root field')\n return `${operation === 'query' ? 'Query' : 'Mutation'}.${fields[0].name.value}`\n}\n\n/** Tells the target, and never lets its record keeping stop the work. */\nexport async function recordEntryEvent(target: EntryTarget, event: EntryEvent, context: EntryContext): Promise<void> {\n if (!target.record) return\n try {\n await target.record(event, context)\n } catch {\n /* an audit that failed to write is the application's to report */\n }\n}\n\nexport const DEFAULT_MAX_ROWS = 200\n\n/* The model's way of saying a value came from the person - kept only to read older rows and loose words. */\nconst PERSON = /person|message|user|사용자|말/i\n\nconst targets = new Map<string, EntryTarget>()\n\nconst KEY = /^[a-z][a-z0-9-]*\\.[a-z][a-z0-9-]*$/\n\n/** Validates and keeps a target - `registerEntryTarget` (entry-tools.ts) also opens its tool. A malformed declaration is refused at boot, not in a conversation. */\nexport function declareEntryTarget(target: EntryTarget): void {\n if (!KEY.test(target?.key ?? '')) throw new Error(`[ai-assistant] entry target key '${target?.key}' is not '<app>.<record>'.`)\n try {\n entryDoorOf(target.mutation ?? '')\n } catch (error: any) {\n throw new Error(`[ai-assistant] entry target '${target.key}': its mutation ${error?.message ?? 'does not parse'}.`)\n }\n if (typeof target.variables !== 'function' && typeof target.group?.variables !== 'function')\n throw new Error(`[ai-assistant] entry target '${target.key}' has no variables (per row, or per group).`)\n if (target.group && !target.fields.some(field => field.name === target.group!.by))\n throw new Error(`[ai-assistant] entry target '${target.key}': group by '${target.group.by}' is not a declared field.`)\n if (target.update) {\n for (const [what, document, operation] of [\n ['update.read', target.update.read?.query, 'query'],\n ['update.mutation', target.update.mutation, 'mutation'],\n ...(target.update.find ? [['update.find', target.update.find.query, 'query']] : [])\n ] as [string, string, 'query' | 'mutation'][]) {\n try {\n rootFieldOf(document ?? '', operation)\n } catch (error: any) {\n throw new Error(`[ai-assistant] entry target '${target.key}': ${what} ${error?.message ?? 'does not parse'}.`)\n }\n }\n const known = new Set(target.fields.map(field => field.name))\n for (const name of target.update.fields ?? []) if (!known.has(name)) throw new Error(`[ai-assistant] entry target '${target.key}': update field '${name}' is not declared.`)\n }\n if (!target.fields?.length) throw new Error(`[ai-assistant] entry target '${target.key}' declares no fields.`)\n const names = new Set<string>()\n for (const field of target.fields) {\n if (field.type === 'reference') {\n try {\n rootFieldOf(field.reference?.query ?? '', 'query')\n } catch (error: any) {\n throw new Error(`[ai-assistant] entry target '${target.key}': reference field '${field.name}' ${error?.message ?? 'has no query'}.`)\n }\n }\n if (names.has(field.name)) throw new Error(`[ai-assistant] entry target '${target.key}' declares '${field.name}' twice.`)\n names.add(field.name)\n if (field.type === 'enum' && !field.values?.length)\n throw new Error(`[ai-assistant] entry target '${target.key}': enum field '${field.name}' lists no values.`)\n }\n targets.set(target.key, target)\n}\n\nexport function entryTargetOf(key: string | undefined): EntryTarget | undefined {\n return key ? targets.get(key) : undefined\n}\n\nexport function entryTargets(): EntryTarget[] {\n return [...targets.values()]\n}\n\n/** For tests. */\nexport function clearEntryTargets(): void {\n targets.clear()\n}\n\nconst pascalOf = (key: string) =>\n key\n .split(/[.-]/)\n .filter(Boolean)\n .map(part => part[0].toUpperCase() + part.slice(1))\n .join('')\n\n/** `office.expense-line` → `proposeOfficeExpenseLineChanges` / `findOfficeExpenseLine` - the tools of changing. */\nexport const changeToolName = (key: string) => `propose${pascalOf(key)}Changes`\nexport const findToolName = (key: string) => `find${pascalOf(key)}`\n\n/** `office.expense-line` → `proposeOfficeExpenseLineEntries` - one tool per target, so each has its own door. */\nexport function entryToolName(key: string): string {\n const pascal = key\n .split(/[.-]/)\n .filter(Boolean)\n .map(part => part[0].toUpperCase() + part.slice(1))\n .join('')\n return `propose${pascal}Entries`\n}\n\nexport function entryCategoryName(key: string): string {\n return `data-entry:${key}`\n}\n\nconst empty = (value: unknown) => value === undefined || value === null || (typeof value === 'string' && !value.trim())\n\n/** \"12,400\" · \"₩12,400\" · \"12 400\" → 12400. Only the separators people write; anything else is not a number. */\nfunction toNumber(value: unknown): number | undefined {\n if (typeof value === 'number') return Number.isFinite(value) ? value : undefined\n if (typeof value !== 'string') return undefined\n const cleaned = value.trim().replace(/^[₩$€¥£]\\s*/, '').replace(/[,\\s]/g, '').replace(/원$/, '')\n if (!/^-?\\d+(\\.\\d+)?$/.test(cleaned)) return undefined\n return Number(cleaned)\n}\n\n/** A calendar date as `YYYY-MM-DD` - \"2026.9.12\", \"2026/09/12\" too. A day that does not exist is not a date. */\nfunction toDate(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const match = value.trim().match(/^(\\d{4})[-./](\\d{1,2})[-./](\\d{1,2})\\.?$/)\n if (!match) return undefined\n const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])]\n const date = new Date(Date.UTC(year, month - 1, day))\n if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) return undefined\n return `${match[1]}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`\n}\n\n/**\n * A moment as `YYYY-MM-DDTHH:mm:ss`, with the offset when it was written - \"2026-10-01 08:30\", \"2026.10.1 8:30\",\n * an ISO string. Without an offset it stays without one: the application reads it in its own time zone, as it\n * reads a time typed into its own screen.\n */\nfunction toDateTime(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const match = value.trim().match(/^(\\d{4})[-./](\\d{1,2})[-./](\\d{1,2})[ T](\\d{1,2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?\\s*(Z|[+-]\\d{2}:?\\d{2})?$/)\n if (!match) return undefined\n const day = toDate(`${match[1]}-${match[2]}-${match[3]}`)\n const [hour, minute, second] = [Number(match[4]), Number(match[5]), Number(match[6] ?? 0)]\n if (!day || hour > 23 || minute > 59 || second > 59) return undefined\n const offset = match[7] ? (match[7] === 'Z' ? 'Z' : match[7].replace(/^([+-]\\d{2})(\\d{2})$/, '$1:$2')) : ''\n return `${day}T${String(hour).padStart(2, '0')}:${match[5]}:${String(second).padStart(2, '0')}${offset}`\n}\n\nfunction toBoolean(value: unknown): boolean | undefined {\n if (typeof value === 'boolean') return value\n if (typeof value !== 'string') return undefined\n const text = value.trim().toLowerCase()\n if (['true', 'yes', 'y', '1'].includes(text)) return true\n if (['false', 'no', 'n', '0'].includes(text)) return false\n return undefined\n}\n\n/** One value in its field's type - or the code of why it is not. An empty value is the caller's to judge. */\nexport function readFieldValue(field: EntryField, value: unknown): { read?: unknown; code?: string } {\n switch (field.type) {\n case 'number': {\n const read = toNumber(value)\n return read === undefined ? { code: 'not-a-number' } : { read }\n }\n case 'integer': {\n const read = toNumber(value)\n return read === undefined || !Number.isInteger(read) ? { code: 'not-an-integer' } : { read }\n }\n case 'date': {\n const read = toDate(value)\n return read === undefined ? { code: 'not-a-date' } : { read }\n }\n case 'datetime': {\n const read = toDateTime(value)\n return read === undefined ? { code: 'not-a-datetime' } : { read }\n }\n case 'boolean': {\n const read = toBoolean(value)\n return read === undefined ? { code: 'not-a-boolean' } : { read }\n }\n case 'enum':\n return field.values!.includes(String(value).trim()) ? { read: String(value).trim() } : { code: 'not-in-list' }\n case 'reference':\n /* Resolved already ({ id }), or a name to look up ({ text }) - resolveReferences settles the second. */\n if (value && typeof value === 'object' && typeof (value as any).id === 'string') return { read: { id: (value as any).id, ...((value as any).label ? { label: String((value as any).label) } : {}) } }\n if (value && typeof value === 'object' && typeof (value as any).text === 'string') return { read: { text: (value as any).text } }\n return typeof value === 'string' || typeof value === 'number' ? { read: { text: String(value).trim() } } : { code: 'not-a-reference' }\n default:\n return { read: String(value).trim() }\n }\n}\n\n/** Two values of one field the same - \"12400.00\" read from the database is 12400. */\nexport function sameFieldValue(field: EntryField, a: unknown, b: unknown): boolean {\n if (empty(a) && empty(b)) return true\n if (empty(a) || empty(b)) return false\n if (field.type === 'reference') {\n const idOf = (v: any) => (v && typeof v === 'object' ? v.id ?? v.text : String(v))\n return idOf(a) === idOf(b)\n }\n const x = readFieldValue(field, a)\n const y = readFieldValue(field, b)\n return x.read !== undefined && y.read !== undefined ? x.read === y.read : String(a) === String(b)\n}\n\n/**\n * The rows as the target reads them - each value in its field's type, and what was wrong said as an issue.\n *\n * A value that does not fit is **kept as it was written and marked**, never dropped or guessed: the card\n * shows what the material said, and the person corrects it in the conversation.\n */\nexport function normalizeEntryRows(target: EntryTarget, input: unknown): { rows: EntryRow[]; cut: number } {\n const list = Array.isArray(input) ? input : []\n const max = target.maxRows ?? DEFAULT_MAX_ROWS\n const fields = new Map(target.fields.map(field => [field.name, field]))\n\n const rows = list.slice(0, max).map((raw: any, index): EntryRow => {\n const given = raw && typeof raw.values === 'object' && raw.values ? raw.values : {}\n const values: Record<string, unknown> = {}\n const issues: EntryIssue[] = []\n\n for (const name of Object.keys(given)) {\n if (!fields.has(name)) issues.push({ field: name, code: 'unknown-field', blocking: false })\n }\n\n for (const field of target.fields) {\n const value = given[field.name]\n if (empty(value)) {\n if (field.required) issues.push({ field: field.name, code: 'required', blocking: true })\n continue\n }\n const { read, code } = readFieldValue(field, value)\n if (read === undefined) {\n values[field.name] = value\n issues.push({ field: field.name, code: code!, params: code === 'not-in-list' ? { values: field.values } : undefined, blocking: true })\n } else {\n values[field.name] = read\n }\n }\n\n const sources: EntrySource[] = Array.isArray(raw?.sources)\n ? raw.sources\n .filter((one: any) => one && (one.attachmentId || one.where || one.person === true))\n .map((one: any): EntrySource => {\n /* \"the person's message\" written by the model is the person flag - the screen says it in its own words. */\n if (one.person === true || (!one.attachmentId && typeof one.where === 'string' && PERSON.test(one.where))) return { person: true }\n return {\n ...(typeof one.attachmentId === 'string' ? { attachmentId: one.attachmentId } : {}),\n ...(typeof one.where === 'string' ? { where: one.where.slice(0, 120) } : {})\n }\n })\n : []\n if (!sources.length) issues.push({ code: 'no-source', blocking: false })\n\n return { index, values, sources, issues }\n })\n\n return { rows, cut: Math.max(0, list.length - max) }\n}\n\n/** Adds the target's own findings to each row. A check that throws marks nothing and is reported by the caller. */\nexport function withCheckedIssues(rows: EntryRow[], found: EntryIssue[][] | undefined): EntryRow[] {\n if (!found) return rows\n return rows.map((row, i) => (found[i]?.length ? { ...row, issues: [...row.issues, ...found[i]] } : row))\n}\n\nexport function isBlocked(row: EntryRow): boolean {\n return row.issues.some(issue => issue.blocking)\n}\n\n/* ── Checking the rows against the material (design/ai/data-entry.md §4-1) ─────────────────────────────\n *\n * A row cites where it came from; the model's word is not proof. For a text source the server looks: the\n * row's numbers and dates must stand together on one line of the cited file. Found - the row carries that\n * line as evidence. A value the file does not have is marked, unless the row also cites the person's\n * message (a correction said in the conversation). A photo cannot be read here - the row says so.\n * Names and descriptions are not looked for: the model tidies them, and a tidied name is not a wrong one.\n */\n\n\n/** The ways a number or a date is written in a file. */\nexport function writtenForms(type: EntryFieldType, value: unknown): string[] {\n if (type === 'number' || type === 'integer') {\n if (typeof value !== 'number' || !Number.isFinite(value)) return []\n const negative = value < 0\n const abs = Math.abs(value)\n const fixed = Number.isInteger(abs) ? String(abs) : abs.toFixed(2).replace(/0+$/, '').replace(/\\.$/, '')\n const [int, frac] = fixed.split('.')\n const grouped = int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n const forms = new Set<string>()\n for (const whole of [int, grouped]) {\n forms.add(frac ? `${whole}.${frac}` : whole)\n if (!frac) forms.add(`${whole}.00`)\n }\n return [...forms].map(form => (negative ? `-${form}` : form))\n }\n if (type === 'datetime') {\n /* A moment is found by its day and its hh:mm - the file writes seconds and zones its own way. */\n const match = typeof value === 'string' ? value.match(/^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}):(\\d{2})/) : null\n if (!match) return []\n return writtenForms('date', match[1])\n }\n if (type === 'date') {\n const match = typeof value === 'string' ? value.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/) : null\n if (!match) return []\n const [, y, m, d] = match\n const mm = String(Number(m))\n const dd = String(Number(d))\n return [`${y}-${m}-${d}`, `${y}.${m}.${d}`, `${y}/${m}/${d}`, `${y}${m}${d}`, `${y}.${mm}.${dd}`, `${y}/${mm}/${dd}`, `${y}-${mm}-${dd}`, `${y.slice(2)}.${m}.${d}`, `${y.slice(2)}/${m}/${d}`]\n }\n return []\n}\n\n/**\n * A form found as a whole number - \"12,400\" is not found in \"112,400\", \"12,4001\", \"12,400.50\" or \"12,400,000\";\n * \"2026-09-12\" not in \"2026-09-120\". A CSV's own commas are not part of the number.\n */\nexport function lineHas(line: string, forms: string[]): boolean {\n const digit = (c: string | undefined) => !!c && c >= '0' && c <= '9'\n return forms.some(form => {\n for (let at = line.indexOf(form); at >= 0; at = line.indexOf(form, at + 1)) {\n const before = line[at - 1]\n const after = line[at + form.length]\n /* A comma is also the column separator of a CSV: only a comma and three digits more continue the number. */\n if (digit(before) || (before === '.' && digit(line[at - 2]))) continue\n if (digit(after) || (after === '.' && digit(line[at + form.length + 1]))) continue\n if (after === ',' && /^,\\d{3}(?!\\d)/.test(line.slice(at + form.length))) continue\n return true\n }\n return false\n })\n}\n\n/**\n * Checks each row against the text of the files it cites. `texts` holds what could be read, by attachment id;\n * an id that is not there was an image, or could not be opened.\n */\nexport function verifyRowsAgainstSources(rows: EntryRow[], fields: EntryField[], texts: Map<string, string>): EntryRow[] {\n const checked = fields.filter(field => ['number', 'integer', 'date'].includes(field.type))\n return rows.map(row => {\n const files = row.sources.map(source => source.attachmentId).filter((id): id is string => !!id)\n if (!files.length || !checked.length) return row\n const readable = files.filter(id => texts.has(id))\n if (!readable.length) return { ...row, issues: [...row.issues, { code: 'source-not-checked', blocking: false }] }\n\n const forms = checked\n .map(field => ({ field, forms: writtenForms(field.type, row.values[field.name]) }))\n .filter(one => one.forms.length)\n if (!forms.length) return row\n\n for (const id of readable) {\n const lines = texts.get(id)!.split(/\\r?\\n/)\n const at = lines.findIndex(line => forms.every(one => lineHas(line, one.forms)))\n if (at >= 0) return { ...row, evidence: { attachmentId: id, line: at + 1 } }\n }\n\n const saidByPerson = row.sources.some(source => source.person)\n const issues = [...row.issues]\n for (const one of forms) {\n const anywhere = readable.some(id => texts.get(id)!.split(/\\r?\\n/).some(line => lineHas(line, one.forms)))\n if (!anywhere && !saidByPerson) issues.push({ field: one.field.name, code: 'not-in-source', blocking: false })\n }\n if (issues.length === row.issues.length) issues.push({ code: 'source-scattered', blocking: false })\n return { ...row, issues }\n })\n}\n\n/**\n * The total a file prints - a line named 합계 · 총계 · 총액 · total · sum, and the last amount on it. The server\n * reads it itself, so the card can compare even when the model did not say it (2026-10-01: once it did, once not).\n */\nexport function printedTotalOf(text: string): { value: number; line: number } | undefined {\n const lines = text.split(/\\r?\\n/)\n for (let i = lines.length - 1; i >= 0; i--) {\n if (!/(합\\s*계|총\\s*계|총\\s*액|total|sum)/i.test(lines[i])) continue\n const amounts = [...lines[i].matchAll(/-?\\d{1,3}(?:,\\d{3})+(?:\\.\\d+)?|-?\\d+(?:\\.\\d+)?/g)].map(match => Number(match[0].replace(/,/g, '')))\n if (amounts.length) return { value: amounts[amounts.length - 1], line: i + 1 }\n }\n return undefined\n}\n\nexport interface EntryTotal {\n field: string\n /** The sum over every row, and over the rows that will be entered. */\n all: number\n ready: number\n /** The total the material prints, as the model read it - and whether the server found it in the file. */\n declared?: number\n declaredFound?: boolean\n /** declared - all. */\n difference?: number\n /** Where the declared total came from - the model's reading, or the server's own from a file's total line. */\n declaredBy?: 'model' | 'file'\n}\n\n/** The sums of the fields declared `total`, and how they stand against the total the material prints. */\nexport function entryTotals(\n rows: EntryRow[],\n fields: EntryField[],\n declared: { field?: string; value?: unknown; attachmentId?: string } | undefined,\n texts: Map<string, string>\n): EntryTotal[] {\n const totalled = fields.filter(field => field.total && (field.type === 'number' || field.type === 'integer'))\n /* With one totalled field and no total from the model, the server looks for the file's own total line. */\n const printed = !declared && totalled.length === 1 ? [...texts.values()].map(printedTotalOf).find(Boolean) : undefined\n return totalled\n .map(field => {\n const sum = (list: EntryRow[]) => Math.round(list.reduce((acc, row) => acc + (typeof row.values[field.name] === 'number' ? (row.values[field.name] as number) : 0), 0) * 100) / 100\n const total: EntryTotal = { field: field.name, all: sum(rows), ready: sum(rows.filter(row => !isBlocked(row))) }\n if (printed) {\n total.declared = printed.value\n total.declaredFound = true\n total.declaredBy = 'file'\n total.difference = Math.round((printed.value - total.all) * 100) / 100\n return total\n }\n /*\n * With one totalled field the model's total is that field's, whatever it named it - on office's second card it\n * wrote the file's column name (이용금액) for amount, and the total was dropped (2026-10-01).\n */\n const mine = declared && (totalled.length === 1 || (declared.field ?? field.name) === field.name)\n const value = mine ? toNumber(declared!.value) : undefined\n if (value !== undefined) {\n total.declaredBy = 'model'\n total.declared = value\n total.difference = Math.round((value - total.all) * 100) / 100\n const text = declared!.attachmentId ? texts.get(declared!.attachmentId) : undefined\n if (text !== undefined) total.declaredFound = text.split(/\\r?\\n/).some(line => lineHas(line, writtenForms(field.type, value)))\n }\n return total\n })\n}\n\n/** The doors of the queries a target's reference fields reach - the person must pass them too. */\nexport function referenceDoorsOf(fields: EntryField[]): string[] {\n return [...new Set(fields.filter(field => field.type === 'reference' && field.reference).map(field => rootFieldOf(field.reference!.query, 'query')))]\n}\n\n/**\n * Settles each reference a row names by text, through the application's query as the person. One match keeps its\n * id and name; none or several keep the row out - several with their names, so the person can say which.\n */\nexport async function resolveReferences<T extends { values: Record<string, unknown>; issues: EntryIssue[] }>(\n fields: EntryField[],\n rows: T[],\n run: (document: string, variables: Record<string, unknown>) => Promise<{ data?: any; errors?: readonly { message: string }[] }>\n): Promise<T[]> {\n const references = fields.filter(field => field.type === 'reference' && field.reference)\n if (!references.length) return rows\n const asked = new Map<string, { id: string; label?: string }[] | Error>()\n for (const row of rows) {\n for (const field of references) {\n const value: any = row.values[field.name]\n if (!value || typeof value !== 'object' || typeof value.text !== 'string') continue\n const key = `${field.name}\\u0000${value.text}`\n if (!asked.has(key)) {\n try {\n const answer = await run(field.reference!.query, field.reference!.variables(value.text))\n asked.set(key, answer.errors?.length ? new Error(answer.errors[0].message) : field.reference!.recordsOf(answer.data, value.text) ?? [])\n } catch (error: any) {\n asked.set(key, error instanceof Error ? error : new Error(String(error)))\n }\n }\n const found = asked.get(key)!\n if (found instanceof Error) {\n row.issues.push({ field: field.name, code: 'reference-unreadable', params: { text: value.text }, blocking: true })\n } else if (found.length === 1) {\n row.values[field.name] = { id: found[0].id, ...(found[0].label ? { label: found[0].label } : {}) }\n } else {\n row.issues.push({\n field: field.name,\n code: found.length ? 'reference-ambiguous' : 'reference-not-found',\n params: { text: value.text, ...(found.length ? { candidates: found.slice(0, 5).map(one => one.label || one.id).join(', ') } : {}) },\n blocking: true\n })\n }\n }\n }\n return rows\n}\n\n/** The rows by group, in the order groups first appear - `[key, rows]`. A row without the key is a group of its own. */\nexport function entryGroups<T extends { index: number; values: Record<string, unknown> }>(rows: T[], by: string): [string, T[]][] {\n const groups = new Map<string, T[]>()\n for (const row of rows) {\n const value = row.values[by]\n const key = value === undefined || value === null || value === '' ? `\\u0000row-${row.index}` : String(typeof value === 'object' ? (value as any).id ?? (value as any).text : value)\n groups.set(key, [...(groups.get(key) ?? []), row])\n }\n return [...groups.entries()]\n}\n\n/** The UTC offset a time zone has at a wall time - \"+09:00\". DST is taken at that day, not today. */\nexport function offsetAt(timeZone: string | undefined, wall: string): string | undefined {\n const match = wall.match(/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})$/)\n if (!match) return undefined\n const [y, mo, d, h, mi, se] = match.slice(1).map(Number)\n let format: Intl.DateTimeFormat\n try {\n format = new Intl.DateTimeFormat('en-US', { timeZone: timeZone || undefined, timeZoneName: 'longOffset', year: 'numeric' })\n } catch {\n return undefined\n }\n const minutesOf = (at: number) => {\n const name = format.formatToParts(new Date(at)).find(part => part.type === 'timeZoneName')?.value ?? 'GMT'\n const m = name.match(/GMT([+-])(\\d{2}):?(\\d{2})?/)\n return m ? (m[1] === '-' ? -1 : 1) * (Number(m[2]) * 60 + Number(m[3] ?? 0)) : 0\n }\n /* The offset at the wall time read as UTC, then once more at the instant that gives - right across a DST change. */\n const asUtc = Date.UTC(y, mo - 1, d, h, mi, se)\n const minutes = minutesOf(asUtc - minutesOf(asUtc) * 60_000)\n const sign = minutes < 0 ? '-' : '+'\n const abs = Math.abs(minutes)\n return `${sign}${String(Math.floor(abs / 60)).padStart(2, '0')}:${String(abs % 60).padStart(2, '0')}`\n}\n\n/**\n * A moment written without an offset is the domain's wall time - \"08:30\" in a factory is 08:30 there. Each such\n * value gets the domain time zone's offset at that day, so an API taking DateTimeISO accepts it and reads the moment\n * meant (plant refused every downtime log without it, 2026-10-01).\n */\nexport function zonedDateTimes<T extends { values: Record<string, unknown> }>(fields: EntryField[], rows: T[], timeZone: string | undefined): T[] {\n const moments = fields.filter(field => field.type === 'datetime')\n if (!moments.length) return rows\n for (const row of rows) {\n for (const field of moments) {\n const value = row.values[field.name]\n if (typeof value !== 'string' || !/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/.test(value)) continue\n const offset = offsetAt(timeZone, value)\n if (offset) row.values[field.name] = `${value}${offset}`\n }\n }\n return rows\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"entry-target.js","sourceRoot":"","sources":["../../../server/service/data-entry/entry-target.ts"],"names":[],"mappings":";;;AA8DA,sCAKC;AA4JD,kCAEC;AAGD,kCAOC;AAGD,4CAOC;AAYD,gDA0CC;AAED,sCAEC;AAED,oCAEC;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,IAAI,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAA;AACvG,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAgD,MAAoB,EAAE,IAAS,EAAE,QAA4B;IACzI,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA;IACjE,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAChC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,uCAAuC,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,SAAQ;YAC/F,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;YACxC,IAAI,MAAM;gBAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG,MAAM,EAAE,CAAA;QAC1D,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["/*\n * Data entry from material - what an application declares so the assistant can enter its records\n * (operato-application/design/ai/data-entry.md).\n *\n * A person hands the conversation what the records are made of - a bank export, a photo of a receipt,\n * lines pasted from a mail - and the assistant turns it into rows of one of the application's records.\n * Nothing is written by the model. It proposes the rows; the card shows them with what was wrong in\n * each and where each came from; a correction is said in the conversation and the model proposes again;\n * the person presses the button; the server enters each row **through the application's own GraphQL\n * mutation**, run with the person's request state - the same door, directives and checks as entering by hand.\n * There is no second way into the record.\n *\n * This file is pure - no framework, no database - so the rules a row passes are tested without a server.\n */\nimport { parse } from 'graphql'\n\nexport type EntryFieldType = 'string' | 'text' | 'number' | 'integer' | 'date' | 'datetime' | 'boolean' | 'enum' | 'reference'\n\nexport interface EntryField {\n name: string\n type: EntryFieldType\n required?: boolean\n /** The allowed values of an `enum` field. */\n values?: string[]\n /** What the model reads about the field - English, like every tool description. */\n description?: string\n /** i18n key of the column heading on the card. Absent: the field name. */\n labelKey?: string\n /** A number field the card sums - and compares with the total the material prints (§ totals). */\n total?: boolean\n /** An enum's values on the card: `<prefix><value in lowercase>` - `text.expense-payment-` shows PERSONAL_CARD as 개인카드. */\n valueKeyPrefix?: string\n /**\n * A `reference` field points at another record - a loan, an item, a location. The model knows it by a name or\n * a code; the server finds it through the application's query, as the person, and keeps its id. One match is\n * taken; none or several keep the row out and say so - the server never picks among several.\n */\n reference?: EntryReference\n /**\n * The axis of the record the field names (`tax-invoice`, `contract`) - several when it may name a record of each - for a\n * record the model is shown by its key: an open record's anchor and an application's link evidence write\n * `<axis>:<id>`. The key is read as the id it names, so what the model was shown is what it may write (2026-10-23: a\n * card took `tax-invoice:<uuid>` from the evidence, looked it up as an approval number and found nothing). A reference\n * reads it before its query runs; a string field holding an id reads it as the id.\n */\n axis?: string | readonly string[]\n}\n\nexport interface EntryReference {\n query: string\n /** The query's variables for what the model wrote - \"기업은행\", \"A-100\". */\n variables(text: string): Record<string, unknown>\n /** The records the answer holds that the text names - the application filters, the server does not guess. */\n recordsOf(data: any, text: string): { id: string; label?: string }[]\n}\n\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/**\n * The id a record's key names - `<axis>:<uuid>` as an anchor writes it, or the uuid alone. Nothing for a word, or for\n * the key of a record of another axis: that one is not this record, whatever its uuid.\n */\nexport function recordIdOfKey(axis: string | readonly string[], text: string): string | undefined {\n const value = String(text ?? '').trim()\n const prefix = (typeof axis === 'string' ? [axis] : axis).map(one => `${one}:`).find(one => value.startsWith(one))\n const id = prefix ? value.slice(prefix.length) : value\n return UUID.test(id) ? id : undefined\n}\n\n/** What the model wrote for a field that names a record - the id, when it wrote the record's key. */\nconst shownId = (field: EntryField, text: string): string => (field.axis && recordIdOfKey(field.axis, text)) || text\n\n/** A resolved reference, as a row keeps it. */\nexport interface ReferenceValue {\n id: string\n label?: string\n}\n\n/** Where a row came from - which file, and where in it. Shown on the card beside the row. */\nexport interface EntrySource {\n attachmentId?: string\n /** \"row 3\", \"the receipt photo\" - the model's words, in the person's language. */\n where?: string\n /** The value came from what the person said in the conversation - shown in the screen's own words, never the model's. */\n person?: boolean\n}\n\nexport interface EntryIssue {\n /** The field it is about. Absent: the row as a whole. */\n field?: string\n /** A code the screen translates: `ai-assistant.entry.issue.<code>`, or the target's own `messageKey`. */\n code: string\n messageKey?: string\n params?: Record<string, unknown>\n /** A param that is a code the screen words - { status: 'text.state-' } shows `down` as 고장. */\n paramKeys?: Record<string, string>\n /** A blocking issue keeps the row out when the person presses the button. */\n blocking: boolean\n}\n\nexport interface EntryRowInput {\n values?: Record<string, unknown>\n sources?: EntrySource[]\n}\n\nexport interface EntryRow {\n index: number\n values: Record<string, unknown>\n sources: EntrySource[]\n issues: EntryIssue[]\n /** The line of a text source where this row's numbers and dates were all found - the server's check, not the model's word. */\n evidence?: { attachmentId: string; line: number }\n}\n\nexport interface EntryContext {\n /** The request state - domain, user, and when writing, `tx` and `afterCommit`. */\n state: any\n}\n\nexport interface EntryApplied {\n /** The created record's id, when there is one. */\n id?: string\n /** A short name for the conversation line - \"2026-09-12 · 택시 · ₩12,400\". */\n label?: string\n}\n\n/** What happened, for an application that writes down every assistant call (office's AI audit). */\nexport interface EntryEvent {\n phase: 'propose' | 'apply'\n tool: string\n rows: number\n ok: boolean\n applied?: number\n missed?: number\n error?: string\n /** propose: the rows as the model gave them; apply: the proposal key and each row's result. */\n detail?: unknown\n}\n\nexport interface EntryTarget {\n /** `<app>.<record>` - `office.expense-line`. */\n key: string\n /**\n * The records the card is about besides its own (the axes of `subject` anchors) - a link card is about the deposit,\n * the invoice and the round it joins. On those records' screens its propose tool is put in front (ADR-0061 decision\n * 9); asked to link a deposit from its 360, the model found the invoice and never opened the card (2026-10-24).\n */\n axes?: string[]\n /** i18n key of the record's name on the card. */\n labelKey: string\n /** What one row is, for the model. */\n description: string\n fields: EntryField[]\n /**\n * The application's own mutation that enters one record, as a GraphQL document with one root field -\n * `mutation ($line: NewExpenseLine!) { addExpenseLine(line: $line) { id } }`. Its root field is the door:\n * the propose tool is offered only to someone who passes it, and each row is entered by running it with\n * the person's request state, so `@privilege`, `@transaction` and the door's own checks apply as they do\n * to a person typing it in.\n */\n mutation: string\n /** The mutation's variables for one row. Absent when the target enters rows by group (below). */\n variables?(row: EntryRow): Record<string, unknown>\n /** What the conversation says of an entered row - its id and a short name. */\n appliedOf?(data: any, row: EntryRow): EntryApplied | undefined\n /**\n * A record with lines - one order, several item lines. Rows that share the value of `by` (the order number) are one\n * record, entered by one call of the mutation with `variables(rows)`. If any row of a group is kept out, the whole\n * group is: an order missing a line must not go in unseen.\n */\n group?: {\n by: string\n variables(rows: EntryRow[]): Record<string, unknown>\n appliedOf?(data: any, rows: EntryRow[]): EntryApplied | undefined\n }\n /** At most this many rows in one proposal. Default 200. */\n maxRows?: number\n /**\n * Read-only checks the application owns - a duplicate of what is already entered, a code that does not\n * exist. Asked when the rows are proposed and again when they are entered: the records may have moved.\n * Returns one list per row, in order.\n */\n check?(rows: EntryRow[], context: EntryContext): EntryIssue[][] | Promise<EntryIssue[][]>\n /** Told of every proposal and every entering - an application that audits its assistant writes it down. A throw is ignored. */\n record?(event: EntryEvent, context: EntryContext): void | Promise<void>\n /** Changing records that exist (design/ai/data-entry.md §5-1). Absent: this target only enters new ones. */\n update?: EntryUpdate\n}\n\n/** One record as the application's read query answers it - an `id` and the fields. */\nexport type EntryRecord = { id: string } & Record<string, unknown>\n\n/**\n * How records of a target are changed - every step through the application's API, as the person.\n *\n * Which record is meant is the server's to settle, never the model's memory: whichever way it was picked\n * (on screen, selected, described), the server reads it with `read` before a card is made and again before\n * it is written.\n */\nexport interface EntryUpdate {\n /** Reads the records by id, as the person - one they may not see is not found. */\n read: { query: string; variables(ids: string[]): Record<string, unknown>; recordsOf(data: any, ids: string[]): EntryRecord[] }\n /** Finds candidates from what the person said - \"last week's 12,400 taxi\". */\n find?: { query: string; variables(criteria: Record<string, unknown>): Record<string, unknown>; recordsOf(data: any, criteria: Record<string, unknown>): EntryRecord[]; criteria: EntryField[] }\n /** The application's own mutation that changes one record. */\n mutation: string\n variables(change: { id: string; record: EntryRecord; values: Record<string, unknown> }): Record<string, unknown>\n /** How a record is named on the card - \"2026-09-12 · 카카오T\". */\n labelOf?(record: EntryRecord): string\n /** The fields that may change. Default: every declared field. */\n fields?: string[]\n /**\n * Read-only checks of the changes - a new name that another record already has. Asked when the card is made and\n * again when it is pressed, like an entry's check; one issue list per row. Without it a clash is caught only by\n * the database's own refusal.\n */\n check?(rows: { id: string; record?: EntryRecord; values: Record<string, unknown> }[], context: EntryContext): EntryIssue[][] | Promise<EntryIssue[][]>\n}\n\n/**\n * `Mutation.<root field>` of the target's mutation - the one declaration both the tool's gate and the\n * entering read. A document that is not one mutation with one root field is refused at boot.\n */\nexport function entryDoorOf(mutation: string): string {\n return rootFieldOf(mutation, 'mutation')\n}\n\n/** `Query.<field>` or `Mutation.<field>` of a document with one operation and one root field. */\nexport function rootFieldOf(document: string, operation: 'query' | 'mutation'): string {\n const doc = parse(document)\n const operations = doc.definitions.filter((one: any) => one.kind === 'OperationDefinition') as any[]\n if (operations.length !== 1 || operations[0].operation !== operation) throw new Error(`is not one ${operation}`)\n const fields = operations[0].selectionSet.selections.filter((one: any) => one.kind === 'Field')\n if (fields.length !== 1) throw new Error('must have exactly one root field')\n return `${operation === 'query' ? 'Query' : 'Mutation'}.${fields[0].name.value}`\n}\n\n/** Tells the target, and never lets its record keeping stop the work. */\nexport async function recordEntryEvent(target: EntryTarget, event: EntryEvent, context: EntryContext): Promise<void> {\n if (!target.record) return\n try {\n await target.record(event, context)\n } catch {\n /* an audit that failed to write is the application's to report */\n }\n}\n\nexport const DEFAULT_MAX_ROWS = 200\n\n/* The model's way of saying a value came from the person - kept only to read older rows and loose words. */\nconst PERSON = /person|message|user|사용자|말/i\n\nconst targets = new Map<string, EntryTarget>()\n\nconst KEY = /^[a-z][a-z0-9-]*\\.[a-z][a-z0-9-]*$/\n\n/** Validates and keeps a target - `registerEntryTarget` (entry-tools.ts) also opens its tool. A malformed declaration is refused at boot, not in a conversation. */\nexport function declareEntryTarget(target: EntryTarget): void {\n if (!KEY.test(target?.key ?? '')) throw new Error(`[ai-assistant] entry target key '${target?.key}' is not '<app>.<record>'.`)\n try {\n entryDoorOf(target.mutation ?? '')\n } catch (error: any) {\n throw new Error(`[ai-assistant] entry target '${target.key}': its mutation ${error?.message ?? 'does not parse'}.`)\n }\n if (typeof target.variables !== 'function' && typeof target.group?.variables !== 'function')\n throw new Error(`[ai-assistant] entry target '${target.key}' has no variables (per row, or per group).`)\n if (target.group && !target.fields.some(field => field.name === target.group!.by))\n throw new Error(`[ai-assistant] entry target '${target.key}': group by '${target.group.by}' is not a declared field.`)\n if (target.update) {\n for (const [what, document, operation] of [\n ['update.read', target.update.read?.query, 'query'],\n ['update.mutation', target.update.mutation, 'mutation'],\n ...(target.update.find ? [['update.find', target.update.find.query, 'query']] : [])\n ] as [string, string, 'query' | 'mutation'][]) {\n try {\n rootFieldOf(document ?? '', operation)\n } catch (error: any) {\n throw new Error(`[ai-assistant] entry target '${target.key}': ${what} ${error?.message ?? 'does not parse'}.`)\n }\n }\n const known = new Set(target.fields.map(field => field.name))\n for (const name of target.update.fields ?? []) if (!known.has(name)) throw new Error(`[ai-assistant] entry target '${target.key}': update field '${name}' is not declared.`)\n }\n if (!target.fields?.length) throw new Error(`[ai-assistant] entry target '${target.key}' declares no fields.`)\n const names = new Set<string>()\n for (const field of target.fields) {\n if (field.type === 'reference') {\n try {\n rootFieldOf(field.reference?.query ?? '', 'query')\n } catch (error: any) {\n throw new Error(`[ai-assistant] entry target '${target.key}': reference field '${field.name}' ${error?.message ?? 'has no query'}.`)\n }\n }\n if (names.has(field.name)) throw new Error(`[ai-assistant] entry target '${target.key}' declares '${field.name}' twice.`)\n names.add(field.name)\n if (field.type === 'enum' && !field.values?.length)\n throw new Error(`[ai-assistant] entry target '${target.key}': enum field '${field.name}' lists no values.`)\n }\n targets.set(target.key, target)\n}\n\nexport function entryTargetOf(key: string | undefined): EntryTarget | undefined {\n return key ? targets.get(key) : undefined\n}\n\nexport function entryTargets(): EntryTarget[] {\n return [...targets.values()]\n}\n\n/** For tests. */\nexport function clearEntryTargets(): void {\n targets.clear()\n}\n\nconst pascalOf = (key: string) =>\n key\n .split(/[.-]/)\n .filter(Boolean)\n .map(part => part[0].toUpperCase() + part.slice(1))\n .join('')\n\n/** `office.expense-line` → `proposeOfficeExpenseLineChanges` / `findOfficeExpenseLine` - the tools of changing. */\nexport const changeToolName = (key: string) => `propose${pascalOf(key)}Changes`\nexport const findToolName = (key: string) => `find${pascalOf(key)}`\n\n/** `office.expense-line` → `proposeOfficeExpenseLineEntries` - one tool per target, so each has its own door. */\nexport function entryToolName(key: string): string {\n const pascal = key\n .split(/[.-]/)\n .filter(Boolean)\n .map(part => part[0].toUpperCase() + part.slice(1))\n .join('')\n return `propose${pascal}Entries`\n}\n\nexport function entryCategoryName(key: string): string {\n return `data-entry:${key}`\n}\n\nconst empty = (value: unknown) => value === undefined || value === null || (typeof value === 'string' && !value.trim())\n\n/** \"12,400\" · \"₩12,400\" · \"12 400\" → 12400. Only the separators people write; anything else is not a number. */\nfunction toNumber(value: unknown): number | undefined {\n if (typeof value === 'number') return Number.isFinite(value) ? value : undefined\n if (typeof value !== 'string') return undefined\n const cleaned = value.trim().replace(/^[₩$€¥£]\\s*/, '').replace(/[,\\s]/g, '').replace(/원$/, '')\n if (!/^-?\\d+(\\.\\d+)?$/.test(cleaned)) return undefined\n return Number(cleaned)\n}\n\n/** A calendar date as `YYYY-MM-DD` - \"2026.9.12\", \"2026/09/12\" too. A day that does not exist is not a date. */\nfunction toDate(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const match = value.trim().match(/^(\\d{4})[-./](\\d{1,2})[-./](\\d{1,2})\\.?$/)\n if (!match) return undefined\n const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])]\n const date = new Date(Date.UTC(year, month - 1, day))\n if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) return undefined\n return `${match[1]}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`\n}\n\n/**\n * A moment as `YYYY-MM-DDTHH:mm:ss`, with the offset when it was written - \"2026-10-01 08:30\", \"2026.10.1 8:30\",\n * an ISO string. Without an offset it stays without one: the application reads it in its own time zone, as it\n * reads a time typed into its own screen.\n */\nfunction toDateTime(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const match = value.trim().match(/^(\\d{4})[-./](\\d{1,2})[-./](\\d{1,2})[ T](\\d{1,2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?\\s*(Z|[+-]\\d{2}:?\\d{2})?$/)\n if (!match) return undefined\n const day = toDate(`${match[1]}-${match[2]}-${match[3]}`)\n const [hour, minute, second] = [Number(match[4]), Number(match[5]), Number(match[6] ?? 0)]\n if (!day || hour > 23 || minute > 59 || second > 59) return undefined\n const offset = match[7] ? (match[7] === 'Z' ? 'Z' : match[7].replace(/^([+-]\\d{2})(\\d{2})$/, '$1:$2')) : ''\n return `${day}T${String(hour).padStart(2, '0')}:${match[5]}:${String(second).padStart(2, '0')}${offset}`\n}\n\nfunction toBoolean(value: unknown): boolean | undefined {\n if (typeof value === 'boolean') return value\n if (typeof value !== 'string') return undefined\n const text = value.trim().toLowerCase()\n if (['true', 'yes', 'y', '1'].includes(text)) return true\n if (['false', 'no', 'n', '0'].includes(text)) return false\n return undefined\n}\n\n/** One value in its field's type - or the code of why it is not. An empty value is the caller's to judge. */\nexport function readFieldValue(field: EntryField, value: unknown): { read?: unknown; code?: string } {\n switch (field.type) {\n case 'number': {\n const read = toNumber(value)\n return read === undefined ? { code: 'not-a-number' } : { read }\n }\n case 'integer': {\n const read = toNumber(value)\n return read === undefined || !Number.isInteger(read) ? { code: 'not-an-integer' } : { read }\n }\n case 'date': {\n const read = toDate(value)\n return read === undefined ? { code: 'not-a-date' } : { read }\n }\n case 'datetime': {\n const read = toDateTime(value)\n return read === undefined ? { code: 'not-a-datetime' } : { read }\n }\n case 'boolean': {\n const read = toBoolean(value)\n return read === undefined ? { code: 'not-a-boolean' } : { read }\n }\n case 'enum':\n return field.values!.includes(String(value).trim()) ? { read: String(value).trim() } : { code: 'not-in-list' }\n case 'reference':\n /* Resolved already ({ id }), or a name to look up ({ text }) - resolveReferences settles the second. */\n if (value && typeof value === 'object' && typeof (value as any).id === 'string') return { read: { id: shownId(field, (value as any).id), ...((value as any).label ? { label: String((value as any).label) } : {}) } }\n if (value && typeof value === 'object' && typeof (value as any).text === 'string') return { read: { text: (value as any).text } }\n return typeof value === 'string' || typeof value === 'number' ? { read: { text: String(value).trim() } } : { code: 'not-a-reference' }\n default:\n return { read: shownId(field, String(value).trim()) }\n }\n}\n\n/** Two values of one field the same - \"12400.00\" read from the database is 12400. */\nexport function sameFieldValue(field: EntryField, a: unknown, b: unknown): boolean {\n if (empty(a) && empty(b)) return true\n if (empty(a) || empty(b)) return false\n if (field.type === 'reference') {\n const idOf = (v: any) => (v && typeof v === 'object' ? v.id ?? v.text : String(v))\n return idOf(a) === idOf(b)\n }\n const x = readFieldValue(field, a)\n const y = readFieldValue(field, b)\n return x.read !== undefined && y.read !== undefined ? x.read === y.read : String(a) === String(b)\n}\n\n/**\n * The rows as the target reads them - each value in its field's type, and what was wrong said as an issue.\n *\n * A value that does not fit is **kept as it was written and marked**, never dropped or guessed: the card\n * shows what the material said, and the person corrects it in the conversation.\n */\nexport function normalizeEntryRows(target: EntryTarget, input: unknown): { rows: EntryRow[]; cut: number } {\n const list = Array.isArray(input) ? input : []\n const max = target.maxRows ?? DEFAULT_MAX_ROWS\n const fields = new Map(target.fields.map(field => [field.name, field]))\n\n const rows = list.slice(0, max).map((raw: any, index): EntryRow => {\n const given = raw && typeof raw.values === 'object' && raw.values ? raw.values : {}\n const values: Record<string, unknown> = {}\n const issues: EntryIssue[] = []\n\n for (const name of Object.keys(given)) {\n if (!fields.has(name)) issues.push({ field: name, code: 'unknown-field', blocking: false })\n }\n\n for (const field of target.fields) {\n const value = given[field.name]\n if (empty(value)) {\n if (field.required) issues.push({ field: field.name, code: 'required', blocking: true })\n continue\n }\n const { read, code } = readFieldValue(field, value)\n if (read === undefined) {\n values[field.name] = value\n issues.push({ field: field.name, code: code!, params: code === 'not-in-list' ? { values: field.values } : undefined, blocking: true })\n } else {\n values[field.name] = read\n }\n }\n\n const sources: EntrySource[] = Array.isArray(raw?.sources)\n ? raw.sources\n .filter((one: any) => one && (one.attachmentId || one.where || one.person === true))\n .map((one: any): EntrySource => {\n /* \"the person's message\" written by the model is the person flag - the screen says it in its own words. */\n if (one.person === true || (!one.attachmentId && typeof one.where === 'string' && PERSON.test(one.where))) return { person: true }\n return {\n ...(typeof one.attachmentId === 'string' ? { attachmentId: one.attachmentId } : {}),\n ...(typeof one.where === 'string' ? { where: one.where.slice(0, 120) } : {})\n }\n })\n : []\n if (!sources.length) issues.push({ code: 'no-source', blocking: false })\n\n return { index, values, sources, issues }\n })\n\n return { rows, cut: Math.max(0, list.length - max) }\n}\n\n/** Adds the target's own findings to each row. A check that throws marks nothing and is reported by the caller. */\nexport function withCheckedIssues(rows: EntryRow[], found: EntryIssue[][] | undefined): EntryRow[] {\n if (!found) return rows\n return rows.map((row, i) => (found[i]?.length ? { ...row, issues: [...row.issues, ...found[i]] } : row))\n}\n\nexport function isBlocked(row: EntryRow): boolean {\n return row.issues.some(issue => issue.blocking)\n}\n\n/* ── Checking the rows against the material (design/ai/data-entry.md §4-1) ─────────────────────────────\n *\n * A row cites where it came from; the model's word is not proof. For a text source the server looks: the\n * row's numbers and dates must stand together on one line of the cited file. Found - the row carries that\n * line as evidence. A value the file does not have is marked, unless the row also cites the person's\n * message (a correction said in the conversation). A photo cannot be read here - the row says so.\n * Names and descriptions are not looked for: the model tidies them, and a tidied name is not a wrong one.\n */\n\n\n/** The ways a number or a date is written in a file. */\nexport function writtenForms(type: EntryFieldType, value: unknown): string[] {\n if (type === 'number' || type === 'integer') {\n if (typeof value !== 'number' || !Number.isFinite(value)) return []\n const negative = value < 0\n const abs = Math.abs(value)\n const fixed = Number.isInteger(abs) ? String(abs) : abs.toFixed(2).replace(/0+$/, '').replace(/\\.$/, '')\n const [int, frac] = fixed.split('.')\n const grouped = int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n const forms = new Set<string>()\n for (const whole of [int, grouped]) {\n forms.add(frac ? `${whole}.${frac}` : whole)\n if (!frac) forms.add(`${whole}.00`)\n }\n return [...forms].map(form => (negative ? `-${form}` : form))\n }\n if (type === 'datetime') {\n /* A moment is found by its day and its hh:mm - the file writes seconds and zones its own way. */\n const match = typeof value === 'string' ? value.match(/^(\\d{4}-\\d{2}-\\d{2})T(\\d{2}):(\\d{2})/) : null\n if (!match) return []\n return writtenForms('date', match[1])\n }\n if (type === 'date') {\n const match = typeof value === 'string' ? value.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/) : null\n if (!match) return []\n const [, y, m, d] = match\n const mm = String(Number(m))\n const dd = String(Number(d))\n return [`${y}-${m}-${d}`, `${y}.${m}.${d}`, `${y}/${m}/${d}`, `${y}${m}${d}`, `${y}.${mm}.${dd}`, `${y}/${mm}/${dd}`, `${y}-${mm}-${dd}`, `${y.slice(2)}.${m}.${d}`, `${y.slice(2)}/${m}/${d}`]\n }\n return []\n}\n\n/**\n * A form found as a whole number - \"12,400\" is not found in \"112,400\", \"12,4001\", \"12,400.50\" or \"12,400,000\";\n * \"2026-09-12\" not in \"2026-09-120\". A CSV's own commas are not part of the number.\n */\nexport function lineHas(line: string, forms: string[]): boolean {\n const digit = (c: string | undefined) => !!c && c >= '0' && c <= '9'\n return forms.some(form => {\n for (let at = line.indexOf(form); at >= 0; at = line.indexOf(form, at + 1)) {\n const before = line[at - 1]\n const after = line[at + form.length]\n /* A comma is also the column separator of a CSV: only a comma and three digits more continue the number. */\n if (digit(before) || (before === '.' && digit(line[at - 2]))) continue\n if (digit(after) || (after === '.' && digit(line[at + form.length + 1]))) continue\n if (after === ',' && /^,\\d{3}(?!\\d)/.test(line.slice(at + form.length))) continue\n return true\n }\n return false\n })\n}\n\n/**\n * Checks each row against the text of the files it cites. `texts` holds what could be read, by attachment id;\n * an id that is not there was an image, or could not be opened.\n */\nexport function verifyRowsAgainstSources(rows: EntryRow[], fields: EntryField[], texts: Map<string, string>): EntryRow[] {\n const checked = fields.filter(field => ['number', 'integer', 'date'].includes(field.type))\n return rows.map(row => {\n const files = row.sources.map(source => source.attachmentId).filter((id): id is string => !!id)\n if (!files.length || !checked.length) return row\n const readable = files.filter(id => texts.has(id))\n if (!readable.length) return { ...row, issues: [...row.issues, { code: 'source-not-checked', blocking: false }] }\n\n const forms = checked\n .map(field => ({ field, forms: writtenForms(field.type, row.values[field.name]) }))\n .filter(one => one.forms.length)\n if (!forms.length) return row\n\n for (const id of readable) {\n const lines = texts.get(id)!.split(/\\r?\\n/)\n const at = lines.findIndex(line => forms.every(one => lineHas(line, one.forms)))\n if (at >= 0) return { ...row, evidence: { attachmentId: id, line: at + 1 } }\n }\n\n const saidByPerson = row.sources.some(source => source.person)\n const issues = [...row.issues]\n for (const one of forms) {\n const anywhere = readable.some(id => texts.get(id)!.split(/\\r?\\n/).some(line => lineHas(line, one.forms)))\n if (!anywhere && !saidByPerson) issues.push({ field: one.field.name, code: 'not-in-source', blocking: false })\n }\n if (issues.length === row.issues.length) issues.push({ code: 'source-scattered', blocking: false })\n return { ...row, issues }\n })\n}\n\n/**\n * The total a file prints - a line named 합계 · 총계 · 총액 · total · sum, and the last amount on it. The server\n * reads it itself, so the card can compare even when the model did not say it (2026-10-01: once it did, once not).\n */\nexport function printedTotalOf(text: string): { value: number; line: number } | undefined {\n const lines = text.split(/\\r?\\n/)\n for (let i = lines.length - 1; i >= 0; i--) {\n if (!/(합\\s*계|총\\s*계|총\\s*액|total|sum)/i.test(lines[i])) continue\n const amounts = [...lines[i].matchAll(/-?\\d{1,3}(?:,\\d{3})+(?:\\.\\d+)?|-?\\d+(?:\\.\\d+)?/g)].map(match => Number(match[0].replace(/,/g, '')))\n if (amounts.length) return { value: amounts[amounts.length - 1], line: i + 1 }\n }\n return undefined\n}\n\nexport interface EntryTotal {\n field: string\n /** The sum over every row, and over the rows that will be entered. */\n all: number\n ready: number\n /** The total the material prints, as the model read it - and whether the server found it in the file. */\n declared?: number\n declaredFound?: boolean\n /** declared - all. */\n difference?: number\n /** Where the declared total came from - the model's reading, or the server's own from a file's total line. */\n declaredBy?: 'model' | 'file'\n}\n\n/** The sums of the fields declared `total`, and how they stand against the total the material prints. */\nexport function entryTotals(\n rows: EntryRow[],\n fields: EntryField[],\n declared: { field?: string; value?: unknown; attachmentId?: string } | undefined,\n texts: Map<string, string>\n): EntryTotal[] {\n const totalled = fields.filter(field => field.total && (field.type === 'number' || field.type === 'integer'))\n /* With one totalled field and no total from the model, the server looks for the file's own total line. */\n const printed = !declared && totalled.length === 1 ? [...texts.values()].map(printedTotalOf).find(Boolean) : undefined\n return totalled\n .map(field => {\n const sum = (list: EntryRow[]) => Math.round(list.reduce((acc, row) => acc + (typeof row.values[field.name] === 'number' ? (row.values[field.name] as number) : 0), 0) * 100) / 100\n const total: EntryTotal = { field: field.name, all: sum(rows), ready: sum(rows.filter(row => !isBlocked(row))) }\n if (printed) {\n total.declared = printed.value\n total.declaredFound = true\n total.declaredBy = 'file'\n total.difference = Math.round((printed.value - total.all) * 100) / 100\n return total\n }\n /*\n * With one totalled field the model's total is that field's, whatever it named it - on office's second card it\n * wrote the file's column name (이용금액) for amount, and the total was dropped (2026-10-01).\n */\n const mine = declared && (totalled.length === 1 || (declared.field ?? field.name) === field.name)\n const value = mine ? toNumber(declared!.value) : undefined\n if (value !== undefined) {\n total.declaredBy = 'model'\n total.declared = value\n total.difference = Math.round((value - total.all) * 100) / 100\n const text = declared!.attachmentId ? texts.get(declared!.attachmentId) : undefined\n if (text !== undefined) total.declaredFound = text.split(/\\r?\\n/).some(line => lineHas(line, writtenForms(field.type, value)))\n }\n return total\n })\n}\n\n/** The doors of the queries a target's reference fields reach - the person must pass them too. */\nexport function referenceDoorsOf(fields: EntryField[]): string[] {\n return [...new Set(fields.filter(field => field.type === 'reference' && field.reference).map(field => rootFieldOf(field.reference!.query, 'query')))]\n}\n\n/**\n * Settles each reference a row names by text, through the application's query as the person. One match keeps its\n * id and name; none or several keep the row out - several with their names, so the person can say which.\n */\nexport async function resolveReferences<T extends { values: Record<string, unknown>; issues: EntryIssue[] }>(\n fields: EntryField[],\n rows: T[],\n run: (document: string, variables: Record<string, unknown>) => Promise<{ data?: any; errors?: readonly { message: string }[] }>\n): Promise<T[]> {\n const references = fields.filter(field => field.type === 'reference' && field.reference)\n if (!references.length) return rows\n const asked = new Map<string, { id: string; label?: string }[] | Error>()\n for (const row of rows) {\n for (const field of references) {\n const value: any = row.values[field.name]\n if (!value || typeof value !== 'object' || typeof value.text !== 'string') continue\n const text = shownId(field, value.text)\n const key = `${field.name}\\u0000${text}`\n if (!asked.has(key)) {\n try {\n const answer = await run(field.reference!.query, field.reference!.variables(text))\n asked.set(key, answer.errors?.length ? new Error(answer.errors[0].message) : field.reference!.recordsOf(answer.data, text) ?? [])\n } catch (error: any) {\n asked.set(key, error instanceof Error ? error : new Error(String(error)))\n }\n }\n const found = asked.get(key)!\n if (found instanceof Error) {\n row.issues.push({ field: field.name, code: 'reference-unreadable', params: { text: value.text }, blocking: true })\n } else if (found.length === 1) {\n row.values[field.name] = { id: found[0].id, ...(found[0].label ? { label: found[0].label } : {}) }\n } else {\n row.issues.push({\n field: field.name,\n code: found.length ? 'reference-ambiguous' : 'reference-not-found',\n params: { text: value.text, ...(found.length ? { candidates: found.slice(0, 5).map(one => one.label || one.id).join(', ') } : {}) },\n blocking: true\n })\n }\n }\n }\n return rows\n}\n\n/** The rows by group, in the order groups first appear - `[key, rows]`. A row without the key is a group of its own. */\nexport function entryGroups<T extends { index: number; values: Record<string, unknown> }>(rows: T[], by: string): [string, T[]][] {\n const groups = new Map<string, T[]>()\n for (const row of rows) {\n const value = row.values[by]\n const key = value === undefined || value === null || value === '' ? `\\u0000row-${row.index}` : String(typeof value === 'object' ? (value as any).id ?? (value as any).text : value)\n groups.set(key, [...(groups.get(key) ?? []), row])\n }\n return [...groups.entries()]\n}\n\n/** The UTC offset a time zone has at a wall time - \"+09:00\". DST is taken at that day, not today. */\nexport function offsetAt(timeZone: string | undefined, wall: string): string | undefined {\n const match = wall.match(/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})$/)\n if (!match) return undefined\n const [y, mo, d, h, mi, se] = match.slice(1).map(Number)\n let format: Intl.DateTimeFormat\n try {\n format = new Intl.DateTimeFormat('en-US', { timeZone: timeZone || undefined, timeZoneName: 'longOffset', year: 'numeric' })\n } catch {\n return undefined\n }\n const minutesOf = (at: number) => {\n const name = format.formatToParts(new Date(at)).find(part => part.type === 'timeZoneName')?.value ?? 'GMT'\n const m = name.match(/GMT([+-])(\\d{2}):?(\\d{2})?/)\n return m ? (m[1] === '-' ? -1 : 1) * (Number(m[2]) * 60 + Number(m[3] ?? 0)) : 0\n }\n /* The offset at the wall time read as UTC, then once more at the instant that gives - right across a DST change. */\n const asUtc = Date.UTC(y, mo - 1, d, h, mi, se)\n const minutes = minutesOf(asUtc - minutesOf(asUtc) * 60_000)\n const sign = minutes < 0 ? '-' : '+'\n const abs = Math.abs(minutes)\n return `${sign}${String(Math.floor(abs / 60)).padStart(2, '0')}:${String(abs % 60).padStart(2, '0')}`\n}\n\n/**\n * A moment written without an offset is the domain's wall time - \"08:30\" in a factory is 08:30 there. Each such\n * value gets the domain time zone's offset at that day, so an API taking DateTimeISO accepts it and reads the moment\n * meant (plant refused every downtime log without it, 2026-10-01).\n */\nexport function zonedDateTimes<T extends { values: Record<string, unknown> }>(fields: EntryField[], rows: T[], timeZone: string | undefined): T[] {\n const moments = fields.filter(field => field.type === 'datetime')\n if (!moments.length) return rows\n for (const row of rows) {\n for (const field of moments) {\n const value = row.values[field.name]\n if (typeof value !== 'string' || !/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/.test(value)) continue\n const offset = offsetAt(timeZone, value)\n if (offset) row.values[field.name] = `${value}${offset}`\n }\n }\n return rows\n}\n\n"]}
|
|
@@ -160,7 +160,7 @@ function changeSpecs(target, run) {
|
|
|
160
160
|
/* The person must be able to read the records and change them by hand. */
|
|
161
161
|
doors: [...new Set([(0, entry_target_js_1.rootFieldOf)(update.mutation, 'mutation'), readDoor, ...(0, entry_target_js_1.referenceDoorsOf)((0, entry_update_js_1.changeableFields)(target))])],
|
|
162
162
|
description: `Propose changes to existing records: ${target.description} ` +
|
|
163
|
-
'Name each record by ref: "current" (the one on screen), "selected" (every row selected on screen)
|
|
163
|
+
'Name each record by ref: "current" (the one on screen), "selected" (every row selected on screen), the id a list read or a find tool returned, or the record\'s key (`<kind>:<id>`) as you were shown it - nothing need be selected to change rows a read found. ' +
|
|
164
164
|
'The server reads each record, and the card shows what it holds now and what it becomes; nothing changes until the person presses it.',
|
|
165
165
|
schema: {
|
|
166
166
|
type: 'object',
|
|
@@ -170,7 +170,7 @@ function changeSpecs(target, run) {
|
|
|
170
170
|
items: {
|
|
171
171
|
type: 'object',
|
|
172
172
|
properties: {
|
|
173
|
-
ref: { type: 'string', description: '"current", "selected",
|
|
173
|
+
ref: { type: 'string', description: '"current", "selected", a record id from a list read or a find tool, or the record\'s key as shown - never a guessed id.' },
|
|
174
174
|
values: { type: 'object', description: 'Only the fields that change, with their new values.', properties: Object.fromEntries((0, entry_update_js_1.changeableFields)(target).map(field => [field.name, fieldSchema(field)])) }
|
|
175
175
|
},
|
|
176
176
|
required: ['ref', 'values']
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-tools.js","sourceRoot":"","sources":["../../../server/service/data-entry/entry-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,wCAwDC;AAkED,0CA6EC;AAOD,kDAGC;AAtRD;;;;;;;;GAQG;AACH,mEAAuG;AAEvG,uDAAqG;AACrG,uDAqB0B;AAE1B,SAAS,WAAW,CAAC,KAAiB;IACpC;;;OAGG;IACH,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAA;IACxI,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,EAAE,uFAAuF,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;IACzP,MAAM,IAAI,GAAG;QACX,KAAK,CAAC,WAAW;QACjB,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU;QACxC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QAChD,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,oEAAoE,CAAC,CAAC,CAAC,SAAS;QAC5G,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CA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AA;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,MAAmB;IACrD,IAAA,oCAAkB,EAAC,MAAM,CAAC,CAAA;IAC1B,IAAA,qCAAoB,EAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["/*\n * The propose tool of each entry target (operato-application/design/ai/data-entry.md §3).\n *\n * One tool per target, so each carries its own door: the tool is offered only to a person who could enter\n * those records by hand, and its card cannot be made for someone who could not press it.\n *\n * The tool writes nothing. It reads the rows the model made from the material, puts each value in its\n * field's type, asks the target's own checks, and hands back a proposal - the card.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\n\nimport { findRecords, proposeChanges, changeableFields, type GraphqlRunner } from './entry-update.js'\nimport {\n changeToolName,\n findToolName,\n rootFieldOf,\n declareEntryTarget,\n entryTotals,\n verifyRowsAgainstSources,\n entryCategoryName,\n entryDoorOf,\n entryToolName,\n isBlocked,\n normalizeEntryRows,\n zonedDateTimes,\n entryGroups,\n referenceDoorsOf,\n resolveReferences,\n recordEntryEvent,\n withCheckedIssues,\n type EntryField,\n type EntryRow,\n type EntryTarget\n} from './entry-target.js'\n\nfunction fieldSchema(field: EntryField): any {\n /*\n * One type per field - Gemini's function schema (an OpenAPI 3.0 subset) refuses a list of types, and the\n * whole request with it: \"12,400\" or \"₩12,400\" is the model's to write as 12400 (2026-10-01, office).\n */\n const type = field.type === 'number' ? 'number' : field.type === 'integer' ? 'integer' : field.type === 'boolean' ? 'boolean' : 'string'\n if (field.type === 'reference') return { type: 'string', description: [field.description, field.required ? 'required' : 'optional', 'the name or code as the material or the person gives it - the server finds the record'].filter(Boolean).join('. ') }\n const said = [\n field.description,\n field.required ? 'required' : 'optional',\n field.type === 'date' ? 'YYYY-MM-DD' : undefined,\n field.type === 'datetime' ? 'YYYY-MM-DD HH:mm, with the offset only when the material gives one' : undefined,\n field.type === 'enum' ? `one of: ${field.values!.join(', ')}` : undefined\n ]\n .filter(Boolean)\n .join('. ')\n return { type, description: said }\n}\n\n/** What the card needs besides the rows - the columns, in the target's order. */\nfunction columnsOf(target: EntryTarget) {\n return target.fields.map(field => ({\n name: field.name,\n type: field.type,\n required: !!field.required,\n ...(field.labelKey ? { labelKey: field.labelKey } : {}),\n ...(field.valueKeyPrefix ? { valueKeyPrefix: field.valueKeyPrefix } : {})\n }))\n}\n\nexport type SourceTextLoader = (attachmentIds: string[], context: any) => Promise<Map<string, string>>\n\nconst readSources: SourceTextLoader = async (ids, context) => (await import('./entry-sources.js')).loadSourceTexts(ids, context)\n\nexport async function proposeEntries(target: EntryTarget, args: any, context: any, loadTexts: SourceTextLoader = readSources, run?: GraphqlRunner) {\n const tool = entryToolName(target.key)\n const told = (event: Omit<Parameters<typeof recordEntryEvent>[1], 'phase' | 'tool'>) => recordEntryEvent(target, { phase: 'propose', tool, ...event }, { state: context?.state })\n const { rows: normalized, cut } = normalizeEntryRows(target, args?.rows)\n if (!normalized.length) {\n await told({ rows: 0, ok: false, error: 'no-rows', detail: args })\n return { rejected: true, error: 'no-rows', message: 'no rows were given. Read the material and pass every record as a row.' }\n }\n\n /* The server looks in the cited files itself - the model's citation is not proof (design/ai/data-entry.md §4-1). */\n const declared = args?.declaredTotal && typeof args.declaredTotal === 'object' ? args.declaredTotal : undefined\n const cited = [...normalized.flatMap(row => row.sources.map(source => source.attachmentId)), declared?.attachmentId].filter((id): id is string => typeof id === 'string' && !!id)\n const texts = cited.length ? await loadTexts(cited, context).catch(() => new Map<string, string>()) : new Map<string, string>()\n /* A name the model wrote for another record is settled to its id by the application's query, as the person. */\n const resolved = await resolveReferences(target.fields, zonedDateTimes(target.fields, normalized, context?.state?.domain?.timezone), run ?? runAsCaller(context))\n const read = verifyRowsAgainstSources(resolved, target.fields, texts)\n\n let rows: EntryRow[] = read\n let checkFailed: string | undefined\n if (target.check) {\n try {\n rows = withCheckedIssues(read, await target.check(read, { state: context?.state }))\n } catch (error: any) {\n checkFailed = error?.message || 'check-failed'\n }\n }\n\n const blocked = rows.filter(isBlocked).length\n /* With lines grouped into records, the card counts the records and says which are kept out whole. */\n const groups = target.group ? entryGroups(rows, target.group.by) : undefined\n const groupCounts = groups ? { groups: groups.length, groupsReady: groups.filter(([, members]) => !members.some(isBlocked)).length } : {}\n const totals = entryTotals(rows, target.fields, declared, texts)\n const verified = rows.filter(row => row.evidence).length\n const unmatched = rows.filter(row => row.issues.some(issue => issue.code === 'not-in-source')).length\n await told({ rows: rows.length, ok: true, detail: args })\n return {\n proposed: true,\n kind: 'entry',\n target: target.key,\n labelKey: target.labelKey,\n label: `${rows.length} ${target.key} rows`,\n icon: 'playlist_add',\n columns: columnsOf(target),\n rows,\n counts: { rows: rows.length, ready: rows.length - blocked, blocked, cut, verified, unmatched, ...groupCounts },\n ...(target.group ? { groupBy: target.group.by } : {}),\n ...(totals.length ? { totals } : {}),\n ...(typeof args?.note === 'string' && args.note.trim() ? { reason: args.note.trim().slice(0, 300) } : {}),\n ...(checkFailed ? { checkFailed } : {}),\n /* For the model - the card is the answer; it says what the person must still decide. */\n message:\n `proposed ${rows.length} rows (${rows.length - blocked} ready, ${blocked} blocked${cut ? `, ${cut} cut over the limit` : ''}; ` +\n `${verified} found line by line in their files, ${unmatched} with a value the file does not have). ` +\n totals.filter(total => total.difference).map(total => `${total.field}: the material's total differs from the rows by ${total.difference}. `).join('') +\n 'nothing is written until the person presses the button on the card. Tell them which rows are blocked or do not match their file, and why, and ask for what is missing.'\n }\n}\n\n/**\n * The application's API as the person who asked - the tool's own request state, no transaction handed on.\n * Loaded late so the rules are tested without the shell.\n */\nexport const runAsCaller = (context: any): GraphqlRunner => async (document, variables) => {\n const [{ GraphqlLocalClient }, { default: gql }] = await Promise.all([import('@things-factory/shell'), import('graphql-tag')])\n const { tx: _tx, afterCommit: _after, ...state } = context?.state ?? {}\n const operation = /^\\s*mutation\\b/.test(document) ? 'mutate' : 'query'\n const result: any =\n operation === 'mutate'\n ? await GraphqlLocalClient.client.mutate({ mutation: gql(document), variables, context: { state, t: context?.t } })\n : await GraphqlLocalClient.client.query({ query: gql(document), variables, context: { state, t: context?.t }, fetchPolicy: 'no-cache' })\n return { data: result.data, errors: result.errors }\n}\n\n/** The two tools of changing records - finding candidates, and the 수정안 (design/ai/data-entry.md §5-1). */\nfunction changeSpecs(target: EntryTarget, run: (context: any) => GraphqlRunner): ToolSpec[] {\n const update = target.update\n if (!update) return []\n const readDoor = rootFieldOf(update.read.query, 'query')\n const specs: ToolSpec[] = [\n {\n kind: 'read',\n name: changeToolName(target.key),\n /* The person must be able to read the records and change them by hand. */\n doors: [...new Set([rootFieldOf(update.mutation, 'mutation'), readDoor, ...referenceDoorsOf(changeableFields(target))])],\n description:\n `Propose changes to existing records: ${target.description} ` +\n 'Name each record by ref: \"current\" (the one on screen), \"selected\" (every row selected on screen) or an id a find tool returned. ' +\n 'The server reads each record, and the card shows what it holds now and what it becomes; nothing changes until the person presses it.',\n schema: {\n type: 'object',\n properties: {\n changes: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n ref: { type: 'string', description: '\"current\", \"selected\", or a record id from a find tool - never a guessed id.' },\n values: { type: 'object', description: 'Only the fields that change, with their new values.', properties: Object.fromEntries(changeableFields(target).map(field => [field.name, fieldSchema(field)])) }\n },\n required: ['ref', 'values']\n }\n },\n note: { type: 'string', description: 'One line for the card.' }\n },\n required: ['changes']\n },\n builder: (args: any, context: any) => proposeChanges(target, args, context, run(context))\n } as ToolSpec\n ]\n if (update.find) {\n specs.push({\n kind: 'read',\n name: findToolName(target.key),\n doors: [rootFieldOf(update.find.query, 'query')],\n description: `Find existing records to change from what the person described: ${target.description} Returns candidates with their ids.`,\n schema: { type: 'object', properties: Object.fromEntries(update.find.criteria.map(field => [field.name, fieldSchema(field)])) },\n builder: (args: any, context: any) => findRecords(target, args, run(context))\n } as ToolSpec)\n }\n return specs\n}\n\nexport function entryCategoryOf(target: EntryTarget, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {\n const name = entryToolName(target.key)\n const spec = {\n kind: 'read',\n name,\n /* The person must be able to enter these records themselves - the tool is not a second way in. */\n doors: [entryDoorOf(target.mutation), ...referenceDoorsOf(target.fields)],\n description:\n `Propose records to enter: ${target.description} ` +\n (target.group ? `Each row is one line; the rows of one record share the same ${target.group.by}. ` : '') +\n 'Pass every record found in the material as one row. The rows are shown to the person as a card; nothing is written until they press it.',\n schema: {\n type: 'object',\n properties: {\n rows: {\n type: 'array',\n description: `At most ${target.maxRows ?? 200} rows.`,\n items: {\n type: 'object',\n properties: {\n values: {\n type: 'object',\n properties: Object.fromEntries(target.fields.map(field => [field.name, fieldSchema(field)]))\n },\n sources: {\n type: 'array',\n description: 'Where this row came from: the attachment id and where in it, and { person: true } for a value the person said.',\n items: {\n type: 'object',\n properties: {\n attachmentId: { type: 'string' },\n where: { type: 'string', description: 'Where in the attachment, in the person\\'s language (\"3번째 줄\", \"영수증 사진\").' },\n person: { type: 'boolean', description: 'true when the value came from what the person said in the conversation.' }\n }\n }\n }\n },\n required: ['values', 'sources']\n }\n },\n note: { type: 'string', description: 'One line for the card - what this set is (\"September card statement\").' },\n declaredTotal: {\n type: 'object',\n description: 'The total the material itself prints, when it prints one - the card compares it with the sum of the rows. Never compute it yourself.',\n properties: {\n field: { type: 'string', description: `Which field it totals${target.fields.filter(field => field.total).length ? ` (${target.fields.filter(field => field.total).map(field => field.name).join(', ')})` : ''}.` },\n value: { type: 'number' },\n attachmentId: { type: 'string' },\n where: { type: 'string' }\n }\n }\n },\n required: ['rows']\n },\n builder: (args: any, context: any) => proposeEntries(target, args, context, readSources, run(context))\n } as ToolSpec\n\n return {\n name: entryCategoryName(target.key),\n description: `data entry: ${target.key}`,\n guidance: [\n `- When the person gives material to enter as records (files, photos, pasted text), read all of it first - call readChatAttachment for a file sent in an earlier turn - then call ${name} once with every record as a row.`,\n '- Never invent a value. Leave a field out when the material does not say it; the card marks it, and you ask the person for it.',\n '- A row kept out because a name was not found, or matches several records, is settled in the conversation: say which name, list the candidates the card names, and ask; then propose again with the name the person chose. The card has no picker - never tell the person to choose on it.',\n '- Give each row its sources: which attachment and where in it, written in the person\\'s language. A value the person gave or corrected in the conversation adds the source { person: true }. The server looks for each row\\'s numbers and dates in the cited file and marks what it does not find.',\n '- When the material prints a total, always pass it as declaredTotal exactly as printed - do not add it up yourself. The server also reads a total line of a text file itself.',\n `- ${name} only proposes. Nothing is entered until the person presses the button on the card - never say the records were entered.`,\n `- When the person corrects or drops rows, call ${name} again with the whole corrected set. The newest card replaces the earlier ones; an earlier card can no longer be entered.`,\n ...(target.update\n ? [\n `- To change records that exist, call ${changeToolName(target.key)}. Use ref \"current\" for the record on screen and \"selected\" for the rows selected there.${target.update.find ? ` Otherwise call ${findToolName(target.key)} first with what the person said; if more than one record matches, list them and ask which - never pick one yourself.` : ' Otherwise ask the person to open or select the record.'}`,\n `- ${changeToolName(target.key)} only proposes; the card shows each record's value now and after. Never say a record was changed.`\n ]\n : [])\n ].join('\\n'),\n specs: [spec, ...changeSpecs(target, run)]\n }\n}\n\n/**\n * What an application calls at boot to let the assistant enter one of its records.\n *\n * A mode opens it by naming the key in `entryTargets` (the tool is not in every conversation of the app).\n */\nexport function registerEntryTarget(target: EntryTarget): void {\n declareEntryTarget(target)\n registerToolCategory(entryCategoryOf(target))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entry-tools.js","sourceRoot":"","sources":["../../../server/service/data-entry/entry-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,wCAwDC;AAkED,0CA6EC;AAOD,kDAGC;AAtRD;;;;;;;;GAQG;AACH,mEAAuG;AAEvG,uDAAqG;AACrG,uDAqB0B;AAE1B,SAAS,WAAW,CAAC,KAAiB;IACpC;;;OAGG;IACH,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CA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AA,mCAAiB,EAAC,MAAM,CAAC,GAAG,CAAC;QACnC,WAAW,EAAE,eAAe,MAAM,CAAC,GAAG,EAAE;QACxC,QAAQ,EAAE;YACR,oLAAoL,IAAI,mCAAmC;YAC3N,gIAAgI;YAChI,4RAA4R;YAC5R,oSAAoS;YACpS,+KAA+K;YAC/K,KAAK,IAAI,0HAA0H;YACnI,kDAAkD,IAAI,2HAA2H;YACjL,GAAG,CAAC,MAAM,CAAC,MAAM;gBACf,CAAC,CAAC;oBACE,wCAAwC,IAAA,gCAAc,EAAC,MAAM,CAAC,GAAG,CAAC,2FAA2F,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,IAAA,8BAAY,EAAC,MAAM,CAAC,GAAG,CAAC,uHAAuH,CAAC,CAAC,CAAC,yDAAyD,EAAE;oBAClZ,KAAK,IAAA,gCAAc,EAAC,MAAM,CAAC,GAAG,CAAC,mGAAmG;iBACnI;gBACH,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC3C,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,MAAmB;IACrD,IAAA,oCAAkB,EAAC,MAAM,CAAC,CAAA;IAC1B,IAAA,qCAAoB,EAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["/*\n * The propose tool of each entry target (operato-application/design/ai/data-entry.md §3).\n *\n * One tool per target, so each carries its own door: the tool is offered only to a person who could enter\n * those records by hand, and its card cannot be made for someone who could not press it.\n *\n * The tool writes nothing. It reads the rows the model made from the material, puts each value in its\n * field's type, asks the target's own checks, and hands back a proposal - the card.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\n\nimport { findRecords, proposeChanges, changeableFields, type GraphqlRunner } from './entry-update.js'\nimport {\n changeToolName,\n findToolName,\n rootFieldOf,\n declareEntryTarget,\n entryTotals,\n verifyRowsAgainstSources,\n entryCategoryName,\n entryDoorOf,\n entryToolName,\n isBlocked,\n normalizeEntryRows,\n zonedDateTimes,\n entryGroups,\n referenceDoorsOf,\n resolveReferences,\n recordEntryEvent,\n withCheckedIssues,\n type EntryField,\n type EntryRow,\n type EntryTarget\n} from './entry-target.js'\n\nfunction fieldSchema(field: EntryField): any {\n /*\n * One type per field - Gemini's function schema (an OpenAPI 3.0 subset) refuses a list of types, and the\n * whole request with it: \"12,400\" or \"₩12,400\" is the model's to write as 12400 (2026-10-01, office).\n */\n const type = field.type === 'number' ? 'number' : field.type === 'integer' ? 'integer' : field.type === 'boolean' ? 'boolean' : 'string'\n if (field.type === 'reference') return { type: 'string', description: [field.description, field.required ? 'required' : 'optional', 'the name or code as the material or the person gives it - the server finds the record'].filter(Boolean).join('. ') }\n const said = [\n field.description,\n field.required ? 'required' : 'optional',\n field.type === 'date' ? 'YYYY-MM-DD' : undefined,\n field.type === 'datetime' ? 'YYYY-MM-DD HH:mm, with the offset only when the material gives one' : undefined,\n field.type === 'enum' ? `one of: ${field.values!.join(', ')}` : undefined\n ]\n .filter(Boolean)\n .join('. ')\n return { type, description: said }\n}\n\n/** What the card needs besides the rows - the columns, in the target's order. */\nfunction columnsOf(target: EntryTarget) {\n return target.fields.map(field => ({\n name: field.name,\n type: field.type,\n required: !!field.required,\n ...(field.labelKey ? { labelKey: field.labelKey } : {}),\n ...(field.valueKeyPrefix ? { valueKeyPrefix: field.valueKeyPrefix } : {})\n }))\n}\n\nexport type SourceTextLoader = (attachmentIds: string[], context: any) => Promise<Map<string, string>>\n\nconst readSources: SourceTextLoader = async (ids, context) => (await import('./entry-sources.js')).loadSourceTexts(ids, context)\n\nexport async function proposeEntries(target: EntryTarget, args: any, context: any, loadTexts: SourceTextLoader = readSources, run?: GraphqlRunner) {\n const tool = entryToolName(target.key)\n const told = (event: Omit<Parameters<typeof recordEntryEvent>[1], 'phase' | 'tool'>) => recordEntryEvent(target, { phase: 'propose', tool, ...event }, { state: context?.state })\n const { rows: normalized, cut } = normalizeEntryRows(target, args?.rows)\n if (!normalized.length) {\n await told({ rows: 0, ok: false, error: 'no-rows', detail: args })\n return { rejected: true, error: 'no-rows', message: 'no rows were given. Read the material and pass every record as a row.' }\n }\n\n /* The server looks in the cited files itself - the model's citation is not proof (design/ai/data-entry.md §4-1). */\n const declared = args?.declaredTotal && typeof args.declaredTotal === 'object' ? args.declaredTotal : undefined\n const cited = [...normalized.flatMap(row => row.sources.map(source => source.attachmentId)), declared?.attachmentId].filter((id): id is string => typeof id === 'string' && !!id)\n const texts = cited.length ? await loadTexts(cited, context).catch(() => new Map<string, string>()) : new Map<string, string>()\n /* A name the model wrote for another record is settled to its id by the application's query, as the person. */\n const resolved = await resolveReferences(target.fields, zonedDateTimes(target.fields, normalized, context?.state?.domain?.timezone), run ?? runAsCaller(context))\n const read = verifyRowsAgainstSources(resolved, target.fields, texts)\n\n let rows: EntryRow[] = read\n let checkFailed: string | undefined\n if (target.check) {\n try {\n rows = withCheckedIssues(read, await target.check(read, { state: context?.state }))\n } catch (error: any) {\n checkFailed = error?.message || 'check-failed'\n }\n }\n\n const blocked = rows.filter(isBlocked).length\n /* With lines grouped into records, the card counts the records and says which are kept out whole. */\n const groups = target.group ? entryGroups(rows, target.group.by) : undefined\n const groupCounts = groups ? { groups: groups.length, groupsReady: groups.filter(([, members]) => !members.some(isBlocked)).length } : {}\n const totals = entryTotals(rows, target.fields, declared, texts)\n const verified = rows.filter(row => row.evidence).length\n const unmatched = rows.filter(row => row.issues.some(issue => issue.code === 'not-in-source')).length\n await told({ rows: rows.length, ok: true, detail: args })\n return {\n proposed: true,\n kind: 'entry',\n target: target.key,\n labelKey: target.labelKey,\n label: `${rows.length} ${target.key} rows`,\n icon: 'playlist_add',\n columns: columnsOf(target),\n rows,\n counts: { rows: rows.length, ready: rows.length - blocked, blocked, cut, verified, unmatched, ...groupCounts },\n ...(target.group ? { groupBy: target.group.by } : {}),\n ...(totals.length ? { totals } : {}),\n ...(typeof args?.note === 'string' && args.note.trim() ? { reason: args.note.trim().slice(0, 300) } : {}),\n ...(checkFailed ? { checkFailed } : {}),\n /* For the model - the card is the answer; it says what the person must still decide. */\n message:\n `proposed ${rows.length} rows (${rows.length - blocked} ready, ${blocked} blocked${cut ? `, ${cut} cut over the limit` : ''}; ` +\n `${verified} found line by line in their files, ${unmatched} with a value the file does not have). ` +\n totals.filter(total => total.difference).map(total => `${total.field}: the material's total differs from the rows by ${total.difference}. `).join('') +\n 'nothing is written until the person presses the button on the card. Tell them which rows are blocked or do not match their file, and why, and ask for what is missing.'\n }\n}\n\n/**\n * The application's API as the person who asked - the tool's own request state, no transaction handed on.\n * Loaded late so the rules are tested without the shell.\n */\nexport const runAsCaller = (context: any): GraphqlRunner => async (document, variables) => {\n const [{ GraphqlLocalClient }, { default: gql }] = await Promise.all([import('@things-factory/shell'), import('graphql-tag')])\n const { tx: _tx, afterCommit: _after, ...state } = context?.state ?? {}\n const operation = /^\\s*mutation\\b/.test(document) ? 'mutate' : 'query'\n const result: any =\n operation === 'mutate'\n ? await GraphqlLocalClient.client.mutate({ mutation: gql(document), variables, context: { state, t: context?.t } })\n : await GraphqlLocalClient.client.query({ query: gql(document), variables, context: { state, t: context?.t }, fetchPolicy: 'no-cache' })\n return { data: result.data, errors: result.errors }\n}\n\n/** The two tools of changing records - finding candidates, and the 수정안 (design/ai/data-entry.md §5-1). */\nfunction changeSpecs(target: EntryTarget, run: (context: any) => GraphqlRunner): ToolSpec[] {\n const update = target.update\n if (!update) return []\n const readDoor = rootFieldOf(update.read.query, 'query')\n const specs: ToolSpec[] = [\n {\n kind: 'read',\n name: changeToolName(target.key),\n /* The person must be able to read the records and change them by hand. */\n doors: [...new Set([rootFieldOf(update.mutation, 'mutation'), readDoor, ...referenceDoorsOf(changeableFields(target))])],\n description:\n `Propose changes to existing records: ${target.description} ` +\n 'Name each record by ref: \"current\" (the one on screen), \"selected\" (every row selected on screen), the id a list read or a find tool returned, or the record\\'s key (`<kind>:<id>`) as you were shown it - nothing need be selected to change rows a read found. ' +\n 'The server reads each record, and the card shows what it holds now and what it becomes; nothing changes until the person presses it.',\n schema: {\n type: 'object',\n properties: {\n changes: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n ref: { type: 'string', description: '\"current\", \"selected\", a record id from a list read or a find tool, or the record\\'s key as shown - never a guessed id.' },\n values: { type: 'object', description: 'Only the fields that change, with their new values.', properties: Object.fromEntries(changeableFields(target).map(field => [field.name, fieldSchema(field)])) }\n },\n required: ['ref', 'values']\n }\n },\n note: { type: 'string', description: 'One line for the card.' }\n },\n required: ['changes']\n },\n builder: (args: any, context: any) => proposeChanges(target, args, context, run(context))\n } as ToolSpec\n ]\n if (update.find) {\n specs.push({\n kind: 'read',\n name: findToolName(target.key),\n doors: [rootFieldOf(update.find.query, 'query')],\n description: `Find existing records to change from what the person described: ${target.description} Returns candidates with their ids.`,\n schema: { type: 'object', properties: Object.fromEntries(update.find.criteria.map(field => [field.name, fieldSchema(field)])) },\n builder: (args: any, context: any) => findRecords(target, args, run(context))\n } as ToolSpec)\n }\n return specs\n}\n\nexport function entryCategoryOf(target: EntryTarget, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {\n const name = entryToolName(target.key)\n const spec = {\n kind: 'read',\n name,\n /* The person must be able to enter these records themselves - the tool is not a second way in. */\n doors: [entryDoorOf(target.mutation), ...referenceDoorsOf(target.fields)],\n description:\n `Propose records to enter: ${target.description} ` +\n (target.group ? `Each row is one line; the rows of one record share the same ${target.group.by}. ` : '') +\n 'Pass every record found in the material as one row. The rows are shown to the person as a card; nothing is written until they press it.',\n schema: {\n type: 'object',\n properties: {\n rows: {\n type: 'array',\n description: `At most ${target.maxRows ?? 200} rows.`,\n items: {\n type: 'object',\n properties: {\n values: {\n type: 'object',\n properties: Object.fromEntries(target.fields.map(field => [field.name, fieldSchema(field)]))\n },\n sources: {\n type: 'array',\n description: 'Where this row came from: the attachment id and where in it, and { person: true } for a value the person said.',\n items: {\n type: 'object',\n properties: {\n attachmentId: { type: 'string' },\n where: { type: 'string', description: 'Where in the attachment, in the person\\'s language (\"3번째 줄\", \"영수증 사진\").' },\n person: { type: 'boolean', description: 'true when the value came from what the person said in the conversation.' }\n }\n }\n }\n },\n required: ['values', 'sources']\n }\n },\n note: { type: 'string', description: 'One line for the card - what this set is (\"September card statement\").' },\n declaredTotal: {\n type: 'object',\n description: 'The total the material itself prints, when it prints one - the card compares it with the sum of the rows. Never compute it yourself.',\n properties: {\n field: { type: 'string', description: `Which field it totals${target.fields.filter(field => field.total).length ? ` (${target.fields.filter(field => field.total).map(field => field.name).join(', ')})` : ''}.` },\n value: { type: 'number' },\n attachmentId: { type: 'string' },\n where: { type: 'string' }\n }\n }\n },\n required: ['rows']\n },\n builder: (args: any, context: any) => proposeEntries(target, args, context, readSources, run(context))\n } as ToolSpec\n\n return {\n name: entryCategoryName(target.key),\n description: `data entry: ${target.key}`,\n guidance: [\n `- When the person gives material to enter as records (files, photos, pasted text), read all of it first - call readChatAttachment for a file sent in an earlier turn - then call ${name} once with every record as a row.`,\n '- Never invent a value. Leave a field out when the material does not say it; the card marks it, and you ask the person for it.',\n '- A row kept out because a name was not found, or matches several records, is settled in the conversation: say which name, list the candidates the card names, and ask; then propose again with the name the person chose. The card has no picker - never tell the person to choose on it.',\n '- Give each row its sources: which attachment and where in it, written in the person\\'s language. A value the person gave or corrected in the conversation adds the source { person: true }. The server looks for each row\\'s numbers and dates in the cited file and marks what it does not find.',\n '- When the material prints a total, always pass it as declaredTotal exactly as printed - do not add it up yourself. The server also reads a total line of a text file itself.',\n `- ${name} only proposes. Nothing is entered until the person presses the button on the card - never say the records were entered.`,\n `- When the person corrects or drops rows, call ${name} again with the whole corrected set. The newest card replaces the earlier ones; an earlier card can no longer be entered.`,\n ...(target.update\n ? [\n `- To change records that exist, call ${changeToolName(target.key)}. Use ref \"current\" for the record on screen and \"selected\" for the rows selected there.${target.update.find ? ` Otherwise call ${findToolName(target.key)} first with what the person said; if more than one record matches, list them and ask which - never pick one yourself.` : ' Otherwise ask the person to open or select the record.'}`,\n `- ${changeToolName(target.key)} only proposes; the card shows each record's value now and after. Never say a record was changed.`\n ]\n : [])\n ].join('\\n'),\n specs: [spec, ...changeSpecs(target, run)]\n }\n}\n\n/**\n * What an application calls at boot to let the assistant enter one of its records.\n *\n * A mode opens it by naming the key in `entryTargets` (the tool is not in every conversation of the app).\n */\nexport function registerEntryTarget(target: EntryTarget): void {\n declareEntryTarget(target)\n registerToolCategory(entryCategoryOf(target))\n}\n"]}
|
|
@@ -24,7 +24,8 @@ export declare function changeableFields(target: EntryTarget): EntryField[];
|
|
|
24
24
|
/**
|
|
25
25
|
* The records the changes name. `current` is the record on screen, `selected` every row selected there -
|
|
26
26
|
* both from the surface's host context, which is **not trusted**: an id from it is only a candidate, read
|
|
27
|
-
* through the application before anything is shown. Any other ref is an id, from the find tool
|
|
27
|
+
* through the application before anything is shown. Any other ref is an id, from the find tool, or the key the record
|
|
28
|
+
* was shown by.
|
|
28
29
|
*/
|
|
29
30
|
export declare function resolveChangeRefs(targetKey: string, changes: unknown, host: Record<string, any> | undefined): {
|
|
30
31
|
picked: {
|
|
@@ -31,7 +31,8 @@ function changeableFields(target) {
|
|
|
31
31
|
/**
|
|
32
32
|
* The records the changes name. `current` is the record on screen, `selected` every row selected there -
|
|
33
33
|
* both from the surface's host context, which is **not trusted**: an id from it is only a candidate, read
|
|
34
|
-
* through the application before anything is shown. Any other ref is an id, from the find tool
|
|
34
|
+
* through the application before anything is shown. Any other ref is an id, from the find tool, or the key the record
|
|
35
|
+
* was shown by.
|
|
35
36
|
*/
|
|
36
37
|
function resolveChangeRefs(targetKey, changes, host) {
|
|
37
38
|
const picked = [];
|
|
@@ -56,7 +57,8 @@ function resolveChangeRefs(targetKey, changes, host) {
|
|
|
56
57
|
unresolved.push('selected');
|
|
57
58
|
}
|
|
58
59
|
else if (ref) {
|
|
59
|
-
|
|
60
|
+
/* An open record's key - `contract-round:<id>` for `office.contract-round` - names the record of this target's axis. */
|
|
61
|
+
picked.push({ id: (0, entry_target_js_1.recordIdOfKey)(targetKey.split('.').pop(), ref) ?? ref, via: 'id', values });
|
|
60
62
|
}
|
|
61
63
|
else {
|
|
62
64
|
unresolved.push('no-ref');
|
|
@@ -130,7 +132,7 @@ async function proposeChanges(target, args, context, run) {
|
|
|
130
132
|
error: unresolved.length ? `unresolved-${unresolved[0]}` : 'no-changes',
|
|
131
133
|
message: unresolved[0] === 'current' || unresolved[0] === 'selected'
|
|
132
134
|
? `the screen names no ${unresolved[0] === 'current' ? 'record' : 'selected rows'} of this kind. Ask the person which record, or call ${(0, entry_target_js_1.findToolName)(target.key)}.`
|
|
133
|
-
: `name each record: ref "current", "selected", or an id
|
|
135
|
+
: `name each record: ref "current", "selected", or an id a list read or ${(0, entry_target_js_1.findToolName)(target.key)} returned. Never guess an id.`
|
|
134
136
|
};
|
|
135
137
|
}
|
|
136
138
|
let records;
|