@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/profile-editor.js
CHANGED
|
@@ -18,7 +18,6 @@ import { SegmentedControl, SegmentedControlItem } from '@astryxdesign/core/Segme
|
|
|
18
18
|
import { StackItem } from '@astryxdesign/core/Stack';
|
|
19
19
|
import { pixel, proportional, Table } from '@astryxdesign/core/Table';
|
|
20
20
|
import { Text } from '@astryxdesign/core/Text';
|
|
21
|
-
import { TextArea } from '@astryxdesign/core/TextArea';
|
|
22
21
|
import { TextInput } from '@astryxdesign/core/TextInput';
|
|
23
22
|
import { Thumbnail } from '@astryxdesign/core/Thumbnail';
|
|
24
23
|
import { Token } from '@astryxdesign/core/Token';
|
|
@@ -29,11 +28,11 @@ import { ATTACHMENT_ACCEPT_MIMES, CONTINUE_STOP_KINDS, fieldMeta, HTTP_METHODS,
|
|
|
29
28
|
import { BOUNDARIES, BOUNDARY_META, DETECT_ACTION_META, DETECT_ACTIONS, DETECTOR_BOUNDARIES, DETECTOR_GROUP_META, DETECTOR_GROUPS, DETECTOR_META, DETECTORS, TOOL_BOUNDARIES, TOOL_KINDS, } from '@theoremjs/agents/guardrails';
|
|
30
29
|
import { MODEL_SELECT_MIN_MODELS } from '@theoremjs/agents/interface';
|
|
31
30
|
import { createContext, lazy, Suspense, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
|
|
32
|
-
import { acceptSections, agentToolTarget, bindingSlots, COMPACTION_DRAFT_DEFAULTS, canSize, defaultEffortRequired, defaultModelRequired, definitionOf, draftAllows, draftKey, expandAccept, GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, INLINE_LABELS, includableFacets, includeFacet, inputLimitsRequired, isGoogleRoute, isOpenRouterRoute, keptLimits, kernelDefinitions, LABEL_AREAS, LOCAL_PROVIDER_ID, labelAreaOf, lentCompression, MODEL_LIMITS, modelRoute, modelSlots, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newToolSpec, nextAccept, onStudioLocal, optionAt, PROFILE_LABEL_KEYS, plantsCanary, protocolOptionFields, removeModelBinding, STUDIO_TRACE_DESTINATION, sampleToolInput, sectionNote, servedProtocols, servesProfileType, setProfileType, studioNetworkNote, studioNodeRef, studioRunsProvider, studioTaintNote, TIMER_MAX_MS, takesContinueInstruction, toolSpecKeyOf, toolSpecNodeId, updateModelBinding, withOption,
|
|
31
|
+
import { acceptSections, agentToolTarget, bindingSlots, COMPACTION_DRAFT_DEFAULTS, canSize, defaultEffortRequired, defaultModelRequired, definitionOf, draftAllows, draftConditions, draftKey, expandAccept, GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_OUTPUT_MIMES, GOOGLE_IMAGE_RESOLUTIONS, GOOGLE_SPEECH_FORMATS, GOOGLE_SPEECH_VOICES, INLINE_LABELS, includableFacets, includeFacet, inputLimitsRequired, isGoogleRoute, isOpenRouterRoute, keptLimits, kernelDefinitions, LABEL_AREAS, LOCAL_PROVIDER_ID, labelAreaOf, lentCompression, MODEL_LIMITS, modelRoute, modelSlots, newCondition, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newToolSpec, nextAccept, onStudioLocal, optionAt, PROFILE_LABEL_KEYS, plantsCanary, protocolOptionFields, removeModelBinding, STUDIO_TRACE_DESTINATION, sampleToolInput, sectionNote, servedProtocols, servesProfileType, setProfileType, studioNetworkNote, studioNodeRef, studioRunsProvider, studioTaintNote, TIMER_MAX_MS, takesContinueInstruction, toolSpecKeyOf, toolSpecNodeId, updateModelBinding, withOption, } from "../mod.js";
|
|
33
32
|
import { AddProviderButton } from "./add-provider.js";
|
|
34
33
|
import { IconGoogle, IconOpenAi, IconOpenRouter, IconTypeSafe } from "./brand-icons.js";
|
|
35
|
-
import { ChoiceRow, InspectorGroupTitle, InspectorRow, InspectorSection, ListRow, NamesRow, NumberRow, OriginLine, SegmentedRow, SetInCode, SliderRow, SwitchRow, TextAreaRow, TextRow, } from "./inspector.js";
|
|
36
|
-
import {
|
|
34
|
+
import { ChoiceRow, EntriesRow, InspectorGroupTitle, InspectorRow, InspectorSection, LABEL_COLUMN, ListRow, NamesInput, NamesRow, NumberRow, OriginLine, SegmentedRow, SetInCode, SliderRow, SwitchRow, TextAreaRow, TextRow, } from "./inspector.js";
|
|
35
|
+
import { GuardrailTest, LeavePage, ListBadges, LocalConnection, NodeIssues, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.js";
|
|
37
36
|
import { CONTEXT_PLACEHOLDER, contextErrorOf, draftSlots, usePageValues, } from "./lib/studio-page.js";
|
|
38
37
|
import { useProject } from "./lib/studio-project.js";
|
|
39
38
|
import { setToolCredential, subscribeToolCredentials, toolCredential, } from "./lib/tool-credentials.js";
|
|
@@ -53,6 +52,11 @@ const PROFILE_TYPE_SEGMENTS = [
|
|
|
53
52
|
{ value: 'text', label: 'Text', icon: PROFILE_TYPE_ICON.text },
|
|
54
53
|
{ value: 'image', label: 'Image', icon: PROFILE_TYPE_ICON.image },
|
|
55
54
|
{ value: 'speech', label: 'Speech', icon: PROFILE_TYPE_ICON.speech },
|
|
55
|
+
{
|
|
56
|
+
value: 'transcription',
|
|
57
|
+
label: 'Transcription',
|
|
58
|
+
icon: PROFILE_TYPE_ICON.transcription,
|
|
59
|
+
},
|
|
56
60
|
{ value: 'live', label: 'Live', icon: PROFILE_TYPE_ICON.live },
|
|
57
61
|
{ value: 'decision', label: 'Decision', icon: PROFILE_TYPE_ICON.decision },
|
|
58
62
|
{ value: 'embedding', label: 'Embedding', icon: PROFILE_TYPE_ICON.embedding },
|
|
@@ -171,11 +175,32 @@ function withNewSections(before, after) {
|
|
|
171
175
|
.reduce(includeFacet, after);
|
|
172
176
|
}
|
|
173
177
|
function SystemPromptSection({ identity, set, }) {
|
|
174
|
-
return (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
return (_jsx(InspectorSection, { title: "System prompt", note: sectionNote('system'), children: _jsx(TextAreaRow, { label: "Prompt", path: "identity.system", field: "system", rows: PROMPT_ROWS, value: identity.system, placeholder: fieldMeta('identity.system')?.unset, onChange: (system) => {
|
|
179
|
+
set({ system });
|
|
180
|
+
} }) }));
|
|
181
|
+
}
|
|
182
|
+
/** One condition on one row: its name, the values it takes as tokens, and its remove button. */
|
|
183
|
+
function ConditionRow({ condition, at, onChange, onRemove, }) {
|
|
184
|
+
const status = useFieldStatus()('conditions', at);
|
|
185
|
+
const row = `Condition ${String(at + 1)}`;
|
|
186
|
+
return (_jsxs(HStack, { gap: 1, vAlign: "start", children: [_jsx(StackItem, { size: "static", children: _jsx(HStack, { width: LABEL_COLUMN, children: _jsx(StackItem, { size: "fill", children: _jsx(TextInput, { label: `${row} name`, isLabelHidden: true, size: "sm", status: status, value: condition.name, placeholder: "plan", onChange: (name) => {
|
|
187
|
+
onChange({ name });
|
|
188
|
+
} }) }) }) }), _jsx(StackItem, { size: "fill", children: _jsx(NamesInput, { label: `${row} values`, value: condition.values, placeholder: "free", overflow: "none", onChange: (values) => {
|
|
189
|
+
onChange({ values });
|
|
190
|
+
} }) }), _jsx(IconButton, { label: `Remove ${row.toLowerCase()}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: onRemove })] }));
|
|
191
|
+
}
|
|
192
|
+
/** Every condition, one to a row, and the page's pick for each below them. */
|
|
193
|
+
function ConditionSection({ identity, set, }) {
|
|
194
|
+
const { conditions } = identity;
|
|
195
|
+
return (_jsxs(InspectorSection, { title: "Conditions", path: "identity.conditions", children: [conditions.map((condition, at) => (_jsx(ConditionRow, { condition: condition, at: at, onChange: (change) => {
|
|
196
|
+
set({
|
|
197
|
+
conditions: conditions.map((each) => each.key === condition.key ? { ...each, ...change } : each),
|
|
198
|
+
});
|
|
199
|
+
}, onRemove: () => {
|
|
200
|
+
set({ conditions: conditions.filter((each) => each.key !== condition.key) });
|
|
201
|
+
} }, condition.key))), _jsx(HStack, { children: _jsx(Button, { label: "Add condition", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
|
|
202
|
+
set({ conditions: [...conditions, newCondition()] });
|
|
203
|
+
} }) }), _jsx(ConditionPreviewRows, { conditions: conditions })] }));
|
|
179
204
|
}
|
|
180
205
|
function IdentityEditor({ draft, setDraft }) {
|
|
181
206
|
const keys = useLentKeys();
|
|
@@ -189,8 +214,9 @@ function IdentityEditor({ draft, setDraft }) {
|
|
|
189
214
|
} }), identity.profileType !== 'host' && (_jsx(TextRow, { label: "Handle", path: "identity.handle", field: "handle", value: identity.handle, placeholder: "agent", maxLength: PROFILE_HANDLE_MAX_CHARS, onChange: (handle) => {
|
|
190
215
|
set({ handle });
|
|
191
216
|
} }))] }), identity.profileType !== 'speech' &&
|
|
217
|
+
identity.profileType !== 'transcription' &&
|
|
192
218
|
identity.profileType !== 'decision' &&
|
|
193
|
-
identity.profileType !== 'host' && _jsx(SystemPromptSection, { identity: identity, set: set })] }));
|
|
219
|
+
identity.profileType !== 'host' && (_jsxs(_Fragment, { children: [_jsx(ConditionSection, { identity: identity, set: set }), _jsx(SystemPromptSection, { identity: identity, set: set })] }))] }));
|
|
194
220
|
}
|
|
195
221
|
/** The policy every model of the profile shares: default, switching, steps, and key slots. */
|
|
196
222
|
function ModelPolicySection({ draft, type, set, }) {
|
|
@@ -506,6 +532,10 @@ function ProtocolOptionRow({ option, binding, set, }) {
|
|
|
506
532
|
return (_jsx(NumberRow, { ...common, value: typeof value === 'number' ? value : null, hint: option.description, onChange: (next) => {
|
|
507
533
|
write(next ?? undefined);
|
|
508
534
|
} }));
|
|
535
|
+
case 'names':
|
|
536
|
+
return (_jsx(NamesRow, { label: option.label, path: "models.*.options", field: field, value: Array.isArray(value) ? value.filter((name) => typeof name === 'string') : [], onChange: (next) => {
|
|
537
|
+
write(next.length ? next : undefined);
|
|
538
|
+
} }));
|
|
509
539
|
case 'text':
|
|
510
540
|
return (_jsx(TextRow, { ...common, value: typeof value === 'string' ? value : '', hint: option.description, onChange: (next) => {
|
|
511
541
|
write(next || undefined);
|
|
@@ -660,13 +690,13 @@ function AcceptRow({ label, path, value, picker, hasSizes, onChange, }) {
|
|
|
660
690
|
const unset = fieldMeta(path)?.unset;
|
|
661
691
|
return (_jsx(InspectorRow, { label: label, path: path, hasIssue: status !== undefined, hasNote: Boolean(status?.message), children: _jsx(StackItem, { size: "fill", children: _jsx(ComplexSelector, { label: label, isLabelHidden: true, size: "sm", placement: "below", status: status, value: value, triggerLabel: value.accept.length ? _jsx(AcceptTokens, { ...value }) : undefined, placeholder: unset, onChange: onChange, children: (current, change) => (_jsx(AcceptGrid, { current: current, change: change, picker: picker, hasSizes: hasSizes })) }) }) }));
|
|
662
692
|
}
|
|
663
|
-
function InputAcceptsSection({ inputs, set, image, hasSizes, }) {
|
|
693
|
+
function InputAcceptsSection({ inputs, set, image, voiceOnly, hasSizes, }) {
|
|
664
694
|
const attachmentPicker = image ? IMAGE_ATTACHMENT_PICKER : ATTACHMENT_PICKER;
|
|
665
|
-
return (_jsxs(InspectorSection, { title: "Accepts", path: "inputs", children: [_jsx(SwitchRow, { label: "Text", path: "inputs.text", value: inputs.text, onChange: (text) => {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
695
|
+
return (_jsxs(InspectorSection, { title: "Accepts", path: "inputs", children: [!voiceOnly && (_jsxs(_Fragment, { children: [_jsx(SwitchRow, { label: "Text", path: "inputs.text", value: inputs.text, onChange: (text) => {
|
|
696
|
+
set({ text });
|
|
697
|
+
} }), _jsx(AcceptRow, { label: "Attachments", path: "inputs.attachments.accept", value: { accept: inputs.attachmentsAccept, limits: inputs.limitsByMime }, picker: attachmentPicker, hasSizes: hasSizes, onChange: ({ accept, limits }) => {
|
|
698
|
+
set({ attachmentsAccept: accept, limitsByMime: limits });
|
|
699
|
+
} })] })), !image && (_jsx(AcceptRow, { label: "Voice", path: "inputs.voice.accept", value: { accept: inputs.voiceAccept, limits: inputs.limitsByMime }, picker: VOICE_PICKER, hasSizes: hasSizes, onChange: ({ accept, limits }) => {
|
|
670
700
|
set({ voiceAccept: accept, limitsByMime: limits });
|
|
671
701
|
} }))] }));
|
|
672
702
|
}
|
|
@@ -715,6 +745,15 @@ function SlotPreviewRows({ slots }) {
|
|
|
715
745
|
setValues({ ...values, slots: { ...values.slots, [name]: next } });
|
|
716
746
|
} }, name)));
|
|
717
747
|
}
|
|
748
|
+
/** The value the studio's page states for each condition declared so far. Kept in this tab. */
|
|
749
|
+
function ConditionPreviewRows({ conditions }) {
|
|
750
|
+
const [values, setValues] = usePageValues(useContext(WorkspaceContext)?.self ?? '');
|
|
751
|
+
return Object.entries(draftConditions(conditions)).map(([name, allowed]) => (_jsx(ChoiceRow, { label: name, path: "identity.conditions", hasClear: false, value: allowed.find((value) => value === values.conditions[name]) ?? allowed[0], options: allowed, onChange: (next) => {
|
|
752
|
+
if (next) {
|
|
753
|
+
setValues({ ...values, conditions: { ...values.conditions, [name]: next } });
|
|
754
|
+
}
|
|
755
|
+
} }, name)));
|
|
756
|
+
}
|
|
718
757
|
/** One of a slot's choices: the value a turn sends, what the page says of it, and a remove button. */
|
|
719
758
|
function SlotChoiceRow({ choice, at, onChange, onRemove, }) {
|
|
720
759
|
return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx("div", { className: "criterion-label", children: _jsx(TextInput, { label: `Choice ${String(at + 1)} value`, isLabelHidden: true, size: "sm", value: choice.value, placeholder: "value", onChange: (value) => {
|
|
@@ -770,11 +809,11 @@ function InputsEditor({ draft, setDraft }) {
|
|
|
770
809
|
const set = patch(setDraft, 'inputs');
|
|
771
810
|
/** An image profile takes images, video, and PDF as references, and no voice. */
|
|
772
811
|
const image = draft.identity.profileType === 'image';
|
|
773
|
-
|
|
812
|
+
const voiceOnly = !draftAllows(draft, 'inputs.attachments.accept');
|
|
813
|
+
return (_jsxs(_Fragment, { children: [(!voiceOnly || draftAllows(draft, 'inputs.voice')) && (_jsx(InputAcceptsSection, { inputs: inputs, set: set, image: image, voiceOnly: voiceOnly, hasSizes: draftAllows(draft, 'inputs.limitsByMime') })), draftAllows(draft, 'inputs.maxFiles') && _jsx(InputLimitsSection, { inputs: inputs, set: set }), draftAllows(draft, 'inputs.context') && _jsx(InputContextSection, { inputs: inputs, set: set }), draftAllows(draft, 'inputs.slots') && _jsx(InputSlotsSections, { inputs: inputs, set: set })] }));
|
|
774
814
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
}`;
|
|
815
|
+
/** How tall the system prompt starts. */
|
|
816
|
+
const PROMPT_ROWS = 12;
|
|
778
817
|
/** The agents another agent can name: every one but itself, each by its id. */
|
|
779
818
|
function otherAgents(agents, self, canName) {
|
|
780
819
|
return agents
|
|
@@ -1773,9 +1812,6 @@ function FlagList({ label, path, flags, value, onChange, }) {
|
|
|
1773
1812
|
description: _jsx(Text, { type: "supporting", children: fieldMeta(`${path}.${flag.key}`)?.doc }) }, flag.key))) }));
|
|
1774
1813
|
}
|
|
1775
1814
|
const PERCENT = new Intl.NumberFormat('en-US', { style: 'percent' });
|
|
1776
|
-
const RESOURCE_PLACEHOLDER = `{
|
|
1777
|
-
"service.name": "my-agent"
|
|
1778
|
-
}`;
|
|
1779
1815
|
/** Whether traces are written, and how many turns are sampled. */
|
|
1780
1816
|
function TracesSection({ observability, set }) {
|
|
1781
1817
|
const on = observability.writeTo !== false;
|
|
@@ -1799,7 +1835,7 @@ function TraceStorageSection({ observability, set }) {
|
|
|
1799
1835
|
set({ retainForDays });
|
|
1800
1836
|
} }), _jsx(NumberRow, { label: "Rotate at", path: "observability.rotateAfterMiB", field: "rotateAfterMiB", units: "MiB", value: observability.rotateAfterMiB, min: 1, onChange: (rotateAfterMiB) => {
|
|
1801
1837
|
set({ rotateAfterMiB });
|
|
1802
|
-
} }), _jsx(
|
|
1838
|
+
} }), _jsx(EntriesRow, { label: "Resource", noun: "Attribute", path: "observability.resource", field: "resourceJson", value: observability.resourceJson, typed: true, namePlaceholder: "service.name", valuePlaceholder: "my-agent", onChange: (resourceJson) => {
|
|
1803
1839
|
set({ resourceJson });
|
|
1804
1840
|
} })] }));
|
|
1805
1841
|
}
|
|
@@ -1885,9 +1921,6 @@ function placeholderHint(schemas) {
|
|
|
1885
1921
|
}
|
|
1886
1922
|
return names.size ? `Can use ${[...names].join(' ')}` : undefined;
|
|
1887
1923
|
}
|
|
1888
|
-
const HEADERS_PLACEHOLDER = `{
|
|
1889
|
-
"Accept": "application/json"
|
|
1890
|
-
}`;
|
|
1891
1924
|
/** Adds a new tool to the draft and opens it. */
|
|
1892
1925
|
export function addToolSpec(draft, setDraft, onSelect) {
|
|
1893
1926
|
const tool = newToolSpec(draft);
|
|
@@ -1970,8 +2003,12 @@ function ToolLoadingSection({ value, loaders, set, }) {
|
|
|
1970
2003
|
}
|
|
1971
2004
|
const MS = new Intl.NumberFormat('en-US', { style: 'unit', unit: 'millisecond' });
|
|
1972
2005
|
/** The result's headline: the status line, or for an MCP server, what it offers. */
|
|
1973
|
-
function probeTitle(result, tool) {
|
|
2006
|
+
function probeTitle(result, tool, inProject) {
|
|
1974
2007
|
const took = result.elapsedMs === undefined ? '' : ` · ${MS.format(result.elapsedMs)}`;
|
|
2008
|
+
// why: on a project the test keeps to the agent's guardrail, as its runs do; the way out is there.
|
|
2009
|
+
if (inProject && result.code === 'ssrf_blocked') {
|
|
2010
|
+
return "This agent's network guardrail doesn't allow this address, so a run couldn't call it either. Change it in Guardrails, under Network.";
|
|
2011
|
+
}
|
|
1975
2012
|
if (!result.ok && result.error)
|
|
1976
2013
|
return result.error;
|
|
1977
2014
|
if (tool.toolType === 'mcp' && result.tools) {
|
|
@@ -2048,6 +2085,7 @@ function ToolTest({ tool, guardrails }) {
|
|
|
2048
2085
|
const shown = useContext(ShownProbe);
|
|
2049
2086
|
const [result, setResult] = useState(shown);
|
|
2050
2087
|
const http = tool.toolType === 'http';
|
|
2088
|
+
const inProject = useProject() !== null;
|
|
2051
2089
|
const method = tool.method ?? HTTP_METHODS[0];
|
|
2052
2090
|
// A result answers the request as it was: once what it reaches or sends changes, it's dropped.
|
|
2053
2091
|
const target = probeTarget(tool, method);
|
|
@@ -2056,12 +2094,7 @@ function ToolTest({ tool, guardrails }) {
|
|
|
2056
2094
|
setTestedTarget(target);
|
|
2057
2095
|
setResult(undefined);
|
|
2058
2096
|
}
|
|
2059
|
-
const confirmWrite = useContext(ConfirmWrite);
|
|
2060
2097
|
const run = async () => {
|
|
2061
|
-
// A tool that writes runs only once the builder read the input and said so.
|
|
2062
|
-
const ask = writeAsk(tool, sampleInput);
|
|
2063
|
-
if (ask && !(await confirmWrite(ask)))
|
|
2064
|
-
return;
|
|
2065
2098
|
setPending(true);
|
|
2066
2099
|
try {
|
|
2067
2100
|
setResult(await runToolProbe(tool, sampleInput, credential, guardrails));
|
|
@@ -2072,7 +2105,7 @@ function ToolTest({ tool, guardrails }) {
|
|
|
2072
2105
|
};
|
|
2073
2106
|
return (_jsxs(InspectorSection, { title: "Test", note: http ? sectionNote('tool.test.http', { method }) : sectionNote('tool.test.mcp'), children: [http && _jsx(SampleInputRow, { value: sampleInput, onChange: setTypedInput }), (tool.authType ?? 'none') !== 'none' && (_jsx(TestCredentialRow, { value: credential, onChange: setCredential })), _jsx(TestConnectionButton, { isLoading: pending, onClick: () => {
|
|
2074
2107
|
void run();
|
|
2075
|
-
} }), result && (_jsx(Banner, { status: probeStatus(result), title: probeTitle(result, tool), description: probeDetails(result) }))] }));
|
|
2108
|
+
} }), result && (_jsx(Banner, { status: probeStatus(result), title: probeTitle(result, tool, inProject), description: probeDetails(result) }))] }));
|
|
2076
2109
|
}
|
|
2077
2110
|
/** The tool types offered: an agent tool only where there are agents to run. */
|
|
2078
2111
|
function toolTypeSegments(workspace) {
|
|
@@ -2150,7 +2183,7 @@ function StubSection({ tool, set }) {
|
|
|
2150
2183
|
}
|
|
2151
2184
|
/** The static headers HTTP and MCP tools both send. */
|
|
2152
2185
|
function HeadersRow({ tool, set }) {
|
|
2153
|
-
return (_jsx(
|
|
2186
|
+
return (_jsx(EntriesRow, { label: "Headers", noun: "Header", path: "registerTool.headers", field: "headersJson", value: tool.headersJson ?? '', namePlaceholder: "Accept", valuePlaceholder: "application/json", onChange: (headersJson) => {
|
|
2154
2187
|
set({ headersJson });
|
|
2155
2188
|
} }));
|
|
2156
2189
|
}
|
|
@@ -2243,18 +2276,9 @@ function AuthSection({ tool, set }) {
|
|
|
2243
2276
|
set({ authType: next });
|
|
2244
2277
|
} }), authType !== 'none' && _jsx(AuthCredentialRows, { tool: tool, authType: authType, set: set }), authType === 'oauth2' && _jsx(OAuthRows, { tool: tool, set: set })] }));
|
|
2245
2278
|
}
|
|
2246
|
-
/** What the studio does about a tool that writes, when that is not what Permission says. */
|
|
2247
|
-
function studioAskNote(asks, tool) {
|
|
2248
|
-
if (asks.asked.includes(tool))
|
|
2249
|
-
return 'In the studio this tool asks before every run, because it writes. Your application runs it as Permission says.';
|
|
2250
|
-
if (asks.inside.includes(tool))
|
|
2251
|
-
return 'This tool writes, and the studio cannot make it ask: a called agent runs it, and a question inside a called agent has no one to answer it. The call to that agent asks instead.';
|
|
2252
|
-
return undefined;
|
|
2253
|
-
}
|
|
2254
2279
|
/** Who may call the tool, whether it asks first, when it loads and on which paths. */
|
|
2255
2280
|
function PolicySection({ draft, tool, set, }) {
|
|
2256
|
-
|
|
2257
|
-
return (_jsxs(InspectorSection, { title: "Policy", note: note, children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
|
|
2281
|
+
return (_jsxs(InspectorSection, { title: "Policy", children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
|
|
2258
2282
|
set({ access });
|
|
2259
2283
|
} }), _jsx(SegmentedRow, { label: "Permission", path: "registerTool.permission", field: "permission", value: tool.permission, segments: PERMISSION_SEGMENTS, onChange: (permission) => {
|
|
2260
2284
|
set({ permission });
|
package/ui/studio-compare.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type TheoremChatHandle } from '@theoremjs/react/ui';
|
|
2
|
-
import { type TraceFeed } from '@theoremjs/web/client';
|
|
3
|
-
import { type ReactNode, type Ref } from 'react';
|
|
1
|
+
import { TheoremChat, type TheoremChatHandle } from '@theoremjs/react/ui';
|
|
2
|
+
import { type StatedTurn, type TraceFeed } from '@theoremjs/web/client';
|
|
3
|
+
import { type ComponentProps, type ReactNode, type Ref } from 'react';
|
|
4
4
|
import { type StudioWorkspace } from '../mod.ts';
|
|
5
5
|
import type { EditedAnswer, SaveRefusal } from '../server/save-wire.ts';
|
|
6
6
|
import { type ProjectSession } from './lib/studio-project.ts';
|
|
@@ -18,6 +18,11 @@ export declare function useEditedLoad(project: ProjectSession, edits: StudioWork
|
|
|
18
18
|
* standing under the refusal, so the edited side keeps what it showed; with no edits, none.
|
|
19
19
|
*/
|
|
20
20
|
export declare function useLoadedStamp(answer: EditedAnswer | undefined): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* What the edited side states. While edits load it still runs the last load, which refuses a
|
|
23
|
+
* condition only the new edits declare, so it states what that load declares.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useLoadedStated(stated: StatedTurn | undefined, isLoaded: boolean): StatedTurn | undefined;
|
|
21
26
|
/** Whether the builder put the files' side away: the edits then run alone. */
|
|
22
27
|
export declare function useSavedHidden(): boolean;
|
|
23
28
|
/**
|
|
@@ -40,7 +45,8 @@ export declare function SavedSide({ isCompared, children, }: {
|
|
|
40
45
|
isCompared?: boolean;
|
|
41
46
|
children: ReactNode;
|
|
42
47
|
}): import("react").JSX.Element;
|
|
43
|
-
export
|
|
48
|
+
export /** What a chat resumes and starts with; the page keeps its conversation through these. */ type ChatStart = Pick<ComponentProps<typeof TheoremChat>, 'conversation' | 'conversationView' | 'initialText' | 'initialFiles' | 'initialVoice' | 'initialPending' | 'onConversationChange'>;
|
|
49
|
+
export interface ProjectChatProps extends ChatStart {
|
|
44
50
|
project: ProjectSession;
|
|
45
51
|
/** The id of the profile the page chats with, as its edits name it. */
|
|
46
52
|
profileId: string;
|
|
@@ -54,6 +60,10 @@ export interface ProjectChatProps {
|
|
|
54
60
|
chatRef?: Ref<TheoremChatHandle>;
|
|
55
61
|
/** The value the page picked for each slot. */
|
|
56
62
|
slots?: Record<string, string>;
|
|
63
|
+
/** What the edited side states, of the profile the edits make. */
|
|
64
|
+
stated?: StatedTurn;
|
|
65
|
+
/** What the files' side states, of the profile the files hold. */
|
|
66
|
+
savedStated?: StatedTurn;
|
|
57
67
|
/** What the page tells the agent. */
|
|
58
68
|
context?: unknown;
|
|
59
69
|
}
|
package/ui/studio-compare.js
CHANGED
|
@@ -13,7 +13,7 @@ import { IconInputAi, IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand
|
|
|
13
13
|
import { createComposerPendingMessage, orderComposerPendingMessages, removeComposerPendingMessage, } from '@theoremjs/agents/interface';
|
|
14
14
|
import { ChatComposerBar, DEFAULT_CHAT_MAX_WIDTH, generationOptions, InPlace, PaneFailure, PaneLoading, TheoremChat, } from '@theoremjs/react/ui';
|
|
15
15
|
import { clientFailure, composerFieldsFromDraft, composerHasPayload, createHttpTransport, createTraceFeed, encodeComposerDraft, } from '@theoremjs/web/client';
|
|
16
|
-
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
16
|
+
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
17
17
|
import { atStart } from "../mod.js";
|
|
18
18
|
import { useActingAs } from "./lib/acting-as.js";
|
|
19
19
|
import { runsAsConversation } from "./lib/conversation-types.js";
|
|
@@ -75,6 +75,17 @@ export function useLoadedStamp(answer) {
|
|
|
75
75
|
setLoaded(now);
|
|
76
76
|
return now;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* What the edited side states. While edits load it still runs the last load, which refuses a
|
|
80
|
+
* condition only the new edits declare, so it states what that load declares.
|
|
81
|
+
*/
|
|
82
|
+
export function useLoadedStated(stated, isLoaded) {
|
|
83
|
+
const [loaded, setLoaded] = useState(stated);
|
|
84
|
+
const now = isLoaded ? stated : loaded;
|
|
85
|
+
if (JSON.stringify(now) !== JSON.stringify(loaded))
|
|
86
|
+
setLoaded(now);
|
|
87
|
+
return now;
|
|
88
|
+
}
|
|
78
89
|
/** A side's chat as it stands, and as it changes. Null until the side is mounted. */
|
|
79
90
|
function useSideState(chat) {
|
|
80
91
|
const subscribe = useCallback((listener) => (chat ? chat.subscribe(listener) : () => { }), [chat]);
|
|
@@ -397,13 +408,20 @@ function whyNot(failed, isReady) {
|
|
|
397
408
|
* is replaced, starts from what was said. Every load seals with the studio run's one key, so the
|
|
398
409
|
* edited side opens the files' side's ref and goes on from there on its own.
|
|
399
410
|
*/
|
|
400
|
-
function useConversations(isEditing) {
|
|
401
|
-
const conversations = useRef({});
|
|
411
|
+
function useConversations(isEditing, resumed, report) {
|
|
412
|
+
const conversations = useRef({ saved: resumed });
|
|
402
413
|
if (!isEditing)
|
|
403
414
|
conversations.current.edited = undefined;
|
|
415
|
+
const reporting = useRef({ isEditing, report });
|
|
416
|
+
useLayoutEffect(() => {
|
|
417
|
+
reporting.current = { isEditing, report };
|
|
418
|
+
});
|
|
404
419
|
const [onChange] = useState(() => {
|
|
405
420
|
const change = (side) => (ref) => {
|
|
406
421
|
conversations.current[side] = ref;
|
|
422
|
+
// invariant: the page keeps one conversation, so a reload resumes what was shown.
|
|
423
|
+
if (side === 'edited' || !reporting.current.isEditing)
|
|
424
|
+
reporting.current.report?.(ref);
|
|
407
425
|
};
|
|
408
426
|
return { saved: change('saved'), edited: change('edited') };
|
|
409
427
|
});
|
|
@@ -448,7 +466,7 @@ export function EditedSide({ refused, isLoading, hasSaved, actions, children, })
|
|
|
448
466
|
} })), children: [_jsx(InPlace, { view: refused ? _jsx(NotRunning, { refusal: refused, actions: actions }) : null, children: children }), isLoading && _jsx(PaneLoading, { label: "Loading your edits" })] }));
|
|
449
467
|
}
|
|
450
468
|
/** What the comparison shows now: which sides there are, and what each one runs. */
|
|
451
|
-
function useComparison({ project, profileId, tested, note, traces }) {
|
|
469
|
+
function useComparison({ project, profileId, tested, note, traces, conversation, onConversationChange, }) {
|
|
452
470
|
const edits = useMemo(() => unsavedEdits(tested, project.profiles), [tested, project.profiles]);
|
|
453
471
|
const pair = usePair();
|
|
454
472
|
const isBusy = pair.busy.length > 0;
|
|
@@ -459,7 +477,7 @@ function useComparison({ project, profileId, tested, note, traces }) {
|
|
|
459
477
|
// A profile the edits made a chat is another type in the files, which a chat cannot talk to.
|
|
460
478
|
const chatsInFiles = !saved || runsAsConversation(saved.profileType);
|
|
461
479
|
const inFiles = !isEditing || (chatsInFiles && (answer?.saved ?? project.profiles).includes(ids.saved));
|
|
462
|
-
const { conversations, onChange } = useConversations(isEditing);
|
|
480
|
+
const { conversations, onChange } = useConversations(isEditing, conversation, onConversationChange);
|
|
463
481
|
const stamp = useLoadedStamp(answer);
|
|
464
482
|
const transports = useTransports(project, ids, stamp, { note, traces });
|
|
465
483
|
const refused = answer && !answer.ok && !pending ? answer : undefined;
|
|
@@ -482,8 +500,11 @@ function useComparison({ project, profileId, tested, note, traces }) {
|
|
|
482
500
|
* to the one side otherwise. It answers with what the edits said, and its controller is theirs.
|
|
483
501
|
*/
|
|
484
502
|
function useChatHandle(chatRef, pair, only, canSendBoth, sharedInput) {
|
|
485
|
-
const { send, stop, handles } = pair;
|
|
486
|
-
|
|
503
|
+
const { send, stop, handles, chats } = pair;
|
|
504
|
+
const controller = chats[only ?? 'edited'];
|
|
505
|
+
useImperativeHandle(
|
|
506
|
+
// invariant: a screen holds this handle only while the chat behind it is open.
|
|
507
|
+
chatRef, () => controller && {
|
|
487
508
|
send: (text, options) => {
|
|
488
509
|
if (only)
|
|
489
510
|
return handles.current[only]?.send(text, options) ?? Promise.resolve(null);
|
|
@@ -498,13 +519,22 @@ function useChatHandle(chatRef, pair, only, canSendBoth, sharedInput) {
|
|
|
498
519
|
else
|
|
499
520
|
sharedInput.current?.focus();
|
|
500
521
|
},
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
522
|
+
controller,
|
|
523
|
+
}, [only, canSendBoth, send, stop, handles, sharedInput, controller]);
|
|
524
|
+
}
|
|
525
|
+
/** The one composer under a split, or why it waits. */
|
|
526
|
+
function SharedSlot({ sides, edited, inputRef, handle, why, }) {
|
|
527
|
+
if (edited)
|
|
528
|
+
return _jsx(SharedComposer, { sides: sides, edited: edited, inputRef: inputRef });
|
|
529
|
+
return _jsx(WaitingComposer, { handle: handle, why: why ?? 'Loading your edits' });
|
|
530
|
+
}
|
|
531
|
+
/** The sides whose chats have opened. */
|
|
532
|
+
function openSides(pair) {
|
|
533
|
+
return SIDES.flatMap((side) => {
|
|
534
|
+
const chat = pair.chats[side];
|
|
535
|
+
const state = pair.states[side];
|
|
536
|
+
return chat && state ? [{ side, chat, state }] : [];
|
|
537
|
+
});
|
|
508
538
|
}
|
|
509
539
|
/**
|
|
510
540
|
* A project's text or image profile, run by the studio's local server. While the builder has
|
|
@@ -512,20 +542,18 @@ function useChatHandle(chatRef, pair, only, canSendBoth, sharedInput) {
|
|
|
512
542
|
* the files with the edits laid over them.
|
|
513
543
|
*/
|
|
514
544
|
export function ProjectChat(props) {
|
|
515
|
-
const { profileId, trace, className, chatRef, slots, context } = props;
|
|
545
|
+
const { profileId, trace, className, chatRef, slots, stated, savedStated, context } = props;
|
|
546
|
+
const { conversationView, initialText, initialFiles, initialVoice, initialPending } = props;
|
|
516
547
|
const view = useComparison(props);
|
|
517
548
|
const { pair, isBusy, transports, refused, isReady } = view;
|
|
549
|
+
const loadedStated = useLoadedStated(stated, isReady);
|
|
518
550
|
const isSavedHidden = useSavedHidden();
|
|
519
551
|
const showsSaved = view.inFiles && !(view.isEditing && isSavedHidden);
|
|
520
552
|
const isShared = view.isShared && showsSaved;
|
|
521
553
|
const only = isShared ? undefined : showsSaved ? 'saved' : 'edited';
|
|
522
554
|
const sharedInput = useRef(null);
|
|
523
555
|
useChatHandle(chatRef, pair, only, !isBusy && isReady, sharedInput);
|
|
524
|
-
const shared =
|
|
525
|
-
const chat = pair.chats[side];
|
|
526
|
-
const state = pair.states[side];
|
|
527
|
-
return chat && state ? [{ side, chat, state }] : [];
|
|
528
|
-
});
|
|
556
|
+
const shared = openSides(pair);
|
|
529
557
|
const common = {
|
|
530
558
|
detectCodeLanguage: true,
|
|
531
559
|
labels: STUDIO_LABELS,
|
|
@@ -534,13 +562,19 @@ export function ProjectChat(props) {
|
|
|
534
562
|
slots,
|
|
535
563
|
context,
|
|
536
564
|
composer: !isShared,
|
|
565
|
+
// A greeting says where to start; both sides start at the one composer under them.
|
|
566
|
+
emptyState: isShared ? null : undefined,
|
|
567
|
+
conversationView,
|
|
568
|
+
initialText,
|
|
569
|
+
initialFiles,
|
|
570
|
+
initialVoice,
|
|
571
|
+
initialPending,
|
|
537
572
|
};
|
|
538
|
-
return (_jsxs(VStack, { height: "100%", children: [_jsx(StackItem, { size: "fill", children: _jsxs(HStack, { height: "100%", children: [_jsx(SavedSlot, { isShown: showsSaved, hasDivider: view.isShared, children: view.inFiles && (_jsx(SavedSide, { isCompared: view.isEditing, children: _jsx(TheoremChat, { ...common, transport: transports.saved,
|
|
573
|
+
return (_jsxs(VStack, { height: "100%", children: [_jsx(StackItem, { size: "fill", children: _jsxs(HStack, { height: "100%", children: [_jsx(SavedSlot, { isShown: showsSaved, hasDivider: view.isShared, children: view.inFiles && (_jsx(SavedSide, { isCompared: view.isEditing, children: _jsx(TheoremChat, { ...common, stated: savedStated, transport: transports.saved,
|
|
539
574
|
// A side that comes back starts from what it had said.
|
|
540
|
-
conversation: view.conversations.current.saved, onConversationChange: view.onChange.saved, chatRef: pair.refs.saved }) })) }), view.isEditing && (_jsx("div", { className: "studio-edited-slot", children: _jsx(EditedSide, { refused: refused, isLoading: !transports.edited && !refused, hasSaved: view.inFiles, children: transports.edited && (_jsx(TheoremChat, { ...common,
|
|
575
|
+
conversation: view.conversations.current.saved, onConversationChange: view.onChange.saved, chatRef: pair.refs.saved }) })) }), view.isEditing && (_jsx("div", { className: "studio-edited-slot", children: _jsx(EditedSide, { refused: refused, isLoading: !transports.edited && !refused, hasSaved: view.inFiles, children: transports.edited && (_jsx(TheoremChat, { ...common, stated: loadedStated,
|
|
541
576
|
// A new load is a new transport: the chat reads it in place and keeps its transcript.
|
|
542
577
|
transport: transports.edited, conversation: view.conversations.current.edited ?? view.conversations.current.saved, onConversationChange: view.onChange.edited,
|
|
543
578
|
// Under a refusal nothing reaches it: the edits it ran are not loaded.
|
|
544
|
-
chatRef: refused ? undefined : pair.refs.edited })) }) }, "edited"))] }) }), isShared &&
|
|
545
|
-
(isReady && pair.states.edited ? (_jsx(SharedComposer, { sides: shared, edited: pair.states.edited, inputRef: sharedInput })) : (_jsx(WaitingComposer, { handle: profileId, why: whyNot(refused !== undefined, isReady) ?? 'Loading your edits' })))] }));
|
|
579
|
+
chatRef: refused ? undefined : pair.refs.edited })) }) }, "edited"))] }) }), isShared && (_jsx(SharedSlot, { sides: shared, edited: isReady ? (pair.states.edited ?? undefined) : undefined, inputRef: sharedInput, handle: profileId, why: whyNot(refused !== undefined, isReady) }))] }));
|
|
546
580
|
}
|
package/ui/studio-live.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type LiveRunnerProps } from '@theoremjs/react/live';
|
|
|
2
2
|
import { type StudioBrowserRuntime } from '../browser.ts';
|
|
3
3
|
import { type StudioRunPayload } from '../mod.ts';
|
|
4
4
|
/** What a live call is run with, wherever it runs. */
|
|
5
|
-
export type StudioLiveProps = Pick<LiveRunnerProps, 'trace' | 'slots' | 'context'> & {
|
|
5
|
+
export type StudioLiveProps = Pick<LiveRunnerProps, 'trace' | 'slots' | 'stated' | 'context'> & {
|
|
6
6
|
payload: StudioRunPayload;
|
|
7
7
|
/** Called as each call starts. */
|
|
8
8
|
note: () => void;
|
package/ui/studio-live.js
CHANGED
|
@@ -3,6 +3,8 @@ import { LiveRunner } from '@theoremjs/react/live';
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { browserStudioLiveConnection } from "../browser.js";
|
|
5
5
|
import { studioInterface, studioLiveConnection, studioPageTools, } from "../mod.js";
|
|
6
|
+
import { useActingAs } from "./lib/acting-as.js";
|
|
7
|
+
import { liveSocketAddress } from "./lib/project-traces.js";
|
|
6
8
|
import { STUDIO_LABELS } from "./lib/studio-labels.js";
|
|
7
9
|
/** A live profile's call: in the browser's runtime when there is one, else through the studio's server. */
|
|
8
10
|
export function StudioLive({ runtime, ...props }) {
|
|
@@ -11,9 +13,12 @@ export function StudioLive({ runtime, ...props }) {
|
|
|
11
13
|
}
|
|
12
14
|
/** A project's live profile: the call runs in the project, through the studio's local server. */
|
|
13
15
|
export function ProjectLive({ endpoint, ...props }) {
|
|
14
|
-
|
|
16
|
+
const { actingAs } = useActingAs();
|
|
17
|
+
return (_jsx(LiveView, { ...props, connect: () => ({
|
|
18
|
+
createSocket: () => new WebSocket(liveSocketAddress(endpoint, actingAs)),
|
|
19
|
+
}) }));
|
|
15
20
|
}
|
|
16
|
-
function LiveView({ payload, note, connect, trace, slots, context, }) {
|
|
21
|
+
function LiveView({ payload, note, connect, trace, slots, stated, context, }) {
|
|
17
22
|
const iface = useMemo(() => studioInterface(payload), [payload]);
|
|
18
23
|
/** The studio's page answers each page tool with the tool's stub. */
|
|
19
24
|
const pageTools = useMemo(() => studioPageTools(payload), [payload]);
|
|
@@ -22,5 +27,5 @@ function LiveView({ payload, note, connect, trace, slots, context, }) {
|
|
|
22
27
|
return (_jsx(LiveRunner, { labels: STUDIO_LABELS, iface: iface, connection: () => {
|
|
23
28
|
note();
|
|
24
29
|
return connect();
|
|
25
|
-
}, trace: trace, slots: slots, context: context, pageTools: pageTools }));
|
|
30
|
+
}, trace: trace, slots: slots, stated: stated, context: context, pageTools: pageTools }));
|
|
26
31
|
}
|
package/ui/studio-runner.d.ts
CHANGED
|
@@ -15,8 +15,7 @@ export interface StudioRunnerProps {
|
|
|
15
15
|
/** Called on each request the conversation sends: a turn, call, decision, or live session. */
|
|
16
16
|
onActivity?: () => void;
|
|
17
17
|
/**
|
|
18
|
-
* The ref of a chat conversation to resume, as `onConversationChange` reported it
|
|
19
|
-
* image agents run in the page). A project's chat is not resumed: its key is the run's.
|
|
18
|
+
* The ref of a chat conversation to resume, as `onConversationChange` reported it.
|
|
20
19
|
*/
|
|
21
20
|
conversation?: ChatProps['conversation'];
|
|
22
21
|
/** The conversation under `conversation` as the server showed it, drawn at once. */
|
|
@@ -33,6 +32,8 @@ export interface StudioRunnerProps {
|
|
|
33
32
|
chatRef?: ChatProps['chatRef'];
|
|
34
33
|
/** The value the page picked for each slot, for a chat's turns and a call's start. */
|
|
35
34
|
slots?: ChatProps['slots'];
|
|
35
|
+
/** What a run of a profile states: it declares its own conditions. */
|
|
36
|
+
statedOf?: (of: StudioRunPayload) => ChatProps['stated'];
|
|
36
37
|
/** What the page tells the agent. */
|
|
37
38
|
context?: ChatProps['context'];
|
|
38
39
|
/**
|