@genesislcap/ai-assistant 15.81.0 → 15.83.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 (110) hide show
  1. package/dist/ai-assistant.api.json +2800 -116
  2. package/dist/ai-assistant.d.ts +887 -109
  3. package/dist/chat-driver.cjs +468 -107
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +468 -107
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +1108 -61
  8. package/dist/dts/autopilot/autopilot-driver.d.ts +117 -11
  9. package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -1
  10. package/dist/dts/autopilot/autopilot-session.d.ts +55 -7
  11. package/dist/dts/autopilot/autopilot-session.d.ts.map +1 -1
  12. package/dist/dts/autopilot/autopilot-tools.d.ts +3 -2
  13. package/dist/dts/autopilot/autopilot-tools.d.ts.map +1 -1
  14. package/dist/dts/autopilot/decision-message.d.ts +35 -3
  15. package/dist/dts/autopilot/decision-message.d.ts.map +1 -1
  16. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts +2 -2
  17. package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts.map +1 -1
  18. package/dist/dts/autopilot/hand-back/hand-back.d.ts +2 -2
  19. package/dist/dts/autopilot/hand-back/hand-back.d.ts.map +1 -1
  20. package/dist/dts/autopilot/index.d.ts +1 -0
  21. package/dist/dts/autopilot/index.d.ts.map +1 -1
  22. package/dist/dts/autopilot/widget-tools.d.ts +95 -0
  23. package/dist/dts/autopilot/widget-tools.d.ts.map +1 -0
  24. package/dist/dts/channel/ai-activity-channel.d.ts +10 -0
  25. package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
  26. package/dist/dts/components/agent-session/agent-session.d.ts +2 -1
  27. package/dist/dts/components/agent-session/agent-session.d.ts.map +1 -1
  28. package/dist/dts/components/ai-driver/ai-driver.d.ts +25 -6
  29. package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
  30. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +2 -0
  31. package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
  32. package/dist/dts/components/chat-driver/chat-driver.d.ts +14 -2
  33. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  34. package/dist/dts/components/chat-driver/interaction-controller.d.ts +61 -17
  35. package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
  36. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +6 -0
  37. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
  38. package/dist/dts/config/config.d.ts +31 -6
  39. package/dist/dts/config/config.d.ts.map +1 -1
  40. package/dist/dts/config/define-stateful-agent.d.ts +5 -1
  41. package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
  42. package/dist/dts/index.d.ts +4 -2
  43. package/dist/dts/index.d.ts.map +1 -1
  44. package/dist/dts/main/main.d.ts +33 -16
  45. package/dist/dts/main/main.d.ts.map +1 -1
  46. package/dist/dts/main/main.template.d.ts.map +1 -1
  47. package/dist/dts/main/main.types.d.ts +15 -0
  48. package/dist/dts/main/main.types.d.ts.map +1 -1
  49. package/dist/dts/notifications/agent-notifications.d.ts +6 -2
  50. package/dist/dts/notifications/agent-notifications.d.ts.map +1 -1
  51. package/dist/dts/notifications/agent-notifier.d.ts +26 -4
  52. package/dist/dts/notifications/agent-notifier.d.ts.map +1 -1
  53. package/dist/dts/state/decision-surface.d.ts +22 -4
  54. package/dist/dts/state/decision-surface.d.ts.map +1 -1
  55. package/dist/dts/state/interaction-context.d.ts +23 -4
  56. package/dist/dts/state/interaction-context.d.ts.map +1 -1
  57. package/dist/dts/state/interaction-registry.d.ts +55 -6
  58. package/dist/dts/state/interaction-registry.d.ts.map +1 -1
  59. package/dist/dts/state/live-interactions.d.ts +28 -0
  60. package/dist/dts/state/live-interactions.d.ts.map +1 -0
  61. package/dist/dts/state/persistence/session-persister.d.ts +6 -0
  62. package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
  63. package/dist/dts/state/persistence/session-snapshot.d.ts +16 -5
  64. package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
  65. package/dist/dts/state/test-interaction-context.d.ts +93 -0
  66. package/dist/dts/state/test-interaction-context.d.ts.map +1 -0
  67. package/dist/dts/types/ai-chat-widget.d.ts +7 -6
  68. package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
  69. package/dist/dts/types/interaction-context.d.ts +128 -17
  70. package/dist/dts/types/interaction-context.d.ts.map +1 -1
  71. package/dist/dts/types/interaction-interceptor.d.ts +48 -6
  72. package/dist/dts/types/interaction-interceptor.d.ts.map +1 -1
  73. package/dist/dts/types/interaction-surface.d.ts +145 -23
  74. package/dist/dts/types/interaction-surface.d.ts.map +1 -1
  75. package/dist/dts/utils/delegated-message.d.ts +7 -0
  76. package/dist/dts/utils/delegated-message.d.ts.map +1 -1
  77. package/dist/esm/autopilot/autopilot-driver.js +313 -60
  78. package/dist/esm/autopilot/autopilot-session.js +219 -40
  79. package/dist/esm/autopilot/autopilot-tools.js +11 -7
  80. package/dist/esm/autopilot/decision-message.js +105 -26
  81. package/dist/esm/autopilot/hand-back/hand-back.controller.js +2 -1
  82. package/dist/esm/autopilot/index.js +1 -0
  83. package/dist/esm/autopilot/widget-tools.js +39 -0
  84. package/dist/esm/components/agent-session/agent-session.js +3 -2
  85. package/dist/esm/components/ai-driver/base-driver-decorator.js +17 -0
  86. package/dist/esm/components/chat-driver/chat-driver.js +18 -2
  87. package/dist/esm/components/chat-driver/interaction-controller.js +232 -71
  88. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +14 -6
  89. package/dist/esm/components/settings-modal/settings-modal.template.js +2 -2
  90. package/dist/esm/config/define-stateful-agent.js +22 -1
  91. package/dist/esm/index.js +2 -0
  92. package/dist/esm/main/main.js +88 -35
  93. package/dist/esm/main/main.template.js +4 -1
  94. package/dist/esm/notifications/agent-notifications.js +11 -1
  95. package/dist/esm/notifications/agent-notifier.js +41 -7
  96. package/dist/esm/state/debug-event-log.js +6 -6
  97. package/dist/esm/state/decision-surface.js +137 -54
  98. package/dist/esm/state/interaction-context.js +41 -8
  99. package/dist/esm/state/interaction-registry.js +11 -0
  100. package/dist/esm/state/live-interactions.js +36 -0
  101. package/dist/esm/state/persistence/session-persister.js +55 -18
  102. package/dist/esm/state/persistence/session-snapshot.js +2 -2
  103. package/dist/esm/state/test-interaction-context.js +99 -0
  104. package/docs/notifications.md +55 -5
  105. package/docs/styling.md +33 -0
  106. package/package.json +19 -19
  107. package/sandbox/README.md +3 -2
  108. package/sandbox/autopilot.ts +26 -6
  109. package/sandbox/sandbox.ts +2 -0
  110. /package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +0 -0
@@ -1046,6 +1046,14 @@
1046
1046
  "module": "./types/ai-chat-widget"
1047
1047
  }
1048
1048
  },
1049
+ {
1050
+ "kind": "js",
1051
+ "name": "ControllerHost",
1052
+ "declaration": {
1053
+ "name": "ControllerHost",
1054
+ "module": "./types/interaction-context"
1055
+ }
1056
+ },
1049
1057
  {
1050
1058
  "kind": "js",
1051
1059
  "name": "InteractionContext",
@@ -1062,6 +1070,14 @@
1062
1070
  "module": "./types/interaction-context"
1063
1071
  }
1064
1072
  },
1073
+ {
1074
+ "kind": "js",
1075
+ "name": "InteractionResolveOptions",
1076
+ "declaration": {
1077
+ "name": "InteractionResolveOptions",
1078
+ "module": "./types/interaction-context"
1079
+ }
1080
+ },
1065
1081
  {
1066
1082
  "kind": "js",
1067
1083
  "name": "PersistedInteractionCheckpoint",
@@ -1070,6 +1086,54 @@
1070
1086
  "module": "./types/interaction-context"
1071
1087
  }
1072
1088
  },
1089
+ {
1090
+ "kind": "js",
1091
+ "name": "getInteractionContext",
1092
+ "declaration": {
1093
+ "name": "getInteractionContext",
1094
+ "module": "./state/live-interactions"
1095
+ }
1096
+ },
1097
+ {
1098
+ "kind": "js",
1099
+ "name": "createTestInteractionContext",
1100
+ "declaration": {
1101
+ "name": "createTestInteractionContext",
1102
+ "module": "./state/test-interaction-context"
1103
+ }
1104
+ },
1105
+ {
1106
+ "kind": "js",
1107
+ "name": "type",
1108
+ "declaration": {
1109
+ "name": "type",
1110
+ "module": "./state/test-interaction-context"
1111
+ }
1112
+ },
1113
+ {
1114
+ "kind": "js",
1115
+ "name": "TestActResult",
1116
+ "declaration": {
1117
+ "name": "TestActResult",
1118
+ "module": "./state/test-interaction-context"
1119
+ }
1120
+ },
1121
+ {
1122
+ "kind": "js",
1123
+ "name": "type",
1124
+ "declaration": {
1125
+ "name": "type",
1126
+ "module": "./state/test-interaction-context"
1127
+ }
1128
+ },
1129
+ {
1130
+ "kind": "js",
1131
+ "name": "TestInteractionContext",
1132
+ "declaration": {
1133
+ "name": "TestInteractionContext",
1134
+ "module": "./state/test-interaction-context"
1135
+ }
1136
+ },
1073
1137
  {
1074
1138
  "kind": "js",
1075
1139
  "name": "runSteps",
@@ -1246,6 +1310,14 @@
1246
1310
  "module": "./types/interaction-surface"
1247
1311
  }
1248
1312
  },
1313
+ {
1314
+ "kind": "js",
1315
+ "name": "SurfaceView",
1316
+ "declaration": {
1317
+ "name": "SurfaceView",
1318
+ "module": "./types/interaction-surface"
1319
+ }
1320
+ },
1249
1321
  {
1250
1322
  "kind": "js",
1251
1323
  "name": "getInteractionRegistration",
@@ -1439,6 +1511,24 @@
1439
1511
  },
1440
1512
  "privacy": "private"
1441
1513
  },
1514
+ {
1515
+ "kind": "field",
1516
+ "name": "open",
1517
+ "type": {
1518
+ "text": "InteractionOpened | undefined"
1519
+ },
1520
+ "privacy": "private",
1521
+ "description": "The interaction open right now, whoever holds it: claimed or not, it was offered here first.\n`held` covers only what the autopilot claimed, so this is how the status knows that the working\nagent is parked on a question left with the person (see `waitingOnUser`)."
1522
+ },
1523
+ {
1524
+ "kind": "field",
1525
+ "name": "declinedWhilePaused",
1526
+ "type": {
1527
+ "text": "InteractionOpened | undefined"
1528
+ },
1529
+ "privacy": "private",
1530
+ "description": "The open interaction, when the autopilot declined it only for being paused as it opened: a live\nResume may still take it (see `takeOpenOnResume`). Cleared when it is taken or settles."
1531
+ },
1442
1532
  {
1443
1533
  "kind": "field",
1444
1534
  "name": "refinements",
@@ -1446,7 +1536,7 @@
1446
1536
  "text": "{ key: string; count: number } | undefined"
1447
1537
  },
1448
1538
  "privacy": "private",
1449
- "description": "Written answers given on the current step, for the refinement limit."
1539
+ "description": "Refining actions taken on the current step (written answers among them), for the limit."
1450
1540
  },
1451
1541
  {
1452
1542
  "kind": "field",
@@ -1545,6 +1635,14 @@
1545
1635
  "privacy": "private",
1546
1636
  "description": "The check that confirms the autopilot stopped, once it looked like it had."
1547
1637
  },
1638
+ {
1639
+ "kind": "field",
1640
+ "name": "handBackWaits",
1641
+ "privacy": "private",
1642
+ "readonly": true,
1643
+ "default": "new Set<() => void>()",
1644
+ "description": "Stops each wait for a widget left with the person to ask them; see `reportHandBackWhenAsking`."
1645
+ },
1548
1646
  {
1549
1647
  "kind": "field",
1550
1648
  "name": "state",
@@ -1553,6 +1651,17 @@
1553
1651
  },
1554
1652
  "readonly": true
1555
1653
  },
1654
+ {
1655
+ "kind": "method",
1656
+ "name": "waitingOnUser",
1657
+ "privacy": "private",
1658
+ "return": {
1659
+ "type": {
1660
+ "text": "boolean"
1661
+ }
1662
+ },
1663
+ "description": "Whether the working agent is parked on a question the person holds, with the autopilot deciding\nnothing: one it never took — its policy keeps it for the person, it is `userOnly` (the turn-level\nhand-back among them), it has no controller, or it opened while paused and no Resume has taken\nit since (a restored mode takes nothing) — or one another interceptor took and then gave to the\nperson. One the autopilot handed back reads `selfPaused`, and one a pause handed over reads\n`paused`; `state` settles both before asking this.\n\nNever one that asks them nothing (see `asksThePerson`): the person holds it, but it is work\nrunning, which settles by itself, so \"waiting for your answer\" would be untrue. A hand-back is\nreported by the same rule (see `reportHandBackWhenAsking`)."
1664
+ },
1556
1665
  {
1557
1666
  "kind": "field",
1558
1667
  "name": "copy",
@@ -1865,7 +1974,7 @@
1865
1974
  }
1866
1975
  }
1867
1976
  ],
1868
- "description": "Answer a written question the working agent ended its turn on, and send the answer on the\nuser's behalf, with what writing it cost booked on that message (§4.2).\n\nSent only if the question still stands when the answer lands: no pause or resume since it was\nasked (Pause stops it, and the question is the person's to answer by typing), the flow still\nrunning, the working agent idle, and the question still the last thing it said. Otherwise the\nanswer goes nowhere — not sent, not counted, not recorded as acted — and its cost is recorded as\ndropped, as it is whenever no reply is sent to carry it."
1977
+ "description": "Answer a written question the working agent ended its turn on, and send the answer on the\nuser's behalf, with what writing it cost booked on that message (§4.2).\n\nSent only if the question still stands when the answer lands: no pause or resume since it was\nasked (Pause stops it, and the question is the person's to answer by typing), the flow still\nrunning and the autopilot still available to it, the working agent idle, and the question still\nthe last thing it said. Otherwise the answer goes nowhere — not sent, not counted, not recorded\nas acted — and its cost is recorded as dropped, as it is whenever no reply is sent to carry it."
1869
1978
  },
1870
1979
  {
1871
1980
  "kind": "method",
@@ -1985,6 +2094,175 @@
1985
2094
  }
1986
2095
  ]
1987
2096
  },
