@things-factory/ai-assistant 10.1.210 → 10.1.213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/components/assistant-chat.ts +115 -2
- package/client/components/assistant-dock.ts +106 -3
- package/client/components/workspace-view.ts +56 -3
- package/client/index.ts +3 -0
- package/client/utils/assistant-ask.test.ts +38 -0
- package/client/utils/assistant-ask.ts +35 -1
- package/client/utils/assistant-proposals.ts +23 -0
- package/client/utils/assistant-selection.test.ts +30 -0
- package/client/utils/assistant-selection.ts +47 -0
- package/client/utils/assistant-session-controller.ts +2 -0
- package/client/utils/assistant-session-transport.ts +1 -1
- package/client/utils/invite-proposal-register.ts +31 -0
- package/client/utils/invite-proposal.test.ts +40 -0
- package/client/utils/invite-proposal.ts +54 -0
- package/dist-client/components/assistant-chat.d.ts +18 -0
- package/dist-client/components/assistant-chat.js +117 -2
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/components/assistant-dock.d.ts +11 -0
- package/dist-client/components/assistant-dock.js +97 -4
- package/dist-client/components/assistant-dock.js.map +1 -1
- package/dist-client/components/workspace-view.d.ts +2 -0
- package/dist-client/components/workspace-view.js +58 -3
- package/dist-client/components/workspace-view.js.map +1 -1
- package/dist-client/index.d.ts +2 -0
- package/dist-client/index.js +3 -0
- package/dist-client/index.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/assistant-ask.d.ts +22 -1
- package/dist-client/utils/assistant-ask.js +19 -0
- package/dist-client/utils/assistant-ask.js.map +1 -1
- package/dist-client/utils/assistant-ask.test.d.ts +1 -0
- package/dist-client/utils/assistant-ask.test.js +40 -0
- package/dist-client/utils/assistant-ask.test.js.map +1 -0
- package/dist-client/utils/assistant-proposals.d.ts +14 -0
- package/dist-client/utils/assistant-proposals.js +7 -0
- package/dist-client/utils/assistant-proposals.js.map +1 -1
- package/dist-client/utils/assistant-selection.d.ts +19 -0
- package/dist-client/utils/assistant-selection.js +35 -0
- package/dist-client/utils/assistant-selection.js.map +1 -0
- package/dist-client/utils/assistant-selection.test.d.ts +1 -0
- package/dist-client/utils/assistant-selection.test.js +26 -0
- package/dist-client/utils/assistant-selection.test.js.map +1 -0
- package/dist-client/utils/assistant-session-controller.d.ts +2 -0
- package/dist-client/utils/assistant-session-controller.js.map +1 -1
- package/dist-client/utils/assistant-session-transport.js +1 -1
- package/dist-client/utils/assistant-session-transport.js.map +1 -1
- package/dist-client/utils/invite-proposal-register.d.ts +1 -0
- package/dist-client/utils/invite-proposal-register.js +24 -0
- package/dist-client/utils/invite-proposal-register.js.map +1 -0
- package/dist-client/utils/invite-proposal.d.ts +17 -0
- package/dist-client/utils/invite-proposal.js +37 -0
- package/dist-client/utils/invite-proposal.js.map +1 -0
- package/dist-client/utils/invite-proposal.test.d.ts +1 -0
- package/dist-client/utils/invite-proposal.test.js +35 -0
- package/dist-client/utils/invite-proposal.test.js.map +1 -0
- package/dist-server/service/assistant-chat-resolver.js +2 -0
- package/dist-server/service/assistant-chat-resolver.js.map +1 -1
- package/dist-server/service/assistant-mode/index.d.ts +2 -1
- package/dist-server/service/assistant-mode/index.js +6 -1
- package/dist-server/service/assistant-mode/index.js.map +1 -1
- package/dist-server/service/assistant-mode/mode-categories.d.ts +14 -1
- package/dist-server/service/assistant-mode/mode-categories.js +29 -4
- package/dist-server/service/assistant-mode/mode-categories.js.map +1 -1
- package/dist-server/service/assistant-mode/screen-rules.d.ts +6 -0
- package/dist-server/service/assistant-mode/screen-rules.js +21 -6
- package/dist-server/service/assistant-mode/screen-rules.js.map +1 -1
- package/dist-server/service/data-read/read-target.d.ts +24 -3
- package/dist-server/service/data-read/read-target.js +42 -10
- package/dist-server/service/data-read/read-target.js.map +1 -1
- package/dist-server/service/data-read/read-tools.d.ts +18 -1
- package/dist-server/service/data-read/read-tools.js +19 -5
- package/dist-server/service/data-read/read-tools.js.map +1 -1
- package/dist-server/service/index.d.ts +5 -1
- package/dist-server/service/index.js +10 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/people/index.d.ts +4 -0
- package/dist-server/service/people/index.js +22 -0
- package/dist-server/service/people/index.js.map +1 -0
- package/dist-server/service/people/invite-tools.d.ts +34 -0
- package/dist-server/service/people/invite-tools.js +144 -0
- package/dist-server/service/people/invite-tools.js.map +1 -0
- package/dist-server/service/people/people-keys.d.ts +8 -0
- package/dist-server/service/people/people-keys.js +16 -0
- package/dist-server/service/people/people-keys.js.map +1 -0
- package/dist-server/service/people/people-read.d.ts +4 -0
- package/dist-server/service/people/people-read.js +57 -0
- package/dist-server/service/people/people-read.js.map +1 -0
- package/dist-server/service/testing/mode-conformance.js +3 -0
- package/dist-server/service/testing/mode-conformance.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/server/service/assistant-chat-resolver.ts +2 -0
- package/server/service/assistant-mode/conversation-category.test.ts +35 -0
- package/server/service/assistant-mode/index.ts +3 -1
- package/server/service/assistant-mode/mode-categories.ts +41 -4
- package/server/service/assistant-mode/mode-front.test.ts +5 -3
- package/server/service/assistant-mode/resolve.test.ts +1 -1
- package/server/service/assistant-mode/screen-rules.test.ts +23 -1
- package/server/service/assistant-mode/screen-rules.ts +22 -5
- package/server/service/data-entry/data-entry.test.ts +2 -2
- package/server/service/data-read/detail-lists.test.ts +61 -0
- package/server/service/data-read/read-target.ts +54 -9
- package/server/service/data-read/read-tools.ts +32 -6
- package/server/service/index.ts +7 -1
- package/server/service/people/index.ts +13 -0
- package/server/service/people/invite-tools.ts +159 -0
- package/server/service/people/invite.test.ts +159 -0
- package/server/service/people/people-keys.ts +16 -0
- package/server/service/people/people-read.test.ts +82 -0
- package/server/service/people/people-read.ts +56 -0
- package/server/service/testing/mode-conformance.test.ts +14 -1
- package/server/service/testing/mode-conformance.ts +2 -0
- package/test/assistant-dock.test.ts +73 -0
- package/translations/en.json +18 -1
- package/translations/es.json +18 -1
- package/translations/ja.json +18 -1
- package/translations/ko.json +19 -2
- package/translations/ms.json +18 -1
- package/translations/zh.json +18 -1
|
@@ -83,6 +83,10 @@ export declare const screenToolName: (key: string) => string;
|
|
|
83
83
|
export declare const readCategoryName: (key: string) => string;
|
|
84
84
|
export declare function declareReadTarget(target: ReadTarget): void;
|
|
85
85
|
export declare function readTargetOf(key: string | undefined): ReadTarget | undefined;
|
|
86
|
+
/** Every list read target declared - what else reads the declarations (a dashboard card, ADR-0160) lists them by key. */
|
|
87
|
+
export declare function readTargetKeys(): string[];
|
|
88
|
+
/** Every detail read declared. */
|
|
89
|
+
export declare function detailReadKeys(): string[];
|
|
86
90
|
export declare function clearReadTargets(): void;
|
|
87
91
|
/** An argument of a detail read - one variable of its query, read with the entry fields' rules. */
|
|
88
92
|
export interface DetailArg {
|
|
@@ -114,6 +118,22 @@ export interface DetailRead {
|
|
|
114
118
|
* for any ledger record; asked on a deposit's 360 why it was in the check, the model never opened it (2026-10-24).
|
|
115
119
|
*/
|
|
116
120
|
axes?: string[];
|
|
121
|
+
/**
|
|
122
|
+
* The lists the answer holds, each a table of typed columns - what a dashboard card may draw from a one-answer read
|
|
123
|
+
* (ADR-0160 decision 2). The card keeps only `key`; where the rows are and what their columns are is read here.
|
|
124
|
+
*/
|
|
125
|
+
lists?: DetailList[];
|
|
126
|
+
}
|
|
127
|
+
/** A list inside a detail read's answer. */
|
|
128
|
+
export interface DetailList {
|
|
129
|
+
/** A name stable within the read (`by-contract`) - what a card keeps. */
|
|
130
|
+
key: string;
|
|
131
|
+
/** A dotted path inside the value of the query's root field (`rows`); '' when the root field is the list. */
|
|
132
|
+
at: string;
|
|
133
|
+
labelKey?: string;
|
|
134
|
+
/** What the rows are, for the model. */
|
|
135
|
+
description?: string;
|
|
136
|
+
columns: ReadColumn[];
|
|
117
137
|
}
|
|
118
138
|
/** Characters of an answer handed to the model - a longer one is refused, and the model narrows it. */
|
|
119
139
|
export declare const MAX_DETAIL_CHARS = 60000;
|
|
@@ -129,8 +149,9 @@ export declare function readCriteria(target: ReadTarget, args: any): {
|
|
|
129
149
|
}[];
|
|
130
150
|
};
|
|
131
151
|
export declare function filtersOf(target: ReadTarget, criteria: Record<string, unknown>): ReadFilter[];
|
|
152
|
+
export declare const valueAt: (row: any, path: string) => any;
|
|
132
153
|
/** One row as the columns say - a number column as a number, a missing value as null. */
|
|
133
|
-
export declare function rowOf(target: ReadTarget, item: any): Record<string, string | number | null>;
|
|
154
|
+
export declare function rowOf(target: Pick<ReadTarget, 'columns'>, item: any): Record<string, string | number | null>;
|
|
134
155
|
/**
|
|
135
156
|
* Reads the rows through the application's query, page by page, up to MAX_READ_ROWS. `complete` is false when the
|
|
136
157
|
* list holds more - a sum of the rows read is then not the sum of the list, and is never said as one.
|
|
@@ -150,11 +171,11 @@ export interface ReadGroup {
|
|
|
150
171
|
/** The currency a row without one is summed under - said as it is, never taken for the domain's own. */
|
|
151
172
|
export declare const UNKNOWN_CURRENCY = "unknown";
|
|
152
173
|
/** The sums of the number columns marked total - the server's, never the model's; a column with a currency per currency. */
|
|
153
|
-
export declare function sumsOf(target: ReadTarget, rows: Record<string, any>[]): Record<string, ReadSum>;
|
|
174
|
+
export declare function sumsOf(target: Pick<ReadTarget, 'columns'>, rows: Record<string, any>[]): Record<string, ReadSum>;
|
|
154
175
|
/** The currencies a set of sums holds for one column - none for a column summed as one number. */
|
|
155
176
|
export declare function currenciesOf(sums: Record<string, ReadSum>[], column: string): string[];
|
|
156
177
|
/** The rows grouped by one column - a date column by its month - each with its count and sums, largest first. */
|
|
157
|
-
export declare function groupsOf(target: ReadTarget, rows: Record<string, any>[], by: string): ReadGroup[] | undefined;
|
|
178
|
+
export declare function groupsOf(target: Pick<ReadTarget, 'columns'>, rows: Record<string, any>[], by: string): ReadGroup[] | undefined;
|
|
158
179
|
/** The address of the target's list screen with the conditions it takes, and the conditions it does not. */
|
|
159
180
|
export declare function screenAddress(target: ReadTarget, criteria: Record<string, unknown>): {
|
|
160
181
|
href: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UNKNOWN_CURRENCY = exports.detailToolName = exports.MAX_DETAIL_CHARS = exports.readCategoryName = exports.screenToolName = exports.queryToolName = exports.READ_PAGE = exports.ROWS_FOR_MODEL = exports.MAX_READ_ROWS = void 0;
|
|
3
|
+
exports.UNKNOWN_CURRENCY = exports.valueAt = exports.detailToolName = exports.MAX_DETAIL_CHARS = exports.readCategoryName = exports.screenToolName = exports.queryToolName = exports.READ_PAGE = exports.ROWS_FOR_MODEL = exports.MAX_READ_ROWS = void 0;
|
|
4
4
|
exports.declareReadTarget = declareReadTarget;
|
|
5
5
|
exports.readTargetOf = readTargetOf;
|
|
6
|
+
exports.readTargetKeys = readTargetKeys;
|
|
7
|
+
exports.detailReadKeys = detailReadKeys;
|
|
6
8
|
exports.clearReadTargets = clearReadTargets;
|
|
7
9
|
exports.declareDetailRead = declareDetailRead;
|
|
8
10
|
exports.detailReadOf = detailReadOf;
|
|
@@ -46,20 +48,30 @@ const screenToolName = (key) => `open${pascalOf(key)}Screen`;
|
|
|
46
48
|
exports.screenToolName = screenToolName;
|
|
47
49
|
const readCategoryName = (key) => `data-read:${key}`;
|
|
48
50
|
exports.readCategoryName = readCategoryName;
|
|
51
|
+
/** The columns of a list - shown, each named once, a currency only on a summed number and taken from a string column. */
|
|
52
|
+
function checkColumns(of, columns) {
|
|
53
|
+
if (!columns.length)
|
|
54
|
+
throw new Error(`read target '${of}' shows no column`);
|
|
55
|
+
const names = new Set();
|
|
56
|
+
for (const column of columns) {
|
|
57
|
+
if (names.has(column.name))
|
|
58
|
+
throw new Error(`read target '${of}' names the column '${column.name}' twice`);
|
|
59
|
+
names.add(column.name);
|
|
60
|
+
}
|
|
61
|
+
for (const column of columns.filter(one => one.currency)) {
|
|
62
|
+
if (!column.total || column.type !== 'number')
|
|
63
|
+
throw new Error(`column '${column.name}' of '${of}' names a currency but is not a summed number`);
|
|
64
|
+
if (columns.find(one => one.name === column.currency)?.type !== 'string')
|
|
65
|
+
throw new Error(`column '${column.name}' of '${of}' takes its currency from '${column.currency}', which is no string column`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
49
68
|
function declareReadTarget(target) {
|
|
50
69
|
if (!/^[a-z0-9-]+\.[a-z0-9-]+$/.test(target.key))
|
|
51
70
|
throw new Error(`read target key '${target.key}' is not <app>.<record>`);
|
|
52
71
|
if (registry.has(target.key) || details.has(target.key))
|
|
53
72
|
throw new Error(`read target '${target.key}' is declared twice`);
|
|
54
73
|
(0, entry_target_js_1.rootFieldOf)(target.query, 'query');
|
|
55
|
-
|
|
56
|
-
throw new Error(`read target '${target.key}' shows no column`);
|
|
57
|
-
for (const column of target.columns.filter(one => one.currency)) {
|
|
58
|
-
if (!column.total || column.type !== 'number')
|
|
59
|
-
throw new Error(`column '${column.name}' of '${target.key}' names a currency but is not a summed number`);
|
|
60
|
-
if (target.columns.find(one => one.name === column.currency)?.type !== 'string')
|
|
61
|
-
throw new Error(`column '${column.name}' of '${target.key}' takes its currency from '${column.currency}', which is no string column`);
|
|
62
|
-
}
|
|
74
|
+
checkColumns(target.key, target.columns);
|
|
63
75
|
const names = new Set(['id']);
|
|
64
76
|
for (const criterion of target.criteria) {
|
|
65
77
|
if (criterion.name === 'id')
|
|
@@ -82,6 +94,14 @@ function declareReadTarget(target) {
|
|
|
82
94
|
function readTargetOf(key) {
|
|
83
95
|
return key ? registry.get(key) : undefined;
|
|
84
96
|
}
|
|
97
|
+
/** Every list read target declared - what else reads the declarations (a dashboard card, ADR-0160) lists them by key. */
|
|
98
|
+
function readTargetKeys() {
|
|
99
|
+
return [...registry.keys()];
|
|
100
|
+
}
|
|
101
|
+
/** Every detail read declared. */
|
|
102
|
+
function detailReadKeys() {
|
|
103
|
+
return [...details.keys()];
|
|
104
|
+
}
|
|
85
105
|
function clearReadTargets() {
|
|
86
106
|
registry.clear();
|
|
87
107
|
details.clear();
|
|
@@ -116,6 +136,17 @@ function declareDetailRead(target) {
|
|
|
116
136
|
if (arg.type === 'enum' && !arg.values?.length)
|
|
117
137
|
throw new Error(`argument '${arg.name}' of '${target.key}' lists no values`);
|
|
118
138
|
}
|
|
139
|
+
const lists = new Set();
|
|
140
|
+
for (const list of target.lists ?? []) {
|
|
141
|
+
if (!/^[a-z0-9-]+$/.test(list.key))
|
|
142
|
+
throw new Error(`list '${list.key}' of '${target.key}' is not a lowercase key`);
|
|
143
|
+
if (lists.has(list.key))
|
|
144
|
+
throw new Error(`detail read '${target.key}' names the list '${list.key}' twice`);
|
|
145
|
+
lists.add(list.key);
|
|
146
|
+
if (!/^([A-Za-z0-9_]+(\.[A-Za-z0-9_]+)*)?$/.test(list.at))
|
|
147
|
+
throw new Error(`list '${list.key}' of '${target.key}' is at '${list.at}', which is no dotted path`);
|
|
148
|
+
checkColumns(`${target.key}/${list.key}`, list.columns);
|
|
149
|
+
}
|
|
119
150
|
details.set(target.key, target);
|
|
120
151
|
}
|
|
121
152
|
function detailReadOf(key) {
|
|
@@ -149,13 +180,14 @@ function filtersOf(target, criteria) {
|
|
|
149
180
|
];
|
|
150
181
|
}
|
|
151
182
|
const valueAt = (row, path) => path.split('.').reduce((at, part) => (at === null || at === undefined ? undefined : at[part]), row);
|
|
183
|
+
exports.valueAt = valueAt;
|
|
152
184
|
/** One row as the columns say - a number column as a number, a missing value as null. */
|
|
153
185
|
function rowOf(target, item) {
|
|
154
186
|
return Object.fromEntries([
|
|
155
187
|
/* The id names the record to the model - for one record's detail, a change, or its screen. */
|
|
156
188
|
...(item?.id ? [['id', String(item.id)]] : []),
|
|
157
189
|
...target.columns.map(column => {
|
|
158
|
-
const raw = valueAt(item, column.path ?? column.name);
|
|
190
|
+
const raw = (0, exports.valueAt)(item, column.path ?? column.name);
|
|
159
191
|
if (raw === undefined || raw === null || raw === '')
|
|
160
192
|
return [column.name, null];
|
|
161
193
|
if (column.type === 'number') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-target.js","sourceRoot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AAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACnC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC/G,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU;QAC7B,CAAC,CAAC,IAAA,+BAAe,EAAC;YACd,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;YACtC,MAAM,EAAE,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YACzE,OAAO,EAAE,MAAM,CAAC,QAAQ;SACzB,CAAC;QACJ,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IACrB,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;QACvD,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1D,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;KAC/D,CAAA;AACH,CAAC","sourcesContent":["/*\n * AI 조회 - an application's list, read through its own query as the person (operato-application/design/ai/read-targets.md).\n *\n * The application declares what it lets the assistant read: its list query, the conditions the model may set and\n * how each becomes one of the query's filters, the columns to show, and the screen that lists the same records.\n * The framework reads the rows through that query with the person's request state - the same @privilege and\n * domain as the screen - counts and sums them itself, and puts a long result on the AI 작업판 as the query returned\n * it. The model is told the count, the sums and a few rows; it never copies a table.\n *\n * Pure but for the GraphQL runner, which comes in as an argument - the rules are tested without a server.\n */\nimport { readFieldValue, recordIdOfKey, rootFieldOf, type EntryField } from '../data-entry/entry-target.js'\nimport { encodeListQuery } from '@operato/utils/list-query.js'\nimport type { GraphqlRunner } from '../data-entry/entry-update.js'\nimport { parse } from 'graphql'\n\nexport interface ReadFilter {\n name: string\n operator: string\n value: unknown\n}\n\n/** A condition the model may set - read with the entry fields' rules, turned into the query's filters by the application. */\nexport interface ReadCriterion extends Omit<EntryField, 'required' | 'reference' | 'total'> {\n filter: (value: any) => ReadFilter | ReadFilter[]\n}\n\nexport interface ReadColumn {\n /** The key in the workspace table. */\n name: string\n /** Where the value is in a row - a dotted path into the query's item (`account.name`). Defaults to `name`. */\n path?: string\n type: 'string' | 'number' | 'date'\n labelKey?: string\n /** A number column the server sums. */\n total?: boolean\n /**\n * The column that holds this amount's currency (ISO 4217, `KRW`). Its sums are kept per currency - amounts of two\n * currencies are never added into one number.\n */\n currency?: string\n}\n\nexport interface ReadScreen {\n /** A URL-bound grid accepts the same predicates used by readRows, including conditions outside its form. */\n queryState?: boolean\n /** The application's route of the list screen (`cash-transaction-list`). */\n route: string\n /** The conditions the screen takes, as its address's query arguments. A condition left out is said on the card. */\n params: (criteria: Record<string, any>) => Record<string, string | number | undefined>\n /** The conditions `params` carries - the card names the others as not applied on the screen. */\n takes: string[]\n labelKey?: string\n}\n\nexport interface ReadTarget {\n /** `<app>.<record>` - the tools are named after it. */\n key: string\n /** i18n key naming the records (「은행 입출금」). */\n labelKey?: string\n /** What the records are, for the model. */\n description: string\n /**\n * The list query - takes `$filters: [Filter!]`, `$pagination: Pagination` and `$sortings: [Sorting!]`, and\n * `$search: String` when `search` is declared.\n */\n query: string\n /**\n * The list takes ListParam's free-text term, matched by the resolver across its own searchable fields - the\n * condition `text`. Say what it finds in, for the model.\n */\n search?: { description: string }\n criteria: ReadCriterion[]\n /**\n * Filters every read of this list applies - the records it is of (a book's confirmed lines, not its forecasts). Not\n * a condition: the model neither sees nor sets them, so a read can narrow the list but never widen it.\n */\n fixedFilters?: ReadFilter[]\n columns: ReadColumn[]\n rowsOf: (data: any) => { rows: any[]; total: number }\n /** Orders the rows; the query's own order when left out. */\n sortings?: { name: string; desc?: boolean }[]\n screen?: ReadScreen\n}\n\n/** At most this many rows are read - the AI 작업판 table's own limit (workspace-blocks MAX_TABLE_ROWS). */\nexport const MAX_READ_ROWS = 1000\n/** Rows the model is shown; the rest stay on the card. */\nexport const ROWS_FOR_MODEL = 20\n/** A page of the list query. */\nexport const READ_PAGE = 200\n\nconst registry = new Map<string, ReadTarget>()\n\nconst pascalOf = (key: string) =>\n key\n .split(/[^a-zA-Z0-9]+/)\n .filter(Boolean)\n .map(part => part[0].toUpperCase() + part.slice(1))\n .join('')\n\nexport const queryToolName = (key: string) => `query${pascalOf(key)}`\nexport const screenToolName = (key: string) => `open${pascalOf(key)}Screen`\nexport const readCategoryName = (key: string) => `data-read:${key}`\n\nexport function declareReadTarget(target: ReadTarget): void {\n if (!/^[a-z0-9-]+\\.[a-z0-9-]+$/.test(target.key)) throw new Error(`read target key '${target.key}' is not <app>.<record>`)\n if (registry.has(target.key) || details.has(target.key)) throw new Error(`read target '${target.key}' is declared twice`)\n rootFieldOf(target.query, 'query')\n if (!target.columns.length) throw new Error(`read target '${target.key}' shows no column`)\n for (const column of target.columns.filter(one => one.currency)) {\n if (!column.total || column.type !== 'number') throw new Error(`column '${column.name}' of '${target.key}' names a currency but is not a summed number`)\n if (target.columns.find(one => one.name === column.currency)?.type !== 'string') throw new Error(`column '${column.name}' of '${target.key}' takes its currency from '${column.currency}', which is no string column`)\n }\n const names = new Set<string>(['id'])\n for (const criterion of target.criteria) {\n if (criterion.name === 'id') throw new Error(`read target '${target.key}' declares 'id' - every target takes it`)\n if (criterion.name === 'text' && target.search) throw new Error(`read target '${target.key}' declares 'text' and search - search is the text condition`)\n if (names.has(criterion.name)) throw new Error(`read target '${target.key}' names the condition '${criterion.name}' twice`)\n names.add(criterion.name)\n if (criterion.type === 'enum' && !criterion.values?.length) throw new Error(`condition '${criterion.name}' of '${target.key}' lists no values`)\n }\n if (target.search) names.add('text')\n for (const taken of target.screen?.takes ?? []) if (!names.has(taken)) throw new Error(`the screen of '${target.key}' takes '${taken}', which is no condition`)\n registry.set(target.key, target)\n}\n\nexport function readTargetOf(key: string | undefined): ReadTarget | undefined {\n return key ? registry.get(key) : undefined\n}\n\nexport function clearReadTargets(): void {\n registry.clear()\n details.clear()\n}\n\n/* ── One answer of a query ──────────────────────────────────────────────────────────────────────────────────── */\n\n/** An argument of a detail read - one variable of its query, read with the entry fields' rules. */\nexport interface DetailArg {\n name: string\n type: 'string' | 'integer' | 'number' | 'boolean' | 'date' | 'enum'\n values?: string[]\n description?: string\n required?: boolean\n /** A record's id: the axis (or axes) of the record, whose key `<axis>:<id>` the model may have been shown (EntryField.axis). */\n axis?: string | readonly string[]\n}\n\n/**\n * A query whose answer is one thing, not a list - a 360's summary, the receivables, a statement (design/ai/read-targets.md\n * §9). The application declares the query with the fields its screen reads; the framework runs it as the person, with\n * the arguments the model set, and hands the answer over as the query returned it. Nothing is summed or cut here: the\n * selection is the projection, and an answer too long to hand over is refused, never cut.\n */\nexport interface DetailRead {\n /** `<app>.<thing>` - the tool is named after it. */\n key: string\n labelKey?: string\n /** What it answers, for the model. */\n description: string\n /** One query with one root field. Its variables are the arguments - each declared in `args`. */\n query: string\n args?: DetailArg[]\n /**\n * The records the answer is about, whose screens put it in front (EntryTarget.axes) - the management check answers\n * for any ledger record; asked on a deposit's 360 why it was in the check, the model never opened it (2026-10-24).\n */\n axes?: string[]\n}\n\n/** Characters of an answer handed to the model - a longer one is refused, and the model narrows it. */\nexport const MAX_DETAIL_CHARS = 60_000\n\nconst details = new Map<string, DetailRead>()\n\nexport const detailToolName = (key: string) => `read${pascalOf(key)}`\n\n/** The variables a query declares, and whether each is required (`!`). */\nfunction variablesOf(document: string): { name: string; required: boolean }[] {\n const operation: any = parse(document).definitions.find((one: any) => one.kind === 'OperationDefinition')\n return (operation?.variableDefinitions ?? []).map((one: any) => ({ name: one.variable.name.value, required: one.type.kind === 'NonNullType' && !one.defaultValue }))\n}\n\nexport function declareDetailRead(target: DetailRead): void {\n if (!/^[a-z0-9-]+\\.[a-z0-9-]+$/.test(target.key)) throw new Error(`detail read key '${target.key}' is not <app>.<thing>`)\n if (details.has(target.key) || registry.has(target.key)) throw new Error(`read target '${target.key}' is declared twice`)\n rootFieldOf(target.query, 'query')\n const args = target.args ?? []\n for (const variable of variablesOf(target.query)) {\n const arg = args.find(one => one.name === variable.name)\n if (!arg) throw new Error(`detail read '${target.key}' takes $${variable.name}, which is no argument`)\n if (variable.required && !arg.required) throw new Error(`detail read '${target.key}': $${variable.name} is required by the query - declare it required`)\n }\n for (const arg of args) {\n if (!variablesOf(target.query).some(one => one.name === arg.name)) throw new Error(`detail read '${target.key}' declares '${arg.name}', which its query does not take`)\n if (arg.type === 'enum' && !arg.values?.length) throw new Error(`argument '${arg.name}' of '${target.key}' lists no values`)\n }\n details.set(target.key, target)\n}\n\nexport function detailReadOf(key: string | undefined): DetailRead | undefined {\n return key ? details.get(key) : undefined\n}\n\n/** The conditions the model set, read by their declared types; a value that does not fit is said, never guessed at. */\nexport function readCriteria(target: ReadTarget, args: any): { criteria: Record<string, unknown>; refused: { name: string; code: string }[] } {\n const criteria: Record<string, unknown> = {}\n const refused: { name: string; code: string }[] = []\n /* One record by its id - every target takes it (the id a list answer or a find tool gave, or the key `<axis>:<id>` an open record is shown by, the axis being the key's last part). */\n if (typeof args?.id === 'string' && args.id.trim()) criteria.id = recordIdOfKey(target.key.split('.').pop()!, args.id) ?? args.id.trim()\n if (target.search && typeof args?.text === 'string' && args.text.trim()) criteria.text = args.text.trim()\n for (const criterion of target.criteria) {\n const value = args?.[criterion.name]\n if (value === undefined || value === null || value === '') continue\n const { read, code } = readFieldValue(criterion as EntryField, value)\n if (read === undefined) refused.push({ name: criterion.name, code: code ?? 'unreadable' })\n else criteria[criterion.name] = read\n }\n return { criteria, refused }\n}\n\nexport function filtersOf(target: ReadTarget, criteria: Record<string, unknown>): ReadFilter[] {\n return [\n ...(typeof criteria.id === 'string' ? [{ name: 'id', operator: 'eq', value: criteria.id }] : []),\n ...target.criteria.flatMap(criterion =>\n criterion.name in criteria ? [criterion.filter(criteria[criterion.name])].flat() : []\n )\n ]\n}\n\nconst valueAt = (row: any, path: string) => path.split('.').reduce((at, part) => (at === null || at === undefined ? undefined : at[part]), row)\n\n/** One row as the columns say - a number column as a number, a missing value as null. */\nexport function rowOf(target: ReadTarget, item: any): Record<string, string | number | null> {\n return Object.fromEntries([\n /* The id names the record to the model - for one record's detail, a change, or its screen. */\n ...(item?.id ? [['id', String(item.id)] as [string, string]] : []),\n ...target.columns.map(column => {\n const raw = valueAt(item, column.path ?? column.name)\n if (raw === undefined || raw === null || raw === '') return [column.name, null]\n if (column.type === 'number') {\n const number = Number(raw)\n return [column.name, Number.isFinite(number) ? number : null]\n }\n return [column.name, String(raw)]\n })\n ])\n}\n\n/**\n * Reads the rows through the application's query, page by page, up to MAX_READ_ROWS. `complete` is false when the\n * list holds more - a sum of the rows read is then not the sum of the list, and is never said as one.\n */\nexport async function readRows(target: ReadTarget, filters: ReadFilter[], run: GraphqlRunner, search?: string): Promise<{ rows: Record<string, any>[]; total: number; complete: boolean }> {\n const rows: Record<string, any>[] = []\n let total = 0\n for (let page = 1; rows.length < MAX_READ_ROWS; page++) {\n const answer = await run(target.query, {\n filters: [...filters, ...(target.fixedFilters ?? [])],\n ...(search ? { search } : {}),\n pagination: { page, limit: READ_PAGE },\n ...(target.sortings ? { sortings: target.sortings } : {})\n })\n if (answer.errors?.length) throw new Error(answer.errors.map(one => one.message).join('; '))\n const read = target.rowsOf(answer.data)\n total = Number(read?.total) || 0\n const items = read?.rows ?? []\n rows.push(...items.slice(0, MAX_READ_ROWS - rows.length).map(item => rowOf(target, item)))\n if (items.length < READ_PAGE || rows.length >= total) break\n }\n return { rows, total, complete: rows.length >= total }\n}\n\n/** A column's sum - one number, or one per currency when the column names its currency (`{ KRW: 1000, USD: 100 }`). */\nexport type ReadSum = number | Record<string, number>\n\nexport interface ReadGroup {\n key: string\n count: number\n sums: Record<string, ReadSum>\n}\n\n/** The currency a row without one is summed under - said as it is, never taken for the domain's own. */\nexport const UNKNOWN_CURRENCY = 'unknown'\n\nconst sumOf = (rows: Record<string, any>[], name: string) => Math.round(rows.reduce((sum, row) => sum + (typeof row[name] === 'number' ? row[name] : 0), 0) * 100) / 100\n\n/** The sums of the number columns marked total - the server's, never the model's; a column with a currency per currency. */\nexport function sumsOf(target: ReadTarget, rows: Record<string, any>[]): Record<string, ReadSum> {\n const sums: Record<string, ReadSum> = {}\n for (const column of target.columns.filter(one => one.total && one.type === 'number')) {\n if (!column.currency) {\n sums[column.name] = sumOf(rows, column.name)\n continue\n }\n const byCurrency = new Map<string, Record<string, any>[]>()\n for (const row of rows) {\n const code = typeof row[column.currency] === 'string' && row[column.currency] ? row[column.currency] : UNKNOWN_CURRENCY\n byCurrency.set(code, [...(byCurrency.get(code) ?? []), row])\n }\n sums[column.name] = Object.fromEntries([...byCurrency].sort(([a], [b]) => a.localeCompare(b)).map(([code, members]) => [code, sumOf(members, column.name)]))\n }\n return sums\n}\n\n/** The currencies a set of sums holds for one column - none for a column summed as one number. */\nexport function currenciesOf(sums: Record<string, ReadSum>[], column: string): string[] {\n const codes = new Set<string>()\n for (const one of sums) if (one[column] && typeof one[column] === 'object') for (const code of Object.keys(one[column] as object)) codes.add(code)\n return [...codes].sort()\n}\n\n/** The rows grouped by one column - a date column by its month - each with its count and sums, largest first. */\nexport function groupsOf(target: ReadTarget, rows: Record<string, any>[], by: string): ReadGroup[] | undefined {\n const column = target.columns.find(one => one.name === by)\n if (!column) return undefined\n const groups = new Map<string, Record<string, any>[]>()\n for (const row of rows) {\n const value = row[by]\n const key = value === null || value === undefined ? '' : column.type === 'date' ? String(value).slice(0, 7) : String(value)\n groups.set(key, [...(groups.get(key) ?? []), row])\n }\n const list = [...groups].map(([key, members]) => ({ key, count: members.length, sums: sumsOf(target, members) }))\n if (column.type === 'date') return list.sort((a, b) => a.key.localeCompare(b.key))\n /* Largest first by the first sum - in its one currency; groups in two currencies have no common size, so by count. */\n const first = target.columns.find(one => one.total)?.name\n const codes = first ? currenciesOf(list.map(group => group.sums), first) : []\n const size = (group: ReadGroup) => {\n const sum = first ? group.sums[first] : undefined\n return typeof sum === 'number' ? Math.abs(sum) : codes.length === 1 && sum ? Math.abs(sum[codes[0]] ?? 0) : undefined\n }\n return list.sort((a, b) => {\n const [x, y] = [size(a), size(b)]\n return x !== undefined && y !== undefined && codes.length <= 1 ? y - x : b.count - a.count\n })\n}\n\n/** The address of the target's list screen with the conditions it takes, and the conditions it does not. */\nexport function screenAddress(target: ReadTarget, criteria: Record<string, unknown>): { href: string; applied: string[]; notApplied: string[] } | undefined {\n const screen = target.screen\n if (!screen) return undefined\n const params = new URLSearchParams()\n for (const [name, value] of Object.entries(screen.params(criteria))) if (value !== undefined && value !== null && value !== '') params.set(name, String(value))\n const given = Object.keys(criteria)\n const applicable = Object.fromEntries(Object.entries(criteria).filter(([name]) => screen.takes.includes(name)))\n const query = screen.queryState\n ? encodeListQuery({\n filters: filtersOf(target, applicable),\n search: typeof applicable.text === 'string' ? applicable.text : undefined,\n sorters: target.sortings\n })\n : params.toString()\n return {\n href: query ? `${screen.route}?${query}` : screen.route,\n applied: given.filter(name => screen.takes.includes(name)),\n notApplied: given.filter(name => !screen.takes.includes(name))\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"read-target.js","sourceRoot":"","sources":["../../../server/service/data-read/read-target.ts"],"names":[],"mappings":";;;AAuHA,8CAgBC;AAED,oCAEC;AAGD,wCAEC;AAGD,wCAEC;AAED,4CAGC;AAmED,8CAuBC;AAED,oCAEC;AAGD,oCAcC;AAED,8BAOC;AAKD,sBAcC;AAMD,4BAkBC;AAiBD,wBAeC;AAGD,oCAIC;AAGD,4B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MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACnC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC/G,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU;QAC7B,CAAC,CAAC,IAAA,+BAAe,EAAC;YACd,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;YACtC,MAAM,EAAE,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YACzE,OAAO,EAAE,MAAM,CAAC,QAAQ;SACzB,CAAC;QACJ,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IACrB,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;QACvD,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1D,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;KAC/D,CAAA;AACH,CAAC","sourcesContent":["/*\n * AI 조회 - an application's list, read through its own query as the person (operato-application/design/ai/read-targets.md).\n *\n * The application declares what it lets the assistant read: its list query, the conditions the model may set and\n * how each becomes one of the query's filters, the columns to show, and the screen that lists the same records.\n * The framework reads the rows through that query with the person's request state - the same @privilege and\n * domain as the screen - counts and sums them itself, and puts a long result on the AI 작업판 as the query returned\n * it. The model is told the count, the sums and a few rows; it never copies a table.\n *\n * Pure but for the GraphQL runner, which comes in as an argument - the rules are tested without a server.\n */\nimport { readFieldValue, recordIdOfKey, rootFieldOf, type EntryField } from '../data-entry/entry-target.js'\nimport { encodeListQuery } from '@operato/utils/list-query.js'\nimport type { GraphqlRunner } from '../data-entry/entry-update.js'\nimport { parse } from 'graphql'\n\nexport interface ReadFilter {\n name: string\n operator: string\n value: unknown\n}\n\n/** A condition the model may set - read with the entry fields' rules, turned into the query's filters by the application. */\nexport interface ReadCriterion extends Omit<EntryField, 'required' | 'reference' | 'total'> {\n filter: (value: any) => ReadFilter | ReadFilter[]\n}\n\nexport interface ReadColumn {\n /** The key in the workspace table. */\n name: string\n /** Where the value is in a row - a dotted path into the query's item (`account.name`). Defaults to `name`. */\n path?: string\n type: 'string' | 'number' | 'date'\n labelKey?: string\n /** A number column the server sums. */\n total?: boolean\n /**\n * The column that holds this amount's currency (ISO 4217, `KRW`). Its sums are kept per currency - amounts of two\n * currencies are never added into one number.\n */\n currency?: string\n}\n\nexport interface ReadScreen {\n /** A URL-bound grid accepts the same predicates used by readRows, including conditions outside its form. */\n queryState?: boolean\n /** The application's route of the list screen (`cash-transaction-list`). */\n route: string\n /** The conditions the screen takes, as its address's query arguments. A condition left out is said on the card. */\n params: (criteria: Record<string, any>) => Record<string, string | number | undefined>\n /** The conditions `params` carries - the card names the others as not applied on the screen. */\n takes: string[]\n labelKey?: string\n}\n\nexport interface ReadTarget {\n /** `<app>.<record>` - the tools are named after it. */\n key: string\n /** i18n key naming the records (「은행 입출금」). */\n labelKey?: string\n /** What the records are, for the model. */\n description: string\n /**\n * The list query - takes `$filters: [Filter!]`, `$pagination: Pagination` and `$sortings: [Sorting!]`, and\n * `$search: String` when `search` is declared.\n */\n query: string\n /**\n * The list takes ListParam's free-text term, matched by the resolver across its own searchable fields - the\n * condition `text`. Say what it finds in, for the model.\n */\n search?: { description: string }\n criteria: ReadCriterion[]\n /**\n * Filters every read of this list applies - the records it is of (a book's confirmed lines, not its forecasts). Not\n * a condition: the model neither sees nor sets them, so a read can narrow the list but never widen it.\n */\n fixedFilters?: ReadFilter[]\n columns: ReadColumn[]\n rowsOf: (data: any) => { rows: any[]; total: number }\n /** Orders the rows; the query's own order when left out. */\n sortings?: { name: string; desc?: boolean }[]\n screen?: ReadScreen\n}\n\n/** At most this many rows are read - the AI 작업판 table's own limit (workspace-blocks MAX_TABLE_ROWS). */\nexport const MAX_READ_ROWS = 1000\n/** Rows the model is shown; the rest stay on the card. */\nexport const ROWS_FOR_MODEL = 20\n/** A page of the list query. */\nexport const READ_PAGE = 200\n\nconst registry = new Map<string, ReadTarget>()\n\nconst pascalOf = (key: string) =>\n key\n .split(/[^a-zA-Z0-9]+/)\n .filter(Boolean)\n .map(part => part[0].toUpperCase() + part.slice(1))\n .join('')\n\nexport const queryToolName = (key: string) => `query${pascalOf(key)}`\nexport const screenToolName = (key: string) => `open${pascalOf(key)}Screen`\nexport const readCategoryName = (key: string) => `data-read:${key}`\n\n/** The columns of a list - shown, each named once, a currency only on a summed number and taken from a string column. */\nfunction checkColumns(of: string, columns: ReadColumn[]): void {\n if (!columns.length) throw new Error(`read target '${of}' shows no column`)\n const names = new Set<string>()\n for (const column of columns) {\n if (names.has(column.name)) throw new Error(`read target '${of}' names the column '${column.name}' twice`)\n names.add(column.name)\n }\n for (const column of columns.filter(one => one.currency)) {\n if (!column.total || column.type !== 'number') throw new Error(`column '${column.name}' of '${of}' names a currency but is not a summed number`)\n if (columns.find(one => one.name === column.currency)?.type !== 'string') throw new Error(`column '${column.name}' of '${of}' takes its currency from '${column.currency}', which is no string column`)\n }\n}\n\nexport function declareReadTarget(target: ReadTarget): void {\n if (!/^[a-z0-9-]+\\.[a-z0-9-]+$/.test(target.key)) throw new Error(`read target key '${target.key}' is not <app>.<record>`)\n if (registry.has(target.key) || details.has(target.key)) throw new Error(`read target '${target.key}' is declared twice`)\n rootFieldOf(target.query, 'query')\n checkColumns(target.key, target.columns)\n const names = new Set<string>(['id'])\n for (const criterion of target.criteria) {\n if (criterion.name === 'id') throw new Error(`read target '${target.key}' declares 'id' - every target takes it`)\n if (criterion.name === 'text' && target.search) throw new Error(`read target '${target.key}' declares 'text' and search - search is the text condition`)\n if (names.has(criterion.name)) throw new Error(`read target '${target.key}' names the condition '${criterion.name}' twice`)\n names.add(criterion.name)\n if (criterion.type === 'enum' && !criterion.values?.length) throw new Error(`condition '${criterion.name}' of '${target.key}' lists no values`)\n }\n if (target.search) names.add('text')\n for (const taken of target.screen?.takes ?? []) if (!names.has(taken)) throw new Error(`the screen of '${target.key}' takes '${taken}', which is no condition`)\n registry.set(target.key, target)\n}\n\nexport function readTargetOf(key: string | undefined): ReadTarget | undefined {\n return key ? registry.get(key) : undefined\n}\n\n/** Every list read target declared - what else reads the declarations (a dashboard card, ADR-0160) lists them by key. */\nexport function readTargetKeys(): string[] {\n return [...registry.keys()]\n}\n\n/** Every detail read declared. */\nexport function detailReadKeys(): string[] {\n return [...details.keys()]\n}\n\nexport function clearReadTargets(): void {\n registry.clear()\n details.clear()\n}\n\n/* ── One answer of a query ──────────────────────────────────────────────────────────────────────────────────── */\n\n/** An argument of a detail read - one variable of its query, read with the entry fields' rules. */\nexport interface DetailArg {\n name: string\n type: 'string' | 'integer' | 'number' | 'boolean' | 'date' | 'enum'\n values?: string[]\n description?: string\n required?: boolean\n /** A record's id: the axis (or axes) of the record, whose key `<axis>:<id>` the model may have been shown (EntryField.axis). */\n axis?: string | readonly string[]\n}\n\n/**\n * A query whose answer is one thing, not a list - a 360's summary, the receivables, a statement (design/ai/read-targets.md\n * §9). The application declares the query with the fields its screen reads; the framework runs it as the person, with\n * the arguments the model set, and hands the answer over as the query returned it. Nothing is summed or cut here: the\n * selection is the projection, and an answer too long to hand over is refused, never cut.\n */\nexport interface DetailRead {\n /** `<app>.<thing>` - the tool is named after it. */\n key: string\n labelKey?: string\n /** What it answers, for the model. */\n description: string\n /** One query with one root field. Its variables are the arguments - each declared in `args`. */\n query: string\n args?: DetailArg[]\n /**\n * The records the answer is about, whose screens put it in front (EntryTarget.axes) - the management check answers\n * for any ledger record; asked on a deposit's 360 why it was in the check, the model never opened it (2026-10-24).\n */\n axes?: string[]\n /**\n * The lists the answer holds, each a table of typed columns - what a dashboard card may draw from a one-answer read\n * (ADR-0160 decision 2). The card keeps only `key`; where the rows are and what their columns are is read here.\n */\n lists?: DetailList[]\n}\n\n/** A list inside a detail read's answer. */\nexport interface DetailList {\n /** A name stable within the read (`by-contract`) - what a card keeps. */\n key: string\n /** A dotted path inside the value of the query's root field (`rows`); '' when the root field is the list. */\n at: string\n labelKey?: string\n /** What the rows are, for the model. */\n description?: string\n columns: ReadColumn[]\n}\n\n/** Characters of an answer handed to the model - a longer one is refused, and the model narrows it. */\nexport const MAX_DETAIL_CHARS = 60_000\n\nconst details = new Map<string, DetailRead>()\n\nexport const detailToolName = (key: string) => `read${pascalOf(key)}`\n\n/** The variables a query declares, and whether each is required (`!`). */\nfunction variablesOf(document: string): { name: string; required: boolean }[] {\n const operation: any = parse(document).definitions.find((one: any) => one.kind === 'OperationDefinition')\n return (operation?.variableDefinitions ?? []).map((one: any) => ({ name: one.variable.name.value, required: one.type.kind === 'NonNullType' && !one.defaultValue }))\n}\n\nexport function declareDetailRead(target: DetailRead): void {\n if (!/^[a-z0-9-]+\\.[a-z0-9-]+$/.test(target.key)) throw new Error(`detail read key '${target.key}' is not <app>.<thing>`)\n if (details.has(target.key) || registry.has(target.key)) throw new Error(`read target '${target.key}' is declared twice`)\n rootFieldOf(target.query, 'query')\n const args = target.args ?? []\n for (const variable of variablesOf(target.query)) {\n const arg = args.find(one => one.name === variable.name)\n if (!arg) throw new Error(`detail read '${target.key}' takes $${variable.name}, which is no argument`)\n if (variable.required && !arg.required) throw new Error(`detail read '${target.key}': $${variable.name} is required by the query - declare it required`)\n }\n for (const arg of args) {\n if (!variablesOf(target.query).some(one => one.name === arg.name)) throw new Error(`detail read '${target.key}' declares '${arg.name}', which its query does not take`)\n if (arg.type === 'enum' && !arg.values?.length) throw new Error(`argument '${arg.name}' of '${target.key}' lists no values`)\n }\n const lists = new Set<string>()\n for (const list of target.lists ?? []) {\n if (!/^[a-z0-9-]+$/.test(list.key)) throw new Error(`list '${list.key}' of '${target.key}' is not a lowercase key`)\n if (lists.has(list.key)) throw new Error(`detail read '${target.key}' names the list '${list.key}' twice`)\n lists.add(list.key)\n if (!/^([A-Za-z0-9_]+(\\.[A-Za-z0-9_]+)*)?$/.test(list.at)) throw new Error(`list '${list.key}' of '${target.key}' is at '${list.at}', which is no dotted path`)\n checkColumns(`${target.key}/${list.key}`, list.columns)\n }\n details.set(target.key, target)\n}\n\nexport function detailReadOf(key: string | undefined): DetailRead | undefined {\n return key ? details.get(key) : undefined\n}\n\n/** The conditions the model set, read by their declared types; a value that does not fit is said, never guessed at. */\nexport function readCriteria(target: ReadTarget, args: any): { criteria: Record<string, unknown>; refused: { name: string; code: string }[] } {\n const criteria: Record<string, unknown> = {}\n const refused: { name: string; code: string }[] = []\n /* One record by its id - every target takes it (the id a list answer or a find tool gave, or the key `<axis>:<id>` an open record is shown by, the axis being the key's last part). */\n if (typeof args?.id === 'string' && args.id.trim()) criteria.id = recordIdOfKey(target.key.split('.').pop()!, args.id) ?? args.id.trim()\n if (target.search && typeof args?.text === 'string' && args.text.trim()) criteria.text = args.text.trim()\n for (const criterion of target.criteria) {\n const value = args?.[criterion.name]\n if (value === undefined || value === null || value === '') continue\n const { read, code } = readFieldValue(criterion as EntryField, value)\n if (read === undefined) refused.push({ name: criterion.name, code: code ?? 'unreadable' })\n else criteria[criterion.name] = read\n }\n return { criteria, refused }\n}\n\nexport function filtersOf(target: ReadTarget, criteria: Record<string, unknown>): ReadFilter[] {\n return [\n ...(typeof criteria.id === 'string' ? [{ name: 'id', operator: 'eq', value: criteria.id }] : []),\n ...target.criteria.flatMap(criterion =>\n criterion.name in criteria ? [criterion.filter(criteria[criterion.name])].flat() : []\n )\n ]\n}\n\nexport const valueAt = (row: any, path: string) => path.split('.').reduce((at, part) => (at === null || at === undefined ? undefined : at[part]), row)\n\n/** One row as the columns say - a number column as a number, a missing value as null. */\nexport function rowOf(target: Pick<ReadTarget, 'columns'>, item: any): Record<string, string | number | null> {\n return Object.fromEntries([\n /* The id names the record to the model - for one record's detail, a change, or its screen. */\n ...(item?.id ? [['id', String(item.id)] as [string, string]] : []),\n ...target.columns.map(column => {\n const raw = valueAt(item, column.path ?? column.name)\n if (raw === undefined || raw === null || raw === '') return [column.name, null]\n if (column.type === 'number') {\n const number = Number(raw)\n return [column.name, Number.isFinite(number) ? number : null]\n }\n return [column.name, String(raw)]\n })\n ])\n}\n\n/**\n * Reads the rows through the application's query, page by page, up to MAX_READ_ROWS. `complete` is false when the\n * list holds more - a sum of the rows read is then not the sum of the list, and is never said as one.\n */\nexport async function readRows(target: ReadTarget, filters: ReadFilter[], run: GraphqlRunner, search?: string): Promise<{ rows: Record<string, any>[]; total: number; complete: boolean }> {\n const rows: Record<string, any>[] = []\n let total = 0\n for (let page = 1; rows.length < MAX_READ_ROWS; page++) {\n const answer = await run(target.query, {\n filters: [...filters, ...(target.fixedFilters ?? [])],\n ...(search ? { search } : {}),\n pagination: { page, limit: READ_PAGE },\n ...(target.sortings ? { sortings: target.sortings } : {})\n })\n if (answer.errors?.length) throw new Error(answer.errors.map(one => one.message).join('; '))\n const read = target.rowsOf(answer.data)\n total = Number(read?.total) || 0\n const items = read?.rows ?? []\n rows.push(...items.slice(0, MAX_READ_ROWS - rows.length).map(item => rowOf(target, item)))\n if (items.length < READ_PAGE || rows.length >= total) break\n }\n return { rows, total, complete: rows.length >= total }\n}\n\n/** A column's sum - one number, or one per currency when the column names its currency (`{ KRW: 1000, USD: 100 }`). */\nexport type ReadSum = number | Record<string, number>\n\nexport interface ReadGroup {\n key: string\n count: number\n sums: Record<string, ReadSum>\n}\n\n/** The currency a row without one is summed under - said as it is, never taken for the domain's own. */\nexport const UNKNOWN_CURRENCY = 'unknown'\n\nconst sumOf = (rows: Record<string, any>[], name: string) => Math.round(rows.reduce((sum, row) => sum + (typeof row[name] === 'number' ? row[name] : 0), 0) * 100) / 100\n\n/** The sums of the number columns marked total - the server's, never the model's; a column with a currency per currency. */\nexport function sumsOf(target: Pick<ReadTarget, 'columns'>, rows: Record<string, any>[]): Record<string, ReadSum> {\n const sums: Record<string, ReadSum> = {}\n for (const column of target.columns.filter(one => one.total && one.type === 'number')) {\n if (!column.currency) {\n sums[column.name] = sumOf(rows, column.name)\n continue\n }\n const byCurrency = new Map<string, Record<string, any>[]>()\n for (const row of rows) {\n const code = typeof row[column.currency] === 'string' && row[column.currency] ? row[column.currency] : UNKNOWN_CURRENCY\n byCurrency.set(code, [...(byCurrency.get(code) ?? []), row])\n }\n sums[column.name] = Object.fromEntries([...byCurrency].sort(([a], [b]) => a.localeCompare(b)).map(([code, members]) => [code, sumOf(members, column.name)]))\n }\n return sums\n}\n\n/** The currencies a set of sums holds for one column - none for a column summed as one number. */\nexport function currenciesOf(sums: Record<string, ReadSum>[], column: string): string[] {\n const codes = new Set<string>()\n for (const one of sums) if (one[column] && typeof one[column] === 'object') for (const code of Object.keys(one[column] as object)) codes.add(code)\n return [...codes].sort()\n}\n\n/** The rows grouped by one column - a date column by its month - each with its count and sums, largest first. */\nexport function groupsOf(target: Pick<ReadTarget, 'columns'>, rows: Record<string, any>[], by: string): ReadGroup[] | undefined {\n const column = target.columns.find(one => one.name === by)\n if (!column) return undefined\n const groups = new Map<string, Record<string, any>[]>()\n for (const row of rows) {\n const value = row[by]\n const key = value === null || value === undefined ? '' : column.type === 'date' ? String(value).slice(0, 7) : String(value)\n groups.set(key, [...(groups.get(key) ?? []), row])\n }\n const list = [...groups].map(([key, members]) => ({ key, count: members.length, sums: sumsOf(target, members) }))\n if (column.type === 'date') return list.sort((a, b) => a.key.localeCompare(b.key))\n /* Largest first by the first sum - in its one currency; groups in two currencies have no common size, so by count. */\n const first = target.columns.find(one => one.total)?.name\n const codes = first ? currenciesOf(list.map(group => group.sums), first) : []\n const size = (group: ReadGroup) => {\n const sum = first ? group.sums[first] : undefined\n return typeof sum === 'number' ? Math.abs(sum) : codes.length === 1 && sum ? Math.abs(sum[codes[0]] ?? 0) : undefined\n }\n return list.sort((a, b) => {\n const [x, y] = [size(a), size(b)]\n return x !== undefined && y !== undefined && codes.length <= 1 ? y - x : b.count - a.count\n })\n}\n\n/** The address of the target's list screen with the conditions it takes, and the conditions it does not. */\nexport function screenAddress(target: ReadTarget, criteria: Record<string, unknown>): { href: string; applied: string[]; notApplied: string[] } | undefined {\n const screen = target.screen\n if (!screen) return undefined\n const params = new URLSearchParams()\n for (const [name, value] of Object.entries(screen.params(criteria))) if (value !== undefined && value !== null && value !== '') params.set(name, String(value))\n const given = Object.keys(criteria)\n const applicable = Object.fromEntries(Object.entries(criteria).filter(([name]) => screen.takes.includes(name)))\n const query = screen.queryState\n ? encodeListQuery({\n filters: filtersOf(target, applicable),\n search: typeof applicable.text === 'string' ? applicable.text : undefined,\n sorters: target.sortings\n })\n : params.toString()\n return {\n href: query ? `${screen.route}?${query}` : screen.route,\n applied: given.filter(name => screen.takes.includes(name)),\n notApplied: given.filter(name => !screen.takes.includes(name))\n }\n}\n"]}
|
|
@@ -226,6 +226,23 @@ export declare function readCategoryOf(target: ReadTarget, run?: (context: any)
|
|
|
226
226
|
* in `readTargets`.
|
|
227
227
|
*/
|
|
228
228
|
export declare function registerReadTarget(target: ReadTarget): void;
|
|
229
|
+
/**
|
|
230
|
+
* What running a detail read as the person gave - the root field's value, or why there is none. Shared by the tool,
|
|
231
|
+
* which hands the value to the model, and by every other reader of a detail read (a dashboard card, ADR-0160
|
|
232
|
+
* decision 2), which has its own limits: the arguments, the door and the query are one, the size rule is the tool's.
|
|
233
|
+
*/
|
|
234
|
+
export interface DetailRun {
|
|
235
|
+
/** The root field's value - absent when `error` says why. */
|
|
236
|
+
value?: unknown;
|
|
237
|
+
error?: 'argument-unreadable' | 'query-failed' | 'not-found';
|
|
238
|
+
refused?: {
|
|
239
|
+
name: string;
|
|
240
|
+
code: string;
|
|
241
|
+
}[];
|
|
242
|
+
message?: string;
|
|
243
|
+
}
|
|
244
|
+
/** Runs the query as the person with the arguments given - read by their declared types, a missing required one refused. */
|
|
245
|
+
export declare function runDetail(target: DetailRead, args: any, run: GraphqlRunner): Promise<DetailRun>;
|
|
229
246
|
/** Runs the query as the person with the arguments the model set; the answer as the query returned it. */
|
|
230
247
|
export declare function queryDetail(target: DetailRead, args: any, run: GraphqlRunner): Promise<{
|
|
231
248
|
rejected: boolean;
|
|
@@ -268,7 +285,7 @@ export declare function queryDetail(target: DetailRead, args: any, run: GraphqlR
|
|
|
268
285
|
answer?: undefined;
|
|
269
286
|
} | {
|
|
270
287
|
target: string;
|
|
271
|
-
answer:
|
|
288
|
+
answer: unknown;
|
|
272
289
|
message: string;
|
|
273
290
|
rejected?: undefined;
|
|
274
291
|
error?: undefined;
|
|
@@ -4,6 +4,7 @@ exports.queryRecords = queryRecords;
|
|
|
4
4
|
exports.openScreen = openScreen;
|
|
5
5
|
exports.readCategoryOf = readCategoryOf;
|
|
6
6
|
exports.registerReadTarget = registerReadTarget;
|
|
7
|
+
exports.runDetail = runDetail;
|
|
7
8
|
exports.queryDetail = queryDetail;
|
|
8
9
|
exports.detailCategoryOf = detailCategoryOf;
|
|
9
10
|
exports.registerDetailRead = registerDetailRead;
|
|
@@ -214,8 +215,8 @@ function argSchema(arg) {
|
|
|
214
215
|
const said = [arg.description, arg.type === 'date' ? 'YYYY-MM-DD' : undefined, arg.type === 'enum' ? `one of: ${arg.values.join(', ')}` : undefined].filter(Boolean).join('. ');
|
|
215
216
|
return { type, ...(said ? { description: said } : {}) };
|
|
216
217
|
}
|
|
217
|
-
/** Runs the query as the person with the arguments
|
|
218
|
-
async function
|
|
218
|
+
/** Runs the query as the person with the arguments given - read by their declared types, a missing required one refused. */
|
|
219
|
+
async function runDetail(target, args, run) {
|
|
219
220
|
const variables = {};
|
|
220
221
|
const refused = [];
|
|
221
222
|
for (const arg of target.args ?? []) {
|
|
@@ -232,20 +233,33 @@ async function queryDetail(target, args, run) {
|
|
|
232
233
|
variables[arg.name] = read;
|
|
233
234
|
}
|
|
234
235
|
if (refused.length)
|
|
235
|
-
return {
|
|
236
|
+
return { error: 'argument-unreadable', refused };
|
|
236
237
|
let answer;
|
|
237
238
|
try {
|
|
238
239
|
answer = await run(target.query, variables);
|
|
239
240
|
}
|
|
240
241
|
catch (error) {
|
|
241
|
-
return {
|
|
242
|
+
return { error: 'query-failed', message: String(error?.message ?? error) };
|
|
242
243
|
}
|
|
243
244
|
if (answer.errors?.length)
|
|
244
|
-
return {
|
|
245
|
+
return { error: 'query-failed', message: answer.errors.map(one => one.message).join('; ') };
|
|
245
246
|
const root = (0, entry_target_js_1.rootFieldOf)(target.query, 'query').replace(/^Query\./, '');
|
|
246
247
|
const value = answer.data?.[root];
|
|
247
248
|
if (value === null || value === undefined)
|
|
249
|
+
return { error: 'not-found' };
|
|
250
|
+
return { value };
|
|
251
|
+
}
|
|
252
|
+
/** Runs the query as the person with the arguments the model set; the answer as the query returned it. */
|
|
253
|
+
async function queryDetail(target, args, run) {
|
|
254
|
+
const ran = await runDetail(target, args, run);
|
|
255
|
+
if (ran.error) {
|
|
256
|
+
if (ran.error === 'argument-unreadable')
|
|
257
|
+
return { rejected: true, error: 'argument-unreadable', refused: ran.refused, message: `these arguments are missing or do not fit their type: ${ran.refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` };
|
|
258
|
+
if (ran.error === 'query-failed')
|
|
259
|
+
return { rejected: true, error: 'query-failed', message: `it could not be read: ${ran.message}` };
|
|
248
260
|
return { target: target.key, found: false, message: 'nothing was found for these arguments - say so; do not fill it in.' };
|
|
261
|
+
}
|
|
262
|
+
const value = ran.value;
|
|
249
263
|
const size = JSON.stringify(value).length;
|
|
250
264
|
if (size > read_target_js_1.MAX_DETAIL_CHARS)
|
|
251
265
|
return { rejected: true, error: 'answer-too-large', size, message: `the answer runs to ${size} characters, more than ${read_target_js_1.MAX_DETAIL_CHARS} - narrow the arguments, or read the list it is made of.` };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-tools.js","sourceRoot":"","sources":["../../../server/service/data-read/read-tools.ts"],"names":[],"mappings":";;AAwDA,oCAmFC;AAED,gCAqBC;AAED,wCAuDC;AAMD,gDAGC;AAWD,kCA2BC;AAED,4CAuBC;AAGD,gDAGC;AAzSD;;;;;;;GAOG;AACH,mEAAuG;AAEvG,mEAA2E;AAE3E,iEAA0D;AAC1D,0EAAwF;AACxF,qDAoByB;AAEzB,yFAAyF;AACzF,MAAM,OAAO,GAAG,CAAC,OAAY,EAAE,EAAE,CAAC,CAAC,GAAuB,EAAE,QAAgB,EAAE,EAAE;IAC9E,IAAI,CAAC,GAAG,IAAI,OAAO,OAAO,EAAE,CAAC,KAAK,UAAU;QAAE,OAAO,QAAQ,CAAA;IAC7D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAC3B,OAAO,IAAI,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAA;IACjB,CAAC;AACH,CAAC,CAAA;AAED,SAAS,eAAe,CAAC,SAAwB;IAC/C,yFAAyF;IACzF,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAA;IACpJ,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,KAAK,MAA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ACb,WAAW,EAAE,QAAQ,MAAM,CAAC,WAAW,EAAE;gBACzC,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC5I,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBAC3F;gBACD,OAAO,EAAE,CAAC,IAAS,EAAE,OAAY,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;aAClE;SACd;KACF,CAAA;AACH,CAAC;AAED,kIAAkI;AAClI,SAAgB,kBAAkB,CAAC,MAAkB;IACnD,IAAA,kCAAiB,EAAC,MAAM,CAAC,CAAA;IACzB,IAAA,qCAAoB,EAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC","sourcesContent":["/*\n * The tools of an AI 조회 target (operato-application/design/ai/read-targets.md §4, §5).\n *\n * query<X> reads the rows through the application's list query as the person, and tells the model the count, the\n * sums, the groups and a few rows. A longer result goes on the AI 작업판 as a proposal the server builds from the rows\n * themselves - the table is never written by the model. open<X>Screen reads nothing: it hands the card the address\n * of the application's list screen with the conditions it takes.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\n\nimport { readFieldValue, rootFieldOf } from '../data-entry/entry-target.js'\nimport type { GraphqlRunner } from '../data-entry/entry-update.js'\nimport { runAsCaller } from '../data-entry/entry-tools.js'\nimport { normalizeWorkspace, workspaceContents } from '../workspace/workspace-blocks.js'\nimport {\n declareReadTarget,\n filtersOf,\n currenciesOf,\n declareDetailRead,\n detailToolName,\n MAX_DETAIL_CHARS,\n type DetailArg,\n type DetailRead,\n groupsOf,\n queryToolName,\n readCategoryName,\n readCriteria,\n readRows,\n ROWS_FOR_MODEL,\n screenAddress,\n screenToolName,\n sumsOf,\n type ReadCriterion,\n type ReadTarget\n} from './read-target.js'\n\n/** The reader's words for a key - the key's own default when the translator has none. */\nconst wordsOf = (context: any) => (key: string | undefined, fallback: string) => {\n if (!key || typeof context?.t !== 'function') return fallback\n try {\n const said = context.t(key)\n return said && said !== key ? String(said) : fallback\n } catch {\n return fallback\n }\n}\n\nfunction criterionSchema(criterion: ReadCriterion): any {\n /* One type per field - Gemini's function schema refuses a list of types (2026-10-01). */\n const type = criterion.type === 'number' ? 'number' : criterion.type === 'integer' ? 'integer' : criterion.type === 'boolean' ? 'boolean' : 'string'\n const said = [criterion.description, criterion.type === 'date' ? 'YYYY-MM-DD' : undefined, criterion.type === 'enum' ? `one of: ${criterion.values!.join(', ')}` : undefined]\n .filter(Boolean)\n .join('. ')\n return { type, ...(said ? { description: said } : {}) }\n}\n\nexport async function queryRecords(target: ReadTarget, args: any, context: any, run: GraphqlRunner) {\n const { criteria, refused } = readCriteria(target, args)\n if (refused.length) {\n return { rejected: true, error: 'condition-unreadable', refused, message: `these conditions do not fit their type: ${refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }\n }\n let read\n try {\n read = await readRows(target, filtersOf(target, criteria), run, typeof criteria.text === 'string' && target.search ? criteria.text : undefined)\n } catch (error: any) {\n return { rejected: true, error: 'query-failed', message: `the list could not be read: ${error?.message ?? error}` }\n }\n const { rows, total, complete } = read\n const sums = sumsOf(target, rows)\n const groupBy = typeof args?.groupBy === 'string' && args.groupBy ? args.groupBy : undefined\n const groups = groupBy ? groupsOf(target, rows, groupBy) : undefined\n const words = wordsOf(context)\n const label = words(target.labelKey, target.key)\n\n const said = {\n target: target.key,\n criteria,\n total,\n read: rows.length,\n complete,\n sums,\n ...(groupBy ? (groups ? { groupBy, groups: groups.slice(0, 50), ...(groups.length > 50 ? { moreGroups: groups.length - 50 } : {}) } : { groupBy, groupRefused: 'no such column' }) : {}),\n rows: rows.slice(0, ROWS_FOR_MODEL),\n ...(rows.length > ROWS_FOR_MODEL ? { rowsNotShown: rows.length - ROWS_FOR_MODEL } : {})\n }\n const incomplete = complete\n ? ''\n : ` Only ${rows.length} of ${total} rows were read; the sums and groups are of those rows, not of the list - say so, and ask the person to narrow the conditions.`\n\n if (rows.length === 1 && args?.show !== 'workspace') {\n return { ...said, record: rows[0], message: 'one record - answer from its fields; say a field it does not have as not recorded.' }\n }\n if (rows.length <= ROWS_FOR_MODEL && args?.show !== 'workspace') {\n return { ...said, message: `${rows.length} rows of ${total}.${incomplete} Answer from these rows; every number you say comes from them.` }\n }\n\n /* The workspace is built here from the rows as read - the model never copies the table. */\n const columns = target.columns.map(column => ({ name: column.name, label: words(column.labelKey, column.name), type: column.type }))\n const totalColumns = target.columns.filter(one => one.total)\n /* A sum per currency is one figure and one group column per currency it holds - 「계약금액 (USD)」. */\n const sumColumns = totalColumns.flatMap(column => {\n const label = words(column.labelKey, column.name)\n const codes = currenciesOf([sums, ...(groups ?? []).map(group => group.sums)], column.name)\n return column.currency\n ? codes.map(code => ({ name: `${column.name}:${code}`, label: `${label} (${code})`, of: (one: Record<string, any>) => one[column.name]?.[code] ?? 0 }))\n : [{ name: column.name, label, of: (one: Record<string, any>) => one[column.name] }]\n })\n const title = typeof args?.title === 'string' && args.title.trim() ? args.title.trim() : `${label} · ${rows.length}`\n const { workspace } = normalizeWorkspace({\n name: typeof args?.name === 'string' && args.name ? args.name : target.key.replace(/\\./g, '-'),\n title,\n ...(complete ? {} : { summary: `${total} / ${rows.length}` }),\n blocks: [\n {\n kind: 'metrics',\n items: [{ label: words('ai-assistant.read.count', 'rows'), value: String(rows.length), ...(complete ? {} : { note: `/ ${total}` }) }, ...sumColumns.map(column => ({ label: column.label, value: String(column.of(sums)) }))]\n },\n ...(groups\n ? [\n {\n kind: 'table',\n caption: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!),\n columns: [{ name: 'key', label: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!), type: 'string' }, { name: 'count', label: words('ai-assistant.read.count', 'rows'), type: 'number' }, ...sumColumns.map(column => ({ name: column.name, label: column.label, type: 'number' }))],\n rows: groups.map(group => ({ key: group.key, count: group.count, ...Object.fromEntries(sumColumns.map(column => [column.name, column.of(group.sums)])) }))\n }\n ]\n : []),\n { kind: 'table', caption: label, columns, rows }\n ]\n })\n return {\n proposed: true,\n kind: 'workspace',\n icon: 'table_view',\n label: title,\n ...said,\n forScreen: { workspace, contents: workspaceContents(workspace!) },\n message: `${rows.length} rows of ${total} are on the AI 작업판 as read - the person opens it from the card.${incomplete} Say the point in one or two lines from the sums, groups and rows above; do not write the table out.`\n }\n}\n\nexport function openScreen(target: ReadTarget, args: any, context: any) {\n const { criteria, refused } = readCriteria(target, args)\n if (refused.length) return { rejected: true, error: 'condition-unreadable', refused, message: 'fix the conditions and call again.' }\n const address = screenAddress(target, criteria)\n if (!address) return { rejected: true, error: 'no-screen', message: 'this list has no screen to open.' }\n const words = wordsOf(context)\n return {\n proposed: true,\n kind: 'open-page',\n icon: 'open_in_new',\n label: words(target.screen!.labelKey ?? target.labelKey, target.key),\n target: target.key,\n href: address.href,\n applied: address.applied,\n notApplied: address.notApplied,\n /* The card says them in the reader's words. */\n notAppliedLabels: address.notApplied.map(name => words(target.criteria.find(one => one.name === name)?.labelKey ?? (name === 'text' || name === 'id' ? `ai-assistant.read.${name}` : undefined), name)),\n message:\n 'the card opens the screen when the person presses it.' +\n (address.notApplied.length ? ` The screen does not take ${address.notApplied.join(', ')} - say so.` : '')\n }\n}\n\nexport function readCategoryOf(target: ReadTarget, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {\n const door = rootFieldOf(target.query, 'query')\n const conditions = {\n ...Object.fromEntries(target.criteria.map(criterion => [criterion.name, criterionSchema(criterion)])),\n ...(target.search ? { text: { type: 'string', description: `words to find - ${target.search.description}` } } : {})\n }\n const specs: ToolSpec[] = [\n {\n kind: 'read',\n name: queryToolName(target.key),\n /* The person must be able to read the list on its screen - the tool is not a second way in. */\n doors: [door],\n description:\n `Read ${target.description} Set the conditions the question names. Returns the count, the sums, ` +\n `groups when groupBy is given (a date column groups by month) and the first ${ROWS_FOR_MODEL} rows; more rows go on the AI 작업판 as read.`,\n schema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'One record by its id, from an earlier answer - its detail.' },\n ...conditions,\n groupBy: { type: 'string', description: `One column to group by: ${target.columns.map(one => one.name).join(', ')}.` },\n show: { type: 'string', enum: ['answer', 'workspace'], description: 'workspace to put even a short result on the AI 작업판.' },\n title: { type: 'string', description: 'The workspace title, in the person\\'s language.' },\n name: { type: 'string', description: 'The workspace key; the same key again makes a new version.' }\n }\n },\n builder: (args: any, context: any) => queryRecords(target, args, context, run(context))\n } as ToolSpec,\n ...(target.screen\n ? [\n {\n kind: 'read',\n name: screenToolName(target.key),\n doors: [door],\n description: `Offer the person the screen that lists ${target.description} with these conditions. Reads nothing. The screen takes: ${target.screen.takes.join(', ')}.`,\n schema: { type: 'object', properties: conditions },\n builder: (args: any, context: any) => openScreen(target, args, context)\n } as ToolSpec\n ]\n : [])\n ]\n return {\n name: readCategoryName(target.key),\n description: `data read: ${target.key}`,\n guidance: [\n `- To answer from ${target.key} records - a list, or one record found by its name, code or id - call ${queryToolName(target.key)} with the conditions the question names. Every number you say comes from its result - never add up rows yourself; use its sums and groups.`,\n `- A list, a summary by item or month, or a comparison: call it with groupBy, and let a long result go on the AI 작업판 - then answer in one or two lines.`,\n `- When the result says complete: false, say how many of how many were read and ask to narrow - never call partial sums the total.`,\n ...(target.columns.some(one => one.currency)\n ? [`- Sums of ${target.columns.filter(one => one.currency).map(one => one.name).join(', ')} come per currency. Say each currency's sum; never add two currencies into one number. A comparison across currencies uses a rate you read, and says the rate and its date.`]\n : []),\n ...(target.screen ? [`- When the person wants to work on the records themselves (edit, sort, export), call ${screenToolName(target.key)}; say which conditions the screen does not take.`] : [])\n ].join('\\n'),\n specs\n }\n}\n\n/**\n * What an application calls at boot to let the assistant read one of its lists. A mode opens it by naming the key\n * in `readTargets`.\n */\nexport function registerReadTarget(target: ReadTarget): void {\n declareReadTarget(target)\n registerToolCategory(readCategoryOf(target))\n}\n\n/* ── One answer of a query (DetailRead) ───────────────────────────────────────────────────────────────────── */\n\nfunction argSchema(arg: DetailArg): any {\n const type = arg.type === 'number' ? 'number' : arg.type === 'integer' ? 'integer' : arg.type === 'boolean' ? 'boolean' : 'string'\n const said = [arg.description, arg.type === 'date' ? 'YYYY-MM-DD' : undefined, arg.type === 'enum' ? `one of: ${arg.values!.join(', ')}` : undefined].filter(Boolean).join('. ')\n return { type, ...(said ? { description: said } : {}) }\n}\n\n/** Runs the query as the person with the arguments the model set; the answer as the query returned it. */\nexport async function queryDetail(target: DetailRead, args: any, run: GraphqlRunner) {\n const variables: Record<string, unknown> = {}\n const refused: { name: string; code: string }[] = []\n for (const arg of target.args ?? []) {\n const value = args?.[arg.name]\n if (value === undefined || value === null || value === '') {\n if (arg.required) refused.push({ name: arg.name, code: 'required' })\n continue\n }\n const { read, code } = readFieldValue({ name: arg.name, type: arg.type === 'string' ? 'text' : arg.type, values: arg.values, axis: arg.axis } as any, value)\n if (read === undefined) refused.push({ name: arg.name, code: code ?? 'unreadable' })\n else variables[arg.name] = read\n }\n if (refused.length) return { rejected: true, error: 'argument-unreadable', refused, message: `these arguments are missing or do not fit their type: ${refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }\n let answer\n try {\n answer = await run(target.query, variables)\n } catch (error: any) {\n return { rejected: true, error: 'query-failed', message: `it could not be read: ${error?.message ?? error}` }\n }\n if (answer.errors?.length) return { rejected: true, error: 'query-failed', message: `it could not be read: ${answer.errors.map(one => one.message).join('; ')}` }\n const root = rootFieldOf(target.query, 'query').replace(/^Query\\./, '')\n const value = answer.data?.[root]\n if (value === null || value === undefined) return { target: target.key, found: false, message: 'nothing was found for these arguments - say so; do not fill it in.' }\n const size = JSON.stringify(value).length\n if (size > MAX_DETAIL_CHARS) return { rejected: true, error: 'answer-too-large', size, message: `the answer runs to ${size} characters, more than ${MAX_DETAIL_CHARS} - narrow the arguments, or read the list it is made of.` }\n return { target: target.key, answer: value, message: 'answer from these fields; every number you say comes from them. Amounts are in the currency beside them - never add two currencies into one number.' }\n}\n\nexport function detailCategoryOf(target: DetailRead, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {\n const door = rootFieldOf(target.query, 'query')\n const name = detailToolName(target.key)\n return {\n name: readCategoryName(target.key),\n description: `data read: ${target.key}`,\n guidance: `- To answer about ${target.description.replace(/\\.$/, '')}, call ${name}. Every number you say comes from its answer.`,\n specs: [\n {\n kind: 'read',\n name,\n /* The person must be able to run the query on its screen - the tool is not a second way in. */\n doors: [door],\n description: `Read ${target.description}`,\n schema: {\n type: 'object',\n ...((target.args ?? []).some(one => one.required) ? { required: (target.args ?? []).filter(one => one.required).map(one => one.name) } : {}),\n properties: Object.fromEntries((target.args ?? []).map(arg => [arg.name, argSchema(arg)]))\n },\n builder: (args: any, context: any) => queryDetail(target, args, run(context))\n } as ToolSpec\n ]\n }\n}\n\n/** What an application calls at boot to let the assistant read one answer of its API. A mode opens it by key in `readTargets`. */\nexport function registerDetailRead(target: DetailRead): void {\n declareDetailRead(target)\n registerToolCategory(detailCategoryOf(target))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"read-tools.js","sourceRoot":"","sources":["../../../server/service/data-read/read-tools.ts"],"names":[],"m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GAAG,CAAC,OAAO,CAAC,CAAC;aAClE;SACd;KACF,CAAA;AACH,CAAC;AAED,kIAAkI;AAClI,SAAgB,kBAAkB,CAAC,MAAkB;IACnD,IAAA,kCAAiB,EAAC,MAAM,CAAC,CAAA;IACzB,IAAA,qCAAoB,EAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC","sourcesContent":["/*\n * The tools of an AI 조회 target (operato-application/design/ai/read-targets.md §4, §5).\n *\n * query<X> reads the rows through the application's list query as the person, and tells the model the count, the\n * sums, the groups and a few rows. A longer result goes on the AI 작업판 as a proposal the server builds from the rows\n * themselves - the table is never written by the model. open<X>Screen reads nothing: it hands the card the address\n * of the application's list screen with the conditions it takes.\n */\nimport { registerToolCategory, type ToolCategory, type ToolSpec } from '@things-factory/ai-client-base'\n\nimport { readFieldValue, rootFieldOf } from '../data-entry/entry-target.js'\nimport type { GraphqlRunner } from '../data-entry/entry-update.js'\nimport { runAsCaller } from '../data-entry/entry-tools.js'\nimport { normalizeWorkspace, workspaceContents } from '../workspace/workspace-blocks.js'\nimport {\n declareReadTarget,\n filtersOf,\n currenciesOf,\n declareDetailRead,\n detailToolName,\n MAX_DETAIL_CHARS,\n type DetailArg,\n type DetailRead,\n groupsOf,\n queryToolName,\n readCategoryName,\n readCriteria,\n readRows,\n ROWS_FOR_MODEL,\n screenAddress,\n screenToolName,\n sumsOf,\n type ReadCriterion,\n type ReadTarget\n} from './read-target.js'\n\n/** The reader's words for a key - the key's own default when the translator has none. */\nconst wordsOf = (context: any) => (key: string | undefined, fallback: string) => {\n if (!key || typeof context?.t !== 'function') return fallback\n try {\n const said = context.t(key)\n return said && said !== key ? String(said) : fallback\n } catch {\n return fallback\n }\n}\n\nfunction criterionSchema(criterion: ReadCriterion): any {\n /* One type per field - Gemini's function schema refuses a list of types (2026-10-01). */\n const type = criterion.type === 'number' ? 'number' : criterion.type === 'integer' ? 'integer' : criterion.type === 'boolean' ? 'boolean' : 'string'\n const said = [criterion.description, criterion.type === 'date' ? 'YYYY-MM-DD' : undefined, criterion.type === 'enum' ? `one of: ${criterion.values!.join(', ')}` : undefined]\n .filter(Boolean)\n .join('. ')\n return { type, ...(said ? { description: said } : {}) }\n}\n\nexport async function queryRecords(target: ReadTarget, args: any, context: any, run: GraphqlRunner) {\n const { criteria, refused } = readCriteria(target, args)\n if (refused.length) {\n return { rejected: true, error: 'condition-unreadable', refused, message: `these conditions do not fit their type: ${refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }\n }\n let read\n try {\n read = await readRows(target, filtersOf(target, criteria), run, typeof criteria.text === 'string' && target.search ? criteria.text : undefined)\n } catch (error: any) {\n return { rejected: true, error: 'query-failed', message: `the list could not be read: ${error?.message ?? error}` }\n }\n const { rows, total, complete } = read\n const sums = sumsOf(target, rows)\n const groupBy = typeof args?.groupBy === 'string' && args.groupBy ? args.groupBy : undefined\n const groups = groupBy ? groupsOf(target, rows, groupBy) : undefined\n const words = wordsOf(context)\n const label = words(target.labelKey, target.key)\n\n const said = {\n target: target.key,\n criteria,\n total,\n read: rows.length,\n complete,\n sums,\n ...(groupBy ? (groups ? { groupBy, groups: groups.slice(0, 50), ...(groups.length > 50 ? { moreGroups: groups.length - 50 } : {}) } : { groupBy, groupRefused: 'no such column' }) : {}),\n rows: rows.slice(0, ROWS_FOR_MODEL),\n ...(rows.length > ROWS_FOR_MODEL ? { rowsNotShown: rows.length - ROWS_FOR_MODEL } : {})\n }\n const incomplete = complete\n ? ''\n : ` Only ${rows.length} of ${total} rows were read; the sums and groups are of those rows, not of the list - say so, and ask the person to narrow the conditions.`\n\n if (rows.length === 1 && args?.show !== 'workspace') {\n return { ...said, record: rows[0], message: 'one record - answer from its fields; say a field it does not have as not recorded.' }\n }\n if (rows.length <= ROWS_FOR_MODEL && args?.show !== 'workspace') {\n return { ...said, message: `${rows.length} rows of ${total}.${incomplete} Answer from these rows; every number you say comes from them.` }\n }\n\n /* The workspace is built here from the rows as read - the model never copies the table. */\n const columns = target.columns.map(column => ({ name: column.name, label: words(column.labelKey, column.name), type: column.type }))\n const totalColumns = target.columns.filter(one => one.total)\n /* A sum per currency is one figure and one group column per currency it holds - 「계약금액 (USD)」. */\n const sumColumns = totalColumns.flatMap(column => {\n const label = words(column.labelKey, column.name)\n const codes = currenciesOf([sums, ...(groups ?? []).map(group => group.sums)], column.name)\n return column.currency\n ? codes.map(code => ({ name: `${column.name}:${code}`, label: `${label} (${code})`, of: (one: Record<string, any>) => one[column.name]?.[code] ?? 0 }))\n : [{ name: column.name, label, of: (one: Record<string, any>) => one[column.name] }]\n })\n const title = typeof args?.title === 'string' && args.title.trim() ? args.title.trim() : `${label} · ${rows.length}`\n const { workspace } = normalizeWorkspace({\n name: typeof args?.name === 'string' && args.name ? args.name : target.key.replace(/\\./g, '-'),\n title,\n ...(complete ? {} : { summary: `${total} / ${rows.length}` }),\n blocks: [\n {\n kind: 'metrics',\n items: [{ label: words('ai-assistant.read.count', 'rows'), value: String(rows.length), ...(complete ? {} : { note: `/ ${total}` }) }, ...sumColumns.map(column => ({ label: column.label, value: String(column.of(sums)) }))]\n },\n ...(groups\n ? [\n {\n kind: 'table',\n caption: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!),\n columns: [{ name: 'key', label: words(target.columns.find(one => one.name === groupBy)?.labelKey, groupBy!), type: 'string' }, { name: 'count', label: words('ai-assistant.read.count', 'rows'), type: 'number' }, ...sumColumns.map(column => ({ name: column.name, label: column.label, type: 'number' }))],\n rows: groups.map(group => ({ key: group.key, count: group.count, ...Object.fromEntries(sumColumns.map(column => [column.name, column.of(group.sums)])) }))\n }\n ]\n : []),\n { kind: 'table', caption: label, columns, rows }\n ]\n })\n return {\n proposed: true,\n kind: 'workspace',\n icon: 'table_view',\n label: title,\n ...said,\n forScreen: { workspace, contents: workspaceContents(workspace!) },\n message: `${rows.length} rows of ${total} are on the AI 작업판 as read - the person opens it from the card.${incomplete} Say the point in one or two lines from the sums, groups and rows above; do not write the table out.`\n }\n}\n\nexport function openScreen(target: ReadTarget, args: any, context: any) {\n const { criteria, refused } = readCriteria(target, args)\n if (refused.length) return { rejected: true, error: 'condition-unreadable', refused, message: 'fix the conditions and call again.' }\n const address = screenAddress(target, criteria)\n if (!address) return { rejected: true, error: 'no-screen', message: 'this list has no screen to open.' }\n const words = wordsOf(context)\n return {\n proposed: true,\n kind: 'open-page',\n icon: 'open_in_new',\n label: words(target.screen!.labelKey ?? target.labelKey, target.key),\n target: target.key,\n href: address.href,\n applied: address.applied,\n notApplied: address.notApplied,\n /* The card says them in the reader's words. */\n notAppliedLabels: address.notApplied.map(name => words(target.criteria.find(one => one.name === name)?.labelKey ?? (name === 'text' || name === 'id' ? `ai-assistant.read.${name}` : undefined), name)),\n message:\n 'the card opens the screen when the person presses it.' +\n (address.notApplied.length ? ` The screen does not take ${address.notApplied.join(', ')} - say so.` : '')\n }\n}\n\nexport function readCategoryOf(target: ReadTarget, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {\n const door = rootFieldOf(target.query, 'query')\n const conditions = {\n ...Object.fromEntries(target.criteria.map(criterion => [criterion.name, criterionSchema(criterion)])),\n ...(target.search ? { text: { type: 'string', description: `words to find - ${target.search.description}` } } : {})\n }\n const specs: ToolSpec[] = [\n {\n kind: 'read',\n name: queryToolName(target.key),\n /* The person must be able to read the list on its screen - the tool is not a second way in. */\n doors: [door],\n description:\n `Read ${target.description} Set the conditions the question names. Returns the count, the sums, ` +\n `groups when groupBy is given (a date column groups by month) and the first ${ROWS_FOR_MODEL} rows; more rows go on the AI 작업판 as read.`,\n schema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'One record by its id, from an earlier answer - its detail.' },\n ...conditions,\n groupBy: { type: 'string', description: `One column to group by: ${target.columns.map(one => one.name).join(', ')}.` },\n show: { type: 'string', enum: ['answer', 'workspace'], description: 'workspace to put even a short result on the AI 작업판.' },\n title: { type: 'string', description: 'The workspace title, in the person\\'s language.' },\n name: { type: 'string', description: 'The workspace key; the same key again makes a new version.' }\n }\n },\n builder: (args: any, context: any) => queryRecords(target, args, context, run(context))\n } as ToolSpec,\n ...(target.screen\n ? [\n {\n kind: 'read',\n name: screenToolName(target.key),\n doors: [door],\n description: `Offer the person the screen that lists ${target.description} with these conditions. Reads nothing. The screen takes: ${target.screen.takes.join(', ')}.`,\n schema: { type: 'object', properties: conditions },\n builder: (args: any, context: any) => openScreen(target, args, context)\n } as ToolSpec\n ]\n : [])\n ]\n return {\n name: readCategoryName(target.key),\n description: `data read: ${target.key}`,\n guidance: [\n `- To answer from ${target.key} records - a list, or one record found by its name, code or id - call ${queryToolName(target.key)} with the conditions the question names. Every number you say comes from its result - never add up rows yourself; use its sums and groups.`,\n `- A list, a summary by item or month, or a comparison: call it with groupBy, and let a long result go on the AI 작업판 - then answer in one or two lines.`,\n `- When the result says complete: false, say how many of how many were read and ask to narrow - never call partial sums the total.`,\n ...(target.columns.some(one => one.currency)\n ? [`- Sums of ${target.columns.filter(one => one.currency).map(one => one.name).join(', ')} come per currency. Say each currency's sum; never add two currencies into one number. A comparison across currencies uses a rate you read, and says the rate and its date.`]\n : []),\n ...(target.screen ? [`- When the person wants to work on the records themselves (edit, sort, export), call ${screenToolName(target.key)}; say which conditions the screen does not take.`] : [])\n ].join('\\n'),\n specs\n }\n}\n\n/**\n * What an application calls at boot to let the assistant read one of its lists. A mode opens it by naming the key\n * in `readTargets`.\n */\nexport function registerReadTarget(target: ReadTarget): void {\n declareReadTarget(target)\n registerToolCategory(readCategoryOf(target))\n}\n\n/* ── One answer of a query (DetailRead) ───────────────────────────────────────────────────────────────────── */\n\nfunction argSchema(arg: DetailArg): any {\n const type = arg.type === 'number' ? 'number' : arg.type === 'integer' ? 'integer' : arg.type === 'boolean' ? 'boolean' : 'string'\n const said = [arg.description, arg.type === 'date' ? 'YYYY-MM-DD' : undefined, arg.type === 'enum' ? `one of: ${arg.values!.join(', ')}` : undefined].filter(Boolean).join('. ')\n return { type, ...(said ? { description: said } : {}) }\n}\n\n/**\n * What running a detail read as the person gave - the root field's value, or why there is none. Shared by the tool,\n * which hands the value to the model, and by every other reader of a detail read (a dashboard card, ADR-0160\n * decision 2), which has its own limits: the arguments, the door and the query are one, the size rule is the tool's.\n */\nexport interface DetailRun {\n /** The root field's value - absent when `error` says why. */\n value?: unknown\n error?: 'argument-unreadable' | 'query-failed' | 'not-found'\n refused?: { name: string; code: string }[]\n message?: string\n}\n\n/** Runs the query as the person with the arguments given - read by their declared types, a missing required one refused. */\nexport async function runDetail(target: DetailRead, args: any, run: GraphqlRunner): Promise<DetailRun> {\n const variables: Record<string, unknown> = {}\n const refused: { name: string; code: string }[] = []\n for (const arg of target.args ?? []) {\n const value = args?.[arg.name]\n if (value === undefined || value === null || value === '') {\n if (arg.required) refused.push({ name: arg.name, code: 'required' })\n continue\n }\n const { read, code } = readFieldValue({ name: arg.name, type: arg.type === 'string' ? 'text' : arg.type, values: arg.values, axis: arg.axis } as any, value)\n if (read === undefined) refused.push({ name: arg.name, code: code ?? 'unreadable' })\n else variables[arg.name] = read\n }\n if (refused.length) return { error: 'argument-unreadable', refused }\n let answer\n try {\n answer = await run(target.query, variables)\n } catch (error: any) {\n return { error: 'query-failed', message: String(error?.message ?? error) }\n }\n if (answer.errors?.length) return { error: 'query-failed', message: answer.errors.map(one => one.message).join('; ') }\n const root = rootFieldOf(target.query, 'query').replace(/^Query\\./, '')\n const value = answer.data?.[root]\n if (value === null || value === undefined) return { error: 'not-found' }\n return { value }\n}\n\n/** Runs the query as the person with the arguments the model set; the answer as the query returned it. */\nexport async function queryDetail(target: DetailRead, args: any, run: GraphqlRunner) {\n const ran = await runDetail(target, args, run)\n if (ran.error) {\n if (ran.error === 'argument-unreadable')\n return { rejected: true, error: 'argument-unreadable', refused: ran.refused, message: `these arguments are missing or do not fit their type: ${ran.refused.map(one => `${one.name} (${one.code})`).join(', ')}. Fix them and call again.` }\n if (ran.error === 'query-failed') return { rejected: true, error: 'query-failed', message: `it could not be read: ${ran.message}` }\n return { target: target.key, found: false, message: 'nothing was found for these arguments - say so; do not fill it in.' }\n }\n const value = ran.value\n const size = JSON.stringify(value).length\n if (size > MAX_DETAIL_CHARS) return { rejected: true, error: 'answer-too-large', size, message: `the answer runs to ${size} characters, more than ${MAX_DETAIL_CHARS} - narrow the arguments, or read the list it is made of.` }\n return { target: target.key, answer: value, message: 'answer from these fields; every number you say comes from them. Amounts are in the currency beside them - never add two currencies into one number.' }\n}\n\nexport function detailCategoryOf(target: DetailRead, run: (context: any) => GraphqlRunner = runAsCaller): ToolCategory {\n const door = rootFieldOf(target.query, 'query')\n const name = detailToolName(target.key)\n return {\n name: readCategoryName(target.key),\n description: `data read: ${target.key}`,\n guidance: `- To answer about ${target.description.replace(/\\.$/, '')}, call ${name}. Every number you say comes from its answer.`,\n specs: [\n {\n kind: 'read',\n name,\n /* The person must be able to run the query on its screen - the tool is not a second way in. */\n doors: [door],\n description: `Read ${target.description}`,\n schema: {\n type: 'object',\n ...((target.args ?? []).some(one => one.required) ? { required: (target.args ?? []).filter(one => one.required).map(one => one.name) } : {}),\n properties: Object.fromEntries((target.args ?? []).map(arg => [arg.name, argSchema(arg)]))\n },\n builder: (args: any, context: any) => queryDetail(target, args, run(context))\n } as ToolSpec\n ]\n }\n}\n\n/** What an application calls at boot to let the assistant read one answer of its API. A mode opens it by key in `readTargets`. */\nexport function registerDetailRead(target: DetailRead): void {\n declareDetailRead(target)\n registerToolCategory(detailCategoryOf(target))\n}\n"]}
|
|
@@ -11,6 +11,7 @@ import './chat-session/session-purge.js';
|
|
|
11
11
|
import './chat-session/attachment-route.js';
|
|
12
12
|
import { EntryProposalResolver } from './data-entry/entry-resolver.js';
|
|
13
13
|
import './workspace/workspace-tools.js';
|
|
14
|
+
import './people/index.js';
|
|
14
15
|
export * from './types.js';
|
|
15
16
|
export * from './chat-session-resolver.js';
|
|
16
17
|
export * from './assistant-chat-resolver.js';
|
|
@@ -22,8 +23,9 @@ export * from './data-entry/entry-target.js';
|
|
|
22
23
|
export { registerEntryTarget, entryCategoryOf, runAsCaller } from './data-entry/entry-tools.js';
|
|
23
24
|
export { proposeChanges, MAX_CHANGES } from './data-entry/entry-update.js';
|
|
24
25
|
export * from './data-read/read-target.js';
|
|
25
|
-
export { registerReadTarget, readCategoryOf, registerDetailRead, detailCategoryOf } from './data-read/read-tools.js';
|
|
26
|
+
export { registerReadTarget, readCategoryOf, registerDetailRead, detailCategoryOf, runDetail, type DetailRun } from './data-read/read-tools.js';
|
|
26
27
|
export * from './data-read/list-read.js';
|
|
28
|
+
export * from './people/index.js';
|
|
27
29
|
export * from './workspace/workspace-blocks.js';
|
|
28
30
|
export * from './grounding-sources.js';
|
|
29
31
|
export * from './chat-session/session-anchor.js';
|
|
@@ -45,6 +47,8 @@ export * from './chat-session-participant/mention-invite.js';
|
|
|
45
47
|
export * from './chat-session-participant/presence.js';
|
|
46
48
|
export * from './chat-message/index.js';
|
|
47
49
|
export * from './chat-session-participant/index.js';
|
|
50
|
+
export { PROPOSAL_OUTCOME_PREFIX } from './chat-message/proposal-outcome.js';
|
|
51
|
+
export { assertMayWriteSession } from './chat-session/session-write-gate.js';
|
|
48
52
|
export * from './unattended-run/index.js';
|
|
49
53
|
export declare const entities: (typeof import("./chat-message/chat-message.js").ChatMessage | typeof import("./chat-session/chat-session.js").ChatSession | typeof import("./chat-session-participant/chat-session-participant.js").ChatSessionParticipant | typeof import("./unattended-run/assistant-run.js").AssistantRun)[];
|
|
50
54
|
export declare const schema: {
|