@theoremjs/studio 0.3.4-next.735.g8d504c6 → 0.3.4-next.753.g176c472

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 (162) hide show
  1. package/installed.mjs +10 -1
  2. package/label-areas.d.ts +5 -0
  3. package/label-areas.js +6 -0
  4. package/package.json +19 -4
  5. package/page/assets/Badge-D78MvW22.js +1 -0
  6. package/page/assets/{BottomSheet-Dbh6A5Vl.js → BottomSheet-CS905Wxu.js} +1 -1
  7. package/page/assets/Card-D_40unTk.js +1 -0
  8. package/page/assets/CheckboxInput-MMjt4mDv.js +2 -0
  9. package/page/assets/CodeBlock-DzXH_9DF.js +3 -0
  10. package/page/assets/CollapsibleGroup-D1qiJpkR.js +1 -0
  11. package/page/assets/ConsoleFrame-CqQsb1GZ.js +3 -0
  12. package/page/assets/DateInput-BvG86MuZ.js +1 -0
  13. package/page/assets/{Dialog-Sd04KQS2.js → Dialog-DUNBjHOI.js} +1 -1
  14. package/page/assets/{HoverCard-DMyWUvwP.js → HoverCard-DMHc1Gh1.js} +1 -1
  15. package/page/assets/Icon-3c9WmPTH.js +3 -0
  16. package/page/assets/{IconButton-DVUFx-8p.js → IconButton-BeI1pXEZ.js} +1 -1
  17. package/page/assets/IconFilter-BO98ezum.js +1 -0
  18. package/page/assets/IconHistory-VvDVN7WG.js +1 -0
  19. package/page/assets/{ItemSwipeLayer-Ckn4X6h9.js → ItemSwipeLayer-BzVkYf4E.js} +1 -1
  20. package/page/assets/{ListItem-QF7KFt0h.js → ListItem-MWWVygeh.js} +1 -1
  21. package/page/assets/MenuBottomSheet-BInvPU7g.js +1 -0
  22. package/page/assets/MenuBottomSheetActionList-CYZ56fty.js +1 -0
  23. package/page/assets/OverflowList-CoxIfkMv.js +1 -0
  24. package/page/assets/SchemaFields-Bd9lDE4d.js +1 -0
  25. package/page/assets/ScrollableArea-CZpbLBeP.js +1 -0
  26. package/page/assets/SidePanel-Bp_RI52Y.js +2 -0
  27. package/page/assets/{Text-BOqCfzZC.js → Text-B74VhVA7.js} +2 -2
  28. package/page/assets/TextInput-D1GkClqk.js +1 -0
  29. package/page/assets/{TimestampHoverCard-CDCVpEWM.js → TimestampHoverCard-BNDnoAyp.js} +1 -1
  30. package/page/assets/ToolResultCharts-CI9TdyAV.js +1 -0
  31. package/page/assets/Toolbar-RbTb26eP.js +1 -0
  32. package/page/assets/{Tooltip-BWs5DLrM.js → Tooltip-DrSpWxD8.js} +1 -1
  33. package/page/assets/TraceInspector-aObqeJHi.js +1 -0
  34. package/page/assets/{TraceOverview-DqCofwm4.js → TraceOverview-D5c_l1Ux.js} +4 -4
  35. package/page/assets/{_virtual_studio-type-sources-nXG6uotl.js → _virtual_studio-type-sources-Cc4WAdgD.js} +50 -17
  36. package/page/assets/browser-connection-159CdeHX.js +1 -0
  37. package/page/assets/browser-engine-DI5i0e2R.js +16 -0
  38. package/page/assets/browser-transport-Dh5ab7QT.js +45 -0
  39. package/page/assets/compile-iB2CAmRL.js +2 -0
  40. package/page/assets/{container.stylex-BmOi-8DQ.js → container.stylex-C2nFBhUj.js} +1 -1
  41. package/page/assets/{embedding-space-view-CN0VHXXH.js → embedding-space-view-JuXKDaFw.js} +1 -1
  42. package/page/assets/encode-files-CeZxxjYd.js +1 -0
  43. package/page/assets/{export-agent-BrN5vTz2.js → export-agent-Cd8Q-cK9.js} +3 -3
  44. package/page/assets/{fieldParts-CoOpDoax.js → fieldParts-Dtp1EoJQ.js} +1 -1
  45. package/page/assets/{focusOutline.stylex-BT0kfa4t.js → focusOutline.stylex-B9nWSXsG.js} +1 -1
  46. package/page/assets/guardrail-tester-CR-zyzhr.js +9 -0
  47. package/page/assets/highlightRanges-yrVxbmkN.js +51 -0
  48. package/page/assets/index-DakRjE8R.css +1 -0
  49. package/page/assets/index-Kvukosz3.js +149 -0
  50. package/page/assets/{labels-provider-uONlWExD.js → labels-provider-Dc-AJqPH.js} +2 -2
  51. package/page/assets/{live-messages-_FDpxQYF.js → live-messages-D-SPyR3e.js} +1 -1
  52. package/page/assets/menuItemRoles-Bod0knkp.js +1 -0
  53. package/page/assets/prompt-row-CE0EDTVb.js +71 -0
  54. package/page/assets/prompt-row-beoYzntJ.css +1 -0
  55. package/page/assets/reader-DtOL_I1x.js +5 -0
  56. package/page/assets/registry-DP0ArymS.js +1 -0
  57. package/page/assets/schema-Cv4HAfBT.js +3 -0
  58. package/page/assets/shaped-data-DCfLI4gb.js +21 -0
  59. package/page/assets/{stub-J0Ig6FyA.js → stub-REBz-ZC7.js} +1 -1
  60. package/page/assets/studio-code-pane-DCaWq57x.js +10 -0
  61. package/page/assets/{studio-console-BG1WmM3M.js → studio-console-bHQq_-86.js} +1 -1
  62. package/page/assets/studio-decision-BaoUot8U.js +1 -0
  63. package/page/assets/studio-embedding-BVMWcpVq.js +2 -0
  64. package/page/assets/studio-host-console-BfLdRxc9.js +2 -0
  65. package/page/assets/studio-labels-CNc-S7NH.js +3 -0
  66. package/page/assets/studio-live-DeDSZSSs.js +5 -0
  67. package/page/assets/studio-map-u2kDE0i4.js +1 -0
  68. package/page/assets/studio-trace-replay-BInKCErs.js +3 -0
  69. package/page/assets/{studio-type-checker-CF7Re1aY.js → studio-type-checker-JZuu4iVI.js} +1 -1
  70. package/page/assets/{tokens.stylex-DkHf0P9C.js → tokens.stylex-BpCwr7Mf.js} +1 -1
  71. package/page/assets/tool-schema-BwaPiLtT.js +17 -0
  72. package/page/assets/{trace-patterns-D6TbkLLr.js → trace-patterns-D5Rcl0G4.js} +1 -1
  73. package/page/assets/{trace-record-YSvR6YMe.js → trace-record--uEnDt_D.js} +1 -1
  74. package/page/assets/tree-CL4ETBd5.js +3 -0
  75. package/page/assets/{turn-client-Xn70kpoZ.js → turn-client-B3jV7UKH.js} +2 -2
  76. package/page/assets/types-BDx4pnrt.js +1 -0
  77. package/page/assets/use-one-call-D9ArlH1f.js +1 -0
  78. package/page/assets/use-second-ticker-DhbZ0Soz.js +1 -0
  79. package/page/assets/{useAnnounce-DTSHZvjg.js → useAnnounce-DOkF3CS1.js} +1 -1
  80. package/page/assets/useAnnounceRenderedText-aqUr1P16.js +1 -0
  81. package/page/assets/{useClipboard-CbN9bb4J.js → useClipboard-BC4cMFBa.js} +1 -1
  82. package/page/assets/useKeyboardHint-BBkDGjRh.js +1 -0
  83. package/page/assets/useLocale-D8GRz3lz.js +1 -0
  84. package/page/assets/useMenuDrillIn-tTYG6Wzi.js +1 -0
  85. package/page/assets/{useMenuPress-DLG1QOiE.js → useMenuPress-DPpqa6F7.js} +1 -1
  86. package/page/assets/{useResolvedRequired-DbsOcDqy.js → useResolvedRequired-68GOSl0j.js} +1 -1
  87. package/page/assets/{useTooltip-c097gL_-.js → useTooltip-BaCjTHk-.js} +1 -1
  88. package/page/assets/{workspace-Bfoebvk4.js → workspace-B6d08n7C.js} +1 -1
  89. package/page/index.html +53 -42
  90. package/prompt-doc.d.ts +24 -0
  91. package/prompt-doc.js +251 -0
  92. package/read-source.js +25 -33
  93. package/section-notes.d.ts +16 -2
  94. package/section-notes.js +16 -2
  95. package/server/runs.d.ts +17 -0
  96. package/server/runs.js +73 -0
  97. package/server/save-session.d.ts +4 -0
  98. package/server/save-session.js +10 -6
  99. package/server/serve.js +76 -12
  100. package/ui/built/theme.css +1 -1
  101. package/ui/built/theorem-studio.js +1 -1
  102. package/ui/inspector-context.d.ts +2 -0
  103. package/ui/inspector-context.js +2 -0
  104. package/ui/inspector.d.ts +44 -2
  105. package/ui/inspector.js +20 -9
  106. package/ui/lib/studio-watch.d.ts +6 -0
  107. package/ui/lib/studio-watch.js +16 -0
  108. package/ui/profile-editor.js +47 -40
  109. package/ui/prompt-editor.css +112 -0
  110. package/ui/prompt-editor.d.ts +16 -0
  111. package/ui/prompt-editor.js +315 -0
  112. package/ui/prompt-line-node.d.ts +29 -0
  113. package/ui/prompt-line-node.js +112 -0
  114. package/ui/prompt-row.d.ts +9 -0
  115. package/ui/prompt-row.js +25 -0
  116. package/ui/provider-editor.js +2 -1
  117. package/ui/studio-compare.js +48 -7
  118. package/ui/studio-save.d.ts +2 -0
  119. package/ui/studio-save.js +13 -5
  120. package/ui/studio-screen.js +18 -16
  121. package/ui/studio-theme.d.ts +1 -1
  122. package/ui/studio-theme.js +2 -0
  123. package/ui/studio-trace-replay.js +5 -5
  124. package/ui/studio.css +42 -14
  125. package/page/assets/Banner-BXQ3eMGX.js +0 -3
  126. package/page/assets/Card-DruykyeB.js +0 -1
  127. package/page/assets/CheckboxInput-CFZ_Wq8-.js +0 -2
  128. package/page/assets/CodeBlock-CfVOtDeO.js +0 -52
  129. package/page/assets/CollapsibleGroup-BsIYDnJR.js +0 -1
  130. package/page/assets/ConsoleFrame-DDSgPsZH.js +0 -3
  131. package/page/assets/DateInput-CalwZl6a.js +0 -1
  132. package/page/assets/Icon-BqkS-pIq.js +0 -3
  133. package/page/assets/IconEye-BB5aY-wQ.js +0 -1
  134. package/page/assets/MenuBottomSheet-CGBoKe8D.js +0 -1
  135. package/page/assets/SchemaFields-D7ClAIou.js +0 -1
  136. package/page/assets/ScrollableArea-ChTx-OVZ.js +0 -1
  137. package/page/assets/SegmentedControlItem-CZs-ycSA.js +0 -1
  138. package/page/assets/SidePanel-DEd3R1Q3.js +0 -2
  139. package/page/assets/ToolResultCharts-DiEXUaNn.js +0 -1
  140. package/page/assets/TraceInspector-CaNKb5tj.js +0 -1
  141. package/page/assets/browser-connection-Dm_C2k-h.js +0 -3
  142. package/page/assets/browser-engine-BfnMGcT2.js +0 -16
  143. package/page/assets/browser-transport-9tBHJSxP.js +0 -45
  144. package/page/assets/crypto-DbeKCGAB.js +0 -1
  145. package/page/assets/encode-files-BdORDAbw.js +0 -1
  146. package/page/assets/guardrail-tester-BrSKPdyb.js +0 -9
  147. package/page/assets/index-Boxd3JUw.js +0 -149
  148. package/page/assets/index-C9rhrCGT.css +0 -1
  149. package/page/assets/reader-CHvIE7jW.js +0 -5
  150. package/page/assets/shaped-data-B5yHkAzM.js +0 -21
  151. package/page/assets/studio-code-pane-B4bfZLeO.js +0 -10
  152. package/page/assets/studio-decision-Ck3RM4xV.js +0 -1
  153. package/page/assets/studio-embedding-pvHODyby.js +0 -2
  154. package/page/assets/studio-host-console-DAv2ocEl.js +0 -2
  155. package/page/assets/studio-labels-DLm-OIlS.js +0 -3
  156. package/page/assets/studio-live-BBVkUupj.js +0 -5
  157. package/page/assets/studio-map-DE4o1Dw6.js +0 -1
  158. package/page/assets/studio-trace-replay-DMnAw57P.js +0 -3
  159. package/page/assets/tool-schema-CAhMfN4z.js +0 -17
  160. package/page/assets/tree-sm5ci1wZ.js +0 -3
  161. package/page/assets/use-one-call-DJQhFDfz.js +0 -1
  162. package/page/assets/use-second-ticker-B_tRvZF_.js +0 -1
