@genesislcap/ai-assistant 15.44.0 → 15.45.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 (39) hide show
  1. package/dist/ai-assistant.api.json +34 -19
  2. package/dist/ai-assistant.d.ts +36 -2
  3. package/dist/chat-driver.cjs +89 -10
  4. package/dist/chat-driver.cjs.map +2 -2
  5. package/dist/chat-driver.mjs +89 -10
  6. package/dist/chat-driver.mjs.map +2 -2
  7. package/dist/custom-elements.json +128 -6
  8. package/dist/dts/components/chat-driver/chat-driver.d.ts +15 -2
  9. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  10. package/dist/dts/components/chat-driver/interaction-controller.d.ts +26 -3
  11. package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
  12. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +6 -0
  13. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
  14. package/dist/dts/genesis/review-model.d.ts +50 -0
  15. package/dist/dts/genesis/review-model.d.ts.map +1 -1
  16. package/dist/dts/genesis/write-review/write-review.d.ts +15 -1
  17. package/dist/dts/genesis/write-review/write-review.d.ts.map +1 -1
  18. package/dist/dts/genesis/write-review/write-review.styles.d.ts.map +1 -1
  19. package/dist/dts/genesis/write-review/write-review.template.d.ts.map +1 -1
  20. package/dist/dts/genesis/write-tools.d.ts +6 -1
  21. package/dist/dts/genesis/write-tools.d.ts.map +1 -1
  22. package/dist/dts/main/main.template.d.ts +8 -0
  23. package/dist/dts/main/main.template.d.ts.map +1 -1
  24. package/dist/dts/state/debug-event-log.d.ts +1 -1
  25. package/dist/dts/state/debug-event-log.d.ts.map +1 -1
  26. package/dist/dts/types/ai-chat-widget.d.ts +7 -0
  27. package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
  28. package/dist/esm/components/chat-driver/chat-driver.js +39 -6
  29. package/dist/esm/components/chat-driver/interaction-controller.js +50 -4
  30. package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +17 -6
  31. package/dist/esm/genesis/review-model.js +78 -0
  32. package/dist/esm/genesis/write-review/write-review.js +70 -19
  33. package/dist/esm/genesis/write-review/write-review.styles.js +5 -2
  34. package/dist/esm/genesis/write-review/write-review.template.js +10 -1
  35. package/dist/esm/genesis/write-tools.js +14 -2
  36. package/dist/esm/main/main.template.js +19 -10
  37. package/dist/esm/state/debug-event-log.js +4 -0
  38. package/docs/genesis.md +11 -1
  39. package/package.json +18 -18
@@ -70,6 +70,14 @@ export declare const messageTimestampTemplate: ViewTemplate<ChatMessage, Foundat
70
70
  * @internal
71
71
  */
72
72
  export declare const blockedBannerClasses: (x: FoundationAiAssistant) => string;
73
+ /**
74
+ * A message's interaction widget, in the wrapper that mounts it. Everything the widget is shown
75
+ * comes from the history message through here, the outcome a tool recorded after the answer
76
+ * included, so a remount, a pop-out and a reload all show the same thing.
77
+ *
78
+ * @internal
79
+ */
80
+ export declare const interactionWrapperTemplate: ViewTemplate<ChatMessage, FoundationAiAssistant>;
73
81
  /**
74
82
  * Id of the blocked banner, referenced by the composer controls'
75
83
  * `aria-describedby`. Shadow-DOM-scoped, so a fixed string cannot collide with
@@ -1 +1 @@
1
- {"version":3,"file":"main.template.d.ts","sourceRoot":"","sources":["../../../src/main/main.template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEV,WAAW,EAGZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAuC,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAU1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAkDpD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAC4B,CAAC;AAsGzF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,kDAWpC,CAAC;AAo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CAAC"}
@@ -28,7 +28,7 @@ import type { TurnFailureReason } from '@genesislcap/foundation-ai';
28
28
  * Catalogue of meta event names. This is the documented surface — extend it as
29
29
  * new events are wired in (Tier 2/3 lifecycle, interaction, provider events).
30
30
  */
