@theoremjs/studio 0.3.4-next.735.g8d504c6 → 0.3.4-next.753.g176c472
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/installed.mjs +10 -1
- package/label-areas.d.ts +5 -0
- package/label-areas.js +6 -0
- package/package.json +19 -4
- package/page/assets/Badge-D78MvW22.js +1 -0
- package/page/assets/{BottomSheet-Dbh6A5Vl.js → BottomSheet-CS905Wxu.js} +1 -1
- package/page/assets/Card-D_40unTk.js +1 -0
- package/page/assets/CheckboxInput-MMjt4mDv.js +2 -0
- package/page/assets/CodeBlock-DzXH_9DF.js +3 -0
- package/page/assets/CollapsibleGroup-D1qiJpkR.js +1 -0
- package/page/assets/ConsoleFrame-CqQsb1GZ.js +3 -0
- package/page/assets/DateInput-BvG86MuZ.js +1 -0
- package/page/assets/{Dialog-Sd04KQS2.js → Dialog-DUNBjHOI.js} +1 -1
- package/page/assets/{HoverCard-DMyWUvwP.js → HoverCard-DMHc1Gh1.js} +1 -1
- package/page/assets/Icon-3c9WmPTH.js +3 -0
- package/page/assets/{IconButton-DVUFx-8p.js → IconButton-BeI1pXEZ.js} +1 -1
- package/page/assets/IconFilter-BO98ezum.js +1 -0
- package/page/assets/IconHistory-VvDVN7WG.js +1 -0
- package/page/assets/{ItemSwipeLayer-Ckn4X6h9.js → ItemSwipeLayer-BzVkYf4E.js} +1 -1
- package/page/assets/{ListItem-QF7KFt0h.js → ListItem-MWWVygeh.js} +1 -1
- package/page/assets/MenuBottomSheet-BInvPU7g.js +1 -0
- package/page/assets/MenuBottomSheetActionList-CYZ56fty.js +1 -0
- package/page/assets/OverflowList-CoxIfkMv.js +1 -0
- package/page/assets/SchemaFields-Bd9lDE4d.js +1 -0
- package/page/assets/ScrollableArea-CZpbLBeP.js +1 -0
- package/page/assets/SidePanel-Bp_RI52Y.js +2 -0
- package/page/assets/{Text-BOqCfzZC.js → Text-B74VhVA7.js} +2 -2
- package/page/assets/TextInput-D1GkClqk.js +1 -0
- package/page/assets/{TimestampHoverCard-CDCVpEWM.js → TimestampHoverCard-BNDnoAyp.js} +1 -1
- package/page/assets/ToolResultCharts-CI9TdyAV.js +1 -0
- package/page/assets/Toolbar-RbTb26eP.js +1 -0
- package/page/assets/{Tooltip-BWs5DLrM.js → Tooltip-DrSpWxD8.js} +1 -1
- package/page/assets/TraceInspector-aObqeJHi.js +1 -0
- package/page/assets/{TraceOverview-DqCofwm4.js → TraceOverview-D5c_l1Ux.js} +4 -4
- package/page/assets/{_virtual_studio-type-sources-nXG6uotl.js → _virtual_studio-type-sources-Cc4WAdgD.js} +50 -17
- package/page/assets/browser-connection-159CdeHX.js +1 -0
- package/page/assets/browser-engine-DI5i0e2R.js +16 -0
- package/page/assets/browser-transport-Dh5ab7QT.js +45 -0
- package/page/assets/compile-iB2CAmRL.js +2 -0
- package/page/assets/{container.stylex-BmOi-8DQ.js → container.stylex-C2nFBhUj.js} +1 -1
- package/page/assets/{embedding-space-view-CN0VHXXH.js → embedding-space-view-JuXKDaFw.js} +1 -1
- package/page/assets/encode-files-CeZxxjYd.js +1 -0
- package/page/assets/{export-agent-BrN5vTz2.js → export-agent-Cd8Q-cK9.js} +3 -3
- package/page/assets/{fieldParts-CoOpDoax.js → fieldParts-Dtp1EoJQ.js} +1 -1
- package/page/assets/{focusOutline.stylex-BT0kfa4t.js → focusOutline.stylex-B9nWSXsG.js} +1 -1
- package/page/assets/guardrail-tester-CR-zyzhr.js +9 -0
- package/page/assets/highlightRanges-yrVxbmkN.js +51 -0
- package/page/assets/index-DakRjE8R.css +1 -0
- package/page/assets/index-Kvukosz3.js +149 -0
- package/page/assets/{labels-provider-uONlWExD.js → labels-provider-Dc-AJqPH.js} +2 -2
- package/page/assets/{live-messages-_FDpxQYF.js → live-messages-D-SPyR3e.js} +1 -1
- package/page/assets/menuItemRoles-Bod0knkp.js +1 -0
- package/page/assets/prompt-row-CE0EDTVb.js +71 -0
- package/page/assets/prompt-row-beoYzntJ.css +1 -0
- package/page/assets/reader-DtOL_I1x.js +5 -0
- package/page/assets/registry-DP0ArymS.js +1 -0
- package/page/assets/schema-Cv4HAfBT.js +3 -0
- package/page/assets/shaped-data-DCfLI4gb.js +21 -0
- package/page/assets/{stub-J0Ig6FyA.js → stub-REBz-ZC7.js} +1 -1
- package/page/assets/studio-code-pane-DCaWq57x.js +10 -0
- package/page/assets/{studio-console-BG1WmM3M.js → studio-console-bHQq_-86.js} +1 -1
- package/page/assets/studio-decision-BaoUot8U.js +1 -0
- package/page/assets/studio-embedding-BVMWcpVq.js +2 -0
- package/page/assets/studio-host-console-BfLdRxc9.js +2 -0
- package/page/assets/studio-labels-CNc-S7NH.js +3 -0
- package/page/assets/studio-live-DeDSZSSs.js +5 -0
- package/page/assets/studio-map-u2kDE0i4.js +1 -0
- package/page/assets/studio-trace-replay-BInKCErs.js +3 -0
- package/page/assets/{studio-type-checker-CF7Re1aY.js → studio-type-checker-JZuu4iVI.js} +1 -1
- package/page/assets/{tokens.stylex-DkHf0P9C.js → tokens.stylex-BpCwr7Mf.js} +1 -1
- package/page/assets/tool-schema-BwaPiLtT.js +17 -0
- package/page/assets/{trace-patterns-D6TbkLLr.js → trace-patterns-D5Rcl0G4.js} +1 -1
- package/page/assets/{trace-record-YSvR6YMe.js → trace-record--uEnDt_D.js} +1 -1
- package/page/assets/tree-CL4ETBd5.js +3 -0
- package/page/assets/{turn-client-Xn70kpoZ.js → turn-client-B3jV7UKH.js} +2 -2
- package/page/assets/types-BDx4pnrt.js +1 -0
- package/page/assets/use-one-call-D9ArlH1f.js +1 -0
- package/page/assets/use-second-ticker-DhbZ0Soz.js +1 -0
- package/page/assets/{useAnnounce-DTSHZvjg.js → useAnnounce-DOkF3CS1.js} +1 -1
- package/page/assets/useAnnounceRenderedText-aqUr1P16.js +1 -0
- package/page/assets/{useClipboard-CbN9bb4J.js → useClipboard-BC4cMFBa.js} +1 -1
- package/page/assets/useKeyboardHint-BBkDGjRh.js +1 -0
- package/page/assets/useLocale-D8GRz3lz.js +1 -0
- package/page/assets/useMenuDrillIn-tTYG6Wzi.js +1 -0
- package/page/assets/{useMenuPress-DLG1QOiE.js → useMenuPress-DPpqa6F7.js} +1 -1
- package/page/assets/{useResolvedRequired-DbsOcDqy.js → useResolvedRequired-68GOSl0j.js} +1 -1
- package/page/assets/{useTooltip-c097gL_-.js → useTooltip-BaCjTHk-.js} +1 -1
- package/page/assets/{workspace-Bfoebvk4.js → workspace-B6d08n7C.js} +1 -1
- package/page/index.html +53 -42
- package/prompt-doc.d.ts +24 -0
- package/prompt-doc.js +251 -0
- package/read-source.js +25 -33
- package/section-notes.d.ts +16 -2
- package/section-notes.js +16 -2
- package/server/runs.d.ts +17 -0
- package/server/runs.js +73 -0
- package/server/save-session.d.ts +4 -0
- package/server/save-session.js +10 -6
- package/server/serve.js +76 -12
- package/ui/built/theme.css +1 -1
- package/ui/built/theorem-studio.js +1 -1
- package/ui/inspector-context.d.ts +2 -0
- package/ui/inspector-context.js +2 -0
- package/ui/inspector.d.ts +44 -2
- package/ui/inspector.js +20 -9
- package/ui/lib/studio-watch.d.ts +6 -0
- package/ui/lib/studio-watch.js +16 -0
- package/ui/profile-editor.js +47 -40
- package/ui/prompt-editor.css +112 -0
- package/ui/prompt-editor.d.ts +16 -0
- package/ui/prompt-editor.js +315 -0
- package/ui/prompt-line-node.d.ts +29 -0
- package/ui/prompt-line-node.js +112 -0
- package/ui/prompt-row.d.ts +9 -0
- package/ui/prompt-row.js +25 -0
- package/ui/provider-editor.js +2 -1
- package/ui/studio-compare.js +48 -7
- package/ui/studio-save.d.ts +2 -0
- package/ui/studio-save.js +13 -5
- package/ui/studio-screen.js +18 -16
- package/ui/studio-theme.d.ts +1 -1
- package/ui/studio-theme.js +2 -0
- package/ui/studio-trace-replay.js +5 -5
- package/ui/studio.css +42 -14
- package/page/assets/Banner-BXQ3eMGX.js +0 -3
- package/page/assets/Card-DruykyeB.js +0 -1
- package/page/assets/CheckboxInput-CFZ_Wq8-.js +0 -2
- package/page/assets/CodeBlock-CfVOtDeO.js +0 -52
- package/page/assets/CollapsibleGroup-BsIYDnJR.js +0 -1
- package/page/assets/ConsoleFrame-DDSgPsZH.js +0 -3
- package/page/assets/DateInput-CalwZl6a.js +0 -1
- package/page/assets/Icon-BqkS-pIq.js +0 -3
- package/page/assets/IconEye-BB5aY-wQ.js +0 -1
- package/page/assets/MenuBottomSheet-CGBoKe8D.js +0 -1
- package/page/assets/SchemaFields-D7ClAIou.js +0 -1
- package/page/assets/ScrollableArea-ChTx-OVZ.js +0 -1
- package/page/assets/SegmentedControlItem-CZs-ycSA.js +0 -1
- package/page/assets/SidePanel-DEd3R1Q3.js +0 -2
- package/page/assets/ToolResultCharts-DiEXUaNn.js +0 -1
- package/page/assets/TraceInspector-CaNKb5tj.js +0 -1
- package/page/assets/browser-connection-Dm_C2k-h.js +0 -3
- package/page/assets/browser-engine-BfnMGcT2.js +0 -16
- package/page/assets/browser-transport-9tBHJSxP.js +0 -45
- package/page/assets/crypto-DbeKCGAB.js +0 -1
- package/page/assets/encode-files-BdORDAbw.js +0 -1
- package/page/assets/guardrail-tester-BrSKPdyb.js +0 -9
- package/page/assets/index-Boxd3JUw.js +0 -149
- package/page/assets/index-C9rhrCGT.css +0 -1
- package/page/assets/reader-CHvIE7jW.js +0 -5
- package/page/assets/shaped-data-B5yHkAzM.js +0 -21
- package/page/assets/studio-code-pane-B4bfZLeO.js +0 -10
- package/page/assets/studio-decision-Ck3RM4xV.js +0 -1
- package/page/assets/studio-embedding-pvHODyby.js +0 -2
- package/page/assets/studio-host-console-DAv2ocEl.js +0 -2
- package/page/assets/studio-labels-DLm-OIlS.js +0 -3
- package/page/assets/studio-live-BBVkUupj.js +0 -5
- package/page/assets/studio-map-DE4o1Dw6.js +0 -1
- package/page/assets/studio-trace-replay-DMnAw57P.js +0 -3
- package/page/assets/tool-schema-CAhMfN4z.js +0 -17
- package/page/assets/tree-sm5ci1wZ.js +0 -3
- package/page/assets/use-one-call-DJQhFDfz.js +0 -1
- package/page/assets/use-second-ticker-B_tRvZF_.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer reset;@layer astryx-base{@property --x-left{syntax:"*";inherits:false}@property --x-minHeight{syntax:"*";inherits:false}@property --x-top{syntax:"*";inherits:false}@property --x-width{syntax:"*";inherits:false}.x1qgjean{--astryx-section-padding-inline-end:var(--spacing-1)}.xcfn0br{--astryx-section-padding-inline-start:var(--spacing-1)}.xax9j7h{--container-padding-block-end:0px}.x1047aw6{--container-padding-block-start:0px}.xjsfl84{--container-padding-inline-end:0px}.xrhngw9{--container-padding-inline-start:0px}.x1717udv:not(#\#){padding:0}.xlsj2fj:not(#\#){padding:var(--spacing-2)}.x14i3s5s:not(#\#):not(#\#){border-color:var(--color-border)}.xh6dtrn:not(#\#):not(#\#){border-radius:var(--radius-element)}.xx3sua9:not(#\#):not(#\#){border-radius:var(--radius-inner)}.xng3xce:not(#\#):not(#\#){border-style:none}.x1y0btm7:not(#\#):not(#\#){border-style:solid}.xc342km:not(#\#):not(#\#){border-width:0}.x1litavf:not(#\#):not(#\#){border-width:var(--border-width)}.x845mor:not(#\#):not(#\#){flex:1}.xsn7fz1:not(#\#):not(#\#){gap:var(--spacing-0)}.xrxpjvj:not(#\#):not(#\#){margin-inline:0}.x1a2a7pz:not(#\#):not(#\#){outline:none}.xb3r6kr:not(#\#):not(#\#){overflow:hidden}.x1hp7d8q:not(#\#):not(#\#){padding-block:var(--spacing-0)}.xu0wf1k:not(#\#):not(#\#){padding-block:var(--spacing-1)}.xce4md1:not(#\#):not(#\#){padding-block:var(--spacing-2)}.x17a0aqu:not(#\#):not(#\#){padding-inline:var(--spacing-0)}.x7a5moj:not(#\#):not(#\#){padding-inline:var(--spacing-1)}.xf314gf:not(#\#):not(#\#){padding-inline:var(--spacing-2)}.x1pzlopt:not(#\#):not(#\#){padding-inline:var(--spacing-4)}.xmqliwb:not(#\#):not(#\#){text-decoration:line-through}.x1bvjpef:not(#\#):not(#\#){text-decoration:underline}.x6s0dn4:not(#\#):not(#\#):not(#\#){align-items:center}.x1qjc9v5:not(#\#):not(#\#):not(#\#){align-items:stretch}.xkh2ocl:not(#\#):not(#\#):not(#\#){align-self:stretch}.xwmxj5m:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-muted)}.xzyc27v:not(#\#):not(#\#):not(#\#){background-color:var(--color-syntax-background)}.x1mwwwfo:not(#\#):not(#\#):not(#\#){border-collapse:collapse}.x1gejf6u:not(#\#):not(#\#):not(#\#){border-inline-end-color:var(--color-border)}.x18b5jzi:not(#\#):not(#\#):not(#\#){border-inline-end-style:solid}.xw8tdv1:not(#\#):not(#\#):not(#\#){border-inline-end-width:var(--border-width)}.x14ydlgx:not(#\#):not(#\#):not(#\#){border-inline-start-color:var(--color-border-emphasized)}.x1t7ytsu:not(#\#):not(#\#):not(#\#){border-inline-start-style:solid}.xyumdvf:not(#\#):not(#\#):not(#\#){border-inline-start-width:2px}.x9f619:not(#\#):not(#\#):not(#\#){box-sizing:border-box}.x1afcbsf:not(#\#):not(#\#):not(#\#){box-sizing:content-box}.x1heor9g:not(#\#):not(#\#):not(#\#){color:inherit}.xjt36v0:not(#\#):not(#\#):not(#\#){color:var(--color-error)}.x1mjzq1q:not(#\#):not(#\#):not(#\#){color:var(--color-syntax-comment)}.xjse4m1:not(#\#):not(#\#):not(#\#){color:var(--color-text-accent)}.x1tgivj0:not(#\#):not(#\#):not(#\#){color:var(--color-text-primary)}.xv1l7n4:not(#\#):not(#\#):not(#\#){color:var(--color-text-secondary)}.xt0e3qv:not(#\#):not(#\#):not(#\#){cursor:default}.x1ypdohk:not(#\#):not(#\#):not(#\#){cursor:pointer}.x1epdd7z:not(#\#):not(#\#):not(#\#){direction:inherit}.x1lliihq:not(#\#):not(#\#):not(#\#){display:block}.x78zum5:not(#\#):not(#\#):not(#\#){display:flex}.xrvj5dj:not(#\#):not(#\#):not(#\#){display:grid}.x3nfvp2:not(#\#):not(#\#):not(#\#){display:inline-flex}.xdt5ytf:not(#\#):not(#\#):not(#\#){flex-direction:column}.x2lah0s:not(#\#):not(#\#):not(#\#){flex-shrink:0}.x9ynric:not(#\#):not(#\#):not(#\#){font-family:var(--font-family-body)}.x9m5x89:not(#\#):not(#\#):not(#\#){font-family:var(--font-family-code)}.x1g81bgm:not(#\#):not(#\#):not(#\#){font-family:var(--font-family-heading)}.xjm74w1:not(#\#):not(#\#):not(#\#){font-size:var(--text-body-size)}.xp03k98:not(#\#):not(#\#):not(#\#){font-size:var(--text-code-size)}.xcg7oai:not(#\#):not(#\#):not(#\#){font-size:var(--text-heading-1-size)}.x1xvnhcw:not(#\#):not(#\#):not(#\#){font-size:var(--text-heading-2-size)}.xii13ha:not(#\#):not(#\#):not(#\#){font-size:var(--text-heading-3-size)}.x8tkxat:not(#\#):not(#\#):not(#\#){font-size:var(--text-heading-4-size)}.xsgqta0:not(#\#):not(#\#):not(#\#){font-size:var(--text-heading-5-size)}.xw5ohdf:not(#\#):not(#\#):not(#\#){font-size:var(--text-heading-6-size)}.x141an7d:not(#\#):not(#\#):not(#\#){font-size:var(--text-supporting-size)}.x1k4tb9n:not(#\#):not(#\#):not(#\#){font-style:italic}.xss6m8b:not(#\#):not(#\#):not(#\#){font-variant-numeric:tabular-nums}.x1pd3egz:not(#\#):not(#\#):not(#\#){font-weight:inherit}.x1lvx875:not(#\#):not(#\#):not(#\#){font-weight:var(--font-weight-bold)}.x1e4wzip:not(#\#):not(#\#):not(#\#){font-weight:var(--font-weight-medium)}.x2mo6ok:not(#\#):not(#\#):not(#\#){font-weight:var(--font-weight-semibold)}.x1v68xuy:not(#\#):not(#\#):not(#\#){font-weight:var(--text-heading-1-weight)}.x12yy4cs:not(#\#):not(#\#):not(#\#){font-weight:var(--text-heading-2-weight)}.x1jcxfy8:not(#\#):not(#\#):not(#\#){font-weight:var(--text-heading-3-weight)}.x2hcmsi:not(#\#):not(#\#):not(#\#){font-weight:var(--text-heading-4-weight)}.xno150v:not(#\#):not(#\#):not(#\#){font-weight:var(--text-heading-5-weight)}.x1pw4frv:not(#\#):not(#\#):not(#\#){font-weight:var(--text-heading-6-weight)}.x1mkdm3x:not(#\#):not(#\#):not(#\#){grid-template-columns:minmax(0,1fr)}.x72tfeb:not(#\#):not(#\#):not(#\#){inset-inline-end:var(--spacing-2)}.x1o0tod:not(#\#):not(#\#):not(#\#){inset-inline-start:0}.x13a6bvl:not(#\#):not(#\#):not(#\#){justify-content:flex-end}.x1qughib:not(#\#):not(#\#):not(#\#){justify-content:space-between}.xw6l6zx:not(#\#):not(#\#):not(#\#){line-height:var(--text-body-leading)}.x17iicif:not(#\#):not(#\#):not(#\#){line-height:var(--text-code-leading)}.xfmsba7:not(#\#):not(#\#):not(#\#){line-height:var(--text-heading-1-leading)}.x1cpk1wn:not(#\#):not(#\#):not(#\#){line-height:var(--text-heading-2-leading)}.xwjzt0u:not(#\#):not(#\#):not(#\#){line-height:var(--text-heading-3-leading)}.xqerer:not(#\#):not(#\#):not(#\#){line-height:var(--text-heading-4-leading)}.xo3gurs:not(#\#):not(#\#):not(#\#){line-height:var(--text-heading-5-leading)}.xeixjfn:not(#\#):not(#\#):not(#\#){line-height:var(--text-heading-6-leading)}.x1ltkj2j:not(#\#):not(#\#):not(#\#){line-height:var(--text-supporting-leading)}.x43c9pm:not(#\#):not(#\#):not(#\#){list-style-position:outside}.xrylv2j:not(#\#):not(#\#):not(#\#){list-style-type:circle}.x3yw8vx:not(#\#):not(#\#):not(#\#){list-style-type:decimal}.xtaz4m5:not(#\#):not(#\#):not(#\#){list-style-type:disc}.x1sle589:not(#\#):not(#\#):not(#\#){list-style-type:inherit}.x1rrqm6h:not(#\#):not(#\#):not(#\#){list-style-type:lower-alpha}.x19k9dhg:not(#\#):not(#\#):not(#\#){list-style-type:lower-roman}.x152237o:not(#\#):not(#\#):not(#\#){list-style-type:square}.x8yim9t:not(#\#):not(#\#):not(#\#){margin-inline-start:calc(var(--spacing-0))}.x19bwoy8:not(#\#):not(#\#):not(#\#){outline-color:var(--focus-outline-color)}.x1c097ug:not(#\#):not(#\#):not(#\#){outline-offset:calc(-1 * var(--focus-outline-width))}.x1eqjuhu:not(#\#):not(#\#):not(#\#){outline-offset:var(--focus-outline-offset)}.x9ssot5:not(#\#):not(#\#):not(#\#){outline-style:var(--focus-outline-style)}.xak0ai5:not(#\#):not(#\#):not(#\#){outline-width:var(--focus-outline-width)}.x1mzt3pk:not(#\#):not(#\#):not(#\#){overflow-wrap:break-word}.xp74n0j:not(#\#):not(#\#):not(#\#){padding-inline-end:calc(var(--spacing-2) + var(--spacing-6))}.xbj1ybn:not(#\#):not(#\#):not(#\#){padding-inline-start:calc(var(--spacing-0))}.x1rey3nv:not(#\#):not(#\#):not(#\#){padding-inline-start:var(--spacing-4)}.x31w388:not(#\#):not(#\#):not(#\#){padding-inline-start:var(--spacing-6)}.x67bb7w:not(#\#):not(#\#):not(#\#){pointer-events:auto}.x47corl:not(#\#):not(#\#):not(#\#){pointer-events:none}.x10l6tqk:not(#\#):not(#\#):not(#\#){position:absolute}.x1n2onr6:not(#\#):not(#\#):not(#\#){position:relative}.x1597r2g:not(#\#):not(#\#):not(#\#){scrollbar-width:thin}.x1yc453h:not(#\#):not(#\#):not(#\#){text-align:start}.xlyipyv:not(#\#):not(#\#):not(#\#){text-overflow:ellipsis}.x87ps6o:not(#\#):not(#\#):not(#\#){-webkit-user-select:none;user-select:none}.xxymvpz:not(#\#):not(#\#):not(#\#){vertical-align:middle}.xuxw1ft:not(#\#):not(#\#):not(#\#){white-space:nowrap}.x126k92a:not(#\#):not(#\#):not(#\#){white-space:pre-wrap}.x1yn0g08:not(#\#):not(#\#):not(#\#){word-break:break-all}.x1vjfegm:not(#\#):not(#\#):not(#\#){z-index:1}.x16khyan:is(:disabled,[aria-disabled=true]):not(#\#):not(#\#):not(#\#){cursor:default}.x2i8j16[data-richtext-task]:not(#\#):not(#\#):not(#\#){list-style-type:none}.x1pvqllw[data-richtext-task]:not(#\#):not(#\#):not(#\#){margin-inline-start:calc(-1 * var(--spacing-6))}.x1kuvm45[data-richtext-task]:not(#\#):not(#\#):not(#\#){padding-inline-start:calc(20px + var(--spacing-2))}.x81k3mc:has(ul):not(#\#):not(#\#):not(#\#){list-style-type:none}.xovwveo:has(ol):not(#\#):not(#\#):not(#\#){list-style-type:none}.x1qlsc9e:last-child:not(#\#):not(#\#):not(#\#){border-inline-end-width:0}@supports (-webkit-touch-callout:none){@media (pointer:coarse){.xf9zqsd.xf9zqsd.xf9zqsd:not(#\#):not(#\#):not(#\#){font-size:max(1rem,var(--text-body-size))}}}.xw8gpjh:not(#\#):not(#\#):not(#\#):not(#\#){border-bottom-color:var(--color-border)}.x1q0q8m5:not(#\#):not(#\#):not(#\#):not(#\#){border-bottom-style:solid}.xso031l:not(#\#):not(#\#):not(#\#):not(#\#){border-bottom-width:1px}.x1pc3f07:not(#\#):not(#\#):not(#\#):not(#\#){border-top-color:var(--color-border)}.x13fuv20:not(#\#):not(#\#):not(#\#):not(#\#){border-top-style:solid}.x178xt8z:not(#\#):not(#\#):not(#\#):not(#\#){border-top-width:1px}.x11xkdxz:not(#\#):not(#\#):not(#\#):not(#\#){border-top-width:var(--border-width)}.xt7dq6l:not(#\#):not(#\#):not(#\#):not(#\#){height:auto}.xgq9j65:not(#\#):not(#\#):not(#\#):not(#\#){left:var(--x-left)}.x199tud:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:calc(-1 * var(--spacing-1))}.x10j6jf0:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:calc(var(--spacing-0-5))}.x1hws3vx:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:calc(var(--spacing-2))}.x18pneqc:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:calc(var(--spacing-3))}.x1u2y747:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:calc(var(--spacing-4))}.x1qaki06:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:calc(var(--spacing-6))}.x1uy92hs:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(-1 * var(--spacing-1))}.x1wqhfsw:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(var(--spacing-0))}.x1ftnraw:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(var(--spacing-3))}.x1w2a574:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(var(--spacing-4))}.x13xmvwt:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(var(--spacing-6))}.xcsaf9d:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:var(--spacing-1)}.x193iq5w:not(#\#):not(#\#):not(#\#):not(#\#){max-width:100%}.x7ep2pv:not(#\#):not(#\#):not(#\#):not(#\#){max-width:680px}.x65nank:not(#\#):not(#\#):not(#\#):not(#\#){min-height:auto}.x82snj4:not(#\#):not(#\#):not(#\#):not(#\#){min-height:var(--x-minHeight)}.xeuugli:not(#\#):not(#\#):not(#\#):not(#\#){min-width:0}.xejm5pw:not(#\#):not(#\#):not(#\#):not(#\#){min-width:min(680px,100%)}.xw2csxc:not(#\#):not(#\#):not(#\#):not(#\#){overflow-x:auto}.x10wlt62:not(#\#):not(#\#):not(#\#):not(#\#){overflow-y:hidden}.x7p5m3t:not(#\#):not(#\#):not(#\#):not(#\#){overscroll-behavior-x:contain}.x13xdy6z:not(#\#):not(#\#):not(#\#):not(#\#){padding-bottom:calc(var(--spacing-1))}.xvmdzux:not(#\#):not(#\#):not(#\#):not(#\#){padding-bottom:var(--spacing-3)}.x1f3mx8c:not(#\#):not(#\#):not(#\#):not(#\#){padding-top:calc(var(--spacing-1))}.xekneqv:not(#\#):not(#\#):not(#\#):not(#\#){padding-top:calc(var(--spacing-3))}.x4xegtk:not(#\#):not(#\#):not(#\#):not(#\#){top:var(--spacing-0)}.xctzyg:not(#\#):not(#\#):not(#\#):not(#\#){top:var(--spacing-2)}.xjbys53:not(#\#):not(#\#):not(#\#):not(#\#){top:var(--x-top)}.xnalus7:not(#\#):not(#\#):not(#\#):not(#\#){width:0}.xh8yej3:not(#\#):not(#\#):not(#\#):not(#\#){width:100%}.xeq5yr9:not(#\#):not(#\#):not(#\#):not(#\#){width:fit-content}.x5lhr3w:not(#\#):not(#\#):not(#\#):not(#\#){width:var(--x-width)}.xe66n16:is([data-lexical-decorator-boundary]:first-child+*):not(#\#):not(#\#):not(#\#):not(#\#){margin-top:var(--spacing-0)}.x2w4pp4[data-language]:not([data-language=plaintext]):not(#\#):not(#\#):not(#\#):not(#\#){padding-top:calc(var(--spacing-2) + var(--size-element-sm) + var(--spacing-3))}.x1vugyqv:has(+[data-lexical-decorator-boundary]:last-child):not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:var(--spacing-0)}.xkuhcwz:has(ul):not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(var(--spacing-2))}.xsgnyjk:has(ol):not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(var(--spacing-2))}.x1uerj9w:has(ol):not(#\#):not(#\#):not(#\#):not(#\#){padding-top:var(--spacing-0)}.xmvvslv:has(ul):not(#\#):not(#\#):not(#\#):not(#\#){padding-top:var(--spacing-0)}.xnhvf09:first-child:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:var(--spacing-0)}.x1bta2m4:last-child:not(#\#):not(#\#):not(#\#):not(#\#){border-bottom-color:#0000}.xfo59cc:last-child:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:var(--spacing-0)}}@layer astryx-theme;.prompt-editor{position:relative}.prompt-editor [contenteditable]{max-height:calc(100vh - 340px);overflow-y:auto}.prompt-editor [contenteditable] *{max-width:none}.prompt-editor h1,.prompt-editor h2,.prompt-editor h3{font-size:var(--font-size-sm);font-weight:var(--font-weight-semibold);margin-block:var(--spacing-2) var(--spacing-1);line-height:1.4}.prompt-editor [role=toolbar] [role=group]{flex-wrap:wrap;overflow:visible}.prompt-editor [role=toolbar] button[role=combobox]>span{display:none}.prompt-editor [style*=--private]{background:var(--color-background-muted);border-radius:var(--radius-xs,3px);-webkit-box-decoration-break:clone;box-decoration-break:clone}.prompt-editor [contenteditable] [data-private]{background:var(--color-background-muted);padding-block:0;padding-inline:var(--spacing-8) var(--spacing-2);margin-block:0;position:relative}.prompt-editor [contenteditable] [data-private] [style*=--private]{background:0 0}.prompt-editor [contenteditable] ul[data-private],.prompt-editor [contenteditable] ol[data-private]{padding-inline-start:var(--spacing-12)}.prompt-editor [contenteditable] [data-private-start]{border-start-start-radius:var(--radius-md,6px);border-start-end-radius:var(--radius-md,6px);padding-block-start:var(--spacing-2)}.prompt-editor [contenteditable] [data-private-end]{border-end-end-radius:var(--radius-md,6px);border-end-start-radius:var(--radius-md,6px);padding-block-end:var(--spacing-2)}.prompt-editor [data-private-start]:before{content:"";inset-inline-start:var(--spacing-2);top:var(--spacing-2);background:var(--color-text-secondary);width:16px;height:16px;position:absolute;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M15 6a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M15.861 15.896a3 3 0 0 0 4.265 4.22m.578 -3.417a3.012 3.012 0 0 0 -1.507 -1.45'/%3E%3Cpath d='M8.7 10.7l1.336 -.688m2.624 -1.352l2.64 -1.36'/%3E%3Cpath d='M8.7 13.3l6.6 3.4'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E") 50%/contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M15 6a3 3 0 1 0 6 0a3 3 0 1 0 -6 0'/%3E%3Cpath d='M15.861 15.896a3 3 0 0 0 4.265 4.22m.578 -3.417a3.012 3.012 0 0 0 -1.507 -1.45'/%3E%3Cpath d='M8.7 10.7l1.336 -.688m2.624 -1.352l2.64 -1.36'/%3E%3Cpath d='M8.7 13.3l6.6 3.4'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E") 50%/contain no-repeat}.prompt-hint-anchor{pointer-events:none;position:absolute}.prompt-line-slot:not(:first-child){margin-top:var(--spacing-3)}.prompt-line-slot:has(.prompt-line-head){margin-bottom:var(--spacing-1)}.prompt-line-head{align-items:center;gap:var(--spacing-1);flex-wrap:wrap;display:flex}.prompt-line-head:after{content:"";min-width:var(--spacing-4);background:var(--color-border);flex:1;height:1px}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{t as e}from"./preload-helper-DpV6A1kQ.js";import{C as t,D as n,E as r,O as i,S as a,T as o,b as s,c,d as l,g as u,h as d,l as f,m as p,p as m,u as h,v as g,x as _}from"./schemas-D7cgkv3L.js";import{$n as v,Cn as y,En as b,Hn as x,Kn as S,Tn as C,U as ee,Vn as w,X as T,Xn as E,Zn as D,ar as O,bn as k,en as te,or as ne,pn as re,qt as ie,s as ae,sr as oe,tn as se,wn as ce,xn as A}from"./tool-schema-BwaPiLtT.js";import{c as j}from"./host-patterns-F-KZIzkF.js";import{$ as le,Ar as ue,At as de,Br as fe,Bt as pe,Dr as me,Et as he,F as ge,Fr as _e,Ft as ve,G as ye,Gt as be,Hr as M,Ht as xe,I as Se,Ir as Ce,It as we,Jt as Te,Kt as Ee,L as De,Lr as Oe,Lt as ke,N as Ae,Ot as je,P as Me,R as Ne,Tr as Pe,Ut as Fe,V as Ie,Vt as Le,Wn as Re,Wt as ze,Yn as Be,Yt as Ve,Z as He,_n as Ue,an as We,at as Ge,bn as Ke,cr as qe,dn as Je,dt as Ye,fn as Xe,in as Ze,it as Qe,j as $e,jr as et,kn as tt,mr as nt,nt as rt,pr as it,pt as at,qt as ot,rn as st,rt as ct,sr as lt,tn as ut,tt as dt,un as ft,vt as N,wn as pt,wt as mt,xn as ht,xr as gt,yn as _t,zn as vt,zr as yt,zt as bt}from"./shaped-data-DCfLI4gb.js";import{S as xt,_ as St,b as Ct,x as wt}from"./browser-connection-159CdeHX.js";import{A as Tt,C as Et,E as Dt,M as Ot,N as kt,O as At,P as jt,S as Mt,g as Nt,h as Pt,x as Ft}from"./schema-Cv4HAfBT.js";import{a as It}from"./live-ingress-OuSlQ6q7.js";import{n as Lt,t as Rt}from"./trace-schema--4IGmLeE.js";import{n as zt}from"./stub-REBz-ZC7.js";function Bt(e){return{type:`guardrail`,guardrail:e}}function Vt(e,t,n,r=`redact`,i){if(n.length!==0)return Bt({stage:e,trust:t,action:r,hits:n,...i?{provenance:i}:{}})}function Ht(e,t){return e.type===`guardrail`?{...e,guardrail:qe(e.guardrail,t)}:e}var P=65536;function F(e){let t=e.classStarts.length,n=new Uint16Array(P);for(let r=0;r<t;r++)n.fill(r,e.classStarts[r],e.classStarts[r+1]??P);let r=e.charsets.map(e=>{let n=new Uint8Array(t);for(let t of e)n[t]=1;return n}),i=e.nodes.length,a=new Int32Array(i),o=new Uint8Array(i),s=[];return e.nodes.forEach((e,t)=>{a[t]=e[0],o[t]=e[1],s.push(Int32Array.from(e.slice(2)))}),{classOf:n,has:r,pattern:a,final:o,edges:s,initials:e.initials,leads:e.leads,size:i}}var Ut,I,Wt;async function Gt(){if(Ut)return;let{FORWARD_AUTOMATON:t,REVERSED_AUTOMATON:n}=await e(async()=>{let{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}=await import(`./egress-automata-SiHQTP1i.js`);return{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}},[]);Ut={forward:t,reversed:n}}function Kt(){if(!Ut)throw Error(`A stream was opened before loadEgressAutomata() finished.`);return Ut}var L;function qt(e){let t=String.fromCharCode(e).toUpperCase();if(t.length!==1)return e;let n=t.charCodeAt(0);return e>=128&&n<128?e:n}function Jt(e){if(!L){L=new Map;for(let e=0;e<P;e++){let t=qt(e),n=L.get(t);n?n.push(e):L.set(t,[e])}}return L.get(qt(e))??[e]}function Yt(e){let t=[0];for(let n of e)t.at(-1)!==n&&t.push(n),n+1<P&&t.push(n+1);return t}var Xt=new Map;function Zt(e){let t=Xt.get(e);if(t)return t;let n=Array.from({length:e.length},(t,n)=>Jt(e.charCodeAt(n))),r=Yt([...new Set(n.flat())].sort((e,t)=>e-t)),i=e=>r.indexOf(e),a=F({classStarts:r,charsets:n.map(e=>e.map(i)),initials:[0],leads:[-1],nodes:[...n.map((e,t)=>[0,0,t+1,t]),[0,1]]});return Xt.set(e,a),a}function Qt(e){let t=JSON.stringify(e),n=Xt.get(t);if(n)return n;let r=[...new Set(e.flatMap(e=>Array.from(e,e=>e.charCodeAt(0))))];r.sort((e,t)=>e-t);let i=Yt(r),a=r.map(e=>[i.indexOf(e)]),o=[],s=F({classStarts:i,charsets:a,initials:e.map((e,t)=>{let n=o.length;for(let n=0;n<e.length;n++)o.push([t,0,o.length+1,r.indexOf(e.charCodeAt(n))]);return o.push([t,1]),n}),leads:e.map(()=>-1),nodes:o});return Xt.set(t,s),s}function $t(e,t){let n=e.has[0]?.length??0,r=Array.from({length:n},()=>[]);for(let i of t){let t=e.edges[e.initials[i]];for(let i=0;i<t.length;i+=2){let a=e.has[t[i+1]];for(let e=0;e<n;e++)a[e]&&r[e]?.push(t[i])}}return r.map(e=>Int32Array.from(e))}function en(e,t){e.text+=t,e.fresh+=t}function tn(e){return e.text.length-e.fresh.length}function R(e,t){let n=tn(e);return t>=n?e.fresh.charCodeAt(t-n):e.text.charCodeAt(t)}function nn(e,t,n=e.text.length){let r=tn(e);return t>=r?e.fresh.slice(t-r,n-r):e.text.slice(t,n)}function rn(e){let t={text:``,fresh:``,rawAt:e=>e,update(){t.text=e.text,t.fresh=e.fresh}};return t}function an(e,t){let n={text:``,fresh:``,rawAt:e.rawAt,update(){n.fresh=``,en(n,t(nn(e,n.text.length)))}};return n}var on=/\w/,sn=Math.max(...Le.map(e=>e.length));function cn(e){return e.length<=sn+1&&/^[A-Za-z]*$/.test(e)}function ln(e){let t=0,n,r=!1,i=[],a=(e,t,n)=>{en(o,e);for(let r=0;r<e.length;r++)i.push(t+Math.min(r,n-1))},o={text:``,fresh:``,rawAt:r=>e.rawAt(r<i.length?i[r]:t-(n?.length??0)),update(){o.fresh=``;for(let i=e.text.length;t<i;t++){let i=String.fromCharCode(R(e,t)),o=on.test(i);o&&!r&&(n=``),r=o,o?n===void 0?a(i,t,1):n+=i:(n!==void 0&&a(be(n),t-n.length,n.length),n=void 0,a(i,t,1))}n!==void 0&&!cn(n)&&(a(n,t-n.length,n.length),n=void 0)}};return o}function un(e){let t={text:``,fresh:``,from:[],rawAt:n=>n<t.from.length?t.from[n]:e(),update(){}};return t}function z(e,t,n){en(e,t);for(let r=0;r<t.length;r++)e.from.push(n)}var dn=55296,fn=56319,pn=/[A-Za-z]/,mn=56320,hn=57343;function gn(e){let t=0,n=``,r=[],i=``,a=[],o=!1,s=-1,c=un(()=>Math.min(t,r[0]??t,a[0]??t,s<0?t:s));function l(e,t){s>=0&&(pn.test(e)||z(c,`\\`,s),s=-1),e===`\\`?s=t:z(c,e,t)}function u(e,t){if(Ee(e)&&(o||i)){i+=e;for(let n=0;n<e.length;n++)a.push(t)}else{if(i){if(!pn.test(e))for(let e=0;e<i.length;e++)l(i[e],a[e]);i=``,a=[]}for(let n=0;n<e.length;n++)l(e[n],t);o=pn.test(e)&&e.length===1}}function d(){let e=0;for(;e<n.length;){let t=n.charCodeAt(e),i=t>=dn&&t<=fn;if(i&&e+1>=n.length)break;let a=n.charCodeAt(e+1),o=i&&a>=mn&&a<=hn?2:1;u(n.slice(e,e+o),r[e]),e+=o}n=n.slice(e),r=r.slice(e)}return c.update=()=>{c.fresh=``;let i=e.text.length;for(;t<i;){let a=R(e,t),o=a>=dn&&a<=fn;if(o&&t+1>=i)break;let s=R(e,t+1),c=o&&s>=mn&&s<=hn?2:1,l=ot(nn(e,t,t+c));n+=l;for(let e=0;e<l.length;e++)r.push(t);t+=c}d()},c}var _n=/[0-9A-Fa-f]/;function vn(e){let t=0,n=-1,r=un(()=>n<0?t:n);r.update=()=>{r.fresh=``;let a=e.text.length;for(;t<a;){let a=String.fromCharCode(R(e,t));if(n<0){a===`%`?n=t:(z(r,a,t),t++);continue}let o=(t-n)%3;if(o===0?a===`%`:_n.test(a))t++;else{i(t-o);for(let n=t-o;n<t;n++)z(r,String.fromCharCode(R(e,n)),n)}}};function i(t){t>n&&z(r,xe(nn(e,n,t)),n),n=-1}return r}var yn=new Set([`injection`,`base64`,`hex`,`spaced`,`pipe`]),bn=new Map(pe.map(({pattern:e,hit:t})=>[e,t])),xn=new Map(rt.flatMap(({pattern:e,hit:t})=>t?[[e,t]]:[]));function B(e){return{rule:it(e),severity:`high`,detector:e}}var Sn=B(`injection`),Cn=B(`marker_leak`),wn=B(`tool_leak`);function Tn({kind:e,group:t}){if(yn.has(e))return Sn;switch(e){case`sensitive`:case`card`:return t===void 0?void 0:B(t);case`boundary`:return Cn;case`image`:return B(`ungiven_images`);default:return B(`ungiven_links`)}}function En(e,t,n){if(e===`card`)return{hit:ct};if(e===`image`||e===`link`){let r=(e===`image`?Qe:Ge).indexOf(t),i=n[e][r];return`find`in i?{find:i.find}:{hit:i.test}}let r=bn.get(t)??xn.get(t);return r?{hit:r}:{}}function Dn(e,{given:t,allow:n,skipImages:r}){let i=e=>({...e,...t?{given:t}:{}}),a={image:Ye(i(n?.ungiven_images)),link:at(i(n?.ungiven_links),r??e.includes(`ungiven_images`))},o=[];return le.forEach((t,n)=>{let r=Tn(t);r?.detector&&e.includes(r.detector)&&o.push({...r,id:n,regex:Ve(t.pattern),...En(t.kind,t.pattern,a)})}),o}function On(){let e=[];return le.forEach(({kind:t,pattern:n},r)=>{if(t!==`injection`)return;let i=bn.get(n);e.push({...Sn,id:r,regex:Ve(n),...i?{hit:i}:{}})}),e}function kn(){return Te.map((e,t)=>({...Sn,id:t,regex:new RegExp(e.source,e.flags)}))}function An(e,t,n){let r=$t(t,n.map(e=>e.id)),i=new Int32Array(t.initials.length).fill(-1);n.forEach((e,t)=>{i[e.id]=t});let a=new Int32Array(t.size),o=new Int32Array(t.size),s=new Int32Array(t.size),c=new Int32Array(t.size),l=0,u=new Int32Array(t.size),d=new Int32Array(t.size),f=0,p=0,m=new Uint8Array(n.length),h=new Uint8Array(n.length),g=new Int32Array(n.length),_=new Int32Array(n.length),v=new Uint8Array(n.length),y=Uint8Array.from(n,e=>+!!e.find),b=new Int32Array(n.length).fill(-1),x=new Int32Array(n.length).fill(-1),S=Int32Array.from(n,e=>t.leads[e.id]??-1),C=[...new Set(S)].filter(e=>e>=0),ee=n.flatMap((e,t)=>S[t]<0?[]:[t]),w=new Int32Array(t.has.length).fill(-1);function T(){let{text:n,fresh:h}=e,g=tn(e),{classOf:_,has:v,edges:ee,final:T,pattern:E}=t;for(;p<n.length;p++){let e=_[p>=g?h.charCodeAt(p-g):n.charCodeAt(p)];f++;let t=0,D=(e,n)=>{if(d[e]===f){let t=u[e];n<c[t]&&(c[t]=n)}else d[e]=f,u[e]=t,s[t]=e,c[t]=n,t++,T[e]&&(m[i[E[e]]]=1)};for(let t=0;t<l;t++){let n=ee[a[t]],r=o[t];for(let t=0;t<n.length;t+=2)v[n[t+1]][e]&&D(n[t],r)}let O=r[e];for(let e=0;e<O.length;e++){let t=O[e],n=i[E[t]],r=S[n],a=r<0?-1:w[r],o=a<0?p:a;D(t,o),y[n]&&(x[n]=p,b[n]<0&&(b[n]=o))}for(let t of C)v[t][e]?w[t]<0&&(w[t]=p):w[t]=-1;[a,s]=[s,a],[o,c]=[c,o],l=t}}function E(){let n=e.text.length;_.fill(n),v.fill(0);let r=n;for(let e=0;e<l;e++){let n=a[e],s=i[t.pattern[n]],c=o[e];c<_[s]&&(_[s]=c),t.final[n]&&(v[s]=1),c<r&&(r=c)}for(let e of ee){let t=w[S[e]];t<0||(t<_[e]&&(_[e]=t),t<r&&(r=t))}return r}function D(t,r){let i=b[t],a=g[t];if(i<0||i>=r){g[t]=r;return}let{find:o,rule:s,severity:c,detector:l}=n[t],u=o?.(e.text,a,r);if(u===void 0)g[t]=r,b[t]=x[t]>=r?r:-1;else return g[t]=Math.max(a,u)+1,{rule:s,severity:c,start:e.rawAt(u),detector:l}}let O={text:``,lower:``},k=()=>(O.text!==e.text&&(O={text:e.text,lower:e.text.toLowerCase()}),O.lower);function te(t,r){if(!m[t]&&!h[t]){g[t]=r;return}m[t]=0;let i=e.text,{regex:a,hit:o,rule:s,severity:c,detector:l}=n[t];for(a.lastIndex=g[t];;){let n=a.exec(i);if(!n||n.index>=r){g[t]=r,h[t]=n||v[t]?1:0;return}let[u]=n;if(u&&(!o||o(u,i,n.index,k)))return g[t]=a.lastIndex,h[t]=1,{rule:s,severity:c,start:e.rawAt(n.index),detector:l};u||a.lastIndex++,g[t]=a.lastIndex}}function ne(){for(let e=0;e<n.length;e++){let t=_[e];if(t<=g[e])continue;let r=n[e].find?D(e,t):te(e,t);if(r)return r}}return{run(t){T();let n=E();for(let e=ne();e;e=ne())t.push(e);return e.rawAt(n)}}}var jn=new WeakMap;function Mn(e){let t=jn.get(e);return t||(t=F(e),jn.set(e,t)),t}function Nn(e={}){let t={text:``,fresh:``},n=rn(t),r=[n],i=(e,t,n)=>(r.includes(e)||r.push(e),An(e,t,n)),a=[],o=e.detect??[],s=Dn(o,e);if(s.length>0&&(I??=F(Kt().forward),a.push(i(n,I,s))),o.includes(`injection`)){I??=F(Kt().forward),Wt??=F(Kt().reversed);let e=gn(t),r=On();a.push(i(n,Wt,kn()),i(ln(n),I,r),i(e,I,r),i(ln(e),I,r),i(an(n,ze),I,r),i(an(n,e=>Fe(e)??e),I,r),i(vn(t),I,r))}if(o.includes(`marker_leak`)&&e.note){let t=dt(e.note);a.push(i(n,Zt(e.note),[{...Cn,id:0,regex:t}]))}if(o.includes(`tool_leak`)&&e.tools){let t=ye(e.tools),r=t.map(({regex:e},t)=>({...wn,id:t,regex:e}));t.length>0&&a.push(i(n,Qt(t.map(({literal:e})=>e)),r))}for(let{detector:t,compiled:r,matchers:o}of e.own??[]){let e=o.map(({regex:e},n)=>({...B(t),id:n,regex:new RegExp(e.source,e.flags)}));a.push(i(n,Mn(r.automaton),e))}let c=0;return{push(e){t.text+=e,t.fresh=e;for(let e of r)e.update();let n=[],i=t.text.length;for(let e of a)i=Math.min(i,e.run(n));return c=i,n},holdFrom:()=>c}}function Pn(e,t,n={},r=[]){let i=Se(e,t).filter(e=>!(Ne(e)||r.includes(e))),a=De(e,t);if(i.length===0&&a.length===0)return;let o=[...i,...a.map(({id:e})=>e)],s=t.sources??{},c=[...i.map(e=>({detector:e,...s[e]})),...a.map(({id:e,matchers:t,compiled:n})=>({detector:e,matchers:t,compiled:n}))],l=c.some(({matchers:e,compiled:t})=>e?.length&&!t),u=Nn({detect:i.filter(e=>s[e]?.theorem!==!1),own:c.flatMap(({detector:e,compiled:t,matchers:n=[]})=>t?[{detector:e,compiled:t,matchers:n}]:[]),skipImages:t.ungiven_images[e]!==`ignore`,...n.allow?{allow:n.allow}:{},...n.givenUrls?{given:n.givenUrls}:{},...n.note?{note:n.note}:{},...n.ownTools?{tools:n.ownTools}:{}}),d=a.some(({find:e})=>e),f=e===`live_reply`?96:256,p=``,m=[];return{push(e){p+=e;for(let{start:t,detector:n}of u.push(e))n&&m.push({start:t,detector:n})},holdFrom(){if(l)return 0;let e=u.holdFrom();return d?Math.min(e,Math.max(0,p.length-f)):e},take(r,i,a=!1){let s=m.filter(({start:e})=>e<i);if(s.length===0&&!a&&!d)return{action:`allow`,text:p.slice(r,i),hits:[],taken:i-r};let c={from:r,to:i,settled:s.map(({detector:e})=>e)},l=ge(p,c,e,t,{detectors:o,scope:n});return m=m.filter(({start:e})=>e>=r+l.taken),l}}}function Fn(e){let{context:t}=e,n=e.detect,r=n?Pn(n.boundary,n.matrix,n.scope):void 0,i=e=>n?n.matrix[e][n.boundary]:`block`,a=i(`canary_leak`),o=i(`prompt_leak`),s=t.canaryGiven||a===`ignore`?void 0:t.canary,c=o===`ignore`?void 0:t.privateSystem,l=s!==void 0||c!==void 0,u=l?e.carry??``:``,d=[],f=new Set,p=``,m=0,h=``,g=u.slice(-N),_=u,v=0,y=u,b=0,x=0,S=s?he(s):void 0;S?.push(u);function C(e){let n=[];if(S?.push(e)&&n.push([a,lt]),c){let r=_.length;_+=e;let i=bt(_,r);_=_.slice(i),v+=i;let[a]=He(_,c,t.canary);a&&n.push([o,a])}for(let[e,t]of n)e!==`flag`||f.has(t.rule)||(f.add(t.rule),d.push(t));return n.filter(([e])=>e!==`flag`).map(([,e])=>e)}function ee(e){let t=l?C(e??``):[];return e&&r?.push(e),t.length===0?null:{hits:t,...n?{boundary:n.boundary}:{}}}function w(){let e=s&&a!==`flag`?E(s):h.length,n=c&&o!==`flag`?D(c,t.canary):h.length;return m+Math.min(e,n)}function T(e){if(d.length===0)return e;let t=[...d,...e.found?.hits??[]];return d=[],{...e,found:{action:e.found?.action??`flag`,hits:t}}}function E(e){let t=u.length+m,n=Math.max(t,x),r=Math.max(b,n-N),i=r+mt(y.slice(r-b),e);i<n&&n>t&&(y=g+h,b=t-g.length,i=b+mt(y,e)),x=Math.min(i,u.length+p.length-N);let a=Math.max(b,Math.max(t,x)-N);return y=y.slice(a-b),b=a,Math.max(0,i-t)}function D(e,t){let n=m===0?u:``,r=u.length+m-n.length,[i,a]=v>=r?[_,v]:[n+h,r];return Math.max(0,a+ke(i,e,t)-u.length-m)}function O(e){let t=ee(e);if(t)return{blocked:!0,...t};let i=e===void 0,a=i?p.length:Math.min(w(),r?.holdFrom()??p.length),o=Math.max(0,a-m);if(!(n&&r))return T({blocked:!1,emit:k(o)});let s=r.take(m,m+o,i);return s.action===`block`||s.action===`redact`&&!n.rewrite?{blocked:!0,hits:s.hits,boundary:n.boundary}:(k(s.taken),T({blocked:!1,emit:s.text??``,...s.action===`allow`?{}:{found:{action:s.action,hits:s.hits}}}))}function k(e){let t=h.slice(0,e);return h=h.slice(e),m+=t.length,l&&(g=(g+t).slice(-N)),t}return{process(e){return e?(p+=e,h+=e,l&&(y+=e),O(e)):{blocked:!1,emit:``}},flush:()=>O(),accumulated:()=>p,unreleased:()=>h,drainUnreleased:()=>k(h.length),carryOut:()=>l?de(u+p,s,c):``}}function V(e,t,n){return Me(t,e.detect,n)}async function In(e,t,n,r){return V(e,[n],t)?(await Gt(),Ln(e,t,n,r)):null}function Ln(e,t,n,r){return V(e,[n],t)?Fn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:n===`reply`,scope:Ie(e,t)},...r?{carry:r}:{}}):null}async function Rn(e,t,n,r){return V(e,[n],r??t)?(await Gt(),Fn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:!1,scope:r??Ie(e,t)}})):null}var zn=class{open;gate;constructor(e){this.open=e}async read(e){if(this.gate===void 0&&(this.gate=await this.open()),this.gate===`stopped`)return``;if(!this.gate)return e;let t=this.gate.process(e);return t.blocked?(this.gate=`stopped`,``):t.emit}end(){if(!this.gate||this.gate===`stopped`)return``;let e=this.gate.flush();return e.blocked?``:e.emit}},Bn=[`user`,`slots`,`repair`,`attachment`,`voice`,`history`,`system`];function Vn(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t.read(n)]))}var Hn={client:`untrusted`,server:`assembled`};function Un(e){return typeof e==`string`?e:JSON.stringify(e)}function Wn(e,t){let n=[],r=!1;if(!e)return{context:e,events:n,blocked:r};let i={};for(let a of Ze){let o=e[a];if(o===void 0)continue;let s=t();i[a]=s.read(Un(o));let c=s.found(),l=Ae(`context`,c);l&&n.push({...l,trust:Hn[a]}),r||=c.action===`block`}return{context:i,events:n,blocked:r}}var Gn=/^[A-Za-z0-9._-]+$/;function Kn(e){let t=e?.trim();return t&&Gn.test(t)?t:void 0}function qn(e,t){if(!e)return e;let n=e.guidance?t.read(e.guidance):void 0;return{previousOutput:t.read(e.previousOutput),rejection:t.read(e.rejection),...n?{guidance:n}:{}}}function Jn(e,t){return e.map(e=>{let n=e.content===void 0?void 0:t.read(e.content),r=e.parts?.map(e=>e.type===`text`?{...e,text:t.read(e.text)}:e);return{role:e.role,...n===void 0?{}:{content:n},...r?{parts:r}:{},...e.tool_calls?{tool_calls:e.tool_calls}:{},...e.tool_call_id?{tool_call_id:e.tool_call_id}:{},...e.name?{name:e.name}:{},...e.metadata?{metadata:e.metadata}:{},...e.reasoning?{reasoning:e.reasoning}:{}}})}function Yn(e,t){let n=t?`: ${t}`:``;return new j(`input`,`guardrails.detect blocked the request at ${e}${n}`,{copy:{key:`detect.blocked`}})}function Xn(e,t){let{detect:n}=b(t.guardrails),r=Pe(Bn,e=>$e(e,n)),i=e.input??{},a=i.text===void 0?void 0:r.user.read(i.text),o=e.system===void 0?void 0:kt(e.system,`TurnRequest.system`,e=>r.system.read(e)),s=Vn(i.slots,r.slots),c=Wn(i.context,()=>$e(`context`,n)),l=qn(i.repair,r.repair),u=i.history?Jn(i.history,r.history):void 0,{attachments:d,voice:f}=i.attachments?.length||i.voice?.length?xt(t,i.attachments,i.voice,r):i,p=[],m;for(let e of Bn){let t=r[e].found(),n=Ae(e,t);n&&p.push(Bt(n)),t.action===`block`&&(m??=Yn(e,t.errorInternal))}return p.push(...c.events.map(Bt)),c.blocked&&(m??=Yn(`context`)),{request:{...e,system:o,projectId:Kn(e.projectId),input:{...i,text:a,slots:s,...c.context?{context:c.context}:{},repair:l,history:u,attachments:d,voice:f}},events:p,...m?{refusal:m}:{}}}function Zn(e,t){let{request:n,refusal:r}=Xn(e,t);if(r)throw r;return n}function Qn(e,t){return[...new Set([...t.filter(t=>A(e,t)),...e.filter(e=>A(t,e))])]}function $n(e,t){let n=e.attachments?t?Qn(e.attachments.accept,t.media.flatMap(e=>e.accept)):[...e.attachments.accept]:[],r=(t?.media??[]).flatMap(e=>e.maxPerInput===void 0?[]:[{accept:[...e.accept],max:e.maxPerInput}]);return{text:e.text!==!1,...n.length>0?{attachments:{accept:n}}:{},...e.maxFiles===void 0?{}:{maxFiles:e.maxFiles},...e.maxBytes===void 0?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===void 0?{}:{maxTurnBytes:e.maxTurnBytes},...e.limitsByMime===void 0?{}:{limitsByMime:{...e.limitsByMime}},...t?.maxInputs===void 0?{}:{maxInputs:t.maxInputs},...r.length>0?{perInput:r}:{}}}function er(e){let t=C(e[0]??``);return t===`application/pdf`?`PDF`:t.split(`/`)[0]??t}function tr(e,t){let n=wt(e),r=St({attachments:e.attachments?.accept,...n?{limits:{...n,maxFiles:2**53-1}}:{}},t.flat(),[]);if(n)for(let i of t){i.length>n.maxFiles&&r.push({code:`too_many_files`,params:{maxFiles:n.maxFiles}});for(let t of e.perInput??[])i.filter(e=>A(t.accept,e.mimeType)).length>t.max&&r.push({code:`too_many_of_kind`,params:{maxFiles:t.max,kind:er(t.accept)}})}let i=new Set;return r.filter(e=>{let t=JSON.stringify(e);return!i.has(t)&&(i.add(t),!0)})}var nr=`final_answer`;function rr(e){return e.structured!==null&&e.tools.wire.length>0}function ir(e,t,n){let{structured:r}=t;if(!r||!rr(t))return e;let i={type:`function`,name:nr,description:M(`structured.answer_tool`,{},n),parameters:r.jsonSchema};return{...e,structured:null,wireTools:[...e.wireTools??[],i]}}function ar(e,t){return e.get(t)||{name:t,missing:!0}}function or(e){let t=new Set;if(e.type===`host`||e.type===`decision`||e.type===`embedding`)return[];for(let n of Object.values(e.models))for(let e of n.builtInTools??[])t.add(e);return[...t]}function sr(e,t){return[...Ft(t),...or(t)].map(t=>ar(e,t))}function cr(e,t){if(Array.isArray(e)){for(let n of e)cr(n,t);return}if(typeof e!=`object`||!e)return;let{properties:n,...r}=e;if(typeof n==`object`&&n)for(let[e,r]of Object.entries(n))t.add(e),cr(r,t);for(let e of Object.values(r))cr(e,t)}function lr(e,t){let n=sr(e,t);if(n.length===0)return;let r=new Set;for(let e of n)`inputSchema`in e&&cr(e.inputSchema,r);return{names:n.map(({name:e})=>e),params:[...r]}}function ur(e){return!e||e.length===0?[]:e.slice(-4)}function dr(e,t){if(e.length===0)return``;let n=e.map(e=>`${e.role===`user`?`User`:`Assistant`}: ${e.content}`);return`${M(`repair.history_heading`,{count:e.length},t)}\n${n.join(`
|
|
2
|
+
`)}\n\n`}function fr(e){let{profile:t,repair:n,history:r}=e,i=n.guidance||M(`repair.default_guidance`,{},t.labels),a=dr(ur(r),t.labels),o=`${M(`repair.prompt_header`,{},t.labels)}\n\n`;return o+=`${M(`repair.prompt_intro`,{},t.labels)}\n\n`,o+=`${M(`repair.section_previous_output`,{},t.labels)}\n\`\`\`\n${n.previousOutput.trim()}\n\`\`\`\n\n`,o+=`${M(`repair.section_validator_rejection`,{},t.labels)}\n${n.rejection.trim()}\n\n`,i.trim()&&(o+=`${M(`repair.section_repair_guidance`,{},t.labels)}\n${i.trim()}\n\n`),a&&(o+=a),o+=`${M(`repair.section_instructions`,{},t.labels)}\n`,o+=M(`repair.prompt_instructions`,{},t.labels),o}function pr(e,t){let n=[];return t&&n.push(`structured`),e.type===`image`&&n.push(`image`),e.type===`speech`&&n.push(`speech`),n}function mr(e,t){let n=pr(e,t);if(!(n.length<=1))throw new j(`config`,`Profile ${e.id} declares multiple output wire formats (${n.join(`, `)}). Only one of a structured JSON schema (outputs.structured), image, or speech may be active.`)}function hr(e,t){if(e.type!==`speech`){if(t.speech)throw new j(`request`,`Profile ${e.id} (${e.type}) takes no speech settings — only a speech profile speaks`)}else if(t.system)throw new j(`config`,`Profile ${e.id} (speech) takes no system prompt — the input text is the transcript`)}function gr(e,t){if(e.type===`transcription`){if(t.system)throw new j(`config`,`Profile ${e.id} (transcription) takes no system prompt — the input is the clip`);if(!t.input?.voice?.length)throw new j(`request`,`Profile ${e.id} (transcription) requires a voice clip`)}}function _r(e,t){return e.type===`speech`?{...e.speech,...vr(t.speech)}:void 0}function vr(e){return Object.fromEntries(Object.entries(e??{}).filter(([,e])=>e!==void 0))}function yr(e){if(e.type!==`image`)return null;let t=e.image;return{type:`image`,mimeType:t.mimeType,aspectRatio:t.aspectRatio,resolution:t.resolution,quality:t.quality,background:t.background,n:t.n,seed:t.seed,outputCompression:t.outputCompression,includeText:t.includeText===!0}}function br(e){let t=k(e);if(!t)throw new j(`input`,`MIME '${e}' is not a supported media input type`);return t}function xr(e){return e.map(e=>{let t=br(e.mimeType),n=C(e.mimeType),r=n===`image/jpg`?`image/jpeg`:n;return Ct(e)?{type:t,mimeType:r,uri:e.uri}:{type:t,mimeType:r,data:e.data}})}function Sr(e,t){let{text:n,repair:r,history:i}=t.input??{};if(e.type===`speech`&&!n?.trim())throw new j(`request`,`Profile ${e.id} (speech) requires text input`);if(y(e)?.text===!1&&n)throw new j(`request`,`Profile ${e.id} does not accept text input`);let a=r?fr({profile:e,repair:r,history:i}):wr(e,t)??n;if(e.type===`speech`)return a?{type:`text`,text:a}:null;let o=[...Cr(t),...a?[we(a)]:[]];return o.length>0?{type:`text`,text:o.join(`
|
|
3
|
+
|
|
4
|
+
`)}:null}function Cr(e){let t=e.input?.context??{};return[...Ze].reverse().filter(e=>t[e]!==void 0).map(e=>ve(e,Un(t[e])))}function wr(e,t){if(t.continueFrom&&ie.includes(e.type)){if(t.input?.text)throw new j(`request`,`Profile ${e.id}: a continueFrom turn takes no input.text — its user message is the continue instruction`);return M(`continue.instruction`,{},e.labels)}}function Tr(e){return e.type===`image`&&e.image.references?xr(e.image.references):[]}function Er(e,t){let n=t.input?.attachments??[],r=t.input?.voice??[];return[...Tr(e),...xr(n),...xr(r)]}function Dr(e,t){let n=[],r=Sr(e,t);return r&&n.push(r),n.push(...Er(e,t)),n}function Or(e,t){let n=t.input?.slots;if(!n)return;let r=y(e)?.slots??{};for(let[t,i]of Object.entries(n)){let n=Object.hasOwn(r,t)?r[t]:void 0;if(!n)throw new j(`request`,`Profile ${e.id} has no slot '${t}'`);let a=Nt(n);if(!a.includes(i))throw new j(`request`,`Profile ${e.id}: slot '${t}' takes ${a.join(`, `)}, not '${i}'`)}}function kr(e,t){let n=t.input?.context;if(!n)return;let r=y(e)?.context;for(let[t,i]of Object.entries(n))if(i!==void 0){if(!Ze.includes(t)||!r?.from.some(e=>e===t))throw new j(`request`,`Profile ${e.id} takes no context from '${t}'`);if(Un(i).length>r.maxChars)throw new j(`request`,`Profile ${e.id}: context from '${t}' is over inputs.context.maxChars (${String(r.maxChars)})`)}}var Ar=/\{([A-Za-z_][\w-]*)\}/g;function jr(e,t,n,r){let i=y(e)?.slots;return i?t.replace(Ar,(t,a)=>{if(!Object.hasOwn(i,a))return t;let o=n&&Object.hasOwn(n,a)?n[a]:void 0;if(o===void 0)throw new j(`request`,`Profile ${e.id}: ${r} uses slot '${a}', and the request chose no value for it`);return o}):t}function Mr(e,t,n){if(e.type===`speech`||e.type===`transcription`)return[];let r=e.identity.system;if(!r)return[];let i=Tt(e.id,e.identity.conditions,n,t);return At(r,i,n=>jr(e,n,t,`identity.system`))}function Nr(e,t){let n=Mr(e,t.input?.slots,t);return{pieces:Ot([...n.map(({pieces:e})=>e),t.system===void 0?[]:jt(t.system)]),lines:n.map(({line:e})=>e)}}function Pr(e){return e.type!==`host`&&e.type!==`decision`&&e.type!==`embedding`}function Fr(e,t){if(Pr(e))return e;throw e.type===`host`?new j(`request`,`Profile ${e.id}: type 'host' never runs a model — ${t} is not supported; execute tools with invokeTool`):e.type===`embedding`?new j(`request`,`Profile ${e.id}: type 'embedding' runs through runEmbedding — ${t} is not supported`):new j(`request`,`Profile ${e.id}: type 'decision' runs through runDecision — ${t} is not supported`)}function Ir(e,t){if(t){if(!e.allowModelSelect)throw new j(`request`,`Profile ${e.id} does not allow model selection`);if(!e.models[t])throw new j(`request`,`Unknown model '${t}' for ${e.id}`);return t}return e.defaultModel}function Lr(e,t,n,r){let i=t.efforts;if(!i||Object.keys(i).length===0){if(r)throw new j(`request`,`Profile ${e.id} model '${n}' has no selectable efforts`);return}let a=Object.keys(i);if(r){if(!t.allowEffortSelect)throw new j(`request`,`Profile ${e.id} model '${n}' does not allow effort selection`);let a=i[r];if(!a)throw new j(`request`,`Unknown effort '${r}' for ${e.id} model '${n}'`);return a}return i[t.defaultEffort??a[0]]}function Rr(e){if(e.summaries===!0)return`auto`;if(e.summaries===!1)return`none`}function zr(e,t){if(e.type===`live`)return null;let n=e.outputs?.structured;if(!n)return null;if(typeof n==`string`)return n;let r=t?.[n.by];if(r){let e=n.map[r];if(e)return e}return n.fallback}function Br(e){return e.type===`live`||e.outputs?.streaming?.mode!==`buffered`}function Vr(e,t){return e.type===`live`?`live`:`turn`}function Hr(e,t){if(!t.continueFrom)return;if(e.type===`live`)throw new j(`request`,`Profile ${e.id}: type 'live' uses live.sessionResumption, not turnBehaviour.resumption/continueFrom`);let n=se(e)?.maxContinues;if(n===void 0)return;let r=t.continuation;if(r===void 0)throw new j(`request`,`Profile ${e.id}: continueFrom requires TurnRequest.continuation when turnBehaviour.resumption.maxContinues is set`);if(r<1)throw new j(`request`,`Profile ${e.id}: continuation must be >= 1`);if(r>n)throw new j(`request`,`Profile ${e.id}: continuation ${r} exceeds turnBehaviour.resumption.maxContinues (${n})`)}function Ur(e,t){return V(b(t),[`live_reply`])?{...e,transcription:{...e?.transcription,output:!0}}:e}function Wr(e){let{detect:t}=b(e.guardrails);return e.type!==`speech`&&e.type!==`transcription`&&Be(t,`canary_leak`)?je():``}function Gr(e,t,n,r){if(!r)return;let i={};for(let[a,o]of Object.entries(r)){if(!n.builtInTools?.includes(a))throw new j(`request`,`Profile ${e.id}: builtInArgs names '${a}', which model '${t}' does not list in builtInTools`);i[a]=o}return i}function Kr(e,t,n){let r=Fr(e.profiles.get(t.profile),`resolveTurn`);Or(r,t),kr(r,t);let i=Zn(t,r),a=i.input??{};Hr(r,i);let o=n??Ir(r,i.model),s=ce(r,o),c=Dt(e.tools,r,i,o),l=c.builtins,u=zr(r,a.slots);if(mr(r,u),u&&c.wire.some(e=>e.name===`final_answer`))throw new j(`config`,`Profile ${r.id}: a structured turn answers through '${nr}', so no tool of its own may take that name`);hr(r,i),gr(r,i);let d=Gr(r,o,s,i.builtInArgs),f=Vr(r,s),p=e.providers.get(s.provider),m=p&&re(p,s,r.type),h=Nr(r,i);return{profile:r,generation:{model:o,apiId:s.apiId,transport:f,...m?{operationName:m}:{},stream:Br(r),thinking:Lr(r,s,o,i.effort),summaries:Rr(s),maxOutputTokens:s.maxOutputTokens,temperature:s.temperature,builtins:l,builtInArgs:d,sessionId:i.sessionId,tools:c,sessionPermissions:i.sessionPermissions,execution:i.execution,pageExecution:i.pageExecution,history:a.history,maxSteps:r.maxSteps??20,structured:u?{id:u,jsonSchema:e.schemas.get(u).jsonSchema}:null,image:yr(r),speech:_r(r,i),live:r.type===`live`?Ur(r.live,r.guardrails):void 0,input:Dr(r,i),canary:Wr(r),resolvedSystem:h.pieces,systemLines:h.lines,host:i.host}}}function qr(e){return e.type===`image`?e.image:null}function Jr(e,t){let n=Fr(t,`projectProfile`),{identity:r}=n,i=y(n)??null,a=n.type===`live`?null:n.outputs??null;return{id:n.id,type:n.type,handle:r.handle,models:n.models,defaultModel:n.defaultModel,allowModelSelect:n.allowModelSelect,maxSteps:n.maxSteps,tools:sr(e,n),inputs:i,outputs:a,image:qr(n),speech:n.type===`speech`?n.speech:null,live:n.type===`live`?n.live:null}}function Yr(e,t){return Jr(e.tools,e.profiles.get(t))}var Xr=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/wav`,`audio/mpeg`];function Zr(e){return e.join(`,`)}function Qr(e){let t=e?.attachments?.accept,n=e?.voice?.accept;return{text:e?.text!==!1,attachments:t?.length?{accept:t,acceptAttr:Zr(t)}:null,voice:n?.length?{accept:n}:null,maxFiles:e?.maxFiles,maxBytes:e?.maxBytes,maxTurnBytes:e?.maxTurnBytes,limitsByMime:e?.limitsByMime,slots:Pt(e?.slots),context:e?.context}}function $r(e){return{text:e.text,attachments:e.attachments?{accept:e.attachments.accept}:void 0,voice:e.voice?{accept:e.voice.accept}:void 0,maxFiles:e.maxFiles,maxBytes:e.maxBytes,maxTurnBytes:e.maxTurnBytes,limitsByMime:e.limitsByMime,slots:e.slots,context:e.context}}function ei(e,t){let n=e=>(e??[]).map(({name:e,mimeType:t,sizeBytes:n})=>({name:e,mimeType:t,sizeBytes:n})),r=St({attachments:e.attachments?.accept,voice:e.voice?.accept,limits:wt($r(e))},n(t.attachments),n(t.voice));return{ok:r.length===0,issues:r}}function ti(e){let t=globalThis.MediaRecorder;if(t===void 0)return;let n=e=>t.isTypeSupported(e),r=e=>e.find(n);return e?.length?r(Xr.filter(t=>A(e,t)))??e.find(n):r(Xr)}var ni=_({protocol:r(),provider:r(),apiId:r(),options:t(r(),u()).optional(),keySlot:r().optional(),fallbackKeySlot:r().optional(),efforts:t(r(),c(ht)).optional(),defaultEffort:r().optional(),allowEffortSelect:m().optional(),summaries:m().optional(),maxOutputTokens:s().optional(),temperature:s().optional(),builtInTools:l(r()).optional(),compaction:_({maxTokens:s(),compactAt:s(),previousExchanges:s(),profile:r().optional(),timing:c(st),meter:c(ut).optional()}).optional(),limits:_({operationTimeoutMs:s().optional(),connectTimeoutMs:s().optional(),liveStepTimeoutMs:s().optional(),maxWireRecordBytes:s().optional(),maxWireResponseBytes:s().optional(),maxEventBytes:s().optional(),maxStepBytes:s().optional(),maxStepEvents:s().optional(),maxPendingToolCalls:s().optional()}).optional()}),ri=_({structured:n([r(),_({by:r(),map:t(r(),r()),fallback:r()}),f()]).optional(),streaming:_({mode:c(Ke).optional(),streamThoughts:m().optional()}).optional()}),ii=_(Pe(gt,()=>c(Re))),ai=_(Pe(vt,()=>ii)),oi=_({id:r(),label:r(),actions:ii,names:l(r()),find:m()}),si=_({hosts:l(r()),fromTools:m()}),ci=_({quota:_({perDay:s()}).optional(),detect:ai,patterns:a(c(vt),_({theorem:m(),names:l(r())})).optional(),host:l(oi).optional(),allow:_({ungiven_images:si,ungiven_links:si}),blockedReply:_({onBlock:c(nt),maxRetries:s()})}),li=n([m(),_({theorem:m(),host:m()})]),ui=_({record:m(),writeTo:n([g(!1),r()]).optional(),sampleRate:s(),include:_({upstreamLog:m(),outboundWire:m(),evidenceRaw:m(),usage:m(),guardrailDecisions:m(),guardrailMatchPreview:m()}),scrub:_({sensitive:li,injection:li,canary:li}),resource:Rt,retainForDays:s(),rotateAfterMiB:s(),hasOnWriteError:m()}),H=_({text:m(),attachments:_({accept:l(r()),acceptAttr:r()}).nullable(),voice:_({accept:l(r())}).nullable(),maxFiles:s().optional(),maxBytes:s().optional(),maxTurnBytes:s().optional(),limitsByMime:t(r(),s()).optional(),slots:t(r(),_({label:r().optional(),choices:l(_({value:r(),description:r().optional()}))})).optional(),context:_({from:l(c(Ze)),maxChars:s()}).optional()}),di=_({allowContinue:l(c(We)).optional(),autoContinue:l(c(We)).optional(),maxContinues:s().optional()}),fi=_({resumption:di.optional()}),pi=_({allow:l(r()),page:l(r()),t2Loader:r().optional(),parallel:m().optional()}),U={providerContinuation:_({history:c([`host`,`stateless`,`provider`]).optional()}).optional(),id:r(),models:t(r(),ni),defaultModel:r(),allowModelSelect:m().optional(),maxSteps:s().optional(),labels:a(c(yt),r()),guardrails:ci.optional(),observability:ui.optional()},mi=n([r(),o({private:r().min(1)})]),hi=n([r(),l(n([r(),l(mi).readonly()])).min(1).readonly()]),gi=_({handle:r(),conditions:t(r(),l(r()).readonly()).readonly().optional(),system:hi.optional()}),W=d(`type`,[_({...U,type:g(`text`),identity:gi,outputs:ri.optional(),inputs:H,tools:pi,turnBehaviour:_({resumption:di.optional(),allowSteering:m().optional(),atStepLimit:c(_t).optional()}).optional(),canStop:g(!0),allowSteering:m()}),_({...U,type:g(`image`),identity:gi,outputs:ri.optional(),image:_({aspectRatio:r().optional(),resolution:r().optional(),mimeType:r().optional(),quality:r().optional(),background:r().optional(),n:s().int().min(1).optional(),seed:s().int().optional(),outputCompression:s().int().min(0).max(100).optional(),references:l(n([_({mimeType:r(),data:r(),name:r().optional()}),_({mimeType:r(),uri:r(),name:r().optional()})])).optional(),includeText:m().optional()}),inputs:H,tools:pi,turnBehaviour:fi.optional(),canStop:g(!0)}),_({...U,type:g(`transcription`),identity:_({handle:r()}),maxSteps:h().optional(),outputs:ri.optional(),inputs:H,canStop:g(!0)}),_({...U,type:g(`speech`),identity:_({handle:r()}),outputs:ri.optional(),speech:_({voice:r().optional(),style:r().optional(),speed:s().optional(),format:c(Ue).optional()}),inputs:H,turnBehaviour:fi.optional(),canStop:g(!0)}),_({...U,type:g(`live`),identity:gi,inputs:H.pick({slots:!0,context:!0}).optional(),live:_({ingress:_({audio:m().optional(),video:m().optional(),text:m().optional()}).optional(),voice:r().optional(),vad:_({activityHandling:c(ft).optional(),startSensitivity:c(Xe).optional(),endSensitivity:c(Je).optional(),prefixPaddingMs:s().optional(),silenceDurationMs:s().optional()}).optional(),sessionResumption:m().optional(),contextCompression:_({triggerTokens:s().optional(),slidingWindow:_({targetTokens:s().optional()})}).optional(),transcription:_({input:m().optional(),output:m().optional()}).optional()}),tools:pi.pick({allow:!0,page:!0}),turnBehaviour:_({allowSteering:m().optional()}).optional()})]);function _i(e){let t=b(e),{sources:n,host:r,...i}=t.detect;return{quota:t.quota,detect:i,...n?{patterns:Object.fromEntries(Object.entries(n).map(([e,{theorem:t,matchers:n}])=>[e,{theorem:t,names:n.map(({name:e})=>e)}]))}:{},...r?{host:r.map(({id:e,label:t,actions:n,matchers:r,find:i})=>({id:e,label:t,actions:n,names:r.map(({name:e})=>e),find:!!i}))}:{},allow:{ungiven_images:vi(t.allow.ungiven_images),ungiven_links:vi(t.allow.ungiven_links)},blockedReply:t.blockedReply}}function vi(e){return{hosts:[...e.hosts??[]],fromTools:e.fromTools??!0}}function yi(e){return e===void 0||e===!1||typeof e==`string`?e:`custom`}function bi(e){if(!e)return;let t=It(e);return{record:t.record,writeTo:yi(t.writeTo),sampleRate:t.sampleRate,include:t.include,scrub:t.scrub,resource:t.resource,retainForDays:t.retainForDays,rotateAfterMiB:t.rotateAfterMiB,hasOnWriteError:!!t.onWriteError}}function xi(e){let{greeting:t,resumed:n,...r}=e??{};return r}function Si(e,t){let n=e.tools.filter(e=>`type`in e&&e.type===`function`&&e.answeredBy===`page`).map(e=>e.name);if(t){let e=Et(t),r=Mt(t);return{allow:[...Ft(t)],page:n,...e?.t2Loader?{t2Loader:e.t2Loader}:{},...r===void 0?{}:{parallel:r}}}return{allow:e.tools.filter(e=>!(`type`in e&&e.type===`builtin`)).map(e=>e.name),page:n}}function Ci({allow:e,page:t}){return{allow:e,page:t}}function wi(e,t){let n=Qr(e.inputs),r=t?.identity??{handle:e.handle},i=t?_i(t.guardrails):void 0,a=t?bi(t.observability):void 0,o=e.outputs??void 0,s={id:e.id,identity:r,models:e.models,defaultModel:e.defaultModel,allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps,providerContinuation:e.providerContinuation,outputs:o,guardrails:i,observability:a,labels:fe(t?.labels)};switch(e.type){case`text`:return W.parse({...s,type:`text`,inputs:n,tools:Si(e,t),turnBehaviour:t?.type===`text`?t.turnBehaviour:void 0,canStop:!0,allowSteering:!t||te(t)});case`image`:return W.parse({...s,type:`image`,image:e.image??{},inputs:n,tools:Si(e,t),turnBehaviour:t?.type===`image`?t.turnBehaviour:void 0,canStop:!0});case`speech`:return W.parse({...s,type:`speech`,speech:e.speech??{},inputs:n,turnBehaviour:t?.type===`speech`?t.turnBehaviour:void 0,canStop:!0});case`transcription`:return W.parse({...s,type:`transcription`,inputs:n,canStop:!0});case`live`:return W.parse({...s,type:`live`,live:xi(e.live),...e.inputs?{inputs:{slots:n.slots,context:n.context}}:{},tools:Ci(Si(e,t))});default:return e.type}}function Ti(e,t){let n=Fr(e,`interfaceFromProfile`);return wi(Jr(t,n),n)}function Ei(e){return p(t=>E.safeParse(e(t)).success)}var Di=[`running`,`gate`,`background`,`complete`,`error`,`cancel`],Oi=p(e=>{let t=E.safeParse({type:`tool`,tool:e});if(!t.success||t.data.type!==`tool`||!(`phase`in t.data.tool))return!1;let{phase:n}=t.data.tool;return Di.some(e=>e===n)}),ki=t(r(),i()),Ai=_({operationId:r().optional(),name:r(),callId:r(),arguments:ki,draft:r().optional(),reasoning:l(S).optional(),stepId:r().optional(),edited:_({from:ki,to:ki}).optional(),activity:r().optional(),activityPast:r().optional(),outputDraft:r().optional(),state:Oi.optional(),startedAt:s().optional(),endedAt:s().optional(),artifacts:l(i()),get steps(){return l(Ai).optional()}}),ji=_({kind:c(tt),native:r().optional()}),G={id:r()},K=d(`kind`,[_({...G,kind:g(`user-text`),text:r()}),_({...G,kind:c([`user-attachment`,`user-voice`]),name:r(),mimeType:r(),sizeBytes:s(),data:r().optional()}),_({...G,kind:g(`thought`),text:r()}),_({...G,kind:g(`text`),text:r()}),_({...G,kind:g(`tool`),tool:Ai}),_({...G,kind:g(`structured`),value:i(),draft:r().optional()}),_({...G,kind:g(`media`),mimeType:r(),data:r().optional(),url:r().optional(),previewUrl:r().optional()}),_({...G,kind:g(`grounding`),grounding:Ei(e=>({type:`grounding`,grounding:e}))}),_({...G,kind:g(`citation`),sources:Ei(e=>({type:`citation`,sources:e})),callId:r().optional()}),_({...G,kind:g(`evidence`),evidence:Ei(e=>({type:`evidence`,evidence:e}))}),_({...G,kind:g(`guardrail`),guardrail:oe}),_({...G,kind:g(`late-results`),text:r()}),_({...G,kind:g(`error`),message:r()}),_({...G,kind:g(`turn-done`),stop:ji.optional(),tokens:Ei(e=>({type:`tokens`,tokens:e})).optional(),interactionId:r().optional(),compaction:m().optional(),workedMs:s().optional(),endedAt:s().optional()})]),Mi=_({type:r()});function Ni(e,t){return Object.hasOwn(e,t)}function Pi(e,t){return e.map(e=>{let n=[...t,...e.path],r=`${n.map(String).join(`.`)||`(root)`} ${e.code}`;return e.code!==`invalid_union`||e.errors.length===0?r:`${r} [${e.errors.map(e=>Pi(e,n)).join(` | `)}]`}).join(`; `)}function Fi(e){return Pi(e.issues,[])}function Ii(e,t){return new j(`bad_response`,`${e} failed its wire check: ${Fi(t)}`)}function q(e,t,n){let r=e.safeParse(t);if(!r.success)throw Ii(n,r.error);return r.data}function Li(e){return{type:`malformed`,error:new j(`bad_response`,e,{copy:{key:`session.part_skipped`}})}}function Ri(e,t){let n=Mi.safeParse(t);if(!n.success)return Li(`a line without a kind failed its wire check: ${Fi(n.error)}`);let{type:r}=n.data;if(!Ni(e,r))return{type:`unsupported`,received:r,raw:t};let i=e[r].safeParse(t);return i.success?i.data:Li(`a '${r}' line failed its wire check: ${Fi(i.error)}`)}function zi(e){try{return{value:JSON.parse(e)}}catch(e){if(e instanceof SyntaxError)return;throw e}}function Bi(e,t){let n=zi(t);return n?Ri(e,n.value):Li(`a line is not JSON`)}function Vi(e){let t=zi(e);if(!t)throw new j(`bad_response`,`a line is not JSON`);return t.value}var Hi=_({name:r(),mimeType:r(),data:r()}),Ui=_({slots:t(r(),r()).optional(),context:i().optional(),text:r().optional(),attachments:l(Hi).optional(),voice:l(Hi).optional()}),Wi=_({gateKind:c(pt).optional(),sessionPermissions:l(r()).optional(),name:r().optional(),input:i().optional(),snapshot:v.optional(),promoted:l(r()).optional(),model:r().optional(),effort:r().optional()}),J=r().trim().min(1),Gi=_({path:r().optional(),conditions:t(r(),r()).optional()}),Ki=Gi;_({input:Ui,conversation:r().min(1).optional(),model:r().optional(),effort:r().optional(),stated:Gi.optional(),turnId:J.optional(),abandon:l(x).min(1).optional(),replay:Wi.pick({sessionPermissions:!0}).optional(),transcript:l(K).optional()});var qi=[`approve`,`deny`],Ji=n([o({unanswered:g(!0)}),o({output:i()}).refine(e=>`output`in e).transform(e=>({output:e.output}))]);_({gateId:r().min(1),operationId:r().min(1).max(256),decision:c(qi),input:i().optional(),secret:r().optional(),page:Ji.optional(),conversation:r().min(1).optional(),turnId:J.optional(),replay:Wi.optional()}),_({turnId:J,id:J,inject:l(D).min(1)}),_({turnId:J});var Yi=_({type:g(`conversation`),ref:r().min(1),posted:g(!0).optional()}),Xi={...w,conversation:Yi},Zi=_({transcript:l(K),paused:_({events:l(E),blocks:l(K)}).optional(),notify:_({retryMs:s().optional()}).optional()});_({conversation:r().min(1)}),o({});var Qi={changed:_({type:g(`changed`)})};_({conversation:r().min(1),at:s().int().min(-1)}),_({blocks:l(K)});var $i=_({conversation:r().min(1),view:Zi}),ea=class extends Error{kind;publicMessage;internalMessage;copy;constructor(e,t,n,r){super(n??t??e),this.name=`TheoremStreamError`,this.kind=e,t&&(this.publicMessage=t),n&&(this.internalMessage=n),r&&(this.copy=r)}};function ta(e){return e instanceof ea}function na(e){return e?.trim()||void 0}var ra=_({error:r().optional(),errorKind:ne.optional(),errorCopy:O.optional(),errorInternal:r().optional()}),ia=ra;function aa(e,t){let n=na(e.error),r=na(e.errorInternal);return new ea(e.errorKind??t,n,r&&r!==n?r:void 0,e.errorCopy)}function oa(e){return!ta(e)||e.copy===void 0?!1:(Array.isArray(e.copy)?e.copy:[e.copy]).some(e=>e.key===`session.conversation_unknown`)}function sa(e,t){let n=Bi(e,t);if(n.type===`error`)throw aa(ra.parse(n),`internal`);return n}function ca(e,t,n){let r=e.split(`
|
|
5
|
+
`),i=r.pop()??``;for(let e of r)e.trim()&&n(sa(t,e));return i}async function la(e,t,n,r){if(!e.body)throw new j(`bad_response`,`stream reply has no body`);let i=e.body.getReader(),a=new TextDecoder,o=``,s=()=>{i.cancel()};r?.addEventListener(`abort`,s,{once:!0});try{for(;;){_e(r);let{done:e,value:s}=await i.read();if(e)break;o=ca(o+a.decode(s,{stream:!0}),t,n)}let e=o.trim();e&&n(sa(t,e))}finally{r?.removeEventListener(`abort`,s)}}async function ua(e){let t=typeof e.headers==`function`?await e.headers():e.headers,n=new Headers(t);return n.set(`content-type`,`application/json`),n}async function da(e,t){let n=await e.text(),r;try{r=JSON.parse(n),t?.(r)}catch{return aa({errorInternal:`HTTP ${String(e.status)}`},et(e.status))}let i=ra.safeParse(r);return i.success?aa({...i.data,errorInternal:i.data.errorInternal??`HTTP ${String(e.status)}`},et(e.status)):new j(`bad_response`,`HTTP ${String(e.status)} error body failed its wire check`)}async function fa(e,t,n){let r=n.fetch??globalThis.fetch.bind(globalThis);try{return await r(e,{...t,headers:await ua(n),credentials:n.credentials??`same-origin`})}catch(e){throw ue(e)?e:new j(`network`,me(e),{cause:e})}}async function pa(e,t,n,r,i={}){await la(await ma(e,t,i),n,r,i.signal)}async function ma(e,t,n){let r=await fa(e,{method:`POST`,body:JSON.stringify(t),signal:n.signal},n);if(!r.ok)throw await da(r);return r}async function ha(e,t,n={}){await ma(e,t,n)}async function Y(e,t,n={}){let r=await fa(e,{...t.body===void 0?{method:`GET`}:{method:`POST`,body:JSON.stringify(t.body)},signal:t.signal},n);if(!r.ok)throw await da(r,t.failed);return Vi(await r.text())}async function ga(e,t,n={}){let{signal:r,...i}=n;return q(Zi,await Y(e,{body:t,signal:r},i),`the conversation`)}async function _a(e,t,n,r){let{signal:i,...a}=n;return q($i,await Y(e,{body:t,signal:i},a),r)}function va(e,t,n={}){return _a(e,t,n,`the rewound conversation`)}function ya(e,t,n={}){return _a(e,t,n,`the started conversation`)}function ba(e){let t=e.length;for(;t>0&&e[t-1]===`/`;)--t;return e.slice(0,t)}var xa=_({interface:W});function Sa(e={}){let t=ba(e.endpoint??`/api/theorem`);return{async describe(n){let r=await fa(t,{method:`GET`,signal:n},e);if(!r.ok)throw await da(r);return q(xa,Vi(await r.text()),`the profile description`).interface},turn:({replay:n,...r},i,a)=>pa(`${t}/turn`,r,Xi,i,{...e,signal:a}),invoke:({replay:n,...r},i,a)=>pa(`${t}/invoke`,r,Xi,i,{...e,signal:a}),conversation:(n,r)=>ga(`${t}/conversation`,n,{...e,signal:r}),notify:(n,r)=>pa(`${t}/notify`,{},Qi,e=>{e.type===`changed`&&n()},{...e,signal:r}),rewind:(n,r)=>va(`${t}/rewind`,n,{...e,signal:r}),pageResult:(n,r)=>ha(`${t}/page-result`,n,{...e,signal:r}),steer:n=>ha(`${t}/steer`,n,e),stop:n=>ha(`${t}/stop`,n,e)}}function Ca(e,t){if(typeof e==`string`)return e;let n=Array.isArray(e)?e:Object.keys(e);return n.length?Ca(n[0],t):t}function wa(e){return Object.entries(e).map(([e,t])=>({id:e,type:t.type,labels:t.type===`choice`?Object.keys(t.criteria):t.type===`score`?t.criteria.map((e,t)=>Ca(e,String(t))):[],...t.type===`box`&&t.image!==void 0?{image:t.image}:{}}))}function Ta(e,t,n){return{type:`decision`,identity:{handle:e.identity.handle},contract:e.decision.contract,...e.inputs.maxStateBytes===void 0?{}:{maxStateBytes:e.inputs.maxStateBytes},questions:wa(t),...n&&Object.keys(n).length>0?{images:n}:{},...e.observability?{observability:{record:It(e.observability).record}}:{}}}function Ea(e,t){let n=Object.keys(t??{}).find(t=>e&&Object.hasOwn(e,t));if(n!==void 0)throw new j(`request`,`the image ${n} is the host's, so the page's needs another name`);let r={...e,...t};return Object.keys(r).length>0?r:void 0}var X=s().min(0).max(1),Da=t(r(),X),Oa=d(`type`,[_({type:g(`choice`),choice:r(),confidence:X,probabilities:Da}),_({type:g(`noul`),noul:X}),_({type:g(`box`),box:_({top:X,bottom:X,left:X,right:X}),confidence:X}),_({type:g(`score`),score:s().nonnegative(),confidence:X,legend:t(r(),r().min(1)),probabilities:Da})]),ka=_({id:r(),type:c([`choice`,`noul`,`score`,`box`]),labels:l(r()),image:r().optional()}),Aa=_({result:_({model:r().min(1),questions:l(ka).optional(),answers:t(r(),Oa),usage:_({inputTokens:s().int().nonnegative(),outputTokens:s().int().nonnegative(),costUsd:s().nonnegative().optional()}).optional()}),traces:l(Lt).optional()}),ja=new WeakMap;function Ma(e,t){return t.length>0&&typeof e==`object`&&e&&ja.set(e,t),e}function Na(e){return typeof e==`object`&&!!e&&ja.get(e)||[]}var Pa=_({traces:l(Lt)});async function Fa(e,t,n,r,i){let a=[],o=e=>{let t=Pa.safeParse(e);t.success&&(a=t.data.traces)};try{return i(await Y(e,{body:t,signal:n,failed:o},r))}catch(e){throw Ma(e,a)}}function Ia(e,t,n,r={}){return Fa(e,t,n,r,La)}function La(e){return q(Aa,e,`the decision`)}var Ra=_({interface:_({type:g(`decision`),identity:_({handle:r()}),contract:r(),maxStateBytes:s().optional(),questions:l(ka),build:_({input:t(r(),i()).optional()}).optional(),images:t(r(),_({mimeType:c([`image/png`,`image/jpeg`]),data:r()})).optional(),observability:_({record:m()}).optional()})});function za(e={}){let t=(e.endpoint??`/api/decision`).replace(/\/$/,``);return{async describe(n){return q(Ra,await Y(t,{signal:n},e),`the decision description`).interface},decide:(n,r,i,a)=>Ia(`${t}/decide`,{state:n,...i?{assets:i}:{},...a===void 0?{}:{input:a}},r,e)}}function Ba(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function Q(e,t){if(!URL.canParse(t))return;let n=new URL(t);if(n.protocol===`http:`||n.protocol===`https:`)return{title:e.trim()||n.hostname.replace(/^www\./,``),uri:n.href,type:`web`}}function Va(e){let t=new Set;return e.filter(e=>!t.has(e.uri)&&(t.add(e.uri),!0))}function Ha(e){let t=[...e.matchAll(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g)].flatMap(e=>Q(e[1]??``,e[2]??``)??[]),n=[...e.matchAll(/https?:\/\/[^\s"'<>\]]+/g)].flatMap(e=>{let t=(e[0]??``).replace(/[),.;:]+$/,``);return Q(t,t)??[]});return Va([...t,...n])}function Ua(e){if(Array.isArray(e))return e;if(!Ba(e))return[];for(let t of[`items`,`results`,`search_results`,`models`,`datasets`]){let n=e[t];if(Array.isArray(n))return n}return[]}function Wa(e,t){return Va(e.flatMap(e=>Ba(e)?t(e)??[]:[]))}function Ga(e,t){let n=t===`dataset`?`https://huggingface.co/datasets/`:`https://huggingface.co/`;return Wa(Ua(e),e=>{let t=Z(e,`id`)??Z(e,`modelId`);return t?Q(t,`${n}${t}`):void 0})}function Ka(e){return Wa(Ua(e),e=>{let t=Z(e,`html_url`),n=Z(e,`full_name`)??Z(e,`name`);return t?Q(n??t,t):void 0})}function qa(e){let t=e,n;do n=t,t=t.replace(/<[^>]+>/g,``);while(t!==n);return t.replace(/\s+/g,` `).trim()}function Ja(e){if(typeof e!=`string`)return Ha(JSON.stringify(e));let t=[...e.matchAll(/<entry\b[\s\S]*?<\/entry>/g)];return t.length===0?Ha(e):Va(t.flatMap(e=>{let t=/<id>(https?:\/\/[^<]+)<\/id>/.exec(e[0]??``)?.[1],n=/<title>([\s\S]*?)<\/title>/.exec(e[0]??``)?.[1];return t?Q(qa(n??t),t)??[]:[]}))}function $(e){if(typeof e==`string`)return Ha(e);if(Array.isArray(e)||Ba(e)){let t=Wa(Ua(e),e=>{let t=Z(e,`html_url`)??Z(e,`url`)??Z(e,`source_url`)??Z(e,`contentUrl`),n=Z(e,`title`)??Z(e,`name`)??t;return t?Q(n??t,t):void 0});return t.length>0?t:Ha(JSON.stringify(e))}return[]}var Ya={search_models:e=>Ga(e,`model`),search_datasets:e=>Ga(e,`dataset`),search_github:Ka,list_arxiv:Ja,search_web:$,read_pages:$,read_model_card:$,read_dataset_card:$,read_readme:$,find_library:$,read_library_docs:$,ask_repo_docs:$};function Xa(e){return Ya[e]}function Za(e,t){let n=Xa(e);return n?{...t,sources:n}:t}function Qa(e,t,n={}){let r={name:t.name,description:t.description,category:t.category,access:t.access,paths:t.paths,loadTier:t.loadTier,permission:t.permission,...t.labels?{labels:t.labels}:{},...t.after?{after:!0}:{},...t.background?{background:t.background}:{}};if(t.type===`agent`){e.register({...r,type:`agent`,profile:t.profile,...t.maxCallsPerTurn===void 0?{}:{maxCallsPerTurn:t.maxCallsPerTurn}});return}let i={...r,input:ae(t.inputSchema),output:ae(t.outputSchema)};if(t.type===`http`){e.register(Za(t.name,{...i,type:`http`,endpoint:t.endpoint,method:t.method,headers:t.headers,mapping:t.mapping,auth:t.auth,maxResponseBytes:t.maxResponseBytes}));return}if(t.type===`mcp`){e.register(Za(t.name,{...i,type:`mcp`,serverUrl:t.serverUrl,mcpToolName:t.mcpToolName,headers:t.headers,auth:t.auth,maxResponseBytes:t.maxResponseBytes,session:t.session}));return}if(t.answeredBy===`page`){e.register({...i,type:`function`,answeredBy:`page`});return}let a=t.stubResponse||!Object.hasOwn(n,t.name)?void 0:n[t.name],o=t.stubResponse??zt(t.outputSchema);e.register({...i,type:`function`,handler:a?e=>{try{return Promise.resolve(a(e))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}}:()=>Promise.resolve(o)})}function $a(e,t,n){e.registerMany([...ee,...T]);for(let r of t)Qa(e,r,n)}function eo(e,t,n,r,i){if($a(e.tools,n,i),r&&t.type!==`live`)for(let{id:t,spec:n}of[r,...r.also??[]])e.schemas.register(t,n);return e.profiles.register(t),t}function to(e){if(e.type===`error`&&e.errorInternal!==void 0){let{errorInternal:t,...n}=e;return{...n,error:t}}if(e.type===`session`&&e.session.kind===`ended`&&e.errorInternal!==void 0){let{errorInternal:t,...n}=e;return{...n,session:{...e.session,message:t}}}if(e.type===`tool`&&e.tool.phase===`error`&&e.tool.failure.error!==void 0){let{failure:t}=e.tool;return{...e,tool:{...e.tool,failure:{...t,error:t.message}}}}return e}function no(e){if(e.type!==`error`&&e.type!==`session`&&e.type!==`tool`||e.errorInternal===void 0)return e;let{errorInternal:t,...n}=e;return n}function ro(e){if(e.type!==`compaction`||e.failure?.errorInternal===void 0)return e;let{errorInternal:t,...n}=e.failure;return{...e,failure:n}}function io(e){if(e.type!==`guardrail`||!(e.guardrail?.errorInternal||e.guardrail?.errorSummary))return e;let{errorInternal:t,errorSummary:n,...r}=e.guardrail;return{...e,guardrail:r}}function ao(e){if(e.type!==`done`||e.mediaRefused===void 0)return e;let{mediaRefused:t,...n}=e;return n}function oo(e){if(e.type!==`evidence`||!e.evidence?.raw)return e;let{raw:t,...n}=e.evidence;return{...e,evidence:n}}function so(e,t){let n=t?.reader===`builder`?to(e):ao(ro(io(no(e))));return t?.includeEvidenceRaw||(n=oo(n)),n=Ht(n,!1),n}function co(e,t){return e.map(e=>so(e,t))}function lo(e,t,n){let{error:r=``,errorKind:i,errorCopy:a}=so(Oe(Ce(e),t),n);return{error:r,errorKind:i,...a?{errorCopy:a}:{}}}var uo={reader:`builder`};function fo(e){return e.mode===`demo`?{reader:`visitor`}:uo}export{Xn as $,Fi as A,jr as B,ia as C,pa as D,ha as E,ti as F,rr as G,Dr as H,ei as I,$n as J,ir as K,Ir as L,Ri as M,K as N,Ki as O,Ti as P,Zn as Q,Yr as R,aa as S,oa as T,lr as U,kr as V,nr as W,Wn as X,Yn as Y,Jn as Z,Sa as _,co as a,Pn as at,va as b,za as c,Vt as ct,Na as d,zn as et,Ia as f,ea as g,Xi as h,so as i,V as it,Bi as j,q as k,Ea as l,Bt as lt,Ma as m,fo as n,In as nt,eo as o,Nn as ot,Fa as p,tr as q,lo as r,Ln as rt,$a as s,Gt as st,uo as t,Rn as tt,Ta as u,Ht as ut,ga as v,ta as w,ya as x,Y as y,Kr as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e,E as t,T as n,b as r,c as i,d as a,h as o,o as s,p as c,pt as l,s as ee,t as u,v as te}from"./schemas-D7cgkv3L.js";import{Cn as ne,Ct as re,Un as ie,Vn as d,Zn as ae,_t as f,cr as p,ir as m,lr as h,mt as g,or as oe,rr as se}from"./tool-schema-BwaPiLtT.js";import{c as _}from"./host-patterns-F-KZIzkF.js";import{Hr as v,Pn as ce}from"./shaped-data-DCfLI4gb.js";import{d as le,f as ue,i as y,l as de,n as b,s as fe,t as x}from"./schema-Cv4HAfBT.js";var pe=n({accepted:se,preparedInput:m});function S(e){return new _(`internal`,e)}function C(e,t,n){return new _(e,t,{copy:{key:`tool.execution_uncertain`},cause:n})}function w(e){return C(`conflict`,`The tool operation is ${e}, so it does not run again until the host settles it`)}async function T(e){let t=e=>Array.isArray(e)?e.map(t):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,n])=>[e,t(n)])):e,n=m.parse(t(j(e))),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,`0`)).join(``)}var E=d.tool.transform((e,t)=>e.tool.phase===`complete`||e.tool.phase===`error`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),D=n({finding:t(),data:m.optional(),parts:a(ie).optional(),modelText:t().optional(),provenance:h.optional(),suspicious:a(p).optional()}),O=d.tool.transform((e,t)=>e.tool.phase===`background`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),k=n({event:O,replay:n({modelResult:D})}),A=n({event:E,effects:i([`not_started`,`completed`,`unknown`]),replay:n({modelResult:D.optional(),outputRaw:m.optional(),failure:n({code:t(),kind:oe,message:t(),error:t().optional(),details:m.optional()}).optional(),awaiting:c().optional(),denied:te(!0).optional(),callNotStarted:c().optional(),aborted:e([c(),n({reason:t().optional()})]).optional(),pendingInject:a(n({id:t().optional(),messages:a(ae),released:r().int().nonnegative().optional()})).optional()})});function j(e){let t=new Set,n=e=>{if(!e||typeof e!=`object`)return e;if(t.has(e))throw S(`Tool operation value has a cycle`);let r=Object.getPrototypeOf(e);if(!Array.isArray(e)&&r!==Object.prototype&&r!==null)throw S(`Tool operation value holds an object that is not plain data`);if(Object.hasOwn(e,`__proto__`))throw S(`Tool operation value has an own __proto__ key`);t.add(e);try{if(Array.isArray(e))return e.map(n);let t=Object.entries(Object.getOwnPropertyDescriptors(e)),r=t.find(([,e])=>e.get||e.set);if(r)throw S(`Tool operation value has a getter or setter at '${r[0]}'`);return Object.fromEntries(t.filter(([,e])=>e.enumerable&&e.value!==void 0).map(([e,t])=>[e,n(t.value)]))}finally{t.delete(e)}};return m.parse(n(e))}var M=e([i([`always`,`ask`,`never`]),n({afterMs:r().finite().nonnegative()})]),N=`background`;function P(){return c().optional().describe(v(`tool.background_field`))}function F(e,t){if(e?.background!==`ask`||typeof t!=`object`||!t)return{input:t,asked:!1};let{[N]:n,...r}=t;return{input:r,asked:n===!0}}function I(e,t){let{background:n}=e;if(n!==void 0&&n!==`never`)return n===`always`?`claim`:n===`ask`?F(e,t).asked?`claim`:void 0:n}function L(e){let{tool:t,support:n,base:r,labels:i}=e;if(!t||!n)return;let a=I(t,e.input);if(a!==void 0)return{at:a,support:n,trace:n.openTrace(r.callId),reply:()=>{let e={finding:v(`tool.background_started`,{tool:t.name},i)},n=f(e),a=g(r,{phase:`background`,readBack:n});return k.parse(j({event:a,replay:{modelResult:e}}))}}}function R(e,t){if(e&&!t?.detach)throw new _(`config`,`A request with a background service needs a coordinator with detach`)}function z(e){let{name:t,background:n}=e;if(n!==void 0&&n!==`never`){if(e.answeredBy===`page`)throw new _(`config`,`Tool '${t}' sets background, which a tool answered by the page cannot`);if(!M.safeParse(n).success)throw new _(`config`,typeof n==`object`?`Tool '${t}' sets background.afterMs, which must be a time in milliseconds`:`Tool '${t}' sets background to ${JSON.stringify(n)}; it takes 'always', 'ask', 'never' or { afterMs }`)}}var B=/^[\x21-\x7E]{1,256}$/;function V(e=Date.now){let t=new Map,n=new Map,r=({tool:e,max:n})=>{if(n===void 0)return;let r=[...t.values()].filter(t=>t.tool===e).length;for(let[i,a]of t){if(r<=n)break;a.tool===e&&(t.delete(i),r--)}};return{get(n,i){let a=t.get(n);if(a&&(t.delete(n),!(i.idleMs!==void 0&&e()-a.usedAt>i.idleMs)))return t.set(n,{...a,usedAt:e(),tool:i.tool}),r(i),{id:a.id,protocolVersion:a.protocolVersion}},open(i,a,o){let s=n.get(i);if(s)return s;let c=o().then(n=>(t.delete(i),t.set(i,{...n,usedAt:e(),tool:a.tool}),r(a),n)).finally(()=>n.delete(i));return n.set(i,c),c},drop(e,n){t.get(e)?.id===n&&t.delete(e)},clear(){t.clear(),n.clear()}}}function me(e){return e!==null&&B.test(e)}async function he(e,t){let n=JSON.stringify([e,Object.entries(t).map(([e,t])=>[e.toLowerCase(),t]).sort(([e],[t])=>e<t?-1:+(e>t))]),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(n));return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var H=`after`;function ge(){return a(t()).optional().describe(v(`tool.after_field`))}function U(t,n,r,i){let a=n=>{if(n instanceof s){if(r in n.shape)throw new _(`config`,`Tool '${t}' sets ${r}, and its input already has a field of that name`);return n.safeExtend({[r]:i()})}if(n instanceof u){let e=n.options.map(a);return o(n.def.discriminator,e)}if(n instanceof ee)return e(n.options.map(a));throw new _(`config`,`Tool '${t}' sets ${r}, which needs an object input or a union of objects`)};return a(n)}function W(e,t){return U(e,t,H,ge)}function _e(e,t){if(!e.after||typeof t!=`object`||!t)return{input:t,names:[]};let{[H]:n,...r}=t;return{input:r,names:n??[]}}function ve(e,t,n){return n?e.flatMap(e=>{let r=n.filter(n=>n.tool===e&&n.callId!==t).map(e=>e.callId);return r.length>0?r:[e]}):[]}var G=class{value;constructor(e){this.value=e}};function ye(e){return new G(e)}function be(e){return(t,n)=>{let{page:r}=n;if(r&&`output`in r)return ye(r.output);let{labels:i}=n.profile;throw r?.timedOut?Error(v(`tool.page_timed_out`,{},i)):Error(v(`tool.page_no_answer`,{tool:e},i))}}var K=new WeakMap;function q(e,t){let n=K.get(e);n||(n=new WeakMap,K.set(e,n));let r=n.get(t);if(!r){let i=b(e,`input`);y(i,`input`);let a=b(t,`output`);y(a,`output`),r={inputSchema:i,outputSchema:a},n.set(t,r)}return r}function J(e){let{inputSchema:t,outputSchema:n}=q(e.input,e.output),r={activity:{input:t},activityPast:{input:t,output:n},activityFailed:{input:t},request:{input:t}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let n=e.labels?.[t],i=n?re(n,r[t]):void 0;if(i)throw new _(`config`,`Tool "${e.name}" ${t} label: ${i}`)}return{inputSchema:structuredClone(t),outputSchema:structuredClone(n)}}function xe(e,t){if(t&&(typeof t.service!=`string`||!t.service.trim()))throw new _(`config`,`Tool "${e}" signs in with slot "${t.slot}" but names no service`)}function Y(e,t,n=[]){if(t?.queryParam===void 0)return;let r=t.queryParam.trim()?t.type===`api_key`?t.headerName!==void 0||t.headerPrefix!==void 0?`is set with headerName or headerPrefix; the key goes in one place`:n.includes(t.queryParam)?`"${t.queryParam}" is also one of mapping.queryParams`:void 0:`is set on a '${t.type}' sign-in; only an API key goes in the URL`:`is blank`;if(r)throw new _(`config`,`Tool "${e}" auth.queryParam ${r}`)}function Se(e,t){if(t!==void 0&&!(Number.isInteger(t.requests)&&t.requests>0&&Number.isFinite(t.windowMs)&&t.windowMs>0))throw new _(`config`,`Tool "${e}" limit needs a whole number of requests above 0 and a window above 0 ms`)}function X(e,t){if(!(t===void 0||Number.isFinite(t)&&t>0))throw new _(`config`,`Tool "${e}" timeoutMs needs a finite number of ms above 0`)}function Z(e,t,n){if(!(n===void 0||Number.isInteger(n)&&n>0))throw new _(`config`,`Tool "${e}" ${t} needs a whole number above 0`)}function Ce(e){Z(e.name,`maxResponseBytes`,e.maxResponseBytes);let t=e.imageLimits;t&&(Z(e.name,`imageLimits.count`,t.count),Z(e.name,`imageLimits.bytes`,t.bytes),Z(e.name,`imageLimits.totalBytes`,t.totalBytes),X(e.name,t.timeoutMs))}function Q(e){if(e.type!==`builtin`&&z({name:e.name,...e.background===void 0?{}:{background:e.background},...e.answeredBy?{answeredBy:e.answeredBy}:{}}),e.type===`builtin`||e.type===`agent`)return;xe(e.name,e.auth),e.type===`http`?(e.endpoint?.trim()&&x(e.endpoint),Y(e.name,e.auth,e.mapping?.queryParams),Se(e.name,e.limit),X(e.name,e.timeoutMs)):Y(e.name,e.auth),(e.type===`http`||e.type===`mcp`)&&Ce(e),e.type===`mcp`&&(Z(e.name,`session.idleMs`,e.session?.idleMs),Z(e.name,`session.max`,e.session?.max));let[t]=ce(e);if(t)throw new _(`config`,`Tool "${e.name}" ${t.path} ${t.message}`)}function $(e){return x(e.endpoint),{...e,type:`http`,...J(e)}}function we(e){return{...e,type:`mcp`,...J(e)}}function Te(e){let t=e.answeredBy===`page`?be(e.name):e.handler;if(typeof t!=`function`)throw new _(`config`,`Tool '${e.name}' needs a handler, or answeredBy: 'page'`);return{...e,handler:t,type:`function`,...J(e)}}function Ee(e){if(e.type===`builtin`||e.background!==`ask`)return e;let t=e.input,n=U(e.name,t,`background`,P);return{...e,askInputSchema:q(n,e.output).inputSchema}}function De(e,t,n){return Q(e),Ee(Oe(e,t,n))}function Oe(e,t,n){if(e.type===`builtin`)return e;if(e.type===`agent`){let r=le(e,t,n),i=ne(r),a=fe({type:r.type,...i?{inputs:i}:{}},e),o=e.after?W(e.name,a):a,s=J({...e,input:o,output:de});return ue(e,o,s)}let r=e.after?{...e,input:W(e.name,e.input)}:e;return r.type===`http`?$(r):r.type===`mcp`?we(r):Te(r)}function ke(e=()=>void 0){let t=new Map,n=V(),r=e=>t.get(e),i=n=>{let i=De(n,e,r);return t.set(i.name,i),i};return{register:i,registerMany:e=>e.map(e=>i(e)),get:r,require(e){let t=r(e);if(!t)throw new _(`config`,`Tool '${e}' is not registered`);return t},has:e=>t.has(e),list:()=>[...t.values()],findProfile:e,reset:()=>{t.clear(),n.clear()},mcpSessions:n}}export{A as _,ve as a,he as c,F as d,w as f,T as g,pe as h,_e as i,R as l,j as m,ke as n,V as o,S as p,G as r,me as s,Q as t,L as u,k as v,C as y};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{A as e,D as t,E as n,O as r,T as i,b as a,c as o,d as s,f as c,x as l}from"./schemas-D7cgkv3L.js";import{Dt as u,Gn as d,Gt as f,Tt as ee,Un as te,qn as ne,wt as re}from"./tool-schema-BwaPiLtT.js";import{c as p}from"./host-patterns-F-KZIzkF.js";import{A as m}from"./shaped-data-DCfLI4gb.js";var h=`
|
|
2
|
+
|
|
3
|
+
`;function g(e){if(typeof e==`string`)return;if(typeof e!=`object`||!e||Array.isArray(e))return`must be a string or { private: string }`;let t=Object.keys(e);if(t.length!==1||t[0]!==`private`)return`must have exactly one key, private`;let n=e.private;if(typeof n!=`string`)return`must be a string`;if(n===``)return`must not be empty`}function _(e,t){if(typeof e!=`string`){if(!Array.isArray(e))return`${t} must be a string or an array of parts`;if(e.length===0)return`${t} must not be an empty array`;for(let[n,r]of e.entries()){let e=g(r);if(e)return`${t}[${n}]${typeof r==`object`&&r&&`private`in r?`.private`:``} ${e}`}}}function v(e,t){let n=_(e,t);if(n)throw new p(`config`,n)}function ie(e,t,n){return v(e,t),typeof e==`string`?n(e):e.map(e=>typeof e==`string`?n(e):{private:n(e.private)})}function ae(e){if(typeof e==`string`)return[{text:e,private:!0}];let t=e.some(e=>typeof e!=`string`);return e.map(e=>typeof e==`string`?{text:e,private:!t}:{text:e.private,private:!0})}function y(e){let t=[];for(let n of e)n.some(e=>e.text)&&(t.length>0&&t.push({text:h,private:!0}),t.push(...n));return t}function oe(e){return e.map(e=>e.text).join(``)}function se(e){let t=[],n=``;for(let r of e)r.private?n+=r.text:(n.trim()&&t.push(n),n=``);return n.trim()&&t.push(n),{text:oe(e),private:t}}function ce(e,t){return se(y([e,...t.map(e=>e?[{text:e,private:!0}]:[])]))}var le=/^[A-Za-z_][\w-]*$/,ue=/^\S+$/;function b(e){return typeof e==`string`?[[e]]:e.map(e=>typeof e==`string`?[e]:e)}function x(e){return typeof e==`string`?e:e.private}function S(e){return u(e[0]===void 0?``:x(e[0]))}function de(e,t){let n={};for(let[r,i]of Object.entries({...e,...t}))n[r]={type:`string`,enum:[...i]};return{type:`object`,properties:n}}function fe(e,t){for(let[n,r]of Object.entries(e??{})){if(!le.test(n))return`Condition "${n}" needs a plain name.`;if(n===`input`||n===`output`)return`Condition "${n}" is a reserved name.`;if(Object.hasOwn(t,n))return`"${n}" is both a condition and a slot.`;if(r.length===0)return`Condition "${n}" lists no values.`;let e=r.find(e=>!ue.test(e)||e===`null`);if(e!==void 0)return`Condition "${n}" can't take the value "${e}".`}}function C(e,t){if(e.length===0)return`It has no wording to send.`;let n=S(e);if(n.joined)return`A prompt line can't start with "+"; every line that fits is sent.`;if(n.when===`unreadable`)return`A line that opens with "when" needs a condition and a colon, like "when path is web: …".`;for(let e of n.when){if(e.path.includes(`.`))return`"${e.path}" isn't one condition or slot.`;if(e.expected===null)return`A condition always has a value, so "is null" never fits.`;let n=ee(e,t,`this profile’s conditions or slots`);if(n)return n}if(n.when.length>0&&!n.text&&e.length===1)return`It has no wording to send.`}function w(e,t,n){let r=fe(t,n);if(r)return r;let i=de(t,n);for(let[t,n]of b(e).entries()){let e=C(n,i);if(e)return`Line ${t+1}: ${e}`}}function T(e,t,n,r){let i=n.conditions??{};if(t===void 0){if(n.conditions)throw new p(`request`,`Profile ${e} declares no conditions`);return{...r}}if(Object.hasOwn(i,`path`))throw new p(`request`,`Profile ${e}: the turn's own path states path`);for(let n of Object.keys(i))if(!Object.hasOwn(t,n))throw new p(`request`,`Profile ${e} has no condition '${n}'`);let a={...r};for(let[r,o]of Object.entries(t)){let t=r===`path`?n.path:i[r];if(t===void 0)throw new p(`request`,`Profile ${e}: the turn left condition '${r}' unset`);if(!o.includes(t))throw new p(`request`,`Profile ${e}: '${t}' is no value of condition '${r}'`);a[r]=t}return a}function E(e,t){return e.when!==`unreadable`&&e.when.every(e=>re(e,t))}function D(e,t,n){let r=b(e),i=r.flat().some(e=>typeof e!=`string`),a=[];for(let[e,o]of r.entries()){let r=S(o);if(!E(r,t))continue;let s=[];for(let[e,t]of o.entries()){let a=n(e===0?r.text:x(t));a&&s.push({text:a,private:typeof t!=`string`||!i})}a.push({line:e+1,pieces:s})}return a}function O(e,t){if(typeof e!=`string`){if(!Array.isArray(e))throw new p(`config`,`${t} must be a string or an array of lines`);if(e.length===0)throw new p(`config`,`${t} must not be an empty array`);for(let[n,r]of e.entries())if(typeof r!=`string`){if(!Array.isArray(r))throw new p(`config`,`${t}[${n}] must be a string or a list of parts; put { private } inside the list`);v(r,`${t}[${n}]`)}}}function k(e,t){let n=e?.path;if(n)for(let e of t){let t=e.paths?.find(e=>e!==`*`&&!n.includes(e));if(t!==void 0)return`Tool ${e.name} lists path "${t}", which is not one of ${n.join(`, `)}.`}}function A(e,t){let n=e.get(t);return n!==void 0&&n.type!==`builtin`}function j(e,t){return!e||e.includes(`*`)?!0:t?e.includes(t):!1}function M(e,t){return t.filter(n=>{let r=e.get(n);return r?.type!==`builtin`||!(r.conflictsWith??[]).some(e=>t.includes(e))})}function N(e){return`tools`in e?e.tools.allow:[]}function P(e){return e.type===`text`||e.type===`image`?e.tools:void 0}function F(e){return`tools`in e?e.tools.parallel:void 0}function I(e,t,n){return N(t).filter(r=>{let i=e.get(r);return!i||i.type===`builtin`?!1:t.type===`host`||j(i.paths,n.path)})}function L(e,t,n,r){let i=t.models[r];return i?(i.builtInTools??[]).filter(t=>{let r=e.get(t);return r?.type===`builtin`&&j(r.paths,n.path)}):[]}function R(e,t,n){let r=e.get(t);if(r&&r.type!==`builtin`)return{type:`function`,name:r.name,description:r.description,parameters:n&&r.askInputSchema||r.inputSchema}}function z(e,t,n){let r=[];for(let i of t){let t=R(e,i,n);t&&r.push(t)}return r}function B(e,t,n){if(t.visible.includes(n))return;t.visible.push(n);let r=R(e,n,t.modelBackground);r&&!t.wire.some(e=>e.name===n)&&t.wire.push(r)}function V(e,t,n){if(t.builtins.includes(n))return;let r=e.get(n);if(r?.type!==`builtin`)return;let i=r.conflictsWith??[];t.builtins=t.builtins.filter(t=>{if(i.includes(t))return!1;let r=e.get(t);return!(r?.type===`builtin`&&r.conflictsWith?.includes(n))}),t.builtins.push(n)}function pe(e,t,n){return t.type===`live`||t.type===`host`?[...n]:n.filter(t=>e.get(t)?.loadTier===`T0`)}function me(e,t,n){return M(e,n.filter(n=>{let r=e.get(n);return r?.type===`builtin`&&(t.type===`live`||r.loadTier===`T0`)}))}function he(e,t){if(t.type!==`text`&&t.type!==`image`&&t.type!==`live`)return;let n=N(t).flatMap(t=>e.get(t)??[]),r=k(t.identity.conditions,n);if(r)throw new p(`config`,`Profile ${t.id}: ${r}`)}function ge(e,t){let n=P(t)?.t2Loader,r=n===void 0?void 0:e.get(n);if(r&&r.type!==`builtin`&&(r.background??`never`)!==`never`)throw new p(`config`,`Profile ${t.id}: tools.t2Loader '${r.name}' sets background, and a loader cannot detach`)}function H(e,t,n,r){he(e,t),ge(e,t);let i=I(e,t,n),a=t.type===`host`||t.type===`decision`||t.type===`embedding`||r===void 0?[]:L(e,t,n,r),o=[...i,...a],s=me(e,t,o),c=pe(e,t,o),l=c.filter(t=>A(e,t)),u=n.background!==void 0;return{builtins:s,gated:o,visible:c,executable:l,path:n.path,sessionPermissions:n.sessionPermissions,wire:z(e,c,u),...u?{modelBackground:u}:{}}}async function _e(e,t,n,r){let i=H(e,t,n,r);return await U(e,i,t,n),i}function ve(e){return{builtins:[...e.builtins],gated:[...e.gated],visible:[...e.visible],executable:[...e.executable],path:e.path,sessionPermissions:e.sessionPermissions?[...e.sessionPermissions]:void 0,wire:e.wire.map(e=>({...e,parameters:structuredClone(e.parameters)})),...e.modelBackground?{modelBackground:e.modelBackground}:{}}}async function U(e,t,n,r){let i=P(n)?.t1Policy;if(!i)return;let a;try{a=await i({profile:n,input:r.input,path:r.path,sessionPermissions:r.sessionPermissions,gated:t.gated,host:r.host})}catch(e){let t=e instanceof Error?e.message:String(e);throw new p(`config`,`Profile '${n.id}' tools.t1Policy rejected: ${t}`,{cause:e})}if(!Array.isArray(a))throw new p(`config`,`Profile '${n.id}' tools.t1Policy must return ToolId[]`);W(e,t,a)}function W(e,t,n=[]){for(let r of n){if(!t.gated.includes(r))continue;let n=e.get(r);n?.loadTier===`T2`&&(n.type===`builtin`?V(e,t,r):B(e,t,r))}t.executable=t.visible.filter(t=>A(e,t))}var ye=new Set([`__proto__`,`constructor`,`prototype`]);function be(e){if(!m(e))return;let{loaded:t}=e;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t}function xe(e,t,n,r){if(r.type===`live`||r.type===`host`)return{promoted:[]};let i=[];for(let a of n){if(typeof a!=`string`||ye.has(a))return{promoted:[],failure:{code:`invalid_output`,kind:`bad_response`,message:`tools.t2Loader loaded ids must be plain strings`}};let n=Se(e,a,r);if(`failure`in n)return{promoted:[],failure:n.failure};let{tool:o}=n;j(o.paths,t.path)&&t.gated.includes(a)&&i.push(a)}let a=[];for(let n of i)B(e,t,n),a.push(n);return t.executable=t.visible.filter(t=>A(e,t)),{promoted:a}}function G(e){return{failure:{code:`invalid_output`,kind:`bad_response`,message:e}}}function Se(e,t,n){if(!N(n).includes(t))return G(`tools.t2Loader attempted to promote tool '${t}' outside profile allow`);let r=e.get(t);return r?r.type===`builtin`?G(`tools.t2Loader attempted to promote builtin '${t}' — only custom tools may be promoted`):r.loadTier===`T2`?{tool:r}:G(`tools.t2Loader attempted to promote tool '${t}' with loadTier '${r.loadTier}' — only T2 tools may be promoted`):G(`tools.t2Loader attempted to promote unknown tool '${t}'`)}function K(e){return Array.isArray(e)?[...e]:e.choices.map(e=>e.value)}function Ce(e){return Array.isArray(e)?{choices:e.map(e=>({value:e}))}:{...e.label!==void 0&&e.label!==``?{label:e.label}:{},choices:e.choices.map(e=>({value:e.value,...e.description!==void 0&&e.description!==``?{description:e.description}:{}}))}}function q(e){if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Ce(t)]))}function we(e){return e?.slots?{...e,slots:q(e.slots)}:e}var Te=class extends Error{failure;constructor(e){super(e.message),this.failure=e}},Ee=new Set([`text`,`image`,`speech`]),De=n().regex(/\S/),J=i({mimeType:n(),data:c(),name:n().optional()}),Oe=i({mimeType:n(),uri:n(),name:n().optional()}),ke=i({voice:n().optional(),style:n().optional(),speed:a().positive().optional()});function Ae(e){return i(Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=K(t);return[e,o(n).optional()]})))}var je=new Set([`text`,`attachments`,`voice`,`slots`,`speech`]);function Me(e,t){if(!e.hostFields)return{sent:t};let n={...t},r={};for(let t of Object.keys(e.hostFields))n[t]!==void 0&&(r[t]=n[t]);let{text:i,attachments:a,voice:o,slots:s,speech:c}=t;return{sent:{text:i,...a?{attachments:a}:{},...o?{voice:o}:{},...s?{slots:s}:{},...c?{speech:c}:{}},hostInput:r}}function Ne(e,n){let{inputs:r}=e,a={text:De};r?.attachments&&(a.attachments=s(t([J,Oe])).optional()),r?.voice&&(a.voice=s(J).optional()),r?.slots&&(a.slots=Ae(r.slots).optional()),e.type===`speech`&&(a.speech=ke.optional());for(let e of n?.hostOnly??[]){if(!a[e])throw new p(`config`,`Tool '${n?.name}' keeps '${e}' for the host, which its profile does not take`);delete a[e]}for(let[e,t]of Object.entries(n?.fieldText??{})){let r=a[e];if(!r)throw new p(`config`,`Tool '${n?.name}' describes '${e}', which its profile does not take`);a[e]=r.describe(t)}for(let[e,t]of Object.entries(n?.hostFields??{})){if(je.has(e))throw new p(`config`,`Tool '${n?.name}' declares the host field '${e}', which is a field of every agent tool`);a[e]=t}return i(a)}var Y=l({text:n().optional(),structured:r().optional(),removed:s(l({path:n(),reason:n(),item:r()})).optional(),parts:s(te).optional(),sources:s(ne).optional()});function Pe(e){return e.type===`speech`||(e.type===`text`||e.type===`image`)&&e.inputs.text!==!1}function Fe(e){return e.type===`builtin`?!1:e.permission!==`auto`||`auth`in e&&e.auth!==void 0&&(e.auth.onUnauthenticated??`gate`)===`gate`}function X(e,t){if(!Ee.has(e.type))return`it is a ${e.type} profile; an agent tool runs a text, image, or speech profile`;if(!Pe(e))return`it does not take text`;for(let n of N(e)){let e=t(n);if(!e)return`its tool '${n}' is not registered; register it first`;if(Fe(e))return`its tool '${n}' can stop on a gate; give it permission 'auto' and no sign-in`}}function Ie(e,t,n){let r=`Agent tool "${e.name}"`,i=e.maxCallsPerTurn;if(i!==void 0&&!(Number.isInteger(i)&&i>0))throw new p(`config`,`${r}: maxCallsPerTurn must be a whole number above 0`);let a=t(e.profile);if(!a)throw new p(`config`,`${r}: profile '${e.profile}' must be registered before the tool`);let o=X(a,n);if(o)throw new p(`config`,`${r} can't run '${e.profile}': ${o}`);return a}function Z(e){if(!e)return`delegated`;let t=`models`in e&&Object.values(e.models).some(e=>(e.builtInTools?.length??0)>0);return N(e).length===0&&!t?`local`:`delegated`}function Le(e){let t=d(e),n=t.flatMap(e=>e.type===`text`?[e.text]:[]).join(``),r=f(t,e=>e.type===`structured`),i=r?.structured,a=t.flatMap(e=>e.type===`media`?[{type:e.media.mimeType.startsWith(`audio/`)?`audio`:`image`,mimeType:e.media.mimeType,data:e.media.data}]:[]),o=t.flatMap(e=>e.type===`citation`?e.sources:[]);return{...i===void 0?{text:n}:{structured:i},...r?.removed?.length?{removed:r.removed}:{},...a.length>0?{parts:a}:{},...o.length>0?{sources:o}:{}}}function Re(e,t,n){return{...e,type:`agent`,input:t,output:Y,sources:e=>e.sources??[],...n}}function ze(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n.push(`${t}: schema must be an object`),!1;let r=typeof e.type==`string`||Array.isArray(e.type),i=e.anyOf!==void 0||e.oneOf!==void 0;if(!r&&!i){if(t!==`$`)return!0;n.push(`${t}: missing type or combinator`)}return e.type===`array`&&e.items===void 0&&n.push(`${t}: array schema must define items`),!0}function Be(e,t,n,r){let i=Array.isArray(t)?t:[];for(let t of i)typeof t==`string`&&!Object.hasOwn(e,t)&&r.push(`${n}: required key '${t}' missing from properties`);for(let[t,i]of Object.entries(e))i&&typeof i==`object`&&Q(i,`${n}.properties.${t}`,r)}function Q(e,t,n){if(!ze(e,t,n))return;let r=e.properties;r&&typeof r==`object`&&!Array.isArray(r)&&Be(r,e.required,t,n),e.items&&typeof e.items==`object`&&!Array.isArray(e.items)&&Q(e.items,`${t}.items`,n);for(let r of[`anyOf`,`oneOf`]){let i=e[r];Array.isArray(i)&&i.forEach((e,i)=>{e&&typeof e==`object`&&Q(e,`${t}.${r}[${i}]`,n)})}}function Ve(e,t){let n=[];if(Q(e,`$`,n),n.length>0)throw new p(`config`,`Invalid tool ${t} schema: ${n.join(`; `)}`)}function He(t,n=`output`){let r=e(t,{target:`draft-7`,io:n});return delete r.$schema,r.type||=`object`,r}function $(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map($);let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=$(e[n]));return t}function Ue(e){let t=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(e)?.[0];if(!t||/[{}]/.test(t))throw new p(`config`,`Endpoint "${e}" must start with a fixed scheme and host; placeholders belong in the path or query`)}export{T as A,P as C,O as D,H as E,y as M,ie as N,D as O,ae as P,F as S,W as T,ve as _,Te as a,_e as b,Z as c,Ie as d,Re as f,K as g,q as h,Ve as i,ce as j,w as k,Y as l,we as m,He as n,X as o,Me as p,$ as r,Ne as s,Ue as t,Le as u,U as v,xe as w,N as x,be as y};
|