@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.global.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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 Lb=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},qb=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Fb=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(qb(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}let i=Lb(r),o=s.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):Ye({allowReserved:e,name:n,value:a})).join(i);return r==="label"||r==="matrix"?i+o:o},Ye=({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)}`},Cn=({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=Fb(r),a=Object.entries(s).map(([l,g])=>Ye({allowReserved:e,name:r==="deepObject"?`${n}[${l}]`:l,value:g})).join(o);return r==="label"||r==="matrix"?o+a:a};var Nb=/\{[^{}]+\}/g,Gb=({path:e,url:t})=>{let n=t,r=t.match(Nb);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,Cn({explode:i,name:o,style:a,value:l,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(s,`;${Ye({name:o,value:l})}`);continue}let g=encodeURIComponent(a==="label"?`.${l}`:l);n=n.replace(s,g)}return n},Vg=({baseUrl:e,path:t,query:n,querySerializer:r,url:s})=>{let i=s.startsWith("/")?s:`/${s}`,o=(e??"")+i;t&&(o=Gb({path:t,url:o}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(o+=`?${a}`),o};function fs(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 Yg=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 ys={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)};var Xg=({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=Cn({allowReserved:a.allowReserved,explode:!0,name:i,style:"deepObject",value:o,...a.object});l&&s.push(l)}else{let l=Ye({allowReserved:a.allowReserved,name:i,value:o});l&&s.push(l)}}return s.join("&")},Jg=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"}},Bb=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,Qg=async({security:e,...t})=>{for(let n of e){if(Bb(t,n.name))continue;let r=await Yg(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}}},hs=e=>Vg({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Xg(e.querySerializer),url:e.url}),bs=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=In(e.headers,t.headers),n},Kb=e=>{let t=[];return e.forEach((n,r)=>{t.push([r,n])}),t},In=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let r=n instanceof Headers?Kb(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},Tt=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}},Zg=()=>({error:new Tt,request:new Tt,response:new Tt}),Wb=Xg({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Hb={"Content-Type":"application/json"},Ct=(e={})=>({...ys,headers:Hb,parseAs:"auto",querySerializer:Wb,...e});var It=(e={})=>{let t=bs(Ct(),e),n=()=>({...t}),r=g=>(t=bs(t,g),n()),s=Zg(),i=async g=>{let m={...t,...g,fetch:g.fetch??t.fetch??globalThis.fetch,headers:In(t.headers,g.headers),serializedBody:void 0};m.security&&await Qg({...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=hs(m);return{opts:m,url:h}},o=async g=>{let{opts:m,url:h}=await i(g),_={redirect:"follow",...m,body:fs(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"?Jg(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 zg({...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:fs(h),url:_})};return{buildUrl:hs,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 zb={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Vb=Object.entries(zb),em=(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&&em(n.args,t);return t},Yb=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=em(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=Vb.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 Yb(n),n};var tm=It(Ct({baseUrl:"http://localhost:4096"}));var I=class{client;constructor(t){this.client=t?.client??tm}},_s=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)}},xs=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}})}},Ps=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})}},ws=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}})}},Ss=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})}},ks=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}})}},vs=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})}},As=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})}},Rs=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}})}},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:"/experimental/workspace/adapter",...n,...r})}},Cs=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 Ts({client:this.client})}},Is=class extends I{_controlPlane;get controlPlane(){return this._controlPlane??=new ws({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new Ss({client:this.client})}_console;get console(){return this._console??=new ks({client:this.client})}_session;get session(){return this._session??=new vs({client:this.client})}_resource;get resource(){return this._resource??=new As({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Rs({client:this.client})}_workspace;get workspace(){return this._workspace??=new Cs({client:this.client})}},Es=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}})}},Ms=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 Es({client:this.client})}},Os=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})}},js=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})}},Ds=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})}},$s=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}})}},Us=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})}},Ls=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})}},qs=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})}},Fs=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})}},Ns=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})}},Gs=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 Ns({client:this.client})}},Bs=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})}},Ks=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})}},Ws=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})}},Hs=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})}},zs=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 Hs({client:this.client})}},Vs=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})}},Ys=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})}},Xs=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})}},Js=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}})}},Qs=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}})}},Zs=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 Qs({client:this.client})}},ei=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})}},ti=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}})}},ni=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}})}},ri=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 ni({client:this.client})}},si=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}})}},ii=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 si({client:this.client})}},oi=class extends I{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},ai=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})}},ci=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})}},li=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})}},ui=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}})}},pi=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})}},di=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 li({client:this.client})}_permission;get permission(){return this._permission??=new ui({client:this.client})}_question;get question(){return this._question??=new pi({client:this.client})}},gi=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})}},mi=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})}},fi=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}})}},yi=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}})}},hi=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 fi({client:this.client})}_attempt;get attempt(){return this._attempt??=new yi({client:this.client})}},bi=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}})}},_i=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})}},xi=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})}},Pi=class extends I{_request;get request(){return this._request??=new _i({client:this.client})}_saved;get saved(){return this._saved??=new xi({client:this.client})}},wi=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})}},Si=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})}},ki=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})}},vi=class extends I{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},Ai=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})}},Ri=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})}},Ti=class extends I{_request;get request(){return this._request??=new Ri({client:this.client})}},Ci=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})}},Ii=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})}},Ei=class extends I{_health;get health(){return this._health??=new oi({client:this.client})}_location;get location(){return this._location??=new ai({client:this.client})}_agent;get agent(){return this._agent??=new ci({client:this.client})}_session;get session(){return this._session??=new di({client:this.client})}_model;get model(){return this._model??=new gi({client:this.client})}_provider;get provider(){return this._provider??=new mi({client:this.client})}_integration;get integration(){return this._integration??=new hi({client:this.client})}_credential;get credential(){return this._credential??=new bi({client:this.client})}_permission;get permission(){return this._permission??=new Pi({client:this.client})}_fs;get fs(){return this._fs??=new wi({client:this.client})}_command;get command(){return this._command??=new Si({client:this.client})}_skill;get skill(){return this._skill??=new ki({client:this.client})}_event;get event(){return this._event??=new vi({client:this.client})}_pty;get pty(){return this._pty??=new Ai({client:this.client})}_question;get question(){return this._question??=new Ti({client:this.client})}_reference;get reference(){return this._reference??=new Ci({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Ii({client:this.client})}},En=class e extends I{static __registry=new _s;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new xs({client:this.client})}_app;get app(){return this._app??=new Ps({client:this.client})}_experimental;get experimental(){return this._experimental??=new Is({client:this.client})}_global;get global(){return this._global??=new Ms({client:this.client})}_event;get event(){return this._event??=new Os({client:this.client})}_config;get config(){return this._config??=new js({client:this.client})}_tool;get tool(){return this._tool??=new Ds({client:this.client})}_worktree;get worktree(){return this._worktree??=new $s({client:this.client})}_find;get find(){return this._find??=new Us({client:this.client})}_file;get file(){return this._file??=new Ls({client:this.client})}_instance;get instance(){return this._instance??=new qs({client:this.client})}_path;get path(){return this._path??=new Fs({client:this.client})}_vcs;get vcs(){return this._vcs??=new Gs({client:this.client})}_command;get command(){return this._command??=new Bs({client:this.client})}_lsp;get lsp(){return this._lsp??=new Ks({client:this.client})}_formatter;get formatter(){return this._formatter??=new Ws({client:this.client})}_mcp;get mcp(){return this._mcp??=new zs({client:this.client})}_project;get project(){return this._project??=new Vs({client:this.client})}_pty;get pty(){return this._pty??=new Ys({client:this.client})}_question;get question(){return this._question??=new Xs({client:this.client})}_permission;get permission(){return this._permission??=new Js({client:this.client})}_provider;get provider(){return this._provider??=new Zs({client:this.client})}_session;get session(){return this._session??=new ei({client:this.client})}_part;get part(){return this._part??=new ti({client:this.client})}_sync;get sync(){return this._sync??=new ri({client:this.client})}_tui;get tui(){return this._tui??=new ii({client:this.client})}_v2;get v2(){return this._v2??=new Ei({client:this.client})}};function rm(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||nm(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 ${nm(n,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function nm(e,t){let n=e?.method??"?",r=e?.url??"?",s=t?.status,i=t?.statusText;return`${n} ${r}${s?" \u2192 "+s:""}${i?" "+i:""}`}function Xb(e,t,n){if(e)return t&&(e===t||n&&e===n(t))?t:e}function Jb(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=Xb(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 Mi(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=It(e);return t.interceptors.request.use(n=>Jb(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(rm),new En({client:t})}var Qb=new Set(["api","cli","mobile","tui","web"]);function sm(e){let t=e?.trim().toLowerCase();return t&&Qb.has(t)?t:null}function Zb(e){return new Promise(t=>setTimeout(t,e))}async function Mn(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 Zb(s)),o=await e(),o)return o;return o}var Oi=12e4;function e_(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function im(e,t,n=Oi){let r=e instanceof Request?e.signal:t?.signal;if(e_(e))return r??void 0;let s=AbortSignal.timeout(n);return r?typeof AbortSignal.any=="function"?AbortSignal.any([r,s]):r:s}function On(){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)}},ae=class extends T{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},Ie=class extends T{constructor(t,n,r,s={}){super(r||n.message||`Billing Error: ${t}`,{...s,status:t,detail:n}),this.name="BillingError"}},qe=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"}},t_="ENDPOINT_RETIRED";function z(e,t){let n=t?` ${t}`:"";return new T(`${e}() is retired: the Kortix API no longer serves this endpoint.${n}`,{code:t_})}var jn="feature_disabled";function om(e){if(!(e instanceof T)||e.status!==403||e.code!==jn)return null;let t=e.details??e.data;return t&&typeof t=="object"?t:{}}function ji(e){let t=om(e);return t?(typeof t.feature=="string"&&!e.feature&&(e.feature=t.feature),!0):!1}function Di(e){let t=om(e);if(!t)return null;let n=e.feature;return typeof n=="string"?n:typeof t.feature=="string"?t.feature:null}function Et(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 Ie(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 $i(e){return e instanceof Ie}function Ui(e){if(!(e instanceof Ie))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 be(){return typeof DOMException=="function"?new DOMException("Aborted","AbortError"):Object.assign(new Error("Aborted"),{name:"AbortError"})}function _e(e,t){return new Promise((n,r)=>{let s=()=>{t.removeEventListener("abort",s),r(be())};t.addEventListener("abort",s,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",s)),t.aborted&&s()})}function Dn(e,t){return new Promise((n,r)=>{let s=()=>{clearTimeout(i),t?.removeEventListener("abort",s),r(be())},i=setTimeout(()=>{t?.removeEventListener("abort",s),n()},e);t?.aborted?s():t?.addEventListener("abort",s,{once:!0})})}var am="X-Kortix-Impersonate",qi="kortix.impersonation",Fe=null,$n=!1,Li=new Set;function Fi(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}function cm(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 n_(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 lm(){for(let e of Li)try{e()}catch{}}function um(){return $n||($n=!0,Fe=n_(Fi()?.getItem(qi)??null)),Fe&&!cm(Fe)?(Ni(),null):Fe}function r_(e){if($n=!0,!e){Ni();return}Fe=e;try{Fi()?.setItem(qi,JSON.stringify(e))}catch{}lm()}function Ni(){$n=!0;let e=Fe!==null;Fe=null;try{Fi()?.removeItem(qi)}catch{}e&&lm()}function s_(e){return Li.add(e),()=>{Li.delete(e)}}var i_=/(^|\/)admin\/(api|analytics)(\/|$)/;function pm(e){let t=e;if(/^https?:\/\//.test(e))try{t=new URL(e).pathname}catch{t=e}return!i_.test(t)}function Gi(e){if(e!==void 0&&!pm(e))return{};let t=um();return t?{[am]:t.grantId}:{}}var Hi=!1;function mm(e){Hi=e}function fm(){return Hi}function o_(e){return e?e instanceof Headers||Array.isArray(e)?[...new Headers(e).entries()]:Object.entries(e):[]}function Ki(e,t){let n=t.toLowerCase();return Object.keys(e).some(r=>r.toLowerCase()===n)}function Mt(e,t,n){let r=t.toLowerCase();for(let s of Object.keys(e))s.toLowerCase()===r&&delete e[s];e[t]=n}function Wi(e,t){let n={},r=[e instanceof Request?e.headers:void 0,t.headers];for(let[s,i]of r.flatMap(o_))Mt(n,s,i);return n}function dm(e,t,n){let r={...t},s=sm(L().clientSource);s&&!Ki(r,"x-kortix-client")&&Mt(r,"X-Kortix-Client",s),Hi&&Mt(r,"x-kortix-admin-bypass","1");for(let[i,o]of Object.entries(Gi(e)))Mt(r,i,o);return Ki(r,"authorization")||Mt(r,"Authorization",`Bearer ${n}`),r}function a_(e){return typeof ReadableStream<"u"&&e.body instanceof ReadableStream}function gm(e,t,n,r,s){if(t instanceof Request){let a=new Headers(dm(t.url,Wi(t,n),r));return e(new Request(t,{headers:a,...s?{signal:s}:{}}))}let i=String(t),o=dm(i,Wi(t,n),r);return e(i,{...n,headers:o,...s?{signal:s}:{}})}async function Bi(e){return Mn(()=>L().getToken(),e)}async function Ot(e,t={},n={}){let{retryOnAuthError:r=!0,timeoutMs:s=Oi}=n,i=n.fetch??L().fetch??fetch,o=s===null?(e instanceof Request?e.signal:t.signal)??void 0:im(e,t,s);if(o?.aborted)throw be();let a=await(o?_e(Bi(),o):Bi());if(!a)throw new ae;let l=r&&!a_(t)&&!Ki(Wi(e,t),"authorization"),g=l&&e instanceof Request?e.clone():e,m=await gm(i,e,t,a,o);if(m.status!==401||!l)return m;let h=await Bi({attempts:2,baseDelayMs:200});return!h||h===a?m:gm(i,g,t,h,o)}async function Un(){return L().getToken()}async function Xe(e){return Mn(()=>L().getToken(),e,Ln)}function Ln(){}function c_(e){}function l_(e){}async function Je(){return Un()}async function u_(e){return Xe(e)}async function F(e,t,n){try{return await Ot(e,t,{retryOnAuthError:n?.retryOnAuthError,timeoutMs:n?.timeoutMs})}catch(r){if(r instanceof ae)return On();throw r}}var Qe={url:null,sandboxId:null,dbSandboxId:null,version:0},p_=new Set;function ym(e,t=null,n=null){if(!(Qe.url===e&&Qe.sandboxId===t&&Qe.dbSandboxId===n)){Qe={url:e,sandboxId:t,dbSandboxId:n,version:Qe.version+1};for(let r of p_)r()}}function hm(){return Qe.url}function d_(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function jt(){return d_(L().backendUrl||"http://localhost:8008/v1")}function bm(){let e=L().sandboxId;return e?`${jt()}/p/${e}/8000`:""}function g_(e,t=8e3){return`${jt()}/p/${e}/${t}`}function Dt(e,t=8e3){return g_(e,t)}var ge=()=>L().backendUrl||"",_m="feature_not_supported",xm="model_not_servable",Pm="provision_in_flight",wm="analytics_unavailable",Sm="accounts_list_unavailable",km="request_deadline",m_=/^Request exceeded the \d+s server processing deadline$/,f_=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===km||m_.test(n),y_="git_mirror_unavailable",h_=/^git mirror is temporarily unavailable$/,b_=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===y_||h_.test(n),__=new Set([502,503,504]),x_=e=>__.has(e),vm=e=>{let t=(e??"GET").toUpperCase();return t==="GET"||t==="HEAD"},P_=e=>vm(e)||(e??"GET").toUpperCase()==="DELETE",w_=2,qn=e=>e?.name==="AbortError"||e?.name==="AbortSignal"||e instanceof Error&&e.message.includes("aborted");async function Ee(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 be();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=vm(o.method),v=P_(o.method),j=v?w_+1:1,k;for(let u=0;u<j;u++){u>0&&await Dn(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 _e(Ot(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 ae)return{error:new ae,success:!1};if(_&&qn(P)&&!o.signal?.aborted&&v&&u<j-1){_=!1;continue}if(qn(P)||u===j-1)throw P;continue}if(!(A&&x_(k.status)&&u<j-1)){!i&&m&&(clearTimeout(m),m=null);break}try{await _e(k.arrayBuffer(),x.signal)}catch(P){if(qn(P))throw P}finally{m&&(clearTimeout(m),m=null)}}if(!k.ok){let u=`HTTP ${k.status}: ${k.statusText}`,x=null;try{x=await _e(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 be();let C=f_(k.status,x,u),P=b_(k.status,x,u),w=new T(u,{status:k.status,response:k,details:x||void 0,data:x,detail:x?.detail,code:C?km:x?.code||x?.error_code||x?.detail?.error_code||k.status.toString()});if(k.status===402&&(w=Et(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 qe(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===_m,R=k.status===409&&x?.code===xm,D=k.status===409&&x?.code===Pm,U=k.status===503&&x?.code===wm,b=k.status===503&&x?.code===Sm;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 _e(k.json(),l.signal):f?.includes("text/")?d=await _e(k.text(),l.signal):d=await _e(k.blob(),l.signal),{data:d,success:!0,headers:k.headers}}catch(S){m&&(clearTimeout(m),m=null);let A=qn(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(ge(),"")||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 S_={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 k_(e,t,n={}){let{timeout:r=3e4,fetch:s}=n,i=new AbortController,o=setTimeout(()=>i.abort(),r);try{return await Ot(`${ge()}${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 ae)return On();throw a}finally{clearTimeout(o)}}var c={putRaw:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"PUT",body:t,headers:{"Content-Type":"application/octet-stream",...n?.headers}}),get:(e,t)=>Ee(`${ge()}${e}`,{...t,method:"GET"}),post:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>Ee(`${ge()}${e}`,{...t,method:"DELETE"}),upload:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],Ee(`${ge()}${e}`,{...s,method:"POST",body:t,headers:i})},uploadPut:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],Ee(`${ge()}${e}`,{...s,method:"PUT",body:t,headers:i})},postStream:k_};var $t=new Map,zi=new Map;function Vi(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Am(e){return $t.get(Vi(e))??null}function Rm(){return[...$t.values()].filter(e=>typeof e=="string")}function Tm(e){return $t.has(Vi(e))}async function Ze(e){let t=Vi(e),n=$t.get(t);if(n!==void 0)return n;let r=zi.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 $t.set(t,o),o}catch{return null}finally{zi.delete(t)}})();return zi.set(t,s),s}function Cm(e){let{apiBaseUrl:t}=e;return Tm(t)||Ze(t).catch(()=>{}),{sandboxId:e.sandboxId,backendPort:e.backendPort,apiBaseUrl:t,previewUrlTemplate:Am(t)}}function xe(){let e=hm();return e||(L().billingEnabled??!1?"":bm())}async function Yi(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function Xi(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function Ji(e){let t=Xi(e),n=await F(`${t}/env`);if(!n.ok)throw new Error(await Yi(n,"Failed to load secrets"));return(await n.json()).secrets??{}}async function Qi(e,t,n){let r=Xi(e),s=await F(`${r}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!s.ok)throw new Error(await Yi(s,"Failed to save secret"))}async function Zi(e,t){let n=Xi(e),r=await F(`${n}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await Yi(r,"Failed to delete secret"))}var Im={list:Ji,set:Qi,delete:Zi};async function Em(e,t,n){let r=e;for(;r.endsWith("/");)r=r.slice(0,-1);let s=await F(`${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 Pe(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 Fn(e,t){let n=await e.json().catch(()=>({}));return n?.error||n?.message||e.statusText||t}function Ut(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return Pe(e)}async function to(e){let t=Ut(e),n=await F(`${t}/kortix/pty`);if(!n.ok)throw new Error(await Fn(n,"Failed to list terminals"));return n.json()}async function no(e,t){let n=Ut(e),r=await F(`${n}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok)throw new Error(await Fn(r,"Failed to create terminal"));return r.json()}async function ro(e,t,n){let r=Ut(e),s=await F(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw new Error(await Fn(s,"Failed to update terminal"));return s.json()}async function so(e,t){let n=Ut(e),r=await F(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await Fn(r,"Failed to remove terminal"))}async function io(e,t,n){let r=Ut(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:"),Pe(g.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,o=new URLSearchParams,a=await Je();a&&o.set("token",a),n?.wake&&o.set("wake","1");let l=o.toString();return l?`${i}${i.includes("?")?"&":"?"}${l}`:i}function Mm(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 Me="\x1B",Om="\x07",v_="\0",eo=`(?:${Om}|${Me}\\\\)`,A_=[new RegExp(`${Me}\\]697;[^${Om}${Me}]*${eo}`,"g"),new RegExp(`${v_}?\\{"cursor":\\d+\\}`,"g"),new RegExp(`${Me}\\][0-9]+;rgb:[0-9a-fA-F/]+${eo}`,"g"),new RegExp(`${Me}\\]4;[0-9]+;rgb:[0-9a-fA-F/]+${eo}`,"g"),new RegExp(`${Me}\\[\\??[0-9;]*\\$y`,"g"),new RegExp(`${Me}\\[\\d+;\\d+R`,"g"),new RegExp(`${Me}\\[\\?[0-9;]*c`,"g")];function jm(e){let t=e;for(let n of A_)t=t.replace(n,"");return t}var Dm={list:to,create:no,update:ro,remove:so,webSocketUrl:io};async function $(e,t,n,r){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let i=await F(`${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 R_(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 T_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function C_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function I_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function E_(e,t){return $(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function M_(e,t,n){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function O_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function j_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function D_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function $_(e,t){let n=t?`?project_id=${encodeURIComponent(t)}`:"";return $(e,`/kortix/tickets${n}`)}async function U_(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function L_(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function q_(e,t){return $(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function F_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function N_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(n)})}async function G_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(n)})}async function B_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(n)})}async function K_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(n)})}async function W_(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function H_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function z_(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:n})})}async function V_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function Y_(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:n})})}async function X_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function J_(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:n})})}async function Q_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function Z_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function ex(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(n)})}async function tx(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function nx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"DELETE"})}async function rx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}/persona`)}async function sx(e,t,n=200){return $(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${n}`)}async function ix(e){return $(e,"/kortix/projects")}async function ox(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function ax(e,t){return $(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function cx(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function lx(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function ux(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function px(e,t,n="all"){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${n}`)}async function dx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`)}async function gx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/events`)}async function mx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(n)})}async function fx(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function yx(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/close`,{method:"POST",body:JSON.stringify(r)})}async function hx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/reopen`,{method:"POST"})}async function bx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"DELETE"})}async function _x(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function xx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}/events`)}async function Px(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(n)})}async function wx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`)}async function Sx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`,{method:"DELETE"})}var kx=1e4,vx={retryOnAuthError:!1};function et(e,t,n){return $(e,t,{signal:AbortSignal.timeout(kx),...n},vx)}async function Ax(e,t=!1){return(await et(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function Rx(e){return(await et(e,"/kortix/services/templates")).templates??[]}async function Tx(e,t){return(await et(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function Cx(e,t,n){let r=n==="delete",s=r?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${n}`;return et(e,s,{method:r?"DELETE":"POST"})}async function Ix(e,t){return et(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function Ex(e,t){return et(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var Nn=new Map,tt=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function Oe(){let e=xe();if(!e)throw new tt;return we(e)}function we(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=Nn.get(e);if(t)return t;if(!Rn())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let n=Mi({baseUrl:e,fetch:F});return Nn.set(e,n),n}function Mx(e){Nn.delete(e)}function Ox(){Nn.clear()}var Gn=new Map;function jx(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=Gn.get(e);if(t)return t;let n=Mi({baseUrl:e,fetch});return Gn.set(e,n),n}function Dx(e){Gn.delete(e)}function $x(){Gn.clear()}async function Ux(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 Lx(e){let t=xe();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 F(`${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 Ux(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 qm(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 st(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 re(e){let t=(e??xe()).trim();if(!t)throw new tt;return t}async function Kn(e,t){let n=await F(`${re(t)}${e}`);if(!n.ok)throw new T(await st(n),{status:n.status,response:n});return n.json()}var Wn=["/workspace","/tmp","/home","/opt"],qx=Wn.filter(e=>e!=="/workspace");function co(e){return Wn.some(t=>e===t||e.startsWith(`${t}/`))}function it(e){return co(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function Ne(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(qx.some(n=>t===n||t.startsWith(`${n}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var lo=Ne;async function ot(e,t){let n=re(t),r=Ne(e)||".";return(await Kn(`/file?path=${encodeURIComponent(r)}`,n)).map(i=>({...i,path:i.absolute||`/workspace/${i.path}`}))}async function at(e,t){let n=re(t),r=Ne(e),s=await F(`${n}/file/content?path=${encodeURIComponent(r)}`);if(!s.ok)throw new T(await st(s),{status:s.status,response:s});return s.json()}async function Fx(e,t,n){let r=re(n),s=Ne(e),i=await F(`${r}/file/raw?path=${encodeURIComponent(s)}`);if(!i.ok)throw new T(await st(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 ct(e,t){let n=re(t);try{return await Fx(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 qt(e){return Kn("/file/status",re(e))}async function Ft(e,t,n){let r=re(n),s=new URLSearchParams({query:e});return t?.type&&s.set("type",t.type),t?.limit&&s.set("limit",String(t.limit)),Kn(`/find/file?${s.toString()}`,r)}async function Nt(e,t){let n=re(t);return(await Kn(`/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 Lt=[400,1200],Nx=e=>e===408||e===429||e===502||e===503||e===504,$m=e=>new Promise(t=>setTimeout(t,e));function Gx(e){let t=e?.name;return t==="TimeoutError"||t==="AbortError"}var oo=3e4,Bx=15*6e4,Kx=256;function nt(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return oo;let t=oo+e/Kx;return Math.min(Bx,Math.max(oo,Math.round(t)))}async function Wx(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 Bn(e,t){let n;for(let s=0;s<=Lt.length;s++){let i;try{i=await t(e())}catch(a){if(n=a,Gx(a)||s===Lt.length)break;await $m(Lt[s]);continue}if(i.ok)return i.json();let o=await Wx(i);if(n=new T(`Upload failed (${i.status}): ${o}`,{status:i.status,response:i}),!Nx(i.status)||s===Lt.length)throw n;await $m(Lt[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 ao=64*1024;function Um(e,t){try{e?.onProgress?.(t)}catch{}}function Lm(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 Hx(e){let t=e.lastIndexOf("/");return t<0?{parent:"",name:e}:{parent:e.slice(0,t)||"/",name:e.slice(t+1)}}async function lt(e,t,n,r,s){let i=typeof r=="string"?r:void 0,o=typeof r=="string"?s:r,a=re(i),l=nt(e.size),g=n||(e instanceof File?e.name:"")||"";if(e.size<=ao){let S=await Bn(()=>Lm(e,t,g),A=>F(`${a}/file/upload`,{method:"POST",body:A},{timeoutMs:l}));return Um(o,{loadedBytes:e.size,totalBytes:e.size}),S}let h=(await Bn(()=>Lm(new Blob([],{type:e.type}),t,g),S=>F(`${a}/file/upload`,{method:"POST",body:S},{timeoutMs:nt(0)})))[0]?.path;if(!h)throw new T("Upload reservation returned no file path",{code:"UPLOAD_NO_RESULT"});let _=Hx(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+=ao){let A=Math.min(e.size,S+ao),v=e.slice(S,A,e.type),j=await Bn(()=>{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=>F(`${a}/file/append`,{method:"POST",body:k},{timeoutMs:nt(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"});Um(o,{loadedBytes:A,totalBytes:e.size})}}catch(S){throw await Ge(h,a).catch(()=>{}),S}return[{path:h,size:e.size}]}function zx(e,t,n){let r=re(n),s=nt(t.size);return Bn(()=>{let i=new FormData;return i.append(e,t,e.split("/").pop()||"file"),i},i=>F(`${r}/file/upload`,{method:"POST",body:i},{timeoutMs:s}))}var rt=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 Gt(e,t){let n=re(t),r=e.trim(),i=(r.startsWith("/")?r:`/${r}`).split("/"),o=i.pop()||"untitled",a=i.join("/")||"/workspace",l=it(`${a}/${o}`),g=[];try{g=await ot(Fm(l),n)}catch(h){if(!(h instanceof T&&h.status===404))throw h}if(g.some(h=>h.name===Nm(l)))throw new rt(l);let m=await Gm(l,new Blob([],{type:"application/octet-stream"}),n,{overwrite:!1});return[{path:m.path,size:m.bytes}]}async function Bt(e,t,n){let r=re(n);return zx(t,await ct(e,r),r)}function Vx(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Fm(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}function Nm(e){return e.slice(e.lastIndexOf("/")+1)}function Yx(){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 Kt(e,t,n){let r=re(n),s=it(Vx(e.trim()));return Gm(s,t,r,{overwrite:!0})}async function Gm(e,t,n,r){let s=Nm(e);if(!s)throw new T(`writeFile needs a file path, got "${e}"`,{code:"INVALID_PATH"});let i=Fm(e);await ut(i,n).catch(()=>{});let o=Yx(),a=await lt(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=it(l);try{await Bm(g,e,n,r.overwrite)}catch(h){throw await Ge(g,n).catch(()=>{}),!r.overwrite&&h instanceof T&&h.status===409?new rt(e):h}let m=a[0]?.size;return{path:e,bytes:typeof m=="number"?m:t.size}}async function Ge(e,t){let n=await F(`${re(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 st(n)}`,{status:n.status,response:n});return n.json()}async function ut(e,t){let n=await F(`${re(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 st(n)}`,{status:n.status,response:n});return n.json()}async function Wt(e,t,n){return Bm(e,t,re(n),!0)}async function Bm(e,t,n,r){let s=await F(`${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 st(s)}`,{status:s.status,response:s});return s.json()}async function uo(){return qm(await Oe().project.current())}async function Hn(){return qm(await Oe().global.health())}async function po(){try{return(await Hn()).healthy===!0}catch{return!1}}var Km={list:ot,read:at,readBlob:ct,status:qt,findFiles:Ft,findText:Nt,upload:lt,write:Kt,create:Gt,copy:Bt,remove:Ge,mkdir:ut,rename:Wt,currentProject:uo,health:Hn,isReachable:po,toDaemonPath:Ne,toSandboxAbsolutePath:it,toWorkspaceRelative:lo};var go=52428800,Jx=104857600,Wm=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 mo(e){return e.replace(/\/v1\/?$/,"")}async function pt(e,t){if(!e.backendUrl||!e.accessToken)return null;let n=mo(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`,Yn={showErrors:!1,deadlineCoversBody:!0},Hm=3e4,Qx=12e4,Zx=6e4,eP=5*6e4,tP=6e4,nP=6e4;function zn(){return new T("Request aborted",{name:"AbortError",code:"ABORTED"})}function Ht(e){if(e?.aborted)throw zn()}function rP(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 zt(e,t,n=!1){let r;for(let s=0;;s++){Ht(t);try{return await e()}catch(i){let o=n&&i instanceof T&&i.status===409&&i.code==="attachment_processing";if(t?.aborted||!(rP(i)||o))throw i;r??=Date.now()+(n?eP:Zx);let a=Math.min(8e3,500*2**s)*(.5+Math.random()/2);if(Date.now()+a>=r)throw i;try{await Dn(a,t)}catch{throw Ht(t),i}}}}function sP(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string")}function fo(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"&&sP(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 zm(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},{...Yn,signal:n,timeout:Hm}),"Failed to start attachment upload")}async function Vm(e,t,n,r){let s=fo({...await zt(()=>zm(e,t,r.signal,n.attachment_id),r.signal),received_bytes:0},t,n.attachment_id);return r.onUpload?.(s),s}function Ym(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 iP(e){if(!(e instanceof T))return;let t=Number(e.details?.statusCode);return Number.isInteger(t)&&t>=400?t:e.status}function oP(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()},tP)},_=()=>{m(zn()),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(Ym(o.status,o.responseText))},o.onerror=()=>m(new T("Network error during attachment upload",{name:"TypeError"})),o.onabort=()=>m(zn()),r.signal?.addEventListener("abort",_,{once:!0}),h(),o.send(n)})}async function aP(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"?zn():new T(i instanceof Error?i.message:String(i),{name:i instanceof Error?i.name:"TypeError"})}if(!s.ok)throw Ym(s.status,await s.text().catch(()=>""));n.onProgress?.(t.size,t.size)}function cP(e,t,n){Ht(n.signal);let r=globalThis.XMLHttpRequest;return typeof r=="function"?oP(r,e,t,n):aP(e,t,n)}async function lP(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 zt(()=>cP(o,t,r),r.signal)}catch(a){let l=iP(a);if(l!==409){if(i||!(l===400||l===401||l===403))throw a;i=!0,s=await Vm(e,t,s,r);continue}}return s={...s,received_bytes:t.size},r.onUpload?.(s),s}return Xm(e,t,s,r)}async function Xm(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;){Ht(r.signal);let a=o.received_bytes,l=Math.min(a+s,t.size),g=t.slice(a,l),m=await zt(async()=>p(await c.putRaw(`${i}/chunks/${a/s}`,g,{...Yn,signal:r.signal,timeout:Hm}),"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 Vt(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");Ht(n.signal);let r=n.resume?fo({...n.resume},t):fo({...await zt(()=>zm(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()<nP&&(r=await Vm(e,t,r,n)),r=r.upload.kind==="direct"?await lP(e,t,r,n):await Xm(e,t,r,n)),n.onProcessing?.();let s=`${Vn(e)}/${encodeURIComponent(r.attachment_id)}`;try{return await zt(async()=>p(await c.post(`${s}/complete`,{},{...Yn,signal:n.signal,timeout:Qx}),"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 dt(e,t,n={}){if(!e)throw new Error("A project is required to remove attachments");let r=await c.delete(`${Vn(e)}/${encodeURIComponent(t)}`,{...Yn,signal:n.signal});if(!r.success)throw r.error??new Error("Failed to remove attachment")}var uP=100,pP=0,dP=new Set(["attachment_size_mismatch","attachment_failed"]),Jm=()=>new T("Attachment expired. Attach the file again.",{code:"attachment_expired"});function Qm(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 yo(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,dt(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:Jm()});_()},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);Vt(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+uP-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:Qm(b),receivedBytes:b.size})}).catch(b=>{b instanceof T&&dP.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-${++pP}`;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(be()),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=Qm(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 Jm();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&&dt(e,u).catch(()=>{})}s.clear(),_()}},getSnapshot:()=>g,subscribe(f){return s.add(f),()=>{s.delete(f)}}}}async function ho(){return p(await c.get("/accounts"))}async function bo(e){return p(await c.post("/accounts",e))}async function _o(e){return p(await c.get(`/accounts/${e}`))}async function xo(e,t){return p(await c.patch(`/accounts/${e}`,{name:t}))}async function Po(e){return p(await c.get(`/accounts/${e}/branding`))}async function wo(e,t){return p(await c.put(`/accounts/${e}/branding`,t))}async function So(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 ko(e,t){return p(await c.delete(`/accounts/${e}/branding/assets/${t}`))}async function vo(e){return p(await c.delete(`/accounts/${e}/branding`))}async function Ao(e){return p(await c.get(`/accounts/${e}/members`))}async function Ro(e,t){return p(await c.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function To(e){return p(await c.get(`/accounts/${e}/invites`))}async function Co(e,t){return p(await c.delete(`/accounts/${e}/invites/${t}`))}async function Io(e,t){return p(await c.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function Eo(){return p(await c.get("/account-invites",{showErrors:!1})).invites}async function Mo(e){return p(await c.get(`/account-invites/${e}`,{showErrors:!1}))}async function Oo(e){return p(await c.post(`/account-invites/${e}/accept`,{}))}async function jo(e){return p(await c.post(`/account-invites/${e}/decline`,{}))}async function Do(e,t){return p(await c.delete(`/accounts/${e}/members/${t}`))}async function $o(e,t,n){return p(await c.patch(`/accounts/${e}/members/${t}`,{role:n}))}async function Uo(e){return p(await c.post(`/accounts/${e}/leave`,{}))}async function gP(e){return pt(e,"/v1/accounts")}async function Lo(){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 mP=["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 Be(){return p(await c.get("/projects"))}async function qo(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return p(await c.get(`/projects${t}`))}async function Xn(e,t){return p(await c.get(`/projects/${e}`,t))}async function Fo(e,t,n="write"){return p(await c.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:n}))}async function No(e,t){return p(await c.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function Go(e){return p(await c.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function fP(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function Jn(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 Qn(e,t){return p(await c.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function Zn(e,t){return p(await c.get(`/projects/${e}/model-picker`,{showErrors:!1,...t}))}async function yP(e,t){return p(await c.get(`/projects/${e}/llm-catalog/providers`,{showErrors:!1,...t}))}async function Bo(e){return p(await c.post("/projects",e))}async function Ko(e){return p(await c.post("/projects/create-repo",e,{showErrors:!1}))}async function Wo(e,t={}){return p(await c.post("/projects/provision",{seed_starter:!0,...e},{timeout:12e4,...t}))}var Zm=200;function hP(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 Lb=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},qb=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Fb=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(qb(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}let i=Lb(r),o=s.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):Ye({allowReserved:e,name:n,value:a})).join(i);return r==="label"||r==="matrix"?i+o:o},Ye=({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)}`},Cn=({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=Fb(r),a=Object.entries(s).map(([l,g])=>Ye({allowReserved:e,name:r==="deepObject"?`${n}[${l}]`:l,value:g})).join(o);return r==="label"||r==="matrix"?o+a:a};var Nb=/\{[^{}]+\}/g,Gb=({path:e,url:t})=>{let n=t,r=t.match(Nb);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,Cn({explode:i,name:o,style:a,value:l,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(s,`;${Ye({name:o,value:l})}`);continue}let g=encodeURIComponent(a==="label"?`.${l}`:l);n=n.replace(s,g)}return n},Vg=({baseUrl:e,path:t,query:n,querySerializer:r,url:s})=>{let i=s.startsWith("/")?s:`/${s}`,o=(e??"")+i;t&&(o=Gb({path:t,url:o}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(o+=`?${a}`),o};function fs(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 Yg=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 ys={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)};var Xg=({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=Cn({allowReserved:a.allowReserved,explode:!0,name:i,style:"deepObject",value:o,...a.object});l&&s.push(l)}else{let l=Ye({allowReserved:a.allowReserved,name:i,value:o});l&&s.push(l)}}return s.join("&")},Jg=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"}},Bb=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,Qg=async({security:e,...t})=>{for(let n of e){if(Bb(t,n.name))continue;let r=await Yg(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}}},hs=e=>Vg({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Xg(e.querySerializer),url:e.url}),bs=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=In(e.headers,t.headers),n},Kb=e=>{let t=[];return e.forEach((n,r)=>{t.push([r,n])}),t},In=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let r=n instanceof Headers?Kb(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},Tt=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}},Zg=()=>({error:new Tt,request:new Tt,response:new Tt}),Wb=Xg({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Hb={"Content-Type":"application/json"},Ct=(e={})=>({...ys,headers:Hb,parseAs:"auto",querySerializer:Wb,...e});var It=(e={})=>{let t=bs(Ct(),e),n=()=>({...t}),r=g=>(t=bs(t,g),n()),s=Zg(),i=async g=>{let m={...t,...g,fetch:g.fetch??t.fetch??globalThis.fetch,headers:In(t.headers,g.headers),serializedBody:void 0};m.security&&await Qg({...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=hs(m);return{opts:m,url:h}},o=async g=>{let{opts:m,url:h}=await i(g),_={redirect:"follow",...m,body:fs(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"?Jg(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 zg({...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:fs(h),url:_})};return{buildUrl:hs,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 zb={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Vb=Object.entries(zb),em=(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&&em(n.args,t);return t},Yb=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=em(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=Vb.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 Yb(n),n};var tm=It(Ct({baseUrl:"http://localhost:4096"}));var I=class{client;constructor(t){this.client=t?.client??tm}},_s=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)}},xs=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}})}},Ps=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})}},ws=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}})}},Ss=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})}},ks=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}})}},vs=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})}},As=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})}},Rs=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}})}},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:"/experimental/workspace/adapter",...n,...r})}},Cs=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 Ts({client:this.client})}},Is=class extends I{_controlPlane;get controlPlane(){return this._controlPlane??=new ws({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new Ss({client:this.client})}_console;get console(){return this._console??=new ks({client:this.client})}_session;get session(){return this._session??=new vs({client:this.client})}_resource;get resource(){return this._resource??=new As({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Rs({client:this.client})}_workspace;get workspace(){return this._workspace??=new Cs({client:this.client})}},Es=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}})}},Ms=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 Es({client:this.client})}},Os=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})}},js=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})}},Ds=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})}},$s=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}})}},Us=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})}},Ls=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})}},qs=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})}},Fs=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})}},Ns=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})}},Gs=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 Ns({client:this.client})}},Bs=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})}},Ks=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})}},Ws=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})}},Hs=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})}},zs=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 Hs({client:this.client})}},Vs=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})}},Ys=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})}},Xs=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})}},Js=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}})}},Qs=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}})}},Zs=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 Qs({client:this.client})}},ei=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})}},ti=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}})}},ni=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}})}},ri=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 ni({client:this.client})}},si=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}})}},ii=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 si({client:this.client})}},oi=class extends I{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},ai=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})}},ci=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})}},li=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})}},ui=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}})}},pi=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})}},di=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 li({client:this.client})}_permission;get permission(){return this._permission??=new ui({client:this.client})}_question;get question(){return this._question??=new pi({client:this.client})}},gi=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})}},mi=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})}},fi=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}})}},yi=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}})}},hi=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 fi({client:this.client})}_attempt;get attempt(){return this._attempt??=new yi({client:this.client})}},bi=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}})}},_i=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})}},xi=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})}},Pi=class extends I{_request;get request(){return this._request??=new _i({client:this.client})}_saved;get saved(){return this._saved??=new xi({client:this.client})}},wi=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})}},Si=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})}},ki=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})}},vi=class extends I{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},Ai=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})}},Ri=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})}},Ti=class extends I{_request;get request(){return this._request??=new Ri({client:this.client})}},Ci=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})}},Ii=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})}},Ei=class extends I{_health;get health(){return this._health??=new oi({client:this.client})}_location;get location(){return this._location??=new ai({client:this.client})}_agent;get agent(){return this._agent??=new ci({client:this.client})}_session;get session(){return this._session??=new di({client:this.client})}_model;get model(){return this._model??=new gi({client:this.client})}_provider;get provider(){return this._provider??=new mi({client:this.client})}_integration;get integration(){return this._integration??=new hi({client:this.client})}_credential;get credential(){return this._credential??=new bi({client:this.client})}_permission;get permission(){return this._permission??=new Pi({client:this.client})}_fs;get fs(){return this._fs??=new wi({client:this.client})}_command;get command(){return this._command??=new Si({client:this.client})}_skill;get skill(){return this._skill??=new ki({client:this.client})}_event;get event(){return this._event??=new vi({client:this.client})}_pty;get pty(){return this._pty??=new Ai({client:this.client})}_question;get question(){return this._question??=new Ti({client:this.client})}_reference;get reference(){return this._reference??=new Ci({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Ii({client:this.client})}},En=class e extends I{static __registry=new _s;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new xs({client:this.client})}_app;get app(){return this._app??=new Ps({client:this.client})}_experimental;get experimental(){return this._experimental??=new Is({client:this.client})}_global;get global(){return this._global??=new Ms({client:this.client})}_event;get event(){return this._event??=new Os({client:this.client})}_config;get config(){return this._config??=new js({client:this.client})}_tool;get tool(){return this._tool??=new Ds({client:this.client})}_worktree;get worktree(){return this._worktree??=new $s({client:this.client})}_find;get find(){return this._find??=new Us({client:this.client})}_file;get file(){return this._file??=new Ls({client:this.client})}_instance;get instance(){return this._instance??=new qs({client:this.client})}_path;get path(){return this._path??=new Fs({client:this.client})}_vcs;get vcs(){return this._vcs??=new Gs({client:this.client})}_command;get command(){return this._command??=new Bs({client:this.client})}_lsp;get lsp(){return this._lsp??=new Ks({client:this.client})}_formatter;get formatter(){return this._formatter??=new Ws({client:this.client})}_mcp;get mcp(){return this._mcp??=new zs({client:this.client})}_project;get project(){return this._project??=new Vs({client:this.client})}_pty;get pty(){return this._pty??=new Ys({client:this.client})}_question;get question(){return this._question??=new Xs({client:this.client})}_permission;get permission(){return this._permission??=new Js({client:this.client})}_provider;get provider(){return this._provider??=new Zs({client:this.client})}_session;get session(){return this._session??=new ei({client:this.client})}_part;get part(){return this._part??=new ti({client:this.client})}_sync;get sync(){return this._sync??=new ri({client:this.client})}_tui;get tui(){return this._tui??=new ii({client:this.client})}_v2;get v2(){return this._v2??=new Ei({client:this.client})}};function rm(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||nm(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 ${nm(n,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function nm(e,t){let n=e?.method??"?",r=e?.url??"?",s=t?.status,i=t?.statusText;return`${n} ${r}${s?" \u2192 "+s:""}${i?" "+i:""}`}function Xb(e,t,n){if(e)return t&&(e===t||n&&e===n(t))?t:e}function Jb(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=Xb(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 Mi(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=It(e);return t.interceptors.request.use(n=>Jb(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(rm),new En({client:t})}var Qb=new Set(["api","cli","mobile","tui","web"]);function sm(e){let t=e?.trim().toLowerCase();return t&&Qb.has(t)?t:null}function Zb(e){return new Promise(t=>setTimeout(t,e))}async function Mn(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 Zb(s)),o=await e(),o)return o;return o}var Oi=12e4;function e_(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function im(e,t,n=Oi){let r=e instanceof Request?e.signal:t?.signal;if(e_(e))return r??void 0;let s=AbortSignal.timeout(n);return r?typeof AbortSignal.any=="function"?AbortSignal.any([r,s]):r:s}function On(){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)}},ae=class extends T{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},Ie=class extends T{constructor(t,n,r,s={}){super(r||n.message||`Billing Error: ${t}`,{...s,status:t,detail:n}),this.name="BillingError"}},qe=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"}},t_="ENDPOINT_RETIRED";function z(e,t){let n=t?` ${t}`:"";return new T(`${e}() is retired: the Kortix API no longer serves this endpoint.${n}`,{code:t_})}var jn="feature_disabled";function om(e){if(!(e instanceof T)||e.status!==403||e.code!==jn)return null;let t=e.details??e.data;return t&&typeof t=="object"?t:{}}function ji(e){let t=om(e);return t?(typeof t.feature=="string"&&!e.feature&&(e.feature=t.feature),!0):!1}function Di(e){let t=om(e);if(!t)return null;let n=e.feature;return typeof n=="string"?n:typeof t.feature=="string"?t.feature:null}function Et(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 Ie(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 $i(e){return e instanceof Ie}function Ui(e){if(!(e instanceof Ie))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 be(){return typeof DOMException=="function"?new DOMException("Aborted","AbortError"):Object.assign(new Error("Aborted"),{name:"AbortError"})}function _e(e,t){return new Promise((n,r)=>{let s=()=>{t.removeEventListener("abort",s),r(be())};t.addEventListener("abort",s,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener("abort",s)),t.aborted&&s()})}function Dn(e,t){return new Promise((n,r)=>{let s=()=>{clearTimeout(i),t?.removeEventListener("abort",s),r(be())},i=setTimeout(()=>{t?.removeEventListener("abort",s),n()},e);t?.aborted?s():t?.addEventListener("abort",s,{once:!0})})}var am="X-Kortix-Impersonate",qi="kortix.impersonation",Fe=null,$n=!1,Li=new Set;function Fi(){try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}}function cm(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 n_(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 lm(){for(let e of Li)try{e()}catch{}}function um(){return $n||($n=!0,Fe=n_(Fi()?.getItem(qi)??null)),Fe&&!cm(Fe)?(Ni(),null):Fe}function r_(e){if($n=!0,!e){Ni();return}Fe=e;try{Fi()?.setItem(qi,JSON.stringify(e))}catch{}lm()}function Ni(){$n=!0;let e=Fe!==null;Fe=null;try{Fi()?.removeItem(qi)}catch{}e&&lm()}function s_(e){return Li.add(e),()=>{Li.delete(e)}}var i_=/(^|\/)admin\/(api|analytics)(\/|$)/;function pm(e){let t=e;if(/^https?:\/\//.test(e))try{t=new URL(e).pathname}catch{t=e}return!i_.test(t)}function Gi(e){if(e!==void 0&&!pm(e))return{};let t=um();return t?{[am]:t.grantId}:{}}var Hi=!1;function mm(e){Hi=e}function fm(){return Hi}function o_(e){return e?e instanceof Headers||Array.isArray(e)?[...new Headers(e).entries()]:Object.entries(e):[]}function Ki(e,t){let n=t.toLowerCase();return Object.keys(e).some(r=>r.toLowerCase()===n)}function Mt(e,t,n){let r=t.toLowerCase();for(let s of Object.keys(e))s.toLowerCase()===r&&delete e[s];e[t]=n}function Wi(e,t){let n={},r=[e instanceof Request?e.headers:void 0,t.headers];for(let[s,i]of r.flatMap(o_))Mt(n,s,i);return n}function dm(e,t,n){let r={...t},s=sm(L().clientSource);s&&!Ki(r,"x-kortix-client")&&Mt(r,"X-Kortix-Client",s),Hi&&Mt(r,"x-kortix-admin-bypass","1");for(let[i,o]of Object.entries(Gi(e)))Mt(r,i,o);return Ki(r,"authorization")||Mt(r,"Authorization",`Bearer ${n}`),r}function a_(e){return typeof ReadableStream<"u"&&e.body instanceof ReadableStream}function gm(e,t,n,r,s){if(t instanceof Request){let a=new Headers(dm(t.url,Wi(t,n),r));return e(new Request(t,{headers:a,...s?{signal:s}:{}}))}let i=String(t),o=dm(i,Wi(t,n),r);return e(i,{...n,headers:o,...s?{signal:s}:{}})}async function Bi(e){return Mn(()=>L().getToken(),e)}async function Ot(e,t={},n={}){let{retryOnAuthError:r=!0,timeoutMs:s=Oi}=n,i=n.fetch??L().fetch??fetch,o=s===null?(e instanceof Request?e.signal:t.signal)??void 0:im(e,t,s);if(o?.aborted)throw be();let a=await(o?_e(Bi(),o):Bi());if(!a)throw new ae;let l=r&&!a_(t)&&!Ki(Wi(e,t),"authorization"),g=l&&e instanceof Request?e.clone():e,m=await gm(i,e,t,a,o);if(m.status!==401||!l)return m;let h=await Bi({attempts:2,baseDelayMs:200});return!h||h===a?m:gm(i,g,t,h,o)}async function Un(){return L().getToken()}async function Xe(e){return Mn(()=>L().getToken(),e,Ln)}function Ln(){}function c_(e){}function l_(e){}async function Je(){return Un()}async function u_(e){return Xe(e)}async function F(e,t,n){try{return await Ot(e,t,{retryOnAuthError:n?.retryOnAuthError,timeoutMs:n?.timeoutMs})}catch(r){if(r instanceof ae)return On();throw r}}var Qe={url:null,sandboxId:null,dbSandboxId:null,version:0},p_=new Set;function ym(e,t=null,n=null){if(!(Qe.url===e&&Qe.sandboxId===t&&Qe.dbSandboxId===n)){Qe={url:e,sandboxId:t,dbSandboxId:n,version:Qe.version+1};for(let r of p_)r()}}function hm(){return Qe.url}function d_(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function jt(){return d_(L().backendUrl||"http://localhost:8008/v1")}function bm(){let e=L().sandboxId;return e?`${jt()}/p/${e}/8000`:""}function g_(e,t=8e3){return`${jt()}/p/${e}/${t}`}function Dt(e,t=8e3){return g_(e,t)}var ge=()=>L().backendUrl||"",_m="feature_not_supported",xm="model_not_servable",Pm="provision_in_flight",wm="analytics_unavailable",Sm="accounts_list_unavailable",km="request_deadline",m_=/^Request exceeded the \d+s server processing deadline$/,f_=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===km||m_.test(n),y_="git_mirror_unavailable",h_=/^git mirror is temporarily unavailable$/,b_=(e,t,n)=>e!==503?!1:(typeof t=="object"&&t!==null&&"code"in t?t.code:void 0)===y_||h_.test(n),__=new Set([502,503,504]),x_=e=>__.has(e),vm=e=>{let t=(e??"GET").toUpperCase();return t==="GET"||t==="HEAD"},P_=e=>vm(e)||(e??"GET").toUpperCase()==="DELETE",w_=2,qn=e=>e?.name==="AbortError"||e?.name==="AbortSignal"||e instanceof Error&&e.message.includes("aborted");async function Ee(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 be();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=vm(o.method),v=P_(o.method),j=v?w_+1:1,k;for(let u=0;u<j;u++){u>0&&await Dn(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 _e(Ot(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 ae)return{error:new ae,success:!1};if(_&&qn(P)&&!o.signal?.aborted&&v&&u<j-1){_=!1;continue}if(qn(P)||u===j-1)throw P;continue}if(!(A&&x_(k.status)&&u<j-1)){!i&&m&&(clearTimeout(m),m=null);break}try{await _e(k.arrayBuffer(),x.signal)}catch(P){if(qn(P))throw P}finally{m&&(clearTimeout(m),m=null)}}if(!k.ok){let u=`HTTP ${k.status}: ${k.statusText}`,x=null;try{x=await _e(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 be();let C=f_(k.status,x,u),P=b_(k.status,x,u),w=new T(u,{status:k.status,response:k,details:x||void 0,data:x,detail:x?.detail,code:C?km:x?.code||x?.error_code||x?.detail?.error_code||k.status.toString()});if(k.status===402&&(w=Et(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 qe(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===_m,R=k.status===409&&x?.code===xm,D=k.status===409&&x?.code===Pm,U=k.status===503&&x?.code===wm,b=k.status===503&&x?.code===Sm;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 _e(k.json(),l.signal):f?.includes("text/")?d=await _e(k.text(),l.signal):d=await _e(k.blob(),l.signal),{data:d,success:!0,headers:k.headers}}catch(S){m&&(clearTimeout(m),m=null);let A=qn(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(ge(),"")||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 S_={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 k_(e,t,n={}){let{timeout:r=3e4,fetch:s}=n,i=new AbortController,o=setTimeout(()=>i.abort(),r);try{return await Ot(`${ge()}${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 ae)return On();throw a}finally{clearTimeout(o)}}var c={putRaw:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"PUT",body:t,headers:{"Content-Type":"application/octet-stream",...n?.headers}}),get:(e,t)=>Ee(`${ge()}${e}`,{...t,method:"GET"}),post:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,n)=>Ee(`${ge()}${e}`,{...n,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>Ee(`${ge()}${e}`,{...t,method:"DELETE"}),upload:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],Ee(`${ge()}${e}`,{...s,method:"POST",body:t,headers:i})},uploadPut:(e,t,n)=>{let{headers:r,...s}=n||{},i={...r};return delete i["Content-Type"],Ee(`${ge()}${e}`,{...s,method:"PUT",body:t,headers:i})},postStream:k_};var $t=new Map,zi=new Map;function Vi(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Am(e){return $t.get(Vi(e))??null}function Rm(){return[...$t.values()].filter(e=>typeof e=="string")}function Tm(e){return $t.has(Vi(e))}async function Ze(e){let t=Vi(e),n=$t.get(t);if(n!==void 0)return n;let r=zi.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 $t.set(t,o),o}catch{return null}finally{zi.delete(t)}})();return zi.set(t,s),s}function Cm(e){let{apiBaseUrl:t}=e;return Tm(t)||Ze(t).catch(()=>{}),{sandboxId:e.sandboxId,backendPort:e.backendPort,apiBaseUrl:t,previewUrlTemplate:Am(t)}}function xe(){let e=hm();return e||(L().billingEnabled??!1?"":bm())}async function Yi(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function Xi(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function Ji(e){let t=Xi(e),n=await F(`${t}/env`);if(!n.ok)throw new Error(await Yi(n,"Failed to load secrets"));return(await n.json()).secrets??{}}async function Qi(e,t,n){let r=Xi(e),s=await F(`${r}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!s.ok)throw new Error(await Yi(s,"Failed to save secret"))}async function Zi(e,t){let n=Xi(e),r=await F(`${n}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await Yi(r,"Failed to delete secret"))}var Im={list:Ji,set:Qi,delete:Zi};async function Em(e,t,n){let r=e;for(;r.endsWith("/");)r=r.slice(0,-1);let s=await F(`${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 Pe(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 Fn(e,t){let n=await e.json().catch(()=>({}));return n?.error||n?.message||e.statusText||t}function Ut(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return Pe(e)}async function to(e){let t=Ut(e),n=await F(`${t}/kortix/pty`);if(!n.ok)throw new Error(await Fn(n,"Failed to list terminals"));return n.json()}async function no(e,t){let n=Ut(e),r=await F(`${n}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok)throw new Error(await Fn(r,"Failed to create terminal"));return r.json()}async function ro(e,t,n){let r=Ut(e),s=await F(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw new Error(await Fn(s,"Failed to update terminal"));return s.json()}async function so(e,t){let n=Ut(e),r=await F(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw new Error(await Fn(r,"Failed to remove terminal"))}async function io(e,t,n){let r=Ut(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:"),Pe(g.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,o=new URLSearchParams,a=await Je();a&&o.set("token",a),n?.wake&&o.set("wake","1");let l=o.toString();return l?`${i}${i.includes("?")?"&":"?"}${l}`:i}function Mm(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 Me="\x1B",Om="\x07",v_="\0",eo=`(?:${Om}|${Me}\\\\)`,A_=[new RegExp(`${Me}\\]697;[^${Om}${Me}]*${eo}`,"g"),new RegExp(`${v_}?\\{"cursor":\\d+\\}`,"g"),new RegExp(`${Me}\\][0-9]+;rgb:[0-9a-fA-F/]+${eo}`,"g"),new RegExp(`${Me}\\]4;[0-9]+;rgb:[0-9a-fA-F/]+${eo}`,"g"),new RegExp(`${Me}\\[\\??[0-9;]*\\$y`,"g"),new RegExp(`${Me}\\[\\d+;\\d+R`,"g"),new RegExp(`${Me}\\[\\?[0-9;]*c`,"g")];function jm(e){let t=e;for(let n of A_)t=t.replace(n,"");return t}var Dm={list:to,create:no,update:ro,remove:so,webSocketUrl:io};async function $(e,t,n,r){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let i=await F(`${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 R_(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 T_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function C_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function I_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function E_(e,t){return $(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function M_(e,t,n){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function O_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function j_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function D_(e,t){return $(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function $_(e,t){let n=t?`?project_id=${encodeURIComponent(t)}`:"";return $(e,`/kortix/tickets${n}`)}async function U_(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function L_(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function q_(e,t){return $(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function F_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function N_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(n)})}async function G_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(n)})}async function B_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(n)})}async function K_(e,t,n){return $(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(n)})}async function W_(e,t){return $(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function H_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function z_(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:n})})}async function V_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function Y_(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:n})})}async function X_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function J_(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:n})})}async function Q_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function Z_(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function ex(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(n)})}async function tx(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function nx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}`,{method:"DELETE"})}async function rx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(n)}/persona`)}async function sx(e,t,n=200){return $(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${n}`)}async function ix(e){return $(e,"/kortix/projects")}async function ox(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function ax(e,t){return $(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function cx(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function lx(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function ux(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}async function px(e,t,n="all"){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${n}`)}async function dx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`)}async function gx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/events`)}async function mx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(n)})}async function fx(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(r)})}async function yx(e,t,n,r){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/close`,{method:"POST",body:JSON.stringify(r)})}async function hx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}/reopen`,{method:"POST"})}async function bx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(n)}`,{method:"DELETE"})}async function _x(e,t){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function xx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}/events`)}async function Px(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(n)})}async function wx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`)}async function Sx(e,t,n){return $(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(n)}`,{method:"DELETE"})}var kx=1e4,vx={retryOnAuthError:!1};function et(e,t,n){return $(e,t,{signal:AbortSignal.timeout(kx),...n},vx)}async function Ax(e,t=!1){return(await et(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function Rx(e){return(await et(e,"/kortix/services/templates")).templates??[]}async function Tx(e,t){return(await et(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function Cx(e,t,n){let r=n==="delete",s=r?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${n}`;return et(e,s,{method:r?"DELETE":"POST"})}async function Ix(e,t){return et(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function Ex(e,t){return et(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var Nn=new Map,tt=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function Oe(){let e=xe();if(!e)throw new tt;return we(e)}function we(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=Nn.get(e);if(t)return t;if(!Rn())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let n=Mi({baseUrl:e,fetch:F});return Nn.set(e,n),n}function Mx(e){Nn.delete(e)}function Ox(){Nn.clear()}var Gn=new Map;function jx(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=Gn.get(e);if(t)return t;let n=Mi({baseUrl:e,fetch});return Gn.set(e,n),n}function Dx(e){Gn.delete(e)}function $x(){Gn.clear()}async function Ux(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 Lx(e){let t=xe();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 F(`${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 Ux(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 qm(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 st(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 re(e){let t=(e??xe()).trim();if(!t)throw new tt;return t}async function Kn(e,t){let n=await F(`${re(t)}${e}`);if(!n.ok)throw new T(await st(n),{status:n.status,response:n});return n.json()}var Wn=["/workspace","/tmp","/home","/opt"],qx=Wn.filter(e=>e!=="/workspace");function co(e){return Wn.some(t=>e===t||e.startsWith(`${t}/`))}function it(e){return co(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function Ne(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(qx.some(n=>t===n||t.startsWith(`${n}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var lo=Ne;async function ot(e,t){let n=re(t),r=Ne(e)||".";return(await Kn(`/file?path=${encodeURIComponent(r)}`,n)).map(i=>({...i,path:i.absolute||`/workspace/${i.path}`}))}async function at(e,t){let n=re(t),r=Ne(e),s=await F(`${n}/file/content?path=${encodeURIComponent(r)}`);if(!s.ok)throw new T(await st(s),{status:s.status,response:s});return s.json()}async function Fx(e,t,n){let r=re(n),s=Ne(e),i=await F(`${r}/file/raw?path=${encodeURIComponent(s)}`);if(!i.ok)throw new T(await st(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 ct(e,t){let n=re(t);try{return await Fx(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 qt(e){return Kn("/file/status",re(e))}async function Ft(e,t,n){let r=re(n),s=new URLSearchParams({query:e});return t?.type&&s.set("type",t.type),t?.limit&&s.set("limit",String(t.limit)),Kn(`/find/file?${s.toString()}`,r)}async function Nt(e,t){let n=re(t);return(await Kn(`/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 Lt=[400,1200],Nx=e=>e===408||e===429||e===502||e===503||e===504,$m=e=>new Promise(t=>setTimeout(t,e));function Gx(e){let t=e?.name;return t==="TimeoutError"||t==="AbortError"}var oo=3e4,Bx=15*6e4,Kx=256;function nt(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return oo;let t=oo+e/Kx;return Math.min(Bx,Math.max(oo,Math.round(t)))}async function Wx(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 Bn(e,t){let n;for(let s=0;s<=Lt.length;s++){let i;try{i=await t(e())}catch(a){if(n=a,Gx(a)||s===Lt.length)break;await $m(Lt[s]);continue}if(i.ok)return i.json();let o=await Wx(i);if(n=new T(`Upload failed (${i.status}): ${o}`,{status:i.status,response:i}),!Nx(i.status)||s===Lt.length)throw n;await $m(Lt[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 ao=64*1024;function Um(e,t){try{e?.onProgress?.(t)}catch{}}function Lm(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 Hx(e){let t=e.lastIndexOf("/");return t<0?{parent:"",name:e}:{parent:e.slice(0,t)||"/",name:e.slice(t+1)}}async function lt(e,t,n,r,s){let i=typeof r=="string"?r:void 0,o=typeof r=="string"?s:r,a=re(i),l=nt(e.size),g=n||(e instanceof File?e.name:"")||"";if(e.size<=ao){let S=await Bn(()=>Lm(e,t,g),A=>F(`${a}/file/upload`,{method:"POST",body:A},{timeoutMs:l}));return Um(o,{loadedBytes:e.size,totalBytes:e.size}),S}let h=(await Bn(()=>Lm(new Blob([],{type:e.type}),t,g),S=>F(`${a}/file/upload`,{method:"POST",body:S},{timeoutMs:nt(0)})))[0]?.path;if(!h)throw new T("Upload reservation returned no file path",{code:"UPLOAD_NO_RESULT"});let _=Hx(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+=ao){let A=Math.min(e.size,S+ao),v=e.slice(S,A,e.type),j=await Bn(()=>{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=>F(`${a}/file/append`,{method:"POST",body:k},{timeoutMs:nt(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"});Um(o,{loadedBytes:A,totalBytes:e.size})}}catch(S){throw await Ge(h,a).catch(()=>{}),S}return[{path:h,size:e.size}]}function zx(e,t,n){let r=re(n),s=nt(t.size);return Bn(()=>{let i=new FormData;return i.append(e,t,e.split("/").pop()||"file"),i},i=>F(`${r}/file/upload`,{method:"POST",body:i},{timeoutMs:s}))}var rt=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 Gt(e,t){let n=re(t),r=e.trim(),i=(r.startsWith("/")?r:`/${r}`).split("/"),o=i.pop()||"untitled",a=i.join("/")||"/workspace",l=it(`${a}/${o}`),g=[];try{g=await ot(Fm(l),n)}catch(h){if(!(h instanceof T&&h.status===404))throw h}if(g.some(h=>h.name===Nm(l)))throw new rt(l);let m=await Gm(l,new Blob([],{type:"application/octet-stream"}),n,{overwrite:!1});return[{path:m.path,size:m.bytes}]}async function Bt(e,t,n){let r=re(n);return zx(t,await ct(e,r),r)}function Vx(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Fm(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}function Nm(e){return e.slice(e.lastIndexOf("/")+1)}function Yx(){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 Kt(e,t,n){let r=re(n),s=it(Vx(e.trim()));return Gm(s,t,r,{overwrite:!0})}async function Gm(e,t,n,r){let s=Nm(e);if(!s)throw new T(`writeFile needs a file path, got "${e}"`,{code:"INVALID_PATH"});let i=Fm(e);await ut(i,n).catch(()=>{});let o=Yx(),a=await lt(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=it(l);try{await Bm(g,e,n,r.overwrite)}catch(h){throw await Ge(g,n).catch(()=>{}),!r.overwrite&&h instanceof T&&h.status===409?new rt(e):h}let m=a[0]?.size;return{path:e,bytes:typeof m=="number"?m:t.size}}async function Ge(e,t){let n=await F(`${re(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 st(n)}`,{status:n.status,response:n});return n.json()}async function ut(e,t){let n=await F(`${re(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 st(n)}`,{status:n.status,response:n});return n.json()}async function Wt(e,t,n){return Bm(e,t,re(n),!0)}async function Bm(e,t,n,r){let s=await F(`${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 st(s)}`,{status:s.status,response:s});return s.json()}async function uo(){return qm(await Oe().project.current())}async function Hn(){return qm(await Oe().global.health())}async function po(){try{return(await Hn()).healthy===!0}catch{return!1}}var Km={list:ot,read:at,readBlob:ct,status:qt,findFiles:Ft,findText:Nt,upload:lt,write:Kt,create:Gt,copy:Bt,remove:Ge,mkdir:ut,rename:Wt,currentProject:uo,health:Hn,isReachable:po,toDaemonPath:Ne,toSandboxAbsolutePath:it,toWorkspaceRelative:lo};var go=52428800,Jx=104857600,Wm=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 mo(e){return e.replace(/\/v1\/?$/,"")}async function pt(e,t){if(!e.backendUrl||!e.accessToken)return null;let n=mo(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`,Yn={showErrors:!1,deadlineCoversBody:!0},Hm=3e4,Qx=12e4,Zx=6e4,eP=5*6e4,tP=6e4,nP=6e4;function zn(){return new T("Request aborted",{name:"AbortError",code:"ABORTED"})}function Ht(e){if(e?.aborted)throw zn()}function rP(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 zt(e,t,n=!1){let r;for(let s=0;;s++){Ht(t);try{return await e()}catch(i){let o=n&&i instanceof T&&i.status===409&&i.code==="attachment_processing";if(t?.aborted||!(rP(i)||o))throw i;r??=Date.now()+(n?eP:Zx);let a=Math.min(8e3,500*2**s)*(.5+Math.random()/2);if(Date.now()+a>=r)throw i;try{await Dn(a,t)}catch{throw Ht(t),i}}}}function sP(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string")}function fo(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"&&sP(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 zm(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},{...Yn,signal:n,timeout:Hm}),"Failed to start attachment upload")}async function Vm(e,t,n,r){let s=fo({...await zt(()=>zm(e,t,r.signal,n.attachment_id),r.signal),received_bytes:0},t,n.attachment_id);return r.onUpload?.(s),s}function Ym(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 iP(e){if(!(e instanceof T))return;let t=Number(e.details?.statusCode);return Number.isInteger(t)&&t>=400?t:e.status}function oP(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()},tP)},_=()=>{m(zn()),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(Ym(o.status,o.responseText))},o.onerror=()=>m(new T("Network error during attachment upload",{name:"TypeError"})),o.onabort=()=>m(zn()),r.signal?.addEventListener("abort",_,{once:!0}),h(),o.send(n)})}async function aP(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"?zn():new T(i instanceof Error?i.message:String(i),{name:i instanceof Error?i.name:"TypeError"})}if(!s.ok)throw Ym(s.status,await s.text().catch(()=>""));n.onProgress?.(t.size,t.size)}function cP(e,t,n){Ht(n.signal);let r=globalThis.XMLHttpRequest;return typeof r=="function"?oP(r,e,t,n):aP(e,t,n)}async function lP(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 zt(()=>cP(o,t,r),r.signal)}catch(a){let l=iP(a);if(l!==409){if(i||!(l===400||l===401||l===403))throw a;i=!0,s=await Vm(e,t,s,r);continue}}return s={...s,received_bytes:t.size},r.onUpload?.(s),s}return Xm(e,t,s,r)}async function Xm(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;){Ht(r.signal);let a=o.received_bytes,l=Math.min(a+s,t.size),g=t.slice(a,l),m=await zt(async()=>p(await c.putRaw(`${i}/chunks/${a/s}`,g,{...Yn,signal:r.signal,timeout:Hm}),"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 Vt(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");Ht(n.signal);let r=n.resume?fo({...n.resume},t):fo({...await zt(()=>zm(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()<nP&&(r=await Vm(e,t,r,n)),r=r.upload.kind==="direct"?await lP(e,t,r,n):await Xm(e,t,r,n)),n.onProcessing?.();let s=`${Vn(e)}/${encodeURIComponent(r.attachment_id)}`;try{return await zt(async()=>p(await c.post(`${s}/complete`,{},{...Yn,signal:n.signal,timeout:Qx}),"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 dt(e,t,n={}){if(!e)throw new Error("A project is required to remove attachments");let r=await c.delete(`${Vn(e)}/${encodeURIComponent(t)}`,{...Yn,signal:n.signal});if(!r.success)throw r.error??new Error("Failed to remove attachment")}var uP=100,pP=0,dP=new Set(["attachment_size_mismatch","attachment_failed"]),Jm=()=>new T("Attachment expired. Attach the file again.",{code:"attachment_expired"});function Qm(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 yo(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,dt(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:Jm()});_()},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);Vt(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+uP-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:Qm(b),receivedBytes:b.size})}).catch(b=>{b instanceof T&&dP.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-${++pP}`;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(be()),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=Qm(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 Jm();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&&dt(e,u).catch(()=>{})}s.clear(),_()}},getSnapshot:()=>g,subscribe(f){return s.add(f),()=>{s.delete(f)}}}}async function ho(){return p(await c.get("/accounts"))}async function bo(e){return p(await c.post("/accounts",e))}async function _o(e){return p(await c.get(`/accounts/${e}`))}async function xo(e,t){return p(await c.patch(`/accounts/${e}`,{name:t}))}async function Po(e){return p(await c.get(`/accounts/${e}/branding`))}async function wo(e,t){return p(await c.put(`/accounts/${e}/branding`,t))}async function So(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 ko(e,t){return p(await c.delete(`/accounts/${e}/branding/assets/${t}`))}async function vo(e){return p(await c.delete(`/accounts/${e}/branding`))}async function Ao(e){return p(await c.get(`/accounts/${e}/members`))}async function Ro(e,t){return p(await c.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function To(e){return p(await c.get(`/accounts/${e}/invites`))}async function Co(e,t){return p(await c.delete(`/accounts/${e}/invites/${t}`))}async function Io(e,t){return p(await c.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function Eo(){return p(await c.get("/account-invites",{showErrors:!1})).invites}async function Mo(e){return p(await c.get(`/account-invites/${e}`,{showErrors:!1}))}async function Oo(e){return p(await c.post(`/account-invites/${e}/accept`,{}))}async function jo(e){return p(await c.post(`/account-invites/${e}/decline`,{}))}async function Do(e,t){return p(await c.delete(`/accounts/${e}/members/${t}`))}async function $o(e,t,n){return p(await c.patch(`/accounts/${e}/members/${t}`,{role:n}))}async function Uo(e){return p(await c.post(`/accounts/${e}/leave`,{}))}async function gP(e){return pt(e,"/v1/accounts")}async function Lo(){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 mP=["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 Be(){return p(await c.get("/projects"))}async function qo(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return p(await c.get(`/projects${t}`))}async function Xn(e,t){return p(await c.get(`/projects/${e}`,t))}async function Fo(e,t,n="write"){return p(await c.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:n}))}async function No(e,t){return p(await c.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function Go(e){return p(await c.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function fP(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function Jn(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 Qn(e,t){return p(await c.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function Zn(e,t){return p(await c.get(`/projects/${e}/model-picker`,{showErrors:!1,...t}))}async function yP(e,t){return p(await c.get(`/projects/${e}/llm-catalog/providers`,{showErrors:!1,...t}))}async function Bo(e){return p(await c.post("/projects",e))}async function Ko(e){return p(await c.post("/projects/create-repo",e,{showErrors:!1}))}async function Wo(e,t={}){return p(await c.post("/projects/provision",{seed_starter:!0,...e},{timeout:12e4,...t}))}var Zm=200;function hP(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>Zm?`${n.slice(0,Zm)}\u2026`:n;throw new Error(`provisionProjectStream: received an unparseable SSE frame (${s})`,{cause:r})}}async function bP(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
|
|