@theoremjs/studio 0.3.4-next.693.g4ab1526 → 0.3.4-next.715.geef22fd

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 (94) hide show
  1. package/agreement.js +35 -5
  2. package/compile.d.ts +3 -3
  3. package/compile.js +43 -20
  4. package/cookbooks/catalog.js +8 -10
  5. package/draft.d.ts +12 -9
  6. package/draft.js +4 -4
  7. package/mod.d.ts +1 -2
  8. package/mod.js +1 -2
  9. package/package.json +4 -4
  10. package/page/assets/Banner-CrhjYjDy.js +3 -0
  11. package/page/assets/{ConsoleFrame-BvgFGqp2.js → ConsoleFrame-dOTqIkpb.js} +1 -1
  12. package/page/assets/{MenuBottomSheet-BZecY8fw.js → MenuBottomSheet-DeuZCVb-.js} +1 -1
  13. package/page/assets/{SchemaFields-BNNkvyyO.js → SchemaFields-DeuNDrvj.js} +1 -1
  14. package/page/assets/{ToolResultCharts-C3CPsfXl.js → ToolResultCharts-B-pokquL.js} +1 -1
  15. package/page/assets/{TraceInspector-36e6ozKD.js → TraceInspector-CvJ0wx9n.js} +1 -1
  16. package/page/assets/{TraceOverview-CSdJ_cYY.js → TraceOverview-cIjJwpvK.js} +1 -1
  17. package/page/assets/{_virtual_studio-type-sources-DSpwr3WK.js → _virtual_studio-type-sources-BxnDf9BC.js} +225 -85
  18. package/page/assets/browser-connection-CuWeoI9s.js +3 -0
  19. package/page/assets/browser-engine-C3SeJyrA.js +13 -0
  20. package/page/assets/{browser-transport-GzhRiBdm.js → browser-transport-DKhZ4zo1.js} +3 -3
  21. package/page/assets/{crypto-B8dqEoWf.js → crypto-BnoW7FFO.js} +1 -1
  22. package/page/assets/{encode-files-CHeRLBO8.js → encode-files-DoLGXgup.js} +1 -1
  23. package/page/assets/{export-agent-botXSyoH.js → export-agent-CO4lAMum.js} +1 -1
  24. package/page/assets/{guardrail-tester-DYR7EPIy.js → guardrail-tester-Slctc2oI.js} +1 -1
  25. package/page/assets/{index-B7sK7d-l.js → index-CAK9cdCh.js} +72 -76
  26. package/page/assets/{labels-provider-t4c-5JMk.js → labels-provider-uONlWExD.js} +1 -1
  27. package/page/assets/{live-messages-DN_q2nBN.js → live-messages-M0vS3YB0.js} +1 -1
  28. package/page/assets/people-CIsR0-5R.js +1 -0
  29. package/page/assets/reader-747-Cvu8.js +5 -0
  30. package/page/assets/{shaped-data-CJQ3W_RE.js → shaped-data-7q5Be8sp.js} +3 -3
  31. package/page/assets/{stub-U6wDGe3P.js → stub--LOYiyQO.js} +1 -1
  32. package/page/assets/studio-code-pane-CuccT4Ur.js +10 -0
  33. package/page/assets/{studio-console-B7zL133d.js → studio-console-DwxLzV9_.js} +1 -1
  34. package/page/assets/{studio-decision-CbRjfbvG.js → studio-decision-w6OjVUM3.js} +1 -1
  35. package/page/assets/{studio-embedding-DQ0QrEsu.js → studio-embedding-CxFoTvOd.js} +1 -1
  36. package/page/assets/studio-host-console-BhQSkUhA.js +2 -0
  37. package/page/assets/{studio-labels-jYWBoEyP.js → studio-labels-q6eBFSru.js} +1 -1
  38. package/page/assets/{studio-live-D0YRu2zQ.js → studio-live-D5NjMEky.js} +1 -1
  39. package/page/assets/{studio-map-C4Ra1QqL.js → studio-map-DlkGoGam.js} +1 -1
  40. package/page/assets/studio-session-ClF2iNCX.js +1 -0
  41. package/page/assets/{studio-trace-replay-D-f2p7k9.js → studio-trace-replay-Ccv4ToIz.js} +1 -1
  42. package/page/assets/{studio-type-checker-CVNPnko-.js → studio-type-checker-Dm2eit0p.js} +1 -1
  43. package/page/assets/{tool-schema-BDG2_rlP.js → tool-schema-6RWBAqGO.js} +2 -2
  44. package/page/assets/{trace-record-DoXjxrmJ.js → trace-record-Dm2jEhUR.js} +1 -1
  45. package/page/assets/tree-DcCW259J.js +3 -0
  46. package/page/assets/turn-client-OLK12Fyi.js +2 -0
  47. package/page/assets/{use-one-call-B3t-kfc5.js → use-one-call-CLndFp2X.js} +1 -1
  48. package/page/assets/use-second-ticker-D6JSf9B3.js +1 -0
  49. package/page/assets/{workspace-DUfaxr-g.js → workspace-DSAX72vF.js} +1 -1
  50. package/page/index.html +18 -17
  51. package/read-source.js +41 -8
  52. package/registrations.d.ts +9 -1
  53. package/runtime.js +1 -0
  54. package/section-notes.d.ts +1 -0
  55. package/section-notes.js +1 -0
  56. package/serve-page.mjs +8 -4
  57. package/server/handler.d.ts +0 -3
  58. package/server/handler.js +4 -26
  59. package/server/live.d.ts +1 -2
  60. package/server/live.js +3 -4
  61. package/server/save-plan.js +2 -1
  62. package/system-markup.d.ts +9 -7
  63. package/system-markup.js +38 -19
  64. package/tools.js +1 -0
  65. package/types.d.ts +3 -0
  66. package/ui/inspector-context.d.ts +1 -8
  67. package/ui/inspector-context.js +0 -7
  68. package/ui/inspector.d.ts +43 -1
  69. package/ui/inspector.js +50 -9
  70. package/ui/lib/entries.d.ts +13 -0
  71. package/ui/lib/entries.js +43 -0
  72. package/ui/lib/project-traces.js +2 -10
  73. package/ui/lib/studio-prefs.d.ts +0 -4
  74. package/ui/lib/studio-prefs.js +0 -7
  75. package/ui/lib/studio-project.d.ts +2 -5
  76. package/ui/lib/studio-project.js +1 -4
  77. package/ui/profile-editor.js +37 -49
  78. package/ui/studio-screen.d.ts +0 -1
  79. package/ui/studio-screen.js +8 -18
  80. package/ui/studio-settings.js +1 -12
  81. package/asks.d.ts +0 -61
  82. package/asks.js +0 -78
  83. package/page/assets/Banner-DrRNC3MG.js +0 -4
  84. package/page/assets/browser-connection-dads1eyK.js +0 -3
  85. package/page/assets/browser-engine-CugH58NS.js +0 -13
  86. package/page/assets/reader-DHN96tSr.js +0 -5
  87. package/page/assets/studio-code-pane-Boy63AK2.js +0 -8
  88. package/page/assets/studio-host-console-DDA2Um2-.js +0 -2
  89. package/page/assets/studio-session-CPnJaHc-.js +0 -1
  90. package/page/assets/tree-CcEbNvms.js +0 -3
  91. package/page/assets/turn-client-BmOSpCgw.js +0 -2
  92. package/page/assets/use-second-ticker-CWjCHLG6.js +0 -1
  93. package/ui/confirm-write.d.ts +0 -12
  94. package/ui/confirm-write.js +0 -45
@@ -28,13 +28,12 @@ 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, newCriteria, newCriterion, newDecisionImage, newDecisionQuestion, newModelBinding, newOwnDetector, newPattern, newSlot, newSlotChoice, newSystemLine, 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, writeAsk, } from "../mod.js";
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
32
  import { AddProviderButton } from "./add-provider.js";
33
33
  import { IconGoogle, IconOpenAi, IconOpenRouter, IconTypeSafe } from "./brand-icons.js";
