agentica 0.20.0 → 0.22.0

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.
Files changed (3) hide show
  1. package/README.md +141 -42
  2. package/dist/index.mjs +2 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,66 +1,165 @@
1
- # Agentica CLI Tool
1
+ # Agentica, AI Function Calling Framework
2
2
 
3
- ```bash
4
- npx agentica start <directory>
5
- npx agentica backend <directory>
6
- npx agentica client <directory>
7
- ```
3
+ <!-- https://github.com/user-attachments/assets/5326cc59-5129-470d-abcb-c3f458b5c488 -->
8
4
 
9
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wrtnlabs/agentica/blob/master/LICENSE)
10
- [![npm version](https://img.shields.io/npm/v/agentica.svg)](https://www.npmjs.com/package/agentica)
11
- [![Downloads](https://img.shields.io/npm/dm/agentica.svg)](https://www.npmjs.com/package/agentica)
5
+ ![Logo](https://wrtnlabs.io/agentica/og.jpg?refresh)
6
+
7
+ [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wrtnlabs/agentica/blob/master/LICENSE)
8
+ [![NPM Version](https://img.shields.io/npm/v/@agentica/core.svg)](https://www.npmjs.com/package/@agentica/core)
9
+ [![NPM Downloads](https://img.shields.io/npm/dm/@agentica/core.svg)](https://www.npmjs.com/package/@agentica/core)
12
10
  [![Build Status](https://github.com/wrtnlabs/agentica/workflows/build/badge.svg)](https://github.com/wrtnlabs/agentica/actions?query=workflow%3Abuild)
11
+ [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://wrtnlabs.io/agentica/)
12
+ [![Discord Badge](https://dcbadge.limes.pink/api/server/https://discord.gg/aMhRmzkqCx?style=flat)](https://discord.gg/aMhRmzkqCx)
13
+
14
+ Agentic AI framework specialized in AI Function Calling.
13
15
 
14
- Agentica CLI Tool cloning boilerplate project.
16
+ Don't be afraid of AI agent development. Just list functions from three protocols below. This is everything you should do for AI agent development.
15
17
 
16
- - `start`: a frontend application creating agent in browser
17
- - `backend`: backend application serving the agent through websocket protocol
18
- - `client`: frontend application connecting to above websocket server
18
+ - TypeScript Class
19
+ - Swagger/OpenAPI Document
20
+ - MCP (Model Context Protocol) Server
19
21
 
20
- ## Introduction
22
+ Wanna make an e-commerce agent? Bring in e-commerce functions. Need a newspaper agent? Get API functions from the newspaper company. Just prepare any functions that you need, then it becomes an AI agent.
21
23
 
22
- ![agentica-conceptual-diagram](https://github.com/user-attachments/assets/d7ebbd1f-04d3-4b0d-9e2a-234e29dd6c57)
24
+ Are you a TypeScript developer? Then you're already an AI developer. Familiar with backend development? You're already well-versed in AI development. Anyone who can make functions can make AI agents.
25
+
26
+ <!-- eslint-skip -->
23
27
 
24
28
  ```typescript
25
- import { Agentica } from "@agentica/core";
29
+ import { Agentica, assertHttpLlmApplication } from "@agentica/core";
30
+ import OpenAI from "openai";
26
31
  import typia from "typia";
27
32
 
33
+ import { MobileFileSystem } from "./services/MobileFileSystem";
34
+
28
35
  const agent = new Agentica({
36
+ vendor: {
37
+ api: new OpenAI({ apiKey: "********" }),
38
+ model: "gpt-4o-mini",
39
+ },
29
40
  controllers: [
30
- await fetch(
31
- "https://shopping-be.wrtn.ai/editor/swagger.json",
32
- ).then(r => r.json()),
33
- typia.llm.application<ShoppingCounselor>(),
34
- typia.llm.application<ShoppingPolicy>(),
35
- typia.llm.application<ShoppingSearchRag>(),
41
+ // functions from TypeScript class
42
+ {
43
+ protocol: "http",
44
+ application: typia.llm.application<MobileFileSystem, "chatgpt">(),
45
+ execute: new MobileFileSystem(),
46
+ },
47
+ // functions from Swagger/OpenAPI
48
+ {
49
+ protocol: "http",
50
+ application: assertHttpLlmApplication({
51
+ model: "chatgpt",
52
+ document: await fetch(
53
+ "https://shopping-be.wrtn.ai/editor/swagger.json",
54
+ ).then(r => r.json()),
55
+ }),
56
+ connection: {
57
+ host: "https://shopping-be.wrtn.ai",
58
+ headers: { Authorization: "Bearer ********" },
59
+ },
60
+ },
36
61
  ],
37
62
  });
38
63
  await agent.conversate("I wanna buy MacBook Pro");
39
64
  ```
40
65
 
41
- The simplest **Agentic AI** library, specialized in **LLM Function Calling**.
66
+ ## 📦 Setup
42
67
 
43
- Don't compose complicate agent graph or workflow, but just deliver **Swagger/OpenAPI** documents or **TypeScript class** types linearly to the `@agentica`. Then `@agentica` will do everything with the function calling.
68
+ ```bash
69
+ $ npx agentica start <directory>
44
70
 
45
- Look at the below demonstration, and feel how `@agentica` is easy and powerful.
71
+ ----------------------------------------
72
+ Agentica Setup Wizard
73
+ ----------------------------------------
74
+ ? Package Manager (use arrow keys)
75
+ > npm
76
+ pnpm
77
+ yarn (berry is not supported)
78
+ ? Project Type
79
+ NodeJS Agent Server
80
+ > NestJS Agent Server
81
+ React Client Application
82
+ Standalone Application
83
+ ? Embedded Controllers (multi-selectable)
84
+ (none)
85
+ Google Calendar
86
+ Google News
87
+ > Github
88
+ Reddit
89
+ Slack
90
+ ...
91
+ ```
46
92
 
47
- ```typescript
48
- import { Agentica } from "@agentica/core";
49
- import typia from "typia";
93
+ The setup wizard helps you create a new project tailored to your needs.
50
94
 
51
- const agent = new Agentica({
52
- controllers: [
53
- await fetch(
54
- "https://shopping-be.wrtn.ai/editor/swagger.json",
55
- ).then(r => r.json()),
56
- typia.llm.application<ShoppingCounselor>(),
57
- typia.llm.application<ShoppingPolicy>(),
58
- typia.llm.application<ShoppingSearchRag>(),
59
- ],
60
- });
61
- await agent.conversate("I wanna buy MacBook Pro");
95
+ For reference, when selecting a project type, any option other than "Standalone Application" will implement the [WebSocket Protocol](https://wrtnlabs.io/agentica/docs/websocket/) for client-server communication.
96
+
97
+ For comprehensive setup instructions, visit our [Getting Started](https://wrtnlabs.io/agentica/docs/) guide.
98
+
99
+ ## 💻 Playground
100
+
101
+ Experience Agentica firsthand through our [interactive playground](https://wrtnlabs.io/agentica/playground) before installing.
102
+
103
+ Our demonstrations showcase the power and simplicity of Agentica's function calling capabilities across different integration methods.
104
+
105
+ - [TypeScript Class](https://wrtnlabs.io/agentica/playground/bbs)
106
+ - [Swagger/OpenAPI Document](https://wrtnlabs.io/agentica/playground/swagger)
107
+ - [Enterprise E-commerce Agent](https://wrtnlabs.io/agentica/playground/shopping)
108
+
109
+ <!--
110
+ @todo this section would be changed after making tutorial playground
111
+ -->
112
+
113
+ ## 📚 Documentation Resources
114
+
115
+ Find comprehensive resources at our [official website](https://wrtnlabs.io/agentica).
116
+
117
+ - [Home](https://wrtnlabs.io/agentica)
118
+ - [Guide Documents](https://wrtnlabs.io/agentica/docs)
119
+ - [Tutorial](https://wrtnlabs.io/agentica/tutorial)
120
+ - [API Documents](https://wrtnlabs.io/agentica/api)
121
+ - [Youtube](https://www.youtube.com/@wrtnlabs)
122
+ - [Paper](https://wrtnlabs.io/agentica/paper)
123
+
124
+ ## 🌟 Why Agentica?
125
+
126
+ ```mermaid
127
+ flowchart
128
+ subgraph "JSON Schema Specification"
129
+ schemav4("JSON Schema v4 ~ v7") --upgrades--> emended[["OpenAPI v3.1 (emended)"]]
130
+ schema2910("JSON Schema 2019-03") --upgrades--> emended
131
+ schema2020("JSON Schema 2020-12") --emends--> emended
132
+ end
133
+ subgraph "Agentica"
134
+ emended --"Artificial Intelligence"--> fc{{"AI Function Calling"}}
135
+ fc --"OpenAI"--> chatgpt("ChatGPT")
136
+ fc --"Google"--> gemini("Gemini")
137
+ fc --"Anthropic"--> claude("Claude")
138
+ fc --"High-Flyer"--> deepseek("DeepSeek")
139
+ fc --"Meta"--> llama("Llama")
140
+ chatgpt --"3.1"--> custom(["Custom JSON Schema"])
141
+ gemini --"3.0"--> custom(["Custom JSON Schema"])
142
+ claude --"3.1"--> standard(["Standard JSON Schema"])
143
+ deepseek --"3.1"--> standard
144
+ llama --"3.1"--> standard
145
+ end
62
146
  ```
63
147
 
64
- > https://github.com/user-attachments/assets/01604b53-aca4-41cb-91aa-3faf63549ea6
65
- >
66
- > Demonstration video of Shopping AI Chatbot
148
+ Agentica enhances AI function calling by the following strategies:
149
+
150
+ - [**Compiler Driven Development**](https://wrtnlabs.io/agentica/docs/concepts/compiler-driven-development): constructs function calling schema automatically by compiler skills without hand-writing.
151
+ - [**JSON Schema Conversion**](https://wrtnlabs.io/agentica/docs/core/vendor/#schema-specification): automatically handles specification differences between LLM vendors, ensuring seamless integration regardless of your chosen AI model.
152
+ - [**Validation Feedback**](https://wrtnlabs.io/agentica/docs/concepts/function-calling#validation-feedback): detects and corrects AI mistakes in argument composition, dramatically reducing errors and improving reliability.
153
+ - [**Selector Agent**](https://wrtnlabs.io/agentica/docs/concepts/function-calling#orchestration-strategy): filtering candidate functions to minimize context usage, optimize performance, and reduce token consumption.
154
+
155
+ Thanks to these innovations, Agentica makes AI function calling easier, safer, and more accurate than before. Development becomes more intuitive since you only need to prepare functions relevant to your specific use case, and scaling your agent's capabilities is as simple as adding or removing functions.
156
+
157
+ In 2023, when OpenAI announced function calling, many predicted that function calling-driven AI development would become the mainstream. However, in reality, due to the difficulty and instability of function calling, the trend in AI development became agent workflow. Agent workflow, which is inflexible and must be created for specific purposes, has conquered the AI agent ecosystem.
158
+ By the way, as Agentica has resolved the difficulty and instability problems of function calling, the time has come to embrace function-driven AI development once again.
159
+
160
+ | Type | Workflow | Vanilla Function Calling | Agentica Function Calling |
161
+ | ----------- | ------------- | ------------------------ | ------------------------- |
162
+ | Purpose | ❌ Specific | 🟢 General | 🟢 General |
163
+ | Difficulty | ❌ Difficult | ❌ Difficult | 🟢 Easy |
164
+ | Stability | 🟢 Stable | ❌ Unstable | 🟢 Stable |
165
+ | Flexibility | ❌ Inflexible | 🟢 Flexible | 🟢 Flexible |
package/dist/index.mjs CHANGED
@@ -87,10 +87,10 @@ execute: new ${s}Service(),
87
87
  `,y=Buffer.byteLength(E);let m=Math.floor(Math.log(y)/Math.log(10))+1;return y+m>=Math.pow(10,m)&&(m+=1),m+y+E}}s.parse=(e,o,h)=>new s(r(i(e),o),h);const r=(e,o)=>o?Object.keys(e).reduce((h,E)=>(h[E]=e[E],h),o):e,i=e=>e.replace(/\n$/,"").split(`
88
88
  `).reduce(a,Object.create(null)),a=(e,o)=>{const h=parseInt(o,10);if(h!==Buffer.byteLength(o)+1)return e;o=o.slice((h+" ").length);const E=o.split("="),y=E.shift().replace(/^SCHILY\.(dev|ino|nlink)/,"$1");if(!y)return e;const m=E.join("=");return e[y]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(y)?new Date(m*1e3):/^[0-9]+$/.test(m)?+m:m,e};return Gt=s,Gt}var Vt,xs;function Pe(){return xs||(xs=1,Vt=u=>{let t=u.length-1,s=-1;for(;t>-1&&u.charAt(t)==="/";)s=t,t--;return s===-1?u:u.slice(0,s)}),Vt}var Wt,Ts;function Kt(){return Ts||(Ts=1,Wt=u=>class extends u{warn(t,s,r={}){this.file&&(r.file=this.file),this.cwd&&(r.cwd=this.cwd),r.code=s instanceof Error&&s.code||t,r.tarCode=t,!this.strict&&r.recoverable!==!1?(s instanceof Error&&(r=Object.assign(s,r),s=s.message),this.emit("warn",r.tarCode,s,r)):s instanceof Error?this.emit("error",Object.assign(s,r)):this.emit("error",Object.assign(new Error(`${t}: ${s}`),r))}}),Wt}var Yt,$s;function Ns(){if($s)return Yt;$s=1;const u=["|","<",">","?",":"],t=u.map(i=>String.fromCharCode(61440+i.charCodeAt(0))),s=new Map(u.map((i,a)=>[i,t[a]])),r=new Map(t.map((i,a)=>[i,u[a]]));return Yt={encode:i=>u.reduce((a,e)=>a.split(e).join(s.get(e)),i),decode:i=>t.reduce((a,e)=>a.split(e).join(r.get(e)),i)},Yt}var Zt,Is;function Ls(){if(Is)return Zt;Is=1;const{isAbsolute:u,parse:t}=De.win32;return Zt=s=>{let r="",i=t(s);for(;u(s)||i.root;){const a=s.charAt(0)==="/"&&s.slice(0,4)!=="//?/"?"/":i.root;s=s.slice(a.length),r+=a,i=t(s)}return[r,s]},Zt}var Xt,Ms;function kn(){return Ms||(Ms=1,Xt=(u,t,s)=>(u&=4095,s&&(u=(u|384)&-19),t&&(u&256&&(u|=64),u&32&&(u|=8),u&4&&(u|=1)),u)),Xt}var Jt,Ps;function ks(){if(Ps)return Jt;Ps=1;const{Minipass:u}=It(),t=qt(),s=Me(),r=ge,i=De,a=Le(),e=Pe(),o=(w,c)=>c?(w=a(w).replace(/^\.(\/|$)/,""),e(c)+"/"+w):a(w),h=16*1024*1024,E=Symbol("process"),y=Symbol("file"),m=Symbol("directory"),C=Symbol("symlink"),_=Symbol("hardlink"),b=Symbol("header"),A=Symbol("read"),S=Symbol("lstat"),v=Symbol("onlstat"),n=Symbol("onread"),l=Symbol("onreadlink"),f=Symbol("openfile"),d=Symbol("onopenfile"),D=Symbol("close"),F=Symbol("mode"),R=Symbol("awaitDrain"),B=Symbol("ondrain"),x=Symbol("prefix"),M=Symbol("hadError"),P=Kt(),U=Ns(),G=Ls(),Y=kn(),N=P(class extends u{constructor(c,g){if(g=g||{},super(g),typeof c!="string")throw new TypeError("path is required");this.path=a(c),this.portable=!!g.portable,this.myuid=process.getuid&&process.getuid()||0,this.myuser=process.env.USER||"",this.maxReadSize=g.maxReadSize||h,this.linkCache=g.linkCache||new Map,this.statCache=g.statCache||new Map,this.preservePaths=!!g.preservePaths,this.cwd=a(g.cwd||process.cwd()),this.strict=!!g.strict,this.noPax=!!g.noPax,this.noMtime=!!g.noMtime,this.mtime=g.mtime||null,this.prefix=g.prefix?a(g.prefix):null,this.fd=null,this.blockLen=null,this.blockRemain=null,this.buf=null,this.offset=null,this.length=null,this.pos=null,this.remain=null,typeof g.onwarn=="function"&&this.on("warn",g.onwarn);let L=!1;if(!this.preservePaths){const[H,J]=G(this.path);H&&(this.path=J,L=H)}this.win32=!!g.win32||process.platform==="win32",this.win32&&(this.path=U.decode(this.path.replace(/\\/g,"/")),c=c.replace(/\\/g,"/")),this.absolute=a(g.absolute||i.resolve(this.cwd,c)),this.path===""&&(this.path="./"),L&&this.warn("TAR_ENTRY_INFO",`stripping ${L} from absolute path`,{entry:this,path:L+this.path}),this.statCache.has(this.absolute)?this[v](this.statCache.get(this.absolute)):this[S]()}emit(c,...g){return c==="error"&&(this[M]=!0),super.emit(c,...g)}[S](){r.lstat(this.absolute,(c,g)=>{if(c)return this.emit("error",c);this[v](g)})}[v](c){this.statCache.set(this.absolute,c),this.stat=c,c.isFile()||(c.size=0),this.type=ee(c),this.emit("stat",c),this[E]()}[E](){switch(this.type){case"File":return this[y]();case"Directory":return this[m]();case"SymbolicLink":return this[C]();default:return this.end()}}[F](c){return Y(c,this.type==="Directory",this.portable)}[x](c){return o(c,this.prefix)}[b](){this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.header=new s({path:this[x](this.path),linkpath:this.type==="Link"?this[x](this.linkpath):this.linkpath,mode:this[F](this.stat.mode),uid:this.portable?null:this.stat.uid,gid:this.portable?null:this.stat.gid,size:this.stat.size,mtime:this.noMtime?null:this.mtime||this.stat.mtime,type:this.type,uname:this.portable?null:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?null:this.stat.atime,ctime:this.portable?null:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new t({atime:this.portable?null:this.header.atime,ctime:this.portable?null:this.header.ctime,gid:this.portable?null:this.header.gid,mtime:this.noMtime?null:this.mtime||this.header.mtime,path:this[x](this.path),linkpath:this.type==="Link"?this[x](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?null:this.header.uid,uname:this.portable?null:this.header.uname,dev:this.portable?null:this.stat.dev,ino:this.portable?null:this.stat.ino,nlink:this.portable?null:this.stat.nlink}).encode()),super.write(this.header.block)}[m](){this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[b](),this.end()}[C](){r.readlink(this.absolute,(c,g)=>{if(c)return this.emit("error",c);this[l](g)})}[l](c){this.linkpath=a(c),this[b](),this.end()}[_](c){this.type="Link",this.linkpath=a(i.relative(this.cwd,c)),this.stat.size=0,this[b](),this.end()}[y](){if(this.stat.nlink>1){const c=this.stat.dev+":"+this.stat.ino;if(this.linkCache.has(c)){const g=this.linkCache.get(c);if(g.indexOf(this.cwd)===0)return this[_](g)}this.linkCache.set(c,this.absolute)}if(this[b](),this.stat.size===0)return this.end();this[f]()}[f](){r.open(this.absolute,"r",(c,g)=>{if(c)return this.emit("error",c);this[d](g)})}[d](c){if(this.fd=c,this[M])return this[D]();this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;const g=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(g),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[A]()}[A](){const{fd:c,buf:g,offset:L,length:H,pos:J}=this;r.read(c,g,L,H,J,($,q)=>{if($)return this[D](()=>this.emit("error",$));this[n](q)})}[D](c){r.close(this.fd,c)}[n](c){if(c<=0&&this.remain>0){const H=new Error("encountered unexpected EOF");return H.path=this.absolute,H.syscall="read",H.code="EOF",this[D](()=>this.emit("error",H))}if(c>this.remain){const H=new Error("did not encounter expected EOF");return H.path=this.absolute,H.syscall="read",H.code="EOF",this[D](()=>this.emit("error",H))}if(c===this.remain)for(let H=c;H<this.length&&c<this.blockRemain;H++)this.buf[H+this.offset]=0,c++,this.remain++;const g=this.offset===0&&c===this.buf.length?this.buf:this.buf.slice(this.offset,this.offset+c);this.write(g)?this[B]():this[R](()=>this[B]())}[R](c){this.once("drain",c)}write(c){if(this.blockRemain<c.length){const g=new Error("writing more data than expected");return g.path=this.absolute,this.emit("error",g)}return this.remain-=c.length,this.blockRemain-=c.length,this.pos+=c.length,this.offset+=c.length,super.write(c)}[B](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[D](c=>c?this.emit("error",c):this.end());this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[A]()}});class V extends N{[S](){this[v](r.lstatSync(this.absolute))}[C](){this[l](r.readlinkSync(this.absolute))}[f](){this[d](r.openSync(this.absolute,"r"))}[A](){let c=!0;try{const{fd:g,buf:L,offset:H,length:J,pos:$}=this,q=r.readSync(g,L,H,J,$);this[n](q),c=!1}finally{if(c)try{this[D](()=>{})}catch{}}}[R](c){c()}[D](c){r.closeSync(this.fd),c()}}const W=P(class extends u{constructor(c,g){g=g||{},super(g),this.preservePaths=!!g.preservePaths,this.portable=!!g.portable,this.strict=!!g.strict,this.noPax=!!g.noPax,this.noMtime=!!g.noMtime,this.readEntry=c,this.type=c.type,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=g.prefix||null,this.path=a(c.path),this.mode=this[F](c.mode),this.uid=this.portable?null:c.uid,this.gid=this.portable?null:c.gid,this.uname=this.portable?null:c.uname,this.gname=this.portable?null:c.gname,this.size=c.size,this.mtime=this.noMtime?null:g.mtime||c.mtime,this.atime=this.portable?null:c.atime,this.ctime=this.portable?null:c.ctime,this.linkpath=a(c.linkpath),typeof g.onwarn=="function"&&this.on("warn",g.onwarn);let L=!1;if(!this.preservePaths){const[H,J]=G(this.path);H&&(this.path=J,L=H)}this.remain=c.size,this.blockRemain=c.startBlockSize,this.header=new s({path:this[x](this.path),linkpath:this.type==="Link"?this[x](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?null:this.uid,gid:this.portable?null:this.gid,size:this.size,mtime:this.noMtime?null:this.mtime,type:this.type,uname:this.portable?null:this.uname,atime:this.portable?null:this.atime,ctime:this.portable?null:this.ctime}),L&&this.warn("TAR_ENTRY_INFO",`stripping ${L} from absolute path`,{entry:this,path:L+this.path}),this.header.encode()&&!this.noPax&&super.write(new t({atime:this.portable?null:this.atime,ctime:this.portable?null:this.ctime,gid:this.portable?null:this.gid,mtime:this.noMtime?null:this.mtime,path:this[x](this.path),linkpath:this.type==="Link"?this[x](this.linkpath):this.linkpath,size:this.size,uid:this.portable?null:this.uid,uname:this.portable?null:this.uname,dev:this.portable?null:this.readEntry.dev,ino:this.portable?null:this.readEntry.ino,nlink:this.portable?null:this.readEntry.nlink}).encode()),super.write(this.header.block),c.pipe(this)}[x](c){return o(c,this.prefix)}[F](c){return Y(c,this.type==="Directory",this.portable)}write(c){const g=c.length;if(g>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=g,super.write(c)}end(){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),super.end()}});N.Sync=V,N.Tar=W;const ee=w=>w.isFile()?"File":w.isDirectory()?"Directory":w.isSymbolicLink()?"SymbolicLink":"Unsupported";return Jt=N,Jt}var Qt,Hs;function Hn(){return Hs||(Hs=1,Qt=function(u){u.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}),Qt}var ei,js;function Us(){if(js)return ei;js=1,ei=u,u.Node=i,u.create=u;function u(a){var e=this;if(e instanceof u||(e=new u),e.tail=null,e.head=null,e.length=0,a&&typeof a.forEach=="function")a.forEach(function(E){e.push(E)});else if(arguments.length>0)for(var o=0,h=arguments.length;o<h;o++)e.push(arguments[o]);return e}u.prototype.removeNode=function(a){if(a.list!==this)throw new Error("removing node which does not belong to this list");var e=a.next,o=a.prev;return e&&(e.prev=o),o&&(o.next=e),a===this.head&&(this.head=e),a===this.tail&&(this.tail=o),a.list.length--,a.next=null,a.prev=null,a.list=null,e},u.prototype.unshiftNode=function(a){if(a!==this.head){a.list&&a.list.removeNode(a);var e=this.head;a.list=this,a.next=e,e&&(e.prev=a),this.head=a,this.tail||(this.tail=a),this.length++}},u.prototype.pushNode=function(a){if(a!==this.tail){a.list&&a.list.removeNode(a);var e=this.tail;a.list=this,a.prev=e,e&&(e.next=a),this.tail=a,this.head||(this.head=a),this.length++}},u.prototype.push=function(){for(var a=0,e=arguments.length;a<e;a++)s(this,arguments[a]);return this.length},u.prototype.unshift=function(){for(var a=0,e=arguments.length;a<e;a++)r(this,arguments[a]);return this.length},u.prototype.pop=function(){if(this.tail){var a=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,a}},u.prototype.shift=function(){if(this.head){var a=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,a}},u.prototype.forEach=function(a,e){e=e||this;for(var o=this.head,h=0;o!==null;h++)a.call(e,o.value,h,this),o=o.next},u.prototype.forEachReverse=function(a,e){e=e||this;for(var o=this.tail,h=this.length-1;o!==null;h--)a.call(e,o.value,h,this),o=o.prev},u.prototype.get=function(a){for(var e=0,o=this.head;o!==null&&e<a;e++)o=o.next;if(e===a&&o!==null)return o.value},u.prototype.getReverse=function(a){for(var e=0,o=this.tail;o!==null&&e<a;e++)o=o.prev;if(e===a&&o!==null)return o.value},u.prototype.map=function(a,e){e=e||this;for(var o=new u,h=this.head;h!==null;)o.push(a.call(e,h.value,this)),h=h.next;return o},u.prototype.mapReverse=function(a,e){e=e||this;for(var o=new u,h=this.tail;h!==null;)o.push(a.call(e,h.value,this)),h=h.prev;return o},u.prototype.reduce=function(a,e){var o,h=this.head;if(arguments.length>1)o=e;else if(this.head)h=this.head.next,o=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var E=0;h!==null;E++)o=a(o,h.value,E),h=h.next;return o},u.prototype.reduceReverse=function(a,e){var o,h=this.tail;if(arguments.length>1)o=e;else if(this.tail)h=this.tail.prev,o=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var E=this.length-1;h!==null;E--)o=a(o,h.value,E),h=h.prev;return o},u.prototype.toArray=function(){for(var a=new Array(this.length),e=0,o=this.head;o!==null;e++)a[e]=o.value,o=o.next;return a},u.prototype.toArrayReverse=function(){for(var a=new Array(this.length),e=0,o=this.tail;o!==null;e++)a[e]=o.value,o=o.prev;return a},u.prototype.slice=function(a,e){e=e||this.length,e<0&&(e+=this.length),a=a||0,a<0&&(a+=this.length);var o=new u;if(e<a||e<0)return o;a<0&&(a=0),e>this.length&&(e=this.length);for(var h=0,E=this.head;E!==null&&h<a;h++)E=E.next;for(;E!==null&&h<e;h++,E=E.next)o.push(E.value);return o},u.prototype.sliceReverse=function(a,e){e=e||this.length,e<0&&(e+=this.length),a=a||0,a<0&&(a+=this.length);var o=new u;if(e<a||e<0)return o;a<0&&(a=0),e>this.length&&(e=this.length);for(var h=this.length,E=this.tail;E!==null&&h>e;h--)E=E.prev;for(;E!==null&&h>a;h--,E=E.prev)o.push(E.value);return o},u.prototype.splice=function(a,e,...o){a>this.length&&(a=this.length-1),a<0&&(a=this.length+a);for(var h=0,E=this.head;E!==null&&h<a;h++)E=E.next;for(var y=[],h=0;E&&h<e;h++)y.push(E.value),E=this.removeNode(E);E===null&&(E=this.tail),E!==this.head&&E!==this.tail&&(E=E.prev);for(var h=0;h<o.length;h++)E=t(this,E,o[h]);return y},u.prototype.reverse=function(){for(var a=this.head,e=this.tail,o=a;o!==null;o=o.prev){var h=o.prev;o.prev=o.next,o.next=h}return this.head=e,this.tail=a,this};function t(a,e,o){var h=e===a.head?new i(o,null,e,a):new i(o,e,e.next,a);return h.next===null&&(a.tail=h),h.prev===null&&(a.head=h),a.length++,h}function s(a,e){a.tail=new i(e,a.tail,null,a),a.head||(a.head=a.tail),a.length++}function r(a,e){a.head=new i(e,null,a.head,a),a.tail||(a.tail=a.head),a.length++}function i(a,e,o,h){if(!(this instanceof i))return new i(a,e,o,h);this.list=h,this.value=a,e?(e.next=this,this.prev=e):this.prev=null,o?(o.prev=this,this.next=o):this.next=null}try{Hn()(u)}catch{}return ei}var ti,zs;function ii(){if(zs)return ti;zs=1;class u{constructor(w,c){this.path=w||"./",this.absolute=c,this.entry=null,this.stat=null,this.readdir=null,this.pending=!1,this.ignore=!1,this.piped=!1}}const{Minipass:t}=It(),s=_s(),r=Ht(),i=ks(),a=i.Sync,e=i.Tar,o=Us(),h=Buffer.alloc(1024),E=Symbol("onStat"),y=Symbol("ended"),m=Symbol("queue"),C=Symbol("current"),_=Symbol("process"),b=Symbol("processing"),A=Symbol("processJob"),S=Symbol("jobs"),v=Symbol("jobDone"),n=Symbol("addFSEntry"),l=Symbol("addTarEntry"),f=Symbol("stat"),d=Symbol("readdir"),D=Symbol("onreaddir"),F=Symbol("pipe"),R=Symbol("entry"),B=Symbol("entryOpt"),x=Symbol("writeEntryClass"),M=Symbol("write"),P=Symbol("ondrain"),U=ge,G=De,Y=Kt(),N=Le(),V=Y(class extends t{constructor(w){if(super(w),w=w||Object.create(null),this.opt=w,this.file=w.file||"",this.cwd=w.cwd||process.cwd(),this.maxReadSize=w.maxReadSize,this.preservePaths=!!w.preservePaths,this.strict=!!w.strict,this.noPax=!!w.noPax,this.prefix=N(w.prefix||""),this.linkCache=w.linkCache||new Map,this.statCache=w.statCache||new Map,this.readdirCache=w.readdirCache||new Map,this[x]=i,typeof w.onwarn=="function"&&this.on("warn",w.onwarn),this.portable=!!w.portable,this.zip=null,w.gzip||w.brotli){if(w.gzip&&w.brotli)throw new TypeError("gzip and brotli are mutually exclusive");w.gzip&&(typeof w.gzip!="object"&&(w.gzip={}),this.portable&&(w.gzip.portable=!0),this.zip=new s.Gzip(w.gzip)),w.brotli&&(typeof w.brotli!="object"&&(w.brotli={}),this.zip=new s.BrotliCompress(w.brotli)),this.zip.on("data",c=>super.write(c)),this.zip.on("end",c=>super.end()),this.zip.on("drain",c=>this[P]()),this.on("resume",c=>this.zip.resume())}else this.on("drain",this[P]);this.noDirRecurse=!!w.noDirRecurse,this.follow=!!w.follow,this.noMtime=!!w.noMtime,this.mtime=w.mtime||null,this.filter=typeof w.filter=="function"?w.filter:c=>!0,this[m]=new o,this[S]=0,this.jobs=+w.jobs||4,this[b]=!1,this[y]=!1}[M](w){return super.write(w)}add(w){return this.write(w),this}end(w){return w&&this.write(w),this[y]=!0,this[_](),this}write(w){if(this[y])throw new Error("write after end");return w instanceof r?this[l](w):this[n](w),this.flowing}[l](w){const c=N(G.resolve(this.cwd,w.path));if(!this.filter(w.path,w))w.resume();else{const g=new u(w.path,c,!1);g.entry=new e(w,this[B](g)),g.entry.on("end",L=>this[v](g)),this[S]+=1,this[m].push(g)}this[_]()}[n](w){const c=N(G.resolve(this.cwd,w));this[m].push(new u(w,c)),this[_]()}[f](w){w.pending=!0,this[S]+=1;const c=this.follow?"stat":"lstat";U[c](w.absolute,(g,L)=>{w.pending=!1,this[S]-=1,g?this.emit("error",g):this[E](w,L)})}[E](w,c){this.statCache.set(w.absolute,c),w.stat=c,this.filter(w.path,c)||(w.ignore=!0),this[_]()}[d](w){w.pending=!0,this[S]+=1,U.readdir(w.absolute,(c,g)=>{if(w.pending=!1,this[S]-=1,c)return this.emit("error",c);this[D](w,g)})}[D](w,c){this.readdirCache.set(w.absolute,c),w.readdir=c,this[_]()}[_](){if(!this[b]){this[b]=!0;for(let w=this[m].head;w!==null&&this[S]<this.jobs;w=w.next)if(this[A](w.value),w.value.ignore){const c=w.next;this[m].removeNode(w),w.next=c}this[b]=!1,this[y]&&!this[m].length&&this[S]===0&&(this.zip?this.zip.end(h):(super.write(h),super.end()))}}get[C](){return this[m]&&this[m].head&&this[m].head.value}[v](w){this[m].shift(),this[S]-=1,this[_]()}[A](w){if(!w.pending){if(w.entry){w===this[C]&&!w.piped&&this[F](w);return}if(w.stat||(this.statCache.has(w.absolute)?this[E](w,this.statCache.get(w.absolute)):this[f](w)),!!w.stat&&!w.ignore&&!(!this.noDirRecurse&&w.stat.isDirectory()&&!w.readdir&&(this.readdirCache.has(w.absolute)?this[D](w,this.readdirCache.get(w.absolute)):this[d](w),!w.readdir))){if(w.entry=this[R](w),!w.entry){w.ignore=!0;return}w===this[C]&&!w.piped&&this[F](w)}}}[B](w){return{onwarn:(c,g,L)=>this.warn(c,g,L),noPax:this.noPax,cwd:this.cwd,absolute:w.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix}}[R](w){this[S]+=1;try{return new this[x](w.path,this[B](w)).on("end",()=>this[v](w)).on("error",c=>this.emit("error",c))}catch(c){this.emit("error",c)}}[P](){this[C]&&this[C].entry&&this[C].entry.resume()}[F](w){w.piped=!0,w.readdir&&w.readdir.forEach(L=>{const H=w.path,J=H==="./"?"":H.replace(/\/*$/,"/");this[n](J+L)});const c=w.entry,g=this.zip;g?c.on("data",L=>{g.write(L)||c.pause()}):c.on("data",L=>{super.write(L)||c.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}});class W extends V{constructor(w){super(w),this[x]=a}pause(){}resume(){}[f](w){const c=this.follow?"statSync":"lstatSync";this[E](w,U[c](w.absolute))}[d](w,c){this[D](w,U.readdirSync(w.absolute))}[F](w){const c=w.entry,g=this.zip;w.readdir&&w.readdir.forEach(L=>{const H=w.path,J=H==="./"?"":H.replace(/\/*$/,"/");this[n](J+L)}),g?c.on("data",L=>{g.write(L)}):c.on("data",L=>{super[M](L)})}}return V.Sync=W,ti=V,ti}var Re={},Gs;function ke(){if(Gs)return Re;Gs=1;const u=ys(),t=xe.EventEmitter,s=ge;let r=s.writev;if(!r){const w=process.binding("fs"),c=w.FSReqWrap||w.FSReqCallback;r=(g,L,H,J)=>{const $=(z,O)=>J(z,O,L),q=new c;q.oncomplete=$,w.writeBuffers(g,L,H,q)}}const i=Symbol("_autoClose"),a=Symbol("_close"),e=Symbol("_ended"),o=Symbol("_fd"),h=Symbol("_finished"),E=Symbol("_flags"),y=Symbol("_flush"),m=Symbol("_handleChunk"),C=Symbol("_makeBuf"),_=Symbol("_mode"),b=Symbol("_needDrain"),A=Symbol("_onerror"),S=Symbol("_onopen"),v=Symbol("_onread"),n=Symbol("_onwrite"),l=Symbol("_open"),f=Symbol("_path"),d=Symbol("_pos"),D=Symbol("_queue"),F=Symbol("_read"),R=Symbol("_readSize"),B=Symbol("_reading"),x=Symbol("_remain"),M=Symbol("_size"),P=Symbol("_write"),U=Symbol("_writing"),G=Symbol("_defaultFlag"),Y=Symbol("_errored");class N extends u{constructor(c,g){if(g=g||{},super(g),this.readable=!0,this.writable=!1,typeof c!="string")throw new TypeError("path must be a string");this[Y]=!1,this[o]=typeof g.fd=="number"?g.fd:null,this[f]=c,this[R]=g.readSize||16*1024*1024,this[B]=!1,this[M]=typeof g.size=="number"?g.size:1/0,this[x]=this[M],this[i]=typeof g.autoClose=="boolean"?g.autoClose:!0,typeof this[o]=="number"?this[F]():this[l]()}get fd(){return this[o]}get path(){return this[f]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[l](){s.open(this[f],"r",(c,g)=>this[S](c,g))}[S](c,g){c?this[A](c):(this[o]=g,this.emit("open",g),this[F]())}[C](){return Buffer.allocUnsafe(Math.min(this[R],this[x]))}[F](){if(!this[B]){this[B]=!0;const c=this[C]();if(c.length===0)return process.nextTick(()=>this[v](null,0,c));s.read(this[o],c,0,c.length,null,(g,L,H)=>this[v](g,L,H))}}[v](c,g,L){this[B]=!1,c?this[A](c):this[m](g,L)&&this[F]()}[a](){if(this[i]&&typeof this[o]=="number"){const c=this[o];this[o]=null,s.close(c,g=>g?this.emit("error",g):this.emit("close"))}}[A](c){this[B]=!0,this[a](),this.emit("error",c)}[m](c,g){let L=!1;return this[x]-=c,c>0&&(L=super.write(c<g.length?g.slice(0,c):g)),(c===0||this[x]<=0)&&(L=!1,this[a](),super.end()),L}emit(c,g){switch(c){case"prefinish":case"finish":break;case"drain":typeof this[o]=="number"&&this[F]();break;case"error":return this[Y]?void 0:(this[Y]=!0,super.emit(c,g));default:return super.emit(c,g)}}}class V extends N{[l](){let c=!0;try{this[S](null,s.openSync(this[f],"r")),c=!1}finally{c&&this[a]()}}[F](){let c=!0;try{if(!this[B]){this[B]=!0;do{const g=this[C](),L=g.length===0?0:s.readSync(this[o],g,0,g.length,null);if(!this[m](L,g))break}while(!0);this[B]=!1}c=!1}finally{c&&this[a]()}}[a](){if(this[i]&&typeof this[o]=="number"){const c=this[o];this[o]=null,s.closeSync(c),this.emit("close")}}}class W extends t{constructor(c,g){g=g||{},super(g),this.readable=!1,this.writable=!0,this[Y]=!1,this[U]=!1,this[e]=!1,this[b]=!1,this[D]=[],this[f]=c,this[o]=typeof g.fd=="number"?g.fd:null,this[_]=g.mode===void 0?438:g.mode,this[d]=typeof g.start=="number"?g.start:null,this[i]=typeof g.autoClose=="boolean"?g.autoClose:!0;const L=this[d]!==null?"r+":"w";this[G]=g.flags===void 0,this[E]=this[G]?L:g.flags,this[o]===null&&this[l]()}emit(c,g){if(c==="error"){if(this[Y])return;this[Y]=!0}return super.emit(c,g)}get fd(){return this[o]}get path(){return this[f]}[A](c){this[a](),this[U]=!0,this.emit("error",c)}[l](){s.open(this[f],this[E],this[_],(c,g)=>this[S](c,g))}[S](c,g){this[G]&&this[E]==="r+"&&c&&c.code==="ENOENT"?(this[E]="w",this[l]()):c?this[A](c):(this[o]=g,this.emit("open",g),this[y]())}end(c,g){return c&&this.write(c,g),this[e]=!0,!this[U]&&!this[D].length&&typeof this[o]=="number"&&this[n](null,0),this}write(c,g){return typeof c=="string"&&(c=Buffer.from(c,g)),this[e]?(this.emit("error",new Error("write() after end()")),!1):this[o]===null||this[U]||this[D].length?(this[D].push(c),this[b]=!0,!1):(this[U]=!0,this[P](c),!0)}[P](c){s.write(this[o],c,0,c.length,this[d],(g,L)=>this[n](g,L))}[n](c,g){c?this[A](c):(this[d]!==null&&(this[d]+=g),this[D].length?this[y]():(this[U]=!1,this[e]&&!this[h]?(this[h]=!0,this[a](),this.emit("finish")):this[b]&&(this[b]=!1,this.emit("drain"))))}[y](){if(this[D].length===0)this[e]&&this[n](null,0);else if(this[D].length===1)this[P](this[D].pop());else{const c=this[D];this[D]=[],r(this[o],c,this[d],(g,L)=>this[n](g,L))}}[a](){if(this[i]&&typeof this[o]=="number"){const c=this[o];this[o]=null,s.close(c,g=>g?this.emit("error",g):this.emit("close"))}}}class ee extends W{[l](){let c;if(this[G]&&this[E]==="r+")try{c=s.openSync(this[f],this[E],this[_])}catch(g){if(g.code==="ENOENT")return this[E]="w",this[l]();throw g}else c=s.openSync(this[f],this[E],this[_]);this[S](null,c)}[a](){if(this[i]&&typeof this[o]=="number"){const c=this[o];this[o]=null,s.closeSync(c),this.emit("close")}}[P](c){let g=!0;try{this[n](null,s.writeSync(this[o],c,0,c.length,this[d])),g=!1}finally{if(g)try{this[a]()}catch{}}}}return Re.ReadStream=N,Re.ReadStreamSync=V,Re.WriteStream=W,Re.WriteStreamSync=ee,Re}var si,qs;function ri(){if(qs)return si;qs=1;const u=Kt(),t=Me(),s=xe,r=Us(),i=1024*1024,a=Ht(),e=qt(),o=_s(),{nextTick:h}=xi,E=Buffer.from([31,139]),y=Symbol("state"),m=Symbol("writeEntry"),C=Symbol("readEntry"),_=Symbol("nextEntry"),b=Symbol("processEntry"),A=Symbol("extendedHeader"),S=Symbol("globalExtendedHeader"),v=Symbol("meta"),n=Symbol("emitMeta"),l=Symbol("buffer"),f=Symbol("queue"),d=Symbol("ended"),D=Symbol("emittedEnd"),F=Symbol("emit"),R=Symbol("unzip"),B=Symbol("consumeChunk"),x=Symbol("consumeChunkSub"),M=Symbol("consumeBody"),P=Symbol("consumeMeta"),U=Symbol("consumeHeader"),G=Symbol("consuming"),Y=Symbol("bufferConcat"),N=Symbol("maybeEnd"),V=Symbol("writing"),W=Symbol("aborted"),ee=Symbol("onDone"),w=Symbol("sawValidEntry"),c=Symbol("sawNullBlock"),g=Symbol("sawEOF"),L=Symbol("closeStream"),H=J=>!0;return si=u(class extends s{constructor($){$=$||{},super($),this.file=$.file||"",this[w]=null,this.on(ee,z=>{(this[y]==="begin"||this[w]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),$.ondone?this.on(ee,$.ondone):this.on(ee,z=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!$.strict,this.maxMetaEntrySize=$.maxMetaEntrySize||i,this.filter=typeof $.filter=="function"?$.filter:H;const q=$.file&&($.file.endsWith(".tar.br")||$.file.endsWith(".tbr"));this.brotli=!$.gzip&&$.brotli!==void 0?$.brotli:q?void 0:!1,this.writable=!0,this.readable=!1,this[f]=new r,this[l]=null,this[C]=null,this[m]=null,this[y]="begin",this[v]="",this[A]=null,this[S]=null,this[d]=!1,this[R]=null,this[W]=!1,this[c]=!1,this[g]=!1,this.on("end",()=>this[L]()),typeof $.onwarn=="function"&&this.on("warn",$.onwarn),typeof $.onentry=="function"&&this.on("entry",$.onentry)}[U]($,q){this[w]===null&&(this[w]=!1);let z;try{z=new t($,q,this[A],this[S])}catch(O){return this.warn("TAR_ENTRY_INVALID",O)}if(z.nullBlock)this[c]?(this[g]=!0,this[y]==="begin"&&(this[y]="header"),this[F]("eof")):(this[c]=!0,this[F]("nullBlock"));else if(this[c]=!1,!z.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:z});else if(!z.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:z});else{const O=z.type;if(/^(Symbolic)?Link$/.test(O)&&!z.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:z});else if(!/^(Symbolic)?Link$/.test(O)&&z.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:z});else{const T=this[m]=new a(z,this[A],this[S]);if(!this[w])if(T.remain){const K=()=>{T.invalid||(this[w]=!0)};T.on("end",K)}else this[w]=!0;T.meta?T.size>this.maxMetaEntrySize?(T.ignore=!0,this[F]("ignoredEntry",T),this[y]="ignore",T.resume()):T.size>0&&(this[v]="",T.on("data",K=>this[v]+=K),this[y]="meta"):(this[A]=null,T.ignore=T.ignore||!this.filter(T.path,T),T.ignore?(this[F]("ignoredEntry",T),this[y]=T.remain?"ignore":"header",T.resume()):(T.remain?this[y]="body":(this[y]="header",T.end()),this[C]?this[f].push(T):(this[f].push(T),this[_]())))}}}[L](){h(()=>this.emit("close"))}[b]($){let q=!0;return $?Array.isArray($)?this.emit.apply(this,$):(this[C]=$,this.emit("entry",$),$.emittedEnd||($.on("end",z=>this[_]()),q=!1)):(this[C]=null,q=!1),q}[_](){do;while(this[b](this[f].shift()));if(!this[f].length){const $=this[C];!$||$.flowing||$.size===$.remain?this[V]||this.emit("drain"):$.once("drain",z=>this.emit("drain"))}}[M]($,q){const z=this[m],O=z.blockRemain,T=O>=$.length&&q===0?$:$.slice(q,q+O);return z.write(T),z.blockRemain||(this[y]="header",this[m]=null,z.end()),T.length}[P]($,q){const z=this[m],O=this[M]($,q);return this[m]||this[n](z),O}[F]($,q,z){!this[f].length&&!this[C]?this.emit($,q,z):this[f].push([$,q,z])}[n]($){switch(this[F]("meta",this[v]),$.type){case"ExtendedHeader":case"OldExtendedHeader":this[A]=e.parse(this[v],this[A],!1);break;case"GlobalExtendedHeader":this[S]=e.parse(this[v],this[S],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":this[A]=this[A]||Object.create(null),this[A].path=this[v].replace(/\0.*/,"");break;case"NextFileHasLongLinkpath":this[A]=this[A]||Object.create(null),this[A].linkpath=this[v].replace(/\0.*/,"");break;default:throw new Error("unknown meta: "+$.type)}}abort($){this[W]=!0,this.emit("abort",$),this.warn("TAR_ABORT",$,{recoverable:!1})}write($){if(this[W])return;if((this[R]===null||this.brotli===void 0&&this[R]===!1)&&$){if(this[l]&&($=Buffer.concat([this[l],$]),this[l]=null),$.length<E.length)return this[l]=$,!0;for(let T=0;this[R]===null&&T<E.length;T++)$[T]!==E[T]&&(this[R]=!1);const O=this.brotli===void 0;if(this[R]===!1&&O)if($.length<512)if(this[d])this.brotli=!0;else return this[l]=$,!0;else try{new t($.slice(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[R]===null||this[R]===!1&&this.brotli){const T=this[d];this[d]=!1,this[R]=this[R]===null?new o.Unzip:new o.BrotliDecompress,this[R].on("data",oe=>this[B](oe)),this[R].on("error",oe=>this.abort(oe)),this[R].on("end",oe=>{this[d]=!0,this[B]()}),this[V]=!0;const K=this[R][T?"end":"write"]($);return this[V]=!1,K}}this[V]=!0,this[R]?this[R].write($):this[B]($),this[V]=!1;const z=this[f].length?!1:this[C]?this[C].flowing:!0;return!z&&!this[f].length&&this[C].once("drain",O=>this.emit("drain")),z}[Y]($){$&&!this[W]&&(this[l]=this[l]?Buffer.concat([this[l],$]):$)}[N](){if(this[d]&&!this[D]&&!this[W]&&!this[G]){this[D]=!0;const $=this[m];if($&&$.blockRemain){const q=this[l]?this[l].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${$.blockRemain} more bytes, only ${q} available)`,{entry:$}),this[l]&&$.write(this[l]),$.end()}this[F](ee)}}[B]($){if(this[G])this[Y]($);else if(!$&&!this[l])this[N]();else{if(this[G]=!0,this[l]){this[Y]($);const q=this[l];this[l]=null,this[x](q)}else this[x]($);for(;this[l]&&this[l].length>=512&&!this[W]&&!this[g];){const q=this[l];this[l]=null,this[x](q)}this[G]=!1}(!this[l]||this[d])&&this[N]()}[x]($){let q=0;const z=$.length;for(;q+512<=z&&!this[W]&&!this[g];)switch(this[y]){case"begin":case"header":this[U]($,q),q+=512;break;case"ignore":case"body":q+=this[M]($,q);break;case"meta":q+=this[P]($,q);break;default:throw new Error("invalid state: "+this[y])}q<z&&(this[l]?this[l]=Buffer.concat([$.slice(q),this[l]]):this[l]=$.slice(q))}end($){this[W]||(this[R]?this[R].end($):(this[d]=!0,this.brotli===void 0&&($=$||Buffer.alloc(0)),this.write($)))}}),si}var ni,Vs;function ui(){if(Vs)return ni;Vs=1;const u=Ie(),t=ri(),s=ge,r=ke(),i=De,a=Pe();ni=(m,C,_)=>{typeof m=="function"?(_=m,C=null,m={}):Array.isArray(m)&&(C=m,m={}),typeof C=="function"&&(_=C,C=null),C?C=Array.from(C):C=[];const b=u(m);if(b.sync&&typeof _=="function")throw new TypeError("callback not supported for sync tar functions");if(!b.file&&typeof _=="function")throw new TypeError("callback only supported with file option");return C.length&&o(b,C),b.noResume||e(b),b.file&&b.sync?h(b):b.file?E(b,_):y(b)};const e=m=>{const C=m.onentry;m.onentry=C?_=>{C(_),_.resume()}:_=>_.resume()},o=(m,C)=>{const _=new Map(C.map(S=>[a(S),!0])),b=m.filter,A=(S,v)=>{const n=v||i.parse(S).root||".",l=S===n?!1:_.has(S)?_.get(S):A(i.dirname(S),n);return _.set(S,l),l};m.filter=b?(S,v)=>b(S,v)&&A(a(S)):S=>A(a(S))},h=m=>{const C=y(m),_=m.file;let b=!0,A;try{const S=s.statSync(_),v=m.maxReadSize||16*1024*1024;if(S.size<v)C.end(s.readFileSync(_));else{let n=0;const l=Buffer.allocUnsafe(v);for(A=s.openSync(_,"r");n<S.size;){const f=s.readSync(A,l,0,v,n);n+=f,C.write(l.slice(0,f))}C.end()}b=!1}finally{if(b&&A)try{s.closeSync(A)}catch{}}},E=(m,C)=>{const _=new t(m),b=m.maxReadSize||16*1024*1024,A=m.file,S=new Promise((v,n)=>{_.on("error",n),_.on("end",v),s.stat(A,(l,f)=>{if(l)n(l);else{const d=new r.ReadStream(A,{readSize:b,size:f.size});d.on("error",n),d.pipe(_)}})});return C?S.then(C,C):S},y=m=>new t(m);return ni}var oi,Ws;function jn(){if(Ws)return oi;Ws=1;const u=Ie(),t=ii(),s=ke(),r=ui(),i=De;oi=(m,C,_)=>{if(typeof C=="function"&&(_=C),Array.isArray(m)&&(C=m,m={}),!C||!Array.isArray(C)||!C.length)throw new TypeError("no files or directories specified");C=Array.from(C);const b=u(m);if(b.sync&&typeof _=="function")throw new TypeError("callback not supported for sync tar functions");if(!b.file&&typeof _=="function")throw new TypeError("callback only supported with file option");return b.file&&b.sync?a(b,C):b.file?e(b,C,_):b.sync?E(b,C):y(b,C)};const a=(m,C)=>{const _=new t.Sync(m),b=new s.WriteStreamSync(m.file,{mode:m.mode||438});_.pipe(b),o(_,C)},e=(m,C,_)=>{const b=new t(m),A=new s.WriteStream(m.file,{mode:m.mode||438});b.pipe(A);const S=new Promise((v,n)=>{A.on("error",n),A.on("close",v),b.on("error",n)});return h(b,C),_?S.then(_,_):S},o=(m,C)=>{C.forEach(_=>{_.charAt(0)==="@"?r({file:i.resolve(m.cwd,_.slice(1)),sync:!0,noResume:!0,onentry:b=>m.add(b)}):m.add(_)}),m.end()},h=(m,C)=>{for(;C.length;){const _=C.shift();if(_.charAt(0)==="@")return r({file:i.resolve(m.cwd,_.slice(1)),noResume:!0,onentry:b=>m.add(b)}).then(b=>h(m,C));m.add(_)}m.end()},E=(m,C)=>{const _=new t.Sync(m);return o(_,C),_},y=(m,C)=>{const _=new t(m);return h(_,C),_};return oi}var ai,Ks;function Ys(){if(Ks)return ai;Ks=1;const u=Ie(),t=ii(),s=ge,r=ke(),i=ui(),a=De,e=Me();ai=(C,_,b)=>{const A=u(C);if(!A.file)throw new TypeError("file is required");if(A.gzip||A.brotli||A.file.endsWith(".br")||A.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!_||!Array.isArray(_)||!_.length)throw new TypeError("no files or directories specified");return _=Array.from(_),A.sync?o(A,_):E(A,_,b)};const o=(C,_)=>{const b=new t.Sync(C);let A=!0,S,v;try{try{S=s.openSync(C.file,"r+")}catch(f){if(f.code==="ENOENT")S=s.openSync(C.file,"w+");else throw f}const n=s.fstatSync(S),l=Buffer.alloc(512);e:for(v=0;v<n.size;v+=512){for(let D=0,F=0;D<512;D+=F){if(F=s.readSync(S,l,D,l.length-D,v+D),v===0&&l[0]===31&&l[1]===139)throw new Error("cannot append to compressed archives");if(!F)break e}const f=new e(l);if(!f.cksumValid)break;const d=512*Math.ceil(f.size/512);if(v+d+512>n.size)break;v+=d,C.mtimeCache&&C.mtimeCache.set(f.path,f.mtime)}A=!1,h(C,b,v,S,_)}finally{if(A)try{s.closeSync(S)}catch{}}},h=(C,_,b,A,S)=>{const v=new r.WriteStreamSync(C.file,{fd:A,start:b});_.pipe(v),y(_,S)},E=(C,_,b)=>{_=Array.from(_);const A=new t(C),S=(n,l,f)=>{const d=(x,M)=>{x?s.close(n,P=>f(x)):f(null,M)};let D=0;if(l===0)return d(null,0);let F=0;const R=Buffer.alloc(512),B=(x,M)=>{if(x)return d(x);if(F+=M,F<512&&M)return s.read(n,R,F,R.length-F,D+F,B);if(D===0&&R[0]===31&&R[1]===139)return d(new Error("cannot append to compressed archives"));if(F<512)return d(null,D);const P=new e(R);if(!P.cksumValid)return d(null,D);const U=512*Math.ceil(P.size/512);if(D+U+512>l||(D+=U+512,D>=l))return d(null,D);C.mtimeCache&&C.mtimeCache.set(P.path,P.mtime),F=0,s.read(n,R,0,512,D,B)};s.read(n,R,0,512,D,B)},v=new Promise((n,l)=>{A.on("error",l);let f="r+";const d=(D,F)=>{if(D&&D.code==="ENOENT"&&f==="r+")return f="w+",s.open(C.file,f,d);if(D)return l(D);s.fstat(F,(R,B)=>{if(R)return s.close(F,()=>l(R));S(F,B.size,(x,M)=>{if(x)return l(x);const P=new r.WriteStream(C.file,{fd:F,start:M});A.pipe(P),P.on("error",l),P.on("close",n),m(A,_)})})};s.open(C.file,f,d)});return b?v.then(b,b):v},y=(C,_)=>{_.forEach(b=>{b.charAt(0)==="@"?i({file:a.resolve(C.cwd,b.slice(1)),sync:!0,noResume:!0,onentry:A=>C.add(A)}):C.add(b)}),C.end()},m=(C,_)=>{for(;_.length;){const b=_.shift();if(b.charAt(0)==="@")return i({file:a.resolve(C.cwd,b.slice(1)),noResume:!0,onentry:A=>C.add(A)}).then(A=>m(C,_));C.add(b)}C.end()};return ai}var hi,Zs;function Un(){if(Zs)return hi;Zs=1;const u=Ie(),t=Ys();hi=(r,i,a)=>{const e=u(r);if(!e.file)throw new TypeError("file is required");if(e.gzip||e.brotli||e.file.endsWith(".br")||e.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!i||!Array.isArray(i)||!i.length)throw new TypeError("no files or directories specified");return i=Array.from(i),s(e),t(e,i,a)};const s=r=>{const i=r.filter;r.mtimeCache||(r.mtimeCache=new Map),r.filter=i?(a,e)=>i(a,e)&&!(r.mtimeCache.get(a)>e.mtime):(a,e)=>!(r.mtimeCache.get(a)>e.mtime)};return hi}var st={exports:{}},li,Xs;function zn(){if(Xs)return li;Xs=1;const{promisify:u}=Rr,t=ge;return li=r=>{if(!r)r={mode:511,fs:t};else if(typeof r=="object")r={mode:511,fs:t,...r};else if(typeof r=="number")r={mode:r,fs:t};else if(typeof r=="string")r={mode:parseInt(r,8),fs:t};else throw new TypeError("invalid options argument");return r.mkdir=r.mkdir||r.fs.mkdir||t.mkdir,r.mkdirAsync=u(r.mkdir),r.stat=r.stat||r.fs.stat||t.stat,r.statAsync=u(r.stat),r.statSync=r.statSync||r.fs.statSync||t.statSync,r.mkdirSync=r.mkdirSync||r.fs.mkdirSync||t.mkdirSync,r},li}var ci,Js;function Gn(){if(Js)return ci;Js=1;const u=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,{resolve:t,parse:s}=De;return ci=i=>{if(/\0/.test(i))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:i,code:"ERR_INVALID_ARG_VALUE"});if(i=t(i),u==="win32"){const a=/[*|"<>?:]/,{root:e}=s(i);if(a.test(i.substr(e.length)))throw Object.assign(new Error("Illegal characters in path."),{path:i,code:"EINVAL"})}return i},ci}var Di,Qs;function qn(){if(Qs)return Di;Qs=1;const{dirname:u}=De,t=(r,i,a=void 0)=>a===i?Promise.resolve():r.statAsync(i).then(e=>e.isDirectory()?a:void 0,e=>e.code==="ENOENT"?t(r,u(i),i):void 0),s=(r,i,a=void 0)=>{if(a!==i)try{return r.statSync(i).isDirectory()?a:void 0}catch(e){return e.code==="ENOENT"?s(r,u(i),i):void 0}};return Di={findMade:t,findMadeSync:s},Di}var fi,er;function tr(){if(er)return fi;er=1;const{dirname:u}=De,t=(r,i,a)=>{i.recursive=!1;const e=u(r);return e===r?i.mkdirAsync(r,i).catch(o=>{if(o.code!=="EISDIR")throw o}):i.mkdirAsync(r,i).then(()=>a||r,o=>{if(o.code==="ENOENT")return t(e,i).then(h=>t(r,i,h));if(o.code!=="EEXIST"&&o.code!=="EROFS")throw o;return i.statAsync(r).then(h=>{if(h.isDirectory())return a;throw o},()=>{throw o})})},s=(r,i,a)=>{const e=u(r);if(i.recursive=!1,e===r)try{return i.mkdirSync(r,i)}catch(o){if(o.code!=="EISDIR")throw o;return}try{return i.mkdirSync(r,i),a||r}catch(o){if(o.code==="ENOENT")return s(r,i,s(e,i,a));if(o.code!=="EEXIST"&&o.code!=="EROFS")throw o;try{if(!i.statSync(r).isDirectory())throw o}catch{throw o}}};return fi={mkdirpManual:t,mkdirpManualSync:s},fi}var di,ir;function Vn(){if(ir)return di;ir=1;const{dirname:u}=De,{findMade:t,findMadeSync:s}=qn(),{mkdirpManual:r,mkdirpManualSync:i}=tr();return di={mkdirpNative:(o,h)=>(h.recursive=!0,u(o)===o?h.mkdirAsync(o,h):t(h,o).then(y=>h.mkdirAsync(o,h).then(()=>y).catch(m=>{if(m.code==="ENOENT")return r(o,h);throw m}))),mkdirpNativeSync:(o,h)=>{if(h.recursive=!0,u(o)===o)return h.mkdirSync(o,h);const y=s(h,o);try{return h.mkdirSync(o,h),y}catch(m){if(m.code==="ENOENT")return i(o,h);throw m}}},di}var mi,sr;function Wn(){if(sr)return mi;sr=1;const u=ge,s=(process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version).replace(/^v/,"").split("."),r=+s[0]>10||+s[0]==10&&+s[1]>=12;return mi={useNative:r?e=>e.mkdir===u.mkdir:()=>!1,useNativeSync:r?e=>e.mkdirSync===u.mkdirSync:()=>!1},mi}var pi,rr;function Kn(){if(rr)return pi;rr=1;const u=zn(),t=Gn(),{mkdirpNative:s,mkdirpNativeSync:r}=Vn(),{mkdirpManual:i,mkdirpManualSync:a}=tr(),{useNative:e,useNativeSync:o}=Wn(),h=(y,m)=>(y=t(y),m=u(m),e(m)?s(y,m):i(y,m)),E=(y,m)=>(y=t(y),m=u(m),o(m)?r(y,m):a(y,m));return h.sync=E,h.native=(y,m)=>s(t(y),u(m)),h.manual=(y,m)=>i(t(y),u(m)),h.nativeSync=(y,m)=>r(t(y),u(m)),h.manualSync=(y,m)=>a(t(y),u(m)),pi=h,pi}var Ei,nr;function Yn(){if(nr)return Ei;nr=1;const u=ge,t=De,s=u.lchown?"lchown":"chown",r=u.lchownSync?"lchownSync":"chownSync",i=u.lchown&&!process.version.match(/v1[1-9]+\./)&&!process.version.match(/v10\.[6-9]/),a=(v,n,l)=>{try{return u[r](v,n,l)}catch(f){if(f.code!=="ENOENT")throw f}},e=(v,n,l)=>{try{return u.chownSync(v,n,l)}catch(f){if(f.code!=="ENOENT")throw f}},o=i?(v,n,l,f)=>d=>{!d||d.code!=="EISDIR"?f(d):u.chown(v,n,l,f)}:(v,n,l,f)=>f,h=i?(v,n,l)=>{try{return a(v,n,l)}catch(f){if(f.code!=="EISDIR")throw f;e(v,n,l)}}:(v,n,l)=>a(v,n,l),E=process.version;let y=(v,n,l)=>u.readdir(v,n,l),m=(v,n)=>u.readdirSync(v,n);/^v4\./.test(E)&&(y=(v,n,l)=>u.readdir(v,l));const C=(v,n,l,f)=>{u[s](v,n,l,o(v,n,l,d=>{f(d&&d.code!=="ENOENT"?d:null)}))},_=(v,n,l,f,d)=>{if(typeof n=="string")return u.lstat(t.resolve(v,n),(D,F)=>{if(D)return d(D.code!=="ENOENT"?D:null);F.name=n,_(v,F,l,f,d)});if(n.isDirectory())b(t.resolve(v,n.name),l,f,D=>{if(D)return d(D);const F=t.resolve(v,n.name);C(F,l,f,d)});else{const D=t.resolve(v,n.name);C(D,l,f,d)}},b=(v,n,l,f)=>{y(v,{withFileTypes:!0},(d,D)=>{if(d){if(d.code==="ENOENT")return f();if(d.code!=="ENOTDIR"&&d.code!=="ENOTSUP")return f(d)}if(d||!D.length)return C(v,n,l,f);let F=D.length,R=null;const B=x=>{if(!R){if(x)return f(R=x);if(--F===0)return C(v,n,l,f)}};D.forEach(x=>_(v,x,n,l,B))})},A=(v,n,l,f)=>{if(typeof n=="string")try{const d=u.lstatSync(t.resolve(v,n));d.name=n,n=d}catch(d){if(d.code==="ENOENT")return;throw d}n.isDirectory()&&S(t.resolve(v,n.name),l,f),h(t.resolve(v,n.name),l,f)},S=(v,n,l)=>{let f;try{f=m(v,{withFileTypes:!0})}catch(d){if(d.code==="ENOENT")return;if(d.code==="ENOTDIR"||d.code==="ENOTSUP")return h(v,n,l);throw d}return f&&f.length&&f.forEach(d=>A(v,d,n,l)),h(v,n,l)};return Ei=b,b.sync=S,Ei}var ur;function Zn(){if(ur)return st.exports;ur=1;const u=Kn(),t=ge,s=De,r=Yn(),i=Le();class a extends Error{constructor(b,A){super("Cannot extract through symbolic link"),this.path=A,this.symlink=b}get name(){return"SylinkError"}}class e extends Error{constructor(b,A){super(A+": Cannot cd into '"+b+"'"),this.path=b,this.code=A}get name(){return"CwdError"}}const o=(_,b)=>_.get(i(b)),h=(_,b,A)=>_.set(i(b),A),E=(_,b)=>{t.stat(_,(A,S)=>{(A||!S.isDirectory())&&(A=new e(_,A&&A.code||"ENOTDIR")),b(A)})};st.exports=(_,b,A)=>{_=i(_);const S=b.umask,v=b.mode|448,n=(v&S)!==0,l=b.uid,f=b.gid,d=typeof l=="number"&&typeof f=="number"&&(l!==b.processUid||f!==b.processGid),D=b.preserve,F=b.unlink,R=b.cache,B=i(b.cwd),x=(U,G)=>{U?A(U):(h(R,_,!0),G&&d?r(G,l,f,Y=>x(Y)):n?t.chmod(_,v,A):A())};if(R&&o(R,_)===!0)return x();if(_===B)return E(_,x);if(D)return u(_,{mode:v}).then(U=>x(null,U),x);const P=i(s.relative(B,_)).split("/");y(B,P,v,R,F,B,null,x)};const y=(_,b,A,S,v,n,l,f)=>{if(!b.length)return f(null,l);const d=b.shift(),D=i(s.resolve(_+"/"+d));if(o(S,D))return y(D,b,A,S,v,n,l,f);t.mkdir(D,A,m(D,b,A,S,v,n,l,f))},m=(_,b,A,S,v,n,l,f)=>d=>{d?t.lstat(_,(D,F)=>{if(D)D.path=D.path&&i(D.path),f(D);else if(F.isDirectory())y(_,b,A,S,v,n,l,f);else if(v)t.unlink(_,R=>{if(R)return f(R);t.mkdir(_,A,m(_,b,A,S,v,n,l,f))});else{if(F.isSymbolicLink())return f(new a(_,_+"/"+b.join("/")));f(d)}}):(l=l||_,y(_,b,A,S,v,n,l,f))},C=_=>{let b=!1,A="ENOTDIR";try{b=t.statSync(_).isDirectory()}catch(S){A=S.code}finally{if(!b)throw new e(_,A)}};return st.exports.sync=(_,b)=>{_=i(_);const A=b.umask,S=b.mode|448,v=(S&A)!==0,n=b.uid,l=b.gid,f=typeof n=="number"&&typeof l=="number"&&(n!==b.processUid||l!==b.processGid),d=b.preserve,D=b.unlink,F=b.cache,R=i(b.cwd),B=U=>{h(F,_,!0),U&&f&&r.sync(U,n,l),v&&t.chmodSync(_,S)};if(F&&o(F,_)===!0)return B();if(_===R)return C(R),B();if(d)return B(u.sync(_,S));const M=i(s.relative(R,_)).split("/");let P=null;for(let U=M.shift(),G=R;U&&(G+="/"+U);U=M.shift())if(G=i(s.resolve(G)),!o(F,G))try{t.mkdirSync(G,S),P=P||G,h(F,G,!0)}catch{const N=t.lstatSync(G);if(N.isDirectory()){h(F,G,!0);continue}else if(D){t.unlinkSync(G),t.mkdirSync(G,S),P=P||G,h(F,G,!0);continue}else if(N.isSymbolicLink())return new a(G,G+"/"+M.join("/"))}return B(P)},st.exports}var gi,or;function ar(){if(or)return gi;or=1;const u=Object.create(null),{hasOwnProperty:t}=Object.prototype;return gi=s=>(t.call(u,s)||(u[s]=s.normalize("NFD")),u[s]),gi}var Ci,hr;function Xn(){if(hr)return Ci;hr=1;const u=lt,t=ar(),s=Pe(),{join:r}=De,a=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32";return Ci=()=>{const e=new Map,o=new Map,h=A=>A.split("/").slice(0,-1).reduce((v,n)=>(v.length&&(n=r(v[v.length-1],n)),v.push(n||"/"),v),[]),E=new Set,y=A=>{const S=o.get(A);if(!S)throw new Error("function does not have any path reservations");return{paths:S.paths.map(v=>e.get(v)),dirs:[...S.dirs].map(v=>e.get(v))}},m=A=>{const{paths:S,dirs:v}=y(A);return S.every(n=>n[0]===A)&&v.every(n=>n[0]instanceof Set&&n[0].has(A))},C=A=>E.has(A)||!m(A)?!1:(E.add(A),A(()=>_(A)),!0),_=A=>{if(!E.has(A))return!1;const{paths:S,dirs:v}=o.get(A),n=new Set;return S.forEach(l=>{const f=e.get(l);u.equal(f[0],A),f.length===1?e.delete(l):(f.shift(),typeof f[0]=="function"?n.add(f[0]):f[0].forEach(d=>n.add(d)))}),v.forEach(l=>{const f=e.get(l);u(f[0]instanceof Set),f[0].size===1&&f.length===1?e.delete(l):f[0].size===1?(f.shift(),n.add(f[0])):f[0].delete(A)}),E.delete(A),n.forEach(l=>C(l)),!0};return{check:m,reserve:(A,S)=>{A=a?["win32 parallelization disabled"]:A.map(n=>s(r(t(n))).toLowerCase());const v=new Set(A.map(n=>h(n)).reduce((n,l)=>n.concat(l)));return o.set(S,{dirs:v,paths:A}),A.forEach(n=>{const l=e.get(n);l?l.push(S):e.set(n,[S])}),v.forEach(n=>{const l=e.get(n);l?l[l.length-1]instanceof Set?l[l.length-1].add(S):l.push(new Set([S])):e.set(n,[new Set([S])])}),C(S)}}},Ci}var Fi,lr;function Jn(){if(lr)return Fi;lr=1;const t=(process.env.__FAKE_PLATFORM__||process.platform)==="win32",s=ct.__FAKE_TESTING_FS__||ge,{O_CREAT:r,O_TRUNC:i,O_WRONLY:a,UV_FS_O_FILEMAP:e=0}=s.constants,o=t&&!!e,h=512*1024,E=e|i|r|a;return Fi=o?y=>y<h?E:"w":()=>"w",Fi}var yi,cr;function Dr(){if(cr)return yi;cr=1;const u=lt,t=ri(),s=ge,r=ke(),i=De,a=Zn(),e=Ns(),o=Xn(),h=Ls(),E=Le(),y=Pe(),m=ar(),C=Symbol("onEntry"),_=Symbol("checkFs"),b=Symbol("checkFs2"),A=Symbol("pruneCache"),S=Symbol("isReusable"),v=Symbol("makeFs"),n=Symbol("file"),l=Symbol("directory"),f=Symbol("link"),d=Symbol("symlink"),D=Symbol("hardlink"),F=Symbol("unsupported"),R=Symbol("checkPath"),B=Symbol("mkdir"),x=Symbol("onError"),M=Symbol("pending"),P=Symbol("pend"),U=Symbol("unpend"),G=Symbol("ended"),Y=Symbol("maybeClose"),N=Symbol("skip"),V=Symbol("doChown"),W=Symbol("uid"),ee=Symbol("gid"),w=Symbol("checkedCwd"),c=Br,g=Jn(),H=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",J=1024,$=(te,p)=>{if(!H)return s.unlink(te,p);const k=te+".DELETE."+c.randomBytes(16).toString("hex");s.rename(te,k,j=>{if(j)return p(j);s.unlink(k,p)})},q=te=>{if(!H)return s.unlinkSync(te);const p=te+".DELETE."+c.randomBytes(16).toString("hex");s.renameSync(te,p),s.unlinkSync(p)},z=(te,p,k)=>te===te>>>0?te:p===p>>>0?p:k,O=te=>y(E(m(te))).toLowerCase(),T=(te,p)=>{p=O(p);for(const k of te.keys()){const j=O(k);(j===p||j.indexOf(p+"/")===0)&&te.delete(k)}},K=te=>{for(const p of te.keys())te.delete(p)};class oe extends t{constructor(p){if(p||(p={}),p.ondone=k=>{this[G]=!0,this[Y]()},super(p),this[w]=!1,this.reservations=o(),this.transform=typeof p.transform=="function"?p.transform:null,this.writable=!0,this.readable=!1,this[M]=0,this[G]=!1,this.dirCache=p.dirCache||new Map,typeof p.uid=="number"||typeof p.gid=="number"){if(typeof p.uid!="number"||typeof p.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(p.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=p.uid,this.gid=p.gid,this.setOwner=!0}else this.uid=null,this.gid=null,this.setOwner=!1;p.preserveOwner===void 0&&typeof p.uid!="number"?this.preserveOwner=process.getuid&&process.getuid()===0:this.preserveOwner=!!p.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():null,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():null,this.maxDepth=typeof p.maxDepth=="number"?p.maxDepth:J,this.forceChown=p.forceChown===!0,this.win32=!!p.win32||H,this.newer=!!p.newer,this.keep=!!p.keep,this.noMtime=!!p.noMtime,this.preservePaths=!!p.preservePaths,this.unlink=!!p.unlink,this.cwd=E(i.resolve(p.cwd||process.cwd())),this.strip=+p.strip||0,this.processUmask=p.noChmod?0:process.umask(),this.umask=typeof p.umask=="number"?p.umask:this.processUmask,this.dmode=p.dmode||511&~this.umask,this.fmode=p.fmode||438&~this.umask,this.on("entry",k=>this[C](k))}warn(p,k,j={}){return(p==="TAR_BAD_ARCHIVE"||p==="TAR_ABORT")&&(j.recoverable=!1),super.warn(p,k,j)}[Y](){this[G]&&this[M]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[R](p){const k=E(p.path),j=k.split("/");if(this.strip){if(j.length<this.strip)return!1;if(p.type==="Link"){const Z=E(p.linkpath).split("/");if(Z.length>=this.strip)p.linkpath=Z.slice(this.strip).join("/");else return!1}j.splice(0,this.strip),p.path=j.join("/")}if(isFinite(this.maxDepth)&&j.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:p,path:k,depth:j.length,maxDepth:this.maxDepth}),!1;if(!this.preservePaths){if(j.includes("..")||H&&/^[a-z]:\.\.$/i.test(j[0]))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:p,path:k}),!1;const[Z,X]=h(k);Z&&(p.path=X,this.warn("TAR_ENTRY_INFO",`stripping ${Z} from absolute path`,{entry:p,path:k}))}if(i.isAbsolute(p.path)?p.absolute=E(i.resolve(p.path)):p.absolute=E(i.resolve(this.cwd,p.path)),!this.preservePaths&&p.absolute.indexOf(this.cwd+"/")!==0&&p.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:p,path:E(p.path),resolvedPath:p.absolute,cwd:this.cwd}),!1;if(p.absolute===this.cwd&&p.type!=="Directory"&&p.type!=="GNUDumpDir")return!1;if(this.win32){const{root:Z}=i.win32.parse(p.absolute);p.absolute=Z+e.encode(p.absolute.slice(Z.length));const{root:X}=i.win32.parse(p.path);p.path=X+e.encode(p.path.slice(X.length))}return!0}[C](p){if(!this[R](p))return p.resume();switch(u.equal(typeof p.absolute,"string"),p.type){case"Directory":case"GNUDumpDir":p.mode&&(p.mode=p.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[_](p);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[F](p)}}[x](p,k){p.name==="CwdError"?this.emit("error",p):(this.warn("TAR_ENTRY_ERROR",p,{entry:k}),this[U](),k.resume())}[B](p,k,j){a(E(p),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:k,noChmod:this.noChmod},j)}[V](p){return this.forceChown||this.preserveOwner&&(typeof p.uid=="number"&&p.uid!==this.processUid||typeof p.gid=="number"&&p.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[W](p){return z(this.uid,p.uid,this.processUid)}[ee](p){return z(this.gid,p.gid,this.processGid)}[n](p,k){const j=p.mode&4095||this.fmode,Z=new r.WriteStream(p.absolute,{flags:g(p.size),mode:j,autoClose:!1});Z.on("error",se=>{Z.fd&&s.close(Z.fd,()=>{}),Z.write=()=>!0,this[x](se,p),k()});let X=1;const ue=se=>{if(se){Z.fd&&s.close(Z.fd,()=>{}),this[x](se,p),k();return}--X===0&&s.close(Z.fd,le=>{le?this[x](le,p):this[U](),k()})};Z.on("finish",se=>{const le=p.absolute,Fe=Z.fd;if(p.mtime&&!this.noMtime){X++;const ye=p.atime||new Date,Ae=p.mtime;s.futimes(Fe,ye,Ae,Be=>Be?s.utimes(le,ye,Ae,ut=>ue(ut&&Be)):ue())}if(this[V](p)){X++;const ye=this[W](p),Ae=this[ee](p);s.fchown(Fe,ye,Ae,Be=>Be?s.chown(le,ye,Ae,ut=>ue(ut&&Be)):ue())}ue()});const ie=this.transform&&this.transform(p)||p;ie!==p&&(ie.on("error",se=>{this[x](se,p),k()}),p.pipe(ie)),ie.pipe(Z)}[l](p,k){const j=p.mode&4095||this.dmode;this[B](p.absolute,j,Z=>{if(Z){this[x](Z,p),k();return}let X=1;const ue=ie=>{--X===0&&(k(),this[U](),p.resume())};p.mtime&&!this.noMtime&&(X++,s.utimes(p.absolute,p.atime||new Date,p.mtime,ue)),this[V](p)&&(X++,s.chown(p.absolute,this[W](p),this[ee](p),ue)),ue()})}[F](p){p.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${p.type}`,{entry:p}),p.resume()}[d](p,k){this[f](p,p.linkpath,"symlink",k)}[D](p,k){const j=E(i.resolve(this.cwd,p.linkpath));this[f](p,j,"link",k)}[P](){this[M]++}[U](){this[M]--,this[Y]()}[N](p){this[U](),p.resume()}[S](p,k){return p.type==="File"&&!this.unlink&&k.isFile()&&k.nlink<=1&&!H}[_](p){this[P]();const k=[p.path];p.linkpath&&k.push(p.linkpath),this.reservations.reserve(k,j=>this[b](p,j))}[A](p){p.type==="SymbolicLink"?K(this.dirCache):p.type!=="Directory"&&T(this.dirCache,p.absolute)}[b](p,k){this[A](p);const j=ie=>{this[A](p),k(ie)},Z=()=>{this[B](this.cwd,this.dmode,ie=>{if(ie){this[x](ie,p),j();return}this[w]=!0,X()})},X=()=>{if(p.absolute!==this.cwd){const ie=E(i.dirname(p.absolute));if(ie!==this.cwd)return this[B](ie,this.dmode,se=>{if(se){this[x](se,p),j();return}ue()})}ue()},ue=()=>{s.lstat(p.absolute,(ie,se)=>{if(se&&(this.keep||this.newer&&se.mtime>p.mtime)){this[N](p),j();return}if(ie||this[S](p,se))return this[v](null,p,j);if(se.isDirectory()){if(p.type==="Directory"){const le=!this.noChmod&&p.mode&&(se.mode&4095)!==p.mode,Fe=ye=>this[v](ye,p,j);return le?s.chmod(p.absolute,p.mode,Fe):Fe()}if(p.absolute!==this.cwd)return s.rmdir(p.absolute,le=>this[v](le,p,j))}if(p.absolute===this.cwd)return this[v](null,p,j);$(p.absolute,le=>this[v](le,p,j))})};this[w]?X():Z()}[v](p,k,j){if(p){this[x](p,k),j();return}switch(k.type){case"File":case"OldFile":case"ContiguousFile":return this[n](k,j);case"Link":return this[D](k,j);case"SymbolicLink":return this[d](k,j);case"Directory":case"GNUDumpDir":return this[l](k,j)}}[f](p,k,j,Z){s[j](k,p.absolute,X=>{X?this[x](X,p):(this[U](),p.resume()),Z()})}}const ce=te=>{try{return[null,te()]}catch(p){return[p,null]}};class Ge extends oe{[v](p,k){return super[v](p,k,()=>{})}[_](p){if(this[A](p),!this[w]){const X=this[B](this.cwd,this.dmode);if(X)return this[x](X,p);this[w]=!0}if(p.absolute!==this.cwd){const X=E(i.dirname(p.absolute));if(X!==this.cwd){const ue=this[B](X,this.dmode);if(ue)return this[x](ue,p)}}const[k,j]=ce(()=>s.lstatSync(p.absolute));if(j&&(this.keep||this.newer&&j.mtime>p.mtime))return this[N](p);if(k||this[S](p,j))return this[v](null,p);if(j.isDirectory()){if(p.type==="Directory"){const ue=!this.noChmod&&p.mode&&(j.mode&4095)!==p.mode,[ie]=ue?ce(()=>{s.chmodSync(p.absolute,p.mode)}):[];return this[v](ie,p)}const[X]=ce(()=>s.rmdirSync(p.absolute));this[v](X,p)}const[Z]=p.absolute===this.cwd?[]:ce(()=>q(p.absolute));this[v](Z,p)}[n](p,k){const j=p.mode&4095||this.fmode,Z=ie=>{let se;try{s.closeSync(X)}catch(le){se=le}(ie||se)&&this[x](ie||se,p),k()};let X;try{X=s.openSync(p.absolute,g(p.size),j)}catch(ie){return Z(ie)}const ue=this.transform&&this.transform(p)||p;ue!==p&&(ue.on("error",ie=>this[x](ie,p)),p.pipe(ue)),ue.on("data",ie=>{try{s.writeSync(X,ie,0,ie.length)}catch(se){Z(se)}}),ue.on("end",ie=>{let se=null;if(p.mtime&&!this.noMtime){const le=p.atime||new Date,Fe=p.mtime;try{s.futimesSync(X,le,Fe)}catch(ye){try{s.utimesSync(p.absolute,le,Fe)}catch{se=ye}}}if(this[V](p)){const le=this[W](p),Fe=this[ee](p);try{s.fchownSync(X,le,Fe)}catch(ye){try{s.chownSync(p.absolute,le,Fe)}catch{se=se||ye}}}Z(se)})}[l](p,k){const j=p.mode&4095||this.dmode,Z=this[B](p.absolute,j);if(Z){this[x](Z,p),k();return}if(p.mtime&&!this.noMtime)try{s.utimesSync(p.absolute,p.atime||new Date,p.mtime)}catch{}if(this[V](p))try{s.chownSync(p.absolute,this[W](p),this[ee](p))}catch{}k(),p.resume()}[B](p,k){try{return a.sync(E(p),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:k})}catch(j){return j}}[f](p,k,j,Z){try{s[j+"Sync"](k,p.absolute),Z(),p.resume()}catch(X){return this[x](X,p)}}}return oe.Sync=Ge,yi=oe,yi}var bi,fr;function Qn(){if(fr)return bi;fr=1;const u=Ie(),t=Dr(),s=ge,r=ke(),i=De,a=Pe();bi=(m,C,_)=>{typeof m=="function"?(_=m,C=null,m={}):Array.isArray(m)&&(C=m,m={}),typeof C=="function"&&(_=C,C=null),C?C=Array.from(C):C=[];const b=u(m);if(b.sync&&typeof _=="function")throw new TypeError("callback not supported for sync tar functions");if(!b.file&&typeof _=="function")throw new TypeError("callback only supported with file option");return C.length&&e(b,C),b.file&&b.sync?o(b):b.file?h(b,_):b.sync?E(b):y(b)};const e=(m,C)=>{const _=new Map(C.map(S=>[a(S),!0])),b=m.filter,A=(S,v)=>{const n=v||i.parse(S).root||".",l=S===n?!1:_.has(S)?_.get(S):A(i.dirname(S),n);return _.set(S,l),l};m.filter=b?(S,v)=>b(S,v)&&A(a(S)):S=>A(a(S))},o=m=>{const C=new t.Sync(m),_=m.file,b=s.statSync(_),A=m.maxReadSize||16*1024*1024;new r.ReadStreamSync(_,{readSize:A,size:b.size}).pipe(C)},h=(m,C)=>{const _=new t(m),b=m.maxReadSize||16*1024*1024,A=m.file,S=new Promise((v,n)=>{_.on("error",n),_.on("close",v),s.stat(A,(l,f)=>{if(l)n(l);else{const d=new r.ReadStream(A,{readSize:b,size:f.size});d.on("error",n),d.pipe(_)}})});return C?S.then(C,C):S},E=m=>new t.Sync(m),y=m=>new t(m);return bi}var dr;function eu(){return dr||(dr=1,he.c=he.create=jn(),he.r=he.replace=Ys(),he.t=he.list=ui(),he.u=he.update=Un(),he.x=he.extract=Qn(),he.Pack=ii(),he.Unpack=Dr(),he.Parse=ri(),he.ReadEntry=Ht(),he.WriteEntry=ks(),he.Header=Me(),he.Pax=qt(),he.types=Ss()),he}var tu=eu();class iu extends Error{}class mr extends Error{}class su extends Error{}class ru extends Error{}const pr=async(u,t)=>{const s=new URL(u),r=we.basename(s.pathname);return{name:r,version:void 0,subdir:void 0,url:s.href,tar:s.href,defaultDir:r,headers:t.auth?{Authorization:`Bearer ${t.auth}`}:void 0}},Er=async(u,t)=>{const s=rt(u),r=await _i(s,t,async()=>(await(await He(`https://api.github.com/repos/${s.repo}`)).json())?.default_branch);return{name:s.repo.replace("/","-"),version:r,subdir:s.subdir,headers:{...t.auth?{Authorization:`Bearer ${t.auth}`}:{},Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},url:`https://github.com/${s.repo}/tree/${r}${s.subdir}`,tar:`https://api.github.com/repos/${s.repo}/tarball/${r}`}},nu=async(u,t)=>{const s=rt(u),r=await _i(s,t,async()=>(await(await He(`https://gitlab.com/api/v4/projects/${encodeURIComponent(s.repo)}`)).json())?.default_branch);return{name:s.repo.replace("/","-"),version:r,subdir:s.subdir,headers:{...t.auth?{Authorization:`Bearer ${t.auth}`}:{},"sec-fetch-mode":"same-origin"},url:`https://gitlab.com/${s.repo}/tree/${r}${s.subdir}`,tar:`https://gitlab.com/${s.repo}/-/archive/${r}.tar.gz`}},uu=async(u,t)=>{const s=rt(u),r=await _i(s,t,async()=>(await(await He(`https://api.bitbucket.org/2.0/repositories/${s.repo}`)).json())?.mainbranch?.name);return{name:s.repo.replace("/","-"),version:r,subdir:s.subdir,headers:t.auth?{Authorization:`Bearer ${t.auth}`}:{},url:`https://bitbucket.com/${s.repo}/src/${r}${s.subdir}`,tar:`https://bitbucket.org/${s.repo}/get/${r}.tar.gz`}},ou=(u,t)=>{const s=rt(u),r=s.ref||"main";return{name:s.repo.replace("/","-"),version:r,subdir:s.subdir,headers:t.auth?{Authorization:`Bearer ${t.auth}`}:{},url:`https://git.sr.ht/~${s.repo}/tree/${r}/item${s.subdir}`,tar:`https://git.sr.ht/~${s.repo}/archive/${r}.tar.gz`}},au={http:pr,https:pr,github:Er,gh:Er,gitlab:nu,bitbucket:uu,sourcehut:ou};async function _i(u,t,s){if(u.ref)return u.ref;if(t.offline!==!0)try{const r=await s();if(r)return r}catch(r){wi(`Failed to fetch ref for ${u.repo}`,r)}return"main"}const hu=/^([\w-.]+):/;function lu(u,t,s){t||="github";let r=u;const i=u.match(hu);i&&(t=i[1],t!=="http"&&t!=="https"&&(r=u.slice(i[0].length)));const a=s?.[t]||au[t];return{source:r,providerName:t,provider:a}}async function cu(u,t,s={}){const r=t+".json",i=JSON.parse(await Oe.readFile(r,"utf8").catch(()=>"{}")),e=(await He(u,{...s,method:"HEAD"}).catch(()=>{}))?.headers.get("etag");if(i.etag===e&&Se.existsSync(t))return;typeof e=="string"&&(i.etag=e);const o=await He(u,{headers:s.headers});if(o.status>=400)throw new mr(`Failed to download ${u}: ${o.status} ${o.statusText}`);if(o.body==null)throw new mr(`Failed to download ${u}: empty response body`);await Oe.mkdir(we.dirname(t),{recursive:!0});const h=Se.createWriteStream(t);await Ri(Sr)(o.body,h),await Oe.writeFile(r,JSON.stringify(i),"utf8")}const Du=/^(?<repo>[\w\-.]+\/[\w\-.]+)(?<subdir>[^#]+)?(?<ref>#[\w\-./@]+)?/;function rt(u){const t=u.match(Du)?.groups||{};return{repo:t.repo,subdir:t.subdir||"/",ref:t.ref?.slice(1)}}function wi(...u){process.env.DEBUG&&console.debug("[giget]",...u)}async function He(u,t={}){t.headers?.["sec-fetch-mode"]&&(t.mode=t.headers["sec-fetch-mode"]);const s=await fetch(u,t).catch(r=>{throw new Error(`Failed to fetch ${u}`,{cause:r})});if(t.validateStatus&&s.status>=400)throw new Error(`Failed to fetch ${u}: ${s.status} ${s.statusText}`);return s}function fu(){return process.env.XDG_CACHE_HOME?we.resolve(process.env.XDG_CACHE_HOME,"bluwy-giget"):we.resolve(Ar.homedir(),".cache/bluwy-giget")}async function du(u,t,s){s==="/"&&(s=void 0),s&&(s.startsWith("/")&&(s=s.slice(1)),s.endsWith("/")||(s+="/"));let r=!1;if(await Oe.mkdir(t,{recursive:!0}),await tu.extract({file:u,cwd:t,onentry(i){i.path=i.path.split("/").splice(1).join("/"),s&&(i.path.startsWith(s)?(i.path=i.path.slice(s.length-1),r=!0):i.path="")}}),s&&!r)throw await Oe.rm(t,{recursive:!0,force:!0}),new su(`Subdirectory not found in tar: ${s}`)}async function mu(u,t={}){const{source:s,providerName:r,provider:i}=lu(u,t.provider,t.providers);if(!i)throw new iu(`Unsupported provider: ${r}`);const a={...t.providerOptions,offline:t.offline},e=await Promise.resolve().then(()=>i(s,a)).catch(m=>{throw new Error(`The ${r} provider failed with errors`,{cause:m})});e.name=(e.name||"template").replace(/[^\da-z-]/gi,"-"),e.defaultDir=(e.defaultDir||e.name).replace(/[^\da-z-]/gi,"-");const o=we.resolve(fu(),r,e.name),h=we.resolve(o,(e.version||e.name)+".tar.gz");if((t.offline==="prefer"?!Se.existsSync(h):!t.offline)&&(await cu(e.tar,h,{headers:e.headers}).catch(m=>{if(!Se.existsSync(h))throw m;wi("Download error. Using cached version:",m)}),wi(`Downloaded ${e.tar} to ${h}`)),!Se.existsSync(h))throw new Error(`Tarball not found: ${h} (offline: ${t.offline})`);const E=we.resolve(t.cwd||"."),y=we.resolve(E,t.dir||e.defaultDir);if(t.force==="clean")await Oe.rm(y,{recursive:!0,force:!0});else if(!t.force&&Se.existsSync(y)&&Se.readdirSync(y).length>0)throw new ru(`Destination ${y} already exists.`);return await du(h,y,e.subdir),{info:e,source:s,dir:y}}async function je({template:u,project:t}){await mu(`wrtnlabs/agentica.template.${u}`,{provider:"github",dir:t}),await _r(be(t,".github"),{force:!0,recursive:!0})}async function Ue({projectPath:u,dotEnvfileName:t,apiKeys:s}){if(!ot(u))throw new Error(`${u} directory does not exist.`);const r=be(u,t??".env"),i=(ot(r)?`
89
89
  `:"")+s.map(({key:a,value:e})=>`${a}=${e}`).join(`
90
- `);await wr(r,i)}function pu({packageManager:u,pkg:t}){switch(u){case"npm":return`npm install ${t??""}`;case"yarn":return t!=null?`yarn add ${t}`:"yarn";case"pnpm":return`pnpm install ${t??""}`;case"bun":return`bun install ${t??""}`;default:throw new Error(`Unsupported package manager: ${u}`)}}function Eu({packageManager:u,command:t}){switch(u){case"npm":return`npm run ${t}`;case"yarn":return`yarn ${t}`;case"pnpm":return`pnpm ${t}`;case"bun":return`bun ${t}`;default:throw new Error(`Unsupported package manager: ${u}`)}}function gu(){const u=ae.env.npm_config_user_agent;switch(!0){case u?.startsWith("npm"):return"npm";case u?.startsWith("yarn"):return"yarn";case u?.startsWith("pnpm"):return"pnpm";case u?.startsWith("bun"):return"bun";default:return"npm"}}const Cu=["nodejs","nestjs","react","react-native","standalone","nestjs+react","nodejs+react"];async function ze({packageManager:u,projectAbsolutePath:t,services:s}){const r=s.length>0?[...s.map(e=>$n(e))].join(" "):void 0,i=pu({packageManager:u,pkg:r}),a=rs();a.start("\u{1F4E6} Package installation in progress..."),await ps(i,{cwd:t}),a.stop("\u2705 Package installation completed")}async function vi({packageManager:u,projectAbsolutePath:t}){const s=Eu({packageManager:u,command:"prepare"}),r=rs();r.start("\u{1F4E6} Package installation in progress..."),await ps(s,{cwd:t}),r.stop("\u2705 Package installation completed")}async function Fu({template:u}){const t={template:u,services:[]};{const s=await Je({message:"Enter the project directory path:",placeholder:"./my-agentica-project",validate(i){if(i==="")return"Please enter a directory path";if(i[0]!==".")return"Please enter a relative path.";if(ot(i))return"Directory already exists"}});_e(s)&&ae.exit(0);const r=be(ae.cwd(),s);t.projectAbsolutePath=r}{const s=await ts({message:"Which package manager do you want to use?",initialValue:gu(),options:[{value:"npm",label:"npm"},{value:"pnpm",label:"pnpm"},{value:"yarn",label:`yarn (${pe.blueBright("berry is not supported")})`},{value:"bun",label:"bun"}]});_e(s)&&ae.exit(0),fe.info(`\u{1F4E6} Using ${s} as package manager`),t.packageManager=s}if(t.template==null){const s=await ts({message:"Which project type do you want to start?",options:[{value:"standalone",label:`Standalone ${pe.blueBright("Agent Server")}`},{value:"nodejs",label:`NodeJS ${pe.blueBright("Agent Server")}`},{value:"nestjs",label:`NestJS ${pe.blueBright("Agent Server")}`},{value:"react",label:`React ${pe.blueBright("Application")}`},{value:"react-native",label:`React Native ${pe.blueBright("Application")}`},{value:"nestjs+react",label:`NestJS + React ${pe.blueBright("Agent Server + Client Application")}`},{value:"nodejs+react",label:`NodeJS + React ${pe.blueBright("Agent Server + Client Application")}`}]});_e(s)&&ae.exit(0),t.template=s}if(t.template!=="standalone"){const s=await Je({message:"Server Port(if project is client app, this port mean ws server port):",initialValue:"3000",validate(r){if(Number.isNaN(Number.parseInt(r)))return"Port must be an integer"}});_e(s)&&ae.exit(0),t.port=Number(s)}if(t.template!=="react"){const s=await Ln(),r=s.sort((h,E)=>h.displayName.localeCompare(E.displayName)).map(({displayName:h,serviceName:E})=>({label:h,value:E})),i=await Cn({message:`Which connectors do you want to include? (Press ${pe.cyan("<space>")} to select, ${pe.cyan("<a>")} to select all, ${pe.cyan("<enter>")} to proceed)`,options:r,required:!1});_e(i)&&ae.exit(0),t.services=i;const a=Array.from(new Set(s.filter(h=>i.includes(h.serviceName)).flatMap(h=>h.envList))),e=await es({message:`Do you want to enter environment variables? (Number of environment variables to enter: ${a.length})
90
+ `);await wr(r,i)}function pu({packageManager:u,pkg:t}){switch(u){case"npm":return`npm install ${t??""}`;case"yarn":return t!=null?`yarn add ${t}`:"yarn";case"pnpm":return`pnpm install ${t??""}`;case"bun":return`bun install ${t??""}`;default:throw new Error(`Unsupported package manager: ${u}`)}}function Eu({packageManager:u,command:t}){switch(u){case"npm":return`npm run ${t}`;case"yarn":return`yarn ${t}`;case"pnpm":return`pnpm ${t}`;case"bun":return`bun ${t}`;default:throw new Error(`Unsupported package manager: ${u}`)}}function gu(){const u=ae.env.npm_config_user_agent;switch(!0){case u?.startsWith("npm"):return"npm";case u?.startsWith("yarn"):return"yarn";case u?.startsWith("pnpm"):return"pnpm";case u?.startsWith("bun"):return"bun";default:return"npm"}}const Cu=["nodejs","nestjs","react","react-native","standalone","nestjs+react","nodejs+react"];async function ze({packageManager:u,projectAbsolutePath:t,services:s}){const r=s.length>0?[...s.map(e=>$n(e))].join(" "):void 0,i=pu({packageManager:u,pkg:r}),a=rs();a.start("\u{1F4E6} Package installation in progress..."),await ps(i,{cwd:t}),a.stop("\u2705 Package installation completed")}async function vi({packageManager:u,projectAbsolutePath:t}){const s=Eu({packageManager:u,command:"prepare"}),r=rs();r.start("\u{1F4E6} Package installation in progress..."),await ps(s,{cwd:t}),r.stop("\u2705 Package installation completed")}async function Fu({template:u}){const t={template:u,services:[]};{const s=await Je({message:"Enter the project directory path:",placeholder:"./my-agentica-project",validate(i){if(i==="")return"Please enter a directory path";if(i[0]!==".")return"Please enter a relative path.";if(ot(i))return"Directory already exists"}});_e(s)&&ae.exit(0);const r=be(ae.cwd(),s);t.projectAbsolutePath=r}{const s=await ts({message:"Which package manager do you want to use?",initialValue:gu(),options:[{value:"npm",label:"npm"},{value:"pnpm",label:"pnpm"},{value:"yarn",label:`yarn (${pe.blueBright("berry is not supported")})`},{value:"bun",label:"bun"}]});_e(s)&&ae.exit(0),fe.info(`\u{1F4E6} Using ${s} as package manager`),t.packageManager=s}if(t.template==null){const s=await ts({message:"Which project type do you want to start?",options:[{value:"standalone",label:`Standalone ${pe.blueBright("Agent Server")}`},{value:"nodejs",label:`NodeJS ${pe.blueBright("Agent Server")}`},{value:"nestjs",label:`NestJS ${pe.blueBright("Agent Server")}`},{value:"react",label:`React ${pe.blueBright("Application")}`},{value:"react-native",label:`React Native ${pe.blueBright("Application")}`},{value:"nestjs+react",label:`NestJS + React ${pe.blueBright("Agent Server + Client Application")}`},{value:"nodejs+react",label:`NodeJS + React ${pe.blueBright("Agent Server + Client Application")}`}]});_e(s)&&ae.exit(0),t.template=s}if(t.template!=="standalone"){const s=await Je({message:"Server Port(if project is client app, this port mean ws server port):",initialValue:"3000",validate(r){if(Number.isNaN(Number.parseInt(r)))return"Port must be an integer"}});_e(s)&&ae.exit(0),t.port=Number(s)}if(t.template!=="react"){const s=await Ln(),r=s.sort((h,E)=>h.displayName.localeCompare(E.displayName)).map(({displayName:h,serviceName:E})=>({label:h,value:E})),i=await Cn({message:`Which connectors do you want to include? (Press ${pe.cyan("<space>")} to select, ${pe.cyan("<a>")} to select all, ${pe.cyan("<enter>")} to proceed)`,options:r,required:!1});_e(i)&&ae.exit(0),t.services=i;const a=Array.from(new Set(s.filter(h=>i.includes(h.serviceName)).flatMap(h=>h.envList))),e=a.length===0?!1:await es({message:`Do you want to enter environment variables? (Number of environment variables to enter: ${a.length})
91
91
  ${pe.cyan("If you press <ctrl+c>, you can skip this step.")}`,initialValue:!1}),o=[];if(_e(e)||!e)a.forEach(h=>{o.push({key:h,value:""})}),is("Skipping environment variables input.");else for(let h=0;h<a.length;h++){const E=a[h],y=await Je({message:`${E}: `,defaultValue:""});if(_e(y)){const m=a.splice(h);m.forEach(C=>{o.push({key:C,value:""})}),is(`Skipping environment variables input: ${m.slice(0,3).join(", ")}... (count: ${m.length})`);break}o.push({key:E,value:y})}t.envList=o}{const s=await es({message:"Enter your OpenAI API key?",initialValue:!1});if(_e(s)&&ae.exit(0),s){const r=await Je({message:"Please enter your OPENAI API key:"});_e(r)&&ae.exit(0),t.openAIKey=r}else t.openAIKey=null}try{(()=>{const s=h=>(h.packageManager==="npm"||h.packageManager==="yarn"||h.packageManager==="pnpm"||h.packageManager==="bun")&&typeof h.projectAbsolutePath=="string"&&(h.template==="nodejs"||h.template==="nestjs"||h.template==="react"||h.template==="react-native"||h.template==="standalone"||h.template==="nestjs+react"||h.template==="nodejs+react")&&(h.openAIKey===null||typeof h.openAIKey=="string")&&(h.port===void 0||typeof h.port=="number")&&Array.isArray(h.services)&&h.services.every(E=>typeof E=="string")&&(h.envList===void 0||Array.isArray(h.envList)&&h.envList.every(E=>typeof E=="object"&&E!==null&&r(E))),r=h=>typeof h.key=="string"&&typeof h.value=="string",i=(h,E,y=!0)=>(h.packageManager==="npm"||h.packageManager==="yarn"||h.packageManager==="pnpm"||h.packageManager==="bun"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".packageManager",expected:'("bun" | "npm" | "pnpm" | "yarn")',value:h.packageManager},o))&&(typeof h.projectAbsolutePath=="string"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".projectAbsolutePath",expected:"string",value:h.projectAbsolutePath},o))&&(h.template==="nodejs"||h.template==="nestjs"||h.template==="react"||h.template==="react-native"||h.template==="standalone"||h.template==="nestjs+react"||h.template==="nodejs+react"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".template",expected:'("nestjs" | "nestjs+react" | "nodejs" | "nodejs+react" | "react" | "react-native" | "standalone")',value:h.template},o))&&(h.openAIKey===null||typeof h.openAIKey=="string"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".openAIKey",expected:"(null | string)",value:h.openAIKey},o))&&(h.port===void 0||typeof h.port=="number"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".port",expected:"(number | undefined)",value:h.port},o))&&((Array.isArray(h.services)||re._assertGuard(y,{method:"typia.assertGuard",path:E+".services",expected:"Array<string>",value:h.services},o))&&h.services.every((m,C)=>typeof m=="string"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".services["+C+"]",expected:"string",value:m},o))||re._assertGuard(y,{method:"typia.assertGuard",path:E+".services",expected:"Array<string>",value:h.services},o))&&(h.envList===void 0||(Array.isArray(h.envList)||re._assertGuard(y,{method:"typia.assertGuard",path:E+".envList",expected:"(Array<__type> | undefined)",value:h.envList},o))&&h.envList.every((m,C)=>(typeof m=="object"&&m!==null||re._assertGuard(y,{method:"typia.assertGuard",path:E+".envList["+C+"]",expected:"__type.o1",value:m},o))&&a(m,E+".envList["+C+"]",y)||re._assertGuard(y,{method:"typia.assertGuard",path:E+".envList["+C+"]",expected:"__type.o1",value:m},o))||re._assertGuard(y,{method:"typia.assertGuard",path:E+".envList",expected:"(Array<__type> | undefined)",value:h.envList},o)),a=(h,E,y=!0)=>(typeof h.key=="string"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".key",expected:"string",value:h.key},o))&&(typeof h.value=="string"||re._assertGuard(y,{method:"typia.assertGuard",path:E+".value",expected:"string",value:h.value},o)),e=h=>typeof h=="object"&&h!==null&&s(h);let o;return(h,E)=>{e(h)===!1&&(o=E,((y,m,C=!0)=>(typeof y=="object"&&y!==null||re._assertGuard(!0,{method:"typia.assertGuard",path:m+"",expected:"__type",value:y},o))&&i(y,m+"",!0)||re._assertGuard(!0,{method:"typia.assertGuard",path:m+"",expected:"__type",value:y},o))(h,"$input",!0))}})()(t)}catch(s){throw new Error(`\u274C ${s.toString()}`)}return t}async function yu({projectAbsolutePath:u,context:t}){await je({template:"standalone",project:u}),fe.success("\u2705 Template downloaded");const s=xt(t.services),r=Bt(t.services),i=be(u,"src/index.ts"),a=await at(i,"utf-8"),e=Tt({content:a,importCode:s,connectorCode:r}),o=await Ot(e);await ht(i,o),await Ue({projectPath:u,apiKeys:[{key:"OPENAI_API_KEY",value:t.openAIKey??""},...t.envList??[]]}),fe.success("\u2705 .env created"),await ze({packageManager:t.packageManager,projectAbsolutePath:u,services:t.services}),await vi({packageManager:t.packageManager,projectAbsolutePath:u})}async function gr({projectAbsolutePath:u,context:t}){await je({template:"nodejs",project:u}),fe.success("\u2705 Template downloaded");const s=xt(t.services),r=Bt(t.services),i=be(u,"src/index.ts"),a=await at(i,"utf-8").then(h=>t.services.length===0?h:h.replace(/import \{ BbsArticleService \}.*;\n/g,"").replace(/controllers:\s*\[[\s\S]*?\],\n/,`controllers: [/// INSERT CONTROLLER HERE],
92
92
  `)),e=Tt({content:a,importCode:s,connectorCode:r}),o=await Ot(e);await ht(i,o),await Ue({projectPath:u,apiKeys:[{key:"OPENAI_API_KEY",value:t.openAIKey??""},{key:"PORT",value:t.port?.toString()??"3000"},...t.envList??[]]}),fe.success("\u2705 .env created"),await ze({packageManager:t.packageManager,projectAbsolutePath:u,services:t.services}),await vi({packageManager:t.packageManager,projectAbsolutePath:u})}async function Cr({projectAbsolutePath:u,context:t}){await je({template:"nestjs",project:u}),fe.success("\u2705 Template downloaded");const s=xt(t.services),r=Bt(t.services),i=be(u,"src/controllers/chat/ChatController.ts"),a=await at(i,"utf-8").then(h=>t.services.length===0?h:h.replace(/import \{ BbsArticleService \}.*;\n/g,"").replace(/controllers:\s*\[[\s\S]*?\],\n/,`controllers: [/// INSERT CONTROLLER HERE],
93
93
  `)),e=Tt({content:a,importCode:s,connectorCode:r}),o=await Ot(e);await ht(i,o),await Ue({projectPath:u,apiKeys:[{key:"OPENAI_API_KEY",value:t.openAIKey??""},{key:"API_PORT",value:t.port?.toString()??"3000"},...t.envList??[]]}),fe.success("\u2705 .env created"),await ze({packageManager:t.packageManager,projectAbsolutePath:u,services:t.services}),await vi({packageManager:t.packageManager,projectAbsolutePath:u})}async function Ai({projectAbsolutePath:u,context:t}){await je({template:"react",project:u}),fe.success("\u2705 Template downloaded"),await Ue({projectPath:u,apiKeys:[{key:"OPENAI_API_KEY",value:t.openAIKey??""},{key:"VITE_AGENTICA_WS_URL",value:`ws://localhost:${t.port}/chat`}]}),fe.success("\u2705 .env created"),await ze({packageManager:t.packageManager,projectAbsolutePath:u,services:t.services})}async function bu({projectAbsolutePath:u,context:t}){await je({template:"react-native",project:u}),fe.success("\u2705 Template downloaded"),await Ue({projectPath:u,apiKeys:[{key:"OPENAI_API_KEY",value:t.openAIKey??""}]}),fe.success("\u2705 .env created"),await ze({packageManager:t.packageManager,projectAbsolutePath:u,services:t.services})}async function _u({template:u}){ss("Agentica Start Wizard");const t=await Fu({template:u}),{projectAbsolutePath:s}=t;switch(t.template){case"standalone":await yu({projectAbsolutePath:s,context:t});break;case"nodejs":await gr({projectAbsolutePath:s,context:t});break;case"nestjs":await Cr({projectAbsolutePath:s,context:t});break;case"react":await Ai({projectAbsolutePath:s,context:t});break;case"react-native":await bu({projectAbsolutePath:s,context:t});break;case"nestjs+react":await Cr({projectAbsolutePath:be(s,"server"),context:t}),await Ai({projectAbsolutePath:be(s,"client"),context:t});break;case"nodejs+react":await gr({projectAbsolutePath:be(s,"server"),context:t}),await Ai({projectAbsolutePath:be(s,"client"),context:t});break;default:throw t.template,new Error(`\u274C Template ${t.template} not supported`)}Fn(`
94
94
  \u{1F389} Project ${s} created
95
95
  \u26A0\uFE0F ${pe.yellow("Note:")} Please implement constructor values for each controller generated in index.ts
96
- `)}const wu="0.20.0",nt=new An;nt.version(wu),nt.command("start").description("Start a new project").addOption(new Sn("-p, --project <project>","The project type").choices(Cu)).action(async u=>{ss(`\u{1F680} ${pe.blueBright("Agentica")} Setup Wizard`),await _u({template:u.project})});function vu(){nt.parse(ae.argv)}export{nt as program,vu as run};
96
+ `)}const wu="0.22.0",nt=new An;nt.version(wu),nt.command("start").description("Start a new project").addOption(new Sn("-p, --project <project>","The project type").choices(Cu)).action(async u=>{ss(`\u{1F680} ${pe.blueBright("Agentica")} Setup Wizard`),await _u({template:u.project})});function vu(){nt.parse(ae.argv)}export{nt as program,vu as run};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentica",
3
3
  "type": "module",
4
- "version": "0.20.0",
4
+ "version": "0.22.0",
5
5
  "description": "Agentic AI Library specialized in LLM Function Calling",
6
6
  "author": "Wrtn Technologies",
7
7
  "license": "MIT",