2097
+ {
2098
+ "kind": "method",
2099
+ "name": "decline",
2100
+ "privacy": "private",
2101
+ "return": {
2102
+ "type": {
2103
+ "text": "undefined"
2104
+ }
2105
+ },
2106
+ "parameters": [
2107
+ {
2108
+ "name": "opened",
2109
+ "type": {
2110
+ "text": "InteractionOpened"
2111
+ }
2112
+ },
2113
+ {
2114
+ "name": "reason",
2115
+ "type": {
2116
+ "text": "string"
2117
+ }
2118
+ },
2119
+ {
2120
+ "name": "extra",
2121
+ "default": "{}",
2122
+ "type": {
2123
+ "text": "Record<string, unknown>"
2124
+ }
2125
+ }
2126
+ ]
2127
+ },
2128
+ {
2129
+ "kind": "method",
2130
+ "name": "reportHandBackWhenAsking",
2131
+ "privacy": "private",
2132
+ "return": {
2133
+ "type": {
2134
+ "text": "void"
2135
+ }
2136
+ },
2137
+ "parameters": [
2138
+ {
2139
+ "name": "opened",
2140
+ "type": {
2141
+ "text": "InteractionOpened"
2142
+ }
2143
+ }
2144
+ ],
2145
+ "description": "Report a widget the autopilot declined, and so left with the person, as a hand-back (GENC-1660)\n— but only once it waits on them: by the rule the status reads (`asksThePerson`), or because the\nwidget asked for their attention. Then only if it still does, and is still theirs, after\n`HAND_BACK_GRACE_MS`, so one that settles itself as it mounts never reports. One that is working\nreports when it starts asking, with the message it asked with. One that settles first, or that\nanother interceptor claims first, never reports: that claimant reports its own hand-back.\n\nThe report is the interaction's one notification. The widget's own request is taken over\n(`hold.takeAttention`), so it is not reported as well, before or after: it only counts as the\nwidget asking. When its request has already counted — reported while the person held it, before\na decline on Resume — the person was told then, so nothing more is reported."
2146
+ },
2147
+ {
2148
+ "kind": "method",
2149
+ "name": "eligibility",
2150
+ "privacy": "private",
2151
+ "return": {
2152
+ "type": {
2153
+ "text": "{ readonly agentName: string } | { readonly reason: string }"
2154
+ }
2155
+ },
2156
+ "parameters": [
2157
+ {
2158
+ "name": "opened",
2159
+ "type": {
2160
+ "text": "InteractionOpened"
2161
+ }
2162
+ },
2163
+ {
2164
+ "name": "owner",
2165
+ "type": {
2166
+ "text": "string"
2167
+ }
2168
+ }
2169
+ ],
2170
+ "description": "Whether the autopilot running for `owner` may take `opened`: the agent that answers for it, or\nwhy not, as `autopilot.declined` records it. The mode is the caller's to check — the open path\nasks this only while running, and a live Resume only for what opened while paused — so both ask\nthe same questions in the same order."
2171
+ },
2172
+ {
2173
+ "kind": "method",
2174
+ "name": "take",
2175
+ "privacy": "private",
2176
+ "return": {
2177
+ "type": {
2178
+ "text": "void"
2179
+ }
2180
+ },
2181
+ "parameters": [
2182
+ {
2183
+ "name": "opened",
2184
+ "type": {
2185
+ "text": "InteractionOpened"
2186
+ }
2187
+ },
2188
+ {
2189
+ "name": "agentName",
2190
+ "type": {
2191
+ "text": "string"
2192
+ }
2193
+ },
2194
+ {
2195
+ "name": "how",
2196
+ "type": {
2197
+ "text": "{ deferred: boolean; onResume?: boolean }"
2198
+ }
2199
+ }
2200
+ ],
2201
+ "description": "Hold an interaction the autopilot claimed, watch it, and decide it once its surface is ready.\n`deferred` when the claim is granted only after the caller returns (the open path), so the\ndecision waits a microtask for it; a late claim through `hold.claim` is granted already.\n\nThe decision starts only if the autopilot still holds it then, with no pause or resume in\nbetween: a pause hands it over, and the Resume after that decides it itself."
2202
+ },
2203
+ {
2204
+ "kind": "method",
2205
+ "name": "decideWhenReady",
2206
+ "privacy": "private",
2207
+ "return": {
2208
+ "type": {
2209
+ "text": "void"
2210
+ }
2211
+ },
2212
+ "parameters": [
2213
+ {
2214
+ "name": "held",
2215
+ "type": {
2216
+ "text": "Held"
2217
+ }
2218
+ },
2219
+ {
2220
+ "name": "options",
2221
+ "type": {
2222
+ "text": "{ allowHandBack: boolean }"
2223
+ }
2224
+ }
2225
+ ],
2226
+ "description": "Decide `held` once a decision is due on it (`onSurfaceReady`): at once if one is, or when its\ncontroller next makes one due — exposes a surface, enables an action, or says it is asking.\nOnly if, by then, the autopilot still holds it with no pause or resume in between: a pause hands\nit over, and the Resume after that decides it itself."
2227
+ },
2228
+ {
2229
+ "kind": "method",
2230
+ "name": "takeOpenOnResume",
2231
+ "privacy": "private",
2232
+ "return": {
2233
+ "type": {
2234
+ "text": "boolean"
2235
+ }
2236
+ },
2237
+ "parameters": [
2238
+ {
2239
+ "name": "owner",
2240
+ "type": {
2241
+ "text": "string"
2242
+ }
2243
+ }
2244
+ ],
2245
+ "description": "On a live Resume: take the open interaction if it was declined only because the autopilot was\npaused when it opened, and would be claimed if it opened now — the same checks as the open\npath. Returns whether it took it. A person may have started on it; it is taken as it stands, as\nResume takes back one a pause handed over, and the autopilot reads it as it now is."
2246
+ },
2247
+ {
2248
+ "kind": "method",
2249
+ "name": "trackOpen",
2250
+ "privacy": "private",
2251
+ "return": {
2252
+ "type": {
2253
+ "text": "void"
2254
+ }
2255
+ },
2256
+ "parameters": [
2257
+ {
2258
+ "name": "opened",
2259
+ "type": {
2260
+ "text": "InteractionOpened"
2261
+ }
2262
+ }
2263
+ ],
2264
+ "description": "Follow every interaction while it is open, claimed or not, so the status can say when the\nperson is the one being waited on (see `waitingOnUser`), and tell the host each time that\nchanges: when it opens, when it moves between holders, and when it settles."
2265
+ },
1988
2266
  {
1989
2267
  "kind": "method",
1990
2268
  "name": "decide",
@@ -2031,11 +2309,11 @@
2031
2309
  },
2032
2310
  {
2033
2311
  "kind": "method",
2034
- "name": "mayRefine",
2312
+ "name": "refinementsLeft",
2035
2313
  "privacy": "private",
2036
2314
  "return": {
2037
2315
  "type": {
2038
- "text": "boolean"
2316
+ "text": "number"
2039
2317
  }
2040
2318
  },
2041
2319
  "parameters": [
@@ -2052,7 +2330,7 @@
2052
2330
  }
2053
2331
  }
2054
2332
  ],
2055
- "description": "Whether a written answer is still allowed on this step. The count resets when the step changes."
2333
+ "description": "How many refining actions (written answers, and full-form actions declared `refines`) are left\non this step: none left withdraws them all. Read fresh, so a refinement taken mid-decision (a\n`refines` action that does not settle) counts at once. The count resets when the step changes."
2056
2334
  },
2057
2335
  {
2058
2336
  "kind": "method",
@@ -2075,6 +2353,12 @@
2075
2353
  "type": {
2076
2354
  "text": "string"
2077
2355
  }
2356
+ },
2357
+ {
2358
+ "name": "action",
2359
+ "type": {
2360
+ "text": "string"
2361
+ }
2078
2362
  }
2079
2363
  ]
2080
2364
  },
@@ -2095,7 +2379,7 @@
2095
2379
  }
2096
2380
  }
2097
2381
  ],
2098
- "description": "Written answers allowed per step: the config's when it is a whole number `>= 0`."
2382
+ "description": "Refinements allowed per step: the config's when it is a whole number `>= 0`."
2099
2383
  },
2100
2384
  {
2101
2385
  "kind": "method",
@@ -2370,9 +2654,16 @@
2370
2654
  "type": {
2371
2655
  "text": "string"
2372
2656
  }
2657
+ },
2658
+ {
2659
+ "name": "message",
2660
+ "optional": true,
2661
+ "type": {
2662
+ "text": "string"
2663
+ }
2373
2664
  }
2374
2665
  ],
2375
- "description": "Report that something needs the person, for the assistant to notify them (GENC-1676)."
2666
+ "description": "Report that something needs the person, for the assistant to notify them (GENC-1676), with the\nwidget's own message when it gave one (GENC-1660)."
2376
2667
  },
2377
2668
  {
2378
2669
  "kind": "method",
@@ -2742,6 +3033,40 @@
2742
3033
  "module": "src/components/ai-driver/base-driver-decorator.ts"
2743
3034
  }
2744
3035
  },
3036
+ {
3037
+ "kind": "method",
3038
+ "name": "getInteractionCheckpoints",
3039
+ "return": {
3040
+ "type": {
3041
+ "text": "readonly PersistedInteractionCheckpoint[]"
3042
+ }
3043
+ },
3044
+ "inheritedFrom": {
3045
+ "name": "BaseDriverDecorator",
3046
+ "module": "src/components/ai-driver/base-driver-decorator.ts"
3047
+ }
3048
+ },
3049
+ {
3050
+ "kind": "method",
3051
+ "name": "restoreInteractionCheckpoints",
3052
+ "return": {
3053
+ "type": {
3054
+ "text": "void"
3055
+ }
3056
+ },
3057
+ "parameters": [
3058
+ {
3059
+ "name": "saved",
3060
+ "type": {
3061
+ "text": "readonly PersistedInteractionCheckpoint[]"
3062
+ }
3063
+ }
3064
+ ],
3065
+ "inheritedFrom": {
3066
+ "name": "BaseDriverDecorator",
3067
+ "module": "src/components/ai-driver/base-driver-decorator.ts"
3068
+ }
3069
+ },
2745
3070
  {
2746
3071
  "kind": "method",
2747
3072
  "name": "getInteractionCheckpoint",
@@ -3143,6 +3468,48 @@
3143
3468
  ],
3144
3469
  "description": "The newest `lines` that fit in `maxChars`, after one line saying how many earlier ones were left\nout: a transcript cut to size from the old end, since what the autopilot decides next turns on the\nrecent past."
3145
3470
  },
3471
+ {
3472
+ "kind": "function",
3473
+ "name": "parseFields",
3474
+ "return": {
3475
+ "type": {
3476
+ "text": "{ ok: true; value: unknown } | { ok: false }"
3477
+ }
3478
+ },
3479
+ "parameters": [
3480
+ {
3481
+ "name": "fields",
3482
+ "type": {
3483
+ "text": "unknown"
3484
+ }
3485
+ }
3486
+ ],
3487
+ "description": "`widget_act`'s `fields`, parsed leniently: an object is taken as it is (a model may send one\ndespite the schema's string), and a Markdown code fence around the JSON is stripped."
3488
+ },
3489
+ {
3490
+ "kind": "function",
3491
+ "name": "fieldsExample",
3492
+ "return": {
3493
+ "type": {
3494
+ "text": "string"
3495
+ }
3496
+ },
3497
+ "parameters": [
3498
+ {
3499
+ "name": "action",
3500
+ "type": {
3501
+ "text": "string"
3502
+ }
3503
+ },
3504
+ {
3505
+ "name": "schema",
3506
+ "type": {
3507
+ "text": "Readonly<Record<string, unknown>> | undefined"
3508
+ }
3509
+ }
3510
+ ],
3511
+ "description": "How to send `fields` for `action`, as a correctly escaped example: the whole `widget_act` call,\nwith `fields` a JSON object inside a string, built from the action's schema where it has one."
3512
+ },
3146
3513
  {
3147
3514
  "kind": "class",
3148
3515
  "description": "One autopilot for one flow (GENC-1660): its own `ChatDriver`, its own history, and the last\nmessage of what the person has seen that it was told about. Each decision is one short turn on\nthat driver, which ends when the autopilot acts or hands back.\n\nIts history holds only its own conversation — the decisions it was sent, its tool calls and\ntheir results — never the working agent's. What happened without it (answers the person gave,\nmessages they typed, what the assistant showed) arrives at the top of the next decision as a\n`<since-last>` block, built from the working history by code. Its own messages in the working\nhistory (what it sent on the user's behalf) are left out of that block while its history holds\nthem, and labelled as its own whenever it does not: on its first decision (after a reload, too),\nafter a size rebuild, and when a compaction removed the last message it saw.",
@@ -3337,50 +3704,126 @@
3337
3704
  "text": "() => Promise<DecisionOutcome>"
3338
3705
  }
3339
3706
  }
3340
- ]
3707
+ ]
3708
+ },
3709
+ {
3710
+ "kind": "method",
3711
+ "name": "runTurn",
3712
+ "privacy": "private",
3713
+ "return": {
3714
+ "type": {
3715
+ "text": "Promise<DecisionOutcome>"
3716
+ }
3717
+ },
3718
+ "parameters": [
3719
+ {
3720
+ "name": "current",
3721
+ "type": {
3722
+ "text": "Current"
3723
+ }
3724
+ },
3725
+ {
3726
+ "name": "decisionText",
3727
+ "type": {
3728
+ "text": "string"
3729
+ }
3730
+ },
3731
+ {
3732
+ "name": "interactionId",
3733
+ "optional": true,
3734
+ "type": {
3735
+ "text": "string"
3736
+ }
3737
+ },
3738
+ {
3739
+ "name": "sentDetail",
3740
+ "default": "{}",
3741
+ "type": {
3742
+ "text": "Record<string, unknown>"
3743
+ }
3744
+ }
3745
+ ],
3746
+ "description": "One turn on the autopilot's driver: the `<since-last>` block, then the decision. Ends when the\nautopilot acts, replies or hands back, when it passes its spend cap, or when it runs out of\ncalls. Books what it cost to `interactionId`; for a written question, which has none, returns\nit on the outcome for the driver to book on its reply."
3747
+ },
3748
+ {
3749
+ "kind": "method",
3750
+ "name": "agentConfig",
3751
+ "privacy": "private",
3752
+ "return": {
3753
+ "type": {
3754
+ "text": "AgentConfig"
3755
+ }
3756
+ },
3757
+ "description": "The autopilot as an agent: its config's resolvers bound to the working agent's state. Its tools\n— the fixed three, the config's own, and its widget tools — are fixed here, once, sorted by\nname, so every decision sends the same list and the cached prefix holds."
3758
+ },
3759
+ {
3760
+ "kind": "field",
3761
+ "name": "toolsByWidget",
3762
+ "privacy": "private",
3763
+ "readonly": true,
3764
+ "default": "new Map<\n string,\n Array<{ name: string; spec: WidgetToolSpec<unknown, Record<string, unknown>> }>\n >()",
3765
+ "description": "The widget tools, by component name; filled once, by `widgetTools`."
3766
+ },
3767
+ {
3768
+ "kind": "method",
3769
+ "name": "widgetTools",
3770
+ "privacy": "private",
3771
+ "return": {
3772
+ "type": {
3773
+ "text": "{\n definitions: ChatToolDefinition[];\n handlers: ChatToolHandlers;\n }"
3774
+ }
3775
+ },
3776
+ "parameters": [
3777
+ {
3778
+ "name": "taken",
3779
+ "type": {
3780
+ "text": "readonly string[]"
3781
+ }
3782
+ }
3783
+ ],
3784
+ "description": "The config's widget tools as tools: their definitions and their handlers, each routed to the\ninteraction of its widget type being decided. A name already `taken` (a fixed tool, one of the\nconfig's own, or an earlier widget tool) is skipped with a warning: `defineAutopilot` refuses\nsuch a config, so only one built by hand gets here."
3785
+ },
3786
+ {
3787
+ "kind": "method",
3788
+ "name": "widgetToolsLine",
3789
+ "privacy": "private",
3790
+ "return": {
3791
+ "type": {
3792
+ "text": "string"
3793
+ }
3794
+ },
3795
+ "description": "The platform's line in the tail: the widget tools usable now — those of the widget the decision\nin progress is on, less any that say they are unavailable — and nothing when there are none."
3341
3796
  },
3342
3797
  {
3343
3798
  "kind": "method",
3344
- "name": "runTurn",
3799
+ "name": "widgetToolHandler",
3345
3800
  "privacy": "private",
3346
3801
  "return": {
3347
3802
  "type": {
3348
- "text": "Promise<DecisionOutcome>"
3803
+ "text": "ChatToolHandler"
3349
3804
  }
3350
3805
  },
3351
3806
  "parameters": [
3352
3807
  {
3353
- "name": "current",
3808
+ "name": "componentName",
3354
3809
  "type": {
3355
- "text": "Current"
3810
+ "text": "string"
3356
3811
  }
3357
3812
  },
3358
3813
  {
3359
- "name": "decisionText",
3814
+ "name": "name",
3360
3815
  "type": {
3361
3816
  "text": "string"
3362
3817
  }
3363
3818
  },
3364
3819
  {
3365
- "name": "interactionId",
3366
- "optional": true,
3820
+ "name": "spec",
3367
3821
  "type": {
3368
- "text": "string"
3822
+ "text": "WidgetToolSpec<unknown, Record<string, unknown>>"
3369
3823
  }
3370
3824
  }
3371
3825
  ],
3372
- "description": "One turn on the autopilot's driver: the `<since-last>` block, then the decision. Ends when the\nautopilot acts, replies or hands back, when it passes its spend cap, or when it runs out of\ncalls. Books what it cost to `interactionId`; for a written question, which has none, returns\nit on the outcome for the driver to book on its reply."
3373
- },
3374
- {
3375
- "kind": "method",
3376
- "name": "agentConfig",
3377
- "privacy": "private",
3378
- "return": {
3379
- "type": {
3380
- "text": "AgentConfig"
3381
- }
3382
- },
3383
- "description": "The autopilot as an agent: its config's resolvers bound to the working agent's state."
3826
+ "description": "One widget tool's handler: routed to the interaction of `componentName` the autopilot is\ndeciding and holds, its controller passed to `run`, its arguments checked first. Refused, with a\nreason, when no such interaction is in progress. Its result is capped, and leaves the history\nat the end of the decision, as a `widget_read` does."
3384
3827
  },
3385
3828
  {
3386
3829
  "kind": "method",
@@ -3420,6 +3863,22 @@
3420
3863
  "module": "src/autopilot/autopilot-session.ts"
3421
3864
  }
3422
3865
  },
