@astralbeam/cli 0.30.5 → 0.30.6

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-Dvrig7OB.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-CJvUWh7_.js`);e.exitCode=await t(e.argv);export{};
@@ -92,7 +92,7 @@ Please do one of the following:
92
92
  - Use a different option key
93
93
  https://yargs.js.org/docs/#api-reference-version`,void 0,`versionWarning`),R(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&&(R(this,V,`f`).defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let i=t.describe||t.description||t.desc,a=R(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){I(`[string|array] [function|boolean|object] [function]`,[e,t,n],arguments.length),this[yn](),e===void 0&&(e=R(this,sn,`f`)),typeof t==`object`&&(L(this,rn,t,`f`),t=n),typeof t==`function`&&(L(this,nn,t,`f`),t=!1),t||L(this,sn,e,`f`),R(this,nn,`f`)&&L(this,Kt,!1,`f`);let r=this[qn](e,!!t),i=this.parsed;return R(this,Bt,`f`).setParsed(this.parsed),F(r)?r.then(e=>(R(this,nn,`f`)&&R(this,nn,`f`).call(this,R(this,Ut,`f`),e,R(this,B,`f`)),e)).catch(e=>{throw R(this,nn,`f`)&&R(this,nn,`f`)(e,this.parsed.argv,R(this,B,`f`)),e}).finally(()=>{this[Nn](),this.parsed=i}):(R(this,nn,`f`)&&R(this,nn,`f`).call(this,R(this,Ut,`f`),r,R(this,B,`f`)),this[Nn](),this.parsed=i,r)}parseAsync(e,t,n){let r=this.parse(e,t,n);return F(r)?r:Promise.resolve(r)}parseSync(e,t,n){let r=this.parse(e,t,n);if(F(r))throw new P(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return r}parserConfiguration(e){return I(`<object>`,[e],arguments.length),L(this,tn,e,`f`),this}pkgConf(e,t){I(`<string> [string]`,[e,t],arguments.length);let n=null,r=this[En](t||R(this,Rt,`f`));return r[e]&&typeof r[e]==`object`&&(n=Pt(r[e],t||R(this,Rt,`f`),this[xn]()[`deep-merge-config`]||!1,R(this,H,`f`)),R(this,V,`f`).configObjects=(R(this,V,`f`).configObjects||[]).concat(n)),this}positional(e,t){I(`<string> <object>`,[e,t],arguments.length);let n=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];t=_t(t,(e,t)=>e===`type`&&![`string`,`number`,`boolean`].includes(t)?!1:n.includes(e));let r=R(this,zt,`f`).fullCommands[R(this,zt,`f`).fullCommands.length-1],i=r?R(this,z,`f`).cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return Qe(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,R(this,U,`f`).getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return I(`[boolean]`,[e],arguments.length),L(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 I(`<array|string|object> [number]`,[e],arguments.length),typeof e==`string`&&R(this,V,`f`).narg[e]||this[On](this.requiresArg.bind(this),`narg`,e,NaN),this}showCompletionScript(e,t){return I(`[string] [string]`,[e,t],arguments.length),e||=this.$0,R(this,$t,`f`).log(R(this,Bt,`f`).generateCompletionScript(e,t||R(this,Vt,`f`)||`completion`)),this}showHelp(e){if(I(`[string|function]`,[e],arguments.length),L(this,Xt,!0,`f`),!R(this,U,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[qn](R(this,sn,`f`),void 0,void 0,0,!0);if(F(t))return t.then(()=>{R(this,U,`f`).showHelp(e)}),this}let t=R(this,z,`f`).runDefaultBuilderOn(this);if(F(t))return t.then(()=>{R(this,U,`f`).showHelp(e)}),this}return R(this,U,`f`).showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return I(`[boolean|string] [string]`,[e,t],arguments.length),R(this,U,`f`).showHelpOnFail(e,t),this}showVersion(e){return I(`[string|function]`,[e],arguments.length),R(this,U,`f`).showVersion(e),this}skipValidation(e){return I(`<array|string>`,[e],arguments.length),this[Dn](`skipValidation`,e),this}strict(e){return I(`[boolean]`,[e],arguments.length),L(this,ln,e!==!1,`f`),this}strictCommands(e){return I(`[boolean]`,[e],arguments.length),L(this,un,e!==!1,`f`),this}strictOptions(e){return I(`[boolean]`,[e],arguments.length),L(this,dn,e!==!1,`f`),this}string(e){return I(`<array|string>`,[e],arguments.length),this[Dn](`string`,e),this[Xn](e),this}terminalWidth(){return I([],0),R(this,H,`f`).process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return I(`<object>`,[e],arguments.length),L(this,Wt,!1,`f`),R(this,H,`f`).y18n.updateLocale(e),this}usage(e,t,n,r){if(I(`<string|null|undefined> [string|boolean] [function|object] [function]`,[e,t,n,r],arguments.length),t!==void 0){if(Xe(e,null,R(this,H,`f`)),(e||``).match(/^\$0( |$)/))return this.command(e,t,n,r);throw new P(`.usage() description must start with $0 if being used as alias for .command()`)}return R(this,U,`f`).usage(e),this}usageConfiguration(e){return I(`<object>`,[e],arguments.length),L(this,fn,e,`f`),this}version(e,t,n){let r=`version`;if(I(`[boolean|string] [string] [string]`,[e,t,n],arguments.length),R(this,pn,`f`)&&(this[_n](R(this,pn,`f`)),R(this,U,`f`).version(void 0),L(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 L(this,pn,typeof e==`string`?e:r,`f`),t||=R(this,U,`f`).deferY18nLookup(`Show version number`),R(this,U,`f`).version(n||void 0),this.boolean(R(this,pn,`f`)),this.describe(R(this,pn,`f`),t),this}wrap(e){return I(`<number|null|undefined>`,[e],arguments.length),R(this,U,`f`).wrap(e),this}[(z=/* @__PURE__ */ new WeakMap,Rt=/* @__PURE__ */ new WeakMap,zt=/* @__PURE__ */ new WeakMap,Bt=/* @__PURE__ */ new WeakMap,Vt=/* @__PURE__ */ new WeakMap,Ht=/* @__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,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),L(this,Xt,!0,`f`),R(this,B,`f`).length&&L(this,B,R(this,B,`f`)+`
94
94
  `,`f`),L(this,B,R(this,B,`f`)+e.join(` `),`f`)},error:(...e)=>{this[Hn]()||console.error(...e),L(this,Xt,!0,`f`),R(this,B,`f`).length&&L(this,B,R(this,B,`f`)+`
95
- `,`f`),L(this,B,R(this,B,`f`)+e.join(` `),`f`)}}}[_n](e){Qe(R(this,V,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=R(this,V,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete R(this,U,`f`).getDescriptions()[e]}[vn](e,t,n){R(this,Gt,`f`)[n]||(R(this,H,`f`).process.emitWarning(e,t),R(this,Gt,`f`)[n]=!0)}[yn](){R(this,qt,`f`).push({options:R(this,V,`f`),configObjects:R(this,V,`f`).configObjects.slice(0),exitProcess:R(this,Kt,`f`),groups:R(this,Yt,`f`),strict:R(this,ln,`f`),strictCommands:R(this,un,`f`),strictOptions:R(this,dn,`f`),completionCommand:R(this,Vt,`f`),output:R(this,B,`f`),exitError:R(this,Ut,`f`),hasOutput:R(this,Xt,`f`),parsed:this.parsed,parseFn:R(this,nn,`f`),parseContext:R(this,rn,`f`)}),R(this,U,`f`).freeze(),R(this,W,`f`).freeze(),R(this,z,`f`).freeze(),R(this,Jt,`f`).freeze()}[bn](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(R(this,H,`f`).process.argv()[0])?R(this,H,`f`).process.argv().slice(1,2):R(this,H,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Gn](R(this,Rt,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),R(this,H,`f`).getEnv(`_`)&&R(this,H,`f`).getProcessArgvBin()===R(this,H,`f`).getEnv(`_`)&&(e=R(this,H,`f`).getEnv(`_`).replace(`${R(this,H,`f`).path.dirname(R(this,H,`f`).process.execPath())}/`,``)),e}[xn](){return R(this,tn,`f`)}[Sn](){return R(this,fn,`f`)}[Cn](){if(!R(this,Wt,`f`))return;let e=R(this,H,`f`).getEnv(`LC_ALL`)||R(this,H,`f`).getEnv(`LC_MESSAGES`)||R(this,H,`f`).getEnv(`LANG`)||R(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++)R(this,H,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[En](e){let t=e||`*`;if(R(this,an,`f`)[t])return R(this,an,`f`)[t];let n={};try{let t=e||R(this,H,`f`).mainFilename;!e&&R(this,H,`f`).path.extname(t)&&(t=R(this,H,`f`).path.dirname(t));let r=R(this,H,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Xe(r,void 0,R(this,H,`f`)),n=JSON.parse(R(this,H,`f`).readFileSync(r,`utf8`))}catch{}return R(this,an,`f`)[t]=n||{},R(this,an,`f`)[t]}[Dn](e,t){t=[].concat(t),t.forEach(t=>{t=this[jn](t),R(this,V,`f`)[e].push(t)})}[On](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{R(this,V,`f`)[e][t]=n})}[kn](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{R(this,V,`f`)[e][t]=(R(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 Qe(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=R(this,qt,`f`).pop();Xe(f,void 0,R(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){L(e,V,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){L(t,Kt,e,`f`)}}.value,groups:{set value(e){L(n,Yt,e,`f`)}}.value,output:{set value(e){L(r,B,e,`f`)}}.value,exitError:{set value(e){L(i,Ut,e,`f`)}}.value,hasOutput:{set value(e){L(a,Xt,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){L(o,ln,e,`f`)}}.value,strictCommands:{set value(e){L(s,un,e,`f`)}}.value,strictOptions:{set value(e){L(c,dn,e,`f`)}}.value,completionCommand:{set value(e){L(l,Vt,e,`f`)}}.value,parseFn:{set value(e){L(u,nn,e,`f`)}}.value,parseContext:{set value(e){L(d,rn,e,`f`)}}.value}=f,R(this,V,`f`).configObjects=p,R(this,U,`f`).unfreeze(),R(this,W,`f`).unfreeze(),R(this,z,`f`).unfreeze(),R(this,Jt,`f`).unfreeze()}[Pn](e,t){return ot(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 R(this,z,`f`)}[In](){return R(this,zt,`f`)}[Ln](){return R(this,Xt,`f`)}[Rn](){return R(this,$t,`f`)}[zn](){return R(this,rn,`f`)||{}}[Bn](){return R(this,U,`f`)}[Vn](){return R(this,W,`f`)}[Hn](){return!!R(this,nn,`f`)}[Un](){return R(this,Qt,`f`)}[Wn](e,t,n,r){return n||F(e)||(t||(e=this[hn](e)),(this[xn]()[`parse-positional-numbers`]||this[xn]()[`parse-positional-numbers`]===void 0)&&(e=this[Tn](e)),r&&(e=at(e,this,R(this,Jt,`f`).getMiddleware(),!1))),e}[Kn](e={}){L(this,V,R(this,V,`f`)||{},`f`);let t={};t.local=R(this,V,`f`).local||[],t.configObjects=R(this,V,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(R(this,on,`f`),Object.keys(R(this,Yt,`f`)).reduce((e,t)=>{let r=R(this,Yt,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),L(this,Yt,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(R(this,V,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=_t(R(this,V,`f`)[e],e=>!n[e])}),t.envPrefix=R(this,V,`f`).envPrefix,L(this,V,t,`f`),L(this,U,R(this,U,`f`)?R(this,U,`f`).reset(n):bt(this,R(this,H,`f`)),`f`),L(this,W,R(this,W,`f`)?R(this,W,`f`).reset(n):jt(this,R(this,U,`f`),R(this,H,`f`)),`f`),L(this,z,R(this,z,`f`)?R(this,z,`f`).reset():dt(R(this,U,`f`),R(this,W,`f`),R(this,Jt,`f`),R(this,H,`f`)),`f`),R(this,Bt,`f`)||L(this,Bt,Et(this,R(this,U,`f`),R(this,z,`f`),R(this,H,`f`)),`f`),R(this,Jt,`f`).reset(),L(this,Vt,null,`f`),L(this,B,``,`f`),L(this,Ut,null,`f`),L(this,Xt,!1,`f`),this.parsed=!1,this}[Gn](e,t){return R(this,H,`f`).path.relative(e,t)}[qn](e,t,n,r=0,i=!1){let a=!!n||i;e||=R(this,sn,`f`),R(this,V,`f`).__=R(this,H,`f`).y18n.__,R(this,V,`f`).configuration=this[xn]();let o=!!R(this,V,`f`).configuration[`populate--`],s=Object.assign({},R(this,V,`f`).configuration,{"populate--":!0}),c=R(this,H,`f`).Parser.detailed(e,Object.assign({},R(this,V,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,R(this,rn,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===R(this,Zt,`f`)&&l[e]?f=!0:e===R(this,pn,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&R(this,U,`f`).clearCachedHelpMessage();try{if(this[Cn](),t)return this[Wn](l,o,!!n,!1);R(this,Zt,`f`)&&[R(this,Zt,`f`)].concat(d[R(this,Zt,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),L(this,Qt,!1,`f`);let s=R(this,z,`f`).getCommands(),m=R(this,Bt,`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!==R(this,Vt,`f`)){let e=R(this,z,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(!e&&a!==R(this,Vt,`f`)){e=a;break}}!R(this,z,`f`).hasDefaultCommand()&&R(this,cn,`f`)&&e&&!h&&R(this,W,`f`).recommendCommands(e,s)}R(this,Vt,`f`)&&l._.includes(R(this,Vt,`f`))&&!m&&(R(this,Kt,`f`)&&vt(!0),this.showCompletionScript(),this.exit(0))}if(R(this,z,`f`).hasDefaultCommand()&&!h){let e=R(this,z,`f`).runCommand(null,this,c,0,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(m){R(this,Kt,`f`)&&vt(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${R(this,Bt,`f`).completionKey}`)+1);return R(this,Bt,`f`).getCompletion(t,(e,t)=>{if(e)throw new P(e.message);(t||[]).forEach(e=>{R(this,$t,`f`).log(e)}),this.exit(0)}),this[Wn](l,!o,!!n,!1)}if(R(this,Xt,`f`)||(f?(R(this,Kt,`f`)&&vt(!0),a=!0,this.showHelp(`log`),this.exit(0)):p&&(R(this,Kt,`f`)&&vt(!0),a=!0,R(this,U,`f`).showVersion(`log`),this.exit(0))),!a&&R(this,V,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>R(this,V,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new P(c.error.message);if(!m){let e=this[Jn](d,{},c.error);n||(u=at(l,this,R(this,Jt,`f`).getMiddleware(),!0)),u=this[Pn](e,u??l),F(u)&&!n&&(u=u.then(()=>at(l,this,R(this,Jt,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof P)R(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 P(n.message);R(this,W,`f`).nonOptionCount(a),R(this,W,`f`).requiredArguments(a,i);let o=!1;R(this,un,`f`)&&(o=R(this,W,`f`).unknownCommands(a)),R(this,ln,`f`)&&!o?R(this,W,`f`).unknownArguments(a,e,t,!!r):R(this,dn,`f`)&&R(this,W,`f`).unknownArguments(a,e,{},!1,!1),R(this,W,`f`).limitedChoices(a),R(this,W,`f`).implications(a),R(this,W,`f`).conflicting(a)}}[Yn](){L(this,Xt,!0,`f`)}[Xn](e){if(typeof e==`string`)R(this,V,`f`).key[e]=!0;else for(let t of e)R(this,V,`f`).key[t]=!0}};function Qn(e){return!!e&&typeof e.getInternalMethods==`function`}const $n=mn(Ye);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.30.5`;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??ae():n.XDG_CONFIG_HOME??se(ae(),`.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]`||w(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(oe(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 ie(n,t)}catch(e){throw await S(n,{force:!0}),e}}async function gi(){return await x(t())}function _i(e,t){for(let n=t;;n=oe(n)){let t=e.bindings[n];if(t)return{directory:n,binding:t};if(oe(n)===n)return}}function vi(e){let t=ae();return e===t||e.startsWith(t+T)?`~${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=le(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=le(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.
95
+ `,`f`),L(this,B,R(this,B,`f`)+e.join(` `),`f`)}}}[_n](e){Qe(R(this,V,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=R(this,V,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete R(this,U,`f`).getDescriptions()[e]}[vn](e,t,n){R(this,Gt,`f`)[n]||(R(this,H,`f`).process.emitWarning(e,t),R(this,Gt,`f`)[n]=!0)}[yn](){R(this,qt,`f`).push({options:R(this,V,`f`),configObjects:R(this,V,`f`).configObjects.slice(0),exitProcess:R(this,Kt,`f`),groups:R(this,Yt,`f`),strict:R(this,ln,`f`),strictCommands:R(this,un,`f`),strictOptions:R(this,dn,`f`),completionCommand:R(this,Vt,`f`),output:R(this,B,`f`),exitError:R(this,Ut,`f`),hasOutput:R(this,Xt,`f`),parsed:this.parsed,parseFn:R(this,nn,`f`),parseContext:R(this,rn,`f`)}),R(this,U,`f`).freeze(),R(this,W,`f`).freeze(),R(this,z,`f`).freeze(),R(this,Jt,`f`).freeze()}[bn](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(R(this,H,`f`).process.argv()[0])?R(this,H,`f`).process.argv().slice(1,2):R(this,H,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[Gn](R(this,Rt,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),R(this,H,`f`).getEnv(`_`)&&R(this,H,`f`).getProcessArgvBin()===R(this,H,`f`).getEnv(`_`)&&(e=R(this,H,`f`).getEnv(`_`).replace(`${R(this,H,`f`).path.dirname(R(this,H,`f`).process.execPath())}/`,``)),e}[xn](){return R(this,tn,`f`)}[Sn](){return R(this,fn,`f`)}[Cn](){if(!R(this,Wt,`f`))return;let e=R(this,H,`f`).getEnv(`LC_ALL`)||R(this,H,`f`).getEnv(`LC_MESSAGES`)||R(this,H,`f`).getEnv(`LANG`)||R(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++)R(this,H,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[En](e){let t=e||`*`;if(R(this,an,`f`)[t])return R(this,an,`f`)[t];let n={};try{let t=e||R(this,H,`f`).mainFilename;!e&&R(this,H,`f`).path.extname(t)&&(t=R(this,H,`f`).path.dirname(t));let r=R(this,H,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});Xe(r,void 0,R(this,H,`f`)),n=JSON.parse(R(this,H,`f`).readFileSync(r,`utf8`))}catch{}return R(this,an,`f`)[t]=n||{},R(this,an,`f`)[t]}[Dn](e,t){t=[].concat(t),t.forEach(t=>{t=this[jn](t),R(this,V,`f`)[e].push(t)})}[On](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{R(this,V,`f`)[e][t]=n})}[kn](e,t,n,r){this[An](e,t,n,r,(e,t,n)=>{R(this,V,`f`)[e][t]=(R(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 Qe(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=R(this,qt,`f`).pop();Xe(f,void 0,R(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){L(e,V,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){L(t,Kt,e,`f`)}}.value,groups:{set value(e){L(n,Yt,e,`f`)}}.value,output:{set value(e){L(r,B,e,`f`)}}.value,exitError:{set value(e){L(i,Ut,e,`f`)}}.value,hasOutput:{set value(e){L(a,Xt,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){L(o,ln,e,`f`)}}.value,strictCommands:{set value(e){L(s,un,e,`f`)}}.value,strictOptions:{set value(e){L(c,dn,e,`f`)}}.value,completionCommand:{set value(e){L(l,Vt,e,`f`)}}.value,parseFn:{set value(e){L(u,nn,e,`f`)}}.value,parseContext:{set value(e){L(d,rn,e,`f`)}}.value}=f,R(this,V,`f`).configObjects=p,R(this,U,`f`).unfreeze(),R(this,W,`f`).unfreeze(),R(this,z,`f`).unfreeze(),R(this,Jt,`f`).unfreeze()}[Pn](e,t){return ot(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 R(this,z,`f`)}[In](){return R(this,zt,`f`)}[Ln](){return R(this,Xt,`f`)}[Rn](){return R(this,$t,`f`)}[zn](){return R(this,rn,`f`)||{}}[Bn](){return R(this,U,`f`)}[Vn](){return R(this,W,`f`)}[Hn](){return!!R(this,nn,`f`)}[Un](){return R(this,Qt,`f`)}[Wn](e,t,n,r){return n||F(e)||(t||(e=this[hn](e)),(this[xn]()[`parse-positional-numbers`]||this[xn]()[`parse-positional-numbers`]===void 0)&&(e=this[Tn](e)),r&&(e=at(e,this,R(this,Jt,`f`).getMiddleware(),!1))),e}[Kn](e={}){L(this,V,R(this,V,`f`)||{},`f`);let t={};t.local=R(this,V,`f`).local||[],t.configObjects=R(this,V,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(R(this,on,`f`),Object.keys(R(this,Yt,`f`)).reduce((e,t)=>{let r=R(this,Yt,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),L(this,Yt,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(R(this,V,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=_t(R(this,V,`f`)[e],e=>!n[e])}),t.envPrefix=R(this,V,`f`).envPrefix,L(this,V,t,`f`),L(this,U,R(this,U,`f`)?R(this,U,`f`).reset(n):bt(this,R(this,H,`f`)),`f`),L(this,W,R(this,W,`f`)?R(this,W,`f`).reset(n):jt(this,R(this,U,`f`),R(this,H,`f`)),`f`),L(this,z,R(this,z,`f`)?R(this,z,`f`).reset():dt(R(this,U,`f`),R(this,W,`f`),R(this,Jt,`f`),R(this,H,`f`)),`f`),R(this,Bt,`f`)||L(this,Bt,Et(this,R(this,U,`f`),R(this,z,`f`),R(this,H,`f`)),`f`),R(this,Jt,`f`).reset(),L(this,Vt,null,`f`),L(this,B,``,`f`),L(this,Ut,null,`f`),L(this,Xt,!1,`f`),this.parsed=!1,this}[Gn](e,t){return R(this,H,`f`).path.relative(e,t)}[qn](e,t,n,r=0,i=!1){let a=!!n||i;e||=R(this,sn,`f`),R(this,V,`f`).__=R(this,H,`f`).y18n.__,R(this,V,`f`).configuration=this[xn]();let o=!!R(this,V,`f`).configuration[`populate--`],s=Object.assign({},R(this,V,`f`).configuration,{"populate--":!0}),c=R(this,H,`f`).Parser.detailed(e,Object.assign({},R(this,V,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,R(this,rn,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===R(this,Zt,`f`)&&l[e]?f=!0:e===R(this,pn,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&R(this,U,`f`).clearCachedHelpMessage();try{if(this[Cn](),t)return this[Wn](l,o,!!n,!1);R(this,Zt,`f`)&&[R(this,Zt,`f`)].concat(d[R(this,Zt,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),L(this,Qt,!1,`f`);let s=R(this,z,`f`).getCommands(),m=R(this,Bt,`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!==R(this,Vt,`f`)){let e=R(this,z,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(!e&&a!==R(this,Vt,`f`)){e=a;break}}!R(this,z,`f`).hasDefaultCommand()&&R(this,cn,`f`)&&e&&!h&&R(this,W,`f`).recommendCommands(e,s)}R(this,Vt,`f`)&&l._.includes(R(this,Vt,`f`))&&!m&&(R(this,Kt,`f`)&&vt(!0),this.showCompletionScript(),this.exit(0))}if(R(this,z,`f`).hasDefaultCommand()&&!h){let e=R(this,z,`f`).runCommand(null,this,c,0,i,f||p||i);return this[Wn](e,o,!!n,!1)}if(m){R(this,Kt,`f`)&&vt(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${R(this,Bt,`f`).completionKey}`)+1);return R(this,Bt,`f`).getCompletion(t,(e,t)=>{if(e)throw new P(e.message);(t||[]).forEach(e=>{R(this,$t,`f`).log(e)}),this.exit(0)}),this[Wn](l,!o,!!n,!1)}if(R(this,Xt,`f`)||(f?(R(this,Kt,`f`)&&vt(!0),a=!0,this.showHelp(`log`),this.exit(0)):p&&(R(this,Kt,`f`)&&vt(!0),a=!0,R(this,U,`f`).showVersion(`log`),this.exit(0))),!a&&R(this,V,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>R(this,V,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new P(c.error.message);if(!m){let e=this[Jn](d,{},c.error);n||(u=at(l,this,R(this,Jt,`f`).getMiddleware(),!0)),u=this[Pn](e,u??l),F(u)&&!n&&(u=u.then(()=>at(l,this,R(this,Jt,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof P)R(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 P(n.message);R(this,W,`f`).nonOptionCount(a),R(this,W,`f`).requiredArguments(a,i);let o=!1;R(this,un,`f`)&&(o=R(this,W,`f`).unknownCommands(a)),R(this,ln,`f`)&&!o?R(this,W,`f`).unknownArguments(a,e,t,!!r):R(this,dn,`f`)&&R(this,W,`f`).unknownArguments(a,e,{},!1,!1),R(this,W,`f`).limitedChoices(a),R(this,W,`f`).implications(a),R(this,W,`f`).conflicting(a)}}[Yn](){L(this,Xt,!0,`f`)}[Xn](e){if(typeof e==`string`)R(this,V,`f`).key[e]=!0;else for(let t of e)R(this,V,`f`).key[t]=!0}};function Qn(e){return!!e&&typeof e.getInternalMethods==`function`}const $n=mn(Ye);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.30.6`;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??ae():n.XDG_CONFIG_HOME??se(ae(),`.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]`||w(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(oe(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 ie(n,t)}catch(e){throw await S(n,{force:!0}),e}}async function gi(){return await x(t())}function _i(e,t){for(let n=t;;n=oe(n)){let t=e.bindings[n];if(t)return{directory:n,binding:t};if(oe(n)===n)return}}function vi(e){let t=ae();return e===t||e.startsWith(t+T)?`~${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=le(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=le(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.
96
96
  `),`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
97
97
 
98
98
  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.30.5",
3
+ "version": "0.30.6",
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.30.5",
47
+ "@astralbeam/sdk": "0.30.6",
48
48
  "@effect/tsgo": "0.67.5",
49
49
  "@types/bun": "1.4.4",
50
50
  "@types/node": "^26.2.0",