@theoremjs/react 0.3.5-next.1033.g5c598ea → 0.3.5-next.1034.gfe14d6a

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
@@ -183,6 +183,7 @@ To draw your own figures like the trace panel does, `@theoremjs/react/ui` also e
183
183
  | `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). |
184
184
  | `resolveMedia` | Turns a tool's reference into an address the page can load. See [Tool media](#tool-media). |
185
185
  | `mediaViewer` | The viewer every picture and video opens in. Default: Astryx's Lightbox, with zoom. See [Your own media viewer](#your-own-media-viewer). |
186
+ | `transcript` | The options of `TheoremChatTranscript` that the chat does not set itself, given to its transcript as they are: `slots`, `dividers`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `showWorkStatus`, and `showResumedNotice`. Its type is `TheoremChatTranscriptOptions`. See [Draw under a reply](#draw-under-a-reply). |
186
187
 
187
188
  ### The row composer's look
188
189
 
@@ -718,7 +719,7 @@ function Dock({ chat, iface }) {
718
719
  }
719
720
  ```
720
721
 
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
+ `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`, `showResumedNotice`, `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
723
 
723
724
  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
725
 
@@ -754,7 +755,7 @@ The hooks and the client write no English text. They return kinds, codes, and st
754
755
 
755
756
  ### Draw under a reply
756
757
 
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
+ 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`, or `transcript={{ slots: { reply } }}` to `TheoremChat`. `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
 
759
760
  `reply` receives a `ChatReply`:
760
761
 
@@ -780,20 +781,18 @@ beforeSave: async (at, reply) => ({
780
781
  // page
781
782
  type JoinCard = { card: 'join'; room: string };
782
783
 
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
- />
784
+ const drawJoinCard = ({ host }: ChatReply<JoinCard>) => {
785
+ const join = host.find((value) => value.card === 'join');
786
+ return join ? (
787
+ <ActionCard title={`Join ${join.room}`} actions={<Button label="Join" onClick={() => open(join.room)} />} />
788
+ ) : null;
789
+ };
790
+
791
+ <TheoremChat<JoinCard> endpoint="/api/theorem" transcript={{ slots: { reply: drawJoinCard } }} />
795
792
  ```
796
793
 
794
+ `TheoremChatTranscript` takes the slot as `slots={{ reply: drawJoinCard }}`, with the same type argument.
795
+
797
796
  The type argument is the type of your values, a JSON object type. Theorem does not check their shape against it.
798
797
 
799
798
  These rules apply:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.1033.g5c598ea",
3
+ "version": "0.3.5-next.1034.gfe14d6a",
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.1033.g5c598ea",
64
- "@theoremjs/web": "^0.3.5-next.1033.g5c598ea"
63
+ "@theoremjs/agents": "^0.3.5-next.1034.gfe14d6a",
64
+ "@theoremjs/web": "^0.3.5-next.1034.gfe14d6a"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -14,7 +14,7 @@ import { type ChatTranscriptProps } from './ChatTranscript.js';
14
14
  import type { TheoremLabels } from './labels.js';
15
15
  import type { MediaViewer } from './media-viewer.js';
16
16
  import type { ResolveMedia, ToolMediaShown } from './tool-media.js';
