@theoremjs/studio 0.3.4-next.757.gde44a4d → 0.3.4-next.761.g22f8dca

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/compile.d.ts +3 -3
  2. package/compile.js +70 -101
  3. package/cookbooks/catalog.js +14 -28
  4. package/draft.d.ts +30 -28
  5. package/draft.js +26 -12
  6. package/guardrail-probe.js +1 -30
  7. package/mod.d.ts +2 -2
  8. package/mod.js +2 -2
  9. package/package.json +4 -4
  10. package/page/assets/{ConsoleFrame-D309UtSL.js → ConsoleFrame-BML2qu-M.js} +1 -1
  11. package/page/assets/{MenuBottomSheet-CVBLnUiO.js → MenuBottomSheet-CUd8PJUL.js} +1 -1
  12. package/page/assets/{SchemaFields-muOTQM8x.js → SchemaFields-BAqgDS0V.js} +1 -1
  13. package/page/assets/{ToolResultCharts-Bhesjbc4.js → ToolResultCharts-B89bOlhx.js} +1 -1
  14. package/page/assets/{Toolbar-t4I6MDV_.js → Toolbar-IjJyRVuq.js} +1 -1
  15. package/page/assets/{TraceInspector-BqEGN_46.js → TraceInspector-BPuA0rJm.js} +1 -1
  16. package/page/assets/{TraceOverview-DLEqvRF2.js → TraceOverview-D-fMveFI.js} +1 -1
  17. package/page/assets/{_virtual_studio-type-sources-Cc4WAdgD.js → _virtual_studio-type-sources-_88V0ngH.js} +37 -44
  18. package/page/assets/browser-connection-C1_PJcSQ.js +1 -0
  19. package/page/assets/browser-engine-C8QugF1C.js +16 -0
  20. package/page/assets/browser-transport-Dna_HxBt.js +45 -0
  21. package/page/assets/compile-BV0Yh4CT.js +2 -0
  22. package/page/assets/{encode-files-CeZxxjYd.js → encode-files-CCet4LKE.js} +1 -1
  23. package/page/assets/{export-agent-CYZqQ4ll.js → export-agent-C9RKqF8V.js} +8 -8
  24. package/page/assets/{guardrail-tester-D-_i4Zuj.js → guardrail-tester-B_NNaWwk.js} +1 -1
  25. package/page/assets/index-BYDlXF8Q.css +1 -0
  26. package/page/assets/{index-DuTrjzLN.js → index-DDOBYjLr.js} +73 -73
  27. package/page/assets/live-messages-tG47aB12.js +1 -0
  28. package/page/assets/{prompt-row-CIxkqX9Q.js → prompt-row-DmXTmPM0.js} +2 -2
  29. package/page/assets/reader-SzTjS7rw.js +5 -0
  30. package/page/assets/{registry-DP0ArymS.js → registry-BrmnEhgs.js} +1 -1
  31. package/page/assets/schema-BztznKB7.js +3 -0
  32. package/page/assets/{shaped-data-DCfLI4gb.js → shaped-data-D15FDUcH.js} +3 -3
  33. package/page/assets/{stub-REBz-ZC7.js → stub-CJG-5zBe.js} +1 -1
  34. package/page/assets/studio-code-pane-DrdLqe75.js +10 -0
  35. package/page/assets/{studio-console-DHgwXKne.js → studio-console-Qv_3jkIz.js} +1 -1
  36. package/page/assets/{studio-decision-B_EdxnvG.js → studio-decision-CX3MLpTH.js} +1 -1
  37. package/page/assets/{studio-embedding-mZIx4qHD.js → studio-embedding-CW_pjRjJ.js} +1 -1
  38. package/page/assets/{studio-host-console-BmB0sSsX.js → studio-host-console-B7Mx-m0f.js} +2 -2
  39. package/page/assets/{studio-labels-BRouZt4M.js → studio-labels-B_pBoFqS.js} +1 -1
  40. package/page/assets/studio-live-DdMC-L2A.js +5 -0
  41. package/page/assets/{studio-map-8aIk_pdY.js → studio-map-Dm7XWVyE.js} +1 -1
  42. package/page/assets/{studio-trace-replay-BaF2UAqT.js → studio-trace-replay-DHmsgLaT.js} +1 -1
  43. package/page/assets/{studio-type-checker-JZuu4iVI.js → studio-type-checker-o2Q6t4mP.js} +1 -1
  44. package/page/assets/{tool-schema-BwaPiLtT.js → tool-schema-D26IAEC3.js} +1 -1
  45. package/page/assets/trace-record-jocyYEPa.js +1 -0
  46. package/page/assets/tree-BCzsUTaF.js +3 -0
  47. package/page/assets/{turn-client-B3jV7UKH.js → turn-client-eM8VIbMd.js} +1 -1
  48. package/page/assets/{types-BDx4pnrt.js → types-CfC3vRXO.js} +1 -1
  49. package/page/assets/{use-one-call-BKLi6fk_.js → use-one-call-CRLKviQ-.js} +1 -1
  50. package/page/assets/{workspace-B6d08n7C.js → workspace-3igDw3Tv.js} +1 -1
  51. package/page/index.html +17 -17
  52. package/prompt-doc.d.ts +1 -1
  53. package/prompt-doc.js +2 -2
  54. package/read-source.js +26 -39
  55. package/section-notes.d.ts +1 -2
  56. package/section-notes.js +1 -2
  57. package/system-markup.d.ts +1 -1
  58. package/system-markup.js +1 -1
  59. package/ui/lib/export-agent.js +9 -26
  60. package/ui/lib/studio-page.d.ts +9 -16
  61. package/ui/lib/studio-page.js +28 -38
  62. package/ui/profile-editor.js +48 -104
  63. package/ui/prompt-editor.d.ts +1 -1
  64. package/ui/prompt-editor.js +11 -11
  65. package/ui/prompt-line-node.d.ts +5 -5
  66. package/ui/prompt-line-node.js +9 -9
  67. package/ui/prompt-row.d.ts +3 -3
  68. package/ui/prompt-row.js +3 -3
  69. package/ui/studio-compare.d.ts +4 -2
  70. package/ui/studio-compare.js +6 -5
  71. package/ui/studio-live.d.ts +1 -1
  72. package/ui/studio-live.js +2 -2
  73. package/ui/studio-runner.d.ts +4 -3
  74. package/ui/studio-runner.js +9 -9
  75. package/ui/studio-screen.js +5 -2
  76. package/ui/studio.css +3 -3
  77. package/page/assets/browser-connection-159CdeHX.js +0 -1
  78. package/page/assets/browser-engine-Fi7MROTb.js +0 -16
  79. package/page/assets/browser-transport-C_sHZVPa.js +0 -45
  80. package/page/assets/compile-iB2CAmRL.js +0 -2
  81. package/page/assets/index-DakRjE8R.css +0 -1
  82. package/page/assets/live-messages-D-SPyR3e.js +0 -1
  83. package/page/assets/reader-DtOL_I1x.js +0 -5
  84. package/page/assets/schema-Cv4HAfBT.js +0 -3
  85. package/page/assets/studio-code-pane-DEBuOivy.js +0 -10
  86. package/page/assets/studio-live-Cy09vyLv.js +0 -5
  87. package/page/assets/trace-record--uEnDt_D.js +0 -1
  88. package/page/assets/tree-CL4ETBd5.js +0 -3
  89. package/slot-values.d.ts +0 -2
  90. package/slot-values.js +0 -22
