@yuriai/web 0.2.0-beta.1 → 0.2.0-beta.2

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