@kortix/sdk 0.10.5 → 0.10.7

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.
@@ -1,11 +1,11 @@
1
- var Gc={backendUrl:"",getToken:async()=>null},ht=null,Fe=null;function Up(e){Fe=e}function Op(){return Fe}function bt(e,t){t?.global!==!1&&(ht=e)}function I(){return Fe?.()??ht??Gc}function xt(){return ht!==null||Fe?.()!==void 0}var wn=({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:s,sseDefaultRetryDelay:c,sseMaxRetryAttempts:u,sseMaxRetryDelay:d,sseSleepFn:g,url:h,...m})=>{let x,w=g??(i=>new Promise(P=>setTimeout(P,i)));return{stream:async function*(){let i=c??3e3,P=0,_=m.signal??new AbortController().signal;for(;!_.aborted;){P++;let D=m.headers instanceof Headers?m.headers:new Headers(m.headers);x!==void 0&&D.set("Last-Event-ID",x);try{let A={redirect:"follow",...m,body:m.serializedBody,headers:D,signal:_},v=new Request(h,A);e&&(v=await e(h,A));let j=await(m.fetch??globalThis.fetch)(v);if(!j.ok)throw new Error(`SSE failed: ${j.status} ${j.statusText}`);if(!j.body)throw new Error("No body in SSE response");let f=j.body.pipeThrough(new TextDecoderStream).getReader(),S="",U=()=>{try{f.cancel()}catch{}};_.addEventListener("abort",U);try{for(;;){let{done:K,value:M}=await f.read();if(K)break;S+=M,S=S.replace(/\r\n/g,`
1
+ var Wc={backendUrl:"",getToken:async()=>null},bt=null,Be=null;function Bp(e){Be=e}function Kp(){return Be}function xt(e,t){t?.global!==!1&&(bt=e)}function I(){return Be?.()??bt??Wc}function kt(){return bt!==null||Be?.()!==void 0}var Sn=({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:s,sseDefaultRetryDelay:c,sseMaxRetryAttempts:u,sseMaxRetryDelay:d,sseSleepFn:g,url:h,...m})=>{let x,w=g??(i=>new Promise(P=>setTimeout(P,i)));return{stream:async function*(){let i=c??3e3,P=0,_=m.signal??new AbortController().signal;for(;!_.aborted;){P++;let D=m.headers instanceof Headers?m.headers:new Headers(m.headers);x!==void 0&&D.set("Last-Event-ID",x);try{let A={redirect:"follow",...m,body:m.serializedBody,headers:D,signal:_},v=new Request(h,A);e&&(v=await e(h,A));let j=await(m.fetch??globalThis.fetch)(v);if(!j.ok)throw new Error(`SSE failed: ${j.status} ${j.statusText}`);if(!j.body)throw new Error("No body in SSE response");let f=j.body.pipeThrough(new TextDecoderStream).getReader(),S="",U=()=>{try{f.cancel()}catch{}};_.addEventListener("abort",U);try{for(;;){let{done:K,value:M}=await f.read();if(K)break;S+=M,S=S.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `);let O=S.split(`
4
4
 
5
- `);S=O.pop()??"";for(let ne of O){let Ue=ne.split(`
6
- `),me=[],fe;for(let E of Ue)if(E.startsWith("data:"))me.push(E.replace(/^data:\s*/,""));else if(E.startsWith("event:"))fe=E.replace(/^event:\s*/,"");else if(E.startsWith("id:"))x=E.replace(/^id:\s*/,"");else if(E.startsWith("retry:")){let B=Number.parseInt(E.replace(/^retry:\s*/,""),10);Number.isNaN(B)||(i=B)}let N,F=!1;if(me.length){let E=me.join(`
7
- `);try{N=JSON.parse(E),F=!0}catch{N=E}}F&&(s&&await s(N),n&&(N=await n(N))),r?.({data:N,event:fe,id:x,retry:i}),me.length&&(yield N)}}}finally{_.removeEventListener("abort",U),f.releaseLock()}break}catch(A){if(t?.(A),u!==void 0&&P>=u)break;let v=Math.min(i*2**(P-1),d??3e4);await w(v)}}}()}};var Bc=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Kc=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Nc=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Ge=({allowReserved:e,explode:t,name:r,style:n,value:s})=>{if(!t){let d=(e?s:s.map(g=>encodeURIComponent(g))).join(Kc(n));switch(n){case"label":return`.${d}`;case"matrix":return`;${r}=${d}`;case"simple":return d;default:return`${r}=${d}`}}let c=Bc(n),u=s.map(d=>n==="label"||n==="simple"?e?d:encodeURIComponent(d):se({allowReserved:e,name:r,value:d})).join(c);return n==="label"||n==="matrix"?c+u:u},se=({allowReserved:e,name:t,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},Be=({allowReserved:e,explode:t,name:r,style:n,value:s,valueOnly:c})=>{if(s instanceof Date)return c?s.toISOString():`${r}=${s.toISOString()}`;if(n!=="deepObject"&&!t){let g=[];Object.entries(s).forEach(([m,x])=>{g=[...g,m,e?x:encodeURIComponent(x)]});let h=g.join(",");switch(n){case"form":return`${r}=${h}`;case"label":return`.${h}`;case"matrix":return`;${r}=${h}`;default:return h}}let u=Nc(n),d=Object.entries(s).map(([g,h])=>se({allowReserved:e,name:n==="deepObject"?`${r}[${g}]`:g,value:h})).join(u);return n==="label"||n==="matrix"?u+d:d};var Hc=/\{[^{}]+\}/g,Wc=({path:e,url:t})=>{let r=t,n=t.match(Hc);if(n)for(let s of n){let c=!1,u=s.substring(1,s.length-1),d="simple";u.endsWith("*")&&(c=!0,u=u.substring(0,u.length-1)),u.startsWith(".")?(u=u.substring(1),d="label"):u.startsWith(";")&&(u=u.substring(1),d="matrix");let g=e[u];if(g==null)continue;if(Array.isArray(g)){r=r.replace(s,Ge({explode:c,name:u,style:d,value:g}));continue}if(typeof g=="object"){r=r.replace(s,Be({explode:c,name:u,style:d,value:g,valueOnly:!0}));continue}if(d==="matrix"){r=r.replace(s,`;${se({name:u,value:g})}`);continue}let h=encodeURIComponent(d==="label"?`.${g}`:g);r=r.replace(s,h)}return r},_n=({baseUrl:e,path:t,query:r,querySerializer:n,url:s})=>{let c=s.startsWith("/")?s:`/${s}`,u=(e??"")+c;t&&(u=Wc({path:t,url:u}));let d=r?n(r):"";return d.startsWith("?")&&(d=d.substring(1)),d&&(u+=`?${d}`),u};function kt(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 Sn=async(e,t)=>{let r=typeof t=="function"?await t(e):t;if(r)return e.scheme==="bearer"?`Bearer ${r}`:e.scheme==="basic"?`Basic ${btoa(r)}`:r};var Pt={bodySerializer:e=>JSON.stringify(e,(t,r)=>typeof r=="bigint"?r.toString():r)};var vn=({parameters:e={},...t}={})=>n=>{let s=[];if(n&&typeof n=="object")for(let c in n){let u=n[c];if(u==null)continue;let d=e[c]||t;if(Array.isArray(u)){let g=Ge({allowReserved:d.allowReserved,explode:!0,name:c,style:"form",value:u,...d.array});g&&s.push(g)}else if(typeof u=="object"){let g=Be({allowReserved:d.allowReserved,explode:!0,name:c,style:"deepObject",value:u,...d.object});g&&s.push(g)}else{let g=se({allowReserved:d.allowReserved,name:c,value:u});g&&s.push(g)}}return s.join("&")},Cn=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(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},Vc=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,Rn=async({security:e,...t})=>{for(let r of e){if(Vc(t,r.name))continue;let n=await Sn(r,t.auth);if(!n)continue;let s=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[s]=n;break;case"cookie":t.headers.append("Cookie",`${s}=${n}`);break;default:t.headers.set(s,n);break}}},wt=e=>_n({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:vn(e.querySerializer),url:e.url}),_t=(e,t)=>{let r={...e,...t};return r.baseUrl?.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=Ke(e.headers,t.headers),r},zc=e=>{let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t},Ke=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?zc(r):Object.entries(r);for(let[s,c]of n)if(c===null)t.delete(s);else if(Array.isArray(c))for(let u of c)t.append(s,u);else c!==void 0&&t.set(s,typeof c=="object"?JSON.stringify(c):c)}return t},he=class{fns=[];clear(){this.fns=[]}eject(t){let r=this.getInterceptorIndex(t);this.fns[r]&&(this.fns[r]=null)}exists(t){let r=this.getInterceptorIndex(t);return!!this.fns[r]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,r){let n=this.getInterceptorIndex(t);return this.fns[n]?(this.fns[n]=r,t):!1}use(t){return this.fns.push(t),this.fns.length-1}},Tn=()=>({error:new he,request:new he,response:new he}),Jc=vn({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Xc={"Content-Type":"application/json"},be=(e={})=>({...Pt,headers:Xc,parseAs:"auto",querySerializer:Jc,...e});var xe=(e={})=>{let t=_t(be(),e),r=()=>({...t}),n=h=>(t=_t(t,h),r()),s=Tn(),c=async h=>{let m={...t,...h,fetch:h.fetch??t.fetch??globalThis.fetch,headers:Ke(t.headers,h.headers),serializedBody:void 0};m.security&&await Rn({...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 x=wt(m);return{opts:m,url:x}},u=async h=>{let{opts:m,url:x}=await c(h),w={redirect:"follow",...m,body:kt(m)},k=new Request(x,w);for(let T of s.request.fns)T&&(k=await T(k,m));let l=m.fetch,i;try{i=await l(k)}catch(T){let j=T;for(let f of s.error.fns)f&&(j=await f(T,void 0,k,m));if(j=j||{},m.throwOnError)throw j;return m.responseStyle==="data"?void 0:{error:j,request:k,response:void 0}}for(let T of s.response.fns)T&&(i=await T(i,k,m));let P={request:k,response:i};if(i.ok){let T=(m.parseAs==="auto"?Cn(i.headers.get("Content-Type")):m.parseAs)??"json";if(i.status===204||i.headers.get("Content-Length")==="0"){let f;switch(T){case"arrayBuffer":case"blob":case"text":f=await i[T]();break;case"formData":f=new FormData;break;case"stream":f=i.body;break;default:f={};break}return m.responseStyle==="data"?f:{data:f,...P}}let j;switch(T){case"arrayBuffer":case"blob":case"formData":case"text":j=await i[T]();break;case"json":{let f=await i.text();j=f?JSON.parse(f):{};break}case"stream":return m.responseStyle==="data"?i.body:{data:i.body,...P}}return T==="json"&&(m.responseValidator&&await m.responseValidator(j),m.responseTransformer&&(j=await m.responseTransformer(j))),m.responseStyle==="data"?j:{data:j,...P}}let _=await i.text(),D;try{D=JSON.parse(_)}catch{}let A=D??_,v=A;for(let T of s.error.fns)T&&(v=await T(A,i,k,m));if(v=v||{},m.throwOnError)throw v;return m.responseStyle==="data"?void 0:{error:v,...P}},d=h=>m=>u({...m,method:h}),g=h=>async m=>{let{opts:x,url:w}=await c(m);return wn({...x,body:x.body,headers:x.headers,method:h,onRequest:async(k,l)=>{let i=new Request(k,l);for(let P of s.request.fns)P&&(i=await P(i,x));return i},serializedBody:kt(x),url:w})};return{buildUrl:wt,connect:d("CONNECT"),delete:d("DELETE"),get:d("GET"),getConfig:r,head:d("HEAD"),interceptors:s,options:d("OPTIONS"),patch:d("PATCH"),post:d("POST"),put:d("PUT"),request:u,setConfig:n,sse:{connect:g("CONNECT"),delete:g("DELETE"),get:g("GET"),head:g("HEAD"),options:g("OPTIONS"),patch:g("PATCH"),post:g("POST"),put:g("PUT"),trace:g("TRACE")},trace:d("TRACE")}};var Qc={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Yc=Object.entries(Qc),In=(e,t)=>{t||(t=new Map);for(let r of e)"in"in r?r.key&&t.set(r.key,{in:r.in,map:r.map}):"key"in r?t.set(r.key,{map:r.map}):r.args&&In(r.args,t);return t},Zc=e=>{for(let[t,r]of Object.entries(e))r&&typeof r=="object"&&!Object.keys(r).length&&delete e[t]},p=(e,t)=>{let r={body:{},headers:{},path:{},query:{}},n=In(t),s;for(let[c,u]of e.entries())if(t[c]&&(s=t[c]),!!s)if("in"in s)if(s.key){let d=n.get(s.key),g=d.map||s.key;d.in&&(r[d.in][g]=u)}else r.body=u;else for(let[d,g]of Object.entries(u??{})){let h=n.get(d);if(h)if(h.in){let m=h.map||d;r[h.in][m]=g}else r[h.map]=g;else{let m=Yc.find(([x])=>d.startsWith(x));if(m){let[x,w]=m;r[w][d.slice(x.length)]=g}else if("allowExtra"in s&&s.allowExtra){for(let[x,w]of Object.entries(s.allowExtra))if(w){r[x][d]=g;break}}}}return Zc(r),r};var jn=xe(be({baseUrl:"http://localhost:4096"}));var y=class{client;constructor(t){this.client=t?.client??jn}},St=class{defaultKey="default";instances=new Map;get(t){let r=this.instances.get(t??this.defaultKey);if(!r)throw new Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return r}set(t,r){this.instances.set(r??this.defaultKey,t)}},vt=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"}]}]);return(r?.client??this.client).delete({url:"/auth/{providerID}",...r,...n})}set(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return(r?.client??this.client).put({url:"/auth/{providerID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Ct=class extends y{log(t,r){let n=p([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(r?.client??this.client).post({url:"/log",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}agents(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/agent",...r,...n})}skills(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/skill",...r,...n})}},Rt=class extends y{moveSession(t,r){let n=p([t],[{args:[{in:"body",key:"sessionID"},{in:"body",key:"destination"},{in:"body",key:"moveChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/control-plane/move-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Tt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/capabilities",...r,...n})}},It=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console",...r,...n})}listOrgs(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console/orgs",...r,...n})}switchOrg(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"accountID"},{in:"body",key:"orgID"}]}]);return(r?.client??this.client).post({url:"/experimental/console/switch",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},jt=class extends y{list(t,r){let n=p([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(r?.client??this.client).get({url:"/experimental/session",...r,...n})}background(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/session/{sessionID}/background",...r,...n})}},At=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/resource",...r,...n})}},Et=class extends y{generateName(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"context"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/generate-name",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},$t=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/adapter",...r,...n})}},qt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/experimental/workspace",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}syncList(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/sync-list",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/status",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/experimental/workspace/{id}",...r,...n})}warp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"sessionID"},{in:"body",key:"copyChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/warp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_adapter;get adapter(){return this._adapter??=new $t({client:this.client})}},Dt=class extends y{_controlPlane;get controlPlane(){return this._controlPlane??=new Rt({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new Tt({client:this.client})}_console;get console(){return this._console??=new It({client:this.client})}_session;get session(){return this._session??=new jt({client:this.client})}_resource;get resource(){return this._resource??=new At({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Et({client:this.client})}_workspace;get workspace(){return this._workspace??=new qt({client:this.client})}},Mt=class extends y{get(t){return(t?.client??this.client).get({url:"/global/config",...t})}update(t,r){let n=p([t],[{args:[{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/global/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Ut=class extends y{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,r){let n=p([t],[{args:[{in:"body",key:"target"}]}]);return(r?.client??this.client).post({url:"/global/upgrade",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_config;get config(){return this._config??=new Mt({client:this.client})}},Ot=class extends y{subscribe(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).sse.get({url:"/event",...r,...n})}},Lt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}providers(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config/providers",...r,...n})}},Ft=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return(r?.client??this.client).get({url:"/experimental/tool",...r,...n})}ids(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/tool/ids",...r,...n})}},Gt=class extends y{remove(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeRemoveInput",map:"body"}]}]);return(r?.client??this.client).delete({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/worktree",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeCreateInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reset(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeResetInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree/reset",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Bt=class extends y{text(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"pattern"}]}]);return(r?.client??this.client).get({url:"/find",...r,...n})}files(t,r){let n=p([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(r?.client??this.client).get({url:"/find/file",...r,...n})}symbols(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"}]}]);return(r?.client??this.client).get({url:"/find/symbol",...r,...n})}},Kt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file",...r,...n})}read(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file/content",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/file/status",...r,...n})}},Nt=class extends y{dispose(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/instance/dispose",...r,...n})}},Ht=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/path",...r,...n})}},Wt=class extends y{raw(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/diff/raw",...r,...n})}},Vt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/status",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"mode"},{in:"query",key:"context"}]}]);return(r?.client??this.client).get({url:"/vcs/diff",...r,...n})}apply(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"patch"}]}]);return(r?.client??this.client).post({url:"/vcs/apply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_diff;get diff2(){return this._diff??=new Wt({client:this.client})}},zt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/command",...r,...n})}},Jt=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/lsp",...r,...n})}},Xt=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/formatter",...r,...n})}},Qt=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/mcp/{name}/auth",...r,...n})}start(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth",...r,...n})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}authenticate(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...r,...n})}},Yt=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/mcp",...r,...n})}add(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return(r?.client??this.client).post({url:"/mcp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/connect",...r,...n})}disconnect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/disconnect",...r,...n})}_auth;get auth(){return this._auth??=new Qt({client:this.client})}},Zt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project",...r,...n})}current(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/current",...r,...n})}initGit(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/project/git/init",...r,...n})}update(t,r){let n=p([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(r?.client??this.client).patch({url:"/project/{projectID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}directories(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/{projectID}/directories",...r,...n})}},er=class extends y{shells(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/shells",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}/connect",...r,...n})}},tr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"answers"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reject",...r,...n})}},rr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}respond(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"response"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},nr=class extends y{authorize(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"inputs"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},sr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider",...r,...n})}auth(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider/auth",...r,...n})}_oauth;get oauth(){return this._oauth??=new nr({client:this.client})}},ir=class extends y{list(t,r){let n=p([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(r?.client??this.client).get({url:"/session",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/status",...r,...n})}delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}",...r,...n})}update(t,r){let n=p([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(r?.client??this.client).patch({url:"/session/{sessionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}children(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/children",...r,...n})}todo(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/todo",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"messageID"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/diff",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"before"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message",...r,...n})}prompt(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/message",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}deleteMessage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}",...r,...n})}message(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...r,...n})}fork(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/fork",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}abort(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/abort",...r,...n})}init(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/init",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unshare(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/share",...r,...n})}share(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/share",...r,...n})}summarize(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/summarize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}promptAsync(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}command(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}shell(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/shell",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}revert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/revert",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unrevert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/unrevert",...r,...n})}},or=class extends y{delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n})}update(t,r){let n=p([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(r?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},ar=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/sync/history",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},cr=class extends y{start(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/sync/start",...r,...n})}replay(t,r){let n=p([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(r?.client??this.client).post({url:"/sync/replay",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}steal(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/sync/steal",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_history;get history(){return this._history??=new ar({client:this.client})}},lr=class extends y{next(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/tui/control/next",...r,...n})}response(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/control/response",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},ur=class extends y{appendPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"text"}]}]);return(r?.client??this.client).post({url:"/tui/append-prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}openHelp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-help",...r,...n})}openSessions(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-sessions",...r,...n})}openThemes(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-themes",...r,...n})}openModels(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-models",...r,...n})}submitPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/submit-prompt",...r,...n})}clearPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/clear-prompt",...r,...n})}executeCommand(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"}]}]);return(r?.client??this.client).post({url:"/tui/execute-command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}showToast(t,r){let n=p([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(r?.client??this.client).post({url:"/tui/show-toast",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}publish(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/publish",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}selectSession(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/tui/select-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_control;get control(){return this._control??=new lr({client:this.client})}},pr=class extends y{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},dr=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/location",...r,...n})}},gr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/agent",...r,...n})}},mr=class extends y{stage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"messageID"},{in:"body",key:"files"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/stage",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}clear(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/clear",...r,...n})}commit(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/commit",...r,...n})}},fr=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},yr=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{key:"questionV2Reply",map:"body"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reject",...r,...n})}},hr=class extends y{list(t,r){let n=p([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(r?.client??this.client).get({url:"/api/session",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"body",key:"id"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}",...r,...n})}switchAgent(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"agent"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/agent",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}switchModel(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"model"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/model",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}prompt(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"prompt"},{in:"body",key:"delivery"},{in:"body",key:"resume"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}compact(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/compact",...r,...n})}wait(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/wait",...r,...n})}context(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/context",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"cursor"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/message",...r,...n})}_revert;get revert(){return this._revert??=new mr({client:this.client})}_permission;get permission(){return this._permission??=new fr({client:this.client})}_question;get question(){return this._question??=new yr({client:this.client})}},br=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/model",...r,...n})}},xr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider/{providerID}",...r,...n})}},kr=class extends y{key(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"key"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/key",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}oauth(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"methodID"},{in:"body",key:"inputs"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/oauth",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Pr=class extends y{cancel(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/integration/attempt/{attemptID}",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/attempt/{attemptID}",...r,...n})}complete(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/api/integration/attempt/{attemptID}/complete",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},wr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/{integrationID}",...r,...n})}_connect;get connect(){return this._connect??=new kr({client:this.client})}_attempt;get attempt(){return this._attempt??=new Pr({client:this.client})}},_r=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/credential/{credentialID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"},{in:"body",key:"label"}]}]);return(r?.client??this.client).patch({url:"/api/credential/{credentialID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Sr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/permission/request",...r,...n})}},vr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"projectID"}]}]);return(r?.client??this.client).get({url:"/api/permission/saved",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"}]}]);return(r?.client??this.client).delete({url:"/api/permission/saved/{id}",...r,...n})}},Cr=class extends y{_request;get request(){return this._request??=new Sr({client:this.client})}_saved;get saved(){return this._saved??=new vr({client:this.client})}},Rr=class extends y{read(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/fs/read/*",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/api/fs/list",...r,...n})}find(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"query"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/api/fs/find",...r,...n})}},Tr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/command",...r,...n})}},Ir=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/skill",...r,...n})}},jr=class extends y{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},Ar=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/api/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/api/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([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(r?.client??this.client).get({url:"/api/pty/{ptyID}/connect",...r,...n})}},Er=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/question/request",...r,...n})}},$r=class extends y{_request;get request(){return this._request??=new Er({client:this.client})}},qr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/reference",...r,...n})}},Dr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"directory"},{in:"body",key:"force"}]}]);return(r?.client??this.client).delete({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}create(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"strategy"},{in:"body",key:"directory"},{in:"body",key:"name"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}refresh(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/refresh",...r,...n})}},Mr=class extends y{_health;get health(){return this._health??=new pr({client:this.client})}_location;get location(){return this._location??=new dr({client:this.client})}_agent;get agent(){return this._agent??=new gr({client:this.client})}_session;get session(){return this._session??=new hr({client:this.client})}_model;get model(){return this._model??=new br({client:this.client})}_provider;get provider(){return this._provider??=new xr({client:this.client})}_integration;get integration(){return this._integration??=new wr({client:this.client})}_credential;get credential(){return this._credential??=new _r({client:this.client})}_permission;get permission(){return this._permission??=new Cr({client:this.client})}_fs;get fs(){return this._fs??=new Rr({client:this.client})}_command;get command(){return this._command??=new Tr({client:this.client})}_skill;get skill(){return this._skill??=new Ir({client:this.client})}_event;get event(){return this._event??=new jr({client:this.client})}_pty;get pty(){return this._pty??=new Ar({client:this.client})}_question;get question(){return this._question??=new $r({client:this.client})}_reference;get reference(){return this._reference??=new qr({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Dr({client:this.client})}},Ne=class e extends y{static __registry=new St;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new vt({client:this.client})}_app;get app(){return this._app??=new Ct({client:this.client})}_experimental;get experimental(){return this._experimental??=new Dt({client:this.client})}_global;get global(){return this._global??=new Ut({client:this.client})}_event;get event(){return this._event??=new Ot({client:this.client})}_config;get config(){return this._config??=new Lt({client:this.client})}_tool;get tool(){return this._tool??=new Ft({client:this.client})}_worktree;get worktree(){return this._worktree??=new Gt({client:this.client})}_find;get find(){return this._find??=new Bt({client:this.client})}_file;get file(){return this._file??=new Kt({client:this.client})}_instance;get instance(){return this._instance??=new Nt({client:this.client})}_path;get path(){return this._path??=new Ht({client:this.client})}_vcs;get vcs(){return this._vcs??=new Vt({client:this.client})}_command;get command(){return this._command??=new zt({client:this.client})}_lsp;get lsp(){return this._lsp??=new Jt({client:this.client})}_formatter;get formatter(){return this._formatter??=new Xt({client:this.client})}_mcp;get mcp(){return this._mcp??=new Yt({client:this.client})}_project;get project(){return this._project??=new Zt({client:this.client})}_pty;get pty(){return this._pty??=new er({client:this.client})}_question;get question(){return this._question??=new tr({client:this.client})}_permission;get permission(){return this._permission??=new rr({client:this.client})}_provider;get provider(){return this._provider??=new sr({client:this.client})}_session;get session(){return this._session??=new ir({client:this.client})}_part;get part(){return this._part??=new or({client:this.client})}_sync;get sync(){return this._sync??=new cr({client:this.client})}_tui;get tui(){return this._tui??=new ur({client:this.client})}_v2;get v2(){return this._v2??=new Mr({client:this.client})}};function En(e,t,r,n){if(!n?.throwOnError||e instanceof Error)return e;if(typeof e=="object"&&e!==null&&Object.keys(e).length>0){let c=e,u=typeof c.data?.message=="string"&&c.data.message||typeof c.message=="string"&&c.message||typeof c.name=="string"&&c.name||An(r,t);return new Error(u,{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 ${An(r,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function An(e,t){let r=e?.method??"?",n=e?.url??"?",s=t?.status,c=t?.statusText;return`${r} ${n}${s?" \u2192 "+s:""}${c?" "+c:""}`}function el(e,t,r){if(e)return t&&(e===t||r&&e===r(t))?t:e}function tl(e,t){if(e.method!=="GET"&&e.method!=="HEAD")return e;let r=new URL(e.url),n=!1;for(let[c,u]of[["x-opencode-directory","directory"],["x-opencode-workspace","workspace"]]){let d=el(e.headers.get(c),u==="directory"?t.directory:t.workspace,u==="directory"?encodeURIComponent:void 0);if(d){for(let g of r.pathname.startsWith("/api/")?[u,`location[${u}]`]:[u])r.searchParams.has(g)||r.searchParams.set(g,d);n=!0}}if(!n)return e;let s=new Request(r,e);return s.headers.delete("x-opencode-directory"),s.headers.delete("x-opencode-workspace"),s}function Ur(e){e?.fetch||(e={...e,fetch:n=>(n.timeout=!1,fetch(n))}),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=xe(e);return t.interceptors.request.use(r=>tl(r,{directory:e?.directory,workspace:e?.experimental_workspaceID})),t.interceptors.response.use(r=>{if(r.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 r}),t.interceptors.error.use(En),new Ne({client:t})}function rl(e){return new Promise(t=>setTimeout(t,e))}async function $n(e,t,r){let n=Math.max(1,t?.attempts??1),s=t?.baseDelayMs??0,c=t?.invalidateBetweenAttempts??!1,u=null;for(let d=0;d<n;d++)if(d>0&&(c&&r?.(),s>0&&await rl(s)),u=await e(),u)return u;return u}var nl=3e4;function sl(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function qn(e,t,r=nl){let n=e instanceof Request?e.signal:t?.signal;if(sl(e))return n??void 0;let s=AbortSignal.timeout(r);return n?typeof AbortSignal.any=="function"?AbortSignal.any([n,s]):n:s}function Or(e,t,r){let n=new Headers(e instanceof Request?e.headers:void 0);return t?.headers&&new Headers(t.headers).forEach((s,c)=>{n.set(c,s)}),r&&!n.has("Authorization")&&n.set("Authorization",`Bearer ${r}`),n}function Dn(){return new Response(JSON.stringify({error:"Not authenticated"}),{status:401,headers:{"Content-Type":"application/json"}})}async function Lr(){return I().getToken()}async function ke(e){return $n(()=>I().getToken(),e,He)}function He(){}function Cd(e){}function Rd(e){}async function We(){return Lr()}async function Mn(e){return ke(e)}function Un(e,t,r,n){if(e instanceof Request){let s=new Request(e,{headers:r,...n?{signal:n}:{}});return fetch(s)}return fetch(e,{...t,headers:r,...n?{signal:n}:{}})}async function R(e,t,r){let{retryOnAuthError:n=!0}=r??{},s=await Mn();if(!s)return Dn();let c=Or(e,t,s),u=qn(e,t),d=await Un(e,t,c,u);if(d.status===401&&n&&s){He();let g=await Mn({attempts:2,baseDelayMs:200});if(g&&g!==s){let h=Or(e,t,g);return Un(e,t,h,u)}}return d}var ie={url:null,sandboxId:null,dbSandboxId:null,version:0},il=new Set;function On(e,t=null,r=null){if(!(ie.url===e&&ie.sandboxId===t&&ie.dbSandboxId===r)){ie={url:e,sandboxId:t,dbSandboxId:r,version:ie.version+1};for(let n of il)n()}}function Ln(){return ie.url}function ol(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function Pe(){return ol(I().backendUrl||"http://localhost:8008/v1")}function Fn(){let e=I().sandboxId||"";return`${Pe()}/p/${e}/8000`}function al(e){return`${Pe()}/p/${e}/8000`}function Ve(e){return al(e)}function $(){let e=Ln();return e||(I().billingEnabled??!1?"":Fn())}var C=class extends Error{status;code;details;data;detail;response;url;endpoint;timeout;constructor(t,r={}){super(t),this.name="ApiError";let{name:n,stack:s,...c}=r;Object.assign(this,c),n&&(this.name=n),s&&(this.stack=s);let u=typeof t=="string"?t:t==null?"":String(t);Object.defineProperty(this,"message",{value:u,enumerable:!0,writable:!0,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype)}},we=class extends C{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},oe=class e extends Error{status;detail;constructor(t,r,n){super(n||r.message||`Billing Error: ${t}`),this.name="BillingError",this.status=t,this.detail=r,Object.setPrototypeOf(this,e.prototype)}},_e=class e extends Error{status;detail;constructor(t=431,r,n){let s="Request headers are too large",c="Try uploading files one at a time, or reduce the number of files in a single request.";super(n||r?.message||s),this.name="RequestTooLargeError",this.status=t,this.detail={message:r?.message||s,suggestion:r?.suggestion||c},Object.setPrototypeOf(this,e.prototype)}};function Se(e){let t=e.response?.status||e.status;if(t!==402)return e;let r=e.response?.data||e.data||e.detail||{},n=r?.detail||r;return new oe(t,{message:n?.message||e.message||"Billing error",...n})}function cl(e){return e instanceof oe}function ll(e){if(!(e instanceof oe))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."}}async function Fr(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function Gr(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function Gn(e){let t=Gr(e),r=await R(`${t}/env`);if(!r.ok)throw new Error(await Fr(r,"Failed to load secrets"));return(await r.json()).secrets??{}}async function Bn(e,t,r){let n=Gr(e),s=await R(`${n}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!s.ok)throw new Error(await Fr(s,"Failed to save secret"))}async function Kn(e,t){let r=Gr(e),n=await R(`${r}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await Fr(n,"Failed to delete secret"))}var ul={list:Gn,set:Bn,delete:Kn};async function pl(e,t,r){let n=e;for(;n.endsWith("/");)n=n.slice(0,-1);let s=await R(`${n}/kortix/triggers${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}}),c=await s.json();if(!s.ok)throw new Error(c?.error||c?.message||`Request failed with ${s.status}`);return c}function ae(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return t===e.length?e:e.slice(0,t)}async function ze(e,t){let r=await e.json().catch(()=>({}));return r?.error||r?.message||e.statusText||t}function ve(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return ae(e)}async function Nn(e){let t=ve(e),r=await R(`${t}/kortix/pty`);if(!r.ok)throw new Error(await ze(r,"Failed to list terminals"));return r.json()}async function Hn(e,t){let r=ve(e),n=await R(`${r}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!n.ok)throw new Error(await ze(n,"Failed to create terminal"));return n.json()}async function Wn(e,t,r){let n=ve(e),s=await R(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await ze(s,"Failed to update terminal"));return s.json()}async function Vn(e,t){let r=ve(e),n=await R(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await ze(n,"Failed to remove terminal"))}async function zn(e,t){let r=ve(t),s=`${(()=>{try{let d=new URL(r);return d.protocol==="https:"?d.protocol="wss:":d.protocol==="http:"&&(d.protocol="ws:"),typeof window<"u"&&window.location.protocol==="https:"&&d.protocol==="ws:"&&(d.protocol="wss:"),ae(d.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,c=await We();if(!c)return s;let u=s.includes("?")?"&":"?";return`${s}${u}token=${encodeURIComponent(c)}`}var dl={list:Nn,create:Hn,update:Wn,remove:Vn,webSocketUrl:zn};async function b(e,t,r,n){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let c=await R(`${s}${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}},n),u=await c.text(),d={};try{d=u?JSON.parse(u):{}}catch{d={}}if(!c.ok)throw new Error(d?.error||d?.message||d?.details||u.slice(0,200)||`Request failed with ${c.status}`);return d}async function zd(e,t={}){let r=new URLSearchParams;t.projectId&&r.set("project_id",t.projectId),t.status&&r.set("status",t.status);let n=r.toString()?`?${r}`:"";return b(e,`/kortix/tasks${n}`)}async function Jd(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function Xd(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function Qd(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function Yd(e,t){return b(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function Zd(e,t,r){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function eg(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function tg(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function rg(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function ng(e,t){let r=t?`?project_id=${encodeURIComponent(t)}`:"";return b(e,`/kortix/tickets${r}`)}async function sg(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function ig(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function og(e,t){return b(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function ag(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function cg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(r)})}async function lg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(r)})}async function ug(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(r)})}async function pg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(r)})}async function dg(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function gg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function mg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:r})})}async function fg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function yg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:r})})}async function hg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function bg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:r})})}async function xg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function kg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function Pg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(r)})}async function wg(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function _g(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Sg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}/persona`)}async function vg(e,t,r=200){return b(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${r}`)}async function Cg(e){return b(e,"/kortix/projects")}async function Rg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function Tg(e,t){return b(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function Ig(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function jg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Ag(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function Eg(e,t,r="all"){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${r}`)}async function $g(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`)}async function qg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/events`)}async function Dg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(r)})}async function Mg(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function Ug(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/close`,{method:"POST",body:JSON.stringify(n)})}async function Og(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/reopen`,{method:"POST"})}async function Lg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Fg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function Gg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}/events`)}async function Bg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(r)})}async function Kg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`)}async function Ng(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`,{method:"DELETE"})}var gl=1e4,ml={retryOnAuthError:!1};function ce(e,t,r){return b(e,t,{signal:AbortSignal.timeout(gl),...r},ml)}async function Hg(e,t=!1){return(await ce(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function Wg(e){return(await ce(e,"/kortix/services/templates")).templates??[]}async function Vg(e,t){return(await ce(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function zg(e,t,r){let n=r==="delete",s=n?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${r}`;return ce(e,s,{method:n?"DELETE":"POST"})}async function Jg(e,t){return ce(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function Xg(e,t){return ce(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var Je=new Map,Br=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function Z(){let e=$();if(!e)throw new Br;return le(e)}function le(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=Je.get(e);if(t)return t;if(!xt())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let r=Ur({baseUrl:e,fetch:R});return Je.set(e,r),r}function nm(e){Je.delete(e)}function sm(){Je.clear()}var Xe=new Map;function im(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=Xe.get(e);if(t)return t;let r=Ur({baseUrl:e,fetch});return Xe.set(e,r),r}function om(e){Xe.delete(e)}function am(){Xe.clear()}async function fl(e){let t=await e.text().catch(()=>"");try{let r=JSON.parse(t);return r?.error||r?.message||t||e.statusText||`HTTP ${e.status}`}catch{return t||e.statusText||`HTTP ${e.status}`}}async function cm(e){let t=$();if(!t)throw new C("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading",{code:"RUNTIME_UNAVAILABLE"});let r=await R(`${t}/kortix/services/system/reload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e})});if(!r.ok)throw new C(`System reload failed (${r.status}): ${await fl(r)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});return r.json()}function Xn(e){if(e.error){let t=e.error,r=t?.data?.message||t?.message||(typeof t?.error=="string"?t.error:null)||"SDK request failed";throw new C(r,{status:t?.response?.status??t?.status,response:t?.response,details:t})}return e.data}async function ue(e){let t=await e.text().catch(()=>""),r=null;try{r=JSON.parse(t)}catch{}return r?.error||t||e.statusText||`HTTP ${e.status}`}async function Qe(e,t=$()){let r=await R(`${t}${e}`);if(!r.ok)throw new C(await ue(r),{status:r.status,response:r});return r.json()}var Qn=["/workspace","/tmp","/home","/opt"],yl=Qn.filter(e=>e!=="/workspace");function hl(e){return Qn.some(t=>e===t||e.startsWith(`${t}/`))}function bl(e){return hl(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function Re(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(yl.some(r=>t===r||t.startsWith(`${r}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var xl=Re;async function Kr(e,t=$()){let r=Re(e)||".";return(await Qe(`/file?path=${encodeURIComponent(r)}`,t)).map(s=>({...s,path:s.absolute||`/workspace/${s.path}`}))}async function Ye(e,t=$()){let r=Re(e),n=await R(`${t}/file/content?path=${encodeURIComponent(r)}`);if(!n.ok)throw new C(await ue(n),{status:n.status,response:n});return n.json()}async function kl(e,t,r=$()){let n=Re(e),s=await R(`${r}/file/raw?path=${encodeURIComponent(n)}`);if(!s.ok)throw new C(await ue(s),{status:s.status,response:s});if((s.headers.get("content-type")||"").includes("text/html"))throw new C("File could not be loaded (raw byte route unavailable)",{status:s.status,response:s,code:"INVALID_CONTENT_TYPE"});let c=await s.blob();return t&&(!c.type||c.type==="application/octet-stream")?new Blob([c],{type:t}):c}async function Ze(e,t=$()){try{return await kl(e,void 0,t)}catch{}let r=await Ye(e,t);if(r.encoding==="base64"&&r.content){let n=Uint8Array.from(atob(r.content),s=>s.charCodeAt(0));return new Blob([n],{type:r.mimeType||"application/octet-stream"})}return new Blob([r.content??""],{type:r.mimeType||"text/plain;charset=utf-8"})}function Nr(e=$()){return Qe("/file/status",e)}async function Hr(e,t,r=$()){let n=new URLSearchParams({query:e});return t?.type&&n.set("type",t.type),t?.limit&&n.set("limit",String(t.limit)),Qe(`/find/file?${n.toString()}`,r)}async function Wr(e,t=$()){return(await Qe(`/find?pattern=${encodeURIComponent(e)}`,t)).map(n=>({path:typeof n.path=="string"?n.path:n.path?.text??"",lines:typeof n.lines=="string"?n.lines:n.lines?.text??"",line_number:n.line_number,absolute_offset:n.absolute_offset,submatches:(n.submatches??[]).map(s=>({start:s.start,end:s.end}))}))}var Ce=[400,1200],Pl=e=>e===408||e===429||e===502||e===503||e===504,Jn=e=>new Promise(t=>setTimeout(t,e));async function wl(e){let t=await e.text().catch(()=>""),r=null;try{r=t?JSON.parse(t):null}catch{}let n=r?.error||r?.message||r?.data?.message;return typeof n=="string"&&n.trim()?n.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 Yn(e,t){let r;for(let s=0;s<=Ce.length;s++){let c;try{c=await t(e())}catch(d){if(r=d,s===Ce.length)break;await Jn(Ce[s]);continue}if(c.ok)return c.json();let u=await wl(c);if(r=new C(`Upload failed (${c.status}): ${u}`,{status:c.status,response:c}),!Pl(c.status)||s===Ce.length)throw r;await Jn(Ce[s])}if(r instanceof C)throw r;let n=r instanceof Error?r.message:String(r||"request failed");throw new C(`Upload failed: ${n}`)}function et(e,t,r,n=$()){return Yn(()=>{let s=new FormData,c=(t??"").trim();return c&&s.append("path",c.startsWith("/")?c:`/${c}`),r?s.append("file",e,r):s.append("file",e),s},s=>R(`${n}/file/upload`,{method:"POST",body:s}))}function _l(e,t,r=$()){return Yn(()=>{let n=new FormData;return n.append(e,t,e.split("/").pop()||"file"),n},async n=>{let s={},c=await We();return c&&(s.Authorization=`Bearer ${c}`),fetch(`${r}/file/upload`,{method:"POST",body:n,headers:s})})}function Vr(e,t=$()){let r=e.trim(),s=(r.startsWith("/")?r:`/${r}`).split("/"),c=s.pop()||"untitled",u=s.join("/")||"/workspace";return et(new File([" "],c,{type:"application/octet-stream"}),u,void 0,t)}async function zr(e,t,r=$()){return _l(t,await Ze(e,r),r)}async function Jr(e,t=$()){let r=await R(`${t}/file`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new C(`Delete failed (${r.status}): ${await ue(r)}`,{status:r.status,response:r});return r.json()}async function Xr(e,t=$()){let r=await R(`${t}/file/mkdir`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new C(`Mkdir failed (${r.status}): ${await ue(r)}`,{status:r.status,response:r});return r.json()}async function Qr(e,t,r=$()){let n=await R(`${r}/file/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:e,to:t})});if(!n.ok)throw new C(`Rename failed (${n.status}): ${await ue(n)}`,{status:n.status,response:n});return n.json()}async function Sl(){return Xn(await Z().project.current())}async function Zn(){return Xn(await Z().global.health())}async function vl(){try{return(await Zn()).healthy===!0}catch{return!1}}var Cl={list:Kr,read:Ye,readBlob:Ze,status:Nr,findFiles:Hr,findText:Wr,upload:et,create:Vr,copy:zr,remove:Jr,mkdir:Xr,rename:Qr,currentProject:Sl,health:Zn,isReachable:vl,toDaemonPath:Re,toSandboxAbsolutePath:bl,toWorkspaceRelative:xl};var z=()=>I().backendUrl||"",Tl=e=>new Promise(t=>setTimeout(t,e)),Il=new Set([502,503,504]),es=e=>Il.has(e),jl=e=>{let t=(e??"GET").toUpperCase();return t==="GET"||t==="HEAD"},Al=2,Yr=!1;function Pm(e){Yr=e}function wm(){return Yr}async function ee(e,t={}){let{showErrors:r=!0,errorContext:n,timeout:s=3e4,...c}=t,u=new AbortController,d=null,g=!1,h=!1;try{d=setTimeout(()=>{!g&&!u.signal.aborted&&(g=!0,h=!0,u.abort())},s);let m=await ke(),x=c.body instanceof FormData,w={};if(x||(w["Content-Type"]="application/json"),Object.assign(w,c.headers),Yr&&(w["x-kortix-admin-bypass"]="1"),m)w.Authorization=`Bearer ${m}`;else return{error:new we,success:!1};let k=await fetch(e,{...c,headers:w,signal:u.signal,credentials:c.credentials??"omit"});if(d&&(clearTimeout(d),d=null),!k.ok&&jl(c.method)&&es(k.status))for(let P=0;P<Al;P++){try{await k.arrayBuffer()}catch{}await Tl(250*2**P);let _=new AbortController,D=setTimeout(()=>{_.abort()},s);try{k=await fetch(e,{...c,headers:w,signal:_.signal,credentials:c.credentials??"omit"})}catch{break}finally{D&&(clearTimeout(D),D=null)}if(k.ok||!es(k.status))break}if(!k.ok){let P=`HTTP ${k.status}: ${k.statusText}`,_=null;try{_=await k.json(),typeof _.message=="string"?P=_.message:_.error&&typeof _.error=="string"?P=_.error:typeof _.detail=="string"?P=_.detail:typeof _.detail?.message=="string"&&(P=_.detail.message)}catch{}let D=new C(P,{status:k.status,response:k,details:_||void 0,data:_,detail:_?.detail,code:_?.code||_?.error_code||_?.detail?.error_code||k.status.toString()});if(k.status===402&&(D=Se(D)),k.status===403&&_?.code==="account_mfa_required"&&typeof window<"u"&&typeof window.dispatchEvent=="function")try{window.dispatchEvent(new CustomEvent("kortix:mfa-required"))}catch{}return k.status===431&&(D=new _e(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."})),r&&I().onError?.(D,n),{error:D,success:!1}}let l,i=k.headers.get("content-type");return i?.includes("application/json")?l=await k.json():i?.includes("text/")?l=await k.text():l=await k.blob(),{data:l,success:!0}}catch(m){d&&(clearTimeout(d),d=null);let x=m?.name==="AbortError"||m?.name==="AbortSignal"||m instanceof Error&&m.message.includes("aborted");x&&(g=!0);let w;if(x){if(!h)return{error:new C("Request aborted",{name:"AbortError",code:"ABORTED"}),success:!1};let k=e.replace(z(),"")||e;w=new C(`Request timed out after ${Math.round(s/1e3)}s: ${k}`,{code:"TIMEOUT",url:e,endpoint:k,timeout:s}),r&&I().onError?.(w,n)}else m instanceof Error?(w=new C(m.message,{name:m.name||"ApiError",stack:m.stack}),r&&I().onError?.(w,n)):(w=new C(String(m)),r&&I().onError?.(w,n));return{error:w,success:!1}}}var _m={async execute(e,t){try{let{data:r,error:n}=await e();if(n){let s=new C(n.message||"Database error",{code:n.code,details:n});return I().onError?.(s,t),{error:s,success:!1}}return{data:r,success:!0}}catch(r){let n=r instanceof Error?new C(r.message,{name:r.name||"ApiError",stack:r.stack}):new C(String(r));return I().onError?.(n,t),{error:n,success:!1}}}},o={get:(e,t)=>ee(`${z()}${e}`,{...t,method:"GET"}),post:(e,t,r)=>ee(`${z()}${e}`,{...r,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,r)=>ee(`${z()}${e}`,{...r,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,r)=>ee(`${z()}${e}`,{...r,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>ee(`${z()}${e}`,{...t,method:"DELETE"}),upload:(e,t,r)=>{let{headers:n,...s}=r||{},c={...n};return delete c["Content-Type"],ee(`${z()}${e}`,{...s,method:"POST",body:t,headers:c})},uploadPut:(e,t,r)=>{let{headers:n,...s}=r||{},c={...n};return delete c["Content-Type"],ee(`${z()}${e}`,{...s,method:"PUT",body:t,headers:c})}};function a(e,t="Project request failed"){if(!e.success||e.data===void 0)throw e.error??new Error(t);return e.data}function Zr(e){return e.replace(/\/v1\/?$/,"")}async function pe(e,t){if(!e.backendUrl||!e.accessToken)return null;let r=Zr(e.backendUrl);try{let n=await fetch(`${r}${t}`,{headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(e.timeoutMs??8e3)});return n.ok?await n.json():null}catch{return null}}async function ts(){return a(await o.get("/accounts"))}async function rs(e){return a(await o.post("/accounts",e))}async function ns(e){return a(await o.get(`/accounts/${e}`))}async function ss(e,t){return a(await o.patch(`/accounts/${e}`,{name:t}))}async function is(e){return a(await o.get(`/accounts/${e}/members`))}async function os(e,t){return a(await o.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function as(e){return a(await o.get(`/accounts/${e}/invites`))}async function cs(e,t){return a(await o.delete(`/accounts/${e}/invites/${t}`))}async function ls(e,t){return a(await o.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function us(e){return a(await o.get(`/account-invites/${e}`,{showErrors:!1}))}async function ps(e){return a(await o.post(`/account-invites/${e}/accept`,{}))}async function ds(e){return a(await o.post(`/account-invites/${e}/decline`,{}))}async function gs(e,t){return a(await o.delete(`/accounts/${e}/members/${t}`))}async function ms(e,t,r){return a(await o.patch(`/accounts/${e}/members/${t}`,{role:r}))}async function fs(e){return a(await o.post(`/accounts/${e}/leave`,{}))}async function Tm(e){return pe(e,"/v1/accounts")}async function ys(){let e=await o.get("/accounts/me",{showErrors:!1});return!e.success||!e.data?{valid:!1,error:e.error}:{valid:!0,identity:e.data}}async function de(){return a(await o.get("/projects"))}async function hs(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/projects${t}`))}async function en(e,t){return a(await o.get(`/projects/${e}`,t))}async function bs(e,t,r="write"){return a(await o.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:r}))}async function xs(e,t){return a(await o.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function ks(e){return a(await o.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function Em(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function tn(e,t){return a(await o.get(`/projects/${e}/detail`,{showErrors:!1,...t}))}async function rn(e,t){return a(await o.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function nn(e,t){return a(await o.get(`/projects/${e}/model-picker`,{showErrors:!1,...t}))}async function Ps(e){return a(await o.post("/projects",e))}async function ws(e){return a(await o.post("/projects/create-repo",e))}async function _s(e){return a(await o.post("/projects/provision",{seed_starter:!0,...e}))}async function $m(){try{return a(await o.get("/projects/managed-git/status",{showErrors:!1}))}catch{return{configured:!1,provider:"github"}}}async function sn(e,t){return a(await o.patch(`/projects/${e}`,t))}async function Ss(e,t,r){return a(await o.patch(`/projects/${e}/experimental`,{feature:t,enabled:r}))}async function vs(e,t){return a(await o.patch(`/projects/${e}/sandbox-provider`,{provider:t}))}async function qm(e,t){return a(await o.patch(`/projects/${e}/warm-pool`,t))}async function Cs(e,t){return a(await o.patch(`/projects/${e}/onboarding`,{completed:t}))}async function on(e){return a(await o.delete(`/projects/${e}`))}async function Dm(e,t){return pe(e,`/v1/projects?account_id=${encodeURIComponent(t)}`)}async function Mm(e,t){if(!e.backendUrl||!e.accessToken)return{ok:!1,limitReached:!1};let r=Zr(e.backendUrl);try{let n=await fetch(`${r}/v1/projects/provision`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({seed_starter:!0,...t}),signal:AbortSignal.timeout(e.timeoutMs??9e4)});if(n.ok){let s=await n.json().catch(()=>null);return s?.project_id?{ok:!0,project:s}:{ok:!1,limitReached:!1}}return n.status===403?{ok:!1,limitReached:(await n.json().catch(()=>null))?.code==="project_limit_reached"}:{ok:!1,limitReached:!1}}catch{return{ok:!1,limitReached:!1}}}async function Rs(e){return a(await o.post("/projects/link-repository",e,{showErrors:!1}))}async function Ts(e){return a(await o.get(`/projects/github/installation?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function Is(e){return a(await o.get(`/projects/github/installations?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function js(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.get(`/projects/github/repositories?${r.toString()}`,{showErrors:!1}))}async function As(e,t,r){let n=new URLSearchParams({account_id:e,installation_id:t,repo_full_name:r});return a(await o.get(`/projects/github/repository-branches?${n.toString()}`,{showErrors:!1}))}async function Es(e){return a(await o.post("/projects/github/installation",e,{showErrors:!1}))}async function $s(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.delete(`/projects/github/installation?${r.toString()}`))}async function Km(e,t){return a(await o.post(`/projects/${e}/access-requests`,{message:t?.trim()||void 0},{showErrors:!1}))}async function qs(e,t){return a(await o.get(`/projects/${e}/access-requests`,t))}async function Ds(e,t,r="member"){return a(await o.post(`/projects/${e}/access-requests/${t}/approve`,{role:r}))}async function Ms(e,t){return a(await o.post(`/projects/${e}/access-requests/${t}/reject`,{}))}async function Us(e){return a(await o.get(`/projects/${e}/access`))}async function Os(e,t,r){return a(await o.put(`/projects/${e}/access/${t}`,{role:r}))}async function Ls(e,t){return a(await o.delete(`/projects/${e}/access/${t}`))}function Nm(e){return"status"in e&&e.status==="invited"}async function Fs(e,t,r,n){return a(await o.post(`/projects/${e}/access/invite`,{email:t,role:r,...n!==void 0?{expires_at:n}:{}}))}async function Gs(e){return a(await o.get(`/projects/${e}/access/pending-invites`))}async function Bs(e,t){return a(await o.delete(`/projects/${e}/access/pending-invites/${t}`))}async function Ks(e,t){return a(await o.post(`/projects/${e}/access/pending-invites/${t}/resend`))}async function Ns(e){return a(await o.get(`/projects/${e}/group-grants`))}async function Hs(e,t,r,n){return a(await o.post(`/projects/${e}/group-grants`,n===void 0?{group_id:t,role:r}:{group_id:t,role:r,expires_at:n}))}async function Ws(e,t,r,n){return a(await o.patch(`/projects/${e}/group-grants/${t}`,n===void 0?{role:r}:{role:r,expires_at:n}))}async function Vs(e,t){return a(await o.delete(`/projects/${e}/group-grants/${t}`))}async function zs(e){return a(await o.get(`/projects/${e}/resource-grants`))}async function Js(e,t){return a(await o.post(`/projects/${e}/resource-grants`,{resource_type:t.resourceType,resource_id:t.resourceId,principal_type:t.principalType,principal_id:t.principalId,...t.expiresAt!==void 0?{expires_at:t.expiresAt}:{}}))}async function Xs(e,t){return a(await o.delete(`/projects/${e}/resource-grants/${t}`))}async function Qs(e,t){return a(await o.get(`/projects/${e}/approvals`,{showErrors:t?.showErrors}))}async function Ys(e,t){return a(await o.get(`/projects/${e}/approvals/needs-input`,{showErrors:t?.showErrors}))}async function Zs(e,t,r,n="once"){return a(await o.post(`/projects/${e}/approvals/${t}`,{decision:r,scope:n}))}async function ei(e){return a(await o.get(`/projects/${e}/secrets`,{showErrors:!1}))}async function ti(e,t){return a(await o.post(`/projects/${e}/secrets`,t))}async function ri(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/start`,{sharing:r?.sharing}))}async function ni(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/poll`,{flow_id:r}))}async function si(e,t){return a(await o.put(`/projects/${e}/git-credential`,t))}async function ii(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}`))}async function oi(e,t,r){return a(await o.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`,r))}async function ai(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`))}async function ci(e){return a(await o.get(`/projects/${e}/connector-profiles`))}async function li(e,t){return a(await o.post(`/projects/${e}/connector-profiles`,t))}async function ui(e,t,r){return a(await o.put(`/projects/${e}/connector-profiles/${t}/credential`,r))}async function pi(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/revoke`,{}))}async function di(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/activate`,{}))}async function gi(e){return a(await o.get(`/executor/projects/${e}/connectors`,{showErrors:!1}))}async function mi(e){return a(await o.post(`/executor/projects/${e}/connectors/sync`,{}))}async function fi(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential-mode`,{mode:r}))}async function yi(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/sensitive`,{sensitive:r}))}async function hi(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`))}async function bi(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`,{policies:r}))}async function xi(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/config`))}async function ki(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/name`,{name:r}))}async function Pi(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect`,{}))}async function wi(e,t){return a(await o.post(`/executor/projects/${e}/connectors`,t))}async function _i(e,t){return a(await o.delete(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}`))}async function Si(e,t,r){let n=new URLSearchParams;t&&n.set("q",t),r&&n.set("cursor",r);let s=n.toString();return a(await o.get(`/executor/projects/${e}/pipedream/apps${s?`?${s}`:""}`))}async function vi(){return a(await o.get("/executor/connect-status"))}async function Ci(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential`,{value:r}))}async function Ri(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect/finalize`,{}))}async function Ti(e){return a(await o.get(`/executor/projects/${e}/policies`))}async function Ii(e,t,r){return a(await o.put(`/executor/projects/${e}/policies`,{policies:t,defaultMode:r}))}async function ji(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function Ai(e){return a(await o.get(`/projects/${e}/snapshots`))}async function an(e){return a(await o.get(`/projects/${e}/sandbox-health`,{showErrors:!1,timeout:15e3}))}async function Ei(e,t){return a(await o.post(`/projects/${e}/snapshots/rebuild`,t?{slug:t}:{}))}async function $i(e){return a(await o.post(`/projects/${e}/snapshots/fix-with-agent`,{}))}async function qi(e,t){return a(await o.post(`/projects/${e}/sandbox-templates`,t))}async function Di(e,t,r){return a(await o.patch(`/projects/${e}/sandbox-templates/${t}`,r))}async function Mi(e,t){return a(await o.delete(`/projects/${e}/sandbox-templates/${t}`))}async function Ui(e,t){return a(await o.post(`/projects/${e}/sandbox-templates/${t}/build`,{}))}async function Oi(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function Li(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path);let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/files${n}`,{showErrors:!1}))}async function Fi(e,t,r){let n=new URLSearchParams({q:t});return r?.content&&n.set("content","1"),r?.ref&&n.set("ref",r.ref),r?.limit&&n.set("limit",String(r.limit)),a(await o.get(`/projects/${e}/files/search?${n.toString()}`))}async function Gi(e,t,r){let n=new URLSearchParams({path:t});return r&&n.set("ref",r),a(await o.get(`/projects/${e}/files/content?${n.toString()}`))}async function Bi(e,t,r){let n=new URLSearchParams;t&&n.set("ref",t),r&&n.set("path",r);let s=n.toString()?`?${n.toString()}`:"",c=await ke(),u=`${I().backendUrl||""}/projects/${e}/files/archive${s}`,d=await fetch(u,{method:"GET",headers:c?{Authorization:`Bearer ${c}`}:{}});if(!d.ok){let g=await d.text().catch(()=>"");throw new Error(g||`Failed to download (HTTP ${d.status})`)}return await d.blob()}async function Ki(e){return a(await o.get(`/projects/${e}/branches`))}async function Ni(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path),t?.limit!=null&&r.set("limit",String(t.limit)),t?.skip!=null&&r.set("skip",String(t.skip));let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/commits${n}`))}async function Hi(e,t){return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}`))}async function Wi(e,t,r){let n=new URLSearchParams;r?.path&&n.set("path",r.path);let s=n.toString()?`?${n.toString()}`:"";return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}/diff${s}`))}async function Vi(e,t,r){let n=new URLSearchParams({path:t});return r?.ref&&n.set("ref",r.ref),r?.limit!=null&&n.set("limit",String(r.limit)),r?.skip!=null&&n.set("skip",String(r.skip)),a(await o.get(`/projects/${e}/files/history?${n.toString()}`))}async function zi(e,t){let r=new URLSearchParams({from:t.from,into:t.into});return a(await o.get(`/projects/${e}/version-diff?${r.toString()}`))}async function Ji(e,t){let r=t?`?status=${t}`:"";return a(await o.get(`/projects/${e}/change-requests${r}`,{showErrors:!1,timeout:15e3}))}async function Xi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}`))}async function Qi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/diff`))}async function Yi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/merge-preview`))}async function Zi(e,t){return a(await o.post(`/projects/${e}/change-requests`,t))}async function eo(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/merge`,r??{},{showErrors:!1}))}async function to(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/close`,{}))}async function ro(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/reopen`,{}))}async function no(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/request-changes`,{feedback:r}))}async function so(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/commit-push`,r??{}))}var cn=new Set;function io(e){e&&cn.add(e)}function oo(e){return!!e&&cn.has(e)}function yf(e){e&&cn.delete(e)}async function Te(e){return a(await o.get(`/projects/${e}/sessions`))}async function ao(e,t,r){return a(await o.put(`/projects/${e}/sessions/${t}/sharing`,r))}async function co(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/previews`))}async function lo(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/public-shares`,{showErrors:!1}))}async function uo(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/public-shares`,r))}async function po(e,t,r){return a(await o.delete(`/projects/${e}/sessions/${t}/public-shares/${r}`))}async function Ie(e,t){let r=a(await o.post(`/projects/${e}/sessions`,t??{}));return t?.initial_prompt||io(r?.session_id),r}async function go(e,t,r){return a(await o.get(`/projects/${e}/sessions/${t}`,{showErrors:r?.showErrors}))}async function mo(e,t,r,n){let s=r?`?limit=${r}`:"";return a(await o.get(`/projects/${e}/sessions/${t}/audit${s}`,{showErrors:n?.showErrors}))}async function fo(e,t,r){let n=new URLSearchParams;r?.limit!=null&&n.set("limit",String(r.limit)),r?.chars!=null&&n.set("chars",String(r.chars));let s=n.toString();return a(await o.get(`/projects/${e}/sessions/${t}/transcript${s?`?${s}`:""}`))}async function yo(e,t,r){return a(await o.patch(`/projects/${e}/sessions/${t}`,r))}async function ho(e,t){return a(await o.delete(`/projects/${e}/sessions/${t}`))}async function tt(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/restart`,{}))}async function rt(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/stop`,{}))}async function bo(e){return a(await o.get(`/projects/${e}/triggers`))}async function xo(e,t){return a(await o.post(`/projects/${e}/triggers`,t))}async function ko(e,t,r){return a(await o.patch(`/projects/${e}/triggers/${t}`,r))}async function Po(e,t){return a(await o.delete(`/projects/${e}/triggers/${t}`))}async function wo(e,t){return a(await o.patch(`/projects/${e}/triggers/activation`,{paused:t}))}async function _o(e,t){return a(await o.post(`/projects/${e}/triggers/${t}/fire`,{}))}var J=new Map;function ln(e,t){return`${e}::${t}`}function So(e,t){J.delete(e),J.set(e,t)}function vo(e,t){let r=ln(e,t),n=J.get(r);return n&&So(r,n),n}function Co(e,t,r){let n=ln(e,t);if(!J.has(n)&&J.size>=512){let s=J.keys().next().value;s!==void 0&&J.delete(s)}So(n,r)}function Ro(e,t){J.delete(ln(e,t))}var un=class extends Error{status;code;terminal;constructor(t,r){super(t),this.name="SessionStartError",this.status=r.status,this.code=r.code,this.terminal=r.terminal}};function jf(e){return e instanceof Error&&e.name==="SessionStartError"}function El(e){let t=e,r=t?.status,n=t?.code??t?.details?.code??t?.details?.error,s=t?.message||"Unable to start this session";return r&&r>=400&&r<500&&r!==408&&r!==429?new un(s,{status:r,code:n,terminal:!0}):null}async function je(e,t,r){let n=r&&r>0?`?wait_ms=${Math.floor(r)}`:"",s=await o.post(`/projects/${e}/sessions/${t}/start${n}`,{},{showErrors:!1});if(!s.success||!s.data){let d=El(s.error);if(d&&!(d.status===404&&oo(t)))throw d;return null}let c=s.data,u=c.sandbox?.external_id;return c.stage==="ready"&&u&&c.opencode_session_id&&Co(e,t,{opencodeSessionId:c.opencode_session_id,runtimeUrl:Ve(u),sandboxId:u}),c}function Af(e,t){return["session-start",e,t]}async function To(e){return a(await o.get(`/projects/${e}/model-defaults`))}async function Io(e,t){return a(await o.put(`/projects/${e}/model-defaults`,t))}async function jo(e,t){let r=new URLSearchParams({scope:t.scope,...t.agentName?{agentName:t.agentName}:{}}).toString();return a(await o.delete(`/projects/${e}/model-defaults?${r}`))}async function Ao(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/scope`,r))}async function Gf(e,t){return a(await o.get(`/projects/${e}/agents/${encodeURIComponent(t)}/config`))}async function Bf(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/config`,r))}async function Eo(e,t){return a(await o.put(`/projects/${e}/default-agent`,{agent:t}))}function $o(){return{credits:{total:0,daily:0,monthly:0,extra:0,can_run:!1,daily_refresh:null},subscription:{tier_key:"none",tier_display_name:"No Plan",status:"no_subscription",billing_period:null,provider:"stripe",subscription_id:null,current_period_end:null,cancel_at_period_end:!1,is_cancelled:!1,cancellation_effective_date:null,has_scheduled_change:!1,scheduled_change:null,commitment:{has_commitment:!1,can_cancel:!0,commitment_type:null,months_remaining:null,commitment_end_date:null},can_purchase_credits:!1},models:[],limits:{concurrent_runs:{running_count:0,limit:0,can_start:!1,tier_name:"none"},ai_worker_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"},custom_mcp_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"}},tier:{name:"none",display_name:"No Plan",monthly_credits:0,can_purchase_credits:!1}}}async function qo(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state${n}`,{showErrors:!1}),c=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!c)throw s.error;return s.error?$o():s.data}async function Do(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state/minimal${n}`,{showErrors:!1}),c=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!c)throw s.error;return s.error?$o():s.data}async function Mo(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.limit!=null&&t.set("limit",String(e.limit)),e?.offset!=null&&t.set("offset",String(e.offset)),e?.typeFilter&&t.set("type_filter",Array.isArray(e.typeFilter)?e.typeFilter.join(","):e.typeFilter);let r=t.toString();return a(await o.get(`/billing/transactions${r?`?${r}`:""}`))}async function Uo(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.days!=null&&t.set("days",String(e.days));let r=t.toString();return a(await o.get(`/billing/transactions/summary${r?`?${r}`:""}`))}async function Oo(){return a(await o.get("/billing/credit-breakdown"))}async function Lo(e){let t=e!=null?`?days=${e}`:"";return a(await o.get(`/billing/usage-history${t}`))}async function Fo(){return a(await o.get("/billing/tier-configurations"))}async function Wf(e){let t=e.accountId?`?account_id=${encodeURIComponent(e.accountId)}`:"";return pe(e,`/v1/billing/account-state${t}`)}async function Go(e){return a(await o.post("/billing/create-checkout-session",{account_id:e.accountId,tier_key:e.tierKey,success_url:e.successUrl,cancel_url:e.cancelUrl,commitment_type:e.commitmentType,locale:e.locale,server_type:e.serverType,location:e.location}),"Failed to create checkout session")}async function Bo(e,t){return a(await o.post("/billing/confirm-checkout-session",{account_id:t,session_id:e}),"Failed to confirm checkout session")}async function Ko(e,t){return a(await o.post("/billing/create-portal-session",{account_id:t,return_url:e}),"Failed to create portal session")}async function No(e,t){return a(await o.post("/billing/cancel-subscription",{account_id:t,feedback:e}),"Failed to cancel subscription")}async function Ho(e){return a(await o.post("/billing/reactivate-subscription",{account_id:e}),"Failed to reactivate subscription")}async function Wo(e,t,r){return a(await o.post("/billing/schedule-downgrade",{account_id:r,target_tier_key:e,commitment_type:t}),"Failed to schedule downgrade")}async function Vo(e){return a(await o.post("/billing/cancel-scheduled-change",{account_id:e}),"Failed to cancel scheduled change")}async function zo(e,t){let r=new URLSearchParams({new_price_id:e});return t&&r.set("account_id",t),a(await o.get(`/billing/proration-preview?${r.toString()}`),"Failed to load proration preview")}async function Jo(e){return a(await o.post("/billing/purchase-credits",{amount:e.amount,account_id:e.accountId,success_url:e.successUrl,cancel_url:e.cancelUrl}),"Failed to purchase credits")}async function Xo(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/billing/auto-topup/settings${t}`),"Failed to load auto-topup settings")}async function Qo(e){return a(await o.post("/billing/auto-topup/configure",{account_id:e.accountId,enabled:e.enabled,threshold:e.threshold,amount:e.amount}),"Failed to configure auto-topup")}async function Yo(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});return t.success?t.data??null:null}async function Zo(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/connect`,t,{showErrors:!1}),"Failed to connect")}var $l={oauth_available:!1,install_url:null};async function ea(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/mode`,{showErrors:!1});return!t.success||!t.data?$l:t.data}async function ta(e){return a(await o.get(`/webhooks/slack/${encodeURIComponent(e)}/manifest`,{showErrors:!1}),"Failed to load Slack manifest")}async function ra(e){let t=await o.delete(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});if(!t.success)throw new Error(t.error?.message??"Failed to disconnect")}async function na(e,t){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/file?url=${encodeURIComponent(t)}`,{showErrors:!1}),"Failed to download Slack file")}async function sa(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/file/upload`,{channel:t.channel,filename:t.filename,content_base64:t.contentBase64,comment:t.comment,thread_ts:t.threadTs},{showErrors:!1}),"Failed to upload Slack file")}function pn(e){return{...e,profileId:e.profileId??e.profile_id??null}}var ql={provider:"agentmail",managed_available:!1};async function ia(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});return n.success&&n.data?pn(n.data):null}async function oa(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/mode`,{showErrors:!1});return!t.success||!t.data?ql:t.data}async function aa(e,t){let r=a(await o.post(`/projects/${encodeURIComponent(e)}/channels/email/connect`,t,{showErrors:!1}),"Failed to connect email");return pn(r)}async function ca(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.delete(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});if(!n.success)throw new Error(n.error?.message??"Failed to disconnect email")}async function la(e,t,r){let n=a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/email/installation`,{connector_slug:t??"kortix_email",sender_policy:r},{showErrors:!1}),"Failed to update email policy");return pn(n)}async function ua(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/meet/voices`,{showErrors:!1});return t.success?t.data??null:null}async function pa(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/voice`,{voice:t},{showErrors:!1}),"Failed to save voice")}async function da(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/name`,{name:t},{showErrors:!1}),"Failed to save name")}async function ga(e,t){let r=await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/voices/${encodeURIComponent(t)}/preview`,{},{showErrors:!1});return!r.success||!r.data?.b64?null:r.data.b64}async function Xf(e){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/bindings`,{showErrors:!1}),"Failed to load channel bindings")}async function Qf(e,t,r){return a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/bindings/${encodeURIComponent(t)}`,r,{showErrors:!1}),"Failed to update channel binding")}async function ma(e,t,r,n){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/speak`,{bot_id:t,text:r,voice:n},{showErrors:!1}),"Failed to speak in meeting")}async function fa(e){return a(await o.get(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function ya(e,t){return a(await o.put(`/projects/${e}/gateway/routing-policy`,t),"Gateway routing policy request failed")}async function ha(e){return a(await o.delete(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function ba(e,t){return a(await o.post(`/projects/${e}/gateway/routing-policy/preview`,t),"Gateway route preview failed")}async function xa(e,t){let r=new URLSearchParams;t?.limit&&r.set("limit",String(t.limit)),t?.offset&&r.set("offset",String(t.offset)),t?.ok!==void 0&&r.set("ok",String(t.ok));let n=r.toString();return a(await o.get(`/projects/${e}/gateway/logs${n?`?${n}`:""}`),"Gateway request failed")}async function ka(e,t){return a(await o.get(`/projects/${e}/gateway/logs/${t}`),"Gateway request failed")}async function Pa(e,t){return a(await o.get(`/projects/${e}/gateway/overview${t?`?days=${t}`:""}`),"Gateway request failed")}async function wa(e,t){return a(await o.get(`/projects/${e}/gateway/series${t?`?days=${t}`:""}`),"Gateway request failed")}async function _a(e,t){return a(await o.get(`/projects/${e}/gateway/breakdown${t?`?days=${t}`:""}`),"Gateway request failed")}async function Sa(e,t){return a(await o.get(`/projects/${e}/gateway/sessions${t?`?days=${t}`:""}`),"Gateway request failed")}async function va(e,t){return a(await o.get(`/projects/${e}/gateway/errors${t?`?days=${t}`:""}`),"Gateway request failed")}async function Ca(e){return a(await o.get(`/projects/${e}/gateway/budgets`),"Gateway request failed")}async function Ra(e,t){return a(await o.put(`/projects/${e}/gateway/budgets`,t),"Gateway request failed")}async function Ta(e,t){return a(await o.delete(`/projects/${e}/gateway/budgets/${t}`),"Gateway request failed")}async function Ia(e){return a(await o.get(`/projects/${e}/gateway/keys`),"Gateway request failed")}async function ja(e,t){return a(await o.post(`/projects/${e}/gateway/keys`,{name:t}),"Gateway request failed")}async function Aa(e,t){return a(await o.delete(`/projects/${e}/gateway/keys/${t}`),"Gateway request failed")}async function Ea(e,t,r){return a(await o.post(`/projects/${e}/gateway/playground`,{prompt:t,models:r}),"Gateway request failed")}async function $a(e){let t=new FormData;t.append("audio_file",e);let r=await o.upload("/transcription",t,{showErrors:!0});if(r.error)throw new Error(`Error transcribing audio: ${r.error.message} (${r.error.status})`);return r.data}async function qa(e,t){let r=new URLSearchParams;t?.segment&&r.set("segment",t.segment),t?.kind&&r.set("kind",t.kind);let n=r.toString();return a(await o.get(`/projects/${e}/review/items${n?`?${n}`:""}`,{showErrors:!1}))}async function Da(e,t){return a(await o.get(`/projects/${e}/review/items/${t}`))}async function Ma(e,t){return a(await o.post(`/projects/${e}/review/items`,t))}async function Ua(e,t,r){return a(await o.post(`/projects/${e}/review/items/${t}/act`,r))}async function Oa(e,t){return a(await o.post(`/projects/${e}/review/bulk`,t))}async function La(e){return a(await o.get(`/p/share?sandbox_id=${encodeURIComponent(e)}`),"Failed to load public links").shares??[]}async function Fa(e){return a(await o.post("/p/share",{sandbox_id:e.sandboxId,port:e.port,ttl:e.ttl,label:e.label}),"Failed to generate public URL")}async function Ga(e,t){let r=await o.delete(`/p/share/${encodeURIComponent(t)}?sandbox_id=${encodeURIComponent(e)}`);if(!r.success)throw new Error(r.error?.message??"Failed to revoke public link")}var dn=class extends Error{constructor(r,n){super(r);this.status=n;this.name="PublicSessionShareError"}status};function Ba(e,t=""){return`${Pe()}/public/session-shares/${encodeURIComponent(e)}${t}`}async function Ka(e){let t=await fetch(e,{method:"GET",headers:{Accept:"application/json"}}),r=await t.text().catch(()=>""),n=null;try{n=r?JSON.parse(r):null}catch{}if(!t.ok){let s=(n&&typeof n=="object"&&"error"in n&&typeof n.error=="string"?n.error:null)||t.statusText||`HTTP ${t.status}`;throw new dn(s,t.status)}return n}async function py(e){return Ka(Ba(e))}async function dy(e){return Ka(Ba(e,"/messages"))}async function Na(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/accounts/tokens${t}`))}async function Ha(e){let{accountId:t,expiresAt:r,projectId:n,name:s}=e;return a(await o.post("/accounts/tokens",{name:s,...t?{account_id:t}:{},...r?{expires_at:r}:{},...n?{project_id:n}:{}}))}async function Wa(e,t){let r=t?`?account_id=${encodeURIComponent(t)}`:"";return a(await o.delete(`/accounts/tokens/${e}${r}`))}async function Va(e){return a(await o.get(`/projects/${e}/cli-token`))}async function za(e,t){return a(await o.post(`/projects/${e}/cli-token`,t??{}))}async function Ja(e,t){return a(await o.delete(`/projects/${e}/cli-token/${t}`))}async function Xa(e,t){let r=new URLSearchParams;t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since),t?.cursor&&r.set("cursor",t.cursor),t?.limit!=null&&r.set("limit",String(t.limit));let n=r.toString();return a(await o.get(`/accounts/${e}/audit${n?`?${n}`:""}`))}async function Qa(e,t){let r=new URLSearchParams;t?.format&&r.set("format",t.format),t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since);let n=r.toString();return a(await o.get(`/accounts/${e}/audit/export${n?`?${n}`:""}`))}async function Ya(e){return a(await o.get(`/accounts/${e}/audit/webhooks`))}async function Za(e,t){return a(await o.post(`/accounts/${e}/audit/webhooks`,t))}async function ec(e,t,r){return a(await o.patch(`/accounts/${e}/audit/webhooks/${t}`,r))}async function tc(e,t){return a(await o.delete(`/accounts/${e}/audit/webhooks/${t}`))}async function rc(e,t){return a(await o.post(`/projects/${e}/secret-requests`,{names:t.names,labels:t.labels,descriptions:t.descriptions,scope:t.scope,expires_in_minutes:t.expiresInMinutes}),"Failed to mint secret-entry link")}async function nc(e,t){return a(await o.post(`/projects/${e}/connect-requests`,{slug:t.slug,expires_in_minutes:t.expiresInMinutes}),"Failed to mint connect link")}async function sc(e){let t=new URLSearchParams;e?.query&&t.set("query",e.query),e?.type&&t.set("type",e.type),e?.source&&t.set("source",e.source);let r=t.toString()?`?${t.toString()}`:"";return a(await o.get(`/marketplace/items${r}`))}async function ic(){return a(await o.get("/marketplace/marketplaces"))}async function oc(){return a(await o.get("/marketplace/marketplaces/featured"))}async function ac(e){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}`),"Item not found")}async function cc(e,t){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),"File not found")}async function lc(){return a(await o.get("/marketplace/sources"))}async function uc(e){return a(await o.post("/marketplace/sources",e),"Failed to add marketplace source")}async function pc(e){return a(await o.delete(`/marketplace/sources/${encodeURIComponent(e)}`),"Failed to remove marketplace source")}async function Ty(e){return a(await o.get(`/templates/${encodeURIComponent(e)}`))}async function Iy(e,t){return a(await o.post(`/templates/${encodeURIComponent(e)}/install`,t))}function $y(e){return e?e.runtimeReady!==void 0?e.runtimeReady===!0:e.opencode!==void 0?e.opencode==="ok"||e.opencode===!0:e.status!=="starting"&&e.status!=="down"&&e.status!=="error":!1}async function dc(e,t){let r=(e===void 0?$():e)||null;if(!r)return{status:0,ok:!1,health:null,body:""};let n=await R(`${r}/kortix/health`,{method:"GET",...t},{retryOnAuthError:!1}),s=await n.text().catch(()=>""),c=null;try{c=s?JSON.parse(s):null}catch{c=null}return{status:n.status,ok:n.ok,health:c,body:s}}var X={DESKTOP:"6080",DESKTOP_HTTPS:"6081",PRESENTATION_VIEWER:"3210",STATIC_FILE_SERVER:"3211",KORTIX_MASTER:"8000",BROWSER_STREAM:"9223",BROWSER_VIEWER:"9224",SSH:"22"};var gc=/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s)"'<>]*/g,mc=/^https?:\/\/p(\d+)-([^.]+)\.localhost(?::(\d+))?(\/.*)?$/,fc=new Set([22,4096,parseInt(X.KORTIX_MASTER,10)]);function Dl(e){return mc.test(e)}function nt(e){if(!e)return"/";let t=e,r=t.indexOf("](");r!==-1&&(t=t.slice(0,r));let n=t.toLowerCase().indexOf("%5d(");return n!==-1&&(t=t.slice(0,n)),t?t.startsWith("/")?t:`/${t}`:"/"}function Ml(e){let t=e.indexOf("](");return t===-1?e:e.slice(0,t)}var Ul=new Set(["'",'"',"`","<","(","["]),Ol=new Set([">","'",'"',"`",")","]",",",";",".","!","?"]);function Ll(e){let t=0,r=e.length;for(;t<r&&(e[t]===" "||e[t]===" ");)t++;for(;r>t&&(e[r-1]===" "||e[r-1]===" ");)r--;for(;t<r&&Ul.has(e[t]);)t++;for(;r>t&&Ol.has(e[r-1]);)r--;return e.slice(t,r)}function Fl(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s"'<>)]*/i)?.[0]??null}var Gl=/^\/proxy\/(\d{1,5})(\/.*)?$/,Bl=/^\/(connectors|settings|dashboard|projects|agents|skills|tools|commands|support|changelog|files|p|browser|desktop|terminal|sessions|services|workspace|channels|scheduled-tasks|marketplace|templates|tunnel|admin|auth)(\/|$|\?)/;function Kl(e){if(!e)return!1;try{let t=new URL(e);return t.hostname!=="localhost"&&t.hostname!=="127.0.0.1"?!1:Bl.test(t.pathname)}catch{return!1}}function st(e){if(!e)return null;let t=Ll(Ml(e.trim())),r=bc(t);if(r){let n=nt(r.path||"/");return{originalUrl:`http://localhost:${r.port}${n}`,port:r.port,path:n}}try{let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.hostname!=="localhost"&&n.hostname!=="127.0.0.1"||!n.port)return null;let s=parseInt(n.port,10);if(!Number.isInteger(s)||s<1||s>65535)return null;let c=`${n.pathname||"/"}${n.search}${n.hash}`,u=parseInt(X.KORTIX_MASTER,10);if(s===u){let g=n.pathname.match(Gl);if(g){let h=parseInt(g[1],10);if(h>=1&&h<=65535)return s=h,c=nt(`${g[2]||"/"}${n.search}${n.hash}`),{originalUrl:`http://localhost:${s}${c}`,port:s,path:c}}}let d=nt(c);return{originalUrl:`${n.protocol}//${n.hostname}:${s}${d}`,port:s,path:d}}catch{let n=Fl(e);return n&&n!==e?st(n):null}}function Nl(e){let t=[],r=/```[\s\S]*?```/g,n;for(;(n=r.exec(e))!==null;)t.push([n.index,n.index+n[0].length]);let s=/`[^`\n]+`/g;for(;(n=s.exec(e))!==null;){let c=n.index,u=c+n[0].length;t.some(([g,h])=>c>=g&&u<=h)||t.push([c,u])}return t}function Hl(e,t){return t.some(([r,n])=>e>=r&&e<n)}function Wl(e){let t=[],r=new Set,n=Nl(e);gc.lastIndex=0;let s;for(;(s=gc.exec(e))!==null;){let c=st(s[0]);if(!c)continue;let{originalUrl:u,port:d,path:g}=c;d<1||d>65535||fc.has(d)||r.has(u)||(r.add(u),t.push({originalUrl:u,port:d,path:g,startIndex:s.index,endIndex:s.index+u.length,inCodeBlock:Hl(s.index,n)}))}return t}function Uy(e){return Wl(e).length>0}function Vl(e){try{let{hostname:t}=new URL(e);return t==="localhost"||t==="127.0.0.1"}catch{return!1}}function Ee(e,t,r){let n=nt(t);if(!Vl(r.apiBaseUrl)){let s=r.apiBaseUrl.length;for(;s>0&&r.apiBaseUrl.charCodeAt(s-1)===47;)s--;return`${r.apiBaseUrl.slice(0,s)}/p/${r.sandboxId}/${e}${n}`}return`http://p${e}-${r.sandboxId}.localhost:${r.backendPort}${n}`}function Oy(e,t){return Ee(e,"/",t)}function zl(e){let t=st(e);return!(!t||fc.has(t.port)||Kl(e))}function yc(e,t){if(!e)return e;let r=st(e);return r?zl(r.originalUrl)?Ee(r.port,r.path,t):r.originalUrl:e}function Ly(e,t="/"){return`http://localhost:${e}${t}`}var hc=/^https?:\/\/[^/]+\/v1\/p\/([^/]+)\/(\d+)(\/.*)?$/;function bc(e){let t=e.match(mc);if(t)return{port:parseInt(t[1],10),sandboxId:t[2],backendPort:t[3]?parseInt(t[3],10):80,path:t[4]||"/"};let r=e.match(hc);if(r)try{let n=new URL(e);return{port:parseInt(r[2],10),sandboxId:r[1],backendPort:parseInt(n.port,10)||(n.protocol==="https:"?443:80),path:r[3]||"/"}}catch{return null}return null}function Fy(e){try{let t=bc(e);return t?`http://localhost:${t.port}${t.path}`:null}catch{return null}}function Gy(e){return Dl(e)||hc.test(e)}var Ae="/web-proxy/";function By(e,t){try{let r=new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")return null;let n=r.protocol.replace(":",""),s=`${Ae}${n}/${r.host}${r.pathname}${r.search}${r.hash}`,c=parseInt(X.KORTIX_MASTER,10);return`${Ee(c,"/",t).replace(/\/$/,"")}${s}`}catch{return null}}function Ky(e){try{let t=new URL(e),r=t.pathname.indexOf(Ae);if(r===-1)return null;let s=t.pathname.slice(r+Ae.length).match(/^(https?)\/([\w.\-]+(?::\d+)?)(\/.*)?$/);if(!s)return null;let c=s[1],u=s[2],d=s[3]||"/";return`${c}://${u}${d}${t.search}${t.hash}`}catch{return null}}function Ny(e){try{return new URL(e).pathname.includes(Ae)}catch{return e.includes(Ae)}}function Hy(e){if(!e)return!1;let t=e.trim();return!!(/^https?:\/\/(?!localhost|127\.0\.0\.1)/i.test(t)||/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t))}function Wy(e){let t=e.trim();return t?/^https?:\/\//i.test(t)?t:/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t)?`https://${t}`:null:null}var xc="frontend";function it(e,t,r){(e==="error"?console.error:e==="warn"?console.warn:e==="debug"?console.debug:console.log)(`[${xc}] ${t}`,...r?[r]:[]);try{Z().app.log({service:xc,level:e,message:t,extra:r})}catch{}}var Q={debug:(e,t)=>it("debug",e,t),info:(e,t)=>it("info",e,t),warn:(e,t)=>it("warn",e,t),error:(e,t)=>it("error",e,t)};function Jl(e){return{type:"heartbeat-gap",gapMs:e}}function Xl(e){switch(e.type){case"message.updated":return{type:"message.updated",sessionID:e.properties.sessionID,message:e.properties.info};case"message.removed":return{type:"message.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID};case"message.part.updated":return{type:"message.part.updated",sessionID:e.properties.sessionID,part:e.properties.part};case"message.part.removed":return{type:"message.part.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID,partID:e.properties.partID};case"session.status":return{type:"session.status",sessionID:e.properties.sessionID,status:e.properties.status};case"session.idle":return{type:"session.idle",sessionID:e.properties.sessionID};case"session.error":return{type:"session.error",sessionID:e.properties.sessionID,error:e.properties.error};case"question.asked":return{type:"question.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,questions:e.properties.questions,tool:e.properties.tool};case"question.replied":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"replied",answers:e.properties.answers};case"question.rejected":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"rejected"};case"permission.asked":return{type:"permission.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,permission:e.properties.permission,patterns:e.properties.patterns,tool:e.properties.tool};case"permission.replied":return{type:"permission.replied",sessionID:e.properties.sessionID,requestID:e.properties.requestID,reply:e.properties.reply};case"todo.updated":return{type:"todo.updated",sessionID:e.properties.sessionID,todos:e.properties.todos};case"server.connected":return{type:"connection",status:"connected"};default:return null}}var Ql={now:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},Yl=16,Zl=8,eu=6e4,tu=5e3,ru=250,nu=1e3,su=3e4,iu=5,ou=3e3,au=3e4,cu=2e4,lu=2e3,uu=8;function pu(e){if(e.type==="session.status")return`session.status:${e.properties.sessionID}`;if(e.type==="lsp.updated")return"lsp.updated"}function kc(e){if(e.aborted)return{promise:Promise.resolve(),cleanup:()=>{}};let t=()=>{};return{promise:new Promise(n=>{t=()=>n(),e.addEventListener("abort",t,{once:!0})}),cleanup:()=>e.removeEventListener("abort",t)}}function gn(e){let{client:t,onEvent:r,onGapRehydrate:n,onParked:s,signal:c}=e,u=e.timers??Ql,d=e.connectTimeoutMs??cu,g=e.heartbeatTimeoutMs??eu,h=e.maxConsecutiveHardFailures??uu,m=new AbortController,x=()=>m.abort();c&&(c.aborted?m.abort():c.addEventListener("abort",x,{once:!0}));let w=u.now(),k=[],l,i=0,P=new Map,_=()=>{if(l&&u.clearTimeout(l),l=void 0,k.length===0)return;let A=k;k=[],P.clear(),i=u.now(),w=u.now();for(let v of A)if(v)try{r(v.event)}catch(T){console.warn("[opencode-events] event handler threw, skipping",T)}},D=()=>{if(l)return;let A=u.now()-i;l=u.setTimeout(_,Math.max(0,Yl-A))};return(async()=>{let A=0,v=0;for(;!m.signal.aborted;){let T=!1,j=!1,f,S,U=null,K=u.now(),M=new AbortController,O=kc(m.signal);O.promise.then(()=>M.abort());try{let F=await new Promise((ft,ye)=>{let G=!1;S=u.setTimeout(()=>{G||(G=!0,Q.warn("SSE connect timed out, forcing reconnect",{connectTimeoutMs:d}),M.abort(),ye(new Error(`SSE connect timed out after ${d}ms`)))},d),t.global.event({signal:M.signal,sseDefaultRetryDelay:ou,sseMaxRetryDelay:au,sseMaxRetryAttempts:1}).then(H=>{G||(G=!0,u.clearTimeout(S),ft(H))},H=>{G||(G=!0,u.clearTimeout(S),ye(H))})}),{stream:E}=F;w=u.now();let B=()=>{u.clearTimeout(f),f=u.setTimeout(()=>{Q.warn("SSE heartbeat timeout, forcing reconnect"),M.abort()},g)};B();let Oe=u.now(),Fc=E[Symbol.asyncIterator]();for(;!M.signal.aborted;){let ft=Fc.next().then(V=>({kind:"next",result:V}),V=>({kind:"error",error:V})),ye=kc(M.signal),G=await Promise.race([ft,ye.promise.then(()=>({kind:"aborted"}))]);if(ye.cleanup(),G.kind==="aborted")break;if(G.kind==="error")throw G.error;if(G.result.done)break;T=!0,B();let H=G.result.value,Le=H&&typeof H=="object"&&"payload"in H?H.payload:H;if(!Le?.type)continue;let yt=pu(Le);if(yt){let V=P.get(yt);V!==void 0&&(k[V]=void 0),P.set(yt,k.length)}k.push({type:Le.type,event:Le}),D(),!(u.now()-Oe<Zl)&&(Oe=u.now(),await new Promise(V=>u.setTimeout(V,0)))}j=T}catch(F){if(m.signal.aborted)break;U=F;let E=String(F),B=E.includes("401")||E.includes("403")||E.includes("Unauthorized")||E.includes("Token refresh failed");if(Q.error("SSE event stream error",{error:E,retryCount:A,isAuthError:B}),B)try{He(),await Lr(),Q.info("SSE: refreshed auth token after auth error")}catch(Oe){Q.error("SSE: failed to refresh auth token",{error:String(Oe)})}}finally{u.clearTimeout(f),u.clearTimeout(S),M.abort(),O.cleanup(),_()}if(m.signal.aborted)break;let ne=u.now()-K,Ue=U?.cause?.status;if(v=!T&&(typeof Ue=="number"&&Ue>=400||ne<lu)?v+1:0,v>=h){Q.error("SSE event stream parked \u2014 giving up after consecutive hard failures",{consecutiveFailures:v,lastError:String(U)});try{s?.({consecutiveFailures:v,lastError:U})}catch(F){console.warn("[opencode-events] onParked handler threw",F)}break}let fe=u.now()-w;fe>tu&&n?.(fe),j?A=0:(A++,A>1&&Q.warn("SSE event stream reconnecting",{retryCount:A}));let N=j?ru:Math.min(nu*2**Math.min(A-1,iu),su);await new Promise(F=>{let E=u.setTimeout(F,N),B=()=>{u.clearTimeout(E),F()};m.signal.addEventListener("abort",B,{once:!0})})}})(),{close:()=>{m.abort(),c&&c.removeEventListener("abort",x),l&&u.clearTimeout(l)}}}function du(){return Z()}var ot=new Map,at=class extends Error{constructor(t){super(`Session runtime not ready \u2014 call \`await session.ensureReady()\` (it drives \`start()\` to completion and resolves this session's own sandbox runtime) before calling \`${t}\`.`),this.name="SessionNotReadyError"}};function gu(e,t){bt(e,t);function r(l){try{return new URL(l)}catch{if(typeof window<"u"&&window.location?.origin)try{return new URL(l,window.location.origin)}catch{return null}throw new C(`Kortix SDK: backendUrl must be an absolute URL outside the browser (got ${JSON.stringify(l)}). Relative paths like "/api/kortix" only resolve against a page origin \u2014 configure an absolute backendUrl for server-side hosts.`,{code:"INVALID_BACKEND_URL"})}}function n(l){let i=I().backendUrl??e.backendUrl,P=80,_=r(i);return _&&(P=_.port?Number(_.port):_.protocol==="https:"?443:80),{sandboxId:l,backendPort:P,apiBaseUrl:i}}let s={list:ts,get:ns,create:rs,updateName:ss,leave:fs,members:is,invite:os,removeMember:gs,updateMemberRole:ms,invites:as,cancelInvite:cs,resendInvite:ls,tokens:{list:Na,create:Ha,revoke:Wa},audit:{log:Xa,export:Qa,webhooks:{list:Ya,create:Za,update:ec,remove:tc}}},c={accountState:qo,accountStateMinimal:Do,transactions:Mo,transactionsSummary:Uo,creditBreakdown:Oo,usageHistory:Lo,tierConfigurations:Fo,checkout:{createSession:l=>Go(l),confirmSession:(l,i)=>Bo(l,i)},subscription:{createPortalSession:(l,i)=>Ko(l,i),cancel:(l,i)=>No(l,i),reactivate:l=>Ho(l),scheduleDowngrade:(l,i,P)=>Wo(l,i,P),cancelScheduledChange:l=>Vo(l),prorationPreview:(l,i)=>zo(l,i)},credits:{purchase:l=>Jo(l),autoTopupSettings:l=>Xo(l),configureAutoTopup:l=>Qo(l)}},u={describe:us,accept:ps,decline:ds},d={list:de,listForAccount:hs,get:en,detail:tn,create:Ps,createRepo:ws,provision:_s,update:sn,archive:on,llmCatalog:rn,modelPicker:nn,sandboxHealth:an,sandboxTemplates:ji,sessions:Te,createSession:Ie},g={linkRepository:Rs,getInstallation:Ts,listInstallations:Is,listRepositories:js,listRepositoryBranches:As,saveInstallation:Es,deleteInstallation:$s},h={list:La,create:Fa,revoke:Ga},m=vi,x={items:l=>sc(l),item:l=>ac(l),itemFile:(l,i)=>cc(l,i),marketplaces:()=>ic(),featured:()=>oc(),sources:{list:()=>lc(),add:l=>uc(l),remove:l=>pc(l)}};function w(l){return{get:i=>en(l,i),detail:()=>tn(l),update:i=>sn(l,i),archive:()=>on(l),llmCatalog:()=>rn(l),modelPicker:()=>nn(l),sandboxHealth:()=>an(l),onboardingComplete:(...i)=>Cs(l,...i),tokens:{list:()=>Va(l),create:i=>za(l,i),revoke:i=>Ja(l,i)},setupLinks:{requestSecret:i=>rc(l,i),requestConnector:i=>nc(l,i)},validateManifest:i=>xs(l,i),gitToken:()=>ks(l),secrets:{list:()=>ei(l),upsert:i=>ti(l,i),remove:i=>ii(l,i),setPersonal:(...i)=>oi(l,...i),removePersonal:i=>ai(l,i),setGitCredential:i=>si(l,i),startProviderOAuth:(...i)=>ri(l,...i),pollProviderOAuth:(...i)=>ni(l,...i)},access:{list:()=>Us(l),invite:(...i)=>Fs(l,...i),update:(...i)=>Os(l,...i),revoke:i=>Ls(l,i),pendingInvites:()=>Gs(l),resendInvite:(...i)=>Ks(l,...i),revokeInvite:(...i)=>Bs(l,...i),requests:()=>qs(l),approveRequest:(...i)=>Ds(l,...i),rejectRequest:(...i)=>Ms(l,...i),groupGrants:()=>Ns(l),attachGroupGrant:(...i)=>Hs(l,...i),updateGroupGrant:(...i)=>Ws(l,...i),detachGroupGrant:i=>Vs(l,i),resourceGrants:{list:()=>zs(l),create:i=>Js(l,i),remove:i=>Xs(l,i)}},connectors:{list:()=>gi(l),config:(...i)=>xi(l,...i),create:(...i)=>wi(l,...i),remove:(...i)=>_i(l,...i),sync:()=>mi(l),setName:(...i)=>ki(l,...i),setCredentialMode:(...i)=>fi(l,...i),setCredential:(...i)=>Ci(l,...i),setSensitive:(...i)=>yi(l,...i),profiles:{list:()=>ci(l),reconcile:(...i)=>li(l,...i),updateCredential:(...i)=>ui(l,...i),revoke:(...i)=>pi(l,...i),activate:(...i)=>di(l,...i)},policies:{get:(...i)=>hi(l,...i),set:(...i)=>bi(l,...i)},pipedream:{listApps:(...i)=>Si(l,...i),connect:(...i)=>Pi(l,...i),finalize:(...i)=>Ri(l,...i)}},policies:{list:()=>Ti(l),set:(...i)=>Ii(l,...i)},triggers:{list:()=>bo(l),create:(...i)=>xo(l,...i),update:(...i)=>ko(l,...i),remove:(...i)=>Po(l,...i),fire:(...i)=>_o(l,...i),setActivation:(...i)=>wo(l,...i)},files:{list:i=>Li(l,i),read:(i,P)=>Gi(l,i,P),search:(...i)=>Fi(l,...i),archive:(...i)=>Bi(l,...i),history:(...i)=>Vi(l,...i)},git:{commits:()=>Ni(l),commit:i=>Hi(l,i),commitDiff:i=>Wi(l,i),branches:()=>Ki(l),versionDiff:(...i)=>zi(l,...i),inviteCollaborator:(...i)=>bs(l,...i)},changeRequests:{list:()=>Ji(l),get:i=>Xi(l,i),diff:i=>Qi(l,i),mergePreview:i=>Yi(l,i),open:(...i)=>Zi(l,...i),merge:(...i)=>eo(l,...i),close:(...i)=>to(l,...i),reopen:(...i)=>ro(l,...i),requestChanges:(...i)=>no(l,...i)},sessions:{list:()=>Te(l),create:i=>Ie(l,i)},review:{list:i=>qa(l,i),get:i=>Da(l,i),submit:i=>Ma(l,i),act:(...i)=>Ua(l,...i),bulkAct:i=>Oa(l,i)},approvals:{list:i=>Qs(l,i),resolve:(...i)=>Zs(l,...i),sessionsNeedingInput:i=>Ys(l,i)},gateway:{logs:i=>xa(l,i),log:i=>ka(l,i),overview:i=>Pa(l,i),series:i=>wa(l,i),breakdown:i=>_a(l,i),sessions:i=>Sa(l,i),errors:i=>va(l,i),budgets:()=>Ca(l),setBudget:i=>Ra(l,i),deleteBudget:i=>Ta(l,i),keys:()=>Ia(l),createKey:i=>ja(l,i),revokeKey:i=>Aa(l,i),routing:{get:()=>fa(l),set:i=>ya(l,i),reset:()=>ha(l),preview:i=>ba(l,i)},playground:(i,P)=>Ea(l,i,P)},channels:{slack:{installation:()=>Yo(l),connect:i=>Zo(l,i),mode:()=>ea(l),manifest:()=>ta(l),disconnect:()=>ra(l),getFile:i=>na(l,i),uploadFile:i=>sa(l,i)},email:{installation:i=>ia(l,i),mode:()=>oa(l),connect:i=>aa(l,i),disconnect:i=>ca(l,i),updatePolicy:(...i)=>la(l,...i)},meet:{voices:()=>ua(l),setVoice:i=>pa(l,i),setBotName:i=>da(l,i),previewVoice:i=>ga(l,i),speak:(i,P,_)=>ma(l,i,P,_)}},updateExperimentalFeature:(...i)=>Ss(l,...i),modelDefaults:{get:()=>To(l),set:i=>Io(l,i),clear:i=>jo(l,i)},setDefaultAgent:i=>Eo(l,i),sandbox:{list:()=>Oi(l),snapshots:()=>Ai(l),rebuildSnapshot:i=>Ei(l,i),fixWithAgent:()=>$i(l),createTemplate:i=>qi(l,i),updateTemplate:(...i)=>Di(l,...i),removeTemplate:i=>Mi(l,i),buildTemplate:i=>Ui(l,i),setProvider:i=>vs(l,i)},setAgentScope:(...i)=>Ao(l,...i),session:i=>k(l,i)}}function k(l,i){let P=null,_,D;function A(){if(P)return P;let f=vo(l,i);return f&&(P=f),P}async function v(){let f=A();if(f)return f;let S=`${l}
8
- ${i}`,U=ot.get(S);if(U)return P=await U,P;let K=(async()=>{let M=await je(l,i,3e4);if(!M||M.stage!=="ready"||!M.sandbox||!M.opencode_session_id)throw new C(`Session runtime not ready (stage: ${M?.stage??"unknown"})`,{code:"RUNTIME_UNAVAILABLE"});let O=M.sandbox.external_id;if(!O)throw new C("Session sandbox has no external_id \u2014 cannot resolve its runtime URL",{code:"RUNTIME_UNAVAILABLE"});let ne=Ve(O);return On(ne,O),{opencodeSessionId:M.opencode_session_id,runtimeUrl:ne,sandboxId:O}})();ot.set(S,K);try{return P=await K,P}finally{ot.get(S)===K&&ot.delete(S)}}function T(f){let S=A();if(!S)throw new at(f);return S}function j(){P=null,Ro(l,i)}return{get:f=>go(l,i,f),update:f=>yo(l,i,f),delete:()=>(j(),ho(l,i)),start:(...f)=>je(l,i,...f),restart:()=>(j(),tt(l,i)),stop:()=>(j(),rt(l,i)),setSharing:f=>ao(l,i,f),previews:()=>co(l,i),commit:f=>so(l,i,f),publicShares:{list:()=>lo(l,i),create:(...f)=>uo(l,i,...f),revoke:(...f)=>po(l,i,...f)},audit:(f,S)=>mo(l,i,f,S),transcript:f=>fo(l,i,f),ensureReady:v,health:f=>dc(A()?.runtimeUrl??null,f),previewUrl:(f,S="/")=>Ee(f,S,n(T("previewUrl").sandboxId)),proxyUrl:f=>yc(f,n(T("proxyUrl").sandboxId)),setModel:f=>{_=f},setAgent:f=>{D=f},send:async(f,S)=>{let{opencodeSessionId:U,runtimeUrl:K}=await v(),M=S?.model??_,O=S?.agent??D;return le(K).session.prompt({sessionID:U,parts:[{type:"text",text:f}],...M?{model:M}:{},...O?{agent:O}:{}})},abort:async()=>{let{opencodeSessionId:f,runtimeUrl:S}=await v();return le(S).session.abort({sessionID:f})},stream:async f=>{let{runtimeUrl:S}=await v();return gn({client:le(S),onEvent:f.onEvent,onGapRehydrate:f.onGapRehydrate,signal:f.signal})},get runtime(){return le(T("runtime").runtimeUrl)},files:{list:async f=>Kr(f,(await v()).runtimeUrl),read:async f=>Ye(f,(await v()).runtimeUrl),readBlob:async f=>Ze(f,(await v()).runtimeUrl),status:async()=>Nr((await v()).runtimeUrl),findFiles:async(f,S)=>Hr(f,S,(await v()).runtimeUrl),findText:async f=>Wr(f,(await v()).runtimeUrl),upload:async(f,S,U)=>et(f,S,U,(await v()).runtimeUrl),create:async f=>Vr(f,(await v()).runtimeUrl),copy:async(f,S)=>zr(f,S,(await v()).runtimeUrl),remove:async f=>Jr(f,(await v()).runtimeUrl),mkdir:async f=>Xr(f,(await v()).runtimeUrl),rename:async(f,S)=>Qr(f,S,(await v()).runtimeUrl)}}}return{config:e,accounts:s,accountInvites:u,projects:d,project:w,session:k,github:g,billing:c,sandboxShares:h,transcribe:$a,connectStatus:m,marketplace:x,validateToken:ys,runtime:du}}function mu(){let e=typeof crypto<"u"?crypto:void 0;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)e.getRandomValues(t);else for(let n=0;n<16;n++)t[n]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=[...t].map(n=>n.toString(16).padStart(2,"0"));return`${r[0]}${r[1]}${r[2]}${r[3]}-${r[4]}${r[5]}-${r[6]}${r[7]}-${r[8]}${r[9]}-${r.slice(10).join("")}`}var Pc={thinking:!1,toolDetails:!0,assistantMetadata:!0};function fu(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function yu(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let r=Math.floor(t/60),n=t%60;return`${r}m ${n.toFixed(0)}s`}function hu(e,t){if(e.type==="text"&&!("synthetic"in e&&e.synthetic))return`${e.text}
5
+ `);S=O.pop()??"";for(let se of O){let Le=se.split(`
6
+ `),fe=[],ye;for(let E of Le)if(E.startsWith("data:"))fe.push(E.replace(/^data:\s*/,""));else if(E.startsWith("event:"))ye=E.replace(/^event:\s*/,"");else if(E.startsWith("id:"))x=E.replace(/^id:\s*/,"");else if(E.startsWith("retry:")){let B=Number.parseInt(E.replace(/^retry:\s*/,""),10);Number.isNaN(B)||(i=B)}let N,F=!1;if(fe.length){let E=fe.join(`
7
+ `);try{N=JSON.parse(E),F=!0}catch{N=E}}F&&(s&&await s(N),n&&(N=await n(N))),r?.({data:N,event:ye,id:x,retry:i}),fe.length&&(yield N)}}}finally{_.removeEventListener("abort",U),f.releaseLock()}break}catch(A){if(t?.(A),u!==void 0&&P>=u)break;let v=Math.min(i*2**(P-1),d??3e4);await w(v)}}}()}};var Vc=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},zc=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Jc=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Ke=({allowReserved:e,explode:t,name:r,style:n,value:s})=>{if(!t){let d=(e?s:s.map(g=>encodeURIComponent(g))).join(zc(n));switch(n){case"label":return`.${d}`;case"matrix":return`;${r}=${d}`;case"simple":return d;default:return`${r}=${d}`}}let c=Vc(n),u=s.map(d=>n==="label"||n==="simple"?e?d:encodeURIComponent(d):ie({allowReserved:e,name:r,value:d})).join(c);return n==="label"||n==="matrix"?c+u:u},ie=({allowReserved:e,name:t,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},Ne=({allowReserved:e,explode:t,name:r,style:n,value:s,valueOnly:c})=>{if(s instanceof Date)return c?s.toISOString():`${r}=${s.toISOString()}`;if(n!=="deepObject"&&!t){let g=[];Object.entries(s).forEach(([m,x])=>{g=[...g,m,e?x:encodeURIComponent(x)]});let h=g.join(",");switch(n){case"form":return`${r}=${h}`;case"label":return`.${h}`;case"matrix":return`;${r}=${h}`;default:return h}}let u=Jc(n),d=Object.entries(s).map(([g,h])=>ie({allowReserved:e,name:n==="deepObject"?`${r}[${g}]`:g,value:h})).join(u);return n==="label"||n==="matrix"?u+d:d};var Xc=/\{[^{}]+\}/g,Qc=({path:e,url:t})=>{let r=t,n=t.match(Xc);if(n)for(let s of n){let c=!1,u=s.substring(1,s.length-1),d="simple";u.endsWith("*")&&(c=!0,u=u.substring(0,u.length-1)),u.startsWith(".")?(u=u.substring(1),d="label"):u.startsWith(";")&&(u=u.substring(1),d="matrix");let g=e[u];if(g==null)continue;if(Array.isArray(g)){r=r.replace(s,Ke({explode:c,name:u,style:d,value:g}));continue}if(typeof g=="object"){r=r.replace(s,Ne({explode:c,name:u,style:d,value:g,valueOnly:!0}));continue}if(d==="matrix"){r=r.replace(s,`;${ie({name:u,value:g})}`);continue}let h=encodeURIComponent(d==="label"?`.${g}`:g);r=r.replace(s,h)}return r},vn=({baseUrl:e,path:t,query:r,querySerializer:n,url:s})=>{let c=s.startsWith("/")?s:`/${s}`,u=(e??"")+c;t&&(u=Qc({path:t,url:u}));let d=r?n(r):"";return d.startsWith("?")&&(d=d.substring(1)),d&&(u+=`?${d}`),u};function Pt(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 Cn=async(e,t)=>{let r=typeof t=="function"?await t(e):t;if(r)return e.scheme==="bearer"?`Bearer ${r}`:e.scheme==="basic"?`Basic ${btoa(r)}`:r};var wt={bodySerializer:e=>JSON.stringify(e,(t,r)=>typeof r=="bigint"?r.toString():r)};var Rn=({parameters:e={},...t}={})=>n=>{let s=[];if(n&&typeof n=="object")for(let c in n){let u=n[c];if(u==null)continue;let d=e[c]||t;if(Array.isArray(u)){let g=Ke({allowReserved:d.allowReserved,explode:!0,name:c,style:"form",value:u,...d.array});g&&s.push(g)}else if(typeof u=="object"){let g=Ne({allowReserved:d.allowReserved,explode:!0,name:c,style:"deepObject",value:u,...d.object});g&&s.push(g)}else{let g=ie({allowReserved:d.allowReserved,name:c,value:u});g&&s.push(g)}}return s.join("&")},Tn=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(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},Yc=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1,In=async({security:e,...t})=>{for(let r of e){if(Yc(t,r.name))continue;let n=await Cn(r,t.auth);if(!n)continue;let s=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[s]=n;break;case"cookie":t.headers.append("Cookie",`${s}=${n}`);break;default:t.headers.set(s,n);break}}},_t=e=>vn({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Rn(e.querySerializer),url:e.url}),St=(e,t)=>{let r={...e,...t};return r.baseUrl?.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=He(e.headers,t.headers),r},Zc=e=>{let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t},He=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?Zc(r):Object.entries(r);for(let[s,c]of n)if(c===null)t.delete(s);else if(Array.isArray(c))for(let u of c)t.append(s,u);else c!==void 0&&t.set(s,typeof c=="object"?JSON.stringify(c):c)}return t},be=class{fns=[];clear(){this.fns=[]}eject(t){let r=this.getInterceptorIndex(t);this.fns[r]&&(this.fns[r]=null)}exists(t){let r=this.getInterceptorIndex(t);return!!this.fns[r]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,r){let n=this.getInterceptorIndex(t);return this.fns[n]?(this.fns[n]=r,t):!1}use(t){return this.fns.push(t),this.fns.length-1}},jn=()=>({error:new be,request:new be,response:new be}),el=Rn({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),tl={"Content-Type":"application/json"},xe=(e={})=>({...wt,headers:tl,parseAs:"auto",querySerializer:el,...e});var ke=(e={})=>{let t=St(xe(),e),r=()=>({...t}),n=h=>(t=St(t,h),r()),s=jn(),c=async h=>{let m={...t,...h,fetch:h.fetch??t.fetch??globalThis.fetch,headers:He(t.headers,h.headers),serializedBody:void 0};m.security&&await In({...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 x=_t(m);return{opts:m,url:x}},u=async h=>{let{opts:m,url:x}=await c(h),w={redirect:"follow",...m,body:Pt(m)},k=new Request(x,w);for(let T of s.request.fns)T&&(k=await T(k,m));let l=m.fetch,i;try{i=await l(k)}catch(T){let j=T;for(let f of s.error.fns)f&&(j=await f(T,void 0,k,m));if(j=j||{},m.throwOnError)throw j;return m.responseStyle==="data"?void 0:{error:j,request:k,response:void 0}}for(let T of s.response.fns)T&&(i=await T(i,k,m));let P={request:k,response:i};if(i.ok){let T=(m.parseAs==="auto"?Tn(i.headers.get("Content-Type")):m.parseAs)??"json";if(i.status===204||i.headers.get("Content-Length")==="0"){let f;switch(T){case"arrayBuffer":case"blob":case"text":f=await i[T]();break;case"formData":f=new FormData;break;case"stream":f=i.body;break;default:f={};break}return m.responseStyle==="data"?f:{data:f,...P}}let j;switch(T){case"arrayBuffer":case"blob":case"formData":case"text":j=await i[T]();break;case"json":{let f=await i.text();j=f?JSON.parse(f):{};break}case"stream":return m.responseStyle==="data"?i.body:{data:i.body,...P}}return T==="json"&&(m.responseValidator&&await m.responseValidator(j),m.responseTransformer&&(j=await m.responseTransformer(j))),m.responseStyle==="data"?j:{data:j,...P}}let _=await i.text(),D;try{D=JSON.parse(_)}catch{}let A=D??_,v=A;for(let T of s.error.fns)T&&(v=await T(A,i,k,m));if(v=v||{},m.throwOnError)throw v;return m.responseStyle==="data"?void 0:{error:v,...P}},d=h=>m=>u({...m,method:h}),g=h=>async m=>{let{opts:x,url:w}=await c(m);return Sn({...x,body:x.body,headers:x.headers,method:h,onRequest:async(k,l)=>{let i=new Request(k,l);for(let P of s.request.fns)P&&(i=await P(i,x));return i},serializedBody:Pt(x),url:w})};return{buildUrl:_t,connect:d("CONNECT"),delete:d("DELETE"),get:d("GET"),getConfig:r,head:d("HEAD"),interceptors:s,options:d("OPTIONS"),patch:d("PATCH"),post:d("POST"),put:d("PUT"),request:u,setConfig:n,sse:{connect:g("CONNECT"),delete:g("DELETE"),get:g("GET"),head:g("HEAD"),options:g("OPTIONS"),patch:g("PATCH"),post:g("POST"),put:g("PUT"),trace:g("TRACE")},trace:d("TRACE")}};var rl={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},nl=Object.entries(rl),An=(e,t)=>{t||(t=new Map);for(let r of e)"in"in r?r.key&&t.set(r.key,{in:r.in,map:r.map}):"key"in r?t.set(r.key,{map:r.map}):r.args&&An(r.args,t);return t},sl=e=>{for(let[t,r]of Object.entries(e))r&&typeof r=="object"&&!Object.keys(r).length&&delete e[t]},p=(e,t)=>{let r={body:{},headers:{},path:{},query:{}},n=An(t),s;for(let[c,u]of e.entries())if(t[c]&&(s=t[c]),!!s)if("in"in s)if(s.key){let d=n.get(s.key),g=d.map||s.key;d.in&&(r[d.in][g]=u)}else r.body=u;else for(let[d,g]of Object.entries(u??{})){let h=n.get(d);if(h)if(h.in){let m=h.map||d;r[h.in][m]=g}else r[h.map]=g;else{let m=nl.find(([x])=>d.startsWith(x));if(m){let[x,w]=m;r[w][d.slice(x.length)]=g}else if("allowExtra"in s&&s.allowExtra){for(let[x,w]of Object.entries(s.allowExtra))if(w){r[x][d]=g;break}}}}return sl(r),r};var En=ke(xe({baseUrl:"http://localhost:4096"}));var y=class{client;constructor(t){this.client=t?.client??En}},vt=class{defaultKey="default";instances=new Map;get(t){let r=this.instances.get(t??this.defaultKey);if(!r)throw new Error('No SDK client found. Create one with "new OpencodeClient()" to fix this error.');return r}set(t,r){this.instances.set(r??this.defaultKey,t)}},Ct=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"}]}]);return(r?.client??this.client).delete({url:"/auth/{providerID}",...r,...n})}set(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return(r?.client??this.client).put({url:"/auth/{providerID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Rt=class extends y{log(t,r){let n=p([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(r?.client??this.client).post({url:"/log",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}agents(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/agent",...r,...n})}skills(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/skill",...r,...n})}},Tt=class extends y{moveSession(t,r){let n=p([t],[{args:[{in:"body",key:"sessionID"},{in:"body",key:"destination"},{in:"body",key:"moveChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/control-plane/move-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},It=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/capabilities",...r,...n})}},jt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console",...r,...n})}listOrgs(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/console/orgs",...r,...n})}switchOrg(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"accountID"},{in:"body",key:"orgID"}]}]);return(r?.client??this.client).post({url:"/experimental/console/switch",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},At=class extends y{list(t,r){let n=p([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(r?.client??this.client).get({url:"/experimental/session",...r,...n})}background(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/session/{sessionID}/background",...r,...n})}},Et=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/resource",...r,...n})}},$t=class extends y{generateName(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"context"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/generate-name",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},qt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/adapter",...r,...n})}},Dt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/experimental/workspace",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}syncList(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/sync-list",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/workspace/status",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/experimental/workspace/{id}",...r,...n})}warp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"sessionID"},{in:"body",key:"copyChanges"}]}]);return(r?.client??this.client).post({url:"/experimental/workspace/warp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_adapter;get adapter(){return this._adapter??=new qt({client:this.client})}},Mt=class extends y{_controlPlane;get controlPlane(){return this._controlPlane??=new Tt({client:this.client})}_capabilities;get capabilities(){return this._capabilities??=new It({client:this.client})}_console;get console(){return this._console??=new jt({client:this.client})}_session;get session(){return this._session??=new At({client:this.client})}_resource;get resource(){return this._resource??=new Et({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new $t({client:this.client})}_workspace;get workspace(){return this._workspace??=new Dt({client:this.client})}},Ut=class extends y{get(t){return(t?.client??this.client).get({url:"/global/config",...t})}update(t,r){let n=p([t],[{args:[{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/global/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Ot=class extends y{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,r){let n=p([t],[{args:[{in:"body",key:"target"}]}]);return(r?.client??this.client).post({url:"/global/upgrade",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_config;get config(){return this._config??=new Ut({client:this.client})}},Lt=class extends y{subscribe(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).sse.get({url:"/event",...r,...n})}},Ft=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"config",map:"body"}]}]);return(r?.client??this.client).patch({url:"/config",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}providers(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/config/providers",...r,...n})}},Gt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return(r?.client??this.client).get({url:"/experimental/tool",...r,...n})}ids(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/tool/ids",...r,...n})}},Bt=class extends y{remove(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeRemoveInput",map:"body"}]}]);return(r?.client??this.client).delete({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/experimental/worktree",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeCreateInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reset(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeResetInput",map:"body"}]}]);return(r?.client??this.client).post({url:"/experimental/worktree/reset",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},Kt=class extends y{text(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"pattern"}]}]);return(r?.client??this.client).get({url:"/find",...r,...n})}files(t,r){let n=p([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(r?.client??this.client).get({url:"/find/file",...r,...n})}symbols(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"}]}]);return(r?.client??this.client).get({url:"/find/symbol",...r,...n})}},Nt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file",...r,...n})}read(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/file/content",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/file/status",...r,...n})}},Ht=class extends y{dispose(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/instance/dispose",...r,...n})}},Wt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/path",...r,...n})}},Vt=class extends y{raw(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/diff/raw",...r,...n})}},zt=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/vcs/status",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"mode"},{in:"query",key:"context"}]}]);return(r?.client??this.client).get({url:"/vcs/diff",...r,...n})}apply(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"patch"}]}]);return(r?.client??this.client).post({url:"/vcs/apply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_diff;get diff2(){return this._diff??=new Vt({client:this.client})}},Jt=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/command",...r,...n})}},Xt=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/lsp",...r,...n})}},Qt=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/formatter",...r,...n})}},Yt=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/mcp/{name}/auth",...r,...n})}start(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth",...r,...n})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}authenticate(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",...r,...n})}},Zt=class extends y{status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/mcp",...r,...n})}add(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return(r?.client??this.client).post({url:"/mcp",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/connect",...r,...n})}disconnect(t,r){let n=p([t],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/mcp/{name}/disconnect",...r,...n})}_auth;get auth(){return this._auth??=new Yt({client:this.client})}},er=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project",...r,...n})}current(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/current",...r,...n})}initGit(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/project/git/init",...r,...n})}update(t,r){let n=p([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(r?.client??this.client).patch({url:"/project/{projectID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}directories(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/project/{projectID}/directories",...r,...n})}},tr=class extends y{shells(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/shells",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(r?.client??this.client).get({url:"/pty/{ptyID}/connect",...r,...n})}},rr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"answers"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/question/{requestID}/reject",...r,...n})}},nr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}respond(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"response"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},sr=class extends y{authorize(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"inputs"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}callback(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},ir=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider",...r,...n})}auth(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/provider/auth",...r,...n})}_oauth;get oauth(){return this._oauth??=new sr({client:this.client})}},or=class extends y{list(t,r){let n=p([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(r?.client??this.client).get({url:"/session",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}status(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/status",...r,...n})}delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}",...r,...n})}update(t,r){let n=p([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(r?.client??this.client).patch({url:"/session/{sessionID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}children(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/children",...r,...n})}todo(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/todo",...r,...n})}diff(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"messageID"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/diff",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"before"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message",...r,...n})}prompt(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/message",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}deleteMessage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}",...r,...n})}message(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",...r,...n})}fork(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/fork",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}abort(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/abort",...r,...n})}init(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/init",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unshare(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/share",...r,...n})}share(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/share",...r,...n})}summarize(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/summarize",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}promptAsync(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/prompt_async",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}command(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}shell(t,r){let n=p([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(r?.client??this.client).post({url:"/session/{sessionID}/shell",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}revert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/revert",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}unrevert(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/session/{sessionID}/unrevert",...r,...n})}},ar=class extends y{delete(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n})}update(t,r){let n=p([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(r?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},cr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/sync/history",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},lr=class extends y{start(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/sync/start",...r,...n})}replay(t,r){let n=p([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(r?.client??this.client).post({url:"/sync/replay",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}steal(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/sync/steal",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_history;get history(){return this._history??=new cr({client:this.client})}},ur=class extends y{next(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).get({url:"/tui/control/next",...r,...n})}response(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/control/response",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},pr=class extends y{appendPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"text"}]}]);return(r?.client??this.client).post({url:"/tui/append-prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}openHelp(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-help",...r,...n})}openSessions(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-sessions",...r,...n})}openThemes(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-themes",...r,...n})}openModels(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/open-models",...r,...n})}submitPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/submit-prompt",...r,...n})}clearPrompt(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(r?.client??this.client).post({url:"/tui/clear-prompt",...r,...n})}executeCommand(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"}]}]);return(r?.client??this.client).post({url:"/tui/execute-command",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}showToast(t,r){let n=p([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(r?.client??this.client).post({url:"/tui/show-toast",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}publish(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(r?.client??this.client).post({url:"/tui/publish",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}selectSession(t,r){let n=p([t],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/tui/select-session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}_control;get control(){return this._control??=new ur({client:this.client})}},dr=class extends y{get(t){return(t?.client??this.client).get({url:"/api/health",...t})}},gr=class extends y{get(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/location",...r,...n})}},mr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/agent",...r,...n})}},fr=class extends y{stage(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"messageID"},{in:"body",key:"files"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/stage",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}clear(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/clear",...r,...n})}commit(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/revert/commit",...r,...n})}},yr=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/permission",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/permission/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},hr=class extends y{list(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/question",...r,...n})}reply(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"},{key:"questionV2Reply",map:"body"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reply",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}reject(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"requestID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/question/{requestID}/reject",...r,...n})}},br=class extends y{list(t,r){let n=p([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(r?.client??this.client).get({url:"/api/session",...r,...n})}create(t,r){let n=p([t],[{args:[{in:"body",key:"id"},{in:"body",key:"agent"},{in:"body",key:"model"},{in:"body",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/session",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}get(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}",...r,...n})}switchAgent(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"agent"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/agent",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}switchModel(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"model"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/model",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}prompt(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"body",key:"id"},{in:"body",key:"prompt"},{in:"body",key:"delivery"},{in:"body",key:"resume"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/prompt",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}compact(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/compact",...r,...n})}wait(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).post({url:"/api/session/{sessionID}/wait",...r,...n})}context(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/context",...r,...n})}messages(t,r){let n=p([t],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"cursor"}]}]);return(r?.client??this.client).get({url:"/api/session/{sessionID}/message",...r,...n})}_revert;get revert(){return this._revert??=new fr({client:this.client})}_permission;get permission(){return this._permission??=new yr({client:this.client})}_question;get question(){return this._question??=new hr({client:this.client})}},xr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/model",...r,...n})}},kr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"providerID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/provider/{providerID}",...r,...n})}},Pr=class extends y{key(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"key"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/key",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}oauth(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"},{in:"body",key:"methodID"},{in:"body",key:"inputs"},{in:"body",key:"label"}]}]);return(r?.client??this.client).post({url:"/api/integration/{integrationID}/connect/oauth",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},wr=class extends y{cancel(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/integration/attempt/{attemptID}",...r,...n})}status(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/attempt/{attemptID}",...r,...n})}complete(t,r){let n=p([t],[{args:[{in:"path",key:"attemptID"},{in:"query",key:"location"},{in:"body",key:"code"}]}]);return(r?.client??this.client).post({url:"/api/integration/attempt/{attemptID}/complete",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},_r=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"integrationID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/integration/{integrationID}",...r,...n})}_connect;get connect(){return this._connect??=new Pr({client:this.client})}_attempt;get attempt(){return this._attempt??=new wr({client:this.client})}},Sr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/credential/{credentialID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"credentialID"},{in:"query",key:"location"},{in:"body",key:"label"}]}]);return(r?.client??this.client).patch({url:"/api/credential/{credentialID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}},vr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/permission/request",...r,...n})}},Cr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"projectID"}]}]);return(r?.client??this.client).get({url:"/api/permission/saved",...r,...n})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"id"}]}]);return(r?.client??this.client).delete({url:"/api/permission/saved/{id}",...r,...n})}},Rr=class extends y{_request;get request(){return this._request??=new vr({client:this.client})}_saved;get saved(){return this._saved??=new Cr({client:this.client})}},Tr=class extends y{read(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/fs/read/*",...r,...n})}list(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"path"}]}]);return(r?.client??this.client).get({url:"/api/fs/list",...r,...n})}find(t,r){let n=p([t],[{args:[{in:"query",key:"location"},{in:"query",key:"query"},{in:"query",key:"type"},{in:"query",key:"limit"}]}]);return(r?.client??this.client).get({url:"/api/fs/find",...r,...n})}},Ir=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/command",...r,...n})}},jr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/skill",...r,...n})}},Ar=class extends y{subscribe(t){return(t?.client??this.client).sse.get({url:"/api/event",...t})}},Er=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty",...r,...n})}create(t,r){let n=p([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(r?.client??this.client).post({url:"/api/pty",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}remove(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).delete({url:"/api/pty/{ptyID}",...r,...n})}get(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/pty/{ptyID}",...r,...n})}update(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(r?.client??this.client).put({url:"/api/pty/{ptyID}",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}connectToken(t,r){let n=p([t],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/api/pty/{ptyID}/connect-token",...r,...n})}connect(t,r){let n=p([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(r?.client??this.client).get({url:"/api/pty/{ptyID}/connect",...r,...n})}},$r=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/question/request",...r,...n})}},qr=class extends y{_request;get request(){return this._request??=new $r({client:this.client})}},Dr=class extends y{list(t,r){let n=p([t],[{args:[{in:"query",key:"location"}]}]);return(r?.client??this.client).get({url:"/api/reference",...r,...n})}},Mr=class extends y{remove(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"directory"},{in:"body",key:"force"}]}]);return(r?.client??this.client).delete({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}create(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"},{in:"body",key:"strategy"},{in:"body",key:"directory"},{in:"body",key:"name"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy",...r,...n,headers:{"Content-Type":"application/json",...r?.headers,...n.headers}})}refresh(t,r){let n=p([t],[{args:[{in:"path",key:"projectID"},{in:"query",key:"location"}]}]);return(r?.client??this.client).post({url:"/experimental/project/{projectID}/copy/refresh",...r,...n})}},Ur=class extends y{_health;get health(){return this._health??=new dr({client:this.client})}_location;get location(){return this._location??=new gr({client:this.client})}_agent;get agent(){return this._agent??=new mr({client:this.client})}_session;get session(){return this._session??=new br({client:this.client})}_model;get model(){return this._model??=new xr({client:this.client})}_provider;get provider(){return this._provider??=new kr({client:this.client})}_integration;get integration(){return this._integration??=new _r({client:this.client})}_credential;get credential(){return this._credential??=new Sr({client:this.client})}_permission;get permission(){return this._permission??=new Rr({client:this.client})}_fs;get fs(){return this._fs??=new Tr({client:this.client})}_command;get command(){return this._command??=new Ir({client:this.client})}_skill;get skill(){return this._skill??=new jr({client:this.client})}_event;get event(){return this._event??=new Ar({client:this.client})}_pty;get pty(){return this._pty??=new Er({client:this.client})}_question;get question(){return this._question??=new qr({client:this.client})}_reference;get reference(){return this._reference??=new Dr({client:this.client})}_projectCopy;get projectCopy(){return this._projectCopy??=new Mr({client:this.client})}},We=class e extends y{static __registry=new vt;constructor(t){super(t),e.__registry.set(this,t?.key)}_auth;get auth(){return this._auth??=new Ct({client:this.client})}_app;get app(){return this._app??=new Rt({client:this.client})}_experimental;get experimental(){return this._experimental??=new Mt({client:this.client})}_global;get global(){return this._global??=new Ot({client:this.client})}_event;get event(){return this._event??=new Lt({client:this.client})}_config;get config(){return this._config??=new Ft({client:this.client})}_tool;get tool(){return this._tool??=new Gt({client:this.client})}_worktree;get worktree(){return this._worktree??=new Bt({client:this.client})}_find;get find(){return this._find??=new Kt({client:this.client})}_file;get file(){return this._file??=new Nt({client:this.client})}_instance;get instance(){return this._instance??=new Ht({client:this.client})}_path;get path(){return this._path??=new Wt({client:this.client})}_vcs;get vcs(){return this._vcs??=new zt({client:this.client})}_command;get command(){return this._command??=new Jt({client:this.client})}_lsp;get lsp(){return this._lsp??=new Xt({client:this.client})}_formatter;get formatter(){return this._formatter??=new Qt({client:this.client})}_mcp;get mcp(){return this._mcp??=new Zt({client:this.client})}_project;get project(){return this._project??=new er({client:this.client})}_pty;get pty(){return this._pty??=new tr({client:this.client})}_question;get question(){return this._question??=new rr({client:this.client})}_permission;get permission(){return this._permission??=new nr({client:this.client})}_provider;get provider(){return this._provider??=new ir({client:this.client})}_session;get session(){return this._session??=new or({client:this.client})}_part;get part(){return this._part??=new ar({client:this.client})}_sync;get sync(){return this._sync??=new lr({client:this.client})}_tui;get tui(){return this._tui??=new pr({client:this.client})}_v2;get v2(){return this._v2??=new Ur({client:this.client})}};function qn(e,t,r,n){if(!n?.throwOnError||e instanceof Error)return e;if(typeof e=="object"&&e!==null&&Object.keys(e).length>0){let c=e,u=typeof c.data?.message=="string"&&c.data.message||typeof c.message=="string"&&c.message||typeof c.name=="string"&&c.name||$n(r,t);return new Error(u,{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 ${$n(r,t)}: ${s}`,{cause:{body:e,status:t?.status}})}function $n(e,t){let r=e?.method??"?",n=e?.url??"?",s=t?.status,c=t?.statusText;return`${r} ${n}${s?" \u2192 "+s:""}${c?" "+c:""}`}function il(e,t,r){if(e)return t&&(e===t||r&&e===r(t))?t:e}function ol(e,t){if(e.method!=="GET"&&e.method!=="HEAD")return e;let r=new URL(e.url),n=!1;for(let[c,u]of[["x-opencode-directory","directory"],["x-opencode-workspace","workspace"]]){let d=il(e.headers.get(c),u==="directory"?t.directory:t.workspace,u==="directory"?encodeURIComponent:void 0);if(d){for(let g of r.pathname.startsWith("/api/")?[u,`location[${u}]`]:[u])r.searchParams.has(g)||r.searchParams.set(g,d);n=!0}}if(!n)return e;let s=new Request(r,e);return s.headers.delete("x-opencode-directory"),s.headers.delete("x-opencode-workspace"),s}function Or(e){e?.fetch||(e={...e,fetch:n=>(n.timeout=!1,fetch(n))}),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=ke(e);return t.interceptors.request.use(r=>ol(r,{directory:e?.directory,workspace:e?.experimental_workspaceID})),t.interceptors.response.use(r=>{if(r.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 r}),t.interceptors.error.use(qn),new We({client:t})}function al(e){return new Promise(t=>setTimeout(t,e))}async function Dn(e,t,r){let n=Math.max(1,t?.attempts??1),s=t?.baseDelayMs??0,c=t?.invalidateBetweenAttempts??!1,u=null;for(let d=0;d<n;d++)if(d>0&&(c&&r?.(),s>0&&await al(s)),u=await e(),u)return u;return u}var cl=3e4;function ll(e){return(e instanceof Request?e.url:String(e)).includes("/global/event")}function Mn(e,t,r=cl){let n=e instanceof Request?e.signal:t?.signal;if(ll(e))return n??void 0;let s=AbortSignal.timeout(r);return n?typeof AbortSignal.any=="function"?AbortSignal.any([n,s]):n:s}function Lr(e,t,r){let n=new Headers(e instanceof Request?e.headers:void 0);return t?.headers&&new Headers(t.headers).forEach((s,c)=>{n.set(c,s)}),r&&!n.has("Authorization")&&n.set("Authorization",`Bearer ${r}`),n}function Un(){return new Response(JSON.stringify({error:"Not authenticated"}),{status:401,headers:{"Content-Type":"application/json"}})}async function Fr(){return I().getToken()}async function Pe(e){return Dn(()=>I().getToken(),e,Ve)}function Ve(){}function Ad(e){}function Ed(e){}async function ze(){return Fr()}async function On(e){return Pe(e)}function Ln(e,t,r,n){if(e instanceof Request){let s=new Request(e,{headers:r,...n?{signal:n}:{}});return fetch(s)}return fetch(e,{...t,headers:r,...n?{signal:n}:{}})}async function R(e,t,r){let{retryOnAuthError:n=!0}=r??{},s=await On();if(!s)return Un();let c=Lr(e,t,s),u=Mn(e,t),d=await Ln(e,t,c,u);if(d.status===401&&n&&s){Ve();let g=await On({attempts:2,baseDelayMs:200});if(g&&g!==s){let h=Lr(e,t,g);return Ln(e,t,h,u)}}return d}var oe={url:null,sandboxId:null,dbSandboxId:null,version:0},ul=new Set;function Fn(e,t=null,r=null){if(!(oe.url===e&&oe.sandboxId===t&&oe.dbSandboxId===r)){oe={url:e,sandboxId:t,dbSandboxId:r,version:oe.version+1};for(let n of ul)n()}}function Gn(){return oe.url}function pl(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return e.slice(0,t)}function we(){return pl(I().backendUrl||"http://localhost:8008/v1")}function Bn(){let e=I().sandboxId||"";return`${we()}/p/${e}/8000`}function dl(e){return`${we()}/p/${e}/8000`}function Je(e){return dl(e)}function $(){let e=Gn();return e||(I().billingEnabled??!1?"":Bn())}var C=class extends Error{status;code;details;data;detail;response;url;endpoint;timeout;constructor(t,r={}){super(t),this.name="ApiError";let{name:n,stack:s,...c}=r;Object.assign(this,c),n&&(this.name=n),s&&(this.stack=s);let u=typeof t=="string"?t:t==null?"":String(t);Object.defineProperty(this,"message",{value:u,enumerable:!0,writable:!0,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype)}},_e=class extends C{constructor(t="Not authenticated"){super(t,{code:"NO_SESSION"}),this.name="AuthError"}},ae=class e extends Error{status;detail;constructor(t,r,n){super(n||r.message||`Billing Error: ${t}`),this.name="BillingError",this.status=t,this.detail=r,Object.setPrototypeOf(this,e.prototype)}},Se=class e extends Error{status;detail;constructor(t=431,r,n){let s="Request headers are too large",c="Try uploading files one at a time, or reduce the number of files in a single request.";super(n||r?.message||s),this.name="RequestTooLargeError",this.status=t,this.detail={message:r?.message||s,suggestion:r?.suggestion||c},Object.setPrototypeOf(this,e.prototype)}};function ve(e){let t=e.response?.status||e.status;if(t!==402)return e;let r=e.response?.data||e.data||e.detail||{},n=r?.detail||r;return new ae(t,{message:n?.message||e.message||"Billing error",...n})}function gl(e){return e instanceof ae}function ml(e){if(!(e instanceof ae))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."}}async function Gr(e,t){return(await e.json().catch(()=>({})))?.error||e.statusText||t}function Br(e){if(!e)throw new Error("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading");return e}async function Kn(e){let t=Br(e),r=await R(`${t}/env`);if(!r.ok)throw new Error(await Gr(r,"Failed to load secrets"));return(await r.json()).secrets??{}}async function Nn(e,t,r){let n=Br(e),s=await R(`${n}/env/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!s.ok)throw new Error(await Gr(s,"Failed to save secret"))}async function Hn(e,t){let r=Br(e),n=await R(`${r}/env/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await Gr(n,"Failed to delete secret"))}var fl={list:Kn,set:Nn,delete:Hn};async function yl(e,t,r){let n=e;for(;n.endsWith("/");)n=n.slice(0,-1);let s=await R(`${n}/kortix/triggers${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}}),c=await s.json();if(!s.ok)throw new Error(c?.error||c?.message||`Request failed with ${s.status}`);return c}function ce(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 Xe(e,t){let r=await e.json().catch(()=>({}));return r?.error||r?.message||e.statusText||t}function Ce(e){if(!e)throw new Error("[kortix-pty] Server URL not ready \u2014 sandbox is still loading");return ce(e)}async function Wn(e){let t=Ce(e),r=await R(`${t}/kortix/pty`);if(!r.ok)throw new Error(await Xe(r,"Failed to list terminals"));return r.json()}async function Vn(e,t){let r=Ce(e),n=await R(`${r}/kortix/pty`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!n.ok)throw new Error(await Xe(n,"Failed to create terminal"));return n.json()}async function zn(e,t,r){let n=Ce(e),s=await R(`${n}/kortix/pty/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await Xe(s,"Failed to update terminal"));return s.json()}async function Jn(e,t){let r=Ce(e),n=await R(`${r}/kortix/pty/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(await Xe(n,"Failed to remove terminal"))}async function Xn(e,t){let r=Ce(t),s=`${(()=>{try{let d=new URL(r);return d.protocol==="https:"?d.protocol="wss:":d.protocol==="http:"&&(d.protocol="ws:"),typeof window<"u"&&window.location.protocol==="https:"&&d.protocol==="ws:"&&(d.protocol="wss:"),ce(d.toString())}catch{return r.replace("https://","wss://").replace("http://","ws://")}})()}/kortix/pty/${encodeURIComponent(e)}/connect`,c=await ze();if(!c)return s;let u=s.includes("?")?"&":"?";return`${s}${u}token=${encodeURIComponent(c)}`}var hl={list:Wn,create:Vn,update:zn,remove:Jn,webSocketUrl:Xn};async function b(e,t,r,n){let s=e;for(;s.endsWith("/");)s=s.slice(0,-1);let c=await R(`${s}${t}`,{...r,headers:{"Content-Type":"application/json",...r?.headers}},n),u=await c.text(),d={};try{d=u?JSON.parse(u):{}}catch{d={}}if(!c.ok)throw new Error(d?.error||d?.message||d?.details||u.slice(0,200)||`Request failed with ${c.status}`);return d}async function Zd(e,t={}){let r=new URLSearchParams;t.projectId&&r.set("project_id",t.projectId),t.status&&r.set("status",t.status);let n=r.toString()?`?${r}`:"";return b(e,`/kortix/tasks${n}`)}async function eg(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`)}async function tg(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/events`)}async function rg(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/status`)}async function ng(e,t){return b(e,"/kortix/tasks",{method:"POST",body:JSON.stringify(t)})}async function sg(e,t,r){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function ig(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/start`,{method:"POST"})}async function og(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}/approve`,{method:"POST"})}async function ag(e,t){return b(e,`/kortix/tasks/${encodeURIComponent(t)}`,{method:"DELETE"})}async function cg(e,t){let r=t?`?project_id=${encodeURIComponent(t)}`:"";return b(e,`/kortix/tickets${r}`)}async function lg(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`)}async function ug(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/events`)}async function pg(e,t){return b(e,"/kortix/tickets",{method:"POST",body:JSON.stringify(t)})}async function dg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function gg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/status`,{method:"POST",body:JSON.stringify(r)})}async function mg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/assign`,{method:"POST",body:JSON.stringify(r)})}async function fg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/unassign`,{method:"POST",body:JSON.stringify(r)})}async function yg(e,t,r){return b(e,`/kortix/tickets/${encodeURIComponent(t)}/comments`,{method:"POST",body:JSON.stringify(r)})}async function hg(e,t){return b(e,`/kortix/tickets/${encodeURIComponent(t)}`,{method:"DELETE"})}async function bg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`)}async function xg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/columns`,{method:"PUT",body:JSON.stringify({columns:r})})}async function kg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`)}async function Pg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/fields`,{method:"PUT",body:JSON.stringify({fields:r})})}async function wg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`)}async function _g(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/templates`,{method:"PUT",body:JSON.stringify({templates:r})})}async function Sg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/pm-session`,{method:"POST"})}async function vg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`)}async function Cg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents`,{method:"POST",body:JSON.stringify(r)})}async function Rg(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function Tg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Ig(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/agents/${encodeURIComponent(r)}/persona`)}async function jg(e,t,r=200){return b(e,`/kortix/projects/${encodeURIComponent(t)}/activity?limit=${r}`)}async function Ag(e){return b(e,"/kortix/projects")}async function Eg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`)}async function $g(e,t){return b(e,`/kortix/projects/by-session/${encodeURIComponent(t)}`)}async function qg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/sessions`)}async function Dg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Mg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(r)})}async function Ug(e,t,r="all"){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones?status=${r}`)}async function Og(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`)}async function Lg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/events`)}async function Fg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones`,{method:"POST",body:JSON.stringify(r)})}async function Gg(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(n)})}async function Bg(e,t,r,n){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/close`,{method:"POST",body:JSON.stringify(n)})}async function Kg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}/reopen`,{method:"POST"})}async function Ng(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/milestones/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Hg(e,t){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`)}async function Wg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}/events`)}async function Vg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials`,{method:"POST",body:JSON.stringify(r)})}async function zg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`)}async function Jg(e,t,r){return b(e,`/kortix/projects/${encodeURIComponent(t)}/credentials/${encodeURIComponent(r)}`,{method:"DELETE"})}var bl=1e4,xl={retryOnAuthError:!1};function le(e,t,r){return b(e,t,{signal:AbortSignal.timeout(bl),...r},xl)}async function Xg(e,t=!1){return(await le(e,`/kortix/services${t?"?all=true":""}`)).services??[]}async function Qg(e){return(await le(e,"/kortix/services/templates")).templates??[]}async function Yg(e,t){return(await le(e,`/kortix/services/${encodeURIComponent(t)}/logs`)).logs??[]}async function Zg(e,t,r){let n=r==="delete",s=n?`/kortix/services/${encodeURIComponent(t)}`:`/kortix/services/${encodeURIComponent(t)}/${r}`;return le(e,s,{method:n?"DELETE":"POST"})}async function em(e,t){return le(e,`/kortix/services/reconcile${t?"?reload=true":""}`,{method:"POST"})}async function tm(e,t){return le(e,"/kortix/services/register",{method:"POST",body:JSON.stringify(t)})}var Qe=new Map,Kr=class extends Error{constructor(t="[opencode-sdk] Server URL not ready \u2014 sandbox is still loading"){super(t),this.name="RuntimeNotReadyError"}};function Z(){let e=$();if(!e)throw new Kr;return ue(e)}function ue(e){if(!e)throw new Error("[opencode-sdk] getClientForUrl called without a url");let t=Qe.get(e);if(t)return t;if(!kt())throw new Error("[opencode-sdk] No auth token provider configured \u2014 call configureKortix()/createKortix() before talking to a sandbox runtime.");let r=Or({baseUrl:e,fetch:R});return Qe.set(e,r),r}function cm(e){Qe.delete(e)}function lm(){Qe.clear()}var Ye=new Map;function um(e){if(!e)throw new Error("[opencode-sdk] getPublicClientForUrl called without a url");let t=Ye.get(e);if(t)return t;let r=Or({baseUrl:e,fetch});return Ye.set(e,r),r}function pm(e){Ye.delete(e)}function dm(){Ye.clear()}async function kl(e){let t=await e.text().catch(()=>"");try{let r=JSON.parse(t);return r?.error||r?.message||t||e.statusText||`HTTP ${e.status}`}catch{return t||e.statusText||`HTTP ${e.status}`}}async function gm(e){let t=$();if(!t)throw new C("[opencode-sdk] Server URL not ready \u2014 sandbox is still loading",{code:"RUNTIME_UNAVAILABLE"});let r=await R(`${t}/kortix/services/system/reload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e})});if(!r.ok)throw new C(`System reload failed (${r.status}): ${await kl(r)}`,{status:r.status,response:r,code:"RUNTIME_UNAVAILABLE"});return r.json()}function Yn(e){if(e.error){let t=e.error,r=t?.data?.message||t?.message||(typeof t?.error=="string"?t.error:null)||"SDK request failed";throw new C(r,{status:t?.response?.status??t?.status,response:t?.response,details:t})}return e.data}async function pe(e){let t=await e.text().catch(()=>""),r=null;try{r=JSON.parse(t)}catch{}return r?.error||t||e.statusText||`HTTP ${e.status}`}async function Ze(e,t=$()){let r=await R(`${t}${e}`);if(!r.ok)throw new C(await pe(r),{status:r.status,response:r});return r.json()}var Zn=["/workspace","/tmp","/home","/opt"],Pl=Zn.filter(e=>e!=="/workspace");function wl(e){return Zn.some(t=>e===t||e.startsWith(`${t}/`))}function _l(e){return wl(e)?e:`/workspace/${e.replace(/^\/+/,"")}`}function Te(e){let t=e||"";if(t==="/workspace"||t==="/workspace/")return"";if(t.startsWith("/workspace/"))t=t.slice(11);else if(Pl.some(r=>t===r||t.startsWith(`${r}/`)))return t;for(;t.startsWith("/");)t=t.slice(1);return t}var Sl=Te;async function Nr(e,t=$()){let r=Te(e)||".";return(await Ze(`/file?path=${encodeURIComponent(r)}`,t)).map(s=>({...s,path:s.absolute||`/workspace/${s.path}`}))}async function et(e,t=$()){let r=Te(e),n=await R(`${t}/file/content?path=${encodeURIComponent(r)}`);if(!n.ok)throw new C(await pe(n),{status:n.status,response:n});return n.json()}async function vl(e,t,r=$()){let n=Te(e),s=await R(`${r}/file/raw?path=${encodeURIComponent(n)}`);if(!s.ok)throw new C(await pe(s),{status:s.status,response:s});if((s.headers.get("content-type")||"").includes("text/html"))throw new C("File could not be loaded (raw byte route unavailable)",{status:s.status,response:s,code:"INVALID_CONTENT_TYPE"});let c=await s.blob();return t&&(!c.type||c.type==="application/octet-stream")?new Blob([c],{type:t}):c}async function tt(e,t=$()){try{return await vl(e,void 0,t)}catch{}let r=await et(e,t);if(r.encoding==="base64"&&r.content){let n=Uint8Array.from(atob(r.content),s=>s.charCodeAt(0));return new Blob([n],{type:r.mimeType||"application/octet-stream"})}return new Blob([r.content??""],{type:r.mimeType||"text/plain;charset=utf-8"})}function Hr(e=$()){return Ze("/file/status",e)}async function Wr(e,t,r=$()){let n=new URLSearchParams({query:e});return t?.type&&n.set("type",t.type),t?.limit&&n.set("limit",String(t.limit)),Ze(`/find/file?${n.toString()}`,r)}async function Vr(e,t=$()){return(await Ze(`/find?pattern=${encodeURIComponent(e)}`,t)).map(n=>({path:typeof n.path=="string"?n.path:n.path?.text??"",lines:typeof n.lines=="string"?n.lines:n.lines?.text??"",line_number:n.line_number,absolute_offset:n.absolute_offset,submatches:(n.submatches??[]).map(s=>({start:s.start,end:s.end}))}))}var Re=[400,1200],Cl=e=>e===408||e===429||e===502||e===503||e===504,Qn=e=>new Promise(t=>setTimeout(t,e));async function Rl(e){let t=await e.text().catch(()=>""),r=null;try{r=t?JSON.parse(t):null}catch{}let n=r?.error||r?.message||r?.data?.message;return typeof n=="string"&&n.trim()?n.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 es(e,t){let r;for(let s=0;s<=Re.length;s++){let c;try{c=await t(e())}catch(d){if(r=d,s===Re.length)break;await Qn(Re[s]);continue}if(c.ok)return c.json();let u=await Rl(c);if(r=new C(`Upload failed (${c.status}): ${u}`,{status:c.status,response:c}),!Cl(c.status)||s===Re.length)throw r;await Qn(Re[s])}if(r instanceof C)throw r;let n=r instanceof Error?r.message:String(r||"request failed");throw new C(`Upload failed: ${n}`)}function rt(e,t,r,n=$()){return es(()=>{let s=new FormData,c=(t??"").trim();return c&&s.append("path",c.startsWith("/")?c:`/${c}`),r?s.append("file",e,r):s.append("file",e),s},s=>R(`${n}/file/upload`,{method:"POST",body:s}))}function Tl(e,t,r=$()){return es(()=>{let n=new FormData;return n.append(e,t,e.split("/").pop()||"file"),n},async n=>{let s={},c=await ze();return c&&(s.Authorization=`Bearer ${c}`),fetch(`${r}/file/upload`,{method:"POST",body:n,headers:s})})}function zr(e,t=$()){let r=e.trim(),s=(r.startsWith("/")?r:`/${r}`).split("/"),c=s.pop()||"untitled",u=s.join("/")||"/workspace";return rt(new File([" "],c,{type:"application/octet-stream"}),u,void 0,t)}async function Jr(e,t,r=$()){return Tl(t,await tt(e,r),r)}async function Xr(e,t=$()){let r=await R(`${t}/file`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new C(`Delete failed (${r.status}): ${await pe(r)}`,{status:r.status,response:r});return r.json()}async function Qr(e,t=$()){let r=await R(`${t}/file/mkdir`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})});if(!r.ok)throw new C(`Mkdir failed (${r.status}): ${await pe(r)}`,{status:r.status,response:r});return r.json()}async function Yr(e,t,r=$()){let n=await R(`${r}/file/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:e,to:t})});if(!n.ok)throw new C(`Rename failed (${n.status}): ${await pe(n)}`,{status:n.status,response:n});return n.json()}async function Il(){return Yn(await Z().project.current())}async function ts(){return Yn(await Z().global.health())}async function jl(){try{return(await ts()).healthy===!0}catch{return!1}}var Al={list:Nr,read:et,readBlob:tt,status:Hr,findFiles:Wr,findText:Vr,upload:rt,create:zr,copy:Jr,remove:Xr,mkdir:Qr,rename:Yr,currentProject:Il,health:ts,isReachable:jl,toDaemonPath:Te,toSandboxAbsolutePath:_l,toWorkspaceRelative:Sl};var z=()=>I().backendUrl||"",$l=e=>new Promise(t=>setTimeout(t,e)),ql=new Set([502,503,504]),rs=e=>ql.has(e),Dl=e=>{let t=(e??"GET").toUpperCase();return t==="GET"||t==="HEAD"},Ml=2,Zr=!1;function Cm(e){Zr=e}function Rm(){return Zr}async function ee(e,t={}){let{showErrors:r=!0,errorContext:n,timeout:s=3e4,...c}=t,u=new AbortController,d=null,g=!1,h=!1;try{d=setTimeout(()=>{!g&&!u.signal.aborted&&(g=!0,h=!0,u.abort())},s);let m=await Pe(),x=c.body instanceof FormData,w={};if(x||(w["Content-Type"]="application/json"),Object.assign(w,c.headers),Zr&&(w["x-kortix-admin-bypass"]="1"),m)w.Authorization=`Bearer ${m}`;else return{error:new _e,success:!1};let k=await fetch(e,{...c,headers:w,signal:u.signal,credentials:c.credentials??"omit"});if(d&&(clearTimeout(d),d=null),!k.ok&&Dl(c.method)&&rs(k.status))for(let P=0;P<Ml;P++){try{await k.arrayBuffer()}catch{}await $l(250*2**P);let _=new AbortController,D=setTimeout(()=>{_.abort()},s);try{k=await fetch(e,{...c,headers:w,signal:_.signal,credentials:c.credentials??"omit"})}catch{break}finally{D&&(clearTimeout(D),D=null)}if(k.ok||!rs(k.status))break}if(!k.ok){let P=`HTTP ${k.status}: ${k.statusText}`,_=null;try{_=await k.json(),typeof _.message=="string"?P=_.message:_.error&&typeof _.error=="string"?P=_.error:typeof _.detail=="string"?P=_.detail:typeof _.detail?.message=="string"&&(P=_.detail.message)}catch{}let D=new C(P,{status:k.status,response:k,details:_||void 0,data:_,detail:_?.detail,code:_?.code||_?.error_code||_?.detail?.error_code||k.status.toString()});if(k.status===402&&(D=ve(D)),k.status===403&&_?.code==="account_mfa_required"&&typeof window<"u"&&typeof window.dispatchEvent=="function")try{window.dispatchEvent(new CustomEvent("kortix:mfa-required"))}catch{}return k.status===431&&(D=new Se(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."})),r&&I().onError?.(D,n),{error:D,success:!1}}let l,i=k.headers.get("content-type");return i?.includes("application/json")?l=await k.json():i?.includes("text/")?l=await k.text():l=await k.blob(),{data:l,success:!0}}catch(m){d&&(clearTimeout(d),d=null);let x=m?.name==="AbortError"||m?.name==="AbortSignal"||m instanceof Error&&m.message.includes("aborted");x&&(g=!0);let w;if(x){if(!h)return{error:new C("Request aborted",{name:"AbortError",code:"ABORTED"}),success:!1};let k=e.replace(z(),"")||e;w=new C(`Request timed out after ${Math.round(s/1e3)}s: ${k}`,{code:"TIMEOUT",url:e,endpoint:k,timeout:s}),r&&I().onError?.(w,n)}else m instanceof Error?(w=new C(m.message,{name:m.name||"ApiError",stack:m.stack}),r&&I().onError?.(w,n)):(w=new C(String(m)),r&&I().onError?.(w,n));return{error:w,success:!1}}}var Tm={async execute(e,t){try{let{data:r,error:n}=await e();if(n){let s=new C(n.message||"Database error",{code:n.code,details:n});return I().onError?.(s,t),{error:s,success:!1}}return{data:r,success:!0}}catch(r){let n=r instanceof Error?new C(r.message,{name:r.name||"ApiError",stack:r.stack}):new C(String(r));return I().onError?.(n,t),{error:n,success:!1}}}},o={get:(e,t)=>ee(`${z()}${e}`,{...t,method:"GET"}),post:(e,t,r)=>ee(`${z()}${e}`,{...r,method:"POST",body:t?JSON.stringify(t):void 0}),put:(e,t,r)=>ee(`${z()}${e}`,{...r,method:"PUT",body:t?JSON.stringify(t):void 0}),patch:(e,t,r)=>ee(`${z()}${e}`,{...r,method:"PATCH",body:t?JSON.stringify(t):void 0}),delete:(e,t)=>ee(`${z()}${e}`,{...t,method:"DELETE"}),upload:(e,t,r)=>{let{headers:n,...s}=r||{},c={...n};return delete c["Content-Type"],ee(`${z()}${e}`,{...s,method:"POST",body:t,headers:c})},uploadPut:(e,t,r)=>{let{headers:n,...s}=r||{},c={...n};return delete c["Content-Type"],ee(`${z()}${e}`,{...s,method:"PUT",body:t,headers:c})}};function a(e,t="Project request failed"){if(!e.success||e.data===void 0)throw e.error??new Error(t);return e.data}function en(e){return e.replace(/\/v1\/?$/,"")}async function de(e,t){if(!e.backendUrl||!e.accessToken)return null;let r=en(e.backendUrl);try{let n=await fetch(`${r}${t}`,{headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},signal:AbortSignal.timeout(e.timeoutMs??8e3)});return n.ok?await n.json():null}catch{return null}}async function ns(){return a(await o.get("/accounts"))}async function ss(e){return a(await o.post("/accounts",e))}async function is(e){return a(await o.get(`/accounts/${e}`))}async function os(e,t){return a(await o.patch(`/accounts/${e}`,{name:t}))}async function as(e){return a(await o.get(`/accounts/${e}/members`))}async function cs(e,t){return a(await o.post(`/accounts/${e}/members`,t,{showErrors:!1}))}async function ls(e){return a(await o.get(`/accounts/${e}/invites`))}async function us(e,t){return a(await o.delete(`/accounts/${e}/invites/${t}`))}async function ps(e,t){return a(await o.post(`/accounts/${e}/invites/${t}/resend`,{}))}async function ds(e){return a(await o.get(`/account-invites/${e}`,{showErrors:!1}))}async function gs(e){return a(await o.post(`/account-invites/${e}/accept`,{}))}async function ms(e){return a(await o.post(`/account-invites/${e}/decline`,{}))}async function fs(e,t){return a(await o.delete(`/accounts/${e}/members/${t}`))}async function ys(e,t,r){return a(await o.patch(`/accounts/${e}/members/${t}`,{role:r}))}async function hs(e){return a(await o.post(`/accounts/${e}/leave`,{}))}async function $m(e){return de(e,"/v1/accounts")}async function bs(){let e=await o.get("/accounts/me",{showErrors:!1});return!e.success||!e.data?{valid:!1,error:e.error}:{valid:!0,identity:e.data}}async function ge(){return a(await o.get("/projects"))}async function xs(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/projects${t}`))}async function tn(e,t){return a(await o.get(`/projects/${e}`,t))}async function ks(e,t,r="write"){return a(await o.post(`/projects/${e}/git/collaborators`,{github_username:t,permission:r}))}async function Ps(e,t){return a(await o.post(`/projects/${e}/manifest/validate`,{raw:t}),"Failed to validate manifest")}async function ws(e){return a(await o.post(`/projects/${e}/git-token`,{}),"Failed to mint git token")}function Um(e){let t=e.metadata?.git;return t?.provider==="github"&&t?.managed===!0}async function rn(e,t){return a(await o.get(`/projects/${e}/detail`,{showErrors:!1,...t}))}async function nn(e,t){return a(await o.get(`/projects/${e}/llm-catalog`,{showErrors:!1,...t}))}async function sn(e,t){return a(await o.get(`/projects/${e}/model-picker`,{showErrors:!1,...t}))}async function _s(e){return a(await o.post("/projects",e))}async function Ss(e){return a(await o.post("/projects/create-repo",e))}async function vs(e){return a(await o.post("/projects/provision",{seed_starter:!0,...e}))}async function Om(){try{return a(await o.get("/projects/managed-git/status",{showErrors:!1}))}catch{return{configured:!1,provider:"github"}}}async function on(e,t){return a(await o.patch(`/projects/${e}`,t))}async function Cs(e,t,r){return a(await o.patch(`/projects/${e}/experimental`,{feature:t,enabled:r}))}async function Rs(e,t){return a(await o.patch(`/projects/${e}/sandbox-provider`,{provider:t}))}async function Lm(e,t){return a(await o.patch(`/projects/${e}/warm-pool`,t))}async function Ts(e,t){return a(await o.patch(`/projects/${e}/onboarding`,{completed:t}))}async function an(e){return a(await o.delete(`/projects/${e}`))}async function Fm(e,t){return de(e,`/v1/projects?account_id=${encodeURIComponent(t)}`)}async function Gm(e,t){if(!e.backendUrl||!e.accessToken)return{ok:!1,limitReached:!1};let r=en(e.backendUrl);try{let n=await fetch(`${r}/v1/projects/provision`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({seed_starter:!0,...t}),signal:AbortSignal.timeout(e.timeoutMs??9e4)});if(n.ok){let s=await n.json().catch(()=>null);return s?.project_id?{ok:!0,project:s}:{ok:!1,limitReached:!1}}return n.status===403?{ok:!1,limitReached:(await n.json().catch(()=>null))?.code==="project_limit_reached"}:{ok:!1,limitReached:!1}}catch{return{ok:!1,limitReached:!1}}}async function Is(e){return a(await o.post("/projects/link-repository",e,{showErrors:!1}))}async function js(e){return a(await o.get(`/projects/github/installation?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function As(e){return a(await o.get(`/projects/github/installations?account_id=${encodeURIComponent(e)}`,{showErrors:!1}))}async function Es(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.get(`/projects/github/repositories?${r.toString()}`,{showErrors:!1}))}async function $s(e,t,r){let n=new URLSearchParams({account_id:e,installation_id:t,repo_full_name:r});return a(await o.get(`/projects/github/repository-branches?${n.toString()}`,{showErrors:!1}))}async function qs(e){return a(await o.post("/projects/github/installation",e,{showErrors:!1}))}async function Ds(e,t){let r=new URLSearchParams({account_id:e});return t&&r.set("installation_id",t),a(await o.delete(`/projects/github/installation?${r.toString()}`))}async function zm(e,t){return a(await o.post(`/projects/${e}/access-requests`,{message:t?.trim()||void 0},{showErrors:!1}))}async function Ms(e,t){return a(await o.get(`/projects/${e}/access-requests`,t))}async function Us(e,t,r="member"){return a(await o.post(`/projects/${e}/access-requests/${t}/approve`,{role:r}))}async function Os(e,t){return a(await o.post(`/projects/${e}/access-requests/${t}/reject`,{}))}async function Ls(e){return a(await o.get(`/projects/${e}/access`))}async function Fs(e,t,r){return a(await o.put(`/projects/${e}/access/${t}`,{role:r}))}async function Gs(e,t){return a(await o.delete(`/projects/${e}/access/${t}`))}function Jm(e){return"status"in e&&e.status==="invited"}async function Bs(e,t,r,n){return a(await o.post(`/projects/${e}/access/invite`,{email:t,role:r,...n!==void 0?{expires_at:n}:{}}))}async function Ks(e){return a(await o.get(`/projects/${e}/access/pending-invites`))}async function Ns(e,t){return a(await o.delete(`/projects/${e}/access/pending-invites/${t}`))}async function Hs(e,t){return a(await o.post(`/projects/${e}/access/pending-invites/${t}/resend`))}async function Ws(e){return a(await o.get(`/projects/${e}/group-grants`))}async function Vs(e,t,r,n){return a(await o.post(`/projects/${e}/group-grants`,n===void 0?{group_id:t,role:r}:{group_id:t,role:r,expires_at:n}))}async function zs(e,t,r,n){return a(await o.patch(`/projects/${e}/group-grants/${t}`,n===void 0?{role:r}:{role:r,expires_at:n}))}async function Js(e,t){return a(await o.delete(`/projects/${e}/group-grants/${t}`))}async function Xs(e){return a(await o.get(`/projects/${e}/resource-grants`))}async function Qs(e,t){return a(await o.post(`/projects/${e}/resource-grants`,{resource_type:t.resourceType,resource_id:t.resourceId,principal_type:t.principalType,principal_id:t.principalId,...t.expiresAt!==void 0?{expires_at:t.expiresAt}:{}}))}async function Ys(e,t){return a(await o.delete(`/projects/${e}/resource-grants/${t}`))}async function Zs(e,t){return a(await o.get(`/projects/${e}/approvals`,{showErrors:t?.showErrors}))}async function ei(e,t){return a(await o.get(`/projects/${e}/approvals/needs-input`,{showErrors:t?.showErrors}))}async function ti(e,t,r,n="once"){return a(await o.post(`/projects/${e}/approvals/${t}`,{decision:r,scope:n}))}async function ri(e){return a(await o.get(`/projects/${e}/secrets`,{showErrors:!1}))}async function ni(e,t){return a(await o.post(`/projects/${e}/secrets`,t))}async function si(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/start`,{sharing:r?.sharing}))}async function ii(e,t,r){return a(await o.post(`/projects/${e}/oauth/${t}/poll`,{flow_id:r}))}async function oi(e,t){return a(await o.put(`/projects/${e}/git-credential`,t))}async function ai(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}`))}async function ci(e,t,r){return a(await o.put(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`,r))}async function li(e,t){return a(await o.delete(`/projects/${e}/secrets/${encodeURIComponent(t)}/personal`))}async function ui(e,t){return a(await o.post(`/projects/${e}/secrets/${encodeURIComponent(t)}/promote-to-shared`,{}))}async function pi(e){return a(await o.get(`/projects/${e}/connector-profiles`))}async function di(e,t){return a(await o.post(`/projects/${e}/connector-profiles`,t))}async function gi(e,t,r){return a(await o.put(`/projects/${e}/connector-profiles/${t}/credential`,r))}async function mi(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/revoke`,{}))}async function fi(e,t){return a(await o.put(`/projects/${e}/connector-profiles/${t}/activate`,{}))}async function yi(e){return a(await o.get(`/executor/projects/${e}/connectors`,{showErrors:!1}))}async function hi(e){return a(await o.post(`/executor/projects/${e}/connectors/sync`,{}))}async function bi(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential-mode`,{mode:r}))}async function xi(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/sensitive`,{sensitive:r}))}async function ki(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`))}async function Pi(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/policies`,{policies:r}))}async function wi(e,t){return a(await o.get(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/config`))}async function _i(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/name`,{name:r}))}async function Si(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect`,{}))}async function vi(e,t){return a(await o.post(`/executor/projects/${e}/connectors`,t))}async function Ci(e,t){return a(await o.delete(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}`))}async function Ri(e,t,r){let n=new URLSearchParams;t&&n.set("q",t),r&&n.set("cursor",r);let s=n.toString();return a(await o.get(`/executor/projects/${e}/pipedream/apps${s?`?${s}`:""}`))}async function Ti(){return a(await o.get("/executor/connect-status"))}async function Ii(e,t,r){return a(await o.put(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/credential`,{value:r}))}async function ji(e,t){return a(await o.post(`/executor/projects/${e}/connectors/${encodeURIComponent(t)}/connect/finalize`,{}))}async function Ai(e){return a(await o.get(`/executor/projects/${e}/policies`))}async function Ei(e,t,r){return a(await o.put(`/executor/projects/${e}/policies`,{policies:t,defaultMode:r}))}async function $i(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function qi(e){return a(await o.get(`/projects/${e}/snapshots`))}async function cn(e){return a(await o.get(`/projects/${e}/sandbox-health`,{showErrors:!1,timeout:15e3}))}async function Di(e,t){return a(await o.post(`/projects/${e}/snapshots/rebuild`,t?{slug:t}:{}))}async function Mi(e){return a(await o.post(`/projects/${e}/snapshots/fix-with-agent`,{}))}async function Ui(e,t){return a(await o.post(`/projects/${e}/sandbox-templates`,t))}async function Oi(e,t,r){return a(await o.patch(`/projects/${e}/sandbox-templates/${t}`,r))}async function Li(e,t){return a(await o.delete(`/projects/${e}/sandbox-templates/${t}`))}async function Fi(e,t){return a(await o.post(`/projects/${e}/sandbox-templates/${t}/build`,{}))}async function Gi(e){return a(await o.get(`/projects/${e}/sandboxes`))}async function Bi(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path);let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/files${n}`,{showErrors:!1}))}async function Ki(e,t,r){let n=new URLSearchParams({q:t});return r?.content&&n.set("content","1"),r?.ref&&n.set("ref",r.ref),r?.limit&&n.set("limit",String(r.limit)),a(await o.get(`/projects/${e}/files/search?${n.toString()}`))}async function Ni(e,t,r){let n=new URLSearchParams({path:t});return r&&n.set("ref",r),a(await o.get(`/projects/${e}/files/content?${n.toString()}`))}async function Hi(e,t,r){let n=new URLSearchParams;t&&n.set("ref",t),r&&n.set("path",r);let s=n.toString()?`?${n.toString()}`:"",c=await Pe(),u=`${I().backendUrl||""}/projects/${e}/files/archive${s}`,d=await fetch(u,{method:"GET",headers:c?{Authorization:`Bearer ${c}`}:{}});if(!d.ok){let g=await d.text().catch(()=>"");throw new Error(g||`Failed to download (HTTP ${d.status})`)}return await d.blob()}async function Wi(e){return a(await o.get(`/projects/${e}/branches`))}async function Vi(e,t){let r=new URLSearchParams;t?.ref&&r.set("ref",t.ref),t?.path&&r.set("path",t.path),t?.limit!=null&&r.set("limit",String(t.limit)),t?.skip!=null&&r.set("skip",String(t.skip));let n=r.toString()?`?${r.toString()}`:"";return a(await o.get(`/projects/${e}/commits${n}`))}async function zi(e,t){return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}`))}async function Ji(e,t,r){let n=new URLSearchParams;r?.path&&n.set("path",r.path);let s=n.toString()?`?${n.toString()}`:"";return a(await o.get(`/projects/${e}/commits/${encodeURIComponent(t)}/diff${s}`))}async function Xi(e,t,r){let n=new URLSearchParams({path:t});return r?.ref&&n.set("ref",r.ref),r?.limit!=null&&n.set("limit",String(r.limit)),r?.skip!=null&&n.set("skip",String(r.skip)),a(await o.get(`/projects/${e}/files/history?${n.toString()}`))}async function Qi(e,t){let r=new URLSearchParams({from:t.from,into:t.into});return a(await o.get(`/projects/${e}/version-diff?${r.toString()}`))}async function Yi(e,t){let r=t?`?status=${t}`:"";return a(await o.get(`/projects/${e}/change-requests${r}`,{showErrors:!1,timeout:15e3}))}async function Zi(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}`))}async function eo(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/diff`))}async function to(e,t){return a(await o.get(`/projects/${e}/change-requests/${t}/merge-preview`))}async function ro(e,t){return a(await o.post(`/projects/${e}/change-requests`,t))}async function no(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/merge`,r??{},{showErrors:!1}))}async function so(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/close`,{}))}async function io(e,t){return a(await o.post(`/projects/${e}/change-requests/${t}/reopen`,{}))}async function oo(e,t,r){return a(await o.post(`/projects/${e}/change-requests/${t}/request-changes`,{feedback:r}))}async function ao(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/commit-push`,r??{}))}var ln=new Set;function co(e){e&&ln.add(e)}function lo(e){return!!e&&ln.has(e)}function Pf(e){e&&ln.delete(e)}async function Ie(e){return a(await o.get(`/projects/${e}/sessions`))}async function uo(e,t,r){return a(await o.put(`/projects/${e}/sessions/${t}/sharing`,r))}async function po(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/previews`))}async function go(e,t){return a(await o.get(`/projects/${e}/sessions/${t}/public-shares`,{showErrors:!1}))}async function mo(e,t,r){return a(await o.post(`/projects/${e}/sessions/${t}/public-shares`,r))}async function fo(e,t,r){return a(await o.delete(`/projects/${e}/sessions/${t}/public-shares/${r}`))}async function je(e,t){let r=a(await o.post(`/projects/${e}/sessions`,t??{}));return t?.initial_prompt||co(r?.session_id),r}async function yo(e,t,r){return a(await o.get(`/projects/${e}/sessions/${t}`,{showErrors:r?.showErrors}))}async function ho(e,t,r,n){let s=r?`?limit=${r}`:"";return a(await o.get(`/projects/${e}/sessions/${t}/audit${s}`,{showErrors:n?.showErrors}))}async function bo(e,t,r){let n=new URLSearchParams;r?.limit!=null&&n.set("limit",String(r.limit)),r?.chars!=null&&n.set("chars",String(r.chars));let s=n.toString();return a(await o.get(`/projects/${e}/sessions/${t}/transcript${s?`?${s}`:""}`))}async function xo(e,t,r){return a(await o.patch(`/projects/${e}/sessions/${t}`,r))}async function ko(e,t){return a(await o.delete(`/projects/${e}/sessions/${t}`))}async function nt(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/restart`,{}))}async function st(e,t){return a(await o.post(`/projects/${e}/sessions/${t}/stop`,{}))}async function Po(e){return a(await o.get(`/projects/${e}/triggers`))}async function wo(e,t){return a(await o.post(`/projects/${e}/triggers`,t))}async function _o(e,t,r){return a(await o.patch(`/projects/${e}/triggers/${t}`,r))}async function So(e,t){return a(await o.delete(`/projects/${e}/triggers/${t}`))}async function vo(e,t){return a(await o.patch(`/projects/${e}/triggers/activation`,{paused:t}))}async function Co(e,t){return a(await o.post(`/projects/${e}/triggers/${t}/fire`,{}))}var J=new Map;function un(e,t){return`${e}::${t}`}function Ro(e,t){J.delete(e),J.set(e,t)}function To(e,t){let r=un(e,t),n=J.get(r);return n&&Ro(r,n),n}function Io(e,t,r){let n=un(e,t);if(!J.has(n)&&J.size>=512){let s=J.keys().next().value;s!==void 0&&J.delete(s)}Ro(n,r)}function jo(e,t){J.delete(un(e,t))}var pn=class extends Error{status;code;terminal;constructor(t,r){super(t),this.name="SessionStartError",this.status=r.status,this.code=r.code,this.terminal=r.terminal}};function Df(e){return e instanceof Error&&e.name==="SessionStartError"}function Ul(e){let t=e,r=t?.status,n=t?.code??t?.details?.code??t?.details?.error,s=t?.message||"Unable to start this session";return r&&r>=400&&r<500&&r!==408&&r!==429?new pn(s,{status:r,code:n,terminal:!0}):null}async function Ae(e,t,r){let n=r&&r>0?`?wait_ms=${Math.floor(r)}`:"",s=await o.post(`/projects/${e}/sessions/${t}/start${n}`,{},{showErrors:!1});if(!s.success||!s.data){let d=Ul(s.error);if(d&&!(d.status===404&&lo(t)))throw d;return null}let c=s.data,u=c.sandbox?.external_id;return c.stage==="ready"&&u&&c.opencode_session_id&&Io(e,t,{opencodeSessionId:c.opencode_session_id,runtimeUrl:Je(u),sandboxId:u}),c}function Mf(e,t){return["session-start",e,t]}async function Ao(e){return a(await o.get(`/projects/${e}/model-defaults`))}async function Eo(e,t){return a(await o.put(`/projects/${e}/model-defaults`,t))}async function $o(e,t){let r=new URLSearchParams({scope:t.scope,...t.agentName?{agentName:t.agentName}:{}}).toString();return a(await o.delete(`/projects/${e}/model-defaults?${r}`))}async function qo(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/scope`,r))}async function Wf(e,t){return a(await o.get(`/projects/${e}/agents/${encodeURIComponent(t)}/config`))}async function Vf(e,t,r){return a(await o.put(`/projects/${e}/agents/${encodeURIComponent(t)}/config`,r))}async function Do(e,t){return a(await o.put(`/projects/${e}/default-agent`,{agent:t}))}function Mo(){return{credits:{total:0,daily:0,monthly:0,extra:0,can_run:!1,daily_refresh:null},subscription:{tier_key:"none",tier_display_name:"No Plan",status:"no_subscription",billing_period:null,provider:"stripe",subscription_id:null,current_period_end:null,cancel_at_period_end:!1,is_cancelled:!1,cancellation_effective_date:null,has_scheduled_change:!1,scheduled_change:null,commitment:{has_commitment:!1,can_cancel:!0,commitment_type:null,months_remaining:null,commitment_end_date:null},can_purchase_credits:!1},models:[],limits:{concurrent_runs:{running_count:0,limit:0,can_start:!1,tier_name:"none"},ai_worker_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"},custom_mcp_count:{current_count:0,limit:0,can_create:!1,tier_name:"none"}},tier:{name:"none",display_name:"No Plan",monthly_credits:0,can_purchase_credits:!1}}}async function Uo(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state${n}`,{showErrors:!1}),c=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!c)throw s.error;return s.error?Mo():s.data}async function Oo(e){let t=new URLSearchParams;e?.skipCache&&t.set("skip_cache","true"),e?.accountId&&t.set("account_id",e.accountId);let r=t.toString(),n=r?`?${r}`:"",s=await o.get(`/billing/account-state/minimal${n}`,{showErrors:!1}),c=s.error?.status===404&&/billing is not enabled/i.test(s.error.message||"");if(s.error&&s.error.status!==401&&!c)throw s.error;return s.error?Mo():s.data}async function Lo(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.limit!=null&&t.set("limit",String(e.limit)),e?.offset!=null&&t.set("offset",String(e.offset)),e?.typeFilter&&t.set("type_filter",Array.isArray(e.typeFilter)?e.typeFilter.join(","):e.typeFilter);let r=t.toString();return a(await o.get(`/billing/transactions${r?`?${r}`:""}`))}async function Fo(e){let t=new URLSearchParams;e?.accountId&&t.set("account_id",e.accountId),e?.days!=null&&t.set("days",String(e.days));let r=t.toString();return a(await o.get(`/billing/transactions/summary${r?`?${r}`:""}`))}async function Go(){return a(await o.get("/billing/credit-breakdown"))}async function Bo(e){let t=e!=null?`?days=${e}`:"";return a(await o.get(`/billing/usage-history${t}`))}async function Ko(){return a(await o.get("/billing/tier-configurations"))}async function Qf(e){let t=e.accountId?`?account_id=${encodeURIComponent(e.accountId)}`:"";return de(e,`/v1/billing/account-state${t}`)}async function No(e){return a(await o.post("/billing/create-checkout-session",{account_id:e.accountId,tier_key:e.tierKey,success_url:e.successUrl,cancel_url:e.cancelUrl,commitment_type:e.commitmentType,locale:e.locale,server_type:e.serverType,location:e.location}),"Failed to create checkout session")}async function Ho(e,t){return a(await o.post("/billing/confirm-checkout-session",{account_id:t,session_id:e}),"Failed to confirm checkout session")}async function Wo(e,t){return a(await o.post("/billing/create-portal-session",{account_id:t,return_url:e}),"Failed to create portal session")}async function Vo(e,t){return a(await o.post("/billing/cancel-subscription",{account_id:t,feedback:e}),"Failed to cancel subscription")}async function zo(e){return a(await o.post("/billing/reactivate-subscription",{account_id:e}),"Failed to reactivate subscription")}async function Jo(e,t,r){return a(await o.post("/billing/schedule-downgrade",{account_id:r,target_tier_key:e,commitment_type:t}),"Failed to schedule downgrade")}async function Xo(e){return a(await o.post("/billing/cancel-scheduled-change",{account_id:e}),"Failed to cancel scheduled change")}async function Qo(e,t){let r=new URLSearchParams({new_price_id:e});return t&&r.set("account_id",t),a(await o.get(`/billing/proration-preview?${r.toString()}`),"Failed to load proration preview")}async function Yo(e){return a(await o.post("/billing/purchase-credits",{amount:e.amount,account_id:e.accountId,success_url:e.successUrl,cancel_url:e.cancelUrl}),"Failed to purchase credits")}async function Zo(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/billing/auto-topup/settings${t}`),"Failed to load auto-topup settings")}async function ea(e){return a(await o.post("/billing/auto-topup/configure",{account_id:e.accountId,enabled:e.enabled,threshold:e.threshold,amount:e.amount}),"Failed to configure auto-topup")}async function ta(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});return t.success?t.data??null:null}async function ra(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/connect`,t,{showErrors:!1}),"Failed to connect")}var Ol={oauth_available:!1,install_url:null};async function na(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/mode`,{showErrors:!1});return!t.success||!t.data?Ol:t.data}async function sa(e){return a(await o.get(`/webhooks/slack/${encodeURIComponent(e)}/manifest`,{showErrors:!1}),"Failed to load Slack manifest")}async function ia(e){let t=await o.delete(`/projects/${encodeURIComponent(e)}/channels/slack/installation`,{showErrors:!1});if(!t.success)throw new Error(t.error?.message??"Failed to disconnect")}async function oa(e,t){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/slack/file?url=${encodeURIComponent(t)}`,{showErrors:!1}),"Failed to download Slack file")}async function aa(e,t){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/slack/file/upload`,{channel:t.channel,filename:t.filename,content_base64:t.contentBase64,comment:t.comment,thread_ts:t.threadTs},{showErrors:!1}),"Failed to upload Slack file")}function dn(e){return{...e,profileId:e.profileId??e.profile_id??null}}var Ll={provider:"agentmail",managed_available:!1};async function ca(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});return n.success&&n.data?dn(n.data):null}async function la(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/email/mode`,{showErrors:!1});return!t.success||!t.data?Ll:t.data}async function ua(e,t){let r=a(await o.post(`/projects/${encodeURIComponent(e)}/channels/email/connect`,t,{showErrors:!1}),"Failed to connect email");return dn(r)}async function pa(e,t){let r=t?`?connector_slug=${encodeURIComponent(t)}`:"",n=await o.delete(`/projects/${encodeURIComponent(e)}/channels/email/installation${r}`,{showErrors:!1});if(!n.success)throw new Error(n.error?.message??"Failed to disconnect email")}async function da(e,t,r){let n=a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/email/installation`,{connector_slug:t??"kortix_email",sender_policy:r},{showErrors:!1}),"Failed to update email policy");return dn(n)}async function ga(e){let t=await o.get(`/projects/${encodeURIComponent(e)}/channels/meet/voices`,{showErrors:!1});return t.success?t.data??null:null}async function ma(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/voice`,{voice:t},{showErrors:!1}),"Failed to save voice")}async function fa(e,t){return a(await o.put(`/projects/${encodeURIComponent(e)}/channels/meet/name`,{name:t},{showErrors:!1}),"Failed to save name")}async function ya(e,t){let r=await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/voices/${encodeURIComponent(t)}/preview`,{},{showErrors:!1});return!r.success||!r.data?.b64?null:r.data.b64}async function ty(e){return a(await o.get(`/projects/${encodeURIComponent(e)}/channels/bindings`,{showErrors:!1}),"Failed to load channel bindings")}async function ry(e,t,r){return a(await o.patch(`/projects/${encodeURIComponent(e)}/channels/bindings/${encodeURIComponent(t)}`,r,{showErrors:!1}),"Failed to update channel binding")}async function ha(e,t,r,n){return a(await o.post(`/projects/${encodeURIComponent(e)}/channels/meet/speak`,{bot_id:t,text:r,voice:n},{showErrors:!1}),"Failed to speak in meeting")}async function ba(e){return a(await o.get(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function xa(e,t){return a(await o.put(`/projects/${e}/gateway/routing-policy`,t),"Gateway routing policy request failed")}async function ka(e){return a(await o.delete(`/projects/${e}/gateway/routing-policy`),"Gateway routing policy request failed")}async function Pa(e,t){return a(await o.post(`/projects/${e}/gateway/routing-policy/preview`,t),"Gateway route preview failed")}async function wa(e,t){let r=new URLSearchParams;t?.limit&&r.set("limit",String(t.limit)),t?.offset&&r.set("offset",String(t.offset)),t?.ok!==void 0&&r.set("ok",String(t.ok));let n=r.toString();return a(await o.get(`/projects/${e}/gateway/logs${n?`?${n}`:""}`),"Gateway request failed")}async function _a(e,t){return a(await o.get(`/projects/${e}/gateway/logs/${t}`),"Gateway request failed")}async function Sa(e,t){return a(await o.get(`/projects/${e}/gateway/overview${t?`?days=${t}`:""}`),"Gateway request failed")}async function va(e,t){return a(await o.get(`/projects/${e}/gateway/series${t?`?days=${t}`:""}`),"Gateway request failed")}async function Ca(e,t){return a(await o.get(`/projects/${e}/gateway/breakdown${t?`?days=${t}`:""}`),"Gateway request failed")}async function Ra(e,t){return a(await o.get(`/projects/${e}/gateway/sessions${t?`?days=${t}`:""}`),"Gateway request failed")}async function Ta(e,t){return a(await o.get(`/projects/${e}/gateway/errors${t?`?days=${t}`:""}`),"Gateway request failed")}async function Ia(e){return a(await o.get(`/projects/${e}/gateway/budgets`),"Gateway request failed")}async function ja(e,t){return a(await o.put(`/projects/${e}/gateway/budgets`,t),"Gateway request failed")}async function Aa(e,t){return a(await o.delete(`/projects/${e}/gateway/budgets/${t}`),"Gateway request failed")}async function Ea(e){return a(await o.get(`/projects/${e}/gateway/keys`),"Gateway request failed")}async function $a(e,t){return a(await o.post(`/projects/${e}/gateway/keys`,{name:t}),"Gateway request failed")}async function qa(e,t){return a(await o.delete(`/projects/${e}/gateway/keys/${t}`),"Gateway request failed")}async function Da(e,t,r){return a(await o.post(`/projects/${e}/gateway/playground`,{prompt:t,models:r}),"Gateway request failed")}async function Ma(e){let t=new FormData;t.append("audio_file",e);let r=await o.upload("/transcription",t,{showErrors:!0});if(r.error)throw new Error(`Error transcribing audio: ${r.error.message} (${r.error.status})`);return r.data}async function Ua(e,t){let r=new URLSearchParams;t?.segment&&r.set("segment",t.segment),t?.kind&&r.set("kind",t.kind);let n=r.toString();return a(await o.get(`/projects/${e}/review/items${n?`?${n}`:""}`,{showErrors:!1}))}async function Oa(e,t){return a(await o.get(`/projects/${e}/review/items/${t}`))}async function La(e,t){return a(await o.post(`/projects/${e}/review/items`,t))}async function Fa(e,t,r){return a(await o.post(`/projects/${e}/review/items/${t}/act`,r))}async function Ga(e,t){return a(await o.post(`/projects/${e}/review/bulk`,t))}async function Ba(e){return a(await o.get(`/p/share?sandbox_id=${encodeURIComponent(e)}`),"Failed to load public links").shares??[]}async function Ka(e){return a(await o.post("/p/share",{sandbox_id:e.sandboxId,port:e.port,ttl:e.ttl,label:e.label}),"Failed to generate public URL")}async function Na(e,t){let r=await o.delete(`/p/share/${encodeURIComponent(t)}?sandbox_id=${encodeURIComponent(e)}`);if(!r.success)throw new Error(r.error?.message??"Failed to revoke public link")}var gn=class extends Error{constructor(r,n){super(r);this.status=n;this.name="PublicSessionShareError"}status};function Ha(e,t=""){return`${we()}/public/session-shares/${encodeURIComponent(e)}${t}`}async function Wa(e){let t=await fetch(e,{method:"GET",headers:{Accept:"application/json"}}),r=await t.text().catch(()=>""),n=null;try{n=r?JSON.parse(r):null}catch{}if(!t.ok){let s=(n&&typeof n=="object"&&"error"in n&&typeof n.error=="string"?n.error:null)||t.statusText||`HTTP ${t.status}`;throw new gn(s,t.status)}return n}async function yy(e){return Wa(Ha(e))}async function hy(e){return Wa(Ha(e,"/messages"))}async function Va(e){let t=e?`?account_id=${encodeURIComponent(e)}`:"";return a(await o.get(`/accounts/tokens${t}`))}async function za(e){let{accountId:t,expiresAt:r,projectId:n,name:s}=e;return a(await o.post("/accounts/tokens",{name:s,...t?{account_id:t}:{},...r?{expires_at:r}:{},...n?{project_id:n}:{}}))}async function Ja(e,t){let r=t?`?account_id=${encodeURIComponent(t)}`:"";return a(await o.delete(`/accounts/tokens/${e}${r}`))}async function Xa(e){return a(await o.get(`/projects/${e}/cli-token`))}async function Qa(e,t){return a(await o.post(`/projects/${e}/cli-token`,t??{}))}async function Ya(e,t){return a(await o.delete(`/projects/${e}/cli-token/${t}`))}async function Za(e,t){let r=new URLSearchParams;t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since),t?.cursor&&r.set("cursor",t.cursor),t?.limit!=null&&r.set("limit",String(t.limit));let n=r.toString();return a(await o.get(`/accounts/${e}/audit${n?`?${n}`:""}`))}async function ec(e,t){let r=new URLSearchParams;t?.format&&r.set("format",t.format),t?.action&&r.set("action",t.action),t?.since&&r.set("since",t.since);let n=r.toString();return a(await o.get(`/accounts/${e}/audit/export${n?`?${n}`:""}`))}async function tc(e){return a(await o.get(`/accounts/${e}/audit/webhooks`))}async function rc(e,t){return a(await o.post(`/accounts/${e}/audit/webhooks`,t))}async function nc(e,t,r){return a(await o.patch(`/accounts/${e}/audit/webhooks/${t}`,r))}async function sc(e,t){return a(await o.delete(`/accounts/${e}/audit/webhooks/${t}`))}async function ic(e,t){return a(await o.post(`/projects/${e}/secret-requests`,{names:t.names,labels:t.labels,descriptions:t.descriptions,scope:t.scope,expires_in_minutes:t.expiresInMinutes}),"Failed to mint secret-entry link")}async function oc(e,t){return a(await o.post(`/projects/${e}/connect-requests`,{slug:t.slug,expires_in_minutes:t.expiresInMinutes}),"Failed to mint connect link")}async function ac(e){let t=new URLSearchParams;e?.query&&t.set("query",e.query),e?.type&&t.set("type",e.type),e?.source&&t.set("source",e.source);let r=t.toString()?`?${t.toString()}`:"";return a(await o.get(`/marketplace/items${r}`))}async function cc(){return a(await o.get("/marketplace/marketplaces"))}async function lc(){return a(await o.get("/marketplace/marketplaces/featured"))}async function uc(e){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}`),"Item not found")}async function pc(e,t){return a(await o.get(`/marketplace/items/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`),"File not found")}async function dc(){return a(await o.get("/marketplace/sources"))}async function gc(e){return a(await o.post("/marketplace/sources",e),"Failed to add marketplace source")}async function mc(e){return a(await o.delete(`/marketplace/sources/${encodeURIComponent(e)}`),"Failed to remove marketplace source")}async function $y(e){return a(await o.get(`/templates/${encodeURIComponent(e)}`))}async function qy(e,t){return a(await o.post(`/templates/${encodeURIComponent(e)}/install`,t))}function Oy(e){return e?e.runtimeReady!==void 0?e.runtimeReady===!0:e.opencode!==void 0?e.opencode==="ok"||e.opencode===!0:e.status!=="starting"&&e.status!=="down"&&e.status!=="error":!1}async function fc(e,t){let r=(e===void 0?$():e)||null;if(!r)return{status:0,ok:!1,health:null,body:""};let n=await R(`${r}/kortix/health`,{method:"GET",...t},{retryOnAuthError:!1}),s=await n.text().catch(()=>""),c=null;try{c=s?JSON.parse(s):null}catch{c=null}return{status:n.status,ok:n.ok,health:c,body:s}}var X={DESKTOP:"6080",DESKTOP_HTTPS:"6081",PRESENTATION_VIEWER:"3210",STATIC_FILE_SERVER:"3211",KORTIX_MASTER:"8000",BROWSER_STREAM:"9223",BROWSER_VIEWER:"9224",SSH:"22"};var yc=/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s)"'<>]*/g,hc=/^https?:\/\/p(\d+)-([^.]+)\.localhost(?::(\d+))?(\/.*)?$/,bc=new Set([22,4096,parseInt(X.KORTIX_MASTER,10)]);function Fl(e){return hc.test(e)}function it(e){if(!e)return"/";let t=e,r=t.indexOf("](");r!==-1&&(t=t.slice(0,r));let n=t.toLowerCase().indexOf("%5d(");return n!==-1&&(t=t.slice(0,n)),t?t.startsWith("/")?t:`/${t}`:"/"}function Gl(e){let t=e.indexOf("](");return t===-1?e:e.slice(0,t)}var Bl=new Set(["'",'"',"`","<","(","["]),Kl=new Set([">","'",'"',"`",")","]",",",";",".","!","?"]);function Nl(e){let t=0,r=e.length;for(;t<r&&(e[t]===" "||e[t]===" ");)t++;for(;r>t&&(e[r-1]===" "||e[r-1]===" ");)r--;for(;t<r&&Bl.has(e[t]);)t++;for(;r>t&&Kl.has(e[r-1]);)r--;return e.slice(t,r)}function Hl(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1):\d{1,5}[^\s"'<>)]*/i)?.[0]??null}var Wl=/^\/proxy\/(\d{1,5})(\/.*)?$/,Vl=/^\/(connectors|settings|dashboard|projects|agents|skills|tools|commands|support|changelog|files|p|browser|desktop|terminal|sessions|services|workspace|channels|scheduled-tasks|marketplace|templates|tunnel|admin|auth)(\/|$|\?)/;function zl(e){if(!e)return!1;try{let t=new URL(e);return t.hostname!=="localhost"&&t.hostname!=="127.0.0.1"?!1:Vl.test(t.pathname)}catch{return!1}}function ot(e){if(!e)return null;let t=Nl(Gl(e.trim())),r=Pc(t);if(r){let n=it(r.path||"/");return{originalUrl:`http://localhost:${r.port}${n}`,port:r.port,path:n}}try{let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.hostname!=="localhost"&&n.hostname!=="127.0.0.1"||!n.port)return null;let s=parseInt(n.port,10);if(!Number.isInteger(s)||s<1||s>65535)return null;let c=`${n.pathname||"/"}${n.search}${n.hash}`,u=parseInt(X.KORTIX_MASTER,10);if(s===u){let g=n.pathname.match(Wl);if(g){let h=parseInt(g[1],10);if(h>=1&&h<=65535)return s=h,c=it(`${g[2]||"/"}${n.search}${n.hash}`),{originalUrl:`http://localhost:${s}${c}`,port:s,path:c}}}let d=it(c);return{originalUrl:`${n.protocol}//${n.hostname}:${s}${d}`,port:s,path:d}}catch{let n=Hl(e);return n&&n!==e?ot(n):null}}function Jl(e){let t=[],r=/```[\s\S]*?```/g,n;for(;(n=r.exec(e))!==null;)t.push([n.index,n.index+n[0].length]);let s=/`[^`\n]+`/g;for(;(n=s.exec(e))!==null;){let c=n.index,u=c+n[0].length;t.some(([g,h])=>c>=g&&u<=h)||t.push([c,u])}return t}function Xl(e,t){return t.some(([r,n])=>e>=r&&e<n)}function Ql(e){let t=[],r=new Set,n=Jl(e);yc.lastIndex=0;let s;for(;(s=yc.exec(e))!==null;){let c=ot(s[0]);if(!c)continue;let{originalUrl:u,port:d,path:g}=c;d<1||d>65535||bc.has(d)||r.has(u)||(r.add(u),t.push({originalUrl:u,port:d,path:g,startIndex:s.index,endIndex:s.index+u.length,inCodeBlock:Xl(s.index,n)}))}return t}function By(e){return Ql(e).length>0}function Yl(e){try{let{hostname:t}=new URL(e);return t==="localhost"||t==="127.0.0.1"}catch{return!1}}function $e(e,t,r){let n=it(t);if(!Yl(r.apiBaseUrl)){let s=r.apiBaseUrl.length;for(;s>0&&r.apiBaseUrl.charCodeAt(s-1)===47;)s--;return`${r.apiBaseUrl.slice(0,s)}/p/${r.sandboxId}/${e}${n}`}return`http://p${e}-${r.sandboxId}.localhost:${r.backendPort}${n}`}function Ky(e,t){return $e(e,"/",t)}function Zl(e){let t=ot(e);return!(!t||bc.has(t.port)||zl(e))}function xc(e,t){if(!e)return e;let r=ot(e);return r?Zl(r.originalUrl)?$e(r.port,r.path,t):r.originalUrl:e}function Ny(e,t="/"){return`http://localhost:${e}${t}`}var kc=/^https?:\/\/[^/]+\/v1\/p\/([^/]+)\/(\d+)(\/.*)?$/;function Pc(e){let t=e.match(hc);if(t)return{port:parseInt(t[1],10),sandboxId:t[2],backendPort:t[3]?parseInt(t[3],10):80,path:t[4]||"/"};let r=e.match(kc);if(r)try{let n=new URL(e);return{port:parseInt(r[2],10),sandboxId:r[1],backendPort:parseInt(n.port,10)||(n.protocol==="https:"?443:80),path:r[3]||"/"}}catch{return null}return null}function Hy(e){try{let t=Pc(e);return t?`http://localhost:${t.port}${t.path}`:null}catch{return null}}function Wy(e){return Fl(e)||kc.test(e)}var Ee="/web-proxy/";function Vy(e,t){try{let r=new URL(e);if(r.protocol!=="http:"&&r.protocol!=="https:")return null;let n=r.protocol.replace(":",""),s=`${Ee}${n}/${r.host}${r.pathname}${r.search}${r.hash}`,c=parseInt(X.KORTIX_MASTER,10);return`${$e(c,"/",t).replace(/\/$/,"")}${s}`}catch{return null}}function zy(e){try{let t=new URL(e),r=t.pathname.indexOf(Ee);if(r===-1)return null;let s=t.pathname.slice(r+Ee.length).match(/^(https?)\/([\w.\-]+(?::\d+)?)(\/.*)?$/);if(!s)return null;let c=s[1],u=s[2],d=s[3]||"/";return`${c}://${u}${d}${t.search}${t.hash}`}catch{return null}}function Jy(e){try{return new URL(e).pathname.includes(Ee)}catch{return e.includes(Ee)}}function Xy(e){if(!e)return!1;let t=e.trim();return!!(/^https?:\/\/(?!localhost|127\.0\.0\.1)/i.test(t)||/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t))}function Qy(e){let t=e.trim();return t?/^https?:\/\//i.test(t)?t:/^[a-z0-9][\w.-]*\.[a-z]{2,}/i.test(t)?`https://${t}`:null:null}var wc="frontend";function at(e,t,r){(e==="error"?console.error:e==="warn"?console.warn:e==="debug"?console.debug:console.log)(`[${wc}] ${t}`,...r?[r]:[]);try{Z().app.log({service:wc,level:e,message:t,extra:r})}catch{}}var Q={debug:(e,t)=>at("debug",e,t),info:(e,t)=>at("info",e,t),warn:(e,t)=>at("warn",e,t),error:(e,t)=>at("error",e,t)};function eu(e){return{type:"heartbeat-gap",gapMs:e}}function tu(e){switch(e.type){case"message.updated":return{type:"message.updated",sessionID:e.properties.sessionID,message:e.properties.info};case"message.removed":return{type:"message.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID};case"message.part.updated":return{type:"message.part.updated",sessionID:e.properties.sessionID,part:e.properties.part};case"message.part.removed":return{type:"message.part.removed",sessionID:e.properties.sessionID,messageID:e.properties.messageID,partID:e.properties.partID};case"session.status":return{type:"session.status",sessionID:e.properties.sessionID,status:e.properties.status};case"session.idle":return{type:"session.idle",sessionID:e.properties.sessionID};case"session.error":return{type:"session.error",sessionID:e.properties.sessionID,error:e.properties.error};case"question.asked":return{type:"question.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,questions:e.properties.questions,tool:e.properties.tool};case"question.replied":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"replied",answers:e.properties.answers};case"question.rejected":return{type:"question.answered",sessionID:e.properties.sessionID,requestID:e.properties.requestID,outcome:"rejected"};case"permission.asked":return{type:"permission.asked",sessionID:e.properties.sessionID,requestID:e.properties.id,permission:e.properties.permission,patterns:e.properties.patterns,tool:e.properties.tool};case"permission.replied":return{type:"permission.replied",sessionID:e.properties.sessionID,requestID:e.properties.requestID,reply:e.properties.reply};case"todo.updated":return{type:"todo.updated",sessionID:e.properties.sessionID,todos:e.properties.todos};case"server.connected":return{type:"connection",status:"connected"};default:return null}}var ru={now:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},nu=16,su=8,iu=6e4,ou=5e3,au=250,cu=1e3,lu=3e4,uu=5,pu=3e3,du=3e4,gu=2e4,mu=2e3,fu=8;function yu(e){if(e.type==="session.status")return`session.status:${e.properties.sessionID}`;if(e.type==="lsp.updated")return"lsp.updated"}function _c(e){if(e.aborted)return{promise:Promise.resolve(),cleanup:()=>{}};let t=()=>{};return{promise:new Promise(n=>{t=()=>n(),e.addEventListener("abort",t,{once:!0})}),cleanup:()=>e.removeEventListener("abort",t)}}function mn(e){let{client:t,onEvent:r,onGapRehydrate:n,onParked:s,signal:c}=e,u=e.timers??ru,d=e.connectTimeoutMs??gu,g=e.heartbeatTimeoutMs??iu,h=e.maxConsecutiveHardFailures??fu,m=new AbortController,x=()=>m.abort();c&&(c.aborted?m.abort():c.addEventListener("abort",x,{once:!0}));let w=u.now(),k=[],l,i=0,P=new Map,_=()=>{if(l&&u.clearTimeout(l),l=void 0,k.length===0)return;let A=k;k=[],P.clear(),i=u.now(),w=u.now();for(let v of A)if(v)try{r(v.event)}catch(T){console.warn("[opencode-events] event handler threw, skipping",T)}},D=()=>{if(l)return;let A=u.now()-i;l=u.setTimeout(_,Math.max(0,nu-A))};return(async()=>{let A=0,v=0;for(;!m.signal.aborted;){let T=!1,j=!1,f,S,U=null,K=u.now(),M=new AbortController,O=_c(m.signal);O.promise.then(()=>M.abort());try{let F=await new Promise((yt,he)=>{let G=!1;S=u.setTimeout(()=>{G||(G=!0,Q.warn("SSE connect timed out, forcing reconnect",{connectTimeoutMs:d}),M.abort(),he(new Error(`SSE connect timed out after ${d}ms`)))},d),t.global.event({signal:M.signal,sseDefaultRetryDelay:pu,sseMaxRetryDelay:du,sseMaxRetryAttempts:1}).then(H=>{G||(G=!0,u.clearTimeout(S),yt(H))},H=>{G||(G=!0,u.clearTimeout(S),he(H))})}),{stream:E}=F;w=u.now();let B=()=>{u.clearTimeout(f),f=u.setTimeout(()=>{Q.warn("SSE heartbeat timeout, forcing reconnect"),M.abort()},g)};B();let Fe=u.now(),Hc=E[Symbol.asyncIterator]();for(;!M.signal.aborted;){let yt=Hc.next().then(V=>({kind:"next",result:V}),V=>({kind:"error",error:V})),he=_c(M.signal),G=await Promise.race([yt,he.promise.then(()=>({kind:"aborted"}))]);if(he.cleanup(),G.kind==="aborted")break;if(G.kind==="error")throw G.error;if(G.result.done)break;T=!0,B();let H=G.result.value,Ge=H&&typeof H=="object"&&"payload"in H?H.payload:H;if(!Ge?.type)continue;let ht=yu(Ge);if(ht){let V=P.get(ht);V!==void 0&&(k[V]=void 0),P.set(ht,k.length)}k.push({type:Ge.type,event:Ge}),D(),!(u.now()-Fe<su)&&(Fe=u.now(),await new Promise(V=>u.setTimeout(V,0)))}j=T}catch(F){if(m.signal.aborted)break;U=F;let E=String(F),B=E.includes("401")||E.includes("403")||E.includes("Unauthorized")||E.includes("Token refresh failed");if(Q.error("SSE event stream error",{error:E,retryCount:A,isAuthError:B}),B)try{Ve(),await Fr(),Q.info("SSE: refreshed auth token after auth error")}catch(Fe){Q.error("SSE: failed to refresh auth token",{error:String(Fe)})}}finally{u.clearTimeout(f),u.clearTimeout(S),M.abort(),O.cleanup(),_()}if(m.signal.aborted)break;let se=u.now()-K,Le=U?.cause?.status;if(v=!T&&(typeof Le=="number"&&Le>=400||se<mu)?v+1:0,v>=h){Q.error("SSE event stream parked \u2014 giving up after consecutive hard failures",{consecutiveFailures:v,lastError:String(U)});try{s?.({consecutiveFailures:v,lastError:U})}catch(F){console.warn("[opencode-events] onParked handler threw",F)}break}let ye=u.now()-w;ye>ou&&n?.(ye),j?A=0:(A++,A>1&&Q.warn("SSE event stream reconnecting",{retryCount:A}));let N=j?au:Math.min(cu*2**Math.min(A-1,uu),lu);await new Promise(F=>{let E=u.setTimeout(F,N),B=()=>{u.clearTimeout(E),F()};m.signal.addEventListener("abort",B,{once:!0})})}})(),{close:()=>{m.abort(),c&&c.removeEventListener("abort",x),l&&u.clearTimeout(l)}}}function hu(){return Z()}var ct=new Map,lt=class extends Error{constructor(t){super(`Session runtime not ready \u2014 call \`await session.ensureReady()\` (it drives \`start()\` to completion and resolves this session's own sandbox runtime) before calling \`${t}\`.`),this.name="SessionNotReadyError"}};function bu(e,t){xt(e,t);function r(l){try{return new URL(l)}catch{if(typeof window<"u"&&window.location?.origin)try{return new URL(l,window.location.origin)}catch{return null}throw new C(`Kortix SDK: backendUrl must be an absolute URL outside the browser (got ${JSON.stringify(l)}). Relative paths like "/api/kortix" only resolve against a page origin \u2014 configure an absolute backendUrl for server-side hosts.`,{code:"INVALID_BACKEND_URL"})}}function n(l){let i=I().backendUrl??e.backendUrl,P=80,_=r(i);return _&&(P=_.port?Number(_.port):_.protocol==="https:"?443:80),{sandboxId:l,backendPort:P,apiBaseUrl:i}}let s={list:ns,get:is,create:ss,updateName:os,leave:hs,members:as,invite:cs,removeMember:fs,updateMemberRole:ys,invites:ls,cancelInvite:us,resendInvite:ps,tokens:{list:Va,create:za,revoke:Ja},audit:{log:Za,export:ec,webhooks:{list:tc,create:rc,update:nc,remove:sc}}},c={accountState:Uo,accountStateMinimal:Oo,transactions:Lo,transactionsSummary:Fo,creditBreakdown:Go,usageHistory:Bo,tierConfigurations:Ko,checkout:{createSession:l=>No(l),confirmSession:(l,i)=>Ho(l,i)},subscription:{createPortalSession:(l,i)=>Wo(l,i),cancel:(l,i)=>Vo(l,i),reactivate:l=>zo(l),scheduleDowngrade:(l,i,P)=>Jo(l,i,P),cancelScheduledChange:l=>Xo(l),prorationPreview:(l,i)=>Qo(l,i)},credits:{purchase:l=>Yo(l),autoTopupSettings:l=>Zo(l),configureAutoTopup:l=>ea(l)}},u={describe:ds,accept:gs,decline:ms},d={list:ge,listForAccount:xs,get:tn,detail:rn,create:_s,createRepo:Ss,provision:vs,update:on,archive:an,llmCatalog:nn,modelPicker:sn,sandboxHealth:cn,sandboxTemplates:$i,sessions:Ie,createSession:je},g={linkRepository:Is,getInstallation:js,listInstallations:As,listRepositories:Es,listRepositoryBranches:$s,saveInstallation:qs,deleteInstallation:Ds},h={list:Ba,create:Ka,revoke:Na},m=Ti,x={items:l=>ac(l),item:l=>uc(l),itemFile:(l,i)=>pc(l,i),marketplaces:()=>cc(),featured:()=>lc(),sources:{list:()=>dc(),add:l=>gc(l),remove:l=>mc(l)}};function w(l){return{get:i=>tn(l,i),detail:()=>rn(l),update:i=>on(l,i),archive:()=>an(l),llmCatalog:()=>nn(l),modelPicker:()=>sn(l),sandboxHealth:()=>cn(l),onboardingComplete:(...i)=>Ts(l,...i),tokens:{list:()=>Xa(l),create:i=>Qa(l,i),revoke:i=>Ya(l,i)},setupLinks:{requestSecret:i=>ic(l,i),requestConnector:i=>oc(l,i)},validateManifest:i=>Ps(l,i),gitToken:()=>ws(l),secrets:{list:()=>ri(l),upsert:i=>ni(l,i),remove:i=>ai(l,i),setPersonal:(...i)=>ci(l,...i),removePersonal:i=>li(l,i),promoteToShared:i=>ui(l,i),setGitCredential:i=>oi(l,i),startProviderOAuth:(...i)=>si(l,...i),pollProviderOAuth:(...i)=>ii(l,...i)},access:{list:()=>Ls(l),invite:(...i)=>Bs(l,...i),update:(...i)=>Fs(l,...i),revoke:i=>Gs(l,i),pendingInvites:()=>Ks(l),resendInvite:(...i)=>Hs(l,...i),revokeInvite:(...i)=>Ns(l,...i),requests:()=>Ms(l),approveRequest:(...i)=>Us(l,...i),rejectRequest:(...i)=>Os(l,...i),groupGrants:()=>Ws(l),attachGroupGrant:(...i)=>Vs(l,...i),updateGroupGrant:(...i)=>zs(l,...i),detachGroupGrant:i=>Js(l,i),resourceGrants:{list:()=>Xs(l),create:i=>Qs(l,i),remove:i=>Ys(l,i)}},connectors:{list:()=>yi(l),config:(...i)=>wi(l,...i),create:(...i)=>vi(l,...i),remove:(...i)=>Ci(l,...i),sync:()=>hi(l),setName:(...i)=>_i(l,...i),setCredentialMode:(...i)=>bi(l,...i),setCredential:(...i)=>Ii(l,...i),setSensitive:(...i)=>xi(l,...i),profiles:{list:()=>pi(l),reconcile:(...i)=>di(l,...i),updateCredential:(...i)=>gi(l,...i),revoke:(...i)=>mi(l,...i),activate:(...i)=>fi(l,...i)},policies:{get:(...i)=>ki(l,...i),set:(...i)=>Pi(l,...i)},pipedream:{listApps:(...i)=>Ri(l,...i),connect:(...i)=>Si(l,...i),finalize:(...i)=>ji(l,...i)}},policies:{list:()=>Ai(l),set:(...i)=>Ei(l,...i)},triggers:{list:()=>Po(l),create:(...i)=>wo(l,...i),update:(...i)=>_o(l,...i),remove:(...i)=>So(l,...i),fire:(...i)=>Co(l,...i),setActivation:(...i)=>vo(l,...i)},files:{list:i=>Bi(l,i),read:(i,P)=>Ni(l,i,P),search:(...i)=>Ki(l,...i),archive:(...i)=>Hi(l,...i),history:(...i)=>Xi(l,...i)},git:{commits:()=>Vi(l),commit:i=>zi(l,i),commitDiff:i=>Ji(l,i),branches:()=>Wi(l),versionDiff:(...i)=>Qi(l,...i),inviteCollaborator:(...i)=>ks(l,...i)},changeRequests:{list:()=>Yi(l),get:i=>Zi(l,i),diff:i=>eo(l,i),mergePreview:i=>to(l,i),open:(...i)=>ro(l,...i),merge:(...i)=>no(l,...i),close:(...i)=>so(l,...i),reopen:(...i)=>io(l,...i),requestChanges:(...i)=>oo(l,...i)},sessions:{list:()=>Ie(l),create:i=>je(l,i)},review:{list:i=>Ua(l,i),get:i=>Oa(l,i),submit:i=>La(l,i),act:(...i)=>Fa(l,...i),bulkAct:i=>Ga(l,i)},approvals:{list:i=>Zs(l,i),resolve:(...i)=>ti(l,...i),sessionsNeedingInput:i=>ei(l,i)},gateway:{logs:i=>wa(l,i),log:i=>_a(l,i),overview:i=>Sa(l,i),series:i=>va(l,i),breakdown:i=>Ca(l,i),sessions:i=>Ra(l,i),errors:i=>Ta(l,i),budgets:()=>Ia(l),setBudget:i=>ja(l,i),deleteBudget:i=>Aa(l,i),keys:()=>Ea(l),createKey:i=>$a(l,i),revokeKey:i=>qa(l,i),routing:{get:()=>ba(l),set:i=>xa(l,i),reset:()=>ka(l),preview:i=>Pa(l,i)},playground:(i,P)=>Da(l,i,P)},channels:{slack:{installation:()=>ta(l),connect:i=>ra(l,i),mode:()=>na(l),manifest:()=>sa(l),disconnect:()=>ia(l),getFile:i=>oa(l,i),uploadFile:i=>aa(l,i)},email:{installation:i=>ca(l,i),mode:()=>la(l),connect:i=>ua(l,i),disconnect:i=>pa(l,i),updatePolicy:(...i)=>da(l,...i)},meet:{voices:()=>ga(l),setVoice:i=>ma(l,i),setBotName:i=>fa(l,i),previewVoice:i=>ya(l,i),speak:(i,P,_)=>ha(l,i,P,_)}},updateExperimentalFeature:(...i)=>Cs(l,...i),modelDefaults:{get:()=>Ao(l),set:i=>Eo(l,i),clear:i=>$o(l,i)},setDefaultAgent:i=>Do(l,i),sandbox:{list:()=>Gi(l),snapshots:()=>qi(l),rebuildSnapshot:i=>Di(l,i),fixWithAgent:()=>Mi(l),createTemplate:i=>Ui(l,i),updateTemplate:(...i)=>Oi(l,...i),removeTemplate:i=>Li(l,i),buildTemplate:i=>Fi(l,i),setProvider:i=>Rs(l,i)},setAgentScope:(...i)=>qo(l,...i),session:i=>k(l,i)}}function k(l,i){let P=null,_,D;function A(){if(P)return P;let f=To(l,i);return f&&(P=f),P}async function v(){let f=A();if(f)return f;let S=`${l}
8
+ ${i}`,U=ct.get(S);if(U)return P=await U,P;let K=(async()=>{let M=await Ae(l,i,3e4);if(!M||M.stage!=="ready"||!M.sandbox||!M.opencode_session_id)throw new C(`Session runtime not ready (stage: ${M?.stage??"unknown"})`,{code:"RUNTIME_UNAVAILABLE"});let O=M.sandbox.external_id;if(!O)throw new C("Session sandbox has no external_id \u2014 cannot resolve its runtime URL",{code:"RUNTIME_UNAVAILABLE"});let se=Je(O);return Fn(se,O),{opencodeSessionId:M.opencode_session_id,runtimeUrl:se,sandboxId:O}})();ct.set(S,K);try{return P=await K,P}finally{ct.get(S)===K&&ct.delete(S)}}function T(f){let S=A();if(!S)throw new lt(f);return S}function j(){P=null,jo(l,i)}return{get:f=>yo(l,i,f),update:f=>xo(l,i,f),delete:()=>(j(),ko(l,i)),start:(...f)=>Ae(l,i,...f),restart:()=>(j(),nt(l,i)),stop:()=>(j(),st(l,i)),setSharing:f=>uo(l,i,f),previews:()=>po(l,i),commit:f=>ao(l,i,f),publicShares:{list:()=>go(l,i),create:(...f)=>mo(l,i,...f),revoke:(...f)=>fo(l,i,...f)},audit:(f,S)=>ho(l,i,f,S),transcript:f=>bo(l,i,f),ensureReady:v,health:f=>fc(A()?.runtimeUrl??null,f),previewUrl:(f,S="/")=>$e(f,S,n(T("previewUrl").sandboxId)),proxyUrl:f=>xc(f,n(T("proxyUrl").sandboxId)),setModel:f=>{_=f},setAgent:f=>{D=f},send:async(f,S)=>{let{opencodeSessionId:U,runtimeUrl:K}=await v(),M=S?.model??_,O=S?.agent??D;return ue(K).session.prompt({sessionID:U,parts:[{type:"text",text:f}],...M?{model:M}:{},...O?{agent:O}:{}})},abort:async()=>{let{opencodeSessionId:f,runtimeUrl:S}=await v();return ue(S).session.abort({sessionID:f})},stream:async f=>{let{runtimeUrl:S}=await v();return mn({client:ue(S),onEvent:f.onEvent,onGapRehydrate:f.onGapRehydrate,signal:f.signal})},get runtime(){return ue(T("runtime").runtimeUrl)},files:{list:async f=>Nr(f,(await v()).runtimeUrl),read:async f=>et(f,(await v()).runtimeUrl),readBlob:async f=>tt(f,(await v()).runtimeUrl),status:async()=>Hr((await v()).runtimeUrl),findFiles:async(f,S)=>Wr(f,S,(await v()).runtimeUrl),findText:async f=>Vr(f,(await v()).runtimeUrl),upload:async(f,S,U)=>rt(f,S,U,(await v()).runtimeUrl),create:async f=>zr(f,(await v()).runtimeUrl),copy:async(f,S)=>Jr(f,S,(await v()).runtimeUrl),remove:async f=>Xr(f,(await v()).runtimeUrl),mkdir:async f=>Qr(f,(await v()).runtimeUrl),rename:async(f,S)=>Yr(f,S,(await v()).runtimeUrl)}}}return{config:e,accounts:s,accountInvites:u,projects:d,project:w,session:k,github:g,billing:c,sandboxShares:h,transcribe:Ma,connectStatus:m,marketplace:x,validateToken:bs,runtime:hu}}function xu(){let e=typeof crypto<"u"?crypto:void 0;if(e?.randomUUID)return e.randomUUID();let t=new Uint8Array(16);if(e?.getRandomValues)e.getRandomValues(t);else for(let n=0;n<16;n++)t[n]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=[...t].map(n=>n.toString(16).padStart(2,"0"));return`${r[0]}${r[1]}${r[2]}${r[3]}-${r[4]}${r[5]}-${r[6]}${r[7]}-${r[8]}${r[9]}-${r.slice(10).join("")}`}var Sc={thinking:!1,toolDetails:!0,assistantMetadata:!0};function ku(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Pu(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let r=Math.floor(t/60),n=t%60;return`${r}m ${n.toFixed(0)}s`}function wu(e,t){if(e.type==="text"&&!("synthetic"in e&&e.synthetic))return`${e.text}
9
9
 
10
10
  `;if(e.type==="reasoning")return t.thinking?`> _Thinking:_
11
11
  >
@@ -38,15 +38,15 @@ ${c}
38
38
  ${r.state.error}
39
39
  \`\`\`
40
40
  `),n+=`
41
- `,n}return""}function bu(e,t){if(!t)return`## Assistant
41
+ `,n}return""}function _u(e,t){if(!t)return`## Assistant
42
42
 
43
- `;let r=e.agent?fu(e.agent):"Assistant",n=e.modelID||"",s="";e.time?.completed&&e.time?.created&&(s=yu(e.time.completed-e.time.created));let c=[n,s].filter(Boolean).join(" \xB7 ");return c?`## ${r} (${c})
43
+ `;let r=e.agent?ku(e.agent):"Assistant",n=e.modelID||"",s="";e.time?.completed&&e.time?.created&&(s=Pu(e.time.completed-e.time.created));let c=[n,s].filter(Boolean).join(" \xB7 ");return c?`## ${r} (${c})
44
44
 
45
45
  `:`## ${r}
46
46
 
47
- `}function xu(e,t,r){let n="";e.role==="user"?n+=`## User
47
+ `}function Su(e,t,r){let n="";e.role==="user"?n+=`## User
48
48
 
49
- `:n+=bu(e,r.assistantMetadata);for(let s of t)n+=hu(s,r);return n}function ku(e,t,r=Pc){let n=`# ${e.title||"Untitled Session"}
49
+ `:n+=_u(e,r.assistantMetadata);for(let s of t)n+=wu(s,r);return n}function vu(e,t,r=Sc){let n=`# ${e.title||"Untitled Session"}
50
50
 
51
51
  `;n+=`**Session ID:** \`${e.id}\`
52
52
  `,n+=`**Created:** ${new Date(e.time.created).toLocaleString()}
@@ -54,11 +54,11 @@ ${r.state.error}
54
54
 
55
55
  `,n+=`---
56
56
 
57
- `;for(let s of t)n+=xu(s.info,s.parts,r),n+=`---
57
+ `;for(let s of t)n+=Su(s.info,s.parts,r),n+=`---
58
58
 
59
- `;return n}function Pu(e,t){return`session-${e}.md`}function W(e){if(!e)return"An error occurred";if(typeof e=="string"){let t=e.startsWith("Error: ")?e.slice(7):e;try{let r=JSON.parse(t);if(typeof r=="string"){t=r;try{let n=JSON.parse(t);return ct(n)||t}catch{return t}}return ct(r)||t}catch{return wu(t)??t}}return typeof e=="object"?ct(e)||"An error occurred":String(e)}function wu(e){let t=e.indexOf("{"),r=e.lastIndexOf("}");if(!(t===-1||r===-1||r<=t))try{let n=JSON.parse(e.slice(t,r+1));return ct(n)}catch{return}}function ct(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(typeof t.message=="string"&&t.message)return t.message;if(typeof t.error=="string"&&t.error)return t.error;let r=t.data;if(typeof r?.message=="string")return r.message;let n=t.error;if(typeof n?.message=="string")return n.message}var _u={bash:{label:"Shell",category:"shell"},pty_spawn:{label:"Spawn Terminal",category:"shell"},pty_read:{label:"Terminal Output",category:"shell"},pty_write:{label:"Terminal Input",category:"shell"},pty_input:{label:"Terminal Input",category:"shell"},pty_kill:{label:"Kill Process",category:"shell"},read:{label:"Read File",category:"files"},list:{label:"List Directory",category:"files"},ls:{label:"List Directory",category:"files"},write:{label:"Write File",category:"edit"},edit:{label:"Edit File",category:"edit"},multiedit:{label:"Edit File",category:"edit"},morph_edit:{label:"Edit File",category:"edit"},apply_patch:{label:"Apply Patch",category:"edit"},patch:{label:"Apply Patch",category:"edit"},grep:{label:"Search Code",category:"search"},glob:{label:"Find Files",category:"search"},image_search:{label:"Image Search",category:"search"},session_search:{label:"Search Sessions",category:"search"},webfetch:{label:"Fetch Page",category:"web"},scrape_webpage:{label:"Scrape Page",category:"web"},websearch:{label:"Web Search",category:"web"},web_search:{label:"Web Search",category:"web"},image_gen:{label:"Generate Image",category:"web"},video_gen:{label:"Generate Video",category:"web"},task:{label:"Delegate to Agent",category:"task"},todowrite:{label:"Plan Tasks",category:"task"},todoread:{label:"Read Plan",category:"task"},question:{label:"Ask Question",category:"task"},presentation_gen:{label:"Presentation",category:"task"},show:{label:"Show Output",category:"task"},show_user:{label:"Show Output",category:"task"},prune:{label:"Prune Context",category:"other"},distill:{label:"Distill Context",category:"other"},compress:{label:"Compress Context",category:"other"},context_info:{label:"Context Info",category:"other"}},Su=[{prefix:"pty_",category:"shell"},{prefix:"agent_",category:"task"},{prefix:"session_",category:"task"},{prefix:"task_",category:"task"},{prefix:"trigger_",category:"task"},{prefix:"project_",category:"task"}];function vu(e){return e.replace(/^oc[-_]/,"")}function lt(e){return vu(e).replace(/-/g,"_")}function mn(e){return lt(e).split(/[_\s]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function fn(e){let t=lt(e),r=_u[t];if(r)return r;for(let{prefix:n,category:s}of Su)if(t.startsWith(n))return{label:mn(e),category:s};return{label:mn(e),category:"other"}}var Cu=256*1024;function Ru(e){switch(e.status){case"pending":return"pending";case"running":return"running";case"completed":return"done";case"error":return"error";default:return e}}function Tu(e){if(e===void 0)return{};if(e.length>Cu)return{outputText:e};try{return{outputParsed:JSON.parse(e),outputText:e}}catch{return{outputText:e}}}function Iu(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r=t.success===!1,n=t.error,s=typeof n=="string"&&n.length>0||typeof n=="object"&&n!==null;if(!(!r&&!s))return s?W(n):typeof t.message=="string"&&t.message?t.message:"Tool reported failure"}function ju(e,t){let r="title"in t?t.title:void 0,n=t.status==="completed"?t.output:void 0,{outputParsed:s,outputText:c}=Tu(n),u=Ru(t),d=t.status==="error"?t.error:void 0;if(u==="done"){let g=Iu(s);g&&(u="error",d=g)}return{name:e,title:r||fn(e).label,status:u,input:t.input,output:n,outputParsed:s,outputText:c,error:d}}function Au(e){return{kind:"text",id:e.id,text:e.text,synthetic:!!e.synthetic}}function Eu(e){return{kind:"reasoning",id:e.id,text:e.text}}function $u(e){return{kind:"tool",id:e.id,tool:ju(e.tool,e.state)}}function qu(e){let t=e.mime;return{kind:"file",id:e.id,filename:e.filename,mime:t,url:e.url,isImage:t.startsWith("image/"),isPdf:t==="application/pdf"}}function Du(e){return{kind:"subtask",id:e.id,description:e.description,agent:e.agent,prompt:e.prompt,model:e.model}}function Mu(e){return{kind:"patch",id:e.id,hash:e.hash,files:e.files,fileCount:e.files.length}}function Uu(e){return{kind:"snapshot",id:e.id,snapshot:e.snapshot}}function Ou(e){return{kind:"agent",id:e.id,name:e.name}}function Lu(e){return{kind:"retry",id:e.id,attempt:e.attempt,message:W(e.error),createdAt:e.time.created}}function Fu(e){return{kind:"compaction",id:e.id,auto:e.auto,overflow:!!e.overflow,tailStartId:e.tail_start_id}}function Gu(e){return{kind:"step",id:e.id,phase:"start",snapshot:e.snapshot}}function Bu(e){return{kind:"step",id:e.id,phase:"finish",snapshot:e.snapshot,reason:e.reason,cost:e.cost,tokens:e.tokens}}function wc(e){switch(e.type){case"text":return Au(e);case"reasoning":return Eu(e);case"tool":return $u(e);case"file":return qu(e);case"subtask":return Du(e);case"patch":return Mu(e);case"snapshot":return Uu(e);case"agent":return Ou(e);case"retry":return Lu(e);case"compaction":return Fu(e);case"step-start":return Gu(e);case"step-finish":return Bu(e);default:return{kind:"unknown",raw:e}}}function Ku(e){return e?{name:typeof e=="object"&&"name"in e&&typeof e.name=="string"?e.name:"Error",message:W(e)}:void 0}function Nu(e){switch(e.kind){case"text":case"reasoning":return e.text.trim().length>0;case"step":return!1;default:return!0}}function Hu(e){let t=e.parts.map(wc),r=e.info.role==="assistant"?e.info.error:void 0,n=Ku(r),s=!n&&!t.some(Nu);return{parts:t,error:n,isEmpty:s}}function te(e){return e.type==="text"}function yn(e){return e.type==="reasoning"}function Y(e){return e.type==="tool"}function Wu(e){return e.type==="file"}function xh(e){return e.type==="agent"}function kh(e){return e.type==="compaction"}function Ph(e){return e.type==="snapshot"}function wh(e){return e.type==="patch"}function _h(e){if(te(e)||yn(e))return e.text}function Vu(e){if(!Wu(e))return!1;let t=e.mime;return t.startsWith("image/")||t==="application/pdf"}function Sh(e){let t=[],r=[];for(let n of e)Vu(n)?t.push(n):r.push(n);return{attachments:t,stickyParts:r}}function vh(e,t){let r=[];return e?.tool&&r.push(e.tool),t?.tool&&r.push(t.tool),r}function Ch(e,t,r){return r.some(n=>n.messageID===t&&n.callID===e.callID)}var zu=new Set(["todoread","context_info"]);function Ju(e){return!zu.has(e.tool)}function Rh(e){let t=e.tool||"";if(t==="task"||t==="agent_spawn"||t==="agent-spawn"||t==="agent_message"||t==="agent-message"||t==="agent_task"||t==="agent-task"||t==="agent_task_update"||t==="agent-task-update"||t==="agent_task_message"||t==="agent-task-message"||t==="agent_task_start"||t==="agent-task-start"||t==="task_create"||t==="task-create"||t==="task_start"||t==="task-start"||t==="task_update"||t==="task-update"||t==="task_message"||t==="task-message"){let n=e.state?.metadata?.sessionId;if(typeof n=="string"&&n)return n;let s=e.state?.title;if(s){let u=s.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}let c=e.state?.output;if(c){let u=c.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}return}let r=e.tool?.replace(/-/g,"_")||"";if(r==="session_spawn"||r==="session_start_background"){let n=e.state?.output;if(n){let s=n.match(/\*?\*?Session:?\*?\*?\s*(ses_[a-zA-Z0-9]+)/);if(s)return s[1]}return}}function Th(e){if(e)for(let t=e.length-1;t>=0;t--){let r=e[t]?.info;if(r?.role==="assistant"&&r.error)return W(r.error)}}function Ih(e){let t=[];for(let r of e)if(r.info.role==="assistant")for(let n of r.parts)Y(n)&&Ju(n)&&t.push(n);return t}function jh(e,t={}){switch(e){case"read":return{icon:"glasses",title:"Read",subtitle:Xu(t.filePath)};case"list":return{icon:"list",title:"List",subtitle:Qu(t.path)};case"glob":return{icon:"search",title:"Glob",subtitle:t.pattern};case"grep":return{icon:"search",title:"Grep",subtitle:t.pattern};case"webfetch":return{icon:"globe",title:"Web Fetch",subtitle:t.url};case"websearch":case"web-search":case"web_search":return{icon:"search",title:"Web Search",subtitle:t.query};case"scrape-webpage":return{icon:"globe",title:"Scrape",subtitle:t.urls?.split?.(",")[0]};case"image-search":return{icon:"image",title:"Image Search",subtitle:t.query};case"image-gen":return{icon:"image",title:"Image Gen",subtitle:t.prompt?.slice?.(0,40)};case"video-gen":return{icon:"cpu",title:"Video Gen",subtitle:t.prompt?.slice?.(0,40)};case"presentation-gen":{let r=t.action||"";return{icon:"presentation",title:{create_slide:"Create Slide",list_slides:"List Slides",preview:"Preview",export_pdf:"Export PDF",export_pptx:"Export PPTX"}[r]||"Presentation",subtitle:t.slide_title||t.presentation_name}}case"show":case"show-user":return{icon:"globe",title:"Output",subtitle:t.title||t.description};case"task":return{icon:"square-kanban",title:`Agent (${t.subagent_type||"task"})`,subtitle:Yu(t)};case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":case"oc-session_spawn":case"oc-session-spawn":case"oc-session_start_background":case"oc-session-start-background":return{icon:"square-kanban",title:`Worker (${t.agent||"KortixWorker"})`,subtitle:t.description||t.prompt?.slice(0,60)};case"bash":return{icon:"terminal",title:"Shell",subtitle:t.description};case"edit":case"morph_edit":return{icon:"file-pen",title:"Edit",subtitle:_c(t.filePath)};case"write":return{icon:"file-pen",title:"Write",subtitle:_c(t.filePath)};case"apply_patch":return{icon:"file-pen",title:"Patch",subtitle:t.files?.length?`${t.files.length} file${t.files.length>1?"s":""}`:void 0};case"todowrite":return{icon:"check-square",title:"Todos"};case"todoread":return{icon:"check-square",title:"Todos (read)"};case"question":return{icon:"message-circle",title:"Questions"};case"prune":return{icon:"scissors",title:"DCP Prune",subtitle:t.reason};case"distill":return{icon:"scissors",title:"DCP Distill"};case"compress":return{icon:"scissors",title:"DCP Compress",subtitle:t.topic};case"context_info":return{icon:"scissors",title:"Context Info"};case"session_read":case"session-read":case"oc-session_read":case"oc-session-read":return{icon:"glasses",title:`Session Read (${t.mode||"summary"})`,subtitle:t.session_id?.slice(-12)};case"session_search":case"session-search":case"oc-session_search":case"oc-session-search":return{icon:"search",title:"Session Search",subtitle:t.query};case"session_message":case"session-message":case"oc-session_message":case"oc-session-message":return{icon:"message-circle",title:"Message \u2192 Session",subtitle:t.session_id?.slice(-12)};case"session_lineage":case"session-lineage":case"oc-session_lineage":case"oc-session-lineage":return{icon:"list-tree",title:"Session Lineage",subtitle:t.session_id?.slice(-12)};case"session_list_background":case"session-list-background":case"session_list_spawned":case"session-list-spawned":case"oc-session_list_background":case"oc-session-list-background":case"oc-session_list_spawned":case"oc-session-list-spawned":return{icon:"layers",title:"Background Sessions",subtitle:t.project||"all"};case"session_stats":case"session-stats":case"oc-session_stats":case"oc-session-stats":return{icon:"layers",title:"Session Stats",subtitle:t.session_id?.slice(-12)||"current"};case"session_list":case"session-list":case"oc-session_list":case"oc-session-list":return{icon:"list",title:"Session List",subtitle:t.search};case"session_get":case"session-get":case"oc-session_get":case"oc-session-get":return{icon:"book-open",title:"Session Get",subtitle:t.session_id?.slice(-12)};case"session_context":case"session-context":case"oc-session_context":case"oc-session-context":return{icon:"book-open",title:"Session Context",subtitle:t.session_id?.slice(-12)};case"project_delete":case"project-delete":case"oc-project_delete":case"oc-project-delete":return{icon:"trash-2",title:"Workspace Delete Disabled",subtitle:t.project};case"project_list":case"project-list":case"oc-project_list":case"oc-project-list":return{icon:"folder",title:"Projects"};case"project_get":case"project-get":case"oc-project_get":case"oc-project-get":case"project_update":case"project-update":case"oc-project_update":case"oc-project-update":return{icon:"folder",title:"Project",subtitle:t.name||t.project};case"project_select":case"project-select":case"oc-project_select":case"oc-project-select":return{icon:"folder",title:"Project Select",subtitle:t.project};case"project_create":case"project-create":case"oc-project_create":case"oc-project-create":return{icon:"folder-plus",title:"Project Create",subtitle:t.name};case"triggers":case"trigger_create":case"trigger-create":case"oc-trigger_create":case"oc-trigger-create":return{icon:"clock",title:"Create Trigger",subtitle:t.name};case"trigger_list":case"trigger-list":case"oc-trigger_list":case"oc-trigger-list":return{icon:"clock",title:"List Triggers"};case"trigger_get":case"trigger-get":case"oc-trigger_get":case"oc-trigger-get":return{icon:"clock",title:"Trigger Details",subtitle:t.name||t.id};case"trigger_delete":case"trigger-delete":case"oc-trigger_delete":case"oc-trigger-delete":return{icon:"clock",title:"Delete Trigger",subtitle:t.name||t.id};case"trigger_update":case"trigger-update":case"oc-trigger_update":case"oc-trigger-update":return{icon:"clock",title:"Update Trigger",subtitle:t.name||t.id};case"trigger_test":case"trigger-test":case"oc-trigger_test":case"oc-trigger-test":return{icon:"clock",title:"Test Trigger",subtitle:t.name||t.id};case"trigger_pause":case"trigger-pause":case"oc-trigger_pause":case"oc-trigger-pause":return{icon:"clock",title:"Pause Trigger",subtitle:t.name||t.id};case"trigger_resume":case"trigger-resume":case"oc-trigger_resume":case"oc-trigger-resume":return{icon:"clock",title:"Resume Trigger",subtitle:t.name||t.id};case"agent_spawn":case"agent-spawn":return{icon:"cpu",title:`Agent (${t.agent_type||"worker"})`,subtitle:t.description};case"agent_message":case"agent-message":return{icon:"message-circle",title:"Agent Message",subtitle:t.agent_id};case"agent_stop":case"agent-stop":return{icon:"ban",title:"Agent Stop",subtitle:t.agent_id};case"agent_status":case"agent-status":return{icon:"layers",title:"Agent Status"};case"agent_task":case"agent-task":case"oc-agent_task":case"oc-agent-task":return{icon:"check-square",title:"Create Task",subtitle:t.title};case"agent_task_update":case"agent-task-update":case"oc-agent_task_update":case"oc-agent-task-update":return{icon:"check-square",title:"Update Task",subtitle:t.task_id};case"agent_task_list":case"agent-task-list":case"oc-agent_task_list":case"oc-agent-task-list":return{icon:"check-square",title:"List Tasks"};case"agent_task_get":case"agent-task-get":case"oc-agent_task_get":case"oc-agent-task-get":return{icon:"check-square",title:"Task Details",subtitle:t.task_id};case"task_create":case"task-create":return{icon:"plus",title:"Create Task",subtitle:t.title};case"task_list":case"task-list":return{icon:"list",title:"Tasks",subtitle:t.status||"all"};case"task_update":case"task-update":return{icon:"refresh-cw",title:"Update Task",subtitle:t.id};case"task_done":case"task-done":return{icon:"check-circle",title:"Task Done",subtitle:t.id};case"task_delete":case"task-delete":return{icon:"trash-2",title:"Delete Task",subtitle:t.id};case"pty_spawn":return{icon:"terminal",title:"Spawn",subtitle:t.title||t.command};case"pty_read":return{icon:"terminal",title:"Terminal Output",subtitle:t.id};case"pty_write":case"pty_input":return{icon:"terminal",title:"Terminal Input",subtitle:t.id};case"pty_kill":return{icon:"terminal",title:"Kill Process",subtitle:t.id};default:return{icon:"cpu",title:e}}}function Xu(e){if(!e)return;let t=e.split("/");return t[t.length-1]||e}function _c(e){if(!e)return;let t=e.split("/"),r=t[t.length-1]||e;if(t.length<=1)return r;let n=t[t.length-2];return n?`${r} /${n}`:r}function Qu(e){if(!e)return;let t=e.lastIndexOf("/");if(!(t<0))return e.slice(0,t)||"/"}function Ah(e,t){if(!t)return e;if(e.startsWith(t)){let r=e.slice(t.length);return r.startsWith("/")?r.slice(1):r}return e}function $e(e,t=120){if(typeof e!="string")return"";let r=e.split(`
60
- `).map(n=>n.trim()).find(Boolean);return r?r.length>t?`${r.slice(0,t).trim()}\u2026`:r:""}function Yu(e){let t=$e(e.description);if(t)return t;let r=$e(e.title,80);if(r)return r;let n=$e(e.message);if(n)return n;let s=$e(e.prompt);if(s)return s;let c=$e(e.agent_id,40);return c?`Agent ${c}`:"Worker task"}function Eh(e,t){return!e||!t?[]:(e[t]??[]).filter(n=>n.severity===1).slice(0,3)}function $h(e,t){return e.find(r=>r.tool?.callID===t)}function qh(e,t){return e.find(r=>r.tool?.callID===t)}var Zu=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function Dh(e){return e?e.replace(Zu,""):""}function Oh(e){let t=[],r=new Map;for(let s of e)if(s.info.role==="user"){if(r.has(s.info.id))continue;let c={userMessage:s,assistantMessages:[]};t.push(c),r.set(s.info.id,c)}let n=null;for(let s of e){if(s.info.role==="user"){n=r.get(s.info.id)??null;continue}if(s.info.role!=="assistant")continue;let c=s.info;if(c.parentID){let d=r.get(c.parentID);if(d){d.assistantMessages.push(s);continue}}if(n){n.assistantMessages.push(s);continue}if(t.length>0){t[0].assistantMessages.unshift(s);continue}let u={userMessage:s,assistantMessages:[]};t.push(u)}return t}function Lh(e){let t=[];for(let r of e.assistantMessages)for(let n of r.parts)t.push({part:n,message:r});return t}function Fh(e){for(let t=e.length-1;t>=0;t--){let r=e[t].part;if(te(r)&&r.text?.trim())return r}}function Gh(e){return e.some(({part:t})=>t.type==="tool"||t.type==="compaction"||t.type==="snapshot"||t.type==="patch")}function Bh(e,t,r){if(r)return[];let n=[];for(let s of e.assistantMessages)for(let c of s.parts){if(!Y(c))continue;let u=c,d=u.state?.metadata?.answers;u.tool==="question"&&(d?.length??0)>0&&n.push({part:c,message:s})}return n}function Kh(e){let t=new Map;for(let r of e){if(!r.parentID)continue;let n=t.get(r.parentID);n?n.push(r.id):t.set(r.parentID,[r.id])}return t}function Nh(e){let t=e-6e4;return(r,n)=>{let s=r.time.updated??r.time.created,c=n.time.updated??n.time.created,u=s>t,d=c>t;return u&&d?r.id<n.id?-1:r.id>n.id?1:0:u&&!d?-1:!u&&d?1:c-s}}function ep(e,t){let r=e.get(t);if(!r||r.length===0)return[];let n=[];for(let s of r)n.push(s),n.push(...ep(e,s));return n}function tp(e){let t=e.userMessage.parts;if(t.length===0||!t.every(c=>te(c)&&c.synthetic)||e.assistantMessages.length!==1)return!1;let n=e.assistantMessages[0].parts;if(n.length!==1)return!1;let s=n[0];return Y(s)&&s.tool==="bash"}function Vh(e){if(tp(e))return e.assistantMessages[0].parts[0]}function Qh(e,t){for(let r=t.length-1;r>=0;r--)if(t[r].info.role==="user")return t[r].info.id===e;return!1}function Yh(e,t){return!t||!e?!1:e.type!=="idle"}function Zh(e,t){return!e&&!!t}function eb(e){for(let t of e.assistantMessages){let r=t.info;if(r.error)return W(r.error)}}function Sc(e){if(e){if(Y(e))switch(e.tool){case"task":case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":return"Delegating to agent...";case"agent_spawn":case"agent-spawn":case"agent_task":case"agent-task":return"Delegating to agent...";case"agent_task_update":case"agent-task-update":case"task_update":case"task-update":return"Updating task...";case"agent_message":case"agent-message":case"agent_task_message":case"agent-task-message":case"task_message":case"task-message":return"Messaging agent...";case"task_create":case"task-create":case"task_start":case"task-start":return"Creating task...";case"task_list":case"task-list":return"Listing tasks...";case"task_done":case"task-done":return"Updating task...";case"todowrite":case"todoread":return"Planning...";case"read":return"Gathering context...";case"list":case"grep":case"glob":return"Searching codebase...";case"webfetch":case"scrape-webpage":return"Fetching web page...";case"websearch":case"web-search":case"web_search":return"Searching web...";case"image-search":return"Searching images...";case"image-gen":return"Generating image...";case"video-gen":return"Generating video...";case"presentation-gen":return"Creating presentation...";case"show":case"show-user":return"Showing output...";case"edit":case"write":case"morph_edit":return"Making edits...";case"bash":return"Running commands...";case"apply_patch":return"Applying patches...";case"prune":return"Pruning context...";case"distill":return"Distilling context...";case"compress":return"Compressing context...";case"context_info":return"Updating context info...";default:return`Running ${e.tool}...`}if(yn(e)){let t=e.text?.trimStart();if(t){let r=t.match(/^\*\*(.+?)\*\*/);if(r)return`Thinking about ${r[1].trim()}...`}return"Thinking..."}if(te(e))return"Gathering thoughts..."}}function tb(e,t){for(let r=e.length-1;r>=0;r--){let n=e[r].part,s=Y(n)?n:void 0;if(s&&(s.tool==="task"||s.tool==="agent_task"||s.tool==="agent-task"||s.tool==="task_create"||s.tool==="task-create"||s.tool==="task_start"||s.tool==="task-start")&&s.state.status==="running"&&t&&t.length>0){for(let u=t.length-1;u>=0;u--){let d=t[u];if(d.info.role==="assistant")for(let g=d.parts.length-1;g>=0;g--){let h=Sc(d.parts[g]);if(h)return h}}return"Delegating to agent..."}let c=Sc(n);if(c)return c}return"Considering next steps..."}function rb(e){if(!Number.isFinite(e)||e<1e3)return"";let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}m ${n}s`:`${r}m`}var vc=1.2;function Cc(e,t){if(!e)return 0;let r=e.input??0,n=(e.output??0)+(e.reasoning??0),s=e.cache?.read??0,c=e.cache?.write??0,d=Math.max(0,r-s-c)/1e6*t.inputPer1M;return d+=n/1e6*t.outputPer1M,s>0&&(d+=s/1e6*(t.cacheReadPer1M??t.inputPer1M)),c>0&&(d+=c/1e6*t.inputPer1M),d}function Rc(e,t,r,n){let s=e.cost||0;if(s>0)return s;if(!n||!t||!r)return 0;let c=n(t,r);return c?Cc(e.tokens,c):0}function Tc(e){if(e.role!=="assistant")return{};let t=e;return{providerID:t.providerID,modelID:t.modelID}}function nb(e,t){let r=0,n=0,s=0,c=0,u=0,d=0,g=!1;for(let{part:h,message:m}of e)if(h.type==="step-finish"){g=!0;let x=h,{providerID:w,modelID:k}=Tc(m.info);r+=Rc(x,w,k,t),n+=x.tokens?.input||0,s+=x.tokens?.output||0,c+=x.tokens?.reasoning||0,u+=x.tokens?.cache?.read||0,d+=x.tokens?.cache?.write||0}if(!g)for(let{message:h}of e){if(h.info.role!=="assistant")continue;let m=h.info,x=Ic(m,t);if(x<=0)continue;g=!0,r+=x;let w=m.tokens;w&&(n+=w.input??0,s+=w.output??0,c+=w.reasoning??0,u+=w.cache?.read??0,d+=w.cache?.write??0)}if(g)return{cost:r*vc,tokens:{input:n,output:s,reasoning:c,cacheRead:u,cacheWrite:d}}}function Ic(e,t){if(!t||!e.providerID||!e.modelID||!e.tokens)return 0;let r=t(e.providerID,e.modelID);return r?Cc({input:e.tokens.input,output:e.tokens.output,reasoning:e.tokens.reasoning,cache:e.tokens.cache},r):0}function sb(e,t){let r=0;for(let n of e){if(n.info?.role!=="assistant")continue;let s=n.info,{providerID:c,modelID:u}=Tc(s),d=0,g=!1;for(let h of n.parts)h.type==="step-finish"&&(g=!0,d+=Rc(h,c,u,t));g||(d+=Ic(s,t)),r+=d}return r*vc}function ib(e){return e===0?"$0.00":e<.001?`$${e.toFixed(4)}`:e<.01?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function ob(e){return e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1)}k`:`${Math.round(e/1e3)}k`}function ab(e){if(!e||e.type!=="retry")return;let t=e;return{attempt:t.attempt,message:t.message.length>60?`${t.message.slice(0,60)}...`:t.message,next:t.next}}function cb(e){if(!(!e||e.type!=="retry"))return W(e.message)}function lb(e){return(e.info.summary?.diffs?.length??0)>0}var rp=4e3;function qe(e,t=rp){return e.length>t?`${e.slice(0,t)}
61
- \u2026`:e}function jc(e){if(e!==void 0)try{return qe(JSON.stringify(e,null,2))}catch{return}}function q(...e){for(let t of e)if(typeof t=="string"&&t.length>0)return t}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function np(e){let t=q(e.input?.query)??"";if(e.status==="error")return{kind:"web-search",query:t,error:e.error??"Search failed"};let r=ge(e.outputParsed);if(!r)return{kind:"web-search",query:t};let s=(Array.isArray(r.results)?r.results:Array.isArray(r.images)?r.images:[]).slice(0,50).map(c=>{let u=ge(c)??{};return{title:q(u.title)??"",url:q(u.url,u.link)??"",snippet:q(u.snippet,u.description,u.source)}});return{kind:"web-search",query:q(r.query)??t,results:s.length>0?s:void 0,answer:q(r.answer)}}var sp=/<exit_code>\s*(-?\d+)\s*<\/exit_code>/;function ip(e,t,r){let n="",s=0;for(;;){let c=e.indexOf(t,s);if(c===-1)return n+e.slice(s);let u=e.indexOf(r,c+t.length);if(u===-1)return n+e.slice(s);n+=e.slice(s,c),s=u+r.length}}var op=["<system_info>","</system_info>","<exit_code>","</exit_code>","<stderr_note>","</stderr_note>"];function ap(e){let t=-1;for(let r of op){let n=e.indexOf(r);n!==-1&&(t===-1||n<t)&&(t=n)}return t===-1?e:e.slice(0,t)}var cp=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function lp(e){return e.replace(cp,"")}function up(e){let t=q(e.input?.command)??"",r=e.output??"",n=r.match(sp),s=n?Number(n[1]):void 0,u=lp(ap(ip(r,"<bash_metadata>","</bash_metadata>"))).trim()||(e.status==="error"?e.error:void 0);return{kind:"shell",command:t,stdout:u||void 0,exitCode:s}}function bn(e){return q(e.input?.filePath,e.input?.file_path,e.input?.path)??""}function pp(e){let t=e.status==="error"?e.error:e.output&&qe(e.output)||void 0;return{kind:"file-read",path:bn(e),preview:t}}function dp(e){let t=q(e.input?.content),r=e.status==="error"?e.error:qe(t??e.output??"")||void 0;return{kind:"file-write",path:bn(e),preview:r}}var gp=256*1024;function mp(e,t){if(e.length+t.length>gp)return;let r=e.split(`
59
+ `;return n}function Cu(e,t){return`session-${e}.md`}function W(e){if(!e)return"An error occurred";if(typeof e=="string"){let t=e.startsWith("Error: ")?e.slice(7):e;try{let r=JSON.parse(t);if(typeof r=="string"){t=r;try{let n=JSON.parse(t);return qe(n)||t}catch{return t}}return qe(r)||t}catch{return Ru(t)??t}}return typeof e=="object"?qe(e)||"An error occurred":String(e)}function Cc(e){let t=e.indexOf("{"),r=e.lastIndexOf("}");if(!(t===-1||r===-1||r<=t))return e.slice(t,r+1)}function Ru(e){let t=Cc(e);if(t)try{return qe(JSON.parse(t))}catch{return}}function qe(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(typeof t.message=="string"&&t.message)return t.message;if(typeof t.error=="string"&&t.error)return t.error;let r=t.data;if(typeof r?.message=="string")return r.message;let n=t.error;if(typeof n?.message=="string")return n.message}function fn(e){if(!(typeof e!="string"||!e))try{return JSON.parse(e)}catch{return}}function vc(e){let t=typeof e.provider=="string"&&e.provider?e.provider:void 0,r=typeof e.code=="string"&&e.code?e.code:void 0,n=typeof e.suggestion=="string"&&e.suggestion?e.suggestion:void 0,s=typeof e.upstream_status=="number"?e.upstream_status:void 0,c=typeof e.request_id=="string"&&e.request_id?e.request_id:void 0;return!t&&!r&&!n&&s===void 0&&!c?void 0:{message:typeof e.message=="string"&&e.message||qe(e)||"",provider:t,code:r,suggestion:n,upstreamStatus:s,requestId:c}}function te(e){if(e==null)return;if(typeof e=="string"){let u=e.startsWith("Error: ")?e.slice(7):e,d=fn(u)??fn(Cc(u));return d!==void 0?te(d):void 0}if(typeof e!="object")return;let t=e,r=vc(t);if(r)return r;let n=t.error;if(n&&typeof n=="object"&&!Array.isArray(n)){let u=vc(n);if(u)return u}let s=t.data;if(s&&typeof s.responseBody=="string"){let u=fn(s.responseBody);if(u!==void 0){let d=te(u);if(d)return d}}let c=t.cause;if(c&&typeof c=="object"){let u=c.body;if(u!==void 0){let d=te(u);if(d)return d}}}var Tu={bash:{label:"Shell",category:"shell"},pty_spawn:{label:"Spawn Terminal",category:"shell"},pty_read:{label:"Terminal Output",category:"shell"},pty_write:{label:"Terminal Input",category:"shell"},pty_input:{label:"Terminal Input",category:"shell"},pty_kill:{label:"Kill Process",category:"shell"},read:{label:"Read File",category:"files"},list:{label:"List Directory",category:"files"},ls:{label:"List Directory",category:"files"},write:{label:"Write File",category:"edit"},edit:{label:"Edit File",category:"edit"},multiedit:{label:"Edit File",category:"edit"},morph_edit:{label:"Edit File",category:"edit"},apply_patch:{label:"Apply Patch",category:"edit"},patch:{label:"Apply Patch",category:"edit"},grep:{label:"Search Code",category:"search"},glob:{label:"Find Files",category:"search"},image_search:{label:"Image Search",category:"search"},session_search:{label:"Search Sessions",category:"search"},webfetch:{label:"Fetch Page",category:"web"},scrape_webpage:{label:"Scrape Page",category:"web"},websearch:{label:"Web Search",category:"web"},web_search:{label:"Web Search",category:"web"},image_gen:{label:"Generate Image",category:"web"},video_gen:{label:"Generate Video",category:"web"},task:{label:"Delegate to Agent",category:"task"},todowrite:{label:"Plan Tasks",category:"task"},todoread:{label:"Read Plan",category:"task"},question:{label:"Ask Question",category:"task"},presentation_gen:{label:"Presentation",category:"task"},show:{label:"Show Output",category:"task"},show_user:{label:"Show Output",category:"task"},prune:{label:"Prune Context",category:"other"},distill:{label:"Distill Context",category:"other"},compress:{label:"Compress Context",category:"other"},context_info:{label:"Context Info",category:"other"}},Iu=[{prefix:"pty_",category:"shell"},{prefix:"agent_",category:"task"},{prefix:"session_",category:"task"},{prefix:"task_",category:"task"},{prefix:"trigger_",category:"task"},{prefix:"project_",category:"task"}];function ju(e){return e.replace(/^oc[-_]/,"")}function ut(e){return ju(e).replace(/-/g,"_")}function yn(e){return ut(e).split(/[_\s]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function hn(e){let t=ut(e),r=Tu[t];if(r)return r;for(let{prefix:n,category:s}of Iu)if(t.startsWith(n))return{label:yn(e),category:s};return{label:yn(e),category:"other"}}var Au=256*1024;function Eu(e){switch(e.status){case"pending":return"pending";case"running":return"running";case"completed":return"done";case"error":return"error";default:return e}}function $u(e){if(e===void 0)return{};if(e.length>Au)return{outputText:e};try{return{outputParsed:JSON.parse(e),outputText:e}}catch{return{outputText:e}}}function qu(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r=t.success===!1,n=t.error,s=typeof n=="string"&&n.length>0||typeof n=="object"&&n!==null;if(!(!r&&!s))return s?W(n):typeof t.message=="string"&&t.message?t.message:"Tool reported failure"}function Du(e,t){let r="title"in t?t.title:void 0,n=t.status==="completed"?t.output:void 0,{outputParsed:s,outputText:c}=$u(n),u=Eu(t),d=t.status==="error"?t.error:void 0;if(u==="done"){let g=qu(s);g&&(u="error",d=g)}return{name:e,title:r||hn(e).label,status:u,input:t.input,output:n,outputParsed:s,outputText:c,error:d}}function Mu(e){return{kind:"text",id:e.id,text:e.text,synthetic:!!e.synthetic}}function Uu(e){return{kind:"reasoning",id:e.id,text:e.text}}function Ou(e){return{kind:"tool",id:e.id,tool:Du(e.tool,e.state)}}function Lu(e){let t=e.mime;return{kind:"file",id:e.id,filename:e.filename,mime:t,url:e.url,isImage:t.startsWith("image/"),isPdf:t==="application/pdf"}}function Fu(e){return{kind:"subtask",id:e.id,description:e.description,agent:e.agent,prompt:e.prompt,model:e.model}}function Gu(e){return{kind:"patch",id:e.id,hash:e.hash,files:e.files,fileCount:e.files.length}}function Bu(e){return{kind:"snapshot",id:e.id,snapshot:e.snapshot}}function Ku(e){return{kind:"agent",id:e.id,name:e.name}}function Nu(e){return{kind:"retry",id:e.id,attempt:e.attempt,message:W(e.error),createdAt:e.time.created}}function Hu(e){return{kind:"compaction",id:e.id,auto:e.auto,overflow:!!e.overflow,tailStartId:e.tail_start_id}}function Wu(e){return{kind:"step",id:e.id,phase:"start",snapshot:e.snapshot}}function Vu(e){return{kind:"step",id:e.id,phase:"finish",snapshot:e.snapshot,reason:e.reason,cost:e.cost,tokens:e.tokens}}function Rc(e){switch(e.type){case"text":return Mu(e);case"reasoning":return Uu(e);case"tool":return Ou(e);case"file":return Lu(e);case"subtask":return Fu(e);case"patch":return Gu(e);case"snapshot":return Bu(e);case"agent":return Ku(e);case"retry":return Nu(e);case"compaction":return Hu(e);case"step-start":return Wu(e);case"step-finish":return Vu(e);default:return{kind:"unknown",raw:e}}}function zu(e){if(!e)return;let t=typeof e=="object"&&"name"in e&&typeof e.name=="string"?e.name:"Error",r=te(e);return{name:t,message:r?.message||W(e),provider:r?.provider,code:r?.code,suggestion:r?.suggestion,upstreamStatus:r?.upstreamStatus,requestId:r?.requestId}}function Ju(e){switch(e.kind){case"text":case"reasoning":return e.text.trim().length>0;case"step":return!1;default:return!0}}function Xu(e){let t=e.parts.map(Rc),r=e.info.role==="assistant"?e.info.error:void 0,n=zu(r),s=!n&&!t.some(Ju);return{parts:t,error:n,isEmpty:s}}function re(e){return e.type==="text"}function bn(e){return e.type==="reasoning"}function Y(e){return e.type==="tool"}function Qu(e){return e.type==="file"}function Sh(e){return e.type==="agent"}function vh(e){return e.type==="compaction"}function Ch(e){return e.type==="snapshot"}function Rh(e){return e.type==="patch"}function Th(e){if(re(e)||bn(e))return e.text}function Yu(e){if(!Qu(e))return!1;let t=e.mime;return t.startsWith("image/")||t==="application/pdf"}function Ih(e){let t=[],r=[];for(let n of e)Yu(n)?t.push(n):r.push(n);return{attachments:t,stickyParts:r}}function jh(e,t){let r=[];return e?.tool&&r.push(e.tool),t?.tool&&r.push(t.tool),r}function Ah(e,t,r){return r.some(n=>n.messageID===t&&n.callID===e.callID)}var Zu=new Set(["todoread","context_info"]);function ep(e){return!Zu.has(e.tool)}function Eh(e){let t=e.tool||"";if(t==="task"||t==="agent_spawn"||t==="agent-spawn"||t==="agent_message"||t==="agent-message"||t==="agent_task"||t==="agent-task"||t==="agent_task_update"||t==="agent-task-update"||t==="agent_task_message"||t==="agent-task-message"||t==="agent_task_start"||t==="agent-task-start"||t==="task_create"||t==="task-create"||t==="task_start"||t==="task-start"||t==="task_update"||t==="task-update"||t==="task_message"||t==="task-message"){let n=e.state?.metadata?.sessionId;if(typeof n=="string"&&n)return n;let s=e.state?.title;if(s){let u=s.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}let c=e.state?.output;if(c){let u=c.match(/\bses_[a-zA-Z0-9]+/);if(u)return u[0]}return}let r=e.tool?.replace(/-/g,"_")||"";if(r==="session_spawn"||r==="session_start_background"){let n=e.state?.output;if(n){let s=n.match(/\*?\*?Session:?\*?\*?\s*(ses_[a-zA-Z0-9]+)/);if(s)return s[1]}return}}function $h(e){if(e)for(let t=e.length-1;t>=0;t--){let r=e[t]?.info;if(r?.role==="assistant"&&r.error)return W(r.error)}}function qh(e){let t=[];for(let r of e)if(r.info.role==="assistant")for(let n of r.parts)Y(n)&&ep(n)&&t.push(n);return t}function Dh(e,t={}){switch(e){case"read":return{icon:"glasses",title:"Read",subtitle:tp(t.filePath)};case"list":return{icon:"list",title:"List",subtitle:rp(t.path)};case"glob":return{icon:"search",title:"Glob",subtitle:t.pattern};case"grep":return{icon:"search",title:"Grep",subtitle:t.pattern};case"webfetch":return{icon:"globe",title:"Web Fetch",subtitle:t.url};case"websearch":case"web-search":case"web_search":return{icon:"search",title:"Web Search",subtitle:t.query};case"scrape-webpage":return{icon:"globe",title:"Scrape",subtitle:t.urls?.split?.(",")[0]};case"image-search":return{icon:"image",title:"Image Search",subtitle:t.query};case"image-gen":return{icon:"image",title:"Image Gen",subtitle:t.prompt?.slice?.(0,40)};case"video-gen":return{icon:"cpu",title:"Video Gen",subtitle:t.prompt?.slice?.(0,40)};case"presentation-gen":{let r=t.action||"";return{icon:"presentation",title:{create_slide:"Create Slide",list_slides:"List Slides",preview:"Preview",export_pdf:"Export PDF",export_pptx:"Export PPTX"}[r]||"Presentation",subtitle:t.slide_title||t.presentation_name}}case"show":case"show-user":return{icon:"globe",title:"Output",subtitle:t.title||t.description};case"task":return{icon:"square-kanban",title:`Agent (${t.subagent_type||"task"})`,subtitle:np(t)};case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":case"oc-session_spawn":case"oc-session-spawn":case"oc-session_start_background":case"oc-session-start-background":return{icon:"square-kanban",title:`Worker (${t.agent||"KortixWorker"})`,subtitle:t.description||t.prompt?.slice(0,60)};case"bash":return{icon:"terminal",title:"Shell",subtitle:t.description};case"edit":case"morph_edit":return{icon:"file-pen",title:"Edit",subtitle:Tc(t.filePath)};case"write":return{icon:"file-pen",title:"Write",subtitle:Tc(t.filePath)};case"apply_patch":return{icon:"file-pen",title:"Patch",subtitle:t.files?.length?`${t.files.length} file${t.files.length>1?"s":""}`:void 0};case"todowrite":return{icon:"check-square",title:"Todos"};case"todoread":return{icon:"check-square",title:"Todos (read)"};case"question":return{icon:"message-circle",title:"Questions"};case"prune":return{icon:"scissors",title:"DCP Prune",subtitle:t.reason};case"distill":return{icon:"scissors",title:"DCP Distill"};case"compress":return{icon:"scissors",title:"DCP Compress",subtitle:t.topic};case"context_info":return{icon:"scissors",title:"Context Info"};case"session_read":case"session-read":case"oc-session_read":case"oc-session-read":return{icon:"glasses",title:`Session Read (${t.mode||"summary"})`,subtitle:t.session_id?.slice(-12)};case"session_search":case"session-search":case"oc-session_search":case"oc-session-search":return{icon:"search",title:"Session Search",subtitle:t.query};case"session_message":case"session-message":case"oc-session_message":case"oc-session-message":return{icon:"message-circle",title:"Message \u2192 Session",subtitle:t.session_id?.slice(-12)};case"session_lineage":case"session-lineage":case"oc-session_lineage":case"oc-session-lineage":return{icon:"list-tree",title:"Session Lineage",subtitle:t.session_id?.slice(-12)};case"session_list_background":case"session-list-background":case"session_list_spawned":case"session-list-spawned":case"oc-session_list_background":case"oc-session-list-background":case"oc-session_list_spawned":case"oc-session-list-spawned":return{icon:"layers",title:"Background Sessions",subtitle:t.project||"all"};case"session_stats":case"session-stats":case"oc-session_stats":case"oc-session-stats":return{icon:"layers",title:"Session Stats",subtitle:t.session_id?.slice(-12)||"current"};case"session_list":case"session-list":case"oc-session_list":case"oc-session-list":return{icon:"list",title:"Session List",subtitle:t.search};case"session_get":case"session-get":case"oc-session_get":case"oc-session-get":return{icon:"book-open",title:"Session Get",subtitle:t.session_id?.slice(-12)};case"session_context":case"session-context":case"oc-session_context":case"oc-session-context":return{icon:"book-open",title:"Session Context",subtitle:t.session_id?.slice(-12)};case"project_delete":case"project-delete":case"oc-project_delete":case"oc-project-delete":return{icon:"trash-2",title:"Workspace Delete Disabled",subtitle:t.project};case"project_list":case"project-list":case"oc-project_list":case"oc-project-list":return{icon:"folder",title:"Projects"};case"project_get":case"project-get":case"oc-project_get":case"oc-project-get":case"project_update":case"project-update":case"oc-project_update":case"oc-project-update":return{icon:"folder",title:"Project",subtitle:t.name||t.project};case"project_select":case"project-select":case"oc-project_select":case"oc-project-select":return{icon:"folder",title:"Project Select",subtitle:t.project};case"project_create":case"project-create":case"oc-project_create":case"oc-project-create":return{icon:"folder-plus",title:"Project Create",subtitle:t.name};case"triggers":case"trigger_create":case"trigger-create":case"oc-trigger_create":case"oc-trigger-create":return{icon:"clock",title:"Create Trigger",subtitle:t.name};case"trigger_list":case"trigger-list":case"oc-trigger_list":case"oc-trigger-list":return{icon:"clock",title:"List Triggers"};case"trigger_get":case"trigger-get":case"oc-trigger_get":case"oc-trigger-get":return{icon:"clock",title:"Trigger Details",subtitle:t.name||t.id};case"trigger_delete":case"trigger-delete":case"oc-trigger_delete":case"oc-trigger-delete":return{icon:"clock",title:"Delete Trigger",subtitle:t.name||t.id};case"trigger_update":case"trigger-update":case"oc-trigger_update":case"oc-trigger-update":return{icon:"clock",title:"Update Trigger",subtitle:t.name||t.id};case"trigger_test":case"trigger-test":case"oc-trigger_test":case"oc-trigger-test":return{icon:"clock",title:"Test Trigger",subtitle:t.name||t.id};case"trigger_pause":case"trigger-pause":case"oc-trigger_pause":case"oc-trigger-pause":return{icon:"clock",title:"Pause Trigger",subtitle:t.name||t.id};case"trigger_resume":case"trigger-resume":case"oc-trigger_resume":case"oc-trigger-resume":return{icon:"clock",title:"Resume Trigger",subtitle:t.name||t.id};case"agent_spawn":case"agent-spawn":return{icon:"cpu",title:`Agent (${t.agent_type||"worker"})`,subtitle:t.description};case"agent_message":case"agent-message":return{icon:"message-circle",title:"Agent Message",subtitle:t.agent_id};case"agent_stop":case"agent-stop":return{icon:"ban",title:"Agent Stop",subtitle:t.agent_id};case"agent_status":case"agent-status":return{icon:"layers",title:"Agent Status"};case"agent_task":case"agent-task":case"oc-agent_task":case"oc-agent-task":return{icon:"check-square",title:"Create Task",subtitle:t.title};case"agent_task_update":case"agent-task-update":case"oc-agent_task_update":case"oc-agent-task-update":return{icon:"check-square",title:"Update Task",subtitle:t.task_id};case"agent_task_list":case"agent-task-list":case"oc-agent_task_list":case"oc-agent-task-list":return{icon:"check-square",title:"List Tasks"};case"agent_task_get":case"agent-task-get":case"oc-agent_task_get":case"oc-agent-task-get":return{icon:"check-square",title:"Task Details",subtitle:t.task_id};case"task_create":case"task-create":return{icon:"plus",title:"Create Task",subtitle:t.title};case"task_list":case"task-list":return{icon:"list",title:"Tasks",subtitle:t.status||"all"};case"task_update":case"task-update":return{icon:"refresh-cw",title:"Update Task",subtitle:t.id};case"task_done":case"task-done":return{icon:"check-circle",title:"Task Done",subtitle:t.id};case"task_delete":case"task-delete":return{icon:"trash-2",title:"Delete Task",subtitle:t.id};case"pty_spawn":return{icon:"terminal",title:"Spawn",subtitle:t.title||t.command};case"pty_read":return{icon:"terminal",title:"Terminal Output",subtitle:t.id};case"pty_write":case"pty_input":return{icon:"terminal",title:"Terminal Input",subtitle:t.id};case"pty_kill":return{icon:"terminal",title:"Kill Process",subtitle:t.id};default:return{icon:"cpu",title:e}}}function tp(e){if(!e)return;let t=e.split("/");return t[t.length-1]||e}function Tc(e){if(!e)return;let t=e.split("/"),r=t[t.length-1]||e;if(t.length<=1)return r;let n=t[t.length-2];return n?`${r} /${n}`:r}function rp(e){if(!e)return;let t=e.lastIndexOf("/");if(!(t<0))return e.slice(0,t)||"/"}function Mh(e,t){if(!t)return e;if(e.startsWith(t)){let r=e.slice(t.length);return r.startsWith("/")?r.slice(1):r}return e}function De(e,t=120){if(typeof e!="string")return"";let r=e.split(`
60
+ `).map(n=>n.trim()).find(Boolean);return r?r.length>t?`${r.slice(0,t).trim()}\u2026`:r:""}function np(e){let t=De(e.description);if(t)return t;let r=De(e.title,80);if(r)return r;let n=De(e.message);if(n)return n;let s=De(e.prompt);if(s)return s;let c=De(e.agent_id,40);return c?`Agent ${c}`:"Worker task"}function Uh(e,t){return!e||!t?[]:(e[t]??[]).filter(n=>n.severity===1).slice(0,3)}function Oh(e,t){return e.find(r=>r.tool?.callID===t)}function Lh(e,t){return e.find(r=>r.tool?.callID===t)}var sp=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function Fh(e){return e?e.replace(sp,""):""}function Kh(e){let t=[],r=new Map;for(let s of e)if(s.info.role==="user"){if(r.has(s.info.id))continue;let c={userMessage:s,assistantMessages:[]};t.push(c),r.set(s.info.id,c)}let n=null;for(let s of e){if(s.info.role==="user"){n=r.get(s.info.id)??null;continue}if(s.info.role!=="assistant")continue;let c=s.info;if(c.parentID){let d=r.get(c.parentID);if(d){d.assistantMessages.push(s);continue}}if(n){n.assistantMessages.push(s);continue}if(t.length>0){t[0].assistantMessages.unshift(s);continue}let u={userMessage:s,assistantMessages:[]};t.push(u)}return t}function Nh(e){let t=[];for(let r of e.assistantMessages)for(let n of r.parts)t.push({part:n,message:r});return t}function Hh(e){for(let t=e.length-1;t>=0;t--){let r=e[t].part;if(re(r)&&r.text?.trim())return r}}function Wh(e){return e.some(({part:t})=>t.type==="tool"||t.type==="compaction"||t.type==="snapshot"||t.type==="patch")}function Vh(e,t,r){if(r)return[];let n=[];for(let s of e.assistantMessages)for(let c of s.parts){if(!Y(c))continue;let u=c,d=u.state?.metadata?.answers;u.tool==="question"&&(d?.length??0)>0&&n.push({part:c,message:s})}return n}function zh(e){let t=new Map;for(let r of e){if(!r.parentID)continue;let n=t.get(r.parentID);n?n.push(r.id):t.set(r.parentID,[r.id])}return t}function Jh(e){let t=e-6e4;return(r,n)=>{let s=r.time.updated??r.time.created,c=n.time.updated??n.time.created,u=s>t,d=c>t;return u&&d?r.id<n.id?-1:r.id>n.id?1:0:u&&!d?-1:!u&&d?1:c-s}}function ip(e,t){let r=e.get(t);if(!r||r.length===0)return[];let n=[];for(let s of r)n.push(s),n.push(...ip(e,s));return n}function op(e){let t=e.userMessage.parts;if(t.length===0||!t.every(c=>re(c)&&c.synthetic)||e.assistantMessages.length!==1)return!1;let n=e.assistantMessages[0].parts;if(n.length!==1)return!1;let s=n[0];return Y(s)&&s.tool==="bash"}function Yh(e){if(op(e))return e.assistantMessages[0].parts[0]}function rb(e,t){for(let r=t.length-1;r>=0;r--)if(t[r].info.role==="user")return t[r].info.id===e;return!1}function nb(e,t){return!t||!e?!1:e.type!=="idle"}function sb(e,t){return!e&&!!t}function ib(e){for(let t of e.assistantMessages){let r=t.info;if(r.error)return W(r.error)}}function ob(e){for(let t of e.assistantMessages){let r=t.info;if(r.error)return te(r.error)}}function Ic(e){if(e){if(Y(e))switch(e.tool){case"task":case"session_spawn":case"session_start_background":case"session-spawn":case"session-start-background":return"Delegating to agent...";case"agent_spawn":case"agent-spawn":case"agent_task":case"agent-task":return"Delegating to agent...";case"agent_task_update":case"agent-task-update":case"task_update":case"task-update":return"Updating task...";case"agent_message":case"agent-message":case"agent_task_message":case"agent-task-message":case"task_message":case"task-message":return"Messaging agent...";case"task_create":case"task-create":case"task_start":case"task-start":return"Creating task...";case"task_list":case"task-list":return"Listing tasks...";case"task_done":case"task-done":return"Updating task...";case"todowrite":case"todoread":return"Planning...";case"read":return"Gathering context...";case"list":case"grep":case"glob":return"Searching codebase...";case"webfetch":case"scrape-webpage":return"Fetching web page...";case"websearch":case"web-search":case"web_search":return"Searching web...";case"image-search":return"Searching images...";case"image-gen":return"Generating image...";case"video-gen":return"Generating video...";case"presentation-gen":return"Creating presentation...";case"show":case"show-user":return"Showing output...";case"edit":case"write":case"morph_edit":return"Making edits...";case"bash":return"Running commands...";case"apply_patch":return"Applying patches...";case"prune":return"Pruning context...";case"distill":return"Distilling context...";case"compress":return"Compressing context...";case"context_info":return"Updating context info...";default:return`Running ${e.tool}...`}if(bn(e)){let t=e.text?.trimStart();if(t){let r=t.match(/^\*\*(.+?)\*\*/);if(r)return`Thinking about ${r[1].trim()}...`}return"Thinking..."}if(re(e))return"Gathering thoughts..."}}function ab(e,t){for(let r=e.length-1;r>=0;r--){let n=e[r].part,s=Y(n)?n:void 0;if(s&&(s.tool==="task"||s.tool==="agent_task"||s.tool==="agent-task"||s.tool==="task_create"||s.tool==="task-create"||s.tool==="task_start"||s.tool==="task-start")&&s.state.status==="running"&&t&&t.length>0){for(let u=t.length-1;u>=0;u--){let d=t[u];if(d.info.role==="assistant")for(let g=d.parts.length-1;g>=0;g--){let h=Ic(d.parts[g]);if(h)return h}}return"Delegating to agent..."}let c=Ic(n);if(c)return c}return"Considering next steps..."}function cb(e){if(!Number.isFinite(e)||e<1e3)return"";let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}m ${n}s`:`${r}m`}var jc=1.2;function Ac(e,t){if(!e)return 0;let r=e.input??0,n=(e.output??0)+(e.reasoning??0),s=e.cache?.read??0,c=e.cache?.write??0,d=Math.max(0,r-s-c)/1e6*t.inputPer1M;return d+=n/1e6*t.outputPer1M,s>0&&(d+=s/1e6*(t.cacheReadPer1M??t.inputPer1M)),c>0&&(d+=c/1e6*t.inputPer1M),d}function Ec(e,t,r,n){let s=e.cost||0;if(s>0)return s;if(!n||!t||!r)return 0;let c=n(t,r);return c?Ac(e.tokens,c):0}function $c(e){if(e.role!=="assistant")return{};let t=e;return{providerID:t.providerID,modelID:t.modelID}}function lb(e,t){let r=0,n=0,s=0,c=0,u=0,d=0,g=!1;for(let{part:h,message:m}of e)if(h.type==="step-finish"){g=!0;let x=h,{providerID:w,modelID:k}=$c(m.info);r+=Ec(x,w,k,t),n+=x.tokens?.input||0,s+=x.tokens?.output||0,c+=x.tokens?.reasoning||0,u+=x.tokens?.cache?.read||0,d+=x.tokens?.cache?.write||0}if(!g)for(let{message:h}of e){if(h.info.role!=="assistant")continue;let m=h.info,x=qc(m,t);if(x<=0)continue;g=!0,r+=x;let w=m.tokens;w&&(n+=w.input??0,s+=w.output??0,c+=w.reasoning??0,u+=w.cache?.read??0,d+=w.cache?.write??0)}if(g)return{cost:r*jc,tokens:{input:n,output:s,reasoning:c,cacheRead:u,cacheWrite:d}}}function qc(e,t){if(!t||!e.providerID||!e.modelID||!e.tokens)return 0;let r=t(e.providerID,e.modelID);return r?Ac({input:e.tokens.input,output:e.tokens.output,reasoning:e.tokens.reasoning,cache:e.tokens.cache},r):0}function ub(e,t){let r=0;for(let n of e){if(n.info?.role!=="assistant")continue;let s=n.info,{providerID:c,modelID:u}=$c(s),d=0,g=!1;for(let h of n.parts)h.type==="step-finish"&&(g=!0,d+=Ec(h,c,u,t));g||(d+=qc(s,t)),r+=d}return r*jc}function pb(e){return e===0?"$0.00":e<.001?`$${e.toFixed(4)}`:e<.01?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function db(e){return e<1e3?String(e):e<1e4?`${(e/1e3).toFixed(1)}k`:`${Math.round(e/1e3)}k`}function gb(e){if(!e||e.type!=="retry")return;let t=e;return{attempt:t.attempt,message:t.message.length>60?`${t.message.slice(0,60)}...`:t.message,next:t.next}}function mb(e){if(!(!e||e.type!=="retry"))return W(e.message)}function fb(e){return(e.info.summary?.diffs?.length??0)>0}var ap=4e3;function Me(e,t=ap){return e.length>t?`${e.slice(0,t)}
61
+ \u2026`:e}function Dc(e){if(e!==void 0)try{return Me(JSON.stringify(e,null,2))}catch{return}}function q(...e){for(let t of e)if(typeof t=="string"&&t.length>0)return t}function me(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function cp(e){let t=q(e.input?.query)??"";if(e.status==="error")return{kind:"web-search",query:t,error:e.error??"Search failed"};let r=me(e.outputParsed);if(!r)return{kind:"web-search",query:t};let s=(Array.isArray(r.results)?r.results:Array.isArray(r.images)?r.images:[]).slice(0,50).map(c=>{let u=me(c)??{};return{title:q(u.title)??"",url:q(u.url,u.link)??"",snippet:q(u.snippet,u.description,u.source)}});return{kind:"web-search",query:q(r.query)??t,results:s.length>0?s:void 0,answer:q(r.answer)}}var lp=/<exit_code>\s*(-?\d+)\s*<\/exit_code>/;function up(e,t,r){let n="",s=0;for(;;){let c=e.indexOf(t,s);if(c===-1)return n+e.slice(s);let u=e.indexOf(r,c+t.length);if(u===-1)return n+e.slice(s);n+=e.slice(s,c),s=u+r.length}}var pp=["<system_info>","</system_info>","<exit_code>","</exit_code>","<stderr_note>","</stderr_note>"];function dp(e){let t=-1;for(let r of pp){let n=e.indexOf(r);n!==-1&&(t===-1||n<t)&&(t=n)}return t===-1?e:e.slice(0,t)}var gp=/\x1B\[[\d;]*[A-Za-z]|\x1B\][^\x07]{0,512}\x07|\x1B[()#][A-Z0-9]|\x1B\[?[\d;]*[hl]|\x1B[>=<]|\x1B\[[?]?\d*[A-Z]|\x1B\[\d*[JKHG]|\x1B\[\d*;\d*[Hf]|\x1b\[[0-9;]*m/g;function mp(e){return e.replace(gp,"")}function fp(e){let t=q(e.input?.command)??"",r=e.output??"",n=r.match(lp),s=n?Number(n[1]):void 0,u=mp(dp(up(r,"<bash_metadata>","</bash_metadata>"))).trim()||(e.status==="error"?e.error:void 0);return{kind:"shell",command:t,stdout:u||void 0,exitCode:s}}function kn(e){return q(e.input?.filePath,e.input?.file_path,e.input?.path)??""}function yp(e){let t=e.status==="error"?e.error:e.output&&Me(e.output)||void 0;return{kind:"file-read",path:kn(e),preview:t}}function hp(e){let t=q(e.input?.content),r=e.status==="error"?e.error:Me(t??e.output??"")||void 0;return{kind:"file-write",path:kn(e),preview:r}}var bp=256*1024;function xp(e,t){if(e.length+t.length>bp)return;let r=e.split(`
62
62
  `),n=t.split(`
63
- `),s=0;for(;s<r.length&&s<n.length&&r[s]===n[s];)s++;let c=r.length,u=n.length;for(;c>s&&u>s&&r[c-1]===n[u-1];)c--,u--;let d=[];for(let g=0;g<s;g++)d.push({type:"unchanged",text:r[g]});for(let g=s;g<c;g++)d.push({type:"removed",text:r[g]});for(let g=s;g<u;g++)d.push({type:"added",text:n[g]});for(let g=c;g<r.length;g++)d.push({type:"unchanged",text:r[g]});return d}function fp(e){let t=q(e.input?.oldString),r=q(e.input?.newString),n=t!==void 0&&r!==void 0?mp(t,r):void 0;return{kind:"file-edit",path:bn(e),diff:n}}var Ec=/^Found\s+(\d+)\s+match/i,yp=/^(\/[^:]+?):\s*/,Ac=/Line\s+(\d+):/g;function hp(e){let t=e.trim(),r=t.match(Ec),n=r?t.slice(r[0].length).trim():t;if(!n)return[];let s=[];for(let c of n.split(/\n\n+/)){let u=c.trim();if(!u)continue;let d=u.match(yp);if(!d)continue;let g=d[1],h=u.slice(d[0].length),m=[],x;for(Ac.lastIndex=0;(x=Ac.exec(h))!==null;)m.push({line:Number(x[1]),contentStart:x.index+x[0].length,headerStart:x.index});for(let w=0;w<m.length;w++){let k=w+1<m.length?m[w+1].headerStart:h.length,l=h.slice(m[w].contentStart,k).trim();s.push({path:g,line:m[w].line,content:l.endsWith(";")?l.slice(0,-1):l})}}return s}function bp(e){return e.trim().split(`
64
- `).map(t=>t.trim()).filter(t=>t.startsWith("/")||t.startsWith("./")||t.startsWith("~")).map(t=>({path:t}))}function xp(e){let t=q(e.input?.pattern,e.input?.query)??"";if(e.status==="error"||!e.output)return{kind:"search",pattern:t};let r=Ec.test(e.output.trim())?hp(e.output):bp(e.output);return{kind:"search",pattern:t,matches:r.length>0?r.slice(0,200):void 0}}function kp(e){let t=q(e.input?.description,e.input?.title,e.input?.prompt)??e.title,r=q(e.input?.subagent_type,e.input?.agent);return{kind:"task",description:t,agent:r}}function hn(e){let t=ge(e)??{};return{content:q(t.content)??"",status:q(t.status)??"pending",priority:q(t.priority)}}function Pp(e){let t=e.input?.todos;if(Array.isArray(t))return{kind:"todo",items:t.map(hn)};if(Array.isArray(e.outputParsed))return{kind:"todo",items:e.outputParsed.map(hn)};let r=ge(e.outputParsed);return r&&Array.isArray(r.todos)?{kind:"todo",items:r.todos.map(hn)}:{kind:"todo",items:[]}}function wp(e){return{kind:"question",questions:(Array.isArray(e.input?.questions)?e.input.questions:[]).map(n=>{let s=ge(n)??{},u=(Array.isArray(s.options)?s.options:[]).flatMap(d=>{let g=ge(d),h=g&&q(g.label);return h?[{label:h,description:g?q(g.description):void 0}]:[]});return{question:q(s.question)??"",header:q(s.header),options:u}})}}function _p(e){let r=e.input&&Object.keys(e.input).length>0?jc(e.input):void 0,n;return e.outputParsed!==void 0?n=typeof e.outputParsed=="string"?qe(e.outputParsed):jc(e.outputParsed):e.outputText!==void 0?n=qe(e.outputText):n=e.error,{kind:"generic",label:e.title,inputPretty:r,outputPretty:n}}function Sp(e){switch(lt(e.name)){case"web_search":case"websearch":case"image_search":return np(e);case"bash":return up(e);case"read":return pp(e);case"write":return dp(e);case"edit":case"morph_edit":return fp(e);case"grep":case"glob":return xp(e);case"task":return kp(e);case"todowrite":return Pp(e);case"question":case"ask":return wp(e);default:return _p(e)}}var ut=[{id:"claude-opus-4.8",name:"Claude Opus 4.8",upstreamModelId:"us.anthropic.claude-opus-4-8",transport:"bedrock",pricingRef:"anthropic/claude-opus-4.8",tier:"flagship",vision:!0,limit:{context:1e6,output:64e3}},{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",upstreamModelId:"us.anthropic.claude-sonnet-4-6",transport:"bedrock",pricingRef:"anthropic/claude-sonnet-4.6",tier:"balanced",vision:!0,limit:{context:1e6,output:64e3}},{id:"glm-5.2",name:"GLM 5.2",upstreamModelId:"z-ai/glm-5.2",transport:"openrouter",pricingRef:"z-ai/glm-5.2",tier:"balanced",vision:!1,limit:{context:1e6,output:131072},openrouterProvider:{order:["z-ai"],allow_fallbacks:!0}},{id:"qwen3.7-max",name:"Qwen3.7 Max",upstreamModelId:"qwen/qwen3.7-max",transport:"openrouter",pricingRef:"qwen/qwen3.7-max",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",upstreamModelId:"deepseek/deepseek-v4-pro",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-pro",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",upstreamModelId:"deepseek/deepseek-v4-flash",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-flash",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}}],gb=new Map(ut.map(e=>[e.id,e]));var mb=ut.map(e=>e.id),fb=(ut.find(e=>e.tier==="flagship")??ut[0]).id;var $c=!1;function pt(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function vp(e,t){if(e==null)return t;let r=e.trim().toLowerCase();return["1","true","yes","y","on"].includes(r)?!0:["0","false","no","n","off"].includes(r)?!1:t}function Pb(e){if(e==null)return;let t=e.trim().toLowerCase();if(["1","true","yes","y","on"].includes(t))return!0;if(["0","false","no","n","off"].includes(t))return!1}function dt(e,t,r){return e!==void 0?e:vp(pt(t),r)}var wb={get disableMobileAdvertising(){return dt(I().featureFlags?.disableMobileAdvertising,"NEXT_PUBLIC_DISABLE_MOBILE_ADVERTISING",!1)},get enableDinoGame(){return dt(I().featureFlags?.enableDinoGame,"NEXT_PUBLIC_ENABLE_DINO_GAME",!1)},get enableProjects(){return dt(I().featureFlags?.enableProjects,"NEXT_PUBLIC_ENABLE_PROJECTS",!1)},get enableAutoModel(){return dt(I().featureFlags?.enableAutoModel,"NEXT_PUBLIC_ENABLE_AUTO_MODEL",$c)}};var gt="kortix-active-instance",Cp=["/dashboard","/agents","/p","/workspace","/settings","/browser","/desktop","/services","/sessions","/terminal","/files","/scheduled-tasks","/commands","/tools","/configuration","/changelog","/legacy","/credits-explained"];function Rp(e){return Cp.some(t=>e===t||e.startsWith(`${t}/`))}function De(e){let t=e.match(/^\/instances\/([^/]+)(?:\/(.*))?$/);if(!t)return null;let r=decodeURIComponent(t[1]),n=t[2]??"";return{instanceId:r,innerPath:n?`/${n}`:""}}function Sb(e){let t=De(e);return!!t&&t.innerPath===""}function vb(e){let t=De(e);return!t||!t.innerPath?e:t.innerPath}function Tp(e,t){if(!e)return t;if(t.startsWith("/")||(t=`/${t}`),t.startsWith("/instances/")){let r=De(t);return r?`/instances/${encodeURIComponent(e)}${r.innerPath}`:t}return Rp(t)?`/instances/${encodeURIComponent(e)}${t}`:t}function Ip(e){return e?De(e)?.instanceId??null:null}function Cb(){return typeof window>"u"?null:Ip(window.location.pathname)||jp()}function jp(){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp(`(?:^|; )${gt}=([^;]+)`));return e?decodeURIComponent(e[1]):null}function Rb(e){if(typeof document>"u")return;let t=r=>{document.cookie=r};if(typeof window<"u"&&window.location.pathname.startsWith("/projects")){t(`${gt}=; Max-Age=0; Path=/; SameSite=Lax`);return}if(!e){t(`${gt}=; Max-Age=0; Path=/; SameSite=Lax`);return}t(`${gt}=${encodeURIComponent(e)}; Path=/; SameSite=Lax`)}function Tb(e,t){return t?Tp(t,e):e}function Ib(e){let t=De(e);return t?t.innerPath||"/dashboard":e}function qc(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e&&typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e??"")}function Ap(e){let t=qc(e).trim();if(!t)return null;let r=[t,t.replace(/^Failed to perform action:\s*/i,"").trim()],n=t.indexOf("{");n>=0&&r.push(t.slice(n));for(let s of r)if(s)try{return JSON.parse(s)}catch{}return null}function Dc(e){let t=Ap(e);if(!t||typeof t!="object")return null;let r=t;return r.name==="ConfigInvalidError"?r:null}function Ab(e){return Dc(e)!==null}function Eb(e){let t=Dc(e);if(t){let s=(t.data?.path??"OpenCode config").replace(/^\/workspace\//,""),c=t.data?.issues?.[0]?.message,u=t.data?.issues?.[0]?.path?.join("."),d=u?.startsWith("permission")?"Remove the invalid permission frontmatter entry or replace it with valid OpenCode permission config.":"Fix the invalid config entry, then restart this session.";return{title:"OpenCode config is invalid",message:`${s} is preventing OpenCode from loading. ${d}`,detail:c?`${u?`${u}: `:""}${c}`:void 0}}return{title:"OpenCode failed to load",message:qc(e)||"The sandbox is running, but OpenCode returned an error."}}function L(){let e=pt("BACKEND_URL")||I().backendUrl;return e||"http://localhost:8008/v1"}function Me(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:void 0}if(Array.isArray(e)){for(let t of e){let r=Me(t);if(r)return r}return}if(e&&typeof e=="object"){let t=e;return Me(t.sandboxId??t.id??t.slug??Object.values(t)[0])}}var Mc=["http://localhost:8008/v1","http://127.0.0.1:8008/v1"];function Uc(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return`${e.slice(0,t)}/platform/local-bridge/status`}function Ep(e){return e==="running"||e==="active"?"active":e==="queued"||e==="branching"||e==="provisioning"?"provisioning":e==="failed"||e==="error"?"error":e==="stopped"||e==="completed"||e==="archived"?"stopped":e||"unknown"}function xn(e,t,r){let n=r?.external_id||t.sandbox_url?.match(/\/p\/([^/]+)\//)?.[1]||t.sandbox_id;return{sandbox_id:r?.sandbox_id||t.sandbox_id||t.session_id,external_id:n,name:t.name||`${e.name} session`,provider:r?.provider||t.sandbox_provider||"daytona",base_url:r?.base_url||t.sandbox_url||(r?.external_id?`${L()}/p/${r.external_id}/${X.KORTIX_MASTER}`:""),status:Ep(r?.status||t.status),metadata:{...t.metadata??{},project_id:e.project_id,session_id:t.session_id,project_name:e.name,runtime_status:r?.status,error:t.error},created_at:r?.created_at||t.created_at,updated_at:r?.updated_at||t.updated_at}}async function kn(){let e=await de(),t=[];for(let r of e){let n=await Te(r.project_id).catch(()=>[]);for(let s of n)t.push({project:r,session:s,runtime:null,sandbox:xn(r,s,null)})}return t.sort((r,n)=>{let s={active:0,provisioning:1,stopped:2,error:3},c=(s[r.sandbox.status]??99)-(s[n.sandbox.status]??99);return c!==0?c:Date.parse(n.sandbox.updated_at)-Date.parse(r.sandbox.updated_at)})}async function re(e){let t=await kn();return e?t.find(r=>r.sandbox.sandbox_id===e||r.sandbox.external_id===e||r.session.session_id===e||r.runtime?.external_id===e)??null:t[0]??null}async function mt(e,t={}){let r={"Content-Type":"application/json",...t.headers},n=t.signal??AbortSignal.timeout(3e4),s=await R(`${L()}${e}`,{...t,headers:r,signal:n}),c=await s.text().catch(()=>{}),u;if(c)try{u=JSON.parse(c)}catch{}if(!s.ok){let d=u?.error||u?.message||u?.detail||c||`Platform API error ${s.status}`,g=new C(d,{status:s.status,code:u?.code||u?.error_code||String(s.status),details:u??(c?{rawText:c}:void 0),response:s,endpoint:e});throw s.status===402&&(g=Se(Object.assign(g,{response:s,status:s.status,data:u}))),g}return u}function Oc(e){if(!e.external_id){if(e.base_url)return e.base_url;throw new Error(`Cannot build sandbox URL: missing external_id for ${e.provider} sandbox "${e.sandbox_id}"`)}return`${L()}/p/${e.external_id}/${X.KORTIX_MASTER}`}function Kb(e,t){return e.external_id?`${L()}/p/${e.external_id}/${t}`:null}async function Jb(){let e=await o.get("/setup/sandbox-providers");if(e.error)throw e.error;return e.data}async function $p(e){let t=await re();if(t)return{sandbox:t.sandbox,created:!1};let n=(await de())[0];if(!n)throw new Error("Create a project before starting a sandbox");let s=await Ie(n.project_id,{...e?.provider?{provider:e.provider}:{}}),c=(await je(n.project_id,s.session_id))?.sandbox??null;return{sandbox:xn(n,s,c),created:!0}}async function Xb(){return(await re().catch(()=>null))?.sandbox??null}async function Qb(e){return{sandbox:(await $p(e)).sandbox}}async function Yb(e){let t=Me(e);return t?(await re(t).catch(()=>null))?.sandbox??null:null}async function Zb(e,t){throw await re(e)?new Error("Renaming project-session sandboxes is not exposed by the current API"):new Error("Project session sandbox not found")}async function ex(e){let t=Me(e);return(await kn().catch(()=>[])).map(n=>n.sandbox).filter(n=>!t||n.sandbox_id===t||n.external_id===t)}async function tx(){if(typeof window>"u")return null;let e=L(),t=Array.from(new Set([e,...Mc]));for(let r of t)try{let n=await fetch(Uc(r),{method:"GET",signal:AbortSignal.timeout(1500),headers:{Accept:"application/json"}});if(!n.ok)continue;let s=await n.json();if(!s.success||s.status!=="ready"||!s.data?.sandbox_id)continue;return s.data}catch{continue}return null}async function rx(e){if(!e)throw new Error("No sandbox selected for workload restart");let t=await re(e);if(!t)throw new Error("Project session sandbox not found");await tt(t.project.project_id,t.session.session_id)}async function nx(e){if(!e)throw new Error("No sandbox selected to stop");let t=await re(e);if(!t)throw new Error("Project session sandbox not found");await rt(t.project.project_id,t.session.session_id)}async function sx(e){throw new Error("Cancellation is not exposed for project-session sandboxes")}async function ix(e){throw new Error("Reactivation is not exposed for project-session sandboxes")}async function ux(e){throw new Error("Sandbox members moved to project access; use project members for project-session sandboxes")}async function px(e,t,r="member"){throw new Error("Sandbox members moved to project access; invite the user to the project instead")}async function dx(e,t){throw new Error("Sandbox members moved to project access; update project access instead")}async function gx(e,t,r){throw new Error("Sandbox members moved to project access; update project access instead")}async function mx(e,t,r){throw new Error("Sandbox member spend caps are not exposed for project-session sandboxes")}async function fx(e){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function yx(e,t){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function hx(e,t,r,n){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function Pn(e,t,r){let n=Oc(e),s=await R(`${ae(n)}${t}`,{signal:AbortSignal.timeout(8e3),headers:{"Content-Type":"application/json"},...r});if(!s.ok){let c=await s.text().catch(()=>"");throw new Error(c||`Request failed (${s.status})`)}return await s.json()}async function bx(e,t){return Pn(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"GET"})}async function xx(e,t,r,n="member"){await Pn(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify({user_id:r,role:n})})}async function kx(e,t,r){await Pn(e,`/kortix/projects/${encodeURIComponent(t)}/members/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Px(e,t){throw new Error("Sandbox invites moved to project access for project-session sandboxes")}async function Sx(e){let t=await mt(`/platform/invites/${encodeURIComponent(e)}`,{method:"GET"});if(!t.success||!t.data)throw new Error(t.error||"Invite not found");return t.data}async function vx(e){let t=await mt(`/platform/invites/${encodeURIComponent(e)}/accept`,{method:"POST"});if(!t.success||!t.data)throw new Error(t.error||"Failed to accept invite");return t.data}async function Cx(e){let t=await mt(`/platform/invites/${encodeURIComponent(e)}/decline`,{method:"POST"});if(!t.success)throw new Error(t.error||"Failed to decline invite")}async function Tx(e){throw new Error("Backups are not exposed for project-session sandboxes")}async function Ix(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function jx(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function Ax(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function $x(e){throw new Error("SSH setup is not exposed for project-session sandboxes")}async function qx(e){throw new Error("SSH connection details are not exposed for project-session sandboxes")}var qp=["pulling","patching","stopping","removing","recreating","restarting","verifying","starting","health_check"];function Ux(e){return qp.includes(e)}async function Ox(e){return{phase:"idle",progress:0,message:"Sandbox image updates are managed by project-session provisioning.",targetVersion:null,previousVersion:null,currentVersion:e?.version??null,error:null,startedAt:null,updatedAt:null}}async function Lx(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/latest${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Version check failed: ${r.status}`);let n=await r.json();try{let s=await Dp(e||"stable");n.changelog=s.find(c=>c.version===n.version)??s[0]??null}catch{n.changelog=null}return n}async function Dp(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/changelog${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Changelog fetch failed: ${r.status}`);return(await r.json()).changelog}async function Fx(){let e=await fetch(`${L()}/platform/sandbox/version/all`,{headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`All versions fetch failed: ${e.status}`);return e.json()}async function Gx(e,t){throw new Error("Sandbox image updates are managed by project-session provisioning")}async function Bx(e){}async function Kx(e){}async function Vx(e){return{serverTypes:[],location:e||"hel1"}}async function zx(e){throw new Error("Retired instance provisioning is unavailable. Create a project session with daytona, platinum, or e2b.")}async function Jx(e){let t=await o.delete(`/platform/sandbox?sandbox_id=${e}`);if(t.error)throw t.error;return t.data}async function Xx(e,t){await o.post("/platform/sandbox/mark-error",{sandbox_id:e,error_message:t},{showErrors:!1,timeout:1e4})}async function Qx(){let e=await o.post("/platform/sandbox/claim-computer",{},{timeout:6e4});if(e.error)throw e.error;return e.data}async function Yx(e){let t=await o.get(`/platform/sandbox/${e}/status`,{showErrors:!1,timeout:1e4});return t.success?t.data??null:null}function Zx(e,t){return`${L()}/platform/sandbox/${e}/provision-stream?token=${encodeURIComponent(t)}`}async function rk(){let e=await o.get("/platform/github-app/status",{showErrors:!1});if(e.error)throw e.error;if(!e.data)throw new Error("GitHub App status request failed");return e.data}async function nk(e={}){let t=await o.post("/platform/github-app/manifest-start",e,{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub App manifest-start request failed");return t.data}async function sk(e){let t=await o.post("/platform/github-app/app",{app_id:e.appId,private_key:e.privateKey,installation_id:e.installationId,slug:e.slug},{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub App configuration request failed");return t.data}async function ik(e){let t=await o.post("/platform/github-app/pat",e,{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub token configuration request failed");return t.data}async function ok(){let e=await o.delete("/platform/github-app",{showErrors:!1});if(e.error)throw e.error;if(!e.data)throw new Error("GitHub App disconnect request failed");return e.data}function Lc(e){try{let t=new URL(e);if(/^\/proxy\/\d+(?:\/|$)/.test(t.pathname))return`${t.origin}/v1/p/auth`;let r=t.pathname.indexOf("/p/");return r!==-1?`${t.origin}${t.pathname.slice(0,r)}/p/auth`:`${t.origin}/v1/p/auth`}catch{return null}}function Mp(e,t){try{let r=new URL(e),n=r.pathname;if(!(/^\/v1\/p\/[^/]+\/\d+(?:\/|$)/.test(n)||/^\/proxy\/\d+(?:\/|$)/.test(n)))return!1;let c=new Set;if(t)try{c.add(new URL(t).origin)}catch{}return typeof window<"u"&&c.add(window.location.origin),c.size===0||c.has(r.origin)}catch{return!1}}function ck(e,t){return Mp(e,t)?(t?Lc(t):null)??Lc(e):null}function lk(e){try{return/^p\d+-[^.]+\./.test(new URL(e).hostname)}catch{return!1}}function uk(e,t){try{let r=new URL(e);return r.searchParams.set("token",t),r.toString()}catch{return e}}export{gt as ACTIVE_INSTANCE_COOKIE,C as ApiError,we as AuthError,oe as BillingError,vc as COST_MARKUP,Pc as DEFAULT_TRANSCRIPT_OPTIONS,qp as DESTRUCTIVE_PHASES,Cp as INSTANCE_SCOPED_ROUTES,dn as PublicSessionShareError,_e as RequestTooLargeError,Br as RuntimeNotReadyError,X as SANDBOX_PORTS,at as SessionNotReadyError,un as SessionStartError,Op as __getConfigResolver,Up as __setConfigResolver,ps as acceptAccountInvite,vx as acceptInvite,Ua as actReviewItem,di as activateConnectionProfile,uc as addMarketplaceSource,px as addSandboxMember,ep as allDescendantIds,uk as appendPreviewToken,Ds as approveProjectAccessRequest,tg as approveTask,on as archiveProject,lg as assignTicket,Hs as attachGroupToProject,R as authenticatedFetch,o as backendApi,Tp as buildInstancePath,ck as buildPreviewAuthEndpoint,Ui as buildSandboxTemplate,By as buildWebProxyUrl,Oa as bulkActReviewItems,cs as cancelAccountInvite,sx as cancelSandbox,Kx as cancelSandboxUpdate,Vo as cancelScheduledChange,No as cancelSubscription,Kh as childMapByParent,Qx as claimComputer,wc as classifyPart,Hu as classifyTurn,jo as clearModelDefault,yf as clearSessionFresh,to as closeChangeRequest,Ug as closeMilestone,Lh as collectTurnParts,pg as commentTicket,so as commitSessionChanges,Sc as computeStatusFromPart,Qo as configureAutoTopup,bt as configureKortix,Bo as confirmCheckoutSession,aa as connectEmail,Zo as connectSlack,rs as createAccount,Za as createAccountAuditWebhook,Ha as createAccountToken,Ix as createBackup,Go as createCheckoutSession,wi as createConnector,ja as createGatewayKey,zx as createInstance,gu as createKortix,Hn as createKortixPty,Dg as createMilestone,Ko as createPortalSession,Ps as createProject,Pg as createProjectAgent,za as createProjectCliToken,ws as createProjectRepo,Js as createProjectResourceGrant,Ie as createProjectSession,xo as createProjectTrigger,Qb as createSandbox,Fa as createSandboxShare,qi as createSandboxTemplate,uo as createSessionPublicShare,Yd as createTask,og as createTicket,ds as declineAccountInvite,Cx as declineInvite,Ax as deleteBackup,_i as deleteConnector,Ng as deleteCredential,Kn as deleteEnv,Ta as deleteGatewayBudget,$s as deleteGitHubInstallation,Jx as deleteInstance,jg as deleteKortixProject,Lg as deleteMilestone,ai as deletePersonalProjectSecret,_g as deleteProjectAgent,Xs as deleteProjectResourceGrant,ii as deleteProjectSecret,ho as deleteProjectSession,Po as deleteProjectTrigger,Mi as deleteSandboxTemplate,rg as deleteTask,dg as deleteTicket,us as describeAccountInvite,Vs as detachGroupFromProject,Wl as detectLocalhostUrls,ca as disconnectEmail,ok as disconnectGitHubApp,ra as disconnectSlack,tx as discoverLocalSandbox,nm as dropClientForUrl,om as dropPublicClientForUrl,xg as ensurePmSession,$p as ensureSandbox,ul as env,Qa as exportAccountAudit,De as extractInstanceRoute,wb as featureFlags,Wf as fetchAccountStateWithToken,Tm as fetchAccountsWithToken,Bi as fetchProjectArchive,Dm as fetchProjectsForAccountWithToken,Cl as files,Fh as findLastTextPart,_o as fireProjectTrigger,$i as fixSandboxWithAgent,ll as formatBillingErrorForUI,ib as formatCost,rb as formatDuration,Eb as formatOpenCodeRuntimeError,ob as formatTokens,ku as formatTranscript,mu as generateSessionId,ns as getAccount,qo as getAccountState,Do as getAccountStateMinimal,jp as getActiveInstanceIdFromCookie,Yu as getAgentCardLabel,Gf as getAgentConfig,Sg as getAgentPersona,Fx as getAllVersions,Bh as getAnsweredQuestionParts,We as getAuthToken,Mn as getAuthTokenWithRetry,Xo as getAutoTopupSettings,Oo as getBillingCreditBreakdown,Fo as getBillingTierConfigurations,Uo as getBillingTransactionsSummary,Lo as getBillingUsageHistory,Xi as getChangeRequest,Qi as getChangeRequestDiff,Yi as getChangeRequestMergePreview,Th as getChildSessionError,Rh as getChildSessionId,Ih as getChildSessionToolParts,Z as getClient,le as getClientForUrl,vi as getConnectStatus,xi as getConnectorConfig,hi as getConnectorPolicies,Ip as getCurrentInstanceIdFromPathname,Cb as getCurrentInstanceIdFromWindow,$o as getDefaultAccountState,Eh as getDiagnostics,Qu as getDirectory,ia as getEmailInstallation,oa as getEmailMode,_c as getFileWithDir,Xu as getFilename,Dp as getFullChangelog,_a as getGatewayBreakdown,Ca as getGatewayBudgets,va as getGatewayErrors,Ia as getGatewayKeys,ka as getGatewayLog,Pa as getGatewayOverview,fa as getGatewayRoutingPolicy,wa as getGatewaySeries,Sa as getGatewaySessions,rk as getGitHubAppStatus,Ts as getGitHubInstallation,vh as getHiddenToolParts,Sx as getInvite,Vx as getJustavpsServerTypes,Rg as getKortixProject,Tg as getKortixProjectBySession,zn as getKortixPtyWebSocketUrl,Lx as getLatestSandboxVersion,$m as getManagedGitStatus,ac as getMarketplaceCatalogItem,cc as getMarketplaceCatalogItemFile,ua as getMeetVoices,$g as getMilestone,To as getModelDefaults,Dc as getOpenCodeConfigInvalidError,_h as getPartText,$h as getPermissionForTool,en as getProject,vg as getProjectActivity,Hi as getProjectCommit,Wi as getProjectCommitDiff,tn as getProjectDetail,Vi as getProjectFileHistory,ks as getProjectGitToken,rn as getProjectLlmCatalog,nn as getProjectModelPicker,an as getProjectSandboxHealth,go as getProjectSession,zo as getProrationPreview,Jb as getProviders,Oy as getProxyBaseUrl,im as getPublicClientForUrl,py as getPublicSessionShare,dy as getPublicSessionShareMessages,qh as getQuestionForTool,ab as getRetryInfo,cb as getRetryMessage,Da as getReviewItem,qx as getSSHConnection,Xb as getSandbox,Yb as getSandboxById,yx as getSandboxMemberScopes,Kb as getSandboxPortUrl,Yx as getSandboxProvisionStatus,Zx as getSandboxProvisionStreamUrl,Ox as getSandboxUpdateStatus,Oc as getSandboxUrl,Vg as getServiceLogs,mo as getSessionAudit,sb as getSessionCost,dc as getSessionHealth,co as getSessionPreviewCandidates,fo as getSessionTranscript,Vh as getShellModePart,na as getSlackChannelFile,Yo as getSlackInstallation,ta as getSlackManifest,ea as getSlackMode,Lr as getSupabaseAccessToken,ke as getSupabaseAccessTokenWithRetry,Jd as getTask,Qd as getTaskStatus,Ty as getTemplate,sg as getTicket,jh as getToolInfo,Pu as getTranscriptFilename,nb as getTurnCost,eb as getTurnError,tb as getTurnStatus,zi as getVersionDiff,fx as getViewerSandboxScopes,Yh as getWorkingState,xx as grantSandboxProjectAccess,Oh as groupMessagesIntoTurns,lb as hasDiffs,Uy as hasLocalhostUrls,Jl as heartbeatGapEvent,mn as humanizeToolName,Iy as installTemplate,He as invalidateTokenCache,os as inviteAccountMember,Fs as inviteProjectMember,bs as inviteRepoCollaborator,wm as isAdminBypassEnabled,xh as isAgentPart,Kl as isAppRouteUrl,Vu as isAttachment,cl as isBillingError,kh as isCompactionPart,xt as isConfigured,Ux as isDestructivePhase,Hy as isExternalUrl,Wu as isFilePart,Sb as isInstanceDetailPath,Rp as isInstanceScopedAppPath,Nm as isInviteSent,Qh as isLastUserMessage,Em as isManagedGithubProject,Ab as isOpenCodeConfigInvalidError,wh as isPatchPart,Gy as isPreviewUrl,zl as isProxiableLocalhostUrl,yn as isReasoningPart,$y as isRuntimeReady,oo as isSessionFresh,jf as isSessionStartError,tp as isShellMode,Ph as isSnapshotPart,lk as isSubdomainPreviewUrl,te as isTextPart,Y as isToolPart,Ch as isToolPartHidden,Ny as isWebProxyUrl,dl as kortixPty,fs as leaveAccount,Rs as linkRepository,Xa as listAccountAudit,Ya as listAccountAuditWebhooks,as as listAccountInvites,is as listAccountMembers,Na as listAccountTokens,ts as listAccounts,Tx as listBackups,Mo as listBillingTransactions,Ji as listChangeRequests,Xf as listChannelBindings,gg as listColumns,ci as listConnectionProfiles,gi as listConnectors,Gg as listCredentialEvents,Fg as listCredentials,Gn as listEnv,oc as listFeaturedMarketplaces,fg as listFields,xa as listGatewayLogs,Is as listGitHubInstallations,js as listGitHubRepositories,As as listGitHubRepositoryBranches,Ig as listKortixProjectSessions,Cg as listKortixProjects,Nn as listKortixPty,sc as listMarketplaceCatalogItems,lc as listMarketplaceSources,ic as listMarketplaces,qg as listMilestoneEvents,Eg as listMilestones,Qs as listPendingApprovals,Gs as listPendingProjectInvites,Si as listPipedreamApps,Us as listProjectAccess,qs as listProjectAccessRequests,kg as listProjectAgents,Ki as listProjectBranches,Va as listProjectCliTokens,Ni as listProjectCommits,Li as listProjectFiles,Ns as listProjectGroupGrants,Ti as listProjectPolicies,zs as listProjectResourceGrants,ji as listProjectSandboxTemplates,Oi as listProjectSandboxes,ei as listProjectSecrets,Te as listProjectSessions,Ai as listProjectSnapshots,bo as listProjectTriggers,de as listProjects,hs as listProjectsForAccount,qa as listReviewItems,ux as listSandboxMembers,bx as listSandboxProjectMembers,La as listSandboxShares,ex as listSandboxes,Wg as listServiceTemplates,Hg as listServices,lo as listSessionPublicShares,Ys as listSessionsNeedingInput,Xd as listTaskEvents,zd as listTasks,hg as listTemplates,ig as listTicketEvents,ng as listTickets,Xx as markInstanceError,io as markSessionFresh,eo as mergeChangeRequest,Xl as narrowChatEvent,Ib as normalizeAppPathname,Wy as normalizeExternalInput,lt as normalizeToolName,Zi as openChangeRequest,gn as openEventStream,Se as parseBillingError,Pb as parseFlagOverride,st as parseLocalhostUrl,Ap as parseOpenCodeErrorPayload,bc as parseSubdomainUrl,Ky as parseWebProxyUrl,Ag as patchKortixProject,Pi as pipedreamConnect,Ri as pipedreamFinalize,I as platformConfig,ni as pollProjectProviderOAuth,ba as previewGatewayRoute,ga as previewMeetVoice,_s as provisionProject,Mm as provisionProjectWithToken,yc as proxyLocalhostUrl,Fy as proxyUrlToInternal,Jo as purchaseCredits,ix as reactivateSandbox,Ho as reactivateSubscription,Gi as readProjectFile,Ei as rebuildProjectSnapshot,li as reconcileConnectionProfile,Jg as reconcileServices,Xg as registerService,Ms as rejectProjectAccessRequest,Ah as relativizePath,tc as removeAccountAuditWebhook,gs as removeAccountMember,Vn as removeKortixPty,pc as removeMarketplaceSource,dx as removeSandboxMember,Zb as renameSandbox,ro as reopenChangeRequest,Og as reopenMilestone,mg as replaceColumns,yg as replaceFields,bg as replaceTemplates,no as requestChangesOnChangeRequest,Km as requestProjectAccess,nc as requestProjectConnector,rc as requestProjectSecret,ls as resendAccountInvite,Ks as resendPendingProjectInvite,sm as resetClient,ha as resetGatewayRoutingPolicy,am as resetPublicClient,Bx as resetSandboxUpdateStatus,Zs as resolveApproval,tt as restartProjectSession,rx as restartSandbox,jx as restoreBackup,Kg as revealCredential,Wa as revokeAccountToken,pi as revokeConnectionProfile,Aa as revokeGatewayKey,Bs as revokePendingProjectInvite,Ls as revokeProjectAccess,Ja as revokeProjectCliToken,Px as revokeSandboxInvite,kx as revokeSandboxProjectAccess,Ga as revokeSandboxShare,po as revokeSessionPublicShare,Ee as rewriteLocalhostUrl,Ea as runGatewayPlayground,Es as saveGitHubInstallation,Wo as scheduleDowngrade,Fi as searchProjectFiles,zg as serviceAction,Af as sessionStartKey,Rb as setActiveInstanceCookie,Pm as setAdminBypass,Ao as setAgentScope,Rd as setBootstrapAuthToken,Cd as setCachedAuthToken,Ci as setConnectorCredential,fi as setConnectorCredentialMode,ki as setConnectorName,bi as setConnectorPolicies,yi as setConnectorSensitive,Bn as setEnv,Ra as setGatewayBudget,ya as setGatewayRoutingPolicy,sk as setGitHubAppFromExisting,ik as setGitHubAppPat,da as setMeetBotName,pa as setMeetVoice,Io as setModelDefault,oi as setPersonalProjectSecret,Cs as setProjectOnboardingComplete,Ii as setProjectPolicies,ao as setProjectSessionSharing,wo as setProjectTriggersActivation,$x as setupSSH,Zh as shouldHideResponsePart,Ju as shouldShowToolPart,Nh as sortSessions,ma as speakInMeeting,Sh as splitUserParts,nk as startGitHubAppManifest,ri as startProjectProviderOAuth,je as startProjectSession,eg as startTask,rt as stopProjectSession,nx as stopSandbox,Dh as stripAnsi,vb as stripInstancePrefix,ae as stripTrailingSlashes,Ma as submitReviewItem,_m as supabaseClient,mi as syncConnectors,cm as systemReload,Tb as toInstanceAwarePath,Ly as toInternalUrl,fn as toolInfo,Sp as toolViewModel,$a as transcribeAudio,Gx as triggerSandboxUpdate,pl as triggersRequest,Gh as turnHasSteps,ug as unassignTicket,W as unwrapError,ec as updateAccountAuditWebhook,ms as updateAccountMemberRole,ss as updateAccountName,Bf as updateAgentConfig,Qf as updateChannelBinding,ui as updateConnectionProfileCredential,la as updateEmailPolicy,Ss as updateExperimentalFeature,Wn as updateKortixPty,Mg as updateMilestone,sn as updateProject,Os as updateProjectAccess,wg as updateProjectAgent,Eo as updateProjectDefaultAgent,Ws as updateProjectGroupGrant,vs as updateProjectSandboxProvider,yo as updateProjectSession,ko as updateProjectTrigger,gx as updateSandboxMemberRole,hx as updateSandboxMemberScope,mx as updateSandboxMemberSpendCap,Di as updateSandboxTemplate,Zd as updateTask,qm as updateTemplateWarmPool,ag as updateTicket,cg as updateTicketStatus,sa as uploadSlackChannelFile,Bg as upsertCredential,si as upsertProjectGitCredential,ti as upsertProjectSecret,xs as validateProjectManifest,ys as validateToken};
63
+ `),s=0;for(;s<r.length&&s<n.length&&r[s]===n[s];)s++;let c=r.length,u=n.length;for(;c>s&&u>s&&r[c-1]===n[u-1];)c--,u--;let d=[];for(let g=0;g<s;g++)d.push({type:"unchanged",text:r[g]});for(let g=s;g<c;g++)d.push({type:"removed",text:r[g]});for(let g=s;g<u;g++)d.push({type:"added",text:n[g]});for(let g=c;g<r.length;g++)d.push({type:"unchanged",text:r[g]});return d}function kp(e){let t=q(e.input?.oldString),r=q(e.input?.newString),n=t!==void 0&&r!==void 0?xp(t,r):void 0;return{kind:"file-edit",path:kn(e),diff:n}}var Uc=/^Found\s+(\d+)\s+match/i,Pp=/^(\/[^:]+?):\s*/,Mc=/Line\s+(\d+):/g;function wp(e){let t=e.trim(),r=t.match(Uc),n=r?t.slice(r[0].length).trim():t;if(!n)return[];let s=[];for(let c of n.split(/\n\n+/)){let u=c.trim();if(!u)continue;let d=u.match(Pp);if(!d)continue;let g=d[1],h=u.slice(d[0].length),m=[],x;for(Mc.lastIndex=0;(x=Mc.exec(h))!==null;)m.push({line:Number(x[1]),contentStart:x.index+x[0].length,headerStart:x.index});for(let w=0;w<m.length;w++){let k=w+1<m.length?m[w+1].headerStart:h.length,l=h.slice(m[w].contentStart,k).trim();s.push({path:g,line:m[w].line,content:l.endsWith(";")?l.slice(0,-1):l})}}return s}function _p(e){return e.trim().split(`
64
+ `).map(t=>t.trim()).filter(t=>t.startsWith("/")||t.startsWith("./")||t.startsWith("~")).map(t=>({path:t}))}function Sp(e){let t=q(e.input?.pattern,e.input?.query)??"";if(e.status==="error"||!e.output)return{kind:"search",pattern:t};let r=Uc.test(e.output.trim())?wp(e.output):_p(e.output);return{kind:"search",pattern:t,matches:r.length>0?r.slice(0,200):void 0}}function vp(e){let t=q(e.input?.description,e.input?.title,e.input?.prompt)??e.title,r=q(e.input?.subagent_type,e.input?.agent);return{kind:"task",description:t,agent:r}}function xn(e){let t=me(e)??{};return{content:q(t.content)??"",status:q(t.status)??"pending",priority:q(t.priority)}}function Cp(e){let t=e.input?.todos;if(Array.isArray(t))return{kind:"todo",items:t.map(xn)};if(Array.isArray(e.outputParsed))return{kind:"todo",items:e.outputParsed.map(xn)};let r=me(e.outputParsed);return r&&Array.isArray(r.todos)?{kind:"todo",items:r.todos.map(xn)}:{kind:"todo",items:[]}}function Rp(e){return{kind:"question",questions:(Array.isArray(e.input?.questions)?e.input.questions:[]).map(n=>{let s=me(n)??{},u=(Array.isArray(s.options)?s.options:[]).flatMap(d=>{let g=me(d),h=g&&q(g.label);return h?[{label:h,description:g?q(g.description):void 0}]:[]});return{question:q(s.question)??"",header:q(s.header),options:u}})}}function Tp(e){let r=e.input&&Object.keys(e.input).length>0?Dc(e.input):void 0,n;return e.outputParsed!==void 0?n=typeof e.outputParsed=="string"?Me(e.outputParsed):Dc(e.outputParsed):e.outputText!==void 0?n=Me(e.outputText):n=e.error,{kind:"generic",label:e.title,inputPretty:r,outputPretty:n}}function Ip(e){switch(ut(e.name)){case"web_search":case"websearch":case"image_search":return cp(e);case"bash":return fp(e);case"read":return yp(e);case"write":return hp(e);case"edit":case"morph_edit":return kp(e);case"grep":case"glob":return Sp(e);case"task":return vp(e);case"todowrite":return Cp(e);case"question":case"ask":return Rp(e);default:return Tp(e)}}var pt=[{id:"claude-opus-4.8",name:"Claude Opus 4.8",upstreamModelId:"us.anthropic.claude-opus-4-8",transport:"bedrock",pricingRef:"anthropic/claude-opus-4.8",tier:"flagship",vision:!0,limit:{context:1e6,output:64e3}},{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",upstreamModelId:"us.anthropic.claude-sonnet-4-6",transport:"bedrock",pricingRef:"anthropic/claude-sonnet-4.6",tier:"balanced",vision:!0,limit:{context:1e6,output:64e3}},{id:"glm-5.2",name:"GLM 5.2",upstreamModelId:"z-ai/glm-5.2",transport:"openrouter",pricingRef:"z-ai/glm-5.2",tier:"balanced",vision:!1,limit:{context:1e6,output:131072},openrouterProvider:{order:["z-ai"],allow_fallbacks:!0}},{id:"qwen3.7-max",name:"Qwen3.7 Max",upstreamModelId:"qwen/qwen3.7-max",transport:"openrouter",pricingRef:"qwen/qwen3.7-max",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",upstreamModelId:"deepseek/deepseek-v4-pro",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-pro",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",upstreamModelId:"deepseek/deepseek-v4-flash",transport:"openrouter",pricingRef:"deepseek/deepseek-v4-flash",tier:"balanced",vision:!1,limit:{context:1048576,output:64e3}}],xb=new Map(pt.map(e=>[e.id,e]));var kb=pt.map(e=>e.id),Pb=(pt.find(e=>e.tier==="flagship")??pt[0]).id;var Oc=!1;function dt(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function jp(e,t){if(e==null)return t;let r=e.trim().toLowerCase();return["1","true","yes","y","on"].includes(r)?!0:["0","false","no","n","off"].includes(r)?!1:t}function Rb(e){if(e==null)return;let t=e.trim().toLowerCase();if(["1","true","yes","y","on"].includes(t))return!0;if(["0","false","no","n","off"].includes(t))return!1}function gt(e,t,r){return e!==void 0?e:jp(dt(t),r)}var Tb={get disableMobileAdvertising(){return gt(I().featureFlags?.disableMobileAdvertising,"NEXT_PUBLIC_DISABLE_MOBILE_ADVERTISING",!1)},get enableDinoGame(){return gt(I().featureFlags?.enableDinoGame,"NEXT_PUBLIC_ENABLE_DINO_GAME",!1)},get enableProjects(){return gt(I().featureFlags?.enableProjects,"NEXT_PUBLIC_ENABLE_PROJECTS",!1)},get enableAutoModel(){return gt(I().featureFlags?.enableAutoModel,"NEXT_PUBLIC_ENABLE_AUTO_MODEL",Oc)}};var mt="kortix-active-instance",Ap=["/dashboard","/agents","/p","/workspace","/settings","/browser","/desktop","/services","/sessions","/terminal","/files","/scheduled-tasks","/commands","/tools","/configuration","/changelog","/legacy","/credits-explained"];function Ep(e){return Ap.some(t=>e===t||e.startsWith(`${t}/`))}function Ue(e){let t=e.match(/^\/instances\/([^/]+)(?:\/(.*))?$/);if(!t)return null;let r=decodeURIComponent(t[1]),n=t[2]??"";return{instanceId:r,innerPath:n?`/${n}`:""}}function jb(e){let t=Ue(e);return!!t&&t.innerPath===""}function Ab(e){let t=Ue(e);return!t||!t.innerPath?e:t.innerPath}function $p(e,t){if(!e)return t;if(t.startsWith("/")||(t=`/${t}`),t.startsWith("/instances/")){let r=Ue(t);return r?`/instances/${encodeURIComponent(e)}${r.innerPath}`:t}return Ep(t)?`/instances/${encodeURIComponent(e)}${t}`:t}function qp(e){return e?Ue(e)?.instanceId??null:null}function Eb(){return typeof window>"u"?null:qp(window.location.pathname)||Dp()}function Dp(){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp(`(?:^|; )${mt}=([^;]+)`));return e?decodeURIComponent(e[1]):null}function $b(e){if(typeof document>"u")return;let t=r=>{document.cookie=r};if(typeof window<"u"&&window.location.pathname.startsWith("/projects")){t(`${mt}=; Max-Age=0; Path=/; SameSite=Lax`);return}if(!e){t(`${mt}=; Max-Age=0; Path=/; SameSite=Lax`);return}t(`${mt}=${encodeURIComponent(e)}; Path=/; SameSite=Lax`)}function qb(e,t){return t?$p(t,e):e}function Db(e){let t=Ue(e);return t?t.innerPath||"/dashboard":e}function Lc(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e&&typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e??"")}function Mp(e){let t=Lc(e).trim();if(!t)return null;let r=[t,t.replace(/^Failed to perform action:\s*/i,"").trim()],n=t.indexOf("{");n>=0&&r.push(t.slice(n));for(let s of r)if(s)try{return JSON.parse(s)}catch{}return null}function Fc(e){let t=Mp(e);if(!t||typeof t!="object")return null;let r=t;return r.name==="ConfigInvalidError"?r:null}function Ub(e){return Fc(e)!==null}function Ob(e){let t=Fc(e);if(t){let s=(t.data?.path??"OpenCode config").replace(/^\/workspace\//,""),c=t.data?.issues?.[0]?.message,u=t.data?.issues?.[0]?.path?.join("."),d=u?.startsWith("permission")?"Remove the invalid permission frontmatter entry or replace it with valid OpenCode permission config.":"Fix the invalid config entry, then restart this session.";return{title:"OpenCode config is invalid",message:`${s} is preventing OpenCode from loading. ${d}`,detail:c?`${u?`${u}: `:""}${c}`:void 0}}return{title:"OpenCode failed to load",message:Lc(e)||"The sandbox is running, but OpenCode returned an error."}}function L(){let e=dt("BACKEND_URL")||I().backendUrl;return e||"http://localhost:8008/v1"}function Oe(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:void 0}if(Array.isArray(e)){for(let t of e){let r=Oe(t);if(r)return r}return}if(e&&typeof e=="object"){let t=e;return Oe(t.sandboxId??t.id??t.slug??Object.values(t)[0])}}var Gc=["http://localhost:8008/v1","http://127.0.0.1:8008/v1"];function Bc(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t--;return`${e.slice(0,t)}/platform/local-bridge/status`}function Up(e){return e==="running"||e==="active"?"active":e==="queued"||e==="branching"||e==="provisioning"?"provisioning":e==="failed"||e==="error"?"error":e==="stopped"||e==="completed"||e==="archived"?"stopped":e||"unknown"}function Pn(e,t,r){let n=r?.external_id||t.sandbox_url?.match(/\/p\/([^/]+)\//)?.[1]||t.sandbox_id;return{sandbox_id:r?.sandbox_id||t.sandbox_id||t.session_id,external_id:n,name:t.name||`${e.name} session`,provider:r?.provider||t.sandbox_provider||"daytona",base_url:r?.base_url||t.sandbox_url||(r?.external_id?`${L()}/p/${r.external_id}/${X.KORTIX_MASTER}`:""),status:Up(r?.status||t.status),metadata:{...t.metadata??{},project_id:e.project_id,session_id:t.session_id,project_name:e.name,runtime_status:r?.status,error:t.error},created_at:r?.created_at||t.created_at,updated_at:r?.updated_at||t.updated_at}}async function wn(){let e=await ge(),t=[];for(let r of e){let n=await Ie(r.project_id).catch(()=>[]);for(let s of n)t.push({project:r,session:s,runtime:null,sandbox:Pn(r,s,null)})}return t.sort((r,n)=>{let s={active:0,provisioning:1,stopped:2,error:3},c=(s[r.sandbox.status]??99)-(s[n.sandbox.status]??99);return c!==0?c:Date.parse(n.sandbox.updated_at)-Date.parse(r.sandbox.updated_at)})}async function ne(e){let t=await wn();return e?t.find(r=>r.sandbox.sandbox_id===e||r.sandbox.external_id===e||r.session.session_id===e||r.runtime?.external_id===e)??null:t[0]??null}async function ft(e,t={}){let r={"Content-Type":"application/json",...t.headers},n=t.signal??AbortSignal.timeout(3e4),s=await R(`${L()}${e}`,{...t,headers:r,signal:n}),c=await s.text().catch(()=>{}),u;if(c)try{u=JSON.parse(c)}catch{}if(!s.ok){let d=u?.error||u?.message||u?.detail||c||`Platform API error ${s.status}`,g=new C(d,{status:s.status,code:u?.code||u?.error_code||String(s.status),details:u??(c?{rawText:c}:void 0),response:s,endpoint:e});throw s.status===402&&(g=ve(Object.assign(g,{response:s,status:s.status,data:u}))),g}return u}function Kc(e){if(!e.external_id){if(e.base_url)return e.base_url;throw new Error(`Cannot build sandbox URL: missing external_id for ${e.provider} sandbox "${e.sandbox_id}"`)}return`${L()}/p/${e.external_id}/${X.KORTIX_MASTER}`}function Jb(e,t){return e.external_id?`${L()}/p/${e.external_id}/${t}`:null}async function tx(){let e=await o.get("/setup/sandbox-providers");if(e.error)throw e.error;return e.data}async function Op(e){let t=await ne();if(t)return{sandbox:t.sandbox,created:!1};let n=(await ge())[0];if(!n)throw new Error("Create a project before starting a sandbox");let s=await je(n.project_id,{...e?.provider?{provider:e.provider}:{}}),c=(await Ae(n.project_id,s.session_id))?.sandbox??null;return{sandbox:Pn(n,s,c),created:!0}}async function rx(){return(await ne().catch(()=>null))?.sandbox??null}async function nx(e){return{sandbox:(await Op(e)).sandbox}}async function sx(e){let t=Oe(e);return t?(await ne(t).catch(()=>null))?.sandbox??null:null}async function ix(e,t){throw await ne(e)?new Error("Renaming project-session sandboxes is not exposed by the current API"):new Error("Project session sandbox not found")}async function ox(e){let t=Oe(e);return(await wn().catch(()=>[])).map(n=>n.sandbox).filter(n=>!t||n.sandbox_id===t||n.external_id===t)}async function ax(){if(typeof window>"u")return null;let e=L(),t=Array.from(new Set([e,...Gc]));for(let r of t)try{let n=await fetch(Bc(r),{method:"GET",signal:AbortSignal.timeout(1500),headers:{Accept:"application/json"}});if(!n.ok)continue;let s=await n.json();if(!s.success||s.status!=="ready"||!s.data?.sandbox_id)continue;return s.data}catch{continue}return null}async function cx(e){if(!e)throw new Error("No sandbox selected for workload restart");let t=await ne(e);if(!t)throw new Error("Project session sandbox not found");await nt(t.project.project_id,t.session.session_id)}async function lx(e){if(!e)throw new Error("No sandbox selected to stop");let t=await ne(e);if(!t)throw new Error("Project session sandbox not found");await st(t.project.project_id,t.session.session_id)}async function ux(e){throw new Error("Cancellation is not exposed for project-session sandboxes")}async function px(e){throw new Error("Reactivation is not exposed for project-session sandboxes")}async function yx(e){throw new Error("Sandbox members moved to project access; use project members for project-session sandboxes")}async function hx(e,t,r="member"){throw new Error("Sandbox members moved to project access; invite the user to the project instead")}async function bx(e,t){throw new Error("Sandbox members moved to project access; update project access instead")}async function xx(e,t,r){throw new Error("Sandbox members moved to project access; update project access instead")}async function kx(e,t,r){throw new Error("Sandbox member spend caps are not exposed for project-session sandboxes")}async function Px(e){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function wx(e,t){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function _x(e,t,r,n){throw new Error("Sandbox scopes moved to project access for project-session sandboxes")}async function _n(e,t,r){let n=Kc(e),s=await R(`${ce(n)}${t}`,{signal:AbortSignal.timeout(8e3),headers:{"Content-Type":"application/json"},...r});if(!s.ok){let c=await s.text().catch(()=>"");throw new Error(c||`Request failed (${s.status})`)}return await s.json()}async function Sx(e,t){return _n(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"GET"})}async function vx(e,t,r,n="member"){await _n(e,`/kortix/projects/${encodeURIComponent(t)}/members`,{method:"POST",body:JSON.stringify({user_id:r,role:n})})}async function Cx(e,t,r){await _n(e,`/kortix/projects/${encodeURIComponent(t)}/members/${encodeURIComponent(r)}`,{method:"DELETE"})}async function Rx(e,t){throw new Error("Sandbox invites moved to project access for project-session sandboxes")}async function jx(e){let t=await ft(`/platform/invites/${encodeURIComponent(e)}`,{method:"GET"});if(!t.success||!t.data)throw new Error(t.error||"Invite not found");return t.data}async function Ax(e){let t=await ft(`/platform/invites/${encodeURIComponent(e)}/accept`,{method:"POST"});if(!t.success||!t.data)throw new Error(t.error||"Failed to accept invite");return t.data}async function Ex(e){let t=await ft(`/platform/invites/${encodeURIComponent(e)}/decline`,{method:"POST"});if(!t.success)throw new Error(t.error||"Failed to decline invite")}async function qx(e){throw new Error("Backups are not exposed for project-session sandboxes")}async function Dx(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function Mx(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function Ux(e,t){throw new Error("Backups are not exposed for project-session sandboxes")}async function Lx(e){throw new Error("SSH setup is not exposed for project-session sandboxes")}async function Fx(e){throw new Error("SSH connection details are not exposed for project-session sandboxes")}var Lp=["pulling","patching","stopping","removing","recreating","restarting","verifying","starting","health_check"];function Kx(e){return Lp.includes(e)}async function Nx(e){return{phase:"idle",progress:0,message:"Sandbox image updates are managed by project-session provisioning.",targetVersion:null,previousVersion:null,currentVersion:e?.version??null,error:null,startedAt:null,updatedAt:null}}async function Hx(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/latest${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Version check failed: ${r.status}`);let n=await r.json();try{let s=await Fp(e||"stable");n.changelog=s.find(c=>c.version===n.version)??s[0]??null}catch{n.changelog=null}return n}async function Fp(e){let t=e?`?channel=${e}`:"",r=await fetch(`${L()}/platform/sandbox/version/changelog${t}`,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Changelog fetch failed: ${r.status}`);return(await r.json()).changelog}async function Wx(){let e=await fetch(`${L()}/platform/sandbox/version/all`,{headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`All versions fetch failed: ${e.status}`);return e.json()}async function Vx(e,t){throw new Error("Sandbox image updates are managed by project-session provisioning")}async function zx(e){}async function Jx(e){}async function Zx(e){return{serverTypes:[],location:e||"hel1"}}async function ek(e){throw new Error("Retired instance provisioning is unavailable. Create a project session with daytona, platinum, or e2b.")}async function tk(e){let t=await o.delete(`/platform/sandbox?sandbox_id=${e}`);if(t.error)throw t.error;return t.data}async function rk(e,t){await o.post("/platform/sandbox/mark-error",{sandbox_id:e,error_message:t},{showErrors:!1,timeout:1e4})}async function nk(){let e=await o.post("/platform/sandbox/claim-computer",{},{timeout:6e4});if(e.error)throw e.error;return e.data}async function sk(e){let t=await o.get(`/platform/sandbox/${e}/status`,{showErrors:!1,timeout:1e4});return t.success?t.data??null:null}function ik(e,t){return`${L()}/platform/sandbox/${e}/provision-stream?token=${encodeURIComponent(t)}`}async function ck(){let e=await o.get("/platform/github-app/status",{showErrors:!1});if(e.error)throw e.error;if(!e.data)throw new Error("GitHub App status request failed");return e.data}async function lk(e={}){let t=await o.post("/platform/github-app/manifest-start",e,{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub App manifest-start request failed");return t.data}async function uk(e){let t=await o.post("/platform/github-app/app",{app_id:e.appId,private_key:e.privateKey,installation_id:e.installationId,slug:e.slug},{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub App configuration request failed");return t.data}async function pk(e){let t=await o.post("/platform/github-app/pat",e,{showErrors:!1});if(t.error)throw t.error;if(!t.data)throw new Error("GitHub token configuration request failed");return t.data}async function dk(){let e=await o.delete("/platform/github-app",{showErrors:!1});if(e.error)throw e.error;if(!e.data)throw new Error("GitHub App disconnect request failed");return e.data}function Nc(e){try{let t=new URL(e);if(/^\/proxy\/\d+(?:\/|$)/.test(t.pathname))return`${t.origin}/v1/p/auth`;let r=t.pathname.indexOf("/p/");return r!==-1?`${t.origin}${t.pathname.slice(0,r)}/p/auth`:`${t.origin}/v1/p/auth`}catch{return null}}function Gp(e,t){try{let r=new URL(e),n=r.pathname;if(!(/^\/v1\/p\/[^/]+\/\d+(?:\/|$)/.test(n)||/^\/proxy\/\d+(?:\/|$)/.test(n)))return!1;let c=new Set;if(t)try{c.add(new URL(t).origin)}catch{}return typeof window<"u"&&c.add(window.location.origin),c.size===0||c.has(r.origin)}catch{return!1}}function mk(e,t){return Gp(e,t)?(t?Nc(t):null)??Nc(e):null}function fk(e){try{return/^p\d+-[^.]+\./.test(new URL(e).hostname)}catch{return!1}}function yk(e,t){try{let r=new URL(e);return r.searchParams.set("token",t),r.toString()}catch{return e}}export{mt as ACTIVE_INSTANCE_COOKIE,C as ApiError,_e as AuthError,ae as BillingError,jc as COST_MARKUP,Sc as DEFAULT_TRANSCRIPT_OPTIONS,Lp as DESTRUCTIVE_PHASES,Ap as INSTANCE_SCOPED_ROUTES,gn as PublicSessionShareError,Se as RequestTooLargeError,Kr as RuntimeNotReadyError,X as SANDBOX_PORTS,lt as SessionNotReadyError,pn as SessionStartError,Kp as __getConfigResolver,Bp as __setConfigResolver,gs as acceptAccountInvite,Ax as acceptInvite,Fa as actReviewItem,fi as activateConnectionProfile,gc as addMarketplaceSource,hx as addSandboxMember,ip as allDescendantIds,yk as appendPreviewToken,Us as approveProjectAccessRequest,og as approveTask,an as archiveProject,mg as assignTicket,Vs as attachGroupToProject,R as authenticatedFetch,o as backendApi,$p as buildInstancePath,mk as buildPreviewAuthEndpoint,Fi as buildSandboxTemplate,Vy as buildWebProxyUrl,Ga as bulkActReviewItems,us as cancelAccountInvite,ux as cancelSandbox,Jx as cancelSandboxUpdate,Xo as cancelScheduledChange,Vo as cancelSubscription,zh as childMapByParent,nk as claimComputer,Rc as classifyPart,Xu as classifyTurn,$o as clearModelDefault,Pf as clearSessionFresh,so as closeChangeRequest,Bg as closeMilestone,Nh as collectTurnParts,yg as commentTicket,ao as commitSessionChanges,Ic as computeStatusFromPart,ea as configureAutoTopup,xt as configureKortix,Ho as confirmCheckoutSession,ua as connectEmail,ra as connectSlack,ss as createAccount,rc as createAccountAuditWebhook,za as createAccountToken,Dx as createBackup,No as createCheckoutSession,vi as createConnector,$a as createGatewayKey,ek as createInstance,bu as createKortix,Vn as createKortixPty,Fg as createMilestone,Wo as createPortalSession,_s as createProject,Cg as createProjectAgent,Qa as createProjectCliToken,Ss as createProjectRepo,Qs as createProjectResourceGrant,je as createProjectSession,wo as createProjectTrigger,nx as createSandbox,Ka as createSandboxShare,Ui as createSandboxTemplate,mo as createSessionPublicShare,ng as createTask,pg as createTicket,ms as declineAccountInvite,Ex as declineInvite,Ux as deleteBackup,Ci as deleteConnector,Jg as deleteCredential,Hn as deleteEnv,Aa as deleteGatewayBudget,Ds as deleteGitHubInstallation,tk as deleteInstance,Dg as deleteKortixProject,Ng as deleteMilestone,li as deletePersonalProjectSecret,Tg as deleteProjectAgent,Ys as deleteProjectResourceGrant,ai as deleteProjectSecret,ko as deleteProjectSession,So as deleteProjectTrigger,Li as deleteSandboxTemplate,ag as deleteTask,hg as deleteTicket,ds as describeAccountInvite,Js as detachGroupFromProject,Ql as detectLocalhostUrls,pa as disconnectEmail,dk as disconnectGitHubApp,ia as disconnectSlack,ax as discoverLocalSandbox,cm as dropClientForUrl,pm as dropPublicClientForUrl,Sg as ensurePmSession,Op as ensureSandbox,fl as env,ec as exportAccountAudit,te as extractGatewayErrorDetails,Ue as extractInstanceRoute,Tb as featureFlags,Qf as fetchAccountStateWithToken,$m as fetchAccountsWithToken,Hi as fetchProjectArchive,Fm as fetchProjectsForAccountWithToken,Al as files,Hh as findLastTextPart,Co as fireProjectTrigger,Mi as fixSandboxWithAgent,ml as formatBillingErrorForUI,pb as formatCost,cb as formatDuration,Ob as formatOpenCodeRuntimeError,db as formatTokens,vu as formatTranscript,xu as generateSessionId,is as getAccount,Uo as getAccountState,Oo as getAccountStateMinimal,Dp as getActiveInstanceIdFromCookie,np as getAgentCardLabel,Wf as getAgentConfig,Ig as getAgentPersona,Wx as getAllVersions,Vh as getAnsweredQuestionParts,ze as getAuthToken,On as getAuthTokenWithRetry,Zo as getAutoTopupSettings,Go as getBillingCreditBreakdown,Ko as getBillingTierConfigurations,Fo as getBillingTransactionsSummary,Bo as getBillingUsageHistory,Zi as getChangeRequest,eo as getChangeRequestDiff,to as getChangeRequestMergePreview,$h as getChildSessionError,Eh as getChildSessionId,qh as getChildSessionToolParts,Z as getClient,ue as getClientForUrl,Ti as getConnectStatus,wi as getConnectorConfig,ki as getConnectorPolicies,qp as getCurrentInstanceIdFromPathname,Eb as getCurrentInstanceIdFromWindow,Mo as getDefaultAccountState,Uh as getDiagnostics,rp as getDirectory,ca as getEmailInstallation,la as getEmailMode,Tc as getFileWithDir,tp as getFilename,Fp as getFullChangelog,Ca as getGatewayBreakdown,Ia as getGatewayBudgets,Ta as getGatewayErrors,Ea as getGatewayKeys,_a as getGatewayLog,Sa as getGatewayOverview,ba as getGatewayRoutingPolicy,va as getGatewaySeries,Ra as getGatewaySessions,ck as getGitHubAppStatus,js as getGitHubInstallation,jh as getHiddenToolParts,jx as getInvite,Zx as getJustavpsServerTypes,Eg as getKortixProject,$g as getKortixProjectBySession,Xn as getKortixPtyWebSocketUrl,Hx as getLatestSandboxVersion,Om as getManagedGitStatus,uc as getMarketplaceCatalogItem,pc as getMarketplaceCatalogItemFile,ga as getMeetVoices,Og as getMilestone,Ao as getModelDefaults,Fc as getOpenCodeConfigInvalidError,Th as getPartText,Oh as getPermissionForTool,tn as getProject,jg as getProjectActivity,zi as getProjectCommit,Ji as getProjectCommitDiff,rn as getProjectDetail,Xi as getProjectFileHistory,ws as getProjectGitToken,nn as getProjectLlmCatalog,sn as getProjectModelPicker,cn as getProjectSandboxHealth,yo as getProjectSession,Qo as getProrationPreview,tx as getProviders,Ky as getProxyBaseUrl,um as getPublicClientForUrl,yy as getPublicSessionShare,hy as getPublicSessionShareMessages,Lh as getQuestionForTool,gb as getRetryInfo,mb as getRetryMessage,Oa as getReviewItem,Fx as getSSHConnection,rx as getSandbox,sx as getSandboxById,wx as getSandboxMemberScopes,Jb as getSandboxPortUrl,sk as getSandboxProvisionStatus,ik as getSandboxProvisionStreamUrl,Nx as getSandboxUpdateStatus,Kc as getSandboxUrl,Yg as getServiceLogs,ho as getSessionAudit,ub as getSessionCost,fc as getSessionHealth,po as getSessionPreviewCandidates,bo as getSessionTranscript,Yh as getShellModePart,oa as getSlackChannelFile,ta as getSlackInstallation,sa as getSlackManifest,na as getSlackMode,Fr as getSupabaseAccessToken,Pe as getSupabaseAccessTokenWithRetry,eg as getTask,rg as getTaskStatus,$y as getTemplate,lg as getTicket,Dh as getToolInfo,Cu as getTranscriptFilename,lb as getTurnCost,ib as getTurnError,ob as getTurnErrorDetails,ab as getTurnStatus,Qi as getVersionDiff,Px as getViewerSandboxScopes,nb as getWorkingState,vx as grantSandboxProjectAccess,Kh as groupMessagesIntoTurns,fb as hasDiffs,By as hasLocalhostUrls,eu as heartbeatGapEvent,yn as humanizeToolName,qy as installTemplate,Ve as invalidateTokenCache,cs as inviteAccountMember,Bs as inviteProjectMember,ks as inviteRepoCollaborator,Rm as isAdminBypassEnabled,Sh as isAgentPart,zl as isAppRouteUrl,Yu as isAttachment,gl as isBillingError,vh as isCompactionPart,kt as isConfigured,Kx as isDestructivePhase,Xy as isExternalUrl,Qu as isFilePart,jb as isInstanceDetailPath,Ep as isInstanceScopedAppPath,Jm as isInviteSent,rb as isLastUserMessage,Um as isManagedGithubProject,Ub as isOpenCodeConfigInvalidError,Rh as isPatchPart,Wy as isPreviewUrl,Zl as isProxiableLocalhostUrl,bn as isReasoningPart,Oy as isRuntimeReady,lo as isSessionFresh,Df as isSessionStartError,op as isShellMode,Ch as isSnapshotPart,fk as isSubdomainPreviewUrl,re as isTextPart,Y as isToolPart,Ah as isToolPartHidden,Jy as isWebProxyUrl,hl as kortixPty,hs as leaveAccount,Is as linkRepository,Za as listAccountAudit,tc as listAccountAuditWebhooks,ls as listAccountInvites,as as listAccountMembers,Va as listAccountTokens,ns as listAccounts,qx as listBackups,Lo as listBillingTransactions,Yi as listChangeRequests,ty as listChannelBindings,bg as listColumns,pi as listConnectionProfiles,yi as listConnectors,Wg as listCredentialEvents,Hg as listCredentials,Kn as listEnv,lc as listFeaturedMarketplaces,kg as listFields,wa as listGatewayLogs,As as listGitHubInstallations,Es as listGitHubRepositories,$s as listGitHubRepositoryBranches,qg as listKortixProjectSessions,Ag as listKortixProjects,Wn as listKortixPty,ac as listMarketplaceCatalogItems,dc as listMarketplaceSources,cc as listMarketplaces,Lg as listMilestoneEvents,Ug as listMilestones,Zs as listPendingApprovals,Ks as listPendingProjectInvites,Ri as listPipedreamApps,Ls as listProjectAccess,Ms as listProjectAccessRequests,vg as listProjectAgents,Wi as listProjectBranches,Xa as listProjectCliTokens,Vi as listProjectCommits,Bi as listProjectFiles,Ws as listProjectGroupGrants,Ai as listProjectPolicies,Xs as listProjectResourceGrants,$i as listProjectSandboxTemplates,Gi as listProjectSandboxes,ri as listProjectSecrets,Ie as listProjectSessions,qi as listProjectSnapshots,Po as listProjectTriggers,ge as listProjects,xs as listProjectsForAccount,Ua as listReviewItems,yx as listSandboxMembers,Sx as listSandboxProjectMembers,Ba as listSandboxShares,ox as listSandboxes,Qg as listServiceTemplates,Xg as listServices,go as listSessionPublicShares,ei as listSessionsNeedingInput,tg as listTaskEvents,Zd as listTasks,wg as listTemplates,ug as listTicketEvents,cg as listTickets,rk as markInstanceError,co as markSessionFresh,no as mergeChangeRequest,tu as narrowChatEvent,Db as normalizeAppPathname,Qy as normalizeExternalInput,ut as normalizeToolName,ro as openChangeRequest,mn as openEventStream,ve as parseBillingError,Rb as parseFlagOverride,ot as parseLocalhostUrl,Mp as parseOpenCodeErrorPayload,Pc as parseSubdomainUrl,zy as parseWebProxyUrl,Mg as patchKortixProject,Si as pipedreamConnect,ji as pipedreamFinalize,I as platformConfig,ii as pollProjectProviderOAuth,Pa as previewGatewayRoute,ya as previewMeetVoice,ui as promoteProjectSecretToShared,vs as provisionProject,Gm as provisionProjectWithToken,xc as proxyLocalhostUrl,Hy as proxyUrlToInternal,Yo as purchaseCredits,px as reactivateSandbox,zo as reactivateSubscription,Ni as readProjectFile,Di as rebuildProjectSnapshot,di as reconcileConnectionProfile,em as reconcileServices,tm as registerService,Os as rejectProjectAccessRequest,Mh as relativizePath,sc as removeAccountAuditWebhook,fs as removeAccountMember,Jn as removeKortixPty,mc as removeMarketplaceSource,bx as removeSandboxMember,ix as renameSandbox,io as reopenChangeRequest,Kg as reopenMilestone,xg as replaceColumns,Pg as replaceFields,_g as replaceTemplates,oo as requestChangesOnChangeRequest,zm as requestProjectAccess,oc as requestProjectConnector,ic as requestProjectSecret,ps as resendAccountInvite,Hs as resendPendingProjectInvite,lm as resetClient,ka as resetGatewayRoutingPolicy,dm as resetPublicClient,zx as resetSandboxUpdateStatus,ti as resolveApproval,nt as restartProjectSession,cx as restartSandbox,Mx as restoreBackup,zg as revealCredential,Ja as revokeAccountToken,mi as revokeConnectionProfile,qa as revokeGatewayKey,Ns as revokePendingProjectInvite,Gs as revokeProjectAccess,Ya as revokeProjectCliToken,Rx as revokeSandboxInvite,Cx as revokeSandboxProjectAccess,Na as revokeSandboxShare,fo as revokeSessionPublicShare,$e as rewriteLocalhostUrl,Da as runGatewayPlayground,qs as saveGitHubInstallation,Jo as scheduleDowngrade,Ki as searchProjectFiles,Zg as serviceAction,Mf as sessionStartKey,$b as setActiveInstanceCookie,Cm as setAdminBypass,qo as setAgentScope,Ed as setBootstrapAuthToken,Ad as setCachedAuthToken,Ii as setConnectorCredential,bi as setConnectorCredentialMode,_i as setConnectorName,Pi as setConnectorPolicies,xi as setConnectorSensitive,Nn as setEnv,ja as setGatewayBudget,xa as setGatewayRoutingPolicy,uk as setGitHubAppFromExisting,pk as setGitHubAppPat,fa as setMeetBotName,ma as setMeetVoice,Eo as setModelDefault,ci as setPersonalProjectSecret,Ts as setProjectOnboardingComplete,Ei as setProjectPolicies,uo as setProjectSessionSharing,vo as setProjectTriggersActivation,Lx as setupSSH,sb as shouldHideResponsePart,ep as shouldShowToolPart,Jh as sortSessions,ha as speakInMeeting,Ih as splitUserParts,lk as startGitHubAppManifest,si as startProjectProviderOAuth,Ae as startProjectSession,ig as startTask,st as stopProjectSession,lx as stopSandbox,Fh as stripAnsi,Ab as stripInstancePrefix,ce as stripTrailingSlashes,La as submitReviewItem,Tm as supabaseClient,hi as syncConnectors,gm as systemReload,qb as toInstanceAwarePath,Ny as toInternalUrl,hn as toolInfo,Ip as toolViewModel,Ma as transcribeAudio,Vx as triggerSandboxUpdate,yl as triggersRequest,Wh as turnHasSteps,fg as unassignTicket,W as unwrapError,nc as updateAccountAuditWebhook,ys as updateAccountMemberRole,os as updateAccountName,Vf as updateAgentConfig,ry as updateChannelBinding,gi as updateConnectionProfileCredential,da as updateEmailPolicy,Cs as updateExperimentalFeature,zn as updateKortixPty,Gg as updateMilestone,on as updateProject,Fs as updateProjectAccess,Rg as updateProjectAgent,Do as updateProjectDefaultAgent,zs as updateProjectGroupGrant,Rs as updateProjectSandboxProvider,xo as updateProjectSession,_o as updateProjectTrigger,xx as updateSandboxMemberRole,_x as updateSandboxMemberScope,kx as updateSandboxMemberSpendCap,Oi as updateSandboxTemplate,sg as updateTask,Lm as updateTemplateWarmPool,dg as updateTicket,gg as updateTicketStatus,aa as uploadSlackChannelFile,Vg as upsertCredential,oi as upsertProjectGitCredential,ni as upsertProjectSecret,Ps as validateProjectManifest,bs as validateToken};