@@ -28,13 +28,13 @@ import { ATTACHMENT_ACCEPT_MIMES, CONTINUE_STOP_KINDS, fieldMeta, HTTP_METHODS,
28
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';
29
29
  import { MODEL_SELECT_MIN_MODELS } from '@theoremjs/agents/interface';
30
30
  import { createContext, lazy, Suspense, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
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";
31
+ 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, loadTierWarning, MODEL_LIMITS, modelRoute, modelSlots, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOption, newOwnDetector, newPattern, newToolSpec, nextAccept, onStudioLocal, optionAt, optionChoices, 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";
32
32
  import { SECTION_HINTS } from "../section-notes.js";
33
33
  import { AddProviderButton } from "./add-provider.js";
34
34
  import { IconGoogle, IconOpenAi, IconOpenRouter, IconTypeSafe } from "./brand-icons.js";
35
35
  import { ChoiceRow, EntriesRow, InspectorGroupTitle, InspectorRow, InspectorSection, LABEL_COLUMN, ListRow, NamesInput, NamesRow, NumberRow, OriginLine, OwnField, SegmentedRow, SetInCode, SliderRow, SwitchRow, TextAreaRow, TextRow, WideRow, } from "./inspector.js";
36
36
  import { GuardrailTest, LeavePage, ListBadges, LocalConnection, NodeIssues, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.js";
37
- import { CONTEXT_PLACEHOLDER, contextErrorOf, draftSlots, usePageValues, } from "./lib/studio-page.js";
37
+ import { CONTEXT_PLACEHOLDER, contextErrorOf, usePageValues } from "./lib/studio-page.js";
38
38
  import { useProject } from "./lib/studio-project.js";
39
39
  import { setToolCredential, subscribeToolCredentials, toolCredential, } from "./lib/tool-credentials.js";
40
40
  import { runToolProbe } from "./lib/tool-probe.js";
@@ -177,45 +177,56 @@ function withNewSections(before, after) {
177
177
  .filter((facet) => !leftOut.has(facet))
178
178
  .reduce(includeFacet, after);
179
179
  }
180
- function SystemPromptSection({ identity, set, }) {
181
- return (_jsxs(InspectorSection, { title: "System prompt", hint: SECTION_HINTS.system, children: [_jsx(ConditionRows, { identity: identity, set: set }), _jsx(Suspense, { fallback: null, children: _jsx(PromptRow, { value: identity.system, conditions: identity.conditions, rows: PROMPT_ROWS, placeholder: fieldMeta('identity.system')?.unset, onChange: (system) => {
180
+ function SystemPromptSection({ identity, canShowOptions, set, }) {
181
+ return (_jsxs(InspectorSection, { title: "System prompt", hint: SECTION_HINTS.system, children: [_jsx(OptionRows, { identity: identity, canShow: canShowOptions, set: set }), _jsx(Suspense, { fallback: null, children: _jsx(PromptRow, { value: identity.system, options: identity.options, rows: PROMPT_ROWS, placeholder: fieldMeta('identity.system')?.unset, onChange: (system) => {
182
182
  set({ system });
183
183
  } }) })] }));
184
184
  }
185
- /** The value a condition states: the page's pick while the condition still takes it, or its first. */
186
- const statedValue = (allowed, picked) => allowed?.find((value) => value === picked) ?? allowed?.[0];
185
+ /** The value an option states: the page's pick while the option still takes it, or its first. */
186
+ const statedValue = (option, picked) => {
187
+ const values = option.choices.map(({ value }) => value);
188
+ return values.find((value) => value === picked) ?? values[0];
189
+ };
187
190
  const VALUE_HINT = {
188
191
  marked: 'The studio states this value.',
189
192
  other: 'Press to state this value.',
190
193
  };
191
- /** One condition on one row: its name, the values it takes with the one the chat states marked, and its remove button. */
192
- function ConditionRow({ condition, at, stated, onState, onChange, onRemove, }) {
193
- const status = useFieldStatus()('conditions', at);
194
- const row = `Condition ${String(at + 1)}`;
195
- return (_jsxs(HStack, { gap: 1, vAlign: "start", className: "condition-row", 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) => {
196
- onChange({ name });
197
- } }) }) }) }), _jsx(StackItem, { size: "fill", children: _jsx(NamesInput, { label: `${row} values`, value: condition.values, placeholder: "free", overflow: "none", marked: stated, onMark: onState, markHint: VALUE_HINT, onChange: (values) => {
198
- onChange({ values });
199
- } }) }), _jsx(IconButton, { label: `Remove ${row.toLowerCase()}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: onRemove })] }));
200
- }
201
- /** Every condition, one to a row. The value marked on each is the one the page states, kept in this tab. */
202
- function ConditionRows({ identity, set, }) {
203
- const { conditions } = identity;
194
+ /** What a person reads of a shown option: its label and a line on each value. */
195
+ function OptionShownRows({ option, onChange, }) {
196
+ return (_jsxs(_Fragment, { children: [_jsx(TextRow, { label: "Label", path: "inputs.options.*.label", value: option.label, placeholder: option.name.trim() || undefined, onChange: (label) => {
197
+ onChange({ label });
198
+ } }), option.choices.map((choice) => (_jsx(TextRow, { label: choice.value, path: "inputs.options.*.choices.*.description", value: choice.description, placeholder: "What the page says of it", onChange: (description) => {
199
+ onChange({
200
+ choices: option.choices.map((each) => each.key === choice.key ? { ...each, description } : each),
201
+ });
202
+ } }, choice.key)))] }));
203
+ }
204
+ /** One option on one row: its name, its values with the one the chat states marked, whether a person picks it, and its remove button. */
205
+ function OptionRow({ option, at, canShow, stated, onState, onChange, onRemove, }) {
206
+ const status = useFieldStatus()('options', at);
207
+ const row = `Option ${String(at + 1)}`;
208
+ return (_jsxs(VStack, { gap: 1, children: [_jsxs(HStack, { gap: 1, vAlign: "start", className: "option-row", 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: option.name, placeholder: "plan", onChange: (name) => {
209
+ onChange({ name });
210
+ } }) }) }) }), _jsx(StackItem, { size: "fill", children: _jsx(NamesInput, { label: `${row} values`, value: option.choices.map(({ value }) => value), placeholder: "free", overflow: "none", marked: stated, onMark: onState, markHint: VALUE_HINT, onChange: (values) => {
211
+ onChange({ choices: optionChoices(values, option.choices) });
212
+ } }) }), _jsx(IconButton, { label: `Remove ${row.toLowerCase()}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: onRemove })] }), canShow && (_jsx(SwitchRow, { label: "Shown in chat", path: "inputs.options", field: "options", value: option.isShownInChat, onChange: (isShownInChat) => {
213
+ onChange({ isShownInChat });
214
+ } })), option.isShownInChat && _jsx(OptionShownRows, { option: option, onChange: onChange })] }));
215
+ }
216
+ /** Every option, one to a row. The value marked on each is the one the page states, kept in this tab. */
217
+ function OptionRows({ identity, canShow, set, }) {
218
+ const { options } = identity;
204
219
  const [values, setValues] = usePageValues(useContext(WorkspaceContext)?.self ?? '');
205
- const named = draftConditions(conditions);
206
- return (_jsx(WideRow, { label: "Conditions", path: "identity.conditions", isRequired: false, hasIssue: false, children: _jsxs(OwnField, { path: "identity.conditions", children: [conditions.map((condition, at) => (_jsx(ConditionRow, { condition: condition, at: at, stated: statedValue(named[condition.name], values.conditions[condition.name]), onState: (value) => {
207
- setValues({
208
- ...values,
209
- conditions: { ...values.conditions, [condition.name]: value },
210
- });
211
- }, onChange: (change) => {
212
- set({
213
- conditions: conditions.map((each) => each.key === condition.key ? { ...each, ...change } : each),
214
- });
215
- }, onRemove: () => {
216
- set({ conditions: conditions.filter((each) => each.key !== condition.key) });
217
- } }, condition.key))), _jsx(HStack, { children: _jsx(Button, { label: "Add condition", tooltip: "A fact each turn states, which lines of the prompt can depend on", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
218
- set({ conditions: [...conditions, newCondition()] });
220
+ return (_jsx(WideRow, { label: "Options", path: "identity.options", isRequired: false, hasIssue: false, children: _jsxs(OwnField, { path: "identity.options", children: [options.map((option, at) => (_jsx(OwnField, { path: option.isShownInChat ? 'inputs.options' : 'identity.options', children: _jsx(OptionRow, { option: option, at: at, canShow: canShow, stated: statedValue(option, values.options[option.name]), onState: (value) => {
221
+ setValues({ ...values, options: { ...values.options, [option.name]: value } });
222
+ }, onChange: (change) => {
223
+ set({
224
+ options: options.map((each) => each.key === option.key ? { ...each, ...change } : each),
225
+ });
226
+ }, onRemove: () => {
227
+ set({ options: options.filter((each) => each.key !== option.key) });
228
+ } }) }, option.key))), _jsx(HStack, { children: _jsx(Button, { label: "Add option", tooltip: "A named value that lines of the prompt can read and print", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
229
+ set({ options: [...options, newOption()] });
219
230
  } }) })] }) }));
220
231
  }
221
232
  function IdentityEditor({ draft, setDraft }) {
@@ -232,7 +243,7 @@ function IdentityEditor({ draft, setDraft }) {
232
243
  } }))] }), identity.profileType !== 'speech' &&
233
244
  identity.profileType !== 'transcription' &&
234
245
  identity.profileType !== 'decision' &&
235
- identity.profileType !== 'host' && _jsx(SystemPromptSection, { identity: identity, set: set })] }));
246
+ identity.profileType !== 'host' && (_jsx(SystemPromptSection, { identity: identity, canShowOptions: draftAllows(draft, 'inputs.options'), set: set }))] }));
236
247
  }
