@things-factory/ai-assistant 10.1.207 → 10.1.208

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.
Files changed (43) hide show
  1. package/client/setup-assistant-dock.ts +1 -0
  2. package/dist-client/setup-assistant-dock.js +1 -0
  3. package/dist-client/setup-assistant-dock.js.map +1 -1
  4. package/dist-client/tsconfig.tsbuildinfo +1 -1
  5. package/dist-server/service/assistant-mode/index.d.ts +1 -1
  6. package/dist-server/service/assistant-mode/index.js +3 -1
  7. package/dist-server/service/assistant-mode/index.js.map +1 -1
  8. package/dist-server/service/assistant-mode/screen-rules.d.ts +13 -0
  9. package/dist-server/service/assistant-mode/screen-rules.js +32 -5
  10. package/dist-server/service/assistant-mode/screen-rules.js.map +1 -1
  11. package/dist-server/service/data-entry/entry-target.d.ts +13 -0
  12. package/dist-server/service/data-entry/entry-target.js +20 -5
  13. package/dist-server/service/data-entry/entry-target.js.map +1 -1
  14. package/dist-server/service/data-entry/entry-tools.js +2 -2
  15. package/dist-server/service/data-entry/entry-tools.js.map +1 -1
  16. package/dist-server/service/data-entry/entry-update.d.ts +2 -1
  17. package/dist-server/service/data-entry/entry-update.js +4 -2
  18. package/dist-server/service/data-entry/entry-update.js.map +1 -1
  19. package/dist-server/service/data-read/read-target.d.ts +2 -0
  20. package/dist-server/service/data-read/read-target.js +2 -2
  21. package/dist-server/service/data-read/read-target.js.map +1 -1
  22. package/dist-server/service/data-read/read-tools.js +1 -1
  23. package/dist-server/service/data-read/read-tools.js.map +1 -1
  24. package/dist-server/service/testing/mode-conformance.js +2 -0
  25. package/dist-server/service/testing/mode-conformance.js.map +1 -1
  26. package/dist-server/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +9 -9
  28. package/server/explicit-graphql-types.test.ts +1 -1
  29. package/server/service/assistant-mode/index.ts +1 -1
  30. package/server/service/assistant-mode/resolve.test.ts +2 -1
  31. package/server/service/assistant-mode/screen-rules.test.ts +35 -3
  32. package/server/service/assistant-mode/screen-rules.ts +34 -4
  33. package/server/service/chat-message/fold-history-window.test.ts +1 -1
  34. package/server/service/data-entry/data-entry-update.test.ts +11 -0
  35. package/server/service/data-entry/data-entry.test.ts +65 -1
  36. package/server/service/data-entry/entry-target.ts +30 -5
  37. package/server/service/data-entry/entry-tools.ts +2 -2
  38. package/server/service/data-entry/entry-update.ts +5 -2
  39. package/server/service/data-read/read-target.ts +5 -3
  40. package/server/service/data-read/read-tools.ts +1 -1
  41. package/server/service/data-read/record-keys.test.ts +36 -0
  42. package/server/service/testing/mode-conformance.ts +1 -0
  43. package/translations/ko.json +2 -2
@@ -5,6 +5,6 @@
5
5
  */
6
6
  export { registerAssistantMode, getAssistantMode, listAssistantModes, assistantModeForSubject, getAssistantModeWarnings, clearAssistantModes } from './registry.js';
7
7
  export { resolveModeSettings, assistantModeView } from './resolve.js';
8
- export { ABSENCE_RULE, NEXT_REQUEST_RULE, conversationPrompt, splitNextRequest } from './screen-rules.js';
8
+ export { ABSENCE_RULE, FINISH_RULE, NEXT_REQUEST_RULE, conversationPrompt, isPersonRequest, splitNextRequest } from './screen-rules.js';
9
9
  export type { AssistantModeSpec, AssistantModeSlash, AssistantModeWarning, UnattendedLimits } from './types.js';