17
- export type TheoremChatProps = {
17
+ export type TheoremChatProps<Host extends JsonObject = JsonObject> = {
18
18
  /** Where `createTheoremHandler` is mounted. Default `/api/theorem`. Ignored when `transport` is set. */
19
19
  endpoint?: string;
20
20
  /** Extra fetch options for the default HTTP transport (auth headers, custom fetch). */
@@ -160,7 +160,18 @@ export type TheoremChatProps = {
160
160
  renderRef?: (ref: UserRef) => ReactNode;
161
161
  /** Stands in for the send button while the composer is empty; see `ChatComposerBarProps.emptyAction`. */
162
162
  composerEmptyAction?: ReactNode;
163
+ /**
164
+ * The transcript's own options, given to {@link TheoremChatTranscript} as they are: its `slots`,
165
+ * such as the `reply` slot, and how it lays out a reply. `Host` is the type of the values your
166
+ * server sets on a reply's blocks in `beforeSave`.
167
+ */
168
+ transcript?: TheoremChatTranscriptOptions<Host>;
163
169
  };
170
+ /**
171
+ * What {@link TheoremChat} gives its transcript from the `transcript` prop: every option of
172
+ * {@link TheoremChatTranscript} that the chat does not set itself.
173
+ */
174
+ export type TheoremChatTranscriptOptions<Host extends JsonObject = JsonObject> = Omit<TheoremChatTranscriptProps<Host>, 'chat' | 'iface' | 'handle' | 'usage' | 'renderRef' | 'emptyState'>;
164
175
  /** What a host can do to a mounted {@link TheoremChat}. */
165
176
  export type TheoremChatHandle = {
166
177
  /**
@@ -233,4 +244,4 @@ export declare function TheoremChatTranscript<Host extends JsonObject = JsonObje
233
244
  * <TheoremChat endpoint="/api/theorem" />
234
245
  * ```
235
246
  */
236
- export declare function TheoremChat({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, media, resolveMedia, mediaViewer, ...rest }: TheoremChatProps): import("react").JSX.Element;
247
+ export declare function TheoremChat<Host extends JsonObject = JsonObject>({ endpoint, http, transport, theme, mode, labels, detectCodeLanguage, media, resolveMedia, mediaViewer, ...rest }: TheoremChatProps<Host>): import("react").JSX.Element;
package/ui/TheoremChat.js CHANGED
@@ -76,7 +76,7 @@ function ChatBodyComposer({ body, chat, inputRef, }) {
76
76
  return failure ? _jsx(Banner, { status: "error", role: "alert", title: failure.error }) : null;
77
77
  }
78
78
  function ChatBody(props) {
79
- const { transport, iface, emptyState, density, maxWidth = DEFAULT_CHAT_MAX_WIDTH, scrollRef, trace, usage, className, style, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, refText, renderRef, options, onOptionsChange, stated, context, pageTools, onTurnEvent, } = props;
79
+ const { transport, iface, emptyState, density, maxWidth = DEFAULT_CHAT_MAX_WIDTH, scrollRef, trace, usage, className, style, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, refText, renderRef, options, onOptionsChange, stated, context, pageTools, onTurnEvent, transcript, } = props;
80
80
  const t = useLabels();
81
81
  const chat = useTheoremChat({
82
82
  transport,
@@ -104,7 +104,7 @@ function ChatBody(props) {
104
104
  const header = _jsx(SidePanelHeader, { floating: true, children: inspector.toggle });
105
105
  const composer = _jsx(ChatBodyComposer, { body: props, chat: chat, inputRef: inputRef });
106
106
  const docked = { composer, composerRef, maxWidth };
107
- 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, renderRef: renderRef })) }) }) }));
107
+ 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, renderRef: renderRef, transcript: transcript })) }) }) }));
108
108
  }
109
109
  const CHAT_SCROLL = { overscrollBehavior: 'none' };
110
110
  /**
@@ -120,10 +120,10 @@ function ChatLanding({ composer, composerRef, maxWidth, handle, emptyState, }) {
120
120
  * why: the dock leaves 12px under the composer; paddingBlockEnd={3} adds 12px more for a 24px
121
121
  * bottom margin.
122
122
  */
123
- function ChatThread({ composer, composerRef, maxWidth, chat, iface, handle, density, scrollRef, usage, renderRef, }) {
123
+ function ChatThread({ composer, composerRef, maxWidth, chat, iface, handle, density, scrollRef, usage, renderRef, transcript, }) {
124
124
  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,
125
125
  // why: Scrolling past either end does not bounce the transcript and its docked composer.
126
- 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, renderRef: renderRef }) }) })] }));
126
+ 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, { ...transcript, chat: chat, iface: iface, handle: handle, usage: usage, renderRef: renderRef }) }) })] }));
127
127
  }
128
128
  /**
129
129
  * The transcript bound to a chat: its blocks as they stream, its gates answered through the chat,
package/ui/index.d.ts CHANGED
@@ -33,7 +33,7 @@ export { RadialBars, Sunburst, type SunburstNode } from './RadialCharts.js';
33
33
  export { type RankedBar, RankedBars } from './RankedBars.js';
34
34
  export type { ChatReply, ChatReplySlot, ChatTranscriptSlots } from './reply-slot.js';
35
35
  export { InPlace, PaneLayout, PanePanel, Prose, RaisedPane } from './SidePanel.js';
36
- export { DEFAULT_CHAT_MAX_WIDTH, TheoremChat, TheoremChatComposer, type TheoremChatComposerProps, type TheoremChatHandle, type TheoremChatProps, TheoremChatTranscript, type TheoremChatTranscriptProps, } from './TheoremChat.js';
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';
38
38
  export { TheoremEmbedding, type TheoremEmbeddingProps } from './TheoremEmbedding.js';
39
39
  export { TheoremHost, type TheoremHostProps } from './TheoremHost.js';