@genesislcap/ai-assistant 15.46.5-FUI-2648.1 → 15.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/ai-assistant.api.json +0 -65
  2. package/dist/ai-assistant.d.ts +16 -35
  3. package/dist/custom-elements.json +215 -21
  4. package/dist/dts/genesis/config.d.ts +30 -6
  5. package/dist/dts/genesis/config.d.ts.map +1 -1
  6. package/dist/dts/genesis/consumes.d.ts.map +1 -1
  7. package/dist/dts/genesis/event-fields.d.ts.map +1 -1
  8. package/dist/dts/genesis/filter-fields.d.ts +31 -0
  9. package/dist/dts/genesis/filter-fields.d.ts.map +1 -1
  10. package/dist/dts/genesis/index.d.ts +3 -1
  11. package/dist/dts/genesis/index.d.ts.map +1 -1
  12. package/dist/dts/genesis/reference-check.d.ts +83 -0
  13. package/dist/dts/genesis/reference-check.d.ts.map +1 -0
  14. package/dist/dts/genesis/reference-existence.d.ts +110 -0
  15. package/dist/dts/genesis/reference-existence.d.ts.map +1 -0
  16. package/dist/dts/genesis/resource-tools.d.ts +4 -4
  17. package/dist/dts/genesis/resource-tools.d.ts.map +1 -1
  18. package/dist/dts/genesis/review-model.d.ts +2 -2
  19. package/dist/dts/genesis/review-model.d.ts.map +1 -1
  20. package/dist/dts/genesis/row-source.d.ts +32 -0
  21. package/dist/dts/genesis/row-source.d.ts.map +1 -1
  22. package/dist/dts/genesis/server-text.d.ts +29 -0
  23. package/dist/dts/genesis/server-text.d.ts.map +1 -1
  24. package/dist/dts/genesis/types.d.ts +32 -5
  25. package/dist/dts/genesis/types.d.ts.map +1 -1
  26. package/dist/dts/genesis/write-payload.d.ts +14 -1
  27. package/dist/dts/genesis/write-payload.d.ts.map +1 -1
  28. package/dist/dts/genesis/write-plan.d.ts +8 -2
  29. package/dist/dts/genesis/write-plan.d.ts.map +1 -1
  30. package/dist/dts/genesis/write-tools.d.ts +5 -3
  31. package/dist/dts/genesis/write-tools.d.ts.map +1 -1
  32. package/dist/dts/genesis/write-turn.d.ts +4 -1
  33. package/dist/dts/genesis/write-turn.d.ts.map +1 -1
  34. package/dist/dts/main/main.d.ts +0 -16
  35. package/dist/dts/main/main.d.ts.map +1 -1
  36. package/dist/dts/main/main.styles.d.ts.map +1 -1
  37. package/dist/dts/main/main.template.d.ts +4 -7
  38. package/dist/dts/main/main.template.d.ts.map +1 -1
  39. package/dist/esm/genesis/config.js +152 -20
  40. package/dist/esm/genesis/consumes.js +2 -1
  41. package/dist/esm/genesis/event-fields.js +5 -8
  42. package/dist/esm/genesis/filter-fields.js +159 -78
  43. package/dist/esm/genesis/index.js +1 -0
  44. package/dist/esm/genesis/reference-check.js +132 -0
  45. package/dist/esm/genesis/reference-existence.js +283 -0
  46. package/dist/esm/genesis/resource-tools.js +135 -18
  47. package/dist/esm/genesis/review-model.js +3 -1
  48. package/dist/esm/genesis/row-source.js +107 -16
  49. package/dist/esm/genesis/server-text.js +52 -0
  50. package/dist/esm/genesis/write-payload.js +32 -4
  51. package/dist/esm/genesis/write-plan.js +3 -2
  52. package/dist/esm/genesis/write-tools.js +248 -44
  53. package/dist/esm/main/main.js +0 -21
  54. package/dist/esm/main/main.styles.js +0 -25
  55. package/dist/esm/main/main.template.js +34 -76
  56. package/dist/genesis-consumes.cjs +3 -2
  57. package/dist/genesis-consumes.cjs.map +2 -2
  58. package/dist/genesis-consumes.mjs +3 -2
  59. package/dist/genesis-consumes.mjs.map +2 -2
  60. package/docs/genesis.md +131 -21
  61. package/docs/styling.md +0 -130
  62. package/package.json +17 -17
  63. package/scripts/smoke-genesis-consumes-node.mjs +2 -2
