@theoremjs/react 0.3.5-next.1003.g05ad1e8 → 0.3.5-next.1005.geaafb0b
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 +8 -2
- package/client/transcript-groups.d.ts +7 -1
- package/client/transcript-groups.js +9 -1
- package/package.json +3 -3
- package/ui/ChatTranscript.d.ts +6 -0
- package/ui/ChatTranscript.js +11 -2
package/README.md
CHANGED
|
@@ -108,6 +108,7 @@ export const theorem = createTheoremHandler({
|
|
|
108
108
|
profile: support,
|
|
109
109
|
provider: { vault: { main: process.env.GEMINI_API_KEY } },
|
|
110
110
|
conversationStore: createMemoryConversationStore(),
|
|
111
|
+
operationRetentionMs: 24 * 60 * 60 * 1000, // a day: how long a finished call's result is kept
|
|
111
112
|
});
|
|
112
113
|
```
|
|
113
114
|
|
|
@@ -327,7 +328,10 @@ A `host` profile does not run a model. The page calls the tools of the profile d
|
|
|
327
328
|
```ts
|
|
328
329
|
import { createTheoremHostHandler } from '@theoremjs/web/server';
|
|
329
330
|
|
|
330
|
-
export const host = createTheoremHostHandler({
|
|
331
|
+
export const host = createTheoremHostHandler({
|
|
332
|
+
profile: opsConsole,
|
|
333
|
+
operationRetentionMs: 24 * 60 * 60 * 1000,
|
|
334
|
+
}); // mount at /api/host
|
|
331
335
|
```
|
|
332
336
|
|
|
333
337
|
```tsx
|
|
@@ -590,7 +594,7 @@ function Dock({ chat, iface }) {
|
|
|
590
594
|
}
|
|
591
595
|
```
|
|
592
596
|
|
|
593
|
-
`TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, and `
|
|
597
|
+
`TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, and `showWorkStatus`. Its `handle` is the handle of the profile when you leave it out. Put both pieces inside one `TheoremSurface`. It takes what `TheoremChat` takes for the look and the media: `theme`, `mode`, `labels`, `detectCodeLanguage`, `media`, `resolveMedia`, and `mediaViewer`.
|
|
594
598
|
|
|
595
599
|
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.
|
|
596
600
|
|
|
@@ -615,6 +619,8 @@ A failed tool call in `ChatTranscript` shows its failure once: the row shows the
|
|
|
615
619
|
|
|
616
620
|
Pass `showToolDurations={false}` to leave out how long each call ran.
|
|
617
621
|
|
|
622
|
+
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.
|
|
623
|
+
|
|
618
624
|
The hooks and the client write no English text. They return kinds, codes, and states. You write the words.
|
|
619
625
|
|
|
620
626
|
- 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.
|
|
@@ -92,11 +92,17 @@ export type WorkStatus = {
|
|
|
92
92
|
phase: 'working' | 'worked';
|
|
93
93
|
elapsedMs?: number;
|
|
94
94
|
};
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Working while streaming; worked after, when it has a duration or steps; else nothing to show.
|
|
97
|
+
* With `shown: false` (`ChatTranscriptProps.showWorkStatus`), only a reply whose steps fold under
|
|
98
|
+
* the status (`folds`) has one, as the fold's trigger, without its time.
|
|
99
|
+
*/
|
|
96
100
|
export declare function workStatus(args: {
|
|
97
101
|
streaming: boolean;
|
|
98
102
|
hasSteps: boolean;
|
|
99
103
|
elapsedMs?: number;
|
|
104
|
+
shown?: boolean;
|
|
105
|
+
folds?: boolean;
|
|
100
106
|
}): WorkStatus | null;
|
|
101
107
|
/**
|
|
102
108
|
* Split an assistant turn into Seance-style trace + final body.
|
|
@@ -108,8 +108,16 @@ export function assistantTurnCopyText(blocks) {
|
|
|
108
108
|
.filter(Boolean)
|
|
109
109
|
.join('\n\n');
|
|
110
110
|
}
|
|
111
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Working while streaming; worked after, when it has a duration or steps; else nothing to show.
|
|
113
|
+
* With `shown: false` (`ChatTranscriptProps.showWorkStatus`), only a reply whose steps fold under
|
|
114
|
+
* the status (`folds`) has one, as the fold's trigger, without its time.
|
|
115
|
+
*/
|
|
112
116
|
export function workStatus(args) {
|
|
117
|
+
if (args.shown === false) {
|
|
118
|
+
const work = workStatus({ streaming: args.streaming, hasSteps: args.hasSteps });
|
|
119
|
+
return args.folds && work ? { phase: work.phase } : null;
|
|
120
|
+
}
|
|
113
121
|
const elapsed = args.elapsedMs !== undefined ? { elapsedMs: args.elapsedMs } : {};
|
|
114
122
|
if (args.streaming)
|
|
115
123
|
return { phase: 'working', ...elapsed };
|
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.1005.geaafb0b",
|
|
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.1005.geaafb0b",
|
|
64
|
+
"@theoremjs/web": "^0.3.5-next.1005.geaafb0b"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|
package/ui/ChatTranscript.d.ts
CHANGED
|
@@ -60,6 +60,12 @@ export type ChatTranscriptProps = {
|
|
|
60
60
|
stepLayout?: StepLayout;
|
|
61
61
|
/** Whether a finished tool call's row shows how long it ran. Default: true. */
|
|
62
62
|
showToolDurations?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether a reply shows its work status ("Working for 12s", "Worked for 3.5s"). Default: true.
|
|
65
|
+
* With `false`, a reply whose steps fold under the status keeps it as the fold's trigger, without
|
|
66
|
+
* the time ("Worked"); any other reply shows none.
|
|
67
|
+
*/
|
|
68
|
+
showWorkStatus?: boolean;
|
|
63
69
|
/** The profile's labels (`iface.labels`): a stopped turn says why in its words. */
|
|
64
70
|
labels?: LabelOverrides;
|
|
65
71
|
};
|
package/ui/ChatTranscript.js
CHANGED
|
@@ -42,6 +42,8 @@ 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
|
+
/** Whether a reply shows its work status (`ChatTranscriptProps.showWorkStatus`). */
|
|
46
|
+
const ShowWorkStatus = createContext(true);
|
|
45
47
|
/** What the transcript's props say a tool call's row shows. */
|
|
46
48
|
function useToolRowShows() {
|
|
47
49
|
return {
|
|
@@ -660,7 +662,14 @@ function AssistantTurn(props) {
|
|
|
660
662
|
});
|
|
661
663
|
const { shown } = useToolMedia();
|
|
662
664
|
const rows = bodyRows(t, body, shown);
|
|
663
|
-
const
|
|
665
|
+
const statusShown = useContext(ShowWorkStatus);
|
|
666
|
+
const status = workStatusLabel(t, workStatus({
|
|
667
|
+
streaming: props.streaming,
|
|
668
|
+
hasSteps,
|
|
669
|
+
elapsedMs,
|
|
670
|
+
shown: statusShown,
|
|
671
|
+
folds: hasTrace,
|
|
672
|
+
}));
|
|
664
673
|
const copyText = assistantTurnCopyText(body.length > 0 ? body : props.blocks);
|
|
665
674
|
return (_jsx(ChatMessage, { sender: "assistant", name: props.handle, ...chrome.handlers, metadata: props.streaming ? undefined : (_jsx(MessageChrome, { sender: "assistant", at: props.at, copyText: copyText, error: props.error, stopped: props.stopped, usage: showUsage ? props.usage : undefined, revealed: chrome.revealed })), children: _jsxs(VStack, { gap: 3, width: "100%", children: [_jsx(TurnStatus, { status: status, trace: trace, hasTrace: hasTrace, streaming: props.streaming }), gatedTools.map((block) => (_jsx(GateCard, { block: block, handle: props.handle, handlers: props.handlers }, block.id))), keyedByContent(rows, (row) => row.kind === 'gallery' || row.kind === 'sources' || row.kind === 'tools'
|
|
666
675
|
? row.kind
|
|
@@ -693,7 +702,7 @@ function isBareFailure(group) {
|
|
|
693
702
|
}
|
|
694
703
|
/** Theorem transcript blocks rendered as Astryx chat messages. */
|
|
695
704
|
export function ChatTranscript(props) {
|
|
696
|
-
return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ShowToolDurations.Provider, { value: props.showToolDurations !== false, children: _jsx(ChatTranscriptBody, { ...props }) }) }) }) }));
|
|
705
|
+
return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ShowToolDurations.Provider, { value: props.showToolDurations !== false, children: _jsx(ShowWorkStatus.Provider, { value: props.showWorkStatus !== false, children: _jsx(ChatTranscriptBody, { ...props }) }) }) }) }) }));
|
|
697
706
|
}
|
|
698
707
|
function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, }) {
|
|
699
708
|
const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers))), [blocks, dividers]);
|