10
10
  export type { AssistantModeRef, ModeSettings, AssistantModeView, AssistantModeSlashView, Translate } from './resolve.js';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitNextRequest = exports.conversationPrompt = exports.NEXT_REQUEST_RULE = exports.ABSENCE_RULE = exports.assistantModeView = exports.resolveModeSettings = exports.clearAssistantModes = exports.getAssistantModeWarnings = exports.assistantModeForSubject = exports.listAssistantModes = exports.getAssistantMode = exports.registerAssistantMode = void 0;
3
+ exports.splitNextRequest = exports.isPersonRequest = exports.conversationPrompt = exports.NEXT_REQUEST_RULE = exports.FINISH_RULE = exports.ABSENCE_RULE = exports.assistantModeView = exports.resolveModeSettings = exports.clearAssistantModes = exports.getAssistantModeWarnings = exports.assistantModeForSubject = exports.listAssistantModes = exports.getAssistantMode = exports.registerAssistantMode = void 0;
4
4
  /**
5
5
  * Modes — what each conversation is, declared by the app server that owns the screen.
6
6
  *
@@ -18,7 +18,9 @@ Object.defineProperty(exports, "resolveModeSettings", { enumerable: true, get: f
18
18
  Object.defineProperty(exports, "assistantModeView", { enumerable: true, get: function () { return resolve_js_1.assistantModeView; } });
19
19
  var screen_rules_js_1 = require("./screen-rules.js");
20
20
  Object.defineProperty(exports, "ABSENCE_RULE", { enumerable: true, get: function () { return screen_rules_js_1.ABSENCE_RULE; } });
21
+ Object.defineProperty(exports, "FINISH_RULE", { enumerable: true, get: function () { return screen_rules_js_1.FINISH_RULE; } });
21
22
  Object.defineProperty(exports, "NEXT_REQUEST_RULE", { enumerable: true, get: function () { return screen_rules_js_1.NEXT_REQUEST_RULE; } });
22
23
  Object.defineProperty(exports, "conversationPrompt", { enumerable: true, get: function () { return screen_rules_js_1.conversationPrompt; } });
24
+ Object.defineProperty(exports, "isPersonRequest", { enumerable: true, get: function () { return screen_rules_js_1.isPersonRequest; } });
23
25
  Object.defineProperty(exports, "splitNextRequest", { enumerable: true, get: function () { return screen_rules_js_1.splitNextRequest; } });
24
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/assistant-mode/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,6CAOsB;AANpB,oHAAA,qBAAqB,OAAA;AACrB,+GAAA,gBAAgB,OAAA;AAChB,iHAAA,kBAAkB,OAAA;AAClB,sHAAA,uBAAuB,OAAA;AACvB,uHAAA,wBAAwB,OAAA;AACxB,kHAAA,mBAAmB,OAAA;AAErB,2CAAqE;AAA5D,iHAAA,mBAAmB,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAC/C,qDAAyG;AAAhG,+GAAA,YAAY,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,qHAAA,kBAAkB,OAAA;AAAE,mHAAA,gBAAgB,OAAA","sourcesContent":["/**\n * Modes — what each conversation is, declared by the app server that owns the screen.\n *\n * Design: ADR-0061 decision 7 (`operato-application/adr/ADR-0061.md`) and the AI standard's A2.\n */\nexport {\n registerAssistantMode,\n getAssistantMode,\n listAssistantModes,\n assistantModeForSubject,\n getAssistantModeWarnings,\n clearAssistantModes\n} from './registry.js'\nexport { resolveModeSettings, assistantModeView } from './resolve.js'\nexport { ABSENCE_RULE, NEXT_REQUEST_RULE, conversationPrompt, splitNextRequest } from './screen-rules.js'\nexport type { AssistantModeSpec, AssistantModeSlash, AssistantModeWarning, UnattendedLimits } from './types.js'\nexport type { AssistantModeRef, ModeSettings, AssistantModeView, AssistantModeSlashView, Translate } from './resolve.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/assistant-mode/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,6CAOsB;AANpB,oHAAA,qBAAqB,OAAA;AACrB,+GAAA,gBAAgB,OAAA;AAChB,iHAAA,kBAAkB,OAAA;AAClB,sHAAA,uBAAuB,OAAA;AACvB,uHAAA,wBAAwB,OAAA;AACxB,kHAAA,mBAAmB,OAAA;AAErB,2CAAqE;AAA5D,iHAAA,mBAAmB,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAC/C,qDAAuI;AAA9H,+GAAA,YAAY,OAAA;AAAE,8GAAA,WAAW,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,qHAAA,kBAAkB,OAAA;AAAE,kHAAA,eAAe,OAAA;AAAE,mHAAA,gBAAgB,OAAA","sourcesContent":["/**\n * Modes — what each conversation is, declared by the app server that owns the screen.\n *\n * Design: ADR-0061 decision 7 (`operato-application/adr/ADR-0061.md`) and the AI standard's A2.\n */\nexport {\n registerAssistantMode,\n getAssistantMode,\n listAssistantModes,\n assistantModeForSubject,\n getAssistantModeWarnings,\n clearAssistantModes\n} from './registry.js'\nexport { resolveModeSettings, assistantModeView } from './resolve.js'\nexport { ABSENCE_RULE, FINISH_RULE, NEXT_REQUEST_RULE, conversationPrompt, isPersonRequest, splitNextRequest } from './screen-rules.js'\nexport type { AssistantModeSpec, AssistantModeSlash, AssistantModeWarning, UnattendedLimits } from './types.js'\nexport type { AssistantModeRef, ModeSettings, AssistantModeView, AssistantModeSlashView, Translate } from './resolve.js'\n"]}
@@ -9,10 +9,23 @@
9
9
  */
