@theoremjs/react 0.3.4-next.881.gf46821d → 0.3.5-next.1000.g569f044

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.
Files changed (88) hide show
  1. package/README.md +132 -6
  2. package/client/live/use-live-caption-log.d.ts +1 -1
  3. package/client/trace-story.d.ts +1 -1
  4. package/client/transcript-groups.d.ts +27 -4
  5. package/client/transcript-groups.js +45 -7
  6. package/components/InkWaveform.d.ts +1 -1
  7. package/components/live/use-live-call.d.ts +3 -3
  8. package/components/live/use-live-runner-controls.d.ts +2 -2
  9. package/components/live/use-live-runner-ui.d.ts +3 -3
  10. package/components/live/use-live-session-client.d.ts +2 -2
  11. package/components/use-composer-voice.d.ts +1 -1
  12. package/components/use-voice-playback.d.ts +1 -1
  13. package/hooks/use-embedding-index.d.ts +1 -1
  14. package/hooks/use-theorem-chat.d.ts +45 -44
  15. package/hooks/use-theorem-chat.js +10 -1
  16. package/hooks/use-theorem-decision.d.ts +1 -1
  17. package/hooks/use-theorem-embedding.d.ts +1 -1
  18. package/hooks/use-theorem-host.d.ts +1 -1
  19. package/hooks/use-turn-clock.d.ts +19 -0
  20. package/hooks/use-turn-clock.js +71 -0
  21. package/index.d.ts +8 -6
  22. package/index.js +1 -0
  23. package/live.d.ts +4 -4
  24. package/package.json +5 -5
  25. package/ui/ChatComposerBar.d.ts +17 -0
  26. package/ui/ChatComposerBar.js +141 -50
  27. package/ui/ChatComposerRow.d.ts +54 -0
  28. package/ui/ChatComposerRow.js +194 -0
  29. package/ui/ChatTranscript.d.ts +31 -2
  30. package/ui/ChatTranscript.js +158 -90
  31. package/ui/ConsoleFrame.d.ts +2 -2
  32. package/ui/DecisionAnswers.d.ts +1 -1
  33. package/ui/DecisionAnswers.js +9 -6
  34. package/ui/DecisionImages.d.ts +4 -3
  35. package/ui/EmbeddingDocuments.d.ts +2 -2
  36. package/ui/EmbeddingQuery.d.ts +2 -2
  37. package/ui/EmbeddingResults.d.ts +3 -3
  38. package/ui/LiveCallTile.d.ts +2 -2
  39. package/ui/LiveCaptionsPanel.d.ts +1 -1
  40. package/ui/LiveRunner.d.ts +6 -4
  41. package/ui/LiveRunner.js +4 -4
  42. package/ui/LiveToolGateDialog.d.ts +1 -1
  43. package/ui/LiveVideoPreview.d.ts +1 -1
  44. package/ui/RadialCharts.d.ts +2 -2
  45. package/ui/RankedBars.d.ts +1 -1
  46. package/ui/SchemaFields.d.ts +1 -1
  47. package/ui/SchemaFields.js +56 -3
  48. package/ui/ShapedData.js +4 -4
  49. package/ui/StateFields.d.ts +1 -1
  50. package/ui/StateFields.js +3 -3
  51. package/ui/TheoremChat.d.ts +72 -4
  52. package/ui/TheoremChat.js +53 -33
  53. package/ui/TheoremDecision.d.ts +3 -3
  54. package/ui/TheoremEmbedding.d.ts +2 -2
  55. package/ui/TheoremHost.d.ts +16 -2
  56. package/ui/TheoremHost.js +6 -6
  57. package/ui/TheoremSurface.d.ts +22 -0
  58. package/ui/TheoremSurface.js +13 -0
  59. package/ui/ToolResult.js +8 -6
  60. package/ui/TraceCharts.d.ts +2 -2
  61. package/ui/TraceGuardrails.d.ts +2 -2
  62. package/ui/TraceInspectorPanel.d.ts +1 -1
  63. package/ui/TraceOverview.d.ts +2 -2
  64. package/ui/TraceSpanDetail.d.ts +1 -1
  65. package/ui/TraceStory.d.ts +2 -2
  66. package/ui/TraceValues.d.ts +2 -2
  67. package/ui/TraceWaterfall.d.ts +1 -1
  68. package/ui/approval-heading.d.ts +1 -1
  69. package/ui/built/theme.css +91 -41
  70. package/ui/built/theme.css.d.ts +2 -2
  71. package/ui/built/theorem.d.ts +2 -2
  72. package/ui/built/theorem.js +41 -19
  73. package/ui/built/theorem.variants.d.ts +2 -2
  74. package/ui/embedding-space-view.d.ts +1 -1
  75. package/ui/index.d.ts +33 -28
  76. package/ui/index.js +4 -1
  77. package/ui/labels-provider.d.ts +1 -1
  78. package/ui/labels.d.ts +66 -2
  79. package/ui/labels.js +64 -0
  80. package/ui/media-viewer.d.ts +34 -0
  81. package/ui/media-viewer.js +27 -0
  82. package/ui/tool-media-shown.d.ts +13 -0
  83. package/ui/tool-media-shown.js +15 -0
  84. package/ui/tool-media.d.ts +34 -0
  85. package/ui/tool-media.js +52 -0
  86. package/ui/trace-patterns.d.ts +1 -1
  87. package/ui/transcript-copy-text.d.ts +1 -1
  88. package/ui/transcript-copy-text.js +1 -1
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from 'react';
2
- import { type LabelText, type TheoremLabels } from './labels.ts';
2
+ import { type LabelText, type TheoremLabels } from './labels.js';
3
3
  export type TheoremLabelsProviderProps = {
4
4
  /** Replacements by locale for any `@theorem.*` or `@astryx.*` line; checked on mount. */
5
5
  labels?: TheoremLabels;
package/ui/labels.d.ts CHANGED
@@ -8,8 +8,8 @@
8
8
  * @module
9
9
  */
10
10
  import { type ComposerDrawerSummary, type LiveState } from '@theoremjs/web/client';
11
- import type { LiveActiveTool } from '../client/live/apply-live-turn-tool-event.ts';
12
- import type { TurnUsage, WorkStatus } from '../client/transcript-groups.ts';
11
+ import type { LiveActiveTool } from '../client/live/apply-live-turn-tool-event.js';
12
+ import type { TurnUsage, WorkStatus } from '../client/transcript-groups.js';
13
13
  export declare const THEOREM_UI_CATALOG: {
14
14
  readonly '@theorem.agent.handle': {
15
15
  readonly defaultMessage: "@{handle}";
@@ -89,6 +89,45 @@ export declare const THEOREM_UI_CATALOG: {
89
89
  readonly defaultMessage: "Set it aside to send later.";
90
90
  readonly description: "Send menu item detail: the message waits in the composer until sent.";
91
91
  };
92
+ readonly '@theorem.composer.menu.queue.gated.description': {
93
+ readonly defaultMessage: "Send it once you answer the waiting step.";
94
+ readonly description: "Send menu item detail while a step waits for approval: the message waits for the answer.";
95
+ };
96
+ readonly '@theorem.composer.menu.send_now.gated.description': {
97
+ readonly defaultMessage: "Cancel the waiting step and send this instead.";
98
+ readonly description: "Send menu item detail while a step waits for approval: ends the wait, then sends.";
99
+ };
100
+ readonly '@theorem.composer.send_menu': {
101
+ readonly defaultMessage: "Send options";
102
+ readonly description: "The row composer's button while a reply runs: it opens the send menu.";
103
+ };
104
+ readonly '@theorem.composer.pill.working': {
105
+ readonly defaultMessage: "Working";
106
+ readonly description: "The row composer's pill while the agent replies, before its start is known.";
107
+ };
108
+ readonly '@theorem.composer.pill.working_for': {
109
+ readonly defaultMessage: "Working for {duration}";
110
+ readonly description: "The row composer's pill while the agent replies, with how long it has run.";
111
+ readonly params: readonly ["duration"];
112
+ };
113
+ readonly '@theorem.composer.tray.expand': {
114
+ readonly defaultMessage: "Expand {label}";
115
+ readonly description: "Names the row composer's tray toggle while the tray is folded.";
116
+ readonly params: readonly ["label"];
117
+ };
118
+ readonly '@theorem.composer.tray.collapse': {
119
+ readonly defaultMessage: "Collapse {label}";
120
+ readonly description: "Names the row composer's tray toggle while the tray is open.";
121
+ readonly params: readonly ["label"];
122
+ };
123
+ readonly '@theorem.composer.pill.stop': {
124
+ readonly defaultMessage: "Stop";
125
+ readonly description: "The stop button on the working pill.";
126
+ };
127
+ readonly '@theorem.composer.pill.background': {
128
+ readonly defaultMessage: "Running in the background";
129
+ readonly description: "Read by screen readers on a background job pill, after its name.";
130
+ };
92
131
  readonly '@theorem.composer.hint.stash-selected-draft.message': {
93
132
  readonly defaultMessage: "Replacing this?";
94
133
  readonly description: "Hint when the whole draft is selected and could be stashed.";
@@ -145,6 +184,14 @@ export declare const THEOREM_UI_CATALOG: {
145
184
  readonly defaultMessage: "Steering: the agent reads it at its next step.";
146
185
  readonly description: "Tooltip on a waiting steering message.";
147
186
  };
187
+ readonly '@theorem.composer.pending.saved': {
188
+ readonly defaultMessage: "Sent";
189
+ readonly description: "Name of a waiting message the host has saved, read by screen readers on its icon.";
190
+ };
191
+ readonly '@theorem.composer.pending.saved.description': {
192
+ readonly defaultMessage: "Sent: the agent reads it with its next reply.";
193
+ readonly description: "Tooltip on a waiting message the host has saved.";
194
+ };
148
195
  readonly '@theorem.composer.pending.queue': {
149
196
  readonly defaultMessage: "Queued";
150
197
  readonly description: "Name of a waiting queued message, read by screen readers on its icon.";
@@ -319,6 +366,11 @@ export declare const THEOREM_UI_CATALOG: {
319
366
  readonly defaultMessage: "Worked";
320
367
  readonly description: "Turn status once done, duration unknown.";
321
368
  };
369
+ readonly '@theorem.transcript.thought': {
370
+ readonly defaultMessage: "Thought: {text}";
371
+ readonly description: "A thought where it came in a reply, folded to one line; `text` is the thought, cut off at the line's end.";
372
+ readonly params: readonly ["text"];
373
+ };
322
374
  readonly '@theorem.transcript.worked_for': {
323
375
  readonly defaultMessage: "Worked for {duration}";
324
376
  readonly description: "Turn status once done.";
@@ -482,6 +534,14 @@ export declare const THEOREM_UI_CATALOG: {
482
534
  readonly defaultMessage: "Add a value";
483
535
  readonly description: "A list of words in the state, while it is empty.";
484
536
  };
537
+ readonly '@theorem.decision.send_null': {
538
+ readonly defaultMessage: "Send null";
539
+ readonly description: "Sends the JSON null for a field that takes it, instead of leaving the field out.";
540
+ };
541
+ readonly '@theorem.decision.shape': {
542
+ readonly defaultMessage: "Kind";
543
+ readonly description: "Picks which of its shapes a request takes, for a tool whose input is one of several.";
544
+ };
485
545
  readonly '@theorem.decision.invalid_json': {
486
546
  readonly defaultMessage: "Not valid JSON yet";
487
547
  readonly description: "The state doesn't parse.";
@@ -880,6 +940,10 @@ export declare const THEOREM_UI_CATALOG: {
880
940
  readonly defaultMessage: "MCP";
881
941
  readonly description: "A tool served by an MCP server.";
882
942
  };
943
+ readonly '@theorem.host.kind.agent': {
944
+ readonly defaultMessage: "Agent";
945
+ readonly description: "A tool that asks another agent.";
946
+ };
883
947
  readonly '@theorem.tool.access.read-only': {
884
948
  readonly defaultMessage: "Read only";
885
949
  readonly description: "A tool that only reads.";
package/ui/labels.js CHANGED
@@ -76,6 +76,45 @@ export const THEOREM_UI_CATALOG = {
76
76
  defaultMessage: 'Set it aside to send later.',
77
77
  description: 'Send menu item detail: the message waits in the composer until sent.',
78
78
  },
79
+ '@theorem.composer.menu.queue.gated.description': {
80
+ defaultMessage: 'Send it once you answer the waiting step.',
81
+ description: 'Send menu item detail while a step waits for approval: the message waits for the answer.',
82
+ },
83
+ '@theorem.composer.menu.send_now.gated.description': {
84
+ defaultMessage: 'Cancel the waiting step and send this instead.',
85
+ description: 'Send menu item detail while a step waits for approval: ends the wait, then sends.',
86
+ },
87
+ '@theorem.composer.send_menu': {
88
+ defaultMessage: 'Send options',
89
+ description: "The row composer's button while a reply runs: it opens the send menu.",
90
+ },
91
+ '@theorem.composer.pill.working': {
92
+ defaultMessage: 'Working',
93
+ description: "The row composer's pill while the agent replies, before its start is known.",
94
+ },
95
+ '@theorem.composer.pill.working_for': {
96
+ defaultMessage: 'Working for {duration}',
97
+ description: "The row composer's pill while the agent replies, with how long it has run.",
98
+ params: ['duration'],
99
+ },
100
+ '@theorem.composer.tray.expand': {
101
+ defaultMessage: 'Expand {label}',
102
+ description: "Names the row composer's tray toggle while the tray is folded.",
103
+ params: ['label'],
104
+ },
105
+ '@theorem.composer.tray.collapse': {
106
+ defaultMessage: 'Collapse {label}',
107
+ description: "Names the row composer's tray toggle while the tray is open.",
108
+ params: ['label'],
109
+ },
110
+ '@theorem.composer.pill.stop': {
111
+ defaultMessage: 'Stop',
112
+ description: 'The stop button on the working pill.',
113
+ },
114
+ '@theorem.composer.pill.background': {
115
+ defaultMessage: 'Running in the background',
116
+ description: 'Read by screen readers on a background job pill, after its name.',
117
+ },
79
118
  '@theorem.composer.hint.stash-selected-draft.message': {
80
119
  defaultMessage: 'Replacing this?',
81
120
  description: 'Hint when the whole draft is selected and could be stashed.',
@@ -132,6 +171,14 @@ export const THEOREM_UI_CATALOG = {
132
171
  defaultMessage: 'Steering: the agent reads it at its next step.',
133
172
  description: 'Tooltip on a waiting steering message.',
134
173
  },
174
+ '@theorem.composer.pending.saved': {
175
+ defaultMessage: 'Sent',
176
+ description: 'Name of a waiting message the host has saved, read by screen readers on its icon.',
177
+ },
178
+ '@theorem.composer.pending.saved.description': {
179
+ defaultMessage: 'Sent: the agent reads it with its next reply.',
180
+ description: 'Tooltip on a waiting message the host has saved.',
181
+ },
135
182
  '@theorem.composer.pending.queue': {
136
183
  defaultMessage: 'Queued',
137
184
  description: 'Name of a waiting queued message, read by screen readers on its icon.',
@@ -294,6 +341,11 @@ export const THEOREM_UI_CATALOG = {
294
341
  defaultMessage: 'Worked',
295
342
  description: 'Turn status once done, duration unknown.',
296
343
  },
344
+ '@theorem.transcript.thought': {
345
+ defaultMessage: 'Thought: {text}',
346
+ description: "A thought where it came in a reply, folded to one line; `text` is the thought, cut off at the line's end.",
347
+ params: ['text'],
348
+ },
297
349
  '@theorem.transcript.worked_for': {
298
350
  defaultMessage: 'Worked for {duration}',
299
351
  description: 'Turn status once done.',
@@ -445,6 +497,14 @@ export const THEOREM_UI_CATALOG = {
445
497
  defaultMessage: 'Add a value',
446
498
  description: 'A list of words in the state, while it is empty.',
447
499
  },
500
+ '@theorem.decision.send_null': {
501
+ defaultMessage: 'Send null',
502
+ description: 'Sends the JSON null for a field that takes it, instead of leaving the field out.',
503
+ },
504
+ '@theorem.decision.shape': {
505
+ defaultMessage: 'Kind',
506
+ description: 'Picks which of its shapes a request takes, for a tool whose input is one of several.',
507
+ },
448
508
  '@theorem.decision.invalid_json': {
449
509
  defaultMessage: 'Not valid JSON yet',
450
510
  description: "The state doesn't parse.",
@@ -837,6 +897,10 @@ export const THEOREM_UI_CATALOG = {
837
897
  defaultMessage: 'MCP',
838
898
  description: 'A tool served by an MCP server.',
839
899
  },
900
+ '@theorem.host.kind.agent': {
901
+ defaultMessage: 'Agent',
902
+ description: 'A tool that asks another agent.',
903
+ },
840
904
  '@theorem.tool.access.read-only': {
841
905
  defaultMessage: 'Read only',
842
906
  description: 'A tool that only reads.',
@@ -0,0 +1,34 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type MediaReference } from './tool-media.js';
3
+ /** One picture or video the viewer shows. */
4
+ export type MediaViewerItem = {
5
+ type: 'image' | 'video';
6
+ /** The address the page loads it from. */
7
+ src: string;
8
+ alt: string;
9
+ caption?: ReactNode;
10
+ /** The saved file it was loaded from, when the app saved it: `src` may be a link that expires. */
11
+ reference?: MediaReference;
12
+ };
13
+ /** What a viewer is given: it is open or closed, and shows `media[index]`. */
14
+ export type MediaViewerProps = {
15
+ isOpen: boolean;
16
+ onOpenChange: (isOpen: boolean) => void;
17
+ media: readonly MediaViewerItem[];
18
+ index: number;
19
+ onIndexChange: (index: number) => void;
20
+ };
21
+ /** The viewer every picture and video in Theorem opens in. Astryx's Lightbox, with zoom, unless the page gives its own. */
22
+ export type MediaViewer = (props: MediaViewerProps) => ReactNode;
23
+ /** Astryx's Lightbox, with zoom: the viewer when the page gives none. */
24
+ export declare function AstryxMediaViewer({ isOpen, onOpenChange, media, index, onIndexChange, }: MediaViewerProps): import("react").JSX.Element;
25
+ /** The page's viewer, held open or closed by its caller. */
26
+ export declare function PageMediaViewer(props: MediaViewerProps): import("react").JSX.Element;
27
+ /**
28
+ * The page's viewer over `media`, closed until `open`; render `element` where the viewer belongs.
29
+ * A viewer may report the index or open state it already has; that changes nothing.
30
+ */
31
+ export declare function useMediaViewer(media: readonly MediaViewerItem[]): {
32
+ open: (index?: number) => void;
33
+ element: ReactNode;
34
+ };
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Lightbox } from '@astryxdesign/core/Lightbox';
3
+ import { useState } from 'react';
4
+ import { useToolMedia } from "./tool-media.js";
5
+ /** Astryx's Lightbox, with zoom: the viewer when the page gives none. */
6
+ export function AstryxMediaViewer({ isOpen, onOpenChange, media, index, onIndexChange, }) {
7
+ return (_jsx(Lightbox, { isOpen: isOpen, onOpenChange: onOpenChange, media: media.map(({ src, alt, caption, type }) => ({ src, alt, caption, type })), index: index, onIndexChange: onIndexChange, hasZoom: true }));
8
+ }
9
+ /** The page's viewer, held open or closed by its caller. */
10
+ export function PageMediaViewer(props) {
11
+ const Viewer = useToolMedia().viewer ?? AstryxMediaViewer;
12
+ return _jsx(Viewer, { ...props });
13
+ }
14
+ /**
15
+ * The page's viewer over `media`, closed until `open`; render `element` where the viewer belongs.
16
+ * A viewer may report the index or open state it already has; that changes nothing.
17
+ */
18
+ export function useMediaViewer(media) {
19
+ const [shown, setShown] = useState({
20
+ isOpen: false,
21
+ index: 0,
22
+ });
23
+ return {
24
+ open: (index = 0) => setShown({ isOpen: true, index }),
25
+ element: media.length > 0 ? (_jsx(PageMediaViewer, { isOpen: shown.isOpen, onOpenChange: (isOpen) => setShown((current) => (current.isOpen === isOpen ? current : { ...current, isOpen })), media: media, index: shown.index, onIndexChange: (index) => setShown((current) => (current.index === index ? current : { ...current, index })) })) : null,
26
+ };
27
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The media a tool returned that the chat shows: `sent`, what the tool sent to the person (a
3
+ * consumer chat); `all`, every piece the model read as well (an evaluation view). Media a model
4
+ * generated and files a person attached always show.
5
+ */
6
+ export type ToolMediaShown = 'sent' | 'all';
7
+ /** Whether a tool's piece of media shows under `shown`: under `sent`, only what the tool sent. */
8
+ export declare function toolMediaShows(block: {
9
+ fromTool?: true;
10
+ sent?: true;
11
+ }, shown: ToolMediaShown): boolean;
12
+ /** The last segment of a reference, the name it reads as; the whole reference when it has none. */
13
+ export declare function mediaFileName(uri: string): string;
@@ -0,0 +1,15 @@
1
+ /** Whether a tool's piece of media shows under `shown`: under `sent`, only what the tool sent. */
2
+ export function toolMediaShows(block, shown) {
3
+ return shown === 'all' || !block.fromTool || block.sent === true;
4
+ }
5
+ /** The last segment of a reference, the name it reads as; the whole reference when it has none. */
6
+ export function mediaFileName(uri) {
7
+ const path = uri.split(/[?#]/)[0] ?? uri;
8
+ const last = path.split('/').filter(Boolean).at(-1);
9
+ try {
10
+ return last ? decodeURIComponent(last) : uri;
11
+ }
12
+ catch {
13
+ return last ?? uri;
14
+ }
15
+ }
@@ -0,0 +1,34 @@
1
+ import type { ToolOutputRefPart } from '@theoremjs/agents';
2
+ import { type ReactNode } from 'react';
3
+ import type { MediaViewer } from './media-viewer.js';
4
+ import { type ToolMediaShown } from './tool-media-shown.js';
5
+ export { type ToolMediaShown, toolMediaShows } from './tool-media-shown.js';
6
+ /** A reference a tool returned, with the tool's own `metadata`: the person is shown it, the model never read it. */
7
+ export type MediaReference = ToolOutputRefPart;
8
+ /**
9
+ * Turns a tool's reference into an address the page may load, under the viewer's own sign-in, or
10
+ * `null` when there is none. Without it, a reference shows as a named file.
11
+ */
12
+ export type ResolveMedia = (reference: MediaReference) => string | null | Promise<string | null>;
13
+ /** What a page shows of tool media, how it loads a reference, and the viewer its pictures open in. */
14
+ export type ToolMediaView = {
15
+ shown: ToolMediaShown;
16
+ resolve?: ResolveMedia;
17
+ viewer?: MediaViewer;
18
+ };
19
+ export declare function ToolMediaProvider({ media, resolveMedia, mediaViewer, children, }: {
20
+ media?: ToolMediaShown;
21
+ resolveMedia?: ResolveMedia;
22
+ mediaViewer?: MediaViewer;
23
+ children: ReactNode;
24
+ }): import("react").JSX.Element;
25
+ export declare function useToolMedia(): ToolMediaView;
26
+ /**
27
+ * What the resolver makes of `reference`: `undefined` while it works, `null` when it gives no
28
+ * address (or there is no resolver, or it throws).
29
+ */
30
+ export declare function useResolvedMedia(reference: MediaReference | undefined): string | null | undefined;
31
+ /** A reference shown as the file it names, when nothing resolves it to show. */
32
+ export declare function MediaFileToken({ reference }: {
33
+ reference: MediaReference;
34
+ }): import("react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Token } from '@astryxdesign/core/Token';
3
+ import { createContext, use, useEffect, useRef, useState } from 'react';
4
+ import { mediaFileName } from "./tool-media-shown.js";
5
+ export { toolMediaShows } from "./tool-media-shown.js";
6
+ const ToolMediaContext = createContext({ shown: 'sent' });
7
+ export function ToolMediaProvider({ media = 'sent', resolveMedia, mediaViewer, children, }) {
8
+ return (_jsx(ToolMediaContext, { value: {
9
+ shown: media,
10
+ ...(resolveMedia ? { resolve: resolveMedia } : {}),
11
+ ...(mediaViewer ? { viewer: mediaViewer } : {}),
12
+ }, children: children }));
13
+ }
14
+ export function useToolMedia() {
15
+ return use(ToolMediaContext);
16
+ }
17
+ /**
18
+ * What the resolver makes of `reference`: `undefined` while it works, `null` when it gives no
19
+ * address (or there is no resolver, or it throws).
20
+ */
21
+ export function useResolvedMedia(reference) {
22
+ const { resolve } = useToolMedia();
23
+ const latest = useRef(reference);
24
+ latest.current = reference;
25
+ const type = reference?.type;
26
+ const mimeType = reference?.mimeType;
27
+ const uri = reference?.uri;
28
+ const [resolved, setResolved] = useState();
29
+ useEffect(() => {
30
+ const current = latest.current;
31
+ if (current === undefined || type === undefined || mimeType === undefined || uri === undefined)
32
+ return;
33
+ if (!resolve) {
34
+ setResolved({ uri, src: null });
35
+ return;
36
+ }
37
+ let live = true;
38
+ Promise.resolve()
39
+ .then(() => resolve(current))
40
+ .then((src) => live && setResolved({ uri, src: src ?? null }), () => live && setResolved({ uri, src: null }));
41
+ return () => {
42
+ live = false;
43
+ };
44
+ }, [resolve, type, mimeType, uri]);
45
+ if (uri === undefined)
46
+ return null;
47
+ return resolved?.uri === uri ? resolved.src : undefined;
48
+ }
49
+ /** A reference shown as the file it names, when nothing resolves it to show. */
50
+ export function MediaFileToken({ reference }) {
51
+ return _jsx(Token, { label: mediaFileName(reference.uri), description: reference.mimeType });
52
+ }
@@ -1,5 +1,5 @@
1
1
  import type { ComponentProps, CSSProperties, ReactNode } from 'react';
2
- import type { TraceActor } from '../client/trace-story.ts';
2
+ import type { TraceActor } from '../client/trace-story.js';
3
3
  /**
4
4
  * The trace charts' fills, one per series in order: the first is clear (a
5
5
  * solid), the second a fine hatch, and the rest shades of deep navy (#0D1E37).
@@ -1,4 +1,4 @@
1
1
  import type { TranscriptBlock } from '@theoremjs/agents/interface';
2
- import type { LabelText } from './labels.ts';
2
+ import type { LabelText } from './labels.js';
3
3
  /** Plain text copied from a transcript block. */
4
4
  export declare function transcriptBlockCopyText(t: LabelText, block: TranscriptBlock): string;
@@ -24,7 +24,7 @@ export function transcriptBlockCopyText(t, block) {
24
24
  case 'structured':
25
25
  return JSON.stringify(block.value, null, 2);
26
26
  case 'media':
27
- return block.url ?? t('@theorem.transcript.copy_text.media', { mimeType: block.mimeType });
27
+ return t('@theorem.transcript.copy_text.media', { mimeType: block.mimeType });
28
28
  case 'grounding':
29
29
  return JSON.stringify(block.grounding, null, 2);
30
30
  case 'citation':