@muxcodecli/cli 1.15.18 → 1.15.19

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.
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Ar as N,Dr as W,Op as g,gq as O,xp as h,yr as de}from"./chunk-a0srn4ak.js";import{us as ie,xs as v}from"./chunk-8jy0dvcn.js";import{AF as s,Fx as $,Hz as le,Yz as d,eC as o}from"./chunk-1mqsg5s7.js";import{SF as se}from"./chunk-8j3aw4qg.js";function _e(e){let r,t=!1,i=()=>{if(t)return r;return r=e(),t=!0,r};return i.reset=()=>{t=!1,r=void 0},i.loaded=()=>t,i}var V={};se(V,{resolveAll:()=>me,resolve:()=>he,referencePath:()=>ge,layer:()=>pe,defaultLayer:()=>We,Service:()=>A,Reference:()=>V});import _ from"path";import Y from"path";import{fileURLToPath as Ee}from"url";class w extends s.TaggedErrorClass()("RepositoryInvalidReferenceError",{repository:s.String,message:s.String}){}class C extends s.TaggedErrorClass()("RepositoryUnsupportedLocalRepositoryError",{repository:s.String,message:s.String}){}class k extends s.TaggedErrorClass()("RepositoryInvalidBranchError",{branch:s.String,message:s.String}){}function ee(e){return e.trim().replace(/^git\+/,"").replace(/#.*$/,"").replace(/\/+$/,"")}function M(e){return e.replace(/\.git$/,"")}function q(e){return e.split("/").map((r)=>M(r.trim())).filter(Boolean)}function Se(e){return Boolean(e)&&!e.startsWith("-")&&!/[\s/\\]/.test(e)}function ve(e){return e!=="."&&e!==".."&&!e.includes(":")&&!/[\s/\\]/.test(e)}function we(e){return e.includes(".")||e.includes(":")||e==="localhost"}function Ce(e){return e.endsWith("/")?e:`${e}/`}function re(e){let r=process.env.MUXCODE_REPO_CLONE_GITHUB_BASE_URL;if(!r)return`https://github.com/${e}.git`;return new URL(`${e}.git`,Ce(r)).href}function y(e){let r=e.segments.map(M).filter(Boolean);if(!Se(e.host)||!r.length||r.some((a)=>!ve(a)))return null;let t=r.join("/"),i=r[r.length-1],n=e.host.toLowerCase();return{host:n,path:t,segments:r,owner:r.length===2?r[0]:void 0,repo:i,remote:e.remote??(n==="github.com"?re(t):`https://${n}/${t}.git`),label:n==="github.com"&&r.length===2?t:`${n}/${t}`,protocol:e.protocol}}function ke(e){let r=Y.normalize(Ee(e.url)),t=r.split(/[\\/]+/).filter(Boolean);if(!t.length)return null;return{host:"file",path:r,segments:t.map((i)=>i.replace(/:$/,"")),owner:void 0,repo:M(t[t.length-1]),remote:e.remote,label:r,protocol:"file:"}}function u(e){let r=ee(e);if(!r)return null;let t=r.match(/^github:([^/\s]+)\/([^/\s]+)$/);if(t)return y({host:"github.com",segments:[t[1],t[2]]});if(!r.includes("://")){let i=r.match(/^(?:[^@/\s]+@)?([^:/\s]+):(.+)$/);if(i)return y({host:i[1],segments:q(i[2]),remote:r});let n=q(r);if(n.length>=2&&we(n[0]))return y({host:n[0],segments:n.slice(1)});if(n.length===2)return y({host:"github.com",segments:n})}try{let i=new URL(r);if(i.protocol==="file:")return ke({url:i,remote:r});let n=q(i.pathname),a=i.host;return y({host:a,segments:n,remote:a==="github.com"?re(n.join("/")):r,protocol:i.protocol})}catch{return null}}function Fe(e){return e.protocol==="file:"}function Le(e){return!Fe(e)}function te(e){let r=u(e);if(!r)throw new w({repository:e,message:"Repository must be a git URL, host/path reference, or GitHub owner/repo shorthand"});if(!Le(r))throw new C({repository:e,message:"Local file repositories are not supported"});return r}function ne(e){if(!/^[A-Za-z0-9/_.-]+$/.test(e)||e.startsWith("-")||e.includes(".."))throw new k({branch:e,message:"Branch must contain only alphanumeric characters, /, _, ., and -, and cannot start with - or contain .."})}function Ze(e){let r=ee(e);if(!r.includes("://")&&!r.match(/^(?:[^@/\s]+@)?github\.com:/))return null;let t=u(r);if(!t||t.host!=="github.com"||!t.owner||t.segments.length!==2)return null;return{owner:t.owner,repo:t.repo}}function F(e){return Y.join(v.Path.repos,...e.host.split(":"),...e.segments)}function Q(e){return`${e.host}/${e.path}`}function oe(e,r){return Q(e)===Q(r)}var m={};se(m,{validateBranch:()=>ae,parseRemoteReference:()=>Ie,layer:()=>ce,isError:()=>Be,defaultLayer:()=>Pe,Service:()=>L,ResetFailedError:()=>T,RepositoryCache:()=>m,LockFailedError:()=>P,InvalidRepositoryError:()=>x,InvalidBranchError:()=>b,FetchFailedError:()=>B,CloneFailedError:()=>z,CheckoutFailedError:()=>I,CacheOperationError:()=>E});import D from"path";class x extends s.TaggedErrorClass()("RepositoryCacheInvalidRepositoryError",{repository:s.String,message:s.String}){}class b extends s.TaggedErrorClass()("RepositoryCacheInvalidBranchError",{branch:s.String,message:s.String}){}class z extends s.TaggedErrorClass()("RepositoryCacheCloneFailedError",{repository:s.String,message:s.String}){}class B extends s.TaggedErrorClass()("RepositoryCacheFetchFailedError",{repository:s.String,message:s.String}){}class I extends s.TaggedErrorClass()("RepositoryCacheCheckoutFailedError",{repository:s.String,branch:s.String,message:s.String}){}class T extends s.TaggedErrorClass()("RepositoryCacheResetFailedError",{repository:s.String,message:s.String}){}class P extends s.TaggedErrorClass()("RepositoryCacheLockFailedError",{localPath:s.String,message:s.String}){}class E extends s.TaggedErrorClass()("RepositoryCacheOperationError",{operation:s.String,path:s.String,message:s.String}){}class L extends $.Service()("@muxcode/RepositoryCache"){}function $e(e){if(!e.reuse)return"cloned";if(e.branchMatches===!1)return"refreshed";if(e.refresh)return"refreshed";return"cached"}function ze(e){if(e.requestedBranch)return`origin/${e.requestedBranch}`;if(e.remoteHead.code===0&&e.remoteHead.stdout)return e.remoteHead.stdout.replace(/^refs\/remotes\//,"");if(e.branch.code===0&&e.branch.stdout)return`origin/${e.branch.stdout}`;return"HEAD"}function R(e){return e instanceof globalThis.Error?e.message:String(e)}function Be(e){return e instanceof x||e instanceof b||e instanceof z||e instanceof B||e instanceof I||e instanceof T||e instanceof P||e instanceof E}var Ie=o.fn("RepositoryCache.parseRemoteReference")(function*(e){try{return te(e)}catch(r){if(r instanceof w||r instanceof C)return yield*new x({repository:r.repository,message:r.message});return yield*new x({repository:e,message:R(r)})}}),ae=o.fn("RepositoryCache.validateBranch")(function*(e){try{ne(e)}catch(r){if(r instanceof k)return yield*new b({branch:r.branch,message:r.message});return yield*new b({branch:e,message:R(r)})}}),Te=o.fn("RepositoryCache.ensureWithServices")(function*(e,r){if(e.branch)yield*ae(e.branch);let t=e.reference.label,i=e.reference.remote,n=F(e.reference),a=u(i)??e.reference;return yield*o.acquireUseRelease(o.promise((c)=>ie.acquire(`repo-clone:${n}`,{signal:c})).pipe(o.catch((c)=>o.fail(new P({localPath:n,message:R(c)||`Failed to lock ${n}`})))),()=>o.gen(function*(){yield*r.fs.ensureDir(D.dirname(n)).pipe(o.catch((l)=>o.fail(new E({operation:"ensure cache directory",path:n,message:R(l)}))));let c=yield*r.fs.existsSafe(n),f=yield*r.fs.existsSafe(D.join(n,".git")),p=f?yield*r.git.run(["config","--get","remote.origin.url"],{cwd:n}):void 0,S=p?.exitCode===0?u(p.text().trim()):void 0,X=f&&Boolean(S&&oe(S,a));if(c&&!X)yield*r.fs.remove(n,{recursive:!0}).pipe(o.catch((l)=>o.fail(new E({operation:"remove stale cache",path:n,message:R(l)}))));let ye=f?yield*r.git.branch(n):void 0,H=$e({reuse:X,refresh:e.refresh,branchMatches:e.branch?ye===e.branch:void 0});if(H==="cloned"){let l=yield*r.git.run(["clone","--depth","100",...e.branch?["--branch",e.branch]:[],"--",i,n],{cwd:D.dirname(n)});if(l.exitCode!==0)return yield*new z({repository:t,message:l.stderr.toString().trim()||l.text().trim()||`Failed to clone ${t}`})}if(H==="refreshed"){let l=yield*r.git.run(["fetch","--all","--prune"],{cwd:n});if(l.exitCode!==0)return yield*new B({repository:t,message:l.stderr.toString().trim()||l.text().trim()||`Failed to refresh ${t}`});if(e.branch){let G=yield*r.git.run(["checkout","-B",e.branch,`origin/${e.branch}`],{cwd:n});if(G.exitCode!==0)return yield*new I({repository:t,branch:e.branch,message:G.stderr.toString().trim()||G.text().trim()||`Failed to checkout ${e.branch}`})}let J=yield*r.git.run(["symbolic-ref","refs/remotes/origin/HEAD"],{cwd:n}),K=yield*r.git.run(["symbolic-ref","--quiet","--short","HEAD"],{cwd:n}),be=ze({requestedBranch:e.branch,remoteHead:{code:J.exitCode,stdout:J.text().trim()},branch:{code:K.exitCode,stdout:K.text().trim()}}),U=yield*r.git.run(["reset","--hard",be],{cwd:n});if(U.exitCode!==0)return yield*new T({repository:t,message:U.stderr.toString().trim()||U.text().trim()||`Failed to reset ${t}`})}let Z=yield*r.git.run(["rev-parse","HEAD"],{cwd:n}),Re=yield*r.git.branch(n),xe=Z.exitCode===0?Z.text().trim():void 0;return{repository:t,host:e.reference.host,remote:i,localPath:n,status:H,head:xe,branch:Re}}),(c)=>o.promise(()=>c.release()).pipe(o.ignore))}),ce=d.effect(L,o.gen(function*(){let e=yield*h.Service,r=yield*W.Service;return L.of({ensure:o.fn("RepositoryCache.ensure")(function*(t){return yield*Te(t,{fs:e,git:r})})})})),Pe=ce.pipe(d.provide(h.defaultLayer),d.provide(W.defaultLayer));class A extends $.Service()("@muxcode/Reference"){}function ge(e){if(e.value.startsWith("~/"))return _.join(v.Path.home,e.value.slice(2));return _.isAbsolute(e.value)?e.value:_.resolve(e.worktree==="/"?e.directory:e.worktree,e.value)}function Ae(e){let r=u(e.repository);if(!r||r.protocol==="file:")return{name:e.name,kind:"invalid",repository:e.repository,message:"Repository must be a git URL, host/path reference, or GitHub owner/repo shorthand"};return{name:e.name,kind:"git",repository:e.repository,reference:r,path:F(r),..."branch"in e?{branch:e.branch}:{}}}function fe(e){return e??"default branch"}function j(e){if(!e)return;return process.platform==="win32"?h.normalizePath(e):e}function ue(e,r){return h.contains(j(e)??e,r)}function He(e){let r=new Set;return e.filter((t)=>{if(t.kind!=="git")return!1;if(r.has(t.path))return!1;return r.add(t.path),!0})}function Ue(e,r){return e.ensure({reference:r.reference,branch:r.branch,refresh:!0}).pipe(o.asVoid,o.catchCause((t)=>o.logWarning("failed to materialize reference repository").pipe(o.annotateLogs({name:r.name,cause:t}))))}var Ge=o.fn("Reference.materializers")(function*(e,r){return yield*o.forEach(He(r),o.fnUntraced(function*(t){return{path:t.path,run:yield*o.cached(Ue(e,t))}}),{concurrency:"unbounded"})});function qe(e){if(!e.flags.experimentalScout)return o.void;return o.forEach(e.materializers,o.fnUntraced(function*(r){yield*r.run}),{concurrency:4,discard:!0})}function Me(e,r){return e.find((t)=>ue(t.path,r))?.run??o.void}function De(e,r){return e.some((t)=>t.kind==="git"&&ue(t.path,r))}function he(e){if(e.reference.kind==="invalid")return{name:e.name,kind:"invalid",message:e.reference.message};if(e.reference.kind==="local")return{name:e.name,kind:"local",path:ge({...e,value:e.reference.path})};return Ae({name:e.name,repository:e.reference.repository,branch:e.reference.branch})}function me(e){let r=new Map;return Object.entries(e.references).map(([t,i])=>{let n=he({name:t,reference:i,directory:e.directory,worktree:e.worktree});if(n.kind!=="git")return n;let a=r.get(n.path);if(!a)return r.set(n.path,{name:t,branch:n.branch}),n;if(a.branch===n.branch)return n;return{name:t,kind:"invalid",repository:n.repository,message:`Reference conflicts with @${a.name}: both use ${n.path}, but @${a.name} requests ${fe(a.branch)} and @${t} requests ${fe(n.branch)}`}})}var pe=d.effect(A,o.gen(function*(){let e=yield*N.Service,r=yield*m.Service,t=yield*le.Scope,i=yield*O.Service,n=yield*g.make(o.fn("Reference.state")(function*(a){let c=yield*e.get(),f=me({references:de.normalize(c.reference??{}),directory:a.directory,worktree:a.worktree}),p=yield*Ge(r,f),S=yield*o.cached(qe({flags:i,materializers:p}));return{references:f,materializeAll:S,materializeByPath:p}}));return A.of({init:o.fn("Reference.init")(function*(){if(!i.experimentalScout)return;yield*g.useEffect(n,(a)=>a.materializeAll).pipe(o.forkIn(t),o.asVoid)}),list:o.fn("Reference.list")(function*(){return yield*g.use(n,(a)=>a.references)}),get:o.fn("Reference.get")(function*(a){return yield*g.use(n,(c)=>c.references.find((f)=>f.name===a))}),ensure:o.fn("Reference.ensure")(function*(a){if(!i.experimentalScout)return;let c=j(a);if(!c)return yield*g.useEffect(n,(f)=>f.materializeAll);return yield*g.useEffect(n,(f)=>Me(f.materializeByPath,c))}),contains:o.fn("Reference.contains")(function*(a){if(!i.experimentalScout)return!1;let c=j(a);if(!c)return!1;return yield*g.use(n,(f)=>De(f.references,c))})})})),We=pe.pipe(d.provide(N.defaultLayer),d.provide(m.defaultLayer),d.provide(O.defaultLayer));
3
+ export{_e as Yk,u as Zk,Ze as _k,F as $k,m as al,V as bl};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{db as v,eb as l}from"./chunk-dtk4m8rm.js";import{Ff as x}from"./chunk-y4f43qq5.js";import{wj as $}from"./chunk-9n629gtn.js";var P=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"});function Uf(f={}){return{includeUserText:f.includeUserText??!1,announced:!1,ids:new Set,tools:new Set,call:new Map,shell:new Map,permissions:[],questions:[],role:new Map,msg:new Map,part:new Map,text:new Map,sent:new Map,end:new Set,echo:new Map}}function c(f,M){return`${f}/${M}`}function u(f,M,R){let B=(f?.input??0)+(f?.output??0)+(f?.reasoning??0)+(f?.cache?.read??0)+(f?.cache?.write??0);if(B<=0){if(typeof R==="number"&&R>0)return P.format(R);return}let W=M&&M>0?`${$(B)} (${Math.round(B/M*100)}%)`:$(B);if(typeof R==="number"&&R>0)return`${W} \xB7 ${P.format(R)}`;return W}function V(f){if(f.data?.message)return f.data.message;if(f.message)return f.message;if(f.name)return f.name;return"unknown error"}function r(f){return f?.name==="MessageAbortedError"}function g(f){return`msg:${f}:error`}function J(f,M){if(!f&&!M)return;return{patch:f,view:M}}function A(f,M,R){if(!R)return{data:f,commits:M};return{data:f,commits:M,footer:R}}function p(f){if(f.permission)return{type:"permission",request:f.permission};if(f.question)return{type:"question",request:f.question};return{type:"prompt"}}function d(f){if(f.type==="permission")return"awaiting permission";if(f.type==="question")return"awaiting answer";return""}function h(f){return p({permission:f.permissions[0],question:f.questions[0]})}function q(f){let M=h(f);return{view:M,patch:{status:d(M)}}}function K(f,M){return A(f,M,q(f))}function X(f,M){let R=f.findIndex((B)=>B.id===M.id);if(R===-1){f.push(M);return}f[R]=M}function E(f,M){let R=f.findIndex((B)=>B.id===M);if(R===-1)return!1;return f.splice(R,1),!0}function bf(f){for(let M of f.messages)for(let R of M.parts){if(R.type!=="tool")continue;f.data.call.set(T(R.messageID,R.callID),R.state.input)}for(let M of f.permissions.slice().sort((R,B)=>R.id.localeCompare(B.id)))X(f.data.permissions,C(f.data,M));for(let M of f.questions.slice().sort((R,B)=>R.id.localeCompare(B.id)))X(f.data.questions,M)}function T(f,M){return`${f}:${M}`}function C(f,M){if(!M.tool)return M;let R=f.call.get(T(M.tool.messageID,M.tool.callID));if(!R)return M;let B=M.metadata??{};if(B.input===R)return M;return{...M,metadata:{...B,input:R}}}function o(f,M){if(f.call.set(T(M.messageID,M.callID),M.state.input),f.permissions.length===0)return;let R=!1,B=!1;if(f.permissions=f.permissions.map((W,N)=>{if(!W.tool||W.tool.messageID!==M.messageID||W.tool.callID!==M.callID)return W;let L=C(f,W);if(L===W)return W;return R=!0,B||=N===0,L}),!R||!B)return;return{view:h(f)}}function i(f,M){if(M.tool!=="question")return;if(M.state.status!=="completed"&&M.state.status!=="error")return;let R=f.questions.filter((B)=>B.tool?.messageID!==M.messageID||B.tool?.callID!==M.callID);if(R.length===f.questions.length)return;return f.questions=R,q(f)}function k(f){if(f.tool!=="task")return`running ${f.tool}`;let M=f.state,R=M.input?.description;if(typeof R==="string"&&R.trim())return`running ${R.trim()}`;let B=M.input?.subagent_type;if(typeof B==="string"&&B.trim())return`running ${B.trim()}`;return"running task"}function z(f,M){let R=f.msg.get(M);if(!R)return!0;let B=f.role.get(R);if(!B)return!1;if(B==="assistant")return!0;return f.includeUserText&&B==="user"}function e(f,M,R){let B=f.text.get(M)??"";if(!R)return B;if(!B||R.length>=B.length)return f.text.set(M,R),R;return B}function m(f,M){if(M.tool!=="bash")return;if(typeof M.messageID!=="string"||!M.messageID)return;let R="output"in M.state?M.state.output:void 0;if(typeof R!=="string")return;let B=R.replace(/^\n+/,"");if(!B.trim())return;let W=f.echo.get(M.messageID)??new Set;W.add(B);let N=B.replace(/\n+$/,"");if(N&&N!==B)W.add(N);f.echo.set(M.messageID,W)}function a(f,M,R){if(!M)return R;let B=f.echo.get(M);if(!B||B.size===0)return R;f.echo.delete(M);let W=[...B].sort((N,L)=>L.length-N.length);for(let N of W){if(!N||!R.startsWith(N))continue;return R.slice(N.length).replace(/^\n+/,"")}return R}function Y(f,M,R,B=!1){let W=f.part.get(R);if(!W)return;let N=f.text.get(R)??"",L=f.sent.get(R)??0,y=N.slice(L),S=f.msg.get(R);if(L===0){if(y=y.replace(/^\n+/,""),!y.trim())return;if(W==="reasoning"&&y)y=`Thinking: ${y.replace(/\[REDACTED\]/g,"")}`;if(W==="assistant"&&y){if(y=a(f,S,y),!y.trim())return}}if(y)f.sent.set(R,N.length),M.push({kind:W,text:y,phase:"progress",source:W==="user"?"system":W,messageID:S,partID:R});if(!B)return;M.push({kind:W,text:"",phase:"final",source:W==="user"?"system":W,messageID:S,partID:R,interrupted:!0})}function U(f,M){f.part.delete(M),f.text.delete(M),f.sent.delete(M),f.msg.delete(M),f.end.delete(M)}function t(f,M,R,B,W){for(let[N,L]of f.msg.entries()){if(L!==R||f.ids.has(N))continue;if(B==="user"&&!f.includeUserText){f.ids.add(N),U(f,N);continue}let y=f.part.get(N);if(!y)continue;if(B==="user"&&y==="assistant")f.part.set(N,"user");if(y==="reasoning"&&!W){if(f.end.has(N))f.ids.add(N);U(f,N);continue}if(Y(f,M,N),!f.end.has(N))continue;f.ids.add(N),U(f,N)}}function F(f,M){return{kind:"tool",source:"tool",messageID:f.messageID,partID:f.id,tool:f.tool,part:f,...M}}function Q(f){return`shell:${f}`}function Z(f,M,R,B){let W=f.shell.get(M);if(W){if(B&&!W.command)W.command=B;return W}let N={source:R,...B?{command:B}:{}};return f.shell.set(M,N),N}function ff(f){if(f.tool!=="bash")return;let M=f.state.input;if(!M||typeof M!=="object"||Array.isArray(M))return;let R=Reflect.get(M,"command");return typeof R==="string"?R:void 0}function n(f,M){return{kind:"tool",source:"tool",partID:Q(f.callID),tool:"bash",shell:f,...M}}function w(f,M){return n({callID:f,command:M},{text:"running shell",phase:"start",toolState:"running"})}function Rf(f,M,R){return n({callID:f,command:M},{text:R,phase:"progress",toolState:"completed"})}function _(f){return F(f,{text:k(f),phase:"start",toolState:"running"})}function Mf(f){return F(f,{text:"",phase:"final",toolState:"completed"})}function Wf(f,M){return F(f,{text:M,phase:"final",toolState:"error",toolError:M})}function Gf(f,M){for(let R of f.part.keys()){if(f.ids.has(R))continue;let B=f.msg.get(R);if(B&&f.role.get(B)==="user"&&!f.includeUserText){f.ids.add(R),U(f,R);continue}Y(f,M,R,!0),f.ids.add(R),U(f,R)}}function Jf(f){let M=[],R=f.data,B=f.event;if(B.type==="session.next.shell.started"){if(B.properties.sessionID!==f.sessionID)return A(R,M);let W=Z(R,B.properties.callID,"shell",B.properties.command);if(W.source!=="shell")return A(R,M);let N=Q(B.properties.callID);if(R.ids.has(N)||R.tools.has(N))return A(R,M,J({status:"running shell"}));return R.tools.add(N),M.push(w(B.properties.callID,W.command??B.properties.command)),A(R,M,J({status:"running shell"}))}if(B.type==="session.next.shell.ended"){if(B.properties.sessionID!==f.sessionID)return A(R,M);let W=Z(R,B.properties.callID,"shell");if(W.source!=="shell")return A(R,M);let N=Q(B.properties.callID),L=R.tools.has(N),y=W.command??"";if(R.tools.delete(N),R.ids.has(N))return A(R,M);if(!L&&y)M.push(w(B.properties.callID,y));return R.ids.add(N),M.push(Rf(B.properties.callID,y,B.properties.output)),A(R,M)}if(B.type==="message.updated"){if(B.properties.sessionID!==f.sessionID)return A(R,M);let W=B.properties.info;if(typeof W.id==="string")R.role.set(W.id,W.role),t(R,M,W.id,W.role,f.thinking);if(W.role!=="assistant")return A(R,M);let N;if(!R.announced)R.announced=!0,N={status:"assistant responding"};let L=u(W.tokens,f.limits[c(W.providerID,W.modelID)],typeof W.cost==="number"?W.cost:void 0);if(L)N={...N,usage:L};if(typeof W.id==="string"&&W.error&&!r(W.error)&&!R.ids.has(g(W.id)))R.ids.add(g(W.id)),M.push({kind:"error",text:V(W.error),phase:"start",source:"system",messageID:W.id});return A(R,M,J(N))}if(B.type==="message.part.delta"){if(B.properties.sessionID!==f.sessionID)return A(R,M);if(typeof B.properties.partID!=="string"||typeof B.properties.field!=="string"||typeof B.properties.delta!=="string")return A(R,M);if(B.properties.field!=="text")return A(R,M);let W=B.properties.partID;if(R.ids.has(W))return A(R,M);if(typeof B.properties.messageID==="string")R.msg.set(W,B.properties.messageID);let N=R.text.get(W)??"";R.text.set(W,N+B.properties.delta);let L=R.part.get(W);if(!L)return A(R,M);if(L==="reasoning"&&!f.thinking)return A(R,M);if(!z(R,W))return A(R,M);return Y(R,M,W),A(R,M)}if(B.type==="message.part.updated"){let W=B.properties.part;if(W.sessionID!==f.sessionID)return A(R,M);if(W.type==="tool"){let S=o(R,W)??i(R,W);if(W.tool==="bash"&&W.callID){if(Z(R,W.callID,"tool",ff(W)).source==="shell")return A(R,M,S)}if(W.state.status==="running"){if(R.ids.has(W.id))return A(R,M,S);if(!R.tools.has(W.id))R.tools.add(W.id),M.push(_(W));return A(R,M,S??J({status:k(W)}))}if(W.state.status==="completed"){let H=R.tools.has(W.id),j=x(W.tool);if(R.tools.delete(W.id),R.ids.has(W.id))return A(R,M,S);if(!H)M.push(_(W));R.ids.add(W.id),m(R,W);let G=W.state.output;if(j.output&&typeof G==="string"&&G.trim())M.push({kind:"tool",text:G,phase:"progress",source:"tool",messageID:W.messageID,partID:W.id,tool:W.tool,part:W,toolState:"completed"});if(j.final)M.push(Mf(W));return A(R,M,S)}if(W.state.status==="error"){let H=R.tools.has(W.id);if(R.tools.delete(W.id),R.ids.has(W.id))return A(R,M,S);if(!H)M.push(_(W));R.ids.add(W.id);let j=typeof W.state.error==="string"&&W.state.error.trim()?W.state.error:"unknown error";return M.push(Wf(W,j)),A(R,M,S)}}if(W.type!=="text"&&W.type!=="reasoning")return A(R,M);if(R.ids.has(W.id))return A(R,M);let N=W.type==="text"?"assistant":"reasoning";if(typeof W.messageID==="string")R.msg.set(W.id,W.messageID);let L=W.messageID,y=L?R.role.get(L):void 0;if(y==="user"&&W.type==="text"&&!R.includeUserText)return R.ids.add(W.id),U(R,W.id),A(R,M);if(N==="reasoning"&&!f.thinking){if(W.time?.end)R.ids.add(W.id);return U(R,W.id),A(R,M)}if(R.part.set(W.id,y==="user"&&N==="assistant"?"user":N),e(R,W.id,W.text),W.time?.end)R.end.add(W.id);if(L&&!y)return A(R,M);if(!z(R,W.id))return A(R,M);if(Y(R,M,W.id),!W.time?.end)return A(R,M);return R.ids.add(W.id),U(R,W.id),A(R,M)}if(B.type==="permission.asked"){if(B.properties.sessionID!==f.sessionID)return A(R,M);return X(R.permissions,C(R,B.properties)),K(R,M)}if(B.type==="permission.replied"){if(B.properties.sessionID!==f.sessionID)return A(R,M);if(!E(R.permissions,B.properties.requestID))return A(R,M);return K(R,M)}if(B.type==="question.asked"){if(B.properties.sessionID!==f.sessionID)return A(R,M);return X(R.questions,B.properties),K(R,M)}if(B.type==="question.replied"||B.type==="question.rejected"){if(B.properties.sessionID!==f.sessionID)return A(R,M);if(!E(R.questions,B.properties.requestID))return A(R,M);return K(R,M)}if(B.type==="session.error"){if(B.properties.sessionID!==f.sessionID||!B.properties.error)return A(R,M);return M.push({kind:"error",text:V(B.properties.error),phase:"start",source:"system"}),A(R,M)}return A(R,M)}function Bf(f){if(typeof f.status==="string"&&f.phase===void 0)return{phase:"running",...f};return f}function b(f){if(typeof f==="string"){if(f.length<=160)return f;return{type:"string",length:f.length,preview:`${f.slice(0,160)}...`}}if(Array.isArray(f))return{type:"array",length:f.length};if(!f||typeof f!=="object")return f;return{type:"object",keys:Object.keys(f)}}function yf(f){return{...f,text:b(f.text),textLength:f.text.length,part:f.part?{id:f.part.id,sessionID:f.part.sessionID,messageID:f.part.messageID,callID:f.part.callID,tool:f.part.tool,state:{status:f.part.state.status,title:"title"in f.part.state?b(f.part.state.title):void 0,error:"error"in f.part.state?b(f.part.state.error):void 0,time:"time"in f.part.state?b(f.part.state.time):void 0,input:b(f.part.state.input),metadata:"metadata"in f.part.state?b(f.part.state.metadata):void 0}}:void 0}}function I(f){return{tabs:f.tabs,details:Object.fromEntries(Object.entries(f.details).map(([M,R])=>[M,{sessionID:M,commits:R.commits.map(yf)}])),permissions:f.permissions.map((M)=>({id:M.id,sessionID:M.sessionID,permission:M.permission,patterns:M.patterns,tool:M.tool,metadata:M.metadata?{keys:Object.keys(M.metadata),input:b(M.metadata.input)}:void 0})),questions:f.questions.map((M)=>({id:M.id,sessionID:M.sessionID,questions:M.questions.map((R)=>({header:R.header,question:R.question,options:R.options.length,multiple:R.multiple}))}))}}function Xf(f){if(!f?.subagent)return f;return{...f,subagent:I(f.subagent)}}function Yf(f,M){for(let R of M.commits)f.trace?.write("ui.commit",R),f.footer.append(R);if(M.footer?.patch){let R=Bf(M.footer.patch);f.trace?.write("ui.patch",R),f.footer.event({type:"stream.patch",patch:R})}if(M.footer?.subagent)f.trace?.write("ui.subagent",I(M.footer.subagent)),f.footer.event({type:"stream.subagent",state:M.footer.subagent});if(!M.footer?.view)return;f.trace?.write("ui.patch",{view:M.footer.view}),f.footer.event({type:"stream.view",view:M.footer.view})}var s=200;function D(f,M){if(M)return M;try{let R=new URL(f);if(R.protocol!=="file:")return f;let B=R.pathname.split("/").at(-1);if(B)return decodeURIComponent(B)}catch{}return f}function Nf(f,M){if(f.source)return{...structuredClone(f.source),text:M};return{type:"file",path:f.filename??f.url,text:M}}function Af(f){let M=[],R=f.parts.filter((y)=>{return y.type==="text"&&!y.synthetic}).map((y)=>y.text).join(""),B=Bun.stringWidth(R),W=[],N=(y)=>{let S=0;while(!0){let H=R.indexOf(y,S);if(H===-1)return;let j=Bun.stringWidth(R.slice(0,H)),G=j+Bun.stringWidth(y);if(!W.some((O)=>O.start<G&&j<O.end))return{start:j,end:G,value:y};S=H+y.length}},L=(y)=>{let S=R?" ":"",H=B+Bun.stringWidth(S);R+=S+y;let j=H+Bun.stringWidth(y);return B=j,{start:H,end:j,value:y}};for(let y of f.parts){if(y.type==="file"){let j=(y.source?.text?structuredClone(y.source.text):N("@"+D(y.url,y.filename)))??L("@"+D(y.url,y.filename));W.push({start:j.start,end:j.end}),M.push({type:"file",mime:y.mime,filename:y.filename,url:y.url,source:Nf(y,j)});continue}if(y.type!=="agent")continue;let S=y.source?structuredClone(y.source):N("@"+y.name)??L("@"+y.name);W.push({start:S.start,end:S.end}),M.push({type:"agent",name:y.name,source:S})}return{text:R,parts:M}}function Lf(f){if(f.info.role!=="user")return;return{prompt:Af(f),provider:f.info.model.providerID,model:f.info.model.modelID,variant:f.info.model.variant}}function Sf(f){return{first:f.length===0,turns:f.flatMap((M)=>{let R=Lf(M);return R?[R]:[]})}}async function $f(f,M,R=s){let B=await f.session.messages({sessionID:M,limit:R});return Sf(B.data??[])}function Qf(f,M=s){let R=[];for(let B of f.turns){if(!B.prompt.text.trim())continue;if(R[R.length-1]&&l(R[R.length-1],B.prompt))continue;R.push(v(B.prompt))}return R.slice(-M)}function Tf(f,M){if(!M)return;for(let R=f.turns.length-1;R>=0;R-=1){let B=f.turns[R];if(B.provider!==M.providerID||B.model!==M.modelID)continue;return B.variant}return}
3
+ export{Uf as Oa,V as Pa,p as Qa,d as Ra,bf as Sa,Gf as Ta,Jf as Ua,Xf as Va,Yf as Wa,Af as Xa,Sf as Ya,$f as Za,Qf as _a,Tf as $a};
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import{qj as $_}from"./chunk-1evcc54z.js";import{dl as Xc}from"./chunk-sjd8mzvx.js";import{$o as h_,$q as sc,Bq as rc,Mq as Ac,Oq as Fc,Pq as Hc,Tq as M_,Uq as Zc,br as j_,dp as mc,er as oc,fp as ic,fr as pc,gr as F,hq as k_,tr as m,vq as A,xp as D_,zr as ac}from"./chunk-a0srn4ak.js";import{as as Lg}from"./chunk-jfz77m78.js";import{cs as Y,gs as G}from"./chunk-my9cfmvt.js";import{vs as q,xs as w_}from"./chunk-8jy0dvcn.js";import{AF as e,Dw as E,Fx as e_,TC as Cc,Yz as d_,eC as D,fz as N_}from"./chunk-1mqsg5s7.js";import{QF as Gg,SF as Wc}from"./chunk-8j3aw4qg.js";var W_=({onRequest:c,onSseError:_,onSseEvent:g,responseTransformer:d,responseValidator:l,sseDefaultRetryDelay:O,sseMaxRetryAttempts:S,sseMaxRetryDelay:f,sseSleepFn:k,url:T,...x})=>{let K,J=k??(($)=>new Promise((N)=>setTimeout(N,$)));return{stream:async function*(){let $=O??3000,N=0,M=x.signal??new AbortController().signal;while(!0){if(M.aborted)break;N++;let V=x.headers instanceof Headers?x.headers:new Headers(x.headers);if(K!==void 0)V.set("Last-Event-ID",K);try{let X={redirect:"follow",...x,body:x.serializedBody,headers:V,signal:M},I=new Request(T,X);if(c)I=await c(T,X);let U=await(x.fetch??globalThis.fetch)(I);if(!U.ok)throw Error(`SSE failed: ${U.status} ${U.statusText}`);if(!U.body)throw Error("No body in SSE response");let Z=U.body.pipeThrough(new TextDecoderStream).getReader(),t="",G_=()=>{try{Z.cancel()}catch{}};M.addEventListener("abort",G_);try{while(!0){let{done:hg,value:eg}=await Z.read();if(hg)break;t+=eg,t=t.replace(/\r\n/g,`
3
+ `).replace(/\r/g,`
4
+ `);let L_=t.split(`
5
+
6
+ `);t=L_.pop()??"";for(let dg of L_){let fg=dg.split(`
7
+ `),r=[],X_;for(let R of fg)if(R.startsWith("data:"))r.push(R.replace(/^data:\s*/,""));else if(R.startsWith("event:"))X_=R.replace(/^event:\s*/,"");else if(R.startsWith("id:"))K=R.replace(/^id:\s*/,"");else if(R.startsWith("retry:")){let V_=Number.parseInt(R.replace(/^retry:\s*/,""),10);if(!Number.isNaN(V_))$=V_}let z,Z_=!1;if(r.length){let R=r.join(`
8
+ `);try{z=JSON.parse(R),Z_=!0}catch{z=R}}if(Z_){if(l)await l(z);if(d)z=await d(z)}if(g?.({data:z,event:X_,id:K,retry:$}),r.length)yield z}}}finally{M.removeEventListener("abort",G_),Z.releaseLock()}break}catch(X){if(_?.(X),S!==void 0&&N>=S)break;let I=Math.min($*2**(N-1),f??30000);await J(I)}}}()}};var lg=(c)=>{switch(c){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Sg=(c)=>{switch(c){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},xg=(c)=>{switch(c){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},s=({allowReserved:c,explode:_,name:g,style:d,value:l})=>{if(!_){let f=(c?l:l.map((k)=>encodeURIComponent(k))).join(Sg(d));switch(d){case"label":return`.${f}`;case"matrix":return`;${g}=${f}`;case"simple":return f;default:return`${g}=${f}`}}let O=lg(d),S=l.map((f)=>{if(d==="label"||d==="simple")return c?f:encodeURIComponent(f);return y({allowReserved:c,name:g,value:f})}).join(O);return d==="label"||d==="matrix"?O+S:S},y=({allowReserved:c,name:_,value:g})=>{if(g===void 0||g===null)return"";if(typeof g==="object")throw Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${_}=${c?g:encodeURIComponent(g)}`},o=({allowReserved:c,explode:_,name:g,style:d,value:l,valueOnly:O})=>{if(l instanceof Date)return O?l.toISOString():`${g}=${l.toISOString()}`;if(d!=="deepObject"&&!_){let k=[];Object.entries(l).forEach(([x,K])=>{k=[...k,x,c?K:encodeURIComponent(K)]});let T=k.join(",");switch(d){case"form":return`${g}=${T}`;case"label":return`.${T}`;case"matrix":return`;${g}=${T}`;default:return T}}let S=xg(d),f=Object.entries(l).map(([k,T])=>y({allowReserved:c,name:d==="deepObject"?`${g}[${k}]`:k,value:T})).join(S);return d==="label"||d==="matrix"?S+f:f};var kg=/\{[^{}]+\}/g,Og=({path:c,url:_})=>{let g=_,d=_.match(kg);if(d)for(let l of d){let O=!1,S=l.substring(1,l.length-1),f="simple";if(S.endsWith("*"))O=!0,S=S.substring(0,S.length-1);if(S.startsWith("."))S=S.substring(1),f="label";else if(S.startsWith(";"))S=S.substring(1),f="matrix";let k=c[S];if(k===void 0||k===null)continue;if(Array.isArray(k)){g=g.replace(l,s({explode:O,name:S,style:f,value:k}));continue}if(typeof k==="object"){g=g.replace(l,o({explode:O,name:S,style:f,value:k,valueOnly:!0}));continue}if(f==="matrix"){g=g.replace(l,`;${y({name:S,value:k})}`);continue}let T=encodeURIComponent(f==="label"?`.${k}`:k);g=g.replace(l,T)}return g},Y_=({baseUrl:c,path:_,query:g,querySerializer:d,url:l})=>{let O=l.startsWith("/")?l:`/${l}`,S=(c??"")+O;if(_)S=Og({path:_,url:S});let f=g?d(g):"";if(f.startsWith("?"))f=f.substring(1);if(f)S+=`?${f}`;return S};function f_(c){let _=c.body!==void 0;if(_&&c.bodySerializer){if("serializedBody"in c)return c.serializedBody!==void 0&&c.serializedBody!==""?c.serializedBody:null;return c.body!==""?c.body:null}if(_)return c.body;return}var J_=async(c,_)=>{let g=typeof _==="function"?await _(c):_;if(!g)return;if(c.scheme==="bearer")return`Bearer ${g}`;if(c.scheme==="basic")return`Basic ${btoa(g)}`;return g};var l_={bodySerializer:(c)=>JSON.stringify(c,(_,g)=>typeof g==="bigint"?g.toString():g)};var I_=({parameters:c={},..._}={})=>{return(d)=>{let l=[];if(d&&typeof d==="object")for(let O in d){let S=d[O];if(S===void 0||S===null)continue;let f=c[O]||_;if(Array.isArray(S)){let k=s({allowReserved:f.allowReserved,explode:!0,name:O,style:"form",value:S,...f.array});if(k)l.push(k)}else if(typeof S==="object"){let k=o({allowReserved:f.allowReserved,explode:!0,name:O,style:"deepObject",value:S,...f.object});if(k)l.push(k)}else{let k=y({allowReserved:f.allowReserved,name:O,value:S});if(k)l.push(k)}}return l.join("&")}},Q_=(c)=>{if(!c)return"stream";let _=c.split(";")[0]?.trim();if(!_)return;if(_.startsWith("application/json")||_.endsWith("+json"))return"json";if(_==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((g)=>_.startsWith(g)))return"blob";if(_.startsWith("text/"))return"text";return},Tg=(c,_)=>{if(!_)return!1;if(c.headers.has(_)||c.query?.[_]||c.headers.get("Cookie")?.includes(`${_}=`))return!0;return!1},R_=async({security:c,..._})=>{for(let g of c){if(Tg(_,g.name))continue;let d=await J_(g,_.auth);if(!d)continue;let l=g.name??"Authorization";switch(g.in){case"query":if(!_.query)_.query={};_.query[l]=d;break;case"cookie":_.headers.append("Cookie",`${l}=${d}`);break;case"header":default:_.headers.set(l,d);break}}},S_=(c)=>Y_({baseUrl:c.baseUrl,path:c.path,query:c.query,querySerializer:typeof c.querySerializer==="function"?c.querySerializer:I_(c.querySerializer),url:c.url}),x_=(c,_)=>{let g={...c,..._};if(g.baseUrl?.endsWith("/"))g.baseUrl=g.baseUrl.substring(0,g.baseUrl.length-1);return g.headers=a(c.headers,_.headers),g},$g=(c)=>{let _=[];return c.forEach((g,d)=>{_.push([d,g])}),_},a=(...c)=>{let _=new Headers;for(let g of c){if(!g)continue;let d=g instanceof Headers?$g(g):Object.entries(g);for(let[l,O]of d)if(O===null)_.delete(l);else if(Array.isArray(O))for(let S of O)_.append(l,S);else if(O!==void 0)_.set(l,typeof O==="object"?JSON.stringify(O):O)}return _};class p{fns=[];clear(){this.fns=[]}eject(c){let _=this.getInterceptorIndex(c);if(this.fns[_])this.fns[_]=null}exists(c){let _=this.getInterceptorIndex(c);return Boolean(this.fns[_])}getInterceptorIndex(c){if(typeof c==="number")return this.fns[c]?c:-1;return this.fns.indexOf(c)}update(c,_){let g=this.getInterceptorIndex(c);if(this.fns[g])return this.fns[g]=_,c;return!1}use(c){return this.fns.push(c),this.fns.length-1}}var q_=()=>({error:new p,request:new p,response:new p}),Bg=I_({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),ug={"Content-Type":"application/json"},P=(c={})=>({...l_,headers:ug,parseAs:"auto",querySerializer:Bg,...c});var C=(c={})=>{let _=x_(P(),c),g=()=>({..._}),d=(T)=>{return _=x_(_,T),g()},l=q_(),O=async(T)=>{let x={..._,...T,fetch:T.fetch??_.fetch??globalThis.fetch,headers:a(_.headers,T.headers),serializedBody:void 0};if(x.security)await R_({...x,security:x.security});if(x.requestValidator)await x.requestValidator(x);if(x.body!==void 0&&x.bodySerializer)x.serializedBody=x.bodySerializer(x.body);if(x.body===void 0||x.serializedBody==="")x.headers.delete("Content-Type");let K=S_(x);return{opts:x,url:K}},S=async(T)=>{let{opts:x,url:K}=await O(T),J={redirect:"follow",...x,body:f_(x)},j=new Request(K,J);for(let L of l.request.fns)if(L)j=await L(j,x);let u=x.fetch,$;try{$=await u(j)}catch(L){let U=L;for(let Z of l.error.fns)if(Z)U=await Z(L,void 0,j,x);if(U=U||{},x.throwOnError)throw U;return x.responseStyle==="data"?void 0:{error:U,request:j,response:void 0}}for(let L of l.response.fns)if(L)$=await L($,j,x);let N={request:j,response:$};if($.ok){let L=(x.parseAs==="auto"?Q_($.headers.get("Content-Type")):x.parseAs)??"json";if($.status===204||$.headers.get("Content-Length")==="0"){let Z;switch(L){case"arrayBuffer":case"blob":case"text":Z=await $[L]();break;case"formData":Z=new FormData;break;case"stream":Z=$.body;break;case"json":default:Z={};break}return x.responseStyle==="data"?Z:{data:Z,...N}}let U;switch(L){case"arrayBuffer":case"blob":case"formData":case"text":U=await $[L]();break;case"json":{let Z=await $.text();U=Z?JSON.parse(Z):{};break}case"stream":return x.responseStyle==="data"?$.body:{data:$.body,...N}}if(L==="json"){if(x.responseValidator)await x.responseValidator(U);if(x.responseTransformer)U=await x.responseTransformer(U)}return x.responseStyle==="data"?U:{data:U,...N}}let M=await $.text(),V;try{V=JSON.parse(M)}catch{}let X=V??M,I=X;for(let L of l.error.fns)if(L)I=await L(X,$,j,x);if(I=I||{},x.throwOnError)throw I;return x.responseStyle==="data"?void 0:{error:I,...N}},f=(T)=>(x)=>S({...x,method:T}),k=(T)=>async(x)=>{let{opts:K,url:J}=await O(x);return W_({...K,body:K.body,headers:K.headers,method:T,onRequest:async(j,u)=>{let $=new Request(j,u);for(let N of l.request.fns)if(N)$=await N($,K);return $},serializedBody:f_(K),url:J})};return{buildUrl:S_,connect:f("CONNECT"),delete:f("DELETE"),get:f("GET"),getConfig:g,head:f("HEAD"),interceptors:l,options:f("OPTIONS"),patch:f("PATCH"),post:f("POST"),put:f("PUT"),request:S,setConfig:d,sse:{connect:k("CONNECT"),delete:k("DELETE"),get:k("GET"),head:k("HEAD"),options:k("OPTIONS"),patch:k("PATCH"),post:k("POST"),put:k("PUT"),trace:k("TRACE")},trace:f("TRACE")}};var Kg={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Ng=Object.entries(Kg),z_=(c,_)=>{if(!_)_=new Map;for(let g of c)if("in"in g){if(g.key)_.set(g.key,{in:g.in,map:g.map})}else if("key"in g)_.set(g.key,{map:g.map});else if(g.args)z_(g.args,_);return _},Mg=(c)=>{for(let[_,g]of Object.entries(c))if(g&&typeof g==="object"&&!Object.keys(g).length)delete c[_]},h=(c,_)=>{let g={body:{},headers:{},path:{},query:{}},d=z_(_),l;for(let[O,S]of c.entries()){if(_[O])l=_[O];if(!l)continue;if("in"in l)if(l.key){let f=d.get(l.key),k=f.map||l.key;if(f.in)g[f.in][k]=S}else g.body=S;else for(let[f,k]of Object.entries(S??{})){let T=d.get(f);if(T)if(T.in){let x=T.map||f;g[T.in][x]=k}else g[T.map]=k;else{let x=Ng.find(([K])=>f.startsWith(K));if(x){let[K,J]=x;g[J][f.slice(K.length)]=k}else if("allowExtra"in l&&l.allowExtra){for(let[K,J]of Object.entries(l.allowExtra))if(J){g[K][f]=k;break}}}}}return Mg(g),g};var v_=C(P({baseUrl:"http://localhost:4096"}));class B{client;constructor(c){this.client=c?.client??v_}}class b_{defaultKey="default";instances=new Map;get(c){let _=this.instances.get(c??this.defaultKey);if(!_)throw Error('No SDK client found. Create one with "new MuxcodeClient()" to fix this error.');return _}set(c,_){this.instances.set(_??this.defaultKey,c)}}class E_ extends B{remove(c,_){let g=h([c],[{args:[{in:"path",key:"providerID"}]}]);return(_?.client??this.client).delete({url:"/auth/{providerID}",..._,...g})}set(c,_){let g=h([c],[{args:[{in:"path",key:"providerID"},{key:"auth",map:"body"}]}]);return(_?.client??this.client).put({url:"/auth/{providerID}",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class y_ extends B{log(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/log",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}agents(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/agent",..._,...g})}skills(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/skill",..._,...g})}}class n_ extends B{get(c){return(c?.client??this.client).get({url:"/global/config",...c})}update(c,_){let g=h([c],[{args:[{key:"config",map:"body"}]}]);return(_?.client??this.client).patch({url:"/global/config",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class A_ extends B{health(c){return(c?.client??this.client).get({url:"/global/health",...c})}event(c){return(c?.client??this.client).sse.get({url:"/global/event",...c})}dispose(c){return(c?.client??this.client).post({url:"/global/dispose",...c})}upgrade(c,_){let g=h([c],[{args:[{in:"body",key:"target"}]}]);return(_?.client??this.client).post({url:"/global/upgrade",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}_config;get config(){return this._config??=new n_({client:this.client})}}class F_ extends B{subscribe(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).sse.get({url:"/event",..._,...g})}}class H_ extends B{get(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/config",..._,...g})}update(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"config",map:"body"}]}]);return(_?.client??this.client).patch({url:"/config",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}providers(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/config/providers",..._,...g})}}class t_ extends B{get(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/console",..._,...g})}listOrgs(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/console/orgs",..._,...g})}switchOrg(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"accountID"},{in:"body",key:"orgID"}]}]);return(_?.client??this.client).post({url:"/experimental/console/switch",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class P_ extends B{list(c,_){let g=h([c],[{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(_?.client??this.client).get({url:"/experimental/session",..._,...g})}}class C_ extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/resource",..._,...g})}}class m_ extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/workspace/adapter",..._,...g})}}class i_ extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/workspace",..._,...g})}create(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/experimental/workspace",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}syncList(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/experimental/workspace/sync-list",..._,...g})}status(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/workspace/status",..._,...g})}remove(c,_){let g=h([c],[{args:[{in:"path",key:"id"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).delete({url:"/experimental/workspace/{id}",..._,...g})}warp(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"id"},{in:"body",key:"sessionID"},{in:"body",key:"copyChanges"}]}]);return(_?.client??this.client).post({url:"/experimental/workspace/warp",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}_adapter;get adapter(){return this._adapter??=new m_({client:this.client})}}class r_ extends B{_console;get console(){return this._console??=new t_({client:this.client})}_session;get session(){return this._session??=new P_({client:this.client})}_resource;get resource(){return this._resource??=new C_({client:this.client})}_workspace;get workspace(){return this._workspace??=new i_({client:this.client})}}class s_ extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"provider"},{in:"query",key:"model"}]}]);return(_?.client??this.client).get({url:"/experimental/tool",..._,...g})}ids(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/tool/ids",..._,...g})}}class o_ extends B{remove(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeRemoveInput",map:"body"}]}]);return(_?.client??this.client).delete({url:"/experimental/worktree",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/experimental/worktree",..._,...g})}create(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeCreateInput",map:"body"}]}]);return(_?.client??this.client).post({url:"/experimental/worktree",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}reset(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"worktreeResetInput",map:"body"}]}]);return(_?.client??this.client).post({url:"/experimental/worktree/reset",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class p_ extends B{text(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"pattern"}]}]);return(_?.client??this.client).get({url:"/find",..._,...g})}files(c,_){let g=h([c],[{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(_?.client??this.client).get({url:"/find/file",..._,...g})}symbols(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"query"}]}]);return(_?.client??this.client).get({url:"/find/symbol",..._,...g})}}class a_ extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(_?.client??this.client).get({url:"/file",..._,...g})}read(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"path"}]}]);return(_?.client??this.client).get({url:"/file/content",..._,...g})}status(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/file/status",..._,...g})}}class _c extends B{dispose(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/instance/dispose",..._,...g})}}class cc extends B{get(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/path",..._,...g})}}class gc extends B{raw(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/vcs/diff/raw",..._,...g})}}class wc extends B{get(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/vcs",..._,...g})}status(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/vcs/status",..._,...g})}diff(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"mode"},{in:"query",key:"context"}]}]);return(_?.client??this.client).get({url:"/vcs/diff",..._,...g})}apply(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"patch"}]}]);return(_?.client??this.client).post({url:"/vcs/apply",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}_diff;get diff2(){return this._diff??=new gc({client:this.client})}}class hc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/command",..._,...g})}}class ec extends B{status(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/lsp",..._,...g})}}class dc extends B{status(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/formatter",..._,...g})}}class fc extends B{remove(c,_){let g=h([c],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).delete({url:"/mcp/{name}/auth",..._,...g})}start(c,_){let g=h([c],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/mcp/{name}/auth",..._,...g})}callback(c,_){let g=h([c],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"code"}]}]);return(_?.client??this.client).post({url:"/mcp/{name}/auth/callback",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}authenticate(c,_){let g=h([c],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/mcp/{name}/auth/authenticate",..._,...g})}}class lc extends B{status(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/mcp",..._,...g})}add(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"name"},{in:"body",key:"config"}]}]);return(_?.client??this.client).post({url:"/mcp",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}connect(c,_){let g=h([c],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/mcp/{name}/connect",..._,...g})}disconnect(c,_){let g=h([c],[{args:[{in:"path",key:"name"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/mcp/{name}/disconnect",..._,...g})}_auth;get auth(){return this._auth??=new fc({client:this.client})}}class Sc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/project",..._,...g})}current(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/project/current",..._,...g})}initGit(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/project/git/init",..._,...g})}update(c,_){let g=h([c],[{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(_?.client??this.client).patch({url:"/project/{projectID}",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class xc extends B{shells(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/pty/shells",..._,...g})}list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/pty",..._,...g})}create(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/pty",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}remove(c,_){let g=h([c],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).delete({url:"/pty/{ptyID}",..._,...g})}get(c,_){let g=h([c],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/pty/{ptyID}",..._,...g})}update(c,_){let g=h([c],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"size"}]}]);return(_?.client??this.client).put({url:"/pty/{ptyID}",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}connectToken(c,_){let g=h([c],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/pty/{ptyID}/connect-token",..._,...g})}connect(c,_){let g=h([c],[{args:[{in:"path",key:"ptyID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"cursor"},{in:"query",key:"ticket"}]}]);return(_?.client??this.client).get({url:"/pty/{ptyID}/connect",..._,...g})}}class kc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/question",..._,...g})}reply(c,_){let g=h([c],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"answers"}]}]);return(_?.client??this.client).post({url:"/question/{requestID}/reply",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}reject(c,_){let g=h([c],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/question/{requestID}/reject",..._,...g})}}class Oc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/permission",..._,...g})}reply(c,_){let g=h([c],[{args:[{in:"path",key:"requestID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"reply"},{in:"body",key:"message"}]}]);return(_?.client??this.client).post({url:"/permission/{requestID}/reply",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}respond(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"permissionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"response"}]}]);return(_?.client??this.client).post({url:"/session/{sessionID}/permissions/{permissionID}",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class Tc extends B{authorize(c,_){let g=h([c],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"inputs"}]}]);return(_?.client??this.client).post({url:"/provider/{providerID}/oauth/authorize",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}callback(c,_){let g=h([c],[{args:[{in:"path",key:"providerID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"method"},{in:"body",key:"code"}]}]);return(_?.client??this.client).post({url:"/provider/{providerID}/oauth/callback",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class $c extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/provider",..._,...g})}auth(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/provider/auth",..._,...g})}_oauth;get oauth(){return this._oauth??=new Tc({client:this.client})}}class Bc extends B{list(c,_){let g=h([c],[{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(_?.client??this.client).get({url:"/session",..._,...g})}create(c,_){let g=h([c],[{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:"permission"},{in:"body",key:"workspaceID"}]}]);return(_?.client??this.client).post({url:"/session",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}status(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/session/status",..._,...g})}delete(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).delete({url:"/session/{sessionID}",..._,...g})}get(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/session/{sessionID}",..._,...g})}update(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"title"},{in:"body",key:"permission"},{in:"body",key:"time"}]}]);return(_?.client??this.client).patch({url:"/session/{sessionID}",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}children(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/session/{sessionID}/children",..._,...g})}todo(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/session/{sessionID}/todo",..._,...g})}diff(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"messageID"}]}]);return(_?.client??this.client).get({url:"/session/{sessionID}/diff",..._,...g})}messages(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"before"}]}]);return(_?.client??this.client).get({url:"/session/{sessionID}/message",..._,...g})}prompt(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/session/{sessionID}/message",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}deleteMessage(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}",..._,...g})}message(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/session/{sessionID}/message/{messageID}",..._,...g})}fork(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"}]}]);return(_?.client??this.client).post({url:"/session/{sessionID}/fork",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}abort(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/session/{sessionID}/abort",..._,...g})}init(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/session/{sessionID}/init",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}unshare(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).delete({url:"/session/{sessionID}/share",..._,...g})}share(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/session/{sessionID}/share",..._,...g})}summarize(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/session/{sessionID}/summarize",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}promptAsync(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/session/{sessionID}/prompt_async",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}command(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/session/{sessionID}/command",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}shell(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/session/{sessionID}/shell",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}revert(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"messageID"},{in:"body",key:"partID"}]}]);return(_?.client??this.client).post({url:"/session/{sessionID}/revert",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}unrevert(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/session/{sessionID}/unrevert",..._,...g})}}class uc extends B{delete(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"path",key:"messageID"},{in:"path",key:"partID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).delete({url:"/session/{sessionID}/message/{messageID}/part/{partID}",..._,...g})}update(c,_){let g=h([c],[{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(_?.client??this.client).patch({url:"/session/{sessionID}/message/{messageID}/part/{partID}",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class Kc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(_?.client??this.client).post({url:"/sync/history",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class Nc extends B{start(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/sync/start",..._,...g})}replay(c,_){let g=h([c],[{args:[{in:"query",key:"query_directory",map:"directory"},{in:"query",key:"workspace"},{in:"body",key:"body_directory",map:"directory"},{in:"body",key:"events"}]}]);return(_?.client??this.client).post({url:"/sync/replay",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}steal(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(_?.client??this.client).post({url:"/sync/steal",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}_history;get history(){return this._history??=new Kc({client:this.client})}}class Mc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"path"},{in:"query",key:"roots"},{in:"query",key:"start"},{in:"query",key:"search"},{in:"query",key:"cursor"}]}]);return(_?.client??this.client).get({url:"/api/session",..._,...g})}prompt(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"prompt"},{in:"body",key:"delivery"}]}]);return(_?.client??this.client).post({url:"/api/session/{sessionID}/prompt",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}compact(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/api/session/{sessionID}/compact",..._,...g})}wait(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/api/session/{sessionID}/wait",..._,...g})}context(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/api/session/{sessionID}/context",..._,...g})}messages(c,_){let g=h([c],[{args:[{in:"path",key:"sessionID"},{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"query",key:"limit"},{in:"query",key:"order"},{in:"query",key:"cursor"}]}]);return(_?.client??this.client).get({url:"/api/session/{sessionID}/message",..._,...g})}}class Dc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"location"}]}]);return(_?.client??this.client).get({url:"/api/model",..._,...g})}}class jc extends B{list(c,_){let g=h([c],[{args:[{in:"query",key:"location"}]}]);return(_?.client??this.client).get({url:"/api/provider",..._,...g})}get(c,_){let g=h([c],[{args:[{in:"path",key:"providerID"},{in:"query",key:"location"}]}]);return(_?.client??this.client).get({url:"/api/provider/{providerID}",..._,...g})}}class Uc extends B{_session;get session(){return this._session??=new Mc({client:this.client})}_model;get model(){return this._model??=new Dc({client:this.client})}_provider;get provider(){return this._provider??=new jc({client:this.client})}}class Gc extends B{next(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).get({url:"/tui/control/next",..._,...g})}response(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(_?.client??this.client).post({url:"/tui/control/response",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}}class Lc extends B{appendPrompt(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"text"}]}]);return(_?.client??this.client).post({url:"/tui/append-prompt",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}openHelp(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/tui/open-help",..._,...g})}openSessions(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/tui/open-sessions",..._,...g})}openThemes(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/tui/open-themes",..._,...g})}openModels(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/tui/open-models",..._,...g})}submitPrompt(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/tui/submit-prompt",..._,...g})}clearPrompt(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"}]}]);return(_?.client??this.client).post({url:"/tui/clear-prompt",..._,...g})}executeCommand(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"command"}]}]);return(_?.client??this.client).post({url:"/tui/execute-command",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}showToast(c,_){let g=h([c],[{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(_?.client??this.client).post({url:"/tui/show-toast",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}publish(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{key:"body",map:"body"}]}]);return(_?.client??this.client).post({url:"/tui/publish",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}selectSession(c,_){let g=h([c],[{args:[{in:"query",key:"directory"},{in:"query",key:"workspace"},{in:"body",key:"sessionID"}]}]);return(_?.client??this.client).post({url:"/tui/select-session",..._,...g,headers:{"Content-Type":"application/json",..._?.headers,...g.headers}})}_control;get control(){return this._control??=new Gc({client:this.client})}}class __ extends B{static __registry=new b_;constructor(c){super(c);__.__registry.set(this,c?.key)}_auth;get auth(){return this._auth??=new E_({client:this.client})}_app;get app(){return this._app??=new y_({client:this.client})}_global;get global(){return this._global??=new A_({client:this.client})}_event;get event(){return this._event??=new F_({client:this.client})}_config;get config(){return this._config??=new H_({client:this.client})}_experimental;get experimental(){return this._experimental??=new r_({client:this.client})}_tool;get tool(){return this._tool??=new s_({client:this.client})}_worktree;get worktree(){return this._worktree??=new o_({client:this.client})}_find;get find(){return this._find??=new p_({client:this.client})}_file;get file(){return this._file??=new a_({client:this.client})}_instance;get instance(){return this._instance??=new _c({client:this.client})}_path;get path(){return this._path??=new cc({client:this.client})}_vcs;get vcs(){return this._vcs??=new wc({client:this.client})}_command;get command(){return this._command??=new hc({client:this.client})}_lsp;get lsp(){return this._lsp??=new ec({client:this.client})}_formatter;get formatter(){return this._formatter??=new dc({client:this.client})}_mcp;get mcp(){return this._mcp??=new lc({client:this.client})}_project;get project(){return this._project??=new Sc({client:this.client})}_pty;get pty(){return this._pty??=new xc({client:this.client})}_question;get question(){return this._question??=new kc({client:this.client})}_permission;get permission(){return this._permission??=new Oc({client:this.client})}_provider;get provider(){return this._provider??=new $c({client:this.client})}_session;get session(){return this._session??=new Bc({client:this.client})}_part;get part(){return this._part??=new uc({client:this.client})}_sync;get sync(){return this._sync??=new Nc({client:this.client})}_v2;get v2(){return this._v2??=new Uc({client:this.client})}_tui;get tui(){return this._tui??=new Lc({client:this.client})}}function Dg(c,_,g){if(!c)return;if(!_)return c;if(c===_)return _;if(g&&c===g(_))return _;return c}function jg(c,_){if(c.method!=="GET"&&c.method!=="HEAD")return c;let g=new URL(c.url),d=!1;for(let[O,S]of[["x-muxcode-directory","directory"],["x-muxcode-workspace","workspace"]]){let f=Dg(c.headers.get(O),S==="directory"?_.directory:_.workspace,S==="directory"?encodeURIComponent:void 0);if(!f)continue;if(!g.searchParams.has(S))g.searchParams.set(S,f);d=!0}if(!d)return c;let l=new Request(g,c);return l.headers.delete("x-muxcode-directory"),l.headers.delete("x-muxcode-workspace"),l}function Ug(c){if(!c?.fetch)c={...c,fetch:(d)=>{return d.timeout=!1,fetch(d)}};if(c?.directory)c.headers={...c.headers,"x-muxcode-directory":encodeURIComponent(c.directory)};if(c?.experimental_workspaceID)c.headers={...c.headers,"x-muxcode-workspace":c.experimental_workspaceID};let _=C(c);return _.interceptors.request.use((g)=>jg(g,{directory:c?.directory,workspace:c?.experimental_workspaceID})),_.interceptors.response.use((g)=>{if(g.headers.get("content-type")==="text/html")throw Error("Request is not supported by this version of MuxCode Server (Server responded with text/html)");return g}),_.interceptors.error.use(Xc),new __({client:_})}var Xg=Gg(Lg(),1);function c_(c,_){return Y(c)&&c._tag===_}function n(c,_){if(!Y(c))return;if(c.name===_&&Y(c.data))return c.data;if(c._tag===_)return c;return}function W(c,_){return typeof c[_]==="string"?c[_]:void 0}function Vg(c){return Array.isArray(c.issues)?c.issues.filter((_)=>{if(!Y(_))return!1;return typeof _.message==="string"&&Array.isArray(_.path)&&_.path.every((g)=>typeof g==="string")}):[]}function g_(c){if(c instanceof Error&&Y(c.cause)&&"body"in c.cause){let f=g_(c.cause.body);if(f)return f}if(c_(c,"CliError")){if(typeof c.exitCode==="number")process.exitCode=c.exitCode;return W(c,"message")??""}if(k_.hasName(c,"MCPFailed"))return`MCP server "${Y(c)&&Y(c.data)?W(c.data,"name"):void 0}" failed. Note, muxcode does not support MCP authentication yet.`;if(c_(c,"AccountServiceError")||c_(c,"AccountTransportError"))return W(c,"message")??"";let _=n(c,"ProviderModelNotFoundError");if(_){let f=Array.isArray(_.suggestions)?_.suggestions.filter((k)=>typeof k==="string"):[];return[`Model not found: ${W(_,"providerID")}/${W(_,"modelID")}`,...f.length?["Did you mean: "+f.join(", ")]:[],"Try: `muxcode models` to list available models","Or check your config (muxcode.json) provider/model names"].join(`
9
+ `)}let g=n(c,"ProviderInitError");if(g)return`Failed to initialize provider "${W(g,"providerID")}". Check credentials and configuration.`;let d=n(c,"ConfigJsonError");if(d){let f=W(d,"message");return`Config file at ${W(d,"path")} is not valid JSON(C)`+(f?`: ${f}`:"")}let l=n(c,"ConfigDirectoryTypoError");if(l)return`Directory "${W(l,"dir")}" in ${W(l,"path")} is not valid. Rename the directory to "${W(l,"suggestion")}" or remove it. This is a common typo.`;let O=n(c,"ConfigFrontmatterError");if(O)return W(O,"message")??"";let S=n(c,"ConfigInvalidError");if(S){let f=W(S,"path"),k=W(S,"message"),T=Vg(S);return[`Configuration is invalid${f&&f!=="config"?` at ${f}`:""}`+(k?`: ${k}`:""),...T.map((x)=>"\u21B3 "+x.message+" "+x.path.join("."))].join(`
10
+ `)}if(c_(c,"UICancelledError")||k_.hasName(c,"UICancelledError"))return"";return}function O_(c){return Zc(c)}var wh={left:["\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557","\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551","\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551","\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551","\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551","\u255A\u2550\u255D \u255A\u2550\u255D"],right:["\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557","\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D","\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 ","\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D ","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2554\u255D \u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"]},hh={left:[" ","\u2588\u2580\u2580\u2580","\u2588_^\u2588","\u2580\u2580\u2580\u2580"],right:[" ","\u2588\u2580\u2580\u2588","\u2588__\u2588","\u2580\u2580\u2580\u2580"]};var Q={};Wc(Q,{unknownKeys:()=>Rc,toBindingConfig:()=>qg,parse:()=>Qc,defaultValue:()=>vg,bindingDefaults:()=>Eg,TuiKeybind:()=>Q,LeaderDefault:()=>Jc,Keybinds:()=>bg,KeybindOverrides:()=>Ig,Descriptions:()=>Qg,Definitions:()=>v,CommandMap:()=>Ic,BindingValueSchema:()=>T_});var Yc=e.Struct({name:e.String,ctrl:e.optional(e.Boolean),shift:e.optional(e.Boolean),meta:e.optional(e.Boolean),super:e.optional(e.Boolean),hyper:e.optional(e.Boolean)}),Wg=e.StructWithRest(e.Struct({key:e.Union([e.String,Yc]),event:e.optional(e.Literals(["press","release"])),preventDefault:e.optional(e.Boolean),fallthrough:e.optional(e.Boolean)}),[e.Record(e.String,e.Unknown)]),Vc=e.Union([e.String,Yc,Wg]),T_=e.Union([e.Literal(!1),e.Literal("none"),Vc,e.Array(Vc)]),Yg=process.platform==="win32"?"ctrl+z,ctrl+-,super+z":"ctrl+-,super+z",Jc="ctrl+x",w=(c,_)=>({default:c,description:_}),v={leader:w(Jc,"Leader key for keybind combinations"),app_exit:w("ctrl+c,ctrl+d,<leader>q","Exit the application"),app_debug:w("none","Toggle debug panel"),app_console:w("none","Toggle console"),app_heap_snapshot:w("none","Write heap snapshot"),app_toggle_animations:w("none","Toggle animations"),app_toggle_file_context:w("none","Toggle file context"),app_toggle_diffwrap:w("none","Toggle diff wrapping"),app_toggle_paste_summary:w("none","Toggle paste summary"),app_toggle_session_directory_filter:w("none","Toggle session directory filtering"),command_list:w("ctrl+p","List available commands"),help_show:w("none","Open help dialog"),docs_open:w("none","Open documentation"),diff_close:w("escape,q","Close diff viewer"),diff_toggle:w("enter,space","Toggle diff viewer item"),diff_expand:w("right","Expand diff viewer item"),diff_expand_all:w("E","Expand all diff viewer folders"),diff_collapse:w("left","Collapse diff viewer item"),diff_switch_focus:w("tab","Switch diff viewer focus"),diff_next_file:w("n","Jump to next diff file"),diff_previous_file:w("p","Jump to previous diff file"),diff_toggle_file_tree:w("b","Toggle diff viewer file tree"),diff_single_patch:w("s","Toggle single patch view"),diff_switch_source:w("d","Switch diff viewer source"),diff_toggle_view:w("v","Toggle diff viewer split or unified view"),diff_help:w("?","Show more diff viewer shortcuts"),editor_open:w("<leader>e","Open external editor"),theme_list:w("<leader>t","List available themes"),theme_switch_mode:w("none","Switch between light and dark theme mode"),theme_mode_lock:w("none","Lock or unlock theme mode"),sidebar_toggle:w("<leader>b","Toggle sidebar"),scrollbar_toggle:w("none","Toggle session scrollbar"),status_view:w("<leader>s","View status"),session_export:w("<leader>x","Export session to editor"),session_copy:w("none","Copy session transcript"),session_new:w("<leader>n","Create a new session"),session_list:w("<leader>l","List all sessions"),session_timeline:w("<leader>g","Show session timeline"),session_fork:w("none","Fork session from message"),session_rename:w("ctrl+r","Rename session"),session_delete:w("ctrl+d","Delete session"),session_share:w("none","Share current session"),session_unshare:w("none","Unshare current session"),session_interrupt:w("escape","Interrupt current session"),session_compact:w("<leader>c","Compact the session"),session_toggle_timestamps:w("none","Toggle message timestamps"),session_toggle_generic_tool_output:w("none","Toggle generic tool output"),session_child_first:w("<leader>down","Go to first child session"),session_child_cycle:w("right","Go to next child session"),session_child_cycle_reverse:w("left","Go to previous child session"),session_parent:w("up","Go to parent session"),session_pin_toggle:w("ctrl+f","Pin or unpin session in the session list"),session_quick_switch_1:w("<leader>1","Switch to session in quick slot 1"),session_quick_switch_2:w("<leader>2","Switch to session in quick slot 2"),session_quick_switch_3:w("<leader>3","Switch to session in quick slot 3"),session_quick_switch_4:w("<leader>4","Switch to session in quick slot 4"),session_quick_switch_5:w("<leader>5","Switch to session in quick slot 5"),session_quick_switch_6:w("<leader>6","Switch to session in quick slot 6"),session_quick_switch_7:w("<leader>7","Switch to session in quick slot 7"),session_quick_switch_8:w("<leader>8","Switch to session in quick slot 8"),session_quick_switch_9:w("<leader>9","Switch to session in quick slot 9"),stash_delete:w("ctrl+d","Delete stash entry"),model_provider_list:w("ctrl+a","Open provider list from model dialog"),model_favorite_toggle:w("ctrl+f","Toggle model favorite status"),model_list:w("<leader>m","List available models"),model_cycle_recent:w("f2","Next recently used model"),model_cycle_recent_reverse:w("shift+f2","Previous recently used model"),model_cycle_favorite:w("none","Next favorite model"),model_cycle_favorite_reverse:w("none","Previous favorite model"),mcp_list:w("none","List MCP servers"),provider_connect:w("none","Connect provider"),console_org_switch:w("none","Switch console organization"),agent_list:w("<leader>a","List agents"),agent_cycle:w("tab","Next agent"),agent_cycle_reverse:w("shift+tab","Previous agent"),variant_cycle:w("ctrl+t","Cycle model variants"),variant_list:w("none","List model variants"),messages_page_up:w("pageup,ctrl+alt+b","Scroll messages up by one page"),messages_page_down:w("pagedown,ctrl+alt+f","Scroll messages down by one page"),messages_line_up:w("ctrl+alt+y","Scroll messages up by one line"),messages_line_down:w("ctrl+alt+e","Scroll messages down by one line"),messages_half_page_up:w("ctrl+alt+u","Scroll messages up by half page"),messages_half_page_down:w("ctrl+alt+d","Scroll messages down by half page"),messages_first:w("ctrl+g,home","Navigate to first message"),messages_last:w("ctrl+alt+g,end","Navigate to last message"),messages_next:w("none","Navigate to next message"),messages_previous:w("none","Navigate to previous message"),messages_last_user:w("none","Navigate to last user message"),messages_copy:w("<leader>y","Copy message"),messages_undo:w("<leader>u","Undo message"),messages_redo:w("<leader>r","Redo message"),messages_toggle_conceal:w("<leader>h","Toggle code block concealment in messages"),tool_details:w("none","Toggle tool details visibility"),display_thinking:w("none","Toggle thinking blocks visibility"),prompt_submit:w("none","Submit prompt"),prompt_editor_context_clear:w("none","Clear editor context"),prompt_skills:w("none","Open skill selector"),prompt_stash:w("none","Stash prompt"),prompt_stash_pop:w("none","Pop stashed prompt"),prompt_stash_list:w("none","List stashed prompts"),workspace_set:w("none","Set workspace"),input_clear:w("ctrl+c","Clear input field"),input_paste:w({key:"ctrl+v",preventDefault:!1},"Paste from clipboard"),input_submit:w("return","Submit input"),input_newline:w("shift+return,ctrl+return,alt+return,ctrl+j","Insert newline in input"),input_move_left:w("left,ctrl+b","Move cursor left in input"),input_move_right:w("right,ctrl+f","Move cursor right in input"),input_move_up:w("up","Move cursor up in input"),input_move_down:w("down","Move cursor down in input"),input_select_left:w("shift+left","Select left in input"),input_select_right:w("shift+right","Select right in input"),input_select_up:w("shift+up","Select up in input"),input_select_down:w("shift+down","Select down in input"),input_line_home:w("ctrl+a","Move to start of line in input"),input_line_end:w("ctrl+e","Move to end of line in input"),input_select_line_home:w("ctrl+shift+a","Select to start of line in input"),input_select_line_end:w("ctrl+shift+e","Select to end of line in input"),input_visual_line_home:w("alt+a","Move to start of visual line in input"),input_visual_line_end:w("alt+e","Move to end of visual line in input"),input_select_visual_line_home:w("alt+shift+a","Select to start of visual line in input"),input_select_visual_line_end:w("alt+shift+e","Select to end of visual line in input"),input_buffer_home:w("home","Move to start of buffer in input"),input_buffer_end:w("end","Move to end of buffer in input"),input_select_buffer_home:w("shift+home","Select to start of buffer in input"),input_select_buffer_end:w("shift+end","Select to end of buffer in input"),input_delete_line:w("ctrl+shift+d","Delete line in input"),input_delete_to_line_end:w("ctrl+k","Delete to end of line in input"),input_delete_to_line_start:w("ctrl+u","Delete to start of line in input"),input_backspace:w("backspace,shift+backspace","Backspace in input"),input_delete:w("ctrl+d,delete,shift+delete","Delete character in input"),input_undo:w(Yg,"Undo in input"),input_redo:w("ctrl+.,super+shift+z","Redo in input"),input_word_forward:w("alt+f,alt+right,ctrl+right","Move word forward in input"),input_word_backward:w("alt+b,alt+left,ctrl+left","Move word backward in input"),input_select_word_forward:w("alt+shift+f,alt+shift+right","Select word forward in input"),input_select_word_backward:w("alt+shift+b,alt+shift+left","Select word backward in input"),input_delete_word_forward:w("alt+d,alt+delete,ctrl+delete","Delete word forward in input"),input_delete_word_backward:w("ctrl+w,ctrl+backspace,alt+backspace","Delete word backward in input"),input_select_all:w("super+a","Select all in input"),history_previous:w("up","Previous history item"),history_next:w("down","Next history item"),"dialog.select.prev":w("up,ctrl+p","Move to previous dialog item"),"dialog.select.next":w("down,ctrl+n","Move to next dialog item"),"dialog.select.page_up":w("pageup","Move up one page in dialog"),"dialog.select.page_down":w("pagedown","Move down one page in dialog"),"dialog.select.home":w("home","Move to first dialog item"),"dialog.select.end":w("end","Move to last dialog item"),"dialog.select.submit":w("return","Submit selected dialog item"),"dialog.prompt.submit":w("return","Submit dialog prompt"),"dialog.mcp.toggle":w("space","Toggle MCP in MCP dialog"),"prompt.autocomplete.prev":w("up,ctrl+p","Move to previous autocomplete item"),"prompt.autocomplete.next":w("down,ctrl+n","Move to next autocomplete item"),"prompt.autocomplete.hide":w("escape","Hide autocomplete"),"prompt.autocomplete.select":w("return","Select autocomplete item"),"prompt.autocomplete.complete":w("tab","Complete autocomplete item"),"permission.prompt.fullscreen":w("ctrl+f","Toggle permission prompt fullscreen"),"plugins.toggle":w("space","Toggle plugin"),"dialog.plugins.install":w("shift+i","Install plugin from plugin dialog"),terminal_suspend:w("ctrl+z","Suspend terminal"),terminal_title_toggle:w("none","Toggle terminal title"),tips_toggle:w("<leader>h","Toggle tips on home screen"),plugin_manager:w("none","Open plugin manager dialog"),plugin_install:w("none","Install plugin"),which_key_toggle:w("ctrl+alt+k","Toggle which-key panel"),which_key_layout_toggle:w("ctrl+alt+shift+k","Switch which-key layout"),which_key_pending_toggle:w("ctrl+alt+shift+p","Toggle which-key pending preview"),which_key_group_previous:w("ctrl+alt+left,ctrl+alt+[","Previous which-key group"),which_key_group_next:w("ctrl+alt+right,ctrl+alt+]","Next which-key group"),which_key_scroll_up:w("ctrl+alt+up,ctrl+alt+p","Scroll which-key up"),which_key_scroll_down:w("ctrl+alt+down,ctrl+alt+n","Scroll which-key down"),which_key_page_up:w("ctrl+alt+pageup","Page which-key up"),which_key_page_down:w("ctrl+alt+pagedown","Page which-key down"),which_key_home:w("ctrl+alt+home","Jump to first which-key binding"),which_key_end:w("ctrl+alt+end","Jump to last which-key binding")},Jg=new Set(Object.keys(v)),Ig=e.Struct(Object.fromEntries(Object.entries(v).map(([c,_])=>[c,e.optional(T_).annotate({description:_.description})]))).annotate({description:"TUI keybinding overrides"}),Qg=Object.fromEntries(Object.entries(v).map(([c,_])=>[c,_.description])),Ic={app_exit:"app.exit",app_debug:"app.debug",app_console:"app.console",app_heap_snapshot:"app.heap_snapshot",app_toggle_animations:"app.toggle.animations",app_toggle_file_context:"app.toggle.file_context",app_toggle_diffwrap:"app.toggle.diffwrap",app_toggle_paste_summary:"app.toggle.paste_summary",app_toggle_session_directory_filter:"app.toggle.session_directory_filter",command_list:"command.palette.show",help_show:"help.show",docs_open:"docs.open",diff_close:"diff.close",diff_toggle:"diff.toggle",diff_expand:"diff.expand",diff_expand_all:"diff.expand_all",diff_collapse:"diff.collapse",diff_switch_focus:"diff.switch_focus",diff_next_file:"diff.next_file",diff_previous_file:"diff.previous_file",diff_toggle_file_tree:"diff.toggle_file_tree",diff_single_patch:"diff.single_patch",diff_switch_source:"diff.switch_source",diff_toggle_view:"diff.toggle_view",diff_help:"diff.help",editor_open:"prompt.editor",theme_list:"theme.switch",theme_switch_mode:"theme.switch_mode",theme_mode_lock:"theme.mode.lock",sidebar_toggle:"session.sidebar.toggle",scrollbar_toggle:"session.toggle.scrollbar",status_view:"muxcode.status",session_export:"session.export",session_copy:"session.copy",session_new:"session.new",session_list:"session.list",session_timeline:"session.timeline",session_fork:"session.fork",session_rename:"session.rename",session_delete:"session.delete",session_share:"session.share",session_unshare:"session.unshare",session_interrupt:"session.interrupt",session_compact:"session.compact",session_toggle_timestamps:"session.toggle.timestamps",session_toggle_generic_tool_output:"session.toggle.generic_tool_output",session_child_first:"session.child.first",session_child_cycle:"session.child.next",session_child_cycle_reverse:"session.child.previous",session_parent:"session.parent",session_pin_toggle:"session.pin.toggle",session_quick_switch_1:"session.quick_switch.1",session_quick_switch_2:"session.quick_switch.2",session_quick_switch_3:"session.quick_switch.3",session_quick_switch_4:"session.quick_switch.4",session_quick_switch_5:"session.quick_switch.5",session_quick_switch_6:"session.quick_switch.6",session_quick_switch_7:"session.quick_switch.7",session_quick_switch_8:"session.quick_switch.8",session_quick_switch_9:"session.quick_switch.9",stash_delete:"stash.delete",model_provider_list:"model.dialog.provider",model_favorite_toggle:"model.dialog.favorite",model_list:"model.list",model_cycle_recent:"model.cycle_recent",model_cycle_recent_reverse:"model.cycle_recent_reverse",model_cycle_favorite:"model.cycle_favorite",model_cycle_favorite_reverse:"model.cycle_favorite_reverse",mcp_list:"mcp.list",provider_connect:"provider.connect",console_org_switch:"console.org.switch",agent_list:"agent.list",agent_cycle:"agent.cycle",agent_cycle_reverse:"agent.cycle.reverse",variant_cycle:"variant.cycle",variant_list:"variant.list",messages_page_up:"session.page.up",messages_page_down:"session.page.down",messages_line_up:"session.line.up",messages_line_down:"session.line.down",messages_half_page_up:"session.half.page.up",messages_half_page_down:"session.half.page.down",messages_first:"session.first",messages_last:"session.last",messages_next:"session.message.next",messages_previous:"session.message.previous",messages_last_user:"session.messages_last_user",messages_copy:"messages.copy",messages_undo:"session.undo",messages_redo:"session.redo",messages_toggle_conceal:"session.toggle.conceal",tool_details:"session.toggle.actions",display_thinking:"session.toggle.thinking",prompt_submit:"prompt.submit",prompt_editor_context_clear:"prompt.editor_context.clear",prompt_skills:"prompt.skills",prompt_stash:"prompt.stash",prompt_stash_pop:"prompt.stash.pop",prompt_stash_list:"prompt.stash.list",workspace_set:"workspace.set",input_clear:"prompt.clear",input_paste:"prompt.paste",input_submit:"input.submit",input_newline:"input.newline",input_move_left:"input.move.left",input_move_right:"input.move.right",input_move_up:"input.move.up",input_move_down:"input.move.down",input_select_left:"input.select.left",input_select_right:"input.select.right",input_select_up:"input.select.up",input_select_down:"input.select.down",input_line_home:"input.line.home",input_line_end:"input.line.end",input_select_line_home:"input.select.line.home",input_select_line_end:"input.select.line.end",input_visual_line_home:"input.visual.line.home",input_visual_line_end:"input.visual.line.end",input_select_visual_line_home:"input.select.visual.line.home",input_select_visual_line_end:"input.select.visual.line.end",input_buffer_home:"input.buffer.home",input_buffer_end:"input.buffer.end",input_select_buffer_home:"input.select.buffer.home",input_select_buffer_end:"input.select.buffer.end",input_delete_line:"input.delete.line",input_delete_to_line_end:"input.delete.to.line.end",input_delete_to_line_start:"input.delete.to.line.start",input_backspace:"input.backspace",input_delete:"input.delete",input_undo:"input.undo",input_redo:"input.redo",input_word_forward:"input.word.forward",input_word_backward:"input.word.backward",input_select_word_forward:"input.select.word.forward",input_select_word_backward:"input.select.word.backward",input_delete_word_forward:"input.delete.word.forward",input_delete_word_backward:"input.delete.word.backward",input_select_all:"input.select.all",history_previous:"prompt.history.previous",history_next:"prompt.history.next",terminal_suspend:"terminal.suspend",terminal_title_toggle:"terminal.title.toggle",tips_toggle:"tips.toggle",plugin_manager:"plugins.list",plugin_install:"plugins.install",which_key_toggle:"which-key.toggle",which_key_layout_toggle:"which-key.layout.toggle",which_key_pending_toggle:"which-key.pending.toggle",which_key_group_previous:"which-key.group.previous",which_key_group_next:"which-key.group.next",which_key_scroll_up:"which-key.scroll.up",which_key_scroll_down:"which-key.scroll.down",which_key_page_up:"which-key.page.up",which_key_page_down:"which-key.page.down",which_key_home:"which-key.home",which_key_end:"which-key.end"},Rg=Object.fromEntries(Object.entries(v).map(([c,_])=>[Ic[c]??c,_.description]));function qg(c){return Object.fromEntries(Object.entries(c))}var zg=e.decodeUnknownSync(T_);function vg(c){return v[c].default}function Qc(c){let _=Rc(c);if(_.length)throw Error(`Unrecognized keybind${_.length===1?"":"s"}: ${_.join(", ")}`);return Object.fromEntries(Object.entries(v).map(([g,d])=>[g,zg(c[g]??d.default)]))}var bg={parse:Qc};function Rc(c){return Object.keys(c).filter((_)=>!Jg.has(_))}function Eg(){return({command:c,binding:_})=>{if(_.desc!==void 0)return;return{desc:Rg[c]}}}var qc=["default","question","permission","error","done","subagent_done"];function yg(c){return qc.includes(c)}function vc(c,_,g){if(!Y(_))return{};return Object.fromEntries(Object.entries(_).flatMap(([d,l])=>{if(!yg(d))return[];if(typeof l!=="string")return[];let O=g?.trim?l.trim():l;if(!O)return[];return[[d,G.resolveFilePath(c,O)]]}))}var bc=2000,ng=e.Int.check(e.isGreaterThan(0)).annotate({description:"Leader key timeout in milliseconds"}),Ag=e.Struct({default:e.optional(e.String),question:e.optional(e.String),permission:e.optional(e.String),error:e.optional(e.String),done:e.optional(e.String),subagent_done:e.optional(e.String)}),B_=e.Number.check(e.isGreaterThanOrEqualTo(0.001)),u_=e.Struct({enabled:e.Boolean.annotate({description:"Enable scroll acceleration"})}).annotate({description:"Scroll acceleration settings"}),K_=e.Literals(["auto","stacked"]).annotate({description:"Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"}),Fg=e.Struct({enabled:e.optional(e.Boolean),notifications:e.optional(e.Boolean),sound:e.optional(e.Boolean),volume:e.optional(e.Number.check(e.isGreaterThanOrEqualTo(0),e.isLessThanOrEqualTo(1))),sound_pack:e.optional(e.String),sounds:e.optional(Ag)}).annotate({description:"Attention notification and sound settings"}),zc=e.Int.check(e.isGreaterThan(0)),Hg=e.Struct({max_height:e.optional(zc).annotate({description:"Prompt textarea max height"}),max_width:e.optional(e.Union([zc,e.Literal("auto")])).annotate({description:"Home prompt max width: a positive integer for a fixed cap, or 'auto' to scale with terminal width"})}).annotate({description:"Prompt size settings"}),Ec=e.Struct({$schema:e.optional(e.String),theme:e.optional(e.String),keybinds:e.optional(Q.KeybindOverrides),plugin:e.optional(e.Array(m.Spec)),plugin_enabled:e.optional(e.Record(e.String,e.Boolean)),leader_timeout:e.optional(ng),attention:e.optional(Fg),prompt:e.optional(Hg),scroll_speed:e.optional(B_).annotate({description:"TUI scroll speed"}),scroll_acceleration:e.optional(u_),diff_style:e.optional(K_),mouse:e.optional(e.Boolean).annotate({description:"Enable or disable mouse capture (default: true)"})});var U_={};Wc(U_,{waitForDependencies:()=>ew,layer:()=>cg,get:()=>dw,defaultLayer:()=>gg,TuiConfig:()=>U_,Service:()=>i,Info:()=>_g});import _w from"path";import yc from"path";var b=h_({service:"tui.migrate"}),Cg="https://muxcode.ai/tui.json",mg=e.decodeUnknownOption(e.String),nc=e.decodeUnknownOption(e.Record(e.String,e.Unknown)),ig=e.decodeUnknownOption(B_),rg=e.decodeUnknownOption(u_),sg=e.decodeUnknownOption(K_);async function tc(c){let _=await ag(c);for(let g of _){let d=await G.readText(g).catch((N)=>{b.warn("failed to read config for tui migration",{path:g,error:N});return});if(!d)continue;let l=[],O=Ac(d,l,{allowTrailingComma:!0});if(l.length||!O||typeof O!=="object"||Array.isArray(O))continue;let S=mg("theme"in O?O.theme:void 0),f=nc("keybinds"in O?O.keybinds:void 0),k=nc("tui"in O?O.tui:void 0),T={theme:E.getOrUndefined(S),keybinds:E.getOrUndefined(f),tui:E.getOrUndefined(k)},x=T.tui?og(T.tui):void 0;if(T.theme===void 0&&T.keybinds===void 0&&!x)continue;let K=yc.join(yc.dirname(g),"tui.json");if(await G.exists(K))continue;let j={$schema:Cg};if(T.theme!==void 0)j.theme=T.theme;if(T.keybinds!==void 0)j.keybinds=T.keybinds;if(x)Object.assign(j,x);if(!await G.write(K,JSON.stringify(j,null,2)).then(()=>!0).catch((N)=>{return b.warn("failed to write tui migration target",{from:g,to:K,error:N}),!1}))continue;if(!await pg(g,d)){b.warn("tui config migrated but source file was not stripped",{from:g,to:K});continue}b.info("migrated tui config",{from:g,to:K})}}function og(c){let _={scroll_speed:E.getOrUndefined(ig(c.scroll_speed)),scroll_acceleration:E.getOrUndefined(rg(c.scroll_acceleration)),diff_style:E.getOrUndefined(sg(c.diff_style))};return _.scroll_speed===void 0&&_.diff_style===void 0&&_.scroll_acceleration===void 0?void 0:_}async function pg(c,_){let g=c+".tui-migration.bak";if(!(await G.exists(g)?!0:await G.write(g,_).then(()=>!0).catch((S)=>{return b.warn("failed to backup source config during tui migration",{path:c,backup:g,error:S}),!1})))return!1;let O=["theme","keybinds","tui"].reduce((S,f)=>{let k=Fc(S,[f],void 0,{formattingOptions:{insertSpaces:!0,tabSize:2}});if(!k.length)return S;return Hc(S,k)},_);return G.write(c,O).then(()=>{return b.info("stripped tui keys from server config",{path:c,backup:g}),!0}).catch((S)=>{return b.warn("failed to strip legacy tui keys from server config",{path:c,backup:g,error:S}),!1})}async function ag(c){let _=[...F(w_.Path.config,"muxcode"),...await G.findUp(["muxcode.json","muxcode.jsonc"],c.cwd,void 0,{rootFirst:!0})];for(let d of A(c.directories))_.push(...F(d,"muxcode"));if(q.MUXCODE_CONFIG)_.push(q.MUXCODE_CONFIG);return(await Promise.all(A(_).map(async(d)=>{return await G.exists(d)?d:void 0}))).filter((d)=>!!d)}var Pc=e_.Reference("CurrentWorkingDirectory",{defaultValue:()=>process.cwd()});var H=h_({service:"tui.config"}),_g=Ec;class i extends e_.Service()("@muxcode/TuiConfig"){}function cw(c,_){if(G.contains(_.directory,c))return"local";return"global"}function gw(c){let _={...c};if(!("tui"in _))return _;if(!Y(_.tui))return delete _.tui,_;let g=_.tui;return delete _.tui,{...g,..._}}function ww(c,_){if(!Y(c.keybinds))return c;let g=Q.unknownKeys(c.keybinds);if(!g.length)return c;return H.warn("ignored unknown tui keybinds",{path:_,keybinds:g,hint:"Remove these entries or rename them to keys from the tui.json schema."}),{...c,keybinds:Object.fromEntries(Object.entries(c.keybinds).filter(([d])=>!g.includes(d)))}}var hw=D.fn("TuiConfig.loadState")(function*(c){let _=yield*D_.Service,g=0,d=(u,$)=>D.gen(function*(){let N=u.plugin;if(!N)return u;for(let M=0;M<N.length;M++)N[M]=yield*D.promise(()=>m.resolvePluginSpec(N[M],$));return u}),l=(u,$)=>D.gen(function*(){let N=yield*D.promise(()=>ac.substitute({text:u,type:"path",path:$,missing:"empty"})),M=M_.jsonc(N,$);if(!Y(M))return{};let V=ww(gw(M),$),X=M_.schema(_g,V,$),I=X.attention?.sounds?{...X,attention:{...X.attention,sounds:vc(_w.dirname($),X.attention.sounds)}}:X;return yield*d(I,$)}).pipe(D.catchCause((N)=>D.sync(()=>{let M=N_.squash(N),V=g_(M)??O_(M);return H.warn("skipping invalid tui config",{path:$,reason:V}),{}}))),O=(u)=>D.gen(function*(){let $=yield*_.readFileStringSafe(u).pipe(D.catchCause((N)=>D.sync(()=>{let M=N_.squash(N),V=g_(M)??O_(M);H.warn("failed to read tui config",{path:u,reason:V});return})));if(!$)return{};return H.info("loading tui config",{path:u}),yield*l($,u)}),S=(u,$)=>D.gen(function*(){let N=yield*O($);if(Object.keys(N).length)g+=1,H.info("applying tui config",{path:$,order:g});if(u.result=rc(u.result,N),!N.plugin?.length)return;let M=cw($,c),V=m.deduplicatePluginOrigins([...u.plugin_origins,...N.plugin.map((X)=>({spec:X,scope:M,source:$}))]);u.result.plugin=V.map((X)=>X.spec),u.plugin_origins=V}),f=yield*pc(c.directory);yield*D.promise(()=>tc({directories:f,cwd:c.directory}));let k=q.MUXCODE_DISABLE_PROJECT_CONFIG?[]:yield*oc("tui",c.directory),T={result:{},plugin_origins:[]};for(let u of F(w_.Path.config,"tui"))yield*S(T,u);if(q.MUXCODE_TUI_CONFIG){let u=q.MUXCODE_TUI_CONFIG;yield*S(T,u),H.debug("loaded custom tui config",{path:u})}for(let u of k)yield*S(T,u);let x=A(f).filter((u)=>u.endsWith(".muxcode")||u===q.MUXCODE_CONFIG_DIR);for(let u of x){if(!u.endsWith(".muxcode")&&u!==q.MUXCODE_CONFIG_DIR)continue;for(let $ of F(u,"tui"))yield*S(T,$)}let K={...T.result.keybinds};if(process.platform==="win32"){K.terminal_suspend="none";let u=Q.defaultValue("input_undo");K.input_undo??=A(["ctrl+z",...typeof u==="string"?u.split(","):[]]).join(",")}let J=Q.parse(K),j={...T.result,attention:{enabled:T.result.attention?.enabled??!1,notifications:T.result.attention?.notifications??!0,sound:T.result.attention?.sound??!0,volume:T.result.attention?.volume??0.4,sound_pack:T.result.attention?.sound_pack??"muxcode.default",sounds:T.result.attention?.sounds??{}},keybinds:$_(Q.toBindingConfig(J),{commandMap:Q.CommandMap,bindingDefaults:Q.bindingDefaults()}),leader_timeout:T.result.leader_timeout??bc,plugin_origins:T.plugin_origins.length?T.plugin_origins:void 0};return{config:j,dirs:j.plugin?.length?x:[]}}),cg=d_.effect(i,D.gen(function*(){let c=yield*Pc,_=yield*j_.Service,g=yield*hw({directory:c}),d=yield*D.forEach(g.dirs,(S)=>_.install(S,{add:[{name:"@muxcode-ai/plugin",version:ic?void 0:mc}]}).pipe(D.forkScoped),{concurrency:"unbounded"}),l=D.fn("TuiConfig.get")(()=>D.succeed(g.config)),O=D.fn("TuiConfig.waitForDependencies")(()=>D.forEach(d,Cc.join,{concurrency:"unbounded"}).pipe(D.ignore(),D.asVoid));return i.of({get:l,waitForDependencies:O})}).pipe(D.withSpan("TuiConfig.layer"))),gg=cg.pipe(d_.provide(j_.defaultLayer),d_.provide(D_.defaultLayer)),{runPromise:wg}=sc(i,gg);async function ew(){await wg((c)=>c.waitForDependencies())}async function dw(){return wg((c)=>c.get())}
11
+ export{wh as Ui,hh as Vi,Ug as Wi,g_ as Xi,O_ as Yi,Q as Zi,yg as _i,vc as $i,U_ as aj};