10
10
  /** §4-2 — an absence or a refusal is a fact, with what the person can do. */
11
11
  export declare const ABSENCE_RULE: string;
12
+ /**
13
+ * §4-3 — a request is finished in the turn it is asked (2026-10-23, the user: 「한번에 끝낼 일을 왜 자꾸 확인하고, 프롬프트를
14
+ * 또 입력하게 만드는가」). Asked to link a deposit, the model found the invoice, then asked whether to propose the link
15
+ * and offered 「…진행해줘"라고 해줘」 as the next request - a second turn for what the first could do. A proposal card is
16
+ * the person's review; asking before it is asking twice.
17
+ */
18
+ export declare const FINISH_RULE: string;
12
19
  /** §4-1 — the reply names the next request, and the input offers it. */
13
20
  export declare const NEXT_REQUEST_RULE: string;
14
21
  /** A mode's persona with the rules every conversation follows. */
15
22
  export declare function conversationPrompt(modePrompt: string): string;
23
+ /**
24
+ * Whether the line names a request the person could send as it is. The input offers it to be sent with one key, so a
25
+ * line that tells the person what to say (「"…진행해줘"라고 해줘」) or carries an id is no request: offered, it is sent
26
+ * back to the model as the person's words.
27
+ */
28
+ export declare function isPersonRequest(text: string): boolean;
16
29
  /**
17
30
  * The reply without its `Next:` line, and the request that line named.
18
31
  *
@@ -9,21 +9,47 @@
9
9
  * Model-facing text is English (the AI standard's A11); the person's language comes from the request.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.NEXT_REQUEST_RULE = exports.ABSENCE_RULE = void 0;
12
+ exports.NEXT_REQUEST_RULE = exports.FINISH_RULE = exports.ABSENCE_RULE = void 0;
13
13
  exports.conversationPrompt = conversationPrompt;
14
+ exports.isPersonRequest = isPersonRequest;
14
15
  exports.splitNextRequest = splitNextRequest;
15
16
  /** §4-2 — an absence or a refusal is a fact, with what the person can do. */
16
17
  exports.ABSENCE_RULE = 'When a tool says something is absent or refuses, state that and what the person can do. ' +
17
18
  'Do not guess why, and do not describe our machinery - words like passed, delivered or loaded name our plumbing, not their situation.';