237
248
  /** The policy every model of the profile shares: default, switching, steps, and key slots. */
238
249
  function ModelPolicySection({ draft, type, set, }) {
@@ -753,71 +764,13 @@ function ContextPreviewRow() {
753
764
  setValues({ ...values, contextJson });
754
765
  } }));
755
766
  }
756
- /** The value the studio's page sends for each slot declared so far. Kept in this tab. */
757
- function SlotPreviewRows({ slots }) {
758
- const [values, setValues] = usePageValues(useContext(WorkspaceContext)?.self ?? '');
759
- return draftSlots(slots).map(({ name, label, values: allowed }) => (_jsx(ChoiceRow, { label: label, path: "inputs.slots", isRequired: true, value: allowed.find((value) => value === values.slots[name]) ?? allowed[0], options: allowed, onChange: (next) => {
760
- if (next)
761
- setValues({ ...values, slots: { ...values.slots, [name]: next } });
762
- } }, name)));
763
- }
764
- /** One of a slot's choices: the value a turn sends, what the page says of it, and a remove button. */
765
- function SlotChoiceRow({ choice, at, onChange, onRemove, }) {
766
- 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) => {
767
- onChange({ value });
768
- } }) }), _jsx(StackItem, { size: "fill", children: _jsx(TextInput, { label: `Choice ${String(at + 1)} description`, isLabelHidden: true, size: "sm", value: choice.description, placeholder: "What the page says of it", onChange: (description) => {
769
- onChange({ description });
770
- } }) }), _jsx(IconButton, { label: `Remove choice ${String(at + 1)}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: onRemove })] }));
771
- }
772
- /** A head over a slot's choices, with its field's description on hover. */
773
- function SlotChoiceHead({ title, doc }) {
774
- return (_jsx(Tooltip, { content: doc, hasHoverIndication: false, children: _jsx(Text, { type: "supporting", color: "secondary", children: title }) }));
775
- }
776
- function SlotChoiceHeads() {
777
- return (_jsxs(HStack, { gap: 1, children: [_jsx("div", { className: "criterion-label", children: _jsx(SlotChoiceHead, { title: "Value", doc: fieldMeta('inputs.slots.*.choices.*.value')?.doc }) }), _jsx(StackItem, { size: "fill", children: _jsx(SlotChoiceHead, { title: "Description", doc: fieldMeta('inputs.slots.*.choices.*.description')?.doc }) })] }));
778
- }
779
- /** One slot: its name, its label, its choices, and the buttons that add a choice and remove it. */
780
- function SlotSection({ slot, at, onChange, onRemove, }) {
781
- const status = useFieldStatus()('slots', at);
782
- const name = slot.name.trim() || `Slot ${String(at + 1)}`;
783
- const setChoice = (key, change) => {
784
- onChange({
785
- choices: slot.choices.map((choice) => choice.key === key ? { ...choice, ...change } : choice),
786
- });
787
- };
788
- return (_jsxs(InspectorSection, { title: slot.label.trim() || name, path: "inputs.slots.*", children: [_jsx(TextRow, { label: "Name", path: "inputs.slots.*", status: status, value: slot.name, placeholder: "language", onChange: (next) => {
789
- onChange({ name: next });
790
- } }), _jsx(TextRow, { label: "Label", path: "inputs.slots.*.label", value: slot.label, placeholder: slot.name.trim() || undefined, onChange: (label) => {
791
- onChange({ label });
792
- } }), _jsxs(VStack, { gap: 1, children: [_jsx(Tooltip, { content: fieldMeta('inputs.slots.*.choices')?.doc, hasHoverIndication: false, children: _jsx(Text, { type: "label", weight: "semibold", children: "Choices" }) }), _jsx(SlotChoiceHeads, {}), slot.choices.map((choice, index) => (_jsx(SlotChoiceRow, { choice: choice, at: index, onChange: (change) => {
793
- setChoice(choice.key, change);
794
- }, onRemove: () => {
795
- onChange({ choices: slot.choices.filter((each) => each.key !== choice.key) });
796
- } }, choice.key)))] }), _jsxs(HStack, { gap: 1, children: [_jsx(Button, { label: "Add choice", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
797
- onChange({ choices: [...slot.choices, newSlotChoice()] });
798
- } }), _jsx(Button, { label: `Remove ${name}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconTrash, size: "sm" }), onClick: onRemove })] })] }));
799
- }
800
- /** Every slot, each in its own section, and the page's pick for each above them. */
801
- function InputSlotsSections({ inputs, set }) {
802
- const { slots } = inputs;
803
- const setSlot = (key, change) => {
804
- set({ slots: slots.map((slot) => (slot.key === key ? { ...slot, ...change } : slot)) });
805
- };
806
- return (_jsxs(_Fragment, { children: [_jsxs(InspectorSection, { path: "inputs.slots", note: sectionNote('slots'), children: [_jsx(SlotPreviewRows, { slots: slots }), _jsx(HStack, { children: _jsx(Button, { label: "Add slot", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
807
- set({ slots: [...slots, newSlot(slots)] });
808
- } }) })] }), slots.map((slot, at) => (_jsx(SlotSection, { slot: slot, at: at, onChange: (change) => {
809
- setSlot(slot.key, change);
810
- }, onRemove: () => {
811
- set({ slots: slots.filter((each) => each.key !== slot.key) });
812
- } }, slot.key)))] }));
813
- }
814
767
  function InputsEditor({ draft, setDraft }) {
815
768
  const { inputs } = draft;
816
769
  const set = patch(setDraft, 'inputs');
817
770
  /** An image profile takes images, video, and PDF as references, and no voice. */
818
771
  const image = draft.identity.profileType === 'image';
819
772
  const voiceOnly = !draftAllows(draft, 'inputs.attachments.accept');
820
- 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 })] }));
773
+ 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 })] }));
821
774
  }