31
- export type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'routing.decided' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'interaction.external-cost' | 'interaction.external-cost-dropped' | 'external-diagnostics.folded' | 'context.updated' | 'context.threshold-crossed' | 'context.compacted' | 'context.condensed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed' | 'session.cleared' | 'session.switched' | 'session.switch-deferred' | 'persistence.toggled' | 'persistence.saved' | 'persistence.save-failed' | 'persistence.suppressed' | 'persistence.not-resumable' | 'persistence.restored' | 'persistence.restore-orphan';
31
+ export type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'routing.decided' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'interaction.external-cost' | 'interaction.external-cost-dropped' | 'interaction.outcome' | 'interaction.outcome-dropped' | 'external-diagnostics.folded' | 'context.updated' | 'context.threshold-crossed' | 'context.compacted' | 'context.condensed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed' | 'session.cleared' | 'session.switched' | 'session.switch-deferred' | 'persistence.toggled' | 'persistence.saved' | 'persistence.save-failed' | 'persistence.suppressed' | 'persistence.not-resumable' | 'persistence.restored' | 'persistence.restore-orphan';
32
32
  /**
33
33
  * How much a reader should care about an event — lets a consumer (or an AI
34
34
  * agent) filter the timeline: skip `low` UI/bookkeeping noise, skim `normal`
@@ -1 +1 @@
1
- {"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAErB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GAEjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAEhB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GAEjB,iBAAiB,GACjB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,mBAAmB,GAEnB,uBAAuB,GACvB,sBAAsB,GACtB,2BAA2B,GAC3B,mCAAmC,GAEnC,6BAA6B,GAE7B,iBAAiB,GACjB,2BAA2B,GAC3B,mBAAmB,GACnB,mBAAmB,GAEnB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GAEpB,iBAAiB,GACjB,kBAAkB,GAClB,yBAAyB,GACzB,qBAAqB,GACrB,mBAAmB,GACnB,yBAAyB,GACzB,wBAAwB,GACxB,2BAA2B,GAC3B,sBAAsB,GACtB,4BAA4B,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAwD5E,C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,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
1
+ {"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAErB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GAEjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAEhB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GAEjB,iBAAiB,GACjB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,mBAAmB,GAEnB,uBAAuB,GACvB,sBAAsB,GACtB,2BAA2B,GAC3B,mCAAmC,GACnC,qBAAqB,GACrB,6BAA6B,GAE7B,6BAA6B,GAE7B,iBAAiB,GACjB,2BAA2B,GAC3B,mBAAmB,GACnB,mBAAmB,GAEnB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GAEpB,iBAAiB,GACjB,kBAAkB,GAClB,yBAAyB,GACzB,qBAAqB,GACrB,mBAAmB,GACnB,yBAAyB,GACzB,wBAAwB,GACxB,2BAA2B,GAC3B,sBAAsB,GACtB,4BAA4B,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,aAAa,EAAE,mBAAmB,CA4D5E,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,0EA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<TData = unknown, TResult = unknown> = {
31
31
  data: TData;
32
32
  /** The interaction outcome. */
33
33
  result: InteractionResult<TResult>;
34
+ /**
35
+ * What came of the answer, when the tool that opened the widget recorded it afterwards (see
36
+ * `recordInteractionOutcome` on the tool handler context): which rows a write review's
37
+ * approval actually wrote, say. Absent until then, and for a tool that records none.
38
+ * Display-only: the widget shows it, and it is never sent to a model.
39
+ */
40
+ outcome?: unknown;
34
41
  };
35
42
  /**
36
43
  * Interface that AI inline interaction components implement. The
@@ -1 +1 @@
1
- {"version":3,"file":"ai-chat-widget.d.ts","sourceRoot":"","sources":["../../../src/types/ai-chat-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IAC5D;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,4CAA4C;IAC5C,IAAI,EAAE,KAAK,CAAC;IACZ;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,GACD;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,wDAAwD;IACxD,IAAI,EAAE,KAAK,CAAC;IACZ,+BAA+B;IAC/B,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;CACpC,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC9D,qFAAqF;IACrF,aAAa,EAAE,MAAM,CAAC;IAEtB,2DAA2D;IAC3D,WAAW,EAAE,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CAChD"}
1
+ {"version":3,"file":"ai-chat-widget.d.ts","sourceRoot":"","sources":["../../../src/types/ai-chat-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,IAC5D;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,4CAA4C;IAC5C,IAAI,EAAE,KAAK,CAAC;IACZ;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,GACD;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,wDAAwD;IACxD,IAAI,EAAE,KAAK,CAAC;IACZ,+BAA+B;IAC/B,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC9D,qFAAqF;IACrF,aAAa,EAAE,MAAM,CAAC;IAEtB,2DAA2D;IAC3D,WAAW,EAAE,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CAChD"}
@@ -1564,8 +1564,8 @@ export class ChatDriver extends EventTarget {
1564
1564
  * resolves through) the parent's history and pending map. Calls chain
1565
1565
  * naturally: a grandchild → child → root.
1566
1566
  */
