@genesislcap/ai-assistant 15.46.5 → 15.47.0
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/dist/custom-elements.json +426 -214
- package/dist/dts/genesis/config.d.ts +30 -6
- package/dist/dts/genesis/config.d.ts.map +1 -1
- package/dist/dts/genesis/consumes.d.ts.map +1 -1
- package/dist/dts/genesis/event-fields.d.ts.map +1 -1
- package/dist/dts/genesis/filter-fields.d.ts +31 -0
- package/dist/dts/genesis/filter-fields.d.ts.map +1 -1
- package/dist/dts/genesis/index.d.ts +3 -1
- package/dist/dts/genesis/index.d.ts.map +1 -1
- package/dist/dts/genesis/reference-check.d.ts +83 -0
- package/dist/dts/genesis/reference-check.d.ts.map +1 -0
- package/dist/dts/genesis/reference-existence.d.ts +110 -0
- package/dist/dts/genesis/reference-existence.d.ts.map +1 -0
- package/dist/dts/genesis/resource-tools.d.ts +4 -4
- package/dist/dts/genesis/resource-tools.d.ts.map +1 -1
- package/dist/dts/genesis/review-model.d.ts +2 -2
- package/dist/dts/genesis/review-model.d.ts.map +1 -1
- package/dist/dts/genesis/row-source.d.ts +32 -0
- package/dist/dts/genesis/row-source.d.ts.map +1 -1
- package/dist/dts/genesis/server-text.d.ts +29 -0
- package/dist/dts/genesis/server-text.d.ts.map +1 -1
- package/dist/dts/genesis/types.d.ts +32 -5
- package/dist/dts/genesis/types.d.ts.map +1 -1
- package/dist/dts/genesis/write-payload.d.ts +14 -1
- package/dist/dts/genesis/write-payload.d.ts.map +1 -1
- package/dist/dts/genesis/write-plan.d.ts +8 -2
- package/dist/dts/genesis/write-plan.d.ts.map +1 -1
- package/dist/dts/genesis/write-tools.d.ts +5 -3
- package/dist/dts/genesis/write-tools.d.ts.map +1 -1
- package/dist/dts/genesis/write-turn.d.ts +4 -1
- package/dist/dts/genesis/write-turn.d.ts.map +1 -1
- package/dist/esm/genesis/config.js +152 -20
- package/dist/esm/genesis/consumes.js +2 -1
- package/dist/esm/genesis/event-fields.js +5 -8
- package/dist/esm/genesis/filter-fields.js +159 -78
- package/dist/esm/genesis/index.js +1 -0
- package/dist/esm/genesis/reference-check.js +132 -0
- package/dist/esm/genesis/reference-existence.js +283 -0
- package/dist/esm/genesis/resource-tools.js +135 -18
- package/dist/esm/genesis/review-model.js +3 -1
- package/dist/esm/genesis/row-source.js +107 -16
- package/dist/esm/genesis/server-text.js +52 -0
- package/dist/esm/genesis/write-payload.js +32 -4
- package/dist/esm/genesis/write-plan.js +3 -2
- package/dist/esm/genesis/write-tools.js +248 -44
- package/dist/genesis-consumes.cjs +3 -2
- package/dist/genesis-consumes.cjs.map +2 -2
- package/dist/genesis-consumes.mjs +3 -2
- package/dist/genesis-consumes.mjs.map +2 -2
- package/docs/genesis.md +131 -21
- package/package.json +17 -17
- package/scripts/smoke-genesis-consumes-node.mjs +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/genesis/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAErF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/genesis/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,O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AC,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,wBAAwB,CAAC;IACpC;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GenesisEventField } from './event-fields';
|
|
2
|
+
import { type UncheckedField } from './reference-check';
|
|
2
3
|
import type { GenesisEventOp } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Turns one row of model-supplied values into the `DETAILS` payload an event takes.
|
|
@@ -61,6 +62,12 @@ export declare const isCarryOnly: (field: Pick<GenesisEventField, "type">) => bo
|
|
|
61
62
|
* @internal
|
|
62
63
|
*/
|
|
63
64
|
export declare const isWholeNumberType: (type: string | undefined) => boolean;
|
|
65
|
+
/**
|
|
66
|
+
* A value echoed into one of our sentences: bounded, and without the quote that delimits it.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare const quoted: (raw: unknown) => string;
|
|
64
71
|
/**
|
|
65
72
|
* Builds one event payload from a row the model supplied.
|
|
66
73
|
*
|
|
@@ -97,6 +104,12 @@ export interface BuildPayloadOptions {
|
|
|
97
104
|
* would be a model inventing them.
|
|
98
105
|
*/
|
|
99
106
|
preImage?: Record<string, unknown>;
|
|
107
|
+
/**
|
|
108
|
+
* Fields whose reference cannot be checked (contracts C-17.8). An insert refuses a value for one;
|
|
109
|
+
* a modify keeps the row's, and refuses any value but that one or a blank. Required: no default
|
|
110
|
+
* may offer what cannot be checked.
|
|
111
|
+
*/
|
|
112
|
+
unchecked: ReadonlyMap<string, UncheckedField>;
|
|
100
113
|
}
|
|
101
114
|
/**
|
|
102
115
|
* The fields this op may put on the wire: what the event declares, minus the platform's own
|
|
@@ -125,5 +138,5 @@ export declare const isBlankText: (text: string) => boolean;
|
|
|
125
138
|
* @internal
|
|
126
139
|
*/
|
|
127
140
|
export declare const isBlankEntry: (value: unknown) => boolean;
|
|
128
|
-
export declare function buildEventPayload(fields: readonly GenesisEventField[], row: unknown, { op, preImage }
|
|
141
|
+
export declare function buildEventPayload(fields: readonly GenesisEventField[], row: unknown, { op, preImage, unchecked }: BuildPayloadOptions): PayloadResult;
|
|
129
142
|
//# sourceMappingURL=write-payload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-payload.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-payload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"write-payload.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-payload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAoC,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAClD;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAa/C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,KAAG,OACnB,CAAC;AAoFnD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,OACd,CAAC;AAkDhD;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,OAAO,KAAG,MAMrC,CAAC;AA4IF;;;;GAIG;AACH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,aAAsC,CAAC;AAwBvE,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,EAAE,CAAC,EAAE,cAAc,CAAC;IACpB;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;OAIG;IACH,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,SAAS,iBAAiB,EAAE,EACpC,IAAI,cAAc,GAAG,SAAS,KAC7B,iBAAiB,EAGjB,CAAC;AAiFJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,OAAgC,CAAC;AAE5E;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,OACuB,CAAC;AA6HtE,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,iBAAiB,EAAE,EACpC,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAC/C,aAAa,CAsLf"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GenesisEventField } from './event-fields';
|
|
2
|
+
import type { UncheckedField } from './reference-check';
|
|
2
3
|
import type { GenesisRowSource } from './row-source';
|
|
3
4
|
import type { GenesisEventOp } from './types';
|
|
4
5
|
/**
|
|
@@ -19,7 +20,10 @@ export interface PlannedRow {
|
|
|
19
20
|
* a re-read by anything else would be re-reading a different question.
|
|
20
21
|
*/
|
|
21
22
|
key?: Record<string, unknown>;
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The payload, frozen, when one could be built. A row refused over a reference keeps it: `problems`
|
|
25
|
+
* alone decides whether a row is written.
|
|
26
|
+
*/
|
|
23
27
|
details?: Record<string, unknown>;
|
|
24
28
|
/** The row as it stood when the review was built — what the user was shown as "now". */
|
|
25
29
|
preImage?: Record<string, unknown>;
|
|
@@ -37,6 +41,8 @@ export interface PlanOptions {
|
|
|
37
41
|
fields: readonly GenesisEventField[];
|
|
38
42
|
/** Required for a modify or a delete; an insert has no row to read. */
|
|
39
43
|
source?: GenesisRowSource;
|
|
44
|
+
/** Fields whose reference cannot be checked; see `BuildPayloadOptions.unchecked`. Required. */
|
|
45
|
+
unchecked: ReadonlyMap<string, UncheckedField>;
|
|
40
46
|
}
|
|
41
47
|
/**
|
|
42
48
|
* A batch a person can actually read before approving it.
|
|
@@ -56,7 +62,7 @@ export declare const MAX_WRITE_ROWS = 25;
|
|
|
56
62
|
*
|
|
57
63
|
* @internal
|
|
58
64
|
*/
|
|
59
|
-
export declare function planWrite(rows: unknown, { op, fields, source }: PlanOptions): Promise<{
|
|
65
|
+
export declare function planWrite(rows: unknown, { op, fields, source, unchecked }: PlanOptions): Promise<{
|
|
60
66
|
status: 'ok';
|
|
61
67
|
rows: PlannedRow[];
|
|
62
68
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-plan.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAS9C;;;;;;;;GAQG;AAEH,gGAAgG;AAChG,MAAM,WAAW,UAAU;IACzB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,GAAG,CAAC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EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,WAAW,GAC7C,OAAO,CAAC;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAqNxF;AAsBD;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE;AACvB,mGAAmG;GACjG;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,GACvC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;AACpB,+FAA+F;GAC7F;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,UAAU,EACf,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAAE,GACrF,OAAO,CAAC,eAAe,CAAC,CAmB1B"}
|
|
@@ -31,7 +31,9 @@ export type GenesisWriteRowStatus = GenesisWriteStatus
|
|
|
31
31
|
* Approved, and never sent: the user stopped the turn before its turn to be written came.
|
|
32
32
|
* Not `failed`, which says the app could not be reached or the row was refused first.
|
|
33
33
|
*/
|
|
34
|
-
| 'stopped'
|
|
34
|
+
| 'stopped'
|
|
35
|
+
/** A reference it sets no longer named a row when it was written. Nothing was sent. */
|
|
36
|
+
| 'reference_gone';
|
|
35
37
|
/**
|
|
36
38
|
* What the user decided in a write review.
|
|
37
39
|
*
|
|
@@ -166,8 +168,8 @@ export declare function createGenesisWriteTools(resources: readonly GenesisAiRes
|
|
|
166
168
|
toolHandlers: ChatToolHandlers;
|
|
167
169
|
/**
|
|
168
170
|
* The events that can get a write tool, as far as the config can tell: an event refused for its
|
|
169
|
-
* op
|
|
170
|
-
* metadata, read when the tools are first listed, can still withhold one.
|
|
171
|
+
* op, its rowSources entry or a malformed references, or a modify or delete with no row source,
|
|
172
|
+
* is not among them. Their metadata, read when the tools are first listed, can still withhold one.
|
|
171
173
|
*/
|
|
172
174
|
writableEvents: readonly string[];
|
|
173
175
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-tools.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"write-tools.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,+BAA+B,CAAC;AA0BzE,OAAO,EAAE,mBAAmB,EAAyB,MAAM,kBAAkB,CAAC;AAa9E,OAAO,EAEL,KAAK,iBAAiB,EAGvB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAwB1D;;;;;;;;;;;;;;;;;GAiBG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,qBAAqB,GAC7B,kBAAkB;AACpB,oDAAoD;GAClD,cAAc;AAChB,4EAA4E;GAC1E,sBAAsB;AACxB;;;GAGG;GACD,SAAS;AACX,uFAAuF;GACrF,gBAAgB,CAAC;AAErB;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,QAAQ,GAAG,mBAAmB,GAAG,WAAW,CAAC;AAE7F;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM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AC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3F;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,MAGvB,CAAC;AA0wBb;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,iBAAiB,EAAE,EACvC,OAAO,GAAE,wBAA6B,GACrC;IACD,eAAe,EAAE,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACrD,YAAY,EAAE,gBAAgB,CAAC;IAC/B;;;;OAIG;IACH,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CA0OA"}
|
|
@@ -43,7 +43,10 @@ export interface ProposalRow {
|
|
|
43
43
|
target: Readonly<Record<string, unknown>>;
|
|
44
44
|
/** What the row would write. For a modify, only the fields it changes. */
|
|
45
45
|
change: Readonly<Record<string, unknown>>;
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Why the row was refused: `problems` alone decides refusal. A row refused over a reference keeps
|
|
48
|
+
* its frozen payload, so these are what tell two refusals apart.
|
|
49
|
+
*/
|
|
47
50
|
problems: readonly string[];
|
|
48
51
|
/** What the row's outcome would also say, such as a blank kept as the row's value. */
|
|
49
52
|
notes: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-turn.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-turn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC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mFAAmF;AACnF,MAAM,MAAM,QAAQ,GAAG,SAAS,WAAW,EAAE,CAAC;AAE9C;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,EAAE,EAAE,cAAc,EAClB,IAAI,EAAE,SAAS,UAAU,EAAE,EAC3B,MAAM,EAAE,SAAS,iBAAiB,EAAE,GACnC,QAAQ,CAeV;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC1B,CAAC,EAAE,QAAQ,EACX,CAAC,EAAE,QAAQ,EACX,MAAM,EAAE,SAAS,iBAAiB,EAAE,GACnC,OAAO,CAuBT;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,gBAAgB;AAChB,MAAM,WAAW,UAAU;IACzB,qFAAqF;IACrF,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAC;IACpE;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5E;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1E;AASD,gBAAgB;AAChB,wBAAgB,gBAAgB,IAAI,UAAU,CAuC7C"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AI_TIER_IDS, AI_TIER_VENDORS } from '@genesislcap/foundation-ai';
|
|
2
|
+
import { logger } from '../utils/logger';
|
|
2
3
|
import { GENESIS_EVENT_OPS, } from './types';
|
|
3
4
|
/** The default read cap, and the ceiling the config may raise it to. */
|
|
4
5
|
export const DEFAULT_MAX_ROWS = 50;
|
|
5
6
|
export const MAX_ROWS_CEILING = 1000;
|
|
6
7
|
/**
|
|
7
|
-
* Whether a request's `maxRows` can be read as a cap: absent, so the default applies,
|
|
8
|
-
* number, which is clamped into range.
|
|
8
|
+
* Whether a request's or a query's `maxRows` can be read as a cap: absent, so the default applies,
|
|
9
|
+
* or a finite number, which is clamped into range.
|
|
9
10
|
*
|
|
10
11
|
* @remarks
|
|
11
|
-
* Anything else declares SOME cap, and none can be read from it, so the
|
|
12
|
+
* Anything else declares SOME cap, and none can be read from it, so the resource gets no read tool.
|
|
12
13
|
* Having none, it is no row source for a write either: a modify reading through it would answer
|
|
13
14
|
* "no row matches that key" about a table the model cannot read. One test for both factories, so
|
|
14
15
|
* they cannot disagree about which requests the assistant reads. The validator is stricter (a
|
|
@@ -22,13 +23,53 @@ export const capIsReadable = (resource) => {
|
|
|
22
23
|
};
|
|
23
24
|
/** Tool names are the lowercased resource name; vendors reject names over 64 characters. */
|
|
24
25
|
const MAX_TOOL_NAME_LENGTH = 64;
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* What a resource's name must look like, by its kind. The kind decides, never the name: a query's
|
|
28
|
+
* name is the dataserver's own, and one called `REQ_…` is still a query. A query's name is upper
|
|
29
|
+
* case so that lowercasing it into a tool name stays one to one.
|
|
30
|
+
*/
|
|
31
|
+
const NAME_RULES = {
|
|
32
|
+
request: { pattern: /^REQ_[A-Z0-9_]+$/, described: "a request's name must look like REQ_<NAME>" },
|
|
33
|
+
event: {
|
|
34
|
+
pattern: /^EVENT_[A-Z0-9_]+$/,
|
|
35
|
+
described: "an event's name must look like EVENT_<NAME>",
|
|
36
|
+
},
|
|
37
|
+
query: {
|
|
38
|
+
pattern: /^[A-Z][A-Z0-9_]*$/,
|
|
39
|
+
described: "a query's name must be upper-case letters, digits and underscores",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
26
42
|
/**
|
|
27
43
|
* The model-facing tool name for a resource. Deterministic and collision-free (resource names
|
|
28
44
|
* are unique), and trivially mapped back to the resource in a debug log. What the tool is FOR
|
|
29
45
|
* reaches the model through its description, not its name.
|
|
30
46
|
*/
|
|
31
47
|
export const toolNameOf = (resourceName) => resourceName.toLowerCase();
|
|
48
|
+
/**
|
|
49
|
+
* The resources whose tool name no earlier one in the list already has.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* The tool factories are exported and skip the config validator, and they key handlers by tool
|
|
53
|
+
* name, so two resources that lowercase to one name used to overwrite each other there without a
|
|
54
|
+
* word. The first is kept, and each later one is left out with a warning naming both.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export function firstPerToolName(resources) {
|
|
59
|
+
const kept = new Map();
|
|
60
|
+
for (const resource of resources) {
|
|
61
|
+
const tool = toolNameOf(resource.name);
|
|
62
|
+
const first = kept.get(tool);
|
|
63
|
+
if (first) {
|
|
64
|
+
logger.warn(`Genesis assistant: left out ${resource.name}: ${first.name} already has its tool name, ` +
|
|
65
|
+
`${tool}.`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
kept.set(tool, resource);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return [...kept.values()];
|
|
72
|
+
}
|
|
32
73
|
/**
|
|
33
74
|
* The op a resource's NAME declares, when it declares one.
|
|
34
75
|
*
|
|
@@ -49,7 +90,83 @@ export const opFromName = (resourceName) => {
|
|
|
49
90
|
return suffix ? suffix.toLowerCase() : undefined;
|
|
50
91
|
};
|
|
51
92
|
/** The kinds of resource the validator accepts. Kept apart from GENESIS_AI_CONSUMES on purpose. */
|
|
52
|
-
const KNOWN_KINDS = ['request', 'event'];
|
|
93
|
+
const KNOWN_KINDS = ['request', 'event', 'query'];
|
|
94
|
+
/** What a reference's resource and field names look like (contracts C-17.2). */
|
|
95
|
+
const REFERENCE_RESOURCE = /^REQ_[A-Z0-9_]+$/;
|
|
96
|
+
const REFERENCE_NAME = /^[A-Z0-9_]+$/;
|
|
97
|
+
const REFERENCE_KEYS = ['resource', 'fields'];
|
|
98
|
+
const REFERENCE_MEMBER_KEYS = ['field', 'targetField'];
|
|
99
|
+
const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
100
|
+
/**
|
|
101
|
+
* What is wrong with a resource's declared `references`, if anything. The validator and the write
|
|
102
|
+
* tools' own rules both use it, because the write tools are exported and a direct call never
|
|
103
|
+
* reaches the validator.
|
|
104
|
+
*
|
|
105
|
+
* @param op - the op the write is judged by: the declared one for the validator, the decided one
|
|
106
|
+
* for the write tools, which take an op from the name as well.
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export function referencesProblems(resource, op = resource === null || resource === void 0 ? void 0 : resource.op) {
|
|
110
|
+
const references = resource === null || resource === void 0 ? void 0 : resource.references;
|
|
111
|
+
if (references === undefined)
|
|
112
|
+
return [];
|
|
113
|
+
if ((resource === null || resource === void 0 ? void 0 : resource.kind) !== 'event' || (op !== 'insert' && op !== 'modify')) {
|
|
114
|
+
return ['references apply to an insert or a modify event only'];
|
|
115
|
+
}
|
|
116
|
+
if (!Array.isArray(references))
|
|
117
|
+
return ['references must be a list'];
|
|
118
|
+
const problems = [];
|
|
119
|
+
const fields = new Set();
|
|
120
|
+
references.forEach((group, i) => {
|
|
121
|
+
const at = `references[${i}]`;
|
|
122
|
+
if (!isObject(group)) {
|
|
123
|
+
problems.push(`${at} must be an object`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const unknownKeys = Object.keys(group).filter((key) => !REFERENCE_KEYS.includes(key));
|
|
127
|
+
if (unknownKeys.length)
|
|
128
|
+
problems.push(`${at} has keys it does not read (${unknownKeys.join(', ')})`);
|
|
129
|
+
if (typeof group.resource !== 'string' || !REFERENCE_RESOURCE.test(group.resource)) {
|
|
130
|
+
problems.push(`${at}.resource must look like REQ_<NAME> (got ${String(group.resource)})`);
|
|
131
|
+
}
|
|
132
|
+
if (!Array.isArray(group.fields) || !group.fields.length) {
|
|
133
|
+
problems.push(`${at}.fields must be a list of at least one field`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const targets = new Set();
|
|
137
|
+
group.fields.forEach((member, j) => {
|
|
138
|
+
const where = `${at}.fields[${j}]`;
|
|
139
|
+
if (!isObject(member)) {
|
|
140
|
+
problems.push(`${where} must be an object`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const unknownMemberKeys = Object.keys(member).filter((key) => !REFERENCE_MEMBER_KEYS.includes(key));
|
|
144
|
+
if (unknownMemberKeys.length) {
|
|
145
|
+
problems.push(`${where} has keys it does not read (${unknownMemberKeys.join(', ')})`);
|
|
146
|
+
}
|
|
147
|
+
const { field, targetField } = member;
|
|
148
|
+
if (typeof field !== 'string' || !REFERENCE_NAME.test(field)) {
|
|
149
|
+
problems.push(`${where}.field must be upper-case letters, digits and underscores`);
|
|
150
|
+
}
|
|
151
|
+
else if (fields.has(field)) {
|
|
152
|
+
problems.push(`${field} is in more than one reference`);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
fields.add(field);
|
|
156
|
+
}
|
|
157
|
+
if (typeof targetField !== 'string' || !REFERENCE_NAME.test(targetField)) {
|
|
158
|
+
problems.push(`${where}.targetField must be upper-case letters, digits and underscores`);
|
|
159
|
+
}
|
|
160
|
+
else if (targets.has(targetField)) {
|
|
161
|
+
problems.push(`${at} names ${targetField} as a target field twice`);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
targets.add(targetField);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
return problems;
|
|
169
|
+
}
|
|
53
170
|
/**
|
|
54
171
|
* Checks a generated AI config before anything is registered, and says what can be kept.
|
|
55
172
|
*
|
|
@@ -65,7 +182,10 @@ const KNOWN_KINDS = ['request', 'event'];
|
|
|
65
182
|
*
|
|
66
183
|
* Leaving out a kind it does not know is survival, not support: the resource does nothing here.
|
|
67
184
|
*
|
|
68
|
-
*
|
|
185
|
+
* Exported so a generator's tests, or an app's seed, can check a config against the rules of the
|
|
186
|
+
* assistant version it installs.
|
|
187
|
+
*
|
|
188
|
+
* @beta
|
|
69
189
|
*/
|
|
70
190
|
export function validateGenesisAiConfig(config) {
|
|
71
191
|
var _a;
|
|
@@ -222,21 +342,36 @@ export function customCodeOf(resource) {
|
|
|
222
342
|
* which is when GENESIS_AI_CONSUMES has to name it.
|
|
223
343
|
*/
|
|
224
344
|
function keptCopy(resource, customCode) {
|
|
225
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({ name: resource.name, kind: resource.kind }, (resource.op !== undefined ? { op: resource.op } : {})), { context: resource.context }), (resource.maxRows !== undefined ? { maxRows: resource.maxRows } : {})), (customCode ? { customCode } : {}))
|
|
345
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name: resource.name, kind: resource.kind }, (resource.op !== undefined ? { op: resource.op } : {})), { context: resource.context }), (resource.maxRows !== undefined ? { maxRows: resource.maxRows } : {})), (customCode ? { customCode } : {})), (resource.references !== undefined
|
|
346
|
+
? {
|
|
347
|
+
references: resource.references.map(({ resource: target, fields }) => ({
|
|
348
|
+
resource: target,
|
|
349
|
+
fields: fields.map(({ field, targetField }) => ({ field, targetField })),
|
|
350
|
+
})),
|
|
351
|
+
}
|
|
352
|
+
: {}));
|
|
226
353
|
}
|
|
227
354
|
/** What is wrong with one resource, if anything. `copies` is how many entries share its name. */
|
|
228
355
|
function resourceProblems(resource, copies) {
|
|
229
356
|
// A kind this version does not know is judged on nothing else: its name need not look like
|
|
230
|
-
// anything here
|
|
357
|
+
// anything here, and it is left out either way.
|
|
231
358
|
const kind = resource === null || resource === void 0 ? void 0 : resource.kind;
|
|
232
|
-
if (typeof kind
|
|
359
|
+
if (typeof kind !== 'string') {
|
|
233
360
|
return [
|
|
234
|
-
|
|
361
|
+
`${kind === undefined ? 'kind is missing' : 'kind is not text'}; it must be one of ` +
|
|
362
|
+
KNOWN_KINDS.join(', '),
|
|
235
363
|
];
|
|
236
364
|
}
|
|
365
|
+
if (!KNOWN_KINDS.includes(kind)) {
|
|
366
|
+
return [
|
|
367
|
+
`kind '${String(kind)}' is not one this version of the assistant reads ` +
|
|
368
|
+
`(${KNOWN_KINDS.join(', ')})`,
|
|
369
|
+
];
|
|
370
|
+
}
|
|
371
|
+
const rule = NAME_RULES[kind];
|
|
237
372
|
const name = resource === null || resource === void 0 ? void 0 : resource.name;
|
|
238
|
-
if (typeof name !== 'string' || !
|
|
239
|
-
return [
|
|
373
|
+
if (typeof name !== 'string' || !rule.pattern.test(name)) {
|
|
374
|
+
return [`${rule.described} (got ${String(name)})`];
|
|
240
375
|
}
|
|
241
376
|
const problems = [];
|
|
242
377
|
if (toolNameOf(name).length > MAX_TOOL_NAME_LENGTH) {
|
|
@@ -245,24 +380,20 @@ function resourceProblems(resource, copies) {
|
|
|
245
380
|
if (copies > 1) {
|
|
246
381
|
problems.push(`appears ${copies} times, and which one is meant is unknown`);
|
|
247
382
|
}
|
|
248
|
-
const expectedKind = name.startsWith('REQ_') ? 'request' : 'event';
|
|
249
|
-
if (kind !== expectedKind) {
|
|
250
|
-
problems.push(`kind must be '${expectedKind}' (got ${String(kind)})`);
|
|
251
|
-
}
|
|
252
383
|
if (typeof resource.context !== 'string')
|
|
253
384
|
problems.push('context must be a string');
|
|
254
|
-
if (
|
|
385
|
+
if (kind === 'event') {
|
|
255
386
|
if (!GENESIS_EVENT_OPS.includes(resource.op)) {
|
|
256
387
|
problems.push(`op must be one of ${GENESIS_EVENT_OPS.join(', ')}`);
|
|
257
388
|
}
|
|
258
|
-
//
|
|
259
|
-
//
|
|
389
|
+
// A name and a declared op that disagree are a generator bug, and not a cosmetic one: see
|
|
390
|
+
// opFromName.
|
|
260
391
|
const declared = opFromName(name);
|
|
261
392
|
if (declared && resource.op !== declared) {
|
|
262
393
|
problems.push(`op must be '${declared}' to match its name (got ${String(resource.op)})`);
|
|
263
394
|
}
|
|
264
395
|
if (resource.maxRows !== undefined)
|
|
265
|
-
problems.push('maxRows applies to requests only');
|
|
396
|
+
problems.push('maxRows applies to requests and queries only');
|
|
266
397
|
}
|
|
267
398
|
else {
|
|
268
399
|
if (resource.op !== undefined)
|
|
@@ -273,5 +404,6 @@ function resourceProblems(resource, copies) {
|
|
|
273
404
|
problems.push(`maxRows must be a whole number from 1 to ${MAX_ROWS_CEILING}`);
|
|
274
405
|
}
|
|
275
406
|
}
|
|
407
|
+
problems.push(...referencesProblems(resource));
|
|
276
408
|
return problems;
|
|
277
409
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @beta
|
|
24
24
|
*/
|
|
25
25
|
export const GENESIS_AI_CONSUMES = Object.freeze({
|
|
26
|
-
kinds: Object.freeze(['request', 'event']),
|
|
26
|
+
kinds: Object.freeze(['request', 'event', 'query']),
|
|
27
27
|
resourceFields: Object.freeze([
|
|
28
28
|
'name',
|
|
29
29
|
'kind',
|
|
@@ -31,6 +31,7 @@ export const GENESIS_AI_CONSUMES = Object.freeze({
|
|
|
31
31
|
'context',
|
|
32
32
|
'maxRows',
|
|
33
33
|
'customCode',
|
|
34
|
+
'references',
|
|
34
35
|
]),
|
|
35
36
|
vendors: Object.freeze(['anthropic', 'gemini']),
|
|
36
37
|
tiers: Object.freeze(['low', 'high', 'reasoning']),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { logger } from '../utils/logger';
|
|
3
3
|
import { withTimeout } from '../utils/with-timeout';
|
|
4
|
-
import { allowedValuesOf, metadataNameOf } from './filter-fields';
|
|
4
|
+
import { allowedValuesOf, listOf, metadataNameOf } from './filter-fields';
|
|
5
|
+
import { metadataFailureOf } from './server-text';
|
|
5
6
|
import { genesisTypeName } from './type-name';
|
|
6
7
|
/**
|
|
7
8
|
* How a value travels when the reply does not say. Every live 8.15 `FIELD` entry carries
|
|
@@ -68,8 +69,8 @@ const titleOf = (detail) => {
|
|
|
68
69
|
const METADATA_TIMEOUT_MS = 20000;
|
|
69
70
|
/** @internal */
|
|
70
71
|
export function eventFieldsFrom(metadata) {
|
|
71
|
-
var _a
|
|
72
|
-
const details = (
|
|
72
|
+
var _a;
|
|
73
|
+
const details = listOf((_a = metadata.FIELD) !== null && _a !== void 0 ? _a : metadata.REQUEST_FIELD);
|
|
73
74
|
const named = details.filter((detail) => typeof (detail === null || detail === void 0 ? void 0 : detail.NAME) === 'string' && detail.NAME.length);
|
|
74
75
|
// Untyped, or typed as something this module cannot say how to send: either way the value
|
|
75
76
|
// would go out on a guess, so neither is writable.
|
|
@@ -111,11 +112,7 @@ export function loadEventFields(connect_1, resourceName_1) {
|
|
|
111
112
|
metadata = yield withTimeout(connect.getMetadata(metadataNameOf(resourceName)), timeoutMs);
|
|
112
113
|
}
|
|
113
114
|
catch (error) {
|
|
114
|
-
return {
|
|
115
|
-
status: 'failed',
|
|
116
|
-
reason: `the metadata request failed (${String(error)})`,
|
|
117
|
-
transient: true,
|
|
118
|
-
};
|
|
115
|
+
return { status: 'failed', reason: metadataFailureOf(error, resourceName), transient: true };
|
|
119
116
|
}
|
|
120
117
|
// Mirrors Connect's own rule for what it caches: a reply with any key. See `settled`.
|
|
121
118
|
const cached = !!metadata && typeof metadata === 'object' && Object.keys(metadata).length > 0;
|