@zeyos/zx 5.4.0 → 5.6.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 (145) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/README.md +23 -16
  3. package/dist/types/components/agent-thread/agent-thread.d.ts +583 -0
  4. package/dist/types/components/app-sidebar/app-sidebar.d.ts +33 -0
  5. package/dist/types/components/approval-card/approval-card.d.ts +596 -0
  6. package/dist/types/components/avatar/avatar.d.ts +91 -4
  7. package/dist/types/components/badge/badge.d.ts +5 -4
  8. package/dist/types/components/block-view/block-view.d.ts +205 -0
  9. package/dist/types/components/composer/composer.d.ts +736 -0
  10. package/dist/types/components/datebox/date-range-box.d.ts +15 -2
  11. package/dist/types/components/datebox/datebox.d.ts +37 -3
  12. package/dist/types/components/kbd/kbd.d.ts +41 -0
  13. package/dist/types/components/launcher/launcher.d.ts +4 -2
  14. package/dist/types/components/prose/prose.d.ts +69 -0
  15. package/dist/types/components/questionnaire/questionnaire.d.ts +0 -36
  16. package/dist/types/components/run-status/run-status.d.ts +393 -0
  17. package/dist/types/components/run-trace/run-trace.d.ts +624 -0
  18. package/dist/types/components/source-list/source-list.d.ts +177 -0
  19. package/dist/types/components/stat-tile/stat-tile.d.ts +20 -0
  20. package/dist/types/components/tag-picker/tag-picker.d.ts +11 -5
  21. package/dist/types/components/tree/tree.d.ts +44 -3
  22. package/dist/types/core/icons.d.ts +22 -1
  23. package/dist/types/core/messages.d.ts +135 -0
  24. package/dist/types/index.d.ts +12 -2
  25. package/dist/types/internal/agent-model.d.ts +587 -0
  26. package/dist/types/internal/app-rail.d.ts +10 -3
  27. package/dist/types/internal/highlight.d.ts +24 -0
  28. package/dist/types/internal/presence-loop.d.ts +148 -0
  29. package/dist/types/internal/row-actions.d.ts +151 -0
  30. package/dist/zx-zeyos.esm.js +4852 -4535
  31. package/dist/zx-zeyos.esm.min.js +4 -4
  32. package/dist/zx.css +3152 -434
  33. package/dist/zx.esm.js +13730 -6595
  34. package/dist/zx.esm.min.js +27 -8
  35. package/dist/zx.global.js +13730 -6595
  36. package/dist/zx.global.min.js +27 -8
  37. package/dist/zx.min.css +1 -1
  38. package/docs/api.json +1474 -205
  39. package/docs/llms.md +698 -39
  40. package/docs/llms.txt +12 -1
  41. package/package.json +1 -1
  42. package/src/components/account-menu/account-menu.js +2 -2
  43. package/src/components/agent-thread/agent-thread.css +417 -0
  44. package/src/components/agent-thread/agent-thread.js +1365 -0
  45. package/src/components/app-rail/app-rail.css +11 -11
  46. package/src/components/app-sidebar/app-sidebar.css +90 -17
  47. package/src/components/app-sidebar/app-sidebar.js +120 -12
  48. package/src/components/approval-card/approval-card.css +289 -0
  49. package/src/components/approval-card/approval-card.js +1377 -0
  50. package/src/components/avatar/avatar.css +56 -1
  51. package/src/components/avatar/avatar.js +148 -26
  52. package/src/components/badge/badge.css +33 -20
  53. package/src/components/badge/badge.js +5 -4
  54. package/src/components/block-view/block-view.css +300 -0
  55. package/src/components/block-view/block-view.js +523 -0
  56. package/src/components/breadcrumb/breadcrumb.css +28 -3
  57. package/src/components/breadcrumb/breadcrumb.js +2 -2
  58. package/src/components/button/button.css +24 -13
  59. package/src/components/button/button.js +20 -2
  60. package/src/components/calendar/calendar.css +14 -4
  61. package/src/components/card-view/card-view.js +2 -2
  62. package/src/components/chart/chart.js +20 -5
  63. package/src/components/check-button/check-button.css +11 -3
  64. package/src/components/check-button/check-button.js +3 -3
  65. package/src/components/composer/composer.css +403 -0
  66. package/src/components/composer/composer.js +1441 -0
  67. package/src/components/context-menu/context-menu.css +7 -1
  68. package/src/components/date-picker/date-picker.css +6 -0
  69. package/src/components/date-picker/date-picker.js +5 -5
  70. package/src/components/date-picker/date-range-picker.css +6 -0
  71. package/src/components/date-picker/date-range-picker.js +3 -3
  72. package/src/components/date-picker/month-picker.js +3 -3
  73. package/src/components/date-picker/time-picker.css +6 -0
  74. package/src/components/datebox/date-range-box.js +30 -6
  75. package/src/components/datebox/datebox.js +44 -7
  76. package/src/components/dialog/dialog.css +0 -1
  77. package/src/components/dialog/dialog.js +2 -1
  78. package/src/components/dock/dock.js +2 -2
  79. package/src/components/dropdown/dropdown.css +2 -1
  80. package/src/components/entity-ref/entity-ref.css +8 -1
  81. package/src/components/file-item/file-item.css +1 -1
  82. package/src/components/finder/finder.js +2 -2
  83. package/src/components/groupbox/groupbox.js +2 -2
  84. package/src/components/kanban-view/kanban-view.css +8 -4
  85. package/src/components/kanban-view/kanban-view.js +3 -3
  86. package/src/components/kbd/kbd.css +64 -0
  87. package/src/components/kbd/kbd.js +121 -0
  88. package/src/components/launcher/launcher.css +30 -25
  89. package/src/components/launcher/launcher.js +15 -21
  90. package/src/components/list-toolbar/list-toolbar.css +7 -1
  91. package/src/components/menu-button/menu-button.css +9 -2
  92. package/src/components/message/message.js +2 -2
  93. package/src/components/module-bar/module-bar.css +11 -1
  94. package/src/components/multi-value-editor/multi-value-editor.js +4 -4
  95. package/src/components/navigation-bar/navigation-bar.css +3 -2
  96. package/src/components/pagination/pagination.js +2 -2
  97. package/src/components/panel/panel.js +2 -2
  98. package/src/components/prose/prose.css +53 -0
  99. package/src/components/prose/prose.js +152 -0
  100. package/src/components/questionnaire/questionnaire.css +7 -17
  101. package/src/components/questionnaire/questionnaire.js +16 -1
  102. package/src/components/rating/rating.css +3 -1
  103. package/src/components/run-status/run-status.css +208 -0
  104. package/src/components/run-status/run-status.js +782 -0
  105. package/src/components/run-trace/run-trace.css +443 -0
  106. package/src/components/run-trace/run-trace.js +1209 -0
  107. package/src/components/search/search.js +2 -2
  108. package/src/components/select/glyphs.js +3 -3
  109. package/src/components/select/select.css +35 -7
  110. package/src/components/select/select.js +4 -4
  111. package/src/components/source-list/source-list.css +208 -0
  112. package/src/components/source-list/source-list.js +355 -0
  113. package/src/components/stat-tile/stat-tile.css +56 -2
  114. package/src/components/stat-tile/stat-tile.js +25 -2
  115. package/src/components/stepper/stepper.css +2 -1
  116. package/src/components/stepper/stepper.js +3 -3
  117. package/src/components/tabbox/tabbox.css +2 -2
  118. package/src/components/tabbox/tabbox.js +2 -2
  119. package/src/components/table/table.css +52 -16
  120. package/src/components/table/table.js +7 -5
  121. package/src/components/tag-picker/tag-picker.css +56 -43
  122. package/src/components/tag-picker/tag-picker.js +21 -16
  123. package/src/components/tree/tree.css +44 -0
  124. package/src/components/tree/tree.js +97 -9
  125. package/src/components/value-list/value-list.css +25 -4
  126. package/src/components/value-list/value-list.js +2 -1
  127. package/src/components/view/record-view.js +3 -3
  128. package/src/components/view-settings/view-settings.css +2 -1
  129. package/src/components/workspace-switcher/workspace-switcher.js +3 -3
  130. package/src/core/icons.js +34 -3
  131. package/src/core/messages.js +143 -0
  132. package/src/elements/define.js +1 -0
  133. package/src/index.js +12 -2
  134. package/src/internal/agent-model.js +488 -0
  135. package/src/internal/app-rail.js +5 -1
  136. package/src/internal/highlight.js +104 -0
  137. package/src/internal/presence-loop.js +343 -0
  138. package/src/internal/row-actions.js +203 -0
  139. package/styles/base.css +26 -1
  140. package/styles/prose.css +306 -0
  141. package/styles/tokens/dark.css +97 -120
  142. package/styles/tokens/global.css +24 -9
  143. package/styles/tokens/semantic.css +464 -184
  144. package/styles/tokens/themes.css +9 -0
  145. package/styles/zx.css +10 -0
