arial-cli 0.1.7 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +125 -2
  2. package/dist/index.js +47 -0
  3. package/package.json +35 -30
  4. package/dist/cli.js +0 -32076
package/README.md CHANGED
@@ -1,3 +1,126 @@
1
- # Arial
1
+ # arial-cli
2
2
 
3
- Arial is an open source CLI tool to interact with LLMs and build agents. Simple, powerful, scriptable.
3
+ Command-line interface for [Arial](https://arial.sh) dispatch coding jobs from your terminal.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g arial-cli
9
+ ```
10
+
11
+ ## Authentication
12
+
13
+ Get an API token from your Arial dashboard (Dashboard → Keys), then authenticate:
14
+
15
+ ```bash
16
+ arial login --token ak_your_token_here
17
+ ```
18
+
19
+ This saves your credentials to `~/.arial/config.json`.
20
+
21
+ ## Commands
22
+
23
+ ### dispatch
24
+
25
+ Dispatch a coding job to a repository:
26
+
27
+ ```bash
28
+ arial dispatch owner/repo "Add a logout button to the navbar"
29
+ ```
30
+
31
+ Read the prompt from a file:
32
+
33
+ ```bash
34
+ arial dispatch owner/repo -f task.md
35
+ ```
36
+
37
+ Options:
38
+ - `-f, --file <path>` — Read prompt from a file
39
+ - `--strategy <strategy>` — Execution strategy (`cruise` or `glide`, default: `cruise`)
40
+ - `--json` — Output as JSON
41
+
42
+ ### jobs
43
+
44
+ List recent jobs:
45
+
46
+ ```bash
47
+ arial jobs
48
+ ```
49
+
50
+ Inspect a specific job:
51
+
52
+ ```bash
53
+ arial jobs <job-id>
54
+ ```
55
+
56
+ Stream logs from a running job:
57
+
58
+ ```bash
59
+ arial jobs <job-id> --logs
60
+ ```
61
+
62
+ Cancel a job:
63
+
64
+ ```bash
65
+ arial jobs <job-id> --cancel
66
+ ```
67
+
68
+ Options:
69
+ - `--logs` — Stream job logs
70
+ - `--cancel` — Cancel the job
71
+ - `--stop` — Soft stop a running job
72
+ - `--json` — Output as JSON
73
+
74
+ ### repos
75
+
76
+ List connected GitHub repositories:
77
+
78
+ ```bash
79
+ arial repos
80
+ ```
81
+
82
+ Options:
83
+ - `--json` — Output as JSON
84
+
85
+ ### status
86
+
87
+ Show usage and job status overview:
88
+
89
+ ```bash
90
+ arial status
91
+ ```
92
+
93
+ Options:
94
+ - `--json` — Output as JSON
95
+
96
+ ### usage
97
+
98
+ Show detailed usage statistics for the current billing period:
99
+
100
+ ```bash
101
+ arial usage
102
+ ```
103
+
104
+ Options:
105
+ - `--json` — Output as JSON
106
+
107
+ ## Configuration
108
+
109
+ Configuration is stored in `~/.arial/config.json`:
110
+
111
+ ```json
112
+ {
113
+ "apiToken": "ak_...",
114
+ "apiUrl": "https://api.arial.sh"
115
+ }
116
+ ```
117
+
118
+ You can override the API URL during login:
119
+
120
+ ```bash
121
+ arial login --token ak_... --api-url https://custom-api.example.com
122
+ ```
123
+
124
+ ## License
125
+
126
+ MIT
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as q4}from"node:module";var t1=Object.create;var{getPrototypeOf:e1,defineProperty:Y0,getOwnPropertyNames:$4}=Object;var H4=Object.prototype.hasOwnProperty;var X4=($,H,X)=>{X=$!=null?t1(e1($)):{};let q=H||!$||!$.__esModule?Y0(X,"default",{value:$,enumerable:!0}):X;for(let J of $4($))if(!H4.call(q,J))Y0(q,J,{get:()=>$[J],enumerable:!0});return q};var M$=($,H)=>()=>(H||$((H={exports:{}}).exports,H),H.exports);var J4=($,H)=>{for(var X in H)Y0($,X,{get:H[X],enumerable:!0,configurable:!0,set:(q)=>H[X]=()=>q})};var g$=q4(import.meta.url);var m$=M$((G4)=>{class W0 extends Error{constructor($,H,X){super(X);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=H,this.exitCode=$,this.nestedError=void 0}}class y0 extends W0{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}G4.CommanderError=W0;G4.InvalidArgumentError=y0});var a$=M$((B4)=>{var{InvalidArgumentError:Y4}=m$();class Z0{constructor($,H){switch(this.description=H||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,H){if(H===this.defaultValue||!Array.isArray(H))return[$];return H.concat($)}default($,H){return this.defaultValue=$,this.defaultValueDescription=H,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(H,X)=>{if(!this.argChoices.includes(H))throw new Y4(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(H,X);return H},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function W4($){let H=$.name()+($.variadic===!0?"...":"");return $.required?"<"+H+">":"["+H+"]"}B4.Argument=Z0;B4.humanReadableArgName=W4});var B0=M$((R4)=>{var{humanReadableArgName:j4}=a$();class h0{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let H=$.commands.filter((q)=>!q._hidden),X=$._getHelpCommand();if(X&&!X._hidden)H.push(X);if(this.sortSubcommands)H.sort((q,J)=>{return q.name().localeCompare(J.name())});return H}compareOptions($,H){let X=(q)=>{return q.short?q.short.replace(/^-/,""):q.long.replace(/^--/,"")};return X($).localeCompare(X(H))}visibleOptions($){let H=$.options.filter((q)=>!q.hidden),X=$._getHelpOption();if(X&&!X.hidden){let q=X.short&&$._findOption(X.short),J=X.long&&$._findOption(X.long);if(!q&&!J)H.push(X);else if(X.long&&!J)H.push($.createOption(X.long,X.description));else if(X.short&&!q)H.push($.createOption(X.short,X.description))}if(this.sortOptions)H.sort(this.compareOptions);return H}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let H=[];for(let X=$.parent;X;X=X.parent){let q=X.options.filter((J)=>!J.hidden);H.push(...q)}if(this.sortOptions)H.sort(this.compareOptions);return H}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((H)=>{H.description=H.description||$._argsDescription[H.name()]||""});if($.registeredArguments.find((H)=>H.description))return $.registeredArguments;return[]}subcommandTerm($){let H=$.registeredArguments.map((X)=>j4(X)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(H?" "+H:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,H){return H.visibleCommands($).reduce((X,q)=>{return Math.max(X,this.displayWidth(H.styleSubcommandTerm(H.subcommandTerm(q))))},0)}longestOptionTermLength($,H){return H.visibleOptions($).reduce((X,q)=>{return Math.max(X,this.displayWidth(H.styleOptionTerm(H.optionTerm(q))))},0)}longestGlobalOptionTermLength($,H){return H.visibleGlobalOptions($).reduce((X,q)=>{return Math.max(X,this.displayWidth(H.styleOptionTerm(H.optionTerm(q))))},0)}longestArgumentTermLength($,H){return H.visibleArguments($).reduce((X,q)=>{return Math.max(X,this.displayWidth(H.styleArgumentTerm(H.argumentTerm(q))))},0)}commandUsage($){let H=$._name;if($._aliases[0])H=H+"|"+$._aliases[0];let X="";for(let q=$.parent;q;q=q.parent)X=q.name()+" "+X;return X+H+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let H=[];if($.argChoices)H.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")H.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)H.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)H.push(`env: ${$.envVar}`);if(H.length>0)return`${$.description} (${H.join(", ")})`;return $.description}argumentDescription($){let H=[];if($.argChoices)H.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0)H.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(H.length>0){let X=`(${H.join(", ")})`;if($.description)return`${$.description} ${X}`;return X}return $.description}formatHelp($,H){let X=H.padWidth($,H),q=H.helpWidth??80;function J(j,N){return H.formatItem(j,X,N,H)}let _=[`${H.styleTitle("Usage:")} ${H.styleUsage(H.commandUsage($))}`,""],Q=H.commandDescription($);if(Q.length>0)_=_.concat([H.boxWrap(H.styleCommandDescription(Q),q),""]);let Y=H.visibleArguments($).map((j)=>{return J(H.styleArgumentTerm(H.argumentTerm(j)),H.styleArgumentDescription(H.argumentDescription(j)))});if(Y.length>0)_=_.concat([H.styleTitle("Arguments:"),...Y,""]);let W=H.visibleOptions($).map((j)=>{return J(H.styleOptionTerm(H.optionTerm(j)),H.styleOptionDescription(H.optionDescription(j)))});if(W.length>0)_=_.concat([H.styleTitle("Options:"),...W,""]);if(H.showGlobalOptions){let j=H.visibleGlobalOptions($).map((N)=>{return J(H.styleOptionTerm(H.optionTerm(N)),H.styleOptionDescription(H.optionDescription(N)))});if(j.length>0)_=_.concat([H.styleTitle("Global Options:"),...j,""])}let B=H.visibleCommands($).map((j)=>{return J(H.styleSubcommandTerm(H.subcommandTerm(j)),H.styleSubcommandDescription(H.subcommandDescription(j)))});if(B.length>0)_=_.concat([H.styleTitle("Commands:"),...B,""]);return _.join(`
3
+ `)}displayWidth($){return g0($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((H)=>{if(H==="[options]")return this.styleOptionText(H);if(H==="[command]")return this.styleSubcommandText(H);if(H[0]==="["||H[0]==="<")return this.styleArgumentText(H);return this.styleCommandText(H)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((H)=>{if(H==="[options]")return this.styleOptionText(H);if(H[0]==="["||H[0]==="<")return this.styleArgumentText(H);return this.styleSubcommandText(H)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,H){return Math.max(H.longestOptionTermLength($,H),H.longestGlobalOptionTermLength($,H),H.longestSubcommandTermLength($,H),H.longestArgumentTermLength($,H))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,H,X,q){let _=" ".repeat(2);if(!X)return _+$;let Q=$.padEnd(H+$.length-q.displayWidth($)),Y=2,B=(this.helpWidth??80)-H-Y-2,j;if(B<this.minWidthToWrap||q.preformatted(X))j=X;else j=q.boxWrap(X,B).replace(/\n/g,`
4
+ `+" ".repeat(H+Y));return _+Q+" ".repeat(Y)+j.replace(/\n/g,`
5
+ ${_}`)}boxWrap($,H){if(H<this.minWidthToWrap)return $;let X=$.split(/\r\n|\n/),q=/[\s]*[^\s]+/g,J=[];return X.forEach((_)=>{let Q=_.match(q);if(Q===null){J.push("");return}let Y=[Q.shift()],W=this.displayWidth(Y[0]);Q.forEach((B)=>{let j=this.displayWidth(B);if(W+j<=H){Y.push(B),W+=j;return}J.push(Y.join(""));let N=B.trimStart();Y=[N],W=this.displayWidth(N)}),J.push(Y.join(""))}),J.join(`
6
+ `)}}function g0($){let H=/\x1b\[\d*(;\d*)*m/g;return $.replace(H,"")}R4.Help=h0;R4.stripColor=g0});var M0=M$((A4)=>{var{InvalidArgumentError:w4}=m$();class l0{constructor($,H){this.flags=$,this.description=H||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let X=N4($);if(this.short=X.shortFlag,this.long=X.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default($,H){return this.defaultValue=$,this.defaultValueDescription=H,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let H=$;if(typeof $==="string")H={[$]:!0};return this.implied=Object.assign(this.implied||{},H),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,H){if(H===this.defaultValue||!Array.isArray(H))return[$];return H.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(H,X)=>{if(!this.argChoices.includes(H))throw new w4(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(H,X);return H},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return m0(this.name().replace(/^no-/,""));return m0(this.name())}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class u0{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((H)=>{if(H.negate)this.negativeOptions.set(H.attributeName(),H);else this.positiveOptions.set(H.attributeName(),H)}),this.negativeOptions.forEach((H,X)=>{if(this.positiveOptions.has(X))this.dualOptions.add(X)})}valueFromOption($,H){let X=H.attributeName();if(!this.dualOptions.has(X))return!0;let q=this.negativeOptions.get(X).presetArg,J=q!==void 0?q:!1;return H.negate===(J===$)}}function m0($){return $.split("-").reduce((H,X)=>{return H+X[0].toUpperCase()+X.slice(1)})}function N4($){let H,X,q=/^-[^-]$/,J=/^--[^-]/,_=$.split(/[ |,]+/).concat("guard");if(q.test(_[0]))H=_.shift();if(J.test(_[0]))X=_.shift();if(!H&&q.test(_[0]))H=_.shift();if(!H&&J.test(_[0]))H=X,X=_.shift();if(_[0].startsWith("-")){let Q=_[0],Y=`option creation failed due to '${Q}' in option flags '${$}'`;if(/^-[^-][^-]/.test(Q))throw Error(`${Y}
7
+ - a short flag is a single dash and a single character
8
+ - either use a single dash and a single character (for a short flag)
9
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(q.test(Q))throw Error(`${Y}
10
+ - too many short flags`);if(J.test(Q))throw Error(`${Y}
11
+ - too many long flags`);throw Error(`${Y}
12
+ - unrecognised flag format`)}if(H===void 0&&X===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:H,longFlag:X}}A4.Option=l0;A4.DualOptions=u0});var c0=M$((O4)=>{function K4($,H){if(Math.abs($.length-H.length)>3)return Math.max($.length,H.length);let X=[];for(let q=0;q<=$.length;q++)X[q]=[q];for(let q=0;q<=H.length;q++)X[0][q]=q;for(let q=1;q<=H.length;q++)for(let J=1;J<=$.length;J++){let _=1;if($[J-1]===H[q-1])_=0;else _=1;if(X[J][q]=Math.min(X[J-1][q]+1,X[J][q-1]+1,X[J-1][q-1]+_),J>1&&q>1&&$[J-1]===H[q-2]&&$[J-2]===H[q-1])X[J][q]=Math.min(X[J][q],X[J-2][q-2]+1)}return X[$.length][H.length]}function S4($,H){if(!H||H.length===0)return"";H=Array.from(new Set(H));let X=$.startsWith("--");if(X)$=$.slice(2),H=H.map((Q)=>Q.slice(2));let q=[],J=3,_=0.4;if(H.forEach((Q)=>{if(Q.length<=1)return;let Y=K4($,Q),W=Math.max($.length,Q.length);if((W-Y)/W>_){if(Y<J)J=Y,q=[Q];else if(Y===J)q.push(Q)}}),q.sort((Q,Y)=>Q.localeCompare(Y)),X)q=q.map((Q)=>`--${Q}`);if(q.length>1)return`
13
+ (Did you mean one of ${q.join(", ")}?)`;if(q.length===1)return`
14
+ (Did you mean ${q[0]}?)`;return""}O4.suggestSimilar=S4});var n0=M$((z4)=>{var f4=g$("node:events").EventEmitter,U0=g$("node:child_process"),t=g$("node:path"),s$=g$("node:fs"),K=g$("node:process"),{Argument:b4,humanReadableArgName:I4}=a$(),{CommanderError:j0}=m$(),{Help:k4,stripColor:C4}=B0(),{Option:i0,DualOptions:P4}=M0(),{suggestSimilar:p0}=c0();class L0 extends f4{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(H)=>K.stdout.write(H),writeErr:(H)=>K.stderr.write(H),outputError:(H,X)=>X(H),getOutHelpWidth:()=>K.stdout.isTTY?K.stdout.columns:void 0,getErrHelpWidth:()=>K.stderr.isTTY?K.stderr.columns:void 0,getOutHasColors:()=>R0()??(K.stdout.isTTY&&K.stdout.hasColors?.()),getErrHasColors:()=>R0()??(K.stderr.isTTY&&K.stderr.hasColors?.()),stripColor:(H)=>C4(H)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let H=this;H;H=H.parent)$.push(H);return $}command($,H,X){let q=H,J=X;if(typeof q==="object"&&q!==null)J=q,q=null;J=J||{};let[,_,Q]=$.match(/([^ ]+) *(.*)/),Y=this.createCommand(_);if(q)Y.description(q),Y._executableHandler=!0;if(J.isDefault)this._defaultCommandName=Y._name;if(Y._hidden=!!(J.noHelp||J.hidden),Y._executableFile=J.executableFile||null,Q)Y.arguments(Q);if(this._registerCommand(Y),Y.parent=this,Y.copyInheritedSettings(this),q)return this;return Y}createCommand($){return new L0($)}createHelp(){return Object.assign(new k4,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,H){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);if(H=H||{},H.isDefault)this._defaultCommandName=$._name;if(H.noHelp||H.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,H){return new b4($,H)}argument($,H,X,q){let J=this.createArgument($,H);if(typeof X==="function")J.default(q).argParser(X);else J.default(X);return this.addArgument(J),this}arguments($){return $.trim().split(/ +/).forEach((H)=>{this.argument(H)}),this}addArgument($){let H=this.registeredArguments.slice(-1)[0];if(H&&H.variadic)throw Error(`only the last argument can be variadic '${H.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,H){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,X,q]=$.match(/([^ ]+) *(.*)/),J=H??"display help for command",_=this.createCommand(X);if(_.helpOption(!1),q)_.arguments(q);if(J)_.description(J);return this._addImplicitHelpCommand=!0,this._helpCommand=_,this}addHelpCommand($,H){if(typeof $!=="object")return this.helpCommand($,H),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,H){let X=["preSubcommand","preAction","postAction"];if(!X.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
16
+ Expecting one of '${X.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(H);else this._lifeCycleHooks[$]=[H];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(H)=>{if(H.code!=="commander.executeSubCommandAsync")throw H};return this}_exit($,H,X){if(this._exitCallback)this._exitCallback(new j0($,H,X));K.exit($)}action($){let H=(X)=>{let q=this.registeredArguments.length,J=X.slice(0,q);if(this._storeOptionsAsProperties)J[q]=this;else J[q]=this.opts();return J.push(this),$.apply(this,J)};return this._actionHandler=H,this}createOption($,H){return new i0($,H)}_callParseArg($,H,X,q){try{return $.parseArg(H,X)}catch(J){if(J.code==="commander.invalidArgument"){let _=`${q} ${J.message}`;this.error(_,{exitCode:J.exitCode,code:J.code})}throw J}}_registerOption($){let H=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(H){let X=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${X}'
17
+ - already used by option '${H.flags}'`)}this.options.push($)}_registerCommand($){let H=(q)=>{return[q.name()].concat(q.aliases())},X=H($).find((q)=>this._findCommand(q));if(X){let q=H(this._findCommand(X)).join("|"),J=H($).join("|");throw Error(`cannot add command '${J}' as already have command '${q}'`)}this.commands.push($)}addOption($){this._registerOption($);let H=$.name(),X=$.attributeName();if($.negate){let J=$.long.replace(/^--no-/,"--");if(!this._findOption(J))this.setOptionValueWithSource(X,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(X,$.defaultValue,"default");let q=(J,_,Q)=>{if(J==null&&$.presetArg!==void 0)J=$.presetArg;let Y=this.getOptionValue(X);if(J!==null&&$.parseArg)J=this._callParseArg($,J,Y,_);else if(J!==null&&$.variadic)J=$._concatValue(J,Y);if(J==null)if($.negate)J=!1;else if($.isBoolean()||$.optional)J=!0;else J="";this.setOptionValueWithSource(X,J,Q)};if(this.on("option:"+H,(J)=>{let _=`error: option '${$.flags}' argument '${J}' is invalid.`;q(J,_,"cli")}),$.envVar)this.on("optionEnv:"+H,(J)=>{let _=`error: option '${$.flags}' value '${J}' from env '${$.envVar}' is invalid.`;q(J,_,"env")});return this}_optionEx($,H,X,q,J){if(typeof H==="object"&&H instanceof i0)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let _=this.createOption(H,X);if(_.makeOptionMandatory(!!$.mandatory),typeof q==="function")_.default(J).argParser(q);else if(q instanceof RegExp){let Q=q;q=(Y,W)=>{let B=Q.exec(Y);return B?B[0]:W},_.default(J).argParser(q)}else _.default(q);return this.addOption(_)}option($,H,X,q){return this._optionEx({},$,H,X,q)}requiredOption($,H,X,q){return this._optionEx({mandatory:!0},$,H,X,q)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,H){return this.setOptionValueWithSource($,H,void 0)}setOptionValueWithSource($,H,X){if(this._storeOptionsAsProperties)this[$]=H;else this._optionValues[$]=H;return this._optionValueSources[$]=X,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let H;return this._getCommandAndAncestors().forEach((X)=>{if(X.getOptionValueSource($)!==void 0)H=X.getOptionValueSource($)}),H}_prepareUserArgs($,H){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(H=H||{},$===void 0&&H.from===void 0){if(K.versions?.electron)H.from="electron";let q=K.execArgv??[];if(q.includes("-e")||q.includes("--eval")||q.includes("-p")||q.includes("--print"))H.from="eval"}if($===void 0)$=K.argv;this.rawArgs=$.slice();let X;switch(H.from){case void 0:case"node":this._scriptPath=$[1],X=$.slice(2);break;case"electron":if(K.defaultApp)this._scriptPath=$[1],X=$.slice(2);else X=$.slice(1);break;case"user":X=$.slice(0);break;case"eval":X=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${H.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",X}parse($,H){this._prepareForParse();let X=this._prepareUserArgs($,H);return this._parseCommand([],X),this}async parseAsync($,H){this._prepareForParse();let X=this._prepareUserArgs($,H);return await this._parseCommand([],X),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
18
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,H,X){if(s$.existsSync($))return;let q=H?`searched for local subcommand relative to directory '${H}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",J=`'${$}' does not exist
19
+ - if '${X}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
+ - ${q}`;throw Error(J)}_executeSubCommand($,H){H=H.slice();let X=!1,q=[".js",".ts",".tsx",".mjs",".cjs"];function J(B,j){let N=t.resolve(B,j);if(s$.existsSync(N))return N;if(q.includes(t.extname(j)))return;let Z=q.find((X$)=>s$.existsSync(`${N}${X$}`));if(Z)return`${N}${Z}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let _=$._executableFile||`${this._name}-${$._name}`,Q=this._executableDir||"";if(this._scriptPath){let B;try{B=s$.realpathSync(this._scriptPath)}catch{B=this._scriptPath}Q=t.resolve(t.dirname(B),Q)}if(Q){let B=J(Q,_);if(!B&&!$._executableFile&&this._scriptPath){let j=t.basename(this._scriptPath,t.extname(this._scriptPath));if(j!==this._name)B=J(Q,`${j}-${$._name}`)}_=B||_}X=q.includes(t.extname(_));let Y;if(K.platform!=="win32")if(X)H.unshift(_),H=d0(K.execArgv).concat(H),Y=U0.spawn(K.argv[0],H,{stdio:"inherit"});else Y=U0.spawn(_,H,{stdio:"inherit"});else this._checkForMissingExecutable(_,Q,$._name),H.unshift(_),H=d0(K.execArgv).concat(H),Y=U0.spawn(K.execPath,H,{stdio:"inherit"});if(!Y.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((j)=>{K.on(j,()=>{if(Y.killed===!1&&Y.exitCode===null)Y.kill(j)})});let W=this._exitCallback;Y.on("close",(B)=>{if(B=B??1,!W)K.exit(B);else W(new j0(B,"commander.executeSubCommandAsync","(close)"))}),Y.on("error",(B)=>{if(B.code==="ENOENT")this._checkForMissingExecutable(_,Q,$._name);else if(B.code==="EACCES")throw Error(`'${_}' not executable`);if(!W)K.exit(1);else{let j=new j0(1,"commander.executeSubCommandAsync","(error)");j.nestedError=B,W(j)}}),this.runningCommand=Y}_dispatchSubcommand($,H,X){let q=this._findCommand($);if(!q)this.help({error:!0});q._prepareForParse();let J;return J=this._chainOrCallSubCommandHook(J,q,"preSubcommand"),J=this._chainOrCall(J,()=>{if(q._executableHandler)this._executeSubCommand(q,H.concat(X));else return q._parseCommand(H,X)}),J}_dispatchHelpCommand($){if(!$)this.help();let H=this._findCommand($);if(H&&!H._executableHandler)H.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,H)=>{if($.required&&this.args[H]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(X,q,J)=>{let _=q;if(q!==null&&X.parseArg){let Q=`error: command-argument value '${q}' is invalid for argument '${X.name()}'.`;_=this._callParseArg(X,q,J,Q)}return _};this._checkNumberOfArguments();let H=[];this.registeredArguments.forEach((X,q)=>{let J=X.defaultValue;if(X.variadic){if(q<this.args.length){if(J=this.args.slice(q),X.parseArg)J=J.reduce((_,Q)=>{return $(X,Q,_)},X.defaultValue)}else if(J===void 0)J=[]}else if(q<this.args.length){if(J=this.args[q],X.parseArg)J=$(X,J,X.defaultValue)}H[q]=J}),this.processedArgs=H}_chainOrCall($,H){if($&&$.then&&typeof $.then==="function")return $.then(()=>H());return H()}_chainOrCallHooks($,H){let X=$,q=[];if(this._getCommandAndAncestors().reverse().filter((J)=>J._lifeCycleHooks[H]!==void 0).forEach((J)=>{J._lifeCycleHooks[H].forEach((_)=>{q.push({hookedCommand:J,callback:_})})}),H==="postAction")q.reverse();return q.forEach((J)=>{X=this._chainOrCall(X,()=>{return J.callback(J.hookedCommand,this)})}),X}_chainOrCallSubCommandHook($,H,X){let q=$;if(this._lifeCycleHooks[X]!==void 0)this._lifeCycleHooks[X].forEach((J)=>{q=this._chainOrCall(q,()=>{return J(this,H)})});return q}_parseCommand($,H){let X=this.parseOptions(H);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(X.operands),H=X.unknown,this.args=$.concat(H),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),H);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(H),this._dispatchSubcommand(this._defaultCommandName,$,H);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(X.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let q=()=>{if(X.unknown.length>0)this.unknownOption(X.unknown[0])},J=`command:${this.name()}`;if(this._actionHandler){q(),this._processArguments();let _;if(_=this._chainOrCallHooks(_,"preAction"),_=this._chainOrCall(_,()=>this._actionHandler(this.processedArgs)),this.parent)_=this._chainOrCall(_,()=>{this.parent.emit(J,$,H)});return _=this._chainOrCallHooks(_,"postAction"),_}if(this.parent&&this.parent.listenerCount(J))q(),this._processArguments(),this.parent.emit(J,$,H);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,H);if(this.listenerCount("command:*"))this.emit("command:*",$,H);else if(this.commands.length)this.unknownCommand();else q(),this._processArguments()}else if(this.commands.length)q(),this.help({error:!0});else q(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((H)=>H._name===$||H._aliases.includes($))}_findOption($){return this.options.find((H)=>H.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((H)=>{if(H.mandatory&&$.getOptionValue(H.attributeName())===void 0)$.missingMandatoryOptionValue(H)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((X)=>{let q=X.attributeName();if(this.getOptionValue(q)===void 0)return!1;return this.getOptionValueSource(q)!=="default"});$.filter((X)=>X.conflictsWith.length>0).forEach((X)=>{let q=$.find((J)=>X.conflictsWith.includes(J.attributeName()));if(q)this._conflictingOption(X,q)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let H=[],X=[],q=H,J=$.slice();function _(Y){return Y.length>1&&Y[0]==="-"}let Q=null;while(J.length){let Y=J.shift();if(Y==="--"){if(q===X)q.push(Y);q.push(...J);break}if(Q&&!_(Y)){this.emit(`option:${Q.name()}`,Y);continue}if(Q=null,_(Y)){let W=this._findOption(Y);if(W){if(W.required){let B=J.shift();if(B===void 0)this.optionMissingArgument(W);this.emit(`option:${W.name()}`,B)}else if(W.optional){let B=null;if(J.length>0&&!_(J[0]))B=J.shift();this.emit(`option:${W.name()}`,B)}else this.emit(`option:${W.name()}`);Q=W.variadic?W:null;continue}}if(Y.length>2&&Y[0]==="-"&&Y[1]!=="-"){let W=this._findOption(`-${Y[1]}`);if(W){if(W.required||W.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${W.name()}`,Y.slice(2));else this.emit(`option:${W.name()}`),J.unshift(`-${Y.slice(2)}`);continue}}if(/^--[^=]+=/.test(Y)){let W=Y.indexOf("="),B=this._findOption(Y.slice(0,W));if(B&&(B.required||B.optional)){this.emit(`option:${B.name()}`,Y.slice(W+1));continue}}if(_(Y))q=X;if((this._enablePositionalOptions||this._passThroughOptions)&&H.length===0&&X.length===0){if(this._findCommand(Y)){if(H.push(Y),J.length>0)X.push(...J);break}else if(this._getHelpCommand()&&Y===this._getHelpCommand().name()){if(H.push(Y),J.length>0)H.push(...J);break}else if(this._defaultCommandName){if(X.push(Y),J.length>0)X.push(...J);break}}if(this._passThroughOptions){if(q.push(Y),J.length>0)q.push(...J);break}q.push(Y)}return{operands:H,unknown:X}}opts(){if(this._storeOptionsAsProperties){let $={},H=this.options.length;for(let X=0;X<H;X++){let q=this.options[X].attributeName();$[q]=q===this._versionOptionName?this._version:this[q]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,H)=>Object.assign($,H.opts()),{})}error($,H){if(this._outputConfiguration.outputError(`${$}
22
+ `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
+ `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
24
+ `),this.outputHelp({error:!0});let X=H||{},q=X.exitCode||1,J=X.code||"commander.error";this._exit(q,J,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in K.env){let H=$.attributeName();if(this.getOptionValue(H)===void 0||["default","config","env"].includes(this.getOptionValueSource(H)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,K.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new P4(this.options),H=(X)=>{return this.getOptionValue(X)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(X))};this.options.filter((X)=>X.implied!==void 0&&H(X.attributeName())&&$.valueFromOption(this.getOptionValue(X.attributeName()),X)).forEach((X)=>{Object.keys(X.implied).filter((q)=>!H(q)).forEach((q)=>{this.setOptionValueWithSource(q,X.implied[q],"implied")})})}missingArgument($){let H=`error: missing required argument '${$}'`;this.error(H,{code:"commander.missingArgument"})}optionMissingArgument($){let H=`error: option '${$.flags}' argument missing`;this.error(H,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let H=`error: required option '${$.flags}' not specified`;this.error(H,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,H){let X=(_)=>{let Q=_.attributeName(),Y=this.getOptionValue(Q),W=this.options.find((j)=>j.negate&&Q===j.attributeName()),B=this.options.find((j)=>!j.negate&&Q===j.attributeName());if(W&&(W.presetArg===void 0&&Y===!1||W.presetArg!==void 0&&Y===W.presetArg))return W;return B||_},q=(_)=>{let Q=X(_),Y=Q.attributeName();if(this.getOptionValueSource(Y)==="env")return`environment variable '${Q.envVar}'`;return`option '${Q.flags}'`},J=`error: ${q($)} cannot be used with ${q(H)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let H="";if($.startsWith("--")&&this._showSuggestionAfterError){let q=[],J=this;do{let _=J.createHelp().visibleOptions(J).filter((Q)=>Q.long).map((Q)=>Q.long);q=q.concat(_),J=J.parent}while(J&&!J._enablePositionalOptions);H=p0($,q)}let X=`error: unknown option '${$}'${H}`;this.error(X,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let H=this.registeredArguments.length,X=H===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${H} argument${X} but got ${$.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],H="";if(this._showSuggestionAfterError){let q=[];this.createHelp().visibleCommands(this).forEach((J)=>{if(q.push(J.name()),J.alias())q.push(J.alias())}),H=p0($,q)}let X=`error: unknown command '${$}'${H}`;this.error(X,{code:"commander.unknownCommand"})}version($,H,X){if($===void 0)return this._version;this._version=$,H=H||"-V, --version",X=X||"output the version number";let q=this.createOption(H,X);return this._versionOptionName=q.attributeName(),this._registerOption(q),this.on("option:"+q.name(),()=>{this._outputConfiguration.writeOut(`${$}
25
+ `),this._exit(0,"commander.version",$)}),this}description($,H){if($===void 0&&H===void 0)return this._description;if(this._description=$,H)this._argsDescription=H;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let H=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)H=this.commands[this.commands.length-1];if($===H._name)throw Error("Command alias can't be the same as its name");let X=this.parent?._findCommand($);if(X){let q=[X.name()].concat(X.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${q}'`)}return H._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((H)=>this.alias(H)),this}usage($){if($===void 0){if(this._usage)return this._usage;let H=this.registeredArguments.map((X)=>{return I4(X)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?H:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=t.basename($,t.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let H=this.createHelp(),X=this._getOutputContext($);H.prepareContext({error:X.error,helpWidth:X.helpWidth,outputHasColors:X.hasColors});let q=H.formatHelp(this,H);if(X.hasColors)return q;return this._outputConfiguration.stripColor(q)}_getOutputContext($){$=$||{};let H=!!$.error,X,q,J;if(H)X=(Q)=>this._outputConfiguration.writeErr(Q),q=this._outputConfiguration.getErrHasColors(),J=this._outputConfiguration.getErrHelpWidth();else X=(Q)=>this._outputConfiguration.writeOut(Q),q=this._outputConfiguration.getOutHasColors(),J=this._outputConfiguration.getOutHelpWidth();return{error:H,write:(Q)=>{if(!q)Q=this._outputConfiguration.stripColor(Q);return X(Q)},hasColors:q,helpWidth:J}}outputHelp($){let H;if(typeof $==="function")H=$,$=void 0;let X=this._getOutputContext($),q={error:X.error,write:X.write,command:this};this._getCommandAndAncestors().reverse().forEach((_)=>_.emit("beforeAllHelp",q)),this.emit("beforeHelp",q);let J=this.helpInformation({error:X.error});if(H){if(J=H(J),typeof J!=="string"&&!Buffer.isBuffer(J))throw Error("outputHelp callback must return a string or a Buffer")}if(X.write(J),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",q),this._getCommandAndAncestors().forEach((_)=>_.emit("afterAllHelp",q))}helpOption($,H){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",H=H??"display help for command",this._helpOption=this.createOption($,H),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let H=Number(K.exitCode??0);if(H===0&&$&&typeof $!=="function"&&$.error)H=1;this._exit(H,"commander.help","(outputHelp)")}addHelpText($,H){let X=["beforeAll","before","after","afterAll"];if(!X.includes($))throw Error(`Unexpected value for position to addHelpText.
26
+ Expecting one of '${X.join("', '")}'`);let q=`${$}Help`;return this.on(q,(J)=>{let _;if(typeof H==="function")_=H({error:J.error,command:J.command});else _=H;if(_)J.write(`${_}
27
+ `)}),this}_outputHelpIfRequested($){let H=this._getHelpOption();if(H&&$.find((q)=>H.is(q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function d0($){return $.map((H)=>{if(!H.startsWith("--inspect"))return H;let X,q="127.0.0.1",J="9229",_;if((_=H.match(/^(--inspect(-brk)?)$/))!==null)X=_[1];else if((_=H.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(X=_[1],/^\d+$/.test(_[3]))J=_[3];else q=_[3];else if((_=H.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)X=_[1],q=_[3],J=_[4];if(X&&J!=="0")return`${X}=${q}:${parseInt(J)+1}`;return H})}function R0(){if(K.env.NO_COLOR||K.env.FORCE_COLOR==="0"||K.env.FORCE_COLOR==="false")return!1;if(K.env.FORCE_COLOR||K.env.CLICOLOR_FORCE!==void 0)return!0;return}z4.Command=L0;z4.useColor=R0});var s0=M$((Z4)=>{var{Argument:r0}=a$(),{Command:V0}=n0(),{CommanderError:x4,InvalidArgumentError:o0}=m$(),{Help:y4}=B0(),{Option:a0}=M0();Z4.program=new V0;Z4.createCommand=($)=>new V0($);Z4.createOption=($,H)=>new a0($,H);Z4.createArgument=($,H)=>new r0($,H);Z4.Command=V0;Z4.Option=a0;Z4.Argument=r0;Z4.Help=y4;Z4.CommanderError=x4;Z4.InvalidArgumentError=o0;Z4.InvalidOptionArgumentError=o0});var t0=X4(s0(),1),{program:KH,createCommand:SH,createArgument:OH,createOption:FH,CommanderError:fH,InvalidArgumentError:bH,InvalidOptionArgumentError:IH,Command:T,Argument:kH,Option:CH,Help:PH}=t0.default;import{existsSync as o4,mkdirSync as a4,readFileSync as s4,writeFileSync as t4}from"node:fs";import{homedir as e4}from"node:os";import{join as e0}from"node:path";var $1=e0(e4(),".arial"),w0=e0($1,"config.json"),$6="https://api.arial.sh";function N0(){if(!o4(w0))return null;try{let $=s4(w0,"utf-8"),H=JSON.parse($);if(!H.apiToken)return null;return{apiToken:H.apiToken,apiUrl:H.apiUrl??$6}}catch{return null}}function H1($){a4($1,{recursive:!0}),t4(w0,JSON.stringify($,null,2)+`
28
+ `,"utf-8")}function X1(){let $=N0();if(!$)console.error("Not authenticated. Run `arial login --token <token>` or generate a token at your Arial dashboard (Dashboard → Keys)."),process.exit(1);return $}var J1=($=0)=>(H)=>`\x1B[${H+$}m`,q1=($=0)=>(H)=>`\x1B[${38+$};5;${H}m`,G1=($=0)=>(H,X,q)=>`\x1B[${38+$};2;${H};${X};${q}m`,F={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},ZH=Object.keys(F.modifier),H6=Object.keys(F.color),X6=Object.keys(F.bgColor),hH=[...H6,...X6];function J6(){let $=new Map;for(let[H,X]of Object.entries(F)){for(let[q,J]of Object.entries(X))F[q]={open:`\x1B[${J[0]}m`,close:`\x1B[${J[1]}m`},X[q]=F[q],$.set(J[0],J[1]);Object.defineProperty(F,H,{value:X,enumerable:!1})}return Object.defineProperty(F,"codes",{value:$,enumerable:!1}),F.color.close="\x1B[39m",F.bgColor.close="\x1B[49m",F.color.ansi=J1(),F.color.ansi256=q1(),F.color.ansi16m=G1(),F.bgColor.ansi=J1(10),F.bgColor.ansi256=q1(10),F.bgColor.ansi16m=G1(10),Object.defineProperties(F,{rgbToAnsi256:{value(H,X,q){if(H===X&&X===q){if(H<8)return 16;if(H>248)return 231;return Math.round((H-8)/247*24)+232}return 16+36*Math.round(H/255*5)+6*Math.round(X/255*5)+Math.round(q/255*5)},enumerable:!1},hexToRgb:{value(H){let X=/[a-f\d]{6}|[a-f\d]{3}/i.exec(H.toString(16));if(!X)return[0,0,0];let[q]=X;if(q.length===3)q=[...q].map((_)=>_+_).join("");let J=Number.parseInt(q,16);return[J>>16&255,J>>8&255,J&255]},enumerable:!1},hexToAnsi256:{value:(H)=>F.rgbToAnsi256(...F.hexToRgb(H)),enumerable:!1},ansi256ToAnsi:{value(H){if(H<8)return 30+H;if(H<16)return 90+(H-8);let X,q,J;if(H>=232)X=((H-232)*10+8)/255,q=X,J=X;else{H-=16;let Y=H%36;X=Math.floor(H/36)/5,q=Math.floor(Y/6)/5,J=Y%6/5}let _=Math.max(X,q,J)*2;if(_===0)return 30;let Q=30+(Math.round(J)<<2|Math.round(q)<<1|Math.round(X));if(_===2)Q+=60;return Q},enumerable:!1},rgbToAnsi:{value:(H,X,q)=>F.ansi256ToAnsi(F.rgbToAnsi256(H,X,q)),enumerable:!1},hexToAnsi:{value:(H)=>F.ansi256ToAnsi(F.hexToAnsi256(H)),enumerable:!1}}),F}var q6=J6(),m=q6;import A0 from"node:process";import G6 from"node:os";import _1 from"node:tty";function h($,H=globalThis.Deno?globalThis.Deno.args:A0.argv){let X=$.startsWith("-")?"":$.length===1?"-":"--",q=H.indexOf(X+$),J=H.indexOf("--");return q!==-1&&(J===-1||q<J)}var{env:f}=A0,t$;if(h("no-color")||h("no-colors")||h("color=false")||h("color=never"))t$=0;else if(h("color")||h("colors")||h("color=true")||h("color=always"))t$=1;function _6(){if("FORCE_COLOR"in f){if(f.FORCE_COLOR==="true")return 1;if(f.FORCE_COLOR==="false")return 0;return f.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(f.FORCE_COLOR,10),3)}}function Q6($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function Y6($,{streamIsTTY:H,sniffFlags:X=!0}={}){let q=_6();if(q!==void 0)t$=q;let J=X?t$:q;if(J===0)return 0;if(X){if(h("color=16m")||h("color=full")||h("color=truecolor"))return 3;if(h("color=256"))return 2}if("TF_BUILD"in f&&"AGENT_NAME"in f)return 1;if($&&!H&&J===void 0)return 0;let _=J||0;if(f.TERM==="dumb")return _;if(A0.platform==="win32"){let Q=G6.release().split(".");if(Number(Q[0])>=10&&Number(Q[2])>=10586)return Number(Q[2])>=14931?3:2;return 1}if("CI"in f){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((Q)=>(Q in f)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((Q)=>(Q in f))||f.CI_NAME==="codeship")return 1;return _}if("TEAMCITY_VERSION"in f)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(f.TEAMCITY_VERSION)?1:0;if(f.COLORTERM==="truecolor")return 3;if(f.TERM==="xterm-kitty")return 3;if(f.TERM==="xterm-ghostty")return 3;if(f.TERM==="wezterm")return 3;if("TERM_PROGRAM"in f){let Q=Number.parseInt((f.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(f.TERM_PROGRAM){case"iTerm.app":return Q>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(f.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(f.TERM))return 1;if("COLORTERM"in f)return 1;return _}function Q1($,H={}){let X=Y6($,{streamIsTTY:$&&$.isTTY,...H});return Q6(X)}var W6={stdout:Q1({isTTY:_1.isatty(1)}),stderr:Q1({isTTY:_1.isatty(2)})},Y1=W6;function W1($,H,X){let q=$.indexOf(H);if(q===-1)return $;let J=H.length,_=0,Q="";do Q+=$.slice(_,q)+H+X,_=q+J,q=$.indexOf(H,_);while(q!==-1);return Q+=$.slice(_),Q}function B1($,H,X,q){let J=0,_="";do{let Q=$[q-1]==="\r";_+=$.slice(J,Q?q-1:q)+H+(Q?`\r
29
+ `:`
30
+ `)+X,J=q+1,q=$.indexOf(`
31
+ `,J)}while(q!==-1);return _+=$.slice(J),_}var{stdout:M1,stderr:U1}=Y1,D0=Symbol("GENERATOR"),D$=Symbol("STYLER"),l$=Symbol("IS_EMPTY"),j1=["ansi","ansi","ansi256","ansi16m"],E$=Object.create(null),B6=($,H={})=>{if(H.level&&!(Number.isInteger(H.level)&&H.level>=0&&H.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let X=M1?M1.level:0;$.level=H.level===void 0?X:H.level};var M6=($)=>{let H=(...X)=>X.join(" ");return B6(H,$),Object.setPrototypeOf(H,u$.prototype),H};function u$($){return M6($)}Object.setPrototypeOf(u$.prototype,Function.prototype);for(let[$,H]of Object.entries(m))E$[$]={get(){let X=e$(this,K0(H.open,H.close,this[D$]),this[l$]);return Object.defineProperty(this,$,{value:X}),X}};E$.visible={get(){let $=e$(this,this[D$],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var E0=($,H,X,...q)=>{if($==="rgb"){if(H==="ansi16m")return m[X].ansi16m(...q);if(H==="ansi256")return m[X].ansi256(m.rgbToAnsi256(...q));return m[X].ansi(m.rgbToAnsi(...q))}if($==="hex")return E0("rgb",H,X,...m.hexToRgb(...q));return m[X][$](...q)},U6=["rgb","hex","ansi256"];for(let $ of U6){E$[$]={get(){let{level:X}=this;return function(...q){let J=K0(E0($,j1[X],"color",...q),m.color.close,this[D$]);return e$(this,J,this[l$])}}};let H="bg"+$[0].toUpperCase()+$.slice(1);E$[H]={get(){let{level:X}=this;return function(...q){let J=K0(E0($,j1[X],"bgColor",...q),m.bgColor.close,this[D$]);return e$(this,J,this[l$])}}}}var j6=Object.defineProperties(()=>{},{...E$,level:{enumerable:!0,get(){return this[D0].level},set($){this[D0].level=$}}}),K0=($,H,X)=>{let q,J;if(X===void 0)q=$,J=H;else q=X.openAll+$,J=H+X.closeAll;return{open:$,close:H,openAll:q,closeAll:J,parent:X}},e$=($,H,X)=>{let q=(...J)=>R6(q,J.length===1?""+J[0]:J.join(" "));return Object.setPrototypeOf(q,j6),q[D0]=$,q[D$]=H,q[l$]=X,q},R6=($,H)=>{if($.level<=0||!H)return $[l$]?"":H;let X=$[D$];if(X===void 0)return H;let{openAll:q,closeAll:J}=X;if(H.includes("\x1B"))while(X!==void 0)H=W1(H,X.close,X.open),X=X.parent;let _=H.indexOf(`
32
+ `);if(_!==-1)H=B1(H,J,q,_);return q+H+J};Object.defineProperties(u$.prototype,E$);var L6=u$(),rH=u$({level:U1?U1.level:0});var v=L6;var K$=v.hex("#7C3AED"),O=v.dim,I=v.bold,g=v.green,d=v.yellow,P=v.red,U$=v.cyan;function V6($){return O($)}function j$($){let H="─".repeat(Math.min(process.stdout.columns||60,60));if($)console.log(`
33
+ ${O(H)}
34
+ ${K$($)}
35
+ ${O(H)}`);else console.log(O(H))}function x($){let H=P("✗"),X=w6($);switch($.type){case"network":console.error(`${H} Network error: ${$.message}`);break;case"http":console.error(`${H} HTTP error (${$.status}): ${$.message}`);break;case"api":console.error(`${H} API error (${$.status}): ${$.message}`);break;case"validation":if(console.error(`${H} Validation error: ${$.message}`),$.issues.length>0){let q=$.issues.slice(0,3);for(let J of q){let _=J.path.length>0?J.path.join("."):"response";console.error(O(` • ${_}: ${J.message}`))}if($.issues.length>q.length)console.error(O(` • ${$.issues.length-q.length} more issue(s)`))}break}if(X.length>0){console.error(O(" Suggestions:"));for(let q of X)console.error(O(` • ${q}`))}process.exit(1)}function w6($){let H=new Set,X=N0(),q=X?.apiUrl?`Verify the API URL: ${X.apiUrl}`:"Check the API URL in ~/.arial/config.json",J=(_)=>{if(!_)return;H.add(_)};if($.type==="network")J("Check your network connection."),J(q),J("Try `arial status` once connectivity is restored.");if($.type==="validation")J("The CLI and API may be out of sync. Update the CLI to the latest version."),J(q);if($.type==="http"||$.type==="api"){if($.status===401)J("Run `arial login --token <token>` to refresh your credentials."),J("Verify your token in ~/.arial/config.json.");if($.status===403)J("Make sure your token has access to this resource."),J("If this is a repo, confirm it's accessible via your connected GitHub account.");if($.status===404)J(q),J("If you recently upgraded the server, update the CLI to match."),J("If this was a job ID, run `arial jobs` to list valid IDs.");if($.status===429)J("You are rate limited. Wait a bit and retry."),J("Upgrade your plan if you need higher limits.");if($.status>=500)J("The server had an error. Retry in a moment."),J("If this persists, contact support with the time and command.")}if($.type==="api"){let _=$.message.toLowerCase();if(_.includes("github not connected"))J("Connect your GitHub account in the Arial dashboard.");if(_.includes("no anthropic api key"))J("Add an Anthropic provider key in the Arial dashboard.");if(_.includes("invalid repo format"))J("Use `owner/repo` or a full GitHub URL.");if(_.includes("not found")&&$.status===404)J("Double-check the command and arguments for typos.")}return Array.from(H)}function J$($,H){if(H)console.log(JSON.stringify($,null,2));else console.log($)}function $0($,H,X){if(X){console.log(JSON.stringify($,null,2));return}if($.length===0){console.log(O("No results."));return}let q=H.map((_)=>Math.max(_.label.length,...$.map((Q)=>(Q[_.key]??"").length))),J=H.map((_,Q)=>I(_.label.padEnd(q[Q]))).join(" ");console.log(J),console.log(O(H.map((_,Q)=>"─".repeat(q[Q])).join(" ")));for(let _ of $){let Q=H.map((Y,W)=>(_[Y.key]??"").padEnd(q[W])).join(" ");console.log(Q)}}function S($,H){console.log(` ${V6($.padEnd(10))} ${H}`)}var N6="https://api.arial.sh",R1=new T("login").description("Authenticate with the Arial API").requiredOption("--token <token>","API token (ak_...)").option("--api-url <url>","API base URL",N6).action(async($)=>{if(!$.token.startsWith("ak_"))console.error(`${P("✗")} Invalid token format. Tokens should start with ${I("ak_")}. Generate one at Dashboard → Keys.`),process.exit(1);H1({apiToken:$.token,apiUrl:$.apiUrl}),console.log(`${g("✓")} Authenticated. Config saved to ~/.arial/config.json`)});var G={};J4(G,{void:()=>X8,util:()=>E,unknown:()=>$8,union:()=>_8,undefined:()=>s6,tuple:()=>W8,transformer:()=>A8,symbol:()=>a6,string:()=>S1,strictObject:()=>G8,setErrorMap:()=>E6,set:()=>U8,record:()=>B8,quotelessJson:()=>A6,promise:()=>N8,preprocess:()=>K8,pipeline:()=>S8,ostring:()=>O8,optional:()=>D8,onumber:()=>F8,oboolean:()=>f8,objectUtil:()=>S0,object:()=>q8,number:()=>O1,nullable:()=>E8,null:()=>t6,never:()=>H8,nativeEnum:()=>w8,nan:()=>n6,map:()=>M8,makeIssue:()=>c$,literal:()=>L8,lazy:()=>R8,late:()=>p6,isValid:()=>q$,isDirty:()=>X0,isAsync:()=>O$,isAborted:()=>H0,intersection:()=>Y8,instanceof:()=>d6,getParsedType:()=>n,getErrorMap:()=>S$,function:()=>j8,enum:()=>V8,effect:()=>A8,discriminatedUnion:()=>Q8,defaultErrorMap:()=>e,datetimeRegex:()=>D1,date:()=>o6,custom:()=>K1,coerce:()=>b8,boolean:()=>F1,bigint:()=>r6,array:()=>J8,any:()=>e6,addIssueToContext:()=>R,ZodVoid:()=>p$,ZodUnknown:()=>G$,ZodUnion:()=>C$,ZodUndefined:()=>I$,ZodType:()=>D,ZodTuple:()=>o,ZodTransformer:()=>p,ZodSymbol:()=>i$,ZodString:()=>l,ZodSet:()=>w$,ZodSchema:()=>D,ZodRecord:()=>d$,ZodReadonly:()=>Z$,ZodPromise:()=>N$,ZodPipeline:()=>o$,ZodParsedType:()=>U,ZodOptional:()=>c,ZodObject:()=>b,ZodNumber:()=>_$,ZodNullable:()=>H$,ZodNull:()=>k$,ZodNever:()=>r,ZodNativeEnum:()=>v$,ZodNaN:()=>r$,ZodMap:()=>n$,ZodLiteral:()=>T$,ZodLazy:()=>z$,ZodIssueCode:()=>M,ZodIntersection:()=>P$,ZodFunction:()=>f$,ZodFirstPartyTypeKind:()=>w,ZodError:()=>y,ZodEnum:()=>Y$,ZodEffects:()=>p,ZodDiscriminatedUnion:()=>J0,ZodDefault:()=>x$,ZodDate:()=>L$,ZodCatch:()=>y$,ZodBranded:()=>q0,ZodBoolean:()=>b$,ZodBigInt:()=>Q$,ZodArray:()=>u,ZodAny:()=>V$,Schema:()=>D,ParseStatus:()=>C,OK:()=>z,NEVER:()=>I8,INVALID:()=>V,EMPTY_PATH:()=>K6,DIRTY:()=>R$,BRAND:()=>i6});var E;(function($){$.assertEqual=(J)=>{};function H(J){}$.assertIs=H;function X(J){throw Error()}$.assertNever=X,$.arrayToEnum=(J)=>{let _={};for(let Q of J)_[Q]=Q;return _},$.getValidEnumValues=(J)=>{let _=$.objectKeys(J).filter((Y)=>typeof J[J[Y]]!=="number"),Q={};for(let Y of _)Q[Y]=J[Y];return $.objectValues(Q)},$.objectValues=(J)=>{return $.objectKeys(J).map(function(_){return J[_]})},$.objectKeys=typeof Object.keys==="function"?(J)=>Object.keys(J):(J)=>{let _=[];for(let Q in J)if(Object.prototype.hasOwnProperty.call(J,Q))_.push(Q);return _},$.find=(J,_)=>{for(let Q of J)if(_(Q))return Q;return},$.isInteger=typeof Number.isInteger==="function"?(J)=>Number.isInteger(J):(J)=>typeof J==="number"&&Number.isFinite(J)&&Math.floor(J)===J;function q(J,_=" | "){return J.map((Q)=>typeof Q==="string"?`'${Q}'`:Q).join(_)}$.joinValues=q,$.jsonStringifyReplacer=(J,_)=>{if(typeof _==="bigint")return _.toString();return _}})(E||(E={}));var S0;(function($){$.mergeShapes=(H,X)=>{return{...H,...X}}})(S0||(S0={}));var U=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),n=($)=>{switch(typeof $){case"undefined":return U.undefined;case"string":return U.string;case"number":return Number.isNaN($)?U.nan:U.number;case"boolean":return U.boolean;case"function":return U.function;case"bigint":return U.bigint;case"symbol":return U.symbol;case"object":if(Array.isArray($))return U.array;if($===null)return U.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return U.promise;if(typeof Map<"u"&&$ instanceof Map)return U.map;if(typeof Set<"u"&&$ instanceof Set)return U.set;if(typeof Date<"u"&&$ instanceof Date)return U.date;return U.object;default:return U.unknown}};var M=E.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),A6=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class y extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let H=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,H);else this.__proto__=H;this.name="ZodError",this.issues=$}format($){let H=$||function(J){return J.message},X={_errors:[]},q=(J)=>{for(let _ of J.issues)if(_.code==="invalid_union")_.unionErrors.map(q);else if(_.code==="invalid_return_type")q(_.returnTypeError);else if(_.code==="invalid_arguments")q(_.argumentsError);else if(_.path.length===0)X._errors.push(H(_));else{let Q=X,Y=0;while(Y<_.path.length){let W=_.path[Y];if(Y!==_.path.length-1)Q[W]=Q[W]||{_errors:[]};else Q[W]=Q[W]||{_errors:[]},Q[W]._errors.push(H(_));Q=Q[W],Y++}}};return q(this),X}static assert($){if(!($ instanceof y))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(H)=>H.message){let H={},X=[];for(let q of this.issues)if(q.path.length>0){let J=q.path[0];H[J]=H[J]||[],H[J].push($(q))}else X.push($(q));return{formErrors:X,fieldErrors:H}}get formErrors(){return this.flatten()}}y.create=($)=>{return new y($)};var D6=($,H)=>{let X;switch($.code){case M.invalid_type:if($.received===U.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case M.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,E.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:X=`Unrecognized key(s) in object: ${E.joinValues($.keys,", ")}`;break;case M.invalid_union:X="Invalid input";break;case M.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${E.joinValues($.options)}`;break;case M.invalid_enum_value:X=`Invalid enum value. Expected ${E.joinValues($.options)}, received '${$.received}'`;break;case M.invalid_arguments:X="Invalid function arguments";break;case M.invalid_return_type:X="Invalid function return type";break;case M.invalid_date:X="Invalid date";break;case M.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else E.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case M.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case M.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case M.custom:X="Invalid input";break;case M.invalid_intersection_types:X="Intersection results could not be merged";break;case M.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case M.not_finite:X="Number must be finite";break;default:X=H.defaultError,E.assertNever($)}return{message:X}},e=D6;var L1=e;function E6($){L1=$}function S$(){return L1}var c$=($)=>{let{data:H,path:X,errorMaps:q,issueData:J}=$,_=[...X,...J.path||[]],Q={...J,path:_};if(J.message!==void 0)return{...J,path:_,message:J.message};let Y="",W=q.filter((B)=>!!B).slice().reverse();for(let B of W)Y=B(Q,{data:H,defaultError:Y}).message;return{...J,path:_,message:Y}},K6=[];function R($,H){let X=S$(),q=c$({issueData:H,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===e?void 0:e].filter((J)=>!!J)});$.common.issues.push(q)}class C{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,H){let X=[];for(let q of H){if(q.status==="aborted")return V;if(q.status==="dirty")$.dirty();X.push(q.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,H){let X=[];for(let q of H){let J=await q.key,_=await q.value;X.push({key:J,value:_})}return C.mergeObjectSync($,X)}static mergeObjectSync($,H){let X={};for(let q of H){let{key:J,value:_}=q;if(J.status==="aborted")return V;if(_.status==="aborted")return V;if(J.status==="dirty")$.dirty();if(_.status==="dirty")$.dirty();if(J.value!=="__proto__"&&(typeof _.value<"u"||q.alwaysSet))X[J.value]=_.value}return{status:$.value,value:X}}}var V=Object.freeze({status:"aborted"}),R$=($)=>({status:"dirty",value:$}),z=($)=>({status:"valid",value:$}),H0=($)=>$.status==="aborted",X0=($)=>$.status==="dirty",q$=($)=>$.status==="valid",O$=($)=>typeof Promise<"u"&&$ instanceof Promise;var L;(function($){$.errToObj=(H)=>typeof H==="string"?{message:H}:H||{},$.toString=(H)=>typeof H==="string"?H:H?.message})(L||(L={}));class i{constructor($,H,X,q){this._cachedPath=[],this.parent=$,this.data=H,this._path=X,this._key=q}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var V1=($,H)=>{if(q$(H))return{success:!0,data:H.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new y($.common.issues);return this._error=X,this._error}}}};function A($){if(!$)return{};let{errorMap:H,invalid_type_error:X,required_error:q,description:J}=$;if(H&&(X||q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(H)return{errorMap:H,description:J};return{errorMap:(Q,Y)=>{let{message:W}=$;if(Q.code==="invalid_enum_value")return{message:W??Y.defaultError};if(typeof Y.data>"u")return{message:W??q??Y.defaultError};if(Q.code!=="invalid_type")return{message:Y.defaultError};return{message:W??X??Y.defaultError}},description:J}}class D{get description(){return this._def.description}_getType($){return n($.data)}_getOrReturnCtx($,H){return H||{common:$.parent.common,data:$.data,parsedType:n($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new C,ctx:{common:$.parent.common,data:$.data,parsedType:n($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let H=this._parse($);if(O$(H))throw Error("Synchronous parse encountered promise.");return H}_parseAsync($){let H=this._parse($);return Promise.resolve(H)}parse($,H){let X=this.safeParse($,H);if(X.success)return X.data;throw X.error}safeParse($,H){let X={common:{issues:[],async:H?.async??!1,contextualErrorMap:H?.errorMap},path:H?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:n($)},q=this._parseSync({data:$,path:X.path,parent:X});return V1(X,q)}"~validate"($){let H={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:n($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:H});return q$(X)?{value:X.value}:{issues:H.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;H.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:H}).then((X)=>q$(X)?{value:X.value}:{issues:H.common.issues})}async parseAsync($,H){let X=await this.safeParseAsync($,H);if(X.success)return X.data;throw X.error}async safeParseAsync($,H){let X={common:{issues:[],contextualErrorMap:H?.errorMap,async:!0},path:H?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:n($)},q=this._parse({data:$,path:X.path,parent:X}),J=await(O$(q)?q:Promise.resolve(q));return V1(X,J)}refine($,H){let X=(q)=>{if(typeof H==="string"||typeof H>"u")return{message:H};else if(typeof H==="function")return H(q);else return H};return this._refinement((q,J)=>{let _=$(q),Q=()=>J.addIssue({code:M.custom,...X(q)});if(typeof Promise<"u"&&_ instanceof Promise)return _.then((Y)=>{if(!Y)return Q(),!1;else return!0});if(!_)return Q(),!1;else return!0})}refinement($,H){return this._refinement((X,q)=>{if(!$(X))return q.addIssue(typeof H==="function"?H(X,q):H),!1;else return!0})}_refinement($){return new p({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(H)=>this["~validate"](H)}}optional(){return c.create(this,this._def)}nullable(){return H$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return u.create(this)}promise(){return N$.create(this,this._def)}or($){return C$.create([this,$],this._def)}and($){return P$.create(this,$,this._def)}transform($){return new p({...A(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:$}})}default($){let H=typeof $==="function"?$:()=>$;return new x$({...A(this._def),innerType:this,defaultValue:H,typeName:w.ZodDefault})}brand(){return new q0({typeName:w.ZodBranded,type:this,...A(this._def)})}catch($){let H=typeof $==="function"?$:()=>$;return new y$({...A(this._def),innerType:this,catchValue:H,typeName:w.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return o$.create(this,$)}readonly(){return Z$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var S6=/^c[^\s-]{8,}$/i,O6=/^[0-9a-z]+$/,F6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,f6=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,b6=/^[a-z0-9_-]{21}$/i,I6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,k6=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,C6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,P6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",O0,z6=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,T6=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,v6=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,x6=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,y6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Z6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,N1="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",h6=new RegExp(`^${N1}$`);function A1($){let H="[0-5]\\d";if($.precision)H=`${H}\\.\\d{${$.precision}}`;else if($.precision==null)H=`${H}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${H})${X}`}function g6($){return new RegExp(`^${A1($)}$`)}function D1($){let H=`${N1}T${A1($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return H=`${H}(${X.join("|")})`,new RegExp(`^${H}$`)}function m6($,H){if((H==="v4"||!H)&&z6.test($))return!0;if((H==="v6"||!H)&&v6.test($))return!0;return!1}function l6($,H){if(!I6.test($))return!1;try{let[X]=$.split(".");if(!X)return!1;let q=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),J=JSON.parse(atob(q));if(typeof J!=="object"||J===null)return!1;if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if(H&&J.alg!==H)return!1;return!0}catch{return!1}}function u6($,H){if((H==="v4"||!H)&&T6.test($))return!0;if((H==="v6"||!H)&&x6.test($))return!0;return!1}class l extends D{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==U.string){let J=this._getOrReturnCtx($);return R(J,{code:M.invalid_type,expected:U.string,received:J.parsedType}),V}let X=new C,q=void 0;for(let J of this._def.checks)if(J.kind==="min"){if($.data.length<J.value)q=this._getOrReturnCtx($,q),R(q,{code:M.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),X.dirty()}else if(J.kind==="max"){if($.data.length>J.value)q=this._getOrReturnCtx($,q),R(q,{code:M.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),X.dirty()}else if(J.kind==="length"){let _=$.data.length>J.value,Q=$.data.length<J.value;if(_||Q){if(q=this._getOrReturnCtx($,q),_)R(q,{code:M.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});else if(Q)R(q,{code:M.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});X.dirty()}}else if(J.kind==="email"){if(!C6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"email",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="emoji"){if(!O0)O0=new RegExp(P6,"u");if(!O0.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"emoji",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="uuid"){if(!f6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"uuid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="nanoid"){if(!b6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"nanoid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="cuid"){if(!S6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"cuid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="cuid2"){if(!O6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"cuid2",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="ulid"){if(!F6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"ulid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="url")try{new URL($.data)}catch{q=this._getOrReturnCtx($,q),R(q,{validation:"url",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="regex"){if(J.regex.lastIndex=0,!J.regex.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"regex",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="trim")$.data=$.data.trim();else if(J.kind==="includes"){if(!$.data.includes(J.value,J.position))q=this._getOrReturnCtx($,q),R(q,{code:M.invalid_string,validation:{includes:J.value,position:J.position},message:J.message}),X.dirty()}else if(J.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(J.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(J.kind==="startsWith"){if(!$.data.startsWith(J.value))q=this._getOrReturnCtx($,q),R(q,{code:M.invalid_string,validation:{startsWith:J.value},message:J.message}),X.dirty()}else if(J.kind==="endsWith"){if(!$.data.endsWith(J.value))q=this._getOrReturnCtx($,q),R(q,{code:M.invalid_string,validation:{endsWith:J.value},message:J.message}),X.dirty()}else if(J.kind==="datetime"){if(!D1(J).test($.data))q=this._getOrReturnCtx($,q),R(q,{code:M.invalid_string,validation:"datetime",message:J.message}),X.dirty()}else if(J.kind==="date"){if(!h6.test($.data))q=this._getOrReturnCtx($,q),R(q,{code:M.invalid_string,validation:"date",message:J.message}),X.dirty()}else if(J.kind==="time"){if(!g6(J).test($.data))q=this._getOrReturnCtx($,q),R(q,{code:M.invalid_string,validation:"time",message:J.message}),X.dirty()}else if(J.kind==="duration"){if(!k6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"duration",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="ip"){if(!m6($.data,J.version))q=this._getOrReturnCtx($,q),R(q,{validation:"ip",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="jwt"){if(!l6($.data,J.alg))q=this._getOrReturnCtx($,q),R(q,{validation:"jwt",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="cidr"){if(!u6($.data,J.version))q=this._getOrReturnCtx($,q),R(q,{validation:"cidr",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="base64"){if(!y6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"base64",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="base64url"){if(!Z6.test($.data))q=this._getOrReturnCtx($,q),R(q,{validation:"base64url",code:M.invalid_string,message:J.message}),X.dirty()}else E.assertNever(J);return{status:X.value,value:$.data}}_regex($,H,X){return this.refinement((q)=>$.test(q),{validation:H,code:M.invalid_string,...L.errToObj(X)})}_addCheck($){return new l({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...L.errToObj($)})}url($){return this._addCheck({kind:"url",...L.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...L.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...L.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...L.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...L.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...L.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...L.errToObj($)})}base64($){return this._addCheck({kind:"base64",...L.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...L.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...L.errToObj($)})}ip($){return this._addCheck({kind:"ip",...L.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...L.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...L.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...L.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...L.errToObj($)})}regex($,H){return this._addCheck({kind:"regex",regex:$,...L.errToObj(H)})}includes($,H){return this._addCheck({kind:"includes",value:$,position:H?.position,...L.errToObj(H?.message)})}startsWith($,H){return this._addCheck({kind:"startsWith",value:$,...L.errToObj(H)})}endsWith($,H){return this._addCheck({kind:"endsWith",value:$,...L.errToObj(H)})}min($,H){return this._addCheck({kind:"min",value:$,...L.errToObj(H)})}max($,H){return this._addCheck({kind:"max",value:$,...L.errToObj(H)})}length($,H){return this._addCheck({kind:"length",value:$,...L.errToObj(H)})}nonempty($){return this.min(1,L.errToObj($))}trim(){return new l({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let H of this._def.checks)if(H.kind==="min"){if($===null||H.value>$)$=H.value}return $}get maxLength(){let $=null;for(let H of this._def.checks)if(H.kind==="max"){if($===null||H.value<$)$=H.value}return $}}l.create=($)=>{return new l({checks:[],typeName:w.ZodString,coerce:$?.coerce??!1,...A($)})};function c6($,H){let X=($.toString().split(".")[1]||"").length,q=(H.toString().split(".")[1]||"").length,J=X>q?X:q,_=Number.parseInt($.toFixed(J).replace(".","")),Q=Number.parseInt(H.toFixed(J).replace(".",""));return _%Q/10**J}class _$ extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==U.number){let J=this._getOrReturnCtx($);return R(J,{code:M.invalid_type,expected:U.number,received:J.parsedType}),V}let X=void 0,q=new C;for(let J of this._def.checks)if(J.kind==="int"){if(!E.isInteger($.data))X=this._getOrReturnCtx($,X),R(X,{code:M.invalid_type,expected:"integer",received:"float",message:J.message}),q.dirty()}else if(J.kind==="min"){if(J.inclusive?$.data<J.value:$.data<=J.value)X=this._getOrReturnCtx($,X),R(X,{code:M.too_small,minimum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),q.dirty()}else if(J.kind==="max"){if(J.inclusive?$.data>J.value:$.data>=J.value)X=this._getOrReturnCtx($,X),R(X,{code:M.too_big,maximum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),q.dirty()}else if(J.kind==="multipleOf"){if(c6($.data,J.value)!==0)X=this._getOrReturnCtx($,X),R(X,{code:M.not_multiple_of,multipleOf:J.value,message:J.message}),q.dirty()}else if(J.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),R(X,{code:M.not_finite,message:J.message}),q.dirty()}else E.assertNever(J);return{status:q.value,value:$.data}}gte($,H){return this.setLimit("min",$,!0,L.toString(H))}gt($,H){return this.setLimit("min",$,!1,L.toString(H))}lte($,H){return this.setLimit("max",$,!0,L.toString(H))}lt($,H){return this.setLimit("max",$,!1,L.toString(H))}setLimit($,H,X,q){return new _$({...this._def,checks:[...this._def.checks,{kind:$,value:H,inclusive:X,message:L.toString(q)}]})}_addCheck($){return new _$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:L.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L.toString($)})}multipleOf($,H){return this._addCheck({kind:"multipleOf",value:$,message:L.toString(H)})}finite($){return this._addCheck({kind:"finite",message:L.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L.toString($)})}get minValue(){let $=null;for(let H of this._def.checks)if(H.kind==="min"){if($===null||H.value>$)$=H.value}return $}get maxValue(){let $=null;for(let H of this._def.checks)if(H.kind==="max"){if($===null||H.value<$)$=H.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&E.isInteger($.value))}get isFinite(){let $=null,H=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(H===null||X.value>H)H=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(H)&&Number.isFinite($)}}_$.create=($)=>{return new _$({checks:[],typeName:w.ZodNumber,coerce:$?.coerce||!1,...A($)})};class Q$ extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==U.bigint)return this._getInvalidInput($);let X=void 0,q=new C;for(let J of this._def.checks)if(J.kind==="min"){if(J.inclusive?$.data<J.value:$.data<=J.value)X=this._getOrReturnCtx($,X),R(X,{code:M.too_small,type:"bigint",minimum:J.value,inclusive:J.inclusive,message:J.message}),q.dirty()}else if(J.kind==="max"){if(J.inclusive?$.data>J.value:$.data>=J.value)X=this._getOrReturnCtx($,X),R(X,{code:M.too_big,type:"bigint",maximum:J.value,inclusive:J.inclusive,message:J.message}),q.dirty()}else if(J.kind==="multipleOf"){if($.data%J.value!==BigInt(0))X=this._getOrReturnCtx($,X),R(X,{code:M.not_multiple_of,multipleOf:J.value,message:J.message}),q.dirty()}else E.assertNever(J);return{status:q.value,value:$.data}}_getInvalidInput($){let H=this._getOrReturnCtx($);return R(H,{code:M.invalid_type,expected:U.bigint,received:H.parsedType}),V}gte($,H){return this.setLimit("min",$,!0,L.toString(H))}gt($,H){return this.setLimit("min",$,!1,L.toString(H))}lte($,H){return this.setLimit("max",$,!0,L.toString(H))}lt($,H){return this.setLimit("max",$,!1,L.toString(H))}setLimit($,H,X,q){return new Q$({...this._def,checks:[...this._def.checks,{kind:$,value:H,inclusive:X,message:L.toString(q)}]})}_addCheck($){return new Q$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L.toString($)})}multipleOf($,H){return this._addCheck({kind:"multipleOf",value:$,message:L.toString(H)})}get minValue(){let $=null;for(let H of this._def.checks)if(H.kind==="min"){if($===null||H.value>$)$=H.value}return $}get maxValue(){let $=null;for(let H of this._def.checks)if(H.kind==="max"){if($===null||H.value<$)$=H.value}return $}}Q$.create=($)=>{return new Q$({checks:[],typeName:w.ZodBigInt,coerce:$?.coerce??!1,...A($)})};class b$ extends D{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==U.boolean){let X=this._getOrReturnCtx($);return R(X,{code:M.invalid_type,expected:U.boolean,received:X.parsedType}),V}return z($.data)}}b$.create=($)=>{return new b$({typeName:w.ZodBoolean,coerce:$?.coerce||!1,...A($)})};class L$ extends D{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==U.date){let J=this._getOrReturnCtx($);return R(J,{code:M.invalid_type,expected:U.date,received:J.parsedType}),V}if(Number.isNaN($.data.getTime())){let J=this._getOrReturnCtx($);return R(J,{code:M.invalid_date}),V}let X=new C,q=void 0;for(let J of this._def.checks)if(J.kind==="min"){if($.data.getTime()<J.value)q=this._getOrReturnCtx($,q),R(q,{code:M.too_small,message:J.message,inclusive:!0,exact:!1,minimum:J.value,type:"date"}),X.dirty()}else if(J.kind==="max"){if($.data.getTime()>J.value)q=this._getOrReturnCtx($,q),R(q,{code:M.too_big,message:J.message,inclusive:!0,exact:!1,maximum:J.value,type:"date"}),X.dirty()}else E.assertNever(J);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new L$({...this._def,checks:[...this._def.checks,$]})}min($,H){return this._addCheck({kind:"min",value:$.getTime(),message:L.toString(H)})}max($,H){return this._addCheck({kind:"max",value:$.getTime(),message:L.toString(H)})}get minDate(){let $=null;for(let H of this._def.checks)if(H.kind==="min"){if($===null||H.value>$)$=H.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let H of this._def.checks)if(H.kind==="max"){if($===null||H.value<$)$=H.value}return $!=null?new Date($):null}}L$.create=($)=>{return new L$({checks:[],coerce:$?.coerce||!1,typeName:w.ZodDate,...A($)})};class i$ extends D{_parse($){if(this._getType($)!==U.symbol){let X=this._getOrReturnCtx($);return R(X,{code:M.invalid_type,expected:U.symbol,received:X.parsedType}),V}return z($.data)}}i$.create=($)=>{return new i$({typeName:w.ZodSymbol,...A($)})};class I$ extends D{_parse($){if(this._getType($)!==U.undefined){let X=this._getOrReturnCtx($);return R(X,{code:M.invalid_type,expected:U.undefined,received:X.parsedType}),V}return z($.data)}}I$.create=($)=>{return new I$({typeName:w.ZodUndefined,...A($)})};class k$ extends D{_parse($){if(this._getType($)!==U.null){let X=this._getOrReturnCtx($);return R(X,{code:M.invalid_type,expected:U.null,received:X.parsedType}),V}return z($.data)}}k$.create=($)=>{return new k$({typeName:w.ZodNull,...A($)})};class V$ extends D{constructor(){super(...arguments);this._any=!0}_parse($){return z($.data)}}V$.create=($)=>{return new V$({typeName:w.ZodAny,...A($)})};class G$ extends D{constructor(){super(...arguments);this._unknown=!0}_parse($){return z($.data)}}G$.create=($)=>{return new G$({typeName:w.ZodUnknown,...A($)})};class r extends D{_parse($){let H=this._getOrReturnCtx($);return R(H,{code:M.invalid_type,expected:U.never,received:H.parsedType}),V}}r.create=($)=>{return new r({typeName:w.ZodNever,...A($)})};class p$ extends D{_parse($){if(this._getType($)!==U.undefined){let X=this._getOrReturnCtx($);return R(X,{code:M.invalid_type,expected:U.void,received:X.parsedType}),V}return z($.data)}}p$.create=($)=>{return new p$({typeName:w.ZodVoid,...A($)})};class u extends D{_parse($){let{ctx:H,status:X}=this._processInputParams($),q=this._def;if(H.parsedType!==U.array)return R(H,{code:M.invalid_type,expected:U.array,received:H.parsedType}),V;if(q.exactLength!==null){let _=H.data.length>q.exactLength.value,Q=H.data.length<q.exactLength.value;if(_||Q)R(H,{code:_?M.too_big:M.too_small,minimum:Q?q.exactLength.value:void 0,maximum:_?q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:q.exactLength.message}),X.dirty()}if(q.minLength!==null){if(H.data.length<q.minLength.value)R(H,{code:M.too_small,minimum:q.minLength.value,type:"array",inclusive:!0,exact:!1,message:q.minLength.message}),X.dirty()}if(q.maxLength!==null){if(H.data.length>q.maxLength.value)R(H,{code:M.too_big,maximum:q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:q.maxLength.message}),X.dirty()}if(H.common.async)return Promise.all([...H.data].map((_,Q)=>{return q.type._parseAsync(new i(H,_,H.path,Q))})).then((_)=>{return C.mergeArray(X,_)});let J=[...H.data].map((_,Q)=>{return q.type._parseSync(new i(H,_,H.path,Q))});return C.mergeArray(X,J)}get element(){return this._def.type}min($,H){return new u({...this._def,minLength:{value:$,message:L.toString(H)}})}max($,H){return new u({...this._def,maxLength:{value:$,message:L.toString(H)}})}length($,H){return new u({...this._def,exactLength:{value:$,message:L.toString(H)}})}nonempty($){return this.min(1,$)}}u.create=($,H)=>{return new u({type:$,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...A(H)})};function F$($){if($ instanceof b){let H={};for(let X in $.shape){let q=$.shape[X];H[X]=c.create(F$(q))}return new b({...$._def,shape:()=>H})}else if($ instanceof u)return new u({...$._def,type:F$($.element)});else if($ instanceof c)return c.create(F$($.unwrap()));else if($ instanceof H$)return H$.create(F$($.unwrap()));else if($ instanceof o)return o.create($.items.map((H)=>F$(H)));else return $}class b extends D{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),H=E.objectKeys($);return this._cached={shape:$,keys:H},this._cached}_parse($){if(this._getType($)!==U.object){let W=this._getOrReturnCtx($);return R(W,{code:M.invalid_type,expected:U.object,received:W.parsedType}),V}let{status:X,ctx:q}=this._processInputParams($),{shape:J,keys:_}=this._getCached(),Q=[];if(!(this._def.catchall instanceof r&&this._def.unknownKeys==="strip")){for(let W in q.data)if(!_.includes(W))Q.push(W)}let Y=[];for(let W of _){let B=J[W],j=q.data[W];Y.push({key:{status:"valid",value:W},value:B._parse(new i(q,j,q.path,W)),alwaysSet:W in q.data})}if(this._def.catchall instanceof r){let W=this._def.unknownKeys;if(W==="passthrough")for(let B of Q)Y.push({key:{status:"valid",value:B},value:{status:"valid",value:q.data[B]}});else if(W==="strict"){if(Q.length>0)R(q,{code:M.unrecognized_keys,keys:Q}),X.dirty()}else if(W==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let W=this._def.catchall;for(let B of Q){let j=q.data[B];Y.push({key:{status:"valid",value:B},value:W._parse(new i(q,j,q.path,B)),alwaysSet:B in q.data})}}if(q.common.async)return Promise.resolve().then(async()=>{let W=[];for(let B of Y){let j=await B.key,N=await B.value;W.push({key:j,value:N,alwaysSet:B.alwaysSet})}return W}).then((W)=>{return C.mergeObjectSync(X,W)});else return C.mergeObjectSync(X,Y)}get shape(){return this._def.shape()}strict($){return L.errToObj,new b({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(H,X)=>{let q=this._def.errorMap?.(H,X).message??X.defaultError;if(H.code==="unrecognized_keys")return{message:L.errToObj($).message??q};return{message:q}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend($){return new b({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new b({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:w.ZodObject})}setKey($,H){return this.augment({[$]:H})}catchall($){return new b({...this._def,catchall:$})}pick($){let H={};for(let X of E.objectKeys($))if($[X]&&this.shape[X])H[X]=this.shape[X];return new b({...this._def,shape:()=>H})}omit($){let H={};for(let X of E.objectKeys(this.shape))if(!$[X])H[X]=this.shape[X];return new b({...this._def,shape:()=>H})}deepPartial(){return F$(this)}partial($){let H={};for(let X of E.objectKeys(this.shape)){let q=this.shape[X];if($&&!$[X])H[X]=q;else H[X]=q.optional()}return new b({...this._def,shape:()=>H})}required($){let H={};for(let X of E.objectKeys(this.shape))if($&&!$[X])H[X]=this.shape[X];else{let J=this.shape[X];while(J instanceof c)J=J._def.innerType;H[X]=J}return new b({...this._def,shape:()=>H})}keyof(){return E1(E.objectKeys(this.shape))}}b.create=($,H)=>{return new b({shape:()=>$,unknownKeys:"strip",catchall:r.create(),typeName:w.ZodObject,...A(H)})};b.strictCreate=($,H)=>{return new b({shape:()=>$,unknownKeys:"strict",catchall:r.create(),typeName:w.ZodObject,...A(H)})};b.lazycreate=($,H)=>{return new b({shape:$,unknownKeys:"strip",catchall:r.create(),typeName:w.ZodObject,...A(H)})};class C$ extends D{_parse($){let{ctx:H}=this._processInputParams($),X=this._def.options;function q(J){for(let Q of J)if(Q.result.status==="valid")return Q.result;for(let Q of J)if(Q.result.status==="dirty")return H.common.issues.push(...Q.ctx.common.issues),Q.result;let _=J.map((Q)=>new y(Q.ctx.common.issues));return R(H,{code:M.invalid_union,unionErrors:_}),V}if(H.common.async)return Promise.all(X.map(async(J)=>{let _={...H,common:{...H.common,issues:[]},parent:null};return{result:await J._parseAsync({data:H.data,path:H.path,parent:_}),ctx:_}})).then(q);else{let J=void 0,_=[];for(let Y of X){let W={...H,common:{...H.common,issues:[]},parent:null},B=Y._parseSync({data:H.data,path:H.path,parent:W});if(B.status==="valid")return B;else if(B.status==="dirty"&&!J)J={result:B,ctx:W};if(W.common.issues.length)_.push(W.common.issues)}if(J)return H.common.issues.push(...J.ctx.common.issues),J.result;let Q=_.map((Y)=>new y(Y));return R(H,{code:M.invalid_union,unionErrors:Q}),V}}get options(){return this._def.options}}C$.create=($,H)=>{return new C$({options:$,typeName:w.ZodUnion,...A(H)})};var $$=($)=>{if($ instanceof z$)return $$($.schema);else if($ instanceof p)return $$($.innerType());else if($ instanceof T$)return[$.value];else if($ instanceof Y$)return $.options;else if($ instanceof v$)return E.objectValues($.enum);else if($ instanceof x$)return $$($._def.innerType);else if($ instanceof I$)return[void 0];else if($ instanceof k$)return[null];else if($ instanceof c)return[void 0,...$$($.unwrap())];else if($ instanceof H$)return[null,...$$($.unwrap())];else if($ instanceof q0)return $$($.unwrap());else if($ instanceof Z$)return $$($.unwrap());else if($ instanceof y$)return $$($._def.innerType);else return[]};class J0 extends D{_parse($){let{ctx:H}=this._processInputParams($);if(H.parsedType!==U.object)return R(H,{code:M.invalid_type,expected:U.object,received:H.parsedType}),V;let X=this.discriminator,q=H.data[X],J=this.optionsMap.get(q);if(!J)return R(H,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),V;if(H.common.async)return J._parseAsync({data:H.data,path:H.path,parent:H});else return J._parseSync({data:H.data,path:H.path,parent:H})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,H,X){let q=new Map;for(let J of H){let _=$$(J.shape[$]);if(!_.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Q of _){if(q.has(Q))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Q)}`);q.set(Q,J)}}return new J0({typeName:w.ZodDiscriminatedUnion,discriminator:$,options:H,optionsMap:q,...A(X)})}}function F0($,H){let X=n($),q=n(H);if($===H)return{valid:!0,data:$};else if(X===U.object&&q===U.object){let J=E.objectKeys(H),_=E.objectKeys($).filter((Y)=>J.indexOf(Y)!==-1),Q={...$,...H};for(let Y of _){let W=F0($[Y],H[Y]);if(!W.valid)return{valid:!1};Q[Y]=W.data}return{valid:!0,data:Q}}else if(X===U.array&&q===U.array){if($.length!==H.length)return{valid:!1};let J=[];for(let _=0;_<$.length;_++){let Q=$[_],Y=H[_],W=F0(Q,Y);if(!W.valid)return{valid:!1};J.push(W.data)}return{valid:!0,data:J}}else if(X===U.date&&q===U.date&&+$===+H)return{valid:!0,data:$};else return{valid:!1}}class P$ extends D{_parse($){let{status:H,ctx:X}=this._processInputParams($),q=(J,_)=>{if(H0(J)||H0(_))return V;let Q=F0(J.value,_.value);if(!Q.valid)return R(X,{code:M.invalid_intersection_types}),V;if(X0(J)||X0(_))H.dirty();return{status:H.value,value:Q.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([J,_])=>q(J,_));else return q(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}P$.create=($,H,X)=>{return new P$({left:$,right:H,typeName:w.ZodIntersection,...A(X)})};class o extends D{_parse($){let{status:H,ctx:X}=this._processInputParams($);if(X.parsedType!==U.array)return R(X,{code:M.invalid_type,expected:U.array,received:X.parsedType}),V;if(X.data.length<this._def.items.length)return R(X,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;if(!this._def.rest&&X.data.length>this._def.items.length)R(X,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),H.dirty();let J=[...X.data].map((_,Q)=>{let Y=this._def.items[Q]||this._def.rest;if(!Y)return null;return Y._parse(new i(X,_,X.path,Q))}).filter((_)=>!!_);if(X.common.async)return Promise.all(J).then((_)=>{return C.mergeArray(H,_)});else return C.mergeArray(H,J)}get items(){return this._def.items}rest($){return new o({...this._def,rest:$})}}o.create=($,H)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new o({items:$,typeName:w.ZodTuple,rest:null,...A(H)})};class d$ extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:H,ctx:X}=this._processInputParams($);if(X.parsedType!==U.object)return R(X,{code:M.invalid_type,expected:U.object,received:X.parsedType}),V;let q=[],J=this._def.keyType,_=this._def.valueType;for(let Q in X.data)q.push({key:J._parse(new i(X,Q,X.path,Q)),value:_._parse(new i(X,X.data[Q],X.path,Q)),alwaysSet:Q in X.data});if(X.common.async)return C.mergeObjectAsync(H,q);else return C.mergeObjectSync(H,q)}get element(){return this._def.valueType}static create($,H,X){if(H instanceof D)return new d$({keyType:$,valueType:H,typeName:w.ZodRecord,...A(X)});return new d$({keyType:l.create(),valueType:$,typeName:w.ZodRecord,...A(H)})}}class n$ extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:H,ctx:X}=this._processInputParams($);if(X.parsedType!==U.map)return R(X,{code:M.invalid_type,expected:U.map,received:X.parsedType}),V;let q=this._def.keyType,J=this._def.valueType,_=[...X.data.entries()].map(([Q,Y],W)=>{return{key:q._parse(new i(X,Q,X.path,[W,"key"])),value:J._parse(new i(X,Y,X.path,[W,"value"]))}});if(X.common.async){let Q=new Map;return Promise.resolve().then(async()=>{for(let Y of _){let W=await Y.key,B=await Y.value;if(W.status==="aborted"||B.status==="aborted")return V;if(W.status==="dirty"||B.status==="dirty")H.dirty();Q.set(W.value,B.value)}return{status:H.value,value:Q}})}else{let Q=new Map;for(let Y of _){let{key:W,value:B}=Y;if(W.status==="aborted"||B.status==="aborted")return V;if(W.status==="dirty"||B.status==="dirty")H.dirty();Q.set(W.value,B.value)}return{status:H.value,value:Q}}}}n$.create=($,H,X)=>{return new n$({valueType:H,keyType:$,typeName:w.ZodMap,...A(X)})};class w$ extends D{_parse($){let{status:H,ctx:X}=this._processInputParams($);if(X.parsedType!==U.set)return R(X,{code:M.invalid_type,expected:U.set,received:X.parsedType}),V;let q=this._def;if(q.minSize!==null){if(X.data.size<q.minSize.value)R(X,{code:M.too_small,minimum:q.minSize.value,type:"set",inclusive:!0,exact:!1,message:q.minSize.message}),H.dirty()}if(q.maxSize!==null){if(X.data.size>q.maxSize.value)R(X,{code:M.too_big,maximum:q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:q.maxSize.message}),H.dirty()}let J=this._def.valueType;function _(Y){let W=new Set;for(let B of Y){if(B.status==="aborted")return V;if(B.status==="dirty")H.dirty();W.add(B.value)}return{status:H.value,value:W}}let Q=[...X.data.values()].map((Y,W)=>J._parse(new i(X,Y,X.path,W)));if(X.common.async)return Promise.all(Q).then((Y)=>_(Y));else return _(Q)}min($,H){return new w$({...this._def,minSize:{value:$,message:L.toString(H)}})}max($,H){return new w$({...this._def,maxSize:{value:$,message:L.toString(H)}})}size($,H){return this.min($,H).max($,H)}nonempty($){return this.min(1,$)}}w$.create=($,H)=>{return new w$({valueType:$,minSize:null,maxSize:null,typeName:w.ZodSet,...A(H)})};class f$ extends D{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:H}=this._processInputParams($);if(H.parsedType!==U.function)return R(H,{code:M.invalid_type,expected:U.function,received:H.parsedType}),V;function X(Q,Y){return c$({data:Q,path:H.path,errorMaps:[H.common.contextualErrorMap,H.schemaErrorMap,S$(),e].filter((W)=>!!W),issueData:{code:M.invalid_arguments,argumentsError:Y}})}function q(Q,Y){return c$({data:Q,path:H.path,errorMaps:[H.common.contextualErrorMap,H.schemaErrorMap,S$(),e].filter((W)=>!!W),issueData:{code:M.invalid_return_type,returnTypeError:Y}})}let J={errorMap:H.common.contextualErrorMap},_=H.data;if(this._def.returns instanceof N$){let Q=this;return z(async function(...Y){let W=new y([]),B=await Q._def.args.parseAsync(Y,J).catch((Z)=>{throw W.addIssue(X(Y,Z)),W}),j=await Reflect.apply(_,this,B);return await Q._def.returns._def.type.parseAsync(j,J).catch((Z)=>{throw W.addIssue(q(j,Z)),W})})}else{let Q=this;return z(function(...Y){let W=Q._def.args.safeParse(Y,J);if(!W.success)throw new y([X(Y,W.error)]);let B=Reflect.apply(_,this,W.data),j=Q._def.returns.safeParse(B,J);if(!j.success)throw new y([q(B,j.error)]);return j.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new f$({...this._def,args:o.create($).rest(G$.create())})}returns($){return new f$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,H,X){return new f$({args:$?$:o.create([]).rest(G$.create()),returns:H||G$.create(),typeName:w.ZodFunction,...A(X)})}}class z$ extends D{get schema(){return this._def.getter()}_parse($){let{ctx:H}=this._processInputParams($);return this._def.getter()._parse({data:H.data,path:H.path,parent:H})}}z$.create=($,H)=>{return new z$({getter:$,typeName:w.ZodLazy,...A(H)})};class T$ extends D{_parse($){if($.data!==this._def.value){let H=this._getOrReturnCtx($);return R(H,{received:H.data,code:M.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:$.data}}get value(){return this._def.value}}T$.create=($,H)=>{return new T$({value:$,typeName:w.ZodLiteral,...A(H)})};function E1($,H){return new Y$({values:$,typeName:w.ZodEnum,...A(H)})}class Y$ extends D{_parse($){if(typeof $.data!=="string"){let H=this._getOrReturnCtx($),X=this._def.values;return R(H,{expected:E.joinValues(X),received:H.parsedType,code:M.invalid_type}),V}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let H=this._getOrReturnCtx($),X=this._def.values;return R(H,{received:H.data,code:M.invalid_enum_value,options:X}),V}return z($.data)}get options(){return this._def.values}get enum(){let $={};for(let H of this._def.values)$[H]=H;return $}get Values(){let $={};for(let H of this._def.values)$[H]=H;return $}get Enum(){let $={};for(let H of this._def.values)$[H]=H;return $}extract($,H=this._def){return Y$.create($,{...this._def,...H})}exclude($,H=this._def){return Y$.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...H})}}Y$.create=E1;class v$ extends D{_parse($){let H=E.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==U.string&&X.parsedType!==U.number){let q=E.objectValues(H);return R(X,{expected:E.joinValues(q),received:X.parsedType,code:M.invalid_type}),V}if(!this._cache)this._cache=new Set(E.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let q=E.objectValues(H);return R(X,{received:X.data,code:M.invalid_enum_value,options:q}),V}return z($.data)}get enum(){return this._def.values}}v$.create=($,H)=>{return new v$({values:$,typeName:w.ZodNativeEnum,...A(H)})};class N$ extends D{unwrap(){return this._def.type}_parse($){let{ctx:H}=this._processInputParams($);if(H.parsedType!==U.promise&&H.common.async===!1)return R(H,{code:M.invalid_type,expected:U.promise,received:H.parsedType}),V;let X=H.parsedType===U.promise?H.data:Promise.resolve(H.data);return z(X.then((q)=>{return this._def.type.parseAsync(q,{path:H.path,errorMap:H.common.contextualErrorMap})}))}}N$.create=($,H)=>{return new N$({type:$,typeName:w.ZodPromise,...A(H)})};class p extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:H,ctx:X}=this._processInputParams($),q=this._def.effect||null,J={addIssue:(_)=>{if(R(X,_),_.fatal)H.abort();else H.dirty()},get path(){return X.path}};if(J.addIssue=J.addIssue.bind(J),q.type==="preprocess"){let _=q.transform(X.data,J);if(X.common.async)return Promise.resolve(_).then(async(Q)=>{if(H.value==="aborted")return V;let Y=await this._def.schema._parseAsync({data:Q,path:X.path,parent:X});if(Y.status==="aborted")return V;if(Y.status==="dirty")return R$(Y.value);if(H.value==="dirty")return R$(Y.value);return Y});else{if(H.value==="aborted")return V;let Q=this._def.schema._parseSync({data:_,path:X.path,parent:X});if(Q.status==="aborted")return V;if(Q.status==="dirty")return R$(Q.value);if(H.value==="dirty")return R$(Q.value);return Q}}if(q.type==="refinement"){let _=(Q)=>{let Y=q.refinement(Q,J);if(X.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Q};if(X.common.async===!1){let Q=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return V;if(Q.status==="dirty")H.dirty();return _(Q.value),{status:H.value,value:Q.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((Q)=>{if(Q.status==="aborted")return V;if(Q.status==="dirty")H.dirty();return _(Q.value).then(()=>{return{status:H.value,value:Q.value}})})}if(q.type==="transform")if(X.common.async===!1){let _=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!q$(_))return V;let Q=q.transform(_.value,J);if(Q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:H.value,value:Q}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((_)=>{if(!q$(_))return V;return Promise.resolve(q.transform(_.value,J)).then((Q)=>({status:H.value,value:Q}))});E.assertNever(q)}}p.create=($,H,X)=>{return new p({schema:$,typeName:w.ZodEffects,effect:H,...A(X)})};p.createWithPreprocess=($,H,X)=>{return new p({schema:H,effect:{type:"preprocess",transform:$},typeName:w.ZodEffects,...A(X)})};class c extends D{_parse($){if(this._getType($)===U.undefined)return z(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}c.create=($,H)=>{return new c({innerType:$,typeName:w.ZodOptional,...A(H)})};class H$ extends D{_parse($){if(this._getType($)===U.null)return z(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}H$.create=($,H)=>{return new H$({innerType:$,typeName:w.ZodNullable,...A(H)})};class x$ extends D{_parse($){let{ctx:H}=this._processInputParams($),X=H.data;if(H.parsedType===U.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:H.path,parent:H})}removeDefault(){return this._def.innerType}}x$.create=($,H)=>{return new x$({innerType:$,typeName:w.ZodDefault,defaultValue:typeof H.default==="function"?H.default:()=>H.default,...A(H)})};class y$ extends D{_parse($){let{ctx:H}=this._processInputParams($),X={...H,common:{...H.common,issues:[]}},q=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(O$(q))return q.then((J)=>{return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new y(X.common.issues)},input:X.data})}});else return{status:"valid",value:q.status==="valid"?q.value:this._def.catchValue({get error(){return new y(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}y$.create=($,H)=>{return new y$({innerType:$,typeName:w.ZodCatch,catchValue:typeof H.catch==="function"?H.catch:()=>H.catch,...A(H)})};class r$ extends D{_parse($){if(this._getType($)!==U.nan){let X=this._getOrReturnCtx($);return R(X,{code:M.invalid_type,expected:U.nan,received:X.parsedType}),V}return{status:"valid",value:$.data}}}r$.create=($)=>{return new r$({typeName:w.ZodNaN,...A($)})};var i6=Symbol("zod_brand");class q0 extends D{_parse($){let{ctx:H}=this._processInputParams($),X=H.data;return this._def.type._parse({data:X,path:H.path,parent:H})}unwrap(){return this._def.type}}class o$ extends D{_parse($){let{status:H,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let J=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(J.status==="aborted")return V;if(J.status==="dirty")return H.dirty(),R$(J.value);else return this._def.out._parseAsync({data:J.value,path:X.path,parent:X})})();else{let q=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(q.status==="aborted")return V;if(q.status==="dirty")return H.dirty(),{status:"dirty",value:q.value};else return this._def.out._parseSync({data:q.value,path:X.path,parent:X})}}static create($,H){return new o$({in:$,out:H,typeName:w.ZodPipeline})}}class Z$ extends D{_parse($){let H=this._def.innerType._parse($),X=(q)=>{if(q$(q))q.value=Object.freeze(q.value);return q};return O$(H)?H.then((q)=>X(q)):X(H)}unwrap(){return this._def.innerType}}Z$.create=($,H)=>{return new Z$({innerType:$,typeName:w.ZodReadonly,...A(H)})};function w1($,H){let X=typeof $==="function"?$(H):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function K1($,H={},X){if($)return V$.create().superRefine((q,J)=>{let _=$(q);if(_ instanceof Promise)return _.then((Q)=>{if(!Q){let Y=w1(H,q),W=Y.fatal??X??!0;J.addIssue({code:"custom",...Y,fatal:W})}});if(!_){let Q=w1(H,q),Y=Q.fatal??X??!0;J.addIssue({code:"custom",...Q,fatal:Y})}return});return V$.create()}var p6={object:b.lazycreate},w;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(w||(w={}));var d6=($,H={message:`Input not instance of ${$.name}`})=>K1((X)=>X instanceof $,H),S1=l.create,O1=_$.create,n6=r$.create,r6=Q$.create,F1=b$.create,o6=L$.create,a6=i$.create,s6=I$.create,t6=k$.create,e6=V$.create,$8=G$.create,H8=r.create,X8=p$.create,J8=u.create,q8=b.create,G8=b.strictCreate,_8=C$.create,Q8=J0.create,Y8=P$.create,W8=o.create,B8=d$.create,M8=n$.create,U8=w$.create,j8=f$.create,R8=z$.create,L8=T$.create,V8=Y$.create,w8=v$.create,N8=N$.create,A8=p.create,D8=c.create,E8=H$.create,K8=p.createWithPreprocess,S8=o$.create,O8=()=>S1().optional(),F8=()=>O1().optional(),f8=()=>F1().optional(),b8={string:($)=>l.create({...$,coerce:!0}),number:($)=>_$.create({...$,coerce:!0}),boolean:($)=>b$.create({...$,coerce:!0}),bigint:($)=>Q$.create({...$,coerce:!0}),date:($)=>L$.create({...$,coerce:!0})};var I8=V;function k($){return{ok:!0,value:$}}function a($){return{ok:!1,error:$}}var W$=G.object({type:G.enum(["spec","pr","branch","conversation"]),value:G.string(),intent:G.enum(["awareness","dependency"]).optional()}),f1=G.object({name:G.string(),email:G.string().email()}),b1=G.enum(["draft","dispatched","queued","running","completed","failed"]),PX=G.object({title:G.string(),content:G.string(),extends:G.array(W$).optional()});var k8=G.enum(["pending","running","completed","failed","cancelled"]),xX=G.enum(["draft","dispatched","pending","running","completed","failed","cancelled"]),C8=G.enum(["cruise","glide"]),yX=G.object({repo:G.string().min(1),prompt:G.string().min(1),branch:G.string().optional(),specId:G.string().optional(),specTitle:G.string().optional(),contextTags:G.array(W$).optional(),strategy:C8.default("cruise")}),P8=G.object({id:G.string(),repo:G.string(),branch:G.string(),prompt:G.string(),specId:G.string().nullable(),specTitle:G.string().nullable(),status:k8,workingBranch:G.string().nullable(),prNumber:G.number().nullable(),prUrl:G.string().nullable(),createdAt:G.string().datetime(),startedAt:G.string().datetime().nullable(),completedAt:G.string().datetime().nullable(),error:G.string().nullable(),contextTags:G.array(W$).nullable()}),ZX=P8.extend({isActive:G.boolean(),logs:G.string().nullable(),result:G.string().nullable(),usage:G.object({inputTokens:G.number(),outputTokens:G.number(),cacheCreationTokens:G.number(),cacheReadTokens:G.number(),estimatedCostUsd:G.number(),durationMs:G.number().nullable()}).nullable()});var z8=G.object({id:G.string(),role:G.enum(["user","assistant"]),content:G.string(),specId:G.string().optional(),createdAt:G.string().datetime()}),T8=G.object({id:G.string(),specId:G.string().optional(),title:G.string(),content:G.string(),extends:G.array(W$).optional(),status:b1,prUrl:G.string().url().optional(),error:G.string().optional(),dispatchedAt:G.string().datetime().optional()}),lX=G.object({id:G.string(),repoId:G.string(),title:G.string(),messages:G.array(z8),specs:G.array(T8),forkedFrom:G.string().optional(),createdAt:G.string().datetime(),updatedAt:G.string().datetime()}),v8=G.object({id:G.string().optional(),label:G.string(),description:G.string().optional(),isOther:G.boolean().optional()}),x8=G.object({id:G.string(),text:G.string(),options:G.array(v8),multiSelect:G.boolean()}),y8=G.object({questionId:G.string(),selectedOptionIds:G.array(G.string()),notes:G.string()}),uX=G.object({batchNumber:G.number(),questions:G.array(x8),answers:G.array(y8)}),cX=G.enum(["connecting","ready","thinking","error"]);var I1=G.object({id:G.string(),name:G.string(),fullName:G.string(),description:G.string().nullable(),private:G.boolean(),updatedAt:G.string().datetime()}),dX=G.object({status:G.enum(["idle","running","merging"]),activeAgents:G.number(),buildQueue:G.array(G.string()),mergeQueue:G.array(G.string())}),nX=G.object({repoId:G.string(),languages:G.array(G.string()),frameworks:G.array(G.string()),keyFiles:G.array(G.string()),recentCommits:G.array(G.string()),fileStructure:G.string(),inspectedAt:G.string().datetime()});var Z8=G.object({id:G.string(),label:G.string(),description:G.string().optional(),isOther:G.boolean().optional()}),f0=G.object({id:G.string(),prompt:G.string(),options:G.array(Z8),allowMultiple:G.boolean()}),h8=G.object({questionId:G.string(),selectedOptionIds:G.array(G.string()),notes:G.string()}),k1=G.object({batchNumber:G.number(),questions:G.array(f0),answers:G.array(h8)}),C1=G.object({title:G.string(),suggestedFilename:G.string(),content:G.string(),extends:G.array(G.string()).optional()}),aX=G.object({planName:G.string(),planDescription:G.string().optional(),previousBatches:G.array(k1).optional()}),sX=G.object({planName:G.string(),planDescription:G.string().optional(),questionHistory:G.array(k1),additionalInstructions:G.string().optional()}),P1=G.object({questions:G.array(f0),readyToGenerate:G.boolean()}),z1=G.object({plan:C1}),b0=G.discriminatedUnion("type",[G.object({type:G.literal("text"),text:G.string()}),G.object({type:G.literal("questions"),questions:G.array(f0),readyToGenerate:G.boolean()}),G.object({type:G.literal("plan"),plan:C1}),G.object({type:G.literal("done")}),G.object({type:G.literal("error"),error:G.string()})]);var g8=G.enum(["UNAUTHORIZED","TOKEN_EXPIRED","INVALID_TOKEN","NOT_FOUND","ALREADY_EXISTS","CONFLICT","VALIDATION_ERROR","INVALID_REQUEST","INTERNAL_ERROR","SERVICE_UNAVAILABLE","SPEC_NOT_CANCELLABLE","REPO_NOT_FOUND","REPO_NOT_CONFIGURED","RATE_LIMITED"]),$3=G.object({code:g8,message:G.string(),details:G.record(G.unknown()).optional()}),m8=G.enum(["MISSING_API_KEY","INVALID_CONFIG","CAPABILITY_NOT_SUPPORTED","ADAPTER_NOT_FOUND","INITIALIZATION_FAILED"]),H3=G.object({code:m8,message:G.string(),adapterId:G.string().optional()}),l8=G.enum(["LLM_ERROR","PARSE_ERROR","CONTEXT_ERROR","CANCELLED"]),X3=G.object({code:l8,message:G.string(),details:G.unknown().optional()});var _3=G.object({}),Q3=G.object({deviceCode:G.string()}),Y3=G.object({refreshToken:G.string()}),W3=G.object({repoId:G.string(),title:G.string().optional()}),B3=G.object({newTitle:G.string().optional()}),M3=G.object({role:G.enum(["user","assistant"]),content:G.string()}),U3=G.object({content:G.string(),requestId:G.string().optional()}),j3=G.object({repoId:G.string(),name:G.string(),title:G.string(),content:G.string(),owner:f1,remoteUrl:G.string().url().optional(),baseBranch:G.string().optional(),extends:G.array(W$).optional()}),R3=G.object({});var T1=G.object({error:G.string(),details:G.unknown().optional()}),v1=G.object({deviceCode:G.string(),userCode:G.string(),verificationUri:G.string().url(),expiresIn:G.number(),interval:G.number()}),u8=G.object({status:G.literal("pending")}),c8=G.object({status:G.literal("complete"),accessToken:G.string(),refreshToken:G.string(),expiresIn:G.number(),user:G.object({id:G.string(),username:G.string(),avatarUrl:G.string().url()})}),x1=G.union([u8,c8]),y1=G.object({accessToken:G.string(),expiresIn:G.number()}),Z1=G.object({conversations:G.array(G.object({id:G.string(),title:G.string().nullable(),tags:G.array(G.string()),repoFullName:G.string().nullable(),repoBranch:G.string().nullable(),messageCount:G.number(),createdAt:G.string(),updatedAt:G.string()})),total:G.number(),limit:G.number(),offset:G.number()}),h1=G.object({id:G.string(),title:G.string().nullable(),tags:G.array(G.string()),repoFullName:G.string().nullable(),repoBranch:G.string().nullable(),hasRepoContext:G.boolean(),messages:G.array(G.object({id:G.string(),role:G.string(),content:G.string(),createdAt:G.string()})),createdAt:G.string(),updatedAt:G.string()}),I0=G.object({id:G.string(),title:G.string().nullable(),tags:G.array(G.string()),repoFullName:G.string().nullable(),repoBranch:G.string().nullable(),createdAt:G.string(),updatedAt:G.string()});var g1=I0,N3=G.object({deleted:G.literal(!0)}),A3=G.object({jobs:G.array(G.object({id:G.string(),repo:G.string(),branch:G.string(),prompt:G.string(),specId:G.string().nullable(),specTitle:G.string().nullable(),status:G.string(),workingBranch:G.string().nullable(),prNumber:G.number().nullable(),prUrl:G.string().nullable(),createdAt:G.string(),startedAt:G.string().nullable(),completedAt:G.string().nullable(),error:G.string().nullable()})),total:G.number(),limit:G.number(),offset:G.number()}),D3=G.object({id:G.string(),repo:G.string(),branch:G.string(),prompt:G.string(),specId:G.string().nullable(),specTitle:G.string().nullable(),status:G.string(),isActive:G.boolean(),workingBranch:G.string().nullable(),prNumber:G.number().nullable(),prUrl:G.string().nullable(),createdAt:G.string(),startedAt:G.string().nullable(),completedAt:G.string().nullable(),logs:G.string().nullable(),result:G.string().nullable(),error:G.string().nullable(),usage:G.object({inputTokens:G.number(),outputTokens:G.number(),cacheCreationTokens:G.number(),cacheReadTokens:G.number(),estimatedCostUsd:G.number(),durationMs:G.number().nullable()}).nullable()}),E3=G.object({id:G.string(),prNumber:G.number(),prUrl:G.string()}),m1=G.object({repos:G.array(I1),total:G.number(),limit:G.number(),offset:G.number()}),l1=G.object({context:G.object({repoId:G.string(),languages:G.array(G.string()),frameworks:G.array(G.string()),keyFiles:G.array(G.string()),recentCommits:G.array(G.string()),fileStructure:G.string(),inspectedAt:G.string()})}),K3=G.object({jobId:G.string(),inputTokens:G.number(),outputTokens:G.number(),cacheCreationTokens:G.number(),cacheReadTokens:G.number(),estimatedCostUsd:G.number(),durationMs:G.number().nullable(),claudeDurationMs:G.number().nullable(),modelBreakdown:G.unknown().nullable()}),i8=G.object({period:G.string(),totalInputTokens:G.number(),totalOutputTokens:G.number(),totalCacheCreationTokens:G.number(),totalCacheReadTokens:G.number(),totalCostUsd:G.number(),jobCount:G.number(),totalDurationMs:G.number()}),S3=G.object({history:G.array(i8)}),O3=G.object({status:G.literal("ok"),authMode:G.string()});var p8=G.object({id:G.string(),title:G.string(),task:G.string(),context:G.string().optional(),approach:G.string().optional(),references:G.array(G.object({type:G.string(),id:G.string(),title:G.string().optional()})).optional()}),d8=G.object({id:G.string(),label:G.string(),description:G.string().optional()}),n8=G.object({id:G.string(),text:G.string(),options:G.array(d8),multiSelect:G.boolean()}),r8=G.object({id:G.string(),questions:G.array(n8),assistantTextBefore:G.string(),createdAt:G.string()}),o8=G.object({type:G.literal("user_message"),id:G.string()}),a8=G.object({type:G.literal("content"),text:G.string()}),s8=G.object({type:G.literal("tool_call"),name:G.string(),args:G.unknown()}),t8=G.object({type:G.literal("tool_result"),name:G.string(),result:G.unknown()}),e8=G.object({type:G.literal("spec"),spec:p8}),$H=G.object({type:G.literal("question_batch"),batch:r8}),HH=G.object({type:G.literal("done"),id:G.string(),awaitingAnswers:G.boolean().optional(),batchId:G.string().optional()}),XH=G.object({type:G.literal("error"),message:G.string()}),u1=G.discriminatedUnion("type",[o8,a8,s8,t8,e8,$H,HH,XH]),JH=G.object({type:G.literal("job_info"),id:G.string(),status:G.string(),repo:G.string(),branch:G.string()}),qH=G.object({type:G.literal("output"),data:G.string()}),GH=G.object({type:G.literal("phase"),phase:G.enum(["credentials","clone","running","planning","building","refresh","commit","push","pr","usage","done"]),message:G.string()}),_H=G.object({type:G.literal("strategy_progress"),strategy:G.string(),data:G.record(G.unknown())}),QH=G.object({type:G.literal("error"),message:G.string(),stderr:G.boolean().optional()}),YH=G.object({type:G.literal("git_result"),action:G.enum(["commit","push","pr"]),success:G.boolean(),message:G.string(),url:G.string().optional()}),WH=G.object({type:G.literal("usage_summary"),inputTokens:G.number(),outputTokens:G.number(),cacheReadTokens:G.number().optional(),cacheWriteTokens:G.number().optional(),model:G.string().optional()}),BH=G.object({type:G.literal("done"),status:G.string()}),MH=G.object({type:G.literal("keepalive"),ts:G.number().optional()}),c1=G.discriminatedUnion("type",[JH,qH,GH,_H,QH,YH,WH,BH,MH]);function k0($){let H=$.token,X=$.fetch??fetch,q=$.baseUrl.replace(/\/$/,"");async function J(_,Q,Y,W){let B=`${q}${Q}`,j={"Content-Type":"application/json"};if(H)j.Authorization=`Bearer ${H}`;let N;try{N=await X(B,{method:_,headers:j,body:Y!==void 0?JSON.stringify(Y):void 0})}catch(h$){return a({type:"network",message:h$ instanceof Error?h$.message:"Network error"})}if(!N.headers.get("content-type")?.includes("application/json")){if(!N.ok)return a({type:"http",status:N.status,message:`HTTP ${N.status}: ${N.statusText}`})}let X$;try{X$=await N.json()}catch{if(!N.ok)return a({type:"http",status:N.status,message:`HTTP ${N.status}: ${N.statusText}`});return a({type:"http",status:N.status,message:"Invalid JSON response"})}if(!N.ok){let h$=T1.safeParse(X$);if(h$.success)return a({type:"api",status:N.status,message:h$.data.error});return a({type:"http",status:N.status,message:`HTTP ${N.status}: ${N.statusText}`})}let B$=W.safeParse(X$);if(!B$.success)return a({type:"validation",message:"Response validation failed",issues:B$.error.issues});return k(B$.data)}return{get(_,Q){return J("GET",_,void 0,Q)},post(_,Q,Y){return J("POST",_,Q,Y)},patch(_,Q,Y){return J("PATCH",_,Q,Y)},delete(_,Q){return J("DELETE",_,void 0,Q)},setToken(_){H=_},clearToken(){H=void 0}}}function C0($){return{async startDeviceFlow(){let H=await $.post("/auth/device",{},v1);if(!H.ok)return H;return k({deviceCode:H.value.deviceCode,userCode:H.value.userCode,verificationUri:H.value.verificationUri,expiresIn:H.value.expiresIn,interval:H.value.interval})},async pollDeviceFlow(H){let X=await $.post("/auth/device/poll",{deviceCode:H},x1);if(!X.ok)return X;let q=X.value;if("status"in q&&q.status==="pending")return k("pending");if("accessToken"in q)return k({accessToken:q.accessToken,refreshToken:q.refreshToken,expiresIn:q.expiresIn,user:q.user});return a({type:"api",status:500,message:"Unexpected response from device flow poll"})},async refreshToken(H){let X=await $.post("/auth/refresh",{refreshToken:H},y1);if(!X.ok)return X;return k({accessToken:X.value.accessToken,expiresIn:X.value.expiresIn})},async logout(){let H=await $.post("/auth/logout",{},G.object({loggedOut:G.literal(!0)}));if(!H.ok)return H;return k(void 0)}}}function P0(){let $=null,H=null,X=null;return{getAccessToken:()=>$,getRefreshToken:()=>H,getUser:()=>X,setTokens(q){$=q.accessToken,H=q.refreshToken,X=q.user},updateAccessToken(q){$=q},clear(){$=null,H=null,X=null}}}class G0 extends Error{constructor($="Stream disconnected unexpectedly"){super($);this.name="StreamDisconnectedError"}}function i1($){if($.startsWith("data: "))return $.slice(6);return null}function p1($,H){try{let X=JSON.parse($),q=H.safeParse(X);if(q.success)return q.data;return console.warn("SSE validation failed:",q.error.issues),null}catch{return null}}async function*_0($){let H=$.options.fetch??fetch,X={Accept:"text/event-stream"};if($.body!==void 0)X["Content-Type"]="application/json";if($.token)X.Authorization=`Bearer ${$.token}`;let q={method:$.method,headers:X};if($.body!==void 0)q.body=JSON.stringify($.body);if($.options.signal!==void 0)q.signal=$.options.signal;let J=await H($.url,q);if(!J.ok){let B=await J.text();throw Error(`SSE request failed: ${J.status} ${B}`)}if(!J.body)throw Error("No response body");let _=J.body.getReader(),Q=new TextDecoder,Y="",W=!1;try{while(!0){let{done:B,value:j}=await _.read();if(B)break;Y+=Q.decode(j,{stream:!0});let N=Y.split(`
36
+ `);Y=N.pop()??"";for(let Z of N){if(Z.startsWith(":"))continue;let X$=i1(Z);if(X$){let B$=p1(X$,$.schema);if(B$){if(yield B$,$.terminalTypes.includes(B$.type)){W=!0;return}}}}}if(Y){let B=i1(Y);if(B){let j=p1(B,$.schema);if(j){if(yield j,$.terminalTypes.includes(j.type))W=!0}}}if(!W)throw new G0}finally{_.releaseLock()}}async function*Q0($,H,X,q={}){yield*_0({url:$,method:"POST",body:H,token:X,schema:u1,terminalTypes:["done","error"],options:q})}async function*z0($,H,X={}){let q=X.maxRetries??5,J=X.initialDelayMs??1000,_=0;while(_<=q)try{yield*_0({url:$,method:"GET",token:H,schema:c1,terminalTypes:["done"],options:X});return}catch(Q){if(Q instanceof G0){if(_++,_>q)throw Error(`Stream disconnected after ${q} reconnection attempts`);let Y=Math.min(J*Math.pow(2,_-1)+Math.random()*500,1e4);X.onReconnect?.(_),await new Promise((W)=>setTimeout(W,Y))}else throw Q}}async function*T0($,H,X,q={}){yield*_0({url:$,method:"POST",body:H,token:X,schema:b0,terminalTypes:["done","error"],options:q})}async function*v0($,H,X,q={}){yield*_0({url:$,method:"POST",body:H,token:X,schema:b0,terminalTypes:["done","error"],options:q})}function x0($){let H=$.baseUrl.replace(/\/$/,""),X=$.tokenStorage??P0(),q={baseUrl:H,token:X.getAccessToken()??void 0,fetch:$.fetch},J=k0(q),_=C0(J),Q=G.object({id:G.string(),status:G.string(),repo:G.string(),branch:G.string(),streamUrl:G.string().optional(),createdAt:G.string()});return{auth:_,tokenStorage:X,setToken(Y){J.setToken(Y),X.updateAccessToken(Y)},clearToken(){J.clearToken(),X.clear()},async createJob(Y){return J.post("/jobs",Y,Q)},async listJobs(Y){let W=new URLSearchParams;if(Y?.repo)W.set("repo",Y.repo);if(Y?.status)W.set("status",Y.status);if(Y?.limit)W.set("limit",String(Y.limit));if(Y?.offset)W.set("offset",String(Y.offset));let B=W.toString(),j=B?`/jobs?${B}`:"/jobs";return J.get(j,G.object({jobs:G.array(G.object({id:G.string(),status:G.string(),repo:G.string(),branch:G.string(),task:G.string(),pr:G.object({number:G.number(),url:G.string()}).nullable(),createdAt:G.string(),completedAt:G.string().nullable(),error:G.string().nullable()})),total:G.number(),limit:G.number(),offset:G.number()}))},async getJob(Y){return J.get(`/jobs/${encodeURIComponent(Y)}`,G.object({id:G.string(),status:G.string(),repo:G.string(),branch:G.string(),task:G.string(),isActive:G.boolean(),pr:G.object({number:G.number(),url:G.string()}).nullable(),createdAt:G.string(),completedAt:G.string().nullable(),error:G.string().nullable(),usage:G.object({inputTokens:G.number(),outputTokens:G.number(),estimatedCostUsd:G.number(),durationSeconds:G.number().nullable()}).nullable()}))},async getUsage(){return J.get("/usage",G.object({period:G.string(),totalInputTokens:G.number(),totalOutputTokens:G.number(),totalCacheCreationTokens:G.number(),totalCacheReadTokens:G.number(),totalCostUsd:G.number(),jobCount:G.number(),conversationCount:G.number(),totalDurationMs:G.number()}))},async cancel(Y){let W=await J.post(`/jobs/${encodeURIComponent(Y)}/cancel`,{},G.object({cancelled:G.literal(!0),id:G.string()}));if(!W.ok)return W;return k(void 0)},async listGitHubRepos(){let Y=await J.get("/github/repos",m1);if(!Y.ok)return Y;return k(Y.value.repos)},async inspectRepo(Y,W){let B=await J.post(`/repos/${encodeURIComponent(Y)}/${encodeURIComponent(W)}/inspect`,{},l1);if(!B.ok)return B;return k(B.value.context)},async listConversations(Y){let W=Y?`/conversations?repo=${encodeURIComponent(Y)}`:"/conversations",B=await J.get(W,Z1);if(!B.ok)return B;return k(B.value.conversations)},async getConversation(Y){let W=await J.get(`/conversations/${encodeURIComponent(Y)}`,h1);if(!W.ok)return W;return k(W.value)},async createConversation(Y,W){let B=await J.post("/conversations",{repoFullName:Y,title:W},I0);if(!B.ok)return B;return k(B.value)},async forkConversation(Y,W){let B=await J.post(`/conversations/${encodeURIComponent(Y)}/fork`,{newTitle:W},g1);if(!B.ok)return B;return k(B.value)},async deleteConversation(Y){let W=await J.delete(`/conversations/${encodeURIComponent(Y)}`,G.object({deleted:G.literal(!0)}));if(!W.ok)return W;return k(void 0)},async*sendMessage(Y,W,B){let j=`${H}/conversations/${encodeURIComponent(Y)}/messages`,N=X.getAccessToken()??void 0;yield*Q0(j,{content:W},N,{fetch:$.fetch,signal:B?.signal??null})},async*submitAnswers(Y,W,B,j){let N=`${H}/conversations/${encodeURIComponent(Y)}/answer`,Z=X.getAccessToken()??void 0;yield*Q0(N,{batchId:W,answers:B},Z,{fetch:$.fetch,signal:j?.signal??null})},async*streamJobOutput(Y,W){let B=`${H}/jobs/${encodeURIComponent(Y)}/stream`,j=X.getAccessToken()??void 0;yield*z0(B,j,{fetch:$.fetch,signal:W?.signal??null,maxRetries:W?.maxRetries,initialDelayMs:W?.initialDelayMs,onReconnect:W?.onReconnect})},async generateQuestions(Y,W){let B=await J.post(`/conversations/${encodeURIComponent(Y)}/questions`,W,P1);if(!B.ok)return B;return k(B.value)},async*streamQuestions(Y,W,B){let j=`${H}/conversations/${encodeURIComponent(Y)}/questions/stream`,N=X.getAccessToken()??void 0;yield*T0(j,W,N,{fetch:$.fetch,signal:B?.signal??null})},async generatePlan(Y,W){let B=await J.post(`/conversations/${encodeURIComponent(Y)}/plan`,W,z1);if(!B.ok)return B;return k(B.value.plan)},async*streamPlan(Y,W,B){let j=`${H}/conversations/${encodeURIComponent(Y)}/plan/stream`,N=X.getAccessToken()??void 0;yield*v0(j,W,N,{fetch:$.fetch,signal:B?.signal??null})}}}function s($){let H=$??X1(),X=x0({baseUrl:H.apiUrl});return X.setToken(H.apiToken),X}var d1=new T("status").description("Show usage and job status").option("--json","Output as JSON",!1).action(async($)=>{let H=s(),[X,q]=await Promise.all([H.getUsage(),H.listJobs({limit:10})]);if(!X.ok)x(X.error);if(!q.ok)x(q.error);let J=X.value,_=q.value;if($.json){J$({usage:J,jobs:_},!0);return}let Q=_.jobs.filter((B)=>B.status==="running"||B.status==="pending").length,Y=_.jobs.filter((B)=>B.status==="completed").length,W=_.jobs.filter((B)=>B.status==="failed").length;console.log(),S("Status",g("connected")),S("Period",J.period),S("Jobs",`${Q} active · ${Y} completed · ${W} failed`),S("Tokens",`${J.totalInputTokens.toLocaleString()} in / ${J.totalOutputTokens.toLocaleString()} out`),S("Cost",`$${J.totalCostUsd.toFixed(2)}`),console.log()});var n1=new T("jobs").description("List and manage jobs").argument("[id]","Job ID to inspect").option("--logs","Stream job logs",!1).option("--cancel","Cancel the job",!1).option("--stop","Soft stop a running job",!1).option("--json","Output as JSON",!1).action(async($,H)=>{let X=s();if($&&H.cancel){let J=await X.cancel($);if(!J.ok)x(J.error);console.log(`${g("✓")} Job ${I($)} cancelled.`);return}if($&&H.stop){let J=await X.cancel($);if(!J.ok)x(J.error);console.log(`${d("●")} Job ${I($)} will stop after the current iteration.`);return}if($&&H.logs){j$("Streaming logs"),console.log();for await(let J of X.streamJobOutput($))switch(J.type){case"job_info":console.log(` ${U$("◆")} ${I(J.id)} ${O(`[${J.status}]`)} ${J.repo} ${O(`→ ${J.branch}`)}`),console.log();break;case"output":process.stdout.write(J.data);break;case"phase":console.log(`
37
+ ${K$("▸")} ${I(J.phase)} ${O("—")} ${J.message}`);break;case"error":if(console.error(`
38
+ ${P("✗")} ${J.message}`),J.stderr)console.error(O(J.stderr));break;case"git_result":{let _=J.success?g("✓"):P("✗");if(console.log(`
39
+ ${_} Git ${J.action}: ${J.message}`),J.url)console.log(` ${U$("→")} ${v.underline(J.url)}`);break}case"usage_summary":console.log(`
40
+ ${O("Tokens:")} ${J.inputTokens.toLocaleString()} in / ${J.outputTokens.toLocaleString()} out${J.model?O(` (${J.model})`):""}`);break;case"done":{console.log(),j$();let _=J.status==="completed"||J.status==="pr_created"?g("✓"):J.status==="failed"?P("✗"):d("●");console.log(` ${_} ${I(J.status)}`),console.log();break}}return}if($){let J=await X.getJob($);if(!J.ok)x(J.error);let _=J.value;if(H.json){J$(_,!0);return}if(console.log(),S("ID",_.id),S("Task",I(_.task.length>60?_.task.slice(0,60)+"...":_.task)),S("Status",_.status),S("Repo",_.repo),S("Branch",_.branch),_.pr)S("PR",v.underline(_.pr.url));if(S("Created",_.createdAt),_.completedAt)S("Completed",_.completedAt);if(_.error)S("Error",P(_.error));if(_.usage)S("Tokens",`${_.usage.inputTokens.toLocaleString()} in / ${_.usage.outputTokens.toLocaleString()} out`),S("Cost",`$${_.usage.estimatedCostUsd.toFixed(4)}`);console.log();return}let q=await X.listJobs();if(!q.ok)x(q.error);$0(q.value.jobs.map((J)=>({id:J.id,task:J.task.length>40?J.task.slice(0,40)+"...":J.task,status:J.status,repo:J.repo,created:J.createdAt})),[{key:"id",label:"ID"},{key:"task",label:"Task"},{key:"status",label:"Status"},{key:"repo",label:"Repo"},{key:"created",label:"Created"}],H.json)});import{readFileSync as UH}from"node:fs";var o1=new T("dispatch").description("Dispatch a job for execution").argument("<repo>","Repository (owner/repo)").argument("[prompt]","Prompt describing the work").option("-f, --file <path>","Read prompt from a file").option("--strategy <strategy>","Execution strategy (cruise or glide)","cruise").option("--json","Output as JSON",!1).action(async($,H,X)=>{let q;if(X.file)q=UH(X.file,"utf-8");else if(H)q=H;else console.error(P("✗")+" Provide a prompt or use -f to read from a file."),process.exit(1);let J=s(),[_,Q]=$.split("/");if(!_||!Q)console.error(P("✗")+" Repository must be in owner/repo format."),process.exit(1);console.log(`
41
+ ${K$("▸")} Dispatching to ${I($)} ${O(`(${X.strategy})`)}
42
+ `);let Y=await J.createJob({repo:$,task:q});if(!Y.ok)x(Y.error);if(X.json){J$(Y.value,!0);return}S("Job",Y.value.id),S("Status",Y.value.status),S("Repo",Y.value.repo),S("Branch",Y.value.branch),j$("Streaming output"),console.log();let W=!1;try{for await(let B of J.streamJobOutput(Y.value.id,{onReconnect:(j)=>{console.log(`
43
+ ${d("●")} ${O(`Reconnecting... (attempt ${j})`)}`)}}))switch(B.type){case"keepalive":break;case"job_info":console.log(` ${U$("◆")} ${I(B.id)} ${O(`[${B.status}]`)} ${B.repo} ${O(`→ ${B.branch}`)}`),console.log();break;case"output":process.stdout.write(B.data);break;case"phase":console.log(`
44
+ ${K$("▸")} ${I(B.phase)} ${O("—")} ${B.message}`);break;case"strategy_progress":console.log(` ${O("↻")} ${B.strategy}: ${typeof B.data==="string"?B.data:JSON.stringify(B.data)}`);break;case"git_result":{let j=B.success?g("✓"):P("✗");if(console.log(`
45
+ ${j} Git ${B.action}: ${B.message}`),B.url)console.log(` ${U$("→")} ${v.underline(B.url)}`);break}case"usage_summary":console.log(`
46
+ ${O("Tokens:")} ${B.inputTokens.toLocaleString()} in / ${B.outputTokens.toLocaleString()} out${B.model?O(` (${B.model})`):""}`);break;case"error":if(console.error(`
47
+ ${P("✗")} ${B.message}`),B.stderr)console.error(O(B.stderr));break;case"done":{W=!0,console.log(),j$();let j=B.status==="completed"||B.status==="pr_created"?g("✓"):B.status==="failed"?P("✗"):d("●");console.log(` ${j} ${I(B.status)}`),console.log();break}}}catch(B){console.log(),console.log(` ${d("●")} ${I("Stream disconnected")} — checking job status...`),await r1(J,Y.value.id);return}if(!W)console.log(),console.log(` ${d("●")} ${I("Stream ended unexpectedly")} — checking job status...`),await r1(J,Y.value.id)});async function r1($,H){for(let J=0;J<60;J++){let _=await $.getJob(H);if(!_.ok)console.error(` ${P("✗")} Failed to fetch job status: ${_.error.message}`),process.exit(1);let Q=_.value;if(Q.status==="completed"||Q.status==="failed"||Q.status==="cancelled"){j$();let Y=Q.status==="completed"?g("✓"):Q.status==="failed"?P("✗"):d("●");if(console.log(` ${Y} ${I(Q.status)}`),Q.pr?.url)console.log(` ${U$("→")} ${v.underline(Q.pr.url)}`);console.log();return}await new Promise((Y)=>setTimeout(Y,1000))}console.log(` ${d("●")} Job is still running. Check status with: ${I(`arial jobs ${H}`)}`)}var a1=new T("repos").description("List connected GitHub repositories").option("--json","Output as JSON",!1).action(async($)=>{let X=await s().listGitHubRepos();if(!X.ok)x(X.error);$0(X.value.map((q)=>({name:q.fullName,private:q.private?"yes":"no",description:q.description??""})),[{key:"name",label:"Repository"},{key:"private",label:"Private"},{key:"description",label:"Description"}],$.json)});var s1=new T("usage").description("Show usage statistics for current billing period").option("--json","Output as JSON",!1).action(async($)=>{let X=await s().getUsage();if(!X.ok)x(X.error);let q=X.value;if($.json){J$(q,!0);return}console.log(),console.log(` ${I("Usage")} (${q.period})`),console.log(),S("Jobs",String(q.jobCount)),S("Conversations",String(q.conversationCount)),S("Input Tokens",q.totalInputTokens.toLocaleString()),S("Output Tokens",q.totalOutputTokens.toLocaleString()),S("Cache Creation",q.totalCacheCreationTokens.toLocaleString()),S("Cache Read",q.totalCacheReadTokens.toLocaleString()),S("Estimated Cost",`$${q.totalCostUsd.toFixed(2)}`),console.log()});var A$=new T().name("arial").description("Arial CLI — dispatch coding jobs from your terminal").version("0.0.1");A$.addCommand(R1);A$.addCommand(d1);A$.addCommand(n1);A$.addCommand(o1);A$.addCommand(a1);A$.addCommand(s1);A$.parse();
package/package.json CHANGED
@@ -1,42 +1,47 @@
1
1
  {
2
2
  "name": "arial-cli",
3
- "version": "0.1.7",
4
- "description": "A CLI utility to interact with LLMs",
3
+ "version": "0.2.1",
4
+ "description": "Arial CLI dispatch coding jobs from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
7
- "arial": "./dist/cli.js",
8
- "arial-cli": "./dist/cli.js"
7
+ "arial": "./dist/index.js"
9
8
  },
10
- "author": "Shane Neubauer",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "dev": "bun run src/index.ts",
14
+ "build": "bun build src/index.ts --outdir dist --target node --minify",
15
+ "typecheck": "tsc --noEmit",
16
+ "test": "echo 'No tests yet'",
17
+ "prepublishOnly": "pnpm run build"
18
+ },
19
+ "keywords": [
20
+ "arial",
21
+ "cli",
22
+ "ai",
23
+ "coding",
24
+ "agent",
25
+ "automation"
26
+ ],
27
+ "author": "Arial",
11
28
  "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/arial-ai/arial.git",
32
+ "directory": "apps/cli"
33
+ },
34
+ "homepage": "https://arial.sh",
12
35
  "engines": {
13
- "node": ">=18.0.0",
14
- "bun": ">=1.0.0"
36
+ "node": ">=18"
15
37
  },
16
- "files": [
17
- "dist",
18
- "README.md"
19
- ],
20
38
  "devDependencies": {
21
39
  "@types/bun": "latest",
22
- "@types/node": "^24.5.2"
23
- },
24
- "peerDependencies": {
40
+ "@workspace/client-sdk": "workspace:*",
41
+ "@workspace/types": "workspace:*",
42
+ "@workspace/typescript-config": "workspace:*",
43
+ "chalk": "^5.4.1",
44
+ "commander": "^13.1.0",
25
45
  "typescript": "^5.0.0"
26
- },
27
- "dependencies": {
28
- "@ai-sdk/openai": "^2.0.32",
29
- "ai": "^5.0.48",
30
- "chalk": "^5.6.2",
31
- "dotenv": "^17.2.2",
32
- "is-unicode-supported": "^2.1.0",
33
- "uuid": "^13.0.0",
34
- "zod": "^4.1.11"
35
- },
36
- "scripts": {
37
- "build": "bun build src/cli.ts --outdir dist --target node --format esm",
38
- "dev": "bun --watch src/cli.ts",
39
- "start": "bun src/cli.ts",
40
- "test": "bun test"
41
46
  }
42
- }
47
+ }