@astralbeam/cli 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import e from"node:process";e.env.NO_COLOR!==void 0&&delete e.env.FORCE_COLOR;const{run:t}=await import(`./program-CepxzKL7.js`);e.exitCode=await t(e.argv);export{};
2
+ import e from"node:process";e.env.NO_COLOR!==void 0&&delete e.env.FORCE_COLOR;const{run:t}=await import(`./program-CALrKSDX.js`);e.exitCode=await t(e.argv);export{};
@@ -88,7 +88,7 @@ complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name
88
88
  `)}`:``;t.fail(i(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(r).length,Object.keys(r).join(`, `)+n))}},a.unknownArguments=function(n,r,o,s,c=!0){let l=e.getInternalMethods().getCommandInstance().getCommands(),u=[],d=e.getInternalMethods().getContext();if(Object.keys(n).forEach(t=>{!Mt.includes(t)&&!Object.prototype.hasOwnProperty.call(o,t)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),t)&&!a.isValidAndSomeAliasIsNotNew(t,r)&&u.push(t)}),c&&(d.commands.length>0||l.length>0||s)&&n._.slice(d.commands.length).forEach(e=>{l.includes(``+e)||u.push(``+e)}),c){let t=e.getDemandedCommands()._?.max||0,r=d.commands.length+t;r<n._.length&&n._.slice(r).forEach(e=>{e=String(e),!d.commands.includes(e)&&!u.includes(e)&&u.push(e)})}u.length&&t.fail(i(`Unknown argument: %s`,`Unknown arguments: %s`,u.length,u.map(e=>e.trim()?e:`"${e}"`).join(`, `)))},a.unknownCommands=function(n){let r=e.getInternalMethods().getCommandInstance().getCommands(),a=[],o=e.getInternalMethods().getContext();return(o.commands.length>0||r.length>0)&&n._.slice(o.commands.length).forEach(e=>{r.includes(``+e)||a.push(``+e)}),a.length>0&&(t.fail(i(`Unknown command: %s`,`Unknown commands: %s`,a.length,a.join(`, `))),!0)},a.isValidAndSomeAliasIsNotNew=function(t,n){if(!Object.prototype.hasOwnProperty.call(n,t))return!1;let r=e.parsed.newAliases;return[t,...n[t]].some(e=>!Object.prototype.hasOwnProperty.call(r,e)||!r[t])},a.limitedChoices=function(n){let i=e.getOptions(),a={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach(e=>{Mt.indexOf(e)===-1&&Object.prototype.hasOwnProperty.call(i.choices,e)&&[].concat(n[e]).forEach(t=>{i.choices[e].indexOf(t)===-1&&t!==void 0&&(a[e]=(a[e]||[]).concat(t))})});let o=Object.keys(a);if(!o.length)return;let s=r(`Invalid values:`);o.forEach(e=>{s+=`\n ${r(`Argument: %s, Given: %s, Choices: %s`,e,t.stringifiedValues(a[e]),t.stringifiedValues(i.choices[e]))}`}),t.fail(s)};let o={};a.implies=function(t,r){P(`<string|object> [array|number|string]`,[t,r],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.implies(e,t[e])}):(e.global(t),o[t]||(o[t]=[]),Array.isArray(r)?r.forEach(e=>a.implies(t,e)):(Qe(r,void 0,n),o[t].push(r)))},a.getImplied=function(){return o};function s(e,t){let n=Number(t);return t=isNaN(n)?t:n,typeof t==`number`?t=e._.length>=t:t.match(/^--no-.+/)?(t=t.match(/^--no-(.+)/)[1],t=!Object.prototype.hasOwnProperty.call(e,t)):t=Object.prototype.hasOwnProperty.call(e,t),t}a.implications=function(e){let n=[];if(Object.keys(o).forEach(t=>{let r=t;(o[t]||[]).forEach(t=>{let i=r,a=t;i=s(e,i),t=s(e,t),i&&!t&&n.push(` ${r} -> ${a}`)})}),n.length){let e=`${r(`Implications failed:`)}\n`;n.forEach(t=>{e+=t}),t.fail(e)}};let c={};a.conflicts=function(t,n){P(`<string|object> [array|string]`,[t,n],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.conflicts(e,t[e])}):(e.global(t),c[t]||(c[t]=[]),Array.isArray(n)?n.forEach(e=>a.conflicts(t,e)):c[t].push(n))},a.getConflicting=()=>c,a.conflicting=function(i){Object.keys(i).forEach(e=>{c[e]&&c[e].forEach(n=>{n&&i[e]!==void 0&&i[n]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,n))})}),e.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(c).forEach(e=>{c[e].forEach(a=>{a&&i[n.Parser.camelCase(e)]!==void 0&&i[n.Parser.camelCase(a)]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,a))})})},a.recommendCommands=function(e,n){n=n.sort((e,t)=>t.length-e.length);let i=null,a=1/0;for(let t=0,r;(r=n[t])!==void 0;t++){let t=jt(e,r);t<=3&&t<a&&(a=t,i=r)}i&&t.fail(r(`Did you mean %s?`,i))},a.reset=function(e){return o=yt(o,t=>!e[t]),c=yt(c,t=>!e[t]),a};let l=[];return a.freeze=function(){l.push({implied:o,conflicting:c})},a.unfreeze=function(){let e=l.pop();Qe(e,void 0,n),{implied:o,conflicting:c}=e},a}let Pt=[],Ft;function It(e,t,n,r){Ft=r;let i={};if(Object.prototype.hasOwnProperty.call(e,`extends`)){if(typeof e.extends!=`string`)return i;let r=/\.json|\..*rc$/.test(e.extends),a=null;if(r)a=Rt(t,e.extends);else try{a=me.resolve(e.extends)}catch{return e}Lt(a),Pt.push(a),i=r?JSON.parse(Ft.readFileSync(a,`utf8`)):me(e.extends),delete e.extends,i=It(i,Ft.path.dirname(a),n,Ft)}return Pt=[],n?zt(i,e):Object.assign({},i,e)}function Lt(e){if(Pt.indexOf(e)>-1)throw new M(`Circular extended configurations: '${e}'.`)}function Rt(e,t){return Ft.path.resolve(e,t)}function zt(e,t){let n={};function r(e){return e&&typeof e==`object`&&!Array.isArray(e)}Object.assign(n,e);for(let i of Object.keys(t))n[i]=r(t[i])&&r(n[i])?zt(e[i],t[i]):t[i];return n}var F=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},I=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},L,Bt,Vt,Ht,R,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,z,Zt,Qt,$t,B,V,en,tn,nn,rn,an,on,sn,cn,H,ln,un,dn,U,fn,pn,W;function mn(e){return(t=[],n=e.process.cwd(),r)=>{let i=new Zn(t,n,r,e);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}const hn=Symbol(`copyDoubleDash`),gn=Symbol(`copyDoubleDash`),_n=Symbol(`deleteFromParserHintObject`),vn=Symbol(`emitWarning`),yn=Symbol(`freeze`),bn=Symbol(`getDollarZero`),xn=Symbol(`getParserConfiguration`),Sn=Symbol(`getUsageConfiguration`),Cn=Symbol(`guessLocale`),wn=Symbol(`guessVersion`),Tn=Symbol(`parsePositionalNumbers`),En=Symbol(`pkgUp`),Dn=Symbol(`populateParserHintArray`),On=Symbol(`populateParserHintSingleValueDictionary`),kn=Symbol(`populateParserHintArrayDictionary`),An=Symbol(`populateParserHintDictionary`),jn=Symbol(`sanitizeKey`),Mn=Symbol(`setKey`),Nn=Symbol(`unfreeze`),Pn=Symbol(`validateAsync`),Fn=Symbol(`getCommandInstance`),In=Symbol(`getContext`),Ln=Symbol(`getHasOutput`),Rn=Symbol(`getLoggerInstance`),zn=Symbol(`getParseContext`),Bn=Symbol(`getUsageInstance`),Vn=Symbol(`getValidationInstance`),Hn=Symbol(`hasParseCallback`),Un=Symbol(`isGlobalContext`),Wn=Symbol(`postProcess`),Gn=Symbol(`rebase`),Kn=Symbol(`reset`),qn=Symbol(`runYargsParserAndExecuteCommands`),Jn=Symbol(`runValidation`),Yn=Symbol(`setHasOutput`),Xn=Symbol(`kTrackManuallySetKeys`);var Zn=class{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,L.set(this,void 0),Bt.set(this,void 0),Vt.set(this,{commands:[],fullCommands:[]}),Ht.set(this,null),R.set(this,null),Ut.set(this,`show-hidden`),Wt.set(this,null),Gt.set(this,!0),Kt.set(this,{}),qt.set(this,!0),Jt.set(this,[]),Yt.set(this,void 0),Xt.set(this,{}),z.set(this,!1),Zt.set(this,null),Qt.set(this,!0),$t.set(this,void 0),B.set(this,``),V.set(this,void 0),en.set(this,void 0),tn.set(this,{}),nn.set(this,null),rn.set(this,null),an.set(this,{}),on.set(this,{}),sn.set(this,void 0),cn.set(this,!1),H.set(this,void 0),ln.set(this,!1),un.set(this,!1),dn.set(this,!1),U.set(this,void 0),fn.set(this,{}),pn.set(this,null),W.set(this,void 0),F(this,H,r,`f`),F(this,sn,e,`f`),F(this,Bt,t,`f`),F(this,en,n,`f`),F(this,Yt,new at(this),`f`),this.$0=this[bn](),this[Kn](),F(this,L,I(this,L,`f`),`f`),F(this,U,I(this,U,`f`),`f`),F(this,W,I(this,W,`f`),`f`),F(this,V,I(this,V,`f`),`f`),I(this,V,`f`).showHiddenOpt=I(this,Ut,`f`),F(this,$t,this[gn](),`f`)}addHelpOpt(e,t){return P(`[string|boolean] [string]`,[e,t],arguments.length),I(this,Zt,`f`)&&(this[_n](I(this,Zt,`f`)),F(this,Zt,null,`f`)),e===!1&&t===void 0||(F(this,Zt,typeof e==`string`?e:`help`,`f`),this.boolean(I(this,Zt,`f`)),this.describe(I(this,Zt,`f`),t||I(this,U,`f`).deferY18nLookup(`Show help`))),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(P(`[string|boolean] [string]`,[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==`string`?e:I(this,Ut,`f`);return this.boolean(n),this.describe(n,t||I(this,U,`f`).deferY18nLookup(`Show hidden options`)),I(this,V,`f`).showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return P(`<object|string|array> [string|array]`,[e,t],arguments.length),this[kn](this.alias.bind(this),`alias`,e,t),this}array(e){return P(`<array|string>`,[e],arguments.length),this[Dn](`array`,e),this[Xn](e),this}boolean(e){return P(`<array|string>`,[e],arguments.length),this[Dn](`boolean`,e),this[Xn](e),this}check(e,t){return P(`<function> [boolean]`,[e,t],arguments.length),this.middleware((t,n)=>ct(()=>e(t,n.getOptions()),n=>(n?(typeof n==`string`||n instanceof Error)&&I(this,U,`f`).fail(n.toString(),n):I(this,U,`f`).fail(I(this,H,`f`).y18n.__(`Argument check failed: %s`,e.toString())),t),e=>(I(this,U,`f`).fail(e.message?e.message:e.toString(),e),t)),!1,t),this}choices(e,t){return P(`<object|string|array> [string|array]`,[e,t],arguments.length),this[kn](this.choices.bind(this),`choices`,e,t),this}coerce(e,t){if(P(`<object|string|array> [function]`,[e,t],arguments.length),Array.isArray(e)){if(!t)throw new M(`coerce callback must be provided`);for(let n of e)this.coerce(n,t);return this}if(typeof e==`object`){for(let t of Object.keys(e))this.coerce(t,e[t]);return this}if(!t)throw new M(`coerce callback must be provided`);return I(this,V,`f`).key[e]=!0,I(this,Yt,`f`).addCoerceMiddleware((n,r)=>{let i;return Object.prototype.hasOwnProperty.call(n,e)?ct(()=>(i=r.getAliases(),t(n[e])),t=>{n[e]=t;let a=r.getInternalMethods().getParserConfiguration()[`strip-aliased`];if(i[e]&&a!==!0)for(let r of i[e])n[r]=t;return n},e=>{throw new M(e.message)}):n},e),this}conflicts(e,t){return P(`<string|object> [string|array]`,[e,t],arguments.length),I(this,W,`f`).conflicts(e,t),this}config(e=`config`,t,n){return P(`[object|string] [string|function] [function]`,[e,t,n],arguments.length),typeof e==`object`&&!Array.isArray(e)?(e=It(e,I(this,Bt,`f`),this[xn]()[`deep-merge-config`]||!1,I(this,H,`f`)),I(this,V,`f`).configObjects=(I(this,V,`f`).configObjects||[]).concat(e),this):(typeof t==`function`&&(n=t,t=void 0),this.describe(e,t||I(this,U,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(e)?e:[e]).forEach(e=>{I(this,V,`f`).config[e]=n||!0}),this)}completion(e,t,n){return P(`[string] [string|boolean|function] [function]`,[e,t,n],arguments.length),typeof t==`function`&&(n=t,t=void 0),F(this,R,e||I(this,R,`f`)||`completion`,`f`),!t&&t!==!1&&(t=`generate completion script`),this.command(I(this,R,`f`),t),n&&I(this,Ht,`f`).registerFunction(n),this}command(e,t,n,r,i,a){return P(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[e,t,n,r,i,a],arguments.length),I(this,L,`f`).addHandler(e,t,n,r,i,a),this}commands(e,t,n,r,i,a){return this.command(e,t,n,r,i,a)}commandDir(e,t){P(`<string> [object]`,[e,t],arguments.length);let n=I(this,en,`f`)||I(this,H,`f`).require;return I(this,L,`f`).addDirectory(e,n,I(this,H,`f`).getCallerFile(),t),this}count(e){return P(`<array|string>`,[e],arguments.length),this[Dn](`count`,e),this[Xn](e),this}default(e,t,n){return P(`<object|string|array> [*] [string]`,[e,t,n],arguments.length),n&&($e(e,I(this,H,`f`)),I(this,V,`f`).defaultDescription[e]=n),typeof t==`function`&&($e(e,I(this,H,`f`)),I(this,V,`f`).defaultDescription[e]||(I(this,V,`f`).defaultDescription[e]=I(this,U,`f`).functionDescription(t)),t=t.call()),this[On](this.default.bind(this),`default`,e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){return P(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[e,t,n,r],arguments.length),typeof t!=`number`&&(n=t,t=1/0),this.global(`_`,!1),I(this,V,`f`).demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(e=>{Qe(n,!0,I(this,H,`f`)),this.demandOption(e,n)}),t=1/0):typeof t!=`number`&&(n=t,t=1/0),typeof e==`number`?(Qe(n,!0,I(this,H,`f`)),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(e=>{Qe(n,!0,I(this,H,`f`)),this.demandOption(e,n)}):typeof n==`string`?this.demandOption(e,n):(n===!0||n===void 0)&&this.demandOption(e),this}demandOption(e,t){return P(`<object|string|array> [string]`,[e,t],arguments.length),this[On](this.demandOption.bind(this),`demandedOptions`,e,t),this}deprecateOption(e,t){return P(`<string> [string|boolean]`,[e,t],arguments.length),I(this,V,`f`).deprecatedOptions[e]=t,this}describe(e,t){return P(`<object|string|array> [string]`,[e,t],arguments.length),this[Mn](e,!0),I(this,U,`f`).describe(e,t),this}detectLocale(e){return P(`<boolean>`,[e],arguments.length),F(this,Gt,e,`f`),this}env(e){return P(`[string|boolean]`,[e],arguments.length),e===!1?delete I(this,V,`f`).envPrefix:I(this,V,`f`).envPrefix=e||``,this}epilogue(e){return P(`<string>`,[e],arguments.length),I(this,U,`f`).epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return P(`<string|array> [string]`,[e,t],arguments.length),Array.isArray(e)?e.forEach(e=>this.example(...e)):I(this,U,`f`).example(e,t),this}exit(e,t){F(this,z,!0,`f`),F(this,Wt,t,`f`),I(this,qt,`f`)&&I(this,H,`f`).process.exit(e)}exitProcess(e=!0){return P(`[boolean]`,[e],arguments.length),F(this,qt,e,`f`),this}fail(e){if(P(`<function|boolean>`,[e],arguments.length),typeof e==`boolean`&&e!==!1)throw new M(`Invalid first argument. Expected function or boolean 'false'`);return I(this,U,`f`).failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return P(`<array> [function]`,[e,t],arguments.length),t?I(this,Ht,`f`).getCompletion(e,t):new Promise((t,n)=>{I(this,Ht,`f`).getCompletion(e,(e,r)=>{e?n(e):t(r)})})}getDemandedOptions(){return P([],0),I(this,V,`f`).demandedOptions}getDemandedCommands(){return P([],0),I(this,V,`f`).demandedCommands}getDeprecatedOptions(){return P([],0),I(this,V,`f`).deprecatedOptions}getDetectLocale(){return I(this,Gt,`f`)}getExitProcess(){return I(this,qt,`f`)}getGroups(){return Object.assign({},I(this,Xt,`f`),I(this,on,`f`))}getHelp(){if(F(this,z,!0,`f`),!I(this,U,`f`).hasCachedHelpMessage()){if(!this.parsed){let e=this[qn](I(this,sn,`f`),void 0,void 0,0,!0);if(N(e))return e.then(()=>I(this,U,`f`).help())}let e=I(this,L,`f`).runDefaultBuilderOn(this);if(N(e))return e.then(()=>I(this,U,`f`).help())}return Promise.resolve(I(this,U,`f`).help())}getOptions(){return I(this,V,`f`)}getStrict(){return I(this,ln,`f`)}getStrictCommands(){return I(this,un,`f`)}getStrictOptions(){return I(this,dn,`f`)}global(e,t){return P(`<string|array> [boolean]`,[e,t],arguments.length),e=[].concat(e),t===!1?e.forEach(e=>{I(this,V,`f`).local.includes(e)||I(this,V,`f`).local.push(e)}):I(this,V,`f`).local=I(this,V,`f`).local.filter(t=>e.indexOf(t)===-1),this}group(e,t){P(`<string|array> <string>`,[e,t],arguments.length);let n=I(this,on,`f`)[t]||I(this,Xt,`f`)[t];I(this,on,`f`)[t]&&delete I(this,on,`f`)[t];let r={};return I(this,Xt,`f`)[t]=(n||[]).concat(e).filter(e=>r[e]?!1:r[e]=!0),this}hide(e){return P(`<string>`,[e],arguments.length),I(this,V,`f`).hiddenOptions.push(e),this}implies(e,t){return P(`<string|object> [number|string|array]`,[e,t],arguments.length),I(this,W,`f`).implies(e,t),this}locale(e){return P(`[string]`,[e],arguments.length),e===void 0?(this[Cn](),I(this,H,`f`).y18n.getLocale()):(F(this,Gt,!1,`f`),I(this,H,`f`).y18n.setLocale(e),this)}middleware(e,t,n){return I(this,Yt,`f`).addMiddleware(e,!!t,n)}nargs(e,t){return P(`<string|object|array> [number]`,[e,t],arguments.length),this[On](this.nargs.bind(this),`narg`,e,t),this}normalize(e){return P(`<array|string>`,[e],arguments.length),this[Dn](`normalize`,e),this}number(e){return P(`<array|string>`,[e],arguments.length),this[Dn](`number`,e),this[Xn](e),this}option(e,t){if(P(`<string|object> [object]`,[e,t],arguments.length),typeof e==`object`)Object.keys(e).forEach(t=>{this.options(t,e[t])});else{typeof t!=`object`&&(t={}),this[Xn](e),I(this,pn,`f`)&&(e===`version`||t?.alias===`version`)&&this[vn]([`"version" is a reserved word.`,`Please do one of the following:`,'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)",`- Use a different option key`,`https://yargs.js.org/docs/#api-reference-version`].join(`
89
89
  `),void 0,`versionWarning`),I(this,V,`f`).key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let r=t.demand||t.required||t.require;r&&this.demand(e,r),t.demandOption&&this.demandOption(e,typeof t.demandOption==`string`?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),`default`in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type===`boolean`)&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type===`array`)&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type===`number`)&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type===`string`)&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type===`count`)&&this.count(e),typeof t.global==`boolean`&&this.global(e,t.global),t.defaultDescription&&(I(this,V,`f`).defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let i=t.describe||t.description||t.desc,a=I(this,U,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(a,e)||typeof i==`string`)&&this.describe(e,i),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){P(`[string|array] [function|boolean|object] [function]`,[e,t,n],arguments.length),this[yn](),e===void 0&&(e=I(this,sn,`f`)),typeof t==`object`&&(F(this,rn,t,`f`),t=n),typeof t==`function`&&(F(this,nn,t,`f`),t=!1),t||F(this,sn,e,`f`),I(this,nn,`f`)&&F(this,qt,!1,`f`);let r=this[qn](e,!!t),i=this.parsed;return I(this,Ht,`f`).setParsed(this.parsed),N(r)?r.then(e=>(I(this,nn,`f`)&&I(this,nn,`f`).call(this,I(this,Wt,`f`),e,I(this,B,`f`)),e)).catch(e=>{throw I(this,nn,`f`)&&I(this,nn,`f`)(e,this.parsed.argv,I(this,B,`f`)),e}).finally(()=>{this[Nn](),this.parsed=i}):(I(this,nn,`f`)&&I(this,nn,`f`).call(this,I(this,Wt,`f`),r,I(this,B,`f`)),this[Nn](),this.parsed=i,r)}parseAsync(e,t,n){let r=this.parse(e,t,n);return N(r)?r:Promise.resolve(r)}parseSync(e,t,n){let r=this.parse(e,t,n);if(N(r))throw new M(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return r}parserConfiguration(e){return P(`<object>`,[e],arguments.length),F(this,tn,e,`f`),this}pkgConf(e,t){P(`<string> [string]`,[e,t],arguments.length);let n=null,r=this[En](t||I(this,Bt,`f`));return r[e]&&typeof r[e]==`object`&&(n=It(r[e],t||I(this,Bt,`f`),this[xn]()[`deep-merge-config`]||!1,I(this,H,`f`)),I(this,V,`f`).configObjects=(I(this,V,`f`).configObjects||[]).concat(n)),this}positional(e,t){P(`<string> <object>`,[e,t],arguments.length);let n=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];t=yt(t,(e,t)=>e===`type`&&![`string`,`number`,`boolean`].includes(t)?!1:n.includes(e));let r=I(this,Vt,`f`).fullCommands[I(this,Vt,`f`).fullCommands.length-1],i=r?I(this,L,`f`).cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return et(i).forEach(n=>{let r=i[n];Array.isArray(r)?r.indexOf(e)!==-1&&(t[n]=!0):r[e]&&!(n in t)&&(t[n]=r[e])}),this.group(e,I(this,U,`f`).getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return P(`[boolean]`,[e],arguments.length),F(this,cn,e,`f`),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return P(`<array|string|object> [number]`,[e],arguments.length),typeof e==`string`&&I(this,V,`f`).narg[e]||this[On](this.requiresArg.bind(this),`narg`,e,NaN),this}showCompletionScript(e,t){return P(`[string] [string]`,[e,t],arguments.length),e||=this.$0,I(this,$t,`f`).log(I(this,Ht,`f`).generateCompletionScript(e,t||I(this,R,`f`)||`completion`)),this}showHelp(e){if(P(`[string|function]`,[e],arguments.length),F(this,z,!0,`f`),!I(this,U,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[qn](I(this,sn,`f`),void 0,void 0,0,!0);if(N(t))return t.then(()=>{I(this,U,`f`).showHelp(e)}),this}let t=I(this,L,`f`).runDefaultBuilderOn(this);if(N(t))return t.then(()=>{I(this,U,`f`).showHelp(e)}),this}return I(this,U,`f`).showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return P(`[boolean|string] [string]`,[e,t],arguments.length),I(this,U,`f`).showHelpOnFail(e,t),this}showVersion(e){return P(`[string|function]`,[e],arguments.length),I(this,U,`f`).showVersion(e),this}skipValidation(e){return P(`<array|string>`,[e],arguments.length),this[Dn](`skipValidation`,e),this}strict(e){return P(`[boolean]`,[e],arguments.length),F(this,ln,e!==!1,`f`),this}strictCommands(e){return P(`[boolean]`,[e],arguments.length),F(this,un,e!==!1,`f`),this}strictOptions(e){return P(`[boolean]`,[e],arguments.length),F(this,dn,e!==!1,`f`),this}string(e){return P(`<array|string>`,[e],arguments.length),this[Dn](`string`,e),this[Xn](e),this}terminalWidth(){return P([],0),I(this,H,`f`).process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return P(`<object>`,[e],arguments.length),F(this,Gt,!1,`f`),I(this,H,`f`).y18n.updateLocale(e),this}usage(e,t,n,r){if(P(`<string|null|undefined> [string|boolean] [function|object] [function]`,[e,t,n,r],arguments.length),t!==void 0){if(Qe(e,null,I(this,H,`f`)),(e||``).match(/^\$0( |$)/))return this.command(e,t,n,r);throw new M(`.usage() description must start with $0 if being used as alias for .command()`)}return I(this,U,`f`).usage(e),this}usageConfiguration(e){return P(`<object>`,[e],arguments.length),F(this,fn,e,`f`),this}version(e,t,n){let r=`version`;if(P(`[boolean|string] [string] [string]`,[e,t,n],arguments.length),I(this,pn,`f`)&&(this[_n](I(this,pn,`f`)),I(this,U,`f`).version(void 0),F(this,pn,null,`f`)),arguments.length===0)n=this[wn](),e=r;else if(arguments.length===1){if(e===!1)return this;n=e,e=r}else arguments.length===2&&(n=t,t=void 0);return F(this,pn,typeof e==`string`?e:r,`f`),t||=I(this,U,`f`).deferY18nLookup(`Show version number`),I(this,U,`f`).version(n||void 0),this.boolean(I(this,pn,`f`)),this.describe(I(this,pn,`f`),t),this}wrap(e){return P(`<number|null|undefined>`,[e],arguments.length),I(this,U,`f`).wrap(e),this}[(L=/* @__PURE__ */ new WeakMap,Bt=/* @__PURE__ */ new WeakMap,Vt=/* @__PURE__ */ new WeakMap,Ht=/* @__PURE__ */ new WeakMap,R=/* @__PURE__ */ new WeakMap,Ut=/* @__PURE__ */ new WeakMap,Wt=/* @__PURE__ */ new WeakMap,Gt=/* @__PURE__ */ new WeakMap,Kt=/* @__PURE__ */ new WeakMap,qt=/* @__PURE__ */ new WeakMap,Jt=/* @__PURE__ */ new WeakMap,Yt=/* @__PURE__ */ new WeakMap,Xt=/* @__PURE__ */ new WeakMap,z=/* @__PURE__ */ new WeakMap,Zt=/* @__PURE__ */ new WeakMap,Qt=/* @__PURE__ */ new WeakMap,$t=/* @__PURE__ */ new WeakMap,B=/* @__PURE__ */ new WeakMap,V=/* @__PURE__ */ new WeakMap,en=/* @__PURE__ */ new WeakMap,tn=/* @__PURE__ */ new WeakMap,nn=/* @__PURE__ */ new WeakMap,rn=/* @__PURE__ */ new WeakMap,an=/* @__PURE__ */ new WeakMap,on=/* @__PURE__ */ new WeakMap,sn=/* @__PURE__ */ new WeakMap,cn=/* @__PURE__ */ new WeakMap,H=/* @__PURE__ */ new WeakMap,ln=/* @__PURE__ */ new WeakMap,un=/* @__PURE__ */ new WeakMap,dn=/* @__PURE__ */ new WeakMap,U=/* @__PURE__ */ new WeakMap,fn=/* @__PURE__ */ new WeakMap,pn=/* @__PURE__ */ new WeakMap,W=/* @__PURE__ */ new WeakMap,hn)](e){if(!e._||!e[`--`])return e;e._.push.apply(e._,e[`--`]);try{delete e[`--`]}catch{}return e}[gn](){return{log:(...e)=>{this[Hn]()||console.log(...e),F(this,z,!0,`f`),I(this,B,`f`).length&&F(this,B,I(this,B,`f`)+`
90
90
  `,`f`),F(this,B,I(this,B,`f`)+e.join(` `),`f`)},error:(...e)=>{this[Hn]()||console.error(...e),F(this,z,!0,`f`),I(this,B,`f`).length&&F(this,B,I(this,B,`f`)+`
91
- `,`f`),F(this,B,I(this,B,`f`)+e.join(` `),`f`)}}}[_n](e){et(I(this,V,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=I(this,V,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete I(this,U,`f`).getDescriptions()[e]}[vn](e,t,n){I(this,Kt,`f`)[n]||(I(this,H,`f`).process.emitWarning(e,t),I(this,Kt,`f`)[n]=!0)}[yn](){I(this,Jt,`f`).push({options:I(this,V,`f`),configObjects:I(this,V,`f`).configObjects.slice(0),exitProcess:I(this,qt,`f`),groups:I(this,Xt,`f`),strict:I(this,ln,`f`),strictCommands:I(this,un,`f`),strictOptions:I(this,dn,`f`),completionCommand:I(this,R,`f`),output:I(this,B,`f`),exitError:I(this,Wt,`f`),hasOutput:I(this,z,`f`),parsed:this.parsed,parseFn:I(this,nn,`f`),parseContext:I(this,rn,`f`)}),I(this,U,`f`).freeze(),I(this,W,`f`).freeze(),I(this,L,`f`).freeze(),I(this,Yt,`f`).freeze()}[bn](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(I(this,H,`f`).process.argv()[0])?I(this,H,`f`).process.argv().slice(1,2):I(this,H,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Gn](I(this,Bt,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),I(this,H,`f`).getEnv(`_`)&&I(this,H,`f`).getProcessArgvBin()===I(this,H,`f`).getEnv(`_`)&&(e=I(this,H,`f`).getEnv(`_`).replace(`${I(this,H,`f`).path.dirname(I(this,H,`f`).process.execPath())}/`,``)),e}[xn](){return I(this,tn,`f`)}[Sn](){return I(this,fn,`f`)}[Cn](){if(!I(this,Gt,`f`))return;let e=I(this,H,`f`).getEnv(`LC_ALL`)||I(this,H,`f`).getEnv(`LC_MESSAGES`)||I(this,H,`f`).getEnv(`LANG`)||I(this,H,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(e.replace(/[.:].*/,``))}[wn](){return this[En]().version||`unknown`}[Tn](e){let t=e[`--`]?e[`--`]:e._;for(let e=0,n;(n=t[e])!==void 0;e++)I(this,H,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[En](e){let t=e||`*`;if(I(this,an,`f`)[t])return I(this,an,`f`)[t];let n={};try{let t=e||I(this,H,`f`).mainFilename;!e&&I(this,H,`f`).path.extname(t)&&(t=I(this,H,`f`).path.dirname(t));let r=I(this,H,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Qe(r,void 0,I(this,H,`f`)),n=JSON.parse(I(this,H,`f`).readFileSync(r,`utf8`))}catch{}return I(this,an,`f`)[t]=n||{},I(this,an,`f`)[t]}[Dn](e,t){t=[].concat(t),t.forEach(t=>{t=this[jn](t),I(this,V,`f`)[e].push(t)})}[On](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{I(this,V,`f`)[e][t]=n})}[kn](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{I(this,V,`f`)[e][t]=(I(this,V,`f`)[e][t]||[]).concat(n)})}[An](e,t,n,r,i){if(Array.isArray(n))n.forEach(t=>{e(t,r)});else if((e=>typeof e==`object`)(n))for(let t of et(n))e(t,n[t]);else i(t,this[jn](n),r)}[jn](e){return e===`__proto__`?`___proto___`:e}[Mn](e,t){return this[On](this[Mn].bind(this),`key`,e,t),this}[Nn](){var e,t,n,r,i,a,o,s,c,l,u,d;let f=I(this,Jt,`f`).pop();Qe(f,void 0,I(this,H,`f`));let p;e=this,t=this,n=this,r=this,i=this,a=this,o=this,s=this,c=this,l=this,u=this,d=this,{options:{set value(t){F(e,V,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){F(t,qt,e,`f`)}}.value,groups:{set value(e){F(n,Xt,e,`f`)}}.value,output:{set value(e){F(r,B,e,`f`)}}.value,exitError:{set value(e){F(i,Wt,e,`f`)}}.value,hasOutput:{set value(e){F(a,z,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){F(o,ln,e,`f`)}}.value,strictCommands:{set value(e){F(s,un,e,`f`)}}.value,strictOptions:{set value(e){F(c,dn,e,`f`)}}.value,completionCommand:{set value(e){F(l,R,e,`f`)}}.value,parseFn:{set value(e){F(u,nn,e,`f`)}}.value,parseContext:{set value(e){F(d,rn,e,`f`)}}.value}=f,I(this,V,`f`).configObjects=p,I(this,U,`f`).unfreeze(),I(this,W,`f`).unfreeze(),I(this,L,`f`).unfreeze(),I(this,Yt,`f`).unfreeze()}[Pn](e,t){return ct(t,t=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Fn].bind(this),getContext:this[In].bind(this),getHasOutput:this[Ln].bind(this),getLoggerInstance:this[Rn].bind(this),getParseContext:this[zn].bind(this),getParserConfiguration:this[xn].bind(this),getUsageConfiguration:this[Sn].bind(this),getUsageInstance:this[Bn].bind(this),getValidationInstance:this[Vn].bind(this),hasParseCallback:this[Hn].bind(this),isGlobalContext:this[Un].bind(this),postProcess:this[Wn].bind(this),reset:this[Kn].bind(this),runValidation:this[Jn].bind(this),runYargsParserAndExecuteCommands:this[qn].bind(this),setHasOutput:this[Yn].bind(this)}}[Fn](){return I(this,L,`f`)}[In](){return I(this,Vt,`f`)}[Ln](){return I(this,z,`f`)}[Rn](){return I(this,$t,`f`)}[zn](){return I(this,rn,`f`)||{}}[Bn](){return I(this,U,`f`)}[Vn](){return I(this,W,`f`)}[Hn](){return!!I(this,nn,`f`)}[Un](){return I(this,Qt,`f`)}[Wn](e,t,n,r){return n||N(e)||(t||(e=this[hn](e)),(this[xn]()[`parse-positional-numbers`]||this[xn]()[`parse-positional-numbers`]===void 0)&&(e=this[Tn](e)),r&&(e=st(e,this,I(this,Yt,`f`).getMiddleware(),!1))),e}[Kn](e={}){F(this,V,I(this,V,`f`)||{},`f`);let t={};t.local=I(this,V,`f`).local||[],t.configObjects=I(this,V,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(I(this,on,`f`),Object.keys(I(this,Xt,`f`)).reduce((e,t)=>{let r=I(this,Xt,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),F(this,Xt,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(I(this,V,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=yt(I(this,V,`f`)[e],e=>!n[e])}),t.envPrefix=I(this,V,`f`).envPrefix,F(this,V,t,`f`),F(this,U,I(this,U,`f`)?I(this,U,`f`).reset(n):St(this,I(this,H,`f`)),`f`),F(this,W,I(this,W,`f`)?I(this,W,`f`).reset(n):Nt(this,I(this,U,`f`),I(this,H,`f`)),`f`),F(this,L,I(this,L,`f`)?I(this,L,`f`).reset():pt(I(this,U,`f`),I(this,W,`f`),I(this,Yt,`f`),I(this,H,`f`)),`f`),I(this,Ht,`f`)||F(this,Ht,Ot(this,I(this,U,`f`),I(this,L,`f`),I(this,H,`f`)),`f`),I(this,Yt,`f`).reset(),F(this,R,null,`f`),F(this,B,``,`f`),F(this,Wt,null,`f`),F(this,z,!1,`f`),this.parsed=!1,this}[Gn](e,t){return I(this,H,`f`).path.relative(e,t)}[qn](e,t,n,r=0,i=!1){let a=!!n||i;e||=I(this,sn,`f`),I(this,V,`f`).__=I(this,H,`f`).y18n.__,I(this,V,`f`).configuration=this[xn]();let o=!!I(this,V,`f`).configuration[`populate--`],s=Object.assign({},I(this,V,`f`).configuration,{"populate--":!0}),c=I(this,H,`f`).Parser.detailed(e,Object.assign({},I(this,V,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,I(this,rn,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===I(this,Zt,`f`)&&l[e]?f=!0:e===I(this,pn,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&I(this,U,`f`).clearCachedHelpMessage();try{if(this[Cn](),t)return this[Wn](l,o,!!n,!1);I(this,Zt,`f`)&&[I(this,Zt,`f`)].concat(d[I(this,Zt,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),F(this,Qt,!1,`f`);let s=I(this,L,`f`).getCommands(),m=I(this,Ht,`f`).completionKey in l,h=f||m||i;if(l._.length){if(s.length){let e;for(let t=r||0,a;l._[t]!==void 0;t++){if(a=String(l._[t]),s.includes(a)&&a!==I(this,R,`f`)){let e=I(this,L,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(!e&&a!==I(this,R,`f`)){e=a;break}}!I(this,L,`f`).hasDefaultCommand()&&I(this,cn,`f`)&&e&&!h&&I(this,W,`f`).recommendCommands(e,s)}I(this,R,`f`)&&l._.includes(I(this,R,`f`))&&!m&&(I(this,qt,`f`)&&bt(!0),this.showCompletionScript(),this.exit(0))}if(I(this,L,`f`).hasDefaultCommand()&&!h){let e=I(this,L,`f`).runCommand(null,this,c,0,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(m){I(this,qt,`f`)&&bt(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${I(this,Ht,`f`).completionKey}`)+1);return I(this,Ht,`f`).getCompletion(t,(e,t)=>{if(e)throw new M(e.message);(t||[]).forEach(e=>{I(this,$t,`f`).log(e)}),this.exit(0)}),this[Wn](l,!o,!!n,!1)}if(I(this,z,`f`)||(f?(I(this,qt,`f`)&&bt(!0),a=!0,this.showHelp(`log`),this.exit(0)):p&&(I(this,qt,`f`)&&bt(!0),a=!0,I(this,U,`f`).showVersion(`log`),this.exit(0))),!a&&I(this,V,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>I(this,V,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new M(c.error.message);if(!m){let e=this[Jn](d,{},c.error);n||(u=st(l,this,I(this,Yt,`f`).getMiddleware(),!0)),u=this[Pn](e,u??l),N(u)&&!n&&(u=u.then(()=>st(l,this,I(this,Yt,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof M)I(this,U,`f`).fail(e.message,e);else throw e}return this[Wn](u??l,o,!!n,!0)}[Jn](e,t,n,r){let i={...this.getDemandedOptions()};return a=>{if(n)throw new M(n.message);I(this,W,`f`).nonOptionCount(a),I(this,W,`f`).requiredArguments(a,i);let o=!1;I(this,un,`f`)&&(o=I(this,W,`f`).unknownCommands(a)),I(this,ln,`f`)&&!o?I(this,W,`f`).unknownArguments(a,e,t,!!r):I(this,dn,`f`)&&I(this,W,`f`).unknownArguments(a,e,{},!1,!1),I(this,W,`f`).limitedChoices(a),I(this,W,`f`).implications(a),I(this,W,`f`).conflicting(a)}}[Yn](){F(this,z,!0,`f`)}[Xn](e){if(typeof e==`string`)I(this,V,`f`).key[e]=!0;else for(let t of e)I(this,V,`f`).key[t]=!0}};function Qn(e){return!!e&&typeof e.getInternalMethods==`function`}const $n=mn(Ze);var er=class extends Error{};function tr(e){if(!Number.isInteger(e)||e<60||e>600)throw new er(`Expected a whole number of seconds from 60 to 600.`);return e}function nr(e,t=`https://astralbeam.ai/api`){return`${t.replace(/\/+$/,``)}${e.replace(/^\/api(?=\/)/,``)}`}function rr(e,t){if(!e||typeof e!=`object`)return!1;let n=e;return n.status===t&&typeof n.type==`string`&&typeof n.title==`string`&&typeof n.detail==`string`&&(n.reference===void 0||typeof n.reference==`string`)&&(n.issues===void 0||Array.isArray(n.issues)&&n.issues.every(e=>e&&typeof e.path==`string`&&typeof e.message==`string`))}async function ir(e,t){let{apiUrl:n,apiKey:r,astralBeamToken:i,fetchClient:a=globalThis.fetch,...o}=t,s=new Headers,c=o.headers instanceof Headers?o.headers.entries():Array.isArray(o.headers)?o.headers:Object.entries(o.headers??{});for(let[e,t]of c)s.set(e,t);s.delete(`authorization`),s.delete(`x-api-key`),r&&s.set(`x-api-key`,r),i&&s.set(`authorization`,`Bearer ${i}`);let l=await a(nr(e,n),{...o,headers:s,...r?{redirect:`error`}:{}});if(l.ok)return l;let u=await l.json().catch(e=>{if(!(e instanceof SyntaxError))throw e}),d=rr(u,l.status)?u:void 0;throw Object.assign(Error(d?.detail??`AstralBeam API returned HTTP ${l.status}`),{name:`AstralBeamApiError`,status:l.status,headers:l.headers,body:d})}async function ar(e,t){let n=await ir(e,t);if(n.status!==204)return await n.json()}function or(e){return e instanceof Error&&e.name===`AstralBeamApiError`&&`status`in e&&typeof e.status==`number`}function sr(e,t=`https://astralbeam.ai/api`){return`${t.replace(/\/+$/,``)}${e.replace(/^\/api(?=\/)/,``)}`}function cr(e,t){if(!e||typeof e!=`object`)return!1;let n=e;return n.status===t&&typeof n.type==`string`&&typeof n.title==`string`&&typeof n.detail==`string`&&(n.reference===void 0||typeof n.reference==`string`)&&(n.issues===void 0||Array.isArray(n.issues)&&n.issues.every(e=>e&&typeof e.path==`string`&&typeof e.message==`string`))}async function lr(e,t){let{apiUrl:n,apiKey:r,astralBeamToken:i,fetchClient:a=globalThis.fetch,...o}=t,s=new Headers,c=o.headers instanceof Headers?o.headers.entries():Array.isArray(o.headers)?o.headers:Object.entries(o.headers??{});for(let[e,t]of c)s.set(e,t);s.delete(`authorization`),s.delete(`x-api-key`),r&&s.set(`x-api-key`,r),i&&s.set(`authorization`,`Bearer ${i}`);let l=await a(sr(e,n),{...o,headers:s,...r?{redirect:`error`}:{}});if(l.ok)return l;let u=await l.json().catch(e=>{if(!(e instanceof SyntaxError))throw e}),d=cr(u,l.status)?u:void 0;throw Object.assign(Error(d?.detail??`AstralBeam API returned HTTP ${l.status}`),{name:`AstralBeamApiError`,status:l.status,headers:l.headers,body:d})}async function ur(e,t){let n=await lr(e,t);if(n.status!==204)return await n.json()}function G(e,t){return ur(e,t)}async function dr(e,t){let n=await lr(e,t),r=n.status===204?n.headers.get(`location`):null;if(!r)return n;let i=await globalThis.fetch(r,{credentials:`omit`,redirect:`error`,referrerPolicy:`no-referrer`,signal:t.signal??null});if(!i.ok)throw Error(`The file could not be downloaded. Please try again.`);return i}function fr(e,t){return lr(e,t)}const pr=()=>`/api/v1/organization`,mr=e=>ur(pr(),{...e,method:`GET`}),hr=()=>`/api/v1/chat/files`,gr=(e,t)=>{let n=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(hr(),{...t,method:`POST`,headers:{"Content-Type":`application/json`,...n(t?.headers)},body:JSON.stringify(e)})},_r=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([e,n])=>{n!==void 0&&t.append(e,n===null?`null`:String(n))});let n=t.toString();return n.length>0?`/api/v1/chat/files?${n}`:`/api/v1/chat/files`},vr=(e,t)=>dr(_r(e),{...t,method:`GET`}),yr=()=>`/api/v1/chat`,br=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([e,n])=>{n!==void 0&&t.append(e,n===null?`null`:String(n))});let n=t.toString();return n.length>0?`/api/v1/chat/config?${n}`:`/api/v1/chat/config`},xr=(e,t)=>G(br(e),{...t,method:`GET`}),Sr=()=>`/api/v1/chat/threads`,Cr=(e,t)=>{let n=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Sr(),{...t,method:`POST`,headers:{"Content-Type":`application/json`,...n(t?.headers)},body:JSON.stringify(e)})},wr=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([e,n])=>{n!==void 0&&t.append(e,n===null?`null`:String(n))});let n=t.toString();return n.length>0?`/api/v1/chat/threads?${n}`:`/api/v1/chat/threads`},Tr=(e,t)=>G(wr(e),{...t,method:`GET`}),Er=e=>`/api/v1/chat/threads/${encodeURIComponent(String(e))}`,Dr=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Er(e),{...n,method:`PATCH`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Or=(e,t)=>{let n=new URLSearchParams;Object.entries(t||{}).forEach(([e,t])=>{t!==void 0&&n.append(e,t===null?`null`:String(t))});let r=n.toString();return r.length>0?`/api/v1/chat/threads/${encodeURIComponent(String(e))}?${r}`:`/api/v1/chat/threads/${encodeURIComponent(String(e))}`},kr=(e,t,n)=>G(Or(e,t),{...n,method:`DELETE`}),Ar=(e,t)=>{let n=new URLSearchParams;Object.entries(t||{}).forEach(([e,t])=>{t!==void 0&&n.append(e,t===null?`null`:String(t))});let r=n.toString();return r.length>0?`/api/v1/chat/threads/${encodeURIComponent(String(e))}/messages?${r}`:`/api/v1/chat/threads/${encodeURIComponent(String(e))}/messages`},jr=(e,t,n)=>G(Ar(e,t),{...n,method:`GET`}),Mr=e=>`/api/v1/chat/threads/${encodeURIComponent(String(e))}/tool-results`,Nr=()=>`/api/v1/me`,Pr=e=>G(Nr(),{...e,method:`POST`}),Fr=()=>`/api/v1/me/mcp/catalog`,Ir=e=>G(Fr(),{...e,method:`GET`}),Lr=()=>`/api/v1/me/mcp/connections`,Rr=(e,t)=>{let n=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Lr(),{...t,method:`POST`,headers:{"Content-Type":`application/json`,...n(t?.headers)},body:JSON.stringify(e)})},zr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/headers`,Br=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(zr(e),{...n,method:`POST`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Vr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}`,Hr=(e,t)=>G(Vr(e),{...t,method:`DELETE`}),Ur=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/test`,Wr=(e,t)=>G(Ur(e),{...t,method:`POST`}),Gr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/authorize`,Kr=(e,t)=>G(Gr(e),{...t,method:`POST`}),qr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/oauth/bind`,Jr=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(qr(e),{...n,method:`POST`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Yr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/oauth/complete`,Xr=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Yr(e),{...n,method:`POST`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})};var Zr=`0.27.0`;function Qr(e){s.write(`${JSON.stringify(e,null,2)}\n`)}function $r(e,t=``){let n=``;for(let r of e){let e=r.codePointAt(0)??0;n+=(e<32||e>=127&&e<160)&&!t.includes(r)?`\\u${e.toString(16).padStart(4,`0`)}`:r}return n}function ei(e){return e==null?``:$r(typeof e==`string`?e:JSON.stringify(e))}function ti(e){let t=Object.entries(e),n=Math.max(...t.map(([e])=>e.length));for(let[e,r]of t)s.write(`${e.padEnd(n)} ${ei(r)}\n`)}function ni(e,t){t?Qr(e):ti(e)}function ri(e,t){let n=e.map(e=>t.map(t=>ei(e[t]))),r=t.map((e,t)=>n.reduce((e,n)=>Math.max(e,n[t]?.length??0),e.length)),i=e=>`${e.map((e,t)=>e.padEnd(r[t]??0)).join(` `)}`.trimEnd();s.write(`${i(t.map(e=>e.toUpperCase()))}\n`);for(let e of n)s.write(`${i(e)}\n`)}function ii(e){if(e.status===401)return"The API key was rejected. It may be revoked or deleted, so create a new one and run `astralbeam auth login` again.";if(e.status===404&&e.body?.detail===`Resource not found.`)return`This server does not serve that endpoint. Check the API URL, or the server may run an older AstralBeam release than this CLI (${Zr}).`;if(e.status===429)return`The API rate limit was reached. Wait a few minutes and retry.`}function ai(e,t,n,r){let i=e instanceof Error?e.message:String(e);if(t){let t=or(e)?e.body??{status:e.status,detail:i}:{detail:i};a.write(`${JSON.stringify({error:t,context:n??null})}\n`);return}if(!or(e))return void a.write(`Error: ${$r(i)}\n`);let o=r?` from ${r}`:``;a.write(`Error: ${$r(i)} (HTTP ${e.status}${o})\n`);for(let t of e.body?.issues??[])a.write(` ${$r(t.path)}: ${$r(t.message)}\n`);let s=ii(e);s&&a.write(`${s}\n`)}const oi=`https://astralbeam.ai/api`,si=/^key_([0-9a-f-]{36})_[0-9a-f-]{36}_abo_[A-Za-z]{64}$/;function ci(){if(n.ASTRALBEAM_CONFIG_DIR)return se(n.ASTRALBEAM_CONFIG_DIR,`config.json`);let e=i===`win32`?n.APPDATA??oe():n.XDG_CONFIG_HOME??se(oe(),`.config`);return se(e,`astralbeam`,`config.json`)}function li(e){let t=si.exec(e)?.[1];if(!t)throw Error(`The API key must match key_<organizationId>_<id>_abo_<secret>.`);return t}function ui(e){let t;try{t=new URL(e)}catch{throw Error(`The API URL "${e}" is not a valid URL.`)}let n=t.hostname,r=n===`localhost`||n===`[::1]`||ae(n)&&n.startsWith(`127.`);if(t.protocol!==`https:`&&!(t.protocol===`http:`&&r))throw Error(`The API URL "${e}" must use https://, or http:// only for loopback hosts.`);return e}function di(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fi(e){return di(e)&&Object.values(e).every(e=>di(e)&&typeof e.api_url==`string`&&typeof e.api_key==`string`&&di(e.organization)&&typeof e.organization.id==`string`&&typeof e.organization.name==`string`&&typeof e.organization.slug==`string`)}function pi(e){try{let t=JSON.parse(e);if(di(t)){let e=t.bindings===void 0?{}:t.bindings;if(fi(e))return{bindings:e}}}catch{}throw Error(`Invalid AstralBeam login bindings in ${ci()}`)}async function mi(){try{return pi(await b(ci(),`utf8`))}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{bindings:{}};throw e}}async function hi(e){let t=ci();await re(w(t),{recursive:!0,mode:448});let n=`${t}.${r}.tmp`;try{await C(n,`${JSON.stringify(e,null,2)}\n`,{mode:384,flag:`wx`}),await S(n,t)}catch(e){throw await ie(n,{force:!0}),e}}async function gi(){return await x(t())}function _i(e,t){for(let n=t;;n=w(n)){let t=e.bindings[n];if(t)return{directory:n,binding:t};if(w(n)===n)return}}function vi(e){let t=oe();return e===t||e.startsWith(t+le)?`~${e.slice(t.length)}`:e}const K={json:!1,context:void 0,failedRequest:void 0};function yi(e){K.context={organization:e.organization,bound_directory:e.directory??null},K.json||a.write(bi(e))}function bi(e){let{organization:t,directory:n}=e,r=t.name?`${$r(t.name)} (${$r(t.slug??``)}) · `:``,i=n?`bound at ${vi(n)}`:`from ASTRALBEAM_API_KEY`;return`▸ ${r}org ${t.id} · ${i}\n`}async function xi(){let e=n.ASTRALBEAM_API_KEY,t;if(e)t={apiKey:e,apiUrl:ui(n.ASTRALBEAM_API_URL??`https://astralbeam.ai/api`),organization:{id:li(e)}};else{let e=await gi(),r=_i(await mi(),e);if(!r)throw Error(`No AstralBeam login covers ${vi(e)}. Run \`astralbeam auth login\` in this directory or a parent, or set ASTRALBEAM_API_KEY.`);let{binding:i}=r;t={apiKey:i.api_key,apiUrl:ui(n.ASTRALBEAM_API_URL??i.api_url),organization:i.organization,directory:r.directory}}return yi(t),t}function Si(e,t=[]){let n=(e,r)=>{if(Array.isArray(e)||typeof e!=`object`||!e)return e;let i=Object.entries(e).flatMap(([e,i])=>{let a=[...r,e],o=t.some(e=>e.length===a.length&&e.every((e,t)=>e===a[t])),s=o?i:n(i,a);return s===void 0||!o&&typeof s==`object`&&s&&!Array.isArray(s)&&Object.keys(s).length===0?[]:[[e,s]]});return Object.fromEntries(i)};return n(e,[])}function Ci(e,t){let n=t.startsWith(`--`)?t:`--${t}`,r=e;if(e.startsWith(`@`)){let t=e.slice(1);if(t.length===0)throw Error(`${n} '@' must be followed by a file path (got empty path)`);let i=ce(t);try{r=ue(i,`utf-8`)}catch(e){let r=e instanceof Error?e.message:`unknown read error`;throw Error(`${n}: cannot read file at '${t}': ${r}`)}}try{return JSON.parse(r)}catch{throw Error(`Invalid JSON in ${n}. Expected valid JSON.`)}}function wi(e,t=[]){let n=Ci(e,`body`);for(let{path:e,flag:r}of t){let t=n;for(let n of e)t=Ti(t)&&Object.hasOwn(t,n)?t[n]:void 0;if(!Ti(t))throw Error(`--body must include a JSON object at ${e.join(`.`)} (for --${r}).`)}return n}function Ti(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ei(e,t,n=!1){let r=t.startsWith(`--`)?t:`--${t}`;if(e===void 0){if(n)throw Error(`${r} is required (or pass --body with this field set).`);return}if(typeof e!=`string`)throw Error(`${r} must be provided once as a JSON object.`);let i=Ci(e,t);if(!Ti(i))throw Error(`${r} must be a JSON object.`);return i}function Di(e,t,n=`text`){if(e===void 0||!e.startsWith(`@`))return e;let r=e.slice(1);if(r.length===0)throw Error(`--${t} '@' must be followed by a file path (got empty path)`);let i=ce(r),a;try{a=ue(i)}catch(e){let n=e instanceof Error?e.message:`unknown read error`;throw Error(`--${t}: cannot read file at '${r}': ${n}`)}switch(n){case`text`:return a.toString(`utf-8`);case`binary`:return a;case`base64`:return a.toString(`base64`);case`json`:{let e=a.toString(`utf-8`);try{return JSON.parse(e)}catch(e){let n=e instanceof Error?e.message:`unknown JSON parse error`;throw Error(`--${t}: file at '${r}' is not valid JSON: ${n}`)}}}}function Oi(e){return e.replace(/^filter_(.+)$/,`filter[$1]`)}async function ki(e){let{apiKey:t,apiUrl:n}=await xi();return{send(e,r={}){let i=new URLSearchParams;for(let t of e.query??[]){let e=r[t];e!==void 0&&i.set(Oi(t),typeof e==`string`?e:JSON.stringify(e))}return ar(e.path(r)+(i.size?`?${i.toString()}`:``),{apiKey:t,apiUrl:n,method:e.method,...e.body?{headers:{"content-type":`application/json`},body:JSON.stringify(r.body)}:{}})}}}function q(e,t){if(e!==void 0){if(K.json||typeof e!=`object`||!e)return Qr(e);if(`items`in e&&Array.isArray(e.items)){let t=e.items;t.length?ri(t,Object.keys(t[0])):a.write(`No results.
91
+ `,`f`),F(this,B,I(this,B,`f`)+e.join(` `),`f`)}}}[_n](e){et(I(this,V,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=I(this,V,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete I(this,U,`f`).getDescriptions()[e]}[vn](e,t,n){I(this,Kt,`f`)[n]||(I(this,H,`f`).process.emitWarning(e,t),I(this,Kt,`f`)[n]=!0)}[yn](){I(this,Jt,`f`).push({options:I(this,V,`f`),configObjects:I(this,V,`f`).configObjects.slice(0),exitProcess:I(this,qt,`f`),groups:I(this,Xt,`f`),strict:I(this,ln,`f`),strictCommands:I(this,un,`f`),strictOptions:I(this,dn,`f`),completionCommand:I(this,R,`f`),output:I(this,B,`f`),exitError:I(this,Wt,`f`),hasOutput:I(this,z,`f`),parsed:this.parsed,parseFn:I(this,nn,`f`),parseContext:I(this,rn,`f`)}),I(this,U,`f`).freeze(),I(this,W,`f`).freeze(),I(this,L,`f`).freeze(),I(this,Yt,`f`).freeze()}[bn](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(I(this,H,`f`).process.argv()[0])?I(this,H,`f`).process.argv().slice(1,2):I(this,H,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Gn](I(this,Bt,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),I(this,H,`f`).getEnv(`_`)&&I(this,H,`f`).getProcessArgvBin()===I(this,H,`f`).getEnv(`_`)&&(e=I(this,H,`f`).getEnv(`_`).replace(`${I(this,H,`f`).path.dirname(I(this,H,`f`).process.execPath())}/`,``)),e}[xn](){return I(this,tn,`f`)}[Sn](){return I(this,fn,`f`)}[Cn](){if(!I(this,Gt,`f`))return;let e=I(this,H,`f`).getEnv(`LC_ALL`)||I(this,H,`f`).getEnv(`LC_MESSAGES`)||I(this,H,`f`).getEnv(`LANG`)||I(this,H,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(e.replace(/[.:].*/,``))}[wn](){return this[En]().version||`unknown`}[Tn](e){let t=e[`--`]?e[`--`]:e._;for(let e=0,n;(n=t[e])!==void 0;e++)I(this,H,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[En](e){let t=e||`*`;if(I(this,an,`f`)[t])return I(this,an,`f`)[t];let n={};try{let t=e||I(this,H,`f`).mainFilename;!e&&I(this,H,`f`).path.extname(t)&&(t=I(this,H,`f`).path.dirname(t));let r=I(this,H,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Qe(r,void 0,I(this,H,`f`)),n=JSON.parse(I(this,H,`f`).readFileSync(r,`utf8`))}catch{}return I(this,an,`f`)[t]=n||{},I(this,an,`f`)[t]}[Dn](e,t){t=[].concat(t),t.forEach(t=>{t=this[jn](t),I(this,V,`f`)[e].push(t)})}[On](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{I(this,V,`f`)[e][t]=n})}[kn](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{I(this,V,`f`)[e][t]=(I(this,V,`f`)[e][t]||[]).concat(n)})}[An](e,t,n,r,i){if(Array.isArray(n))n.forEach(t=>{e(t,r)});else if((e=>typeof e==`object`)(n))for(let t of et(n))e(t,n[t]);else i(t,this[jn](n),r)}[jn](e){return e===`__proto__`?`___proto___`:e}[Mn](e,t){return this[On](this[Mn].bind(this),`key`,e,t),this}[Nn](){var e,t,n,r,i,a,o,s,c,l,u,d;let f=I(this,Jt,`f`).pop();Qe(f,void 0,I(this,H,`f`));let p;e=this,t=this,n=this,r=this,i=this,a=this,o=this,s=this,c=this,l=this,u=this,d=this,{options:{set value(t){F(e,V,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){F(t,qt,e,`f`)}}.value,groups:{set value(e){F(n,Xt,e,`f`)}}.value,output:{set value(e){F(r,B,e,`f`)}}.value,exitError:{set value(e){F(i,Wt,e,`f`)}}.value,hasOutput:{set value(e){F(a,z,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){F(o,ln,e,`f`)}}.value,strictCommands:{set value(e){F(s,un,e,`f`)}}.value,strictOptions:{set value(e){F(c,dn,e,`f`)}}.value,completionCommand:{set value(e){F(l,R,e,`f`)}}.value,parseFn:{set value(e){F(u,nn,e,`f`)}}.value,parseContext:{set value(e){F(d,rn,e,`f`)}}.value}=f,I(this,V,`f`).configObjects=p,I(this,U,`f`).unfreeze(),I(this,W,`f`).unfreeze(),I(this,L,`f`).unfreeze(),I(this,Yt,`f`).unfreeze()}[Pn](e,t){return ct(t,t=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Fn].bind(this),getContext:this[In].bind(this),getHasOutput:this[Ln].bind(this),getLoggerInstance:this[Rn].bind(this),getParseContext:this[zn].bind(this),getParserConfiguration:this[xn].bind(this),getUsageConfiguration:this[Sn].bind(this),getUsageInstance:this[Bn].bind(this),getValidationInstance:this[Vn].bind(this),hasParseCallback:this[Hn].bind(this),isGlobalContext:this[Un].bind(this),postProcess:this[Wn].bind(this),reset:this[Kn].bind(this),runValidation:this[Jn].bind(this),runYargsParserAndExecuteCommands:this[qn].bind(this),setHasOutput:this[Yn].bind(this)}}[Fn](){return I(this,L,`f`)}[In](){return I(this,Vt,`f`)}[Ln](){return I(this,z,`f`)}[Rn](){return I(this,$t,`f`)}[zn](){return I(this,rn,`f`)||{}}[Bn](){return I(this,U,`f`)}[Vn](){return I(this,W,`f`)}[Hn](){return!!I(this,nn,`f`)}[Un](){return I(this,Qt,`f`)}[Wn](e,t,n,r){return n||N(e)||(t||(e=this[hn](e)),(this[xn]()[`parse-positional-numbers`]||this[xn]()[`parse-positional-numbers`]===void 0)&&(e=this[Tn](e)),r&&(e=st(e,this,I(this,Yt,`f`).getMiddleware(),!1))),e}[Kn](e={}){F(this,V,I(this,V,`f`)||{},`f`);let t={};t.local=I(this,V,`f`).local||[],t.configObjects=I(this,V,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(I(this,on,`f`),Object.keys(I(this,Xt,`f`)).reduce((e,t)=>{let r=I(this,Xt,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),F(this,Xt,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(I(this,V,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=yt(I(this,V,`f`)[e],e=>!n[e])}),t.envPrefix=I(this,V,`f`).envPrefix,F(this,V,t,`f`),F(this,U,I(this,U,`f`)?I(this,U,`f`).reset(n):St(this,I(this,H,`f`)),`f`),F(this,W,I(this,W,`f`)?I(this,W,`f`).reset(n):Nt(this,I(this,U,`f`),I(this,H,`f`)),`f`),F(this,L,I(this,L,`f`)?I(this,L,`f`).reset():pt(I(this,U,`f`),I(this,W,`f`),I(this,Yt,`f`),I(this,H,`f`)),`f`),I(this,Ht,`f`)||F(this,Ht,Ot(this,I(this,U,`f`),I(this,L,`f`),I(this,H,`f`)),`f`),I(this,Yt,`f`).reset(),F(this,R,null,`f`),F(this,B,``,`f`),F(this,Wt,null,`f`),F(this,z,!1,`f`),this.parsed=!1,this}[Gn](e,t){return I(this,H,`f`).path.relative(e,t)}[qn](e,t,n,r=0,i=!1){let a=!!n||i;e||=I(this,sn,`f`),I(this,V,`f`).__=I(this,H,`f`).y18n.__,I(this,V,`f`).configuration=this[xn]();let o=!!I(this,V,`f`).configuration[`populate--`],s=Object.assign({},I(this,V,`f`).configuration,{"populate--":!0}),c=I(this,H,`f`).Parser.detailed(e,Object.assign({},I(this,V,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,I(this,rn,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===I(this,Zt,`f`)&&l[e]?f=!0:e===I(this,pn,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&I(this,U,`f`).clearCachedHelpMessage();try{if(this[Cn](),t)return this[Wn](l,o,!!n,!1);I(this,Zt,`f`)&&[I(this,Zt,`f`)].concat(d[I(this,Zt,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),F(this,Qt,!1,`f`);let s=I(this,L,`f`).getCommands(),m=I(this,Ht,`f`).completionKey in l,h=f||m||i;if(l._.length){if(s.length){let e;for(let t=r||0,a;l._[t]!==void 0;t++){if(a=String(l._[t]),s.includes(a)&&a!==I(this,R,`f`)){let e=I(this,L,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(!e&&a!==I(this,R,`f`)){e=a;break}}!I(this,L,`f`).hasDefaultCommand()&&I(this,cn,`f`)&&e&&!h&&I(this,W,`f`).recommendCommands(e,s)}I(this,R,`f`)&&l._.includes(I(this,R,`f`))&&!m&&(I(this,qt,`f`)&&bt(!0),this.showCompletionScript(),this.exit(0))}if(I(this,L,`f`).hasDefaultCommand()&&!h){let e=I(this,L,`f`).runCommand(null,this,c,0,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(m){I(this,qt,`f`)&&bt(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${I(this,Ht,`f`).completionKey}`)+1);return I(this,Ht,`f`).getCompletion(t,(e,t)=>{if(e)throw new M(e.message);(t||[]).forEach(e=>{I(this,$t,`f`).log(e)}),this.exit(0)}),this[Wn](l,!o,!!n,!1)}if(I(this,z,`f`)||(f?(I(this,qt,`f`)&&bt(!0),a=!0,this.showHelp(`log`),this.exit(0)):p&&(I(this,qt,`f`)&&bt(!0),a=!0,I(this,U,`f`).showVersion(`log`),this.exit(0))),!a&&I(this,V,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>I(this,V,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new M(c.error.message);if(!m){let e=this[Jn](d,{},c.error);n||(u=st(l,this,I(this,Yt,`f`).getMiddleware(),!0)),u=this[Pn](e,u??l),N(u)&&!n&&(u=u.then(()=>st(l,this,I(this,Yt,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof M)I(this,U,`f`).fail(e.message,e);else throw e}return this[Wn](u??l,o,!!n,!0)}[Jn](e,t,n,r){let i={...this.getDemandedOptions()};return a=>{if(n)throw new M(n.message);I(this,W,`f`).nonOptionCount(a),I(this,W,`f`).requiredArguments(a,i);let o=!1;I(this,un,`f`)&&(o=I(this,W,`f`).unknownCommands(a)),I(this,ln,`f`)&&!o?I(this,W,`f`).unknownArguments(a,e,t,!!r):I(this,dn,`f`)&&I(this,W,`f`).unknownArguments(a,e,{},!1,!1),I(this,W,`f`).limitedChoices(a),I(this,W,`f`).implications(a),I(this,W,`f`).conflicting(a)}}[Yn](){F(this,z,!0,`f`)}[Xn](e){if(typeof e==`string`)I(this,V,`f`).key[e]=!0;else for(let t of e)I(this,V,`f`).key[t]=!0}};function Qn(e){return!!e&&typeof e.getInternalMethods==`function`}const $n=mn(Ze);var er=class extends Error{};function tr(e){if(!Number.isInteger(e)||e<60||e>600)throw new er(`Expected a whole number of seconds from 60 to 600.`);return e}function nr(e,t=`https://astralbeam.ai/api`){return`${t.replace(/\/+$/,``)}${e.replace(/^\/api(?=\/)/,``)}`}function rr(e,t){if(!e||typeof e!=`object`)return!1;let n=e;return n.status===t&&typeof n.type==`string`&&typeof n.title==`string`&&typeof n.detail==`string`&&(n.reference===void 0||typeof n.reference==`string`)&&(n.issues===void 0||Array.isArray(n.issues)&&n.issues.every(e=>e&&typeof e.path==`string`&&typeof e.message==`string`))}async function ir(e,t){let{apiUrl:n,apiKey:r,astralBeamToken:i,fetchClient:a=globalThis.fetch,...o}=t,s=new Headers,c=o.headers instanceof Headers?o.headers.entries():Array.isArray(o.headers)?o.headers:Object.entries(o.headers??{});for(let[e,t]of c)s.set(e,t);s.delete(`authorization`),s.delete(`x-api-key`),r&&s.set(`x-api-key`,r),i&&s.set(`authorization`,`Bearer ${i}`);let l=await a(nr(e,n),{...o,headers:s,...r?{redirect:`error`}:{}});if(l.ok)return l;let u=await l.json().catch(e=>{if(!(e instanceof SyntaxError))throw e}),d=rr(u,l.status)?u:void 0;throw Object.assign(Error(d?.detail??`AstralBeam API returned HTTP ${l.status}`),{name:`AstralBeamApiError`,status:l.status,headers:l.headers,body:d})}async function ar(e,t){let n=await ir(e,t);if(n.status!==204)return await n.json()}function or(e){return e instanceof Error&&e.name===`AstralBeamApiError`&&`status`in e&&typeof e.status==`number`}function sr(e,t=`https://astralbeam.ai/api`){return`${t.replace(/\/+$/,``)}${e.replace(/^\/api(?=\/)/,``)}`}function cr(e,t){if(!e||typeof e!=`object`)return!1;let n=e;return n.status===t&&typeof n.type==`string`&&typeof n.title==`string`&&typeof n.detail==`string`&&(n.reference===void 0||typeof n.reference==`string`)&&(n.issues===void 0||Array.isArray(n.issues)&&n.issues.every(e=>e&&typeof e.path==`string`&&typeof e.message==`string`))}async function lr(e,t){let{apiUrl:n,apiKey:r,astralBeamToken:i,fetchClient:a=globalThis.fetch,...o}=t,s=new Headers,c=o.headers instanceof Headers?o.headers.entries():Array.isArray(o.headers)?o.headers:Object.entries(o.headers??{});for(let[e,t]of c)s.set(e,t);s.delete(`authorization`),s.delete(`x-api-key`),r&&s.set(`x-api-key`,r),i&&s.set(`authorization`,`Bearer ${i}`);let l=await a(sr(e,n),{...o,headers:s,...r?{redirect:`error`}:{}});if(l.ok)return l;let u=await l.json().catch(e=>{if(!(e instanceof SyntaxError))throw e}),d=cr(u,l.status)?u:void 0;throw Object.assign(Error(d?.detail??`AstralBeam API returned HTTP ${l.status}`),{name:`AstralBeamApiError`,status:l.status,headers:l.headers,body:d})}async function ur(e,t){let n=await lr(e,t);if(n.status!==204)return await n.json()}function G(e,t){return ur(e,t)}async function dr(e,t){let n=await lr(e,t),r=n.status===204?n.headers.get(`location`):null;if(!r)return n;let i=await globalThis.fetch(r,{credentials:`omit`,redirect:`error`,referrerPolicy:`no-referrer`,signal:t.signal??null});if(!i.ok)throw Error(`The file could not be downloaded. Please try again.`);return i}function fr(e,t){return lr(e,t)}const pr=()=>`/api/v1/organization`,mr=e=>ur(pr(),{...e,method:`GET`}),hr=()=>`/api/v1/chat/files`,gr=(e,t)=>{let n=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(hr(),{...t,method:`POST`,headers:{"Content-Type":`application/json`,...n(t?.headers)},body:JSON.stringify(e)})},_r=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([e,n])=>{n!==void 0&&t.append(e,n===null?`null`:String(n))});let n=t.toString();return n.length>0?`/api/v1/chat/files?${n}`:`/api/v1/chat/files`},vr=(e,t)=>dr(_r(e),{...t,method:`GET`}),yr=()=>`/api/v1/chat`,br=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([e,n])=>{n!==void 0&&t.append(e,n===null?`null`:String(n))});let n=t.toString();return n.length>0?`/api/v1/chat/config?${n}`:`/api/v1/chat/config`},xr=(e,t)=>G(br(e),{...t,method:`GET`}),Sr=()=>`/api/v1/chat/threads`,Cr=(e,t)=>{let n=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Sr(),{...t,method:`POST`,headers:{"Content-Type":`application/json`,...n(t?.headers)},body:JSON.stringify(e)})},wr=e=>{let t=new URLSearchParams;Object.entries(e||{}).forEach(([e,n])=>{n!==void 0&&t.append(e,n===null?`null`:String(n))});let n=t.toString();return n.length>0?`/api/v1/chat/threads?${n}`:`/api/v1/chat/threads`},Tr=(e,t)=>G(wr(e),{...t,method:`GET`}),Er=e=>`/api/v1/chat/threads/${encodeURIComponent(String(e))}`,Dr=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Er(e),{...n,method:`PATCH`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Or=(e,t)=>{let n=new URLSearchParams;Object.entries(t||{}).forEach(([e,t])=>{t!==void 0&&n.append(e,t===null?`null`:String(t))});let r=n.toString();return r.length>0?`/api/v1/chat/threads/${encodeURIComponent(String(e))}?${r}`:`/api/v1/chat/threads/${encodeURIComponent(String(e))}`},kr=(e,t,n)=>G(Or(e,t),{...n,method:`DELETE`}),Ar=(e,t)=>{let n=new URLSearchParams;Object.entries(t||{}).forEach(([e,t])=>{t!==void 0&&n.append(e,t===null?`null`:String(t))});let r=n.toString();return r.length>0?`/api/v1/chat/threads/${encodeURIComponent(String(e))}/messages?${r}`:`/api/v1/chat/threads/${encodeURIComponent(String(e))}/messages`},jr=(e,t,n)=>G(Ar(e,t),{...n,method:`GET`}),Mr=e=>`/api/v1/chat/threads/${encodeURIComponent(String(e))}/tool-results`,Nr=()=>`/api/v1/me`,Pr=e=>G(Nr(),{...e,method:`POST`}),Fr=()=>`/api/v1/me/mcp/catalog`,Ir=e=>G(Fr(),{...e,method:`GET`}),Lr=()=>`/api/v1/me/mcp/connections`,Rr=(e,t)=>{let n=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Lr(),{...t,method:`POST`,headers:{"Content-Type":`application/json`,...n(t?.headers)},body:JSON.stringify(e)})},zr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/headers`,Br=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(zr(e),{...n,method:`POST`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Vr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}`,Hr=(e,t)=>G(Vr(e),{...t,method:`DELETE`}),Ur=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/test`,Wr=(e,t)=>G(Ur(e),{...t,method:`POST`}),Gr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/authorize`,Kr=(e,t)=>G(Gr(e),{...t,method:`POST`}),qr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/oauth/bind`,Jr=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(qr(e),{...n,method:`POST`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Yr=e=>`/api/v1/me/mcp/connections/${encodeURIComponent(String(e))}/oauth/complete`,Xr=(e,t,n)=>{let r=e=>{if(!e)return{};if(e instanceof Headers)return Object.fromEntries(e.entries());if(Symbol.iterator in e)return Object.fromEntries(Array.from(e,e=>Array.from(e)));let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t};return G(Yr(e),{...n,method:`POST`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})};var Zr=`0.28.0`;function Qr(e){s.write(`${JSON.stringify(e,null,2)}\n`)}function $r(e,t=``){let n=``;for(let r of e){let e=r.codePointAt(0)??0;n+=(e<32||e>=127&&e<160)&&!t.includes(r)?`\\u${e.toString(16).padStart(4,`0`)}`:r}return n}function ei(e){return e==null?``:$r(typeof e==`string`?e:JSON.stringify(e))}function ti(e){let t=Object.entries(e),n=Math.max(...t.map(([e])=>e.length));for(let[e,r]of t)s.write(`${e.padEnd(n)} ${ei(r)}\n`)}function ni(e,t){t?Qr(e):ti(e)}function ri(e,t){let n=e.map(e=>t.map(t=>ei(e[t]))),r=t.map((e,t)=>n.reduce((e,n)=>Math.max(e,n[t]?.length??0),e.length)),i=e=>`${e.map((e,t)=>e.padEnd(r[t]??0)).join(` `)}`.trimEnd();s.write(`${i(t.map(e=>e.toUpperCase()))}\n`);for(let e of n)s.write(`${i(e)}\n`)}function ii(e){if(e.status===401)return"The API key was rejected. It may be revoked or deleted, so create a new one and run `astralbeam auth login` again.";if(e.status===404&&e.body?.detail===`Resource not found.`)return`This server does not serve that endpoint. Check the API URL, or the server may run an older AstralBeam release than this CLI (${Zr}).`;if(e.status===429)return`The API rate limit was reached. Wait a few minutes and retry.`}function ai(e,t,n,r){let i=e instanceof Error?e.message:String(e);if(t){let t=or(e)?e.body??{status:e.status,detail:i}:{detail:i};a.write(`${JSON.stringify({error:t,context:n??null})}\n`);return}if(!or(e))return void a.write(`Error: ${$r(i)}\n`);let o=r?` from ${r}`:``;a.write(`Error: ${$r(i)} (HTTP ${e.status}${o})\n`);for(let t of e.body?.issues??[])a.write(` ${$r(t.path)}: ${$r(t.message)}\n`);let s=ii(e);s&&a.write(`${s}\n`)}const oi=`https://astralbeam.ai/api`,si=/^key_([0-9a-f-]{36})_[0-9a-f-]{36}_abo_[A-Za-z]{64}$/;function ci(){if(n.ASTRALBEAM_CONFIG_DIR)return se(n.ASTRALBEAM_CONFIG_DIR,`config.json`);let e=i===`win32`?n.APPDATA??oe():n.XDG_CONFIG_HOME??se(oe(),`.config`);return se(e,`astralbeam`,`config.json`)}function li(e){let t=si.exec(e)?.[1];if(!t)throw Error(`The API key must match key_<organizationId>_<id>_abo_<secret>.`);return t}function ui(e){let t;try{t=new URL(e)}catch{throw Error(`The API URL "${e}" is not a valid URL.`)}let n=t.hostname,r=n===`localhost`||n===`[::1]`||ae(n)&&n.startsWith(`127.`);if(t.protocol!==`https:`&&!(t.protocol===`http:`&&r))throw Error(`The API URL "${e}" must use https://, or http:// only for loopback hosts.`);return e}function di(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fi(e){return di(e)&&Object.values(e).every(e=>di(e)&&typeof e.api_url==`string`&&typeof e.api_key==`string`&&di(e.organization)&&typeof e.organization.id==`string`&&typeof e.organization.name==`string`&&typeof e.organization.slug==`string`)}function pi(e){try{let t=JSON.parse(e);if(di(t)){let e=t.bindings===void 0?{}:t.bindings;if(fi(e))return{bindings:e}}}catch{}throw Error(`Invalid AstralBeam login bindings in ${ci()}`)}async function mi(){try{return pi(await b(ci(),`utf8`))}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{bindings:{}};throw e}}async function hi(e){let t=ci();await re(w(t),{recursive:!0,mode:448});let n=`${t}.${r}.tmp`;try{await C(n,`${JSON.stringify(e,null,2)}\n`,{mode:384,flag:`wx`}),await S(n,t)}catch(e){throw await ie(n,{force:!0}),e}}async function gi(){return await x(t())}function _i(e,t){for(let n=t;;n=w(n)){let t=e.bindings[n];if(t)return{directory:n,binding:t};if(w(n)===n)return}}function vi(e){let t=oe();return e===t||e.startsWith(t+le)?`~${e.slice(t.length)}`:e}const K={json:!1,context:void 0,failedRequest:void 0};function yi(e){K.context={organization:e.organization,bound_directory:e.directory??null},K.json||a.write(bi(e))}function bi(e){let{organization:t,directory:n}=e,r=t.name?`${$r(t.name)} (${$r(t.slug??``)}) · `:``,i=n?`bound at ${vi(n)}`:`from ASTRALBEAM_API_KEY`;return`▸ ${r}org ${t.id} · ${i}\n`}async function xi(){let e=n.ASTRALBEAM_API_KEY,t;if(e)t={apiKey:e,apiUrl:ui(n.ASTRALBEAM_API_URL??`https://astralbeam.ai/api`),organization:{id:li(e)}};else{let e=await gi(),r=_i(await mi(),e);if(!r)throw Error(`No AstralBeam login covers ${vi(e)}. Run \`astralbeam auth login\` in this directory or a parent, or set ASTRALBEAM_API_KEY.`);let{binding:i}=r;t={apiKey:i.api_key,apiUrl:ui(n.ASTRALBEAM_API_URL??i.api_url),organization:i.organization,directory:r.directory}}return yi(t),t}function Si(e,t=[]){let n=(e,r)=>{if(Array.isArray(e)||typeof e!=`object`||!e)return e;let i=Object.entries(e).flatMap(([e,i])=>{let a=[...r,e],o=t.some(e=>e.length===a.length&&e.every((e,t)=>e===a[t])),s=o?i:n(i,a);return s===void 0||!o&&typeof s==`object`&&s&&!Array.isArray(s)&&Object.keys(s).length===0?[]:[[e,s]]});return Object.fromEntries(i)};return n(e,[])}function Ci(e,t){let n=t.startsWith(`--`)?t:`--${t}`,r=e;if(e.startsWith(`@`)){let t=e.slice(1);if(t.length===0)throw Error(`${n} '@' must be followed by a file path (got empty path)`);let i=ce(t);try{r=ue(i,`utf-8`)}catch(e){let r=e instanceof Error?e.message:`unknown read error`;throw Error(`${n}: cannot read file at '${t}': ${r}`)}}try{return JSON.parse(r)}catch{throw Error(`Invalid JSON in ${n}. Expected valid JSON.`)}}function wi(e,t=[]){let n=Ci(e,`body`);for(let{path:e,flag:r}of t){let t=n;for(let n of e)t=Ti(t)&&Object.hasOwn(t,n)?t[n]:void 0;if(!Ti(t))throw Error(`--body must include a JSON object at ${e.join(`.`)} (for --${r}).`)}return n}function Ti(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ei(e,t,n=!1){let r=t.startsWith(`--`)?t:`--${t}`;if(e===void 0){if(n)throw Error(`${r} is required (or pass --body with this field set).`);return}if(typeof e!=`string`)throw Error(`${r} must be provided once as a JSON object.`);let i=Ci(e,t);if(!Ti(i))throw Error(`${r} must be a JSON object.`);return i}function Di(e,t,n=`text`){if(e===void 0||!e.startsWith(`@`))return e;let r=e.slice(1);if(r.length===0)throw Error(`--${t} '@' must be followed by a file path (got empty path)`);let i=ce(r),a;try{a=ue(i)}catch(e){let n=e instanceof Error?e.message:`unknown read error`;throw Error(`--${t}: cannot read file at '${r}': ${n}`)}switch(n){case`text`:return a.toString(`utf-8`);case`binary`:return a;case`base64`:return a.toString(`base64`);case`json`:{let e=a.toString(`utf-8`);try{return JSON.parse(e)}catch(e){let n=e instanceof Error?e.message:`unknown JSON parse error`;throw Error(`--${t}: file at '${r}' is not valid JSON: ${n}`)}}}}function Oi(e){return e.replace(/^filter_(.+)$/,`filter[$1]`)}async function ki(e){let{apiKey:t,apiUrl:n}=await xi();return{send(e,r={}){let i=new URLSearchParams;for(let t of e.query??[]){let e=r[t];e!==void 0&&i.set(Oi(t),typeof e==`string`?e:JSON.stringify(e))}return ar(e.path(r)+(i.size?`?${i.toString()}`:``),{apiKey:t,apiUrl:n,method:e.method,...e.body?{headers:{"content-type":`application/json`},body:JSON.stringify(r.body)}:{}})}}}function q(e,t){if(e!==void 0){if(K.json||typeof e!=`object`||!e)return Qr(e);if(`items`in e&&Array.isArray(e.items)){let t=e.items;t.length?ri(t,Object.keys(t[0])):a.write(`No results.
92
92
  `),`page_after`in e&&typeof e.page_after==`string`&&a.write(`More results: --page-after ${$r(e.page_after)}\n`)}else ni(e,!1)}}function J(e,t){return t()}let Ai=``;async function ji(e,t,n){return t.dryRun&&(Ai=(await xi()).apiUrl),n()}function Mi(e){e.query&&=Object.fromEntries(Object.entries(e.query).map(([e,t])=>[Oi(e),t])),Qr({...e,note:`Local request preview only. No HTTP request or server-side validation is performed.`,command:e.command.replace(/^cf /,`astralbeam `),url:nr(new URL(e.url).pathname.replace(/^\/client\/v4/,``),Ai)})}function Ni(e,t){throw Error(`Missing required option --${e} (or pass --body).`)}var Pi={method:`GET`,path:()=>`/api/v1/docs/search`,query:[`q`],errors:{400:`BadRequestError`,401:`UnauthorizedError`,403:`ForbiddenError`,404:`NotFoundError`,409:`ConflictError`,413:`ContentTooLargeError`,415:`UnsupportedMediaTypeError`,422:`UnprocessableEntityError`,429:`TooManyRequestsError`,500:`InternalServerError`,503:`ServiceUnavailableError`}};function Fi(e){return e.usage(`$0 docs search
93
93
 
94
94
  Search the published guides and API reference. Returns up to five matching pages with relative URLs and the best matching section. Accepts the same credentials as the resource APIs.`).option(`q`,{type:`string`,description:`Q`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ii={command:`search`,describe:`Search documentation`,builder:Fi,handler:async e=>ji({command:`docs search`,classification:{safeFlags:[`dry-run`]}},e,async()=>{let t={q:e.q};if(e.dryRun){Mi({command:`cf docs search`,method:`GET`,url:`https://api.cloudflare.com/client/v4/api/v1/docs/search`,pathParams:{},query:t,bodyKind:`none`});return}let n=await ki(e);q(await J(`Loading`,async()=>n.send(Pi,t)),{successLabel:`Loaded`})})},Li={command:`docs`,describe:`docs`,builder:e=>e.command(Ii).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};var Ri={method:`GET`,path:()=>`/api/v1/organization`,errors:{400:`BadRequestError`,401:`UnauthorizedError`,403:`ForbiddenError`,404:`NotFoundError`,409:`ConflictError`,413:`ContentTooLargeError`,415:`UnsupportedMediaTypeError`,422:`UnprocessableEntityError`,429:`TooManyRequestsError`,500:`InternalServerError`,503:`ServiceUnavailableError`}};function zi(e){return e.usage(`$0 organization get
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astralbeam/cli",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Command-line interface for AstralBeam organization admins and their coding agents",
5
5
  "homepage": "https://astralbeam.ai/docs/cli/getting-started",
6
6
  "bugs": "https://github.com/AstralBeamAI/astralbeam/issues",
@@ -44,7 +44,7 @@
44
44
  "generate:api": "bun run scripts/forge/generate.ts"
45
45
  },
46
46
  "devDependencies": {
47
- "@astralbeam/sdk": "0.27.0",
47
+ "@astralbeam/sdk": "0.28.0",
48
48
  "@types/bun": "1.4.4",
49
49
  "@types/node": "^26.2.0",
50
50
  "@types/yargs": "17.0.35",