@theoremjs/react 0.3.5-next.1043.ge9acd49 → 0.3.5-next.1045.gcc305fe
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 +30 -3
- package/package.json +3 -3
- package/ui/ChatComposerBar.d.ts +6 -1
- package/ui/ChatComposerBar.js +1 -1
- package/ui/ChatComposerRow.d.ts +9 -1
- package/ui/ChatComposerRow.js +25 -8
- package/ui/ChatTranscript.d.ts +13 -1
- package/ui/ChatTranscript.js +69 -16
- package/ui/TheoremChat.d.ts +6 -2
- package/ui/TheoremChat.js +3 -3
- package/ui/index.d.ts +3 -3
- package/ui/index.js +1 -1
- package/ui/reply-slot.d.ts +34 -0
package/README.md
CHANGED
|
@@ -180,11 +180,12 @@ To draw your own figures like the trace panel does, `@theoremjs/react/ui` also e
|
|
|
180
180
|
| `composerLayout` | `'stacked'` or `'row'`. In `'row'`, the field, the mic and send share one line, and text that wraps moves the field onto its own line. Above them, a pill shows the reply in progress, with its stop button, and a pill shows each background call. While a reply runs or a step waits, Enter queues a draft and send opens the send menu. Default: `'stacked'`. |
|
|
181
181
|
| `composerEmptyAction` | Shows in place of the send button while the composer has nothing to send, for example a button that starts a call. It never replaces stop or the send menu. `TheoremChatComposer` and `ChatComposerBar` take it as `emptyAction`. Default: the send button. |
|
|
182
182
|
| `renderComposerStatus` | Draws the composer's problem: a send that failed (`type: 'error'`), or files or a voice note it could not take (`type: 'warning'`), with its `message`. Give what you draw its own `role`: `alert` for an error, `status` for a warning. `TheoremChatComposer` and `ChatComposerBar` take it as `renderStatus`. Default: in `'row'`, Theorem's card over the surface (see [The row composer's look](#the-row-composers-look)); in `'stacked'`, Astryx's status, in the status colour. |
|
|
183
|
-
| `
|
|
183
|
+
| `renderComposerPillWords` | Draws the words of the working pill and of each background call's pill in the `'row'` composer, from `{ pill, words }`. `pill` is `'working'` or `'background'`. The pill keeps its words for screen readers. `TheoremChatComposer` and `ChatComposerBar` take it as `renderPillWords`. Default: Theorem's words. |
|
|
184
|
+
| `composerIcons` | The glyphs the `'row'` composer draws: `working`, before the working pill's text; `backgroundJob`, before each background call's name; `stop`, in the working pill's stop button. Each one you leave out keeps Theorem's; `null` draws none. See [The row composer's look](#the-row-composers-look). |
|
|
184
185
|
| `media` | Which media from tools the chat shows. `'sent'` shows only what a tool sent to the person. `'all'` also shows what only the model read, for an evaluation view. Default: `'sent'`. See [Tool media](#tool-media). |
|
|
185
186
|
| `resolveMedia` | Turns a tool's reference into an address the page can load. See [Tool media](#tool-media). |
|
|
186
187
|
| `mediaViewer` | The viewer every picture and video opens in. Default: Astryx's Lightbox, with zoom. See [Your own media viewer](#your-own-media-viewer). |
|
|
187
|
-
| `transcript` | The options of `TheoremChatTranscript` that the chat does not set itself, given to its transcript as they are: `slots`, `turnKeyOf`, `turnTimeOf`, `dividers`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `showWorkStatus`, and `
|
|
188
|
+
| `transcript` | The options of `TheoremChatTranscript` that the chat does not set itself, given to its transcript as they are: `slots`, `turnKeyOf`, `turnTimeOf`, `dividers`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `toolFailureReasonKinds`, `showWorkStatus`, `showResumedNotice`, and `nameAppears`. Its type is `TheoremChatTranscriptOptions`. See [Draw under a reply](#draw-under-a-reply) and [Draw beside a message's time](#draw-beside-a-messages-time). |
|
|
188
189
|
|
|
189
190
|
### The row composer's look
|
|
190
191
|
|
|
@@ -745,7 +746,7 @@ function Dock({ chat, iface }) {
|
|
|
745
746
|
}
|
|
746
747
|
```
|
|
747
748
|
|
|
748
|
-
`TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, `inputRef`, `inputComponent`, `triggers`, `refText`, `renderRef`, `emptyAction`, and `
|
|
749
|
+
`TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, `inputRef`, `inputComponent`, `triggers`, `refText`, `renderRef`, `emptyAction`, `renderStatus`, and `renderPillWords`. Pass it the `refText` you gave `useTheoremChat`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `toolFailureReasonKinds`, `showWorkStatus`, `showResumedNotice`, `nameAppears`, `renderRef`, `turnKeyOf`, `turnTimeOf`, and `slots`. 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`.
|
|
749
750
|
|
|
750
751
|
Use `pills` to show your own notice in the pill row of the `row` layout, for example "New from your agent" while the chat is closed. Each pill is `{ id, label, icon?, onSelect? }`. It comes after the working pill and the background calls, and looks like them. The icon goes before the words. A click calls `onSelect`. A pill without `onSelect` only shows.
|
|
751
752
|
|
|
@@ -770,8 +771,12 @@ A failed tool call in `ChatTranscript` shows its failure in the person's wording
|
|
|
770
771
|
|
|
771
772
|
Pass `showToolDurations={false}` to leave out how long each call ran.
|
|
772
773
|
|
|
774
|
+
A failed call's row shows the call's failed label and then a sentence on why it failed. Pass `toolFailureReasonKinds` to keep that sentence only for the failure kinds you name, such as `['cancelled', 'declined']`; `[]` leaves it out of every row. The model still reads the failure, and the call's detail still holds it.
|
|
775
|
+
|
|
773
776
|
Pass `showWorkStatus={false}` to leave out a reply's work status ("Working for 12s", "Worked for 3.5s"). A reply whose steps fold under the status keeps it as the fold's trigger, without the time ("Worked"). Any other reply shows none.
|
|
774
777
|
|
|
778
|
+
Pass `nameAppears="with-content"` to keep a reply's name back until the reply has something to show: its work status, a call, a gate, words, media, or an image's placeholder. By default the name shows as soon as the reply starts.
|
|
779
|
+
|
|
775
780
|
The hooks and the client write no English text. They return kinds, codes, and states. You write the words.
|
|
776
781
|
|
|
777
782
|
- 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.
|
|
@@ -858,6 +863,28 @@ These rules apply:
|
|
|
858
863
|
- A reply on its way has no details row yet.
|
|
859
864
|
- Without `slots.details`, the row is unchanged. Without `turnKeyOf`, messages join as before.
|
|
860
865
|
|
|
866
|
+
### Draw the name, the calls, and the words yourself
|
|
867
|
+
|
|
868
|
+
Three more `slots` stand in for parts the transcript draws. Use them to change how a part looks or moves. Each one you leave out keeps the transcript's own.
|
|
869
|
+
|
|
870
|
+
| Slot | Stands in for | Receives |
|
|
871
|
+
| --- | --- | --- |
|
|
872
|
+
| `name` | A reply's name, where the name shows (`nameAppears`). | `{ handle, streaming }` |
|
|
873
|
+
| `toolCalls` | Each list of tool calls: in a reply, in its trace, and in an agent call's detail. | `{ list, streaming }`. `list` is what the transcript gives Astryx's `ChatToolCalls`. |
|
|
874
|
+
| `markdown` | The Markdown of a reply's words and thoughts. | What the transcript gives Astryx's `Markdown`, its `children` and `isStreaming` among them. |
|
|
875
|
+
|
|
876
|
+
`streaming` is `true` while the reply is on its way. A call's `key` is its operation id, or its call id. It stays the same from the live reply to the saved one.
|
|
877
|
+
|
|
878
|
+
```tsx
|
|
879
|
+
<ChatTranscript
|
|
880
|
+
blocks={blocks}
|
|
881
|
+
handle="Harbor"
|
|
882
|
+
slots={{
|
|
883
|
+
toolCalls: ({ list }) => <ChatToolCalls {...list} isDefaultExpanded />,
|
|
884
|
+
}}
|
|
885
|
+
/>;
|
|
886
|
+
```
|
|
887
|
+
|
|
861
888
|
### Date messages by your own record
|
|
862
889
|
|
|
863
890
|
A reply is dated from its end, and any other message from when the page first showed it. To date messages by your own record, pass `turnTimeOf`: it takes a block's `host` value and returns when the block was written, in milliseconds since the epoch, or `undefined`.
|
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.1045.gcc305fe",
|
|
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.1045.gcc305fe",
|
|
64
|
+
"@theoremjs/web": "^0.3.5-next.1045.gcc305fe"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|
package/ui/ChatComposerBar.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type AttachmentValidationIssue, type ComposerMenuAction, type ComposerP
|
|
|
4
4
|
import type { ClientFailure } from '@theoremjs/web/client';
|
|
5
5
|
import { type ComponentProps, type ComponentType, type ReactNode } from 'react';
|
|
6
6
|
import type { BackgroundJob } from '../client/transcript-groups.js';
|
|
7
|
-
import { type ComposerPill, type ComposerRowIcons } from './ChatComposerRow.js';
|
|
7
|
+
import { type ComposerPill, type ComposerPillWords, type ComposerRowIcons } from './ChatComposerRow.js';
|
|
8
8
|
/** An option the profile declares: its allowed values, the one chosen, and how to choose another. */
|
|
9
9
|
/** The effort selector's icon. The studio's Agents list shows the same one. */
|
|
10
10
|
export declare const EFFORT_ICON: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
@@ -99,6 +99,11 @@ export type ChatComposerBarProps = {
|
|
|
99
99
|
* a warning. Omit to keep Theorem's: in `row`, a card over the surface; in `stacked`, Astryx's.
|
|
100
100
|
*/
|
|
101
101
|
renderStatus?: (status: ChatComposerStatus) => ReactNode;
|
|
102
|
+
/**
|
|
103
|
+
* Draws the words of the working pill and of each background job's, in the `row` layout. The
|
|
104
|
+
* pill keeps its words for screen readers. Omit to keep Theorem's.
|
|
105
|
+
*/
|
|
106
|
+
renderPillWords?: (said: ComposerPillWords) => ReactNode;
|
|
102
107
|
};
|
|
103
108
|
/** A Live call's text line: it is sent as typed, so there is nothing to attach, queue, or stop. */
|
|
104
109
|
export type LiveComposerBarProps = Omit<Pick<ChatComposerBarProps, 'draftText' | 'placeholder' | 'inputRef' | 'inputComponent' | 'triggers' | 'draftParts' | 'onDraftPartsChange' | 'refText' | 'renderRef' | 'onDraftTextChange' | 'onSubmit' | 'emptyAction'>, 'onSubmit'> & {
|
package/ui/ChatComposerBar.js
CHANGED
|
@@ -448,7 +448,7 @@ function RowComposerBar({ props, parts, }) {
|
|
|
448
448
|
// why: Stop lives on the working pill, so the button only sends; while a reply runs or a
|
|
449
449
|
// step waits, a draft opens the send menu instead (Enter still queues).
|
|
450
450
|
const opensMenu = props.phase !== 'idle' && parts.menuActions.length > 0;
|
|
451
|
-
return (_jsx(ChatComposerRow, { isWorking: props.phase === 'streaming', workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs ?? [], pills: props.pills, onStop: props.onStop, hint: parts.hintNode, tray: parts.tray, attach: parts.attach, input: parts.input, editorRef: parts.editorRef, draftText: props.draftText, controls: parts.controls, record: parts.record, action: props.emptyAction !== undefined &&
|
|
451
|
+
return (_jsx(ChatComposerRow, { isWorking: props.phase === 'streaming', workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs ?? [], pills: props.pills, renderPillWords: props.renderPillWords, onStop: props.onStop, hint: parts.hintNode, tray: parts.tray, attach: parts.attach, input: parts.input, editorRef: parts.editorRef, draftText: props.draftText, controls: parts.controls, record: parts.record, action: props.emptyAction !== undefined &&
|
|
452
452
|
composerShowsEmptyAction({
|
|
453
453
|
hasPayload: parts.hasPayload,
|
|
454
454
|
primary: parts.primary,
|
package/ui/ChatComposerRow.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ChatComposerStatus } from '@astryxdesign/core/Chat';
|
|
|
2
2
|
import { type ReactNode, type RefObject } from 'react';
|
|
3
3
|
import type { BackgroundJob } from '../client/transcript-groups.js';
|
|
4
4
|
/**
|
|
5
|
-
* The glyphs the row composer draws. Each one left out keeps Theorem's.
|
|
5
|
+
* The glyphs the row composer draws. Each one left out keeps Theorem's; `null` draws none.
|
|
6
6
|
* Text is in the labels (`@theorem.composer.pill.*`, `@theorem.composer.tray.*`); sizes, colours,
|
|
7
7
|
* radii and spacing are the `--theorem-composer-*` CSS properties.
|
|
8
8
|
*/
|
|
@@ -14,6 +14,12 @@ export type ComposerRowIcons = {
|
|
|
14
14
|
/** In the working pill's stop button. Default: a filled square. */
|
|
15
15
|
stop?: ReactNode;
|
|
16
16
|
};
|
|
17
|
+
/** The words of one of Theorem's pills, as `renderPillWords` is given them. */
|
|
18
|
+
export type ComposerPillWords = {
|
|
19
|
+
/** Whose words: the working pill's, or a background job's. */
|
|
20
|
+
pill: 'working' | 'background';
|
|
21
|
+
words: string;
|
|
22
|
+
};
|
|
17
23
|
/**
|
|
18
24
|
* A pill the app puts in the pill row after Theorem's own, drawn as they are: its icon, its words,
|
|
19
25
|
* and what a click does. One without `icon` has words only; one without `onSelect` only shows.
|
|
@@ -40,6 +46,8 @@ export type ComposerRowParts = {
|
|
|
40
46
|
backgroundJobs: readonly BackgroundJob[];
|
|
41
47
|
/** The app's own pills, after the background jobs. */
|
|
42
48
|
pills?: readonly ComposerPill[];
|
|
49
|
+
/** Draws the words of the working pill and of each background job's. */
|
|
50
|
+
renderPillWords?: (said: ComposerPillWords) => ReactNode;
|
|
43
51
|
onStop: () => void;
|
|
44
52
|
/** Contextual hint, at the end of the pill row. */
|
|
45
53
|
hint?: ReactNode;
|
package/ui/ChatComposerRow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Badge } from '@astryxdesign/core/Badge';
|
|
3
3
|
import { Card } from '@astryxdesign/core/Card';
|
|
4
4
|
import { useCollapsible } from '@astryxdesign/core/Collapsible';
|
|
@@ -15,6 +15,20 @@ import { useId, useLayoutEffect, useState, } from 'react';
|
|
|
15
15
|
import { useSecondTicker } from "../hooks/use-second-ticker.js";
|
|
16
16
|
import { liveDuration, toolNameLabel } from "./labels.js";
|
|
17
17
|
import { useLabels } from "./labels-provider.js";
|
|
18
|
+
/** The words of a pill the app draws, and the pill's own label for screen readers. */
|
|
19
|
+
function pillWords(said, render, after) {
|
|
20
|
+
if (!render)
|
|
21
|
+
return { label: said.words, endContent: after };
|
|
22
|
+
return {
|
|
23
|
+
label: said.words,
|
|
24
|
+
isLabelHidden: true,
|
|
25
|
+
endContent: (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: render(said) }), after] })),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** An icon the host left out is Theorem's; `null` is none. */
|
|
29
|
+
function pillIcon(icon, fallback) {
|
|
30
|
+
return icon === undefined ? fallback : icon;
|
|
31
|
+
}
|
|
18
32
|
/**
|
|
19
33
|
* A `--theorem-composer-*` property, or Theorem's value when the page sets none.
|
|
20
34
|
* why: Inline styles beat Astryx's own, so every look the row has goes through one of these and
|
|
@@ -93,14 +107,14 @@ const TRAY_CONTENT = {
|
|
|
93
107
|
* why: It counts from the chat's turn clock, the one the transcript's status line reads, so the
|
|
94
108
|
* two agree and a wait on approval does not count.
|
|
95
109
|
*/
|
|
96
|
-
function WorkingPill({ since, icons, onStop, }) {
|
|
110
|
+
function WorkingPill({ since, icons, renderPillWords, onStop, }) {
|
|
97
111
|
const t = useLabels();
|
|
98
112
|
const now = useSecondTicker(since !== undefined);
|
|
99
113
|
const stop = t('@theorem.composer.pill.stop');
|
|
100
114
|
const label = since === undefined
|
|
101
115
|
? t('@theorem.composer.pill.working')
|
|
102
116
|
: t('@theorem.composer.pill.working_for', { duration: liveDuration(t, now - since) });
|
|
103
|
-
return (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "working", style: WORKING_PILL,
|
|
117
|
+
return (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "working", style: WORKING_PILL, ...pillWords({ pill: 'working', words: label }, renderPillWords, _jsx(IconButton, { label: stop, tooltip: stop, size: "sm", variant: "secondary", icon: icons?.stop ?? _jsx(IconPlayerStopFilled, { size: 12 }), onClick: onStop })), icon: pillIcon(icons?.working, _jsx(Spinner, { size: "sm", shade: "inherit", "aria-label": label })) }));
|
|
104
118
|
}
|
|
105
119
|
/**
|
|
106
120
|
* The pill row. One pill sits centred over the composer (see `pill-align`); with more, the working
|
|
@@ -109,10 +123,13 @@ function WorkingPill({ since, icons, onStop, }) {
|
|
|
109
123
|
function PillRow(props) {
|
|
110
124
|
const t = useLabels();
|
|
111
125
|
const pills = [
|
|
112
|
-
props.isWorking ? (_jsx(WorkingPill, { since: props.workingSince, icons: props.icons, onStop: props.onStop }, "working")) : null,
|
|
113
|
-
...props.backgroundJobs.map((job) => (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "background", style: PILL,
|
|
114
|
-
|
|
115
|
-
:
|
|
126
|
+
props.isWorking ? (_jsx(WorkingPill, { since: props.workingSince, icons: props.icons, renderPillWords: props.renderPillWords, onStop: props.onStop }, "working")) : null,
|
|
127
|
+
...props.backgroundJobs.map((job) => (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "background", style: PILL, ...pillWords({
|
|
128
|
+
pill: 'background',
|
|
129
|
+
words: job.unlabelledTool === undefined
|
|
130
|
+
? job.label
|
|
131
|
+
: toolNameLabel(t, job.unlabelledTool, job.label),
|
|
132
|
+
}, props.renderPillWords), description: t('@theorem.composer.pill.background'), icon: pillIcon(props.icons?.backgroundJob, _jsx(Spinner, { size: "sm", shade: "inherit", "aria-label": t('@theorem.composer.pill.background') })) }, job.callId))),
|
|
116
133
|
...(props.pills ?? []).map((pill) => (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "app", style: PILL, label: pill.label, icon: pill.icon, onClick: pill.onSelect }, pill.id))),
|
|
117
134
|
].filter(Boolean);
|
|
118
135
|
if (pills.length === 0 && !props.hint)
|
|
@@ -216,5 +233,5 @@ function RowStatus({ status, renderStatus }) {
|
|
|
216
233
|
*/
|
|
217
234
|
export function ChatComposerRow(props) {
|
|
218
235
|
const stacked = useWrapped(props.editorRef, props.draftText);
|
|
219
|
-
return (_jsxs(VStack, { gap: 0, width: "100%", className: "theorem-composer-row", style: { gap: GAP }, children: [_jsx(PillRow, { isWorking: props.isWorking, workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs, pills: props.pills, onStop: props.onStop, hint: props.hint }), props.tray ? _jsx(RowTray, { tray: props.tray }) : null, _jsx(RowStatus, { status: props.status, renderStatus: props.renderStatus }), _jsx(RowSurface, { stacked: stacked, attach: props.attach, input: props.input, controls: props.controls, record: props.record, action: props.action })] }));
|
|
236
|
+
return (_jsxs(VStack, { gap: 0, width: "100%", className: "theorem-composer-row", style: { gap: GAP }, children: [_jsx(PillRow, { isWorking: props.isWorking, workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs, pills: props.pills, renderPillWords: props.renderPillWords, onStop: props.onStop, hint: props.hint }), props.tray ? _jsx(RowTray, { tray: props.tray }) : null, _jsx(RowStatus, { status: props.status, renderStatus: props.renderStatus }), _jsx(RowSurface, { stacked: stacked, attach: props.attach, input: props.input, controls: props.controls, record: props.record, action: props.action })] }));
|
|
220
237
|
}
|
package/ui/ChatTranscript.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ChatMessageStatus } from '@astryxdesign/core/Chat';
|
|
2
|
-
import type { LabelOverrides } from '@theoremjs/agents';
|
|
2
|
+
import type { ErrorKind, LabelOverrides } from '@theoremjs/agents';
|
|
3
3
|
import type { UserRef } from '@theoremjs/agents/interface';
|
|
4
4
|
import { type TranscriptBlock } from '@theoremjs/agents/interface';
|
|
5
5
|
import type { JsonObject } from '@theoremjs/agents/kernel';
|
|
@@ -67,6 +67,11 @@ export type ChatTranscriptProps<Host extends JsonObject = JsonObject> = {
|
|
|
67
67
|
stepLayout?: StepLayout;
|
|
68
68
|
/** Whether a finished tool call's row shows how long it ran. Default: true. */
|
|
69
69
|
showToolDurations?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The failure kinds whose failed tool call row says why, after the call's failed label. Default:
|
|
72
|
+
* every kind. Leave a kind out when the label says enough and the person has nothing to do.
|
|
73
|
+
*/
|
|
74
|
+
toolFailureReasonKinds?: readonly ErrorKind[];
|
|
70
75
|
/**
|
|
71
76
|
* Whether a reply shows its work status ("Working for 12s", "Worked for 3.5s"). Default: true.
|
|
72
77
|
* With `false`, a reply whose steps fold under the status keeps it as the fold's trigger, without
|
|
@@ -79,6 +84,8 @@ export type ChatTranscriptProps<Host extends JsonObject = JsonObject> = {
|
|
|
79
84
|
* picked up where it left off."). Default: true.
|
|
80
85
|
*/
|
|
81
86
|
showResumedNotice?: boolean;
|
|
87
|
+
/** When a reply shows its name. Default: `'at-start'`. */
|
|
88
|
+
nameAppears?: NameAppears;
|
|
82
89
|
/** The profile's labels (`iface.labels`): a stopped turn says why in its words. */
|
|
83
90
|
labels?: LabelOverrides;
|
|
84
91
|
/**
|
|
@@ -96,6 +103,11 @@ export type ChatTranscriptProps<Host extends JsonObject = JsonObject> = {
|
|
|
96
103
|
*/
|
|
97
104
|
turnTimeOf?: (host: Host) => number | undefined;
|
|
98
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* `'at-start'`: as soon as the reply starts. `'with-content'`: once the reply has something to
|
|
108
|
+
* show: its work status, a call, a gate, words, media, or an image's placeholder.
|
|
109
|
+
*/
|
|
110
|
+
export type NameAppears = 'at-start' | 'with-content';
|
|
99
111
|
/** Image-profile display: `ratio` is the profile's pinned aspect ratio, if any. */
|
|
100
112
|
export type ImageOutput = {
|
|
101
113
|
ratio?: number;
|
package/ui/ChatTranscript.js
CHANGED
|
@@ -42,10 +42,18 @@ const ShowUsage = createContext(false);
|
|
|
42
42
|
const ShowToolData = createContext(true);
|
|
43
43
|
/** Whether a finished tool call's row shows how long it ran (`ChatTranscriptProps.showToolDurations`). */
|
|
44
44
|
const ShowToolDurations = createContext(true);
|
|
45
|
+
/** The kinds whose failed row says why; every kind when none are named (`toolFailureReasonKinds`). */
|
|
46
|
+
const ToolFailureReasonKinds = createContext(undefined);
|
|
45
47
|
/** Whether a reply shows its work status (`ChatTranscriptProps.showWorkStatus`). */
|
|
46
48
|
const ShowWorkStatus = createContext(true);
|
|
47
49
|
/** Whether a reply that went on after its call failed shows its notice (`ChatTranscriptProps.showResumedNotice`). */
|
|
48
50
|
const ShowResumedNotice = createContext(true);
|
|
51
|
+
/** When a reply shows its name (`ChatTranscriptProps.nameAppears`). */
|
|
52
|
+
const NameTiming = createContext('at-start');
|
|
53
|
+
/** The app's stand-ins for what the transcript draws (`ChatTranscriptProps.slots`). */
|
|
54
|
+
const AppSlots = createContext({});
|
|
55
|
+
/** Whether the reply being drawn is on its way. */
|
|
56
|
+
const ReplyStreaming = createContext(false);
|
|
49
57
|
/** What the app draws under each reply (`ChatTranscriptProps.slots.reply`). */
|
|
50
58
|
const ReplySlot = createContext(undefined);
|
|
51
59
|
/** What the app draws in each message's details (`ChatTranscriptProps.slots.details`). */
|
|
@@ -56,6 +64,7 @@ function useToolRowShows() {
|
|
|
56
64
|
usage: useContext(ShowUsage),
|
|
57
65
|
detail: useContext(ShowToolData),
|
|
58
66
|
duration: useContext(ShowToolDurations),
|
|
67
|
+
reasonKinds: useContext(ToolFailureReasonKinds),
|
|
59
68
|
};
|
|
60
69
|
}
|
|
61
70
|
/** Largest a generated image renders in the transcript. */
|
|
@@ -460,7 +469,9 @@ function Sources({ citations }) {
|
|
|
460
469
|
*/
|
|
461
470
|
function StreamedMarkdown({ text, streaming, density, components, }) {
|
|
462
471
|
const plugins = useMarkdownPlugins();
|
|
463
|
-
|
|
472
|
+
const draw = useContext(AppSlots).markdown;
|
|
473
|
+
const markdown = { isStreaming: streaming, density, components, plugins, children: text };
|
|
474
|
+
return draw ? draw(markdown) : _jsx(Markdown, { ...markdown });
|
|
464
475
|
}
|
|
465
476
|
function BodyBlock({ block, streaming }) {
|
|
466
477
|
if (block.kind === 'text')
|
|
@@ -491,7 +502,10 @@ function ResultBlock({ block }) {
|
|
|
491
502
|
// whole tool call (row and expanded detail) uses the body font instead.
|
|
492
503
|
const CODE_FONT_AS_BODY = { '--font-family-code': 'var(--font-family-body)' };
|
|
493
504
|
function ToolCalls({ calls }) {
|
|
494
|
-
|
|
505
|
+
const draw = useContext(AppSlots).toolCalls;
|
|
506
|
+
const streaming = useContext(ReplyStreaming);
|
|
507
|
+
const list = { calls, style: CODE_FONT_AS_BODY };
|
|
508
|
+
return draw ? draw({ list, streaming }) : _jsx(ChatToolCalls, { ...list });
|
|
495
509
|
}
|
|
496
510
|
/** A call's detail: what it ran with, then what came back. */
|
|
497
511
|
function toolDetail(t, tool, result) {
|
|
@@ -502,7 +516,7 @@ function toolDetail(t, tool, result) {
|
|
|
502
516
|
function ToolSteps({ steps }) {
|
|
503
517
|
const t = useLabels();
|
|
504
518
|
const shows = useToolRowShows();
|
|
505
|
-
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
|
|
519
|
+
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, shows)) })] }));
|
|
506
520
|
}
|
|
507
521
|
/** How long a finished call ran, when the transcript shows it and both ends were seen. */
|
|
508
522
|
function toolDuration(t, tool, shows) {
|
|
@@ -536,14 +550,19 @@ function failedToolItem(t, base, tool, state, shows) {
|
|
|
536
550
|
return {
|
|
537
551
|
...base,
|
|
538
552
|
status: 'error',
|
|
539
|
-
|
|
553
|
+
...(shows.reasonKinds?.includes(state.failure.kind) === false
|
|
554
|
+
? {}
|
|
555
|
+
: { target: said, errorMessage: said }),
|
|
540
556
|
...toolUsageStats(state, shows),
|
|
541
|
-
errorMessage: said,
|
|
542
557
|
...rowDetail(t, tool, shows, _jsx(ShapedData, { value: failureDetail(state.failure), title: t('@theorem.transcript.tool_error') })),
|
|
543
558
|
};
|
|
544
559
|
}
|
|
545
|
-
function toolCallItem(t,
|
|
546
|
-
|
|
560
|
+
function toolCallItem(t, tool, shows) {
|
|
561
|
+
// why: Not the block id: the saved reply re-mints those, and a row would be drawn anew.
|
|
562
|
+
const base = {
|
|
563
|
+
key: tool.operationId ?? tool.callId,
|
|
564
|
+
name: toolCallLabel(tool, (name) => toolNameLabel(t, name)),
|
|
565
|
+
};
|
|
547
566
|
const { state } = tool;
|
|
548
567
|
switch (state?.phase) {
|
|
549
568
|
case 'error':
|
|
@@ -574,7 +593,7 @@ function toolCallItem(t, id, tool, shows) {
|
|
|
574
593
|
function ToolRun({ blocks }) {
|
|
575
594
|
const t = useLabels();
|
|
576
595
|
const shows = useToolRowShows();
|
|
577
|
-
return _jsx(ToolCalls, { calls: blocks.map((block) => toolCallItem(t, block.
|
|
596
|
+
return _jsx(ToolCalls, { calls: blocks.map((block) => toolCallItem(t, block.tool, shows)) });
|
|
578
597
|
}
|
|
579
598
|
/**
|
|
580
599
|
* Thinking reads as quieter text than the reply. Astryx has no reasoning
|
|
@@ -612,7 +631,7 @@ function TraceList({ items, streaming }) {
|
|
|
612
631
|
};
|
|
613
632
|
for (const [i, item] of items.entries()) {
|
|
614
633
|
if (item.kind === 'tool') {
|
|
615
|
-
tools.push(toolCallItem(t, item.
|
|
634
|
+
tools.push(toolCallItem(t, item.block.tool, shows));
|
|
616
635
|
continue;
|
|
617
636
|
}
|
|
618
637
|
flush();
|
|
@@ -694,9 +713,30 @@ function PendingImage(props) {
|
|
|
694
713
|
return null;
|
|
695
714
|
return _jsx(GeneratingImage, { ratio: props.imageOutput.ratio });
|
|
696
715
|
}
|
|
716
|
+
/** Whether a body row puts anything on screen: words that are still empty do not. */
|
|
717
|
+
function rowDraws(row) {
|
|
718
|
+
if (row.kind !== 'block')
|
|
719
|
+
return true;
|
|
720
|
+
const { block } = row;
|
|
721
|
+
return !(block.kind === 'text' || block.kind === 'thought') || block.text.trim() !== '';
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Whether a reply shows its name yet. A reply that has stopped always does: its notice, time,
|
|
725
|
+
* or the app's part under it belongs to a named message.
|
|
726
|
+
*/
|
|
727
|
+
function useNameShown(reply) {
|
|
728
|
+
const appears = useContext(NameTiming);
|
|
729
|
+
if (appears === 'at-start' || !reply.streaming)
|
|
730
|
+
return true;
|
|
731
|
+
return (reply.status !== '' ||
|
|
732
|
+
reply.gated ||
|
|
733
|
+
reply.imageOutput !== undefined ||
|
|
734
|
+
reply.rows.some(rowDraws));
|
|
735
|
+
}
|
|
697
736
|
function AssistantTurn(props) {
|
|
698
737
|
const t = useLabels();
|
|
699
738
|
const replySlot = useContext(ReplySlot);
|
|
739
|
+
const drawName = useContext(AppSlots).name;
|
|
700
740
|
const chrome = useChromeReveal(props.isNewest === true);
|
|
701
741
|
const showUsage = useContext(ShowUsage);
|
|
702
742
|
const showResumed = useContext(ShowResumedNotice);
|
|
@@ -719,12 +759,25 @@ function AssistantTurn(props) {
|
|
|
719
759
|
folds: hasTrace,
|
|
720
760
|
}));
|
|
721
761
|
const copyText = assistantTurnCopyText(body.length > 0 ? body : props.blocks);
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
762
|
+
const named = useNameShown({
|
|
763
|
+
streaming: props.streaming,
|
|
764
|
+
status,
|
|
765
|
+
gated: gatedTools.length > 0,
|
|
766
|
+
rows,
|
|
767
|
+
imageOutput: props.imageOutput,
|
|
768
|
+
});
|
|
769
|
+
return (_jsx(ChatMessage, { sender: "assistant", name: named
|
|
770
|
+
? (drawName?.({ handle: props.handle, streaming: props.streaming }) ?? props.handle)
|
|
771
|
+
: undefined, ...chrome.handlers, metadata: props.streaming ? undefined : (_jsx(MessageChrome, { sender: "assistant", blocks: props.blocks, host: props.host ?? [], at: props.at, copyText: copyText, error: props.error, stopped: props.stopped, resumed: resumed, usage: showUsage ? props.usage : undefined, revealed: chrome.revealed })), children: _jsx(ReplyStreaming.Provider, { value: props.streaming, 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'
|
|
772
|
+
? row.kind
|
|
773
|
+
: row.block.kind).map(({ item: row, index: i, key }) => (_jsx(BodyRowView
|
|
774
|
+
// why: Not the block id: the committed turn re-mints ids, and a
|
|
775
|
+
// remount would cut the text reveal short.
|
|
776
|
+
, { row: row, streaming: props.streaming && i === rows.length - 1, imageOutput: props.imageOutput }, key))), _jsx(PendingImage, { imageOutput: props.imageOutput, streaming: props.streaming, rows: rows }), replySlot?.({
|
|
777
|
+
blocks: props.blocks,
|
|
778
|
+
host: props.host ?? [],
|
|
779
|
+
streaming: props.streaming,
|
|
780
|
+
})] }) }) }));
|
|
728
781
|
}
|
|
729
782
|
/** The notice of a reply that went on after its model call failed part-way, if it did. */
|
|
730
783
|
function resumedNotice(blocks) {
|
|
@@ -768,7 +821,7 @@ export function ChatTranscript(props) {
|
|
|
768
821
|
const turnKeyOf = keyOf ? (host) => keyOf(host) : undefined;
|
|
769
822
|
const dateOf = props.turnTimeOf;
|
|
770
823
|
const turnTimeOf = dateOf ? (host) => dateOf(host) : undefined;
|
|
771
|
-
return (_jsx(TheoremLabelsProvider, { children: _jsx(ReplySlot.Provider, { value: replySlot, children: _jsx(DetailsSlot.Provider, { value: detailsSlot, children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(RenderRef.Provider, { value: props.renderRef, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ShowToolDurations.Provider, { value: props.showToolDurations !== false, children: _jsx(ShowWorkStatus.Provider, { value: props.showWorkStatus !== false, children: _jsx(ShowResumedNotice.Provider, { value: props.showResumedNotice !== false, children: _jsx(ChatTranscriptBody, { ...props, turnKeyOf: turnKeyOf, turnTimeOf: turnTimeOf }) }) }) }) }) }) }) }) }) }));
|
|
824
|
+
return (_jsx(TheoremLabelsProvider, { children: _jsx(AppSlots.Provider, { value: props.slots ?? {}, children: _jsx(ReplySlot.Provider, { value: replySlot, children: _jsx(DetailsSlot.Provider, { value: detailsSlot, children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(RenderRef.Provider, { value: props.renderRef, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ShowToolDurations.Provider, { value: props.showToolDurations !== false, children: _jsx(ToolFailureReasonKinds.Provider, { value: props.toolFailureReasonKinds, children: _jsx(ShowWorkStatus.Provider, { value: props.showWorkStatus !== false, children: _jsx(ShowResumedNotice.Provider, { value: props.showResumedNotice !== false, children: _jsx(NameTiming.Provider, { value: props.nameAppears ?? 'at-start', children: _jsx(ChatTranscriptBody, { ...props, turnKeyOf: turnKeyOf, turnTimeOf: turnTimeOf }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
772
825
|
}
|
|
773
826
|
function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, turnKeyOf, turnTimeOf, }) {
|
|
774
827
|
const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers)), turnKeyOf), [blocks, dividers, turnKeyOf]);
|
package/ui/TheoremChat.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { type ReactNode, type Ref } from 'react';
|
|
|
9
9
|
import { type SendTextOptions, type SentTurn, type TheoremChatState, type UseTheoremChatOptions } from '../hooks/use-theorem-chat.js';
|
|
10
10
|
import type { ComposerInputComponent } from './ChatComposerBar.js';
|
|
11
11
|
import { type ComposerLayout } from './ChatComposerBar.js';
|
|
12
|
-
import type { ComposerPill, ComposerRowIcons } from './ChatComposerRow.js';
|
|
12
|
+
import type { ComposerPill, ComposerPillWords, ComposerRowIcons } from './ChatComposerRow.js';
|
|
13
13
|
import { type ChatTranscriptProps } from './ChatTranscript.js';
|
|
14
14
|
import type { TheoremLabels } from './labels.js';
|
|
15
15
|
import type { MediaViewer } from './media-viewer.js';
|
|
@@ -162,6 +162,8 @@ export type TheoremChatProps<Host extends JsonObject = JsonObject> = {
|
|
|
162
162
|
composerEmptyAction?: ReactNode;
|
|
163
163
|
/** Draws the composer's problem in place of Theorem's; see `ChatComposerBarProps.renderStatus`. */
|
|
164
164
|
renderComposerStatus?: (status: ChatComposerStatus) => ReactNode;
|
|
165
|
+
/** Draws the words of the composer's pills; see `ChatComposerBarProps.renderPillWords`. */
|
|
166
|
+
renderComposerPillWords?: (said: ComposerPillWords) => ReactNode;
|
|
165
167
|
/**
|
|
166
168
|
* The transcript's own options, given to {@link TheoremChatTranscript} as they are: its `slots`,
|
|
167
169
|
* such as the `reply` slot, its `turnKeyOf`, and how it lays out a reply. `Host` is the type of
|
|
@@ -220,13 +222,15 @@ export type TheoremChatComposerProps = {
|
|
|
220
222
|
emptyAction?: ReactNode;
|
|
221
223
|
/** Draws the composer's problem in place of Theorem's; see `ChatComposerBarProps.renderStatus`. */
|
|
222
224
|
renderStatus?: (status: ChatComposerStatus) => ReactNode;
|
|
225
|
+
/** Draws the words of the composer's pills; see `ChatComposerBarProps.renderPillWords`. */
|
|
226
|
+
renderPillWords?: (said: ComposerPillWords) => ReactNode;
|
|
223
227
|
};
|
|
224
228
|
/**
|
|
225
229
|
* The composer bound to a chat: drafts, files, voice, the pending queue, send and stop, and the
|
|
226
230
|
* working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
|
|
227
231
|
* `TheoremChatTranscript`.
|
|
228
232
|
*/
|
|
229
|
-
export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, renderStatus, }: TheoremChatComposerProps): import("react").JSX.Element;
|
|
233
|
+
export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, renderStatus, renderPillWords, }: TheoremChatComposerProps): import("react").JSX.Element;
|
|
230
234
|
export type TheoremChatTranscriptProps<Host extends JsonObject = JsonObject> = Omit<ChatTranscriptProps<Host>, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
|
|
231
235
|
/** The chat it shows (`useTheoremChat`). */
|
|
232
236
|
chat: TheoremChatState;
|
package/ui/TheoremChat.js
CHANGED
|
@@ -33,8 +33,8 @@ function ChatColumn({ maxWidth, ref, children, }) {
|
|
|
33
33
|
* working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
|
|
34
34
|
* `TheoremChatTranscript`.
|
|
35
35
|
*/
|
|
36
|
-
export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, renderStatus, }) {
|
|
37
|
-
return (_jsx(ChatComposerBar, { emptyAction: emptyAction, renderStatus: renderStatus, iface: iface, layout: layout, icons: icons, pills: pills, workingSince: chat.workingSince, backgroundJobs: chat.backgroundJobs, draftText: chat.draftText, pendingFiles: chat.pendingFiles, pendingVoice: chat.pendingVoice, pendingMessages: chat.pendingMessages, issues: chat.issues, phase: chat.phase, failure: chat.failure, selectedModel: chat.session.selectedModel, selectedEffort: chat.session.selectedEffort, placeholder: placeholder, inputRef: inputRef, inputComponent: inputComponent, triggers: triggers, refText: refText, renderRef: renderRef, draftParts: chat.draftParts, onDraftPartsChange: chat.setDraftParts, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
|
|
36
|
+
export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, renderStatus, renderPillWords, }) {
|
|
37
|
+
return (_jsx(ChatComposerBar, { emptyAction: emptyAction, renderStatus: renderStatus, renderPillWords: renderPillWords, iface: iface, layout: layout, icons: icons, pills: pills, workingSince: chat.workingSince, backgroundJobs: chat.backgroundJobs, draftText: chat.draftText, pendingFiles: chat.pendingFiles, pendingVoice: chat.pendingVoice, pendingMessages: chat.pendingMessages, issues: chat.issues, phase: chat.phase, failure: chat.failure, selectedModel: chat.session.selectedModel, selectedEffort: chat.session.selectedEffort, placeholder: placeholder, inputRef: inputRef, inputComponent: inputComponent, triggers: triggers, refText: refText, renderRef: renderRef, draftParts: chat.draftParts, onDraftPartsChange: chat.setDraftParts, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
|
|
38
38
|
chat.setPendingFiles((prev) => [...prev, ...files]);
|
|
39
39
|
chat.setIssues([]);
|
|
40
40
|
}, onAttachmentRemove: (index) => {
|
|
@@ -71,7 +71,7 @@ function useChatHandle(chatRef, chat) {
|
|
|
71
71
|
/** The composer, or, with none, the failed turn's error where the composer was. */
|
|
72
72
|
function ChatBodyComposer({ body, chat, inputRef, }) {
|
|
73
73
|
if (body.composer ?? true)
|
|
74
|
-
return (_jsx(TheoremChatComposer, { chat: chat, iface: body.iface, placeholder: body.placeholder, inputRef: inputRef, layout: body.composerLayout, icons: body.composerIcons, inputComponent: body.composerInput, triggers: body.composerTriggers, refText: body.refText, renderRef: body.renderRef, emptyAction: body.composerEmptyAction, renderStatus: body.renderComposerStatus }));
|
|
74
|
+
return (_jsx(TheoremChatComposer, { chat: chat, iface: body.iface, placeholder: body.placeholder, inputRef: inputRef, layout: body.composerLayout, icons: body.composerIcons, inputComponent: body.composerInput, triggers: body.composerTriggers, refText: body.refText, renderRef: body.renderRef, emptyAction: body.composerEmptyAction, renderStatus: body.renderComposerStatus, renderPillWords: body.renderComposerPillWords }));
|
|
75
75
|
const failure = chat.failure;
|
|
76
76
|
return failure ? _jsx(Banner, { status: "error", role: "alert", title: failure.error }) : null;
|
|
77
77
|
}
|
package/ui/index.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ export { InkWaveform, type InkWaveformProps, type InkWaveLevels, } from '../comp
|
|
|
16
16
|
export { type LiveCall, type LiveCallInput, useLiveCall, } from '../components/live/use-live-call.js';
|
|
17
17
|
export { theoremTheme } from './built/theorem.js';
|
|
18
18
|
export { ChatComposerBar, type ChatComposerBarProps, type ComposerInputComponent, type ComposerLayout, EFFORT_ICON, generationOptions, type LiveComposerBarProps, } from './ChatComposerBar.js';
|
|
19
|
-
export type { ComposerPill, ComposerRowIcons } from './ChatComposerRow.js';
|
|
20
|
-
export { ChatTranscript, type ChatTranscriptProps } from './ChatTranscript.js';
|
|
19
|
+
export type { ComposerPill, ComposerPillWords, ComposerRowIcons } from './ChatComposerRow.js';
|
|
20
|
+
export { ChatTranscript, type ChatTranscriptProps, type NameAppears, } from './ChatTranscript.js';
|
|
21
21
|
export { ConsoleFrame, type ConsoleFrameProps, type ConsolePageProps, RequestCard, ResponseColumn, RunBar, useBytes, } from './ConsoleFrame.js';
|
|
22
22
|
export { type RefTokenOptions, refToken } from './composer-refs.js';
|
|
23
23
|
export { TheoremDecisionAnswers, type TheoremDecisionAnswersProps } from './DecisionAnswers.js';
|
|
@@ -31,7 +31,7 @@ export { AstryxMediaViewer, type MediaViewer, type MediaViewerItem, type MediaVi
|
|
|
31
31
|
export { PaneFailure, PaneLoading, PaneState } from './PaneState.js';
|
|
32
32
|
export { RadialBars, Sunburst, type SunburstNode } from './RadialCharts.js';
|
|
33
33
|
export { type RankedBar, RankedBars } from './RankedBars.js';
|
|
34
|
-
export type { ChatDetailsSlot, ChatMessageDetails, ChatReply, ChatReplySlot, ChatTranscriptSlots, } from './reply-slot.js';
|
|
34
|
+
export type { ChatDetailsSlot, ChatMarkdownSlot, ChatMessageDetails, ChatNameSlot, ChatReply, ChatReplyName, ChatReplySlot, ChatToolCallList, ChatToolCallsSlot, ChatTranscriptSlots, } from './reply-slot.js';
|
|
35
35
|
export { InPlace, PaneLayout, PanePanel, Prose, RaisedPane } from './SidePanel.js';
|
|
36
36
|
export { DEFAULT_CHAT_MAX_WIDTH, TheoremChat, TheoremChatComposer, type TheoremChatComposerProps, type TheoremChatHandle, type TheoremChatProps, TheoremChatTranscript, type TheoremChatTranscriptOptions, type TheoremChatTranscriptProps, } from './TheoremChat.js';
|
|
37
37
|
export { TheoremDecision, type TheoremDecisionProps } from './TheoremDecision.js';
|
package/ui/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export { InkWaveform, } from "../components/InkWaveform.js";
|
|
|
18
18
|
export { useLiveCall, } from "../components/live/use-live-call.js";
|
|
19
19
|
export { theoremTheme } from './built/theorem.js';
|
|
20
20
|
export { ChatComposerBar, EFFORT_ICON, generationOptions, } from "./ChatComposerBar.js";
|
|
21
|
-
export { ChatTranscript } from "./ChatTranscript.js";
|
|
21
|
+
export { ChatTranscript, } from "./ChatTranscript.js";
|
|
22
22
|
export { ConsoleFrame, RequestCard, ResponseColumn, RunBar, useBytes, } from "./ConsoleFrame.js";
|
|
23
23
|
export { refToken } from "./composer-refs.js";
|
|
24
24
|
export { TheoremDecisionAnswers } from "./DecisionAnswers.js";
|
package/ui/reply-slot.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { ChatToolCallsProps } from '@astryxdesign/core/Chat';
|
|
2
|
+
import type { MarkdownProps } from '@astryxdesign/core/Markdown';
|
|
3
|
+
import type { MarkdownPluginEntry } from '@astryxdesign/core/Markdown/plugins';
|
|
1
4
|
import type { TranscriptBlock } from '@theoremjs/agents/interface';
|
|
2
5
|
import type { JsonObject } from '@theoremjs/agents/kernel';
|
|
3
6
|
import type { ReactNode } from 'react';
|
|
@@ -30,6 +33,31 @@ export type ChatMessageDetails<Host extends JsonObject = JsonObject> = {
|
|
|
30
33
|
};
|
|
31
34
|
/** Drawn in each message's details, right after its time. Unset or `null` draws nothing. */
|
|
32
35
|
export type ChatDetailsSlot<Host extends JsonObject = JsonObject> = null | ((message: ChatMessageDetails<Host>) => ReactNode);
|
|
36
|
+
/** A reply's name as the transcript's `name` slot is given it. */
|
|
37
|
+
export type ChatReplyName = {
|
|
38
|
+
handle: string;
|
|
39
|
+
/** `true` while the reply is on its way. */
|
|
40
|
+
streaming: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** Draws a reply's name. Unset draws the handle. */
|
|
43
|
+
export type ChatNameSlot = (name: ChatReplyName) => ReactNode;
|
|
44
|
+
/** A list of tool calls as the transcript's `toolCalls` slot is given it. */
|
|
45
|
+
export type ChatToolCallList = {
|
|
46
|
+
/**
|
|
47
|
+
* What the transcript gives Astryx's `ChatToolCalls`. A call's `key` is its operation id, or its
|
|
48
|
+
* call id, so it stays the same from the live reply to the saved one.
|
|
49
|
+
*/
|
|
50
|
+
list: ChatToolCallsProps;
|
|
51
|
+
/** `true` while the reply the calls belong to is on its way. */
|
|
52
|
+
streaming: boolean;
|
|
53
|
+
};
|
|
54
|
+
/** Draws a list of tool calls. Unset draws Astryx's `ChatToolCalls`. */
|
|
55
|
+
export type ChatToolCallsSlot = (calls: ChatToolCallList) => ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* Draws the words of a reply and of its thoughts, from what the transcript gives Astryx's
|
|
58
|
+
* `Markdown`. Unset draws Astryx's `Markdown`.
|
|
59
|
+
*/
|
|
60
|
+
export type ChatMarkdownSlot = (markdown: MarkdownProps<readonly MarkdownPluginEntry[]>) => ReactNode;
|
|
33
61
|
/** What the app draws in the transcript's slots. */
|
|
34
62
|
export type ChatTranscriptSlots<Host extends JsonObject = JsonObject> = {
|
|
35
63
|
/** Under each reply, inside its message. */
|
|
@@ -39,4 +67,10 @@ export type ChatTranscriptSlots<Host extends JsonObject = JsonObject> = {
|
|
|
39
67
|
* details show with the message's time and copy button; a reply on its way has none yet.
|
|
40
68
|
*/
|
|
41
69
|
details?: ChatDetailsSlot<Host>;
|
|
70
|
+
/** In place of a reply's name, where the name shows (`nameAppears`). */
|
|
71
|
+
name?: ChatNameSlot;
|
|
72
|
+
/** In place of each list of tool calls: in a reply, in its trace, and in an agent call's detail. */
|
|
73
|
+
toolCalls?: ChatToolCallsSlot;
|
|
74
|
+
/** In place of the Markdown of a reply's words and thoughts. */
|
|
75
|
+
markdown?: ChatMarkdownSlot;
|
|
42
76
|
};
|