3866
+ {
3867
+ "kind": "js",
3868
+ "name": "parseFields",
3869
+ "declaration": {
3870
+ "name": "parseFields",
3871
+ "module": "src/autopilot/autopilot-session.ts"
3872
+ }
3873
+ },
3874
+ {
3875
+ "kind": "js",
3876
+ "name": "fieldsExample",
3877
+ "declaration": {
3878
+ "name": "fieldsExample",
3879
+ "module": "src/autopilot/autopilot-session.ts"
3880
+ }
3881
+ },
3423
3882
  {
3424
3883
  "kind": "js",
3425
3884
  "name": "AutopilotSession",
@@ -3467,8 +3926,8 @@
3467
3926
  "type": {
3468
3927
  "text": "ChatToolDefinition[]"
3469
3928
  },
3470
- "default": "[\n {\n name: WIDGET_READ,\n description:\n 'Read the current decision as it stands now: its state (one of its views, if it lists views), and its actions with their numbers and whether each is available. Use it when the decision message may be out of date, or to read a view it lists.',\n parameters: {\n type: 'object',\n properties: {\n view: { type: 'string', description: 'One of the views the decision lists, if any.' },\n },\n },\n },\n {\n name: WIDGET_ACT,\n description:\n 'Act on the current decision, as the user would by clicking. `action` is the number of an option from the decision\\'s list (e.g. \"1\"), or a named action from that list: \"select\" with `options` to choose several, or \"reply\" with `text` to answer in your own words. ' +\n 'If it settles the decision, your turn ends. ' +\n '`note` is shown to the user as the assistant speaking, before the outcome: one short sentence in the first person saying what you chose and why, e.g. \"Your brief has no external feeds, so I\\'ll skip Data Feeds.\" Never mention an autopilot or a second agent.',\n parameters: {\n type: 'object',\n required: ['action'],\n properties: {\n action: {\n type: 'string',\n description:\n 'An option number from the list, starting at 1, or a named action (\"select\", \"reply\").',\n },\n options: {\n type: 'array',\n items: { type: 'string' },\n description: 'For \"select\": the options to choose, by number or label.',\n },\n text: { type: 'string', description: 'For \"reply\": your answer, in the user\\'s place.' },\n fields: {\n type: 'string',\n description:\n 'For a named action that takes arguments: a JSON object, as text, matching the args schema the decision lists for it.',\n },\n note: {\n type: 'string',\n description: 'Shown to the user as the assistant speaking. One sentence, first person.',\n },\n },\n },\n },\n {\n name: HAND_BACK,\n description:\n 'Give this one decision to the user, when it rests on something only they can know and neither their brief nor their own answers settle it. Your turn ends and the user sees the question. `reason` is shown to them as the assistant speaking, after \"I need your input on this one:\" — say plainly what you need from them. Never mention an autopilot or a second agent.',\n parameters: {\n type: 'object',\n required: ['reason'],\n properties: {\n reason: {\n type: 'string',\n description: 'What the user needs to decide, and why it is theirs.',\n },\n },\n },\n },\n]",
3471
- "description": "The autopilot's three fixed tools (GENC-1660 §4.2, §4.6). Fixed for every decision, so the cached\nprefix holds: what varies — the widget, its actions, their arguments — travels in the decision\nmessage, not here. Plain string and string-array fields only, which every provider accepts\n(critique round 2, N5: Gemini rejects a type-array union)."
3929
+ "default": "[\n {\n name: WIDGET_READ,\n description:\n 'Read the current decision as it stands now: its state (one of its views, if it lists views; without one, its facts or the view shown as Now), and its actions with their numbers and whether each is available. Use it when the decision message may be out of date, or to read a view it lists.',\n parameters: {\n type: 'object',\n properties: {\n view: { type: 'string', description: 'One of the views the decision lists, if any.' },\n },\n },\n },\n {\n name: WIDGET_ACT,\n description:\n 'Act on the current decision, as the user would by clicking. `action` is the number of an option from the decision\\'s list (e.g. \"1\"), or a named action from that list: \"select\" with `options` to choose several, \"reply\" with `text` to answer in your own words, any action listed as name({text}) with its argument in `text`, and any listed as name({fields}) with `fields`. ' +\n 'If it settles the decision, your turn ends. ' +\n '`note` is shown to the user as the assistant speaking, before the outcome: one short sentence in the first person saying what you chose and why, e.g. \"Your brief has no external feeds, so I\\'ll skip Data Feeds.\" Never mention an autopilot or a second agent.',\n parameters: {\n type: 'object',\n required: ['action'],\n properties: {\n action: {\n type: 'string',\n description:\n 'An option number from the list, starting at 1, or a named action (\"select\", \"reply\").',\n },\n options: {\n type: 'array',\n items: { type: 'string' },\n description: 'For \"select\": the options to choose, by number or label.',\n },\n text: {\n type: 'string',\n description:\n 'For \"reply\" (your answer, in the user\\'s place) and any action listed as name({text}): its one argument, as plain text.',\n },\n fields: {\n type: 'string',\n description:\n 'Only for an action listed as name({fields}): a JSON object, as text, matching the fields schema the decision lists for it.',\n },\n note: {\n type: 'string',\n description: 'Shown to the user as the assistant speaking. One sentence, first person.',\n },\n },\n },\n },\n {\n name: HAND_BACK,\n description:\n 'Give this one decision to the user, when it rests on something only they can know and neither their brief nor their own answers settle it, or when nothing on it can be done (every action unavailable). Your turn ends and the user sees the question. `reason` is shown to them as the assistant speaking, after \"I need your input on this one:\" — say plainly what you need from them. Never mention an autopilot or a second agent.',\n parameters: {\n type: 'object',\n required: ['reason'],\n properties: {\n reason: {\n type: 'string',\n description: 'What the user needs to decide, and why it is theirs.',\n },\n },\n },\n },\n]",
3930
+ "description": "The autopilot's three fixed tools (GENC-1660 §4.2, §4.6). Fixed for every decision, so the cached\nprefix holds: what varies — the widget, its actions, their arguments — travels in the decision\nmessage, not here. An autopilot's own tools and its widget tools join them, the whole list sorted\nby name and fixed for its session. Plain string and string-array fields only, which every\nprovider accepts (critique round 2, N5: Gemini rejects a type-array union)."
3472
3931
  }
3473
3932
  ],
3474
3933
  "exports": [
@@ -3510,6 +3969,40 @@
3510
3969
  "kind": "javascript-module",
3511
3970
  "path": "src/autopilot/decision-message.ts",
3512
3971
  "declarations": [
3972
+ {
3973
+ "kind": "variable",
3974
+ "name": "READ_CAP_CHARS",
3975
+ "type": {
3976
+ "text": "number"
3977
+ },
3978
+ "default": "20_000",
3979
+ "description": "How long one read may run, in characters: a view, a preview or a widget tool's result."
3980
+ },
3981
+ {
3982
+ "kind": "function",
3983
+ "name": "capRead",
3984
+ "return": {
3985
+ "type": {
3986
+ "text": "string"
3987
+ }
3988
+ },
3989
+ "parameters": [
3990
+ {
3991
+ "name": "text",
3992
+ "type": {
3993
+ "text": "string"
3994
+ }
3995
+ },
3996
+ {
3997
+ "name": "max",
3998
+ "default": "READ_CAP_CHARS",
3999
+ "type": {
4000
+ "text": "number"
4001
+ }
4002
+ }
4003
+ ],
4004
+ "description": "A read cut to READ_CAP_CHARS, with a note telling the model to ask for less. A safety\nnet: each widget pages its own data, and this stops one that does not from flooding a decision."
4005
+ },
3513
4006
  {
3514
4007
  "kind": "function",
3515
4008
  "name": "widgetAsText",
@@ -3541,6 +4034,40 @@
3541
4034
  ],
3542
4035
  "description": "A widget as text: what the person saw (GENC-1660 §4.7). From its registration's `asText` when it\nhas one; otherwise its name and a size-limited dump of its data — ugly, never wrong, and a nudge\nto register one."
3543
4036
  },
4037
+ {
4038
+ "kind": "variable",
4039
+ "name": "NOTHING_ENABLED_LINE",
4040
+ "type": {
4041
+ "text": "string"
4042
+ },
4043
+ "default": "'Nothing here can be done right now: every action is unavailable. Hand it back with hand_back, saying in your reason what is unavailable and why, so the user knows what to do.'",
4044
+ "description": "What a list of actions offers when none of them can be taken now."
4045
+ },
4046
+ {
4047
+ "kind": "function",
4048
+ "name": "anyActionable",
4049
+ "return": {
4050
+ "type": {
4051
+ "text": "boolean"
4052
+ }
4053
+ },
4054
+ "parameters": [
4055
+ {
4056
+ "name": "actions",
4057
+ "type": {
4058
+ "text": "readonly SurfaceAction[]"
4059
+ }
4060
+ },
4061
+ {
4062
+ "name": "withholdRefining",
4063
+ "optional": true,
4064
+ "type": {
4065
+ "text": "boolean"
4066
+ }
4067
+ }
4068
+ ],
4069
+ "description": "Whether any of `actions` can be taken now, as renderActions offers them: enabled, and not\na refining action withheld past the refinement limit."
4070
+ },
3544
4071
  {
3545
4072
  "kind": "function",
3546
4073
  "name": "renderActions",
@@ -3560,11 +4087,29 @@
3560
4087
  "name": "options",
3561
4088
  "default": "{}",
3562
4089
  "type": {
3563
- "text": "{ withholdReply?: boolean }"
4090
+ "text": "{ withholdRefining?: boolean; refinementsLeft?: number }"
4091
+ }
4092
+ }
4093
+ ],
4094
+ "description": "List a surface's actions for the model (GENC-1660 §4.2). Options are numbered from 1, so they are\nchosen by number rather than by retyping a label; platform-owned actions keep their names. An\nunavailable action is listed, and marked, so the model knows it exists but cannot take it.\nPast the refinement limit (`withholdRefining`), a refining action is not listed at all.\n\n`refinementsLeft`, when the step has a limit, is said beneath the list wherever the surface has\na refining action (listed or withheld), so the model can spend them knowingly. When nothing listed\ncan be taken, the list ends by saying the only way out is to hand it back."
4095
+ },
4096
+ {
4097
+ "kind": "function",
4098
+ "name": "renderViews",
4099
+ "return": {
4100
+ "type": {
4101
+ "text": "string[]"
4102
+ }
4103
+ },
4104
+ "parameters": [
4105
+ {
4106
+ "name": "surface",
4107
+ "type": {
4108
+ "text": "InteractionSurface"
3564
4109
  }
3565
4110
  }
3566
4111
  ],
3567
- "description": "List a surface's actions for the model (GENC-1660 §4.2). Options are numbered from 1, so they are\nchosen by number rather than by retyping a label; platform-owned actions keep their names. An\nunavailable action is listed, and marked, so the model knows it exists but cannot take it."
4112
+ "description": "List a surface's views for the model, as lines (GENC-1660 §4.2): one view a line, with what it\nholds, and the preview marked as the one shown below. Nothing where it has no views."
3568
4113
  },
3569
4114
  {
3570
4115
  "kind": "function",
@@ -3578,7 +4123,7 @@
3578
4123
  {
3579
4124
  "name": "opts",
3580
4125
  "type": {
3581
- "text": "{\n interactionId: string;\n componentName: string;\n data: unknown;\n surface: InteractionSurface;\n /** Set when the person clicked Resume to say \"decide it yourself\": no hand-back this time. */\n decideYourself?: boolean;\n /** Set past the refinement limit: `reply` is withdrawn. */\n withholdReply?: boolean;\n}"
4126
+ "text": "{\n interactionId: string;\n componentName: string;\n data: unknown;\n surface: InteractionSurface;\n /** Set when the person clicked Resume to say \"decide it yourself\": no hand-back this time. */\n decideYourself?: boolean;\n /** Set past the refinement limit: every refining action (`reply`, a regenerate) is withdrawn. */\n withholdRefining?: boolean;\n /** Refining actions left on this step, when it has a limit: said beneath the actions. */\n refinementsLeft?: number;\n}"
3582
4127
  }
3583
4128
  }
3584
4129
  ],
@@ -3635,6 +4180,22 @@
3635
4180
  }
3636
4181
  ],
3637
4182
  "exports": [
4183
+ {
4184
+ "kind": "js",
4185
+ "name": "READ_CAP_CHARS",
4186
+ "declaration": {
4187
+ "name": "READ_CAP_CHARS",
4188
+ "module": "src/autopilot/decision-message.ts"
4189
+ }
4190
+ },
4191
+ {
4192
+ "kind": "js",
4193
+ "name": "capRead",
4194
+ "declaration": {
4195
+ "name": "capRead",
4196
+ "module": "src/autopilot/decision-message.ts"
4197
+ }
4198
+ },
3638
4199
  {
3639
4200
  "kind": "js",
3640
4201
  "name": "widgetAsText",
@@ -3643,6 +4204,22 @@
3643
4204
  "module": "src/autopilot/decision-message.ts"
3644
4205
  }
3645
4206
  },
4207
+ {
4208
+ "kind": "js",
4209
+ "name": "NOTHING_ENABLED_LINE",
4210
+ "declaration": {
4211
+ "name": "NOTHING_ENABLED_LINE",
4212
+ "module": "src/autopilot/decision-message.ts"
4213
+ }
4214
+ },
4215
+ {
4216
+ "kind": "js",
4217
+ "name": "anyActionable",
4218
+ "declaration": {
4219
+ "name": "anyActionable",
4220
+ "module": "src/autopilot/decision-message.ts"
4221
+ }
4222
+ },
3646
4223
  {
3647
4224
  "kind": "js",
3648
4225
  "name": "renderActions",
@@ -3651,6 +4228,14 @@
3651
4228
  "module": "src/autopilot/decision-message.ts"
3652
4229
  }
3653
4230
  },
4231
+ {
4232
+ "kind": "js",
4233
+ "name": "renderViews",
4234
+ "declaration": {
4235
+ "name": "renderViews",
4236
+ "module": "src/autopilot/decision-message.ts"
4237
+ }
4238
+ },
3654
4239
  {
3655
4240
  "kind": "js",
3656
4241
  "name": "renderDecision",
@@ -3866,6 +4451,46 @@
3866
4451
  "module": "./hand-back/hand-back.controller"
3867
4452
  }
3868
4453
  },
4454
+ {
4455
+ "kind": "js",
4456
+ "name": "widgetTools",
4457
+ "declaration": {
4458
+ "name": "widgetTools",
4459
+ "module": "./widget-tools"
4460
+ }
4461
+ },
4462
+ {
4463
+ "kind": "js",
4464
+ "name": "type",
4465
+ "declaration": {
4466
+ "name": "type",
4467
+ "module": "./widget-tools"
4468
+ }
4469
+ },
4470
+ {
4471
+ "kind": "js",
4472
+ "name": "WidgetTools",
4473
+ "declaration": {
4474
+ "name": "WidgetTools",
4475
+ "module": "./widget-tools"
4476
+ }
4477
+ },
4478
+ {
4479
+ "kind": "js",
4480
+ "name": "type",
4481
+ "declaration": {
4482
+ "name": "type",
4483
+ "module": "./widget-tools"
4484
+ }
4485
+ },
4486
+ {
4487
+ "kind": "js",
4488
+ "name": "WidgetToolSpec",
4489
+ "declaration": {
4490
+ "name": "WidgetToolSpec",
4491
+ "module": "./widget-tools"
4492
+ }
4493
+ },
3869
4494
  {
3870
4495
  "kind": "js",
3871
4496
  "name": "AutopilotHandBack",
@@ -3876,6 +4501,46 @@
3876
4501
  }
3877
4502
  ]
3878
4503
  },
4504
+ {
4505
+ "kind": "javascript-module",
4506
+ "path": "src/autopilot/widget-tools.ts",
4507
+ "declarations": [
4508
+ {
4509
+ "kind": "function",
4510
+ "name": "widgetTools",
4511
+ "return": {
4512
+ "type": {
4513
+ "text": "WidgetTools"
4514
+ }
4515
+ },
4516
+ "parameters": [
4517
+ {
4518
+ "name": "componentName",
4519
+ "type": {
4520
+ "text": "string"
4521
+ }
4522
+ },
4523
+ {
4524
+ "name": "tools",
4525
+ "type": {
4526
+ "text": "{ [K in keyof TArgs]: WidgetToolSpec<TController, TArgs[K]> }"
4527
+ }
4528
+ }
4529
+ ],
4530
+ "description": "Declare tools that read from one widget type (GENC-1660): parameterised reads that a view cannot\nexpress, such as one table's rows, or a page of them.\n\nPut them on the autopilot (`defineAutopilot({ widgetTools: [...] })`), never discovered from the\nregistration. Its tool list is fixed when its session starts, sorted by name, and identical for\nevery decision, so the cache never breaks. Each call is routed to the interaction of\n`componentName` the autopilot is deciding, and `run` gets its controller; with none open, it is\nrefused with a reason. While one is open, the autopilot's tail says which tools are usable now.\n\nReads only. Their results leave the autopilot's history at the end of the decision, as\n`widget_read`'s do."
4531
+ }
4532
+ ],
4533
+ "exports": [
4534
+ {
4535
+ "kind": "js",
4536
+ "name": "widgetTools",
4537
+ "declaration": {
4538
+ "name": "widgetTools",
4539
+ "module": "src/autopilot/widget-tools.ts"
4540
+ }
4541
+ }
4542
+ ]
4543
+ },
3879
4544
  {
3880
4545
  "kind": "javascript-module",
3881
4546
  "path": "src/channel/ai-activity-bus.ts",
@@ -7034,7 +7699,7 @@
7034
7699
  "type": {
7035
7700
  "text": "string | null"
7036
7701
  },
7037
- "description": "Name of the agent the user has pinned via the agent picker. `null` means\norchestration: the assistant routes each message. Persisted on the session store, so it survives\npop-in/pop-out but resets on page refresh.\n\nOnly changes on explicit user action (picker click or host's `setAgent`).\nThe orchestrator's auto-pin on stateful activation writes\n`flowOwnerAgentName` instead, so finishing a guided flow doesn't wipe\nthe user's sticky pick."
7702
+ "description": "Name of the agent the user has pinned via the agent picker. `null` means\norchestration: the assistant routes each message. Persisted on the session store, so it survives\npop-in/pop-out. A page refresh resets it unless session persistence is on, which saves it with\nthe session and restores it.\n\nOnly changes on explicit user action (picker click or host's `setAgent`).\nThe orchestrator's auto-pin on stateful activation writes\n`flowOwnerAgentName` instead, so finishing a guided flow doesn't wipe\nthe user's sticky pick."
7038
7703
  },