@@ -15,7 +15,7 @@
15
15
  * lines let the formatter inject whitespace between them.
16
16
  */
17
17
  import { isChatToolCallUnknown } from '@genesislcap/foundation-ai';
18
- import { classNames, html, ref, repeat, slotted, when } from '@genesislcap/web-core';
18
+ import { classNames, html, ref, repeat, when } from '@genesislcap/web-core';
19
19
  import { MARKDOWN_EXPORTPARTS } from '../components/chat-markdown/chat-markdown';
20
20
  import { SettingsModalTemplate } from '../components/settings-modal';
21
21
  import { SUGGESTIONS_EXPORTPARTS } from '../suggestions/chat-suggestions';
@@ -68,23 +68,20 @@ const messageType = (m) => {
68
68
  }
69
69
  };
70
70
  /**
71
- * The three names one element is exposed under: the bare name, a role-level name, and — on the
72
- * assistant side, whose rows vary — the message type. `rolePartsFor('avatar', 'ai-thinking')` is
73
- * `avatar avatar-assistant avatar-ai-thinking`.
71
+ * Part names for one avatar element: the bare name, a role-level name, and — on the assistant
72
+ * side, whose rows vary — the message type.
74
73
  *
75
74
  * The role-level name is the one an app usually wants. `messageType` splits the assistant across
76
75
  * `ai`, `ai-thinking`, `ai-function` and `interaction`, so without it "style the assistant's
77
- * rows, not the user's" takes four selectors and silently misses any type added later.
76
+ * avatar, not the user's" takes four selectors and silently misses any type added later.
78
77
  * `::part()` names cannot be chained, so each has to be a name of its own rather than a
79
78
  * combination. The user side needs no extra name — its role and its type are both `user`.
80
79
  *
81
- * Shared by the avatar and the message row so the two cannot drift.
82
- *
83
80
  * Exported for the unit test that pins the vocabulary; not part of the element API.
84
81
  *
85
82
  * @internal
86
83
  */
87
- export const rolePartsFor = (base, type) => type === 'user' ? `${base} ${base}-user` : `${base} ${base}-assistant ${base}-${type}`;
84
+ export const avatarPartsFor = (base, type) => type === 'user' ? `${base} ${base}-user` : `${base} ${base}-assistant ${base}-${type}`;
88
85
  // Avatar markup is owned by the component (`assistantIconSafe` / `userIconSafe`),
89
86
  // which holds the sanitized SVG string for the default or any consumer override
90
87
  // and is injected via `:innerHTML`. A raster `image-src` / `user-image-src`
@@ -107,13 +104,13 @@ const assistantAvatarMarkup = (parent, type) => parent.imageSrc
107
104
  src="${() => parent.imageSrc}"
108
105
  alt="Assistant"
109
106
  class="avatar-img"
110
- part="${() => rolePartsFor('avatar-img', type)}"
107
+ part="${() => avatarPartsFor('avatar-img', type)}"
111
108
  />
112
109
  `
113
110
  : html `
114
111
  <span
115
112
  class="avatar-icon"
116
- part="${() => rolePartsFor('avatar-icon', type)}"
113
+ part="${() => avatarPartsFor('avatar-icon', type)}"
117
114
  :innerHTML="${() => parent.assistantIconSafe}"
118
115
  ></span>
119
116
  `;
@@ -129,13 +126,13 @@ const userAvatarTemplate = html `
129
126
  src="${() => parent.userImageSrc}"
130
127
  alt="You"
131
128
  class="avatar-img"
132
- part="${() => rolePartsFor('avatar-img', 'user')}"
129
+ part="${() => avatarPartsFor('avatar-img', 'user')}"
133
130
  />
134
131
  `
135
132
  : html `
136
133
  <span
137
134
  class="avatar-icon"
138
- part="${() => rolePartsFor('avatar-icon', 'user')}"
135
+ part="${() => avatarPartsFor('avatar-icon', 'user')}"
139
136
  :innerHTML="${() => parent.userIconSafe}"
140
137
  ></span>
