agestra 4.5.4 → 4.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.ko.md +45 -4
- package/README.md +45 -4
- package/dist/bundle.js +1 -1
- package/package.json +13 -9
- package/scripts/install-host-mcp.mjs +104 -17
- package/scripts/uninstall-host-mcp.mjs +28 -4
package/README.ko.md
CHANGED
|
@@ -22,20 +22,50 @@ Claude는 기존 플러그인 설치 UX를 그대로 유지합니다. Agestra가
|
|
|
22
22
|
|
|
23
23
|
### Codex CLI
|
|
24
24
|
|
|
25
|
+
저장소 체크아웃 기준:
|
|
26
|
+
|
|
25
27
|
```
|
|
26
28
|
npm run bundle
|
|
27
29
|
npm run install:codex
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
전역 npm 패키지 기준:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
npm install -g agestra
|
|
36
|
+
agestra-install codex
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
저장소에서 작업 중이지만 등록 대상은 전역 npm 패키지로 하고 싶다면:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
npm run install:codex:global
|
|
43
|
+
```
|
|
44
|
+
|
|
30
45
|
Codex는 저장소 루트의 [AGENTS.md](AGENTS.md)와 등록된 `agestra` MCP 서버를 함께 사용합니다.
|
|
31
46
|
|
|
32
47
|
### Gemini CLI
|
|
33
48
|
|
|
49
|
+
저장소 체크아웃 기준:
|
|
50
|
+
|
|
34
51
|
```
|
|
35
52
|
npm run bundle
|
|
36
53
|
npm run install:gemini
|
|
37
54
|
```
|
|
38
55
|
|
|
56
|
+
전역 npm 패키지 기준:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
npm install -g agestra
|
|
60
|
+
agestra-install gemini
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
저장소에서 작업 중이지만 등록 대상은 전역 npm 패키지로 하고 싶다면:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
npm run install:gemini:global
|
|
67
|
+
```
|
|
68
|
+
|
|
39
69
|
Gemini는 저장소 루트의 [GEMINI.md](GEMINI.md)와 [`.gemini/commands/agestra/`](.gemini/commands/agestra) 프로젝트 커맨드를 함께 사용합니다.
|
|
40
70
|
|
|
41
71
|
설치 후 Gemini에서 사용할 수 있는 명령:
|
|
@@ -55,10 +85,21 @@ Gemini는 저장소 루트의 [GEMINI.md](GEMINI.md)와 [`.gemini/commands/agest
|
|
|
55
85
|
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `npm install -g @google/gemini-cli` | 클라우드 |
|
|
56
86
|
| [Codex CLI](https://github.com/openai/codex) | `npm install -g @openai/codex` | 클라우드 |
|
|
57
87
|
|
|
58
|
-
선택 사항이지만 권장:
|
|
59
|
-
- **tmux** — 자율 실행 중 CLI 워커 패인을 시각적으로 확인 가능
|
|
60
|
-
|
|
61
|
-
|
|
88
|
+
선택 사항이지만 권장:
|
|
89
|
+
- **tmux** — 자율 실행 중 CLI 워커 패인을 시각적으로 확인 가능
|
|
90
|
+
- **Windows의 ripgrep (`rg`)** — Codex가 Store 앱 번들 경로의 `rg`를 잡아서 `Access is denied` 오류가 나면, 별도 ripgrep를 설치해 정상 `rg.exe`가 `PATH`에서 먼저 잡히게 하세요:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
cargo install ripgrep
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
대안:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
winget install BurntSushi.ripgrep.MSVC
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
62
103
|
|
|
63
104
|
## 철학
|
|
64
105
|
|
package/README.md
CHANGED
|
@@ -22,20 +22,50 @@ Claude keeps the existing plugin UX. Agestra auto-detects available providers (C
|
|
|
22
22
|
|
|
23
23
|
### Codex CLI
|
|
24
24
|
|
|
25
|
+
Repository checkout:
|
|
26
|
+
|
|
25
27
|
```
|
|
26
28
|
npm run bundle
|
|
27
29
|
npm run install:codex
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
Global npm package:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
npm install -g agestra
|
|
36
|
+
agestra-install codex
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If you want to register the global package while working from a repo checkout, use:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
npm run install:codex:global
|
|
43
|
+
```
|
|
44
|
+
|
|
30
45
|
Codex uses the repository-level [AGENTS.md](AGENTS.md) instructions plus the registered `agestra` MCP server.
|
|
31
46
|
|
|
32
47
|
### Gemini CLI
|
|
33
48
|
|
|
49
|
+
Repository checkout:
|
|
50
|
+
|
|
34
51
|
```
|
|
35
52
|
npm run bundle
|
|
36
53
|
npm run install:gemini
|
|
37
54
|
```
|
|
38
55
|
|
|
56
|
+
Global npm package:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
npm install -g agestra
|
|
60
|
+
agestra-install gemini
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you want to register the global package while working from a repo checkout, use:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
npm run install:gemini:global
|
|
67
|
+
```
|
|
68
|
+
|
|
39
69
|
Gemini uses the repository-level [GEMINI.md](GEMINI.md) context file plus project commands under [`.gemini/commands/agestra/`](.gemini/commands/agestra).
|
|
40
70
|
|
|
41
71
|
Available Gemini commands after setup:
|
|
@@ -55,10 +85,21 @@ At least one AI provider must be installed:
|
|
|
55
85
|
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `npm install -g @google/gemini-cli` | Cloud |
|
|
56
86
|
| [Codex CLI](https://github.com/openai/codex) | `npm install -g @openai/codex` | Cloud |
|
|
57
87
|
|
|
58
|
-
Optional but recommended:
|
|
59
|
-
- **tmux** — enables visible CLI worker panes during autonomous execution
|
|
60
|
-
|
|
61
|
-
|
|
88
|
+
Optional but recommended:
|
|
89
|
+
- **tmux** — enables visible CLI worker panes during autonomous execution
|
|
90
|
+
- **ripgrep (`rg`)** on Windows — if Codex resolves `rg` to its bundled Store-app path and fails with an "Access is denied" error, install ripgrep separately so a normal `rg.exe` is found first in `PATH`:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
cargo install ripgrep
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Alternative:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
winget install BurntSushi.ripgrep.MSVC
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
62
103
|
|
|
63
104
|
## Philosophy
|
|
64
105
|
|
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 up=Object.create;var $d=Object.defineProperty;var np=Object.getOwnPropertyDescriptor;var wp=Object.getOwnPropertyNames;var vp=Object.getPrototypeOf,tp=Object.prototype.hasOwnProperty;var la=(G=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(G,{get:(I,l)=>(typeof require<"u"?require:I)[l]}):G)(function(G){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+G+'" is not supported')});var fl=(G,I)=>()=>(G&&(I=G(G=0)),I);var e=(G,I)=>()=>(I||G((I={exports:{}}).exports,I),I.exports),iI=(G,I)=>{for(var l in I)$d(G,l,{get:I[l],enumerable:!0})},sp=(G,I,l,b)=>{if(I&&typeof I=="object"||typeof I=="function")for(let Z of wp(I))!tp.call(G,Z)&&Z!==l&&$d(G,Z,{get:()=>I[Z],enumerable:!(b=np(I,Z))||b.enumerable});return G};var uc=(G,I,l)=>(l=G!=null?up(vp(G)):{},sp(I||!G||!G.__esModule?$d(l,"default",{value:G,enumerable:!0}):l,G));var ba,Kb,Za,ca,Wa,da,Na,ma,Ya,Va,aa,Db=fl(()=>{"use strict";ba="4.5.4",Kb="http://localhost:11434",Za="llama3",ca=".agestra/.jobs",Wa=".agestra/traces",da=".agestra/worktrees",Na=".agestra/sessions",ma=".agestra/workspace",Ya=".agestra/memory.db",Va=".agestra/messages",aa=".agestra/workers"});function $l(G,I=3e3){G.kill("SIGTERM"),setTimeout(()=>{try{G.kill("SIGKILL")}catch{}},I)}var wc=fl(()=>{"use strict"});import{execFileSync as ep,spawn as Jp}from"child_process";import{existsSync as Ep}from"fs";function Cp(G){return process.platform!=="win32"||G.includes("/")||G.includes("\\")?!1:yp.has(G.toLowerCase())}function gp(G){let I=G.toLowerCase();if(Sb.has(I))return Sb.get(I)??null;try{let b=ep("where.exe",[G],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).split(/\r?\n/).map(c=>c.trim()).find(Boolean);if(!b)return Sb.set(I,null),null;let Z=`${b}.ps1`;if(Ep(Z))return Sb.set(I,Z),Z}catch{}return Sb.set(I,null),null}function LG(G,I){if(!Cp(G))return{command:G,args:I};let l=gp(G);return l?{command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","RemoteSigned","-File",l,...I]}:{command:G,args:I}}function PI(G){let{command:I,args:l,timeout:b=12e4,cwd:Z,env:c,stdin:W,maxBuffer:d=10485760}=G;return new Promise((N,m)=>{let Y=LG(I,l),V=Jp(Y.command,Y.args,{cwd:Z,env:c?{...process.env,...c}:void 0,stdio:[W?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),a="",h="",R=0,F=0,Q=!1;V.stdout.on("data",J=>{R+=J.length,R<=d?a+=J.toString():Q=!0}),V.stderr.on("data",J=>{F+=J.length,F<=d?h+=J.toString():Q=!0}),W&&V.stdin&&(V.stdin.write(W),V.stdin.end());let H=()=>{$l(V),m(new Error(`CLI timeout after ${b}ms of inactivity: ${I} ${l.join(" ")}`))},w=setTimeout(H,b),n=()=>{clearTimeout(w),w=setTimeout(H,b)};V.stdout.on("data",n),V.stderr.on("data",n),V.on("close",J=>{clearTimeout(w),N({stdout:a,stderr:h,exitCode:J??1,truncated:Q})}),V.on("error",J=>{clearTimeout(w),m(new Error(`CLI spawn error: ${J.message}`))})})}var yp,Sb,Tb=fl(()=>{"use strict";wc();yp=new Set(["codex","gemini","npm","npx"]),Sb=new Map});import{writeFileSync as q0,mkdirSync as _b,openSync as ZN,writeSync as cN,fsyncSync as Ea,closeSync as WN,renameSync as f0,unlinkSync as P0,appendFileSync as _0}from"fs";import{dirname as $b,join as $0}from"path";import{randomUUID as Iu}from"crypto";function VI(G,I){let l=$b(G);_b(l,{recursive:!0});let b=$0(l,`.tmp-${Iu().slice(0,8)}`);try{q0(b,I,"utf-8"),f0(b,G)}catch(Z){try{P0(b)}catch{}throw Z}}function VG(G,I){VI(G,JSON.stringify(I,null,2))}function IZ(G,I){let l=$b(G);_b(l,{recursive:!0});let b=ZN(G,"a");try{cN(b,I),Ea(b)}finally{WN(b)}}var Lc,oc=fl(()=>{"use strict";Lc=class{buffer=new Map;flushTimer=null;flushIntervalMs;maxBufferSize;auditFsync;destroyed=!1;constructor(I){this.flushIntervalMs=I?.flushIntervalMs??2e3,this.maxBufferSize=I?.maxBufferSize??100,this.auditFsync=I?.auditFsync??!0,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>this.flush(),this.flushIntervalMs),this.flushTimer&&typeof this.flushTimer.unref=="function"&&this.flushTimer.unref())}append(I,l,b){if(this.destroyed)throw new Error("DurableAppendWriter has been destroyed");if(b==="audit"){if(this.auditFsync)IZ(I,l);else{let c=$b(I);_b(c,{recursive:!0}),_0(I,l)}return}let Z=this.buffer.get(I);Z||(Z=[],this.buffer.set(I,Z)),Z.push(l),Z.length>=this.maxBufferSize&&this.flushFile(I),this.flushIntervalMs===0&&this.flushFile(I)}flush(){for(let I of this.buffer.keys())this.flushFile(I)}panicFlush(){for(let[I,l]of this.buffer)if(l.length!==0)try{let b=$b(I);_b(b,{recursive:!0});let Z=ZN(I,"a");try{cN(Z,l.join("")),Ea(Z)}finally{WN(Z)}}catch{}this.buffer.clear()}destroy(){this.destroyed||(this.destroyed=!0,this.flushTimer!==null&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush())}flushFile(I){let l=this.buffer.get(I);if(!l||l.length===0)return;let b=$b(I);_b(b,{recursive:!0});let Z=ZN(I,"a");try{cN(Z,l.join(""))}finally{WN(Z)}this.buffer.delete(I)}}});import{existsSync as ya,realpathSync as Gu}from"fs";import{basename as lu,dirname as bu,isAbsolute as ga,join as Zu,normalize as cu,resolve as dN,relative as Wu}from"path";function du(G){return G===""||!G.startsWith("..")&&!ga(G)}function Ca(G){let I=[],l=dN(G);for(;!ya(l);){let Z=bu(l);if(Z===l)break;I.unshift(lu(l)),l=Z}let b=ya(l)?Gu(l):l;return I.reduce((Z,c)=>Zu(Z,c),b)}function Aa(G,I){let l=Ca(I),b=Ca(G),Z=Wu(l,b);return du(Z)}function NN(G,I){let l=dN(I,G);return Aa(l,I)}function Il(G,I){let l=dN(I,G);if(!Aa(l,I))throw new Error(`Path traversal blocked: ${G} escapes ${I}`);return l}function aG(G,I){if(ga(G)){let l=cu(G);if(!NN(l,I))throw new Error(`Read path outside base directory: ${G} is not within ${I}`);return l}return Il(G,I)}function kc(G){return Nu.test(G)}function La(G){return mu.has(G)}var Nu,mu,ic=fl(()=>{"use strict";Nu=/^[a-zA-Z0-9_-]+-\d+-[a-f0-9]{6}$/;mu=new Set(["gemini","codex","npx","node"])});var ia={};iI(ia,{CLI_PROVIDERS:()=>oa,resolveCliConfig:()=>ka});import{readFileSync as mN}from"fs";import{join as rG}from"path";import{spawn as Yu}from"child_process";function ka(G){if(G.cliCommand)return La(G.cliCommand)?{command:G.cliCommand,buildArgs:b=>G.cliArgs?G.cliArgs.map(Z=>Z==="{prompt}"?b:Z):[b]}:null;let I=Vu[G.provider]??G.provider;return oa[I]??null}function GZ(G,I){let l=rG(G,"status.json"),b=JSON.parse(mN(l,"utf-8"));VG(l,{...b,...I})}async function au(){let G=process.argv[2];G||process.exit(1);let I;try{I=JSON.parse(mN(rG(G,"job.json"),"utf-8"))}catch{process.exit(1)}let l=ka(I);l||(GZ(G,{state:"missing_cli",completedAt:new Date().toISOString()}),VI(rG(G,"error.txt"),`No CLI mapping for provider: ${I.provider}`),process.exit(1));let{command:b,buildArgs:Z}=l;GZ(G,{state:"running",startedAt:new Date().toISOString()});let c=mN(rG(G,"prompt.txt"),"utf-8"),W=Z(c);return new Promise(d=>{let N=LG(b,W),m=Yu(N.command,N.args,{stdio:["ignore","pipe","pipe"],windowsHide:!0}),Y="",V="",a=0,h=0;m.stdout.on("data",F=>{a+=F.length,a<=10485760&&(Y+=F.toString())}),m.stderr.on("data",F=>{h+=F.length,h<=10485760&&(V+=F.toString())});let R=setTimeout(()=>{$l(m),VI(rG(G,"output.txt"),Y),VI(rG(G,"error.txt"),V),GZ(G,{state:"timed_out",completedAt:new Date().toISOString()}),d()},I.timeout);m.on("close",F=>{clearTimeout(R),VI(rG(G,"output.txt"),Y),VI(rG(G,"error.txt"),V),GZ(G,{state:F===0?"completed":"error",exitCode:F??1,completedAt:new Date().toISOString()}),d()}),m.on("error",F=>{clearTimeout(R),VI(rG(G,"error.txt"),F.message),GZ(G,{state:"missing_cli",completedAt:new Date().toISOString()}),d()})})}var Vu,oa,hu,za=fl(()=>{"use strict";oc();wc();ic();Tb();Vu={"gemini-cli":"gemini","codex-cli":"codex"},oa={gemini:{command:"gemini",buildArgs:G=>["-p",G]},codex:{command:"codex",buildArgs:G=>["exec","--full-auto","--ephemeral",G]}};hu=process.argv[1]?.endsWith("job-worker.js")||process.argv[1]?.endsWith("job-worker.ts");hu&&au().catch(()=>process.exit(1))});var nh=e(NW=>{"use strict";NW.byteLength=qn;NW.toByteArray=Pn;NW.fromByteArray=Iw;var vG=[],lG=[],Tn=typeof Uint8Array<"u"?Uint8Array:Array,tN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(il=0,ph=tN.length;il<ph;++il)vG[il]=tN[il],lG[tN.charCodeAt(il)]=il;var il,ph;lG[45]=62;lG[95]=63;function uh(G){var I=G.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=G.indexOf("=");l===-1&&(l=I);var b=l===I?0:4-l%4;return[l,b]}function qn(G){var I=uh(G),l=I[0],b=I[1];return(l+b)*3/4-b}function fn(G,I,l){return(I+l)*3/4-l}function Pn(G){var I,l=uh(G),b=l[0],Z=l[1],c=new Tn(fn(G,b,Z)),W=0,d=Z>0?b-4:b,N;for(N=0;N<d;N+=4)I=lG[G.charCodeAt(N)]<<18|lG[G.charCodeAt(N+1)]<<12|lG[G.charCodeAt(N+2)]<<6|lG[G.charCodeAt(N+3)],c[W++]=I>>16&255,c[W++]=I>>8&255,c[W++]=I&255;return Z===2&&(I=lG[G.charCodeAt(N)]<<2|lG[G.charCodeAt(N+1)]>>4,c[W++]=I&255),Z===1&&(I=lG[G.charCodeAt(N)]<<10|lG[G.charCodeAt(N+1)]<<4|lG[G.charCodeAt(N+2)]>>2,c[W++]=I>>8&255,c[W++]=I&255),c}function _n(G){return vG[G>>18&63]+vG[G>>12&63]+vG[G>>6&63]+vG[G&63]}function $n(G,I,l){for(var b,Z=[],c=I;c<l;c+=3)b=(G[c]<<16&16711680)+(G[c+1]<<8&65280)+(G[c+2]&255),Z.push(_n(b));return Z.join("")}function Iw(G){for(var I,l=G.length,b=l%3,Z=[],c=16383,W=0,d=l-b;W<d;W+=c)Z.push($n(G,W,W+c>d?d:W+c));return b===1?(I=G[l-1],Z.push(vG[I>>2]+vG[I<<4&63]+"==")):b===2&&(I=(G[l-2]<<8)+G[l-1],Z.push(vG[I>>10]+vG[I>>4&63]+vG[I<<2&63]+"=")),Z.join("")}});var yh=e(wW=>{"use strict";Object.defineProperty(wW,"__esModule",{value:!0});wW.initSqlJs=Eh;function Eh(G){let l={...{locateFile:Z=>la("path").join(__dirname,Z)},...G};return la("./sql-wasm.cjs")(l)}wW.default=Eh});var DZ=e(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.regexpCode=_.getEsmExportName=_.getProperty=_.safeStringify=_.stringify=_.strConcat=_.addCodeArg=_.str=_._=_.nil=_._Code=_.Name=_.IDENTIFIER=_._CodeOrName=void 0;var jZ=class{};_._CodeOrName=jZ;_.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ul=class extends jZ{constructor(I){if(super(),!_.IDENTIFIER.test(I))throw new Error("CodeGen: name must be a valid identifier");this.str=I}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};_.Name=Ul;var WG=class extends jZ{constructor(I){super(),this._items=typeof I=="string"?[I]:I}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let I=this._items[0];return I===""||I==='""'}get str(){var I;return(I=this._str)!==null&&I!==void 0?I:this._str=this._items.reduce((l,b)=>`${l}${b}`,"")}get names(){var I;return(I=this._names)!==null&&I!==void 0?I:this._names=this._items.reduce((l,b)=>(b instanceof Ul&&(l[b.str]=(l[b.str]||0)+1),l),{})}};_._Code=WG;_.nil=new WG("");function IF(G,...I){let l=[G[0]],b=0;for(;b<I.length;)Mm(l,I[b]),l.push(G[++b]);return new WG(l)}_._=IF;var Om=new WG("+");function GF(G,...I){let l=[KZ(G[0])],b=0;for(;b<I.length;)l.push(Om),Mm(l,I[b]),l.push(Om,KZ(G[++b]));return Ps(l),new WG(l)}_.str=GF;function Mm(G,I){I instanceof WG?G.push(...I._items):I instanceof Ul?G.push(I):G.push(Ie(I))}_.addCodeArg=Mm;function Ps(G){let I=1;for(;I<G.length-1;){if(G[I]===Om){let l=_s(G[I-1],G[I+1]);if(l!==void 0){G.splice(I-1,3,l);continue}G[I++]="+"}I++}}function _s(G,I){if(I==='""')return G;if(G==='""')return I;if(typeof G=="string")return I instanceof Ul||G[G.length-1]!=='"'?void 0:typeof I!="string"?`${G.slice(0,-1)}${I}"`:I[0]==='"'?G.slice(0,-1)+I.slice(1):void 0;if(typeof I=="string"&&I[0]==='"'&&!(G instanceof Ul))return`"${G}${I.slice(1)}`}function $s(G,I){return I.emptyStr()?G:G.emptyStr()?I:GF`${G}${I}`}_.strConcat=$s;function Ie(G){return typeof G=="number"||typeof G=="boolean"||G===null?G:KZ(Array.isArray(G)?G.join(","):G)}function Ge(G){return new WG(KZ(G))}_.stringify=Ge;function KZ(G){return JSON.stringify(G).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}_.safeStringify=KZ;function le(G){return typeof G=="string"&&_.IDENTIFIER.test(G)?new WG(`.${G}`):IF`[${G}]`}_.getProperty=le;function be(G){if(typeof G=="string"&&_.IDENTIFIER.test(G))return new WG(`${G}`);throw new Error(`CodeGen: invalid export name: ${G}, use explicit $id name mapping`)}_.getEsmExportName=be;function Ze(G){return new WG(G.toString())}_.regexpCode=Ze});var Dm=e(DI=>{"use strict";Object.defineProperty(DI,"__esModule",{value:!0});DI.ValueScope=DI.ValueScopeName=DI.Scope=DI.varKinds=DI.UsedValueState=void 0;var KI=DZ(),jm=class extends Error{constructor(I){super(`CodeGen: "code" for ${I} not defined`),this.value=I.value}},Zd;(function(G){G[G.Started=0]="Started",G[G.Completed=1]="Completed"})(Zd||(DI.UsedValueState=Zd={}));DI.varKinds={const:new KI.Name("const"),let:new KI.Name("let"),var:new KI.Name("var")};var cd=class{constructor({prefixes:I,parent:l}={}){this._names={},this._prefixes=I,this._parent=l}toName(I){return I instanceof KI.Name?I:this.name(I)}name(I){return new KI.Name(this._newName(I))}_newName(I){let l=this._names[I]||this._nameGroup(I);return`${I}${l.index++}`}_nameGroup(I){var l,b;if(!((b=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||b===void 0)&&b.has(I)||this._prefixes&&!this._prefixes.has(I))throw new Error(`CodeGen: prefix "${I}" is not allowed in this scope`);return this._names[I]={prefix:I,index:0}}};DI.Scope=cd;var Wd=class extends KI.Name{constructor(I,l){super(l),this.prefix=I}setValue(I,{property:l,itemIndex:b}){this.value=I,this.scopePath=(0,KI._)`.${new KI.Name(l)}[${b}]`}};DI.ValueScopeName=Wd;var ce=(0,KI._)`\n`,Km=class extends cd{constructor(I){super(I),this._values={},this._scope=I.scope,this.opts={...I,_n:I.lines?ce:KI.nil}}get(){return this._scope}name(I){return new Wd(I,this._newName(I))}value(I,l){var b;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let Z=this.toName(I),{prefix:c}=Z,W=(b=l.key)!==null&&b!==void 0?b:l.ref,d=this._values[c];if(d){let Y=d.get(W);if(Y)return Y}else d=this._values[c]=new Map;d.set(W,Z);let N=this._scope[c]||(this._scope[c]=[]),m=N.length;return N[m]=l.ref,Z.setValue(l,{property:c,itemIndex:m}),Z}getValue(I,l){let b=this._values[I];if(b)return b.get(l)}scopeRefs(I,l=this._values){return this._reduceValues(l,b=>{if(b.scopePath===void 0)throw new Error(`CodeGen: name "${b}" has no value`);return(0,KI._)`${I}${b.scopePath}`})}scopeCode(I=this._values,l,b){return this._reduceValues(I,Z=>{if(Z.value===void 0)throw new Error(`CodeGen: name "${Z}" has no value`);return Z.value.code},l,b)}_reduceValues(I,l,b={},Z){let c=KI.nil;for(let W in I){let d=I[W];if(!d)continue;let N=b[W]=b[W]||new Map;d.forEach(m=>{if(N.has(m))return;N.set(m,Zd.Started);let Y=l(m);if(Y){let V=this.opts.es5?DI.varKinds.var:DI.varKinds.const;c=(0,KI._)`${c}${V} ${m} = ${Y};${this.opts._n}`}else if(Y=Z?.(m))c=(0,KI._)`${c}${Y}${this.opts._n}`;else throw new jm(m);N.set(m,Zd.Completed)})}return c}};DI.ValueScope=Km});var M=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 f=DZ(),RG=Dm(),dl=DZ();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return dl._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return dl.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return dl.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return dl.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return dl.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return dl.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return dl.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return dl.Name}});var Yd=Dm();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return Yd.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return Yd.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return Yd.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return Yd.varKinds}});K.operators={GT:new f._Code(">"),GTE:new f._Code(">="),LT:new f._Code("<"),LTE:new f._Code("<="),EQ:new f._Code("==="),NEQ:new f._Code("!=="),NOT:new f._Code("!"),OR:new f._Code("||"),AND:new f._Code("&&"),ADD:new f._Code("+")};var MG=class{optimizeNodes(){return this}optimizeNames(I,l){return this}},Sm=class extends MG{constructor(I,l,b){super(),this.varKind=I,this.name=l,this.rhs=b}render({es5:I,_n:l}){let b=I?RG.varKinds.var:this.varKind,Z=this.rhs===void 0?"":` = ${this.rhs}`;return`${b} ${this.name}${Z};`+l}optimizeNames(I,l){if(I[this.name.str])return this.rhs&&(this.rhs=Jb(this.rhs,I,l)),this}get names(){return this.rhs instanceof f._CodeOrName?this.rhs.names:{}}},dd=class extends MG{constructor(I,l,b){super(),this.lhs=I,this.rhs=l,this.sideEffects=b}render({_n:I}){return`${this.lhs} = ${this.rhs};`+I}optimizeNames(I,l){if(!(this.lhs instanceof f.Name&&!I[this.lhs.str]&&!this.sideEffects))return this.rhs=Jb(this.rhs,I,l),this}get names(){let I=this.lhs instanceof f.Name?{}:{...this.lhs.names};return md(I,this.rhs)}},Tm=class extends dd{constructor(I,l,b,Z){super(I,b,Z),this.op=l}render({_n:I}){return`${this.lhs} ${this.op}= ${this.rhs};`+I}},qm=class extends MG{constructor(I){super(),this.label=I,this.names={}}render({_n:I}){return`${this.label}:`+I}},fm=class extends MG{constructor(I){super(),this.label=I,this.names={}}render({_n:I}){return`break${this.label?` ${this.label}`:""};`+I}},Pm=class extends MG{constructor(I){super(),this.error=I}render({_n:I}){return`throw ${this.error};`+I}get names(){return this.error.names}},_m=class extends MG{constructor(I){super(),this.code=I}render({_n:I}){return`${this.code};`+I}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(I,l){return this.code=Jb(this.code,I,l),this}get names(){return this.code instanceof f._CodeOrName?this.code.names:{}}},SZ=class extends MG{constructor(I=[]){super(),this.nodes=I}render(I){return this.nodes.reduce((l,b)=>l+b.render(I),"")}optimizeNodes(){let{nodes:I}=this,l=I.length;for(;l--;){let b=I[l].optimizeNodes();Array.isArray(b)?I.splice(l,1,...b):b?I[l]=b:I.splice(l,1)}return I.length>0?this:void 0}optimizeNames(I,l){let{nodes:b}=this,Z=b.length;for(;Z--;){let c=b[Z];c.optimizeNames(I,l)||(We(I,c.names),b.splice(Z,1))}return b.length>0?this:void 0}get names(){return this.nodes.reduce((I,l)=>Ml(I,l.names),{})}},jG=class extends SZ{render(I){return"{"+I._n+super.render(I)+"}"+I._n}},$m=class extends SZ{},eb=class extends jG{};eb.kind="else";var Bl=class G extends jG{constructor(I,l){super(l),this.condition=I}render(I){let l=`if(${this.condition})`+super.render(I);return this.else&&(l+="else "+this.else.render(I)),l}optimizeNodes(){super.optimizeNodes();let I=this.condition;if(I===!0)return this.nodes;let l=this.else;if(l){let b=l.optimizeNodes();l=this.else=Array.isArray(b)?new eb(b):b}if(l)return I===!1?l instanceof G?l:l.nodes:this.nodes.length?this:new G(lF(I),l instanceof G?[l]:l.nodes);if(!(I===!1||!this.nodes.length))return this}optimizeNames(I,l){var b;if(this.else=(b=this.else)===null||b===void 0?void 0:b.optimizeNames(I,l),!!(super.optimizeNames(I,l)||this.else))return this.condition=Jb(this.condition,I,l),this}get names(){let I=super.names;return md(I,this.condition),this.else&&Ml(I,this.else.names),I}};Bl.kind="if";var Ol=class extends jG{};Ol.kind="for";var IY=class extends Ol{constructor(I){super(),this.iteration=I}render(I){return`for(${this.iteration})`+super.render(I)}optimizeNames(I,l){if(super.optimizeNames(I,l))return this.iteration=Jb(this.iteration,I,l),this}get names(){return Ml(super.names,this.iteration.names)}},GY=class extends Ol{constructor(I,l,b,Z){super(),this.varKind=I,this.name=l,this.from=b,this.to=Z}render(I){let l=I.es5?RG.varKinds.var:this.varKind,{name:b,from:Z,to:c}=this;return`for(${l} ${b}=${Z}; ${b}<${c}; ${b}++)`+super.render(I)}get names(){let I=md(super.names,this.from);return md(I,this.to)}},Nd=class extends Ol{constructor(I,l,b,Z){super(),this.loop=I,this.varKind=l,this.name=b,this.iterable=Z}render(I){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(I)}optimizeNames(I,l){if(super.optimizeNames(I,l))return this.iterable=Jb(this.iterable,I,l),this}get names(){return Ml(super.names,this.iterable.names)}},TZ=class extends jG{constructor(I,l,b){super(),this.name=I,this.args=l,this.async=b}render(I){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(I)}};TZ.kind="func";var qZ=class extends SZ{render(I){return"return "+super.render(I)}};qZ.kind="return";var lY=class extends jG{render(I){let l="try"+super.render(I);return this.catch&&(l+=this.catch.render(I)),this.finally&&(l+=this.finally.render(I)),l}optimizeNodes(){var I,l;return super.optimizeNodes(),(I=this.catch)===null||I===void 0||I.optimizeNodes(),(l=this.finally)===null||l===void 0||l.optimizeNodes(),this}optimizeNames(I,l){var b,Z;return super.optimizeNames(I,l),(b=this.catch)===null||b===void 0||b.optimizeNames(I,l),(Z=this.finally)===null||Z===void 0||Z.optimizeNames(I,l),this}get names(){let I=super.names;return this.catch&&Ml(I,this.catch.names),this.finally&&Ml(I,this.finally.names),I}},fZ=class extends jG{constructor(I){super(),this.error=I}render(I){return`catch(${this.error})`+super.render(I)}};fZ.kind="catch";var PZ=class extends jG{render(I){return"finally"+super.render(I)}};PZ.kind="finally";var bY=class{constructor(I,l={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...l,_n:l.lines?`
|
|
3
|
+
var up=Object.create;var $d=Object.defineProperty;var np=Object.getOwnPropertyDescriptor;var wp=Object.getOwnPropertyNames;var vp=Object.getPrototypeOf,tp=Object.prototype.hasOwnProperty;var la=(G=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(G,{get:(I,l)=>(typeof require<"u"?require:I)[l]}):G)(function(G){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+G+'" is not supported')});var fl=(G,I)=>()=>(G&&(I=G(G=0)),I);var e=(G,I)=>()=>(I||G((I={exports:{}}).exports,I),I.exports),iI=(G,I)=>{for(var l in I)$d(G,l,{get:I[l],enumerable:!0})},sp=(G,I,l,b)=>{if(I&&typeof I=="object"||typeof I=="function")for(let Z of wp(I))!tp.call(G,Z)&&Z!==l&&$d(G,Z,{get:()=>I[Z],enumerable:!(b=np(I,Z))||b.enumerable});return G};var uc=(G,I,l)=>(l=G!=null?up(vp(G)):{},sp(I||!G||!G.__esModule?$d(l,"default",{value:G,enumerable:!0}):l,G));var ba,Kb,Za,ca,Wa,da,Na,ma,Ya,Va,aa,Db=fl(()=>{"use strict";ba="4.5.5",Kb="http://localhost:11434",Za="llama3",ca=".agestra/.jobs",Wa=".agestra/traces",da=".agestra/worktrees",Na=".agestra/sessions",ma=".agestra/workspace",Ya=".agestra/memory.db",Va=".agestra/messages",aa=".agestra/workers"});function $l(G,I=3e3){G.kill("SIGTERM"),setTimeout(()=>{try{G.kill("SIGKILL")}catch{}},I)}var wc=fl(()=>{"use strict"});import{execFileSync as ep,spawn as Jp}from"child_process";import{existsSync as Ep}from"fs";function Cp(G){return process.platform!=="win32"||G.includes("/")||G.includes("\\")?!1:yp.has(G.toLowerCase())}function gp(G){let I=G.toLowerCase();if(Sb.has(I))return Sb.get(I)??null;try{let b=ep("where.exe",[G],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).split(/\r?\n/).map(c=>c.trim()).find(Boolean);if(!b)return Sb.set(I,null),null;let Z=`${b}.ps1`;if(Ep(Z))return Sb.set(I,Z),Z}catch{}return Sb.set(I,null),null}function LG(G,I){if(!Cp(G))return{command:G,args:I};let l=gp(G);return l?{command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","RemoteSigned","-File",l,...I]}:{command:G,args:I}}function PI(G){let{command:I,args:l,timeout:b=12e4,cwd:Z,env:c,stdin:W,maxBuffer:d=10485760}=G;return new Promise((N,m)=>{let Y=LG(I,l),V=Jp(Y.command,Y.args,{cwd:Z,env:c?{...process.env,...c}:void 0,stdio:[W?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),a="",h="",R=0,F=0,Q=!1;V.stdout.on("data",J=>{R+=J.length,R<=d?a+=J.toString():Q=!0}),V.stderr.on("data",J=>{F+=J.length,F<=d?h+=J.toString():Q=!0}),W&&V.stdin&&(V.stdin.write(W),V.stdin.end());let H=()=>{$l(V),m(new Error(`CLI timeout after ${b}ms of inactivity: ${I} ${l.join(" ")}`))},w=setTimeout(H,b),n=()=>{clearTimeout(w),w=setTimeout(H,b)};V.stdout.on("data",n),V.stderr.on("data",n),V.on("close",J=>{clearTimeout(w),N({stdout:a,stderr:h,exitCode:J??1,truncated:Q})}),V.on("error",J=>{clearTimeout(w),m(new Error(`CLI spawn error: ${J.message}`))})})}var yp,Sb,Tb=fl(()=>{"use strict";wc();yp=new Set(["codex","gemini","npm","npx"]),Sb=new Map});import{writeFileSync as q0,mkdirSync as _b,openSync as ZN,writeSync as cN,fsyncSync as Ea,closeSync as WN,renameSync as f0,unlinkSync as P0,appendFileSync as _0}from"fs";import{dirname as $b,join as $0}from"path";import{randomUUID as Iu}from"crypto";function VI(G,I){let l=$b(G);_b(l,{recursive:!0});let b=$0(l,`.tmp-${Iu().slice(0,8)}`);try{q0(b,I,"utf-8"),f0(b,G)}catch(Z){try{P0(b)}catch{}throw Z}}function VG(G,I){VI(G,JSON.stringify(I,null,2))}function IZ(G,I){let l=$b(G);_b(l,{recursive:!0});let b=ZN(G,"a");try{cN(b,I),Ea(b)}finally{WN(b)}}var Lc,oc=fl(()=>{"use strict";Lc=class{buffer=new Map;flushTimer=null;flushIntervalMs;maxBufferSize;auditFsync;destroyed=!1;constructor(I){this.flushIntervalMs=I?.flushIntervalMs??2e3,this.maxBufferSize=I?.maxBufferSize??100,this.auditFsync=I?.auditFsync??!0,this.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>this.flush(),this.flushIntervalMs),this.flushTimer&&typeof this.flushTimer.unref=="function"&&this.flushTimer.unref())}append(I,l,b){if(this.destroyed)throw new Error("DurableAppendWriter has been destroyed");if(b==="audit"){if(this.auditFsync)IZ(I,l);else{let c=$b(I);_b(c,{recursive:!0}),_0(I,l)}return}let Z=this.buffer.get(I);Z||(Z=[],this.buffer.set(I,Z)),Z.push(l),Z.length>=this.maxBufferSize&&this.flushFile(I),this.flushIntervalMs===0&&this.flushFile(I)}flush(){for(let I of this.buffer.keys())this.flushFile(I)}panicFlush(){for(let[I,l]of this.buffer)if(l.length!==0)try{let b=$b(I);_b(b,{recursive:!0});let Z=ZN(I,"a");try{cN(Z,l.join("")),Ea(Z)}finally{WN(Z)}}catch{}this.buffer.clear()}destroy(){this.destroyed||(this.destroyed=!0,this.flushTimer!==null&&(clearInterval(this.flushTimer),this.flushTimer=null),this.flush())}flushFile(I){let l=this.buffer.get(I);if(!l||l.length===0)return;let b=$b(I);_b(b,{recursive:!0});let Z=ZN(I,"a");try{cN(Z,l.join(""))}finally{WN(Z)}this.buffer.delete(I)}}});import{existsSync as ya,realpathSync as Gu}from"fs";import{basename as lu,dirname as bu,isAbsolute as ga,join as Zu,normalize as cu,resolve as dN,relative as Wu}from"path";function du(G){return G===""||!G.startsWith("..")&&!ga(G)}function Ca(G){let I=[],l=dN(G);for(;!ya(l);){let Z=bu(l);if(Z===l)break;I.unshift(lu(l)),l=Z}let b=ya(l)?Gu(l):l;return I.reduce((Z,c)=>Zu(Z,c),b)}function Aa(G,I){let l=Ca(I),b=Ca(G),Z=Wu(l,b);return du(Z)}function NN(G,I){let l=dN(I,G);return Aa(l,I)}function Il(G,I){let l=dN(I,G);if(!Aa(l,I))throw new Error(`Path traversal blocked: ${G} escapes ${I}`);return l}function aG(G,I){if(ga(G)){let l=cu(G);if(!NN(l,I))throw new Error(`Read path outside base directory: ${G} is not within ${I}`);return l}return Il(G,I)}function kc(G){return Nu.test(G)}function La(G){return mu.has(G)}var Nu,mu,ic=fl(()=>{"use strict";Nu=/^[a-zA-Z0-9_-]+-\d+-[a-f0-9]{6}$/;mu=new Set(["gemini","codex","npx","node"])});var ia={};iI(ia,{CLI_PROVIDERS:()=>oa,resolveCliConfig:()=>ka});import{readFileSync as mN}from"fs";import{join as rG}from"path";import{spawn as Yu}from"child_process";function ka(G){if(G.cliCommand)return La(G.cliCommand)?{command:G.cliCommand,buildArgs:b=>G.cliArgs?G.cliArgs.map(Z=>Z==="{prompt}"?b:Z):[b]}:null;let I=Vu[G.provider]??G.provider;return oa[I]??null}function GZ(G,I){let l=rG(G,"status.json"),b=JSON.parse(mN(l,"utf-8"));VG(l,{...b,...I})}async function au(){let G=process.argv[2];G||process.exit(1);let I;try{I=JSON.parse(mN(rG(G,"job.json"),"utf-8"))}catch{process.exit(1)}let l=ka(I);l||(GZ(G,{state:"missing_cli",completedAt:new Date().toISOString()}),VI(rG(G,"error.txt"),`No CLI mapping for provider: ${I.provider}`),process.exit(1));let{command:b,buildArgs:Z}=l;GZ(G,{state:"running",startedAt:new Date().toISOString()});let c=mN(rG(G,"prompt.txt"),"utf-8"),W=Z(c);return new Promise(d=>{let N=LG(b,W),m=Yu(N.command,N.args,{stdio:["ignore","pipe","pipe"],windowsHide:!0}),Y="",V="",a=0,h=0;m.stdout.on("data",F=>{a+=F.length,a<=10485760&&(Y+=F.toString())}),m.stderr.on("data",F=>{h+=F.length,h<=10485760&&(V+=F.toString())});let R=setTimeout(()=>{$l(m),VI(rG(G,"output.txt"),Y),VI(rG(G,"error.txt"),V),GZ(G,{state:"timed_out",completedAt:new Date().toISOString()}),d()},I.timeout);m.on("close",F=>{clearTimeout(R),VI(rG(G,"output.txt"),Y),VI(rG(G,"error.txt"),V),GZ(G,{state:F===0?"completed":"error",exitCode:F??1,completedAt:new Date().toISOString()}),d()}),m.on("error",F=>{clearTimeout(R),VI(rG(G,"error.txt"),F.message),GZ(G,{state:"missing_cli",completedAt:new Date().toISOString()}),d()})})}var Vu,oa,hu,za=fl(()=>{"use strict";oc();wc();ic();Tb();Vu={"gemini-cli":"gemini","codex-cli":"codex"},oa={gemini:{command:"gemini",buildArgs:G=>["-p",G]},codex:{command:"codex",buildArgs:G=>["exec","--full-auto","--ephemeral",G]}};hu=process.argv[1]?.endsWith("job-worker.js")||process.argv[1]?.endsWith("job-worker.ts");hu&&au().catch(()=>process.exit(1))});var nh=e(NW=>{"use strict";NW.byteLength=qn;NW.toByteArray=Pn;NW.fromByteArray=Iw;var vG=[],lG=[],Tn=typeof Uint8Array<"u"?Uint8Array:Array,tN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(il=0,ph=tN.length;il<ph;++il)vG[il]=tN[il],lG[tN.charCodeAt(il)]=il;var il,ph;lG[45]=62;lG[95]=63;function uh(G){var I=G.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=G.indexOf("=");l===-1&&(l=I);var b=l===I?0:4-l%4;return[l,b]}function qn(G){var I=uh(G),l=I[0],b=I[1];return(l+b)*3/4-b}function fn(G,I,l){return(I+l)*3/4-l}function Pn(G){var I,l=uh(G),b=l[0],Z=l[1],c=new Tn(fn(G,b,Z)),W=0,d=Z>0?b-4:b,N;for(N=0;N<d;N+=4)I=lG[G.charCodeAt(N)]<<18|lG[G.charCodeAt(N+1)]<<12|lG[G.charCodeAt(N+2)]<<6|lG[G.charCodeAt(N+3)],c[W++]=I>>16&255,c[W++]=I>>8&255,c[W++]=I&255;return Z===2&&(I=lG[G.charCodeAt(N)]<<2|lG[G.charCodeAt(N+1)]>>4,c[W++]=I&255),Z===1&&(I=lG[G.charCodeAt(N)]<<10|lG[G.charCodeAt(N+1)]<<4|lG[G.charCodeAt(N+2)]>>2,c[W++]=I>>8&255,c[W++]=I&255),c}function _n(G){return vG[G>>18&63]+vG[G>>12&63]+vG[G>>6&63]+vG[G&63]}function $n(G,I,l){for(var b,Z=[],c=I;c<l;c+=3)b=(G[c]<<16&16711680)+(G[c+1]<<8&65280)+(G[c+2]&255),Z.push(_n(b));return Z.join("")}function Iw(G){for(var I,l=G.length,b=l%3,Z=[],c=16383,W=0,d=l-b;W<d;W+=c)Z.push($n(G,W,W+c>d?d:W+c));return b===1?(I=G[l-1],Z.push(vG[I>>2]+vG[I<<4&63]+"==")):b===2&&(I=(G[l-2]<<8)+G[l-1],Z.push(vG[I>>10]+vG[I>>4&63]+vG[I<<2&63]+"=")),Z.join("")}});var yh=e(wW=>{"use strict";Object.defineProperty(wW,"__esModule",{value:!0});wW.initSqlJs=Eh;function Eh(G){let l={...{locateFile:Z=>la("path").join(__dirname,Z)},...G};return la("./sql-wasm.cjs")(l)}wW.default=Eh});var DZ=e(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.regexpCode=_.getEsmExportName=_.getProperty=_.safeStringify=_.stringify=_.strConcat=_.addCodeArg=_.str=_._=_.nil=_._Code=_.Name=_.IDENTIFIER=_._CodeOrName=void 0;var jZ=class{};_._CodeOrName=jZ;_.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ul=class extends jZ{constructor(I){if(super(),!_.IDENTIFIER.test(I))throw new Error("CodeGen: name must be a valid identifier");this.str=I}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};_.Name=Ul;var WG=class extends jZ{constructor(I){super(),this._items=typeof I=="string"?[I]:I}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let I=this._items[0];return I===""||I==='""'}get str(){var I;return(I=this._str)!==null&&I!==void 0?I:this._str=this._items.reduce((l,b)=>`${l}${b}`,"")}get names(){var I;return(I=this._names)!==null&&I!==void 0?I:this._names=this._items.reduce((l,b)=>(b instanceof Ul&&(l[b.str]=(l[b.str]||0)+1),l),{})}};_._Code=WG;_.nil=new WG("");function IF(G,...I){let l=[G[0]],b=0;for(;b<I.length;)Mm(l,I[b]),l.push(G[++b]);return new WG(l)}_._=IF;var Om=new WG("+");function GF(G,...I){let l=[KZ(G[0])],b=0;for(;b<I.length;)l.push(Om),Mm(l,I[b]),l.push(Om,KZ(G[++b]));return Ps(l),new WG(l)}_.str=GF;function Mm(G,I){I instanceof WG?G.push(...I._items):I instanceof Ul?G.push(I):G.push(Ie(I))}_.addCodeArg=Mm;function Ps(G){let I=1;for(;I<G.length-1;){if(G[I]===Om){let l=_s(G[I-1],G[I+1]);if(l!==void 0){G.splice(I-1,3,l);continue}G[I++]="+"}I++}}function _s(G,I){if(I==='""')return G;if(G==='""')return I;if(typeof G=="string")return I instanceof Ul||G[G.length-1]!=='"'?void 0:typeof I!="string"?`${G.slice(0,-1)}${I}"`:I[0]==='"'?G.slice(0,-1)+I.slice(1):void 0;if(typeof I=="string"&&I[0]==='"'&&!(G instanceof Ul))return`"${G}${I.slice(1)}`}function $s(G,I){return I.emptyStr()?G:G.emptyStr()?I:GF`${G}${I}`}_.strConcat=$s;function Ie(G){return typeof G=="number"||typeof G=="boolean"||G===null?G:KZ(Array.isArray(G)?G.join(","):G)}function Ge(G){return new WG(KZ(G))}_.stringify=Ge;function KZ(G){return JSON.stringify(G).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}_.safeStringify=KZ;function le(G){return typeof G=="string"&&_.IDENTIFIER.test(G)?new WG(`.${G}`):IF`[${G}]`}_.getProperty=le;function be(G){if(typeof G=="string"&&_.IDENTIFIER.test(G))return new WG(`${G}`);throw new Error(`CodeGen: invalid export name: ${G}, use explicit $id name mapping`)}_.getEsmExportName=be;function Ze(G){return new WG(G.toString())}_.regexpCode=Ze});var Dm=e(DI=>{"use strict";Object.defineProperty(DI,"__esModule",{value:!0});DI.ValueScope=DI.ValueScopeName=DI.Scope=DI.varKinds=DI.UsedValueState=void 0;var KI=DZ(),jm=class extends Error{constructor(I){super(`CodeGen: "code" for ${I} not defined`),this.value=I.value}},Zd;(function(G){G[G.Started=0]="Started",G[G.Completed=1]="Completed"})(Zd||(DI.UsedValueState=Zd={}));DI.varKinds={const:new KI.Name("const"),let:new KI.Name("let"),var:new KI.Name("var")};var cd=class{constructor({prefixes:I,parent:l}={}){this._names={},this._prefixes=I,this._parent=l}toName(I){return I instanceof KI.Name?I:this.name(I)}name(I){return new KI.Name(this._newName(I))}_newName(I){let l=this._names[I]||this._nameGroup(I);return`${I}${l.index++}`}_nameGroup(I){var l,b;if(!((b=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||b===void 0)&&b.has(I)||this._prefixes&&!this._prefixes.has(I))throw new Error(`CodeGen: prefix "${I}" is not allowed in this scope`);return this._names[I]={prefix:I,index:0}}};DI.Scope=cd;var Wd=class extends KI.Name{constructor(I,l){super(l),this.prefix=I}setValue(I,{property:l,itemIndex:b}){this.value=I,this.scopePath=(0,KI._)`.${new KI.Name(l)}[${b}]`}};DI.ValueScopeName=Wd;var ce=(0,KI._)`\n`,Km=class extends cd{constructor(I){super(I),this._values={},this._scope=I.scope,this.opts={...I,_n:I.lines?ce:KI.nil}}get(){return this._scope}name(I){return new Wd(I,this._newName(I))}value(I,l){var b;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let Z=this.toName(I),{prefix:c}=Z,W=(b=l.key)!==null&&b!==void 0?b:l.ref,d=this._values[c];if(d){let Y=d.get(W);if(Y)return Y}else d=this._values[c]=new Map;d.set(W,Z);let N=this._scope[c]||(this._scope[c]=[]),m=N.length;return N[m]=l.ref,Z.setValue(l,{property:c,itemIndex:m}),Z}getValue(I,l){let b=this._values[I];if(b)return b.get(l)}scopeRefs(I,l=this._values){return this._reduceValues(l,b=>{if(b.scopePath===void 0)throw new Error(`CodeGen: name "${b}" has no value`);return(0,KI._)`${I}${b.scopePath}`})}scopeCode(I=this._values,l,b){return this._reduceValues(I,Z=>{if(Z.value===void 0)throw new Error(`CodeGen: name "${Z}" has no value`);return Z.value.code},l,b)}_reduceValues(I,l,b={},Z){let c=KI.nil;for(let W in I){let d=I[W];if(!d)continue;let N=b[W]=b[W]||new Map;d.forEach(m=>{if(N.has(m))return;N.set(m,Zd.Started);let Y=l(m);if(Y){let V=this.opts.es5?DI.varKinds.var:DI.varKinds.const;c=(0,KI._)`${c}${V} ${m} = ${Y};${this.opts._n}`}else if(Y=Z?.(m))c=(0,KI._)`${c}${Y}${this.opts._n}`;else throw new jm(m);N.set(m,Zd.Completed)})}return c}};DI.ValueScope=Km});var M=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 f=DZ(),RG=Dm(),dl=DZ();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return dl._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return dl.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return dl.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return dl.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return dl.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return dl.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return dl.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return dl.Name}});var Yd=Dm();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return Yd.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return Yd.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return Yd.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return Yd.varKinds}});K.operators={GT:new f._Code(">"),GTE:new f._Code(">="),LT:new f._Code("<"),LTE:new f._Code("<="),EQ:new f._Code("==="),NEQ:new f._Code("!=="),NOT:new f._Code("!"),OR:new f._Code("||"),AND:new f._Code("&&"),ADD:new f._Code("+")};var MG=class{optimizeNodes(){return this}optimizeNames(I,l){return this}},Sm=class extends MG{constructor(I,l,b){super(),this.varKind=I,this.name=l,this.rhs=b}render({es5:I,_n:l}){let b=I?RG.varKinds.var:this.varKind,Z=this.rhs===void 0?"":` = ${this.rhs}`;return`${b} ${this.name}${Z};`+l}optimizeNames(I,l){if(I[this.name.str])return this.rhs&&(this.rhs=Jb(this.rhs,I,l)),this}get names(){return this.rhs instanceof f._CodeOrName?this.rhs.names:{}}},dd=class extends MG{constructor(I,l,b){super(),this.lhs=I,this.rhs=l,this.sideEffects=b}render({_n:I}){return`${this.lhs} = ${this.rhs};`+I}optimizeNames(I,l){if(!(this.lhs instanceof f.Name&&!I[this.lhs.str]&&!this.sideEffects))return this.rhs=Jb(this.rhs,I,l),this}get names(){let I=this.lhs instanceof f.Name?{}:{...this.lhs.names};return md(I,this.rhs)}},Tm=class extends dd{constructor(I,l,b,Z){super(I,b,Z),this.op=l}render({_n:I}){return`${this.lhs} ${this.op}= ${this.rhs};`+I}},qm=class extends MG{constructor(I){super(),this.label=I,this.names={}}render({_n:I}){return`${this.label}:`+I}},fm=class extends MG{constructor(I){super(),this.label=I,this.names={}}render({_n:I}){return`break${this.label?` ${this.label}`:""};`+I}},Pm=class extends MG{constructor(I){super(),this.error=I}render({_n:I}){return`throw ${this.error};`+I}get names(){return this.error.names}},_m=class extends MG{constructor(I){super(),this.code=I}render({_n:I}){return`${this.code};`+I}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(I,l){return this.code=Jb(this.code,I,l),this}get names(){return this.code instanceof f._CodeOrName?this.code.names:{}}},SZ=class extends MG{constructor(I=[]){super(),this.nodes=I}render(I){return this.nodes.reduce((l,b)=>l+b.render(I),"")}optimizeNodes(){let{nodes:I}=this,l=I.length;for(;l--;){let b=I[l].optimizeNodes();Array.isArray(b)?I.splice(l,1,...b):b?I[l]=b:I.splice(l,1)}return I.length>0?this:void 0}optimizeNames(I,l){let{nodes:b}=this,Z=b.length;for(;Z--;){let c=b[Z];c.optimizeNames(I,l)||(We(I,c.names),b.splice(Z,1))}return b.length>0?this:void 0}get names(){return this.nodes.reduce((I,l)=>Ml(I,l.names),{})}},jG=class extends SZ{render(I){return"{"+I._n+super.render(I)+"}"+I._n}},$m=class extends SZ{},eb=class extends jG{};eb.kind="else";var Bl=class G extends jG{constructor(I,l){super(l),this.condition=I}render(I){let l=`if(${this.condition})`+super.render(I);return this.else&&(l+="else "+this.else.render(I)),l}optimizeNodes(){super.optimizeNodes();let I=this.condition;if(I===!0)return this.nodes;let l=this.else;if(l){let b=l.optimizeNodes();l=this.else=Array.isArray(b)?new eb(b):b}if(l)return I===!1?l instanceof G?l:l.nodes:this.nodes.length?this:new G(lF(I),l instanceof G?[l]:l.nodes);if(!(I===!1||!this.nodes.length))return this}optimizeNames(I,l){var b;if(this.else=(b=this.else)===null||b===void 0?void 0:b.optimizeNames(I,l),!!(super.optimizeNames(I,l)||this.else))return this.condition=Jb(this.condition,I,l),this}get names(){let I=super.names;return md(I,this.condition),this.else&&Ml(I,this.else.names),I}};Bl.kind="if";var Ol=class extends jG{};Ol.kind="for";var IY=class extends Ol{constructor(I){super(),this.iteration=I}render(I){return`for(${this.iteration})`+super.render(I)}optimizeNames(I,l){if(super.optimizeNames(I,l))return this.iteration=Jb(this.iteration,I,l),this}get names(){return Ml(super.names,this.iteration.names)}},GY=class extends Ol{constructor(I,l,b,Z){super(),this.varKind=I,this.name=l,this.from=b,this.to=Z}render(I){let l=I.es5?RG.varKinds.var:this.varKind,{name:b,from:Z,to:c}=this;return`for(${l} ${b}=${Z}; ${b}<${c}; ${b}++)`+super.render(I)}get names(){let I=md(super.names,this.from);return md(I,this.to)}},Nd=class extends Ol{constructor(I,l,b,Z){super(),this.loop=I,this.varKind=l,this.name=b,this.iterable=Z}render(I){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(I)}optimizeNames(I,l){if(super.optimizeNames(I,l))return this.iterable=Jb(this.iterable,I,l),this}get names(){return Ml(super.names,this.iterable.names)}},TZ=class extends jG{constructor(I,l,b){super(),this.name=I,this.args=l,this.async=b}render(I){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(I)}};TZ.kind="func";var qZ=class extends SZ{render(I){return"return "+super.render(I)}};qZ.kind="return";var lY=class extends jG{render(I){let l="try"+super.render(I);return this.catch&&(l+=this.catch.render(I)),this.finally&&(l+=this.finally.render(I)),l}optimizeNodes(){var I,l;return super.optimizeNodes(),(I=this.catch)===null||I===void 0||I.optimizeNodes(),(l=this.finally)===null||l===void 0||l.optimizeNodes(),this}optimizeNames(I,l){var b,Z;return super.optimizeNames(I,l),(b=this.catch)===null||b===void 0||b.optimizeNames(I,l),(Z=this.finally)===null||Z===void 0||Z.optimizeNames(I,l),this}get names(){let I=super.names;return this.catch&&Ml(I,this.catch.names),this.finally&&Ml(I,this.finally.names),I}},fZ=class extends jG{constructor(I){super(),this.error=I}render(I){return`catch(${this.error})`+super.render(I)}};fZ.kind="catch";var PZ=class extends jG{render(I){return"finally"+super.render(I)}};PZ.kind="finally";var bY=class{constructor(I,l={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...l,_n:l.lines?`
|
|
4
4
|
`:""},this._extScope=I,this._scope=new RG.Scope({parent:I}),this._nodes=[new $m]}toString(){return this._root.render(this.opts)}name(I){return this._scope.name(I)}scopeName(I){return this._extScope.name(I)}scopeValue(I,l){let b=this._extScope.value(I,l);return(this._values[b.prefix]||(this._values[b.prefix]=new Set)).add(b),b}getScopeValue(I,l){return this._extScope.getValue(I,l)}scopeRefs(I){return this._extScope.scopeRefs(I,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(I,l,b,Z){let c=this._scope.toName(l);return b!==void 0&&Z&&(this._constants[c.str]=b),this._leafNode(new Sm(I,c,b)),c}const(I,l,b){return this._def(RG.varKinds.const,I,l,b)}let(I,l,b){return this._def(RG.varKinds.let,I,l,b)}var(I,l,b){return this._def(RG.varKinds.var,I,l,b)}assign(I,l,b){return this._leafNode(new dd(I,l,b))}add(I,l){return this._leafNode(new Tm(I,K.operators.ADD,l))}code(I){return typeof I=="function"?I():I!==f.nil&&this._leafNode(new _m(I)),this}object(...I){let l=["{"];for(let[b,Z]of I)l.length>1&&l.push(","),l.push(b),(b!==Z||this.opts.es5)&&(l.push(":"),(0,f.addCodeArg)(l,Z));return l.push("}"),new f._Code(l)}if(I,l,b){if(this._blockNode(new Bl(I)),l&&b)this.code(l).else().code(b).endIf();else if(l)this.code(l).endIf();else if(b)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(I){return this._elseNode(new Bl(I))}else(){return this._elseNode(new eb)}endIf(){return this._endBlockNode(Bl,eb)}_for(I,l){return this._blockNode(I),l&&this.code(l).endFor(),this}for(I,l){return this._for(new IY(I),l)}forRange(I,l,b,Z,c=this.opts.es5?RG.varKinds.var:RG.varKinds.let){let W=this._scope.toName(I);return this._for(new GY(c,W,l,b),()=>Z(W))}forOf(I,l,b,Z=RG.varKinds.const){let c=this._scope.toName(I);if(this.opts.es5){let W=l instanceof f.Name?l:this.var("_arr",l);return this.forRange("_i",0,(0,f._)`${W}.length`,d=>{this.var(c,(0,f._)`${W}[${d}]`),b(c)})}return this._for(new Nd("of",Z,c,l),()=>b(c))}forIn(I,l,b,Z=this.opts.es5?RG.varKinds.var:RG.varKinds.const){if(this.opts.ownProperties)return this.forOf(I,(0,f._)`Object.keys(${l})`,b);let c=this._scope.toName(I);return this._for(new Nd("in",Z,c,l),()=>b(c))}endFor(){return this._endBlockNode(Ol)}label(I){return this._leafNode(new qm(I))}break(I){return this._leafNode(new fm(I))}return(I){let l=new qZ;if(this._blockNode(l),this.code(I),l.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(qZ)}try(I,l,b){if(!l&&!b)throw new Error('CodeGen: "try" without "catch" and "finally"');let Z=new lY;if(this._blockNode(Z),this.code(I),l){let c=this.name("e");this._currNode=Z.catch=new fZ(c),l(c)}return b&&(this._currNode=Z.finally=new PZ,this.code(b)),this._endBlockNode(fZ,PZ)}throw(I){return this._leafNode(new Pm(I))}block(I,l){return this._blockStarts.push(this._nodes.length),I&&this.code(I).endBlock(l),this}endBlock(I){let l=this._blockStarts.pop();if(l===void 0)throw new Error("CodeGen: not in self-balancing block");let b=this._nodes.length-l;if(b<0||I!==void 0&&b!==I)throw new Error(`CodeGen: wrong number of nodes: ${b} vs ${I} expected`);return this._nodes.length=l,this}func(I,l=f.nil,b,Z){return this._blockNode(new TZ(I,l,b)),Z&&this.code(Z).endFunc(),this}endFunc(){return this._endBlockNode(TZ)}optimize(I=1){for(;I-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(I){return this._currNode.nodes.push(I),this}_blockNode(I){this._currNode.nodes.push(I),this._nodes.push(I)}_endBlockNode(I,l){let b=this._currNode;if(b instanceof I||l&&b instanceof l)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${l?`${I.kind}/${l.kind}`:I.kind}"`)}_elseNode(I){let l=this._currNode;if(!(l instanceof Bl))throw new Error('CodeGen: "else" without "if"');return this._currNode=l.else=I,this}get _root(){return this._nodes[0]}get _currNode(){let I=this._nodes;return I[I.length-1]}set _currNode(I){let l=this._nodes;l[l.length-1]=I}};K.CodeGen=bY;function Ml(G,I){for(let l in I)G[l]=(G[l]||0)+(I[l]||0);return G}function md(G,I){return I instanceof f._CodeOrName?Ml(G,I.names):G}function Jb(G,I,l){if(G instanceof f.Name)return b(G);if(!Z(G))return G;return new f._Code(G._items.reduce((c,W)=>(W instanceof f.Name&&(W=b(W)),W instanceof f._Code?c.push(...W._items):c.push(W),c),[]));function b(c){let W=l[c.str];return W===void 0||I[c.str]!==1?c:(delete I[c.str],W)}function Z(c){return c instanceof f._Code&&c._items.some(W=>W instanceof f.Name&&I[W.str]===1&&l[W.str]!==void 0)}}function We(G,I){for(let l in I)G[l]=(G[l]||0)-(I[l]||0)}function lF(G){return typeof G=="boolean"||typeof G=="number"||G===null?!G:(0,f._)`!${ZY(G)}`}K.not=lF;var de=bF(K.operators.AND);function Ne(...G){return G.reduce(de)}K.and=Ne;var me=bF(K.operators.OR);function Ye(...G){return G.reduce(me)}K.or=Ye;function bF(G){return(I,l)=>I===f.nil?l:l===f.nil?I:(0,f._)`${ZY(I)} ${G} ${ZY(l)}`}function ZY(G){return G instanceof f.Name?G:(0,f._)`(${G})`}});var $=e(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.checkStrictMode=D.getErrorPath=D.Type=D.useFunc=D.setEvaluated=D.evaluatedPropsToName=D.mergeEvaluated=D.eachItem=D.unescapeJsonPointer=D.escapeJsonPointer=D.escapeFragment=D.unescapeFragment=D.schemaRefOrVal=D.schemaHasRulesButRef=D.schemaHasRules=D.checkUnknownRules=D.alwaysValidSchema=D.toHash=void 0;var cI=M(),Ve=DZ();function ae(G){let I={};for(let l of G)I[l]=!0;return I}D.toHash=ae;function he(G,I){return typeof I=="boolean"?I:Object.keys(I).length===0?!0:(WF(G,I),!dF(I,G.self.RULES.all))}D.alwaysValidSchema=he;function WF(G,I=G.schema){let{opts:l,self:b}=G;if(!l.strictSchema||typeof I=="boolean")return;let Z=b.RULES.keywords;for(let c in I)Z[c]||YF(G,`unknown keyword: "${c}"`)}D.checkUnknownRules=WF;function dF(G,I){if(typeof G=="boolean")return!G;for(let l in G)if(I[l])return!0;return!1}D.schemaHasRules=dF;function Re(G,I){if(typeof G=="boolean")return!G;for(let l in G)if(l!=="$ref"&&I.all[l])return!0;return!1}D.schemaHasRulesButRef=Re;function Xe({topSchemaRef:G,schemaPath:I},l,b,Z){if(!Z){if(typeof l=="number"||typeof l=="boolean")return l;if(typeof l=="string")return(0,cI._)`${l}`}return(0,cI._)`${G}${I}${(0,cI.getProperty)(b)}`}D.schemaRefOrVal=Xe;function Fe(G){return NF(decodeURIComponent(G))}D.unescapeFragment=Fe;function Qe(G){return encodeURIComponent(WY(G))}D.escapeFragment=Qe;function WY(G){return typeof G=="number"?`${G}`:G.replace(/~/g,"~0").replace(/\//g,"~1")}D.escapeJsonPointer=WY;function NF(G){return G.replace(/~1/g,"/").replace(/~0/g,"~")}D.unescapeJsonPointer=NF;function He(G,I){if(Array.isArray(G))for(let l of G)I(l);else I(G)}D.eachItem=He;function ZF({mergeNames:G,mergeToName:I,mergeValues:l,resultToName:b}){return(Z,c,W,d)=>{let N=W===void 0?c:W instanceof cI.Name?(c instanceof cI.Name?G(Z,c,W):I(Z,c,W),W):c instanceof cI.Name?(I(Z,W,c),c):l(c,W);return d===cI.Name&&!(N instanceof cI.Name)?b(Z,N):N}}D.mergeEvaluated={props:ZF({mergeNames:(G,I,l)=>G.if((0,cI._)`${l} !== true && ${I} !== undefined`,()=>{G.if((0,cI._)`${I} === true`,()=>G.assign(l,!0),()=>G.assign(l,(0,cI._)`${l} || {}`).code((0,cI._)`Object.assign(${l}, ${I})`))}),mergeToName:(G,I,l)=>G.if((0,cI._)`${l} !== true`,()=>{I===!0?G.assign(l,!0):(G.assign(l,(0,cI._)`${l} || {}`),dY(G,l,I))}),mergeValues:(G,I)=>G===!0?!0:{...G,...I},resultToName:mF}),items:ZF({mergeNames:(G,I,l)=>G.if((0,cI._)`${l} !== true && ${I} !== undefined`,()=>G.assign(l,(0,cI._)`${I} === true ? true : ${l} > ${I} ? ${l} : ${I}`)),mergeToName:(G,I,l)=>G.if((0,cI._)`${l} !== true`,()=>G.assign(l,I===!0?!0:(0,cI._)`${l} > ${I} ? ${l} : ${I}`)),mergeValues:(G,I)=>G===!0?!0:Math.max(G,I),resultToName:(G,I)=>G.var("items",I)})};function mF(G,I){if(I===!0)return G.var("props",!0);let l=G.var("props",(0,cI._)`{}`);return I!==void 0&&dY(G,l,I),l}D.evaluatedPropsToName=mF;function dY(G,I,l){Object.keys(l).forEach(b=>G.assign((0,cI._)`${I}${(0,cI.getProperty)(b)}`,!0))}D.setEvaluated=dY;var cF={};function pe(G,I){return G.scopeValue("func",{ref:I,code:cF[I.code]||(cF[I.code]=new Ve._Code(I.code))})}D.useFunc=pe;var cY;(function(G){G[G.Num=0]="Num",G[G.Str=1]="Str"})(cY||(D.Type=cY={}));function ue(G,I,l){if(G instanceof cI.Name){let b=I===cY.Num;return l?b?(0,cI._)`"[" + ${G} + "]"`:(0,cI._)`"['" + ${G} + "']"`:b?(0,cI._)`"/" + ${G}`:(0,cI._)`"/" + ${G}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return l?(0,cI.getProperty)(G).toString():"/"+WY(G)}D.getErrorPath=ue;function YF(G,I,l=G.opts.strictSchema){if(l){if(I=`strict mode: ${I}`,l===!0)throw new Error(I);G.self.logger.warn(I)}}D.checkStrictMode=YF});var KG=e(NY=>{"use strict";Object.defineProperty(NY,"__esModule",{value:!0});var LI=M(),ne={data:new LI.Name("data"),valCxt:new LI.Name("valCxt"),instancePath:new LI.Name("instancePath"),parentData:new LI.Name("parentData"),parentDataProperty:new LI.Name("parentDataProperty"),rootData:new LI.Name("rootData"),dynamicAnchors:new LI.Name("dynamicAnchors"),vErrors:new LI.Name("vErrors"),errors:new LI.Name("errors"),this:new LI.Name("this"),self:new LI.Name("self"),scope:new LI.Name("scope"),json:new LI.Name("json"),jsonPos:new LI.Name("jsonPos"),jsonLen:new LI.Name("jsonLen"),jsonPart:new LI.Name("jsonPart")};NY.default=ne});var _Z=e(oI=>{"use strict";Object.defineProperty(oI,"__esModule",{value:!0});oI.extendErrors=oI.resetErrorsCount=oI.reportExtraError=oI.reportError=oI.keyword$DataError=oI.keywordError=void 0;var P=M(),Vd=$(),xI=KG();oI.keywordError={message:({keyword:G})=>(0,P.str)`must pass "${G}" keyword validation`};oI.keyword$DataError={message:({keyword:G,schemaType:I})=>I?(0,P.str)`"${G}" keyword must be ${I} ($data)`:(0,P.str)`"${G}" keyword is invalid ($data)`};function we(G,I=oI.keywordError,l,b){let{it:Z}=G,{gen:c,compositeRule:W,allErrors:d}=Z,N=hF(G,I,l);b??(W||d)?VF(c,N):aF(Z,(0,P._)`[${N}]`)}oI.reportError=we;function ve(G,I=oI.keywordError,l){let{it:b}=G,{gen:Z,compositeRule:c,allErrors:W}=b,d=hF(G,I,l);VF(Z,d),c||W||aF(b,xI.default.vErrors)}oI.reportExtraError=ve;function te(G,I){G.assign(xI.default.errors,I),G.if((0,P._)`${xI.default.vErrors} !== null`,()=>G.if(I,()=>G.assign((0,P._)`${xI.default.vErrors}.length`,I),()=>G.assign(xI.default.vErrors,null)))}oI.resetErrorsCount=te;function se({gen:G,keyword:I,schemaValue:l,data:b,errsCount:Z,it:c}){if(Z===void 0)throw new Error("ajv implementation error");let W=G.name("err");G.forRange("i",Z,xI.default.errors,d=>{G.const(W,(0,P._)`${xI.default.vErrors}[${d}]`),G.if((0,P._)`${W}.instancePath === undefined`,()=>G.assign((0,P._)`${W}.instancePath`,(0,P.strConcat)(xI.default.instancePath,c.errorPath))),G.assign((0,P._)`${W}.schemaPath`,(0,P.str)`${c.errSchemaPath}/${I}`),c.opts.verbose&&(G.assign((0,P._)`${W}.schema`,l),G.assign((0,P._)`${W}.data`,b))})}oI.extendErrors=se;function VF(G,I){let l=G.const("err",I);G.if((0,P._)`${xI.default.vErrors} === null`,()=>G.assign(xI.default.vErrors,(0,P._)`[${l}]`),(0,P._)`${xI.default.vErrors}.push(${l})`),G.code((0,P._)`${xI.default.errors}++`)}function aF(G,I){let{gen:l,validateName:b,schemaEnv:Z}=G;Z.$async?l.throw((0,P._)`new ${G.ValidationError}(${I})`):(l.assign((0,P._)`${b}.errors`,I),l.return(!1))}var jl={keyword:new P.Name("keyword"),schemaPath:new P.Name("schemaPath"),params:new P.Name("params"),propertyName:new P.Name("propertyName"),message:new P.Name("message"),schema:new P.Name("schema"),parentSchema:new P.Name("parentSchema")};function hF(G,I,l){let{createErrors:b}=G.it;return b===!1?(0,P._)`{}`:ee(G,I,l)}function ee(G,I,l={}){let{gen:b,it:Z}=G,c=[Je(Z,l),Ee(G,l)];return ye(G,I,c),b.object(...c)}function Je({errorPath:G},{instancePath:I}){let l=I?(0,P.str)`${G}${(0,Vd.getErrorPath)(I,Vd.Type.Str)}`:G;return[xI.default.instancePath,(0,P.strConcat)(xI.default.instancePath,l)]}function Ee({keyword:G,it:{errSchemaPath:I}},{schemaPath:l,parentSchema:b}){let Z=b?I:(0,P.str)`${I}/${G}`;return l&&(Z=(0,P.str)`${Z}${(0,Vd.getErrorPath)(l,Vd.Type.Str)}`),[jl.schemaPath,Z]}function ye(G,{params:I,message:l},b){let{keyword:Z,data:c,schemaValue:W,it:d}=G,{opts:N,propertyName:m,topSchemaRef:Y,schemaPath:V}=d;b.push([jl.keyword,Z],[jl.params,typeof I=="function"?I(G):I||(0,P._)`{}`]),N.messages&&b.push([jl.message,typeof l=="function"?l(G):l]),N.verbose&&b.push([jl.schema,W],[jl.parentSchema,(0,P._)`${Y}${V}`],[xI.default.data,c]),m&&b.push([jl.propertyName,m])}});var XF=e(Eb=>{"use strict";Object.defineProperty(Eb,"__esModule",{value:!0});Eb.boolOrEmptySchema=Eb.topBoolOrEmptySchema=void 0;var Ce=_Z(),ge=M(),Ae=KG(),Le={message:"boolean schema is false"};function oe(G){let{gen:I,schema:l,validateName:b}=G;l===!1?RF(G,!1):typeof l=="object"&&l.$async===!0?I.return(Ae.default.data):(I.assign((0,ge._)`${b}.errors`,null),I.return(!0))}Eb.topBoolOrEmptySchema=oe;function ke(G,I){let{gen:l,schema:b}=G;b===!1?(l.var(I,!1),RF(G)):l.var(I,!0)}Eb.boolOrEmptySchema=ke;function RF(G,I){let{gen:l,data:b}=G,Z={gen:l,keyword:"false schema",data:b,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:G};(0,Ce.reportError)(Z,Le,void 0,I)}});var mY=e(yb=>{"use strict";Object.defineProperty(yb,"__esModule",{value:!0});yb.getRules=yb.isJSONType=void 0;var ie=["string","number","integer","boolean","null","object","array"],ze=new Set(ie);function re(G){return typeof G=="string"&&ze.has(G)}yb.isJSONType=re;function xe(){let G={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...G,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},G.number,G.string,G.array,G.object],post:{rules:[]},all:{},keywords:{}}}yb.getRules=xe});var YY=e(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.shouldUseRule=Nl.shouldUseGroup=Nl.schemaHasRulesForType=void 0;function Ue({schema:G,self:I},l){let b=I.RULES.types[l];return b&&b!==!0&&FF(G,b)}Nl.schemaHasRulesForType=Ue;function FF(G,I){return I.rules.some(l=>QF(G,l))}Nl.shouldUseGroup=FF;function QF(G,I){var l;return G[I.keyword]!==void 0||((l=I.definition.implements)===null||l===void 0?void 0:l.some(b=>G[b]!==void 0))}Nl.shouldUseRule=QF});var $Z=e(kI=>{"use strict";Object.defineProperty(kI,"__esModule",{value:!0});kI.reportTypeError=kI.checkDataTypes=kI.checkDataType=kI.coerceAndCheckDataType=kI.getJSONTypes=kI.getSchemaTypes=kI.DataType=void 0;var Be=mY(),Oe=YY(),Me=_Z(),U=M(),HF=$(),Cb;(function(G){G[G.Correct=0]="Correct",G[G.Wrong=1]="Wrong"})(Cb||(kI.DataType=Cb={}));function je(G){let I=pF(G.type);if(I.includes("null")){if(G.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!I.length&&G.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');G.nullable===!0&&I.push("null")}return I}kI.getSchemaTypes=je;function pF(G){let I=Array.isArray(G)?G:G?[G]:[];if(I.every(Be.isJSONType))return I;throw new Error("type must be JSONType or JSONType[]: "+I.join(","))}kI.getJSONTypes=pF;function Ke(G,I){let{gen:l,data:b,opts:Z}=G,c=De(I,Z.coerceTypes),W=I.length>0&&!(c.length===0&&I.length===1&&(0,Oe.schemaHasRulesForType)(G,I[0]));if(W){let d=aY(I,b,Z.strictNumbers,Cb.Wrong);l.if(d,()=>{c.length?Se(G,I,c):hY(G)})}return W}kI.coerceAndCheckDataType=Ke;var uF=new Set(["string","number","integer","boolean","null"]);function De(G,I){return I?G.filter(l=>uF.has(l)||I==="array"&&l==="array"):[]}function Se(G,I,l){let{gen:b,data:Z,opts:c}=G,W=b.let("dataType",(0,U._)`typeof ${Z}`),d=b.let("coerced",(0,U._)`undefined`);c.coerceTypes==="array"&&b.if((0,U._)`${W} == 'object' && Array.isArray(${Z}) && ${Z}.length == 1`,()=>b.assign(Z,(0,U._)`${Z}[0]`).assign(W,(0,U._)`typeof ${Z}`).if(aY(I,Z,c.strictNumbers),()=>b.assign(d,Z))),b.if((0,U._)`${d} !== undefined`);for(let m of l)(uF.has(m)||m==="array"&&c.coerceTypes==="array")&&N(m);b.else(),hY(G),b.endIf(),b.if((0,U._)`${d} !== undefined`,()=>{b.assign(Z,d),Te(G,d)});function N(m){switch(m){case"string":b.elseIf((0,U._)`${W} == "number" || ${W} == "boolean"`).assign(d,(0,U._)`"" + ${Z}`).elseIf((0,U._)`${Z} === null`).assign(d,(0,U._)`""`);return;case"number":b.elseIf((0,U._)`${W} == "boolean" || ${Z} === null
|
|
5
5
|
|| (${W} == "string" && ${Z} && ${Z} == +${Z})`).assign(d,(0,U._)`+${Z}`);return;case"integer":b.elseIf((0,U._)`${W} === "boolean" || ${Z} === null
|
|
6
6
|
|| (${W} === "string" && ${Z} && ${Z} == +${Z} && !(${Z} % 1))`).assign(d,(0,U._)`+${Z}`);return;case"boolean":b.elseIf((0,U._)`${Z} === "false" || ${Z} === 0 || ${Z} === null`).assign(d,!1).elseIf((0,U._)`${Z} === "true" || ${Z} === 1`).assign(d,!0);return;case"null":b.elseIf((0,U._)`${Z} === "" || ${Z} === 0 || ${Z} === false`),b.assign(d,null);return;case"array":b.elseIf((0,U._)`${W} === "string" || ${W} === "number"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agestra",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.5",
|
|
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",
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
"packages/*"
|
|
9
9
|
],
|
|
10
10
|
"main": "dist/bundle.js",
|
|
11
|
-
"bin": {
|
|
12
|
-
"agestra": "dist/bundle.js"
|
|
13
|
-
|
|
11
|
+
"bin": {
|
|
12
|
+
"agestra": "dist/bundle.js",
|
|
13
|
+
"agestra-install": "scripts/install-host-mcp.mjs",
|
|
14
|
+
"agestra-uninstall": "scripts/uninstall-host-mcp.mjs"
|
|
15
|
+
},
|
|
14
16
|
"files": [
|
|
15
17
|
"dist/bundle.js",
|
|
16
18
|
"dist/sql-wasm.cjs",
|
|
@@ -35,11 +37,13 @@
|
|
|
35
37
|
"lint": "turbo lint",
|
|
36
38
|
"clean": "turbo clean",
|
|
37
39
|
"prebundle": "npm run sync:metadata",
|
|
38
|
-
"bundle": "node scripts/bundle.mjs",
|
|
39
|
-
"install:codex": "node scripts/install-host-mcp.mjs codex",
|
|
40
|
-
"install:
|
|
41
|
-
"
|
|
42
|
-
"
|
|
40
|
+
"bundle": "node scripts/bundle.mjs",
|
|
41
|
+
"install:codex": "node scripts/install-host-mcp.mjs codex",
|
|
42
|
+
"install:codex:global": "node scripts/install-host-mcp.mjs codex --source global",
|
|
43
|
+
"install:gemini": "node scripts/install-host-mcp.mjs gemini",
|
|
44
|
+
"install:gemini:global": "node scripts/install-host-mcp.mjs gemini --source global",
|
|
45
|
+
"uninstall:codex": "node scripts/uninstall-host-mcp.mjs codex",
|
|
46
|
+
"uninstall:gemini": "node scripts/uninstall-host-mcp.mjs gemini",
|
|
43
47
|
"prepublishOnly": "npm run build && npm run bundle"
|
|
44
48
|
},
|
|
45
49
|
"keywords": [
|
|
@@ -6,8 +6,9 @@ import { spawnSync } from "node:child_process";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
8
|
const USAGE = `Usage: node scripts/install-host-mcp.mjs <codex|gemini|all> [--scope project|user] [--trust]
|
|
9
|
+
node scripts/install-host-mcp.mjs <codex|gemini|all> [--source local|global] [--scope project|user] [--trust]
|
|
9
10
|
|
|
10
|
-
Registers the local Agestra MCP bundle with the selected host CLI.
|
|
11
|
+
Registers the local or globally installed Agestra MCP bundle with the selected host CLI.
|
|
11
12
|
`;
|
|
12
13
|
|
|
13
14
|
function fail(message) {
|
|
@@ -24,6 +25,7 @@ function parseArgs(argv) {
|
|
|
24
25
|
const args = [...argv];
|
|
25
26
|
const target = args.shift();
|
|
26
27
|
let scope = "project";
|
|
28
|
+
let source = "local";
|
|
27
29
|
let trust = false;
|
|
28
30
|
|
|
29
31
|
while (args.length > 0) {
|
|
@@ -42,6 +44,15 @@ function parseArgs(argv) {
|
|
|
42
44
|
continue;
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
if (current === "--source") {
|
|
48
|
+
const value = args.shift();
|
|
49
|
+
if (value !== "local" && value !== "global") {
|
|
50
|
+
fail("`--source` must be `local` or `global`.");
|
|
51
|
+
}
|
|
52
|
+
source = value;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
45
56
|
fail(`Unknown argument: ${current}`);
|
|
46
57
|
}
|
|
47
58
|
|
|
@@ -49,13 +60,38 @@ function parseArgs(argv) {
|
|
|
49
60
|
fail(USAGE);
|
|
50
61
|
}
|
|
51
62
|
|
|
52
|
-
return { target, scope, trust };
|
|
63
|
+
return { target, scope, source, trust };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function quoteShellArg(value) {
|
|
67
|
+
if (process.platform === "win32") {
|
|
68
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function spawnCommand(command, args, options = {}) {
|
|
75
|
+
if (process.platform !== "win32") {
|
|
76
|
+
return spawnSync(command, args, {
|
|
77
|
+
shell: false,
|
|
78
|
+
...options,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const commandLine = [command, ...args]
|
|
83
|
+
.map((value, index) => (index === 0 ? String(value) : quoteShellArg(String(value))))
|
|
84
|
+
.join(" ");
|
|
85
|
+
|
|
86
|
+
return spawnSync(commandLine, {
|
|
87
|
+
shell: true,
|
|
88
|
+
...options,
|
|
89
|
+
});
|
|
53
90
|
}
|
|
54
91
|
|
|
55
92
|
function runCommand(command, args, options = {}) {
|
|
56
|
-
const result =
|
|
93
|
+
const result = spawnCommand(command, args, {
|
|
57
94
|
stdio: "inherit",
|
|
58
|
-
shell: false,
|
|
59
95
|
...options,
|
|
60
96
|
});
|
|
61
97
|
|
|
@@ -69,9 +105,8 @@ function runCommand(command, args, options = {}) {
|
|
|
69
105
|
}
|
|
70
106
|
|
|
71
107
|
function commandSucceeds(command, args) {
|
|
72
|
-
const result =
|
|
108
|
+
const result = spawnCommand(command, args, {
|
|
73
109
|
stdio: "ignore",
|
|
74
|
-
shell: false,
|
|
75
110
|
});
|
|
76
111
|
|
|
77
112
|
if (result.error) {
|
|
@@ -92,16 +127,60 @@ function resolveBundlePath() {
|
|
|
92
127
|
return bundlePath;
|
|
93
128
|
}
|
|
94
129
|
|
|
95
|
-
function
|
|
130
|
+
function resolveGlobalBundlePath() {
|
|
131
|
+
const result = spawnCommand("npm", ["root", "-g"], {
|
|
132
|
+
encoding: "utf8",
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (result.error) {
|
|
136
|
+
fail(`Failed to resolve the global npm root: ${result.error.message}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
140
|
+
fail("Failed to resolve the global npm root. Run `npm install -g agestra` first.");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const globalRoot = result.stdout?.trim();
|
|
144
|
+
if (!globalRoot) {
|
|
145
|
+
fail("Failed to resolve the global npm root. Run `npm install -g agestra` first.");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const bundlePath = path.join(globalRoot, "agestra", "dist", "bundle.js");
|
|
149
|
+
if (!fs.existsSync(bundlePath)) {
|
|
150
|
+
fail(`Could not find ${bundlePath}. Run \`npm install -g agestra\` first.`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return bundlePath;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function resolveServerEntry(source) {
|
|
157
|
+
const bundlePath = source === "global" ? resolveGlobalBundlePath() : resolveBundlePath();
|
|
158
|
+
return {
|
|
159
|
+
bundlePath,
|
|
160
|
+
command: process.execPath,
|
|
161
|
+
args: [bundlePath],
|
|
162
|
+
source,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function installCodex(serverEntry) {
|
|
96
167
|
if (commandSucceeds("codex", ["mcp", "get", "agestra", "--json"])) {
|
|
97
168
|
runCommand("codex", ["mcp", "remove", "agestra"]);
|
|
98
169
|
}
|
|
99
170
|
|
|
100
|
-
runCommand("codex", ["mcp", "add", "agestra", "--",
|
|
101
|
-
|
|
171
|
+
runCommand("codex", ["mcp", "add", "agestra", "--", serverEntry.command, ...serverEntry.args]);
|
|
172
|
+
|
|
173
|
+
if (serverEntry.source === "global") {
|
|
174
|
+
console.log("Agestra is now registered with Codex using the globally installed npm package.");
|
|
175
|
+
console.log("Open your target repo in Codex. If that repo has an AGENTS.md file, Codex will use it automatically.");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
console.log("Agestra is now registered with Codex using the local repository bundle.");
|
|
180
|
+
console.log("Open this repo and Codex will pick up AGENTS.md automatically.");
|
|
102
181
|
}
|
|
103
182
|
|
|
104
|
-
function installGemini(
|
|
183
|
+
function installGemini(serverEntry, scope, trust) {
|
|
105
184
|
if (commandSucceeds("gemini", ["mcp", "remove", "agestra", "--scope", scope])) {
|
|
106
185
|
console.log(`Removed existing Gemini MCP registration for scope \`${scope}\`.`);
|
|
107
186
|
}
|
|
@@ -110,8 +189,8 @@ function installGemini(bundlePath, scope, trust) {
|
|
|
110
189
|
"mcp",
|
|
111
190
|
"add",
|
|
112
191
|
"agestra",
|
|
113
|
-
|
|
114
|
-
|
|
192
|
+
serverEntry.command,
|
|
193
|
+
...serverEntry.args,
|
|
115
194
|
"--scope",
|
|
116
195
|
scope,
|
|
117
196
|
"--description",
|
|
@@ -123,16 +202,24 @@ function installGemini(bundlePath, scope, trust) {
|
|
|
123
202
|
}
|
|
124
203
|
|
|
125
204
|
runCommand("gemini", args);
|
|
126
|
-
|
|
205
|
+
|
|
206
|
+
if (serverEntry.source === "global") {
|
|
207
|
+
console.log("Agestra is now registered with Gemini using the globally installed npm package.");
|
|
208
|
+
console.log("Open your target repo in Gemini. If that repo has GEMINI.md or .gemini commands, Gemini will load them.");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
console.log("Agestra is now registered with Gemini using the local repository bundle.");
|
|
213
|
+
console.log("Open this repo and Gemini will load GEMINI.md plus /agestra:* project commands.");
|
|
127
214
|
}
|
|
128
215
|
|
|
129
|
-
const { target, scope, trust } = parseArgs(process.argv.slice(2));
|
|
130
|
-
const
|
|
216
|
+
const { target, scope, source, trust } = parseArgs(process.argv.slice(2));
|
|
217
|
+
const serverEntry = resolveServerEntry(source);
|
|
131
218
|
|
|
132
219
|
if (target === "codex" || target === "all") {
|
|
133
|
-
installCodex(
|
|
220
|
+
installCodex(serverEntry);
|
|
134
221
|
}
|
|
135
222
|
|
|
136
223
|
if (target === "gemini" || target === "all") {
|
|
137
|
-
installGemini(
|
|
224
|
+
installGemini(serverEntry, scope, trust);
|
|
138
225
|
}
|
|
@@ -12,6 +12,32 @@ function fail(message) {
|
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function quoteShellArg(value) {
|
|
16
|
+
if (process.platform === "win32") {
|
|
17
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function spawnCommand(command, args, options = {}) {
|
|
24
|
+
if (process.platform !== "win32") {
|
|
25
|
+
return spawnSync(command, args, {
|
|
26
|
+
shell: false,
|
|
27
|
+
...options,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const commandLine = [command, ...args]
|
|
32
|
+
.map((value, index) => (index === 0 ? String(value) : quoteShellArg(String(value))))
|
|
33
|
+
.join(" ");
|
|
34
|
+
|
|
35
|
+
return spawnSync(commandLine, {
|
|
36
|
+
shell: true,
|
|
37
|
+
...options,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
15
41
|
function parseArgs(argv) {
|
|
16
42
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
17
43
|
console.log(USAGE);
|
|
@@ -44,9 +70,8 @@ function parseArgs(argv) {
|
|
|
44
70
|
}
|
|
45
71
|
|
|
46
72
|
function runCommand(command, args) {
|
|
47
|
-
const result =
|
|
73
|
+
const result = spawnCommand(command, args, {
|
|
48
74
|
stdio: "inherit",
|
|
49
|
-
shell: false,
|
|
50
75
|
});
|
|
51
76
|
|
|
52
77
|
if (result.error) {
|
|
@@ -59,9 +84,8 @@ function runCommand(command, args) {
|
|
|
59
84
|
}
|
|
60
85
|
|
|
61
86
|
function commandSucceeds(command, args) {
|
|
62
|
-
const result =
|
|
87
|
+
const result = spawnCommand(command, args, {
|
|
63
88
|
stdio: "ignore",
|
|
64
|
-
shell: false,
|
|
65
89
|
});
|
|
66
90
|
|
|
67
91
|
if (result.error) {
|