19
+ /**
20
+ * §4-3 — a request is finished in the turn it is asked (2026-10-23, the user: 「한번에 끝낼 일을 왜 자꾸 확인하고, 프롬프트를
21
+ * 또 입력하게 만드는가」). Asked to link a deposit, the model found the invoice, then asked whether to propose the link
22
+ * and offered 「…진행해줘"라고 해줘」 as the next request - a second turn for what the first could do. A proposal card is
23
+ * the person's review; asking before it is asking twice.
24
+ */
25
+ exports.FINISH_RULE = 'Finish what was asked in this turn: read what it needs and, when it changes records, propose the card in the same turn - ' +
26
+ 'the card is the person\'s review, so never ask whether to propose it, and never ask the person to confirm, repeat or ' +
27
+ 'resend the request. Do not ask for an id, a number or a name your tools can read. Ask only when the records leave a ' +
28
+ 'choice that only the person can make, and then ask just that choice. Answer briefly: what was found and what the card ' +
29
+ 'does, in the person\'s words - no internal ids, keys, field names or codes.';
18
30
  /** The line a reply ends with when a next request is natural (§4-1). */
19
31
  const NEXT_PREFIX = 'Next:';
20
32
  /** §4-1 — the reply names the next request, and the input offers it. */
21
33
  exports.NEXT_REQUEST_RULE = `After answering, when there is a natural next request, end the reply with one last line "${NEXT_PREFIX} <request>": ` +
22
- "the request the person is most likely to make next, written as they would type it, in the language they wrote in. " +
23
- 'Offer only what this conversation can do with its tools. When nothing natural follows, leave the line out.';
34
+ 'a new request the person is most likely to make next, exactly the words they would type, in the language they wrote in - ' +
35
+ 'no quotation marks, no "say ..." or "ask me ...", no ids or keys. Never a yes to your own question and never what this ' +
36
+ 'reply could have done - do that now instead. Offer only what this conversation can do with its tools. ' +
37
+ 'When nothing natural follows, leave the line out.';
24
38
  /** A mode's persona with the rules every conversation follows. */
25
39
  function conversationPrompt(modePrompt) {
26
- return [modePrompt.trim(), exports.ABSENCE_RULE, exports.NEXT_REQUEST_RULE].join('\n\n');
40
+ return [modePrompt.trim(), exports.ABSENCE_RULE, exports.FINISH_RULE, exports.NEXT_REQUEST_RULE].join('\n\n');
41
+ }
42
+ /** Quotation marks inside a request: it quotes another sentence, so it is about a request, not one. */
43
+ const QUOTED = /["“”‘「」『』`]/;
44
+ /** An id or a record key - nothing a person types. */
45
+ const MACHINE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\b[a-z]+(?:-[a-z]+)*:[0-9a-f-]{8,}/i;
46
+ /**
47
+ * Whether the line names a request the person could send as it is. The input offers it to be sent with one key, so a
48
+ * line that tells the person what to say (「"…진행해줘"라고 해줘」) or carries an id is no request: offered, it is sent
49
+ * back to the model as the person's words.
50
+ */
51
+ function isPersonRequest(text) {
52
+ return !!text && !QUOTED.test(text) && !MACHINE.test(text);
27
53
  }
28
54
  /**
29
55
  * The reply without its `Next:` line, and the request that line named.
@@ -42,6 +68,7 @@ function splitNextRequest(reply) {
42
68
  const rest = lines.slice(0, -1).join('\n').replace(/\s+$/, '');
43
69
  if (!suggestion || !rest)
44
70
  return { reply: text };
45
- return { reply: rest, suggestion };
71
+ /* The line is ours either way - a line that is no request is taken off and offered as nothing. */
72
+ return isPersonRequest(suggestion) ? { reply: rest, suggestion } : { reply: rest };
46
73
  }