141
138
  `;
@@ -174,25 +171,6 @@ const messageParts = (m) => {
174
171
  ? `message message-interaction message-interaction-${interactionPresentation(m)}`
175
172
  : `message message-${type}`;
176
173
  };
177
- /**
178
- * Space-separated `part` names for a message ROW — the flex line that holds the avatar and the
179
- * bubble together.
180
- *
181
- * `messageParts` covers the bubble, not the line it sits on, so everything the row owns was
182
- * unreachable: its `flex-direction` (reversed for the user, a column for most interactions), its
183
- * `gap` between avatar and bubble, its `align-items`, and its entrance animation. An app wanting
184
- * to change the spacing of a conversation, or to drop the slide-in, had nothing to select.
185
- *
186
- * Names mirror `messageParts` exactly — same types, same interaction presentations — so the row
187
- * and the bubble are selected the same way, with `message-row` where `message` would be.
188
- */
189
- const messageRowParts = (m) => {
190
- const type = messageType(m);
191
- const names = rolePartsFor('message-row', type);
192
- return type === 'interaction'
193
- ? `${names} message-row-interaction-${interactionPresentation(m)}`
194
- : names;
195
- };
196
174
  /**
197
175
  * The timestamp shown beside the sender name (GENC-1257).
198
176
  *
@@ -596,11 +574,10 @@ ${(tc) => { var _a; return (((_a = tc.foldPath) === null || _a === void 0 ? void
596
574
  ${when((m) => m.role !== 'system-event' && m.role !== 'compacted-summary', html `
597
575
  <div
598
576
  class="message-row ${(m) => messageType(m)} ${(m) => m.interaction ? `present-${interactionPresentation(m)}` : ''}"
599
- part="${(m) => messageRowParts(m)}"
600
577
  >
601
578
  <div
602
579
  class="avatar ${(m) => messageType(m)}"
603
- part="${(m) => rolePartsFor('avatar', messageType(m))}"
580
+ part="${(m) => avatarPartsFor('avatar', messageType(m))}"
604
581
  >
