@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.
- package/CHANGELOG.md +210 -0
- package/README.md +73 -7
- package/bin/zx-css.js +328 -0
- package/dist/types/components/account-menu/account-menu.d.ts +4 -2
- package/dist/types/components/activity-list/activity-list.d.ts +14 -8
- package/dist/types/components/agent-thread/ag-ui.d.ts +340 -0
- package/dist/types/components/agent-thread/agent-thread.d.ts +711 -0
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +401 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +14 -8
- package/dist/types/components/approval-card/approval-card.d.ts +596 -0
- package/dist/types/components/avatar/avatar.d.ts +91 -4
- package/dist/types/components/block-view/block-view.d.ts +205 -0
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +3 -3
- package/dist/types/components/calendar/calendar-model.d.ts +9 -2
- package/dist/types/components/calendar/calendar.d.ts +12 -4
- package/dist/types/components/chart/chart.d.ts +25 -13
- package/dist/types/components/code-editor/code-editor.d.ts +7 -2
- package/dist/types/components/composer/composer.d.ts +938 -0
- package/dist/types/components/composer/queue.d.ts +76 -0
- package/dist/types/components/copy/copy-button.d.ts +6 -4
- package/dist/types/components/copy/copy-input.d.ts +10 -6
- package/dist/types/components/datebox/date-range-box.d.ts +33 -0
- package/dist/types/components/datebox/placeholder.d.ts +7 -0
- package/dist/types/components/dock/dock.d.ts +12 -3
- package/dist/types/components/entity-ref/entity-ref.d.ts +5 -3
- package/dist/types/components/field-upload/field-upload.d.ts +3 -2
- package/dist/types/components/file-item/file-item.d.ts +3 -2
- package/dist/types/components/file-list/file-list.d.ts +14 -8
- package/dist/types/components/filter/filter-model.d.ts +31 -1
- package/dist/types/components/filter/filter.d.ts +20 -2
- package/dist/types/components/finder/finder.d.ts +14 -6
- package/dist/types/components/flag/flag.d.ts +99 -0
- package/dist/types/components/grid/grid.d.ts +1 -1
- package/dist/types/components/kanban-view/kanban-view.d.ts +8 -66
- package/dist/types/components/launcher/launcher.d.ts +2 -0
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
- package/dist/types/components/number-field/number-field.d.ts +17 -6
- package/dist/types/components/prompt-starters/prompt-starters.d.ts +107 -0
- package/dist/types/components/prose/prose.d.ts +9 -6
- package/dist/types/components/questionnaire/conditions.d.ts +270 -0
- package/dist/types/components/questionnaire/items.d.ts +52 -30
- package/dist/types/components/questionnaire/questionnaire.d.ts +44 -4
- package/dist/types/components/rating/rating.d.ts +5 -3
- package/dist/types/components/run-status/run-status.d.ts +393 -0
- package/dist/types/components/run-trace/run-trace.d.ts +624 -0
- package/dist/types/components/select/country.d.ts +106 -0
- package/dist/types/components/select/field-adapter.d.ts +2 -1
- package/dist/types/components/select/locale.d.ts +102 -0
- package/dist/types/components/select/select.d.ts +41 -2
- package/dist/types/components/slider/slider.d.ts +1 -0
- package/dist/types/components/sort-control/sort-control.d.ts +7 -3
- package/dist/types/components/source-list/source-list.d.ts +179 -0
- package/dist/types/components/split-view/split-view.d.ts +5 -3
- package/dist/types/components/surface/catalog.d.ts +260 -0
- package/dist/types/components/surface/elicit.d.ts +81 -0
- package/dist/types/components/surface/mcp.d.ts +165 -0
- package/dist/types/components/surface/schema.d.ts +314 -0
- package/dist/types/components/surface/stream.d.ts +118 -0
- package/dist/types/components/surface/surface.d.ts +718 -0
- package/dist/types/components/surface/text.d.ts +277 -0
- package/dist/types/components/surface/validate.d.ts +339 -0
- package/dist/types/components/table/table.d.ts +55 -3
- package/dist/types/components/table/window.d.ts +203 -0
- package/dist/types/components/toolbar/toolbar.d.ts +10 -6
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/tree/tree.d.ts +20 -13
- package/dist/types/core/component.d.ts +10 -0
- package/dist/types/core/date.d.ts +8 -1
- package/dist/types/core/dom.d.ts +1 -0
- package/dist/types/core/http.d.ts +10 -0
- package/dist/types/core/i18n.d.ts +38 -0
- package/dist/types/core/messages.d.ts +479 -1
- package/dist/types/core/storage.d.ts +7 -2
- package/dist/types/elements/define.d.ts +21 -46
- package/dist/types/elements/definitions.d.ts +147 -0
- package/dist/types/elements/kit.d.ts +7 -0
- package/dist/types/elements/reflect.d.ts +6 -3
- package/dist/types/index.d.ts +18 -1
- package/dist/types/internal/agent-model.d.ts +587 -0
- package/dist/types/internal/date-locale.d.ts +7 -0
- package/dist/types/internal/highlight.d.ts +24 -0
- package/dist/types/internal/json-patch.d.ts +146 -0
- package/dist/types/internal/presence-loop.d.ts +148 -0
- package/dist/types/locales/de.d.ts +13 -0
- package/dist/types/locales/en.d.ts +2 -0
- package/dist/types/locales/index.d.ts +823 -0
- package/dist/types/zeyos/view.d.ts +8 -1
- package/dist/zx-zeyos.esm.js +20505 -18748
- package/dist/zx-zeyos.esm.min.js +5 -5
- package/dist/zx.core.css +1276 -0
- package/dist/zx.core.min.css +1 -0
- package/dist/zx.css +2424 -134
- package/dist/zx.esm.js +46167 -28468
- package/dist/zx.esm.min.js +40 -8
- package/dist/zx.global.js +46167 -28468
- package/dist/zx.global.min.js +40 -8
- package/dist/zx.layered.css +17302 -0
- package/dist/zx.layered.min.css +1 -0
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +12501 -0
- package/docs/agent-surfaces.md +340 -0
- package/docs/api.json +2057 -166
- package/docs/llms.md +1458 -58
- package/docs/llms.txt +38 -8
- package/package.json +29 -6
- package/src/components/account-menu/account-menu.js +6 -3
- package/src/components/activity-item/activity-item.js +2 -1
- package/src/components/activity-list/activity-list.js +16 -10
- package/src/components/agent-thread/ag-ui.js +1439 -0
- package/src/components/agent-thread/agent-thread.css +417 -0
- package/src/components/agent-thread/agent-thread.js +1670 -0
- package/src/components/agent-thread/ui-message-stream.js +1281 -0
- package/src/components/app-sidebar/app-sidebar.js +18 -8
- package/src/components/approval-card/approval-card.css +289 -0
- package/src/components/approval-card/approval-card.js +1378 -0
- package/src/components/avatar/avatar.css +56 -1
- package/src/components/avatar/avatar.js +148 -26
- package/src/components/block-view/block-view.css +300 -0
- package/src/components/block-view/block-view.js +524 -0
- package/src/components/breadcrumb/breadcrumb.js +8 -5
- package/src/components/calendar/calendar-model.js +8 -2
- package/src/components/calendar/calendar.js +53 -18
- package/src/components/chart/chart.js +54 -23
- package/src/components/code-editor/code-editor.js +45 -8
- package/src/components/code-editor/field-adapter.js +1 -1
- package/src/components/composer/composer.css +482 -0
- package/src/components/composer/composer.js +1815 -0
- package/src/components/composer/queue.js +78 -0
- package/src/components/context-menu/context-menu.js +12 -1
- package/src/components/copy/copy-button.js +9 -7
- package/src/components/copy/copy-input.js +10 -6
- package/src/components/date-picker/date-picker.js +2 -1
- package/src/components/date-picker/date-range-picker.js +8 -7
- package/src/components/datebox/date-range-box.js +3 -9
- package/src/components/datebox/datebox.js +18 -21
- package/src/components/datebox/placeholder.js +18 -0
- package/src/components/dialog/dialog.js +1 -1
- package/src/components/dock/dock.js +34 -13
- package/src/components/entity-ref/entity-ref.js +16 -5
- package/src/components/field-upload/field-upload.js +81 -38
- package/src/components/file-item/file-item.js +70 -40
- package/src/components/file-list/file-list.js +15 -9
- package/src/components/filter/filter-model.js +46 -8
- package/src/components/filter/filter.css +3 -3
- package/src/components/filter/filter.js +29 -10
- package/src/components/filter-panel/filter-panel.js +13 -5
- package/src/components/finder/finder.js +50 -26
- package/src/components/flag/flag.css +40 -0
- package/src/components/flag/flag.js +177 -0
- package/src/components/form/form.js +1 -1
- package/src/components/grid/grid.js +22 -8
- package/src/components/kanban-view/kanban-view.js +51 -81
- package/src/components/launcher/launcher.js +17 -2
- package/src/components/list-toolbar/list-toolbar.js +2 -1
- package/src/components/master-panel/master-panel.js +1 -1
- package/src/components/menu-button/menu-button.js +4 -0
- package/src/components/message/message.js +3 -0
- package/src/components/multi-value-editor/multi-value-editor.js +10 -9
- package/src/components/navigation-bar/navigation-bar.js +3 -3
- package/src/components/number-field/number-field.js +29 -13
- package/src/components/prompt-starters/prompt-starters.css +91 -0
- package/src/components/prompt-starters/prompt-starters.js +206 -0
- package/src/components/prose/prose.js +14 -10
- package/src/components/questionnaire/conditions.js +666 -0
- package/src/components/questionnaire/items.js +150 -41
- package/src/components/questionnaire/questionnaire.js +126 -32
- package/src/components/rating/rating.js +5 -4
- package/src/components/run-status/run-status.css +208 -0
- package/src/components/run-status/run-status.js +782 -0
- package/src/components/run-trace/run-trace.css +443 -0
- package/src/components/run-trace/run-trace.js +1209 -0
- package/src/components/select/country.js +136 -0
- package/src/components/select/field-adapter.js +7 -2
- package/src/components/select/locale.js +219 -0
- package/src/components/select/select.css +20 -22
- package/src/components/select/select.js +94 -12
- package/src/components/sheet/sheet-stack.js +10 -1
- package/src/components/slider/slider.js +7 -2
- package/src/components/sort-control/sort-control.js +15 -5
- package/src/components/source-list/source-list.css +208 -0
- package/src/components/source-list/source-list.js +358 -0
- package/src/components/split-view/split-view.js +5 -3
- package/src/components/surface/catalog.js +1334 -0
- package/src/components/surface/elicit.js +107 -0
- package/src/components/surface/mcp.js +243 -0
- package/src/components/surface/schema.js +644 -0
- package/src/components/surface/stream.js +245 -0
- package/src/components/surface/surface.css +308 -0
- package/src/components/surface/surface.js +2291 -0
- package/src/components/surface/text.js +513 -0
- package/src/components/surface/validate.js +2218 -0
- package/src/components/tabbox/tabbox.js +9 -0
- package/src/components/table/table.css +63 -3
- package/src/components/table/table.js +167 -28
- package/src/components/table/window.js +317 -0
- package/src/components/toolbar/toolbar.js +12 -7
- package/src/components/tooltip/tooltip.css +2 -3
- package/src/components/tooltip/tooltip.js +32 -5
- package/src/components/tree/tree.js +53 -23
- package/src/core/component.js +25 -1
- package/src/core/date.js +62 -16
- package/src/core/dom.js +22 -2
- package/src/core/format.js +15 -13
- package/src/core/http.js +29 -20
- package/src/core/i18n.js +83 -10
- package/src/core/keyboard.js +79 -8
- package/src/core/messages.js +519 -2
- package/src/core/overlay-host.js +1 -0
- package/src/core/storage.js +59 -6
- package/src/elements/define.js +178 -130
- package/src/elements/definitions.js +229 -0
- package/src/elements/kit.js +444 -0
- package/src/elements/reflect.js +8 -3
- package/src/index.js +18 -1
- package/src/internal/agent-model.js +488 -0
- package/src/internal/date-locale.js +11 -0
- package/src/internal/highlight.js +104 -0
- package/src/internal/json-patch.js +405 -0
- package/src/internal/presence-loop.js +343 -0
- package/src/locales/de.js +911 -0
- package/src/locales/en.js +2 -0
- package/src/locales/index.js +7 -0
- package/src/zeyos/calendar.js +2 -1
- package/src/zeyos/form.js +2 -1
- package/src/zeyos/launcher.js +7 -6
- package/src/zeyos/module-bar.js +2 -1
- package/src/zeyos/schema.js +37 -23
- package/src/zeyos/select.js +4 -3
- package/src/zeyos/table.js +2 -13
- package/src/zeyos/view.js +57 -17
- package/styles/core.css +11 -0
- package/styles/tokens/semantic.css +1 -0
- package/styles/zeyos.css +2 -0
- package/styles/zx.css +11 -8
- package/styles/zx.layered.css +1 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
1
|
+
import { isEmptyAnswer } from './conditions.js';
|
|
2
|
+
export { isEmptyAnswer };
|
|
3
|
+
export type Condition = import('./conditions.js').Condition;
|
|
4
|
+
export type NextTarget = import('./conditions.js').NextTarget;
|
|
5
|
+
export type ValidationRule = import('./conditions.js').ValidationRule;
|
|
7
6
|
export type QuestionnaireChoice = {
|
|
8
7
|
/**
|
|
9
8
|
* Answer value, unique within its item.
|
|
@@ -95,17 +94,24 @@ export type QuestionnaireItem = {
|
|
|
95
94
|
*/
|
|
96
95
|
field?: any | null;
|
|
97
96
|
/**
|
|
98
|
-
* Visibility
|
|
97
|
+
* Visibility:
|
|
98
|
+
* a declarative condition, or a predicate. Either sees only the answers of visible items declared
|
|
99
|
+
* before this one, and a declarative condition may only name those items. Anything else, such as
|
|
100
|
+
* `false` or `{}`, reads as absent.
|
|
99
101
|
*/
|
|
100
|
-
when?: ((answers: Record<string, unknown>) => boolean) | null;
|
|
102
|
+
when?: Condition | ((answers: Record<string, unknown>) => boolean) | null;
|
|
101
103
|
/**
|
|
102
|
-
* Branch target: an item name,
|
|
104
|
+
* Branch target: an item name, `$review`, `$submit`, a list of `{if, goto}` branches whose first
|
|
105
|
+
* match wins, or a function returning a name. A branch condition may name this item and the
|
|
106
|
+
* items declared before it. An item named `$review` or `$submit` takes the name's place; anything
|
|
107
|
+
* else, such as `false` or `[]`, reads as absent.
|
|
103
108
|
*/
|
|
104
|
-
next?:
|
|
109
|
+
next?: NextTarget | ((answer: unknown, answers: Record<string, unknown>) => string | null) | null;
|
|
105
110
|
/**
|
|
106
|
-
* Extra validation
|
|
111
|
+
* Extra validation: a list of declarative rules, or a function returning an error message, or
|
|
112
|
+
* null when the answer is acceptable. Anything else, such as `false` or `[]`, reads as absent.
|
|
107
113
|
*/
|
|
108
|
-
validate?: ((answer: unknown, answers: Record<string, unknown>) => string | null | Promise<string | null>) | null;
|
|
114
|
+
validate?: ValidationRule[] | ((answer: unknown, answers: Record<string, unknown>) => string | null | Promise<string | null>) | null;
|
|
109
115
|
};
|
|
110
116
|
export type NormalizedItem = {
|
|
111
117
|
/**
|
|
@@ -149,17 +155,18 @@ export type NormalizedItem = {
|
|
|
149
155
|
*/
|
|
150
156
|
field: any | null;
|
|
151
157
|
/**
|
|
152
|
-
* Visibility
|
|
158
|
+
* Visibility
|
|
159
|
+
* condition or predicate.
|
|
153
160
|
*/
|
|
154
|
-
when: ((answers: Record<string, unknown>) => boolean) | null;
|
|
161
|
+
when: Condition | ((answers: Record<string, unknown>) => boolean) | null;
|
|
155
162
|
/**
|
|
156
163
|
* Branch target.
|
|
157
164
|
*/
|
|
158
|
-
next:
|
|
165
|
+
next: NextTarget | ((answer: unknown, answers: Record<string, unknown>) => string | null) | null;
|
|
159
166
|
/**
|
|
160
|
-
*
|
|
167
|
+
* Extra validation.
|
|
161
168
|
*/
|
|
162
|
-
validate: ((answer: unknown, answers: Record<string, unknown>) => string | null | Promise<string | null>) | null;
|
|
169
|
+
validate: ValidationRule[] | ((answer: unknown, answers: Record<string, unknown>) => string | null | Promise<string | null>) | null;
|
|
163
170
|
};
|
|
164
171
|
export type NormalizedChoice = {
|
|
165
172
|
/**
|
|
@@ -226,12 +233,23 @@ export type QuestionnaireProgress = {
|
|
|
226
233
|
section: string;
|
|
227
234
|
};
|
|
228
235
|
/**
|
|
229
|
-
* Normalizes and validates a list of item definitions. Never mutates its input
|
|
236
|
+
* Normalizes and validates a list of item definitions. Never mutates its input; declarative
|
|
237
|
+
* `when`, `next` and `validate` forms are copied.
|
|
230
238
|
* @param {QuestionnaireItem[]} list Item definitions.
|
|
231
239
|
* @returns {NormalizedItem[]}
|
|
232
|
-
* @throws {TypeError} When the list, an item, or a name is malformed,
|
|
240
|
+
* @throws {TypeError} When the list, an item, or a name is malformed, a name repeats, or a
|
|
241
|
+
* declarative condition, branch list or rule list is malformed — including a condition naming
|
|
242
|
+
* an item that is not declared before it. A `when`, `next` or `validate` that is neither
|
|
243
|
+
* declarative nor a function does not throw: it reads as absent.
|
|
233
244
|
*/
|
|
234
245
|
export declare function normalizeItems(list: QuestionnaireItem[]): NormalizedItem[];
|
|
246
|
+
/**
|
|
247
|
+
* {@link normalizeItems} with the messages of a component.
|
|
248
|
+
* @param {QuestionnaireItem[]} list Item definitions.
|
|
249
|
+
* @param {(key: string) => string} text Resolves the default label of a free-form input.
|
|
250
|
+
* @returns {NormalizedItem[]}
|
|
251
|
+
*/
|
|
252
|
+
export declare function normalizeItemList(list: QuestionnaireItem[], text: (key: string) => string): NormalizedItem[];
|
|
235
253
|
/**
|
|
236
254
|
* Normalizes an item's choices and hands out the shortcut keys. Explicit keys are reserved before
|
|
237
255
|
* any are assigned, so adding one to the third choice never renumbers the others.
|
|
@@ -242,9 +260,9 @@ export declare function normalizeItems(list: QuestionnaireItem[]): NormalizedIte
|
|
|
242
260
|
*/
|
|
243
261
|
export declare function normalizeChoices(list: QuestionnaireChoice[], itemName?: string): NormalizedChoice[];
|
|
244
262
|
/**
|
|
245
|
-
* Reports whether an item's `when` predicate passes for a given set of answers. An
|
|
246
|
-
* one is always visible, and a
|
|
247
|
-
* strand the reader mid-questionnaire.
|
|
263
|
+
* Reports whether an item's `when` condition or predicate passes for a given set of answers. An
|
|
264
|
+
* item without one is always visible, and a condition that throws hides nothing — a broken
|
|
265
|
+
* condition must not strand the reader mid-questionnaire.
|
|
248
266
|
* @param {NormalizedItem} item Item to test.
|
|
249
267
|
* @param {Record<string, unknown>} answers Answers visible to the predicate.
|
|
250
268
|
* @returns {boolean}
|
|
@@ -275,23 +293,27 @@ export declare function visibleItems(items: NormalizedItem[], raw: Record<string
|
|
|
275
293
|
/**
|
|
276
294
|
* Resolves which item follows the given one.
|
|
277
295
|
*
|
|
278
|
-
* A `next` of `null
|
|
279
|
-
*
|
|
280
|
-
*
|
|
296
|
+
* A `next` of `null`, or a branch list where nothing matches, falls through to the next visible
|
|
297
|
+
* item in declaration order. A string, a matching branch, or a function returning a string names a
|
|
298
|
+
* target: when that target is currently hidden the walk continues forward from it rather than
|
|
299
|
+
* stranding the reader on an invisible question. `$review` and `$submit` are returned as they are,
|
|
300
|
+
* for the caller to open the review screen or submit, unless an item bears that name.
|
|
281
301
|
* @param {NormalizedItem[]} items All items.
|
|
282
302
|
* @param {NormalizedItem} item Item being left.
|
|
283
303
|
* @param {Record<string, unknown>} raw Every answer given.
|
|
284
|
-
* @returns {string|null} Name of the next item, or null at the end of the
|
|
304
|
+
* @returns {string|null} Name of the next item, `$review`, `$submit`, or null at the end of the
|
|
305
|
+
* questionnaire.
|
|
285
306
|
* @throws {RangeError} When `next` names an item that does not exist.
|
|
286
307
|
*/
|
|
287
308
|
export declare function resolveNext(items: NormalizedItem[], item: NormalizedItem, raw: Record<string, unknown>): string | null;
|
|
288
309
|
/**
|
|
289
|
-
* Reports whether
|
|
290
|
-
*
|
|
291
|
-
* @param {
|
|
310
|
+
* Reports whether a resolved target ends the walk rather than naming an item: `$review` or
|
|
311
|
+
* `$submit`, unless an item bears that name, which then goes first.
|
|
312
|
+
* @param {NormalizedItem[]} items All items.
|
|
313
|
+
* @param {string|null} target What `resolveNext()` returned.
|
|
292
314
|
* @returns {boolean}
|
|
293
315
|
*/
|
|
294
|
-
export declare function
|
|
316
|
+
export declare function endsFlow(items: NormalizedItem[], target: string | null): boolean;
|
|
295
317
|
/**
|
|
296
318
|
* Runs the synchronous part of validation: the required check. An item's own `validate` may be
|
|
297
319
|
* asynchronous and is awaited by the component instead.
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { Component } from '../../core/component.js';
|
|
2
2
|
import { Field } from '../field/field.js';
|
|
3
3
|
import { ProgressBar } from '../loading/progress-bar.js';
|
|
4
|
+
/**
|
|
5
|
+
* The message key of each declarative rule's default text, as `checkRules()` names the rule.
|
|
6
|
+
* `required` is absent: an item words it itself (`questionnaire.required`,
|
|
7
|
+
* `questionnaire.requiredInput`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const RULE_MESSAGE_KEYS: Readonly<{
|
|
10
|
+
minLength: "questionnaire.rule.minLength";
|
|
11
|
+
maxLength: "questionnaire.rule.maxLength";
|
|
12
|
+
minItems: "questionnaire.rule.minItems";
|
|
13
|
+
maxItems: "questionnaire.rule.maxItems";
|
|
14
|
+
minimum: "questionnaire.rule.minimum";
|
|
15
|
+
maximum: "questionnaire.rule.maximum";
|
|
16
|
+
oneOf: "questionnaire.rule.oneOf";
|
|
17
|
+
date: "questionnaire.rule.date";
|
|
18
|
+
'date-time': "questionnaire.rule.dateTime";
|
|
19
|
+
time: "questionnaire.rule.time";
|
|
20
|
+
email: "questionnaire.rule.email";
|
|
21
|
+
uri: "questionnaire.rule.uri";
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* A rule's default message through a component's `msg()`: its catalogue key when it has one, the
|
|
25
|
+
* English of `ruleMessage()` otherwise.
|
|
26
|
+
* @param {(key: string, ...args: unknown[]) => string} msg The component's message lookup.
|
|
27
|
+
* @param {string} key The rule key `checkRules()` reports.
|
|
28
|
+
* @param {...unknown} args Its interpolation values.
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export declare function ruleText(msg: (key: string, ...args: unknown[]) => string, key: string, ...args: unknown[]): string;
|
|
4
32
|
export type QuestionnaireItem = import('./items.js').QuestionnaireItem;
|
|
5
33
|
export type QuestionnaireChoice = import('./items.js').QuestionnaireChoice;
|
|
6
34
|
export type NormalizedItem = import('./items.js').NormalizedItem;
|
|
@@ -121,14 +149,18 @@ export type QuestionnaireCompleteDetail = {
|
|
|
121
149
|
* persistence and transport.
|
|
122
150
|
*
|
|
123
151
|
* Three things separate it from a `Form` with one `Fieldset` per question. It **branches**: an item
|
|
124
|
-
* carries a `when`
|
|
152
|
+
* carries a `when` condition and a `next` target, conditions cascade, and Back retraces the path
|
|
125
153
|
* actually walked rather than an array index. Its answer control is **any registered Zx `Field`
|
|
126
154
|
* type**, so a question can ask for a date, a number, a rating or an upload instead of a choice.
|
|
127
155
|
* And its `validate` may be asynchronous, which is what lets a question be gated on a server check.
|
|
128
156
|
*
|
|
129
|
-
*
|
|
130
|
-
* so
|
|
131
|
-
*
|
|
157
|
+
* `when`, `next` and `validate` each take a function or the same logic written as plain JSON (see
|
|
158
|
+
* `conditions.js`), so a whole questionnaire can be stored, sent, or composed by an agent.
|
|
159
|
+
*
|
|
160
|
+
* A created root is a real `<form>`; an enhanced non-form target contains one. Choices are native
|
|
161
|
+
* radios and checkboxes carrying the item name,
|
|
162
|
+
* and arrow-key navigation inside a choice group is the browser's. Form data includes every
|
|
163
|
+
* applicable answer, including answers from earlier steps.
|
|
132
164
|
*
|
|
133
165
|
* @fires Questionnaire#change
|
|
134
166
|
* @fires Questionnaire#navigate
|
|
@@ -156,6 +188,7 @@ export declare class Questionnaire extends Component<QuestionnaireOptions> {
|
|
|
156
188
|
_status: QuestionnaireStatus;
|
|
157
189
|
_returnToReview: any;
|
|
158
190
|
_busy: boolean;
|
|
191
|
+
_revision: number;
|
|
159
192
|
_error: string;
|
|
160
193
|
_advanceTimer: number;
|
|
161
194
|
_uid: string;
|
|
@@ -232,6 +265,8 @@ export declare class Questionnaire extends Component<QuestionnaireOptions> {
|
|
|
232
265
|
* @fires Questionnaire#complete
|
|
233
266
|
*/
|
|
234
267
|
submit(): Promise<boolean>;
|
|
268
|
+
/** @returns {boolean} */
|
|
269
|
+
_finishSubmit(): boolean;
|
|
235
270
|
/**
|
|
236
271
|
* Returns the answers of every visible question that carries one, in declaration order.
|
|
237
272
|
* Questions conditioned out are left out, so an abandoned branch never submits stale data.
|
|
@@ -332,6 +367,11 @@ export declare class Questionnaire extends Component<QuestionnaireOptions> {
|
|
|
332
367
|
_field(item: NormalizedItem): Field;
|
|
333
368
|
/** @param {string} name @param {QuestionnaireNavigateDetail['reason']} reason @returns {boolean} */
|
|
334
369
|
_navigate(name: string, reason: QuestionnaireNavigateDetail['reason']): boolean;
|
|
370
|
+
/**
|
|
371
|
+
* Follows a resolved branch target: an item, the review screen, or submission.
|
|
372
|
+
* @param {string|null} target @param {'next'|'skip'} reason @returns {Promise<boolean>|boolean}
|
|
373
|
+
*/
|
|
374
|
+
_leave(target: string | null, reason: 'next' | 'skip'): Promise<boolean> | boolean;
|
|
335
375
|
/** @returns {boolean} */
|
|
336
376
|
_enterReview(): boolean;
|
|
337
377
|
/** @returns {Promise<boolean>} */
|
|
@@ -25,9 +25,10 @@ export type RatingOptions = {
|
|
|
25
25
|
*/
|
|
26
26
|
disabled?: boolean;
|
|
27
27
|
/**
|
|
28
|
-
* Accessible name of the group.
|
|
28
|
+
* Accessible name of the group; null reads the `rating.label`
|
|
29
|
+
* message ("Rating").
|
|
29
30
|
*/
|
|
30
|
-
label?: string;
|
|
31
|
+
label?: string | null;
|
|
31
32
|
/**
|
|
32
33
|
* Icon name used for each symbol.
|
|
33
34
|
*/
|
|
@@ -73,7 +74,8 @@ export type RatingOptions = {
|
|
|
73
74
|
* @property {boolean} [clearable=true] Whether re-selecting the current value clears it.
|
|
74
75
|
* @property {boolean} [readonly=false] Whether the rating is display-only.
|
|
75
76
|
* @property {boolean} [disabled=false] Whether interaction is disabled.
|
|
76
|
-
* @property {string} [label=
|
|
77
|
+
* @property {string|null} [label=null] Accessible name of the group; null reads the `rating.label`
|
|
78
|
+
* message ("Rating").
|
|
77
79
|
* @property {string} [icon='star'] Icon name used for each symbol.
|
|
78
80
|
* @property {string[]|null} [labels=null] Per-step accessible names, lowest first.
|
|
79
81
|
* @property {boolean} [showValue=false] Whether to render the numeric value beside the symbols.
|
|
@@ -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;
|