@theoremjs/studio 0.3.4-next.544.gb5ef325 → 0.3.4-next.550.gf20b9cd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +57 -17
  2. package/agreement.js +22 -7
  3. package/compile.js +61 -13
  4. package/cookbooks/catalog.d.ts +26 -3
  5. package/cookbooks/catalog.js +114 -60
  6. package/cookbooks/exchanges.d.ts +3 -0
  7. package/cookbooks/exchanges.js +7 -2
  8. package/cookbooks/mod.d.ts +3 -3
  9. package/cookbooks/mod.js +2 -2
  10. package/cookbooks/project.js +1 -3
  11. package/draft.d.ts +23 -5
  12. package/draft.js +10 -2
  13. package/media-accept.d.ts +7 -0
  14. package/media-accept.js +17 -0
  15. package/mod.d.ts +4 -4
  16. package/mod.js +3 -3
  17. package/package.json +4 -4
  18. package/page/assets/Banner-Bvkdyf59.js +2 -0
  19. package/page/assets/BottomSheet-Dbh6A5Vl.js +1 -0
  20. package/page/assets/{Card-Ghe4ozhC.js → Card-DruykyeB.js} +1 -1
  21. package/page/assets/CheckboxInput-CFZ_Wq8-.js +2 -0
  22. package/page/assets/CodeBlock-CfVOtDeO.js +52 -0
  23. package/page/assets/CollapsibleGroup-FIawJRo4.js +1 -0
  24. package/page/assets/ConsoleFrame-BTL67qHr.js +3 -0
  25. package/page/assets/ContextMenu-BngxR9na.js +2 -0
  26. package/page/assets/DateInput-B1ICJtHn.js +1 -0
  27. package/page/assets/{Dialog-BDUExlk_.js → Dialog-Sd04KQS2.js} +1 -1
  28. package/page/assets/EmptyState-C_uF9Wyj.js +1 -0
  29. package/page/assets/HoverCard-DMyWUvwP.js +1 -0
  30. package/page/assets/Icon-BqkS-pIq.js +3 -0
  31. package/page/assets/IconButton-DVUFx-8p.js +1 -0
  32. package/page/assets/ListItem-QF7KFt0h.js +1 -0
  33. package/page/assets/MenuBottomSheet-C4fG_GyZ.js +1 -0
  34. package/page/assets/MenuBottomSheetActionList-3L0HS4Kf.js +1 -0
  35. package/page/assets/SchemaFields-BT2XCbid.js +1 -0
  36. package/page/assets/ScrollableArea-BHfY7sWH.js +1 -0
  37. package/page/assets/SegmentedControlItem-BBGRPrxp.js +1 -0
  38. package/page/assets/{Text-BsiAsowd.js → Text-BOqCfzZC.js} +2 -2
  39. package/page/assets/{TimestampHoverCard-CCnmnVlQ.js → TimestampHoverCard-CDCVpEWM.js} +1 -1
  40. package/page/assets/{ToolResultCharts-BAIAtrxa.js → ToolResultCharts-rJr0Ksno.js} +1 -1
  41. package/page/assets/Tooltip-BWs5DLrM.js +1 -0
  42. package/page/assets/TraceInspector-DQI_wNzL.js +1 -0
  43. package/page/assets/{TraceOverview-C6T0S77W.js → TraceOverview-DmfmwSR6.js} +2 -2
  44. package/page/assets/{_virtual_studio-type-sources-C1mRXxbj.js → _virtual_studio-type-sources-CxP3L28S.js} +158 -78
  45. package/page/assets/browser-engine-B1PxEekk.js +11 -0
  46. package/page/assets/browser-transport-BOHBmYvp.js +47 -0
  47. package/page/assets/{embedding-space-view-BU2AjjAx.js → embedding-space-view-CN0VHXXH.js} +1 -1
  48. package/page/assets/{export-agent-m6Z0No6j.js → export-agent-BvEVKW_C.js} +8 -8
  49. package/page/assets/fieldParts-B7DYLgh4.js +1 -0
  50. package/page/assets/focusableSelector-DXZeMU85.js +1 -0
  51. package/page/assets/{guardrail-tester-oVuyo5d2.js → guardrail-tester-08T-hMFL.js} +2 -2
  52. package/page/assets/index-eSb7kilv.js +146 -0
  53. package/page/assets/isRenderable-DHkzpAoQ.js +1 -0
  54. package/page/assets/{labels-provider-Gus3heEH.js → labels-provider-DkA22zkP.js} +2 -2
  55. package/page/assets/{live-messages-BNhCuiuF.js → live-messages-DmTC8qc8.js} +1 -1
  56. package/page/assets/plainDate-BHiJcj7o.js +1 -0
  57. package/page/assets/reader-DoTXxl0W.js +7 -0
  58. package/page/assets/{stub-DPcZtI0s.js → stub-CKo_lxer.js} +1 -1
  59. package/page/assets/studio-code-pane-CEG07Zk7.js +8 -0
  60. package/page/assets/{studio-console-DoZMv_gr.js → studio-console-udt4MmTi.js} +1 -1
  61. package/page/assets/studio-decision-tocwLzxr.js +1 -0
  62. package/page/assets/studio-embedding-DQ84xzlj.js +2 -0
  63. package/page/assets/studio-host-console-BJOUpXHR.js +2 -0
  64. package/page/assets/studio-labels-Zqd84hcs.js +3 -0
  65. package/page/assets/studio-live-BmuHpeF4.js +5 -0
  66. package/page/assets/{studio-map-Dv8iCayn.js → studio-map-qP_i4hWG.js} +1 -1
  67. package/page/assets/studio-trace-replay-JUMs6EMA.js +2 -0
  68. package/page/assets/{studio-type-checker-B5DVxAZ0.js → studio-type-checker-B_CHmWnf.js} +1 -1
  69. package/page/assets/{tool-schema-CxLtS_Zt.js → tool-schema-CWGccblZ.js} +6 -6
  70. package/page/assets/{trace-patterns-CS99kExN.js → trace-patterns-D6TbkLLr.js} +1 -1
  71. package/page/assets/tree-B7VVMg1s.js +3 -0
  72. package/page/assets/{turn-client-BCi5WnI6.js → turn-client-CoLR6hrl.js} +1 -1
  73. package/page/assets/types-CL44MvsT.js +1 -0
  74. package/page/assets/{use-one-call-TEvndb3j.js → use-one-call-BKeMtY5F.js} +1 -1
  75. package/page/assets/use-second-ticker-GWBt83pd.css +1 -0
  76. package/page/assets/use-trace-records-B1vrKQmA.js +1 -0
  77. package/page/assets/useAdaptivePresentation-Bma4-u1a.js +1 -0
  78. package/page/assets/useAnnounce-DTSHZvjg.js +1 -0
  79. package/page/assets/useClipboard-CbN9bb4J.js +1 -0
  80. package/page/assets/useDevWarning-Z9SoixOP.js +1 -0
  81. package/page/assets/useFocusReturnVisibility-BHKv5Jwr.js +1 -0
  82. package/page/assets/useMenuPress-DLG1QOiE.js +1 -0
  83. package/page/assets/useResolvedRequired-DbsOcDqy.js +1 -0
  84. package/page/assets/useScrollableArea-DuF_pz9m.js +1 -0
  85. package/page/assets/useTooltip-c097gL_-.js +1 -0
  86. package/page/assets/workspace-NGa3jjDc.js +1 -0
  87. package/page/index.html +45 -38
  88. package/read-source.js +35 -8
  89. package/read-studio.mjs +99 -0
  90. package/replay.d.ts +3 -1
  91. package/replay.js +53 -5
  92. package/requirements.d.ts +3 -0
  93. package/requirements.js +10 -0
  94. package/server/alerts.d.ts +23 -0
  95. package/server/alerts.js +82 -0
  96. package/server/draft-handler.d.ts +3 -0
  97. package/server/draft-handler.js +5 -1
  98. package/server/events.d.ts +38 -0
  99. package/server/events.js +95 -0
  100. package/server/handler.d.ts +11 -3
  101. package/server/handler.js +64 -8
  102. package/server/project-source.d.ts +6 -3
  103. package/server/project-source.js +45 -4
  104. package/server/project.js +25 -3
  105. package/server/save-session.d.ts +2 -0
  106. package/server/save-session.js +7 -1
  107. package/server/serve.d.ts +1 -1
  108. package/server/serve.js +174 -18
  109. package/server/test-key.d.ts +19 -2
  110. package/server/test-key.js +51 -74
  111. package/server/watch.d.ts +8 -0
  112. package/server/watch.js +16 -5
  113. package/start.mjs +95 -5
  114. package/surface.js +1 -2
  115. package/ui/built/theme.css +2 -2
  116. package/ui/built/theme.css.d.ts +2 -2
  117. package/ui/built/theorem-studio.d.ts +2 -2
  118. package/ui/built/theorem-studio.js +3 -3
  119. package/ui/built/theorem-studio.variants.d.ts +2 -2
  120. package/ui/lib/export-agent.js +20 -2
  121. package/ui/lib/page-errors.d.ts +13 -0
  122. package/ui/lib/page-errors.js +31 -0
  123. package/ui/lib/studio-examples.js +0 -4
  124. package/ui/lib/studio-page.d.ts +8 -3
  125. package/ui/lib/studio-page.js +34 -13
  126. package/ui/profile-editor.js +186 -34
  127. package/ui/studio-decision.js +4 -1
  128. package/ui/studio-runner.d.ts +1 -1
  129. package/ui/studio-runner.js +7 -3
  130. package/ui/studio-screen.js +24 -18
  131. package/ui/studio-trace-replay.js +1 -8
  132. package/workspace.d.ts +1 -0
  133. package/workspace.js +3 -2
  134. package/page/assets/Banner-BUrqNrQ9.js +0 -2
  135. package/page/assets/BottomSheet-BQPskY35.js +0 -1
  136. package/page/assets/CheckboxInput-C9kbVyhK.js +0 -2
  137. package/page/assets/CodeBlock-Kjgv83A6.js +0 -52
  138. package/page/assets/CollapsibleGroup-PavPZ114.js +0 -1
  139. package/page/assets/ConsoleFrame-BpbXMWsq.js +0 -3
  140. package/page/assets/ContextMenu-D_6fLWw7.js +0 -2
  141. package/page/assets/DateInput-BJt-UTCy.js +0 -1
  142. package/page/assets/EmptyState-C8W4JKBZ.js +0 -1
  143. package/page/assets/HoverCard-C6thuzrf.js +0 -1
  144. package/page/assets/Icon-ZfFwTt8n.js +0 -3
  145. package/page/assets/IconButton-CG5klqF1.js +0 -1
  146. package/page/assets/ScrollableArea-C8AVuqnt.js +0 -1
  147. package/page/assets/Section-DJ97F7QE.js +0 -1
  148. package/page/assets/SegmentedControlItem-BLuJOusN.js +0 -1
  149. package/page/assets/Tooltip-CTEuMRLe.js +0 -1
  150. package/page/assets/TraceInspector-CvaN-GcS.js +0 -1
  151. package/page/assets/browser-engine-BS9Kn2Gx.js +0 -11
  152. package/page/assets/browser-transport-eqZ9n2AK.js +0 -47
  153. package/page/assets/fieldParts-Cs6Amprh.js +0 -1
  154. package/page/assets/index-Q8T7gvHP.js +0 -149
  155. package/page/assets/reader-BT_YeHdq.js +0 -7
  156. package/page/assets/studio-code-pane-BB8Q348A.js +0 -8
  157. package/page/assets/studio-decision-BPT3x1kT.js +0 -1
  158. package/page/assets/studio-embedding-cH6PQupx.js +0 -2
  159. package/page/assets/studio-host-console-ZvV5TFC4.js +0 -2
  160. package/page/assets/studio-labels-Dwd-ojX5.js +0 -3
  161. package/page/assets/studio-live-DDInnfd7.js +0 -5
  162. package/page/assets/studio-trace-replay-Dl792A2v.js +0 -2
  163. package/page/assets/tree-Bi2FOU_h.js +0 -3
  164. package/page/assets/types-s-3wFTyD.js +0 -1
  165. package/page/assets/use-second-ticker-CnxaP3LD.css +0 -1
  166. package/page/assets/use-trace-records-BkAYJz0M.js +0 -1
  167. package/page/assets/useAdaptivePresentation-BY_zvjIp.js +0 -1
  168. package/page/assets/useClipboard-B1amtN2V.js +0 -1
  169. package/page/assets/useDevWarning-Cna3kqg1.js +0 -1
  170. package/page/assets/useScrollableArea-vxuztwym.js +0 -1
  171. package/page/assets/useTooltip-rxACYEAC.js +0 -1
  172. package/page/assets/workspace-BiCkglEt.js +0 -1
  173. /package/page/assets/{use-second-ticker-VX91zrxj.js → use-second-ticker-DhbZ0Soz.js} +0 -0