@@ -29,9 +29,10 @@ import { BOUNDARIES, BOUNDARY_META, DETECT_ACTION_META, DETECT_ACTIONS, DETECTOR
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
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";
32
+ import { SECTION_HINTS } from "../section-notes.js";
32
33
  import { AddProviderButton } from "./add-provider.js";
33
34
  import { IconGoogle, IconOpenAi, IconOpenRouter, IconTypeSafe } from "./brand-icons.js";
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 { ChoiceRow, EntriesRow, InspectorGroupTitle, InspectorRow, InspectorSection, LABEL_COLUMN, ListRow, NamesInput, NamesRow, NumberRow, OriginLine, OwnField, SegmentedRow, SetInCode, SliderRow, SwitchRow, TextAreaRow, TextRow, WideRow, } from "./inspector.js";
35
36
  import { GuardrailTest, LeavePage, ListBadges, LocalConnection, NodeIssues, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.js";
36
37
  import { CONTEXT_PLACEHOLDER, contextErrorOf, draftSlots, usePageValues, } from "./lib/studio-page.js";
37
38
  import { useProject } from "./lib/studio-project.js";
@@ -42,6 +43,8 @@ import { slotDescription, useProviderModels } from "./studio-connection.js";
42
43
  import { IconTheorem } from "./theorem-mark.js";
43
44
  // The tester and its probes load when a detector's page first shows it.
44
45
  const DetectorTester = lazy(() => import("./guardrail-tester.js").then((tester) => ({ default: tester.DetectorTester })));
46
+ // The formatted editor and Lexical load when a prompt first shows.
47
+ const PromptRow = lazy(() => import("./prompt-row.js").then((row) => ({ default: row.PromptRow })));
45
48
  /** Sets fields of one section of the draft, leaving the rest as it is. */
46
49
  function patch(setDraft, key) {
47
50
  return (change) => {
@@ -175,38 +178,51 @@ function withNewSections(before, after) {
175
178
  .reduce(includeFacet, after);
176
179
  }
177
180
  function SystemPromptSection({ identity, set, }) {
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
+ 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) => {
182
+ set({ system });
183
+ } }) })] }));
181
184
  }
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, }) {
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];
187
+ const VALUE_HINT = {
188
+ marked: 'The studio states this value.',
189
+ other: 'Press to state this value.',
190
+ };
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, }) {
184
193
  const status = useFieldStatus()('conditions', at);
185
194
  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) => {
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) => {
187
196
  onChange({ name });
188
- } }) }) }) }), _jsx(StackItem, { size: "fill", children: _jsx(NamesInput, { label: `${row} values`, value: condition.values, placeholder: "free", overflow: "none", onChange: (values) => {
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) => {
189
198
  onChange({ values });
190
199
  } }) }), _jsx(IconButton, { label: `Remove ${row.toLowerCase()}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: onRemove })] }));
191
200
  }
192
- /** Every condition, one to a row, and the page's pick for each below them. */
193
- function ConditionSection({ identity, set, }) {
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, }) {
194
203
  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 })] }));
204
+ 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()] });
219
+ } }) })] }) }));
204
220
  }
205
221
  function IdentityEditor({ draft, setDraft }) {
206
222
  const keys = useLentKeys();
207
223
  const { identity } = draft;
208
224
  const set = patch(setDraft, 'identity');
209
- return (_jsxs(_Fragment, { children: [_jsxs(InspectorSection, { title: "Profile", children: [_jsx(TextRow, { label: "Id", path: "profile.id", field: "agentId", value: identity.agentId, placeholder: "my.agent", maxLength: PROFILE_ID_MAX_CHARS, onChange: (agentId) => {
225
+ return (_jsxs(_Fragment, { children: [_jsxs(InspectorSection, { title: "Profile", hint: SECTION_HINTS.profile, children: [_jsx(TextRow, { label: "Id", path: "profile.id", field: "agentId", value: identity.agentId, placeholder: "my.agent", maxLength: PROFILE_ID_MAX_CHARS, onChange: (agentId) => {
210
226
  set({ agentId });
211
227
  } }), _jsx(SegmentedRow, { label: "Type", path: "profile.type", field: "profileType", value: identity.profileType, segments: PROFILE_TYPE_SEGMENTS, onChange: (type) => {
212
228
  if (type)
@@ -216,12 +232,12 @@ function IdentityEditor({ draft, setDraft }) {
216
232
  } }))] }), identity.profileType !== 'speech' &&
217
233
  identity.profileType !== 'transcription' &&
218
234
  identity.profileType !== 'decision' &&
219
- identity.profileType !== 'host' && (_jsxs(_Fragment, { children: [_jsx(ConditionSection, { identity: identity, set: set }), _jsx(SystemPromptSection, { identity: identity, set: set })] }))] }));
235
+ identity.profileType !== 'host' && _jsx(SystemPromptSection, { identity: identity, set: set })] }));
220
236
  }
221
237
  /** The policy every model of the profile shares: default, switching, steps, and key slots. */
222
238
  function ModelPolicySection({ draft, type, set, }) {
223
239
  const { models } = draft;
224
- return (_jsxs(InspectorSection, { title: "Policy", children: [_jsx(ChoiceRow, { label: "Default", path: "profile.defaultModel", field: "defaultModel", value: models.defaultModel, isRequired: defaultModelRequired(draft), options: draft.modelBindings.map((binding) => binding.modelId), onChange: (defaultModel) => {
240
+ return (_jsxs(InspectorSection, { title: "Policy", hint: SECTION_HINTS.modelPolicy, children: [_jsx(ChoiceRow, { label: "Default", path: "profile.defaultModel", field: "defaultModel", value: models.defaultModel, isRequired: defaultModelRequired(draft), options: draft.modelBindings.map((binding) => binding.modelId), onChange: (defaultModel) => {
225
241
  set({ defaultModel });
226
242
  } }), _jsx(SwitchRow, { label: "Switching", path: "profile.allowModelSelect", field: "allowModelSelect", value: models.allowModelSelect, isDisabled: draft.modelBindings.length < MODEL_SELECT_MIN_MODELS, disabledMessage: "Add a second model to let people switch.", onChange: (allowModelSelect) => {
227
243
  set({ allowModelSelect });
@@ -564,7 +580,7 @@ function ModelSection({ draft, binding, type, set, }) {
564
580
  }
565
581
  /** How the model generates: its output cap, temperature, and summaries. */
566
582
  function GenerationSection({ binding, set }) {
567
- return (_jsxs(InspectorSection, { title: "Generation", children: [_jsx(NumberRow, { label: "Max output", path: "models.*.maxOutputTokens", units: "tokens", field: "maxOutputTokens", value: binding.maxOutputTokens, min: 1, isIntegerOnly: true, onChange: (maxOutputTokens) => {
583
+ return (_jsxs(InspectorSection, { title: "Generation", hint: SECTION_HINTS.generation, children: [_jsx(NumberRow, { label: "Max output", path: "models.*.maxOutputTokens", units: "tokens", field: "maxOutputTokens", value: binding.maxOutputTokens, min: 1, isIntegerOnly: true, onChange: (maxOutputTokens) => {
568
584
  set({ maxOutputTokens });
569
585
  } }), _jsx(NumberRow, { label: "Temperature", path: "models.*.temperature", field: "temperature", value: binding.temperature, min: 0, step: 0.1, onChange: (temperature) => {
570
586
  set({ temperature });
@@ -702,7 +718,7 @@ function InputAcceptsSection({ inputs, set, image, voiceOnly, hasSizes, }) {
702
718
  }
703
719
  function InputLimitsSection({ inputs, set }) {
704
720
  const limitsRequired = inputLimitsRequired(inputs);
705
- return (_jsxs(InspectorSection, { title: "Limits", children: [_jsx(NumberRow, { label: "Max files", path: "inputs.maxFiles", units: "files", field: "maxFiles", isRequired: limitsRequired, value: inputs.maxFiles, min: 0, isIntegerOnly: true, onChange: (maxFiles) => {
721
+ return (_jsxs(InspectorSection, { title: "Limits", hint: SECTION_HINTS.limits, children: [_jsx(NumberRow, { label: "Max files", path: "inputs.maxFiles", units: "files", field: "maxFiles", isRequired: limitsRequired, value: inputs.maxFiles, min: 0, isIntegerOnly: true, onChange: (maxFiles) => {
706
722
  set({ maxFiles });
707
723
  } }), _jsx(NumberRow, { label: "Max bytes", path: "inputs.maxBytes", units: "bytes", field: "maxBytes", isRequired: limitsRequired, value: inputs.maxBytes, min: 0, isIntegerOnly: true, onChange: (maxBytes) => {
708
724
  set({ maxBytes });
@@ -745,15 +761,6 @@ function SlotPreviewRows({ slots }) {
745
761
  setValues({ ...values, slots: { ...values.slots, [name]: next } });
746
762
  } }, name)));
747
763
  }
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
- }
757
764
  /** One of a slot's choices: the value a turn sends, what the page says of it, and a remove button. */
758
765
  function SlotChoiceRow({ choice, at, onChange, onRemove, }) {
759
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) => {
@@ -1496,7 +1503,7 @@ function PatternSourceSection({ detector, source, onChange, }) {
1496
1503
  const setAside = useRef([]);
1497
1504
  const mine = source.patterns.length > 0;
1498
1505
  const use = source.theorem ? (mine ? 'both' : 'theorem') : 'mine';
1499
- return (_jsxs(InspectorSection, { title: "Patterns", children: [_jsx(SegmentedRow, { label: "Read with", path: `guardrails.detect.${detector}.theorem`, value: use, segments: PATTERN_USE_SEGMENTS, onChange: (next) => {
1506
+ return (_jsxs(InspectorSection, { title: "Patterns", hint: SECTION_HINTS.patterns, children: [_jsx(SegmentedRow, { label: "Read with", path: `guardrails.detect.${detector}.theorem`, value: use, segments: PATTERN_USE_SEGMENTS, onChange: (next) => {
1500
1507
  if (next === 'theorem') {
1501
1508
  setAside.current = source.patterns;
1502
1509
  onChange({ ...source, theorem: true, patterns: [] });
@@ -1598,9 +1605,9 @@ function DetectorPage({ detector, boundaries, hasCanary, guardrails, set, onBack
1598
1605
  };
1599
1606
  return (_jsxs(_Fragment, { children: [_jsx(PageHeader, { title: meta.label, doc: meta.doc, back: "Back to detectors", onBack: onBack, children: _jsx(DetectIssue, {}) }), _jsx(ActionSection, { detector: detector, defaults: meta.defaults, boundaries: boundaries, actions: detect[detector], onChange: setActions }), detector === 'canary_leak' && hasCanary && (_jsx(CanarySection, { guardrails: guardrails, set: set })), meta.patterns && (_jsx(PatternSourceSection, { detector: detector, source: sources[detector], onChange: (next) => {
1600
1607
  set({ sources: { ...sources, [detector]: next } });
1601
- } })), isUrlDetector(detector) && (_jsx(InspectorSection, { title: "Allow", children: _jsx(UrlAllowRows, { detector: detector, allow: allow[detector], onChange: (next) => {
1608
+ } })), isUrlDetector(detector) && (_jsx(InspectorSection, { title: "Allow", hint: SECTION_HINTS.allow, children: _jsx(UrlAllowRows, { detector: detector, allow: allow[detector], onChange: (next) => {
1602
1609
  set({ allow: { ...allow, [detector]: next } });
1603
- } }) })), meta.allow === 'names' && (_jsx(InspectorSection, { title: "Allow", children: _jsx(NamesRow, { label: "Names", path: `guardrails.detect.${detector}.allow.names`, field: "innocentNames", value: innocentNames, onChange: (names) => {
1610
+ } }) })), meta.allow === 'names' && (_jsx(InspectorSection, { title: "Allow", hint: SECTION_HINTS.allow, children: _jsx(NamesRow, { label: "Names", path: `guardrails.detect.${detector}.allow.names`, field: "innocentNames", value: innocentNames, onChange: (names) => {
1604
1611
  set({ innocentNames: names });
1605
1612
  } }) })), _jsx(Suspense, { fallback: null, children: _jsx(DetectorTester, { only: detector }) })] }));
1606
1613
  }
@@ -1612,7 +1619,7 @@ function OwnDetectorPage({ detector, index, boundaries, onChange, onRemove, onBa
1612
1619
  const setActions = (at) => {
1613
1620
  onChange({ ...detector, at });
1614
1621
  };
1615
- return (_jsxs(_Fragment, { children: [_jsx(PageHeader, { title: ownName(detector), doc: fieldMeta('guardrails.detect.*')?.doc, back: "Back to detectors", trailing: _jsx(Tooltip, { content: remove, children: _jsx(IconButton, { label: remove, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconTrash, size: "sm" }), onClick: onRemove }) }), onBack: onBack, children: _jsx(DetectIssue, {}) }), _jsxs(InspectorSection, { title: "Detector", children: [_jsx(TextRow, { label: "Name", path: "guardrails.detect.*.label", field: `own.${String(index)}.label`, value: detector.label, placeholder: "Codenames", onChange: (label) => {
1622
+ return (_jsxs(_Fragment, { children: [_jsx(PageHeader, { title: ownName(detector), doc: fieldMeta('guardrails.detect.*')?.doc, back: "Back to detectors", trailing: _jsx(Tooltip, { content: remove, children: _jsx(IconButton, { label: remove, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconTrash, size: "sm" }), onClick: onRemove }) }), onBack: onBack, children: _jsx(DetectIssue, {}) }), _jsxs(InspectorSection, { title: "Detector", hint: SECTION_HINTS.detector, children: [_jsx(TextRow, { label: "Name", path: "guardrails.detect.*.label", field: `own.${String(index)}.label`, value: detector.label, placeholder: "Codenames", onChange: (label) => {
1616
1623
  onChange({ ...detector, label });
1617
1624
  } }), _jsx(TextRow, { label: "Key", path: "guardrails.detect.*", status: status, value: detector.key, placeholder: "acme.codenames", onChange: (key) => {
1618
1625
  onChange({ ...detector, key });
@@ -2168,7 +2175,7 @@ function ToolSection({ draft, setDraft, tool, set, }) {
2168
2175
  }
2169
2176
  /** The tool's input and output schemas. */
2170
2177
  function ContractSection({ tool, set }) {
2171
- return (_jsxs(InspectorSection, { title: "Contract", children: [_jsx(TextAreaRow, { label: "Input", path: "registerTool.inputSchema", field: "inputJson", value: tool.inputJson, rows: 8, hasSpellCheck: false, onChange: (inputJson) => {
2178
+ return (_jsxs(InspectorSection, { title: "Contract", hint: SECTION_HINTS.contract, children: [_jsx(TextAreaRow, { label: "Input", path: "registerTool.inputSchema", field: "inputJson", value: tool.inputJson, rows: 8, hasSpellCheck: false, onChange: (inputJson) => {
2172
2179
  set({ inputJson });
2173
2180
  } }), _jsx(TextAreaRow, { label: "Output", path: "registerTool.outputSchema", field: "outputJson", value: tool.outputJson, rows: 8, hasSpellCheck: false, onChange: (outputJson) => {
2174
2181
  set({ outputJson });
@@ -2232,7 +2239,7 @@ function HttpMappingSection({ tool, set }) {
2232
2239
  }
2233
2240
  /** The agent an agent tool runs, and how often a turn may call it. */
2234
2241
  function AgentSection({ tool, set, workspace, }) {
2235
- return (_jsxs(InspectorSection, { title: "Agent", children: [_jsx(ChoiceRow, { label: "Runs", path: "registerTool.profile", field: "agentKey", isRequired: true, value: tool.agentKey ?? '', options: otherAgents(workspace.agents, workspace.self, (agent) => CALLABLE_TYPES.has(agent.type)), onChange: (agentKey) => {
2242
+ return (_jsxs(InspectorSection, { title: "Agent", hint: SECTION_HINTS.agent, children: [_jsx(ChoiceRow, { label: "Runs", path: "registerTool.profile", field: "agentKey", isRequired: true, value: tool.agentKey ?? '', options: otherAgents(workspace.agents, workspace.self, (agent) => CALLABLE_TYPES.has(agent.type)), onChange: (agentKey) => {
2236
2243
  const agentId = workspace.agents.find((agent) => agent.key === agentKey)?.agentId ?? '';
2237
2244
  set(agentToolTarget(tool, agentKey, agentId));
2238
2245
  } }), _jsx(NumberRow, { label: "Calls per turn", path: "registerTool.maxCallsPerTurn", field: "maxCallsPerTurn", value: tool.maxCallsPerTurn ?? null, min: 1, isIntegerOnly: true, onChange: (maxCallsPerTurn) => {
@@ -2308,7 +2315,7 @@ function BackgroundRows({ tool, set }) {
2308
2315
  /** Who may call the tool, whether it asks first, when it loads and on which paths. */
2309
2316
  function PolicySection({ draft, tool, set, }) {
2310
2317
  const isLoader = draft.tools.t2Loader.trim() === tool.toolName.trim();
2311
- return (_jsxs(InspectorSection, { title: "Policy", children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
2318
+ 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) => {
2312
2319
  set({ access });
2313
2320
  } }), _jsx(SegmentedRow, { label: "Permission", path: "registerTool.permission", field: "permission", value: tool.permission, segments: PERMISSION_SEGMENTS, onChange: (permission) => {
2314
2321
  set({ permission });
@@ -0,0 +1,112 @@
1
+ .prompt-editor {
2
+ position: relative;
3
+ }
4
+
5
+ .prompt-editor [contenteditable] {
6
+ /* why: a long prompt scrolls inside the editor, so its toolbar stays in reach. */
7
+ max-height: calc(100vh - 340px);
8
+ overflow-y: auto;
9
+ }
10
+
11
+ .prompt-editor [contenteditable] * {
12
+ max-width: none;
13
+ }
14
+
15
+ .prompt-editor h1,
16
+ .prompt-editor h2,
17
+ .prompt-editor h3 {
18
+ font-size: var(--font-size-sm);
19
+ font-weight: var(--font-weight-semibold);
20
+ line-height: 1.4;
21
+ margin-block: var(--spacing-2) var(--spacing-1);
22
+ }
23
+
24
+ /* why: the panel can be narrower than the toolbar, and Private and Condition sit at its end. */
25
+ .prompt-editor [role="toolbar"] [role="group"] {
26
+ flex-wrap: wrap;
27
+ overflow: visible;
28
+ }
29
+
30
+ /* The toolbar's block menu shows its icon alone, so "Heading 2" reads as H2. */
31
+ .prompt-editor [role="toolbar"] button[role="combobox"] > span {
32
+ display: none;
33
+ }
34
+
35
+ /* Private text stays as readable as the rest: a wash marks it, on the words or on whole blocks. */
36
+ .prompt-editor [style*="--private"] {
37
+ background: var(--color-background-muted);
38
+ border-radius: var(--radius-xs, 3px);
39
+ box-decoration-break: clone;
40
+ }
41
+
42
+ .prompt-editor [contenteditable] [data-private] {
43
+ position: relative;
44
+ background: var(--color-background-muted);
45
+ margin-block: 0;
46
+ padding-block: 0;
47
+ padding-inline: var(--spacing-8) var(--spacing-2);
48
+ }
49
+
50
+ .prompt-editor [contenteditable] [data-private] [style*="--private"] {
51
+ background: none;
52
+ }
53
+
54
+ .prompt-editor [contenteditable] ul[data-private],
55
+ .prompt-editor [contenteditable] ol[data-private] {
56
+ padding-inline-start: var(--spacing-12);
57
+ }
58
+
59
+ .prompt-editor [contenteditable] [data-private-start] {
60
+ border-start-start-radius: var(--radius-md, 6px);
61
+ border-start-end-radius: var(--radius-md, 6px);
62
+ padding-block-start: var(--spacing-2);
63
+ }
64
+
65
+ .prompt-editor [contenteditable] [data-private-end] {
66
+ border-end-start-radius: var(--radius-md, 6px);
67
+ border-end-end-radius: var(--radius-md, 6px);
68
+ padding-block-end: var(--spacing-2);
69
+ }
70
+
71
+ /* The mark at the top of a private run: nothing here is shared. */
72
+ .prompt-editor [data-private-start]::before {
73
+ content: "";
74
+ position: absolute;
75
+ inset-inline-start: var(--spacing-2);
76
+ top: var(--spacing-2);
77
+ width: 16px;
78
+ height: 16px;
79
+ background: var(--color-text-secondary);
80
+ mask:
81
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M15 6a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M15.861 15.896a3 3 0 0 0 4.265 4.22m.578 -3.417a3.012 3.012 0 0 0 -1.507 -1.45'/%3E%3Cpath d='M8.7 10.7l1.336 -.688m2.624 -1.352l2.64 -1.36'/%3E%3Cpath d='M8.7 13.3l6.6 3.4'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E")
82
+ center / contain no-repeat;
83
+ }
84
+
85
+ .prompt-hint-anchor {
86
+ position: absolute;
87
+ pointer-events: none;
88
+ }
89
+
90
+ .prompt-line-slot:not(:first-child) {
91
+ margin-top: var(--spacing-3);
92
+ }
93
+
94
+ .prompt-line-slot:has(.prompt-line-head) {
95
+ margin-bottom: var(--spacing-1);
96
+ }
97
+
98
+ /* A condition opens a stretch of the prompt: its tokens, and a line running on from them. */
99
+ .prompt-line-head {
100
+ display: flex;
101
+ flex-wrap: wrap;
102
+ align-items: center;
103
+ gap: var(--spacing-1);
104
+ }
105
+
106
+ .prompt-line-head::after {
107
+ content: "";
108
+ flex: 1;
109
+ min-width: var(--spacing-4);
110
+ height: 1px;
111
+ background: var(--color-border);
112
+ }
@@ -0,0 +1,16 @@
1
+ import { RichTextEditor } from '@astryxdesign/richtext';
2
+ import { type ComponentProps } from 'react';
3
+ export type EditorStatus = ComponentProps<typeof RichTextEditor>['status'];
4
+ export type PromptEditorProps = {
5
+ /** The prompt as markup text, the only form the draft holds. */
6
+ value: string;
7
+ placeholder?: string;
8
+ status?: EditorStatus;
9
+ onChange: (next: string) => void;
10
+ };
11
+ /**
12
+ * The prompt with its private stretches and conditions in view. It is a view of the markup text:
13
+ * it writes back only when the prompt changes, so opening it never dirties the draft, and text
14
+ * changed from outside (another profile, a reload, a kept source) opens afresh.
15
+ */
16
+ export declare function PromptEditor({ value, placeholder, status, onChange }: PromptEditorProps): import("react").JSX.Element;