@yuriai/web 0.2.27-beta.8 → 0.2.28

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 (198) hide show
  1. package/dist/assets/{AgentAvatar-BJ42lGZD.js → AgentAvatar-BybF1ayP.js} +1 -1
  2. package/dist/assets/AssistantContactStatus-BwpxTn0d.js +3 -0
  3. package/dist/assets/{AssistantUnreadBadge-QwhBfXpC.js → AssistantUnreadBadge-DqThZdCe.js} +1 -1
  4. package/dist/assets/{AssistantView-D7ryIKL0.js → AssistantView-DPUDCXoY.js} +1 -1
  5. package/dist/assets/{DiagramView-ERrGEBDp.js → DiagramView-CHVLoYrV.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-Bu2GvaM9.js → FadeInOnReveal-Cj3JXYvE.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-MzQgEZNr.js → GuiPluginSurface-CBZYeKHb.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-DZMmlQzx.js → GuiPluginWindow-_Z5wycnH.js} +1 -1
  9. package/dist/assets/{Icon-Dj4CCqCP.js → Icon-CeRMtJa8.js} +1 -1
  10. package/dist/assets/{ImageLoadingPlaceholder-BnFXgUuO.js → ImageLoadingPlaceholder-DjLaKB4o.js} +1 -1
  11. package/dist/assets/{LoadingImage-PBnivDKv.js → LoadingImage-DG3otL5V.js} +1 -1
  12. package/dist/assets/MarkdownRenderer-C8rv6z7p.js +2 -0
  13. package/dist/assets/{MarkdownRendererImpl-CfyXL4rg.js → MarkdownRendererImpl-_plqOlsV.js} +1 -1
  14. package/dist/assets/{MarkstreamRendererImpl-BGadklK1.js → MarkstreamRendererImpl-bs8HZ4Ra.js} +1 -1
  15. package/dist/assets/{MobileDetailNavigation-DqajQdB4.js → MobileDetailNavigation-SeT764Ps.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-BvdUgwA3.js → MobileResizableSheet-BY1-oo_E.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-3oPoYnry.js → MobileShareBridge-Dw8gLtJD.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-EsrOCLyg.js +2 -0
  19. package/dist/assets/{MultiRunWindow-yhs0Ih5_.js → MultiRunWindow-C-Qw_g7N.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-Bi1VWFQC.js → OnboardingScreen-CGqabMbp.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-BBDwGvGO.js → OverlayScrollbar-AGSWQKg-.js} +1 -1
  22. package/dist/assets/{SettingsView-BSf-SJUA.js → SettingsView-BLfFnnnX.js} +14 -14
  23. package/dist/assets/{SettingsWindow-BvSXVMTm.js → SettingsWindow-lyYO8Byy.js} +1 -1
  24. package/dist/assets/{TerminalView-DhL01N7e.js → TerminalView-OHqpkHzz.js} +1 -1
  25. package/dist/assets/{ToolOutputDialog-C8lnH4Ky.js → ToolOutputDialog-DU4Pb1s0.js} +1 -1
  26. package/dist/assets/{YuriLogo-D8asj1CS.js → YuriLogo-Bb6yHagP.js} +1 -1
  27. package/dist/assets/{appThemeRegistry-C-maYSdv.js → appThemeRegistry-9j-rCSlE.js} +1 -1
  28. package/dist/assets/{button-vXOdzd8x.js → button-Bjh2BSXh.js} +1 -1
  29. package/dist/assets/{capgoAdapter-DJ_h2x5D.js → capgoAdapter-DERfot6h.js} +1 -1
  30. package/dist/assets/{collapsible-DwDQs3Wa.js → collapsible-BEAHoxNi.js} +1 -1
  31. package/dist/assets/{context-menu-BabBujQ-.js → context-menu-BxLcot-3.js} +1 -1
  32. package/dist/assets/device-BcRP6Tjd.js +2 -0
  33. package/dist/assets/{diagram-HwgrQxY5.js → diagram-CXVm2vzI.js} +1 -1
  34. package/dist/assets/{dialog-Dnf626tb.js → dialog-nshKUSE5.js} +1 -1
  35. package/dist/assets/{dropdown-menu.styles-CBc_a-Nv.js → dropdown-menu.styles-M78xpvb2.js} +1 -1
  36. package/dist/assets/{es-BQkO-Odr.js → es-N9ZkQwG9.js} +2 -2
  37. package/dist/assets/fileMentionAutocompleteState-BZJqfgae.js +2 -0
  38. package/dist/assets/{fileMentionTouchSelection-CKPnEetl.js → fileMentionTouchSelection-B9NbPN9D.js} +2 -2
  39. package/dist/assets/{fileReferenceActions-g7KZLi_G.js → fileReferenceActions-CrIAce3K.js} +1 -1
  40. package/dist/assets/{fr-C852roK5.js → fr-CIGqV46N.js} +2 -2
  41. package/dist/assets/{gitApi-CVq5oKCd.js → gitApi-CY3D5CF0.js} +1 -1
  42. package/dist/assets/{gitApiHttp-BYOIbYIh.js → gitApiHttp-B7vYwgBh.js} +4 -4
  43. package/dist/assets/{gui-M_Rbwkyu.js → gui-CJjEj3l4.js} +1 -1
  44. package/dist/assets/host-CnVx34Dh.js +1 -0
  45. package/dist/assets/{image-loading-D5UhMj7Z.js → image-loading-D6kOgU4w.js} +1 -1
  46. package/dist/assets/{input-BtM712b1.js → input-3Re4pmHm.js} +1 -1
  47. package/dist/assets/insertionBoundaries-DK7XYF8d.js +1 -0
  48. package/dist/assets/{ja-BqC39qK6.js → ja-DAhnTq6V.js} +2 -2
  49. package/dist/assets/{ko-BMaChAWh.js → ko-FbMgNKcI.js} +2 -2
  50. package/dist/assets/main-B_THXYMs.js +2 -0
  51. package/dist/assets/main-CpcudEZb.js +169 -0
  52. package/dist/assets/{markdownHeightCache-Bf8iisO4.js → markdownHeightCache-DVWGXtAX.js} +1 -1
  53. package/dist/assets/{mcpQueries-DpXqegX5.js → mcpQueries-CdOYmUdO.js} +1 -1
  54. package/dist/assets/miniChat-DxZiTnAZ.js +2 -0
  55. package/dist/assets/mobile-BJuATiaC.js +2 -0
  56. package/dist/assets/{mobileBackNavigation-DZcI7aZg.js → mobileBackNavigation-CgZndzFA.js} +1 -1
  57. package/dist/assets/{multirun-hzspPepd.js → multirun-BlaYsQi2.js} +1 -1
  58. package/dist/assets/{native-H7K64Ulc.js → native-BYMhr-xH.js} +1 -1
  59. package/dist/assets/{native-config-CddZtLQ1.js → native-config-BpsFKLGl.js} +1 -1
  60. package/dist/assets/{persistence-BT8045Ue.js → persistence-CWuLIq1J.js} +2 -2
  61. package/dist/assets/{pl-Ubs8p28T.js → pl-DzX0cbiQ.js} +2 -2
  62. package/dist/assets/{projectMeta-CEf0QPmD.js → projectMeta-CnXHTolN.js} +1 -1
  63. package/dist/assets/{pt-BR-8rAOjJrs.js → pt-BR-C5yvwyDK.js} +2 -2
  64. package/dist/assets/queue-abort-optimistic-DCLBpirg.js +1 -0
  65. package/dist/assets/{readiness-Dyr7314z.js → readiness-U16Qor79.js} +1 -1
  66. package/dist/assets/renderElectronMiniChatApp-n-nhgy1V.js +2 -0
  67. package/dist/assets/renderMobileApp-DBj_7RlD.js +28 -0
  68. package/dist/assets/{runtimeConfig-B8VHHNxj.js → runtimeConfig-BBgkLVr_.js} +1 -1
  69. package/dist/assets/runtimeEndpointReset-BvSQVFfx.js +149 -0
  70. package/dist/assets/{scheduledTaskNavigation-Zm87Nydi.js → scheduledTaskNavigation-EomDNVu2.js} +1 -1
  71. package/dist/assets/sessionLookup-C_CCp7MJ.js +1 -0
  72. package/dist/assets/{sortable-tabs-strip-D4pVoodN.js → sortable-tabs-strip-p16Pn6Zz.js} +1 -1
  73. package/dist/assets/{speechSettingsQueries-RlCLMBtr.js → speechSettingsQueries-CBSEAKyj.js} +2 -2
  74. package/dist/assets/src-u-YDfCVw.css +2 -0
  75. package/dist/assets/{store-ME7oHni1.js → store-DVfZQktm.js} +4 -3
  76. package/dist/assets/{terminalApi-BSaclMDJ.js → terminalApi-rl9mZAlB.js} +1 -1
  77. package/dist/assets/{textarea-B98rsLs7.js → textarea-C6VQ7dHH.js} +1 -1
  78. package/dist/assets/{tooltip-B9810jbK.js → tooltip-Dnc6GA-X.js} +1 -1
  79. package/dist/assets/types-DnZw0gLD.js +2 -0
  80. package/dist/assets/{uk-LzwzUApL.js → uk-zbDcUpBy.js} +2 -2
  81. package/dist/assets/{useAppFontEffects-D2C1sBYM.js → useAppFontEffects-CEgDiZHu.js} +49 -49
  82. package/dist/assets/{useAssistantUIStore-TUN_ycy5.js → useAssistantUIStore-CfaQV3ID.js} +1 -1
  83. package/dist/assets/useDesktopWindowControlsLayout-B2o4IFmd.js +1 -0
  84. package/dist/assets/useEffectiveDirectory-BOYMJ6k7.js +1 -0
  85. package/dist/assets/{useFontPreferences-BlhlCJCX.js → useFontPreferences-DeqW9nRx.js} +1 -1
  86. package/dist/assets/useMobileNavigationStore-DlvrZQ49.js +17 -0
  87. package/dist/assets/{useUIStore-DRx6OgCp.js → useUIStore-C6CE42oh.js} +1 -1
  88. package/dist/assets/{useWorkerHighlightedLines-D093jNsH.js → useWorkerHighlightedLines-EcJThS4x.js} +1 -1
  89. package/dist/assets/{vendor-effect-DV9F8PTZ.js → vendor-effect-X1Hqc7ba.js} +13 -13
  90. package/dist/assets/vendor-opencode-client-cQ47ywrT.js +23 -0
  91. package/dist/assets/{vendor-opencode-plugin-BBOP6WNx.js → vendor-opencode-plugin-BmdTE4Te.js} +1 -1
  92. package/dist/assets/vendor-opencode-schema-DWT45VBX.js +1 -0
  93. package/dist/assets/vendor-solid-js-D98iXT7C.js +1 -0
  94. package/dist/assets/vendor-zod-DZzbCm1s.js +55 -0
  95. package/dist/assets/{zh-CN-D-FVCeks.js → zh-CN-BHRJ7CF3.js} +2 -2
  96. package/dist/assets/{zh-TW-B9iH_NXL.js → zh-TW-BFI_YFd-.js} +2 -2
  97. package/dist/index.html +12 -12
  98. package/dist/mini-chat.html +12 -12
  99. package/dist/mobile.html +12 -12
  100. package/package.json +1 -1
  101. package/server/index.js +2 -145
  102. package/server/lib/assistants/DOCUMENTATION.md +63 -10
  103. package/server/lib/assistants/cards.js +1 -1
  104. package/server/lib/assistants/channel-image.js +92 -0
  105. package/server/lib/assistants/channel-image.test.js +76 -0
  106. package/server/lib/assistants/channel-output-store.test.js +41 -0
  107. package/server/lib/assistants/channel-output.integration.test.js +128 -0
  108. package/server/lib/assistants/channel-output.js +90 -0
  109. package/server/lib/assistants/channel-output.test.js +79 -0
  110. package/server/lib/assistants/channels/DOCUMENTATION.md +52 -14
  111. package/server/lib/assistants/channels/PROTOCOLS.md +23 -1
  112. package/server/lib/assistants/channels/dingtalk-chat-adapter.js +19 -7
  113. package/server/lib/assistants/channels/dingtalk-chat-adapter.test.js +8 -0
  114. package/server/lib/assistants/channels/routes.js +12 -0
  115. package/server/lib/assistants/channels/routes.test.js +34 -0
  116. package/server/lib/assistants/channels/runtime.js +117 -26
  117. package/server/lib/assistants/channels/runtime.test.js +179 -5
  118. package/server/lib/assistants/channels/sdk-adapters.js +15 -3
  119. package/server/lib/assistants/channels/sdk-adapters.test.js +17 -0
  120. package/server/lib/assistants/channels/store.js +9 -6
  121. package/server/lib/assistants/channels/store.test.js +21 -11
  122. package/server/lib/assistants/channels/transport.js +2 -1
  123. package/server/lib/assistants/channels/wecom-chat-adapter.js +16 -2
  124. package/server/lib/assistants/channels/wecom-chat-adapter.test.js +21 -0
  125. package/server/lib/assistants/contact-store.js +9 -3
  126. package/server/lib/assistants/contact-store.test.js +27 -0
  127. package/server/lib/assistants/contact-tools.js +65 -75
  128. package/server/lib/assistants/contact-tools.test.js +114 -22
  129. package/server/lib/assistants/harness.js +80 -34
  130. package/server/lib/assistants/harness.test.js +68 -20
  131. package/server/lib/assistants/resource-reference.integration.test.js +284 -0
  132. package/server/lib/assistants/routes.js +0 -3
  133. package/server/lib/assistants/service.js +116 -69
  134. package/server/lib/assistants/service.test.js +31 -17
  135. package/server/lib/assistants/weixin/DOCUMENTATION.md +34 -9
  136. package/server/lib/assistants/weixin/api.js +43 -1
  137. package/server/lib/assistants/weixin/api.test.js +28 -0
  138. package/server/lib/assistants/weixin/chat-adapter.js +8 -2
  139. package/server/lib/assistants/weixin/inbound.js +5 -3
  140. package/server/lib/assistants/weixin/inbound.test.js +20 -0
  141. package/server/lib/assistants/weixin/runtime.js +27 -18
  142. package/server/lib/assistants/weixin/runtime.test.js +36 -0
  143. package/server/lib/assistants/weixin/store.js +8 -4
  144. package/server/lib/assistants/weixin/store.test.js +21 -0
  145. package/server/lib/assistants/yuri-project.http.test.js +9 -3
  146. package/server/lib/notifications/DOCUMENTATION.md +6 -0
  147. package/server/lib/notifications/runtime.js +26 -15
  148. package/server/lib/notifications/runtime.test.js +14 -13
  149. package/server/lib/opencode/DOCUMENTATION.md +9 -0
  150. package/server/lib/opencode/auth.d.ts +6 -2
  151. package/server/lib/opencode/core-routes.js +0 -1
  152. package/server/lib/opencode/feature-routes-runtime.js +0 -24
  153. package/server/lib/opencode/location-release.d.ts +5 -1
  154. package/server/lib/opencode/managed-capabilities/scheduled-task.js +1 -1
  155. package/server/lib/opencode/managed-capabilities-runtime.test.js +1 -1
  156. package/server/lib/opencode/native-goal.js +15 -0
  157. package/server/lib/opencode/native-goal.test.js +17 -0
  158. package/server/lib/opencode/settings-helpers.js +0 -6
  159. package/server/lib/opencode/shutdown-runtime.js +0 -2
  160. package/server/lib/projects/project-config.js +3 -6
  161. package/server/lib/scheduled-tasks/DOCUMENTATION.md +10 -35
  162. package/server/lib/scheduled-tasks/managed-tool-route.js +1 -30
  163. package/server/lib/scheduled-tasks/routes.js +0 -26
  164. package/server/lib/scheduled-tasks/runtime.js +33 -257
  165. package/server/lib/scheduled-tasks/runtime.test.js +24 -65
  166. package/server/lib/session-metadata/DOCUMENTATION.md +9 -12
  167. package/server/lib/session-metadata/routes.js +4 -38
  168. package/server/lib/session-metadata/routes.test.js +2 -2
  169. package/dist/assets/AssistantContactStatus-dtkObamV.js +0 -3
  170. package/dist/assets/MarkdownRenderer-BajF4gUU.js +0 -2
  171. package/dist/assets/MobileTabPageHeader-B6cRyIRH.js +0 -2
  172. package/dist/assets/device-BjRYYXNT.js +0 -2
  173. package/dist/assets/host-BW3FEJdU.js +0 -1
  174. package/dist/assets/insertionBoundaries-Dx3WAY6i.js +0 -1
  175. package/dist/assets/main-9uP2z1qT.js +0 -2
  176. package/dist/assets/main-Mey7bCWf.js +0 -169
  177. package/dist/assets/miniChat-DqZvVkme.js +0 -2
  178. package/dist/assets/mobile-DXAWjYcN.js +0 -2
  179. package/dist/assets/renderElectronMiniChatApp-DoOq8Cuo.js +0 -2
  180. package/dist/assets/renderMobileApp-TTxtOb8b.js +0 -28
  181. package/dist/assets/runtimeEndpointReset-BC6XWntz.js +0 -149
  182. package/dist/assets/sessionLookup-De53jDwM.js +0 -1
  183. package/dist/assets/src-lE4uqaHS.css +0 -2
  184. package/dist/assets/types-DFf9vd1b.js +0 -2
  185. package/dist/assets/useDesktopWindowControlsLayout-BjKaHN0x.js +0 -1
  186. package/dist/assets/useEffectiveDirectory-TEvyiQSC.js +0 -1
  187. package/dist/assets/useMobileNavigationStore-DTvJV9s-.js +0 -23
  188. package/dist/assets/vendor-opencode-client-ZeOZ4Efz.js +0 -23
  189. package/dist/assets/vendor-solid-js-9wmPZH9g.js +0 -1
  190. package/dist/assets/vendor-zod-Dzk5kdUU.js +0 -39
  191. package/server/lib/session-goal/DOCUMENTATION.md +0 -371
  192. package/server/lib/session-goal/capability.js +0 -57
  193. package/server/lib/session-goal/capability.test.js +0 -33
  194. package/server/lib/session-goal/objectives.js +0 -61
  195. package/server/lib/session-goal/routes.js +0 -274
  196. package/server/lib/session-goal/routes.test.js +0 -211
  197. package/server/lib/session-goal/runtime.js +0 -2452
  198. package/server/lib/session-goal/runtime.test.js +0 -2125
@@ -0,0 +1,23 @@
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$t as n,A as r,At as i,B as a,Bt as o,C as s,Ct as c,D as l,Dt as u,E as d,Et as f,F as p,Ft as ee,G as te,Gt as ne,H as m,Ht as re,I as ie,It as ae,J as oe,Jt as se,K as ce,Kt as le,L as ue,M as de,Mt as fe,N as h,Nt as pe,O as me,Ot as he,P as g,Pt as _,Q as ge,Qt as _e,R as ve,Rt as ye,S as be,St as xe,T as Se,Tt as Ce,U as v,Ut as we,V as Te,Vt as Ee,W as De,Wt as Oe,X as y,Xt as ke,Y as b,Yt as Ae,Z as x,Zt as je,_ as Me,_n as Ne,a as Pe,an as Fe,at as Ie,b as Le,bn as Re,bt as ze,c as Be,cn as Ve,ct as He,d as S,dn as Ue,dt as We,en as Ge,et as Ke,f as qe,fn as Je,g as Ye,gn as Xe,gt as Ze,h as Qe,hn as $e,ht as et,i as tt,in as nt,it as C,j as rt,jt as w,k as it,kt as at,l as T,ln as E,lt as ot,m as st,mn as ct,n as lt,nn as ut,nt as dt,o as ft,on as pt,ot as D,p as mt,pn as ht,q as gt,qt as _t,r as O,rn as vt,rt as yt,s as k,sn as bt,st as A,t as j,tn as xt,tt as St,u as Ct,un as M,ut as wt,v as Tt,vn as Et,vt as Dt,w as Ot,wt as kt,x as At,xn as jt,xt as Mt,yn as Nt,yt as Pt,z as N,zt as Ft}from"./vendor-effect-X1Hqc7ba.js";var It=Object.defineProperty,Lt=e=>e;function Rt(e,t){this[e]=Lt.bind(null,t)}var zt=(e,t)=>{for(var n in t)It(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Rt.bind(t,n)})},Bt={};zt(Bt,{SharedEvents:()=>Bt,make:()=>Vt});function Vt(e){let t,n=4096;function r(e){e.connected=void 0,e.controller.abort(),t===e&&(t=void 0)}async function i(t){let n,i={};try{if(t.controller.signal.aborted)return;for(n=e(t.controller.signal,()=>{t.subscribers.forEach(e=>e.activity?.())})[Symbol.asyncIterator]();!t.controller.signal.aborted;){let e=await n.next();if(e.done||t.controller.signal.aborted)break;e.value.type===`server.connected`&&(t.connected=e.value),t.subscribers.forEach(t=>t.push(e.value))}}catch(e){i={error:e}}finally{r(t);try{await n?.return?.()}catch(e){`error`in i||(i={error:e})}t.subscribers.forEach(e=>e.finish(i))}}return{subscribe(e){return{[Symbol.asyncIterator](){let a=[],o=[],s=!1,c,l,u=e?.types?.length?new Set(e.types):void 0,d=e=>!u||e.type===`server.connected`||u.has(e.type);function f(t,n=!0){c=t,n&&(o.length=0),e?.signal?.removeEventListener(`abort`,p),l?.subscribers.delete(ee)&&!l.subscribers.size&&r(l),a.splice(0).forEach(e=>{`error`in t?e.reject(t.error):e.resolve({done:!0,value:void 0})})}function p(){f({})}let ee={activity:e?.onActivity,finish(e){f(e,!1)},push(e){if(c||!d(e))return;let t=a.shift();if(t){t.resolve({done:!1,value:e});return}if(o.length===n){f({error:Error(`Event subscriber exceeded its ${n}-event capacity`)});return}o.push(e)}};function te(){if(c)return;let e=!t;l=t??{controller:new AbortController,subscribers:new Set},t=l,l.subscribers.add(ee),l.connected&&ee.push(l.connected),e&&i(l)}return{next(){let t=o.shift();if(t)return Promise.resolve({done:!1,value:t});if(c)return`error`in c?Promise.reject(c.error):Promise.resolve({done:!0,value:void 0});if(e?.signal?.aborted)return p(),Promise.resolve({done:!0,value:void 0});let n=Promise.withResolvers();return a.push(n),s||(s=!0,e?.signal?.addEventListener(`abort`,p,{once:!0}),te()),n.promise},return(){return f({}),Promise.resolve({done:!0,value:void 0})}}}}}}}var Ht=class extends Error{reason;name=`ClientError`;constructor(e,t){let n=t?.detail??(t?.cause instanceof Error?t.cause.message:void 0);super(n?`${e}: ${n}`:e,t),this.reason=e}};zt({},{make:()=>Wt});var Ut=16777216;function Wt(e){let t=e.fetch??globalThis.fetch,n=(t,n)=>{let r=new URL(e.baseUrl);r.pathname.endsWith(`/`)||(r.pathname+=`/`);let i=new URL(t.path.slice(1),r);for(let[e,n]of Object.entries(t.query??{}))Kt(i.searchParams,e,n);let a=new Headers(e.headers);for(let[e,n]of Object.entries(t.headers??{}))n!=null&&a.set(e,String(n));for(let[e,t]of new Headers(n?.headers))a.set(e,t);return t.body!==void 0&&!a.has(`content-type`)&&a.set(`content-type`,t.binaryBody?`application/octet-stream`:`application/json`),{url:i,init:{method:t.method,signal:n?.signal,headers:a,body:t.body===void 0?void 0:t.binaryBody?t.body:JSON.stringify(t.body)}}},r=async(e,r)=>{try{let i=n(e,r);return await t(i.url,i.init)}catch(e){throw new Ht(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw Jt(await qt(e));try{await e.body?.cancel()}catch{}throw new Ht(`UnexpectedStatus`,{cause:{status:e.status},detail:String(e.status)})},a=async(e,t)=>{let n=await r(e,t);if(n.status!==e.successStatus)return i(n,e);if(e.binary)return new Uint8Array(await n.arrayBuffer());if(e.empty){try{await n.body?.cancel()}catch{}return}return await qt(n)},o=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!Yt(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new Ht(`UnsupportedContentType`,{detail:n.headers.get(`content-type`)})}if(n.body===null)throw new Ht(`MalformedResponse`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new Ht(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),s+=o.decode(e.value,{stream:!e.done}),s.length>Ut)throw new Ht(`SseEventTooLarge`);let n=!e.done&&s.endsWith(`\r`);n&&(s=s.slice(0,-1)),s=s.replaceAll(`\r
2
+ `,`
3
+ `).replaceAll(`\r`,`
4
+ `),n&&(s+=`\r`),e.done&&s!==``&&(s+=`
5
+
6
+ `);let r=s.indexOf(`
7
+
8
+ `);for(;r>=0;){let e=s.slice(0,r);s=s.slice(r+2);let t=e.split(`
9
+ `).flatMap(e=>e.startsWith(`data:`)?[e.slice(5).trimStart()]:[]).join(`
10
+ `);if(t!==``)try{yield JSON.parse(t)}catch(e){throw new Ht(`MalformedResponse`,{cause:e})}r=s.indexOf(`
11
+
12
+ `)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}}),s={server:{info:e=>a({method:`GET`,path:`/api/info`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),pair:e=>a({method:`POST`,path:`/api/pair`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),connect:(e,t)=>a({method:`GET`,path:`/auth/connect/${encodeURIComponent(e.code)}`,successStatus:200,declaredStatuses:[400,401],empty:!1},t)},location:{get:(e,t)=>a({method:`GET`,path:`/api/location`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),reload:e=>a({method:`POST`,path:`/api/location/reload`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e)},agent:{list:(e,t)=>a({method:`GET`,path:`/api/agent`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},plugin:{list:(e,t)=>a({method:`GET`,path:`/api/plugin`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),gui:(e,t)=>a({method:`GET`,path:`/api/plugin/gui`,query:{location:e.location,id:e.id},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),check:(e,t)=>a({method:`POST`,path:`/api/plugin/check`,query:{location:e?.location},body:{target:e?.target},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`POST`,path:`/api/plugin/update`,query:{location:e.location},body:{targets:e.targets},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t)},session:{list:(e,t)=>a({method:`GET`,path:`/api/session`,query:{limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,archived:e?.archived,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/session`,body:{id:e?.id,parentID:e?.parentID,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,metadata:e?.metadata,permissions:e?.permissions},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),active:e=>a({method:`GET`,path:`/api/session/active`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),fork:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{before:e.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),switchAgent:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),switchModel:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,body:{title:e.title,metadata:e.metadata,permissions:e.permissions,archived:e.archived},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),move:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),prompt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,skills:e.skills,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),command:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{name:e.name,text:e.text,files:e.files,agents:e.agents,skills:e.skills,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},t),synthetic:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),shell:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),compact:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id,delivery:e.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),revert:{stage:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},t).then(e=>e.data),clear:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},t),commit:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},context:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),diff:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/diff`,query:{from:e.from,to:e.to,context:e.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),inbox:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,body:{delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},generate:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),interrupt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,query:{resume:e.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),background:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),message:{get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data)},form:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,query:{message:e.message},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},environment:(e,t)=>a({method:`PUT`,path:`/api/session/${encodeURIComponent(e.sessionID)}/environment`,body:{variables:e.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),view:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/view`,body:{idle:e.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},experimental:{session:{stats:(e,t)=>a({method:`GET`,path:`/api/experimental/session/stats`,query:{from:e?.from,to:e?.to,project:e?.project,timezone:e?.timezone,tools:e?.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),import:(e,t)=>a({method:`POST`,path:`/api/experimental/session/import`,body:{info:e.info,messages:e.messages,location:e.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),export:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/export`,query:{sanitize:e.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),skill:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,resume:e.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),instructions:{entry:{list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),put:(e,t)=>a({method:`PUT`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},log:(e,t)=>o({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},generate:{text:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/text`,body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),image:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/image`,body:{model:e.model,prompt:e.prompt,images:e.images,n:e.n,aspect:e.aspect,resolution:e.resolution},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),decisions:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/decisions`,body:{model:e.model,input:e.input,questions:e.questions},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data)},voice:{models:e=>a({method:`GET`,path:`/api/experimental/voice/models`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},e).then(e=>e.data),session:(e,t)=>a({method:`POST`,path:`/api/experimental/voice/session`,body:{model:e.model,session:e.session,transport:e.transport},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data)},integration:{wellknown:{add:(e,t)=>a({method:`POST`,path:`/api/experimental/integration/wellknown`,query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},mcp:{add:(e,t)=>a({method:`PUT`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),disconnect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),client:{token:(e,t)=>a({method:`POST`,path:`/api/experimental/client-mcp/token`,query:{location:e.location,name:e.name},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},file:{write:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/write`,query:{location:e.location,path:e.path},body:e.payload,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binaryBody:!0},t),watch:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),unwatch:(e,t)=>a({method:`DELETE`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},persistentPty:{read:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal/read`,query:{lines:e.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,body:{command:e.command,args:e.args,cwd:e.cwd,title:e.title,env:e.env,size:e.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),shutdown:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/shutdown`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e),handoff:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/handoff`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},e),get:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PUT`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,body:{attachmentID:e.attachmentID,size:e.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),snapshot:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),connectToken:(e,t)=>a({method:`POST`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/connect-token`,headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},t).then(e=>e.data)},media:{get:(e,t)=>a({method:`GET`,path:`/api/experimental/media/${encodeURIComponent(e.hash)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t)},schedule:{create:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule`,body:{sessionID:e.sessionID,name:e.name,when:e.when,ends:e.ends,prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/schedule`,query:{sessionID:e.sessionID},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),pause:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}/pause`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),resume:(e,t)=>a({method:`POST`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}/resume`,successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t).then(e=>e.data),delete:(e,t)=>a({method:`DELETE`,path:`/api/experimental/schedule/${encodeURIComponent(e.scheduleID)}`,successStatus:204,declaredStatuses:[400,401,403,404],empty:!0},t)},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},usage:{limits:(e,t)=>a({method:`GET`,path:`/api/experimental/usage/limits`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},config:{update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},message:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor,type:e.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},model:{list:(e,t)=>a({method:`GET`,path:`/api/model`,query:{location:e?.location,types:e?.types},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),default:(e,t)=>a({method:`GET`,path:`/api/model/default`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},provider:{list:(e,t)=>a({method:`GET`,path:`/api/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},integration:{list:(e,t)=>a({method:`GET`,path:`/api/integration`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),connect:{key:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),external:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/external`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},oauth:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),complete:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},mcp:{list:(e,t)=>a({method:`GET`,path:`/api/mcp`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)}},credential:{list:e=>a({method:`GET`,path:`/api/credential`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/credential`,body:{id:e.id,integrationID:e.integrationID,label:e.label,value:e.value,activate:e.activate},successStatus:200,declaredStatuses:[400,401,409],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,body:{label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},t),activate:(e,t)=>a({method:`POST`,path:`/api/credential/${encodeURIComponent(e.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},project:{list:(e,t)=>a({method:`GET`,path:`/api/project`,query:{archived:e?.archived},successStatus:200,declaredStatuses:[400,401],empty:!1},t),update:(e,t)=>a({method:`PATCH`,path:`/api/project/${encodeURIComponent(e.projectID)}`,body:{canonical:e.canonical,name:e.name,icon:e.icon,commands:e.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},form:{list:(e,t)=>a({method:`GET`,path:`/api/form`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},permission:{request:{list:(e,t)=>a({method:`GET`,path:`/api/permission/request`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},saved:{list:(e,t)=>a({method:`GET`,path:`/api/permission/saved`,query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,body:{action:e.action,resource:e.resource},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{decision:e.decision,message:e.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},file:{read:(e,t)=>a({method:`GET`,path:`/api/fs/read/${Gt(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t),list:(e,t)=>a({method:`GET`,path:`/api/fs/list`,query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),find:(e,t)=>a({method:`GET`,path:`/api/fs/find`,query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},command:{list:(e,t)=>a({method:`GET`,path:`/api/command`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},skill:{list:(e,t)=>a({method:`GET`,path:`/api/skill`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},rpc:{call:(e,t)=>a({method:`POST`,path:`/api/rpc/${encodeURIComponent(e.rpcID)}/${encodeURIComponent(e.method)}`,query:{location:e.location},body:{input:e.input},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},event:{subscribe:(e,t)=>o({method:`GET`,path:`/api/event`,query:{types:e?.types},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},pty:{list:(e,t)=>a({method:`GET`,path:`/api/pty`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/pty`,query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`PUT`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:{token:(e,t)=>a({method:`POST`,path:`/api/pty/${encodeURIComponent(e.ptyID)}/connect-token`,query:{location:e.location},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},shell:{list:(e,t)=>a({method:`GET`,path:`/api/shell`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/shell`,query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),output:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},reference:{list:(e,t)=>a({method:`GET`,path:`/api/reference`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},worktree:{list:(e,t)=>a({method:`GET`,path:`/api/worktree`,query:{projectID:e.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/worktree`,body:{projectID:e.projectID,from:e.from,branch:e.branch,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/worktree`,body:{projectID:e.projectID,directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),refresh:(e,t)=>a({method:`POST`,path:`/api/worktree/refresh`,body:{projectID:e.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},vcs:{init:(e,t)=>a({method:`POST`,path:`/api/vcs/init`,query:{location:e?.location,provider:e?.provider},successStatus:204,declaredStatuses:[400,401,404,409,501,503],empty:!0},t),get:(e,t)=>a({method:`GET`,path:`/api/vcs`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),base:(e,t)=>a({method:`GET`,path:`/api/vcs/base`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/vcs/status`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),branch:{list:(e,t)=>a({method:`GET`,path:`/api/vcs/branch`,query:{location:e?.location,search:e?.search,limit:e?.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},diff:(e,t)=>a({method:`GET`,path:`/api/vcs/diff`,query:{location:e.location,mode:e.mode,base:e.base,context:e.context,untracked:e.untracked},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},debug:{heapDump:(e,t)=>a({method:`POST`,path:`/api/debug/heap-dump`,query:{directory:e?.directory},successStatus:200,declaredStatuses:[400,401,500],empty:!1},t),location:{list:e=>a({method:`GET`,path:`/api/debug/location`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),evict:(e,t)=>a({method:`DELETE`,path:`/api/debug/location`,query:{location:e?.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}},websearch:{providers:(e,t)=>a({method:`GET`,path:`/api/websearch/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),query:(e,t)=>a({method:`POST`,path:`/api/websearch`,query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},config:{get:(e,t)=>a({method:`GET`,path:`/api/config`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),shells:e=>a({method:`GET`,path:`/api/config/shell`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},e)}};return{...s,session:{...s.session,stats:s.experimental.session.stats,import:s.experimental.session.import,export:s.experimental.session.export,skill:s.experimental.session.skill,wait:s.experimental.session.wait,instructions:{entry:{list:s.experimental.session.instructions.entry.list,put:s.experimental.session.instructions.entry.put,remove:s.experimental.session.instructions.entry.remove}},log:s.experimental.session.log},generate:{text:s.experimental.generate.text,image:s.experimental.generate.image,decisions:s.experimental.generate.decisions},voice:{models:s.experimental.voice.models,session:s.experimental.voice.session},integration:{...s.integration,wellknown:{add:s.experimental.integration.wellknown.add}},mcp:{...s.mcp,add:s.experimental.mcp.add,remove:s.experimental.mcp.remove,connect:s.experimental.mcp.connect,disconnect:s.experimental.mcp.disconnect,client:{token:s.experimental.mcp.client.token}},file:{...s.file,write:s.experimental.file.write,watch:s.experimental.file.watch,unwatch:s.experimental.file.unwatch},migration:{v1:{status:s.experimental.migration.v1.status}},usage:{limits:s.experimental.usage.limits},config:{...s.config,update:s.experimental.config.update}}}function Gt(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Kt(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)Kt(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))Kt(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function qt(e){if(!Yt(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new Ht(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new Ht(`Transport`,{cause:e})}if(t===``)throw new Ht(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new Ht(`MalformedResponse`,{cause:e})}}function Jt(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function Yt(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var Xt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,Zt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Qt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,$t=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`;function en(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=tn(n,e);return{[Symbol.asyncIterator](){let e=new AbortController,n=r?.signal?AbortSignal.any([e.signal,r.signal]):e.signal,a=async function*(){try{for await(let e of t.subscribe({signal:n})){if(n.aborted)return;e.type===i&&(yield e)}}catch(e){if(!n.aborted)throw e}finally{e.abort()}}();return{next:()=>a.next(),return:()=>(e.abort(),a.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(t=>[t,async(r,i)=>{try{return(await e.rpc.call({rpcID:n.id,method:t,input:r,location:i?.location},{signal:i?.signal,headers:i?.headers})).output}catch(e){throw!Qt(e)&&!$t(e)?e:e.data===void 0?{type:e.type,message:e.message}:{type:e.type,message:e.message,data:e.data}}}])),{events:{subscribe:r,on:(e,t,n)=>{let i=new AbortController,a=n?.signal?AbortSignal.any([i.signal,n.signal]):i.signal,o=r(e,{signal:a});return(async()=>{for await(let e of o)await t(e)})().catch(e=>console.error(e)),()=>i.abort()}}})}}function tn(e,t){return`rpc.${e.id}.${t}`}var nn={};zt(nn,{OpenCode:()=>nn,make:()=>rn});function rn(e){let t=Wt(e),n=Vt((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(en(t,n),t.rpc),event:n}}var an=e({$DEVCOMP:()=>Mn,$PROXY:()=>kn,$TRACK:()=>jn,DEV:()=>void 0,ErrorBoundary:()=>_i,For:()=>ui,Index:()=>di,Match:()=>mi,Show:()=>fi,Suspense:()=>xi,SuspenseList:()=>bi,Switch:()=>pi,batch:()=>nr,cancelCallback:()=>Sn,catchError:()=>sr,children:()=>yr,createComponent:()=>$r,createComputed:()=>qn,createContext:()=>_r,createDeferred:()=>er,createEffect:()=>Yn,createMemo:()=>Zn,createReaction:()=>Xn,createRenderEffect:()=>Jn,createResource:()=>$n,createRoot:()=>Gn,createSelector:()=>tr,createSignal:()=>Kn,createUniqueId:()=>ci,enableExternalSource:()=>Sr,enableHydration:()=>Qr,enableScheduling:()=>dr,equalFn:()=>On,from:()=>Kr,getListener:()=>cr,getOwner:()=>lr,indexArray:()=>Xr,lazy:()=>oi,mapArray:()=>Yr,mergeProps:()=>ii,observable:()=>Gr,on:()=>ir,onCleanup:()=>or,onError:()=>Ur,onMount:()=>ar,requestCallback:()=>xn,resetErrorBoundaries:()=>gi,runWithOwner:()=>ur,sharedConfig:()=>P,splitProps:()=>ai,startTransition:()=>fr,untrack:()=>rr,useContext:()=>vr,useTransition:()=>hr}),on=1,sn=!1,cn=!1,ln=[],un=null,dn=null,fn=5,pn=0,mn=300,hn=0,gn=null,_n=null,vn=1073741823;function yn(){let e=new MessageChannel,t=e.port1,n=e.port2;if(typeof t.unref==`function`&&t.unref(),typeof n.unref==`function`&&n.unref(),gn=()=>n.postMessage(null),t.onmessage=()=>{if(_n!==null){let e=performance.now();pn=e+fn,hn=e+mn;try{_n(e)?n.postMessage(null):_n=null}catch(e){throw n.postMessage(null),e}}},navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){let e=navigator.scheduling;dn=()=>{let t=performance.now();return t>=pn?e.isInputPending()?!0:t>=hn:!1}}else dn=()=>performance.now()>=pn}function bn(e,t){function n(){let n=0,r=e.length-1;for(;n<=r;){let i=r+n>>1,a=t.expirationTime-e[i].expirationTime;if(a>0)n=i+1;else if(a<0)r=i-1;else return i}return n}e.splice(n(),0,t)}function xn(e,t){gn||yn();let n=performance.now(),r=vn;t&&t.timeout&&(r=t.timeout);let i={id:on++,fn:e,startTime:n,expirationTime:n+r};return bn(ln,i),!sn&&!cn&&(sn=!0,_n=Cn,gn()),i}function Sn(e){e.fn=null}function Cn(e){sn=!1,cn=!0;try{return wn(e)}finally{un=null,cn=!1}}function wn(e){let t=e;for(un=ln[0]||null;un!==null&&!(un.expirationTime>t&&dn());){let e=un.fn;e===null?ln.shift():(un.fn=null,e(un.expirationTime<=t),t=performance.now(),un===ln[0]&&ln.shift()),un=ln[0]||null}return un!==null}var P={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Tn(this.context.count)},getNextContextId(){return Tn(this.context.count++)}};function Tn(e){let t=String(e),n=t.length-1;return P.context.id+(n?String.fromCharCode(96+n):``)+t}function En(e){P.context=e}function Dn(){return{...P.context,id:P.getNextContextId(),count:0}}var On=(e,t)=>e===t,kn=Symbol(`solid-proxy`),An=typeof Proxy==`function`,jn=Symbol(`solid-track`),Mn=Symbol(`solid-dev-component`),Nn={equals:On},Pn=null,Fn=jr,In=1,Ln=2,Rn={owned:null,cleanups:null,context:null,owner:null},zn={},F=null,I=null,Bn=null,Vn=null,L=null,Hn=null,Un=null,Wn=0;function Gn(e,t){let n=L,r=F,i=e.length===0,a=t===void 0?r:t,o=i?Rn:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>rr(()=>Ir(o)));F=o,L=null;try{return kr(s,!0)}finally{L=n,F=r}}function Kn(e,t){t=t?Object.assign({},Nn,t):Nn;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[Cr.bind(n),e=>(typeof e==`function`&&(e=I&&I.running&&I.sources.has(n)?e(n.tValue):e(n.value)),wr(n,e))]}function qn(e,t,n){let r=Dr(e,t,!0,In);Bn&&I&&I.running?Hn.push(r):Tr(r)}function Jn(e,t,n){let r=Dr(e,t,!1,In);Bn&&I&&I.running?Hn.push(r):Tr(r)}function Yn(e,t,n){Fn=Nr;let r=Dr(e,t,!1,In),i=br&&vr(br);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Un?Un.push(r):Tr(r)}function Xn(e,t){let n,r=Dr(()=>{n?n():rr(e),n=void 0},void 0,!1,0),i=br&&vr(br);return i&&(r.suspense=i),r.user=!0,e=>{n=e,Tr(r)}}function Zn(e,t,n){n=n?Object.assign({},Nn,n):Nn;let r=Dr(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,Bn&&I&&I.running?(r.tState=In,Hn.push(r)):Tr(r),Cr.bind(r)}function Qn(e){return e&&typeof e==`object`&&`then`in e}function $n(e,t,n){let r,i,a;typeof t==`function`?(r=e,i=t,a=n||{}):(r=!0,i=e,a=t||{});let o=null,s=zn,c=null,l=!1,u=!1,d=`initialValue`in a,f=typeof r==`function`&&Zn(r),p=new Set,[ee,te]=(a.storage||Kn)(a.initialValue),[ne,m]=Kn(void 0),[re,ie]=Kn(void 0,{equals:!1}),[ae,oe]=Kn(d?`ready`:`unresolved`);P.context&&(c=P.getNextContextId(),a.ssrLoadFrom===`initial`?s=a.initialValue:P.load&&P.has(c)&&(s=P.load(c)));function se(e,t,n,r){return o===e&&(o=null,r!==void 0&&(d=!0),(e===s||t===s)&&a.onHydrated&&queueMicrotask(()=>a.onHydrated(r,{value:t})),s=zn,I&&e&&l?(I.promises.delete(e),l=!1,kr(()=>{I.running=!0,ce(t,n)},!1)):ce(t,n)),t}function ce(e,t){kr(()=>{t===void 0&&te(()=>e),oe(t===void 0?d?`ready`:`unresolved`:`errored`),m(t);for(let e of p.keys())e.decrement();p.clear()},!1)}function le(){let e=br&&vr(br),t=ee(),n=ne();if(n!==void 0&&!o)throw n;return L&&!L.user&&e&&qn(()=>{re(),o&&(e.resolved&&I&&l?I.promises.add(o):p.has(e)||(e.increment(),p.add(e)))}),t}function ue(e=!0){if(e!==!1&&u)return;u=!1;let t=f?f():r;if(l=I&&I.running,t==null||t===!1){se(o,rr(ee));return}I&&o&&I.promises.delete(o);let n,a=s===zn?rr(()=>{try{return i(t,{value:ee(),refetching:e})}catch(e){n=e}}):s;if(n!==void 0){se(o,void 0,Rr(n),t);return}return Qn(a)?(o=a,`v`in a?(a.s===1?se(o,a.v,void 0,t):se(o,void 0,Rr(a.v),t),a):(u=!0,queueMicrotask(()=>u=!1),kr(()=>{oe(d?`refreshing`:`pending`),ie()},!1),a.then(e=>se(a,e,void 0,t),e=>se(a,void 0,Rr(e),t)))):(se(o,a,void 0,t),a)}Object.defineProperties(le,{state:{get:()=>ae()},error:{get:()=>ne()},loading:{get(){let e=ae();return e===`pending`||e===`refreshing`}},latest:{get(){if(!d)return le();let e=ne();if(e&&!o)throw e;return ee()}}});let de=F;return f?qn(()=>(de=F,ue(!1))):ue(!1),[le,{refetch:e=>ur(de,()=>ue(e)),mutate:te}]}function er(e,t){let n,r=t?t.timeoutMs:void 0,i=Dr(()=>((!n||!n.fn)&&(n=xn(()=>o(()=>i.value),r===void 0?void 0:{timeout:r})),e()),void 0,!0),[a,o]=Kn(I&&I.running&&I.sources.has(i)?i.tValue:i.value,t);return Tr(i),o(()=>I&&I.running&&I.sources.has(i)?i.tValue:i.value),a}function tr(e,t=On,n){let r=new Map,i=Dr(n=>{let i=e();for(let[e,a]of r.entries())if(t(e,i)!==t(e,n))for(let e of a.values())e.state=In,e.pure?Hn.push(e):Un.push(e);return i},void 0,!0,In);return Tr(i),e=>{let n=L;if(n){let t;(t=r.get(e))?t.add(n):r.set(e,t=new Set([n])),or(()=>{t.delete(n),!t.size&&r.delete(e)})}return t(e,I&&I.running&&I.sources.has(i)?i.tValue:i.value)}}function nr(e){return kr(e,!1)}function rr(e){if(!Vn&&L===null)return e();let t=L;L=null;try{return Vn?Vn.untrack(e):e()}finally{L=t}}function ir(e,t,n){let r=Array.isArray(e),i,a=n&&n.defer;return n=>{let o;if(r){o=Array(e.length);for(let t=0;t<e.length;t++)o[t]=e[t]()}else o=e();if(a)return a=!1,n;let s=rr(()=>t(o,i,n));return i=o,s}}function ar(e){Yn(()=>rr(e))}function or(e){return F===null||(F.cleanups===null?F.cleanups=[e]:F.cleanups.push(e)),e}function sr(e,t){Pn||=Symbol(`error`),F=Dr(void 0,void 0,!0),F.context={...F.context,[Pn]:[t]},I&&I.running&&I.sources.add(F);try{return e()}catch(e){Br(e)}finally{F=F.owner}}function cr(){return L}function lr(){return F}function ur(e,t){let n=F,r=L;F=e,L=null;try{return kr(t,!0)}catch(e){Br(e)}finally{F=n,L=r}}function dr(e=xn){Bn=e}function fr(e){if(I&&I.running)return e(),I.done;let t=L,n=F;return Promise.resolve().then(()=>{L=t,F=n;let r;return(Bn||br)&&(r=I||={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0},r.done||(r.done=new Promise(e=>r.resolve=e)),r.running=!0),kr(e,!1),L=F=null,r?r.done:void 0})}var[pr,mr]=Kn(!1);function hr(){return[pr,fr]}function gr(e){Un.push.apply(Un,e),e.length=0}function _r(e,t){let n=Symbol(`context`);return{id:n,Provider:Hr(n),defaultValue:e}}function vr(e){let t;return F&&F.context&&(t=F.context[e.id])!==void 0?t:e.defaultValue}function yr(e){let t=Zn(e),n=Zn(()=>Vr(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var br;function xr(){return br||=_r()}function Sr(e,t=e=>e()){if(Vn){let{factory:n,untrack:r}=Vn;Vn={factory:(t,r)=>{let i=n(t,r),a=e(e=>i.track(e),r);return{track:e=>a.track(e),dispose(){a.dispose(),i.dispose()}}},untrack:e=>r(()=>t(e))}}else Vn={factory:e,untrack:t}}function Cr(){let e=I&&I.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===In)Tr(this);else{let e=Hn;Hn=null,kr(()=>Pr(this),!1),Hn=e}if(L){let e=this.observers;if(!e||e[e.length-1]!==L){let t=e?e.length:0;L.sources?(L.sources.push(this),L.sourceSlots.push(t)):(L.sources=[this],L.sourceSlots=[t]),e?(e.push(L),this.observerSlots.push(L.sources.length-1)):(this.observers=[L],this.observerSlots=[L.sources.length-1])}}return e&&I.sources.has(this)?this.tValue:this.value}function wr(e,t,n){let r=I&&I.running&&I.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(I){let r=I.running;(r||!n&&I.sources.has(e))&&(I.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&kr(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=I&&I.running;r&&I.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?Hn.push(n):Un.push(n),n.observers&&Fr(n)),r?n.tState=In:n.state=In)}if(Hn.length>1e6)throw Hn=[],Error()},!1)}return t}function Tr(e){if(!e.fn)return;Ir(e);let t=Wn;Er(e,I&&I.running&&I.sources.has(e)?e.tValue:e.value,t),I&&!I.running&&I.sources.has(e)&&queueMicrotask(()=>{kr(()=>{I&&(I.running=!0),L=F=e,Er(e,e.tValue,t),L=F=null},!1)})}function Er(e,t,n){let r,i=F,a=L;L=F=e;try{r=e.fn(t)}catch(t){return e.pure&&(I&&I.running?(e.tState=In,e.tOwned&&e.tOwned.forEach(Ir),e.tOwned=void 0):(e.state=In,e.owned&&e.owned.forEach(Ir),e.owned=null)),e.updatedAt=n+1,Br(t)}finally{L=a,F=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?wr(e,r,!0):I&&I.running&&e.pure?(I.sources.has(e)||(e.value=r),I.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function Dr(e,t,n,r=In,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:F,context:F?F.context:null,pure:n};if(I&&I.running&&(a.state=0,a.tState=r),F===null||F!==Rn&&(I&&I.running&&F.pure?F.tOwned?F.tOwned.push(a):F.tOwned=[a]:F.owned?F.owned.push(a):F.owned=[a]),Vn&&a.fn){let e=a.fn,[t,n]=Kn(void 0,{equals:!1}),r=Vn.factory(e,n);or(()=>r.dispose());let i,o=()=>fr(n).then(()=>{i&&=(i.dispose(),void 0)});a.fn=n=>(t(),I&&I.running?(i||=Vn.factory(e,o),i.track(n)):r.track(n))}return a}function Or(e){let t=I&&I.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===Ln)return Pr(e);if(e.suspense&&rr(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Wn);){if(t&&I.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(I.disposed.has(t))return}if((t?e.tState:e.state)===In)Tr(e);else if((t?e.tState:e.state)===Ln){let t=Hn;Hn=null,kr(()=>Pr(e,n[0]),!1),Hn=t}}}function kr(e,t){if(Hn)return e();let n=!1;t||(Hn=[]),Un?n=!0:Un=[],Wn++;try{let t=e();return Ar(n),t}catch(e){n||(Un=null),Hn=null,Br(e)}}function Ar(e){if(Hn&&=(Bn&&I&&I.running?Mr(Hn):jr(Hn),null),e)return;let t;if(I){if(!I.promises.size&&!I.queue.size){let e=I.sources,n=I.disposed;Un.push.apply(Un,I.effects),t=I.resolve;for(let e of Un)`tState`in e&&(e.state=e.tState),delete e.tState;I=null,kr(()=>{for(let e of n)Ir(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)Ir(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}mr(!1)},!1)}else if(I.running){I.running=!1,I.effects.push.apply(I.effects,Un),Un=null,mr(!0);return}}let n=Un;Un=null,n.length&&kr(()=>Fn(n),!1),t&&t()}function jr(e){for(let t=0;t<e.length;t++)Or(e[t])}function Mr(e){for(let t=0;t<e.length;t++){let n=e[t],r=I.queue;r.has(n)||(r.add(n),Bn(()=>{r.delete(n),kr(()=>{I.running=!0,Or(n)},!1),I&&(I.running=!1)}))}}function Nr(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:Or(r)}if(P.context){if(P.count){P.effects||=[],P.effects.push(...e.slice(0,n));return}En()}for(P.effects&&(P.done||!P.count)&&(e=[...P.effects,...e],n+=P.effects.length,delete P.effects),t=0;t<n;t++)Or(e[t])}function Pr(e,t){let n=I&&I.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===In?i!==t&&(!i.updatedAt||i.updatedAt<Wn)&&Or(i):e===Ln&&Pr(i,t)}}}function Fr(e){let t=I&&I.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=Ln:r.state=Ln,r.pure?Hn.push(r):Un.push(r),r.observers&&Fr(r))}}function Ir(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)Ir(e.tOwned[t]);delete e.tOwned}if(I&&I.running&&e.pure)Lr(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)Ir(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}I&&I.running?e.tState=0:e.state=0}function Lr(e,t){if(t||(e.tState=0,I.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)Lr(e.owned[t])}function Rr(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function zr(e,t,n){try{for(let n of t)n(e)}catch(e){Br(e,n&&n.owner||null)}}function Br(e,t=F){let n=Pn&&t&&t.context&&t.context[Pn],r=Rr(e);if(!n)throw r;Un?Un.push({fn(){zr(r,n,t)},state:In}):zr(r,n,t)}function Vr(e){if(typeof e==`function`&&!e.length)return Vr(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Vr(e[n]);if(Array.isArray(r))if(r.length<32768)t.push.apply(t,r);else for(let e=0;e<r.length;e++)t.push(r[e]);else t.push(r)}return t}return e}function Hr(e,t){return function(t){let n;return Jn(()=>n=rr(()=>(F.context={...F.context,[e]:t.value},yr(()=>t.children))),void 0),n}}function Ur(e){Pn||=Symbol(`error`),F===null||(F.context===null||!F.context[Pn]?(F.context={...F.context,[Pn]:[e]},Wr(F,Pn,[e])):F.context[Pn].push(e))}function Wr(e,t,n){if(e.owned)for(let r=0;r<e.owned.length;r++)e.owned[r].context===e.context&&Wr(e.owned[r],t,n),e.owned[r].context?e.owned[r].context[t]||(e.owned[r].context[t]=n,Wr(e.owned[r],t,n)):(e.owned[r].context=e.context,Wr(e.owned[r],t,n))}function Gr(e){return{subscribe(t){if(!(t instanceof Object)||t==null)throw TypeError(`Expected the observer to be an object.`);let n=typeof t==`function`?t:t.next&&t.next.bind(t);if(!n)return{unsubscribe(){}};let r=Gn(t=>(Yn(()=>{let t=e();rr(()=>n(t))}),t));return lr()&&or(r),{unsubscribe(){r()}}},[Symbol.observable||`@@observable`](){return this}}}function Kr(e,t=void 0){let[n,r]=Kn(t,{equals:!1});if(`subscribe`in e){let t=e.subscribe(e=>r(()=>e));or(()=>`unsubscribe`in t?t.unsubscribe():t())}else or(e(r));return n}var qr=Symbol(`fallback`);function Jr(e){for(let t=0;t<e.length;t++)e[t]()}function Yr(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return or(()=>Jr(a)),()=>{let c=e()||[],l=c.length,u,d;return c[jn],rr(()=>{let e,t,p,ee,te,ne,m,re,ie;if(l===0)o!==0&&(Jr(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[qr],i[0]=Gn(e=>(a[0]=e,n.fallback())),o=1);else if(o===0){for(i=Array(l),d=0;d<l;d++)r[d]=c[d],i[d]=Gn(f);o=l}else{for(p=Array(l),ee=Array(l),s&&(te=Array(l)),ne=0,m=Math.min(o,l);ne<m&&r[ne]===c[ne];ne++);for(m=o-1,re=l-1;m>=ne&&re>=ne&&r[m]===c[re];m--,re--)p[re]=i[m],ee[re]=a[m],s&&(te[re]=s[m]);for(e=new Map,t=Array(re+1),d=re;d>=ne;d--)ie=c[d],u=e.get(ie),t[d]=u===void 0?-1:u,e.set(ie,d);for(u=ne;u<=m;u++)ie=r[u],d=e.get(ie),d!==void 0&&d!==-1?(p[d]=i[u],ee[d]=a[u],s&&(te[d]=s[u]),d=t[d],e.set(ie,d)):a[u]();for(d=ne;d<l;d++)d in p?(i[d]=p[d],a[d]=ee[d],s&&(s[d]=te[d],s[d](d))):i[d]=Gn(f);i=i.slice(0,o=l),r=c.slice(0)}return i});function f(e){if(a[d]=e,s){let[e,n]=Kn(d);return s[d]=n,t(c[d],e)}return t(c[d])}}}function Xr(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return or(()=>Jr(a)),()=>{let l=e()||[],u=l.length;return l[jn],rr(()=>{if(u===0)return s!==0&&(Jr(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[qr],i[0]=Gn(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===qr&&(a[0](),a=[],r=[],i=[],s=0),c=0;c<u;c++)c<r.length&&r[c]!==l[c]?o[c](()=>l[c]):c>=r.length&&(i[c]=Gn(d));for(;c<r.length;c++)a[c]();return s=o.length=a.length=u,r=l.slice(0),i=i.slice(0,s)});function d(e){a[c]=e;let[n,r]=Kn(l[c]);return o[c]=r,t(n,c)}}}var Zr=!1;function Qr(){Zr=!0}function $r(e,t){if(Zr&&P.context){let n=P.context;En(Dn());let r=rr(()=>e(t||{}));return En(n),r}return rr(()=>e(t||{}))}function ei(){return!0}var ti={get(e,t,n){return t===kn?n:e.get(t)},has(e,t){return t===kn||e.has(t)},set:ei,deleteProperty:ei,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:ei,deleteProperty:ei}},ownKeys(e){return e.keys()}};function ni(e){return(e=typeof e==`function`?e():e)?e:{}}function ri(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function ii(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&kn in r,e[n]=typeof r==`function`?(t=!0,Zn(r)):r}if(An&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=ni(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in ni(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(ni(e[n])));return[...new Set(t)]}},ti);let n={},r=Object.create(null);for(let t=e.length-1;t>=0;t--){let i=e[t];if(!i)continue;let a=Object.getOwnPropertyNames(i);for(let e=a.length-1;e>=0;e--){let t=a[e];if(t===`__proto__`||t===`constructor`)continue;let o=Object.getOwnPropertyDescriptor(i,t);if(!r[t])r[t]=o.get?{enumerable:!0,configurable:!0,get:ri.bind(n[t]=[o.get.bind(i)])}:o.value===void 0?void 0:o;else{let e=n[t];e&&(o.get?e.push(o.get.bind(i)):o.value!==void 0&&e.push(()=>o.value))}}}let i={},a=Object.keys(r);for(let e=a.length-1;e>=0;e--){let t=a[e],n=r[t];n&&n.get?Object.defineProperty(i,t,n):i[t]=n?n.value:void 0}return i}function ai(e,...t){let n=t.length;if(An&&kn in e){let r=n>1?t.flat():t[0],i=t.map(t=>new Proxy({get(n){return t.includes(n)?e[n]:void 0},has(n){return t.includes(n)&&n in e},keys(){return t.filter(t=>t in e)}},ti));return i.push(new Proxy({get(t){return r.includes(t)?void 0:e[t]},has(t){return!r.includes(t)&&t in e},keys(){return Object.keys(e).filter(e=>!r.includes(e))}},ti)),i}let r=[];for(let e=0;e<=n;e++)r[e]={};for(let i of Object.getOwnPropertyNames(e)){let a=n;for(let e=0;e<t.length;e++)if(t[e].includes(i)){a=e;break}let o=Object.getOwnPropertyDescriptor(e,i);!o.get&&!o.set&&o.enumerable&&o.writable&&o.configurable?r[a][i]=o.value:Object.defineProperty(r[a],i,o)}return r}function oi(e){let t,n,r=r=>{let i=P.context;if(i){let[r,a]=Kn();P.count||=0,P.count++,(n||=e()).then(e=>{!P.done&&En(i),P.count--,a(()=>e.default),En()}),t=r}else if(!t){let[r]=$n(()=>(n||=e()).then(e=>e.default));t=r}let a;return Zn(()=>(a=t())?rr(()=>{if(!i||P.done)return a(r);let e=P.context;En(i);let t=a(r);return En(e),t}):``)};return r.preload=()=>n||((n=e()).then(e=>t=()=>e.default),n),r}var si=0;function ci(){return P.context?P.getNextContextId():`cl-${si++}`}var li=e=>`Stale read from <${e}>.`;function ui(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Zn(Yr(()=>e.each,e.children,t||void 0))}function di(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Zn(Xr(()=>e.each,e.children,t||void 0))}function fi(e){let t=e.keyed,n=Zn(()=>e.when,void 0,void 0),r=t?n:Zn(n,void 0,{equals:(e,t)=>!e==!t});return Zn(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?rr(()=>a(t?i:()=>{if(!rr(r))throw li(`Show`);return n()})):a}return e.fallback},void 0,void 0)}function pi(e){let t=yr(()=>e.children),n=Zn(()=>{let e=t(),n=Array.isArray(e)?e:[e],r=()=>void 0;for(let e=0;e<n.length;e++){let t=e,i=n[e],a=r,o=Zn(()=>a()?void 0:i.when,void 0,void 0),s=i.keyed?o:Zn(o,void 0,{equals:(e,t)=>!e==!t});r=()=>a()||(s()?[t,o,i]:void 0)}return r});return Zn(()=>{let t=n()();if(!t)return e.fallback;let[r,i,a]=t,o=a.children;return typeof o==`function`&&o.length>0?rr(()=>o(a.keyed?i():()=>{if(rr(n)()?.[0]!==r)throw li(`Match`);return i()})):o},void 0,void 0)}function mi(e){return e}var hi;function gi(){hi&&[...hi].forEach(e=>e())}function _i(e){let t;P.context&&P.load&&(t=P.load(P.getContextId()));let[n,r]=Kn(t,void 0);return hi||=new Set,hi.add(r),or(()=>hi.delete(r)),Zn(()=>{let t;if(t=n()){let n=e.fallback;return typeof n==`function`&&n.length?rr(()=>n(t,()=>r())):n}return sr(()=>e.children,r)},void 0,void 0)}var vi=(e,t)=>e.showContent===t.showContent&&e.showFallback===t.showFallback,yi=_r();function bi(e){let[t,n]=Kn(()=>({inFallback:!1})),r,i=vr(yi),[a,o]=Kn([]);i&&(r=i.register(Zn(()=>t()().inFallback)));let s=Zn(t=>{let n=e.revealOrder,i=e.tail,{showContent:o=!0,showFallback:s=!0}=r?r():{},c=a(),l=n===`backwards`;if(n===`together`){let e=c.every(e=>!e()),t=c.map(()=>({showContent:e&&o,showFallback:s}));return t.inFallback=!e,t}let u=!1,d=t.inFallback,f=[];for(let e=0,t=c.length;e<t;e++){let n=l?t-e-1:e,r=c[n]();if(!u&&!r)f[n]={showContent:o,showFallback:s};else{let e=!u;e&&(d=!0),f[n]={showContent:e,showFallback:!i||e&&i===`collapsed`?s:!1},u=!0}}return u||(d=!1),f.inFallback=d,f},{inFallback:!1});return n(()=>s),$r(yi.Provider,{value:{register:e=>{let t;return o(n=>(t=n.length,[...n,e])),Zn(()=>s()[t],void 0,{equals:vi})}},get children(){return e.children}})}function xi(e){let t=0,n,r,i,a,o,[s,c]=Kn(!1),l=xr(),u={increment:()=>{++t===1&&c(!0)},decrement:()=>{--t===0&&c(!1)},inFallback:s,effects:[],resolved:!1},d=lr();if(P.context&&P.load){let e=P.getContextId(),t=P.load(e);if(t&&(typeof t!=`object`||t.s!==1?i=t:P.gather(e)),i&&i!==`$$f`){let[t,n]=Kn(void 0,{equals:!1});a=t,i.then(()=>{if(P.done)return n();P.gather(e),En(r),n(),En()},e=>{o=e,n()})}}let f=vr(yi);f&&(n=f.register(u.inFallback));let p;return or(()=>p&&p()),$r(l.Provider,{value:u,get children(){return Zn(()=>{if(o)throw o;if(r=P.context,a){a(),a=void 0;return}r&&i===`$$f`&&En();let t=Zn(()=>e.children);return Zn(a=>{let o=u.inFallback(),{showContent:s=!0,showFallback:c=!0}=n?n():{};if((!o||i&&i!==`$$f`)&&s)return u.resolved=!0,p&&p(),p=r=i=void 0,gr(u.effects),t();if(c)return p?a:Gn(t=>(p=t,r&&=(En({id:r.id+`F`,count:0}),void 0),e.fallback),d)})})}})}var Si=e({$RAW:()=>Ci,DEV:()=>void 0,createMutable:()=>Gi,createStore:()=>Vi,modifyMutable:()=>Ki,produce:()=>$i,reconcile:()=>Xi,unwrap:()=>ki}),Ci=Symbol(`store-raw`),wi=Symbol(`store-node`),Ti=Symbol(`store-has`),Ei=Symbol(`store-self`);function Di(e){let t=e[kn];if(!t&&(Object.defineProperty(e,kn,{value:t=new Proxy(e,Fi)}),!Array.isArray(e))){let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=Object.getOwnPropertyDescriptors(i);n.push(...Object.keys(e)),Object.assign(r,e)}for(let i=0,o=n.length;i<o;i++){let o=n[i];a&&o===`constructor`||r[o].get&&Object.defineProperty(e,o,{configurable:!0,enumerable:r[o].enumerable,get:r[o].get.bind(t)})}}return t}function Oi(e){let t;return typeof e==`object`&&!!e&&(e[kn]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function ki(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[Ci])return n;if(!Oi(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let n=0,a=e.length;n<a;n++)i=e[n],(r=ki(i,t))!==i&&(e[n]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let s=0,c=n.length;s<c;s++)a=n[s],!o[a].get&&(i=e[a],(r=ki(i,t))!==i&&(e[a]=r))}return e}function Ai(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function ji(e,t,n){if(e[t])return e[t];let[r,i]=Kn(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Mi(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===kn||t===wi?n:(delete n.value,delete n.writable,n.get=()=>e[kn][t],n)}function Ni(e){cr()&&ji(Ai(e,wi),Ei)()}function Pi(e){return Ni(e),Reflect.ownKeys(e)}var Fi={get(e,t,n){if(t===Ci)return e;if(t===kn)return n;if(t===jn)return Ni(e),n;let r=Ai(e,wi),i=r[t],a=i?i():e[t];if(t===wi||t===Ti||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);cr()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=ji(r,t,a)())}return Oi(a)?Di(a):a},has(e,t){return t===Ci||t===kn||t===jn||t===wi||t===Ti||t===`__proto__`||(cr()&&ji(Ai(e,Ti),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Pi,getOwnPropertyDescriptor:Mi};function Ii(e,t,n,r=!1){if(t===`__proto__`||!r&&e[t]===n)return;let i=e[t],a=e.length;n===void 0?(delete e[t],e[Ti]&&e[Ti][t]&&i!==void 0&&e[Ti][t].$()):(e[t]=n,e[Ti]&&e[Ti][t]&&i===void 0&&e[Ti][t].$());let o=Ai(e,wi),s;if((s=ji(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=ji(o,`length`,a))&&s.$(e.length)}(s=o[Ei])&&s.$()}function Li(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];Ri(i)||Ii(e,i,t[i])}}function Ri(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function zi(e,t){if(typeof t==`function`&&(t=t(e)),t=ki(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){let r=t[n];e[n]!==r&&Ii(e,n,r)}Ii(e,`length`,r)}else Li(e,t)}function Bi(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();let a=typeof r,o=Array.isArray(e);if(a===`string`&&(r===`__proto__`||t.length>1&&Ri(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)Bi(e,[r[i]].concat(t),n);return}if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&Bi(e,[i].concat(t),n);return}if(o&&a===`object`){let{from:i=0,to:a=e.length-1,by:o=1}=r;for(let r=i;r<=a;r+=o)Bi(e,[r].concat(t),n);return}if(t.length>1){Bi(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let a=t[0];typeof a==`function`&&(a=a(i,n),a===i)||(r!==void 0||a!=null)&&(a=ki(a),r===void 0||Oi(i)&&Oi(a)&&!Array.isArray(a)?Li(i,a):Ii(e,r,a))}function Vi(...[e,t]){let n=ki(e||{}),r=Array.isArray(n),i=Di(n);function a(...e){nr(()=>{r&&e.length===1?zi(n,e[0]):Bi(n,e)})}return[i,a]}function Hi(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===kn||t===wi?n:(delete n.value,delete n.writable,n.get=()=>e[kn][t],n.set=n=>e[kn][t]=n,n)}var Ui={get(e,t,n){if(t===Ci)return e;if(t===kn)return n;if(t===jn)return Ni(e),n;let r=Ai(e,wi),i=r[t],a=i?i():e[t];if(t===wi||t===Ti||t===`__proto__`)return a;if(!i){let i=Object.getOwnPropertyDescriptor(e,t),o=typeof a==`function`;if(cr()&&(!o||e.hasOwnProperty(t))&&!(i&&i.get))a=ji(r,t,a)();else if(a!=null&&o&&a===Array.prototype[t])return(...e)=>nr(()=>Array.prototype[t].apply(n,e))}return Oi(a)?Wi(a):a},has(e,t){return t===Ci||t===kn||t===jn||t===wi||t===Ti||t===`__proto__`||(cr()&&ji(Ai(e,Ti),t)(),t in e)},set(e,t,n){return nr(()=>Ii(e,t,ki(n))),!0},deleteProperty(e,t){return nr(()=>Ii(e,t,void 0,!0)),!0},ownKeys:Pi,getOwnPropertyDescriptor:Hi};function Wi(e){let t=e[kn];if(!t){Object.defineProperty(e,kn,{value:t=new Proxy(e,Ui)});let n=Object.keys(e),r=Object.getOwnPropertyDescriptors(e),i=Object.getPrototypeOf(e),a=i!==null&&typeof e==`object`&&!!e&&!Array.isArray(e)&&i!==Object.prototype;if(a){let e=i;for(;e!=null;){let t=Object.getOwnPropertyDescriptors(e);n.push(...Object.keys(t)),Object.assign(r,t),e=Object.getPrototypeOf(e)}}for(let i=0,o=n.length;i<o;i++){let o=n[i];if(!(a&&o===`constructor`)){if(r[o].get){let n=r[o].get.bind(t);Object.defineProperty(e,o,{get:n,configurable:!0})}if(r[o].set){let n=r[o].set;Object.defineProperty(e,o,{set:e=>nr(()=>n.call(t,e)),configurable:!0})}}}}return t}function Gi(e,t){return Wi(ki(e||{}))}function Ki(e,t){nr(()=>t(ki(e)))}var qi=Symbol(`store-root`);function Ji(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Yi(e,t,n,r,i){if(Ji(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==qi&&(!Oi(e)||!Oi(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){Ii(t,n,e);return}if(o){if(e.length&&a.length&&(!r||i&&e[0]&&e[0][i]!=null)){let t,n,o,s,c,l,u,d;for(o=0,s=Math.min(a.length,e.length);o<s&&(a[o]===e[o]||i&&a[o]&&e[o]&&a[o][i]&&a[o][i]===e[o][i]);o++)Yi(e[o],a,o,r,i);let f=Array(e.length),p=new Map;for(s=a.length-1,c=e.length-1;s>=o&&c>=o&&(a[s]===e[c]||i&&a[s]&&e[c]&&a[s][i]&&a[s][i]===e[c][i]);s--,c--)f[c]=a[s];if(o>c||o>s){for(n=o;n<=c;n++)Ii(a,n,e[n]);for(;n<e.length;n++)Ii(a,n,f[n]),Yi(e[n],a,n,r,i);a.length>e.length&&Ii(a,`length`,e.length);return}for(u=Array(c+1),n=c;n>=o;n--)l=e[n],d=i&&l?l[i]:l,t=p.get(d),u[n]=t===void 0?-1:t,p.set(d,n);for(t=o;t<=s;t++)l=a[t],d=i&&l?l[i]:l,n=p.get(d),n!==void 0&&n!==-1&&(f[n]=a[t],n=u[n],p.set(d,n));for(n=o;n<e.length;n++)n in f?(Ii(a,n,f[n]),Yi(e[n],a,n,r,i)):Ii(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)Yi(e[t],a,t,r,i);a.length>e.length&&Ii(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Ji(s[t])||Yi(e[s[t]],a,s[t],r,i);let c=Object.keys(a);for(let t=0,n=c.length;t<n;t++)e[c[t]]===void 0&&Ii(a,c[t],void 0)}function Xi(e,t={}){let{merge:n,key:r=`id`}=t,i=ki(e);return e=>{if(!Oi(e)||!Oi(i))return i;let t=Yi(i,{[qi]:e},qi,n,r);return t===void 0?e:t}}var Zi=new WeakMap,Qi={get(e,t){if(t===Ci)return e;let n=e[t];if(t===kn||t===jn||t===wi||t===Ti||t===`__proto__`)return n;let r;return Oi(n)?Zi.get(n)||(Zi.set(n,r=new Proxy(n,Qi)),r):n},set(e,t,n){return Ii(e,t,ki(n)),!0},deleteProperty(e,t){return Ii(e,t,void 0,!0),!0}};function $i(e){return t=>{if(Oi(t)){let n;(n=Zi.get(t))||Zi.set(t,n=new Proxy(t,Qi)),e(n)}return t}}var ea=Object.defineProperty,ta=e=>e;function na(e,t){this[e]=ta.bind(null,t)}var ra=(e,t)=>{for(var n in t)ea(e,n,{get:t[n],enumerable:!0,configurable:!0,set:na.bind(t,n)})},ia={};ra(ia,{SharedEvents:()=>ia,make:()=>aa});function aa(e){let t,n=4096;function r(e){e.connected=void 0,e.controller.abort(),t===e&&(t=void 0)}async function i(t){let n,i={};try{if(t.controller.signal.aborted)return;for(n=e(t.controller.signal,()=>{t.subscribers.forEach(e=>e.activity?.())})[Symbol.asyncIterator]();!t.controller.signal.aborted;){let e=await n.next();if(e.done||t.controller.signal.aborted)break;e.value.type===`server.connected`&&(t.connected=e.value),t.subscribers.forEach(t=>t.push(e.value))}}catch(e){i={error:e}}finally{r(t);try{await n?.return?.()}catch(e){`error`in i||(i={error:e})}t.subscribers.forEach(e=>e.finish(i))}}return{subscribe(e){return{[Symbol.asyncIterator](){let a=[],o=[],s=!1,c,l,u=e?.types?.length?new Set(e.types):void 0,d=e=>!u||e.type===`server.connected`||u.has(e.type);function f(t,n=!0){c=t,n&&(o.length=0),e?.signal?.removeEventListener(`abort`,p),l?.subscribers.delete(ee)&&!l.subscribers.size&&r(l),a.splice(0).forEach(e=>{`error`in t?e.reject(t.error):e.resolve({done:!0,value:void 0})})}function p(){f({})}let ee={activity:e?.onActivity,finish(e){f(e,!1)},push(e){if(c||!d(e))return;let t=a.shift();if(t){t.resolve({done:!1,value:e});return}if(o.length===n){f({error:Error(`Event subscriber exceeded its ${n}-event capacity`)});return}o.push(e)}};function te(){if(c)return;let e=!t;l=t??{controller:new AbortController,subscribers:new Set},t=l,l.subscribers.add(ee),l.connected&&ee.push(l.connected),e&&i(l)}return{next(){let t=o.shift();if(t)return Promise.resolve({done:!1,value:t});if(c)return`error`in c?Promise.reject(c.error):Promise.resolve({done:!0,value:void 0});if(e?.signal?.aborted)return p(),Promise.resolve({done:!0,value:void 0});let n=Promise.withResolvers();return a.push(n),s||(s=!0,e?.signal?.addEventListener(`abort`,p,{once:!0}),te()),n.promise},return(){return f({}),Promise.resolve({done:!0,value:void 0})}}}}}}}var oa=class extends Error{reason;name=`ClientError`;constructor(e,t){let n=t?.detail??(t?.cause instanceof Error?t.cause.message:void 0);super(n?`${e}: ${n}`:e,t),this.reason=e}};ra({},{make:()=>ca});var sa=16777216;function ca(e){let t=e.fetch??globalThis.fetch,n=(t,n)=>{let r=new URL(e.baseUrl);r.pathname.endsWith(`/`)||(r.pathname+=`/`);let i=new URL(t.path.slice(1),r);for(let[e,n]of Object.entries(t.query??{}))ua(i.searchParams,e,n);let a=new Headers(e.headers);for(let[e,n]of Object.entries(t.headers??{}))n!=null&&a.set(e,String(n));for(let[e,t]of new Headers(n?.headers))a.set(e,t);return t.body!==void 0&&!a.has(`content-type`)&&a.set(`content-type`,t.binaryBody?`application/octet-stream`:`application/json`),{url:i,init:{method:t.method,signal:n?.signal,headers:a,body:t.body===void 0?void 0:t.binaryBody?t.body:JSON.stringify(t.body)}}},r=async(e,r)=>{try{let i=n(e,r);return await t(i.url,i.init)}catch(e){throw new oa(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw fa(await da(e));try{await e.body?.cancel()}catch{}throw new oa(`UnexpectedStatus`,{cause:{status:e.status},detail:String(e.status)})},a=async(e,t)=>{let n=await r(e,t);if(n.status!==e.successStatus)return i(n,e);if(e.binary)return new Uint8Array(await n.arrayBuffer());if(e.empty){try{await n.body?.cancel()}catch{}return}return await da(n)},o=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!pa(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new oa(`UnsupportedContentType`,{detail:n.headers.get(`content-type`)})}if(n.body===null)throw new oa(`MalformedResponse`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new oa(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),s+=o.decode(e.value,{stream:!e.done}),s.length>sa)throw new oa(`SseEventTooLarge`);let n=!e.done&&s.endsWith(`\r`);n&&(s=s.slice(0,-1)),s=s.replaceAll(`\r
13
+ `,`
14
+ `).replaceAll(`\r`,`
15
+ `),n&&(s+=`\r`),e.done&&s!==``&&(s+=`
16
+
17
+ `);let r=s.indexOf(`
18
+
19
+ `);for(;r>=0;){let e=s.slice(0,r);s=s.slice(r+2);let t=e.split(`
20
+ `).flatMap(e=>e.startsWith(`data:`)?[e.slice(5).trimStart()]:[]).join(`
21
+ `);if(t!==``)try{yield JSON.parse(t)}catch(e){throw new oa(`MalformedResponse`,{cause:e})}r=s.indexOf(`
22
+
23
+ `)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}});return{server:{info:e=>a({method:`GET`,path:`/api/info`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),pair:e=>a({method:`POST`,path:`/api/pair`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),connect:(e,t)=>a({method:`GET`,path:`/auth/connect/${encodeURIComponent(e.code)}`,successStatus:200,declaredStatuses:[400,401],empty:!1},t)},location:{get:(e,t)=>a({method:`GET`,path:`/api/location`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),reload:e=>a({method:`POST`,path:`/api/location/reload`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e)},agent:{list:(e,t)=>a({method:`GET`,path:`/api/agent`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},plugin:{list:(e,t)=>a({method:`GET`,path:`/api/plugin`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),gui:(e,t)=>a({method:`GET`,path:`/api/plugin/gui`,query:{location:e.location,id:e.id},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),check:(e,t)=>a({method:`POST`,path:`/api/plugin/check`,query:{location:e?.location},body:{target:e?.target},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`POST`,path:`/api/plugin/update`,query:{location:e.location},body:{targets:e.targets},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t)},session:{list:(e,t)=>a({method:`GET`,path:`/api/session`,query:{limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,archived:e?.archived,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},t),stats:(e,t)=>a({method:`GET`,path:`/api/experimental/session/stats`,query:{from:e?.from,to:e?.to,project:e?.project,timezone:e?.timezone,tools:e?.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session`,body:{id:e?.id,parentID:e?.parentID,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,metadata:e?.metadata,permissions:e?.permissions},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),import:(e,t)=>a({method:`POST`,path:`/api/experimental/session/import`,body:{info:e.info,messages:e.messages,location:e.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),export:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/export`,query:{sanitize:e.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),active:e=>a({method:`GET`,path:`/api/session/active`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),fork:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{before:e.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),switchAgent:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),switchModel:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,body:{title:e.title,metadata:e.metadata,permissions:e.permissions,archived:e.archived},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),move:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),prompt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,skills:e.skills,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),command:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{name:e.name,text:e.text,files:e.files,agents:e.agents,skills:e.skills,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},t),skill:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,resume:e.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),synthetic:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),shell:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),compact:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id,delivery:e.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),revert:{stage:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},t).then(e=>e.data),clear:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},t),commit:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},context:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),diff:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/diff`,query:{from:e.from,to:e.to,context:e.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),inbox:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,body:{delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},instructions:{entry:{list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),put:(e,t)=>a({method:`PUT`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},generate:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),log:(e,t)=>o({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),interrupt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,query:{resume:e.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),background:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),message:{get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data)},form:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,query:{message:e.message},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},environment:(e,t)=>a({method:`PUT`,path:`/api/session/${encodeURIComponent(e.sessionID)}/environment`,body:{variables:e.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),view:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/view`,body:{idle:e.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},message:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor,type:e.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},model:{list:(e,t)=>a({method:`GET`,path:`/api/model`,query:{location:e?.location,types:e?.types},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),default:(e,t)=>a({method:`GET`,path:`/api/model/default`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},generate:{text:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/text`,body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),image:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/image`,body:{model:e.model,prompt:e.prompt,images:e.images,n:e.n,aspect:e.aspect,resolution:e.resolution},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data),decisions:(e,t)=>a({method:`POST`,path:`/api/experimental/generate/decisions`,body:{model:e.model,input:e.input,questions:e.questions},successStatus:200,declaredStatuses:[400,401,404,422,502,503],empty:!1},t).then(e=>e.data)},voice:{models:e=>a({method:`GET`,path:`/api/experimental/voice/models`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},e).then(e=>e.data),session:(e,t)=>a({method:`POST`,path:`/api/experimental/voice/session`,body:{model:e.model,session:e.session,transport:e.transport},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data)},provider:{list:(e,t)=>a({method:`GET`,path:`/api/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},integration:{list:(e,t)=>a({method:`GET`,path:`/api/integration`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),wellknown:{add:(e,t)=>a({method:`POST`,path:`/api/experimental/integration/wellknown`,query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},connect:{key:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),external:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/external`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},oauth:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),complete:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},mcp:{list:(e,t)=>a({method:`GET`,path:`/api/mcp`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),add:(e,t)=>a({method:`PUT`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),disconnect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},client:{token:(e,t)=>a({method:`POST`,path:`/api/experimental/client-mcp/token`,query:{location:e.location,name:e.name},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},credential:{list:e=>a({method:`GET`,path:`/api/credential`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/credential`,body:{id:e.id,integrationID:e.integrationID,label:e.label,value:e.value,activate:e.activate},successStatus:200,declaredStatuses:[400,401,409],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,body:{label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},t),activate:(e,t)=>a({method:`POST`,path:`/api/credential/${encodeURIComponent(e.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},project:{list:(e,t)=>a({method:`GET`,path:`/api/project`,query:{archived:e?.archived},successStatus:200,declaredStatuses:[400,401],empty:!1},t),update:(e,t)=>a({method:`PATCH`,path:`/api/project/${encodeURIComponent(e.projectID)}`,body:{canonical:e.canonical,name:e.name,icon:e.icon,commands:e.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},form:{list:(e,t)=>a({method:`GET`,path:`/api/form`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},permission:{request:{list:(e,t)=>a({method:`GET`,path:`/api/permission/request`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},saved:{list:(e,t)=>a({method:`GET`,path:`/api/permission/saved`,query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PATCH`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,body:{action:e.action,resource:e.resource},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{decision:e.decision,message:e.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},file:{read:(e,t)=>a({method:`GET`,path:`/api/fs/read/${la(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t),list:(e,t)=>a({method:`GET`,path:`/api/fs/list`,query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),find:(e,t)=>a({method:`GET`,path:`/api/fs/find`,query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),write:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/write`,query:{location:e.location,path:e.path},body:e.payload,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binaryBody:!0},t),watch:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),unwatch:(e,t)=>a({method:`DELETE`,path:`/api/experimental/fs/watch`,query:{location:e.location},body:{path:e.path},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},command:{list:(e,t)=>a({method:`GET`,path:`/api/command`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},skill:{list:(e,t)=>a({method:`GET`,path:`/api/skill`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},rpc:{call:(e,t)=>a({method:`POST`,path:`/api/rpc/${encodeURIComponent(e.rpcID)}/${encodeURIComponent(e.method)}`,query:{location:e.location},body:{input:e.input},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},event:{subscribe:(e,t)=>o({method:`GET`,path:`/api/event`,query:{types:e?.types},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},pty:{list:(e,t)=>a({method:`GET`,path:`/api/pty`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/pty`,query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`PUT`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:{token:(e,t)=>a({method:`POST`,path:`/api/pty/${encodeURIComponent(e.ptyID)}/connect-token`,query:{location:e.location},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},experimental:{persistentPty:{read:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal/read`,query:{lines:e.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,body:{command:e.command,args:e.args,cwd:e.cwd,title:e.title,env:e.env,size:e.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),shutdown:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/shutdown`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e),handoff:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/handoff`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},e),get:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PUT`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,body:{attachmentID:e.attachmentID,size:e.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),snapshot:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),connectToken:(e,t)=>a({method:`POST`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/connect-token`,headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},t).then(e=>e.data)},media:{get:(e,t)=>a({method:`GET`,path:`/api/experimental/media/${encodeURIComponent(e.hash)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t)}},shell:{list:(e,t)=>a({method:`GET`,path:`/api/shell`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/shell`,query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),output:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},reference:{list:(e,t)=>a({method:`GET`,path:`/api/reference`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},worktree:{list:(e,t)=>a({method:`GET`,path:`/api/worktree`,query:{projectID:e.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/worktree`,body:{projectID:e.projectID,from:e.from,branch:e.branch,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/worktree`,body:{projectID:e.projectID,directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),refresh:(e,t)=>a({method:`POST`,path:`/api/worktree/refresh`,body:{projectID:e.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},vcs:{init:(e,t)=>a({method:`POST`,path:`/api/vcs/init`,query:{location:e?.location,provider:e?.provider},successStatus:204,declaredStatuses:[400,401,404,409,501,503],empty:!0},t),get:(e,t)=>a({method:`GET`,path:`/api/vcs`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),base:(e,t)=>a({method:`GET`,path:`/api/vcs/base`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/vcs/status`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),branch:{list:(e,t)=>a({method:`GET`,path:`/api/vcs/branch`,query:{location:e?.location,search:e?.search,limit:e?.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},diff:(e,t)=>a({method:`GET`,path:`/api/vcs/diff`,query:{location:e.location,mode:e.mode,base:e.base,context:e.context,untracked:e.untracked},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},debug:{heapDump:(e,t)=>a({method:`POST`,path:`/api/debug/heap-dump`,query:{directory:e?.directory},successStatus:200,declaredStatuses:[400,401,500],empty:!1},t),location:{list:e=>a({method:`GET`,path:`/api/debug/location`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),evict:(e,t)=>a({method:`DELETE`,path:`/api/debug/location`,query:{location:e?.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},websearch:{providers:(e,t)=>a({method:`GET`,path:`/api/websearch/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t),query:(e,t)=>a({method:`POST`,path:`/api/websearch`,query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},usage:{limits:(e,t)=>a({method:`GET`,path:`/api/experimental/usage/limits`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},config:{get:(e,t)=>a({method:`GET`,path:`/api/config`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),shells:e=>a({method:`GET`,path:`/api/config/shell`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},e),update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}}}function la(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function ua(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)ua(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))ua(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function da(e){if(!pa(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new oa(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new oa(`Transport`,{cause:e})}if(t===``)throw new oa(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new oa(`MalformedResponse`,{cause:e})}}function fa(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function pa(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var ma=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidRequestError`,ha=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnauthorizedError`,ga=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,_a=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ServiceUnavailableError`,va=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AgentNotFoundError`,ya=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PluginNotFoundError`,ba=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidCursorError`,xa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionNotFoundError`,Sa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ConflictError`,Ca=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnknownError`,wa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`MessageNotFoundError`,Ta=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandNotFoundError`,Ea=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandExecutionError`,Da=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SkillNotFoundError`,Oa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionBusyError`,ka=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InstructionEntryValueTooLargeError`,Aa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormNotFoundError`,ja=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormInvalidAnswerError`,Ma=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormAlreadySettledError`,Na=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderNotFoundError`,Pa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ModelNotFoundError`,Fa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnsupportedModelError`,Ia=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderRequestError`,La=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationNotFoundError`,Ra=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationAttemptNotFoundError`,za=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationMethodNotFoundError`,Ba=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`McpServerNotFoundError`,Va=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ForbiddenError`,Ha=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProjectNotFoundError`,Ua=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionSavedNotFoundError`,Wa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Ga=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FileNotFoundError`,Ka=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,qa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`,Ja=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PtyNotFoundError`,Ya=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ShellNotFoundError`,Xa=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`WorktreeError`,Za=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`VcsInitNotSupportedError`;function Qa(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=$a(n,e);return{[Symbol.asyncIterator](){let e=new AbortController,n=r?.signal?AbortSignal.any([e.signal,r.signal]):e.signal,a=async function*(){try{for await(let e of t.subscribe({signal:n})){if(n.aborted)return;e.type===i&&(yield e)}}catch(e){if(!n.aborted)throw e}finally{e.abort()}}();return{next:()=>a.next(),return:()=>(e.abort(),a.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(t=>[t,async(r,i)=>{try{return(await e.rpc.call({rpcID:n.id,method:t,input:r,location:i?.location},{signal:i?.signal,headers:i?.headers})).output}catch(e){throw!Ka(e)&&!qa(e)?e:e.data===void 0?{type:e.type,message:e.message}:{type:e.type,message:e.message,data:e.data}}}])),{events:{subscribe:r,on:(e,t,n)=>{let i=new AbortController,a=n?.signal?AbortSignal.any([i.signal,n.signal]):i.signal,o=r(e,{signal:a});return(async()=>{for await(let e of o)await t(e)})().catch(e=>console.error(e)),()=>i.abort()}}})}}function $a(e,t){return`rpc.${e.id}.${t}`}var eo={};ra(eo,{OpenCode:()=>eo,make:()=>to});function to(e){let t=ca(e),n=aa((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(Qa(t,n),t.rpc),event:n}}var no=e({ClientError:()=>oa,OpenCode:()=>eo,isAgentNotFoundError:()=>va,isCommandExecutionError:()=>Ea,isCommandNotFoundError:()=>Ta,isConflictError:()=>Sa,isFileNotFoundError:()=>Ga,isForbiddenError:()=>Va,isFormAlreadySettledError:()=>Ma,isFormInvalidAnswerError:()=>ja,isFormNotFoundError:()=>Aa,isInstructionEntryValueTooLargeError:()=>ka,isIntegrationAttemptNotFoundError:()=>Ra,isIntegrationMethodNotFoundError:()=>za,isIntegrationNotFoundError:()=>La,isInvalidCursorError:()=>ba,isInvalidRequestError:()=>ma,isLocationNotFoundError:()=>ga,isMcpServerNotFoundError:()=>Ba,isMessageNotFoundError:()=>wa,isModelNotFoundError:()=>Pa,isPermissionNotFoundError:()=>Wa,isPermissionSavedNotFoundError:()=>Ua,isPluginNotFoundError:()=>ya,isProjectNotFoundError:()=>Ha,isProviderNotFoundError:()=>Na,isProviderRequestError:()=>Ia,isPtyNotFoundError:()=>Ja,isRpcError:()=>Ka,isRpcInternalError:()=>qa,isServiceUnavailableError:()=>_a,isSessionBusyError:()=>Oa,isSessionNotFoundError:()=>xa,isShellNotFoundError:()=>Ya,isSkillNotFoundError:()=>Da,isUnauthorizedError:()=>ha,isUnknownError:()=>Ca,isUnsupportedModelError:()=>Fa,isVcsInitNotSupportedError:()=>Za,isWorktreeError:()=>Xa}),ro=class extends t()(`ClientError`,{cause:ue()}){},R=a.check(ze(0)),z=a.check(Mt(0)),io=y.pipe(A(`RelativePath`),D({identifier:`RelativePath`})),ao=y.pipe(A(`AbsolutePath`),D({identifier:`AbsolutePath`})),B=e=>fe(e).pipe(wt(w(Ft(e)),{decode:le({strict:!1}),encode:se(jt(e=>e!==void 0))})),oo=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),so=e=>t=>oo(t,e(t)),co=N.pipe(wt(ie,{decode:_t(e=>je(e)),encode:_t(e=>_e(e))})),lo=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,uo=0,fo=0;function po(){return ho(!1)}function mo(){return ho(!0)}function ho(e,t=Date.now()){t!==uo&&(uo=t,fo=0),fo++;let n=BigInt(t)*4096n+BigInt(fo),r=e?~n:n,i=Array.from({length:6},(e,t)=>Number(r>>BigInt(40-8*t)&255n).toString(16).padStart(2,`0`)).join(``),a=crypto.getRandomValues(new Uint8Array(14));return i+Array.from(a,e=>lo[e%62]).join(``)}var go=y.pipe(A(`Project.ID`),D({identifier:`Project.ID`}),so(e=>({global:e.make(`global`)}))),_o=y.check(at(`wrk`)).pipe(A(`Workspace.ID`),D({identifier:`Workspace.ID`}),so(e=>{let t=()=>e.make(`wrk_`+po());return{ascending:n=>n?e.make(n):t(),create:t}})),vo=e({Info:()=>xo,Location:()=>vo,PublicInfo:()=>So,PublicRef:()=>bo,Ref:()=>yo,response:()=>V}),yo=x({directory:ao,workspaceID:B(_o)}).annotate({identifier:`Location.Ref`}),bo=x(re(yo.fields,[`workspaceID`])).annotate({identifier:`Location.PublicRef`}),xo=class extends p(`Location.Info`)({directory:ao,workspaceID:B(_o),project:x({id:go,directory:ao,canonical:ao})}){},So=x(re(xo.fields,[`workspaceID`])).annotate({identifier:`Location.PublicInfo`});function V(e){return x({location:bo,data:e})}var Co=e({Event:()=>Co,ID:()=>wo,Seq:()=>To,Version:()=>Eo,durable:()=>H,durableMap:()=>Ao,ephemeral:()=>U,inventory:()=>W,latest:()=>Oo,versionedType:()=>ko}),wo=y.check(at(`evt_`)).pipe(A(`Event.ID`),D({identifier:`Event.ID`}),so(e=>({create:()=>e.make(`evt_`+po())}))),To=a.check(Mt(0)).pipe(A(`Event.Seq`),D({identifier:`Event.Seq`})),Eo=a.check(Mt(1)).pipe(A(`Event.Version`),D({identifier:`Event.Version`})),Do=x({aggregateID:y,seq:To,version:Eo});function H(e){let t=x(e.schema),n=x({aggregateID:Do.fields.aggregateID,seq:Do.fields.seq,version:m(e.durable.version).pipe(wt(Ft(Eo),ne({decode:()=>Eo.make(e.durable.version),encode:()=>e.durable.version})))});return x({id:wo,created:N,metadata:B(b(y,Ie)),type:m(e.type),durable:n,location:B(yo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(so(()=>({type:e.type,durability:`durable`,durable:e.durable,data:t})))}function U(e){let t=x(e.schema);return x({id:wo,created:N,metadata:B(b(y,Ie)),type:m(e.type),location:B(yo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(so(()=>({type:e.type,durability:`ephemeral`,durable:void 0,data:t})))}function W(...e){return Object.freeze(e)}function Oo(e){return jo(e.reduce((e,t)=>{let n=e.get(t.type);if(!n)return e.set(t.type,t),e;if(t.durable&&n.durable&&t.durable.version!==n.durable.version)return t.durable.version>n.durable.version&&e.set(t.type,t),e;if(t!==n)throw Error(`Duplicate latest event definition for ${t.type}`);return e},new Map))}function ko(e,t){return`${e}.${t}`}function Ao(e){return jo(e.reduce((e,t)=>{if(t.durability!==`durable`)return e;let n=ko(t.type,t.durable.version);if(e.has(n))throw Error(`Duplicate durable event definition for ${n}`);return e.set(n,t),e},new Map))}function jo(e){let t=Object.freeze({get size(){return e.size},entries:()=>e.entries(),forEach:(n,r)=>e.forEach((e,i)=>n.call(r,e,i,t)),get:t=>e.get(t),has:t=>e.has(t),keys:()=>e.keys(),values:()=>e.values(),[Symbol.iterator]:()=>e[Symbol.iterator]()});return t}var Mo=e({DirectorySource:()=>Fo,EmbeddedSource:()=>Bo,Event:()=>zo,ID:()=>No,Info:()=>Lo,Name:()=>Po,Skill:()=>Mo,Source:()=>Vo,UrlSource:()=>Io}),No=y.pipe(A(`Skill.ID`),D({identifier:`Skill.ID`})),Po=y.pipe(A(`Skill.Name`),D({identifier:`Skill.Name`})),Fo=x({type:_(`directory`),path:ao}).annotate({identifier:`Skill.DirectorySource`}),Io=x({type:_(`url`),url:y}).annotate({identifier:`Skill.UrlSource`}),Lo=x({id:No,name:Po,description:y.pipe(B),autoinvoke:g.pipe(B),path:ao,content:y}).annotate({identifier:`Skill.Info`}),Ro=U({type:`skill.updated`,schema:{}}),zo={Updated:Ro,Definitions:W(Ro)},Bo=x({type:_(`embedded`),skill:pe(()=>Lo)}).annotate({identifier:`Skill.EmbeddedSource`}),Vo=Object.assign(C([Fo,Io,Bo]).pipe(ye(`type`),D({identifier:`Skill.Source`})),{equals:(e,t)=>e.type===t.type?e.type===`directory`&&t.type===`directory`?e.path===t.path:e.type===`url`&&t.type===`url`?e.url===t.url:e.type===`embedded`&&t.type===`embedded`&&e.skill.id===t.skill.id:!1,key:e=>e.type===`directory`?`directory:${e.path}`:e.type===`url`?`url:${e.url}`:`embedded:${e.skill.id}`}),Ho=class extends t()(`LocationNotFoundError`,{location:bo,message:y},{httpApiStatus:404}){},Uo=class extends t()(`InvalidRequestError`,{message:y,kind:w(y),field:w(y)},{httpApiStatus:400}){},Wo=class extends t()(`RpcError`,{type:y,message:y,data:w(Ie)},{httpApiStatus:400}){},Go=class extends t()(`RpcInternalError`,{type:v([`rpc.internal`,`rpc.invalid_output`]),message:y,data:w(Ie)},{httpApiStatus:500}){},Ko=class extends t()(`UnauthorizedError`,{message:y},{httpApiStatus:401}){},qo=class extends t()(`ConflictError`,{message:y,resource:w(y)},{httpApiStatus:409}){},Jo=class extends t()(`SessionBusyError`,{sessionID:y,message:y},{httpApiStatus:409}){},Yo=class extends t()(`ServiceUnavailableError`,{message:y,service:w(y)},{httpApiStatus:503}){},Xo=class extends t()(`UnknownError`,{message:y,ref:w(y)},{httpApiStatus:500}){},Zo=class extends t()(`ProviderNotFoundError`,{providerID:y,message:y},{httpApiStatus:404}){},Qo=class extends t()(`IntegrationNotFoundError`,{integrationID:y,message:y},{httpApiStatus:404}){},$o=class extends t()(`IntegrationAttemptNotFoundError`,{integrationID:y,attemptID:y,message:y},{httpApiStatus:404}){},es=class extends t()(`IntegrationMethodNotFoundError`,{integrationID:y,methodID:y,message:y},{httpApiStatus:404}){},ts=class extends t()(`ProjectNotFoundError`,{projectID:y,message:y},{httpApiStatus:404}){},ns=class extends t()(`FileNotFoundError`,{path:y,message:y},{httpApiStatus:404}){},rs=class extends t()(`PluginNotFoundError`,{pluginID:y,message:y},{httpApiStatus:404}){},is=class extends t()(`AgentNotFoundError`,{agentID:y,message:y},{httpApiStatus:404}){},G=class extends t()(`SessionNotFoundError`,{sessionID:y,message:y},{httpApiStatus:404}){},as=class extends t()(`MessageNotFoundError`,{sessionID:y,messageID:y,message:y},{httpApiStatus:404}){},os=class extends t()(`SkillNotFoundError`,{skill:No,message:y},{httpApiStatus:404}){},ss=class extends t()(`McpServerNotFoundError`,{server:y,message:y},{httpApiStatus:404}){},cs=class extends t()(`CommandNotFoundError`,{command:y,message:y},{httpApiStatus:404}){},ls=class extends t()(`CommandExecutionError`,{command:y,message:y},{httpApiStatus:500}){},us=class extends t()(`InvalidCursorError`,{message:y},{httpApiStatus:400}){},ds=class extends t()(`PermissionNotFoundError`,{requestID:y,message:y},{httpApiStatus:404}){},fs=class extends t()(`PermissionSavedNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},ps=class extends t()(`FormNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},ms=class extends t()(`FormAlreadySettledError`,{id:y,message:y},{httpApiStatus:409}){},hs=class extends t()(`FormInvalidAnswerError`,{id:y,message:y},{httpApiStatus:400}){},gs=class extends t()(`ForbiddenError`,{message:y},{httpApiStatus:403}){},_s=class extends t()(`PtyNotFoundError`,{ptyID:y,message:y},{httpApiStatus:404}){},vs=class extends t()(`ShellNotFoundError`,{id:y,message:y},{httpApiStatus:404}){},ys=class extends t()(`ModelNotFoundError`,{providerID:y,modelID:y,message:y},{httpApiStatus:404}){},bs=class extends t()(`UnsupportedModelError`,{providerID:y,modelID:y,capability:y,message:y},{httpApiStatus:422}){},xs=class extends t()(`ProviderRequestError`,{providerID:y,reason:v([`authentication`,`rate_limit`,`content_filter`,`invalid_request`,`overloaded`,`provider`]),message:y,status:w(a),retryAfterMs:w(a)},{httpApiStatus:502}){},Ss=class extends tt()(`@opencode/HttpApiSchemaError`,{error:Uo}){},Cs=y.pipe(A(`Integration.ID`),D({identifier:`Integration.ID`})),ws=y.pipe(A(`Integration.MethodID`),D({identifier:`Integration.MethodID`})),Ts=e({CreateInput:()=>Fs,Credential:()=>Ts,Entry:()=>Ps,Event:()=>ks,External:()=>Ms,ID:()=>Es,Key:()=>js,OAuth:()=>As,Value:()=>Ns}),Es=y.pipe(A(`Credential.ID`),D({identifier:`Credential.ID`}),so(e=>({create:()=>e.make(`cred_`+po())}))),Ds=U({type:`credential.updated`,schema:{}}),Os=U({type:`credential.switched`,schema:{integrationID:Cs,credentialID:ce(Es)}}),ks={Updated:Ds,Switched:Os,Definitions:W(Ds,Os)},As=x({type:m(`oauth`),methodID:ws,refresh:y,access:y,expires:z,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.OAuth`}),js=x({type:m(`key`),key:y,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.Key`}),Ms=x({type:m(`external`),methodID:ws,metadata:B(b(y,Ie))}).annotate({identifier:`Credential.External`}),Ns=C([As,js,Ms]).pipe(ye(`type`)).annotate({identifier:`Credential.Value`}),Ps=x({id:Es,integrationID:Cs,label:y,active:g,value:Ns}).annotate({identifier:`Credential.Entry`}),Fs=x({id:B(Es),integrationID:Cs,label:B(y),value:Ns,activate:B(g)}).annotate({identifier:`Credential.CreateInput`}),Is=x({status:v([`needs_auth`]),message:y,url:B(y)}).annotate({identifier:`Connection.Status`}),Ls=x({type:m(`credential`),id:Es,label:y,method:v([`key`,`oauth`,`external`]),status:B(Is)}).annotate({identifier:`Connection.CredentialInfo`}),Rs=x({type:m(`env`),name:y,status:B(Is)}).annotate({identifier:`Connection.EnvInfo`}),zs=C([Ls,Rs]).pipe(ye(`type`)).annotate({identifier:`Connection.Info`}),Bs=e({Answer:()=>rc,BooleanField:()=>Ys,Detail:()=>ac,Event:()=>uc,ExternalField:()=>Zs,Field:()=>Qs,Fields:()=>$s,Form:()=>Bs,ID:()=>Vs,Info:()=>tc,IntegerField:()=>Js,Metadata:()=>Hs,MultiselectField:()=>Xs,NumberField:()=>qs,Option:()=>Us,Reply:()=>oc,State:()=>ic,StringField:()=>Ks,Value:()=>nc,When:()=>Ws}),Vs=y.check(at(`frm_`)).pipe(A(`Form.ID`),D({identifier:`Form.ID`})).pipe(so(e=>({create:t=>e.make(t??`frm_`+po())}))),Hs=b(y,Ie).annotate({identifier:`Form.Metadata`}),Us=x({value:y,label:y,description:y.pipe(B)}).annotate({identifier:`Form.Option`}),Ws=x({key:y,op:v([`eq`,`neq`]),value:C([y,gt,g])}).annotate({identifier:`Form.When`}),Gs={key:y,title:y.pipe(B),description:y.pipe(B),required:g.pipe(B),hidden:g.pipe(B).annotate({description:`Skip the interactive authentication prompt and use the default unless an answer is supplied`}),when:h(Ws).pipe(B)},Ks=x({...Gs,type:m(`string`),format:v([`email`,`uri`,`date`,`date-time`]).pipe(B),minLength:z.pipe(B),maxLength:z.pipe(B),pattern:y.pipe(B),placeholder:y.pipe(B),default:y.pipe(B),options:h(Us).pipe(B),custom:g.pipe(B)}).annotate({identifier:`Form.StringField`}),qs=x({...Gs,type:m(`number`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.NumberField`}),Js=x({...Gs,type:m(`integer`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.IntegerField`}),Ys=x({...Gs,type:m(`boolean`),default:g.pipe(B)}).annotate({identifier:`Form.BooleanField`}),Xs=x({...Gs,type:m(`multiselect`),options:h(Us),minItems:z.pipe(B),maxItems:z.pipe(B),custom:g.pipe(B),default:h(y).pipe(B)}).annotate({identifier:`Form.MultiselectField`}),Zs=x({key:y,type:m(`external`),url:y,title:y.pipe(B),description:y.pipe(B)}).annotate({identifier:`Form.ExternalField`}),Qs=C([Ks,qs,Js,Ys,Xs,Zs]).pipe(ye(`type`),D({identifier:`Form.Field`})),$s=De(Qs).annotate({identifier:`Form.Fields`}),ec={id:Vs,sessionID:y,title:y,metadata:Hs.pipe(B)},tc=x({...ec,fields:$s}).annotate({identifier:`Form.Info`}),nc=C([y,gt,g,h(y)]).annotate({identifier:`Form.Value`}),rc=b(y,nc).annotate({identifier:`Form.Answer`}),ic=C([x({status:m(`pending`)}),x({status:m(`answered`),answer:rc}),x({status:m(`cancelled`),message:y.pipe(B)})]).pipe(ye(`status`)).annotate({identifier:`Form.State`}),ac=x({...tc.fields,state:ic}).annotate({identifier:`Form.Detail`}),oc=x({answer:rc}).annotate({identifier:`Form.Reply`}),sc=U({type:`form.created`,schema:{form:tc}}),cc=U({type:`form.replied`,schema:{id:Vs,sessionID:y,answer:rc}}),lc=U({type:`form.cancelled`,schema:{id:Vs,sessionID:y}}),uc={Created:sc,Replied:cc,Cancelled:lc,Definitions:W(sc,cc,lc)},dc=e({Attempt:()=>Ec,AttemptID:()=>wc,AttemptStatus:()=>Dc,CommandAttempt:()=>Oc,CommandAttemptStatus:()=>kc,CommandMethod:()=>hc,EnvMethod:()=>vc,Event:()=>xc,ExternalMethod:()=>_c,ID:()=>fc,Info:()=>Cc,Integration:()=>dc,KeyMethod:()=>gc,Method:()=>yc,MethodID:()=>pc,OAuthMethod:()=>mc,Ref:()=>Sc}),fc=Cs,pc=ws,mc=x({id:pc,type:m(`oauth`),label:y,form:B($s)}).annotate({identifier:`Integration.OAuthMethod`}),hc=x({id:pc,type:m(`command`),label:y,command:h(y)}).annotate({identifier:`Integration.CommandMethod`}),gc=x({type:m(`key`),label:B(y),form:B($s)}).annotate({identifier:`Integration.KeyMethod`}),_c=x({id:pc,type:m(`external`),label:y,form:B($s)}).annotate({identifier:`Integration.ExternalMethod`}),vc=x({type:m(`env`),names:h(y)}).annotate({identifier:`Integration.EnvMethod`}),yc=C([mc,hc,gc,_c,vc]).pipe(ye(`type`)).annotate({identifier:`Integration.Method`}),bc=U({type:`integration.updated`,schema:{}}),xc={Updated:bc,Definitions:W(bc)},Sc=x({id:fc,name:y,metadata:B(b(y,rt))}).annotate({identifier:`Integration.Ref`}),Cc=x({id:fc,name:y,metadata:B(b(y,rt)),methods:h(yc),connections:h(zs)}).annotate({identifier:`Integration.Info`}),wc=y.pipe(A(`Integration.AttemptID`),D({identifier:`Integration.AttemptID`}),so(e=>({create:()=>e.make(`con_`+po())}))),Tc=x({created:gt,expires:gt}),Ec=class extends p(`Integration.Attempt`)({attemptID:wc,url:y,instructions:y,mode:v([`auto`,`code`]),time:Tc}){},Dc=C([x({status:m(`pending`),time:Tc}),x({status:m(`complete`),time:Tc}),x({status:m(`failed`),message:y,time:Tc}),x({status:m(`expired`),time:Tc})]).pipe(ye(`status`)).annotate({identifier:`Integration.AttemptStatus`}),Oc=x({attemptID:wc,time:Tc}).annotate({identifier:`Integration.CommandAttempt`}),kc=C([x({status:m(`pending`),message:B(y),time:Tc}),x({status:m(`complete`),time:Tc}),x({status:m(`failed`),message:y,time:Tc}),x({status:m(`expired`),time:Tc})]).pipe(ye(`status`)).annotate({identifier:`Integration.CommandAttemptStatus`}),Ac=C([v([`reasoning`,`reasoning_content`,`reasoning_text`]),y]).annotate({identifier:`Model.ReasoningField`}),jc=v([`max_completion_tokens`,`max_tokens`]).annotate({identifier:`Model.MaxTokensField`}),Mc=v([`assets`,`state`,`root`]).annotate({identifier:`Model.MediaInput`}),Nc=v([`anthropic`,`alibaba`]).annotate({identifier:`Model.CacheFormat`}),Pc=x({reasoningField:Ac.pipe(B),requireReasoning:g.pipe(B),maxTokensField:jc.pipe(B),requireFinishReason:g.pipe(B),requireAssistantAfterTool:g.pipe(B),supportsPromptCacheKey:g.pipe(B),streamUsage:g.pipe(B),cacheFormat:Nc.pipe(B),supportsThinkingBlockBinding:g.pipe(B),supportsEffortUpdates:g.pipe(B),mediaInput:Mc.pipe(B)}).annotate({identifier:`Model.Compatibility`}),Fc=x(re(Pc.fields,[`supportsThinkingBlockBinding`,`supportsEffortUpdates`])).annotate({identifier:`Provider.Compatibility`}),Ic=e({Activation:()=>Vc,Cache:()=>Gc,CacheTTL:()=>Wc,Compaction:()=>Hc,Encoding:()=>Kc,Event:()=>zc,ID:()=>Lc,Info:()=>Zc,Overlays:()=>Yc,Package:()=>Bc,Provider:()=>Ic,Request:()=>Xc,Settings:()=>Jc,Transport:()=>Uc}),Lc=y.pipe(A(`Provider.ID`),D({identifier:`Provider.ID`}),so(e=>({opencode:e.make(`opencode`),anthropic:e.make(`anthropic`),openai:e.make(`openai`),google:e.make(`google`),googleVertex:e.make(`google-vertex`),githubCopilot:e.make(`github-copilot`),amazonBedrock:e.make(`amazon-bedrock`),azure:e.make(`azure`),openrouter:e.make(`openrouter`),mistral:e.make(`mistral`),gitlab:e.make(`gitlab`)}))),Rc=U({type:`provider.updated`,schema:{}}),zc={Updated:Rc,Definitions:W(Rc)},Bc=y,Vc=v([`auto`,`enabled`,`disabled`]),Hc=C([x({type:m(`summary`)}),x({type:m(`native`)})]).pipe(ye(`type`)).annotate({identifier:`Provider.Compaction`}),Uc=v([`http`,`websocket`]).annotate({identifier:`Provider.Transport`}),Wc=Ke([gt,v([`ms`,`s`,`m`,`h`,`d`])]).check(f(/^\d+(ms|s|m|h|d)$/)).annotate({identifier:`Provider.CacheTTL`}),Gc=x({ttl:Wc.pipe(B)}).annotate({identifier:`Provider.Cache`}),Kc=v([`zstd`,`gzip`,`none`]).annotate({identifier:`Provider.Encoding`}),qc=C([N,m(!1)]).pipe(B),Jc=ge(x({timeout:qc,headerTimeout:qc,chunkTimeout:qc,compaction:Hc.pipe(B),cache:Gc.pipe(B),transport:Uc.pipe(B),encoding:Kc.pipe(B)}),[b(y,rt)]).annotate({identifier:`Provider.Settings`}),Yc={settings:Jc.pipe(B),headers:b(y,y).pipe(B),body:b(y,rt).pipe(B)},Xc=x({settings:Jc.pipe(o(ht({}))),headers:b(y,y),body:b(y,rt)}).annotate({identifier:`Provider.Request`}),Zc=x({id:Lc,canonical:Lc.pipe(B),integrationID:fc.pipe(B),name:y,activation:Vc,package:Bc,compatibility:Fc.pipe(B),...Yc}).annotate({identifier:`Provider.Info`}).pipe(so(()=>({empty:e=>({id:e,name:e,activation:`auto`,package:``})}))),Qc=N.pipe(A(`Money.USD`),D({identifier:`Money.USD`}),so(e=>({zero:e.make(0)}))),$c=N.pipe(A(`Money.USDPerMillionTokens`),D({identifier:`Money.USDPerMillionTokens`}),so(e=>({zero:e.make(0)}))),el=e({Capabilities:()=>ul,Compatibility:()=>Pc,Cost:()=>dl,Event:()=>rl,Family:()=>ol,ID:()=>tl,Info:()=>pl,MaxTokensField:()=>jc,MediaInput:()=>Mc,Model:()=>el,Overlays:()=>ll,ReasoningField:()=>Ac,Ref:()=>al,Settings:()=>cl,Type:()=>sl,Variant:()=>fl,VariantID:()=>il}),tl=y.pipe(A(`Model.ID`)),nl=U({type:`model.updated`,schema:{}}),rl={Updated:nl,Definitions:W(nl)},il=y.pipe(A(`Model.VariantID`)),al=x({id:tl,providerID:Lc,variant:il.pipe(B)}).annotate({identifier:`Model.Ref`}).pipe(so(e=>({parse:t=>{let n=t.indexOf(`/`);if(n<=0)throw Error(`Invalid model reference: ${t}`);let r=t.slice(0,n),i=t.indexOf(`#`,n+1),a=t.slice(n+1,i===-1?void 0:i),o=i===-1?void 0:t.slice(i+1);if(!a||r.includes(`#`)||o!==void 0&&(!o||o.includes(`#`)))throw Error(`Invalid model reference: ${t}`);return e.make({providerID:Lc.make(r),id:tl.make(a),...o?{variant:il.make(o)}:{}})}}))),ol=y.pipe(A(`Model.Family`)),sl=C([v([`chat`,`decision`,`image`]),y]).annotate({identifier:`Model.Type`}),cl=ge(x(we(Jc.schema.fields,[`compaction`,`cache`,`encoding`])),[b(y,rt)]).annotate({identifier:`Model.Settings`}),ll={settings:cl.pipe(B),headers:b(y,y).pipe(B),body:b(y,rt).pipe(B)},ul=x({tools:g,input:h(y),output:h(y),temperature:g.pipe(B)}).annotate({identifier:`Model.Capabilities`}).pipe(so(()=>({default:()=>({tools:!0,input:[`text`,`image`],output:[`text`]})}))),dl=x({tier:x({type:_(`context`),size:a}).pipe(B),input:$c,output:$c,cache:x({read:$c,write:$c})}).annotate({identifier:`Model.Cost`}),fl=x({id:il,...ll}).annotate({identifier:`Model.Variant`}),pl=x({id:tl,modelID:tl,providerID:Lc,canonical:Lc.pipe(B),type:sl.pipe(B),family:ol.pipe(B),name:y,compatibility:Pc.pipe(B),package:Bc.pipe(B),...ll,capabilities:ul,variants:h(fl),time:x({released:N}),cost:h(dl),status:v([`alpha`,`beta`,`deprecated`,`active`]),enabled:g,limit:x({context:a,input:a.pipe(B),output:a})}).annotate({identifier:`Model.Info`}).pipe(so(()=>({default:(e,t)=>({id:t,modelID:t,providerID:e,name:t,capabilities:ul.default(),variants:[],time:{released:0},cost:[],status:`active`,enabled:!0,limit:{context:2e5,output:32e3}})}))),ml=x({start:N,end:N,text:y}).annotate({identifier:`Prompt.Mention`}),hl=C([x({type:m(`inline`)}),x({type:m(`uri`),uri:y})]).pipe(ye(`type`)).annotate({identifier:`Prompt.FileSource`}),gl=y.check(i(e=>e.length%4==0&&/^[A-Za-z0-9+/]*={0,2}$/u.test(e),f(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations)).annotate({identifier:`Prompt.Base64`}),_l=x({data:gl,mime:y,source:hl,name:y.pipe(B),description:y.pipe(B),mention:ml.pipe(B)}).annotate({identifier:`Prompt.FileAttachment`}).pipe(so(e=>({create:t=>e.make({data:t.data,mime:t.mime,source:t.source,name:t.name,description:t.description,mention:t.mention})}))),vl=y.check(f(/^media:[0-9a-f]{64}$/)).annotate({identifier:`Prompt.MediaRef`}),{data:yl,...bl}=_l.fields,xl=x({...bl,uri:vl,bytes:a.pipe(B),width:a.pipe(B),height:a.pipe(B)}).annotate({identifier:`Prompt.MediaFileAttachment`}),Sl=C([_l,xl]).annotate({identifier:`Prompt.Attachment`}),Cl=x({name:y,mention:ml.pipe(B)}).annotate({identifier:`Prompt.AgentAttachment`}),wl=x({id:No,name:Po,text:y.pipe(B),mention:ml.pipe(B)}).annotate({identifier:`Prompt.SkillAttachment`}),Tl=x({text:y,files:h(_l).pipe(B),agents:h(Cl).pipe(B),skills:h(wl).pipe(B)}).annotate({identifier:`Prompt`}).pipe(so(e=>({equivalence:ae(e),fromUserMessage:t=>e.make({text:t.text,...t.files===void 0?{}:{files:t.files},...t.agents===void 0?{}:{agents:t.agents},...t.skills===void 0?{}:{skills:t.skills}})}))),El=e=>({description:e}),Dl=x({data:gl,mime:y,name:y.pipe(B)}).annotate({identifier:`Generate.File`}),Ol=x({input:N.pipe(B),output:N.pipe(B)}).annotate({identifier:`Generate.Usage`,description:`Token counts, when the provider reports them`}),kl=b(y,Ie).annotate({identifier:`Generate.Native`,description:`Provider-specific data the shared fields do not cover`}),Al=Ke([gt,`:`,gt]).check(f(/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/)).annotate({identifier:`Generate.ImageAspect`,description:`Aspect ratio as width:height, for example 16:9`}),jl=C([v([`1K`,`2K`,`4K`]),y]).annotate({identifier:`Generate.ImageResolution`,description:`Size tier such as 1K, 2K or 4K; 1K is about as many pixels as 1024x1024 at the requested aspect`}),Ml=x({model:al,prompt:y,images:h(Dl).pipe(B).annotate(El(`Edit sources or style and subject references, in order`)),n:R.pipe(B).annotate(El(`Number of images to generate; defaults to 1`)),aspect:Al.pipe(B),resolution:jl.pipe(B)}).annotate({identifier:`Generate.ImageRequest`}),Nl=x({type:m(`image`),...Dl.fields}).annotate({identifier:`Generate.ImageOutput`}),Pl=x({images:h(Nl),cost:Qc.pipe(B),tokens:Ol.pipe(B),native:kl.pipe(B)}).annotate({identifier:`Generate.ImageResult`}),Fl=x({type:m(`text`),text:y}).annotate({identifier:`Generate.DecisionTextPart`}),Il=x({type:m(`json`),value:Te}).annotate({identifier:`Generate.DecisionJsonPart`}),Ll=x({type:m(`file`),...Dl.fields}).annotate({identifier:`Generate.DecisionFilePart`}),Rl=C([Fl,Il,Ll]).annotate({identifier:`Generate.DecisionPart`}),zl=C([y,g]).annotate({identifier:`Generate.ChoiceValue`,description:`Choice values are typed: true and "true" are different values`}),Bl=y.annotate(El(`Unique within the request; echoed on the matching answer`)),Vl=x({type:m(`predicate`),name:Bl,instructions:y}).annotate({identifier:`Generate.PredicateQuestion`,description:`The probability that a statement is true`}),Hl=x({type:m(`choice`),name:Bl,instructions:y,choices:h(x({value:zl,description:y.pipe(B)})).check(kt(1))}).annotate({identifier:`Generate.ChoiceQuestion`,description:`Pick one value from a fixed set`}),Ul=x({type:m(`score`),name:Bl,instructions:y,levels:h(x({label:y,description:y.pipe(B)})).check(kt(1))}).annotate({identifier:`Generate.ScoreQuestion`,description:`Place the input on ordered levels, lowest first`}),Wl=C([Vl,Hl,Ul]).annotate({identifier:`Generate.DecisionQuestion`}),Gl=x({model:al,input:h(Rl).annotate(El(`The evidence every question is asked about, in order`)),questions:h(Wl).check(kt(1)).annotate(El(`Question names must be unique; duplicates fail with InvalidRequestError`))}).annotate({identifier:`Generate.DecisionRequest`}),Kl=N.check(Pt({minimum:0,maximum:1})),ql=x({type:m(`predicate`),name:y,probability:Kl}).annotate({identifier:`Generate.PredicateAnswer`}),Jl=x({type:m(`choice`),name:y,choice:zl,probabilities:h(x({value:zl,probability:Kl})),confidence:Kl}).annotate({identifier:`Generate.ChoiceAnswer`}),Yl=x({type:m(`score`),name:y,score:N.annotate(El(`Probability-weighted level index, so it can fall between levels`)),probabilities:h(x({value:a,label:y,probability:Kl})),confidence:Kl}).annotate({identifier:`Generate.ScoreAnswer`}),Xl=x({type:m(`error`),name:y,reason:y.annotate(El(`Why the question has no answer, for example refusal`)),message:y.pipe(B)}).annotate({identifier:`Generate.ErrorAnswer`,description:`This one question has no answer; the other answers still came back`}),Zl=C([ql,Jl,Yl,Xl]).annotate({identifier:`Generate.DecisionAnswer`}),Ql=x({answers:h(Zl).annotate(El(`One answer per question, in question order`)),cost:Qc.pipe(B),tokens:Ol.pipe(B),native:kl.pipe(B)}).annotate({identifier:`Generate.DecisionResult`}),$l=[Uo,Zo,ys,bs,xs,Yo,Ho],eu={payload:x({prompt:y,model:al.pipe(w)}),success:x({data:x({text:y})}).annotate({identifier:`GenerateTextResponse`}),error:$l},tu=j(`server.generate`).add(T(`generate.text`,`/api/experimental/generate/text`,eu).annotateMerge(O({identifier:`experimental.generate.text`,summary:`Generate text`,description:`Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.`}))).add(T(`generate.textLegacy`,`/api/experimental/generate`,eu).annotateMerge(O({identifier:`experimental.generate.textLegacy`,summary:`Generate text (deprecated path)`,description:`Deprecated alias of POST /api/experimental/generate/text.`,deprecated:!0}))).add(T(`generate.image`,`/api/experimental/generate/image`,{payload:Ml,success:x({data:Pl}).annotate({identifier:`GenerateImageResponse`}),error:$l}).annotateMerge(O({identifier:`experimental.generate.image`,summary:`Generate images`,description:`Generate or edit images with an image model using the server's base configuration and return them as base64. Stateless: nothing is stored.`}))).add(T(`generate.decisions`,`/api/experimental/generate/decisions`,{payload:Gl,success:x({data:Ql}).annotate({identifier:`GenerateDecisionsResponse`}),error:$l}).annotateMerge(O({identifier:`experimental.generate.decisions`,summary:`Generate decisions`,description:`Ask a decision model typed predicate, choice and score questions about the input and return one probability-bearing answer per question, in question order. Stateless: nothing is stored.`}))).annotateMerge(O({title:`generate`,description:`Experimental one-shot generation routes.`})),nu=y.check(f(/^[0-9a-f]{64}$/u)).annotate({identifier:`MediaHash`}),ru=k(`media.get`,`/api/experimental/media/:hash`,{params:{hash:nu},success:dt.pipe(mt()),error:[ns,Uo]}).annotateMerge(O({identifier:`experimental.media.get`,summary:`Read media blob`,description:`Read a content-addressed media blob by SHA-256 hash with immutable Cache-Control, ETag, and 304 Not Modified support. Only blobs a stored message or inbox item still references are served. Experimental: may change without compatibility guarantees.`,transform:e=>({...e,tags:[`experimental`]})})),iu=e({CreateInput:()=>fu,Event:()=>du,ID:()=>au,Info:()=>ou,Pty:()=>iu,UpdateInput:()=>pu}),au=y.check(at(`pty`)).pipe(A(`PtyID`),D({identifier:`Pty.ID`})).pipe(so(e=>{let t=()=>e.make(`pty_`+po());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),ou=x({id:au,title:y,command:y,args:h(y),cwd:y,status:v([`running`,`exited`]),pid:z,exitCode:B(z)}).annotate({identifier:`Pty`}),su=U({type:`pty.created`,schema:{info:ou}}),cu=U({type:`pty.updated`,schema:{info:ou}}),lu=U({type:`pty.exited`,schema:{id:au,exitCode:z}}),uu=U({type:`pty.deleted`,schema:{id:au}}),du={Created:su,Updated:cu,Exited:lu,Deleted:uu,Definitions:W(su,cu,lu,uu)},fu=x({command:B(y),args:B(h(y)),cwd:B(y),title:B(y),env:B(b(y,y))}),pu=x({title:B(y),size:B(x({rows:R,cols:R}))}),mu=y.check(at(`ses`)).pipe(A(`SessionID`),D({identifier:`Session.ID`}),so(e=>({create:()=>e.make(`ses_`+mo())}))),hu=e({Effect:()=>wu,Event:()=>Cu,ID:()=>gu,Permission:()=>hu,Reply:()=>bu,Request:()=>yu,Rule:()=>Tu,Ruleset:()=>Eu,Source:()=>_u}),gu=y.check(at(`per`)).pipe(A(`Permission.ID`),D({identifier:`Permission.ID`}),so(e=>({create:t=>e.make(t??`per_`+po())}))),_u=C([x({type:m(`tool`),messageID:y,id:y})]).annotate({identifier:`Permission.Source`}),vu={sessionID:mu,action:y,resources:h(y),save:h(y).pipe(B),metadata:b(y,Ie).pipe(B),source:_u.pipe(B),message:y.pipe(B)},yu=x({id:gu,...vu}).annotate({identifier:`Permission.Request`}),bu=v([`once`,`always`,`reject`]).annotate({identifier:`Permission.Reply`}),xu=U({type:`permission.asked`,schema:yu.fields}),Su=U({type:`permission.replied`,schema:{sessionID:mu,requestID:gu,reply:bu}}),Cu={Asked:xu,Replied:Su,Definitions:W(xu,Su)},wu=v([`allow`,`deny`,`ask`]).annotate({identifier:`Permission.Effect`}),Tu=x({action:y,resource:y,effect:wu}).annotate({identifier:`Permission.Rule`}),Eu=h(Tu).annotate({identifier:`Permission.Ruleset`}),Du=e({Agent:()=>Du,Color:()=>ju,Event:()=>Nu,ID:()=>ku,Info:()=>Mu,Name:()=>Au}),Ou=U({type:`agent.updated`,schema:{}}),ku=y.pipe(A(`Agent.ID`),D({identifier:`Agent.ID`})),Au=y.pipe(A(`Agent.Name`)),ju=y.annotate({identifier:`Agent.Color`}),Mu=x({id:ku,name:Au,model:al.pipe(B),request:Xc,system:y.pipe(B),description:y.pipe(B),mode:v([`subagent`,`primary`,`all`]),hidden:g,color:ju.pipe(B),steps:R.pipe(B),permissions:Eu}).annotate({identifier:`Agent.Info`}).pipe(so(()=>({default:e=>({id:e,name:Au.make(e),request:{settings:{},headers:{},body:{}},mode:`primary`,hidden:!1,permissions:[{action:`*`,resource:`*`,effect:`allow`},{action:`read`,resource:`*.env`,effect:`ask`},{action:`read`,resource:`*.env.*`,effect:`ask`},{action:`read`,resource:`*.env.example`,effect:`allow`}]})}))),Nu={Updated:Ou,Definitions:W(Ou)},Pu=e({Commands:()=>zu,Current:()=>Lu,Event:()=>Wu,ID:()=>Fu,Icon:()=>Ru,Info:()=>Vu,Project:()=>Pu,Time:()=>Bu,UpdateInput:()=>Hu,Vcs:()=>Iu}),Fu=go,Iu=y.check(f(/^[a-z][a-z0-9._-]*$/u)).annotate({identifier:`Project.Vcs`}),Lu=x({id:Fu,directory:ao,canonical:ao}).annotate({identifier:`Project.Current`}),Ru=x({url:B(y),override:B(y),color:B(y)}).annotate({identifier:`Project.Icon`}),zu=x({start:B(y.annotate({description:`Startup script to run when creating a new workspace (worktree)`}))}).annotate({identifier:`Project.Commands`}),Bu=x({created:z,updated:z,active:z,archived:B(z)}).annotate({identifier:`Project.Time`}),Vu=x({id:Fu,canonical:ao,vcs:B(Iu),name:B(y),icon:B(Ru),commands:B(zu),time:Bu,sandboxes:h(y)}).annotate({identifier:`Project`}),Hu=x({projectID:Fu,canonical:B(ao),name:B(y),icon:B(Ru),commands:B(zu)}).annotate({identifier:`Project.UpdateInput`}),Uu=U({type:`project.updated`,schema:Vu.fields}),Wu={Updated:Uu,Definitions:W(Uu)},Gu=v([`stop`,`length`,`tool-calls`,`content-filter`,`error`,`unknown`]);y.pipe(A(`Tool.CallID`)),t()(`Tool.Error`,{message:y,error:w(ue()),metadata:w(b(y,Ie))});var Ku=x({type:m(`text`),text:y}).annotate({identifier:`Tool.TextContent`}),qu=x({type:m(`file`),uri:y,mime:y,name:w(y)}).annotate({identifier:`Tool.FileContent`}),Ju=C([Ku,qu]).pipe(ye(`type`)).annotate({identifier:`Tool.Content`}),Yu=b(y,Te).annotate({identifier:`Session.Metadata`}),Xu=y.check(at(`sh_`)).pipe(A(`Shell.ID`),D({identifier:`Shell.ID`})).pipe(so(e=>{let t=()=>e.make(`sh_`+po());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),Zu=v([`running`,`exited`,`timeout`,`killed`]),Qu=x({started:N.annotate({description:`Start time in milliseconds since the Unix epoch`}),completed:B(N).annotate({description:`Completion time in milliseconds since the Unix epoch`})}),$u=b(y,Ie),ed=x({id:Xu,status:Zu,command:y,cwd:y,shell:y,file:y,pid:B(z),exit:B(N),signal:B(y),metadata:$u,time:Qu}).annotate({identifier:`Shell.Info`}),td=U({type:`shell.created`,schema:{info:ed}}),nd=U({type:`shell.exited`,schema:{id:Xu,exit:B(N),status:Zu}}),rd=U({type:`shell.deleted`,schema:{id:Xu}}),id={Created:td,Exited:nd,Deleted:rd,Definitions:W(td,nd,rd)},ad=x({command:y,cwd:B(y),timeout:B(z),metadata:B($u)}),od=x({cursor:B(z),limit:B(z)}),sd=x({output:y,cursor:z,size:z,truncated:g}),cd=x({type:y,message:y,status:a.check(Pt({minimum:100,maximum:599})).pipe(B),response:x({body:y}).pipe(B),retryAfterMs:z.pipe(B)}).annotate({identifier:`Session.StructuredError`}),ld=y.pipe(A(`Snapshot.ID`),D({identifier:`Snapshot.ID`})),ud=x({input:N,output:N,reasoning:N,cache:x({read:N,write:N})}).annotate({identifier:`TokenUsage.Info`}),dd=e({AgentSelected:()=>md,Assistant:()=>Pd,AssistantContent:()=>jd,AssistantContentEncoded:()=>Md,AssistantReasoning:()=>Ad,AssistantRetry:()=>Nd,AssistantText:()=>kd,AssistantTool:()=>Od,Compaction:()=>Bd,CompactionCompleted:()=>Rd,CompactionFailed:()=>zd,CompactionRunning:()=>Ld,ID:()=>K,Idle:()=>Vd,Info:()=>Hd,LocationSwitched:()=>gd,MediaInfo:()=>Ud,MediaUser:()=>vd,ModelSelected:()=>hd,Native:()=>pd,SessionMessage:()=>dd,Shell:()=>Sd,Skill:()=>xd,Synthetic:()=>yd,System:()=>bd,ToolState:()=>Dd,ToolStateCompleted:()=>Td,ToolStateError:()=>Ed,ToolStateRunning:()=>wd,ToolStateStreaming:()=>Cd,User:()=>_d}),K=y.check(at(`msg_`)).pipe(A(`Session.Message.ID`),D({identifier:`Session.Message.ID`}),so(e=>({create:()=>e.make(`msg_`+po()),fromEvent:t=>e.make(t.replace(/^evt_/,`msg_`))}))),fd={id:K,metadata:b(y,Ie).pipe(B),time:x({created:co})},pd=b(y,Ie).annotate({identifier:`Session.Message.Native`}),md=x({...fd,type:_(`agent-switched`),agent:ku,previous:ku.pipe(B)}).annotate({identifier:`Session.Message.AgentSelected`}),hd=x({...fd,type:_(`model-switched`),model:al,previous:al.pipe(B)}).annotate({identifier:`Session.Message.ModelSelected`}),gd=x({...fd,type:_(`location-switched`),location:yo,projectID:Fu.pipe(B),subpath:io.pipe(B),previous:x({location:yo,projectID:Fu.pipe(B),subpath:io.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.LocationSwitched`}),_d=x({...fd,text:Tl.fields.text,files:Tl.fields.files,agents:Tl.fields.agents,skills:Tl.fields.skills,type:_(`user`)}).annotate({identifier:`Session.Message.User`}),vd=x({..._d.fields,files:h(Sl).pipe(B)}).annotate({identifier:`Session.Message.MediaUser`}),yd=x({...fd,text:y,description:y.pipe(B),type:_(`synthetic`)}).annotate({identifier:`Session.Message.Synthetic`}),bd=x({...fd,type:_(`system`),text:y,description:y.pipe(B)}).annotate({identifier:`Session.Message.System`}),xd=x({...fd,type:_(`skill`),skill:No,name:Po,text:y}).annotate({identifier:`Session.Message.Skill`}),Sd=x({...fd,type:_(`shell`),shellID:Xu,command:y,status:Zu,exit:gt.pipe(B),output:sd.pipe(B),time:x({created:co,completed:co.pipe(B)})}).annotate({identifier:`Session.Message.Shell`}),Cd=x({status:_(`streaming`),input:y}).annotate({identifier:`Session.Message.ToolState.Streaming`}),wd=x({status:_(`running`),input:b(y,Ie),metadata:b(y,Te)}).annotate({identifier:`Session.Message.ToolState.Running`}),Td=x({status:_(`completed`),input:b(y,Ie),content:De(Ju),metadata:b(y,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Completed`}),Ed=x({status:_(`error`),input:b(y,Ie),error:cd,content:De(Ju).pipe(B),metadata:b(y,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Error`}),Dd=C([Cd,wd,Td,Ed]).pipe(ye(`status`)),Od=x({type:_(`tool`),id:y,name:y,executed:g.pipe(B),native:pd.pipe(B),state:Dd,time:x({created:co,ran:co.pipe(B),completed:co.pipe(B)})}).annotate({identifier:`Session.Message.Assistant.Tool`}),kd=x({type:_(`text`),text:y,native:pd.pipe(B)}).annotate({identifier:`Session.Message.Assistant.Text`}),Ad=x({type:_(`reasoning`),text:y,native:pd.pipe(B),time:x({created:co,completed:co.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.Assistant.Reasoning`}),jd=C([kd,Ad,Od]).pipe(ye(`type`)),Md=ee(jd).annotate({identifier:`Session.Message.AssistantContent.Encoded`}),Nd=x({attempt:R,at:co,error:cd}).annotate({identifier:`Session.Message.Assistant.Retry`}),Pd=x({...fd,type:_(`assistant`),agent:ku,model:al,content:jd.pipe(h),snapshot:x({start:ld.pipe(B),end:ld.pipe(B),files:h(io).pipe(B)}).pipe(B),finish:Gu.pipe(B),rawFinish:y.pipe(B),native:pd.pipe(B),cost:Qc.pipe(B),tokens:ud.pipe(B),error:cd.pipe(B),retry:Nd.pipe(B),time:x({created:co,streamed:co.pipe(B),completed:co.pipe(B)})}).annotate({identifier:`Session.Message.Assistant`}),Fd={type:_(`compaction`),...fd},Id={cost:Qc.pipe(B),tokens:ud.pipe(B)},Ld=x({...Fd,status:_(`running`),reason:v([`auto`,`manual`]),summary:y}).annotate({identifier:`Session.Message.Compaction.Running`}),Rd=x({...Fd,status:_(`completed`),reason:v([`auto`,`manual`]),model:al.pipe(B),native:pd.pipe(B),summary:y,...Id}).annotate({identifier:`Session.Message.Compaction.Completed`}),zd=x({...Fd,status:_(`failed`),reason:v([`auto`,`manual`]),error:cd,...Id}).annotate({identifier:`Session.Message.Compaction.Failed`}),Bd=C([Ld,Rd,zd]).pipe(ye(`status`),D({identifier:`Session.Message.Compaction`})),Vd=x({...fd,type:_(`idle`),outcome:v([`succeeded`,`failed`,`interrupted`]),error:cd.pipe(B)}).annotate({identifier:`Session.Message.Idle`}),Hd=C([md,hd,gd,_d,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.Info`}),Ud=C([md,hd,gd,vd,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.MediaInfo`}),Wd=x({file:y,patch:y,additions:z,deletions:z,status:v([`added`,`deleted`,`modified`]),more:m(!0).pipe(B)}).annotate({identifier:`FileDiff.Info`}),Gd=x({file:y.pipe(B),patch:y.pipe(B),additions:N,deletions:N,status:v([`added`,`deleted`,`modified`]).pipe(B)}).annotate({identifier:`FileDiff.LegacyInfo`}),Kd=x({messageID:K,partID:y.pipe(B),snapshot:ld.pipe(B),files:h(Wd).pipe(B)}).annotate({identifier:`Session.Revert`}),qd=x({path:y,status:v([`added`,`modified`,`deleted`]),additions:N,deletions:N,patch:y}),Jd=x({messageID:K,partID:y.pipe(B),snapshot:y.pipe(B),diff:y.pipe(B),files:h(qd).pipe(B)}).annotate({identifier:`Session.RevertV1`}),Yd=Kd.pipe(wt(x({source:_(`current`),revert:Ft(Kd)}),ne({decode:e=>({source:`current`,revert:e}),encode:e=>e.revert}))),Xd=Jd.pipe(wt(x({source:_(`legacy`),revert:Ft(Jd)}),ne({decode:e=>({source:`legacy`,revert:e}),encode:e=>e.revert})));C([Yd,Xd]).pipe(ye(`source`),wt(Ft(Kd),ne({decode:e=>e.source===`current`?e.revert:Kd.make({messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot?ld.make(e.revert.snapshot):void 0,files:e.revert.files?.map(e=>({file:e.path,status:e.status,additions:e.additions,deletions:e.deletions,patch:e.patch}))}),encode:e=>({source:`current`,revert:e})})),D({identifier:`Session.Revert.Persisted`}));var Zd=y.check(f(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(A(`Instruction.Key`),D({identifier:`Instruction.Key`})),Qd=y.check(f(/^[a-f0-9]{64}$/u)).pipe(A(`Instruction.Hash`),D({identifier:`Instruction.Hash`})),$d=b(Zd,Qd),ef=m(`removed`);ef.make(`removed`);var tf=b(y,C([Qd,ef])),nf=y.check(f(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({identifier:`InstructionEntry.Key`,description:`Instruction entry key (lowercase alphanumerics plus . _ -)`}),rf=x({key:nf,value:Te.annotate({description:`JSON value attached to the session's instructions`})}).annotate({identifier:`InstructionEntry.Info`}),af=h(x({...rf.fields,removed:g})).annotate({identifier:`InstructionEntry.Snapshot`}),of=class extends t()(`InstructionEntryValueTooLargeError`,{actualBytes:a,maxBytes:a,message:y},{httpApiStatus:413}){},sf=e({Compaction:()=>Cf,CompactionPayload:()=>ff,Delivery:()=>cf,Info:()=>Tf,Item:()=>vf,MediaInfo:()=>Ef,MediaUser:()=>xf,MediaUserPayload:()=>uf,Move:()=>wf,MovePayload:()=>pf,SessionInbox:()=>sf,Synthetic:()=>Sf,SyntheticPayload:()=>df,User:()=>bf,UserPayload:()=>lf}),cf=v([`steer`,`queue`]).annotate({identifier:`Session.Inbox.Delivery`}),lf=x({...Tl.fields,metadata:b(y,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.UserPayload`}),uf=x({...lf.fields,files:h(Sl).pipe(B)}).annotate({identifier:`Session.Inbox.MediaUserPayload`}),df=x({text:y,description:y.pipe(B),metadata:b(y,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.SyntheticPayload`}),ff=x({}).annotate({identifier:`Session.Inbox.CompactionPayload`}),pf=x({location:yo,projectID:Fu,subpath:io.pipe(B)}).annotate({identifier:`Session.Inbox.MovePayload`}),mf=x({type:_(`user`),payload:lf,delivery:cf}),hf=x({type:_(`synthetic`),payload:df,delivery:cf}),gf=x({type:_(`compaction`),payload:ff,delivery:cf}),_f=x({type:_(`move`),payload:pf,delivery:cf}),vf=C([mf,hf,gf,_f]).pipe(ye(`type`),D({identifier:`Session.Inbox.Item`})),yf={id:K,sessionID:mu,time:x({created:co})},bf=x({...yf,...mf.fields}).annotate({identifier:`Session.Inbox.User`}),xf=x({...bf.fields,payload:uf}).annotate({identifier:`Session.Inbox.MediaUser`}),Sf=x({...yf,...hf.fields}).annotate({identifier:`Session.Inbox.Synthetic`}),Cf=x({...yf,...gf.fields}).annotate({identifier:`Session.Inbox.Compaction`}),wf=x({...yf,..._f.fields}).annotate({identifier:`Session.Inbox.Move`}),Tf=C([bf,Sf,Cf,wf]).pipe(ye(`type`),D({identifier:`Session.Inbox.Info`})),Ef=C([xf,Sf,Cf,wf]).pipe(ye(`type`),D({identifier:`Session.Inbox.MediaInfo`})),Df=C([x({type:m(`before`),messageID:K}),x({type:m(`through`),messageID:K})]).annotate({identifier:`Session.ForkBoundary`}),Of=e({AgentSelected:()=>Af,All:()=>dp,Archived:()=>Lf,Compaction:()=>ap,Created:()=>kf,Definitions:()=>sp,Deleted:()=>Hf,Durable:()=>up,DurableDefinitions:()=>cp,EphemeralDefinitions:()=>lp,Execution:()=>Yf,Forked:()=>Uf,InboxCancelled:()=>qf,InboxDelivered:()=>Gf,InboxDeliveryChanged:()=>Jf,InboxEnqueued:()=>Kf,InstructionsUpdated:()=>Xf,MessageContentUpdated:()=>zf,MetadataUpdated:()=>Pf,ModelSelected:()=>jf,Moved:()=>Mf,Permissions:()=>Ff,Reasoning:()=>np,Renamed:()=>Nf,RetryScheduled:()=>ip,RevertEvent:()=>op,SessionEvent:()=>Of,Shell:()=>$f,Skill:()=>Qf,Step:()=>ep,Synthetic:()=>Zf,Text:()=>tp,Tool:()=>rp,Unarchived:()=>Rf,UsageRecorded:()=>Bf,UsageUpdated:()=>Vf,Viewed:()=>If}),q={sessionID:mu},J={durable:{aggregate:`sessionID`,version:1}},kf=H({type:`session.created`,...J,schema:{...q,projectID:Fu,location:yo,subpath:io.pipe(B),parentID:mu.pipe(B),slug:y,title:y.pipe(B),agent:ku.pipe(B),model:al.pipe(B),metadata:Yu.pipe(B),permissions:Eu.pipe(B),version:y}}),Af=H({type:`session.agent.selected`,...J,schema:{...q,agent:ku,previous:ku.pipe(B)}}),jf=H({type:`session.model.selected`,...J,schema:{...q,model:al,previous:al.pipe(B)}}),Mf=H({type:`session.moved`,...J,schema:{...q,...pf.fields}}),Nf=H({type:`session.renamed`,...J,schema:{...q,title:y}}),Pf=H({type:`session.metadata.updated`,...J,schema:{...q,metadata:Yu}}),Ff=H({type:`session.permissions`,...J,schema:{...q,permissions:Eu}}),If=H({type:`session.viewed`,...J,schema:{...q,idle:N}}),Lf=H({type:`session.archived`,...J,schema:q}),Rf=H({type:`session.unarchived`,...J,schema:q}),zf=H({type:`session.message.content.updated`,...J,schema:{...q,messageID:K,content:h(Md)}}),Bf=H({type:`session.usage.recorded`,...J,schema:{...q,source:v([`title`,`compaction`]),cost:Qc,tokens:ud}}),Vf=U({type:`session.usage.updated`,schema:{...q,cost:Qc,tokens:ud}}),Hf=H({type:`session.deleted`,durable:{aggregate:`sessionID`,version:2},schema:q}),Uf=H({type:`session.forked`,durable:{aggregate:`sessionID`,version:2},schema:{...q,parentID:mu,boundary:Df,instructions:$d.pipe(B),instructionEntries:af.pipe(B)}}),Wf={...q,inboxID:K},Gf=H({type:`session.inbox.delivered`,...J,schema:Wf}),Kf=H({type:`session.inbox.enqueued`,...J,schema:{...Wf,item:vf}}),qf=H({type:`session.inbox.cancelled`,...J,schema:Wf}),Jf=H({type:`session.inbox.delivery.changed`,...J,schema:{...Wf,delivery:cf}}),Yf;(function(e){e.Started=H({type:`session.execution.started`,...J,schema:q}),e.Succeeded=H({type:`session.execution.succeeded`,...J,schema:q}),e.Failed=H({type:`session.execution.failed`,...J,schema:{...q,error:cd}}),e.Interrupted=H({type:`session.execution.interrupted`,...J,schema:{...q,reason:v([`user`,`shutdown`,`superseded`,`inactivity`])}})})(Yf||={});var Xf=H({type:`session.instructions.updated`,durable:{aggregate:`sessionID`,version:2},schema:{...q,delta:tf,text:y.pipe(B)}}),Zf=H({type:`session.synthetic`,...J,schema:{...q,text:y,description:y.pipe(B),metadata:b(y,Ie).pipe(B)}}),Qf;(function(e){e.Activated=H({type:`session.skill.activated`,...J,schema:{...q,id:No,name:Po,text:y}})})(Qf||={});var $f;(function(e){e.Started=H({type:`session.shell.started`,...J,schema:{...q,shell:ed}}),e.Ended=H({type:`session.shell.ended`,...J,schema:{...q,shell:ed,output:sd}})})($f||={});var ep;(function(e){e.Started=H({type:`session.step.started`,...J,schema:{...q,assistantMessageID:K,agent:ku,model:al,snapshot:ld.pipe(B),started:z}}),e.Streamed=H({type:`session.step.streamed`,...J,schema:{...q,assistantMessageID:K}}),e.Ended=H({type:`session.step.ended`,...J,schema:{...q,assistantMessageID:K,finish:Gu,rawFinish:y.pipe(B),native:pd.pipe(B),cost:Qc,tokens:ud,snapshot:ld.pipe(B),files:h(io).pipe(B)}}),e.Failed=H({type:`session.step.failed`,...J,schema:{...q,assistantMessageID:K,error:cd,finish:v([`content-filter`]).pipe(B),rawFinish:y.pipe(B),native:pd.pipe(B),cost:Qc.pipe(B),tokens:ud.pipe(B),snapshot:ld.pipe(B),files:h(io).pipe(B)}})})(ep||={});var tp;(function(e){e.Started=H({type:`session.text.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z}}),e.Delta=U({type:`session.text.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:y}}),e.Ended=H({type:`session.text.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:y,native:pd.pipe(B)}})})(tp||={});var np;(function(e){e.Started=H({type:`session.reasoning.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z,native:pd.pipe(B)}}),e.Delta=U({type:`session.reasoning.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:y}}),e.Ended=H({type:`session.reasoning.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:y,native:pd.pipe(B)}})})(np||={});var rp;(function(e){let t={...q,assistantMessageID:K,id:y};(function(e){e.Started=H({type:`session.tool.input.started`,...J,schema:{...t,name:y}}),e.Delta=U({type:`session.tool.input.delta`,schema:{...t,delta:y}}),e.Ended=H({type:`session.tool.input.ended`,...J,schema:{...t,text:y}})})(e.Input||={}),e.Called=H({type:`session.tool.called`,...J,schema:{...t,input:b(y,Ie),executed:g,native:pd.pipe(B)}}),e.Progress=U({type:`session.tool.progress`,schema:{...t,metadata:b(y,Te)}}),e.Success=H({type:`session.tool.success`,durable:{aggregate:`sessionID`,version:2},schema:{...t,content:De(Ju),metadata:b(y,Te).pipe(B),executed:g,native:pd.pipe(B)}}),e.Failed=H({type:`session.tool.failed`,durable:{aggregate:`sessionID`,version:2},schema:{...t,error:cd,content:De(Ju).pipe(B),metadata:b(y,Te).pipe(B),executed:g,native:pd.pipe(B)}})})(rp||={});var ip=H({type:`session.retry.scheduled`,...J,schema:{...q,assistantMessageID:K,attempt:R,at:z,error:cd}}),ap;(function(e){e.Started=H({type:`session.compaction.started`,...J,schema:{...q,reason:v([`auto`,`manual`]),inputID:K.pipe(B)}}),e.Delta=U({type:`session.compaction.delta`,schema:{...q,text:y}}),e.Ended=H({type:`session.compaction.ended`,...J,schema:{...q,reason:e.Started.data.fields.reason,model:Rd.fields.model,native:Rd.fields.native,text:y,cost:Rd.fields.cost,tokens:Rd.fields.tokens}}),e.Failed=H({type:`session.compaction.failed`,...J,schema:{...q,reason:e.Started.data.fields.reason,error:cd,inputID:K.pipe(B),cost:zd.fields.cost,tokens:zd.fields.tokens}})})(ap||={});var op;(function(e){e.Staged=H({type:`session.revert.staged`,...J,schema:{...q,revert:Kd}}),e.Cleared=H({type:`session.revert.cleared`,...J,schema:q}),e.Committed=H({type:`session.revert.committed`,...J,schema:{...q,to:K}})})(op||={});var sp=W(kf,Af,jf,Mf,Nf,Pf,Ff,If,Lf,Rf,Vf,Hf,Uf,Gf,Kf,qf,Jf,Yf.Started,Yf.Succeeded,Yf.Failed,Yf.Interrupted,Xf,Zf,Qf.Activated,$f.Started,$f.Ended,ep.Started,ep.Streamed,ep.Ended,ep.Failed,tp.Started,tp.Delta,tp.Ended,np.Started,np.Delta,np.Ended,rp.Input.Started,rp.Input.Delta,rp.Input.Ended,rp.Called,rp.Progress,rp.Success,rp.Failed,ip,ap.Started,ap.Delta,ap.Ended,ap.Failed,op.Staged,op.Cleared,op.Committed),cp=W(...sp.filter(e=>e.durability===`durable`),Bf,zf),lp=W(...sp.filter(e=>e.durability===`ephemeral`)),up=C(cp,{mode:`oneOf`}).annotate({identifier:`Session.Event.Durable`}).pipe(ye(`type`)),dp=C([up,...lp],{mode:`oneOf`}).pipe(ye(`type`)),fp=e({Event:()=>mp,ForkBoundary:()=>hp,ID:()=>Y,Info:()=>gp,ListAnchor:()=>_p,ListCursor:()=>wp,ListFilter:()=>yp,Metadata:()=>pp,Revert:()=>Kd,Session:()=>fp}),Y=mu,pp=Yu,mp=Of,hp=Df,gp=x({id:Y,parentID:Y.pipe(B),fork:x({sessionID:Y,boundary:hp}).pipe(B),projectID:Fu,agent:ku.pipe(B),model:al.pipe(B),cost:Qc,tokens:ud,outcome:v([`succeeded`,`failed`,`interrupted`]).pipe(B),time:x({created:co,updated:co,idle:co.pipe(B),viewed:co.pipe(B),archived:co.pipe(B)}),title:y.pipe(B),location:yo,subpath:io.pipe(B),metadata:pp.pipe(B),permissions:Eu.pipe(B),revert:Kd.pipe(B)}).annotate({identifier:`Session.Info`}),_p=x({id:Y,time:N,direction:v([`previous`,`next`])}).annotate({identifier:`Session.ListAnchor`}),vp={order:v([`asc`,`desc`]).pipe(w).annotate({description:`Session order for the first page. Use desc for newest first or asc for oldest first.`}),search:y.pipe(w),parentID:C([Y,te.pipe(Ze(m(`null`),{decode:_t(()=>null),encode:_t(()=>`null`)}))]).annotate({description:`Filter by parent session. Use null to return only root sessions.`}).pipe(w),archived:v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(e=>e?`true`:`false`)})).annotate({description:`Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both.`}).pipe(w)},yp=x({...vp,directory:ao.pipe(w),project:Fu.pipe(w),subpath:io.pipe(w)}).annotate({identifier:`Session.ListFilter`}),bp=C([x({...vp,directory:ao,anchor:_p}),x({...vp,project:Fu,subpath:io.pipe(w),anchor:_p}),x({...vp,anchor:_p})]),xp=Dt(bp),Sp=et(xp),Cp=We(xp),wp=y.pipe(A(`SessionsCursor`),D({identifier:`SessionsCursor`,description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.`}),so(e=>{let t=Oe(e);return{make:e=>t(ke(Sp(e))),parse:e=>$e(()=>{let t=Ae(e);return Nt(t)?nt(`Invalid cursor`):Cp(t.success).pipe(M(()=>`Invalid cursor`))})}})),Tp=x({...ou.fields,sessionID:Y,foregroundProcess:ce(y),size:x({cols:R,rows:R}),output:x({head:z,tail:z})}).annotate({identifier:`PersistentPty.Info`}),Ep=x({directory:y,instanceID:y,ticket:y,expiresAt:gt}).annotate({identifier:`PersistentPty.Handoff`}),Dp=x({command:B(y),args:h(y),cwd:B(y),title:y,env:b(y,y),size:B(x({cols:R,rows:R}))}).annotate({identifier:`PersistentPty.CreateInput`}),Op=x({attachmentID:B(y),size:x({cols:R,rows:R})}).annotate({identifier:`PersistentPty.UpdateInput`}),kp=x({info:Tp,text:y,checkpoint:dt,cursor:x({x:z,y:z})}).annotate({identifier:`PersistentPty.Snapshot`}),Ap=R.check(c(65535)).annotate({identifier:`PersistentPty.ReadLines`}),jp=x({ptyID:au,title:y,cwd:y,foregroundProcess:ce(y),screen:x({text:y,cols:R,rows:R,cursor:kp.fields.cursor})}).annotate({identifier:`PersistentPty.ReadResult`}),Mp=U({type:`persistent-pty.added`,schema:{sessionID:Y,terminal:Tp}}),Np=U({type:`persistent-pty.removed`,schema:{sessionID:Y,ptyID:au}}),Pp={Added:Mp,Removed:Np,Definitions:W(Mp,Np)},Fp=x({ticket:y,expires_in:R}).annotate({identifier:`PtyTicket.ConnectToken`}),X=x({location:w(x({directory:w(y)}))}).annotate({identifier:`LocationQuery`}),Z=O({transform:e=>{let t=e.parameters;return Array.isArray(t)?{...e,parameters:t.map(e=>e?.name===`location`&&e?.in===`query`?{...e,style:`deepObject`,explode:!0}:e)}:e}}),Ip=e=>j(`server.location`).add(k(`location.get`,`/api/location`,{query:X,success:So}).middleware(e).annotateMerge(Z).annotateMerge(O({identifier:`location.get`,summary:`Get location`,description:`Resolve the requested location or the server default location.`}))).add(T(`location.reload`,`/api/location/reload`,{success:S,error:Yo}).annotateMerge(O({identifier:`location.reload`,summary:`Reload configuration`,description:`Shut down and rebuild every loaded location. Pending permissions and forms are cancelled; running sessions continue with fresh services at the next step boundary. Emits location.shutdown for client recovery and responds once all replacement builds settle.`}))).annotateMerge(O({title:`location`})),Lp=`ticket`,Rp=`x-opencode-ticket`,zp=`/api/pty/:ptyID/connect`,Bp=e=>j(`server.pty`).add(k(`pty.list`,`/api/pty`,{query:X,success:V(h(ou))}).annotateMerge(Z).annotateMerge(O({identifier:`pty.list`,summary:`List PTY sessions`,description:`List PTY sessions for a location, including exited sessions retained until removal.`}))).add(T(`pty.create`,`/api/pty`,{query:X,payload:fu,success:V(ou)}).annotateMerge(Z).annotateMerge(O({identifier:`pty.create`,summary:`Create PTY session`,description:`Create a pseudo-terminal session for a location.`}))).add(k(`pty.get`,`/api/pty/:ptyID`,{params:{ptyID:au},query:X,success:V(ou),error:_s}).annotateMerge(Z).annotateMerge(O({identifier:`pty.get`,summary:`Get PTY session`,description:`Get one PTY session, including its exit code once exited.`}))).add(Ct(`pty.update`,`/api/pty/:ptyID`,{params:{ptyID:au},query:X,payload:pu,success:V(ou),error:_s}).annotateMerge(Z).annotateMerge(O({identifier:`pty.update`,summary:`Update PTY session`,description:`Update the title or viewport size of one PTY session.`}))).add(ft(`pty.remove`,`/api/pty/:ptyID`,{params:{ptyID:au},query:X,success:S,error:_s}).annotateMerge(Z).annotateMerge(O({identifier:`pty.remove`,summary:`Remove PTY session`,description:`Terminate and remove one PTY session.`}))).add(T(`pty.connectToken`,`/api/pty/:ptyID/connect-token`,{params:{ptyID:au},query:X,headers:x({[Rp]:w(y)}),success:V(Fp),error:[gs,_s]}).annotateMerge(Z).annotateMerge(O({identifier:`pty.connect.token`,summary:`Create PTY WebSocket token`,description:`Create a short-lived single-use ticket for opening a PTY WebSocket connection.`}))).middleware(e).add(k(`pty.connect`,zp,{params:{ptyID:au},success:g,error:[gs,_s,Ho]}).annotateMerge(O({identifier:`pty.connect`,summary:`Connect to PTY session`,description:`Establish a WebSocket connection streaming PTY output and accepting terminal input.`,transform:e=>({...e,"x-websocket":!0,parameters:[...e.parameters??[],...[`location[directory]`,`cursor`,Lp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(O({title:`pty`,description:`Experimental location-scoped PTY routes.`})),Vp=`/api/experimental/persistent-pty/:ptyID/connect`,Hp=[Uo,Yo],Up=[_s,Yo],Wp=j(`server.experimental`).add(k(`persistentPty.read`,`/api/experimental/session/:sessionID/terminal/read`,{params:{sessionID:Y},query:{lines:oe.pipe(wt(Ap),w)},success:x({data:ce(jp)}),error:[Yo]}).annotateMerge(O({summary:`Read the session's most recently controlled terminal`,description:`Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.`}))).add(k(`persistentPty.list`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},success:x({data:h(Tp)}),error:Hp})).add(T(`persistentPty.create`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},payload:Dp,success:x({data:Tp}),error:Hp})).add(T(`persistentPty.shutdown`,`/api/experimental/persistent-pty/shutdown`,{success:S,error:[Yo]})).add(T(`persistentPty.handoff`,`/api/experimental/persistent-pty/handoff`,{success:x({handoff:ce(Ep)}),error:[Yo]})).add(k(`persistentPty.get`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:au},success:x({data:Tp}),error:Up})).add(Ct(`persistentPty.update`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:au},payload:Op,success:x({data:Tp}),error:Up})).add(k(`persistentPty.snapshot`,`/api/experimental/persistent-pty/:ptyID/snapshot`,{params:{ptyID:au},success:x({data:kp}),error:Up})).add(ft(`persistentPty.remove`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:au},success:S,error:Up})).add(T(`persistentPty.connectToken`,`/api/experimental/persistent-pty/:ptyID/connect-token`,{params:{ptyID:au},headers:x({[Rp]:w(y)}),success:x({data:Fp}),error:[gs,_s,Yo]})).add(k(`persistentPty.connect`,Vp,{params:{ptyID:au},success:g,error:[gs,_s,Yo]}).annotateMerge(O({identifier:`persistentPty.connect`,summary:`Connect to a persistent PTY`,description:`Stream persistent PTY output through the OpenCode server.`,transform:e=>({...e,"x-websocket":!0,parameters:[...e.parameters??[],...[`cursor`,`role`,`attachment_id`,`takeover`,`input_protocol`,Lp].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(O({title:`persistentPty`,description:`Prototype persistent PTY routes.`})).add(ru),Gp=v([`webrtc`,`websocket`]).annotate({identifier:`VoiceTransportType`}),Kp=x({model:y,provider:y,transports:h(Gp),available:g}).annotate({identifier:`VoiceModel`}),qp=x({type:m(`webrtc`),sdp:y,dcid:w(gt)}).annotate({identifier:`VoiceWebRTCTransportInput`}),Jp=x({type:m(`websocket`)}).annotate({identifier:`VoiceWebSocketTransportInput`}),Yp=C([qp,Jp]).annotate({identifier:`VoiceTransportInput`}),Xp=x({type:m(`webrtc`),sdp:y}).annotate({identifier:`VoiceWebRTCTransport`}),Zp=x({type:m(`websocket`),url:y,token:y,expiresAt:gt}).annotate({identifier:`VoiceWebSocketTransport`}),Qp=C([Xp,Zp]).annotate({identifier:`VoiceTransport`}),$p=j(`server.voice`).add(k(`voice.models`,`/api/experimental/voice/models`,{success:x({data:x({models:h(Kp),default:w(y)})}).annotate({identifier:`VoiceModelsResponse`}),error:[Yo,Ho]}).annotateMerge(O({identifier:`experimental.voice.models`,summary:`List voice models`,description:`List supported voice models, their transports, and whether the server has a usable API key for each provider.`}))).add(T(`voice.session`,`/api/experimental/voice/session`,{payload:x({model:y,session:w(b(y,Ie)),transport:Yp}),success:x({data:x({transport:Qp})}).annotate({identifier:`VoiceSessionResponse`}),error:[Uo,Yo,Ho]}).annotateMerge(O({identifier:`experimental.voice.session`,summary:`Create voice session`,description:`Create a server-brokered voice session using the server's configured provider credentials and return the WebRTC SDP answer or WebSocket ephemeral token.`}))).annotateMerge(O({title:`voice`,description:`Experimental server-brokered voice session routes.`})),em=x({limit:w(oe.check(xe(),Mt(1),c(200))).annotate({description:`Maximum number of messages to return. When omitted, the endpoint returns its default page size.`}),order:w(C([m(`asc`),m(`desc`)])).annotate({description:`Message order for the first page. Use desc for newest first or asc for oldest first.`}),cursor:w(y.annotate({description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.`})),type:w(v(Object.keys({"agent-switched":!0,"model-switched":!0,"location-switched":!0,user:!0,synthetic:!0,system:!0,skill:!0,shell:!0,assistant:!0,compaction:!0,idle:!0}))).annotate({description:`Filter by message type before pagination. When omitted, all message types are returned. Pass the same type when following cursors.`})}).annotate({identifier:`SessionMessagesQuery`}),tm=x({...re(gd.fields,[`location`,`previous`]),location:bo,previous:x({location:bo,projectID:gd.fields.projectID,subpath:gd.fields.subpath}).pipe(w)}).annotate({identifier:`Session.Message.LocationSwitched`}),nm=C([md,hd,tm,_d,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.Info`}),rm=C([md,hd,tm,vd,yd,bd,xd,Sd,Pd,Bd,Vd]).annotate({identifier:`Session.Message.MediaInfo`}),im=x({previous:y.pipe(w),next:y.pipe(w)});x({data:h(rm),cursor:im}),x({data:rm});var am=j(`server.message`).add(k(`session.messages`,`/api/session/:sessionID/message`,{params:{sessionID:Y},query:em,success:x({data:h(nm),cursor:im}).annotate({identifier:`SessionMessagesResponse`}),error:[us,G,Xo]}).annotateMerge(O({identifier:`session.message.list`,summary:`Get session messages`,description:`Retrieve projected messages for a session, optionally filtered by type. Items keep the requested order across pages; use cursor.next or cursor.previous to move through the ordered timeline, passing the same type filter on each page.`}))).annotateMerge(O({title:`session`,description:`Experimental message routes.`})),om=x({...X.fields,types:w(de(sl)).annotate({description:`Only list models of these types. Defaults to chat, the only type offered for sessions.`})}),sm=j(`server.model`).add(k(`model.list`,`/api/model`,{query:om,success:V(h(pl)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`model.list`,summary:`List models`,description:`Retrieve the current snapshot of available models of the requested types, chat by default, ordered by release date within each type. The snapshot may precede initial plugin settlement.`}))).add(k(`model.default`,`/api/model/default`,{query:X,success:V(yt(pl)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`model.default`,summary:`Get default model`,description:`Retrieve the model used when a session has no explicit model selection.`}))).annotateMerge(O({title:`model`,description:`Experimental model routes.`})),cm=j(`server.provider`).add(k(`provider.list`,`/api/provider`,{query:X,success:V(h(Zc)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`provider.list`,summary:`List providers`,description:`Retrieve active AI providers so clients can show provider availability and configuration.`}))).add(k(`provider.get`,`/api/provider/:providerID`,{params:{providerID:Lc},query:X,success:V(Zc),error:[Zo,Yo]}).annotateMerge(Z).annotateMerge(O({identifier:`provider.get`,summary:`Get provider`,description:`Retrieve a single AI provider so clients can inspect its availability and endpoint settings.`}))).annotateMerge(O({title:`provider`,description:`Experimental provider routes.`})),lm=e({FileAttachment:()=>um,Prompt:()=>fm,PromptInput:()=>lm,SkillAttachment:()=>dm}),um=x({uri:y,name:y.pipe(B),description:y.pipe(B),mention:ml.pipe(B)}).annotate({identifier:`PromptInput.FileAttachment`}),dm=x({id:No,mention:ml.pipe(B)}).annotate({identifier:`PromptInput.SkillAttachment`}),fm=x({text:y,files:h(um).pipe(B),agents:h(Cl).pipe(B),skills:h(dm).pipe(B)}).annotate({identifier:`PromptInput`}),pm=x({date:y,steps:z}).annotate({identifier:`SessionStats.Activity`}),mm=x({model:al,steps:z,tokens:ud,cost:Qc}).annotate({identifier:`SessionStats.ModelUsage`}),hm=x({name:y,calls:z,succeeded:z,failed:z,unfinished:z,durationP50:N.pipe(B)}).annotate({identifier:`SessionStats.ToolUsage`}),gm=v([`none`,`summary`,`detail`]),_m=x({calls:z,succeeded:z,failed:z,unfinished:z}).annotate({identifier:`SessionStats.ToolTotals`}),vm=C([x({mode:m(`none`)}),x({mode:m(`summary`),totals:_m}),x({mode:m(`detail`),totals:_m,usage:h(hm)})]).annotate({identifier:`SessionStats.Tools`}),ym=x({range:x({from:co,to:co}),sessions:z,subagents:z,prompts:z,steps:z,tokens:ud,cost:Qc,tools:vm,activeDays:z,streak:z,activity:h(pm),models:h(mm)}).annotate({identifier:`SessionStats.Info`});function bm(e,t){return e===`assistant`?Sm(km(t,`providerState`,`native`)):e===`compaction`?Tm(wm(km(t,`providerState`,`native`))):t}function xm(e){return e.map(e=>Am(e)?bm(e.type,e):e)}function Sm(e){return Array.isArray(e.content)?{...e,content:e.content.map(Cm)}:e}function Cm(e){return Am(e)?e.type===`text`||e.type===`reasoning`?km(e,`state`,`native`):e.type===`tool`?Om(km(e,`providerState`,`native`)):e:e}function wm(e){let t=e.recent,n=Dm(e,`recent`);if(typeof t!=`string`||!t)return n;let r=Am(n.metadata)?n.metadata:{};return{...n,metadata:{recent:t,...r}}}function Tm(e){let t=e.providerContext,n=Dm(e,`providerContext`);return Am(t)?{...n,native:{messages:Array.isArray(t.messages)?t.messages.map(Em):t.messages}}:n}function Em(e){return!Am(e)||!Array.isArray(e.content)?e:{...e,content:e.content.map(e=>{if(!Am(e)||e.type!==`media`||e.media!==void 0||typeof e.data!=`string`)return e;let{mediaType:t,data:n,...r}=e;return{...r,media:{source:{type:`base64`,data:n,mediaType:t}}}})}}function Dm(e,t){if(!(t in e))return e;let{[t]:n,...r}=e;return r}function Om(e){if(!(`providerResultState`in e))return e;let{providerResultState:t,...n}=e;return Am(t)?{...n,native:{...Am(n.native)?n.native:{},...t}}:n}function km(e,t,n){if(!(t in e))return e;let{[t]:r,...i}=e;return n in i?i:{...i,[n]:r}}function Am(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var jm=e({EventLog:()=>jm,Synced:()=>Mm}),Mm=x({type:m(`log.synced`),aggregateID:y,seq:B(To)}).annotate({identifier:`EventLog.Synced`,description:`Marker emitted once when a log read reaches its captured watermark. The reader holds every event committed at or below seq.`}),Nm=x({type:m(`running`)}).annotate({identifier:`SessionActive`}),Pm=x({...re(gp.fields,[`location`]),location:bo}).annotate({identifier:`Session.Info`}),Fm=x({info:Pm,messages:h(nm)}).annotate({identifier:`SessionTransfer.Data`}),Im=x({...re(pf.fields,[`location`]),location:bo}).annotate({identifier:`Session.Inbox.MovePayload`}),Lm=x({...re(wf.fields,[`payload`]),payload:Im}).annotate({identifier:`Session.Inbox.Move`}),Rm=C([bf,Sf,Cf,Lm]).annotate({identifier:`Session.Inbox.Info`});x({data:h(C([xf,Sf,Cf,Lm]).annotate({identifier:`Session.Inbox.MediaInfo`}))});var zm=h(Te).pipe(wt(h(Ie),{decode:_t(xm),encode:le({strict:!1})}),wt(h(nm),{decode:le({strict:!1}),encode:le({strict:!1})})),Bm=x({id:Vs.pipe(w),title:tc.fields.title,metadata:tc.fields.metadata,fields:tc.fields.fields}).annotate({identifier:`Form.CreatePayload`}),Vm=v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(e=>e?`true`:`false`)})),Hm=x({limit:oe.pipe(wt(R),w).annotate({description:`Maximum number of sessions to return. Defaults to the newest 50 sessions.`}),...yp.fields,cursor:wp.pipe(w)}).annotate({identifier:`SessionsQuery`}),Um=(e,t)=>j(`server.session`).add(k(`session.list`,`/api/session`,{query:Hm,success:x({data:h(Pm),cursor:x({previous:wp.pipe(w),next:wp.pipe(w)})}).annotate({identifier:`SessionsResponse`}),error:[us,Uo]}).annotateMerge(O({identifier:`session.list`,summary:`List sessions`,description:`Retrieve sessions in the requested order. Items keep that order across pages; use cursor.next or cursor.previous to move through the ordered list.`}))).add(k(`session.stats`,`/api/experimental/session/stats`,{query:x({from:oe.pipe(w),to:oe.pipe(w),project:Fu.pipe(w),timezone:y.pipe(w),tools:gm.pipe(w)}),success:x({data:ym}),error:Uo}).annotateMerge(O({identifier:`experimental.session.stats`,summary:`Get session statistics`,description:`Aggregate local session activity, usage, and tool reliability for a time range.`}))).add(T(`session.create`,`/api/session`,{payload:x({id:Y.pipe(w),parentID:Y.pipe(w),title:y.pipe(w),agent:ku.pipe(w),model:al.pipe(w),location:bo.pipe(w),metadata:pp.pipe(w),permissions:Eu.pipe(w)}),success:x({data:Pm}),error:G}).annotateMerge(O({identifier:`session.create`,summary:`Create session`,description:`Create a session at the requested location. A parentID creates a linked child session at its parent's location.`}))).add(T(`session.import`,`/api/experimental/session/import`,{payload:x({info:Fm.fields.info,messages:zm,location:bo.pipe(w)}),success:x({data:Pm}),error:[qo,G]}).annotateMerge(O({identifier:`experimental.session.import`,summary:`Import session`,description:`Import a projected session transcript at the requested location. Accepts transcripts exported by earlier releases. If parentID is supplied, the parent session must already exist; import parents before children.`}))).add(k(`session.export`,`/api/experimental/session/:sessionID/export`,{params:{sessionID:Y},query:x({sanitize:Vm.pipe(w)}),success:x({data:Fm}),error:[G,Xo]}).annotateMerge(O({identifier:`experimental.session.export`,summary:`Export session`,description:`Export a complete projected session transcript.`}))).add(k(`session.active`,`/api/session/active`,{success:x({data:b(Y,Nm)})}).annotateMerge(O({identifier:`session.active`,summary:`List active sessions`,description:`Retrieve foreground Session drains currently owned by this OpenCode process. Sessions absent from the result are inactive.`}))).add(k(`session.get`,`/api/session/:sessionID`,{params:{sessionID:Y},success:x({data:Pm}),error:G}).annotateMerge(O({identifier:`session.get`,summary:`Get session`,description:`Retrieve a session by ID.`}))).add(ft(`session.remove`,`/api/session/:sessionID`,{params:{sessionID:Y},success:S,error:G}).annotateMerge(O({identifier:`session.remove`,summary:`Delete session`,description:`Delete a session and its child sessions.`}))).add(T(`session.fork`,`/api/session/:sessionID/fork`,{params:{sessionID:Y},payload:x({before:K.pipe(w)}),success:x({data:Pm}),error:[G,as,Uo]}).annotateMerge(O({identifier:`session.fork`,summary:`Fork session`,description:`Create a child session by copying projected history before a message. Omit before to copy the full history.`}))).add(T(`session.switchAgent`,`/api/session/:sessionID/agent`,{params:{sessionID:Y},payload:x({agent:ku}),success:S,error:G}).annotateMerge(O({identifier:`session.switchAgent`,summary:`Switch session agent`,description:`Switch the agent used by subsequent provider turns.`}))).add(T(`session.switchModel`,`/api/session/:sessionID/model`,{params:{sessionID:Y},payload:x({model:al}),success:S,error:G}).annotateMerge(O({identifier:`session.switchModel`,summary:`Switch session model`,description:`Switch the model used by subsequent provider turns.`}))).add(Be(`session.update`,`/api/session/:sessionID`,{params:{sessionID:Y},payload:x({title:y.pipe(w),metadata:pp.pipe(w),permissions:Eu.pipe(w),archived:g.pipe(w).annotate({description:`Archive the session with true or restore it with false. Repeating the current state is a no-op.`})}),success:S,error:[G,Ho]}).annotateMerge(O({identifier:`session.update`,summary:`Update session`,description:`Update mutable session properties.`}))).add(T(`session.move`,`/api/session/:sessionID/move`,{params:{sessionID:Y},payload:x({...bo.fields,delivery:cf.pipe(w)}),success:S,error:[G,Uo]}).annotateMerge(O({identifier:`session.move`,summary:`Move session`,description:`Move a session to another project directory at the requested delivery boundary.`}))).add(T(`session.prompt`,`/api/session/:sessionID/prompt`,{params:{sessionID:Y},payload:x({id:K.pipe(w),...fm.fields,metadata:lf.fields.metadata,delivery:cf.pipe(w),resume:g.pipe(w)}),success:x({data:bf}),error:[qo,Uo,G]}).middleware(e).annotateMerge(O({identifier:`session.prompt`,summary:`Send message`,description:`Durably admit one session input and schedule agent-loop execution unless resume is false.`}))).add(T(`session.command`,`/api/session/:sessionID/command`,{params:{sessionID:Y},payload:x({name:y,...fm.fields,delivery:cf.pipe(w)}),success:S,error:[G,cs,ls]}).middleware(e).annotateMerge(O({identifier:`session.command`,summary:`Run command`,description:`Execute a slash command callback immediately.`}))).add(T(`session.skill`,`/api/experimental/session/:sessionID/skill`,{params:{sessionID:Y},payload:x({id:No,resume:g.pipe(w)}),success:S,error:[G,os]}).middleware(e).annotateMerge(O({identifier:`experimental.session.skill`,summary:`Activate skill`,description:`Activate a skill for a session by appending a skill message and resuming execution.`}))).add(T(`session.synthetic`,`/api/session/:sessionID/synthetic`,{params:{sessionID:Y},payload:x({id:K.pipe(w),text:y,description:y.pipe(w),metadata:yd.fields.metadata,delivery:cf.pipe(w),resume:g.pipe(w)}),success:x({data:Sf}),error:[qo,G]}).middleware(e).annotateMerge(O({identifier:`session.synthetic`,summary:`Add synthetic message`,description:`Durably admit synthetic session input and schedule execution unless resume is false.`}))).add(T(`session.shell`,`/api/session/:sessionID/shell`,{params:{sessionID:Y},payload:x({id:K.pipe(w),command:y}),success:S,error:G}).middleware(e).annotateMerge(O({identifier:`session.shell`,summary:`Run shell command`,description:`Execute one shell command in the session's working directory. Emits a shell.started event before execution and a shell.ended event with the merged output after.`}))).add(T(`session.compact`,`/api/session/:sessionID/compact`,{params:{sessionID:Y},payload:x({id:K.pipe(w),delivery:cf.pipe(w)}),success:x({data:Cf}),error:[qo,G]}).middleware(e).annotateMerge(O({identifier:`session.compact`,summary:`Compact session`,description:`Durably admit a session compaction request. Steers by default: it runs at the next step boundary instead of waiting behind queued prompts.`}))).add(T(`session.wait`,`/api/experimental/session/:sessionID/wait`,{params:{sessionID:Y},success:S,error:[G,Yo]}).annotateMerge(O({identifier:`experimental.session.wait`,summary:`Wait for session`,description:`Wait for a session agent loop to become idle.`}))).add(T(`session.revert.stage`,`/api/session/:sessionID/revert/stage`,{params:{sessionID:Y},payload:x({messageID:K,files:g.pipe(w)}),success:x({data:Kd}),error:[as,G,Jo,Xo]}).middleware(e).annotateMerge(O({identifier:`session.revert.stage`,summary:`Stage session revert`,description:`Stage or move a reversible session boundary and optionally apply its file changes.`}))).add(ft(`session.revert.clear`,`/api/session/:sessionID/revert`,{params:{sessionID:Y},success:S,error:[G,Jo,Xo]}).middleware(e).annotateMerge(O({identifier:`session.revert.clear`,summary:`Clear staged revert`}))).add(T(`session.revert.commit`,`/api/session/:sessionID/revert/commit`,{params:{sessionID:Y},success:S,error:[G,Jo]}).annotateMerge(O({identifier:`session.revert.commit`,summary:`Commit staged revert`}))).add(k(`session.context`,`/api/session/:sessionID/context`,{params:{sessionID:Y},success:x({data:h(nm)}),error:[G,Xo]}).annotateMerge(O({identifier:`session.context`,summary:`Get session context`,description:`Retrieve the active context messages for a session (all messages after the last compaction).`}))).add(k(`session.diff`,`/api/session/:sessionID/diff`,{params:{sessionID:Y},query:x({from:w(K).annotate({description:`User message whose turn to diff. Defaults to the turn of the newest user message.`}),to:w(K).annotate({description:"Later user message whose turn ends the range. Defaults to the turn of `from` alone."}),context:oe.pipe(wt(z),w).annotate({description:`Unchanged lines around each hunk. Omit for full-file patches.`})}),success:x({data:h(Wd)}),error:[Uo,as,G,Xo,Ho]}).annotateMerge(O({identifier:`session.diff`,summary:`Diff session turns`,description:"Structured per-file diffs of the files a turn changed. A turn runs from the first prompt after the session was last idle until its next idle marker, so prompts steered in while it was busy belong to the same turn; `to` extends the range through a later turn. Compares the range's first recorded snapshot with its last; a step still running in the active session compares against the working copy. Ranges that span a location change are rejected. In sessions without any idle marker, a prompt's turn spans until the next user message."}))).add(k(`session.inbox.list`,`/api/session/:sessionID/inbox`,{params:{sessionID:Y},success:x({data:h(Rm)}),error:G}).annotateMerge(O({identifier:`session.inbox.list`,summary:`List session inbox`,description:`List durable enqueued session work not yet delivered, ordered by enqueue sequence. Includes user, synthetic, compaction, and move items.`}))).add(ft(`session.inbox.cancel`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},success:S,error:G}).annotateMerge(O({identifier:`session.inbox.cancel`,summary:`Cancel inbox input`,description:`Cancel an inbox item that has not yet been delivered. Unavailable items are a no-op.`}))).add(Be(`session.inbox.update`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},payload:x({delivery:cf}),success:S,error:[qo,G]}).annotateMerge(O({identifier:`session.inbox.update`,summary:`Update inbox item`,description:`Change a pending inbox item's delivery mode. Steering wakes session execution.`}))).add(k(`session.instructions.entry.list`,`/api/experimental/session/:sessionID/instructions/entries`,{params:{sessionID:Y},success:x({data:h(rf)}),error:G}).annotateMerge(O({identifier:`experimental.session.instructions.entry.list`,summary:`List instruction entries`,description:`List API-managed instruction entries attached to the session.`}))).add(Ct(`session.instructions.entry.put`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:nf},payload:x({value:Te}),success:S,error:[G,of]}).annotateMerge(O({identifier:`experimental.session.instructions.entry.put`,summary:`Put instruction entry`,description:`Attach or replace one durable instruction entry. Changes announce as updates at the next step boundary.`}))).add(ft(`session.instructions.entry.remove`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:nf},success:S,error:G}).annotateMerge(O({identifier:`experimental.session.instructions.entry.remove`,summary:`Remove instruction entry`,description:`Remove one instruction entry; the removal is announced to the model at the next step boundary.`}))).add(T(`session.generate`,`/api/session/:sessionID/generate`,{params:{sessionID:Y},payload:x({prompt:y}),success:x({data:x({text:y})}).annotate({identifier:`SessionGenerateResponse`}),error:[G,Yo]}).middleware(e).annotateMerge(O({identifier:`session.generate`,summary:`Generate text from session context`,description:`Generate transient text from the current session context without mutating session history.`}))).add(k(`session.log`,`/api/experimental/session/:sessionID/log`,{params:{sessionID:Y},query:{after:oe.pipe(wt(To),w),follow:Vm.pipe(w)},success:qe({data:C([up,Mm]).annotate({identifier:`SessionLogItem`})}),error:G}).annotateMerge(O({identifier:`session.log`,summary:`Read the session log`,description:`Experimental durable session event log. Reads events after an exclusive aggregate sequence and continues with live events when follow=true.`}))).add(T(`session.interrupt`,`/api/session/:sessionID/interrupt`,{params:{sessionID:Y},query:{resume:Vm.pipe(w)},success:x({interrupted:g.annotate({description:`Whether an active execution owned by this OpenCode process was interrupted.`})}).annotate({identifier:`SessionInterruptResponse`}),error:G}).annotateMerge(O({identifier:`session.interrupt`,summary:`Interrupt session execution`,description:`Interrupt active execution owned by this OpenCode process. Returns interrupted=true when an active execution was interrupted and false for the idle no-op. When resume=true, execution resumes pending steering input and next-in-line control items (manual compaction, moves) while queued prompts remain parked.`}))).add(T(`session.background`,`/api/session/:sessionID/background`,{params:{sessionID:Y},success:S,error:G}).annotateMerge(O({identifier:`session.background`,summary:`Background blocking session tools`,description:`Move active foreground backgroundable tools for this session into background observation. Idle requests are a no-op.`}))).add(k(`session.message`,`/api/session/:sessionID/message/:messageID`,{params:{sessionID:Y,messageID:K},success:x({data:nm}),error:[G,as]}).annotateMerge(O({identifier:`session.message.get`,summary:`Get session message`,description:`Retrieve one projected message owned by the Session.`}))).add(k(`session.form.list`,`/api/session/:sessionID/form`,{params:{sessionID:y},success:x({data:h(tc)}),error:G}).middleware(t).annotateMerge(O({identifier:`session.form.list`,summary:`List session forms`,description:`Retrieve pending forms for a session.`}))).add(T(`session.form.create`,`/api/session/:sessionID/form`,{params:{sessionID:y},payload:Bm,success:x({data:tc}),error:[G,qo,Uo]}).middleware(t).annotateMerge(O({identifier:`session.form.create`,summary:`Create session form`,description:`Create a form for a session.`}))).add(k(`session.form.get`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:y,formID:Vs},success:x({data:ac}),error:[G,ps]}).middleware(t).annotateMerge(O({identifier:`session.form.get`,summary:`Get session form`,description:`Retrieve a form and its current state for a session.`}))).add(T(`session.form.reply`,`/api/session/:sessionID/form/:formID/reply`,{params:{sessionID:y,formID:Vs},payload:oc,success:S,error:[G,ms,hs,ps]}).middleware(t).annotateMerge(O({identifier:`session.form.reply`,summary:`Reply to form`,description:`Submit an answer to a pending form.`}))).add(ft(`session.form.cancel`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:y,formID:Vs},query:x({message:w(y)}),success:S,error:[G,ms,ps]}).middleware(t).annotateMerge(O({identifier:`session.form.cancel`,summary:`Cancel form`,description:`Cancel a pending form, optionally telling the asker why it was not answered.`}))).add(Ct(`session.environment`,`/api/session/:sessionID/environment`,{params:{sessionID:Y},payload:x({variables:b(y,y)}),success:S,error:G}).annotateMerge(O({identifier:`session.environment`,summary:`Set session environment`,description:`Replace the process environment used by local shell commands for this session.`}))).add(T(`session.view`,`/api/session/:sessionID/view`,{params:{sessionID:Y},payload:x({idle:co}),success:S,error:G}).annotateMerge(O({identifier:`session.view`,summary:`View session`,description:`Mark the idle transition observed by the viewer as viewed.`}))).annotateMerge(O({title:`session`,description:`Experimental session routes.`})),Wm=e({ID:()=>Gm,Info:()=>Km,PermissionSaved:()=>Wm}),Gm=y.pipe(A(`PermissionSaved.ID`),D({identifier:`PermissionSaved.ID`}),so(e=>({create:()=>e.make(`psv_`+po())}))),Km=x({id:Gm,projectID:go,action:y,resource:y,time:x({created:co,updated:co})}).annotate({identifier:`PermissionSaved.Info`}),qm=(e,t)=>j(`server.permission`).add(k(`permission.request.list`,`/api/permission/request`,{query:X,success:V(h(yu))}).middleware(e).annotateMerge(Z).annotateMerge(O({identifier:`permission.request.list`,summary:`List pending permission requests`,description:`Retrieve pending permission requests for a location.`}))).add(k(`permission.saved.list`,`/api/permission/saved`,{query:x({projectID:Fu.pipe(w)}),success:x({data:h(Km)})}).middleware(e).annotateMerge(O({identifier:`permission.saved.list`,summary:`List saved permissions`,description:`Retrieve saved permissions, optionally filtered by project.`}))).add(Be(`permission.saved.update`,`/api/permission/saved/:id`,{params:{id:Gm},payload:x({action:y.pipe(w),resource:y.pipe(w)}),success:x({data:Km}),error:[fs,qo]}).annotateMerge(O({identifier:`permission.saved.update`,summary:`Update saved permission`,description:`Change the action or resource of a saved permission. Fails with a conflict when the project already has a saved permission with the same action and resource.`}))).add(ft(`permission.saved.remove`,`/api/permission/saved/:id`,{params:{id:Gm},success:S}).annotateMerge(O({identifier:`permission.saved.remove`,summary:`Remove saved permission`,description:`Remove a saved permission by ID.`}))).add(T(`session.permission.create`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},payload:x({id:gu.pipe(w),action:yu.fields.action,resources:yu.fields.resources,save:yu.fields.save,metadata:yu.fields.metadata,source:yu.fields.source,agent:ku.pipe(w)}),success:x({data:x({id:gu,effect:wu})}),error:G}).middleware(t).annotateMerge(O({identifier:`session.permission.create`,summary:`Create permission request`,description:`Evaluate and, when approval is required, create a permission request for a session.`}))).add(k(`session.permission.list`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},success:x({data:h(yu)}),error:[G,Ho]}).annotateMerge(O({identifier:`session.permission.list`,summary:`List session permission requests`,description:`Retrieve pending permission requests owned by a session.`}))).add(k(`session.permission.get`,`/api/session/:sessionID/permission/:requestID`,{params:{sessionID:Y,requestID:gu},success:x({data:yu}),error:[G,ds]}).middleware(t).annotateMerge(O({identifier:`session.permission.get`,summary:`Get permission request`,description:`Retrieve a pending permission request owned by a session.`}))).add(T(`session.permission.reply`,`/api/session/:sessionID/permission/:requestID/reply`,{params:{sessionID:Y,requestID:gu},payload:x({decision:bu,message:y.pipe(w)}),success:S,error:[G,ds]}).middleware(t).annotateMerge(O({identifier:`session.permission.reply`,summary:`Reply to pending permission request`,description:`Respond to a pending permission request owned by a session.`}))).annotateMerge(O({title:`permission`,description:`Experimental permission routes.`})),Jm=e({Entry:()=>Zm,Event:()=>Xm,FileSystem:()=>Jm,FindInput:()=>eh,Match:()=>$m,Submatch:()=>Qm,Write:()=>th}),Ym=U({type:`filesystem.changed`,schema:{file:y,event:v([`add`,`change`,`unlink`])}}),Xm={Changed:Ym,Definitions:W(Ym)},Zm=x({path:io,type:v([`file`,`directory`])}).annotate({identifier:`FileSystem.Entry`}),Qm=x({text:y,start:z,end:z}).annotate({identifier:`FileSystem.Submatch`}),$m=x({entry:Zm,line:R,offset:z,text:y,submatches:h(Qm)}).annotate({identifier:`FileSystem.Match`}),eh=class extends p(`FileSystem.FindInput`)({query:y,type:v([`file`,`directory`]).pipe(B),limit:R.pipe(B)}){},th=x({path:ao}).annotate({identifier:`FileSystem.Write`}),nh=x({...X.fields,path:y.pipe(w).annotate({description:`An absolute path or a path relative to the requested location. Defaults to the location directory.`})}),rh=x({...X.fields,path:y.annotate({description:`An absolute path or a path relative to the requested location. Missing parent directories are created.`})}),ih=x({path:y.annotate({description:`A file path relative to the requested location.`})}),ah=x({...X.fields,query:eh.fields.query,type:eh.fields.type,limit:oe.pipe(wt(R),w)}),oh=j(`server.fs`).add(k(`fs.read`,`/api/fs/read/*`,{query:X,success:dt.pipe(mt()),error:ns}).annotateMerge(Z).annotateMerge(O({identifier:`fs.read`,summary:`Read file`,description:`Stream one file relative to the requested location with ETag, Last-Modified, and single-range HTTP Range support (206 Partial Content, 416 Range Not Satisfiable, and 304 Not Modified; multi-range and malformed Range headers fall back to 200).`}))).add(k(`fs.list`,`/api/fs/list`,{query:nh,success:V(h(Zm)),error:ns}).annotateMerge(Z).annotateMerge(O({identifier:`fs.list`,summary:`List directory`,description:`List direct children using an absolute path or a path relative to the requested location, including parents and siblings outside its directory. Entry paths remain relative to the requested location; listing does not switch locations.`}))).add(k(`fs.find`,`/api/fs/find`,{query:ah,success:V(h(Zm))}).annotateMerge(Z).annotateMerge(O({identifier:`fs.find`,summary:`Find files`,description:`Find recursively ranked filesystem entries relative to the requested location.`}))).add(T(`fs.write`,`/api/experimental/fs/write`,{query:rh,payload:dt.pipe(mt()),success:V(th)}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.fs.write`,summary:`Write file`,description:`Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.`}))).add(T(`fs.watch`,`/api/experimental/fs/watch`,{query:X,payload:ih,success:S,error:[ns,Yo]}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.fs.watch`,summary:`Watch file`,description:`Watch one file relative to the requested location for 24 hours, publishing filesystem.changed on that location when it changes. Watching an already watched file resets its expiry. Paths follow read confinement. Experimental: may change without compatibility guarantees.`}))).add(ft(`fs.unwatch`,`/api/experimental/fs/watch`,{query:X,payload:ih,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.fs.unwatch`,summary:`Unwatch file`,description:`Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.`}))).annotateMerge(O({title:`filesystem`,description:`Experimental location-scoped filesystem routes.`})),sh=e=>j(`server.form`).add(k(`form.list`,`/api/form`,{query:X,success:V(h(tc))}).annotateMerge(Z).annotateMerge(O({identifier:`form.list`,summary:`List pending forms`,description:`Retrieve pending forms for a location.`}))).middleware(e).annotateMerge(O({title:`form`,description:`Location form routes.`})),ch=e({Command:()=>ch,Event:()=>dh,Info:()=>uh}),lh=U({type:`command.updated`,schema:{}}),uh=x({name:y,description:y.pipe(B)}).annotate({identifier:`Command.Info`}),dh={Updated:lh,Definitions:W(lh)},fh=j(`server.command`).add(k(`command.list`,`/api/command`,{query:X,success:V(h(uh))}).annotateMerge(Z).annotateMerge(O({identifier:`command.list`,summary:`List commands`,description:`Retrieve currently registered commands.`}))).annotateMerge(O({title:`command`,description:`Experimental command routes.`})),ph=j(`server.skill`).add(k(`skill.list`,`/api/skill`,{query:X,success:V(h(Lo))}).annotateMerge(Z).annotateMerge(O({identifier:`skill.list`,summary:`List skills`,description:`Retrieve currently registered skills.`}))).annotateMerge(O({title:`skill`,description:`Experimental skill routes.`})),mh=x({input:B(Ie)}).annotate({identifier:`Rpc.Input`}),hh=x({output:fe(Ie)}).annotate({identifier:`Rpc.Output`}),gh=j(`server.rpc`).add(T(`rpc.call`,`/api/rpc/:rpcID/:method`,{params:{rpcID:y,method:y},query:X,payload:mh,success:hh,error:[Wo,Go]}).annotateMerge(Z).annotateMerge(O({identifier:`rpc.call`,summary:`Call a plugin RPC`,description:`Dispatch a method to the currently registered RPC at the requested location.`}))).annotateMerge(O({title:`rpc`,description:`Plugin RPC routes.`})),_h=Lc.check(f(/^[^/#]+$/u)),vh=tl.check(f(/^[^#]+$/u)),yh=il.check(f(/^[^#]+$/u)),bh=x({providerID:_h,model:vh,variant:yh.pipe(B)}),xh=y.check(f(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u)),Sh=C([xh,bh]).pipe(wt(bh,{decode:_t(e=>typeof e==`string`?Ch(e):e),encode:le({strict:!1})})).annotate({identifier:`Config.ModelSelection`});function Ch(e){let t=al.parse(e);return{providerID:t.providerID,model:t.id,...t.variant?{variant:t.variant}:{}}}var wh=ge(x(Jc.schema.fields),[b(y,yt(Te))]).annotate({identifier:`Config.Provider.Settings`}),Th=ge(x(cl.schema.fields),[b(y,yt(Te))]).annotate({identifier:`Config.Model.Settings`}),Eh=b(y,Te),Dh={settings:wh.pipe(B),headers:b(y,y).pipe(B),body:Eh.pipe(B)},Oh={settings:Th.pipe(B),headers:b(y,y).pipe(B),body:Eh.pipe(B)},kh=class extends p(`Config.Provider.Request`)({headers:Dh.headers,body:Dh.body}){},Ah=class extends p(`Config.Model.Cost.Cache`)({read:$c.pipe(B),write:$c.pipe(B)}){},jh=class extends p(`Config.Model.Cost`)({tier:x({type:m(`context`),size:a}).pipe(B),input:$c,output:$c,cache:Ah.pipe(B)}){},Mh=class extends p(`Config.Model.Limit`)({context:a.pipe(B),input:a.pipe(B),output:a.pipe(B)}){},Nh=C([x({supported:m(!1)}),x({supported:m(!0),toggle:g.pipe(B),effort:y.pipe(h,B),budget:x({min:a.pipe(B),max:a.pipe(B)}).pipe(B)})]).annotate({identifier:`Config.Model.Reasoning`}),Ph=class extends p(`Config.Model`)({modelID:tl.pipe(B),type:sl.pipe(B),family:ol.pipe(B),name:y.pipe(B),releaseDate:y.check(f(/^\d{4}-\d{2}(-\d{2})?$/u)).annotate({description:`Release date as YYYY-MM-DD or YYYY-MM`}).pipe(B),compatibility:Pc.pipe(B),package:y.pipe(B),...Oh,capabilities:ul.mapFields(e=>({tools:B(e.tools),input:B(e.input),output:B(e.output),temperature:e.temperature,reasoning:Nh.pipe(B)})).annotate({identifier:`Config.Model.Capabilities`}).pipe(B),variants:x({id:il,...Oh}).pipe(h,B),cost:C([jh,jh.pipe(h)]).pipe(B),disabled:g.pipe(B),limit:Mh.pipe(B)}){},Fh=class extends p(`Config.Provider`)({canonical:Lc.pipe(B),name:y.pipe(B),env:y.pipe(h,B),package:y.pipe(B),compatibility:Fc.pipe(B),...Dh,models:b(y,Ph).pipe(B)}){},Ih=y.check(f(/^#[0-9a-fA-F]{6}$/u)),Lh=class extends p(`Config.Agent`)({model:Sh.pipe(B),request:kh.pipe(B),system:y.pipe(B),description:y.pipe(B),mode:v([`subagent`,`primary`,`all`]).pipe(B),hidden:g.pipe(B),color:Ih.pipe(He(()=>ct),B),steps:R.pipe(B),disabled:g.pipe(B),permissions:Eu.pipe(B)}){},Rh=class extends p(`Config.Media.Image`)({auto_resize:g.pipe(B),max_width:R.pipe(B),max_height:R.pipe(B),max_base64_bytes:R.pipe(B)}){},zh=class extends p(`Config.Media`)({image:Rh.pipe(B)}){},Bh=class extends p(`Config.Compaction.Keep`)({tokens:z.pipe(B)}){},Vh=class extends p(`Config.Compaction`)({auto:g.pipe(B),keep:Bh.pipe(B),buffer:z.pipe(B)}){},Hh=class extends p(`Config.Command`)({template:y,description:y.pipe(B),agent:y.pipe(B),model:Sh.pipe(B),subagent:g.pipe(B),subtask:g.annotate({description:`Deprecated alias for subagent.`}).pipe(B)}){},Uh=v([`allow`,`deny`]),Wh=x({action:v([`provider.use`,`tool.use`,`integration.use`]),resource:y,effect:Uh}),Gh=class extends p(`ConfigExperimental.Info`)({portable_shell_scanner:g.pipe(B).annotate({description:`Enable the experimental portable shell permission scanner. Defaults to false.`}),todo:g.pipe(B).annotate({description:`Enable the experimental todowrite tool. Defaults to false.`}),background_compaction:g.pipe(B).annotate({description:`Enable experimental background compaction: summarize the conversation in the background as it nears the compaction threshold, so automatic compaction does not wait for the summary. Background summaries that are never used still cost tokens. Defaults to false.`}),media_blob:g.pipe(B).annotate({description:`Store new session media once in a deduplicated blob table instead of inline in every message row. Defaults to false.`}),subagent_depth:z.pipe(B).annotate({description:`Maximum subagent nesting depth. Defaults to 1.`}),location_idle_timeout:C([ve,m(!1)]).pipe(B).annotate({description:`How long a location can go without session activity before its services are unloaded. Running sessions and background jobs keep a location loaded. Set to false to never unload (default: "60 minutes")`}),policies:Wh.pipe(h,B).annotate({description:`Deprecated: use top-level policies. Ordered policies controlling access to configured resources`})}){},Kh=class extends p(`Config.Formatter.Entry`)({disabled:g.pipe(B),command:y.pipe(h,B),environment:b(y,y).pipe(B),extensions:y.pipe(h,B)}){},qh=C([g,b(y,Kh)]),Jh=x({disabled:m(!0)}),Yh=class extends p(`Config.LSP.Server`)({command:y.pipe(h),extensions:y.pipe(h,B),disabled:g.pipe(B),env:b(y,y).pipe(B),initialization:b(y,Ie).pipe(B)}){},Xh=C([Jh,Yh]),Zh=C([g,b(y,Xh)]),Qh=class extends p(`Mcp.TimeoutConfig`)({startup:R.pipe(B).annotate({description:`Maximum time in milliseconds to establish and initialize the MCP server.`}),catalog:R.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.`}),execution:R.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP tool and prompt execution.`})}){},$h=v([`legacy`,`auto`,`2026-07-28`]).annotate({identifier:`Mcp.Protocol`,description:`MCP protocol negotiation. "legacy" (default) opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "auto" probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "2026-07-28" requires that revision and fails otherwise.`}),eg=class extends p(`Mcp.LocalConfig`)({type:m(`local`),command:y.pipe(h),cwd:y.pipe(B).annotate({description:`Working directory for the MCP server process. Relative paths resolve from the workspace directory.`}),environment:b(y,y).pipe(B),disabled:g.pipe(B),codemode:g.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Qh.pipe(B),protocol:$h.pipe(B)}){},tg=class extends p(`Mcp.OAuthConfig`)({client_id:y.pipe(B),client_secret:y.pipe(B),scope:y.pipe(B),callback_port:a.check(Pt({minimum:1,maximum:65535})).pipe(B),redirect_uri:y.pipe(B),auth_server_metadata_url:y.pipe(B).annotate({description:`URL of the OAuth or OpenID Connect authorization server metadata document. Set when the MCP server does not publish protected resource metadata that names its authorization server.`})}){},ng=class extends p(`Mcp.RemoteConfig`)({type:m(`remote`),url:y,headers:b(y,y).pipe(B),oauth:C([tg,m(!1)]).pipe(B),disabled:g.pipe(B),codemode:g.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Qh.pipe(B),protocol:$h.pipe(B)}){},rg=C([eg,ng]).pipe(ye(`type`)),ig=x({status:m(`connected`)}).annotate({identifier:`Mcp.Status.Connected`}),ag=x({status:m(`pending`)}).annotate({identifier:`Mcp.Status.Pending`}),og=x({status:m(`disabled`)}).annotate({identifier:`Mcp.Status.Disabled`}),sg=x({status:m(`failed`),error:y}).annotate({identifier:`Mcp.Status.Failed`}),cg=x({status:m(`needs_auth`),error:y}).annotate({identifier:`Mcp.Status.NeedsAuth`}),lg=C([ig,ag,og,sg,cg]).pipe(ye(`status`)),ug=x({name:y,status:lg,title:B(y),integrationID:B(Cs)}).annotate({identifier:`Mcp.Server`}),dg=x({server:y,name:y,uri:y,description:B(y),mimeType:B(y)}).annotate({identifier:`Mcp.Resource`}),fg=x({server:y,name:y,uriTemplate:y,description:B(y),mimeType:B(y)}).annotate({identifier:`Mcp.ResourceTemplate`}),pg=x({resources:h(dg),templates:h(fg)}).annotate({identifier:`Mcp.ResourceCatalog`}),mg=C([x({type:m(`text`),uri:y,text:y,mimeType:B(y)}),x({type:m(`blob`),uri:y,blob:y,mimeType:B(y)})]).pipe(ye(`type`),D({identifier:`Mcp.ResourceContentPart`}));x({server:y,uri:y,contents:h(mg)}).annotate({identifier:`Mcp.ResourceContent`});var hg=Qh,gg=rg,_g=class extends p(`Config.MCP`)({timeout:hg.pipe(B),servers:b(y,gg).pipe(B)}){},vg=class extends p(`Config.Plugin.Entry`)({package:y,options:b(y,Ie).pipe(B)}){},yg=C([y,vg]).pipe(h),bg=class extends p(`Config.Reference.Git`)({repository:y,branch:y.pipe(B),description:y.pipe(B),hidden:g.pipe(B)}){},xg=class extends p(`Config.Reference.Local`)({path:y,description:y.pipe(B),hidden:g.pipe(B)}){},Sg=C([y,bg,xg]),Cg=b(y,Sg),wg=e({Event:()=>jg,ID:()=>Tg,Input:()=>Dg,Provider:()=>Eg,Response:()=>kg,Result:()=>Og,WebSearch:()=>wg}),Tg=y.pipe(A(`WebSearch.ID`),D({identifier:`WebSearch.ID`})),Eg=x({id:Tg,name:y}).annotate({identifier:`WebSearch.Provider`}),Dg=x({query:y,providerID:Tg.pipe(B)}).annotate({identifier:`WebSearch.Input`}),Og=x({url:y,title:y.pipe(B),content:y.pipe(B),time:x({published:N.pipe(B).annotate({description:`Publication time in milliseconds since the Unix epoch`})})}).annotate({identifier:`WebSearch.Result`}),kg=class extends p(`WebSearch.Response`)({providerID:Tg,results:h(Og)}){},Ag=U({type:`websearch.updated`,schema:{}}),jg={Updated:Ag,Definitions:W(Ag)},Mg=class extends p(`ConfigWebSearch.Info`)({provider:C([m(`random`).annotate({description:`Reuse a randomly selected provider until it is rate limited, then switch to another available provider.`}),Tg])}){},Ng=C([m(!1),Mg]),Pg=class extends p(`Config.ToolOutput`)({max_lines:R.pipe(B),max_bytes:R.pipe(B)}){},Fg=class extends p(`Config.Watcher`)({ignore:y.pipe(h,B)}){},Ig=class extends p(`Config.Warming`)({prompt:y.pipe(B).annotate({description:`Prompt sent for keep-alive requests`}),interval:ve.pipe(B).annotate({description:`Idle time between keep-alive requests (default: "4 minutes")`}),duration:ve.pipe(B).annotate({description:`Time after the last active request to keep a session warm (default: "30 minutes")`})}){},Lg=C([g,Ig]),Rg=x({directory:St.pipe(ot(Ce())).annotate({description:`Parent directory for new worktrees, relative to the project's primary checkout when not absolute`})}).annotate({identifier:`Config.Worktree`}),zg=e({Config:()=>zg,Directory:()=>Ug,Document:()=>Hg,Entry:()=>Wg,Event:()=>Kg,Info:()=>Bg,Patch:()=>Vg}),Bg=class extends p(`Config.Info`)({$schema:B(y).annotate({description:`JSON schema reference for configuration validation`}),shell:y.pipe(B).annotate({description:`Default shell to use for terminal and shell tool execution`}),model:Sh.pipe(B).annotate({description:`Default model to use when no session or agent model is selected`}),default_agent:y.pipe(B).annotate({description:`Default primary agent to use when no session agent is selected`}),update:v([`disable`,`notify`,`auto`]).pipe(B).annotate({description:`Disable updates, notify when one is available, or install updates automatically`}),share:v([`manual`,`auto`,`disabled`]).pipe(B).annotate({description:`Control whether sessions may be shared manually, automatically, or not at all`}),enterprise:x({url:y.pipe(B)}).pipe(B).annotate({description:`Enterprise sharing service configuration`}),username:y.pipe(B).annotate({description:`Username displayed in conversations and used for telemetry identity`}),permissions:Eu.pipe(B).annotate({description:`Ordered tool permission rules applied to agent tool use`}),policies:Wh.pipe(h,B).annotate({description:`Ordered policies controlling access to providers, tools, and integrations`}),agents:b(y,Lh).pipe(B).annotate({description:`Named built-in agent overrides and custom agent definitions`}),snapshots:g.pipe(B).annotate({description:`Enable snapshots used for undo and revert behavior`}),watcher:Fg.pipe(B).annotate({description:`Filesystem watcher configuration`}),formatter:qh.pipe(B).annotate({description:`Enable built-in formatters or configure formatter overrides`}),lsp:Zh.pipe(B).annotate({description:`Enable built-in language servers or configure server overrides`}),media:zh.pipe(B).annotate({description:`Media processing configuration`}),tool_output:Pg.pipe(B).annotate({description:`Tool output truncation thresholds`}),mcp:_g.pipe(B).annotate({description:`MCP server configuration`}),compaction:Vh.pipe(B).annotate({description:`Conversation compaction behavior`}),skills:y.pipe(h,B).annotate({description:`Additional paths or URLs to discover skills from`}),commands:b(y,Hh).pipe(B).annotate({description:`Named slash command definitions`}),instructions:y.pipe(h,B).annotate({description:`Additional paths or URLs supplying ambient instructions`}),references:Cg.pipe(B).annotate({description:`Named local directories or Git repositories available as external context`}),websearch:Ng.pipe(B).annotate({description:`Web search provider selection`}),plugins:yg.pipe(B).annotate({description:`Ordered plugin enablement directives and external package declarations`}),worktree:Rg.pipe(B).annotate({description:`Directory defaults for local worktree creation`}),warming:Lg.pipe(B).annotate({description:`Keep recently active sessions warm with transient model requests (default: false)`}),providers:b(y,Fh).pipe(B),experimental:Gh.pipe(B)}){},Vg=x({shell:ce(y)}).annotate({identifier:`Config.Patch`}),Hg=class extends p(`Config.Document`)({type:m(`document`),path:ao.pipe(B),info:Bg}){},Ug=class extends p(`Config.Directory`)({type:m(`directory`),path:ao}){},Wg=C([Hg,Ug]).annotate({identifier:`Config.Entry`}),Gg=U({type:`config.updated`,schema:{}}),Kg={Updated:Gg,Definitions:W(Gg)},qg=e({CreateInput:()=>Yg,Directory:()=>Qg,Event:()=>i_,Info:()=>Zg,List:()=>t_,ListEntry:()=>$g,OperationError:()=>e_,RemoveInput:()=>Xg,StrategyID:()=>Jg,Worktree:()=>qg,adopt:()=>a_}),Jg=St.pipe(ot(Ce()),A(`Worktree.StrategyID`)),Yg=x({projectID:Fu,from:B(ao),branch:B(St.pipe(ot(Ce()))),directory:B(ao).annotate({description:`Parent directory for the new worktree. Uses the project's canonical configuration, then defaults to the server's data directory under worktree/<first six project ID characters>.`}),name:B(y)}).annotate({identifier:`Worktree.CreateInput`}),Xg=x({projectID:Fu,directory:ao,force:g}).annotate({identifier:`Worktree.RemoveInput`}),Zg=x({directory:ao}).annotate({identifier:`Worktree.Info`}),Qg=x({directory:ao,strategy:B(y)}).annotate({identifier:`Worktree.Directory`}),$g=x({directory:ao,type:v([`root`,`worktree`])}).annotate({identifier:`Worktree.ListEntry`}),e_=class extends t()(`Worktree.OperationError`,{message:y,forceRequired:B(g)}){},t_=h(Qg).annotate({identifier:`Worktree.List`}),n_=U({type:`worktree.updated`,schema:{projectID:Fu}}),r_=H({type:`worktree.resolved`,durable:{aggregate:`projectID`,version:1},schema:{projectID:Fu,directory:ao,previous:Fu,adopted:B(h(Fu))}}),i_={Updated:n_,Resolved:r_,Definitions:W(n_,r_)};function a_(e,t){if(e.workspaceID||e.projectID!==t.previous&&e.projectID!==Fu.global&&!t.adopted?.includes(e.projectID)||e.projectID===t.projectID)return;let n=e=>e.replaceAll(`\\`,`/`).split(`/`).reduce((e,t)=>!t||t===`.`?e:t===`..`?e.slice(0,e.lastIndexOf(`/`)):`${e}/${t}`,``),r=n(e.directory),i=n(t.directory),a=/^\/[a-z]:/i.test(i),o=a?r.toLowerCase():r,s=a?i.toLowerCase():i;if(!(o!==s&&!o.startsWith(s+`/`)))return{projectID:t.projectID,subpath:o===s?void 0:r.slice(i.length+1)}}Ao([...cp,i_.Resolved]);var o_=U({type:`file.edited`,schema:{file:y}}),s_={Edited:o_,Definitions:W(o_)},c_=W(U({type:`installation.updated`,schema:{version:y}}),U({type:`installation.update-available`,schema:{version:y}})),l_=y.check(at(`per`)).pipe(A(`PermissionV1.ID`),so(e=>({ascending:t=>e.make(t??`per_`+po())}))),u_=v([`allow`,`deny`,`ask`]).annotate({identifier:`PermissionV1.Action`}),d_=x({permission:y,pattern:y,action:u_}).annotate({identifier:`PermissionV1.Rule`}),f_=h(d_).annotate({identifier:`PermissionV1.Ruleset`}),p_=x({id:l_,sessionID:mu,permission:y,patterns:h(y),metadata:b(y,Ie),always:h(y),tool:w(x({messageID:y,callID:y}))}).annotate({identifier:`PermissionV1.Request`}),m_=v([`once`,`always`,`reject`]),h_=x({reply:m_,message:w(y)}).annotate({identifier:`PermissionV1.ReplyBody`});x({projectID:Fu,patterns:h(y)}).annotate({identifier:`PermissionV1.Approval`}),x({...p_.fields,id:w(l_),ruleset:f_}).annotate({identifier:`PermissionV1.AskInput`}),x({requestID:l_,...h_.fields}).annotate({identifier:`PermissionV1.ReplyInput`}),W(U({type:`permission.asked`,schema:p_.fields}),U({type:`permission.replied`,schema:{sessionID:mu,requestID:l_,reply:m_}}));var g_=N.check(Mt(0)),__=y.check(at(`msg`)).pipe(A(`SessionV1.MessageID`),so(e=>({ascending:t=>e.make(t??`msg_`+po())}))),v_=y.check(at(`prt`)).pipe(A(`SessionV1.PartID`),so(e=>({ascending:t=>e.make(t??`prt_`+po())}))),y_=(e,t)=>{let n=x({name:m(e),data:x(t)}).annotate({identifier:e});return{Schema:n,EffectSchema:n}},b_=y_(`MessageOutputLengthError`,{}),x_=y_(`ProviderAuthError`,{providerID:y,message:y}),S_=y_(`MessageAbortedError`,{message:y}),C_=y_(`StructuredOutputError`,{message:y,retries:z}),w_=y_(`APIError`,{message:y,statusCode:w(z),isRetryable:g,responseHeaders:w(b(y,y)),responseBody:w(y),metadata:w(b(y,y))}),T_=y_(`ContextOverflowError`,{message:y,responseBody:w(y)}),E_=y_(`ContentFilterError`,{message:y}),D_=class extends p(`OutputFormatText`)({type:m(`text`)}){},O_=class extends p(`OutputFormatJsonSchema`)({type:m(`json_schema`),schema:b(y,rt).annotate({identifier:`SessionV1.JSONSchema`}),retryCount:z.pipe(w,Ee(ht(2)))}){},k_=C([D_,O_]).annotate({discriminator:`type`,identifier:`SessionV1.OutputFormat`}),A_={id:v_,sessionID:mu,messageID:__},j_=x({...A_,type:m(`snapshot`),snapshot:y}).annotate({identifier:`SessionV1.SnapshotPart`}),M_=x({...A_,type:m(`patch`),hash:y,files:h(y)}).annotate({identifier:`SessionV1.PatchPart`}),N_=x({...A_,type:m(`text`),text:y,synthetic:w(g),ignored:w(g),time:w(x({start:z,end:w(z)})),metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.TextPart`}),P_=x({...A_,type:m(`reasoning`),text:y,metadata:w(b(y,rt)),time:x({start:z,end:w(z)})}).annotate({identifier:`SessionV1.ReasoningPart`}),F_={text:x({value:y,start:N,end:N}).annotate({identifier:`SessionV1.FilePartSourceText`})},I_=x({start:x({line:z,character:z}),end:x({line:z,character:z})}).annotate({identifier:`SessionV1.Range`}),L_=x({...F_,type:m(`file`),path:y}).annotate({identifier:`SessionV1.FileSource`}),R_=x({...F_,type:m(`symbol`),path:y,range:I_,name:y,kind:z}).annotate({identifier:`SessionV1.SymbolSource`}),z_=x({...F_,type:m(`resource`),clientName:y,uri:y}).annotate({identifier:`SessionV1.ResourceSource`}),B_=C([L_,R_,z_]).annotate({discriminator:`type`,identifier:`SessionV1.FilePartSource`}),V_=x({...A_,type:m(`file`),mime:y,filename:w(y),url:y,source:w(B_)}).annotate({identifier:`SessionV1.FilePart`}),H_=x({...A_,type:m(`agent`),name:y,source:w(x({value:y,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPart`}),U_=x({...A_,type:m(`compaction`),auto:g,overflow:w(g),tail_start_id:w(__)}).annotate({identifier:`SessionV1.CompactionPart`}),W_=x({...A_,type:m(`subtask`),prompt:y,description:y,agent:y,model:w(x({providerID:Lc,modelID:tl})),command:w(y)}).annotate({identifier:`SessionV1.SubtaskPart`}),G_=x({...A_,type:m(`retry`),attempt:z,error:w_.EffectSchema,time:x({created:z})}).annotate({identifier:`SessionV1.RetryPart`}),K_=x({...A_,type:m(`step-start`),snapshot:w(y)}).annotate({identifier:`SessionV1.StepStartPart`}),q_=x({...A_,type:m(`step-finish`),reason:y,snapshot:w(y),cost:N,tokens:x({total:w(N),input:N,output:N,reasoning:N,cache:x({read:N,write:N})})}).annotate({identifier:`SessionV1.StepFinishPart`}),J_=x({status:m(`pending`),input:b(y,rt),raw:y}).annotate({identifier:`SessionV1.ToolStatePending`}),Y_=x({status:m(`running`),input:b(y,rt),title:w(y),metadata:w(b(y,rt)),time:x({start:z})}).annotate({identifier:`SessionV1.ToolStateRunning`}),X_=x({status:m(`completed`),input:b(y,rt),output:y,title:y,metadata:b(y,rt),time:x({start:z,end:z,compacted:w(z)}),attachments:w(h(V_))}).annotate({identifier:`SessionV1.ToolStateCompleted`}),Z_=x({status:m(`error`),input:b(y,rt),error:y,metadata:w(b(y,rt)),time:x({start:z,end:z})}).annotate({identifier:`SessionV1.ToolStateError`}),Q_=C([J_,Y_,X_,Z_]).annotate({discriminator:`status`,identifier:`SessionV1.ToolState`}),$_=x({...A_,type:m(`tool`),callID:y,tool:y,state:Q_,metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.ToolPart`}),ev={id:__,sessionID:A_.sessionID},tv=x({...ev,role:m(`user`),time:x({created:g_}),format:w(k_),summary:w(x({title:w(y),body:w(y),diffs:h(Gd)})),agent:y,model:x({providerID:Lc,modelID:tl,variant:w(y)}),system:w(y),tools:w(b(y,g))}).annotate({identifier:`SessionV1.UserMessage`}),nv=C([N_,W_,P_,V_,$_,K_,q_,j_,M_,H_,G_,U_]).annotate({discriminator:`type`,identifier:`SessionV1.Part`}),rv=C([x_.EffectSchema,y_(`UnknownError`,{message:y,ref:w(y)}).EffectSchema,b_.EffectSchema,S_.EffectSchema,C_.EffectSchema,T_.EffectSchema,E_.EffectSchema,w_.EffectSchema]).annotate({discriminator:`name`});x({id:w(v_),type:m(`text`),text:y,synthetic:w(g),ignored:w(g),time:w(x({start:z,end:w(z)})),metadata:w(b(y,rt))}).annotate({identifier:`SessionV1.TextPartInput`}),x({id:w(v_),type:m(`file`),mime:y,filename:w(y),url:y,source:w(B_)}).annotate({identifier:`SessionV1.FilePartInput`}),x({id:w(v_),type:m(`agent`),name:y,source:w(x({value:y,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPartInput`}),x({id:w(v_),type:m(`subtask`),prompt:y,description:y,agent:y,model:w(x({providerID:Lc,modelID:tl})),command:w(y)}).annotate({identifier:`SessionV1.SubtaskPartInput`});var iv=x({...ev,role:m(`assistant`),time:x({created:z,completed:w(z)}),error:w(rv),parentID:__,modelID:tl,providerID:Lc,mode:y,agent:y,path:x({cwd:y,root:y}),summary:w(g),cost:N,tokens:x({total:w(N),input:N,output:N,reasoning:N,cache:x({read:N,write:N})}),structured:w(rt),variant:w(y),finish:w(y)}).annotate({identifier:`SessionV1.AssistantMessage`}),av=C([tv,iv]).annotate({discriminator:`role`,identifier:`SessionV1.Message`}),ov={durable:{aggregate:`sessionID`,version:1}},sv=x({additions:N,deletions:N,files:N,diffs:B(h(Gd))}),cv=x({input:N,output:N,reasoning:N,cache:x({read:N,write:N})}),lv=x({url:y}),uv=x({messageID:__,partID:B(v_),snapshot:B(y),diff:B(y)}),dv=x({id:tl,providerID:Lc,variant:B(y)}),fv=x({id:mu,slug:y,projectID:Fu,workspaceID:B(_o),directory:y,path:B(y),parentID:B(mu),summary:B(sv),cost:B(N),tokens:B(cv),share:B(lv),title:B(y),agent:B(y),model:B(dv),version:y,metadata:B(b(y,rt)),time:x({created:z,updated:z,compacting:B(z),archived:B(N)}),permission:B(f_),revert:B(uv)}).annotate({identifier:`SessionV1.Info`}),pv={Created:H({type:`session.created`,...ov,schema:{sessionID:mu,info:fv}}),Updated:H({type:`session.updated`,...ov,schema:{sessionID:mu,info:fv}}),Deleted:H({type:`session.deleted`,...ov,schema:{sessionID:mu,info:fv}}),MessageUpdated:H({type:`message.updated`,...ov,schema:{sessionID:mu,info:av}}),MessageRemoved:H({type:`message.removed`,...ov,schema:{sessionID:mu,messageID:__}}),PartUpdated:H({type:`message.part.updated`,...ov,schema:{sessionID:mu,part:nv,time:N}}),PartRemoved:H({type:`message.part.removed`,...ov,schema:{sessionID:mu,messageID:__,partID:v_}})},mv=U({type:`message.part.delta`,schema:{sessionID:mu,messageID:__,partID:v_,field:y,delta:y}}),hv=U({type:`session.diff`,schema:{sessionID:mu,diff:h(Gd)}}),gv=U({type:`session.error`,schema:{sessionID:w(mu),error:iv.fields.error}});({...pv}),W(pv.Created,pv.Updated,pv.Deleted,pv.MessageUpdated,pv.MessageRemoved,pv.PartUpdated,pv.PartRemoved,mv,hv,gv);var _v=W(U({type:`command.executed`,schema:{name:y,sessionID:mu,arguments:y,messageID:__}})),vv=W(U({type:`lsp.updated`,schema:{}})),yv=W(U({type:`location.shutdown`,schema:{}})),bv=U({type:`mcp.tools.changed`,schema:{server:y}}),xv=U({type:`mcp.resources.changed`,schema:{server:y}}),Sv=U({type:`mcp.status.changed`,schema:{server:y}}),Cv=W(bv,xv,Sv),wv=U({type:`models-dev.refreshed`,schema:{}}),Tv={Refreshed:wv,Definitions:W(wv)},Ev=y.pipe(A(`Plugin.ID`),D({identifier:`Plugin.ID`})),Dv=C([x({type:m(`builtin`)}),x({type:m(`package`),target:y,version:y.pipe(B),outdated:m(!0).pipe(B),updating:m(!0).pipe(B)}),x({type:m(`local`),path:y}),x({type:m(`sdk`)})]).annotate({identifier:`Plugin.Source`}),Ov=x({server:m(!0).pipe(B),tui:m(!0).pipe(B),rpc:m(!0).pipe(B),gui:m(!0).pipe(B)}).annotate({identifier:`Plugin.Features`}),kv=x({code:y,revision:y,options:b(y,Te)}).annotate({identifier:`Plugin.GuiBundle`}),Av=C([x({status:m(`active`)}),x({status:m(`failed`),error:y,ref:y.pipe(B)})]).annotate({identifier:`Plugin.State`}),jv=x({id:Ev.pipe(B),source:Dv,features:Ov,state:Av}).annotate({identifier:`Plugin.Info`}),Mv=U({type:`plugin.updated`,schema:{}}),Nv={Updated:Mv,Definitions:W(Mv)},Pv=e({Event:()=>Iv,GitSource:()=>Rv,Info:()=>Bv,LocalSource:()=>Lv,Reference:()=>Pv,Source:()=>zv}),Fv=U({type:`reference.updated`,schema:{}}),Iv={Updated:Fv,Definitions:W(Fv)},Lv=x({type:m(`local`),path:ao,description:y.pipe(B),hidden:g.pipe(B)}).annotate({identifier:`Reference.LocalSource`}),Rv=x({type:m(`git`),repository:y,branch:y.pipe(B),description:y.pipe(B),hidden:g.pipe(B)}).annotate({identifier:`Reference.GitSource`}),zv=C([Lv,Rv]).pipe(ye(`type`)).annotate({identifier:`Reference.Source`}),Bv=x({name:y,path:ao,description:y.pipe(B),hidden:g.pipe(B),source:zv}).annotate({identifier:`Reference.Info`}),Vv=W(U({type:`server.connected`,schema:{}}),U({type:`global.disposed`,schema:{}})),Hv=W(U({type:`session.status`,identifier:`SessionStatusUpdated`,schema:{sessionID:mu,status:C([x({type:m(`idle`)}),x({type:m(`retry`),attempt:z,message:y,action:B(x({reason:y,provider:y,title:y,message:y,label:y,link:B(y)})),next:z}),x({type:m(`busy`)})]).annotate({identifier:`SessionStatus`})}}),U({type:`session.idle`,schema:{sessionID:mu}})),Uv=W(U({type:`tui.prompt.append`,schema:{text:y}}),U({type:`tui.command.execute`,schema:{command:C([v([`session.list`,`session.new`,`session.interrupt`,`session.background`,`session.compact`,`session.page.up`,`session.page.down`,`session.line.up`,`session.line.down`,`session.half.page.up`,`session.half.page.down`,`session.first`,`session.last`,`prompt.clear`,`prompt.submit`,`agent.cycle`]),y])}}),U({type:`tui.toast.show`,schema:{title:B(y),message:y,variant:v([`info`,`success`,`warning`,`error`]),duration:R.pipe(Ee(ht(5e3))).annotate({description:`Duration in milliseconds`})}}),U({type:`tui.session.select`,schema:{sessionID:mu.annotate({description:`Session ID to navigate to`})}})),Wv=W(U({type:`vcs.branch.updated`,schema:{branch:B(y)}})),Gv=x({workspaceID:_o,status:v([`connected`,`connecting`,`disconnected`,`error`])}).annotate({identifier:`WorkspaceEvent.ConnectionStatus`}),Kv=W(U({type:`workspace.ready`,schema:{name:y}}),U({type:`workspace.failed`,schema:{message:y}}),U({type:`workspace.status`,schema:Gv.fields})),qv=W(U({type:`worktree.ready`,schema:{name:y,branch:B(y)}}),U({type:`worktree.failed`,schema:{message:y}})),Jv=W(...sp),Yv=W(...yv,...Tv.Definitions,...ks.Definitions,...xc.Definitions,...zc.Definitions,...rl.Definitions,...Nu.Definitions,...Jv),Xv=W(...Xm.Definitions,...Iv.Definitions,...Cu.Definitions,...Nv.Definitions,...Wu.Definitions,...i_.Definitions,...dh.Definitions,...Kg.Definitions,...zo.Definitions,...du.Definitions,...Pp.Definitions,...id.Definitions,...uc.Definitions,...jg.Definitions),Zv=W(...Yv,...Xv,...Hv,...Uv,...c_,...Wv,Sv,xv);Oo(Zv),Oo(W(...Yv,...c_,...Xv,...vv,...Uv,...Cv,..._v,...s_.Definitions,...Hv,...Wv,...Kv,...qv,...Vv));var Qv={id:wo,metadata:w(b(y,Ie)),location:w(bo)},$v=x({id:wo,created:N,metadata:w(b(y,Ie)),type:Ke([`rpc.`,y]),location:bo,data:b(y,Ie)}).annotate({identifier:`V2Event.rpc`}),ey=e=>C([...e,$v,...e.some(e=>e.type===`server.connected`)?[]:[x({...Qv,type:m(`server.connected`),data:x({})}).annotate({identifier:`V2Event.server.connected`})]]).annotate({identifier:`V2Event`}),ty=e=>x({types:w(de(C([v(e.map(e=>e.type)),$v.fields.type]))).annotate({description:`Only send events of these types, plus the initial server.connected event. When omitted, all events are sent.`})}).annotate({identifier:`EventSubscribeQuery`}),ny=(e=>{let t=ey(e);return{schema:t,group:j(`server.event`).add(k(`event.subscribe`,`/api/event`,{query:ty(e),success:qe({data:t})}).annotateMerge(O({identifier:`event.subscribe`,summary:`Subscribe to events`,description:`Subscribe to native events and plugin RPC events across all server locations. Volatile by contract: a slow consumer overflows and fails the stream, and events during disconnection are missed.`}))).annotateMerge(O({title:`event`,description:`Experimental event stream routes.`}))}})(Zv),ry=ny.group;ny.schema;var iy=j(`server.agent`).add(k(`agent.list`,`/api/agent`,{query:X,success:V(h(Mu)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`agent.list`,summary:`List agents`,description:`Retrieve currently registered agents.`}))).add(k(`agent.get`,`/api/agent/:agentID`,{params:{agentID:ku},query:X,success:V(Mu),error:is}).annotateMerge(Z).annotateMerge(O({identifier:`agent.get`,summary:`Get agent`,description:`Retrieve a single currently registered agent.`}))).annotateMerge(O({title:`agent`})),ay=j(`server.plugin`).add(k(`plugin.list`,`/api/plugin`,{query:X,success:V(h(jv))}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.list`,summary:`List plugins`,description:`Retrieve enabled server plugins and their current status.`}))).add(k(`plugin.gui`,`/api/plugin/gui`,{query:x({...X.fields,id:Ev}),success:V(kv),error:rs}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.gui`,summary:`Read plugin GUI bundle`,description:"Read an active plugin's prebuilt CommonJS `./gui-experimental` bundle. Desktop app windows run its default export; the desktop app's main process runs its `main` export. Fails with not found when no active plugin has the id or the plugin exports no `./gui-experimental`."}))).add(T(`plugin.check`,`/api/plugin/check`,{query:X,payload:x({target:y.pipe(w)}),success:V(h(jv)),error:Uo}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.check`,summary:`Check plugin updates`,description:`Check one or all package plugins for available updates.`}))).add(T(`plugin.update`,`/api/plugin/update`,{query:X,payload:x({targets:h(y)}),success:S,error:[Uo,Yo]}).annotateMerge(Z).annotateMerge(O({identifier:`plugin.update`,summary:`Update plugins`,description:`Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.`}))).annotateMerge(O({title:`plugin`,description:`Experimental plugin routes.`})),oy=x({version:y,pid:a.check(Mt(0)),hostname:w(y),urls:h(y),paths:x({tmp:y}),capabilities:w(x({persistentPty:w(g)}))}).annotate({identifier:`ServerInfo`}),sy=x({code:y,expires_in:a}).annotate({identifier:`PairingCode`}),cy=x({token:y}).annotate({identifier:`PairingSession`}),ly=j(`server.server`).add(k(`server.info`,`/api/info`,{success:oy}).annotateMerge(O({identifier:`server.info`,summary:`Get server info`,description:`Return the server identity, connection URLs, paths, and readiness status.`}))).add(T(`server.pair`,`/api/pair`,{success:sy}).annotateMerge(O({identifier:`server.pair`,summary:`Create pairing code`,description:`Create a short-lived, single-use code for a /auth/connect/:code pairing link.`}))).add(k(`server.connect`,`/auth/connect/:code`,{params:{code:y},success:cy,error:Ko}).annotateMerge(O({identifier:`server.connect`,summary:`Redeem pairing code`,description:`Redeem a pairing code. Browsers receive a session cookie and a redirect to the web app; requests that accept JSON receive a session token to use as the password.`}))).annotateMerge(O({title:`server`})),uy=j(`server.debug`).add(T(`debug.heapDump`,`/api/debug/heap-dump`,{query:x({directory:y.pipe(w,D({description:`Absolute server-local directory to write the snapshot into, created when missing. Defaults to the server's log directory.`}))}),success:x({path:y,pid:a,memory:x({rss:gt,heapTotal:gt,heapUsed:gt,external:gt,arrayBuffers:gt}).annotate({description:`The server process's memory in bytes, read just before the snapshot (Node's process.memoryUsage()). rss covers native memory the snapshot cannot show.`})}),error:[Uo,Xo]}).annotateMerge(O({identifier:`debug.heapDump`,summary:`Write a heap snapshot`,description:`Write a JavaScript heap snapshot of the server process into its log directory, or the requested directory, and return the server-local path once the file is complete. Pauses the server while the heap serializes and can temporarily increase its memory use. The snapshot can contain credentials, prompts, and file contents.`}))).add(k(`debug.location`,`/api/debug/location`,{success:h(bo)}).annotateMerge(O({identifier:`debug.location.list`,summary:`List loaded locations`,description:`List locations currently loaded by the server.`}))).add(ft(`debug.location.evict`,`/api/debug/location`,{query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`debug.location.evict`,summary:`Evict a loaded location`,description:`Dispose the requested location's cached services so its next use boots them fresh.`}))).annotateMerge(O({title:`debug`})),dy=j(`server.shell`).add(k(`shell.list`,`/api/shell`,{query:X,success:V(h(ed))}).annotateMerge(Z).annotateMerge(O({identifier:`shell.list`,summary:`List running shell commands`,description:`List currently running shell commands for a location. Exited commands are not included.`}))).add(T(`shell.create`,`/api/shell`,{query:X,payload:ad,success:V(ed)}).annotateMerge(Z).annotateMerge(O({identifier:`shell.create`,summary:`Run shell command`,description:`Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.`}))).add(k(`shell.get`,`/api/shell/:id`,{params:{id:Xu},query:X,success:V(ed),error:vs}).annotateMerge(Z).annotateMerge(O({identifier:`shell.get`,summary:`Get shell command`,description:`Get one shell command, including its status and exit code once exited.`}))).add(k(`shell.output`,`/api/shell/:id/output`,{params:{id:Xu},query:x({...X.fields,...od.fields}),success:V(sd),error:vs}).annotateMerge(Z).annotateMerge(O({identifier:`shell.output`,summary:`Read shell output`,description:`Page through captured combined output by absolute byte cursor.`}))).add(ft(`shell.remove`,`/api/shell/:id`,{params:{id:Xu},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`shell.remove`,summary:`Remove shell command`,description:`Terminate and remove one shell command and its retained output.`}))).annotateMerge(O({title:`shell`,description:`Location-scoped shell command routes.`})),fy=x(re(Lv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.LocalSource`}),py=x(re(Rv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.GitSource`}),my=C([fy,py]).pipe(ye(`type`)).annotate({identifier:`Reference.Source`}),hy=x({...re(Bv.fields,[`source`]),source:my}).annotate({identifier:`Reference.Info`}),gy=j(`server.reference`).add(k(`reference.list`,`/api/reference`,{query:X,success:V(h(hy))}).annotateMerge(Z).annotateMerge(O({identifier:`reference.list`,summary:`List references`,description:`List references available in the requested location.`}))).annotateMerge(O({title:`reference`,description:`Location-scoped project references.`})),_y=class extends tt()(`@opencode/HttpApiAuthorization`,{error:Ko}){},vy=j(`server.integration`).add(k(`integration.list`,`/api/integration`,{query:X,success:V(h(Cc))}).annotateMerge(Z).annotateMerge(O({identifier:`integration.list`,summary:`List integrations`,description:`Retrieve available integrations and their authentication methods.`}))).add(k(`integration.get`,`/api/integration/:integrationID`,{params:{integrationID:fc},query:X,success:V(Cc),error:Qo}).annotateMerge(Z).annotateMerge(O({identifier:`integration.get`,summary:`Get integration`,description:`Retrieve one integration and its authentication methods.`}))).add(T(`integration.wellknown.add`,`/api/experimental/integration/wellknown`,{query:X,payload:x({url:y}),success:S,error:Uo}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.integration.wellknown.add`,summary:`Add wellknown integration`,description:`Discover and persist an experimental wellknown integration source.`}))).add(T(`integration.connect.key`,`/api/integration/:integrationID/connect/key`,{params:{integrationID:fc},query:X,payload:x({key:y,answer:w(rc),label:w(y)}),success:S,error:[Qo,Uo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.connect.key`,summary:`Connect with key`,description:`Run a key authentication method and store the resulting credential.`}))).add(T(`integration.connect.external`,`/api/integration/:integrationID/connect/external`,{params:{integrationID:fc},query:X,payload:x({methodID:pc,answer:w(rc),label:w(y)}),success:S,error:[Qo,Uo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.connect.external`,summary:`Connect with external credentials`,description:`Run an external authentication method and store a reference to its credential source.`}))).add(T(`integration.oauth.connect`,`/api/integration/:integrationID/connect/oauth`,{params:{integrationID:fc},query:X,payload:x({methodID:pc,answer:w(rc),label:w(y)}),success:V(Ec),error:Uo}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.connect`,summary:`Begin OAuth connection`,description:`Start an OAuth attempt and return the authorization details.`}))).add(k(`integration.oauth.status`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:fc,attemptID:wc},query:X,success:V(Dc),error:[Qo,$o]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.status`,summary:`Get OAuth attempt status`,description:`Poll the current status of an OAuth attempt.`}))).add(T(`integration.oauth.complete`,`/api/integration/:integrationID/connect/oauth/:attemptID/complete`,{params:{integrationID:fc,attemptID:wc},query:X,payload:x({code:w(y)}),success:S,error:[Qo,$o,Uo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.complete`,summary:`Complete OAuth connection`,description:`Complete a code-based OAuth attempt and store the resulting credential.`}))).add(ft(`integration.oauth.cancel`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:fc,attemptID:wc},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`integration.oauth.cancel`,summary:`Cancel OAuth connection`,description:`Cancel an OAuth attempt and release its resources.`}))).add(T(`integration.command.connect`,`/api/integration/:integrationID/connect/command`,{params:{integrationID:fc},query:X,payload:x({methodID:pc,label:w(y)}),success:V(Oc),error:[Qo,es,Uo]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.command.connect`,summary:`Begin command connection`,description:`Start a command authentication attempt.`}))).add(k(`integration.command.status`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:fc,attemptID:wc},query:X,success:V(kc),error:[Qo,$o]}).annotateMerge(Z).annotateMerge(O({identifier:`integration.command.status`,summary:`Get command attempt status`,description:`Poll the current status and output of a command authentication attempt.`}))).add(ft(`integration.command.cancel`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:fc,attemptID:wc},query:X,success:S}).annotateMerge(Z).annotateMerge(O({identifier:`integration.command.cancel`,summary:`Cancel command connection`,description:`Cancel a command authentication attempt and terminate its process.`}))).annotateMerge(O({title:`integration`,description:`Integration discovery and authentication routes.`})),yy=j(`server.websearch`).add(k(`websearch.providers`,`/api/websearch/provider`,{query:X,success:V(h(Eg)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`websearch.providers`,summary:`List web search providers`,description:`Return the registered web search providers.`}))).add(T(`websearch.query`,`/api/websearch`,{query:X,payload:x(Dg.fields),success:V(kg),error:[Uo,Yo]}).annotateMerge(Z).annotateMerge(O({identifier:`websearch.query`,summary:`Search the web`,description:`Run one web search through the selected provider. Specify a provider to override the configured default.`}))).annotateMerge(O({title:`websearch`,description:`Location-scoped web search routes.`})),by=N.check(Pt({minimum:0,maximum:100})),xy=N.annotate({description:`Milliseconds since the Unix epoch`}),Sy=x({percent:by,limited:g,resetsAt:xy}).annotate({identifier:`UsageLimits.Meter`}),Cy=x({rolling:Sy,weekly:Sy,monthly:Sy}).annotate({identifier:`UsageLimits.Go`}),wy=x({providerID:Lc,modelID:tl,name:y,spent:Qc.pipe(B)}).annotate({identifier:`UsageLimits.BudgetModel`}),Ty=x({id:y,limit:Qc,spent:Qc,scope:v([`each`,`combined`]),per:v([`set`,`model`]),coverage:v([`all`,`models`]),models:h(wy),vendors:h(y),inputPriceAtLeast:$c.pipe(B),picked:g,shared:g,resetsAt:xy}).annotate({identifier:`UsageLimits.Budget`}),Ey=x({workspace:x({id:y,name:y.pipe(B),usageURL:y}),go:Cy.pipe(B),budgets:h(Ty)}).annotate({identifier:`UsageLimits.Info`}),Dy=j(`server.usage`).add(k(`usage.limits`,`/api/experimental/usage/limits`,{query:X,success:V(ce(Ey)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.usage.limits`,summary:`Get usage limits`,description:`Return the OpenCode Go allowance and Console budgets of the OpenCode Console workspace the location is signed in to, or null when it isn't signed in.`}))).annotateMerge(O({title:`usage`,description:`Experimental usage limit routes.`})),Oy=`/api/experimental/client-mcp`,ky=x({...X.fields,name:y.check(f(/^[a-zA-Z0-9_-]+$/))}),Ay=e=>j(`server.mcp`).add(k(`mcp.list`,`/api/mcp`,{query:X,success:V(h(ug))}).annotateMerge(Z).annotateMerge(O({identifier:`mcp.list`,summary:`List MCP servers`,description:`Retrieve configured MCP servers and their connection status.`}))).add(Ct(`mcp.add`,`/api/experimental/mcp/:server`,{params:{server:y},query:X,payload:x({config:rg}),success:S}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.add`,summary:`Add MCP server`,description:`Add an MCP server at runtime or replace an existing one, connecting it immediately.`}))).add(ft(`mcp.remove`,`/api/experimental/mcp/:server`,{params:{server:y},query:X,success:S,error:ss}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.remove`,summary:`Remove MCP server`,description:`Stop an MCP server and remove it from the runtime set until restart.`}))).add(T(`mcp.connect`,`/api/experimental/mcp/:server/connect`,{params:{server:y},query:X,success:S,error:ss}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.connect`,summary:`Connect MCP server`,description:`Connect an MCP server at runtime, overriding a disabled configuration until restart.`}))).add(T(`mcp.disconnect`,`/api/experimental/mcp/:server/disconnect`,{params:{server:y},query:X,success:S,error:ss}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.disconnect`,summary:`Disconnect MCP server`,description:`Disconnect an MCP server at runtime, removing its tools until reconnected.`}))).add(k(`mcp.resource.catalog`,`/api/mcp/resource`,{query:X,success:V(pg)}).annotateMerge(Z).annotateMerge(O({identifier:`mcp.resource.catalog`,summary:`List MCP resources`,description:`Retrieve resources and resource templates from connected MCP servers.`}))).add(T(`mcp.clientToken`,`${Oy}/token`,{query:ky,headers:x({[Rp]:w(y)}),success:V(Fp),error:gs}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.client.token`,summary:`Create client MCP WebSocket token`,description:`Create a short-lived single-use ticket for opening a client MCP WebSocket connection from a browser.`}))).middleware(e).add(k(`mcp.client`,Oy,{query:x({...ky.fields,[Lp]:w(y)}),success:g,error:[gs,Ho]}).annotateMerge(Z).annotateMerge(O({identifier:`experimental.mcp.client`,summary:`Attach client MCP server`,description:"Upgrade to a WebSocket over which the client hosts an MCP server named after `name`; its tools stay available while the socket is open. One JSON-RPC message per text frame. Experimental: may change without compatibility guarantees.",transform:e=>({...e,"x-websocket":!0})}))).annotateMerge(O({title:`mcp`,description:`MCP server and resource routes.`})),jy=j(`server.credential`).add(k(`credential.list`,`/api/credential`,{success:x({data:h(Ps)})}).annotateMerge(O({identifier:`credential.list`,summary:`List credentials`,description:`List every stored integration credential, including its secret value.`}))).add(T(`credential.create`,`/api/credential`,{payload:Fs,success:x({data:Ps}),error:qo}).annotateMerge(O({identifier:`credential.create`,summary:`Create credential`,description:`Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists.`}))).add(Be(`credential.update`,`/api/credential/:credentialID`,{params:{credentialID:Es},payload:x({label:y}),success:S}).annotateMerge(O({identifier:`credential.update`,summary:`Update credential`,description:`Update a stored credential label.`}))).annotateMerge(O({title:`credential`})).add(T(`credential.activate`,`/api/credential/:credentialID/activate`,{params:{credentialID:Es},success:S}).annotateMerge(O({identifier:`credential.activate`,summary:`Activate credential`,description:`Activate a stored integration credential.`}))).add(ft(`credential.remove`,`/api/credential/:credentialID`,{params:{credentialID:Es},success:S}).annotateMerge(O({identifier:`credential.remove`,summary:`Remove credential`,description:`Remove a stored integration credential.`}))),My=`/api/project`,Ny=x(re(Hu.fields,[`projectID`])),Py=v([`true`,`false`]).pipe(wt(g,{decode:_t(e=>e===`true`),encode:_t(e=>e?`true`:`false`)})),Fy=j(`server.project`).add(k(`project.list`,My,{query:x({archived:Py.pipe(w)}),success:h(Vu)}).annotateMerge(O({identifier:`project.list`,summary:`List projects`,description:`List known projects. Archived projects are excluded unless archived=true.`}))).add(Be(`project.update`,`${My}/:projectID`,{params:{projectID:Fu},payload:Ny,success:Vu,error:ts}).annotateMerge(O({identifier:`project.update`,summary:`Update project`,description:`Update the project canonical directory, display metadata, and workspace commands.`}))).annotateMerge(O({title:`project`,description:`Project routes.`})),Iy=`/api/worktree`,Ly=class extends t()(`WorktreeError`,{name:m(`WorktreeError`),data:x({message:y,forceRequired:w(g)})},{httpApiStatus:400}){},Ry=j(`server.worktree`).add(k(`worktree.list`,Iy,{query:x({projectID:Fu}),success:t_,error:ts}).annotateMerge(O({identifier:`worktree.list`,summary:`List worktrees`,description:`Return the project's saved worktree inventory without loading configuration or running discovery.`}))).add(T(`worktree.create`,Iy,{payload:Yg,success:Zg,error:[Ly,ts]}).annotateMerge(O({identifier:`worktree.create`,summary:`Create worktree`,description:`Load the project's canonical configuration, create a local worktree using its selected strategy, then run the project's setup script.`}))).add(ft(`worktree.remove`,Iy,{payload:Xg,success:S,error:[Ly,ts]}).annotateMerge(O({identifier:`worktree.remove`,summary:`Remove worktree`,description:`Load the project's canonical configuration and remove a saved worktree using its recorded strategy.`}))).add(T(`worktree.refresh`,`${Iy}/refresh`,{payload:x({projectID:Fu}),success:S,error:[Ly,ts]}).annotateMerge(O({identifier:`worktree.refresh`,summary:`Refresh worktrees`,description:`Load the project's canonical configuration, discover worktrees across known checkout roots using all available strategies, and reconcile saved state.`}))).annotateMerge(O({title:`worktree`,description:`Project-based worktree management routes.`})),zy=e({Base:()=>Uy,Branch:()=>By,BranchList:()=>Hy,FileStatus:()=>Ky,Info:()=>Vy,Mode:()=>Wy,Untracked:()=>Gy,Vcs:()=>zy}),By=x({current:B(y),default:B(y)}).annotate({identifier:`Vcs.Branch`}),Vy=x({provider:B(y),branch:By}).annotate({identifier:`Vcs.Info`}),Hy=h(y).annotate({identifier:`Vcs.BranchList`}),Uy=x({name:y,ref:y,source:v([`reflog`,`default`])}).annotate({identifier:`Vcs.Base`}),Wy=v([`working`,`branch`,`committed`]).annotate({identifier:`Vcs.Mode`}),Gy=v([`files`,`folders`]).annotate({identifier:`Vcs.Untracked`}),Ky=x({file:y,additions:z,deletions:z,status:v([`added`,`deleted`,`modified`])}).annotate({identifier:`Vcs.FileStatus`}),qy=x({...X.fields,provider:w(y)}),Jy=class extends t()(`VcsInitNotSupportedError`,{providerID:y,message:y},{httpApiStatus:501}){},Yy=x({...X.fields,search:w(y),limit:oe.pipe(wt(R),w)}),Xy=x({...X.fields,mode:Wy,base:B(y),context:oe.pipe(wt(z),w),untracked:B(Gy)}),Zy=j(`server.vcs`).add(T(`vcs.init`,`/api/vcs/init`,{query:qy,success:S,error:[qo,Uo,Jy,Yo]}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.init`,summary:`Initialize VCS repository`,description:`Initialize a repository using the selected VCS provider in a markerless project's directory and refresh its location services. Omitting provider defaults to git; built-in git and hg providers support initialization. An unknown provider returns 400; a registered provider without init returns 501.`}))).add(k(`vcs.get`,`/api/vcs`,{query:X,success:V(Vy)}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.get`,summary:`VCS info`,description:`Get current and default branch information for the requested location.`}))).add(k(`vcs.base`,`/api/vcs/base`,{query:X,success:V(ce(Uy)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.base`,summary:`VCS review base`,description:`Infer a local review base from named branch creation history, or the repository default only when currently on that branch. Returns null before the first commit or when the provider lacks base metadata; ambiguous Git history requires an explicit base on diff requests.`}))).add(k(`vcs.status`,`/api/vcs/status`,{query:X,success:V(h(Ky))}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.status`,summary:`VCS status`,description:`List uncommitted working-copy changes relative to the requested location.`}))).add(k(`vcs.branch.list`,`/api/vcs/branch`,{query:Yy,success:V(Hy)}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.branch.list`,summary:`VCS branches`,description:`List local and remote branches available at the requested location.`}))).add(k(`vcs.diff`,`/api/vcs/diff`,{query:Xy,success:V(h(Wd)),error:Yo}).annotateMerge(Z).annotateMerge(O({identifier:`vcs.diff`,summary:`VCS diff`,description:`Diff HEAD to the working copy (working), the base merge-base to the working copy (branch), or the base merge-base to HEAD (committed). Omitting base preserves repository-default comparison; supplying it overrides the comparison without saving it.`}))).annotateMerge(O({title:`vcs`,description:`Location-scoped version control routes.`})),Qy=x({label:y,numerator:w(a.check(Mt(0))),denominator:w(a.check(Mt(0)))}),$y=C([x({status:v([`required`,`completed`])}),x({status:m(`running`),progress:Qy}),x({status:m(`error`),error:y})]),eb=j(`server.migration`).add(k(`migration.v1.status`,`/api/experimental/migration/v1`,{success:$y}).annotateMerge(O({identifier:`experimental.migration.v1.status`,summary:`Get V1 migration status`,description:`Return the progress of the V1 to V2 session history migration.`}))).annotateMerge(O({title:`migration`})),tb=x({path:y,name:y,acceptable:g}).annotate({identifier:`ConfigShell.Option`}),nb=j(`server.config`).add(k(`config.get`,`/api/config`,{query:X,success:h(Wg)}).annotateMerge(Z).annotateMerge(O({identifier:`config.get`,summary:`Get configuration`,description:`Return configuration documents and discovery sources for the requested location, from lowest to highest priority.`}))).add(k(`config.shells`,`/api/config/shell`,{success:h(tb)}).annotateMerge(O({identifier:`config.shells`,summary:`List available shells`,description:`Return shells available to terminal and agent execution.`}))).add(Be(`config.update`,`/api/experimental/config`,{payload:Vg,success:S}).annotateMerge(O({identifier:`experimental.config.update`,summary:`Update global configuration`,description:`Patch supported fields in the highest-precedence global configuration document.`}))).annotateMerge(O({title:`config`,description:`Location-scoped configuration routes.`})),rb=(e,t,n,r)=>Pe(`server`).add(ly).add(Ip(t)).add(iy.middleware(t)).add(ay.middleware(t)).add(Um(r,n)).add(am).add(sm.middleware(t)).add(tu).add($p).add(cm.middleware(t)).add(vy.middleware(t)).add(Ay(t)).add(jy).add(Fy).add(sh(t)).add(qm(t,r)).add(oh.middleware(t)).add(fh.middleware(t)).add(ph.middleware(t)).add(gh.middleware(t)).add(e).add(Bp(t)).add(Wp).add(dy.middleware(t)).add(gy.middleware(t)).add(Ry).add(Zy.middleware(t)).add(uy).add(eb).add(yy.middleware(t)).add(Dy.middleware(t)).add(nb.middleware(t)).annotateMerge(O({title:`opencode HttpApi`,version:`0.0.1`,description:`Experimental HttpApi surface for selected instance routes.`})).middleware(_y).middleware(Ss),ib=e=>rb(ry,e.locationMiddleware,e.formLocationMiddleware,e.sessionLocationMiddleware),ab=class extends tt()(`@opencode/client/LocationMiddleware`,{error:[Ho]}){},ob=class extends tt()(`@opencode/client/SessionLocationMiddleware`,{error:[Uo,G,Ho]}){},sb=ib({locationMiddleware:ab,formLocationMiddleware:ob,sessionLocationMiddleware:ob});ra({},{make:()=>kC});var Q=e=>Tt(e)||he(e)||st.is(e)?new ro({cause:e}):e,$=()=>e=>e,cb=()=>e=>e,lb=e=>()=>$()(e[`server.info`]({}).pipe(M(Q))),ub=e=>()=>$()(e[`server.pair`]({}).pipe(M(Q))),db=e=>t=>$()(e[`server.connect`]({params:{code:t.code}}).pipe(M(Q))),fb=e=>({info:lb(e),pair:ub(e),connect:db(e)}),pb=e=>t=>$()(e[`location.get`]({query:{location:t?.location}}).pipe(M(Q))),mb=e=>()=>$()(e[`location.reload`]({}).pipe(M(Q))),hb=e=>({get:pb(e),reload:mb(e)}),gb=e=>t=>$()(e[`agent.list`]({query:{location:t?.location}}).pipe(M(Q))),_b=e=>t=>$()(e[`agent.get`]({params:{agentID:t.agentID},query:{location:t.location}}).pipe(M(Q))),vb=e=>({list:gb(e),get:_b(e)}),yb=e=>t=>$()(e[`plugin.list`]({query:{location:t?.location}}).pipe(M(Q))),bb=e=>t=>$()(e[`plugin.gui`]({query:{location:t.location,id:t.id}}).pipe(M(Q))),xb=e=>t=>$()(e[`plugin.check`]({query:{location:t?.location},payload:{target:t?.target}}).pipe(M(Q))),Sb=e=>t=>$()(e[`plugin.update`]({query:{location:t.location},payload:{targets:t.targets}}).pipe(M(Q))),Cb=e=>({list:yb(e),gui:bb(e),check:xb(e),update:Sb(e)}),wb=e=>t=>$()(e[`session.list`]({query:{limit:t?.limit,order:t?.order,search:t?.search,parentID:t?.parentID,archived:t?.archived,directory:t?.directory,project:t?.project,subpath:t?.subpath,cursor:t?.cursor}}).pipe(M(Q))),Tb=e=>t=>$()(e[`session.stats`]({query:{from:t?.from,to:t?.to,project:t?.project,timezone:t?.timezone,tools:t?.tools}}).pipe(M(Q),E(e=>e.data))),Eb=e=>t=>$()(e[`session.create`]({payload:{id:t?.id,parentID:t?.parentID,title:t?.title,agent:t?.agent,model:t?.model,location:t?.location,metadata:t?.metadata,permissions:t?.permissions}}).pipe(M(Q),E(e=>e.data))),Db=e=>t=>$()(e[`session.import`]({payload:{info:t.info,messages:t.messages,location:t.location}}).pipe(M(Q),E(e=>e.data))),Ob=e=>t=>$()(e[`session.export`]({params:{sessionID:t.sessionID},query:{sanitize:t.sanitize}}).pipe(M(Q),E(e=>e.data))),kb=e=>()=>$()(e[`session.active`]({}).pipe(M(Q),E(e=>e.data))),Ab=e=>t=>$()(e[`session.get`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),jb=e=>t=>$()(e[`session.remove`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Mb=e=>t=>$()(e[`session.fork`]({params:{sessionID:t.sessionID},payload:{before:t.before}}).pipe(M(Q),E(e=>e.data))),Nb=e=>t=>$()(e[`session.switchAgent`]({params:{sessionID:t.sessionID},payload:{agent:t.agent}}).pipe(M(Q))),Pb=e=>t=>$()(e[`session.switchModel`]({params:{sessionID:t.sessionID},payload:{model:t.model}}).pipe(M(Q))),Fb=e=>t=>$()(e[`session.update`]({params:{sessionID:t.sessionID},payload:{title:t.title,metadata:t.metadata,permissions:t.permissions,archived:t.archived}}).pipe(M(Q))),Ib=e=>t=>$()(e[`session.move`]({params:{sessionID:t.sessionID},payload:{directory:t.directory,delivery:t.delivery}}).pipe(M(Q))),Lb=e=>t=>$()(e[`session.prompt`]({params:{sessionID:t.sessionID},payload:{id:t.id,text:t.text,files:t.files,agents:t.agents,skills:t.skills,metadata:t.metadata,delivery:t.delivery,resume:t.resume}}).pipe(M(Q),E(e=>e.data))),Rb=e=>t=>$()(e[`session.command`]({params:{sessionID:t.sessionID},payload:{name:t.name,text:t.text,files:t.files,agents:t.agents,skills:t.skills,delivery:t.delivery}}).pipe(M(Q))),zb=e=>t=>$()(e[`session.skill`]({params:{sessionID:t.sessionID},payload:{id:t.id,resume:t.resume}}).pipe(M(Q))),Bb=e=>t=>$()(e[`session.synthetic`]({params:{sessionID:t.sessionID},payload:{id:t.id,text:t.text,description:t.description,metadata:t.metadata,delivery:t.delivery,resume:t.resume}}).pipe(M(Q),E(e=>e.data))),Vb=e=>t=>$()(e[`session.shell`]({params:{sessionID:t.sessionID},payload:{id:t.id,command:t.command}}).pipe(M(Q))),Hb=e=>t=>$()(e[`session.compact`]({params:{sessionID:t.sessionID},payload:{id:t.id,delivery:t.delivery}}).pipe(M(Q),E(e=>e.data))),Ub=e=>t=>$()(e[`session.wait`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Wb=e=>t=>$()(e[`session.revert.stage`]({params:{sessionID:t.sessionID},payload:{messageID:t.messageID,files:t.files}}).pipe(M(Q),E(e=>e.data))),Gb=e=>t=>$()(e[`session.revert.clear`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),Kb=e=>t=>$()(e[`session.revert.commit`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),qb=e=>t=>$()(e[`session.context`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),Jb=e=>t=>$()(e[`session.diff`]({params:{sessionID:t.sessionID},query:{from:t.from,to:t.to,context:t.context}}).pipe(M(Q),E(e=>e.data))),Yb=e=>t=>$()(e[`session.inbox.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),Xb=e=>t=>$()(e[`session.inbox.cancel`]({params:{sessionID:t.sessionID,inboxID:t.inboxID}}).pipe(M(Q))),Zb=e=>t=>$()(e[`session.inbox.update`]({params:{sessionID:t.sessionID,inboxID:t.inboxID},payload:{delivery:t.delivery}}).pipe(M(Q))),Qb=e=>t=>$()(e[`session.instructions.entry.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),$b=e=>t=>$()(e[`session.instructions.entry.put`]({params:{sessionID:t.sessionID,key:t.key},payload:{value:t.value}}).pipe(M(Q))),ex=e=>t=>$()(e[`session.instructions.entry.remove`]({params:{sessionID:t.sessionID,key:t.key}}).pipe(M(Q))),tx=e=>t=>$()(e[`session.generate`]({params:{sessionID:t.sessionID},payload:{prompt:t.prompt}}).pipe(M(Q),E(e=>e.data))),nx=e=>t=>cb()(r(e[`session.log`]({params:{sessionID:t.sessionID},query:{after:t.after,follow:t.follow}}).pipe(M(Q),E(e=>e.pipe(me(Q)))))),rx=e=>t=>$()(e[`session.interrupt`]({params:{sessionID:t.sessionID},query:{resume:t.resume}}).pipe(M(Q))),ix=e=>t=>$()(e[`session.background`]({params:{sessionID:t.sessionID}}).pipe(M(Q))),ax=e=>t=>$()(e[`session.message`]({params:{sessionID:t.sessionID,messageID:t.messageID}}).pipe(M(Q),E(e=>e.data))),ox=e=>t=>$()(e[`session.form.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),sx=e=>t=>$()(e[`session.form.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,title:t.title,metadata:t.metadata,fields:t.fields}}).pipe(M(Q),E(e=>e.data))),cx=e=>t=>$()(e[`session.form.get`]({params:{sessionID:t.sessionID,formID:t.formID}}).pipe(M(Q),E(e=>e.data))),lx=e=>t=>$()(e[`session.form.reply`]({params:{sessionID:t.sessionID,formID:t.formID},payload:{answer:t.answer}}).pipe(M(Q))),ux=e=>t=>$()(e[`session.form.cancel`]({params:{sessionID:t.sessionID,formID:t.formID},query:{message:t.message}}).pipe(M(Q))),dx=e=>t=>$()(e[`session.environment`]({params:{sessionID:t.sessionID},payload:{variables:t.variables}}).pipe(M(Q))),fx=e=>t=>$()(e[`session.view`]({params:{sessionID:t.sessionID},payload:{idle:t.idle}}).pipe(M(Q))),px=e=>({list:wb(e),stats:Tb(e),create:Eb(e),import:Db(e),export:Ob(e),active:kb(e),get:Ab(e),remove:jb(e),fork:Mb(e),switchAgent:Nb(e),switchModel:Pb(e),update:Fb(e),move:Ib(e),prompt:Lb(e),command:Rb(e),skill:zb(e),synthetic:Bb(e),shell:Vb(e),compact:Hb(e),wait:Ub(e),revert:{stage:Wb(e),clear:Gb(e),commit:Kb(e)},context:qb(e),diff:Jb(e),inbox:{list:Yb(e),cancel:Xb(e),update:Zb(e)},instructions:{entry:{list:Qb(e),put:$b(e),remove:ex(e)}},generate:tx(e),log:nx(e),interrupt:rx(e),background:ix(e),message:{get:ax(e)},form:{list:ox(e),create:sx(e),get:cx(e),reply:lx(e),cancel:ux(e)},environment:dx(e),view:fx(e)}),mx=e=>t=>$()(e[`session.messages`]({params:{sessionID:t.sessionID},query:{limit:t.limit,order:t.order,cursor:t.cursor,type:t.type}}).pipe(M(Q))),hx=e=>({list:mx(e)}),gx=e=>t=>$()(e[`model.list`]({query:{location:t?.location,types:t?.types}}).pipe(M(Q))),_x=e=>t=>$()(e[`model.default`]({query:{location:t?.location}}).pipe(M(Q))),vx=e=>({list:gx(e),default:_x(e)}),yx=e=>t=>$()(e[`generate.text`]({payload:{prompt:t.prompt,model:t.model}}).pipe(M(Q),E(e=>e.data))),bx=e=>t=>$()(e[`generate.image`]({payload:{model:t.model,prompt:t.prompt,images:t.images,n:t.n,aspect:t.aspect,resolution:t.resolution}}).pipe(M(Q),E(e=>e.data))),xx=e=>t=>$()(e[`generate.decisions`]({payload:{model:t.model,input:t.input,questions:t.questions}}).pipe(M(Q),E(e=>e.data))),Sx=e=>({text:yx(e),image:bx(e),decisions:xx(e)}),Cx=e=>()=>$()(e[`voice.models`]({}).pipe(M(Q),E(e=>e.data))),wx=e=>t=>$()(e[`voice.session`]({payload:{model:t.model,session:t.session,transport:t.transport}}).pipe(M(Q),E(e=>e.data))),Tx=e=>({models:Cx(e),session:wx(e)}),Ex=e=>t=>$()(e[`provider.list`]({query:{location:t?.location}}).pipe(M(Q))),Dx=e=>t=>$()(e[`provider.get`]({params:{providerID:t.providerID},query:{location:t.location}}).pipe(M(Q))),Ox=e=>({list:Ex(e),get:Dx(e)}),kx=e=>t=>$()(e[`integration.list`]({query:{location:t?.location}}).pipe(M(Q))),Ax=e=>t=>$()(e[`integration.get`]({params:{integrationID:t.integrationID},query:{location:t.location}}).pipe(M(Q))),jx=e=>t=>$()(e[`integration.wellknown.add`]({query:{location:t.location},payload:{url:t.url}}).pipe(M(Q))),Mx=e=>t=>$()(e[`integration.connect.key`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{key:t.key,answer:t.answer,label:t.label}}).pipe(M(Q))),Nx=e=>t=>$()(e[`integration.connect.external`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,answer:t.answer,label:t.label}}).pipe(M(Q))),Px=e=>t=>$()(e[`integration.oauth.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,answer:t.answer,label:t.label}}).pipe(M(Q))),Fx=e=>t=>$()(e[`integration.oauth.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Ix=e=>t=>$()(e[`integration.oauth.complete`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location},payload:{code:t.code}}).pipe(M(Q))),Lx=e=>t=>$()(e[`integration.oauth.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Rx=e=>t=>$()(e[`integration.command.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,label:t.label}}).pipe(M(Q))),zx=e=>t=>$()(e[`integration.command.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Bx=e=>t=>$()(e[`integration.command.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(M(Q))),Vx=e=>({list:kx(e),get:Ax(e),wellknown:{add:jx(e)},connect:{key:Mx(e),external:Nx(e)},oauth:{connect:Px(e),status:Fx(e),complete:Ix(e),cancel:Lx(e)},command:{connect:Rx(e),status:zx(e),cancel:Bx(e)}}),Hx=e=>t=>$()(e[`mcp.list`]({query:{location:t?.location}}).pipe(M(Q))),Ux=e=>t=>$()(e[`mcp.add`]({params:{server:t.server},query:{location:t.location},payload:{config:t.config}}).pipe(M(Q))),Wx=e=>t=>$()(e[`mcp.remove`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),Gx=e=>t=>$()(e[`mcp.connect`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),Kx=e=>t=>$()(e[`mcp.disconnect`]({params:{server:t.server},query:{location:t.location}}).pipe(M(Q))),qx=e=>t=>$()(e[`mcp.resource.catalog`]({query:{location:t?.location}}).pipe(M(Q))),Jx=e=>t=>$()(e[`mcp.clientToken`]({query:{location:t.location,name:t.name},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q))),Yx=e=>({list:Hx(e),add:Ux(e),remove:Wx(e),connect:Gx(e),disconnect:Kx(e),resource:{catalog:qx(e)},client:{token:Jx(e)}}),Xx=e=>()=>$()(e[`credential.list`]({}).pipe(M(Q),E(e=>e.data))),Zx=e=>t=>$()(e[`credential.create`]({payload:{id:t.id,integrationID:t.integrationID,label:t.label,value:t.value,activate:t.activate}}).pipe(M(Q),E(e=>e.data))),Qx=e=>t=>$()(e[`credential.update`]({params:{credentialID:t.credentialID},payload:{label:t.label}}).pipe(M(Q))),$x=e=>t=>$()(e[`credential.activate`]({params:{credentialID:t.credentialID}}).pipe(M(Q))),eS=e=>t=>$()(e[`credential.remove`]({params:{credentialID:t.credentialID}}).pipe(M(Q))),tS=e=>({list:Xx(e),create:Zx(e),update:Qx(e),activate:$x(e),remove:eS(e)}),nS=e=>t=>$()(e[`project.list`]({query:{archived:t?.archived}}).pipe(M(Q))),rS=e=>t=>$()(e[`project.update`]({params:{projectID:t.projectID},payload:{canonical:t.canonical,name:t.name,icon:t.icon,commands:t.commands}}).pipe(M(Q))),iS=e=>({list:nS(e),update:rS(e)}),aS=e=>t=>$()(e[`form.list`]({query:{location:t?.location}}).pipe(M(Q))),oS=e=>({list:aS(e)}),sS=e=>t=>$()(e[`permission.request.list`]({query:{location:t?.location}}).pipe(M(Q))),cS=e=>t=>$()(e[`permission.saved.list`]({query:{projectID:t?.projectID}}).pipe(M(Q),E(e=>e.data))),lS=e=>t=>$()(e[`permission.saved.update`]({params:{id:t.id},payload:{action:t.action,resource:t.resource}}).pipe(M(Q),E(e=>e.data))),uS=e=>t=>$()(e[`permission.saved.remove`]({params:{id:t.id}}).pipe(M(Q))),dS=e=>t=>$()(e[`session.permission.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,action:t.action,resources:t.resources,save:t.save,metadata:t.metadata,source:t.source,agent:t.agent}}).pipe(M(Q),E(e=>e.data))),fS=e=>t=>$()(e[`session.permission.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),pS=e=>t=>$()(e[`session.permission.get`]({params:{sessionID:t.sessionID,requestID:t.requestID}}).pipe(M(Q),E(e=>e.data))),mS=e=>t=>$()(e[`session.permission.reply`]({params:{sessionID:t.sessionID,requestID:t.requestID},payload:{decision:t.decision,message:t.message}}).pipe(M(Q))),hS=e=>({request:{list:sS(e)},saved:{list:cS(e),update:lS(e),remove:uS(e)},create:dS(e),list:fS(e),get:pS(e),reply:mS(e)}),gS=e=>t=>$()(e[`fs.list`]({query:{location:t?.location,path:t?.path}}).pipe(M(Q))),_S=e=>t=>$()(e[`fs.find`]({query:{location:t.location,query:t.query,type:t.type,limit:t.limit}}).pipe(M(Q))),vS=e=>t=>$()(e[`fs.watch`]({query:{location:t.location},payload:{path:t.path}}).pipe(M(Q))),yS=e=>t=>$()(e[`fs.unwatch`]({query:{location:t.location},payload:{path:t.path}}).pipe(M(Q))),bS=e=>({list:gS(e),find:_S(e),watch:vS(e),unwatch:yS(e)}),xS=e=>t=>$()(e[`command.list`]({query:{location:t?.location}}).pipe(M(Q))),SS=e=>({list:xS(e)}),CS=e=>t=>$()(e[`skill.list`]({query:{location:t?.location}}).pipe(M(Q))),wS=e=>({list:CS(e)}),TS=e=>t=>$()(e[`rpc.call`]({params:{rpcID:t.rpcID,method:t.method},query:{location:t.location},payload:{input:t.input}}).pipe(M(Q))),ES=e=>({call:TS(e)}),DS=e=>t=>cb()(r(e[`event.subscribe`]({query:{types:t?.types}}).pipe(M(Q),E(e=>e.pipe(me(Q)))))),OS=e=>({subscribe:DS(e)}),kS=e=>t=>$()(e[`pty.list`]({query:{location:t?.location}}).pipe(M(Q))),AS=e=>t=>$()(e[`pty.create`]({query:{location:t?.location},payload:{command:t?.command,args:t?.args,cwd:t?.cwd,title:t?.title,env:t?.env}}).pipe(M(Q))),jS=e=>t=>$()(e[`pty.get`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(M(Q))),MS=e=>t=>$()(e[`pty.update`]({params:{ptyID:t.ptyID},query:{location:t.location},payload:{title:t.title,size:t.size}}).pipe(M(Q))),NS=e=>t=>$()(e[`pty.remove`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(M(Q))),PS=e=>t=>$()(e[`pty.connectToken`]({params:{ptyID:t.ptyID},query:{location:t.location},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q))),FS=e=>({list:kS(e),create:AS(e),get:jS(e),update:MS(e),remove:NS(e),connect:{token:PS(e)}}),IS=e=>t=>$()(e[`persistentPty.read`]({params:{sessionID:t.sessionID},query:{lines:t.lines}}).pipe(M(Q),E(e=>e.data))),LS=e=>t=>$()(e[`persistentPty.list`]({params:{sessionID:t.sessionID}}).pipe(M(Q),E(e=>e.data))),RS=e=>t=>$()(e[`persistentPty.create`]({params:{sessionID:t.sessionID},payload:{command:t.command,args:t.args,cwd:t.cwd,title:t.title,env:t.env,size:t.size}}).pipe(M(Q),E(e=>e.data))),zS=e=>()=>$()(e[`persistentPty.shutdown`]({}).pipe(M(Q))),BS=e=>()=>$()(e[`persistentPty.handoff`]({}).pipe(M(Q))),VS=e=>t=>$()(e[`persistentPty.get`]({params:{ptyID:t.ptyID}}).pipe(M(Q),E(e=>e.data))),HS=e=>t=>$()(e[`persistentPty.update`]({params:{ptyID:t.ptyID},payload:{attachmentID:t.attachmentID,size:t.size}}).pipe(M(Q),E(e=>e.data))),US=e=>t=>$()(e[`persistentPty.snapshot`]({params:{ptyID:t.ptyID}}).pipe(M(Q),E(e=>e.data))),WS=e=>t=>$()(e[`persistentPty.remove`]({params:{ptyID:t.ptyID}}).pipe(M(Q))),GS=e=>t=>$()(e[`persistentPty.connectToken`]({params:{ptyID:t.ptyID},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(M(Q),E(e=>e.data))),KS=e=>({persistentPty:{read:IS(e),list:LS(e),create:RS(e),shutdown:zS(e),handoff:BS(e),get:VS(e),update:HS(e),snapshot:US(e),remove:WS(e),connectToken:GS(e)}}),qS=e=>t=>$()(e[`shell.list`]({query:{location:t?.location}}).pipe(M(Q))),JS=e=>t=>$()(e[`shell.create`]({query:{location:t.location},payload:{command:t.command,cwd:t.cwd,timeout:t.timeout,metadata:t.metadata}}).pipe(M(Q))),YS=e=>t=>$()(e[`shell.get`]({params:{id:t.id},query:{location:t.location}}).pipe(M(Q))),XS=e=>t=>$()(e[`shell.output`]({params:{id:t.id},query:{location:t.location,cursor:t.cursor,limit:t.limit}}).pipe(M(Q))),ZS=e=>t=>$()(e[`shell.remove`]({params:{id:t.id},query:{location:t.location}}).pipe(M(Q))),QS=e=>({list:qS(e),create:JS(e),get:YS(e),output:XS(e),remove:ZS(e)}),$S=e=>t=>$()(e[`reference.list`]({query:{location:t?.location}}).pipe(M(Q))),eC=e=>({list:$S(e)}),tC=e=>t=>$()(e[`worktree.list`]({query:{projectID:t.projectID}}).pipe(M(Q))),nC=e=>t=>$()(e[`worktree.create`]({payload:{projectID:t.projectID,from:t.from,branch:t.branch,directory:t.directory,name:t.name}}).pipe(M(Q))),rC=e=>t=>$()(e[`worktree.remove`]({payload:{projectID:t.projectID,directory:t.directory,force:t.force}}).pipe(M(Q))),iC=e=>t=>$()(e[`worktree.refresh`]({payload:{projectID:t.projectID}}).pipe(M(Q))),aC=e=>({list:tC(e),create:nC(e),remove:rC(e),refresh:iC(e)}),oC=e=>t=>$()(e[`vcs.init`]({query:{location:t?.location,provider:t?.provider}}).pipe(M(Q))),sC=e=>t=>$()(e[`vcs.get`]({query:{location:t?.location}}).pipe(M(Q))),cC=e=>t=>$()(e[`vcs.base`]({query:{location:t?.location}}).pipe(M(Q))),lC=e=>t=>$()(e[`vcs.status`]({query:{location:t?.location}}).pipe(M(Q))),uC=e=>t=>$()(e[`vcs.branch.list`]({query:{location:t?.location,search:t?.search,limit:t?.limit}}).pipe(M(Q))),dC=e=>t=>$()(e[`vcs.diff`]({query:{location:t.location,mode:t.mode,base:t.base,context:t.context,untracked:t.untracked}}).pipe(M(Q))),fC=e=>({init:oC(e),get:sC(e),base:cC(e),status:lC(e),branch:{list:uC(e)},diff:dC(e)}),pC=e=>t=>$()(e[`debug.heapDump`]({query:{directory:t?.directory}}).pipe(M(Q))),mC=e=>()=>$()(e[`debug.location`]({}).pipe(M(Q))),hC=e=>t=>$()(e[`debug.location.evict`]({query:{location:t?.location}}).pipe(M(Q))),gC=e=>({heapDump:pC(e),location:{list:mC(e),evict:hC(e)}}),_C=e=>()=>$()(e[`migration.v1.status`]({}).pipe(M(Q))),vC=e=>({v1:{status:_C(e)}}),yC=e=>t=>$()(e[`websearch.providers`]({query:{location:t?.location}}).pipe(M(Q))),bC=e=>t=>$()(e[`websearch.query`]({query:{location:t.location},payload:{query:t.query,providerID:t.providerID}}).pipe(M(Q))),xC=e=>({providers:yC(e),query:bC(e)}),SC=e=>t=>$()(e[`usage.limits`]({query:{location:t?.location}}).pipe(M(Q))),CC=e=>({limits:SC(e)}),wC=e=>t=>$()(e[`config.get`]({query:{location:t?.location}}).pipe(M(Q))),TC=e=>()=>$()(e[`config.shells`]({}).pipe(M(Q))),EC=e=>t=>$()(e[`config.update`]({payload:{shell:t.shell}}).pipe(M(Q))),DC=e=>({get:wC(e),shells:TC(e),update:EC(e)}),OC=e=>({server:fb(e[`server.server`]),location:hb(e[`server.location`]),agent:vb(e[`server.agent`]),plugin:Cb(e[`server.plugin`]),session:px(e[`server.session`]),message:hx(e[`server.message`]),model:vx(e[`server.model`]),generate:Sx(e[`server.generate`]),voice:Tx(e[`server.voice`]),provider:Ox(e[`server.provider`]),integration:Vx(e[`server.integration`]),mcp:Yx(e[`server.mcp`]),credential:tS(e[`server.credential`]),project:iS(e[`server.project`]),form:oS(e[`server.form`]),permission:hS(e[`server.permission`]),file:bS(e[`server.fs`]),command:SS(e[`server.command`]),skill:wS(e[`server.skill`]),rpc:ES(e[`server.rpc`]),event:OS(e[`server.event`]),pty:FS(e[`server.pty`]),experimental:KS(e[`server.experimental`]),shell:QS(e[`server.shell`]),reference:eC(e[`server.reference`]),worktree:aC(e[`server.worktree`]),vcs:fC(e[`server.vcs`]),debug:gC(e[`server.debug`]),migration:vC(e[`server.migration`]),websearch:xC(e[`server.websearch`]),usage:CC(e[`server.usage`]),config:DC(e[`server.config`])}),kC=e=>lt(sb,e).pipe(E(OC)),AC={};ra(AC,{RpcRuntime:()=>AC,event:()=>NC,eventType:()=>PC,read:()=>jC,readError:()=>MC});function jC(e,t){return u(e)?We(e)(t):ht(t)}function MC(e,t){return!(t instanceof Wo)&&!(t instanceof Go)?nt(t):!e.errors||!Object.hasOwn(e.errors,t.type)?nt(t.data===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:t.data}):jC(e.errors[t.type],t.data).pipe(xt(e=>vt(e)),Fe(e=>nt(e===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:e})))}var NC=pt(`Client.Rpc.event`)(function*(e,t,n,r){let i=yield*jC(n.schema,r.data);return{...r,type:PC(e,t),data:i}});function PC(e,t){return`rpc.${e.id}.${t}`}var FC={};ra(FC,{RpcClientRuntime:()=>FC,aborted:()=>LC,make:()=>IC});function IC(e,t){return r=>{let i=Object.fromEntries(Object.entries(r.methods).map(([t,i])=>[t,(a,o)=>{let s=bt(function*(){let n=yield*e({rpcID:r.id,method:t,input:a,location:o?.location},o);return yield*jC(i.output,n.output)}).pipe(xt(e=>MC(i,e))),c=o?.signal;return c?$e(()=>c.aborted?Ve:Je(s,n(LC(c),Ve))):s}]));return Object.assign(i,{events:{subscribe:e=>{let n=PC(r,e);if(!Object.hasOwn(r.events,e))return be(Error(`Unknown RPC event: ${n}`));let i=r.events[e];return t().pipe(Ot(e=>e.type===n),l(t=>NC(r,e,i,t)))}}})}}function LC(e){return Ge(t=>{if(e.aborted)return t(Ne);let n=()=>t(Ne);return e.addEventListener(`abort`,n,{once:!0}),Xe(()=>e.removeEventListener(`abort`,n))})}var RC={};ra(RC,{OpenCode:()=>RC,make:()=>BC});var zC=Re(`@opencode/client/effect/rpc/headers`,{defaultValue:()=>{}}),BC=pt(`OpenCode.make`)(function*(e){let t=yield*Qe,n=yield*kC(e).pipe(Ue(Qe,Ye(t,e=>E(zC,t=>t?Me(e,new Headers(t)):e)))),r=yield*ut(),i=n.event.subscribe();class a{cause;constructor(e){this.cause=e}}let o=aa(e=>it(i.pipe(d(LC(e)),Le(e=>be(new a(e)))),r)),c=e=>Se(o.subscribe({types:e?.types}),e=>e).pipe(At(e=>s(e instanceof a?e.cause:Et(new ro({cause:e})))));return{...n,event:{...n.event,subscribe:c},rpc:Object.assign(IC((e,t)=>n.rpc.call(e).pipe(Ue(zC,t?.headers)),c),n.rpc)}}),VC=e({Answer:()=>GC,Prompt:()=>WC,Question:()=>VC}),HC=x({label:y.annotate({description:`Display text (1-5 words, concise)`}),description:y.annotate({description:`Explanation of choice`})}),UC={question:y.annotate({description:`Complete question`}),header:y.annotate({description:`Very short label (max 30 chars)`}),options:h(HC).annotate({description:`Available choices`}),multiple:g.pipe(B).annotate({description:`Allow selecting multiple choices`})},WC=x(UC).annotate({identifier:`Question.Prompt`}),GC=h(y).annotate({identifier:`Question.Answer`}),KC=e({AbsolutePath:()=>ao,Agent:()=>Du,ClientError:()=>ro,Command:()=>ch,Config:()=>zg,Credential:()=>Ts,Event:()=>Co,EventLog:()=>jm,FileSystem:()=>Jm,Form:()=>Bs,Integration:()=>dc,Location:()=>vo,Model:()=>el,OpenCode:()=>RC,Permission:()=>hu,PermissionSaved:()=>Wm,Project:()=>Pu,Prompt:()=>Tl,PromptInput:()=>lm,Provider:()=>Ic,Pty:()=>iu,Question:()=>VC,Reference:()=>Pv,RelativePath:()=>io,Session:()=>fp,SessionInbox:()=>sf,SessionMessage:()=>dd,Skill:()=>Mo,Vcs:()=>zy,WebSearch:()=>wg,Worktree:()=>qg}),qC=20;function JC(e){return JSON.stringify([e.directory,e.workspaceID])}function YC(e){return{directory:e.directory}}function XC(e){let t=e?.flatMap(e=>{if(!e.uri.startsWith(`data:`))return[];let t=e.uri.indexOf(`,`);if(t<0)return[];let n=e.uri.slice(5,t).split(`;`);if(!n.slice(1).some(e=>e.toLowerCase()===`base64`))return[];let r={data:e.uri.slice(t+1),mime:n[0]||`application/octet-stream`,source:{type:`inline`}};return e.name!==void 0&&(r.name=e.name),e.description!==void 0&&(r.description=e.description),e.mention!==void 0&&(r.mention={...e.mention}),[r]});return t?.length?t:void 0}function ZC(e){let t=e=>e.type===`file`&&e.uri.startsWith(`data:`)?{...e,uri:`data:${e.mime};base64,`}:e;return[t(e[0]),...e.slice(1).map(t)]}function QC(e){return e.type===`assistant`?{...e,content:e.content.map(e=>e.type===`tool`&&`content`in e.state&&e.state.content?{...e,state:{...e.state,content:ZC(e.state.content)}}:e)}:e}function $C(e,t){if(!(e!==`global`||!t))return{headers:{"x-opencode-directory":encodeURIComponent(t.directory)}}}function ew(){let e=new Map,t=(t,n,r)=>{let i={promise:Promise.resolve(),invalidated:!1,started:!r};e.set(t,i);let a=()=>(i.started=!0,n());return i.promise=(r?r.catch(()=>{}).then(a):a()).then(()=>{e.get(t)===i&&!i.invalidated&&e.set(t,!0)}).finally(()=>{e.get(t)===i&&e.delete(t)}),i.promise};return{run(n,r){let i=e.get(n);return i===!0?Promise.resolve():i?i.invalidated?t(n,r,i.promise):i.promise:t(n,r)},complete(t){e.has(t)||e.set(t,!0)},has(t){return e.has(t)},pending(t){let n=e.get(t);return n!==void 0&&n!==!0},invalidate(t){if(t){let n=e.get(t);n===!0&&e.delete(t),n!==void 0&&n!==!0&&n.started&&(n.invalidated=!0);return}e.forEach((t,n)=>{t===!0&&e.delete(n),t!==!0&&t.started&&(t.invalidated=!0)})}}}var tw=200;function nw(e){let t=e.api,n=!1;or(()=>n=!0);function r(t){n||e.connection&&e.connection.status()!==`connected`||t().catch(t=>{if(!(n||e.connection&&e.connection.status()!==`connected`)){if(e.onError)return e.onError(t);console.error(`Failed to refresh client data`,t)}})}let i=new Map;or(()=>i.forEach(e=>clearTimeout(e)));function a(e,t){clearTimeout(i.get(e)),i.set(e,setTimeout(()=>{i.delete(e),r(t)},150))}let[o,s]=Vi({session:{info:{},family:{},active:{},message:{},messageCursor:{},messageLoading:{},pending:{},permission:{},form:{}},project:{info:{},permission:{}},location:{}}),[c,l]=Kn({directory:e.directory}),u=Zn(()=>Object.values(o.session.info).toSorted((e,t)=>t.time.updated-e.time.updated)),d=new Map,f=t=>e.omitToolFileData?QC(t):t,p=ew(),ee,te=new Map;function ne(e,t){ee?.set(e,t),s(`session`,`active`,e,t)}function m(e,t){t&&(te.get(e)?.set(t,void 0),o.session.pending[e]?.some(e=>e.id===t)&&s(`session`,`pending`,e,(o.session.pending[e]??[]).filter(e=>e.id!==t)))}function re(e,t){let n=o.session.permission[e];n?.some(e=>e.id===t)&&s(`session`,`permission`,e,n.filter(e=>e.id!==t))}function ie(e,t,n){let r=o.session.form[e];if(!r)return!1;let i=n&&JC(n),a=r.filter(n=>n.id===t?e!==`global`||!i?!1:!n.location||JC(n.location)!==i:!0);return a.length!==r.length&&(s(`session`,`form`,e,a),!0)}function ae(e,t,n){return n.catch(t=>{if(!Aa(t)&&!Ma(t)||t.id!==e.formID)throw t}).then(()=>{ie(e.sessionID,e.formID,t)&&(y.session.form.invalidate(e.sessionID,t),y.session.form.sync(e.sessionID,t).catch(()=>{}))})}function oe(e,t,n){let r=o.session.pending[e]?.findIndex(e=>e.id===t)??-1,i=o.session.pending[e]?.[r];te.get(e)?.set(t,i?{...i,delivery:n}:n),!(r<0||!i||i.delivery===n)&&s(`session`,`pending`,e,r,{...i,delivery:n})}let se=new Set,ce=new Set,le=new Map,ue=new Map,de=new Map,fe=new Map;or(()=>fe.clear());function h(e,t,n){e.set(t,n);let r=()=>{e.get(t)===n&&e.delete(t)};n.then(r,r)}function pe(e,t,n){let r=le.get(e),i=ue.get(e),a=Promise.resolve().then(()=>Promise.all([n,r,i])).then(t);return h(ue,e,a.catch(()=>{})),a}function me(e){nr(()=>{let t=o.session.pending[e.sessionID]??[],n=t.findIndex(t=>t.id===e.id);s(`session`,`pending`,e.sessionID,n<0?[...t,e]:t.map((t,r)=>r===n?e:t)),e.type!==`compaction`&&he(e)})}function he(e){(e.type===`user`||e.type===`synthetic`)&&_.update(e.sessionID,(t,n)=>{let r=e.type===`user`?{id:e.id,type:`user`,...e.payload,time:{created:e.time.created}}:{id:e.id,type:`synthetic`,...e.payload,time:{created:e.time.created}},i=n.get(e.id);if(i===void 0)return _.append(t,n,r);t[i]=r})}function g(e,t){nr(()=>{m(e,t),d.get(e)?.has(t)&&_.update(e,(e,n)=>{let r=n.get(t);r!==void 0&&(e.splice(r,1),n.delete(t),_.reindex(e,n,r))})})}let _={update(e,t){s(`session`,`message`,$i(n=>{t(n[e]??=[],ge(e))}))},append(e,t,n){t.has(n.id)||(t.set(n.id,e.length),e.push(n))},insert(e,t){_.update(e,(e,n)=>_.append(e,n,t))},editAssistant(e,t,n){d.get(e)?.has(t)&&_.update(e,(e,r)=>{let i=r.get(t),a=i===void 0?void 0:e[i];a?.type===`assistant`&&n(a)})},editTool(e,t,n,r){_.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`tool`&&e.id===n);t&&r(t)})},editText(e,t,n){_.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`text`);t&&n(t)})},editReasoning(e,t,n){_.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`reasoning`&&!e.time?.completed);t&&n(t)})},activeAssistant(e){let t=e.findLast(e=>e.type===`assistant`&&!e.time.completed);return t?.type===`assistant`?t:void 0},shell(e,t){let n=e.findLast(e=>e.type===`shell`&&e.shellID===t);return n?.type===`shell`?n:void 0},compaction(e){let t=e.findLast(e=>e.type===`compaction`&&e.status===`running`);return t?.type===`compaction`?t:void 0},reindex(e,t,n){for(let r=n;r<e.length;r++){let n=e[r];n&&t.set(n.id,r)}}};function ge(e){let t=d.get(e);if(t)return t;let n=new Map;return d.set(e,n),n}async function _e(e){let n=await t().session.list(e);return n.data.length<tw||!n.cursor.next?n.data:[...n.data,...await _e({cursor:n.cursor.next,limit:tw})]}function ve(e){let t=e,n=o.session.info[e]?.parentID,r=new Set([e]);for(;n&&!r.has(n);)r.add(n),t=n,n=o.session.info[n]?.parentID;return t}function ye(e){if(!o.session.info[e])return;let t=ve(e);s(`session`,`family`,$i(n=>{if(e!==t&&n[e]){let r=n[t]??=[];for(let t of n[e])r.includes(t)||r.push(t);delete n[e]}let r=n[t]??=[];r.includes(e)||r.push(e)}))}function be(e){if(ce.has(e))return;p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),de.delete(e);let t=o.session.pending[e]?.filter(e=>se.has(e.id))??[],n=o.session.message[e]?.filter(e=>se.has(e.id))??[];d.delete(e),n.length&&d.set(e,new Map(n.map((e,t)=>[e.id,t]))),s(`session`,$i(r=>{delete r.message[e],delete r.messageCursor[e],delete r.messageLoading[e],delete r.pending[e],n.length&&(r.message[e]=n),t.length&&(r.pending[e]=t)}))}function xe(e){ee?.set(e,void 0),o.session.pending[e]?.forEach(e=>se.delete(e.id)),d.delete(e),p.invalidate(`session:${e}`),p.invalidate(`session.family:${e}`),p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),p.invalidate(`session.permission:${e}`),p.invalidate(`session.form:${e}:`),s(`session`,$i(t=>{delete t.info[e],delete t.active[e],delete t.message[e],delete t.messageCursor[e],delete t.messageLoading[e],delete t.pending[e],delete t.permission[e],delete t.form[e];for(let[n,r]of Object.entries(t.family)){let i=r.filter(t=>t!==e);i.length===0?delete t.family[n]:t.family[n]=i}}))}function Se(n){switch(n.type){case`server.connected`:{let e=new Map;ee=e,r(()=>t().session.active().then(t=>{if(ee!==e)return;let n=new Map(Object.keys(t).map(e=>[e,`running`]));e.forEach((e,t)=>{if(e===void 0)return n.delete(t);n.set(t,e)}),ee=void 0,s(`session`,`active`,Xi(Object.fromEntries(n))),n.forEach((e,t)=>{e===`running`&&!o.session.info[t]&&r(()=>y.session.sync(t))})}).catch(()=>{ee===e&&(ee=void 0)})),r(()=>t().location.get({location:YC(c())}).then(e=>{let t=JC(e);s(`location`,t,{info:e})})),r(()=>y.location.vcs.sync()),r(()=>y.project.sync());return}case`project.updated`:s(`project`,`info`,n.data.id,Xi(n.data));return;case`session.created`:ce.delete(n.data.sessionID),y.session.invalidate(n.data.sessionID),r(()=>y.session.sync(n.data.sessionID)),p.complete(`session.pending:${n.data.sessionID}`),p.complete(`session.message:${n.data.sessionID}`);return;case`session.deleted`:xe(n.data.sessionID);return;case`session.usage.updated`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,{cost:n.data.cost,tokens:n.data.tokens});return;case`session.agent.selected`:{let e=o.session.info[n.data.sessionID]?.agent;o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`agent`,n.data.agent),_.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`agent-switched`,agent:n.data.agent,previous:e,time:{created:n.created}});return}case`session.model.selected`:{let e=n.data.previous??o.session.info[n.data.sessionID]?.model;if(o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`model`,n.data.model),!o.session.message[n.data.sessionID])return;_.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`model-switched`,model:n.data.model,previous:e,time:{created:n.created}}),r(()=>t().session.message.get({sessionID:n.data.sessionID,messageID:K.fromEvent(n.id)}).then(e=>{_.update(n.data.sessionID,(t,n)=>{let r=n.get(e.id);if(r===void 0)return _.append(t,n,e);t[r]=e})}));return}case`session.renamed`:r(()=>{let e=p.pending(`session.family:${n.data.sessionID}`)?y.session.sync(n.data.sessionID,{children:!0}):Promise.resolve();return Promise.all([y.session.sync(n.data.sessionID),e]).then(()=>{o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`title`,n.data.title)})});return;case`session.permissions`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`permissions`,n.data.permissions);return;case`session.archived`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`time`,`archived`,n.created);return;case`session.unarchived`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`time`,`archived`,void 0);return;case`session.moved`:{let e=o.session.info[n.data.sessionID];if(e){let t={location:{...e.location},projectID:e.projectID,subpath:e.subpath};s(`session`,`info`,n.data.sessionID,`location`,n.data.location),s(`session`,`info`,n.data.sessionID,`projectID`,n.data.projectID),s(`session`,`info`,n.data.sessionID,`subpath`,n.data.subpath),_.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`location-switched`,location:n.data.location,projectID:n.data.projectID,subpath:n.data.subpath,previous:t,time:{created:n.created}})}return}case`worktree.resolved`:for(let[e,t]of Object.entries(o.session.info)){let i=n.data.adopted?.includes(t.projectID)?o.project.info[t.projectID]?.canonical:t.location.directory;if(!i){y.session.invalidate(e),r(()=>y.session.sync(e));continue}let a=a_({projectID:t.projectID,directory:i},n.data);a&&(s(`session`,`info`,e,`projectID`,a.projectID),s(`session`,`info`,e,`subpath`,a.subpath))}return;case`session.inbox.delivered`:{let e=y.session.input.has(n.data.sessionID,n.data.inboxID);m(n.data.sessionID,n.data.inboxID),_.update(n.data.sessionID,(t,r)=>{let i=r.get(n.data.inboxID);if(i===void 0)return;let a=t[i];!a||!e||(a.time.created=n.created,t.splice(i,1),t.push(a),_.reindex(t,r,i))}),fe.get(n.data.sessionID)?.observed.add(n.data.inboxID);return}case`session.inbox.delivery.changed`:oe(n.data.sessionID,n.data.inboxID,n.data.delivery);return;case`session.inbox.cancelled`:g(n.data.sessionID,n.data.inboxID),fe.get(n.data.sessionID)?.observed.add(n.data.inboxID);return;case`session.inbox.enqueued`:{se.delete(n.data.inboxID);let e={id:n.data.inboxID,sessionID:n.data.sessionID,time:{created:n.created},...n.data.item};if(te.get(e.sessionID)?.set(e.id,e),me(e),n.data.item.type===`compaction`){let e=fe.get(n.data.sessionID);e?.observed.add(n.data.inboxID),e&&e.id!==n.data.inboxID&&se.delete(e.id)&&m(n.data.sessionID,e.id)}return}case`session.instructions.updated`:let i=n.data.text;if(i===void 0)return;_.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`system`,text:i,description:`Instructions updated: ${Object.keys(n.data.delta).join(`, `)}`,metadata:n.metadata,time:{created:n.created}});return;case`session.synthetic`:_.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`synthetic`,text:n.data.text,description:n.data.description,metadata:n.data.metadata,time:{created:n.created}});return;case`session.shell.started`:_.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`shell`,shellID:n.data.shell.id,command:n.data.shell.command,status:n.data.shell.status,exit:n.data.shell.exit,metadata:n.data.shell.metadata.background===!0?{...n.metadata,background:!0}:n.metadata,time:{created:n.created}});return;case`session.shell.ended`:if(!o.session.message[n.data.sessionID])return;_.update(n.data.sessionID,e=>{let t=_.shell(e,n.data.shell.id);t&&(t.status=n.data.shell.status,t.exit=n.data.shell.exit,t.output=n.data.output,t.time.completed=n.created)});return;case`session.step.started`:_.update(n.data.sessionID,(e,t)=>{let r=t.get(n.data.assistantMessageID),i=r===void 0?void 0:e[r];if(i?.type===`assistant`){i.agent=n.data.agent,i.model=n.data.model,i.retry=void 0,i.error=void 0,i.finish=void 0,i.rawFinish=void 0,i.native=void 0,i.time.created=n.data.started,i.time.streamed=void 0,i.time.completed=void 0,n.data.snapshot&&(i.snapshot={...i.snapshot,start:n.data.snapshot});return}let a=_.activeAssistant(e);a&&(a.retry=void 0,a.time.completed=n.created),_.append(e,t,{id:n.data.assistantMessageID,type:`assistant`,agent:n.data.agent,model:n.data.model,metadata:n.metadata,content:[],snapshot:n.data.snapshot?{start:n.data.snapshot}:void 0,time:{created:n.data.started}})});return;case`session.step.streamed`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.streamed=n.created});return;case`session.step.ended`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.completed=n.created,e.finish=n.data.finish,e.rawFinish=n.data.rawFinish,e.native=n.data.native,e.cost=n.data.cost,e.tokens=n.data.tokens,n.data.snapshot&&(e.snapshot={...e.snapshot,end:n.data.snapshot})});return;case`session.step.failed`:n.location&&(n.data.error.type===`provider.budget-limit`||n.data.error.type===`provider.model-budget-limit`)&&we(n.location),_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.completed=n.created,e.finish=n.data.finish??`error`,e.rawFinish=n.data.rawFinish,e.native=n.data.native,e.error=n.data.error,e.retry=void 0,n.data.cost!==void 0&&n.data.tokens!==void 0&&(e.cost=n.data.cost,e.tokens=n.data.tokens)});return;case`session.text.started`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`text`,text:``})});return;case`session.text.delta`:_.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.text.ended`:_.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text});return;case`session.tool.input.started`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`tool`,id:n.data.id,name:n.data.name,time:{created:n.created},state:{status:`streaming`,input:``}})});return;case`session.tool.input.delta`:_.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`streaming`&&(e.state.input+=n.data.delta)});return;case`session.tool.input.ended`:_.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`streaming`&&(e.state.input=n.data.text)});return;case`session.tool.called`:_.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.time.ran=n.created,e.executed=n.data.executed,e.native=n.data.native,e.state={status:`running`,input:n.data.input,metadata:{}}});return;case`session.tool.progress`:_.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,e=>{e.state.status===`running`&&(e.state.metadata=n.data.metadata)});return;case`session.tool.success`:_.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,t=>{t.state.status===`running`&&(t.state={status:`completed`,input:t.state.input,metadata:n.data.metadata,content:e.omitToolFileData?ZC(n.data.content):[...n.data.content]},t.executed=n.data.executed||t.executed===!0,n.data.native&&(t.native={...t.native,...n.data.native}),t.time.completed=n.created)});return;case`session.tool.failed`:_.editTool(n.data.sessionID,n.data.assistantMessageID,n.data.id,t=>{(t.state.status===`streaming`||t.state.status===`running`)&&(t.state={status:`error`,error:n.data.error,input:typeof t.state.input==`string`?{}:t.state.input,metadata:n.data.metadata,content:e.omitToolFileData&&n.data.content?ZC(n.data.content):n.data.content},t.executed=n.data.executed||t.executed===!0,n.data.native&&(t.native={...t.native,...n.data.native}),t.time.completed=n.created)});return;case`session.reasoning.started`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`reasoning`,text:``,native:n.data.native,time:{created:n.created}})});return;case`session.reasoning.delta`:_.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.reasoning.ended`:_.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text,e.time={created:e.time?.created??n.created,completed:n.created},n.data.native!==void 0&&(e.native=n.data.native)});return;case`session.retry.scheduled`:_.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.retry={attempt:n.data.attempt,at:n.data.at,error:n.data.error}});return;case`session.execution.started`:ne(n.data.sessionID,`running`);return;case`session.compaction.started`:n.data.inputID&&m(n.data.sessionID,n.data.inputID),_.insert(n.data.sessionID,{id:n.data.inputID??K.fromEvent(n.id),type:`compaction`,status:`running`,reason:n.data.reason,summary:``,time:{created:n.created}}),n.data.inputID&&fe.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(ne(n.data.sessionID,`idle`),_.update(n.data.sessionID,e=>{let t=_.activeAssistant(e);t&&(t.retry=void 0)}),n.type===`session.execution.interrupted`&&n.data.reason===`shutdown`||(_.insert(n.data.sessionID,{id:K.fromEvent(n.id),type:`idle`,outcome:n.type===`session.execution.succeeded`?`succeeded`:n.type===`session.execution.failed`?`failed`:`interrupted`,...n.type===`session.execution.failed`?{error:n.data.error}:{},time:{created:n.created}}),o.session.message[n.data.sessionID]?.some(e=>e.type===`assistant`&&e.content.some(e=>e.type===`tool`&&(e.state.status===`streaming`||e.state.status===`running`)))&&(p.invalidate(`session.message:${n.data.sessionID}`),r(()=>y.session.message.sync(n.data.sessionID))),!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`)))return;y.session.invalidate(n.data.sessionID),r(()=>y.session.sync(n.data.sessionID));return;case`session.viewed`:if(!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`))return;y.session.invalidate(n.data.sessionID),r(()=>y.session.sync(n.data.sessionID));return;case`session.revert.staged`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,n.data.revert);return;case`session.revert.cleared`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,void 0);return;case`session.revert.committed`:o.session.info[n.data.sessionID]&&s(`session`,`info`,n.data.sessionID,`revert`,void 0),s(`session`,`pending`,n.data.sessionID,(o.session.pending[n.data.sessionID]??[]).filter(e=>e.id<n.data.to)),_.update(n.data.sessionID,(e,t)=>{let r=e.findIndex(e=>e.id>=n.data.to);if(r!==-1)for(let n of e.splice(r))t.delete(n.id)});return;case`session.compaction.delta`:if(!o.session.message[n.data.sessionID])return;_.update(n.data.sessionID,e=>{let t=_.compaction(e);t?.status===`running`&&(t.summary+=n.data.text)});return;case`session.compaction.ended`:_.update(n.data.sessionID,(e,t)=>{let r=e[e.findLastIndex(e=>e.type===`compaction`&&e.status===`running`)];if(r?.type===`compaction`){Object.assign(r,{status:`completed`,reason:n.data.reason,model:n.data.model,native:n.data.native,summary:n.data.text,cost:n.data.cost,tokens:n.data.tokens});return}_.append(e,t,{id:K.fromEvent(n.id),type:`compaction`,status:`completed`,reason:n.data.reason,model:n.data.model,native:n.data.native,summary:n.data.text,cost:n.data.cost,tokens:n.data.tokens,time:{created:n.created}})});return;case`session.compaction.failed`:n.data.inputID&&m(n.data.sessionID,n.data.inputID),_.update(n.data.sessionID,(e,t)=>{let r=e.findLastIndex(e=>e.type===`compaction`&&e.status===`running`),i=e[r],a={id:i?.id??n.data.inputID??K.fromEvent(n.id),type:`compaction`,status:`failed`,reason:n.data.reason,error:n.data.error,metadata:i?.type===`compaction`?i.metadata:n.metadata,cost:n.data.cost,tokens:n.data.tokens,time:i?.type===`compaction`?i.time:{created:n.created}};if(i?.type===`compaction`){e[r]=a;return}_.append(e,t,a)}),n.data.inputID&&fe.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`permission.asked`:if(o.session.permission[n.data.sessionID]?.some(e=>e.id===n.data.id))return;s(`session`,`permission`,n.data.sessionID,[...o.session.permission[n.data.sessionID]??[],n.data]);return;case`permission.replied`:re(n.data.sessionID,n.data.requestID);return;case`form.replied`:case`form.cancelled`:ie(n.data.sessionID,n.data.id,n.location);return}if(n.type===`credential.updated`||n.type===`credential.switched`){Object.keys(o.location).forEach(e=>{let t=JSON.parse(e),i={directory:t[0],workspaceID:t[1]??void 0};if(we(i),n.type===`credential.updated`){v(`integration`,y.location.integration,i);return}o.location[e]?.integration&&s(`location`,e,e=>({integration:e?.integration?.map(e=>{if(e.id!==n.data.integrationID)return e;let t=e.connections.find(e=>e.type===`credential`&&e.id===n.data.credentialID);return t?{...e,connections:[t,...e.connections.filter(e=>e!==t)]}:e})}));let a=Ce(`integration`,i)||Ce(`model`,i)||Ce(`provider`,i);y.location.model.invalidate(i),y.location.provider.invalidate(i),a&&r(()=>Promise.all([y.location.model.sync(i),y.location.provider.sync(i)]))});return}if(!n.location)return;let i=n.location;switch(n.type){case`provider.updated`:v(`provider`,y.location.provider,i);break;case`model.updated`:v(`model`,y.location.model,i);break;case`agent.updated`:v(`agent`,y.location.agent,i);break;case`command.updated`:v(`command`,y.location.command,i);break;case`skill.updated`:v(`skill`,y.location.skill,i);break;case`vcs.branch.updated`:v(`vcs`,y.location.vcs,i);break;case`form.created`:if(o.session.form[n.data.form.sessionID]?.some(e=>e.id===n.data.form.id))break;s(`session`,`form`,n.data.form.sessionID,[...o.session.form[n.data.form.sessionID]??[],n.data.form.sessionID===`global`?{...n.data.form,location:i}:n.data.form]);break;case`shell.created`:s(`location`,JC(i),e=>({shell:{...e?.shell,[n.data.info.id]:{...n.data.info,location:i}}}));break;case`shell.exited`:case`shell.deleted`:if(!o.location[JC(i)]?.shell?.[n.data.id])break;s(`location`,JC(i),e=>({shell:Object.fromEntries(Object.entries(e?.shell??{}).filter(([e])=>e!==n.data.id))}));break;case`reference.updated`:v(`reference`,y.location.reference,i);break;case`integration.updated`:{we(i);let e=Ce(`integration`,i)||Ce(`model`,i)||Ce(`provider`,i);y.location.integration.invalidate(i),y.location.model.invalidate(i),y.location.provider.invalidate(i),e&&r(()=>Promise.all([y.location.integration.sync(i),y.location.model.sync(i),y.location.provider.sync(i)]));break}case`config.updated`:v(`config`,y.location.config,i),Ce(`websearch`,i)&&r(()=>y.location.websearch.refresh(i));break;case`websearch.updated`:Ce(`websearch`,i)&&r(()=>y.location.websearch.refresh(i));break;case`mcp.status.changed`:{let e=Ce(`mcpServer`,i);y.location.mcp.server.invalidate(i),e&&a(`mcp.status:${JC(i)}`,()=>y.location.mcp.server.sync(i));break}case`mcp.resources.changed`:v(`mcpResource`,y.location.mcp.resource,i)}}function Ce(e,t){let n=JC(t??c());return o.location[n]?.[e]!==void 0||p.has(`location.${e}:${n}`)}function v(e,t,n){let i=Ce(e,n);t.invalidate(n),i&&r(()=>t.sync(n))}function we(e){let t=o.location[JC(e)]?.usageLimits!==void 0||p.has(`location.usageLimits:${JC(e)}`);De.invalidate(e),t&&r(()=>De.sync(e))}function Te(e,t,n){let r=(t,n)=>s(`location`,t,{[e]:n});return{list:t=>o.location[JC(t??c())]?.[e],sync:i=>{let a=i??c(),o=JC(a);return p.run(`location.${e}:${o}`,async()=>{let e=await t(YC(a)),i=JC(e.location);r(i,e.data),n?.alias&&i!==o&&r(o,e.data)})},invalidate:t=>p.invalidate(`location.${e}:${JC(t??c())}`)}}let Ee=Te(`vcs`,e=>t().vcs.get({location:e})),De=Te(`usageLimits`,e=>t().usage.limits({location:e})),Oe=Te(`shell`,async e=>{let n=await t().shell.list({location:e}),r={directory:n.location.directory};return{location:n.location,data:Object.fromEntries(n.data.map(e=>[e.id,{...e,location:r}]))}}),y={on:e.event.on,listen:e.event.listen,session:{list(){return u()},get(e){return o.session.info[e]},creating(e){return le.has(e)},remember(e){nr(()=>{s(`session`,`info`,e.id,Xi(e)),p.complete(`session:${e.id}`),ye(e.id)})},setStatus(e,t){ne(e,t)},root(e){return ve(e)},family(e){return o.session.family[ve(e)]??[]},evict(e){let t=ve(e);nr(()=>{for(let n of new Set([t,e,...o.session.family[t]??[]]))be(n)})},cost(e){let t=o.session.info[e];return t?t.parentID?t.cost:(o.session.family[e]??[e]).reduce((e,t)=>e+(o.session.info[t]?.cost??0),0):0},status(e){return o.session.active[e]??`idle`},active(){return Object.entries(o.session.active).flatMap(([e,t])=>t===`running`?[e]:[])},input:{list(e){return(o.session.pending[e]??[]).flatMap(e=>e.type===`compaction`?[]:[e.id])},has(e,t){return o.session.pending[e]?.some(e=>e.id===t&&e.type!==`compaction`)??!1}},pending:{list(e){return o.session.pending[e]??[]},status(e,t){let n=o.session.pending[e]??[],r=n.find(e=>e.id===t&&e.type===`user`);if(!r)return;if(r.delivery===`queue`)return`queued`;let i=o.session.message[e]??[],a=i.findLastIndex(e=>e.type===`idle`);return(o.session.active[e]??`idle`)===`idle`?a>=0&&r.time.created<=i[a].time.created?`stranded`:`starting`:i.slice(a+1).some(e=>e.type===`user`&&!n.some(t=>t.id===e.id))?`steering`:`starting`},sync(e){return p.run(`session.pending:${e}`,async()=>{let n=new Map;te.set(e,n);try{let r=await t().session.inbox.list({sessionID:e}),i=new Map(r.map(e=>[e.id,e]));n.forEach((e,t)=>{if(e===void 0)i.delete(t);else if(typeof e==`string`){let n=i.get(t);n&&i.set(t,{...n,delivery:e})}else i.set(t,e)});let a=[...i.values()];a.forEach(e=>se.delete(e.id)),a.some(e=>e.type===`compaction`)&&o.session.pending[e]?.filter(e=>e.type===`compaction`).forEach(e=>se.delete(e.id));let c=(o.session.pending[e]??[]).filter(e=>se.has(e.id)),l=c.length===0?a:[...a,...c];nr(()=>{s(`session`,`pending`,e,Xi(l)),l.forEach(he)})}finally{te.get(e)===n&&te.delete(e)}})},invalidate(e){p.invalidate(`session.pending:${e}`)}},create(e){let{projectID:n,...r}=e,i=r.id??mu.create(),a=r.location??c(),s=!o.session.info[i];if(s){let e=Date.now();ce.add(i),y.session.remember({id:i,projectID:n??o.location[JC(a)]?.info?.project.id??``,agent:r.agent,model:r.model,cost:0,tokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}},time:{created:e,updated:e},title:r.title,location:a}),p.complete(`session.family:${i}`),p.complete(`session.pending:${i}`),p.complete(`session.message:${i}`)}let l=Promise.resolve().then(()=>t().session.create({...r,id:i,location:a})).then(e=>(ce.delete(i),y.session.remember(e),e)).catch(e=>{throw s&&ce.delete(i)&&xe(i),e});return s&&h(le,i,l),{id:i,request:l}},compact(e){let n=fe.get(e.sessionID);if(n)return n.request;let r=K.create();o.session.pending[e.sessionID]?.some(e=>e.type===`compaction`)||(se.add(r),me({id:r,sessionID:e.sessionID,time:{created:Date.now()},type:`compaction`,delivery:`steer`,payload:{}}));let i=new Set,a=pe(e.sessionID,async()=>(e.model&&await t().session.switchModel({sessionID:e.sessionID,model:e.model}),t().session.compact({sessionID:e.sessionID,id:r}))).then(t=>(nr(()=>{se.delete(r),t.id!==r&&m(e.sessionID,r),!i.has(t.id)&&!d.get(e.sessionID)?.has(t.id)&&me(t)}),t)).catch(t=>{throw se.delete(r)&&m(e.sessionID,r),t}).finally(()=>{fe.get(e.sessionID)?.request===a&&fe.delete(e.sessionID)});return fe.set(e.sessionID,{id:r,observed:i,request:a}),a},prompt(e){let{gate:n,prepare:r,...i}=e,a=i.id??K.create(),s=!d.get(i.sessionID)?.has(a)&&!o.session.pending[i.sessionID]?.some(e=>e.id===a);if(s){let e=XC(i.files),t={text:i.text,agents:i.agents?.map(e=>({...e})),metadata:i.metadata};e&&(t.files=e),se.add(a),me({id:a,sessionID:i.sessionID,time:{created:Date.now()},type:`user`,delivery:i.delivery??`steer`,payload:t})}return pe(i.sessionID,async()=>(await r?.(),t().session.prompt({...i,id:a})),n).catch(e=>{throw s&&se.delete(a)&&g(i.sessionID,a),e})},sync(e,n){return p.run(n?.children?`session.family:${e}`:`session:${e}`,async()=>{let[r,i]=await Promise.all([t().session.get({sessionID:e}),n?.children?_e({parentID:e,order:`desc`,limit:tw}):[]]),a=[r,...i];nr(()=>{s(`session`,`info`,$i(e=>{for(let t of a)e[t.id]=t}));for(let e of a)p.complete(`session:${e.id}`),ye(e.id)})})},invalidate(e){p.invalidate(`session:${e}`)},message:{list(e){return o.session.message[e]??[]},get(e,t){let n=o.session.message[e],r=d.get(e)?.get(t);return r===void 0?void 0:n?.[r]},sync(n){return p.run(`session.message:${n}`,async()=>{let r=await t().message.list({sessionID:n,limit:e.initialMessageLimit?.()??qC,order:`desc`}),i=r.data.toReversed().map(f),a=new Set(i.map(e=>e.id)),c=new Set((o.session.pending[n]??[]).flatMap(e=>e.type===`user`||e.type===`synthetic`?[e.id]:[])),l=(o.session.message[n]??[]).filter(e=>!a.has(e.id)&&(se.has(e.id)||c.has(e.id))),u=l.length===0?i:[...i,...l];nr(()=>{d.set(n,new Map(u.map((e,t)=>[e.id,t]))),s(`session`,`message`,n,Xi(u)),s(`session`,`messageCursor`,n,r.cursor.next??void 0)})})},more(e){return o.session.messageCursor[e]!==void 0},loading(e){return o.session.messageLoading[e]??!1},async loadMore(e,n){let r=n?.signal;if(r?.aborted)return;for(;de.has(e);){let t=await(()=>{let t=de.get(e);if(!r)return t;let n=Promise.withResolvers(),i=()=>n.resolve();return r.addEventListener(`abort`,i,{once:!0}),Promise.race([t,n.promise]).catch(e=>{if(!r.aborted)throw e}).finally(()=>r.removeEventListener(`abort`,i))})();if(!n?.all&&t||r?.aborted)return}let i=o.session.messageCursor[e];if(!i||r?.aborted)return;s(`session`,`messageLoading`,e,!0);let a=(async()=>{let a=[],c=i;do{let i=await t().message.list({sessionID:e,limit:n?.all?200:qC,cursor:c},{signal:r});if(r?.aborted)return;if(a.push(...i.data.map(f)),c=i.cursor.next??void 0,!n?.all)break}while(c);let l=o.session.message[e]??[],u=new Set(l.map(e=>e.id)),p=[...a.reverse().filter(e=>!u.has(e.id)),...l];return nr(()=>{n?.beforePublish?.(),d.set(e,new Map(p.map((e,t)=>[e.id,t]))),s(`session`,`message`,e,Xi(p)),s(`session`,`messageCursor`,e,c)}),!0})().catch(e=>{if(!r?.aborted)throw e}).finally(()=>s(`session`,`messageLoading`,e,!1));h(de,e,a),await a},invalidate(e){p.invalidate(`session.message:${e}`)}},permission:{list(e){return o.session.permission[e]},sessions(){return Object.entries(o.session.permission).flatMap(([e,t])=>t.length>0?[e]:[])},sync(e){return p.run(`session.permission:${e}`,async()=>{s(`session`,`permission`,e,await t().permission.list({sessionID:e}))})},invalidate(e){p.invalidate(`session.permission:${e}`)},async reply(e){await t().permission.reply(e).catch(e=>{if(!Wa(e))throw e}),re(e.sessionID,e.requestID)}},form:{list(e,t){let n=o.session.form[e];if(e!==`global`)return n;if(!t)return;let r=JC(t);return n?.filter(e=>e.location&&JC(e.location)===r)},sessions(){return Object.entries(o.session.form).flatMap(([e,t])=>e!==`global`&&t.length>0?[e]:[])},sync(e,n){let r=`session.form:${e}:${e===`global`?JC(n??c()):``}`;return p.run(r,async()=>{if(e===`global`){let r=await t().form.list({location:YC(n??c())}),i={directory:r.location.directory},a=JC(i);s(`session`,`form`,e,[...(o.session.form[e]??[]).filter(e=>e.location&&JC(e.location)!==a),...r.data.filter(e=>e.sessionID===`global`).map(e=>({...e,location:i}))]);return}s(`session`,`form`,e,await t().session.form.list({sessionID:e}))})},invalidate(e,t){p.invalidate(`session.form:${e}:${e===`global`?JC(t??c()):``}`)},reply(e,n){return ae(e,n,t().session.form.reply(e,$C(e.sessionID,n)))},cancel(e,n){return ae(e,n,t().session.form.cancel(e,$C(e.sessionID,n)))}}},project:{list(){return Object.values(o.project.info).filter(e=>e.time.archived===void 0).toSorted((e,t)=>t.time.active-e.time.active)},get(e){return o.project.info[e]},sync(){return p.run(`project`,async()=>{let e=await t().project.list();s(`project`,`info`,Xi(Object.fromEntries(e.map(e=>[e.id,e]))))})},invalidate(){p.invalidate(`project`)},permission:{list(e){return o.project.permission[e]},sync(e){return p.run(`project.permission:${e}`,async()=>{s(`project`,`permission`,e,await t().permission.saved.list({projectID:e}))})},invalidate(e){p.invalidate(`project.permission:${e}`)}}},shell:{list(e){return Object.values(Oe.list(e)??{})},listBySession(e){return Object.values(o.location).flatMap(e=>Object.values(e.shell??{})).filter(t=>t.metadata.sessionID===e)},get(e){return Object.values(o.location).map(t=>t.shell?.[e]).find(e=>e!==void 0)},sync:Oe.sync,invalidate:Oe.invalidate},location:{info(e){return o.location[JC(e??c())]?.info},default(){return c()},syncInfo(e){let n=e??c();return p.run(`location:${JC(n)}`,async()=>{let r=await t().location.get({location:YC(n)}),i=JC(r);o.location[i]||s(`location`,i,{}),s(`location`,i,`info`,r),e||l({directory:r.directory})})},async sync(e){await y.location.syncInfo(e);let t=e??c();await Promise.all([y.location.vcs.sync(t),y.location.agent.sync(t),y.location.command.sync(t),y.location.integration.sync(t),y.location.mcp.server.sync(t),y.location.mcp.resource.sync(t),y.location.model.sync(t),y.location.provider.sync(t),y.location.reference.sync(t),y.location.skill.sync(t),y.shell.sync(t),y.session.form.sync(`global`,t)])},invalidate(e){let t=e??c();p.invalidate(`location:${JC(t)}`),y.location.vcs.invalidate(t),y.location.agent.invalidate(t),y.location.command.invalidate(t),y.location.config.invalidate(t),y.location.integration.invalidate(t),y.location.mcp.server.invalidate(t),y.location.mcp.resource.invalidate(t),y.location.model.invalidate(t),y.location.provider.invalidate(t),y.location.reference.invalidate(t),y.location.skill.invalidate(t),y.shell.invalidate(t),y.session.form.invalidate(`global`,t)},vcs:{info:Ee.list,sync:Ee.sync,invalidate:Ee.invalidate},usage:{limits:De.list,sync:De.sync,invalidate:De.invalidate},agent:Te(`agent`,e=>t().agent.list({location:e})),command:Te(`command`,e=>t().command.list({location:e})),config:Te(`config`,async e=>({location:{directory:e.directory},data:await t().config.get({location:e})})),integration:Te(`integration`,e=>t().integration.list({location:e})),mcp:{server:Te(`mcpServer`,e=>t().mcp.list({location:e})),resource:Te(`mcpResource`,async e=>{let n=await t().mcp.resource.catalog({location:e});return{location:n.location,data:n.data.resources}})},model:Te(`model`,e=>t().model.list({location:e}),{alias:!0}),provider:Te(`provider`,e=>t().provider.list({location:e}),{alias:!0}),reference:Te(`reference`,e=>t().reference.list({location:e})),websearch:{list(e){return o.location[JC(e??c())]?.websearch},async refresh(e){let n={location:YC(e??c())},r=await t().websearch.providers(n),i=JC(r.location);s(`location`,i,{websearch:r.data})}},skill:Te(`skill`,e=>t().skill.list({location:e}))}};return Yn(()=>{e.connection?.status()!==`connected`&&p.invalidate()}),or(e.event.listen(({details:e})=>{Se(e)})),y}var rw=2e3,iw=1e3,aw=50,ow=45e3,sw=2e4;function cw(e,t){let n=new AbortController,r=[],i=t.idleTimeout??45e3,[a,o]=Vi({status:`connecting`,attempt:0}),s=e,c=[],l,u,d,f,p=!1,ee=0,te=0,ne=!1;function m(e,t,n){r.push({type:`client.connection`,created:Date.now(),data:{status:e,attempt:t,error:n}}),r.length>aw&&r.shift()}function re(e){c.push(e),!l&&(l=setTimeout(()=>{l=void 0;let e=c;c=[],nr(()=>e.forEach(t.onEvent))},t.flushInterval??10))}async function ie(e,n){let r,a=new AbortController;d=a;let c=()=>a.abort(e.reason),l=setTimeout(()=>a.abort(Error(`Timed out connecting to server`)),rw);e.addEventListener(`abort`,c,{once:!0});let u,f=()=>{te=Date.now(),r!==void 0&&(clearTimeout(u),u=setTimeout(()=>a.abort(Error(`Event stream stalled`)),i))};try{m(n===0?`connecting`:`reconnecting`,n),t.log?.info?.(`event stream connecting`,{attempt:n});let i=s.event.subscribe({signal:a.signal,onActivity:f})[Symbol.asyncIterator](),c=await i.next();if(e.aborted)return{error:void 0,connectedAt:r};if(c.done)return{error:a.signal.reason instanceof Error?a.signal.reason:Error(`Event stream disconnected`),connectedAt:r};if(c.value.type!==`server.connected`)return{error:Error(`Event stream did not start with server.connected`),connectedAt:r};for(clearTimeout(l),m(`connected`,n),r=Date.now(),f(),t.log?.info?.(`event stream connected`),re(c.value),o({status:`connected`,attempt:0,error:void 0});!e.aborted;){let n=await i.next();if(e.aborted)return{error:void 0,connectedAt:r};if(n.done)return{error:a.signal.reason instanceof Error?a.signal.reason:Error(`Event stream disconnected`),connectedAt:r};f(),`durable`in n.value&&n.value.durable&&t.log?.debug?.(`event`,{type:n.value.type,aggregateID:n.value.durable.aggregateID,seq:n.value.durable.seq}),re(n.value)}return{error:void 0,connectedAt:r}}catch(e){return{error:e,connectedAt:r}}finally{a.abort(),d===a&&(d=void 0),clearTimeout(l),clearTimeout(u),e.removeEventListener(`abort`,c)}}async function ae(e){let r=0;for(;!n.signal.aborted&&p&&ee===e;){o({status:r===0?`connecting`:`reconnecting`,attempt:r});let i=new AbortController;u=i;let a=()=>i.abort(n.signal.reason);n.signal.addEventListener(`abort`,a);let c=await ie(i.signal,r);if(n.signal.removeEventListener(`abort`,a),n.signal.aborted||!p||ee!==e)return;c.connectedAt!==void 0&&Date.now()-c.connectedAt>=iw&&(r=0),r+=1;let l=lw(c.error);if(m(`disconnected`,r,l),t.log?.info?.(`event stream disconnected`,{attempt:r,error:l}),o({status:`reconnecting`,attempt:r,error:l}),t.reconnect){let a=await t.reconnect(i.signal).catch(e=>{i.signal.aborted||t.log?.info?.(`server resolution failed`,{attempt:r,error:lw(e)})});if(n.signal.aborted||i.signal.aborted||!p||ee!==e)return;if(a&&(s=a,r===1))continue}if(ne){ne=!1;continue}await uw(iw,i.signal)}}function oe(){if(p)return f;p=!0,ne=!1;let e=++ee,t=f,n=(async()=>{t&&await t,await ae(e)})().finally(()=>{f===n&&(f=void 0)});return f=n,f}function se(){p&&(p=!1,ee+=1,u?.abort(),o({status:`connecting`,attempt:0,error:void 0}))}function ce(e){!p||a.status!==`connected`||(t.log?.info?.(`event stream resync`,{reason:e,idle:Date.now()-te}),ne=!0,d?.abort(Error(e)))}if(t.pageLifecycle){let e=()=>se(),t=()=>void oe(),n=()=>{document.visibilityState===`visible`&&(Date.now()-te<2e4||ce(`Page returned to the foreground after the event stream went quiet`))},r=()=>ce(`Network connection restored`);window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,t),window.addEventListener(`online`,r),document.addEventListener(`visibilitychange`,n),or(()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,r),document.removeEventListener(`visibilitychange`,n)})}return oe(),or(()=>{se(),n.abort(),l&&clearTimeout(l),c=[]}),{status:()=>a.status,attempt:()=>a.attempt,error:()=>a.error,internal:{history:()=>r.slice(),resync:ce}}}function lw(e){if(e!==void 0)return e instanceof Error?e.message:String(e)}function uw(e,t){return new Promise(n=>{let r=setTimeout(i,e);t.addEventListener(`abort`,i,{once:!0});function i(){clearTimeout(r),t.removeEventListener(`abort`,i),n()}})}function dw(e,t){return{async connect(n){let r=await e.pty.connect.token({ptyID:n.ptyID,location:n.location,"x-opencode-ticket":`1`}),i=new URL(t.url);i.pathname.endsWith(`/`)||(i.pathname+=`/`);let a=new URL(`api/pty/${encodeURIComponent(n.ptyID)}/connect`,i);n.location?.directory&&a.searchParams.set(`location[directory]`,n.location.directory),n.cursor!==void 0&&a.searchParams.set(`cursor`,String(n.cursor)),a.searchParams.set(`ticket`,r.data.ticket),a.protocol=a.protocol===`https:`?`wss:`:`ws:`;let o=t.openSocket?.(a)??new WebSocket(a);return o.binaryType=`arraybuffer`,o}}}function fw(e,t){return{async connect(n){let r=await e.experimental.persistentPty.connectToken({ptyID:n.ptyID,"x-opencode-ticket":`1`}),i=new URL(t.url);i.pathname.endsWith(`/`)||(i.pathname+=`/`);let a=new URL(`api/experimental/persistent-pty/${encodeURIComponent(n.ptyID)}/connect`,i);a.searchParams.set(`ticket`,r.ticket),a.searchParams.set(`cursor`,String(n.cursor)),a.searchParams.set(`attachment_id`,n.attachmentID),a.searchParams.set(`takeover`,String(n.takeover??!1)),a.searchParams.set(`input_protocol`,`1`),a.protocol=a.protocol===`https:`?`wss:`:`ws:`;let o=t.openSocket?.(a)??new WebSocket(a);return o.binaryType=`arraybuffer`,o}}}function pw(e){let t,n=[],r=new Map;Yn(()=>{let i=e.current(),a=i===void 0?void 0:e.session.root(i),o=new Set(e.keep().map(t=>e.session.root(t)));n=[...new Set([...i!==t&&a!==void 0?[a]:[],...n.map(t=>e.session.root(t))])],t=i;let s=new Set([...o,...n.filter(e=>!o.has(e)).slice(0,e.limit)]);a!==void 0&&s.add(a),n=n.filter(e=>s.has(e));let c=t=>rr(()=>e.session.message?.list(t).length??0),l=new Map(e.session.list().flatMap(t=>{let n=e.session.root(t.id);return s.has(n)?[]:[[t.id,n]]})),u=new Set([...l].filter(([e,t])=>r.get(e)!==`${t}:${c(e)}`).map(([,e])=>e));rr(()=>u.forEach(t=>e.session.evict(t))),r=new Map([...l].map(([e,t])=>[e,`${t}:${c(e)}`]))})}function mw(e,t){let n=t?e.findIndex(e=>e.id===t):-1;if(t&&n===-1)return;let r=n===-1?e.length:n,i=e.findLastIndex((e,t)=>e.type===`compaction`&&e.status===`completed`&&t<r);return e.findLast((e,t)=>e.type===`assistant`&&e.tokens!==void 0&&t>i&&t<r)}var hw=e({createClientConnection:()=>cw,createData:()=>nw,createPersistentPtyClient:()=>fw,createPtyClient:()=>dw,createSessionRetention:()=>pw,defaultIdleTimeout:()=>ow,foregroundIdleThreshold:()=>sw,lastAssistantWithUsage:()=>mw,locationKey:()=>JC,settleMs:()=>150});export{ir as A,Zt as B,Jn as C,cr as D,Qr as E,ai as F,rr as I,vr as L,ur as M,P as N,lr as O,an as P,nn as R,Zn as S,Kn as T,Ht as V,nr as _,Vi as a,_r as b,ki as c,di as d,mi as f,pi as g,bi as h,eo as i,or as j,ii as k,_i as l,xi as m,KC as n,Xi as o,fi as p,no as r,Si as s,hw as t,ui as u,sr as v,Gn as w,Yn as x,$r as y,Xt as z};