@@ -1 +1 @@
1
- import{c as e}from"./themeProps-3IqahpCr.js";import{t}from"./VStack-CkVMcNiK.js";import{n,t as r}from"./StackItem-CQviqAfM.js";import{t as i}from"./Text-BsiAsowd.js";import{t as a}from"./Card-Ghe4ozhC.js";var o=e(),s={clear:`light-dark(#0d1e37, #b4c6e2)`,shade1:`light-dark(#3b5580, #6582ad)`,shade2:`light-dark(#7f95b7, #3b5078)`,shade3:`light-dark(#bcc8da, #22345a)`,failed:`light-dark(#8e2a28, #cd5f55)`},c=`light-dark(#e4e7ec, #2b2f36)`,l=`light-dark(#9aa3b1, #6b727d)`,u=s.clear,d=`var(--color-background-surface)`,f={model:`clear`,tool:`hatch`,host:`shade1`,theorem:`shade2`,user:`shade3`,error:`failed`};function p(e){return e===`hatch`?`url(#trace-fill-hatch)`:s[e]}function m(){return(0,o.jsx)(`svg`,{"aria-hidden":!0,width:0,height:0,style:{position:`absolute`},children:(0,o.jsx)(`defs`,{children:(0,o.jsxs)(`pattern`,{id:`trace-fill-hatch`,width:3,height:3,patternUnits:`userSpaceOnUse`,patternTransform:`rotate(45)`,children:[(0,o.jsx)(`rect`,{width:3,height:3,fill:c}),(0,o.jsx)(`line`,{x1:0,y1:0,x2:0,y2:3,stroke:l,strokeWidth:1.2})]})})})}function h({fill:e}){return(0,o.jsx)(`svg`,{"aria-hidden":!0,width:10,height:10,style:{display:`block`,flexShrink:0},children:(0,o.jsx)(`rect`,{width:10,height:10,rx:2,fill:p(e)})})}var g={background:`var(--theorem-console-card, var(--color-background-surface))`,borderRadius:`var(--radius-page)`};function _({title:e,value:a,note:s,aside:c,detail:l,children:d}){let f=(0,o.jsx)(i,{type:`supporting`,color:`secondary`,children:e}),p=l?(0,o.jsxs)(t,{gap:1,children:[f,(0,o.jsx)(i,{type:`supporting`,maxLines:2,children:l})]}):f;return(0,o.jsxs)(t,{gap:3,children:[c?(0,o.jsxs)(n,{gap:3,vAlign:`center`,children:[(0,o.jsx)(r,{size:`fill`,children:p}),c]}):p,(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,flexWrap:`wrap`,columnGap:8},children:[(0,o.jsx)(i,{size:`2xl`,weight:`medium`,hasTabularNumbers:!0,children:a}),s?(0,o.jsx)(i,{type:`supporting`,hasTabularNumbers:!0,children:(0,o.jsx)(`span`,{style:{color:u},children:s})}):null]}),d]})}function v(e){return(0,o.jsx)(a,{variant:`muted`,padding:4,style:g,children:(0,o.jsx)(_,{...e})})}export{d as a,p as c,v as i,g as n,m as o,_ as r,h as s,f as t};
1
+ import{c as e}from"./themeProps-3IqahpCr.js";import{t}from"./VStack-CkVMcNiK.js";import{n,t as r}from"./StackItem-CQviqAfM.js";import{t as i}from"./Text-BOqCfzZC.js";import{t as a}from"./Card-DruykyeB.js";var o=e(),s={clear:`light-dark(#0d1e37, #b4c6e2)`,shade1:`light-dark(#3b5580, #6582ad)`,shade2:`light-dark(#7f95b7, #3b5078)`,shade3:`light-dark(#bcc8da, #22345a)`,failed:`light-dark(#8e2a28, #cd5f55)`},c=`light-dark(#e4e7ec, #2b2f36)`,l=`light-dark(#9aa3b1, #6b727d)`,u=s.clear,d=`var(--color-background-surface)`,f={model:`clear`,tool:`hatch`,host:`shade1`,theorem:`shade2`,user:`shade3`,error:`failed`};function p(e){return e===`hatch`?`url(#trace-fill-hatch)`:s[e]}function m(){return(0,o.jsx)(`svg`,{"aria-hidden":!0,width:0,height:0,style:{position:`absolute`},children:(0,o.jsx)(`defs`,{children:(0,o.jsxs)(`pattern`,{id:`trace-fill-hatch`,width:3,height:3,patternUnits:`userSpaceOnUse`,patternTransform:`rotate(45)`,children:[(0,o.jsx)(`rect`,{width:3,height:3,fill:c}),(0,o.jsx)(`line`,{x1:0,y1:0,x2:0,y2:3,stroke:l,strokeWidth:1.2})]})})})}function h({fill:e}){return(0,o.jsx)(`svg`,{"aria-hidden":!0,width:10,height:10,style:{display:`block`,flexShrink:0},children:(0,o.jsx)(`rect`,{width:10,height:10,rx:2,fill:p(e)})})}var g={background:`var(--theorem-console-card, var(--color-background-surface))`,borderRadius:`var(--radius-page)`};function _({title:e,value:a,note:s,aside:c,detail:l,children:d}){let f=(0,o.jsx)(i,{type:`supporting`,color:`secondary`,children:e}),p=l?(0,o.jsxs)(t,{gap:1,children:[f,(0,o.jsx)(i,{type:`supporting`,maxLines:2,children:l})]}):f;return(0,o.jsxs)(t,{gap:3,children:[c?(0,o.jsxs)(n,{gap:3,vAlign:`center`,children:[(0,o.jsx)(r,{size:`fill`,children:p}),c]}):p,(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,flexWrap:`wrap`,columnGap:8},children:[(0,o.jsx)(i,{size:`2xl`,weight:`medium`,hasTabularNumbers:!0,children:a}),s?(0,o.jsx)(i,{type:`supporting`,hasTabularNumbers:!0,children:(0,o.jsx)(`span`,{style:{color:u},children:s})}):null]}),d]})}function v(e){return(0,o.jsx)(a,{variant:`muted`,padding:4,style:g,children:(0,o.jsx)(_,{...e})})}export{d as a,p as c,v as i,g as n,m as o,_ as r,h as s,f as t};
@@ -0,0 +1,3 @@
1
+ import{$n as e,C as t,Cr as n,M as r,Vt as i,ar as a,br as o,h as ee,j as s,mn as c,mr as l,n as u,p as d,pr as te,qt as ne,t as re,ur as ie,y as ae,yn as oe,z as se}from"./tool-schema-CWGccblZ.js";import{En as f,Sn as p,qt as m,rn as h,tn as g}from"./shaped-data-DYOBdvLJ.js";import{a as _,r as v}from"./live-ingress-OuSlQ6q7.js";var ce=[{id:`identity`,profilePath:`identity`,role:`root`,optional:!1,editor:`structural`,label:`Identity`,ownsFields:[`profile.id`,`profile.type`]},{id:`models`,profilePath:`models`,role:`spine`,optional:!1,editor:`structural`,label:`Models`,ownsFields:[`profile.defaultModel`,`profile.allowModelSelect`,`profile.maxSteps`,`providerContinuation`]},{id:`modelBinding`,profilePath:`models.*`,role:`branch`,parent:`models`,optional:!1,editor:`structural`,label:`Model binding`},{id:`decision`,profilePath:`decision`,role:`spine`,optional:!1,editor:`structural`,label:`Decision`,ownsFields:[`inputs`]},{id:`image`,profilePath:`image`,role:`spine`,optional:!1,editor:`structural`,label:`Image`},{id:`speech`,profilePath:`speech`,role:`spine`,optional:!1,editor:`structural`,label:`Speech`},{id:`live`,profilePath:`live`,role:`spine`,optional:!1,editor:`structural`,label:`Live`},{id:`tools`,profilePath:`tools`,role:`spine`,optional:!1,editor:`structural`,label:`Tools`},{id:`toolSpec`,profilePath:`tools.allow`,role:`branch`,parent:`tools`,optional:!0,editor:`structural`,label:`Tool`},{id:`inputs`,profilePath:`inputs`,role:`spine`,optional:!1,editor:`structural`,label:`Inputs`},{id:`outputs`,profilePath:`outputs`,role:`spine`,optional:!0,editor:`structural`,label:`Outputs`},{id:`turnBehaviour`,profilePath:`turnBehaviour`,role:`spine`,optional:!0,editor:`structural`,label:`Turn behaviour`},{id:`guardrails`,profilePath:`guardrails`,role:`spine`,optional:!0,editor:`structural`,label:`Guardrails`},{id:`observability`,profilePath:`observability`,role:`spine`,optional:!0,editor:`structural`,label:`Observability`},{id:`labels`,profilePath:`labels`,role:`spine`,optional:!0,editor:`structural`,label:`Labels`}],le={identity:o,inputs:n(`inputs`).filter(e=>e!==`decision`)},y=ce.map(e=>({...e,profileTypes:le[e.id]??n(e.profilePath)}));function ue(e){return y.find(t=>t.id===e)}function de(e){return e.modelBindings.length>1}function fe(e){return e.modelBindings.some(t=>t.provider!==`local`&&!r(e.providers,t).keySlot)}function b(e,t){let n={provider:t.provider,keySlot:t.keySlot||e.models.key,fallbackKeySlot:t.fallbackKeySlot||e.models.fallbackKey},i=r(e.providers,n);return{...i,given:{keySlot:!!i.keySlot&&!n.keySlot,fallbackKeySlot:!!i.fallbackKeySlot&&!n.fallbackKeySlot}}}function pe(e,t){let n=new Set(e.modelBindings.filter(n=>{let r=b(e,n);return r.keySlot===t||r.fallbackKeySlot===t}).map(e=>e.provider));return e.providers.filter(e=>n.has(e.id))}function me(e){let t=e.efforts.map(({alias:e})=>e.trim()).filter(Boolean);return new Set(t).size>1}function he(e){return e.attachmentsAccept.length>0||e.voiceAccept.length>0}var ge=a,x=[{name:`operationTimeoutMs`,label:`Call timeout`,units:`ms`,isTimer:!0},{name:`connectTimeoutMs`,label:`Connect timeout`,units:`ms`,isTimer:!0},{name:`liveStepTimeoutMs`,label:`Live step timeout`,units:`ms`,isTimer:!0},{name:`maxWireRecordBytes`,label:`Wire record`,units:`bytes`,isTimer:!1},{name:`maxWireResponseBytes`,label:`Wire response`,units:`bytes`,isTimer:!1},{name:`maxEventBytes`,label:`Event`,units:`bytes`,isTimer:!1},{name:`maxStepBytes`,label:`Step`,units:`bytes`,isTimer:!1},{name:`maxStepEvents`,label:`Step events`,units:`events`,isTimer:!1},{name:`maxPendingToolCalls`,label:`Tool calls`,units:`calls`,isTimer:!1}],S=2147483647,C={compactMaxTokens:32e3,compactAt:.75,compactKeep:4},w={"continue.instruction":`turnBehaviour`,"canary.bind_note":`guardrails`,"quota.exhausted":`guardrails`,"repair.default_guidance":`outputs`,"egress.default_repair_guidance":`guardrails`,"egress.refusal":`guardrails`};function T(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function E(e){return{key:T(`model`),modelId:`fast`,protocol:`openRouterOpenAi`,provider:`openrouter`,apiId:``,options:{},timeoutMs:null,efforts:[],defaultEffort:``,allowEffortSelect:!1,summaries:null,maxOutputTokens:null,temperature:null,builtInTools:[],...e}}var D=`Studio stub tool — returns a fixed result.`;function O(e){return{key:T(`tool`),toolName:`my_tool`,toolType:`function`,description:D,category:`studio`,access:ie[0],permission:l[0],loadTier:te[0],paths:[`*`],inputJson:re,outputJson:u,...e}}function k(e,t,n){return(!e.description.trim()||e.description===D)&&n?{agentKey:t,description:`Asks ${n} and returns its answer.`}:{agentKey:t}}function A(){return{name:``,kind:`words`,pattern:``,flags:``,words:[]}}function j(){return{key:``,label:``,at:f(p,()=>`ignore`),patterns:[A()],hint:``}}function M(){let e=oe(void 0);return{canaryBindNote:``,detect:f(m,t=>({...e.detect[t]})),sources:Object.fromEntries(g.map(e=>[e,{theorem:!0,patterns:[],hint:``}])),own:[],quotaEnabled:!1,quotaPerDay:null,quotaMessage:``,allow:{ungiven_images:{hosts:[],fromTools:!0},ungiven_links:{hosts:[],fromTools:!0}},innocentNames:[],blockedReplyOnBlock:``,blockedReplyMaxRetries:null,egressRepairGuidance:``,egressRefusal:``,allowPrivateNetworks:!1,allowedHosts:[],allowedSchemes:[],taintAfterRemoteRead:``,taintRemoteDestination:``}}function N(){let e=_({});return{writeTo:d,destination:d,sampleRate:e.sampleRate,include:{...e.include},scrub:{sensitive:!!e.scrub.sensitive,injection:!!e.scrub.injection,canary:!!e.scrub.canary},retainForDays:null,rotateAfterMiB:null,resourceJson:``}}function P(e){return e.map(([e,t])=>({key:T(`criterion`),label:e,text:t}))}function F(){return{contract:`guardrails.tool_call.v1`,maxStateBytes:null,questions:[{key:T(`question`),id:`verdict`,type:`choice`,instructions:`Given what the user asked for and what the call would do, should it run?`,criteria:P([[`allow`,`Safe, and what the user asked for.`],[`flag`,`Probably fine, but unusual or sensitive enough for a person to look first.`],[`block`,`Harmful, or clearly beyond what the user asked for.`]])},{key:T(`question`),id:`risk`,type:`score`,instructions:`How much harm would this call do if it were wrong?`,criteria:P([[``,`Low: reversible, and affects only the user.`],[``,`High: hard to undo, or affects other people or money.`]])}],images:[]}}var I=JSON.stringify({context:`The user asked the agent to tidy up old screenshots on their desktop.`,tool_call:{name:`delete_files`,path:`~/Documents`,recursive:!0},outcome:`Would delete 1,284 files, including tax_return_2025.pdf.`},null,2),L=JSON.stringify(`The user asked to tidy screenshots. The proposed call recursively deletes 1,284 files, including a tax return.`),_e=`To clear your desktop, select the screenshots and move them to the Trash. Empty the Trash to delete them for good.(Screen captures save to the desktop by default. You can change where they go in the Screenshot app's Options menu.(Press Command-Shift-5 to record the screen or capture a window. Recordings are saved as movie files next to your screenshots.(Stacks group desktop files by kind, date or tag, so a cluttered desktop folds into a few piles you can open one at a time.(Deleted files stay in the Trash for 30 days. Drag a file out of the Trash to put it back where it was.(When your disk is almost full, open Storage settings and review the largest files. Old downloads and installers are safe to remove.(Offloading unused apps frees space and keeps their documents. Reinstalling an app brings its data back.(Photos you have backed up can be optimised so the originals live in the cloud and smaller copies stay on the device.(Your plan renews on the same date each month. You can see the next charge under Billing, then Upcoming invoices.(To get a refund, open the invoice and choose Request refund. Charges from the last 14 days are refunded in full.(Update your card under Billing, then Payment methods. The new card is used for the next renewal, not for past invoices.(Annual plans cost two months less than paying monthly. Switching mid-term credits the unused months to the new plan.(Invoices are emailed as PDFs and list your company name and tax number. Edit those details before the invoice is issued.(Turn on two-step verification under Security. You will be asked for a code from your authenticator app each time you sign in on a new device.(If you forget your password, choose Forgot password on the sign-in page. The reset link expires after one hour.(Review signed-in devices under Security and sign out any you don't recognise. This ends their sessions immediately.(Passkeys replace your password with your fingerprint or face. Create one under Security, then Passkeys.(To close your account, export your data first. Closing deletes your workspace after a 30-day grace period.(Share a folder by choosing Share, then entering an email address. Viewers can read; editors can change and delete.(Public links work for anyone who has them. Set an expiry date, or turn the link off to stop sharing at once.(Transfer ownership of a folder before you leave a team, or its contents will be archived with your account.(Lisbon has mild, wet winters and warm, dry summers. Expect highs near 28 °C in August.(The best months for the Algarve coast are May, June and September, when the beaches are warm and the crowds are thin.(Trams in Lisbon climb the steep hills of Alfama and Graça. Line 28 is the famous one, and the busiest.(For a crisp pizza base, preheat the oven and the baking tray together at the highest setting for at least thirty minutes.(Rest steak for five minutes after cooking so the juices settle back into the meat instead of running onto the board.`.split(`(`).join(`
2
+
3
+ `),ve=`How do I delete every screenshot on my desktop?`;function ye(e,t=`choice`){let n=K(`question`,e.decision.questions.map(e=>e.id),e=>`question_${e}`);return{key:T(`question`),id:n,type:t,instructions:``,criteria:z(t)}}function be(e,t,n){let r=t.replace(/\.[^.]*$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``)||`image`,i=K(r,e.decision.images.map(e=>e.name),e=>`${r}_${e}`);return{key:T(`image`),name:i,...n}}function xe(e){let t=K(`slot`,e.map(e=>e.name),e=>`slot_${String(e)}`);return{key:T(`slot`),name:t,label:``,choices:[R(),R()]}}function R(){return{key:T(`choice`),value:``,description:``}}function z(e){return e===`noul`||e===`box`?[]:P(e===`choice`?[[`yes`,``],[`no`,``]]:[[``,``],[``,``]])}function Se(){return{identity:{agentId:``,profileType:``,handle:``,system:``,systemByRoleJson:``},included:[`observability`,`labels`],models:{defaultModel:``,allowModelSelect:!1,maxSteps:null,key:``},modelBindings:[],providers:[...t],tools:{t2Loader:``,parallel:!1},toolSpecs:[],inputs:{text:!0,attachmentsAccept:[],voiceAccept:[],maxFiles:null,maxBytes:null,maxTurnBytes:null,limitsByMime:{},slots:[],contextFrom:[],contextMaxChars:null},outputs:{mode:`text`,schemaId:``,schemaJson:``,streamMode:``,streamThoughts:!0,validationEnabled:!1,maxRetries:null,itemRules:{},repairGuidance:``},turnBehaviour:{resumeEnabled:!1,allowContinue:[],autoContinue:[],maxContinues:null,continueInstruction:``,allowSteering:ne({type:`text`}),atStepLimit:`stop`},guardrails:M(),observability:N(),image:{aspectRatio:``,resolution:``,mimeType:``,quality:``,background:``,n:null,seed:null,outputCompression:null,includeText:!1,references:[]},speech:{voice:``,style:``,speed:null,format:``},live:{ingressAudio:v(`audio`),ingressVideo:v(`video`),ingressText:v(`text`),voice:``,sessionResumption:!1,greeting:``,resumedPrompt:``,resumedAfterMs:null,contextCompression:!1,compressionTriggerTokens:null,compressionTargetTokens:null,transcriptionInput:!1,transcriptionOutput:!1,vadActivityHandling:``,vadStartSensitivity:``,vadEndSensitivity:``,vadPrefixPaddingMs:null,vadSilenceDurationMs:null},decision:F(),labels:{}}}var Ce=new Set([`guardrails`]);function B(e,t){return e.profileTypes.includes(t)&&!(t===`decision`&&Ce.has(e.id))}function V(e){let t=e.identity.profileType;if(!t)return[`identity`];let n=new Set(e.included);return y.filter(e=>e.role!==`branch`&&B(e,t)&&(!e.optional||n.has(e.id))).map(e=>e.id)}function H(e,t){let r=e.identity.profileType;return r!==``&&n(t).includes(r)}function we(e){return H(e,`identity.system`)&&h(e.guardrails.detect,`canary_leak`)}function Te(e){let t=e.identity.profileType;return t!==``&&i.includes(t)}function U(e){let t=e.identity.profileType;return t?y.filter(n=>n.role===`spine`&&n.optional&&B(n,t)&&!e.included.includes(n.id)).map(e=>e.id):[]}function Ee(t){return{...t,attachmentsAccept:t.attachmentsAccept.filter(t=>c(e,t)),voiceAccept:[]}}function De(e,t,n){let r=e.modelBindings.find(e=>e.key===t);return r?{...e,models:n.modelId!==void 0&&e.models.defaultModel===r.modelId?{...e.models,defaultModel:n.modelId}:e.models,modelBindings:e.modelBindings.map(e=>e.key===t?{...e,...n}:e)}:e}function W(e,t){if(t.some(t=>t.modelId===e))return e;let[n,...r]=t;return n&&!r.length?n.modelId:``}function Oe(e,t){if(!e.modelBindings.find(e=>e.key===t))return e;let n=e.modelBindings.filter(e=>e.key!==t);return{...e,models:{...e.models,defaultModel:W(e.models.defaultModel,n)},modelBindings:n}}function G(e,t){let n=e.identity.profileType,r=n&&n!==`host`?n:`text`,i=e.modelBindings.map(e=>e.modelId),a=ae(r,t),o=K(a.modelId,i,e=>`${a.modelId}${e}`);return E({...a,modelId:o})}function ke(e){return O({toolName:K(`my_tool`,e.toolSpecs.map(e=>e.toolName),e=>`my_tool_${e}`)})}function K(e,t,n){let r=new Set(t),i=e;for(let e=2;r.has(i);e++)i=n(e);return i}function Ae(e,t,n){if(t===`host`)return{...e,identity:{...e.identity,profileType:t}};let r=e.modelBindings.filter(r=>{let i=s(e.providers,t,r),a=e.providers.find(e=>e.id===r.provider);return se(a,t,r.protocol)&&!Ne(n,t,i)}),i={...e,identity:{...e.identity,profileType:t},modelBindings:r},a=r.length?r:[G(i,n?.start)],o=!e.models.key&&fe({...i,modelBindings:a}),c=t===`speech`&&!e.speech.voice.trim()&&a.some(n=>ee(s(e.providers,t,n)));return{...i,inputs:t===`image`?Ee(e.inputs):e.inputs,...c?{speech:{...e.speech,voice:je}}:{},models:{...e.models,defaultModel:W(e.models.defaultModel,a),key:o?Pe:e.models.key},modelBindings:a}}var je=`Kore`,Me=[`text`,`image`,`speech`,`live`,`decision`];function Ne(e,t,n){if(!e)return!1;let r=t=>e.models(t,n.definition).some(e=>e.id===n.apiId.trim());return!r(t)&&Me.some(e=>e!==t&&r(e))}var Pe=`slot_a`;function Fe(e,t){return U(e).includes(t)?{...e,included:[...e.included,t]}:e}function Ie(e,t){return{...e,included:e.included.filter(e=>e!==t)}}function q(e){return`modelBinding:${e}`}var J=`toolSpec:`;function Y(e){return`${J}${e}`}function X(e){return e.startsWith(J)?e.slice(9):void 0}var Z=`provider:`;function Le(e){return`${Z}${e}`}function Re(e){return e.startsWith(Z)?e.slice(9):void 0}var ze=new Map(y.map(e=>[e.id,e.label]));function Q(e){return ze.get(e)??e}function Be(e,t){let[n,r]=t.split(`:`,2);if(n===`modelBinding`&&r!==void 0)return e.modelBindings.some(e=>e.key===r)?{facet:n,key:r}:void 0;let i=X(t);if(i!==void 0)return e.toolSpecs.some(e=>e.key===i)?{facet:`toolSpec`,key:i}:void 0;let a=V(e);if(r===void 0&&a.includes(t))return{facet:t}}function Ve(e,t){return t===`models`?e.modelBindings.map(e=>({id:q(e.key),ref:{facet:`modelBinding`,key:e.key},label:e.modelId.trim()||Q(`modelBinding`),children:[]})):t===`tools`?$(e.toolSpecs):[]}function $(e){return e.map(e=>({id:Y(e.key),ref:{facet:`toolSpec`,key:e.key},label:e.toolName.trim()||Q(`toolSpec`),children:[]}))}function He(e){let t=V(e).filter(e=>e!==`identity`).map(t=>({id:t,ref:{facet:t},label:Q(t),children:Ve(e,t)}));return{id:`identity`,ref:{facet:`identity`},label:e.identity.agentId.trim()||Q(`identity`),children:t}}export{be as A,Ae as B,V as C,U as D,K as E,xe as F,de as G,De as H,R as I,y as J,he as K,ke as L,G as M,j as N,Fe as O,A as P,we as R,H as S,Ie as T,b as U,Te as V,me as W,ue as Y,S as _,He as a,E as b,$ as c,ve as d,_e as f,ge as g,x as h,Be as i,ye as j,z as k,C as l,w as m,Re as n,X as o,L as p,pe as q,Le as r,Y as s,q as t,I as u,k as v,T as w,O as x,Se as y,Oe as z};
@@ -1,2 +1,2 @@
1
- import{Ln as e,Vt as t}from"./tool-schema-CxLtS_Zt.js";import{c as n}from"./host-patterns-F-KZIzkF.js";import{Un as r,en as i,j as a}from"./shaped-data-DYOBdvLJ.js";import{F as o,bt as s}from"./reader-BT_YeHdq.js";import{r as c}from"./encode-files-CiyHxnUC.js";function l(e,t){let r=typeof t==`string`?t.trim():``;if(!r)throw new n(`request`,`A typed credential must be a non-empty string`);if(e===`bearer`)return{type:`bearer`,token:r};if(e===`api_key`)return{type:`api_key`,key:r};throw new n(`request`,`A '${e}' sign-in takes no typed credential; the host's callback saves it`)}function ee(e,t){if(!e)throw new n(`request`,`a typed credential answers only a sign-in gate`);return{slot:e.slot,credential:l(e.authType,t)}}var u=18e5;function te(e,t){let r=t??u;if(!Number.isFinite(r)||r<=0)throw new n(`config`,`${e} gateTtlMs must be a positive number of milliseconds; got ${r}.`);return r}function ne(e,t,n){return t-e>=n}var d=[`approve`,`deny`,`abandon`];function f(e,t=!1){return e.decision===`approve`?{granted:!0,...e.edited?{edited:e.edited}:{},...t?{signIn:t}:{}}:{granted:!1,cause:e.decision===`deny`?`declined`:`abandoned`,...t?{signIn:t}:{}}}function p(e,t,n){return n!==`session_consent`||e.includes(t)?[...e]:[...e,t]}function re(e,t,r){let{callId:i,decision:a,input:o,secret:s,page:c}=e;if((o!==void 0||s!==void 0||c!==void 0)&&a!==`approve`)throw new n(`request`,`only an approval takes edited input, a secret, or a page answer (call ${i})`);if(a!==`approve`)return{resume:f({decision:a},t.auth!==void 0),input:t.arguments,sessionPermissions:[...r]};let l=s===void 0?void 0:ee(t.auth,s);return{resume:{...f(o===void 0?{decision:a}:{decision:a,edited:{from:t.arguments}},t.auth!==void 0),...t.gateKind?{gateKind:t.gateKind}:{}},input:o??t.arguments,sessionPermissions:p(r,t.name,t.permission),...l?{typed:l}:{},...c?{page:c}:{}}}var m={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
1
+ import{Ln as e,zt as t}from"./tool-schema-CWGccblZ.js";import{c as n}from"./host-patterns-F-KZIzkF.js";import{Un as r,en as i,j as a}from"./shaped-data-DYOBdvLJ.js";import{F as o,bt as s}from"./reader-DoTXxl0W.js";import{r as c}from"./encode-files-CiyHxnUC.js";function l(e,t){let r=typeof t==`string`?t.trim():``;if(!r)throw new n(`request`,`A typed credential must be a non-empty string`);if(e===`bearer`)return{type:`bearer`,token:r};if(e===`api_key`)return{type:`api_key`,key:r};throw new n(`request`,`A '${e}' sign-in takes no typed credential; the host's callback saves it`)}function ee(e,t){if(!e)throw new n(`request`,`a typed credential answers only a sign-in gate`);return{slot:e.slot,credential:l(e.authType,t)}}var u=18e5;function te(e,t){let r=t??u;if(!Number.isFinite(r)||r<=0)throw new n(`config`,`${e} gateTtlMs must be a positive number of milliseconds; got ${r}.`);return r}function ne(e,t,n){return t-e>=n}var d=[`approve`,`deny`,`abandon`];function f(e,t=!1){return e.decision===`approve`?{granted:!0,...e.edited?{edited:e.edited}:{},...t?{signIn:t}:{}}:{granted:!1,cause:e.decision===`deny`?`declined`:`abandoned`,...t?{signIn:t}:{}}}function p(e,t,n){return n!==`session_consent`||e.includes(t)?[...e]:[...e,t]}function re(e,t,r){let{callId:i,decision:a,input:o,secret:s,page:c}=e;if((o!==void 0||s!==void 0||c!==void 0)&&a!==`approve`)throw new n(`request`,`only an approval takes edited input, a secret, or a page answer (call ${i})`);if(a!==`approve`)return{resume:f({decision:a},t.auth!==void 0),input:t.arguments,sessionPermissions:[...r]};let l=s===void 0?void 0:ee(t.auth,s);return{resume:{...f(o===void 0?{decision:a}:{decision:a,edited:{from:t.arguments}},t.auth!==void 0),...t.gateKind?{gateKind:t.gateKind}:{}},input:o??t.arguments,sessionPermissions:p(r,t.name,t.permission),...l?{typed:l}:{},...c?{page:c}:{}}}var m={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
2
  `,r:`\r`,t:` `};function h(e,t){let n=``,r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`"`)return{text:n,end:r+1};if(t!==`\\`){n+=t,r++;continue}if(r+1>=e.length)break;let i=e.charAt(r+1);if(i===`u`){let t=e.slice(r+2,r+6);if(t.length<4)break;if(/^[0-9a-fA-F]{4}$/.test(t)){n+=String.fromCharCode(Number.parseInt(t,16)),r+=6;continue}}n+=m[i]??i,r+=2}return{text:n}}function g(e,t){let n=t;for(;/\s/.test(e.charAt(n));)n++;return n}function ie(e,t){if(e.charAt(t)===`"`){let n=h(e,t);return n.end===void 0?void 0:_(e,t,n.end)}let n=0;for(let r=t;r<e.length;r++){let i=e.charAt(r);if(i===`"`){let t=h(e,r).end;if(t===void 0)return;r=t-1}else if(i===`{`||i===`[`)n++;else if(i===`}`||i===`]`){if(n===0)return _(e,t,r);if(n--,n===0)return _(e,t,r+1)}else if(i===`,`&&n===0)return _(e,t,r)}}function _(e,t,n){try{return{value:JSON.parse(e.slice(t,n)),end:n}}catch{return}}function v(e){let t={},n=g(e,0);if(e.charAt(n)!==`{`)return t;for(n++;;){if(n=g(e,n),e.charAt(n)===`,`&&(n=g(e,n+1)),e.charAt(n)!==`"`)return t;let r=h(e,n);if(r.end===void 0||(n=g(e,r.end),e.charAt(n)!==`:`)||(n=g(e,n+1),n>=e.length))return t;let i=ie(e,n);if(!i)return e.charAt(n)===`"`&&(t[r.text]=h(e,n).text),t;t[r.text]=i.value,n=i.end}}function y(e,t){if(t.phase===void 0)return{name:t.name,callId:t.callId,...t.operationId?{operationId:t.operationId}:{},arguments:t.arguments,...t.reasoning?{reasoning:t.reasoning}:{},...t.stepId?{stepId:t.stepId}:{},artifacts:[]};if(e===void 0)throw new n(`bad_response`,`Tool event '${t.phase}' for call '${t.callId}' arrived before the call.`);if(e.callId!==t.callId||e.name!==t.name)throw new n(`bad_response`,r(`error.bad_response`));switch(t.phase){case`running`:{let{endedAt:n,outputDraft:r,...i}=e;return{...i,state:t,startedAt:t.at,...t.edited?{edited:t.edited}:{},...t.activity?{activity:t.activity}:{}}}case`complete`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`error`:return{...b(e),state:t,endedAt:t.at,...t.activityPast?{activityPast:t.activityPast}:{}};case`cancel`:case`gate`:return{...b(e),state:t,endedAt:t.at};case`draft`:return{...e,outputDraft:(e.outputDraft??``)+t.text};case`artifact`:return{...e,artifacts:[...e.artifacts,t.artifact]};case`dispatch`:case`progress`:case`trace`:case`warning`:return e}}function b(e){let{outputDraft:t,...n}=e;return n}function x(e,t){return{arguments:{},artifacts:[],...e,name:t.name,callId:t.callId,draft:(e?.draft??``)+t.text}}function ae(e){let t=new Map;for(let n of e){if(n.type===`tool_draft`){t.set(n.callId,x(t.get(n.callId),n));continue}if(n.type!==`tool`)continue;let{tool:e}=n,r=e.operationId??e.callId;e.phase===void 0&&t.get(e.callId)?.draft!==void 0&&t.delete(e.callId),t.set(r,y(t.get(r),e))}return[...t.values()]}function S(e){return(e.state?.phase===`gate`?e.state.gate.preparedArguments:void 0)??e.edited?.to??e.arguments}function C(e,t){return e.type!==`tool`||e.tool.callId!==t?!1:e.tool.phase===`complete`||e.tool.phase===`error`}var w={avif:`image/avif`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,webp:`image/webp`,mp4:`video/mp4`,webm:`video/webm`,mov:`video/quicktime`,ogv:`video/ogg`,mp3:`audio/mpeg`,m4a:`audio/mp4`,ogg:`audio/ogg`,wav:`audio/wav`};function oe(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0||n===t.length-1?void 0:w[t.slice(n+1).toLowerCase()]}function se(e){let t=e.trim();if(t.length===0)return;let n;try{n=new URL(t)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=oe(n.pathname);if(r)return{url:n.href,mimeType:r}}var ce=/^(.*)\/thumb(\/.+\/([^/]+))\/(\d+)px-\3(?:\.[a-z0-9]+)?$/i;function le(e){let t=new URL(e),n=t.hostname.split(`.`).slice(-2).join(`.`);for(let e of[...t.searchParams.keys()])e.startsWith(`utm_`)&&t.searchParams.delete(e);let r=ce.exec(t.pathname);return{key:`${n}${r?`${r[1]}${r[2]}`:t.pathname}${t.search}`,width:r?Number(r[4]):1/0}}function ue(e){let t=new Map,n=[],r=e=>{if(typeof e==`string`){let r=se(e);if(!r)return;let i=le(r.url),a=t.get(i.key);if(!a){t.set(i.key,{index:n.length,largest:i.width,smallest:i.width}),n.push(r);return}let o=n[a.index];i.width>a.largest?(a.largest=i.width,n[a.index]={...o,url:r.url,previewUrl:o.previewUrl??o.url}):i.width<a.smallest&&(a.smallest=i.width,n[a.index]={...o,previewUrl:r.url})}else if(Array.isArray(e))for(let t of e)r(t);else if(typeof e==`object`&&e)for(let t of Object.values(e))r(t)};return r(e),n}var T=0;function E(e){return e===`user`?`user-${globalThis.crypto.randomUUID()}`:(T+=1,`${e}-${String(T)}`)}function de(e,t){return e?.kind===t}function D(e,t,n,r){let i=e.at(-1);de(i,t)?i.text+=n:e.push({id:E(r),kind:t,text:n})}function O(e,t){let n=e.at(-1),r=n?.kind===`text`||n?.kind===`thought`;e.splice(r?e.length-1:e.length,0,t)}function k(e,t){return e.find(e=>e.kind===`tool`&&e.id===t)}function A(e,t){let n=`tool-${t.operationId??t.callId}`,r=k(e,n),i=y(r?.tool,t);if(r){r.tool=i;return}let a=t.phase===void 0?k(e,`tool-${t.callId}`):void 0;a?.tool.draft===void 0?e.push({id:n,kind:`tool`,tool:i}):(a.id=n,a.tool=i)}function j(e,t){let n=`tool-${t.callId}`,r=k(e,n),i=x(r?.tool,t);r?r.tool=i:e.push({id:n,kind:`tool`,tool:i})}function M(e){return e.findLast(e=>e.kind===`structured`&&e.draft!==void 0)}function N(e,t,n){let r=M(e),i=(r?.draft??``)+t;r?(r.draft=i,r.value=v(i)):e.push({id:E(n),kind:`structured`,value:v(i),draft:i})}function P(e,t,n){let r=M(e);r?(r.value=t,delete r.draft):e.push({id:E(n),kind:`structured`,value:t})}function F(e,t){return e.type===t.type?e.placeId&&t.placeId?e.placeId===t.placeId:e.uri===t.uri:!1}function I(e,t,n){let r=e.find(e=>e.kind===`citation`&&e.callId===t.callId),i=r?[...r.sources]:[];for(let e of t.sources)i.some(t=>F(t,e))||i.push(e);r?r.sources=i:e.push({id:E(n),kind:`citation`,sources:i,...t.callId===void 0?{}:{callId:t.callId}})}function L(e,t,n,r){if(t.phase===`complete`&&t.output!==void 0)for(let i of ue(t.output))r.has(i.url)||(r.add(i.url),e.push({id:E(n),kind:`media`,mimeType:i.mimeType,url:i.url,...i.previewUrl?{previewUrl:i.previewUrl}:{}}))}function R(e,t){return e.messages.flatMap(e=>{if(e.role!==`user`)return[];let n=e.parts??[],r=[e.content??``,...n.map(e=>`text`in e?e.text:``)].join(``).trim();return[...r?[{id:E(t),kind:`user-text`,text:r}]:[],...n.flatMap(e=>`text`in e?[]:[{id:E(t),kind:e.type===`audio`?`user-voice`:`user-attachment`,name:e.mimeType,mimeType:e.mimeType,...`data`in e?{sizeBytes:Math.floor(e.data.length*3/4),data:e.data}:{sizeBytes:0}}])]})}function z(e,t=`user`){let n=[],r=e.text?.trim();r&&n.push({id:E(t),kind:`user-text`,text:r});for(let r of e.attachments??[])n.push({id:E(t),kind:`user-attachment`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});for(let r of e.voice??[])n.push({id:E(t),kind:`user-voice`,name:r.name,mimeType:r.mimeType,sizeBytes:r.sizeBytes,...r.data===void 0?{}:{data:r.data}});return n}function B(e,t){switch(e.type){case`media`:return e.media?{id:E(t),kind:`media`,mimeType:e.media.mimeType,data:e.media.data}:void 0;case`grounding`:return{id:E(t),kind:`grounding`,grounding:e.grounding};case`evidence`:return{id:E(t),kind:`evidence`,evidence:e.evidence};case`error`:return e.error?{id:E(t),kind:`error`,message:e.error}:void 0;case`done`:return{id:E(t),kind:`turn-done`,stop:e.stop,tokens:e.tokens,interactionId:e.interactionId,compaction:e.compaction!==void 0};default:return}}function V(t,n={}){let r=n.idPrefix??`turn`,i=n.showThoughts??!0;T=0;let a=[],o=new Set;for(let n of e(t))switch(n.type){case`thought`:i&&n.text&&D(a,`thought`,n.text,r);break;case`text`:n.text&&D(a,`text`,n.text,r);break;case`tool_draft`:j(a,n);break;case`tool`:A(a,n.tool),L(a,n.tool,r,o);break;case`structured_draft`:N(a,n.text,r);break;case`structured`:P(a,n.structured,r);break;case`citation`:I(a,n,r);break;case`guardrail`:O(a,{id:E(r),kind:`guardrail`,guardrail:n.guardrail});break;case`stage`:for(let e of n.injected??[])a.push(...R(e,r));break;default:{let e=B(n,r);e&&a.push(e)}}return a}function H(e,t,n={}){return[...z(e,`user`),...V(t,n)]}function fe(e){if(!e)return i;let{detect:t,patterns:n}=e;if(!n)return t;let r=Object.fromEntries(Object.entries(n).map(([e,{theorem:t}])=>[e,{theorem:t,matchers:[]}]));return{...t,sources:r}}function pe(e,t){if(e.text===void 0)return e;let n=a(e.text,`user`,fe(t));return{...e,text:n.text??e.text}}function U(e,t,n){let r=o(e,t);if(!r.ok)return{ok:!1,issues:r.issues};let i=pe(t,n);return{ok:!0,draft:i,blocks:z(i)}}function W(e,t){if(t)return e.models[t]}function G(e){return!!(e.allowModelSelect&&Object.keys(e.models).length>=2)}function K(e,t){let n=W(e,t);return n?.allowEffortSelect?Object.keys(n.efforts??{}).length>=2:!1}function q(e,t){let n=W(e,t);if(!n?.efforts)return;let r=n.defaultEffort?.trim();return r&&n.efforts[r]?r:Object.keys(n.efforts)[0]}function me(e){return G(e)?Object.entries(e.models).map(([e,t])=>({id:e,label:t.apiId})):[]}function he(e,t){if(!K(e,t))return[];let n=W(e,t);return n?.efforts?Object.entries(n.efforts).map(([e,t])=>({alias:e,level:t})):[]}function ge(e){let t=new Set;for(let n of e)if(n.type===`tool`&&n.tool.phase===`complete`)for(let e of s(n.tool.output)??[])t.add(e);return[...t]}function _e(e){let n=t(e,e=>e.type===`done`&&e.tools!==void 0);return n?.type===`done`?n.tools:void 0}function J(e){return e?.streaming?.streamThoughts!==!1}function Y(e){return e.defaultModel??Object.keys(e.models)[0]}function ve(e,t,n){let r=t.model!==void 0&&Object.hasOwn(e.models,t.model)&&(n===void 0||t.model!==Y(n))?t.model:Y(e),i=r===void 0?void 0:e.models[r]?.efforts;return{model:r,effort:r===t.model&&t.effort!==void 0&&i!==void 0&&Object.hasOwn(i,t.effort)&&(n===void 0||t.effort!==q(n,r))?t.effort:q(e,r)}}function X(e){if(!e.operationId)throw new n(`request`,r(`session.gate_expired`));return e.operationId}function ye(e,t){return t.selectedModel??Y(e)}function be(e,t,n){if(!n||!Object.hasOwn(e.models,n))return;let r=e.models[n];if(r.allowEffortSelect)return t.selectedEffort??r.defaultEffort}function Z(e,t){let n=ye(e,t),r=e.allowModelSelect?n:void 0,i=be(e,t,n);return{...r?{model:r}:{},...i?{effort:i}:{}}}function xe(e,t,n){return{name:n.name,input:n.input,...n.gateKind?{gateKind:n.gateKind}:{},sessionPermissions:n.sessionPermissions??t.sessionPermissions,...t.toolSnapshot?{snapshot:t.toolSnapshot}:{},...t.promotedToolIds.length?{promoted:[...t.promotedToolIds]}:{},...Z(e,t)}}function Q(e){return{...e.conversation?{conversation:e.conversation}:{},...e.turnId?{turnId:e.turnId}:{}}}function Se(e,t,n,r={}){let i=(r.walkAway?.calls??[]).map(e=>({callId:e.callId,operationId:X(e)}));return{...Q(r),...Z(e,t),input:n,...i.length?{abandon:i}:{},replay:{sessionPermissions:t.sessionPermissions}}}function Ce(e,t,n,r={}){return{...Q(r),gateId:n.gateId,operationId:n.operationId,decision:n.decision,...n.secret===void 0?{}:{secret:n.secret},...n.page===void 0?{}:{page:n.page},replay:xe(e,t,{...n,gateKind:n.gateKind??(t.gatedTool?.callId===n.gateId?t.gatedTool.gateKind:void 0)})}}function $(e,t){return U(e.inputs,t,e.guardrails)}function we(e,t,n,r=[]){return $(e,{...t.trim()?{text:t}:{},...n.length?{attachments:c(n)}:{},...r.length?{voice:c(r)}:{}})}function Te(e,t){return V(t,{showThoughts:J(e.outputs)})}export{d as C,f as D,te as E,p as O,ae as S,ne as T,H as _,we as a,C as b,J as c,q as d,K as f,U as g,G as h,X as i,ge as l,me as m,Se as n,$ as o,he as p,Te as r,ve as s,Ce as t,_e as u,V as v,re as w,S as x,y};
@@ -0,0 +1 @@
1
+ import{hr as e}from"./tool-schema-CWGccblZ.js";var t=e.filter(e=>e!==`builtin`),n=`Tool type must be ${t.join(`, `).replace(/, ([^,]+)$/,`, or $1`)}.`;export{n,t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{t as r}from"./VStack-CkVMcNiK.js";import{n as i}from"./StackItem-CQviqAfM.js";import{F as a,U as o,c as s,l as c}from"./browser-transport-eqZ9n2AK.js";import{t as l}from"./Icon-ZfFwTt8n.js";import{t as u}from"./IconButton-CG5klqF1.js";import{t as d}from"./Text-BsiAsowd.js";import{n as f,o as p}from"./labels-provider-Gus3heEH.js";import{n as m}from"./Card-Ghe4ozhC.js";import{t as h}from"./Tooltip-CTEuMRLe.js";import{n as g,t as _}from"./arrive-DvbqpeRS.js";import{d as v}from"./reader-BT_YeHdq.js";import{_ as y,b,g as x,y as S}from"./ConsoleFrame-BpbXMWsq.js";import{c as C,i as w}from"./trace-patterns-CS99kExN.js";import{t as T}from"./CardWall-CBRLdDZW.js";var E=e(n(),1),D=t(),O=`var(--duration-medium) var(--ease-standard)`,k=12;function A(){let e=m();return(0,E.useMemo)(()=>({percent:new Intl.NumberFormat(e,{style:`percent`,maximumFractionDigits:0}),decimal:new Intl.NumberFormat(e,{maximumFractionDigits:2}),usd:new Intl.NumberFormat(e,{style:`currency`,currency:`USD`,maximumSignificantDigits:2})}),[e])}function j(e){return C(e?`clear`:`shade2`)}function M({value:e,isLead:t}){return(0,D.jsx)(`div`,{style:{height:k,width:`${String(Math.max(e,.01)*100)}%`,borderRadius:4,background:j(t),transition:`width ${O}`}})}function N({title:e,aside:t,detail:n,answer:a}){let o=f(),s=A(),c=Object.entries(a.probabilities).sort(([,e],[,t])=>t-e);return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a.choice,note:o(`@theorem.decision.confidence`,{percent:s.percent.format(a.confidence)}),children:(0,D.jsx)(r,{gap:2,role:`list`,children:c.map(([e,t])=>(0,D.jsxs)(r,{gap:1,role:`listitem`,"aria-label":o(`@theorem.decision.option`,{label:e,percent:s.percent.format(t)}),children:[(0,D.jsxs)(i,{gap:2,hAlign:`between`,"aria-hidden":!0,children:[(0,D.jsx)(d,{type:`supporting`,color:`secondary`,maxLines:1,children:e}),(0,D.jsx)(d,{type:`supporting`,hasTabularNumbers:!0,children:s.percent.format(t)})]}),(0,D.jsx)(M,{value:t,isLead:e===a.choice})]},e))})})}var P=56;function F(e){let t=e.split(/[:—–]\s/)[0]?.trim()??``;return t&&t.length<=32&&t!==e?t:e}function I({title:e,aside:t,detail:n,answer:i,labels:a}){let o=f(),s=A(),c=a.length,l=Math.min(c-1,Math.max(0,Math.round(i.score)));return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a[l]===void 0?s.decimal.format(i.score):F(a[l]),note:[o(`@theorem.decision.score_of`,{score:s.decimal.format(i.score),max:s.decimal.format(c-1)}),o(`@theorem.decision.confidence`,{percent:s.percent.format(i.confidence)})].join(` · `),children:(0,D.jsxs)(r,{gap:1,children:[(0,D.jsxs)(`div`,{"aria-hidden":!0,style:{position:`relative`,display:`flex`,alignItems:`flex-end`,gap:4,height:P},children:[a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,height:`${String(Math.max(.04,i.probabilities[String(t)]??0)*100)}%`,borderRadius:4,background:j(t===l),transition:`height ${O}`}},`${String(t)}:${e}`)),(0,D.jsx)(`div`,{style:{position:`absolute`,insetBlock:-4,left:`${String((i.score+.5)/c*100)}%`,width:0,borderInlineStart:`1.5px dashed var(--color-text-secondary)`,transition:`left ${O}`}})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,minWidth:0},title:e,children:(0,D.jsx)(d,{type:`supporting`,color:`secondary`,maxLines:1,children:F(e)})},`${String(t)}:${e}`))}),(0,D.jsx)(`span`,{style:{position:`absolute`,width:1,height:1,overflow:`hidden`,clipPath:`inset(50%)`},children:a.map((e,t)=>o(`@theorem.decision.option`,{label:e,percent:s.percent.format(i.probabilities[String(t)]??0)})).join(`; `)})]})})}function L({title:e,aside:t,detail:n,answer:r}){let i=A();return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:i.decimal.format(r.noul)})}var R=72,z=168;function B(e){let[t,n]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let t=new Image;t.onload=()=>{n({width:t.naturalWidth,height:t.naturalHeight})},t.src=e},[e]),t}function V(e,t){let n=e.style.color;e.style.color=`var(${t})`;let r=getComputedStyle(e).color;return e.style.color=n,r}function H({source:e,box:t,caption:n}){let r=f(),i=S(e),a=B(i),[o,l]=(0,E.useState)(null);if(!a)return null;let u=y(t),d=a.width*(t.right-t.left)/(a.height*(t.bottom-t.top)),p=r(`@theorem.decision.open_box`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(h,{content:p,children:(0,D.jsx)(c,{label:p,padding:0,onClick:e=>{let n={outline:V(e.currentTarget,`--color-accent`),shade:V(e.currentTarget,`--color-overlay`)};b(i,t,n).then(l)},children:(0,D.jsx)(`div`,{role:`img`,"aria-label":r(`@theorem.decision.box_in`),style:{position:`relative`,overflow:`hidden`,aspectRatio:String(d),height:z,maxWidth:`100%`,borderRadius:4},children:(0,D.jsx)(`img`,{src:i,alt:``,style:{position:`absolute`,width:`${String(u.width)}%`,height:`${String(u.height)}%`,left:`${String(u.left)}%`,top:`${String(u.top)}%`,maxWidth:`none`}})})})}),(0,D.jsx)(s,{isOpen:o!==null,onOpenChange:e=>{e||l(null)},media:{src:o??i,alt:r(`@theorem.decision.box_marked`),caption:n},hasZoom:!0})]})}function U({title:e,aside:t,detail:n,answer:r,image:i,asked:a}){let o=f(),s=a&&x(a.images,a.state,i),c=A(),{top:l,bottom:u,left:d,right:p}=r.box,m=o(`@theorem.decision.box_edges`,{left:c.percent.format(d),top:c.percent.format(l),right:c.percent.format(p),bottom:c.percent.format(u)});return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:m,note:o(`@theorem.decision.confidence`,{percent:c.percent.format(r.confidence)}),children:s?(0,D.jsx)(H,{source:s,box:r.box,caption:`${e}: ${m}`}):(0,D.jsx)(`div`,{"aria-hidden":!0,style:{position:`relative`,height:R,borderRadius:4,border:`1px solid var(--color-border)`},children:(0,D.jsx)(`div`,{style:{position:`absolute`,insetInlineStart:`${String(d*100)}%`,insetBlockStart:`${String(l*100)}%`,width:`${String((p-d)*100)}%`,height:`${String((u-l)*100)}%`,borderRadius:2,background:j(!0),transition:`all ${O}`}})})})}function W({question:e,answer:t,asked:n,onQuestion:r,detail:i}){let a=f(),s=`${e.id} · ${a(`@theorem.decision.type.${e.type}`)}`;if(!t)return null;let c=a(`@theorem.decision.edit_question`,{question:e.id}),d={title:s,detail:i,aside:r?(0,D.jsx)(u,{label:c,tooltip:c,size:`sm`,variant:`ghost`,icon:(0,D.jsx)(l,{icon:o,size:`xsm`,color:`secondary`}),onClick:()=>{r(e.id)}}):void 0};return t.type===`choice`?(0,D.jsx)(N,{...d,answer:t}):t.type===`score`?(0,D.jsx)(I,{...d,answer:t,labels:e.labels}):t.type===`noul`?(0,D.jsx)(L,{...d,answer:t}):(0,D.jsx)(U,{...d,answer:t,image:e.image,asked:n})}function G({model:e,usage:t,elapsedMs:n,isStale:i,tokens:a,children:o}){let s=f(),c=A();return(0,D.jsx)(g,{children:(0,D.jsxs)(r,{gap:3,style:{opacity:i?.5:1,transition:`opacity ${O}`},"aria-busy":i,children:[o,(0,D.jsx)(_,{children:(0,D.jsx)(d,{type:`supporting`,color:`secondary`,hasTabularNumbers:!0,children:p(s,c.usd,{model:e,usage:t,elapsedMs:n,tokens:a})})})]},n??0)})}function K({iface:e,result:t,elapsedMs:n,isStale:r,asked:i,onQuestion:a,questionText:o}){let s=f();return(0,D.jsx)(G,{model:t.model,usage:t.usage,elapsedMs:n,isStale:r,tokens:e=>s(`@theorem.decision.tokens`,{count:e}),children:(0,D.jsx)(T,{minWidth:260,children:e.questions.map(e=>(0,D.jsx)(_,{children:(0,D.jsx)(W,{question:e,answer:t.answers[e.id],asked:i,onQuestion:a,detail:o?.[e.id]})},e.id))})})}var q={status:`idle`,result:null,elapsedMs:null,startedAt:null,failure:null};function J(e,t){for(let n of t??[])e.traces?.push(n)}function Y(e,t,n){let[r,i]=(0,E.useState)(q),o=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>o.current?.abort(),[]);let s=(0,E.useCallback)(()=>{o.current?.abort(),o.current=null,i(e=>e.status===t?{...e,status:e.result?`done`:`idle`,startedAt:null}:e)},[t]),c=(0,E.useCallback)(async(...r)=>{o.current?.abort();let s=new AbortController;o.current=s,i(e=>({status:t,result:e.result,elapsedMs:e.elapsedMs,startedAt:Date.now(),failure:null}));let c=performance.now();try{let t=await n(e,s.signal,...r);if(s.signal.aborted)return;J(e,t.traces),i({status:`done`,result:t.result,elapsedMs:performance.now()-c,startedAt:null,failure:null})}catch(t){if(s.signal.aborted)return;J(e,v(t)),i(e=>({...e,status:`error`,startedAt:null,failure:a(t)}))}finally{o.current===s&&(o.current=null)}},[e,t,n]);return{...r,call:c,cancel:s}}export{A as a,K as i,G as n,M as r,Y as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{t as r}from"./VStack-CkVMcNiK.js";import{n as i}from"./StackItem-CQviqAfM.js";import{I as a,W as o,c as s,l as c}from"./browser-transport-BOHBmYvp.js";import{t as l}from"./Icon-BqkS-pIq.js";import{t as u}from"./Text-BOqCfzZC.js";import{n as d,o as f}from"./labels-provider-DkA22zkP.js";import{n as p}from"./Card-DruykyeB.js";import{t as m}from"./IconButton-DVUFx-8p.js";import{t as h}from"./Tooltip-BWs5DLrM.js";import{n as g,t as _}from"./arrive-DvbqpeRS.js";import{d as v}from"./reader-DoTXxl0W.js";import{_ as y,b,g as x,y as S}from"./ConsoleFrame-BTL67qHr.js";import{c as C,i as w}from"./trace-patterns-D6TbkLLr.js";import{t as T}from"./CardWall-CBRLdDZW.js";var E=e(n(),1),D=t(),O=`var(--duration-medium) var(--ease-standard)`,k=12;function A(){let e=p();return(0,E.useMemo)(()=>({percent:new Intl.NumberFormat(e,{style:`percent`,maximumFractionDigits:0}),decimal:new Intl.NumberFormat(e,{maximumFractionDigits:2}),usd:new Intl.NumberFormat(e,{style:`currency`,currency:`USD`,maximumSignificantDigits:2})}),[e])}function j(e){return C(e?`clear`:`shade2`)}function M({value:e,isLead:t}){return(0,D.jsx)(`div`,{style:{height:k,width:`${String(Math.max(e,.01)*100)}%`,borderRadius:4,background:j(t),transition:`width ${O}`}})}function N({title:e,aside:t,detail:n,answer:a}){let o=d(),s=A(),c=Object.entries(a.probabilities).sort(([,e],[,t])=>t-e);return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a.choice,note:o(`@theorem.decision.confidence`,{percent:s.percent.format(a.confidence)}),children:(0,D.jsx)(r,{gap:2,role:`list`,children:c.map(([e,t])=>(0,D.jsxs)(r,{gap:1,role:`listitem`,"aria-label":o(`@theorem.decision.option`,{label:e,percent:s.percent.format(t)}),children:[(0,D.jsxs)(i,{gap:2,hAlign:`between`,"aria-hidden":!0,children:[(0,D.jsx)(u,{type:`supporting`,color:`secondary`,maxLines:1,children:e}),(0,D.jsx)(u,{type:`supporting`,hasTabularNumbers:!0,children:s.percent.format(t)})]}),(0,D.jsx)(M,{value:t,isLead:e===a.choice})]},e))})})}var P=56;function F(e){let t=e.split(/[:—–]\s/)[0]?.trim()??``;return t&&t.length<=32&&t!==e?t:e}function I({title:e,aside:t,detail:n,answer:i,labels:a}){let o=d(),s=A(),c=a.length,l=Math.min(c-1,Math.max(0,Math.round(i.score)));return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:a[l]===void 0?s.decimal.format(i.score):F(a[l]),note:[o(`@theorem.decision.score_of`,{score:s.decimal.format(i.score),max:s.decimal.format(c-1)}),o(`@theorem.decision.confidence`,{percent:s.percent.format(i.confidence)})].join(` · `),children:(0,D.jsxs)(r,{gap:1,children:[(0,D.jsxs)(`div`,{"aria-hidden":!0,style:{position:`relative`,display:`flex`,alignItems:`flex-end`,gap:4,height:P},children:[a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,height:`${String(Math.max(.04,i.probabilities[String(t)]??0)*100)}%`,borderRadius:4,background:j(t===l),transition:`height ${O}`}},`${String(t)}:${e}`)),(0,D.jsx)(`div`,{style:{position:`absolute`,insetBlock:-4,left:`${String((i.score+.5)/c*100)}%`,width:0,borderInlineStart:`1.5px dashed var(--color-text-secondary)`,transition:`left ${O}`}})]}),(0,D.jsx)(`div`,{style:{display:`flex`,gap:4},children:a.map((e,t)=>(0,D.jsx)(`div`,{style:{flex:1,minWidth:0},title:e,children:(0,D.jsx)(u,{type:`supporting`,color:`secondary`,maxLines:1,children:F(e)})},`${String(t)}:${e}`))}),(0,D.jsx)(`span`,{style:{position:`absolute`,width:1,height:1,overflow:`hidden`,clipPath:`inset(50%)`},children:a.map((e,t)=>o(`@theorem.decision.option`,{label:e,percent:s.percent.format(i.probabilities[String(t)]??0)})).join(`; `)})]})})}function L({title:e,aside:t,detail:n,answer:r}){let i=A();return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:i.decimal.format(r.noul)})}var R=72,z=168;function B(e){let[t,n]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let t=new Image;t.onload=()=>{n({width:t.naturalWidth,height:t.naturalHeight})},t.src=e},[e]),t}function V(e,t){let n=e.style.color;e.style.color=`var(${t})`;let r=getComputedStyle(e).color;return e.style.color=n,r}function H({source:e,box:t,caption:n}){let r=d(),i=S(e),a=B(i),[o,l]=(0,E.useState)(null);if(!a)return null;let u=y(t),f=a.width*(t.right-t.left)/(a.height*(t.bottom-t.top)),p=r(`@theorem.decision.open_box`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(h,{content:p,children:(0,D.jsx)(c,{label:p,padding:0,onClick:e=>{let n={outline:V(e.currentTarget,`--color-accent`),shade:V(e.currentTarget,`--color-overlay`)};b(i,t,n).then(l)},children:(0,D.jsx)(`div`,{role:`img`,"aria-label":r(`@theorem.decision.box_in`),style:{position:`relative`,overflow:`hidden`,aspectRatio:String(f),height:z,maxWidth:`100%`,borderRadius:4},children:(0,D.jsx)(`img`,{src:i,alt:``,style:{position:`absolute`,width:`${String(u.width)}%`,height:`${String(u.height)}%`,left:`${String(u.left)}%`,top:`${String(u.top)}%`,maxWidth:`none`}})})})}),(0,D.jsx)(s,{isOpen:o!==null,onOpenChange:e=>{e||l(null)},media:{src:o??i,alt:r(`@theorem.decision.box_marked`),caption:n},hasZoom:!0})]})}function U({title:e,aside:t,detail:n,answer:r,image:i,asked:a}){let o=d(),s=a&&x(a.images,a.state,i),c=A(),{top:l,bottom:u,left:f,right:p}=r.box,m=o(`@theorem.decision.box_edges`,{left:c.percent.format(f),top:c.percent.format(l),right:c.percent.format(p),bottom:c.percent.format(u)});return(0,D.jsx)(w,{title:e,aside:t,detail:n,value:m,note:o(`@theorem.decision.confidence`,{percent:c.percent.format(r.confidence)}),children:s?(0,D.jsx)(H,{source:s,box:r.box,caption:`${e}: ${m}`}):(0,D.jsx)(`div`,{"aria-hidden":!0,style:{position:`relative`,height:R,borderRadius:4,border:`1px solid var(--color-border)`},children:(0,D.jsx)(`div`,{style:{position:`absolute`,insetInlineStart:`${String(f*100)}%`,insetBlockStart:`${String(l*100)}%`,width:`${String((p-f)*100)}%`,height:`${String((u-l)*100)}%`,borderRadius:2,background:j(!0),transition:`all ${O}`}})})})}function W({question:e,answer:t,asked:n,onQuestion:r,detail:i}){let a=d(),s=`${e.id} · ${a(`@theorem.decision.type.${e.type}`)}`;if(!t)return null;let c=a(`@theorem.decision.edit_question`,{question:e.id}),u={title:s,detail:i,aside:r?(0,D.jsx)(m,{label:c,tooltip:c,size:`sm`,variant:`ghost`,icon:(0,D.jsx)(l,{icon:o,size:`xsm`,color:`secondary`}),onClick:()=>{r(e.id)}}):void 0};return t.type===`choice`?(0,D.jsx)(N,{...u,answer:t}):t.type===`score`?(0,D.jsx)(I,{...u,answer:t,labels:e.labels}):t.type===`noul`?(0,D.jsx)(L,{...u,answer:t}):(0,D.jsx)(U,{...u,answer:t,image:e.image,asked:n})}function G({model:e,usage:t,elapsedMs:n,isStale:i,tokens:a,children:o}){let s=d(),c=A();return(0,D.jsx)(g,{children:(0,D.jsxs)(r,{gap:3,style:{opacity:i?.5:1,transition:`opacity ${O}`},"aria-busy":i,children:[o,(0,D.jsx)(_,{children:(0,D.jsx)(u,{type:`supporting`,color:`secondary`,hasTabularNumbers:!0,children:f(s,c.usd,{model:e,usage:t,elapsedMs:n,tokens:a})})})]},n??0)})}function K({iface:e,result:t,elapsedMs:n,isStale:r,asked:i,onQuestion:a,questionText:o}){let s=d();return(0,D.jsx)(G,{model:t.model,usage:t.usage,elapsedMs:n,isStale:r,tokens:e=>s(`@theorem.decision.tokens`,{count:e}),children:(0,D.jsx)(T,{minWidth:260,children:e.questions.map(e=>(0,D.jsx)(_,{children:(0,D.jsx)(W,{question:e,answer:t.answers[e.id],asked:i,onQuestion:a,detail:o?.[e.id]})},e.id))})})}var q={status:`idle`,result:null,elapsedMs:null,startedAt:null,failure:null};function J(e,t){for(let n of t??[])e.traces?.push(n)}function Y(e,t,n){let[r,i]=(0,E.useState)(q),o=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>o.current?.abort(),[]);let s=(0,E.useCallback)(()=>{o.current?.abort(),o.current=null,i(e=>e.status===t?{...e,status:e.result?`done`:`idle`,startedAt:null}:e)},[t]),c=(0,E.useCallback)(async(...r)=>{o.current?.abort();let s=new AbortController;o.current=s,i(e=>({status:t,result:e.result,elapsedMs:e.elapsedMs,startedAt:Date.now(),failure:null}));let c=performance.now();try{let t=await n(e,s.signal,...r);if(s.signal.aborted)return;J(e,t.traces),i({status:`done`,result:t.result,elapsedMs:performance.now()-c,startedAt:null,failure:null})}catch(t){if(s.signal.aborted)return;J(e,v(t)),i(e=>({...e,status:`error`,startedAt:null,failure:a(t)}))}finally{o.current===s&&(o.current=null)}},[e,t,n]);return{...r,call:c,cancel:s}}export{A as a,K as i,G as n,M as r,Y as t};