@theoremjs/react 0.3.5-next.997.g6d32810 → 0.3.5-next.999.gc01f07c
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/README.md +10 -1
- package/client/transcript-groups.d.ts +15 -2
- package/client/transcript-groups.js +21 -3
- package/package.json +3 -3
- package/ui/ChatTranscript.d.ts +10 -1
- package/ui/ChatTranscript.js +51 -18
- package/ui/index.d.ts +1 -0
- package/ui/labels.d.ts +5 -0
- package/ui/labels.js +5 -0
package/README.md
CHANGED
|
@@ -590,7 +590,7 @@ function Dock({ chat, iface }) {
|
|
|
590
590
|
}
|
|
591
591
|
```
|
|
592
592
|
|
|
593
|
-
`TheoremChatComposer` takes `layout`, `icons`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, and `
|
|
593
|
+
`TheoremChatComposer` takes `layout`, `icons`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, and `showToolDurations`. Its `handle` is the handle of the profile when you leave it out. Put both pieces inside one `TheoremSurface`. It takes what `TheoremChat` takes for the look and the media: `theme`, `mode`, `labels`, `detectCodeLanguage`, `media`, `resolveMedia`, and `mediaViewer`.
|
|
594
594
|
|
|
595
595
|
The two pieces read one clock: `chat.turnClock`. So the working pill of the composer and the status line of the transcript show the same time. `chat.workingSince` is when the reply in progress started, less its waits for approval. For a reply that runs elsewhere, it is `chat.runningElsewhere.since`. `chat.shownBlocks` is what the transcript shows: `chat.blocks`, then `chat.streamBlocks`.
|
|
596
596
|
|
|
@@ -602,6 +602,15 @@ A failed tool call in `ChatTranscript` shows its failure once: the row shows the
|
|
|
602
602
|
|
|
603
603
|
`ChatTranscript` places `citation` blocks after the answer text by default (the Sources strip under the prose). Pass `bodyKindPlacement={{}}` when citations must stay in stream order between text segments (inline citations).
|
|
604
604
|
|
|
605
|
+
`ChatTranscript` folds a reply's thoughts and tool calls, with the words the reply wrote between them, under its work status ("Worked for 22s"). Pass `stepLayout="inline"` to keep each where it came. A channel that sends each piece of words as its own message, as a text message does, then reads the same as the page:
|
|
606
|
+
|
|
607
|
+
- All the words show in the open.
|
|
608
|
+
- Calls side by side are one row. One call shows its own label. Several show their count and open to each call.
|
|
609
|
+
- Each thought is one folded line, "Thought: …", that opens to the whole of it.
|
|
610
|
+
- The work status is a line with nothing under it.
|
|
611
|
+
|
|
612
|
+
Pass `showToolDurations={false}` to leave out how long each call ran.
|
|
613
|
+
|
|
605
614
|
The hooks and the client write no English text. They return kinds, codes, and states. You write the words.
|
|
606
615
|
|
|
607
616
|
- A failure is a `ClientFailure`: `{ error, errorKind, errorInternal? }`. Show `error` to the user. It is the wording of the profile. `errorKind` and `errorInternal` are for your code.
|
|
@@ -57,7 +57,16 @@ export type ComposedAssistantTurn = {
|
|
|
57
57
|
body: TranscriptBlock[];
|
|
58
58
|
/** True when the disclosure control should appear. */
|
|
59
59
|
hasTrace: boolean;
|
|
60
|
+
/** True when the reply thought or called a tool, folded or in place. */
|
|
61
|
+
hasSteps: boolean;
|
|
60
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Where a reply's steps (its thoughts and tool calls) sit.
|
|
65
|
+
*
|
|
66
|
+
* - `trace`: under the work status, folded, with the words written between them.
|
|
67
|
+
* - `inline`: each where it came, beside the words, which all show. The work status is a line.
|
|
68
|
+
*/
|
|
69
|
+
export type StepLayout = 'trace' | 'inline';
|
|
61
70
|
/** Pin a body kind before or after kinds with no placement (stream order among peers). */
|
|
62
71
|
export type BodyKindPlacement = 'first' | 'last';
|
|
63
72
|
export type ComposeAssistantTurnOptions = {
|
|
@@ -67,6 +76,8 @@ export type ComposeAssistantTurnOptions = {
|
|
|
67
76
|
* When the option is omitted entirely, {@link DEFAULT_BODY_KIND_PLACEMENT} applies.
|
|
68
77
|
*/
|
|
69
78
|
bodyKindPlacement?: Partial<Record<TranscriptBlock['kind'], BodyKindPlacement | null | undefined>>;
|
|
79
|
+
/** Where the reply's steps sit. Default: `trace`. */
|
|
80
|
+
stepLayout?: StepLayout;
|
|
70
81
|
};
|
|
71
82
|
/**
|
|
72
83
|
* Blocks as turns: neighbours from the same side share one, unless a block is
|
|
@@ -81,10 +92,10 @@ export type WorkStatus = {
|
|
|
81
92
|
phase: 'working' | 'worked';
|
|
82
93
|
elapsedMs?: number;
|
|
83
94
|
};
|
|
84
|
-
/** Working while streaming; worked after, when it has a duration or
|
|
95
|
+
/** Working while streaming; worked after, when it has a duration or steps; else nothing to show. */
|
|
85
96
|
export declare function workStatus(args: {
|
|
86
97
|
streaming: boolean;
|
|
87
|
-
|
|
98
|
+
hasSteps: boolean;
|
|
88
99
|
elapsedMs?: number;
|
|
89
100
|
}): WorkStatus | null;
|
|
90
101
|
/**
|
|
@@ -96,6 +107,8 @@ export declare function workStatus(args: {
|
|
|
96
107
|
* - `text` before/between tools → narration; text and answer kinds after the
|
|
97
108
|
* latest tool → body (while streaming too, so the answer streams formatted)
|
|
98
109
|
* - No tools: thoughts still go to trace; remaining kinds → body
|
|
110
|
+
* - Under `stepLayout: 'inline'`, nothing is traced: every block but the first gate is body, in
|
|
111
|
+
* stream order; thoughts, and words before a call, that say nothing are dropped
|
|
99
112
|
* - Body kinds then follow {@link ComposeAssistantTurnOptions.bodyKindPlacement}
|
|
100
113
|
* (default: citations last)
|
|
101
114
|
*/
|
|
@@ -108,14 +108,14 @@ export function assistantTurnCopyText(blocks) {
|
|
|
108
108
|
.filter(Boolean)
|
|
109
109
|
.join('\n\n');
|
|
110
110
|
}
|
|
111
|
-
/** Working while streaming; worked after, when it has a duration or
|
|
111
|
+
/** Working while streaming; worked after, when it has a duration or steps; else nothing to show. */
|
|
112
112
|
export function workStatus(args) {
|
|
113
113
|
const elapsed = args.elapsedMs !== undefined ? { elapsedMs: args.elapsedMs } : {};
|
|
114
114
|
if (args.streaming)
|
|
115
115
|
return { phase: 'working', ...elapsed };
|
|
116
116
|
if (args.elapsedMs !== undefined && args.elapsedMs > 0)
|
|
117
117
|
return { phase: 'worked', elapsedMs: args.elapsedMs };
|
|
118
|
-
return args.
|
|
118
|
+
return args.hasSteps ? { phase: 'worked' } : null;
|
|
119
119
|
}
|
|
120
120
|
function isGatedTool(block) {
|
|
121
121
|
return block.kind === 'tool' && block.tool.state?.phase === 'gate';
|
|
@@ -164,6 +164,8 @@ function classifyNonGateBlock(block, args, trace, body) {
|
|
|
164
164
|
* - `text` before/between tools → narration; text and answer kinds after the
|
|
165
165
|
* latest tool → body (while streaming too, so the answer streams formatted)
|
|
166
166
|
* - No tools: thoughts still go to trace; remaining kinds → body
|
|
167
|
+
* - Under `stepLayout: 'inline'`, nothing is traced: every block but the first gate is body, in
|
|
168
|
+
* stream order; thoughts, and words before a call, that say nothing are dropped
|
|
167
169
|
* - Body kinds then follow {@link ComposeAssistantTurnOptions.bodyKindPlacement}
|
|
168
170
|
* (default: citations last)
|
|
169
171
|
*/
|
|
@@ -173,6 +175,22 @@ export function composeAssistantTurn(blocks, options) {
|
|
|
173
175
|
const nextGate = visible.find(isGatedTool);
|
|
174
176
|
const gatedTools = nextGate ? [nextGate] : [];
|
|
175
177
|
const nonGate = visible.filter((block) => block !== nextGate);
|
|
178
|
+
const placement = options?.bodyKindPlacement ?? DEFAULT_BODY_KIND_PLACEMENT;
|
|
179
|
+
if (options?.stepLayout === 'inline') {
|
|
180
|
+
// why: In place, a step is a body row like the words around it. As in the trace, a thought or
|
|
181
|
+
// the words before a call that say nothing are dropped; the answer after the last call stays,
|
|
182
|
+
// empty while it starts streaming.
|
|
183
|
+
const lastToolIndex = lastToolIndexOf(nonGate);
|
|
184
|
+
const body = nonGate.filter((block, index) => !(block.kind === 'thought' || (block.kind === 'text' && index < lastToolIndex)) ||
|
|
185
|
+
block.text.trim());
|
|
186
|
+
return {
|
|
187
|
+
trace: [],
|
|
188
|
+
gatedTools,
|
|
189
|
+
body: placeBodyBlocks(body, placement),
|
|
190
|
+
hasTrace: false,
|
|
191
|
+
hasSteps: body.some((block) => block.kind === 'tool' || block.kind === 'thought'),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
176
194
|
const lastToolIndex = lastToolIndexOf(nonGate);
|
|
177
195
|
const hasTools = lastToolIndex >= 0;
|
|
178
196
|
const trace = [];
|
|
@@ -180,12 +198,12 @@ export function composeAssistantTurn(blocks, options) {
|
|
|
180
198
|
for (const [index, block] of nonGate.entries()) {
|
|
181
199
|
classifyNonGateBlock(block, { hasTools, index, lastToolIndex }, trace, body);
|
|
182
200
|
}
|
|
183
|
-
const placement = options?.bodyKindPlacement ?? DEFAULT_BODY_KIND_PLACEMENT;
|
|
184
201
|
return {
|
|
185
202
|
trace,
|
|
186
203
|
gatedTools,
|
|
187
204
|
body: placeBodyBlocks(body, placement),
|
|
188
205
|
hasTrace: trace.length > 0,
|
|
206
|
+
hasSteps: trace.length > 0,
|
|
189
207
|
};
|
|
190
208
|
}
|
|
191
209
|
/** The trailing user group while its reply has not started streaming back. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/react",
|
|
3
|
-
"version": "0.3.5-next.
|
|
3
|
+
"version": "0.3.5-next.999.gc01f07c",
|
|
4
4
|
"description": "React bindings for Theorem: headless hooks + transport, an Astryx chat UI, and a Web-standard server handler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@stylexjs/stylex": "0.19.0",
|
|
61
61
|
"react": "^19.0.0",
|
|
62
62
|
"react-dom": "^19.0.0",
|
|
63
|
-
"@theoremjs/agents": "^0.3.5-next.
|
|
64
|
-
"@theoremjs/web": "^0.3.5-next.
|
|
63
|
+
"@theoremjs/agents": "^0.3.5-next.999.gc01f07c",
|
|
64
|
+
"@theoremjs/web": "^0.3.5-next.999.gc01f07c"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|
package/ui/ChatTranscript.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { LabelOverrides } from '@theoremjs/agents';
|
|
|
3
3
|
import { type TranscriptBlock } from '@theoremjs/agents/interface';
|
|
4
4
|
import type { AnsweringGate } from '@theoremjs/web/client';
|
|
5
5
|
import { type ReactNode } from 'react';
|
|
6
|
-
import { type ComposeAssistantTurnOptions } from '../client/transcript-groups.js';
|
|
6
|
+
import { type ComposeAssistantTurnOptions, type StepLayout } from '../client/transcript-groups.js';
|
|
7
7
|
import { type TurnClock } from '../hooks/use-turn-clock.js';
|
|
8
8
|
import { type ToolDecision } from './ToolGateCard.js';
|
|
9
9
|
import { type MediaReference } from './tool-media.js';
|
|
@@ -51,6 +51,15 @@ export type ChatTranscriptProps = {
|
|
|
51
51
|
* the prose). Pass `{}` to keep stream order for inline citations.
|
|
52
52
|
*/
|
|
53
53
|
bodyKindPlacement?: ComposeAssistantTurnOptions['bodyKindPlacement'];
|
|
54
|
+
/**
|
|
55
|
+
* Where a reply's thoughts and tool calls sit. `trace` (default) folds them, with the words
|
|
56
|
+
* written between them, under the work status. `inline` shows each where it came: every word in
|
|
57
|
+
* the open, calls side by side as one row that opens from its count, and each thought a folded
|
|
58
|
+
* line. The work status is then a line of its own.
|
|
59
|
+
*/
|
|
60
|
+
stepLayout?: StepLayout;
|
|
61
|
+
/** Whether a finished tool call's row shows how long it ran. Default: true. */
|
|
62
|
+
showToolDurations?: boolean;
|
|
54
63
|
/** The profile's labels (`iface.labels`): a stopped turn says why in its words. */
|
|
55
64
|
labels?: LabelOverrides;
|
|
56
65
|
};
|
package/ui/ChatTranscript.js
CHANGED
|
@@ -40,9 +40,15 @@ import { VoiceNote } from "./VoiceNote.js";
|
|
|
40
40
|
const ShowUsage = createContext(false);
|
|
41
41
|
/** Whether a tool call's row opens on its detail (`ChatTranscriptProps.showToolData`). */
|
|
42
42
|
const ShowToolData = createContext(true);
|
|
43
|
+
/** Whether a finished tool call's row shows how long it ran (`ChatTranscriptProps.showToolDurations`). */
|
|
44
|
+
const ShowToolDurations = createContext(true);
|
|
43
45
|
/** What the transcript's props say a tool call's row shows. */
|
|
44
46
|
function useToolRowShows() {
|
|
45
|
-
return {
|
|
47
|
+
return {
|
|
48
|
+
usage: useContext(ShowUsage),
|
|
49
|
+
detail: useContext(ShowToolData),
|
|
50
|
+
duration: useContext(ShowToolDurations),
|
|
51
|
+
};
|
|
46
52
|
}
|
|
47
53
|
/** Largest a generated image renders in the transcript. */
|
|
48
54
|
const GENERATED_IMAGE_MAX_WIDTH = 512;
|
|
@@ -311,7 +317,8 @@ export function ReferencedMedia({ reference }) {
|
|
|
311
317
|
}
|
|
312
318
|
/**
|
|
313
319
|
* Runs of images/videos become one gallery row; consecutive citation blocks
|
|
314
|
-
* become one sources row;
|
|
320
|
+
* become one sources row; calls side by side become one tools row; everything
|
|
321
|
+
* else is a row of its own.
|
|
315
322
|
*/
|
|
316
323
|
function bodyRows(t, body, shown) {
|
|
317
324
|
const rows = [];
|
|
@@ -323,6 +330,8 @@ function bodyRows(t, body, shown) {
|
|
|
323
330
|
addToGallery(rows, item);
|
|
324
331
|
else if (block.kind === 'citation')
|
|
325
332
|
addToSources(rows, citationsFromBlock(block));
|
|
333
|
+
else if (block.kind === 'tool')
|
|
334
|
+
addToTools(rows, block);
|
|
326
335
|
else
|
|
327
336
|
rows.push({ kind: 'block', block });
|
|
328
337
|
}
|
|
@@ -335,6 +344,13 @@ function addToGallery(rows, item) {
|
|
|
335
344
|
else
|
|
336
345
|
rows.push({ kind: 'gallery', items: [item] });
|
|
337
346
|
}
|
|
347
|
+
function addToTools(rows, block) {
|
|
348
|
+
const last = rows.at(-1);
|
|
349
|
+
if (last?.kind === 'tools')
|
|
350
|
+
last.blocks.push(block);
|
|
351
|
+
else
|
|
352
|
+
rows.push({ kind: 'tools', blocks: [block] });
|
|
353
|
+
}
|
|
338
354
|
function addToSources(rows, citations) {
|
|
339
355
|
if (citations.length === 0)
|
|
340
356
|
return;
|
|
@@ -414,8 +430,8 @@ function StreamedMarkdown({ text, streaming, density, components, }) {
|
|
|
414
430
|
function BodyBlock({ block, streaming }) {
|
|
415
431
|
if (block.kind === 'text')
|
|
416
432
|
return _jsx(StreamedMarkdown, { text: block.text, streaming: streaming });
|
|
417
|
-
if (block.kind === '
|
|
418
|
-
return _jsx(
|
|
433
|
+
if (block.kind === 'thought')
|
|
434
|
+
return _jsx(ThoughtLine, { text: block.text, streaming: streaming });
|
|
419
435
|
return _jsx(ResultBlock, { block: block });
|
|
420
436
|
}
|
|
421
437
|
/** Non-streaming answer rows: errors, structured output, and media. Citations coalesce in bodyRows. */
|
|
@@ -449,9 +465,9 @@ function ToolSteps({ steps }) {
|
|
|
449
465
|
const shows = useToolRowShows();
|
|
450
466
|
return (_jsxs(VStack, { gap: 2, children: [_jsx(Text, { type: "supporting", color: "secondary", children: t('@theorem.transcript.tool_steps') }), _jsx(ToolCalls, { calls: steps.map((step) => toolCallItem(t, step.operationId ?? step.callId, step, shows)) })] }));
|
|
451
467
|
}
|
|
452
|
-
/** How long a finished call ran, when both ends were seen. */
|
|
453
|
-
function toolDuration(t, tool) {
|
|
454
|
-
if (tool.startedAt === undefined || tool.endedAt === undefined)
|
|
468
|
+
/** How long a finished call ran, when the transcript shows it and both ends were seen. */
|
|
469
|
+
function toolDuration(t, tool, shows) {
|
|
470
|
+
if (!shows.duration || tool.startedAt === undefined || tool.endedAt === undefined)
|
|
455
471
|
return {};
|
|
456
472
|
return { duration: workDuration(t, tool.endedAt - tool.startedAt) };
|
|
457
473
|
}
|
|
@@ -489,7 +505,7 @@ function toolCallItem(t, id, tool, shows) {
|
|
|
489
505
|
return {
|
|
490
506
|
...base,
|
|
491
507
|
status: 'complete',
|
|
492
|
-
...toolDuration(t, tool),
|
|
508
|
+
...toolDuration(t, tool, shows),
|
|
493
509
|
...toolUsageStats(state, shows),
|
|
494
510
|
...rowDetail(t, tool, shows, state.output === undefined ? undefined : (_jsx(ShapedData, { value: state.output, title: t('@theorem.transcript.tool_output') }))),
|
|
495
511
|
};
|
|
@@ -500,10 +516,11 @@ function toolCallItem(t, id, tool, shows) {
|
|
|
500
516
|
return { ...base, status: 'pending', ...rowDetail(t, tool, shows) };
|
|
501
517
|
}
|
|
502
518
|
}
|
|
503
|
-
|
|
519
|
+
/** Calls side by side in a reply's body: one call's row, or several under their count. */
|
|
520
|
+
function ToolRun({ blocks }) {
|
|
504
521
|
const t = useLabels();
|
|
505
522
|
const shows = useToolRowShows();
|
|
506
|
-
return _jsx(ToolCalls, { calls:
|
|
523
|
+
return _jsx(ToolCalls, { calls: blocks.map((block) => toolCallItem(t, block.id, block.tool, shows)) });
|
|
507
524
|
}
|
|
508
525
|
/**
|
|
509
526
|
* Thinking reads as quieter text than the reply. Astryx has no reasoning
|
|
@@ -519,6 +536,15 @@ const THOUGHT_TEXT = {
|
|
|
519
536
|
'--text-body-size': 'var(--text-supporting-size)',
|
|
520
537
|
'--color-text-primary': 'var(--color-text-secondary)',
|
|
521
538
|
};
|
|
539
|
+
/**
|
|
540
|
+
* A thought where it came in a reply, folded to one line that opens on the whole of it. It starts
|
|
541
|
+
* folded, streaming too: the reply's words are what is read.
|
|
542
|
+
*/
|
|
543
|
+
function ThoughtLine({ text, streaming }) {
|
|
544
|
+
const t = useLabels();
|
|
545
|
+
const trigger = (_jsx(Text, { size: "sm", color: "secondary", maxLines: 1, children: t('@theorem.transcript.thought', { text: text.trim().replace(/\s+/g, ' ') }) }));
|
|
546
|
+
return (_jsx(Collapsible, { trigger: trigger, defaultIsOpen: false, children: _jsx("div", { style: THOUGHT_TEXT, children: _jsx(StreamedMarkdown, { text: text, streaming: streaming, density: "compact", components: THOUGHT_MARKDOWN }) }) }));
|
|
547
|
+
}
|
|
522
548
|
function TraceList({ items, streaming }) {
|
|
523
549
|
const t = useLabels();
|
|
524
550
|
const shows = useToolRowShows();
|
|
@@ -600,6 +626,8 @@ function TurnStatus(props) {
|
|
|
600
626
|
function BodyRowView({ row, streaming, imageOutput, }) {
|
|
601
627
|
if (row.kind === 'block')
|
|
602
628
|
return _jsx(BodyBlock, { block: row.block, streaming: streaming });
|
|
629
|
+
if (row.kind === 'tools')
|
|
630
|
+
return _jsx(ToolRun, { blocks: row.blocks });
|
|
603
631
|
if (row.kind === 'sources')
|
|
604
632
|
return _jsx(Sources, { citations: row.citations });
|
|
605
633
|
if (imageOutput)
|
|
@@ -617,14 +645,19 @@ function AssistantTurn(props) {
|
|
|
617
645
|
const chrome = useChromeReveal(props.isNewest === true);
|
|
618
646
|
const showUsage = useContext(ShowUsage);
|
|
619
647
|
const elapsedMs = useTurnElapsed(props.streaming, props.startedAt, props.workedMs);
|
|
620
|
-
const { trace, gatedTools, body, hasTrace } = composeAssistantTurn(props.blocks,
|
|
621
|
-
|
|
622
|
-
|
|
648
|
+
const { trace, gatedTools, body, hasTrace, hasSteps } = composeAssistantTurn(props.blocks, {
|
|
649
|
+
...(props.bodyKindPlacement !== undefined
|
|
650
|
+
? { bodyKindPlacement: props.bodyKindPlacement }
|
|
651
|
+
: {}),
|
|
652
|
+
...(props.stepLayout !== undefined ? { stepLayout: props.stepLayout } : {}),
|
|
653
|
+
});
|
|
623
654
|
const { shown } = useToolMedia();
|
|
624
655
|
const rows = bodyRows(t, body, shown);
|
|
625
|
-
const status = workStatusLabel(t, workStatus({ streaming: props.streaming,
|
|
656
|
+
const status = workStatusLabel(t, workStatus({ streaming: props.streaming, hasSteps, elapsedMs }));
|
|
626
657
|
const copyText = assistantTurnCopyText(body.length > 0 ? body : props.blocks);
|
|
627
|
-
return (_jsx(ChatMessage, { sender: "assistant", name: props.handle, ...chrome.handlers, metadata: props.streaming ? undefined : (_jsx(MessageChrome, { sender: "assistant", at: props.at, copyText: copyText, error: props.error, stopped: props.stopped, usage: showUsage ? props.usage : undefined, revealed: chrome.revealed })), children: _jsxs(VStack, { gap: 3, width: "100%", children: [_jsx(TurnStatus, { status: status, trace: trace, hasTrace: hasTrace, streaming: props.streaming }), gatedTools.map((block) => (_jsx(GateCard, { block: block, handle: props.handle, handlers: props.handlers }, block.id))), keyedByContent(rows, (row) => row.kind === 'gallery' || row.kind === 'sources'
|
|
658
|
+
return (_jsx(ChatMessage, { sender: "assistant", name: props.handle, ...chrome.handlers, metadata: props.streaming ? undefined : (_jsx(MessageChrome, { sender: "assistant", at: props.at, copyText: copyText, error: props.error, stopped: props.stopped, usage: showUsage ? props.usage : undefined, revealed: chrome.revealed })), children: _jsxs(VStack, { gap: 3, width: "100%", children: [_jsx(TurnStatus, { status: status, trace: trace, hasTrace: hasTrace, streaming: props.streaming }), gatedTools.map((block) => (_jsx(GateCard, { block: block, handle: props.handle, handlers: props.handlers }, block.id))), keyedByContent(rows, (row) => row.kind === 'gallery' || row.kind === 'sources' || row.kind === 'tools'
|
|
659
|
+
? row.kind
|
|
660
|
+
: row.block.kind).map(({ item: row, index: i, key }) => (_jsx(BodyRowView
|
|
628
661
|
// why: Not the block id: the committed turn re-mints ids, and a
|
|
629
662
|
// remount would cut the text reveal short.
|
|
630
663
|
, { row: row, streaming: props.streaming && i === rows.length - 1, imageOutput: props.imageOutput }, key))), _jsx(PendingImage, { imageOutput: props.imageOutput, streaming: props.streaming, rows: rows })] }) }));
|
|
@@ -653,9 +686,9 @@ function isBareFailure(group) {
|
|
|
653
686
|
}
|
|
654
687
|
/** Theorem transcript blocks rendered as Astryx chat messages. */
|
|
655
688
|
export function ChatTranscript(props) {
|
|
656
|
-
return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ChatTranscriptBody, { ...props }) }) }) }));
|
|
689
|
+
return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ShowToolDurations.Provider, { value: props.showToolDurations !== false, children: _jsx(ChatTranscriptBody, { ...props }) }) }) }) }));
|
|
657
690
|
}
|
|
658
|
-
function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, labels, clock, }) {
|
|
691
|
+
function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, }) {
|
|
659
692
|
const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers))), [blocks, dividers]);
|
|
660
693
|
const own = useTurnClock(groups, streaming);
|
|
661
694
|
const { timeOf, replyStart } = clock ?? own;
|
|
@@ -668,7 +701,7 @@ function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToo
|
|
|
668
701
|
onToolDecision,
|
|
669
702
|
onAuthenticated,
|
|
670
703
|
};
|
|
671
|
-
const turn = { handle, handlers, imageOutput, bodyKindPlacement };
|
|
704
|
+
const turn = { handle, handlers, imageOutput, bodyKindPlacement, stepLayout };
|
|
672
705
|
const lastUser = groups.findLastIndex((group) => group.kind === 'user');
|
|
673
706
|
const userTurn = (group, index) => {
|
|
674
707
|
const next = groups[index + 1];
|
package/ui/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
export type { LiveCallOptions, PageTool, PageToolAnswer, PageTools, } from '@theoremjs/web/client';
|
|
12
12
|
export type { InkWaveStatus } from '../client/ink-waveform.js';
|
|
13
13
|
export { useLiveCaptionLog } from '../client/live/use-live-caption-log.js';
|
|
14
|
+
export type { StepLayout } from '../client/transcript-groups.js';
|
|
14
15
|
export { InkWaveform, type InkWaveformProps, type InkWaveLevels, } from '../components/InkWaveform.js';
|
|
15
16
|
export { type LiveCall, type LiveCallInput, useLiveCall, } from '../components/live/use-live-call.js';
|
|
16
17
|
export { theoremTheme } from './built/theorem.js';
|
package/ui/labels.d.ts
CHANGED
|
@@ -366,6 +366,11 @@ export declare const THEOREM_UI_CATALOG: {
|
|
|
366
366
|
readonly defaultMessage: "Worked";
|
|
367
367
|
readonly description: "Turn status once done, duration unknown.";
|
|
368
368
|
};
|
|
369
|
+
readonly '@theorem.transcript.thought': {
|
|
370
|
+
readonly defaultMessage: "Thought: {text}";
|
|
371
|
+
readonly description: "A thought where it came in a reply, folded to one line; `text` is the thought, cut off at the line's end.";
|
|
372
|
+
readonly params: readonly ["text"];
|
|
373
|
+
};
|
|
369
374
|
readonly '@theorem.transcript.worked_for': {
|
|
370
375
|
readonly defaultMessage: "Worked for {duration}";
|
|
371
376
|
readonly description: "Turn status once done.";
|
package/ui/labels.js
CHANGED
|
@@ -341,6 +341,11 @@ export const THEOREM_UI_CATALOG = {
|
|
|
341
341
|
defaultMessage: 'Worked',
|
|
342
342
|
description: 'Turn status once done, duration unknown.',
|
|
343
343
|
},
|
|
344
|
+
'@theorem.transcript.thought': {
|
|
345
|
+
defaultMessage: 'Thought: {text}',
|
|
346
|
+
description: "A thought where it came in a reply, folded to one line; `text` is the thought, cut off at the line's end.",
|
|
347
|
+
params: ['text'],
|
|
348
|
+
},
|
|
344
349
|
'@theorem.transcript.worked_for': {
|
|
345
350
|
defaultMessage: 'Worked for {duration}',
|
|
346
351
|
description: 'Turn status once done.',
|