@theoremjs/studio 0.3.4-next.679.gcdf1a3a → 0.3.4-next.711.g78e504a
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/agreement.js +35 -5
- package/browser-connection.d.ts +1 -1
- package/browser-connection.js +3 -1
- package/browser-execution.js +1 -0
- package/compile-workspace.js +12 -5
- package/compile.d.ts +5 -3
- package/compile.js +80 -36
- package/cookbooks/catalog.d.ts +2 -2
- package/cookbooks/catalog.js +296 -51
- package/cookbooks/project.js +1 -0
- package/cookbooks/tools.js +64 -0
- package/draft.d.ts +23 -4
- package/draft.js +25 -2
- package/guardrail-probe.d.ts +3 -1
- package/guardrail-probe.js +37 -5
- package/mod.d.ts +2 -3
- package/mod.js +2 -3
- package/package.json +4 -4
- package/page/assets/Banner-GFaYsfrc.js +3 -0
- package/page/assets/Center-CgO0c-qo.js +1 -0
- package/page/assets/{ConsoleFrame-BMf3HicW.js → ConsoleFrame-KmyDVQkS.js} +3 -3
- package/page/assets/{MenuBottomSheet-sVJMYa4R.js → MenuBottomSheet-BSQO5V7g.js} +1 -1
- package/page/assets/{SchemaFields-DYormNVH.js → SchemaFields-CIsMisSq.js} +1 -1
- package/page/assets/{ToolResultCharts-Ce4lVdgN.js → ToolResultCharts-95plvcj4.js} +1 -1
- package/page/assets/{TraceInspector-DHyj0IHY.js → TraceInspector-D2113s73.js} +1 -1
- package/page/assets/{TraceOverview-CeiOIqk9.js → TraceOverview-Bz2EnBzL.js} +3 -3
- package/page/assets/{_virtual_studio-type-sources-BwSqfSwd.js → _virtual_studio-type-sources-La9AcR1O.js} +360 -97
- package/page/assets/browser-connection-B2a2EaIg.js +3 -0
- package/page/assets/browser-engine--lGbAmPM.js +13 -0
- package/page/assets/browser-transport-h1KAGUN4.js +45 -0
- package/page/assets/{crypto-CD14HeXH.js → crypto-BnoW7FFO.js} +1 -1
- package/page/assets/{encode-files-DhoC5hWG.js → encode-files-DoLGXgup.js} +1 -1
- package/page/assets/{export-agent-Cs2S0oXB.js → export-agent-CA42Pf8A.js} +3 -3
- package/page/assets/{guardrail-tester-IcJWVveC.js → guardrail-tester-fDJlewVB.js} +2 -2
- package/page/assets/index-Bd7U_fu_.js +149 -0
- package/page/assets/{labels-provider-t4c-5JMk.js → labels-provider-uONlWExD.js} +1 -1
- package/page/assets/live-messages-CTL-QEqM.js +1 -0
- package/page/assets/people-CIsR0-5R.js +1 -0
- package/page/assets/project-address-DjxPZuyn.js +1 -0
- package/page/assets/reader-COeSYhdZ.js +5 -0
- package/page/assets/{schemas-BQ9Jydzb.js → schemas-D7cgkv3L.js} +1 -1
- package/page/assets/shaped-data-7q5Be8sp.js +20 -0
- package/page/assets/{stub-nxRsh1jo.js → stub-DJBcKncO.js} +25 -7
- package/page/assets/studio-code-pane-MXm30Ppv.js +10 -0
- package/page/assets/{studio-console-Cn-v8Vvw.js → studio-console-dHEr6mr5.js} +1 -1
- package/page/assets/studio-decision-BoSmTyjn.js +1 -0
- package/page/assets/studio-embedding-B5E__vsY.js +2 -0
- package/page/assets/studio-host-console-CadL7PPh.js +2 -0
- package/page/assets/{studio-labels-CiLuAo3N.js → studio-labels-sxDmOFeL.js} +1 -1
- package/page/assets/studio-live-Cgt4zKeL.js +5 -0
- package/page/assets/studio-map-BgeqrIh_.js +1 -0
- package/page/assets/{studio-session-CjUQSXx0.js → studio-session-ClF2iNCX.js} +1 -1
- package/page/assets/studio-trace-replay-BqYGBZ1t.js +3 -0
- package/page/assets/{studio-type-checker-BbUSqqOS.js → studio-type-checker-DutkTKte.js} +1 -1
- package/page/assets/tool-schema-m1KPujBp.js +17 -0
- package/page/assets/{trace-record-DxgSKmYY.js → trace-record-Dm2jEhUR.js} +1 -1
- package/page/assets/trace-schema--4IGmLeE.js +1 -0
- package/page/assets/tree-5tuw5ISS.js +3 -0
- package/page/assets/turn-client-BmadRouD.js +2 -0
- package/page/assets/{use-one-call-BZKByPJh.js → use-one-call-IXfdRlUH.js} +1 -1
- package/page/assets/use-second-ticker-D6JSf9B3.js +1 -0
- package/page/assets/workspace-CMUi6xcQ.js +1 -0
- package/page/index.html +22 -20
- package/people.d.ts +2 -0
- package/people.js +3 -1
- package/policy.js +1 -0
- package/providers.d.ts +2 -2
- package/providers.js +8 -3
- package/read-source.js +67 -7
- package/registrations.d.ts +32 -4
- package/runtime-scope.d.ts +6 -3
- package/runtime-scope.js +16 -4
- package/runtime.js +15 -2
- package/section-notes.d.ts +1 -0
- package/section-notes.js +1 -0
- package/serve-page.mjs +8 -4
- package/server/draft-handler.d.ts +4 -4
- package/server/draft-handler.js +3 -2
- package/server/draft-probe.d.ts +9 -1
- package/server/draft-probe.js +2 -1
- package/server/handler.d.ts +0 -3
- package/server/handler.js +62 -38
- package/server/live.d.ts +7 -2
- package/server/live.js +11 -5
- package/server/run-traces.d.ts +5 -1
- package/server/run-traces.js +7 -3
- package/server/save-new.js +5 -5
- package/server/save-plan.js +2 -1
- package/server/save-session.js +4 -2
- package/server/serve.js +2 -1
- package/server/test-key.d.ts +2 -2
- package/server/test-key.js +1 -1
- package/slot-values.d.ts +2 -0
- package/slot-values.js +22 -0
- package/source.js +11 -4
- package/system-markup.d.ts +9 -7
- package/system-markup.js +38 -19
- package/tool-readers.d.ts +23 -0
- package/tool-readers.js +60 -0
- package/tools.js +5 -1
- package/types.d.ts +6 -1
- package/ui/inspector-context.d.ts +1 -8
- package/ui/inspector-context.js +0 -7
- package/ui/inspector.d.ts +43 -1
- package/ui/inspector.js +50 -9
- package/ui/lib/entries.d.ts +13 -0
- package/ui/lib/entries.js +43 -0
- package/ui/lib/project-traces.d.ts +5 -0
- package/ui/lib/project-traces.js +11 -1
- package/ui/lib/studio-page.d.ts +6 -1
- package/ui/lib/studio-page.js +33 -31
- package/ui/lib/studio-prefs.d.ts +0 -4
- package/ui/lib/studio-prefs.js +0 -7
- package/ui/lib/studio-project.d.ts +10 -6
- package/ui/lib/studio-project.js +19 -4
- package/ui/lib/studio-session.d.ts +2 -0
- package/ui/lib/studio-session.js +40 -2
- package/ui/lib/studio-store.d.ts +2 -2
- package/ui/lib/studio-store.js +9 -5
- package/ui/lib/tool-probe.d.ts +2 -0
- package/ui/lib/tool-probe.js +3 -2
- package/ui/lib/type-icons.d.ts +1 -0
- package/ui/lib/type-icons.js +2 -1
- package/ui/profile-editor.js +69 -45
- package/ui/studio-compare.d.ts +14 -4
- package/ui/studio-compare.js +58 -24
- package/ui/studio-live.d.ts +1 -1
- package/ui/studio-live.js +8 -3
- package/ui/studio-runner.d.ts +3 -2
- package/ui/studio-runner.js +16 -14
- package/ui/studio-screen.d.ts +1 -2
- package/ui/studio-screen.js +33 -37
- package/ui/studio-settings.js +4 -13
- package/ui/studio-trace-replay.js +7 -1
- package/workspace.js +3 -2
- package/asks.d.ts +0 -54
- package/asks.js +0 -69
- package/page/assets/Banner-CkcwUyOn.js +0 -4
- package/page/assets/Center-nHS1JSux.js +0 -1
- package/page/assets/browser-connection-DSUHVCT5.js +0 -3
- package/page/assets/browser-engine-BXSD3WU8.js +0 -11
- package/page/assets/browser-transport-cp9y8bBz.js +0 -45
- package/page/assets/index-JWco7tJJ.js +0 -145
- package/page/assets/live-messages-CiLmR89m.js +0 -1
- package/page/assets/reader-DrOfMM8I.js +0 -5
- package/page/assets/shaped-data-H1miOZm2.js +0 -20
- package/page/assets/studio-code-pane-B8MOEW9g.js +0 -8
- package/page/assets/studio-decision-CjJ_pqdJ.js +0 -1
- package/page/assets/studio-embedding-Cq3ePsfC.js +0 -2
- package/page/assets/studio-host-console-D__Of1no.js +0 -2
- package/page/assets/studio-live-DvDQbP5V.js +0 -5
- package/page/assets/studio-map-BZFYGG_Y.js +0 -1
- package/page/assets/studio-trace-replay-D22FgUA5.js +0 -3
- package/page/assets/tool-schema-BmRYaywn.js +0 -17
- package/page/assets/trace-schema-9CdEyG6Q.js +0 -1
- package/page/assets/tree-3N-1RPZz.js +0 -3
- package/page/assets/turn-client-DN8PawJr.js +0 -2
- package/page/assets/use-second-ticker-CEwOSS-d.js +0 -1
- package/page/assets/workspace-CTSW941G.js +0 -1
- package/ui/confirm-write.d.ts +0 -12
- package/ui/confirm-write.js +0 -45
package/ui/studio-runner.js
CHANGED
|
@@ -15,7 +15,7 @@ import { pageConversationKey } from "./lib/studio-conversation.js";
|
|
|
15
15
|
import { STUDIO_LABELS } from "./lib/studio-labels.js";
|
|
16
16
|
import { editedProfileEndpoint, projectProfileEndpoint, useProject, } from "./lib/studio-project.js";
|
|
17
17
|
import { warmWhenIdle } from "./lib/when-idle.js";
|
|
18
|
-
import { EditedSide, ProjectChat, SavedSide, SavedSlot, unsavedEdits, useEditedLoad, useLoadedStamp, useSavedHidden, } from "./studio-compare.js";
|
|
18
|
+
import { EditedSide, ProjectChat, SavedSide, SavedSlot, unsavedEdits, useEditedLoad, useLoadedStamp, useLoadedStated, useSavedHidden, } from "./studio-compare.js";
|
|
19
19
|
import { ChooseConflictsContext } from "./studio-conflicts.js";
|
|
20
20
|
import { clearRemoves, useProjectSave } from "./studio-save.js";
|
|
21
21
|
// Each type that is not a chat loads when an agent of it first runs, or once the page is idle.
|
|
@@ -58,16 +58,16 @@ export function StudioRunner({ onActivity, traces: given, ...props }) {
|
|
|
58
58
|
}, []);
|
|
59
59
|
return (_jsx(Suspense, { fallback: _jsx(RunLoading, {}), children: _jsx(Run, { ...props, project: project, traces: traces, note: note }) }));
|
|
60
60
|
}
|
|
61
|
-
function Run({ payload, runtime, trace, className, flush, columns, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, slots, context, tested, project, traces, note, }) {
|
|
61
|
+
function Run({ payload, runtime, trace, className, flush, columns, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, slots, statedOf, context, tested, project, traces, note, }) {
|
|
62
62
|
if (project)
|
|
63
|
-
return (_jsx(ProjectRun, { project: project, payload: payload, traces: traces, trace: trace, className: className, flush: flush, columns: columns, note: note, chatRef: chatRef, slots: slots, context: context, tested: tested }));
|
|
63
|
+
return (_jsx(ProjectRun, { project: project, payload: payload, traces: traces, trace: trace, className: className, flush: flush, columns: columns, note: note, conversation: conversation, conversationView: conversationView, initialText: initialText, initialFiles: initialFiles, initialVoice: initialVoice, initialPending: initialPending, onConversationChange: onConversationChange, chatRef: chatRef, slots: slots, statedOf: statedOf, context: context, tested: tested }));
|
|
64
64
|
if (payload.profile.type === 'decision')
|
|
65
65
|
return (_jsx(StudioDecision, { payload: payload, runtime: runtime, traces: traces, trace: trace, className: className, onActivity: note, flush: flush, columns: columns }));
|
|
66
66
|
if (payload.profile.type === 'host')
|
|
67
67
|
return (_jsx(StudioHostConsole, { payload: payload, runtime: runtime, traces: traces, trace: trace, className: className, onActivity: note, flush: flush, columns: columns }));
|
|
68
68
|
if (payload.profile.type === 'embedding')
|
|
69
69
|
return (_jsx(StudioEmbedding, { payload: payload, runtime: runtime, traces: traces, trace: trace, className: className, onActivity: note, flush: flush, columns: columns }));
|
|
70
|
-
return (_jsx(TurnRun, { payload: payload, runtime: runtime, traces: traces, trace: trace, className: className, note: note, conversation: conversation, conversationView: conversationView, initialText: initialText, initialFiles: initialFiles, initialVoice: initialVoice, initialPending: initialPending, onConversationChange: onConversationChange, chatRef: chatRef, slots: slots, context: context }));
|
|
70
|
+
return (_jsx(TurnRun, { payload: payload, runtime: runtime, traces: traces, trace: trace, className: className, note: note, conversation: conversation, conversationView: conversationView, initialText: initialText, initialFiles: initialFiles, initialVoice: initialVoice, initialPending: initialPending, onConversationChange: onConversationChange, chatRef: chatRef, slots: slots, statedOf: statedOf, context: context }));
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* The two ways out of a run that waits on a Save: write the edits, or drop them. Dropping an
|
|
@@ -116,7 +116,7 @@ function savedPayload(edits, files, payload) {
|
|
|
116
116
|
return { ...payload, agentId, profile, customTools, structured, questions, dependencies };
|
|
117
117
|
}
|
|
118
118
|
/** One profile on one endpoint, as its type runs: a chat, a decision, an embedding, a tool console, or a call. */
|
|
119
|
-
function SideRun({ payload, endpoint, load, traces, note, trace, className, flush, columns, chatRef, slots, context, }) {
|
|
119
|
+
function SideRun({ payload, endpoint, load, traces, note, trace, className, flush, columns, chatRef, slots, stated, context, }) {
|
|
120
120
|
const { type } = payload.profile;
|
|
121
121
|
// One per load, so each transport below is made again when the edits load again.
|
|
122
122
|
const at = useMemo(() => ({ endpoint, load }), [endpoint, load]);
|
|
@@ -136,7 +136,7 @@ function SideRun({ payload, endpoint, load, traces, note, trace, className, flus
|
|
|
136
136
|
? noting({ ...createEmbeddingTransport({ endpoint: at.endpoint }), traces }, note)
|
|
137
137
|
: null, [type, at, traces, note]);
|
|
138
138
|
if (chat)
|
|
139
|
-
return (_jsx(TheoremChat, { detectCodeLanguage: true, labels: STUDIO_LABELS, transport: chat, pageTools: pageTools, trace: trace, className: className, chatRef: chatRef, slots: slots, context: context }));
|
|
139
|
+
return (_jsx(TheoremChat, { detectCodeLanguage: true, labels: STUDIO_LABELS, transport: chat, pageTools: pageTools, trace: trace, className: className, chatRef: chatRef, slots: slots, stated: stated, context: context }));
|
|
140
140
|
const view = { payload, trace, flush, columns, className };
|
|
141
141
|
if (decision)
|
|
142
142
|
return _jsx(DecisionView, { ...view, transport: decision });
|
|
@@ -144,20 +144,21 @@ function SideRun({ payload, endpoint, load, traces, note, trace, className, flus
|
|
|
144
144
|
return _jsx(EmbeddingView, { ...view, transport: embedding });
|
|
145
145
|
if (host)
|
|
146
146
|
return _jsx(HostView, { ...view, transport: host });
|
|
147
|
-
return (_jsx(ProjectLive, { payload: payload, endpoint: endpoint, note: note, trace: trace, slots: slots, context: context }));
|
|
147
|
+
return (_jsx(ProjectLive, { payload: payload, endpoint: endpoint, note: note, trace: trace, slots: slots, stated: stated, context: context }));
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* A project's profile with edits the files do not hold, where either side is not a chat: the
|
|
151
151
|
* files' run and the edits' run side by side, each its own. The files' side can be put away.
|
|
152
152
|
*/
|
|
153
|
-
function ProjectSides({ project, payload, saved, edits, traces, chatRef, ...shared }) {
|
|
153
|
+
function ProjectSides({ project, payload, saved, edits, traces, chatRef, statedOf, ...shared }) {
|
|
154
154
|
const { answer, pending } = useEditedLoad(project, edits, false);
|
|
155
155
|
const stamp = useLoadedStamp(answer);
|
|
156
156
|
const refused = answer && !answer.ok && !pending ? answer : undefined;
|
|
157
|
+
const stated = useLoadedStated(statedOf?.(payload), !pending && !refused);
|
|
157
158
|
const isSavedHidden = useSavedHidden();
|
|
158
159
|
// The edited side's own feed, so its traces are not the files' side's.
|
|
159
160
|
const [editedTraces] = useState(createTraceFeed);
|
|
160
|
-
return (_jsxs(HStack, { height: "100%", children: [_jsx(SavedSlot, { isShown: !isSavedHidden, hasDivider: true, children: saved && (_jsx(SavedSide, { children: _jsx(SideRun, { ...shared, payload: saved, endpoint: projectProfileEndpoint(project, saved.agentId), traces: traces }) })) }), _jsx("div", { className: "studio-edited-slot", children: _jsx(EditedSide, { refused: refused, isLoading: stamp === undefined && !refused, hasSaved: saved !== undefined, actions: _jsx(UnsavedActions, { agentId: payload.agentId, isNew: clearRemoves(edits, payload.agentId, project.profiles) }), children: stamp !== undefined && (_jsx(SideRun, { ...shared, load: stamp, payload: payload, endpoint: editedProfileEndpoint(project, payload.agentId), traces: editedTraces, chatRef: chatRef })) }) }, "edited")] }));
|
|
161
|
+
return (_jsxs(HStack, { height: "100%", children: [_jsx(SavedSlot, { isShown: !isSavedHidden, hasDivider: true, children: saved && (_jsx(SavedSide, { children: _jsx(SideRun, { ...shared, payload: saved, stated: statedOf?.(saved), endpoint: projectProfileEndpoint(project, saved.agentId), traces: traces }) })) }), _jsx("div", { className: "studio-edited-slot", children: _jsx(EditedSide, { refused: refused, isLoading: stamp === undefined && !refused, hasSaved: saved !== undefined, actions: _jsx(UnsavedActions, { agentId: payload.agentId, isNew: clearRemoves(edits, payload.agentId, project.profiles) }), children: stamp !== undefined && (_jsx(SideRun, { ...shared, load: stamp, payload: payload, stated: stated, endpoint: editedProfileEndpoint(project, payload.agentId), traces: editedTraces, chatRef: chatRef })) }) }, "edited")] }));
|
|
161
162
|
}
|
|
162
163
|
/**
|
|
163
164
|
* A project's profile, run by the studio's local server: the project's own tools and models.
|
|
@@ -165,7 +166,7 @@ function ProjectSides({ project, payload, saved, edits, traces, chatRef, ...shar
|
|
|
165
166
|
* and as the files with the edits laid over them. Two chats share one message.
|
|
166
167
|
*/
|
|
167
168
|
function ProjectRun({ project, tested, ...run }) {
|
|
168
|
-
const { payload } = run;
|
|
169
|
+
const { payload, statedOf } = run;
|
|
169
170
|
const edits = useMemo(() => unsavedEdits(tested, project.profiles), [tested, project.profiles]);
|
|
170
171
|
const starts = edits?.starts;
|
|
171
172
|
const providers = edits?.providers;
|
|
@@ -173,12 +174,13 @@ function ProjectRun({ project, tested, ...run }) {
|
|
|
173
174
|
const files = useMemo(() => (starts && providers ? compileFiles(starts, providers, project.profiles) : undefined), [starts, providers, project.profiles]);
|
|
174
175
|
const saved = useMemo(() => (edits && files ? savedPayload(edits, files, payload) : undefined), [edits, files, payload]);
|
|
175
176
|
if (isChat(payload) && (!saved || isChat(saved)))
|
|
176
|
-
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
|
+
return (_jsx(ProjectChat, { project: project, profileId: payload.agentId, tested: tested, note: run.note, traces: run.traces, trace: run.trace, className: run.className, conversation: run.conversation, conversationView: run.conversationView, initialText: run.initialText, initialFiles: run.initialFiles, initialVoice: run.initialVoice, initialPending: run.initialPending, onConversationChange: run.onConversationChange, chatRef: run.chatRef, slots: run.slots, stated: statedOf?.(payload), savedStated: statedOf?.(saved ?? payload), context: run.context }));
|
|
177
178
|
if (!edits)
|
|
178
|
-
return _jsx(SideRun, { ...run, endpoint: projectProfileEndpoint(project, payload.agentId) });
|
|
179
|
+
return (_jsx(SideRun, { ...run, stated: statedOf?.(payload), endpoint: projectProfileEndpoint(project, payload.agentId) }));
|
|
179
180
|
return _jsx(ProjectSides, { ...run, project: project, saved: saved, edits: edits });
|
|
180
181
|
}
|
|
181
|
-
function TurnRun({ payload, runtime, traces, trace, className, note, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, slots, context, }) {
|
|
182
|
+
function TurnRun({ payload, runtime, traces, trace, className, note, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, slots, statedOf, context, }) {
|
|
183
|
+
const stated = statedOf?.(payload);
|
|
182
184
|
const iface = useMemo(() => studioInterface(payload), [payload]);
|
|
183
185
|
/** The studio's page answers each page tool with the tool's stub. */
|
|
184
186
|
const pageTools = useMemo(() => studioPageTools(payload), [payload]);
|
|
@@ -188,5 +190,5 @@ function TurnRun({ payload, runtime, traces, trace, className, note, conversatio
|
|
|
188
190
|
traces,
|
|
189
191
|
})
|
|
190
192
|
: createStudioTransport(payload, { traces }), note), [payload, runtime, traces, note]);
|
|
191
|
-
return iface.type === 'live' ? (_jsx(StudioLive, { payload: payload, runtime: runtime, note: note, trace: trace, slots: slots, context: context })) : (_jsx(TheoremChat, { detectCodeLanguage: true, labels: STUDIO_LABELS, transport: transport, trace: trace, className: className, conversation: conversation, conversationView: conversationView, initialText: initialText, initialFiles: initialFiles, initialVoice: initialVoice, initialPending: initialPending, onConversationChange: onConversationChange, chatRef: chatRef, slots: slots, context: context, pageTools: pageTools }));
|
|
193
|
+
return iface.type === 'live' ? (_jsx(StudioLive, { payload: payload, runtime: runtime, note: note, trace: trace, slots: slots, stated: stated, context: context })) : (_jsx(TheoremChat, { detectCodeLanguage: true, labels: STUDIO_LABELS, transport: transport, trace: trace, className: className, conversation: conversation, conversationView: conversationView, initialText: initialText, initialFiles: initialFiles, initialVoice: initialVoice, initialPending: initialPending, onConversationChange: onConversationChange, chatRef: chatRef, slots: slots, stated: stated, context: context, pageTools: pageTools }));
|
|
192
194
|
}
|
package/ui/studio-screen.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare function useStudioWorkspace(start: RestoredStudio, project: ProjectSessi
|
|
|
26
26
|
setQuiet: (quiet: boolean) => void;
|
|
27
27
|
cancelShared: () => void;
|
|
28
28
|
standOn: (files: string) => void;
|
|
29
|
-
flush(): void;
|
|
29
|
+
flush(isLeaving?: boolean): void;
|
|
30
30
|
};
|
|
31
31
|
workspace: StudioWorkspace;
|
|
32
32
|
draft: StudioDraft;
|
|
@@ -35,7 +35,6 @@ declare function useStudioWorkspace(start: RestoredStudio, project: ProjectSessi
|
|
|
35
35
|
update: (change: (current: StudioWorkspace) => StudioWorkspace) => void;
|
|
36
36
|
shared: SharedEntry[];
|
|
37
37
|
origins: import("../server/save-wire.ts").ProjectOrigins | undefined;
|
|
38
|
-
asks: import("../asks.ts").StudioAsks | undefined;
|
|
39
38
|
files: ProjectFiles | undefined;
|
|
40
39
|
refreshOrigins: () => void;
|
|
41
40
|
filesChanged: () => void;
|
package/ui/studio-screen.js
CHANGED
|
@@ -25,7 +25,7 @@ import { IconAdjustmentsHorizontal, IconArrowBarToDown, IconArrowLeft, IconBrows
|
|
|
25
25
|
import { profileGraphFacet } from '@theoremjs/agents';
|
|
26
26
|
import { InPlace, PaneFailure, RaisedPane, useDisclosureMotion, } from '@theoremjs/react/ui';
|
|
27
27
|
import { canonical } from "../canonical.js";
|
|
28
|
-
import { addAgent, addArchitectExample, addProvider, addResearchExample, agentNodeId, compileWorkspace, createBlankDraft, createConsoleExampleDraft, createDecisionExampleDraft, createExampleDraft, createGeminiEmbeddingExampleDraft, createLiveExampleDraft, createNarratorExampleDraft, draftFacets, duplicateAgent, editedSince, excludeFacet, includableFacets, includeFacet, libraryDraft, localProviderAddress, mergedWithFiles, modelBindingNodeId, modelRoute, modelSharers, modelSlots, nodeOrigins, onStudioLocal, openOutcome, originLabel, originPlace, originWay, providerIdOf, providerNodeId, providerUse, rebased, removeAgent, removeLibraryTool, removeProvider, renameProvider, reopened, resetAgent, resetAgentNode, resetLibraryTool, resetProvider, sampleToolInput, scopedNodeId, setToolAllowed, sharedAsk, sharedAt, sharedEntries, studioNodeRef, studioSource, studioTree, toolSpecKeyOf, withAgentDraft, withFilesChosen, withProvider, workspaceNodeRef, workspaceRunAgent, workspaceTree,
|
|
28
|
+
import { addAgent, addArchitectExample, addProvider, addResearchExample, agentNodeId, compileWorkspace, createBlankDraft, createConsoleExampleDraft, createDecisionExampleDraft, createExampleDraft, createGeminiEmbeddingExampleDraft, createLiveExampleDraft, createNarratorExampleDraft, draftFacets, duplicateAgent, editedSince, excludeFacet, includableFacets, includeFacet, libraryDraft, localProviderAddress, mergedWithFiles, modelBindingNodeId, modelRoute, modelSharers, modelSlots, nodeOrigins, onStudioLocal, openOutcome, originLabel, originPlace, originWay, providerIdOf, providerNodeId, providerUse, rebased, removeAgent, removeLibraryTool, removeProvider, renameProvider, reopened, resetAgent, resetAgentNode, resetLibraryTool, resetProvider, sampleToolInput, scopedNodeId, setToolAllowed, sharedAsk, sharedAt, sharedEntries, studioNodeRef, studioSource, studioTree, toolSpecKeyOf, withAgentDraft, withFilesChosen, withProvider, workspaceNodeRef, workspaceRunAgent, workspaceTree, } from "../mod.js";
|
|
29
29
|
import { slotProviders } from "../requirements.js";
|
|
30
30
|
import { studioSurface } from "../surface.js";
|
|
31
31
|
import './studio.css';
|
|
@@ -34,8 +34,7 @@ import { createContext, lazy, memo, Suspense, useCallback, useContext, useEffect
|
|
|
34
34
|
import { flushSync } from 'react-dom';
|
|
35
35
|
import { ActingAsButton } from "./acting-as-button.js";
|
|
36
36
|
import { AddProviderButton } from "./add-provider.js";
|
|
37
|
-
import {
|
|
38
|
-
import { ConfirmWrite, GuardrailTest, ISSUE_ROW_ATTRIBUTE, LeavePage, ListBadges, LocalConnection, ProbedAgent, ProjectAsks, QuestionLink, RowOrigins, RunsOn, WorkspaceContext, } from "./inspector-context.js";
|
|
37
|
+
import { GuardrailTest, ISSUE_ROW_ATTRIBUTE, LeavePage, ListBadges, LocalConnection, ProbedAgent, QuestionLink, RowOrigins, RunsOn, WorkspaceContext, } from "./inspector-context.js";
|
|
39
38
|
import { ActingAsContext, chatKeyOf, useActingAsState } from "./lib/acting-as.js";
|
|
40
39
|
import { runsAsConversation } from "./lib/conversation-types.js";
|
|
41
40
|
import { FACET_ICON } from "./lib/facet-icons.js";
|
|
@@ -48,7 +47,7 @@ import { clearConversation, restoreConversation, saveConversation, } from "./lib
|
|
|
48
47
|
import { STUDIO_EXAMPLES } from "./lib/studio-examples.js";
|
|
49
48
|
import { pageInputsOf, sentPageValues, usePageValues } from "./lib/studio-page.js";
|
|
50
49
|
import { getPref, setPref } from "./lib/studio-prefs.js";
|
|
51
|
-
import {
|
|
50
|
+
import { openInEditor, openProject, ProjectContext, projectCode, readFiles, useProject, } from "./lib/studio-project.js";
|
|
52
51
|
import { dropAside, keepReading, keptReading, setAside } from "./lib/studio-restore.js";
|
|
53
52
|
import { projectKey } from "./lib/studio-session.js";
|
|
54
53
|
import { closeSettings, openSettings, settingsScreen, useSettingsDoor, } from "./lib/studio-settings.js";
|
|
@@ -525,12 +524,6 @@ function editorTitle(draft, id) {
|
|
|
525
524
|
return nodeLabel(studioTree(draft), id);
|
|
526
525
|
return profileGraphFacet(ref.facet)?.label;
|
|
527
526
|
}
|
|
528
|
-
/** The editor's heading: Tools with the tools list and no tool open; else the open node's title. */
|
|
529
|
-
function headingOf(list, editing, title) {
|
|
530
|
-
return list === 'tools' && toolSpecKeyOf(editing) === undefined
|
|
531
|
-
? profileGraphFacet('tools')?.label
|
|
532
|
-
: title;
|
|
533
|
-
}
|
|
534
527
|
/** Waits before compiling after an edit, so typing doesn't recompile on every key. */
|
|
535
528
|
const COMPILE_DEBOUNCE_MS = 300;
|
|
536
529
|
/** The part of a compile the agent runs from: what the run tab and the preview both take. */
|
|
@@ -769,16 +762,11 @@ function keyAndToolMembers(store, page) {
|
|
|
769
762
|
return { slot, checks };
|
|
770
763
|
},
|
|
771
764
|
toolCredential,
|
|
772
|
-
testTool:
|
|
765
|
+
testTool: (key, input) => {
|
|
773
766
|
const tool = store.getDraft().toolSpecs.find((candidate) => candidate.key === key);
|
|
774
767
|
if (!tool)
|
|
775
|
-
return { ok: false, error: 'No such tool.' };
|
|
768
|
+
return Promise.resolve({ ok: false, error: 'No such tool.' });
|
|
776
769
|
const sample = JSON.stringify(input ?? sampleToolInput(tool.toolName, tool.inputJson) ?? {});
|
|
777
|
-
// A tool that writes runs only once the builder read the input and said so.
|
|
778
|
-
const ask = writeAsk(tool, sample);
|
|
779
|
-
if (ask && !(await page.current.confirmWrite(ask))) {
|
|
780
|
-
return { ok: false, error: 'The builder chose not to run it.' };
|
|
781
|
-
}
|
|
782
770
|
return runToolProbe(tool, sample, toolCredential(key), store.getDraft().guardrails);
|
|
783
771
|
},
|
|
784
772
|
};
|
|
@@ -968,13 +956,13 @@ function useStudioWorkspace(start, project) {
|
|
|
968
956
|
store.update(change);
|
|
969
957
|
}, [store]);
|
|
970
958
|
useEffect(() => {
|
|
971
|
-
const
|
|
972
|
-
store.flush();
|
|
959
|
+
const leave = () => {
|
|
960
|
+
store.flush(true);
|
|
973
961
|
};
|
|
974
|
-
globalThis.addEventListener('pagehide',
|
|
962
|
+
globalThis.addEventListener('pagehide', leave);
|
|
975
963
|
return () => {
|
|
976
|
-
globalThis.removeEventListener('pagehide',
|
|
977
|
-
flush();
|
|
964
|
+
globalThis.removeEventListener('pagehide', leave);
|
|
965
|
+
store.flush();
|
|
978
966
|
};
|
|
979
967
|
}, [store]);
|
|
980
968
|
const { files, refreshOrigins, filesChanged, conflict, settle, showConflict, watchFiles } = useProjectFiles(project, store);
|
|
@@ -992,7 +980,6 @@ function useStudioWorkspace(start, project) {
|
|
|
992
980
|
update,
|
|
993
981
|
shared,
|
|
994
982
|
origins: files?.origins,
|
|
995
|
-
asks: files?.asks,
|
|
996
983
|
files,
|
|
997
984
|
refreshOrigins,
|
|
998
985
|
filesChanged,
|
|
@@ -1103,14 +1090,19 @@ function useProjectFiles(project, store) {
|
|
|
1103
1090
|
keep(conflict.read);
|
|
1104
1091
|
setConflict(undefined);
|
|
1105
1092
|
}, [conflict, project, store, keep]);
|
|
1093
|
+
const [watch, setWatch] = useState({ available: false, on: getPref('watch') === 'on' });
|
|
1094
|
+
const watching = useRef(watch.on);
|
|
1106
1095
|
useEffect(() => {
|
|
1107
|
-
|
|
1096
|
+
// why: coming back from the editor is when its saves wait; with the watch off they keep waiting.
|
|
1097
|
+
const onFocus = () => {
|
|
1098
|
+
if (watching.current)
|
|
1099
|
+
refreshOrigins();
|
|
1100
|
+
};
|
|
1101
|
+
globalThis.addEventListener('focus', onFocus);
|
|
1108
1102
|
return () => {
|
|
1109
|
-
globalThis.removeEventListener('focus',
|
|
1103
|
+
globalThis.removeEventListener('focus', onFocus);
|
|
1110
1104
|
};
|
|
1111
1105
|
}, [refreshOrigins]);
|
|
1112
|
-
const [watch, setWatch] = useState({ available: false, on: getPref('watch') === 'on' });
|
|
1113
|
-
const watching = useRef(watch.on);
|
|
1114
1106
|
const setWatching = useCallback((on) => {
|
|
1115
1107
|
watching.current = on;
|
|
1116
1108
|
setPref('watch', on ? 'on' : 'off');
|
|
@@ -1859,6 +1851,7 @@ function PreviewBody({ compile, run, connection, chatRef, chatWith, profileId, t
|
|
|
1859
1851
|
const pageInputs = useMemo(() => (payload ? pageInputsOf(payload) : null), [payload]);
|
|
1860
1852
|
const [pageValues] = usePageValues(chatWith);
|
|
1861
1853
|
const sent = useMemo(() => sentPageValues(pageInputs, pageValues), [pageInputs, pageValues]);
|
|
1854
|
+
const statedOf = useCallback((of) => sentPageValues(pageInputsOf(of), pageValues).stated, [pageValues]);
|
|
1862
1855
|
const shown = payload && !unserved
|
|
1863
1856
|
? {
|
|
1864
1857
|
chatKey: run.chatKey,
|
|
@@ -1876,6 +1869,7 @@ function PreviewBody({ compile, run, connection, chatRef, chatWith, profileId, t
|
|
|
1876
1869
|
clearConversation(run.chatKey);
|
|
1877
1870
|
},
|
|
1878
1871
|
slots: sent.slots,
|
|
1872
|
+
statedOf,
|
|
1879
1873
|
context: sent.context,
|
|
1880
1874
|
tested,
|
|
1881
1875
|
},
|
|
@@ -2042,10 +2036,8 @@ function useStudioPage(opened) {
|
|
|
2042
2036
|
connection.runtime ? 'page' : 'demo', workspace.chatWith, actingAs.actingAs, opened.question);
|
|
2043
2037
|
useArrivalToast(opened, store);
|
|
2044
2038
|
const { replaceWorkspace, copy } = usePageActions(store, view, run.setConversation);
|
|
2045
|
-
const asking = useConfirmWrite();
|
|
2046
2039
|
const openKeys = useOpenKeys(view.setKeysOpen);
|
|
2047
2040
|
const chatRef = useStudioSurface(store, {
|
|
2048
|
-
confirmWrite: asking.confirm,
|
|
2049
2041
|
on: connection.on,
|
|
2050
2042
|
connection,
|
|
2051
2043
|
replaceWorkspace,
|
|
@@ -2076,7 +2068,6 @@ function useStudioPage(opened) {
|
|
|
2076
2068
|
copy,
|
|
2077
2069
|
chatRef,
|
|
2078
2070
|
title,
|
|
2079
|
-
asking,
|
|
2080
2071
|
project,
|
|
2081
2072
|
actingAs,
|
|
2082
2073
|
};
|
|
@@ -2089,7 +2080,7 @@ function useStudioPage(opened) {
|
|
|
2089
2080
|
function Studio({ opened }) {
|
|
2090
2081
|
const page = useStudioPage(opened);
|
|
2091
2082
|
const { state, connection, view, frame, selected, editing, issueReveal, compile } = page;
|
|
2092
|
-
const { goToIssue, sheet, setSheet, run, copy, chatRef, title,
|
|
2083
|
+
const { goToIssue, sheet, setSheet, run, copy, chatRef, title, project, actingAs } = page;
|
|
2093
2084
|
const { questionLink } = page;
|
|
2094
2085
|
const { store, draft } = state;
|
|
2095
2086
|
const tree = useWorkspaceTree(state, view, selected, setSheet);
|
|
@@ -2111,8 +2102,8 @@ function Studio({ opened }) {
|
|
|
2111
2102
|
},
|
|
2112
2103
|
}
|
|
2113
2104
|
: null, [compile.payload, testing, setSheet]);
|
|
2114
|
-
return (_jsx(ProjectContext.Provider, { value: project, children:
|
|
2115
|
-
|
|
2105
|
+
return (_jsx(ProjectContext.Provider, { value: project, children: _jsxs(ActingAsContext.Provider, { value: actingAs, children: [_jsx(SharedChange, { store: state.store }), _jsx(SaveScope, { project: project, state: state, blocked: Boolean(compile.blocked), children: _jsx(QuestionLink, { value: questionLink, children: _jsx(GuardrailTest.Provider, { value: guardrailTest, children: _jsx(Layout, { ref: frame.layoutCallbackRef, className: frameClass(sheet, view.mapOpen, view.settingsOpen), padding: 0, start: _jsx(SidePanel, { frame: frame, tree: tree, draft: draft, onAddAgent: addAgentFrom, setSheet: setSheet, settings: view.settingsOpen &&
|
|
2106
|
+
project && (_jsx(SettingsPane, { state: state, connection: connection, project: project, setConversation: run.setConversation })), map: view.mapOpen && (_jsx(Suspense, { fallback: null, children: _jsx(StudioMap, { workspace: state.workspace, shared: state.shared, selected: view.keysOpen ? '' : selected, onOpen: view.open, onClose: closeMap }) })), children: _jsx(EditorColumn, { heading: view.keysOpen ? 'Keys' : title, state: state, connection: connection, view: view, compile: compile, selected: selected, editing: editing, frame: frame, issueReveal: issueReveal, goToIssue: goToIssue, copy: copy, setSheet: setSheet }) }), content: _jsx(PreviewPane, { store: store, chatAgents: chatAgents, chatWith: state.workspace.chatWith, compile: compile, run: run, connection: connection, chatRef: chatRef, setSheet: setSheet, onIssue: goToIssue, testing: testing && Boolean(compile.payload) }) }) }) }) })] }) }));
|
|
2116
2107
|
}
|
|
2117
2108
|
/** Save for the screen under it, when the studio is open on a project. */
|
|
2118
2109
|
function SaveScope({ project, state, blocked, children, }) {
|
|
@@ -2217,11 +2208,16 @@ function SharedLine({ entry, workspace, selected, onOpen, }) {
|
|
|
2217
2208
|
return (_jsx(Section, { variant: "transparent", padding: 3, children: _jsx(Banner, { status: "info", title: `${entry.setting.label} · used by ${String(count)} other ${count === 1 ? 'profile' : 'profiles'}`, description: `${declaredAt(entry)}. A change here changes ${others.join(', ')} too.`, endContent: onOpen && _jsx(Button, { label: "Open", variant: "ghost", size: "sm", onClick: onOpen }) }) }));
|
|
2218
2209
|
}
|
|
2219
2210
|
/** Over a node one place in the project's files sets whole: what sets it, where, and the way there. */
|
|
2220
|
-
function OriginBanner({ origin, onOpen }) {
|
|
2211
|
+
function OriginBanner({ origin, unloaded, onOpen, }) {
|
|
2221
2212
|
const place = originPlace(origin);
|
|
2213
|
+
const broken = unloaded && origin.kind === 'unfound';
|
|
2222
2214
|
// The cause is the title. Here: what it does to this page, then the way out.
|
|
2223
|
-
const way =
|
|
2224
|
-
|
|
2215
|
+
const way = broken
|
|
2216
|
+
? 'The alert above says what stopped them.'
|
|
2217
|
+
: place
|
|
2218
|
+
? `Edit it at ${place}.`
|
|
2219
|
+
: originWay(origin);
|
|
2220
|
+
return (_jsx(Section, { variant: "transparent", padding: 3, children: _jsx(Banner, { status: "info", title: broken ? 'Your files stopped loading' : originLabel(origin), description: `Read-only here. ${way}`, endContent: place && _jsx(Button, { label: "Open", variant: "ghost", size: "sm", onClick: onOpen }) }) }));
|
|
2225
2221
|
}
|
|
2226
2222
|
/** The editor column: its toolbar over the Keys panel, the open node's editor, or its code. */
|
|
2227
2223
|
function EditorColumn({ heading, state, connection, view, compile, selected, editing, frame, issueReveal, goToIssue, copy, setSheet, }) {
|
|
@@ -2248,7 +2244,7 @@ function EditorColumn({ heading, state, connection, view, compile, selected, edi
|
|
|
2248
2244
|
line: shared.setting.line,
|
|
2249
2245
|
});
|
|
2250
2246
|
}
|
|
2251
|
-
: undefined })), said && (_jsx(OriginBanner, { origin: said, onOpen: () => {
|
|
2247
|
+
: undefined })), said && (_jsx(OriginBanner, { origin: said, unloaded: state.files?.unloaded !== undefined, onOpen: () => {
|
|
2252
2248
|
openOrigin(said);
|
|
2253
2249
|
} })), _jsx(StackItem, { size: "fill", children: _jsx(RowOrigins, { value: rowOrigins, children: _jsx(LeavePage, { value: leavePage, children: _jsx(EditorColumnBody, { state: state, connection: connection, view: view, compile: compile, rowIssues: shown, selected: selected, editing: editing, frame: frame, editorRef: editorRef }) }) }) })] }));
|
|
2254
2250
|
}
|
package/ui/studio-settings.js
CHANGED
|
@@ -57,12 +57,6 @@ const SETTINGS = [
|
|
|
57
57
|
section: 'confirmations',
|
|
58
58
|
words: 'confirm asking',
|
|
59
59
|
},
|
|
60
|
-
{
|
|
61
|
-
id: 'ask-writes',
|
|
62
|
-
label: 'Ask before a tool writes',
|
|
63
|
-
section: 'confirmations',
|
|
64
|
-
words: 'confirm asking destructive run',
|
|
65
|
-
},
|
|
66
60
|
{ id: 'keys', label: 'Model keys', section: 'keys', words: 'api key provider' },
|
|
67
61
|
{
|
|
68
62
|
id: 'acting-as',
|
|
@@ -133,13 +127,8 @@ function FilesSettings({ project, watch, }) {
|
|
|
133
127
|
setPref('filesToast', on ? 'on' : 'off');
|
|
134
128
|
} })] })] }));
|
|
135
129
|
}
|
|
136
|
-
const isAskWrites = (value) => value === 'always' || value === 'destructive';
|
|
137
130
|
function ConfirmationSettings({ shared }) {
|
|
138
|
-
|
|
139
|
-
return (_jsxs(_Fragment, { children: [_jsx(Group, { title: "Shared values", about: "A value several agents share changes on every one of them.", children: _jsx(CheckboxInput, { label: "Ask before changing a shared value", description: "Shows which agents and files the change reaches, before it is made.", value: shared.asks, onChange: shared.set }) }), _jsx(Divider, {}), _jsx(Group, { title: "Tools that write", about: "A real run of a tool that writes can change something outside the studio.", children: _jsxs(RadioList, { label: "Ask before a run", value: askWrites, onChange: (next) => {
|
|
140
|
-
if (isAskWrites(next))
|
|
141
|
-
setPref('askWrites', next);
|
|
142
|
-
}, children: [_jsx(RadioListItem, { value: "always", label: "Every tool that writes", description: "Shows the input the run would send, each time." }), _jsx(RadioListItem, { value: "destructive", label: "Only destructive tools", description: "Tools that read and write run straight away. Tools marked destructive still ask." })] }) })] }));
|
|
131
|
+
return (_jsx(Group, { title: "Shared values", about: "A value several agents share changes on every one of them.", children: _jsx(CheckboxInput, { label: "Ask before changing a shared value", description: "Shows which agents and files the change reaches, before it is made.", value: shared.asks, onChange: shared.set }) }));
|
|
143
132
|
}
|
|
144
133
|
const NO_ONE = 'no-one';
|
|
145
134
|
const personValue = (person) => `person:${person.id}`;
|
|
@@ -250,7 +239,9 @@ function SectionBody({ section, ...props }) {
|
|
|
250
239
|
case 'confirmations':
|
|
251
240
|
return _jsx(ConfirmationSettings, { shared: props.shared });
|
|
252
241
|
case 'keys':
|
|
253
|
-
return (_jsx(Group, { title: "Model keys", about:
|
|
242
|
+
return (_jsx(Group, { title: "Model keys", about: props.project
|
|
243
|
+
? "This project's runs sign with the keys in its entry's provider vault. The studio does not read or change them."
|
|
244
|
+
: 'Your own keys, to run an agent with. Never saved, never written to your project.', children: props.project ? null : props.keys }));
|
|
254
245
|
case 'people':
|
|
255
246
|
return _jsx(PeopleSettings, { project: props.project });
|
|
256
247
|
case 'project':
|
|
@@ -25,8 +25,10 @@ import { createTraceFeed, recordedFeed, } from '@theoremjs/web/client';
|
|
|
25
25
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
26
26
|
import { createBrowserStudioTransport, startBrowserStudioConversation, } from "../browser.js";
|
|
27
27
|
import { createReplay, parseTraceFile, recordedPayload, recordedTranscript, replayScripts, startStudioConversation, studioInterface, studioPageTools, } from "../mod.js";
|
|
28
|
+
import { useActingAs } from "./lib/acting-as.js";
|
|
28
29
|
import { pageConversationKey } from "./lib/studio-conversation.js";
|
|
29
30
|
import { STUDIO_LABELS } from "./lib/studio-labels.js";
|
|
31
|
+
import { startProjectConversation, useProject } from "./lib/studio-project.js";
|
|
30
32
|
/**
|
|
31
33
|
* A live conversation on `blocks`, kept where the live chat keeps its own: sealed in the page
|
|
32
34
|
* when it runs there, else in this visitor's session on the server.
|
|
@@ -153,6 +155,8 @@ function StatusBanner({ status, turns, onContinue, onLive, }) {
|
|
|
153
155
|
}
|
|
154
156
|
/** A replay of the imported trace: driven turn by turn, beside what the trace recorded. */
|
|
155
157
|
function ReplayConsole({ payload, iface, trace, card, records, script, shown, liveTools, runtime, onLive, }) {
|
|
158
|
+
const project = useProject();
|
|
159
|
+
const { actingAs } = useActingAs();
|
|
156
160
|
const diverged = useRef(undefined);
|
|
157
161
|
const [status, setStatus] = useState({ kind: 'running', turn: 0 });
|
|
158
162
|
const [traces] = useState(createTraceFeed);
|
|
@@ -222,7 +226,9 @@ function ReplayConsole({ payload, iface, trace, card, records, script, shown, li
|
|
|
222
226
|
}, [from, replay, script, sendText]);
|
|
223
227
|
const live = async (turn) => {
|
|
224
228
|
const blocks = script.turns.slice(0, turn).flatMap((each) => each.blocks);
|
|
225
|
-
const started =
|
|
229
|
+
const started = project
|
|
230
|
+
? await startProjectConversation(project, payload.agentId, blocks, actingAs)
|
|
231
|
+
: await startLive(payload, runtime, blocks);
|
|
226
232
|
onLive({ ...started, text: script.turns[turn]?.text ?? '' });
|
|
227
233
|
};
|
|
228
234
|
const replayed = shown === 'replayed';
|
package/workspace.js
CHANGED
|
@@ -608,11 +608,12 @@ export function filesPrint(workspace) {
|
|
|
608
608
|
export function editedSince(workspace, files) {
|
|
609
609
|
return filesPrint(workspace) !== files;
|
|
610
610
|
}
|
|
611
|
-
const
|
|
611
|
+
const KEY_SHAPE = '(agent|line|model|tool|question|criterion|reference)-[0-9a-f]{8}';
|
|
612
|
+
const DRAFT_KEY = new RegExp(`^${KEY_SHAPE}$`);
|
|
612
613
|
/** A value as text with each key named by where it first stands, so two opens of one thing read the same. */
|
|
613
614
|
function keyless(value) {
|
|
614
615
|
const names = new Map();
|
|
615
|
-
return JSON.stringify(value).replace(
|
|
616
|
+
return JSON.stringify(value).replace(new RegExp(`\\b${KEY_SHAPE}\\b`, 'g'), (key) => {
|
|
616
617
|
if (!names.has(key))
|
|
617
618
|
names.set(key, `#${names.size}`);
|
|
618
619
|
return names.get(key) ?? key;
|
package/asks.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The question the studio puts before a real run of a tool that writes: which tool, how it is
|
|
3
|
-
* set, what the run sends, and where. A tool that only reads is run unasked.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import type { StageHandler } from '@theoremjs/agents';
|
|
8
|
-
import type { ToolSpecDraft } from './draft.ts';
|
|
9
|
-
/** What the builder reads before a tool that writes runs. */
|
|
10
|
-
export interface WriteAsk {
|
|
11
|
-
tool: string;
|
|
12
|
-
access: Exclude<ToolSpecDraft['access'], 'read-only'>;
|
|
13
|
-
/** The request the run makes, as `METHOD address`. */
|
|
14
|
-
sends: string;
|
|
15
|
-
/** The input the run sends, as the JSON the builder typed. */
|
|
16
|
-
input: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* The question to put before the editor's Test of `tool`, or undefined when the test needs none:
|
|
20
|
-
* the tool only reads, or the test only lists an MCP server's tools and calls none.
|
|
21
|
-
*/
|
|
22
|
-
export declare function writeAsk(tool: ToolSpecDraft, input: string): WriteAsk | undefined;
|
|
23
|
-
/** What the question says above the input. */
|
|
24
|
-
export declare function writeAskLine(ask: WriteAsk): string;
|
|
25
|
-
/** A registered tool, as far as asking goes. An agent tool names the profile it runs. */
|
|
26
|
-
export interface AskTool {
|
|
27
|
-
name: string;
|
|
28
|
-
type: string;
|
|
29
|
-
access: string;
|
|
30
|
-
permission: string;
|
|
31
|
-
profile?: string;
|
|
32
|
-
}
|
|
33
|
-
/** Which of a project's tools the studio makes ask, and which it cannot. */
|
|
34
|
-
export interface StudioAsks {
|
|
35
|
-
/** The tools that ask before each run here and would not in the application. */
|
|
36
|
-
asked: string[];
|
|
37
|
-
/**
|
|
38
|
-
* The tools that write and run unasked: a called agent runs them, and a question inside a called
|
|
39
|
-
* agent has no one to answer it. The call to that agent asks instead.
|
|
40
|
-
*/
|
|
41
|
-
inside: string[];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The tools the studio makes ask before each run: every one that writes, and every agent tool
|
|
45
|
-
* whose agent can reach one that writes. A tool a called agent runs is left as it is, because the
|
|
46
|
-
* kernel refuses a called agent whose tool can stop on a question.
|
|
47
|
-
*/
|
|
48
|
-
export declare function studioAsks(tools: readonly AskTool[], allowed: (profile: string) => readonly string[]): StudioAsks;
|
|
49
|
-
/**
|
|
50
|
-
* The studio's question before each run of an `asked` tool, as a stage. The tool's registration
|
|
51
|
-
* is left as the project set it, so the project's own code reads its own setting. A call the
|
|
52
|
-
* builder already approved where it stopped is not asked again.
|
|
53
|
-
*/
|
|
54
|
-
export declare function studioAskStage(asked: readonly string[]): StageHandler | undefined;
|
package/asks.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The question the studio puts before a real run of a tool that writes: which tool, how it is
|
|
3
|
-
* set, what the run sends, and where. A tool that only reads is run unasked.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* The question to put before the editor's Test of `tool`, or undefined when the test needs none:
|
|
9
|
-
* the tool only reads, or the test only lists an MCP server's tools and calls none.
|
|
10
|
-
*/
|
|
11
|
-
export function writeAsk(tool, input) {
|
|
12
|
-
if (tool.access === 'read-only' || tool.toolType !== 'http')
|
|
13
|
-
return undefined;
|
|
14
|
-
return {
|
|
15
|
-
tool: tool.toolName,
|
|
16
|
-
access: tool.access,
|
|
17
|
-
sends: `${tool.method ?? 'GET'} ${tool.endpoint ?? ''}`.trim(),
|
|
18
|
-
input: input.trim() || '{}',
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/** What the question says above the input. */
|
|
22
|
-
export function writeAskLine(ask) {
|
|
23
|
-
const set = ask.access === 'destructive' ? 'destructive' : 'read and write';
|
|
24
|
-
return `It is set as ${set}. Run sends a real request: ${ask.sends}`;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The tools the studio makes ask before each run: every one that writes, and every agent tool
|
|
28
|
-
* whose agent can reach one that writes. A tool a called agent runs is left as it is, because the
|
|
29
|
-
* kernel refuses a called agent whose tool can stop on a question.
|
|
30
|
-
*/
|
|
31
|
-
export function studioAsks(tools, allowed) {
|
|
32
|
-
const named = new Map(tools.map((tool) => [tool.name, tool]));
|
|
33
|
-
const runs = (tool) => tool.type === 'agent' && tool.profile ? allowed(tool.profile) : [];
|
|
34
|
-
const inside = new Set(tools.flatMap(runs));
|
|
35
|
-
const writes = (tool, seen) => {
|
|
36
|
-
if (seen.has(tool.name))
|
|
37
|
-
return false;
|
|
38
|
-
seen.add(tool.name);
|
|
39
|
-
if (tool.access !== 'read-only')
|
|
40
|
-
return true;
|
|
41
|
-
return runs(tool).some((name) => {
|
|
42
|
-
const inner = named.get(name);
|
|
43
|
-
return inner !== undefined && writes(inner, seen);
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
// A provider's built-in tool runs on the provider and never stops on a question.
|
|
47
|
-
const writing = tools.filter((tool) => tool.type !== 'builtin' && writes(tool, new Set()));
|
|
48
|
-
return {
|
|
49
|
-
asked: writing
|
|
50
|
-
.filter((tool) => !inside.has(tool.name) && tool.permission !== 'always_confirm')
|
|
51
|
-
.map((tool) => tool.name),
|
|
52
|
-
inside: writing.filter((tool) => inside.has(tool.name)).map((tool) => tool.name),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/** What a question the studio puts before a tool that writes says. */
|
|
56
|
-
const STUDIO_ASK_SUMMARY = 'The studio asks before every run of a tool that writes.';
|
|
57
|
-
/**
|
|
58
|
-
* The studio's question before each run of an `asked` tool, as a stage. The tool's registration
|
|
59
|
-
* is left as the project set it, so the project's own code reads its own setting. A call the
|
|
60
|
-
* builder already approved where it stopped is not asked again.
|
|
61
|
-
*/
|
|
62
|
-
export function studioAskStage(asked) {
|
|
63
|
-
if (asked.length === 0)
|
|
64
|
-
return undefined;
|
|
65
|
-
const ask = new Set(asked);
|
|
66
|
-
return (ctx) => ctx.stage === 'pre_tool' && !ctx.approved && ctx.tool !== undefined && ask.has(ctx.tool)
|
|
67
|
-
? { confirm: { summary: STUDIO_ASK_SUMMARY } }
|
|
68
|
-
: undefined;
|
|
69
|
-
}
|