@zeyos/zx 5.5.0 → 5.7.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 (235) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/README.md +73 -7
  3. package/bin/zx-css.js +328 -0
  4. package/dist/types/components/account-menu/account-menu.d.ts +4 -2
  5. package/dist/types/components/activity-list/activity-list.d.ts +14 -8
  6. package/dist/types/components/agent-thread/ag-ui.d.ts +340 -0
  7. package/dist/types/components/agent-thread/agent-thread.d.ts +711 -0
  8. package/dist/types/components/agent-thread/ui-message-stream.d.ts +401 -0
  9. package/dist/types/components/app-sidebar/app-sidebar.d.ts +14 -8
  10. package/dist/types/components/approval-card/approval-card.d.ts +596 -0
  11. package/dist/types/components/avatar/avatar.d.ts +91 -4
  12. package/dist/types/components/block-view/block-view.d.ts +205 -0
  13. package/dist/types/components/breadcrumb/breadcrumb.d.ts +3 -3
  14. package/dist/types/components/calendar/calendar-model.d.ts +9 -2
  15. package/dist/types/components/calendar/calendar.d.ts +12 -4
  16. package/dist/types/components/chart/chart.d.ts +25 -13
  17. package/dist/types/components/code-editor/code-editor.d.ts +7 -2
  18. package/dist/types/components/composer/composer.d.ts +938 -0
  19. package/dist/types/components/composer/queue.d.ts +76 -0
  20. package/dist/types/components/copy/copy-button.d.ts +6 -4
  21. package/dist/types/components/copy/copy-input.d.ts +10 -6
  22. package/dist/types/components/datebox/date-range-box.d.ts +33 -0
  23. package/dist/types/components/datebox/placeholder.d.ts +7 -0
  24. package/dist/types/components/dock/dock.d.ts +12 -3
  25. package/dist/types/components/entity-ref/entity-ref.d.ts +5 -3
  26. package/dist/types/components/field-upload/field-upload.d.ts +3 -2
  27. package/dist/types/components/file-item/file-item.d.ts +3 -2
  28. package/dist/types/components/file-list/file-list.d.ts +14 -8
  29. package/dist/types/components/filter/filter-model.d.ts +31 -1
  30. package/dist/types/components/filter/filter.d.ts +20 -2
  31. package/dist/types/components/finder/finder.d.ts +14 -6
  32. package/dist/types/components/flag/flag.d.ts +99 -0
  33. package/dist/types/components/grid/grid.d.ts +1 -1
  34. package/dist/types/components/kanban-view/kanban-view.d.ts +8 -66
  35. package/dist/types/components/launcher/launcher.d.ts +2 -0
  36. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
  37. package/dist/types/components/number-field/number-field.d.ts +17 -6
  38. package/dist/types/components/prompt-starters/prompt-starters.d.ts +107 -0
  39. package/dist/types/components/prose/prose.d.ts +9 -6
  40. package/dist/types/components/questionnaire/conditions.d.ts +270 -0
  41. package/dist/types/components/questionnaire/items.d.ts +52 -30
  42. package/dist/types/components/questionnaire/questionnaire.d.ts +44 -4
  43. package/dist/types/components/rating/rating.d.ts +5 -3
  44. package/dist/types/components/run-status/run-status.d.ts +393 -0
  45. package/dist/types/components/run-trace/run-trace.d.ts +624 -0
  46. package/dist/types/components/select/country.d.ts +106 -0
  47. package/dist/types/components/select/field-adapter.d.ts +2 -1
  48. package/dist/types/components/select/locale.d.ts +102 -0
  49. package/dist/types/components/select/select.d.ts +41 -2
  50. package/dist/types/components/slider/slider.d.ts +1 -0
  51. package/dist/types/components/sort-control/sort-control.d.ts +7 -3
  52. package/dist/types/components/source-list/source-list.d.ts +179 -0
  53. package/dist/types/components/split-view/split-view.d.ts +5 -3
  54. package/dist/types/components/surface/catalog.d.ts +260 -0
  55. package/dist/types/components/surface/elicit.d.ts +81 -0
  56. package/dist/types/components/surface/mcp.d.ts +165 -0
  57. package/dist/types/components/surface/schema.d.ts +314 -0
  58. package/dist/types/components/surface/stream.d.ts +118 -0
  59. package/dist/types/components/surface/surface.d.ts +718 -0
  60. package/dist/types/components/surface/text.d.ts +277 -0
  61. package/dist/types/components/surface/validate.d.ts +339 -0
  62. package/dist/types/components/table/table.d.ts +55 -3
  63. package/dist/types/components/table/window.d.ts +203 -0
  64. package/dist/types/components/toolbar/toolbar.d.ts +10 -6
  65. package/dist/types/components/tooltip/tooltip.d.ts +2 -2
  66. package/dist/types/components/tree/tree.d.ts +20 -13
  67. package/dist/types/core/component.d.ts +10 -0
  68. package/dist/types/core/date.d.ts +8 -1
  69. package/dist/types/core/dom.d.ts +1 -0
  70. package/dist/types/core/http.d.ts +10 -0
  71. package/dist/types/core/i18n.d.ts +38 -0
  72. package/dist/types/core/messages.d.ts +479 -1
  73. package/dist/types/core/storage.d.ts +7 -2
  74. package/dist/types/elements/define.d.ts +21 -46
  75. package/dist/types/elements/definitions.d.ts +147 -0
  76. package/dist/types/elements/kit.d.ts +7 -0
  77. package/dist/types/elements/reflect.d.ts +6 -3
  78. package/dist/types/index.d.ts +18 -1
  79. package/dist/types/internal/agent-model.d.ts +587 -0
  80. package/dist/types/internal/date-locale.d.ts +7 -0
  81. package/dist/types/internal/highlight.d.ts +24 -0
  82. package/dist/types/internal/json-patch.d.ts +146 -0
  83. package/dist/types/internal/presence-loop.d.ts +148 -0
  84. package/dist/types/locales/de.d.ts +13 -0
  85. package/dist/types/locales/en.d.ts +2 -0
  86. package/dist/types/locales/index.d.ts +823 -0
  87. package/dist/types/zeyos/view.d.ts +8 -1
  88. package/dist/zx-zeyos.esm.js +20505 -18748
  89. package/dist/zx-zeyos.esm.min.js +5 -5
  90. package/dist/zx.core.css +1276 -0
  91. package/dist/zx.core.min.css +1 -0
  92. package/dist/zx.css +2424 -134
  93. package/dist/zx.esm.js +46167 -28468
  94. package/dist/zx.esm.min.js +40 -8
  95. package/dist/zx.global.js +46167 -28468
  96. package/dist/zx.global.min.js +40 -8
  97. package/dist/zx.layered.css +17302 -0
  98. package/dist/zx.layered.min.css +1 -0
  99. package/dist/zx.min.css +1 -1
  100. package/docs/agent-catalog.json +12501 -0
  101. package/docs/agent-surfaces.md +340 -0
  102. package/docs/api.json +2057 -166
  103. package/docs/llms.md +1458 -58
  104. package/docs/llms.txt +38 -8
  105. package/package.json +29 -6
  106. package/src/components/account-menu/account-menu.js +6 -3
  107. package/src/components/activity-item/activity-item.js +2 -1
  108. package/src/components/activity-list/activity-list.js +16 -10
  109. package/src/components/agent-thread/ag-ui.js +1439 -0
  110. package/src/components/agent-thread/agent-thread.css +417 -0
  111. package/src/components/agent-thread/agent-thread.js +1670 -0
  112. package/src/components/agent-thread/ui-message-stream.js +1281 -0
  113. package/src/components/app-sidebar/app-sidebar.js +18 -8
  114. package/src/components/approval-card/approval-card.css +289 -0
  115. package/src/components/approval-card/approval-card.js +1378 -0
  116. package/src/components/avatar/avatar.css +56 -1
  117. package/src/components/avatar/avatar.js +148 -26
  118. package/src/components/block-view/block-view.css +300 -0
  119. package/src/components/block-view/block-view.js +524 -0
  120. package/src/components/breadcrumb/breadcrumb.js +8 -5
  121. package/src/components/calendar/calendar-model.js +8 -2
  122. package/src/components/calendar/calendar.js +53 -18
  123. package/src/components/chart/chart.js +54 -23
  124. package/src/components/code-editor/code-editor.js +45 -8
  125. package/src/components/code-editor/field-adapter.js +1 -1
  126. package/src/components/composer/composer.css +482 -0
  127. package/src/components/composer/composer.js +1815 -0
  128. package/src/components/composer/queue.js +78 -0
  129. package/src/components/context-menu/context-menu.js +12 -1
  130. package/src/components/copy/copy-button.js +9 -7
  131. package/src/components/copy/copy-input.js +10 -6
  132. package/src/components/date-picker/date-picker.js +2 -1
  133. package/src/components/date-picker/date-range-picker.js +8 -7
  134. package/src/components/datebox/date-range-box.js +3 -9
  135. package/src/components/datebox/datebox.js +18 -21
  136. package/src/components/datebox/placeholder.js +18 -0
  137. package/src/components/dialog/dialog.js +1 -1
  138. package/src/components/dock/dock.js +34 -13
  139. package/src/components/entity-ref/entity-ref.js +16 -5
  140. package/src/components/field-upload/field-upload.js +81 -38
  141. package/src/components/file-item/file-item.js +70 -40
  142. package/src/components/file-list/file-list.js +15 -9
  143. package/src/components/filter/filter-model.js +46 -8
  144. package/src/components/filter/filter.css +3 -3
  145. package/src/components/filter/filter.js +29 -10
  146. package/src/components/filter-panel/filter-panel.js +13 -5
  147. package/src/components/finder/finder.js +50 -26
  148. package/src/components/flag/flag.css +40 -0
  149. package/src/components/flag/flag.js +177 -0
  150. package/src/components/form/form.js +1 -1
  151. package/src/components/grid/grid.js +22 -8
  152. package/src/components/kanban-view/kanban-view.js +51 -81
  153. package/src/components/launcher/launcher.js +17 -2
  154. package/src/components/list-toolbar/list-toolbar.js +2 -1
  155. package/src/components/master-panel/master-panel.js +1 -1
  156. package/src/components/menu-button/menu-button.js +4 -0
  157. package/src/components/message/message.js +3 -0
  158. package/src/components/multi-value-editor/multi-value-editor.js +10 -9
  159. package/src/components/navigation-bar/navigation-bar.js +3 -3
  160. package/src/components/number-field/number-field.js +29 -13
  161. package/src/components/prompt-starters/prompt-starters.css +91 -0
  162. package/src/components/prompt-starters/prompt-starters.js +206 -0
  163. package/src/components/prose/prose.js +14 -10
  164. package/src/components/questionnaire/conditions.js +666 -0
  165. package/src/components/questionnaire/items.js +150 -41
  166. package/src/components/questionnaire/questionnaire.js +126 -32
  167. package/src/components/rating/rating.js +5 -4
  168. package/src/components/run-status/run-status.css +208 -0
  169. package/src/components/run-status/run-status.js +782 -0
  170. package/src/components/run-trace/run-trace.css +443 -0
  171. package/src/components/run-trace/run-trace.js +1209 -0
  172. package/src/components/select/country.js +136 -0
  173. package/src/components/select/field-adapter.js +7 -2
  174. package/src/components/select/locale.js +219 -0
  175. package/src/components/select/select.css +20 -22
  176. package/src/components/select/select.js +94 -12
  177. package/src/components/sheet/sheet-stack.js +10 -1
  178. package/src/components/slider/slider.js +7 -2
  179. package/src/components/sort-control/sort-control.js +15 -5
  180. package/src/components/source-list/source-list.css +208 -0
  181. package/src/components/source-list/source-list.js +358 -0
  182. package/src/components/split-view/split-view.js +5 -3
  183. package/src/components/surface/catalog.js +1334 -0
  184. package/src/components/surface/elicit.js +107 -0
  185. package/src/components/surface/mcp.js +243 -0
  186. package/src/components/surface/schema.js +644 -0
  187. package/src/components/surface/stream.js +245 -0
  188. package/src/components/surface/surface.css +308 -0
  189. package/src/components/surface/surface.js +2291 -0
  190. package/src/components/surface/text.js +513 -0
  191. package/src/components/surface/validate.js +2218 -0
  192. package/src/components/tabbox/tabbox.js +9 -0
  193. package/src/components/table/table.css +63 -3
  194. package/src/components/table/table.js +167 -28
  195. package/src/components/table/window.js +317 -0
  196. package/src/components/toolbar/toolbar.js +12 -7
  197. package/src/components/tooltip/tooltip.css +2 -3
  198. package/src/components/tooltip/tooltip.js +32 -5
  199. package/src/components/tree/tree.js +53 -23
  200. package/src/core/component.js +25 -1
  201. package/src/core/date.js +62 -16
  202. package/src/core/dom.js +22 -2
  203. package/src/core/format.js +15 -13
  204. package/src/core/http.js +29 -20
  205. package/src/core/i18n.js +83 -10
  206. package/src/core/keyboard.js +79 -8
  207. package/src/core/messages.js +519 -2
  208. package/src/core/overlay-host.js +1 -0
  209. package/src/core/storage.js +59 -6
  210. package/src/elements/define.js +178 -130
  211. package/src/elements/definitions.js +229 -0
  212. package/src/elements/kit.js +444 -0
  213. package/src/elements/reflect.js +8 -3
  214. package/src/index.js +18 -1
  215. package/src/internal/agent-model.js +488 -0
  216. package/src/internal/date-locale.js +11 -0
  217. package/src/internal/highlight.js +104 -0
  218. package/src/internal/json-patch.js +405 -0
  219. package/src/internal/presence-loop.js +343 -0
  220. package/src/locales/de.js +911 -0
  221. package/src/locales/en.js +2 -0
  222. package/src/locales/index.js +7 -0
  223. package/src/zeyos/calendar.js +2 -1
  224. package/src/zeyos/form.js +2 -1
  225. package/src/zeyos/launcher.js +7 -6
  226. package/src/zeyos/module-bar.js +2 -1
  227. package/src/zeyos/schema.js +37 -23
  228. package/src/zeyos/select.js +4 -3
  229. package/src/zeyos/table.js +2 -13
  230. package/src/zeyos/view.js +57 -17
  231. package/styles/core.css +11 -0
  232. package/styles/tokens/semantic.css +1 -0
  233. package/styles/zeyos.css +2 -0
  234. package/styles/zx.css +11 -8
  235. package/styles/zx.layered.css +1 -0
