@theoremjs/studio 0.3.4-next.815.g7f5fa76 → 0.3.4-next.819.g62d1f4f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +5 -5
- package/page/assets/Badge-Cj3D81QB.js +1 -0
- package/page/assets/BottomSheet-DUMPEHkR.js +1 -0
- package/page/assets/Button-98PahHB4.js +1 -0
- package/page/assets/Card-DKuxiCN0.js +1 -0
- package/page/assets/Center-C9ai7fq_.js +1 -0
- package/page/assets/CheckboxIndicator-Cca43Ctu.js +2 -0
- package/page/assets/CheckboxInput-nEEHX5M1.js +2 -0
- package/page/assets/CodeBlock-D7u2qG-t.js +3 -0
- package/page/assets/CollapsibleGroup-D_hnA9UR.js +1 -0
- package/page/assets/ConsoleFrame-6cZcgAw3.js +3 -0
- package/page/assets/DateInput-DWdaI0u_.js +1 -0
- package/page/assets/Dialog-C2GP5P7V.js +1 -0
- package/page/assets/EmptyState-DVoDGbtj.js +1 -0
- package/page/assets/FieldStatus-mbnJ60bK.js +1 -0
- package/page/assets/HStack-CqE4exX9.js +1 -0
- package/page/assets/HoverCard-BaUeXNdO.js +1 -0
- package/page/assets/Icon-Cluq4EiW.js +48 -0
- package/page/assets/{IconAlertTriangle-BqAEqqdU.js → IconAlertTriangle-CL88MFAk.js} +1 -1
- package/page/assets/IconButton-Jbcy-K-d.js +1 -0
- package/page/assets/{IconFileText-6zOFKKrF.js → IconFileText-BP1pyMTO.js} +1 -1
- package/page/assets/{IconFilter-BO98ezum.js → IconFilter-DYCjUyWk.js} +1 -1
- package/page/assets/{IconHistory-VvDVN7WG.js → IconHistory-DdcWdeRG.js} +1 -1
- package/page/assets/{IconMathFunction-Eux9NbUx.js → IconMathFunction-CyMTpj2z.js} +1 -1
- package/page/assets/{IconMicrophone-CJCgFwEd.js → IconMicrophone-BT77cilC.js} +1 -1
- package/page/assets/{IconSearch-BTx66a40.js → IconSearch-BN1R3FIx.js} +1 -1
- package/page/assets/{IconServer-DIJ0DAhI.js → IconServer-Dfs13rbh.js} +1 -1
- package/page/assets/{IconShield-DDOh7Gr5.js → IconShield-C7D1qFUk.js} +1 -1
- package/page/assets/{IconTool-CnptGEDw.js → IconTool-BHps7rbl.js} +1 -1
- package/page/assets/{IconWorld-DTIAtVl1.js → IconWorld-DkkGLUyH.js} +1 -1
- package/page/assets/InputClearButton-ClwCL3dr.js +1 -0
- package/page/assets/ItemSwipeLayer-Vrel9VQX.js +1 -0
- package/page/assets/LayoutContent-ClBE78rU.js +1 -0
- package/page/assets/LayoutFooter-QMRRAZfF.js +1 -0
- package/page/assets/ListItem-BevY6nJP.js +1 -0
- package/page/assets/MenuBottomSheet-CtpGLGiS.js +1 -0
- package/page/assets/MenuBottomSheetActionList-4BzDY0Sv.js +1 -0
- package/page/assets/OverflowList-CDkPnQmt.js +1 -0
- package/page/assets/PanelSearchInput-Dw5TVlEX.js +1 -0
- package/page/assets/SchemaFields-CeR8fdQP.js +1 -0
- package/page/assets/ScrollableArea-BGmyGfiL.js +1 -0
- package/page/assets/SidePanel-CYk_zksv.js +2 -0
- package/page/assets/Spinner-B6MdidYQ.js +1 -0
- package/page/assets/Stack-De5MY0tq.js +1 -0
- package/page/assets/StackItem-ClAjT294.js +1 -0
- package/page/assets/Text-BDwNaqzZ.js +2 -0
- package/page/assets/TextInput-BRBEgg_h.js +1 -0
- package/page/assets/TimestampHoverCard-Lt3iYlao.js +1 -0
- package/page/assets/Token-BZrQH6-I.js +1 -0
- package/page/assets/TokenizerBottomSheet-DWwKcApA.js +1 -0
- package/page/assets/ToolResultCharts-Cu8Vyn7b.js +1 -0
- package/page/assets/Toolbar-Bn-SeRUY.js +1 -0
- package/page/assets/{Tooltip-i8-9gEjh.js → Tooltip-Dhy5lIDA.js} +1 -1
- package/page/assets/TraceInspector-DSH0cSNV.js +1 -0
- package/page/assets/{TraceOverview-BWKmIqB_.js → TraceOverview-B1-wFXpd.js} +5 -5
- package/page/assets/VStack-CCYGIv4A.js +1 -0
- package/page/assets/VisuallyHidden-Dfmmn1_I.js +1 -0
- package/page/assets/{_virtual_studio-type-sources-By1WFfl3.js → _virtual_studio-type-sources-DsadDSMk.js} +25 -12
- package/page/assets/{browser-connection-CcVePgFL.js → browser-connection-Bc7sOuyD.js} +1 -1
- package/page/assets/browser-engine-CfZLnFHY.js +16 -0
- package/page/assets/browser-transport-Cw2eNd0h.js +2 -0
- package/page/assets/compile-D3bEXuZx.js +2 -0
- package/page/assets/{container.stylex-C2nFBhUj.js → container.stylex-CkS70he6.js} +1 -1
- package/page/assets/{createReactComponent-CZwsv6DD.js → createReactComponent-DVEyVJ-p.js} +1 -1
- package/page/assets/disabledInteraction-2qeNzu0m.js +1 -0
- package/page/assets/egress-automata-DTnWTzpb.js +1 -0
- package/page/assets/{embedding-space-view-hA6LFkNX.js → embedding-space-view-CRxJE7jA.js} +2 -2
- package/page/assets/{encode-files-D5aFu4ln.js → encode-files-DiwDNH4N.js} +1 -1
- package/page/assets/{export-agent-BODTL50Q.js → export-agent-BxwvLEI2.js} +3 -3
- package/page/assets/fieldParts-DOfguMAs.js +1 -0
- package/page/assets/focusOutline.stylex-LUQxyg0W.js +1 -0
- package/page/assets/focusReturn-DF3Bi_HC.js +1 -0
- package/page/assets/guardrail-tester-Cf-_eQoc.js +9 -0
- package/page/assets/highlightRanges-B7TRPq9q.js +51 -0
- package/page/assets/index-Df0i5k06.js +150 -0
- package/page/assets/index-YKE-6URE.css +1 -0
- package/page/assets/inputStyles.stylex-Dmh4r-B9.js +1 -0
- package/page/assets/{json-code-Baj1sHwL.js → json-code-Bv8iMKXP.js} +1 -1
- package/page/assets/{labels-provider-CKypi3Rm.js → labels-provider-B6PGDZ7i.js} +2 -2
- package/page/assets/{layerScopedContext-OrLDujSh.js → layerScopedContext-BA4VBuWG.js} +1 -1
- package/page/assets/{live-messages-CXlxccEO.js → live-messages-BmxSAnjs.js} +1 -1
- package/page/assets/{map-token-zJGxIUb4.js → map-token-_aDyWhNO.js} +1 -1
- package/page/assets/menuBottomSheet.stylex-BoKs4EdV.js +1 -0
- package/page/assets/plainDate-CE-glc6O.js +1 -0
- package/page/assets/prompt-row-BJrXOhMi.css +1 -0
- package/page/assets/prompt-row-W3uZ_pur.js +71 -0
- package/page/assets/{read-map-CVfRMOdU.js → read-map-i9VRmt7r.js} +1 -1
- package/page/assets/{reader-BVF30qvS.js → reader-LWnKsoZI.js} +4 -4
- package/page/assets/{registry-DFEch9py.js → registry-DSpjWDhn.js} +1 -1
- package/page/assets/{row-keys-WByP9Hsh.js → row-keys-0Bn7ZyYy.js} +1 -1
- package/page/assets/rtlStyles-CVVETNV7.js +1 -0
- package/page/assets/{schema-D7LTUA0h.js → schema-5VLoC-4Z.js} +1 -1
- package/page/assets/shaped-data-BPXuDrSn.js +21 -0
- package/page/assets/stackItem.stylex-BkECao56.js +1 -0
- package/page/assets/{stub-BS-Ey8w3.js → stub-ChwFuX34.js} +1 -1
- package/page/assets/{studio-code-pane-aoU9CYU8.js → studio-code-pane-CeO0QRc6.js} +3 -3
- package/page/assets/{studio-console-BfE4Qs0I.js → studio-console-B1jS8dTh.js} +1 -1
- package/page/assets/studio-decision-B_aYdM5T.js +1 -0
- package/page/assets/studio-embedding-DomBUA-V.js +2 -0
- package/page/assets/studio-host-console-BR9k5Rix.js +2 -0
- package/page/assets/studio-labels-CqXp6VcR.js +3 -0
- package/page/assets/studio-live-BKThbU_V.js +5 -0
- package/page/assets/studio-map-jVb58ujM.js +1 -0
- package/page/assets/studio-trace-replay-jn_RsjjK.js +3 -0
- package/page/assets/{studio-type-checker-CWgKneqZ.js → studio-type-checker-f2wzNB9Y.js} +1 -1
- package/page/assets/{themeProps-3IqahpCr.js → themeProps-Bo2jNkIC.js} +1 -1
- package/page/assets/tokens.stylex-a4pw9QVe.js +1 -0
- package/page/assets/{tool-schema-CxyHWJU1.js → tool-schema-C7QZtUhR.js} +5 -5
- package/page/assets/{trace-patterns-7ljKzdWI.js → trace-patterns-DFMwRU00.js} +1 -1
- package/page/assets/{trace-record-BnoxKfn0.js → trace-record-B7jN6tSR.js} +1 -1
- package/page/assets/tree-DGmS8wGm.js +3 -0
- package/page/assets/{turn-client-DMwkU41t.js → turn-client-4WkWaRoo.js} +2 -2
- package/page/assets/{type-icons-BH_hcYiS.js → type-icons-DgazEJTc.js} +1 -1
- package/page/assets/typeaheadMatch-BJfmSQc6.js +1 -0
- package/page/assets/{types-BoHnkC5F.js → types-vI-k9MS_.js} +1 -1
- package/page/assets/use-one-call-DeJ64uVJ.js +1 -0
- package/page/assets/use-second-ticker-D0uA9-ps.css +1 -0
- package/page/assets/{use-second-ticker-D29e7ivl.js → use-second-ticker-ovc65-Bo.js} +1 -1
- package/page/assets/useAnnounce-QM3mmuiE.js +1 -0
- package/page/assets/useAnnounceRenderedText-_-FYc-5m.js +1 -0
- package/page/assets/useBusyAnnouncement-CjJI13FX.js +1 -0
- package/page/assets/useClickableContainer-dg6qYWze.js +1 -0
- package/page/assets/{useClipboard-CBYppUy6.js → useClipboard-CAtohmvr.js} +1 -1
- package/page/assets/useDevWarning-WeXt8Pe8.js +1 -0
- package/page/assets/useFocusLeavingChange-Bb1WH0Lr.js +1 -0
- package/page/assets/useFocusReturnVisibility-Brk7Chog.js +1 -0
- package/page/assets/useHighlightedOptionScroll-CFs91KPl.js +1 -0
- package/page/assets/useIsHydrating-JHu3d-Y0.js +1 -0
- package/page/assets/useKeyboardHint-BP66YM6d.js +1 -0
- package/page/assets/useLayerDismissal-7g2rAKDN.js +1 -0
- package/page/assets/useLocale-d7ARRGFj.js +1 -0
- package/page/assets/{useMediaQuery-BCT0NUeZ.js → useMediaQuery-D0tQ79Tl.js} +1 -1
- package/page/assets/useMenuOverflow-nA_EuFZP.js +1 -0
- package/page/assets/useMenuPress-BHmqa9bx.js +1 -0
- package/page/assets/useMergedRefs-BgzyWuff.js +1 -0
- package/page/assets/usePressFeedback-BpX4yZ5R.js +1 -0
- package/page/assets/useResolvedRequired-DR7Agwbm.js +1 -0
- package/page/assets/useScrollLock-Dm92sJDr.js +1 -0
- package/page/assets/useScrollableArea-CIrHdx_f.js +1 -0
- package/page/assets/useSettledOpen-DTsZ7A6A.js +1 -0
- package/page/assets/useTooltip-ClCeZiOV.js +1 -0
- package/page/assets/useTranslator-Ba7ULSHc.js +1 -0
- package/page/assets/{workspace-1TqzwSjs.js → workspace-CnHLWgF-.js} +1 -1
- package/page/index.html +105 -90
- package/probe-battery.js +2 -2
- package/ui/built/theme.css +35 -125
- package/ui/built/theme.css.d.ts +2 -2
- package/ui/built/theorem-studio.d.ts +2 -2
- package/ui/built/theorem-studio.js +30 -122
- package/ui/built/theorem-studio.variants.d.ts +2 -2
- package/ui/studio-theme.d.ts +1 -1
- package/page/assets/Badge-D78MvW22.js +0 -1
- package/page/assets/BottomSheet-RjdFLREq.js +0 -1
- package/page/assets/Card-UzuJJI_o.js +0 -1
- package/page/assets/Center-CfSYa5SJ.js +0 -1
- package/page/assets/CheckboxInput-DC62lfiG.js +0 -2
- package/page/assets/CodeBlock-Dcj5-dI6.js +0 -3
- package/page/assets/CollapsibleGroup-C558j700.js +0 -1
- package/page/assets/ConsoleFrame-Bf_3mpqP.js +0 -3
- package/page/assets/DateInput-BrLgvHDz.js +0 -1
- package/page/assets/Dialog-CVk3thtl.js +0 -1
- package/page/assets/EmptyState-C_uF9Wyj.js +0 -1
- package/page/assets/FieldStatus-DsLpiRRE.js +0 -1
- package/page/assets/HStack-DxvXX_Xt.js +0 -1
- package/page/assets/HoverCard-DM8G9-0E.js +0 -1
- package/page/assets/Icon-DQhwzrkL.js +0 -3
- package/page/assets/IconButton-DkBz0UbI.js +0 -1
- package/page/assets/ItemSwipeLayer-BzVkYf4E.js +0 -1
- package/page/assets/ListItem-DB9l0niX.js +0 -1
- package/page/assets/MenuBottomSheet-CO5gepJx.js +0 -1
- package/page/assets/MenuBottomSheetActionList-BXRLqw9i.js +0 -1
- package/page/assets/OverflowList-DCbz0juN.js +0 -1
- package/page/assets/SchemaFields-DwwHUFSt.js +0 -1
- package/page/assets/ScrollableArea-B4atQbG7.js +0 -1
- package/page/assets/SidePanel-CJhDv_-c.js +0 -2
- package/page/assets/Spinner-CB4UUJ5a.js +0 -1
- package/page/assets/Stack-BxV67rLm.js +0 -1
- package/page/assets/StackItem-YZCLellt.js +0 -1
- package/page/assets/Text-DsdhhbQq.js +0 -2
- package/page/assets/TextInput-DQESAqpV.js +0 -1
- package/page/assets/TimestampHoverCard-79rKEd7V.js +0 -1
- package/page/assets/Token-B-NmyYhm.js +0 -1
- package/page/assets/ToolResultCharts-CCpwUDJd.js +0 -1
- package/page/assets/Toolbar-B5ZOgQbb.js +0 -1
- package/page/assets/TraceInspector-DQRx1QUy.js +0 -1
- package/page/assets/VStack-CdkbS0YS.js +0 -1
- package/page/assets/VisuallyHidden-BdRLF-8h.js +0 -1
- package/page/assets/browser-engine-COB1GYTI.js +0 -16
- package/page/assets/browser-transport-DopwOpwI.js +0 -45
- package/page/assets/compile-Dg5FWToI.js +0 -2
- package/page/assets/egress-automata-SiHQTP1i.js +0 -1
- package/page/assets/fieldParts-CrDK1ecV.js +0 -1
- package/page/assets/focusOutline.stylex-B9nWSXsG.js +0 -1
- package/page/assets/focusReturn-CTppP2k0.js +0 -1
- package/page/assets/guardrail-tester-wCPEkzxL.js +0 -9
- package/page/assets/highlightRanges-BfROnk2i.js +0 -51
- package/page/assets/index-Coeeiw_9.css +0 -1
- package/page/assets/index-HAKOsFT6.js +0 -150
- package/page/assets/inputStyles.stylex-B1aNWR3P.js +0 -1
- package/page/assets/plainDate-BHiJcj7o.js +0 -1
- package/page/assets/prompt-row-DrNj8Dpl.js +0 -71
- package/page/assets/prompt-row-beoYzntJ.css +0 -1
- package/page/assets/safeUrl-CYCzKQ-X.js +0 -1
- package/page/assets/shaped-data-CDuHM2x5.js +0 -21
- package/page/assets/sharedResizeObserver-4U9Xq5Oq.js +0 -1
- package/page/assets/studio-decision-CEhkNfU0.js +0 -1
- package/page/assets/studio-embedding-CXSWEkG2.js +0 -2
- package/page/assets/studio-host-console-DogHcTFD.js +0 -2
- package/page/assets/studio-labels-DqAEpPH7.js +0 -3
- package/page/assets/studio-live-BteE9jJS.js +0 -5
- package/page/assets/studio-map-CNvNoxcA.js +0 -1
- package/page/assets/studio-trace-replay-QZQ9ppo-.js +0 -3
- package/page/assets/tokens.stylex-BpCwr7Mf.js +0 -1
- package/page/assets/tree-C204ODPn.js +0 -3
- package/page/assets/use-one-call-DP6ScVTT.js +0 -1
- package/page/assets/use-second-ticker-B-V4bkIB.css +0 -1
- package/page/assets/useAdaptivePresentation-Bma4-u1a.js +0 -1
- package/page/assets/useAnnounce-CRR83ID0.js +0 -1
- package/page/assets/useAnnounceRenderedText-Dmk4UjwU.js +0 -1
- package/page/assets/useClickableContainer-BirAhL6n.js +0 -1
- package/page/assets/useDevWarning-Z9SoixOP.js +0 -1
- package/page/assets/useFocusReturnVisibility-BHKv5Jwr.js +0 -1
- package/page/assets/useKeyboardHint-CPYLVCI3.js +0 -1
- package/page/assets/useLayerDismissal-BAnTRYTt.js +0 -1
- package/page/assets/useLocale-BuRYk4__.js +0 -1
- package/page/assets/useMenuDrillIn-tkh7-uy6.js +0 -1
- package/page/assets/useMenuPress-C-hKmliO.js +0 -1
- package/page/assets/usePressFeedback-v6IeHjJ6.js +0 -1
- package/page/assets/useResolvedRequired-DgA9eEzw.js +0 -1
- package/page/assets/useScrollLock-Dyf6PHJt.js +0 -1
- package/page/assets/useScrollableArea-DuF_pz9m.js +0 -1
- package/page/assets/useTooltip-CipI1oJa.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as e}from"./themeProps-Bo2jNkIC.js";import{t}from"./Stack-De5MY0tq.js";var n=e();function r({ref:e,justify:r,align:i,hAlign:a,vAlign:o,...s}){return(0,n.jsx)(t,{...s,direction:`vertical`,hAlign:a??i,vAlign:o??r,ref:e})}r.displayName=`VStack`;export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t}from"./themeProps-Bo2jNkIC.js";var n=e(t(),1);function r({children:e,as:t=`span`,ref:r,...i}){let{xstyle:a,className:o,style:s,...c}=i;return(0,n.createElement)(t,{ref:r,...c,className:`x10l6tqk x1i1rx1s xjm9jq1 xkdpibf x1717udv xb3r6kr xzpqnlu xuxw1ft xng3xce x13vifvy x1o0tod x47corl x87ps6o`},e)}r.displayName=`VisuallyHidden`;export{r as t};
|
|
@@ -4441,14 +4441,16 @@ export { listsPatterns, matchersOf, PATTERN_COMPILER_VERSION, patternListProblem
|
|
|
4441
4441
|
import { type Boundary } from './boundaries.js';
|
|
4442
4442
|
import { type CompiledPatterns, type HostMatcher, type HostPattern } from './host-patterns.js';
|
|
4443
4443
|
/**
|
|
4444
|
-
* What the kernel finds in text: the
|
|
4444
|
+
* What the kernel finds in text: the families of sensitive data, prompt-injection phrasing,
|
|
4445
4445
|
* a tool's text that instructs the agent, and what is the profile's own on its way out (the canary token, the system instruction, the
|
|
4446
4446
|
* kernel's markers, an image or link to an address the model was not given, and the names of its
|
|
4447
4447
|
* tools).
|
|
4448
4448
|
*/
|
|
4449
|
-
declare const DETECTORS: readonly ["ids", "financial", "network", "credentials", "injection", "tool_instructions", "canary_leak", "prompt_leak", "marker_leak", "ungiven_images", "ungiven_links", "tool_leak"];
|
|
4449
|
+
declare const DETECTORS: readonly ["ids", "financial", "network", "credentials", "email", "phone", "bank_account", "injection", "tool_instructions", "canary_leak", "prompt_leak", "marker_leak", "ungiven_images", "ungiven_links", "tool_leak"];
|
|
4450
4450
|
/** A detector recognizes a particular kind of content in text. Its configured action determines what happens when it finds a match. */
|
|
4451
4451
|
type Detector = (typeof DETECTORS)[number];
|
|
4452
|
+
/** The detectors a text is cleaned with when no profile says how: every one but the working groups (\`WORKING_GROUPS\`). */
|
|
4453
|
+
declare const UNPROFILED_DETECTORS: readonly Detector[];
|
|
4452
4454
|
/**
|
|
4453
4455
|
* What the kernel does with a match, the same at every boundary:
|
|
4454
4456
|
* - \`ignore\` — the text is not checked.
|
|
@@ -4652,7 +4654,7 @@ declare function isDetector(value: string): value is Detector;
|
|
|
4652
4654
|
*/
|
|
4653
4655
|
declare function detectProblem(path: string, spec: unknown, boundaries?: readonly Boundary[]): string | undefined;
|
|
4654
4656
|
export type { DetectAction, DetectMatrix, DetectMeta, Detector, DetectorConfig, DetectorDeclaration, DetectorGroup, DetectorRule, DetectorSource, DetectSources, DetectSpec, HostDetector, HostDetectorConfig, HostDetectorId, HostFind, HostSpan, NameAllow, ResolvedAllow, ResolvedDetect, UrlAllow, UrlDetector, };
|
|
4655
|
-
export { actionAt, DETECT_ACTION_META, DETECT_ACTIONS, DETECT_DEFAULTS, DETECTOR_BOUNDARIES, DETECTOR_GROUP_META, DETECTOR_GROUPS, DETECTOR_META, DETECTORS, detectProblem, detects, HOST_FIND_HOLD, HOST_FIND_HOLD_LIVE, hintProblem, isDetector, NO_ALLOW, PATTERN_DETECTORS, resolveAllow, resolveDetect, };
|
|
4657
|
+
export { actionAt, DETECT_ACTION_META, DETECT_ACTIONS, DETECT_DEFAULTS, DETECTOR_BOUNDARIES, DETECTOR_GROUP_META, DETECTOR_GROUPS, DETECTOR_META, DETECTORS, detectProblem, detects, HOST_FIND_HOLD, HOST_FIND_HOLD_LIVE, hintProblem, isDetector, NO_ALLOW, PATTERN_DETECTORS, resolveAllow, resolveDetect, UNPROFILED_DETECTORS, };
|
|
4656
4658
|
`,"file:///node_modules/@theoremjs/agents/src/guardrails/boundaries.d.ts":`/** labels-exempt-file: authoring labels and descriptions for boundaries — not runtime user or model copy (P2) */
|
|
4657
4659
|
/** A record with one entry per key, typed by the keys it was built from. */
|
|
4658
4660
|
declare function recordOf<K extends string, V>(keys: readonly K[], value: (key: K) => V): Record<K, V>;
|
|
@@ -8013,7 +8015,7 @@ export { applySpans, blobAt, mergeSpans, OMIT_CANARY, OMIT_INJECTION, OMIT_PROMP
|
|
|
8013
8015
|
`,"file:///node_modules/@theoremjs/agents/src/guardrails/labels.d.ts":`/** Values that fill a label template's \`{param}\` placeholders. */
|
|
8014
8016
|
export type LabelParams = Record<string, string | number>;
|
|
8015
8017
|
/** Keys are stable API. */
|
|
8016
|
-
export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "turn.media_refused_image", "turn.media_refused_video", "turn.media_refused_file", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.cut_off_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.unreachable", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.after_field", "tool.background_field", "tool.background_started", "tool.late_result", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
|
|
8018
|
+
export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "turn.media_refused_image", "turn.media_refused_video", "turn.media_refused_file", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.cut_off_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.email", "detect.hint.phone", "detect.hint.bank_account", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.unreachable", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.after_field", "tool.background_field", "tool.background_started", "tool.late_result", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
|
|
8017
8019
|
/** One of {@linkcode LABEL_KEYS}. */
|
|
8018
8020
|
export type LabelKey = (typeof LABEL_KEYS)[number];
|
|
8019
8021
|
/**
|
|
@@ -11243,8 +11245,8 @@ export declare class HandlerEvents {
|
|
|
11243
11245
|
/**
|
|
11244
11246
|
* Every transport and replay formats through here, so the model's view of a call cannot drift.
|
|
11245
11247
|
* Never embeds \`parts[].data\`: media travels on \`TurnHistoryMessage.parts\`. A result without
|
|
11246
|
-
* \`modelText\` (a host replaying a transcript) has no profile in hand, so every
|
|
11247
|
-
*
|
|
11248
|
+
* \`modelText\` (a host replaying a transcript) has no profile in hand, so the matches of every
|
|
11249
|
+
* detector but the working groups' are replaced.
|
|
11248
11250
|
*/
|
|
11249
11251
|
export declare function formatToolResult(result: ModelToolResult): string;
|
|
11250
11252
|
/** Whether a tool message is a failure the kernel framed, not what the tool returned. */
|
|
@@ -11253,8 +11255,8 @@ export declare function isFramedToolFailure(content: string): boolean;
|
|
|
11253
11255
|
export declare function frameToolFailure(failure: Pick<ToolFailure, 'code' | 'message' | 'details'>): ModelToolResult;
|
|
11254
11256
|
/**
|
|
11255
11257
|
* A failure framed with no profile in hand: the message is remote-authored on HTTP and MCP
|
|
11256
|
-
* tools, so every detector'
|
|
11257
|
-
* executor reads the message at its own boundary instead.
|
|
11258
|
+
* tools, so the matches of every detector but the working groups' are replaced first. A call
|
|
11259
|
+
* that settles through the executor reads the message at its own boundary instead.
|
|
11258
11260
|
*/
|
|
11259
11261
|
export declare function formatToolFailureForModel(failure: Pick<ToolFailure, 'code' | 'message' | 'details'>): ModelToolResult;
|
|
11260
11262
|
`,"file:///node_modules/@theoremjs/agents/src/kernel/tools/harness.d.ts":`import { AWAITING_USER_INPUT_STATUS } from '../schema.js';
|
|
@@ -12659,8 +12661,16 @@ export { CIRCULAR, scanTextOf, textForScan };
|
|
|
12659
12661
|
* The families of sensitive data, each switched on its own: a profile can
|
|
12660
12662
|
* redact credentials and card numbers but leave network addresses alone.
|
|
12661
12663
|
*/
|
|
12662
|
-
declare const SENSITIVE_GROUPS: readonly ["ids", "financial", "network", "credentials"];
|
|
12663
|
-
/**
|
|
12664
|
+
declare const SENSITIVE_GROUPS: readonly ["ids", "financial", "network", "credentials", "email", "phone", "bank_account"];
|
|
12665
|
+
/**
|
|
12666
|
+
* The groups that are data an agent works with (an address to write to, a number to call). They
|
|
12667
|
+
* are read and flagged; their matches are taken out only where a profile says so, never by a
|
|
12668
|
+
* clean that has no profile in hand.
|
|
12669
|
+
*/
|
|
12670
|
+
declare const WORKING_GROUPS: readonly SensitiveGroup[];
|
|
12671
|
+
/** The groups a text is cleaned of when no profile says how: every group but the working ones. */
|
|
12672
|
+
declare const SCRUBBED_GROUPS: readonly SensitiveGroup[];
|
|
12673
|
+
/** A group of sensitive-value checks: ids, financial, network, credentials, email, phone, or bank_account. */
|
|
12664
12674
|
type SensitiveGroup = (typeof SENSITIVE_GROUPS)[number];
|
|
12665
12675
|
/** Per group, whether it runs. A group left out keeps its default. */
|
|
12666
12676
|
type SensitiveSwitches = Partial<Record<SensitiveGroup, boolean>>;
|
|
@@ -12669,9 +12679,9 @@ type SensitiveSelection = boolean | SensitiveSwitches;
|
|
|
12669
12679
|
/** Every group's switch, defaults applied. */
|
|
12670
12680
|
type SensitiveGroups = Readonly<Record<SensitiveGroup, boolean>>;
|
|
12671
12681
|
export type { SensitiveGroup, SensitiveGroups, SensitiveSelection, SensitiveSwitches };
|
|
12672
|
-
export { SENSITIVE_GROUPS };
|
|
12682
|
+
export { SCRUBBED_GROUPS, SENSITIVE_GROUPS, WORKING_GROUPS };
|
|
12673
12683
|
`,"file:///node_modules/@theoremjs/agents/src/guardrails/sensitive.d.ts":`import { type RedactSpan } from '../observability/spans.js';
|
|
12674
|
-
import type
|
|
12684
|
+
import { type SensitiveGroup, type SensitiveSelection } from './sensitive-groups.js';
|
|
12675
12685
|
declare const CARD_CANDIDATE: RegExp;
|
|
12676
12686
|
interface SensitivePattern {
|
|
12677
12687
|
group: SensitiveGroup;
|
|
@@ -12706,6 +12716,9 @@ export declare const DETECT_RULES: {
|
|
|
12706
12716
|
readonly financial: "detect.financial";
|
|
12707
12717
|
readonly network: "detect.network";
|
|
12708
12718
|
readonly credentials: "detect.credentials";
|
|
12719
|
+
readonly email: "detect.email";
|
|
12720
|
+
readonly phone: "detect.phone";
|
|
12721
|
+
readonly bank_account: "detect.bank_account";
|
|
12709
12722
|
readonly injection: "detect.injection";
|
|
12710
12723
|
readonly tool_instructions: "detect.tool_instructions";
|
|
12711
12724
|
readonly canary_leak: "detect.canary_leak";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e,d as t,x as n}from"./schemas-D7cgkv3L.js";import{Cn as r,Dn as i,H as a,Sn as o,Tn as s,Xt as c,fn as l,ir as ee,ln as te,un as ne,wn as u}from"./tool-schema-CxyHWJU1.js";import{c as d}from"./host-patterns-F-KZIzkF.js";import{Cr as re,Hr as f,In as ie,Jn as p,Ln as ae,Nn as oe,Rn as se,Rr as ce,Ur as le,ar as ue,cn as de,gn as m,hn as fe,in as h,kr as pe,mr as me,or as he,xn as g}from"./shaped-data-CDuHM2x5.js";import{E as ge,b as _e,j as ve,k as ye,v as _,w as be}from"./schema-D7LTUA0h.js";import{a as xe,n as Se}from"./live-ingress-OuSlQ6q7.js";var Ce=2,we=4,Te=3,Ee=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,De=/^[A-Za-z0-9+/]*={0,2}$/,Oe=new Set([`text/csv`,`text/plain`,`text/markdown`]);function v(e){let{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}=e;if(t&&n&&r)return{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}}function ke(e,t){if(t.limitsByMime){let n=i(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),a=`${r}/*`;if(t.limitsByMime[a])return t.limitsByMime[a]}return t.maxBytes}function y(e){return`uri`in e}function Ae(e){if(e.type===`speech`)throw new d(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new d(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new d(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=v(e.inputs??{});if(!t)throw new d(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function je(e){let t=0;return e.endsWith(`==`)?t=Ce:e.endsWith(`=`)&&(t=1),Math.floor(e.length*Te/we)-t}function Me(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Ne(e){return e.replace(Ee,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Pe(e,t,n){let r=Me(t);return e===`text/csv`&&(r=Ne(r)),new TextEncoder().encode(n.read(r))}function b(e,t){return t?{...e,fileName:t}:e}function x(e,t,n){return t.filter(t=>!r(e,t.mimeType)).map(e=>b({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function Fe(e,t){let n=[];e.length>t.maxFiles&&n.push({code:`too_many_files`,params:{maxFiles:t.maxFiles}});let r=0;for(let i of e){if(i.sizeBytes===void 0)continue;let e=ke(i.mimeType,t);i.sizeBytes>e&&n.push(b({code:`file_too_large`,params:{maxBytes:e}},i.name)),r+=i.sizeBytes}return r>t.maxTurnBytes&&n.push({code:`turn_too_large`,params:{maxTurnBytes:t.maxTurnBytes}}),n}function S(e,t,n){let r=[];return t.length>0&&!e.attachments&&r.push({code:`attachments_not_accepted`,params:{channel:`attachment`}}),n.length>0&&!e.voice&&r.push({code:`voice_not_accepted`,params:{channel:`voice`}}),r.length>0||t.length===0&&n.length===0?r:(e.attachments&&r.push(...x(e.attachments,t,`attachment`)),e.voice&&r.push(...x(e.voice,n,`voice`)),e.limits?[...r,...Fe([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Ie={mime_not_allowed:`attachments.mime_not_allowed`,too_many_files:`attachments.too_many_files`,too_many_of_kind:`attachments.too_many_of_kind`,file_too_large:`attachments.file_too_large`,turn_too_large:`attachments.turn_too_large`,attachments_not_accepted:`attachments.not_accepted`,voice_not_accepted:`attachments.not_accepted`,limits_unconfigured:`attachments.limits_unconfigured`};function C(e){let t={};for(let[n,r]of Object.entries(e.params??{}))r!==void 0&&(t[n]=r);return e.fileName!==void 0&&(t.fileName=e.fileName),{key:Ie[e.code],params:t}}function Le(e,t){let n=C(e);return f(n.key,n.params,t)}function Re(e){return new d(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(C)})}function w(e){if(!De.test(e))throw new d(`request`,`attachment data must be base64`);return je(e)}function T(e){let t={mimeType:e.mimeType,name:e.name};return y(e)||(t.sizeBytes=w(e.data)),t}function ze(e,t,n){if(!Be(t,n))return;let r=Ae(e),i=S({attachments:u(e,`attachments`),voice:u(e,`voice`),limits:r},(t??[]).map(T),(n??[]).map(T));if(i.length>0)throw Re(i)}function E(e,t){if(y(e))return e;let{mimeType:n,data:r}=e;if(!Oe.has(i(n)))return e;let a=Pe(n,ue(r),t);return{...e,data:he(a)}}function Be(e,t){return(e?.length??0)>0||(t?.length??0)>0}function Ve(e,t,n,r){return ze(e,t,n),{attachments:t?.length?t.map(e=>E(e,r.attachment)):t,voice:n?.length?n.map(e=>E(e,r.voice)):n}}function D(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function O(e){return e==null}function k(e){return O(e)||typeof e!=`object`||Array.isArray(e)?null:e}function A(e){let t=k(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function j(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function M(e){let t=e.properties;return k(t)??{}}function He(e,t){return e?`${e}.${t}`:t}function N(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function Ue(e,t,n,r,i){if(!n)return;let a=await n(t,r);a.isValid||i.push({path:e,error:a.error||a.finding||`Validation failed for '${e}'`})}async function We(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s}=e;if(O(r)){i&&N(t,s);return}await Ue(t,r,a?.[t],o,s);let c=A(n),l=c?k(r):null;c&&l&&await P(c,l,t,a,o,s)}async function P(e,t,n,r,i,a){let o=M(e),s=new Set(j(e)),c=new Set([...Object.keys(o),...s]),l=k(t);for(let e of c)await We({path:He(n,e),propSchema:o[e],child:l?.[e],isRequired:s.has(e),fields:r,options:i,failures:a})}async function Ge(e,t,n,r){let i=A(e);if(!i)throw new d(`config`,`structured validation requires a JSON Schema object root`);let a=[];if(!k(t)){for(let e of j(i))N(e,a);return a}return await P(i,t,``,n,r,a),a}function Ke(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return!1;let r=M(t);if(!Object.hasOwn(r,e)&&!j(t).includes(e))return!1;n=r[e]}return!0}function qe(e){return e.map(e=>e.error).join(`; `)}function F(e,t){let n=e;for(let e of t.split(`.`))n=k(n)?.[e];return n}function I(e,t,n){let[r,...i]=t.split(`.`),a=k(e)??{};return r===void 0?e:{...a,[r]:i.length?I(a[r],i.join(`.`),n):n}}async function Je(e,t,n){let r=[];for(let[i,a]of Object.entries(t??{})){let t=F(e,i);if(Array.isArray(t))for(let[e,o]of t.entries()){let t=await a.check(o,n);t.isValid||r.push({path:i,index:e,item:o,reason:t.error||t.finding||`Validation failed for '${i}'`,onFail:a.onFail})}}return r}function L(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return;n=M(t)[e]}let r=k(n);if(r?.type===`array`)return k(r.items)??void 0}function Ye(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new d(`config`,f(`provider.binding_identity`))}function Xe(e){z(e.id,e.models),J(e.id,e.observability),Z(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Ze(e){z(e.id,e.models),K(e.id,e.guardrails),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new d(`config`,`Profile ${e.id}: a transcription takes a voice clip, so inputs.text must be false`);return{type:`transcription`,id:e.id,identity:{handle:e.identity.handle},...U(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function R(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new d(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`)}function Qe(e,t,n){if(R(e,t,n,ne),Ye(e,t,n,`decision`),`retry`in n)throw new d(`config`,`Profile ${e} model '${t}': a decision binding takes no retry; a decision retries only a transient failure, by the kernel's rule`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0))throw new d(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function $e(e){let t=e.models?D(e.models):void 0;if(!t)throw new d(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Qe(e.id,t,e.models[t])}function et(e){if(e.inputs.state!==`json`)throw new d(`config`,`Profile ${e.id}: decision inputs.state must be 'json'`);let t=e.inputs.maxStateBytes;if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw new d(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new d(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function tt(e){return $e(e),et(e),J(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function nt(e){return e===void 0?{}:{parallel:e}}function rt(e){return it(e.id,e.tools),J(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function it(e,t){if(!Array.isArray(t.allow))throw new d(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function z(e,t){if(Object.keys(t).length===0)throw new d(`config`,`Profile ${e} must declare at least one model`)}function B(e,t){let n=t.defaultModel??D(t.models);if(!n)throw new d(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new d(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function V(e,t,n){H(e,t,n),R(e,t,n,l),H(e,t,n)}function H(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new d(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!g.includes(i))throw new d(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${g.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new d(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new d(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new d(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function U(e){return{providerContinuation:e.providerContinuation?ee.parse(e.providerContinuation):{},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function W(e,t,n){if(n?.length){for(let r of n)if(!c(r))throw new d(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (length | stream_incomplete | provider_error); got '${r}'`)}}function at(e,t){t&&(W(e,`allowContinue`,t.allowContinue),W(e,`autoContinue`,t.autoContinue))}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ot(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>G(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var st=Object.entries(fe).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function ct(e){if(!G(e))throw new d(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new d(`config`,`Profile definition must set id`);if(!m.find(t=>t===e.type))throw new d(`config`,`Profile ${t}: type must be one of ${m.join(`, `)}`)}function lt(e){let t=e.identity?.handle,n=[[`id`,e.id,64],[`identity.handle`,typeof t==`string`?t:``,32]];for(let[t,r,i]of n)if(!(Array.from(r).length<=i))throw new d(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function ut(e){let{id:t,type:n}=e,r=e;for(let[e,i]of st){if(i&&!i.includes(n))continue;let a=ae(e),o=ot(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!G(e))return!1;let t=e[s];return t==null||t===``}))throw new d(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function dt(e){let{id:t,type:n}=e;if(n!==`live`&&se(`inputs`).includes(n)&&e.inputs==null)throw new d(`config`,`Profile ${t}: type '${n}' must set inputs`)}function ft(e){let[t]=ie(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new d(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function pt(e,t){let n=t.turnBehaviour;at(e,n?.resumption)}function mt(e,t){let n=t=>new d(`config`,`Profile ${e}: ${t}`),r=t?.maxRetries;if(r!==void 0&&(!Number.isInteger(r)||r<0))throw n(`outputs.validation.maxRetries must be a non-negative integer`)}function K(e,t){let n=t=>new d(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!q.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${q.join(`, `)}`);gt(t?.blockedReply,n)}var q=[`quota`,`detect`,`blockedReply`,`network`,`taint`],ht=[`onBlock`,`maxRetries`];function gt(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!ht.includes(e));if(n!==void 0)throw t(`guardrails.blockedReply.${n} is not a setting; it takes onBlock and maxRetries`);let{onBlock:r,maxRetries:i}=e;if(r!==void 0&&!me.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${me.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function _t(e){let t=e.guardrails?.detect,n=e.type===`host`?p(`guardrails.detect`,t,re):p(`guardrails.detect`,t);if(n!==void 0)throw new d(`config`,`Profile ${e.id}: ${n}`)}function J(e,t){try{let n=xe(t);if(!Number.isFinite(n.retainForDays))throw new d(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new d(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof d&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new d(pe(t),`Profile ${e}: ${n}`,{cause:t})}}function vt(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`transcription`||e.type===`embedding`)return;let{options:t,system:n}=e.identity,r=n??``;be(r,`Profile ${e.id} identity.system`);let i=ge(r,t,e.inputs?.options);if(i)throw new d(`config`,`Profile ${e.id} identity.system: ${i}`)}function Y(e){let t=yt(e),[n]=oe(e);if(n)throw new d(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function yt(e){ct(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new d(`config`,f(`provider.profile_configuration`,{profile:e.id,field:t}));ft(e),dt(e),ut(e),lt(e),e.labels&&le(e.labels,`Profile ${e.id}`);for(let t of ce)if(e.labels?.[t]!==void 0)throw new d(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(vt(e),_t(e),e.type===`host`)return rt(e);if(e.type===`decision`)return tt(e);if(e.type===`embedding`)return Xe(e);if(e.type===`transcription`)return Ze(e);z(e.id,e.models),pt(e.id,e),K(e.id,e.guardrails),e.type===`text`&&mt(e.id,e.outputs?.validation),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,options:e.identity.options,system:e.identity.system},n=e.guardrails,r=e.observability,i=e.labels,a=U(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`image`:o={type:`image`,id:e.id,identity:t,...a,image:e.image,tools:e.tools,inputs:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Tt(o.id,o.inputs.attachments?.accept),wt(o.id,o.image);break;case`speech`:o={type:`speech`,id:e.id,identity:t,...a,speech:e.speech,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`live`:o={type:`live`,id:e.id,identity:t,...a,live:e.live,inputs:e.inputs,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Se(o),Dt(o.id,o.live.contextCompression),Et(o);break;default:throw new d(`config`,`Unknown profile type '${String(e)}'`)}return St(o),bt(o),xt(o),o}function bt(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function xt(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new d(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function St(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=ve(e,t.by);if(!n)throw new d(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not one of the profile's options`);let r=ye(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new d(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of option '${t.by}'`)}var Ct={n:{ok:e=>Number.isInteger(e)&&e>=1,rule:`a whole number of 1 or more`},seed:{ok:Number.isInteger,rule:`a whole number`},outputCompression:{ok:e=>Number.isInteger(e)&&e>=0&&e<=100,rule:`a whole number from 0 to 100`}};function wt(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Ct)){let a=t[n];if(a!==void 0&&!r(a))throw new d(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(o(t.mimeType)!==`image`)throw new d(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(y(t)?t.uri:t.data))throw new d(`config`,`${r} needs its bytes or its uri`)})}function Tt(e,t){let n=t?.filter(e=>!r(de,e));if(n?.length)throw new d(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function Et(e){let{greeting:t,resumed:n,sessionResumption:r}=e.live,i=`Profile ${e.id} live`;if(t!==void 0&&(typeof t!=`string`||!t.trim()))throw new d(`config`,`${i}.greeting must be a prompt; leave it out to wait`);if(!n)return;if(typeof n.prompt!=`string`||!n.prompt.trim())throw new d(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new d(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new d(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function Dt(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(X(`${n}.triggerTokens`,r),X(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new d(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function X(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`${e} must be a whole number above 0`)}function Ot(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(kt(i,r),At(i,r),r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new d(`config`,`${i}: a profile that compacts itself must be a text profile that takes text`);return}let a=e.get(r.profile);if(!a)throw new d(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new d(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function kt(e,t){if(t.maxTokens<=0)throw new d(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new d(`config`,`${e}: compactAt must be in (0, 1)`)}function At(e,t){if(t.previousExchanges<0)throw new d(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new d(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new d(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function jt(e,t){for(let n of _(t))if(e.get(n)?.type===`builtin`)throw new d(`config`,t.type===`host`?`Profile ${t.id} lists builtin '${n}' in tools.allow — type 'host' never runs a model`:`Profile ${t.id} lists builtin '${n}' in tools.allow — declare it on models.*.builtInTools instead`)}function Mt(e,t){let n=_e(t)?.t2Loader;if(n){if(!_(t).includes(n))throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*Nt(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Pt(e,t){for(let{modelId:n,id:r}of Nt(t))if(e.get(r)?.type!==`builtin`)throw new d(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Ft(e){let t=e.type===`text`?e.outputs?.structured:void 0;return t?typeof t==`string`?[t]:[...new Set([...Object.values(t.map),t.fallback])]:[]}function It(e,t){let n=Ft(t).map(n=>{let r=e.find(n);if(!r)throw new d(`config`,`Profile ${t.id}: outputs.structured names '${n}', which is not a registered schema; register it before the profile`);return r}),r=t.type===`text`?t.outputs?.validation:void 0,i=Object.keys(r?.fields??{}),a=Object.keys(r?.items??{});if(!i.length&&!a.length)return;if(!n.length)throw new d(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>L(t.jsonSchema,e)));if(o.length)throw new d(`config`,`Profile ${t.id}: outputs.validation.items has ${o.join(`, `)}, which no structured schema reaches as a list with an items schema`);let s=i.filter(e=>!n.some(t=>Ke(t.jsonSchema,e)));if(s.length)throw new d(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function Lt(e){let t=s(e)?.context;if(!t)return;let n=h;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new d(`config`,`Profile ${e.id}: inputs.context.from must list ${h.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new d(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function Z(e,t){if(!t)return;let{attachments:n,voice:r,maxFiles:i,maxBytes:a,maxTurnBytes:o,limitsByMime:s}=t,c={maxFiles:i,maxBytes:a,maxTurnBytes:o};if((n||r)&&Object.values(c).some(e=>e===void 0))throw new d(`config`,`Profile ${e} must set maxFiles, maxBytes, and maxTurnBytes`);for(let[e,t]of Object.entries(s??{}))c[`limitsByMime['${e}']`]=t;for(let[t,n]of Object.entries(c))if(n!==void 0&&!(Number.isInteger(n)&&n>0))throw new d(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function Rt(e,t,n){let r=new Map,i=i=>{let a=Y(i),o=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,te(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(jt(e,o),Mt(e,o),o.type!==`host`&&o.type!==`decision`&&o.type!==`embedding`){Pt(e,o),Z(o.id,s(o)),Lt(o),It(t,o);for(let[e,t]of Object.entries(o.models))t.compaction&&Ot(r,o,e,t.compaction)}r.set(o.id,o)};return{register:i,registerMany(e){for(let t of e)i(t)},get(e){let t=r.get(e);if(!t)throw new d(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function zt(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function Q(e){let t;try{t=new URL(e.baseUrl)}catch{throw new d(`config`,`Enter a valid localhost URL.`)}if(![`http:`,`https:`].includes(t.protocol)||![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)||t.username||t.password||t.search||t.hash)throw new d(`config`,`Use a localhost URL without credentials, query parameters or a fragment.`);return{baseUrl:t.href.replace(/\/$/,``),fetch:(e,n)=>new URL(e instanceof Request?e.url:String(e)).origin===t.origin?fetch(e,{...n,redirect:`error`,credentials:`omit`}):Promise.reject(new d(`blocked`,`Local requests must stay on the configured origin.`))}}var Bt=n({data:t(n({id:e().min(1)}))});async function Vt(e,t){let n=Q(e);if(!n?.fetch)throw new d(`config`,`Enter a local endpoint.`);let r=await n.fetch(`${n.baseUrl}/v1/models`,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)throw new d(`network`,`Local model list returned HTTP ${r.status}.`);let i=Bt.safeParse(await r.json());if(!i.success)throw new d(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var Ht=`https://openrouter.ai/api/v1/models`,Ut=`https://openrouter.ai/api/v1/embeddings/models`,Wt=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],Gt=[{id:`liquid/lfm-2.5-embedding-350m:free`,label:`Liquid LFM 2.5 Embedding 350M (free)`},{id:`nvidia/nemotron-3-embed-1b:free`,label:`NVIDIA Nemotron 3 Embed 1B (free)`},{id:`nvidia/llama-nemotron-embed-vl-1b-v2:free`,label:`NVIDIA Llama Nemotron Embed VL 1B v2 (free)`}],Kt={text:`text`,image:`image`,speech:`speech`,transcription:`transcription`,live:void 0,embedding:void 0},qt=n({data:t(n({id:e().min(1),name:e().optional(),architecture:n({output_modalities:t(e()).optional()}).optional()}))}),Jt=n({data:t(n({id:e().min(1),name:e().optional()}))}),Yt=n({models:t(n({name:e().min(1),displayName:e().optional(),supportedGenerationMethods:t(e()).optional()})).optional(),nextPageToken:e().optional()}),Xt=5;async function $(e,t,n){let r=await fetch(t,{...n,redirect:`error`,credentials:`omit`});if(r.status===400||r.status===401||r.status===403)throw new d(`auth`,`${e} refused the key.`);if(!r.ok)throw new d(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function Zt(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?Gt:Wt];if(e===`openrouter`)return await Qt(t,i,r);if(!i)throw new d(`auth`,`Choose a key to list Gemini models.`);return await en(t,i,r)}async function Qt(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Jt.safeParse(await $(`OpenRouter`,Ut,r));if(!e.success)throw new d(`bad_response`,`OpenRouter returned an invalid embedding model list.`);return e.data.data.map(e=>({id:e.id,label:e.name??e.id}))}let i=Kt[e];if(!i)return[];let a=qt.safeParse(await $(`OpenRouter`,`${Ht}?output_modalities=${i}`,r));if(!a.success)throw new d(`bad_response`,`OpenRouter returned an invalid model list.`);return a.data.data.filter(e=>e.architecture?.output_modalities?.includes(i)??!0).map(e=>({id:e.id,label:e.name??e.id}))}var $t={live:`bidiGenerateContent`,embedding:`embedContent`};async function en(e,t,n){let r=$t[e]??`generateContent`,i=[],o;for(let e=0;e<Xt;e++){let e=new URL(a);e.searchParams.set(`pageSize`,`1000`),o&&e.searchParams.set(`pageToken`,o);let s=Yt.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!s.success)throw new d(`bad_response`,`Google returned an invalid model list.`);for(let e of s.data.models??[]){if(!e.supportedGenerationMethods?.includes(r))continue;let t=e.name.replace(/^models\//,``);i.push({id:t,label:e.displayName??t})}if(o=s.data.nextPageToken,!o)break}return i}function tn(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function nn(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{Ve as S,S as _,tn as a,y as b,Y as c,qe as d,L as f,Le as g,D as h,Q as i,Je as l,I as m,Vt as n,nn as o,F as p,Zt as r,Rt as s,zt as t,Ge as u,Re as v,v as x,w as y};
|
|
1
|
+
import{E as e,d as t,x as n}from"./schemas-D7cgkv3L.js";import{Cn as r,Dn as i,H as a,Sn as o,Tn as s,Xt as c,fn as l,ir as ee,ln as te,un as ne,wn as u}from"./tool-schema-C7QZtUhR.js";import{c as d}from"./host-patterns-F-KZIzkF.js";import{Ar as re,In as ie,Ln as ae,Nn as oe,Rn as se,Ur as f,Wr as ce,Yn as p,cn as le,gn as m,hn as ue,hr as h,in as de,or as fe,sr as pe,wr as me,xn as g,zr as he}from"./shaped-data-BPXuDrSn.js";import{E as ge,b as _e,j as ve,k as ye,v as _,w as be}from"./schema-5VLoC-4Z.js";import{a as xe,n as Se}from"./live-ingress-OuSlQ6q7.js";var Ce=2,we=4,Te=3,Ee=/(^|,)(\s*)("?)(?:([=@])|([+-])(?![0-9."]))/gm,De=/^[A-Za-z0-9+/]*={0,2}$/,Oe=new Set([`text/csv`,`text/plain`,`text/markdown`]);function v(e){let{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}=e;if(t&&n&&r)return{maxFiles:t,maxBytes:n,maxTurnBytes:r,limitsByMime:i}}function ke(e,t){if(t.limitsByMime){let n=i(e);if(t.limitsByMime[n])return t.limitsByMime[n];let[r]=n.split(`/`),a=`${r}/*`;if(t.limitsByMime[a])return t.limitsByMime[a]}return t.maxBytes}function y(e){return`uri`in e}function Ae(e){if(e.type===`speech`)throw new d(`request`,`Profile ${e.id} (speech) does not accept media input`);if(e.type===`live`)throw new d(`request`,`Profile ${e.id} (live) does not accept turn attachment input`);if(e.type===`host`||e.type===`decision`||e.type===`embedding`)throw new d(`request`,`Profile ${e.id} (${e.type}) does not accept turn input`);let t=v(e.inputs??{});if(!t)throw new d(`config`,`Profile ${e.id} must set maxFiles, maxBytes, and maxTurnBytes`);return t}function je(e){let t=0;return e.endsWith(`==`)?t=Ce:e.endsWith(`=`)&&(t=1),Math.floor(e.length*Te/we)-t}function Me(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return new TextDecoder(`latin1`).decode(e)}}function Ne(e){return e.replace(Ee,(e,...t)=>{let[n,r,i,a,o]=t;return`${n}${r}${i}'${a??``}${o??``}`})}function Pe(e,t,n){let r=Me(t);return e===`text/csv`&&(r=Ne(r)),new TextEncoder().encode(n.read(r))}function b(e,t){return t?{...e,fileName:t}:e}function x(e,t,n){return t.filter(t=>!r(e,t.mimeType)).map(e=>b({code:`mime_not_allowed`,params:{mimeType:e.mimeType,channel:n}},e.name))}function Fe(e,t){let n=[];e.length>t.maxFiles&&n.push({code:`too_many_files`,params:{maxFiles:t.maxFiles}});let r=0;for(let i of e){if(i.sizeBytes===void 0)continue;let e=ke(i.mimeType,t);i.sizeBytes>e&&n.push(b({code:`file_too_large`,params:{maxBytes:e}},i.name)),r+=i.sizeBytes}return r>t.maxTurnBytes&&n.push({code:`turn_too_large`,params:{maxTurnBytes:t.maxTurnBytes}}),n}function S(e,t,n){let r=[];return t.length>0&&!e.attachments&&r.push({code:`attachments_not_accepted`,params:{channel:`attachment`}}),n.length>0&&!e.voice&&r.push({code:`voice_not_accepted`,params:{channel:`voice`}}),r.length>0||t.length===0&&n.length===0?r:(e.attachments&&r.push(...x(e.attachments,t,`attachment`)),e.voice&&r.push(...x(e.voice,n,`voice`)),e.limits?[...r,...Fe([...t,...n],e.limits)]:[...r,{code:`limits_unconfigured`}])}var Ie={mime_not_allowed:`attachments.mime_not_allowed`,too_many_files:`attachments.too_many_files`,too_many_of_kind:`attachments.too_many_of_kind`,file_too_large:`attachments.file_too_large`,turn_too_large:`attachments.turn_too_large`,attachments_not_accepted:`attachments.not_accepted`,voice_not_accepted:`attachments.not_accepted`,limits_unconfigured:`attachments.limits_unconfigured`};function C(e){let t={};for(let[n,r]of Object.entries(e.params??{}))r!==void 0&&(t[n]=r);return e.fileName!==void 0&&(t.fileName=e.fileName),{key:Ie[e.code],params:t}}function Le(e,t){let n=C(e);return f(n.key,n.params,t)}function Re(e){return new d(`input`,`attachments refused: ${e.map(e=>e.code).join(`, `)}`,{copy:e.map(C)})}function w(e){if(!De.test(e))throw new d(`request`,`attachment data must be base64`);return je(e)}function T(e){let t={mimeType:e.mimeType,name:e.name};return y(e)||(t.sizeBytes=w(e.data)),t}function ze(e,t,n){if(!Be(t,n))return;let r=Ae(e),i=S({attachments:u(e,`attachments`),voice:u(e,`voice`),limits:r},(t??[]).map(T),(n??[]).map(T));if(i.length>0)throw Re(i)}function E(e,t){if(y(e))return e;let{mimeType:n,data:r}=e;if(!Oe.has(i(n)))return e;let a=Pe(n,fe(r),t);return{...e,data:pe(a)}}function Be(e,t){return(e?.length??0)>0||(t?.length??0)>0}function Ve(e,t,n,r){return ze(e,t,n),{attachments:t?.length?t.map(e=>E(e,r.attachment)):t,voice:n?.length?n.map(e=>E(e,r.voice)):n}}function D(e){let t=Object.keys(e);return t.length===1?t[0]:void 0}function O(e){return e==null}function k(e){return O(e)||typeof e!=`object`||Array.isArray(e)?null:e}function A(e){let t=k(e);return!t||t.type!==void 0&&t.type!==`object`?null:t}function j(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function M(e){let t=e.properties;return k(t)??{}}function He(e,t){return e?`${e}.${t}`:t}function N(e,t){t.push({path:e,error:`required field '${e}' is missing`})}async function Ue(e,t,n,r,i){if(!n)return;let a=await n(t,r);a.isValid||i.push({path:e,error:a.error||a.finding||`Validation failed for '${e}'`})}async function We(e){let{path:t,propSchema:n,child:r,isRequired:i,fields:a,options:o,failures:s}=e;if(O(r)){i&&N(t,s);return}await Ue(t,r,a?.[t],o,s);let c=A(n),l=c?k(r):null;c&&l&&await P(c,l,t,a,o,s)}async function P(e,t,n,r,i,a){let o=M(e),s=new Set(j(e)),c=new Set([...Object.keys(o),...s]),l=k(t);for(let e of c)await We({path:He(n,e),propSchema:o[e],child:l?.[e],isRequired:s.has(e),fields:r,options:i,failures:a})}async function Ge(e,t,n,r){let i=A(e);if(!i)throw new d(`config`,`structured validation requires a JSON Schema object root`);let a=[];if(!k(t)){for(let e of j(i))N(e,a);return a}return await P(i,t,``,n,r,a),a}function Ke(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return!1;let r=M(t);if(!Object.hasOwn(r,e)&&!j(t).includes(e))return!1;n=r[e]}return!0}function qe(e){return e.map(e=>e.error).join(`; `)}function F(e,t){let n=e;for(let e of t.split(`.`))n=k(n)?.[e];return n}function I(e,t,n){let[r,...i]=t.split(`.`),a=k(e)??{};return r===void 0?e:{...a,[r]:i.length?I(a[r],i.join(`.`),n):n}}async function Je(e,t,n){let r=[];for(let[i,a]of Object.entries(t??{})){let t=F(e,i);if(Array.isArray(t))for(let[e,o]of t.entries()){let t=await a.check(o,n);t.isValid||r.push({path:i,index:e,item:o,reason:t.error||t.finding||`Validation failed for '${i}'`,onFail:a.onFail})}}return r}function L(e,t){let n=e;for(let e of t.split(`.`)){let t=A(n);if(!t)return;n=M(t)[e]}let r=k(n);if(r?.type===`array`)return k(r.items)??void 0}function Ye(e,t,n,r){if(!n.provider?.trim()||!n.apiId?.trim())throw new d(`config`,f(`provider.binding_identity`))}function Xe(e){z(e.id,e.models),J(e.id,e.observability),Z(e.id,e.inputs);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);return{type:`embedding`,id:e.id,identity:{handle:e.identity.handle},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,inputs:e.inputs,guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function Ze(e){z(e.id,e.models),K(e.id,e.guardrails),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);if(`text`in e.inputs&&e.inputs.text!==!1)throw new d(`config`,`Profile ${e.id}: a transcription takes a voice clip, so inputs.text must be false`);return{type:`transcription`,id:e.id,identity:{handle:e.identity.handle},...U(e),providerContinuation:void 0,maxSteps:void 0,inputs:{...e.inputs,text:!1},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function R(e,t,n,r){let i=r.safeParse(n);if(!i.success)throw new d(`config`,`Profile ${e} model '${t}': ${i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `)}`)}function Qe(e,t,n){if(R(e,t,n,ne),Ye(e,t,n,`decision`),`retry`in n)throw new d(`config`,`Profile ${e} model '${t}': a decision binding takes no retry; a decision retries only a transient failure, by the kernel's rule`);if(n.timeoutMs!==void 0&&(!Number.isFinite(n.timeoutMs)||n.timeoutMs<=0))throw new d(`config`,`Profile ${e} model '${t}' timeoutMs must be > 0`)}function $e(e){let t=e.models?D(e.models):void 0;if(!t)throw new d(`config`,`Profile ${e.id}: type 'decision' must declare exactly one model`);Qe(e.id,t,e.models[t])}function et(e){if(e.inputs.state!==`json`)throw new d(`config`,`Profile ${e.id}: decision inputs.state must be 'json'`);let t=e.inputs.maxStateBytes;if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw new d(`config`,`Profile ${e.id}: decision inputs.maxStateBytes must be a positive integer`);if(!e.decision.contract.trim())throw new d(`config`,`Profile ${e.id}: decision.contract must be non-empty`)}function tt(e){return $e(e),et(e),J(e.id,e.observability),{...e,identity:{handle:e.identity.handle}}}function nt(e){return e===void 0?{}:{parallel:e}}function rt(e){return it(e.id,e.tools),J(e.id,e.observability),{type:`host`,id:e.id,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},guardrails:e.guardrails,observability:e.observability,labels:e.labels}}function it(e,t){if(!Array.isArray(t.allow))throw new d(`config`,`Profile ${e}: type 'host' must set tools.allow`)}function z(e,t){if(Object.keys(t).length===0)throw new d(`config`,`Profile ${e} must declare at least one model`)}function B(e,t){let n=t.defaultModel??D(t.models);if(!n)throw new d(`config`,`Profile ${e} must set defaultModel when more than one model is declared`);if(!t.models[n])throw new d(`config`,`Profile ${e} defaultModel '${n}' is not declared`);return n}function V(e,t,n){H(e,t,n),R(e,t,n,l),H(e,t,n)}function H(e,t,n){let r=n.efforts;if(!r||Object.keys(r).length===0){if(n.defaultEffort||n.allowEffortSelect)throw new d(`config`,`Profile ${e} model '${t}': defaultEffort and allowEffortSelect require efforts`);return}for(let[n,i]of Object.entries(r))if(!g.includes(i))throw new d(`config`,`Profile ${e} model '${t}' effort '${n}': '${i}' is not a thinking level (${g.join(`, `)})`);let i=Object.keys(r),a=n.defaultEffort??(i.length===1?i[0]:void 0);if(!a)throw new d(`config`,`Profile ${e} model '${t}' must set defaultEffort when more than one effort is declared`);if(!r[a])throw new d(`config`,`Profile ${e} model '${t}' defaultEffort '${a}' is not declared`);if(n.allowEffortSelect&&i.length<2)throw new d(`config`,`Profile ${e} model '${t}' allowEffortSelect requires at least two efforts`)}function U(e){return{providerContinuation:e.providerContinuation?ee.parse(e.providerContinuation):{},models:e.models,defaultModel:B(e.id,e),allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps}}function W(e,t,n){if(n?.length){for(let r of n)if(!c(r))throw new d(`config`,`Profile ${e}: turnBehaviour.resumption.${t} may only include ContinueStopKind (length | stream_incomplete | provider_error); got '${r}'`)}}function at(e,t){t&&(W(e,`allowContinue`,t.allowContinue),W(e,`autoContinue`,t.autoContinue))}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ot(e,t){let n=[e];for(let e of t)n=n.flatMap(t=>G(t)?e===`*`?Object.values(t):[t[e]]:[]);return n}var st=Object.entries(ue).filter(([,e])=>e.required===!0).map(([e,t])=>[e,t.profileTypes]).sort(([e],[t])=>e.split(`.`).length-t.split(`.`).length);function ct(e){if(!G(e))throw new d(`config`,`Profile definition must be an object`);let t=typeof e.id==`string`&&e.id.trim()?e.id:void 0;if(!t)throw new d(`config`,`Profile definition must set id`);if(!m.find(t=>t===e.type))throw new d(`config`,`Profile ${t}: type must be one of ${m.join(`, `)}`)}function lt(e){let t=e.identity?.handle,n=[[`id`,e.id,64],[`identity.handle`,typeof t==`string`?t:``,32]];for(let[t,r,i]of n)if(!(Array.from(r).length<=i))throw new d(`config`,`Profile ${e.id.slice(0,64)}: ${t} must be at most ${i} characters`)}function ut(e){let{id:t,type:n}=e,r=e;for(let[e,i]of st){if(i&&!i.includes(n))continue;let a=ae(e),o=ot(r,a.slice(0,-1)),s=a[a.length-1];if(o.some(e=>{if(!G(e))return!1;let t=e[s];return t==null||t===``}))throw new d(`config`,`Profile ${t}: type '${n}' must set ${a.join(`.`)}`)}}function dt(e){let{id:t,type:n}=e;if(n!==`live`&&se(`inputs`).includes(n)&&e.inputs==null)throw new d(`config`,`Profile ${t}: type '${n}' must set inputs`)}function ft(e){let[t]=ie(e);if(!t)return;let{offValue:n,reason:r}=t.scope,i=n===void 0?``:` (other than ${n})`;throw new d(`config`,`Profile ${e.id}: type '${e.type}' must not set ${t.path}${i} — ${r}`)}function pt(e,t){let n=t.turnBehaviour;at(e,n?.resumption)}function mt(e,t){let n=t=>new d(`config`,`Profile ${e}: ${t}`),r=t?.maxRetries;if(r!==void 0&&(!Number.isInteger(r)||r<0))throw n(`outputs.validation.maxRetries must be a non-negative integer`)}function K(e,t){let n=t=>new d(`config`,`Profile ${e}: ${t}`),r=Object.keys(t??{}).find(e=>!q.includes(e));if(r!==void 0)throw n(`guardrails.${r} is not a setting; it takes ${q.join(`, `)}`);gt(t?.blockedReply,n)}var q=[`quota`,`detect`,`blockedReply`,`network`,`taint`],ht=[`onBlock`,`maxRetries`];function gt(e,t){if(e===void 0)return;let n=Object.keys(e).find(e=>!ht.includes(e));if(n!==void 0)throw t(`guardrails.blockedReply.${n} is not a setting; it takes onBlock and maxRetries`);let{onBlock:r,maxRetries:i}=e;if(r!==void 0&&!h.includes(r))throw t(`guardrails.blockedReply.onBlock must be one of ${h.join(`, `)}`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw t(`guardrails.blockedReply.maxRetries must be a non-negative integer`)}function _t(e){let t=e.guardrails?.detect,n=e.type===`host`?p(`guardrails.detect`,t,me):p(`guardrails.detect`,t);if(n!==void 0)throw new d(`config`,`Profile ${e.id}: ${n}`)}function J(e,t){try{let n=xe(t);if(!Number.isFinite(n.retainForDays))throw new d(`config`,`Profile ${e}: observability.retainForDays must be a finite number`);if(n.rotateAfterMiB<=0||!Number.isFinite(n.rotateAfterMiB))throw new d(`config`,`Profile ${e}: observability.rotateAfterMiB must be a positive number`)}catch(t){if(t instanceof d&&t.message.startsWith(`Profile `))throw t;let n=t instanceof Error?t.message:String(t);throw new d(re(t),`Profile ${e}: ${n}`,{cause:t})}}function vt(e){if(e.type===`host`||e.type===`decision`||e.type===`speech`||e.type===`transcription`||e.type===`embedding`)return;let{options:t,system:n}=e.identity,r=n??``;be(r,`Profile ${e.id} identity.system`);let i=ge(r,t,e.inputs?.options);if(i)throw new d(`config`,`Profile ${e.id} identity.system: ${i}`)}function Y(e){let t=yt(e),[n]=oe(e);if(n)throw new d(`config`,`Profile ${e.id}: ${n.path} ${n.message}`);return t}function yt(e){ct(e);for(let t of[`key`,`fallbackKey`,`protocol`,`provider`])if(t in e)throw new d(`config`,f(`provider.profile_configuration`,{profile:e.id,field:t}));ft(e),dt(e),ut(e),lt(e),e.labels&&ce(e.labels,`Profile ${e.id}`);for(let t of he)if(e.labels?.[t]!==void 0)throw new d(`config`,`Profile ${e.id}: labels '${t}' is a host line, which a profile cannot change; set it with overrideLabels`);if(vt(e),_t(e),e.type===`host`)return rt(e);if(e.type===`decision`)return tt(e);if(e.type===`embedding`)return Xe(e);if(e.type===`transcription`)return Ze(e);z(e.id,e.models),pt(e.id,e),K(e.id,e.guardrails),e.type===`text`&&mt(e.id,e.outputs?.validation),J(e.id,e.observability);for(let[t,n]of Object.entries(e.models))V(e.id,t,n);let t=e.type===`speech`?{handle:e.identity.handle}:{handle:e.identity.handle,options:e.identity.options,system:e.identity.system},n=e.guardrails,r=e.observability,i=e.labels,a=U(e),o;switch(e.type){case`text`:o={type:`text`,id:e.id,identity:t,...a,tools:e.tools,inputs:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`image`:o={type:`image`,id:e.id,identity:t,...a,image:e.image,tools:e.tools,inputs:e.inputs,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Tt(o.id,o.inputs.attachments?.accept),wt(o.id,o.image);break;case`speech`:o={type:`speech`,id:e.id,identity:t,...a,speech:e.speech,outputs:e.outputs,turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i};break;case`live`:o={type:`live`,id:e.id,identity:t,...a,live:e.live,inputs:e.inputs,tools:{allow:e.tools.allow,...nt(e.tools.parallel)},turnBehaviour:e.turnBehaviour,guardrails:n,observability:r,labels:i},Se(o),Dt(o.id,o.live.contextCompression),Et(o);break;default:throw new d(`config`,`Unknown profile type '${String(e)}'`)}return St(o),bt(o),xt(o),o}function bt(e){let{maxSteps:t}=e;if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`Profile ${e.id}: maxSteps must be a whole number of 1 or more; leave it out for the default of 20`)}function xt(e){if(e.type===`text`&&e.turnBehaviour?.atStepLimit===`answer`&&e.maxSteps===1)throw new d(`config`,`Profile ${e.id}: turnBehaviour.atStepLimit 'answer' with maxSteps 1 leaves no step that can call a tool`)}function St(e){if(e.type===`live`)return;let t=e.outputs?.structured;if(!t||typeof t==`string`)return;let n=ve(e,t.by);if(!n)throw new d(`config`,`Profile ${e.id}: outputs.structured.by '${t.by}' is not one of the profile's options`);let r=ye(n),i=Object.keys(t.map).filter(e=>!r.includes(e));if(i.length)throw new d(`config`,`Profile ${e.id}: outputs.structured.map maps ${i.join(`, `)}, not a choice of option '${t.by}'`)}var Ct={n:{ok:e=>Number.isInteger(e)&&e>=1,rule:`a whole number of 1 or more`},seed:{ok:Number.isInteger,rule:`a whole number`},outputCompression:{ok:e=>Number.isInteger(e)&&e>=0&&e<=100,rule:`a whole number from 0 to 100`}};function wt(e,t){for(let[n,{ok:r,rule:i}]of Object.entries(Ct)){let a=t[n];if(a!==void 0&&!r(a))throw new d(`config`,`Profile ${e}: image.${n} must be ${i}`)}t.references?.forEach((t,n)=>{let r=`Profile ${e}: image.references[${n}]`;if(o(t.mimeType)!==`image`)throw new d(`config`,`${r} must be an image, not '${t.mimeType}'`);if(!(y(t)?t.uri:t.data))throw new d(`config`,`${r} needs its bytes or its uri`)})}function Tt(e,t){let n=t?.filter(e=>!r(le,e));if(n?.length)throw new d(`config`,`Profile ${e}: an image profile's attachments take images, video, and PDF only, not ${n.join(`, `)}`)}function Et(e){let{greeting:t,resumed:n,sessionResumption:r}=e.live,i=`Profile ${e.id} live`;if(t!==void 0&&(typeof t!=`string`||!t.trim()))throw new d(`config`,`${i}.greeting must be a prompt; leave it out to wait`);if(!n)return;if(typeof n.prompt!=`string`||!n.prompt.trim())throw new d(`config`,`${i}.resumed.prompt must be a prompt`);let{afterMs:a}=n;if(a!==void 0&&!(Number.isFinite(a)&&a>=0))throw new d(`config`,`${i}.resumed.afterMs must be 0 or more milliseconds`);if(!r)throw new d(`config`,`${i}.resumed needs live.sessionResumption: without it no call resumes`)}function Dt(e,t){if(!t)return;let n=`Profile ${e} live.contextCompression`,r=t.triggerTokens,i=t.slidingWindow.targetTokens;if(X(`${n}.triggerTokens`,r),X(`${n}.slidingWindow.targetTokens`,i),r!==void 0&&i!==void 0&&i>=r)throw new d(`config`,`${n}: slidingWindow.targetTokens must be below triggerTokens`)}function X(e,t){if(!(t===void 0||Number.isInteger(t)&&t>0))throw new d(`config`,`${e} must be a whole number above 0`)}function Ot(e,t,n,r){let i=`Profile ${t.id} model ${n} compaction`;if(kt(i,r),At(i,r),r.profile===void 0){if(t.type!==`text`||t.inputs.text===!1)throw new d(`config`,`${i}: a profile that compacts itself must be a text profile that takes text`);return}let a=e.get(r.profile);if(!a)throw new d(`config`,`${i}: compaction profile '${r.profile}' must be registered before '${t.id}'`);if(a.type!==`text`||a.inputs.text===!1)throw new d(`config`,`${i}: compaction profile '${r.profile}' must be a text profile that takes text`)}function kt(e,t){if(t.maxTokens<=0)throw new d(`config`,`${e}: maxTokens must be > 0`);if(t.compactAt<=0||t.compactAt>=1)throw new d(`config`,`${e}: compactAt must be in (0, 1)`)}function At(e,t){if(t.previousExchanges<0)throw new d(`config`,`${e}: previousExchanges must be >= 0`);if(t.previousExchanges<1&&t.previousExchanges>=t.compactAt)throw new d(`config`,`${e}: previousExchanges as fraction (${t.previousExchanges}) must be < compactAt (${t.compactAt})`);if(t.previousExchanges>1&&!Number.isInteger(t.previousExchanges))throw new d(`config`,`${e}: previousExchanges >= 1 must be an integer`)}function jt(e,t){for(let n of _(t))if(e.get(n)?.type===`builtin`)throw new d(`config`,t.type===`host`?`Profile ${t.id} lists builtin '${n}' in tools.allow — type 'host' never runs a model`:`Profile ${t.id} lists builtin '${n}' in tools.allow — declare it on models.*.builtInTools instead`)}function Mt(e,t){let n=_e(t)?.t2Loader;if(n){if(!_(t).includes(n))throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must also be listed in tools.allow`);if(e.get(n)?.type!==`function`)throw new d(`config`,`Profile ${t.id} tools.t2Loader '${n}' must be a registered type: 'function' tool`)}}function*Nt(e){for(let[t,n]of Object.entries(e.models))for(let e of n.builtInTools??[])yield{modelId:t,id:e}}function Pt(e,t){for(let{modelId:n,id:r}of Nt(t))if(e.get(r)?.type!==`builtin`)throw new d(`config`,`Profile ${t.id} model '${n}' lists '${r}' in builtInTools — not a registered builtin`)}function Ft(e){let t=e.type===`text`?e.outputs?.structured:void 0;return t?typeof t==`string`?[t]:[...new Set([...Object.values(t.map),t.fallback])]:[]}function It(e,t){let n=Ft(t).map(n=>{let r=e.find(n);if(!r)throw new d(`config`,`Profile ${t.id}: outputs.structured names '${n}', which is not a registered schema; register it before the profile`);return r}),r=t.type===`text`?t.outputs?.validation:void 0,i=Object.keys(r?.fields??{}),a=Object.keys(r?.items??{});if(!i.length&&!a.length)return;if(!n.length)throw new d(`config`,`Profile ${t.id}: outputs.validation checks a structured reply, so it needs outputs.structured`);let o=a.filter(e=>!n.some(t=>L(t.jsonSchema,e)));if(o.length)throw new d(`config`,`Profile ${t.id}: outputs.validation.items has ${o.join(`, `)}, which no structured schema reaches as a list with an items schema`);let s=i.filter(e=>!n.some(t=>Ke(t.jsonSchema,e)));if(s.length)throw new d(`config`,`Profile ${t.id}: outputs.validation.fields has ${s.join(`, `)}, which no structured schema reaches through object properties`)}function Lt(e){let t=s(e)?.context;if(!t)return;let n=de;if(t.from.length===0||t.from.some(e=>!n.includes(e)))throw new d(`config`,`Profile ${e.id}: inputs.context.from must list ${de.join(` or `)}`);if(!(Number.isInteger(t.maxChars)&&t.maxChars>0))throw new d(`config`,`Profile ${e.id}: inputs.context.maxChars must be a positive integer`)}function Z(e,t){if(!t)return;let{attachments:n,voice:r,maxFiles:i,maxBytes:a,maxTurnBytes:o,limitsByMime:s}=t,c={maxFiles:i,maxBytes:a,maxTurnBytes:o};if((n||r)&&Object.values(c).some(e=>e===void 0))throw new d(`config`,`Profile ${e} must set maxFiles, maxBytes, and maxTurnBytes`);for(let[e,t]of Object.entries(s??{}))c[`limitsByMime['${e}']`]=t;for(let[t,n]of Object.entries(c))if(n!==void 0&&!(Number.isInteger(n)&&n>0))throw new d(`config`,`Profile ${e}: inputs.${t} must be a positive integer`)}function Rt(e,t,n){let r=new Map,i=i=>{let a=Y(i),o=n&&a.type!==`host`?{...a,models:Object.fromEntries(Object.entries(a.models).map(([e,t])=>[e,te(n.require(t.provider,t.apiId),t,a.type)]))}:a;if(jt(e,o),Mt(e,o),o.type!==`host`&&o.type!==`decision`&&o.type!==`embedding`){Pt(e,o),Z(o.id,s(o)),Lt(o),It(t,o);for(let[e,t]of Object.entries(o.models))t.compaction&&Ot(r,o,e,t.compaction)}r.set(o.id,o)};return{register:i,registerMany(e){for(let t of e)i(t)},get(e){let t=r.get(e);if(!t)throw new d(`config`,`Unknown profile '${e}'`);return t},find:e=>r.get(e),has:e=>r.has(e),list:()=>[...r.values()],clear:()=>r.clear()}}function zt(e){let t=e?.trim()??``;if(t.startsWith(`AIza`))return`gemini`;if(t.startsWith(`sk-or-`))return`openrouter`}function Q(e){let t;try{t=new URL(e.baseUrl)}catch{throw new d(`config`,`Enter a valid localhost URL.`)}if(![`http:`,`https:`].includes(t.protocol)||![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname)||t.username||t.password||t.search||t.hash)throw new d(`config`,`Use a localhost URL without credentials, query parameters or a fragment.`);return{baseUrl:t.href.replace(/\/$/,``),fetch:(e,n)=>new URL(e instanceof Request?e.url:String(e)).origin===t.origin?fetch(e,{...n,redirect:`error`,credentials:`omit`}):Promise.reject(new d(`blocked`,`Local requests must stay on the configured origin.`))}}var Bt=n({data:t(n({id:e().min(1)}))});async function Vt(e,t){let n=Q(e);if(!n?.fetch)throw new d(`config`,`Enter a local endpoint.`);let r=await n.fetch(`${n.baseUrl}/v1/models`,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)throw new d(`network`,`Local model list returned HTTP ${r.status}.`);let i=Bt.safeParse(await r.json());if(!i.success)throw new d(`request`,`The endpoint returned an invalid model list.`);return[...new Set(i.data.data.map(e=>e.id))]}var Ht=`https://openrouter.ai/api/v1/models`,Ut=`https://openrouter.ai/api/v1/embeddings/models`,Wt=[{id:`gemini-embedding-2-preview`,label:`Gemini Embeddings 2 (preview)`},{id:`gemini-embedding-001`,label:`Gemini Embedding 001`}],Gt=[{id:`liquid/lfm-2.5-embedding-350m:free`,label:`Liquid LFM 2.5 Embedding 350M (free)`},{id:`nvidia/nemotron-3-embed-1b:free`,label:`NVIDIA Nemotron 3 Embed 1B (free)`},{id:`nvidia/llama-nemotron-embed-vl-1b-v2:free`,label:`NVIDIA Llama Nemotron Embed VL 1B v2 (free)`}],Kt={text:`text`,image:`image`,speech:`speech`,transcription:`transcription`,live:void 0,embedding:void 0},qt=n({data:t(n({id:e().min(1),name:e().optional(),architecture:n({output_modalities:t(e()).optional()}).optional()}))}),Jt=n({data:t(n({id:e().min(1),name:e().optional()}))}),Yt=n({models:t(n({name:e().min(1),displayName:e().optional(),supportedGenerationMethods:t(e()).optional()})).optional(),nextPageToken:e().optional()}),Xt=5;async function $(e,t,n){let r=await fetch(t,{...n,redirect:`error`,credentials:`omit`});if(r.status===400||r.status===401||r.status===403)throw new d(`auth`,`${e} refused the key.`);if(!r.ok)throw new d(`network`,`${e} model list returned HTTP ${r.status}.`);return await r.json()}async function Zt(e,t,n,r){let i=n?.trim();if(t===`embedding`&&!i)return[...e===`openrouter`?Gt:Wt];if(e===`openrouter`)return await Qt(t,i,r);if(!i)throw new d(`auth`,`Choose a key to list Gemini models.`);return await en(t,i,r)}async function Qt(e,t,n){let r={signal:n,headers:{Accept:`application/json`,...t?{Authorization:[`Bearer`,t].join(` `)}:{}}};if(e===`embedding`){let e=Jt.safeParse(await $(`OpenRouter`,Ut,r));if(!e.success)throw new d(`bad_response`,`OpenRouter returned an invalid embedding model list.`);return e.data.data.map(e=>({id:e.id,label:e.name??e.id}))}let i=Kt[e];if(!i)return[];let a=qt.safeParse(await $(`OpenRouter`,`${Ht}?output_modalities=${i}`,r));if(!a.success)throw new d(`bad_response`,`OpenRouter returned an invalid model list.`);return a.data.data.filter(e=>e.architecture?.output_modalities?.includes(i)??!0).map(e=>({id:e.id,label:e.name??e.id}))}var $t={live:`bidiGenerateContent`,embedding:`embedContent`};async function en(e,t,n){let r=$t[e]??`generateContent`,i=[],o;for(let e=0;e<Xt;e++){let e=new URL(a);e.searchParams.set(`pageSize`,`1000`),o&&e.searchParams.set(`pageToken`,o);let s=Yt.safeParse(await $(`Google`,e.href,{signal:n,headers:{Accept:`application/json`,"x-goog-api-key":t}}));if(!s.success)throw new d(`bad_response`,`Google returned an invalid model list.`);for(let e of s.data.models??[]){if(!e.supportedGenerationMethods?.includes(r))continue;let t=e.name.replace(/^models\//,``);i.push({id:t,label:e.displayName??t})}if(o=s.data.nextPageToken,!o)break}return i}function tn(e){return[...new Set([e.key,e.fallbackKey,...Object.values(e.models??{}).flatMap(e=>[e.keySlot,e.fallbackKeySlot])].filter(e=>!!e))]}function nn(e,t){return Object.fromEntries(e.map(e=>[e,Object.hasOwn(t,e)?t[e]:void 0]))}export{Ve as S,S as _,tn as a,y as b,Y as c,qe as d,L as f,Le as g,D as h,Q as i,Je as l,I as m,Vt as n,nn as o,F as p,Zt as r,Rt as s,zt as t,Ge as u,Re as v,v as x,w as y};
|