@theoremjs/react 0.3.5-next.1031.g1faef7b → 0.3.5-next.1032.g04dc504

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 CHANGED
@@ -718,7 +718,7 @@ function Dock({ chat, iface }) {
718
718
  }
719
719
  ```
720
720
 
721
- `TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, `inputRef`, `inputComponent`, `triggers`, `refText`, and `renderRef`. 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`, `showWorkStatus`, and `renderRef`. 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`.
721
+ `TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, `inputRef`, `inputComponent`, `triggers`, `refText`, and `renderRef`. 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`, `showWorkStatus`, `renderRef`, 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`.
722
722
 
723
723
  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.
724
724
 
@@ -752,6 +752,59 @@ The hooks and the client write no English text. They return kinds, codes, and st
752
752
  - A provider can end a live call after it gives a warning. This is not a failure. `LiveSessionClient` calls `onSessionEnded(session)`. `session.message` is the wording of the profile (`live.session_ended`). `session.ended` has the close code and the timing.
753
753
  - The state of the UI is given as values, such as `liveState`, the work status, the drawer parts, and the hint ids. You choose the words for them.
754
754
 
755
+ ### Draw under a reply
756
+
757
+ To draw your own part under a reply, such as a card that a tool's result asks for, pass `slots={{ reply }}` to `ChatTranscript` or `TheoremChatTranscript`. `reply` is called for each reply and draws inside its message, under what the reply wrote. Without it, or with `reply: null`, nothing is drawn.
758
+
759
+ `reply` receives a `ChatReply`:
760
+
761
+ | Field | Meaning |
762
+ | --- | --- |
763
+ | `blocks` | The reply's blocks, as the transcript draws them. Its tool calls are among them, each with its output when it settled. |
764
+ | `host` | The `host` value of each of the reply's blocks that has one, in order, its `turn-done` blocks too. Empty when there is none. |
765
+ | `streaming` | `true` while the reply is on its way. |
766
+
767
+ Your server sets the values. In `beforeSave`, set `host`, a JSON object, on a block of the reply (see [Shape the save that ends a reply](../web/README.md#shape-the-save-that-ends-a-reply)). Read the reply's tool outputs there when the value comes from a tool. Theorem saves the value with the block and never reads it. The page cannot set it.
768
+
769
+ ```ts
770
+ // server
771
+ beforeSave: async (at, reply) => ({
772
+ told: [],
773
+ blocks: reply.blocks.map((block) =>
774
+ block.kind === 'turn-done' ? { ...block, host: { card: 'join', room: roomOf(reply.blocks) } } : block,
775
+ ),
776
+ }),
777
+ ```
778
+
779
+ ```tsx
780
+ // page
781
+ type JoinCard = { card: 'join'; room: string };
782
+
783
+ <TheoremChatTranscript<JoinCard>
784
+ chat={chat}
785
+ iface={iface}
786
+ slots={{
787
+ reply: ({ host }) => {
788
+ const join = host.find((value) => value.card === 'join');
789
+ return join ? (
790
+ <ActionCard title={`Join ${join.room}`} actions={<Button label="Join" onClick={() => open(join.room)} />} />
791
+ ) : null;
792
+ },
793
+ }}
794
+ />
795
+ ```
796
+
797
+ The type argument is the type of your values, a JSON object type. Theorem does not check their shape against it.
798
+
799
+ These rules apply:
800
+
801
+ - A reply has its values once it is saved. The chat reads the conversation again when each reply ends, so the slot gets the values then, and gets the same values after a reload. While the reply streams, `host` is empty.
802
+ - A reply that waits on a gate has no values until it ends: its blocks reach `beforeSave` in the save after the person answers.
803
+ - A profile that keeps no conversation (`'stateless'`) saves no reply, so `host` is always empty. Draw from `blocks` there.
804
+ - With `tools.showData: false`, each tool call in `blocks` has `null` output and `{}` arguments, as the transcript shows it. The `host` values are unchanged.
805
+
806
+ `ActionCard` is the frame of the gate cards: their width, a title with an `icon` before it and a `tag` at its end, the body (`children`), and a row of buttons (`actions`) at the end. `ApprovalCard` and `AuthChallengeCard` are built on it. Build your own cards on it so that they look like the gate cards.
807
+
755
808
  ## Wording
756
809
 
757
810
  Each line of text in the ready-made UI is an Astryx i18n message. Theorem messages use `@theorem.*` keys. `THEOREM_UI_CATALOG` lists them, with a description and the values that each one takes. Astryx messages use `@astryx.*` keys.
@@ -30,6 +30,8 @@ export type TranscriptTurnGroup = {
30
30
  usage?: TurnUsage;
31
31
  /** How its latest run stopped. */
32
32
  stop?: TurnStop;
33
+ /** The `host` value of each of its blocks that has one, its `turn-done` blocks too, in order. */
34
+ host?: NonNullable<TranscriptBlock['host']>[];
33
35
  };
34
36
  export type TraceItem = {
35
37
  kind: 'reasoning';
@@ -74,6 +74,16 @@ function joinsTurn(last, isUser) {
74
74
  return false;
75
75
  return !(last.kind === 'user' && last.stop);
76
76
  }
77
+ /** `block` on the turn before it when it joins that turn, else as a turn of its own. */
78
+ function placeBlock(groups, block, breaks) {
79
+ const isUser = isUserTranscriptBlock(block);
80
+ const last = groups.at(-1);
81
+ if (last && joinsTurn(last, isUser) && !breaks?.has(block.id)) {
82
+ last.blocks.push(block);
83
+ return;
84
+ }
85
+ groups.push({ kind: isUser ? 'user' : 'assistant', key: block.id, blocks: [block] });
86
+ }
77
87
  /**
78
88
  * Blocks as turns: neighbours from the same side share one, unless a block is
79
89
  * in `breaks`, which always starts its own. A message whose turn stopped short
@@ -84,19 +94,11 @@ export function groupTranscriptBlocks(blocks, breaks) {
84
94
  for (const block of blocks) {
85
95
  if (block.kind === 'turn-done')
86
96
  closeTurn(groups.at(-1), block);
87
- if (isHiddenTranscriptBlock(block))
88
- continue;
89
- const isUser = isUserTranscriptBlock(block);
90
- const last = groups.at(-1);
91
- if (last && joinsTurn(last, isUser) && !breaks?.has(block.id)) {
92
- last.blocks.push(block);
93
- continue;
94
- }
95
- groups.push({
96
- kind: isUser ? 'user' : 'assistant',
97
- key: block.id,
98
- blocks: [block],
99
- });
97
+ if (!isHiddenTranscriptBlock(block))
98
+ placeBlock(groups, block, breaks);
99
+ const group = groups.at(-1);
100
+ if (block.host && group?.kind === 'assistant')
101
+ group.host = [...(group.host ?? []), block.host];
100
102
  }
101
103
  return groups;
102
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.1031.g1faef7b",
3
+ "version": "0.3.5-next.1032.g04dc504",
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.1031.g1faef7b",
64
- "@theoremjs/web": "^0.3.5-next.1031.g1faef7b"
63
+ "@theoremjs/agents": "^0.3.5-next.1032.g04dc504",
64
+ "@theoremjs/web": "^0.3.5-next.1032.g04dc504"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -2,13 +2,17 @@ import { type ChatMessageStatus } from '@astryxdesign/core/Chat';
2
2
  import type { LabelOverrides } from '@theoremjs/agents';
3
3
  import type { UserRef } from '@theoremjs/agents/interface';
4
4
  import { type TranscriptBlock } from '@theoremjs/agents/interface';
5
+ import type { JsonObject } from '@theoremjs/agents/kernel';
5
6
  import type { AnsweringGate } from '@theoremjs/web/client';
6
7
  import { type ReactNode } from 'react';
7
8
  import { type ComposeAssistantTurnOptions, type StepLayout } from '../client/transcript-groups.js';
8
9
  import { type TurnClock } from '../hooks/use-turn-clock.js';
10
+ import type { ChatTranscriptSlots } from './reply-slot.js';
9
11
  import { type ToolDecision } from './ToolGateCard.js';
10
12
  import { type MediaReference } from './tool-media.js';
11
- export type ChatTranscriptProps = {
13
+ export type ChatTranscriptProps<Host extends JsonObject = JsonObject> = {
14
+ /** What the app draws in the transcript; see {@link ChatTranscriptSlots}. Default: nothing. */
15
+ slots?: ChatTranscriptSlots<Host>;
12
16
  /** Draws a ref in the person's message; without it the message shows as its plain text. */
13
17
  renderRef?: (ref: UserRef) => ReactNode;
14
18
  blocks: readonly TranscriptBlock[];
@@ -90,4 +94,4 @@ export declare function ReferencedMedia({ reference }: {
90
94
  reference: MediaReference;
91
95
  }): import("react").JSX.Element;
92
96
  /** Theorem transcript blocks rendered as Astryx chat messages. */
93
- export declare function ChatTranscript(props: ChatTranscriptProps): import("react").JSX.Element;
97
+ export declare function ChatTranscript<Host extends JsonObject = JsonObject>(props: ChatTranscriptProps<Host>): import("react").JSX.Element;
@@ -46,6 +46,8 @@ const ShowToolDurations = createContext(true);
46
46
  const ShowWorkStatus = createContext(true);
47
47
  /** Whether a reply that went on after its call failed shows its notice (`ChatTranscriptProps.showResumedNotice`). */
48
48
  const ShowResumedNotice = createContext(true);
49
+ /** What the app draws under each reply (`ChatTranscriptProps.slots.reply`). */
50
+ const ReplySlot = createContext(undefined);
49
51
  /** What the transcript's props say a tool call's row shows. */
50
52
  function useToolRowShows() {
51
53
  return {
@@ -684,6 +686,7 @@ function PendingImage(props) {
684
686
  }
685
687
  function AssistantTurn(props) {
686
688
  const t = useLabels();
689
+ const replySlot = useContext(ReplySlot);
687
690
  const chrome = useChromeReveal(props.isNewest === true);
688
691
  const showUsage = useContext(ShowUsage);
689
692
  const showResumed = useContext(ShowResumedNotice);
@@ -711,7 +714,7 @@ function AssistantTurn(props) {
711
714
  : row.block.kind).map(({ item: row, index: i, key }) => (_jsx(BodyRowView
712
715
  // why: Not the block id: the committed turn re-mints ids, and a
713
716
  // remount would cut the text reveal short.
714
- , { row: row, streaming: props.streaming && i === rows.length - 1, imageOutput: props.imageOutput }, key))), _jsx(PendingImage, { imageOutput: props.imageOutput, streaming: props.streaming, rows: rows })] }) }));
717
+ , { row: row, streaming: props.streaming && i === rows.length - 1, imageOutput: props.imageOutput }, key))), _jsx(PendingImage, { imageOutput: props.imageOutput, streaming: props.streaming, rows: rows }), replySlot?.({ blocks: props.blocks, host: props.host ?? [], streaming: props.streaming })] }) }));
715
718
  }
716
719
  /** The notice of a reply that went on after its model call failed part-way, if it did. */
717
720
  function resumedNotice(blocks) {
@@ -744,7 +747,10 @@ function isBareFailure(group) {
744
747
  }
745
748
  /** Theorem transcript blocks rendered as Astryx chat messages. */
746
749
  export function ChatTranscript(props) {
747
- return (_jsx(TheoremLabelsProvider, { 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 }) }) }) }) }) }) }) }));
750
+ const reply = props.slots?.reply;
751
+ // why: The values are the app's, as its beforeSave wrote them; Theorem never reads them, so their type is the app's to name.
752
+ const replySlot = reply ? (shown) => reply(shown) : undefined;
753
+ return (_jsx(TheoremLabelsProvider, { children: _jsx(ReplySlot.Provider, { value: replySlot, 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 }) }) }) }) }) }) }) }) }));
748
754
  }
749
755
  function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, }) {
750
756
  const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers))), [blocks, dividers]);
@@ -780,7 +786,7 @@ function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToo
780
786
  });
781
787
  // why: A reply is dated when it last stopped: a reply that just finished reads "now".
782
788
  const at = endedAt ?? timeOf(key);
783
- return (_jsx(AssistantTurn, { ...turn, ...timing, blocks: group.blocks, streaming: live, at: at, error: failureOf(group), stopped: stopText(group.stop, group.blocks, labels), usage: group.usage, isNewest: index === groups.length - 1 }, key));
789
+ return (_jsx(AssistantTurn, { ...turn, ...timing, blocks: group.blocks, streaming: live, at: at, error: failureOf(group), stopped: stopText(group.stop, group.blocks, labels), usage: group.usage, host: group.host, isNewest: index === groups.length - 1 }, key));
784
790
  };
785
791
  const turns = groups.flatMap((group, index) => {
786
792
  const label = dividers?.[group.key];
@@ -2,6 +2,7 @@ import { type ChatComposerInputHandle, type ChatComposerTrigger } from '@astryxd
2
2
  import type { DefinedTheme } from '@astryxdesign/core/theme';
3
3
  import type { RefText, UserRef } from '@theoremjs/agents/interface';
4
4
  import { type ComposerPendingMessage, type ComposerProfileInterface } from '@theoremjs/agents/interface';
5
+ import type { JsonObject } from '@theoremjs/agents/kernel';
5
6
  import type { ChatController, PageTools, StatedTurn } from '@theoremjs/web/client';
6
7
  import { type ConversationView, type HttpTransportOptions, type TheoremTransport } from '@theoremjs/web/client';
7
8
  import { type ReactNode, type Ref } from 'react';
@@ -211,7 +212,7 @@ export type TheoremChatComposerProps = {
211
212
  * `TheoremChatTranscript`.
212
213
  */
213
214
  export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, }: TheoremChatComposerProps): import("react").JSX.Element;
214
- export type TheoremChatTranscriptProps = Omit<ChatTranscriptProps, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
215
+ export type TheoremChatTranscriptProps<Host extends JsonObject = JsonObject> = Omit<ChatTranscriptProps<Host>, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
215
216
  /** The chat it shows (`useTheoremChat`). */
216
217
  chat: TheoremChatState;
217
218
  /** The profile's interface (`useTheoremInterface`). */
@@ -224,7 +225,7 @@ export type TheoremChatTranscriptProps = Omit<ChatTranscriptProps, 'blocks' | 'h
224
225
  * and its times on the chat's turn clock, so they agree with `TheoremChatComposer` wherever each
225
226
  * is placed.
226
227
  */
227
- export declare function TheoremChatTranscript({ chat, iface, handle, ...props }: TheoremChatTranscriptProps): import("react").JSX.Element;
228
+ export declare function TheoremChatTranscript<Host extends JsonObject = JsonObject>({ chat, iface, handle, ...props }: TheoremChatTranscriptProps<Host>): import("react").JSX.Element;
228
229
  /**
229
230
  * Drop-in chat for a profile served by `createTheoremHandler`:
230
231
  *
@@ -1,8 +1,27 @@
1
1
  import type { ToolGate } from '@theoremjs/agents/kernel';
2
2
  import type { ToolDecisionAction } from '@theoremjs/web/client';
3
+ import { type ReactNode } from 'react';
3
4
  export type ToolDecision = ToolDecisionAction;
4
5
  /** The widest a gate card gets, in pixels. */
5
6
  export declare const GATE_CARD_WIDTH = 400;
7
+ export type ActionCardProps = {
8
+ /** What the card asks or tells, as its title. */
9
+ title: string;
10
+ /** Drawn before the title, such as an `Icon`. */
11
+ icon?: ReactNode;
12
+ /** Drawn at the title's far end, such as a tag. */
13
+ tag?: ReactNode;
14
+ /** What the card says, under its title. */
15
+ children?: ReactNode;
16
+ /** The card's buttons, in a row at its end, aligned to the right. */
17
+ actions?: ReactNode;
18
+ };
19
+ /**
20
+ * The frame of a card that asks the person for something: its width, its title with an icon and a
21
+ * tag, its body, and its row of buttons. `ApprovalCard` and `AuthChallengeCard` are built on it; a
22
+ * host builds its own cards on it, as in a reply's slot.
23
+ */
24
+ export declare function ActionCard(props: ActionCardProps): import("react").JSX.Element;
6
25
  export type ApprovalCardProps = {
7
26
  gate: ToolGate;
8
27
  toolName: string;
@@ -27,9 +27,14 @@ function formatInput(value) {
27
27
  return '';
28
28
  return JSON.stringify(value, null, 2);
29
29
  }
30
- /** The one frame of every gate card: what is asked, a tag beside it, and what answers it. */
31
- function GateCard(props) {
32
- return (_jsx(Card, { variant: "bubble", elevation: "med", maxWidth: GATE_CARD_WIDTH, children: _jsxs(VStack, { gap: 3, children: [_jsxs(HStack, { justify: "between", align: "start", gap: 3, children: [_jsx(Text, { type: "large", weight: "semibold", tabIndex: -1, "data-autofocus": true, style: TITLE_FOCUS, children: props.heading }), props.tag] }), props.children] }) }));
30
+ /**
31
+ * The frame of a card that asks the person for something: its width, its title with an icon and a
32
+ * tag, its body, and its row of buttons. `ApprovalCard` and `AuthChallengeCard` are built on it; a
33
+ * host builds its own cards on it, as in a reply's slot.
34
+ */
35
+ export function ActionCard(props) {
36
+ const title = (_jsx(Text, { type: "large", weight: "semibold", tabIndex: -1, "data-autofocus": true, style: TITLE_FOCUS, children: props.title }));
37
+ return (_jsx(Card, { variant: "bubble", elevation: "med", maxWidth: GATE_CARD_WIDTH, children: _jsxs(VStack, { gap: 3, children: [_jsxs(HStack, { justify: "between", align: "start", gap: 3, children: [props.icon ? (_jsxs(HStack, { gap: 2, align: "center", children: [props.icon, title] })) : (title), props.tag] }), props.children, props.actions ? (_jsx(HStack, { gap: 2, justify: "end", children: props.actions })) : null] }) }));
33
38
  }
34
39
  const ACCESS_ICON = {
35
40
  'read-only': IconEye,
@@ -46,7 +51,7 @@ export function ApprovalCard(props) {
46
51
  function ApprovalBody({ gate, toolName, agent, input, decided = null, onDecision, }) {
47
52
  const t = useLabels();
48
53
  const args = formatInput(gate.preparedArguments ?? input);
49
- return (_jsxs(GateCard, { heading: approvalHeading(t, gate, toolName, agent), tag: gate.access ? _jsx(ToolAccessTag, { access: gate.access }) : null, children: [gate.summary ? _jsx(Text, { color: "secondary", children: gate.summary }) : null, args ? (_jsx(Collapsible, { defaultIsOpen: false, trigger: _jsx(Text, { type: "supporting", children: t('@theorem.gate.approval.input') }), children: _jsx(CodeBlock, { code: args, language: "json", size: "sm" }) })) : null, _jsxs(HStack, { gap: 2, justify: "end", children: [_jsx(Button, { label: t('@theorem.gate.approval.deny'), variant: "ghost", isLoading: decided === 'deny', isDisabled: decided === 'allow', onClick: () => onDecision?.('deny') }), _jsx(Button, { label: t('@theorem.gate.approval.approve'), variant: "primary", isLoading: decided === 'allow', isDisabled: decided === 'deny', onClick: () => onDecision?.('allow') })] })] }));
54
+ return (_jsxs(ActionCard, { title: approvalHeading(t, gate, toolName, agent), tag: gate.access ? _jsx(ToolAccessTag, { access: gate.access }) : null, actions: _jsxs(_Fragment, { children: [_jsx(Button, { label: t('@theorem.gate.approval.deny'), variant: "ghost", isLoading: decided === 'deny', isDisabled: decided === 'allow', onClick: () => onDecision?.('deny') }), _jsx(Button, { label: t('@theorem.gate.approval.approve'), variant: "primary", isLoading: decided === 'allow', isDisabled: decided === 'deny', onClick: () => onDecision?.('allow') })] }), children: [gate.summary ? _jsx(Text, { color: "secondary", children: gate.summary }) : null, args ? (_jsx(Collapsible, { defaultIsOpen: false, trigger: _jsx(Text, { type: "supporting", children: t('@theorem.gate.approval.input') }), children: _jsx(CodeBlock, { code: args, language: "json", size: "sm" }) })) : null] }));
50
55
  }
51
56
  function AuthChallengeDetails({ challenge }) {
52
57
  const t = useLabels();
@@ -87,7 +92,7 @@ function AuthChallengeBody({ gate, toolName, onAuthenticated, submitted = false,
87
92
  setSecret('');
88
93
  onAuthenticated?.(value);
89
94
  }
90
- return (_jsxs(GateCard, { heading: t('@theorem.gate.auth.title', {
95
+ return (_jsxs(ActionCard, { title: t('@theorem.gate.auth.title', {
91
96
  tool: toolNameLabel(t, toolName, humanize(toolName).toLowerCase()),
92
97
  }), tag: _jsx(Text, { type: "supporting", textWrap: "nowrap", children: t(`@theorem.gate.tag.${authType}`) }), children: [_jsx(AuthChallengeDetails, { challenge: challenge }), _jsx(AuthAction, { authType: authType, authUrl: challenge.authorizationUrl, slot: slot, secret: secret, submitted: submitted, onSecretChange: setSecret, onSubmit: submit, onOpenSignIn: openSignIn })] }));
93
98
  }
package/ui/index.d.ts CHANGED
@@ -31,13 +31,14 @@ 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 { ChatReply, ChatReplySlot, ChatTranscriptSlots } from './reply-slot.js';
34
35
  export { InPlace, PaneLayout, PanePanel, Prose, RaisedPane } from './SidePanel.js';
35
36
  export { DEFAULT_CHAT_MAX_WIDTH, TheoremChat, TheoremChatComposer, type TheoremChatComposerProps, type TheoremChatHandle, type TheoremChatProps, TheoremChatTranscript, type TheoremChatTranscriptProps, } from './TheoremChat.js';
36
37
  export { TheoremDecision, type TheoremDecisionProps } from './TheoremDecision.js';
37
38
  export { TheoremEmbedding, type TheoremEmbeddingProps } from './TheoremEmbedding.js';
38
39
  export { TheoremHost, type TheoremHostProps } from './TheoremHost.js';
39
40
  export { TheoremSurface, type TheoremSurfaceProps } from './TheoremSurface.js';
40
- export { ApprovalCard, type ApprovalCardProps, AuthChallengeCard, type AuthChallengeCardProps, type ToolDecision, } from './ToolGateCard.js';
41
+ export { ActionCard, type ActionCardProps, ApprovalCard, type ApprovalCardProps, AuthChallengeCard, type AuthChallengeCardProps, type ToolDecision, } from './ToolGateCard.js';
41
42
  export { ToolResult } from './ToolResult.js';
42
43
  export { TraceGuardrailsView, TracePlacement, useTraceInspector } from './TraceInspectorPanel.js';
43
44
  export { ChartStat } from './TraceOverview.js';
package/ui/index.js CHANGED
@@ -38,7 +38,7 @@ export { TheoremDecision } from "./TheoremDecision.js";
38
38
  export { TheoremEmbedding } from "./TheoremEmbedding.js";
39
39
  export { TheoremHost } from "./TheoremHost.js";
40
40
  export { TheoremSurface } from "./TheoremSurface.js";
41
- export { ApprovalCard, AuthChallengeCard, } from "./ToolGateCard.js";
41
+ export { ActionCard, ApprovalCard, AuthChallengeCard, } from "./ToolGateCard.js";
42
42
  export { ToolResult } from "./ToolResult.js";
43
43
  export { TraceGuardrailsView, TracePlacement, useTraceInspector } from "./TraceInspectorPanel.js";
44
44
  export { ChartStat } from "./TraceOverview.js";
@@ -0,0 +1,23 @@
1
+ import type { TranscriptBlock } from '@theoremjs/agents/interface';
2
+ import type { JsonObject } from '@theoremjs/agents/kernel';
3
+ import type { ReactNode } from 'react';
4
+ /** A reply as the transcript's `reply` slot is given it. `Host` is the type of the app's own values. */
5
+ export type ChatReply<Host extends JsonObject = JsonObject> = {
6
+ /** The reply's blocks as the transcript draws them, its tool calls with their outputs among them. */
7
+ blocks: readonly TranscriptBlock[];
8
+ /**
9
+ * The `host` value of each of the reply's blocks that has one, in order, its `turn-done` blocks
10
+ * too. The app sets them in `beforeSave`, so a reply has them once it is saved. Empty when it has
11
+ * none. Theorem never reads them and does not check their shape.
12
+ */
13
+ host: readonly Host[];
14
+ /** `true` while the reply is on its way. */
15
+ streaming: boolean;
16
+ };
17
+ /** Drawn under each reply. Unset or `null` draws nothing. */
18
+ export type ChatReplySlot<Host extends JsonObject = JsonObject> = null | ((reply: ChatReply<Host>) => ReactNode);
19
+ /** What the app draws in the transcript's slots. */
20
+ export type ChatTranscriptSlots<Host extends JsonObject = JsonObject> = {
21
+ /** Under each reply, inside its message. */
22
+ reply?: ChatReplySlot<Host>;
23
+ };
@@ -0,0 +1 @@
1
+ export {};