47
74
  //# sourceMappingURL=screen-rules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"screen-rules.js","sourceRoot":"","sources":["../../../server/service/assistant-mode/screen-rules.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAiBH,gDAEC;AAQD,4CAWC;AApCD,6EAA6E;AAChE,QAAA,YAAY,GACvB,0FAA0F;IAC1F,sIAAsI,CAAA;AAExI,wEAAwE;AACxE,MAAM,WAAW,GAAG,OAAO,CAAA;AAE3B,wEAAwE;AAC3D,QAAA,iBAAiB,GAC5B,4FAA4F,WAAW,eAAe;IACtH,oHAAoH;IACpH,4GAA4G,CAAA;AAE9G,kEAAkE;AAClE,SAAgB,kBAAkB,CAAC,UAAkB;IACnD,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,oBAAY,EAAE,yBAAiB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IAC1C,MAAM,KAAK,GAAG,yCAAyC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClE,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IAElC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACpE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC9D,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IAChD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AACpC,CAAC","sourcesContent":["/**\n * The rules every conversation follows, whatever app declared it (operato-application design/ai/screen-pattern.md).\n *\n * Five apps carried their own copy of the absence rule, word for word or nearly. A rule every conversation needs\n * belongs to the door that builds every conversation's prompt, so an app's prompt says only who the assistant is\n * there and what it may not claim.\n *\n * Model-facing text is English (the AI standard's A11); the person's language comes from the request.\n */\n\n/** §4-2 — an absence or a refusal is a fact, with what the person can do. */\nexport const ABSENCE_RULE =\n 'When a tool says something is absent or refuses, state that and what the person can do. ' +\n 'Do not guess why, and do not describe our machinery - words like passed, delivered or loaded name our plumbing, not their situation.'\n\n/** The line a reply ends with when a next request is natural (§4-1). */\nconst NEXT_PREFIX = 'Next:'\n\n/** §4-1 — the reply names the next request, and the input offers it. */\nexport const NEXT_REQUEST_RULE =\n `After answering, when there is a natural next request, end the reply with one last line \"${NEXT_PREFIX} <request>\": ` +\n \"the request the person is most likely to make next, written as they would type it, in the language they wrote in. \" +\n 'Offer only what this conversation can do with its tools. When nothing natural follows, leave the line out.'\n\n/** A mode's persona with the rules every conversation follows. */\nexport function conversationPrompt(modePrompt: string): string {\n return [modePrompt.trim(), ABSENCE_RULE, NEXT_REQUEST_RULE].join('\\n\\n')\n}\n\n/**\n * The reply without its `Next:` line, and the request that line named.\n *\n * Only the last non-empty line counts: a `Next:` in the middle of an answer is part of the answer. The line is\n * taken off before the reply is stored, so a conversation read later shows the answer alone.\n */\nexport function splitNextRequest(reply: string): { reply: string; suggestion?: string } {\n const text = String(reply ?? '')\n const lines = text.replace(/\\s+$/, '').split('\\n')\n const last = lines[lines.length - 1] ?? ''\n const match = /^\\s*(?:\\*\\*)?Next:(?:\\*\\*)?\\s*(.+?)\\s*$/.exec(last)\n if (!match) return { reply: text }\n\n const suggestion = match[1].replace(/^[\"“'`]+|[\"”'`]+$/g, '').trim()\n const rest = lines.slice(0, -1).join('\\n').replace(/\\s+$/, '')\n if (!suggestion || !rest) return { reply: text }\n return { reply: rest, suggestion }\n}\n"]}