@@ -17,9 +17,16 @@ export type DateRangeBoxOptions = {
17
17
  */
18
18
  end?: Date | number | string | null;
19
19
  /**
20
- * Kernel date format used for both endpoints.
20
+ * Kernel date format the reader types for both endpoints,
21
+ * shown while the field has focus. Numeric tokens only, since it is parsed.
21
22
  */
22
23
  format?: string;
24
+ /**
25
+ * Format both endpoints are shown in while the field
26
+ * does not have focus. It is never parsed, so it may use any `formatDate()` token, month and
27
+ * weekday names included. Null shows `format`.
28
+ */
29
+ displayFormat?: string | null;
23
30
  /**
24
31
  * Text placed between the two formatted dates.
25
32
  */
@@ -122,9 +129,11 @@ export declare class DateRangeBox extends Component<DateRangeBoxOptions> {
122
129
  _originalAriaDisabled: string;
123
130
  _originalClearable: string;
124
131
  _format: string;
132
+ _displayFormat: string;
125
133
  _separator: string;
126
134
  _disabled: boolean;
127
135
  _open: boolean;
136
+ _focused: boolean;
128
137
  _position: import("../../core/position.js").PositionController;
129
138
  _range: import("../date-picker/date-range-picker.js").DateRange | {
130
139
  start: unknown;
@@ -209,7 +218,11 @@ export declare class DateRangeBox extends Component<DateRangeBoxOptions> {
209
218
  _clamp(range: DateRange): DateRange;
210
219
  /** @returns {string} */
211
220
  _placeholder(): string;
212
- /** @returns {void} */
221
+ /**
222
+ * Writes the range into the input: in the typing format while the input has focus, in the
223
+ * display format otherwise. Text that is already there is left alone, so the caret stays put.
224
+ * @returns {void}
225
+ */
213
226
  _syncDisplay(): void;
214
227
  /** A disabled box offers no clear button: there is nothing it could do. @returns {void} */
215
228
  _syncClear(): void;
@@ -6,9 +6,16 @@ export type DateboxOptions = {
6
6
  */
7
7
  value?: Date | number | string | null;
8
8
  /**
9
- * Kernel date format.
9
+ * Kernel date format the reader types, shown while the
10
+ * field has focus. Numeric tokens only (`%d %e %m %Y %y %H %M %S`), since it is parsed.
10
11
  */
11
12
  format?: string;
13
+ /**
14
+ * Format the field shows while it does not have focus,
15
+ * so a date reads as the rest of the screen writes dates. It is never parsed, so it may use any
16
+ * `formatDate()` token, month and weekday names included. Null shows `format`.
17
+ */
18
+ displayFormat?: string | null;
12
19
  /**
13
20
  * Append `%H:%M` and show time controls.
14
21
  */
@@ -62,7 +69,11 @@ export type DateboxUnit = 'date' | 'seconds';
62
69
  /**
63
70
  * @typedef {Object} DateboxOptions
64
71
  * @property {Date|number|string|null} [value=null] Date, Unix seconds, or formatted string.
65
- * @property {string} [format='%d.%m.%Y'] Kernel date format.
72
+ * @property {string} [format='%d.%m.%Y'] Kernel date format the reader types, shown while the
73
+ * field has focus. Numeric tokens only (`%d %e %m %Y %y %H %M %S`), since it is parsed.
74
+ * @property {string|null} [displayFormat=null] Format the field shows while it does not have focus,
75
+ * so a date reads as the rest of the screen writes dates. It is never parsed, so it may use any
76
+ * `formatDate()` token, month and weekday names included. Null shows `format`.
66
77
  * @property {boolean} [time=false] Append `%H:%M` and show time controls.
67
78
  * @property {Date|null} [min=null] Earliest selectable date.
68
79
  * @property {Date|null} [max=null] Latest selectable date.
@@ -90,8 +101,10 @@ export declare class Datebox extends Component<DateboxOptions> {
90
101
  _originalAriaDisabled: string;
91
102
  _originalClearable: string;
92
103
  _format: string;
104
+ _displayFormat: string;
93
105
  _disabled: boolean;
94
106
  _open: boolean;
107
+ _focused: boolean;
95
108
  _position: import("../../core/position.js").PositionController;
96
109
  _min: Date;
97
110
  _max: Date;
@@ -143,7 +156,11 @@ export declare class Datebox extends Component<DateboxOptions> {
143
156
  _commitText(): void;
144
157
  /** @param {Date|number|string|null|unknown} value @returns {Date|null} */
145
158
  _normalizeValue(value: Date | number | string | null | unknown): Date | null;
146
- /** @returns {void} */
159
+ /**
160
+ * Writes the value into the input: in the typing format while the input has focus, in the
161
+ * display format otherwise. Text that is already there is left alone, so the caret stays put.
162
+ * @returns {void}
163
+ */
147
164
  _syncDisplay(): void;
148
165
  /** A disabled box offers no clear button: there is nothing it could do. @returns {void} */
149
166
  _syncClear(): void;
@@ -163,3 +180,20 @@ export declare class Datebox extends Component<DateboxOptions> {
163
180
  * @returns {Datebox}
164
181
  */
165
182
  export declare const DateTimeBox: (target: Element | string | null, options?: DateboxOptions) => Datebox;
183
+ /**
184
+ * Resolves the two formats a Datebox works with: `format`, which the reader types and the field
185
+ * shows while focused, and `display`, which the field shows at rest. A missing format is
186
+ * `'%d.%m.%Y'`, a missing display format is the typing format, and with `time` either one that
187
+ * names no hour or minute gets `' %H:%M'` appended, so the time is never hidden.
188
+ * @param {{format?: string|null, displayFormat?: string|null, time?: boolean}} [options={}]
189
+ * The Datebox options that decide them.
190
+ * @returns {{format: string, display: string}}
191
+ */
192
+ export declare function dateboxFormats({ format, displayFormat, time }?: {
193
+ format?: string | null;
194
+ displayFormat?: string | null;
195
+ time?: boolean;
196
+ }): {
197
+ format: string;
198
+ display: string;
199
+ };
@@ -0,0 +1,41 @@
1
+ export type KbdOptions = {
2
+ /**
3
+ * Keycap size; `sm` sits inside a button or a menu row.
4
+ */
5
+ size?: 'md' | 'sm';
6
+ /**
7
+ * `inherit` draws the keycaps in the surrounding
8
+ * ink — on a solid primary button, a dark toast — instead of the neutral surface keycap.
9
+ */
10
+ tone?: 'neutral' | 'inherit';
11
+ };
12
+ /**
13
+ * The keycap labels `kbd()` draws for a chord or a list of keys, without building any DOM.
14
+ * @example
15
+ * keyLabels('Mod+Shift+K'); // ['⌘', '⇧', 'K'] on macOS, ['Ctrl', 'Shift', 'K'] elsewhere
16
+ * keyLabels('Mod+K', { apple: false }); // ['Ctrl', 'K']
17
+ * @param {string|string[]} keys A chord (`'Mod+Shift+K'`) or the key labels, in order.
18
+ * @param {{apple?: boolean}} [options] `apple` overrides the platform check.
19
+ * @returns {string[]}
20
+ */
21
+ export declare function keyLabels(keys: string | string[], { apple }?: {
22
+ apple?: boolean;
23
+ }): string[];
24
+ /**
25
+ * Renders a key or key combination as keycaps: one `<kbd class="zx-kbd">` holding a nested
26
+ * `<kbd class="zx-kbd__key">` per key, which is how HTML marks up a combination. Every place that
27
+ * shows a shortcut — a button, a menu, the launcher's hints, a shortcut sheet — uses it, so keys
28
+ * look the same everywhere.
29
+ *
30
+ * The keycaps are presentation. A control that has a shortcut announces it with
31
+ * `aria-keyshortcuts` on the control itself; mark a hint that repeats it `aria-hidden`.
32
+ *
33
+ * @example
34
+ * kbd('Mod+K'); // ⌘ K on macOS, Ctrl K elsewhere
35
+ * kbd(['g', 'h']); // a sequence written as two caps
36
+ * kbd('Enter', { size: 'sm' });
37
+ * @param {string|string[]} keys A chord (`'Mod+Shift+K'`) or the key labels, in order.
38
+ * @param {KbdOptions} [options]
39
+ * @returns {HTMLElement}
40
+ */
41
+ export declare function kbd(keys: string | string[], options?: KbdOptions): HTMLElement;
@@ -34,7 +34,8 @@ export type LauncherItem = {
34
34
  hint?: string | number;
35
35
  /**
36
36
  * Key labels drawn as
37
- * key caps (`['⌘', 'K']`), or Button's `{label, keys}` shape. Display only: the Launcher binds nothing.
37
+ * key caps with `kbd()` (`['⌘', 'K']`; a name such as `'Mod'` or `'Shift'` takes the platform's
38
+ * glyph), or Button's `{label, keys}` shape. Display only: the Launcher binds nothing.
38
39
  */
39
40
  shortcut?: string | string[] | {
40
41
  label: string | string[];
@@ -297,7 +298,8 @@ export type LauncherPageEntry = {
297
298
  * @property {string|number} [badge] Compact metadata.
298
299
  * @property {string|number} [hint] Muted text at the end of the row, such as a current value or a project.
299
300
  * @property {string|string[]|{label: string|string[], keys?: string}} [shortcut] Key labels drawn as
300
- * key caps (`['⌘', 'K']`), or Button's `{label, keys}` shape. Display only: the Launcher binds nothing.
301
+ * key caps with `kbd()` (`['⌘', 'K']`; a name such as `'Mod'` or `'Shift'` takes the platform's
302
+ * glyph), or Button's `{label, keys}` shape. Display only: the Launcher binds nothing.
301
303
  * @property {string} [keys] The same shortcut in `aria-keyshortcuts` syntax (`'Meta+K'`), exposed on
302
304
  * the option for assistive technology.
303
305
  * @property {'application'|'record'|'action'} [kind='action'] Tile or row presentation.
@@ -0,0 +1,69 @@
1
+ export type ProseAnchorsOptions = {
2
+ /**
3
+ * The headings that get a link, inside a
4
+ * `.zx-prose` under the root. A heading without an `id` has nothing to link to and is skipped.
5
+ */
6
+ selector?: string;
7
+ /**
8
+ * The link's accessible name; `%1` is the heading.
9
+ */
10
+ label?: string;
11
+ /**
12
+ * The link's tooltip.
13
+ */
14
+ title?: string;
15
+ /**
16
+ * What the live region says after a copy.
17
+ */
18
+ feedback?: string;
19
+ /**
20
+ * Milliseconds the tick and the message stay.
21
+ */
22
+ feedbackDuration?: number;
23
+ /**
24
+ * The address copied for a heading id. Defaults to the
25
+ * current address with its hash replaced (`sectionHref(location.href, id)`).
26
+ */
27
+ href?: (id: string) => string;
28
+ /**
29
+ * Called with the address and whether
30
+ * the clipboard took it.
31
+ */
32
+ oncopy?: (url: string, copied: boolean) => void;
33
+ };
34
+ export type ProseAnchors = {
35
+ /**
36
+ * Links headings added since, re-attaches the live region if the
37
+ * content was replaced, and updates the address of every link. Call it after re-rendering.
38
+ */
39
+ refresh: () => void;
40
+ /**
41
+ * Removes every link, the live region, and the listener.
42
+ */
43
+ destroy: () => void;
44
+ };
45
+ /**
46
+ * The address of a section: `base` with its hash replaced by the heading's id. The query is kept,
47
+ * and the id is encoded as a fragment.
48
+ * @param {string} base Absolute address, usually `location.href`.
49
+ * @param {string} id Heading id.
50
+ * @returns {string}
51
+ */
52
+ export declare function sectionHref(base: string, id: string): string;
53
+ /**
54
+ * Gives every section heading of authored content a link to itself. Each `h2`–`h4` with an `id`
55
+ * inside a `.zx-prose` under `root` ends in a small link (`<a class="zx-prose__anchor" href="#id">`)
56
+ * that rests out of sight and shows while the heading is pointed at or the link has focus. A plain
57
+ * click copies the section's address and confirms in place, without moving the page or touching
58
+ * the location, so an application's own routing is left alone; a middle or modified click is left
59
+ * to the browser, which opens the address.
60
+ *
61
+ * The heading becomes the reveal host (`data-zx-reveal-host`), so the link is always visible on a
62
+ * touch screen and under a contrast preference, and it stays in the Tab order.
63
+ *
64
+ * @param {Element|string} root The content, or an element holding it; a selector is resolved in
65
+ * the document.
66
+ * @param {ProseAnchorsOptions} [options={}] Anchor options.
67
+ * @returns {ProseAnchors}
68
+ */
69
+ export declare function proseAnchors(root: Element | string, options?: ProseAnchorsOptions): ProseAnchors;
@@ -114,42 +114,6 @@ export type QuestionnaireCompleteDetail = {
114
114
  answers: Record<string, unknown>;
115
115
  path: string[];
116
116
  };
117
- /**
118
- * @typedef {Object} QuestionnaireOptions
119
- * @property {QuestionnaireItem[]} [items=[]] Ordered question definitions.
120
- * @property {Record<string, unknown>} [answers={}] Answers to start from. Together with `active`
121
- * this is the resume pair: hand back what a previous session collected.
122
- * @property {string|null} [active=null] Item to open, defaulting to the first visible one.
123
- * @property {boolean} [progress=true] Whether the progress bar and counter are shown.
124
- * @property {boolean} [review=false] Whether a summary of every answer is shown before submitting.
125
- * @property {QuestionnaireAdvance} [advance='manual'] `auto` moves on by itself once a
126
- * single-choice question is answered.
127
- * @property {boolean} [shortcuts=true] Whether `1`–`9` and `a`–`z` pick an answer.
128
- * @property {boolean} [allowBack=true] Whether the Back action is offered.
129
- * @property {Record<string, string>|Record<string, Record<string, string>>} [msg] Localized messages.
130
- * @property {(event: CustomEvent<QuestionnaireChangeDetail>) => void} [onchange] Answer listener.
131
- * @property {(event: CustomEvent<QuestionnaireNavigateDetail>) => void} [onnavigate] Navigation listener.
132
- * @property {(event: CustomEvent<QuestionnaireSkipDetail>) => void} [onskip] Skip listener.
133
- * @property {(event: CustomEvent<QuestionnaireInvalidDetail>) => void} [oninvalid] Validation listener.
134
- * @property {(event: CustomEvent<QuestionnaireSubmitDetail>) => void} [onsubmit] Submit listener.
135
- * @property {(event: CustomEvent<QuestionnaireCompleteDetail>) => void} [oncomplete] Completion listener.
136
- */
137
- /**
138
- * @typedef {Object} QuestionnaireChangeDetail
139
- * @property {string} name Item whose answer changed.
140
- * @property {unknown} value The new answer.
141
- * @property {Record<string, unknown>} answers Every visible answer after the change.
142
- */
143
- /**
144
- * @typedef {Object} QuestionnaireNavigateDetail
145
- * @property {string|null} from Item being left, or null.
146
- * @property {string|null} to Item being opened, or null when the review screen is being entered.
147
- * @property {'next'|'previous'|'skip'|'goto'|'review'} reason What triggered the move.
148
- */
149
- /** @typedef {{name: string}} QuestionnaireSkipDetail */
150
- /** @typedef {{name: string, message: string}} QuestionnaireInvalidDetail */
151
- /** @typedef {{answers: Record<string, unknown>, path: string[]}} QuestionnaireSubmitDetail */
152
- /** @typedef {{answers: Record<string, unknown>, path: string[]}} QuestionnaireCompleteDetail */
153
117
  /**
154
118
  * A guided, one-question-at-a-time flow: onboarding intake, a service-call checklist, an audit
155
119
  * form, a feedback survey. The questionnaire owns the ordered items, the active one, the answers,
@@ -0,0 +1,393 @@
1
+ import { Component } from '../../core/component.js';
2
+ export type RunState = import('../../internal/agent-model.js').RunState;
3
+ export type RunStatusAction = {
4
+ /**
5
+ * Visible label.
6
+ */
7
+ label: string;
8
+ /**
9
+ * Visual intent.
10
+ */
11
+ kind?: 'default' | 'primary' | 'danger' | 'ghost';
12
+ /**
13
+ * Icon name.
14
+ */
15
+ icon?: string | null;
16
+ /**
17
+ * Called on activation, before the `action` event.
18
+ */
19
+ onclick?: (event: MouseEvent) => void;
20
+ };
21
+ export type RunCost = {
22
+ /**
23
+ * Spent so far.
24
+ */
25
+ amount: number;
26
+ /**
27
+ * The most it may spend. With a budget the cost is a meter that
28
+ * turns to the warning tone from 80% and to the danger tone at 100%.
29
+ */
30
+ budget?: number | null;
31
+ /**
32
+ * ISO 4217 code, such as `EUR`.
33
+ */
34
+ currency?: string;
35
+ };
36
+ export type RunSteps = {
37
+ done: number;
38
+ total: number;
39
+ };
40
+ export type RunTokens = [number, number] | number;
41
+ export type RunCompactMode = 'word' | 'icon';
42
+ export type RunTokenMeter = {
43
+ /**
44
+ * Tokens used.
45
+ */
46
+ total: number;
47
+ /**
48
+ * The most the run may use.
49
+ */
50
+ budget: number;
51
+ /**
52
+ * `warning` from 80%, `danger` at 100%.
53
+ */
54
+ level: 'normal' | 'warning' | 'danger';
55
+ /**
56
+ * "22.8K of 60K tokens".
57
+ */
58
+ text: string;
59
+ };
60
+ export type RunTime = string | Date;
61
+ export type RunStatusOptions = {
62
+ /**
63
+ * Where the run stands. Also the root's `data-state`. A
64
+ * `blocked` run is not over: it shows since when it is blocked, never a finished time.
65
+ */
66
+ state?: RunState;
67
+ /**
68
+ * One sentence on what is happening: "Step 3 of 6 needs your
69
+ * approval." Text only.
70
+ */
71
+ summary?: string;
72
+ /**
73
+ * Steps done out of the total, drawn as a progressbar.
74
+ */
75
+ steps?: RunSteps | null;
76
+ /**
77
+ * When the run started.
78
+ */
79
+ started?: RunTime | null;
80
+ /**
81
+ * When it finished, failed, or was stopped. Shown once
82
+ * the run is over.
83
+ */
84
+ finished?: RunTime | null;
85
+ /**
86
+ * How long the agent has worked, in milliseconds. Waiting
87
+ * for a person is not work. The row shows only when this is a number.
88
+ */
89
+ workMs?: number | null;
90
+ /**
91
+ * Since when the run has waited for a person, or been
92
+ * blocked. Shown as "Waiting since" while the state is `waiting` and "Blocked since" while it is
93
+ * `blocked`.
94
+ */
95
+ waitingSince?: RunTime | null;
96
+ /**
97
+ * Input and output tokens as `[in, out]`, or the total as
98
+ * one number.
99
+ */
100
+ tokens?: RunTokens | null;
101
+ /**
102
+ * The most tokens the run may use. With a budget the
103
+ * tokens are a meter, read in compact figures ("22.8K of 60K tokens"), that turns to the warning
104
+ * tone from 80% and to the danger tone at 100%. Without one they stay text.
105
+ */
106
+ tokenBudget?: number | null;
107
+ /**
108
+ * What the run has cost, against its budget.
109
+ */
110
+ cost?: RunCost | null;
111
+ /**
112
+ * The model the agent runs on.
113
+ */
114
+ model?: string | null;
115
+ /**
116
+ * Buttons under the summary.
117
+ */
118
+ actions?: RunStatusAction[];
119
+ /**
120
+ * While the state is `running`, the working time counts on
121
+ * once a second from `workMs` and the moment of the last `update()`. One interval, which sleeps
122
+ * while the page is hidden.
123
+ */
124
+ ticking?: boolean;
125
+ /**
126
+ * Draws only the state: `true` as a pill of glyph and
127
+ * word for a narrow header, `'icon'` as the glyph alone, its word visually hidden but still the
128
+ * accessible text, and shown as the pill's tooltip.
129
+ */
130
+ compact?: boolean | 'icon';
131
+ /**
132
+ * The clock: what decides whether a time is today (a
133
+ * time on another day shows its date too) and what the working time counts against while
134
+ * `ticking`. Null is real time. Fixed at construction.
135
+ */
136
+ now?: (() => Date) | null;
137
+ /**
138
+ * BCP 47 tag for numbers and amounts; defaults to the active language.
139
+ */
140
+ locale?: string;
141
+ /**
142
+ * Localized
143
+ * messages: the state words (`agent.status.*`) and the `runStatus.*` labels.
144
+ */
145
+ msg?: Record<string, string> | Record<string, Record<string, string>>;
146
+ /**
147
+ * Action listener.
148
+ */
149
+ onaction?: (event: CustomEvent<{
150
+ index: number;
151
+ action: RunStatusAction;
152
+ }>) => void;
153
+ };
154
+ export type RunStatusState = {
155
+ state: RunState;
156
+ summary: string;
157
+ steps: RunSteps | null;
158
+ started: RunTime | null;
159
+ finished: RunTime | null;
160
+ workMs: number | null;
161
+ waitingSince: RunTime | null;
162
+ tokens: RunTokens | null;
163
+ tokenBudget: number | null;
164
+ cost: RunCost | null;
165
+ model: string | null;
166
+ actions: RunStatusAction[];
167
+ };
168
+ /**
169
+ * Where an agent's run stands: its state in a glyph and a word, a sentence on what is happening,
170
+ * its steps as a progressbar, when it started and how long the agent has worked, what it has cost
171
+ * against its budget, and the buttons for what the reader can do about it now. `compact` draws the
172
+ * state alone, for a header.
173
+ *
174
+ * It announces nothing itself: the conversation the run belongs to says when it starts, waits,
175
+ * fails, or finishes.
176
+ *
177
+ * @fires RunStatus#action
178
+ * @extends {Component<RunStatusOptions>}
179
+ */
180
+ export declare class RunStatus extends Component<RunStatusOptions> {
181
+ _original: import("../../core/dom.js").TargetSnapshot;
182
+ /** @type {Record<string, any>} */
183
+ _values: Record<string, any>;
184
+ _workBase: number;
185
+ _workAt: number;
186
+ /** @type {HTMLElement|null} */
187
+ _elapsed: HTMLElement | null;
188
+ /** @type {HTMLElement|null} The action row as drawn, kept across updates that leave it unchanged. */
189
+ _actionsEl: HTMLElement | null;
190
+ _actionsKey: string;
191
+ /** Whether the root took `tabindex="-1"` to hold focus that had nowhere else to go. */
192
+ _heldFocus: boolean;
193
+ /** @type {ReturnType<typeof setInterval>|0} */
194
+ _interval: ReturnType<typeof setInterval> | 0;
195
+ _destroyed: boolean;
196
+ static cssName: string;
197
+ /** @type {Readonly<RunStatusOptions>} */
198
+ static defaults: Readonly<RunStatusOptions>;
199
+ /** @returns {HTMLElement} */
200
+ render(): HTMLElement;
201
+ /**
202
+ * Merges new values and redraws. The working time carries on from where it stood unless the
203
+ * update brings a new `workMs`. Focus inside the panel stays where it was: an action row that
204
+ * did not change is kept as it is, and otherwise focus moves to the action at the same index (or
205
+ * the nearest one left), or to the panel itself when no action is left.
206
+ * @param {Partial<Omit<RunStatusOptions, 'locale'|'msg'|'onaction'|'now'>>} values
207
+ * @returns {this}
208
+ */
209
+ update(values?: Partial<Omit<RunStatusOptions, 'locale' | 'msg' | 'onaction' | 'now'>>): this;
210
+ /** @returns {RunStatusState} The run's values as they stand, as copies. */
211
+ getState(): RunStatusState;
212
+ /** Stops the clock, removes what the component drew, and restores an enhanced target. @returns {void} */
213
+ destroy(): void;
214
+ /** @private @returns {number} Milliseconds on the clock the working time counts against. */
215
+ private _clock;
216
+ /** @private @returns {number|null} Milliseconds worked, including the time counted since the last update. */
217
+ private _workTime;
218
+ /** @private @returns {void} */
219
+ private _draw;
220
+ /**
221
+ * Puts the drawn parts in the root in order. A part kept from the last draw stays where it is
222
+ * rather than being taken out and put back, so focus inside it survives.
223
+ * @private
224
+ * @param {Array<Node|null>} parts
225
+ * @returns {void}
226
+ */
227
+ private _place;
228
+ /**
229
+ * The action row: the one already drawn when the actions read the same, a new one otherwise.
230
+ * @private
231
+ * @returns {HTMLElement|null}
232
+ */
233
+ private _actions;
234
+ /**
235
+ * Where focus is inside the panel, in terms that survive a redraw: the index of an action, or
236
+ * of a focusable element among all of them.
237
+ * @private
238
+ * @returns {{action: number}|{focusable: number}|null} Null when focus is elsewhere, or on the root.
239
+ */
240
+ private _focusKey;
241
+ /**
242
+ * Puts focus back after a redraw when the element that had it is gone: on the action at the same
243
+ * index or the nearest one left, else on the focusable at the same index, else on the root.
244
+ * @private
245
+ * @param {{action: number}|{focusable: number}|null} key What `_focusKey()` returned before the draw.
246
+ * @returns {void}
247
+ */
248
+ private _restoreFocus;
249
+ /** @private Gives back the `tabindex` the root took to hold focus. @returns {void} */
250
+ private _releaseFocus;
251
+ /** @private @param {RunState} state @returns {Node[]} The state's glyph and its word. */
252
+ private _stateParts;
253
+ /** @private @param {{done: number, total: number, percent: number}} steps @returns {HTMLElement} */
254
+ private _steps;
255
+ /**
256
+ * The property rows that apply to the state: started, working time, waiting or blocked since,
257
+ * or finished, then model, tokens, and cost.
258
+ * @private
259
+ * @param {RunState} state
260
+ * @returns {Array<[string, Node|string|Array<Node>]>}
261
+ */
262
+ private _rows;
263
+ /** @private @param {unknown} value @returns {HTMLElement|null} A `<time>` with the clock time, and the date when it is not today. */
264
+ private _time;
265
+ /** @private @param {unknown} cost @returns {Node[]|null} The cost, and a meter against the budget when there is one. */
266
+ private _cost;
267
+ /**
268
+ * A thin `role="meter"` bar of a value against its limit, toned by how close it is.
269
+ * @private
270
+ * @param {string} label
271
+ * @param {number} value
272
+ * @param {number} limit
273
+ * @param {string} text The value in words, its `aria-valuetext`.
274
+ * @returns {HTMLElement}
275
+ */
276
+ private _meter;
277
+ /** @private @returns {boolean} Whether the working time should count on screen now. */
278
+ private _shouldTick;
279
+ /** @private @returns {void} */
280
+ private _syncTicker;
281
+ /** @private @returns {void} */
282
+ private _stopTicker;
283
+ /** @private @returns {void} */
284
+ private _tick;
285
+ /** @private @param {MouseEvent} event @returns {void} */
286
+ private _onClick;
287
+ }
288
+ /**
289
+ * How close a run's cost is to its budget: `'warning'` from 80%, `'danger'` at 100% and over,
290
+ * `'normal'` below, and without a budget.
291
+ * @param {number} amount
292
+ * @param {number|null|undefined} budget
293
+ * @returns {'normal'|'warning'|'danger'}
294
+ */
295
+ export declare function costLevel(amount: number, budget: number | null | undefined): 'normal' | 'warning' | 'danger';
296
+ /**
297
+ * Reads a steps count: whole numbers, the done count kept within the total. Null for no steps.
298
+ * @param {unknown} steps `{done, total}`.
299
+ * @returns {{done: number, total: number, percent: number}|null}
300
+ */
301
+ export declare function stepProgress(steps: unknown): {
302
+ done: number;
303
+ total: number;
304
+ percent: number;
305
+ } | null;
306
+ /**
307
+ * Token counts in words: "18,420 in · 1,236 out" for a pair, "22,840" for a total. Empty without
308
+ * counts.
309
+ * @param {unknown} tokens `[input, output]`, or the total as one number.
310
+ * @param {{locale?: string, template?: string}} [options={}] `template` takes the two formatted
311
+ * counts of a pair as `%1` and `%2`.
312
+ * @returns {string}
313
+ */
314
+ export declare function formatTokens(tokens: unknown, options?: {
315
+ locale?: string;
316
+ template?: string;
317
+ }): string;
318
+ /**
319
+ * How many tokens a run has used in all: the number itself, or input and output added up.
320
+ * @param {unknown} tokens `[input, output]`, or the total as one number.
321
+ * @returns {number|null} Null without counts.
322
+ */
323
+ export declare function tokenTotal(tokens: unknown): number | null;
324
+ /**
325
+ * A count in the locale's compact notation (`Intl.NumberFormat` with `notation: 'compact'`) and at
326
+ * most one decimal: "22.8K", "60K", "1.2M" in English, "22.840" in German, which has no compact
327
+ * form for thousands.
328
+ * @param {number} value
329
+ * @param {{locale?: string}} [options={}]
330
+ * @returns {string} Empty for anything that is not a finite number.
331
+ */
332
+ export declare function formatCompactNumber(value: number, options?: {
333
+ locale?: string;
334
+ }): string;
335
+ /**
336
+ * The tokens as a meter against their budget: the total, the budget, the level (`warning` from
337
+ * 80%, `danger` at 100%, as for the cost), and the words "22.8K of 60K tokens". Null without
338
+ * counts or without a budget above zero, when the tokens stay text.
339
+ * @param {unknown} tokens `[input, output]`, or the total as one number.
340
+ * @param {unknown} budget The most tokens the run may use.
341
+ * @param {{locale?: string, template?: string}} [options={}] `template` takes the compact total and
342
+ * budget as `%1` and `%2`.
343
+ * @returns {RunTokenMeter|null}
344
+ */
345
+ export declare function tokenMeter(tokens: unknown, budget: unknown, options?: {
346
+ locale?: string;
347
+ template?: string;
348
+ }): RunTokenMeter | null;
349
+ /**
350
+ * Reads the `compact` option: `'icon'` for the glyph alone, `'word'` for any other truthy value
351
+ * (the pill of glyph and word), null for the full panel.
352
+ * @param {unknown} value
353
+ * @returns {RunCompactMode|null}
354
+ */
355
+ export declare function compactMode(value: unknown): RunCompactMode | null;
356
+ /**
357
+ * The message keys of the time rows a state shows besides "Started": the "since" row while the
358
+ * run is held (`waiting`: "Waiting since", `blocked`: "Blocked since"), and the "finished" row
359
+ * once it is over ("Finished", "Failed at", "Stopped at"). A blocked run is not over, so it never
360
+ * shows a finished row.
361
+ * @param {unknown} state
362
+ * @returns {{since: string|null, finished: string|null}}
363
+ */
364
+ export declare function runTimeKeys(state: unknown): {
365
+ since: string | null;
366
+ finished: string | null;
367
+ };
368
+ /**
369
+ * Reads the `now` option: the date its function returns (a `Date` or a millisecond timestamp),
370
+ * or the real time when there is no function or it returns nothing usable.
371
+ * @param {unknown} now
372
+ * @returns {Date}
373
+ */
374
+ export declare function currentTime(now: unknown): Date;
375
+ /**
376
+ * A run's cost in words: "€0.14 of €2.00" against a budget, "€0.14" without one. Empty without a
377
+ * cost.
378
+ * @param {unknown} cost `{amount, budget?, currency?}`.
379
+ * @param {{locale?: string, template?: string}} [options={}] `template` takes the amount and the
380
+ * budget as `%1` and `%2`.
381
+ * @returns {string}
382
+ */
383
+ export declare function formatRunCost(cost: unknown, options?: {
384
+ locale?: string;
385
+ template?: string;
386
+ }): string;
387
+ /**
388
+ * Reads a run time: a `Date`, or a local ISO date-time string (`2026-09-29T11:20:04`; a bare date
389
+ * is midnight local time). Null for anything else.
390
+ * @param {unknown} value
391
+ * @returns {Date|null}
392
+ */
393
+ export declare function runDate(value: unknown): Date | null;