822
775
  /** How tall the system prompt starts. */
823
776
  const PROMPT_ROWS = 12;
@@ -1917,16 +1870,6 @@ const AUTH_HEADER_PREFIX = {
1917
1870
  api_key: '',
1918
1871
  oauth2: 'Bearer ',
1919
1872
  };
1920
- /**
1921
- * Why a tool on `tier` never loads on this draft: the studio can't write a T1 policy, so a
1922
- * T2 tool loads only through the T2 loader.
1923
- */
1924
- function loadTierWarning(draft, tier) {
1925
- if (tier === 'T2' && draftAllows(draft, 'tools.t2Loader') && !draft.tools.t2Loader.trim()) {
1926
- return 'No T2 loader is set under Tools, so this tool never loads.';
1927
- }
1928
- return undefined;
1929
- }
1930
1873
  function placeholderHint(schemas) {
1931
1874
  const names = new Set();
1932
1875
  for (const json of schemas) {
@@ -2314,12 +2257,13 @@ function BackgroundRows({ tool, set }) {
2314
2257
  }
2315
2258
  /** Who may call the tool, whether it asks first, when it loads and on which paths. */
2316
2259
  function PolicySection({ draft, tool, set, }) {
2260
+ const workspace = useContext(WorkspaceContext);
2317
2261
  const isLoader = draft.tools.t2Loader.trim() === tool.toolName.trim();
2318
2262
  return (_jsxs(InspectorSection, { title: "Policy", hint: SECTION_HINTS.toolPolicy, children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
2319
2263
  set({ access });
2320
2264
  } }), _jsx(SegmentedRow, { label: "Permission", path: "registerTool.permission", field: "permission", value: tool.permission, segments: PERMISSION_SEGMENTS, onChange: (permission) => {
2321
2265
  set({ permission });
2322
- } }), tool.answeredBy === 'page' || isLoader ? null : _jsx(BackgroundRows, { tool: tool, set: set }), _jsx(SegmentedRow, { label: "Load tier", path: "registerTool.loadTier", field: "loadTier", value: tool.loadTier, segments: LOAD_TIER_SEGMENTS, warning: loadTierWarning(draft, tool.loadTier), onChange: (loadTier) => {
2266
+ } }), tool.answeredBy === 'page' || isLoader ? null : _jsx(BackgroundRows, { tool: tool, set: set }), _jsx(SegmentedRow, { label: "Load tier", path: "registerTool.loadTier", field: "loadTier", value: tool.loadTier, segments: LOAD_TIER_SEGMENTS, warning: loadTierWarning(draft, tool, workspace?.allowed), onChange: (loadTier) => {
2323
2267
  set({ loadTier });
2324
2268
  } }), _jsx(NamesRow, { label: "Paths", path: "registerTool.paths", field: "paths", value: tool.paths, placeholder: "Every path (*)", onChange: (paths) => {
2325
2269
  set({ paths });
@@ -9,7 +9,7 @@ export type PromptEditorProps = {
9
9
  onChange: (next: string) => void;
10
10
  };
11
11
  /**
12
- * The prompt with its private stretches and conditions in view. It is a view of the markup text:
12
+ * The prompt with its private stretches and options in view. It is a view of the markup text:
13
13
  * it writes back only when the prompt changes, so opening it never dirties the draft, and text
14
14
  * changed from outside (another profile, a reload, a kept source) opens afresh.
15
15
  */
@@ -13,7 +13,7 @@ import { $getRoot, $getSelection, $isElementNode, $isRangeSelection, $isRootNode
13
13
  import { useCallback, useContext, useEffect, useRef, useState, } from 'react';
14
14
  import { openedDoc, PRIVATE_NAME, PRIVATE_ON, promptMarkup, samePrompt } from "../prompt-doc.js";
15
15
  import { ChangeHeld } from "./inspector-context.js";
16
- import { $isPromptLine, conditionItems, PromptConditions, PromptLineNode, } from "./prompt-line-node.js";
16
+ import { $isPromptLine, optionItems, PromptLineNode, PromptOptions } from "./prompt-line-node.js";
17
17
  import './prompt-editor.css';
18
18
  const NODES = [PromptLineNode];
19
19
  const MIN_HEIGHT = '16rem';
@@ -61,7 +61,7 @@ function $selectedEnds(selection) {
61
61
  : [selection.anchor, selection.focus];
62
62
  return { first: $topOf(from.getNode()), last: $topOf(to.getNode()) };
63
63
  }
64
- /** The condition of the line a block belongs to. */
64
+ /** The `when` of the line a block belongs to. */
65
65
  const $whenOf = (top) => $headOf($blockOf(top))?.getWhen() ?? null;
66
66
  /** Lets the blocks from `first` to `last` stand apart from the rest of their lists. */
67
67
  function $standApart(first, last) {
@@ -72,7 +72,7 @@ function $standApart(first, last) {
72
72
  $splitListAt(first, first.getIndexWithinParent());
73
73
  }
74
74
  }
75
- /** Joins `start` to `end` into one line, and what follows keeps the condition it had. */
75
+ /** Joins `start` to `end` into one line, and what follows keeps the `when` it had. */
76
76
  function $closeLine(start, end, tail) {
77
77
  for (let at = start; at && !at.is(end);) {
78
78
  const after = at.getNextSibling();
@@ -84,7 +84,7 @@ function $closeLine(start, end, tail) {
84
84
  if (after && !$isPromptLine(after))
85
85
  end.insertAfter(new PromptLineNode(tail));
86
86
  }
87
- /** Starts the line at `start` under `next`, and neighbours under one condition join back up. */
87
+ /** Starts the line at `start` under `next`, and neighbours under one `when` join back up. */
88
88
  function $openLine(start, end, next) {
89
89
  const before = start.getPreviousSibling();
90
90
  const head = $isPromptLine(before) ? before.setWhen(next) : new PromptLineNode(next);
@@ -99,8 +99,8 @@ function $openLine(start, end, next) {
99
99
  if (above && $headOf(above)?.getWhen() === next)
100
100
  head.remove();
101
101
  }
102
- /** Sets the condition on what is selected, or on the block the caret is in. */
103
- function $setCondition(next) {
102
+ /** Sets the `when` on what is selected, or on the block the caret is in. */
103
+ function $setWhen(next) {
104
104
  const selection = $getSelection();
105
105
  if (!$isRangeSelection(selection))
106
106
  return;
@@ -115,10 +115,10 @@ function $setCondition(next) {
115
115
  $closeLine(start, end, tail);
116
116
  $openLine(start, end, next);
117
117
  }
118
- /** The Private and Condition buttons, on the toolbar's end. */
118
+ /** The Private and Option buttons, on the toolbar's end. */
119
119
  function PromptTools() {
120
120
  const [editor] = useLexicalComposerContext();
121
- const conditions = useContext(PromptConditions);
121
+ const options = useContext(PromptOptions);
122
122
  const [isPrivate, setIsPrivate] = useState(false);
123
123
  const [when, setWhen] = useState(null);
124
124
  useEffect(() => editor.registerUpdateListener(({ editorState }) => {
@@ -138,9 +138,9 @@ function PromptTools() {
138
138
  return;
139
139
  $patchStyleText(selection, { [PRIVATE_NAME]: isPrivate ? null : PRIVATE_ON });
140
140
  });
141
- } }), conditions.length > 0 && (_jsx(DropdownMenu, { label: "Condition", renderTrigger: (props) => (_jsx(ToggleButton, { ...props, label: "Condition", tooltip: "Send this part only on turns where a condition fits", size: "sm", isIconOnly: true, icon: _jsx(Icon, { icon: IconFilter, size: "sm" }), isPressed: Boolean(when), onMouseDown: keepSelection })), items: conditionItems(conditions, when, (next) => {
141
+ } }), options.length > 0 && (_jsx(DropdownMenu, { label: "Option", renderTrigger: (props) => (_jsx(ToggleButton, { ...props, label: "Option", tooltip: "Send this part only on turns where an option fits", size: "sm", isIconOnly: true, icon: _jsx(Icon, { icon: IconFilter, size: "sm" }), isPressed: Boolean(when), onMouseDown: keepSelection })), items: optionItems(options, when, (next) => {
142
142
  editor.update(() => {
143
- $setCondition(next);
143
+ $setWhen(next);
144
144
  });
145
145
  }) }))] }));
146
146
  }
@@ -293,7 +293,7 @@ function OpenedEditor({ opened, placeholder, status, onEdit, }) {
293
293
  } })] }));
294
294
  }
295
295
  /**
296
- * The prompt with its private stretches and conditions in view. It is a view of the markup text:
296
+ * The prompt with its private stretches and options in view. It is a view of the markup text:
297
297
  * it writes back only when the prompt changes, so opening it never dirties the draft, and text
298
298
  * changed from outside (another profile, a reload, a kept source) opens afresh.
299
299
  */
@@ -1,12 +1,12 @@
1
1
  import { type DropdownMenuOption } from '@astryxdesign/core/DropdownMenu';
2
2
  import { DecoratorNode, type LexicalNode, type NodeKey, type SerializedLexicalNode, type Spread } from 'lexical';
3
3
  import { type ReactNode } from 'react';
4
- import type { ConditionDraft } from '../draft.ts';
5
- /** The conditions this profile declares, which the tokens' menus and the toolbar's offer. */
6
- export declare const PromptConditions: import("react").Context<readonly ConditionDraft[]>;
4
+ import type { OptionDraft } from '../draft.ts';
5
+ /** The options this profile declares, which the tokens' menus and the toolbar's offer. */
6
+ export declare const PromptOptions: import("react").Context<readonly OptionDraft[]>;
7
7
  export type SetWhen = (when: string | null) => void;
8
- /** The menu of a line's `when`: one section per condition, with what it holds ticked. */
9
- export declare function conditionItems(conditions: readonly ConditionDraft[], when: string | null, set: SetWhen): DropdownMenuOption[];
8
+ /** The menu of a line's `when`: one section per option, with what it holds ticked. */
9
+ export declare function optionItems(options: readonly OptionDraft[], when: string | null, set: SetWhen): DropdownMenuOption[];
10
10
  export type SerializedPromptLine = Spread<{
11
11
  when?: string | null;
12
12
  }, SerializedLexicalNode>;
@@ -8,26 +8,26 @@ import { IconCheck, IconFilter } from '@tabler/icons-react';
8
8
  import { $getNodeByKey, DecoratorNode, } from 'lexical';
9
9
  import { createContext, useContext, useState } from 'react';
10
10
  import { checksOf, PROMPT_LINE, withCheck, withoutCheck } from "../prompt-doc.js";
11
- /** The conditions this profile declares, which the tokens' menus and the toolbar's offer. */
12
- export const PromptConditions = createContext([]);
13
- /** The menu of a line's `when`: one section per condition, with what it holds ticked. */
14
- export function conditionItems(conditions, when, set) {
11
+ /** The options this profile declares, which the tokens' menus and the toolbar's offer. */
12
+ export const PromptOptions = createContext([]);
13
+ /** The menu of a line's `when`: one section per option, with what it holds ticked. */
14
+ export function optionItems(options, when, set) {
15
15
  const have = checksOf(when);
16
16
  return [
17
17
  ...(have.length > 0
18
18
  ? [
19
19
  {
20
- label: 'Remove condition',
20
+ label: 'Remove',
21
21
  onClick: () => {
22
22
  set(null);
23
23
  },
24
24
  },
25
25
  ]
26
26
  : []),
27
- ...conditions.map(({ name, values }) => ({
27
+ ...options.map(({ name, choices }) => ({
28
28
  type: 'section',
29
29
  title: name,
30
- items: values.map((value) => ({
30
+ items: choices.map(({ value }) => ({
31
31
  label: `${name} is ${value}`,
32
32
  onClick: () => {
33
33
  set(withCheck(when, name, value));
@@ -43,9 +43,9 @@ export function conditionItems(conditions, when, set) {
43
43
  * is a span.
44
44
  */
45
45
  function CheckToken({ check, when, set }) {
46
- const conditions = useContext(PromptConditions);
46
+ const options = useContext(PromptOptions);
47
47
  const [isOpen, setIsOpen] = useState(false);
48
- return (_jsx(DropdownMenu, { label: check, isMenuOpen: isOpen, onOpenChange: setIsOpen, items: conditionItems(conditions, when, set), renderTrigger: ({ ref, id }) => (_jsx(Tooltip, { content: `Sent only on turns where ${when ?? check}. Press to change it.`, children: _jsx(Token, { ref: ref, id: id, size: "sm", label: check, icon: _jsx(Icon, { icon: IconFilter, size: "xsm" }), "aria-haspopup": "menu", "aria-expanded": isOpen, onClick: () => {
48
+ return (_jsx(DropdownMenu, { label: check, isMenuOpen: isOpen, onOpenChange: setIsOpen, items: optionItems(options, when, set), renderTrigger: ({ ref, id }) => (_jsx(Tooltip, { content: `Sent only on turns where ${when ?? check}. Press to change it.`, children: _jsx(Token, { ref: ref, id: id, size: "sm", label: check, icon: _jsx(Icon, { icon: IconFilter, size: "xsm" }), "aria-haspopup": "menu", "aria-expanded": isOpen, onClick: () => {
49
49
  setIsOpen(!isOpen);
50
50
  }, onRemove: () => {
51
51
  set(withoutCheck(when, check));
@@ -1,8 +1,8 @@
1
- import type { ConditionDraft } from '../draft.ts';
1
+ import type { OptionDraft } from '../draft.ts';
2
2
  /** A profile's prompt: formatted, or as code, which is all a prompt the view can't hold can be. */
3
- export declare function PromptRow({ value, conditions, rows, placeholder, onChange, }: {
3
+ export declare function PromptRow({ value, options, rows, placeholder, onChange, }: {
4
4
  value: string;
5
- conditions: readonly ConditionDraft[];
5
+ options: readonly OptionDraft[];
6
6
  rows: number;
7
7
  placeholder?: string;
8
8
  onChange: (next: string) => void;
package/ui/prompt-row.js CHANGED
@@ -6,10 +6,10 @@ import { useDeferredValue, useMemo, useState } from 'react';
6
6
  import { promptDocProblem } from "../prompt-doc.js";
7
7
  import { TextAreaRow, useFieldRow, WideRow } from "./inspector.js";
8
8
  import { PromptEditor } from "./prompt-editor.js";
9
- import { PromptConditions } from "./prompt-line-node.js";
9
+ import { PromptOptions } from "./prompt-line-node.js";
10
10
  const PATH = 'identity.system';
11
11
  /** A profile's prompt: formatted, or as code, which is all a prompt the view can't hold can be. */
12
- export function PromptRow({ value, conditions, rows, placeholder, onChange, }) {
12
+ export function PromptRow({ value, options, rows, placeholder, onChange, }) {
13
13
  const row = { label: 'Prompt', path: PATH, field: 'system' };
14
14
  const { status, required } = useFieldRow(row);
15
15
  const [wantsCode, setWantsCode] = useState(false);
@@ -21,5 +21,5 @@ export function PromptRow({ value, conditions, rows, placeholder, onChange, }) {
21
21
  if (isCode) {
22
22
  return (_jsx(TextAreaRow, { ...row, rows: rows, value: value, placeholder: placeholder, status: problem ? { type: 'warning', message: problem } : undefined, action: toggle, onChange: onChange }));
23
23
  }
24
- return (_jsx(WideRow, { label: row.label, path: row.path, isRequired: required, hasIssue: status !== undefined, action: toggle, children: _jsx(PromptConditions.Provider, { value: conditions, children: _jsx(PromptEditor, { value: value, placeholder: placeholder, status: status, onChange: onChange }) }) }));
24
+ return (_jsx(WideRow, { label: row.label, path: row.path, isRequired: required, hasIssue: status !== undefined, action: toggle, children: _jsx(PromptOptions.Provider, { value: options, children: _jsx(PromptEditor, { value: value, placeholder: placeholder, status: status, onChange: onChange }) }) }));
25
25
  }
@@ -58,8 +58,10 @@ export interface ProjectChatProps extends ChatStart {
58
58
  trace?: boolean;
59
59
  className?: string;
60
60
  chatRef?: Ref<TheoremChatHandle>;
61
- /** The value the page picked for each slot. */
62
- slots?: Record<string, string>;
61
+ /** The value the page picked for each option. */
62
+ options?: Record<string, string>;
63
+ /** Says what a person picked in the composer. */
64
+ onOptionsChange?: (options: Record<string, string>) => void;
63
65
  /** What the edited side states, of the profile the edits make. */
64
66
  stated?: StatedTurn;
65
67
  /** What the files' side states, of the profile the files hold. */
@@ -337,11 +337,11 @@ function SharedComposer({ sides, edited, inputRef, }) {
337
337
  });
338
338
  }, onMenuAction: (action) => {
339
339
  void deliver(action);
340
- }, generationSelect: _jsx(PairGeneration, { sides: sides }), slotChoices: edited.slots && {
341
- ...edited.slots,
340
+ }, generationSelect: _jsx(PairGeneration, { sides: sides }), optionChoices: edited.options && {
341
+ ...edited.options,
342
342
  onChange: (name, value) => {
343
343
  each((chat) => {
344
- chat.pickSlot(name, value);
344
+ chat.pickOption(name, value);
345
345
  });
346
346
  },
347
347
  }, onPendingMove: (id, direction) => {
@@ -550,7 +550,7 @@ function useShownSides({ inFiles, isEditing, isShared }) {
550
550
  * the files with the edits laid over them.
551
551
  */
552
552
  export function ProjectChat(props) {
553
- const { profileId, trace, className, chatRef, slots, stated, savedStated, context } = props;
553
+ const { profileId, trace, className, chatRef, options, stated, savedStated, context } = props;
554
554
  const { conversationView, initialText, initialFiles, initialVoice, initialPending } = props;
555
555
  const view = useComparison(props);
556
556
  const { pair, isBusy, transports, refused, isReady } = view;
@@ -564,7 +564,8 @@ export function ProjectChat(props) {
564
564
  labels: STUDIO_LABELS,
565
565
  trace,
566
566
  className,
567
- slots,
567
+ options,
568
+ onOptionsChange: props.onOptionsChange,
568
569
  context,
569
570
  composer: !isShared,
570
571
  // A greeting says where to start; both sides start at the one composer under them.
@@ -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' | 'stated' | 'context'> & {
5
+ export type StudioLiveProps = Pick<LiveRunnerProps, 'trace' | 'options' | 'stated' | 'context'> & {
6
6
  payload: StudioRunPayload;
7
7
  /** Called as each call starts. */
8
8
  note: () => void;
package/ui/studio-live.js CHANGED
@@ -18,7 +18,7 @@ export function ProjectLive({ endpoint, ...props }) {
18
18
  createSocket: () => new WebSocket(liveSocketAddress(endpoint, actingAs)),
19
19
  }) }));
20
20
  }
21
- function LiveView({ payload, note, connect, trace, slots, stated, context, }) {
21
+ function LiveView({ payload, note, connect, trace, options, stated, context, }) {
22
22
  const iface = useMemo(() => studioInterface(payload), [payload]);
23
23
  /** The studio's page answers each page tool with the tool's stub. */
24
24
  const pageTools = useMemo(() => studioPageTools(payload), [payload]);
@@ -27,5 +27,5 @@ function LiveView({ payload, note, connect, trace, slots, stated, context, }) {
27
27
  return (_jsx(LiveRunner, { labels: STUDIO_LABELS, iface: iface, connection: () => {
28
28
  note();
29
29
  return connect();
30
- }, trace: trace, slots: slots, stated: stated, context: context, pageTools: pageTools }));
30
+ }, trace: trace, options: options, stated: stated, context: context, pageTools: pageTools }));
31
31
  }
@@ -30,9 +30,10 @@ export interface StudioRunnerProps {
30
30
  initialPending?: ChatProps['initialPending'];
31
31
  onConversationChange?: ChatProps['onConversationChange'];
32
32
  chatRef?: ChatProps['chatRef'];
33
- /** The value the page picked for each slot, for a chat's turns and a call's start. */
34
- slots?: ChatProps['slots'];
35
- /** What a run of a profile states: it declares its own conditions. */
33
+ /** The value the page picked for each option, for a chat's turns and a call's start. */
34
+ options?: ChatProps['options'];
35
+ onOptionsChange?: ChatProps['onOptionsChange'];
36
+ /** What a run of a profile states: it declares its own options. */
36
37
  statedOf?: (of: StudioRunPayload) => ChatProps['stated'];
37
38
  /** What the page tells the agent. */
38
39
  context?: ChatProps['context'];
@@ -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, statedOf, context, tested, project, traces, note, }) {
61
+ function Run({ payload, runtime, trace, className, flush, columns, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, options, onOptionsChange, 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, conversation: conversation, conversationView: conversationView, initialText: initialText, initialFiles: initialFiles, initialVoice: initialVoice, initialPending: initialPending, onConversationChange: onConversationChange, chatRef: chatRef, slots: slots, statedOf: statedOf, 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, options: options, onOptionsChange: onOptionsChange, 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, statedOf: statedOf, 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, options: options, onOptionsChange: onOptionsChange, 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, stated, context, }) {
119
+ function SideRun({ payload, endpoint, load, traces, note, trace, className, flush, columns, chatRef, options, onOptionsChange, 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, stated: stated, context: context }));
139
+ return (_jsx(TheoremChat, { detectCodeLanguage: true, labels: STUDIO_LABELS, transport: chat, pageTools: pageTools, trace: trace, className: className, chatRef: chatRef, options: options, onOptionsChange: onOptionsChange, 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,7 +144,7 @@ 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, stated: stated, context: context }));
147
+ return (_jsx(ProjectLive, { payload: payload, endpoint: endpoint, note: note, trace: trace, options: options, 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
@@ -174,12 +174,12 @@ function ProjectRun({ project, tested, ...run }) {
174
174
  const files = useMemo(() => (starts && providers ? compileFiles(starts, providers, project.profiles) : undefined), [starts, providers, project.profiles]);
175
175
  const saved = useMemo(() => (edits && files ? savedPayload(edits, files, payload) : undefined), [edits, files, payload]);
176
176
  if (isChat(payload) && (!saved || isChat(saved)))
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
+ 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, options: run.options, onOptionsChange: run.onOptionsChange, stated: statedOf?.(payload), savedStated: statedOf?.(saved ?? payload), context: run.context }));
178
178
  if (!edits)
179
179
  return (_jsx(SideRun, { ...run, stated: statedOf?.(payload), endpoint: projectProfileEndpoint(project, payload.agentId) }));
180
180
  return _jsx(ProjectSides, { ...run, project: project, saved: saved, edits: edits });
181
181
  }
182
- function TurnRun({ payload, runtime, traces, trace, className, note, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, slots, statedOf, context, }) {
182
+ function TurnRun({ payload, runtime, traces, trace, className, note, conversation, conversationView, initialText, initialFiles, initialVoice, initialPending, onConversationChange, chatRef, options, onOptionsChange, statedOf, context, }) {
183
183
  const stated = statedOf?.(payload);
184
184
  const iface = useMemo(() => studioInterface(payload), [payload]);
185
185
  /** The studio's page answers each page tool with the tool's stub. */
@@ -190,5 +190,5 @@ function TurnRun({ payload, runtime, traces, trace, className, note, conversatio
190
190
  traces,
191
191
  })
192
192
  : createStudioTransport(payload, { traces }), note), [payload, runtime, traces, note]);
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 }));
193
+ return iface.type === 'live' ? (_jsx(StudioLive, { payload: payload, runtime: runtime, note: note, trace: trace, options: options, 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, options: options, onOptionsChange: onOptionsChange, stated: stated, context: context, pageTools: pageTools }));
194
194
  }
@@ -1851,7 +1851,7 @@ function PreviewBody({ compile, run, connection, chatRef, chatWith, profileId, t
1851
1851
  /** Why the project's server does not run this profile: its files say, not the editor. */
1852
1852
  const unserved = useProject()?.problems.find((problem) => problem.profile === profileId);
1853
1853
  const pageInputs = useMemo(() => (payload ? pageInputsOf(payload) : null), [payload]);
1854
- const [pageValues] = usePageValues(chatWith);
1854
+ const [pageValues, setPageValues] = usePageValues(chatWith);
1855
1855
  const sent = useMemo(() => sentPageValues(pageInputs, pageValues), [pageInputs, pageValues]);
1856
1856
  const statedOf = useCallback((of) => sentPageValues(pageInputsOf(of), pageValues).stated, [pageValues]);
1857
1857
  const shown = payload && !unserved
@@ -1870,7 +1870,10 @@ function PreviewBody({ compile, run, connection, chatRef, chatWith, profileId, t
1870
1870
  else
1871
1871
  clearConversation(run.chatKey);
1872
1872
  },
1873
- slots: sent.slots,
1873
+ options: sent.options,
1874
+ onOptionsChange: (options) => {
1875
+ setPageValues({ ...pageValues, options: { ...pageValues.options, ...options } });
1876
+ },
1874
1877
  statedOf,
1875
1878
  context: sent.context,
1876
1879
  tested,