@@ -0,0 +1,711 @@
1
+ import { Component } from '../../core/component.js';
2
+ import { ApprovalCard } from '../approval-card/approval-card.js';
3
+ import { BlockView } from '../block-view/block-view.js';
4
+ import { RunTrace } from '../run-trace/run-trace.js';
5
+ import { SourceList } from '../source-list/source-list.js';
6
+ import { Surface } from '../surface/surface.js';
7
+ export type ThreadItem = import('../../internal/agent-model.js').ThreadItem;
8
+ export type Author = import('../../internal/agent-model.js').Author;
9
+ export type Source = import('../../internal/agent-model.js').Source;
10
+ export type Block = import('../../internal/agent-model.js').Block;
11
+ export type EmptyStateOptions = import('../empty-state/empty-state.js').EmptyStateOptions;
12
+ export type AnswerAction = 'copy' | 'regenerate' | 'branch' | 'rate';
13
+ export type SurfaceOptions = import('../surface/surface.js').SurfaceOptions;
14
+ export type SurfaceReply = import('../surface/text.js').SurfaceReply;
15
+ export type PlaceholderItem = {
16
+ id: string;
17
+ type: 'zx-placeholder';
18
+ at?: string;
19
+ author?: string;
20
+ /**
21
+ * Skeleton lines.
22
+ */
23
+ lines?: number;
24
+ };
25
+ export type UpsertOptions = {
26
+ /**
27
+ * The id of the item to insert the new item right after;
28
+ * the end of the thread when null or unknown. An item already in the thread stays where it is.
29
+ */
30
+ after?: string | null;
31
+ };
32
+ export type SurfaceItem = {
33
+ id: string;
34
+ type: 'surface';
35
+ at?: string;
36
+ author?: string;
37
+ /**
38
+ * The whole surface.
39
+ */
40
+ document?: import('../surface/validate.js').SurfaceDocument | null;
41
+ /**
42
+ * The application's token, copied into the reply.
43
+ */
44
+ token?: string | null;
45
+ /**
46
+ * A narrowed catalog.
47
+ */
48
+ catalog?: import('../surface/catalog.js').SurfaceCatalog;
49
+ /**
50
+ * The reply it gave; the surface is drawn as its receipt.
51
+ */
52
+ reply?: SurfaceReply | null;
53
+ };
54
+ export type ThreadRenderContext = {
55
+ /**
56
+ * The thread drawing the item.
57
+ */
58
+ thread: AgentThread;
59
+ /**
60
+ * The item's author, resolved from `authors`.
61
+ */
62
+ author: Author | null;
63
+ /**
64
+ * Hands a component to the thread, which
65
+ * destroys it with the item.
66
+ */
67
+ own: <T extends Component>(component: T) => T;
68
+ };
69
+ export type ThreadItemRenderer = (item: ThreadItem, context: ThreadRenderContext) => Node | null;
70
+ export type AgentThreadOptions = {
71
+ /**
72
+ * The conversation, oldest first.
73
+ */
74
+ items?: ThreadItem[];
75
+ /**
76
+ * Who wrote the items and took the steps, by key.
77
+ * An item without an `author` is the person's own (`user`) or the first agent's (anything else).
78
+ */
79
+ authors?: Record<string, Author>;
80
+ /**
81
+ * Author key of the person reading; their items read as "You".
82
+ */
83
+ me?: string;
84
+ /**
85
+ * Accessible name of the feed; "Conversation" when null.
86
+ */
87
+ label?: string | null;
88
+ /**
89
+ * Heading level inside answers and cards.
90
+ */
91
+ headingLevel?: 2 | 3 | 4 | 5;
92
+ /**
93
+ * Shown while there are no items.
94
+ */
95
+ emptyState?: EmptyStateOptions | null;
96
+ /**
97
+ * Keep the end in view while new output arrives, as long
98
+ * as the reader is at the end; otherwise offer "Jump to latest" and leave them where they are.
99
+ */
100
+ followOutput?: boolean;
101
+ /**
102
+ * The element that scrolls; the nearest scrolling
103
+ * ancestor (or the thread itself) when null.
104
+ */
105
+ scroller?: Element | null;
106
+ /**
107
+ * Actions under each
108
+ * finished answer; `regenerate` only under the latest one.
109
+ */
110
+ answerActions?: AnswerAction[];
111
+ /**
112
+ * Glyph
113
+ * names for the answer and message actions.
114
+ */
115
+ icons?: Partial<Record<'regenerate' | 'branch' | 'rateUp' | 'rateDown' | 'edit', string>>;
116
+ /**
117
+ * Actions on the person's own messages, shown
118
+ * while the message is pointed at or holds focus (always on a touch screen): `edit` asks the
119
+ * application to put the message back in the composer, `copy` copies its text.
120
+ */
121
+ userActions?: Array<'edit' | 'copy'>;
122
+ /**
123
+ * Glyph names for trace step kinds, handed to
124
+ * every `RunTrace` the thread draws.
125
+ */
126
+ traceIcons?: Record<string, string>;
127
+ /**
128
+ * Glyph names for source kinds, handed to every
129
+ * `SourceList` the thread draws.
130
+ */
131
+ sourceIcons?: Record<string, string>;
132
+ /**
133
+ * The clock "today" is measured against in cards and
134
+ * traces, for an application whose world runs on fixed dates; the real clock when null.
135
+ */
136
+ now?: (() => Date) | null;
137
+ /**
138
+ * Formats an item's `at`; the local
139
+ * clock time when null.
140
+ */
141
+ formatTime?: ((at: string) => string) | null;
142
+ /**
143
+ * Locale for times.
144
+ */
145
+ locale?: string;
146
+ /**
147
+ * Options
148
+ * handed to every Surface the thread draws: the application's `policy`, `resolve`, `chartAdapter`
149
+ * and `msg`. Its authors, heading level and locale are the thread's unless given here.
150
+ */
151
+ surfaceOptions?: Omit<SurfaceOptions, 'document' | 'token' | 'catalog' | 'reply'>;
152
+ /**
153
+ * Localized messages.
154
+ */
155
+ msg?: Record<string, string> | Record<string, Record<string, string>>;
156
+ /**
157
+ * Answer action listener.
158
+ */
159
+ onaction?: (event: CustomEvent<{
160
+ item: ThreadItem;
161
+ action: string;
162
+ value?: unknown;
163
+ }>) => void;
164
+ /**
165
+ * Surface reply listener.
166
+ */
167
+ onreply?: (event: CustomEvent<{
168
+ item: ThreadItem;
169
+ reply: SurfaceReply;
170
+ }>) => void;
171
+ /**
172
+ * Approval listener.
173
+ */
174
+ onapprove?: (event: CustomEvent<{
175
+ item: ThreadItem;
176
+ values: Record<string, unknown>;
177
+ }>) => void;
178
+ /**
179
+ * Edit listener.
180
+ */
181
+ onedit?: (event: CustomEvent<{
182
+ item: ThreadItem;
183
+ values: Record<string, unknown>;
184
+ }>) => void;
185
+ /**
186
+ * Rejection listener.
187
+ */
188
+ onreject?: (event: CustomEvent<{
189
+ item: ThreadItem;
190
+ reason: string;
191
+ }>) => void;
192
+ /**
193
+ * Citation listener.
194
+ */
195
+ oncite?: (event: CustomEvent<{
196
+ item: ThreadItem;
197
+ n: number;
198
+ source: Source | null;
199
+ }>) => void;
200
+ /**
201
+ * Artifact listener.
202
+ */
203
+ onartifact?: (event: CustomEvent<{
204
+ item: ThreadItem;
205
+ id: string;
206
+ }>) => void;
207
+ /**
208
+ * Reveal listener.
209
+ */
210
+ onreveal?: (event: CustomEvent<{
211
+ target: string;
212
+ }>) => void;
213
+ /**
214
+ * Link listener.
215
+ */
216
+ onopen?: (event: CustomEvent<{
217
+ item: ThreadItem;
218
+ ref: import('../../internal/agent-model.js').ItemRef;
219
+ }>) => void;
220
+ };
221
+ export type ThreadEntry = {
222
+ /**
223
+ * The item as last given.
224
+ */
225
+ item: ThreadItem;
226
+ /**
227
+ * Its article.
228
+ */
229
+ article: HTMLElement;
230
+ /**
231
+ * Components drawn for it.
232
+ */
233
+ owned: Component[];
234
+ /**
235
+ * An answer's text.
236
+ */
237
+ view: BlockView | null;
238
+ /**
239
+ * A trace's steps.
240
+ */
241
+ trace: RunTrace | null;
242
+ /**
243
+ * An answer's sources.
244
+ */
245
+ sources: SourceList | null;
246
+ /**
247
+ * An approval.
248
+ */
249
+ card: ApprovalCard | null;
250
+ /**
251
+ * A surface.
252
+ */
253
+ surface?: Surface | null;
254
+ };
255
+ /**
256
+ * A conversation with one or more agents: the person's messages, the agents' answers as they
257
+ * stream, the steps a run took, the approvals that hold it, and one-line notices — drawn from the
258
+ * plain-JSON items of the agent model. The thread owns no transport and no state beyond what it
259
+ * is given: the application feeds it (`upsert`, `patch`, `appendText`) and acts on what it emits.
260
+ *
261
+ * It follows the APG feed pattern: each item is an article in a `role="feed"`, PageDown and
262
+ * PageUp move between articles, and Ctrl+End / Ctrl+Home leave the feed. Streamed text is never
263
+ * read aloud as it arrives; one polite status says when an agent starts, answers, needs
264
+ * approval, or is stopped.
265
+ *
266
+ * @fires AgentThread#action
267
+ * @fires AgentThread#approve
268
+ * @fires AgentThread#edit
269
+ * @fires AgentThread#reject
270
+ * @fires AgentThread#cite
271
+ * @fires AgentThread#artifact
272
+ * @fires AgentThread#reveal
273
+ * @fires AgentThread#open
274
+ * @fires AgentThread#reply
275
+ * @extends {Component<AgentThreadOptions>}
276
+ */
277
+ export declare class AgentThread extends Component<AgentThreadOptions> {
278
+ #private;
279
+ _original: import("../../core/dom.js").TargetSnapshot;
280
+ _id: string;
281
+ /** @type {Map<string, ThreadEntry>} */
282
+ _entries: Map<string, ThreadEntry>;
283
+ /** @type {string[]} */
284
+ _order: string[];
285
+ _announceTimer: number;
286
+ _askingPerson: boolean;
287
+ /** @type {Element|null} */
288
+ _scrollHost: Element | null;
289
+ /** @type {EventTarget|null} */
290
+ _scrollTarget: EventTarget | null;
291
+ _onScroll: () => void;
292
+ /** @type {string|null} */
293
+ _latestAnswer: string | null;
294
+ /** @type {Map<string, {expanded?: boolean|null, controls?: string|null}>} Artifact open states, for answers drawn later. */
295
+ _artifacts: Map<string, {
296
+ expanded?: boolean | null;
297
+ controls?: string | null;
298
+ }>;
299
+ /** @type {WeakSet<Surface>} Surfaces answered elsewhere, whose going is no reply. */
300
+ _answeredElsewhere: WeakSet<Surface>;
301
+ _feed: HTMLElement;
302
+ _empty: HTMLElement;
303
+ _latestButton: HTMLButtonElement;
304
+ _status: HTMLElement;
305
+ _destroyed: boolean;
306
+ static cssName: string;
307
+ /** @type {Readonly<AgentThreadOptions>} */
308
+ static defaults: Readonly<AgentThreadOptions>;
309
+ /**
310
+ * Registers how items of another type are drawn. An application's own renderer for `surface`
311
+ * replaces the library's drawing of that type; the types the library always draws cannot be
312
+ * replaced.
313
+ * @param {string} type Item type.
314
+ * @param {ThreadItemRenderer} render Draws the item's content.
315
+ * @returns {typeof AgentThread}
316
+ */
317
+ static register(type: string, render: ThreadItemRenderer): typeof AgentThread;
318
+ /**
319
+ * Reports whether a type has a registered renderer. `surface` answers false until an
320
+ * application registers its own, so a guarded `register()` still takes effect.
321
+ * @param {string} type
322
+ * @returns {boolean}
323
+ */
324
+ static has(type: string): boolean;
325
+ /** @returns {HTMLElement} */
326
+ render(): HTMLElement;
327
+ /**
328
+ * Replaces the conversation. Everything is dropped and then drawn anew, except a surface already
329
+ * drawn, which stays so that one still matching keeps answering.
330
+ * @param {ThreadItem[]} items
331
+ * @returns {this}
332
+ */
333
+ setItems(items: ThreadItem[]): this;
334
+ /**
335
+ * Adds an item, or replaces the item with the same id where it stands. A new item goes at the
336
+ * end, or right after the item `options.after` names.
337
+ * @param {ThreadItem} item
338
+ * @param {UpsertOptions} [options]
339
+ * @returns {this}
340
+ */
341
+ upsert(item: ThreadItem, options?: UpsertOptions): this;
342
+ /**
343
+ * Changes part of an item. The common changes are made in place — an answer finishing, stopping
344
+ * or writing on, a trace's steps, an approval's status — so what the reader opened, and focus and
345
+ * selection where the blocks stay, survive; anything else redraws the item. Metadata patches
346
+ * retain an answer's live blocks; explicit `blocks` or `versions` remain authoritative.
347
+ * @param {string} id
348
+ * @param {Record<string, unknown>} partial
349
+ * @returns {this}
350
+ */
351
+ patch(id: string, partial: Record<string, unknown>): this;
352
+ /**
353
+ * Streams text into an answer, creating it when the id is new. Only the answer's last
354
+ * paragraph is redrawn.
355
+ * @param {string} id
356
+ * @param {string} text
357
+ * @returns {this}
358
+ */
359
+ appendText(id: string, text: string): this;
360
+ /**
361
+ * Adds a whole block to an answer — a figures block, a table, code — after what it already
362
+ * shows, without redrawing the rest of the answer. Creates the answer when the id is new.
363
+ * @param {string} id
364
+ * @param {Block} block
365
+ * @returns {this}
366
+ */
367
+ appendBlock(id: string, block: Block): this;
368
+ /**
369
+ * Says something through the thread's polite status — an outcome the thread cannot see itself,
370
+ * such as "Reminders sent". Said once; the same words said twice are heard twice.
371
+ * @param {string} text
372
+ * @returns {this}
373
+ */
374
+ announce(text: string): this;
375
+ /**
376
+ * Removes an item. Focus inside it moves to the item above, or the one below when it was the
377
+ * first, so that a keyboard user is not thrown back to the top of the page.
378
+ * @param {string} id
379
+ * @returns {this}
380
+ */
381
+ remove(id: string): this;
382
+ /**
383
+ * An item as it stands, an answer's streamed text included.
384
+ * @param {string} id
385
+ * @returns {ThreadItem|null}
386
+ */
387
+ get(id: string): ThreadItem | null;
388
+ /** @returns {ThreadItem[]} Every item, in order, as it stands. */
389
+ getItems(): ThreadItem[];
390
+ /**
391
+ * The main component drawn for an item: an answer's BlockView, a trace's RunTrace, an
392
+ * approval's ApprovalCard.
393
+ * @param {string} id
394
+ * @returns {Component|null}
395
+ */
396
+ getComponent(id: string): Component | null;
397
+ /**
398
+ * The Surface drawn for a `surface` item, to stream its operations into with `apply()` or
399
+ * `write()`.
400
+ * @param {string} id
401
+ * @returns {Surface|null}
402
+ */
403
+ surface(id: string): Surface | null;
404
+ /**
405
+ * Brings something into view and moves focus to it: `item:<id>` an item, `step:<id>` a trace
406
+ * step (in whichever trace holds it), `source:<n>` a source of the latest answer that has one,
407
+ * `source:<n>:<id>` a source in the list of the answer `id`.
408
+ * @param {string} target
409
+ * @returns {boolean} Whether the target was found.
410
+ */
411
+ reveal(target: string): boolean;
412
+ /**
413
+ * Reflects whether an artifact is open somewhere — an inspector, a drawer — on every card that
414
+ * names it, in every answer. See `BlockView#setArtifactState()`.
415
+ * @param {string} id Artifact id.
416
+ * @param {{expanded?: boolean|null, controls?: string|null}} state
417
+ * @returns {this}
418
+ */
419
+ setArtifactState(id: string, state: {
420
+ expanded?: boolean | null;
421
+ controls?: string | null;
422
+ }): this;
423
+ /**
424
+ * Scrolls to the end of the conversation.
425
+ * @returns {this}
426
+ */
427
+ scrollToEnd(): this;
428
+ /** @returns {void} */
429
+ destroy(): void;
430
+ /**
431
+ * @private
432
+ * @param {ThreadItem} item
433
+ * @param {{announce?: boolean, after?: string|null}} [options]
434
+ * @returns {void}
435
+ */
436
+ private _add;
437
+ /**
438
+ * @private
439
+ * @param {string} id
440
+ * @param {ThreadItem} item
441
+ * @returns {void}
442
+ */
443
+ private _replace;
444
+ /**
445
+ * Puts the feed in the order given, moving only what stands elsewhere. Anything a listener added
446
+ * meanwhile stays, after what was asked for.
447
+ * @private
448
+ * @param {string[]} ids
449
+ * @returns {void}
450
+ */
451
+ private _arrange;
452
+ /** @private @param {string} id @returns {void} */
453
+ private _drop;
454
+ /**
455
+ * Regenerate belongs to the latest answer only: when another answer becomes the latest, both
456
+ * answers' actions are redrawn.
457
+ * @private
458
+ * @returns {void}
459
+ */
460
+ private _syncLatest;
461
+ /** @private @returns {string|null} The id of the last answer in the thread. */
462
+ private _latestAnswerId;
463
+ /**
464
+ * Redraws an answer's action row alone, leaving its sources as they are.
465
+ * @private
466
+ * @param {ThreadEntry} entry
467
+ * @returns {void}
468
+ */
469
+ private _redrawActions;
470
+ /**
471
+ * Draws one item into its article.
472
+ * @private
473
+ * @param {ThreadItem} item
474
+ * @param {Surface|null} [surface=null] A surface to keep rather than draw anew.
475
+ * @returns {ThreadEntry}
476
+ */
477
+ private _build;
478
+ /**
479
+ * A RunTrace the thread owns: its authors, glyphs, and clock.
480
+ * @private
481
+ * @param {import('../../internal/agent-model.js').TraceStep[]} steps
482
+ * @param {{open?: boolean, label?: string|null}} [options]
483
+ * @returns {RunTrace}
484
+ */
485
+ private _trace;
486
+ /**
487
+ * Keeps a child's bubbling `zx-<type>` events inside the thread for the types the thread
488
+ * re-emits itself, so a listener on the thread's root hears each of them once.
489
+ * @private
490
+ * @param {Component} child
491
+ * @param {string[]} types
492
+ * @returns {void}
493
+ */
494
+ private _contain;
495
+ /**
496
+ * Links from an item to the application's own things, after its content.
497
+ * @private
498
+ * @param {unknown} refs
499
+ * @returns {HTMLElement|null}
500
+ */
501
+ private _refs;
502
+ /**
503
+ * Edit and copy on the person's own message, shown while it is pointed at or holds focus.
504
+ * @private
505
+ * @param {Extract<ThreadItem, {type: 'user'}>} user
506
+ * @returns {HTMLElement|null}
507
+ */
508
+ private _userActions;
509
+ /**
510
+ * @private
511
+ * @param {ThreadEntry} entry
512
+ * @param {HTMLElement} body
513
+ * @param {<T extends Component>(component: T) => T} own
514
+ * @returns {void}
515
+ */
516
+ private _buildAnswer;
517
+ /**
518
+ * While an answer is on its way and nothing of it has arrived, a quiet line says who is
519
+ * writing; it goes as soon as the first words do.
520
+ * @private
521
+ * @param {ThreadEntry} entry
522
+ * @returns {void}
523
+ */
524
+ private _syncWriting;
525
+ /**
526
+ * Draws an answer's sources and actions, which show only once it is finished.
527
+ * @private
528
+ * @param {ThreadEntry} entry
529
+ * @param {<T extends Component>(component: T) => T} [own]
530
+ * @returns {void}
531
+ */
532
+ private _redrawAnswerFooter;
533
+ /**
534
+ * @private
535
+ * @param {ThreadEntry} entry
536
+ * @returns {HTMLElement|null}
537
+ */
538
+ private _answerActions;
539
+ /**
540
+ * @private
541
+ * @param {ThreadEntry} entry
542
+ * @param {HTMLElement} body
543
+ * @param {<T extends Component>(component: T) => T} own
544
+ * @returns {void}
545
+ */
546
+ private _buildApproval;
547
+ /**
548
+ * A surface item: the Surface, its reply re-emitted as the thread's `reply` and kept on the item.
549
+ * @private
550
+ * @param {ThreadEntry} entry
551
+ * @param {HTMLElement} body
552
+ * @param {<T extends Component>(component: T) => T} own
553
+ * @param {Surface|null} kept A surface carried over from the item's earlier drawing.
554
+ * @returns {void}
555
+ */
556
+ private _buildSurface;
557
+ /**
558
+ * The author's avatar, beside the byline and the content. Decorative: the byline names them.
559
+ * @private
560
+ * @param {ThreadItem} item
561
+ * @param {<T extends Component>(component: T) => T} own
562
+ * @returns {HTMLElement|null}
563
+ */
564
+ private _avatar;
565
+ /**
566
+ * @private
567
+ * @param {ThreadItem} item
568
+ * @param {string} id
569
+ * @returns {HTMLElement}
570
+ */
571
+ private _byline;
572
+ /**
573
+ * @private
574
+ * @param {Array<{name: string, size?: number}>} files
575
+ * @returns {HTMLElement}
576
+ */
577
+ private _files;
578
+ /** @private @param {ThreadItem} item @returns {boolean} */
579
+ private _isMine;
580
+ /** @private @param {ThreadItem} item @returns {Author|null} */
581
+ private _author;
582
+ /** @private @param {ThreadItem} item @returns {string} */
583
+ private _authorName;
584
+ /** @private @param {unknown} at @returns {string} */
585
+ private _time;
586
+ /** @private @param {Extract<ThreadItem, {type: 'answer'}>} answer @returns {number} */
587
+ private _versionIndex;
588
+ /**
589
+ * An answer with versions shows its chosen version, so what changes in it belongs there too: the
590
+ * item's own fields are only what it would show without them.
591
+ * @private
592
+ * @template {ThreadItem} T
593
+ * @param {T} item
594
+ * @param {Record<string, unknown>} partial What changed.
595
+ * @returns {T}
596
+ */
597
+ private _intoVersion;
598
+ /**
599
+ * Streamed text lives in the view, so an answer drawn anew from the same versions takes it along
600
+ * into the version it was streamed into.
601
+ * @private
602
+ * @param {ThreadEntry} old
603
+ * @param {ThreadItem} item
604
+ * @returns {ThreadItem}
605
+ */
606
+ private _keepStreamed;
607
+ /**
608
+ * The blocks, sources, and steps an answer shows: its chosen version's when it has several.
609
+ * @private
610
+ * @param {Extract<ThreadItem, {type: 'answer'}>} answer
611
+ * @returns {{blocks: Block[], sources: Source[], steps: import('../../internal/agent-model.js').TraceStep[],
612
+ * stopped: boolean, rating: 'up'|'down'|null, at: string|undefined}}
613
+ */
614
+ private _version;
615
+ /**
616
+ * A consecutive item by the same author reads as one turn: its byline is still there for a
617
+ * screen reader, but not drawn again.
618
+ * @private
619
+ * @param {string} id
620
+ * @returns {void}
621
+ */
622
+ private _syncContinuation;
623
+ /** @private @returns {void} */
624
+ private _syncPositions;
625
+ /** @private @returns {void} */
626
+ private _syncEmpty;
627
+ /** @private @param {ThreadItem} item @returns {void} */
628
+ private _announceItem;
629
+ /**
630
+ * Says a milestone once. The region is cleared first so the same words said twice are heard
631
+ * twice. Words still waiting to be said give way only to words that must be heard: what asks
632
+ * something of the person is not overtaken by what has just finished.
633
+ * @private
634
+ * @param {string} text
635
+ * @param {boolean} [urgent=false] Whether it must be heard.
636
+ * @returns {void}
637
+ */
638
+ private _announce;
639
+ /** @private @returns {Element|null} */
640
+ private _scroller;
641
+ /** @private @returns {boolean} */
642
+ private _atEnd;
643
+ /**
644
+ * Runs a change and keeps the end in view if the reader was reading it.
645
+ * @private
646
+ * @param {() => void} change
647
+ * @returns {void}
648
+ */
649
+ private _follow;
650
+ /** @private @returns {HTMLElement|null} */
651
+ private _lastArticle;
652
+ /** @private @param {MouseEvent} event @returns {void} */
653
+ private _onClick;
654
+ /**
655
+ * APG feed keys: PageDown and PageUp move between articles; Ctrl+End and Ctrl+Home move focus
656
+ * past the end or before the start of the feed. A control inside an item keeps them.
657
+ * @private
658
+ * @param {KeyboardEvent} event
659
+ * @returns {void}
660
+ */
661
+ private _onFeedKey;
662
+ }
663
+ /**
664
+ * Action payload: under an answer `copy`, `regenerate`, `branch`, `rate` (`value` up, down, or
665
+ * null), or `version` (`value` the version index; preventable, like `rate`); on the person's own
666
+ * message `edit` (copying needs no event); on a notice, the id of its `action`.
667
+ * @event AgentThread#action
668
+ * @type {CustomEvent<{item: ThreadItem, action: string, value?: unknown}>}
669
+ */
670
+ /**
671
+ * An approval was approved; preventable, which keeps the card pending.
672
+ * @event AgentThread#approve
673
+ * @type {CustomEvent<{item: ThreadItem, values: Record<string, unknown>}>}
674
+ */
675
+ /**
676
+ * An approval's values were edited; preventable.
677
+ * @event AgentThread#edit
678
+ * @type {CustomEvent<{item: ThreadItem, values: Record<string, unknown>}>}
679
+ */
680
+ /**
681
+ * An approval was rejected; preventable, which keeps the card pending.
682
+ * @event AgentThread#reject
683
+ * @type {CustomEvent<{item: ThreadItem, reason: string}>}
684
+ */
685
+ /**
686
+ * A citation was activated; preventable, which skips highlighting the source.
687
+ * @event AgentThread#cite
688
+ * @type {CustomEvent<{item: ThreadItem, n: number, source: Source|null}>}
689
+ */
690
+ /**
691
+ * An artifact card was activated.
692
+ * @event AgentThread#artifact
693
+ * @type {CustomEvent<{item: ThreadItem, id: string}>}
694
+ */
695
+ /**
696
+ * Something was brought into view by `reveal()`.
697
+ * @event AgentThread#reveal
698
+ * @type {CustomEvent<{target: string}>}
699
+ */
700
+ /**
701
+ * A link was activated: one of an item's `refs`, or of a trace step's (then `step` names it).
702
+ * @event AgentThread#open
703
+ * @type {CustomEvent<{item: ThreadItem, ref: import('../../internal/agent-model.js').ItemRef, step?: import('../../internal/agent-model.js').TraceStep}>}
704
+ */
705
+ /**
706
+ * A surface in the thread replied: its one reply, with the item as it now stands. Also sent when
707
+ * an unanswered surface is superseded by a new one under the same id, removed, or destroyed with
708
+ * the thread.
709
+ * @event AgentThread#reply
710
+ * @type {CustomEvent<{item: ThreadItem, reply: SurfaceReply}>}
711
+ */