@genesislcap/ai-assistant 15.43.0 → 15.44.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 +265 -206
- package/dist/dts/genesis/config.d.ts +28 -1
- 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 -1
- package/dist/dts/genesis/index.d.ts.map +1 -1
- package/dist/dts/genesis/register-genesis-assistant.d.ts.map +1 -1
- package/dist/dts/genesis/review-model.d.ts +22 -1
- package/dist/dts/genesis/review-model.d.ts.map +1 -1
- package/dist/dts/genesis/types.d.ts +32 -0
- package/dist/dts/genesis/types.d.ts.map +1 -1
- package/dist/dts/genesis/write-review/write-review.d.ts +7 -0
- package/dist/dts/genesis/write-review/write-review.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.map +1 -1
- package/dist/esm/genesis/config.js +108 -7
- package/dist/esm/genesis/consumes.js +8 -1
- package/dist/esm/genesis/index.js +1 -0
- package/dist/esm/genesis/register-genesis-assistant.js +7 -0
- package/dist/esm/genesis/review-model.js +37 -7
- package/dist/esm/genesis/write-review/write-review.js +11 -1
- package/dist/esm/genesis/write-review/write-review.template.js +9 -1
- package/dist/esm/genesis/write-tools.js +35 -11
- package/dist/genesis-consumes.cjs +8 -1
- package/dist/genesis-consumes.cjs.map +2 -2
- package/dist/genesis-consumes.mjs +8 -1
- package/dist/genesis-consumes.mjs.map +2 -2
- package/docs/genesis.md +49 -1
- package/package.json +18 -18
- package/scripts/smoke-genesis-consumes-node.mjs +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InteractionResult } from '@genesislcap/foundation-ai';
|
|
2
|
-
import type { GenesisEventOp } from './types';
|
|
2
|
+
import type { GenesisCustomCode, GenesisEventOp } from './types';
|
|
3
3
|
export type { GenesisChangeRequest, GenesisReviewPayload } from './review-payload';
|
|
4
4
|
/**
|
|
5
5
|
* What the review table shows, and the rules its buttons obey.
|
|
@@ -105,7 +105,26 @@ export interface ReviewModel {
|
|
|
105
105
|
rows: ReviewRow[];
|
|
106
106
|
/** Indexes a user may select: a row the bridge already refused is shown but not selectable. */
|
|
107
107
|
selectable: number[];
|
|
108
|
+
/**
|
|
109
|
+
* What the event's custom code can also write to, when it runs custom code. Kept on the model,
|
|
110
|
+
* which stays in history, so the line it becomes (see `customCodeLine`) survives a remount and
|
|
111
|
+
* the reload of a review that has already resolved.
|
|
112
|
+
*/
|
|
113
|
+
customCode?: GenesisCustomCode;
|
|
108
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The line a review shows when the event runs custom code: that the code can do more than the
|
|
117
|
+
* row shown, and what the generator found it can also write to.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* Every form says the code can do more than the values shown, because the row a coded handler
|
|
121
|
+
* saves is built in its code, not taken from the review. The named tables are a FLOOR, dated to
|
|
122
|
+
* when the app was generated (the app's code can change after), and end in "other records" unless
|
|
123
|
+
* the generator proved the list complete. The exact words are pinned by contracts C-18.D.4.
|
|
124
|
+
*
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export declare function customCodeLine(op: GenesisEventOp, customCode: GenesisCustomCode): string;
|
|
109
128
|
/**
|
|
110
129
|
* A value as a person should read it.
|
|
111
130
|
*
|
|
@@ -157,6 +176,8 @@ export declare function buildReviewModel(options: {
|
|
|
157
176
|
preImage?: Record<string, unknown>;
|
|
158
177
|
problems?: string[];
|
|
159
178
|
}>;
|
|
179
|
+
/** The event's customCode, as `customCodeOf` read it. */
|
|
180
|
+
customCode?: GenesisCustomCode;
|
|
160
181
|
}): ReviewModel;
|
|
161
182
|
/**
|
|
162
183
|
* The selection a freshly opened review starts with: none.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-model.d.ts","sourceRoot":"","sources":["../../../src/genesis/review-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"review-model.d.ts","sourceRoot":"","sources":["../../../src/genesis/review-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIjE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEnF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;;;OAQG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;CACf;AAuBD;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B,gBAAgB;AAChB,MAAM,WAAW,SAAS;IACxB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,gBAAgB;AAChB,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E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CAAC,EAAE,iBAAiB,CAAC;CAChC,GAAG,WAAW,CAoFd;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAAM,EAAQ,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,GAAG,SAAS,EAAE,QAAQ,OAAO,KAAG,MAAM,EAGlE,CAAC;AAEzB;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,WAAW,SAAS,MAAM,EAAE,KAAG,OAA+B,CAAC;AAExF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACxC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,GACtB;IAAE,QAAQ,EAAE,mBAAmB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GACrE;IAAE,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,SAAS,EAC9C,KAAK,CAAC,EAAE,WAAW,GAClB,cAAc,CAuBhB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,WAAW,EAClB,WAAW,WAAW,CAAC,MAAM,CAAC,KAC7B,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAGG,CAAC"}
|
|
@@ -38,6 +38,27 @@ export interface GenesisAiResource {
|
|
|
38
38
|
context: string;
|
|
39
39
|
/** Requests only: the most rows one read may return (1–1000). Defaults to 50. */
|
|
40
40
|
maxRows?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Insert, modify and delete events only: the event's handler runs custom code, which can write
|
|
43
|
+
* more than the row a review shows. See {@link GenesisCustomCode}.
|
|
44
|
+
*/
|
|
45
|
+
customCode?: GenesisCustomCode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* What the app generator found an event's custom code can write to, beyond the row it saves.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* A FLOOR, never the exact effects: the review tells the user the code "could also write to" these
|
|
52
|
+
* tables, and to other records too unless `listComplete` is true. Read through
|
|
53
|
+
* `customCodeOf`, which is the only reader of the field.
|
|
54
|
+
*
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
export interface GenesisCustomCode {
|
|
58
|
+
/** Tables other than the event's own that the code was proven to write to, in code order. */
|
|
59
|
+
alsoWrites: string[];
|
|
60
|
+
/** True only when the generator could prove those are ALL the other tables it writes to. */
|
|
61
|
+
listComplete: boolean;
|
|
41
62
|
}
|
|
42
63
|
/**
|
|
43
64
|
* What an assistant version reads from a generated AI config. See `GENESIS_AI_CONSUMES`.
|
|
@@ -54,6 +75,17 @@ export interface GenesisAiConsumes {
|
|
|
54
75
|
/** The `tier` values it accepts. Any other blocks the assistant. */
|
|
55
76
|
readonly tiers: readonly AITierId[];
|
|
56
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* What `customCodeOf` makes of a resource's `customCode`.
|
|
80
|
+
*
|
|
81
|
+
* @beta
|
|
82
|
+
*/
|
|
83
|
+
export interface GenesisCustomCodeCheck {
|
|
84
|
+
/** The field as it is used: absent when the resource has none, or none that applies. */
|
|
85
|
+
value?: GenesisCustomCode;
|
|
86
|
+
/** Why the field was dropped or read as malformed, for the console. */
|
|
87
|
+
warning?: string;
|
|
88
|
+
}
|
|
57
89
|
/**
|
|
58
90
|
* The AI block of a generated app's configuration (`client/src/ai/generated/ai-config.json`).
|
|
59
91
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/genesis/types.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,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,4BAA4B;IAC5B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,eAAe,CAAC;IACxB,mFAAmF;IACnF,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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"}
|
|
@@ -48,6 +48,13 @@ export declare class GenesisWriteReview extends GenesisElement {
|
|
|
48
48
|
*/
|
|
49
49
|
get model(): ReviewModel | undefined;
|
|
50
50
|
get resolved(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* What the review says about custom code the event runs, or `''` when it runs none. Read from
|
|
53
|
+
* the model, which history keeps, so it is there whether the review is open, resolved or
|
|
54
|
+
* re-mounted. Not repeated in the closed summary: the resolved review still shows it, and the
|
|
55
|
+
* summary's live region would announce it as though code had run.
|
|
56
|
+
*/
|
|
57
|
+
get customCodeLine(): string;
|
|
51
58
|
/**
|
|
52
59
|
* Set when this element sends its answer. The host marks the review resolved after that, and
|
|
53
60
|
* 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,EAML,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,mBAAmB,CAAC;AAK3B;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAyD3D;;;;;;;;;;;;;;;;;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,UA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AMjC;;;OAGG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED,oEAAoE;IACpE,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED;;;;;;OAMG;IACH,WAAW,IAAI,IAAI;IAanB;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAOlB"}
|
|
@@ -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;AA2JzD,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,kBAAkB,CAsGhE,CAAC"}
|
|
@@ -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;AAKzE,OAAO,EAAE,mBAAmB,EAAyB,MAAM,kBAAkB,CAAC;AAY9E,OAAO,
|
|
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;AAKzE,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eof config !== 'object') {
|
|
73
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
problems: ['the AI config is missing or not an object'],
|
|
75
|
+
resources: [],
|
|
76
|
+
dropped: [],
|
|
77
|
+
warnings: [],
|
|
78
|
+
};
|
|
74
79
|
}
|
|
75
80
|
const c = config;
|
|
76
81
|
const problems = [];
|
|
@@ -96,9 +101,14 @@ export function validateGenesisAiConfig(config) {
|
|
|
96
101
|
// registration logs a warning naming both causes. What that case needs is a signal, not a
|
|
97
102
|
// block.
|
|
98
103
|
if (c.resources === undefined)
|
|
99
|
-
return { problems, resources: [], dropped: [] };
|
|
104
|
+
return { problems, resources: [], dropped: [], warnings: [] };
|
|
100
105
|
if (!Array.isArray(c.resources)) {
|
|
101
|
-
return {
|
|
106
|
+
return {
|
|
107
|
+
problems: [...problems, 'resources must be an array'],
|
|
108
|
+
resources: [],
|
|
109
|
+
dropped: [],
|
|
110
|
+
warnings: [],
|
|
111
|
+
};
|
|
102
112
|
}
|
|
103
113
|
// Counted over every entry before any is judged: a duplicate leaves out EVERY copy. Which one
|
|
104
114
|
// the generator meant is unknown, and keeping the first would be a guess at it. Two tools with
|
|
@@ -112,16 +122,107 @@ export function validateGenesisAiConfig(config) {
|
|
|
112
122
|
}
|
|
113
123
|
const resources = [];
|
|
114
124
|
const dropped = [];
|
|
125
|
+
const warnings = [];
|
|
115
126
|
c.resources.forEach((resource, i) => {
|
|
116
127
|
var _a;
|
|
117
128
|
const name = typeof (resource === null || resource === void 0 ? void 0 : resource.name) === 'string' ? resource.name : undefined;
|
|
118
129
|
const wrong = resourceProblems(resource, (_a = copies.get(name !== null && name !== void 0 ? name : '')) !== null && _a !== void 0 ? _a : 0);
|
|
119
|
-
if (wrong.length)
|
|
130
|
+
if (wrong.length) {
|
|
120
131
|
dropped.push({ at: `resources[${i}]`, name, problems: wrong });
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const customCode = customCodeOf(resource);
|
|
135
|
+
if (customCode.warning)
|
|
136
|
+
warnings.push({ name, warning: customCode.warning });
|
|
137
|
+
resources.push(keptCopy(resource, customCode.value));
|
|
123
138
|
});
|
|
124
|
-
return { problems, resources, dropped };
|
|
139
|
+
return { problems, resources, dropped, warnings };
|
|
140
|
+
}
|
|
141
|
+
/** A table name as the generator writes one. */
|
|
142
|
+
const TABLE_NAME = /^[A-Z0-9_]+$/;
|
|
143
|
+
/** The keys `customCode` has, and every other is a sign it was not built by the generator. */
|
|
144
|
+
const CUSTOM_CODE_KEYS = ['alsoWrites', 'listComplete'];
|
|
145
|
+
/** The ops `customCode` applies to. */
|
|
146
|
+
const CRUD_OPS = ['insert', 'modify', 'delete'];
|
|
147
|
+
/**
|
|
148
|
+
* A resource's `customCode` as it is used: the one reader of the field.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Called by the validator AND by the write tools, because `createGenesisWriteTools` is exported
|
|
152
|
+
* and never validates: one rule, whichever way the resource arrives. It never throws and never
|
|
153
|
+
* drops the resource.
|
|
154
|
+
*
|
|
155
|
+
* - On anything but an insert, modify or delete event, the field has no meaning: it is dropped,
|
|
156
|
+
* with a warning, and the resource is kept.
|
|
157
|
+
* - Malformed — not an object, a key it has no place for, `alsoWrites` not a list, a member that
|
|
158
|
+
* is not a table name or is named twice, `listComplete` not true or false — keeps the valid
|
|
159
|
+
* names, in order, and reads `listComplete` as FALSE, with a warning. The review then says the
|
|
160
|
+
* code can also write to other records: over-disclosure is the safe end, and a malformed value
|
|
161
|
+
* must never read as a complete list.
|
|
162
|
+
*
|
|
163
|
+
* @beta
|
|
164
|
+
*/
|
|
165
|
+
export function customCodeOf(resource) {
|
|
166
|
+
var _a;
|
|
167
|
+
const given = resource.customCode;
|
|
168
|
+
if (given === undefined)
|
|
169
|
+
return {};
|
|
170
|
+
const op = (_a = resource.op) !== null && _a !== void 0 ? _a : opFromName(resource.name);
|
|
171
|
+
if (resource.kind !== 'event' || !CRUD_OPS.includes(op)) {
|
|
172
|
+
return {
|
|
173
|
+
warning: `${resource.name} carries customCode, which applies to insert, modify and delete ` +
|
|
174
|
+
'events only, so the field is ignored',
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const record = given && typeof given === 'object' && !Array.isArray(given)
|
|
178
|
+
? given
|
|
179
|
+
: undefined;
|
|
180
|
+
const reasons = [];
|
|
181
|
+
if (!record)
|
|
182
|
+
reasons.push('it is not an object');
|
|
183
|
+
const stray = Object.keys(record !== null && record !== void 0 ? record : {}).filter((key) => !CUSTOM_CODE_KEYS.includes(key));
|
|
184
|
+
if (stray.length)
|
|
185
|
+
reasons.push(`it carries ${stray.join(', ')}, which it has no place for`);
|
|
186
|
+
const list = record === null || record === void 0 ? void 0 : record.alsoWrites;
|
|
187
|
+
if (record && !Array.isArray(list))
|
|
188
|
+
reasons.push('alsoWrites is not a list');
|
|
189
|
+
const alsoWrites = [];
|
|
190
|
+
for (const name of Array.isArray(list) ? list : []) {
|
|
191
|
+
if (typeof name !== 'string' || !TABLE_NAME.test(name)) {
|
|
192
|
+
reasons.push(`alsoWrites holds ${typeof name === 'string' ? `'${name}'` : typeof name}, not a table name`);
|
|
193
|
+
}
|
|
194
|
+
else if (alsoWrites.includes(name)) {
|
|
195
|
+
reasons.push(`alsoWrites names ${name} twice`);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
alsoWrites.push(name);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (record && typeof record.listComplete !== 'boolean') {
|
|
202
|
+
reasons.push('listComplete is not true or false');
|
|
203
|
+
}
|
|
204
|
+
if (!reasons.length) {
|
|
205
|
+
return { value: { alsoWrites, listComplete: record.listComplete } };
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
value: { alsoWrites, listComplete: false },
|
|
209
|
+
warning: `${resource.name} carries a malformed customCode (${reasons.join('; ')}), so the review ` +
|
|
210
|
+
'says its code can also write to other records',
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* A surviving resource as it is kept: a new object holding the fields this version reads, and
|
|
215
|
+
* nothing else.
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* Never the imported object. The config is the app's `ai-config.json`, imported once and shared,
|
|
219
|
+
* and whatever the assistant goes on to do with a resource must not be able to change it. Built
|
|
220
|
+
* field by field rather than spread, because a spread reads — and carries on — every key there
|
|
221
|
+
* is, including ones this version does not read: a field only gets used once it is copied here,
|
|
222
|
+
* which is when GENESIS_AI_CONSUMES has to name it.
|
|
223
|
+
*/
|
|
224
|
+
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 } : {}));
|
|
125
226
|
}
|
|
126
227
|
/** What is wrong with one resource, if anything. `copies` is how many entries share its name. */
|
|
127
228
|
function resourceProblems(resource, copies) {
|
|
@@ -24,7 +24,14 @@
|
|
|
24
24
|
*/
|
|
25
25
|
export const GENESIS_AI_CONSUMES = Object.freeze({
|
|
26
26
|
kinds: Object.freeze(['request', 'event']),
|
|
27
|
-
resourceFields: Object.freeze([
|
|
27
|
+
resourceFields: Object.freeze([
|
|
28
|
+
'name',
|
|
29
|
+
'kind',
|
|
30
|
+
'op',
|
|
31
|
+
'context',
|
|
32
|
+
'maxRows',
|
|
33
|
+
'customCode',
|
|
34
|
+
]),
|
|
28
35
|
vendors: Object.freeze(['anthropic', 'gemini']),
|
|
29
36
|
tiers: Object.freeze(['low', 'high', 'reasoning']),
|
|
30
37
|
});
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* @beta
|
|
12
12
|
*/
|
|
13
13
|
export { GENESIS_AGENT_NAME, registerGenesisAssistant } from './register-genesis-assistant';
|
|
14
|
+
export { customCodeOf } from './config';
|
|
14
15
|
export { GENESIS_AI_CONSUMES } from './consumes';
|
|
15
16
|
export { createGenesisResourceTools, GENESIS_DATA_SOURCE } from './resource-tools';
|
|
16
17
|
export { createGenesisWriteTools } from './write-tools';
|
|
@@ -311,6 +311,13 @@ export function registerGenesisAssistant(options) {
|
|
|
311
311
|
// The last check that can block is behind us.
|
|
312
312
|
for (const line of leftOut)
|
|
313
313
|
logger.warn(`Genesis assistant: ${line}`);
|
|
314
|
+
// Only of a resource the assistant still has. One an extension replaced gets no review, so
|
|
315
|
+
// "the review says…" would describe one nobody will see; its left-out line has said why.
|
|
316
|
+
const kept = new Set(resources.map((resource) => resource.name));
|
|
317
|
+
for (const { name, warning } of check.warnings) {
|
|
318
|
+
if (kept.has(name))
|
|
319
|
+
logger.warn(`Genesis assistant: ${warning}.`);
|
|
320
|
+
}
|
|
314
321
|
// Accepted (see validateGenesisAiConfig), but announced. An assistant with no generated tools
|
|
315
322
|
// is a real configuration, and it is indistinguishable from one whose resource list came out
|
|
316
323
|
// empty by mistake: the chat opens and answers, and can reach no data, with nothing anywhere
|
|
@@ -31,6 +31,33 @@ const defaultTitle = (name) => name
|
|
|
31
31
|
* value long enough to push the change out of view wraps, where being on several lines is plain.
|
|
32
32
|
*/
|
|
33
33
|
export const LONG_VALUE = 24;
|
|
34
|
+
/** `A`, `A and B`, `A, B and C`. */
|
|
35
|
+
const joined = (items) => items.length > 1 ? `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}` : items[0];
|
|
36
|
+
/**
|
|
37
|
+
* The line a review shows when the event runs custom code: that the code can do more than the
|
|
38
|
+
* row shown, and what the generator found it can also write to.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* Every form says the code can do more than the values shown, because the row a coded handler
|
|
42
|
+
* saves is built in its code, not taken from the review. The named tables are a FLOOR, dated to
|
|
43
|
+
* when the app was generated (the app's code can change after), and end in "other records" unless
|
|
44
|
+
* the generator proved the list complete. The exact words are pinned by contracts C-18.D.4.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export function customCodeLine(op, customCode) {
|
|
49
|
+
const verb = op === 'delete' ? 'remove the row shown' : 'save the values shown';
|
|
50
|
+
const opening = `This action runs custom code, so it can do more than ${verb}`;
|
|
51
|
+
if (!customCode.alsoWrites.length) {
|
|
52
|
+
return customCode.listComplete
|
|
53
|
+
? `${opening}.`
|
|
54
|
+
: `${opening}, and it can also write to other records.`;
|
|
55
|
+
}
|
|
56
|
+
const names = customCode.listComplete
|
|
57
|
+
? customCode.alsoWrites
|
|
58
|
+
: [...customCode.alsoWrites, 'other records'];
|
|
59
|
+
return `${opening}. When this app was generated, that code could also write to ${joined(names)}.`;
|
|
60
|
+
}
|
|
34
61
|
/**
|
|
35
62
|
* How much of a value is spoken in a row's accessible name.
|
|
36
63
|
*
|
|
@@ -144,7 +171,7 @@ export function displayValue(value, type) {
|
|
|
144
171
|
*/
|
|
145
172
|
export function buildReviewModel(options) {
|
|
146
173
|
var _a;
|
|
147
|
-
const { resource, op, fields = [], rows } = options;
|
|
174
|
+
const { resource, op, fields = [], rows, customCode } = options;
|
|
148
175
|
const byName = new Map(fields.map((field) => [field.name, field]));
|
|
149
176
|
// Declared order first, then anything a row carries that the metadata did not describe, in the
|
|
150
177
|
// order it is first seen. One column list, so every row's cells line up under it.
|
|
@@ -204,13 +231,16 @@ export function buildReviewModel(options) {
|
|
|
204
231
|
.join(', ');
|
|
205
232
|
return Object.assign({ index: row.index, details: row.details, cells, label: spoken || `row ${row.index + 1}` }, (((_c = row.problems) === null || _c === void 0 ? void 0 : _c.length) ? { problems: row.problems } : {}));
|
|
206
233
|
});
|
|
207
|
-
return {
|
|
208
|
-
resource,
|
|
234
|
+
return Object.assign({ resource,
|
|
209
235
|
op,
|
|
210
|
-
columns,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
236
|
+
columns, rows: built, selectable: built.filter((row) => { var _a; return !((_a = row.problems) === null || _a === void 0 ? void 0 : _a.length); }).map((row) => row.index) }, (customCode
|
|
237
|
+
? {
|
|
238
|
+
customCode: {
|
|
239
|
+
alsoWrites: [...customCode.alsoWrites],
|
|
240
|
+
listComplete: customCode.listComplete,
|
|
241
|
+
},
|
|
242
|
+
}
|
|
243
|
+
: {}));
|
|
214
244
|
}
|
|
215
245
|
/**
|
|
216
246
|
* The selection a freshly opened review starts with: none.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, GenesisElement, observable } from '@genesislcap/web-core';
|
|
3
|
-
import { canWrite, initialSelection, restoredSelection, reviewDecisionOf, } from '../review-model';
|
|
3
|
+
import { canWrite, customCodeLine, initialSelection, restoredSelection, reviewDecisionOf, } from '../review-model';
|
|
4
4
|
import { MAX_FEEDBACK_CHARS, } from '../review-payload';
|
|
5
5
|
import { isBlankText } from '../write-payload';
|
|
6
6
|
import { WriteReviewStyles as styles } from './write-review.styles';
|
|
@@ -105,6 +105,16 @@ let GenesisWriteReview = class GenesisWriteReview extends GenesisElement {
|
|
|
105
105
|
var _a;
|
|
106
106
|
return ((_a = this.interaction) === null || _a === void 0 ? void 0 : _a.status) === 'resolved';
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* What the review says about custom code the event runs, or `''` when it runs none. Read from
|
|
110
|
+
* the model, which history keeps, so it is there whether the review is open, resolved or
|
|
111
|
+
* re-mounted. Not repeated in the closed summary: the resolved review still shows it, and the
|
|
112
|
+
* summary's live region would announce it as though code had run.
|
|
113
|
+
*/
|
|
114
|
+
get customCodeLine() {
|
|
115
|
+
const model = this.model;
|
|
116
|
+
return (model === null || model === void 0 ? void 0 : model.customCode) ? customCodeLine(model.op, model.customCode) : '';
|
|
117
|
+
}
|
|
108
118
|
/**
|
|
109
119
|
* Whether the review is past taking input: it has resolved, or it has sent its answer. Every
|
|
110
120
|
* action checks this rather than `resolved`, which is still false in between.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { html, repeat, when } from '@genesislcap/web-core';
|
|
2
2
|
import { MAX_FEEDBACK_CHARS } from '../review-payload';
|
|
3
3
|
import { isBlankText } from '../write-payload';
|
|
4
|
+
/** The custom-code line's id: the table is described by it, when there is one. */
|
|
5
|
+
const CUSTOM_CODE_LINE_ID = 'custom-code';
|
|
4
6
|
/**
|
|
5
7
|
* What a checkbox says NOW, read from the event rather than inferred from the state.
|
|
6
8
|
*
|
|
@@ -129,8 +131,14 @@ export const WriteReviewTemplate = html `
|
|
|
129
131
|
${(x) => { var _a; return (_a = x.model) === null || _a === void 0 ? void 0 : _a.op; }} ${(x) => { var _a; return (_a = x.model) === null || _a === void 0 ? void 0 : _a.rows.length; }} row(s) in ${(x) => { var _a; return (_a = x.model) === null || _a === void 0 ? void 0 : _a.resource; }}.
|
|
130
132
|
Nothing is written until you choose rows and select Write.
|
|
131
133
|
</p>
|
|
134
|
+
${when((x) => !!x.customCodeLine, html `
|
|
135
|
+
<p class="custom-code" id="${CUSTOM_CODE_LINE_ID}">${(x) => x.customCodeLine}</p>
|
|
136
|
+
`)}
|
|
132
137
|
<div class="scroller">
|
|
133
|
-
<table
|
|
138
|
+
<table
|
|
139
|
+
aria-label="Rows to be written to ${(x) => { var _a; return (_a = x.model) === null || _a === void 0 ? void 0 : _a.resource; }}"
|
|
140
|
+
aria-describedby="${(x) => (x.customCodeLine ? CUSTOM_CODE_LINE_ID : undefined)}"
|
|
141
|
+
>
|
|
134
142
|
<thead>
|
|
135
143
|
<tr>
|
|
136
144
|
<th>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { getConnect } from '@genesislcap/foundation-comms';
|
|
3
3
|
import { logger } from '../utils/logger';
|
|
4
|
-
import { capIsReadable, opFromName, toolNameOf } from './config';
|
|
4
|
+
import { capIsReadable, customCodeOf, opFromName, toolNameOf } from './config';
|
|
5
5
|
import { fieldKindOf as criteriaKindOf } from './criteria';
|
|
6
6
|
import { loadEventFields } from './event-fields';
|
|
7
7
|
import { GENESIS_DATA_SOURCE } from './resource-tools';
|
|
@@ -9,7 +9,7 @@ import { buildReviewModel, reviewDecisionOf, selectedRows, } from './review-mode
|
|
|
9
9
|
import { MAX_FEEDBACK_CHARS } from './review-payload';
|
|
10
10
|
import { createRequestRowSource } from './row-source';
|
|
11
11
|
import { genesisTypeName } from './type-name';
|
|
12
|
-
import { GENESIS_EVENT_OPS } from './types';
|
|
12
|
+
import { GENESIS_EVENT_OPS, } from './types';
|
|
13
13
|
import { commitRows } from './write-commit';
|
|
14
14
|
import { isCarryOnly, isWholeNumberType, PLATFORM_MAINTAINED, sendableFields, } from './write-payload';
|
|
15
15
|
import { MAX_WRITE_ROWS, planWrite, stillCurrent, } from './write-plan';
|
|
@@ -302,6 +302,35 @@ const decideOp = (resource) => {
|
|
|
302
302
|
}
|
|
303
303
|
return { op };
|
|
304
304
|
};
|
|
305
|
+
/** The Connect the tools were given, or the app's own; none when neither can be had yet. */
|
|
306
|
+
const connectOf = (options) => {
|
|
307
|
+
var _a;
|
|
308
|
+
try {
|
|
309
|
+
return (_a = options.connect) !== null && _a !== void 0 ? _a : getConnect();
|
|
310
|
+
}
|
|
311
|
+
catch (_b) {
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Each event's customCode as its reviews show it, read ONCE, when the tools are built.
|
|
317
|
+
*
|
|
318
|
+
* @remarks
|
|
319
|
+
* The factory is exported and never validates, so a direct call gets the validator's rule, and a
|
|
320
|
+
* malformed value is said once rather than on every review. A validated config's copies are
|
|
321
|
+
* already normal, so they say nothing twice.
|
|
322
|
+
*/
|
|
323
|
+
const customCodesOf = (events) => {
|
|
324
|
+
const customCodes = new Map();
|
|
325
|
+
for (const resource of events) {
|
|
326
|
+
const customCode = customCodeOf(resource);
|
|
327
|
+
if (customCode.warning)
|
|
328
|
+
logger.warn(`Genesis assistant: ${customCode.warning}.`);
|
|
329
|
+
if (customCode.value)
|
|
330
|
+
customCodes.set(resource.name, customCode.value);
|
|
331
|
+
}
|
|
332
|
+
return customCodes;
|
|
333
|
+
};
|
|
305
334
|
/** `EVENT_TRADE_MODIFY` reads its rows from `REQ_TRADE`, when the app exposes one. */
|
|
306
335
|
const readResourceFor = (eventName) => {
|
|
307
336
|
const match = /^EVENT_(.+)_(?:INSERT|MODIFY|DELETE)$/.exec(eventName);
|
|
@@ -514,15 +543,7 @@ function configRules(resources, options) {
|
|
|
514
543
|
export function createGenesisWriteTools(resources, options = {}) {
|
|
515
544
|
var _a;
|
|
516
545
|
const { events, decide, whyNoSource, readsFrom, writable } = configRules(resources, options);
|
|
517
|
-
const resolveConnect = () =>
|
|
518
|
-
var _a;
|
|
519
|
-
try {
|
|
520
|
-
return (_a = options.connect) !== null && _a !== void 0 ? _a : getConnect();
|
|
521
|
-
}
|
|
522
|
-
catch (_b) {
|
|
523
|
-
return undefined;
|
|
524
|
-
}
|
|
525
|
-
};
|
|
546
|
+
const resolveConnect = () => connectOf(options);
|
|
526
547
|
const sources = new Map();
|
|
527
548
|
const lockOf = locksOf(resources, decide, readsFrom);
|
|
528
549
|
/**
|
|
@@ -686,6 +707,7 @@ export function createGenesisWriteTools(resources, options = {}) {
|
|
|
686
707
|
// One record per turn and event, shared by every handler below: see write-turn.ts.
|
|
687
708
|
const turns = createWriteTurns();
|
|
688
709
|
const feedbackKey = (_a = options.feedbackKey) !== null && _a !== void 0 ? _a : mintFeedbackKey();
|
|
710
|
+
const customCodes = customCodesOf(events);
|
|
689
711
|
const toolHandlers = {};
|
|
690
712
|
for (const resource of events) {
|
|
691
713
|
toolHandlers[toolNameOf(resource.name)] = (args, context) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -700,6 +722,7 @@ export function createGenesisWriteTools(resources, options = {}) {
|
|
|
700
722
|
turns,
|
|
701
723
|
feedbackKey,
|
|
702
724
|
lockOf,
|
|
725
|
+
customCode: customCodes.get(resource.name),
|
|
703
726
|
});
|
|
704
727
|
});
|
|
705
728
|
}
|
|
@@ -849,6 +872,7 @@ function runWrite(resource, args, context, deps) {
|
|
|
849
872
|
var _a;
|
|
850
873
|
return (Object.assign(Object.assign({ index: row.index, details: (_a = row.details) !== null && _a !== void 0 ? _a : {} }, (op === 'delete' && row.preImage ? { display: row.preImage } : {})), { preImage: op === 'delete' ? undefined : row.preImage, problems: row.problems }));
|
|
851
874
|
}),
|
|
875
|
+
customCode: deps.customCode,
|
|
852
876
|
});
|
|
853
877
|
// What the staleness check compares: every column the review RENDERED, because what the user
|
|
854
878
|
// saw is evidence for what was checked only if the two are the same set. For a modify that is
|
|
@@ -24,7 +24,14 @@ __export(consumes_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(consumes_exports);
|
|
25
25
|
var GENESIS_AI_CONSUMES = Object.freeze({
|
|
26
26
|
kinds: Object.freeze(["request", "event"]),
|
|
27
|
-
resourceFields: Object.freeze([
|
|
27
|
+
resourceFields: Object.freeze([
|
|
28
|
+
"name",
|
|
29
|
+
"kind",
|
|
30
|
+
"op",
|
|
31
|
+
"context",
|
|
32
|
+
"maxRows",
|
|
33
|
+
"customCode"
|
|
34
|
+
]),
|
|
28
35
|
vendors: Object.freeze(["anthropic", "gemini"]),
|
|
29
36
|
tiers: Object.freeze(["low", "high", "reasoning"])
|
|
30
37
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/genesis/consumes.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event'] as const),\n resourceFields: Object.freeze(['name'
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,OAAO,CAAU;AAAA,EAClD,gBAAgB,OAAO,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,OAAO,CAAU;AAAA,EAClD,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAC5D,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
// src/genesis/consumes.ts
|
|
2
2
|
var GENESIS_AI_CONSUMES = Object.freeze({
|
|
3
3
|
kinds: Object.freeze(["request", "event"]),
|
|
4
|
-
resourceFields: Object.freeze([
|
|
4
|
+
resourceFields: Object.freeze([
|
|
5
|
+
"name",
|
|
6
|
+
"kind",
|
|
7
|
+
"op",
|
|
8
|
+
"context",
|
|
9
|
+
"maxRows",
|
|
10
|
+
"customCode"
|
|
11
|
+
]),
|
|
5
12
|
vendors: Object.freeze(["anthropic", "gemini"]),
|
|
6
13
|
tiers: Object.freeze(["low", "high", "reasoning"])
|
|
7
14
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/genesis/consumes.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event'] as const),\n resourceFields: Object.freeze(['name'
|
|
5
|
-
"mappings": ";AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,OAAO,CAAU;AAAA,EAClD,gBAAgB,OAAO,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * What this version of the assistant reads from a generated AI config\n * (`@genesislcap/ai-assistant/genesis/consumes`).\n *\n * @remarks\n * Its own entry point, loadable in bare Node, because the seed's CI reads it in a Node step and\n * `./genesis` cannot be: that entry is bundler-target ESM, and its closure registers custom\n * elements, which need a DOM. So this module imports nothing at run time. A type from `./types`\n * is all it may take, and a test holds it to that. The Node build bundles it to\n * `dist/genesis-consumes.mjs` and `.cjs`, and a smoke test loads both without a DOM.\n *\n * @packageDocumentation\n * @beta\n */\nimport type { GenesisAiConsumes } from './types';\n\nexport type { GenesisAiConsumes } from './types';\n\n/**\n * What this version of the assistant reads from a generated AI config: the resource kinds it\n * accepts, the resource fields its validator or a tool reads, and the `vendor` and `tier` values\n * it accepts.\n *\n * @remarks\n * The generator must not emit what the installed assistant does not read, or a new kind is left out\n * and a new field ignored \u2014 and an older assistant used to block entirely on a kind it did not know.\n * Nothing in the generator can say which version will run its output. So the app's seed declares\n * what it expects, and the seed's CI checks that declaration against this constant, exported from\n * the version it installs. That makes this the single statement of what an assistant consumes, and\n * it carries no version number because it needs none.\n *\n * A test holds it to the code: its kinds are the ones validation accepts, and its fields are the\n * ones read. A change that teaches the validator a kind, or a tool a field, updates it in the same\n * commit.\n *\n * A resource this version does not read is only left out, but an unknown `vendor` or `tier` still\n * blocks the whole assistant, so those are here too. They are written out rather than imported\n * from foundation-ai, which this entry must not load; a test holds them equal to its\n * `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.\n *\n * @beta\n */\nexport const GENESIS_AI_CONSUMES: GenesisAiConsumes = Object.freeze({\n kinds: Object.freeze(['request', 'event'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n ] as const),\n vendors: Object.freeze(['anthropic', 'gemini'] as const),\n tiers: Object.freeze(['low', 'high', 'reasoning'] as const),\n});\n"],
|
|
5
|
+
"mappings": ";AA0CO,IAAM,sBAAyC,OAAO,OAAO;AAAA,EAClE,OAAO,OAAO,OAAO,CAAC,WAAW,OAAO,CAAU;AAAA,EAClD,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAU;AAAA,EACV,SAAS,OAAO,OAAO,CAAC,aAAa,QAAQ,CAAU;AAAA,EACvD,OAAO,OAAO,OAAO,CAAC,OAAO,QAAQ,WAAW,CAAU;AAC5D,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|