1567
- setHostInteractionRequester(fn) {
1568
- this.interactions.setHostRequester(fn);
1567
+ setHostInteractionRequester(fn, recordOutcome) {
1568
+ this.interactions.setHostRequester(fn, recordOutcome);
1569
1569
  }
1570
1570
  /**
1571
1571
  * Request a custom UI interaction. Emits a new message with the interaction.
@@ -1586,11 +1586,25 @@ export class ChatDriver extends EventTarget {
1586
1586
  * and `presentation` to control whether the host wraps the widget in a chat
1587
1587
  * bubble and/or shows the "Assistant" label.
1588
1588
  */
1589
- requestInteraction(componentName, data, options) {
1589
+ requestInteraction(componentName, data, options, onOpened) {
1590
1590
  return __awaiter(this, void 0, void 0, function* () {
1591
- return this.interactions.request(componentName, data, options);
1591
+ return this.interactions.request(componentName, data, options, onOpened);
1592
1592
  });
1593
1593
  }
1594
+ /**
1595
+ * Record what came of an interaction, after it resolved, on its history message
1596
+ * (`interaction.outcome`): handed to its widget and persisted with the session, never sent to a
1597
+ * model. Routed to the host driver when the interaction lives there (a sub-agent's). `false`,
1598
+ * changing nothing, when it is unknown, still pending, or the value cannot be stored as JSON.
1599
+ *
1600
+ * Tool handlers reach this through `recordInteractionOutcome` on their context, which binds it
1601
+ * to the interaction that call opened: see `buildHandlerContext`.
1602
+ *
1603
+ * @internal
1604
+ */
1605
+ recordInteractionOutcome(interactionId, outcome) {
1606
+ return this.interactions.recordOutcome(interactionId, outcome);
1607
+ }
1594
1608
  /**
1595
1609
  * Add external (non-LLM) spend to an interaction's message AFTER it has resolved — for a widget
1596
1610
  * that resolves early so the assistant stops waiting, then keeps doing paid work on the user's
@@ -1741,7 +1755,24 @@ export class ChatDriver extends EventTarget {
1741
1755
  */
1742
1756
  buildHandlerContext(activeToolCallId, traceCapture) {
1743
1757
  var _a;
1744
- return Object.assign(Object.assign({ requestInteraction: (componentName, data, options) => this.requestInteraction(componentName, data, options),
1758
+ // The interaction THIS call opened, if any: the only one its `recordInteractionOutcome` can
1759
+ // reach, so a tool can never write an outcome onto a widget another tool opened.
1760
+ let opened;
1761
+ let recorded = false;
1762
+ return Object.assign(Object.assign({ requestInteraction: (componentName, data, options) => this.requestInteraction(componentName, data, options, (interactionId) => {
1763
+ opened = interactionId;
1764
+ }), recordInteractionOutcome: (outcome) => {
1765
+ var _a;
1766
+ if (!opened)
1767
+ return false;
1768
+ if (recorded) {
1769
+ logger.warn(`ChatDriver(${(_a = this.activeAgentName) !== null && _a !== void 0 ? _a : 'unknown'}): recordInteractionOutcome called ` +
1770
+ 'more than once in one tool call — ignoring');
1771
+ return false;
1772
+ }
1773
+ recorded = true;
1774
+ return this.recordInteractionOutcome(opened, outcome);
1775
+ },
1745
1776
  // The MESSAGE's scope: one object per `sendMessage`, kept across a handoff's continuation
1746
1777
  // and handed to a sub-agent, and aborted by `cancel()` as well as a dispose. Not the
1747
1778
  // per-request `turnController`, which every continuation replaces.
@@ -1876,7 +1907,9 @@ export class ChatDriver extends EventTarget {
1876
1907
  // parent's (ultimately the root's) history and resolve via the same
1877
1908
  // pending map the main UI is wired to. Recurses naturally for nested
1878
1909
  // sub-agents.
1879
- child.setHostInteractionRequester((componentName, data, opts) => this.requestInteraction(componentName, data, opts));
1910
+ child.setHostInteractionRequester((componentName, data, opts, onOpened) => this.requestInteraction(componentName, data, opts, onOpened),
1911
+ // An outcome goes where its interaction went.
1912
+ (interactionId, outcome) => this.recordInteractionOutcome(interactionId, outcome));
1880
1913
  // The same route for a refusal the child absorbs, so the user sees it in the root transcript.
1881
1914
  child.hostAIServiceNotice = (code) => this.noticeAIServiceRefusal(code);
1882
1915
  const forwardTrace = (e) => {
@@ -28,13 +28,17 @@ export class InteractionController {
28
28
  this.contexts = new Map();
29
29
  }
30
30
  /** See `ChatDriver.setHostInteractionRequester`. */
31
- setHostRequester(fn) {
31
+ setHostRequester(fn, recordOutcome) {
32
32
  this.hostRequester = fn;
33
+ this.hostOutcome = recordOutcome;
33
34
  }
34
- /** See `ChatDriver.requestInteraction`. */
35
- request(componentName, data, options) {
35
+ /**
36
+ * See `ChatDriver.requestInteraction`. `onOpened` is told the id of the interaction this call
37
+ * opens, wherever it opens it, so the caller can later record its outcome and no other's.
38
+ */
39
+ request(componentName, data, options, onOpened) {
36
40
  if (this.hostRequester) {
37
- return this.hostRequester(componentName, data, options);
41
+ return this.hostRequester(componentName, data, options, onOpened);
38
42
  }
39
43
  if (this.pending.size > 0) {
40
44
  throw new Error('requestInteraction: another user interaction is already in flight. ' +
@@ -42,6 +46,7 @@ export class InteractionController {
42
46
  'rather than spawning widgets from parallel sub-agents or parallel tool calls.');
43
47
  }
44
48
  const interactionId = crypto.randomUUID();
49
+ onOpened === null || onOpened === void 0 ? void 0 : onOpened(interactionId);
45
50
  const chatInputDuringExecution = options === null || options === void 0 ? void 0 : options.chatInputDuringExecution;
46
51
  const timeoutMs = options === null || options === void 0 ? void 0 : options.timeoutMs;
47
52
  const presentation = options === null || options === void 0 ? void 0 : options.presentation;
@@ -226,6 +231,47 @@ export class InteractionController {
226
231
  }));
227
232
  return true;
228
233
  }
234
+ /**
235
+ * See `ChatDriver.recordInteractionOutcome`.
236
+ *
237
+ * @remarks
238
+ * Only once the interaction has resolved: an outcome is what came of an answer. The message is
239
+ * REPLACED, as `resolve` replaces it, never changed in place — the host's store freezes what it
240
+ * holds. The value is copied as JSON, the form it is persisted in, so what the widget shows now
241
+ * is what a reload shows, and nothing the caller keeps can change it afterwards.
242
+ *
243
+ * Announced on `history-updated`, unlike `recordExternalCost`: the outcome changes what the
244
+ * widget shows, so the resolved widget has to be rebuilt with it.
245
+ */
246
+ recordOutcome(interactionId, outcome) {
247
+ if (this.hostOutcome)
248
+ return this.hostOutcome(interactionId, outcome);
249
+ const drop = (reason) => {
250
+ recordMetaEvent(this.deps.sessionKey, 'interaction.outcome-dropped', {
251
+ interactionId,
252
+ reason,
253
+ });
254
+ return false;
255
+ };
256
+ if (this.pending.has(interactionId))
257
+ return drop('interaction not resolved');
258
+ let copy;
259
+ try {
260
+ const json = JSON.stringify(outcome);
261
+ if (json === undefined)
262
+ return drop('no value to store');
263
+ copy = JSON.parse(json);
264
+ }
265
+ catch (_a) {
266
+ return drop('not storable as JSON');
267
+ }
268
+ const patched = this.deps.patchInteractionMessage(interactionId, (message) => (Object.assign(Object.assign({}, message), { interaction: Object.assign(Object.assign({}, message.interaction), { outcome: copy }) })));
269
+ if (!patched)
270
+ return drop('interaction message no longer in history');
271
+ recordMetaEvent(this.deps.sessionKey, 'interaction.outcome', { interactionId });
272
+ this.deps.notifyHistoryUpdated();
273
+ return true;
274
+ }
229
275
  /** See `ChatDriver.getInteractionContext`. */
230
276
  context(interactionId) {
231
277
  var _a;
@@ -20,6 +20,8 @@ let AiChatInteractionWrapper = class AiChatInteractionWrapper extends GenesisEle
20
20
  this.interactionId = '';
21
21
  /** The resolved result once the interaction has completed. Forwarded to the rendered component. @internal */
22
22
  this.resolved = undefined;
23
+ /** See `AiChatInteraction`'s resolved `outcome`: recorded after the answer, by the tool. */
24
+ this.outcome = undefined;
23
25
  }
24
26
  connectedCallback() {
25
27
  super.connectedCallback();
@@ -54,14 +56,21 @@ let AiChatInteractionWrapper = class AiChatInteractionWrapper extends GenesisEle
54
56
  // in place, preserving its DOM/state (no re-create). If no matching element exists
55
57
  // yet (e.g. a history re-render straight into the resolved state), render it fresh.
56
58
  if (element && ((_b = element.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === this.componentName) {
57
- if (this.resolved) {
58
- element.interaction = { status: 'resolved', data: this.data, result: this.resolved };
59
- }
59
+ if (this.resolved)
60
+ element.interaction = this.resolvedInteraction();
60
61
  }
61
62
  else if (this.resolved) {
62
63
  this.renderComponent();
63
64
  }
64
65
  }
66
+ /** An outcome recorded after the answer reaches a widget already showing that answer. */
67
+ outcomeChanged() {
68
+ this.resolvedChanged();
69
+ }
70
+ /** The resolved descriptor, with the outcome when one has been recorded. */
71
+ resolvedInteraction() {
72
+ return Object.assign({ status: 'resolved', data: this.data, result: this.resolved }, (this.outcome !== undefined ? { outcome: this.outcome } : {}));
73
+ }
65
74
  /**
66
75
  * Watch the rendered widget element for box-size changes. When the widget
67
76
  * grows or shrinks mid-lifecycle (e.g. expanding a "More info" panel,
@@ -162,9 +171,8 @@ let AiChatInteractionWrapper = class AiChatInteractionWrapper extends GenesisEle
162
171
  */
163
172
  buildInteraction(host) {
164
173
  var _a;
165
- if (this.resolved) {
166
- return { status: 'resolved', data: this.data, result: this.resolved };
167
- }
174
+ if (this.resolved)
175
+ return this.resolvedInteraction();
168
176
  // Pending. The driver creates a live context for EVERY pending interaction BEFORE the widget
169
177
  // mounts, returns the SAME instance on every remount, and drops it the instant the interaction
170
178
  // resolves (see `ChatDriver.resolveInteraction`). So a MISSING context is not "pending, context
@@ -202,6 +210,9 @@ __decorate([
202
210
  __decorate([
203
211
  observable
204
212
  ], AiChatInteractionWrapper.prototype, "resolved", void 0);
213
+ __decorate([
214
+ observable
215
+ ], AiChatInteractionWrapper.prototype, "outcome", void 0);
205
216
  AiChatInteractionWrapper = __decorate([
206
217
  customElement({
207
218
  name: 'ai-chat-interaction-wrapper',
@@ -335,3 +335,81 @@ export function reviewDecisionOf(result, model) {
335
335
  export const selectedRows = (model, selection) => model.rows
336
336
  .filter((row) => { var _a; return selection.has(row.index) && !((_a = row.problems) === null || _a === void 0 ? void 0 : _a.length); })
337
337
  .map((row) => ({ index: row.index, details: row.details }));
338
+ /**
339
+ * A recorded outcome as the review can use it, or nothing.
340
+ *
341
+ * @remarks
342
+ * It comes back from history — a saved session, a later version's shape — so it is read, not
343
+ * trusted: a row that does not have its three fields is left out rather than shown wrong.
344
+ *
345
+ * @internal
346
+ */
347
+ export function reviewOutcomeFrom(value) {
348
+ if (!value || typeof value !== 'object')
349
+ return undefined;
350
+ const { stopped, rows } = value;
351
+ if (typeof stopped !== 'boolean' || !Array.isArray(rows))
352
+ return undefined;
353
+ return {
354
+ stopped,
355
+ rows: rows
356
+ .filter((row) => row &&
357
+ typeof row.index === 'number' &&
358
+ typeof row.status === 'string' &&
359
+ typeof row.message === 'string')
360
+ .map(({ index, status, message }) => ({ index, status, message })),
361
+ };
362
+ }
363
+ /**
364
+ * What a stopped write's closed review says: how many of its approved rows were written.
365
+ *
366
+ * @remarks
367
+ * Counted in three, never two: a row that was sent and got no answer (`unknown`) may well have
368
+ * been written, and counting it as not written is how a record gets written twice.
369
+ *
370
+ * @internal
371
+ */
372
+ export function stoppedSummary(outcome) {
373
+ const written = outcome.rows.filter((row) => row.status === 'written').length;
374
+ const unknown = outcome.rows.filter((row) => row.status === 'unknown').length;
375
+ const notWritten = outcome.rows.length - written - unknown;
376
+ return (`Stopped while writing: ${written} written, ${notWritten} not written` +
377
+ `${unknown ? `, ${unknown} may have been written` : ''}.`);
378
+ }
379
+ /**
380
+ * What an approved row's mark says, from its recorded fate, in words for the user.
381
+ *
382
+ * @remarks
383
+ * A fate's `message` is written for the MODEL ("Read it again before proposing…"), so it is shown
384
+ * only where it carries the app's or the database's own refusal, which is the reason the user
385
+ * needs. A status this version does not know is marked as possibly written: the safe end, since
386
+ * a row counted as not written is one a user may write twice.
387
+ *
388
+ * @internal
389
+ */
390
+ export function rowFate(fate) {
391
+ switch (fate.status) {
392
+ case 'written':
393
+ return 'written';
394
+ case 'checked':
395
+ return 'checked, not written';
396
+ case 'stopped':
397
+ return 'not written (stopped)';
398
+ case 'changed_since_review':
399
+ return 'not written (changed since the review)';
400
+ case 'gone':
401
+ return 'not written (row changed or no longer exists)';
402
+ case 'invalid_payload':
403
+ return 'not written (not valid)';
404
+ case 'unavailable':
405
+ return 'not written (the app cannot take this action)';
406
+ case 'failed':
407
+ return 'not written (not sent)';
408
+ case 'refused_by_app':
409
+ case 'duplicate':
410
+ case 'database_error':
411
+ return fate.message;
412
+ default:
413
+ return 'may have been written';
414
+ }
415
+ }
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { customElement, GenesisElement, observable } from '@genesislcap/web-core';
3
- import { canWrite, customCodeLine, initialSelection, restoredSelection, reviewDecisionOf, } from '../review-model';
3
+ import { canWrite, customCodeLine, initialSelection, restoredSelection, reviewDecisionOf, reviewOutcomeFrom, stoppedSummary, } 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';
@@ -31,8 +31,8 @@ const literalMarkdown = (text) => text
31
31
  .map((line) => line.replace(ASCII_PUNCTUATION, '\\$&'))
32
32
  .join('\\\n');
33
33
  /**
34
- * Reviews answered on this page, by interaction id, until a review showing them resolved takes
35
- * the entry.
34
+ * Reviews answered on this page, by interaction id, until a review has said all there is to say
35
+ * about the answer.
36
36
  *
37
37
  * @remarks
38
38
  * The review that answers is not the one that shows the answer. The host rebuilds its trailing
@@ -40,8 +40,13 @@ const literalMarkdown = (text) => text
40
40
  * review arrives as a FRESH element, already holding its outcome. A live region that starts
41
41
  * populated announces nothing, and the button that was pressed goes with the old element, which
42
42
  * drops focus to the page. This is how the fresh one knows it is showing an answer given just now
43
- * rather than one read back from history, which must neither announce nor take focus. Taken once:
44
- * the next re-mount of the same review is history.
43
+ * rather than one read back from history, which must neither announce nor take focus.
44
+ *
45
+ * An approval has more to say: the write tool records what came of its rows AFTER they are
46
+ * written, and that arrives as one more rebuild. So its entry is kept until a review shows that
47
+ * outcome, and then taken; any other answer's is taken by the first review that shows it. The next
48
+ * re-mount after that is history. An approval whose outcome is never recorded keeps its entry, one
49
+ * per such review for the life of the page.
45
50
  */
46
51
  const answeredHere = new Map();
47
52
  /**
@@ -75,7 +80,7 @@ const PARKED = {
75
80
  */
76
81
  let GenesisWriteReview = class GenesisWriteReview extends GenesisElement {
77
82
  constructor() {
78
- super(...arguments);
83
+ super();
79
84
  /** Set by the interaction wrapper on every (re)mount. */
80
85
  this.interactionId = '';
81
86
  /** Chosen rows, by index. Starts empty — see {@link canWrite} and the model's own reasoning. */
@@ -91,6 +96,21 @@ let GenesisWriteReview = class GenesisWriteReview extends GenesisElement {
91
96
  * until it did, a second click sent a second answer — a Deny straight after a Write included.
92
97
  */
93
98
  this.answered = false;
99
+ this.addEventListener('focusin', () => {
100
+ if (this.heldAnswer)
101
+ this.heldAnswer.focused = true;
102
+ });
103
+ this.addEventListener('focusout', () => {
104
+ const held = this.heldAnswer;
105
+ // Judged once focus has landed, and only while this element is on the page: one removed
106
+ // with focus in it still held it.
107
+ if (held) {
108
+ queueMicrotask(() => {
109
+ if (this.isConnected)
110
+ held.focused = this.hasFocus();
111
+ });
112
+ }
113
+ });
94
114
  }
95
115
  /**
96
116
  * The rows, whether the review is still open or already resolved: a user who has approved a
@@ -139,6 +159,21 @@ let GenesisWriteReview = class GenesisWriteReview extends GenesisElement {
139
159
  ? read.rows.filter((index) => selectable.includes(index))
140
160
  : [];
141
161
  }
162
+ /**
163
+ * What came of the approved rows, once the write tool has recorded it: see `ReviewOutcome`.
164
+ * Only for an approval — nothing else writes — and only in the shape the review can read.
165
+ */
166
+ get outcome() {
167
+ const interaction = this.interaction;
168
+ if ((interaction === null || interaction === void 0 ? void 0 : interaction.status) !== 'resolved' || !this.approved.length)
169
+ return undefined;
170
+ return reviewOutcomeFrom(interaction.outcome);
171
+ }
172
+ /** An approved row's recorded fate, when there is one. */
173
+ fateOf(index) {
174
+ var _a;
175
+ return (_a = this.outcome) === null || _a === void 0 ? void 0 : _a.rows.find((row) => row.index === index);
176
+ }
142
177
  /**
143
178
  * What a CLOSED review can truthfully say about its outcome.
144
179
  *
@@ -155,11 +190,17 @@ let GenesisWriteReview = class GenesisWriteReview extends GenesisElement {
155
190
  return '';
156
191
  const read = reviewDecisionOf(interaction.result, this.model);
157
192
  switch (read.decision) {
158
- case 'approved':
159
- // The reply is where the written rows are named, and a stopped turn has none: said, so the
160
- // user is not left waiting on it.
193
+ case 'approved': {
194
+ // A stopped turn gets no reply to say which rows were written, so the review says it,
195
+ // from what the write tool recorded (and marks each row). With no such record, the reply
196
+ // is where the written rows are named, and a stopped turn has none: said, so the user is
197
+ // not left waiting on it.
198
+ const outcome = this.outcome;
199
+ if (outcome === null || outcome === void 0 ? void 0 : outcome.stopped)
200
+ return stoppedSummary(outcome);
161
201
  return (`Approved ${this.approved.length} row(s). The reply says which were written; if the ` +
162
202
  'turn was stopped, some may not be.');
203
+ }
163
204
  case 'timed_out':
164
205
  return 'Closed without a decision. Nothing was written.';
165
206
  case 'changes_requested':
@@ -220,18 +261,28 @@ let GenesisWriteReview = class GenesisWriteReview extends GenesisElement {
220
261
  var _a;
221
262
  const answered = (_a = this.answeredNow) !== null && _a !== void 0 ? _a : answeredHere.get(this.interactionId);
222
263
  this.answeredNow = undefined;
223
- answeredHere.delete(this.interactionId);
224
- if (!answered || answered.focused) {
225
- this.announcement = this.closedSummary;
226
- if (answered)
264
+ const summary = this.closedSummary;
265
+ // An approval's outcome is still to come: see answeredHere.
266
+ const awaiting = !!answered && this.approved.length > 0 && !this.outcome;
267
+ this.heldAnswer = awaiting ? answered : undefined;
268
+ if (awaiting && this.interactionId)
269
+ answeredHere.set(this.interactionId, answered);
270
+ else
271
+ answeredHere.delete(this.interactionId);
272
+ if (!answered || answered.focused || answered.said === summary) {
273
+ this.announcement = summary;
274
+ if (answered === null || answered === void 0 ? void 0 : answered.focused)
227
275
  this.focusSoon('.closed');
228
- return;
229
276
  }
230
- this.announcement = '';
231
- setTimeout(() => {
232
- if (this.isConnected)
233
- this.announcement = this.closedSummary;
234
- }, ANNOUNCE_DELAY_MS);
277
+ else {
278
+ this.announcement = '';
279
+ setTimeout(() => {
280
+ if (this.isConnected)
281
+ this.announcement = this.closedSummary;
282
+ }, ANNOUNCE_DELAY_MS);
283
+ }
284
+ if (answered)
285
+ answered.said = summary;
235
286
  }
236
287
  /** Whether focus is on something inside this review, however deep in shadow roots. */
237
288
  hasFocus() {
@@ -154,9 +154,12 @@ export const WriteReviewStyles = css `
154
154
 
155
155
  /*
156
156
  * A closed review's row that was not approved says so in words — without them, a denied modify
157
- * read in greyscale or by a screen reader exactly like an approved one.
157
+ * read in greyscale or by a screen reader exactly like an approved one. An approved row says what
158
+ * came of it the same way, once the write tool has recorded that (written, not written
159
+ * because the user stopped, or its own reason).
158
160
  */
159
- .not-written {
161
+ .not-written,
162
+ .fate {
160
163
  margin-inline-start: calc(var(--design-unit, 4) * 1.5px);
161
164
  font-size: var(--type-ramp-minus-1-font-size, 0.875em);
162
165
  color: var(--neutral-foreground-hint);
@@ -1,4 +1,5 @@
1
1
  import { html, repeat, when } from '@genesislcap/web-core';
2
+ import { rowFate } from '../review-model';
2
3
  import { MAX_FEEDBACK_CHARS } from '../review-payload';
3
4
  import { isBlankText } from '../write-payload';
4
5
  /** The custom-code line's id: the table is described by it, when there is one. */
@@ -42,6 +43,11 @@ const rowClass = (row, review) => {
42
43
  // saying it would happen after it had been decided it would not.
43
44
  if (review.resolved && !review.approved.includes(row.index))
44
45
  return 'unwritten';
46
+ // An approved row the write tool has recorded as anything but written: it did not happen, or
47
+ // may not have, so it is not shown as happening either.
48
+ const fate = review.fateOf(row.index);
49
+ if (fate && fate.status !== 'written')
50
+ return 'unwritten';
45
51
  if (((_b = review.model) === null || _b === void 0 ? void 0 : _b.op) === 'insert')
46
52
  return 'added';
47
53
  if (((_c = review.model) === null || _c === void 0 ? void 0 : _c.op) === 'delete')
@@ -110,9 +116,12 @@ const row = html `
110
116
  ${when((x, c) => rowClass(x, c.parent) === 'removed', html `
111
117
  ${mark('−')}
112
118
  `)}
113
- ${when((x, c) => rowClass(x, c.parent) === 'unwritten', html `
119
+ ${when((x, c) => rowClass(x, c.parent) === 'unwritten' && !c.parent.fateOf(x.index), html `
114
120
  <span class="not-written">not written</span>
115
121
  `)}
122
+ ${when((x, c) => !!c.parent.fateOf(x.index), html `
123
+ <span class="fate">${(x, c) => rowFate(c.parent.fateOf(x.index))}</span>
124
+ `)}
116
125
  </td>
117
126
  ${repeat((x) => x.cells, cell)}
118
127
  </tr>
@@ -781,7 +781,7 @@ const summarise = (rows) => {
781
781
  };
782
782
  function runWrite(resource, args, context, deps) {
783
783
  return __awaiter(this, void 0, void 0, function* () {
784
- var _a, _b, _c, _d, _e, _f;
784
+ var _a, _b, _c, _d, _e, _f, _g, _h;
785
785
  const fail = (error, message) => ({
786
786
  source: GENESIS_DATA_SOURCE,
787
787
  untrusted: true,
@@ -998,9 +998,21 @@ function runWrite(resource, args, context, deps) {
998
998
  message: 'No outcome was recorded for this row.',
999
999
  };
1000
1000
  });
1001
+ // The review says what came of its rows itself: when the user stopped the turn, no reply will.
1002
+ (_g = context.recordInteractionOutcome) === null || _g === void 0 ? void 0 : _g.call(context, reviewOutcomeOf(rows, approved, ((_h = context.turnSignal) === null || _h === void 0 ? void 0 : _h.aborted) === true));
1001
1003
  return result(resource.name, true, rows, summarise(rows), 'approved');
1002
1004
  });
1003
1005
  }
1006
+ /** What an approved review records about its rows: see `ReviewOutcome`. */
1007
+ const reviewOutcomeOf = (rows, approved, stopped) => {
1008
+ const written = new Set(approved.map((row) => row.index));
1009
+ return {
1010
+ stopped,
1011
+ rows: rows
1012
+ .filter((row) => written.has(row.index))
1013
+ .map(({ index, status, message }) => ({ index, status, message })),
1014
+ };
1015
+ };
1004
1016
  /**
1005
1017
  * Re-checks and commits the approved rows ONE AT A TIME, in order, recording each outcome in
1006
1018
  * `lines`.
@@ -1023,7 +1035,7 @@ function commitApproved(approved, lines, run) {
1023
1035
  var _a;
1024
1036
  if (!((_a = run.turnSignal) === null || _a === void 0 ? void 0 : _a.aborted))
1025
1037
  return false;
1026
- lines.set(index, { index, status: 'failed', committed: false, message: STOPPED_ROW });
1038
+ lines.set(index, { index, status: 'stopped', committed: false, message: STOPPED_ROW });
1027
1039
  return true;
1028
1040
  };
1029
1041
  for (const row of approved) {
@@ -352,6 +352,24 @@ export const blockedBannerClasses = (x) => [
352
352
  ]
353
353
  .filter(Boolean)
354
354
  .join(' ');
355
+ /**
356
+ * A message's interaction widget, in the wrapper that mounts it. Everything the widget is shown
357
+ * comes from the history message through here, the outcome a tool recorded after the answer
358
+ * included, so a remount, a pop-out and a reload all show the same thing.
359
+ *
360
+ * @internal
361
+ */
362
+ export const interactionWrapperTemplate = html `
363
+ <ai-chat-interaction-wrapper
364
+ :componentName=${(m) => m.interaction.componentName}
365
+ :data=${(m) => m.interaction.data}
366
+ :interactionId=${(m) => m.interaction.interactionId}
367
+ :resolved=${(m) => m.interaction.resolved}
368
+ :outcome=${(m) => m.interaction.outcome}
369
+ @interaction-completed=${(m, c) => c.parent.handleInteractionCompleted(c.event)}
370
+ @interaction-cost=${(m, c) => c.parent.handleInteractionCost(c.event)}
371
+ ></ai-chat-interaction-wrapper>
372
+ `;
355
373
  /**
356
374
  * Id of the blocked banner, referenced by the composer controls'
357
375
  * `aria-describedby`. Shadow-DOM-scoped, so a fixed string cannot collide with
@@ -608,16 +626,7 @@ ${(tc) => { var _a; return (((_a = tc.foldPath) === null || _a === void 0 ? void
608
626
  ${when((m) => m.toolCalls, html `
609
627
  ${repeat((m) => { var _a; return (_a = m.toolCalls) !== null && _a !== void 0 ? _a : []; }, toolCallItemTemplate)}
610
628
  `)}
611
- ${when((m) => m.interaction, html `
612
- <ai-chat-interaction-wrapper
613
- :componentName=${(m) => m.interaction.componentName}
614
- :data=${(m) => m.interaction.data}
615
- :interactionId=${(m) => m.interaction.interactionId}
616
- :resolved=${(m) => m.interaction.resolved}
617
- @interaction-completed=${(m, c) => c.parent.handleInteractionCompleted(c.event)}
618
- @interaction-cost=${(m, c) => c.parent.handleInteractionCost(c.event)}
619
- ></ai-chat-interaction-wrapper>
620
- `)}
629
+ ${when((m) => m.interaction, interactionWrapperTemplate)}
621
630
  </div>
622
631
  </div>
623
632
  </div>