605
582
  ${when(
606
583
  // Keyed on messageType (not raw role) so a synthetic-user message,
@@ -968,56 +945,37 @@ ${(tc) => { var _a; return (((_a = tc.foldPath) === null || _a === void 0 ? void
968
945
  <slot name="splash"></slot>
969
946
  </div>
970
947
 
971
- ${
972
- /* The conversation column: a slot for something alongside the messages (a stepper, in the
973
- case this was built for) and the scroll area, and NOTHING else. The splash overlay, the
974
- attachment chips, the blocked banner and the composer are all siblings of this container
975
- rather than of the messages, so an app can set a flex direction here and get exactly two
976
- boxes to lay out instead of the whole chat column.
977
-
978
- Always rendered, slot filled or not: an empty slot contributes no box, so the column
979
- behaves exactly as it did before this wrapper existed. */ ''}
980
- <div
981
- class="conversation"
982
- part="${(x) => (x.hasStepper ? 'conversation conversation-has-stepper' : 'conversation')}"
983
- >
984
- <slot
985
- name="stepper"
986
- ${slotted({ property: 'stepperNodes', filter: (n) => n.nodeType === Node.ELEMENT_NODE })}
987
- ></slot>
988
-
989
- <div class="messages" part="messages" ${ref('messagesEl')}>
990
- <div
991
- class="messages-content ${(x) => `timestamps-${x.timestampDisplay}`}"
992
- part="messages-content"
993
- >
994
- ${when((x) => x.compacting, compactingTemplate)}
995
- ${when((x) => x.restoring, restoringTemplate)}
996
- ${repeat((x) => (x.compacting || x.restoring ? [] : x.visibleMessages), messageRowTemplate)}
997
- ${
948
+ <div class="messages" part="messages" ${ref('messagesEl')}>
949
+ <div
950
+ class="messages-content ${(x) => `timestamps-${x.timestampDisplay}`}"
951
+ part="messages-content"
952
+ >
953
+ ${when((x) => x.compacting, compactingTemplate)}
954
+ ${when((x) => x.restoring, restoringTemplate)}
955
+ ${repeat((x) => (x.compacting || x.restoring ? [] : x.visibleMessages), messageRowTemplate)}
956
+ ${
998
957
  /* GENC-1429: recycle:false so each pending interaction gets a FRESH wrapper. With
999
- recycling, the trailing slot's wrapper is reused across interactions (e.g. a tool that
1000
- shows the code-diff approval, then the preview-status card): the reused wrapper still
1001
- carries the prior interaction's truthy `resolved` (bound last, after componentName/
1002
- interactionId trigger the re-render), so the completion listener's `if (this.resolved)
1003
- return` guard swallows the next auto-resolve widget's completion and the driver hangs
1004
- awaiting it. A fresh wrapper starts with resolved=undefined, so the guard is correct. */ ''}
1005
- ${repeat((x) => x.activeInteractionRow, messageRowTemplate, { recycle: false })}
1006
- ${when((x) => x.liveSubAgentTrace.length > 0 && x.showToolCalls, liveSubAgentTraceTemplate)}
1007
- ${when((x) => {
958
+ recycling, the trailing slot's wrapper is reused across interactions (e.g. a tool that
959
+ shows the code-diff approval, then the preview-status card): the reused wrapper still
960
+ carries the prior interaction's truthy `resolved` (bound last, after componentName/
961
+ interactionId trigger the re-render), so the completion listener's `if (this.resolved)
962
+ return` guard swallows the next auto-resolve widget's completion and the driver hangs
963
+ awaiting it. A fresh wrapper starts with resolved=undefined, so the guard is correct. */ ''}
964
+ ${repeat((x) => x.activeInteractionRow, messageRowTemplate, { recycle: false })}
965
+ ${when((x) => x.liveSubAgentTrace.length > 0 && x.showToolCalls, liveSubAgentTraceTemplate)}
966
+ ${when((x) => {
1008
967
  var _a;
1009
968
  return x.showLoadingIndicator &&
1010
969
  (((_a = x.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.animations) == null ||
1011
970
  LOADING_STYLE_ANIMATIONS.some((s) => x.enabledAnimations.includes(s)));
1012
971
  }, html `
1013
- <div class="message-row ai" part="thinking ${rolePartsFor('message-row', 'ai')}">
1014
- <div class="avatar ai" part="${rolePartsFor('avatar', 'ai')}">
1015
- ${(x) => assistantAvatarMarkup(x, 'ai')}
1016
- </div>
1017
- ${(x) => selectThinkingTemplate(x)}
972
+ <div class="message-row ai" part="thinking">
973
+ <div class="avatar ai" part="${avatarPartsFor('avatar', 'ai')}">
974
+ ${(x) => assistantAvatarMarkup(x, 'ai')}
1018
975
  </div>
1019
- `)}
1020
- </div>
976
+ ${(x) => selectThinkingTemplate(x)}
977
+ </div>
978
+ `)}
1021
979
  </div>
1022
980
  </div>
1023
981
 
@@ -23,14 +23,15 @@ __export(consumes_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(consumes_exports);
25
25
  var GENESIS_AI_CONSUMES = Object.freeze({
26
- kinds: Object.freeze(["request", "event"]),
26
+ kinds: Object.freeze(["request", "event", "query"]),
27
27
  resourceFields: Object.freeze([
28
28
  "name",
29
29
  "kind",
30
30
  "op",
31
31
  "context",
32
32
  "maxRows",
33
- "customCode"
33
+ "customCode",
34
+ "references"
34
35
  ]),
35
36
  vendors: Object.freeze(["anthropic", "gemini"]),
36
37
  tiers: Object.freeze(["low", "high", "reasoning"])
@@ -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([\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;",
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', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\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,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;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,13 +1,14 @@
1
1
  // src/genesis/consumes.ts
2
2
  var GENESIS_AI_CONSUMES = Object.freeze({
3
- kinds: Object.freeze(["request", "event"]),
3
+ kinds: Object.freeze(["request", "event", "query"]),
4
4
  resourceFields: Object.freeze([
5
5
  "name",
6
6
  "kind",
7
7
  "op",
8
8
  "context",
9
9
  "maxRows",
10
- "customCode"
10
+ "customCode",
11
+ "references"
11
12
  ]),
12
13
  vendors: Object.freeze(["anthropic", "gemini"]),
13
14
  tiers: Object.freeze(["low", "high", "reasoning"])
@@ -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([\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;",
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', 'query'] as const),\n resourceFields: Object.freeze([\n 'name',\n 'kind',\n 'op',\n 'context',\n 'maxRows',\n 'customCode',\n 'references',\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,SAAS,OAAO,CAAU;AAAA,EAC3D,gBAAgB,OAAO,OAAO;AAAA,IAC5B;AAAA,IACA;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
  }
package/docs/genesis.md CHANGED
@@ -7,7 +7,7 @@ model providers from the platform tier table, turns the app's resources into cha
7
7
  hands back one agent to bind to `<foundation-ai-assistant>`. It is what a generated app's mount
8
8
  code calls; the app supplies configuration, never a model id, endpoint or key.
9
9
 
10
- The API is `@beta`. Each `REQ_` resource becomes a read tool. An `EVENT_` resource becomes a write
10
+ The API is `@beta`. Each `REQ_` resource and each query becomes a read tool. An `EVENT_` resource becomes a write
11
11
  tool that shows the user every row it would write and commits only the ones they select, unless
12
12
  it is one of the shapes that get none (see [Write tools](#write-tools)).
13
13
 
@@ -90,7 +90,8 @@ that table, unless asked), then the extensions' prompt.
90
90
  "systemPrompt": "You help traders find and understand their trades.",
91
91
  "resources": [
92
92
  { "name": "REQ_TRADE", "kind": "request", "context": "Trades booked in the app.", "maxRows": 200 },
93
- { "name": "EVENT_TRADE_INSERT", "kind": "event", "op": "insert", "context": "Book a trade." }
93
+ { "name": "EVENT_TRADE_INSERT", "kind": "event", "op": "insert", "context": "Book a trade." },
94
+ { "name": "ALL_TRADES", "kind": "query", "context": "Live trades, as the trades grid shows them." }
94
95
  ]
95
96
  }
96
97
  ```
@@ -99,22 +100,23 @@ that table, unless asked), then the extensions' prompt.
99
100
  | -------------- | ------------------------------------------------------------------------------------------- |
100
101
  | `vendor` | A tier-table vendor. Defaults to `gemini`. |
101
102
  | `tier` | `low`, `high` or `reasoning`. Defaults to `high`. |
102
- | `name` | `REQ_<NAME>` or `EVENT_<NAME>`, unique; the tool name is the lowercased name (≤ 64 chars). |
103
- | `kind` | Must match the prefix: `request` for `REQ_`, `event` for `EVENT_`. |
103
+ | `name` | Unique; the tool name is the lowercased name (≤ 64 chars). `REQ_<NAME>` for a request, `EVENT_<NAME>` for an event, and for a query the dataserver query's own name in upper-case letters, digits and underscores. |
104
+ | `kind` | `request`, `event` or `query`. The kind decides which name rule applies, never the name: a query named `REQ_…` is still a query. |
104
105
  | `context` | Required. Becomes the tool description, so write it for the model. |
105
106
  | `op` | Events only: `insert`, `modify`, `delete` or `custom`. |
106
- | `maxRows` | Requests only: a whole number from 1 to 1000. Defaults to 50. |
107
+ | `maxRows` | Requests and queries: a whole number from 1 to 1000. Defaults to 50. |
107
108
  | `customCode` | Insert, modify and delete events only: the event's handler runs custom code. See [Custom code](#custom-code). |
109
+ | `references` | Inserts and modifies: the values that must match another table's row. See [Reference checks](#reference-checks). |
108
110
 
109
111
  A rule about the config **as a whole** — `enabled`, `vendor`, `tier`, `systemPrompt`, and
110
112
  `resources` being a list — blocks the assistant. A rule about **one resource** leaves that resource
111
113
  out and keeps the rest: it gets no tool, and the console names it and says why. A duplicated name
112
114
  leaves out every copy, since which one is meant is unknown. A `kind` this version does not read
113
- (`request` and `event`) is left out the same way. That keeps an app working when a newer generator
114
- emits one, but it is not support for it. If the config lists resources and every one of them is
115
- left out, the assistant runs on the app's extension tools, and the console names each resource
116
- left out. With no extension tool either, it is blocked: a chat that can reach nothing would still
117
- look like it works.
115
+ (it reads `request`, `event` and `query`) is left out the same way. That keeps an app working when
116
+ a newer generator emits one, but it is not support for it. If the config lists resources and every
117
+ one of them is left out, the assistant runs on the app's extension tools, and the console names
118
+ each resource left out. With no extension tool either, it is blocked: a chat that can reach nothing
119
+ would still look like it works.
118
120
 
119
121
  No `resources` at all, absent or `[]`, is accepted: an assistant whose tools all come from the
120
122
  app's extensions, or a chat helper with none, is a real configuration. It is also exactly what a
@@ -129,8 +131,8 @@ import { GENESIS_AI_CONSUMES } from '@genesislcap/ai-assistant/genesis/consumes'
129
131
 
130
132
  GENESIS_AI_CONSUMES;
131
133
  // {
132
- // kinds: ['request', 'event'],
133
- // resourceFields: ['name', 'kind', 'op', 'context', 'maxRows', 'customCode'],
134
+ // kinds: ['request', 'event', 'query'],
135
+ // resourceFields: ['name', 'kind', 'op', 'context', 'maxRows', 'customCode', 'references'],
134
136
  // vendors: ['anthropic', 'gemini'],
135
137
  // tiers: ['low', 'high', 'reasoning'],
136
138
  // }
@@ -161,7 +163,8 @@ equal to foundation-ai's `AI_TIER_VENDORS` and `AI_TIER_IDS`, which the validato
161
163
 
162
164
  ## Read tools
163
165
 
164
- A `REQ_TRADE` resource becomes the tool `req_trade` with two optional parameters:
166
+ A `REQ_TRADE` resource becomes the tool `req_trade`, and a dataserver query `ALL_TRADES` the tool
167
+ `all_trades` (see [Query reads](#query-reads)). Both take two optional parameters:
165
168
 
166
169
  - `filters` — a list of `{field, op, value}`, all of which must match.
167
170
  - `max_rows` — clamped to the resource's `maxRows`; the resource default when omitted.
@@ -181,7 +184,8 @@ free-text criteria parameter.**
181
184
  reply's fields are what can be filtered on: `REPLY_FIELD`, or `REPLY.FIELD` on a class-typed
182
185
  `requestReply<Input, Output>`. A top-level `FIELD` there describes the **input** class and is
183
186
  never read as the reply. Types and any `VALID_VALUES` come from the same reply. A resource that
184
- describes no fields gets a tool with no `filters` parameter.
187
+ describes no fields gets a tool with no `filters` parameter, and so does a request whose
188
+ metadata comes back as a dataserver's (`TYPE: DATASERVER`), which is never read as a request's.
185
189
  - A field whose allowed values cannot be read — an `ENUM` with no values, or a `VALID_VALUES`
186
190
  that is neither an array nor a pipe-separated string, or a list with any member that does not
187
191
  read — is **not offered as a filter**, and the console names it. Offered without its list, a
@@ -211,13 +215,44 @@ A read never throws. Every result carries `source: 'app-database'` and `untruste
211
215
  { source, untrusted, resource, rows, truncated, note? }
212
216
  // failure
213
217
  { source, untrusted, resource,
214
- error: 'not_connected' | 'invalid_filter' | 'rejected' | 'request_failed', message }
218
+ error: 'not_connected' | 'invalid_filter' | 'rejected' | 'request_failed' | 'unexpected_shape',
219
+ message }
215
220
  ```
216
221
 
217
- `truncated` is the server's `MORE_ROWS` when it sends one; otherwise the rule the platform's own
218
- request datasource uses (an advancing `NEXT_OFFSET` or a full page means there may be more). A
219
- truncated result carries a `note` telling the model these rows are not the full set, and what it
220
- can do: narrow with filters when the tool has any, raise `max_rows` when it is below the cap.
222
+ `truncated` means these rows may not be the full set. For a request it is the server's `MORE_ROWS`
223
+ when it sends one; otherwise the rule the platform's own request datasource uses (an advancing
224
+ `NEXT_OFFSET` or a full page means there may be more). A truncated result carries a `note` telling
225
+ the model these rows are not the full set, and what it can do: narrow with filters when the tool has
226
+ any, raise `max_rows` when it is below the cap.
227
+
228
+ ### Query reads
229
+
230
+ A `kind: 'query'` resource reads a dataserver query once. The bridge sends one `DATA_LOGON` with
231
+ `MAX_ROWS` (always: the server's own default is 250) and the filters' `CRITERIA_MATCH`, and nothing
232
+ else a dataserver takes. The socket logs off on the first update. Filters, `max_rows` and the
233
+ untrusted stamp work as they do for a request.
234
+
235
+ - The query's metadata is fetched under its name exactly as configured, and its fields are the
236
+ dataserver's top-level `FIELD` list. Every typed field of a filterable type, with readable
237
+ allowed values, is offered as a filter; one the server cannot filter on is refused in the
238
+ server's own words.
239
+ - The reply is read as a `QUERY_UPDATE` (`QUERY_HTTP_UPDATE` is also accepted). No `ROW` is an
240
+ empty result only when the reply carries `MORE_ROWS`. Any other shape, or a row that is not an
241
+ `INSERT`, is `error: 'unexpected_shape'`, never zero rows.
242
+ - `MORE_ROWS` is the only truncation signal, and a reply that does not say reads as truncated, with
243
+ a note saying so. `ROWS_COUNT` is never read: it counts an index range and ignores the criteria
244
+ and the user's rights. Rows are also cut to `max_rows` in the bridge.
245
+ - A refusal (no such query, a right the user lacks, a criteria the server rejects) reaches the model
246
+ in the app's own words unless it reads like compiler output. A connection failure is
247
+ `request_failed`, never a refusal.
248
+ - A read the app never answers ends as `request_failed`, without inviting a retry. Known limit: the
249
+ bridge cannot log off a read that timed out, so its server subscription stays open until the
250
+ socket closes.
251
+ - The dataserver's `ROW_REF` is taken off each row, so a query row carries no column a request row
252
+ of that record lacks, apart from fields the query itself declares.
253
+ - A query is never a write's row source, even one named `REQ_<T>`: a dataserver's cache can lag the
254
+ very change a staleness check exists to catch. See
255
+ [A modify needs somewhere to read its rows from](#a-modify-needs-somewhere-to-read-its-rows-from).
221
256
 
222
257
  `createGenesisResourceTools(resources, { connect })` builds the same tools without registering
223
258
  anything, for an app that assembles its own agent.
@@ -306,8 +341,8 @@ return any text, including a perfect copy of a write result. The key is random,
306
341
  return, so nothing that stores or returns data can know it. A session replayed from an earlier
307
342
  registration carries an older key, and its feedback then reads as data. An app with no event
308
343
  that could get a write tool carries no exception in its prompt at all. That includes an app whose
309
- events the config itself refuses: a `custom` op, a `rowSources` entry naming another source, or a
310
- modify or delete whose table's `REQ_` was left out. The metadata read later can still withhold a
344
+ events the config itself refuses: a `custom` op, a `rowSources` entry naming another source, a
345
+ malformed `references`, or a modify or delete whose table's `REQ_` was left out. The metadata read later can still withhold a
311
346
  tool from an event the config allows, and that cannot be known at registration.
312
347
  `createGenesisWriteTools` returns these events as `writableEvents`.
313
348
 
@@ -490,6 +525,10 @@ name that matches an existing entity, view or query.
490
525
  - An **insert that requires a `NANO_TIMESTAMP`**. Its unit has not been confirmed on a live app,
491
526
  so a model may not set one. A modify carries the row's own value through unchanged, and is
492
527
  refused if a JSON number cannot hold that value exactly.
528
+ - An **insert with a required field whose reference cannot be checked**, and an insert or modify
529
+ whose every settable field is one. See [Reference checks](#reference-checks).
530
+ - An **insert or modify with a reference whose target cannot be described right now**: no write
531
+ tool yet, and it is asked again next turn.
493
532
 
494
533
  An event with no usable row source **gets no tool at all**, and the console says why, as the write
495
534
  tools are built (before `registerGenesisAssistant` returns). When the
@@ -501,6 +540,76 @@ unless asking again could help — a request that failed, or a metadata reply th
501
540
  (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,
502
541
  and the tool list should be a true map of what the assistant can do.
503
542
 
543
+ ### Reference checks
544
+
545
+ Nothing in a generated app checks that a `COUNTERPARTY_ID` names a counterparty: its handlers
546
+ write what they are sent. So an insert or a modify declares the values that must match another
547
+ table's row, and the assistant checks them itself:
548
+
549
+ ```json
550
+ {
551
+ "name": "EVENT_TRADE_INSERT",
552
+ "kind": "event",
553
+ "op": "insert",
554
+ "context": "Book a trade.",
555
+ "references": [
556
+ {
557
+ "resource": "REQ_COUNTERPARTY",
558
+ "fields": [{ "field": "COUNTERPARTY_ID", "targetField": "COUNTERPARTY_ID" }]
559
+ }
560
+ ]
561
+ }
562
+ ```
563
+
564
+ Each group names the target table's own `REQ_` and pairs this write's fields with the target's. A
565
+ group of several pairs must match one row on all of them. A malformed `references` leaves the
566
+ resource out, with a warning, like any other rule about one resource.
567
+
568
+ **Before the review**, every value a row sets is looked up through that read. A value that
569
+ matches no row the user can see refuses the row, and the model is told which read to copy it
570
+ from; a value that could not be looked up refuses it too. A refused row is shown in the review
571
+ but cannot be ticked. Each distinct value is read once per call, at most four at a time, all under
572
+ one 30-second deadline. A call that needs more than 50 lookups is
573
+ refused whole, and the tool description says so. A modify looks up only the references it
574
+ changes, so a row that already points at something gone stays editable while nobody touches that
575
+ field. A composite reference with some parts empty is refused; with every part empty it is no
576
+ reference, and nothing is looked up.
577
+
578
+ **As each row is written**, its references are looked up again beside the row's own staleness
579
+ read. One that no longer matches reports `reference_gone`, and nothing is written for that row.
580
+ The rows after it still go ahead.
581
+
582
+ "A row the user can see" is meant exactly: the lookup runs as the user, so a row their
583
+ permissions hide reads as missing. Writing a reference through the assistant needs the view
584
+ right on the **target** table as well as the right to write this one.
585
+
586
+ What is not checked, or cannot be:
587
+
588
+ - **A target that cannot be described right now**: its metadata request timed out, the
589
+ connection dropped, or the app refused it (which reaches the assistant as a failed request
590
+ today). The insert or modify has no write tool yet, and it is asked again next turn.
591
+ - **A reference that cannot be checked is never offered as though it were.** That is a target
592
+ read the config does not have, one whose metadata came back as an error, a target field it cannot be
593
+ searched by, a field this write does not declare, or two fields holding different kinds of
594
+ value. On an insert, a required one costs the event its tool, and an optional one is left out:
595
+ a value sent anyway is refused by name. On a modify the row's value is kept, and a new one is
596
+ refused. The console says which and why, once.
597
+ - **A target field that is a `DATE` or `DATETIME`.** A timestamp cannot be matched exactly, and
598
+ a date's time zone has not been confirmed. Such a reference is treated as one that cannot be
599
+ checked.
600
+ - **Rows proposed in the same batch do not count yet.** A row whose reference names another row
601
+ of the same call, or its own generated key, is refused. Write the parent first, in its own
602
+ review.
603
+ - **The first row of a required reference to its own table**, such as a `MANAGER_ID` every
604
+ employee must have, cannot be inserted through the chat: there is no parent yet, and a row
605
+ pointing at its own key reads as missing.
606
+ - **No `references` at all**, as in a config from before they existed: nothing is checked, and
607
+ the console says so once. An empty list declares none and says nothing.
608
+ - **Writes through MCP.** The check is the chat's own.
609
+
610
+ The model is told what is checked: a checked field's description says which row it must match,
611
+ and the tool's description lists the checked references and the 50-value cap.
612
+
504
613
  ### Reading the result
505
614
 
506
615
  The result's `decision` is what the user answered: `approved`, `denied`, `changes_requested` or
@@ -517,6 +626,7 @@ one — that is how a row gets written twice.
517
626
  | `not_selected` | The user did not tick it. Nothing was sent. |
518
627
  | `invalid_payload` | Refused before the review, or the server found the details malformed. |
519
628
  | `changed_since_review` | Somebody changed the row while the review was open. Nothing was sent. |
629
+ | `reference_gone` | A reference it sets matched no row when it was written. Nothing was sent. |
520
630
  | `gone` | The row a modify or delete named no longer exists. |
521
631
  | `duplicate` | A record with that key already exists. |
522
632
  | `refused_by_app` | The app's own validation said no. Nothing to retry. |