agestra 4.10.1 → 4.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@
12
12
  "name": "agestra",
13
13
  "source": "./",
14
14
  "description": "Orchestrate Ollama, Gemini, and Codex for multi-AI debates, code review, and cross-validation",
15
- "version": "4.10.1",
15
+ "version": "4.10.2",
16
16
  "author": {
17
17
  "name": "mua-vtuber"
18
18
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agestra",
3
- "version": "4.10.1",
3
+ "version": "4.10.2",
4
4
  "description": "Claude Code plugin — orchestrate Ollama, Gemini, and Codex for multi-AI debates, code review, and cross-validation",
5
5
  "mcpServers": {
6
6
  "agestra": {
package/dist/bundle.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as ___cr } from 'module';import { fileURLToPath as ___fu } from 'url';import { dirname as ___dn } from 'path';const __filename = ___fu(import.meta.url);const __dirname = ___dn(__filename);const require = ___cr(import.meta.url);
3
- var PS=Object.create;var Ic=Object.defineProperty;var TS=Object.getOwnPropertyDescriptor;var ES=Object.getOwnPropertyNames;var RS=Object.getPrototypeOf,IS=Object.prototype.hasOwnProperty;var an=(t,e)=>()=>(t&&(e=t(t=0)),e);var E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ze=(t,e)=>{for(var r in e)Ic(t,r,{get:e[r],enumerable:!0})},AS=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ES(e))!IS.call(t,o)&&o!==r&&Ic(t,o,{get:()=>e[o],enumerable:!(n=TS(e,o))||n.enumerable});return t};var Jp=(t,e,r)=>(r=t!=null?PS(RS(t)):{},AS(e||!t||!t.__esModule?Ic(r,"default",{value:t,enumerable:!0}):r,t));var Yp,fo,Qp,Xp,ef,tf,rf,mo,nf,qs,of,sf,af,cf,uf,lf,Vs,Ac,Cc,xj,df,ln,Dc,zc,pf,ff,Bs,xr,Oc,mf,hf,dn,jt=an(()=>{"use strict";Yp="4.10.1",fo="http://localhost:11434",Qp="llama3",Xp=".agestra/.jobs",ef=".agestra/traces",tf=".agestra/worktrees",rf=".agestra/sessions",mo=".agestra/workspace",nf="individual",qs="debates",of="synthesis",sf="issue",af=".agestra/workers",cf=Object.freeze(["PATH","HOME","USER","USERPROFILE","APPDATA","LOCALAPPDATA","TEMP","TMP","TMPDIR","SHELL","LANG","LC_ALL","NODE_PATH","SystemRoot","SystemDrive","COMSPEC","ComSpec","windir"]),uf=2,lf=6e4,Vs=20,Ac=5e4,Cc=10,xj=Object.freeze([3,5,10]),df=Object.freeze(["agree","disagree","abstain","revise"]),ln="votes",Dc=2,zc=2,pf=1440*60*1e3,ff=3600*1e3,Bs=Object.freeze(["ko","zh","ja","en"]),xr="ko",Oc="en",mf="[REDACTED]",hf=["","--- REQUIRED RESPONSE FORMAT ---","Respond with JSON only, matching exactly this shape:",'{ "agrees": true | false, "feedback": "specific issues or why you agree", "suggestions": "concrete changes if you disagree (optional, may be omitted)" }',"No prose, markdown, or explanation outside the JSON object. The JSON must be the entire response or wrapped in a single ```json code fence.","-------------------------------"].join(`
4
- `),dn=Object.freeze({auto:Object.freeze({name:"auto",description:"Auto-detect build profile from project structure (package.json scripts, tsconfig, vitest config, etc.).",command:"npx",args:Object.freeze([])}),tsc:Object.freeze({name:"tsc",description:"TypeScript project-references build via `npx tsc -b --noEmit`.",command:"npx",args:Object.freeze(["tsc","-b","--noEmit"])}),vitest:Object.freeze({name:"vitest",description:"Run the Vitest unit-test suite in CI mode.",command:"npx",args:Object.freeze(["vitest","run","--reporter=dot"])}),"npm-build":Object.freeze({name:"npm-build",description:"Run the project's `npm run build` script.",command:"npm",args:Object.freeze(["run","build"])}),"npm-test":Object.freeze({name:"npm-test",description:"Run the project's `npm test` script.",command:"npm",args:Object.freeze(["test","--","--run"])})})});import{execFileSync as CS}from"child_process";function pn(t){if(!Number.isFinite(t)||t<=0)return{delivered:!1};if(process.platform==="win32")try{return CS("taskkill",["/PID",String(t),"/T","/F"],{stdio:"ignore",windowsHide:!0}),{delivered:!0}}catch{try{return process.kill(t),{delivered:!0}}catch{return{delivered:!1}}}try{return process.kill(-t,"SIGTERM"),{delivered:!0}}catch{try{return process.kill(t,"SIGTERM"),{delivered:!0}}catch{return{delivered:!1}}}}function er(t,e=3e3){let r=t.pid;if(r)pn(r);else try{t.kill("SIGTERM")}catch{}setTimeout(()=>{try{t.kill("SIGKILL")}catch{}},e)}var ho=an(()=>{"use strict"});import{execFileSync as DS,spawn as zS}from"child_process";import{existsSync as OS}from"fs";function NS(t){return process.platform!=="win32"||t.includes("/")||t.includes("\\")?!1:MS.has(t.toLowerCase())}function jS(t){if(t.includes("\0"))throw new Error(`Windows shim arg contains null byte: ${JSON.stringify(t)}`);if(t.includes("%"))throw new Error(`Windows shim arg contains '%' which would trigger cmd.exe env expansion: ${JSON.stringify(t)}`);return/[\s"&^<>|()!]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function LS(t){let e=t.toLowerCase();if(fn.has(e))return fn.get(e)??null;try{let n=DS("where.exe",[t],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).split(/\r?\n/).map(a=>a.trim()).filter(Boolean);if(n.length===0)return fn.set(e,null),null;let o=n.find(a=>/\.(cmd|bat)$/i.test(a));if(o){let a={type:"cmd",path:o};return fn.set(e,a),a}let i=`${n[0]}.ps1`;if(OS(i)){let a={type:"powershell",path:i};return fn.set(e,a),a}}catch{}return fn.set(e,null),null}function Lt(t,e){if(!NS(t))return{command:t,args:e};let r=LS(t);return r?r.type==="cmd"?{command:"cmd.exe",args:["/d","/s","/c",r.path,...e.map(n=>jS(n))]}:{command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","RemoteSigned","-File",r.path,...e]}:{command:t,args:e}}function ze(t){let{command:e,args:r,timeout:n=12e4,cwd:o,env:s,stdin:i,maxBuffer:a=10485760,onStderrChunk:c}=t;return new Promise((u,l)=>{let d=Lt(e,r),p=zS(d.command,d.args,{cwd:o,env:s?{...process.env,...s}:void 0,stdio:[i?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),f="",m="",g=0,y=0,_=!1,x=null,v=!1,P=()=>{!v&&g+y>a&&(_=!0,v=!0,er(p))};p.stdout.on("data",Z=>{g+=Z.length,g<=a&&(f+=Z.toString()),P()}),p.stderr.on("data",Z=>{y+=Z.length;let De=Z.toString();if(y<=a&&(m+=De),P(),!v&&c){let Y=c(De);Y&&(x=Y,v=!0,er(p))}}),i&&p.stdin&&(p.stdin.write(i),p.stdin.end());let S=()=>{er(p),l(new Error(`CLI timeout after ${n}ms of inactivity: ${e} ${r.join(" ")}`))},N=setTimeout(S,n),L=()=>{clearTimeout(N),N=setTimeout(S,n)};p.stdout.on("data",L),p.stderr.on("data",L),p.on("close",Z=>{if(clearTimeout(N),x){l(x);return}u({stdout:f,stderr:m,exitCode:Z??1,truncated:_})}),p.on("error",Z=>{clearTimeout(N),l(new Error(`CLI spawn error: ${Z.message}`))})})}var MS,fn,mn=an(()=>{"use strict";ho();MS=new Set(["codex","gemini","npm","npx"]),fn=new Map});import{writeFileSync as ck,mkdirSync as bo,openSync as Fc,writeSync as Zc,fsyncSync as Df,closeSync as Uc,renameSync as uk,unlinkSync as lk,appendFileSync as dk}from"fs";import{dirname as wo,join as pk}from"path";import{randomUUID as fk}from"crypto";function se(t,e){let r=wo(t);bo(r,{recursive:!0});let n=pk(r,`.tmp-${fk().slice(0,8)}`);try{ck(n,e,"utf-8"),uk(n,t)}catch(o){try{lk(n)}catch{}throw o}}function Ue(t,e){se(t,JSON.stringify(e,null,2))}function ni(t,e){let r=wo(t);bo(r,{recursive:!0});let n=Fc(t,"a");try{Zc(n,e),Df(n)}finally{Uc(n)}}var ri,oi=an(()=>{"use strict";ri=class{buffer=new Map;flushTimer=null;flushIntervalMs;maxBufferSize;auditFsync;destroyed=!1;constructor(e){this.flushIntervalMs=e?.flushIntervalMs??2e3,this.maxBufferSize=e?.maxBufferSize??100,this.auditFsync=e?.auditFsync??!0,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>this.flush(),this.flushIntervalMs),this.flushTimer&&typeof this.flushTimer.unref=="function"&&this.flushTimer.unref())}append(e,r,n){if(this.destroyed)throw new Error("DurableAppendWriter has been destroyed");if(n==="audit"){if(this.auditFsync)ni(e,r);else{let s=wo(e);bo(s,{recursive:!0}),dk(e,r)}return}let o=this.buffer.get(e);o||(o=[],this.buffer.set(e,o)),o.push(r),o.length>=this.maxBufferSize&&this.flushFile(e),this.flushIntervalMs===0&&this.flushFile(e)}flush(){for(let e of this.buffer.keys())this.flushFile(e)}panicFlush(){for(let[e,r]of this.buffer)if(r.length!==0)try{let n=wo(e);bo(n,{recursive:!0});let o=Fc(e,"a");try{Zc(o,r.join("")),Df(o)}finally{Uc(o)}}catch{}this.buffer.clear()}destroy(){this.destroyed||(this.destroyed=!0,this.flushTimer!==null&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush())}flushFile(e){let r=this.buffer.get(e);if(!r||r.length===0)return;let n=wo(e);bo(n,{recursive:!0});let o=Fc(e,"a");try{Zc(o,r.join(""))}finally{Uc(o)}this.buffer.delete(e)}}});import{existsSync as zf,realpathSync as mk}from"fs";import{basename as hk,dirname as gk,isAbsolute as Nf,join as yk,normalize as vk,resolve as qc,relative as _k}from"path";function bk(t){return t===""||!t.startsWith("..")&&!Nf(t)}function Of(t){let e=[],r=qc(t);for(;!zf(r);){let o=gk(r);if(o===r)break;e.unshift(hk(r)),r=o}let n=zf(r)?mk(r):r;return e.reduce((o,s)=>yk(o,s),n)}function jf(t,e){let r=Of(e),n=Of(t),o=_k(r,n);return bk(o)}function Vc(t,e){let r=qc(e,t);return jf(r,e)}function ht(t,e){let r=qc(e,t);if(!jf(r,e))throw new Error(`Path traversal blocked: ${t} escapes ${e}`);return r}function Me(t,e){if(t.length===0)throw new Error("Filename must not be empty");if(t.includes("\0"))throw new Error(`Filename contains null byte: ${JSON.stringify(t)}`);if(t.includes("/")||t.includes("\\"))throw new Error(`Filename must not contain path separators: ${JSON.stringify(t)}`);if(t.includes(".."))throw new Error(`Filename must not contain '..': ${JSON.stringify(t)}`);return ht(t,e)}function Bt(t,e){if(Nf(t)){let r=vk(t);if(!Vc(r,e))throw new Error(`Read path outside base directory: ${t} is not within ${e}`);return r}return ht(t,e)}function si(t){return wk.test(t)}function ii(t,e){if(!t||typeof t!="string")throw new tt(String(t),"command must be a non-empty string");if(t.includes("\0"))throw new tt(t,"command contains null byte");if(t.includes("/")||t.includes("\\"))throw new tt(t,"command must not contain path separators");if(!Mf.has(t))throw new tt(t,`command is not in the allowlist (${[...Mf].join(", ")})`);for(let r of e){if(typeof r!="string")throw new tt(t,`args contain a non-string entry: ${JSON.stringify(r)}`);if(r.includes("\0"))throw new tt(t,`arg contains null byte: ${JSON.stringify(r)}`);if(xk.has(r))throw new tt(t,`arg ${JSON.stringify(r)} is a code-execution flag and is not permitted`)}}var wk,Mf,xk,tt,xo=an(()=>{"use strict";wk=/^[a-zA-Z0-9_-]+-\d+-[a-f0-9]{6}$/;Mf=new Set(["gemini","codex","npx","node","npm","tsc"]),xk=new Set(["-e","--eval","-c","--command","-E","--execute","--exec"]),tt=class extends Error{command;reason;constructor(e,r){super(`CLI command rejected: ${e} \u2014 ${r}`),this.command=e,this.reason=r,this.name="CliCommandRejectedError"}}});var Zf={};Ze(Zf,{CLI_PROVIDERS:()=>Lf,resolveCliConfig:()=>Ff});import{readFileSync as Bc}from"fs";import{join as rt}from"path";import{spawn as Sk}from"child_process";function Ff(t){let e=$k[t.provider]??t.provider;return Lf[e]??null}function Fr(t,e){let r=rt(t,"status.json"),n=JSON.parse(Bc(r,"utf-8"));Ue(r,{...n,...e})}async function kk(){let t=process.argv[2];t||process.exit(1);let e;try{e=JSON.parse(Bc(rt(t,"job.json"),"utf-8"))}catch{try{Ue(rt(t,"status.json"),{id:"unknown",state:"error",provider:"unknown",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),"Failed to read job.json")}catch{}process.exit(1)}let r=Ff(e);r||(Fr(t,{state:"missing_cli",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),`No CLI mapping for provider: ${e.provider}`),process.exit(1));let{command:n,buildArgs:o}=r;Fr(t,{state:"running",startedAt:new Date().toISOString()});let s=Bc(rt(t,"prompt.txt"),"utf-8"),i=o(s);try{ii(n,i)}catch(c){let u=c instanceof tt?c.message:`Argv rejected: ${c.message}`;Fr(t,{state:"error",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),u);return}let a;if(e.cwd)try{a=ht(e.cwd,process.cwd())}catch(c){Fr(t,{state:"error",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),`Rejected descriptor.cwd: ${c.message}`);return}return new Promise(c=>{let u=Lt(n,i),l=Sk(u.command,u.args,{cwd:a,stdio:["ignore","pipe","pipe"],windowsHide:!0}),d="",p="",f=0,m=0;l.stdout.on("data",y=>{f+=y.length,f<=10485760&&(d+=y.toString())}),l.stderr.on("data",y=>{m+=y.length,m<=10485760&&(p+=y.toString())});let g=setTimeout(()=>{er(l),se(rt(t,"output.txt"),d),se(rt(t,"error.txt"),p),Fr(t,{state:"timed_out",completedAt:new Date().toISOString()}),c()},e.timeout);l.on("close",y=>{clearTimeout(g),se(rt(t,"output.txt"),d),se(rt(t,"error.txt"),p);let _=d.trim().length>0;Fr(t,{state:y===0||_?"completed":"error",exitCode:y??1,completedAt:new Date().toISOString()}),c()}),l.on("error",y=>{clearTimeout(g);let _=y.code==="ENOENT"?"missing_cli":"error";se(rt(t,"error.txt"),y.message),Fr(t,{state:_,completedAt:new Date().toISOString()}),c()})})}var $k,Lf,Pk,Uf=an(()=>{"use strict";oi();ho();xo();mn();$k={"gemini-cli":"gemini","codex-cli":"codex"},Lf={gemini:{command:"gemini",buildArgs:t=>["-p",t]},codex:{command:"codex",buildArgs:t=>["exec","--full-auto","--ephemeral",t]}};Pk=process.argv[1]?.endsWith("job-worker.js")||process.argv[1]?.endsWith("job-worker.ts");Pk&&kk().catch(()=>process.exit(1))});var cs=E(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.regexpCode=ne.getEsmExportName=ne.getProperty=ne.safeStringify=ne.stringify=ne.strConcat=ne.addCodeArg=ne.str=ne._=ne.nil=ne._Code=ne.Name=ne.IDENTIFIER=ne._CodeOrName=void 0;var is=class{};ne._CodeOrName=is;ne.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Jr=class extends is{constructor(e){if(super(),!ne.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};ne.Name=Jr;var lt=class extends is{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Jr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ne._Code=lt;ne.nil=new lt("");function Uv(t,...e){let r=[t[0]],n=0;for(;n<e.length;)$l(r,e[n]),r.push(t[++n]);return new lt(r)}ne._=Uv;var Sl=new lt("+");function qv(t,...e){let r=[as(t[0])],n=0;for(;n<e.length;)r.push(Sl),$l(r,e[n]),r.push(Sl,as(t[++n]));return SR(r),new lt(r)}ne.str=qv;function $l(t,e){e instanceof lt?t.push(...e._items):e instanceof Jr?t.push(e):t.push(PR(e))}ne.addCodeArg=$l;function SR(t){let e=1;for(;e<t.length-1;){if(t[e]===Sl){let r=$R(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function $R(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Jr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Jr))return`"${t}${e.slice(1)}`}function kR(t,e){return e.emptyStr()?t:t.emptyStr()?e:qv`${t}${e}`}ne.strConcat=kR;function PR(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:as(Array.isArray(t)?t.join(","):t)}function TR(t){return new lt(as(t))}ne.stringify=TR;function as(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ne.safeStringify=as;function ER(t){return typeof t=="string"&&ne.IDENTIFIER.test(t)?new lt(`.${t}`):Uv`[${t}]`}ne.getProperty=ER;function RR(t){if(typeof t=="string"&&ne.IDENTIFIER.test(t))return new lt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}ne.getEsmExportName=RR;function IR(t){return new lt(t.toString())}ne.regexpCode=IR});var Tl=E(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.ValueScope=Qe.ValueScopeName=Qe.Scope=Qe.varKinds=Qe.UsedValueState=void 0;var Ye=cs(),kl=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},pa;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(pa||(Qe.UsedValueState=pa={}));Qe.varKinds={const:new Ye.Name("const"),let:new Ye.Name("let"),var:new Ye.Name("var")};var fa=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ye.Name?e:this.name(e)}name(e){return new Ye.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Qe.Scope=fa;var ma=class extends Ye.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Ye._)`.${new Ye.Name(r)}[${n}]`}};Qe.ValueScopeName=ma;var AR=(0,Ye._)`\n`,Pl=class extends fa{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?AR:Ye.nil}}get(){return this._scope}name(e){return new ma(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ye._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=Ye.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,pa.Started);let l=r(u);if(l){let d=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const;s=(0,Ye._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ye._)`${s}${l}${this.opts._n}`;else throw new kl(u);c.set(u,pa.Completed)})}return s}};Qe.ValueScope=Pl});var H=E(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.or=K.and=K.not=K.CodeGen=K.operators=K.varKinds=K.ValueScopeName=K.ValueScope=K.Scope=K.Name=K.regexpCode=K.stringify=K.getProperty=K.nil=K.strConcat=K.str=K._=void 0;var te=cs(),_t=Tl(),fr=cs();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return fr._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return fr.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return fr.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return fr.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return fr.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return fr.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return fr.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return fr.Name}});var va=Tl();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return va.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return va.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return va.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return va.varKinds}});K.operators={GT:new te._Code(">"),GTE:new te._Code(">="),LT:new te._Code("<"),LTE:new te._Code("<="),EQ:new te._Code("==="),NEQ:new te._Code("!=="),NOT:new te._Code("!"),OR:new te._Code("||"),AND:new te._Code("&&"),ADD:new te._Code("+")};var Kt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},El=class extends Kt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?_t.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Un(this.rhs,e,r)),this}get names(){return this.rhs instanceof te._CodeOrName?this.rhs.names:{}}},ha=class extends Kt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof te.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Un(this.rhs,e,r),this}get names(){let e=this.lhs instanceof te.Name?{}:{...this.lhs.names};return ya(e,this.rhs)}},Rl=class extends ha{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Il=class extends Kt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Al=class extends Kt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Cl=class extends Kt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Dl=class extends Kt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Un(this.code,e,r),this}get names(){return this.code instanceof te._CodeOrName?this.code.names:{}}},us=class extends Kt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(CR(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Xr(e,r.names),{})}},Gt=class extends us{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},zl=class extends us{},Zn=class extends Gt{};Zn.kind="else";var Yr=class t extends Gt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Zn(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Vv(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Un(this.condition,e,r),this}get names(){let e=super.names;return ya(e,this.condition),this.else&&Xr(e,this.else.names),e}};Yr.kind="if";var Qr=class extends Gt{};Qr.kind="for";var Ol=class extends Qr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Un(this.iteration,e,r),this}get names(){return Xr(super.names,this.iteration.names)}},Ml=class extends Qr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?_t.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=ya(super.names,this.from);return ya(e,this.to)}},ga=class extends Qr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Un(this.iterable,e,r),this}get names(){return Xr(super.names,this.iterable.names)}},ls=class extends Gt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};ls.kind="func";var ds=class extends us{render(e){return"return "+super.render(e)}};ds.kind="return";var Nl=class extends Gt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Xr(e,this.catch.names),this.finally&&Xr(e,this.finally.names),e}},ps=class extends Gt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ps.kind="catch";var fs=class extends Gt{render(e){return"finally"+super.render(e)}};fs.kind="finally";var jl=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
3
+ var PS=Object.create;var Ic=Object.defineProperty;var TS=Object.getOwnPropertyDescriptor;var ES=Object.getOwnPropertyNames;var RS=Object.getPrototypeOf,IS=Object.prototype.hasOwnProperty;var an=(t,e)=>()=>(t&&(e=t(t=0)),e);var E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ze=(t,e)=>{for(var r in e)Ic(t,r,{get:e[r],enumerable:!0})},AS=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ES(e))!IS.call(t,o)&&o!==r&&Ic(t,o,{get:()=>e[o],enumerable:!(n=TS(e,o))||n.enumerable});return t};var Jp=(t,e,r)=>(r=t!=null?PS(RS(t)):{},AS(e||!t||!t.__esModule?Ic(r,"default",{value:t,enumerable:!0}):r,t));var Yp,fo,Qp,Xp,ef,tf,rf,mo,nf,qs,of,sf,af,cf,uf,lf,Vs,Ac,Cc,xj,df,ln,Dc,zc,pf,ff,Bs,xr,Oc,mf,hf,dn,jt=an(()=>{"use strict";Yp="4.10.2",fo="http://localhost:11434",Qp="llama3",Xp=".agestra/.jobs",ef=".agestra/traces",tf=".agestra/worktrees",rf=".agestra/sessions",mo=".agestra/workspace",nf="individual",qs="debates",of="synthesis",sf="issue",af=".agestra/workers",cf=Object.freeze(["PATH","HOME","USER","USERPROFILE","APPDATA","LOCALAPPDATA","TEMP","TMP","TMPDIR","SHELL","LANG","LC_ALL","NODE_PATH","SystemRoot","SystemDrive","COMSPEC","ComSpec","windir"]),uf=2,lf=6e4,Vs=20,Ac=5e4,Cc=10,xj=Object.freeze([3,5,10]),df=Object.freeze(["agree","disagree","abstain","revise"]),ln="votes",Dc=2,zc=2,pf=1440*60*1e3,ff=3600*1e3,Bs=Object.freeze(["ko","zh","ja","en"]),xr="ko",Oc="en",mf="[REDACTED]",hf=["","--- REQUIRED RESPONSE FORMAT ---","Respond with JSON only, matching exactly this shape:",'{ "agrees": true | false, "feedback": "specific issues or why you agree", "suggestions": "concrete changes if you disagree (optional, may be omitted)" }',"No prose, markdown, or explanation outside the JSON object. The JSON must be the entire response or wrapped in a single ```json code fence.","-------------------------------"].join(`
4
+ `),dn=Object.freeze({auto:Object.freeze({name:"auto",description:"Auto-detect build profile from project structure (package.json scripts, tsconfig, vitest config, etc.).",command:"npx",args:Object.freeze([])}),tsc:Object.freeze({name:"tsc",description:"TypeScript project-references build via `npx tsc -b --noEmit`.",command:"npx",args:Object.freeze(["tsc","-b","--noEmit"])}),vitest:Object.freeze({name:"vitest",description:"Run the Vitest unit-test suite in CI mode.",command:"npx",args:Object.freeze(["vitest","run","--reporter=dot"])}),"npm-build":Object.freeze({name:"npm-build",description:"Run the project's `npm run build` script.",command:"npm",args:Object.freeze(["run","build"])}),"npm-test":Object.freeze({name:"npm-test",description:"Run the project's `npm test` script.",command:"npm",args:Object.freeze(["test","--","--run"])})})});import{execFileSync as CS}from"child_process";function pn(t){if(!Number.isFinite(t)||t<=0)return{delivered:!1};if(process.platform==="win32")try{return CS("taskkill",["/PID",String(t),"/T","/F"],{stdio:"ignore",windowsHide:!0}),{delivered:!0}}catch{try{return process.kill(t),{delivered:!0}}catch{return{delivered:!1}}}try{return process.kill(-t,"SIGTERM"),{delivered:!0}}catch{try{return process.kill(t,"SIGTERM"),{delivered:!0}}catch{return{delivered:!1}}}}function er(t,e=3e3){let r=t.pid;if(r)pn(r);else try{t.kill("SIGTERM")}catch{}setTimeout(()=>{try{t.kill("SIGKILL")}catch{}},e)}var ho=an(()=>{"use strict"});import{execFileSync as DS,spawn as zS}from"child_process";import{existsSync as OS}from"fs";function NS(t){return process.platform!=="win32"||t.includes("/")||t.includes("\\")?!1:MS.has(t.toLowerCase())}function jS(t){if(t.includes("\0"))throw new Error(`Windows shim arg contains null byte: ${JSON.stringify(t)}`);if(t.includes("%"))throw new Error(`Windows shim arg contains '%' which would trigger cmd.exe env expansion: ${JSON.stringify(t)}`);return/[\s"&^<>|()!]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function LS(t){let e=t.toLowerCase();if(fn.has(e))return fn.get(e)??null;try{let n=DS("where.exe",[t],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).split(/\r?\n/).map(a=>a.trim()).filter(Boolean);if(n.length===0)return fn.set(e,null),null;let o=n.find(a=>/\.(cmd|bat)$/i.test(a));if(o){let a={type:"cmd",path:o};return fn.set(e,a),a}let i=`${n[0]}.ps1`;if(OS(i)){let a={type:"powershell",path:i};return fn.set(e,a),a}}catch{}return fn.set(e,null),null}function Lt(t,e){if(!NS(t))return{command:t,args:e};let r=LS(t);return r?r.type==="cmd"?{command:"cmd.exe",args:["/d","/s","/c",r.path,...e.map(n=>jS(n))]}:{command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","RemoteSigned","-File",r.path,...e]}:{command:t,args:e}}function ze(t){let{command:e,args:r,timeout:n=12e4,cwd:o,env:s,stdin:i,maxBuffer:a=10485760,onStderrChunk:c}=t;return new Promise((u,l)=>{let d=Lt(e,r),p=zS(d.command,d.args,{cwd:o,env:s?{...process.env,...s}:void 0,stdio:[i?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),f="",m="",g=0,y=0,_=!1,x=null,v=!1,P=()=>{!v&&g+y>a&&(_=!0,v=!0,er(p))};p.stdout.on("data",Z=>{g+=Z.length,g<=a&&(f+=Z.toString()),P()}),p.stderr.on("data",Z=>{y+=Z.length;let De=Z.toString();if(y<=a&&(m+=De),P(),!v&&c){let Y=c(De);Y&&(x=Y,v=!0,er(p))}}),i&&p.stdin&&(p.stdin.write(i),p.stdin.end());let S=()=>{er(p),l(new Error(`CLI timeout after ${n}ms of inactivity: ${e} ${r.join(" ")}`))},N=setTimeout(S,n),L=()=>{clearTimeout(N),N=setTimeout(S,n)};p.stdout.on("data",L),p.stderr.on("data",L),p.on("close",Z=>{if(clearTimeout(N),x){l(x);return}u({stdout:f,stderr:m,exitCode:Z??1,truncated:_})}),p.on("error",Z=>{clearTimeout(N),l(new Error(`CLI spawn error: ${Z.message}`))})})}var MS,fn,mn=an(()=>{"use strict";ho();MS=new Set(["codex","gemini","npm","npx"]),fn=new Map});import{writeFileSync as ck,mkdirSync as bo,openSync as Fc,writeSync as Zc,fsyncSync as Df,closeSync as Uc,renameSync as uk,unlinkSync as lk,appendFileSync as dk}from"fs";import{dirname as wo,join as pk}from"path";import{randomUUID as fk}from"crypto";function se(t,e){let r=wo(t);bo(r,{recursive:!0});let n=pk(r,`.tmp-${fk().slice(0,8)}`);try{ck(n,e,"utf-8"),uk(n,t)}catch(o){try{lk(n)}catch{}throw o}}function Ue(t,e){se(t,JSON.stringify(e,null,2))}function ni(t,e){let r=wo(t);bo(r,{recursive:!0});let n=Fc(t,"a");try{Zc(n,e),Df(n)}finally{Uc(n)}}var ri,oi=an(()=>{"use strict";ri=class{buffer=new Map;flushTimer=null;flushIntervalMs;maxBufferSize;auditFsync;destroyed=!1;constructor(e){this.flushIntervalMs=e?.flushIntervalMs??2e3,this.maxBufferSize=e?.maxBufferSize??100,this.auditFsync=e?.auditFsync??!0,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>this.flush(),this.flushIntervalMs),this.flushTimer&&typeof this.flushTimer.unref=="function"&&this.flushTimer.unref())}append(e,r,n){if(this.destroyed)throw new Error("DurableAppendWriter has been destroyed");if(n==="audit"){if(this.auditFsync)ni(e,r);else{let s=wo(e);bo(s,{recursive:!0}),dk(e,r)}return}let o=this.buffer.get(e);o||(o=[],this.buffer.set(e,o)),o.push(r),o.length>=this.maxBufferSize&&this.flushFile(e),this.flushIntervalMs===0&&this.flushFile(e)}flush(){for(let e of this.buffer.keys())this.flushFile(e)}panicFlush(){for(let[e,r]of this.buffer)if(r.length!==0)try{let n=wo(e);bo(n,{recursive:!0});let o=Fc(e,"a");try{Zc(o,r.join("")),Df(o)}finally{Uc(o)}}catch{}this.buffer.clear()}destroy(){this.destroyed||(this.destroyed=!0,this.flushTimer!==null&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush())}flushFile(e){let r=this.buffer.get(e);if(!r||r.length===0)return;let n=wo(e);bo(n,{recursive:!0});let o=Fc(e,"a");try{Zc(o,r.join(""))}finally{Uc(o)}this.buffer.delete(e)}}});import{existsSync as zf,realpathSync as mk}from"fs";import{basename as hk,dirname as gk,isAbsolute as Nf,join as yk,normalize as vk,resolve as qc,relative as _k}from"path";function bk(t){return t===""||!t.startsWith("..")&&!Nf(t)}function Of(t){let e=[],r=qc(t);for(;!zf(r);){let o=gk(r);if(o===r)break;e.unshift(hk(r)),r=o}let n=zf(r)?mk(r):r;return e.reduce((o,s)=>yk(o,s),n)}function jf(t,e){let r=Of(e),n=Of(t),o=_k(r,n);return bk(o)}function Vc(t,e){let r=qc(e,t);return jf(r,e)}function ht(t,e){let r=qc(e,t);if(!jf(r,e))throw new Error(`Path traversal blocked: ${t} escapes ${e}`);return r}function Me(t,e){if(t.length===0)throw new Error("Filename must not be empty");if(t.includes("\0"))throw new Error(`Filename contains null byte: ${JSON.stringify(t)}`);if(t.includes("/")||t.includes("\\"))throw new Error(`Filename must not contain path separators: ${JSON.stringify(t)}`);if(t.includes(".."))throw new Error(`Filename must not contain '..': ${JSON.stringify(t)}`);return ht(t,e)}function Bt(t,e){if(Nf(t)){let r=vk(t);if(!Vc(r,e))throw new Error(`Read path outside base directory: ${t} is not within ${e}`);return r}return ht(t,e)}function si(t){return wk.test(t)}function ii(t,e){if(!t||typeof t!="string")throw new tt(String(t),"command must be a non-empty string");if(t.includes("\0"))throw new tt(t,"command contains null byte");if(t.includes("/")||t.includes("\\"))throw new tt(t,"command must not contain path separators");if(!Mf.has(t))throw new tt(t,`command is not in the allowlist (${[...Mf].join(", ")})`);for(let r of e){if(typeof r!="string")throw new tt(t,`args contain a non-string entry: ${JSON.stringify(r)}`);if(r.includes("\0"))throw new tt(t,`arg contains null byte: ${JSON.stringify(r)}`);if(xk.has(r))throw new tt(t,`arg ${JSON.stringify(r)} is a code-execution flag and is not permitted`)}}var wk,Mf,xk,tt,xo=an(()=>{"use strict";wk=/^[a-zA-Z0-9_-]+-\d+-[a-f0-9]{6}$/;Mf=new Set(["gemini","codex","npx","node","npm","tsc"]),xk=new Set(["-e","--eval","-c","--command","-E","--execute","--exec"]),tt=class extends Error{command;reason;constructor(e,r){super(`CLI command rejected: ${e} \u2014 ${r}`),this.command=e,this.reason=r,this.name="CliCommandRejectedError"}}});var Zf={};Ze(Zf,{CLI_PROVIDERS:()=>Lf,resolveCliConfig:()=>Ff});import{readFileSync as Bc}from"fs";import{join as rt}from"path";import{spawn as Sk}from"child_process";function Ff(t){let e=$k[t.provider]??t.provider;return Lf[e]??null}function Fr(t,e){let r=rt(t,"status.json"),n=JSON.parse(Bc(r,"utf-8"));Ue(r,{...n,...e})}async function kk(){let t=process.argv[2];t||process.exit(1);let e;try{e=JSON.parse(Bc(rt(t,"job.json"),"utf-8"))}catch{try{Ue(rt(t,"status.json"),{id:"unknown",state:"error",provider:"unknown",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),"Failed to read job.json")}catch{}process.exit(1)}let r=Ff(e);r||(Fr(t,{state:"missing_cli",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),`No CLI mapping for provider: ${e.provider}`),process.exit(1));let{command:n,buildArgs:o}=r;Fr(t,{state:"running",startedAt:new Date().toISOString()});let s=Bc(rt(t,"prompt.txt"),"utf-8"),i=o(s);try{ii(n,i)}catch(c){let u=c instanceof tt?c.message:`Argv rejected: ${c.message}`;Fr(t,{state:"error",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),u);return}let a;if(e.cwd)try{a=ht(e.cwd,process.cwd())}catch(c){Fr(t,{state:"error",completedAt:new Date().toISOString()}),se(rt(t,"error.txt"),`Rejected descriptor.cwd: ${c.message}`);return}return new Promise(c=>{let u=Lt(n,i),l=Sk(u.command,u.args,{cwd:a,stdio:["ignore","pipe","pipe"],windowsHide:!0}),d="",p="",f=0,m=0;l.stdout.on("data",y=>{f+=y.length,f<=10485760&&(d+=y.toString())}),l.stderr.on("data",y=>{m+=y.length,m<=10485760&&(p+=y.toString())});let g=setTimeout(()=>{er(l),se(rt(t,"output.txt"),d),se(rt(t,"error.txt"),p),Fr(t,{state:"timed_out",completedAt:new Date().toISOString()}),c()},e.timeout);l.on("close",y=>{clearTimeout(g),se(rt(t,"output.txt"),d),se(rt(t,"error.txt"),p);let _=d.trim().length>0;Fr(t,{state:y===0||_?"completed":"error",exitCode:y??1,completedAt:new Date().toISOString()}),c()}),l.on("error",y=>{clearTimeout(g);let _=y.code==="ENOENT"?"missing_cli":"error";se(rt(t,"error.txt"),y.message),Fr(t,{state:_,completedAt:new Date().toISOString()}),c()})})}var $k,Lf,Pk,Uf=an(()=>{"use strict";oi();ho();xo();mn();$k={"gemini-cli":"gemini","codex-cli":"codex"},Lf={gemini:{command:"gemini",buildArgs:t=>["-p",t]},codex:{command:"codex",buildArgs:t=>["exec","--skip-git-repo-check","--full-auto","--ephemeral",t]}};Pk=process.argv[1]?.endsWith("job-worker.js")||process.argv[1]?.endsWith("job-worker.ts");Pk&&kk().catch(()=>process.exit(1))});var cs=E(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.regexpCode=ne.getEsmExportName=ne.getProperty=ne.safeStringify=ne.stringify=ne.strConcat=ne.addCodeArg=ne.str=ne._=ne.nil=ne._Code=ne.Name=ne.IDENTIFIER=ne._CodeOrName=void 0;var is=class{};ne._CodeOrName=is;ne.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Jr=class extends is{constructor(e){if(super(),!ne.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};ne.Name=Jr;var lt=class extends is{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Jr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ne._Code=lt;ne.nil=new lt("");function Uv(t,...e){let r=[t[0]],n=0;for(;n<e.length;)$l(r,e[n]),r.push(t[++n]);return new lt(r)}ne._=Uv;var Sl=new lt("+");function qv(t,...e){let r=[as(t[0])],n=0;for(;n<e.length;)r.push(Sl),$l(r,e[n]),r.push(Sl,as(t[++n]));return SR(r),new lt(r)}ne.str=qv;function $l(t,e){e instanceof lt?t.push(...e._items):e instanceof Jr?t.push(e):t.push(PR(e))}ne.addCodeArg=$l;function SR(t){let e=1;for(;e<t.length-1;){if(t[e]===Sl){let r=$R(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function $R(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Jr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Jr))return`"${t}${e.slice(1)}`}function kR(t,e){return e.emptyStr()?t:t.emptyStr()?e:qv`${t}${e}`}ne.strConcat=kR;function PR(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:as(Array.isArray(t)?t.join(","):t)}function TR(t){return new lt(as(t))}ne.stringify=TR;function as(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ne.safeStringify=as;function ER(t){return typeof t=="string"&&ne.IDENTIFIER.test(t)?new lt(`.${t}`):Uv`[${t}]`}ne.getProperty=ER;function RR(t){if(typeof t=="string"&&ne.IDENTIFIER.test(t))return new lt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}ne.getEsmExportName=RR;function IR(t){return new lt(t.toString())}ne.regexpCode=IR});var Tl=E(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.ValueScope=Qe.ValueScopeName=Qe.Scope=Qe.varKinds=Qe.UsedValueState=void 0;var Ye=cs(),kl=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},pa;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(pa||(Qe.UsedValueState=pa={}));Qe.varKinds={const:new Ye.Name("const"),let:new Ye.Name("let"),var:new Ye.Name("var")};var fa=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ye.Name?e:this.name(e)}name(e){return new Ye.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Qe.Scope=fa;var ma=class extends Ye.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Ye._)`.${new Ye.Name(r)}[${n}]`}};Qe.ValueScopeName=ma;var AR=(0,Ye._)`\n`,Pl=class extends fa{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?AR:Ye.nil}}get(){return this._scope}name(e){return new ma(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ye._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=Ye.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,pa.Started);let l=r(u);if(l){let d=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const;s=(0,Ye._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ye._)`${s}${l}${this.opts._n}`;else throw new kl(u);c.set(u,pa.Completed)})}return s}};Qe.ValueScope=Pl});var H=E(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.or=K.and=K.not=K.CodeGen=K.operators=K.varKinds=K.ValueScopeName=K.ValueScope=K.Scope=K.Name=K.regexpCode=K.stringify=K.getProperty=K.nil=K.strConcat=K.str=K._=void 0;var te=cs(),_t=Tl(),fr=cs();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return fr._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return fr.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return fr.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return fr.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return fr.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return fr.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return fr.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return fr.Name}});var va=Tl();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return va.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return va.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return va.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return va.varKinds}});K.operators={GT:new te._Code(">"),GTE:new te._Code(">="),LT:new te._Code("<"),LTE:new te._Code("<="),EQ:new te._Code("==="),NEQ:new te._Code("!=="),NOT:new te._Code("!"),OR:new te._Code("||"),AND:new te._Code("&&"),ADD:new te._Code("+")};var Kt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},El=class extends Kt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?_t.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Un(this.rhs,e,r)),this}get names(){return this.rhs instanceof te._CodeOrName?this.rhs.names:{}}},ha=class extends Kt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof te.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Un(this.rhs,e,r),this}get names(){let e=this.lhs instanceof te.Name?{}:{...this.lhs.names};return ya(e,this.rhs)}},Rl=class extends ha{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Il=class extends Kt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Al=class extends Kt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Cl=class extends Kt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Dl=class extends Kt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Un(this.code,e,r),this}get names(){return this.code instanceof te._CodeOrName?this.code.names:{}}},us=class extends Kt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(CR(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Xr(e,r.names),{})}},Gt=class extends us{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},zl=class extends us{},Zn=class extends Gt{};Zn.kind="else";var Yr=class t extends Gt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Zn(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Vv(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Un(this.condition,e,r),this}get names(){let e=super.names;return ya(e,this.condition),this.else&&Xr(e,this.else.names),e}};Yr.kind="if";var Qr=class extends Gt{};Qr.kind="for";var Ol=class extends Qr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Un(this.iteration,e,r),this}get names(){return Xr(super.names,this.iteration.names)}},Ml=class extends Qr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?_t.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=ya(super.names,this.from);return ya(e,this.to)}},ga=class extends Qr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Un(this.iterable,e,r),this}get names(){return Xr(super.names,this.iterable.names)}},ls=class extends Gt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};ls.kind="func";var ds=class extends us{render(e){return"return "+super.render(e)}};ds.kind="return";var Nl=class extends Gt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Xr(e,this.catch.names),this.finally&&Xr(e,this.finally.names),e}},ps=class extends Gt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ps.kind="catch";var fs=class extends Gt{render(e){return"finally"+super.render(e)}};fs.kind="finally";var jl=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
5
  `:""},this._extScope=e,this._scope=new _t.Scope({parent:e}),this._nodes=[new zl]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new El(e,s,n)),s}const(e,r,n){return this._def(_t.varKinds.const,e,r,n)}let(e,r,n){return this._def(_t.varKinds.let,e,r,n)}var(e,r,n){return this._def(_t.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new ha(e,r,n))}add(e,r){return this._leafNode(new Rl(e,K.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==te.nil&&this._leafNode(new Dl(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,te.addCodeArg)(r,o));return r.push("}"),new te._Code(r)}if(e,r,n){if(this._blockNode(new Yr(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Yr(e))}else(){return this._elseNode(new Zn)}endIf(){return this._endBlockNode(Yr,Zn)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ol(e),r)}forRange(e,r,n,o,s=this.opts.es5?_t.varKinds.var:_t.varKinds.let){let i=this._scope.toName(e);return this._for(new Ml(s,i,r,n),()=>o(i))}forOf(e,r,n,o=_t.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof te.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,te._)`${i}.length`,a=>{this.var(s,(0,te._)`${i}[${a}]`),n(s)})}return this._for(new ga("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?_t.varKinds.var:_t.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,te._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new ga("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Qr)}label(e){return this._leafNode(new Il(e))}break(e){return this._leafNode(new Al(e))}return(e){let r=new ds;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(ds)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Nl;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new ps(s),r(s)}return n&&(this._currNode=o.finally=new fs,this.code(n)),this._endBlockNode(ps,fs)}throw(e){return this._leafNode(new Cl(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=te.nil,n,o){return this._blockNode(new ls(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ls)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Yr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};K.CodeGen=jl;function Xr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function ya(t,e){return e instanceof te._CodeOrName?Xr(t,e.names):t}function Un(t,e,r){if(t instanceof te.Name)return n(t);if(!o(t))return t;return new te._Code(t._items.reduce((s,i)=>(i instanceof te.Name&&(i=n(i)),i instanceof te._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof te._Code&&s._items.some(i=>i instanceof te.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function CR(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Vv(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,te._)`!${Ll(t)}`}K.not=Vv;var DR=Bv(K.operators.AND);function zR(...t){return t.reduce(DR)}K.and=zR;var OR=Bv(K.operators.OR);function MR(...t){return t.reduce(OR)}K.or=MR;function Bv(t){return(e,r)=>e===te.nil?r:r===te.nil?e:(0,te._)`${Ll(e)} ${t} ${Ll(r)}`}function Ll(t){return t instanceof te.Name?t:(0,te._)`(${t})`}});var oe=E(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.checkStrictMode=G.getErrorPath=G.Type=G.useFunc=G.setEvaluated=G.evaluatedPropsToName=G.mergeEvaluated=G.eachItem=G.unescapeJsonPointer=G.escapeJsonPointer=G.escapeFragment=G.unescapeFragment=G.schemaRefOrVal=G.schemaHasRulesButRef=G.schemaHasRules=G.checkUnknownRules=G.alwaysValidSchema=G.toHash=void 0;var le=H(),NR=cs();function jR(t){let e={};for(let r of t)e[r]=!0;return e}G.toHash=jR;function LR(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Kv(t,e),!Gv(e,t.self.RULES.all))}G.alwaysValidSchema=LR;function Kv(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||Qv(t,`unknown keyword: "${s}"`)}G.checkUnknownRules=Kv;function Gv(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}G.schemaHasRules=Gv;function FR(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}G.schemaHasRulesButRef=FR;function ZR({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,le._)`${r}`}return(0,le._)`${t}${e}${(0,le.getProperty)(n)}`}G.schemaRefOrVal=ZR;function UR(t){return Jv(decodeURIComponent(t))}G.unescapeFragment=UR;function qR(t){return encodeURIComponent(Zl(t))}G.escapeFragment=qR;function Zl(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}G.escapeJsonPointer=Zl;function Jv(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}G.unescapeJsonPointer=Jv;function VR(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}G.eachItem=VR;function Wv({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof le.Name?(s instanceof le.Name?t(o,s,i):e(o,s,i),i):s instanceof le.Name?(e(o,i,s),s):r(s,i);return a===le.Name&&!(c instanceof le.Name)?n(o,c):c}}G.mergeEvaluated={props:Wv({mergeNames:(t,e,r)=>t.if((0,le._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,le._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,le._)`${r} || {}`).code((0,le._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,le._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,le._)`${r} || {}`),Ul(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Yv}),items:Wv({mergeNames:(t,e,r)=>t.if((0,le._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,le._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,le._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,le._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Yv(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,le._)`{}`);return e!==void 0&&Ul(t,r,e),r}G.evaluatedPropsToName=Yv;function Ul(t,e,r){Object.keys(r).forEach(n=>t.assign((0,le._)`${e}${(0,le.getProperty)(n)}`,!0))}G.setEvaluated=Ul;var Hv={};function BR(t,e){return t.scopeValue("func",{ref:e,code:Hv[e.code]||(Hv[e.code]=new NR._Code(e.code))})}G.useFunc=BR;var Fl;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Fl||(G.Type=Fl={}));function WR(t,e,r){if(t instanceof le.Name){let n=e===Fl.Num;return r?n?(0,le._)`"[" + ${t} + "]"`:(0,le._)`"['" + ${t} + "']"`:n?(0,le._)`"/" + ${t}`:(0,le._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,le.getProperty)(t).toString():"/"+Zl(t)}G.getErrorPath=WR;function Qv(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}G.checkStrictMode=Qv});var Jt=E(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});var je=H(),HR={data:new je.Name("data"),valCxt:new je.Name("valCxt"),instancePath:new je.Name("instancePath"),parentData:new je.Name("parentData"),parentDataProperty:new je.Name("parentDataProperty"),rootData:new je.Name("rootData"),dynamicAnchors:new je.Name("dynamicAnchors"),vErrors:new je.Name("vErrors"),errors:new je.Name("errors"),this:new je.Name("this"),self:new je.Name("self"),scope:new je.Name("scope"),json:new je.Name("json"),jsonPos:new je.Name("jsonPos"),jsonLen:new je.Name("jsonLen"),jsonPart:new je.Name("jsonPart")};ql.default=HR});var ms=E(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.extendErrors=Le.resetErrorsCount=Le.reportExtraError=Le.reportError=Le.keyword$DataError=Le.keywordError=void 0;var re=H(),_a=oe(),Be=Jt();Le.keywordError={message:({keyword:t})=>(0,re.str)`must pass "${t}" keyword validation`};Le.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,re.str)`"${t}" keyword must be ${e} ($data)`:(0,re.str)`"${t}" keyword is invalid ($data)`};function KR(t,e=Le.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=t_(t,e,r);n??(i||a)?Xv(s,c):e_(o,(0,re._)`[${c}]`)}Le.reportError=KR;function GR(t,e=Le.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=t_(t,e,r);Xv(o,a),s||i||e_(n,Be.default.vErrors)}Le.reportExtraError=GR;function JR(t,e){t.assign(Be.default.errors,e),t.if((0,re._)`${Be.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,re._)`${Be.default.vErrors}.length`,e),()=>t.assign(Be.default.vErrors,null)))}Le.resetErrorsCount=JR;function YR({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,Be.default.errors,a=>{t.const(i,(0,re._)`${Be.default.vErrors}[${a}]`),t.if((0,re._)`${i}.instancePath === undefined`,()=>t.assign((0,re._)`${i}.instancePath`,(0,re.strConcat)(Be.default.instancePath,s.errorPath))),t.assign((0,re._)`${i}.schemaPath`,(0,re.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,re._)`${i}.schema`,r),t.assign((0,re._)`${i}.data`,n))})}Le.extendErrors=YR;function Xv(t,e){let r=t.const("err",e);t.if((0,re._)`${Be.default.vErrors} === null`,()=>t.assign(Be.default.vErrors,(0,re._)`[${r}]`),(0,re._)`${Be.default.vErrors}.push(${r})`),t.code((0,re._)`${Be.default.errors}++`)}function e_(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,re._)`new ${t.ValidationError}(${e})`):(r.assign((0,re._)`${n}.errors`,e),r.return(!1))}var en={keyword:new re.Name("keyword"),schemaPath:new re.Name("schemaPath"),params:new re.Name("params"),propertyName:new re.Name("propertyName"),message:new re.Name("message"),schema:new re.Name("schema"),parentSchema:new re.Name("parentSchema")};function t_(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,re._)`{}`:QR(t,e,r)}function QR(t,e,r={}){let{gen:n,it:o}=t,s=[XR(o,r),eI(t,r)];return tI(t,e,s),n.object(...s)}function XR({errorPath:t},{instancePath:e}){let r=e?(0,re.str)`${t}${(0,_a.getErrorPath)(e,_a.Type.Str)}`:t;return[Be.default.instancePath,(0,re.strConcat)(Be.default.instancePath,r)]}function eI({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,re.str)`${e}/${t}`;return r&&(o=(0,re.str)`${o}${(0,_a.getErrorPath)(r,_a.Type.Str)}`),[en.schemaPath,o]}function tI(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([en.keyword,o],[en.params,typeof e=="function"?e(t):e||(0,re._)`{}`]),c.messages&&n.push([en.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([en.schema,i],[en.parentSchema,(0,re._)`${l}${d}`],[Be.default.data,s]),u&&n.push([en.propertyName,u])}});var n_=E(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.boolOrEmptySchema=qn.topBoolOrEmptySchema=void 0;var rI=ms(),nI=H(),oI=Jt(),sI={message:"boolean schema is false"};function iI(t){let{gen:e,schema:r,validateName:n}=t;r===!1?r_(t,!1):typeof r=="object"&&r.$async===!0?e.return(oI.default.data):(e.assign((0,nI._)`${n}.errors`,null),e.return(!0))}qn.topBoolOrEmptySchema=iI;function aI(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),r_(t)):r.var(e,!0)}qn.boolOrEmptySchema=aI;function r_(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,rI.reportError)(o,sI,void 0,e)}});var Vl=E(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.getRules=Vn.isJSONType=void 0;var cI=["string","number","integer","boolean","null","object","array"],uI=new Set(cI);function lI(t){return typeof t=="string"&&uI.has(t)}Vn.isJSONType=lI;function dI(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Vn.getRules=dI});var Bl=E(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.shouldUseRule=mr.shouldUseGroup=mr.schemaHasRulesForType=void 0;function pI({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&o_(t,n)}mr.schemaHasRulesForType=pI;function o_(t,e){return e.rules.some(r=>s_(t,r))}mr.shouldUseGroup=o_;function s_(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}mr.shouldUseRule=s_});var hs=E(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.reportTypeError=Fe.checkDataTypes=Fe.checkDataType=Fe.coerceAndCheckDataType=Fe.getJSONTypes=Fe.getSchemaTypes=Fe.DataType=void 0;var fI=Vl(),mI=Bl(),hI=ms(),q=H(),i_=oe(),Bn;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Bn||(Fe.DataType=Bn={}));function gI(t){let e=a_(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Fe.getSchemaTypes=gI;function a_(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(fI.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Fe.getJSONTypes=a_;function yI(t,e){let{gen:r,data:n,opts:o}=t,s=vI(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,mI.schemaHasRulesForType)(t,e[0]));if(i){let a=Hl(e,n,o.strictNumbers,Bn.Wrong);r.if(a,()=>{s.length?_I(t,e,s):Kl(t)})}return i}Fe.coerceAndCheckDataType=yI;var c_=new Set(["string","number","integer","boolean","null"]);function vI(t,e){return e?t.filter(r=>c_.has(r)||e==="array"&&r==="array"):[]}function _I(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,q._)`typeof ${o}`),a=n.let("coerced",(0,q._)`undefined`);s.coerceTypes==="array"&&n.if((0,q._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,q._)`${o}[0]`).assign(i,(0,q._)`typeof ${o}`).if(Hl(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,q._)`${a} !== undefined`);for(let u of r)(c_.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Kl(t),n.endIf(),n.if((0,q._)`${a} !== undefined`,()=>{n.assign(o,a),bI(t,a)});function c(u){switch(u){case"string":n.elseIf((0,q._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,q._)`"" + ${o}`).elseIf((0,q._)`${o} === null`).assign(a,(0,q._)`""`);return;case"number":n.elseIf((0,q._)`${i} == "boolean" || ${o} === null
6
6
  || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,q._)`+${o}`);return;case"integer":n.elseIf((0,q._)`${i} === "boolean" || ${o} === null
7
7
  || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,q._)`+${o}`);return;case"boolean":n.elseIf((0,q._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,q._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,q._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,q._)`${i} === "string" || ${i} === "number"
@@ -15,7 +15,7 @@ var PS=Object.create;var Ic=Object.defineProperty;var TS=Object.getOwnPropertyDe
15
15
  `),r=[];for(let n=0;n<e.length;n++){let o=e[n];for(let s of Kf){let i=s.regex.exec(o);if(!i)continue;let a=i[0];if(!Gf.some(u=>u.test(a))){r.push({type:s.type,pattern:s.description,line:n+1,excerpt:o.length>80?o.slice(0,80)+"...":o});break}}}return{clean:r.length===0,findings:r}}function Hc(t){if(t.length===0)return t;let e=t.split(`
16
16
  `);for(let r=0;r<e.length;r++){let n=e[r];for(let o of Kf){let s=new RegExp(o.regex.source,o.regex.flags.includes("g")?o.regex.flags:o.regex.flags+"g");n=n.replace(s,i=>Gf.some(a=>a.test(i))?i:mf)}e[r]=n}return e.join(`
17
17
  `)}jt();import{execFileSync as Zk}from"child_process";import{existsSync as Yf,rmSync as Uk,mkdirSync as qk}from"fs";import{join as Qf}from"path";var li=class{baseDir;worktrees=new Map;worktreeBaseDir;constructor(e){this.baseDir=e,this.worktreeBaseDir=Qf(e,tf)}create(e){let r=e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,60),n=`agestra-worker/${r}`,o=Qf(this.worktreeBaseDir,r);qk(this.worktreeBaseDir,{recursive:!0}),Yf(o)&&this.forceRemoveWorktree(o),this.gitSafe(["branch","-D",n]),this.git(["worktree","add","-b",n,o,"HEAD"]);let s={id:e,path:o,branch:n};return this.worktrees.set(e,s),s}remove(e){let r=this.worktrees.get(e);r&&(this.forceRemoveWorktree(r.path),this.gitSafe(["branch","-D",r.branch]),this.worktrees.delete(e))}get(e){return this.worktrees.get(e)}list(){return[...this.worktrees.values()]}listOrphans(){let e=this.gitSafe(["worktree","list","--porcelain"]);if(!e)return[];let r=[],n="",o="",s=()=>{n.includes(".agestra/worktrees")&&o.startsWith("agestra-worker/")&&([...this.worktrees.values()].some(a=>a.path===n)||r.push({path:n,branch:o})),n="",o=""};for(let i of e.split(`
18
- `))i.startsWith("worktree ")?n=i.slice(9):i.startsWith("branch refs/heads/")?o=i.slice(18):i===""&&s();return n&&s(),r}cleanOrphans(){let e=this.listOrphans(),r=0;for(let n of e)this.forceRemoveWorktree(n.path),this.gitSafe(["branch","-D",n.branch]),r++;return r}forceRemoveWorktree(e){this.gitSafe(["worktree","remove",e])===null&&this.gitSafe(["worktree","remove","--force",e])===null&&(Yf(e)&&Uk(e,{recursive:!0,force:!0}),this.gitSafe(["worktree","prune"]))}git(e){return Zk("git",e,{cwd:this.baseDir,encoding:"utf-8",stdio:"pipe",timeout:3e4}).trim()}gitSafe(e){try{return this.git(e)}catch{return null}}};var Vk=["npm","node","git","tsc"];function Xf(t){return{task:t.taskDescription,files:{readonly:t.filesToRead??[],readwrite:t.filesToModify??[]},constraints:t.constraints,success_criteria:t.successCriteria??[],permissions:{sandbox_root:t.workingDir,allowed_commands:[...Vk]},timeout_minutes:t.timeoutMinutes??10}}function em(t){let e=[];return(!t.task||t.task.trim().length===0)&&e.push("task must not be empty"),(!t.permissions.sandbox_root||t.permissions.sandbox_root.trim().length===0)&&e.push("permissions.sandbox_root must not be empty"),t.timeout_minutes<=0&&e.push("timeout_minutes must be positive"),{valid:e.length===0,errors:e}}var $e;(function(t){t.SPAWNING="SPAWNING",t.RUNNING="RUNNING",t.COLLECTING="COLLECTING",t.COMPLETED="COMPLETED",t.FAILED="FAILED",t.CANCELLING="CANCELLING",t.CANCELLED="CANCELLED",t.TIMEOUT="TIMEOUT"})($e||($e={}));var di=10,Kc=2e4;import{spawn as Jk}from"child_process";import{writeFileSync as Jc,mkdirSync as Yk,readFileSync as om,existsSync as sm}from"fs";import{isAbsolute as im,join as $o,resolve as am}from"path";import{randomBytes as Qk}from"crypto";import{execFileSync as Xk}from"child_process";jt();mn();ho();xo();xo();import{readFileSync as tm}from"fs";var Gc=class{builders=new Map;register(e,r){this.builders.set(e,r)}has(e){return this.builders.has(e)}build(e,r,n,o){let s=this.builders.get(e);if(!s){let i=[...this.builders.keys()];throw new Error(`No CLI launch builder registered for provider "${e}". Known: [${i.join(", ")}]`)}return s(r,n,o)}knownProviders(){return[...this.builders.keys()]}};function Bk(t,e,r){let n=rm(t,e,r);return{command:"codex",args:["exec","--full-auto","--ephemeral","-C",e,"-"],stdin:n}}function Wk(t,e,r){return{command:"gemini",args:["--approval-mode","yolo","-p",rm(t,e,r)]}}function rm(t,e,r){let n=tm(t,"utf-8"),o=Hk(r,e);return["You are an autonomous coding worker operating in the current workspace.","Execute the task manifest below without asking for confirmation.","Stay within the workspace, respect read-only vs read-write boundaries, and summarize changes plus verification at the end.","",n,o].join(`
18
+ `))i.startsWith("worktree ")?n=i.slice(9):i.startsWith("branch refs/heads/")?o=i.slice(18):i===""&&s();return n&&s(),r}cleanOrphans(){let e=this.listOrphans(),r=0;for(let n of e)this.forceRemoveWorktree(n.path),this.gitSafe(["branch","-D",n.branch]),r++;return r}forceRemoveWorktree(e){this.gitSafe(["worktree","remove",e])===null&&this.gitSafe(["worktree","remove","--force",e])===null&&(Yf(e)&&Uk(e,{recursive:!0,force:!0}),this.gitSafe(["worktree","prune"]))}git(e){return Zk("git",e,{cwd:this.baseDir,encoding:"utf-8",stdio:"pipe",timeout:3e4}).trim()}gitSafe(e){try{return this.git(e)}catch{return null}}};var Vk=["npm","node","git","tsc"];function Xf(t){return{task:t.taskDescription,files:{readonly:t.filesToRead??[],readwrite:t.filesToModify??[]},constraints:t.constraints,success_criteria:t.successCriteria??[],permissions:{sandbox_root:t.workingDir,allowed_commands:[...Vk]},timeout_minutes:t.timeoutMinutes??10}}function em(t){let e=[];return(!t.task||t.task.trim().length===0)&&e.push("task must not be empty"),(!t.permissions.sandbox_root||t.permissions.sandbox_root.trim().length===0)&&e.push("permissions.sandbox_root must not be empty"),t.timeout_minutes<=0&&e.push("timeout_minutes must be positive"),{valid:e.length===0,errors:e}}var $e;(function(t){t.SPAWNING="SPAWNING",t.RUNNING="RUNNING",t.COLLECTING="COLLECTING",t.COMPLETED="COMPLETED",t.FAILED="FAILED",t.CANCELLING="CANCELLING",t.CANCELLED="CANCELLED",t.TIMEOUT="TIMEOUT"})($e||($e={}));var di=10,Kc=2e4;import{spawn as Jk}from"child_process";import{writeFileSync as Jc,mkdirSync as Yk,readFileSync as om,existsSync as sm}from"fs";import{isAbsolute as im,join as $o,resolve as am}from"path";import{randomBytes as Qk}from"crypto";import{execFileSync as Xk}from"child_process";jt();mn();ho();xo();xo();import{readFileSync as tm}from"fs";var Gc=class{builders=new Map;register(e,r){this.builders.set(e,r)}has(e){return this.builders.has(e)}build(e,r,n,o){let s=this.builders.get(e);if(!s){let i=[...this.builders.keys()];throw new Error(`No CLI launch builder registered for provider "${e}". Known: [${i.join(", ")}]`)}return s(r,n,o)}knownProviders(){return[...this.builders.keys()]}};function Bk(t,e,r){let n=rm(t,e,r);return{command:"codex",args:["exec","--skip-git-repo-check","--full-auto","--ephemeral","-C",e,"-"],stdin:n}}function Wk(t,e,r){return{command:"gemini",args:["--approval-mode","yolo","-p",rm(t,e,r)]}}function rm(t,e,r){let n=tm(t,"utf-8"),o=Hk(r,e);return["You are an autonomous coding worker operating in the current workspace.","Execute the task manifest below without asking for confirmation.","Stay within the workspace, respect read-only vs read-write boundaries, and summarize changes plus verification at the end.","",n,o].join(`
19
19
  `)}function nm(){let t=new Gc;return t.register("codex",Bk),t.register("gemini",Wk),t}function Hk(t,e){if(!t||t.length===0)return"";let r=t.filter(o=>!Vc(o,e));if(r.length===0)return"";let n=["Read-only file snapshots:","These files may live outside the worker sandbox root. Use the embedded contents below as authoritative context and do not attempt to edit them.",""];for(let o of r.slice(0,di))try{let s=tm(o,"utf-8"),i=s.length>Kc?`${s.slice(0,Kc)}
20
20
  ...[truncated]`:s;n.push(`### File: ${o}`),n.push("```"),n.push(i),n.push("```"),n.push("")}catch(s){let i=s instanceof Error?s.message:String(s);n.push(`### File: ${o}`),n.push(`[unavailable: ${i}]`),n.push("")}return r.length>di&&(n.push(`...[${r.length-di} additional read-only files omitted]`),n.push("")),n.join(`
21
21
  `)}var ko=class t{baseDir;workers=new Map;workersBaseDir;worktreeManager;providerPolicies;cliBuilderRegistry;constructor(e,r={}){this.baseDir=e,this.workersBaseDir=$o(e,af),this.worktreeManager=new li(e),this.providerPolicies=r.providerPolicies??new Map,this.cliBuilderRegistry=r.cliBuilderRegistry??nm()}knownProviders(){let e=new Set;for(let r of this.cliBuilderRegistry.knownProviders())e.add(r);for(let r of this.providerPolicies.keys())e.add(r);return[...e]}activeWorkerCount(){let e=0;for(let r of this.workers.values()){let n=r.info.state;(n===$e.RUNNING||n===$e.COLLECTING)&&e++}return e}spawn(e){if(this.activeWorkerCount()>=3)throw new Error(`Worker quota exceeded: ${this.activeWorkerCount()}/${3} workers already active. Wait for existing workers to complete or call stop() before spawning a new one.`);let r=this.validateWorkingDirectory(e.workingDir),n=this.normalizeReadablePaths(e.filesToRead,r),o=this.normalizeWritablePaths(e.filesToModify,r);this.assertAutonomousExecutionAllowed(e.provider);let s=[e.taskDescription,e.constraints??""],i=Jf(s);if(!i.clean){let Z=i.findings.map(De=>De.pattern).join(", ");throw new Error(`Secret detected in task input \u2014 spawn blocked. Found: ${Z}`)}let a=Qk(3).toString("hex"),c=`${e.provider}-${Date.now()}-${a}`,u=$o(this.workersBaseDir,c);Yk(u,{recursive:!0});let l=Xf({taskDescription:e.taskDescription,workingDir:r,filesToRead:n,filesToModify:o,constraints:e.constraints,successCriteria:e.successCriteria,timeoutMinutes:e.timeoutMinutes}),d=em(l);if(!d.valid)throw new Error(`Invalid task manifest: ${d.errors.join(", ")}`);let p=$o(u,"task-manifest.json");Jc(p,JSON.stringify(l,null,2),"utf-8");let f=e.useWorktree!==!1?this.tryCreateWorktree(c):null,m=$o(u,"stdout.log"),g=$o(u,"stderr.log"),y=f?.path??r,_=this.cliBuilderRegistry.build(e.provider,p,y,n),x=Lt(_.command,_.args),v=Jk(x.command,x.args,{cwd:y,env:t.buildWorkerEnv(),detached:!0,stdio:[_.stdin?"pipe":"ignore","pipe","pipe"]}),P=[],S=[];v.stdout?.on("data",Z=>P.push(Z)),v.stderr?.on("data",Z=>S.push(Z)),_.stdin!==void 0&&v.stdin?.end(_.stdin),v.unref();let N={workerId:c,provider:e.provider,state:$e.RUNNING,pid:v.pid??null,worktreePath:f?.path??null,worktreeBranch:f?.branch??null,startedAt:Date.now(),retryCount:0,exitCode:null,error:null},L={info:N,process:v,workerDir:u,manifestPath:p,outputPath:m,errorPath:g};if(this.workers.set(c,L),e.timeoutMinutes){let Z=e.timeoutMinutes*6e4;setTimeout(()=>{if(L.info.state===$e.RUNNING){L.info.state=$e.TIMEOUT,L.info.error=`Worker timed out after ${e.timeoutMinutes} minutes`;let Y=L.process?.pid;Y&&pn(Y)}},Z).unref()}return v.on("close",Z=>{L.info.exitCode=Z;try{Jc(m,Buffer.concat(P).toString("utf-8")),Jc(g,Buffer.concat(S).toString("utf-8"))}catch{}L.info.state===$e.CANCELLING?L.info.state=$e.CANCELLED:Z===0?L.info.state=$e.COLLECTING:(L.info.state=$e.FAILED,L.info.error=`Process exited with code ${Z}`)}),N}getStatus(e){let r=this.workers.get(e);if(!r)return;let n=Math.floor((Date.now()-r.info.startedAt)/1e3),o="";try{sm(r.outputPath)&&(o=om(r.outputPath,"utf-8").split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agestra",
3
- "version": "4.10.1",
3
+ "version": "4.10.2",
4
4
  "description": "Multi-host AI orchestration toolkit for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.11.0",