@theoremjs/react 0.3.4 → 0.3.5-next.1001.g68d8dcf
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 +136 -6
- package/client/live/use-live-caption-log.d.ts +1 -1
- package/client/trace-story.d.ts +1 -1
- package/client/transcript-groups.d.ts +27 -4
- package/client/transcript-groups.js +45 -7
- package/components/InkWaveform.d.ts +1 -1
- package/components/live/use-live-call.d.ts +3 -3
- package/components/live/use-live-runner-controls.d.ts +2 -2
- package/components/live/use-live-runner-ui.d.ts +3 -3
- package/components/live/use-live-session-client.d.ts +2 -2
- package/components/use-composer-voice.d.ts +1 -1
- package/components/use-voice-playback.d.ts +1 -1
- package/hooks/use-embedding-index.d.ts +1 -1
- package/hooks/use-theorem-chat.d.ts +45 -44
- package/hooks/use-theorem-chat.js +10 -1
- package/hooks/use-theorem-decision.d.ts +1 -1
- package/hooks/use-theorem-embedding.d.ts +1 -1
- package/hooks/use-theorem-host.d.ts +1 -1
- package/hooks/use-turn-clock.d.ts +19 -0
- package/hooks/use-turn-clock.js +71 -0
- package/index.d.ts +8 -6
- package/index.js +1 -0
- package/live.d.ts +4 -4
- package/package.json +5 -5
- package/ui/ChatComposerBar.d.ts +19 -0
- package/ui/ChatComposerBar.js +141 -50
- package/ui/ChatComposerRow.d.ts +66 -0
- package/ui/ChatComposerRow.js +196 -0
- package/ui/ChatTranscript.d.ts +31 -2
- package/ui/ChatTranscript.js +165 -90
- package/ui/ConsoleFrame.d.ts +2 -2
- package/ui/DecisionAnswers.d.ts +1 -1
- package/ui/DecisionAnswers.js +9 -6
- package/ui/DecisionImages.d.ts +4 -3
- package/ui/EmbeddingDocuments.d.ts +2 -2
- package/ui/EmbeddingQuery.d.ts +2 -2
- package/ui/EmbeddingResults.d.ts +3 -3
- package/ui/LiveCallTile.d.ts +2 -2
- package/ui/LiveCaptionsPanel.d.ts +1 -1
- package/ui/LiveRunner.d.ts +6 -4
- package/ui/LiveRunner.js +4 -4
- package/ui/LiveToolGateDialog.d.ts +1 -1
- package/ui/LiveVideoPreview.d.ts +1 -1
- package/ui/RadialCharts.d.ts +2 -2
- package/ui/RankedBars.d.ts +1 -1
- package/ui/SchemaFields.d.ts +1 -1
- package/ui/SchemaFields.js +56 -3
- package/ui/ShapedData.js +4 -4
- package/ui/StateFields.d.ts +1 -1
- package/ui/StateFields.js +3 -3
- package/ui/TheoremChat.d.ts +74 -4
- package/ui/TheoremChat.js +53 -33
- package/ui/TheoremDecision.d.ts +3 -3
- package/ui/TheoremEmbedding.d.ts +2 -2
- package/ui/TheoremHost.d.ts +16 -2
- package/ui/TheoremHost.js +6 -6
- package/ui/TheoremSurface.d.ts +22 -0
- package/ui/TheoremSurface.js +13 -0
- package/ui/ToolResult.js +8 -6
- package/ui/TraceCharts.d.ts +2 -2
- package/ui/TraceGuardrails.d.ts +2 -2
- package/ui/TraceInspectorPanel.d.ts +1 -1
- package/ui/TraceOverview.d.ts +2 -2
- package/ui/TraceSpanDetail.d.ts +1 -1
- package/ui/TraceStory.d.ts +2 -2
- package/ui/TraceValues.d.ts +2 -2
- package/ui/TraceWaterfall.d.ts +1 -1
- package/ui/approval-heading.d.ts +1 -1
- package/ui/built/theme.css +91 -41
- package/ui/built/theme.css.d.ts +2 -2
- package/ui/built/theorem.d.ts +2 -2
- package/ui/built/theorem.js +41 -19
- package/ui/built/theorem.variants.d.ts +2 -2
- package/ui/embedding-space-view.d.ts +1 -1
- package/ui/index.d.ts +33 -28
- package/ui/index.js +4 -1
- package/ui/labels-provider.d.ts +1 -1
- package/ui/labels.d.ts +70 -2
- package/ui/labels.js +68 -0
- package/ui/media-viewer.d.ts +34 -0
- package/ui/media-viewer.js +27 -0
- package/ui/tool-media-shown.d.ts +13 -0
- package/ui/tool-media-shown.js +15 -0
- package/ui/tool-media.d.ts +34 -0
- package/ui/tool-media.js +52 -0
- package/ui/trace-patterns.d.ts +1 -1
- package/ui/transcript-copy-text.d.ts +1 -1
- package/ui/transcript-copy-text.js +1 -1
package/ui/LiveRunner.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { DefinedTheme } from '@astryxdesign/core/theme';
|
|
2
|
-
import type { LiveCall } from '../components/live/use-live-call.
|
|
3
|
-
import { type TheoremLabels } from './labels.
|
|
4
|
-
|
|
2
|
+
import type { LiveCall } from '../components/live/use-live-call.js';
|
|
3
|
+
import { type TheoremLabels } from './labels.js';
|
|
4
|
+
import { type TheoremChatProps } from './TheoremChat.js';
|
|
5
|
+
/** `media`, `resolveMedia` and `mediaViewer` are the chat's: the captions show a tool's media as the chat does. */
|
|
6
|
+
export type LiveRunnerProps = Pick<TheoremChatProps, 'media' | 'resolveMedia' | 'mediaViewer'> & {
|
|
5
7
|
/** The call to draw, from `useLiveCall`. The call outlives the runner: it ends when its owner unmounts. */
|
|
6
8
|
call: LiveCall;
|
|
7
9
|
/** Astryx theme, as on `TheoremChat`. Omit to inherit the host's `<Theme>` or use `theoremTheme`. */
|
|
@@ -30,4 +32,4 @@ export type LiveRunnerProps = {
|
|
|
30
32
|
* in a toolbar, and tool gates in a dialog. Offers the trace inspector when
|
|
31
33
|
* the profile records traces.
|
|
32
34
|
*/
|
|
33
|
-
export declare function LiveRunner({ theme, mode, labels, ...props }: LiveRunnerProps): import("react").JSX.Element;
|
|
35
|
+
export declare function LiveRunner({ theme, mode, labels, media, resolveMedia, mediaViewer, ...props }: LiveRunnerProps): import("react").JSX.Element;
|
package/ui/LiveRunner.js
CHANGED
|
@@ -18,11 +18,11 @@ import { LiveCaptionsPanel } from "./LiveCaptionsPanel.js";
|
|
|
18
18
|
import { LiveToolGateDialog } from "./LiveToolGateDialog.js";
|
|
19
19
|
import { LiveVideoPreview } from "./LiveVideoPreview.js";
|
|
20
20
|
import { liveStateLabel } from "./labels.js";
|
|
21
|
-
import {
|
|
21
|
+
import { useLabels } from "./labels-provider.js";
|
|
22
22
|
import { PANEL_EDGE, SidePanel, SidePanelHeader, SidePanelToggle, useSidePanel, } from "./SidePanel.js";
|
|
23
23
|
import { DEFAULT_CHAT_MAX_WIDTH } from "./TheoremChat.js";
|
|
24
|
+
import { TheoremSurface } from "./TheoremSurface.js";
|
|
24
25
|
import { useTraceInspector, WithTrace } from "./TraceInspectorPanel.js";
|
|
25
|
-
import { TheoremThemeProvider } from "./theme.js";
|
|
26
26
|
/** The waveform's box: it rests on the stage floor rather than filling the stage. */
|
|
27
27
|
const WAVE_MAX_WIDTH = 720;
|
|
28
28
|
const WAVE_HEIGHT = 320;
|
|
@@ -33,8 +33,8 @@ const WAVE_HEIGHT = 320;
|
|
|
33
33
|
* in a toolbar, and tool gates in a dialog. Offers the trace inspector when
|
|
34
34
|
* the profile records traces.
|
|
35
35
|
*/
|
|
36
|
-
export function LiveRunner({ theme, mode, labels, ...props }) {
|
|
37
|
-
return (_jsx(
|
|
36
|
+
export function LiveRunner({ theme, mode, labels, media, resolveMedia, mediaViewer, ...props }) {
|
|
37
|
+
return (_jsx(TheoremSurface, { theme: theme, mode: mode, labels: labels, detectCodeLanguage: undefined, media: media, resolveMedia: resolveMedia, mediaViewer: mediaViewer, children: _jsx(LiveRunnerBody, { ...props }) }));
|
|
38
38
|
}
|
|
39
39
|
function LiveRunnerBody({ call, trace, onMinimize, }) {
|
|
40
40
|
const t = useLabels();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LiveCall } from '../components/live/use-live-call.
|
|
1
|
+
import type { LiveCall } from '../components/live/use-live-call.js';
|
|
2
2
|
/**
|
|
3
3
|
* Tool approvals and credential prompts, as a dialog that must be answered. It shows the card
|
|
4
4
|
* chat shows inline and nothing else, and closes on the answer. `LiveRunner` and
|
package/ui/LiveVideoPreview.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LiveFacingMode } from '../client/live/live-video.
|
|
1
|
+
import type { LiveFacingMode } from '../client/live/live-video.js';
|
|
2
2
|
/**
|
|
3
3
|
* The camera preview: atop the call's captions, or in its tile. The capture element comes
|
|
4
4
|
* from the session client, so it is mounted imperatively; it sits one level
|
package/ui/RadialCharts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type RankedBar } from './RankedBars.
|
|
2
|
-
import { type TraceFill } from './trace-patterns.
|
|
1
|
+
import { type RankedBar } from './RankedBars.js';
|
|
2
|
+
import { type TraceFill } from './trace-patterns.js';
|
|
3
3
|
/**
|
|
4
4
|
* One ring per row, the first outermost, each drawn round its track as far as its value goes, with
|
|
5
5
|
* a key beside it in the same order. `max` fixes the scale, for figures such as rates that share one.
|
package/ui/RankedBars.d.ts
CHANGED
package/ui/SchemaFields.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type JsonSchema } from '@theoremjs/web/client';
|
|
2
|
-
import { type Edit as StateEdit } from './StateFields.
|
|
2
|
+
import { type Edit as StateEdit } from './StateFields.js';
|
|
3
3
|
/**
|
|
4
4
|
* A tool's request as a form drawn from its input schema: each field the
|
|
5
5
|
* input its type asks for, labelled by its title or key and described by its
|
package/ui/SchemaFields.js
CHANGED
|
@@ -14,7 +14,7 @@ import { TextArea } from '@astryxdesign/core/TextArea';
|
|
|
14
14
|
import { TextInput } from '@astryxdesign/core/TextInput';
|
|
15
15
|
import { Tokenizer } from '@astryxdesign/core/Tokenizer';
|
|
16
16
|
import { VStack } from '@astryxdesign/core/VStack';
|
|
17
|
-
import { blankRow, isRow, json, schemaFields, withField, } from '@theoremjs/web/client';
|
|
17
|
+
import { blankRow, branchField, branchSample, branchValue, chosenBranch, inBranch, isRow, json, schemaControl, schemaFields, withField, } from '@theoremjs/web/client';
|
|
18
18
|
import { useState } from 'react';
|
|
19
19
|
import { useLabels } from "./labels-provider.js";
|
|
20
20
|
import { useKeyedRows } from "./row-keys.js";
|
|
@@ -90,6 +90,33 @@ function WordsField({ field, value, onChange }) {
|
|
|
90
90
|
? Number(item.label)
|
|
91
91
|
: item.label)) }));
|
|
92
92
|
}
|
|
93
|
+
/** The shapes to pick from: segments when they are few and short, else a menu. */
|
|
94
|
+
function BranchPicker({ label, labels, isMenu, value, onPick, }) {
|
|
95
|
+
if (isMenu) {
|
|
96
|
+
return _jsx(Selector, { label: label, size: "sm", options: labels, value: value, onChange: onPick });
|
|
97
|
+
}
|
|
98
|
+
return (_jsx(HStack, { children: _jsx(SegmentedControl, { label: label, size: "sm", value: value ?? '', onChange: onPick, children: labels.map((each) => (_jsx(SegmentedControlItem, { value: each, label: each }, each))) }) }));
|
|
99
|
+
}
|
|
100
|
+
/** A field that holds other fields, under its label and description. */
|
|
101
|
+
function FieldGroup({ field, children }) {
|
|
102
|
+
return (_jsx(Group, { label: field.label, isRequired: field.isRequired, description: field.description && _jsx(Description, { text: field.description }), children: children }));
|
|
103
|
+
}
|
|
104
|
+
/** Which shape a value takes, then what that shape asks for. Picking one starts it at its sample. */
|
|
105
|
+
function BranchFields({ label, branches, isMenu, value, onChange, }) {
|
|
106
|
+
const chosen = chosenBranch(branches, value);
|
|
107
|
+
const pick = (next) => {
|
|
108
|
+
const branch = branches.find((each) => each.label === next);
|
|
109
|
+
if (branch && branch !== chosen)
|
|
110
|
+
onChange(branchSample(branch));
|
|
111
|
+
};
|
|
112
|
+
const picker = (_jsx(BranchPicker, { label: label, labels: branches.map((branch) => branch.label), isMenu: isMenu, value: chosen?.label, onPick: pick }));
|
|
113
|
+
if (!chosen)
|
|
114
|
+
return picker;
|
|
115
|
+
const body = branchField(chosen);
|
|
116
|
+
const edit = (next) => onChange(inBranch(chosen, next));
|
|
117
|
+
const current = branchValue(chosen, value);
|
|
118
|
+
return (_jsxs(VStack, { gap: 3, children: [picker, body.control.kind === 'group' ? (_jsx(ObjectFields, { schema: body.control.schema, value: isRow(current) ? current : {}, onChange: edit })) : (_jsx(Field, { field: body, value: current, onChange: edit }))] }));
|
|
119
|
+
}
|
|
93
120
|
/** Each control's input, as the schema asks for it. */
|
|
94
121
|
const CONTROLS = {
|
|
95
122
|
choice: ({ field, control, value, onChange }) => (_jsx(ChoiceField, { field: field, options: control.options, isMenu: control.isMenu, value: value, onChange: onChange })),
|
|
@@ -103,18 +130,39 @@ const CONTROLS = {
|
|
|
103
130
|
: [], onChange: onChange, children: control.options.map((option) => (_jsx(CheckboxListItem, { label: option, value: option }, option))) })),
|
|
104
131
|
words: ({ field, value, onChange }) => (_jsx(WordsField, { field: field, value: value, onChange: onChange })),
|
|
105
132
|
rows: ({ field, control, value, onChange }) => (_jsx(RowsField, { field: field, item: control.item, value: value, onChange: onChange })),
|
|
106
|
-
group: ({ field, control, value, onChange }) => (_jsx(
|
|
133
|
+
group: ({ field, control, value, onChange }) => (_jsx(FieldGroup, { field: field, children: _jsx(ObjectFields, { schema: control.schema, value: isRow(value) ? value : {}, onChange: onChange }) })),
|
|
134
|
+
branches: ({ field, control, value, onChange }) => (_jsx(FieldGroup, { field: field, children: _jsx(BranchFields, { label: field.label, branches: control.branches, isMenu: control.isMenu, value: value, onChange: onChange }) })),
|
|
107
135
|
json: ({ field, value, onChange }) => (_jsx(JsonField, { field: field, value: value, onChange: onChange })),
|
|
108
136
|
};
|
|
109
137
|
function Field({ field, value, onChange }) {
|
|
138
|
+
if (field.isNullable)
|
|
139
|
+
return _jsx(NullableField, { field: field, value: value, onChange: onChange });
|
|
140
|
+
return _jsx(FieldInput, { field: field, value: value, onChange: onChange });
|
|
141
|
+
}
|
|
142
|
+
function FieldInput({ field, value, onChange }) {
|
|
110
143
|
const control = CONTROLS[field.control.kind];
|
|
111
144
|
const input = control({ field, control: field.control, value, onChange });
|
|
112
145
|
// why: A group already says its description under its name.
|
|
113
|
-
const isGroup = field.control.kind === 'rows' ||
|
|
146
|
+
const isGroup = field.control.kind === 'rows' ||
|
|
147
|
+
field.control.kind === 'group' ||
|
|
148
|
+
field.control.kind === 'branches';
|
|
114
149
|
if (!field.description || isGroup)
|
|
115
150
|
return input;
|
|
116
151
|
return (_jsxs(VStack, { gap: 1, children: [input, _jsx(Description, { text: field.description })] }));
|
|
117
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* A field that also takes null: its own input, and a switch that sends null instead. Turning the
|
|
155
|
+
* switch off leaves the field out, so null is sent only when asked for.
|
|
156
|
+
*/
|
|
157
|
+
function NullableField({ field, value, onChange }) {
|
|
158
|
+
const t = useLabels();
|
|
159
|
+
const isNull = value === null;
|
|
160
|
+
const toggle = (_jsx(Switch, { label: t('@theorem.decision.send_null'), value: isNull, onChange: (on) => onChange(on ? null : undefined) }));
|
|
161
|
+
if (isNull) {
|
|
162
|
+
return (_jsx(Labelled, { label: field.label, isRequired: field.isRequired, children: toggle }));
|
|
163
|
+
}
|
|
164
|
+
return (_jsxs(VStack, { gap: 1, children: [_jsx(FieldInput, { field: field, value: value, onChange: onChange }), toggle] }));
|
|
165
|
+
}
|
|
118
166
|
/** Room a short field takes: numbers, dates, menus, and one-line text sit side by side. */
|
|
119
167
|
const SHORT_FIELD_PX = 200;
|
|
120
168
|
/** Segments whose labels run this long in all still fit a short field's width. */
|
|
@@ -145,5 +193,10 @@ function ObjectFields({ schema, value, onChange, }) {
|
|
|
145
193
|
* description. Optional fields left empty aren't sent.
|
|
146
194
|
*/
|
|
147
195
|
export function SchemaFields({ schema, value, onChange, }) {
|
|
196
|
+
const t = useLabels();
|
|
197
|
+
const control = schemaControl(schema);
|
|
198
|
+
if (control.kind === 'branches') {
|
|
199
|
+
return (_jsx(BranchFields, { label: t('@theorem.decision.shape'), branches: control.branches, isMenu: control.isMenu, value: value, onChange: (next) => onChange(isRow(next) ? next : {}) }));
|
|
200
|
+
}
|
|
148
201
|
return _jsx(ObjectFields, { schema: schema, value: value, onChange: onChange });
|
|
149
202
|
}
|
package/ui/ShapedData.js
CHANGED
|
@@ -4,7 +4,6 @@ import { Collapsible, CollapsibleGroup } from '@astryxdesign/core/Collapsible';
|
|
|
4
4
|
import { HStack } from '@astryxdesign/core/HStack';
|
|
5
5
|
import { Icon } from '@astryxdesign/core/Icon';
|
|
6
6
|
import { useLocale } from '@astryxdesign/core/i18n';
|
|
7
|
-
import { useLightbox } from '@astryxdesign/core/Lightbox';
|
|
8
7
|
import { Link } from '@astryxdesign/core/Link';
|
|
9
8
|
import { List, ListItem } from '@astryxdesign/core/List';
|
|
10
9
|
import { Markdown } from '@astryxdesign/core/Markdown';
|
|
@@ -21,6 +20,7 @@ import { Component, useMemo, useState } from 'react';
|
|
|
21
20
|
import { Arrive, useArrive } from "./arrive.js";
|
|
22
21
|
import { useLabels } from "./labels-provider.js";
|
|
23
22
|
import { useMarkdownPlugins } from "./markdown-plugins.js";
|
|
23
|
+
import { useMediaViewer } from "./media-viewer.js";
|
|
24
24
|
import { keyedByContent } from "./row-keys.js";
|
|
25
25
|
import { VoiceNote } from "./VoiceNote.js";
|
|
26
26
|
/** Each way a plain value reads, drawn. */
|
|
@@ -140,12 +140,12 @@ function partSrc(part) {
|
|
|
140
140
|
function viewable(part) {
|
|
141
141
|
return part.type === 'image' || part.type === 'video';
|
|
142
142
|
}
|
|
143
|
-
/** A list of parts in its own order; every image and video opens in one
|
|
143
|
+
/** A list of parts in its own order; every image and video opens in one viewer, so the arrows walk them all. */
|
|
144
144
|
function Parts({ parts }) {
|
|
145
145
|
const t = useLabels();
|
|
146
146
|
const shown = parts.slice(0, MAX_ROWS);
|
|
147
147
|
const media = [];
|
|
148
|
-
/** Each viewable part's place in the
|
|
148
|
+
/** Each viewable part's place in the viewer, by its place in the list. */
|
|
149
149
|
const slides = new Map();
|
|
150
150
|
shown.forEach((part, index) => {
|
|
151
151
|
if (!viewable(part))
|
|
@@ -156,7 +156,7 @@ function Parts({ parts }) {
|
|
|
156
156
|
});
|
|
157
157
|
media.push({ src: partSrc(part), alt, type: part.type });
|
|
158
158
|
});
|
|
159
|
-
const lightbox =
|
|
159
|
+
const lightbox = useMediaViewer(media);
|
|
160
160
|
return (_jsxs(VStack, { gap: 2, children: [shown.map((part, index) => {
|
|
161
161
|
const key = String(index);
|
|
162
162
|
if (part.type === 'text')
|
package/ui/StateFields.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DecisionJson } from '@theoremjs/agents';
|
|
2
|
-
import { type DecisionImages } from '../client/decision-images.
|
|
2
|
+
import { type DecisionImages } from '../client/decision-images.js';
|
|
3
3
|
export type Edit<T = DecisionJson> = {
|
|
4
4
|
value: T;
|
|
5
5
|
onChange: (next: T) => void;
|
package/ui/StateFields.js
CHANGED
|
@@ -4,7 +4,6 @@ import { FieldLabel } from '@astryxdesign/core/Field';
|
|
|
4
4
|
import { FileInput } from '@astryxdesign/core/FileInput';
|
|
5
5
|
import { HStack } from '@astryxdesign/core/HStack';
|
|
6
6
|
import { IconButton } from '@astryxdesign/core/IconButton';
|
|
7
|
-
import { Lightbox } from '@astryxdesign/core/Lightbox';
|
|
8
7
|
import { NumberInput } from '@astryxdesign/core/NumberInput';
|
|
9
8
|
import { StackItem } from '@astryxdesign/core/Stack';
|
|
10
9
|
import { Switch } from '@astryxdesign/core/Switch';
|
|
@@ -21,6 +20,7 @@ import { IMAGE_ACCEPT, imageSrc } from "../client/decision-images.js";
|
|
|
21
20
|
import { blankLike, isWordList, tableColumns } from "../client/state-fields.js";
|
|
22
21
|
import { useImageReader } from "./DecisionImages.js";
|
|
23
22
|
import { useLabels } from "./labels-provider.js";
|
|
23
|
+
import { useMediaViewer } from "./media-viewer.js";
|
|
24
24
|
import { useKeyedRows } from "./row-keys.js";
|
|
25
25
|
const NO_SUGGESTIONS = { search: () => [], bootstrap: () => [] };
|
|
26
26
|
/** Text this long, or on several lines, gets a text area. */
|
|
@@ -36,9 +36,9 @@ function ImageField({ value, label, isLabelHidden, }) {
|
|
|
36
36
|
const t = useLabels();
|
|
37
37
|
const { images, onImages } = useContext(StateImages);
|
|
38
38
|
const { read, status } = useImageReader();
|
|
39
|
-
const [isOpen, setOpen] = useState(false);
|
|
40
39
|
const src = Object.hasOwn(images, value) ? imageSrc(images[value]) : undefined;
|
|
41
|
-
|
|
40
|
+
const viewer = useMediaViewer(src ? [{ type: 'image', src, alt: label, caption: value }] : []);
|
|
41
|
+
return (_jsxs(HStack, { gap: 2, vAlign: "center", children: [_jsx(Thumbnail, { src: src, alt: label, label: value, onClick: src ? () => viewer.open() : undefined }), viewer.element, _jsx(StackItem, { size: "fill", children: _jsx(FileInput, { label: label, isLabelHidden: isLabelHidden, accept: IMAGE_ACCEPT, value: null, placeholder: t('@theorem.decision.replace_image'), status: status, statusVariant: "detached", onChange: (files) => {
|
|
42
42
|
void read(files).then(([first]) => {
|
|
43
43
|
if (first)
|
|
44
44
|
onImages({ ...images, [value]: first[1] });
|
package/ui/TheoremChat.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { type ChatComposerInputHandle } from '@astryxdesign/core/Chat';
|
|
1
2
|
import type { DefinedTheme } from '@astryxdesign/core/theme';
|
|
2
|
-
import { type ComposerPendingMessage } from '@theoremjs/agents/interface';
|
|
3
|
+
import { type ComposerPendingMessage, type ComposerProfileInterface } from '@theoremjs/agents/interface';
|
|
3
4
|
import type { ChatController, PageTools, StatedTurn } from '@theoremjs/web/client';
|
|
4
5
|
import { type ConversationView, type HttpTransportOptions, type TheoremTransport } from '@theoremjs/web/client';
|
|
5
6
|
import { type ReactNode, type Ref } from 'react';
|
|
6
|
-
import { type SendTextOptions, type SentTurn, type UseTheoremChatOptions } from '../hooks/use-theorem-chat.
|
|
7
|
-
import type
|
|
7
|
+
import { type SendTextOptions, type SentTurn, type TheoremChatState, type UseTheoremChatOptions } from '../hooks/use-theorem-chat.js';
|
|
8
|
+
import { type ComposerLayout } from './ChatComposerBar.js';
|
|
9
|
+
import type { ComposerPill, ComposerRowIcons } from './ChatComposerRow.js';
|
|
10
|
+
import { type ChatTranscriptProps } from './ChatTranscript.js';
|
|
11
|
+
import type { TheoremLabels } from './labels.js';
|
|
12
|
+
import type { MediaViewer } from './media-viewer.js';
|
|
13
|
+
import type { ResolveMedia, ToolMediaShown } from './tool-media.js';
|
|
8
14
|
export type TheoremChatProps = {
|
|
9
15
|
/** Where `createTheoremHandler` is mounted. Default `/api/theorem`. Ignored when `transport` is set. */
|
|
10
16
|
endpoint?: string;
|
|
@@ -27,6 +33,25 @@ export type TheoremChatProps = {
|
|
|
27
33
|
* A fence with a language is never changed. Off by default.
|
|
28
34
|
*/
|
|
29
35
|
detectCodeLanguage?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The media a tool returned that the transcript shows: `sent` (default), only what the tool sent
|
|
38
|
+
* to the person; `all`, every piece the model read as well, for an evaluation view. Media a model
|
|
39
|
+
* generated and files a person attached always show. Hiding is not withholding: the page still
|
|
40
|
+
* receives every piece.
|
|
41
|
+
*/
|
|
42
|
+
media?: ToolMediaShown;
|
|
43
|
+
/**
|
|
44
|
+
* Turns a reference a tool sent (`{ type, mimeType, uri }`) into an address the page may load,
|
|
45
|
+
* under the viewer's own sign-in, or `null`. Without it, or on `null`, the reference shows as a
|
|
46
|
+
* named file. The model never reads a reference.
|
|
47
|
+
*/
|
|
48
|
+
resolveMedia?: ResolveMedia;
|
|
49
|
+
/**
|
|
50
|
+
* The viewer every picture and video opens in: the transcript's, a tool's, a decision's and a
|
|
51
|
+
* form field's. It is given the items, which one shows, and whether it is open; each item names
|
|
52
|
+
* the saved file it came from, when there is one. Default: Astryx's Lightbox, with zoom.
|
|
53
|
+
*/
|
|
54
|
+
mediaViewer?: MediaViewer;
|
|
30
55
|
/**
|
|
31
56
|
* The value chosen for each of the profile's `inputs.options`, sent with every turn. An option you
|
|
32
57
|
* name is fixed to that value; one you leave out gets a selector in the composer bar, beside
|
|
@@ -110,6 +135,18 @@ export type TheoremChatProps = {
|
|
|
110
135
|
* through `chatRef`. Gates are still answered in the transcript. Default `true`.
|
|
111
136
|
*/
|
|
112
137
|
composer?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* How the composer is laid out: `stacked` (default), Astryx's composer with the field above its
|
|
140
|
+
* controls; or `row`, the field and its buttons on one line, with a pill row above it for the
|
|
141
|
+
* reply in progress and the background jobs. See {@link ComposerLayout}.
|
|
142
|
+
*/
|
|
143
|
+
composerLayout?: ComposerLayout;
|
|
144
|
+
/**
|
|
145
|
+
* Glyphs the `row` composer draws: the working pill's, each background job's, and stop's. Each
|
|
146
|
+
* one left out keeps Theorem's. Its text is in `labels`; its look is the
|
|
147
|
+
* `--theorem-composer-*` CSS properties.
|
|
148
|
+
*/
|
|
149
|
+
composerIcons?: ComposerRowIcons;
|
|
113
150
|
};
|
|
114
151
|
/** What a host can do to a mounted {@link TheoremChat}. */
|
|
115
152
|
export type TheoremChatHandle = {
|
|
@@ -133,6 +170,39 @@ export type TheoremChatHandle = {
|
|
|
133
170
|
* whichever is smaller) — so phones and narrow panes get 100%.
|
|
134
171
|
*/
|
|
135
172
|
export declare const DEFAULT_CHAT_MAX_WIDTH = "max(50%, min(100%, 640px))";
|
|
173
|
+
export type TheoremChatComposerProps = {
|
|
174
|
+
/** The chat it writes to (`useTheoremChat`). */
|
|
175
|
+
chat: TheoremChatState;
|
|
176
|
+
/** The profile's interface (`useTheoremInterface`). */
|
|
177
|
+
iface: ComposerProfileInterface;
|
|
178
|
+
placeholder?: string;
|
|
179
|
+
/** Focus the field from outside. */
|
|
180
|
+
inputRef?: Ref<ChatComposerInputHandle>;
|
|
181
|
+
layout?: ComposerLayout;
|
|
182
|
+
icons?: ComposerRowIcons;
|
|
183
|
+
/** The app's own pills, in the `row` layout's pill row after the background jobs. */
|
|
184
|
+
pills?: readonly ComposerPill[];
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* The composer bound to a chat: drafts, files, voice, the pending queue, send and stop, and the
|
|
188
|
+
* working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
|
|
189
|
+
* `TheoremChatTranscript`.
|
|
190
|
+
*/
|
|
191
|
+
export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, }: TheoremChatComposerProps): import("react").JSX.Element;
|
|
192
|
+
export type TheoremChatTranscriptProps = Omit<ChatTranscriptProps, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
|
|
193
|
+
/** The chat it shows (`useTheoremChat`). */
|
|
194
|
+
chat: TheoremChatState;
|
|
195
|
+
/** The profile's interface (`useTheoremInterface`). */
|
|
196
|
+
iface: ComposerProfileInterface;
|
|
197
|
+
/** The name over each reply. Default: the profile's handle. */
|
|
198
|
+
handle?: string;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* The transcript bound to a chat: its blocks as they stream, its gates answered through the chat,
|
|
202
|
+
* and its times on the chat's turn clock, so they agree with `TheoremChatComposer` wherever each
|
|
203
|
+
* is placed.
|
|
204
|
+
*/
|
|
205
|
+
export declare function TheoremChatTranscript({ chat, iface, handle, ...props }: TheoremChatTranscriptProps): import("react").JSX.Element;
|
|
136
206
|
/**
|
|
137
207
|
* Drop-in chat for a profile served by `createTheoremHandler`:
|
|
138
208
|
*
|
|
@@ -140,4 +210,4 @@ export declare const DEFAULT_CHAT_MAX_WIDTH = "max(50%, min(100%, 640px))";
|
|
|
140
210
|
* <TheoremChat endpoint="/api/theorem" />
|
|
141
211
|
* ```
|
|
142
212
|
*/
|
|
143
|
-
export declare function TheoremChat({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, ...rest }: TheoremChatProps): import("react").JSX.Element;
|
|
213
|
+
export declare function TheoremChat({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, media, resolveMedia, mediaViewer, ...rest }: TheoremChatProps): import("react").JSX.Element;
|
package/ui/TheoremChat.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ChatLayout } from '@astryxdesign/core/Chat';
|
|
|
5
5
|
import { Layout, LayoutContent } from '@astryxdesign/core/Layout';
|
|
6
6
|
import { Text } from '@astryxdesign/core/Text';
|
|
7
7
|
import { VStack } from '@astryxdesign/core/VStack';
|
|
8
|
-
import { removeComposerPendingMessage, } from '@theoremjs/agents/interface';
|
|
8
|
+
import { interfaceShowsToolData, removeComposerPendingMessage, } from '@theoremjs/agents/interface';
|
|
9
9
|
import { createHttpTransport, } from '@theoremjs/web/client';
|
|
10
10
|
import { useImperativeHandle, useMemo, useRef, } from 'react';
|
|
11
11
|
import { parseAspectRatio } from "../client/image-output.js";
|
|
@@ -14,12 +14,11 @@ import { useTheoremInterface } from "../hooks/use-theorem-interface.js";
|
|
|
14
14
|
import { ChatComposerBar } from "./ChatComposerBar.js";
|
|
15
15
|
import { ChatTranscript } from "./ChatTranscript.js";
|
|
16
16
|
import { useGlide } from "./glide.js";
|
|
17
|
-
import {
|
|
18
|
-
import { MarkdownPluginsProvider } from "./markdown-plugins.js";
|
|
17
|
+
import { useLabels } from "./labels-provider.js";
|
|
19
18
|
import { PaneFailure, PaneLoading } from "./PaneState.js";
|
|
20
19
|
import { SidePanelHeader } from "./SidePanel.js";
|
|
20
|
+
import { TheoremSurface } from "./TheoremSurface.js";
|
|
21
21
|
import { useTraceInspector, WithTrace } from "./TraceInspectorPanel.js";
|
|
22
|
-
import { TheoremThemeProvider } from "./theme.js";
|
|
23
22
|
/**
|
|
24
23
|
* 50% of the chat's width, but never narrower than 640px (or the full width,
|
|
25
24
|
* whichever is smaller) — so phones and narrow panes get 100%.
|
|
@@ -29,9 +28,13 @@ export const DEFAULT_CHAT_MAX_WIDTH = 'max(50%, min(100%, 640px))';
|
|
|
29
28
|
function ChatColumn({ maxWidth, ref, children, }) {
|
|
30
29
|
return (_jsx(Center, { axis: "horizontal", width: "100%", children: _jsx(VStack, { ref: ref, width: "100%", maxWidth: maxWidth, children: children }) }));
|
|
31
30
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The composer bound to a chat: drafts, files, voice, the pending queue, send and stop, and the
|
|
33
|
+
* working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
|
|
34
|
+
* `TheoremChatTranscript`.
|
|
35
|
+
*/
|
|
36
|
+
export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, }) {
|
|
37
|
+
return (_jsx(ChatComposerBar, { 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, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
|
|
35
38
|
chat.setPendingFiles((prev) => [...prev, ...files]);
|
|
36
39
|
chat.setIssues([]);
|
|
37
40
|
}, onAttachmentRemove: (index) => {
|
|
@@ -51,7 +54,28 @@ function ChatComposerForChat({ chat, iface, placeholder, inputRef, }) {
|
|
|
51
54
|
void chat.handleSendNow(message);
|
|
52
55
|
} }));
|
|
53
56
|
}
|
|
54
|
-
|
|
57
|
+
/** The handle `chatRef` gets: send, stop, focus and the controller. */
|
|
58
|
+
function useChatHandle(chatRef, chat) {
|
|
59
|
+
const { sendText, handleStop, controller } = chat;
|
|
60
|
+
const inputRef = useRef(null);
|
|
61
|
+
useImperativeHandle(chatRef, () => ({
|
|
62
|
+
send: sendText,
|
|
63
|
+
stop: handleStop,
|
|
64
|
+
focus: () => {
|
|
65
|
+
inputRef.current?.focus();
|
|
66
|
+
},
|
|
67
|
+
controller,
|
|
68
|
+
}), [sendText, handleStop, controller]);
|
|
69
|
+
return inputRef;
|
|
70
|
+
}
|
|
71
|
+
/** The composer, or, with none, the failed turn's error where the composer was. */
|
|
72
|
+
function ChatBodyComposer({ hasComposer, ...props }) {
|
|
73
|
+
if (hasComposer)
|
|
74
|
+
return _jsx(TheoremChatComposer, { ...props });
|
|
75
|
+
const failure = props.chat.failure;
|
|
76
|
+
return failure ? _jsx(Banner, { status: "error", role: "alert", title: failure.error }) : null;
|
|
77
|
+
}
|
|
78
|
+
function ChatBody({ transport, iface, placeholder, emptyState, density, maxWidth = DEFAULT_CHAT_MAX_WIDTH, scrollRef, trace, usage, className, style, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, composer: hasComposer = true, composerLayout, composerIcons, options, onOptionsChange, stated, context, pageTools, onTurnEvent, }) {
|
|
55
79
|
const t = useLabels();
|
|
56
80
|
const chat = useTheoremChat({
|
|
57
81
|
transport,
|
|
@@ -70,26 +94,15 @@ function ChatBody({ transport, iface, placeholder, emptyState, density, maxWidth
|
|
|
70
94
|
pageTools,
|
|
71
95
|
onTurnEvent,
|
|
72
96
|
});
|
|
73
|
-
const { sendText, handleStop, controller } = chat;
|
|
74
|
-
const blocks = useMemo(() => [...chat.blocks, ...chat.streamBlocks], [chat.blocks, chat.streamBlocks]);
|
|
75
97
|
const handle = t('@theorem.agent.handle', { handle: iface.identity.handle });
|
|
76
|
-
const landing =
|
|
77
|
-
const inputRef =
|
|
78
|
-
useImperativeHandle(chatRef, () => ({
|
|
79
|
-
send: sendText,
|
|
80
|
-
stop: handleStop,
|
|
81
|
-
focus: () => {
|
|
82
|
-
inputRef.current?.focus();
|
|
83
|
-
},
|
|
84
|
-
controller,
|
|
85
|
-
}), [sendText, handleStop, controller]);
|
|
98
|
+
const landing = chat.shownBlocks.length === 0;
|
|
99
|
+
const inputRef = useChatHandle(chatRef, chat);
|
|
86
100
|
const composerRef = useGlide(landing, () => inputRef.current?.focus());
|
|
87
101
|
const inspector = useTraceInspector(iface, transport.traces, trace);
|
|
88
102
|
const header = _jsx(SidePanelHeader, { floating: true, children: inspector.toggle });
|
|
89
|
-
|
|
90
|
-
const composer = hasComposer ? (_jsx(ChatComposerForChat, { chat: chat, iface: iface, placeholder: placeholder, inputRef: inputRef })) : (chat.failure && _jsx(Banner, { status: "error", role: "alert", title: chat.failure.error }));
|
|
103
|
+
const composer = (_jsx(ChatBodyComposer, { hasComposer: hasComposer, chat: chat, iface: iface, placeholder: placeholder, inputRef: inputRef, layout: composerLayout, icons: composerIcons }));
|
|
91
104
|
const docked = { composer, composerRef, maxWidth };
|
|
92
|
-
return (_jsx(WithTrace, { inspector: inspector, children: _jsx(Layout, { height: "fill", className: className, style: { position: 'relative', ...style }, header: header, content: _jsx(LayoutContent, { padding: 0, isScrollable: landing, children: landing ? (_jsx(ChatLanding, { ...docked, handle: handle, emptyState: emptyState })) : (_jsx(ChatThread, { ...docked, chat: chat, iface: iface,
|
|
105
|
+
return (_jsx(WithTrace, { inspector: inspector, children: _jsx(Layout, { height: "fill", className: className, style: { position: 'relative', ...style }, header: header, content: _jsx(LayoutContent, { padding: 0, isScrollable: landing, children: landing ? (_jsx(ChatLanding, { ...docked, handle: handle, emptyState: emptyState })) : (_jsx(ChatThread, { ...docked, chat: chat, iface: iface, handle: handle, density: density, scrollRef: scrollRef, usage: usage })) }) }) }));
|
|
93
106
|
}
|
|
94
107
|
const CHAT_SCROLL = { overscrollBehavior: 'none' };
|
|
95
108
|
/**
|
|
@@ -105,16 +118,23 @@ function ChatLanding({ composer, composerRef, maxWidth, handle, emptyState, }) {
|
|
|
105
118
|
* why: the dock leaves 12px under the composer; paddingBlockEnd={3} adds 12px more for a 24px
|
|
106
119
|
* bottom margin.
|
|
107
120
|
*/
|
|
108
|
-
function ChatThread({ composer, composerRef, maxWidth, chat, iface,
|
|
121
|
+
function ChatThread({ composer, composerRef, maxWidth, chat, iface, handle, density, scrollRef, usage, }) {
|
|
109
122
|
return (_jsxs(VStack, { height: "100%", children: [_jsx("style", { href: "theorem-chat-thread", precedence: "default", children: '.theorem-chat-thread > :last-child > div:empty { display: none; }' }), _jsx(ChatLayout, { className: "theorem-chat-thread", density: density, scrollRef: scrollRef,
|
|
110
123
|
// why: Scrolling past either end does not bounce the transcript and its docked composer.
|
|
111
|
-
style: CHAT_SCROLL, composer: composer && (_jsx(VStack, { paddingBlockEnd: 3, children: _jsx(ChatColumn, { ref: composerRef, maxWidth: maxWidth, children: composer }) })), children: _jsx(ChatColumn, { maxWidth: maxWidth, children: _jsx(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
style: CHAT_SCROLL, composer: composer && (_jsx(VStack, { paddingBlockEnd: 3, children: _jsx(ChatColumn, { ref: composerRef, maxWidth: maxWidth, children: composer }) })), children: _jsx(ChatColumn, { maxWidth: maxWidth, children: _jsx(TheoremChatTranscript, { chat: chat, iface: iface, handle: handle, usage: usage }) }) })] }));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The transcript bound to a chat: its blocks as they stream, its gates answered through the chat,
|
|
128
|
+
* and its times on the chat's turn clock, so they agree with `TheoremChatComposer` wherever each
|
|
129
|
+
* is placed.
|
|
130
|
+
*/
|
|
131
|
+
export function TheoremChatTranscript({ chat, iface, handle, ...props }) {
|
|
132
|
+
const t = useLabels();
|
|
133
|
+
return (_jsx(ChatTranscript, { ...props, handle: handle ?? t('@theorem.agent.handle', { handle: iface.identity.handle }), blocks: chat.shownBlocks, streaming: chat.streaming, delivery: chat.delivery, answering: chat.answering, clock: chat.turnClock, labels: iface.labels, showToolData: interfaceShowsToolData(iface), imageOutput: iface.type === 'image' ? { ratio: parseAspectRatio(iface.image.aspectRatio) } : undefined, onToolDecision: (index, action) => {
|
|
134
|
+
void chat.handleToolDecision(index, action);
|
|
135
|
+
}, onAuthenticated: (index, secret) => {
|
|
136
|
+
void chat.handleAuthenticated(index, secret);
|
|
137
|
+
} }));
|
|
118
138
|
}
|
|
119
139
|
function ChatForTransport(props) {
|
|
120
140
|
const t = useLabels();
|
|
@@ -135,9 +155,9 @@ function ChatForTransport(props) {
|
|
|
135
155
|
* <TheoremChat endpoint="/api/theorem" />
|
|
136
156
|
* ```
|
|
137
157
|
*/
|
|
138
|
-
export function TheoremChat({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, ...rest }) {
|
|
158
|
+
export function TheoremChat({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, media, resolveMedia, mediaViewer, ...rest }) {
|
|
139
159
|
const httpRef = useRef(http);
|
|
140
160
|
httpRef.current = http;
|
|
141
161
|
const resolved = useMemo(() => transport ?? createHttpTransport({ ...httpRef.current, endpoint }), [transport, endpoint]);
|
|
142
|
-
return (_jsx(
|
|
162
|
+
return (_jsx(TheoremSurface, { theme: theme, mode: mode, labels: labels, detectCodeLanguage: detectCodeLanguage, media: media, resolveMedia: resolveMedia, mediaViewer: mediaViewer, children: _jsx(ChatForTransport, { ...rest, transport: resolved }) }));
|
|
143
163
|
}
|
package/ui/TheoremDecision.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DecisionTransport } from '@theoremjs/web/client';
|
|
2
|
-
import { type DecisionImages } from '../client/decision-images.
|
|
3
|
-
import { type ConsolePageProps } from './ConsoleFrame.
|
|
4
|
-
import { type TheoremDecisionAnswersProps } from './DecisionAnswers.
|
|
2
|
+
import { type DecisionImages } from '../client/decision-images.js';
|
|
3
|
+
import { type ConsolePageProps } from './ConsoleFrame.js';
|
|
4
|
+
import { type TheoremDecisionAnswersProps } from './DecisionAnswers.js';
|
|
5
5
|
export type TheoremDecisionProps = ConsolePageProps & {
|
|
6
6
|
/** Where `createTheoremDecisionHandler` is mounted. Default `/api/decision`. Ignored when `transport` is set. */
|
|
7
7
|
endpoint?: string;
|
package/ui/TheoremEmbedding.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EmbeddingTransport } from '@theoremjs/web/client';
|
|
2
|
-
import { type ConsolePageProps } from './ConsoleFrame.
|
|
3
|
-
import { type EmbeddingDocument } from './EmbeddingDocuments.
|
|
2
|
+
import { type ConsolePageProps } from './ConsoleFrame.js';
|
|
3
|
+
import { type EmbeddingDocument } from './EmbeddingDocuments.js';
|
|
4
4
|
export type TheoremEmbeddingProps = ConsolePageProps & {
|
|
5
5
|
/** Where `createTheoremEmbeddingHandler` is mounted. Default `/api/embedding`. Ignored when `transport` is set. */
|
|
6
6
|
endpoint?: string;
|
package/ui/TheoremHost.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type { DefinedTheme } from '@astryxdesign/core/theme';
|
|
|
2
2
|
import type { HttpOptions, PageTools } from '@theoremjs/web/client';
|
|
3
3
|
import { type HostTransport } from '@theoremjs/web/client';
|
|
4
4
|
import { type CSSProperties } from 'react';
|
|
5
|
-
import { type TheoremLabels } from './labels.
|
|
5
|
+
import { type TheoremLabels } from './labels.js';
|
|
6
|
+
import type { MediaViewer } from './media-viewer.js';
|
|
7
|
+
import type { ResolveMedia } from './tool-media.js';
|
|
6
8
|
export type TheoremHostProps = {
|
|
7
9
|
/** Where `createTheoremHostHandler` is mounted. Default `/api/host`. Ignored when `transport` is set. */
|
|
8
10
|
endpoint?: string;
|
|
@@ -22,6 +24,18 @@ export type TheoremHostProps = {
|
|
|
22
24
|
* A fence with a language is never changed. Off by default.
|
|
23
25
|
*/
|
|
24
26
|
detectCodeLanguage?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Turns a reference a tool returned (`{ type, mimeType, uri }`) into an address the page may
|
|
29
|
+
* load, under the viewer's own sign-in, or `null`. Without it, or on `null`, the reference shows
|
|
30
|
+
* as a named file.
|
|
31
|
+
*/
|
|
32
|
+
resolveMedia?: ResolveMedia;
|
|
33
|
+
/**
|
|
34
|
+
* The viewer every picture and video opens in: the transcript's, a tool's, a decision's and a
|
|
35
|
+
* form field's. It is given the items, which one shows, and whether it is open; each item names
|
|
36
|
+
* the saved file it came from, when there is one. Default: Astryx's Lightbox, with zoom.
|
|
37
|
+
*/
|
|
38
|
+
mediaViewer?: MediaViewer;
|
|
25
39
|
/** Widest the column may grow, as a CSS length. Default `960px`. */
|
|
26
40
|
maxWidth?: string;
|
|
27
41
|
/**
|
|
@@ -51,4 +65,4 @@ export type TheoremHostProps = {
|
|
|
51
65
|
* <TheoremHost endpoint="/api/host" />
|
|
52
66
|
* ```
|
|
53
67
|
*/
|
|
54
|
-
export declare function TheoremHost({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, ...rest }: TheoremHostProps): import("react").JSX.Element;
|
|
68
|
+
export declare function TheoremHost({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, resolveMedia, mediaViewer, ...rest }: TheoremHostProps): import("react").JSX.Element;
|
package/ui/TheoremHost.js
CHANGED
|
@@ -9,7 +9,7 @@ import { StatusDot } from '@astryxdesign/core/StatusDot';
|
|
|
9
9
|
import { Text } from '@astryxdesign/core/Text';
|
|
10
10
|
import { Token } from '@astryxdesign/core/Token';
|
|
11
11
|
import { VStack } from '@astryxdesign/core/VStack';
|
|
12
|
-
import { IconMathFunction, IconWorld } from '@tabler/icons-react';
|
|
12
|
+
import { IconFileSmile, IconMathFunction, IconWorld } from '@tabler/icons-react';
|
|
13
13
|
import { createHostTransport, isRow, json, missingFields, } from '@theoremjs/web/client';
|
|
14
14
|
import { useMemo, useRef, useState } from 'react';
|
|
15
15
|
import { hostCallFailure, hostCallStatus, hostConsoleView, } from "../client/host-call.js";
|
|
@@ -19,15 +19,14 @@ import { useTheoremHost } from "../hooks/use-theorem-host.js";
|
|
|
19
19
|
import { Arrive, Stream } from "./arrive.js";
|
|
20
20
|
import { ConsoleFrame, JsonRequest, RequestCard, ResponseColumn, RunBar, } from "./ConsoleFrame.js";
|
|
21
21
|
import { liveDuration, workDuration } from "./labels.js";
|
|
22
|
-
import {
|
|
23
|
-
import { MarkdownPluginsProvider } from "./markdown-plugins.js";
|
|
22
|
+
import { useLabels } from "./labels-provider.js";
|
|
24
23
|
import { IconMcp } from "./mcp-icon.js";
|
|
25
24
|
import { PaneFailure, PaneLoading } from "./PaneState.js";
|
|
26
25
|
import { SchemaFields } from "./SchemaFields.js";
|
|
26
|
+
import { TheoremSurface } from "./TheoremSurface.js";
|
|
27
27
|
import { ApprovalCard, AuthChallengeCard } from "./ToolGateCard.js";
|
|
28
28
|
import { ToolResult } from "./ToolResult.js";
|
|
29
29
|
import { useTraceInspector } from "./TraceInspectorPanel.js";
|
|
30
|
-
import { TheoremThemeProvider } from "./theme.js";
|
|
31
30
|
/** Calls listed under the console before older ones drop off the page. */
|
|
32
31
|
const MAX_EARLIER = 8;
|
|
33
32
|
const STATUS_DOT = {
|
|
@@ -59,6 +58,7 @@ const KIND_ICON = {
|
|
|
59
58
|
function: IconMathFunction,
|
|
60
59
|
http: IconWorld,
|
|
61
60
|
mcp: IconMcp,
|
|
61
|
+
agent: IconFileSmile,
|
|
62
62
|
};
|
|
63
63
|
/** The most room a row of the tool menu takes, and the lines of description it shows. */
|
|
64
64
|
const TOOL_MENU_PX = 440;
|
|
@@ -231,9 +231,9 @@ function HostForTransport(props) {
|
|
|
231
231
|
* <TheoremHost endpoint="/api/host" />
|
|
232
232
|
* ```
|
|
233
233
|
*/
|
|
234
|
-
export function TheoremHost({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, ...rest }) {
|
|
234
|
+
export function TheoremHost({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, resolveMedia, mediaViewer, ...rest }) {
|
|
235
235
|
const httpRef = useRef(http);
|
|
236
236
|
httpRef.current = http;
|
|
237
237
|
const resolved = useMemo(() => transport ?? createHostTransport({ ...httpRef.current, endpoint }), [transport, endpoint]);
|
|
238
|
-
return (_jsx(
|
|
238
|
+
return (_jsx(TheoremSurface, { theme: theme, mode: mode, labels: labels, detectCodeLanguage: detectCodeLanguage, media: "all", resolveMedia: resolveMedia, mediaViewer: mediaViewer, children: _jsx(HostForTransport, { ...rest, transport: resolved }) }));
|
|
239
239
|
}
|