@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
@@ -1,23 +0,0 @@
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 m,H as h,Ht as ne,I as re,It as ie,J as ae,Jt as oe,K as se,Kt as ce,L as le,Lt as ue,M as de,Mt as fe,N as g,Nt as _,O as pe,Ot as me,P as v,Pt as he,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 y,Ut as we,V as Te,Vt as Ee,W as De,Wt as b,X as x,Xt as Oe,Y as S,Yt as ke,Z as C,Zt as Ae,_ as je,_n as Me,_t as Ne,a as Pe,an as Fe,at as Ie,b as Le,bt as Re,c as ze,cn as w,ct as Be,d as T,dn as Ve,dt as He,en as Ue,et as We,f as Ge,fn as Ke,g as qe,gn as Je,h as Ye,hn as Xe,ht as Ze,i as Qe,in as $e,it as E,j as et,jt as tt,k as nt,kt as rt,l as D,ln as it,lt as at,m as ot,mn as st,mt as ct,n as lt,nn as ut,nt as dt,o as ft,on as pt,ot as O,p as mt,pn as ht,q as gt,qt as _t,r as k,rn as vt,rt as yt,s as A,sn as j,st as M,t as N,tn as bt,tt as xt,u as St,un as Ct,ut as wt,v as Tt,vn as Et,vt as Dt,w as Ot,wt as kt,x as At,xt as jt,yn as Mt,yt as Nt,z as P,zt as Pt}from"./vendor-effect-DV9F8PTZ.js";var Ft=Object.defineProperty,It=e=>e;function Lt(e,t){this[e]=It.bind(null,t)}var Rt=(e,t)=>{for(var n in t)Ft(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Lt.bind(t,n)})},zt={};Rt(zt,{SharedEvents:()=>zt,make:()=>Bt});function Bt(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 Vt=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}};Rt({},{make:()=>Ut});var Ht=16777216;function Ut(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??{}))Gt(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 Vt(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw qt(await Kt(e));try{await e.body?.cancel()}catch{}throw new Vt(`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 Kt(n)},o=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!Jt(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new Vt(`UnsupportedContentType`,{detail:n.headers.get(`content-type`)})}if(n.body===null)throw new Vt(`MalformedResponse`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new Vt(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),s+=o.decode(e.value,{stream:!e.done}),s.length>Ht)throw new Vt(`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 Vt(`MalformedResponse`,{cause:e})}r=s.indexOf(`
11
-
12
- `)}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/${Wt(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 Wt(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Gt(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)Gt(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))Gt(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function Kt(e){if(!Jt(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new Vt(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new Vt(`Transport`,{cause:e})}if(t===``)throw new Vt(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new Vt(`MalformedResponse`,{cause:e})}}function qt(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function Jt(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var Yt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidRequestError`,Xt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnauthorizedError`,Zt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,Qt=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ServiceUnavailableError`,$t=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AgentNotFoundError`,en=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PluginNotFoundError`,tn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InvalidCursorError`,nn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionNotFoundError`,rn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ConflictError`,an=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnknownError`,on=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`MessageNotFoundError`,sn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandNotFoundError`,cn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`CommandExecutionError`,ln=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SkillNotFoundError`,un=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`SessionBusyError`,dn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`InstructionEntryValueTooLargeError`,fn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormNotFoundError`,pn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormInvalidAnswerError`,mn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FormAlreadySettledError`,hn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderNotFoundError`,gn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ModelNotFoundError`,_n=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`UnsupportedModelError`,vn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProviderRequestError`,yn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationNotFoundError`,bn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationAttemptNotFoundError`,xn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`IntegrationMethodNotFoundError`,Sn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`McpServerNotFoundError`,Cn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ForbiddenError`,wn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ProjectNotFoundError`,Tn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionSavedNotFoundError`,En=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,Dn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`FileNotFoundError`,On=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,kn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`,An=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PtyNotFoundError`,jn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`ShellNotFoundError`,Mn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`WorktreeError`,Nn=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`VcsInitNotSupportedError`;function Pn(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=Fn(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!On(e)&&!kn(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 Fn(e,t){return`rpc.${e.id}.${t}`}var In={};Rt(In,{OpenCode:()=>In,make:()=>Ln});function Ln(e){let t=Ut(e),n=Bt((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(Pn(t,n),t.rpc),event:n}}var Rn=e({ClientError:()=>Vt,OpenCode:()=>In,isAgentNotFoundError:()=>$t,isCommandExecutionError:()=>cn,isCommandNotFoundError:()=>sn,isConflictError:()=>rn,isFileNotFoundError:()=>Dn,isForbiddenError:()=>Cn,isFormAlreadySettledError:()=>mn,isFormInvalidAnswerError:()=>pn,isFormNotFoundError:()=>fn,isInstructionEntryValueTooLargeError:()=>dn,isIntegrationAttemptNotFoundError:()=>bn,isIntegrationMethodNotFoundError:()=>xn,isIntegrationNotFoundError:()=>yn,isInvalidCursorError:()=>tn,isInvalidRequestError:()=>Yt,isLocationNotFoundError:()=>Zt,isMcpServerNotFoundError:()=>Sn,isMessageNotFoundError:()=>on,isModelNotFoundError:()=>gn,isPermissionNotFoundError:()=>En,isPermissionSavedNotFoundError:()=>Tn,isPluginNotFoundError:()=>en,isProjectNotFoundError:()=>wn,isProviderNotFoundError:()=>hn,isProviderRequestError:()=>vn,isPtyNotFoundError:()=>An,isRpcError:()=>On,isRpcInternalError:()=>kn,isServiceUnavailableError:()=>Qt,isSessionBusyError:()=>un,isSessionNotFoundError:()=>nn,isShellNotFoundError:()=>jn,isSkillNotFoundError:()=>ln,isUnauthorizedError:()=>Xt,isUnknownError:()=>an,isUnsupportedModelError:()=>_n,isVcsInitNotSupportedError:()=>Nn,isWorktreeError:()=>Mn}),zn=Object.defineProperty,Bn=e=>e;function Vn(e,t){this[e]=Bn.bind(null,t)}var Hn=(e,t)=>{for(var n in t)zn(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Vn.bind(t,n)})},Un={};Hn(Un,{SharedEvents:()=>Un,make:()=>Wn});function Wn(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 Gn=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}};Hn({},{make:()=>qn});var Kn=16777216;function qn(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??{}))Yn(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 Gn(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw Zn(await Xn(e));try{await e.body?.cancel()}catch{}throw new Gn(`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 Xn(n)},o=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!Qn(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new Gn(`UnsupportedContentType`,{detail:n.headers.get(`content-type`)})}if(n.body===null)throw new Gn(`MalformedResponse`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new Gn(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),s+=o.decode(e.value,{stream:!e.done}),s.length>Kn)throw new Gn(`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 Gn(`MalformedResponse`,{cause:e})}r=s.indexOf(`
22
-
23
- `)}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/${Jn(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 Jn(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function Yn(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)Yn(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))Yn(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function Xn(e){if(!Qn(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new Gn(`UnsupportedContentType`,{detail:e.headers.get(`content-type`)})}let t;try{t=await e.text()}catch(e){throw new Gn(`Transport`,{cause:e})}if(t===``)throw new Gn(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new Gn(`MalformedResponse`,{cause:e})}}function Zn(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function Qn(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var $n=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`LocationNotFoundError`,er=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,tr=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`;function nr(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=rr(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!er(e)&&!tr(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 rr(e,t){return`rpc.${e.id}.${t}`}var ir={};Hn(ir,{OpenCode:()=>ir,make:()=>ar});function ar(e){let t=qn(e),n=Wn((e,n)=>t.event.subscribe(void 0,{signal:e,onActivity:n}));return{...t,rpc:Object.assign(nr(t,n),t.rpc),event:n}}var or=e({$DEVCOMP:()=>Nr,$PROXY:()=>Ar,$TRACK:()=>Mr,DEV:()=>void 0,ErrorBoundary:()=>va,For:()=>da,Index:()=>fa,Match:()=>ha,Show:()=>pa,Suspense:()=>Sa,SuspenseList:()=>xa,Switch:()=>ma,batch:()=>ri,cancelCallback:()=>Cr,catchError:()=>ci,children:()=>bi,createComponent:()=>ea,createComputed:()=>Jr,createContext:()=>vi,createDeferred:()=>ti,createEffect:()=>Xr,createMemo:()=>Qr,createReaction:()=>Zr,createRenderEffect:()=>Yr,createResource:()=>ei,createRoot:()=>Kr,createSelector:()=>ni,createSignal:()=>qr,createUniqueId:()=>la,enableExternalSource:()=>Ci,enableHydration:()=>$i,enableScheduling:()=>fi,equalFn:()=>kr,from:()=>qi,getListener:()=>li,getOwner:()=>ui,indexArray:()=>Zi,lazy:()=>sa,mapArray:()=>Xi,mergeProps:()=>aa,observable:()=>Ki,on:()=>ai,onCleanup:()=>si,onError:()=>Wi,onMount:()=>oi,requestCallback:()=>Sr,resetErrorBoundaries:()=>_a,runWithOwner:()=>di,sharedConfig:()=>F,splitProps:()=>oa,startTransition:()=>pi,untrack:()=>ii,useContext:()=>yi,useTransition:()=>gi}),sr=1,cr=!1,lr=!1,ur=[],dr=null,fr=null,pr=5,mr=0,hr=300,gr=0,_r=null,vr=null,yr=1073741823;function br(){let e=new MessageChannel,t=e.port1,n=e.port2;if(typeof t.unref==`function`&&t.unref(),typeof n.unref==`function`&&n.unref(),_r=()=>n.postMessage(null),t.onmessage=()=>{if(vr!==null){let e=performance.now();mr=e+pr,gr=e+hr;try{vr(e)?n.postMessage(null):vr=null}catch(e){throw n.postMessage(null),e}}},navigator&&navigator.scheduling&&navigator.scheduling.isInputPending){let e=navigator.scheduling;fr=()=>{let t=performance.now();return t>=mr?e.isInputPending()?!0:t>=gr:!1}}else fr=()=>performance.now()>=mr}function xr(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 Sr(e,t){_r||br();let n=performance.now(),r=yr;t&&t.timeout&&(r=t.timeout);let i={id:sr++,fn:e,startTime:n,expirationTime:n+r};return xr(ur,i),!cr&&!lr&&(cr=!0,vr=wr,_r()),i}function Cr(e){e.fn=null}function wr(e){cr=!1,lr=!0;try{return Tr(e)}finally{dr=null,lr=!1}}function Tr(e){let t=e;for(dr=ur[0]||null;dr!==null&&!(dr.expirationTime>t&&fr());){let e=dr.fn;e===null?ur.shift():(dr.fn=null,e(dr.expirationTime<=t),t=performance.now(),dr===ur[0]&&ur.shift()),dr=ur[0]||null}return dr!==null}var F={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Er(this.context.count)},getNextContextId(){return Er(this.context.count++)}};function Er(e){let t=String(e),n=t.length-1;return F.context.id+(n?String.fromCharCode(96+n):``)+t}function Dr(e){F.context=e}function Or(){return{...F.context,id:F.getNextContextId(),count:0}}var kr=(e,t)=>e===t,Ar=Symbol(`solid-proxy`),jr=typeof Proxy==`function`,Mr=Symbol(`solid-track`),Nr=Symbol(`solid-dev-component`),Pr={equals:kr},Fr=null,Ir=Mi,Lr=1,Rr=2,zr={owned:null,cleanups:null,context:null,owner:null},Br={},I=null,L=null,Vr=null,Hr=null,R=null,Ur=null,Wr=null,Gr=0;function Kr(e,t){let n=R,r=I,i=e.length===0,a=t===void 0?r:t,o=i?zr:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>ii(()=>Li(o)));I=o,R=null;try{return Ai(s,!0)}finally{R=n,I=r}}function qr(e,t){t=t?Object.assign({},Pr,t):Pr;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[wi.bind(n),e=>(typeof e==`function`&&(e=L&&L.running&&L.sources.has(n)?e(n.tValue):e(n.value)),Ti(n,e))]}function Jr(e,t,n){let r=Oi(e,t,!0,Lr);Vr&&L&&L.running?Ur.push(r):Ei(r)}function Yr(e,t,n){let r=Oi(e,t,!1,Lr);Vr&&L&&L.running?Ur.push(r):Ei(r)}function Xr(e,t,n){Ir=Pi;let r=Oi(e,t,!1,Lr),i=xi&&yi(xi);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Wr?Wr.push(r):Ei(r)}function Zr(e,t){let n,r=Oi(()=>{n?n():ii(e),n=void 0},void 0,!1,0),i=xi&&yi(xi);return i&&(r.suspense=i),r.user=!0,e=>{n=e,Ei(r)}}function Qr(e,t,n){n=n?Object.assign({},Pr,n):Pr;let r=Oi(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,Vr&&L&&L.running?(r.tState=Lr,Ur.push(r)):Ei(r),wi.bind(r)}function $r(e){return e&&typeof e==`object`&&`then`in e}function ei(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=Br,c=null,l=!1,u=!1,d=`initialValue`in a,f=typeof r==`function`&&Qr(r),p=new Set,[ee,te]=(a.storage||qr)(a.initialValue),[m,h]=qr(void 0),[ne,re]=qr(void 0,{equals:!1}),[ie,ae]=qr(d?`ready`:`unresolved`);F.context&&(c=F.getNextContextId(),a.ssrLoadFrom===`initial`?s=a.initialValue:F.load&&F.has(c)&&(s=F.load(c)));function oe(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=Br,L&&e&&l?(L.promises.delete(e),l=!1,Ai(()=>{L.running=!0,se(t,n)},!1)):se(t,n)),t}function se(e,t){Ai(()=>{t===void 0&&te(()=>e),ae(t===void 0?d?`ready`:`unresolved`:`errored`),h(t);for(let e of p.keys())e.decrement();p.clear()},!1)}function ce(){let e=xi&&yi(xi),t=ee(),n=m();if(n!==void 0&&!o)throw n;return R&&!R.user&&e&&Jr(()=>{ne(),o&&(e.resolved&&L&&l?L.promises.add(o):p.has(e)||(e.increment(),p.add(e)))}),t}function le(e=!0){if(e!==!1&&u)return;u=!1;let t=f?f():r;if(l=L&&L.running,t==null||t===!1){oe(o,ii(ee));return}L&&o&&L.promises.delete(o);let n,a=s===Br?ii(()=>{try{return i(t,{value:ee(),refetching:e})}catch(e){n=e}}):s;if(n!==void 0){oe(o,void 0,zi(n),t);return}return $r(a)?(o=a,`v`in a?(a.s===1?oe(o,a.v,void 0,t):oe(o,void 0,zi(a.v),t),a):(u=!0,queueMicrotask(()=>u=!1),Ai(()=>{ae(d?`refreshing`:`pending`),re()},!1),a.then(e=>oe(a,e,void 0,t),e=>oe(a,void 0,zi(e),t)))):(oe(o,a,void 0,t),a)}Object.defineProperties(ce,{state:{get:()=>ie()},error:{get:()=>m()},loading:{get(){let e=ie();return e===`pending`||e===`refreshing`}},latest:{get(){if(!d)return ce();let e=m();if(e&&!o)throw e;return ee()}}});let ue=I;return f?Jr(()=>(ue=I,le(!1))):le(!1),[ce,{refetch:e=>di(ue,()=>le(e)),mutate:te}]}function ti(e,t){let n,r=t?t.timeoutMs:void 0,i=Oi(()=>((!n||!n.fn)&&(n=Sr(()=>o(()=>i.value),r===void 0?void 0:{timeout:r})),e()),void 0,!0),[a,o]=qr(L&&L.running&&L.sources.has(i)?i.tValue:i.value,t);return Ei(i),o(()=>L&&L.running&&L.sources.has(i)?i.tValue:i.value),a}function ni(e,t=kr,n){let r=new Map,i=Oi(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=Lr,e.pure?Ur.push(e):Wr.push(e);return i},void 0,!0,Lr);return Ei(i),e=>{let n=R;if(n){let t;(t=r.get(e))?t.add(n):r.set(e,t=new Set([n])),si(()=>{t.delete(n),!t.size&&r.delete(e)})}return t(e,L&&L.running&&L.sources.has(i)?i.tValue:i.value)}}function ri(e){return Ai(e,!1)}function ii(e){if(!Hr&&R===null)return e();let t=R;R=null;try{return Hr?Hr.untrack(e):e()}finally{R=t}}function ai(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=ii(()=>t(o,i,n));return i=o,s}}function oi(e){Xr(()=>ii(e))}function si(e){return I===null||(I.cleanups===null?I.cleanups=[e]:I.cleanups.push(e)),e}function ci(e,t){Fr||=Symbol(`error`),I=Oi(void 0,void 0,!0),I.context={...I.context,[Fr]:[t]},L&&L.running&&L.sources.add(I);try{return e()}catch(e){Vi(e)}finally{I=I.owner}}function li(){return R}function ui(){return I}function di(e,t){let n=I,r=R;I=e,R=null;try{return Ai(t,!0)}catch(e){Vi(e)}finally{I=n,R=r}}function fi(e=Sr){Vr=e}function pi(e){if(L&&L.running)return e(),L.done;let t=R,n=I;return Promise.resolve().then(()=>{R=t,I=n;let r;return(Vr||xi)&&(r=L||={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),Ai(e,!1),R=I=null,r?r.done:void 0})}var[mi,hi]=qr(!1);function gi(){return[mi,pi]}function _i(e){Wr.push.apply(Wr,e),e.length=0}function vi(e,t){let n=Symbol(`context`);return{id:n,Provider:Ui(n),defaultValue:e}}function yi(e){let t;return I&&I.context&&(t=I.context[e.id])!==void 0?t:e.defaultValue}function bi(e){let t=Qr(e),n=Qr(()=>Hi(t()));return n.toArray=()=>{let e=n();return Array.isArray(e)?e:e==null?[]:[e]},n}var xi;function Si(){return xi||=vi()}function Ci(e,t=e=>e()){if(Hr){let{factory:n,untrack:r}=Hr;Hr={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 Hr={factory:e,untrack:t}}function wi(){let e=L&&L.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===Lr)Ei(this);else{let e=Ur;Ur=null,Ai(()=>Fi(this),!1),Ur=e}if(R){let e=this.observers;if(!e||e[e.length-1]!==R){let t=e?e.length:0;R.sources?(R.sources.push(this),R.sourceSlots.push(t)):(R.sources=[this],R.sourceSlots=[t]),e?(e.push(R),this.observerSlots.push(R.sources.length-1)):(this.observers=[R],this.observerSlots=[R.sources.length-1])}}return e&&L.sources.has(this)?this.tValue:this.value}function Ti(e,t,n){let r=L&&L.running&&L.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(L){let r=L.running;(r||!n&&L.sources.has(e))&&(L.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&Ai(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=L&&L.running;r&&L.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?Ur.push(n):Wr.push(n),n.observers&&Ii(n)),r?n.tState=Lr:n.state=Lr)}if(Ur.length>1e6)throw Ur=[],Error()},!1)}return t}function Ei(e){if(!e.fn)return;Li(e);let t=Gr;Di(e,L&&L.running&&L.sources.has(e)?e.tValue:e.value,t),L&&!L.running&&L.sources.has(e)&&queueMicrotask(()=>{Ai(()=>{L&&(L.running=!0),R=I=e,Di(e,e.tValue,t),R=I=null},!1)})}function Di(e,t,n){let r,i=I,a=R;R=I=e;try{r=e.fn(t)}catch(t){return e.pure&&(L&&L.running?(e.tState=Lr,e.tOwned&&e.tOwned.forEach(Li),e.tOwned=void 0):(e.state=Lr,e.owned&&e.owned.forEach(Li),e.owned=null)),e.updatedAt=n+1,Vi(t)}finally{R=a,I=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?Ti(e,r,!0):L&&L.running&&e.pure?(L.sources.has(e)||(e.value=r),L.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function Oi(e,t,n,r=Lr,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:I,context:I?I.context:null,pure:n};if(L&&L.running&&(a.state=0,a.tState=r),I===null||I!==zr&&(L&&L.running&&I.pure?I.tOwned?I.tOwned.push(a):I.tOwned=[a]:I.owned?I.owned.push(a):I.owned=[a]),Hr&&a.fn){let e=a.fn,[t,n]=qr(void 0,{equals:!1}),r=Hr.factory(e,n);si(()=>r.dispose());let i,o=()=>pi(n).then(()=>{i&&=(i.dispose(),void 0)});a.fn=n=>(t(),L&&L.running?(i||=Hr.factory(e,o),i.track(n)):r.track(n))}return a}function ki(e){let t=L&&L.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===Rr)return Fi(e);if(e.suspense&&ii(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<Gr);){if(t&&L.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(L.disposed.has(t))return}if((t?e.tState:e.state)===Lr)Ei(e);else if((t?e.tState:e.state)===Rr){let t=Ur;Ur=null,Ai(()=>Fi(e,n[0]),!1),Ur=t}}}function Ai(e,t){if(Ur)return e();let n=!1;t||(Ur=[]),Wr?n=!0:Wr=[],Gr++;try{let t=e();return ji(n),t}catch(e){n||(Wr=null),Ur=null,Vi(e)}}function ji(e){if(Ur&&=(Vr&&L&&L.running?Ni(Ur):Mi(Ur),null),e)return;let t;if(L){if(!L.promises.size&&!L.queue.size){let e=L.sources,n=L.disposed;Wr.push.apply(Wr,L.effects),t=L.resolve;for(let e of Wr)`tState`in e&&(e.state=e.tState),delete e.tState;L=null,Ai(()=>{for(let e of n)Li(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)Li(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}hi(!1)},!1)}else if(L.running){L.running=!1,L.effects.push.apply(L.effects,Wr),Wr=null,hi(!0);return}}let n=Wr;Wr=null,n.length&&Ai(()=>Ir(n),!1),t&&t()}function Mi(e){for(let t=0;t<e.length;t++)ki(e[t])}function Ni(e){for(let t=0;t<e.length;t++){let n=e[t],r=L.queue;r.has(n)||(r.add(n),Vr(()=>{r.delete(n),Ai(()=>{L.running=!0,ki(n)},!1),L&&(L.running=!1)}))}}function Pi(e){let t,n=0;for(t=0;t<e.length;t++){let r=e[t];r.user?e[n++]=r:ki(r)}if(F.context){if(F.count){F.effects||=[],F.effects.push(...e.slice(0,n));return}Dr()}for(F.effects&&(F.done||!F.count)&&(e=[...F.effects,...e],n+=F.effects.length,delete F.effects),t=0;t<n;t++)ki(e[t])}function Fi(e,t){let n=L&&L.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===Lr?i!==t&&(!i.updatedAt||i.updatedAt<Gr)&&ki(i):e===Rr&&Fi(i,t)}}}function Ii(e){let t=L&&L.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=Rr:r.state=Rr,r.pure?Ur.push(r):Wr.push(r),r.observers&&Ii(r))}}function Li(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--)Li(e.tOwned[t]);delete e.tOwned}if(L&&L.running&&e.pure)Ri(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)Li(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}L&&L.running?e.tState=0:e.state=0}function Ri(e,t){if(t||(e.tState=0,L.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)Ri(e.owned[t])}function zi(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function Bi(e,t,n){try{for(let n of t)n(e)}catch(e){Vi(e,n&&n.owner||null)}}function Vi(e,t=I){let n=Fr&&t&&t.context&&t.context[Fr],r=zi(e);if(!n)throw r;Wr?Wr.push({fn(){Bi(r,n,t)},state:Lr}):Bi(r,n,t)}function Hi(e){if(typeof e==`function`&&!e.length)return Hi(e());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=Hi(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 Ui(e,t){return function(t){let n;return Yr(()=>n=ii(()=>(I.context={...I.context,[e]:t.value},bi(()=>t.children))),void 0),n}}function Wi(e){Fr||=Symbol(`error`),I===null||(I.context===null||!I.context[Fr]?(I.context={...I.context,[Fr]:[e]},Gi(I,Fr,[e])):I.context[Fr].push(e))}function Gi(e,t,n){if(e.owned)for(let r=0;r<e.owned.length;r++)e.owned[r].context===e.context&&Gi(e.owned[r],t,n),e.owned[r].context?e.owned[r].context[t]||(e.owned[r].context[t]=n,Gi(e.owned[r],t,n)):(e.owned[r].context=e.context,Gi(e.owned[r],t,n))}function Ki(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=Kr(t=>(Xr(()=>{let t=e();ii(()=>n(t))}),t));return ui()&&si(r),{unsubscribe(){r()}}},[Symbol.observable||`@@observable`](){return this}}}function qi(e,t=void 0){let[n,r]=qr(t,{equals:!1});if(`subscribe`in e){let t=e.subscribe(e=>r(()=>e));si(()=>`unsubscribe`in t?t.unsubscribe():t())}else si(e(r));return n}var Ji=Symbol(`fallback`);function Yi(e){for(let t=0;t<e.length;t++)e[t]()}function Xi(e,t,n={}){let r=[],i=[],a=[],o=0,s=t.length>1?[]:null;return si(()=>Yi(a)),()=>{let c=e()||[],l=c.length,u,d;return c[Mr],ii(()=>{let e,t,p,ee,te,m,h,ne,re;if(l===0)o!==0&&(Yi(a),a=[],r=[],i=[],o=0,s&&=[]),n.fallback&&(r=[Ji],i[0]=Kr(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]=Kr(f);o=l}else{for(p=Array(l),ee=Array(l),s&&(te=Array(l)),m=0,h=Math.min(o,l);m<h&&r[m]===c[m];m++);for(h=o-1,ne=l-1;h>=m&&ne>=m&&r[h]===c[ne];h--,ne--)p[ne]=i[h],ee[ne]=a[h],s&&(te[ne]=s[h]);for(e=new Map,t=Array(ne+1),d=ne;d>=m;d--)re=c[d],u=e.get(re),t[d]=u===void 0?-1:u,e.set(re,d);for(u=m;u<=h;u++)re=r[u],d=e.get(re),d!==void 0&&d!==-1?(p[d]=i[u],ee[d]=a[u],s&&(te[d]=s[u]),d=t[d],e.set(re,d)):a[u]();for(d=m;d<l;d++)d in p?(i[d]=p[d],a[d]=ee[d],s&&(s[d]=te[d],s[d](d))):i[d]=Kr(f);i=i.slice(0,o=l),r=c.slice(0)}return i});function f(e){if(a[d]=e,s){let[e,n]=qr(d);return s[d]=n,t(c[d],e)}return t(c[d])}}}function Zi(e,t,n={}){let r=[],i=[],a=[],o=[],s=0,c;return si(()=>Yi(a)),()=>{let l=e()||[],u=l.length;return l[Mr],ii(()=>{if(u===0)return s!==0&&(Yi(a),a=[],r=[],i=[],s=0,o=[]),n.fallback&&(r=[Ji],i[0]=Kr(e=>(a[0]=e,n.fallback())),s=1),i;for(r[0]===Ji&&(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]=Kr(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]=qr(l[c]);return o[c]=r,t(n,c)}}}var Qi=!1;function $i(){Qi=!0}function ea(e,t){if(Qi&&F.context){let n=F.context;Dr(Or());let r=ii(()=>e(t||{}));return Dr(n),r}return ii(()=>e(t||{}))}function ta(){return!0}var na={get(e,t,n){return t===Ar?n:e.get(t)},has(e,t){return t===Ar||e.has(t)},set:ta,deleteProperty:ta,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:ta,deleteProperty:ta}},ownKeys(e){return e.keys()}};function ra(e){return(e=typeof e==`function`?e():e)?e:{}}function ia(){for(let e=0,t=this.length;e<t;++e){let t=this[e]();if(t!==void 0)return t}}function aa(...e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];t||=!!r&&Ar in r,e[n]=typeof r==`function`?(t=!0,Qr(r)):r}if(jr&&t)return new Proxy({get(t){for(let n=e.length-1;n>=0;n--){let r=ra(e[n])[t];if(r!==void 0)return r}},has(t){for(let n=e.length-1;n>=0;n--)if(t in ra(e[n]))return!0;return!1},keys(){let t=[];for(let n=0;n<e.length;n++)t.push(...Object.keys(ra(e[n])));return[...new Set(t)]}},na);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:ia.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 oa(e,...t){let n=t.length;if(jr&&Ar 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)}},na));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))}},na)),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 sa(e){let t,n,r=r=>{let i=F.context;if(i){let[r,a]=qr();F.count||=0,F.count++,(n||=e()).then(e=>{!F.done&&Dr(i),F.count--,a(()=>e.default),Dr()}),t=r}else if(!t){let[r]=ei(()=>(n||=e()).then(e=>e.default));t=r}let a;return Qr(()=>(a=t())?ii(()=>{if(!i||F.done)return a(r);let e=F.context;Dr(i);let t=a(r);return Dr(e),t}):``)};return r.preload=()=>n||((n=e()).then(e=>t=()=>e.default),n),r}var ca=0;function la(){return F.context?F.getNextContextId():`cl-${ca++}`}var ua=e=>`Stale read from <${e}>.`;function da(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Qr(Xi(()=>e.each,e.children,t||void 0))}function fa(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return Qr(Zi(()=>e.each,e.children,t||void 0))}function pa(e){let t=e.keyed,n=Qr(()=>e.when,void 0,void 0),r=t?n:Qr(n,void 0,{equals:(e,t)=>!e==!t});return Qr(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?ii(()=>a(t?i:()=>{if(!ii(r))throw ua(`Show`);return n()})):a}return e.fallback},void 0,void 0)}function ma(e){let t=bi(()=>e.children),n=Qr(()=>{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=Qr(()=>a()?void 0:i.when,void 0,void 0),s=i.keyed?o:Qr(o,void 0,{equals:(e,t)=>!e==!t});r=()=>a()||(s()?[t,o,i]:void 0)}return r});return Qr(()=>{let t=n()();if(!t)return e.fallback;let[r,i,a]=t,o=a.children;return typeof o==`function`&&o.length>0?ii(()=>o(a.keyed?i():()=>{if(ii(n)()?.[0]!==r)throw ua(`Match`);return i()})):o},void 0,void 0)}function ha(e){return e}var ga;function _a(){ga&&[...ga].forEach(e=>e())}function va(e){let t;F.context&&F.load&&(t=F.load(F.getContextId()));let[n,r]=qr(t,void 0);return ga||=new Set,ga.add(r),si(()=>ga.delete(r)),Qr(()=>{let t;if(t=n()){let n=e.fallback;return typeof n==`function`&&n.length?ii(()=>n(t,()=>r())):n}return ci(()=>e.children,r)},void 0,void 0)}var ya=(e,t)=>e.showContent===t.showContent&&e.showFallback===t.showFallback,ba=vi();function xa(e){let[t,n]=qr(()=>({inFallback:!1})),r,i=yi(ba),[a,o]=qr([]);i&&(r=i.register(Qr(()=>t()().inFallback)));let s=Qr(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),ea(ba.Provider,{value:{register:e=>{let t;return o(n=>(t=n.length,[...n,e])),Qr(()=>s()[t],void 0,{equals:ya})}},get children(){return e.children}})}function Sa(e){let t=0,n,r,i,a,o,[s,c]=qr(!1),l=Si(),u={increment:()=>{++t===1&&c(!0)},decrement:()=>{--t===0&&c(!1)},inFallback:s,effects:[],resolved:!1},d=ui();if(F.context&&F.load){let e=F.getContextId(),t=F.load(e);if(t&&(typeof t!=`object`||t.s!==1?i=t:F.gather(e)),i&&i!==`$$f`){let[t,n]=qr(void 0,{equals:!1});a=t,i.then(()=>{if(F.done)return n();F.gather(e),Dr(r),n(),Dr()},e=>{o=e,n()})}}let f=yi(ba);f&&(n=f.register(u.inFallback));let p;return si(()=>p&&p()),ea(l.Provider,{value:u,get children(){return Qr(()=>{if(o)throw o;if(r=F.context,a){a(),a=void 0;return}r&&i===`$$f`&&Dr();let t=Qr(()=>e.children);return Qr(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,_i(u.effects),t();if(c)return p?a:Kr(t=>(p=t,r&&=(Dr({id:r.id+`F`,count:0}),void 0),e.fallback),d)})})}})}var Ca=e({$RAW:()=>wa,DEV:()=>void 0,createMutable:()=>Ka,createStore:()=>Ha,modifyMutable:()=>qa,produce:()=>eo,reconcile:()=>Za,unwrap:()=>Aa}),wa=Symbol(`store-raw`),Ta=Symbol(`store-node`),Ea=Symbol(`store-has`),Da=Symbol(`store-self`);function Oa(e){let t=e[Ar];if(!t&&(Object.defineProperty(e,Ar,{value:t=new Proxy(e,Ia)}),!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 ka(e){let t;return typeof e==`object`&&!!e&&(e[Ar]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function Aa(e,t=new Set){let n,r,i,a;if(n=e!=null&&e[wa])return n;if(!ka(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=Aa(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=Aa(i,t))!==i&&(e[a]=r))}return e}function ja(e,t){let n=e[t];return n||Object.defineProperty(e,t,{value:n=Object.create(null)}),n}function Ma(e,t,n){if(e[t])return e[t];let[r,i]=qr(n,{equals:!1,internal:!0});return r.$=i,e[t]=r}function Na(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===Ar||t===Ta?n:(delete n.value,delete n.writable,n.get=()=>e[Ar][t],n)}function Pa(e){li()&&Ma(ja(e,Ta),Da)()}function Fa(e){return Pa(e),Reflect.ownKeys(e)}var Ia={get(e,t,n){if(t===wa)return e;if(t===Ar)return n;if(t===Mr)return Pa(e),n;let r=ja(e,Ta),i=r[t],a=i?i():e[t];if(t===Ta||t===Ea||t===`__proto__`)return a;if(!i){let n=Object.getOwnPropertyDescriptor(e,t);li()&&(typeof a!=`function`||e.hasOwnProperty(t))&&!(n&&n.get)&&(a=Ma(r,t,a)())}return ka(a)?Oa(a):a},has(e,t){return t===wa||t===Ar||t===Mr||t===Ta||t===Ea||t===`__proto__`||(li()&&Ma(ja(e,Ea),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Fa,getOwnPropertyDescriptor:Na};function La(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[Ea]&&e[Ea][t]&&i!==void 0&&e[Ea][t].$()):(e[t]=n,e[Ea]&&e[Ea][t]&&i===void 0&&e[Ea][t].$());let o=ja(e,Ta),s;if((s=Ma(o,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==a){for(let t=e.length;t<a;t++)(s=o[t])&&s.$();(s=Ma(o,`length`,a))&&s.$(e.length)}(s=o[Da])&&s.$()}function Ra(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];za(i)||La(e,i,t[i])}}function za(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Ba(e,t){if(typeof t==`function`&&(t=t(e)),t=Aa(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&&La(e,n,r)}La(e,`length`,r)}else Ra(e,t)}function Va(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&&za(r)))return;if(Array.isArray(r)){for(let i=0;i<r.length;i++)Va(e,[r[i]].concat(t),n);return}if(o&&a===`function`){for(let i=0;i<e.length;i++)r(e[i],i)&&Va(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)Va(e,[r].concat(t),n);return}if(t.length>1){Va(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=Aa(a),r===void 0||ka(i)&&ka(a)&&!Array.isArray(a)?Ra(i,a):La(e,r,a))}function Ha(...[e,t]){let n=Aa(e||{}),r=Array.isArray(n),i=Oa(n);function a(...e){ri(()=>{r&&e.length===1?Ba(n,e[0]):Va(n,e)})}return[i,a]}function Ua(e,t){let n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||n.set||!n.configurable||t===Ar||t===Ta?n:(delete n.value,delete n.writable,n.get=()=>e[Ar][t],n.set=n=>e[Ar][t]=n,n)}var Wa={get(e,t,n){if(t===wa)return e;if(t===Ar)return n;if(t===Mr)return Pa(e),n;let r=ja(e,Ta),i=r[t],a=i?i():e[t];if(t===Ta||t===Ea||t===`__proto__`)return a;if(!i){let i=Object.getOwnPropertyDescriptor(e,t),o=typeof a==`function`;if(li()&&(!o||e.hasOwnProperty(t))&&!(i&&i.get))a=Ma(r,t,a)();else if(a!=null&&o&&a===Array.prototype[t])return(...e)=>ri(()=>Array.prototype[t].apply(n,e))}return ka(a)?Ga(a):a},has(e,t){return t===wa||t===Ar||t===Mr||t===Ta||t===Ea||t===`__proto__`||(li()&&Ma(ja(e,Ea),t)(),t in e)},set(e,t,n){return ri(()=>La(e,t,Aa(n))),!0},deleteProperty(e,t){return ri(()=>La(e,t,void 0,!0)),!0},ownKeys:Fa,getOwnPropertyDescriptor:Ua};function Ga(e){let t=e[Ar];if(!t){Object.defineProperty(e,Ar,{value:t=new Proxy(e,Wa)});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=>ri(()=>n.call(t,e)),configurable:!0})}}}}return t}function Ka(e,t){return Ga(Aa(e||{}))}function qa(e,t){ri(()=>t(Aa(e)))}var Ja=Symbol(`store-root`);function Ya(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function Xa(e,t,n,r,i){if(Ya(n))return;let a=t[n];if(e===a)return;let o=Array.isArray(e);if(n!==Ja&&(!ka(e)||!ka(a)||o!==Array.isArray(a)||i&&e[i]!==a[i])){La(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++)Xa(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++)La(a,n,e[n]);for(;n<e.length;n++)La(a,n,f[n]),Xa(e[n],a,n,r,i);a.length>e.length&&La(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?(La(a,n,f[n]),Xa(e[n],a,n,r,i)):La(a,n,e[n])}else for(let t=0,n=e.length;t<n;t++)Xa(e[t],a,t,r,i);a.length>e.length&&La(a,`length`,e.length);return}let s=Object.keys(e);for(let t=0,n=s.length;t<n;t++)Ya(s[t])||Xa(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&&La(a,c[t],void 0)}function Za(e,t={}){let{merge:n,key:r=`id`}=t,i=Aa(e);return e=>{if(!ka(e)||!ka(i))return i;let t=Xa(i,{[Ja]:e},Ja,n,r);return t===void 0?e:t}}var Qa=new WeakMap,$a={get(e,t){if(t===wa)return e;let n=e[t];if(t===Ar||t===Mr||t===Ta||t===Ea||t===`__proto__`)return n;let r;return ka(n)?Qa.get(n)||(Qa.set(n,r=new Proxy(n,$a)),r):n},set(e,t,n){return La(e,t,Aa(n)),!0},deleteProperty(e,t){return La(e,t,void 0,!0),!0}};function eo(e){return t=>{if(ka(t)){let n;(n=Qa.get(t))||Qa.set(t,n=new Proxy(t,$a)),e(n)}return t}}var to=class extends t()(`ClientError`,{cause:le()}){},no=a.check(Nt(0)),z=a.check(Re(0)),ro=x.pipe(M(`RelativePath`),O({identifier:`RelativePath`})),io=x.pipe(M(`AbsolutePath`),O({identifier:`AbsolutePath`})),B=e=>tt(e).pipe(wt(i(ue(e)),{decode:b({strict:!1}),encode:ce(Mt(e=>e!==void 0))})),ao=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),oo=e=>t=>ao(t,e(t)),so=P.pipe(wt(re,{decode:m(e=>ke(e)),encode:m(e=>Oe(e))})),co=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,lo=0,uo=0;function fo(){return mo(!1)}function po(){return mo(!0)}function mo(e,t=Date.now()){t!==lo&&(lo=t,uo=0),uo++;let n=BigInt(t)*4096n+BigInt(uo),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=>co[e%62]).join(``)}var ho=x.pipe(M(`Project.ID`),O({identifier:`Project.ID`}),oo(e=>({global:e.make(`global`)}))),go=x.check(me(`wrk`)).pipe(M(`Workspace.ID`),O({identifier:`Workspace.ID`}),oo(e=>{let t=()=>e.make(`wrk_`+fo());return{ascending:n=>n?e.make(n):t(),create:t}})),_o=e({Info:()=>bo,Location:()=>_o,PublicInfo:()=>xo,PublicRef:()=>yo,Ref:()=>vo,response:()=>V}),vo=C({directory:io,workspaceID:B(go)}).annotate({identifier:`Location.Ref`}),yo=C(o(vo.fields,[`workspaceID`])).annotate({identifier:`Location.PublicRef`}),bo=class extends p(`Location.Info`)({directory:io,workspaceID:B(go),project:C({id:ho,directory:io,canonical:io})}){},xo=C(o(bo.fields,[`workspaceID`])).annotate({identifier:`Location.PublicInfo`});function V(e){return C({location:yo,data:e})}var So=e({Event:()=>So,ID:()=>Co,Seq:()=>wo,Version:()=>To,durable:()=>H,durableMap:()=>ko,ephemeral:()=>U,inventory:()=>W,latest:()=>Do,versionedType:()=>Oo}),Co=x.check(me(`evt_`)).pipe(M(`Event.ID`),O({identifier:`Event.ID`}),oo(e=>({create:()=>e.make(`evt_`+fo())}))),wo=a.check(Re(0)).pipe(M(`Event.Seq`),O({identifier:`Event.Seq`})),To=a.check(Re(1)).pipe(M(`Event.Version`),O({identifier:`Event.Version`})),Eo=C({aggregateID:x,seq:wo,version:To});function H(e){let t=C(e.schema),n=C({aggregateID:Eo.fields.aggregateID,seq:Eo.fields.seq,version:h(e.durable.version).pipe(wt(ue(To),we({decode:()=>To.make(e.durable.version),encode:()=>e.durable.version})))});return C({id:Co,created:P,metadata:B(S(x,Ie)),type:h(e.type),durable:n,location:B(vo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(oo(()=>({type:e.type,durability:`durable`,durable:e.durable,data:t})))}function U(e){let t=C(e.schema);return C({id:Co,created:P,metadata:B(S(x,Ie)),type:h(e.type),location:B(vo),data:t}).annotate({identifier:e.identifier??e.type}).pipe(oo(()=>({type:e.type,durability:`ephemeral`,durable:void 0,data:t})))}function W(...e){return Object.freeze(e)}function Do(e){return Ao(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 Oo(e,t){return`${e}.${t}`}function ko(e){return Ao(e.reduce((e,t)=>{if(t.durability!==`durable`)return e;let n=Oo(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 Ao(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 jo=e({DirectorySource:()=>Po,EmbeddedSource:()=>zo,Event:()=>Ro,ID:()=>Mo,Info:()=>Io,Name:()=>No,Skill:()=>jo,Source:()=>Bo,UrlSource:()=>Fo}),Mo=x.pipe(M(`Skill.ID`),O({identifier:`Skill.ID`})),No=x.pipe(M(`Skill.Name`),O({identifier:`Skill.Name`})),Po=C({type:_(`directory`),path:io}).annotate({identifier:`Skill.DirectorySource`}),Fo=C({type:_(`url`),url:x}).annotate({identifier:`Skill.UrlSource`}),Io=C({id:Mo,name:No,description:x.pipe(B),autoinvoke:v.pipe(B),path:io,content:x}).annotate({identifier:`Skill.Info`}),Lo=U({type:`skill.updated`,schema:{}}),Ro={Updated:Lo,Definitions:W(Lo)},zo=C({type:_(`embedded`),skill:fe(()=>Io)}).annotate({identifier:`Skill.EmbeddedSource`}),Bo=Object.assign(E([Po,Fo,zo]).pipe(ie(`type`),O({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}`}),Vo=class extends t()(`LocationNotFoundError`,{location:yo,message:x},{httpApiStatus:404}){},Ho=class extends t()(`InvalidRequestError`,{message:x,kind:i(x),field:i(x)},{httpApiStatus:400}){},Uo=class extends t()(`RpcError`,{type:x,message:x,data:i(Ie)},{httpApiStatus:400}){},Wo=class extends t()(`RpcInternalError`,{type:y([`rpc.internal`,`rpc.invalid_output`]),message:x,data:i(Ie)},{httpApiStatus:500}){},Go=class extends t()(`UnauthorizedError`,{message:x},{httpApiStatus:401}){},Ko=class extends t()(`ConflictError`,{message:x,resource:i(x)},{httpApiStatus:409}){},qo=class extends t()(`SessionBusyError`,{sessionID:x,message:x},{httpApiStatus:409}){},Jo=class extends t()(`ServiceUnavailableError`,{message:x,service:i(x)},{httpApiStatus:503}){},Yo=class extends t()(`UnknownError`,{message:x,ref:i(x)},{httpApiStatus:500}){},Xo=class extends t()(`ProviderNotFoundError`,{providerID:x,message:x},{httpApiStatus:404}){},Zo=class extends t()(`IntegrationNotFoundError`,{integrationID:x,message:x},{httpApiStatus:404}){},Qo=class extends t()(`IntegrationAttemptNotFoundError`,{integrationID:x,attemptID:x,message:x},{httpApiStatus:404}){},$o=class extends t()(`IntegrationMethodNotFoundError`,{integrationID:x,methodID:x,message:x},{httpApiStatus:404}){},es=class extends t()(`ProjectNotFoundError`,{projectID:x,message:x},{httpApiStatus:404}){},ts=class extends t()(`FileNotFoundError`,{path:x,message:x},{httpApiStatus:404}){},ns=class extends t()(`PluginNotFoundError`,{pluginID:x,message:x},{httpApiStatus:404}){},rs=class extends t()(`AgentNotFoundError`,{agentID:x,message:x},{httpApiStatus:404}){},G=class extends t()(`SessionNotFoundError`,{sessionID:x,message:x},{httpApiStatus:404}){},is=class extends t()(`MessageNotFoundError`,{sessionID:x,messageID:x,message:x},{httpApiStatus:404}){},as=class extends t()(`SkillNotFoundError`,{skill:Mo,message:x},{httpApiStatus:404}){},os=class extends t()(`McpServerNotFoundError`,{server:x,message:x},{httpApiStatus:404}){},ss=class extends t()(`CommandNotFoundError`,{command:x,message:x},{httpApiStatus:404}){},cs=class extends t()(`CommandExecutionError`,{command:x,message:x},{httpApiStatus:500}){},ls=class extends t()(`InvalidCursorError`,{message:x},{httpApiStatus:400}){},us=class extends t()(`PermissionNotFoundError`,{requestID:x,message:x},{httpApiStatus:404}){},ds=class extends t()(`PermissionSavedNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},fs=class extends t()(`FormNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},ps=class extends t()(`FormAlreadySettledError`,{id:x,message:x},{httpApiStatus:409}){},ms=class extends t()(`FormInvalidAnswerError`,{id:x,message:x},{httpApiStatus:400}){},hs=class extends t()(`ForbiddenError`,{message:x},{httpApiStatus:403}){},gs=class extends t()(`PtyNotFoundError`,{ptyID:x,message:x},{httpApiStatus:404}){},_s=class extends t()(`ShellNotFoundError`,{id:x,message:x},{httpApiStatus:404}){},vs=class extends t()(`ModelNotFoundError`,{providerID:x,modelID:x,message:x},{httpApiStatus:404}){},ys=class extends t()(`UnsupportedModelError`,{providerID:x,modelID:x,capability:x,message:x},{httpApiStatus:422}){},bs=class extends t()(`ProviderRequestError`,{providerID:x,reason:y([`authentication`,`rate_limit`,`content_filter`,`invalid_request`,`overloaded`,`provider`]),message:x,status:i(a),retryAfterMs:i(a)},{httpApiStatus:502}){},xs=class extends Qe()(`@opencode/HttpApiSchemaError`,{error:Ho}){},Ss=x.pipe(M(`Integration.ID`),O({identifier:`Integration.ID`})),Cs=x.pipe(M(`Integration.MethodID`),O({identifier:`Integration.MethodID`})),ws=e({CreateInput:()=>Ps,Credential:()=>ws,Entry:()=>Ns,Event:()=>Os,External:()=>js,ID:()=>Ts,Key:()=>As,OAuth:()=>ks,Value:()=>Ms}),Ts=x.pipe(M(`Credential.ID`),O({identifier:`Credential.ID`}),oo(e=>({create:()=>e.make(`cred_`+fo())}))),Es=U({type:`credential.updated`,schema:{}}),Ds=U({type:`credential.switched`,schema:{integrationID:Ss,credentialID:se(Ts)}}),Os={Updated:Es,Switched:Ds,Definitions:W(Es,Ds)},ks=C({type:h(`oauth`),methodID:Cs,refresh:x,access:x,expires:z,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.OAuth`}),As=C({type:h(`key`),key:x,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.Key`}),js=C({type:h(`external`),methodID:Cs,metadata:B(S(x,Ie))}).annotate({identifier:`Credential.External`}),Ms=E([ks,As,js]).pipe(ie(`type`)).annotate({identifier:`Credential.Value`}),Ns=C({id:Ts,integrationID:Ss,label:x,active:v,value:Ms}).annotate({identifier:`Credential.Entry`}),Ps=C({id:B(Ts),integrationID:Ss,label:B(x),value:Ms,activate:B(v)}).annotate({identifier:`Credential.CreateInput`}),Fs=C({status:y([`needs_auth`]),message:x,url:B(x)}).annotate({identifier:`Connection.Status`}),Is=C({type:h(`credential`),id:Ts,label:x,method:y([`key`,`oauth`,`external`]),status:B(Fs)}).annotate({identifier:`Connection.CredentialInfo`}),Ls=C({type:h(`env`),name:x,status:B(Fs)}).annotate({identifier:`Connection.EnvInfo`}),Rs=E([Is,Ls]).pipe(ie(`type`)).annotate({identifier:`Connection.Info`}),zs=e({Answer:()=>nc,BooleanField:()=>Js,Detail:()=>ic,Event:()=>lc,ExternalField:()=>Xs,Field:()=>Zs,Fields:()=>Qs,Form:()=>zs,ID:()=>Bs,Info:()=>ec,IntegerField:()=>qs,Metadata:()=>Vs,MultiselectField:()=>Ys,NumberField:()=>Ks,Option:()=>Hs,Reply:()=>ac,State:()=>rc,StringField:()=>Gs,Value:()=>tc,When:()=>Us}),Bs=x.check(me(`frm_`)).pipe(M(`Form.ID`),O({identifier:`Form.ID`})).pipe(oo(e=>({create:t=>e.make(t??`frm_`+fo())}))),Vs=S(x,Ie).annotate({identifier:`Form.Metadata`}),Hs=C({value:x,label:x,description:x.pipe(B)}).annotate({identifier:`Form.Option`}),Us=C({key:x,op:y([`eq`,`neq`]),value:E([x,gt,v])}).annotate({identifier:`Form.When`}),Ws={key:x,title:x.pipe(B),description:x.pipe(B),required:v.pipe(B),hidden:v.pipe(B).annotate({description:`Skip the interactive authentication prompt and use the default unless an answer is supplied`}),when:g(Us).pipe(B)},Gs=C({...Ws,type:h(`string`),format:y([`email`,`uri`,`date`,`date-time`]).pipe(B),minLength:z.pipe(B),maxLength:z.pipe(B),pattern:x.pipe(B),placeholder:x.pipe(B),default:x.pipe(B),options:g(Hs).pipe(B),custom:v.pipe(B)}).annotate({identifier:`Form.StringField`}),Ks=C({...Ws,type:h(`number`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.NumberField`}),qs=C({...Ws,type:h(`integer`),minimum:gt.pipe(B),maximum:gt.pipe(B),default:gt.pipe(B)}).annotate({identifier:`Form.IntegerField`}),Js=C({...Ws,type:h(`boolean`),default:v.pipe(B)}).annotate({identifier:`Form.BooleanField`}),Ys=C({...Ws,type:h(`multiselect`),options:g(Hs),minItems:z.pipe(B),maxItems:z.pipe(B),custom:v.pipe(B),default:g(x).pipe(B)}).annotate({identifier:`Form.MultiselectField`}),Xs=C({key:x,type:h(`external`),url:x,title:x.pipe(B),description:x.pipe(B)}).annotate({identifier:`Form.ExternalField`}),Zs=E([Gs,Ks,qs,Js,Ys,Xs]).pipe(ie(`type`),O({identifier:`Form.Field`})),Qs=De(Zs).annotate({identifier:`Form.Fields`}),$s={id:Bs,sessionID:x,title:x,metadata:Vs.pipe(B)},ec=C({...$s,fields:Qs}).annotate({identifier:`Form.Info`}),tc=E([x,gt,v,g(x)]).annotate({identifier:`Form.Value`}),nc=S(x,tc).annotate({identifier:`Form.Answer`}),rc=E([C({status:h(`pending`)}),C({status:h(`answered`),answer:nc}),C({status:h(`cancelled`),message:x.pipe(B)})]).pipe(ie(`status`)).annotate({identifier:`Form.State`}),ic=C({...ec.fields,state:rc}).annotate({identifier:`Form.Detail`}),ac=C({answer:nc}).annotate({identifier:`Form.Reply`}),oc=U({type:`form.created`,schema:{form:ec}}),sc=U({type:`form.replied`,schema:{id:Bs,sessionID:x,answer:nc}}),cc=U({type:`form.cancelled`,schema:{id:Bs,sessionID:x}}),lc={Created:oc,Replied:sc,Cancelled:cc,Definitions:W(oc,sc,cc)},uc=e({Attempt:()=>Tc,AttemptID:()=>Cc,AttemptStatus:()=>Ec,CommandAttempt:()=>Dc,CommandAttemptStatus:()=>Oc,CommandMethod:()=>mc,EnvMethod:()=>_c,Event:()=>bc,ExternalMethod:()=>gc,ID:()=>dc,Info:()=>Sc,Integration:()=>uc,KeyMethod:()=>hc,Method:()=>vc,MethodID:()=>fc,OAuthMethod:()=>pc,Ref:()=>xc}),dc=Ss,fc=Cs,pc=C({id:fc,type:h(`oauth`),label:x,form:B(Qs)}).annotate({identifier:`Integration.OAuthMethod`}),mc=C({id:fc,type:h(`command`),label:x,command:g(x)}).annotate({identifier:`Integration.CommandMethod`}),hc=C({type:h(`key`),label:B(x),form:B(Qs)}).annotate({identifier:`Integration.KeyMethod`}),gc=C({id:fc,type:h(`external`),label:x,form:B(Qs)}).annotate({identifier:`Integration.ExternalMethod`}),_c=C({type:h(`env`),names:g(x)}).annotate({identifier:`Integration.EnvMethod`}),vc=E([pc,mc,hc,gc,_c]).pipe(ie(`type`)).annotate({identifier:`Integration.Method`}),yc=U({type:`integration.updated`,schema:{}}),bc={Updated:yc,Definitions:W(yc)},xc=C({id:dc,name:x,metadata:B(S(x,et))}).annotate({identifier:`Integration.Ref`}),Sc=C({id:dc,name:x,metadata:B(S(x,et)),methods:g(vc),connections:g(Rs)}).annotate({identifier:`Integration.Info`}),Cc=x.pipe(M(`Integration.AttemptID`),O({identifier:`Integration.AttemptID`}),oo(e=>({create:()=>e.make(`con_`+fo())}))),wc=C({created:gt,expires:gt}),Tc=class extends p(`Integration.Attempt`)({attemptID:Cc,url:x,instructions:x,mode:y([`auto`,`code`]),time:wc}){},Ec=E([C({status:h(`pending`),time:wc}),C({status:h(`complete`),time:wc}),C({status:h(`failed`),message:x,time:wc}),C({status:h(`expired`),time:wc})]).pipe(ie(`status`)).annotate({identifier:`Integration.AttemptStatus`}),Dc=C({attemptID:Cc,time:wc}).annotate({identifier:`Integration.CommandAttempt`}),Oc=E([C({status:h(`pending`),message:B(x),time:wc}),C({status:h(`complete`),time:wc}),C({status:h(`failed`),message:x,time:wc}),C({status:h(`expired`),time:wc})]).pipe(ie(`status`)).annotate({identifier:`Integration.CommandAttemptStatus`}),kc=E([y([`reasoning`,`reasoning_content`,`reasoning_text`]),x]).annotate({identifier:`Model.ReasoningField`}),Ac=y([`max_completion_tokens`,`max_tokens`]).annotate({identifier:`Model.MaxTokensField`}),jc=y([`assets`,`state`,`root`]).annotate({identifier:`Model.MediaInput`}),Mc=y([`anthropic`,`alibaba`]).annotate({identifier:`Model.CacheFormat`}),Nc=C({reasoningField:kc.pipe(B),requireReasoning:v.pipe(B),maxTokensField:Ac.pipe(B),requireFinishReason:v.pipe(B),requireAssistantAfterTool:v.pipe(B),supportsPromptCacheKey:v.pipe(B),streamUsage:v.pipe(B),cacheFormat:Mc.pipe(B),supportsThinkingBlockBinding:v.pipe(B),supportsEffortUpdates:v.pipe(B),mediaInput:jc.pipe(B)}).annotate({identifier:`Model.Compatibility`}),Pc=C(o(Nc.fields,[`supportsThinkingBlockBinding`,`supportsEffortUpdates`])).annotate({identifier:`Provider.Compatibility`}),Fc=e({Activation:()=>Bc,Cache:()=>Wc,CacheTTL:()=>Uc,Compaction:()=>Vc,Encoding:()=>Gc,Event:()=>Rc,ID:()=>Ic,Info:()=>Xc,Overlays:()=>Jc,Package:()=>zc,Provider:()=>Fc,Request:()=>Yc,Settings:()=>qc,Transport:()=>Hc}),Ic=x.pipe(M(`Provider.ID`),O({identifier:`Provider.ID`}),oo(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`)}))),Lc=U({type:`provider.updated`,schema:{}}),Rc={Updated:Lc,Definitions:W(Lc)},zc=x,Bc=y([`auto`,`enabled`,`disabled`]),Vc=E([C({type:h(`summary`)}),C({type:h(`native`)})]).pipe(ie(`type`)).annotate({identifier:`Provider.Compaction`}),Hc=y([`http`,`websocket`]).annotate({identifier:`Provider.Transport`}),Uc=We([gt,y([`ms`,`s`,`m`,`h`,`d`])]).check(Ce(/^\d+(ms|s|m|h|d)$/)).annotate({identifier:`Provider.CacheTTL`}),Wc=C({ttl:Uc.pipe(B)}).annotate({identifier:`Provider.Cache`}),Gc=y([`zstd`,`gzip`,`none`]).annotate({identifier:`Provider.Encoding`}),Kc=E([P,h(!1)]).pipe(B),qc=ge(C({timeout:Kc,headerTimeout:Kc,chunkTimeout:Kc,compaction:Vc.pipe(B),cache:Wc.pipe(B),transport:Hc.pipe(B),encoding:Gc.pipe(B)}),[S(x,et)]).annotate({identifier:`Provider.Settings`}),Jc={settings:qc.pipe(B),headers:S(x,x).pipe(B),body:S(x,et).pipe(B)},Yc=C({settings:qc.pipe(ye(Ve({}))),headers:S(x,x),body:S(x,et)}).annotate({identifier:`Provider.Request`}),Xc=C({id:Ic,canonical:Ic.pipe(B),integrationID:dc.pipe(B),name:x,activation:Bc,package:zc,compatibility:Pc.pipe(B),...Jc}).annotate({identifier:`Provider.Info`}).pipe(oo(()=>({empty:e=>({id:e,name:e,activation:`auto`,package:``})}))),Zc=P.pipe(M(`Money.USD`),O({identifier:`Money.USD`}),oo(e=>({zero:e.make(0)}))),Qc=P.pipe(M(`Money.USDPerMillionTokens`),O({identifier:`Money.USDPerMillionTokens`}),oo(e=>({zero:e.make(0)}))),$c=e({Capabilities:()=>ll,Compatibility:()=>Nc,Cost:()=>ul,Event:()=>nl,Family:()=>al,ID:()=>el,Info:()=>fl,MaxTokensField:()=>Ac,MediaInput:()=>jc,Model:()=>$c,Overlays:()=>cl,ReasoningField:()=>kc,Ref:()=>il,Settings:()=>sl,Type:()=>ol,Variant:()=>dl,VariantID:()=>rl}),el=x.pipe(M(`Model.ID`)),tl=U({type:`model.updated`,schema:{}}),nl={Updated:tl,Definitions:W(tl)},rl=x.pipe(M(`Model.VariantID`)),il=C({id:el,providerID:Ic,variant:rl.pipe(B)}).annotate({identifier:`Model.Ref`}).pipe(oo(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:Ic.make(r),id:el.make(a),...o?{variant:rl.make(o)}:{}})}}))),al=x.pipe(M(`Model.Family`)),ol=E([y([`chat`,`decision`,`image`]),x]).annotate({identifier:`Model.Type`}),sl=ge(C(Ee(qc.schema.fields,[`compaction`,`cache`,`encoding`])),[S(x,et)]).annotate({identifier:`Model.Settings`}),cl={settings:sl.pipe(B),headers:S(x,x).pipe(B),body:S(x,et).pipe(B)},ll=C({tools:v,input:g(x),output:g(x),temperature:v.pipe(B)}).annotate({identifier:`Model.Capabilities`}).pipe(oo(()=>({default:()=>({tools:!0,input:[`text`,`image`],output:[`text`]})}))),ul=C({tier:C({type:_(`context`),size:a}).pipe(B),input:Qc,output:Qc,cache:C({read:Qc,write:Qc})}).annotate({identifier:`Model.Cost`}),dl=C({id:rl,...cl}).annotate({identifier:`Model.Variant`}),fl=C({id:el,modelID:el,providerID:Ic,canonical:Ic.pipe(B),type:ol.pipe(B),family:al.pipe(B),name:x,compatibility:Nc.pipe(B),package:zc.pipe(B),...cl,capabilities:ll,variants:g(dl),time:C({released:P}),cost:g(ul),status:y([`alpha`,`beta`,`deprecated`,`active`]),enabled:v,limit:C({context:a,input:a.pipe(B),output:a})}).annotate({identifier:`Model.Info`}).pipe(oo(()=>({default:(e,t)=>({id:t,modelID:t,providerID:e,name:t,capabilities:ll.default(),variants:[],time:{released:0},cost:[],status:`active`,enabled:!0,limit:{context:2e5,output:32e3}})}))),pl=C({start:P,end:P,text:x}).annotate({identifier:`Prompt.Mention`}),ml=E([C({type:h(`inline`)}),C({type:h(`uri`),uri:x})]).pipe(ie(`type`)).annotate({identifier:`Prompt.FileSource`}),hl=x.check(rt(e=>e.length%4==0&&/^[A-Za-z0-9+/]*={0,2}$/u.test(e),Ce(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations)).annotate({identifier:`Prompt.Base64`}),gl=C({data:hl,mime:x,source:ml,name:x.pipe(B),description:x.pipe(B),mention:pl.pipe(B)}).annotate({identifier:`Prompt.FileAttachment`}).pipe(oo(e=>({create:t=>e.make({data:t.data,mime:t.mime,source:t.source,name:t.name,description:t.description,mention:t.mention})}))),_l=x.check(Ce(/^media:[0-9a-f]{64}$/)).annotate({identifier:`Prompt.MediaRef`}),{data:vl,...yl}=gl.fields,bl=C({...yl,uri:_l,bytes:a.pipe(B),width:a.pipe(B),height:a.pipe(B)}).annotate({identifier:`Prompt.MediaFileAttachment`}),xl=E([gl,bl]).annotate({identifier:`Prompt.Attachment`}),Sl=C({name:x,mention:pl.pipe(B)}).annotate({identifier:`Prompt.AgentAttachment`}),Cl=C({id:Mo,name:No,text:x.pipe(B),mention:pl.pipe(B)}).annotate({identifier:`Prompt.SkillAttachment`}),wl=C({text:x,files:g(gl).pipe(B),agents:g(Sl).pipe(B),skills:g(Cl).pipe(B)}).annotate({identifier:`Prompt`}).pipe(oo(e=>({equivalence:ee(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}})}))),Tl=e=>({description:e}),El=C({data:hl,mime:x,name:x.pipe(B)}).annotate({identifier:`Generate.File`}),Dl=C({input:P.pipe(B),output:P.pipe(B)}).annotate({identifier:`Generate.Usage`,description:`Token counts, when the provider reports them`}),Ol=S(x,Ie).annotate({identifier:`Generate.Native`,description:`Provider-specific data the shared fields do not cover`}),kl=We([gt,`:`,gt]).check(Ce(/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/)).annotate({identifier:`Generate.ImageAspect`,description:`Aspect ratio as width:height, for example 16:9`}),Al=E([y([`1K`,`2K`,`4K`]),x]).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`}),jl=C({model:il,prompt:x,images:g(El).pipe(B).annotate(Tl(`Edit sources or style and subject references, in order`)),n:no.pipe(B).annotate(Tl(`Number of images to generate; defaults to 1`)),aspect:kl.pipe(B),resolution:Al.pipe(B)}).annotate({identifier:`Generate.ImageRequest`}),Ml=C({type:h(`image`),...El.fields}).annotate({identifier:`Generate.ImageOutput`}),Nl=C({images:g(Ml),cost:Zc.pipe(B),tokens:Dl.pipe(B),native:Ol.pipe(B)}).annotate({identifier:`Generate.ImageResult`}),Pl=C({type:h(`text`),text:x}).annotate({identifier:`Generate.DecisionTextPart`}),Fl=C({type:h(`json`),value:Te}).annotate({identifier:`Generate.DecisionJsonPart`}),Il=C({type:h(`file`),...El.fields}).annotate({identifier:`Generate.DecisionFilePart`}),Ll=E([Pl,Fl,Il]).annotate({identifier:`Generate.DecisionPart`}),Rl=E([x,v]).annotate({identifier:`Generate.ChoiceValue`,description:`Choice values are typed: true and "true" are different values`}),zl=x.annotate(Tl(`Unique within the request; echoed on the matching answer`)),Bl=C({type:h(`predicate`),name:zl,instructions:x}).annotate({identifier:`Generate.PredicateQuestion`,description:`The probability that a statement is true`}),Vl=C({type:h(`choice`),name:zl,instructions:x,choices:g(C({value:Rl,description:x.pipe(B)})).check(c(1))}).annotate({identifier:`Generate.ChoiceQuestion`,description:`Pick one value from a fixed set`}),Hl=C({type:h(`score`),name:zl,instructions:x,levels:g(C({label:x,description:x.pipe(B)})).check(c(1))}).annotate({identifier:`Generate.ScoreQuestion`,description:`Place the input on ordered levels, lowest first`}),Ul=E([Bl,Vl,Hl]).annotate({identifier:`Generate.DecisionQuestion`}),Wl=C({model:il,input:g(Ll).annotate(Tl(`The evidence every question is asked about, in order`)),questions:g(Ul).check(c(1)).annotate(Tl(`Question names must be unique; duplicates fail with InvalidRequestError`))}).annotate({identifier:`Generate.DecisionRequest`}),Gl=P.check(Dt({minimum:0,maximum:1})),Kl=C({type:h(`predicate`),name:x,probability:Gl}).annotate({identifier:`Generate.PredicateAnswer`}),ql=C({type:h(`choice`),name:x,choice:Rl,probabilities:g(C({value:Rl,probability:Gl})),confidence:Gl}).annotate({identifier:`Generate.ChoiceAnswer`}),Jl=C({type:h(`score`),name:x,score:P.annotate(Tl(`Probability-weighted level index, so it can fall between levels`)),probabilities:g(C({value:a,label:x,probability:Gl})),confidence:Gl}).annotate({identifier:`Generate.ScoreAnswer`}),Yl=C({type:h(`error`),name:x,reason:x.annotate(Tl(`Why the question has no answer, for example refusal`)),message:x.pipe(B)}).annotate({identifier:`Generate.ErrorAnswer`,description:`This one question has no answer; the other answers still came back`}),Xl=E([Kl,ql,Jl,Yl]).annotate({identifier:`Generate.DecisionAnswer`}),Zl=C({answers:g(Xl).annotate(Tl(`One answer per question, in question order`)),cost:Zc.pipe(B),tokens:Dl.pipe(B),native:Ol.pipe(B)}).annotate({identifier:`Generate.DecisionResult`}),Ql=[Ho,Xo,vs,ys,bs,Jo,Vo],$l={payload:C({prompt:x,model:il.pipe(i)}),success:C({data:C({text:x})}).annotate({identifier:`GenerateTextResponse`}),error:Ql},eu=N(`server.generate`).add(D(`generate.text`,`/api/experimental/generate/text`,$l).annotateMerge(k({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(D(`generate.textLegacy`,`/api/experimental/generate`,$l).annotateMerge(k({identifier:`experimental.generate.textLegacy`,summary:`Generate text (deprecated path)`,description:`Deprecated alias of POST /api/experimental/generate/text.`,deprecated:!0}))).add(D(`generate.image`,`/api/experimental/generate/image`,{payload:jl,success:C({data:Nl}).annotate({identifier:`GenerateImageResponse`}),error:Ql}).annotateMerge(k({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(D(`generate.decisions`,`/api/experimental/generate/decisions`,{payload:Wl,success:C({data:Zl}).annotate({identifier:`GenerateDecisionsResponse`}),error:Ql}).annotateMerge(k({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(k({title:`generate`,description:`Experimental one-shot generation routes.`})),tu=x.check(Ce(/^[0-9a-f]{64}$/u)).annotate({identifier:`MediaHash`}),nu=A(`media.get`,`/api/experimental/media/:hash`,{params:{hash:tu},success:dt.pipe(mt()),error:[ts,Ho]}).annotateMerge(k({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`]})})),ru=e({CreateInput:()=>du,Event:()=>uu,ID:()=>iu,Info:()=>au,Pty:()=>ru,UpdateInput:()=>fu}),iu=x.check(me(`pty`)).pipe(M(`PtyID`),O({identifier:`Pty.ID`})).pipe(oo(e=>{let t=()=>e.make(`pty_`+fo());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),au=C({id:iu,title:x,command:x,args:g(x),cwd:x,status:y([`running`,`exited`]),pid:z,exitCode:B(z)}).annotate({identifier:`Pty`}),ou=U({type:`pty.created`,schema:{info:au}}),su=U({type:`pty.updated`,schema:{info:au}}),cu=U({type:`pty.exited`,schema:{id:iu,exitCode:z}}),lu=U({type:`pty.deleted`,schema:{id:iu}}),uu={Created:ou,Updated:su,Exited:cu,Deleted:lu,Definitions:W(ou,su,cu,lu)},du=C({command:B(x),args:B(g(x)),cwd:B(x),title:B(x),env:B(S(x,x))}),fu=C({title:B(x),size:B(C({rows:no,cols:no}))}),pu=x.check(me(`ses`)).pipe(M(`SessionID`),O({identifier:`Session.ID`}),oo(e=>({create:()=>e.make(`ses_`+po())}))),mu=e({Effect:()=>Cu,Event:()=>Su,ID:()=>hu,Permission:()=>mu,Reply:()=>yu,Request:()=>vu,Rule:()=>wu,Ruleset:()=>Tu,Source:()=>gu}),hu=x.check(me(`per`)).pipe(M(`Permission.ID`),O({identifier:`Permission.ID`}),oo(e=>({create:t=>e.make(t??`per_`+fo())}))),gu=E([C({type:h(`tool`),messageID:x,id:x})]).annotate({identifier:`Permission.Source`}),_u={sessionID:pu,action:x,resources:g(x),save:g(x).pipe(B),metadata:S(x,Ie).pipe(B),source:gu.pipe(B),message:x.pipe(B)},vu=C({id:hu,..._u}).annotate({identifier:`Permission.Request`}),yu=y([`once`,`always`,`reject`]).annotate({identifier:`Permission.Reply`}),bu=U({type:`permission.asked`,schema:vu.fields}),xu=U({type:`permission.replied`,schema:{sessionID:pu,requestID:hu,reply:yu}}),Su={Asked:bu,Replied:xu,Definitions:W(bu,xu)},Cu=y([`allow`,`deny`,`ask`]).annotate({identifier:`Permission.Effect`}),wu=C({action:x,resource:x,effect:Cu}).annotate({identifier:`Permission.Rule`}),Tu=g(wu).annotate({identifier:`Permission.Ruleset`}),Eu=e({Agent:()=>Eu,Color:()=>Au,Event:()=>Mu,ID:()=>Ou,Info:()=>ju,Name:()=>ku}),Du=U({type:`agent.updated`,schema:{}}),Ou=x.pipe(M(`Agent.ID`),O({identifier:`Agent.ID`})),ku=x.pipe(M(`Agent.Name`)),Au=x.annotate({identifier:`Agent.Color`}),ju=C({id:Ou,name:ku,model:il.pipe(B),request:Yc,system:x.pipe(B),description:x.pipe(B),mode:y([`subagent`,`primary`,`all`]),hidden:v,color:Au.pipe(B),steps:no.pipe(B),permissions:Tu}).annotate({identifier:`Agent.Info`}).pipe(oo(()=>({default:e=>({id:e,name:ku.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`}]})}))),Mu={Updated:Du,Definitions:W(Du)},Nu=e({Commands:()=>Ru,Current:()=>Iu,Event:()=>Uu,ID:()=>Pu,Icon:()=>Lu,Info:()=>Bu,Project:()=>Nu,Time:()=>zu,UpdateInput:()=>Vu,Vcs:()=>Fu}),Pu=ho,Fu=x.check(Ce(/^[a-z][a-z0-9._-]*$/u)).annotate({identifier:`Project.Vcs`}),Iu=C({id:Pu,directory:io,canonical:io}).annotate({identifier:`Project.Current`}),Lu=C({url:B(x),override:B(x),color:B(x)}).annotate({identifier:`Project.Icon`}),Ru=C({start:B(x.annotate({description:`Startup script to run when creating a new workspace (worktree)`}))}).annotate({identifier:`Project.Commands`}),zu=C({created:z,updated:z,active:z,archived:B(z)}).annotate({identifier:`Project.Time`}),Bu=C({id:Pu,canonical:io,vcs:B(Fu),name:B(x),icon:B(Lu),commands:B(Ru),time:zu,sandboxes:g(x)}).annotate({identifier:`Project`}),Vu=C({projectID:Pu,canonical:B(io),name:B(x),icon:B(Lu),commands:B(Ru)}).annotate({identifier:`Project.UpdateInput`}),Hu=U({type:`project.updated`,schema:Bu.fields}),Uu={Updated:Hu,Definitions:W(Hu)},Wu=y([`stop`,`length`,`tool-calls`,`content-filter`,`error`,`unknown`]);x.pipe(M(`Tool.CallID`)),t()(`Tool.Error`,{message:x,error:i(le()),metadata:i(S(x,Ie))});var Gu=C({type:h(`text`),text:x}).annotate({identifier:`Tool.TextContent`}),Ku=C({type:h(`file`),uri:x,mime:x,name:i(x)}).annotate({identifier:`Tool.FileContent`}),qu=E([Gu,Ku]).pipe(ie(`type`)).annotate({identifier:`Tool.Content`}),Ju=S(x,Te).annotate({identifier:`Session.Metadata`}),Yu=x.check(me(`sh_`)).pipe(M(`Shell.ID`),O({identifier:`Shell.ID`})).pipe(oo(e=>{let t=()=>e.make(`sh_`+fo());return{create:t,ascending:n=>n===void 0?t():e.make(n)}})),Xu=y([`running`,`exited`,`timeout`,`killed`]),Zu=C({started:P.annotate({description:`Start time in milliseconds since the Unix epoch`}),completed:B(P).annotate({description:`Completion time in milliseconds since the Unix epoch`})}),Qu=S(x,Ie),$u=C({id:Yu,status:Xu,command:x,cwd:x,shell:x,file:x,pid:B(z),exit:B(P),signal:B(x),metadata:Qu,time:Zu}).annotate({identifier:`Shell.Info`}),ed=U({type:`shell.created`,schema:{info:$u}}),td=U({type:`shell.exited`,schema:{id:Yu,exit:B(P),status:Xu}}),nd=U({type:`shell.deleted`,schema:{id:Yu}}),rd={Created:ed,Exited:td,Deleted:nd,Definitions:W(ed,td,nd)},id=C({command:x,cwd:B(x),timeout:B(z),metadata:B(Qu)}),ad=C({cursor:B(z),limit:B(z)}),od=C({output:x,cursor:z,size:z,truncated:v}),sd=C({type:x,message:x,status:a.check(Dt({minimum:100,maximum:599})).pipe(B),response:C({body:x}).pipe(B),retryAfterMs:z.pipe(B)}).annotate({identifier:`Session.StructuredError`}),cd=x.pipe(M(`Snapshot.ID`),O({identifier:`Snapshot.ID`})),ld=C({input:P,output:P,reasoning:P,cache:C({read:P,write:P})}).annotate({identifier:`TokenUsage.Info`}),ud=e({AgentSelected:()=>pd,Assistant:()=>Nd,AssistantContent:()=>Ad,AssistantContentEncoded:()=>jd,AssistantReasoning:()=>kd,AssistantRetry:()=>Md,AssistantText:()=>Od,AssistantTool:()=>Dd,Compaction:()=>zd,CompactionCompleted:()=>Ld,CompactionFailed:()=>Rd,CompactionRunning:()=>Id,ID:()=>K,Idle:()=>Bd,Info:()=>Vd,LocationSwitched:()=>hd,MediaInfo:()=>Hd,MediaUser:()=>_d,ModelSelected:()=>md,Native:()=>fd,SessionMessage:()=>ud,Shell:()=>xd,Skill:()=>bd,Synthetic:()=>vd,System:()=>yd,ToolState:()=>Ed,ToolStateCompleted:()=>wd,ToolStateError:()=>Td,ToolStateRunning:()=>Cd,ToolStateStreaming:()=>Sd,User:()=>gd}),K=x.check(me(`msg_`)).pipe(M(`Session.Message.ID`),O({identifier:`Session.Message.ID`}),oo(e=>({create:()=>e.make(`msg_`+fo()),fromEvent:t=>e.make(t.replace(/^evt_/,`msg_`))}))),dd={id:K,metadata:S(x,Ie).pipe(B),time:C({created:so})},fd=S(x,Ie).annotate({identifier:`Session.Message.Native`}),pd=C({...dd,type:_(`agent-switched`),agent:Ou,previous:Ou.pipe(B)}).annotate({identifier:`Session.Message.AgentSelected`}),md=C({...dd,type:_(`model-switched`),model:il,previous:il.pipe(B)}).annotate({identifier:`Session.Message.ModelSelected`}),hd=C({...dd,type:_(`location-switched`),location:vo,projectID:Pu.pipe(B),subpath:ro.pipe(B),previous:C({location:vo,projectID:Pu.pipe(B),subpath:ro.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.LocationSwitched`}),gd=C({...dd,text:wl.fields.text,files:wl.fields.files,agents:wl.fields.agents,skills:wl.fields.skills,type:_(`user`)}).annotate({identifier:`Session.Message.User`}),_d=C({...gd.fields,files:g(xl).pipe(B)}).annotate({identifier:`Session.Message.MediaUser`}),vd=C({...dd,text:x,description:x.pipe(B),type:_(`synthetic`)}).annotate({identifier:`Session.Message.Synthetic`}),yd=C({...dd,type:_(`system`),text:x,description:x.pipe(B)}).annotate({identifier:`Session.Message.System`}),bd=C({...dd,type:_(`skill`),skill:Mo,name:No,text:x}).annotate({identifier:`Session.Message.Skill`}),xd=C({...dd,type:_(`shell`),shellID:Yu,command:x,status:Xu,exit:gt.pipe(B),output:od.pipe(B),time:C({created:so,completed:so.pipe(B)})}).annotate({identifier:`Session.Message.Shell`}),Sd=C({status:_(`streaming`),input:x}).annotate({identifier:`Session.Message.ToolState.Streaming`}),Cd=C({status:_(`running`),input:S(x,Ie),metadata:S(x,Te)}).annotate({identifier:`Session.Message.ToolState.Running`}),wd=C({status:_(`completed`),input:S(x,Ie),content:De(qu),metadata:S(x,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Completed`}),Td=C({status:_(`error`),input:S(x,Ie),error:sd,content:De(qu).pipe(B),metadata:S(x,Te).pipe(B)}).annotate({identifier:`Session.Message.ToolState.Error`}),Ed=E([Sd,Cd,wd,Td]).pipe(ie(`status`)),Dd=C({type:_(`tool`),id:x,name:x,executed:v.pipe(B),native:fd.pipe(B),state:Ed,time:C({created:so,ran:so.pipe(B),completed:so.pipe(B)})}).annotate({identifier:`Session.Message.Assistant.Tool`}),Od=C({type:_(`text`),text:x,native:fd.pipe(B)}).annotate({identifier:`Session.Message.Assistant.Text`}),kd=C({type:_(`reasoning`),text:x,native:fd.pipe(B),time:C({created:so,completed:so.pipe(B)}).pipe(B)}).annotate({identifier:`Session.Message.Assistant.Reasoning`}),Ad=E([Od,kd,Dd]).pipe(ie(`type`)),jd=he(Ad).annotate({identifier:`Session.Message.AssistantContent.Encoded`}),Md=C({attempt:no,at:so,error:sd}).annotate({identifier:`Session.Message.Assistant.Retry`}),Nd=C({...dd,type:_(`assistant`),agent:Ou,model:il,content:Ad.pipe(g),snapshot:C({start:cd.pipe(B),end:cd.pipe(B),files:g(ro).pipe(B)}).pipe(B),finish:Wu.pipe(B),rawFinish:x.pipe(B),native:fd.pipe(B),cost:Zc.pipe(B),tokens:ld.pipe(B),error:sd.pipe(B),retry:Md.pipe(B),time:C({created:so,streamed:so.pipe(B),completed:so.pipe(B)})}).annotate({identifier:`Session.Message.Assistant`}),Pd={type:_(`compaction`),...dd},Fd={cost:Zc.pipe(B),tokens:ld.pipe(B)},Id=C({...Pd,status:_(`running`),reason:y([`auto`,`manual`]),summary:x}).annotate({identifier:`Session.Message.Compaction.Running`}),Ld=C({...Pd,status:_(`completed`),reason:y([`auto`,`manual`]),model:il.pipe(B),native:fd.pipe(B),summary:x,...Fd}).annotate({identifier:`Session.Message.Compaction.Completed`}),Rd=C({...Pd,status:_(`failed`),reason:y([`auto`,`manual`]),error:sd,...Fd}).annotate({identifier:`Session.Message.Compaction.Failed`}),zd=E([Id,Ld,Rd]).pipe(ie(`status`),O({identifier:`Session.Message.Compaction`})),Bd=C({...dd,type:_(`idle`),outcome:y([`succeeded`,`failed`,`interrupted`]),error:sd.pipe(B)}).annotate({identifier:`Session.Message.Idle`}),Vd=E([pd,md,hd,gd,vd,yd,bd,xd,Nd,zd,Bd]).annotate({identifier:`Session.Message.Info`}),Hd=E([pd,md,hd,_d,vd,yd,bd,xd,Nd,zd,Bd]).annotate({identifier:`Session.Message.MediaInfo`}),Ud=C({file:x,patch:x,additions:z,deletions:z,status:y([`added`,`deleted`,`modified`]),more:h(!0).pipe(B)}).annotate({identifier:`FileDiff.Info`}),Wd=C({file:x.pipe(B),patch:x.pipe(B),additions:P,deletions:P,status:y([`added`,`deleted`,`modified`]).pipe(B)}).annotate({identifier:`FileDiff.LegacyInfo`}),Gd=C({messageID:K,partID:x.pipe(B),snapshot:cd.pipe(B),files:g(Ud).pipe(B)}).annotate({identifier:`Session.Revert`}),Kd=C({path:x,status:y([`added`,`modified`,`deleted`]),additions:P,deletions:P,patch:x}),qd=C({messageID:K,partID:x.pipe(B),snapshot:x.pipe(B),diff:x.pipe(B),files:g(Kd).pipe(B)}).annotate({identifier:`Session.RevertV1`}),Jd=Gd.pipe(wt(C({source:_(`current`),revert:ue(Gd)}),we({decode:e=>({source:`current`,revert:e}),encode:e=>e.revert}))),Yd=qd.pipe(wt(C({source:_(`legacy`),revert:ue(qd)}),we({decode:e=>({source:`legacy`,revert:e}),encode:e=>e.revert})));E([Jd,Yd]).pipe(ie(`source`),wt(ue(Gd),we({decode:e=>e.source===`current`?e.revert:Gd.make({messageID:e.revert.messageID,partID:e.revert.partID,snapshot:e.revert.snapshot?cd.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})})),O({identifier:`Session.Revert.Persisted`}));var Xd=x.check(Ce(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(M(`Instruction.Key`),O({identifier:`Instruction.Key`})),Zd=x.check(Ce(/^[a-f0-9]{64}$/u)).pipe(M(`Instruction.Hash`),O({identifier:`Instruction.Hash`})),Qd=S(Xd,Zd),$d=h(`removed`);$d.make(`removed`);var ef=S(x,E([Zd,$d])),tf=x.check(Ce(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({identifier:`InstructionEntry.Key`,description:`Instruction entry key (lowercase alphanumerics plus . _ -)`}),nf=C({key:tf,value:Te.annotate({description:`JSON value attached to the session's instructions`})}).annotate({identifier:`InstructionEntry.Info`}),rf=g(C({...nf.fields,removed:v})).annotate({identifier:`InstructionEntry.Snapshot`}),af=class extends t()(`InstructionEntryValueTooLargeError`,{actualBytes:a,maxBytes:a,message:x},{httpApiStatus:413}){},of=e({Compaction:()=>Sf,CompactionPayload:()=>df,Delivery:()=>sf,Info:()=>wf,Item:()=>_f,MediaInfo:()=>Tf,MediaUser:()=>bf,MediaUserPayload:()=>lf,Move:()=>Cf,MovePayload:()=>ff,SessionInbox:()=>of,Synthetic:()=>xf,SyntheticPayload:()=>uf,User:()=>yf,UserPayload:()=>cf}),sf=y([`steer`,`queue`]).annotate({identifier:`Session.Inbox.Delivery`}),cf=C({...wl.fields,metadata:S(x,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.UserPayload`}),lf=C({...cf.fields,files:g(xl).pipe(B)}).annotate({identifier:`Session.Inbox.MediaUserPayload`}),uf=C({text:x,description:x.pipe(B),metadata:S(x,Ie).pipe(B)}).annotate({identifier:`Session.Inbox.SyntheticPayload`}),df=C({}).annotate({identifier:`Session.Inbox.CompactionPayload`}),ff=C({location:vo,projectID:Pu,subpath:ro.pipe(B)}).annotate({identifier:`Session.Inbox.MovePayload`}),pf=C({type:_(`user`),payload:cf,delivery:sf}),mf=C({type:_(`synthetic`),payload:uf,delivery:sf}),hf=C({type:_(`compaction`),payload:df,delivery:sf}),gf=C({type:_(`move`),payload:ff,delivery:sf}),_f=E([pf,mf,hf,gf]).pipe(ie(`type`),O({identifier:`Session.Inbox.Item`})),vf={id:K,sessionID:pu,time:C({created:so})},yf=C({...vf,...pf.fields}).annotate({identifier:`Session.Inbox.User`}),bf=C({...yf.fields,payload:lf}).annotate({identifier:`Session.Inbox.MediaUser`}),xf=C({...vf,...mf.fields}).annotate({identifier:`Session.Inbox.Synthetic`}),Sf=C({...vf,...hf.fields}).annotate({identifier:`Session.Inbox.Compaction`}),Cf=C({...vf,...gf.fields}).annotate({identifier:`Session.Inbox.Move`}),wf=E([yf,xf,Sf,Cf]).pipe(ie(`type`),O({identifier:`Session.Inbox.Info`})),Tf=E([bf,xf,Sf,Cf]).pipe(ie(`type`),O({identifier:`Session.Inbox.MediaInfo`})),Ef=E([C({type:h(`before`),messageID:K}),C({type:h(`through`),messageID:K})]).annotate({identifier:`Session.ForkBoundary`}),Df=e({AgentSelected:()=>kf,All:()=>up,Archived:()=>If,Compaction:()=>ip,Created:()=>Of,Definitions:()=>op,Deleted:()=>Vf,Durable:()=>lp,DurableDefinitions:()=>sp,EphemeralDefinitions:()=>cp,Execution:()=>Jf,Forked:()=>Hf,InboxCancelled:()=>Kf,InboxDelivered:()=>Wf,InboxDeliveryChanged:()=>qf,InboxEnqueued:()=>Gf,InstructionsUpdated:()=>Yf,MessageContentUpdated:()=>Rf,MetadataUpdated:()=>Nf,ModelSelected:()=>Af,Moved:()=>jf,Permissions:()=>Pf,Reasoning:()=>tp,Renamed:()=>Mf,RetryScheduled:()=>rp,RevertEvent:()=>ap,SessionEvent:()=>Df,Shell:()=>Qf,Skill:()=>Zf,Step:()=>$f,Synthetic:()=>Xf,Text:()=>ep,Tool:()=>np,Unarchived:()=>Lf,UsageRecorded:()=>zf,UsageUpdated:()=>Bf,Viewed:()=>Ff}),q={sessionID:pu},J={durable:{aggregate:`sessionID`,version:1}},Of=H({type:`session.created`,...J,schema:{...q,projectID:Pu,location:vo,subpath:ro.pipe(B),parentID:pu.pipe(B),slug:x,title:x.pipe(B),agent:Ou.pipe(B),model:il.pipe(B),metadata:Ju.pipe(B),permissions:Tu.pipe(B),version:x}}),kf=H({type:`session.agent.selected`,...J,schema:{...q,agent:Ou,previous:Ou.pipe(B)}}),Af=H({type:`session.model.selected`,...J,schema:{...q,model:il,previous:il.pipe(B)}}),jf=H({type:`session.moved`,...J,schema:{...q,...ff.fields}}),Mf=H({type:`session.renamed`,...J,schema:{...q,title:x}}),Nf=H({type:`session.metadata.updated`,...J,schema:{...q,metadata:Ju}}),Pf=H({type:`session.permissions`,...J,schema:{...q,permissions:Tu}}),Ff=H({type:`session.viewed`,...J,schema:{...q,idle:P}}),If=H({type:`session.archived`,...J,schema:q}),Lf=H({type:`session.unarchived`,...J,schema:q}),Rf=H({type:`session.message.content.updated`,...J,schema:{...q,messageID:K,content:g(jd)}}),zf=H({type:`session.usage.recorded`,...J,schema:{...q,source:y([`title`,`compaction`]),cost:Zc,tokens:ld}}),Bf=U({type:`session.usage.updated`,schema:{...q,cost:Zc,tokens:ld}}),Vf=H({type:`session.deleted`,durable:{aggregate:`sessionID`,version:2},schema:q}),Hf=H({type:`session.forked`,durable:{aggregate:`sessionID`,version:2},schema:{...q,parentID:pu,boundary:Ef,instructions:Qd.pipe(B),instructionEntries:rf.pipe(B)}}),Uf={...q,inboxID:K},Wf=H({type:`session.inbox.delivered`,...J,schema:Uf}),Gf=H({type:`session.inbox.enqueued`,...J,schema:{...Uf,item:_f}}),Kf=H({type:`session.inbox.cancelled`,...J,schema:Uf}),qf=H({type:`session.inbox.delivery.changed`,...J,schema:{...Uf,delivery:sf}}),Jf;(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:sd}}),e.Interrupted=H({type:`session.execution.interrupted`,...J,schema:{...q,reason:y([`user`,`shutdown`,`superseded`,`inactivity`])}})})(Jf||={});var Yf=H({type:`session.instructions.updated`,durable:{aggregate:`sessionID`,version:2},schema:{...q,delta:ef,text:x.pipe(B)}}),Xf=H({type:`session.synthetic`,...J,schema:{...q,text:x,description:x.pipe(B),metadata:S(x,Ie).pipe(B)}}),Zf;(function(e){e.Activated=H({type:`session.skill.activated`,...J,schema:{...q,id:Mo,name:No,text:x}})})(Zf||={});var Qf;(function(e){e.Started=H({type:`session.shell.started`,...J,schema:{...q,shell:$u}}),e.Ended=H({type:`session.shell.ended`,...J,schema:{...q,shell:$u,output:od}})})(Qf||={});var $f;(function(e){e.Started=H({type:`session.step.started`,...J,schema:{...q,assistantMessageID:K,agent:Ou,model:il,snapshot:cd.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:Wu,rawFinish:x.pipe(B),native:fd.pipe(B),cost:Zc,tokens:ld,snapshot:cd.pipe(B),files:g(ro).pipe(B)}}),e.Failed=H({type:`session.step.failed`,...J,schema:{...q,assistantMessageID:K,error:sd,finish:y([`content-filter`]).pipe(B),rawFinish:x.pipe(B),native:fd.pipe(B),cost:Zc.pipe(B),tokens:ld.pipe(B),snapshot:cd.pipe(B),files:g(ro).pipe(B)}})})($f||={});var ep;(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:x}}),e.Ended=H({type:`session.text.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:x,native:fd.pipe(B)}})})(ep||={});var tp;(function(e){e.Started=H({type:`session.reasoning.started`,...J,schema:{...q,assistantMessageID:K,ordinal:z,native:fd.pipe(B)}}),e.Delta=U({type:`session.reasoning.delta`,schema:{...q,assistantMessageID:K,ordinal:z,delta:x}}),e.Ended=H({type:`session.reasoning.ended`,...J,schema:{...q,assistantMessageID:K,ordinal:z,text:x,native:fd.pipe(B)}})})(tp||={});var np;(function(e){let t={...q,assistantMessageID:K,id:x};(function(e){e.Started=H({type:`session.tool.input.started`,...J,schema:{...t,name:x}}),e.Delta=U({type:`session.tool.input.delta`,schema:{...t,delta:x}}),e.Ended=H({type:`session.tool.input.ended`,...J,schema:{...t,text:x}})})(e.Input||={}),e.Called=H({type:`session.tool.called`,...J,schema:{...t,input:S(x,Ie),executed:v,native:fd.pipe(B)}}),e.Progress=U({type:`session.tool.progress`,schema:{...t,metadata:S(x,Te)}}),e.Success=H({type:`session.tool.success`,durable:{aggregate:`sessionID`,version:2},schema:{...t,content:De(qu),metadata:S(x,Te).pipe(B),executed:v,native:fd.pipe(B)}}),e.Failed=H({type:`session.tool.failed`,durable:{aggregate:`sessionID`,version:2},schema:{...t,error:sd,content:De(qu).pipe(B),metadata:S(x,Te).pipe(B),executed:v,native:fd.pipe(B)}})})(np||={});var rp=H({type:`session.retry.scheduled`,...J,schema:{...q,assistantMessageID:K,attempt:no,at:z,error:sd}}),ip;(function(e){e.Started=H({type:`session.compaction.started`,...J,schema:{...q,reason:y([`auto`,`manual`]),inputID:K.pipe(B)}}),e.Delta=U({type:`session.compaction.delta`,schema:{...q,text:x}}),e.Ended=H({type:`session.compaction.ended`,...J,schema:{...q,reason:e.Started.data.fields.reason,model:Ld.fields.model,native:Ld.fields.native,text:x,cost:Ld.fields.cost,tokens:Ld.fields.tokens}}),e.Failed=H({type:`session.compaction.failed`,...J,schema:{...q,reason:e.Started.data.fields.reason,error:sd,inputID:K.pipe(B),cost:Rd.fields.cost,tokens:Rd.fields.tokens}})})(ip||={});var ap;(function(e){e.Staged=H({type:`session.revert.staged`,...J,schema:{...q,revert:Gd}}),e.Cleared=H({type:`session.revert.cleared`,...J,schema:q}),e.Committed=H({type:`session.revert.committed`,...J,schema:{...q,to:K}})})(ap||={});var op=W(Of,kf,Af,jf,Mf,Nf,Pf,Ff,If,Lf,Bf,Vf,Hf,Wf,Gf,Kf,qf,Jf.Started,Jf.Succeeded,Jf.Failed,Jf.Interrupted,Yf,Xf,Zf.Activated,Qf.Started,Qf.Ended,$f.Started,$f.Streamed,$f.Ended,$f.Failed,ep.Started,ep.Delta,ep.Ended,tp.Started,tp.Delta,tp.Ended,np.Input.Started,np.Input.Delta,np.Input.Ended,np.Called,np.Progress,np.Success,np.Failed,rp,ip.Started,ip.Delta,ip.Ended,ip.Failed,ap.Staged,ap.Cleared,ap.Committed),sp=W(...op.filter(e=>e.durability===`durable`),zf,Rf),cp=W(...op.filter(e=>e.durability===`ephemeral`)),lp=E(sp,{mode:`oneOf`}).annotate({identifier:`Session.Event.Durable`}).pipe(ie(`type`)),up=E([lp,...cp],{mode:`oneOf`}).pipe(ie(`type`)),dp=e({Event:()=>pp,ForkBoundary:()=>mp,ID:()=>Y,Info:()=>hp,ListAnchor:()=>gp,ListCursor:()=>Cp,ListFilter:()=>vp,Metadata:()=>fp,Revert:()=>Gd,Session:()=>dp}),Y=pu,fp=Ju,pp=Df,mp=Ef,hp=C({id:Y,parentID:Y.pipe(B),fork:C({sessionID:Y,boundary:mp}).pipe(B),projectID:Pu,agent:Ou.pipe(B),model:il.pipe(B),cost:Zc,tokens:ld,outcome:y([`succeeded`,`failed`,`interrupted`]).pipe(B),time:C({created:so,updated:so,idle:so.pipe(B),viewed:so.pipe(B),archived:so.pipe(B)}),title:x.pipe(B),location:vo,subpath:ro.pipe(B),metadata:fp.pipe(B),permissions:Tu.pipe(B),revert:Gd.pipe(B)}).annotate({identifier:`Session.Info`}),gp=C({id:Y,time:P,direction:y([`previous`,`next`])}).annotate({identifier:`Session.ListAnchor`}),_p={order:y([`asc`,`desc`]).pipe(i).annotate({description:`Session order for the first page. Use desc for newest first or asc for oldest first.`}),search:x.pipe(i),parentID:E([Y,te.pipe(Ze(h(`null`),{decode:m(()=>null),encode:m(()=>`null`)}))]).annotate({description:`Filter by parent session. Use null to return only root sessions.`}).pipe(i),archived:y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(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(i)},vp=C({..._p,directory:io.pipe(i),project:Pu.pipe(i),subpath:ro.pipe(i)}).annotate({identifier:`Session.ListFilter`}),yp=E([C({..._p,directory:io,anchor:gp}),C({..._p,project:Pu,subpath:ro.pipe(i),anchor:gp}),C({..._p,anchor:gp})]),bp=Ne(yp),xp=ct(bp),Sp=He(bp),Cp=x.pipe(M(`SessionsCursor`),O({identifier:`SessionsCursor`,description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.`}),oo(e=>{let t=ne(e);return{make:e=>t(oe(xp(e))),parse:e=>ht(()=>{let t=_t(e);return Me(t)?ut(`Invalid cursor`):Sp(t.success).pipe(w(()=>`Invalid cursor`))})}})),wp=C({...au.fields,sessionID:Y,foregroundProcess:se(x),size:C({cols:no,rows:no}),output:C({head:z,tail:z})}).annotate({identifier:`PersistentPty.Info`}),Tp=C({directory:x,instanceID:x,ticket:x,expiresAt:gt}).annotate({identifier:`PersistentPty.Handoff`}),Ep=C({command:B(x),args:g(x),cwd:B(x),title:x,env:S(x,x),size:B(C({cols:no,rows:no}))}).annotate({identifier:`PersistentPty.CreateInput`}),Dp=C({attachmentID:B(x),size:C({cols:no,rows:no})}).annotate({identifier:`PersistentPty.UpdateInput`}),Op=C({info:wp,text:x,checkpoint:dt,cursor:C({x:z,y:z})}).annotate({identifier:`PersistentPty.Snapshot`}),kp=no.check(xe(65535)).annotate({identifier:`PersistentPty.ReadLines`}),Ap=C({ptyID:iu,title:x,cwd:x,foregroundProcess:se(x),screen:C({text:x,cols:no,rows:no,cursor:Op.fields.cursor})}).annotate({identifier:`PersistentPty.ReadResult`}),jp=U({type:`persistent-pty.added`,schema:{sessionID:Y,terminal:wp}}),Mp=U({type:`persistent-pty.removed`,schema:{sessionID:Y,ptyID:iu}}),Np={Added:jp,Removed:Mp,Definitions:W(jp,Mp)},Pp=C({ticket:x,expires_in:no}).annotate({identifier:`PtyTicket.ConnectToken`}),X=C({location:i(C({directory:i(x)}))}).annotate({identifier:`LocationQuery`}),Z=k({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}}),Fp=e=>N(`server.location`).add(A(`location.get`,`/api/location`,{query:X,success:xo}).middleware(e).annotateMerge(Z).annotateMerge(k({identifier:`location.get`,summary:`Get location`,description:`Resolve the requested location or the server default location.`}))).add(D(`location.reload`,`/api/location/reload`,{success:T,error:Jo}).annotateMerge(k({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(k({title:`location`})),Ip=`ticket`,Lp=`x-opencode-ticket`,Rp=`/api/pty/:ptyID/connect`,zp=e=>N(`server.pty`).add(A(`pty.list`,`/api/pty`,{query:X,success:V(g(au))}).annotateMerge(Z).annotateMerge(k({identifier:`pty.list`,summary:`List PTY sessions`,description:`List PTY sessions for a location, including exited sessions retained until removal.`}))).add(D(`pty.create`,`/api/pty`,{query:X,payload:du,success:V(au)}).annotateMerge(Z).annotateMerge(k({identifier:`pty.create`,summary:`Create PTY session`,description:`Create a pseudo-terminal session for a location.`}))).add(A(`pty.get`,`/api/pty/:ptyID`,{params:{ptyID:iu},query:X,success:V(au),error:gs}).annotateMerge(Z).annotateMerge(k({identifier:`pty.get`,summary:`Get PTY session`,description:`Get one PTY session, including its exit code once exited.`}))).add(St(`pty.update`,`/api/pty/:ptyID`,{params:{ptyID:iu},query:X,payload:fu,success:V(au),error:gs}).annotateMerge(Z).annotateMerge(k({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:iu},query:X,success:T,error:gs}).annotateMerge(Z).annotateMerge(k({identifier:`pty.remove`,summary:`Remove PTY session`,description:`Terminate and remove one PTY session.`}))).add(D(`pty.connectToken`,`/api/pty/:ptyID/connect-token`,{params:{ptyID:iu},query:X,headers:C({[Lp]:i(x)}),success:V(Pp),error:[hs,gs]}).annotateMerge(Z).annotateMerge(k({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(A(`pty.connect`,Rp,{params:{ptyID:iu},success:v,error:[hs,gs,Vo]}).annotateMerge(k({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`,Ip].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(k({title:`pty`,description:`Experimental location-scoped PTY routes.`})),Bp=`/api/experimental/persistent-pty/:ptyID/connect`,Vp=[Ho,Jo],Hp=[gs,Jo],Up=N(`server.experimental`).add(A(`persistentPty.read`,`/api/experimental/session/:sessionID/terminal/read`,{params:{sessionID:Y},query:{lines:ae.pipe(wt(kp),i)},success:C({data:se(Ap)}),error:[Jo]}).annotateMerge(k({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(A(`persistentPty.list`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},success:C({data:g(wp)}),error:Vp})).add(D(`persistentPty.create`,`/api/experimental/session/:sessionID/terminal`,{params:{sessionID:Y},payload:Ep,success:C({data:wp}),error:Vp})).add(D(`persistentPty.shutdown`,`/api/experimental/persistent-pty/shutdown`,{success:T,error:[Jo]})).add(D(`persistentPty.handoff`,`/api/experimental/persistent-pty/handoff`,{success:C({handoff:se(Tp)}),error:[Jo]})).add(A(`persistentPty.get`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:iu},success:C({data:wp}),error:Hp})).add(St(`persistentPty.update`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:iu},payload:Dp,success:C({data:wp}),error:Hp})).add(A(`persistentPty.snapshot`,`/api/experimental/persistent-pty/:ptyID/snapshot`,{params:{ptyID:iu},success:C({data:Op}),error:Hp})).add(ft(`persistentPty.remove`,`/api/experimental/persistent-pty/:ptyID`,{params:{ptyID:iu},success:T,error:Hp})).add(D(`persistentPty.connectToken`,`/api/experimental/persistent-pty/:ptyID/connect-token`,{params:{ptyID:iu},headers:C({[Lp]:i(x)}),success:C({data:Pp}),error:[hs,gs,Jo]})).add(A(`persistentPty.connect`,Bp,{params:{ptyID:iu},success:v,error:[hs,gs,Jo]}).annotateMerge(k({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`,Ip].map(e=>({in:`query`,name:e,schema:{type:`string`}}))]})}))).annotateMerge(k({title:`persistentPty`,description:`Prototype persistent PTY routes.`})).add(nu),Wp=y([`webrtc`,`websocket`]).annotate({identifier:`VoiceTransportType`}),Gp=C({model:x,provider:x,transports:g(Wp),available:v}).annotate({identifier:`VoiceModel`}),Kp=C({type:h(`webrtc`),sdp:x,dcid:i(gt)}).annotate({identifier:`VoiceWebRTCTransportInput`}),qp=C({type:h(`websocket`)}).annotate({identifier:`VoiceWebSocketTransportInput`}),Jp=E([Kp,qp]).annotate({identifier:`VoiceTransportInput`}),Yp=C({type:h(`webrtc`),sdp:x}).annotate({identifier:`VoiceWebRTCTransport`}),Xp=C({type:h(`websocket`),url:x,token:x,expiresAt:gt}).annotate({identifier:`VoiceWebSocketTransport`}),Zp=E([Yp,Xp]).annotate({identifier:`VoiceTransport`}),Qp=N(`server.voice`).add(A(`voice.models`,`/api/experimental/voice/models`,{success:C({data:C({models:g(Gp),default:i(x)})}).annotate({identifier:`VoiceModelsResponse`}),error:[Jo,Vo]}).annotateMerge(k({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(D(`voice.session`,`/api/experimental/voice/session`,{payload:C({model:x,session:i(S(x,Ie)),transport:Jp}),success:C({data:C({transport:Zp})}).annotate({identifier:`VoiceSessionResponse`}),error:[Ho,Jo,Vo]}).annotateMerge(k({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(k({title:`voice`,description:`Experimental server-brokered voice session routes.`})),$p=C({limit:i(ae.check(jt(),Re(1),xe(200))).annotate({description:`Maximum number of messages to return. When omitted, the endpoint returns its default page size.`}),order:i(E([h(`asc`),h(`desc`)])).annotate({description:`Message order for the first page. Use desc for newest first or asc for oldest first.`}),cursor:i(x.annotate({description:`Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.`})),type:i(y(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`}),em=C({...o(hd.fields,[`location`,`previous`]),location:yo,previous:C({location:yo,projectID:hd.fields.projectID,subpath:hd.fields.subpath}).pipe(i)}).annotate({identifier:`Session.Message.LocationSwitched`}),tm=E([pd,md,em,gd,vd,yd,bd,xd,Nd,zd,Bd]).annotate({identifier:`Session.Message.Info`}),nm=E([pd,md,em,_d,vd,yd,bd,xd,Nd,zd,Bd]).annotate({identifier:`Session.Message.MediaInfo`}),rm=C({previous:x.pipe(i),next:x.pipe(i)});C({data:g(nm),cursor:rm}),C({data:nm});var im=N(`server.message`).add(A(`session.messages`,`/api/session/:sessionID/message`,{params:{sessionID:Y},query:$p,success:C({data:g(tm),cursor:rm}).annotate({identifier:`SessionMessagesResponse`}),error:[ls,G,Yo]}).annotateMerge(k({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(k({title:`session`,description:`Experimental message routes.`})),am=C({...X.fields,types:i(de(ol)).annotate({description:`Only list models of these types. Defaults to chat, the only type offered for sessions.`})}),om=N(`server.model`).add(A(`model.list`,`/api/model`,{query:am,success:V(g(fl)),error:Jo}).annotateMerge(Z).annotateMerge(k({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(A(`model.default`,`/api/model/default`,{query:X,success:V(yt(fl)),error:Jo}).annotateMerge(Z).annotateMerge(k({identifier:`model.default`,summary:`Get default model`,description:`Retrieve the model used when a session has no explicit model selection.`}))).annotateMerge(k({title:`model`,description:`Experimental model routes.`})),sm=N(`server.provider`).add(A(`provider.list`,`/api/provider`,{query:X,success:V(g(Xc)),error:Jo}).annotateMerge(Z).annotateMerge(k({identifier:`provider.list`,summary:`List providers`,description:`Retrieve active AI providers so clients can show provider availability and configuration.`}))).add(A(`provider.get`,`/api/provider/:providerID`,{params:{providerID:Ic},query:X,success:V(Xc),error:[Xo,Jo]}).annotateMerge(Z).annotateMerge(k({identifier:`provider.get`,summary:`Get provider`,description:`Retrieve a single AI provider so clients can inspect its availability and endpoint settings.`}))).annotateMerge(k({title:`provider`,description:`Experimental provider routes.`})),cm=e({FileAttachment:()=>lm,Prompt:()=>dm,PromptInput:()=>cm,SkillAttachment:()=>um}),lm=C({uri:x,name:x.pipe(B),description:x.pipe(B),mention:pl.pipe(B)}).annotate({identifier:`PromptInput.FileAttachment`}),um=C({id:Mo,mention:pl.pipe(B)}).annotate({identifier:`PromptInput.SkillAttachment`}),dm=C({text:x,files:g(lm).pipe(B),agents:g(Sl).pipe(B),skills:g(um).pipe(B)}).annotate({identifier:`PromptInput`}),fm=C({date:x,steps:z}).annotate({identifier:`SessionStats.Activity`}),pm=C({model:il,steps:z,tokens:ld,cost:Zc}).annotate({identifier:`SessionStats.ModelUsage`}),mm=C({name:x,calls:z,succeeded:z,failed:z,unfinished:z,durationP50:P.pipe(B)}).annotate({identifier:`SessionStats.ToolUsage`}),hm=y([`none`,`summary`,`detail`]),gm=C({calls:z,succeeded:z,failed:z,unfinished:z}).annotate({identifier:`SessionStats.ToolTotals`}),_m=E([C({mode:h(`none`)}),C({mode:h(`summary`),totals:gm}),C({mode:h(`detail`),totals:gm,usage:g(mm)})]).annotate({identifier:`SessionStats.Tools`}),vm=C({range:C({from:so,to:so}),sessions:z,subagents:z,prompts:z,steps:z,tokens:ld,cost:Zc,tools:_m,activeDays:z,streak:z,activity:g(fm),models:g(pm)}).annotate({identifier:`SessionStats.Info`});function ym(e,t){return e===`assistant`?xm(Om(t,`providerState`,`native`)):e===`compaction`?wm(Cm(Om(t,`providerState`,`native`))):t}function bm(e){return e.map(e=>km(e)?ym(e.type,e):e)}function xm(e){return Array.isArray(e.content)?{...e,content:e.content.map(Sm)}:e}function Sm(e){return km(e)?e.type===`text`||e.type===`reasoning`?Om(e,`state`,`native`):e.type===`tool`?Dm(Om(e,`providerState`,`native`)):e:e}function Cm(e){let t=e.recent,n=Em(e,`recent`);if(typeof t!=`string`||!t)return n;let r=km(n.metadata)?n.metadata:{};return{...n,metadata:{recent:t,...r}}}function wm(e){let t=e.providerContext,n=Em(e,`providerContext`);return km(t)?{...n,native:{messages:Array.isArray(t.messages)?t.messages.map(Tm):t.messages}}:n}function Tm(e){return!km(e)||!Array.isArray(e.content)?e:{...e,content:e.content.map(e=>{if(!km(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 Em(e,t){if(!(t in e))return e;let{[t]:n,...r}=e;return r}function Dm(e){if(!(`providerResultState`in e))return e;let{providerResultState:t,...n}=e;return km(t)?{...n,native:{...km(n.native)?n.native:{},...t}}:n}function Om(e,t,n){if(!(t in e))return e;let{[t]:r,...i}=e;return n in i?i:{...i,[n]:r}}function km(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Am=e({EventLog:()=>Am,Synced:()=>jm}),jm=C({type:h(`log.synced`),aggregateID:x,seq:B(wo)}).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.`}),Mm=C({type:h(`running`)}).annotate({identifier:`SessionActive`}),Nm=C({...o(hp.fields,[`location`]),location:yo}).annotate({identifier:`Session.Info`}),Pm=C({info:Nm,messages:g(tm)}).annotate({identifier:`SessionTransfer.Data`}),Fm=C({...o(ff.fields,[`location`]),location:yo}).annotate({identifier:`Session.Inbox.MovePayload`}),Im=C({...o(Cf.fields,[`payload`]),payload:Fm}).annotate({identifier:`Session.Inbox.Move`}),Lm=E([yf,xf,Sf,Im]).annotate({identifier:`Session.Inbox.Info`});C({data:g(E([bf,xf,Sf,Im]).annotate({identifier:`Session.Inbox.MediaInfo`}))});var Rm=g(Te).pipe(wt(g(Ie),{decode:m(bm),encode:b({strict:!1})}),wt(g(tm),{decode:b({strict:!1}),encode:b({strict:!1})})),zm=C({id:Bs.pipe(i),title:ec.fields.title,metadata:ec.fields.metadata,fields:ec.fields.fields}).annotate({identifier:`Form.CreatePayload`}),Bm=y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})),Vm=C({limit:ae.pipe(wt(no),i).annotate({description:`Maximum number of sessions to return. Defaults to the newest 50 sessions.`}),...vp.fields,cursor:Cp.pipe(i)}).annotate({identifier:`SessionsQuery`}),Hm=(e,t)=>N(`server.session`).add(A(`session.list`,`/api/session`,{query:Vm,success:C({data:g(Nm),cursor:C({previous:Cp.pipe(i),next:Cp.pipe(i)})}).annotate({identifier:`SessionsResponse`}),error:[ls,Ho]}).annotateMerge(k({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(A(`session.stats`,`/api/experimental/session/stats`,{query:C({from:ae.pipe(i),to:ae.pipe(i),project:Pu.pipe(i),timezone:x.pipe(i),tools:hm.pipe(i)}),success:C({data:vm}),error:Ho}).annotateMerge(k({identifier:`experimental.session.stats`,summary:`Get session statistics`,description:`Aggregate local session activity, usage, and tool reliability for a time range.`}))).add(D(`session.create`,`/api/session`,{payload:C({id:Y.pipe(i),parentID:Y.pipe(i),title:x.pipe(i),agent:Ou.pipe(i),model:il.pipe(i),location:yo.pipe(i),metadata:fp.pipe(i),permissions:Tu.pipe(i)}),success:C({data:Nm}),error:G}).annotateMerge(k({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(D(`session.import`,`/api/experimental/session/import`,{payload:C({info:Pm.fields.info,messages:Rm,location:yo.pipe(i)}),success:C({data:Nm}),error:[Ko,G]}).annotateMerge(k({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(A(`session.export`,`/api/experimental/session/:sessionID/export`,{params:{sessionID:Y},query:C({sanitize:Bm.pipe(i)}),success:C({data:Pm}),error:[G,Yo]}).annotateMerge(k({identifier:`experimental.session.export`,summary:`Export session`,description:`Export a complete projected session transcript.`}))).add(A(`session.active`,`/api/session/active`,{success:C({data:S(Y,Mm)})}).annotateMerge(k({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(A(`session.get`,`/api/session/:sessionID`,{params:{sessionID:Y},success:C({data:Nm}),error:G}).annotateMerge(k({identifier:`session.get`,summary:`Get session`,description:`Retrieve a session by ID.`}))).add(ft(`session.remove`,`/api/session/:sessionID`,{params:{sessionID:Y},success:T,error:G}).annotateMerge(k({identifier:`session.remove`,summary:`Delete session`,description:`Delete a session and its child sessions.`}))).add(D(`session.fork`,`/api/session/:sessionID/fork`,{params:{sessionID:Y},payload:C({before:K.pipe(i)}),success:C({data:Nm}),error:[G,is,Ho]}).annotateMerge(k({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(D(`session.switchAgent`,`/api/session/:sessionID/agent`,{params:{sessionID:Y},payload:C({agent:Ou}),success:T,error:G}).annotateMerge(k({identifier:`session.switchAgent`,summary:`Switch session agent`,description:`Switch the agent used by subsequent provider turns.`}))).add(D(`session.switchModel`,`/api/session/:sessionID/model`,{params:{sessionID:Y},payload:C({model:il}),success:T,error:G}).annotateMerge(k({identifier:`session.switchModel`,summary:`Switch session model`,description:`Switch the model used by subsequent provider turns.`}))).add(ze(`session.update`,`/api/session/:sessionID`,{params:{sessionID:Y},payload:C({title:x.pipe(i),metadata:fp.pipe(i),permissions:Tu.pipe(i),archived:v.pipe(i).annotate({description:`Archive the session with true or restore it with false. Repeating the current state is a no-op.`})}),success:T,error:[G,Vo]}).annotateMerge(k({identifier:`session.update`,summary:`Update session`,description:`Update mutable session properties.`}))).add(D(`session.move`,`/api/session/:sessionID/move`,{params:{sessionID:Y},payload:C({...yo.fields,delivery:sf.pipe(i)}),success:T,error:[G,Ho]}).annotateMerge(k({identifier:`session.move`,summary:`Move session`,description:`Move a session to another project directory at the requested delivery boundary.`}))).add(D(`session.prompt`,`/api/session/:sessionID/prompt`,{params:{sessionID:Y},payload:C({id:K.pipe(i),...dm.fields,metadata:cf.fields.metadata,delivery:sf.pipe(i),resume:v.pipe(i)}),success:C({data:yf}),error:[Ko,Ho,G]}).middleware(e).annotateMerge(k({identifier:`session.prompt`,summary:`Send message`,description:`Durably admit one session input and schedule agent-loop execution unless resume is false.`}))).add(D(`session.command`,`/api/session/:sessionID/command`,{params:{sessionID:Y},payload:C({name:x,...dm.fields,delivery:sf.pipe(i)}),success:T,error:[G,ss,cs]}).middleware(e).annotateMerge(k({identifier:`session.command`,summary:`Run command`,description:`Execute a slash command callback immediately.`}))).add(D(`session.skill`,`/api/experimental/session/:sessionID/skill`,{params:{sessionID:Y},payload:C({id:Mo,resume:v.pipe(i)}),success:T,error:[G,as]}).middleware(e).annotateMerge(k({identifier:`experimental.session.skill`,summary:`Activate skill`,description:`Activate a skill for a session by appending a skill message and resuming execution.`}))).add(D(`session.synthetic`,`/api/session/:sessionID/synthetic`,{params:{sessionID:Y},payload:C({id:K.pipe(i),text:x,description:x.pipe(i),metadata:vd.fields.metadata,delivery:sf.pipe(i),resume:v.pipe(i)}),success:C({data:xf}),error:[Ko,G]}).middleware(e).annotateMerge(k({identifier:`session.synthetic`,summary:`Add synthetic message`,description:`Durably admit synthetic session input and schedule execution unless resume is false.`}))).add(D(`session.shell`,`/api/session/:sessionID/shell`,{params:{sessionID:Y},payload:C({id:K.pipe(i),command:x}),success:T,error:G}).middleware(e).annotateMerge(k({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(D(`session.compact`,`/api/session/:sessionID/compact`,{params:{sessionID:Y},payload:C({id:K.pipe(i),delivery:sf.pipe(i)}),success:C({data:Sf}),error:[Ko,G]}).middleware(e).annotateMerge(k({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(D(`session.wait`,`/api/experimental/session/:sessionID/wait`,{params:{sessionID:Y},success:T,error:[G,Jo]}).annotateMerge(k({identifier:`experimental.session.wait`,summary:`Wait for session`,description:`Wait for a session agent loop to become idle.`}))).add(D(`session.revert.stage`,`/api/session/:sessionID/revert/stage`,{params:{sessionID:Y},payload:C({messageID:K,files:v.pipe(i)}),success:C({data:Gd}),error:[is,G,qo,Yo]}).middleware(e).annotateMerge(k({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:T,error:[G,qo,Yo]}).middleware(e).annotateMerge(k({identifier:`session.revert.clear`,summary:`Clear staged revert`}))).add(D(`session.revert.commit`,`/api/session/:sessionID/revert/commit`,{params:{sessionID:Y},success:T,error:[G,qo]}).annotateMerge(k({identifier:`session.revert.commit`,summary:`Commit staged revert`}))).add(A(`session.context`,`/api/session/:sessionID/context`,{params:{sessionID:Y},success:C({data:g(tm)}),error:[G,Yo]}).annotateMerge(k({identifier:`session.context`,summary:`Get session context`,description:`Retrieve the active context messages for a session (all messages after the last compaction).`}))).add(A(`session.diff`,`/api/session/:sessionID/diff`,{params:{sessionID:Y},query:C({from:i(K).annotate({description:`User message whose turn to diff. Defaults to the turn of the newest user message.`}),to:i(K).annotate({description:"Later user message whose turn ends the range. Defaults to the turn of `from` alone."}),context:ae.pipe(wt(z),i).annotate({description:`Unchanged lines around each hunk. Omit for full-file patches.`})}),success:C({data:g(Ud)}),error:[Ho,is,G,Yo,Vo]}).annotateMerge(k({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(A(`session.inbox.list`,`/api/session/:sessionID/inbox`,{params:{sessionID:Y},success:C({data:g(Lm)}),error:G}).annotateMerge(k({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:T,error:G}).annotateMerge(k({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(ze(`session.inbox.update`,`/api/session/:sessionID/inbox/:inboxID`,{params:{sessionID:Y,inboxID:K},payload:C({delivery:sf}),success:T,error:[Ko,G]}).annotateMerge(k({identifier:`session.inbox.update`,summary:`Update inbox item`,description:`Change a pending inbox item's delivery mode. Steering wakes session execution.`}))).add(A(`session.instructions.entry.list`,`/api/experimental/session/:sessionID/instructions/entries`,{params:{sessionID:Y},success:C({data:g(nf)}),error:G}).annotateMerge(k({identifier:`experimental.session.instructions.entry.list`,summary:`List instruction entries`,description:`List API-managed instruction entries attached to the session.`}))).add(St(`session.instructions.entry.put`,`/api/experimental/session/:sessionID/instructions/entries/:key`,{params:{sessionID:Y,key:tf},payload:C({value:Te}),success:T,error:[G,af]}).annotateMerge(k({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:tf},success:T,error:G}).annotateMerge(k({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(D(`session.generate`,`/api/session/:sessionID/generate`,{params:{sessionID:Y},payload:C({prompt:x}),success:C({data:C({text:x})}).annotate({identifier:`SessionGenerateResponse`}),error:[G,Jo]}).middleware(e).annotateMerge(k({identifier:`session.generate`,summary:`Generate text from session context`,description:`Generate transient text from the current session context without mutating session history.`}))).add(A(`session.log`,`/api/experimental/session/:sessionID/log`,{params:{sessionID:Y},query:{after:ae.pipe(wt(wo),i),follow:Bm.pipe(i)},success:Ge({data:E([lp,jm]).annotate({identifier:`SessionLogItem`})}),error:G}).annotateMerge(k({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(D(`session.interrupt`,`/api/session/:sessionID/interrupt`,{params:{sessionID:Y},query:{resume:Bm.pipe(i)},success:C({interrupted:v.annotate({description:`Whether an active execution owned by this OpenCode process was interrupted.`})}).annotate({identifier:`SessionInterruptResponse`}),error:G}).annotateMerge(k({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(D(`session.background`,`/api/session/:sessionID/background`,{params:{sessionID:Y},success:T,error:G}).annotateMerge(k({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(A(`session.message`,`/api/session/:sessionID/message/:messageID`,{params:{sessionID:Y,messageID:K},success:C({data:tm}),error:[G,is]}).annotateMerge(k({identifier:`session.message.get`,summary:`Get session message`,description:`Retrieve one projected message owned by the Session.`}))).add(A(`session.form.list`,`/api/session/:sessionID/form`,{params:{sessionID:x},success:C({data:g(ec)}),error:G}).middleware(t).annotateMerge(k({identifier:`session.form.list`,summary:`List session forms`,description:`Retrieve pending forms for a session.`}))).add(D(`session.form.create`,`/api/session/:sessionID/form`,{params:{sessionID:x},payload:zm,success:C({data:ec}),error:[G,Ko,Ho]}).middleware(t).annotateMerge(k({identifier:`session.form.create`,summary:`Create session form`,description:`Create a form for a session.`}))).add(A(`session.form.get`,`/api/session/:sessionID/form/:formID`,{params:{sessionID:x,formID:Bs},success:C({data:ic}),error:[G,fs]}).middleware(t).annotateMerge(k({identifier:`session.form.get`,summary:`Get session form`,description:`Retrieve a form and its current state for a session.`}))).add(D(`session.form.reply`,`/api/session/:sessionID/form/:formID/reply`,{params:{sessionID:x,formID:Bs},payload:ac,success:T,error:[G,ps,ms,fs]}).middleware(t).annotateMerge(k({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:x,formID:Bs},query:C({message:i(x)}),success:T,error:[G,ps,fs]}).middleware(t).annotateMerge(k({identifier:`session.form.cancel`,summary:`Cancel form`,description:`Cancel a pending form, optionally telling the asker why it was not answered.`}))).add(St(`session.environment`,`/api/session/:sessionID/environment`,{params:{sessionID:Y},payload:C({variables:S(x,x)}),success:T,error:G}).annotateMerge(k({identifier:`session.environment`,summary:`Set session environment`,description:`Replace the process environment used by local shell commands for this session.`}))).add(D(`session.view`,`/api/session/:sessionID/view`,{params:{sessionID:Y},payload:C({idle:so}),success:T,error:G}).annotateMerge(k({identifier:`session.view`,summary:`View session`,description:`Mark the idle transition observed by the viewer as viewed.`}))).annotateMerge(k({title:`session`,description:`Experimental session routes.`})),Um=e({ID:()=>Wm,Info:()=>Gm,PermissionSaved:()=>Um}),Wm=x.pipe(M(`PermissionSaved.ID`),O({identifier:`PermissionSaved.ID`}),oo(e=>({create:()=>e.make(`psv_`+fo())}))),Gm=C({id:Wm,projectID:ho,action:x,resource:x,time:C({created:so,updated:so})}).annotate({identifier:`PermissionSaved.Info`}),Km=(e,t)=>N(`server.permission`).add(A(`permission.request.list`,`/api/permission/request`,{query:X,success:V(g(vu))}).middleware(e).annotateMerge(Z).annotateMerge(k({identifier:`permission.request.list`,summary:`List pending permission requests`,description:`Retrieve pending permission requests for a location.`}))).add(A(`permission.saved.list`,`/api/permission/saved`,{query:C({projectID:Pu.pipe(i)}),success:C({data:g(Gm)})}).middleware(e).annotateMerge(k({identifier:`permission.saved.list`,summary:`List saved permissions`,description:`Retrieve saved permissions, optionally filtered by project.`}))).add(ze(`permission.saved.update`,`/api/permission/saved/:id`,{params:{id:Wm},payload:C({action:x.pipe(i),resource:x.pipe(i)}),success:C({data:Gm}),error:[ds,Ko]}).annotateMerge(k({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:Wm},success:T}).annotateMerge(k({identifier:`permission.saved.remove`,summary:`Remove saved permission`,description:`Remove a saved permission by ID.`}))).add(D(`session.permission.create`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},payload:C({id:hu.pipe(i),action:vu.fields.action,resources:vu.fields.resources,save:vu.fields.save,metadata:vu.fields.metadata,source:vu.fields.source,agent:Ou.pipe(i)}),success:C({data:C({id:hu,effect:Cu})}),error:G}).middleware(t).annotateMerge(k({identifier:`session.permission.create`,summary:`Create permission request`,description:`Evaluate and, when approval is required, create a permission request for a session.`}))).add(A(`session.permission.list`,`/api/session/:sessionID/permission`,{params:{sessionID:Y},success:C({data:g(vu)}),error:[G,Vo]}).annotateMerge(k({identifier:`session.permission.list`,summary:`List session permission requests`,description:`Retrieve pending permission requests owned by a session.`}))).add(A(`session.permission.get`,`/api/session/:sessionID/permission/:requestID`,{params:{sessionID:Y,requestID:hu},success:C({data:vu}),error:[G,us]}).middleware(t).annotateMerge(k({identifier:`session.permission.get`,summary:`Get permission request`,description:`Retrieve a pending permission request owned by a session.`}))).add(D(`session.permission.reply`,`/api/session/:sessionID/permission/:requestID/reply`,{params:{sessionID:Y,requestID:hu},payload:C({decision:yu,message:x.pipe(i)}),success:T,error:[G,us]}).middleware(t).annotateMerge(k({identifier:`session.permission.reply`,summary:`Reply to pending permission request`,description:`Respond to a pending permission request owned by a session.`}))).annotateMerge(k({title:`permission`,description:`Experimental permission routes.`})),qm=e({Entry:()=>Xm,Event:()=>Ym,FileSystem:()=>qm,FindInput:()=>$m,Match:()=>Qm,Submatch:()=>Zm,Write:()=>eh}),Jm=U({type:`filesystem.changed`,schema:{file:x,event:y([`add`,`change`,`unlink`])}}),Ym={Changed:Jm,Definitions:W(Jm)},Xm=C({path:ro,type:y([`file`,`directory`])}).annotate({identifier:`FileSystem.Entry`}),Zm=C({text:x,start:z,end:z}).annotate({identifier:`FileSystem.Submatch`}),Qm=C({entry:Xm,line:no,offset:z,text:x,submatches:g(Zm)}).annotate({identifier:`FileSystem.Match`}),$m=class extends p(`FileSystem.FindInput`)({query:x,type:y([`file`,`directory`]).pipe(B),limit:no.pipe(B)}){},eh=C({path:io}).annotate({identifier:`FileSystem.Write`}),th=C({...X.fields,path:x.pipe(i).annotate({description:`An absolute path or a path relative to the requested location. Defaults to the location directory.`})}),nh=C({...X.fields,path:x.annotate({description:`An absolute path or a path relative to the requested location. Missing parent directories are created.`})}),rh=C({path:x.annotate({description:`A file path relative to the requested location.`})}),ih=C({...X.fields,query:$m.fields.query,type:$m.fields.type,limit:ae.pipe(wt(no),i)}),ah=N(`server.fs`).add(A(`fs.read`,`/api/fs/read/*`,{query:X,success:dt.pipe(mt()),error:ts}).annotateMerge(Z).annotateMerge(k({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(A(`fs.list`,`/api/fs/list`,{query:th,success:V(g(Xm)),error:ts}).annotateMerge(Z).annotateMerge(k({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(A(`fs.find`,`/api/fs/find`,{query:ih,success:V(g(Xm))}).annotateMerge(Z).annotateMerge(k({identifier:`fs.find`,summary:`Find files`,description:`Find recursively ranked filesystem entries relative to the requested location.`}))).add(D(`fs.write`,`/api/experimental/fs/write`,{query:nh,payload:dt.pipe(mt()),success:V(eh)}).annotateMerge(Z).annotateMerge(k({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(D(`fs.watch`,`/api/experimental/fs/watch`,{query:X,payload:rh,success:T,error:[ts,Jo]}).annotateMerge(Z).annotateMerge(k({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:rh,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.fs.unwatch`,summary:`Unwatch file`,description:`Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.`}))).annotateMerge(k({title:`filesystem`,description:`Experimental location-scoped filesystem routes.`})),oh=e=>N(`server.form`).add(A(`form.list`,`/api/form`,{query:X,success:V(g(ec))}).annotateMerge(Z).annotateMerge(k({identifier:`form.list`,summary:`List pending forms`,description:`Retrieve pending forms for a location.`}))).middleware(e).annotateMerge(k({title:`form`,description:`Location form routes.`})),sh=e({Command:()=>sh,Event:()=>uh,Info:()=>lh}),ch=U({type:`command.updated`,schema:{}}),lh=C({name:x,description:x.pipe(B)}).annotate({identifier:`Command.Info`}),uh={Updated:ch,Definitions:W(ch)},dh=N(`server.command`).add(A(`command.list`,`/api/command`,{query:X,success:V(g(lh))}).annotateMerge(Z).annotateMerge(k({identifier:`command.list`,summary:`List commands`,description:`Retrieve currently registered commands.`}))).annotateMerge(k({title:`command`,description:`Experimental command routes.`})),fh=N(`server.skill`).add(A(`skill.list`,`/api/skill`,{query:X,success:V(g(Io))}).annotateMerge(Z).annotateMerge(k({identifier:`skill.list`,summary:`List skills`,description:`Retrieve currently registered skills.`}))).annotateMerge(k({title:`skill`,description:`Experimental skill routes.`})),ph=C({input:B(Ie)}).annotate({identifier:`Rpc.Input`}),mh=C({output:tt(Ie)}).annotate({identifier:`Rpc.Output`}),hh=N(`server.rpc`).add(D(`rpc.call`,`/api/rpc/:rpcID/:method`,{params:{rpcID:x,method:x},query:X,payload:ph,success:mh,error:[Uo,Wo]}).annotateMerge(Z).annotateMerge(k({identifier:`rpc.call`,summary:`Call a plugin RPC`,description:`Dispatch a method to the currently registered RPC at the requested location.`}))).annotateMerge(k({title:`rpc`,description:`Plugin RPC routes.`})),gh=Ic.check(Ce(/^[^/#]+$/u)),_h=el.check(Ce(/^[^#]+$/u)),vh=rl.check(Ce(/^[^#]+$/u)),yh=C({providerID:gh,model:_h,variant:vh.pipe(B)}),bh=x.check(Ce(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u)),xh=E([bh,yh]).pipe(wt(yh,{decode:m(e=>typeof e==`string`?Sh(e):e),encode:b({strict:!1})})).annotate({identifier:`Config.ModelSelection`});function Sh(e){let t=il.parse(e);return{providerID:t.providerID,model:t.id,...t.variant?{variant:t.variant}:{}}}var Ch=ge(C(qc.schema.fields),[S(x,yt(Te))]).annotate({identifier:`Config.Provider.Settings`}),wh=ge(C(sl.schema.fields),[S(x,yt(Te))]).annotate({identifier:`Config.Model.Settings`}),Th=S(x,Te),Eh={settings:Ch.pipe(B),headers:S(x,x).pipe(B),body:Th.pipe(B)},Dh={settings:wh.pipe(B),headers:S(x,x).pipe(B),body:Th.pipe(B)},Oh=class extends p(`Config.Provider.Request`)({headers:Eh.headers,body:Eh.body}){},kh=class extends p(`Config.Model.Cost.Cache`)({read:Qc.pipe(B),write:Qc.pipe(B)}){},Ah=class extends p(`Config.Model.Cost`)({tier:C({type:h(`context`),size:a}).pipe(B),input:Qc,output:Qc,cache:kh.pipe(B)}){},jh=class extends p(`Config.Model.Limit`)({context:a.pipe(B),input:a.pipe(B),output:a.pipe(B)}){},Mh=E([C({supported:h(!1)}),C({supported:h(!0),toggle:v.pipe(B),effort:x.pipe(g,B),budget:C({min:a.pipe(B),max:a.pipe(B)}).pipe(B)})]).annotate({identifier:`Config.Model.Reasoning`}),Nh=class extends p(`Config.Model`)({modelID:el.pipe(B),type:ol.pipe(B),family:al.pipe(B),name:x.pipe(B),releaseDate:x.check(Ce(/^\d{4}-\d{2}(-\d{2})?$/u)).annotate({description:`Release date as YYYY-MM-DD or YYYY-MM`}).pipe(B),compatibility:Nc.pipe(B),package:x.pipe(B),...Dh,capabilities:ll.mapFields(e=>({tools:B(e.tools),input:B(e.input),output:B(e.output),temperature:e.temperature,reasoning:Mh.pipe(B)})).annotate({identifier:`Config.Model.Capabilities`}).pipe(B),variants:C({id:rl,...Dh}).pipe(g,B),cost:E([Ah,Ah.pipe(g)]).pipe(B),disabled:v.pipe(B),limit:jh.pipe(B)}){},Ph=class extends p(`Config.Provider`)({canonical:Ic.pipe(B),name:x.pipe(B),env:x.pipe(g,B),package:x.pipe(B),compatibility:Pc.pipe(B),...Eh,models:S(x,Nh).pipe(B)}){},Fh=x.check(Ce(/^#[0-9a-fA-F]{6}$/u)),Ih=class extends p(`Config.Agent`)({model:xh.pipe(B),request:Oh.pipe(B),system:x.pipe(B),description:x.pipe(B),mode:y([`subagent`,`primary`,`all`]).pipe(B),hidden:v.pipe(B),color:Fh.pipe(Be(()=>Ke),B),steps:no.pipe(B),disabled:v.pipe(B),permissions:Tu.pipe(B)}){},Lh=class extends p(`Config.Media.Image`)({auto_resize:v.pipe(B),max_width:no.pipe(B),max_height:no.pipe(B),max_base64_bytes:no.pipe(B)}){},Rh=class extends p(`Config.Media`)({image:Lh.pipe(B)}){},zh=class extends p(`Config.Compaction.Keep`)({tokens:z.pipe(B)}){},Bh=class extends p(`Config.Compaction`)({auto:v.pipe(B),keep:zh.pipe(B),buffer:z.pipe(B)}){},Vh=class extends p(`Config.Command`)({template:x,description:x.pipe(B),agent:x.pipe(B),model:xh.pipe(B),subagent:v.pipe(B),subtask:v.annotate({description:`Deprecated alias for subagent.`}).pipe(B)}){},Hh=y([`allow`,`deny`]),Uh=C({action:y([`provider.use`,`tool.use`,`integration.use`]),resource:x,effect:Hh}),Wh=class extends p(`ConfigExperimental.Info`)({portable_shell_scanner:v.pipe(B).annotate({description:`Enable the experimental portable shell permission scanner. Defaults to false.`}),todo:v.pipe(B).annotate({description:`Enable the experimental todowrite tool. Defaults to false.`}),background_compaction:v.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:v.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:E([ve,h(!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:Uh.pipe(g,B).annotate({description:`Deprecated: use top-level policies. Ordered policies controlling access to configured resources`})}){},Gh=class extends p(`Config.Formatter.Entry`)({disabled:v.pipe(B),command:x.pipe(g,B),environment:S(x,x).pipe(B),extensions:x.pipe(g,B)}){},Kh=E([v,S(x,Gh)]),qh=C({disabled:h(!0)}),Jh=class extends p(`Config.LSP.Server`)({command:x.pipe(g),extensions:x.pipe(g,B),disabled:v.pipe(B),env:S(x,x).pipe(B),initialization:S(x,Ie).pipe(B)}){},Yh=E([qh,Jh]),Xh=E([v,S(x,Yh)]),Zh=class extends p(`Mcp.TimeoutConfig`)({startup:no.pipe(B).annotate({description:`Maximum time in milliseconds to establish and initialize the MCP server.`}),catalog:no.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.`}),execution:no.pipe(B).annotate({description:`Maximum time in milliseconds to wait for MCP tool and prompt execution.`})}){},Qh=y([`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.`}),$h=class extends p(`Mcp.LocalConfig`)({type:h(`local`),command:x.pipe(g),cwd:x.pipe(B).annotate({description:`Working directory for the MCP server process. Relative paths resolve from the workspace directory.`}),environment:S(x,x).pipe(B),disabled:v.pipe(B),codemode:v.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Zh.pipe(B),protocol:Qh.pipe(B)}){},eg=class extends p(`Mcp.OAuthConfig`)({client_id:x.pipe(B),client_secret:x.pipe(B),scope:x.pipe(B),callback_port:a.check(Dt({minimum:1,maximum:65535})).pipe(B),redirect_uri:x.pipe(B),auth_server_metadata_url:x.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.`})}){},tg=class extends p(`Mcp.RemoteConfig`)({type:h(`remote`),url:x,headers:S(x,x).pipe(B),oauth:E([eg,h(!1)]).pipe(B),disabled:v.pipe(B),codemode:v.pipe(B).annotate({description:`Expose this server's tools through Code Mode. Defaults to true.`}),timeout:Zh.pipe(B),protocol:Qh.pipe(B)}){},ng=E([$h,tg]).pipe(ie(`type`)),rg=C({status:h(`connected`)}).annotate({identifier:`Mcp.Status.Connected`}),ig=C({status:h(`pending`)}).annotate({identifier:`Mcp.Status.Pending`}),ag=C({status:h(`disabled`)}).annotate({identifier:`Mcp.Status.Disabled`}),og=C({status:h(`failed`),error:x}).annotate({identifier:`Mcp.Status.Failed`}),sg=C({status:h(`needs_auth`),error:x}).annotate({identifier:`Mcp.Status.NeedsAuth`}),cg=E([rg,ig,ag,og,sg]).pipe(ie(`status`)),lg=C({name:x,status:cg,title:B(x),integrationID:B(Ss)}).annotate({identifier:`Mcp.Server`}),ug=C({server:x,name:x,uri:x,description:B(x),mimeType:B(x)}).annotate({identifier:`Mcp.Resource`}),dg=C({server:x,name:x,uriTemplate:x,description:B(x),mimeType:B(x)}).annotate({identifier:`Mcp.ResourceTemplate`}),fg=C({resources:g(ug),templates:g(dg)}).annotate({identifier:`Mcp.ResourceCatalog`}),pg=E([C({type:h(`text`),uri:x,text:x,mimeType:B(x)}),C({type:h(`blob`),uri:x,blob:x,mimeType:B(x)})]).pipe(ie(`type`),O({identifier:`Mcp.ResourceContentPart`}));C({server:x,uri:x,contents:g(pg)}).annotate({identifier:`Mcp.ResourceContent`});var mg=Zh,hg=ng,gg=class extends p(`Config.MCP`)({timeout:mg.pipe(B),servers:S(x,hg).pipe(B)}){},_g=class extends p(`Config.Plugin.Entry`)({package:x,options:S(x,Ie).pipe(B)}){},vg=E([x,_g]).pipe(g),yg=class extends p(`Config.Reference.Git`)({repository:x,branch:x.pipe(B),description:x.pipe(B),hidden:v.pipe(B)}){},bg=class extends p(`Config.Reference.Local`)({path:x,description:x.pipe(B),hidden:v.pipe(B)}){},xg=E([x,yg,bg]),Sg=S(x,xg),Cg=e({Event:()=>Ag,ID:()=>wg,Input:()=>Eg,Provider:()=>Tg,Response:()=>Og,Result:()=>Dg,WebSearch:()=>Cg}),wg=x.pipe(M(`WebSearch.ID`),O({identifier:`WebSearch.ID`})),Tg=C({id:wg,name:x}).annotate({identifier:`WebSearch.Provider`}),Eg=C({query:x,providerID:wg.pipe(B)}).annotate({identifier:`WebSearch.Input`}),Dg=C({url:x,title:x.pipe(B),content:x.pipe(B),time:C({published:P.pipe(B).annotate({description:`Publication time in milliseconds since the Unix epoch`})})}).annotate({identifier:`WebSearch.Result`}),Og=class extends p(`WebSearch.Response`)({providerID:wg,results:g(Dg)}){},kg=U({type:`websearch.updated`,schema:{}}),Ag={Updated:kg,Definitions:W(kg)},jg=class extends p(`ConfigWebSearch.Info`)({provider:E([h(`random`).annotate({description:`Reuse a randomly selected provider until it is rate limited, then switch to another available provider.`}),wg])}){},Mg=E([h(!1),jg]),Ng=class extends p(`Config.ToolOutput`)({max_lines:no.pipe(B),max_bytes:no.pipe(B)}){},Pg=class extends p(`Config.Watcher`)({ignore:x.pipe(g,B)}){},Fg=class extends p(`Config.Warming`)({prompt:x.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")`})}){},Ig=E([v,Fg]),Lg=C({directory:xt.pipe(at(kt())).annotate({description:`Parent directory for new worktrees, relative to the project's primary checkout when not absolute`})}).annotate({identifier:`Config.Worktree`}),Rg=e({Config:()=>Rg,Directory:()=>Hg,Document:()=>Vg,Entry:()=>Ug,Event:()=>Gg,Info:()=>zg,Patch:()=>Bg}),zg=class extends p(`Config.Info`)({$schema:B(x).annotate({description:`JSON schema reference for configuration validation`}),shell:x.pipe(B).annotate({description:`Default shell to use for terminal and shell tool execution`}),model:xh.pipe(B).annotate({description:`Default model to use when no session or agent model is selected`}),default_agent:x.pipe(B).annotate({description:`Default primary agent to use when no session agent is selected`}),update:y([`disable`,`notify`,`auto`]).pipe(B).annotate({description:`Disable updates, notify when one is available, or install updates automatically`}),share:y([`manual`,`auto`,`disabled`]).pipe(B).annotate({description:`Control whether sessions may be shared manually, automatically, or not at all`}),enterprise:C({url:x.pipe(B)}).pipe(B).annotate({description:`Enterprise sharing service configuration`}),username:x.pipe(B).annotate({description:`Username displayed in conversations and used for telemetry identity`}),permissions:Tu.pipe(B).annotate({description:`Ordered tool permission rules applied to agent tool use`}),policies:Uh.pipe(g,B).annotate({description:`Ordered policies controlling access to providers, tools, and integrations`}),agents:S(x,Ih).pipe(B).annotate({description:`Named built-in agent overrides and custom agent definitions`}),snapshots:v.pipe(B).annotate({description:`Enable snapshots used for undo and revert behavior`}),watcher:Pg.pipe(B).annotate({description:`Filesystem watcher configuration`}),formatter:Kh.pipe(B).annotate({description:`Enable built-in formatters or configure formatter overrides`}),lsp:Xh.pipe(B).annotate({description:`Enable built-in language servers or configure server overrides`}),media:Rh.pipe(B).annotate({description:`Media processing configuration`}),tool_output:Ng.pipe(B).annotate({description:`Tool output truncation thresholds`}),mcp:gg.pipe(B).annotate({description:`MCP server configuration`}),compaction:Bh.pipe(B).annotate({description:`Conversation compaction behavior`}),skills:x.pipe(g,B).annotate({description:`Additional paths or URLs to discover skills from`}),commands:S(x,Vh).pipe(B).annotate({description:`Named slash command definitions`}),instructions:x.pipe(g,B).annotate({description:`Additional paths or URLs supplying ambient instructions`}),references:Sg.pipe(B).annotate({description:`Named local directories or Git repositories available as external context`}),websearch:Mg.pipe(B).annotate({description:`Web search provider selection`}),plugins:vg.pipe(B).annotate({description:`Ordered plugin enablement directives and external package declarations`}),worktree:Lg.pipe(B).annotate({description:`Directory defaults for local worktree creation`}),warming:Ig.pipe(B).annotate({description:`Keep recently active sessions warm with transient model requests (default: false)`}),providers:S(x,Ph).pipe(B),experimental:Wh.pipe(B)}){},Bg=C({shell:se(x)}).annotate({identifier:`Config.Patch`}),Vg=class extends p(`Config.Document`)({type:h(`document`),path:io.pipe(B),info:zg}){},Hg=class extends p(`Config.Directory`)({type:h(`directory`),path:io}){},Ug=E([Vg,Hg]).annotate({identifier:`Config.Entry`}),Wg=U({type:`config.updated`,schema:{}}),Gg={Updated:Wg,Definitions:W(Wg)},Kg=e({CreateInput:()=>Jg,Directory:()=>Zg,Event:()=>r_,Info:()=>Xg,List:()=>e_,ListEntry:()=>Qg,OperationError:()=>$g,RemoveInput:()=>Yg,StrategyID:()=>qg,Worktree:()=>Kg,adopt:()=>i_}),qg=xt.pipe(at(kt()),M(`Worktree.StrategyID`)),Jg=C({projectID:Pu,from:B(io),branch:B(xt.pipe(at(kt()))),directory:B(io).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(x)}).annotate({identifier:`Worktree.CreateInput`}),Yg=C({projectID:Pu,directory:io,force:v}).annotate({identifier:`Worktree.RemoveInput`}),Xg=C({directory:io}).annotate({identifier:`Worktree.Info`}),Zg=C({directory:io,strategy:B(x)}).annotate({identifier:`Worktree.Directory`}),Qg=C({directory:io,type:y([`root`,`worktree`])}).annotate({identifier:`Worktree.ListEntry`}),$g=class extends t()(`Worktree.OperationError`,{message:x,forceRequired:B(v)}){},e_=g(Zg).annotate({identifier:`Worktree.List`}),t_=U({type:`worktree.updated`,schema:{projectID:Pu}}),n_=H({type:`worktree.resolved`,durable:{aggregate:`projectID`,version:1},schema:{projectID:Pu,directory:io,previous:Pu,adopted:B(g(Pu))}}),r_={Updated:t_,Resolved:n_,Definitions:W(t_,n_)};function i_(e,t){if(e.workspaceID||e.projectID!==t.previous&&e.projectID!==Pu.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)}}ko([...sp,r_.Resolved]);var a_=U({type:`file.edited`,schema:{file:x}}),o_={Edited:a_,Definitions:W(a_)},s_=W(U({type:`installation.updated`,schema:{version:x}}),U({type:`installation.update-available`,schema:{version:x}})),c_=x.check(me(`per`)).pipe(M(`PermissionV1.ID`),oo(e=>({ascending:t=>e.make(t??`per_`+fo())}))),l_=y([`allow`,`deny`,`ask`]).annotate({identifier:`PermissionV1.Action`}),u_=C({permission:x,pattern:x,action:l_}).annotate({identifier:`PermissionV1.Rule`}),d_=g(u_).annotate({identifier:`PermissionV1.Ruleset`}),f_=C({id:c_,sessionID:pu,permission:x,patterns:g(x),metadata:S(x,Ie),always:g(x),tool:i(C({messageID:x,callID:x}))}).annotate({identifier:`PermissionV1.Request`}),p_=y([`once`,`always`,`reject`]),m_=C({reply:p_,message:i(x)}).annotate({identifier:`PermissionV1.ReplyBody`});C({projectID:Pu,patterns:g(x)}).annotate({identifier:`PermissionV1.Approval`}),C({...f_.fields,id:i(c_),ruleset:d_}).annotate({identifier:`PermissionV1.AskInput`}),C({requestID:c_,...m_.fields}).annotate({identifier:`PermissionV1.ReplyInput`}),W(U({type:`permission.asked`,schema:f_.fields}),U({type:`permission.replied`,schema:{sessionID:pu,requestID:c_,reply:p_}}));var h_=P.check(Re(0)),g_=x.check(me(`msg`)).pipe(M(`SessionV1.MessageID`),oo(e=>({ascending:t=>e.make(t??`msg_`+fo())}))),__=x.check(me(`prt`)).pipe(M(`SessionV1.PartID`),oo(e=>({ascending:t=>e.make(t??`prt_`+fo())}))),v_=(e,t)=>{let n=C({name:h(e),data:C(t)}).annotate({identifier:e});return{Schema:n,EffectSchema:n}},y_=v_(`MessageOutputLengthError`,{}),b_=v_(`ProviderAuthError`,{providerID:x,message:x}),x_=v_(`MessageAbortedError`,{message:x}),S_=v_(`StructuredOutputError`,{message:x,retries:z}),C_=v_(`APIError`,{message:x,statusCode:i(z),isRetryable:v,responseHeaders:i(S(x,x)),responseBody:i(x),metadata:i(S(x,x))}),w_=v_(`ContextOverflowError`,{message:x,responseBody:i(x)}),T_=v_(`ContentFilterError`,{message:x}),E_=class extends p(`OutputFormatText`)({type:h(`text`)}){},D_=class extends p(`OutputFormatJsonSchema`)({type:h(`json_schema`),schema:S(x,et).annotate({identifier:`SessionV1.JSONSchema`}),retryCount:z.pipe(i,Pt(Ve(2)))}){},O_=E([E_,D_]).annotate({discriminator:`type`,identifier:`SessionV1.OutputFormat`}),k_={id:__,sessionID:pu,messageID:g_},A_=C({...k_,type:h(`snapshot`),snapshot:x}).annotate({identifier:`SessionV1.SnapshotPart`}),j_=C({...k_,type:h(`patch`),hash:x,files:g(x)}).annotate({identifier:`SessionV1.PatchPart`}),M_=C({...k_,type:h(`text`),text:x,synthetic:i(v),ignored:i(v),time:i(C({start:z,end:i(z)})),metadata:i(S(x,et))}).annotate({identifier:`SessionV1.TextPart`}),N_=C({...k_,type:h(`reasoning`),text:x,metadata:i(S(x,et)),time:C({start:z,end:i(z)})}).annotate({identifier:`SessionV1.ReasoningPart`}),P_={text:C({value:x,start:P,end:P}).annotate({identifier:`SessionV1.FilePartSourceText`})},F_=C({start:C({line:z,character:z}),end:C({line:z,character:z})}).annotate({identifier:`SessionV1.Range`}),I_=C({...P_,type:h(`file`),path:x}).annotate({identifier:`SessionV1.FileSource`}),L_=C({...P_,type:h(`symbol`),path:x,range:F_,name:x,kind:z}).annotate({identifier:`SessionV1.SymbolSource`}),R_=C({...P_,type:h(`resource`),clientName:x,uri:x}).annotate({identifier:`SessionV1.ResourceSource`}),z_=E([I_,L_,R_]).annotate({discriminator:`type`,identifier:`SessionV1.FilePartSource`}),B_=C({...k_,type:h(`file`),mime:x,filename:i(x),url:x,source:i(z_)}).annotate({identifier:`SessionV1.FilePart`}),V_=C({...k_,type:h(`agent`),name:x,source:i(C({value:x,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPart`}),H_=C({...k_,type:h(`compaction`),auto:v,overflow:i(v),tail_start_id:i(g_)}).annotate({identifier:`SessionV1.CompactionPart`}),U_=C({...k_,type:h(`subtask`),prompt:x,description:x,agent:x,model:i(C({providerID:Ic,modelID:el})),command:i(x)}).annotate({identifier:`SessionV1.SubtaskPart`}),W_=C({...k_,type:h(`retry`),attempt:z,error:C_.EffectSchema,time:C({created:z})}).annotate({identifier:`SessionV1.RetryPart`}),G_=C({...k_,type:h(`step-start`),snapshot:i(x)}).annotate({identifier:`SessionV1.StepStartPart`}),K_=C({...k_,type:h(`step-finish`),reason:x,snapshot:i(x),cost:P,tokens:C({total:i(P),input:P,output:P,reasoning:P,cache:C({read:P,write:P})})}).annotate({identifier:`SessionV1.StepFinishPart`}),q_=C({status:h(`pending`),input:S(x,et),raw:x}).annotate({identifier:`SessionV1.ToolStatePending`}),J_=C({status:h(`running`),input:S(x,et),title:i(x),metadata:i(S(x,et)),time:C({start:z})}).annotate({identifier:`SessionV1.ToolStateRunning`}),Y_=C({status:h(`completed`),input:S(x,et),output:x,title:x,metadata:S(x,et),time:C({start:z,end:z,compacted:i(z)}),attachments:i(g(B_))}).annotate({identifier:`SessionV1.ToolStateCompleted`}),X_=C({status:h(`error`),input:S(x,et),error:x,metadata:i(S(x,et)),time:C({start:z,end:z})}).annotate({identifier:`SessionV1.ToolStateError`}),Z_=E([q_,J_,Y_,X_]).annotate({discriminator:`status`,identifier:`SessionV1.ToolState`}),Q_=C({...k_,type:h(`tool`),callID:x,tool:x,state:Z_,metadata:i(S(x,et))}).annotate({identifier:`SessionV1.ToolPart`}),$_={id:g_,sessionID:k_.sessionID},ev=C({...$_,role:h(`user`),time:C({created:h_}),format:i(O_),summary:i(C({title:i(x),body:i(x),diffs:g(Wd)})),agent:x,model:C({providerID:Ic,modelID:el,variant:i(x)}),system:i(x),tools:i(S(x,v))}).annotate({identifier:`SessionV1.UserMessage`}),tv=E([M_,U_,N_,B_,Q_,G_,K_,A_,j_,V_,W_,H_]).annotate({discriminator:`type`,identifier:`SessionV1.Part`}),nv=E([b_.EffectSchema,v_(`UnknownError`,{message:x,ref:i(x)}).EffectSchema,y_.EffectSchema,x_.EffectSchema,S_.EffectSchema,w_.EffectSchema,T_.EffectSchema,C_.EffectSchema]).annotate({discriminator:`name`});C({id:i(__),type:h(`text`),text:x,synthetic:i(v),ignored:i(v),time:i(C({start:z,end:i(z)})),metadata:i(S(x,et))}).annotate({identifier:`SessionV1.TextPartInput`}),C({id:i(__),type:h(`file`),mime:x,filename:i(x),url:x,source:i(z_)}).annotate({identifier:`SessionV1.FilePartInput`}),C({id:i(__),type:h(`agent`),name:x,source:i(C({value:x,start:z,end:z}))}).annotate({identifier:`SessionV1.AgentPartInput`}),C({id:i(__),type:h(`subtask`),prompt:x,description:x,agent:x,model:i(C({providerID:Ic,modelID:el})),command:i(x)}).annotate({identifier:`SessionV1.SubtaskPartInput`});var rv=C({...$_,role:h(`assistant`),time:C({created:z,completed:i(z)}),error:i(nv),parentID:g_,modelID:el,providerID:Ic,mode:x,agent:x,path:C({cwd:x,root:x}),summary:i(v),cost:P,tokens:C({total:i(P),input:P,output:P,reasoning:P,cache:C({read:P,write:P})}),structured:i(et),variant:i(x),finish:i(x)}).annotate({identifier:`SessionV1.AssistantMessage`}),iv=E([ev,rv]).annotate({discriminator:`role`,identifier:`SessionV1.Message`}),av={durable:{aggregate:`sessionID`,version:1}},ov=C({additions:P,deletions:P,files:P,diffs:B(g(Wd))}),sv=C({input:P,output:P,reasoning:P,cache:C({read:P,write:P})}),cv=C({url:x}),lv=C({messageID:g_,partID:B(__),snapshot:B(x),diff:B(x)}),uv=C({id:el,providerID:Ic,variant:B(x)}),dv=C({id:pu,slug:x,projectID:Pu,workspaceID:B(go),directory:x,path:B(x),parentID:B(pu),summary:B(ov),cost:B(P),tokens:B(sv),share:B(cv),title:B(x),agent:B(x),model:B(uv),version:x,metadata:B(S(x,et)),time:C({created:z,updated:z,compacting:B(z),archived:B(P)}),permission:B(d_),revert:B(lv)}).annotate({identifier:`SessionV1.Info`}),fv={Created:H({type:`session.created`,...av,schema:{sessionID:pu,info:dv}}),Updated:H({type:`session.updated`,...av,schema:{sessionID:pu,info:dv}}),Deleted:H({type:`session.deleted`,...av,schema:{sessionID:pu,info:dv}}),MessageUpdated:H({type:`message.updated`,...av,schema:{sessionID:pu,info:iv}}),MessageRemoved:H({type:`message.removed`,...av,schema:{sessionID:pu,messageID:g_}}),PartUpdated:H({type:`message.part.updated`,...av,schema:{sessionID:pu,part:tv,time:P}}),PartRemoved:H({type:`message.part.removed`,...av,schema:{sessionID:pu,messageID:g_,partID:__}})},pv=U({type:`message.part.delta`,schema:{sessionID:pu,messageID:g_,partID:__,field:x,delta:x}}),mv=U({type:`session.diff`,schema:{sessionID:pu,diff:g(Wd)}}),hv=U({type:`session.error`,schema:{sessionID:i(pu),error:rv.fields.error}});({...fv}),W(fv.Created,fv.Updated,fv.Deleted,fv.MessageUpdated,fv.MessageRemoved,fv.PartUpdated,fv.PartRemoved,pv,mv,hv);var gv=W(U({type:`command.executed`,schema:{name:x,sessionID:pu,arguments:x,messageID:g_}})),_v=W(U({type:`lsp.updated`,schema:{}})),vv=W(U({type:`location.shutdown`,schema:{}})),yv=U({type:`mcp.tools.changed`,schema:{server:x}}),bv=U({type:`mcp.resources.changed`,schema:{server:x}}),xv=U({type:`mcp.status.changed`,schema:{server:x}}),Sv=W(yv,bv,xv),Cv=U({type:`models-dev.refreshed`,schema:{}}),wv={Refreshed:Cv,Definitions:W(Cv)},Tv=x.pipe(M(`Plugin.ID`),O({identifier:`Plugin.ID`})),Ev=E([C({type:h(`builtin`)}),C({type:h(`package`),target:x,version:x.pipe(B),outdated:h(!0).pipe(B),updating:h(!0).pipe(B)}),C({type:h(`local`),path:x}),C({type:h(`sdk`)})]).annotate({identifier:`Plugin.Source`}),Dv=C({server:h(!0).pipe(B),tui:h(!0).pipe(B),rpc:h(!0).pipe(B),gui:h(!0).pipe(B)}).annotate({identifier:`Plugin.Features`}),Ov=C({code:x,revision:x,options:S(x,Te)}).annotate({identifier:`Plugin.GuiBundle`}),kv=E([C({status:h(`active`)}),C({status:h(`failed`),error:x,ref:x.pipe(B)})]).annotate({identifier:`Plugin.State`}),Av=C({id:Tv.pipe(B),source:Ev,features:Dv,state:kv}).annotate({identifier:`Plugin.Info`}),jv=U({type:`plugin.updated`,schema:{}}),Mv={Updated:jv,Definitions:W(jv)},Nv=e({Event:()=>Fv,GitSource:()=>Lv,Info:()=>zv,LocalSource:()=>Iv,Reference:()=>Nv,Source:()=>Rv}),Pv=U({type:`reference.updated`,schema:{}}),Fv={Updated:Pv,Definitions:W(Pv)},Iv=C({type:h(`local`),path:io,description:x.pipe(B),hidden:v.pipe(B)}).annotate({identifier:`Reference.LocalSource`}),Lv=C({type:h(`git`),repository:x,branch:x.pipe(B),description:x.pipe(B),hidden:v.pipe(B)}).annotate({identifier:`Reference.GitSource`}),Rv=E([Iv,Lv]).pipe(ie(`type`)).annotate({identifier:`Reference.Source`}),zv=C({name:x,path:io,description:x.pipe(B),hidden:v.pipe(B),source:Rv}).annotate({identifier:`Reference.Info`}),Bv=W(U({type:`server.connected`,schema:{}}),U({type:`global.disposed`,schema:{}})),Vv=W(U({type:`session.status`,identifier:`SessionStatusUpdated`,schema:{sessionID:pu,status:E([C({type:h(`idle`)}),C({type:h(`retry`),attempt:z,message:x,action:B(C({reason:x,provider:x,title:x,message:x,label:x,link:B(x)})),next:z}),C({type:h(`busy`)})]).annotate({identifier:`SessionStatus`})}}),U({type:`session.idle`,schema:{sessionID:pu}})),Hv=W(U({type:`tui.prompt.append`,schema:{text:x}}),U({type:`tui.command.execute`,schema:{command:E([y([`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`]),x])}}),U({type:`tui.toast.show`,schema:{title:B(x),message:x,variant:y([`info`,`success`,`warning`,`error`]),duration:no.pipe(Pt(Ve(5e3))).annotate({description:`Duration in milliseconds`})}}),U({type:`tui.session.select`,schema:{sessionID:pu.annotate({description:`Session ID to navigate to`})}})),Uv=W(U({type:`vcs.branch.updated`,schema:{branch:B(x)}})),Wv=C({workspaceID:go,status:y([`connected`,`connecting`,`disconnected`,`error`])}).annotate({identifier:`WorkspaceEvent.ConnectionStatus`}),Gv=W(U({type:`workspace.ready`,schema:{name:x}}),U({type:`workspace.failed`,schema:{message:x}}),U({type:`workspace.status`,schema:Wv.fields})),Kv=W(U({type:`worktree.ready`,schema:{name:x,branch:B(x)}}),U({type:`worktree.failed`,schema:{message:x}})),qv=W(...op),Jv=W(...vv,...wv.Definitions,...Os.Definitions,...bc.Definitions,...Rc.Definitions,...nl.Definitions,...Mu.Definitions,...qv),Yv=W(...Ym.Definitions,...Fv.Definitions,...Su.Definitions,...Mv.Definitions,...Uu.Definitions,...r_.Definitions,...uh.Definitions,...Gg.Definitions,...Ro.Definitions,...uu.Definitions,...Np.Definitions,...rd.Definitions,...lc.Definitions,...Ag.Definitions),Xv=W(...Jv,...Yv,...Vv,...Hv,...s_,...Uv,xv,bv);Do(Xv),Do(W(...Jv,...s_,...Yv,..._v,...Hv,...Sv,...gv,...o_.Definitions,...Vv,...Uv,...Gv,...Kv,...Bv));var Zv={id:Co,metadata:i(S(x,Ie)),location:i(yo)},Qv=C({id:Co,created:P,metadata:i(S(x,Ie)),type:We([`rpc.`,x]),location:yo,data:S(x,Ie)}).annotate({identifier:`V2Event.rpc`}),$v=e=>E([...e,Qv,...e.some(e=>e.type===`server.connected`)?[]:[C({...Zv,type:h(`server.connected`),data:C({})}).annotate({identifier:`V2Event.server.connected`})]]).annotate({identifier:`V2Event`}),ey=e=>C({types:i(de(E([y(e.map(e=>e.type)),Qv.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`}),ty=(e=>{let t=$v(e);return{schema:t,group:N(`server.event`).add(A(`event.subscribe`,`/api/event`,{query:ey(e),success:Ge({data:t})}).annotateMerge(k({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(k({title:`event`,description:`Experimental event stream routes.`}))}})(Xv),ny=ty.group;ty.schema;var ry=N(`server.agent`).add(A(`agent.list`,`/api/agent`,{query:X,success:V(g(ju)),error:Jo}).annotateMerge(Z).annotateMerge(k({identifier:`agent.list`,summary:`List agents`,description:`Retrieve currently registered agents.`}))).add(A(`agent.get`,`/api/agent/:agentID`,{params:{agentID:Ou},query:X,success:V(ju),error:rs}).annotateMerge(Z).annotateMerge(k({identifier:`agent.get`,summary:`Get agent`,description:`Retrieve a single currently registered agent.`}))).annotateMerge(k({title:`agent`})),iy=N(`server.plugin`).add(A(`plugin.list`,`/api/plugin`,{query:X,success:V(g(Av))}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.list`,summary:`List plugins`,description:`Retrieve enabled server plugins and their current status.`}))).add(A(`plugin.gui`,`/api/plugin/gui`,{query:C({...X.fields,id:Tv}),success:V(Ov),error:ns}).annotateMerge(Z).annotateMerge(k({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(D(`plugin.check`,`/api/plugin/check`,{query:X,payload:C({target:x.pipe(i)}),success:V(g(Av)),error:Ho}).annotateMerge(Z).annotateMerge(k({identifier:`plugin.check`,summary:`Check plugin updates`,description:`Check one or all package plugins for available updates.`}))).add(D(`plugin.update`,`/api/plugin/update`,{query:X,payload:C({targets:g(x)}),success:T,error:[Ho,Jo]}).annotateMerge(Z).annotateMerge(k({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(k({title:`plugin`,description:`Experimental plugin routes.`})),ay=C({version:x,pid:a.check(Re(0)),hostname:i(x),urls:g(x),paths:C({tmp:x}),capabilities:i(C({persistentPty:i(v)}))}).annotate({identifier:`ServerInfo`}),oy=C({code:x,expires_in:a}).annotate({identifier:`PairingCode`}),sy=C({token:x}).annotate({identifier:`PairingSession`}),cy=N(`server.server`).add(A(`server.info`,`/api/info`,{success:ay}).annotateMerge(k({identifier:`server.info`,summary:`Get server info`,description:`Return the server identity, connection URLs, paths, and readiness status.`}))).add(D(`server.pair`,`/api/pair`,{success:oy}).annotateMerge(k({identifier:`server.pair`,summary:`Create pairing code`,description:`Create a short-lived, single-use code for a /auth/connect/:code pairing link.`}))).add(A(`server.connect`,`/auth/connect/:code`,{params:{code:x},success:sy,error:Go}).annotateMerge(k({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(k({title:`server`})),ly=N(`server.debug`).add(D(`debug.heapDump`,`/api/debug/heap-dump`,{query:C({directory:x.pipe(i,O({description:`Absolute server-local directory to write the snapshot into, created when missing. Defaults to the server's log directory.`}))}),success:C({path:x,pid:a,memory:C({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:[Ho,Yo]}).annotateMerge(k({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(A(`debug.location`,`/api/debug/location`,{success:g(yo)}).annotateMerge(k({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:T}).annotateMerge(Z).annotateMerge(k({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(k({title:`debug`})),uy=N(`server.shell`).add(A(`shell.list`,`/api/shell`,{query:X,success:V(g($u))}).annotateMerge(Z).annotateMerge(k({identifier:`shell.list`,summary:`List running shell commands`,description:`List currently running shell commands for a location. Exited commands are not included.`}))).add(D(`shell.create`,`/api/shell`,{query:X,payload:id,success:V($u)}).annotateMerge(Z).annotateMerge(k({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(A(`shell.get`,`/api/shell/:id`,{params:{id:Yu},query:X,success:V($u),error:_s}).annotateMerge(Z).annotateMerge(k({identifier:`shell.get`,summary:`Get shell command`,description:`Get one shell command, including its status and exit code once exited.`}))).add(A(`shell.output`,`/api/shell/:id/output`,{params:{id:Yu},query:C({...X.fields,...ad.fields}),success:V(od),error:_s}).annotateMerge(Z).annotateMerge(k({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:Yu},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`shell.remove`,summary:`Remove shell command`,description:`Terminate and remove one shell command and its retained output.`}))).annotateMerge(k({title:`shell`,description:`Location-scoped shell command routes.`})),dy=C(o(Iv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.LocalSource`}),fy=C(o(Lv.fields,[`description`,`hidden`])).annotate({identifier:`Reference.GitSource`}),py=E([dy,fy]).pipe(ie(`type`)).annotate({identifier:`Reference.Source`}),my=C({...o(zv.fields,[`source`]),source:py}).annotate({identifier:`Reference.Info`}),hy=N(`server.reference`).add(A(`reference.list`,`/api/reference`,{query:X,success:V(g(my))}).annotateMerge(Z).annotateMerge(k({identifier:`reference.list`,summary:`List references`,description:`List references available in the requested location.`}))).annotateMerge(k({title:`reference`,description:`Location-scoped project references.`})),gy=class extends Qe()(`@opencode/HttpApiAuthorization`,{error:Go}){},_y=N(`server.integration`).add(A(`integration.list`,`/api/integration`,{query:X,success:V(g(Sc))}).annotateMerge(Z).annotateMerge(k({identifier:`integration.list`,summary:`List integrations`,description:`Retrieve available integrations and their authentication methods.`}))).add(A(`integration.get`,`/api/integration/:integrationID`,{params:{integrationID:dc},query:X,success:V(Sc),error:Zo}).annotateMerge(Z).annotateMerge(k({identifier:`integration.get`,summary:`Get integration`,description:`Retrieve one integration and its authentication methods.`}))).add(D(`integration.wellknown.add`,`/api/experimental/integration/wellknown`,{query:X,payload:C({url:x}),success:T,error:Ho}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.integration.wellknown.add`,summary:`Add wellknown integration`,description:`Discover and persist an experimental wellknown integration source.`}))).add(D(`integration.connect.key`,`/api/integration/:integrationID/connect/key`,{params:{integrationID:dc},query:X,payload:C({key:x,answer:i(nc),label:i(x)}),success:T,error:[Zo,Ho]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.connect.key`,summary:`Connect with key`,description:`Run a key authentication method and store the resulting credential.`}))).add(D(`integration.connect.external`,`/api/integration/:integrationID/connect/external`,{params:{integrationID:dc},query:X,payload:C({methodID:fc,answer:i(nc),label:i(x)}),success:T,error:[Zo,Ho]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.connect.external`,summary:`Connect with external credentials`,description:`Run an external authentication method and store a reference to its credential source.`}))).add(D(`integration.oauth.connect`,`/api/integration/:integrationID/connect/oauth`,{params:{integrationID:dc},query:X,payload:C({methodID:fc,answer:i(nc),label:i(x)}),success:V(Tc),error:Ho}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.connect`,summary:`Begin OAuth connection`,description:`Start an OAuth attempt and return the authorization details.`}))).add(A(`integration.oauth.status`,`/api/integration/:integrationID/connect/oauth/:attemptID`,{params:{integrationID:dc,attemptID:Cc},query:X,success:V(Ec),error:[Zo,Qo]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.status`,summary:`Get OAuth attempt status`,description:`Poll the current status of an OAuth attempt.`}))).add(D(`integration.oauth.complete`,`/api/integration/:integrationID/connect/oauth/:attemptID/complete`,{params:{integrationID:dc,attemptID:Cc},query:X,payload:C({code:i(x)}),success:T,error:[Zo,Qo,Ho]}).annotateMerge(Z).annotateMerge(k({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:dc,attemptID:Cc},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`integration.oauth.cancel`,summary:`Cancel OAuth connection`,description:`Cancel an OAuth attempt and release its resources.`}))).add(D(`integration.command.connect`,`/api/integration/:integrationID/connect/command`,{params:{integrationID:dc},query:X,payload:C({methodID:fc,label:i(x)}),success:V(Dc),error:[Zo,$o,Ho]}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.connect`,summary:`Begin command connection`,description:`Start a command authentication attempt.`}))).add(A(`integration.command.status`,`/api/integration/:integrationID/connect/command/:attemptID`,{params:{integrationID:dc,attemptID:Cc},query:X,success:V(Oc),error:[Zo,Qo]}).annotateMerge(Z).annotateMerge(k({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:dc,attemptID:Cc},query:X,success:T}).annotateMerge(Z).annotateMerge(k({identifier:`integration.command.cancel`,summary:`Cancel command connection`,description:`Cancel a command authentication attempt and terminate its process.`}))).annotateMerge(k({title:`integration`,description:`Integration discovery and authentication routes.`})),vy=N(`server.websearch`).add(A(`websearch.providers`,`/api/websearch/provider`,{query:X,success:V(g(Tg)),error:Jo}).annotateMerge(Z).annotateMerge(k({identifier:`websearch.providers`,summary:`List web search providers`,description:`Return the registered web search providers.`}))).add(D(`websearch.query`,`/api/websearch`,{query:X,payload:C(Eg.fields),success:V(Og),error:[Ho,Jo]}).annotateMerge(Z).annotateMerge(k({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(k({title:`websearch`,description:`Location-scoped web search routes.`})),yy=P.check(Dt({minimum:0,maximum:100})),by=P.annotate({description:`Milliseconds since the Unix epoch`}),xy=C({percent:yy,limited:v,resetsAt:by}).annotate({identifier:`UsageLimits.Meter`}),Sy=C({rolling:xy,weekly:xy,monthly:xy}).annotate({identifier:`UsageLimits.Go`}),Cy=C({providerID:Ic,modelID:el,name:x,spent:Zc.pipe(B)}).annotate({identifier:`UsageLimits.BudgetModel`}),wy=C({id:x,limit:Zc,spent:Zc,scope:y([`each`,`combined`]),per:y([`set`,`model`]),coverage:y([`all`,`models`]),models:g(Cy),vendors:g(x),inputPriceAtLeast:Qc.pipe(B),picked:v,shared:v,resetsAt:by}).annotate({identifier:`UsageLimits.Budget`}),Ty=C({workspace:C({id:x,name:x.pipe(B),usageURL:x}),go:Sy.pipe(B),budgets:g(wy)}).annotate({identifier:`UsageLimits.Info`}),Ey=N(`server.usage`).add(A(`usage.limits`,`/api/experimental/usage/limits`,{query:X,success:V(se(Ty)),error:Jo}).annotateMerge(Z).annotateMerge(k({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(k({title:`usage`,description:`Experimental usage limit routes.`})),Dy=`/api/experimental/client-mcp`,Oy=C({...X.fields,name:x.check(Ce(/^[a-zA-Z0-9_-]+$/))}),ky=e=>N(`server.mcp`).add(A(`mcp.list`,`/api/mcp`,{query:X,success:V(g(lg))}).annotateMerge(Z).annotateMerge(k({identifier:`mcp.list`,summary:`List MCP servers`,description:`Retrieve configured MCP servers and their connection status.`}))).add(St(`mcp.add`,`/api/experimental/mcp/:server`,{params:{server:x},query:X,payload:C({config:ng}),success:T}).annotateMerge(Z).annotateMerge(k({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:x},query:X,success:T,error:os}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.remove`,summary:`Remove MCP server`,description:`Stop an MCP server and remove it from the runtime set until restart.`}))).add(D(`mcp.connect`,`/api/experimental/mcp/:server/connect`,{params:{server:x},query:X,success:T,error:os}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.connect`,summary:`Connect MCP server`,description:`Connect an MCP server at runtime, overriding a disabled configuration until restart.`}))).add(D(`mcp.disconnect`,`/api/experimental/mcp/:server/disconnect`,{params:{server:x},query:X,success:T,error:os}).annotateMerge(Z).annotateMerge(k({identifier:`experimental.mcp.disconnect`,summary:`Disconnect MCP server`,description:`Disconnect an MCP server at runtime, removing its tools until reconnected.`}))).add(A(`mcp.resource.catalog`,`/api/mcp/resource`,{query:X,success:V(fg)}).annotateMerge(Z).annotateMerge(k({identifier:`mcp.resource.catalog`,summary:`List MCP resources`,description:`Retrieve resources and resource templates from connected MCP servers.`}))).add(D(`mcp.clientToken`,`${Dy}/token`,{query:Oy,headers:C({[Lp]:i(x)}),success:V(Pp),error:hs}).annotateMerge(Z).annotateMerge(k({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(A(`mcp.client`,Dy,{query:C({...Oy.fields,[Ip]:i(x)}),success:v,error:[hs,Vo]}).annotateMerge(Z).annotateMerge(k({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(k({title:`mcp`,description:`MCP server and resource routes.`})),Ay=N(`server.credential`).add(A(`credential.list`,`/api/credential`,{success:C({data:g(Ns)})}).annotateMerge(k({identifier:`credential.list`,summary:`List credentials`,description:`List every stored integration credential, including its secret value.`}))).add(D(`credential.create`,`/api/credential`,{payload:Ps,success:C({data:Ns}),error:Ko}).annotateMerge(k({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(ze(`credential.update`,`/api/credential/:credentialID`,{params:{credentialID:Ts},payload:C({label:x}),success:T}).annotateMerge(k({identifier:`credential.update`,summary:`Update credential`,description:`Update a stored credential label.`}))).annotateMerge(k({title:`credential`})).add(D(`credential.activate`,`/api/credential/:credentialID/activate`,{params:{credentialID:Ts},success:T}).annotateMerge(k({identifier:`credential.activate`,summary:`Activate credential`,description:`Activate a stored integration credential.`}))).add(ft(`credential.remove`,`/api/credential/:credentialID`,{params:{credentialID:Ts},success:T}).annotateMerge(k({identifier:`credential.remove`,summary:`Remove credential`,description:`Remove a stored integration credential.`}))),jy=`/api/project`,My=C(o(Vu.fields,[`projectID`])),Ny=y([`true`,`false`]).pipe(wt(v,{decode:m(e=>e===`true`),encode:m(e=>e?`true`:`false`)})),Py=N(`server.project`).add(A(`project.list`,jy,{query:C({archived:Ny.pipe(i)}),success:g(Bu)}).annotateMerge(k({identifier:`project.list`,summary:`List projects`,description:`List known projects. Archived projects are excluded unless archived=true.`}))).add(ze(`project.update`,`${jy}/:projectID`,{params:{projectID:Pu},payload:My,success:Bu,error:es}).annotateMerge(k({identifier:`project.update`,summary:`Update project`,description:`Update the project canonical directory, display metadata, and workspace commands.`}))).annotateMerge(k({title:`project`,description:`Project routes.`})),Fy=`/api/worktree`,Iy=class extends t()(`WorktreeError`,{name:h(`WorktreeError`),data:C({message:x,forceRequired:i(v)})},{httpApiStatus:400}){},Ly=N(`server.worktree`).add(A(`worktree.list`,Fy,{query:C({projectID:Pu}),success:e_,error:es}).annotateMerge(k({identifier:`worktree.list`,summary:`List worktrees`,description:`Return the project's saved worktree inventory without loading configuration or running discovery.`}))).add(D(`worktree.create`,Fy,{payload:Jg,success:Xg,error:[Iy,es]}).annotateMerge(k({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`,Fy,{payload:Yg,success:T,error:[Iy,es]}).annotateMerge(k({identifier:`worktree.remove`,summary:`Remove worktree`,description:`Load the project's canonical configuration and remove a saved worktree using its recorded strategy.`}))).add(D(`worktree.refresh`,`${Fy}/refresh`,{payload:C({projectID:Pu}),success:T,error:[Iy,es]}).annotateMerge(k({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(k({title:`worktree`,description:`Project-based worktree management routes.`})),Ry=e({Base:()=>Hy,Branch:()=>zy,BranchList:()=>Vy,FileStatus:()=>Gy,Info:()=>By,Mode:()=>Uy,Untracked:()=>Wy,Vcs:()=>Ry}),zy=C({current:B(x),default:B(x)}).annotate({identifier:`Vcs.Branch`}),By=C({provider:B(x),branch:zy}).annotate({identifier:`Vcs.Info`}),Vy=g(x).annotate({identifier:`Vcs.BranchList`}),Hy=C({name:x,ref:x,source:y([`reflog`,`default`])}).annotate({identifier:`Vcs.Base`}),Uy=y([`working`,`branch`,`committed`]).annotate({identifier:`Vcs.Mode`}),Wy=y([`files`,`folders`]).annotate({identifier:`Vcs.Untracked`}),Gy=C({file:x,additions:z,deletions:z,status:y([`added`,`deleted`,`modified`])}).annotate({identifier:`Vcs.FileStatus`}),Ky=C({...X.fields,provider:i(x)}),qy=class extends t()(`VcsInitNotSupportedError`,{providerID:x,message:x},{httpApiStatus:501}){},Jy=C({...X.fields,search:i(x),limit:ae.pipe(wt(no),i)}),Yy=C({...X.fields,mode:Uy,base:B(x),context:ae.pipe(wt(z),i),untracked:B(Wy)}),Xy=N(`server.vcs`).add(D(`vcs.init`,`/api/vcs/init`,{query:Ky,success:T,error:[Ko,Ho,qy,Jo]}).annotateMerge(Z).annotateMerge(k({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(A(`vcs.get`,`/api/vcs`,{query:X,success:V(By)}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.get`,summary:`VCS info`,description:`Get current and default branch information for the requested location.`}))).add(A(`vcs.base`,`/api/vcs/base`,{query:X,success:V(se(Hy)),error:Jo}).annotateMerge(Z).annotateMerge(k({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(A(`vcs.status`,`/api/vcs/status`,{query:X,success:V(g(Gy))}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.status`,summary:`VCS status`,description:`List uncommitted working-copy changes relative to the requested location.`}))).add(A(`vcs.branch.list`,`/api/vcs/branch`,{query:Jy,success:V(Vy)}).annotateMerge(Z).annotateMerge(k({identifier:`vcs.branch.list`,summary:`VCS branches`,description:`List local and remote branches available at the requested location.`}))).add(A(`vcs.diff`,`/api/vcs/diff`,{query:Yy,success:V(g(Ud)),error:Jo}).annotateMerge(Z).annotateMerge(k({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(k({title:`vcs`,description:`Location-scoped version control routes.`})),Zy=C({label:x,numerator:i(a.check(Re(0))),denominator:i(a.check(Re(0)))}),Qy=E([C({status:y([`required`,`completed`])}),C({status:h(`running`),progress:Zy}),C({status:h(`error`),error:x})]),$y=N(`server.migration`).add(A(`migration.v1.status`,`/api/experimental/migration/v1`,{success:Qy}).annotateMerge(k({identifier:`experimental.migration.v1.status`,summary:`Get V1 migration status`,description:`Return the progress of the V1 to V2 session history migration.`}))).annotateMerge(k({title:`migration`})),eb=C({path:x,name:x,acceptable:v}).annotate({identifier:`ConfigShell.Option`}),tb=N(`server.config`).add(A(`config.get`,`/api/config`,{query:X,success:g(Ug)}).annotateMerge(Z).annotateMerge(k({identifier:`config.get`,summary:`Get configuration`,description:`Return configuration documents and discovery sources for the requested location, from lowest to highest priority.`}))).add(A(`config.shells`,`/api/config/shell`,{success:g(eb)}).annotateMerge(k({identifier:`config.shells`,summary:`List available shells`,description:`Return shells available to terminal and agent execution.`}))).add(ze(`config.update`,`/api/experimental/config`,{payload:Bg,success:T}).annotateMerge(k({identifier:`experimental.config.update`,summary:`Update global configuration`,description:`Patch supported fields in the highest-precedence global configuration document.`}))).annotateMerge(k({title:`config`,description:`Location-scoped configuration routes.`})),nb=(e,t,n,r)=>Pe(`server`).add(cy).add(Fp(t)).add(ry.middleware(t)).add(iy.middleware(t)).add(Hm(r,n)).add(im).add(om.middleware(t)).add(eu).add(Qp).add(sm.middleware(t)).add(_y.middleware(t)).add(ky(t)).add(Ay).add(Py).add(oh(t)).add(Km(t,r)).add(ah.middleware(t)).add(dh.middleware(t)).add(fh.middleware(t)).add(hh.middleware(t)).add(e).add(zp(t)).add(Up).add(uy.middleware(t)).add(hy.middleware(t)).add(Ly).add(Xy.middleware(t)).add(ly).add($y).add(vy.middleware(t)).add(Ey.middleware(t)).add(tb.middleware(t)).annotateMerge(k({title:`opencode HttpApi`,version:`0.0.1`,description:`Experimental HttpApi surface for selected instance routes.`})).middleware(gy).middleware(xs),rb=e=>nb(ny,e.locationMiddleware,e.formLocationMiddleware,e.sessionLocationMiddleware),ib=class extends Qe()(`@opencode/client/LocationMiddleware`,{error:[Vo]}){},ab=class extends Qe()(`@opencode/client/SessionLocationMiddleware`,{error:[Ho,G,Vo]}){},ob=rb({locationMiddleware:ib,formLocationMiddleware:ab,sessionLocationMiddleware:ab});Rt({},{make:()=>OC});var Q=e=>Tt(e)||u(e)||ot.is(e)?new to({cause:e}):e,$=()=>e=>e,sb=()=>e=>e,cb=e=>()=>$()(e[`server.info`]({}).pipe(w(Q))),lb=e=>()=>$()(e[`server.pair`]({}).pipe(w(Q))),ub=e=>t=>$()(e[`server.connect`]({params:{code:t.code}}).pipe(w(Q))),db=e=>({info:cb(e),pair:lb(e),connect:ub(e)}),fb=e=>t=>$()(e[`location.get`]({query:{location:t?.location}}).pipe(w(Q))),pb=e=>()=>$()(e[`location.reload`]({}).pipe(w(Q))),mb=e=>({get:fb(e),reload:pb(e)}),hb=e=>t=>$()(e[`agent.list`]({query:{location:t?.location}}).pipe(w(Q))),gb=e=>t=>$()(e[`agent.get`]({params:{agentID:t.agentID},query:{location:t.location}}).pipe(w(Q))),_b=e=>({list:hb(e),get:gb(e)}),vb=e=>t=>$()(e[`plugin.list`]({query:{location:t?.location}}).pipe(w(Q))),yb=e=>t=>$()(e[`plugin.gui`]({query:{location:t.location,id:t.id}}).pipe(w(Q))),bb=e=>t=>$()(e[`plugin.check`]({query:{location:t?.location},payload:{target:t?.target}}).pipe(w(Q))),xb=e=>t=>$()(e[`plugin.update`]({query:{location:t.location},payload:{targets:t.targets}}).pipe(w(Q))),Sb=e=>({list:vb(e),gui:yb(e),check:bb(e),update:xb(e)}),Cb=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(w(Q))),wb=e=>t=>$()(e[`session.stats`]({query:{from:t?.from,to:t?.to,project:t?.project,timezone:t?.timezone,tools:t?.tools}}).pipe(w(Q),j(e=>e.data))),Tb=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(w(Q),j(e=>e.data))),Eb=e=>t=>$()(e[`session.import`]({payload:{info:t.info,messages:t.messages,location:t.location}}).pipe(w(Q),j(e=>e.data))),Db=e=>t=>$()(e[`session.export`]({params:{sessionID:t.sessionID},query:{sanitize:t.sanitize}}).pipe(w(Q),j(e=>e.data))),Ob=e=>()=>$()(e[`session.active`]({}).pipe(w(Q),j(e=>e.data))),kb=e=>t=>$()(e[`session.get`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Ab=e=>t=>$()(e[`session.remove`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),jb=e=>t=>$()(e[`session.fork`]({params:{sessionID:t.sessionID},payload:{before:t.before}}).pipe(w(Q),j(e=>e.data))),Mb=e=>t=>$()(e[`session.switchAgent`]({params:{sessionID:t.sessionID},payload:{agent:t.agent}}).pipe(w(Q))),Nb=e=>t=>$()(e[`session.switchModel`]({params:{sessionID:t.sessionID},payload:{model:t.model}}).pipe(w(Q))),Pb=e=>t=>$()(e[`session.update`]({params:{sessionID:t.sessionID},payload:{title:t.title,metadata:t.metadata,permissions:t.permissions,archived:t.archived}}).pipe(w(Q))),Fb=e=>t=>$()(e[`session.move`]({params:{sessionID:t.sessionID},payload:{directory:t.directory,delivery:t.delivery}}).pipe(w(Q))),Ib=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(w(Q),j(e=>e.data))),Lb=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(w(Q))),Rb=e=>t=>$()(e[`session.skill`]({params:{sessionID:t.sessionID},payload:{id:t.id,resume:t.resume}}).pipe(w(Q))),zb=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(w(Q),j(e=>e.data))),Bb=e=>t=>$()(e[`session.shell`]({params:{sessionID:t.sessionID},payload:{id:t.id,command:t.command}}).pipe(w(Q))),Vb=e=>t=>$()(e[`session.compact`]({params:{sessionID:t.sessionID},payload:{id:t.id,delivery:t.delivery}}).pipe(w(Q),j(e=>e.data))),Hb=e=>t=>$()(e[`session.wait`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Ub=e=>t=>$()(e[`session.revert.stage`]({params:{sessionID:t.sessionID},payload:{messageID:t.messageID,files:t.files}}).pipe(w(Q),j(e=>e.data))),Wb=e=>t=>$()(e[`session.revert.clear`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Gb=e=>t=>$()(e[`session.revert.commit`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),Kb=e=>t=>$()(e[`session.context`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),qb=e=>t=>$()(e[`session.diff`]({params:{sessionID:t.sessionID},query:{from:t.from,to:t.to,context:t.context}}).pipe(w(Q),j(e=>e.data))),Jb=e=>t=>$()(e[`session.inbox.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Yb=e=>t=>$()(e[`session.inbox.cancel`]({params:{sessionID:t.sessionID,inboxID:t.inboxID}}).pipe(w(Q))),Xb=e=>t=>$()(e[`session.inbox.update`]({params:{sessionID:t.sessionID,inboxID:t.inboxID},payload:{delivery:t.delivery}}).pipe(w(Q))),Zb=e=>t=>$()(e[`session.instructions.entry.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),Qb=e=>t=>$()(e[`session.instructions.entry.put`]({params:{sessionID:t.sessionID,key:t.key},payload:{value:t.value}}).pipe(w(Q))),$b=e=>t=>$()(e[`session.instructions.entry.remove`]({params:{sessionID:t.sessionID,key:t.key}}).pipe(w(Q))),ex=e=>t=>$()(e[`session.generate`]({params:{sessionID:t.sessionID},payload:{prompt:t.prompt}}).pipe(w(Q),j(e=>e.data))),tx=e=>t=>sb()(r(e[`session.log`]({params:{sessionID:t.sessionID},query:{after:t.after,follow:t.follow}}).pipe(w(Q),j(e=>e.pipe(pe(Q)))))),nx=e=>t=>$()(e[`session.interrupt`]({params:{sessionID:t.sessionID},query:{resume:t.resume}}).pipe(w(Q))),rx=e=>t=>$()(e[`session.background`]({params:{sessionID:t.sessionID}}).pipe(w(Q))),ix=e=>t=>$()(e[`session.message`]({params:{sessionID:t.sessionID,messageID:t.messageID}}).pipe(w(Q),j(e=>e.data))),ax=e=>t=>$()(e[`session.form.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),ox=e=>t=>$()(e[`session.form.create`]({params:{sessionID:t.sessionID},payload:{id:t.id,title:t.title,metadata:t.metadata,fields:t.fields}}).pipe(w(Q),j(e=>e.data))),sx=e=>t=>$()(e[`session.form.get`]({params:{sessionID:t.sessionID,formID:t.formID}}).pipe(w(Q),j(e=>e.data))),cx=e=>t=>$()(e[`session.form.reply`]({params:{sessionID:t.sessionID,formID:t.formID},payload:{answer:t.answer}}).pipe(w(Q))),lx=e=>t=>$()(e[`session.form.cancel`]({params:{sessionID:t.sessionID,formID:t.formID},query:{message:t.message}}).pipe(w(Q))),ux=e=>t=>$()(e[`session.environment`]({params:{sessionID:t.sessionID},payload:{variables:t.variables}}).pipe(w(Q))),dx=e=>t=>$()(e[`session.view`]({params:{sessionID:t.sessionID},payload:{idle:t.idle}}).pipe(w(Q))),fx=e=>({list:Cb(e),stats:wb(e),create:Tb(e),import:Eb(e),export:Db(e),active:Ob(e),get:kb(e),remove:Ab(e),fork:jb(e),switchAgent:Mb(e),switchModel:Nb(e),update:Pb(e),move:Fb(e),prompt:Ib(e),command:Lb(e),skill:Rb(e),synthetic:zb(e),shell:Bb(e),compact:Vb(e),wait:Hb(e),revert:{stage:Ub(e),clear:Wb(e),commit:Gb(e)},context:Kb(e),diff:qb(e),inbox:{list:Jb(e),cancel:Yb(e),update:Xb(e)},instructions:{entry:{list:Zb(e),put:Qb(e),remove:$b(e)}},generate:ex(e),log:tx(e),interrupt:nx(e),background:rx(e),message:{get:ix(e)},form:{list:ax(e),create:ox(e),get:sx(e),reply:cx(e),cancel:lx(e)},environment:ux(e),view:dx(e)}),px=e=>t=>$()(e[`session.messages`]({params:{sessionID:t.sessionID},query:{limit:t.limit,order:t.order,cursor:t.cursor,type:t.type}}).pipe(w(Q))),mx=e=>({list:px(e)}),hx=e=>t=>$()(e[`model.list`]({query:{location:t?.location,types:t?.types}}).pipe(w(Q))),gx=e=>t=>$()(e[`model.default`]({query:{location:t?.location}}).pipe(w(Q))),_x=e=>({list:hx(e),default:gx(e)}),vx=e=>t=>$()(e[`generate.text`]({payload:{prompt:t.prompt,model:t.model}}).pipe(w(Q),j(e=>e.data))),yx=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(w(Q),j(e=>e.data))),bx=e=>t=>$()(e[`generate.decisions`]({payload:{model:t.model,input:t.input,questions:t.questions}}).pipe(w(Q),j(e=>e.data))),xx=e=>({text:vx(e),image:yx(e),decisions:bx(e)}),Sx=e=>()=>$()(e[`voice.models`]({}).pipe(w(Q),j(e=>e.data))),Cx=e=>t=>$()(e[`voice.session`]({payload:{model:t.model,session:t.session,transport:t.transport}}).pipe(w(Q),j(e=>e.data))),wx=e=>({models:Sx(e),session:Cx(e)}),Tx=e=>t=>$()(e[`provider.list`]({query:{location:t?.location}}).pipe(w(Q))),Ex=e=>t=>$()(e[`provider.get`]({params:{providerID:t.providerID},query:{location:t.location}}).pipe(w(Q))),Dx=e=>({list:Tx(e),get:Ex(e)}),Ox=e=>t=>$()(e[`integration.list`]({query:{location:t?.location}}).pipe(w(Q))),kx=e=>t=>$()(e[`integration.get`]({params:{integrationID:t.integrationID},query:{location:t.location}}).pipe(w(Q))),Ax=e=>t=>$()(e[`integration.wellknown.add`]({query:{location:t.location},payload:{url:t.url}}).pipe(w(Q))),jx=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(w(Q))),Mx=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(w(Q))),Nx=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(w(Q))),Px=e=>t=>$()(e[`integration.oauth.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),Fx=e=>t=>$()(e[`integration.oauth.complete`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location},payload:{code:t.code}}).pipe(w(Q))),Ix=e=>t=>$()(e[`integration.oauth.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),Lx=e=>t=>$()(e[`integration.command.connect`]({params:{integrationID:t.integrationID},query:{location:t.location},payload:{methodID:t.methodID,label:t.label}}).pipe(w(Q))),Rx=e=>t=>$()(e[`integration.command.status`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),zx=e=>t=>$()(e[`integration.command.cancel`]({params:{integrationID:t.integrationID,attemptID:t.attemptID},query:{location:t.location}}).pipe(w(Q))),Bx=e=>({list:Ox(e),get:kx(e),wellknown:{add:Ax(e)},connect:{key:jx(e),external:Mx(e)},oauth:{connect:Nx(e),status:Px(e),complete:Fx(e),cancel:Ix(e)},command:{connect:Lx(e),status:Rx(e),cancel:zx(e)}}),Vx=e=>t=>$()(e[`mcp.list`]({query:{location:t?.location}}).pipe(w(Q))),Hx=e=>t=>$()(e[`mcp.add`]({params:{server:t.server},query:{location:t.location},payload:{config:t.config}}).pipe(w(Q))),Ux=e=>t=>$()(e[`mcp.remove`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),Wx=e=>t=>$()(e[`mcp.connect`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),Gx=e=>t=>$()(e[`mcp.disconnect`]({params:{server:t.server},query:{location:t.location}}).pipe(w(Q))),Kx=e=>t=>$()(e[`mcp.resource.catalog`]({query:{location:t?.location}}).pipe(w(Q))),qx=e=>t=>$()(e[`mcp.clientToken`]({query:{location:t.location,name:t.name},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q))),Jx=e=>({list:Vx(e),add:Hx(e),remove:Ux(e),connect:Wx(e),disconnect:Gx(e),resource:{catalog:Kx(e)},client:{token:qx(e)}}),Yx=e=>()=>$()(e[`credential.list`]({}).pipe(w(Q),j(e=>e.data))),Xx=e=>t=>$()(e[`credential.create`]({payload:{id:t.id,integrationID:t.integrationID,label:t.label,value:t.value,activate:t.activate}}).pipe(w(Q),j(e=>e.data))),Zx=e=>t=>$()(e[`credential.update`]({params:{credentialID:t.credentialID},payload:{label:t.label}}).pipe(w(Q))),Qx=e=>t=>$()(e[`credential.activate`]({params:{credentialID:t.credentialID}}).pipe(w(Q))),$x=e=>t=>$()(e[`credential.remove`]({params:{credentialID:t.credentialID}}).pipe(w(Q))),eS=e=>({list:Yx(e),create:Xx(e),update:Zx(e),activate:Qx(e),remove:$x(e)}),tS=e=>t=>$()(e[`project.list`]({query:{archived:t?.archived}}).pipe(w(Q))),nS=e=>t=>$()(e[`project.update`]({params:{projectID:t.projectID},payload:{canonical:t.canonical,name:t.name,icon:t.icon,commands:t.commands}}).pipe(w(Q))),rS=e=>({list:tS(e),update:nS(e)}),iS=e=>t=>$()(e[`form.list`]({query:{location:t?.location}}).pipe(w(Q))),aS=e=>({list:iS(e)}),oS=e=>t=>$()(e[`permission.request.list`]({query:{location:t?.location}}).pipe(w(Q))),sS=e=>t=>$()(e[`permission.saved.list`]({query:{projectID:t?.projectID}}).pipe(w(Q),j(e=>e.data))),cS=e=>t=>$()(e[`permission.saved.update`]({params:{id:t.id},payload:{action:t.action,resource:t.resource}}).pipe(w(Q),j(e=>e.data))),lS=e=>t=>$()(e[`permission.saved.remove`]({params:{id:t.id}}).pipe(w(Q))),uS=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(w(Q),j(e=>e.data))),dS=e=>t=>$()(e[`session.permission.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),fS=e=>t=>$()(e[`session.permission.get`]({params:{sessionID:t.sessionID,requestID:t.requestID}}).pipe(w(Q),j(e=>e.data))),pS=e=>t=>$()(e[`session.permission.reply`]({params:{sessionID:t.sessionID,requestID:t.requestID},payload:{decision:t.decision,message:t.message}}).pipe(w(Q))),mS=e=>({request:{list:oS(e)},saved:{list:sS(e),update:cS(e),remove:lS(e)},create:uS(e),list:dS(e),get:fS(e),reply:pS(e)}),hS=e=>t=>$()(e[`fs.list`]({query:{location:t?.location,path:t?.path}}).pipe(w(Q))),gS=e=>t=>$()(e[`fs.find`]({query:{location:t.location,query:t.query,type:t.type,limit:t.limit}}).pipe(w(Q))),_S=e=>t=>$()(e[`fs.watch`]({query:{location:t.location},payload:{path:t.path}}).pipe(w(Q))),vS=e=>t=>$()(e[`fs.unwatch`]({query:{location:t.location},payload:{path:t.path}}).pipe(w(Q))),yS=e=>({list:hS(e),find:gS(e),watch:_S(e),unwatch:vS(e)}),bS=e=>t=>$()(e[`command.list`]({query:{location:t?.location}}).pipe(w(Q))),xS=e=>({list:bS(e)}),SS=e=>t=>$()(e[`skill.list`]({query:{location:t?.location}}).pipe(w(Q))),CS=e=>({list:SS(e)}),wS=e=>t=>$()(e[`rpc.call`]({params:{rpcID:t.rpcID,method:t.method},query:{location:t.location},payload:{input:t.input}}).pipe(w(Q))),TS=e=>({call:wS(e)}),ES=e=>t=>sb()(r(e[`event.subscribe`]({query:{types:t?.types}}).pipe(w(Q),j(e=>e.pipe(pe(Q)))))),DS=e=>({subscribe:ES(e)}),OS=e=>t=>$()(e[`pty.list`]({query:{location:t?.location}}).pipe(w(Q))),kS=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(w(Q))),AS=e=>t=>$()(e[`pty.get`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(w(Q))),jS=e=>t=>$()(e[`pty.update`]({params:{ptyID:t.ptyID},query:{location:t.location},payload:{title:t.title,size:t.size}}).pipe(w(Q))),MS=e=>t=>$()(e[`pty.remove`]({params:{ptyID:t.ptyID},query:{location:t.location}}).pipe(w(Q))),NS=e=>t=>$()(e[`pty.connectToken`]({params:{ptyID:t.ptyID},query:{location:t.location},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q))),PS=e=>({list:OS(e),create:kS(e),get:AS(e),update:jS(e),remove:MS(e),connect:{token:NS(e)}}),FS=e=>t=>$()(e[`persistentPty.read`]({params:{sessionID:t.sessionID},query:{lines:t.lines}}).pipe(w(Q),j(e=>e.data))),IS=e=>t=>$()(e[`persistentPty.list`]({params:{sessionID:t.sessionID}}).pipe(w(Q),j(e=>e.data))),LS=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(w(Q),j(e=>e.data))),RS=e=>()=>$()(e[`persistentPty.shutdown`]({}).pipe(w(Q))),zS=e=>()=>$()(e[`persistentPty.handoff`]({}).pipe(w(Q))),BS=e=>t=>$()(e[`persistentPty.get`]({params:{ptyID:t.ptyID}}).pipe(w(Q),j(e=>e.data))),VS=e=>t=>$()(e[`persistentPty.update`]({params:{ptyID:t.ptyID},payload:{attachmentID:t.attachmentID,size:t.size}}).pipe(w(Q),j(e=>e.data))),HS=e=>t=>$()(e[`persistentPty.snapshot`]({params:{ptyID:t.ptyID}}).pipe(w(Q),j(e=>e.data))),US=e=>t=>$()(e[`persistentPty.remove`]({params:{ptyID:t.ptyID}}).pipe(w(Q))),WS=e=>t=>$()(e[`persistentPty.connectToken`]({params:{ptyID:t.ptyID},headers:{"x-opencode-ticket":t[`x-opencode-ticket`]}}).pipe(w(Q),j(e=>e.data))),GS=e=>({persistentPty:{read:FS(e),list:IS(e),create:LS(e),shutdown:RS(e),handoff:zS(e),get:BS(e),update:VS(e),snapshot:HS(e),remove:US(e),connectToken:WS(e)}}),KS=e=>t=>$()(e[`shell.list`]({query:{location:t?.location}}).pipe(w(Q))),qS=e=>t=>$()(e[`shell.create`]({query:{location:t.location},payload:{command:t.command,cwd:t.cwd,timeout:t.timeout,metadata:t.metadata}}).pipe(w(Q))),JS=e=>t=>$()(e[`shell.get`]({params:{id:t.id},query:{location:t.location}}).pipe(w(Q))),YS=e=>t=>$()(e[`shell.output`]({params:{id:t.id},query:{location:t.location,cursor:t.cursor,limit:t.limit}}).pipe(w(Q))),XS=e=>t=>$()(e[`shell.remove`]({params:{id:t.id},query:{location:t.location}}).pipe(w(Q))),ZS=e=>({list:KS(e),create:qS(e),get:JS(e),output:YS(e),remove:XS(e)}),QS=e=>t=>$()(e[`reference.list`]({query:{location:t?.location}}).pipe(w(Q))),$S=e=>({list:QS(e)}),eC=e=>t=>$()(e[`worktree.list`]({query:{projectID:t.projectID}}).pipe(w(Q))),tC=e=>t=>$()(e[`worktree.create`]({payload:{projectID:t.projectID,from:t.from,branch:t.branch,directory:t.directory,name:t.name}}).pipe(w(Q))),nC=e=>t=>$()(e[`worktree.remove`]({payload:{projectID:t.projectID,directory:t.directory,force:t.force}}).pipe(w(Q))),rC=e=>t=>$()(e[`worktree.refresh`]({payload:{projectID:t.projectID}}).pipe(w(Q))),iC=e=>({list:eC(e),create:tC(e),remove:nC(e),refresh:rC(e)}),aC=e=>t=>$()(e[`vcs.init`]({query:{location:t?.location,provider:t?.provider}}).pipe(w(Q))),oC=e=>t=>$()(e[`vcs.get`]({query:{location:t?.location}}).pipe(w(Q))),sC=e=>t=>$()(e[`vcs.base`]({query:{location:t?.location}}).pipe(w(Q))),cC=e=>t=>$()(e[`vcs.status`]({query:{location:t?.location}}).pipe(w(Q))),lC=e=>t=>$()(e[`vcs.branch.list`]({query:{location:t?.location,search:t?.search,limit:t?.limit}}).pipe(w(Q))),uC=e=>t=>$()(e[`vcs.diff`]({query:{location:t.location,mode:t.mode,base:t.base,context:t.context,untracked:t.untracked}}).pipe(w(Q))),dC=e=>({init:aC(e),get:oC(e),base:sC(e),status:cC(e),branch:{list:lC(e)},diff:uC(e)}),fC=e=>t=>$()(e[`debug.heapDump`]({query:{directory:t?.directory}}).pipe(w(Q))),pC=e=>()=>$()(e[`debug.location`]({}).pipe(w(Q))),mC=e=>t=>$()(e[`debug.location.evict`]({query:{location:t?.location}}).pipe(w(Q))),hC=e=>({heapDump:fC(e),location:{list:pC(e),evict:mC(e)}}),gC=e=>()=>$()(e[`migration.v1.status`]({}).pipe(w(Q))),_C=e=>({v1:{status:gC(e)}}),vC=e=>t=>$()(e[`websearch.providers`]({query:{location:t?.location}}).pipe(w(Q))),yC=e=>t=>$()(e[`websearch.query`]({query:{location:t.location},payload:{query:t.query,providerID:t.providerID}}).pipe(w(Q))),bC=e=>({providers:vC(e),query:yC(e)}),xC=e=>t=>$()(e[`usage.limits`]({query:{location:t?.location}}).pipe(w(Q))),SC=e=>({limits:xC(e)}),CC=e=>t=>$()(e[`config.get`]({query:{location:t?.location}}).pipe(w(Q))),wC=e=>()=>$()(e[`config.shells`]({}).pipe(w(Q))),TC=e=>t=>$()(e[`config.update`]({payload:{shell:t.shell}}).pipe(w(Q))),EC=e=>({get:CC(e),shells:wC(e),update:TC(e)}),DC=e=>({server:db(e[`server.server`]),location:mb(e[`server.location`]),agent:_b(e[`server.agent`]),plugin:Sb(e[`server.plugin`]),session:fx(e[`server.session`]),message:mx(e[`server.message`]),model:_x(e[`server.model`]),generate:xx(e[`server.generate`]),voice:wx(e[`server.voice`]),provider:Dx(e[`server.provider`]),integration:Bx(e[`server.integration`]),mcp:Jx(e[`server.mcp`]),credential:eS(e[`server.credential`]),project:rS(e[`server.project`]),form:aS(e[`server.form`]),permission:mS(e[`server.permission`]),file:yS(e[`server.fs`]),command:xS(e[`server.command`]),skill:CS(e[`server.skill`]),rpc:TS(e[`server.rpc`]),event:DS(e[`server.event`]),pty:PS(e[`server.pty`]),experimental:GS(e[`server.experimental`]),shell:ZS(e[`server.shell`]),reference:$S(e[`server.reference`]),worktree:iC(e[`server.worktree`]),vcs:dC(e[`server.vcs`]),debug:hC(e[`server.debug`]),migration:_C(e[`server.migration`]),websearch:bC(e[`server.websearch`]),usage:SC(e[`server.usage`]),config:EC(e[`server.config`])}),OC=e=>lt(ob,e).pipe(j(DC)),kC={};Rt(kC,{RpcRuntime:()=>kC,event:()=>MC,eventType:()=>NC,read:()=>AC,readError:()=>jC});function AC(e,t){return f(e)?He(e)(t):Ve(t)}function jC(e,t){return!(t instanceof Uo)&&!(t instanceof Wo)?ut(t):!e.errors||!Object.hasOwn(e.errors,t.type)?ut(t.data===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:t.data}):AC(e.errors[t.type],t.data).pipe(n(e=>bt(e)),vt(e=>ut(e===void 0?{type:t.type,message:t.message}:{type:t.type,message:t.message,data:e})))}var MC=$e(`Client.Rpc.event`)(function*(e,t,n,r){let i=yield*AC(n.schema,r.data);return{...r,type:NC(e,t),data:i}});function NC(e,t){return`rpc.${e.id}.${t}`}var PC={};Rt(PC,{RpcClientRuntime:()=>PC,aborted:()=>IC,make:()=>FC});function FC(e,t){return r=>{let i=Object.fromEntries(Object.entries(r.methods).map(([t,i])=>[t,(a,o)=>{let s=Fe(function*(){let n=yield*e({rpcID:r.id,method:t,input:a,location:o?.location},o);return yield*AC(i.output,n.output)}).pipe(n(e=>jC(i,e))),c=o?.signal;return c?ht(()=>c.aborted?pt:Ct(s,Ae(IC(c),pt))):s}]));return Object.assign(i,{events:{subscribe:e=>{let n=NC(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=>MC(r,e,i,t)))}}})}}function IC(e){return _e(t=>{if(e.aborted)return t(Xe);let n=()=>t(Xe);return e.addEventListener(`abort`,n,{once:!0}),st(()=>e.removeEventListener(`abort`,n))})}var LC={};Rt(LC,{OpenCode:()=>LC,make:()=>zC});var RC=Et(`@opencode/client/effect/rpc/headers`,{defaultValue:()=>{}}),zC=$e(`OpenCode.make`)(function*(e){let t=yield*Ye,n=yield*OC(e).pipe(it(Ye,qe(t,e=>j(RC,t=>t?je(e,new Headers(t)):e)))),r=yield*Ue(),i=n.event.subscribe();class a{cause;constructor(e){this.cause=e}}let o=Bt(e=>nt(i.pipe(d(IC(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:Je(new to({cause:e})))));return{...n,event:{...n.event,subscribe:c},rpc:Object.assign(FC((e,t)=>n.rpc.call(e).pipe(it(RC,t?.headers)),c),n.rpc)}}),BC=e({Answer:()=>WC,Prompt:()=>UC,Question:()=>BC}),VC=C({label:x.annotate({description:`Display text (1-5 words, concise)`}),description:x.annotate({description:`Explanation of choice`})}),HC={question:x.annotate({description:`Complete question`}),header:x.annotate({description:`Very short label (max 30 chars)`}),options:g(VC).annotate({description:`Available choices`}),multiple:v.pipe(B).annotate({description:`Allow selecting multiple choices`})},UC=C(HC).annotate({identifier:`Question.Prompt`}),WC=g(x).annotate({identifier:`Question.Answer`}),GC=e({AbsolutePath:()=>io,Agent:()=>Eu,ClientError:()=>to,Command:()=>sh,Config:()=>Rg,Credential:()=>ws,Event:()=>So,EventLog:()=>Am,FileSystem:()=>qm,Form:()=>zs,Integration:()=>uc,Location:()=>_o,Model:()=>$c,OpenCode:()=>LC,Permission:()=>mu,PermissionSaved:()=>Um,Project:()=>Nu,Prompt:()=>wl,PromptInput:()=>cm,Provider:()=>Fc,Pty:()=>ru,Question:()=>BC,Reference:()=>Nv,RelativePath:()=>ro,Session:()=>dp,SessionInbox:()=>of,SessionMessage:()=>ud,Skill:()=>jo,Vcs:()=>Ry,WebSearch:()=>Cg,Worktree:()=>Kg}),KC=20;function qC(e){return JSON.stringify([e.directory,e.workspaceID])}function JC(e){return{directory:e.directory}}function YC(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 XC(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 ZC(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:XC(e.state.content)}}:e)}:e}function QC(e,t){if(!(e!==`global`||!t))return{headers:{"x-opencode-directory":encodeURIComponent(t.directory)}}}function $C(){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 ew=200;function tw(e){let t=e.api,n=!1;si(()=>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;si(()=>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]=Ha({session:{info:{},family:{},active:{},message:{},messageCursor:{},messageLoading:{},pending:{},permission:{},form:{}},project:{info:{},permission:{}},location:{}}),[c,l]=qr({directory:e.directory}),u=Qr(()=>Object.values(o.session.info).toSorted((e,t)=>t.time.updated-e.time.updated)),d=new Map,f=t=>e.omitToolFileData?ZC(t):t,p=$C(),ee,te=new Map;function m(e,t){ee?.set(e,t),s(`session`,`active`,e,t)}function h(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 ne(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 re(e,t,n){let r=o.session.form[e];if(!r)return!1;let i=n&&qC(n),a=r.filter(n=>n.id===t?e!==`global`||!i?!1:!n.location||qC(n.location)!==i:!0);return a.length!==r.length&&(s(`session`,`form`,e,a),!0)}function ie(e,t,n){return n.catch(t=>{if(!fn(t)&&!mn(t)||t.id!==e.formID)throw t}).then(()=>{re(e.sessionID,e.formID,t)&&(b.session.form.invalidate(e.sessionID,t),b.session.form.sync(e.sessionID,t).catch(()=>{}))})}function ae(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 oe=new Set,se=new Set,ce=new Map,le=new Map,ue=new Map,de=new Map;si(()=>de.clear());function fe(e,t,n){e.set(t,n);let r=()=>{e.get(t)===n&&e.delete(t)};n.then(r,r)}function g(e,t,n){let r=ce.get(e),i=le.get(e),a=Promise.resolve().then(()=>Promise.all([n,r,i])).then(t);return fe(le,e,a.catch(()=>{})),a}function _(e){ri(()=>{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`&&pe(e)})}function pe(e){(e.type===`user`||e.type===`synthetic`)&&v.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 v.append(t,n,r);t[i]=r})}function me(e,t){ri(()=>{h(e,t),d.get(e)?.has(t)&&v.update(e,(e,n)=>{let r=n.get(t);r!==void 0&&(e.splice(r,1),n.delete(t),v.reindex(e,n,r))})})}let v={update(e,t){s(`session`,`message`,eo(n=>{t(n[e]??=[],he(e))}))},append(e,t,n){t.has(n.id)||(t.set(n.id,e.length),e.push(n))},insert(e,t){v.update(e,(e,n)=>v.append(e,n,t))},editAssistant(e,t,n){d.get(e)?.has(t)&&v.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){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`tool`&&e.id===n);t&&r(t)})},editText(e,t,n){v.editAssistant(e,t,e=>{let t=e.content.findLast(e=>e.type===`text`);t&&n(t)})},editReasoning(e,t,n){v.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 he(e){let t=d.get(e);if(t)return t;let n=new Map;return d.set(e,n),n}async function ge(e){let n=await t().session.list(e);return n.data.length<ew||!n.cursor.next?n.data:[...n.data,...await ge({cursor:n.cursor.next,limit:ew})]}function _e(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 ve(e){if(!o.session.info[e])return;let t=_e(e);s(`session`,`family`,eo(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 ye(e){if(se.has(e))return;p.invalidate(`session.pending:${e}`),p.invalidate(`session.message:${e}`),ue.delete(e);let t=o.session.pending[e]?.filter(e=>oe.has(e.id))??[],n=o.session.message[e]?.filter(e=>oe.has(e.id))??[];d.delete(e),n.length&&d.set(e,new Map(n.map((e,t)=>[e.id,t]))),s(`session`,eo(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 be(e){ee?.set(e,void 0),o.session.pending[e]?.forEach(e=>oe.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`,eo(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 xe(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`,Za(Object.fromEntries(n))),n.forEach((e,t)=>{e===`running`&&!o.session.info[t]&&r(()=>b.session.sync(t))})}).catch(()=>{ee===e&&(ee=void 0)})),r(()=>t().location.get({location:JC(c())}).then(e=>{let t=qC(e);s(`location`,t,{info:e})})),r(()=>b.location.vcs.sync()),r(()=>b.project.sync());return}case`project.updated`:s(`project`,`info`,n.data.id,Za(n.data));return;case`session.created`:se.delete(n.data.sessionID),b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID)),p.complete(`session.pending:${n.data.sessionID}`),p.complete(`session.message:${n.data.sessionID}`);return;case`session.deleted`:be(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),v.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;v.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=>{v.update(n.data.sessionID,(t,n)=>{let r=n.get(e.id);if(r===void 0)return v.append(t,n,e);t[r]=e})}));return}case`session.renamed`:r(()=>{let e=p.pending(`session.family:${n.data.sessionID}`)?b.session.sync(n.data.sessionID,{children:!0}):Promise.resolve();return Promise.all([b.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),v.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){b.session.invalidate(e),r(()=>b.session.sync(e));continue}let a=i_({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=b.session.input.has(n.data.sessionID,n.data.inboxID);h(n.data.sessionID,n.data.inboxID),v.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),v.reindex(t,r,i))}),de.get(n.data.sessionID)?.observed.add(n.data.inboxID);return}case`session.inbox.delivery.changed`:ae(n.data.sessionID,n.data.inboxID,n.data.delivery);return;case`session.inbox.cancelled`:me(n.data.sessionID,n.data.inboxID),de.get(n.data.sessionID)?.observed.add(n.data.inboxID);return;case`session.inbox.enqueued`:{oe.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),_(e),n.data.item.type===`compaction`){let e=de.get(n.data.sessionID);e?.observed.add(n.data.inboxID),e&&e.id!==n.data.inboxID&&oe.delete(e.id)&&h(n.data.sessionID,e.id)}return}case`session.instructions.updated`:let i=n.data.text;if(i===void 0)return;v.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`:v.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`:v.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;v.update(n.data.sessionID,e=>{let t=v.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`:v.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=v.activeAssistant(e);a&&(a.retry=void 0,a.time.completed=n.created),v.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`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.time.streamed=n.created});return;case`session.step.ended`:v.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`)&&y(n.location),v.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`:v.editAssistant(n.data.sessionID,n.data.assistantMessageID,e=>{e.content.push({type:`text`,text:``})});return;case`session.text.delta`:v.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.text.ended`:v.editText(n.data.sessionID,n.data.assistantMessageID,e=>{e.text=n.data.text});return;case`session.tool.input.started`:v.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`:v.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`:v.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`:v.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`:v.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`:v.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?XC(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`:v.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?XC(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`:v.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`:v.editReasoning(n.data.sessionID,n.data.assistantMessageID,e=>{e.text+=n.data.delta});return;case`session.reasoning.ended`:v.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`:v.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`:m(n.data.sessionID,`running`);return;case`session.compaction.started`:n.data.inputID&&h(n.data.sessionID,n.data.inputID),v.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&&de.get(n.data.sessionID)?.observed.add(n.data.inputID);return;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(m(n.data.sessionID,`idle`),v.update(n.data.sessionID,e=>{let t=v.activeAssistant(e);t&&(t.retry=void 0)}),n.type===`session.execution.interrupted`&&n.data.reason===`shutdown`||(v.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(()=>b.session.message.sync(n.data.sessionID))),!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`)))return;b.session.invalidate(n.data.sessionID),r(()=>b.session.sync(n.data.sessionID));return;case`session.viewed`:if(!o.session.info[n.data.sessionID]&&!p.has(`session:${n.data.sessionID}`))return;b.session.invalidate(n.data.sessionID),r(()=>b.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)),v.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;v.update(n.data.sessionID,e=>{let t=v.compaction(e);t?.status===`running`&&(t.summary+=n.data.text)});return;case`session.compaction.ended`:v.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}v.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&&h(n.data.sessionID,n.data.inputID),v.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}v.append(e,t,a)}),n.data.inputID&&de.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`:ne(n.data.sessionID,n.data.requestID);return;case`form.replied`:case`form.cancelled`:re(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(y(i),n.type===`credential.updated`){Ce(`integration`,b.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=Se(`integration`,i)||Se(`model`,i)||Se(`provider`,i);b.location.model.invalidate(i),b.location.provider.invalidate(i),a&&r(()=>Promise.all([b.location.model.sync(i),b.location.provider.sync(i)]))});return}if(!n.location)return;let i=n.location;switch(n.type){case`provider.updated`:Ce(`provider`,b.location.provider,i);break;case`model.updated`:Ce(`model`,b.location.model,i);break;case`agent.updated`:Ce(`agent`,b.location.agent,i);break;case`command.updated`:Ce(`command`,b.location.command,i);break;case`skill.updated`:Ce(`skill`,b.location.skill,i);break;case`vcs.branch.updated`:Ce(`vcs`,b.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`,qC(i),e=>({shell:{...e?.shell,[n.data.info.id]:{...n.data.info,location:i}}}));break;case`shell.exited`:case`shell.deleted`:if(!o.location[qC(i)]?.shell?.[n.data.id])break;s(`location`,qC(i),e=>({shell:Object.fromEntries(Object.entries(e?.shell??{}).filter(([e])=>e!==n.data.id))}));break;case`reference.updated`:Ce(`reference`,b.location.reference,i);break;case`integration.updated`:{y(i);let e=Se(`integration`,i)||Se(`model`,i)||Se(`provider`,i);b.location.integration.invalidate(i),b.location.model.invalidate(i),b.location.provider.invalidate(i),e&&r(()=>Promise.all([b.location.integration.sync(i),b.location.model.sync(i),b.location.provider.sync(i)]));break}case`config.updated`:Ce(`config`,b.location.config,i),Se(`websearch`,i)&&r(()=>b.location.websearch.refresh(i));break;case`websearch.updated`:Se(`websearch`,i)&&r(()=>b.location.websearch.refresh(i));break;case`mcp.status.changed`:{let e=Se(`mcpServer`,i);b.location.mcp.server.invalidate(i),e&&a(`mcp.status:${qC(i)}`,()=>b.location.mcp.server.sync(i));break}case`mcp.resources.changed`:Ce(`mcpResource`,b.location.mcp.resource,i)}}function Se(e,t){let n=qC(t??c());return o.location[n]?.[e]!==void 0||p.has(`location.${e}:${n}`)}function Ce(e,t,n){let i=Se(e,n);t.invalidate(n),i&&r(()=>t.sync(n))}function y(e){let t=o.location[qC(e)]?.usageLimits!==void 0||p.has(`location.usageLimits:${qC(e)}`);Ee.invalidate(e),t&&r(()=>Ee.sync(e))}function we(e,t,n){let r=(t,n)=>s(`location`,t,{[e]:n});return{list:t=>o.location[qC(t??c())]?.[e],sync:i=>{let a=i??c(),o=qC(a);return p.run(`location.${e}:${o}`,async()=>{let e=await t(JC(a)),i=qC(e.location);r(i,e.data),n?.alias&&i!==o&&r(o,e.data)})},invalidate:t=>p.invalidate(`location.${e}:${qC(t??c())}`)}}let Te=we(`vcs`,e=>t().vcs.get({location:e})),Ee=we(`usageLimits`,e=>t().usage.limits({location:e})),De=we(`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}]))}}),b={on:e.event.on,listen:e.event.listen,session:{list(){return u()},get(e){return o.session.info[e]},creating(e){return ce.has(e)},remember(e){ri(()=>{s(`session`,`info`,e.id,Za(e)),p.complete(`session:${e.id}`),ve(e.id)})},setStatus(e,t){m(e,t)},root(e){return _e(e)},family(e){return o.session.family[_e(e)]??[]},evict(e){let t=_e(e);ri(()=>{for(let n of new Set([t,e,...o.session.family[t]??[]]))ye(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=>oe.delete(e.id)),a.some(e=>e.type===`compaction`)&&o.session.pending[e]?.filter(e=>e.type===`compaction`).forEach(e=>oe.delete(e.id));let c=(o.session.pending[e]??[]).filter(e=>oe.has(e.id)),l=c.length===0?a:[...a,...c];ri(()=>{s(`session`,`pending`,e,Za(l)),l.forEach(pe)})}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??pu.create(),a=r.location??c(),s=!o.session.info[i];if(s){let e=Date.now();se.add(i),b.session.remember({id:i,projectID:n??o.location[qC(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=>(se.delete(i),b.session.remember(e),e)).catch(e=>{throw s&&se.delete(i)&&be(i),e});return s&&fe(ce,i,l),{id:i,request:l}},compact(e){let n=de.get(e.sessionID);if(n)return n.request;let r=K.create();o.session.pending[e.sessionID]?.some(e=>e.type===`compaction`)||(oe.add(r),_({id:r,sessionID:e.sessionID,time:{created:Date.now()},type:`compaction`,delivery:`steer`,payload:{}}));let i=new Set,a=g(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=>(ri(()=>{oe.delete(r),t.id!==r&&h(e.sessionID,r),!i.has(t.id)&&!d.get(e.sessionID)?.has(t.id)&&_(t)}),t)).catch(t=>{throw oe.delete(r)&&h(e.sessionID,r),t}).finally(()=>{de.get(e.sessionID)?.request===a&&de.delete(e.sessionID)});return de.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=YC(i.files),t={text:i.text,agents:i.agents?.map(e=>({...e})),metadata:i.metadata};e&&(t.files=e),oe.add(a),_({id:a,sessionID:i.sessionID,time:{created:Date.now()},type:`user`,delivery:i.delivery??`steer`,payload:t})}return g(i.sessionID,async()=>(await r?.(),t().session.prompt({...i,id:a})),n).catch(e=>{throw s&&oe.delete(a)&&me(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?ge({parentID:e,order:`desc`,limit:ew}):[]]),a=[r,...i];ri(()=>{s(`session`,`info`,eo(e=>{for(let t of a)e[t.id]=t}));for(let e of a)p.complete(`session:${e.id}`),ve(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?.()??KC,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)&&(oe.has(e.id)||c.has(e.id))),u=l.length===0?i:[...i,...l];ri(()=>{d.set(n,new Map(u.map((e,t)=>[e.id,t]))),s(`session`,`message`,n,Za(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(;ue.has(e);){let t=await(()=>{let t=ue.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:KC,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 ri(()=>{n?.beforePublish?.(),d.set(e,new Map(p.map((e,t)=>[e.id,t]))),s(`session`,`message`,e,Za(p)),s(`session`,`messageCursor`,e,c)}),!0})().catch(e=>{if(!r?.aborted)throw e}).finally(()=>s(`session`,`messageLoading`,e,!1));fe(ue,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(!En(e))throw e}),ne(e.sessionID,e.requestID)}},form:{list(e,t){let n=o.session.form[e];if(e!==`global`)return n;if(!t)return;let r=qC(t);return n?.filter(e=>e.location&&qC(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`?qC(n??c()):``}`;return p.run(r,async()=>{if(e===`global`){let r=await t().form.list({location:JC(n??c())}),i={directory:r.location.directory},a=qC(i);s(`session`,`form`,e,[...(o.session.form[e]??[]).filter(e=>e.location&&qC(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`?qC(t??c()):``}`)},reply(e,n){return ie(e,n,t().session.form.reply(e,QC(e.sessionID,n)))},cancel(e,n){return ie(e,n,t().session.form.cancel(e,QC(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`,Za(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(De.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:De.sync,invalidate:De.invalidate},location:{info(e){return o.location[qC(e??c())]?.info},default(){return c()},syncInfo(e){let n=e??c();return p.run(`location:${qC(n)}`,async()=>{let r=await t().location.get({location:JC(n)}),i=qC(r);o.location[i]||s(`location`,i,{}),s(`location`,i,`info`,r),e||l({directory:r.directory})})},async sync(e){await b.location.syncInfo(e);let t=e??c();await Promise.all([b.location.vcs.sync(t),b.location.agent.sync(t),b.location.command.sync(t),b.location.integration.sync(t),b.location.mcp.server.sync(t),b.location.mcp.resource.sync(t),b.location.model.sync(t),b.location.provider.sync(t),b.location.reference.sync(t),b.location.skill.sync(t),b.shell.sync(t),b.session.form.sync(`global`,t)])},invalidate(e){let t=e??c();p.invalidate(`location:${qC(t)}`),b.location.vcs.invalidate(t),b.location.agent.invalidate(t),b.location.command.invalidate(t),b.location.config.invalidate(t),b.location.integration.invalidate(t),b.location.mcp.server.invalidate(t),b.location.mcp.resource.invalidate(t),b.location.model.invalidate(t),b.location.provider.invalidate(t),b.location.reference.invalidate(t),b.location.skill.invalidate(t),b.shell.invalidate(t),b.session.form.invalidate(`global`,t)},vcs:{info:Te.list,sync:Te.sync,invalidate:Te.invalidate},usage:{limits:Ee.list,sync:Ee.sync,invalidate:Ee.invalidate},agent:we(`agent`,e=>t().agent.list({location:e})),command:we(`command`,e=>t().command.list({location:e})),config:we(`config`,async e=>({location:{directory:e.directory},data:await t().config.get({location:e})})),integration:we(`integration`,e=>t().integration.list({location:e})),mcp:{server:we(`mcpServer`,e=>t().mcp.list({location:e})),resource:we(`mcpResource`,async e=>{let n=await t().mcp.resource.catalog({location:e});return{location:n.location,data:n.data.resources}})},model:we(`model`,e=>t().model.list({location:e}),{alias:!0}),provider:we(`provider`,e=>t().provider.list({location:e}),{alias:!0}),reference:we(`reference`,e=>t().reference.list({location:e})),websearch:{list(e){return o.location[qC(e??c())]?.websearch},async refresh(e){let n={location:JC(e??c())},r=await t().websearch.providers(n),i=qC(r.location);s(`location`,i,{websearch:r.data})}},skill:we(`skill`,e=>t().skill.list({location:e}))}};return Xr(()=>{e.connection?.status()!==`connected`&&p.invalidate()}),si(e.event.listen(({details:e})=>{xe(e)})),b}var nw=2e3,rw=1e3,iw=50,aw=45e3,ow=2e4;function sw(e,t){let n=new AbortController,r=[],i=t.idleTimeout??45e3,[a,o]=Ha({status:`connecting`,attempt:0}),s=e,c=[],l,u,d,f,p=!1,ee=0,te=0,m=!1;function h(e,t,n){r.push({type:`client.connection`,created:Date.now(),data:{status:e,attempt:t,error:n}}),r.length>iw&&r.shift()}function ne(e){c.push(e),!l&&(l=setTimeout(()=>{l=void 0;let e=c;c=[],ri(()=>e.forEach(t.onEvent))},t.flushInterval??10))}async function re(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`)),nw);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{h(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),h(`connected`,n),r=Date.now(),f(),t.log?.info?.(`event stream connected`),ne(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}),ne(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 ie(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 re(i.signal,r);if(n.signal.removeEventListener(`abort`,a),n.signal.aborted||!p||ee!==e)return;c.connectedAt!==void 0&&Date.now()-c.connectedAt>=rw&&(r=0),r+=1;let l=cw(c.error);if(h(`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:cw(e)})});if(n.signal.aborted||i.signal.aborted||!p||ee!==e)return;if(a&&(s=a,r===1))continue}if(m){m=!1;continue}await lw(rw,i.signal)}}function ae(){if(p)return f;p=!0,m=!1;let e=++ee,t=f,n=(async()=>{t&&await t,await ie(e)})().finally(()=>{f===n&&(f=void 0)});return f=n,f}function oe(){p&&(p=!1,ee+=1,u?.abort(),o({status:`connecting`,attempt:0,error:void 0}))}function se(e){!p||a.status!==`connected`||(t.log?.info?.(`event stream resync`,{reason:e,idle:Date.now()-te}),m=!0,d?.abort(Error(e)))}if(t.pageLifecycle){let e=()=>oe(),t=()=>void ae(),n=()=>{document.visibilityState===`visible`&&(Date.now()-te<2e4||se(`Page returned to the foreground after the event stream went quiet`))},r=()=>se(`Network connection restored`);window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,t),window.addEventListener(`online`,r),document.addEventListener(`visibilitychange`,n),si(()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,r),document.removeEventListener(`visibilitychange`,n)})}return ae(),si(()=>{oe(),n.abort(),l&&clearTimeout(l),c=[]}),{status:()=>a.status,attempt:()=>a.attempt,error:()=>a.error,internal:{history:()=>r.slice(),resync:se}}}function cw(e){if(e!==void 0)return e instanceof Error?e.message:String(e)}function lw(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 uw(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 dw(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 fw(e){let t,n=[],r=new Map;Xr(()=>{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=>ii(()=>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));ii(()=>u.forEach(t=>e.session.evict(t))),r=new Map([...l].map(([e,t])=>[e,`${t}:${c(e)}`]))})}function pw(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 mw=e({createClientConnection:()=>sw,createData:()=>tw,createPersistentPtyClient:()=>dw,createPtyClient:()=>uw,createSessionRetention:()=>fw,defaultIdleTimeout:()=>aw,foregroundIdleThreshold:()=>ow,lastAssistantWithUsage:()=>pw,locationKey:()=>qC,settleMs:()=>150});export{di as A,Vt as B,qr as C,aa as D,ui as E,yi as F,$n as I,Rn as L,or as M,oa as N,ai as O,ii as P,In as R,Kr as S,li as T,ea as _,Ca as a,Qr as b,da as c,pa as d,Sa as f,ci as g,ri as h,Za as i,F as j,si as k,fa as l,ma as m,GC as n,Aa as o,xa as p,Ha as r,va as s,mw as t,ha as u,vi as v,$i as w,Yr as x,Xr as y,En as z};