@theoremjs/react 0.3.5-next.986.g09d7a13 → 0.3.5-next.987.ge2681d2

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
@@ -567,7 +567,7 @@ function Dock({ chat, iface }) {
567
567
  }
568
568
  ```
569
569
 
570
- `TheoremChatComposer` takes `layout`, `icons`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `toolDetail`, and `bodyKindPlacement`. Set `toolDetail={false}` when the people in the chat must not read what a tool ran with and what it returned: each call then shows only its labelled row. 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`, and `resolveMedia`.
570
+ `TheoremChatComposer` takes `layout`, `icons`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, and `bodyKindPlacement`. 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`, and `resolveMedia`.
571
571
 
572
572
  The two pieces read one clock: `chat.turnClock`. So the working pill of the composer and the status line of the transcript show the same time. `chat.workingSince` is when the reply in progress started, less its waits for approval. `chat.shownBlocks` is what the transcript shows: `chat.blocks`, then `chat.streamBlocks`.
573
573
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.986.g09d7a13",
3
+ "version": "0.3.5-next.987.ge2681d2",
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.986.g09d7a13",
64
- "@theoremjs/web": "^0.3.5-next.986.g09d7a13"
63
+ "@theoremjs/agents": "^0.3.5-next.987.ge2681d2",
64
+ "@theoremjs/web": "^0.3.5-next.987.ge2681d2"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -41,11 +41,11 @@ export type ChatTranscriptProps = {
41
41
  */
42
42
  usage?: boolean;
43
43
  /**
44
- * Show a tool call's detail when its row is opened: what it ran with, the calls its agent made,
45
- * and what came back. On by default. Off, each call is its labelled row only, for a chat whose
46
- * people should not read a tool's arguments and results.
44
+ * The profile's `tools.showData` (`iface.tools.showData`): whether a tool call's row opens on its
45
+ * detail, what it ran with, the calls its agent made, and what came back. On by default. Off, each
46
+ * call is its labelled row only, and an approval shows no input: the server sent none.
47
47
  */
48
- toolDetail?: boolean;
48
+ showToolData?: boolean;
49
49
  /**
50
50
  * Where body kinds sit in a reply. Default puts `citation` last (Sources under
51
51
  * the prose). Pass `{}` to keep stream order for inline citations.
@@ -38,11 +38,11 @@ import { transcriptBlockCopyText } from "./transcript-copy-text.js";
38
38
  import { VoiceNote } from "./VoiceNote.js";
39
39
  /** Whether the transcript shows usage (`ChatTranscriptProps.usage`). */
40
40
  const ShowUsage = createContext(false);
41
- /** Whether a tool call's row opens on its detail (`ChatTranscriptProps.toolDetail`). */
42
- const ShowToolDetail = createContext(true);
41
+ /** Whether a tool call's row opens on its detail (`ChatTranscriptProps.showToolData`). */
42
+ const ShowToolData = createContext(true);
43
43
  /** What the transcript's props say a tool call's row shows. */
44
44
  function useToolRowShows() {
45
- return { usage: useContext(ShowUsage), detail: useContext(ShowToolDetail) };
45
+ return { usage: useContext(ShowUsage), detail: useContext(ShowToolData) };
46
46
  }
47
47
  /** Largest a generated image renders in the transcript. */
48
48
  const GENERATED_IMAGE_MAX_WIDTH = 512;
@@ -537,6 +537,7 @@ function answerSent(answering, tool) {
537
537
  }
538
538
  function GateCard({ block, handle, handlers, }) {
539
539
  const { tool } = block;
540
+ const shows = useToolRowShows();
540
541
  const gate = personGate(tool);
541
542
  if (!gate)
542
543
  return null;
@@ -545,7 +546,7 @@ function GateCard({ block, handle, handlers, }) {
545
546
  if (gate.kind === 'auth') {
546
547
  return (_jsx(AuthChallengeCard, { gate: gate, toolName: tool.name, submitted: answer === 'auth', onAuthenticated: (secret) => handlers.onAuthenticated?.(index, secret) }));
547
548
  }
548
- return (_jsx(ApprovalCard, { gate: gate, toolName: tool.name, agent: handle, input: tool.arguments, decided: answer === 'auth' ? null : answer, onDecision: (action) => handlers.onToolDecision?.(index, action) }));
549
+ return (_jsx(ApprovalCard, { gate: gate, toolName: tool.name, agent: handle, ...(shows.detail ? { input: tool.arguments } : {}), decided: answer === 'auth' ? null : answer, onDecision: (action) => handlers.onToolDecision?.(index, action) }));
549
550
  }
550
551
  /** Live elapsed time while the turn streams; its final duration once it ends. */
551
552
  /** Live: counted from the start. Stopped: the work its blocks record. */
@@ -635,7 +636,7 @@ function isBareFailure(group) {
635
636
  }
636
637
  /** Theorem transcript blocks rendered as Astryx chat messages. */
637
638
  export function ChatTranscript(props) {
638
- return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(ShowToolDetail.Provider, { value: props.toolDetail !== false, children: _jsx(ChatTranscriptBody, { ...props }) }) }) }));
639
+ return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ChatTranscriptBody, { ...props }) }) }) }));
639
640
  }
640
641
  function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, labels, clock, }) {
641
642
  const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers))), [blocks, dividers]);
@@ -90,11 +90,6 @@ export type TheoremChatProps = {
90
90
  * on an agent tool's call row what the agent it ran used. Off by default.
91
91
  */
92
92
  usage?: boolean;
93
- /**
94
- * Show a tool call's detail when its row is opened: what it ran with, the calls its agent made,
95
- * and what came back. On by default. Off, each call is its labelled row only.
96
- */
97
- toolDetail?: boolean;
98
93
  className?: string;
99
94
  style?: React.CSSProperties;
100
95
  /**
@@ -185,7 +180,7 @@ export type TheoremChatComposerProps = {
185
180
  * `TheoremChatTranscript`.
186
181
  */
187
182
  export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, }: TheoremChatComposerProps): import("react").JSX.Element;
188
- export type TheoremChatTranscriptProps = Omit<ChatTranscriptProps, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels'> & {
183
+ export type TheoremChatTranscriptProps = Omit<ChatTranscriptProps, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
189
184
  /** The chat it shows (`useTheoremChat`). */
190
185
  chat: TheoremChatState;
191
186
  /** The profile's interface (`useTheoremInterface`). */
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";
@@ -75,7 +75,7 @@ function ChatBodyComposer({ hasComposer, ...props }) {
75
75
  const failure = props.chat.failure;
76
76
  return failure ? _jsx(Banner, { status: "error", role: "alert", title: failure.error }) : null;
77
77
  }
78
- function ChatBody({ transport, iface, placeholder, emptyState, density, maxWidth = DEFAULT_CHAT_MAX_WIDTH, scrollRef, trace, usage, toolDetail, className, style, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, composer: hasComposer = true, composerLayout, composerIcons, options, onOptionsChange, stated, context, pageTools, onTurnEvent, }) {
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, }) {
79
79
  const t = useLabels();
80
80
  const chat = useTheoremChat({
81
81
  transport,
@@ -102,7 +102,7 @@ function ChatBody({ transport, iface, placeholder, emptyState, density, maxWidth
102
102
  const header = _jsx(SidePanelHeader, { floating: true, children: inspector.toggle });
103
103
  const composer = (_jsx(ChatBodyComposer, { hasComposer: hasComposer, chat: chat, iface: iface, placeholder: placeholder, inputRef: inputRef, layout: composerLayout, icons: composerIcons }));
104
104
  const docked = { composer, composerRef, maxWidth };
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, toolDetail: toolDetail })) }) }) }));
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 })) }) }) }));
106
106
  }
107
107
  const CHAT_SCROLL = { overscrollBehavior: 'none' };
108
108
  /**
@@ -118,10 +118,10 @@ function ChatLanding({ composer, composerRef, maxWidth, handle, emptyState, }) {
118
118
  * why: the dock leaves 12px under the composer; paddingBlockEnd={3} adds 12px more for a 24px
119
119
  * bottom margin.
120
120
  */
121
- function ChatThread({ composer, composerRef, maxWidth, chat, iface, handle, density, scrollRef, usage, toolDetail, }) {
121
+ function ChatThread({ composer, composerRef, maxWidth, chat, iface, handle, density, scrollRef, usage, }) {
122
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,
123
123
  // why: Scrolling past either end does not bounce the transcript and its docked composer.
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, toolDetail: toolDetail }) }) })] }));
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
125
  }
126
126
  /**
127
127
  * The transcript bound to a chat: its blocks as they stream, its gates answered through the chat,
@@ -130,7 +130,7 @@ function ChatThread({ composer, composerRef, maxWidth, chat, iface, handle, dens
130
130
  */
131
131
  export function TheoremChatTranscript({ chat, iface, handle, ...props }) {
132
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, imageOutput: iface.type === 'image' ? { ratio: parseAspectRatio(iface.image.aspectRatio) } : undefined, onToolDecision: (index, action) => {
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
134
  void chat.handleToolDecision(index, action);
135
135
  }, onAuthenticated: (index, secret) => {
136
136
  void chat.handleAuthenticated(index, secret);