7039
7704
  {
7040
7705
  "kind": "field",
@@ -9896,9 +10561,16 @@
9896
10561
  "type": {
9897
10562
  "text": "{ text?: string; files?: File[] }"
9898
10563
  }
10564
+ },
10565
+ {
10566
+ "name": "options",
10567
+ "optional": true,
10568
+ "type": {
10569
+ "text": "SubmitMessageOptions"
10570
+ }
9899
10571
  }
9900
10572
  ],
9901
- "description": "Programmatically submit a message. Equivalent to the user typing into the\nbuilt-in composer and pressing send, but callable from external code — most\ncommonly a custom input rendered inside `slot=\"splash\"` when paired with\n`chatConfig.ui.hideComposer`.\n\nThe input fully describes the turn: `text` and `files` REPLACE any current\ncomposer state (they are not appended to it). Files are validated against\n`chatConfig.ui.acceptedFiles` using the same pipeline as the composer's\nattach button.\n\nAtomic on validation: if any file fails validation, no attachments are\ncommitted and no send is dispatched. Failure messages are returned in\n`errors` AND appended to the `attachmentErrors` observable so the built-in\nchip UI still surfaces them when visible.\n\nResolves once the underlying send has been kicked off — it does NOT await\nthe assistant's response."
10573
+ "description": "Programmatically submit a message. Sends it the way the built-in composer's\nSend does, but from external code — a custom input rendered inside\n`slot=\"splash\"` when paired with `chatConfig.ui.hideComposer`, or a host\nsending on the user's behalf.\n\nThe input fully describes the turn: `text` and `files` are sent as given,\nand the composer is never read or cleared, so whatever the user has typed or\nattached there stays where it is. Files are validated against\n`chatConfig.ui.acceptedFiles` using the same pipeline as the composer's\nattach button. `options` routes the message — see SubmitMessageOptions.\n\nAtomic on validation: if any file fails validation, no send is dispatched,\nand the failure messages are returned in `errors`. They are not shown as\ncomposer chips: the files are the caller's, not the user's.\n\nResolves when the send settles: it awaits the driver's `sendMessage`, which\nfor the built-in drivers is the whole turn, the assistant's response included."
9902
10574
  },
9903
10575
  {
9904
10576
  "kind": "method",
@@ -9917,7 +10589,25 @@
9917
10589
  {
9918
10590
  "kind": "method",
9919
10591
  "name": "send",
9920
- "privacy": "private"
10592
+ "privacy": "private",
10593
+ "parameters": [
10594
+ {
10595
+ "name": "message",
10596
+ "optional": true,
10597
+ "type": {
10598
+ "text": "{ text: string; attachments: ChatAttachment[] }"
10599
+ },
10600
+ "description": "What to send in place of the composer's contents, which are then neither\nread nor cleared (`submitMessage`). Left out, the composer's contents are sent and cleared."
10601
+ },
10602
+ {
10603
+ "name": "routing",
10604
+ "optional": true,
10605
+ "type": {
10606
+ "text": "SendMessageOptions"
10607
+ },
10608
+ "description": "Passed on to the driver: how this one message is routed."
10609
+ }
10610
+ ]
9921
10611
  },
9922
10612
  {
9923
10613
  "kind": "method",
@@ -9938,6 +10628,31 @@
9938
10628
  ],
9939
10629
  "description": "The post-turn settle shared by `send()` and a resumed restore turn: back to idle through\nthe session ref captured at turn start, then the cleanup the state setter would have done."
9940
10630
  },
10631
+ {
10632
+ "kind": "method",
10633
+ "name": "reportTurnEnded",
10634
+ "privacy": "private",
10635
+ "return": {
10636
+ "type": {
10637
+ "text": "void"
10638
+ }
10639
+ },
10640
+ "parameters": [
10641
+ {
10642
+ "name": "prevState",
10643
+ "type": {
10644
+ "text": "AiAssistantState | undefined"
10645
+ }
10646
+ },
10647
+ {
10648
+ "name": "sessionRef",
10649
+ "type": {
10650
+ "text": "SessionStoreReturn | null | undefined"
10651
+ }
10652
+ }
10653
+ ],
10654
+ "description": "Report a turn that ended with the assistant waiting for the person to type (GENC-1660), for the\nAlways level: `turn-ended` on the activity bus, like every other notification report.\n\nOnly for a turn that ran to its end, failed ones included: not one the person stopped\n(`cancelling`), since they are there. Not while an interaction waits on them, which reports\nitself, so the person is never told twice about one moment. And not while an autopilot runs for\nthe flow: it answers, hands back or reports its own stop. Sub-agents' turns never get here; they\nrun inside one of the parent's."
10655
+ },
9941
10656
  {
9942
10657
  "kind": "method",
9943
10658
  "name": "onChatHeaderMouseDown",
@@ -10791,7 +11506,7 @@
10791
11506
  "type": {
10792
11507
  "text": "Record<MetaEventType, MetaEventImportance>"
10793
11508
  },
10794
- "default": "{\n 'turn.error': 'high',\n 'tool.failed': 'high',\n 'subagent.failed': 'high',\n 'file.read-failed': 'high',\n 'suggestions.failed': 'high',\n 'context.threshold-crossed': 'high',\n 'context.compacted': 'high',\n 'persistence.restore-orphan': 'high',\n // A save that did not land is silent data loss in progress: the transcript on screen\n // is no longer backed by the store, and every later turn widens the gap. GENC-1511.\n 'persistence.save-failed': 'high',\n\n 'assistant.connected': 'normal',\n 'assistant.disconnected': 'normal',\n 'assistant.popout': 'normal',\n 'assistant.popin': 'normal',\n 'driver.created': 'normal',\n 'state.changed': 'normal',\n 'turn.start': 'normal',\n 'turn.end': 'normal',\n 'turn.retry': 'normal',\n 'tool.unresolved': 'normal',\n 'subagent.started': 'normal',\n 'subagent.completed': 'normal',\n // One per routing decision, with what the classifier answered and what the call cost. Same\n // level as the handoff it produces: you read them together to follow how a turn was routed.\n 'routing.decided': 'normal',\n 'agent.handoff': 'normal',\n 'agent.pinned': 'normal',\n 'agent.unpinned': 'normal',\n 'provider.selected': 'normal',\n 'interaction.requested': 'normal',\n 'interaction.resolved': 'normal',\n // Bookkeeping about an already-finished turn; interesting when reconciling a session total.\n 'interaction.external-cost': 'normal',\n // Spend that was billed but could NOT be recorded (the message was trimmed/condensed away, or\n // the value was not real spend). 'high': it is the one way the session total goes quietly\n // wrong, so it must stand out when reconciling.\n 'interaction.external-cost-dropped': 'high',\n // What came of an answer, recorded by the tool that asked (see recordInteractionOutcome).\n 'interaction.outcome': 'normal',\n // An outcome that could not be recorded: the widget goes on showing only the answer.\n 'interaction.outcome-dropped': 'high',\n // A long action's step starting, finishing, or skipped on resume because it was already done.\n 'interaction.step': 'low',\n // A cut checkpoint taken over after a reload, refused (by sameWork, or as malformed), or dropped\n // at flow end.\n 'interaction.checkpoint': 'normal',\n // A claimant handing a pending interaction to the person, or taking it back.\n 'interaction.held': 'normal',\n // A claim on a `userOnly` interaction, refused. Expected when an interceptor claims broadly.\n 'interaction.claim-refused': 'low',\n // A claimant ran one of the surface's actions: what it did, and whether that settled it.\n 'interaction.invoked': 'normal',\n 'autopilot.claimed': 'normal',\n // One per interaction the autopilot does not take, so frequent and mostly expected.\n 'autopilot.declined': 'low',\n 'autopilot.decision-sent': 'low',\n 'autopilot.acted': 'normal',\n 'autopilot.handed-back': 'normal',\n 'autopilot.paused': 'normal',\n 'autopilot.resumed': 'normal',\n // The wrapper itself failed: the journey stops being automatic without anyone choosing that.\n 'autopilot.error': 'high',\n // A written answer counted against the step's limit; reaching it withdraws `reply`.\n 'autopilot.refinement': 'normal',\n // The autopilot showed its own widget because a working turn ended needing the person.\n 'autopilot.handback-presented': 'normal',\n // The autopilot was given the whole visible transcript: its first decision, a rebuild, or after\n // a compaction removed the last message it saw.\n 'autopilot.catch-up': 'normal',\n // Autopilot spend that reached no message, so it is missing from the session total.\n 'autopilot.cost-dropped': 'high',\n 'external-diagnostics.folded': 'normal',\n 'session.cleared': 'normal',\n 'session.switched': 'low',\n 'session.switch-deferred': 'low',\n 'persistence.restored': 'normal',\n // Whether a restored flow will be re-activated and resumed (GENC-1662), and how much the trim cut.\n 'persistence.resume-planned': 'normal',\n // A planned resume that did not run, and why (GENC-1662) — the divider was put back to plain.\n 'persistence.resume-withdrawn': 'normal',\n 'persistence.suppressed': 'normal',\n 'persistence.not-resumable': 'normal',\n\n 'driver.wired': 'low',\n 'driver.unwired': 'low',\n 'context.updated': 'low',\n 'context.condensed': 'low',\n 'panel.toggled': 'low',\n 'persistence.toggled': 'low',\n 'persistence.saved': 'low',\n 'attachment.added': 'low',\n}",
11509
+ "default": "{\n 'turn.error': 'high',\n 'tool.failed': 'high',\n 'subagent.failed': 'high',\n 'file.read-failed': 'high',\n 'suggestions.failed': 'high',\n 'context.threshold-crossed': 'high',\n 'context.compacted': 'high',\n 'persistence.restore-orphan': 'high',\n // A save that did not land is silent data loss in progress: the transcript on screen\n // is no longer backed by the store, and every later turn widens the gap. GENC-1511.\n 'persistence.save-failed': 'high',\n\n 'assistant.connected': 'normal',\n 'assistant.disconnected': 'normal',\n 'assistant.popout': 'normal',\n 'assistant.popin': 'normal',\n 'driver.created': 'normal',\n 'state.changed': 'normal',\n 'turn.start': 'normal',\n 'turn.end': 'normal',\n 'turn.retry': 'normal',\n 'tool.unresolved': 'normal',\n 'subagent.started': 'normal',\n 'subagent.completed': 'normal',\n // One per routing decision, with what the classifier answered and what the call cost. Same\n // level as the handoff it produces: you read them together to follow how a turn was routed.\n 'routing.decided': 'normal',\n 'agent.handoff': 'normal',\n 'agent.pinned': 'normal',\n 'agent.unpinned': 'normal',\n 'provider.selected': 'normal',\n 'interaction.requested': 'normal',\n 'interaction.resolved': 'normal',\n // Bookkeeping about an already-finished turn; interesting when reconciling a session total.\n 'interaction.external-cost': 'normal',\n // Spend that was billed but could NOT be recorded (the message was trimmed/condensed away, or\n // the value was not real spend). 'high': it is the one way the session total goes quietly\n // wrong, so it must stand out when reconciling.\n 'interaction.external-cost-dropped': 'high',\n // What came of an answer, recorded by the tool that asked (see recordInteractionOutcome).\n 'interaction.outcome': 'normal',\n // An outcome that could not be recorded: the widget goes on showing only the answer.\n 'interaction.outcome-dropped': 'high',\n // A long action's step starting, finishing, or skipped on resume because it was already done.\n 'interaction.step': 'low',\n // A cut checkpoint taken over after a reload, refused (by sameWork, and kept for a later request;\n // or as malformed), or dropped at flow end, as is the live one.\n 'interaction.checkpoint': 'normal',\n // A claimant handing a pending interaction to the person, or taking it back.\n 'interaction.held': 'normal',\n // A claim on a `userOnly` interaction, refused. Expected when an interceptor claims broadly.\n 'interaction.claim-refused': 'low',\n // A claimant ran one of the surface's actions: what it did, and whether that settled it.\n 'interaction.invoked': 'normal',\n 'autopilot.claimed': 'normal',\n // One per interaction the autopilot does not take, so frequent and mostly expected.\n 'autopilot.declined': 'low',\n 'autopilot.decision-sent': 'low',\n 'autopilot.acted': 'normal',\n 'autopilot.handed-back': 'normal',\n 'autopilot.paused': 'normal',\n 'autopilot.resumed': 'normal',\n // The wrapper itself failed: the journey stops being automatic without anyone choosing that.\n 'autopilot.error': 'high',\n // A written answer counted against the step's limit; reaching it withdraws `reply`.\n 'autopilot.refinement': 'normal',\n // The autopilot showed its own widget because a working turn ended needing the person.\n 'autopilot.handback-presented': 'normal',\n // The autopilot was given the whole visible transcript: its first decision, a rebuild, or after\n // a compaction removed the last message it saw.\n 'autopilot.catch-up': 'normal',\n // Autopilot spend that reached no message, so it is missing from the session total.\n 'autopilot.cost-dropped': 'high',\n 'external-diagnostics.folded': 'normal',\n 'session.cleared': 'normal',\n 'session.switched': 'low',\n 'session.switch-deferred': 'low',\n 'persistence.restored': 'normal',\n // Whether a restored flow will be re-activated and resumed (GENC-1662), and how much the trim cut.\n 'persistence.resume-planned': 'normal',\n // A planned resume that did not run, and why (GENC-1662) — the divider was put back to plain.\n 'persistence.resume-withdrawn': 'normal',\n 'persistence.suppressed': 'normal',\n 'persistence.not-resumable': 'normal',\n\n 'driver.wired': 'low',\n 'driver.unwired': 'low',\n 'context.updated': 'low',\n 'context.condensed': 'low',\n 'panel.toggled': 'low',\n 'persistence.toggled': 'low',\n 'persistence.saved': 'low',\n 'attachment.added': 'low',\n}",
10795
11510
  "description": "Importance is intrinsic to the event *type*, not the instance, so it's\ndefined once here and stamped automatically by recordMetaEvent — call\nsites never pass it. The `Record` is exhaustive: adding a `MetaEventType`\nwithout a level here is a compile error.\n\n- `high` — failures and hard limits you almost always want to see.\n- `normal` — meaningful session flow you read to follow what happened.\n- `low` — frequent UI / bookkeeping noise, usually safe to skip."
10796
11511
  },