1
+ {"version":3,"file":"screen-rules.js","sourceRoot":"","sources":["../../../server/service/assistant-mode/screen-rules.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAgCH,gDAEC;AAYD,0CAEC;AAQD,4CAYC;AAlED,6EAA6E;AAChE,QAAA,YAAY,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,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IAElC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACpE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC9D,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IAChD,kGAAkG;IAClG,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AACpF,CAAC","sourcesContent":["/**\n * The rules every conversation follows, whatever app declared it (operato-application design/ai/screen-pattern.md).\n *\n * Five apps carried their own copy of the absence rule, word for word or nearly. A rule every conversation needs\n * belongs to the door that builds every conversation's prompt, so an app's prompt says only who the assistant is\n * there and what it may not claim.\n *\n * Model-facing text is English (the AI standard's A11); the person's language comes from the request.\n */\n\n/** §4-2 — an absence or a refusal is a fact, with what the person can do. */\nexport const ABSENCE_RULE =\n 'When a tool says something is absent or refuses, state that and what the person can do. ' +\n 'Do not guess why, and do not describe our machinery - words like passed, delivered or loaded name our plumbing, not their situation.'\n\n/**\n * §4-3 — a request is finished in the turn it is asked (2026-10-23, the user: 「한번에 끝낼 일을 왜 자꾸 확인하고, 프롬프트를\n * 또 입력하게 만드는가」). Asked to link a deposit, the model found the invoice, then asked whether to propose the link\n * and offered 「…진행해줘\"라고 해줘」 as the next request - a second turn for what the first could do. A proposal card is\n * the person's review; asking before it is asking twice.\n */\nexport const FINISH_RULE =\n 'Finish what was asked in this turn: read what it needs and, when it changes records, propose the card in the same turn - ' +\n 'the card is the person\\'s review, so never ask whether to propose it, and never ask the person to confirm, repeat or ' +\n 'resend the request. Do not ask for an id, a number or a name your tools can read. Ask only when the records leave a ' +\n 'choice that only the person can make, and then ask just that choice. Answer briefly: what was found and what the card ' +\n 'does, in the person\\'s words - no internal ids, keys, field names or codes.'\n\n/** The line a reply ends with when a next request is natural (§4-1). */\nconst NEXT_PREFIX = 'Next:'\n\n/** §4-1 — the reply names the next request, and the input offers it. */\nexport const NEXT_REQUEST_RULE =\n `After answering, when there is a natural next request, end the reply with one last line \"${NEXT_PREFIX} <request>\": ` +\n 'a new request the person is most likely to make next, exactly the words they would type, in the language they wrote in - ' +\n 'no quotation marks, no \"say ...\" or \"ask me ...\", no ids or keys. Never a yes to your own question and never what this ' +\n 'reply could have done - do that now instead. Offer only what this conversation can do with its tools. ' +\n 'When nothing natural follows, leave the line out.'\n\n/** A mode's persona with the rules every conversation follows. */\nexport function conversationPrompt(modePrompt: string): string {\n return [modePrompt.trim(), ABSENCE_RULE, FINISH_RULE, NEXT_REQUEST_RULE].join('\\n\\n')\n}\n\n/** Quotation marks inside a request: it quotes another sentence, so it is about a request, not one. */\nconst QUOTED = /[\"“”‘「」『』`]/\n/** An id or a record key - nothing a person types. */\nconst MACHINE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\\b[a-z]+(?:-[a-z]+)*:[0-9a-f-]{8,}/i\n\n/**\n * Whether the line names a request the person could send as it is. The input offers it to be sent with one key, so a\n * line that tells the person what to say (「\"…진행해줘\"라고 해줘」) or carries an id is no request: offered, it is sent\n * back to the model as the person's words.\n */\nexport function isPersonRequest(text: string): boolean {\n return !!text && !QUOTED.test(text) && !MACHINE.test(text)\n}\n\n/**\n * The reply without its `Next:` line, and the request that line named.\n *\n * Only the last non-empty line counts: a `Next:` in the middle of an answer is part of the answer. The line is\n * taken off before the reply is stored, so a conversation read later shows the answer alone.\n */\nexport function splitNextRequest(reply: string): { reply: string; suggestion?: string } {\n const text = String(reply ?? '')\n const lines = text.replace(/\\s+$/, '').split('\\n')\n const last = lines[lines.length - 1] ?? ''\n const match = /^\\s*(?:\\*\\*)?Next:(?:\\*\\*)?\\s*(.+?)\\s*$/.exec(last)\n if (!match) return { reply: text }\n\n const suggestion = match[1].replace(/^[\"“'`]+|[\"”'`]+$/g, '').trim()\n const rest = lines.slice(0, -1).join('\\n').replace(/\\s+$/, '')\n if (!suggestion || !rest) return { reply: text }\n /* The line is ours either way - a line that is no request is taken off and offered as nothing. */\n return isPersonRequest(suggestion) ? { reply: rest, suggestion } : { reply: rest }\n}\n"]}
@@ -19,6 +19,14 @@ export interface EntryField {
19
19
  * taken; none or several keep the row out and say so - the server never picks among several.
20
20
  */
21
21
  reference?: EntryReference;
22
+ /**
23
+ * The axis of the record the field names (`tax-invoice`, `contract`) - several when it may name a record of each - for a
24
+ * record the model is shown by its key: an open record's anchor and an application's link evidence write
25
+ * `<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
26
+ * card took `tax-invoice:<uuid>` from the evidence, looked it up as an approval number and found nothing). A reference
27
+ * reads it before its query runs; a string field holding an id reads it as the id.
28
+ */
29
+ axis?: string | readonly string[];
22
30
  }
23
31
  export interface EntryReference {
24
32
  query: string;
@@ -30,6 +38,11 @@ export interface EntryReference {
30
38
  label?: string;
31
39
  }[];
32
40
  }
41
+ /**
42
+ * The id a record's key names - `<axis>:<uuid>` as an anchor writes it, or the uuid alone. Nothing for a word, or for
43
+ * the key of a record of another axis: that one is not this record, whatever its uuid.
44
+ */
45
+ export declare function recordIdOfKey(axis: string | readonly string[], text: string): string | undefined;
33
46
  /** A resolved reference, as a row keeps it. */
34
47
  export interface ReferenceValue {
35
48
  id: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findToolName = exports.changeToolName = exports.DEFAULT_MAX_ROWS = void 0;
4
+ exports.recordIdOfKey = recordIdOfKey;
4
5
  exports.entryDoorOf = entryDoorOf;
5
6
  exports.rootFieldOf = rootFieldOf;
6
7
  exports.recordEntryEvent = recordEntryEvent;
@@ -40,6 +41,19 @@ exports.zonedDateTimes = zonedDateTimes;
40
41
  * This file is pure - no framework, no database - so the rules a row passes are tested without a server.
41
42
  */
42
43
  const graphql_1 = require("graphql");
44
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
45
+ /**
46
+ * The id a record's key names - `<axis>:<uuid>` as an anchor writes it, or the uuid alone. Nothing for a word, or for
47
+ * the key of a record of another axis: that one is not this record, whatever its uuid.
48
+ */
49
+ function recordIdOfKey(axis, text) {
50
+ const value = String(text ?? '').trim();
51
+ const prefix = (typeof axis === 'string' ? [axis] : axis).map(one => `${one}:`).find(one => value.startsWith(one));
52
+ const id = prefix ? value.slice(prefix.length) : value;
53
+ return UUID.test(id) ? id : undefined;
54
+ }
55
+ /** What the model wrote for a field that names a record - the id, when it wrote the record's key. */
56
+ const shownId = (field, text) => (field.axis && recordIdOfKey(field.axis, text)) || text;
43
57
  /**
44
58
  * `Mutation.<root field>` of the target's mutation - the one declaration both the tool's gate and the
45
59
  * entering read. A document that is not one mutation with one root field is refused at boot.
@@ -241,12 +255,12 @@ function readFieldValue(field, value) {
241
255
  case 'reference':
242
256
  /* Resolved already ({ id }), or a name to look up ({ text }) - resolveReferences settles the second. */
243
257
  if (value && typeof value === 'object' && typeof value.id === 'string')
244
- return { read: { id: value.id, ...(value.label ? { label: String(value.label) } : {}) } };
258
+ return { read: { id: shownId(field, value.id), ...(value.label ? { label: String(value.label) } : {}) } };
245
259
  if (value && typeof value === 'object' && typeof value.text === 'string')
246
260
  return { read: { text: value.text } };
247
261
  return typeof value === 'string' || typeof value === 'number' ? { read: { text: String(value).trim() } } : { code: 'not-a-reference' };
248
262
  default:
249
- return { read: String(value).trim() };
263
+ return { read: shownId(field, String(value).trim()) };
250
264
  }
251
265
  }
