agestra 4.8.0 → 4.8.1

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, cross-validation, and GraphRAG memory",
15
- "version": "4.8.0",
15
+ "version": "4.8.1",
16
16
  "author": {
17
17
  "name": "mua-vtuber"
18
18
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agestra",
3
- "version": "4.8.0",
3
+ "version": "4.8.1",
4
4
  "description": "Claude Code plugin — orchestrate Ollama, Gemini, and Codex for multi-AI debates, cross-validation, and GraphRAG memory",
5
5
  "mcpServers": {
6
6
  "agestra": {
package/dist/bundle.js CHANGED
@@ -1,6 +1,6 @@
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 Fb=Object.create;var ec=Object.defineProperty;var Ub=Object.getOwnPropertyDescriptor;var Vb=Object.getOwnPropertyNames;var Wb=Object.getPrototypeOf,Bb=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),We=(t,e)=>{for(var r in e)ec(t,r,{get:e[r],enumerable:!0})},Hb=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vb(e))!Bb.call(t,o)&&o!==r&&ec(t,o,{get:()=>e[o],enumerable:!(n=Ub(e,o))||n.enumerable});return t};var ap=(t,e,r)=>(r=t!=null?Fb(Wb(t)):{},Hb(e||!t||!t.__esModule?ec(r,"default",{value:t,enumerable:!0}):r,t));var cp,to,up,lp,dp,pp,fp,mp,hp,gp,yp,_p,vp,Ts,tc,xp,bp,ln,vr=an(()=>{"use strict";cp="4.8.0",to="http://localhost:11434",up="llama3",lp=".agestra/.jobs",dp=".agestra/traces",pp=".agestra/worktrees",fp=".agestra/sessions",mp=".agestra/workspace",hp=".agestra/messages",gp=".agestra/workers",yp=Object.freeze(["PATH","HOME","USER","USERPROFILE","APPDATA","LOCALAPPDATA","TEMP","TMP","TMPDIR","SHELL","LANG","LC_ALL","NODE_PATH","SystemRoot","SystemDrive","COMSPEC","ComSpec","windir"]),_p=2,vp=6e4,Ts=20,tc=5e4,xp="[REDACTED]",bp=["","--- 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(`
3
+ var Fb=Object.create;var ec=Object.defineProperty;var Ub=Object.getOwnPropertyDescriptor;var Vb=Object.getOwnPropertyNames;var Wb=Object.getPrototypeOf,Bb=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),We=(t,e)=>{for(var r in e)ec(t,r,{get:e[r],enumerable:!0})},Hb=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vb(e))!Bb.call(t,o)&&o!==r&&ec(t,o,{get:()=>e[o],enumerable:!(n=Ub(e,o))||n.enumerable});return t};var ap=(t,e,r)=>(r=t!=null?Fb(Wb(t)):{},Hb(e||!t||!t.__esModule?ec(r,"default",{value:t,enumerable:!0}):r,t));var cp,to,up,lp,dp,pp,fp,mp,hp,gp,yp,_p,vp,Ts,tc,xp,bp,ln,vr=an(()=>{"use strict";cp="4.8.1",to="http://localhost:11434",up="llama3",lp=".agestra/.jobs",dp=".agestra/traces",pp=".agestra/worktrees",fp=".agestra/sessions",mp=".agestra/workspace",hp=".agestra/messages",gp=".agestra/workers",yp=Object.freeze(["PATH","HOME","USER","USERPROFILE","APPDATA","LOCALAPPDATA","TEMP","TMP","TMPDIR","SHELL","LANG","LC_ALL","NODE_PATH","SystemRoot","SystemDrive","COMSPEC","ComSpec","windir"]),_p=2,vp=6e4,Ts=20,tc=5e4,xp="[REDACTED]",bp=["","--- 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
4
  `),ln=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 Gb}from"child_process";function dn(t){if(!Number.isFinite(t)||t<=0)return{delivered:!1};if(process.platform==="win32")try{return Gb("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 Kt(t,e=3e3){let r=t.pid;if(r)dn(r);else try{t.kill("SIGTERM")}catch{}setTimeout(()=>{try{t.kill("SIGKILL")}catch{}},e)}var ro=an(()=>{"use strict"});import{execFileSync as Jb,spawn as Kb}from"child_process";import{existsSync as Qb}from"fs";function Xb(t){return process.platform!=="win32"||t.includes("/")||t.includes("\\")?!1:Yb.has(t.toLowerCase())}function ew(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 tw(t){let e=t.toLowerCase();if(pn.has(e))return pn.get(e)??null;try{let n=Jb("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 pn.set(e,null),null;let o=n.find(a=>/\.(cmd|bat)$/i.test(a));if(o){let a={type:"cmd",path:o};return pn.set(e,a),a}let i=`${n[0]}.ps1`;if(Qb(i)){let a={type:"powershell",path:i};return pn.set(e,a),a}}catch{}return pn.set(e,null),null}function Nt(t,e){if(!Xb(t))return{command:t,args:e};let r=tw(t);return r?r.type==="cmd"?{command:"cmd.exe",args:["/d","/s","/c",r.path,...e.map(n=>ew(n))]}:{command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","RemoteSigned","-File",r.path,...e]}:{command:t,args:e}}function De(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=Nt(e,r),p=Kb(d.command,d.args,{cwd:o,env:s?{...process.env,...s}:void 0,stdio:[i?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),f="",g="",y=0,m=0,b=!1,_=null,w=!1,k=()=>{!w&&y+m>a&&(b=!0,w=!0,Kt(p))};p.stdout.on("data",j=>{y+=j.length,y<=a&&(f+=j.toString()),k()}),p.stderr.on("data",j=>{m+=j.length;let Se=j.toString();if(m<=a&&(g+=Se),k(),!w&&c){let Q=c(Se);Q&&(_=Q,w=!0,Kt(p))}}),i&&p.stdin&&(p.stdin.write(i),p.stdin.end());let P=()=>{Kt(p),l(new Error(`CLI timeout after ${n}ms of inactivity: ${e} ${r.join(" ")}`))},U=setTimeout(P,n),Z=()=>{clearTimeout(U),U=setTimeout(P,n)};p.stdout.on("data",Z),p.stderr.on("data",Z),p.on("close",j=>{if(clearTimeout(U),_){l(_);return}u({stdout:f,stderr:g,exitCode:j??1,truncated:b})}),p.on("error",j=>{clearTimeout(U),l(new Error(`CLI spawn error: ${j.message}`))})})}var Yb,pn,fn=an(()=>{"use strict";ro();Yb=new Set(["codex","gemini","npm","npx"]),pn=new Map});import{writeFileSync as v$,mkdirSync as io,openSync as ic,writeSync as ac,fsyncSync as Mp,closeSync as cc,renameSync as x$,unlinkSync as b$,appendFileSync as w$}from"fs";import{dirname as ao,join as $$}from"path";import{randomUUID as S$}from"crypto";function ie(t,e){let r=ao(t);io(r,{recursive:!0});let n=$$(r,`.tmp-${S$().slice(0,8)}`);try{v$(n,e,"utf-8"),x$(n,t)}catch(o){try{b$(n)}catch{}throw o}}function it(t,e){ie(t,JSON.stringify(e,null,2))}function co(t,e){let r=ao(t);io(r,{recursive:!0});let n=ic(t,"a");try{ac(n,e),Mp(n)}finally{cc(n)}}var Ns,js=an(()=>{"use strict";Ns=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)co(e,r);else{let s=ao(e);io(s,{recursive:!0}),w$(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=ao(e);io(n,{recursive:!0});let o=ic(e,"a");try{ac(o,r.join("")),Mp(o)}finally{cc(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=ao(e);io(n,{recursive:!0});let o=ic(e,"a");try{ac(o,r.join(""))}finally{cc(o)}this.buffer.delete(e)}}});import{existsSync as Np,realpathSync as k$}from"fs";import{basename as T$,dirname as P$,isAbsolute as Zp,join as E$,normalize as R$,resolve as uc,relative as z$}from"path";function C$(t){return t===""||!t.startsWith("..")&&!Zp(t)}function jp(t){let e=[],r=uc(t);for(;!Np(r);){let o=P$(r);if(o===r)break;e.unshift(T$(r)),r=o}let n=Np(r)?k$(r):r;return e.reduce((o,s)=>E$(o,s),n)}function qp(t,e){let r=jp(e),n=jp(t),o=z$(r,n);return C$(o)}function lc(t,e){let r=uc(e,t);return qp(r,e)}function ht(t,e){let r=uc(e,t);if(!qp(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 Ft(t,e){if(Zp(t)){let r=R$(t);if(!lc(r,e))throw new Error(`Read path outside base directory: ${t} is not within ${e}`);return r}return ht(t,e)}function Ls(t){return A$.test(t)}function Zs(t,e){if(!t||typeof t!="string")throw new et(String(t),"command must be a non-empty string");if(t.includes("\0"))throw new et(t,"command contains null byte");if(t.includes("/")||t.includes("\\"))throw new et(t,"command must not contain path separators");if(!Lp.has(t))throw new et(t,`command is not in the allowlist (${[...Lp].join(", ")})`);for(let r of e){if(typeof r!="string")throw new et(t,`args contain a non-string entry: ${JSON.stringify(r)}`);if(r.includes("\0"))throw new et(t,`arg contains null byte: ${JSON.stringify(r)}`);if(I$.has(r))throw new et(t,`arg ${JSON.stringify(r)} is a code-execution flag and is not permitted`)}}var A$,Lp,I$,et,uo=an(()=>{"use strict";A$=/^[a-zA-Z0-9_-]+-\d+-[a-f0-9]{6}$/;Lp=new Set(["gemini","codex","npx","node","npm","tsc"]),I$=new Set(["-e","--eval","-c","--command","-E","--execute","--exec"]),et=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 Vp={};We(Vp,{CLI_PROVIDERS:()=>Fp,resolveCliConfig:()=>Up});import{readFileSync as dc}from"fs";import{join as tt}from"path";import{spawn as D$}from"child_process";function Up(t){let e=O$[t.provider]??t.provider;return Fp[e]??null}function Nr(t,e){let r=tt(t,"status.json"),n=JSON.parse(dc(r,"utf-8"));it(r,{...n,...e})}async function M$(){let t=process.argv[2];t||process.exit(1);let e;try{e=JSON.parse(dc(tt(t,"job.json"),"utf-8"))}catch{try{it(tt(t,"status.json"),{id:"unknown",state:"error",provider:"unknown",completedAt:new Date().toISOString()}),ie(tt(t,"error.txt"),"Failed to read job.json")}catch{}process.exit(1)}let r=Up(e);r||(Nr(t,{state:"missing_cli",completedAt:new Date().toISOString()}),ie(tt(t,"error.txt"),`No CLI mapping for provider: ${e.provider}`),process.exit(1));let{command:n,buildArgs:o}=r;Nr(t,{state:"running",startedAt:new Date().toISOString()});let s=dc(tt(t,"prompt.txt"),"utf-8"),i=o(s);try{Zs(n,i)}catch(c){let u=c instanceof et?c.message:`Argv rejected: ${c.message}`;Nr(t,{state:"error",completedAt:new Date().toISOString()}),ie(tt(t,"error.txt"),u);return}let a;if(e.cwd)try{a=ht(e.cwd,process.cwd())}catch(c){Nr(t,{state:"error",completedAt:new Date().toISOString()}),ie(tt(t,"error.txt"),`Rejected descriptor.cwd: ${c.message}`);return}return new Promise(c=>{let u=Nt(n,i),l=D$(u.command,u.args,{cwd:a,stdio:["ignore","pipe","pipe"],windowsHide:!0}),d="",p="",f=0,g=0;l.stdout.on("data",m=>{f+=m.length,f<=10485760&&(d+=m.toString())}),l.stderr.on("data",m=>{g+=m.length,g<=10485760&&(p+=m.toString())});let y=setTimeout(()=>{Kt(l),ie(tt(t,"output.txt"),d),ie(tt(t,"error.txt"),p),Nr(t,{state:"timed_out",completedAt:new Date().toISOString()}),c()},e.timeout);l.on("close",m=>{clearTimeout(y),ie(tt(t,"output.txt"),d),ie(tt(t,"error.txt"),p);let b=d.trim().length>0;Nr(t,{state:m===0||b?"completed":"error",exitCode:m??1,completedAt:new Date().toISOString()}),c()}),l.on("error",m=>{clearTimeout(y);let b=m.code==="ENOENT"?"missing_cli":"error";ie(tt(t,"error.txt"),m.message),Nr(t,{state:b,completedAt:new Date().toISOString()}),c()})})}var O$,Fp,N$,Wp=an(()=>{"use strict";js();ro();uo();fn();O$={"gemini-cli":"gemini","codex-cli":"codex"},Fp={gemini:{command:"gemini",buildArgs:t=>["-p",t]},codex:{command:"codex",buildArgs:t=>["exec","--full-auto","--ephemeral",t]}};N$=process.argv[1]?.endsWith("job-worker.js")||process.argv[1]?.endsWith("job-worker.ts");N$&&M$().catch(()=>process.exit(1))});var Qo=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 Jo=class{};ne._CodeOrName=Jo;ne.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Gr=class extends Jo{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=Gr;var lt=class extends Jo{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 Gr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ne._Code=lt;ne.nil=new lt("");function jy(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Wu(r,e[n]),r.push(t[++n]);return new lt(r)}ne._=jy;var Vu=new lt("+");function Ly(t,...e){let r=[Ko(t[0])],n=0;for(;n<e.length;)r.push(Vu),Wu(r,e[n]),r.push(Vu,Ko(t[++n]));return RP(r),new lt(r)}ne.str=Ly;function Wu(t,e){e instanceof lt?t.push(...e._items):e instanceof Gr?t.push(e):t.push(AP(e))}ne.addCodeArg=Wu;function RP(t){let e=1;for(;e<t.length-1;){if(t[e]===Vu){let r=zP(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function zP(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Gr||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 Gr))return`"${t}${e.slice(1)}`}function CP(t,e){return e.emptyStr()?t:t.emptyStr()?e:Ly`${t}${e}`}ne.strConcat=CP;function AP(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Ko(Array.isArray(t)?t.join(","):t)}function IP(t){return new lt(Ko(t))}ne.stringify=IP;function Ko(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ne.safeStringify=Ko;function DP(t){return typeof t=="string"&&ne.IDENTIFIER.test(t)?new lt(`.${t}`):jy`[${t}]`}ne.getProperty=DP;function OP(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=OP;function MP(t){return new lt(t.toString())}ne.regexpCode=MP});var Gu=E(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.ValueScope=Qe.ValueScopeName=Qe.Scope=Qe.varKinds=Qe.UsedValueState=void 0;var Ke=Qo(),Bu=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Vi;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Vi||(Qe.UsedValueState=Vi={}));Qe.varKinds={const:new Ke.Name("const"),let:new Ke.Name("let"),var:new Ke.Name("var")};var Wi=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ke.Name?e:this.name(e)}name(e){return new Ke.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=Wi;var Bi=class extends Ke.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Ke._)`.${new Ke.Name(r)}[${n}]`}};Qe.ValueScopeName=Bi;var NP=(0,Ke._)`\n`,Hu=class extends Wi{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?NP:Ke.nil}}get(){return this._scope}name(e){return new Bi(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,Ke._)`${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=Ke.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,Vi.Started);let l=r(u);if(l){let d=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const;s=(0,Ke._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ke._)`${s}${l}${this.opts._n}`;else throw new Bu(u);c.set(u,Vi.Completed)})}return s}};Qe.ValueScope=Hu});var B=E(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.or=H.and=H.not=H.CodeGen=H.operators=H.varKinds=H.ValueScopeName=H.ValueScope=H.Scope=H.Name=H.regexpCode=H.stringify=H.getProperty=H.nil=H.strConcat=H.str=H._=void 0;var te=Qo(),vt=Gu(),lr=Qo();Object.defineProperty(H,"_",{enumerable:!0,get:function(){return lr._}});Object.defineProperty(H,"str",{enumerable:!0,get:function(){return lr.str}});Object.defineProperty(H,"strConcat",{enumerable:!0,get:function(){return lr.strConcat}});Object.defineProperty(H,"nil",{enumerable:!0,get:function(){return lr.nil}});Object.defineProperty(H,"getProperty",{enumerable:!0,get:function(){return lr.getProperty}});Object.defineProperty(H,"stringify",{enumerable:!0,get:function(){return lr.stringify}});Object.defineProperty(H,"regexpCode",{enumerable:!0,get:function(){return lr.regexpCode}});Object.defineProperty(H,"Name",{enumerable:!0,get:function(){return lr.Name}});var Ki=Gu();Object.defineProperty(H,"Scope",{enumerable:!0,get:function(){return Ki.Scope}});Object.defineProperty(H,"ValueScope",{enumerable:!0,get:function(){return Ki.ValueScope}});Object.defineProperty(H,"ValueScopeName",{enumerable:!0,get:function(){return Ki.ValueScopeName}});Object.defineProperty(H,"varKinds",{enumerable:!0,get:function(){return Ki.varKinds}});H.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 Wt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Ju=class extends Wt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?vt.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=Nn(this.rhs,e,r)),this}get names(){return this.rhs instanceof te._CodeOrName?this.rhs.names:{}}},Hi=class extends Wt{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=Nn(this.rhs,e,r),this}get names(){let e=this.lhs instanceof te.Name?{}:{...this.lhs.names};return Ji(e,this.rhs)}},Ku=class extends Hi{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Qu=class extends Wt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Yu=class extends Wt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Xu=class extends Wt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},el=class extends Wt{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=Nn(this.code,e,r),this}get names(){return this.code instanceof te._CodeOrName?this.code.names:{}}},Yo=class extends Wt{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)||(jP(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Qr(e,r.names),{})}},Bt=class extends Yo{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},tl=class extends Yo{},Mn=class extends Bt{};Mn.kind="else";var Jr=class t extends Bt{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 Mn(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Zy(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=Nn(this.condition,e,r),this}get names(){let e=super.names;return Ji(e,this.condition),this.else&&Qr(e,this.else.names),e}};Jr.kind="if";var Kr=class extends Bt{};Kr.kind="for";var rl=class extends Kr{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=Nn(this.iteration,e,r),this}get names(){return Qr(super.names,this.iteration.names)}},nl=class extends Kr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?vt.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=Ji(super.names,this.from);return Ji(e,this.to)}},Gi=class extends Kr{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=Nn(this.iterable,e,r),this}get names(){return Qr(super.names,this.iterable.names)}},Xo=class extends Bt{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)}};Xo.kind="func";var es=class extends Yo{render(e){return"return "+super.render(e)}};es.kind="return";var ol=class extends Bt{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&&Qr(e,this.catch.names),this.finally&&Qr(e,this.finally.names),e}},ts=class extends Bt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ts.kind="catch";var rs=class extends Bt{render(e){return"finally"+super.render(e)}};rs.kind="finally";var sl=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
5
  `:""},this._extScope=e,this._scope=new vt.Scope({parent:e}),this._nodes=[new tl]}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 Ju(e,s,n)),s}const(e,r,n){return this._def(vt.varKinds.const,e,r,n)}let(e,r,n){return this._def(vt.varKinds.let,e,r,n)}var(e,r,n){return this._def(vt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Hi(e,r,n))}add(e,r){return this._leafNode(new Ku(e,H.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==te.nil&&this._leafNode(new el(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 Jr(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 Jr(e))}else(){return this._elseNode(new Mn)}endIf(){return this._endBlockNode(Jr,Mn)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new rl(e),r)}forRange(e,r,n,o,s=this.opts.es5?vt.varKinds.var:vt.varKinds.let){let i=this._scope.toName(e);return this._for(new nl(s,i,r,n),()=>o(i))}forOf(e,r,n,o=vt.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 Gi("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?vt.varKinds.var:vt.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 Gi("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Kr)}label(e){return this._leafNode(new Qu(e))}break(e){return this._leafNode(new Yu(e))}return(e){let r=new es;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(es)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new ol;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new ts(s),r(s)}return n&&(this._currNode=o.finally=new rs,this.code(n)),this._endBlockNode(ts,rs)}throw(e){return this._leafNode(new Xu(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 Xo(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Xo)}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 Jr))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}};H.CodeGen=sl;function Qr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Ji(t,e){return e instanceof te._CodeOrName?Qr(t,e.names):t}function Nn(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 jP(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Zy(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,te._)`!${il(t)}`}H.not=Zy;var LP=qy(H.operators.AND);function ZP(...t){return t.reduce(LP)}H.and=ZP;var qP=qy(H.operators.OR);function FP(...t){return t.reduce(qP)}H.or=FP;function qy(t){return(e,r)=>e===te.nil?r:r===te.nil?e:(0,te._)`${il(e)} ${t} ${il(r)}`}function il(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=B(),UP=Qo();function VP(t){let e={};for(let r of t)e[r]=!0;return e}G.toHash=VP;function WP(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Vy(t,e),!Wy(e,t.self.RULES.all))}G.alwaysValidSchema=WP;function Vy(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]||Gy(t,`unknown keyword: "${s}"`)}G.checkUnknownRules=Vy;function Wy(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}G.schemaHasRules=Wy;function BP(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=BP;function HP({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=HP;function GP(t){return By(decodeURIComponent(t))}G.unescapeFragment=GP;function JP(t){return encodeURIComponent(cl(t))}G.escapeFragment=JP;function cl(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}G.escapeJsonPointer=cl;function By(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}G.unescapeJsonPointer=By;function KP(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}G.eachItem=KP;function Fy({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:Fy({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:Hy}),items:Fy({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 Hy(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=Hy;function ul(t,e,r){Object.keys(r).forEach(n=>t.assign((0,le._)`${e}${(0,le.getProperty)(n)}`,!0))}G.setEvaluated=ul;var Uy={};function QP(t,e){return t.scopeValue("func",{ref:e,code:Uy[e.code]||(Uy[e.code]=new UP._Code(e.code))})}G.useFunc=QP;var al;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(al||(G.Type=al={}));function YP(t,e,r){if(t instanceof le.Name){let n=e===al.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():"/"+cl(t)}G.getErrorPath=YP;function Gy(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=Gy});var Ht=E(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});var je=B(),XP={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")};ll.default=XP});var ns=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=B(),Qi=oe(),Ue=Ht();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 eE(t,e=Le.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=Qy(t,e,r);n??(i||a)?Jy(s,c):Ky(o,(0,re._)`[${c}]`)}Le.reportError=eE;function tE(t,e=Le.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=Qy(t,e,r);Jy(o,a),s||i||Ky(n,Ue.default.vErrors)}Le.reportExtraError=tE;function rE(t,e){t.assign(Ue.default.errors,e),t.if((0,re._)`${Ue.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,re._)`${Ue.default.vErrors}.length`,e),()=>t.assign(Ue.default.vErrors,null)))}Le.resetErrorsCount=rE;function nE({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,Ue.default.errors,a=>{t.const(i,(0,re._)`${Ue.default.vErrors}[${a}]`),t.if((0,re._)`${i}.instancePath === undefined`,()=>t.assign((0,re._)`${i}.instancePath`,(0,re.strConcat)(Ue.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=nE;function Jy(t,e){let r=t.const("err",e);t.if((0,re._)`${Ue.default.vErrors} === null`,()=>t.assign(Ue.default.vErrors,(0,re._)`[${r}]`),(0,re._)`${Ue.default.vErrors}.push(${r})`),t.code((0,re._)`${Ue.default.errors}++`)}function Ky(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 Yr={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 Qy(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,re._)`{}`:oE(t,e,r)}function oE(t,e,r={}){let{gen:n,it:o}=t,s=[sE(o,r),iE(t,r)];return aE(t,e,s),n.object(...s)}function sE({errorPath:t},{instancePath:e}){let r=e?(0,re.str)`${t}${(0,Qi.getErrorPath)(e,Qi.Type.Str)}`:t;return[Ue.default.instancePath,(0,re.strConcat)(Ue.default.instancePath,r)]}function iE({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,Qi.getErrorPath)(r,Qi.Type.Str)}`),[Yr.schemaPath,o]}function aE(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([Yr.keyword,o],[Yr.params,typeof e=="function"?e(t):e||(0,re._)`{}`]),c.messages&&n.push([Yr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Yr.schema,i],[Yr.parentSchema,(0,re._)`${l}${d}`],[Ue.default.data,s]),u&&n.push([Yr.propertyName,u])}});var Xy=E(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.boolOrEmptySchema=jn.topBoolOrEmptySchema=void 0;var cE=ns(),uE=B(),lE=Ht(),dE={message:"boolean schema is false"};function pE(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Yy(t,!1):typeof r=="object"&&r.$async===!0?e.return(lE.default.data):(e.assign((0,uE._)`${n}.errors`,null),e.return(!0))}jn.topBoolOrEmptySchema=pE;function fE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Yy(t)):r.var(e,!0)}jn.boolOrEmptySchema=fE;function Yy(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,cE.reportError)(o,dE,void 0,e)}});var dl=E(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.getRules=Ln.isJSONType=void 0;var mE=["string","number","integer","boolean","null","object","array"],hE=new Set(mE);function gE(t){return typeof t=="string"&&hE.has(t)}Ln.isJSONType=gE;function yE(){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:{}}}Ln.getRules=yE});var pl=E(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.shouldUseRule=dr.shouldUseGroup=dr.schemaHasRulesForType=void 0;function _E({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&e_(t,n)}dr.schemaHasRulesForType=_E;function e_(t,e){return e.rules.some(r=>t_(t,r))}dr.shouldUseGroup=e_;function t_(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))}dr.shouldUseRule=t_});var os=E(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.reportTypeError=Ze.checkDataTypes=Ze.checkDataType=Ze.coerceAndCheckDataType=Ze.getJSONTypes=Ze.getSchemaTypes=Ze.DataType=void 0;var vE=dl(),xE=pl(),bE=ns(),F=B(),r_=oe(),Zn;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Zn||(Ze.DataType=Zn={}));function wE(t){let e=n_(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}Ze.getSchemaTypes=wE;function n_(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(vE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ze.getJSONTypes=n_;function $E(t,e){let{gen:r,data:n,opts:o}=t,s=SE(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,xE.schemaHasRulesForType)(t,e[0]));if(i){let a=ml(e,n,o.strictNumbers,Zn.Wrong);r.if(a,()=>{s.length?kE(t,e,s):hl(t)})}return i}Ze.coerceAndCheckDataType=$E;var o_=new Set(["string","number","integer","boolean","null"]);function SE(t,e){return e?t.filter(r=>o_.has(r)||e==="array"&&r==="array"):[]}function kE(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,F._)`typeof ${o}`),a=n.let("coerced",(0,F._)`undefined`);s.coerceTypes==="array"&&n.if((0,F._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,F._)`${o}[0]`).assign(i,(0,F._)`typeof ${o}`).if(ml(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,F._)`${a} !== undefined`);for(let u of r)(o_.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),hl(t),n.endIf(),n.if((0,F._)`${a} !== undefined`,()=>{n.assign(o,a),TE(t,a)});function c(u){switch(u){case"string":n.elseIf((0,F._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,F._)`"" + ${o}`).elseIf((0,F._)`${o} === null`).assign(a,(0,F._)`""`);return;case"number":n.elseIf((0,F._)`${i} == "boolean" || ${o} === null
6
6
  || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,F._)`+${o}`);return;case"integer":n.elseIf((0,F._)`${i} === "boolean" || ${o} === null
@@ -4,8 +4,8 @@
4
4
  // Detects user intent and routes to debate mode with configured providers.
5
5
  // If no providers.config.json exists, suggests /agestra setup first.
6
6
 
7
- const { existsSync } = require("fs");
8
- const { join } = require("path");
7
+ import { existsSync, readFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
9
 
10
10
  let input = "";
11
11
  process.stdin.on("data", (chunk) => { input += chunk; });
@@ -59,7 +59,7 @@ process.stdin.on("end", () => {
59
59
  // Config exists — check selectionPolicy
60
60
  let config;
61
61
  try {
62
- config = JSON.parse(require("fs").readFileSync(configPath, "utf-8"));
62
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
63
63
  } catch {
64
64
  // Corrupted config — suggest re-setup
65
65
  console.log(JSON.stringify({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agestra",
3
- "version": "4.8.0",
3
+ "version": "4.8.1",
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",