@genesislcap/ai-assistant 15.49.0 → 15.50.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 +100 -2
- package/dist/dts/genesis/config.d.ts +31 -0
- package/dist/dts/genesis/config.d.ts.map +1 -1
- package/dist/dts/genesis/consumes.d.ts.map +1 -1
- package/dist/dts/genesis/index.d.ts +2 -2
- package/dist/dts/genesis/index.d.ts.map +1 -1
- package/dist/dts/genesis/reference-check.d.ts +4 -3
- package/dist/dts/genesis/reference-check.d.ts.map +1 -1
- package/dist/dts/genesis/reference-existence.d.ts +3 -3
- package/dist/dts/genesis/reference-existence.d.ts.map +1 -1
- package/dist/dts/genesis/review-model.d.ts +59 -4
- package/dist/dts/genesis/review-model.d.ts.map +1 -1
- package/dist/dts/genesis/types.d.ts +43 -0
- package/dist/dts/genesis/types.d.ts.map +1 -1
- package/dist/dts/genesis/write-commit.d.ts +2 -2
- package/dist/dts/genesis/write-commit.d.ts.map +1 -1
- package/dist/dts/genesis/write-op.d.ts +34 -0
- package/dist/dts/genesis/write-op.d.ts.map +1 -0
- package/dist/dts/genesis/write-outcome.d.ts +2 -2
- package/dist/dts/genesis/write-outcome.d.ts.map +1 -1
- package/dist/dts/genesis/write-payload.d.ts +3 -3
- package/dist/dts/genesis/write-payload.d.ts.map +1 -1
- package/dist/dts/genesis/write-plan.d.ts +18 -7
- package/dist/dts/genesis/write-plan.d.ts.map +1 -1
- package/dist/dts/genesis/write-review/write-review.d.ts +6 -0
- package/dist/dts/genesis/write-review/write-review.d.ts.map +1 -1
- package/dist/dts/genesis/write-review/write-review.styles.d.ts.map +1 -1
- package/dist/dts/genesis/write-review/write-review.template.d.ts.map +1 -1
- package/dist/dts/genesis/write-tools.d.ts +2 -2
- package/dist/dts/genesis/write-tools.d.ts.map +1 -1
- package/dist/dts/genesis/write-turn.d.ts +5 -3
- package/dist/dts/genesis/write-turn.d.ts.map +1 -1
- package/dist/esm/genesis/config.js +204 -5
- package/dist/esm/genesis/consumes.js +5 -0
- package/dist/esm/genesis/index.js +1 -1
- package/dist/esm/genesis/review-model.js +62 -10
- package/dist/esm/genesis/write-op.js +18 -0
- package/dist/esm/genesis/write-outcome.js +13 -6
- package/dist/esm/genesis/write-payload.js +22 -10
- package/dist/esm/genesis/write-plan.js +121 -12
- package/dist/esm/genesis/write-review/write-review.js +20 -1
- package/dist/esm/genesis/write-review/write-review.styles.js +14 -0
- package/dist/esm/genesis/write-review/write-review.template.js +25 -7
- package/dist/esm/genesis/write-tools.js +304 -74
- package/dist/esm/genesis/write-turn.js +9 -5
- package/dist/genesis-consumes.cjs +6 -1
- package/dist/genesis-consumes.cjs.map +2 -2
- package/dist/genesis-consumes.mjs +6 -1
- package/dist/genesis-consumes.mjs.map +2 -2
- package/docs/genesis.md +171 -45
- package/package.json +17 -17
- package/scripts/smoke-genesis-consumes-node.mjs +14 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-op.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-op.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,UAAU,GAAG,SAAS,KAAG,OACK,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,IAAI,UAAU,GAAG,SAAS,KAAG,MACO,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnyWriteOp } from './write-op';
|
|
2
2
|
/**
|
|
3
3
|
* What happened to one row, read from the platform's own reply.
|
|
4
4
|
*
|
|
@@ -97,7 +97,7 @@ export type WriteReplyMode = 'commit' | 'validate';
|
|
|
97
97
|
*/
|
|
98
98
|
export interface WriteReplyOptions {
|
|
99
99
|
mode: WriteReplyMode;
|
|
100
|
-
op:
|
|
100
|
+
op: AnyWriteOp;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Reads one commit or `VALIDATE` reply into an outcome.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-outcome.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-outcome.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"write-outcome.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-outcome.ts"],"names":[],"mappings":"AAQA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,kBAAkB,GAC1B,SAAS;AACX;;;;GAIG;GACD,SAAS;AACX,0EAA0E;GACxE,iBAAiB;AACnB,+EAA+E;GAC7E,gBAAgB;AAClB,6CAA6C;GAC3C,WAAW;AACb,4FAA4F;GAC1F,MAAM;AACR,kDAAkD;GAChD,gBAAgB;AAClB;;;;GAIG;GACD,aAAa;AACf,wFAAwF;GACtF,QAAQ;AACV;;;;;GAKG;GACD,SAAS,CAAC;AAEd,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,kBAAkB,CAAC;IAC3B;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,gFAAgF;IAChF,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3C,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAsID;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnD;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,UAAU,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,iBAAiB,GAC9B,mBAAmB,CAgNrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,OAAO,CAAC,kBAAkB,EAAE,QAAQ,GAAG,iBAAiB,CAAC,EACjE,SAAS,MAAM,EACf,SAAS,KAAK,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,KAC/C,mBAKD,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,mBAIpD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GenesisEventField } from './event-fields';
|
|
2
2
|
import { type UncheckedField } from './reference-check';
|
|
3
|
-
import type
|
|
3
|
+
import { type AnyWriteOp } from './write-op';
|
|
4
4
|
/**
|
|
5
5
|
* Turns one row of model-supplied values into the `DETAILS` payload an event takes.
|
|
6
6
|
*
|
|
@@ -86,7 +86,7 @@ export declare const PLATFORM_MAINTAINED: Set<string>;
|
|
|
86
86
|
/** @internal */
|
|
87
87
|
export interface BuildPayloadOptions {
|
|
88
88
|
/** The resource's op. Decides whether a read-only field may travel; see above. */
|
|
89
|
-
op?:
|
|
89
|
+
op?: AnyWriteOp;
|
|
90
90
|
/**
|
|
91
91
|
* The row as it stands now, for a modify or delete — the same pre-image the review shows and
|
|
92
92
|
* the staleness check compares against.
|
|
@@ -122,7 +122,7 @@ export interface BuildPayloadOptions {
|
|
|
122
122
|
*
|
|
123
123
|
* @internal
|
|
124
124
|
*/
|
|
125
|
-
export declare const sendableFields: (fields: readonly GenesisEventField[], op:
|
|
125
|
+
export declare const sendableFields: (fields: readonly GenesisEventField[], op: AnyWriteOp | undefined) => GenesisEventField[];
|
|
126
126
|
/**
|
|
127
127
|
* Whether text shows nothing at all. One test for the payload builder and the review, so what the
|
|
128
128
|
* review calls empty is exactly what the builder treats as a blank.
|
|
@@ -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;AACxD,OAAO,EAAoC,KAAK,cAAc,EAAE,MAAM,mBAAmB,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;AAG1F,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AA+FnD;;;;;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,UAAU,CAAC;IAChB;;;;;;;;;;;;;;;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,UAAU,GAAG,SAAS,KACzB,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;AAmItE,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,CAwLf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GenesisEventField } from './event-fields';
|
|
2
2
|
import type { UncheckedField } from './reference-check';
|
|
3
3
|
import type { GenesisRowSource } from './row-source';
|
|
4
|
-
import type
|
|
4
|
+
import { type AnyWriteOp } from './write-op';
|
|
5
5
|
/**
|
|
6
6
|
* The two data phases either side of the review: what the user is asked to approve, and whether
|
|
7
7
|
* it is still true when they do.
|
|
@@ -16,8 +16,9 @@ export interface PlannedRow {
|
|
|
16
16
|
/** Position in the model's own list, carried through the review and into the outcome. */
|
|
17
17
|
index: number;
|
|
18
18
|
/**
|
|
19
|
-
* What found this row
|
|
20
|
-
*
|
|
19
|
+
* What found this row. Without a declared key it is also what finds the row again at approve
|
|
20
|
+
* time; with one, the row is found again by that key as the row held it (see
|
|
21
|
+
* {@link stillCurrent}).
|
|
21
22
|
*/
|
|
22
23
|
key?: Record<string, unknown>;
|
|
23
24
|
/**
|
|
@@ -37,12 +38,20 @@ export interface PlannedRow {
|
|
|
37
38
|
}
|
|
38
39
|
/** @internal */
|
|
39
40
|
export interface PlanOptions {
|
|
40
|
-
op:
|
|
41
|
+
op: AnyWriteOp;
|
|
41
42
|
fields: readonly GenesisEventField[];
|
|
42
43
|
/** Required for a modify or a delete; an insert has no row to read. */
|
|
43
44
|
source?: GenesisRowSource;
|
|
44
45
|
/** Fields whose reference cannot be checked; see `BuildPayloadOptions.unchecked`. Required. */
|
|
45
46
|
unchecked: ReadonlyMap<string, UncheckedField>;
|
|
47
|
+
/**
|
|
48
|
+
* The declared key: a row action's primary-key fields, which its handler looks its row up by, or
|
|
49
|
+
* a modify's or a delete's when the config gives one. Required for a row action, which is refused
|
|
50
|
+
* without them. On a modify or a delete the model's key must hold every one, and is cut to them.
|
|
51
|
+
*/
|
|
52
|
+
keyFields?: readonly string[];
|
|
53
|
+
/** A row action's declared inputs, by field name: every one must be sent. Row actions only. */
|
|
54
|
+
inputs?: readonly string[];
|
|
46
55
|
}
|
|
47
56
|
/**
|
|
48
57
|
* A batch a person can actually read before approving it.
|
|
@@ -54,7 +63,7 @@ export interface PlanOptions {
|
|
|
54
63
|
*/
|
|
55
64
|
export declare const MAX_WRITE_ROWS = 25;
|
|
56
65
|
/**
|
|
57
|
-
* Builds what the review will show, reading the current row for every modify and
|
|
66
|
+
* Builds what the review will show, reading the current row for every modify, delete and row action.
|
|
58
67
|
*
|
|
59
68
|
* @remarks
|
|
60
69
|
* Reads run together — they are reads, and a batch of 25 sequential round trips is a visibly
|
|
@@ -62,7 +71,7 @@ export declare const MAX_WRITE_ROWS = 25;
|
|
|
62
71
|
*
|
|
63
72
|
* @internal
|
|
64
73
|
*/
|
|
65
|
-
export declare function planWrite(rows: unknown, { op, fields, source, unchecked }: PlanOptions): Promise<{
|
|
74
|
+
export declare function planWrite(rows: unknown, { op, fields, source, unchecked, keyFields, inputs }: PlanOptions): Promise<{
|
|
66
75
|
status: 'ok';
|
|
67
76
|
rows: PlannedRow[];
|
|
68
77
|
} | {
|
|
@@ -108,8 +117,10 @@ export type RowStillCurrent = {
|
|
|
108
117
|
*
|
|
109
118
|
* @internal
|
|
110
119
|
*/
|
|
111
|
-
export declare function stillCurrent(row: PlannedRow, { source, fields }: {
|
|
120
|
+
export declare function stillCurrent(row: PlannedRow, { source, fields, keyFields, }: {
|
|
112
121
|
source: GenesisRowSource;
|
|
113
122
|
fields: readonly GenesisEventField[];
|
|
123
|
+
/** A row action's own key: it is found again by the row's values for these, not the model's. */
|
|
124
|
+
keyFields?: readonly string[];
|
|
114
125
|
}): Promise<RowStillCurrent>;
|
|
115
126
|
//# sourceMappingURL=write-plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-plan.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write-plan.d.ts","sourceRoot":"","sources":["../../../src/genesis/write-plan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAQ/D;;;;;;;;GAQG;AAEH,gGAAgG;AAChG,MAAM,WAAW,UAAU;IACzB,yFAAyF;IACzF,KAAK,EAAE,MA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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,EACE,MAAM,EACN,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrC,gGAAgG;IAChG,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B,GACA,OAAO,CAAC,eAAe,CAAC,CAsC1B"}
|
|
@@ -62,6 +62,12 @@ export declare class GenesisWriteReview extends GenesisElement {
|
|
|
62
62
|
* summary's live region would announce it as though code had run.
|
|
63
63
|
*/
|
|
64
64
|
get customCodeLine(): string;
|
|
65
|
+
/** A row action's header, or `''` for any other write: see `rowActionHeading`. */
|
|
66
|
+
get rowActionHeading(): string;
|
|
67
|
+
/** The table's accessible name. A run's names its handler and table, as its header does. */
|
|
68
|
+
get tableLabel(): string;
|
|
69
|
+
/** The lines under a row action's header, from the model, so a re-mount says them too. */
|
|
70
|
+
get rowActionLines(): string[];
|
|
65
71
|
/**
|
|
66
72
|
* Set when this element sends its answer. The host marks the review resolved after that, and
|
|
67
73
|
* until it did, a second click sent a second answer — a Deny straight after a Write included.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-review.d.ts","sourceRoot":"","sources":["../../../../src/genesis/write-review/write-review.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAc,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"write-review.d.ts","sourceRoot":"","sources":["../../../../src/genesis/write-review/write-review.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAc,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAUL,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,mBAAmB,CAAC;AAK3B;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAiE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,kBAAmB,SAAQ,cAAc;IACpD,yDAAyD;IACzD,aAAa,SAAM;IAEnB,6FAA6F;IACjF,WAAW,EAAG,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAE/E,gGAAgG;IACpF,QAAQ,EAAE,MAAM,EAAE,CAAsB;IAEpD,6DAA6D;IACjD,MAAM,UAAS;IAC3B,mCAAmC;IACvB,UAAU,SAAM;IAE5B,6FAA6F;IACjF,YAAY,SAAM;IAE9B,iEAAiE;IACjE,OAAO,CAAC,WAAW,CAAC,CAAW;IAE/B;;;;OAIG;IACH,OAAO,CAAC,UAAU,CAAC,CAAW;;IAmB9B;;;;OAIG;IACH,IAAI,KAAK,IAAI,WAAW,GAAG,SAAS,CAEnC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;;;OAKG;IACH,IAAI,cAAc,IAAI,MAAM,CAG3B;IAED,kFAAkF;IAClF,IAAI,gBAAgB,IAAI,MAAM,CAG7B;IAED,4FAA4F;IAC5F,IAAI,UAAU,IAAI,MAAM,CAKvB;IAED,0FAA0F;IAC1F,IAAI,cAAc,IAAI,MAAM,EAAE,CAG7B;IAED;;;OAGG;IACS,OAAO,CAAC,QAAQ,CAAS;IAErC;;;OAGG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB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AO,CAAC,SAAS;CAOlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-review.styles.d.ts","sourceRoot":"","sources":["../../../../src/genesis/write-review/write-review.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"write-review.styles.d.ts","sourceRoot":"","sources":["../../../../src/genesis/write-review/write-review.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,iDAuP7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-review.template.d.ts","sourceRoot":"","sources":["../../../../src/genesis/write-review/write-review.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAQ,MAAM,uBAAuB,CAAC;AAIzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"write-review.template.d.ts","sourceRoot":"","sources":["../../../../src/genesis/write-review/write-review.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAQ,MAAM,uBAAuB,CAAC;AAIzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AA6KzD,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,kBAAkB,CA8HhE,CAAC"}
|
|
@@ -10,11 +10,11 @@ import type { GenesisWriteStatus } from './write-outcome';
|
|
|
10
10
|
* The shape of this handler is the whole safety argument, so it is worth stating in order:
|
|
11
11
|
*
|
|
12
12
|
* 1. the model's arguments become payloads, each built against the event's own metadata and, for
|
|
13
|
-
* a modify or a
|
|
13
|
+
* a modify or a run, merged over the row as it currently stands;
|
|
14
14
|
* 2. those payload objects are rendered in the review, by reference;
|
|
15
15
|
* 3. the user selects rows, and the review resolves with their INDEXES — never rows, so nothing
|
|
16
16
|
* that comes back could be a rebuilt or cloned payload;
|
|
17
|
-
* 4. each selected modify or
|
|
17
|
+
* 4. each selected modify, delete or run is re-read and compared with what the review showed;
|
|
18
18
|
* 5. what survives is committed, and the objects committed are the objects from step 2.
|
|
19
19
|
*
|
|
20
20
|
* At no point is a payload re-derived from the model's original arguments. That is the gap the
|
|
@@ -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;AA4BzE,OAAO,EAAE,mBAAmB,EAAyB,MAAM,kBAAkB,CAAC;AAa9E,OAAO,EAAqB,KAAK,iBAAiB,EAA0B,MAAM,SAAS,CAAC;AAG5F,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,EAAE,OAAO,mBAAmB,CAAC;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,QAAQ,EAAE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AAC,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;AAq9Bb;;;;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,CAmPA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GenesisEventField } from './event-fields';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyWriteOp } from './write-op';
|
|
3
3
|
import type { PlannedRow } from './write-plan';
|
|
4
4
|
/**
|
|
5
5
|
* What a write tool remembers for the rest of a TURN — the answer to one user message — about each
|
|
@@ -59,11 +59,13 @@ export type Proposal = readonly ProposalRow[];
|
|
|
59
59
|
* @remarks
|
|
60
60
|
* A modify's payload is the whole merged row, so it also carries every column it leaves alone,
|
|
61
61
|
* as read. Compared whole, a column somebody else changed between two reviews made a resent
|
|
62
|
-
* proposal look new. Only the fields that differ from the row as read are kept.
|
|
62
|
+
* proposal look new. Only the fields that differ from the row as read are kept. A run's payload
|
|
63
|
+
* is the whole row too, and what the model proposes in it is its inputs, so those are kept.
|
|
63
64
|
*
|
|
65
|
+
* @param inputs - A row action's declared inputs, by field name.
|
|
64
66
|
* @internal
|
|
65
67
|
*/
|
|
66
|
-
export declare function proposalOf(op:
|
|
68
|
+
export declare function proposalOf(op: AnyWriteOp, rows: readonly PlannedRow[], fields: readonly GenesisEventField[], inputs?: readonly string[]): Proposal;
|
|
67
69
|
/**
|
|
68
70
|
* Whether two proposals would put the same thing in front of the user.
|
|
69
71
|
*
|
|
@@ -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;
|
|
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;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,uEAAuE;IACvE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C,0EAA0E;IAC1E,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C;;;OAGG;IACH,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,sFAAsF;IACtF,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED,mFAAmF;AACnF,MAAM,MAAM,QAAQ,GAAG,SAAS,WAAW,EAAE,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,SAAS,UAAU,EAAE,EAC3B,MAAM,EAAE,SAAS,iBAAiB,EAAE,EACpC,MAAM,GAAE,SAAS,MAAM,EAAO,GAC7B,QAAQ,CAiBV;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,6 +1,7 @@
|
|
|
1
1
|
import { AI_TIER_IDS, AI_TIER_VENDORS } from '@genesislcap/foundation-ai';
|
|
2
2
|
import { logger } from '../utils/logger';
|
|
3
3
|
import { GENESIS_EVENT_OPS, } from './types';
|
|
4
|
+
import { PLATFORM_MAINTAINED } from './write-payload';
|
|
4
5
|
/** The default read cap, and the ceiling the config may raise it to. */
|
|
5
6
|
export const DEFAULT_MAX_ROWS = 50;
|
|
6
7
|
export const MAX_ROWS_CEILING = 1000;
|
|
@@ -167,6 +168,165 @@ export function referencesProblems(resource, op = resource === null || resource
|
|
|
167
168
|
});
|
|
168
169
|
return problems;
|
|
169
170
|
}
|
|
171
|
+
/** Table and field names as the generator writes them. */
|
|
172
|
+
const ROW_NAME = /^[A-Z0-9_]+$/;
|
|
173
|
+
/** What only a custom event's row action may carry. `entity` is not one of them: see its doc. */
|
|
174
|
+
const ROW_ONLY_FIELDS = ['shape', 'inputs', 'effects'];
|
|
175
|
+
/** The ops besides a row action whose row a declared `key` may name: a modify and a delete. */
|
|
176
|
+
const KEY_OPS = ['modify', 'delete'];
|
|
177
|
+
/**
|
|
178
|
+
* What is wrong with a declared key: at least one field, each a field name, none twice, and none
|
|
179
|
+
* the platform maintains. The same rule for a row action, a modify and a delete. Collects the
|
|
180
|
+
* fields it accepted into `accepted`, when given.
|
|
181
|
+
*/
|
|
182
|
+
function keyProblems(key, accepted = new Set()) {
|
|
183
|
+
if (!Array.isArray(key) || !key.length)
|
|
184
|
+
return ['key must name at least one field'];
|
|
185
|
+
const problems = [];
|
|
186
|
+
for (const field of key) {
|
|
187
|
+
if (typeof field !== 'string' || !ROW_NAME.test(field)) {
|
|
188
|
+
problems.push(`key holds ${shown(field)}, not a field name`);
|
|
189
|
+
}
|
|
190
|
+
else if (accepted.has(field)) {
|
|
191
|
+
problems.push(`key names ${field} twice`);
|
|
192
|
+
}
|
|
193
|
+
else if (PLATFORM_MAINTAINED.has(field)) {
|
|
194
|
+
problems.push(`key names ${field}, which the platform maintains`);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
accepted.add(field);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return problems;
|
|
201
|
+
}
|
|
202
|
+
const INPUT_KEYS = ['field', 'required'];
|
|
203
|
+
const EFFECT_KEYS = ['op', 'table'];
|
|
204
|
+
const EFFECT_OPS = ['modify', 'insert'];
|
|
205
|
+
const shown = (value) => typeof value === 'string' ? `'${value}'` : value === null ? 'null' : typeof value;
|
|
206
|
+
/**
|
|
207
|
+
* Why a request a row action needs is not readable, from what the caller knows about it: in the
|
|
208
|
+
* config with no read tool, in the config but left out, or a query. Failing all three it is missing.
|
|
209
|
+
* The validator and the write tools say it the same way, through this.
|
|
210
|
+
*
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
export const notReadableReason = ({ unreadable = new Set(), leftOut = new Set(), queries = new Set(), }) => (name) => {
|
|
214
|
+
if (unreadable.has(name))
|
|
215
|
+
return `${name} has no read tool, as its maxRows is not a number`;
|
|
216
|
+
if (leftOut.has(name))
|
|
217
|
+
return `${name} is in the AI config but was left out`;
|
|
218
|
+
if (queries.has(name)) {
|
|
219
|
+
return `${name} is a query in the AI config, and a query is never a row source`;
|
|
220
|
+
}
|
|
221
|
+
return `the AI config has no request resource ${name}`;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* What is wrong with a resource's row-action fields (contracts C-18.7.2), if anything.
|
|
225
|
+
*
|
|
226
|
+
* @remarks
|
|
227
|
+
* One rule, three callers: the validator, and the write tools when a tool is defined and when it
|
|
228
|
+
* is called, because the write tools are exported and a direct call never reaches the validator.
|
|
229
|
+
*
|
|
230
|
+
* A custom event with no `shape` has no problem here: the write tools refuse it, as they refuse
|
|
231
|
+
* every custom event that is not a row action. A later change of meaning has to arrive as a new
|
|
232
|
+
* `shape` value, never as a new key on an old one, so a key this version has no place for is a
|
|
233
|
+
* problem rather than something to skip.
|
|
234
|
+
*
|
|
235
|
+
* @param requestNames - The request resources whose rows can be read. A row action reads its rows
|
|
236
|
+
* through `REQ_<entity>`, and without one there is no row to review.
|
|
237
|
+
* @param whyNotReadable - Why a request is not among `requestNames`, when the caller knows: it was
|
|
238
|
+
* left out, has no read tool, or is a query. Without it, the request is said to be missing.
|
|
239
|
+
* @beta
|
|
240
|
+
*/
|
|
241
|
+
export function rowActionProblem(resource, requestNames, whyNotReadable = notReadableReason({})) {
|
|
242
|
+
const fields = (resource !== null && resource !== void 0 ? resource : {});
|
|
243
|
+
if (fields.op !== 'custom') {
|
|
244
|
+
const carried = ROW_ONLY_FIELDS.filter((field) => fields[field] !== undefined);
|
|
245
|
+
const problems = carried.length
|
|
246
|
+
? [
|
|
247
|
+
`${carried.join(', ')} ${carried.length > 1 ? 'apply' : 'applies'} to a custom event's ` +
|
|
248
|
+
'row action only',
|
|
249
|
+
]
|
|
250
|
+
: [];
|
|
251
|
+
// A modify or a delete may name its row by the table's key (contracts C-19); held to a row
|
|
252
|
+
// action's key rule. Anywhere else a key names nothing.
|
|
253
|
+
if (fields.key !== undefined) {
|
|
254
|
+
problems.push(...(KEY_OPS.includes(fields.op)
|
|
255
|
+
? keyProblems(fields.key)
|
|
256
|
+
: ["key applies to a custom event's row action, a modify or a delete only"]));
|
|
257
|
+
}
|
|
258
|
+
return problems.length ? problems.join('; ') : undefined;
|
|
259
|
+
}
|
|
260
|
+
const { shape, entity, key, inputs, effects } = fields;
|
|
261
|
+
if (shape === undefined)
|
|
262
|
+
return undefined;
|
|
263
|
+
if (shape !== 'row') {
|
|
264
|
+
return `shape ${shown(shape)} is not one this version of the assistant runs (row)`;
|
|
265
|
+
}
|
|
266
|
+
const problems = [];
|
|
267
|
+
const table = typeof entity === 'string' && ROW_NAME.test(entity) ? entity : undefined;
|
|
268
|
+
if (!table)
|
|
269
|
+
problems.push(`entity must be a table name (got ${shown(entity)})`);
|
|
270
|
+
const keyFields = new Set();
|
|
271
|
+
problems.push(...keyProblems(key, keyFields));
|
|
272
|
+
if (!Array.isArray(inputs)) {
|
|
273
|
+
problems.push('inputs must be a list');
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
inputs.forEach((input, i) => {
|
|
277
|
+
const at = `inputs[${i}]`;
|
|
278
|
+
if (!isObject(input)) {
|
|
279
|
+
problems.push(`${at} must be an object`);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const stray = Object.keys(input).filter((name) => !INPUT_KEYS.includes(name));
|
|
283
|
+
if (stray.length)
|
|
284
|
+
problems.push(`${at} has keys it does not read (${stray.join(', ')})`);
|
|
285
|
+
if (typeof input.field !== 'string' || !ROW_NAME.test(input.field)) {
|
|
286
|
+
problems.push(`${at}.field must be a field name`);
|
|
287
|
+
}
|
|
288
|
+
else if (keyFields.has(input.field)) {
|
|
289
|
+
problems.push(`${input.field} is both a key and an input`);
|
|
290
|
+
}
|
|
291
|
+
if (input.required !== true)
|
|
292
|
+
problems.push(`${at}.required must be true`);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if (!Array.isArray(effects) || !effects.length) {
|
|
296
|
+
problems.push('effects must list at least one write');
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
let modifies = 0;
|
|
300
|
+
effects.forEach((effect, i) => {
|
|
301
|
+
const at = `effects[${i}]`;
|
|
302
|
+
if (!isObject(effect)) {
|
|
303
|
+
problems.push(`${at} must be an object`);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const stray = Object.keys(effect).filter((name) => !EFFECT_KEYS.includes(name));
|
|
307
|
+
if (stray.length)
|
|
308
|
+
problems.push(`${at} has keys it does not read (${stray.join(', ')})`);
|
|
309
|
+
if (!EFFECT_OPS.includes(effect.op))
|
|
310
|
+
problems.push(`${at}.op must be modify or insert`);
|
|
311
|
+
if (typeof effect.table !== 'string' || !ROW_NAME.test(effect.table)) {
|
|
312
|
+
problems.push(`${at}.table must be a table name`);
|
|
313
|
+
}
|
|
314
|
+
if (effect.op === 'modify') {
|
|
315
|
+
modifies += 1;
|
|
316
|
+
if (table && effect.table !== table) {
|
|
317
|
+
problems.push(`${at} modifies ${shown(effect.table)}, not its own table ${table}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
if (modifies !== 1) {
|
|
322
|
+
problems.push(`effects must hold exactly one modify of its own table, not ${modifies}`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (table && !requestNames.has(`REQ_${table}`)) {
|
|
326
|
+
problems.push(`its rows are not readable: ${whyNotReadable(`REQ_${table}`)}`);
|
|
327
|
+
}
|
|
328
|
+
return problems.length ? problems.join('; ') : undefined;
|
|
329
|
+
}
|
|
170
330
|
/**
|
|
171
331
|
* Checks a generated AI config before anything is registered, and says what can be kept.
|
|
172
332
|
*
|
|
@@ -188,7 +348,7 @@ export function referencesProblems(resource, op = resource === null || resource
|
|
|
188
348
|
* @beta
|
|
189
349
|
*/
|
|
190
350
|
export function validateGenesisAiConfig(config) {
|
|
191
|
-
var _a;
|
|
351
|
+
var _a, _b;
|
|
192
352
|
if (!config || typeof config !== 'object') {
|
|
193
353
|
return {
|
|
194
354
|
problems: ['the AI config is missing or not an object'],
|
|
@@ -240,13 +400,35 @@ export function validateGenesisAiConfig(config) {
|
|
|
240
400
|
if (typeof name === 'string')
|
|
241
401
|
copies.set(name, ((_a = copies.get(name)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
242
402
|
}
|
|
403
|
+
// The requests that will be kept, known before any row action is judged against them, so where
|
|
404
|
+
// a row action sits in the list cannot decide whether its rows are readable. Only a request: a
|
|
405
|
+
// query named REQ_<T> is never a row source. A request's own judgement never needs this set.
|
|
406
|
+
const requestNames = new Set();
|
|
407
|
+
// And why any other one is not: so a row action is told its REQ_ was left out, or is a query,
|
|
408
|
+
// rather than that the config has none.
|
|
409
|
+
const leftOut = new Set();
|
|
410
|
+
const queries = new Set();
|
|
411
|
+
for (const resource of c.resources) {
|
|
412
|
+
const name = resource === null || resource === void 0 ? void 0 : resource.name;
|
|
413
|
+
if (typeof name !== 'string')
|
|
414
|
+
continue;
|
|
415
|
+
if ((resource === null || resource === void 0 ? void 0 : resource.kind) === 'query')
|
|
416
|
+
queries.add(name);
|
|
417
|
+
if ((resource === null || resource === void 0 ? void 0 : resource.kind) !== 'request')
|
|
418
|
+
continue;
|
|
419
|
+
if (resourceProblems(resource, (_b = copies.get(name)) !== null && _b !== void 0 ? _b : 0, new Set()).length)
|
|
420
|
+
leftOut.add(name);
|
|
421
|
+
else
|
|
422
|
+
requestNames.add(name);
|
|
423
|
+
}
|
|
424
|
+
const whyNotReadable = notReadableReason({ leftOut, queries });
|
|
243
425
|
const resources = [];
|
|
244
426
|
const dropped = [];
|
|
245
427
|
const warnings = [];
|
|
246
428
|
c.resources.forEach((resource, i) => {
|
|
247
429
|
var _a;
|
|
248
430
|
const name = typeof (resource === null || resource === void 0 ? void 0 : resource.name) === 'string' ? resource.name : undefined;
|
|
249
|
-
const wrong = resourceProblems(resource, (_a = copies.get(name !== null && name !== void 0 ? name : '')) !== null && _a !== void 0 ? _a : 0);
|
|
431
|
+
const wrong = resourceProblems(resource, (_a = copies.get(name !== null && name !== void 0 ? name : '')) !== null && _a !== void 0 ? _a : 0, requestNames, whyNotReadable);
|
|
250
432
|
if (wrong.length) {
|
|
251
433
|
dropped.push({ at: `resources[${i}]`, name, problems: wrong });
|
|
252
434
|
return;
|
|
@@ -342,17 +524,31 @@ export function customCodeOf(resource) {
|
|
|
342
524
|
* which is when GENESIS_AI_CONSUMES has to name it.
|
|
343
525
|
*/
|
|
344
526
|
function keptCopy(resource, customCode) {
|
|
345
|
-
|
|
527
|
+
var _a, _b, _c;
|
|
528
|
+
return Object.assign(Object.assign(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
529
|
? {
|
|
347
530
|
references: resource.references.map(({ resource: target, fields }) => ({
|
|
348
531
|
resource: target,
|
|
349
532
|
fields: fields.map(({ field, targetField }) => ({ field, targetField })),
|
|
350
533
|
})),
|
|
351
534
|
}
|
|
535
|
+
: {})), ((resource.op === 'modify' || resource.op === 'delete') && resource.key !== undefined
|
|
536
|
+
? { key: [...resource.key] }
|
|
537
|
+
: {})), (resource.op === 'custom' && resource.shape === 'row'
|
|
538
|
+
? {
|
|
539
|
+
shape: resource.shape,
|
|
540
|
+
entity: resource.entity,
|
|
541
|
+
key: [...((_a = resource.key) !== null && _a !== void 0 ? _a : [])],
|
|
542
|
+
inputs: ((_b = resource.inputs) !== null && _b !== void 0 ? _b : []).map(({ field, required }) => ({ field, required })),
|
|
543
|
+
effects: ((_c = resource.effects) !== null && _c !== void 0 ? _c : []).map(({ op, table }) => ({ op, table })),
|
|
544
|
+
}
|
|
352
545
|
: {}));
|
|
353
546
|
}
|
|
354
|
-
/**
|
|
355
|
-
|
|
547
|
+
/**
|
|
548
|
+
* What is wrong with one resource, if anything. `copies` is how many entries share its name, and
|
|
549
|
+
* `requestNames` the requests that will be kept, which a row action reads its rows through.
|
|
550
|
+
*/
|
|
551
|
+
function resourceProblems(resource, copies, requestNames, whyNotReadable) {
|
|
356
552
|
// A kind this version does not know is judged on nothing else: its name need not look like
|
|
357
553
|
// anything here, and it is left out either way.
|
|
358
554
|
const kind = resource === null || resource === void 0 ? void 0 : resource.kind;
|
|
@@ -405,5 +601,8 @@ function resourceProblems(resource, copies) {
|
|
|
405
601
|
}
|
|
406
602
|
}
|
|
407
603
|
problems.push(...referencesProblems(resource));
|
|
604
|
+
const rowAction = rowActionProblem(resource, requestNames, whyNotReadable);
|
|
605
|
+
if (rowAction)
|
|
606
|
+
problems.push(rowAction);
|
|
408
607
|
return problems;
|
|
409
608
|
}
|
|
@@ -32,6 +32,11 @@ export const GENESIS_AI_CONSUMES = Object.freeze({
|
|
|
32
32
|
'maxRows',
|
|
33
33
|
'customCode',
|
|
34
34
|
'references',
|
|
35
|
+
'shape',
|
|
36
|
+
'entity',
|
|
37
|
+
'key',
|
|
38
|
+
'inputs',
|
|
39
|
+
'effects',
|
|
35
40
|
]),
|
|
36
41
|
vendors: Object.freeze(['anthropic', 'gemini']),
|
|
37
42
|
tiers: Object.freeze(['low', 'high', 'reasoning']),
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @beta
|
|
12
12
|
*/
|
|
13
13
|
export { GENESIS_AGENT_NAME, registerGenesisAssistant } from './register-genesis-assistant';
|
|
14
|
-
export { customCodeOf } from './config';
|
|
14
|
+
export { customCodeOf, rowActionProblem } from './config';
|
|
15
15
|
export { GENESIS_AI_CONSUMES } from './consumes';
|
|
16
16
|
export { validateGenesisAiConfig } from './config';
|
|
17
17
|
export { createGenesisResourceTools, GENESIS_DATA_SOURCE } from './resource-tools';
|