252
266
  /** Two values of one field the same - "12400.00" read from the database is 12400. */
@@ -493,11 +507,12 @@ async function resolveReferences(fields, rows, run) {
493
507
  const value = row.values[field.name];
494
508
  if (!value || typeof value !== 'object' || typeof value.text !== 'string')
495
509
  continue;
496
- const key = `${field.name}\u0000${value.text}`;
510
+ const text = shownId(field, value.text);
511
+ const key = `${field.name}\u0000${text}`;
497
512
  if (!asked.has(key)) {
498
513
  try {
499
- const answer = await run(field.reference.query, field.reference.variables(value.text));
500
- asked.set(key, answer.errors?.length ? new Error(answer.errors[0].message) : field.reference.recordsOf(answer.data, value.text) ?? []);
514
+ const answer = await run(field.reference.query, field.reference.variables(text));
515
+ asked.set(key, answer.errors?.length ? new Error(answer.errors[0].message) : field.reference.recordsOf(answer.data, text) ?? []);
501
516
  }
502
517
  catch (error) {
503
518
  asked.set(key, error instanceof Error ? error : new Error(String(error)));
@@ -1 +1 @@
1
- {"version":3,"file":"entry-target.js","sourceRoot":"","sources":["../../../server/service/data-entry/entry-target.ts"],"names":[],"mappings":";;;AAiMA,kCAEC;AAGD,kCAOC;AAGD,4CAOC;AAYD,gDA0CC;AAED,sCAEC;AAED,oCAEC;AAGD,8CAEC;AAcD,sCAOC;AAED,8CAEC;AAkDD,wCAgCC;AAGD,wCAUC;AAQD,gDA+CC;AAGD,8CAGC;AAED,8BAEC;AAaD,oCA8BC;AAMD,0BAcC;AAMD,4DA4BC;AAMD,wCAQC;AAiBD,kCAmCC;AAGD,4CAEC;AAMD,8CAqCC;AAGD,kCAQC;AAGD,4BAqBC;AAOD,wCAYC;AA5tBD;;;;;;;;;;;;;GAaG;AACH,qCAA+B;AA+K/B;;;GAGG;AACH,SAAgB,WAAW,CAAC,QAAgB;IAC1C,OAAO,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;AAC1C,CAAC;AAED,iGAAiG;AACjG,SAAgB,WAAW,CAAC,QAAgB,EAAE,SAA+B;IAC3E,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,QA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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\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;AAsJD,kCAEC;AAGD,kCAOC;AAGD,4CAOC;AAYD,gDA0CC;AAED,sCAEC;AAED,oCAEC;AAGD,8CAEC;AAcD,sCAOC;AAED,8CAEC;AAkDD,wCAgCC;AAGD,wCAUC;AAQD,gDA+CC;AAGD,8CAGC;AAED,8BAEC;AAaD,oCA8BC;AAMD,0BAcC;AAMD,4DA4BC;AAMD,wCAQC;AAiBD,kCAmCC;AAGD,4CAEC;AAMD,8CAsCC;AAGD,kCAQC;AAGD,4BAqBC;AAOD,wCAYC;AArvBD;;;;;;;;;;;;;GAaG;AACH,qCAA+B;AA0C/B,MAAM,IAAI,GAAG,iEAAiE,CAAA;AAE9E;;;GAGG;AACH,SAAgB,aAAa,CAAC,IAAgC,EAAE,IAAY;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACvC,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,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,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 /** 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) or an id a find tool returned. ' +
163
+ 'Name each record by ref: "current" (the one on screen), "selected" (every row selected on screen), an id a find tool returned, or the record\'s key (`<kind>:<id>`) as you were shown it. ' +
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", or a record id from a find tool - never a guessed id.' },
173
+ ref: { type: 'string', description: '"current", "selected", a record id from 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']