@genesislcap/ai-assistant 15.41.0 → 15.43.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/chat-driver.cjs +115 -6
- package/dist/chat-driver.cjs.map +3 -3
- package/dist/chat-driver.mjs +115 -6
- package/dist/chat-driver.mjs.map +3 -3
- package/dist/custom-elements.json +761 -713
- package/dist/dts/genesis/config.d.ts +51 -6
- package/dist/dts/genesis/config.d.ts.map +1 -1
- package/dist/dts/genesis/consumes.d.ts +42 -0
- package/dist/dts/genesis/consumes.d.ts.map +1 -0
- package/dist/dts/genesis/criteria.d.ts.map +1 -1
- package/dist/dts/genesis/event-fields.d.ts +4 -1
- package/dist/dts/genesis/event-fields.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 +29 -4
- package/dist/dts/genesis/register-genesis-assistant.d.ts.map +1 -1
- package/dist/dts/genesis/resource-tools.d.ts.map +1 -1
- package/dist/dts/genesis/review-model.d.ts.map +1 -1
- package/dist/dts/genesis/types.d.ts +37 -5
- package/dist/dts/genesis/types.d.ts.map +1 -1
- package/dist/dts/genesis/write-payload.d.ts.map +1 -1
- package/dist/dts/genesis/write-tools.d.ts +26 -5
- package/dist/dts/genesis/write-tools.d.ts.map +1 -1
- package/dist/esm/genesis/config.js +105 -50
- package/dist/esm/genesis/consumes.js +30 -0
- package/dist/esm/genesis/criteria.js +28 -0
- package/dist/esm/genesis/event-fields.js +20 -3
- package/dist/esm/genesis/index.js +1 -0
- package/dist/esm/genesis/register-genesis-assistant.js +146 -63
- package/dist/esm/genesis/resource-tools.js +20 -12
- package/dist/esm/genesis/review-model.js +16 -3
- package/dist/esm/genesis/write-payload.js +47 -4
- package/dist/esm/genesis/write-tools.js +199 -45
- package/dist/genesis-consumes.cjs +35 -0
- package/dist/genesis-consumes.cjs.map +7 -0
- package/dist/genesis-consumes.mjs +11 -0
- package/dist/genesis-consumes.mjs.map +7 -0
- package/docs/genesis.md +156 -28
- package/package.json +29 -19
- package/scripts/build-genesis-consumes-node.mjs +50 -0
- package/scripts/smoke-genesis-consumes-node.mjs +70 -0
package/docs/genesis.md
CHANGED
|
@@ -28,21 +28,37 @@ if (blockedReason) assistant.setBlocked(true, blockedReason);
|
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
`registerGenesisAssistant` is synchronous and **never throws**. Anything that stops the assistant
|
|
31
|
-
from running comes back
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
from running comes back with an empty `agents` list, so a bad config costs the app its assistant,
|
|
32
|
+
never its start-up. It comes back in two parts:
|
|
33
|
+
|
|
34
|
+
- `blockedReason`, for the person using the app, and one of two sentences. AI switched off, in
|
|
35
|
+
the build or in the config, reads "The assistant is switched off for this app." Anything else
|
|
36
|
+
reads "The assistant isn't set up correctly, so it can't be used. An administrator can find the
|
|
37
|
+
details in the browser console."
|
|
38
|
+
- `blockedDetail`, for whoever maintains the app: which setting, resource or tool is at fault. It
|
|
39
|
+
is logged too, as an error, except for AI switched off, which is a choice rather than a fault
|
|
40
|
+
and is logged at debug. It names the app's internals, so keep it out of the assistant's banner.
|
|
41
|
+
|
|
42
|
+
What blocks it:
|
|
35
43
|
|
|
36
44
|
- AI is switched off for the build (`feature.ai` flag) or in the config (`enabled: false`);
|
|
37
|
-
- the config is invalid
|
|
38
|
-
|
|
39
|
-
- an extension tool is declared twice or has no handler
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
- the config as a whole is invalid, or every resource in it was left out and the app has no
|
|
46
|
+
extension tool of its own (see below; one bad resource only leaves out itself);
|
|
47
|
+
- an extension tool has no name, is declared twice or has no handler, a handler has no tool
|
|
48
|
+
definition, or the extensions are not the shape above;
|
|
49
|
+
- `rowSources` is given and is not an object (a wrong entry in it only costs its own event a
|
|
50
|
+
tool, see [Write tools](#write-tools));
|
|
42
51
|
- the providers cannot be registered (for example `vendors` leaves out the configured vendor).
|
|
43
52
|
|
|
44
53
|
A blocked registration registers no providers.
|
|
45
54
|
|
|
55
|
+
An extension tool whose name is one a resource's tool would have, reads and writes alike, does
|
|
56
|
+
**not** block. The hand-written tool is kept and the resource is left out, with a console warning
|
|
57
|
+
naming both. The extension is the app's own code; the generated tool comes from a config that a
|
|
58
|
+
regeneration can change under it. A handler with no tool definition is not a tool, so it wins no
|
|
59
|
+
clash: it blocks, as a definition with no handler does. Spread over the generated handlers, it
|
|
60
|
+
could only ever answer for a generated tool whose description the model still sees.
|
|
61
|
+
|
|
46
62
|
### Options
|
|
47
63
|
|
|
48
64
|
| Option | Default | Notes |
|
|
@@ -53,7 +69,7 @@ A blocked registration registers no providers.
|
|
|
53
69
|
| `vendors` | `[config.vendor]` | Vendors the user may switch between. One by default: a proxy holding one key cannot answer for another vendor. |
|
|
54
70
|
| `connect` | the app's `Connect`, from DI | Resolved when a tool first runs, not at registration. |
|
|
55
71
|
| `extensions` | none | `{ toolDefinitions, toolHandlers, systemPrompt }` — the app's hand-written tools, added after the generated ones. |
|
|
56
|
-
| `rowSources` | the `REQ_` for the same table |
|
|
72
|
+
| `rowSources` | the `REQ_` for the same table | **Deprecated.** Only the table's own `REQ_` is accepted, which is the default. See [Write tools](#write-tools). |
|
|
57
73
|
|
|
58
74
|
The agent runs on the registry's default provider, which is the configured tier. Its system prompt
|
|
59
75
|
is the configured prompt, then a fixed rule that tool results are app data and never
|
|
@@ -89,10 +105,57 @@ that table, unless asked), then the extensions' prompt.
|
|
|
89
105
|
| `op` | Events only: `insert`, `modify`, `delete` or `custom`. |
|
|
90
106
|
| `maxRows` | Requests only: a whole number from 1 to 1000. Defaults to 50. |
|
|
91
107
|
|
|
108
|
+
A rule about the config **as a whole** — `enabled`, `vendor`, `tier`, `systemPrompt`, and
|
|
109
|
+
`resources` being a list — blocks the assistant. A rule about **one resource** leaves that resource
|
|
110
|
+
out and keeps the rest: it gets no tool, and the console names it and says why. A duplicated name
|
|
111
|
+
leaves out every copy, since which one is meant is unknown. A `kind` this version does not read
|
|
112
|
+
(`request` and `event`) is left out the same way. That keeps an app working when a newer generator
|
|
113
|
+
emits one, but it is not support for it. If the config lists resources and every one of them is
|
|
114
|
+
left out, the assistant runs on the app's extension tools, and the console names each resource
|
|
115
|
+
left out. With no extension tool either, it is blocked: a chat that can reach nothing would still
|
|
116
|
+
look like it works.
|
|
117
|
+
|
|
92
118
|
No `resources` at all, absent or `[]`, is accepted: an assistant whose tools all come from the
|
|
93
119
|
app's extensions, or a chat helper with none, is a real configuration. It is also exactly what a
|
|
94
120
|
list that came out empty by mistake looks like, so registration logs a warning naming both.
|
|
95
121
|
|
|
122
|
+
### What this version reads
|
|
123
|
+
|
|
124
|
+
`GENESIS_AI_CONSUMES` says what this version of the assistant reads from the config:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { GENESIS_AI_CONSUMES } from '@genesislcap/ai-assistant/genesis/consumes';
|
|
128
|
+
|
|
129
|
+
GENESIS_AI_CONSUMES;
|
|
130
|
+
// {
|
|
131
|
+
// kinds: ['request', 'event'],
|
|
132
|
+
// resourceFields: ['name', 'kind', 'op', 'context', 'maxRows'],
|
|
133
|
+
// vendors: ['anthropic', 'gemini'],
|
|
134
|
+
// tiers: ['low', 'high', 'reasoning'],
|
|
135
|
+
// }
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`@genesislcap/ai-assistant/genesis/consumes` is the entry to read it from outside a browser. It
|
|
139
|
+
holds the constant and nothing else, built for plain Node as `import` and as `require`, and every
|
|
140
|
+
build loads it in Node with no DOM to prove it. `@genesislcap/ai-assistant/genesis` exports the
|
|
141
|
+
same value, but it cannot be loaded in plain Node: it is built for a bundler, and it registers
|
|
142
|
+
custom elements, which need a DOM. (Published, the two are separate builds, so they are two
|
|
143
|
+
objects with one value, not one object.)
|
|
144
|
+
|
|
145
|
+
A resource of any other kind is left out, and any other field does nothing. The generator has no
|
|
146
|
+
way to know which assistant version will run its output, so the app's seed declares what it
|
|
147
|
+
expects, and the seed's CI checks that declaration against this constant as exported by the
|
|
148
|
+
version the seed installs. The constant is frozen and carries no version number. A test holds it
|
|
149
|
+
to the code: its kinds are the ones validation accepts, and its fields are exactly the ones read
|
|
150
|
+
while the assistant is registered and its tools are built and called. Teaching the validator a
|
|
151
|
+
kind, or a tool a field, updates it in the same change.
|
|
152
|
+
|
|
153
|
+
`vendors` and `tiers` are the `vendor` and `tier` values this version accepts. They matter more
|
|
154
|
+
than the rest: a resource this version does not read is only left out, but an unknown `vendor` or
|
|
155
|
+
`tier` blocks the whole assistant. So the seed may check the config's `vendor` and `tier` against
|
|
156
|
+
them too. The seed's check (S-6) reads `kinds` and `resourceFields` today. A test holds both lists
|
|
157
|
+
equal to foundation-ai's `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validator checks against.
|
|
158
|
+
|
|
96
159
|
---
|
|
97
160
|
|
|
98
161
|
## Read tools
|
|
@@ -185,6 +248,21 @@ row can be changed in that time. Committing the payload built from the row as it
|
|
|
185
248
|
write the reviewed values straight over somebody else's change, and the server would ACK it.
|
|
186
249
|
A row that moved is reported as `changed_since_review` and left alone.
|
|
187
250
|
|
|
251
|
+
A `DATE` or `LOCALDATE` travels as epoch millis, so a time of day on one is written too. One the
|
|
252
|
+
model gives with a time of day is refused ("TRADE_DATE is a date; send it without a time of
|
|
253
|
+
day"), and it resends the day alone. A value the row already holds is kept whatever it holds, and
|
|
254
|
+
the review shows it in full, to the second and beyond. The same goes for the model echoing that
|
|
255
|
+
value back. It is the server's own, and refusing it would leave the row unwritable over a field
|
|
256
|
+
nobody is changing. An echo counts only when it is exactly that row's value: another row's time,
|
|
257
|
+
or the row's time to the minute when it holds seconds, is refused. When the row holds a time for
|
|
258
|
+
the field, the refusal adds "or leave it out to keep the row's value", because resending the day
|
|
259
|
+
alone would overwrite that time.
|
|
260
|
+
|
|
261
|
+
A write tool reads a field's type from its event metadata's `GENESIS_TYPE`, and from `TYPE` only
|
|
262
|
+
when there is no `GENESIS_TYPE`. `TYPE` names the Java class the value travels as, so a GSF 8.15
|
|
263
|
+
app describes a `DATE` field as `TYPE: DATETIME` with `GENESIS_TYPE: DATE`. The read tools'
|
|
264
|
+
filters still use `TYPE`.
|
|
265
|
+
|
|
188
266
|
### The user's answer
|
|
189
267
|
|
|
190
268
|
The review offers three answers:
|
|
@@ -217,7 +295,11 @@ return any text, including a perfect copy of a write result. The key is random,
|
|
|
217
295
|
`registerGenesisAssistant`, and written only into the prompt and into what the write tools
|
|
218
296
|
return, so nothing that stores or returns data can know it. A session replayed from an earlier
|
|
219
297
|
registration carries an older key, and its feedback then reads as data. An app with no event
|
|
220
|
-
|
|
298
|
+
that could get a write tool carries no exception in its prompt at all. That includes an app whose
|
|
299
|
+
events the config itself refuses: a `custom` op, a `rowSources` entry naming another source, or a
|
|
300
|
+
modify or delete whose table's `REQ_` was left out. The metadata read later can still withhold a
|
|
301
|
+
tool from an event the config allows, and that cannot be known at registration.
|
|
302
|
+
`createGenesisWriteTools` returns these events as `writableEvents`.
|
|
221
303
|
|
|
222
304
|
Three rules hold for the rest of the **turn** (the answer to one user message), in code rather
|
|
223
305
|
than in the prompt: a denial per table, the other two per event:
|
|
@@ -231,7 +313,8 @@ than in the prompt: a denial per table, the other two per event:
|
|
|
231
313
|
the fourth request the model is told that was the last round, the next call is refused, and it
|
|
232
314
|
asks in chat instead;
|
|
233
315
|
- a proposal **identical** to the one the user just asked to change is refused without a review.
|
|
234
|
-
|
|
316
|
+
Only another answer replaces it: a review in between that timed out does not. Proposals are
|
|
317
|
+
compared on the payloads they would write, field by field by type, so `'900'` and
|
|
235
318
|
`900` for an INT are the same proposal. A modify is compared on what it changes, so a column
|
|
236
319
|
somebody else edited between the two reviews does not make a resend new. Rows are matched by
|
|
237
320
|
the key the model named them by, in any order, and what a row's outcome would say (such as a
|
|
@@ -254,11 +337,12 @@ named writes null over every field it did not. The bridge therefore reads the cu
|
|
|
254
337
|
fills in the rest — and it reads it through a resource the assistant can already read, so a write
|
|
255
338
|
can never see fields no read tool was allowed to return.
|
|
256
339
|
|
|
257
|
-
**It
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
340
|
+
**It is always the table's own `REQ_<T>`**, and that `REQ_<T>` must be a request resource the
|
|
341
|
+
assistant can read: in the config, not left out, and with a read tool of its own. That is a rule
|
|
342
|
+
rather than a convenience: the read tools are the assistant's whole view of the app's data, so
|
|
343
|
+
sourcing a row anywhere else would let a write see — and show a user, and carry into the chat's
|
|
344
|
+
saved history — fields no read tool was allowed to return. A modify or delete with no such
|
|
345
|
+
resource gets no write tool, and the console says why; nothing about it blocks the assistant.
|
|
262
346
|
|
|
263
347
|
For a **modify**, the resource also has to **return every field the event writes**. A generated
|
|
264
348
|
modify replaces the record, so a column the read cannot see is a column written null, and no
|
|
@@ -273,18 +357,49 @@ metadata marks it read-only. A key field the row has no value for refuses the ro
|
|
|
273
357
|
review still shows the whole row — what is being approved is the removal of a row, not the sending
|
|
274
358
|
of a key.
|
|
275
359
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
360
|
+
The source is the **table's own `REQ_` resource** (`EVENT_TRADE_MODIFY` reads `REQ_TRADE`), and
|
|
361
|
+
nothing else. What a write reads is its pre-image, the record as it stands, and only the table's
|
|
362
|
+
own read returns that:
|
|
363
|
+
|
|
364
|
+
- a **view** can return a joined table's column under a name the event also has (a `STATUS` from
|
|
365
|
+
a joined `ORDER`). It passes the coverage check, which compares names, and a modify read through
|
|
366
|
+
it would write the joined table's value into the root record;
|
|
367
|
+
- a **dataserver query** reads a cache that can lag the very change the approve-time check exists
|
|
368
|
+
to catch.
|
|
369
|
+
|
|
370
|
+
So an event whose name carries no table (`EVENT_TRADE_AMEND` declared as a modify) has no row
|
|
371
|
+
source and gets no tool.
|
|
372
|
+
|
|
373
|
+
`rowSources` is deprecated and inert. A `rowSources` entry is accepted only when its value is
|
|
374
|
+
exactly the `REQ_<T>` the bridge derives itself for an event named `EVENT_<T>_INSERT`,
|
|
375
|
+
`EVENT_<T>_MODIFY` or `EVENT_<T>_DELETE`. Any other value drops that event's write tool with a
|
|
376
|
+
warning that names the event, the value given and the value expected. That covers another table's
|
|
377
|
+
`REQ_`, a view's `REQ_`, a query, a name that is not a request resource, and an entry for an event
|
|
378
|
+
whose name has no `_INSERT|_MODIFY|_DELETE` suffix. An entry whose key is not a surviving event
|
|
379
|
+
resource is ignored with a warning that names it. The warning says the config offers no such
|
|
380
|
+
event when it is absent, and that it was left out when validation or an extension left it out, so
|
|
381
|
+
the warning that names it says why. Registration warns and never blocks for any `rowSources` entry, and both warnings are logged
|
|
382
|
+
as the write tools are built, before `registerGenesisAssistant` returns. Only a `rowSources` that is
|
|
383
|
+
not a plain object blocks, as a config-level problem. The rest of the assistant is untouched. A view or
|
|
384
|
+
a query is never a pre-image.
|
|
385
|
+
|
|
386
|
+
What remains: "the table's own `REQ_`" is a naming rule. A hand-written app can publish a `REQ_<T>`
|
|
387
|
+
that is backed by a view, and only the field-coverage check above stands between it and a write.
|
|
388
|
+
Create-generated apps are not exposed: a request takes its entity's name, and Create refuses a new
|
|
389
|
+
name that matches an existing entity, view or query.
|
|
282
390
|
|
|
283
391
|
### What gets no write tool
|
|
284
392
|
|
|
393
|
+
- An event whose **`op` is not one of** `insert`, `modify`, `delete` or `custom`, an empty or
|
|
394
|
+
`false` one included. Only when the tools are built directly: the validator leaves such a
|
|
395
|
+
resource out first.
|
|
396
|
+
- An event with a **`rowSources` entry** naming anything but its table's own `REQ_<T>` (above).
|
|
397
|
+
- A **modify or delete with no row source**: its name carries no table, or its table's `REQ_<T>`
|
|
398
|
+
is missing from the config or was left out (below).
|
|
285
399
|
- An event whose **`op` is missing** and whose name does not end in `_INSERT`, `_MODIFY` or
|
|
286
400
|
`_DELETE`. The name settles it where it can; otherwise the resource is refused rather than
|
|
287
|
-
guessed at, because the guess used to be `custom` — the path with the fewest guarantees.
|
|
401
|
+
guessed at, because the guess used to be `custom` — the path with the fewest guarantees. Only
|
|
402
|
+
when the tools are built directly: the validator requires an `op` on every event first.
|
|
288
403
|
- An event declared **`custom`** — which the app generator emits for every exposed custom
|
|
289
404
|
handler, so this is not a rare shape. Every rule the write path follows was learned from
|
|
290
405
|
Create-generated CRUD handlers, and a custom handler is the app's own code: **we do not know
|
|
@@ -302,6 +417,9 @@ registerGenesisAssistant({ config, rowSources: { EVENT_TRADE_MODIFY: 'REQ_TRADE_
|
|
|
302
417
|
enum, text), and a guess writes the wrong value or fails the schema. The whole event, not just
|
|
303
418
|
the field, because the field left out may be a required one.
|
|
304
419
|
- A **modify** whose row source does not return every field it writes (above).
|
|
420
|
+
- A **modify or delete** whose table's request resource has **no read tool**, because its
|
|
421
|
+
`maxRows` is not a number. That only happens when the tools are built directly: the validator
|
|
422
|
+
leaves such a request out. A write reads its rows only through a resource the assistant can read.
|
|
305
423
|
- A **modify or delete** whose row source can be searched by **none of its fields**. The key a
|
|
306
424
|
model may send is offered only from fields the row source can match by equality — its
|
|
307
425
|
`CRITERIA_FIELDS` when it publishes them, typed, with readable allowed values, and not a
|
|
@@ -316,8 +434,12 @@ registerGenesisAssistant({ config, rowSources: { EVENT_TRADE_MODIFY: 'REQ_TRADE_
|
|
|
316
434
|
so a model may not set one. A modify carries the row's own value through unchanged, and is
|
|
317
435
|
refused if a JSON number cannot hold that value exactly.
|
|
318
436
|
|
|
319
|
-
An event with no usable row source **gets no tool at all**, and the console says
|
|
320
|
-
|
|
437
|
+
An event with no usable row source **gets no tool at all**, and the console says why, as the write
|
|
438
|
+
tools are built (before `registerGenesisAssistant` returns). When the
|
|
439
|
+
config has no `REQ_<T>` for its table, it names the resource to add. When the config has one that
|
|
440
|
+
was left out, by the validator or by an extension with its name, it says so, and the warning that
|
|
441
|
+
names that resource says why. An event whose name carries no table has no resource to add. So does
|
|
442
|
+
every case above: each is logged once, with the reason, and not asked about again
|
|
321
443
|
unless asking again could help — a request that failed, or a metadata reply that came back empty
|
|
322
444
|
(Connect caches every other reply, errors included, so asking again would only repeat it). A tool that refused every call would teach the model nothing and cost a turn each time,
|
|
323
445
|
and the tool list should be a true map of what the assistant can do.
|
|
@@ -346,8 +468,14 @@ one — that is how a row gets written twice.
|
|
|
346
468
|
| `failed` | Nothing was sent: the app was not connected, or the row could not be checked first. |
|
|
347
469
|
| `unknown` | Sent, and no answer this can read came back. It may have been written. Never retry. |
|
|
348
470
|
|
|
349
|
-
`createGenesisWriteTools(resources, { connect
|
|
350
|
-
|
|
471
|
+
`createGenesisWriteTools(resources, { connect })` builds these without registering anything, for
|
|
472
|
+
an app that assembles its own agent. It holds the row-source rule itself, so a deprecated
|
|
473
|
+
`rowSources` passed to it is judged the same way, and an entry for no event it was given is
|
|
474
|
+
warned about as registration would. Give it `leftOut`, the names of resources your config has
|
|
475
|
+
but you left out of `resources`, and a modify whose table's read is among them is told it was
|
|
476
|
+
left out, rather than told to add it. Its console warning refers to the warning that names that
|
|
477
|
+
resource, so warn about each name you pass, saying why you left it out. It returns
|
|
478
|
+
`writableEvents`: the events the config lets write, before any metadata is read.
|
|
351
479
|
|
|
352
480
|
---
|
|
353
481
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/ai-assistant",
|
|
3
3
|
"description": "Genesis AI Assistant micro-frontend",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.43.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/ai-assistant.d.ts",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"types": "./dist/dts/genesis/index.d.ts",
|
|
37
37
|
"default": "./dist/esm/genesis/index.js"
|
|
38
38
|
},
|
|
39
|
+
"./genesis/consumes": {
|
|
40
|
+
"types": "./dist/dts/genesis/consumes.d.ts",
|
|
41
|
+
"import": "./dist/genesis-consumes.mjs",
|
|
42
|
+
"require": "./dist/genesis-consumes.cjs"
|
|
43
|
+
},
|
|
39
44
|
"./package.json": "./package.json",
|
|
40
45
|
"./react": {
|
|
41
46
|
"types": "./dist/dts/react.d.ts",
|
|
@@ -53,13 +58,18 @@
|
|
|
53
58
|
],
|
|
54
59
|
"genesis": [
|
|
55
60
|
"./dist/dts/genesis/index.d.ts"
|
|
61
|
+
],
|
|
62
|
+
"genesis/consumes": [
|
|
63
|
+
"./dist/dts/genesis/consumes.d.ts"
|
|
56
64
|
]
|
|
57
65
|
}
|
|
58
66
|
},
|
|
59
67
|
"scripts": {
|
|
60
|
-
"build": "genx build -b ts && node ./scripts/build-chat-driver-node.mjs && npm run smoke:chat-driver",
|
|
68
|
+
"build": "genx build -b ts && node ./scripts/build-chat-driver-node.mjs && node ./scripts/build-genesis-consumes-node.mjs && npm run smoke:chat-driver && npm run smoke:genesis-consumes",
|
|
61
69
|
"build:chat-driver": "node ./scripts/build-chat-driver-node.mjs",
|
|
70
|
+
"build:genesis-consumes": "node ./scripts/build-genesis-consumes-node.mjs",
|
|
62
71
|
"smoke:chat-driver": "node ./scripts/smoke-chat-driver-node.mjs",
|
|
72
|
+
"smoke:genesis-consumes": "node ./scripts/smoke-genesis-consumes-node.mjs",
|
|
63
73
|
"build:webpack": "genx build",
|
|
64
74
|
"build:webpack:stats": "genx analyze",
|
|
65
75
|
"circular": "npx -y madge --extensions ts --circular ./src",
|
|
@@ -82,32 +92,32 @@
|
|
|
82
92
|
}
|
|
83
93
|
},
|
|
84
94
|
"devDependencies": {
|
|
85
|
-
"@genesislcap/foundation-comms": "15.
|
|
86
|
-
"@genesislcap/foundation-testing": "15.
|
|
87
|
-
"@genesislcap/genx": "15.
|
|
88
|
-
"@genesislcap/rollup-builder": "15.
|
|
89
|
-
"@genesislcap/ts-builder": "15.
|
|
90
|
-
"@genesislcap/uvu-playwright-builder": "15.
|
|
91
|
-
"@genesislcap/vite-builder": "15.
|
|
92
|
-
"@genesislcap/webpack-builder": "15.
|
|
95
|
+
"@genesislcap/foundation-comms": "15.43.0",
|
|
96
|
+
"@genesislcap/foundation-testing": "15.43.0",
|
|
97
|
+
"@genesislcap/genx": "15.43.0",
|
|
98
|
+
"@genesislcap/rollup-builder": "15.43.0",
|
|
99
|
+
"@genesislcap/ts-builder": "15.43.0",
|
|
100
|
+
"@genesislcap/uvu-playwright-builder": "15.43.0",
|
|
101
|
+
"@genesislcap/vite-builder": "15.43.0",
|
|
102
|
+
"@genesislcap/webpack-builder": "15.43.0",
|
|
93
103
|
"@types/dompurify": "^3.0.5",
|
|
94
104
|
"@types/marked": "^5.0.2",
|
|
95
105
|
"esbuild": "0.25.12"
|
|
96
106
|
},
|
|
97
107
|
"dependencies": {
|
|
98
|
-
"@genesislcap/foundation-ai": "15.
|
|
99
|
-
"@genesislcap/foundation-logger": "15.
|
|
100
|
-
"@genesislcap/foundation-notifications": "15.
|
|
101
|
-
"@genesislcap/foundation-redux": "15.
|
|
102
|
-
"@genesislcap/foundation-ui": "15.
|
|
103
|
-
"@genesislcap/foundation-utils": "15.
|
|
104
|
-
"@genesislcap/rapid-design-system": "15.
|
|
105
|
-
"@genesislcap/web-core": "15.
|
|
108
|
+
"@genesislcap/foundation-ai": "15.43.0",
|
|
109
|
+
"@genesislcap/foundation-logger": "15.43.0",
|
|
110
|
+
"@genesislcap/foundation-notifications": "15.43.0",
|
|
111
|
+
"@genesislcap/foundation-redux": "15.43.0",
|
|
112
|
+
"@genesislcap/foundation-ui": "15.43.0",
|
|
113
|
+
"@genesislcap/foundation-utils": "15.43.0",
|
|
114
|
+
"@genesislcap/rapid-design-system": "15.43.0",
|
|
115
|
+
"@genesislcap/web-core": "15.43.0",
|
|
106
116
|
"dompurify": "^3.3.1",
|
|
107
117
|
"marked": "^17.0.3"
|
|
108
118
|
},
|
|
109
119
|
"peerDependencies": {
|
|
110
|
-
"@genesislcap/foundation-comms": "^15.
|
|
120
|
+
"@genesislcap/foundation-comms": "^15.43.0"
|
|
111
121
|
},
|
|
112
122
|
"peerDependenciesMeta": {
|
|
113
123
|
"@genesislcap/foundation-comms": {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundles the Node-safe `./genesis/consumes` subpath into Node-loadable dual output
|
|
3
|
+
* (`dist/genesis-consumes.mjs` + `dist/genesis-consumes.cjs`).
|
|
4
|
+
*
|
|
5
|
+
* Why: the seed's CI checks the app's declaration against `GENESIS_AI_CONSUMES` in a bare Node
|
|
6
|
+
* step (contracts C-15A.6 S-6). `./genesis` cannot serve it: `genx build -b ts` emits
|
|
7
|
+
* bundler-target ESM that Node's own loader can't resolve (see build-chat-driver-node.mjs), and
|
|
8
|
+
* that entry's closure registers custom elements, which need a DOM. `src/genesis/consumes.ts`
|
|
9
|
+
* imports nothing at run time, so this bundle is the constant and nothing else — and the build
|
|
10
|
+
* fails if that ever stops being true, rather than shipping a DOM import to a Node step.
|
|
11
|
+
*
|
|
12
|
+
* Runs after `genx build -b ts` (which produces the matching `dist/dts/genesis/consumes.d.ts`).
|
|
13
|
+
*/
|
|
14
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
import * as esbuild from 'esbuild';
|
|
17
|
+
|
|
18
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
19
|
+
const entry = resolve(packageRoot, 'src/genesis/consumes.ts');
|
|
20
|
+
|
|
21
|
+
/** @type {import('esbuild').BuildOptions} */
|
|
22
|
+
const shared = {
|
|
23
|
+
entryPoints: [entry],
|
|
24
|
+
bundle: true,
|
|
25
|
+
platform: 'node',
|
|
26
|
+
target: 'node22',
|
|
27
|
+
metafile: true,
|
|
28
|
+
sourcemap: 'linked',
|
|
29
|
+
logLevel: 'info',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
for (const [format, outfile] of [
|
|
33
|
+
['esm', 'dist/genesis-consumes.mjs'],
|
|
34
|
+
['cjs', 'dist/genesis-consumes.cjs'],
|
|
35
|
+
]) {
|
|
36
|
+
const { metafile } = await esbuild.build({
|
|
37
|
+
...shared,
|
|
38
|
+
format,
|
|
39
|
+
outfile: resolve(packageRoot, outfile),
|
|
40
|
+
});
|
|
41
|
+
const inputs = Object.keys(metafile.inputs);
|
|
42
|
+
const expected = relative(process.cwd(), entry);
|
|
43
|
+
if (inputs.length !== 1 || resolve(process.cwd(), inputs[0]) !== entry) {
|
|
44
|
+
console.error(
|
|
45
|
+
`✖ ${outfile} bundles more than ${expected}: ${inputs.join(', ')}. ` +
|
|
46
|
+
'The consumes entry must import nothing at run time.',
|
|
47
|
+
);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the built `./genesis/consumes` bundles the way the seed's CI loads them — bare Node, no
|
|
3
|
+
* jsdom, no bundler — and checks the constant is there and says what this version reads.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists (contracts C-15A.6 S-6): the seed checks its declaration against
|
|
6
|
+
* `GENESIS_AI_CONSUMES` in a Node step, and nothing in this repo would otherwise load the entry
|
|
7
|
+
* that way. A failed import there looks like an absent export, which holds the seed to its
|
|
8
|
+
* baseline for good, so it has to fail here instead.
|
|
9
|
+
*
|
|
10
|
+
* Runs as part of `npm run build`, right after the bundles are written. The expected value is
|
|
11
|
+
* written out, not read from the source: it is what the seed compares against, so a change to it
|
|
12
|
+
* is a change to that contract and belongs in this file's diff too.
|
|
13
|
+
*/
|
|
14
|
+
import { createRequire } from 'node:module';
|
|
15
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
16
|
+
import { dirname, resolve } from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
|
|
19
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
21
|
+
|
|
22
|
+
const EXPECTED = {
|
|
23
|
+
kinds: ['request', 'event'],
|
|
24
|
+
resourceFields: ['name', 'kind', 'op', 'context', 'maxRows'],
|
|
25
|
+
vendors: ['anthropic', 'gemini'],
|
|
26
|
+
tiers: ['low', 'high', 'reasoning'],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const failures = [];
|
|
30
|
+
const check = (condition, message) => {
|
|
31
|
+
if (!condition) failures.push(message);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
check(
|
|
35
|
+
typeof globalThis.document === 'undefined' && typeof globalThis.window === 'undefined',
|
|
36
|
+
'this smoke test is only meaningful without a DOM, but one is present — has a setup file leaked in?',
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const cjs = require(resolve(packageRoot, 'dist/genesis-consumes.cjs'));
|
|
40
|
+
const esm = await import(resolve(packageRoot, 'dist/genesis-consumes.mjs'));
|
|
41
|
+
|
|
42
|
+
for (const [file, loaded] of [
|
|
43
|
+
['dist/genesis-consumes.cjs', cjs],
|
|
44
|
+
['dist/genesis-consumes.mjs', esm],
|
|
45
|
+
]) {
|
|
46
|
+
// The constant and nothing else: this entry is a contract, not a second way into the bridge.
|
|
47
|
+
check(
|
|
48
|
+
// Exactly: a default export is an export too, and would be a second way to read it.
|
|
49
|
+
isDeepStrictEqual(Object.keys(loaded), ['GENESIS_AI_CONSUMES']),
|
|
50
|
+
`${file} exports ${Object.keys(loaded).join(', ')}, not only GENESIS_AI_CONSUMES`,
|
|
51
|
+
);
|
|
52
|
+
const consumes = loaded.GENESIS_AI_CONSUMES;
|
|
53
|
+
// Every key and every value, exactly: a key the seed does not expect is a change to the contract.
|
|
54
|
+
const lists = Object.entries(consumes ?? {});
|
|
55
|
+
check(
|
|
56
|
+
isDeepStrictEqual(Object.fromEntries(lists.map(([key, list]) => [key, [...list]])), EXPECTED),
|
|
57
|
+
`${file}: GENESIS_AI_CONSUMES is ${JSON.stringify(consumes)}, not ${JSON.stringify(EXPECTED)}`,
|
|
58
|
+
);
|
|
59
|
+
check(
|
|
60
|
+
Object.isFrozen(consumes) && lists.every(([, list]) => Object.isFrozen(list)),
|
|
61
|
+
`${file}: GENESIS_AI_CONSUMES is not frozen all the way down`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (failures.length > 0) {
|
|
66
|
+
console.error(`✖ genesis/consumes Node smoke test failed:\n - ${failures.join('\n - ')}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log('✔ genesis/consumes loads in bare Node, and GENESIS_AI_CONSUMES is as declared');
|