10797
11512
  {
@@ -10953,7 +11668,7 @@
10953
11668
  "type": {
10954
11669
  "text": "readonly string[]"
10955
11670
  },
10956
- "default": "[\n 'This is an exported debug log for the Genesis AI assistant. Read it top-to-bottom.',\n \"`sessionUsage` is what this session spent: `costUsd` (USD, provider-reported per request and summed, cache discounts already applied) plus the four TOKEN BUCKETS — `uncachedInputTokens`, `cacheReadTokens`, `cacheWriteTokens`, `outputTokens`. Those four are disjoint and safe to add up for a total-tokens figure; the per-message fields further down are NOT (see kind:'message'). Each bucket bills at a different rate — cache reads a fraction of uncached input, cache writes a premium, output highest — so a big token count against a small cost means the prompt was mostly cache hits, not a missing charge. It covers sub-agent turns and spend a compaction banked, so for the CONVERSATION it is the authoritative total: prefer it over re-summing the timeline, which can be short by whatever the ring buffers evicted. The same figures appear under `meta.context`. It is as current as the snapshot it came from: the assistant's own download stamps a fresh one, but a log stitched by another tool can carry an older one — compare `meta.timestamp` with the last timeline entry, and if it is well behind, read these totals as historical and fall back to summing the timeline. One scope caveat: it is derived from the transcript, so it excludes billed calls that produced no message (a blank or refused attempt that was retried — see kind:'turn'.`usage`). Summing the turns can therefore come out HIGHER than this, and the difference is exactly that discarded spend, not a double-count.\",\n \"What 'session' means for those figures: the CURRENT conversation under this session key (a host-supplied per-project id, or the element id + header title when the host supplies none) — which is not necessarily everything in `timeline`. It is re-derived from the live transcript, so it spans page loads only when the chat is being remembered, and a Clear resets it to zero. `timeline` is append-only regardless: it keeps every page load and the pre-Clear conversation, with the session.cleared event as the boundary. So on a long-lived log, read these totals as the latest conversation's and the earlier sections as history — not as a total of the whole file.\",\n '`timeline` is the entire session as one array, already sorted chronologically by `timestamp` (ISO 8601). Every entry has a `kind`.',\n 'Timestamps are millisecond-resolution; entries that share the same millisecond are ordered by a fixed kind rank (event, then turn, then message), which is a heuristic and may not reflect exact causal order within that millisecond — e.g. a user message and the turn it triggered, or a final assistant message and its turn.end event, can appear in either order depending on whether they landed in the same millisecond. Read the logical structure of a turn rather than over-interpreting the micro-ordering of co-timestamped entries of different kinds.',\n \"kind:'message' — the conversation. `role` is user/assistant/tool/system-event/synthetic-user; `agentName` says which agent produced it; `toolCalls`/`toolResult`/`interaction` carry tool and widget activity; `inputTokens`/`outputTokens`/`cost` are per-message LLM usage, where `inputTokens` is the WHOLE prompt for that request and `cacheReadTokens`/`cacheWriteTokens` BREAK IT DOWN rather than add to it — uncached input is `inputTokens` minus those two, and adding the cache fields to `inputTokens` counts the prompt twice. The cache fields are absent on providers that report no cache split (Gemini reports reads only, since implicit caching bills no write) and on messages persisted before they existed, so read them as 0 when missing. Each bucket bills at a different rate — cache reads a fraction of uncached input, cache writes a premium, output highest — so a large token count at a small cost means the prompt was mostly cache hits. `externalCostUsd` is any non-LLM cost a widget reported for its own external service calls (folded into the session cost total alongside `cost`). On model-produced assistant messages, `model` is the concrete model id that generated it (e.g. 'gemini-2.5-flash-lite') and `providerName` is the registry slot it resolved under (e.g. a tier name like 'high'/'low', or the default); together they attribute the message — and any tool calls it carries — to an exact model even across a mid-session vendor/tier switch, where one slot name can map to different models before and after the switch. Both are undefined on any entry that is NOT an LLM response: non-assistant roles (user/tool/system-event) and 'synthetic-user' echoes; assistant interaction/widget entries (empty content carrying an `interaction` — a rendered widget, not a model turn); driver-authored assistant fallbacks (the timeout, repeated-malformed-call, and empty-response apology messages); and messages restored from a session persisted before these fields existed. One partial case: on a genuine model turn whose provider exposes no `getStatus` (or reports no model), `providerName` is still set but `model` alone is undefined. A 'synthetic-user' message is a display-only echo of an interaction outcome (e.g. the answer a widget reported): it renders on the user's side of the chat and `agentName` is the agent that created it, but it is never sent to the LLM — so it has no matching 'turn' and the model learns the outcome only from the corresponding tool result. An echo of an answer an interceptor (such as an autopilot) gave is NOT synthetic-user: see the delegated-messages paragraph.\",\n 'The autopilot (GENC-1660) runs on a driver of its own, and everything it did is harvested into this log: entries with delegate: autopilot and an agentName ending in › Autopilot are its turns (the decision message it was sent is the user message of its turn, so what it was shown is there verbatim; its systemPrompt is its grounding, such as the brief), its tool calls (widget_read, widget_act, hand_back) and their results, and its own events. Its cost is already in the session total: it is booked as externalCostUsd on the interaction each decision answered, or, for a written question it answered, on the user message it sent on the user behalf (delegate: autopilot), so do not add its turns to that total. Spend that reached no message is recorded as autopilot.cost-dropped instead.',\n \"Delegated messages (GENC-1660): a message with a `delegate` field was written or sent ON THE USER'S BEHALF by a driver decorator, and `delegate` names it (e.g. autopilot). The platform stamps it; nothing else can. It renders as the assistant whatever its role. A delegated `user` message was NOT typed by the user: it is an answer given on their behalf, and the model read it with `delegateFraming` in brackets in front of the content (the stored `content` is the bare text). A delegated `assistant` message is display-only (`excludeFromProvider`): the decorator's narration, or the echo of a widget answer it gave, which takes the place of a synthetic-user echo. To tell what the person decided from what was decided for them, read `interaction.answeredBy` and these fields, never the role alone.\",\n \"Sub-agent messages appear inline. When a tool delegates to a sub-agent (via `requestSubAgent`), the sub-agent's whole conversation — its own assistant/tool messages, each with their own `content`/`thinking`/`toolCalls`/`toolResult` and per-message `model`/`providerName`/`inputTokens`/`outputTokens`/`cacheReadTokens`/`cacheWriteTokens`/`cost` — is hoisted into the timeline as ordinary kind:'message' entries, interleaved by timestamp right after the tool call that spawned them (so you read the delegation top-to-bottom). A hoisted entry is marked: `subAgentDepth` is its delegation depth (1 for a sub-agent, 2 for a sub-agent's sub-agent, …), `subAgentOf` is the id of the parent tool call that spawned it (correlates it back even when two sub-agents run in one parent turn), `subAgentName` is the sub-agent's own name, and `agentName` is rewritten to a `\\\"<parent> › <sub-agent>\\\"` breadcrumb (composing when nested, e.g. `\\\"UI Builder › Planner › Grounding\\\"`). The sub-agent's per-LLM-call snapshots also surface as kind:'turn' entries with an N-M `turnIndex`, and subagent.started/completed (or subagent.failed) events bracket the run. Per-message `cost` on hoisted entries is already part of the session total (it is summed from the un-flattened history), so summing the top-level timeline does NOT double-count.\",\n \"kind:'turn' — one LLM call. `turnIndex` is a string: a top-level turn is the bare counter ('0', '1', …); a sub-agent's turns are numbered under the parent turn that activated them ('3-1', '3-2', …, and a nested sub-agent contributes '3-2-1', …), and `agentName` names the agent that ran the turn. `systemPrompt` and `toolNames` are what the model saw. A systemPrompt of '<repeated — identical to turn N>' was byte-identical to turn N and de-duplicated; the full prompt is shown whenever it changes (often because a stateful agent advanced), so prompt evolution is visible.\",\n \"kind:'turn'.`model`/`providerName`/`provider` — which model ran that call: the concrete model id, the registry slot it resolved under (a tier name like 'high'/'low', or the default), and the vendor. Recorded per CALL, so an agent whose `provider` selector varies by state — a flow that plans on a high tier and executes on a low one — has every step attributed, including calls that produced no message. `model` is the SERVING model where the provider reports one, so a turn answered by a server-side fallback names the model that answered rather than the one requested; it always matches the `model` on the message that call produced. Absent when the provider exposes no `getStatus` and the transport stamped nothing.\",\n \"kind:'turn'.`usage` — what that ONE call cost, in the same four-bucket + `costUsd` shape as `sessionUsage`. Absent while a call is in flight and on providers that report no usage. This is the SAME money as the message the call produced, not extra money: never add turn usage to message usage, and read a turn plus its message as one charge. Its distinct value is the calls that produced NO message — a blank or refused response is billed and then discarded before the retry, so the turn entry is the only record of that spend, and a turn with `usage` but no message after it is exactly that. `costUsd: 0` alongside a nonzero token count means the provider reported no price, not that the call was free.\",\n \"kind:'turn'.`agentSnapshot` — the active agent's own view of its internal state, captured at that turn. An agent opts into this by exposing a `getDebugSnapshot()` that returns JSON-serializable per-state info; stateful/flow agents wire it automatically, so you can watch a flow advance turn-by-turn (e.g. current step, cursor, collected fields, pending changes). Absent for agents that don't expose one.\",\n \"kind:'event' — a meta/lifecycle event. `type` names it (see below); `detail` carries structured data. `detail.placement` is the emitting UI instance: 'bubble' (collapsed), 'panel' (popped-out), or 'standalone'.\",\n \"Each 'event' also has an `importance`: 'high' (failures/limits — turn.error, tool.failed, subagent.failed, file.read-failed, suggestions.failed, context.threshold-crossed), 'normal' (session flow — connects, turns, retries, handoffs, agent/provider changes, interactions, sub-agent start/complete), or 'low' (skippable UI/bookkeeping noise — panel.toggled, attachment.added, driver.wired/unwired, context.updated, context.condensed). To skim, ignore importance:'low'; to triage a failure, filter to importance:'high' then read the nearby messages and turns. A 'high' turn.error is often preceded by one or more 'normal' turn.retry events for the same reason — read them together to see how many attempts were made before bailing. 'message' and 'turn' entries carry no importance — they are the substance, always read them.\",\n 'Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations/response-truncated/refusal/budget-exhausted/provider-refused/context-exhausted/ai-service-error, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, for response-truncated the model + maxTokens + outputTokens + tools, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, for budget-exhausted the budgetUsd + spentUsd figures reported by the proxy plus the resolved vendor, for provider-refused the kind (spend|auth) plus the upstream status and error type — the vendor refusing the ACCOUNT rather than us refusing to spend, so the remedy is a top-up or a key rotation rather than a raised cap, and the kind is the only place that distinction survives because the user-facing copy is deliberately cause-free, for context-exhausted the estimated contextTokens against the guard that stopped the turn plus the iterations reached — the driver ending a runaway tool loop at the edge of the context window rather than issuing a request the provider would reject, so the transcript survives intact and can still be compacted, for ai-service-error the code (one of AI_SERVICE_ERROR_CODES, e.g. NO_API_KEY) and the status the AI service answered with — its own text goes to the browser console only, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation — detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with an N-M `turnIndex`; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout/response_truncated/refusal/budget_exhausted/provider_refused/context_exhausted/ai_service_error; budget_exhausted and provider_refused are terminal for the PARENT turn too, and so is ai_service_error when the refusal is about the service rather than the request and came from the vendor the parent calls — the parent stops rather than calling the model again into the same wall; after context_exhausted the parent goes on, but its own next call is likely to stop on the same guard), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), routing.decided (ONE PER ROUTING DECISION — see its own paragraph below), provider.selected (the resolved provider for the upcoming turns — detail.provider is the registry SLOT/tier name, detail.model the concrete model behind it and detail.vendor its vendor; emitted only when the slot CHANGES, so read the per-turn `model` for the model of any given call rather than assuming the nearest event still applies), interaction.requested/resolved (blocking user widgets — explain quiet gaps; note that when a sub-agent opens a widget, detail.agent — and the agentName on the interaction message — is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver; detail.ownerPath names the agents that actually asked, outermost first, the last being the one whose tool requested it, and detail.heldBy says who held it when it opened: user, or the id of the interceptor that claimed it, such as autopilot; on interaction.resolved, detail.answeredBy is who answered — the claimant id when it settled through its own hold, user for any other answer (a click counts as the person even on a widget a claimant held) — absent when it closed unanswered (a timeout or a stop); the same value is stamped on the interaction message as answeredBy, and when it is not user the tool result that interaction returned carries a decidedOnUsersBehalf record, so the model was told the choice was not made by the person; detail.edits, present only when non-zero, counts the editing actions a claimant ran on the widget before it was settled, whoever settled it, and those edits are stamped on the interaction message as edits, each with by, action, choice and args when it had some, in the order they ran, while a decidedOnUsersBehalf record carries their choice texts as edits, and when the person settled it after such edits the tool result carries an editedOnUsersBehalf record instead — the framing and those choice texts — so the model knows the widget was changed on the user behalf before the user answered, and that the user then confirmed it by finishing it), interaction.held (a claimant moved a pending interaction to the person or back to itself — detail.heldBy is the new holder, detail.claimant the interceptor; a widget held by anything but user was not answered by the person), interaction.claim-refused (a claim on a userOnly interaction, which stays with the person — detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user — autopilot.claimed / autopilot.declined say whether it took each interaction and, for a decline, detail.reason: paused, other-flow, no-autopilot, unavailable, userOnly, policy or no-controller; autopilot.decision-sent is what it was sent (detail.chars); autopilot.acted is what it did (detail.action, detail.note, detail.finished); autopilot.handed-back is a decision it gave to the person (detail.reason and detail.trigger: model, no-decision or error); autopilot.paused / autopilot.resumed are mode changes (detail.scope, detail.trigger, detail.decideYourself when the person resumed during a hand-back; detail.trigger is restored when the mode came back with the session after a reload, applied once its flow re-activated, which starts nothing by itself); autopilot.error is the wrapper itself failing; autopilot.refinement counts a written answer against its step (detail.stepKey, detail.count, detail.limitReached, after which reply is withdrawn for that step); autopilot.handback-presented is the turn-level hand-back, shown when a working turn ended needing the person with no widget to hand over (detail.why: max-iterations, context-exhausted, failure or question; detail.options; detail.choice once answered); autopilot.catch-up is the autopilot being given the whole visible transcript at once (detail.why: first, for its first decision in a flow or after a reload; size, when its own history passed its budget and was rebuilt short — detail.ownChars; or compacted, when a compaction removed the last message it had seen, so it reads the summary and everything since, short; in each, what it had sent on the user behalf is included and labelled as its own, since its own history does not hold it); autopilot.cost-dropped is autopilot spend that no message carries, so it is NOT in the session total (detail.costUsd and detail.why: handed-back, aborted or stale for a written question it answered that no reply was sent for — stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere — or no-recorder when the driver had no way to book a decision to its interaction); a hand-back trigger can also be budget (the decision passed its spend cap), watchdog (its work went quiet: no ready surface and no heartbeat, or its own decision stalled with no model call landing, which stops that decision) or detached (the autopilot was removed while it held the interaction, which went to the person with no reason shown). To debug one autopilot decision, follow its interactionId: interaction.requested (heldBy), autopilot.claimed, autopilot.decision-sent, autopilot.acted or autopilot.handed-back, interaction.invoked, interaction.resolved (answeredBy), then the next turn of the working agent), interaction.invoked (a claimant ran one of the actions the widget itself exposes, through its hold, the same code the button runs — detail.claimant, detail.action (an option id, select or reply) and detail.finished, whether that settled the interaction, and when it did not, the run is recorded as an edit; the choice and narration it recorded reach the result of the tool that asked as decidedOnUsersBehalf), interaction.step (a long action run as named steps through runSteps, which survive a reload — detail.step and detail.outcome: started, done, skipped when the step was already done before a reload, or resumed when it started before a reload and runs again with what it saved part-way, such as a job id it re-attaches to), interaction.checkpoint (the one checkpoint a conversation keeps for its long action — detail.action: resumed when a reload cut the work and the next request of the same widget type took it over, refused when the registration sameWork said the new request is different work (detail.saved is the identity it kept) or when runSteps found the handed-over checkpoint malformed and started fresh (detail.reason, detail.saved), or cleared when its flow ended with nothing taking it over), context.updated/threshold-crossed (token + cost), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool — detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.',\n 'Sub-agent meta events: a sub-agent\\'s own turn.retry/turn.error/tool.failed/tool.unresolved events are merged into this same timeline, tagged with `detail.subAgent` — a `\"<parent> › <sub-agent>\"` breadcrumb that composes when nested (e.g. `\"UI Builder › Planner › Grounding\"`) — and interleaved by their original timestamps within the subagent.started→completed/failed bracket. These are the per-attempt/per-failure signals that do NOT appear among the sub-agent\\'s (hoisted) messages: a malformed/empty attempt that gets retried produces no message, and the stale-vs-hallucinated split and streak counts live only on the event. A sub-agent\\'s high-volume, message-derivable events (turn.start/turn.end, provider.selected, context.updated) are intentionally NOT merged — read its hoisted messages for model/tokens/cost and turn-by-turn activity, and the bracketing subagent.* events for the run\\'s span.',\n \"`meta` holds context captured at export time: agentSummary (full agent configs), context (active model, contextTokens/contextLimit/contextUsagePercent for the last call, and the session totals — sessionCostUsd, sessionTokensConsumed, and the four-bucket sessionUsage lifted to the top of this log), activeDebugSnapshot (the active agent's `getDebugSnapshot()` taken fresh at export — reflects state NOW, which may have advanced beyond the last turn's agentSnapshot), debug (optional host-supplied debug state), host, and the export timestamp.\",\n 'Note the two different scopes in `meta.context`: `contextTokens` is the prompt size of the LAST call (against `contextLimit`, the model context window), while `sessionUsage`/`sessionTokensConsumed` are cumulative BILLED throughput. Every turn resends the conversation, so the cumulative figure counts each turn’s prompt again in the next turn’s and is expected to dwarf the context size — that is not double-counting.',\n \"kind:'event' type 'routing.decided' — how ONE turn was routed, emitted by the orchestrating driver before the agent runs (and again after every handoff). `decision` is why that agent was chosen: 'classified' (the classifier ran and picked one), 'no-match' (it ran and answered -1 — nothing listed covers the request), 'ballot-exhausted' (every eligible specialist had already handed off this turn, so the ballot was empty and NO call was made — distinct from 'no-match', where one ran and declined), 'pinned' (a user pin or an active stateful flow owned the turn, so no call was made), 'single-candidate'/'no-specialists' (configuration left nothing to decide), 'provider-unavailable' (the registry default exposes no chat()), 'classifier-failed' (every attempt threw — `error` carries the last one). `to` names the agent and `fallback` says whether that agent is the fallback. `candidates` is what was actually ON THE BALLOT, in ballot order, so `index` — the classifier's own answer — indexes it directly; `excluded` names the specialists left off because they already handed off this turn, so the full eligible set is `candidates` ∪ `excluded`. `candidates` is absent on the four decisions that put nothing to a vote — 'pinned', 'single-candidate', 'no-specialists', 'ballot-exhausted'. It IS present on 'provider-unavailable', which is not an exception worth removing: the ballot was built there, it simply never got sent. `attempts` covers the retry ladder. `durationMs` is on EVERY routing.decided, and is the field to read when a decision looks wrong: the four decisions that can reach the fallback are told apart by the clock as much as by their name, because a fallback routing that resolved in tens of milliseconds made no network call at all whatever its `decision` says.\",\n \"kind:'event' type 'routing.decided'.`usage` — what that classifier call cost, in the same four-bucket + costUsd shape as `sessionUsage`, plus `model`. Absent on the decisions that make no call (see 'pinned' and the configuration ones). THIS SPEND IS NOT IN `sessionUsage`: a classifier call never enters the transcript and `sessionUsage` is derived from the transcript, so classifier cost is missing from the session total by construction, not by accident. Sum these events to close that gap — it is the one component of a session's real spend that the totals cannot see.\",\n 'To debug a failure: find the last turn.error or tool.failed, then read upward for the user message, the turn(s), and the agent/provider/state events that led into it. For a turn that went to the wrong agent, read its routing.decided first — `decision` says whether anything was actually asked.',\n]",
11671
+ "default": "[\n 'This is an exported debug log for the Genesis AI assistant. Read it top-to-bottom.',\n \"`sessionUsage` is what this session spent: `costUsd` (USD, provider-reported per request and summed, cache discounts already applied) plus the four TOKEN BUCKETS — `uncachedInputTokens`, `cacheReadTokens`, `cacheWriteTokens`, `outputTokens`. Those four are disjoint and safe to add up for a total-tokens figure; the per-message fields further down are NOT (see kind:'message'). Each bucket bills at a different rate — cache reads a fraction of uncached input, cache writes a premium, output highest — so a big token count against a small cost means the prompt was mostly cache hits, not a missing charge. It covers sub-agent turns and spend a compaction banked, so for the CONVERSATION it is the authoritative total: prefer it over re-summing the timeline, which can be short by whatever the ring buffers evicted. The same figures appear under `meta.context`. It is as current as the snapshot it came from: the assistant's own download stamps a fresh one, but a log stitched by another tool can carry an older one — compare `meta.timestamp` with the last timeline entry, and if it is well behind, read these totals as historical and fall back to summing the timeline. One scope caveat: it is derived from the transcript, so it excludes billed calls that produced no message (a blank or refused attempt that was retried — see kind:'turn'.`usage`). Summing the turns can therefore come out HIGHER than this, and the difference is exactly that discarded spend, not a double-count.\",\n \"What 'session' means for those figures: the CURRENT conversation under this session key (a host-supplied per-project id, or the element id + header title when the host supplies none) — which is not necessarily everything in `timeline`. It is re-derived from the live transcript, so it spans page loads only when the chat is being remembered, and a Clear resets it to zero. `timeline` is append-only regardless: it keeps every page load and the pre-Clear conversation, with the session.cleared event as the boundary. So on a long-lived log, read these totals as the latest conversation's and the earlier sections as history — not as a total of the whole file.\",\n '`timeline` is the entire session as one array, already sorted chronologically by `timestamp` (ISO 8601). Every entry has a `kind`.',\n 'Timestamps are millisecond-resolution; entries that share the same millisecond are ordered by a fixed kind rank (event, then turn, then message), which is a heuristic and may not reflect exact causal order within that millisecond — e.g. a user message and the turn it triggered, or a final assistant message and its turn.end event, can appear in either order depending on whether they landed in the same millisecond. Read the logical structure of a turn rather than over-interpreting the micro-ordering of co-timestamped entries of different kinds.',\n \"kind:'message' — the conversation. `role` is user/assistant/tool/system-event/synthetic-user; `agentName` says which agent produced it; `toolCalls`/`toolResult`/`interaction` carry tool and widget activity; `inputTokens`/`outputTokens`/`cost` are per-message LLM usage, where `inputTokens` is the WHOLE prompt for that request and `cacheReadTokens`/`cacheWriteTokens` BREAK IT DOWN rather than add to it — uncached input is `inputTokens` minus those two, and adding the cache fields to `inputTokens` counts the prompt twice. The cache fields are absent on providers that report no cache split (Gemini reports reads only, since implicit caching bills no write) and on messages persisted before they existed, so read them as 0 when missing. Each bucket bills at a different rate — cache reads a fraction of uncached input, cache writes a premium, output highest — so a large token count at a small cost means the prompt was mostly cache hits. `externalCostUsd` is any non-LLM cost a widget reported for its own external service calls (folded into the session cost total alongside `cost`). On model-produced assistant messages, `model` is the concrete model id that generated it (e.g. 'gemini-2.5-flash-lite') and `providerName` is the registry slot it resolved under (e.g. a tier name like 'high'/'low', or the default); together they attribute the message — and any tool calls it carries — to an exact model even across a mid-session vendor/tier switch, where one slot name can map to different models before and after the switch. Both are undefined on any entry that is NOT an LLM response: non-assistant roles (user/tool/system-event) and 'synthetic-user' echoes; assistant interaction/widget entries (empty content carrying an `interaction` — a rendered widget, not a model turn); driver-authored assistant fallbacks (the timeout, repeated-malformed-call, and empty-response apology messages); and messages restored from a session persisted before these fields existed. One partial case: on a genuine model turn whose provider exposes no `getStatus` (or reports no model), `providerName` is still set but `model` alone is undefined. A 'synthetic-user' message is a display-only echo of an interaction outcome (e.g. the answer a widget reported): it renders on the user's side of the chat and `agentName` is the agent that created it, but it is never sent to the LLM — so it has no matching 'turn' and the model learns the outcome only from the corresponding tool result. An echo of an answer an interceptor (such as an autopilot) gave is NOT synthetic-user: see the delegated-messages paragraph.\",\n 'The autopilot (GENC-1660) runs on a driver of its own, and everything it did is harvested into this log: entries with delegate: autopilot and an agentName ending in › Autopilot are its turns (the decision message it was sent is the user message of its turn, so what it was shown is there verbatim; its systemPrompt is its grounding, such as the brief), its tool calls (widget_read, widget_act, hand_back, any read-only tools of its own, and its widget tools — reads with parameters that a widget type declares, routed to the interaction of that type being decided and refused with a reason when none is, offered on every decision so its tool list never changes; while one is open its tail starts with a line naming them) and their results (a read, view or widget tool, is capped at about 20,000 characters, cut with a note asking for less, and leaves its history at the end of the decision as a one-line note), and its own events. Its cost is already in the session total: it is booked as externalCostUsd on the interaction each decision answered, or, for a written question it answered, on the user message it sent on the user behalf (delegate: autopilot), so do not add its turns to that total. Spend that reached no message is recorded as autopilot.cost-dropped instead.',\n \"Delegated messages (GENC-1660): a message with a `delegate` field was written or sent ON THE USER'S BEHALF by a driver decorator, and `delegate` names it (e.g. autopilot). The platform stamps it; nothing else can. It renders as the assistant whatever its role. A delegated `user` message was NOT typed by the user: it is an answer given on their behalf, and the model read it with `delegateFraming` in brackets in front of the content (the stored `content` is the bare text). A delegated `assistant` message is display-only (`excludeFromProvider`): the decorator's narration note, or, when its answer carried no note, the widget's own echo of the answer (its `userMessage`), shown as the assistant and never as the person. A widget answer a decorator gave with a note is not echoed at all: the note already says what was chosen. To tell what the person decided from what was decided for them, read `interaction.answeredBy` and these fields, never the role alone.\",\n \"Sub-agent messages appear inline. When a tool delegates to a sub-agent (via `requestSubAgent`), the sub-agent's whole conversation — its own assistant/tool messages, each with their own `content`/`thinking`/`toolCalls`/`toolResult` and per-message `model`/`providerName`/`inputTokens`/`outputTokens`/`cacheReadTokens`/`cacheWriteTokens`/`cost` — is hoisted into the timeline as ordinary kind:'message' entries, interleaved by timestamp right after the tool call that spawned them (so you read the delegation top-to-bottom). A hoisted entry is marked: `subAgentDepth` is its delegation depth (1 for a sub-agent, 2 for a sub-agent's sub-agent, …), `subAgentOf` is the id of the parent tool call that spawned it (correlates it back even when two sub-agents run in one parent turn), `subAgentName` is the sub-agent's own name, and `agentName` is rewritten to a `\\\"<parent> › <sub-agent>\\\"` breadcrumb (composing when nested, e.g. `\\\"UI Builder › Planner › Grounding\\\"`). The sub-agent's per-LLM-call snapshots also surface as kind:'turn' entries with an N-M `turnIndex`, and subagent.started/completed (or subagent.failed) events bracket the run. Per-message `cost` on hoisted entries is already part of the session total (it is summed from the un-flattened history), so summing the top-level timeline does NOT double-count.\",\n \"kind:'turn' — one LLM call. `turnIndex` is a string: a top-level turn is the bare counter ('0', '1', …); a sub-agent's turns are numbered under the parent turn that activated them ('3-1', '3-2', …, and a nested sub-agent contributes '3-2-1', …), and `agentName` names the agent that ran the turn. `systemPrompt` and `toolNames` are what the model saw. A systemPrompt of '<repeated — identical to turn N>' was byte-identical to turn N and de-duplicated; the full prompt is shown whenever it changes (often because a stateful agent advanced), so prompt evolution is visible.\",\n \"kind:'turn'.`model`/`providerName`/`provider` — which model ran that call: the concrete model id, the registry slot it resolved under (a tier name like 'high'/'low', or the default), and the vendor. Recorded per CALL, so an agent whose `provider` selector varies by state — a flow that plans on a high tier and executes on a low one — has every step attributed, including calls that produced no message. `model` is the SERVING model where the provider reports one, so a turn answered by a server-side fallback names the model that answered rather than the one requested; it always matches the `model` on the message that call produced. Absent when the provider exposes no `getStatus` and the transport stamped nothing.\",\n \"kind:'turn'.`usage` — what that ONE call cost, in the same four-bucket + `costUsd` shape as `sessionUsage`. Absent while a call is in flight and on providers that report no usage. This is the SAME money as the message the call produced, not extra money: never add turn usage to message usage, and read a turn plus its message as one charge. Its distinct value is the calls that produced NO message — a blank or refused response is billed and then discarded before the retry, so the turn entry is the only record of that spend, and a turn with `usage` but no message after it is exactly that. `costUsd: 0` alongside a nonzero token count means the provider reported no price, not that the call was free.\",\n \"kind:'turn'.`agentSnapshot` — the active agent's own view of its internal state, captured at that turn. An agent opts into this by exposing a `getDebugSnapshot()` that returns JSON-serializable per-state info; stateful/flow agents wire it automatically, so you can watch a flow advance turn-by-turn (e.g. current step, cursor, collected fields, pending changes). Absent for agents that don't expose one.\",\n \"kind:'event' — a meta/lifecycle event. `type` names it (see below); `detail` carries structured data. `detail.placement` is the emitting UI instance: 'bubble' (collapsed), 'panel' (popped-out), or 'standalone'.\",\n \"Each 'event' also has an `importance`: 'high' (failures/limits — turn.error, tool.failed, subagent.failed, file.read-failed, suggestions.failed, context.threshold-crossed), 'normal' (session flow — connects, turns, retries, handoffs, agent/provider changes, interactions, sub-agent start/complete), or 'low' (skippable UI/bookkeeping noise — panel.toggled, attachment.added, driver.wired/unwired, context.updated, context.condensed). To skim, ignore importance:'low'; to triage a failure, filter to importance:'high' then read the nearby messages and turns. A 'high' turn.error is often preceded by one or more 'normal' turn.retry events for the same reason — read them together to see how many attempts were made before bailing. 'message' and 'turn' entries carry no importance — they are the substance, always read them.\",\n 'Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations/response-truncated/refusal/budget-exhausted/provider-refused/context-exhausted/ai-service-error, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, for response-truncated the model + maxTokens + outputTokens + tools, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, for budget-exhausted the budgetUsd + spentUsd figures reported by the proxy plus the resolved vendor, for provider-refused the kind (spend|auth) plus the upstream status and error type — the vendor refusing the ACCOUNT rather than us refusing to spend, so the remedy is a top-up or a key rotation rather than a raised cap, and the kind is the only place that distinction survives because the user-facing copy is deliberately cause-free, for context-exhausted the estimated contextTokens against the guard that stopped the turn plus the iterations reached — the driver ending a runaway tool loop at the edge of the context window rather than issuing a request the provider would reject, so the transcript survives intact and can still be compacted, for ai-service-error the code (one of AI_SERVICE_ERROR_CODES, e.g. NO_API_KEY) and the status the AI service answered with — its own text goes to the browser console only, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), subagent.started/completed/failed (the lifecycle of a `requestSubAgent` delegation — detail.agent names the sub-agent; these bracket the sub-agent turns that appear as kind:turn entries with an N-M `turnIndex`; subagent.failed also carries detail.reason, one of max_iterations/malformed_tool_call/empty_response/unknown_tool_limit/timeout/response_truncated/refusal/budget_exhausted/provider_refused/context_exhausted/ai_service_error; budget_exhausted and provider_refused are terminal for the PARENT turn too, and so is ai_service_error when the refusal is about the service rather than the request and came from the vendor the parent calls — the parent stops rather than calling the model again into the same wall; after context_exhausted the parent goes on, but its own next call is likely to stop on the same guard), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), routing.decided (ONE PER ROUTING DECISION — see its own paragraph below), provider.selected (the resolved provider for the upcoming turns — detail.provider is the registry SLOT/tier name, detail.model the concrete model behind it and detail.vendor its vendor; emitted only when the slot CHANGES, so read the per-turn `model` for the model of any given call rather than assuming the nearest event still applies), interaction.requested/resolved (blocking user widgets — explain quiet gaps; note that when a sub-agent opens a widget, detail.agent — and the agentName on the interaction message — is the HOST agent that owns the widget, NOT the sub-agent that asked, because widgets render and resolve on the host driver; detail.ownerPath names the agents that actually asked, outermost first, the last being the one whose tool requested it, and detail.heldBy says who held it when it opened: user, or the id of the interceptor that claimed it, such as autopilot; on interaction.resolved, detail.answeredBy is who answered — the claimant id when it settled through its own hold, user for any other answer (a click counts as the person even on a widget a claimant held) — absent when it closed unanswered (a timeout or a stop), and absent too when it settled by itself other than through the hold of a claimant — a widget registered resolvesItself (one that does its work and settles on its own, asking the person nothing, such as a generation run), or one outcome its controller said settled itself (ctx.resolve with resolvedItself, such as a generation phase that failed outright before its review gate ever asked anything) — which then carries detail.resolvedItself: true instead, as the interaction message does — nobody answered it, and the platform cannot tell it finishing from the person interrupting it (a Skip), so only the result of the widget itself can say which; the same value is stamped on the interaction message as answeredBy and on the result the asking tool handler receives (absent there in the same cases), and when it is not user the tool result that interaction returned carries a decidedOnUsersBehalf record, so the model was told the choice was not made by the person; detail.edits, present only when non-zero, counts the editing actions a claimant ran on the widget before it was settled, whoever settled it, and those edits are stamped on the interaction message as edits, each with by, action, choice and args when it had some, in the order they ran, while a decidedOnUsersBehalf record carries their choice texts as edits, and when the person settled it after such edits the tool result carries an editedOnUsersBehalf record instead — the framing and those choice texts — so the model knows the widget was changed on the user behalf before the user answered, and that the user then confirmed it by finishing it), interaction.held (a claimant moved a pending interaction to the person or back to itself — detail.heldBy is the new holder, detail.claimant the interceptor; detail.late: true is an interceptor that declined it when it opened claiming it afterwards, such as the autopilot resumed while it was open; a widget held by anything but user was not answered by the person), interaction.claim-refused (a claim on a userOnly interaction, which stays with the person — detail.claimant + reason), autopilot.* (the autopilot, a decorator that answers interactions on behalf of the user — autopilot.claimed / autopilot.declined say whether it took each interaction and, for a decline, detail.reason: paused, other-flow, no-autopilot, unavailable, userOnly, policy or no-controller; one declined as paused that is still open when the person resumes the autopilot is looked at again, and the autopilot.claimed or autopilot.declined recorded for it then carries detail.onResume: true (a decline then can also be claimed-elsewhere, another interceptor having claimed it first); a restored mode looks at nothing; autopilot.decision-sent is what it was sent (detail.chars; detail.nothingEnabled: true when every action on the widget was unavailable — a gate whose controller said it was asking, such as a failed build the autopilot may not cancel — so it could only hand it back, which it may then do even after the person asked it to decide it itself; a widget whose controller says it is working (ctx.setWorking) is never sent a decision until it says it is asking, even when an action is enabled or the person resumes the autopilot); autopilot.acted is what it did (detail.action, detail.note, detail.finished); autopilot.handed-back is a decision it gave to the person (detail.reason and detail.trigger: model, no-decision or error); autopilot.paused / autopilot.resumed are mode changes (detail.scope, detail.trigger, detail.decideYourself when the person resumed during a hand-back; detail.trigger is restored when the mode came back with the session after a reload, applied once its flow re-activated, which starts nothing by itself); autopilot.error is the wrapper itself failing; autopilot.refinement counts a refining action against its step — a written answer (reply) or a widget action declared refines, such as a regenerate with instructions, counted together (detail.action, detail.stepKey, detail.count, detail.limitReached, after which every refining action is withdrawn for that step: not listed, and refused; the decision and every relisting of its actions say how many are left at the step, as a line Refinements left at this step: N, wherever the widget has a refining action); autopilot.handback-presented is the turn-level hand-back, shown when a working turn ended needing the person with no widget to hand over (detail.why: max-iterations, context-exhausted, failure or question; detail.options; detail.choice once answered); autopilot.catch-up is the autopilot being given the whole visible transcript at once (detail.why: first, for its first decision in a flow or after a reload; size, when its own history passed its budget and was rebuilt short — detail.ownChars; or compacted, when a compaction removed the last message it had seen, so it reads the summary and everything since, short; in each, what it had sent on the user behalf is included and labelled as its own, since its own history does not hold it); autopilot.cost-dropped is autopilot spend that no message carries, so it is NOT in the session total (detail.costUsd and detail.why: handed-back, aborted or stale for a written question it answered that no reply was sent for — stale when a pause, a resume, a new turn or the end of its flow came before the answer landed, which then went nowhere — or no-recorder when the driver had no way to book a decision to its interaction); a hand-back trigger can also be budget (the decision passed its spend cap), watchdog (its work went quiet: no ready surface and no heartbeat, or its own decision stalled with no model call landing, which stops that decision) or detached (the autopilot was removed while it held the interaction, which went to the person with no reason shown). To debug one autopilot decision, follow its interactionId: interaction.requested (heldBy), autopilot.claimed, autopilot.decision-sent, autopilot.acted or autopilot.handed-back, interaction.invoked, interaction.resolved (answeredBy), then the next turn of the working agent), interaction.invoked (a claimant ran one of the actions the widget itself exposes, through its hold, the same code the button runs — detail.claimant, detail.action (an option id, select or reply) and detail.finished, whether that settled the interaction, and when it did not, the run is recorded as an edit; the choice and narration it recorded reach the result of the tool that asked as decidedOnUsersBehalf), interaction.step (a long action run as named steps through runSteps, which survive a reload — detail.step and detail.outcome: started, done, skipped when the step was already done before a reload, or resumed when it started before a reload and runs again with what it saved part-way, such as a job id it re-attaches to), interaction.checkpoint (the checkpoints a conversation keeps for its long actions: the one in flight, and each one a reload cut, held apart until a request of its own widget type takes it over, so a resumed flow that opens other long widgets first, which save their own, loses nothing — detail.action: resumed when a reload cut the work and a request of the same widget type that the registration sameWork agrees is the same work took it over, refused when sameWork said a new request is different work (detail.saved is the identity it kept; detail.kept: true, since it stays for a later request of that type, and is offered to every one until one agrees) or when runSteps found the handed-over checkpoint malformed and started fresh (detail.reason, detail.saved), or cleared when its flow ended, once per checkpoint, with detail.cut: true for one a reload cut that nothing took over), context.updated/threshold-crossed (token + cost), context.condensed (a stale tool payload was collapsed out of the model-bound history by a `condenseWhen` declaration on the tool — detail.tool + toolCallId, target args|response, trigger (superseded:<key> or age:<n>), stubLen, and an estimated tokensSaved; stored history and this log keep the FULL payload, so the model-visible slice at any point is the full history minus the condensations recorded up to then), panel.toggled, attachment.added, file.read-failed, suggestions.failed.',\n 'Sub-agent meta events: a sub-agent\\'s own turn.retry/turn.error/tool.failed/tool.unresolved events are merged into this same timeline, tagged with `detail.subAgent` — a `\"<parent> › <sub-agent>\"` breadcrumb that composes when nested (e.g. `\"UI Builder › Planner › Grounding\"`) — and interleaved by their original timestamps within the subagent.started→completed/failed bracket. These are the per-attempt/per-failure signals that do NOT appear among the sub-agent\\'s (hoisted) messages: a malformed/empty attempt that gets retried produces no message, and the stale-vs-hallucinated split and streak counts live only on the event. A sub-agent\\'s high-volume, message-derivable events (turn.start/turn.end, provider.selected, context.updated) are intentionally NOT merged — read its hoisted messages for model/tokens/cost and turn-by-turn activity, and the bracketing subagent.* events for the run\\'s span.',\n \"`meta` holds context captured at export time: agentSummary (full agent configs), context (active model, contextTokens/contextLimit/contextUsagePercent for the last call, and the session totals — sessionCostUsd, sessionTokensConsumed, and the four-bucket sessionUsage lifted to the top of this log), activeDebugSnapshot (the active agent's `getDebugSnapshot()` taken fresh at export — reflects state NOW, which may have advanced beyond the last turn's agentSnapshot), debug (optional host-supplied debug state), host, and the export timestamp.\",\n 'Note the two different scopes in `meta.context`: `contextTokens` is the prompt size of the LAST call (against `contextLimit`, the model context window), while `sessionUsage`/`sessionTokensConsumed` are cumulative BILLED throughput. Every turn resends the conversation, so the cumulative figure counts each turn’s prompt again in the next turn’s and is expected to dwarf the context size — that is not double-counting.',\n \"kind:'event' type 'routing.decided' — how ONE turn was routed, emitted by the orchestrating driver before the agent runs (and again after every handoff). `decision` is why that agent was chosen: 'classified' (the classifier ran and picked one), 'no-match' (it ran and answered -1 — nothing listed covers the request), 'ballot-exhausted' (every eligible specialist had already handed off this turn, so the ballot was empty and NO call was made — distinct from 'no-match', where one ran and declined), 'pinned' (a user pin, an agent named for that one message by the send's `agent` option, or an active stateful flow owned the turn, so no call was made), 'single-candidate'/'no-specialists' (configuration left nothing to decide), 'provider-unavailable' (the registry default exposes no chat()), 'classifier-failed' (every attempt threw — `error` carries the last one). `to` names the agent and `fallback` says whether that agent is the fallback. `candidates` is what was actually ON THE BALLOT, in ballot order, so `index` — the classifier's own answer — indexes it directly; `excluded` names the specialists left off because they already handed off this turn, so the full eligible set is `candidates` ∪ `excluded`. `candidates` is absent on the four decisions that put nothing to a vote — 'pinned', 'single-candidate', 'no-specialists', 'ballot-exhausted'. It IS present on 'provider-unavailable', which is not an exception worth removing: the ballot was built there, it simply never got sent. `attempts` covers the retry ladder. `durationMs` is on EVERY routing.decided, and is the field to read when a decision looks wrong: the four decisions that can reach the fallback are told apart by the clock as much as by their name, because a fallback routing that resolved in tens of milliseconds made no network call at all whatever its `decision` says.\",\n \"kind:'event' type 'routing.decided'.`usage` — what that classifier call cost, in the same four-bucket + costUsd shape as `sessionUsage`, plus `model`. Absent on the decisions that make no call (see 'pinned' and the configuration ones). THIS SPEND IS NOT IN `sessionUsage`: a classifier call never enters the transcript and `sessionUsage` is derived from the transcript, so classifier cost is missing from the session total by construction, not by accident. Sum these events to close that gap — it is the one component of a session's real spend that the totals cannot see.\",\n 'To debug a failure: find the last turn.error or tool.failed, then read upward for the user message, the turn(s), and the agent/provider/state events that led into it. For a turn that went to the wrong agent, read its routing.decided first — `decision` says whether anything was actually asked.',\n]",
10957
11672
  "description": "Human/agent-facing guide emitted as the first key of the exported debug log,\nso whoever opens the JSON (often an AI agent) knows how to read it without\nreverse-engineering the shape. Kept here next to the event catalogue it\ndescribes — but proximity alone demonstrably did NOT keep the two in sync\n(`refusal` was missing from both reason lists for a whole release), so\n`debug-event-log.test.ts` now asserts that every `TurnFailureReason` and every\n`SubAgentFailureReason` is named here, and fails the build when one is added\nwithout a matching sentence. Enumerations below read as exhaustive and WILL be\ntrusted by an agent reading the JSON — keep them so."
10958
11673
  }
