@astralbeam/cli 0.13.3 → 0.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astralbeam.js +1 -1
- package/package.json +1 -1
package/dist/astralbeam.js
CHANGED
|
@@ -17,7 +17,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
17
17
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
18
18
|
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(t,n){n=n.slice();let r=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function i(e,t){let n=u.resolve(e,t);if(h.existsSync(n))return n;if(r.includes(u.extname(t)))return;let i=r.find(e=>h.existsSync(`${n}${e}`));if(i)return`${n}${i}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=t._executableFile||`${this._name}-${t._name}`,o=this._executableDir||``;if(this._scriptPath){let e;try{e=h.realpathSync(this._scriptPath)}catch{e=this._scriptPath}o=u.resolve(u.dirname(e),o)}if(o){let e=i(o,a);if(!e&&!t._executableFile&&this._scriptPath){let n=u.basename(this._scriptPath,u.extname(this._scriptPath));n!==this._name&&(e=i(o,`${n}-${t._name}`))}a=e||a}let s=r.includes(u.extname(a)),c;e.platform===`win32`?(this._checkForMissingExecutable(a,o,t._name),n.unshift(a),n=ge(e.execArgv).concat(n),c=l.spawn(e.execPath,n,{stdio:`inherit`})):s?(n.unshift(a),n=ge(e.execArgv).concat(n),c=l.spawn(e.argv[0],n,{stdio:`inherit`})):c=l.spawn(a,n,{stdio:`inherit`}),c.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(t=>{e.on(t,()=>{c.killed===!1&&c.exitCode===null&&c.kill(t)})});let d=this._exitCallback;c.on(`close`,t=>{t??=1,d?d(new b(t,`commander.executeSubCommandAsync`,`(close)`)):e.exit(t)}),c.on(`error`,n=>{if(n.code===`ENOENT`)this._checkForMissingExecutable(a,o,t._name);else if(n.code===`EACCES`)throw Error(`'${a}' not executable`);if(!d)e.exit(1);else{let e=new b(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=n,d(e)}}),this.runningCommand=c}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
19
19
|
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in e.env){let n=t.attributeName();(this.getOptionValue(n)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(n)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,e.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let e=new ue(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=me(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=e.length,i=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${r}: ${e.join(`, `)}.`;this.error(i,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=me(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>ce(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=u.basename(e,u.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(t){this.outputHelp(t);let n=Number(e.exitCode??0);n===0&&t&&typeof t!=`function`&&t.error&&(n=1),this._exit(n,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
20
|
-
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function ge(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _e(){if(e.env.NO_COLOR||e.env.FORCE_COLOR===`0`||e.env.FORCE_COLOR===`false`)return!1;if(e.env.FORCE_COLOR||e.env.CLICOLOR_FORCE!==void 0)return!0}new he;var ve=`0.13.
|
|
20
|
+
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function ge(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _e(){if(e.env.NO_COLOR||e.env.FORCE_COLOR===`0`||e.env.FORCE_COLOR===`false`)return!1;if(e.env.FORCE_COLOR||e.env.CLICOLOR_FORCE!==void 0)return!0}new he;var ve=`0.13.4`;function ye(e){return e instanceof Error&&e.name===`AstralBeamApiError`&&`status`in e&&typeof e.status==`number`}function be(e,t=`https://app.astralbeam.ai/api`){return`${t.replace(/\/+$/,``)}${e.replace(/^\/api(?=\/)/,``)}`}function xe(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.issues===void 0||Array.isArray(n.issues)&&n.issues.every(e=>e&&typeof e.path==`string`&&typeof e.message==`string`))}async function Se(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(be(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=xe(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 C(e,t){return await(await Se(e,t)).json()}function Ce(e,t){return C(e,t)}function we(e,t){return Se(e,t)}const Te=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/tenants?${n}`:`/api/v1/tenants`},Ee=(e,t)=>C(Te(e),{...t,method:`GET`}),De=()=>`/api/v1/tenants`,Oe=(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 C(De(),{...t,method:`POST`,headers:{"Content-Type":`application/json`,...n(t?.headers)},body:JSON.stringify(e)})},ke=e=>`/api/v1/tenants/${encodeURIComponent(String(e))}`,Ae=(e,t)=>C(ke(e),{...t,method:`GET`}),je=e=>`/api/v1/tenants/${encodeURIComponent(String(e))}`,Me=(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 C(je(e),{...n,method:`PATCH`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Ne=(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/tenants/${encodeURIComponent(String(e))}/tenant_users?${r}`:`/api/v1/tenants/${encodeURIComponent(String(e))}/tenant_users`},Pe=(e,t,n)=>C(Ne(e,t),{...n,method:`GET`}),Fe=e=>`/api/v1/tenants/${encodeURIComponent(String(e))}/tenant_users`,Ie=(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 C(Fe(e),{...n,method:`POST`,headers:{"Content-Type":`application/json`,...r(n?.headers)},body:JSON.stringify(t)})},Le=(e,t)=>`/api/v1/tenants/${encodeURIComponent(String(e))}/tenant_users/${encodeURIComponent(String(t))}`,Re=(e,t,n)=>C(Le(e,t),{...n,method:`GET`}),ze=(e,t)=>`/api/v1/tenants/${encodeURIComponent(String(e))}/tenant_users/${encodeURIComponent(String(t))}`,Be=(e,t,n,r)=>{let i=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 C(ze(e,t),{...r,method:`PATCH`,headers:{"Content-Type":`application/json`,...i(r?.headers)},body:JSON.stringify(n)})},Ve=()=>`/api/v1/organization`,He=e=>C(Ve(),{...e,method:`GET`}),Ue=()=>`/api/v1/chat`,We=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`},Ge=(e,t)=>Ce(We(e),{...t,method:`GET`}),Ke=()=>`/api/v1/me`,qe=e=>Ce(Ke(),{...e,method:`POST`});function w(e){s.write(`${JSON.stringify(e,null,2)}\n`)}function T(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 Je(e){return e==null?``:T(typeof e==`string`?e:JSON.stringify(e))}function Ye(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)} ${Je(r)}\n`)}function E(e,t){t?w(e):Ye(e)}function Xe(e,t){let n=e.map(e=>t.map(t=>Je(e[t]))),r=t.map((e,t)=>Math.max(e.length,...n.map(e=>e[t]?.length??0))),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 Ze(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 (${ve}).`;if(e.status===429)return`The API rate limit was reached. Wait a few minutes and retry.`}function Qe(e,t,n,r){let i=e instanceof Error?e.message:String(e);if(t){let t=ye(e)?e.body??{status:e.status,detail:i}:{detail:i};a.write(`${JSON.stringify({error:t,context:n??null})}\n`);return}if(!ye(e))return void a.write(`Error: ${T(i)}\n`);let o=r?` from ${r}`:``;a.write(`Error: ${T(i)} (HTTP ${e.status}${o})\n`);for(let t of e.body?.issues??[])a.write(` ${T(t.path)}: ${T(t.message)}\n`);let s=Ze(e);s&&a.write(`${s}\n`)}const $e=`https://app.astralbeam.ai/api`,et=/^key_([0-9a-f-]{36})_[0-9a-f-]{36}_abo_[A-Za-z]{64}$/;function tt(){return n.ASTRALBEAM_CONFIG_DIR?f(n.ASTRALBEAM_CONFIG_DIR,`config.json`):f(i===`win32`?n.APPDATA??ie():n.XDG_CONFIG_HOME??f(ie(),`.config`),`astralbeam`,`config.json`)}function nt(e){let t=et.exec(e)?.[1];if(!t)throw Error(`The API key must match key_<organizationId>_<id>_abo_<secret>.`);return t}function rt(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]`||y(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 localhost.`);return e}async function D(){try{return{bindings:JSON.parse(await v(tt(),`utf8`)).bindings??{}}}catch(e){if(e.code===`ENOENT`)return{bindings:{}};throw e}}async function it(e){let t=tt();await _(d(t),{recursive:!0,mode:448});let n=`${t}.${r}.tmp`;try{await re(n,`${JSON.stringify(e,null,2)}\n`,{mode:384,flag:`wx`}),await te(n,t)}catch(e){throw await ne(n,{force:!0}),e}}async function at(){return await ee(t())}function ot(e,t){for(let n=t;;n=d(n)){let t=e.bindings[n];if(t)return{directory:n,binding:t};if(d(n)===n)return}}function st(e){let t=ie();return e===t||e.startsWith(t+m)?`~${e.slice(t.length)}`:e}const O={json:!1,context:void 0,failedRequest:void 0};function ct(e){O.context={organization:e.organization,bound_directory:e.directory??null},O.json||a.write(lt(e))}function lt(e){let{organization:t,directory:n}=e,r=t.name?`${T(t.name)} (${T(t.slug??``)}) · `:``,i=n?`bound at ${st(n)}`:`from ASTRALBEAM_API_KEY`;return`▸ ${r}org ${t.id} · ${i}\n`}function k(e){return{json:e.optsWithGlobals().json===!0}}async function A(){let{apiKey:e,apiUrl:t}=await j();return{apiKey:e,apiUrl:t}}async function j(){let e=n.ASTRALBEAM_API_KEY,t;if(e)t={apiKey:e,apiUrl:rt(n.ASTRALBEAM_API_URL??`https://app.astralbeam.ai/api`),organization:{id:nt(e)}};else{let e=await at(),n=ot(await D(),e);if(!n)throw Error(`No AstralBeam login covers ${st(e)}. Run \`astralbeam auth login\` in this directory or a parent, or set ASTRALBEAM_API_KEY.`);let{binding:r}=n;t={apiKey:r.api_key,apiUrl:rt(r.api_url),organization:r.organization,directory:n.directory}}return ct(t),t}function ut(e){o.setRawMode(!0),a.write(e),o.setEncoding(`utf8`),o.resume();let t=``;return new Promise((e,n)=>{let r=()=>{o.off(`data`,i),o.setRawMode(!1),o.pause(),a.write(`
|
|
21
21
|
`)},i=i=>{for(let a of i){if(a===`\r`||a===`
|
|
22
22
|
`)return r(),e(t.trim());if(a===``)return r(),n(Error(`Cancelled.`));t=a===``||a===`\b`?t.slice(0,-1):t+a}};o.on(`data`,i)})}async function dt(){if(o.isTTY)return await ut(`Paste an organization API key: `);let e=[];for await(let t of o)e.push(t);return Buffer.concat(e).toString(`utf8`).trim()}async function ft(e,t){let n=nt(e),{id:r,name:i,slug:a}=await He({apiKey:e,apiUrl:t});if(r!==n)throw Error(`The API returned a different organization.`);return{id:r,name:i,slug:a}}function pt(e){return`${e.slice(0,e.indexOf(`_abo_`)+5)}…${e.slice(-4)}`}function mt(e){let t=e.command(`auth`).description(`Bind organization API keys to directories, and check them`);t.command(`login`).description(`Verify an API key, read from a hidden prompt or stdin, and bind it to this directory and everything below it`).option(`--api-url <url>`,`API base URL, ending in /api (default ${$e})`).action(async(e,t)=>{let{json:r}=k(t),i=rt(e.apiUrl??n.ASTRALBEAM_API_URL??`https://app.astralbeam.ai/api`),a=await dt(),o=await ft(a,i),s=await at(),c=await D();c.bindings[s]={api_url:i,api_key:a,organization:o},await it(c),ct({apiKey:a,apiUrl:i,organization:o,directory:s}),E({directory:s,organization:o,api_url:i},r)}),t.command(`logout`).description(`Remove the binding that covers this directory`).action(async(e,t)=>{let n=await D(),r=ot(n,await at());if(!r)throw Error(`No AstralBeam login covers this directory.`);delete n.bindings[r.directory],await it(n);let{organization:i}=r.binding;E({directory:r.directory,organization:i},k(t).json)}),t.command(`status`).description(`Show which organization commands here use, and verify the key against the API`).action(async(e,t)=>{let{apiKey:n,apiUrl:r,directory:i}=await j(),a=await ft(n,r);if(O.context&&(O.context.organization=a),i){let e=await D(),t=e.bindings[i];t&&JSON.stringify(t.organization)!==JSON.stringify(a)&&(t.organization=a,await it(e))}E({organization:a,api_url:r,api_key:pt(n),source:i??`ASTRALBEAM_API_KEY`},k(t).json)}),t.command(`list`).description(`List every directory binding`).action(async(e,t)=>{let{bindings:n}=await D(),r=Object.entries(n).map(([e,t])=>({directory:e,organization:t.organization,api_url:t.api_url}));if(k(t).json)return w({items:r});if(r.length===0)return void a.write(`No bindings.
|
|
23
23
|
`);Xe(r.map(({directory:e,organization:t,api_url:n})=>({directory:st(e),name:t.name,slug:t.slug,organization_id:t.id,api_url:n})),[`directory`,`name`,`slug`,`organization_id`,`api_url`])})}const ht=new TextEncoder,gt=new TextDecoder,_t=new TextDecoder(`utf-8`,{fatal:!0});function vt(...e){let t=e.reduce((e,{length:t})=>e+t,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function yt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>127)throw TypeError(`non-ASCII string encountered in encode()`);t[n]=r}return t}var bt=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},xt=class extends bt{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},M=class extends bt{static code=`ERR_JWS_INVALID`;code=`ERR_JWS_INVALID`},N=class extends bt{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`};function St(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function Ct(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}const wt=`The input to be decoded is not correctly encoded.`;function Tt(e){if(Uint8Array.fromBase64)try{return Uint8Array.fromBase64(typeof e==`string`?e:gt.decode(e),{alphabet:`base64url`})}catch(e){throw TypeError(wt,{cause:e})}let t=e;if(t instanceof Uint8Array&&(t=gt.decode(t)),t.includes(`+`)||t.includes(`/`))throw TypeError(wt);t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return Ct(t)}catch{throw TypeError(wt)}}function Et(e){let t=e;return typeof t==`string`&&(t=ht.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):St(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}function Dt(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=t;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return t===n}function Ot(...e){let t=new Set;for(let n of e)if(n)for(let e of Object.keys(n)){if(t.has(e))return!1;t.add(e)}return!0}const kt=e=>Dt(e)&&typeof e.kty==`string`,At=e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`),jt=e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0,Mt=e=>e.kty===`oct`&&typeof e.k==`string`;var Nt=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);function Pt(e){if(typeof e!=`string`)throw new N(`JWTs must use Compact JWS serialization, JWT must be a string`);let{1:t,length:n}=e.split(`.`);if(n===5)throw new N(`Only JWTs using Compact JWS serialization can be decoded`);if(n!==3)throw new N(`Invalid JWT`);if(!t)throw new N(`JWTs must contain a payload`);let r;try{r=Tt(t)}catch{throw new N(`Failed to base64url decode the payload`)}let i;try{i=JSON.parse(_t.decode(r))}catch{throw new N(`Failed to parse the decoded payload as JSON`)}if(!Dt(i))throw new N(`Invalid JWT Claims Set`);return i}var Ft=class extends Error{missingFeature;constructor(e){super(It(e)),this.name=`UnsupportedResponseStreamError`,this.missingFeature=e}};function It(e){return`Streaming fetch responses are not supported in this runtime because ${e} is unavailable. React Native users need a compatible fetch/stream/TextDecoder polyfill, or should use a fetch, XHR, or custom transport that can deliver streaming chunks.`}function Lt(e){if(!e.body)throw new Ft(`Response.body`);if(typeof e.body.getReader!=`function`)throw new Ft(`Response.body.getReader`);return e.body.getReader()}function Rt(){if(typeof globalThis.TextDecoder!=`function`)throw new Ft(`TextDecoder`);return new globalThis.TextDecoder}function zt(e){if(!e.startsWith(`data:`))return e;let t=e.slice(5);return t.startsWith(` `)?t.slice(1):t}function Bt(e){return Object.keys(e).length>0?e:void 0}function Vt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`promptTokens`in e}function Ht(e,t){return Vt(e)?e:Ut(Array.isArray(e)?e:void 0,t)}function Ut(e,t){let n=e?.[0];if(n==null&&t==null)return;let{promptTokensDetails:r,completionTokensDetails:i,...a}=t??{},o=Bt({...n?.cachedInputTokens===void 0?{}:{cachedTokens:n.cachedInputTokens},...r}),s=Bt({...n?.reasoningTokens===void 0?{}:{reasoningTokens:n.reasoningTokens},...i});return{promptTokens:n?.inputTokens??0,completionTokens:n?.outputTokens??0,totalTokens:n?.totalTokens??0,...a,...o===void 0?{}:{promptTokensDetails:o},...s===void 0?{}:{completionTokensDetails:s}}}function Wt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gt(e,t){if(t==null)return e;if(e==null)return{...t};let n={...e,...t};return Wt(e.tanstack)&&Wt(t.tanstack)&&(n.tanstack={...e.tanstack,...t.tanstack}),n}function P(e){if(e==null)return;let t=`metadata`in e?e.metadata:void 0,n=(typeof t==`object`&&t&&!Array.isArray(t)?t:e).tanstack;if(!(typeof n!=`object`||!n||Array.isArray(n)))return n}function Kt(e,t){let n=e.metadata,r=P(e)??{};return{...e,metadata:{...n??{},tanstack:{...r,...t}}}}let qt=function(e){return e.TEXT_MESSAGE_START=`TEXT_MESSAGE_START`,e.TEXT_MESSAGE_CONTENT=`TEXT_MESSAGE_CONTENT`,e.TEXT_MESSAGE_END=`TEXT_MESSAGE_END`,e.TEXT_MESSAGE_CHUNK=`TEXT_MESSAGE_CHUNK`,e.TOOL_CALL_START=`TOOL_CALL_START`,e.TOOL_CALL_ARGS=`TOOL_CALL_ARGS`,e.TOOL_CALL_END=`TOOL_CALL_END`,e.TOOL_CALL_CHUNK=`TOOL_CALL_CHUNK`,e.TOOL_CALL_RESULT=`TOOL_CALL_RESULT`,e.THINKING_START=`THINKING_START`,e.THINKING_END=`THINKING_END`,e.THINKING_TEXT_MESSAGE_START=`THINKING_TEXT_MESSAGE_START`,e.THINKING_TEXT_MESSAGE_CONTENT=`THINKING_TEXT_MESSAGE_CONTENT`,e.THINKING_TEXT_MESSAGE_END=`THINKING_TEXT_MESSAGE_END`,e.STATE_SNAPSHOT=`STATE_SNAPSHOT`,e.STATE_DELTA=`STATE_DELTA`,e.MESSAGES_SNAPSHOT=`MESSAGES_SNAPSHOT`,e.ACTIVITY_SNAPSHOT=`ACTIVITY_SNAPSHOT`,e.ACTIVITY_DELTA=`ACTIVITY_DELTA`,e.RAW=`RAW`,e.CUSTOM=`CUSTOM`,e.RUN_STARTED=`RUN_STARTED`,e.RUN_FINISHED=`RUN_FINISHED`,e.RUN_ERROR=`RUN_ERROR`,e.STEP_STARTED=`STEP_STARTED`,e.STEP_FINISHED=`STEP_FINISHED`,e.REASONING_START=`REASONING_START`,e.REASONING_MESSAGE_START=`REASONING_MESSAGE_START`,e.REASONING_MESSAGE_CONTENT=`REASONING_MESSAGE_CONTENT`,e.REASONING_MESSAGE_END=`REASONING_MESSAGE_END`,e.REASONING_MESSAGE_CHUNK=`REASONING_MESSAGE_CHUNK`,e.REASONING_END=`REASONING_END`,e.REASONING_ENCRYPTED_VALUE=`REASONING_ENCRYPTED_VALUE`,e}({});var Jt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function F(e,t){return e>>>t|e<<32-t}function Yt(e){let t=new TextEncoder().encode(e),n=t.length*8,r=t.length+1,i=r+(56-r%64+64)%64+8,a=new Uint8Array(i);a.set(t),a[t.length]=128;let o=new DataView(a.buffer);o.setUint32(i-8,Math.floor(n/4294967296)),o.setUint32(i-4,n>>>0);let s=1779033703,c=3144134277,l=1013904242,u=2773480762,d=1359893119,f=2600822924,p=528734635,m=1541459225,h=new Uint32Array(64);for(let e=0;e<i;e+=64){for(let t=0;t<16;t++)h[t]=o.getUint32(e+t*4);for(let e=16;e<64;e++){let t=h[e-15]??0,n=h[e-2]??0,r=F(t,7)^F(t,18)^t>>>3,i=F(n,17)^F(n,19)^n>>>10;h[e]=(h[e-16]??0)+r+(h[e-7]??0)+i>>>0}let t=s,n=c,r=l,i=u,a=d,g=f,_=p,v=m;for(let e=0;e<64;e++){let o=F(a,6)^F(a,11)^F(a,25),s=a&g^~a&_,c=v+o+s+(Jt[e]??0)+(h[e]??0)>>>0,l=(F(t,2)^F(t,13)^F(t,22))+(t&n^t&r^n&r)>>>0;v=_,_=g,g=a,a=i+c>>>0,i=r,r=n,n=t,t=c+l>>>0}s=s+t>>>0,c=c+n>>>0,l=l+r>>>0,u=u+i>>>0,d=d+a>>>0,f=f+g>>>0,p=p+_>>>0,m=m+v>>>0}let g=e=>(e>>>0).toString(16).padStart(8,`0`);return g(s)+g(c)+g(l)+g(u)+g(d)+g(f)+g(p)+g(m)}function Xt(e){return`sha256:${Yt(e)}`}function Zt(e,t){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return JSON.stringify(e);if(typeof e!=`object`)throw TypeError(`Interrupt values must be JSON-compatible.`);if(t.has(e))throw TypeError(`Interrupt values must not cycle.`);if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`Interrupt values must use plain JSON objects.`);t.add(e);let n;if(Array.isArray(e)){let r=[];for(let n=0;n<e.length;n++)r.push(Zt(e[n],t));n=`[${r.join(`,`)}]`}else{let r=e;n=`{${Object.keys(r).sort().map(e=>`${JSON.stringify(e)}:${Zt(r[e],t)}`).join(`,`)}}`}return t.delete(e),n}function I(e){return Zt(e,new WeakSet)}function L(e,t=Xt){if(typeof e!=`string`)throw TypeError(`Interrupt digests require canonical JSON text.`);return t(e)}function Qt(e){typeof e!=`object`||!e||Object.isFrozen(e)||(Object.values(e).forEach(Qt),Object.freeze(e))}function R(e){let t=JSON.parse(I(e));return Qt(t),t}function $t(e){let t=R([...e].sort((e,t)=>e.interruptId.localeCompare(t.interruptId))),n=I(t);return Object.freeze({resolutions:t,canonicalResolutions:n,fingerprint:L(n)})}function en(e){let t={};for(let[n,r]of Object.entries(e))n!==`$schema`&&(t[n]=r);return t}function tn(e){return(typeof e==`object`||typeof e==`function`)&&e!==null}function z(e){if(!tn(e)||!(`~standard`in e))return!1;let t=e[`~standard`];return typeof t!=`object`||!t||!(`version`in t)||t.version!==1||!(`jsonSchema`in t)||typeof t.jsonSchema!=`object`||t.jsonSchema===null||!(`input`in t.jsonSchema)?!1:typeof t.jsonSchema.input==`function`}function B(e){return tn(e)&&`~standard`in e&&typeof e[`~standard`]==`object`&&e[`~standard`]!==null&&`version`in e[`~standard`]&&e[`~standard`].version===1&&`validate`in e[`~standard`]&&typeof e[`~standard`].validate==`function`}function nn(e){return Object.keys(e).length>0?e:void 0}function rn(e,t=[]){let n={...e},r={};if(n.type===`object`&&n.properties){let e={...n.properties},i=Object.keys(e),a={};for(let n of i){let r=e[n];if(!r)continue;let i=!t.includes(n),o=!1,s;if(r.type===`object`&&r.properties){let t=rn(r,r.required||[]);e[n]=i?{...t.schema,type:[`object`,`null`]}:t.schema,o=i,s=t.nullWidening}else if(r.type===`array`&&r.items){let t=Array.isArray(r.items)?r.items[0]:r.items,a=t?rn(t,t.required||[]):void 0;e[n]={...r,items:a?a.schema:r.items,...i?{type:[`array`,`null`]}:{}},o=i,s=a?.nullWidening?{items:a.nullWidening}:void 0}else i&&(r.type&&!Array.isArray(r.type)?(e[n]={...r,type:[r.type,`null`]},o=!0):Array.isArray(r.type)&&!r.type.includes(`null`)&&(e[n]={...r,type:[...r.type,`null`]},o=!0));(o||s)&&(a[n]={...s??{},...o?{widened:!0}:{}})}n.properties=e,n.required=i,n.additionalProperties=!1,Object.keys(a).length>0&&(r.properties=a)}if(n.type===`array`&&n.items){let e=Array.isArray(n.items)?n.items[0]:n.items;if(e){let t=rn(e,e.required||[]);n.items=t.schema,t.nullWidening&&(r.items=t.nullWidening)}}return{schema:n,nullWidening:nn(r)}}function an(e){if(z(e)){let t=en(e[`~standard`].jsonSchema.input({target:`draft-07`}));return`properties`in t&&!t.type&&(t.type=`object`),t.type===`object`&&!(`properties`in t)&&(t.properties={}),t.type===`object`&&!(`required`in t)&&(t.required=[]),t}if(B(e))throw Error("Schema is a Standard Schema validator but does not expose a JSON Schema converter on `~standard.jsonSchema`. Use Zod v4.2+, ArkType v2.1.28+, or wrap a Valibot schema with `toStandardJsonSchema()` from `@valibot/to-json-schema` before passing it as `outputSchema`.");return typeof e==`object`?en(e):e}function on(e,t={}){if(!e)return;let{forStructuredOutput:n=!1}=t;if(!n&&!z(e)&&!B(e))return e;let r=an(e);return!r||typeof r!=`object`||!n?r:rn(r,r.required||[]).schema}var sn=class extends Error{name=`StandardSchemaValidationError`;issues;constructor(e){super(`Validation failed: ${e.map(e=>e.message||`Validation failed`).join(`, `)}`),this.issues=e}};function cn(e,t){if(!B(e))return t;let n=e[`~standard`].validate(t);if(n instanceof Promise)throw Error(`Schema validation returned a Promise. Use validateWithStandardSchema for async validation.`);if(!n.issues)return n.value;throw new sn(n.issues)}var ln=new Set([`$schema`,`$id`,`$ref`,`$defs`,`type`,`properties`,`required`,`additionalProperties`,`items`,`oneOf`,`anyOf`,`allOf`,`enum`,`const`,`format`,`minimum`,`maximum`,`minLength`,`maxLength`,`pattern`]);function un(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function dn(e){return un(e)&&Object.keys(e).some(e=>ln.has(e))}function fn(e){return B(e)||z(e)||dn(e)}function pn(e){if(!un(e))return!1;let t=Object.keys(e);return t.length>0&&t.every(e=>e===`approve`||e===`reject`)&&t.every(t=>fn(e[t]))}function mn(e){let t={};for(let[n,r]of Object.entries(e))t[n]=r;return t}function V(e){if(B(e)){let t=z(e)?mn(e[`~standard`].jsonSchema.input({target:`draft-2020-12`})):void 0;return{source:e,validator:e,...t!==void 0&&{jsonSchema:t}}}if(dn(e))return{source:e,jsonSchema:e};throw TypeError(`Expected a supported SchemaInput.`)}function hn(e){let t={approved:{const:e.approved}},n=[`approved`];return e.approved&&e.inputSchema&&(t.editedArgs=e.inputSchema.jsonSchema??{}),e.payload&&(t.payload=e.payload.jsonSchema??{},n.push(`payload`)),{type:`object`,properties:t,required:n,additionalProperties:!1}}function gn(e,t){let n=t===void 0?null:V(t),r=null,i=null;if(e!==void 0)if(B(e)||dn(e))r=V(e),i=r;else if(pn(e))r=e.approve===void 0?null:V(e.approve),i=e.reject===void 0?null:V(e.reject);else throw TypeError(`approvalSchema must be a SchemaInput or a nonempty map containing approve or reject.`);let a={oneOf:[hn({approved:!0,payload:r,inputSchema:n}),hn({approved:!1,payload:i,inputSchema:null})]},o=I(a),s=I({approve:r?.jsonSchema??null,reject:i?.jsonSchema??null});return{branches:{approve:r,reject:i},responseSchema:a,responseSchemaHash:L(o),approvalSchemaHash:L(s)}}function _n(e){return L(e===void 0?`undefined`:I(V(e).jsonSchema??{standardValidator:`unserialized`}))}var vn=`tanstack:interruptBinding`,yn=vn;function bn(e){return e&&typeof e==`object`?e:null}function H(e,t){return typeof e[t]==`string`?e[t]:void 0}function xn(e){let t=e.v;return t===void 0||t===1}function Sn(e){let t=bn(e.metadata),n=t?bn(t[yn]):null;if(!n||H(n,`interruptId`)!==e.id||!xn(n))return;let r=H(n,`kind`),i=H(n,`interruptId`),a=H(n,`responseSchemaHash`),o=H(n,`expiresAt`);if(!i||a===``||o!==void 0&&!Number.isFinite(Date.parse(o)))return;if(r===`generic`){let e=H(n,`definitionId`),t=H(n,`key`),s=n.batchIndex,c=H(n,`payloadSchemaHash`);return(e!==void 0||t!==void 0||s!==void 0||c!==void 0)&&(!e||!t||typeof s!=`number`||!Number.isInteger(s)||s<0)?void 0:{v:1,kind:r,interruptId:i,...a?{responseSchemaHash:a}:{},...o?{expiresAt:o}:{},...e?{definitionId:e}:{},...t?{key:t}:{},...typeof s==`number`?{batchIndex:s}:{},...c?{payloadSchemaHash:c}:{}}}if(!a)return;let s=H(n,`toolName`),c=H(n,`toolCallId`);if(!(!s||!c)){if(r===`client-tool-execution`){let e=H(n,`outputSchemaHash`);return e?{v:1,kind:r,interruptId:i,toolName:s,toolCallId:c,outputSchemaHash:e,responseSchemaHash:a,...o?{expiresAt:o}:{}}:void 0}if(r===`tool-approval`){let e=H(n,`inputSchemaHash`),t=H(n,`approvalSchemaHash`);return!e||!t?void 0:{v:1,kind:r,interruptId:i,toolName:s,toolCallId:c,originalArgs:n.originalArgs,inputSchemaHash:e,approvalSchemaHash:t,responseSchemaHash:a,...o?{expiresAt:o}:{}}}}}function Cn(e){let t=Sn(e);if(!t)return;let n=bn(e.metadata),r=n?bn(n[yn]):null;if(!r)return;let i=H(r,`interruptedRunId`),a=r.generation;if(!(!i||typeof a!=`number`||!Number.isInteger(a)||a<0))return{...t,interruptedRunId:i,generation:a}}var wn=`tanstack:interruptPayload`;function Tn(e,t){if(!z(e))throw TypeError(`${t} must be a Standard Schema with a JSON Schema converter.`);try{let t=e[`~standard`].jsonSchema.input({target:`draft-07`});if(t===void 0)throw TypeError(`The exported schema is undefined.`);if(typeof t==`function`)throw TypeError(`The exported schema must not be a function.`);if(Array.isArray(t)||!t||typeof t!=`object`||![Object.prototype,null].includes(Object.getPrototypeOf(t)))throw TypeError(`The exported schema must be a plain JSON object.`);let n={};for(let[e,r]of Object.entries(t))e!==`$schema`&&(n[e]=r);return{json:n,canonicalJson:I(n)}}catch(e){throw TypeError(`${t} could not export compatible JSON Schema: ${e instanceof Error?e.message:String(e)}`)}}function En(e){return L(Tn(e,`Interrupt schema`).canonicalJson)}var Dn=`tanstack:interruptContinuation`;function On(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kn(e){return{[Dn]:e}}function An(e){let t=Sn(e);if(t?.kind!==`generic`||t.definitionId===void 0||t.key===void 0||t.batchIndex===void 0)return;let n=On(e.metadata)?e.metadata:void 0,r=n!==void 0&&Object.prototype.hasOwnProperty.call(n,`tanstack:interruptPayload`);return{v:1,definitionId:t.definitionId,key:t.key,batchIndex:t.batchIndex,reason:e.reason,message:e.message??``,...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt},...t.responseSchemaHash===void 0?{}:{responseSchemaHash:t.responseSchemaHash},...t.payloadSchemaHash===void 0?{}:{payloadSchemaHash:t.payloadSchemaHash},...r?{payload:n[wn]}:{}}}function jn(e){let t=[];for(let n of e){let e=n.parts??[];if(n.role===`system`){t.push(Mn(n,{content:e.length>0?In(e):n.content??``},e));continue}if(n.role===`user`){t.push(Mn(n,{content:e.length>0?Ln(e):n.content??``},e));continue}for(let r of e)if(r.type===`thinking`){let e={role:`reasoning`,id:Bn(n.id,r),content:r.content};r.signature&&(e.encryptedValue=r.signature),t.push(e)}let r=In(e),i=zn(e);t.push(Mn(n,{...r!==``&&{content:r},...i&&{toolCalls:i}},e));for(let n of e)n.type===`tool-result`&&t.push({role:`tool`,id:Vn(n.toolCallId),toolCallId:n.toolCallId,content:typeof n.content==`string`?n.content:JSON.stringify(n.content),...n.error!==void 0&&{error:n.error}})}return t}function Mn(e,t,n){let r=Nn(e,n),i=e.name;return{id:e.id,role:e.role,...i!==void 0&&{name:i},...t,...r!==void 0&&{metadata:r}}}function Nn(e,t){let n={...e.metadata??{}},r={...P(e)??{}};e.createdAt&&(r.createdAt=e.createdAt.toISOString());let i=Pn(t);i&&(r.structuredOutput=i);let a={};for(let e of t)e.type===`tool-call`&&e.metadata!==void 0&&(a[e.id]=e.metadata);Object.keys(a).length>0&&(r.toolCallMetadata=a);let o=t.filter(e=>e.type===`ui-resource`);return o.length>0&&(r.uiResources=o),Object.keys(r).length>0&&(n.tanstack=r),Object.keys(n).length>0?n:void 0}function Pn(e){for(let t of e)if(t.type===`structured-output`&&t.status!==`complete`)return Fn(t)}function Fn(e){return{status:e.status,raw:e.raw,...e.errorMessage!==void 0&&{errorMessage:e.errorMessage}}}function In(e){let t=[];for(let n of e)n.type===`text`?t.push(n.content):n.type===`structured-output`&&n.status===`complete`&&n.raw!==``&&t.push(n.raw);return t.join(``)}function Ln(e){if(!e.some(e=>e.type===`image`||e.type===`audio`||e.type===`video`||e.type===`document`))return In(e);let t=[];for(let n of e)n.type===`text`?t.push({type:`text`,text:n.content}):(n.type===`image`||n.type===`audio`||n.type===`video`||n.type===`document`)&&t.push(n);return t}function Rn(e){if(typeof e!=`object`||!e||Array.isArray(e)||!(`thoughtSignature`in e))return;let t=e.thoughtSignature;return typeof t==`string`&&t!==``?t:void 0}function zn(e){let t=[];for(let n of e)if(n.type===`tool-call`){let e=Rn(n.metadata);t.push({id:n.id,type:`function`,function:{name:n.name,arguments:n.arguments},...e===void 0?{}:{encryptedValue:e}})}return t.length>0?t:void 0}function Bn(e,t){return`${e}-reasoning-${t.id??Hn(t.content)}`}function Vn(e){return`tool-${e}`}function Hn(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}function Un(e){if((e.type===qt.RUN_FINISHED||e.type===qt.RUN_ERROR)&&(Array.isArray(e.usage)||Vt(e.usage))){let t=Ht(e.usage,P(e)?.usage);t!==void 0&&(e.usage=t)}if(e.type===qt.TOOL_CALL_START&&e.toolName===void 0&&e.toolCallName&&(e.toolName=e.toolCallName),e.type===qt.TOOL_CALL_END&&e.input===void 0){let t=P(e)?.input;t!==void 0&&(e.input=t)}return e}function Wn(e){Un(e);let t=P(e),n=e;if(t==null)return n;for(let[e,r]of Object.entries(t))e===`usage`||e===`interruptErrors`||n[e]===void 0&&r!==void 0&&(n[e]=r);return t.interruptErrors!==void 0&&(n[`tanstack:interruptErrors`]=t.interruptErrors),n}var Gn=new Set([`text`,`image`,`audio`,`video`,`document`]);function Kn(e){if(typeof e!=`object`||!e)return!1;let t=e;if(typeof t.type!=`string`||!Gn.has(t.type))return!1;if(t.type===`text`)return typeof t.content==`string`;let n=t.source;if(typeof n!=`object`||!n)return!1;let r=n;return typeof r.value==`string`?r.type===`data`?typeof r.mimeType==`string`:r.type===`url`:!1}function qn(e){return Array.isArray(e)&&e.length>0&&e.every(Kn)}function Jn(e){return typeof e==`string`||qn(e)?e:JSON.stringify(e)}function Yn(e){let t=e?.metadata;return typeof t==`object`&&t&&t.providerExecuted===!0?t:null}function Xn(e){return Yn(e)!==null}function Zn(e){return e.type===`text`||e.type===`image`||e.type===`audio`||e.type===`video`||e.type===`document`}function Qn(e){try{return JSON.stringify(e)??``}catch{return``}}function $n(e){return typeof e==`string`&&e!==``?e:void 0}function er(e){if(`encryptedValue`in e){let t=$n(e.encryptedValue);if(t!==void 0)return t}return $n(P(e)?.signature)}function tr(e){return e.length===0?null:e.every(e=>e.type===`text`)?e.map(e=>e.content).join(``)||null:e}function nr(e){return e==null?``:typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.content).join(``)}function rr(e){return e.role===`system`?[]:e.role===`assistant`?sr(e):[ir(e)]}function ir(e){let t=[];for(let n of e.parts)Zn(n)&&t.push(n);return{id:e.id,role:e.role,content:tr(t),...e.createdAt!==void 0&&{createdAt:e.createdAt}}}function ar(){return{contentParts:[],toolCalls:[]}}function or(e){return e.state===`input-complete`||e.state===`complete`||e.state===`approval-requested`||e.state===`approval-responded`||e.state===`error`||e.output!==void 0}function sr(e){let t=[],n=ar(),r=[],i=new Set;function a(){let i=tr(n.contentParts),a=i!==null,o=n.toolCalls.length>0,s=r.length>0;(a||o||s)&&(t.push({id:e.id,role:`assistant`,content:i,...o&&{toolCalls:n.toolCalls},...s&&{thinking:r},...n.structuredOutput&&{structuredOutput:n.structuredOutput},...e.createdAt!==void 0&&{createdAt:e.createdAt}}),r=[]),n=ar()}for(let o of e.parts)switch(o.type){case`text`:case`image`:case`audio`:case`video`:case`document`:n.contentParts.push(o);break;case`tool-call`:or(o)&&n.toolCalls.push({id:o.id,type:`function`,function:{name:o.name,arguments:o.arguments},...o.metadata!==void 0&&{metadata:o.metadata}});break;case`tool-result`:a(),(o.state===`complete`||o.state===`error`)&&!i.has(o.toolCallId)&&(t.push({id:e.id,role:`tool`,content:o.content,toolCallId:o.toolCallId,...e.createdAt!==void 0&&{createdAt:e.createdAt}}),i.add(o.toolCallId));break;case`thinking`:o.content&&(n.toolCalls.some(Xn)&&a(),r.push({content:o.content,...o.signature&&{signature:o.signature}}));break;case`structured-output`:if(o.status===`complete`){let e=o.raw===``?o.data===void 0?``:Qn(o.data):o.raw;e!==``&&(n.contentParts.push({type:`text`,content:e}),n.structuredOutput=o)}}a();for(let n of e.parts)if(n.type===`tool-call`&&(n.output!==void 0&&!i.has(n.id)&&(t.push({id:e.id,role:`tool`,content:Jn(n.output),toolCallId:n.id,...e.createdAt!==void 0&&{createdAt:e.createdAt}}),i.add(n.id)),n.output===void 0&&n.state===`approval-responded`&&n.approval?.approved!==void 0&&!i.has(n.id))){let r=n.approval.approved;t.push({id:e.id,role:`tool`,content:JSON.stringify({approved:r,...r&&{pendingExecution:!0},message:r?`User approved this action`:`User denied this action`}),toolCallId:n.id,...e.createdAt!==void 0&&{createdAt:e.createdAt}}),i.add(n.id)}return t.length===0&&t.push({id:e.id,role:`assistant`,content:null,...e.createdAt!==void 0&&{createdAt:e.createdAt}}),t}function cr(e,t){let n=[];if(e.role===`assistant`&&e.thinking?.length)for(let t of e.thinking)t.content&&n.push({type:`thinking`,content:t.content,...t.signature&&{signature:t.signature}});if(e.role===`assistant`&&e.structuredOutput)n.push(e.structuredOutput);else if(e.role===`tool`&&e.toolCallId)n.push({type:`tool-result`,toolCallId:e.toolCallId,content:nr(e.content),state:`complete`});else if(Array.isArray(e.content))for(let t of e.content)n.push(t);else{let t=nr(e.content);t&&n.push({type:`text`,content:t})}if(e.toolCalls&&e.toolCalls.length>0)for(let t of e.toolCalls){let e;try{e=JSON.parse(t.function.arguments)}catch{e=void 0}n.push({type:`tool-call`,id:t.id,name:t.function.name,arguments:t.function.arguments,state:`input-complete`,...e!==void 0&&{input:e},...t.metadata!==void 0&&{metadata:t.metadata}})}return{id:t||W(),role:e.role===`tool`?`assistant`:e.role,parts:n,...e.createdAt!==void 0&&{createdAt:e.createdAt}}}function lr(e){if(`parts`in e)return U(e,{...e,id:e.id||W()});let t=e.id||W();switch(e.role){case`user`:return U(e,{id:t,role:`user`,parts:ur(e.content)});case`assistant`:{let n=P(e)?.toolCallMetadata,r=e.toolCalls?.map(e=>{let t=typeof n==`object`&&n?n[e.id]:void 0;return t===void 0?e:{...e,metadata:t}});return U(e,cr({role:`assistant`,content:e.content??null,...r&&{toolCalls:r}},t))}case`tool`:return U(e,cr({role:`tool`,content:e.content,toolCallId:e.toolCallId},t));case`system`:case`developer`:return U(e,{id:t,role:`system`,parts:e.content?[{type:`text`,content:e.content}]:[]});case`reasoning`:{let n=er(e);return U(e,{id:t,role:`assistant`,parts:e.content?[{type:`thinking`,content:e.content,...n===void 0?{}:{signature:n}}]:[]})}default:return U(e,{id:t,role:`assistant`,parts:[]})}}function U(e,t){if(!(`metadata`in e))return t;let n=e.metadata;if(typeof n!=`object`||!n||Array.isArray(n))return t;let r=n,i=P(r)?.createdAt,a=typeof i==`string`?new Date(i):void 0,o=a!==void 0&&!Number.isNaN(a.getTime());return{...t,metadata:r,...o?{createdAt:a}:{}}}function ur(e){if(typeof e==`string`)return e?[{type:`text`,content:e}]:[];let t=[];for(let n of e)n.type===`text`?t.push({type:`text`,content:n.text}):n.type!==`binary`&&t.push(n);return t}function dr(e,t){return`parts`in e?{...e,id:e.id||t(),createdAt:e.createdAt||new Date}:{...cr(e,t()),createdAt:e.createdAt??new Date}}function W(){return`msg-${Date.now()}-${Math.random().toString(36).substring(7)}`}function fr(e){if(e.approvalSchema!==void 0&&e.needsApproval!==!0)throw TypeError(`approvalSchema requires needsApproval: true.`);let t=e.inputSchema,n=e.outputSchema,r=e.approvalSchema,i=e.needsApproval;return{__toolSide:`definition`,...e,inputSchema:t,outputSchema:n,approvalSchema:r,needsApproval:i,server(a){return{__toolSide:`server`,...e,inputSchema:t,outputSchema:n,approvalSchema:r,needsApproval:i,execute:a}},client(a){return{__toolSide:`client`,...e,inputSchema:t,outputSchema:n,approvalSchema:r,needsApproval:i,...a!==void 0&&{execute:a}}}}}function pr(e){return typeof e==`string`&&e!==``?e:void 0}function mr(e){if(`runId`in e){let t=pr(e.runId);if(t!==void 0)return t}return pr(P(e)?.runId)}var hr=Nt((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.ALL=e.COLLECTION=e.ATOM=e.SPECIAL=e.INF=e._INFINITY=e.INFINITY=e.NAN=e.BOOL=e.NULL=e.OBJ=e.ARR=e.NUM=e.STR=void 0,e.STR=1,e.NUM=2,e.ARR=4,e.OBJ=8,e.NULL=16,e.BOOL=32,e.NAN=64,e.INFINITY=128,e._INFINITY=256,e.INF=e.INFINITY|e._INFINITY,e.SPECIAL=e.NULL|e.BOOL|e.INF|e.NAN,e.ATOM=e.STR|e.NUM|e.SPECIAL,e.COLLECTION=e.ARR|e.OBJ,e.ALL=e.ATOM|e.COLLECTION,e.Allow={STR:e.STR,NUM:e.NUM,ARR:e.ARR,OBJ:e.OBJ,NULL:e.NULL,BOOL:e.BOOL,NAN:e.NAN,INFINITY:e.INFINITY,_INFINITY:e._INFINITY,INF:e.INF,SPECIAL:e.SPECIAL,ATOM:e.ATOM,COLLECTION:e.COLLECTION,ALL:e.ALL},e.default=e.Allow})),gr=Nt((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.Allow=e.MalformedJSON=e.PartialJSON=e.parseJSON=e.parse=void 0;let r=hr();Object.defineProperty(e,"Allow",{enumerable:!0,get:function(){return r.Allow}}),n(hr(),e);var i=class extends Error{};e.PartialJSON=i;var a=class extends Error{};e.MalformedJSON=a;function o(e,t=r.Allow.ALL){if(typeof e!=`string`)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return s(e.trim(),t)}e.parseJSON=o;let s=(e,t)=>{let n=e.length,o=0,s=e=>{throw new i(`${e} at position ${o}`)},c=e=>{throw new a(`${e} at position ${o}`)},l=()=>(m(),o>=n&&s(`Unexpected end of input`),e[o]===`"`?u():e[o]===`{`?d():e[o]===`[`?f():e.substring(o,o+4)===`null`||r.Allow.NULL&t&&n-o<4&&`null`.startsWith(e.substring(o))?(o+=4,null):e.substring(o,o+4)===`true`||r.Allow.BOOL&t&&n-o<4&&`true`.startsWith(e.substring(o))?(o+=4,!0):e.substring(o,o+5)===`false`||r.Allow.BOOL&t&&n-o<5&&`false`.startsWith(e.substring(o))?(o+=5,!1):e.substring(o,o+8)===`Infinity`||r.Allow.INFINITY&t&&n-o<8&&`Infinity`.startsWith(e.substring(o))?(o+=8,1/0):e.substring(o,o+9)===`-Infinity`||r.Allow._INFINITY&t&&1<n-o&&n-o<9&&`-Infinity`.startsWith(e.substring(o))?(o+=9,-1/0):e.substring(o,o+3)===`NaN`||r.Allow.NAN&t&&n-o<3&&`NaN`.startsWith(e.substring(o))?(o+=3,NaN):p()),u=()=>{let i=o,a=!1;for(o++;o<n&&(e[o]!==`"`||a&&e[o-1]===`\\`);)a=e[o]===`\\`&&!a,o++;if(e.charAt(o)==`"`)try{return JSON.parse(e.substring(i,++o-Number(a)))}catch(e){c(String(e))}else if(r.Allow.STR&t)try{return JSON.parse(e.substring(i,o-Number(a))+`"`)}catch{return JSON.parse(e.substring(i,e.lastIndexOf(`\\`))+`"`)}s(`Unterminated string literal`)},d=()=>{o++,m();let i={};try{for(;e[o]!==`}`;){if(m(),o>=n&&r.Allow.OBJ&t)return i;let a=u();m(),o++;try{i[a]=l()}catch(e){if(r.Allow.OBJ&t)return i;throw e}m(),e[o]===`,`&&o++}}catch{if(r.Allow.OBJ&t)return i;s(`Expected '}' at end of object`)}return o++,i},f=()=>{o++;let n=[];try{for(;e[o]!==`]`;)n.push(l()),m(),e[o]===`,`&&o++}catch{if(r.Allow.ARR&t)return n;s(`Expected ']' at end of array`)}return o++,n},p=()=>{if(o===0){e===`-`&&c(`Not sure what '-' is`);try{return JSON.parse(e)}catch(n){if(r.Allow.NUM&t)try{return JSON.parse(e.substring(0,e.lastIndexOf(`e`)))}catch{}c(String(n))}}let i=o;for(e[o]===`-`&&o++;e[o]&&`,]}`.indexOf(e[o])===-1;)o++;o==n&&!(r.Allow.NUM&t)&&s(`Unterminated number literal`);try{return JSON.parse(e.substring(i,o))}catch{e.substring(i,o)===`-`&&s(`Not sure what '-' is`);try{return JSON.parse(e.substring(i,e.lastIndexOf(`e`)))}catch(e){c(String(e))}}},m=()=>{for(;o<n&&`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astralbeam/cli",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"description": "Command-line interface for AstralBeam organization admins and their coding agents",
|
|
5
5
|
"homepage": "https://app.astralbeam.ai/docs/cli/getting-started",
|
|
6
6
|
"bugs": "https://github.com/AstralBeamAI/astralbeam/issues",
|