@kortix/sdk 0.13.42 → 0.13.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.d.ts +1 -1
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +1 -0
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/kortix.esm.min.js +1 -1
- package/dist/kortix.global.js +1 -1
- package/dist/react/hold-live-start.d.ts +15 -0
- package/dist/react/hold-live-start.d.ts.map +1 -0
- package/dist/react/hold-live-start.js +38 -0
- package/dist/react/hold-live-start.js.map +1 -0
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +3 -1
- package/dist/react/use-session.js.map +1 -1
- package/package.json +2 -2
package/dist/kortix.esm.min.js
CHANGED
|
@@ -4,7 +4,7 @@ var Iy={backendUrl:"",getToken:async()=>null},yr=null,en=null;function Rk(e){en=
|
|
|
4
4
|
|
|
5
5
|
`);w=U.pop()??"";for(let b of U){let M=b.split(`
|
|
6
6
|
`),q=[],Q;for(let G of M)if(G.startsWith("data:"))q.push(G.replace(/^data:\s*/,""));else if(G.startsWith("event:"))Q=G.replace(/^event:\s*/,"");else if(G.startsWith("id:"))h=G.replace(/^id:\s*/,"");else if(G.startsWith("retry:")){let V=Number.parseInt(G.replace(/^retry:\s*/,""),10);Number.isNaN(V)||(v=V)}let B,W=!1;if(q.length){let G=q.join(`
|
|
7
|
-
`);try{B=JSON.parse(G),W=!0}catch{B=G}}W&&(s&&await s(B),r&&(B=await r(B))),n?.({data:B,event:Q,id:h,retry:v}),q.length&&(yield B)}}}finally{k.removeEventListener("abort",E),P.releaseLock()}break}catch(f){if(t?.(f),o!==void 0&&j>=o)break;let u=Math.min(v*2**(j-1),a??3e4);await _(u)}}}()}};var Ey=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},My=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Oy=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},tn=({allowReserved:e,explode:t,name:n,style:r,value:s})=>{if(!t){let a=(e?s:s.map(l=>encodeURIComponent(l))).join(My(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}let i=Ey(r),o=s.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):Ge({allowReserved:e,name:n,value:a})).join(i);return r==="label"||r==="matrix"?i+o:o},Ge=({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},nn=({allowReserved:e,explode:t,name:n,style:r,value:s,valueOnly:i})=>{if(s instanceof Date)return i?s.toISOString():`${n}=${s.toISOString()}`;if(r!=="deepObject"&&!t){let l=[];Object.entries(s).forEach(([m,h])=>{l=[...l,m,e?h:encodeURIComponent(h)]});let g=l.join(",");switch(r){case"form":return`${n}=${g}`;case"label":return`.${g}`;case"matrix":return`;${n}=${g}`;default:return g}}let o=Oy(r),a=Object.entries(s).map(([l,g])=>Ge({allowReserved:e,name:r==="deepObject"?`${n}[${l}]`:l,value:g})).join(o);return r==="label"||r==="matrix"?o+a:a};var jy=/\{[^{}]+\}/g,Dy=({path:e,url:t})=>{let n=t,r=t.match(jy);if(r)for(let s of r){let i=!1,o=s.substring(1,s.length-1),a="simple";o.endsWith("*")&&(i=!0,o=o.substring(0,o.length-1)),o.startsWith(".")?(o=o.substring(1),a="label"):o.startsWith(";")&&(o=o.substring(1),a="matrix");let l=e[o];if(l==null)continue;if(Array.isArray(l)){n=n.replace(s,tn({explode:i,name:o,style:a,value:l}));continue}if(typeof l=="object"){n=n.replace(s,nn({explode:i,name:o,style:a,value:l,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(s,`;${Ge({name:o,value:l})}`);continue}let g=encodeURIComponent(a==="label"?`.${l}`:l);n=n.replace(s,g)}return n},Fo=({baseUrl:e,path:t,query:n,querySerializer:r,url:s})=>{let i=s.startsWith("/")?s:`/${s}`,o=(e??"")+i;t&&(o=Dy({path:t,url:o}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(o+=`?${a}`),o};function _r(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}var No=async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n};var xr={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)};var Go=({parameters:e={},...t}={})=>r=>{let s=[];if(r&&typeof r=="object")for(let i in r){let o=r[i];if(o==null)continue;let a=e[i]||t;if(Array.isArray(o)){let l=tn({allowReserved:a.allowReserved,explode:!0,name:i,style:"form",value:o,...a.array});l&&s.push(l)}else if(typeof o=="object"){let l=nn({allowReserved:a.allowReserved,explode:!0,name:i,style:"deepObject",value:o,...a.object});l&&s.push(l)}else{let l=Ge({allowReserved:a.allowReserved,name:i,value:o});l&&s.push(l)}}return s.join("&")},Bo=e=>{if(!e)return"stream";let t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(n=>t.startsWith(n)))return"blob";if(t.startsWith("text/"))return"text"}},$y=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,Ko=async({security:e,...t})=>{for(let n of e){if($y(t,n.name))continue;let r=await No(n,t.auth);if(!r)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=r;break;case"cookie":t.headers.append("Cookie",`${s}=${r}`);break;default:t.headers.set(s,r);break}}},Pr=e=>Fo({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Go(e.querySerializer),url:e.url}),wr=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=rn(e.headers,t.headers),n},Uy=e=>{let t=[];return e.forEach((n,r)=>{t.push([r,n])}),t},rn=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let r=n instanceof Headers?Uy(n):Object.entries(n);for(let[s,i]of r)if(i===null)t.delete(s);else if(Array.isArray(i))for(let o of i)t.append(s,o);else i!==void 0&&t.set(s,typeof i=="object"?JSON.stringify(i):i)}return t},lt=class{fns=[];clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let r=this.getInterceptorIndex(t);return this.fns[r]?(this.fns[r]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}},Wo=()=>({error:new lt,request:new lt,response:new lt}),Ly=Go({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),qy={"Content-Type":"application/json"},ut=(e={})=>({...xr,headers:qy,parseAs:"auto",querySerializer:Ly,...e});var pt=(e={})=>{let t=wr(ut(),e),n=()=>({...t}),r=g=>(t=wr(t,g),n()),s=Wo(),i=async g=>{let m={...t,...g,fetch:g.fetch??t.fetch??globalThis.fetch,headers:rn(t.headers,g.headers),serializedBody:void 0};m.security&&await Ko({...m,security:m.security}),m.requestValidator&&await m.requestValidator(m),m.body!==void 0&&m.bodySerializer&&(m.serializedBody=m.bodySerializer(m.body)),(m.body===void 0||m.serializedBody==="")&&m.headers.delete("Content-Type");let h=Pr(m);return{opts:m,url:h}},o=async g=>{let{opts:m,url:h}=await i(g),_={redirect:"follow",...m,body:_r(m)},S=new Request(h,_);for(let x of s.request.fns)x&&(S=await x(S,m));let A=m.fetch,v;try{v=await A(S)}catch(x){let C=x;for(let P of s.error.fns)P&&(C=await P(x,void 0,S,m));if(C=C||{},m.throwOnError)throw C;return m.responseStyle==="data"?void 0:{error:C,request:S,response:void 0}}for(let x of s.response.fns)x&&(v=await x(v,S,m));let j={request:S,response:v};if(v.ok){let x=(m.parseAs==="auto"?Bo(v.headers.get("Content-Type")):m.parseAs)??"json";if(v.status===204||v.headers.get("Content-Length")==="0"){let P;switch(x){case"arrayBuffer":case"blob":case"text":P=await v[x]();break;case"formData":P=new FormData;break;case"stream":P=v.body;break;default:P={};break}return m.responseStyle==="data"?P:{data:P,...j}}let C;switch(x){case"arrayBuffer":case"blob":case"formData":case"text":C=await v[x]();break;case"json":{let P=await v.text();C=P?JSON.parse(P):{};break}case"stream":return m.responseStyle==="data"?v.body:{data:v.body,...j}}return x==="json"&&(m.responseValidator&&await m.responseValidator(C),m.responseTransformer&&(C=await m.responseTransformer(C))),m.responseStyle==="data"?C:{data:C,...j}}let k=await v.text(),d;try{d=JSON.parse(k)}catch{}let f=d??k,u=f;for(let x of s.error.fns)x&&(u=await x(f,v,S,m));if(u=u||{},m.throwOnError)throw u;return m.responseStyle==="data"?void 0:{error:u,...j}},a=g=>m=>o({...m,method:g}),l=g=>async m=>{let{opts:h,url:_}=await i(m);return qo({...h,body:h.body,headers:h.headers,method:g,onRequest:async(S,A)=>{let v=new Request(S,A);for(let j of s.request.fns)j&&(v=await j(v,h));return v},serializedBody:_r(h),url:_})};return{buildUrl:Pr,connect:a("CONNECT"),delete:a("DELETE"),get:a("GET"),getConfig:n,head:a("HEAD"),interceptors:s,options:a("OPTIONS"),patch:a("PATCH"),post:a("POST"),put:a("PUT"),request:o,setConfig:r,sse:{connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:a("TRACE")}};var Fy={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Ny=Object.entries(Fy),Ho=(e,t)=>{t||(t=new Map);for(let n of e)"in"in n?n.key&&t.set(n.key,{in:n.in,map:n.map}):"key"in n?t.set(n.key,{map:n.map}):n.args&&Ho(n.args,t);return t},Gy=e=>{for(let[t,n]of Object.entries(e))n&&typeof n=="object"&&!Object.keys(n).length&&delete e[t]},y=(e,t)=>{let n={body:{},headers:{},path:{},query:{}},r=Ho(t),s;for(let[i,o]of e.entries())if(t[i]&&(s=t[i]),!!s)if("in"in s)if(s.key){let a=r.get(s.key),l=a.map||s.key;a.in&&(n[a.in][l]=o)}else n.body=o;else for(let[a,l]of Object.entries(o??{})){let g=r.get(a);if(g)if(g.in){let m=g.map||a;n[g.in][m]=l}else n[g.map]=l;else{let m=Ny.find(([h])=>a.startsWith(h));if(m){let[h,_]=m;n[_][a.slice(h.length)]=l}else if("allowExtra"in s&&s.allowExtra){for(let[h,_]of Object.entries(s.allowExtra))if(_){n[h][a]=l;break}}}}return Gy(n),n};var zo=pt(ut({baseUrl:"http://localhost:4096"}));var I=class{client;constructor(t){this.client=t?.client??zo}},Sr=class{defaultKey="default";instances=new Map;get(t){let n=this.instances.get(t??this.defaultKey);if(!n)throw new Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return n}set(t,n){this.instances.set(n??this.defaultKey,t)}},kr=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"}]}]);return(n?.client??this.client).delete({url:"/auth/{providerID}",...n,...r})}set(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return(n?.client??this.client).put({url:"/auth/{providerID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},vr=class extends I{log(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"service"},{in:"body",key:"level"},{in:"body",key:"message"},{in:"body",key:"extra"}]}]);return(n?.client??this.client).post({url:"/log",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}agents(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/agent",...n,...r})}skills(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/skill",...n,...r})}},Ar=class extends I{moveSession(t,n){let r=y([t],[{args:[{in:"body",key:"sessionID"},{in:"body",key:"destination"},{in:"body",key:"moveChanges"}]}]);return(n?.client??this.client).post({url:"/experimental/control-plane/move-session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Rr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/capabilities",...n,...r})}},Tr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/console",...n,...r})}listOrgs(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/console/orgs",...n,...r})}switchOrg(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"accountID"},{in:"body",key:"orgID"}]}]);return(n?.client??this.client).post({url:"/experimental/console/switch",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Cr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"cursor"},{in:"query",key:"search"},{in:"query",key:"limit"},{in:"query",key:"archived"}]}]);return(n?.client??this.client).get({url:"/experimental/session",...n,...r})}background(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/experimental/session/{sessionID}/background",...n,...r})}},Ir=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/resource",...n,...r})}},Er=class extends I{generateName(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"context"}]}]);return(n?.client??this.client).post({url:"/experimental/project/{projectID}/copy/generate-name",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Mr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/workspace/adapter",...n,...r})}},Or=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/workspace",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"type"},{in:"body",key:"branch"},{in:"body",key:"extra"}]}]);return(n?.client??this.client).post({url:"/experimental/workspace",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}syncList(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/experimental/workspace/sync-list",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/workspace/status",...n,...r})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"id"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/experimental/workspace/{id}",...n,...r})}warp(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"sessionID"},{in:"body",key:"copyChanges"}]}]);return(n?.client??this.client).post({url:"/experimental/workspace/warp",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_adapter;get adapter(){return this._adapter??=new Mr({client:this.client})}},jr=class extends I{_controlPlane;get controlPlane(){return this._controlPlane??=new Ar({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new Rr({client:this.client})}_console;get console(){return this._console??=new Tr({client:this.client})}_session;get session(){return this._session??=new Cr({client:this.client})}_resource;get resource(){return this._resource??=new Ir({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Er({client:this.client})}_workspace;get workspace(){return this._workspace??=new Or({client:this.client})}},Dr=class extends I{get(t){return(t?.client??this.client).get({url:"/global/config",...t})}update(t,n){let r=y([t],[{args:[{key:"config",map:"body"}]}]);return(n?.client??this.client).patch({url:"/global/config",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},$r=class extends I{health(t){return(t?.client??this.client).get({url:"/global/health",...t})}event(t){return(t?.client??this.client).sse.get({url:"/global/event",...t})}dispose(t){return(t?.client??this.client).post({url:"/global/dispose",...t})}upgrade(t,n){let r=y([t],[{args:[{in:"body",key:"target"}]}]);return(n?.client??this.client).post({url:"/global/upgrade",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_config;get config(){return this._config??=new Dr({client:this.client})}},Ur=class extends I{subscribe(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).sse.get({url:"/event",...n,...r})}},Lr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/config",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"config",map:"body"}]}]);return(n?.client??this.client).patch({url:"/config",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}providers(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/config/providers",...n,...r})}},qr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return(n?.client??this.client).get({url:"/experimental/tool",...n,...r})}ids(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/tool/ids",...n,...r})}},Fr=class extends I{remove(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeRemoveInput",map:"body"}]}]);return(n?.client??this.client).delete({url:"/experimental/worktree",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/worktree",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeCreateInput",map:"body"}]}]);return(n?.client??this.client).post({url:"/experimental/worktree",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}reset(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeResetInput",map:"body"}]}]);return(n?.client??this.client).post({url:"/experimental/worktree/reset",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Nr=class extends I{text(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"pattern"}]}]);return(n?.client??this.client).get({url:"/find",...n,...r})}files(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"},{in:"query",key:"dirs"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(n?.client??this.client).get({url:"/find/file",...n,...r})}symbols(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"}]}]);return(n?.client??this.client).get({url:"/find/symbol",...n,...r})}},Gr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(n?.client??this.client).get({url:"/file",...n,...r})}read(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(n?.client??this.client).get({url:"/file/content",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/file/status",...n,...r})}},Br=class extends I{dispose(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/instance/dispose",...n,...r})}},Kr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/path",...n,...r})}},Wr=class extends I{raw(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/vcs/diff/raw",...n,...r})}},Hr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/vcs",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/vcs/status",...n,...r})}diff(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"mode"},{in:"query",key:"context"}]}]);return(n?.client??this.client).get({url:"/vcs/diff",...n,...r})}apply(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"patch"}]}]);return(n?.client??this.client).post({url:"/vcs/apply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_diff;get diff2(){return this._diff??=new Wr({client:this.client})}},zr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/command",...n,...r})}},Vr=class extends I{status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/lsp",...n,...r})}},Yr=class extends I{status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/formatter",...n,...r})}},Xr=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/mcp/{name}/auth",...n,...r})}start(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/auth",...n,...r})}callback(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"code"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/auth/callback",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}authenticate(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...n,...r})}},Jr=class extends I{status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/mcp",...n,...r})}add(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return(n?.client??this.client).post({url:"/mcp",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}connect(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/connect",...n,...r})}disconnect(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/disconnect",...n,...r})}_auth;get auth(){return this._auth??=new Xr({client:this.client})}},Qr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/project",...n,...r})}current(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/project/current",...n,...r})}initGit(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/project/git/init",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"icon"},{in:"body",key:"commands"}]}]);return(n?.client??this.client).patch({url:"/project/{projectID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}directories(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/project/{projectID}/directories",...n,...r})}},Zr=class extends I{shells(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/pty/shells",...n,...r})}list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/pty",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(n?.client??this.client).post({url:"/pty",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/pty/{ptyID}",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/pty/{ptyID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(n?.client??this.client).put({url:"/pty/{ptyID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}connectToken(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/pty/{ptyID}/connect-token",...n,...r})}connect(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(n?.client??this.client).get({url:"/pty/{ptyID}/connect",...n,...r})}},es=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/question",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"answers"}]}]);return(n?.client??this.client).post({url:"/question/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}reject(t,n){let r=y([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/question/{requestID}/reject",...n,...r})}},ts=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/permission",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(n?.client??this.client).post({url:"/permission/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}respond(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"response"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},ns=class extends I{authorize(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"inputs"}]}]);return(n?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}callback(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return(n?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},rs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/provider",...n,...r})}auth(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/provider/auth",...n,...r})}_oauth;get oauth(){return this._oauth??=new ns({client:this.client})}},ss=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"scope"},{in:"query",key:"path"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"search"},{in:"query",key:"limit"}]}]);return(n?.client??this.client).get({url:"/session",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"parentID"},{in:"body",key:"title"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"workspaceID"}]}]);return(n?.client??this.client).post({url:"/session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/status",...n,...r})}delete(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"time"}]}]);return(n?.client??this.client).patch({url:"/session/{sessionID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}children(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/children",...n,...r})}todo(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/todo",...n,...r})}diff(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"messageID"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/diff",...n,...r})}messages(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"before"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/message",...n,...r})}prompt(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/message",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}deleteMessage(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}",...n,...r})}message(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...n,...r})}fork(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/fork",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}abort(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/abort",...n,...r})}init(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"modelID"},{in:"body",key:"providerID"},{in:"body",key:"messageID"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/init",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}unshare(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}/share",...n,...r})}share(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/share",...n,...r})}summarize(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"providerID"},{in:"body",key:"modelID"},{in:"body",key:"auto"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/summarize",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}promptAsync(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}command(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"arguments"},{in:"body",key:"command"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/command",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}shell(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"command"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/shell",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}revert(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/revert",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}unrevert(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/unrevert",...n,...r})}},is=class extends I{delete(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"part",map:"body"}]}]);return(n?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},os=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(n?.client??this.client).post({url:"/sync/history",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},as=class extends I{start(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/sync/start",...n,...r})}replay(t,n){let r=y([t],[{args:[{in:"query",key:"query_directory",map:"directory"},{in:"query",key:"workspace"},{in:"body",key:"body_directory",map:"directory"},{in:"body",key:"events"}]}]);return(n?.client??this.client).post({url:"/sync/replay",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}steal(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/sync/steal",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_history;get history(){return this._history??=new os({client:this.client})}},cs=class extends I{next(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/tui/control/next",...n,...r})}response(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(n?.client??this.client).post({url:"/tui/control/response",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},ls=class extends I{appendPrompt(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"text"}]}]);return(n?.client??this.client).post({url:"/tui/append-prompt",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}openHelp(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-help",...n,...r})}openSessions(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-sessions",...n,...r})}openThemes(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-themes",...n,...r})}openModels(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-models",...n,...r})}submitPrompt(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/submit-prompt",...n,...r})}clearPrompt(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/clear-prompt",...n,...r})}executeCommand(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"}]}]);return(n?.client??this.client).post({url:"/tui/execute-command",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}showToast(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"message"},{in:"body",key:"variant"},{in:"body",key:"duration"}]}]);return(n?.client??this.client).post({url:"/tui/show-toast",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}publish(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(n?.client??this.client).post({url:"/tui/publish",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}selectSession(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/tui/select-session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_control;get control(){return this._control??=new cs({client:this.client})}},us=class extends I{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},ps=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/location",...n,...r})}},ds=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/agent",...n,...r})}},gs=class extends I{stage(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"messageID"},{in:"body",key:"files"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/revert/stage",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}clear(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/revert/clear",...n,...r})}commit(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/revert/commit",...n,...r})}},ms=class extends I{list(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/permission",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"action"},{in:"body",key:"resources"},{in:"body",key:"save"},{in:"body",key:"metadata"},{in:"body",key:"source"},{in:"body",key:"agent"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/permission",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}get(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/permission/{requestID}",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/permission/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},fs=class extends I{list(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/question",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{key:"questionV2Reply",map:"body"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}reject(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reject",...n,...r})}},ys=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"search"},{in:"query",key:"directory"},{in:"query",key:"project"},{in:"query",key:"subpath"},{in:"query",key:"cursor"}]}]);return(n?.client??this.client).get({url:"/api/session",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"body",key:"id"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"location"}]}]);return(n?.client??this.client).post({url:"/api/session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}active(t){return(t?.client??this.client).get({url:"/api/session/active",...t})}get(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}",...n,...r})}switchAgent(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"agent"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/agent",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}switchModel(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"model"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/model",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}prompt(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"prompt"},{in:"body",key:"delivery"},{in:"body",key:"resume"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/prompt",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}compact(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/compact",...n,...r})}wait(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/wait",...n,...r})}context(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/context",...n,...r})}history(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"after"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/history",...n,...r})}events(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"after"}]}]);return(n?.client??this.client).sse.get({url:"/api/session/{sessionID}/event",...n,...r})}interrupt(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/interrupt",...n,...r})}message(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/message/{messageID}",...n,...r})}messages(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"cursor"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/message",...n,...r})}_revert;get revert(){return this._revert??=new gs({client:this.client})}_permission;get permission(){return this._permission??=new ms({client:this.client})}_question;get question(){return this._question??=new fs({client:this.client})}},hs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/model",...n,...r})}},bs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/provider",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/provider/{providerID}",...n,...r})}},_s=class extends I{key(t,n){let r=y([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"key"},{in:"body",key:"label"}]}]);return(n?.client??this.client).post({url:"/api/integration/{integrationID}/connect/key",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}oauth(t,n){let r=y([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"methodID"},{in:"body",key:"inputs"},{in:"body",key:"label"}]}]);return(n?.client??this.client).post({url:"/api/integration/{integrationID}/connect/oauth",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},xs=class extends I{cancel(t,n){let r=y([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).delete({url:"/api/integration/attempt/{attemptID}",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/integration/attempt/{attemptID}",...n,...r})}complete(t,n){let r=y([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"},{in:"body",key:"code"}]}]);return(n?.client??this.client).post({url:"/api/integration/attempt/{attemptID}/complete",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Ps=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/integration",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/integration/{integrationID}",...n,...r})}_connect;get connect(){return this._connect??=new _s({client:this.client})}_attempt;get attempt(){return this._attempt??=new xs({client:this.client})}},ws=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).delete({url:"/api/credential/{credentialID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"},{in:"body",key:"label"}]}]);return(n?.client??this.client).patch({url:"/api/credential/{credentialID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Ss=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/permission/request",...n,...r})}},ks=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"projectID"}]}]);return(n?.client??this.client).get({url:"/api/permission/saved",...n,...r})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"id"}]}]);return(n?.client??this.client).delete({url:"/api/permission/saved/{id}",...n,...r})}},vs=class extends I{_request;get request(){return this._request??=new Ss({client:this.client})}_saved;get saved(){return this._saved??=new ks({client:this.client})}},As=class extends I{read(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/fs/read/*",...n,...r})}list(t,n){let r=y([t],[{args:[{in:"query",key:"location"},{in:"query",key:"path"}]}]);return(n?.client??this.client).get({url:"/api/fs/list",...n,...r})}find(t,n){let r=y([t],[{args:[{in:"query",key:"location"},{in:"query",key:"query"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(n?.client??this.client).get({url:"/api/fs/find",...n,...r})}},Rs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/command",...n,...r})}},Ts=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/skill",...n,...r})}},Cs=class extends I{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},Is=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/pty",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"location"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(n?.client??this.client).post({url:"/api/pty",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).delete({url:"/api/pty/{ptyID}",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/pty/{ptyID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(n?.client??this.client).put({url:"/api/pty/{ptyID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}connectToken(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).post({url:"/api/pty/{ptyID}/connect-token",...n,...r})}connect(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location[directory]"},{in:"query",key:"location[workspace]"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(n?.client??this.client).get({url:"/api/pty/{ptyID}/connect",...n,...r})}},Es=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/question/request",...n,...r})}},Ms=class extends I{_request;get request(){return this._request??=new Es({client:this.client})}},Os=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/reference",...n,...r})}},js=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"directory"},{in:"body",key:"force"}]}]);return(n?.client??this.client).delete({url:"/experimental/project/{projectID}/copy",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}create(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"strategy"},{in:"body",key:"directory"},{in:"body",key:"name"}]}]);return(n?.client??this.client).post({url:"/experimental/project/{projectID}/copy",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}refresh(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).post({url:"/experimental/project/{projectID}/copy/refresh",...n,...r})}},Ds=class extends I{_health;get health(){return this._health??=new us({client:this.client})}_location;get location(){return this._location??=new ps({client:this.client})}_agent;get agent(){return this._agent??=new ds({client:this.client})}_session;get session(){return this._session??=new ys({client:this.client})}_model;get model(){return this._model??=new hs({client:this.client})}_provider;get provider(){return this._provider??=new bs({client:this.client})}_integration;get integration(){return this._integration??=new Ps({client:this.client})}_credential;get credential(){return this._credential??=new ws({client:this.client})}_permission;get permission(){return this._permission??=new vs({client:this.client})}_fs;get fs(){return this._fs??=new As({client:this.client})}_command;get command(){return this._command??=new Rs({client:this.client})}_skill;get skill(){return this._skill??=new Ts({client:this.client})}_event;get event(){return this._event??=new Cs({client:this.client})}_pty;get pty(){return this._pty??=new Is({client:this.client})}_question;get question(){return this._question??=new Ms({client:this.client})}_reference;get reference(){return this._reference??=new Os({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new js({client:this.client})}},sn=class e extends I{static __registry=new Sr;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new kr({client:this.client})}_app;get app(){return this._app??=new vr({client:this.client})}_experimental;get experimental(){return this._experimental??=new jr({client:this.client})}_global;get global(){return this._global??=new $r({client:this.client})}_event;get event(){return this._event??=new Ur({client:this.client})}_config;get config(){return this._config??=new Lr({client:this.client})}_tool;get tool(){return this._tool??=new qr({client:this.client})}_worktree;get worktree(){return this._worktree??=new Fr({client:this.client})}_find;get find(){return this._find??=new Nr({client:this.client})}_file;get file(){return this._file??=new Gr({client:this.client})}_instance;get instance(){return this._instance??=new Br({client:this.client})}_path;get path(){return this._path??=new Kr({client:this.client})}_vcs;get vcs(){return this._vcs??=new Hr({client:this.client})}_command;get command(){return this._command??=new zr({client:this.client})}_lsp;get lsp(){return this._lsp??=new Vr({client:this.client})}_formatter;get formatter(){return this._formatter??=new Yr({client:this.client})}_mcp;get mcp(){return this._mcp??=new Jr({client:this.client})}_project;get project(){return this._project??=new Qr({client:this.client})}_pty;get pty(){return this._pty??=new Zr({client:this.client})}_question;get question(){return this._question??=new es({client:this.client})}_permission;get permission(){return this._permission??=new ts({client:this.client})}_provider;get provider(){return this._provider??=new rs({client:this.client})}_session;get session(){return this._session??=new ss({client:this.client})}_part;get part(){return this._part??=new is({client:this.client})}_sync;get sync(){return this._sync??=new as({client:this.client})}_tui;get tui(){return this._tui??=new ls({client:this.client})}_v2;get v2(){return this._v2??=new Ds({client:this.client})}};function Yo(e,t,n,r){if(!r?.throwOnError||e instanceof Error)return e;if(typeof e=="object"&&e!==null&&Object.keys(e).length>0){let i=e,o=typeof i.data?.message=="string"&&i.data.message||typeof i.message=="string"&&i.message||typeof i.name=="string"&&i.name||Vo(n,t);return new Error(o,{cause:{body:e,status:t?.status}})}if(typeof e=="string"&&e.length>0)return new Error(e,{cause:{body:e,status:t?.status}});let s=t?"(empty response body)":"network error (no response)";return new Error(`opencode server ${Vo(n,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function Vo(e,t){let n=e?.method??"?",r=e?.url??"?",s=t?.status,i=t?.statusText;return`${n} ${r}${s?" \u2192 "+s:""}${i?" "+i:""}`}function By(e,t,n){if(e)return t&&(e===t||n&&e===n(t))?t:e}function Ky(e,t){if(e.method!=="GET"&&e.method!=="HEAD")return e;let n=new URL(e.url),r=!1;for(let[i,o]of[["x-opencode-directory","directory"],["x-opencode-workspace","workspace"]]){let a=By(e.headers.get(i),o==="directory"?t.directory:t.workspace,o==="directory"?encodeURIComponent:void 0);if(a){for(let l of n.pathname.startsWith("/api/")?[o,`location[${o}]`]:[o])n.searchParams.has(l)||n.searchParams.set(l,a);r=!0}}if(!r)return e;let s=new Request(n,e);return s.headers.delete("x-opencode-directory"),s.headers.delete("x-opencode-workspace"),s}function $s(e){e?.fetch||(e={...e,fetch:r=>(r.timeout=!1,fetch(r))}),e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)}),e?.experimental_workspaceID&&(e.headers={...e.headers,"x-opencode-workspace":e.experimental_workspaceID});let t=pt(e);return t.interceptors.request.use(n=>Ky(n,{directory:e?.directory,workspace:e?.experimental_workspaceID})),t.interceptors.response.use(n=>{if(n.headers.get("content-type")==="text/html")throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");return n}),t.interceptors.error.use(Yo),new sn({client:t})}var Wy=new Set(["api","cli","mobile","tui","web"]);function Xo(e){let t=e?.trim().toLowerCase();return t&&Wy.has(t)?t:null}function Hy(e){return new Promise(t=>setTimeout(t,e))}async function on(e,t,n){let r=Math.max(1,t?.attempts??1),s=t?.baseDelayMs??0,i=t?.invalidateBetweenAttempts??!1,o=null;for(let a=0;a<r;a++)if(a>0&&(i&&n?.(),s>0&&await Hy(s)),o=await e(),o)return o;return o}var Us=12e4;function zy(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function Jo(e,t,n=Us){let r=e instanceof Request?e.signal:t?.signal;if(zy(e))return r??void 0;let s=AbortSignal.timeout(n);return r?typeof AbortSignal.any=="function"?AbortSignal.any([r,s]):r:s}function an(){return new Response(JSON.stringify({error:"Not authenticated"}),{status:401,headers:{"Content-Type":"application/json"}})}var T=class extends Error{status;code;details;data;detail;response;url;endpoint;timeout;constructor(t,n={}){super(t),this.name="ApiError";let{name:r,stack:s,...i}=n;Object.assign(this,i),r&&(this.name=r),s&&(this.stack=s);let o=typeof t=="string"?t:t==null?"":String(t);Object.defineProperty(this,"message",{value:o,enumerable:!0,writable:!0,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype)}},ce=class extends T{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},je=class extends T{constructor(t,n,r,s={}){super(r||n.message||`Billing Error: ${t}`,{...s,status:t,detail:n}),this.name="BillingError"}},Be=class extends T{constructor(t=431,n,r){let s="Request headers are too large";super(r||n?.message||s,{status:t,detail:{message:n?.message||s,suggestion:n?.suggestion||"Try uploading files one at a time, or reduce the number of files in a single request."}}),this.name="RequestTooLargeError"}},Vy="ENDPOINT_RETIRED";function H(e,t){let n=t?` ${t}`:"";return new T(`${e}() is retired: the Kortix API no longer serves this endpoint.${n}`,{code:Vy})}var Ls="feature_disabled";function Qo(e){if(!(e instanceof T)||e.status!==403||e.code!==Ls)return null;let t=e.details??e.data;return t&&typeof t=="object"?t:{}}function Zo(e){let t=Qo(e);return t?(typeof t.feature=="string"&&!e.feature&&(e.feature=t.feature),!0):!1}function ea(e){let t=Qo(e);if(!t)return null;let n=e.feature;return typeof n=="string"?n:typeof t.feature=="string"?t.feature:null}function cn(e){let t=e.response?.status||e.status;if(t!==402)return e;let n=e.response?.data||e.data||e.detail||{},r=n?.detail||n;return new je(t,{message:r?.message||e.message||"Billing error",...r},void 0,{code:e.code,details:e.details,data:e.data,response:e.response,url:e.url,endpoint:e.endpoint})}function ta(e){return e instanceof je}function na(e){if(!(e instanceof je))return null;let t=e.detail?.message?.toLowerCase()||"";return t.includes("credit")||t.includes("balance")||t.includes("insufficient")?{alertTitle:"You ran out of credits",alertSubtitle:"Upgrade your plan to get more credits and continue using the AI assistant."}:{alertTitle:"Billing check failed",alertSubtitle:e.detail?.message||"Please upgrade to continue."}}function ye(){return typeof DOMException=="function"?new DOMException("Aborted","AbortError"):Object.assign(new Error("Aborted"),{name:"AbortError"})}function he(e,t){return new Promise((n,r)=>{let s=()=>{t.removeEventListener("abort",s),r(ye())};t.addEventListener("abort",s,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",s)),t.aborted&&s()})}function ln(e,t){return new Promise((n,r)=>{let s=()=>{clearTimeout(i),t?.removeEventListener("abort",s),r(ye())},i=setTimeout(()=>{t?.removeEventListener("abort",s),n()},e);t?.aborted?s():t?.addEventListener("abort",s,{once:!0})})}var Yy="X-Kortix-Impersonate",Fs="kortix.impersonation",De=null,un=!1,qs=new Set;function Ns(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}function Xy(e,t=Date.now()){if(!e||!e.grantId||!e.accountId)return!1;let n=Date.parse(e.expiresAt);return Number.isFinite(n)&&n>t}function Jy(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t?.grantId!="string"||typeof t?.accountId!="string"?null:{grantId:t.grantId,accountId:t.accountId,accountName:typeof t.accountName=="string"?t.accountName:null,expiresAt:typeof t.expiresAt=="string"?t.expiresAt:""}}catch{return null}}function ra(){for(let e of qs)try{e()}catch{}}function Qy(){return un||(un=!0,De=Jy(Ns()?.getItem(Fs)??null)),De&&!Xy(De)?(sa(),null):De}function yv(e){if(un=!0,!e){sa();return}De=e;try{Ns()?.setItem(Fs,JSON.stringify(e))}catch{}ra()}function sa(){un=!0;let e=De!==null;De=null;try{Ns()?.removeItem(Fs)}catch{}e&&ra()}function hv(e){return qs.add(e),()=>{qs.delete(e)}}var Zy=/(^|\/)admin\/(api|analytics)(\/|$)/;function eh(e){let t=e;if(/^https?:\/\//.test(e))try{t=new URL(e).pathname}catch{t=e}return!Zy.test(t)}function ia(e){if(e!==void 0&&!eh(e))return{};let t=Qy();return t?{[Yy]:t.grantId}:{}}var Ws=!1;function th(e){Ws=e}function nh(){return Ws}function rh(e){return e?e instanceof Headers||Array.isArray(e)?[...new Headers(e).entries()]:Object.entries(e):[]}function Bs(e,t){let n=t.toLowerCase();return Object.keys(e).some(r=>r.toLowerCase()===n)}function dt(e,t,n){let r=t.toLowerCase();for(let s of Object.keys(e))s.toLowerCase()===r&&delete e[s];e[t]=n}function Ks(e,t){let n={},r=[e instanceof Request?e.headers:void 0,t.headers];for(let[s,i]of r.flatMap(rh))dt(n,s,i);return n}function oa(e,t,n){let r={...t},s=Xo(L().clientSource);s&&!Bs(r,"x-kortix-client")&&dt(r,"X-Kortix-Client",s),Ws&&dt(r,"x-kortix-admin-bypass","1");for(let[i,o]of Object.entries(ia(e)))dt(r,i,o);return Bs(r,"authorization")||dt(r,"Authorization",`Bearer ${n}`),r}function sh(e){return typeof ReadableStream<"u"&&e.body instanceof ReadableStream}function aa(e,t,n,r,s){if(t instanceof Request){let a=new Headers(oa(t.url,Ks(t,n),r));return e(new Request(t,{headers:a,...s?{signal:s}:{}}))}let i=String(t),o=oa(i,Ks(t,n),r);return e(i,{...n,headers:o,...s?{signal:s}:{}})}async function Gs(e){return on(()=>L().getToken(),e)}async function gt(e,t={},n={}){let{retryOnAuthError:r=!0,timeoutMs:s=Us}=n,i=n.fetch??L().fetch??fetch,o=s===null?(e instanceof Request?e.signal:t.signal)??void 0:Jo(e,t,s);if(o?.aborted)throw ye();let a=await(o?he(Gs(),o):Gs());if(!a)throw new ce;let l=r&&!sh(t)&&!Bs(Ks(e,t),"authorization"),g=l&&e instanceof Request?e.clone():e,m=await aa(i,e,t,a,o);if(m.status!==401||!l)return m;let h=await Gs({attempts:2,baseDelayMs:200});return!h||h===a?m:aa(i,g,t,h,o)}async function Hs(){return L().getToken()}async function mt(e){return on(()=>L().getToken(),e,zs)}function zs(){}function Cv(e){}function Iv(e){}async function ft(){return Hs()}async function Ev(e){return mt(e)}async function N(e,t,n){try{return await gt(e,t,{retryOnAuthError:n?.retryOnAuthError,timeoutMs:n?.timeoutMs})}catch(r){if(r instanceof ce)return an();throw r}}var Ke={url:null,sandboxId:null,dbSandboxId:null,version:0},ih=new Set;function ca(e,t=null,n=null){if(!(Ke.url===e&&Ke.sandboxId===t&&Ke.dbSandboxId===n)){Ke={url:e,sandboxId:t,dbSandboxId:n,version:Ke.version+1};for(let r of ih)r()}}function la(){return Ke.url}function oh(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function yt(){return oh(L().backendUrl||"http://localhost:8008/v1")}function ua(){let e=L().sandboxId;return e?`${yt()}/p/${e}/8000`:""}function ah(e,t=8e3){return`${yt()}/p/${e}/${t}`}function ht(e,t=8e3){return ah(e,t)}var de=()=>L().backendUrl||"",ch="feature_not_supported",lh="model_not_servable",uh="provision_in_flight",ph="analytics_unavailable",dh="accounts_list_unavailable",pa="request_deadline",gh=/^Request exceeded the \d+s server processing deadline$/,mh=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===pa||gh.test(n),fh="git_mirror_unavailable",yh=/^git mirror is temporarily unavailable$/,hh=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===fh||yh.test(n),bh=new Set([502,503,504]),_h=e=>bh.has(e),da=e=>{let t=(e??"GET").toUpperCase();return t==="GET"||t==="HEAD"},xh=e=>da(e)||(e??"GET").toUpperCase()==="DELETE",Ph=2,pn=e=>e?.name==="AbortError"||e?.name==="AbortSignal"||e instanceof Error&&e.message.includes("aborted");async function ve(e,t={}){let{showErrors:n=!0,errorContext:r,timeout:s=3e4,deadlineCoversBody:i=!1,...o}=t,a=new AbortController,l=a,g=()=>l.abort();o.signal?.addEventListener("abort",g,{once:!0});let m=null,h=!1,_=!1;try{if(o.signal?.aborted)throw ye();m=setTimeout(()=>{!h&&!a.signal.aborted&&(h=!0,_=!0,a.abort())},s);let S={...o.body instanceof FormData?{}:{"Content-Type":"application/json"},...o.headers},A=da(o.method),v=xh(o.method),j=v?Ph+1:1,k;for(let u=0;u<j;u++){u>0&&await ln(250*2**(u-1),o.signal??void 0);let x=u===0?a:new AbortController;l=x,o.signal?.aborted&&x.abort(),u>0&&(m=setTimeout(()=>{_=!0,x.abort()},s));try{k=await he(gt(e,{...o,headers:S,signal:x.signal,credentials:o.credentials??"omit"},{timeoutMs:null}),x.signal)}catch(P){if(m&&(clearTimeout(m),m=null),P instanceof ce)return{error:new ce,success:!1};if(_&&pn(P)&&!o.signal?.aborted&&v&&u<j-1){_=!1;continue}if(pn(P)||u===j-1)throw P;continue}if(!(A&&_h(k.status)&&u<j-1)){!i&&m&&(clearTimeout(m),m=null);break}try{await he(k.arrayBuffer(),x.signal)}catch(P){if(pn(P))throw P}finally{m&&(clearTimeout(m),m=null)}}if(!k.ok){let u=`HTTP ${k.status}: ${k.statusText}`,x=null;try{x=await he(k.json(),l.signal),typeof x.message=="string"?u=x.message:x.error&&typeof x.error=="string"?u=x.error:typeof x.detail=="string"?u=x.detail:typeof x.detail?.message=="string"?u=x.detail.message:typeof x.reason=="string"&&(u=x.reason)}catch{}if(l.signal.aborted)throw ye();let C=mh(k.status,x,u),P=hh(k.status,x,u),w=new T(u,{status:k.status,response:k,details:x||void 0,data:x,detail:x?.detail,code:C?pa:x?.code||x?.error_code||x?.detail?.error_code||k.status.toString()});if(k.status===402&&(w=cn(w)),k.status===403&&x?.code==="account_mfa_required"&&typeof window<"u"&&typeof window.dispatchEvent=="function")try{window.dispatchEvent(new CustomEvent("kortix:mfa-required"))}catch{}k.status===431&&(w=new Be(431,{message:"Request is too large to process",suggestion:"Try uploading files one at a time, or reduce the number of files attached to your message."}));let E=k.status===501&&x?.code===ch,R=k.status===409&&x?.code===lh,D=k.status===409&&x?.code===uh,U=k.status===503&&x?.code===ph,b=k.status===503&&x?.code===dh;return n&&!E&&!R&&!D&&!U&&!b&&!P&&!C&&L().onError?.(w,r),{error:w,success:!1}}let d,f=k.headers.get("content-type");return f?.includes("application/json")?d=await he(k.json(),l.signal):f?.includes("text/")?d=await he(k.text(),l.signal):d=await he(k.blob(),l.signal),{data:d,success:!0,headers:k.headers}}catch(S){m&&(clearTimeout(m),m=null);let A=pn(S);A&&(h=!0);let v;if(A){if(!_)return{error:new T("Request aborted",{name:"AbortError",code:"ABORTED"}),success:!1};let j=e.replace(de(),"")||e;v=new T(`Request timed out after ${Math.round(s/1e3)}s: ${j}`,{code:"TIMEOUT",url:e,endpoint:j,timeout:s})}else S instanceof Error?(v=new T(S.message,{name:S.name||"ApiError",stack:S.stack}),n&&L().onError?.(v,r)):(v=new T(String(S)),n&&L().onError?.(v,r));return{error:v,success:!1}}finally{m&&clearTimeout(m),o.signal?.removeEventListener("abort",g)}}var Nv={async execute(e,t){try{let{data:n,error:r}=await e();if(r){let s=new T(r.message||"Database error",{code:r.code,details:r});return L().onError?.(s,t),{error:s,success:!1}}return{data:n,success:!0}}catch(n){let r=n instanceof Error?new T(n.message,{name:n.name||"ApiError",stack:n.stack}):new T(String(n));return L().onError?.(r,t),{error:r,success:!1}}}};async function wh(e,t,n={}){let{timeout:r=3e4,fetch:s}=n,i=new AbortController,o=setTimeout(()=>i.abort(),r);try{return await gt(`${de()}${e}`,{method:"POST",headers:{Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify(t),signal:i.signal,credentials:"omit"},{timeoutMs:null,fetch:s})}catch(a){if(a instanceof ce)return an();throw a}finally{clearTimeout(o)}}var c={putRaw:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"PUT",body:t,headers:{"Content-Type":"application/octet-stream",...n?.headers}}),get:(e,t)=>ve(`${de()}${e}`,{...t,method:"GET"}),post:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>ve(`${de()}${e}`,{...t,method:"DELETE"}),upload:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],ve(`${de()}${e}`,{...s,method:"POST",body:t,headers:i})},uploadPut:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],ve(`${de()}${e}`,{...s,method:"PUT",body:t,headers:i})},postStream:wh};var bt=new Map,Vs=new Map;function Ys(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function ga(e){return bt.get(Ys(e))??null}function ma(){return[...bt.values()].filter(e=>typeof e=="string")}function fa(e){return bt.has(Ys(e))}async function We(e){let t=Ys(e),n=bt.get(t);if(n!==void 0)return n;let r=Vs.get(t);if(r)return r;let s=(async()=>{try{let i=await c.get("/p/config",{showErrors:!1,errorContext:{operation:"load preview config",silent:!0}});if(!i.success)return null;let o=typeof i.data?.preview_url_template=="string"?i.data.preview_url_template:null;return bt.set(t,o),o}catch{return null}finally{Vs.delete(t)}})();return Vs.set(t,s),s}function ya(e){let{apiBaseUrl:t}=e;return fa(t)||We(t).catch(()=>{}),{sandboxId:e.sandboxId,backendPort:e.backendPort,apiBaseUrl:t,previewUrlTemplate:ga(t)}}function be(){let e=la();return e||(L().billingEnabled??!1?"":ua())}async function Xs(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function Js(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function ha(e){let t=Js(e),n=await N(`${t}/env`);if(!n.ok)throw new Error(await Xs(n,"Failed to load secrets"));return(await n.json()).secrets??{}}async function ba(e,t,n){let r=Js(e),s=await N(`${r}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!s.ok)throw new Error(await Xs(s,"Failed to save secret"))}async function _a(e,t){let n=Js(e),r=await N(`${n}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await Xs(r,"Failed to delete secret"))}var Sh={list:ha,set:ba,delete:_a};async function kh(e,t,n){let r=e;for(;r.endsWith("/");)r=r.slice(0,-1);let s=await N(`${r}/kortix/triggers${t}`,{...n,headers:{"Content-Type":"application/json",...n?.headers}}),i=await s.json();if(!s.ok)throw new Error(i?.error||i?.message||`Request failed with ${s.status}`);return i}function Ae(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return t===e.length?e:e.slice(0,t)}async function dn(e,t){let n=await e.json().catch(()=>({}));return n?.error||n?.message||e.statusText||t}function _t(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return Ae(e)}async function xa(e){let t=_t(e),n=await N(`${t}/kortix/pty`);if(!n.ok)throw new Error(await dn(n,"Failed to list terminals"));return n.json()}async function Pa(e,t){let n=_t(e),r=await N(`${n}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok)throw new Error(await dn(r,"Failed to create terminal"));return r.json()}async function wa(e,t,n){let r=_t(e),s=await N(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw new Error(await dn(s,"Failed to update terminal"));return s.json()}async function Sa(e,t){let n=_t(e),r=await N(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await dn(r,"Failed to remove terminal"))}async function ka(e,t,n){let r=_t(t),i=`${(()=>{try{let g=new URL(r);return g.protocol==="https:"?g.protocol="wss:":g.protocol==="http:"&&(g.protocol="ws:"),typeof window<"u"&&window.location.protocol==="https:"&&g.protocol==="ws:"&&(g.protocol="wss:"),Ae(g.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,o=new URLSearchParams,a=await ft();a&&o.set("token",a),n?.wake&&o.set("wake","1");let l=o.toString();return l?`${i}${i.includes("?")?"&":"?"}${l}`:i}function vh(e){let t=e.reason.trim().toLowerCase();return t.includes("pty not found")?"replace":t.includes("pty exited")?"ended":e.hadError||t.includes("idle timeout")||t.includes("upstream error")||e.code!==1e3?"reconnect":"ended"}var Re="\x1B",va="\x07",Ah="\0",Qs=`(?:${va}|${Re}\\\\)`,Rh=[new RegExp(`${Re}\\]697;[^${va}${Re}]*${Qs}`,"g"),new RegExp(`${Ah}?\\{"cursor":\\d+\\}`,"g"),new RegExp(`${Re}\\][0-9]+;rgb:[0-9a-fA-F/]+${Qs}`,"g"),new RegExp(`${Re}\\]4;[0-9]+;rgb:[0-9a-fA-F/]+${Qs}`,"g"),new RegExp(`${Re}\\[\\??[0-9;]*\\$y`,"g"),new RegExp(`${Re}\\[\\d+;\\d+R`,"g"),new RegExp(`${Re}\\[\\?[0-9;]*c`,"g")];function Th(e){let t=e;for(let n of Rh)t=t.replace(n,"");return t}var Ch={list:xa,create:Pa,update:wa,remove:Sa,webSocketUrl:ka};async function $(e,t,n,r){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let i=await N(`${s}${t}`,{...n,headers:{"Content-Type":"application/json",...n?.headers}},r),o=await i.text(),a={};try{a=o?JSON.parse(o):{}}catch{a={}}if(!i.ok)throw new Error(a?.error||a?.message||a?.details||o.slice(0,200)||`Request failed with ${i.status}`);return a}async function uA(e,t={}){let n=new URLSearchParams;t.projectId&&n.set("project_id",t.projectId),t.status&&n.set("status",t.status);let r=n.toString()?`?${n}`:"";return $(e,`/kortix/tasks${r}`)}async function pA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function dA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function gA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function mA(e,t){return $(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function fA(e,t,n){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function yA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function hA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function bA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function _A(e,t){let n=t?`?project_id=${encodeURIComponent(t)}`:"";return $(e,`/kortix/tickets${n}`)}async function xA(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function PA(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function wA(e,t){return $(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function SA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function kA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(n)})}async function vA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(n)})}async function AA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(n)})}async function RA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(n)})}async function TA(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function CA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function IA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:n})})}async function EA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function MA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:n})})}async function OA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function jA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:n})})}async function DA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function $A(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function UA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(n)})}async function LA(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function qA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"DELETE"})}async function FA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}/persona`)}async function NA(e,t,n=200){return $(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${n}`)}async function GA(e){return $(e,"/kortix/projects")}async function BA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function KA(e,t){return $(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function WA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function HA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function zA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function VA(e,t,n="all"){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${n}`)}async function YA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`)}async function XA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/events`)}async function JA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(n)})}async function QA(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function ZA(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/close`,{method:"POST",body:JSON.stringify(r)})}async function eR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/reopen`,{method:"POST"})}async function tR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"DELETE"})}async function nR(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function rR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}/events`)}async function sR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(n)})}async function iR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`)}async function oR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`,{method:"DELETE"})}var Ih=1e4,Eh={retryOnAuthError:!1};function He(e,t,n){return $(e,t,{signal:AbortSignal.timeout(Ih),...n},Eh)}async function aR(e,t=!1){return(await He(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function cR(e){return(await He(e,"/kortix/services/templates")).templates??[]}async function lR(e,t){return(await He(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function uR(e,t,n){let r=n==="delete",s=r?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${n}`;return He(e,s,{method:r?"DELETE":"POST"})}async function pR(e,t){return He(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function dR(e,t){return He(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var gn=new Map,xt=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function $e(){let e=be();if(!e)throw new xt;return Te(e)}function Te(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=gn.get(e);if(t)return t;if(!br())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let n=$s({baseUrl:e,fetch:N});return gn.set(e,n),n}function _R(e){gn.delete(e)}function xR(){gn.clear()}var mn=new Map;function PR(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=mn.get(e);if(t)return t;let n=$s({baseUrl:e,fetch});return mn.set(e,n),n}function wR(e){mn.delete(e)}function SR(){mn.clear()}async function Mh(e){let t=await e.text().catch(()=>"");try{let n=JSON.parse(t);return n?.error||n?.message||t||e.statusText||`HTTP ${e.status}`}catch{return t||e.statusText||`HTTP ${e.status}`}}async function kR(e){let t=be();if(!t)throw new T("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading",{code:"RUNTIME_UNAVAILABLE"});let n=e==="full"?"/kortix/refresh":"/global/dispose",r=await N(`${t}${n}`,{method:"POST"}),s=r.headers.get("content-type")??"",i=/^application\/([\w.+-]+\+)?json\b/i.test(s.trim());if(!r.ok)throw new T(`System reload failed (${r.status}): ${await Mh(r)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});if(!i)throw new T(`System reload endpoint is unavailable on this sandbox (${n})`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});let o;try{o=await r.json()}catch(l){throw new T(`System reload returned malformed JSON from ${n}: ${l instanceof Error?l.message:String(l)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"})}let a=o===!0||typeof o=="object"&&o!==null&&o.ok===!0;return{success:a,mode:e,steps:a?[e==="full"?"refreshed workspace and restarted runtime":"reloaded config in place"]:[],errors:a?[]:[`the sandbox did not confirm the reload (${n})`]}}function Ca(e){if(e.error){let t=e.error,n=t?.data?.message||t?.message||(typeof t?.error=="string"?t.error:null)||"SDK request failed";throw new T(n,{status:t?.response?.status??t?.status,response:t?.response,details:t})}return e.data}async function ze(e){let t=await e.text().catch(()=>""),n=null;try{n=JSON.parse(t)}catch{}return n?.error||t||e.statusText||`HTTP ${e.status}`}function ne(e){let t=(e??be()).trim();if(!t)throw new xt;return t}async function yn(e,t){let n=await N(`${ne(t)}${e}`);if(!n.ok)throw new T(await ze(n),{status:n.status,response:n});return n.json()}var ti=["/workspace","/tmp","/home","/opt"],Oh=ti.filter(e=>e!=="/workspace");function Ia(e){return ti.some(t=>e===t||e.startsWith(`${t}/`))}function kt(e){return Ia(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function Ve(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(Oh.some(n=>t===n||t.startsWith(`${n}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var Ea=Ve;async function vt(e,t){let n=ne(t),r=Ve(e)||".";return(await yn(`/file?path=${encodeURIComponent(r)}`,n)).map(i=>({...i,path:i.absolute||`/workspace/${i.path}`}))}async function At(e,t){let n=ne(t),r=Ve(e),s=await N(`${n}/file/content?path=${encodeURIComponent(r)}`);if(!s.ok)throw new T(await ze(s),{status:s.status,response:s});return s.json()}async function jh(e,t,n){let r=ne(n),s=Ve(e),i=await N(`${r}/file/raw?path=${encodeURIComponent(s)}`);if(!i.ok)throw new T(await ze(i),{status:i.status,response:i});if((i.headers.get("content-type")||"").includes("text/html"))throw new T("File could not be loaded (raw byte route unavailable)",{status:i.status,response:i,code:"INVALID_CONTENT_TYPE"});let o=await i.blob();return t&&(!o.type||o.type==="application/octet-stream")?new Blob([o],{type:t}):o}async function Rt(e,t){let n=ne(t);try{return await jh(e,void 0,n)}catch{}let r=await At(e,n);if(r.encoding==="base64"&&r.content){let s=Uint8Array.from(atob(r.content),i=>i.charCodeAt(0));return new Blob([s],{type:r.mimeType||"application/octet-stream"})}return new Blob([r.content??""],{type:r.mimeType||"text/plain;charset=utf-8"})}async function hn(e){return yn("/file/status",ne(e))}async function bn(e,t,n){let r=ne(n),s=new URLSearchParams({query:e});return t?.type&&s.set("type",t.type),t?.limit&&s.set("limit",String(t.limit)),yn(`/find/file?${s.toString()}`,r)}async function _n(e,t){let n=ne(t);return(await yn(`/find?pattern=${encodeURIComponent(e)}`,n)).map(s=>({path:typeof s.path=="string"?s.path:s.path?.text??"",lines:typeof s.lines=="string"?s.lines:s.lines?.text??"",line_number:s.line_number,absolute_offset:s.absolute_offset,submatches:(s.submatches??[]).map(i=>({start:i.start,end:i.end}))}))}var Pt=[400,1200],Dh=e=>e===408||e===429||e===502||e===503||e===504,Aa=e=>new Promise(t=>setTimeout(t,e));function $h(e){let t=e?.name;return t==="TimeoutError"||t==="AbortError"}var Zs=3e4,Uh=15*6e4,Lh=256;function wt(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return Zs;let t=Zs+e/Lh;return Math.min(Uh,Math.max(Zs,Math.round(t)))}async function qh(e){let t=await e.text().catch(()=>""),n=null;try{n=t?JSON.parse(t):null}catch{}let r=n?.error||n?.message||n?.data?.message;return typeof r=="string"&&r.trim()?r.trim():(e.headers.get("content-type")||"").includes("text/html")||/<html[\s>]/i.test(t)?e.status===502||/bad gateway/i.test(t)?"Bad gateway while reaching the sandbox upload service. Please retry.":e.statusText||`HTTP ${e.status}`:t.replace(/\s+/g," ").trim().slice(0,500)||e.statusText||`HTTP ${e.status}`}async function fn(e,t){let n;for(let s=0;s<=Pt.length;s++){let i;try{i=await t(e())}catch(a){if(n=a,$h(a)||s===Pt.length)break;await Aa(Pt[s]);continue}if(i.ok)return i.json();let o=await qh(i);if(n=new T(`Upload failed (${i.status}): ${o}`,{status:i.status,response:i}),!Dh(i.status)||s===Pt.length)throw n;await Aa(Pt[s])}if(n instanceof T)throw n;let r=n instanceof Error?n.message:String(n||"request failed");throw new T(`Upload failed: ${r}`)}var ei=64*1024;function Ra(e,t){try{e?.onProgress?.(t)}catch{}}function Ta(e,t,n){let r=new FormData,s=(t??"").trim();return s&&r.append("path",s.startsWith("/")?s:`/${s}`),n&&r.append("filename",n),n?r.append("file",e,n):r.append("file",e),r}function Fh(e){let t=e.lastIndexOf("/");return t<0?{parent:"",name:e}:{parent:e.slice(0,t)||"/",name:e.slice(t+1)}}async function Tt(e,t,n,r,s){let i=typeof r=="string"?r:void 0,o=typeof r=="string"?s:r,a=ne(i),l=wt(e.size),g=n||(e instanceof File?e.name:"")||"";if(e.size<=ei){let S=await fn(()=>Ta(e,t,g),A=>N(`${a}/file/upload`,{method:"POST",body:A},{timeoutMs:l}));return Ra(o,{loadedBytes:e.size,totalBytes:e.size}),S}let h=(await fn(()=>Ta(new Blob([],{type:e.type}),t,g),S=>N(`${a}/file/upload`,{method:"POST",body:S},{timeoutMs:wt(0)})))[0]?.path;if(!h)throw new T("Upload reservation returned no file path",{code:"UPLOAD_NO_RESULT"});let _=Fh(h);if(!_.name)throw new T(`Upload reservation returned an invalid file path: ${h}`,{code:"UPLOAD_INVALID_PATH"});try{for(let S=0;S<e.size;S+=ei){let A=Math.min(e.size,S+ei),v=e.slice(S,A,e.type),j=await fn(()=>{let k=new FormData;return _.parent&&k.append("path",_.parent),k.append("filename",_.name),k.append("first",S===0?"true":"false"),k.append("offset",String(S)),k.append("file",v,_.name),k},k=>N(`${a}/file/append`,{method:"POST",body:k},{timeoutMs:wt(v.size)}));if(j.path!==h||j.size!==A)throw new T(`Upload verification failed for ${h}: expected ${A} bytes, received ${j.size}`,{code:"UPLOAD_SIZE_MISMATCH"});Ra(o,{loadedBytes:A,totalBytes:e.size})}}catch(S){throw await Ye(h,a).catch(()=>{}),S}return[{path:h,size:e.size}]}function Nh(e,t,n){let r=ne(n),s=wt(t.size);return fn(()=>{let i=new FormData;return i.append(e,t,e.split("/").pop()||"file"),i},i=>N(`${r}/file/upload`,{method:"POST",body:i},{timeoutMs:s}))}var St=class extends T{path;constructor(t){super(`A file or folder already exists at ${t}`,{status:409,code:"FILE_EXISTS"}),this.name="FileExistsError",this.path=t}};async function xn(e,t){let n=ne(t),r=e.trim(),i=(r.startsWith("/")?r:`/${r}`).split("/"),o=i.pop()||"untitled",a=i.join("/")||"/workspace",l=kt(`${a}/${o}`),g=[];try{g=await vt(Ma(l),n)}catch(h){if(!(h instanceof T&&h.status===404))throw h}if(g.some(h=>h.name===Oa(l)))throw new St(l);let m=await ja(l,new Blob([],{type:"application/octet-stream"}),n,{overwrite:!1});return[{path:m.path,size:m.bytes}]}async function Pn(e,t,n){let r=ne(n);return Nh(t,await Rt(e,r),r)}function Gh(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Ma(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}function Oa(e){return e.slice(e.lastIndexOf("/")+1)}function Bh(){let e=typeof crypto<"u"?crypto:void 0;if(e?.randomUUID)return e.randomUUID();if(e?.getRandomValues){let t=new Uint8Array(8);return e.getRandomValues(t),[...t].map(n=>n.toString(16).padStart(2,"0")).join("")}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}async function wn(e,t,n){let r=ne(n),s=kt(Gh(e.trim()));return ja(s,t,r,{overwrite:!0})}async function ja(e,t,n,r){let s=Oa(e);if(!s)throw new T(`writeFile needs a file path, got "${e}"`,{code:"INVALID_PATH"});let i=Ma(e);await Ct(i,n).catch(()=>{});let o=Bh(),a=await Tt(t,i,`.${s}.kortix-write-${o}`,n),l=a[0]?.path;if(!l)throw new T(`Upload returned no file for ${e}`,{code:"UPLOAD_NO_RESULT"});let g=kt(l);try{await Da(g,e,n,r.overwrite)}catch(h){throw await Ye(g,n).catch(()=>{}),!r.overwrite&&h instanceof T&&h.status===409?new St(e):h}let m=a[0]?.size;return{path:e,bytes:typeof m=="number"?m:t.size}}async function Ye(e,t){let n=await N(`${ne(t)}/file`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!n.ok)throw new T(`Delete failed (${n.status}): ${await ze(n)}`,{status:n.status,response:n});return n.json()}async function Ct(e,t){let n=await N(`${ne(t)}/file/mkdir`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!n.ok)throw new T(`Mkdir failed (${n.status}): ${await ze(n)}`,{status:n.status,response:n});return n.json()}async function Sn(e,t,n){return Da(e,t,ne(n),!0)}async function Da(e,t,n,r){let s=await N(`${n}/file/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{from:e,to:t}:{from:e,to:t,overwrite:!1})});if(!s.ok)throw new T(`Rename failed (${s.status}): ${await ze(s)}`,{status:s.status,response:s});return s.json()}async function $a(){return Ca(await $e().project.current())}async function ni(){return Ca(await $e().global.health())}async function Ua(){try{return(await ni()).healthy===!0}catch{return!1}}var Kh={list:vt,read:At,readBlob:Rt,status:hn,findFiles:bn,findText:_n,upload:Tt,write:wn,create:xn,copy:Pn,remove:Ye,mkdir:Ct,rename:Sn,currentProject:$a,health:ni,isReachable:Ua,toDaemonPath:Ve,toSandboxAbsolutePath:kt,toWorkspaceRelative:Ea};var ri=52428800,Hh=104857600,La=20;function p(e,t="Project request failed"){if(!e.success||e.data===void 0)throw e.error??new Error(t);return e.data}function si(e){return e.replace(/\/v1\/?$/,"")}async function Xe(e,t){if(!e.backendUrl||!e.accessToken)return null;let n=si(e.backendUrl);try{let r=await fetch(`${n}${t}`,{headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(e.timeoutMs??8e3)});return r.ok?await r.json():null}catch{return null}}var vn=e=>`/projects/${encodeURIComponent(e)}/attachments`,An={showErrors:!1,deadlineCoversBody:!0},qa=3e4,zh=12e4,Vh=6e4,Yh=5*6e4,Xh=6e4,Jh=6e4;function kn(){return new T("Request aborted",{name:"AbortError",code:"ABORTED"})}function It(e){if(e?.aborted)throw kn()}function Qh(e){return!(e instanceof T)||e.code==="ABORTED"||e.code==="attachment_budget_exceeded"?!1:e.code==="TIMEOUT"||e.name==="TypeError"||e.status===429||e.status!==void 0&&e.status>=500}async function Et(e,t,n=!1){let r;for(let s=0;;s++){It(t);try{return await e()}catch(i){let o=n&&i instanceof T&&i.status===409&&i.code==="attachment_processing";if(t?.aborted||!(Qh(i)||o))throw i;r??=Date.now()+(n?Yh:Vh);let a=Math.min(8e3,500*2**s)*(.5+Math.random()/2);if(Date.now()+a>=r)throw i;try{await ln(a,t)}catch{throw It(t),i}}}}function Zh(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string")}function ii(e,t,n){let r=e?.upload,s=e?.received_bytes,i=Number.isSafeInteger(s)&&s>=0&&s<=t.size,o=r?.kind==="direct"?typeof r.url=="string"&&/^https?:\/\//i.test(r.url)&&r.method==="PUT"&&Zh(r.headers)&&Number.isFinite(Date.parse(r.expires_at))&&(s===0||s===t.size):r?.kind==="chunked"&&Number.isSafeInteger(r.chunk_size)&&r.chunk_size>0&&(s===t.size||s%r.chunk_size===0);if(!e?.attachment_id||n!==void 0&&e.attachment_id!==n||e.size!==t.size||!i||!o)throw new Error("Invalid attachment upload handle");return e}async function Fa(e,t,n,r){return p(await c.post(vn(e),{...r?{attachment_id:r}:{},filename:t.name,mime:t.type||"application/octet-stream",size:t.size},{...An,signal:n,timeout:qa}),"Failed to start attachment upload")}async function Na(e,t,n,r){let s=ii({...await Et(()=>Fa(e,t,r.signal,n.attachment_id),r.signal),received_bytes:0},t,n.attachment_id);return r.onUpload?.(s),s}function Ga(e,t){let n;try{n=JSON.parse(t)}catch{}let r=typeof n?.message=="string"?n.message:typeof n?.error=="string"?n.error:`HTTP ${e}`;return new T(r,{status:e,details:n,code:String(n?.statusCode??e)})}function eb(e){if(!(e instanceof T))return;let t=Number(e.details?.statusCode);return Number.isInteger(t)&&t>=400?t:e.status}function tb(e,t,n,r){return new Promise((s,i)=>{let o=new e,a=0,l=!1,g,m=S=>{l||(l=!0,g&&clearTimeout(g),r.signal?.removeEventListener("abort",_),S?i(S):s())},h=()=>{g&&clearTimeout(g),g=setTimeout(()=>{m(new T("Attachment upload stalled",{code:"TIMEOUT"})),o.abort()},Xh)},_=()=>{m(kn()),o.abort()};o.open(t.method,t.url);for(let[S,A]of Object.entries(t.headers))o.setRequestHeader(S,A);o.upload.onprogress=S=>{h(),a=Math.min(S.loaded,n.size),r.onProgress?.(a,n.size)},o.onload=()=>{o.status>=200&&o.status<300?(a<n.size&&r.onProgress?.(n.size,n.size),m()):m(Ga(o.status,o.responseText))},o.onerror=()=>m(new T("Network error during attachment upload",{name:"TypeError"})),o.onabort=()=>m(kn()),r.signal?.addEventListener("abort",_,{once:!0}),h(),o.send(n)})}async function nb(e,t,n){let r=L().fetch??fetch,s;try{s=await r(e.url,{method:e.method,headers:e.headers,body:t,signal:n.signal,credentials:"omit"})}catch(i){throw n.signal?.aborted||i instanceof Error&&i.name==="AbortError"?kn():new T(i instanceof Error?i.message:String(i),{name:i instanceof Error?i.name:"TypeError"})}if(!s.ok)throw Ga(s.status,await s.text().catch(()=>""));n.onProgress?.(t.size,t.size)}function rb(e,t,n){It(n.signal);let r=globalThis.XMLHttpRequest;return typeof r=="function"?tb(r,e,t,n):nb(e,t,n)}async function sb(e,t,n,r){let s=n,i=!1;for(r.onProgress?.(0,t.size);s.upload.kind==="direct";){let o=s.upload;try{await Et(()=>rb(o,t,r),r.signal)}catch(a){let l=eb(a);if(l!==409){if(i||!(l===400||l===401||l===403))throw a;i=!0,s=await Na(e,t,s,r);continue}}return s={...s,received_bytes:t.size},r.onUpload?.(s),s}return Ba(e,t,s,r)}async function Ba(e,t,n,r){if(n.upload.kind!=="chunked")throw new Error("Invalid attachment upload handle");let s=n.upload.chunk_size,i=`${vn(e)}/${encodeURIComponent(n.attachment_id)}`,o=n;for(;o.received_bytes<t.size;){It(r.signal);let a=o.received_bytes,l=Math.min(a+s,t.size),g=t.slice(a,l),m=await Et(async()=>p(await c.putRaw(`${i}/chunks/${a/s}`,g,{...An,signal:r.signal,timeout:qa}),"Failed to upload attachment chunk"),r.signal);if(m.size!==t.size||m.received_bytes!==l)throw new Error("Invalid attachment chunk acknowledgment");o={...o,received_bytes:l},r.onUpload?.(o),r.onProgress?.(l,t.size)}return o}async function Rn(e,t,n={}){if(!e)throw new Error("A project is required to upload attachments");if(!Number.isSafeInteger(t.size)||t.size<=0||t.size>52428800)throw new Error("Attachment must contain 1 byte to 50 MiB");It(n.signal);let r=n.resume?ii({...n.resume},t):ii({...await Et(()=>Fa(e,t,n.signal),n.signal),received_bytes:0},t);n.onUpload?.(r),r.received_bytes<t.size&&(r.upload.kind==="direct"&&Date.parse(r.upload.expires_at)-Date.now()<Jh&&(r=await Na(e,t,r,n)),r=r.upload.kind==="direct"?await sb(e,t,r,n):await Ba(e,t,r,n)),n.onProcessing?.();let s=`${vn(e)}/${encodeURIComponent(r.attachment_id)}`;try{return await Et(async()=>p(await c.post(`${s}/complete`,{},{...An,signal:n.signal,timeout:zh}),"Failed to complete attachment upload"),n.signal,!0)}catch(i){throw r.upload.kind==="direct"&&i instanceof T&&i.code==="attachment_not_uploaded"&&n.onUpload?.({...r,received_bytes:0}),i}}async function Mt(e,t,n={}){if(!e)throw new Error("A project is required to remove attachments");let r=await c.delete(`${vn(e)}/${encodeURIComponent(t)}`,{...An,signal:n.signal});if(!r.success)throw r.error??new Error("Failed to remove attachment")}var ib=100,ob=0,ab=new Set(["attachment_size_mismatch","attachment_failed"]),Ka=()=>new T("Attachment expired. Attach the file again.",{code:"attachment_expired"});function Wa(e){if(!e||typeof e.attachment_id!="string"||!e.attachment_id||typeof e.filename!="string"||!e.filename||typeof e.mime!="string"||!e.mime||!Number.isSafeInteger(e.size)||e.size<=0||e.size>52428800||!Number.isFinite(Date.parse(e.expires_at))||Date.parse(e.expires_at)<=Date.now())throw new Error("Attachment metadata is invalid or expired. Attach the file again.");return{attachment_id:e.attachment_id,filename:e.filename,mime:e.mime,size:e.size,expires_at:e.expires_at}}function Ha(e,t={}){let n=t.concurrency??2;if(!Number.isInteger(n)||n<1||n>20)throw new Error("Attachment concurrency must be between 1 and 20");let r=new Map,s=new Set,i=new Set,o=0,a=!1,l,g={attachments:[]},m=()=>[...r.values()].filter(f=>!f.handedOff);function h(f,u){f.removalDeleted||(f.removalDeleted=!0,Mt(e,u).catch(()=>{}))}function _(){l&&clearTimeout(l);let f=m().map(({item:x})=>x);(f.length!==g.attachments.length||f.some((x,C)=>x!==g.attachments[C]))&&(g={attachments:f});let u=Math.min(...f.filter(x=>x.status==="ready").map(x=>Date.parse(x.attachment.expires_at)));Number.isFinite(u)&&!a&&(l=setTimeout(()=>{for(let x of m())x.item.status==="ready"&&Date.parse(x.item.attachment.expires_at)<=Date.now()&&(x.item={...x.item,status:"error",error:Ka()});_()},Math.min(2147483647,Math.max(0,u-Date.now()))),typeof l=="object"&&"unref"in l&&l.unref());for(let x of s)x();for(let x of[...i])x()}function S(){if(a)throw new Error("Attachment controller is disposed");if(!e)throw new Error("A project is required to attach files");return e}function A(f){S();let u=m();if(u.length+f.length>20)throw new Error("A message can contain up to 20 attachments");if(f.some(C=>!Number.isSafeInteger(C)||C<=0||C>52428800))throw new Error("Each attachment must contain 1 byte to 50 MiB");if(u.reduce((C,P)=>C+P.item.size,0)+f.reduce((C,P)=>C+P,0)>104857600)throw new Error("Message attachments exceed 100 MiB")}function v(){for(let f of r.values()){if(o>=n)break;if(f.item.status!=="pending"||!f.item.file||a&&!f.handedOff)continue;let u=f.item.file;o++;let x=++f.generation,C=new AbortController;f.abort=C,f.item={...f.item,status:"uploading",error:void 0};let P=()=>(!a||f.handedOff===!0)&&r.get(f.item.id)===f&&f.generation===x,w,E=0,R,D=()=>{R=void 0,!(!P()||f.item.status!=="uploading"||w===void 0)&&(f.item={...f.item,receivedBytes:w},w=void 0,E=Date.now(),_())},U=b=>Math.floor(b*100/f.item.size);Rn(e,u,{resume:f.upload,signal:C.signal,onUpload:b=>{f.upload=b,f.removed&&(C.abort(),h(f,b.attachment_id))},onProgress:b=>{if(!P()||U(b)===U(f.item.receivedBytes)||(w=b,R))return;let M=E+ib-Date.now();if(M<=0)return D();R=setTimeout(D,M),typeof R=="object"&&"unref"in R&&R.unref()},onProcessing:()=>{R&&clearTimeout(R),R=void 0,w=void 0,P()&&(f.item={...f.item,status:"processing",receivedBytes:f.item.size},_())}}).then(b=>{P()&&(f.item={...f.item,status:"ready",attachment:Wa(b),receivedBytes:b.size})}).catch(b=>{b instanceof T&&ab.has(b.code??"")&&(f.upload=void 0),P()&&(f.item={...f.item,status:b instanceof T&&b.code==="ABORTED"?"aborted":"error",error:b instanceof Error?b:new Error(String(b))})}).finally(()=>{o--,R&&clearTimeout(R),f.abort===C&&(f.abort=void 0),_(),v()})}_()}function j(f){A(f.map(x=>x.size));let u=f.map(x=>{let C=`attachment-${++ob}`;return r.set(C,{generation:0,item:{id:C,file:x,filename:x.name,mime:x.type||"application/octet-stream",size:x.size,status:"pending",receivedBytes:0}}),C});return _(),v(),u}function k(f){let u=r.get(f);!u||u.item.status==="ready"||(u.generation++,u.abort?.abort(),u.item={...u.item,status:"aborted",error:new Error("Attachment upload cancelled")},_())}function d(f,{signal:u}={}){let x=[...f];return new Promise((C,P)=>{let w=()=>{i.delete(D),u?.removeEventListener("abort",R)},E=U=>{w(),P(U)},R=()=>E(ye()),D=()=>{let U=!1;for(let M of x){let q=r.get(M);if(!q)return E(new Error("Attachment was removed before it was sent"));if(a&&!q.handedOff)return E(new Error("Attachment controller is disposed"));if(q.item.status==="error"||q.item.status==="aborted")return E(q.item.error??new Error("Attachment upload failed"));q.item.status!=="ready"&&(U=!0)}if(U)return;let b;try{b=x.map(M=>{let q=Wa(r.get(M).item.attachment);return{type:"file",attachment_id:q.attachment_id,filename:q.filename,mime:q.mime}})}catch(M){return E(M instanceof Error?M:new Error(String(M)))}w(),C(b)};if(u?.aborted)return R();i.add(D),u?.addEventListener("abort",R,{once:!0}),D()})}return{add:f=>j([f])[0],addMany:j,retry(f){let u=r.get(f);if(u?.handedOff||S(),!(!u||u.item.status==="ready"||u.item.status==="uploading"||u.item.status==="processing"||u.item.status==="pending")){if(!u.item.file||u.upload&&Date.parse(u.upload.expires_at)<=Date.now())throw Ka();u.item={...u.item,status:"pending",error:void 0},v()}},async remove(f){let u=r.get(f);if(!u)return;u.removed=!0,u.generation++,r.delete(f);let x=u.upload?.attachment_id??u.item.attachment?.attachment_id;x&&u.abort?.abort(),_(),v(),x&&h(u,x)},abort:k,submit(f){if(!a){for(let u of f){let x=r.get(u);x&&(x.handedOff=!0)}_()}},reclaim(f){if(!a){for(let u of f){let x=r.get(u);x&&(x.handedOff=!1)}_()}},whenReady:d,forget(f=m().map(u=>u.item.id)){for(let u of f){let x=r.get(u);x&&(x.generation++,x.abort?.abort(),r.delete(u))}_(),v()},dispose(){if(!a){a=!0,l&&clearTimeout(l);for(let f of r.values()){if(f.handedOff)continue;f.generation++,f.abort?.abort();let u=f.upload?.attachment_id??f.item.attachment?.attachment_id;u&&e&&Mt(e,u).catch(()=>{})}s.clear(),_()}},getSnapshot:()=>g,subscribe(f){return s.add(f),()=>{s.delete(f)}}}}async function za(){return p(await c.get("/accounts"))}async function Va(e){return p(await c.post("/accounts",e))}async function Ya(e){return p(await c.get(`/accounts/${e}`))}async function Xa(e,t){return p(await c.patch(`/accounts/${e}`,{name:t}))}async function Ja(e){return p(await c.get(`/accounts/${e}/branding`))}async function Qa(e,t){return p(await c.put(`/accounts/${e}/branding`,t))}async function Za(e,t,n,r){let s=new FormData;return s.append("file",n,r??(n instanceof File?n.name:t)),p(await c.upload(`/accounts/${e}/branding/assets/${t}`,s))}async function ec(e,t){return p(await c.delete(`/accounts/${e}/branding/assets/${t}`))}async function tc(e){return p(await c.delete(`/accounts/${e}/branding`))}async function nc(e){return p(await c.get(`/accounts/${e}/members`))}async function rc(e,t){return p(await c.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function sc(e){return p(await c.get(`/accounts/${e}/invites`))}async function ic(e,t){return p(await c.delete(`/accounts/${e}/invites/${t}`))}async function oc(e,t){return p(await c.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function ac(){return p(await c.get("/account-invites",{showErrors:!1})).invites}async function cc(e){return p(await c.get(`/account-invites/${e}`,{showErrors:!1}))}async function lc(e){return p(await c.post(`/account-invites/${e}/accept`,{}))}async function uc(e){return p(await c.post(`/account-invites/${e}/decline`,{}))}async function pc(e,t){return p(await c.delete(`/accounts/${e}/members/${t}`))}async function dc(e,t,n){return p(await c.patch(`/accounts/${e}/members/${t}`,{role:n}))}async function gc(e){return p(await c.post(`/accounts/${e}/leave`,{}))}async function zR(e){return Xe(e,"/v1/accounts")}async function mc(){let e=await c.get("/accounts/me",{showErrors:!1});return!e.success||!e.data?{valid:!1,error:e.error}:{valid:!0,identity:e.data}}var QR=["marketplace","connectors_api_discover","agentmail_email","teams","llm_gateway","meta_agent","apps","monitors","reminders","warm_sessions","secrets_egress","pi_worker","pooled_provider_secrets","pi_harness","config_releases","agent_principal"];async function Je(){return p(await c.get("/projects"))}async function yc(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return p(await c.get(`/projects${t}`))}async function oi(e,t){return p(await c.get(`/projects/${e}`,t))}async function hc(e,t,n="write"){return p(await c.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:n}))}async function bc(e,t){return p(await c.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function _c(e){return p(await c.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function ZR(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function ai(e,t){let n=p(await c.get(`/projects/${e}/detail`,{showErrors:!1,...t}));return{...n,config:{...n.config,default_agent:n.config.default_agent??n.config.open_code_default_agent??null}}}async function ci(e,t){return p(await c.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function li(e,t){return p(await c.get(`/projects/${e}/model-picker`,{showErrors:!1,...t}))}async function eT(e,t){return p(await c.get(`/projects/${e}/llm-catalog/providers`,{showErrors:!1,...t}))}async function xc(e){return p(await c.post("/projects",e))}async function Pc(e){return p(await c.post("/projects/create-repo",e,{showErrors:!1}))}async function wc(e,t={}){return p(await c.post("/projects/provision",{seed_starter:!0,...e},{timeout:12e4,...t}))}var fc=200;function cb(e){let t=e.split(`
|
|
7
|
+
`);try{B=JSON.parse(G),W=!0}catch{B=G}}W&&(s&&await s(B),r&&(B=await r(B))),n?.({data:B,event:Q,id:h,retry:v}),q.length&&(yield B)}}}finally{k.removeEventListener("abort",E),P.releaseLock()}break}catch(f){if(t?.(f),o!==void 0&&j>=o)break;let u=Math.min(v*2**(j-1),a??3e4);await _(u)}}}()}};var Ey=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},My=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Oy=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},tn=({allowReserved:e,explode:t,name:n,style:r,value:s})=>{if(!t){let a=(e?s:s.map(l=>encodeURIComponent(l))).join(My(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}let i=Ey(r),o=s.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):Ge({allowReserved:e,name:n,value:a})).join(i);return r==="label"||r==="matrix"?i+o:o},Ge=({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},nn=({allowReserved:e,explode:t,name:n,style:r,value:s,valueOnly:i})=>{if(s instanceof Date)return i?s.toISOString():`${n}=${s.toISOString()}`;if(r!=="deepObject"&&!t){let l=[];Object.entries(s).forEach(([m,h])=>{l=[...l,m,e?h:encodeURIComponent(h)]});let g=l.join(",");switch(r){case"form":return`${n}=${g}`;case"label":return`.${g}`;case"matrix":return`;${n}=${g}`;default:return g}}let o=Oy(r),a=Object.entries(s).map(([l,g])=>Ge({allowReserved:e,name:r==="deepObject"?`${n}[${l}]`:l,value:g})).join(o);return r==="label"||r==="matrix"?o+a:a};var jy=/\{[^{}]+\}/g,Dy=({path:e,url:t})=>{let n=t,r=t.match(jy);if(r)for(let s of r){let i=!1,o=s.substring(1,s.length-1),a="simple";o.endsWith("*")&&(i=!0,o=o.substring(0,o.length-1)),o.startsWith(".")?(o=o.substring(1),a="label"):o.startsWith(";")&&(o=o.substring(1),a="matrix");let l=e[o];if(l==null)continue;if(Array.isArray(l)){n=n.replace(s,tn({explode:i,name:o,style:a,value:l}));continue}if(typeof l=="object"){n=n.replace(s,nn({explode:i,name:o,style:a,value:l,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(s,`;${Ge({name:o,value:l})}`);continue}let g=encodeURIComponent(a==="label"?`.${l}`:l);n=n.replace(s,g)}return n},Fo=({baseUrl:e,path:t,query:n,querySerializer:r,url:s})=>{let i=s.startsWith("/")?s:`/${s}`,o=(e??"")+i;t&&(o=Dy({path:t,url:o}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(o+=`?${a}`),o};function _r(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}var No=async(e,t)=>{let n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n};var xr={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)};var Go=({parameters:e={},...t}={})=>r=>{let s=[];if(r&&typeof r=="object")for(let i in r){let o=r[i];if(o==null)continue;let a=e[i]||t;if(Array.isArray(o)){let l=tn({allowReserved:a.allowReserved,explode:!0,name:i,style:"form",value:o,...a.array});l&&s.push(l)}else if(typeof o=="object"){let l=nn({allowReserved:a.allowReserved,explode:!0,name:i,style:"deepObject",value:o,...a.object});l&&s.push(l)}else{let l=Ge({allowReserved:a.allowReserved,name:i,value:o});l&&s.push(l)}}return s.join("&")},Bo=e=>{if(!e)return"stream";let t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(n=>t.startsWith(n)))return"blob";if(t.startsWith("text/"))return"text"}},$y=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,Ko=async({security:e,...t})=>{for(let n of e){if($y(t,n.name))continue;let r=await No(n,t.auth);if(!r)continue;let s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=r;break;case"cookie":t.headers.append("Cookie",`${s}=${r}`);break;default:t.headers.set(s,r);break}}},Pr=e=>Fo({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Go(e.querySerializer),url:e.url}),wr=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=rn(e.headers,t.headers),n},Uy=e=>{let t=[];return e.forEach((n,r)=>{t.push([r,n])}),t},rn=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let r=n instanceof Headers?Uy(n):Object.entries(n);for(let[s,i]of r)if(i===null)t.delete(s);else if(Array.isArray(i))for(let o of i)t.append(s,o);else i!==void 0&&t.set(s,typeof i=="object"?JSON.stringify(i):i)}return t},lt=class{fns=[];clear(){this.fns=[]}eject(t){let n=this.getInterceptorIndex(t);this.fns[n]&&(this.fns[n]=null)}exists(t){let n=this.getInterceptorIndex(t);return!!this.fns[n]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,n){let r=this.getInterceptorIndex(t);return this.fns[r]?(this.fns[r]=n,t):!1}use(t){return this.fns.push(t),this.fns.length-1}},Wo=()=>({error:new lt,request:new lt,response:new lt}),Ly=Go({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),qy={"Content-Type":"application/json"},ut=(e={})=>({...xr,headers:qy,parseAs:"auto",querySerializer:Ly,...e});var pt=(e={})=>{let t=wr(ut(),e),n=()=>({...t}),r=g=>(t=wr(t,g),n()),s=Wo(),i=async g=>{let m={...t,...g,fetch:g.fetch??t.fetch??globalThis.fetch,headers:rn(t.headers,g.headers),serializedBody:void 0};m.security&&await Ko({...m,security:m.security}),m.requestValidator&&await m.requestValidator(m),m.body!==void 0&&m.bodySerializer&&(m.serializedBody=m.bodySerializer(m.body)),(m.body===void 0||m.serializedBody==="")&&m.headers.delete("Content-Type");let h=Pr(m);return{opts:m,url:h}},o=async g=>{let{opts:m,url:h}=await i(g),_={redirect:"follow",...m,body:_r(m)},S=new Request(h,_);for(let x of s.request.fns)x&&(S=await x(S,m));let A=m.fetch,v;try{v=await A(S)}catch(x){let C=x;for(let P of s.error.fns)P&&(C=await P(x,void 0,S,m));if(C=C||{},m.throwOnError)throw C;return m.responseStyle==="data"?void 0:{error:C,request:S,response:void 0}}for(let x of s.response.fns)x&&(v=await x(v,S,m));let j={request:S,response:v};if(v.ok){let x=(m.parseAs==="auto"?Bo(v.headers.get("Content-Type")):m.parseAs)??"json";if(v.status===204||v.headers.get("Content-Length")==="0"){let P;switch(x){case"arrayBuffer":case"blob":case"text":P=await v[x]();break;case"formData":P=new FormData;break;case"stream":P=v.body;break;default:P={};break}return m.responseStyle==="data"?P:{data:P,...j}}let C;switch(x){case"arrayBuffer":case"blob":case"formData":case"text":C=await v[x]();break;case"json":{let P=await v.text();C=P?JSON.parse(P):{};break}case"stream":return m.responseStyle==="data"?v.body:{data:v.body,...j}}return x==="json"&&(m.responseValidator&&await m.responseValidator(C),m.responseTransformer&&(C=await m.responseTransformer(C))),m.responseStyle==="data"?C:{data:C,...j}}let k=await v.text(),d;try{d=JSON.parse(k)}catch{}let f=d??k,u=f;for(let x of s.error.fns)x&&(u=await x(f,v,S,m));if(u=u||{},m.throwOnError)throw u;return m.responseStyle==="data"?void 0:{error:u,...j}},a=g=>m=>o({...m,method:g}),l=g=>async m=>{let{opts:h,url:_}=await i(m);return qo({...h,body:h.body,headers:h.headers,method:g,onRequest:async(S,A)=>{let v=new Request(S,A);for(let j of s.request.fns)j&&(v=await j(v,h));return v},serializedBody:_r(h),url:_})};return{buildUrl:Pr,connect:a("CONNECT"),delete:a("DELETE"),get:a("GET"),getConfig:n,head:a("HEAD"),interceptors:s,options:a("OPTIONS"),patch:a("PATCH"),post:a("POST"),put:a("PUT"),request:o,setConfig:r,sse:{connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:a("TRACE")}};var Fy={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Ny=Object.entries(Fy),Ho=(e,t)=>{t||(t=new Map);for(let n of e)"in"in n?n.key&&t.set(n.key,{in:n.in,map:n.map}):"key"in n?t.set(n.key,{map:n.map}):n.args&&Ho(n.args,t);return t},Gy=e=>{for(let[t,n]of Object.entries(e))n&&typeof n=="object"&&!Object.keys(n).length&&delete e[t]},y=(e,t)=>{let n={body:{},headers:{},path:{},query:{}},r=Ho(t),s;for(let[i,o]of e.entries())if(t[i]&&(s=t[i]),!!s)if("in"in s)if(s.key){let a=r.get(s.key),l=a.map||s.key;a.in&&(n[a.in][l]=o)}else n.body=o;else for(let[a,l]of Object.entries(o??{})){let g=r.get(a);if(g)if(g.in){let m=g.map||a;n[g.in][m]=l}else n[g.map]=l;else{let m=Ny.find(([h])=>a.startsWith(h));if(m){let[h,_]=m;n[_][a.slice(h.length)]=l}else if("allowExtra"in s&&s.allowExtra){for(let[h,_]of Object.entries(s.allowExtra))if(_){n[h][a]=l;break}}}}return Gy(n),n};var zo=pt(ut({baseUrl:"http://localhost:4096"}));var I=class{client;constructor(t){this.client=t?.client??zo}},Sr=class{defaultKey="default";instances=new Map;get(t){let n=this.instances.get(t??this.defaultKey);if(!n)throw new Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return n}set(t,n){this.instances.set(n??this.defaultKey,t)}},kr=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"}]}]);return(n?.client??this.client).delete({url:"/auth/{providerID}",...n,...r})}set(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return(n?.client??this.client).put({url:"/auth/{providerID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},vr=class extends I{log(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"service"},{in:"body",key:"level"},{in:"body",key:"message"},{in:"body",key:"extra"}]}]);return(n?.client??this.client).post({url:"/log",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}agents(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/agent",...n,...r})}skills(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/skill",...n,...r})}},Ar=class extends I{moveSession(t,n){let r=y([t],[{args:[{in:"body",key:"sessionID"},{in:"body",key:"destination"},{in:"body",key:"moveChanges"}]}]);return(n?.client??this.client).post({url:"/experimental/control-plane/move-session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Rr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/capabilities",...n,...r})}},Tr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/console",...n,...r})}listOrgs(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/console/orgs",...n,...r})}switchOrg(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"accountID"},{in:"body",key:"orgID"}]}]);return(n?.client??this.client).post({url:"/experimental/console/switch",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Cr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"cursor"},{in:"query",key:"search"},{in:"query",key:"limit"},{in:"query",key:"archived"}]}]);return(n?.client??this.client).get({url:"/experimental/session",...n,...r})}background(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/experimental/session/{sessionID}/background",...n,...r})}},Ir=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/resource",...n,...r})}},Er=class extends I{generateName(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"context"}]}]);return(n?.client??this.client).post({url:"/experimental/project/{projectID}/copy/generate-name",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Mr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/workspace/adapter",...n,...r})}},Or=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/workspace",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"type"},{in:"body",key:"branch"},{in:"body",key:"extra"}]}]);return(n?.client??this.client).post({url:"/experimental/workspace",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}syncList(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/experimental/workspace/sync-list",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/workspace/status",...n,...r})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"id"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/experimental/workspace/{id}",...n,...r})}warp(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"sessionID"},{in:"body",key:"copyChanges"}]}]);return(n?.client??this.client).post({url:"/experimental/workspace/warp",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_adapter;get adapter(){return this._adapter??=new Mr({client:this.client})}},jr=class extends I{_controlPlane;get controlPlane(){return this._controlPlane??=new Ar({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new Rr({client:this.client})}_console;get console(){return this._console??=new Tr({client:this.client})}_session;get session(){return this._session??=new Cr({client:this.client})}_resource;get resource(){return this._resource??=new Ir({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Er({client:this.client})}_workspace;get workspace(){return this._workspace??=new Or({client:this.client})}},Dr=class extends I{get(t){return(t?.client??this.client).get({url:"/global/config",...t})}update(t,n){let r=y([t],[{args:[{key:"config",map:"body"}]}]);return(n?.client??this.client).patch({url:"/global/config",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},$r=class extends I{health(t){return(t?.client??this.client).get({url:"/global/health",...t})}event(t){return(t?.client??this.client).sse.get({url:"/global/event",...t})}dispose(t){return(t?.client??this.client).post({url:"/global/dispose",...t})}upgrade(t,n){let r=y([t],[{args:[{in:"body",key:"target"}]}]);return(n?.client??this.client).post({url:"/global/upgrade",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_config;get config(){return this._config??=new Dr({client:this.client})}},Ur=class extends I{subscribe(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).sse.get({url:"/event",...n,...r})}},Lr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/config",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"config",map:"body"}]}]);return(n?.client??this.client).patch({url:"/config",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}providers(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/config/providers",...n,...r})}},qr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return(n?.client??this.client).get({url:"/experimental/tool",...n,...r})}ids(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/tool/ids",...n,...r})}},Fr=class extends I{remove(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeRemoveInput",map:"body"}]}]);return(n?.client??this.client).delete({url:"/experimental/worktree",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/experimental/worktree",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeCreateInput",map:"body"}]}]);return(n?.client??this.client).post({url:"/experimental/worktree",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}reset(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeResetInput",map:"body"}]}]);return(n?.client??this.client).post({url:"/experimental/worktree/reset",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Nr=class extends I{text(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"pattern"}]}]);return(n?.client??this.client).get({url:"/find",...n,...r})}files(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"},{in:"query",key:"dirs"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(n?.client??this.client).get({url:"/find/file",...n,...r})}symbols(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"}]}]);return(n?.client??this.client).get({url:"/find/symbol",...n,...r})}},Gr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(n?.client??this.client).get({url:"/file",...n,...r})}read(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(n?.client??this.client).get({url:"/file/content",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/file/status",...n,...r})}},Br=class extends I{dispose(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/instance/dispose",...n,...r})}},Kr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/path",...n,...r})}},Wr=class extends I{raw(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/vcs/diff/raw",...n,...r})}},Hr=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/vcs",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/vcs/status",...n,...r})}diff(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"mode"},{in:"query",key:"context"}]}]);return(n?.client??this.client).get({url:"/vcs/diff",...n,...r})}apply(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"patch"}]}]);return(n?.client??this.client).post({url:"/vcs/apply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_diff;get diff2(){return this._diff??=new Wr({client:this.client})}},zr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/command",...n,...r})}},Vr=class extends I{status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/lsp",...n,...r})}},Yr=class extends I{status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/formatter",...n,...r})}},Xr=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/mcp/{name}/auth",...n,...r})}start(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/auth",...n,...r})}callback(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"code"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/auth/callback",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}authenticate(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...n,...r})}},Jr=class extends I{status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/mcp",...n,...r})}add(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return(n?.client??this.client).post({url:"/mcp",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}connect(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/connect",...n,...r})}disconnect(t,n){let r=y([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/mcp/{name}/disconnect",...n,...r})}_auth;get auth(){return this._auth??=new Xr({client:this.client})}},Qr=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/project",...n,...r})}current(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/project/current",...n,...r})}initGit(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/project/git/init",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"icon"},{in:"body",key:"commands"}]}]);return(n?.client??this.client).patch({url:"/project/{projectID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}directories(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/project/{projectID}/directories",...n,...r})}},Zr=class extends I{shells(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/pty/shells",...n,...r})}list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/pty",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(n?.client??this.client).post({url:"/pty",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/pty/{ptyID}",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/pty/{ptyID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(n?.client??this.client).put({url:"/pty/{ptyID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}connectToken(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/pty/{ptyID}/connect-token",...n,...r})}connect(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(n?.client??this.client).get({url:"/pty/{ptyID}/connect",...n,...r})}},es=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/question",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"answers"}]}]);return(n?.client??this.client).post({url:"/question/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}reject(t,n){let r=y([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/question/{requestID}/reject",...n,...r})}},ts=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/permission",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(n?.client??this.client).post({url:"/permission/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}respond(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"response"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},ns=class extends I{authorize(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"inputs"}]}]);return(n?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}callback(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return(n?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},rs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/provider",...n,...r})}auth(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/provider/auth",...n,...r})}_oauth;get oauth(){return this._oauth??=new ns({client:this.client})}},ss=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"scope"},{in:"query",key:"path"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"search"},{in:"query",key:"limit"}]}]);return(n?.client??this.client).get({url:"/session",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"parentID"},{in:"body",key:"title"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"workspaceID"}]}]);return(n?.client??this.client).post({url:"/session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}status(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/status",...n,...r})}delete(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"metadata"},{in:"body",key:"permission"},{in:"body",key:"time"}]}]);return(n?.client??this.client).patch({url:"/session/{sessionID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}children(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/children",...n,...r})}todo(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/todo",...n,...r})}diff(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"messageID"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/diff",...n,...r})}messages(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"before"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/message",...n,...r})}prompt(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/message",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}deleteMessage(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}",...n,...r})}message(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...n,...r})}fork(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/fork",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}abort(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/abort",...n,...r})}init(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"modelID"},{in:"body",key:"providerID"},{in:"body",key:"messageID"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/init",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}unshare(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}/share",...n,...r})}share(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/share",...n,...r})}summarize(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"providerID"},{in:"body",key:"modelID"},{in:"body",key:"auto"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/summarize",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}promptAsync(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"model"},{in:"body",key:"agent"},{in:"body",key:"noReply"},{in:"body",key:"tools"},{in:"body",key:"format"},{in:"body",key:"system"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}command(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"arguments"},{in:"body",key:"command"},{in:"body",key:"variant"},{in:"body",key:"parts"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/command",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}shell(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"command"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/shell",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}revert(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/revert",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}unrevert(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/session/{sessionID}/unrevert",...n,...r})}},is=class extends I{delete(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"part",map:"body"}]}]);return(n?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},os=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(n?.client??this.client).post({url:"/sync/history",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},as=class extends I{start(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/sync/start",...n,...r})}replay(t,n){let r=y([t],[{args:[{in:"query",key:"query_directory",map:"directory"},{in:"query",key:"workspace"},{in:"body",key:"body_directory",map:"directory"},{in:"body",key:"events"}]}]);return(n?.client??this.client).post({url:"/sync/replay",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}steal(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/sync/steal",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_history;get history(){return this._history??=new os({client:this.client})}},cs=class extends I{next(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).get({url:"/tui/control/next",...n,...r})}response(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(n?.client??this.client).post({url:"/tui/control/response",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},ls=class extends I{appendPrompt(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"text"}]}]);return(n?.client??this.client).post({url:"/tui/append-prompt",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}openHelp(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-help",...n,...r})}openSessions(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-sessions",...n,...r})}openThemes(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-themes",...n,...r})}openModels(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/open-models",...n,...r})}submitPrompt(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/submit-prompt",...n,...r})}clearPrompt(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(n?.client??this.client).post({url:"/tui/clear-prompt",...n,...r})}executeCommand(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"}]}]);return(n?.client??this.client).post({url:"/tui/execute-command",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}showToast(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"message"},{in:"body",key:"variant"},{in:"body",key:"duration"}]}]);return(n?.client??this.client).post({url:"/tui/show-toast",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}publish(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(n?.client??this.client).post({url:"/tui/publish",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}selectSession(t,n){let r=y([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/tui/select-session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}_control;get control(){return this._control??=new cs({client:this.client})}},us=class extends I{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},ps=class extends I{get(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/location",...n,...r})}},ds=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/agent",...n,...r})}},gs=class extends I{stage(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"messageID"},{in:"body",key:"files"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/revert/stage",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}clear(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/revert/clear",...n,...r})}commit(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/revert/commit",...n,...r})}},ms=class extends I{list(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/permission",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"action"},{in:"body",key:"resources"},{in:"body",key:"save"},{in:"body",key:"metadata"},{in:"body",key:"source"},{in:"body",key:"agent"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/permission",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}get(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/permission/{requestID}",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/permission/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},fs=class extends I{list(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/question",...n,...r})}reply(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{key:"questionV2Reply",map:"body"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reply",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}reject(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reject",...n,...r})}},ys=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"search"},{in:"query",key:"directory"},{in:"query",key:"project"},{in:"query",key:"subpath"},{in:"query",key:"cursor"}]}]);return(n?.client??this.client).get({url:"/api/session",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"body",key:"id"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"location"}]}]);return(n?.client??this.client).post({url:"/api/session",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}active(t){return(t?.client??this.client).get({url:"/api/session/active",...t})}get(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}",...n,...r})}switchAgent(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"agent"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/agent",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}switchModel(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"model"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/model",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}prompt(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"prompt"},{in:"body",key:"delivery"},{in:"body",key:"resume"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/prompt",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}compact(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/compact",...n,...r})}wait(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/wait",...n,...r})}context(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/context",...n,...r})}history(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"after"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/history",...n,...r})}events(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"after"}]}]);return(n?.client??this.client).sse.get({url:"/api/session/{sessionID}/event",...n,...r})}interrupt(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"}]}]);return(n?.client??this.client).post({url:"/api/session/{sessionID}/interrupt",...n,...r})}message(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/message/{messageID}",...n,...r})}messages(t,n){let r=y([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"cursor"}]}]);return(n?.client??this.client).get({url:"/api/session/{sessionID}/message",...n,...r})}_revert;get revert(){return this._revert??=new gs({client:this.client})}_permission;get permission(){return this._permission??=new ms({client:this.client})}_question;get question(){return this._question??=new fs({client:this.client})}},hs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/model",...n,...r})}},bs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/provider",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/provider/{providerID}",...n,...r})}},_s=class extends I{key(t,n){let r=y([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"key"},{in:"body",key:"label"}]}]);return(n?.client??this.client).post({url:"/api/integration/{integrationID}/connect/key",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}oauth(t,n){let r=y([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"methodID"},{in:"body",key:"inputs"},{in:"body",key:"label"}]}]);return(n?.client??this.client).post({url:"/api/integration/{integrationID}/connect/oauth",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},xs=class extends I{cancel(t,n){let r=y([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).delete({url:"/api/integration/attempt/{attemptID}",...n,...r})}status(t,n){let r=y([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/integration/attempt/{attemptID}",...n,...r})}complete(t,n){let r=y([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"},{in:"body",key:"code"}]}]);return(n?.client??this.client).post({url:"/api/integration/attempt/{attemptID}/complete",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Ps=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/integration",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/integration/{integrationID}",...n,...r})}_connect;get connect(){return this._connect??=new _s({client:this.client})}_attempt;get attempt(){return this._attempt??=new xs({client:this.client})}},ws=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).delete({url:"/api/credential/{credentialID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"},{in:"body",key:"label"}]}]);return(n?.client??this.client).patch({url:"/api/credential/{credentialID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}},Ss=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/permission/request",...n,...r})}},ks=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"projectID"}]}]);return(n?.client??this.client).get({url:"/api/permission/saved",...n,...r})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"id"}]}]);return(n?.client??this.client).delete({url:"/api/permission/saved/{id}",...n,...r})}},vs=class extends I{_request;get request(){return this._request??=new Ss({client:this.client})}_saved;get saved(){return this._saved??=new ks({client:this.client})}},As=class extends I{read(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/fs/read/*",...n,...r})}list(t,n){let r=y([t],[{args:[{in:"query",key:"location"},{in:"query",key:"path"}]}]);return(n?.client??this.client).get({url:"/api/fs/list",...n,...r})}find(t,n){let r=y([t],[{args:[{in:"query",key:"location"},{in:"query",key:"query"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(n?.client??this.client).get({url:"/api/fs/find",...n,...r})}},Rs=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/command",...n,...r})}},Ts=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/skill",...n,...r})}},Cs=class extends I{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},Is=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/pty",...n,...r})}create(t,n){let r=y([t],[{args:[{in:"query",key:"location"},{in:"body",key:"command"},{in:"body",key:"args"},{in:"body",key:"cwd"},{in:"body",key:"title"},{in:"body",key:"env"}]}]);return(n?.client??this.client).post({url:"/api/pty",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}remove(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).delete({url:"/api/pty/{ptyID}",...n,...r})}get(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/pty/{ptyID}",...n,...r})}update(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(n?.client??this.client).put({url:"/api/pty/{ptyID}",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}connectToken(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).post({url:"/api/pty/{ptyID}/connect-token",...n,...r})}connect(t,n){let r=y([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location[directory]"},{in:"query",key:"location[workspace]"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(n?.client??this.client).get({url:"/api/pty/{ptyID}/connect",...n,...r})}},Es=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/question/request",...n,...r})}},Ms=class extends I{_request;get request(){return this._request??=new Es({client:this.client})}},Os=class extends I{list(t,n){let r=y([t],[{args:[{in:"query",key:"location"}]}]);return(n?.client??this.client).get({url:"/api/reference",...n,...r})}},js=class extends I{remove(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"directory"},{in:"body",key:"force"}]}]);return(n?.client??this.client).delete({url:"/experimental/project/{projectID}/copy",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}create(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"strategy"},{in:"body",key:"directory"},{in:"body",key:"name"}]}]);return(n?.client??this.client).post({url:"/experimental/project/{projectID}/copy",...n,...r,headers:{"Content-Type":"application/json",...n?.headers,...r.headers}})}refresh(t,n){let r=y([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"}]}]);return(n?.client??this.client).post({url:"/experimental/project/{projectID}/copy/refresh",...n,...r})}},Ds=class extends I{_health;get health(){return this._health??=new us({client:this.client})}_location;get location(){return this._location??=new ps({client:this.client})}_agent;get agent(){return this._agent??=new ds({client:this.client})}_session;get session(){return this._session??=new ys({client:this.client})}_model;get model(){return this._model??=new hs({client:this.client})}_provider;get provider(){return this._provider??=new bs({client:this.client})}_integration;get integration(){return this._integration??=new Ps({client:this.client})}_credential;get credential(){return this._credential??=new ws({client:this.client})}_permission;get permission(){return this._permission??=new vs({client:this.client})}_fs;get fs(){return this._fs??=new As({client:this.client})}_command;get command(){return this._command??=new Rs({client:this.client})}_skill;get skill(){return this._skill??=new Ts({client:this.client})}_event;get event(){return this._event??=new Cs({client:this.client})}_pty;get pty(){return this._pty??=new Is({client:this.client})}_question;get question(){return this._question??=new Ms({client:this.client})}_reference;get reference(){return this._reference??=new Os({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new js({client:this.client})}},sn=class e extends I{static __registry=new Sr;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new kr({client:this.client})}_app;get app(){return this._app??=new vr({client:this.client})}_experimental;get experimental(){return this._experimental??=new jr({client:this.client})}_global;get global(){return this._global??=new $r({client:this.client})}_event;get event(){return this._event??=new Ur({client:this.client})}_config;get config(){return this._config??=new Lr({client:this.client})}_tool;get tool(){return this._tool??=new qr({client:this.client})}_worktree;get worktree(){return this._worktree??=new Fr({client:this.client})}_find;get find(){return this._find??=new Nr({client:this.client})}_file;get file(){return this._file??=new Gr({client:this.client})}_instance;get instance(){return this._instance??=new Br({client:this.client})}_path;get path(){return this._path??=new Kr({client:this.client})}_vcs;get vcs(){return this._vcs??=new Hr({client:this.client})}_command;get command(){return this._command??=new zr({client:this.client})}_lsp;get lsp(){return this._lsp??=new Vr({client:this.client})}_formatter;get formatter(){return this._formatter??=new Yr({client:this.client})}_mcp;get mcp(){return this._mcp??=new Jr({client:this.client})}_project;get project(){return this._project??=new Qr({client:this.client})}_pty;get pty(){return this._pty??=new Zr({client:this.client})}_question;get question(){return this._question??=new es({client:this.client})}_permission;get permission(){return this._permission??=new ts({client:this.client})}_provider;get provider(){return this._provider??=new rs({client:this.client})}_session;get session(){return this._session??=new ss({client:this.client})}_part;get part(){return this._part??=new is({client:this.client})}_sync;get sync(){return this._sync??=new as({client:this.client})}_tui;get tui(){return this._tui??=new ls({client:this.client})}_v2;get v2(){return this._v2??=new Ds({client:this.client})}};function Yo(e,t,n,r){if(!r?.throwOnError||e instanceof Error)return e;if(typeof e=="object"&&e!==null&&Object.keys(e).length>0){let i=e,o=typeof i.data?.message=="string"&&i.data.message||typeof i.message=="string"&&i.message||typeof i.name=="string"&&i.name||Vo(n,t);return new Error(o,{cause:{body:e,status:t?.status}})}if(typeof e=="string"&&e.length>0)return new Error(e,{cause:{body:e,status:t?.status}});let s=t?"(empty response body)":"network error (no response)";return new Error(`opencode server ${Vo(n,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function Vo(e,t){let n=e?.method??"?",r=e?.url??"?",s=t?.status,i=t?.statusText;return`${n} ${r}${s?" \u2192 "+s:""}${i?" "+i:""}`}function By(e,t,n){if(e)return t&&(e===t||n&&e===n(t))?t:e}function Ky(e,t){if(e.method!=="GET"&&e.method!=="HEAD")return e;let n=new URL(e.url),r=!1;for(let[i,o]of[["x-opencode-directory","directory"],["x-opencode-workspace","workspace"]]){let a=By(e.headers.get(i),o==="directory"?t.directory:t.workspace,o==="directory"?encodeURIComponent:void 0);if(a){for(let l of n.pathname.startsWith("/api/")?[o,`location[${o}]`]:[o])n.searchParams.has(l)||n.searchParams.set(l,a);r=!0}}if(!r)return e;let s=new Request(n,e);return s.headers.delete("x-opencode-directory"),s.headers.delete("x-opencode-workspace"),s}function $s(e){e?.fetch||(e={...e,fetch:r=>(r.timeout=!1,fetch(r))}),e?.directory&&(e.headers={...e.headers,"x-opencode-directory":encodeURIComponent(e.directory)}),e?.experimental_workspaceID&&(e.headers={...e.headers,"x-opencode-workspace":e.experimental_workspaceID});let t=pt(e);return t.interceptors.request.use(n=>Ky(n,{directory:e?.directory,workspace:e?.experimental_workspaceID})),t.interceptors.response.use(n=>{if(n.headers.get("content-type")==="text/html")throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");return n}),t.interceptors.error.use(Yo),new sn({client:t})}var Wy=new Set(["api","cli","mobile","tui","web"]);function Xo(e){let t=e?.trim().toLowerCase();return t&&Wy.has(t)?t:null}function Hy(e){return new Promise(t=>setTimeout(t,e))}async function on(e,t,n){let r=Math.max(1,t?.attempts??1),s=t?.baseDelayMs??0,i=t?.invalidateBetweenAttempts??!1,o=null;for(let a=0;a<r;a++)if(a>0&&(i&&n?.(),s>0&&await Hy(s)),o=await e(),o)return o;return o}var Us=12e4;function zy(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function Jo(e,t,n=Us){let r=e instanceof Request?e.signal:t?.signal;if(zy(e))return r??void 0;let s=AbortSignal.timeout(n);return r?typeof AbortSignal.any=="function"?AbortSignal.any([r,s]):r:s}function an(){return new Response(JSON.stringify({error:"Not authenticated"}),{status:401,headers:{"Content-Type":"application/json"}})}var T=class extends Error{status;code;details;data;detail;response;url;endpoint;timeout;constructor(t,n={}){super(t),this.name="ApiError";let{name:r,stack:s,...i}=n;Object.assign(this,i),r&&(this.name=r),s&&(this.stack=s);let o=typeof t=="string"?t:t==null?"":String(t);Object.defineProperty(this,"message",{value:o,enumerable:!0,writable:!0,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype)}},ce=class extends T{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},je=class extends T{constructor(t,n,r,s={}){super(r||n.message||`Billing Error: ${t}`,{...s,status:t,detail:n}),this.name="BillingError"}},Be=class extends T{constructor(t=431,n,r){let s="Request headers are too large";super(r||n?.message||s,{status:t,detail:{message:n?.message||s,suggestion:n?.suggestion||"Try uploading files one at a time, or reduce the number of files in a single request."}}),this.name="RequestTooLargeError"}},Vy="ENDPOINT_RETIRED";function H(e,t){let n=t?` ${t}`:"";return new T(`${e}() is retired: the Kortix API no longer serves this endpoint.${n}`,{code:Vy})}var Ls="feature_disabled";function Qo(e){if(!(e instanceof T)||e.status!==403||e.code!==Ls)return null;let t=e.details??e.data;return t&&typeof t=="object"?t:{}}function Zo(e){let t=Qo(e);return t?(typeof t.feature=="string"&&!e.feature&&(e.feature=t.feature),!0):!1}function ea(e){let t=Qo(e);if(!t)return null;let n=e.feature;return typeof n=="string"?n:typeof t.feature=="string"?t.feature:null}function cn(e){let t=e.response?.status||e.status;if(t!==402)return e;let n=e.response?.data||e.data||e.detail||{},r=n?.detail||n;return new je(t,{message:r?.message||e.message||"Billing error",...r},void 0,{code:e.code,details:e.details,data:e.data,response:e.response,url:e.url,endpoint:e.endpoint})}function ta(e){return e instanceof je}function na(e){if(!(e instanceof je))return null;let t=e.detail?.message?.toLowerCase()||"";return t.includes("credit")||t.includes("balance")||t.includes("insufficient")?{alertTitle:"You ran out of credits",alertSubtitle:"Upgrade your plan to get more credits and continue using the AI assistant."}:{alertTitle:"Billing check failed",alertSubtitle:e.detail?.message||"Please upgrade to continue."}}function ye(){return typeof DOMException=="function"?new DOMException("Aborted","AbortError"):Object.assign(new Error("Aborted"),{name:"AbortError"})}function he(e,t){return new Promise((n,r)=>{let s=()=>{t.removeEventListener("abort",s),r(ye())};t.addEventListener("abort",s,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",s)),t.aborted&&s()})}function ln(e,t){return new Promise((n,r)=>{let s=()=>{clearTimeout(i),t?.removeEventListener("abort",s),r(ye())},i=setTimeout(()=>{t?.removeEventListener("abort",s),n()},e);t?.aborted?s():t?.addEventListener("abort",s,{once:!0})})}var Yy="X-Kortix-Impersonate",Fs="kortix.impersonation",De=null,un=!1,qs=new Set;function Ns(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}function Xy(e,t=Date.now()){if(!e||!e.grantId||!e.accountId)return!1;let n=Date.parse(e.expiresAt);return Number.isFinite(n)&&n>t}function Jy(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t?.grantId!="string"||typeof t?.accountId!="string"?null:{grantId:t.grantId,accountId:t.accountId,accountName:typeof t.accountName=="string"?t.accountName:null,expiresAt:typeof t.expiresAt=="string"?t.expiresAt:""}}catch{return null}}function ra(){for(let e of qs)try{e()}catch{}}function Qy(){return un||(un=!0,De=Jy(Ns()?.getItem(Fs)??null)),De&&!Xy(De)?(sa(),null):De}function yv(e){if(un=!0,!e){sa();return}De=e;try{Ns()?.setItem(Fs,JSON.stringify(e))}catch{}ra()}function sa(){un=!0;let e=De!==null;De=null;try{Ns()?.removeItem(Fs)}catch{}e&&ra()}function hv(e){return qs.add(e),()=>{qs.delete(e)}}var Zy=/(^|\/)admin\/(api|analytics)(\/|$)/;function eh(e){let t=e;if(/^https?:\/\//.test(e))try{t=new URL(e).pathname}catch{t=e}return!Zy.test(t)}function ia(e){if(e!==void 0&&!eh(e))return{};let t=Qy();return t?{[Yy]:t.grantId}:{}}var Ws=!1;function th(e){Ws=e}function nh(){return Ws}function rh(e){return e?e instanceof Headers||Array.isArray(e)?[...new Headers(e).entries()]:Object.entries(e):[]}function Bs(e,t){let n=t.toLowerCase();return Object.keys(e).some(r=>r.toLowerCase()===n)}function dt(e,t,n){let r=t.toLowerCase();for(let s of Object.keys(e))s.toLowerCase()===r&&delete e[s];e[t]=n}function Ks(e,t){let n={},r=[e instanceof Request?e.headers:void 0,t.headers];for(let[s,i]of r.flatMap(rh))dt(n,s,i);return n}function oa(e,t,n){let r={...t},s=Xo(L().clientSource);s&&!Bs(r,"x-kortix-client")&&dt(r,"X-Kortix-Client",s),Ws&&dt(r,"x-kortix-admin-bypass","1");for(let[i,o]of Object.entries(ia(e)))dt(r,i,o);return Bs(r,"authorization")||dt(r,"Authorization",`Bearer ${n}`),r}function sh(e){return typeof ReadableStream<"u"&&e.body instanceof ReadableStream}function aa(e,t,n,r,s){if(t instanceof Request){let a=new Headers(oa(t.url,Ks(t,n),r));return e(new Request(t,{headers:a,...s?{signal:s}:{}}))}let i=String(t),o=oa(i,Ks(t,n),r);return e(i,{...n,headers:o,...s?{signal:s}:{}})}async function Gs(e){return on(()=>L().getToken(),e)}async function gt(e,t={},n={}){let{retryOnAuthError:r=!0,timeoutMs:s=Us}=n,i=n.fetch??L().fetch??fetch,o=s===null?(e instanceof Request?e.signal:t.signal)??void 0:Jo(e,t,s);if(o?.aborted)throw ye();let a=await(o?he(Gs(),o):Gs());if(!a)throw new ce;let l=r&&!sh(t)&&!Bs(Ks(e,t),"authorization"),g=l&&e instanceof Request?e.clone():e,m=await aa(i,e,t,a,o);if(m.status!==401||!l)return m;let h=await Gs({attempts:2,baseDelayMs:200});return!h||h===a?m:aa(i,g,t,h,o)}async function Hs(){return L().getToken()}async function mt(e){return on(()=>L().getToken(),e,zs)}function zs(){}function Cv(e){}function Iv(e){}async function ft(){return Hs()}async function Ev(e){return mt(e)}async function N(e,t,n){try{return await gt(e,t,{retryOnAuthError:n?.retryOnAuthError,timeoutMs:n?.timeoutMs})}catch(r){if(r instanceof ce)return an();throw r}}var Ke={url:null,sandboxId:null,dbSandboxId:null,version:0},ih=new Set;function ca(e,t=null,n=null){if(!(Ke.url===e&&Ke.sandboxId===t&&Ke.dbSandboxId===n)){Ke={url:e,sandboxId:t,dbSandboxId:n,version:Ke.version+1};for(let r of ih)r()}}function la(){return Ke.url}function oh(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function yt(){return oh(L().backendUrl||"http://localhost:8008/v1")}function ua(){let e=L().sandboxId;return e?`${yt()}/p/${e}/8000`:""}function ah(e,t=8e3){return`${yt()}/p/${e}/${t}`}function ht(e,t=8e3){return ah(e,t)}var de=()=>L().backendUrl||"",ch="feature_not_supported",lh="model_not_servable",uh="provision_in_flight",ph="analytics_unavailable",dh="accounts_list_unavailable",pa="request_deadline",gh=/^Request exceeded the \d+s server processing deadline$/,mh=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===pa||gh.test(n),fh="git_mirror_unavailable",yh=/^git mirror is temporarily unavailable$/,hh=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===fh||yh.test(n),bh=new Set([502,503,504]),_h=e=>bh.has(e),da=e=>{let t=(e??"GET").toUpperCase();return t==="GET"||t==="HEAD"},xh=e=>da(e)||(e??"GET").toUpperCase()==="DELETE",Ph=2,pn=e=>e?.name==="AbortError"||e?.name==="AbortSignal"||e instanceof Error&&e.message.includes("aborted");async function ve(e,t={}){let{showErrors:n=!0,errorContext:r,timeout:s=3e4,deadlineCoversBody:i=!1,...o}=t,a=new AbortController,l=a,g=()=>l.abort();o.signal?.addEventListener("abort",g,{once:!0});let m=null,h=!1,_=!1;try{if(o.signal?.aborted)throw ye();m=setTimeout(()=>{!h&&!a.signal.aborted&&(h=!0,_=!0,a.abort())},s);let S={...o.body instanceof FormData?{}:{"Content-Type":"application/json"},...o.headers},A=da(o.method),v=xh(o.method),j=v?Ph+1:1,k;for(let u=0;u<j;u++){u>0&&await ln(250*2**(u-1),o.signal??void 0);let x=u===0?a:new AbortController;l=x,o.signal?.aborted&&x.abort(),u>0&&(m=setTimeout(()=>{_=!0,x.abort()},s));try{k=await he(gt(e,{...o,headers:S,signal:x.signal,credentials:o.credentials??"omit"},{timeoutMs:null}),x.signal)}catch(P){if(m&&(clearTimeout(m),m=null),P instanceof ce)return{error:new ce,success:!1};if(_&&pn(P)&&!o.signal?.aborted&&v&&u<j-1){_=!1;continue}if(pn(P)||u===j-1)throw P;continue}if(!(A&&_h(k.status)&&u<j-1)){!i&&m&&(clearTimeout(m),m=null);break}try{await he(k.arrayBuffer(),x.signal)}catch(P){if(pn(P))throw P}finally{m&&(clearTimeout(m),m=null)}}if(!k.ok){let u=`HTTP ${k.status}: ${k.statusText}`,x=null;try{x=await he(k.json(),l.signal),typeof x.message=="string"?u=x.message:x.error&&typeof x.error=="string"?u=x.error:typeof x.detail=="string"?u=x.detail:typeof x.detail?.message=="string"?u=x.detail.message:typeof x.reason=="string"&&(u=x.reason)}catch{}if(l.signal.aborted)throw ye();let C=mh(k.status,x,u),P=hh(k.status,x,u),w=new T(u,{status:k.status,response:k,details:x||void 0,data:x,detail:x?.detail,code:C?pa:x?.code||x?.error_code||x?.detail?.error_code||k.status.toString()});if(k.status===402&&(w=cn(w)),k.status===403&&x?.code==="account_mfa_required"&&typeof window<"u"&&typeof window.dispatchEvent=="function")try{window.dispatchEvent(new CustomEvent("kortix:mfa-required"))}catch{}k.status===431&&(w=new Be(431,{message:"Request is too large to process",suggestion:"Try uploading files one at a time, or reduce the number of files attached to your message."}));let E=k.status===501&&x?.code===ch,R=k.status===409&&x?.code===lh,D=k.status===409&&x?.code===uh,U=k.status===503&&x?.code===ph,b=k.status===503&&x?.code===dh;return n&&!E&&!R&&!D&&!U&&!b&&!P&&!C&&L().onError?.(w,r),{error:w,success:!1}}let d,f=k.headers.get("content-type");return f?.includes("application/json")?d=await he(k.json(),l.signal):f?.includes("text/")?d=await he(k.text(),l.signal):d=await he(k.blob(),l.signal),{data:d,success:!0,headers:k.headers}}catch(S){m&&(clearTimeout(m),m=null);let A=pn(S);A&&(h=!0);let v;if(A){if(!_)return{error:new T("Request aborted",{name:"AbortError",code:"ABORTED"}),success:!1};let j=e.replace(de(),"")||e;v=new T(`Request timed out after ${Math.round(s/1e3)}s: ${j}`,{code:"TIMEOUT",url:e,endpoint:j,timeout:s})}else S instanceof Error?(v=new T(S.message,{name:S.name||"ApiError",stack:S.stack}),n&&L().onError?.(v,r)):(v=new T(String(S)),n&&L().onError?.(v,r));return{error:v,success:!1}}finally{m&&clearTimeout(m),o.signal?.removeEventListener("abort",g)}}var Nv={async execute(e,t){try{let{data:n,error:r}=await e();if(r){let s=new T(r.message||"Database error",{code:r.code,details:r});return L().onError?.(s,t),{error:s,success:!1}}return{data:n,success:!0}}catch(n){let r=n instanceof Error?new T(n.message,{name:n.name||"ApiError",stack:n.stack}):new T(String(n));return L().onError?.(r,t),{error:r,success:!1}}}};async function wh(e,t,n={}){let{timeout:r=3e4,fetch:s}=n,i=new AbortController,o=setTimeout(()=>i.abort(),r);try{return await gt(`${de()}${e}`,{method:"POST",headers:{Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify(t),signal:i.signal,credentials:"omit"},{timeoutMs:null,fetch:s})}catch(a){if(a instanceof ce)return an();throw a}finally{clearTimeout(o)}}var c={putRaw:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"PUT",body:t,headers:{"Content-Type":"application/octet-stream",...n?.headers}}),get:(e,t)=>ve(`${de()}${e}`,{...t,method:"GET"}),post:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,n)=>ve(`${de()}${e}`,{...n,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>ve(`${de()}${e}`,{...t,method:"DELETE"}),upload:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],ve(`${de()}${e}`,{...s,method:"POST",body:t,headers:i})},uploadPut:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],ve(`${de()}${e}`,{...s,method:"PUT",body:t,headers:i})},postStream:wh};var bt=new Map,Vs=new Map;function Ys(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function ga(e){return bt.get(Ys(e))??null}function ma(){return[...bt.values()].filter(e=>typeof e=="string")}function fa(e){return bt.has(Ys(e))}async function We(e){let t=Ys(e),n=bt.get(t);if(n!==void 0)return n;let r=Vs.get(t);if(r)return r;let s=(async()=>{try{let i=await c.get("/p/config",{showErrors:!1,errorContext:{operation:"load preview config",silent:!0}});if(!i.success)return null;let o=typeof i.data?.preview_url_template=="string"?i.data.preview_url_template:null;return bt.set(t,o),o}catch{return null}finally{Vs.delete(t)}})();return Vs.set(t,s),s}function ya(e){let{apiBaseUrl:t}=e;return fa(t)||We(t).catch(()=>{}),{sandboxId:e.sandboxId,backendPort:e.backendPort,apiBaseUrl:t,previewUrlTemplate:ga(t)}}function be(){let e=la();return e||(L().billingEnabled??!1?"":ua())}async function Xs(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function Js(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function ha(e){let t=Js(e),n=await N(`${t}/env`);if(!n.ok)throw new Error(await Xs(n,"Failed to load secrets"));return(await n.json()).secrets??{}}async function ba(e,t,n){let r=Js(e),s=await N(`${r}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!s.ok)throw new Error(await Xs(s,"Failed to save secret"))}async function _a(e,t){let n=Js(e),r=await N(`${n}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await Xs(r,"Failed to delete secret"))}var Sh={list:ha,set:ba,delete:_a};async function kh(e,t,n){let r=e;for(;r.endsWith("/");)r=r.slice(0,-1);let s=await N(`${r}/kortix/triggers${t}`,{...n,headers:{"Content-Type":"application/json",...n?.headers}}),i=await s.json();if(!s.ok)throw new Error(i?.error||i?.message||`Request failed with ${s.status}`);return i}function Ae(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return t===e.length?e:e.slice(0,t)}async function dn(e,t){let n=await e.json().catch(()=>({}));return n?.error||n?.message||e.statusText||t}function _t(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return Ae(e)}async function xa(e){let t=_t(e),n=await N(`${t}/kortix/pty`);if(!n.ok)throw new Error(await dn(n,"Failed to list terminals"));return n.json()}async function Pa(e,t){let n=_t(e),r=await N(`${n}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok)throw new Error(await dn(r,"Failed to create terminal"));return r.json()}async function wa(e,t,n){let r=_t(e),s=await N(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw new Error(await dn(s,"Failed to update terminal"));return s.json()}async function Sa(e,t){let n=_t(e),r=await N(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await dn(r,"Failed to remove terminal"))}async function ka(e,t,n){let r=_t(t),i=`${(()=>{try{let g=new URL(r);return g.protocol==="https:"?g.protocol="wss:":g.protocol==="http:"&&(g.protocol="ws:"),typeof window<"u"&&window.location.protocol==="https:"&&g.protocol==="ws:"&&(g.protocol="wss:"),Ae(g.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,o=new URLSearchParams,a=await ft();a&&o.set("token",a),n?.wake&&o.set("wake","1");let l=o.toString();return l?`${i}${i.includes("?")?"&":"?"}${l}`:i}function vh(e){let t=e.reason.trim().toLowerCase();return t.includes("pty not found")?"replace":t.includes("pty exited")?"ended":e.hadError||t.includes("idle timeout")||t.includes("upstream error")||e.code!==1e3?"reconnect":"ended"}var Re="\x1B",va="\x07",Ah="\0",Qs=`(?:${va}|${Re}\\\\)`,Rh=[new RegExp(`${Re}\\]697;[^${va}${Re}]*${Qs}`,"g"),new RegExp(`${Ah}?\\{"cursor":\\d+\\}`,"g"),new RegExp(`${Re}\\][0-9]+;rgb:[0-9a-fA-F/]+${Qs}`,"g"),new RegExp(`${Re}\\]4;[0-9]+;rgb:[0-9a-fA-F/]+${Qs}`,"g"),new RegExp(`${Re}\\[\\??[0-9;]*\\$y`,"g"),new RegExp(`${Re}\\[\\d+;\\d+R`,"g"),new RegExp(`${Re}\\[\\?[0-9;]*c`,"g")];function Th(e){let t=e;for(let n of Rh)t=t.replace(n,"");return t}var Ch={list:xa,create:Pa,update:wa,remove:Sa,webSocketUrl:ka};async function $(e,t,n,r){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let i=await N(`${s}${t}`,{...n,headers:{"Content-Type":"application/json",...n?.headers}},r),o=await i.text(),a={};try{a=o?JSON.parse(o):{}}catch{a={}}if(!i.ok)throw new Error(a?.error||a?.message||a?.details||o.slice(0,200)||`Request failed with ${i.status}`);return a}async function uA(e,t={}){let n=new URLSearchParams;t.projectId&&n.set("project_id",t.projectId),t.status&&n.set("status",t.status);let r=n.toString()?`?${n}`:"";return $(e,`/kortix/tasks${r}`)}async function pA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function dA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function gA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function mA(e,t){return $(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function fA(e,t,n){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function yA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function hA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function bA(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function _A(e,t){let n=t?`?project_id=${encodeURIComponent(t)}`:"";return $(e,`/kortix/tickets${n}`)}async function xA(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function PA(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function wA(e,t){return $(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function SA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function kA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(n)})}async function vA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(n)})}async function AA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(n)})}async function RA(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(n)})}async function TA(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function CA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function IA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:n})})}async function EA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function MA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:n})})}async function OA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function jA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:n})})}async function DA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function $A(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function UA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(n)})}async function LA(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function qA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"DELETE"})}async function FA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}/persona`)}async function NA(e,t,n=200){return $(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${n}`)}async function GA(e){return $(e,"/kortix/projects")}async function BA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function KA(e,t){return $(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function WA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function HA(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function zA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function VA(e,t,n="all"){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${n}`)}async function YA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`)}async function XA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/events`)}async function JA(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(n)})}async function QA(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function ZA(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/close`,{method:"POST",body:JSON.stringify(r)})}async function eR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/reopen`,{method:"POST"})}async function tR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"DELETE"})}async function nR(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function rR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}/events`)}async function sR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(n)})}async function iR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`)}async function oR(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`,{method:"DELETE"})}var Ih=1e4,Eh={retryOnAuthError:!1};function He(e,t,n){return $(e,t,{signal:AbortSignal.timeout(Ih),...n},Eh)}async function aR(e,t=!1){return(await He(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function cR(e){return(await He(e,"/kortix/services/templates")).templates??[]}async function lR(e,t){return(await He(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function uR(e,t,n){let r=n==="delete",s=r?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${n}`;return He(e,s,{method:r?"DELETE":"POST"})}async function pR(e,t){return He(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function dR(e,t){return He(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var gn=new Map,xt=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function $e(){let e=be();if(!e)throw new xt;return Te(e)}function Te(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=gn.get(e);if(t)return t;if(!br())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let n=$s({baseUrl:e,fetch:N});return gn.set(e,n),n}function _R(e){gn.delete(e)}function xR(){gn.clear()}var mn=new Map;function PR(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=mn.get(e);if(t)return t;let n=$s({baseUrl:e,fetch});return mn.set(e,n),n}function wR(e){mn.delete(e)}function SR(){mn.clear()}async function Mh(e){let t=await e.text().catch(()=>"");try{let n=JSON.parse(t);return n?.error||n?.message||t||e.statusText||`HTTP ${e.status}`}catch{return t||e.statusText||`HTTP ${e.status}`}}async function kR(e){let t=be();if(!t)throw new T("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading",{code:"RUNTIME_UNAVAILABLE"});let n=e==="full"?"/kortix/refresh":"/global/dispose",r=await N(`${t}${n}`,{method:"POST"}),s=r.headers.get("content-type")??"",i=/^application\/([\w.+-]+\+)?json\b/i.test(s.trim());if(!r.ok)throw new T(`System reload failed (${r.status}): ${await Mh(r)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});if(!i)throw new T(`System reload endpoint is unavailable on this sandbox (${n})`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});let o;try{o=await r.json()}catch(l){throw new T(`System reload returned malformed JSON from ${n}: ${l instanceof Error?l.message:String(l)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"})}let a=o===!0||typeof o=="object"&&o!==null&&o.ok===!0;return{success:a,mode:e,steps:a?[e==="full"?"refreshed workspace and restarted runtime":"reloaded config in place"]:[],errors:a?[]:[`the sandbox did not confirm the reload (${n})`]}}function Ca(e){if(e.error){let t=e.error,n=t?.data?.message||t?.message||(typeof t?.error=="string"?t.error:null)||"SDK request failed";throw new T(n,{status:t?.response?.status??t?.status,response:t?.response,details:t})}return e.data}async function ze(e){let t=await e.text().catch(()=>""),n=null;try{n=JSON.parse(t)}catch{}return n?.error||t||e.statusText||`HTTP ${e.status}`}function ne(e){let t=(e??be()).trim();if(!t)throw new xt;return t}async function yn(e,t){let n=await N(`${ne(t)}${e}`);if(!n.ok)throw new T(await ze(n),{status:n.status,response:n});return n.json()}var ti=["/workspace","/tmp","/home","/opt"],Oh=ti.filter(e=>e!=="/workspace");function Ia(e){return ti.some(t=>e===t||e.startsWith(`${t}/`))}function kt(e){return Ia(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function Ve(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(Oh.some(n=>t===n||t.startsWith(`${n}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var Ea=Ve;async function vt(e,t){let n=ne(t),r=Ve(e)||".";return(await yn(`/file?path=${encodeURIComponent(r)}`,n)).map(i=>({...i,path:i.absolute||`/workspace/${i.path}`}))}async function At(e,t){let n=ne(t),r=Ve(e),s=await N(`${n}/file/content?path=${encodeURIComponent(r)}`);if(!s.ok)throw new T(await ze(s),{status:s.status,response:s});return s.json()}async function jh(e,t,n){let r=ne(n),s=Ve(e),i=await N(`${r}/file/raw?path=${encodeURIComponent(s)}`);if(!i.ok)throw new T(await ze(i),{status:i.status,response:i});if((i.headers.get("content-type")||"").includes("text/html"))throw new T("File could not be loaded (raw byte route unavailable)",{status:i.status,response:i,code:"INVALID_CONTENT_TYPE"});let o=await i.blob();return t&&(!o.type||o.type==="application/octet-stream")?new Blob([o],{type:t}):o}async function Rt(e,t){let n=ne(t);try{return await jh(e,void 0,n)}catch{}let r=await At(e,n);if(r.encoding==="base64"&&r.content){let s=Uint8Array.from(atob(r.content),i=>i.charCodeAt(0));return new Blob([s],{type:r.mimeType||"application/octet-stream"})}return new Blob([r.content??""],{type:r.mimeType||"text/plain;charset=utf-8"})}async function hn(e){return yn("/file/status",ne(e))}async function bn(e,t,n){let r=ne(n),s=new URLSearchParams({query:e});return t?.type&&s.set("type",t.type),t?.limit&&s.set("limit",String(t.limit)),yn(`/find/file?${s.toString()}`,r)}async function _n(e,t){let n=ne(t);return(await yn(`/find?pattern=${encodeURIComponent(e)}`,n)).map(s=>({path:typeof s.path=="string"?s.path:s.path?.text??"",lines:typeof s.lines=="string"?s.lines:s.lines?.text??"",line_number:s.line_number,absolute_offset:s.absolute_offset,submatches:(s.submatches??[]).map(i=>({start:i.start,end:i.end}))}))}var Pt=[400,1200],Dh=e=>e===408||e===429||e===502||e===503||e===504,Aa=e=>new Promise(t=>setTimeout(t,e));function $h(e){let t=e?.name;return t==="TimeoutError"||t==="AbortError"}var Zs=3e4,Uh=15*6e4,Lh=256;function wt(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return Zs;let t=Zs+e/Lh;return Math.min(Uh,Math.max(Zs,Math.round(t)))}async function qh(e){let t=await e.text().catch(()=>""),n=null;try{n=t?JSON.parse(t):null}catch{}let r=n?.error||n?.message||n?.data?.message;return typeof r=="string"&&r.trim()?r.trim():(e.headers.get("content-type")||"").includes("text/html")||/<html[\s>]/i.test(t)?e.status===502||/bad gateway/i.test(t)?"Bad gateway while reaching the sandbox upload service. Please retry.":e.statusText||`HTTP ${e.status}`:t.replace(/\s+/g," ").trim().slice(0,500)||e.statusText||`HTTP ${e.status}`}async function fn(e,t){let n;for(let s=0;s<=Pt.length;s++){let i;try{i=await t(e())}catch(a){if(n=a,$h(a)||s===Pt.length)break;await Aa(Pt[s]);continue}if(i.ok)return i.json();let o=await qh(i);if(n=new T(`Upload failed (${i.status}): ${o}`,{status:i.status,response:i}),!Dh(i.status)||s===Pt.length)throw n;await Aa(Pt[s])}if(n instanceof T)throw n;let r=n instanceof Error?n.message:String(n||"request failed");throw new T(`Upload failed: ${r}`)}var ei=64*1024;function Ra(e,t){try{e?.onProgress?.(t)}catch{}}function Ta(e,t,n){let r=new FormData,s=(t??"").trim();return s&&r.append("path",s.startsWith("/")?s:`/${s}`),n&&r.append("filename",n),n?r.append("file",e,n):r.append("file",e),r}function Fh(e){let t=e.lastIndexOf("/");return t<0?{parent:"",name:e}:{parent:e.slice(0,t)||"/",name:e.slice(t+1)}}async function Tt(e,t,n,r,s){let i=typeof r=="string"?r:void 0,o=typeof r=="string"?s:r,a=ne(i),l=wt(e.size),g=n||(e instanceof File?e.name:"")||"";if(e.size<=ei){let S=await fn(()=>Ta(e,t,g),A=>N(`${a}/file/upload`,{method:"POST",body:A},{timeoutMs:l}));return Ra(o,{loadedBytes:e.size,totalBytes:e.size}),S}let h=(await fn(()=>Ta(new Blob([],{type:e.type}),t,g),S=>N(`${a}/file/upload`,{method:"POST",body:S},{timeoutMs:wt(0)})))[0]?.path;if(!h)throw new T("Upload reservation returned no file path",{code:"UPLOAD_NO_RESULT"});let _=Fh(h);if(!_.name)throw new T(`Upload reservation returned an invalid file path: ${h}`,{code:"UPLOAD_INVALID_PATH"});try{for(let S=0;S<e.size;S+=ei){let A=Math.min(e.size,S+ei),v=e.slice(S,A,e.type),j=await fn(()=>{let k=new FormData;return _.parent&&k.append("path",_.parent),k.append("filename",_.name),k.append("first",S===0?"true":"false"),k.append("offset",String(S)),k.append("file",v,_.name),k},k=>N(`${a}/file/append`,{method:"POST",body:k},{timeoutMs:wt(v.size)}));if(j.path!==h||j.size!==A)throw new T(`Upload verification failed for ${h}: expected ${A} bytes, received ${j.size}`,{code:"UPLOAD_SIZE_MISMATCH"});Ra(o,{loadedBytes:A,totalBytes:e.size})}}catch(S){throw await Ye(h,a).catch(()=>{}),S}return[{path:h,size:e.size}]}function Nh(e,t,n){let r=ne(n),s=wt(t.size);return fn(()=>{let i=new FormData;return i.append(e,t,e.split("/").pop()||"file"),i},i=>N(`${r}/file/upload`,{method:"POST",body:i},{timeoutMs:s}))}var St=class extends T{path;constructor(t){super(`A file or folder already exists at ${t}`,{status:409,code:"FILE_EXISTS"}),this.name="FileExistsError",this.path=t}};async function xn(e,t){let n=ne(t),r=e.trim(),i=(r.startsWith("/")?r:`/${r}`).split("/"),o=i.pop()||"untitled",a=i.join("/")||"/workspace",l=kt(`${a}/${o}`),g=[];try{g=await vt(Ma(l),n)}catch(h){if(!(h instanceof T&&h.status===404))throw h}if(g.some(h=>h.name===Oa(l)))throw new St(l);let m=await ja(l,new Blob([],{type:"application/octet-stream"}),n,{overwrite:!1});return[{path:m.path,size:m.bytes}]}async function Pn(e,t,n){let r=ne(n);return Nh(t,await Rt(e,r),r)}function Gh(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Ma(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}function Oa(e){return e.slice(e.lastIndexOf("/")+1)}function Bh(){let e=typeof crypto<"u"?crypto:void 0;if(e?.randomUUID)return e.randomUUID();if(e?.getRandomValues){let t=new Uint8Array(8);return e.getRandomValues(t),[...t].map(n=>n.toString(16).padStart(2,"0")).join("")}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}async function wn(e,t,n){let r=ne(n),s=kt(Gh(e.trim()));return ja(s,t,r,{overwrite:!0})}async function ja(e,t,n,r){let s=Oa(e);if(!s)throw new T(`writeFile needs a file path, got "${e}"`,{code:"INVALID_PATH"});let i=Ma(e);await Ct(i,n).catch(()=>{});let o=Bh(),a=await Tt(t,i,`.${s}.kortix-write-${o}`,n),l=a[0]?.path;if(!l)throw new T(`Upload returned no file for ${e}`,{code:"UPLOAD_NO_RESULT"});let g=kt(l);try{await Da(g,e,n,r.overwrite)}catch(h){throw await Ye(g,n).catch(()=>{}),!r.overwrite&&h instanceof T&&h.status===409?new St(e):h}let m=a[0]?.size;return{path:e,bytes:typeof m=="number"?m:t.size}}async function Ye(e,t){let n=await N(`${ne(t)}/file`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!n.ok)throw new T(`Delete failed (${n.status}): ${await ze(n)}`,{status:n.status,response:n});return n.json()}async function Ct(e,t){let n=await N(`${ne(t)}/file/mkdir`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!n.ok)throw new T(`Mkdir failed (${n.status}): ${await ze(n)}`,{status:n.status,response:n});return n.json()}async function Sn(e,t,n){return Da(e,t,ne(n),!0)}async function Da(e,t,n,r){let s=await N(`${n}/file/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{from:e,to:t}:{from:e,to:t,overwrite:!1})});if(!s.ok)throw new T(`Rename failed (${s.status}): ${await ze(s)}`,{status:s.status,response:s});return s.json()}async function $a(){return Ca(await $e().project.current())}async function ni(){return Ca(await $e().global.health())}async function Ua(){try{return(await ni()).healthy===!0}catch{return!1}}var Kh={list:vt,read:At,readBlob:Rt,status:hn,findFiles:bn,findText:_n,upload:Tt,write:wn,create:xn,copy:Pn,remove:Ye,mkdir:Ct,rename:Sn,currentProject:$a,health:ni,isReachable:Ua,toDaemonPath:Ve,toSandboxAbsolutePath:kt,toWorkspaceRelative:Ea};var ri=52428800,Hh=104857600,La=20;function p(e,t="Project request failed"){if(!e.success||e.data===void 0)throw e.error??new Error(t);return e.data}function si(e){return e.replace(/\/v1\/?$/,"")}async function Xe(e,t){if(!e.backendUrl||!e.accessToken)return null;let n=si(e.backendUrl);try{let r=await fetch(`${n}${t}`,{headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(e.timeoutMs??8e3)});return r.ok?await r.json():null}catch{return null}}var vn=e=>`/projects/${encodeURIComponent(e)}/attachments`,An={showErrors:!1,deadlineCoversBody:!0},qa=3e4,zh=12e4,Vh=6e4,Yh=5*6e4,Xh=6e4,Jh=6e4;function kn(){return new T("Request aborted",{name:"AbortError",code:"ABORTED"})}function It(e){if(e?.aborted)throw kn()}function Qh(e){return!(e instanceof T)||e.code==="ABORTED"||e.code==="attachment_budget_exceeded"?!1:e.code==="TIMEOUT"||e.name==="TypeError"||e.status===429||e.status!==void 0&&e.status>=500}async function Et(e,t,n=!1){let r;for(let s=0;;s++){It(t);try{return await e()}catch(i){let o=n&&i instanceof T&&i.status===409&&i.code==="attachment_processing";if(t?.aborted||!(Qh(i)||o))throw i;r??=Date.now()+(n?Yh:Vh);let a=Math.min(8e3,500*2**s)*(.5+Math.random()/2);if(Date.now()+a>=r)throw i;try{await ln(a,t)}catch{throw It(t),i}}}}function Zh(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string")}function ii(e,t,n){let r=e?.upload,s=e?.received_bytes,i=Number.isSafeInteger(s)&&s>=0&&s<=t.size,o=r?.kind==="direct"?typeof r.url=="string"&&/^https?:\/\//i.test(r.url)&&r.method==="PUT"&&Zh(r.headers)&&Number.isFinite(Date.parse(r.expires_at))&&(s===0||s===t.size):r?.kind==="chunked"&&Number.isSafeInteger(r.chunk_size)&&r.chunk_size>0&&(s===t.size||s%r.chunk_size===0);if(!e?.attachment_id||n!==void 0&&e.attachment_id!==n||e.size!==t.size||!i||!o)throw new Error("Invalid attachment upload handle");return e}async function Fa(e,t,n,r){return p(await c.post(vn(e),{...r?{attachment_id:r}:{},filename:t.name,mime:t.type||"application/octet-stream",size:t.size},{...An,signal:n,timeout:qa}),"Failed to start attachment upload")}async function Na(e,t,n,r){let s=ii({...await Et(()=>Fa(e,t,r.signal,n.attachment_id),r.signal),received_bytes:0},t,n.attachment_id);return r.onUpload?.(s),s}function Ga(e,t){let n;try{n=JSON.parse(t)}catch{}let r=typeof n?.message=="string"?n.message:typeof n?.error=="string"?n.error:`HTTP ${e}`;return new T(r,{status:e,details:n,code:String(n?.statusCode??e)})}function eb(e){if(!(e instanceof T))return;let t=Number(e.details?.statusCode);return Number.isInteger(t)&&t>=400?t:e.status}function tb(e,t,n,r){return new Promise((s,i)=>{let o=new e,a=0,l=!1,g,m=S=>{l||(l=!0,g&&clearTimeout(g),r.signal?.removeEventListener("abort",_),S?i(S):s())},h=()=>{g&&clearTimeout(g),g=setTimeout(()=>{m(new T("Attachment upload stalled",{code:"TIMEOUT"})),o.abort()},Xh)},_=()=>{m(kn()),o.abort()};o.open(t.method,t.url);for(let[S,A]of Object.entries(t.headers))o.setRequestHeader(S,A);o.upload.onprogress=S=>{h(),a=Math.min(S.loaded,n.size),r.onProgress?.(a,n.size)},o.onload=()=>{o.status>=200&&o.status<300?(a<n.size&&r.onProgress?.(n.size,n.size),m()):m(Ga(o.status,o.responseText))},o.onerror=()=>m(new T("Network error during attachment upload",{name:"TypeError"})),o.onabort=()=>m(kn()),r.signal?.addEventListener("abort",_,{once:!0}),h(),o.send(n)})}async function nb(e,t,n){let r=L().fetch??fetch,s;try{s=await r(e.url,{method:e.method,headers:e.headers,body:t,signal:n.signal,credentials:"omit"})}catch(i){throw n.signal?.aborted||i instanceof Error&&i.name==="AbortError"?kn():new T(i instanceof Error?i.message:String(i),{name:i instanceof Error?i.name:"TypeError"})}if(!s.ok)throw Ga(s.status,await s.text().catch(()=>""));n.onProgress?.(t.size,t.size)}function rb(e,t,n){It(n.signal);let r=globalThis.XMLHttpRequest;return typeof r=="function"?tb(r,e,t,n):nb(e,t,n)}async function sb(e,t,n,r){let s=n,i=!1;for(r.onProgress?.(0,t.size);s.upload.kind==="direct";){let o=s.upload;try{await Et(()=>rb(o,t,r),r.signal)}catch(a){let l=eb(a);if(l!==409){if(i||!(l===400||l===401||l===403))throw a;i=!0,s=await Na(e,t,s,r);continue}}return s={...s,received_bytes:t.size},r.onUpload?.(s),s}return Ba(e,t,s,r)}async function Ba(e,t,n,r){if(n.upload.kind!=="chunked")throw new Error("Invalid attachment upload handle");let s=n.upload.chunk_size,i=`${vn(e)}/${encodeURIComponent(n.attachment_id)}`,o=n;for(;o.received_bytes<t.size;){It(r.signal);let a=o.received_bytes,l=Math.min(a+s,t.size),g=t.slice(a,l),m=await Et(async()=>p(await c.putRaw(`${i}/chunks/${a/s}`,g,{...An,signal:r.signal,timeout:qa}),"Failed to upload attachment chunk"),r.signal);if(m.size!==t.size||m.received_bytes!==l)throw new Error("Invalid attachment chunk acknowledgment");o={...o,received_bytes:l},r.onUpload?.(o),r.onProgress?.(l,t.size)}return o}async function Rn(e,t,n={}){if(!e)throw new Error("A project is required to upload attachments");if(!Number.isSafeInteger(t.size)||t.size<=0||t.size>52428800)throw new Error("Attachment must contain 1 byte to 50 MiB");It(n.signal);let r=n.resume?ii({...n.resume},t):ii({...await Et(()=>Fa(e,t,n.signal),n.signal),received_bytes:0},t);n.onUpload?.(r),r.received_bytes<t.size&&(r.upload.kind==="direct"&&Date.parse(r.upload.expires_at)-Date.now()<Jh&&(r=await Na(e,t,r,n)),r=r.upload.kind==="direct"?await sb(e,t,r,n):await Ba(e,t,r,n)),n.onProcessing?.();let s=`${vn(e)}/${encodeURIComponent(r.attachment_id)}`;try{return await Et(async()=>p(await c.post(`${s}/complete`,{},{...An,signal:n.signal,timeout:zh}),"Failed to complete attachment upload"),n.signal,!0)}catch(i){throw r.upload.kind==="direct"&&i instanceof T&&i.code==="attachment_not_uploaded"&&n.onUpload?.({...r,received_bytes:0}),i}}async function Mt(e,t,n={}){if(!e)throw new Error("A project is required to remove attachments");let r=await c.delete(`${vn(e)}/${encodeURIComponent(t)}`,{...An,signal:n.signal});if(!r.success)throw r.error??new Error("Failed to remove attachment")}var ib=100,ob=0,ab=new Set(["attachment_size_mismatch","attachment_failed"]),Ka=()=>new T("Attachment expired. Attach the file again.",{code:"attachment_expired"});function Wa(e){if(!e||typeof e.attachment_id!="string"||!e.attachment_id||typeof e.filename!="string"||!e.filename||typeof e.mime!="string"||!e.mime||!Number.isSafeInteger(e.size)||e.size<=0||e.size>52428800||!Number.isFinite(Date.parse(e.expires_at))||Date.parse(e.expires_at)<=Date.now())throw new Error("Attachment metadata is invalid or expired. Attach the file again.");return{attachment_id:e.attachment_id,filename:e.filename,mime:e.mime,size:e.size,expires_at:e.expires_at}}function Ha(e,t={}){let n=t.concurrency??2;if(!Number.isInteger(n)||n<1||n>20)throw new Error("Attachment concurrency must be between 1 and 20");let r=new Map,s=new Set,i=new Set,o=0,a=!1,l,g={attachments:[]},m=()=>[...r.values()].filter(f=>!f.handedOff);function h(f,u){f.removalDeleted||(f.removalDeleted=!0,Mt(e,u).catch(()=>{}))}function _(){l&&clearTimeout(l);let f=m().map(({item:x})=>x);(f.length!==g.attachments.length||f.some((x,C)=>x!==g.attachments[C]))&&(g={attachments:f});let u=Math.min(...f.filter(x=>x.status==="ready").map(x=>Date.parse(x.attachment.expires_at)));Number.isFinite(u)&&!a&&(l=setTimeout(()=>{for(let x of m())x.item.status==="ready"&&Date.parse(x.item.attachment.expires_at)<=Date.now()&&(x.item={...x.item,status:"error",error:Ka()});_()},Math.min(2147483647,Math.max(0,u-Date.now()))),typeof l=="object"&&"unref"in l&&l.unref());for(let x of s)x();for(let x of[...i])x()}function S(){if(a)throw new Error("Attachment controller is disposed");if(!e)throw new Error("A project is required to attach files");return e}function A(f){S();let u=m();if(u.length+f.length>20)throw new Error("A message can contain up to 20 attachments");if(f.some(C=>!Number.isSafeInteger(C)||C<=0||C>52428800))throw new Error("Each attachment must contain 1 byte to 50 MiB");if(u.reduce((C,P)=>C+P.item.size,0)+f.reduce((C,P)=>C+P,0)>104857600)throw new Error("Message attachments exceed 100 MiB")}function v(){for(let f of r.values()){if(o>=n)break;if(f.item.status!=="pending"||!f.item.file||a&&!f.handedOff)continue;let u=f.item.file;o++;let x=++f.generation,C=new AbortController;f.abort=C,f.item={...f.item,status:"uploading",error:void 0};let P=()=>(!a||f.handedOff===!0)&&r.get(f.item.id)===f&&f.generation===x,w,E=0,R,D=()=>{R=void 0,!(!P()||f.item.status!=="uploading"||w===void 0)&&(f.item={...f.item,receivedBytes:w},w=void 0,E=Date.now(),_())},U=b=>Math.floor(b*100/f.item.size);Rn(e,u,{resume:f.upload,signal:C.signal,onUpload:b=>{f.upload=b,f.removed&&(C.abort(),h(f,b.attachment_id))},onProgress:b=>{if(!P()||U(b)===U(f.item.receivedBytes)||(w=b,R))return;let M=E+ib-Date.now();if(M<=0)return D();R=setTimeout(D,M),typeof R=="object"&&"unref"in R&&R.unref()},onProcessing:()=>{R&&clearTimeout(R),R=void 0,w=void 0,P()&&(f.item={...f.item,status:"processing",receivedBytes:f.item.size},_())}}).then(b=>{P()&&(f.item={...f.item,status:"ready",attachment:Wa(b),receivedBytes:b.size})}).catch(b=>{b instanceof T&&ab.has(b.code??"")&&(f.upload=void 0),P()&&(f.item={...f.item,status:b instanceof T&&b.code==="ABORTED"?"aborted":"error",error:b instanceof Error?b:new Error(String(b))})}).finally(()=>{o--,R&&clearTimeout(R),f.abort===C&&(f.abort=void 0),_(),v()})}_()}function j(f){A(f.map(x=>x.size));let u=f.map(x=>{let C=`attachment-${++ob}`;return r.set(C,{generation:0,item:{id:C,file:x,filename:x.name,mime:x.type||"application/octet-stream",size:x.size,status:"pending",receivedBytes:0}}),C});return _(),v(),u}function k(f){let u=r.get(f);!u||u.item.status==="ready"||(u.generation++,u.abort?.abort(),u.item={...u.item,status:"aborted",error:new Error("Attachment upload cancelled")},_())}function d(f,{signal:u}={}){let x=[...f];return new Promise((C,P)=>{let w=()=>{i.delete(D),u?.removeEventListener("abort",R)},E=U=>{w(),P(U)},R=()=>E(ye()),D=()=>{let U=!1;for(let M of x){let q=r.get(M);if(!q)return E(new Error("Attachment was removed before it was sent"));if(a&&!q.handedOff)return E(new Error("Attachment controller is disposed"));if(q.item.status==="error"||q.item.status==="aborted")return E(q.item.error??new Error("Attachment upload failed"));q.item.status!=="ready"&&(U=!0)}if(U)return;let b;try{b=x.map(M=>{let q=Wa(r.get(M).item.attachment);return{type:"file",attachment_id:q.attachment_id,filename:q.filename,mime:q.mime}})}catch(M){return E(M instanceof Error?M:new Error(String(M)))}w(),C(b)};if(u?.aborted)return R();i.add(D),u?.addEventListener("abort",R,{once:!0}),D()})}return{add:f=>j([f])[0],addMany:j,retry(f){let u=r.get(f);if(u?.handedOff||S(),!(!u||u.item.status==="ready"||u.item.status==="uploading"||u.item.status==="processing"||u.item.status==="pending")){if(!u.item.file||u.upload&&Date.parse(u.upload.expires_at)<=Date.now())throw Ka();u.item={...u.item,status:"pending",error:void 0},v()}},async remove(f){let u=r.get(f);if(!u)return;u.removed=!0,u.generation++,r.delete(f);let x=u.upload?.attachment_id??u.item.attachment?.attachment_id;x&&u.abort?.abort(),_(),v(),x&&h(u,x)},abort:k,submit(f){if(!a){for(let u of f){let x=r.get(u);x&&(x.handedOff=!0)}_()}},reclaim(f){if(!a){for(let u of f){let x=r.get(u);x&&(x.handedOff=!1)}_()}},whenReady:d,forget(f=m().map(u=>u.item.id)){for(let u of f){let x=r.get(u);x&&(x.generation++,x.abort?.abort(),r.delete(u))}_(),v()},dispose(){if(!a){a=!0,l&&clearTimeout(l);for(let f of r.values()){if(f.handedOff)continue;f.generation++,f.abort?.abort();let u=f.upload?.attachment_id??f.item.attachment?.attachment_id;u&&e&&Mt(e,u).catch(()=>{})}s.clear(),_()}},getSnapshot:()=>g,subscribe(f){return s.add(f),()=>{s.delete(f)}}}}async function za(){return p(await c.get("/accounts"))}async function Va(e){return p(await c.post("/accounts",e))}async function Ya(e){return p(await c.get(`/accounts/${e}`))}async function Xa(e,t){return p(await c.patch(`/accounts/${e}`,{name:t}))}async function Ja(e){return p(await c.get(`/accounts/${e}/branding`))}async function Qa(e,t){return p(await c.put(`/accounts/${e}/branding`,t))}async function Za(e,t,n,r){let s=new FormData;return s.append("file",n,r??(n instanceof File?n.name:t)),p(await c.upload(`/accounts/${e}/branding/assets/${t}`,s))}async function ec(e,t){return p(await c.delete(`/accounts/${e}/branding/assets/${t}`))}async function tc(e){return p(await c.delete(`/accounts/${e}/branding`))}async function nc(e){return p(await c.get(`/accounts/${e}/members`))}async function rc(e,t){return p(await c.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function sc(e){return p(await c.get(`/accounts/${e}/invites`))}async function ic(e,t){return p(await c.delete(`/accounts/${e}/invites/${t}`))}async function oc(e,t){return p(await c.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function ac(){return p(await c.get("/account-invites",{showErrors:!1})).invites}async function cc(e){return p(await c.get(`/account-invites/${e}`,{showErrors:!1}))}async function lc(e){return p(await c.post(`/account-invites/${e}/accept`,{}))}async function uc(e){return p(await c.post(`/account-invites/${e}/decline`,{}))}async function pc(e,t){return p(await c.delete(`/accounts/${e}/members/${t}`))}async function dc(e,t,n){return p(await c.patch(`/accounts/${e}/members/${t}`,{role:n}))}async function gc(e){return p(await c.post(`/accounts/${e}/leave`,{}))}async function zR(e){return Xe(e,"/v1/accounts")}async function mc(){let e=await c.get("/accounts/me",{showErrors:!1});return!e.success||!e.data?{valid:!1,error:e.error}:{valid:!0,identity:e.data}}var QR=["marketplace","connectors_api_discover","agentmail_email","teams","llm_gateway","meta_agent","apps","monitors","reminders","warm_sessions","secrets_egress","pi_worker","pooled_provider_secrets","pi_harness","config_releases","agent_principal","us_region"];async function Je(){return p(await c.get("/projects"))}async function yc(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return p(await c.get(`/projects${t}`))}async function oi(e,t){return p(await c.get(`/projects/${e}`,t))}async function hc(e,t,n="write"){return p(await c.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:n}))}async function bc(e,t){return p(await c.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function _c(e){return p(await c.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function ZR(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function ai(e,t){let n=p(await c.get(`/projects/${e}/detail`,{showErrors:!1,...t}));return{...n,config:{...n.config,default_agent:n.config.default_agent??n.config.open_code_default_agent??null}}}async function ci(e,t){return p(await c.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function li(e,t){return p(await c.get(`/projects/${e}/model-picker`,{showErrors:!1,...t}))}async function eT(e,t){return p(await c.get(`/projects/${e}/llm-catalog/providers`,{showErrors:!1,...t}))}async function xc(e){return p(await c.post("/projects",e))}async function Pc(e){return p(await c.post("/projects/create-repo",e,{showErrors:!1}))}async function wc(e,t={}){return p(await c.post("/projects/provision",{seed_starter:!0,...e},{timeout:12e4,...t}))}var fc=200;function cb(e){let t=e.split(`
|
|
8
8
|
`).filter(r=>r.startsWith("data:")).map(r=>r.slice(5).replace(/^ /,""));if(t.length===0)return null;let n=t.join(`
|
|
9
9
|
`);try{return JSON.parse(n)}catch(r){let s=n.length>fc?`${n.slice(0,fc)}\u2026`:n;throw new Error(`provisionProjectStream: received an unparseable SSE frame (${s})`,{cause:r})}}async function tT(e,t,n={}){let r=await c.postStream("/projects/provision-stream",{seed_starter:!0,...e},n);if(!r.ok){let l=await r.json().catch(()=>null);throw new T(l?.error||`Provision failed: HTTP ${r.status}`,{status:r.status,code:l?.code})}let s=r.body?.getReader();if(!s)throw new Error("Provision stream is unavailable on this runtime (no response body)");let i=new TextDecoder,o="",a=null;try{for(;;){let{done:l,value:g}=await s.read();if(l)break;o+=i.decode(g,{stream:!0});let m=o.indexOf(`
|
|
10
10
|
|