@theoremjs/react 0.3.0 → 0.3.1
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 +728 -202
- package/client/composer-hints.js +1 -1
- package/client/decision-images.d.ts +76 -0
- package/client/decision-images.js +139 -0
- package/client/decision-transport.d.ts +26 -4
- package/client/decision-transport.js +79 -6
- package/client/embedding-input.d.ts +84 -0
- package/client/embedding-input.js +194 -0
- package/client/embedding-space.d.ts +82 -0
- package/client/embedding-space.js +389 -0
- package/client/embedding-transport.d.ts +40 -0
- package/client/embedding-transport.js +71 -0
- package/client/failure.d.ts +7 -10
- package/client/failure.js +9 -9
- package/client/host-call.d.ts +1 -1
- package/client/host-call.js +7 -2
- package/client/host-transport.d.ts +2 -0
- package/client/host-transport.js +3 -2
- package/client/index.d.ts +19 -11
- package/client/index.js +14 -10
- package/client/ink-waveform.d.ts +1 -1
- package/client/ink-waveform.js +1 -2
- package/client/live/apply-live-turn-tool-event.js +1 -1
- package/client/live/live-captions.d.ts +30 -0
- package/client/live/live-captions.js +105 -1
- package/client/live/live-mic-forward.d.ts +1 -0
- package/client/live/live-mic-forward.js +11 -2
- package/client/live/live-page-tool.d.ts +34 -0
- package/client/live/live-page-tool.js +11 -0
- package/client/live/live-state.d.ts +4 -2
- package/client/live/live-state.js +2 -0
- package/client/live/live-video.js +1 -1
- package/client/live/run-live-tool-call.d.ts +7 -2
- package/client/live/run-live-tool-call.js +48 -10
- package/client/live/use-live-caption-log.d.ts +17 -0
- package/client/live/use-live-caption-log.js +51 -0
- package/client/live-client.d.ts +52 -4
- package/client/live-client.js +250 -59
- package/client/live-messages.d.ts +51 -13
- package/client/live-messages.js +42 -9
- package/client/page-dispatch.d.ts +15 -0
- package/client/page-dispatch.js +63 -0
- package/client/run-commit.d.ts +16 -43
- package/client/run-commit.js +26 -101
- package/client/run-session.d.ts +40 -41
- package/client/run-session.js +104 -112
- package/client/schema-fields.js +27 -6
- package/client/shaped-data.js +37 -8
- package/client/source-citations.js +1 -1
- package/client/space-geometry.d.ts +39 -0
- package/client/space-geometry.js +183 -0
- package/client/state-fields.js +1 -1
- package/client/tool-result.js +30 -12
- package/client/tool-resume.d.ts +18 -1
- package/client/tool-resume.js +4 -1
- package/client/trace-feed.d.ts +1 -1
- package/client/trace-story.d.ts +2 -2
- package/client/trace-story.js +43 -19
- package/client/trace-view.d.ts +2 -2
- package/client/trace-view.js +56 -16
- package/client/transcript-groups.d.ts +28 -2
- package/client/transcript-groups.js +63 -13
- package/client/transcript-schema.d.ts +10 -0
- package/client/transcript-schema.js +120 -0
- package/client/transport.d.ts +114 -26
- package/client/transport.js +106 -32
- package/client/turn-client.d.ts +17 -8
- package/client/turn-client.js +26 -31
- package/client/voice-recorder.d.ts +1 -1
- package/client/voice-recorder.js +2 -5
- package/client/wire-line.js +5 -5
- package/client/worklets/mic-capture.js +9 -9
- package/components/InkWaveform.d.ts +12 -1
- package/components/InkWaveform.js +65 -42
- package/components/live/use-live-runner-controls.d.ts +3 -4
- package/components/live/use-live-runner-controls.js +6 -10
- package/components/live/use-live-runner-model.d.ts +10 -6
- package/components/live/use-live-runner-model.js +29 -14
- package/components/live/use-live-runner-ui.d.ts +10 -8
- package/components/live/use-live-runner-ui.js +19 -11
- package/components/live/use-live-session-client.d.ts +4 -4
- package/components/live/use-live-session-client.js +11 -8
- package/components/use-composer-voice.d.ts +4 -4
- package/components/use-composer-voice.js +8 -8
- package/components/use-editor-selection.js +4 -1
- package/components/use-voice-playback.d.ts +2 -1
- package/components/use-voice-playback.js +4 -4
- package/hooks/use-described.d.ts +5 -1
- package/hooks/use-described.js +11 -9
- package/hooks/use-embedding-index.d.ts +27 -0
- package/hooks/use-embedding-index.js +43 -0
- package/hooks/use-one-call.d.ts +31 -0
- package/hooks/use-one-call.js +76 -0
- package/hooks/use-page-tool-warnings.d.ts +6 -0
- package/hooks/use-page-tool-warnings.js +25 -0
- package/hooks/use-second-ticker.d.ts +2 -0
- package/hooks/use-second-ticker.js +13 -0
- package/hooks/use-theorem-chat-actions.d.ts +25 -21
- package/hooks/use-theorem-chat-actions.js +67 -45
- package/hooks/use-theorem-chat-state.d.ts +6 -6
- package/hooks/use-theorem-chat-state.js +13 -9
- package/hooks/use-theorem-chat.d.ts +48 -14
- package/hooks/use-theorem-chat.js +329 -141
- package/hooks/use-theorem-decision.d.ts +5 -10
- package/hooks/use-theorem-decision.js +4 -67
- package/hooks/use-theorem-embedding.d.ts +18 -0
- package/hooks/use-theorem-embedding.js +12 -0
- package/hooks/use-theorem-host.d.ts +5 -4
- package/hooks/use-theorem-host.js +26 -8
- package/hooks/use-theorem-interface.d.ts +6 -3
- package/hooks/use-theorem-interface.js +12 -22
- package/index.d.ts +6 -3
- package/index.js +5 -2
- package/live.d.ts +1 -0
- package/live.js +1 -1
- package/package.json +6 -5
- package/server/checkpoint-ownership.d.ts +6 -0
- package/server/checkpoint-ownership.js +42 -0
- package/server/conversation-store.d.ts +92 -0
- package/server/conversation-store.js +131 -0
- package/server/conversation.d.ts +193 -0
- package/server/conversation.js +552 -0
- package/server/decision-handler.d.ts +12 -4
- package/server/decision-handler.js +29 -38
- package/server/embedding-handler.d.ts +33 -0
- package/server/embedding-handler.js +45 -0
- package/server/handler.d.ts +58 -20
- package/server/handler.js +441 -238
- package/server/mod.d.ts +15 -6
- package/server/mod.js +13 -5
- package/server/page-dispatch.d.ts +22 -0
- package/server/page-dispatch.js +127 -0
- package/server/request-body.d.ts +2 -0
- package/server/request-body.js +42 -0
- package/server/request-check.d.ts +6 -1
- package/server/request-check.js +27 -12
- package/server/session-authority.d.ts +8 -0
- package/server/session-authority.js +78 -0
- package/server/session-boundary.d.ts +26 -0
- package/server/session-boundary.js +64 -0
- package/server/session-identity.d.ts +16 -0
- package/server/session-identity.js +41 -0
- package/server/session-limits.d.ts +12 -0
- package/server/session-limits.js +59 -0
- package/server/session-store.d.ts +69 -20
- package/server/session-store.js +220 -5
- package/server/single-action.d.ts +21 -0
- package/server/single-action.js +30 -0
- package/server/steer-inbox.js +1 -1
- package/server/tool-operations.d.ts +6 -0
- package/server/tool-operations.js +132 -0
- package/server/turn-input.d.ts +10 -0
- package/server/turn-input.js +29 -0
- package/styles/ink-controls.css +78 -78
- package/ui/CardWall.d.ts +10 -0
- package/ui/CardWall.js +61 -0
- package/ui/ChatComposerBar.d.ts +28 -5
- package/ui/ChatComposerBar.js +85 -30
- package/ui/ChatTranscript.d.ts +14 -1
- package/ui/ChatTranscript.js +110 -57
- package/ui/ConsoleFrame.d.ts +61 -4
- package/ui/ConsoleFrame.js +109 -9
- package/ui/DecisionAnswers.d.ts +40 -2
- package/ui/DecisionAnswers.js +166 -35
- package/ui/DecisionImages.d.ts +16 -0
- package/ui/DecisionImages.js +46 -0
- package/ui/EmbeddingDocuments.d.ts +78 -0
- package/ui/EmbeddingDocuments.js +278 -0
- package/ui/EmbeddingQuery.d.ts +27 -0
- package/ui/EmbeddingQuery.js +95 -0
- package/ui/EmbeddingResults.d.ts +41 -0
- package/ui/EmbeddingResults.js +165 -0
- package/ui/EmbeddingSpace.d.ts +26 -0
- package/ui/EmbeddingSpace.js +106 -0
- package/ui/LiveCaptionsPanel.d.ts +22 -0
- package/ui/LiveCaptionsPanel.js +27 -0
- package/ui/LiveRunner.d.ts +6 -4
- package/ui/LiveRunner.js +42 -55
- package/ui/PaneState.d.ts +33 -0
- package/ui/PaneState.js +50 -0
- package/ui/SchemaFields.d.ts +1 -1
- package/ui/SchemaFields.js +54 -26
- package/ui/ShapedData.js +73 -28
- package/ui/SidePanel.d.ts +74 -5
- package/ui/SidePanel.js +82 -9
- package/ui/StateFields.d.ts +10 -2
- package/ui/StateFields.js +56 -13
- package/ui/TheoremChat.d.ts +65 -14
- package/ui/TheoremChat.js +66 -78
- package/ui/TheoremDecision.d.ts +12 -20
- package/ui/TheoremDecision.js +78 -35
- package/ui/TheoremEmbedding.d.ts +27 -0
- package/ui/TheoremEmbedding.js +122 -0
- package/ui/TheoremHost.d.ts +22 -5
- package/ui/TheoremHost.js +127 -37
- package/ui/ToolGateCard.d.ts +5 -1
- package/ui/ToolGateCard.js +30 -23
- package/ui/ToolResult.js +12 -10
- package/ui/ToolResultCharts.js +29 -12
- package/ui/TraceCharts.d.ts +2 -2
- package/ui/TraceCharts.js +48 -17
- package/ui/TraceGuardrails.d.ts +3 -2
- package/ui/TraceGuardrails.js +24 -6
- package/ui/TraceInspector.d.ts +11 -1
- package/ui/TraceInspector.js +45 -28
- package/ui/TraceInspectorPanel.d.ts +31 -9
- package/ui/TraceInspectorPanel.js +77 -39
- package/ui/TraceOverview.d.ts +7 -3
- package/ui/TraceOverview.js +44 -14
- package/ui/TraceSpanDetail.js +24 -22
- package/ui/TraceStory.js +9 -8
- package/ui/TraceValues.js +19 -9
- package/ui/TraceWaterfall.js +12 -9
- package/ui/VoiceNote.js +4 -4
- package/ui/approval-heading.d.ts +4 -0
- package/ui/approval-heading.js +9 -0
- package/ui/arrive.d.ts +18 -0
- package/ui/arrive.js +46 -0
- package/ui/built/theme.css +86 -68
- package/ui/built/theme.css.d.ts +9 -0
- package/ui/built/theorem.d.ts +3 -3
- package/ui/built/theorem.js +34 -5
- package/ui/built/theorem.variants.d.ts +8 -2
- package/ui/code-language.d.ts +12 -0
- package/ui/code-language.js +50 -0
- package/ui/disclosure-motion.js +53 -9
- package/ui/embedding-space-gl.d.ts +37 -0
- package/ui/embedding-space-gl.js +663 -0
- package/ui/embedding-space-view.d.ts +8 -0
- package/ui/embedding-space-view.js +8 -0
- package/ui/glide.d.ts +7 -0
- package/ui/glide.js +44 -0
- package/ui/icons.js +2 -1
- package/ui/index.d.ts +20 -9
- package/ui/index.js +20 -10
- package/ui/labels-provider.js +5 -2
- package/ui/labels.d.ts +374 -85
- package/ui/labels.js +1028 -188
- package/ui/markdown-plugins.d.ts +9 -0
- package/ui/markdown-plugins.js +13 -0
- package/ui/mcp-icon.d.ts +6 -0
- package/ui/mcp-icon.js +8 -0
- package/ui/row-keys.d.ts +19 -0
- package/ui/row-keys.js +33 -0
- package/ui/theme.d.ts +1 -1
- package/ui/theme.js +2 -2
- package/ui/theorem-theme.js +32 -10
- package/ui/trace-palette.d.ts +2 -16
- package/ui/trace-palette.js +2 -16
- package/ui/trace-patterns.d.ts +11 -3
- package/ui/trace-patterns.js +16 -3
- package/ui/transcript-copy-text.js +1 -0
- package/ui/wall-columns.d.ts +8 -0
- package/ui/wall-columns.js +19 -0
- package/client/walk-away.d.ts +0 -34
- package/client/walk-away.js +0 -48
- package/server/walk-away.d.ts +0 -22
- package/server/walk-away.js +0 -41
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MarkdownPluginEntry } from '@astryxdesign/core/Markdown/plugins';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
/** The Markdown plugins the host asked for, or none: one array, so every `Markdown` below shares it. */
|
|
4
|
+
export declare function useMarkdownPlugins(): readonly MarkdownPluginEntry[] | undefined;
|
|
5
|
+
/** Labels untagged code fences in the Markdown beneath it, when `detectCodeLanguage` is on. */
|
|
6
|
+
export declare function MarkdownPluginsProvider({ detectCodeLanguage, children, }: {
|
|
7
|
+
detectCodeLanguage?: boolean;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, use } from 'react';
|
|
3
|
+
import { codeLanguagePlugin } from "./code-language.js";
|
|
4
|
+
const PLUGINS = [codeLanguagePlugin];
|
|
5
|
+
const MarkdownPluginsContext = createContext(undefined);
|
|
6
|
+
/** The Markdown plugins the host asked for, or none: one array, so every `Markdown` below shares it. */
|
|
7
|
+
export function useMarkdownPlugins() {
|
|
8
|
+
return use(MarkdownPluginsContext);
|
|
9
|
+
}
|
|
10
|
+
/** Labels untagged code fences in the Markdown beneath it, when `detectCodeLanguage` is on. */
|
|
11
|
+
export function MarkdownPluginsProvider({ detectCodeLanguage, children, }) {
|
|
12
|
+
return (_jsx(MarkdownPluginsContext, { value: detectCodeLanguage ? PLUGINS : undefined, children: children }));
|
|
13
|
+
}
|
package/ui/mcp-icon.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Model Context Protocol mark (from Simple Icons, CC0), filled in the current colour.
|
|
4
|
+
* Tabler has no MCP icon; this marks MCP tools beside Tabler's glyphs for the other kinds.
|
|
5
|
+
*/
|
|
6
|
+
export declare function IconMcp(props: SVGProps<SVGSVGElement>): import("react").JSX.Element;
|
package/ui/mcp-icon.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Model Context Protocol mark (from Simple Icons, CC0), filled in the current colour.
|
|
4
|
+
* Tabler has no MCP icon; this marks MCP tools beside Tabler's glyphs for the other kinds.
|
|
5
|
+
*/
|
|
6
|
+
export function IconMcp(props) {
|
|
7
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, ...props, children: _jsx("path", { d: "M13.85 0a4.16 4.16 0 0 0-2.95 1.217L1.456 10.66a.835.835 0 0 0 0 1.18.835.835 0 0 0 1.18 0l9.442-9.442a2.49 2.49 0 0 1 3.541 0 2.49 2.49 0 0 1 0 3.541L8.59 12.97l-.1.1a.835.835 0 0 0 0 1.18.835.835 0 0 0 1.18 0l.1-.098 7.03-7.034a2.49 2.49 0 0 1 3.542 0l.049.05a2.49 2.49 0 0 1 0 3.54l-8.54 8.54a1.96 1.96 0 0 0 0 2.755l1.753 1.753a.835.835 0 0 0 1.18 0 .835.835 0 0 0 0-1.18l-1.753-1.753a.266.266 0 0 1 0-.394l8.54-8.54a4.185 4.185 0 0 0 0-5.9l-.05-.05a4.16 4.16 0 0 0-2.95-1.218c-.2 0-.401.02-.6.048a4.17 4.17 0 0 0-1.17-3.552A4.16 4.16 0 0 0 13.85 0m0 3.333a.84.84 0 0 0-.59.245L6.275 10.56a4.186 4.186 0 0 0 0 5.902 4.186 4.186 0 0 0 5.902 0L19.16 9.48a.835.835 0 0 0 0-1.18.835.835 0 0 0-1.18 0l-6.985 6.984a2.49 2.49 0 0 1-3.54 0 2.49 2.49 0 0 1 0-3.54l6.983-6.985a.835.835 0 0 0 0-1.18.84.84 0 0 0-.59-.245" }) }));
|
|
8
|
+
}
|
package/ui/row-keys.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** One item of a list with the React key it renders under. */
|
|
2
|
+
export type KeyedRow<T> = {
|
|
3
|
+
item: T;
|
|
4
|
+
index: number;
|
|
5
|
+
key: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Keys a read-only list by what each item says, so a repeated item is told apart by how many
|
|
9
|
+
* times it has appeared before. `base` must return the same text for the same item.
|
|
10
|
+
*/
|
|
11
|
+
export declare function keyedByContent<T>(items: readonly T[], base: (item: T) => string): KeyedRow<T>[];
|
|
12
|
+
/**
|
|
13
|
+
* Keys an editable list by identity: a row keeps its key while its text changes, and `drop`
|
|
14
|
+
* retires the key of a removed row so the rows after it keep theirs.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useKeyedRows<T>(items: readonly T[]): {
|
|
17
|
+
rows: KeyedRow<T>[];
|
|
18
|
+
drop: (index: number) => void;
|
|
19
|
+
};
|
package/ui/row-keys.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Keys a read-only list by what each item says, so a repeated item is told apart by how many
|
|
4
|
+
* times it has appeared before. `base` must return the same text for the same item.
|
|
5
|
+
*/
|
|
6
|
+
export function keyedByContent(items, base) {
|
|
7
|
+
const seen = new Map();
|
|
8
|
+
return items.map((item, index) => {
|
|
9
|
+
const text = base(item);
|
|
10
|
+
const count = seen.get(text) ?? 0;
|
|
11
|
+
seen.set(text, count + 1);
|
|
12
|
+
return { item, index, key: `${text}#${String(count)}` };
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Keys an editable list by identity: a row keeps its key while its text changes, and `drop`
|
|
17
|
+
* retires the key of a removed row so the rows after it keep theirs.
|
|
18
|
+
*/
|
|
19
|
+
export function useKeyedRows(items) {
|
|
20
|
+
const keys = useRef([]);
|
|
21
|
+
const minted = useRef(0);
|
|
22
|
+
while (keys.current.length < items.length) {
|
|
23
|
+
keys.current.push(String(minted.current));
|
|
24
|
+
minted.current += 1;
|
|
25
|
+
}
|
|
26
|
+
keys.current.length = items.length;
|
|
27
|
+
return {
|
|
28
|
+
rows: items.map((item, index) => ({ item, index, key: keys.current[index] ?? '' })),
|
|
29
|
+
drop: (index) => {
|
|
30
|
+
keys.current.splice(index, 1);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
package/ui/theme.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export type TheoremThemeProviderProps = {
|
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
};
|
|
9
9
|
/** Wraps children in the Theorem theme unless the host already provides an Astryx theme. */
|
|
10
|
-
export declare function TheoremThemeProvider({ theme, mode, children }: TheoremThemeProviderProps): import("react").JSX.Element;
|
|
10
|
+
export declare function TheoremThemeProvider({ theme, mode, children, }: TheoremThemeProviderProps): import("react").JSX.Element;
|
package/ui/theme.js
CHANGED
|
@@ -3,8 +3,8 @@ import { Theme, ThemeContext } from '@astryxdesign/core/theme';
|
|
|
3
3
|
import { use } from 'react';
|
|
4
4
|
import { theoremTheme } from './built/theorem.js';
|
|
5
5
|
/** Wraps children in the Theorem theme unless the host already provides an Astryx theme. */
|
|
6
|
-
export function TheoremThemeProvider({ theme, mode = 'system', children }) {
|
|
7
|
-
// Ask the React tree, not `useThemeName()`: outside a Theme that falls back to
|
|
6
|
+
export function TheoremThemeProvider({ theme, mode = 'system', children, }) {
|
|
7
|
+
// why: Ask the React tree, not `useThemeName()`: outside a Theme that falls back to
|
|
8
8
|
// the <html> attribute our own Theme sets, which would unmount it in a loop.
|
|
9
9
|
const hostTheme = use(ThemeContext);
|
|
10
10
|
if (hostTheme != null && !theme)
|
package/ui/theorem-theme.js
CHANGED
|
@@ -14,7 +14,7 @@ export const theoremTheme = defineTheme({
|
|
|
14
14
|
extends: neutralTheme,
|
|
15
15
|
icons: tablerIcons,
|
|
16
16
|
components: {
|
|
17
|
-
// Media keeps a margin from the viewport edges, over a lighter scrim than
|
|
17
|
+
// why: Media keeps a margin from the viewport edges, over a lighter scrim than
|
|
18
18
|
// Astryx's shared --color-overlay (dialogs keep theirs).
|
|
19
19
|
lightbox: {
|
|
20
20
|
base: {
|
|
@@ -22,7 +22,7 @@ export const theoremTheme = defineTheme({
|
|
|
22
22
|
'::backdrop': { backgroundColor: 'light-dark(#00000059, #00000099)' },
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
-
// Collapsible shows and hides without motion; ease its height with the
|
|
25
|
+
// why: Collapsible shows and hides without motion; ease its height with the
|
|
26
26
|
// same --duration-medium / --ease-standard as ChatToolCalls and the
|
|
27
27
|
// composer drawer. Closed = the trigger before it reads aria-expanded="false".
|
|
28
28
|
'collapsible-content': {
|
|
@@ -31,19 +31,27 @@ export const theoremTheme = defineTheme({
|
|
|
31
31
|
overflow: 'clip',
|
|
32
32
|
interpolateSize: 'allow-keywords',
|
|
33
33
|
transition: 'height var(--duration-medium) var(--ease-standard), padding-top var(--duration-medium) var(--ease-standard), content-visibility var(--duration-medium) allow-discrete',
|
|
34
|
-
':where([aria-expanded="false"] + *)': {
|
|
34
|
+
':where([aria-expanded="false"] + *)': {
|
|
35
|
+
height: '0',
|
|
36
|
+
paddingTop: '0',
|
|
37
|
+
contentVisibility: 'hidden',
|
|
38
|
+
},
|
|
35
39
|
},
|
|
36
40
|
},
|
|
37
|
-
// A source's favicon sits bare beside its title, without the ring
|
|
41
|
+
// why: A source's favicon sits bare beside its title, without the ring
|
|
38
42
|
// Astryx draws around a citation icon. Nested keys must open with a
|
|
39
43
|
// pseudo-class, so `:where(*)` (the citation itself) leads the child rules.
|
|
40
44
|
citation: {
|
|
41
45
|
base: {
|
|
42
|
-
':where(*) > [aria-hidden="true"]': {
|
|
46
|
+
':where(*) > [aria-hidden="true"]': {
|
|
47
|
+
backgroundColor: 'transparent',
|
|
48
|
+
borderWidth: '0',
|
|
49
|
+
borderRadius: '0',
|
|
50
|
+
},
|
|
43
51
|
':where(*) > [aria-hidden="true"] > img': { width: '100%', height: '100%' },
|
|
44
52
|
},
|
|
45
53
|
},
|
|
46
|
-
// A call row's name is code type and its target or error note is body type;
|
|
54
|
+
// why: A call row's name is code type and its target or error note is body type;
|
|
47
55
|
// centered, their different metrics sit their text on different lines.
|
|
48
56
|
// Share a baseline instead (the status icon and chevron stay centered).
|
|
49
57
|
'chat-tool-calls': {
|
|
@@ -53,15 +61,29 @@ export const theoremTheme = defineTheme({
|
|
|
53
61
|
},
|
|
54
62
|
},
|
|
55
63
|
},
|
|
56
|
-
//
|
|
57
|
-
//
|
|
64
|
+
// why: A card that waits on the user sits in the transcript as a turn of its
|
|
65
|
+
// own, so it takes the surface of the user's message bubble.
|
|
66
|
+
card: {
|
|
67
|
+
'variant:bubble': {
|
|
68
|
+
backgroundColor: 'var(--color-neutral)',
|
|
69
|
+
borderRadius: 'var(--radius-chat)',
|
|
70
|
+
paddingBlock: 'var(--spacing-3)',
|
|
71
|
+
paddingInline: 'var(--spacing-4)',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
// why: A code block sits among cards and panels, so it takes a card's corner
|
|
75
|
+
// (--radius-container) rather than the smaller element radius Astryx gives it.
|
|
76
|
+
'code-block': {
|
|
77
|
+
'container:card': { borderRadius: 'var(--radius-container)' },
|
|
78
|
+
},
|
|
58
79
|
'layout-panel': {
|
|
59
80
|
base: {
|
|
60
81
|
':where([role="complementary"])': {
|
|
61
82
|
transition: 'width var(--duration-medium) var(--ease-standard)',
|
|
62
83
|
},
|
|
63
|
-
// While its ResizeHandle
|
|
64
|
-
|
|
84
|
+
// why: While its ResizeHandle drags, follow the pointer. An end panel's
|
|
85
|
+
// handle is the sibling before it; a start panel's handle is the sibling after it.
|
|
86
|
+
':where([data-resizing] + [role="complementary"], [role="complementary"]:has(+ [data-resizing]))': {
|
|
65
87
|
transition: 'none',
|
|
66
88
|
},
|
|
67
89
|
},
|
package/ui/trace-palette.d.ts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The trace panel's
|
|
3
|
-
*
|
|
4
|
-
* stone, and moss and oxblood kept for how a step ended. Each is a
|
|
5
|
-
* light-dark pair, deep in light mode and softened, not brightened, in dark.
|
|
2
|
+
* The trace panel's colour for a failed step: oxblood, a light-dark pair that is deep in light
|
|
3
|
+
* mode and softened, not brightened, in dark.
|
|
6
4
|
*
|
|
7
5
|
* @module
|
|
8
6
|
*/
|
|
9
7
|
export declare const TRACE_HUE: {
|
|
10
|
-
/** Royal navy: the model. */
|
|
11
|
-
readonly navy: "light-dark(#152350, #2b4596)";
|
|
12
|
-
/** Antique brass: tools. */
|
|
13
|
-
readonly brass: "light-dark(#6f5520, #b39150)";
|
|
14
|
-
/** Deep fjord teal: the host. */
|
|
15
|
-
readonly fjord: "light-dark(#24595c, #5f9a9c)";
|
|
16
|
-
/** Moss green: what succeeded. */
|
|
17
|
-
readonly moss: "light-dark(#3d5f2c, #7c9f5a)";
|
|
18
|
-
/** Heather: Theorem itself (guardrails, gates, the turn). */
|
|
19
|
-
readonly heather: "light-dark(#54447e, #9585bf)";
|
|
20
|
-
/** Warm stone: the person, and time nothing else accounts for. */
|
|
21
|
-
readonly stone: "light-dark(#6d6861, #a39d93)";
|
|
22
8
|
/** Oxblood: whatever failed. */
|
|
23
9
|
readonly oxblood: "light-dark(#8e2a28, #cd5f55)";
|
|
24
10
|
};
|
package/ui/trace-palette.js
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The trace panel's
|
|
3
|
-
*
|
|
4
|
-
* stone, and moss and oxblood kept for how a step ended. Each is a
|
|
5
|
-
* light-dark pair, deep in light mode and softened, not brightened, in dark.
|
|
2
|
+
* The trace panel's colour for a failed step: oxblood, a light-dark pair that is deep in light
|
|
3
|
+
* mode and softened, not brightened, in dark.
|
|
6
4
|
*
|
|
7
5
|
* @module
|
|
8
6
|
*/
|
|
9
7
|
export const TRACE_HUE = {
|
|
10
|
-
/** Royal navy: the model. */
|
|
11
|
-
navy: 'light-dark(#152350, #2b4596)',
|
|
12
|
-
/** Antique brass: tools. */
|
|
13
|
-
brass: 'light-dark(#6f5520, #b39150)',
|
|
14
|
-
/** Deep fjord teal: the host. */
|
|
15
|
-
fjord: 'light-dark(#24595c, #5f9a9c)',
|
|
16
|
-
/** Moss green: what succeeded. */
|
|
17
|
-
moss: 'light-dark(#3d5f2c, #7c9f5a)',
|
|
18
|
-
/** Heather: Theorem itself (guardrails, gates, the turn). */
|
|
19
|
-
heather: 'light-dark(#54447e, #9585bf)',
|
|
20
|
-
/** Warm stone: the person, and time nothing else accounts for. */
|
|
21
|
-
stone: 'light-dark(#6d6861, #a39d93)',
|
|
22
8
|
/** Oxblood: whatever failed. */
|
|
23
9
|
oxblood: 'light-dark(#8e2a28, #cd5f55)',
|
|
24
10
|
};
|
package/ui/trace-patterns.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ComponentProps, CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import type { TraceActor } from '../client/trace-story.ts';
|
|
3
3
|
/**
|
|
4
4
|
* The trace charts' fills, one per series in order: the first is clear (a
|
|
@@ -23,10 +23,18 @@ export declare function TracePatterns(): import("react").JSX.Element;
|
|
|
23
23
|
export declare function TraceSwatch({ fill }: {
|
|
24
24
|
fill: TraceFill;
|
|
25
25
|
}): import("react").JSX.Element;
|
|
26
|
-
/**
|
|
27
|
-
export declare
|
|
26
|
+
/** Every console card, request, response and result alike: one ground and one radius. A flush page points the ground at the muted one. */
|
|
27
|
+
export declare const CONSOLE_CARD: CSSProperties;
|
|
28
|
+
/** A chart's content: its name, one figure that answers it, then the chart and its key. */
|
|
29
|
+
export declare function ChartBody({ title, value, note, aside, detail, children, }: {
|
|
28
30
|
title: string;
|
|
29
31
|
value: ReactNode;
|
|
30
32
|
note?: ReactNode;
|
|
33
|
+
/** A line under the title that says more, cut to two lines with the rest on hover. */
|
|
34
|
+
detail?: string;
|
|
35
|
+
/** A control beside the title, such as a switch between views. */
|
|
36
|
+
aside?: ReactNode;
|
|
31
37
|
children?: ReactNode;
|
|
32
38
|
}): import("react").JSX.Element;
|
|
39
|
+
/** A chart as a card. */
|
|
40
|
+
export declare function ChartCard(props: ComponentProps<typeof ChartBody>): import("react").JSX.Element;
|
package/ui/trace-patterns.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Card } from '@astryxdesign/core/Card';
|
|
3
|
+
import { HStack } from '@astryxdesign/core/HStack';
|
|
4
|
+
import { StackItem } from '@astryxdesign/core/Stack';
|
|
3
5
|
import { Text } from '@astryxdesign/core/Text';
|
|
4
6
|
import { VStack } from '@astryxdesign/core/VStack';
|
|
5
7
|
const SOLID = {
|
|
@@ -38,7 +40,18 @@ export function TracePatterns() {
|
|
|
38
40
|
export function TraceSwatch({ fill }) {
|
|
39
41
|
return (_jsx("svg", { "aria-hidden": true, width: 10, height: 10, style: { display: 'block', flexShrink: 0 }, children: _jsx("rect", { width: 10, height: 10, rx: 2, fill: traceFill(fill) }) }));
|
|
40
42
|
}
|
|
41
|
-
/**
|
|
42
|
-
export
|
|
43
|
-
|
|
43
|
+
/** Every console card, request, response and result alike: one ground and one radius. A flush page points the ground at the muted one. */
|
|
44
|
+
export const CONSOLE_CARD = {
|
|
45
|
+
background: 'var(--theorem-console-card, var(--color-background-surface))',
|
|
46
|
+
borderRadius: 'var(--radius-page)',
|
|
47
|
+
};
|
|
48
|
+
/** A chart's content: its name, one figure that answers it, then the chart and its key. */
|
|
49
|
+
export function ChartBody({ title, value, note, aside, detail, children, }) {
|
|
50
|
+
const titled = (_jsx(Text, { type: "supporting", color: "secondary", children: title }));
|
|
51
|
+
const heading = detail ? (_jsxs(VStack, { gap: 1, children: [titled, _jsx(Text, { type: "supporting", maxLines: 2, children: detail })] })) : (titled);
|
|
52
|
+
return (_jsxs(VStack, { gap: 3, children: [aside ? (_jsxs(HStack, { gap: 3, vAlign: "center", children: [_jsx(StackItem, { size: "fill", children: heading }), aside] })) : (heading), _jsxs("div", { style: { display: 'flex', alignItems: 'baseline', flexWrap: 'wrap', columnGap: 8 }, children: [_jsx(Text, { size: "2xl", weight: "medium", hasTabularNumbers: true, children: value }), note ? (_jsx(Text, { type: "supporting", hasTabularNumbers: true, children: _jsx("span", { style: { color: TRACE_ACCENT }, children: note }) })) : null] }), children] }));
|
|
53
|
+
}
|
|
54
|
+
/** A chart as a card. */
|
|
55
|
+
export function ChartCard(props) {
|
|
56
|
+
return (_jsx(Card, { variant: "muted", padding: 4, style: CONSOLE_CARD, children: _jsx(ChartBody, { ...props }) }));
|
|
44
57
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** How many columns at least `minWidth` wide fit across `width`, `gap` apart. Never fewer than one. */
|
|
2
|
+
export declare function columnCount(width: number, minWidth: number, gap: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* Each card, in order, into the column that is shortest so far, by the
|
|
5
|
+
* cards' heights and the gap under each. A card not measured yet counts as
|
|
6
|
+
* no height, so unmeasured cards are dealt out in turn.
|
|
7
|
+
*/
|
|
8
|
+
export declare function wallColumns(heights: readonly (number | undefined)[], count: number, gap: number): number[][];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** How many columns at least `minWidth` wide fit across `width`, `gap` apart. Never fewer than one. */
|
|
2
|
+
export function columnCount(width, minWidth, gap) {
|
|
3
|
+
return Math.max(1, Math.floor((width + gap) / (minWidth + gap)));
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Each card, in order, into the column that is shortest so far, by the
|
|
7
|
+
* cards' heights and the gap under each. A card not measured yet counts as
|
|
8
|
+
* no height, so unmeasured cards are dealt out in turn.
|
|
9
|
+
*/
|
|
10
|
+
export function wallColumns(heights, count, gap) {
|
|
11
|
+
const columns = Array.from({ length: count }, () => []);
|
|
12
|
+
const tall = Array.from({ length: count }, () => 0);
|
|
13
|
+
heights.forEach((height, card) => {
|
|
14
|
+
const at = tall.indexOf(Math.min(...tall));
|
|
15
|
+
columns[at]?.push(card);
|
|
16
|
+
tall[at] = (tall[at] ?? 0) + (height ?? 0) + gap;
|
|
17
|
+
});
|
|
18
|
+
return columns;
|
|
19
|
+
}
|
package/client/walk-away.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A message sent while its reply waits on gates walks away from them in the
|
|
3
|
-
* same request: `abandon` names the waiting calls, and the history carries the
|
|
4
|
-
* paused reply with those calls open. The host settles each one cancelled and
|
|
5
|
-
* streams those events ahead of the message's reply; once the last one
|
|
6
|
-
* settles, the paused reply commits whole, and the message's reply begins.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import { type TurnHistoryMessage } from '@theoremjs/agents';
|
|
11
|
-
import { type ComposerProfileInterface, type InterfaceTurnSession, type TranscriptBlock } from '@theoremjs/agents/interface';
|
|
12
|
-
import type { TurnEventSink } from './transport.ts';
|
|
13
|
-
import { type WalkAway } from './turn-client.ts';
|
|
14
|
-
/** The paused reply, committed with its settled calls, and its blocks as the transcript keeps them. */
|
|
15
|
-
export type WalkedAway = {
|
|
16
|
-
session: InterfaceTurnSession;
|
|
17
|
-
blocks: TranscriptBlock[];
|
|
18
|
-
};
|
|
19
|
-
export type WalkingAway = {
|
|
20
|
-
/** For `buildTurnRequest`: the paused session and the calls it waits on. */
|
|
21
|
-
request: WalkAway;
|
|
22
|
-
/** The paused reply as the model reads it, its waiting calls open. */
|
|
23
|
-
history: TurnHistoryMessage[];
|
|
24
|
-
/**
|
|
25
|
-
* The sink for the request's stream: each waiting call's events settle the
|
|
26
|
-
* paused reply, and `onSettled` fires once the last one has; every event
|
|
27
|
-
* after that is the message's reply, and goes on to `onEvent`.
|
|
28
|
-
*/
|
|
29
|
-
sink(onEvent: TurnEventSink, onSettled: (walked: WalkedAway) => void): TurnEventSink;
|
|
30
|
-
/** Whether every waiting call has settled. */
|
|
31
|
-
settled(): boolean;
|
|
32
|
-
};
|
|
33
|
-
/** Walk away from every call `paused` waits on; `workedMs` is the paused reply's work so far. */
|
|
34
|
-
export declare function walkAwayFrom(iface: ComposerProfileInterface, paused: InterfaceTurnSession, workedMs: number): WalkingAway;
|
package/client/walk-away.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A message sent while its reply waits on gates walks away from them in the
|
|
3
|
-
* same request: `abandon` names the waiting calls, and the history carries the
|
|
4
|
-
* paused reply with those calls open. The host settles each one cancelled and
|
|
5
|
-
* streams those events ahead of the message's reply; once the last one
|
|
6
|
-
* settles, the paused reply commits whole, and the message's reply begins.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import { TheoremError } from '@theoremjs/agents';
|
|
11
|
-
import { appendPausedTurnToHistory, gatedToolsFromEvents, settlesToolCall, } from '@theoremjs/agents/interface';
|
|
12
|
-
import { commitCompletedTurn, stampWorked } from "./run-commit.js";
|
|
13
|
-
import { foldAssistantTurn } from "./turn-client.js";
|
|
14
|
-
/** Walk away from every call `paused` waits on; `workedMs` is the paused reply's work so far. */
|
|
15
|
-
export function walkAwayFrom(iface, paused, workedMs) {
|
|
16
|
-
const calls = gatedToolsFromEvents(paused.assistantEvents);
|
|
17
|
-
const waiting = new Set(calls.map((call) => call.callId));
|
|
18
|
-
const events = [...paused.assistantEvents];
|
|
19
|
-
const settle = (event) => {
|
|
20
|
-
events.push(event);
|
|
21
|
-
if (event.type === 'tool' && settlesToolCall(event, event.tool.callId))
|
|
22
|
-
waiting.delete(event.tool.callId);
|
|
23
|
-
if (waiting.size)
|
|
24
|
-
return undefined;
|
|
25
|
-
return {
|
|
26
|
-
session: commitCompletedTurn(paused, events),
|
|
27
|
-
blocks: stampWorked(foldAssistantTurn(iface, events), { workedMs, endedAt: Date.now() }),
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
return {
|
|
31
|
-
request: { paused, calls },
|
|
32
|
-
history: appendPausedTurnToHistory(paused.history, paused.assistantEvents),
|
|
33
|
-
sink: (onEvent, onSettled) => (event) => {
|
|
34
|
-
if (!waiting.size || event.type === 'unsupported' || event.type === 'malformed') {
|
|
35
|
-
onEvent(event);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (event.type !== 'tool' || !waiting.has(event.tool.callId)) {
|
|
39
|
-
// lexicon-exempt: internal diagnostic; the user reads the error kind's wording
|
|
40
|
-
throw new TheoremError('bad_response', 'the reply began before the calls it walked away from settled');
|
|
41
|
-
}
|
|
42
|
-
const walked = settle(event);
|
|
43
|
-
if (walked)
|
|
44
|
-
onSettled(walked);
|
|
45
|
-
},
|
|
46
|
-
settled: () => waiting.size === 0,
|
|
47
|
-
};
|
|
48
|
-
}
|
package/server/walk-away.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A message that walks away from the calls its reply paused on, the same on
|
|
3
|
-
* every host (`createTheoremHandler`, the playground). The message's history
|
|
4
|
-
* leaves exactly those calls open; each settles cancelled, its events stream
|
|
5
|
-
* ahead of the reply, and the model reads each answer before the message.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import { type TurnEvent, type TurnInput } from '@theoremjs/agents';
|
|
10
|
-
/** Refuses a walk-away its history does not match, before any gate is answered. */
|
|
11
|
-
export declare function checkWalkAway(input: TurnInput, abandon: readonly string[]): void;
|
|
12
|
-
/** One walked-away call: its id, and the run that settles it (`invokeTool` with the abandoned resume). */
|
|
13
|
-
export type WalkedAwayCall = {
|
|
14
|
-
callId: string;
|
|
15
|
-
events: AsyncIterable<TurnEvent>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Streams each call's tool events as it settles; each run's `done` stays with
|
|
19
|
-
* that run. Returns `input` with every call answered in its history, or
|
|
20
|
-
* undefined when a run failed: its `error` event went out and ends the reply.
|
|
21
|
-
*/
|
|
22
|
-
export declare function walkAway(input: TurnInput, calls: readonly WalkedAwayCall[]): AsyncGenerator<TurnEvent, TurnInput | undefined>;
|
package/server/walk-away.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A message that walks away from the calls its reply paused on, the same on
|
|
3
|
-
* every host (`createTheoremHandler`, the playground). The message's history
|
|
4
|
-
* leaves exactly those calls open; each settles cancelled, its events stream
|
|
5
|
-
* ahead of the reply, and the model reads each answer before the message.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import { TheoremError } from '@theoremjs/agents';
|
|
10
|
-
import { answerOpenToolCalls, assertOpenToolCalls, settlesToolCall, } from '@theoremjs/agents/interface';
|
|
11
|
-
/** Refuses a walk-away its history does not match, before any gate is answered. */
|
|
12
|
-
export function checkWalkAway(input, abandon) {
|
|
13
|
-
assertOpenToolCalls(input.history ?? [], abandon);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Streams each call's tool events as it settles; each run's `done` stays with
|
|
17
|
-
* that run. Returns `input` with every call answered in its history, or
|
|
18
|
-
* undefined when a run failed: its `error` event went out and ends the reply.
|
|
19
|
-
*/
|
|
20
|
-
export async function* walkAway(input, calls) {
|
|
21
|
-
const answers = new Map();
|
|
22
|
-
for (const call of calls) {
|
|
23
|
-
for await (const event of call.events) {
|
|
24
|
-
if (event.type === 'error') {
|
|
25
|
-
yield event;
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
if (event.type !== 'tool')
|
|
29
|
-
continue;
|
|
30
|
-
yield event;
|
|
31
|
-
const readBack = settlesToolCall(event, call.callId) ? event.tool.readBack : undefined;
|
|
32
|
-
if (readBack !== undefined)
|
|
33
|
-
answers.set(call.callId, readBack);
|
|
34
|
-
}
|
|
35
|
-
if (!answers.has(call.callId)) {
|
|
36
|
-
// lexicon-exempt: internal diagnostic; the user reads error.internal
|
|
37
|
-
throw new TheoremError('internal', `walked-away call ${call.callId} ended without settling`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return { ...input, history: answerOpenToolCalls(input.history ?? [], answers) };
|
|
41
|
-
}
|