10959
11674
  ],
@@ -11051,8 +11766,41 @@
11051
11766
  "type": {
11052
11767
  "text": "string"
11053
11768
  },
11054
- "default": "'reply'",
11055
- "description": "The `reply` action `freeText` adds. Platform-owned, so never an option's id."
11769
+ "default": "'reply'",
11770
+ "description": "The `reply` action `freeText` adds. Platform-owned, so never an option's id."
11771
+ },
11772
+ {
11773
+ "kind": "variable",
11774
+ "name": "GENERIC_UNAVAILABLE",
11775
+ "type": {
11776
+ "text": "string"
11777
+ },
11778
+ "default": "'not available in this state'",
11779
+ "description": "What an unavailable thing says when its guard gives no reason (an empty one, or a throw)."
11780
+ },
11781
+ {
11782
+ "kind": "function",
11783
+ "name": "unavailableReason",
11784
+ "return": {
11785
+ "type": {
11786
+ "text": "string | undefined"
11787
+ }
11788
+ },
11789
+ "parameters": [
11790
+ {
11791
+ "name": "guard",
11792
+ "type": {
11793
+ "text": "((...args: A) => string | undefined) | undefined"
11794
+ }
11795
+ },
11796
+ {
11797
+ "name": "args",
11798
+ "type": {
11799
+ "text": "A"
11800
+ }
11801
+ }
11802
+ ],
11803
+ "description": "Why something cannot be used right now, from its `unavailable` guard, or `undefined` when it can\n(GENC-1660). One rule for options, actions and widget tools: absent means available; an empty\nreason, or a guard that throws, counts as unavailable with a generic reason, since a guard that\ncannot say why cannot vouch for its button either."
11056
11804
  },
