@theoremjs/studio 0.3.4-next.610.g6ddf39d → 0.3.4-next.614.g49b2422
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/compile-workspace.d.ts +2 -2
- package/mod.d.ts +1 -1
- package/package.json +4 -4
- package/page/assets/{Banner-O0C5KVNy.js → Banner--i2okj5K.js} +3 -3
- package/page/assets/{CollapsibleGroup-FIawJRo4.js → CollapsibleGroup-DB8CMN03.js} +1 -1
- package/page/assets/ConsoleFrame-D10HQnGR.js +3 -0
- package/page/assets/{MenuBottomSheet-BgEFW0aD.js → MenuBottomSheet-B8mBsaxR.js} +1 -1
- package/page/assets/{SchemaFields-BEJRfqpK.js → SchemaFields-DNUWF7Oo.js} +1 -1
- package/page/assets/{ToolResultCharts-D2lBPHEZ.js → ToolResultCharts-Z3YJrgKo.js} +1 -1
- package/page/assets/TraceInspector-Csx3ds6r.js +1 -0
- package/page/assets/TraceOverview-CC-snPqN.js +57 -0
- package/page/assets/{browser-engine-BjJHK9Fj.js → browser-engine-56ii_gXy.js} +1 -1
- package/page/assets/{browser-transport-Dg00IzNm.js → browser-transport-BJg0pAIp.js} +3 -3
- package/page/assets/{export-agent-Deaz-SP9.js → export-agent-CgtBB6BI.js} +1 -1
- package/page/assets/{guardrail-tester-KplaELLL.js → guardrail-tester-CjsM3Y-7.js} +2 -2
- package/page/assets/index-BKYqdh3m.js +145 -0
- package/page/assets/{studio-code-pane-CPkCgdNL.js → studio-code-pane-DfgbrAXv.js} +1 -1
- package/page/assets/studio-console-DgQWpdqq.js +1 -0
- package/page/assets/{studio-decision-58N5707m.js → studio-decision-DPyk5XBk.js} +1 -1
- package/page/assets/{studio-embedding-Bb--Fl0W.js → studio-embedding-CYUNwEtA.js} +1 -1
- package/page/assets/studio-host-console-BYfgqnW7.js +2 -0
- package/page/assets/{studio-labels-1m3jxSy0.js → studio-labels-DjrE2q9k.js} +1 -1
- package/page/assets/{studio-live-DO17Sba3.js → studio-live-BTa4dkZc.js} +1 -1
- package/page/assets/{studio-map-CW6zs4Gl.js → studio-map-Cq3sd0E0.js} +1 -1
- package/page/assets/{studio-trace-replay-3HVWcPKT.js → studio-trace-replay-Af-9PuWP.js} +1 -1
- package/page/assets/use-one-call-Bt7GI8rV.js +1 -0
- package/page/assets/use-trace-records-CsqcWg1x.js +2 -0
- package/page/assets/workspace-C8TpjjeK.js +1 -0
- package/page/index.html +7 -7
- package/ui/lib/studio-store.js +25 -5
- package/ui/studio-runner.js +21 -17
- package/ui/studio-screen.js +85 -37
- package/workspace.d.ts +3 -1
- package/workspace.js +18 -1
- package/page/assets/CardWall-D63k-4of.js +0 -1
- package/page/assets/ConsoleFrame-DZBnKWKu.js +0 -3
- package/page/assets/TraceInspector-BSaIDwyH.js +0 -1
- package/page/assets/TraceOverview-DjHshucg.js +0 -57
- package/page/assets/index-Cl8kUfgj.js +0 -146
- package/page/assets/studio-console-BZyPvkUO.js +0 -1
- package/page/assets/studio-host-console-BXsksNiY.js +0 -2
- package/page/assets/use-one-call-Cj7h9tR9.js +0 -1
- package/page/assets/use-trace-records-B1vrKQmA.js +0 -1
- package/page/assets/workspace-CzTPlUdi.js +0 -1
package/ui/studio-runner.js
CHANGED
|
@@ -89,31 +89,31 @@ function UnsavedActions({ agentId, isNew }) {
|
|
|
89
89
|
const NOT_A_CHAT = new Set(['decision', 'host', 'live']);
|
|
90
90
|
const isChat = (payload) => !NOT_A_CHAT.has(payload.profile.type);
|
|
91
91
|
/**
|
|
92
|
-
* The
|
|
93
|
-
*
|
|
92
|
+
* The agents the files hold, compiled from where the workspace started: an edit may have renamed
|
|
93
|
+
* one or made it another type. Undefined when the files hold none of them.
|
|
94
94
|
*/
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
const key = edits.agents.find((agent) => agent.identity.agentId.trim() === payload.agentId)?.key;
|
|
98
|
-
const start = key === undefined ? undefined : edits.starts.agents[key];
|
|
99
|
-
if (!start || !inFiles(start))
|
|
100
|
-
return undefined;
|
|
101
|
-
const agents = Object.values(edits.starts.agents).filter(inFiles);
|
|
95
|
+
function compileFiles(starts, providers, profiles) {
|
|
96
|
+
const agents = Object.values(starts.agents).filter((agent) => profiles.includes(agent.identity.agentId.trim()));
|
|
102
97
|
const here = new Set(agents.map((agent) => agent.key));
|
|
103
98
|
// A tool that ran an agent the edits removed has no agent here to run.
|
|
104
|
-
const toolSpecs = Object.values(
|
|
99
|
+
const toolSpecs = Object.values(starts.tools).filter((tool) => tool.toolType !== 'agent' || here.has(tool.agentKey ?? ''));
|
|
105
100
|
const held = new Set(toolSpecs.map((tool) => tool.key));
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
// The files run in the project, on its own setup.
|
|
102
|
+
const compiled = compileWorkspace({
|
|
108
103
|
agents: agents.map((agent) => ({
|
|
109
104
|
...agent,
|
|
110
105
|
tools: { ...agent.tools, allow: agent.tools.allow.filter((toolKey) => held.has(toolKey)) },
|
|
111
106
|
})),
|
|
112
107
|
toolSpecs,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
providers,
|
|
109
|
+
}, ON_OWN_KEYS);
|
|
110
|
+
return compiled.ok ? compiled : undefined;
|
|
111
|
+
}
|
|
112
|
+
/** The agent as the files hold it, from their compile. Undefined for an agent the files do not hold. */
|
|
113
|
+
function savedPayload(edits, files, payload) {
|
|
114
|
+
const key = edits.agents.find((agent) => agent.identity.agentId.trim() === payload.agentId)?.key;
|
|
115
|
+
const start = key === undefined ? undefined : edits.starts.agents[key];
|
|
116
|
+
const run = start && workspaceRunAgent(files, start.identity.agentId.trim());
|
|
117
117
|
if (!run)
|
|
118
118
|
return undefined;
|
|
119
119
|
const { agentId, profile, customTools, structured, questions, dependencies } = run;
|
|
@@ -171,7 +171,11 @@ function ProjectSides({ project, payload, saved, edits, traces, chatRef, ...shar
|
|
|
171
171
|
function ProjectRun({ project, tested, ...run }) {
|
|
172
172
|
const { payload } = run;
|
|
173
173
|
const edits = useMemo(() => unsavedEdits(tested, project.profiles), [tested, project.profiles]);
|
|
174
|
-
const
|
|
174
|
+
const starts = edits?.starts;
|
|
175
|
+
const providers = edits?.providers;
|
|
176
|
+
// why: Choosing another agent or node changes neither the files nor the providers, so they compile once.
|
|
177
|
+
const files = useMemo(() => (starts && providers ? compileFiles(starts, providers, project.profiles) : undefined), [starts, providers, project.profiles]);
|
|
178
|
+
const saved = useMemo(() => (edits && files ? savedPayload(edits, files, payload) : undefined), [edits, files, payload]);
|
|
175
179
|
if (isChat(payload) && (!saved || isChat(saved)))
|
|
176
180
|
return (_jsx(ProjectChat, { project: project, profileId: payload.agentId, tested: tested, note: run.note, traces: run.traces, trace: run.trace, className: run.className, chatRef: run.chatRef, slots: run.slots, context: run.context }));
|
|
177
181
|
if (!edits)
|
package/ui/studio-screen.js
CHANGED
|
@@ -30,7 +30,7 @@ import { slotProviders } from "../requirements.js";
|
|
|
30
30
|
import { studioSurface } from "../surface.js";
|
|
31
31
|
import './studio.css';
|
|
32
32
|
import { createTraceFeed } from '@theoremjs/web/client';
|
|
33
|
-
import { lazy, memo, Suspense, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
33
|
+
import { createContext, lazy, memo, Suspense, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
34
34
|
import { flushSync } from 'react-dom';
|
|
35
35
|
import { ActingAsButton } from "./acting-as-button.js";
|
|
36
36
|
import { AddProviderButton } from "./add-provider.js";
|
|
@@ -79,28 +79,53 @@ const GuardrailTester = lazy(() => testerPanel().then((tester) => ({ default: te
|
|
|
79
79
|
const traceReplay = () => import("./studio-trace-replay.js");
|
|
80
80
|
const TraceReplay = lazy(() => traceReplay().then((pane) => ({ default: pane.TraceReplay })));
|
|
81
81
|
const StudioSettings = lazy(() => settingsPanel().then((settings) => ({ default: settings.StudioSettings })));
|
|
82
|
+
/** Runs the handler the tree's last render drew at a place. */
|
|
83
|
+
const RowPress = createContext(() => undefined);
|
|
84
|
+
/**
|
|
85
|
+
* The tree's row actions for one render, and the press that runs the latest of them.
|
|
86
|
+
* why: A click re-renders every row; a button whose place, label and icon are the same is not
|
|
87
|
+
* drawn again, and it still runs the handler of the render on screen.
|
|
88
|
+
*/
|
|
89
|
+
function useRowPresses() {
|
|
90
|
+
const shown = useRef([]);
|
|
91
|
+
const drawn = [];
|
|
92
|
+
useLayoutEffect(() => {
|
|
93
|
+
shown.current = drawn;
|
|
94
|
+
});
|
|
95
|
+
const press = useCallback((slot) => {
|
|
96
|
+
shown.current[slot]?.();
|
|
97
|
+
}, []);
|
|
98
|
+
return { presses: { add: (onPress) => drawn.push(onPress) - 1 }, press };
|
|
99
|
+
}
|
|
82
100
|
/** A row's hover action: stops at the button so the row itself isn't selected. */
|
|
83
|
-
function
|
|
101
|
+
const RowButton = memo(function RowButton({ slot, label, icon, }) {
|
|
102
|
+
const press = useContext(RowPress);
|
|
84
103
|
return (_jsx(IconButton, { label: label, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: icon, size: "sm" }), tooltip: label, onClick: (event) => {
|
|
85
104
|
event.stopPropagation();
|
|
86
|
-
|
|
87
|
-
} }
|
|
105
|
+
press(slot);
|
|
106
|
+
} }));
|
|
107
|
+
});
|
|
108
|
+
function actionButton(presses, label, icon, onPress) {
|
|
109
|
+
return _jsx(RowButton, { slot: presses.add(onPress), label: label, icon: icon }, label);
|
|
88
110
|
}
|
|
89
|
-
function rowAction(label, icon, onPress) {
|
|
90
|
-
return _jsx("span", { className: "studio-tree-action", children: actionButton(label, icon, onPress) });
|
|
111
|
+
function rowAction(presses, label, icon, onPress) {
|
|
112
|
+
return _jsx("span", { className: "studio-tree-action", children: actionButton(presses, label, icon, onPress) });
|
|
91
113
|
}
|
|
92
114
|
/** A row's hover actions: Reset, while it differs from its start, then the others, the x last. */
|
|
93
|
-
function rowActions(label, reset, ...actions) {
|
|
94
|
-
const shown = [
|
|
115
|
+
function rowActions(presses, label, reset, ...actions) {
|
|
116
|
+
const shown = [
|
|
117
|
+
reset && actionButton(presses, `Reset ${label}`, IconRotateClockwise, reset),
|
|
118
|
+
...actions,
|
|
119
|
+
];
|
|
95
120
|
return shown.some(Boolean) ? _jsx("span", { className: "studio-tree-action", children: shown }) : undefined;
|
|
96
121
|
}
|
|
97
122
|
function treeItem(tree, node, isTop = false) {
|
|
98
|
-
const { draft, scope, selectedId, onSelect, setDraft } = tree;
|
|
123
|
+
const { draft, scope, selectedId, onSelect, setDraft, presses } = tree;
|
|
99
124
|
const facet = node.ref.facet;
|
|
100
125
|
const id = scope(node.id);
|
|
101
126
|
const isOptional = isTop && facet !== 'toolSpec' && profileGraphFacet(facet)?.optional === true;
|
|
102
|
-
const actions = rowActions(node.label, tree.resetOf(node.ref, node.label), isOptional &&
|
|
103
|
-
actionButton(`Remove ${node.label}`, IconX, () => {
|
|
127
|
+
const actions = rowActions(presses, node.label, tree.resetOf(node.ref, node.label), isOptional &&
|
|
128
|
+
actionButton(presses, `Remove ${node.label}`, IconX, () => {
|
|
104
129
|
setDraft((current) => excludeFacet(current, facet));
|
|
105
130
|
}));
|
|
106
131
|
return {
|
|
@@ -120,7 +145,7 @@ function treeItem(tree, node, isTop = false) {
|
|
|
120
145
|
};
|
|
121
146
|
}
|
|
122
147
|
/** An optional section the type allows but the draft leaves out: dimmed; a click adds it. */
|
|
123
|
-
function offItem({ scope, onSelect, setDraft }, facet) {
|
|
148
|
+
function offItem({ scope, onSelect, setDraft, presses }, facet) {
|
|
124
149
|
const label = profileGraphFacet(facet)?.label ?? facet;
|
|
125
150
|
const add = () => {
|
|
126
151
|
setDraft((current) => includeFacet(current, facet));
|
|
@@ -130,7 +155,7 @@ function offItem({ scope, onSelect, setDraft }, facet) {
|
|
|
130
155
|
id: scope(facet),
|
|
131
156
|
label: _jsx("span", { className: "studio-tree-off", children: label }),
|
|
132
157
|
startContent: (_jsx(Icon, { icon: FACET_ICON[facet], size: "sm", color: "disabled" })),
|
|
133
|
-
endContent: rowAction(`Add ${label}`, IconPlus, add),
|
|
158
|
+
endContent: rowAction(presses, `Add ${label}`, IconPlus, add),
|
|
134
159
|
className: 'studio-tree-row',
|
|
135
160
|
onClick: add,
|
|
136
161
|
};
|
|
@@ -159,7 +184,7 @@ function agentItem(tree, isOpen, actions) {
|
|
|
159
184
|
};
|
|
160
185
|
}
|
|
161
186
|
function agentItems(state) {
|
|
162
|
-
const { workspace, focus, selectedId, onSelect, update, setDraft, reset } = state;
|
|
187
|
+
const { workspace, focus, selectedId, onSelect, update, setDraft, reset, presses } = state;
|
|
163
188
|
const isOnly = workspace.agents.length === 1;
|
|
164
189
|
return workspace.agents.map((agent) => {
|
|
165
190
|
const draft = libraryDraft(workspace, agent.key) ?? createBlankDraft();
|
|
@@ -168,6 +193,7 @@ function agentItems(state) {
|
|
|
168
193
|
return agentItem({
|
|
169
194
|
draft,
|
|
170
195
|
scope: (id) => scopedNodeId(agent.key, id),
|
|
196
|
+
presses,
|
|
171
197
|
selectedId,
|
|
172
198
|
onSelect,
|
|
173
199
|
setDraft,
|
|
@@ -175,16 +201,16 @@ function agentItems(state) {
|
|
|
175
201
|
resetOf: (ref, label) => whole === workspace
|
|
176
202
|
? undefined
|
|
177
203
|
: reset(resetAgentNode(workspace, agent.key, ref), `Reset ${label} to how it started.`),
|
|
178
|
-
}, agent.key === focus, rowActions(name, reset(whole, `Reset ${name} to how it started.`), actionButton(`Duplicate ${name}`, IconCopyPlus, () => {
|
|
204
|
+
}, agent.key === focus, rowActions(presses, name, reset(whole, `Reset ${name} to how it started.`), actionButton(presses, `Duplicate ${name}`, IconCopyPlus, () => {
|
|
179
205
|
update((current) => duplicateAgent(current, agent.key));
|
|
180
206
|
}), !isOnly &&
|
|
181
|
-
actionButton(`Remove ${name}`, IconX, () => {
|
|
207
|
+
actionButton(presses, `Remove ${name}`, IconX, () => {
|
|
182
208
|
update((current) => removeAgent(current, agent.key));
|
|
183
209
|
})));
|
|
184
210
|
});
|
|
185
211
|
}
|
|
186
212
|
/** The tool library, every agent picks its tools from these: those whose name or description holds `query`. */
|
|
187
|
-
function toolItems({ workspace, selectedId, onSelect, update, reset }, query) {
|
|
213
|
+
function toolItems({ workspace, selectedId, onSelect, update, reset, presses }, query) {
|
|
188
214
|
const needle = query.trim().toLowerCase();
|
|
189
215
|
return workspaceTree(workspace).tools.flatMap((node) => {
|
|
190
216
|
const tool = workspace.toolSpecs.find((spec) => spec.key === toolSpecKeyOf(node.id));
|
|
@@ -196,8 +222,8 @@ function toolItems({ workspace, selectedId, onSelect, update, reset }, query) {
|
|
|
196
222
|
id: node.id,
|
|
197
223
|
label: node.label,
|
|
198
224
|
startContent: (_jsx(Icon, { icon: tool ? toolTypeIcon(tool.toolType) : IconTool, size: "sm", color: "secondary" })),
|
|
199
|
-
endContent: rowActions(node.label, tool &&
|
|
200
|
-
reset(resetLibraryTool(workspace, tool.key), `Reset ${node.label} to how it started.`), actionButton(`Remove ${node.label}`, IconX, () => {
|
|
225
|
+
endContent: rowActions(presses, node.label, tool &&
|
|
226
|
+
reset(resetLibraryTool(workspace, tool.key), `Reset ${node.label} to how it started.`), actionButton(presses, `Remove ${node.label}`, IconX, () => {
|
|
201
227
|
if (tool)
|
|
202
228
|
update((current) => removeLibraryTool(current, tool.key));
|
|
203
229
|
})),
|
|
@@ -220,7 +246,7 @@ function declaredAt({ setting }) {
|
|
|
220
246
|
* provider's row opens its own settings; an agent's opens its first model there.
|
|
221
247
|
*/
|
|
222
248
|
function providerItems(tree) {
|
|
223
|
-
const { workspace, selectedId, onSelect, update, ownsProviders, reset } = tree;
|
|
249
|
+
const { workspace, selectedId, onSelect, update, ownsProviders, reset, presses } = tree;
|
|
224
250
|
return workspace.providers.map((provider) => {
|
|
225
251
|
const id = providerNodeId(provider.id);
|
|
226
252
|
// One a model runs on stays: its row lists the agents to move first.
|
|
@@ -240,8 +266,8 @@ function providerItems(tree) {
|
|
|
240
266
|
},
|
|
241
267
|
];
|
|
242
268
|
});
|
|
243
|
-
const actions = rowActions(provider.id, reset(resetProvider(workspace, provider.id), `Reset ${provider.id} to how it started.`), isFree &&
|
|
244
|
-
actionButton(`Remove ${provider.id}`, IconX, () => {
|
|
269
|
+
const actions = rowActions(presses, provider.id, reset(resetProvider(workspace, provider.id), `Reset ${provider.id} to how it started.`), isFree &&
|
|
270
|
+
actionButton(presses, `Remove ${provider.id}`, IconX, () => {
|
|
245
271
|
update((current) => removeProvider(current, provider.id));
|
|
246
272
|
const [first] = workspace.agents;
|
|
247
273
|
if (selectedId === id && first)
|
|
@@ -430,17 +456,19 @@ function WorkspaceListBody({ tree, list, tools, query, listRef, }) {
|
|
|
430
456
|
function WorkspaceTreeLists({ tree, draft, onAddAgent, listRef, }) {
|
|
431
457
|
const { list, setList } = tree;
|
|
432
458
|
const { query, setQuery, revealSelected } = useWorkspaceList(tree.selectedId, listRef);
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
tree.
|
|
443
|
-
|
|
459
|
+
const { presses, press } = useRowPresses();
|
|
460
|
+
const drawn = { ...tree, presses };
|
|
461
|
+
const tools = list === 'tools' ? toolItems(drawn, query) : [];
|
|
462
|
+
return (_jsx(RowPress.Provider, { value: press, children: _jsxs(VStack, { gap: 2, height: "100%", children: [_jsx(WorkspaceListToggle, { workspace: tree.workspace, list: list, onChange: (next) => {
|
|
463
|
+
setList(next);
|
|
464
|
+
revealSelected();
|
|
465
|
+
} }), list === 'agents' ? _jsx(AddAgentMenu, { onAddAgent: onAddAgent }) : null, list === 'tools' && (_jsx(ToolSearchInput, { query: query, onChange: (next) => {
|
|
466
|
+
setQuery(next);
|
|
467
|
+
revealSelected();
|
|
468
|
+
} })), list === 'tools' ? _jsx(AddToolButton, { tree: tree, draft: draft }) : null, list === 'providers' && tree.keys ? _jsx(ManageKeysButton, { keys: tree.keys }) : null, list === 'providers' && tree.ownsProviders ? (_jsx(AddProviderButton, { taken: tree.workspace.providers.map((provider) => provider.id), onAdd: (provider) => {
|
|
469
|
+
tree.update((current) => addProvider(current, provider));
|
|
470
|
+
tree.onSelect(providerNodeId(provider.id));
|
|
471
|
+
} })) : null, _jsx(StackItem, { size: "fill", children: _jsx(WorkspaceListBody, { tree: drawn, list: list, tools: tools, query: query, listRef: listRef }) })] }) }));
|
|
444
472
|
}
|
|
445
473
|
/** The longest agent name the preview's header shows in full. */
|
|
446
474
|
const CHAT_NAME_MAX = 24;
|
|
@@ -837,7 +865,8 @@ function useLeftIssues(issues, page, revealed) {
|
|
|
837
865
|
const leavePage = useCallback(() => {
|
|
838
866
|
const keys = new Set(before.current.map(issueKey));
|
|
839
867
|
return () => {
|
|
840
|
-
|
|
868
|
+
// why: A move that leaves the same issues behind draws the editor nothing new.
|
|
869
|
+
setLeft((was) => was.size === keys.size && [...keys].every((key) => was.has(key)) ? was : keys);
|
|
841
870
|
};
|
|
842
871
|
}, []);
|
|
843
872
|
// biome-ignore lint/correctness/useExhaustiveDependencies: a move or a press of the pill is what lets them show
|
|
@@ -1198,6 +1227,23 @@ function editorIssuesOf(compiled, focus) {
|
|
|
1198
1227
|
return nodeId === undefined ? [] : [{ ...issue, nodeId }];
|
|
1199
1228
|
});
|
|
1200
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* The workspace as it was last edited. Opening a node or choosing whom to chat with changes no
|
|
1232
|
+
* agent, tool, provider, or start.
|
|
1233
|
+
* why: So those clicks compile nothing again and send the project server no new edits to load.
|
|
1234
|
+
*/
|
|
1235
|
+
function useSameContent(workspace) {
|
|
1236
|
+
const [kept, setKept] = useState(workspace);
|
|
1237
|
+
const now = kept.agents === workspace.agents &&
|
|
1238
|
+
kept.toolSpecs === workspace.toolSpecs &&
|
|
1239
|
+
kept.providers === workspace.providers &&
|
|
1240
|
+
kept.starts === workspace.starts
|
|
1241
|
+
? kept
|
|
1242
|
+
: workspace;
|
|
1243
|
+
if (now !== kept)
|
|
1244
|
+
setKept(now);
|
|
1245
|
+
return now;
|
|
1246
|
+
}
|
|
1201
1247
|
/**
|
|
1202
1248
|
* The workspace compiled once edits settle. Only a workspace that compiles changes the preview;
|
|
1203
1249
|
* while one has issues, the last good agent and its conversation stay put. The chatted agent is
|
|
@@ -1205,8 +1251,10 @@ function editorIssuesOf(compiled, focus) {
|
|
|
1205
1251
|
*/
|
|
1206
1252
|
function useWorkspaceCompile(workspace, focus, connection) {
|
|
1207
1253
|
const { mode, on } = connection;
|
|
1208
|
-
const settled = useDebounced(workspace, COMPILE_DEBOUNCE_MS);
|
|
1209
|
-
const
|
|
1254
|
+
const settled = useDebounced(useSameContent(workspace), COMPILE_DEBOUNCE_MS);
|
|
1255
|
+
const { agents, toolSpecs, providers } = settled;
|
|
1256
|
+
const result = useMemo(() => compileWorkspace({ agents, toolSpecs, providers }, on), [agents, toolSpecs, providers, on]);
|
|
1257
|
+
const compile = useMemo(() => ({ workspace: settled, result }), [settled, result]);
|
|
1210
1258
|
const compiled = compile.result;
|
|
1211
1259
|
const lastGood = useLastGood(compile);
|
|
1212
1260
|
const chatWith = workspace.chatWith;
|
|
@@ -1230,7 +1278,7 @@ function useWorkspaceCompile(workspace, focus, connection) {
|
|
|
1230
1278
|
compiled,
|
|
1231
1279
|
payload,
|
|
1232
1280
|
/** The workspace the payload was compiled from: the edits the preview runs. */
|
|
1233
|
-
tested: lastGood?.workspace,
|
|
1281
|
+
tested: compiled.ok ? compile.workspace : lastGood?.workspace,
|
|
1234
1282
|
traced: recordsTraces(payload),
|
|
1235
1283
|
source,
|
|
1236
1284
|
probed,
|
package/workspace.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export interface StudioWorkspace {
|
|
|
42
42
|
chatWith: string;
|
|
43
43
|
starts: WorkspaceStarts;
|
|
44
44
|
}
|
|
45
|
+
/** What a workspace compiles from: its agents, its tool library, and its providers. */
|
|
46
|
+
export type WorkspaceContent = Pick<StudioWorkspace, 'agents' | 'toolSpecs' | 'providers'>;
|
|
45
47
|
/** An agent's node id: its root, or a facet or binding under it (`identity` is the root). */
|
|
46
48
|
export declare function agentNodeId(agentKey: string, inner?: string): string;
|
|
47
49
|
/** A single draft's node id, under `agentKey`. Tools carry no agent: every agent shares them. */
|
|
@@ -57,7 +59,7 @@ export type WorkspaceNodeRef = {
|
|
|
57
59
|
/** What a workspace node id names; `undefined` when it names nothing there. */
|
|
58
60
|
export declare function workspaceNodeRef(workspace: StudioWorkspace, id: string): WorkspaceNodeRef | undefined;
|
|
59
61
|
/** One agent as a single draft: its tools are the library's it allows, in the order it allows them. */
|
|
60
|
-
export declare function agentDraft(workspace:
|
|
62
|
+
export declare function agentDraft(workspace: WorkspaceContent, key: string): StudioDraft | undefined;
|
|
61
63
|
/** Makes what an agent holds now its start: for an example that links its agents after adding them. */
|
|
62
64
|
export declare function markAgentStart(workspace: StudioWorkspace, key: string): StudioWorkspace;
|
|
63
65
|
/**
|
package/workspace.js
CHANGED
|
@@ -307,7 +307,24 @@ export function removeLibraryTool(workspace, toolKey) {
|
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
/** The same settings with the same values. The order they are held in is not a difference. */
|
|
310
|
-
const same = (a, b) => a === b ||
|
|
310
|
+
const same = (a, b) => a === b || canonicalOnce(a) === canonicalOnce(b);
|
|
311
|
+
const canonicalText = new WeakMap();
|
|
312
|
+
/**
|
|
313
|
+
* `canonical(value)`, worked out once for each object.
|
|
314
|
+
*
|
|
315
|
+
* invariant: The workspace replaces what it changes and never edits an agent, tool, or provider
|
|
316
|
+
* in place, so an object's text stays true.
|
|
317
|
+
*/
|
|
318
|
+
function canonicalOnce(value) {
|
|
319
|
+
if (value === null || typeof value !== 'object')
|
|
320
|
+
return canonical(value);
|
|
321
|
+
const known = canonicalText.get(value);
|
|
322
|
+
if (known !== undefined)
|
|
323
|
+
return known;
|
|
324
|
+
const text = canonical(value);
|
|
325
|
+
canonicalText.set(value, text);
|
|
326
|
+
return text;
|
|
327
|
+
}
|
|
311
328
|
const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
312
329
|
/** Whether every agent, tool, and provider is as it started, and no tool was added or removed. */
|
|
313
330
|
export function atStart(workspace) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{t as r}from"./VStack-CkVMcNiK.js";var i=e(n(),1);function a(e,t,n){return Math.max(1,Math.floor((e+n)/(t+n)))}function o(e,t,n){let r=Array.from({length:t},()=>0);return{places:e.map(e=>{let t=r.indexOf(Math.min(...r)),i=r[t]??0;return e!==0&&(r[t]=i+(e??0)+n),{column:t,top:i}}),height:Math.max(0,Math.max(...r)-n)}}var s=t();function c(e,t){return e.width===t.width&&e.gap===t.gap&&e.heights.length===t.heights.length&&e.heights.every((e,n)=>e===t.heights[n])}function l({minWidth:e,children:t}){let n=i.Children.toArray(t),l=(e,t)=>(0,i.isValidElement)(e)&&e.key!==null?e.key:String(t),u=(0,i.useRef)(null),d=(0,i.useRef)([]),f=(0,i.useRef)(null),p=(0,i.useRef)([]),m=e=>(p.current[e]??=t=>(d.current[e]=t,t&&f.current?.observe(t),()=>{t&&f.current?.unobserve(t)}),p.current[e]),[h,g]=(0,i.useState)({width:0,gap:0,heights:[]}),_=a(h.width,e,h.gap),v=(h.width-h.gap*(_-1))/_,{places:y,height:b}=o(n.map((e,t)=>h.heights[t]),_,h.gap),x=h.width>0;return d.current.length=n.length,(0,i.useLayoutEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t={width:e.clientWidth,gap:Number.parseFloat(getComputedStyle(e).rowGap)||0,heights:d.current.map(e=>e?.offsetHeight)};g(e=>c(e,t)?e:t)};t();let n=new ResizeObserver(t);n.observe(e);for(let e of d.current)e&&n.observe(e);return f.current=n,()=>{n.disconnect(),f.current=null}},[]),(0,s.jsx)(r,{ref:u,gap:3,style:x?{position:`relative`,height:b}:void 0,children:n.map((e,t)=>{let n=y[t];return(0,s.jsx)(`div`,{ref:m(t),style:x&&n?{position:`absolute`,top:n.top,left:n.column*(v+h.gap),width:v}:void 0,children:e},l(e,t))})})}export{l as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{c as r,l as i,n as a,t as o}from"./SegmentedControlItem-BBGRPrxp.js";import{t as s}from"./VStack-CkVMcNiK.js";import{n as c,t as l}from"./StackItem-CQviqAfM.js";import{p as u}from"./fieldParts-B7DYLgh4.js";import{i as d}from"./useResolvedRequired-DbsOcDqy.js";import{a as f,c as ee,d as te,m as ne,o as p,u as re,v as m}from"./use-trace-records-B1vrKQmA.js";import{t as h}from"./Text-BOqCfzZC.js";import{n as g}from"./labels-provider-Bt3Q2GjB.js";import{n as ie,t as _}from"./Card-DruykyeB.js";import{n as v,t as ae}from"./IconButton-DVUFx-8p.js";import{n as y}from"./ScrollableArea-BHfY7sWH.js";import{i as b}from"./Banner-O0C5KVNy.js";import{n as oe}from"./row-keys-WByP9Hsh.js";import{t as se}from"./Center-nHS1JSux.js";import{a as x,o as ce}from"./shaped-data-C4yaGRz9.js";import{n as S}from"./trace-patterns-D6TbkLLr.js";import{D as le,H as ue,R as de,b as C,jt as fe,k as pe,x as w,y as me}from"./index-Cl8kUfgj.js";var T=e(n(),1),he=new Set([`image/png`,`image/jpeg`]),E=`image/png,image/jpeg`;function D(e,t){let n=e.replace(/\.[^.]*$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`image`,r=`<${n}>`;for(let e=2;t.includes(r);e+=1)r=`<${n}_${String(e)}>`;return r}async function O(e){if(!he.has(e.type))return null;let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return{mimeType:e.type,data:btoa(n)}}function k(e){return`data:${e.mimeType};base64,${e.data}`}function A(e,t){return typeof e==`string`?e===t:Array.isArray(e)?e.some(e=>A(e,t)):typeof e==`object`&&e?Object.values(e).some(e=>A(e,t)):!1}function j(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>A(t,e)))}function M(e,t,n){let r=D(e,[...Object.keys(t),...n.map(e=>`<${e}>`)]);return{key:r.slice(1,-1),reference:r}}function N(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function P(e,t){let{images:n,state:r}=t;for(let[i,a]of e){let{key:e,reference:o}=M(i.name,{...t.host,...n},Object.keys(r));n={...n,[o]:a},r={...r,[e]:o}}return{images:n,state:r}}function F(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=Array.isArray(n)?n[Number(e)]:n[e]}return n}function I(e,t,n){let r=n===void 0||n in e?n:F(t,n);if(typeof r==`string`&&r in e)return e[r];let i=Object.values(e);return n===void 0&&i.length===1?i[0]:void 0}function L(e,t,n){return{x:e.left*t,y:e.top*n,width:(e.right-e.left)*t,height:(e.bottom-e.top)*n,line:Math.max(2,Math.round(Math.min(t,n)/200))}}var R=.45;async function ge(e,t,n){let r=new Image;r.src=e,await r.decode();let i=document.createElement(`canvas`);i.width=r.naturalWidth,i.height=r.naturalHeight;let a=i.getContext(`2d`);if(!a)return e;let o=L(t,i.width,i.height);return a.drawImage(r,0,0),a.fillStyle=n.shade,a.globalAlpha=R,a.beginPath(),a.rect(0,0,i.width,i.height),a.rect(o.x,o.y,o.width,o.height),a.fill(`evenodd`),a.globalAlpha=1,a.strokeStyle=n.outline,a.lineWidth=o.line,a.strokeRect(o.x,o.y,o.width,o.height),i.toDataURL(`image/png`)}function _e(e){let t=e.right-e.left,n=e.bottom-e.top;return{width:100/t,height:100/n,left:-e.left/t*100,top:-e.top/n*100}}function ve(e){return e.every(e=>typeof e==`string`)}function z(e){return e==null||typeof e==`string`?``:typeof e==`number`?0:typeof e==`boolean`?!1:Array.isArray(e)?[]:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,z(t)]))}function ye(e){let t=e[0];if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=Object.keys(t);return n.length===0||n.length>4||!e.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).join()===n.join()&&Object.values(e).every(e=>typeof e!=`object`||!e))?null:n.map(t=>{let n=e.map(e=>String(e[t]??``).length),r=Math.max(t.length,...n);return{key:t,weight:Math.min(4,Math.max(1,Math.round(r/10)))}})}var B=t();function be(e){return e===null?[]:Array.isArray(e)?e:[e]}function V(){let e=g(),[t,n]=(0,T.useState)(null);return{read:async e=>{n(null);let t=[];for(let r of be(e)){let e=await O(r);e?t.push([r,e]):n(r.name)}return t},status:t===null?void 0:{type:`error`,message:e(`@theorem.decision.image_bad`,{file:t})}}}function xe({onImages:e}){let t=g(),{read:n,status:r}=V();return(0,B.jsx)(C,{label:t(`@theorem.decision.add_image`),isLabelHidden:!0,mode:`dropzone`,isMultiple:!0,accept:E,value:null,placeholder:t(`@theorem.decision.add_image_hint`),status:r,statusVariant:`detached`,onChange:t=>{n(t).then(t=>{t.length>0&&e(t)})}})}var Se={search:()=>[],bootstrap:()=>[]},Ce=48;function H(e,t,n){return Math.min(Math.max(e.split(`
|
|
2
|
-
`).length,t),n)}var U=(0,T.createContext)({images:{},onImages:()=>{}});function we({value:e,label:t,isLabelHidden:n}){let r=g(),{images:i,onImages:a}=(0,T.useContext)(U),{read:o,status:s}=V(),[u,d]=(0,T.useState)(!1),f=Object.hasOwn(i,e)?k(i[e]):void 0;return(0,B.jsxs)(c,{gap:2,vAlign:`center`,children:[(0,B.jsx)(ue,{src:f,alt:t,label:e,onClick:f?()=>d(!0):void 0}),f?(0,B.jsx)(de,{isOpen:u,onOpenChange:d,media:{src:f,alt:t,caption:e},hasZoom:!0}):null,(0,B.jsx)(l,{size:`fill`,children:(0,B.jsx)(C,{label:t,isLabelHidden:n,accept:E,value:null,placeholder:r(`@theorem.decision.replace_image`),status:s,statusVariant:`detached`,onChange:t=>{o(t).then(([t])=>{t&&a({...i,[e]:t[1]})})}})})]})}function W({value:e,onChange:t,label:n,isLabelHidden:r}){let{images:i}=(0,T.useContext)(U),[a]=(0,T.useState)(()=>typeof e==`string`&&(e.length>Ce||e.includes(`
|
|
3
|
-
`))),[o]=(0,T.useState)(()=>typeof e==`string`&&Object.hasOwn(i,e));if(o&&typeof e==`string`)return(0,B.jsx)(we,{value:e,label:n,isLabelHidden:r});if(typeof e==`boolean`)return(0,B.jsx)(me,{label:n,value:e,onChange:t});if(typeof e==`number`)return(0,B.jsx)(pe,{label:n,isLabelHidden:r,size:`sm`,value:e,isWheelEnabled:!1,onChange:t});if(e===null)return(0,B.jsx)(y,{label:n,isLabelHidden:r,size:`sm`,value:``,placeholder:`null`,isDisabled:!0,onChange:()=>{}});let s=String(e);return a?(0,B.jsx)(w,{label:n,isLabelHidden:r,size:`sm`,rows:H(s,2,12),value:s,onChange:t}):(0,B.jsx)(y,{label:n,isLabelHidden:r,size:`sm`,value:s,onChange:t})}function G({label:e,isRequired:t,description:n,children:r}){let i=(0,T.useId)();return(0,B.jsxs)(s,{gap:2,role:`group`,"aria-labelledby":i,children:[(0,B.jsx)(d,{label:e,inputID:``,labelID:i,isGroupLabel:!0,isRequired:t,description:n}),r]})}function K({children:e,...t}){return(0,B.jsx)(G,{...t,children:(0,B.jsx)(`div`,{style:{paddingInlineStart:12,borderInlineStart:`1px solid var(--color-border)`},children:e})})}function q({field:e,onAdd:t}){let n=g();return(0,B.jsx)(c,{children:(0,B.jsx)(v,{label:n(`@theorem.decision.add_item`,{field:e}),size:`sm`,variant:`ghost`,icon:(0,B.jsx)(fe,{size:14}),onClick:t})})}function J({index:e,onRemove:t}){let n=g();return(0,B.jsx)(ae,{label:n(`@theorem.decision.remove_item`,{item:n(`@theorem.data.item`,{index:String(e+1)})}),size:`sm`,variant:`ghost`,icon:(0,B.jsx)(u,{size:14}),onClick:t})}function Y({value:e,onChange:t}){return(0,B.jsx)(s,{gap:3,children:Object.entries(e).map(([n,r])=>(0,B.jsx)(X,{label:x(n),value:r,onChange:r=>t({...e,[n]:r})},n))})}function Te({value:e,onChange:t,label:n}){let r=g(),i=oe(e);if(ve(e))return(0,B.jsx)(le,{label:n,size:`sm`,value:e.map((e,t)=>({id:`${String(t)}:${e}`,label:e})),searchSource:Se,hasCreate:!0,debounceMs:0,placeholder:r(`@theorem.decision.add_value`),onChange:e=>t(e.map(e=>e.label))});let a=ye(e),o=(0,B.jsx)(q,{field:n,onAdd:()=>t([...e,z(e.at(-1))])}),u=n=>(0,B.jsx)(J,{index:n,onRemove:()=>{i.drop(n),t(e.filter((e,t)=>t!==n))}});if(a){let r={display:`grid`,gap:8,alignItems:`start`,gridTemplateColumns:`${a.map(e=>`minmax(0, ${String(e.weight)}fr)`).join(` `)} auto`},s=e;return(0,B.jsxs)(G,{label:n,children:[(0,B.jsxs)(`div`,{style:r,"aria-hidden":!0,children:[a.map(e=>(0,B.jsx)(h,{type:`supporting`,color:`secondary`,maxLines:1,children:x(e.key)},e.key)),(0,B.jsx)(`span`,{style:{width:28}})]}),i.rows.map(({index:e,key:n})=>{let i=s[e];return(0,B.jsxs)(`div`,{style:r,children:[a.map(n=>(0,B.jsx)(W,{label:`${x(n.key)} ${String(e+1)}`,isLabelHidden:!0,value:i[n.key]??null,onChange:r=>t(s.map((t,i)=>i===e?{...t,[n.key]:r}:t))},n.key)),u(e)]},n)}),o]})}return(0,B.jsx)(K,{label:n,children:(0,B.jsxs)(s,{gap:3,children:[i.rows.map(({item:n,index:i,key:a})=>{let o=r(`@theorem.data.item`,{index:String(i+1)}),s=n=>t(e.map((e,t)=>t===i?n:e));return(0,B.jsxs)(c,{gap:2,vAlign:`start`,children:[(0,B.jsx)(l,{size:`fill`,children:ce(n)?(0,B.jsx)(W,{label:o,isLabelHidden:!0,value:n,onChange:s}):(0,B.jsx)(X,{label:o,value:n,onChange:s})}),u(i)]},a)}),o]})})}function X({value:e,onChange:t,label:n}){return Array.isArray(e)?(0,B.jsx)(Te,{label:n,value:e,onChange:t}):typeof e==`object`&&e?(0,B.jsx)(K,{label:n,children:(0,B.jsx)(Y,{value:e,onChange:t})}):(0,B.jsx)(W,{label:n,value:e,onChange:t})}function Ee({value:e,onChange:t,label:n}){return typeof e==`object`&&e&&!Array.isArray(e)?(0,B.jsx)(Y,{value:e,onChange:t}):(0,B.jsx)(X,{label:n,value:e,onChange:t})}var De={"--theorem-console-card":`var(--color-background-muted)`},Z=`(width < 768px)`,Q=(0,T.createContext)(!0);function $(){return(0,T.useSyncExternalStore)(e=>{let t=globalThis.matchMedia(Z);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},()=>globalThis.matchMedia(Z).matches,()=>!1)}function Oe({flush:e,wide:t,maxWidth:n,children:r}){return(0,B.jsx)(s,{height:`100%`,paddingInlineStart:3,style:{...e?De:void 0,paddingInlineEnd:ne(3)},children:(0,B.jsx)(_,{variant:`transparent`,height:`100%`,padding:0,style:e?{overflowY:`auto`}:{...ee,overflowY:`auto`},children:(0,B.jsx)(se,{axis:`horizontal`,width:`100%`,minHeight:`100%`,children:(0,B.jsx)(s,{width:`100%`,maxWidth:t?void 0:n,gap:3,padding:4,children:r})})})})}function ke({inspector:e,maxWidth:t,flush:n=!1,columns:a=!1,requestLabel:o,className:s,style:c,children:l}){let u=(0,T.useRef)(null),d=e.toggle?(0,B.jsx)(te,{floating:!0,children:e.toggle}):void 0;return(0,B.jsx)(b,{inspector:e,children:(0,B.jsx)(i,{ref:u,height:`fill`,className:s,style:{position:`relative`,...c},header:d,content:(0,B.jsx)(r,{padding:0,isScrollable:!1,children:(0,B.jsx)(Ae,{layoutRef:u,flush:n,columns:a,maxWidth:t,requestLabel:o,children:l})})})})}function Ae({layoutRef:e,flush:t,columns:n,maxWidth:r,requestLabel:i,children:a}){let o=$(),s=T.Children.toArray(a).length,c=n&&s>1;return c&&!o?(0,B.jsx)(je,{requestLabel:i,layoutRef:e,children:a}):(0,B.jsx)(Oe,{flush:t,wide:c,maxWidth:r,children:a})}function je({requestLabel:e=`Request`,layoutRef:t,children:n}){let a=g(),o=(0,T.useRef)(null),[s]=(0,T.useState)(()=>t.current?.clientWidth??0),c=m({defaultSize:s>0?Math.round(s*.4):`40%`,minSize:280,maxSize:`70%`,containerRef:o}),[l,u]=T.Children.toArray(n),d={name:e,show:e,hide:e,resize:a(`@theorem.panel.resize`,{name:e})};return(0,B.jsx)(Q,{value:!1,children:(0,B.jsx)(i,{ref:o,height:`fill`,start:(0,B.jsx)(re,{side:`start`,className:`theorem-console-request`,labels:d,resizable:c,open:!0,children:(0,B.jsx)(p,{label:e,children:l})}),content:(0,B.jsx)(r,{padding:0,isScrollable:!1,children:(0,B.jsx)(f,{inset:`beside`,className:`theorem-console-response`,children:u})})})})}function Me({children:e}){return(0,B.jsx)(_,{variant:`muted`,padding:0,className:`theorem-console-card`,style:S,children:(0,B.jsx)(Q,{value:!1,children:e})})}function Ne({label:e,fill:t=!1,children:n}){return(0,T.use)(Q)?(0,B.jsx)(_,{variant:`muted`,padding:t?0:4,className:`theorem-console-card`,style:S,children:t?n:(0,B.jsx)(s,{height:`100%`,gap:3,children:n})}):t?n:(0,B.jsx)(p,{label:e,padding:4,children:n})}function Pe(e){return t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e())}}function Fe({title:e,onRun:t,children:n,...r}){let i=g(),l=(0,T.use)(Q),u=(0,B.jsxs)(s,{gap:3,padding:l?void 0:4,onKeyDown:Pe(t),children:[(0,B.jsxs)(c,{gap:2,hAlign:`between`,vAlign:`center`,children:[(0,B.jsx)(h,{type:`supporting`,color:`secondary`,as:`h3`,children:e}),r.onView?(0,B.jsxs)(a,{label:i(`@theorem.decision.view`),size:`sm`,value:r.view,onChange:e=>{r.onView(e===`json`?`json`:`fields`)},children:[(0,B.jsx)(o,{value:`fields`,label:i(`@theorem.decision.fields`),isDisabled:!r.hasFields}),(0,B.jsx)(o,{value:`json`,label:i(`@theorem.data.json`)})]}):r.actions]}),n]});return l?(0,B.jsx)(_,{variant:`muted`,padding:4,className:`theorem-console-card`,style:S,children:u}):u}var Ie={"--font-family-body":`var(--font-family-code)`};function Le({label:e,text:t,isInvalid:n,onChange:r}){return(0,B.jsx)(w,{label:e,isLabelHidden:!0,value:t,onChange:r,rows:H(t,8,24),hasSpellCheck:!1,status:n?{type:`error`}:void 0,controlStyle:Ie})}function Re({note:e,isReady:t,isRunning:n,runLabel:r,runningLabel:i,stopLabel:a,onRun:o,onStop:s}){return(0,B.jsxs)(c,{gap:3,hAlign:`between`,vAlign:`center`,children:[(0,B.jsx)(h,{type:`supporting`,color:`secondary`,style:t?void 0:{color:`var(--color-error)`},hasTabularNumbers:!0,children:e}),(0,B.jsxs)(c,{gap:2,vAlign:`center`,children:[n?(0,B.jsx)(v,{label:a,variant:`ghost`,onClick:s}):null,(0,B.jsx)(v,{label:n?i:r,variant:`primary`,isLoading:n,isDisabled:!t,onClick:o})]})]})}function ze(){let e=ie();return(0,T.useMemo)(()=>{let t=new Intl.NumberFormat(e,{style:`unit`,unit:`byte`,unitDisplay:`narrow`}),n=new Intl.NumberFormat(e,{style:`unit`,unit:`kilobyte`,unitDisplay:`narrow`,maximumFractionDigits:1});return e=>e<1024?t.format(e):n.format(e/1024)},[e])}export{N as S,_e as _,Ne as a,ge as b,q as c,J as d,Ee as f,I as g,xe as h,Fe as i,K as l,H as m,Me as n,Re as o,U as p,Le as r,ze as s,ke as t,G as u,P as v,j as x,k as y};
|