34
- import { ChoiceRow, InspectorGroupTitle, InspectorRow, InspectorSection, ListRow, NamesRow, NumberRow, OriginLine, SegmentedRow, SetInCode, SliderRow, SwitchRow, TextAreaRow, TextRow, } from "./inspector.js";
35
- import { ConfirmWrite, GuardrailTest, LeavePage, ListBadges, LocalConnection, NodeIssues, ProjectAsks, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.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 { GuardrailTest, LeavePage, ListBadges, LocalConnection, NodeIssues, QuestionLink, RowOrigins, RunsOn, SaidOrigin, useFieldStatus, useRowOrigin, WorkspaceContext, } from "./inspector-context.js";
36
36
  import { CONTEXT_PLACEHOLDER, contextErrorOf, draftSlots, usePageValues, } from "./lib/studio-page.js";
37
- import { usePref } from "./lib/studio-prefs.js";
38
37
  import { useProject } from "./lib/studio-project.js";
39
38
  import { setToolCredential, subscribeToolCredentials, toolCredential, } from "./lib/tool-credentials.js";
40
39
  import { runToolProbe } from "./lib/tool-probe.js";
@@ -176,19 +175,32 @@ function withNewSections(before, after) {
176
175
  .reduce(includeFacet, after);
177
176
  }
178
177
  function SystemPromptSection({ identity, set, }) {
179
- const { system } = identity;
180
- const setLine = (key, text) => {
181
- set({ system: system.map((line) => (line.key === key ? { ...line, text } : line)) });
182
- };
183
- return (_jsxs(InspectorSection, { title: "System prompt", children: [system.map((line, at) => (_jsxs(HStack, { gap: 1, vAlign: "start", children: [_jsx(StackItem, { size: "fill", children: _jsx(TextAreaRow, { label: `Line ${String(at + 1)}`, path: "identity.system", field: "system", rows: system.length === 1 ? ONLY_LINE_ROWS : LINE_ROWS, value: line.text, placeholder: fieldMeta('identity.system')?.unset, onChange: (text) => {
184
- setLine(line.key, text);
185
- } }) }), system.length > 1 && (_jsx(IconButton, { label: `Remove line ${String(at + 1)}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: () => {
186
- set({ system: system.filter(({ key }) => key !== line.key) });
187
- } }))] }, line.key))), _jsx(HStack, { children: _jsx(Button, { label: "Add line", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
188
- set({ system: [...system, newSystemLine()] });
189
- } }) }), _jsx(TextAreaRow, { label: "Conditions", path: "identity.conditions", field: "conditionsJson", value: identity.conditionsJson, rows: 4, hasSpellCheck: false, placeholder: CONDITIONS_PLACEHOLDER, onChange: (conditionsJson) => {
190
- set({ conditionsJson });
191
- } }), _jsx(ConditionPreviewRows, { conditionsJson: identity.conditionsJson })] }));
178
+ return (_jsx(InspectorSection, { title: "System prompt", note: sectionNote('system'), children: _jsx(TextAreaRow, { label: "Prompt", path: "identity.system", field: "system", rows: PROMPT_ROWS, value: identity.system, placeholder: fieldMeta('identity.system')?.unset, onChange: (system) => {
179
+ set({ system });
180
+ } }) }));
181
+ }
182
+ /** One condition on one row: its name, the values it takes as tokens, and its remove button. */
183
+ function ConditionRow({ condition, at, onChange, onRemove, }) {
184
+ const status = useFieldStatus()('conditions', at);
185
+ const row = `Condition ${String(at + 1)}`;
186
+ return (_jsxs(HStack, { gap: 1, vAlign: "start", children: [_jsx(StackItem, { size: "static", children: _jsx(HStack, { width: LABEL_COLUMN, children: _jsx(StackItem, { size: "fill", children: _jsx(TextInput, { label: `${row} name`, isLabelHidden: true, size: "sm", status: status, value: condition.name, placeholder: "plan", onChange: (name) => {
187
+ onChange({ name });
188
+ } }) }) }) }), _jsx(StackItem, { size: "fill", children: _jsx(NamesInput, { label: `${row} values`, value: condition.values, placeholder: "free", overflow: "none", onChange: (values) => {
189
+ onChange({ values });
190
+ } }) }), _jsx(IconButton, { label: `Remove ${row.toLowerCase()}`, variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconX, size: "sm" }), onClick: onRemove })] }));
191
+ }
192
+ /** Every condition, one to a row, and the page's pick for each below them. */
193
+ function ConditionSection({ identity, set, }) {
194
+ const { conditions } = identity;
195
+ return (_jsxs(InspectorSection, { title: "Conditions", path: "identity.conditions", children: [conditions.map((condition, at) => (_jsx(ConditionRow, { condition: condition, at: at, onChange: (change) => {
196
+ set({
197
+ conditions: conditions.map((each) => each.key === condition.key ? { ...each, ...change } : each),
198
+ });
199
+ }, onRemove: () => {
200
+ set({ conditions: conditions.filter((each) => each.key !== condition.key) });
201
+ } }, condition.key))), _jsx(HStack, { children: _jsx(Button, { label: "Add condition", variant: "ghost", size: "sm", icon: _jsx(Icon, { icon: IconPlus, size: "sm" }), onClick: () => {
202
+ set({ conditions: [...conditions, newCondition()] });
203
+ } }) }), _jsx(ConditionPreviewRows, { conditions: conditions })] }));
192
204
  }
193
205
  function IdentityEditor({ draft, setDraft }) {
194
206
  const keys = useLentKeys();
@@ -204,7 +216,7 @@ function IdentityEditor({ draft, setDraft }) {
204
216
  } }))] }), identity.profileType !== 'speech' &&
205
217
  identity.profileType !== 'transcription' &&
206
218
  identity.profileType !== 'decision' &&
207
- identity.profileType !== 'host' && _jsx(SystemPromptSection, { identity: identity, set: set })] }));
219
+ identity.profileType !== 'host' && (_jsxs(_Fragment, { children: [_jsx(ConditionSection, { identity: identity, set: set }), _jsx(SystemPromptSection, { identity: identity, set: set })] }))] }));
208
220
  }
209
221
  /** The policy every model of the profile shares: default, switching, steps, and key slots. */
210
222
  function ModelPolicySection({ draft, type, set, }) {
@@ -734,9 +746,9 @@ function SlotPreviewRows({ slots }) {
734
746
  } }, name)));
735
747
  }
736
748
  /** The value the studio's page states for each condition declared so far. Kept in this tab. */
737
- function ConditionPreviewRows({ conditionsJson }) {
749
+ function ConditionPreviewRows({ conditions }) {
738
750
  const [values, setValues] = usePageValues(useContext(WorkspaceContext)?.self ?? '');
739
- return Object.entries(draftConditions(conditionsJson)).map(([name, allowed]) => (_jsx(ChoiceRow, { label: name, path: "identity.conditions", isRequired: true, value: allowed.find((value) => value === values.conditions[name]) ?? allowed[0], options: allowed, onChange: (next) => {
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) => {
740
752
  if (next) {
741
753
  setValues({ ...values, conditions: { ...values.conditions, [name]: next } });
742
754
  }
@@ -800,12 +812,8 @@ function InputsEditor({ draft, setDraft }) {
800
812
  const voiceOnly = !draftAllows(draft, 'inputs.attachments.accept');
801
813
  return (_jsxs(_Fragment, { children: [(!voiceOnly || draftAllows(draft, 'inputs.voice')) && (_jsx(InputAcceptsSection, { inputs: inputs, set: set, image: image, voiceOnly: voiceOnly, hasSizes: draftAllows(draft, 'inputs.limitsByMime') })), draftAllows(draft, 'inputs.maxFiles') && _jsx(InputLimitsSection, { inputs: inputs, set: set }), draftAllows(draft, 'inputs.context') && _jsx(InputContextSection, { inputs: inputs, set: set }), draftAllows(draft, 'inputs.slots') && _jsx(InputSlotsSections, { inputs: inputs, set: set })] }));
802
814
  }
803
- const CONDITIONS_PLACEHOLDER = `{
804
- "plan": ["free", "paid"]
805
- }`;
806
- /** How tall a prompt line starts: one line alone is the whole prompt. */
807
- const ONLY_LINE_ROWS = 8;
808
- const LINE_ROWS = 3;
815
+ /** How tall the system prompt starts. */
816
+ const PROMPT_ROWS = 12;
809
817
  /** The agents another agent can name: every one but itself, each by its id. */
810
818
  function otherAgents(agents, self, canName) {
811
819
  return agents
@@ -1804,9 +1812,6 @@ function FlagList({ label, path, flags, value, onChange, }) {
1804
1812
  description: _jsx(Text, { type: "supporting", children: fieldMeta(`${path}.${flag.key}`)?.doc }) }, flag.key))) }));
1805
1813
  }
1806
1814
  const PERCENT = new Intl.NumberFormat('en-US', { style: 'percent' });
1807
- const RESOURCE_PLACEHOLDER = `{
1808
- "service.name": "my-agent"
1809
- }`;
1810
1815
  /** Whether traces are written, and how many turns are sampled. */
1811
1816
  function TracesSection({ observability, set }) {
1812
1817
  const on = observability.writeTo !== false;
@@ -1830,7 +1835,7 @@ function TraceStorageSection({ observability, set }) {
1830
1835
  set({ retainForDays });
1831
1836
  } }), _jsx(NumberRow, { label: "Rotate at", path: "observability.rotateAfterMiB", field: "rotateAfterMiB", units: "MiB", value: observability.rotateAfterMiB, min: 1, onChange: (rotateAfterMiB) => {
1832
1837
  set({ rotateAfterMiB });
1833
- } }), _jsx(TextAreaRow, { label: "Resource", path: "observability.resource", field: "resourceJson", value: observability.resourceJson, rows: 3, hasSpellCheck: false, placeholder: RESOURCE_PLACEHOLDER, onChange: (resourceJson) => {
1838
+ } }), _jsx(EntriesRow, { label: "Resource", noun: "Attribute", path: "observability.resource", field: "resourceJson", value: observability.resourceJson, typed: true, namePlaceholder: "service.name", valuePlaceholder: "my-agent", onChange: (resourceJson) => {
1834
1839
  set({ resourceJson });
1835
1840
  } })] }));
1836
1841
  }
@@ -1916,9 +1921,6 @@ function placeholderHint(schemas) {
1916
1921
  }
1917
1922
  return names.size ? `Can use ${[...names].join(' ')}` : undefined;
1918
1923
  }
1919
- const HEADERS_PLACEHOLDER = `{
1920
- "Accept": "application/json"
1921
- }`;
1922
1924
  /** Adds a new tool to the draft and opens it. */
1923
1925
  export function addToolSpec(draft, setDraft, onSelect) {
1924
1926
  const tool = newToolSpec(draft);
@@ -2092,12 +2094,7 @@ function ToolTest({ tool, guardrails }) {
2092
2094
  setTestedTarget(target);
2093
2095
  setResult(undefined);
2094
2096
  }
2095
- const confirmWrite = useContext(ConfirmWrite);
2096
2097
  const run = async () => {
2097
- // A tool that writes runs only once the builder read the input and said so.
2098
- const ask = writeAsk(tool, sampleInput);
2099
- if (ask && !(await confirmWrite(ask)))
2100
- return;
2101
2098
  setPending(true);
2102
2099
  try {
2103
2100
  setResult(await runToolProbe(tool, sampleInput, credential, guardrails));
@@ -2186,7 +2183,7 @@ function StubSection({ tool, set }) {
2186
2183
  }
2187
2184
  /** The static headers HTTP and MCP tools both send. */
2188
2185
  function HeadersRow({ tool, set }) {
2189
- return (_jsx(TextAreaRow, { label: "Headers", path: "registerTool.headers", field: "headersJson", value: tool.headersJson ?? '', rows: 4, hasSpellCheck: false, placeholder: HEADERS_PLACEHOLDER, onChange: (headersJson) => {
2186
+ return (_jsx(EntriesRow, { label: "Headers", noun: "Header", path: "registerTool.headers", field: "headersJson", value: tool.headersJson ?? '', namePlaceholder: "Accept", valuePlaceholder: "application/json", onChange: (headersJson) => {
2190
2187
  set({ headersJson });
2191
2188
  } }));
2192
2189
  }
@@ -2279,18 +2276,9 @@ function AuthSection({ tool, set }) {
2279
2276
  set({ authType: next });
2280
2277
  } }), authType !== 'none' && _jsx(AuthCredentialRows, { tool: tool, authType: authType, set: set }), authType === 'oauth2' && _jsx(OAuthRows, { tool: tool, set: set })] }));
2281
2278
  }
2282
- /** What the studio does about a tool that writes, when that is not what Permission says. */
2283
- function studioAskNote(asks, tool, askWrites) {
2284
- if ((askWrites === 'destructive' ? asks.destructive : asks.asked).includes(tool))
2285
- return 'In the studio this tool asks before every run, because it writes. Your application runs it as Permission says.';
2286
- if (asks.inside.includes(tool))
2287
- return 'This tool writes, and the studio cannot make it ask: a called agent runs it, and a question inside a called agent has no one to answer it. The call to that agent asks instead.';
2288
- return undefined;
2289
- }
2290
2279
  /** Who may call the tool, whether it asks first, when it loads and on which paths. */
2291
2280
  function PolicySection({ draft, tool, set, }) {
2292
- const note = studioAskNote(useContext(ProjectAsks), tool.toolName, usePref('askWrites'));
2293
- return (_jsxs(InspectorSection, { title: "Policy", note: note, children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
2281
+ return (_jsxs(InspectorSection, { title: "Policy", children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
2294
2282
  set({ access });
2295
2283
  } }), _jsx(SegmentedRow, { label: "Permission", path: "registerTool.permission", field: "permission", value: tool.permission, segments: PERMISSION_SEGMENTS, onChange: (permission) => {
2296
2284
  set({ permission });
@@ -35,7 +35,6 @@ declare function useStudioWorkspace(start: RestoredStudio, project: ProjectSessi
35
35
  update: (change: (current: StudioWorkspace) => StudioWorkspace) => void;
36
36
  shared: SharedEntry[];
37
37
  origins: import("../server/save-wire.ts").ProjectOrigins | undefined;
38
- asks: import("../asks.ts").StudioAsks | undefined;
39
38
  files: ProjectFiles | undefined;
40
39
  refreshOrigins: () => void;
41
40
  filesChanged: () => void;
@@ -25,7 +25,7 @@ import { IconAdjustmentsHorizontal, IconArrowBarToDown, IconArrowLeft, IconBrows
25
25
  import { profileGraphFacet } from '@theoremjs/agents';
26
26
  import { InPlace, PaneFailure, RaisedPane, useDisclosureMotion, } from '@theoremjs/react/ui';
27
27
  import { canonical } from "../canonical.js";
28
- import { addAgent, addArchitectExample, addProvider, addResearchExample, agentNodeId, compileWorkspace, createBlankDraft, createConsoleExampleDraft, createDecisionExampleDraft, createExampleDraft, createGeminiEmbeddingExampleDraft, createLiveExampleDraft, createNarratorExampleDraft, draftFacets, duplicateAgent, editedSince, excludeFacet, includableFacets, includeFacet, libraryDraft, localProviderAddress, mergedWithFiles, modelBindingNodeId, modelRoute, modelSharers, modelSlots, nodeOrigins, onStudioLocal, openOutcome, originLabel, originPlace, originWay, providerIdOf, providerNodeId, providerUse, rebased, removeAgent, removeLibraryTool, removeProvider, renameProvider, reopened, resetAgent, resetAgentNode, resetLibraryTool, resetProvider, sampleToolInput, scopedNodeId, setToolAllowed, sharedAsk, sharedAt, sharedEntries, studioNodeRef, studioSource, studioTree, toolSpecKeyOf, withAgentDraft, withFilesChosen, withProvider, workspaceNodeRef, workspaceRunAgent, workspaceTree, writeAsk, } from "../mod.js";
28
+ import { addAgent, addArchitectExample, addProvider, addResearchExample, agentNodeId, compileWorkspace, createBlankDraft, createConsoleExampleDraft, createDecisionExampleDraft, createExampleDraft, createGeminiEmbeddingExampleDraft, createLiveExampleDraft, createNarratorExampleDraft, draftFacets, duplicateAgent, editedSince, excludeFacet, includableFacets, includeFacet, libraryDraft, localProviderAddress, mergedWithFiles, modelBindingNodeId, modelRoute, modelSharers, modelSlots, nodeOrigins, onStudioLocal, openOutcome, originLabel, originPlace, originWay, providerIdOf, providerNodeId, providerUse, rebased, removeAgent, removeLibraryTool, removeProvider, renameProvider, reopened, resetAgent, resetAgentNode, resetLibraryTool, resetProvider, sampleToolInput, scopedNodeId, setToolAllowed, sharedAsk, sharedAt, sharedEntries, studioNodeRef, studioSource, studioTree, toolSpecKeyOf, withAgentDraft, withFilesChosen, withProvider, workspaceNodeRef, workspaceRunAgent, workspaceTree, } from "../mod.js";
29
29
  import { slotProviders } from "../requirements.js";
30
30
  import { studioSurface } from "../surface.js";
31
31
  import './studio.css';
@@ -34,8 +34,7 @@ import { createContext, lazy, memo, Suspense, useCallback, useContext, useEffect
34
34
  import { flushSync } from 'react-dom';
35
35
  import { ActingAsButton } from "./acting-as-button.js";
36
36
  import { AddProviderButton } from "./add-provider.js";
37
- import { useConfirmWrite } from "./confirm-write.js";
38
- import { ConfirmWrite, GuardrailTest, ISSUE_ROW_ATTRIBUTE, LeavePage, ListBadges, LocalConnection, ProbedAgent, ProjectAsks, QuestionLink, RowOrigins, RunsOn, WorkspaceContext, } from "./inspector-context.js";
37
+ import { GuardrailTest, ISSUE_ROW_ATTRIBUTE, LeavePage, ListBadges, LocalConnection, ProbedAgent, QuestionLink, RowOrigins, RunsOn, WorkspaceContext, } from "./inspector-context.js";
39
38
  import { ActingAsContext, chatKeyOf, useActingAsState } from "./lib/acting-as.js";
40
39
  import { runsAsConversation } from "./lib/conversation-types.js";
41
40
  import { FACET_ICON } from "./lib/facet-icons.js";
@@ -48,7 +47,7 @@ import { clearConversation, restoreConversation, saveConversation, } from "./lib
48
47
  import { STUDIO_EXAMPLES } from "./lib/studio-examples.js";
49
48
  import { pageInputsOf, sentPageValues, usePageValues } from "./lib/studio-page.js";
50
49
  import { getPref, setPref } from "./lib/studio-prefs.js";
51
- import { NO_ASKS, openInEditor, openProject, ProjectContext, projectCode, readFiles, useProject, } from "./lib/studio-project.js";
50
+ import { openInEditor, openProject, ProjectContext, projectCode, readFiles, useProject, } from "./lib/studio-project.js";
52
51
  import { dropAside, keepReading, keptReading, setAside } from "./lib/studio-restore.js";
53
52
  import { projectKey } from "./lib/studio-session.js";
54
53
  import { closeSettings, openSettings, settingsScreen, useSettingsDoor, } from "./lib/studio-settings.js";
@@ -763,16 +762,11 @@ function keyAndToolMembers(store, page) {
763
762
  return { slot, checks };
764
763
  },
765
764
  toolCredential,
766
- testTool: async (key, input) => {
765
+ testTool: (key, input) => {
767
766
  const tool = store.getDraft().toolSpecs.find((candidate) => candidate.key === key);
768
767
  if (!tool)
769
- return { ok: false, error: 'No such tool.' };
768
+ return Promise.resolve({ ok: false, error: 'No such tool.' });
770
769
  const sample = JSON.stringify(input ?? sampleToolInput(tool.toolName, tool.inputJson) ?? {});
771
- // A tool that writes runs only once the builder read the input and said so.
772
- const ask = writeAsk(tool, sample);
773
- if (ask && !(await page.current.confirmWrite(ask))) {
774
- return { ok: false, error: 'The builder chose not to run it.' };
775
- }
776
770
  return runToolProbe(tool, sample, toolCredential(key), store.getDraft().guardrails);
777
771
  },
778
772
  };
@@ -986,7 +980,6 @@ function useStudioWorkspace(start, project) {
986
980
  update,
987
981
  shared,
988
982
  origins: files?.origins,
989
- asks: files?.asks,
990
983
  files,
991
984
  refreshOrigins,
992
985
  filesChanged,
@@ -2043,10 +2036,8 @@ function useStudioPage(opened) {
2043
2036
  connection.runtime ? 'page' : 'demo', workspace.chatWith, actingAs.actingAs, opened.question);
2044
2037
  useArrivalToast(opened, store);
2045
2038
  const { replaceWorkspace, copy } = usePageActions(store, view, run.setConversation);
2046
- const asking = useConfirmWrite();
2047
2039
  const openKeys = useOpenKeys(view.setKeysOpen);
2048
2040
  const chatRef = useStudioSurface(store, {
2049
- confirmWrite: asking.confirm,
2050
2041
  on: connection.on,
2051
2042
  connection,
2052
2043
  replaceWorkspace,
@@ -2077,7 +2068,6 @@ function useStudioPage(opened) {
2077
2068
  copy,
2078
2069
  chatRef,
2079
2070
  title,
2080
- asking,
2081
2071
  project,
2082
2072
  actingAs,
2083
2073
  };
@@ -2090,7 +2080,7 @@ function useStudioPage(opened) {
2090
2080
  function Studio({ opened }) {
2091
2081
  const page = useStudioPage(opened);
2092
2082
  const { state, connection, view, frame, selected, editing, issueReveal, compile } = page;
2093
- const { goToIssue, sheet, setSheet, run, copy, chatRef, title, asking, project, actingAs } = page;
2083
+ const { goToIssue, sheet, setSheet, run, copy, chatRef, title, project, actingAs } = page;
2094
2084
  const { questionLink } = page;
2095
2085
  const { store, draft } = state;
2096
2086
  const tree = useWorkspaceTree(state, view, selected, setSheet);
@@ -2112,8 +2102,8 @@ function Studio({ opened }) {
2112
2102
  },
2113
2103
  }
2114
2104
  : null, [compile.payload, testing, setSheet]);
2115
- return (_jsx(ProjectContext.Provider, { value: project, children: _jsx(ActingAsContext.Provider, { value: actingAs, children: _jsx(ConfirmWrite, { value: asking.confirm, children: _jsxs(ProjectAsks, { value: state.asks ?? NO_ASKS, children: [asking.dialog, _jsx(SharedChange, { store: state.store }), _jsx(SaveScope, { project: project, state: state, blocked: Boolean(compile.blocked), children: _jsx(QuestionLink, { value: questionLink, children: _jsx(GuardrailTest.Provider, { value: guardrailTest, children: _jsx(Layout, { ref: frame.layoutCallbackRef, className: frameClass(sheet, view.mapOpen, view.settingsOpen), padding: 0, start: _jsx(SidePanel, { frame: frame, tree: tree, draft: draft, onAddAgent: addAgentFrom, setSheet: setSheet, settings: view.settingsOpen &&
2116
- project && (_jsx(SettingsPane, { state: state, connection: connection, project: project, setConversation: run.setConversation })), map: view.mapOpen && (_jsx(Suspense, { fallback: null, children: _jsx(StudioMap, { workspace: state.workspace, shared: state.shared, selected: view.keysOpen ? '' : selected, onOpen: view.open, onClose: closeMap }) })), children: _jsx(EditorColumn, { heading: view.keysOpen ? 'Keys' : title, state: state, connection: connection, view: view, compile: compile, selected: selected, editing: editing, frame: frame, issueReveal: issueReveal, goToIssue: goToIssue, copy: copy, setSheet: setSheet }) }), content: _jsx(PreviewPane, { store: store, chatAgents: chatAgents, chatWith: state.workspace.chatWith, compile: compile, run: run, connection: connection, chatRef: chatRef, setSheet: setSheet, onIssue: goToIssue, testing: testing && Boolean(compile.payload) }) }) }) }) })] }) }) }) }));
2105
+ return (_jsx(ProjectContext.Provider, { value: project, children: _jsxs(ActingAsContext.Provider, { value: actingAs, children: [_jsx(SharedChange, { store: state.store }), _jsx(SaveScope, { project: project, state: state, blocked: Boolean(compile.blocked), children: _jsx(QuestionLink, { value: questionLink, children: _jsx(GuardrailTest.Provider, { value: guardrailTest, children: _jsx(Layout, { ref: frame.layoutCallbackRef, className: frameClass(sheet, view.mapOpen, view.settingsOpen), padding: 0, start: _jsx(SidePanel, { frame: frame, tree: tree, draft: draft, onAddAgent: addAgentFrom, setSheet: setSheet, settings: view.settingsOpen &&
2106
+ project && (_jsx(SettingsPane, { state: state, connection: connection, project: project, setConversation: run.setConversation })), map: view.mapOpen && (_jsx(Suspense, { fallback: null, children: _jsx(StudioMap, { workspace: state.workspace, shared: state.shared, selected: view.keysOpen ? '' : selected, onOpen: view.open, onClose: closeMap }) })), children: _jsx(EditorColumn, { heading: view.keysOpen ? 'Keys' : title, state: state, connection: connection, view: view, compile: compile, selected: selected, editing: editing, frame: frame, issueReveal: issueReveal, goToIssue: goToIssue, copy: copy, setSheet: setSheet }) }), content: _jsx(PreviewPane, { store: store, chatAgents: chatAgents, chatWith: state.workspace.chatWith, compile: compile, run: run, connection: connection, chatRef: chatRef, setSheet: setSheet, onIssue: goToIssue, testing: testing && Boolean(compile.payload) }) }) }) }) })] }) }));
2117
2107
  }
2118
2108
  /** Save for the screen under it, when the studio is open on a project. */
2119
2109
  function SaveScope({ project, state, blocked, children, }) {
@@ -57,12 +57,6 @@ const SETTINGS = [
57
57
  section: 'confirmations',
58
58
  words: 'confirm asking',
59
59
  },
60
- {
61
- id: 'ask-writes',
62
- label: 'Ask before a tool writes',
63
- section: 'confirmations',
64
- words: 'confirm asking destructive run',
65
- },
66
60
  { id: 'keys', label: 'Model keys', section: 'keys', words: 'api key provider' },
67
61
  {
68
62
  id: 'acting-as',
@@ -133,13 +127,8 @@ function FilesSettings({ project, watch, }) {
133
127
  setPref('filesToast', on ? 'on' : 'off');
134
128
  } })] })] }));
135
129
  }
136
- const isAskWrites = (value) => value === 'always' || value === 'destructive';
137
130
  function ConfirmationSettings({ shared }) {
138
- const askWrites = usePref('askWrites');
139
- return (_jsxs(_Fragment, { children: [_jsx(Group, { title: "Shared values", about: "A value several agents share changes on every one of them.", children: _jsx(CheckboxInput, { label: "Ask before changing a shared value", description: "Shows which agents and files the change reaches, before it is made.", value: shared.asks, onChange: shared.set }) }), _jsx(Divider, {}), _jsx(Group, { title: "Tools that write", about: "A real run of a tool that writes can change something outside the studio.", children: _jsxs(RadioList, { label: "Ask before a run", value: askWrites, onChange: (next) => {
140
- if (isAskWrites(next))
141
- setPref('askWrites', next);
142
- }, children: [_jsx(RadioListItem, { value: "always", label: "Every tool that writes", description: "Shows the input the run would send, each time." }), _jsx(RadioListItem, { value: "destructive", label: "Only destructive tools", description: "Tools that read and write run straight away. Tools marked destructive still ask." })] }) })] }));
131
+ return (_jsx(Group, { title: "Shared values", about: "A value several agents share changes on every one of them.", children: _jsx(CheckboxInput, { label: "Ask before changing a shared value", description: "Shows which agents and files the change reaches, before it is made.", value: shared.asks, onChange: shared.set }) }));
143
132
  }
144
133
  const NO_ONE = 'no-one';
145
134
  const personValue = (person) => `person:${person.id}`;
package/asks.d.ts DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * The question the studio puts before a real run of a tool that writes: which tool, how it is
3
- * set, what the run sends, and where. A tool that only reads is run unasked.
4
- *
5
- * @module
6
- */
7
- import type { StageHandler } from '@theoremjs/agents';
8
- import type { ToolSpecDraft } from './draft.ts';
9
- /** What the builder reads before a tool that writes runs. */
10
- export interface WriteAsk {
11
- tool: string;
12
- access: Exclude<ToolSpecDraft['access'], 'read-only'>;
13
- /** The request the run makes, as `METHOD address`. */
14
- sends: string;
15
- /** The input the run sends, as the JSON the builder typed. */
16
- input: string;
17
- }
18
- /**
19
- * The question to put before the editor's Test of `tool`, or undefined when the test needs none:
20
- * the tool only reads, or the test only lists an MCP server's tools and calls none.
21
- */
22
- export declare function writeAsk(tool: ToolSpecDraft, input: string): WriteAsk | undefined;
23
- /** What the question says above the input. */
24
- export declare function writeAskLine(ask: WriteAsk): string;
25
- /** A registered tool, as far as asking goes. An agent tool names the profile it runs. */
26
- export interface AskTool {
27
- name: string;
28
- type: string;
29
- access: string;
30
- permission: string;
31
- profile?: string;
32
- }
33
- /** The header a run carries the builder's choice of which tools that write ask in. */
34
- export declare const ASK_WRITES_HEADER = "x-theorem-studio-ask-writes";
35
- /** The same on a live socket's address: a browser's `WebSocket` sends no headers. */
36
- export declare const ASK_WRITES_PARAM = "ask-writes";
37
- /** Which of a project's tools the studio makes ask, and which it cannot. */
38
- export interface StudioAsks {
39
- /** The tools that ask before each run here and would not in the application. */
40
- asked: string[];
41
- /** Those of `asked` that can reach a destructive tool: they ask whatever the builder chose. */
42
- destructive: string[];
43
- /**
44
- * The tools that write and run unasked: a called agent runs them, and a question inside a called
45
- * agent has no one to answer it. The call to that agent asks instead.
46
- */
47
- inside: string[];
48
- }
49
- /**
50
- * The tools the studio makes ask before each run: every one that writes, and every agent tool
51
- * whose agent can reach one that writes. A tool a called agent runs is left as it is, because the
52
- * kernel refuses a called agent whose tool can stop on a question.
53
- */
54
- export declare function studioAsks(tools: readonly AskTool[], allowed: (profile: string) => readonly string[]): StudioAsks;
55
- /**
56
- * The studio's question before each run of an `asked` tool, as a stage. The tool's registration
57
- * is left as the project set it, so the project's own code reads its own setting. A call the
58
- * builder already approved where it stopped is not asked again. `destructiveOnly` reads the run's
59
- * own choice, since the builder can change it between two runs.
60
- */
61
- export declare function studioAskStage({ asked, destructive }: StudioAsks, destructiveOnly: () => boolean): StageHandler | undefined;
package/asks.js DELETED
@@ -1,78 +0,0 @@
1
- /**
2
- * The question the studio puts before a real run of a tool that writes: which tool, how it is
3
- * set, what the run sends, and where. A tool that only reads is run unasked.
4
- *
5
- * @module
6
- */
7
- /**
8
- * The question to put before the editor's Test of `tool`, or undefined when the test needs none:
9
- * the tool only reads, or the test only lists an MCP server's tools and calls none.
10
- */
11
- export function writeAsk(tool, input) {
12
- if (tool.access === 'read-only' || tool.toolType !== 'http')
13
- return undefined;
14
- return {
15
- tool: tool.toolName,
16
- access: tool.access,
17
- sends: `${tool.method ?? 'GET'} ${tool.endpoint ?? ''}`.trim(),
18
- input: input.trim() || '{}',
19
- };
20
- }
21
- /** What the question says above the input. */
22
- export function writeAskLine(ask) {
23
- const set = ask.access === 'destructive' ? 'destructive' : 'read and write';
24
- return `It is set as ${set}. Run sends a real request: ${ask.sends}`;
25
- }
26
- /** The header a run carries the builder's choice of which tools that write ask in. */
27
- export const ASK_WRITES_HEADER = 'x-theorem-studio-ask-writes';
28
- /** The same on a live socket's address: a browser's `WebSocket` sends no headers. */
29
- export const ASK_WRITES_PARAM = 'ask-writes';
30
- /**
31
- * The tools the studio makes ask before each run: every one that writes, and every agent tool
32
- * whose agent can reach one that writes. A tool a called agent runs is left as it is, because the
33
- * kernel refuses a called agent whose tool can stop on a question.
34
- */
35
- export function studioAsks(tools, allowed) {
36
- const named = new Map(tools.map((tool) => [tool.name, tool]));
37
- const runs = (tool) => tool.type === 'agent' && tool.profile ? allowed(tool.profile) : [];
38
- const inside = new Set(tools.flatMap(runs));
39
- const reaches = (tool, is, seen) => {
40
- if (seen.has(tool.name))
41
- return false;
42
- seen.add(tool.name);
43
- if (is(tool))
44
- return true;
45
- return runs(tool).some((name) => {
46
- const inner = named.get(name);
47
- return inner !== undefined && reaches(inner, is, seen);
48
- });
49
- };
50
- // A provider's built-in tool runs on the provider and never stops on a question.
51
- const writing = tools.filter((tool) => tool.type !== 'builtin' && reaches(tool, (each) => each.access !== 'read-only', new Set()));
52
- const asked = writing.filter((tool) => !inside.has(tool.name) && tool.permission !== 'always_confirm');
53
- return {
54
- asked: asked.map((tool) => tool.name),
55
- destructive: asked
56
- .filter((tool) => reaches(tool, (each) => each.access === 'destructive', new Set()))
57
- .map((tool) => tool.name),
58
- inside: writing.filter((tool) => inside.has(tool.name)).map((tool) => tool.name),
59
- };
60
- }
61
- /** What a question the studio puts before a tool that writes says. */
62
- const STUDIO_ASK_SUMMARY = 'The studio asks before every run of a tool that writes.';
63
- /**
64
- * The studio's question before each run of an `asked` tool, as a stage. The tool's registration
65
- * is left as the project set it, so the project's own code reads its own setting. A call the
66
- * builder already approved where it stopped is not asked again. `destructiveOnly` reads the run's
67
- * own choice, since the builder can change it between two runs.
68
- */
69
- export function studioAskStage({ asked, destructive }, destructiveOnly) {
70
- if (asked.length === 0)
71
- return undefined;
72
- return (ctx) => ctx.stage === 'pre_tool' &&
73
- !ctx.approved &&
74
- ctx.tool !== undefined &&
75
- (destructiveOnly() ? destructive : asked).includes(ctx.tool)
76
- ? { confirm: { summary: STUDIO_ASK_SUMMARY } }
77
- : undefined;
78
- }
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TraceInspector-36e6ozKD.js","assets/rolldown-runtime-hePW80VL.js","assets/themeProps-3IqahpCr.js","assets/tokens.stylex-DkHf0P9C.js","assets/SegmentedControlItem-CZs-ycSA.js","assets/padding.stylex-B76907Zf.js","assets/VStack-CkVMcNiK.js","assets/mergeProps-ptS-gIMz.js","assets/StackItem-CQviqAfM.js","assets/useLayerDismissal-BAnTRYTt.js","assets/fieldParts-CoOpDoax.js","assets/Icon-BqkS-pIq.js","assets/devWarning-DxuplmRl.js","assets/Text-BOqCfzZC.js","assets/sharedResizeObserver-4U9Xq5Oq.js","assets/preload-helper-DpV6A1kQ.js","assets/useMediaQuery-BCT0NUeZ.js","assets/useResolvedRequired-DbsOcDqy.js","assets/useAnnounce-DTSHZvjg.js","assets/Tooltip-BWs5DLrM.js","assets/useTooltip-c097gL_-.js","assets/focusOutline.stylex-BT0kfa4t.js","assets/IconButton-DVUFx-8p.js","assets/focusableSelector-DXZeMU85.js","assets/useDevWarning-Z9SoixOP.js","assets/createReactComponent-CZwsv6DD.js","assets/isRtlElement-BG33-k_H.js","assets/plainDate-BHiJcj7o.js","assets/DateInput-CalwZl6a.js","assets/focusReturn-CTppP2k0.js","assets/Card-DruykyeB.js","assets/container.stylex-BmOi-8DQ.js","assets/ScrollableArea-ChTx-OVZ.js","assets/useScrollableArea-DuF_pz9m.js","assets/chainEventHandlers-C6ttXGfW.js","assets/BottomSheet-Dbh6A5Vl.js","assets/useScrollLock-Dyf6PHJt.js","assets/SidePanel-DEd3R1Q3.js","assets/CheckboxInput-CFZ_Wq8-.js","assets/isRenderable-DHkzpAoQ.js","assets/IconAlertTriangle-BqAEqqdU.js","assets/row-keys-WByP9Hsh.js","assets/IconShield-DDOh7Gr5.js","assets/shaped-data-CJQ3W_RE.js","assets/host-patterns-F-KZIzkF.js","assets/trace-record-DoXjxrmJ.js","assets/TraceOverview-CSdJ_cYY.js","assets/labels-provider-t4c-5JMk.js","assets/CodeBlock-CfVOtDeO.js","assets/useClipboard-CbN9bb4J.js","assets/index-B7sK7d-l.js","assets/browser-transport-GzhRiBdm.js","assets/Center-CgO0c-qo.js","assets/IconSearch-BTx66a40.js","assets/schemas-D7cgkv3L.js","assets/tool-schema-BDG2_rlP.js","assets/reader-DHN96tSr.js","assets/browser-connection-dads1eyK.js","assets/live-ingress-OuSlQ6q7.js","assets/trace-schema--4IGmLeE.js","assets/stub-U6wDGe3P.js","assets/Dialog-Sd04KQS2.js","assets/HoverCard-DMyWUvwP.js","assets/IconEye-BB5aY-wQ.js","assets/studio-labels-jYWBoEyP.js","assets/turn-client-BmOSpCgw.js","assets/encode-files-CHeRLBO8.js","assets/CollapsibleGroup-BsIYDnJR.js","assets/tree-CcEbNvms.js","assets/crypto-B8dqEoWf.js","assets/use-second-ticker-CWjCHLG6.js","assets/use-second-ticker-GWBt83pd.css","assets/workspace-DUfaxr-g.js","assets/lent-keys-C32ems-I.js","assets/editors-BJX_S59A.js","assets/project-address-DjxPZuyn.js","assets/studio-session-CPnJaHc-.js","assets/EmptyState-C_uF9Wyj.js","assets/useMenuPress-DLG1QOiE.js","assets/useAdaptivePresentation-Bma4-u1a.js","assets/useFocusReturnVisibility-BHKv5Jwr.js","assets/ListItem-QF7KFt0h.js","assets/index-C9rhrCGT.css","assets/trace-patterns-D6TbkLLr.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n,n as r,u as i}from"./themeProps-3IqahpCr.js";import{h as a}from"./tokens.stylex-DkHf0P9C.js";import{t as o}from"./mergeProps-ptS-gIMz.js";import{b as s}from"./fieldParts-CoOpDoax.js";import{t as c}from"./isRenderable-DHkzpAoQ.js";import{t as l,x as u}from"./Icon-BqkS-pIq.js";import{T as d,c as f,d as p,l as m,m as h,p as g,s as _,t as v,u as y}from"./SidePanel-DEd3R1Q3.js";import{t as b}from"./preload-helper-DpV6A1kQ.js";import{n as ee,t as te}from"./labels-provider-t4c-5JMk.js";import{c as ne,n as re}from"./IconButton-DVUFx-8p.js";import{t as x}from"./createReactComponent-CZwsv6DD.js";import{a as ie}from"./ScrollableArea-ChTx-OVZ.js";import{F as ae,R as S,St as oe,Y as C,_ as se,h as w,i as T,j as E,q as D,v as ce,vn as O,z as k}from"./tool-schema-BDG2_rlP.js";import{c as A,r as le}from"./host-patterns-F-KZIzkF.js";import{Gn as j,Pn as M,Rn as N,Rr as ue,Sr as P,Un as F,Vn as de,an as fe,gr as I,in as pe,jn as me,vr as he}from"./shaped-data-CJQ3W_RE.js";import{C as L,G as R,J as ge,K as _e,S as z,U as ve,_ as ye,h as be,l as xe,m as Se,q as Ce,s as we,t as B}from"./tree-CcEbNvms.js";import{B as Te,_ as Ee,c as De,h as Oe,u as V}from"./browser-connection-dads1eyK.js";import{a as ke,r as Ae}from"./live-ingress-OuSlQ6q7.js";import{n as je,r as Me}from"./use-second-ticker-CWjCHLG6.js";var Ne=x(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),Pe=x(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),H=`••••`,Fe=/auth|key|token|secret|passw|pwd|cookie|session|signature|^sig$|credential|^code$|appid/i,Ie=/auth|key|token|secret|passw|pwd|signature|credential|appid/i,Le=[[/^AIza/,`Google API key`],[/^sk-or-/,`OpenRouter key`],[/^sk-ant-/,`Anthropic key`],[/^sk-/,`OpenAI key`],[/^(?:ghp_|github_pat_)/,`GitHub token`],[/^xox[baprs]-/,`Slack token`],[/^AKIA/,`AWS access key id`],[/^eyJ[\w-]+\.[\w-]+\./,`JWT`],[/^Bearer\s/i,`a whole Bearer header, not a bare token`],[/^https?:\/\//i,`a URL, not a key`]],Re=16;function ze(e,t={}){let n=typeof e==`string`?e:``,r=n.trim(),i=[];/^(?:<.*>|x{3,}|\.{3}|your[-_ ]?(?:api[-_ ]?)?key|changeme|todo)$/i.test(r)?i.push(`a placeholder, not a real value`):(r&&r!==n&&i.push(`spaces or a line break around it`),/[\r\n]/.test(r)?i.push(`a line break inside`):/\s/.test(r)&&i.push(`a space inside`),/^(['"`]).*\1$/.test(r)&&i.push(`wrapped in quotes`),r&&r.length<Re&&i.push(`shorter than keys usually are`));let a=Le.find(([e])=>e.test(r))?.[1];return{secret:!0,set:r.length>0,...a?{looksLike:a}:{},problems:i,sameAs:[...t.sameAs??[]],usedBy:[...t.usedBy??[]]}}var U=/^([a-z][a-z0-9+.-]*:\/\/)([^/?#@]*)@/i,W=/([?&;])([^=?&;#\s]*)=([^&;#\s]*)/g;function G(e){let t=e.indexOf(`:`);return t<0?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function Be(e){try{return decodeURIComponent(e)}catch{return e}}function K(e){return Fe.test(e)}function Ve(e){let t=URL.canParse(e)?Fe:Ie;return e.replace(U,(e,t,n)=>{let[r,i]=G(n);return`${t}${r&&`••••`}${i===void 0?``:`:${i&&`••••`}`}@`}).replace(W,(e,n,r,i)=>i&&t.test(Be(r))?`${n}${r}=${H}`:e)}function He(e,t){let[n,r]=G(U.exec(t)?.[2]??``),i=new Map;for(let[,,e=``,n=``]of t.matchAll(W))i.set(e,[...i.get(e)??[],n]);return e.replace(U,(e,t,i)=>{let[a,o]=G(i),s=a===`••••`&&n?n:a,c=o===`••••`&&r?r:o;return`${t}${s}${c===void 0?``:`:${c}`}@`}).replace(W,(e,t,n,r)=>{let a=r===`••••`?i.get(n)?.shift():void 0;return a?`${t}${n}=${a}`:e})}function Ue(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n===`••••`?t?.[e]??n:n]))}function We(e){if(e==null||e===``)return e;let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return`(not a JSON object, ${String(e.length)} characters)`}if(typeof t!=`object`||!t||Array.isArray(t))return`(not a JSON object)`;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,K(e)?H:t]));return typeof e==`string`?JSON.stringify(n):n}var Ge=/\{\s*private\s*:/g;function Ke(e,t){return e.slice(0,t).split(`
3
- `).length}function qe(e){let t=[],n=0;for(let r of e.matchAll(Ge)){if(r.index<n)continue;let i=1,a=r.index+r[0].length;for(;a<e.length&&i>0;a++)e[a]===`{`?i++:e[a]===`}`&&i--;if(i>0)return{ok:!1,message:`The {private: section on line ${String(Ke(e,r.index))} has no closing }.`};let o=e.slice(r.index+r[0].length,a-1).trim();if(!o)return{ok:!1,message:`The {private: section on line ${String(Ke(e,r.index))} is empty.`};t.push(e.slice(n,r.index),{private:o}),n=a}if(t.push(e.slice(n)),t.length===1)return{ok:!0,prompt:e.trim()||void 0};let r=t[0],i=t.at(-1);return typeof r==`string`&&(t[0]=r.trimStart()),typeof i==`string`&&(t[t.length-1]=i.trimEnd()),{ok:!0,prompt:t.filter(e=>e!==``)}}var Je=()=>void 0,Ye=()=>void 0;function q(e){return(e??[]).map(e=>e.trim()).filter(Boolean)}function J(e,t,n,r,i,a){i===null||Number.isInteger(i)&&i>=a||e(t,`${r} must be a ${a?`positive`:`non-negative`} whole number.`,n)}var Xe={agentId:{label:`Profile id`,max:64},handle:{label:`Handle`,max:32}};function Ze(e,t,n){let{label:r,max:i}=Xe[t];n.trim()?Array.from(n).length>i&&e(`identity`,`${r} is at most ${i} characters.`,t):e(`identity`,`${r} is required.`,t)}function Qe(e,t){Ze(t,`agentId`,e.identity.agentId),e.identity.profileType!==`host`&&Ze(t,`handle`,e.identity.handle)}function $e(e,t,n,r){let i=B(e.key),a=E(n,t,{...e,apiId:e.apiId.trim()}),o=n.find(t=>t.id===e.provider);if(!o)r(i,`No provider is defined as ${e.provider}.`,`provider`);else if(!k(o,t))r(i,`${e.provider} doesn't serve ${t} agents.`,`provider`);else if(!k(o,t,e.protocol)){let n=(S(o,t)??[]).map(e=>e.id).join(` or `);r(i,n?`${e.provider} runs ${t} agents on ${n}, not ${e.protocol}.`:`${e.provider} doesn't serve ${t} agents on ${e.protocol}.`,`protocol`)}return a.apiId||r(i,`API model is required.`,`apiId`),a}function et(e){return e.length<2?e[0]??``:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function tt(e,t){let n=ae(e).map(e=>e.path.split(`.`)[0]??e.path).find(e=>e.toLowerCase()===t.toLowerCase());return n?`${e.id} has no option ${t}. Did you mean ${n}?`:`${e.id} has no option ${t}.`}function nt(e,t,n,r){let i={};e.efforts.forEach(({alias:a,level:o},s)=>{let c=a.trim();c?c in i?r(n,`Effort alias '${c}' is used twice.`,`efforts`,s):i[c]=o:r(n,`Every effort needs an alias.`,`efforts`,s),w(t)&&!C.includes(o)&&r(n,`${e.provider} takes the ${et(C)} thinking level, not ${o}.`,`efforts`,s)}),e.allowEffortSelect&&Object.keys(i).length<2&&r(n,`Effort select needs at least two efforts.`,`allowEffortSelect`);let a=e.defaultEffort.trim();if(!a&&_e(e))r(n,`Pick a default effort — there is more than one.`,`defaultEffort`);else if(a&&!(a in i)){let e=Object.keys(i);r(n,e.length?`Default effort '${a}' is not one of the efforts. Pick ${et(e)}.`:`Default effort '${a}' is not one of the efforts.`,`defaultEffort`)}return{efforts:i,defaultEffort:a}}function rt(e,t,n,r,i){let a=B(e.key),o=$e(e,t,n,r),{apiId:s}=o,{efforts:c,defaultEffort:l}=nt(e,o,a,r),u=Object.keys(c).length;J(r,a,`maxOutputTokens`,`Max output tokens`,e.maxOutputTokens,1),e.temperature!==null&&!(Number.isFinite(e.temperature)&&e.temperature>=0)&&r(a,`Temperature must be zero or more.`,`temperature`),at(e,n,t,a,r);let d=ot(e,t,a,r,i),f=it(e,a,r);return{protocol:e.protocol,provider:e.provider,apiId:s,...e.keySlot?{keySlot:e.keySlot}:{},...e.fallbackKeySlot?{fallbackKeySlot:e.fallbackKeySlot}:{},...u?{efforts:c}:{},...l?{defaultEffort:l}:{},...e.allowEffortSelect?{allowEffortSelect:!0}:{},...e.summaries===null?{}:{summaries:e.summaries},...e.maxOutputTokens===null?{}:{maxOutputTokens:e.maxOutputTokens},...e.temperature===null?{}:{temperature:e.temperature},...e.builtInTools.length?{builtInTools:[...e.builtInTools]}:{},...Object.keys(e.options).length?{options:e.options}:{},...f?{limits:f}:{},...d?{compaction:d}:{}}}function it(e,t,n){let r={};for(let{name:i,label:a,isTimer:o}of be){let s=e.limits?.[i]??null;s!==null&&(J(n,t,`limits.${i}`,a,s,1),o&&s>2147483647&&n(t,`${a} must be at most ${ye} ms.`,`limits.${i}`),r[i]=s)}return Object.keys(r).length?r:void 0}function at(e,t,n,r,i){let a=t.find(t=>t.id===e.provider),o=a&&S(a,n)?.find(t=>t.id===e.protocol);for(let t of o?.options.safeParse(e.options).error?.issues??[]){let e=t.code===`unrecognized_keys`?t.keys[0]:t.path[0];i(r,o&&t.code===`unrecognized_keys`&&typeof e==`string`?tt(o,e):t.message,typeof e==`string`?`options.${e}`:`options`)}let s=e.apiId.trim();for(let t of s?o?.refusedOptions?.(s)??[]:[])e.options[t]!==void 0&&i(r,`${s} takes no ${t}.`,`options.${t}`)}function ot(e,t,n,r,i){let a=e.compactTiming;if(!a)return;t!==`text`&&r(n,`Only a text agent compacts its own history.`,`compactTiming`);let o=e.compactMaxTokens??null,s=e.compactAt??xe.compactAt,c=e.compactKeep??null;o===null&&r(n,`Compaction needs a budget.`,`compactMaxTokens`),J(r,n,`compactMaxTokens`,`Budget`,o,1),s>0&&s<1||r(n,`Compaction must start between 0 and 1 of the budget.`,`compactAt`),c!==null&&(c===0||Number.isInteger(c)&&c>=1||c>0&&c<s)||r(n,`Keep a whole number of exchanges, a fraction of the budget below where compaction starts, or 0.`,`compactKeep`);let l=e.compactWith??``,u=l?i(l):void 0;return l&&!u&&r(n,`The agent that summarised is gone. Pick another, or this agent.`,`compactWith`),{maxTokens:o??0,compactAt:s,...u?{profile:u}:{},previousExchanges:c??0,timing:a,...e.compactMeter?{meter:e.compactMeter}:{}}}function st(e,t,n){let{models:r,modelBindings:i}=e;i.length||n(`models`,`Add at least one model.`);let a=r.defaultModel.trim();return a&&!(a in t)?n(`models`,`Default model '${a}' is not one of the models.`,`defaultModel`):!a&&Ce(e)&&n(`models`,`Pick a default model — there is more than one.`,`defaultModel`),r.maxSteps!==null&&!Number.isInteger(r.maxSteps)&&n(`models`,`Max steps must be a whole number.`,`maxSteps`),a}function ct(e,t,n,r){let{models:i,modelBindings:a}=e,o={};for(let s of a){let a=rt({...s,keySlot:s.keySlot||i.key||void 0,fallbackKeySlot:s.fallbackKeySlot||i.fallbackKey||void 0},t,e.providers,n,r),c=s.modelId.trim(),l=B(s.key);c?c in o?n(l,`Model id '${c}' is used twice.`,`modelId`):o[c]=a:n(l,`Model id is required.`,`modelId`)}let s=st(e,o,n),c=i.providerHistory===`provider`||i.providerHistory===`stateless`?i.providerHistory:void 0;return{models:o,...s?{defaultModel:s}:{},...c?{providerContinuation:{history:c}}:{},...i.allowModelSelect?{allowModelSelect:!0}:{},...i.maxSteps===null?{}:{maxSteps:i.maxSteps}}}function Y(e,t){if(!e?.trim())return;let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=Object.entries(n);return r.every(([,e])=>t(e))?r.length?Object.fromEntries(r):void 0:null}var lt=e=>typeof e==`string`,ut=e=>!0;function dt(e){return Y(e,lt)}var ft=e=>Array.isArray(e)&&e.every(lt);function pt(e){return Y(e,ft)??{}}function mt(e,t){let n=Y(e.identity.conditionsJson,ft);n===null&&t(`identity`,`Conditions must be a JSON object of lists of values.`,`conditionsJson`);let r=e.identity.system.flatMap(({text:e})=>{let n=qe(e);return n.ok||t(`identity`,n.message,`system`),n.ok&&n.prompt!==void 0?[n.prompt]:[]}),[i]=r,a=r.length===0?void 0:r.length===1&&typeof i==`string`?i:r,o=n??void 0;if(a!==void 0&&n!==null){let n=Object.fromEntries(e.inputs.slots.map(e=>[e.name.trim(),e.choices.map(e=>e.value.trim()).filter(Boolean)])),r=Te(a,o,n);r&&t(`identity`,r,`system`)}return{system:a,conditions:o}}function ht(e,t,n){let r=Y(e,t);return r===null&&n(),r??void 0}function gt(e,t){if(!e.authType||e.authType===`none`)return;let n=e.authService?.trim()??``;n||t(`Service is required.`,`authService`);let r=q(e.authScopes),i=e.authType===`api_key`?e.authQueryParam?.trim():void 0;i&&q(e.queryParams).includes(i)&&t(`${i} is also one of the query parameters the model fills.`,`authQueryParam`);let a=i?{queryParam:i}:{...e.authHeaderName?.trim()?{headerName:e.authHeaderName.trim()}:{},...e.authHeaderPrefix===void 0?{}:{headerPrefix:e.authHeaderPrefix}};return{slot:e.authSlot?.trim()||`default`,type:e.authType,service:n,...a,onUnauthenticated:e.authUnauthenticated??`gate`,...r.length?{scopes:r}:{},...e.authClientId?.trim()?{clientId:e.authClientId.trim()}:{},...e.authRedirectUri?.trim()?{redirectUri:e.authRedirectUri.trim()}:{}}}function _t(e){try{return new URL(e),!0}catch{return!1}}function vt(e,t){e?se(e)&&t(`${e} is a provider builtin — turn it on under the model's built-in tools.`,`toolName`):t(`Tool name is required.`,`toolName`)}function yt(e,t,n){let r=e.toolName.trim();vt(r,t);let i=e.description.trim();i||t(`Description is required.`,`description`);let a=e.toolType===`agent`?{inputSchema:n(e.agentKey??``)??xt,outputSchema:St}:bt(e,t),o=q(e.paths);return{name:r,description:i,category:e.category.trim()||`studio`,access:e.access,permission:e.permission,loadTier:e.loadTier,paths:o.length?o:[`*`],...e.after?{after:!0}:{},...a}}function bt(e,t){let n=T(e.inputJson,`Input`);n.ok||t(n.error,`inputJson`);let r=T(e.outputJson,`Output`);return r.ok||t(r.error,`outputJson`),{inputSchema:n.ok?n.schema:{},outputSchema:r.ok?r.schema:{}}}var xt=V(Oe({type:`text`}),`input`),St=V(Ee,`output`);function Ct(e){let t=e.identity.profileType;if(t!==`text`&&t!==`image`&&t!==`speech`)return;let n=t!==`speech`&&L(e).includes(`inputs`)?zt(e.inputs,t,()=>{}):void 0;return V(Oe({type:t,...n?{inputs:n}:{}}),`input`)}function wt(e){return(e??``).split(`
4
- `).map(e=>e.trim()).filter(Boolean)}function Tt(e,t,n){let r={},i={activity:{input:t.inputSchema},activityPast:{input:t.inputSchema,output:t.outputSchema},activityFailed:{input:t.inputSchema},request:{input:t.inputSchema}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let a=wt(e[t]),[o]=a;if(o===void 0)continue;let s=a.length===1?o:a,c=oe(s,i[t]);c?n(c,t):r[t]=s}return Object.keys(r).length?r:void 0}function Et(e){let t=Object.entries(e??{}).find(([e,t])=>K(e)&&t!==`••••`)?.[0];return t?`${t} looks like a credential. Put it under Auth instead: Auth asks for it when a call runs and nothing saves it.`:void 0}function Dt(e){if(!e||!URL.canParse(e))return;let t=[...new URL(e).searchParams].find(([e,t])=>K(e)&&t&&t!==`••••`)?.[0];return t?`${t} in the URL looks like a credential. Put it under Auth instead, as an API key with ${t} as its query parameter: Auth asks for it when a call runs and nothing saves it.`:void 0}function Ot(e,t){let n=dt(e.headersJson);n===null&&t(`Headers must be a JSON object of strings. Until they are, a reload brings back the headers as they started.`,`headersJson`);let r=Et(n??void 0);r&&t(r,`headersJson`);let i=e.toolType===`mcp`?`serverUrl`:`endpoint`,a=Dt(e[i]?.trim());a&&t(a,i);let o=gt(e,t),s=e.maxResponseBytes??null;return s!==null&&!(Number.isInteger(s)&&s>=1)&&t(`Max response must be a positive whole number.`,`maxResponseBytes`),{...n?{headers:n}:{},...o?{auth:o}:{},...s===null?{}:{maxResponseBytes:s}}}function kt(e,t,n,r){let i=e[t]?.trim()??``;return i?_t(i)||r(`${n} must be a full URL.`,t):r(`${n} is required.`,t),i}function At(e,t,n){let r=kt(e,`endpoint`,`Endpoint URL`,n),i=q(e.pathParams),a=q(e.queryParams),o=e.bodyParam?.trim(),s={...i.length?{pathParams:i}:{},...a.length?{queryParams:a}:{},...o?{bodyParam:o}:{}};return{type:`http`,...t,endpoint:r,method:e.method??pe[0],...Ot(e,n),...Object.keys(s).length?{mapping:s}:{}}}function jt(e,t,n){let r=kt(e,`serverUrl`,`MCP server URL`,n),i=e.mcpToolName?.trim()??``;return i||n(`MCP tool name is required.`,`mcpToolName`),{type:`mcp`,...t,serverUrl:r,mcpToolName:i,...Ot(e,n),...Mt(e,n)}}function Mt(e,t){let n=e.sessionIdleMs??null,r=e.sessionMax??null;n!==null&&!(Number.isInteger(n)&&n>=1)&&t(`Idle must be a positive whole number.`,`sessionIdleMs`),r!==null&&!(Number.isInteger(r)&&r>=1)&&t(`Max must be a positive whole number.`,`sessionMax`);let i={...n===null?{}:{idleMs:n},...r===null?{}:{max:r}};return Object.keys(i).length?{session:i}:{}}function Nt(e,t,n){let r=e.answeredBy===`page`?{answeredBy:`page`}:{};if(!e.stubOutputJson?.trim())return{type:`function`,...t,...r};let i=T(e.stubOutputJson,`Stub output`);return i.ok||n(i.error.replace(` JSON Schema`,``),`stubOutputJson`),{type:`function`,...t,...r,...i.ok?{stubResponse:i.schema}:{}}}function Pt(e,t,n,r){let i=e.agentKey??``,a=i?r(i):void 0;i?a||n(`The agent this tool ran is gone. Pick another.`,`agentKey`):n(`Pick the agent this tool runs.`,`agentKey`);let o=e.maxCallsPerTurn??null;return o!==null&&!(Number.isInteger(o)&&o>=1)&&n(`Calls per turn must be a positive whole number.`,`maxCallsPerTurn`),{type:`agent`,...t,profile:a??``,...o===null?{}:{maxCallsPerTurn:o}}}var Ft={http:At,mcp:jt,function:Nt,agent:Pt};function It(e){return je.includes(e)}function Lt(e,t,n,r){let i=we(e.key);if(!It(e.toolType)){t(i,Me,`toolType`);return}let a=!1,o=(e,n)=>{a=!0,t(i,e,n)},s=yt(e,o,r),c=Tt(e,s,o),l=Ft[e.toolType](e,s,o,n),u=e.toolType===`agent`?``:e.stageAgentKey?.trim()??``,d=u?n(u):void 0;return a?void 0:{...l,...c?{labels:c}:{},...d&&l.type!==`agent`?{stageAgent:d}:{}}}function Rt(e,t,n,r,i,a){let o=[],s=new Set;for(let t of e.toolSpecs){let e=Lt(t,r,i,a);e&&(s.has(e.name)?r(we(t.key),`Tool name '${e.name}' is used twice.`,`toolName`):(s.add(e.name),o.push(e)))}let c=o.map(e=>e.name),l=t?e.tools.t2Loader.trim():``;l&&!s.has(l)&&r(`tools`,`T2 loader '${l}' must be one of the custom tools.`,`t2Loader`);let u=n&&e.tools.parallel;return{customTools:o,tools:{allow:c,...l?{t2Loader:l}:{},...u?{parallel:u}:{}}}}function zt(e,t,n){let r=t===`image`?e.attachmentsAccept.filter(e=>!O(fe,e)):[];if(r.length&&n(`inputs`,`An image profile takes images, video, and PDF only, not ${r.join(`, `)}.`,`attachmentsAccept`),!e.text&&!e.attachmentsAccept.length&&!e.voiceAccept.length&&n(`inputs`,`Take text, files, or voice notes: with none, the agent can be sent nothing.`,`text`),ge(e)){let t=[[`maxFiles`,`Max files`,e.maxFiles],[`maxBytes`,`Max bytes`,e.maxBytes],[`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes]];for(let[e,r,i]of t)i===null&&n(`inputs`,`${r} is required with attachments or voice.`,e)}J(n,`inputs`,`maxFiles`,`Max files`,e.maxFiles,1),J(n,`inputs`,`maxBytes`,`Max bytes`,e.maxBytes,1),J(n,`inputs`,`maxTurnBytes`,`Max turn bytes`,e.maxTurnBytes,1);let i=Vt(e,n),a=Ut(e,n),o=Bt(e,n);return{...e.text?{}:{text:!1},...e.attachmentsAccept.length?{attachments:{accept:[...e.attachmentsAccept]}}:{},...e.voiceAccept.length?{voice:{accept:[...e.voiceAccept]}}:{},...e.maxFiles===null?{}:{maxFiles:e.maxFiles},...e.maxBytes===null?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===null?{}:{maxTurnBytes:e.maxTurnBytes},...i?{limitsByMime:i}:{},...a?{slots:a}:{},...o?{context:o}:{}}}function Bt(e,t){if(e.contextFrom.length)return e.contextMaxChars===null&&t(`inputs`,`Max characters is required with context.`,`contextMaxChars`),J(t,`inputs`,`contextMaxChars`,`Max characters`,e.contextMaxChars,1),{from:[...e.contextFrom],maxChars:e.contextMaxChars??0}}function Vt(e,t){let n=Object.entries(e.limitsByMime);for(let[e,r]of n)Number.isInteger(r)&&r>=1||t(`inputs`,`Max size for ${e} must be a whole number of at least 1.`,`limitsByMime`);return n.length?{...e.limitsByMime}:void 0}function Ht(e,t,n){let r=e.name.trim(),i=[];r?n.findIndex(e=>e.name.trim()===r)<t&&i.push(`Another slot is called ${r}.`):i.push(`Name this slot.`);let a=e.choices.map(e=>e.value.trim());a.some(Boolean)||i.push(`Give this slot a choice.`),e.choices.some((e,t)=>!a[t]&&e.description.trim())&&i.push(`Every choice with a description needs a value.`);let o=a.filter((e,t)=>e&&a.indexOf(e)<t);for(let e of new Set(o))i.push(`${e} is a choice twice.`);return i}function Ut(e,t){if(e.slots.length)return e.slots.forEach((n,r)=>{for(let i of Ht(n,r,e.slots))t(`inputs`,i,`slots`,r)}),Object.fromEntries(e.slots.map(e=>{let t=e.label.trim(),n=e.choices.filter(e=>e.value.trim()).map(e=>({value:e.value.trim(),description:e.description.trim()})),r=!t&&n.every(e=>!e.description)?n.map(e=>e.value):{...t?{label:t}:{},choices:n.map(({value:e,description:t})=>t?{value:e,description:t}:{value:e})};return[e.name.trim(),r]}))}function Wt(e,t){let n=Ut(e,t),r=Bt(e,t);return!n&&!r?{}:{inputs:{...n?{slots:n}:{},...r?{context:r}:{}}}}function Gt(e,t,n){let{slot:r,shapes:i}=e.bySlot??{slot:``,shapes:[]},a=[],o={};for(let e of i){let t=T(e.schemaJson,`The reply shape for '${e.choice}'`);t.ok?(a.push({id:e.schemaId,spec:{jsonSchema:t.schema}}),o[e.choice]=e.schemaId):n(`outputs`,t.error,`schemaJson`)}return a.length?{also:a,written:{by:r,map:o,fallback:t}}:void 0}function Kt(e,t,n){let r,i=t&&e.validationEnabled;if(t&&e.mode===`structured`){let t=e.schemaId.trim();t||n(`outputs`,`Structured output needs a schema id.`,`schemaId`);let i=T(e.schemaJson,`Structured output`);i.ok||n(`outputs`,i.error,`schemaJson`),t&&i.ok&&(r={id:t,spec:{jsonSchema:i.schema}})}let a=r&&Gt(e,r.id,n);r&&a&&(r={...r,also:a.also}),i&&J(n,`outputs`,`maxRetries`,`Validation max retries`,e.maxRetries,0);let o=Object.fromEntries(Object.entries(e.itemRules).map(([e,t])=>[e,{onFail:t}])),s=i?{...e.maxRetries===null?{}:{maxRetries:e.maxRetries},...Object.keys(o).length?{items:o}:{}}:{},c={...e.streamMode?{mode:e.streamMode}:{},...e.streamThoughts?{}:{streamThoughts:!1}},l={...r?{structured:a?.written??r.id}:{},...Object.keys(s).length?{validation:s}:{},...Object.keys(c).length?{streaming:c}:{}};return{...Object.keys(l).length?{outputs:l}:{},...r?{structured:r}:{}}}function qt(e,t){return e.resumeEnabled?(J(t,`turnBehaviour`,`maxContinues`,`Max continues`,e.maxContinues,1),{allowContinue:[...e.allowContinue],autoContinue:[...e.autoContinue],...e.maxContinues===null?{}:{maxContinues:e.maxContinues}}):{allowContinue:[],autoContinue:[]}}function Jt(e,t,n){let r=t?qt(e,n):void 0,i={...r?{resumption:r}:{},...e.allowSteering?{}:{allowSteering:!1},...e.atStepLimit===`answer`?{atStepLimit:e.atStepLimit}:{}};return Object.keys(i).length?i:void 0}function Yt(e,t,n,r){let i=[],a=e=>t.has(e)||t.has(`labels`),{turnBehaviour:o,guardrails:s,outputs:c}=e;if(a(`turnBehaviour`)&&ve(e)&&i.push([`turnBehaviour`,`continueInstruction`,`continue.instruction`,o.continueInstruction.trim()]),a(`guardrails`)&&n(`identity.system`)&&i.push([`guardrails`,`canaryBindNote`,`canary.bind_note`,s.canaryBindNote.trim()]),a(`guardrails`)&&n(`guardrails.quota`)&&i.push([`guardrails`,`quotaMessage`,`quota.exhausted`,s.quotaMessage.trim()]),a(`outputs`)&&n(`outputs.validation`)&&i.push([`outputs`,`repairGuidance`,`repair.default_guidance`,c.repairGuidance.trim()]),a(`guardrails`)&&n(`guardrails.blockedReply`)&&(i.push([`guardrails`,`egressRepairGuidance`,`egress.default_repair_guidance`,s.egressRepairGuidance.trim()]),i.push([`guardrails`,`egressRefusal`,`egress.refusal`,s.egressRefusal.trim()])),t.has(`labels`))for(let[t,n]of Object.entries(e.labels))Se[t]||i.push([`labels`,t,t,n.trim()]);let l={};for(let[e,t,n,a]of i)if(a)try{ue({[n]:a},`Profile labels`),l[n]=a}catch(n){r(e,P(n),t)}return Object.keys(l).length?l:void 0}function Xt(e,t){if(e.quotaEnabled){if(e.quotaPerDay===null)t(`guardrails`,`Quota needs turns per day.`,`quotaPerDay`);else return J(t,`guardrails`,`quotaPerDay`,`Quota per day`,e.quotaPerDay,1),{perDay:e.quotaPerDay}}}function Zt(e,t){J(t,`guardrails`,`blockedReplyMaxRetries`,`Blocked reply max retries`,e.blockedReplyMaxRetries,0);let n={...e.blockedReplyOnBlock?{onBlock:e.blockedReplyOnBlock}:{},...e.blockedReplyMaxRetries===null?{}:{maxRetries:e.blockedReplyMaxRetries}};return Object.keys(n).length?n:void 0}function Qt(e){return $t(e,()=>{})}function $t(e,t){let n=e.allowedHosts.map(e=>e.trim()),r=n.indexOf(``);r!==-1&&t(`guardrails`,`Allowed hosts cannot be blank.`,`allowedHosts`,r);let i=q(e.allowedSchemes);if(e.allowPrivateNetworks||n.length||i.length)return{...e.allowPrivateNetworks?{allowPrivateNetworks:!0}:{},...n.length?{allowedHosts:n}:{},...i.length?{allowedSchemes:i}:{}}}function en(e,t,n){let r=t.hosts.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed hosts cannot be blank.`,`allow.${e}.hosts`,i);let a=r.filter(Boolean),o={...a.length?{hosts:a}:{},...t.fromTools?{}:{fromTools:!1}};return Object.keys(o).length?o:void 0}function tn(e,t){for(let[t,n]of e.entries()){let e=`Pattern ${t+1}`;if(!n.name.trim())return`${e} needs a name.`;if(n.kind===`words`){if(!q(n.words).length)return`${e} needs a word to match.`}else if(!n.pattern)return`${e} needs a regular expression.`}let n=le(``,t);if(n===void 0)return;let r=/^\.patterns\[(\d+)\](?:\.(\w+))?:? (.*)$/s.exec(n);if(!r)return n.replace(/^\.patterns/,`This`);let[,i,a,o]=r;return`Pattern ${Number(i)+1}${a?`, ${a}`:``}: ${o}`}function nn(e,t,n){let r=e.map(e=>{let t=e.name.trim();if(e.kind===`words`)return{name:t,words:q(e.words)};let n=e.flags.trim();return{name:t,pattern:e.pattern,...n?{flags:n}:{}}}),i=tn(e,r);return i!==void 0&&n(`guardrails`,i,t),r}function rn(e,t,n){if(!t||!N[e].patterns)return{};let r=an(t.hint,`sources.${e}.hint`,n),i=nn(t.patterns,`sources.${e}.patterns`,n);return{...t.theorem?{}:{theorem:!1},...i.length?{patterns:i}:{},...i.length&&r?{hint:r}:{}}}function an(e,t,n){let r=e.trim();if(!r)return;let i=j(`The retry hint`,r);return i!==void 0&&n(`guardrails`,`${i}.`,t),r}function on(e,t){if(!e)return`Give this detector a key, such as acme.codenames.`;let n={label:e,action:`flag`,find:cn};return F(`Detect`,{[e]:n},t)===void 0?void 0:`A key is a namespace, a dot, and a name, in lower case letters, digits and _, such as acme.codenames.`}function sn(e,t,n){let r={};for(let[i,a]of e.entries()){let e=a.key.trim();if(Object.hasOwn(r,e)){n(`guardrails`,`Detector ${e} is listed twice.`,`own`,i);continue}let o=t.filter(e=>a.at[e]!==`ignore`),s=an(a.hint,`own.${i}.hint`,n),c=nn(a.patterns,`own.${i}.patterns`,n),l=a.label.trim(),u=on(e,t);u!==void 0&&n(`guardrails`,u,`own`,i),l||n(`guardrails`,`Give this detector a name.`,`own.${i}.label`),o.length||n(`guardrails`,`Pick what a match does. It is ignored now.`,`own.${i}.at`),u===void 0&&l&&o.length&&(r[e]={label:l,at:Object.fromEntries(o.map(e=>[e,a.at[e]])),patterns:c,...s?{hint:s}:{}})}return r}var cn=()=>[];function ln(e){return e===void 0||typeof e==`string`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>{if(typeof t==`string`||t.patterns===void 0)return[e,t];let{patterns:n,...r}=t;if(e.includes(`.`))return[e,{...r,find:cn}];let{hint:i,...a}=r;return[e,a]}))}function un(e){let{guardrails:t}=e;return!t||!(`detect`in t)||t.detect===void 0?e:{...e,guardrails:{...t,detect:ln(t.detect)}}}function dn(e,t,n){let{detect:r}=e,i={};for(let a of M){let o=t.filter(e=>r[a][e]!==de[a][e]),s=t.some(e=>r[a][e]!==`ignore`)?fn(a,e,n):void 0,c=rn(a,e.sources[a],n);(o.length||s||Object.keys(c).length)&&(i[a]={...o.length?{at:Object.fromEntries(o.map(e=>[e,r[a][e]]))}:{},...c,...s?{allow:s}:{}})}Object.assign(i,sn(e.own,t,n));let a=F(`Detect`,ln(i),t);return a!==void 0&&n(`guardrails`,a,`detect`),Object.keys(i).length?i:void 0}function fn(e,t,n){if(pn(e))return en(e,t.allow[e],n);if(N[e].allow!==`names`)return;let r=t.innocentNames.map(e=>e.trim()),i=r.indexOf(``);i!==-1&&n(`guardrails`,`Allowed names cannot be blank.`,`innocentNames`,i);let a=r.filter(Boolean);return a.length?{names:a}:void 0}function pn(e){return N[e].allow===`urls`}function mn(e){let{taintAfterRemoteRead:t,taintRemoteDestination:n}=e;if(t||n)return{...t?{afterRemoteRead:t}:{},...n?{remoteDestination:n}:{}}}function hn(e,t,n=I){let r={detect:dn(e,n,t),quota:Xt(e,t),blockedReply:Zt(e,t),network:$t(e,t),taint:mn(e)},i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0));return Object.keys(i).length?i:void 0}function gn(e,t){let n=ke({}),{writeTo:r}=e,{sampleRate:i}=e;Number.isFinite(i)&&i>=0&&i<=1||t(`observability`,`Sample rate must be between 0 and 1.`,`sampleRate`),e.retainForDays!==null&&!Number.isFinite(e.retainForDays)&&t(`observability`,`Retain for days must be a number.`,`retainForDays`),e.rotateAfterMiB!==null&&!(Number.isFinite(e.rotateAfterMiB)&&e.rotateAfterMiB>0)&&t(`observability`,`Rotate after MiB must be more than zero.`,`rotateAfterMiB`);let a=ht(e.resourceJson,ut,()=>{t(`observability`,`Resource must be a JSON object.`,`resourceJson`)}),o=Object.fromEntries(Object.entries(e.include).filter(([e,t])=>t!==n.include[e])),s=Object.fromEntries(Object.entries(e.scrub).filter(([e,t])=>t!==n.scrub[e])),c={writeTo:r,...i===n.sampleRate?{}:{sampleRate:i},...Object.keys(o).length?{include:o}:{},...Object.keys(s).length?{scrub:s}:{},...e.retainForDays===null?{}:{retainForDays:e.retainForDays},...e.rotateAfterMiB===null?{}:{rotateAfterMiB:e.rotateAfterMiB},...a?{resource:a}:{}};return Object.keys(c).length?c:void 0}var _n={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`};function vn(e){if(!URL.canParse(e))return;let t=new URL(e);return t.protocol!==`https:`&&t.protocol!==`http:`?void 0:_n[t.pathname.split(`.`).pop()?.toLowerCase()??``]}function yn(e,t){return e.flatMap((e,n)=>{if(`data`in e)return e.mimeType.startsWith(`image/`)&&e.data?[{mimeType:e.mimeType,data:e.data,name:e.name}]:(t(`image`,`${e.name||`A reference`} is not an image.`,`references`,n),[]);let r=e.uri.trim(),i=vn(r);return i?[{mimeType:i,uri:r,...e.name?{name:e.name}:{}}]:(t(`image`,r?`Link to a .png, .jpg, .webp or .gif image over http(s).`:`Add a link or remove the reference.`,`references`,n),[])})}function bn(e,t){J(t,`image`,`n`,`Images per request`,e.n,1),J(t,`image`,`seed`,`Seed`,e.seed,0),J(t,`image`,`outputCompression`,`Compression`,e.outputCompression,0),e.outputCompression!==null&&e.outputCompression>100&&t(`image`,`Compression goes from 0 to 100.`,`outputCompression`);let n=yn(e.references,t);return{...e.aspectRatio.trim()?{aspectRatio:e.aspectRatio.trim()}:{},...e.resolution.trim()?{resolution:e.resolution.trim()}:{},...e.mimeType.trim()?{mimeType:e.mimeType.trim()}:{},...e.quality.trim()?{quality:e.quality.trim()}:{},...e.background.trim()?{background:e.background.trim()}:{},...e.n===null?{}:{n:e.n},...e.seed===null?{}:{seed:e.seed},...e.outputCompression===null?{}:{outputCompression:e.outputCompression},...e.includeText?{includeText:!0}:{},...n.length?{references:n}:{}}}function xn(e,t,n){let{format:r}=e;if(r){let e=t.modelBindings.find(e=>w(E(t.providers,`speech`,e))&&!D.includes(r));e&&n(`speech`,`Google doesn't make ${r}; ${e.modelId} is on ${e.provider}.`,`format`)}let i=t.modelBindings.find(e=>w(E(t.providers,`speech`,e)));i&&!e.voice.trim()&&n(`speech`,`Gemini needs a voice to speak; ${i.modelId} is on ${i.provider}.`,`voice`);let{speed:a}=e;return{...e.voice.trim()?{voice:e.voice.trim()}:{},...e.style.trim()?{style:e.style.trim()}:{},...a===null?{}:{speed:a},...r?{format:r}:{}}}function Sn(e,t){J(t,`live`,`resumedAfterMs`,`Away for`,e.resumedAfterMs,0);let n=e.resumedPrompt.trim();if(n&&!e.sessionResumption&&t(`live`,`A resume prompt needs Resumption on.`,`resumedPrompt`),!n)e.resumedAfterMs!==null&&t(`live`,`Away for needs a resume prompt.`,`resumedAfterMs`);else return{prompt:n,...e.resumedAfterMs===null?{}:{afterMs:e.resumedAfterMs}}}function Cn(e,t,n){!e.ingressAudio&&!e.ingressVideo&&!e.ingressText&&t(`live`,`Turn on at least one ingress channel.`),J(t,`live`,`vadPrefixPaddingMs`,`VAD prefix padding`,e.vadPrefixPaddingMs,0),J(t,`live`,`vadSilenceDurationMs`,`VAD silence duration`,e.vadSilenceDurationMs,0),e.contextCompression&&wn(e,t,n.mode===`demo`?n.keys.liveInputTokens:void 0);let r=Sn(e,t),i={audio:e.ingressAudio,video:e.ingressVideo,text:e.ingressText},a=Object.fromEntries(Object.entries(i).filter(([e,t])=>t!==Ae(e))),o={...e.vadActivityHandling?{activityHandling:e.vadActivityHandling}:{},...e.vadStartSensitivity?{startSensitivity:e.vadStartSensitivity}:{},...e.vadEndSensitivity?{endSensitivity:e.vadEndSensitivity}:{},...e.vadPrefixPaddingMs===null?{}:{prefixPaddingMs:e.vadPrefixPaddingMs},...e.vadSilenceDurationMs===null?{}:{silenceDurationMs:e.vadSilenceDurationMs}},s={...e.transcriptionInput?{input:!0}:{},...e.transcriptionOutput?{output:!0}:{}};return{...Object.keys(a).length?{ingress:a}:{},...e.voice.trim()?{voice:e.voice.trim()}:{},...Object.keys(o).length?{vad:o}:{},...e.sessionResumption?{sessionResumption:!0}:{},...e.greeting.trim()?{greeting:e.greeting.trim()}:{},...r?{resumed:r}:{},...e.contextCompression?{contextCompression:Tn(e)}:{},...Object.keys(s).length?{transcription:s}:{}}}function wn(e,t,n){J(t,`live`,`compressionTriggerTokens`,`Compression trigger`,e.compressionTriggerTokens,1),J(t,`live`,`compressionTargetTokens`,`Compression target`,e.compressionTargetTokens,1);let r=e.compressionTriggerTokens,i=e.compressionTargetTokens,a=n?.toLocaleString(`en-US`);n!==void 0&&r!==null&&r>n&&t(`live`,`Compression trigger can't exceed the ${a} input tokens a session holds on these keys.`,`compressionTriggerTokens`),i!==null&&(r!==null&&i>=r||n!==void 0&&r===null&&i>=n)&&t(`live`,r===null?`Compression target must be below the ${a} input tokens a session holds on these keys.`:`Compression target must be below the trigger.`,`compressionTargetTokens`)}function Tn(e){let t=e.compressionTriggerTokens,n=e.compressionTargetTokens;return{...t===null?{}:{triggerTokens:t},slidingWindow:n===null?{}:{targetTokens:n}}}function En(e,t){let[n,...r]=t,{[n]:i,...a}=e;return!r.length||typeof i!=`object`||!i?a:{...a,[n]:En(i,r)}}function Dn(e){let t=e;for(let{path:n}of me(e))t=En(t,n.split(`.`));return t}function On(e,t){let n=Object.create(null);return e.questionsBuilt||(e.questions.length||t(`decision`,`Add at least one question.`,`questions`),e.questions.forEach((e,r)=>{let i=e=>t(`decision`,e,`questions`,r),a=e.id.trim(),o=e.instructions.trim();a?Object.hasOwn(n,a)&&i(`Question id '${a}' is used twice.`):i(`Each question needs an id.`),o||i(`Question '${a||r+1}' needs instructions.`);let s=e.criteria.map(e=>({label:e.label.trim(),text:e.text.trim()}));if(!a||!o)return;if(e.type===`box`){let t=e.image?.trim();n[a]={type:`box`,instructions:o,...t?{image:t}:{}};return}if(e.type===`score`){(s.length<2||s.some(e=>!e.text))&&i(`Score '${a}' needs at least two levels, each described.`),n[a]={type:`score`,instructions:o,criteria:s.map(e=>e.text)};return}let c=Object.create(null);for(let e of s)e.label?Object.hasOwn(c,e.label)?i(`Option '${e.label}' of '${a}' is used twice.`):c[e.label]=e.text||e.label:i(`Every option of '${a}' needs a label.`);e.type===`choice`?(s.length<2&&i(`Choice '${a}' needs at least two options.`),n[a]={type:`choice`,instructions:o,criteria:c}):n[a]={type:`noul`,instructions:o,...s.length?{criteria:c}:{}}})),n}var kn=/^[a-z0-9_]+$/,An=[`image/png`,`image/jpeg`];function jn(e,t){let n=Object.create(null);return e.images.forEach((e,r)=>{let i=e=>t(`decision`,e,`images`,r),a=e.name.trim(),o=`<${a}>`;kn.test(a)?Object.hasOwn(n,o)?i(`Image ${o} is used twice.`):!An.includes(e.mimeType)||!e.data?i(`${o} is not a PNG or JPEG.`):n[o]={mimeType:e.mimeType,data:e.data}:i(`Name an image with lowercase letters, digits, and _.`)}),e.questions.forEach((e,r)=>{let i=[...e.instructions.matchAll(/<[a-z0-9_]+>/g)].map(([e])=>e),a=e.type===`box`?e.image?.trim():void 0;a?.startsWith(`<`)&&i.push(a);for(let e of new Set(i))Object.hasOwn(n,e)||t(`decision`,`No image is named ${e}.`,`questions`,r)}),n}function X(e,t,n){let r=t.has(`observability`)?gn(e.observability,n):void 0,i=Yt(e,t,t=>z(e,t),n);return{...r?{observability:r}:{},...i?{labels:i}:{}}}function Mn(e,t){let{decision:n}=e,r=n.contract.trim();return r||t(`decision`,`Contract is required.`,`contract`),r}function Nn(e,t,n,r){let i=n.decision,{decision:a,identity:o}=e,s=(e,t)=>e.trim().length>t;s(a.contract,i.idChars)&&r(`decision`,`Contract is limited to ${i.idChars} characters on these keys.`,`contract`),s(o.agentId,i.idChars)&&r(`identity`,`Profile id is limited to ${i.idChars} characters on these keys.`,`agentId`),s(o.handle,i.nameChars)&&r(`identity`,`Handle is limited to ${i.nameChars} characters on these keys.`,`handle`);let c=e.modelBindings[0];if(c){let e=B(c.key);c.timeoutMs!==null&&c.timeoutMs>i.timeoutMs&&r(e,`Timeout is limited to ${i.timeoutMs} ms on these keys.`,`timeoutMs`),s(c.modelId,i.nameChars)&&r(e,`Model id is limited to ${i.nameChars} characters on these keys.`,`modelId`),s(c.apiId,i.idChars)&&r(e,`API model is limited to ${i.idChars} characters on these keys.`,`apiId`)}a.maxStateBytes!==null&&a.maxStateBytes>i.stateBytes&&r(`decision`,`These keys take at most ${i.stateBytes} bytes of state.`,`maxStateBytes`),a.questions.length>i.questions&&r(`decision`,`These keys ask at most ${i.questions} questions.`,`questions`),a.images.length>i.images&&r(`decision`,`These keys send at most ${i.images} images.`,`images`),a.images.forEach((e,t)=>{Math.floor(e.data.length*3/4)>i.imageBytes&&r(`decision`,`Each image is limited to ${i.imageBytes} bytes on these keys.`,`images`,t)}),a.questions.forEach((a,o)=>{let l=e=>r(`decision`,e,`questions`,o);s(a.id,i.nameChars)&&l(`Question ids are limited to ${i.nameChars} characters on these keys.`),a.type===`box`&&i.images===0&&l(`These keys take no images, so a Box question has nothing to read.`),s(a.instructions,i.instructionsChars)&&l(`Instructions are limited to ${i.instructionsChars} characters on these keys.`),a.criteria.length>i.criteria&&l(`A question has at most ${i.criteria} options or levels on these keys.`),a.criteria.some(e=>s(e.text,i.criterionChars))&&l(`Each option or level is limited to ${i.criterionChars} characters on these keys.`),a.criteria.some(e=>s(e.label,i.nameChars))&&l(`Option labels are limited to ${i.nameChars} characters on these keys.`);let u=t[a.id.trim()],d=c&&u&&n.questionViolation(E(e.providers,`decision`,c),u);d&&l(d)})}function Pn(e,t,n){let{decision:r}=e,i=new Set(L(e)),a=Mn(e,t);e.modelBindings.length!==1&&t(`models`,`A decision needs exactly one model binding.`);let o=e.modelBindings[0],s=o?B(o.key):`models`;o&&($e(o,`decision`,e.providers,t),at(o,e.providers,`decision`,s,t),o.modelId.trim()||t(s,`Model id is required.`,`modelId`),J(t,s,`timeoutMs`,`Timeout`,o.timeoutMs,1));let c=o?it(o,s,t):void 0;J(t,`decision`,`maxStateBytes`,`Max state`,r.maxStateBytes,1);let l=On(r,t),u=jn(r,t);return n.mode===`demo`&&Nn(e,l,n.keys,t),{profile:{type:`decision`,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim()},models:o?{[o.modelId.trim()]:{protocol:o.protocol,provider:o.provider,apiId:o.apiId.trim(),...Object.keys(o.options).length?{options:o.options}:{},...o.keySlot||e.models.key?{keySlot:o.keySlot||e.models.key}:{},...o.fallbackKeySlot?{fallbackKeySlot:o.fallbackKeySlot}:{},...o.timeoutMs===null?{}:{timeoutMs:o.timeoutMs},...c?{limits:c}:{}}}:{},inputs:{state:`json`,...r.maxStateBytes===null?{}:{maxStateBytes:r.maxStateBytes}},decision:{contract:a},...X(e,i,t)},customTools:[],...r.questionsBuilt?{}:{questions:l},...Object.keys(u).length?{images:{...u}}:{}}}function Fn(e,t,n,r){let i=new Set(L(e)),{customTools:a,tools:o}=Rt(e,z(e,`tools.t2Loader`),z(e,`tools.parallel`),t,n,r);a.length||t(`tools`,`Add at least one tool: a host runs only its tools.`);let s=i.has(`guardrails`)?hn(e.guardrails,t,he):void 0;return{profile:Dn({type:`host`,id:e.identity.agentId.trim(),tools:o,...s?{guardrails:s}:{},...X(e,i,t)}),customTools:a}}function In(e,t,n,r,i,a){let o=new Set(L(e)),s=t=>z(e,t),{system:c,conditions:l}=mt(e,n),u=ct(e,t,n,i),{outputs:d,structured:f}=o.has(`outputs`)?Kt(e.outputs,s(`outputs.structured`),n):{},{customTools:p,tools:m}=o.has(`tools`)?Rt(e,s(`tools.t2Loader`),s(`tools.parallel`),n,i,a):{customTools:[]},h=o.has(`turnBehaviour`)?Jt(e.turnBehaviour,s(`turnBehaviour.resumption`),n):void 0,g=o.has(`guardrails`)?hn(e.guardrails,n):void 0;return{profile:Dn({type:t,id:e.identity.agentId.trim(),identity:{handle:e.identity.handle.trim(),...l?{conditions:l}:{},...c?{system:c}:{}},...u,...o.has(`image`)?{image:bn(e.image,n)}:{},...o.has(`speech`)?{speech:xn(e.speech,e,n)}:{},...o.has(`live`)?{live:Cn(e.live,n,r)}:{},...m?{tools:m}:{},...o.has(`inputs`)?t===`live`?Wt(e.inputs,n):{inputs:zt(e.inputs,t,n)}:{},...d?{outputs:d}:{},...h?{turnBehaviour:h}:{},...g?{guardrails:g}:{},...X(e,o,n)}),customTools:p,...f?{structured:f}:{}}}function Ln(e,t,n=Je,r=Ye){let i=[],a=(e,t,n,r)=>{i.push({nodeId:e,message:t,...n===void 0?{}:{field:n},...r===void 0?{}:{index:r}})};Qe(e,a),new Set([e.models.key,e.models.fallbackKey,...e.modelBindings.flatMap(t=>{let{keySlot:n,fallbackKeySlot:r}=R(e,t);return[n,r]})].filter(Boolean)).size>32&&a(`models`,`The studio supports up to 32 key slots.`,`key`);let o=e.identity.profileType;if(!o)return a(`identity`,`Pick a profile type.`,`profileType`),{ok:!1,issues:i};if(o!==`host`)for(let n of e.modelBindings){if(!n.apiId.trim())continue;let r=ce({...E(e.providers,o,n),builtInTools:n.builtInTools},t);r&&a(B(n.key),r.message,r.field)}let s=o===`decision`?Pn(e,a,t):o===`host`?Fn(e,a,n,r):In(e,o,a,t,n,r);if(i.length)return{ok:!1,issues:i};try{De(un(s.profile))}catch(e){if(!(e instanceof A))throw e;return{ok:!1,issues:[{nodeId:`identity`,message:e.message}]}}return{ok:!0,agentId:s.profile.id,providers:e.providers,...s}}var Z=e(i(),1),Q=t(),Rn=(0,Z.lazy)(()=>b(()=>import(`./TraceInspector-36e6ozKD.js`).then(e=>({default:e.TraceGuardrailsBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),zn=(0,Z.lazy)(()=>b(()=>import(`./TraceInspector-36e6ozKD.js`).then(e=>({default:e.TraceFeedBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),Bn=(0,Z.createContext)(`replace`);function Vn({value:e,children:t}){return(0,Q.jsx)(Bn,{value:e,children:t})}function Hn({id:e,toggle:t,traces:n}){return(0,Q.jsx)(_,{id:e,children:e=>(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(m,{floating:!0,children:t}),children:(0,Q.jsx)(zn,{traces:n,isWide:e,end:t})})})}function Un(e,t,n){let r=ee(),i=(0,Z.useId)(),[a,o]=(0,Z.useState)(!1),s=(0,Z.use)(Bn),c={name:r(`@theorem.panel.trace.name`),show:r(`@theorem.panel.trace.show`),hide:r(`@theorem.panel.trace.hide`),resize:r(`@theorem.panel.trace.resize`)};if(e.observability?.record!==!0)return{toggle:null,view:null,labels:c,offered:!1};let u=n??a,d=e=>n===void 0?(0,Q.jsx)(y,{labels:c,icon:(0,Q.jsx)(l,{icon:ie}),panelId:i,open:u,size:e,onToggle:()=>o(e=>!e)}):null;return{toggle:d(),view:u?Wn(s===`panel`,i,t,d(`sm`)):null,labels:c,offered:!0}}function Wn(e,t,n,r){return e?(0,Q.jsx)(Gn,{id:t,toggle:r,traces:n}):(0,Q.jsx)(Hn,{id:t,toggle:r,traces:n})}function Gn({id:e,toggle:t,traces:n}){let{ref:r,width:i}=h();return(0,Q.jsx)(`div`,{id:e,ref:r,style:{height:`100%`,position:`relative`},children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(m,{floating:!0,children:t}),children:(0,Q.jsx)(zn,{traces:n,isWide:p(i),end:t})})})}function Kn({inspector:e,children:t}){let n=(0,Z.useRef)(null),r=g(n,!1),i=(0,Z.useRef)(void 0),a=(0,Z.useCallback)(e=>{n.current=e;let t=i.current;typeof t==`function`?t(e):t!=null&&(t.current=e)},[]);if(!(0,Z.isValidElement)(t))return(0,Q.jsx)(v,{view:e.view,children:t});i.current=t.props.ref;let o=e.view!=null;return(0,Z.cloneElement)(t,{ref:a,end:(0,Q.jsx)(f,{labels:e.labels,resizable:r.resizable,open:o,children:e.view})})}function qn({inspector:e,children:t}){return(0,Z.use)(Bn)===`panel`&&e.offered?(0,Q.jsx)(Kn,{inspector:e,children:t}):(0,Q.jsx)(v,{view:e.view,children:t})}function Jn({records:e,head:t}){return(0,Q.jsx)(te,{children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Rn,{records:e,head:t})})})}var Yn={info:`info`,warning:`warning`,error:`error`,success:`success`},Xn={info:`accent`,warning:`warning`,error:`error`,success:`success`},$={root:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kMv6JI:`xjb2p0i`,$$css:!0},rootElevatedCard:{kaIpWk:`x1vf2byn`,$$css:!0},header:{k1xSpc:`x78zum5`,kGNEyG:`x1cy8zhl`,kwnvtZ:`x1a02dak`,k1C7PZ:`xak3so`,khm7nJ:`x4olc9o`,k8WAf4:`x8o8v82`,kg3NbH:`x1pzlopt`,$$css:!0},headerCardStandalone:{kaIpWk:`x1vf2byn`,$$css:!0},headerCardWithContent:{krdFHd:`xwxb7qi`,kfmiAY:`x13nour3`,kVL7Gh:`xbiv7yw`,kT0f0o:`x16uus16`,$$css:!0},headerCentered:{kGNEyG:`x6s0dn4`,$$css:!0},endArea:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kwnvtZ:`x1a02dak`,kjj79g:`x13a6bvl`,kOIVth:`x1txdalj`,kmuXW:`x2lah0s`,ks0D6T:`x193iq5w`,keTefX:`xvc5jky`,kqGvvJ:`x81ka23`,$$css:!0},chevron:{k1ekBW:`x11xpdln`,kIyJzY:`xuedmi6 x12w9bfk`,kAMwcw:`xlr8y92`,$$css:!0},chevronExpanded:{k3aq6I:`x19jd1h0`,$$css:!0}},Zn={info:{kWkggS:`xgcxg3y`,$$css:!0},warning:{kWkggS:`x24i8r5`,$$css:!0},error:{kWkggS:`x1pritpl`,$$css:!0},success:{kWkggS:`xu13z74`,$$css:!0}};function Qn(e){return Object.prototype.hasOwnProperty.call(Zn,e)}var $n={none:{kGVxlE:`x1gnnqk1`,$$css:!0},low:{kGVxlE:`x1i5ehqx`,$$css:!0},med:{kGVxlE:`x14hfi27`,$$css:!0},high:{kGVxlE:`x1kcpxr7`,$$css:!0}};function er({status:e,title:t,description:i,icon:f,isDismissable:p=!1,onDismiss:m,dismissLabel:h,endContent:g,container:_=`card`,elevation:v=`none`,collapsible:y=!0,children:b,xstyle:ee,className:te,style:x,ref:ie,onFocusCapture:ae,onPointerDownCapture:S,...oe}){let C=u(),[se,w]=(0,Z.useState)(!1),T=typeof y==`object`&&y?y:{},{isEnabled:E,isOpen:D,toggle:ce}=d({isCollapsible:y!==!1&&{...T,defaultIsOpen:T.defaultIsOpen??!1}}),O=(0,Z.useRef)(null),k=(0,Z.useId)(),A=Yn[e],le=Xn[e],j=c(b),M=C(`@astryx.banner.dismiss`),N=h??M,ue=h??(typeof t==`string`?C(`@astryx.banner.dismissTitled`,{dismiss:M,title:t}):M);if(se)return null;let P=(e,t)=>{e instanceof HTMLElement&&e!==document.body&&!t.contains(e)&&(O.current=e)},F=e=>{P(e.relatedTarget,e.currentTarget)},de=e=>{P(document.activeElement,e.currentTarget)},fe=()=>{let e=O.current;w(!0),m?.(),e?.isConnected&&e.focus()},I=E&&j,pe=c(g)||p||I,me=c(g)||p,he=!c(i)&&me,L=j&&(!E||D),R=_===`card`;return(0,Q.jsxs)(`div`,{ref:ie,onFocusCapture:s(ae,F),onPointerDownCapture:s(S,de),...o(r(`banner-frame`,{container:_,elevation:v}),n($.root,$n[v],R&&v!==`none`&&$.rootElevatedCard,ee),te,x),...oe,children:[(0,Q.jsxs)(`div`,{...o(r(`banner`,{container:_,status:e}),n($.header,he&&$.headerCentered,Qn(e)&&Zn[e],R&&(L?$.headerCardWithContent:$.headerCardStandalone))),children:[(0,Q.jsx)(`div`,{...c(f)?o(r(`banner-icon`,{status:e}),{className:`x78zum5 x6s0dn4 x2lah0s`}):{className:`x78zum5 x6s0dn4 x2lah0s`},"aria-hidden":`true`,children:c(f)?f:A==null?null:(0,Q.jsx)(l,{icon:A,size:`md`,color:le,...r(`banner-icon`,{status:e})})}),(0,Q.jsxs)(`div`,{...{0:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli`},1:{className:`x78zum5 xdt5ytf xxhr3t x98rzlu xeuugli xgualba`}}[!!c(g)|0],children:[(0,Q.jsx)(`div`,{className:`x1ghz6dp xjb2p0i xcr08ib x2mo6ok x1kq96og x1tgivj0 xj0a0fe`,children:t}),c(i)&&(0,Q.jsx)(`div`,{...o(r(`banner-description`),{className:`x1ghz6dp xjb2p0i x141an7d x1sodnla x1ltkj2j xv1l7n4 xj0a0fe`}),children:i})]}),pe&&(0,Q.jsxs)(`div`,{...n($.endArea,ne.inset(a[`--spacing-2`])),children:[g,I&&(0,Q.jsx)(re,{variant:`ghost`,size:`sm`,label:C(D?`@astryx.banner.collapse`:`@astryx.banner.expand`),tooltip:C(D?`@astryx.banner.collapse`:`@astryx.banner.expand`),icon:(0,Q.jsx)(l,{icon:`chevronDown`,size:`sm`,color:`inherit`,xstyle:[$.chevron,D&&$.chevronExpanded]}),onClick:ce,"aria-expanded":D,"aria-controls":L?k:void 0,isIconOnly:!0}),p&&(0,Q.jsx)(re,{variant:`ghost`,size:`sm`,label:ue,tooltip:N,icon:(0,Q.jsx)(l,{icon:`close`,size:`sm`,color:`inherit`}),onClick:fe,isIconOnly:!0})]})]}),L&&(0,Q.jsx)(`div`,{id:I?k:void 0,...o(r(`banner-content`,{container:_,status:e}),{0:{className:`x1de1mus x8o8v82 x1pzlopt xgbv0en xw8tdv1 x92x3c3 x1t7ytsu x18b5jzi x1q0q8m5 x1j92z86 x1gejf6u xw8gpjh`},1:{className:`x1de1mus x8o8v82 x1pzlopt xgbv0en xw8tdv1 x92x3c3 x1t7ytsu x18b5jzi x1q0q8m5 x1j92z86 x1gejf6u xw8gpjh x1k5g1gk x1eprgri`}}[!!R|0]),children:b})]})}er.displayName=`Banner`;export{Ue as _,Un as a,Ne as b,Et as c,Qt as d,un as f,ze as g,Ve as h,qn as i,Dt as l,We as m,Jn as n,Ct as o,H as p,Vn as r,Ln as s,er as t,pt as u,He as v,Pe as y};