11057
11805
  {
11058
11806
  "kind": "function",
@@ -11070,7 +11818,7 @@
11070
11818
  }
11071
11819
  }
11072
11820
  ],
11073
- "description": "Build the surface for a short-form decision (GENC-1660). Its actions are its options (by id),\nplus `select` for a multi-select and `reply` for a written answer; all of them finish. Every\nread — facts, actions, enabled-ness — is taken fresh, so the surface always describes the\nwidget as it is now.\n\nThrows if an option's id collides with another or with a platform-owned name, which is a bug in\nthe widget rather than something to recover from."
11821
+ "description": "Build the surface for a short-form decision (GENC-1660). Its actions are its options (by id),\nplus `select` for a multi-select and `reply` for a written answer; all of them finish. Its views,\nif it has any, are read by name. Every read — facts, views, actions, enabled-ness — is taken\nfresh, so the surface always describes the widget as it is now.\n\nThrows if an option's id collides with another or with a platform-owned name, which is a bug in\nthe widget rather than something to recover from."
11074
11822
  },
11075
11823
  {
11076
11824
  "kind": "function",
@@ -11096,6 +11844,24 @@
11096
11844
  ],
11097
11845
  "description": "Check `args` against an action's schema: an object, with its `required` properties present and\neach listed property of its declared top-level `type`. Deliberately shallow — enough to refuse a\nmalformed call with a reason the model can act on, without a schema library in the browser."
11098
11846
  },
11847
+ {
11848
+ "kind": "function",
11849
+ "name": "exampleArgs",
11850
+ "return": {
11851
+ "type": {
11852
+ "text": "Record<string, unknown>"
11853
+ }
11854
+ },
11855
+ "parameters": [
11856
+ {
11857
+ "name": "schema",
11858
+ "type": {
11859
+ "text": "Readonly<Record<string, unknown>>"
11860
+ }
11861
+ }
11862
+ ],
11863
+ "description": "An example of arguments that fit `schema`, for a refusal to show the model: each property with a\nplaceholder of its declared type, required ones first. Shallow, like checkArgs."
11864
+ },
11099
11865
  {
11100
11866
  "kind": "function",
11101
11867
  "name": "buildFullSurface",
@@ -11112,7 +11878,7 @@
11112
11878
  }
11113
11879
  }
11114
11880
  ],
11115
- "description": "Build the surface for a full-form spec (GENC-1660 §4.2): named actions, some editing and some\nfinishing, each guarded and schema-checked; a description; views to read. Every read is fresh."
11881
+ "description": "Build the surface for a full-form spec (GENC-1660 §4.2): named actions, some editing and some\nfinishing, each guarded and checked (a text action's text, a form's fields against its schema); a\ndescription; described views to read, one of them the preview. Every read is fresh.\n\nThrows if an action declares both `text` and `argsSchema`, or the preview is not one of the\nviews: a bug in the widget rather than something to recover from."
11116
11882
  }
11117
11883
  ],
11118
11884
  "exports": [
@@ -11132,6 +11898,22 @@
11132
11898
  "module": "src/state/decision-surface.ts"
11133
11899
  }
11134
11900
  },
11901
+ {
11902
+ "kind": "js",
11903
+ "name": "GENERIC_UNAVAILABLE",
11904
+ "declaration": {
11905
+ "name": "GENERIC_UNAVAILABLE",
11906
+ "module": "src/state/decision-surface.ts"
11907
+ }
11908
+ },
11909
+ {
11910
+ "kind": "js",
11911
+ "name": "unavailableReason",
11912
+ "declaration": {
11913
+ "name": "unavailableReason",
11914
+ "module": "src/state/decision-surface.ts"
11915
+ }
11916
+ },
11135
11917
  {
11136
11918
  "kind": "js",
11137
11919
  "name": "buildDecisionSurface",
@@ -11148,6 +11930,14 @@
11148
11930
  "module": "src/state/decision-surface.ts"
11149
11931
  }
11150
11932
  },
11933
+ {
11934
+ "kind": "js",
11935
+ "name": "exampleArgs",
11936
+ "declaration": {
11937
+ "name": "exampleArgs",
11938
+ "module": "src/state/decision-surface.ts"
11939
+ }
11940
+ },
11151
11941
  {
11152
11942
  "kind": "js",
11153
11943
  "name": "buildFullSurface",
@@ -11310,11 +12100,11 @@
11310
12100
  {
11311
12101
  "name": "registration",
11312
12102
  "type": {
11313
- "text": "InteractionRegistration"
12103
+ "text": "InteractionRegistration<TController>"
11314
12104
  }
11315
12105
  }
11316
12106
  ],
11317
- "description": "Register a widget with the platform (GENC-1660): its controller, the element that renders it, how\nit behaves while a claimant holds it, and its text form. Once per name, at start-up; a second\nregistration under the same name replaces the first, with a warning.\n\nRegistering is optional and additive: an unregistered widget works exactly as before."
12107
+ "description": "Register a widget with the platform (GENC-1660): its controller, the element that renders it, how\nit behaves while a claimant holds it, and its text form. Once per name, at start-up; a second\nregistration under the same name replaces the first, with a warning.\n\nRegistering is optional and additive: an unregistered widget works exactly as before.\n\nGeneric over the controller its factory builds, which types `ctx.controller` for the factory and\nfor anything that reads the context with the same type argument (a view, a widget tool):\n\n```ts\nregisterInteraction<ReviewController>('review', {\n controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),\n asText: reviewAsText,\n});\n```"
11318
12108
  },
11319
12109
  {
11320
12110
  "kind": "function",
@@ -11354,6 +12144,40 @@
11354
12144
  }
11355
12145
  ]
11356
12146
  },
12147
+ {
12148
+ "kind": "javascript-module",
12149
+ "path": "src/state/live-interactions.ts",
12150
+ "declarations": [
12151
+ {
12152
+ "kind": "function",
12153
+ "name": "getInteractionContext",
12154
+ "return": {
12155
+ "type": {
12156
+ "text": "InteractionContext<Record<string, unknown>, unknown, TController> | undefined"
12157
+ }
12158
+ },
12159
+ "parameters": [
12160
+ {
12161
+ "name": "interactionId",
12162
+ "type": {
12163
+ "text": "string"
12164
+ }
12165
+ }
12166
+ ],
12167
+ "description": "The live context of a pending interaction, by its id (GENC-1660), for UI that the chat does not\nrender and so is never handed one: a layout side panel that shows a widget's detail, say. It can\nsubscribe, read `heldBy` and reach the controller directly, rather than through a channel of its\nown. `undefined` once the interaction has resolved (its context is disposed then) and for an id\nthat never opened.\n\n`TController` types `controller`, as it was registered (`registerInteraction<TController>()`).\nUnchecked: the caller says what it expects."
12168
+ }
12169
+ ],
12170
+ "exports": [
12171
+ {
12172
+ "kind": "js",
12173
+ "name": "getInteractionContext",
12174
+ "declaration": {
12175
+ "name": "getInteractionContext",
12176
+ "module": "src/state/live-interactions.ts"
12177
+ }
12178
+ }
12179
+ ]
12180
+ },
11357
12181
  {
11358
12182
  "kind": "javascript-module",
11359
12183
  "path": "src/state/run-steps.ts",
@@ -11516,6 +12340,41 @@
11516
12340
  }
11517
12341
  ]
11518
12342
  },
12343
+ {
12344
+ "kind": "javascript-module",
12345
+ "path": "src/state/test-interaction-context.ts",
12346
+ "declarations": [
12347
+ {
12348
+ "kind": "function",
12349
+ "name": "createTestInteractionContext",
12350
+ "return": {
12351
+ "type": {
12352
+ "text": "TestInteractionContext<TController, TResult>"
12353
+ }
12354
+ },
12355
+ "parameters": [
12356
+ {
12357
+ "name": "options",
12358
+ "default": "{}",
12359
+ "type": {
12360
+ "text": "{\n /** Defaults to `'test-interaction'`. */\n readonly interactionId?: string;\n /** The `data` handed to `controller`. */\n readonly data?: unknown;\n /** Build the controller as the platform would, and install it as `context.controller`. */\n readonly controller?: InteractionControllerFactory<TController>;\n /** A checkpoint the platform handed over, as after a reload (`ctx.checkpoint`). */\n readonly checkpoint?: unknown;\n }"
12361
+ }
12362
+ }
12363
+ ],
12364
+ "description": "Build a real interaction context for a controller test (GENC-1660), so the test exercises the\nplatform's own context — its `state`, `once`, `notify`, surfaces and their checks — rather than a\nhand-built fake that can drift from it. Nothing renders, nothing is persisted, and no driver is\ninvolved: resolving records the result, and the interaction is disposed as it would be."
12365
+ }
12366
+ ],
12367
+ "exports": [
12368
+ {
12369
+ "kind": "js",
12370
+ "name": "createTestInteractionContext",
12371
+ "declaration": {
12372
+ "name": "createTestInteractionContext",
12373
+ "module": "src/state/test-interaction-context.ts"
12374
+ }
12375
+ }
12376
+ ]
12377
+ },
11519
12378
  {
11520
12379
  "kind": "javascript-module",
11521
12380
  "path": "src/styles/ai-colours.ts",
@@ -14578,7 +15437,7 @@
14578
15437
  "kind": "field",
14579
15438
  "name": "interaction",
14580
15439
  "type": {
14581
- "text": "AiChatInteraction<HandBackData, HandBackResult['payload']> | undefined"
15440
+ "text": "AiChatInteraction<\n HandBackData,\n HandBackResult['payload'],\n HandBackController\n > | undefined"
14582
15441
  }
14583
15442
  },
