@zeyos/zx 5.5.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.
- package/CHANGELOG.md +56 -0
- package/dist/types/components/agent-thread/agent-thread.d.ts +583 -0
- 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/composer/composer.d.ts +736 -0
- 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/source-list/source-list.d.ts +177 -0
- package/dist/types/core/messages.d.ts +135 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/internal/agent-model.d.ts +587 -0
- package/dist/types/internal/highlight.d.ts +24 -0
- package/dist/types/internal/presence-loop.d.ts +148 -0
- package/dist/zx-zeyos.esm.js +4648 -4513
- package/dist/zx-zeyos.esm.min.js +2 -2
- package/dist/zx.css +1927 -1
- package/dist/zx.esm.js +15769 -9194
- package/dist/zx.esm.min.js +27 -8
- package/dist/zx.global.js +15769 -9194
- package/dist/zx.global.min.js +27 -8
- package/dist/zx.min.css +1 -1
- package/docs/api.json +1166 -5
- package/docs/llms.md +455 -2
- package/docs/llms.txt +10 -1
- package/package.json +1 -1
- package/src/components/agent-thread/agent-thread.css +417 -0
- package/src/components/agent-thread/agent-thread.js +1365 -0
- package/src/components/approval-card/approval-card.css +289 -0
- package/src/components/approval-card/approval-card.js +1377 -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 +523 -0
- package/src/components/composer/composer.css +403 -0
- package/src/components/composer/composer.js +1441 -0
- 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/source-list/source-list.css +208 -0
- package/src/components/source-list/source-list.js +355 -0
- package/src/core/messages.js +143 -0
- package/src/index.js +8 -0
- package/src/internal/agent-model.js +488 -0
- package/src/internal/highlight.js +104 -0
- package/src/internal/presence-loop.js +343 -0
- package/styles/zx.css +7 -0
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
export type RunState = 'queued' | 'running' | 'waiting' | 'paused' | 'blocked' | 'done' | 'failed' | 'stopped' | 'skipped';
|
|
2
|
+
export type AgentActivity = 'idle' | 'thinking' | 'working' | 'needs-you' | 'blocked' | 'offline';
|
|
3
|
+
export type FigureRow = [string, string, string] | {
|
|
4
|
+
label: string;
|
|
5
|
+
detail?: string;
|
|
6
|
+
value: string;
|
|
7
|
+
call?: string;
|
|
8
|
+
};
|
|
9
|
+
export type Block = {
|
|
10
|
+
type: 'p';
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'quote';
|
|
14
|
+
text: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'heading';
|
|
17
|
+
level?: 2 | 3;
|
|
18
|
+
text: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'list';
|
|
21
|
+
ordered?: boolean;
|
|
22
|
+
items: string[];
|
|
23
|
+
} | {
|
|
24
|
+
type: 'code';
|
|
25
|
+
language?: string;
|
|
26
|
+
code: string;
|
|
27
|
+
lines?: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'table';
|
|
30
|
+
columns: string[];
|
|
31
|
+
rows: string[][];
|
|
32
|
+
align?: Array<'start' | 'center' | 'end' | null>;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'figures';
|
|
35
|
+
rows: FigureRow[];
|
|
36
|
+
} | {
|
|
37
|
+
type: 'callout';
|
|
38
|
+
tone?: 'info' | 'success' | 'warning' | 'danger';
|
|
39
|
+
title?: string;
|
|
40
|
+
text: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'artifact';
|
|
43
|
+
id: string;
|
|
44
|
+
title: string;
|
|
45
|
+
kind?: 'document' | 'code';
|
|
46
|
+
versions?: number;
|
|
47
|
+
};
|
|
48
|
+
export type Source = {
|
|
49
|
+
/**
|
|
50
|
+
* Stable identity.
|
|
51
|
+
*/
|
|
52
|
+
id: string;
|
|
53
|
+
/**
|
|
54
|
+
* Full title, shown in the source card.
|
|
55
|
+
*/
|
|
56
|
+
title: string;
|
|
57
|
+
/**
|
|
58
|
+
* What the source is.
|
|
59
|
+
*/
|
|
60
|
+
kind?: 'web' | 'file' | 'record' | 'call';
|
|
61
|
+
/**
|
|
62
|
+
* Short name shown on the chip: a host, a file name, a record type.
|
|
63
|
+
*/
|
|
64
|
+
site?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The passage the answer used.
|
|
67
|
+
*/
|
|
68
|
+
snippet?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Address of a `web` source.
|
|
71
|
+
*/
|
|
72
|
+
href?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The application record a `record` source names.
|
|
75
|
+
*/
|
|
76
|
+
ref?: {
|
|
77
|
+
entity: string;
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The trace step the source came from.
|
|
82
|
+
*/
|
|
83
|
+
call?: string;
|
|
84
|
+
};
|
|
85
|
+
export type ItemRef = {
|
|
86
|
+
/**
|
|
87
|
+
* Stable identity, handed back on activation.
|
|
88
|
+
*/
|
|
89
|
+
id: string;
|
|
90
|
+
/**
|
|
91
|
+
* What the link says.
|
|
92
|
+
*/
|
|
93
|
+
label: string;
|
|
94
|
+
/**
|
|
95
|
+
* Glyph name.
|
|
96
|
+
*/
|
|
97
|
+
icon?: string;
|
|
98
|
+
/**
|
|
99
|
+
* What kind of thing it is, for the application: `task`, `file`, …
|
|
100
|
+
*/
|
|
101
|
+
entity?: string;
|
|
102
|
+
};
|
|
103
|
+
export type TraceStep = {
|
|
104
|
+
/**
|
|
105
|
+
* Stable identity.
|
|
106
|
+
*/
|
|
107
|
+
id: string;
|
|
108
|
+
/**
|
|
109
|
+
* What kind of step it is; sets the glyph and how the summary counts it. `task` is a planned step,
|
|
110
|
+
* `ask` a request a person made, `decision` a person's answer; with `think` and `handoff` they are
|
|
111
|
+
* not tool calls.
|
|
112
|
+
*/
|
|
113
|
+
kind?: 'search' | 'read' | 'query' | 'write' | 'run' | 'call' | 'handoff' | 'think' | 'task' | 'ask' | 'decision';
|
|
114
|
+
/**
|
|
115
|
+
* What was done, in the past tense: "Read the dunning policy".
|
|
116
|
+
*/
|
|
117
|
+
label: string;
|
|
118
|
+
/**
|
|
119
|
+
* Where the step stands.
|
|
120
|
+
*/
|
|
121
|
+
status?: RunState;
|
|
122
|
+
/**
|
|
123
|
+
* The present-tense line shown while it runs: "Reading the policy".
|
|
124
|
+
*/
|
|
125
|
+
doing?: string;
|
|
126
|
+
/**
|
|
127
|
+
* A muted detail.
|
|
128
|
+
*/
|
|
129
|
+
detail?: string;
|
|
130
|
+
/**
|
|
131
|
+
* How long it took.
|
|
132
|
+
*/
|
|
133
|
+
ms?: number;
|
|
134
|
+
/**
|
|
135
|
+
* A short result count: "42 rows".
|
|
136
|
+
*/
|
|
137
|
+
count?: string;
|
|
138
|
+
/**
|
|
139
|
+
* How many sources a search looked at.
|
|
140
|
+
*/
|
|
141
|
+
sources?: number;
|
|
142
|
+
/**
|
|
143
|
+
* The tool's name, shown in mono.
|
|
144
|
+
*/
|
|
145
|
+
tool?: string;
|
|
146
|
+
/**
|
|
147
|
+
* The call's arguments, JSON or text.
|
|
148
|
+
*/
|
|
149
|
+
args?: string;
|
|
150
|
+
/**
|
|
151
|
+
* What the call returned.
|
|
152
|
+
*/
|
|
153
|
+
result?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Why the call failed.
|
|
156
|
+
*/
|
|
157
|
+
error?: string;
|
|
158
|
+
/**
|
|
159
|
+
* The id of the step this one repeats.
|
|
160
|
+
*/
|
|
161
|
+
retryOf?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Author key of whoever took the step.
|
|
164
|
+
*/
|
|
165
|
+
actor?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Author key a `handoff` hands over to.
|
|
168
|
+
*/
|
|
169
|
+
to?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Local ISO date-time it started; a running step's clock counts from it.
|
|
172
|
+
*/
|
|
173
|
+
at?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Tokens the step used.
|
|
176
|
+
*/
|
|
177
|
+
tokens?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Links to what the step touched — a file it wrote, a record it read.
|
|
180
|
+
*/
|
|
181
|
+
refs?: ItemRef[];
|
|
182
|
+
};
|
|
183
|
+
export type Author = {
|
|
184
|
+
/**
|
|
185
|
+
* Display name.
|
|
186
|
+
*/
|
|
187
|
+
name: string;
|
|
188
|
+
/**
|
|
189
|
+
* What the author is.
|
|
190
|
+
*/
|
|
191
|
+
kind?: 'person' | 'agent' | 'model';
|
|
192
|
+
/**
|
|
193
|
+
* Avatar initials; derived from the name when absent.
|
|
194
|
+
*/
|
|
195
|
+
initials?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Categorical avatar tone.
|
|
198
|
+
*/
|
|
199
|
+
tone?: string;
|
|
200
|
+
/**
|
|
201
|
+
* What an agent is doing now.
|
|
202
|
+
*/
|
|
203
|
+
activity?: AgentActivity | null;
|
|
204
|
+
/**
|
|
205
|
+
* The model an agent answers through, shown in the byline.
|
|
206
|
+
*/
|
|
207
|
+
via?: string;
|
|
208
|
+
/**
|
|
209
|
+
* A glyph drawn in a tinted tile instead of initials — a model's mark.
|
|
210
|
+
*/
|
|
211
|
+
icon?: string;
|
|
212
|
+
};
|
|
213
|
+
export type Attachment = {
|
|
214
|
+
name: string;
|
|
215
|
+
size?: number;
|
|
216
|
+
type?: string;
|
|
217
|
+
};
|
|
218
|
+
export type AnswerVersion = {
|
|
219
|
+
blocks: Block[];
|
|
220
|
+
sources?: Source[];
|
|
221
|
+
steps?: TraceStep[];
|
|
222
|
+
at?: string;
|
|
223
|
+
model?: string;
|
|
224
|
+
stopped?: boolean;
|
|
225
|
+
rating?: 'up' | 'down' | null;
|
|
226
|
+
};
|
|
227
|
+
export type ThreadItem = {
|
|
228
|
+
id: string;
|
|
229
|
+
type: 'user';
|
|
230
|
+
at?: string;
|
|
231
|
+
author?: string;
|
|
232
|
+
text: string;
|
|
233
|
+
files?: Attachment[];
|
|
234
|
+
mentions?: Array<string | {
|
|
235
|
+
name: string;
|
|
236
|
+
tone?: string;
|
|
237
|
+
}>;
|
|
238
|
+
refs?: ItemRef[];
|
|
239
|
+
} | {
|
|
240
|
+
id: string;
|
|
241
|
+
type: 'text';
|
|
242
|
+
at?: string;
|
|
243
|
+
author?: string;
|
|
244
|
+
text: string;
|
|
245
|
+
refs?: ItemRef[];
|
|
246
|
+
} | {
|
|
247
|
+
id: string;
|
|
248
|
+
type: 'answer';
|
|
249
|
+
at?: string;
|
|
250
|
+
author?: string;
|
|
251
|
+
blocks: Block[];
|
|
252
|
+
sources?: Source[];
|
|
253
|
+
steps?: TraceStep[];
|
|
254
|
+
stepsOpen?: boolean;
|
|
255
|
+
streaming?: boolean;
|
|
256
|
+
stopped?: boolean;
|
|
257
|
+
versions?: AnswerVersion[];
|
|
258
|
+
version?: number;
|
|
259
|
+
rating?: 'up' | 'down' | null;
|
|
260
|
+
refs?: ItemRef[];
|
|
261
|
+
} | {
|
|
262
|
+
id: string;
|
|
263
|
+
type: 'trace';
|
|
264
|
+
at?: string;
|
|
265
|
+
author?: string;
|
|
266
|
+
steps: TraceStep[];
|
|
267
|
+
open?: boolean;
|
|
268
|
+
title?: string;
|
|
269
|
+
refs?: ItemRef[];
|
|
270
|
+
} | {
|
|
271
|
+
id: string;
|
|
272
|
+
type: 'approval';
|
|
273
|
+
at?: string;
|
|
274
|
+
author?: string;
|
|
275
|
+
title: string;
|
|
276
|
+
description?: string;
|
|
277
|
+
icon?: string | null;
|
|
278
|
+
tone?: string;
|
|
279
|
+
status?: 'pending' | 'approved' | 'rejected' | 'expired';
|
|
280
|
+
details?: Block[];
|
|
281
|
+
preview?: {
|
|
282
|
+
label: string;
|
|
283
|
+
blocks: Block[];
|
|
284
|
+
};
|
|
285
|
+
fields?: Record<string, Record<string, unknown>>;
|
|
286
|
+
values?: Record<string, unknown>;
|
|
287
|
+
confirmText?: string | null;
|
|
288
|
+
reason?: 'optional' | 'required' | 'none';
|
|
289
|
+
edited?: boolean;
|
|
290
|
+
editedKeys?: string[] | null;
|
|
291
|
+
rejectReason?: string | null;
|
|
292
|
+
answeredBy?: string;
|
|
293
|
+
answeredAt?: string;
|
|
294
|
+
} | {
|
|
295
|
+
id: string;
|
|
296
|
+
type: 'notice';
|
|
297
|
+
at?: string;
|
|
298
|
+
author?: string;
|
|
299
|
+
text: string;
|
|
300
|
+
tone?: 'neutral' | 'info' | 'success' | 'warning' | 'danger';
|
|
301
|
+
action?: {
|
|
302
|
+
id: string;
|
|
303
|
+
label: string;
|
|
304
|
+
};
|
|
305
|
+
} | {
|
|
306
|
+
id: string;
|
|
307
|
+
type: string;
|
|
308
|
+
at?: string;
|
|
309
|
+
author?: string;
|
|
310
|
+
[key: string]: unknown;
|
|
311
|
+
};
|
|
312
|
+
export type StateTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger' | 'muted';
|
|
313
|
+
export type StateEntry = {
|
|
314
|
+
status: string;
|
|
315
|
+
tone: StateTone;
|
|
316
|
+
key: string;
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Where a run, or one step of it, stands.
|
|
320
|
+
* @typedef {'queued'|'running'|'waiting'|'paused'|'blocked'|'done'|'failed'|'stopped'|'skipped'} RunState
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* What an agent is doing, shown beside its avatar.
|
|
324
|
+
* @typedef {'idle'|'thinking'|'working'|'needs-you'|'blocked'|'offline'} AgentActivity
|
|
325
|
+
*/
|
|
326
|
+
/**
|
|
327
|
+
* A row of figures: what it is, a muted detail, and the value. The tuple form is shorthand for the
|
|
328
|
+
* object form; `call` names the trace step the value came from.
|
|
329
|
+
* @typedef {[string, string, string]|{label: string, detail?: string, value: string, call?: string}} FigureRow
|
|
330
|
+
*/
|
|
331
|
+
/**
|
|
332
|
+
* One block of an answer. Text runs use the inline grammar of `parseInline()`; nothing in a block
|
|
333
|
+
* is ever read as HTML.
|
|
334
|
+
* @typedef {{type: 'p', text: string}
|
|
335
|
+
* | {type: 'quote', text: string}
|
|
336
|
+
* | {type: 'heading', level?: 2|3, text: string}
|
|
337
|
+
* | {type: 'list', ordered?: boolean, items: string[]}
|
|
338
|
+
* | {type: 'code', language?: string, code: string, lines?: boolean}
|
|
339
|
+
* | {type: 'table', columns: string[], rows: string[][], align?: Array<'start'|'center'|'end'|null>}
|
|
340
|
+
* | {type: 'figures', rows: FigureRow[]}
|
|
341
|
+
* | {type: 'callout', tone?: 'info'|'success'|'warning'|'danger', title?: string, text: string}
|
|
342
|
+
* | {type: 'artifact', id: string, title: string, kind?: 'document'|'code', versions?: number}} Block
|
|
343
|
+
*/
|
|
344
|
+
/**
|
|
345
|
+
* A source an answer draws on. `web` sources may carry an `href`; a `record` names an application
|
|
346
|
+
* record; a `call` names the trace step it came from.
|
|
347
|
+
* @typedef {Object} Source
|
|
348
|
+
* @property {string} id Stable identity.
|
|
349
|
+
* @property {string} title Full title, shown in the source card.
|
|
350
|
+
* @property {'web'|'file'|'record'|'call'} [kind='web'] What the source is.
|
|
351
|
+
* @property {string} [site] Short name shown on the chip: a host, a file name, a record type.
|
|
352
|
+
* @property {string} [snippet] The passage the answer used.
|
|
353
|
+
* @property {string} [href] Address of a `web` source.
|
|
354
|
+
* @property {{entity: string, id: string}} [ref] The application record a `record` source names.
|
|
355
|
+
* @property {string} [call] The trace step the source came from.
|
|
356
|
+
*/
|
|
357
|
+
/**
|
|
358
|
+
* A link from an item or a step to something of the application's own — a task, a file, a
|
|
359
|
+
* record. The application resolves it; the components only draw the label and report the click.
|
|
360
|
+
* @typedef {Object} ItemRef
|
|
361
|
+
* @property {string} id Stable identity, handed back on activation.
|
|
362
|
+
* @property {string} label What the link says.
|
|
363
|
+
* @property {string} [icon] Glyph name.
|
|
364
|
+
* @property {string} [entity] What kind of thing it is, for the application: `task`, `file`, …
|
|
365
|
+
*/
|
|
366
|
+
/**
|
|
367
|
+
* One thing an agent did during a run.
|
|
368
|
+
* @typedef {Object} TraceStep
|
|
369
|
+
* @property {string} id Stable identity.
|
|
370
|
+
* @property {'search'|'read'|'query'|'write'|'run'|'call'|'handoff'|'think'|'task'|'ask'|'decision'} [kind='call']
|
|
371
|
+
* What kind of step it is; sets the glyph and how the summary counts it. `task` is a planned step,
|
|
372
|
+
* `ask` a request a person made, `decision` a person's answer; with `think` and `handoff` they are
|
|
373
|
+
* not tool calls.
|
|
374
|
+
* @property {string} label What was done, in the past tense: "Read the dunning policy".
|
|
375
|
+
* @property {RunState} [status='done'] Where the step stands.
|
|
376
|
+
* @property {string} [doing] The present-tense line shown while it runs: "Reading the policy".
|
|
377
|
+
* @property {string} [detail] A muted detail.
|
|
378
|
+
* @property {number} [ms] How long it took.
|
|
379
|
+
* @property {string} [count] A short result count: "42 rows".
|
|
380
|
+
* @property {number} [sources] How many sources a search looked at.
|
|
381
|
+
* @property {string} [tool] The tool's name, shown in mono.
|
|
382
|
+
* @property {string} [args] The call's arguments, JSON or text.
|
|
383
|
+
* @property {string} [result] What the call returned.
|
|
384
|
+
* @property {string} [error] Why the call failed.
|
|
385
|
+
* @property {string} [retryOf] The id of the step this one repeats.
|
|
386
|
+
* @property {string} [actor] Author key of whoever took the step.
|
|
387
|
+
* @property {string} [to] Author key a `handoff` hands over to.
|
|
388
|
+
* @property {string} [at] Local ISO date-time it started; a running step's clock counts from it.
|
|
389
|
+
* @property {number} [tokens] Tokens the step used.
|
|
390
|
+
* @property {ItemRef[]} [refs] Links to what the step touched — a file it wrote, a record it read.
|
|
391
|
+
*/
|
|
392
|
+
/**
|
|
393
|
+
* Who wrote an item or took a step.
|
|
394
|
+
* @typedef {Object} Author
|
|
395
|
+
* @property {string} name Display name.
|
|
396
|
+
* @property {'person'|'agent'|'model'} [kind='agent'] What the author is.
|
|
397
|
+
* @property {string} [initials] Avatar initials; derived from the name when absent.
|
|
398
|
+
* @property {string} [tone] Categorical avatar tone.
|
|
399
|
+
* @property {AgentActivity|null} [activity] What an agent is doing now.
|
|
400
|
+
* @property {string} [via] The model an agent answers through, shown in the byline.
|
|
401
|
+
* @property {string} [icon] A glyph drawn in a tinted tile instead of initials — a model's mark.
|
|
402
|
+
*/
|
|
403
|
+
/** @typedef {{name: string, size?: number, type?: string}} Attachment */
|
|
404
|
+
/**
|
|
405
|
+
* One version of a regenerated answer.
|
|
406
|
+
* @typedef {{blocks: Block[], sources?: Source[], steps?: TraceStep[], at?: string, model?: string,
|
|
407
|
+
* stopped?: boolean, rating?: 'up'|'down'|null}} AnswerVersion
|
|
408
|
+
*/
|
|
409
|
+
/**
|
|
410
|
+
* One item in a conversation thread.
|
|
411
|
+
* `refs` on any item draws links to the application's own things after its content; `mentions` on a
|
|
412
|
+
* person's message marks each `@name` in the text; an answer's `steps` show the work it did inline,
|
|
413
|
+
* above its text, and change with its version.
|
|
414
|
+
* @typedef {{id: string, type: 'user', at?: string, author?: string, text: string, files?: Attachment[],
|
|
415
|
+
* mentions?: Array<string|{name: string, tone?: string}>, refs?: ItemRef[]}
|
|
416
|
+
* | {id: string, type: 'text', at?: string, author?: string, text: string, refs?: ItemRef[]}
|
|
417
|
+
* | {id: string, type: 'answer', at?: string, author?: string, blocks: Block[], sources?: Source[],
|
|
418
|
+
* steps?: TraceStep[], stepsOpen?: boolean, streaming?: boolean, stopped?: boolean, versions?: AnswerVersion[],
|
|
419
|
+
* version?: number, rating?: 'up'|'down'|null, refs?: ItemRef[]}
|
|
420
|
+
* | {id: string, type: 'trace', at?: string, author?: string, steps: TraceStep[], open?: boolean,
|
|
421
|
+
* title?: string, refs?: ItemRef[]}
|
|
422
|
+
* | {id: string, type: 'approval', at?: string, author?: string, title: string, description?: string,
|
|
423
|
+
* icon?: string|null, tone?: string,
|
|
424
|
+
* status?: 'pending'|'approved'|'rejected'|'expired', details?: Block[],
|
|
425
|
+
* preview?: {label: string, blocks: Block[]}, fields?: Record<string, Record<string, unknown>>,
|
|
426
|
+
* values?: Record<string, unknown>, confirmText?: string|null, reason?: 'optional'|'required'|'none',
|
|
427
|
+
* edited?: boolean, editedKeys?: string[]|null, rejectReason?: string|null, answeredBy?: string,
|
|
428
|
+
* answeredAt?: string}
|
|
429
|
+
* | {id: string, type: 'notice', at?: string, author?: string, text: string,
|
|
430
|
+
* tone?: 'neutral'|'info'|'success'|'warning'|'danger', action?: {id: string, label: string}}
|
|
431
|
+
* | {id: string, type: string, at?: string, author?: string, [key: string]: unknown}} ThreadItem
|
|
432
|
+
*/
|
|
433
|
+
/** @typedef {'neutral'|'info'|'success'|'warning'|'danger'|'muted'} StateTone */
|
|
434
|
+
/** @typedef {{status: string, tone: StateTone, key: string}} StateEntry */
|
|
435
|
+
/**
|
|
436
|
+
* How each run or step state is drawn: the `statusIcon()` status, its tone, and the message key of
|
|
437
|
+
* the word beside it. A state is always a glyph and a word; its colour never stands alone.
|
|
438
|
+
* @type {Readonly<Record<RunState, StateEntry>>}
|
|
439
|
+
*/
|
|
440
|
+
export declare const STATUS: Readonly<Record<RunState, StateEntry>>;
|
|
441
|
+
/**
|
|
442
|
+
* How each agent activity is drawn beside an avatar: the tone of its dot and the message key of
|
|
443
|
+
* its word.
|
|
444
|
+
* @type {Readonly<Record<AgentActivity, {tone: StateTone, key: string}>>}
|
|
445
|
+
*/
|
|
446
|
+
export declare const ACTIVITY: Readonly<Record<AgentActivity, {
|
|
447
|
+
tone: StateTone;
|
|
448
|
+
key: string;
|
|
449
|
+
}>>;
|
|
450
|
+
/**
|
|
451
|
+
* The English words for `STATUS` and `ACTIVITY`, for a component's `msg` defaults.
|
|
452
|
+
* @type {Readonly<Record<string, string>>}
|
|
453
|
+
*/
|
|
454
|
+
export declare const AGENT_MESSAGES: Readonly<Record<string, string>>;
|
|
455
|
+
/**
|
|
456
|
+
* Reads a state, falling back to `done` for anything the model does not know.
|
|
457
|
+
* @param {unknown} state
|
|
458
|
+
* @returns {RunState}
|
|
459
|
+
*/
|
|
460
|
+
export declare function normalizeRunState(state: unknown): RunState;
|
|
461
|
+
/**
|
|
462
|
+
* Reads an activity, or null for none or anything unknown.
|
|
463
|
+
* @param {unknown} activity
|
|
464
|
+
* @returns {AgentActivity|null}
|
|
465
|
+
*/
|
|
466
|
+
export declare function normalizeActivity(activity: unknown): AgentActivity | null;
|
|
467
|
+
export type InlineSegment = {
|
|
468
|
+
kind: 'text' | 'strong' | 'code';
|
|
469
|
+
text: string;
|
|
470
|
+
} | {
|
|
471
|
+
kind: 'cite';
|
|
472
|
+
text: string;
|
|
473
|
+
n: number;
|
|
474
|
+
};
|
|
475
|
+
/**
|
|
476
|
+
* Splits a run of model text into plain text, `**bold**`, `` `code` ``, and `[n]` citation
|
|
477
|
+
* segments. That is the whole grammar: there are no links, no HTML, and no nesting. A backslash
|
|
478
|
+
* makes the next `*`, `` ` ``, `[`, or backslash literal; a marker that is never closed stays
|
|
479
|
+
* literal text, which is also what a half-streamed marker looks like until its close arrives.
|
|
480
|
+
* Code spans are verbatim: escapes inside them are not processed.
|
|
481
|
+
* @param {unknown} text
|
|
482
|
+
* @returns {InlineSegment[]}
|
|
483
|
+
*/
|
|
484
|
+
export declare function parseInline(text: unknown): InlineSegment[];
|
|
485
|
+
/**
|
|
486
|
+
* The visible text of a run of model text: markers dropped, citations kept as `[n]`.
|
|
487
|
+
* @param {unknown} text
|
|
488
|
+
* @returns {string}
|
|
489
|
+
*/
|
|
490
|
+
export declare function inlineText(text: unknown): string;
|
|
491
|
+
/**
|
|
492
|
+
* Reads a figures row in either form.
|
|
493
|
+
* @param {FigureRow} row
|
|
494
|
+
* @returns {{label: string, detail: string, value: string, call: string|null}}
|
|
495
|
+
*/
|
|
496
|
+
export declare function figureRow(row: FigureRow): {
|
|
497
|
+
label: string;
|
|
498
|
+
detail: string;
|
|
499
|
+
value: string;
|
|
500
|
+
call: string | null;
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* An answer as plain text, for search and screen-reader summaries: markers dropped, one blank line
|
|
504
|
+
* between blocks.
|
|
505
|
+
* @param {Block[]} blocks
|
|
506
|
+
* @returns {string}
|
|
507
|
+
*/
|
|
508
|
+
export declare function blocksToText(blocks: Block[]): string;
|
|
509
|
+
/**
|
|
510
|
+
* An answer as Markdown, for copying and export. Inline markers are already Markdown and pass
|
|
511
|
+
* through as written.
|
|
512
|
+
* @param {Block[]} blocks
|
|
513
|
+
* @returns {string}
|
|
514
|
+
*/
|
|
515
|
+
export declare function blocksToMarkdown(blocks: Block[]): string;
|
|
516
|
+
export type TraceSummary = {
|
|
517
|
+
/**
|
|
518
|
+
* Steps that are not retries.
|
|
519
|
+
*/
|
|
520
|
+
steps: number;
|
|
521
|
+
/**
|
|
522
|
+
* Tool calls made, retries included.
|
|
523
|
+
*/
|
|
524
|
+
calls: number;
|
|
525
|
+
/**
|
|
526
|
+
* Steps that repeat another.
|
|
527
|
+
*/
|
|
528
|
+
retries: number;
|
|
529
|
+
/**
|
|
530
|
+
* Steps that failed and were not retried successfully.
|
|
531
|
+
*/
|
|
532
|
+
failed: number;
|
|
533
|
+
/**
|
|
534
|
+
* Sources looked at, across all searches.
|
|
535
|
+
*/
|
|
536
|
+
sources: number;
|
|
537
|
+
/**
|
|
538
|
+
* Time spent on finished steps.
|
|
539
|
+
*/
|
|
540
|
+
ms: number;
|
|
541
|
+
/**
|
|
542
|
+
* The step running now, if any.
|
|
543
|
+
*/
|
|
544
|
+
running: TraceStep | null;
|
|
545
|
+
/**
|
|
546
|
+
* The step the run was stopped at, if any.
|
|
547
|
+
*/
|
|
548
|
+
stopped: TraceStep | null;
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* What a run's steps add up to, for the one-line summary its trace folds into.
|
|
552
|
+
* @param {TraceStep[]} steps
|
|
553
|
+
* @returns {TraceSummary}
|
|
554
|
+
*/
|
|
555
|
+
export declare function traceSummary(steps: TraceStep[]): TraceSummary;
|
|
556
|
+
/**
|
|
557
|
+
* How long something took, the way a person says it: "0.8 s" below ten seconds, then "12 s",
|
|
558
|
+
* "1 min 42 s", "1 h 5 min".
|
|
559
|
+
* @param {number} ms
|
|
560
|
+
* @param {{locale?: string}} [options]
|
|
561
|
+
* @returns {string}
|
|
562
|
+
*/
|
|
563
|
+
export declare function formatDuration(ms: number, options?: {
|
|
564
|
+
locale?: string;
|
|
565
|
+
}): string;
|
|
566
|
+
/**
|
|
567
|
+
* A running clock in whole units: "2 s", "41 s", "1 min 42 s", "1 h 5 min".
|
|
568
|
+
* @param {number} ms
|
|
569
|
+
* @returns {string}
|
|
570
|
+
*/
|
|
571
|
+
export declare function formatElapsed(ms: number): string;
|
|
572
|
+
/**
|
|
573
|
+
* What a run cost, from its token counts and per-token prices.
|
|
574
|
+
* @param {[number, number]|null|undefined} tokens Input and output tokens.
|
|
575
|
+
* @param {{in: number, out: number}} price Price per input and per output token.
|
|
576
|
+
* @returns {number}
|
|
577
|
+
*/
|
|
578
|
+
export declare function runCost(tokens: [number, number] | null | undefined, price: {
|
|
579
|
+
in: number;
|
|
580
|
+
out: number;
|
|
581
|
+
}): number;
|
|
582
|
+
/**
|
|
583
|
+
* Initials for an avatar from a name: "Finance agent" → "FA".
|
|
584
|
+
* @param {string} name
|
|
585
|
+
* @returns {string}
|
|
586
|
+
*/
|
|
587
|
+
export declare function initialsOf(name: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small syntax tokenizer for code an agent writes into an answer. It recognises comments,
|
|
3
|
+
* strings, numbers, and keywords — enough to make code readable, never enough to be an editor —
|
|
4
|
+
* and returns segments, never markup, so the caller builds text nodes and spans from them.
|
|
5
|
+
*/
|
|
6
|
+
export type TokenKind = 'comment' | 'string' | 'number' | 'keyword';
|
|
7
|
+
export type CodeSegment = {
|
|
8
|
+
text: string;
|
|
9
|
+
token: TokenKind | null;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Whether code in this language is coloured.
|
|
13
|
+
* @param {unknown} language
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export declare function isHighlighted(language: unknown): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Splits code into plain and coloured segments. An unknown language is one plain segment.
|
|
19
|
+
* Python's `True`/`None` and SQL's upper-case keywords are matched without regard to case.
|
|
20
|
+
* @param {unknown} language
|
|
21
|
+
* @param {unknown} source
|
|
22
|
+
* @returns {CodeSegment[]}
|
|
23
|
+
*/
|
|
24
|
+
export declare function highlight(language: unknown, source: unknown): CodeSegment[];
|