14584
15443
  {
@@ -15187,7 +16046,16 @@
15187
16046
  "text": "string | null"
15188
16047
  }
15189
16048
  },
15190
- "description": "The name routing is locked to, flow lock first. A flow in progress outranks the user's\nsticky pick for the duration of the flow; neither being set means automatic routing."
16049
+ "parameters": [
16050
+ {
16051
+ "name": "pin",
16052
+ "default": "this.pinned",
16053
+ "type": {
16054
+ "text": "string | null"
16055
+ }
16056
+ }
16057
+ ],
16058
+ "description": "The name routing is locked to, flow lock first. A flow in progress outranks the user's\nsticky pick for the duration of the flow; neither being set means automatic routing.\n`pin`, when given, stands in for the sticky pick: one message routed its own way."
15191
16059
  },
15192
16060
  {
15193
16061
  "kind": "method",
@@ -15776,6 +16644,32 @@
15776
16644
  }
15777
16645
  }
15778
16646
  },
16647
+ {
16648
+ "kind": "method",
16649
+ "name": "getInteractionCheckpoints",
16650
+ "return": {
16651
+ "type": {
16652
+ "text": "readonly PersistedInteractionCheckpoint[]"
16653
+ }
16654
+ }
16655
+ },
16656
+ {
16657
+ "kind": "method",
16658
+ "name": "restoreInteractionCheckpoints",
16659
+ "return": {
16660
+ "type": {
16661
+ "text": "void"
16662
+ }
16663
+ },
16664
+ "parameters": [
16665
+ {
16666
+ "name": "saved",
16667
+ "type": {
16668
+ "text": "readonly PersistedInteractionCheckpoint[]"
16669
+ }
16670
+ }
16671
+ ]
16672
+ },
15779
16673
  {
15780
16674
  "kind": "method",
15781
16675
  "name": "getInteractionCheckpoint",
@@ -18841,6 +19735,36 @@
18841
19735
  ],
18842
19736
  "description": "The live InteractionContext for a pending interaction (GENC-1390), or\n`undefined` once resolved/evicted. Read by `AiChatInteractionWrapper` (via the\nhost) to build the widget's pending `interaction` descriptor."
18843
19737
  },
19738
+ {
19739
+ "kind": "method",
19740
+ "name": "getInteractionCheckpoints",
19741
+ "privacy": "public",
19742
+ "return": {
19743
+ "type": {
19744
+ "text": "readonly PersistedInteractionCheckpoint[]"
19745
+ }
19746
+ },
19747
+ "description": "{@inheritDoc AiDriver.getInteractionCheckpoints}"
19748
+ },
19749
+ {
19750
+ "kind": "method",
19751
+ "name": "restoreInteractionCheckpoints",
19752
+ "privacy": "public",
19753
+ "return": {
19754
+ "type": {
19755
+ "text": "void"
19756
+ }
19757
+ },
19758
+ "parameters": [
19759
+ {
19760
+ "name": "saved",
19761
+ "type": {
19762
+ "text": "readonly PersistedInteractionCheckpoint[]"
19763
+ }
19764
+ }
19765
+ ],
19766
+ "description": "{@inheritDoc AiDriver.restoreInteractionCheckpoints}"
19767
+ },
18844
19768
  {
18845
19769
  "kind": "method",
18846
19770
  "name": "getInteractionCheckpoint",
@@ -18850,7 +19774,8 @@
18850
19774
  "text": "PersistedInteractionCheckpoint | undefined"
18851
19775
  }
18852
19776
  },
18853
- "description": "{@inheritDoc AiDriver.getInteractionCheckpoint}"
19777
+ "description": "{@inheritDoc AiDriver.getInteractionCheckpoint}",
19778
+ "deprecated": "Use `getInteractionCheckpoints`."
18854
19779
  },
18855
19780
  {
18856
19781
  "kind": "method",
@@ -18869,7 +19794,8 @@
18869
19794
  }
18870
19795
  }
18871
19796
  ],
18872
- "description": "{@inheritDoc AiDriver.restoreInteractionCheckpoint}"
19797
+ "description": "{@inheritDoc AiDriver.restoreInteractionCheckpoint}",
19798
+ "deprecated": "Use `restoreInteractionCheckpoints`."
18873
19799
  },
18874
19800
  {
18875
19801
  "kind": "method",
@@ -19546,12 +20472,32 @@
19546
20472
  },
19547
20473
  {
19548
20474
  "kind": "field",
19549
- "name": "checkpoint",
20475
+ "name": "live",
20476
+ "type": {
20477
+ "text": "PersistedInteractionCheckpoint & { readonly interactionId: string } | undefined"
20478
+ },
20479
+ "privacy": "private",
20480
+ "description": "The live interaction's checkpoint (GENC-1660 §4.12): the last one it saved, or the cut one it\ntook over. At most one: only one interaction is in flight per root."
20481
+ },
20482
+ {
20483
+ "kind": "field",
20484
+ "name": "cut",
19550
20485
  "type": {
19551
- "text": "PersistedInteractionCheckpoint & { interactionId?: string; cut?: boolean } | undefined"
20486
+ "text": "PersistedInteractionCheckpoint[]"
19552
20487
  },
19553
20488
  "privacy": "private",
19554
- "description": "The one checkpoint this conversation holds (GENC-1660 §4.12): the live interaction's, or — after\na restore — the one the reload cut (`cut`), waiting for the first request of its widget type.\nOne is enough: only one interaction is in flight per root, so a reload cuts at most one."
20489
+ "default": "[]",
20490
+ "description": "Checkpoints a reload cut, oldest first, each waiting for a request of its own widget type that\n`sameWork` agrees is the same work. Held apart from `live`, so neither the work a resumed flow\ndoes first nor a request `sameWork` refuses can lose one: a flow may open other long widgets\nbefore the one a checkpoint belongs to asks for it. Each leaves when it is taken over, and all\nof them when the flow ends."
20491
+ },
20492
+ {
20493
+ "kind": "method",
20494
+ "name": "getCheckpoints",
20495
+ "return": {
20496
+ "type": {
20497
+ "text": "PersistedInteractionCheckpoint[]"
20498
+ }
20499
+ },
20500
+ "description": "See `ChatDriver.getInteractionCheckpoints`: every checkpoint to save with the session — those a\nreload cut that nothing has taken yet, oldest first, then the live interaction's. A reload cuts\nthem all, so all of them are restored as cut."
19555
20501
  },
19556
20502
  {
19557
20503
  "kind": "method",
@@ -19561,7 +20507,25 @@
19561
20507
  "text": "PersistedInteractionCheckpoint | undefined"
19562
20508
  }
19563
20509
  },
19564
- "description": "See `ChatDriver.getInteractionCheckpoint`."
20510
+ "description": "See `ChatDriver.getInteractionCheckpoint` (deprecated): one checkpoint, the live interaction's,\nelse the newest a reload cut."
20511
+ },
20512
+ {
20513
+ "kind": "method",
20514
+ "name": "restoreCheckpoints",
20515
+ "return": {
20516
+ "type": {
20517
+ "text": "void"
20518
+ }
20519
+ },
20520
+ "parameters": [
20521
+ {
20522
+ "name": "saved",
20523
+ "type": {
20524
+ "text": "readonly PersistedInteractionCheckpoint[] | undefined"
20525
+ }
20526
+ }
20527
+ ],
20528
+ "description": "See `ChatDriver.restoreInteractionCheckpoints`. Restored means cut: their interactions are gone.\nReplaces whatever was held."
19565
20529
  },
19566
20530
  {
19567
20531
  "kind": "method",
@@ -19579,7 +20543,7 @@
19579
20543
  }
19580
20544
  }
19581
20545
  ],
19582
- "description": "See `ChatDriver.restoreInteractionCheckpoint`. Restored means cut: its interaction is gone."
20546
+ "description": "See `ChatDriver.restoreInteractionCheckpoint` (deprecated): one, or none."
19583
20547
  },
19584
20548
  {
19585
20549
  "kind": "method",
@@ -19597,7 +20561,7 @@
19597
20561
  }
19598
20562
  }
19599
20563
  ],
19600
- "description": "Drop the checkpoint, used or not, when its flow ends."
20564
+ "description": "Drop every checkpoint, used or not, cut or live, when its flow ends."
19601
20565
  },
19602
20566
  {
19603
20567
  "kind": "method",
@@ -19628,7 +20592,7 @@
19628
20592
  }
19629
20593
  }
19630
20594
  ],
19631
- "description": "Hand a cut checkpoint to a new request of the same widget type, if its registration's\n`sameWork` agrees. Only the first such request is asked: a refused checkpoint is dropped, and\nthe work starts fresh as it would have without one."
20595
+ "description": "Offer the checkpoints a reload cut to a new request of their widget type, newest first, and\nhand it the first its registration's `sameWork` agrees is the same work (any, without one). A\ncheckpoint `sameWork` refuses stays where it is, for a later request of the same type: a flow\nmay ask for other work of that type first. Each refusal is recorded, with the identity kept."
19632
20596
  },
19633
20597
  {
19634
20598
  "kind": "method",
@@ -19659,7 +20623,7 @@
19659
20623
  }
19660
20624
  }
19661
20625
  ],
19662
- "description": "A controller's `ctx.saveCheckpoint`: kept as JSON, the form it is persisted in."
20626
+ "description": "A controller's `ctx.saveCheckpoint`: kept as JSON, the form it is persisted in. Replaces the\nlive interaction's only; the checkpoints a reload cut are left waiting for their own widgets."
19663
20627
  },
19664
20628
  {
19665
20629
  "kind": "method",
@@ -19702,7 +20666,26 @@
19702
20666
  }
19703
20667
  }
19704
20668
  ],
19705
- "description": "Offer a new interaction to the interceptors and record who ends up holding it.\n\n**Outermost first.** A decorator installs its interceptor on the driver it wraps when it is\nconstructed, and decorators are constructed innermost first, so registration order is\ninnermost first and the walk runs it backwards. The first claim wins; later interceptors still\nsee the interaction but their `hold` does nothing. A claim on a `userOnly` interaction is\nrefused.\n\nRuns before the interaction's message is appended, so the widget's first render already knows\nits holder and nothing appears only to disappear."
20669
+ "description": "Offer a new interaction to the interceptors and record who ends up holding it.\n\n**Outermost first.** A decorator installs its interceptor on the driver it wraps when it is\nconstructed, and decorators are constructed innermost first, so registration order is\ninnermost first and the walk runs it backwards. The first claim wins; later interceptors still\nsee the interaction but their `hold` does nothing. A claim on a `userOnly` interaction is\nrefused.\n\nRuns before the interaction's message is appended, so the widget's first render already knows\nits holder and nothing appears only to disappear.\n\n**A late claim.** An interceptor that declined may still claim it later, through its hold's\n`claim`, once the asking is over and while nobody else has (see InteractionHold.claim)."
20670
+ },
20671
+ {
20672
+ "kind": "method",
20673
+ "name": "reportAttentionEnds",
20674
+ "privacy": "private",
20675
+ "return": {
20676
+ "type": {
20677
+ "text": "void"
20678
+ }
20679
+ },
20680
+ "parameters": [
20681
+ {
20682
+ "name": "ctx",
20683
+ "type": {
20684
+ "text": "InteractionContext"
20685
+ }
20686
+ }
20687
+ ],
20688
+ "description": "Publish `agent-attention-ended` each time the interaction stops waiting on the person — a\nclaimant takes it, or it settles — so a notification still showing for it is closed\n(GENC-1660). Wired once who holds it is decided, so a claim made as it opens is not one."
19706
20689
  },
19707
20690
  {
19708
20691
  "kind": "method",
@@ -19731,9 +20714,15 @@
19731
20714
  "type": {
19732
20715
  "text": "() => boolean"
19733
20716
  }
20717
+ },
20718
+ {
20719
+ "name": "claim",
20720
+ "type": {
20721
+ "text": "() => boolean"
20722
+ }
19734
20723
  }
19735
20724
  ],
19736
- "description": "The InteractionHold for one interceptor: it applies only while that one is the claimant."
20725
+ "description": "The InteractionHold for one interceptor: it applies only while that one is the claimant,\nwhich `claim` can make it after the asking, if nobody else is."
19737
20726
  },
19738
20727
  {
19739
20728
  "kind": "method",
@@ -19851,9 +20840,16 @@
19851
20840
  "type": {
19852
20841
  "text": "any"
19853
20842
  }
20843
+ },
20844
+ {
20845
+ "name": "how",
20846
+ "optional": true,
20847
+ "type": {
20848
+ "text": "InteractionResolveOptions"
20849
+ }
19854
20850
  }
19855
20851
  ],
19856
- "description": "See `ChatDriver.resolveInteraction`. Warns and returns when the id is unknown — a widget can\nreport twice, and the second report has nothing left to settle."
20852
+ "description": "See `ChatDriver.resolveInteraction`. Warns and returns when the id is unknown — a widget can\nreport twice, and the second report has nothing left to settle. `how` is what a controller's\n`ctx.resolve` said about the settle (`resolvedItself`); every other route passes none."
19857
20853
  },
19858
20854
  {
19859
20855
  "kind": "method",
@@ -21663,8 +22659,16 @@
21663
22659
  "type": {
21664
22660
  "text": "AgentConfig"
21665
22661
  }
22662
+ },
22663
+ {
22664
+ "name": "pin",
22665
+ "optional": true,
22666
+ "type": {
22667
+ "text": "string | null"
22668
+ }
21666
22669
  }
21667
- ]
22670
+ ],
22671
+ "description": "`pin` stands in for the user-pin when given, as for\nOrchestratingDriver.resolvePinnedAgent."
21668
22672
  },
21669
22673
  {
21670
22674
  "kind": "method",
@@ -21803,7 +22807,16 @@
21803
22807
  "text": "AgentConfig | undefined"
21804
22808
  }
21805
22809
  },
21806
- "description": "Returns the agent that the current turn is locked to, if any. Flow-owner\n(transient, set by stateful-agent activation) wins over user-pin (sticky,\nset by picker click). `undefined` falls back to the classifier.\n\nLogs and returns `undefined` if a name no longer matches the agents array\n— protects against stale state after an agents-array reassignment."
22810
+ "parameters": [
22811
+ {
22812
+ "name": "pin",
22813
+ "optional": true,
22814
+ "type": {
22815
+ "text": "string | null"
22816
+ }
22817
+ }
22818
+ ],
22819
+ "description": "Returns the agent that the current turn is locked to, if any. Flow-owner\n(transient, set by stateful-agent activation) wins over user-pin (sticky,\nset by picker click). `undefined` falls back to the classifier.\n\nLogs and returns `undefined` if a name no longer matches the agents array\n— protects against stale state after an agents-array reassignment.\n\n`pin` stands in for the user-pin when given — `SendMessageOptions.agent`."
21807
22820
  },
21808
22821
  {
21809
22822
  "kind": "method",
@@ -22129,6 +23142,40 @@
22129
23142
  "module": "src/components/ai-driver/base-driver-decorator.ts"
22130
23143
  }
22131
23144
  },
23145
+ {
23146
+ "kind": "method",
23147
+ "name": "getInteractionCheckpoints",
23148
+ "return": {
23149
+ "type": {
23150
+ "text": "readonly PersistedInteractionCheckpoint[]"
23151
+ }
23152
+ },
23153
+ "inheritedFrom": {
23154
+ "name": "BaseDriverDecorator",
23155
+ "module": "src/components/ai-driver/base-driver-decorator.ts"
23156
+ }
23157
+ },
23158
+ {
23159
+ "kind": "method",
23160
+ "name": "restoreInteractionCheckpoints",
23161
+ "return": {
23162
+ "type": {
23163
+ "text": "void"
23164
+ }
23165
+ },
23166
+ "parameters": [
23167
+ {
23168
+ "name": "saved",
23169
+ "type": {
23170
+ "text": "readonly PersistedInteractionCheckpoint[]"
23171
+ }
23172
+ }
23173
+ ],
23174
+ "inheritedFrom": {
23175
+ "name": "BaseDriverDecorator",
23176
+ "module": "src/components/ai-driver/base-driver-decorator.ts"
23177
+ }
23178
+ },
22132
23179
  {
22133
23180
  "kind": "method",
22134
23181
  "name": "getInteractionCheckpoint",