blink 0.1.67 → 0.1.69

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/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-ByIbJXPc.js";import{import_websocket as r}from"./wrapper-B4vDwpOq.js";import{findNearestEntry as i,require_main as a,resolveConfig as o}from"./util-cVEGIV3r.js";import{Client as s,loginIfNeeded as c,source_default as l}from"./auth-BUNIOupD.js";import{Y as u,pD as d,ve as f,ye as p}from"./dist-NqrnQGst.js";import"./open-CSMQaj0E.js";import{randomUUID as m}from"crypto";import{basename as h,dirname as g,join as _}from"node:path";import{existsSync as ee}from"node:fs";import{mkdir as v,readdir as y,writeFile as b}from"fs/promises";import{readFile as x,stat as S}from"node:fs/promises";var C=e((exports=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};exports.CommanderError=t,exports.InvalidArgumentError=n})),w=e((exports=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)===`...`&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._concatValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}exports.Argument=n,exports.humanReadableArgName=r})),T=e((exports=>{let{humanReadableArgName:t}=w();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0){let n=e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`;n&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));a=a.concat(this.formatItemList(`Arguments:`,s,t));let c=this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`);if(c.forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}let l=this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`);return l.forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
+ import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-ByIbJXPc.js";import{import_websocket as r}from"./wrapper-B4vDwpOq.js";import{findNearestEntry as i,require_main as a,resolveConfig as o}from"./util-D3Iuwmav.js";import{Client as s,loginIfNeeded as c,source_default as l}from"./auth-BUNIOupD.js";import{Y as u,pD as d,ve as f,ye as p}from"./dist-NqrnQGst.js";import"./open-CSMQaj0E.js";import{randomUUID as m}from"crypto";import{basename as h,dirname as g,join as _}from"node:path";import{existsSync as ee}from"node:fs";import{mkdir as v,readdir as y,writeFile as b}from"fs/promises";import{readFile as x,stat as S}from"node:fs/promises";var C=e((exports=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};exports.CommanderError=t,exports.InvalidArgumentError=n})),w=e((exports=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)===`...`&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._concatValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}exports.Argument=n,exports.humanReadableArgName=r})),T=e((exports=>{let{humanReadableArgName:t}=w();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0){let n=e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`;n&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));a=a.concat(this.formatItemList(`Arguments:`,s,t));let c=this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`);if(c.forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}let l=this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`);return l.forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
3
3
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=this.helpWidth??80,s=o-t-2-2,c;if(s<this.minWidthToWrap||r.preformatted(n))c=n;else{let e=r.boxWrap(n,s);c=e.replace(/\n/g,`
4
4
  `+` `.repeat(t+2))}return i+a+` `.repeat(2)+c.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
5
5
  `)}};function r(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,``)}exports.Help=n,exports.stripColor=r})),E=e((exports=>{let{InvalidArgumentError:t}=C();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._concatValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -17,6 +17,6 @@ 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
  - ${r}`;throw Error(i)}_executeSubCommand(e,t){t=t.slice();let n=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=i.resolve(e,t);if(a.existsSync(n))return n;if(s.includes(i.extname(t)))return;let r=s.find(e=>a.existsSync(`${n}${e}`));if(r)return`${n}${r}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=i.resolve(i.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=i.basename(this._scriptPath,i.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}n=s.includes(i.extname(u));let f;if(o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.execPath,t,{stdio:`inherit`})):n?(t.unshift(u),t=g(o.execArgv).concat(t),f=r.spawn(o.argv[0],t,{stdio:`inherit`})):f=r.spawn(u,t,{stdio:`inherit`}),!f.killed){let e=[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`];e.forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})})}let p=this._exitCallback;f.on(`close`,e=>{e=e??1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_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&&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&&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?!1:this.getOptionValueSource(t)!==`default`}),t=e.filter(e=>e.conflictsWith.length>0);t.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,i=e.slice();function a(e){return e.length>1&&e[0]===`-`}let o=e=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,s=null;for(;i.length;){let e=i.shift();if(e===`--`){r===n&&r.push(e),r.push(...i);break}if(s&&(!a(e)||o(e))){this.emit(`option:${s.name()}`,e);continue}if(s=null,a(e)){let t=this._findOption(e);if(t){if(t.required){let e=i.shift();e===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;i.length>0&&(!a(i[0])||o(i[0]))&&(e=i.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);s=t.variadic?t:null;continue}}if(e.length>2&&e[0]===`-`&&e[1]!==`-`){let t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),i.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){let t=e.indexOf(`=`),n=this._findOption(e.slice(0,t));if(n&&(n.required||n.optional)){this.emit(`option:${n.name()}`,e.slice(t+1));continue}}if(r===t&&a(e)&&!(this.commands.length===0&&o(e))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(e)){t.push(e),i.length>0&&n.push(...i);break}else if(this._getHelpCommand()&&e===this._getHelpCommand().name()){t.push(e),i.length>0&&t.push(...i);break}else if(this._defaultCommandName){n.push(e),i.length>0&&n.push(...i);break}}if(this._passThroughOptions){r.push(e),i.length>0&&r.push(...i);break}r.push(e)}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(e=>{if(e.envVar&&e.envVar in o.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(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(),i=this.getOptionValueSource(r);return i===`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=m(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=this.parent?` for '${this.name()}'`:``,i=`error: too many arguments${r}. Expected ${t} argument${n} but got ${e.length}.`;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=m(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=t||`-V, --version`,n=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=>c(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=i.basename(e,i.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=e||{};let t=!!e.error,n,r,i;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());let a=e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e));return{error:t,write:a,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(e){this.outputHelp(e);let t=Number(o.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`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(),n=t&&e.find(e=>t.is(e));n&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(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 _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}exports.Command=h,exports.useColor=_})),k=e((exports=>{let{Argument:t}=w(),{Command:n}=O(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();exports.program=new n,exports.createCommand=e=>new n(e),exports.createOption=(e,t)=>new o(e,t),exports.createArgument=(e,n)=>new t(e,n),exports.Command=n,exports.Option=o,exports.Argument=t,exports.Help=a,exports.CommanderError=r,exports.InvalidArgumentError=i,exports.InvalidOptionArgumentError=i})),A=n(k(),1);const{program:j,createCommand:te,createArgument:M,createOption:N,CommanderError:P,InvalidArgumentError:F,InvalidOptionArgumentError:I,Command:L,Argument:R,Option:z,Help:B}=A.default;var V=`0.1.67`;async function H(e){e||(e=process.cwd());let t=o(e);await t.build({cwd:e,entry:t.entry,outdir:t.outdir,watch:!1,onStart:()=>{console.log(`Building agent...`)},onResult:e=>{`error`in e&&(console.error(e.error),process.exit(1));for(let t of e.warnings)console.warn(t.message);console.log(`Built agent to ${e.entry}`)}})}var U=n(a(),1);async function W(e,t){e||(e=process.cwd());let n=await c(),r=new s({authToken:n}),a=await i(e,`package.json`);if(!a)throw Error(`package.json not found`);let m=await x(a,`utf-8`),C=JSON.parse(m),w=g(a),T=_(w,`.blink`,`config.json`),E={};if(ee(T)){let e=await x(T,`utf-8`);E=JSON.parse(e)}let D;if(E?.organizationId)try{let e=await r.organizations.get(E.organizationId);D=e.name}catch(e){E.organizationId=void 0}if(!E?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];E.organizationId=t.id,D=t.name}else{let t=await f({message:`Which organization should contain this agent?`,options:e.map(e=>({value:e.id,label:e.name}))});if(d(t))return;E.organizationId=t,D=e.find(e=>e.id===t).name}}if(!E.organizationId)throw Error(`Developer error: No organization ID found.`);let O;if(E?.agentId)try{let e=await r.agents.get(E.agentId);O=e.name}catch(e){E.agentId=void 0}if(!E?.agentId)try{let e=await r.organizations.agents.get({organization_id:E.organizationId,agent_name:C.name});E.agentId=e.id,O=e.name}catch(e){let t=await r.agents.create({name:C.name,organization_id:E.organizationId});E.agentId=t.id,O=t.name}if(!E.agentId)throw Error(`Developer error: No agent ID found.`);await v(g(T),{recursive:!0}),await b(T,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...E},null,2),`utf-8`);let k=o(w),A=await new Promise((e,t)=>{k.build({cwd:w,entry:k.entry,outdir:k.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!A)throw Error(`Failed to build agent`);if(`error`in A)throw Error(A.error.message);let j={},te=await y(A.outdir);for(let e of te)j[_(A.outdir,e)]=e;let M=_(e,`README.md`);await G(M)&&(j[M]=`README.md`);let N=Object.entries(j),P=N.length,F=0,I=0,L=0,R=Array(P);await K(N,10,async([e,t],n)=>{let i=await S(e),a=i.size,o=++F;J(`${l.dim(`[${o}/${P}]`)} Uploading ${t} (${q(a)})...`);let s=await x(e),c=await r.files.upload(new File([s],t));R[n]={path:t,id:c.id},I+=1,L+=a});let z=R.filter(Boolean);J(`${l.dim(`[${I}/${P}]`)} Uploaded files (${q(L)}).`),process.stdout.write(`
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(),n=t&&e.find(e=>t.is(e));n&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function g(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 _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}exports.Command=h,exports.useColor=_})),k=e((exports=>{let{Argument:t}=w(),{Command:n}=O(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();exports.program=new n,exports.createCommand=e=>new n(e),exports.createOption=(e,t)=>new o(e,t),exports.createArgument=(e,n)=>new t(e,n),exports.Command=n,exports.Option=o,exports.Argument=t,exports.Help=a,exports.CommanderError=r,exports.InvalidArgumentError=i,exports.InvalidOptionArgumentError=i})),A=n(k(),1);const{program:j,createCommand:te,createArgument:M,createOption:N,CommanderError:P,InvalidArgumentError:F,InvalidOptionArgumentError:I,Command:L,Argument:R,Option:z,Help:B}=A.default;var V=`0.1.69`;async function H(e){e||(e=process.cwd());let t=o(e);await t.build({cwd:e,entry:t.entry,outdir:t.outdir,watch:!1,onStart:()=>{console.log(`Building agent...`)},onResult:e=>{`error`in e&&(console.error(e.error),process.exit(1));for(let t of e.warnings)console.warn(t.message);console.log(`Built agent to ${e.entry}`)}})}var U=n(a(),1);async function W(e,t){e||(e=process.cwd());let n=await c(),r=new s({authToken:n}),a=await i(e,`package.json`);if(!a)throw Error(`package.json not found`);let m=await x(a,`utf-8`),C=JSON.parse(m),w=g(a),T=_(w,`.blink`,`config.json`),E={};if(ee(T)){let e=await x(T,`utf-8`);E=JSON.parse(e)}let D;if(E?.organizationId)try{let e=await r.organizations.get(E.organizationId);D=e.name}catch(e){E.organizationId=void 0}if(!E?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];E.organizationId=t.id,D=t.name}else{let t=await f({message:`Which organization should contain this agent?`,options:e.map(e=>({value:e.id,label:e.name}))});if(d(t))return;E.organizationId=t,D=e.find(e=>e.id===t).name}}if(!E.organizationId)throw Error(`Developer error: No organization ID found.`);let O;if(E?.agentId)try{let e=await r.agents.get(E.agentId);O=e.name}catch(e){E.agentId=void 0}if(!E?.agentId)try{let e=await r.organizations.agents.get({organization_id:E.organizationId,agent_name:C.name});E.agentId=e.id,O=e.name}catch(e){let t=await r.agents.create({name:C.name,organization_id:E.organizationId});E.agentId=t.id,O=t.name}if(!E.agentId)throw Error(`Developer error: No agent ID found.`);await v(g(T),{recursive:!0}),await b(T,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...E},null,2),`utf-8`);let k=o(w),A=await new Promise((e,t)=>{k.build({cwd:w,entry:k.entry,outdir:k.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!A)throw Error(`Failed to build agent`);if(`error`in A)throw Error(A.error.message);let j={},te=await y(A.outdir);for(let e of te)j[_(A.outdir,e)]=e;let M=_(e,`README.md`);await G(M)&&(j[M]=`README.md`);let N=Object.entries(j),P=N.length,F=0,I=0,L=0,R=Array(P);await K(N,10,async([e,t],n)=>{let i=await S(e),a=i.size,o=++F;J(`${l.dim(`[${o}/${P}]`)} Uploading ${t} (${q(a)})...`);let s=await x(e),c=await r.files.upload(new File([s],t));R[n]={path:t,id:c.id},I+=1,L+=a});let z=R.filter(Boolean);J(`${l.dim(`[${I}/${P}]`)} Uploaded files (${q(L)}).`),process.stdout.write(`
21
21
  `);let B=_(e,`.env.local`),V=[];if(await G(B)){let e=(0,U.parse)(await x(B,`utf-8`));V=Object.keys(e)}let H=[],W=await r.agents.env.list({agent_id:E.agentId});H=W.map(e=>e.key);let Y=_(e,`.env.production`);if(await G(Y)){let e=(0,U.parse)(await x(Y,`utf-8`)),t=Object.entries(e),n=t.length,i=0;for(let[e,a]of t){let t=await r.agents.env.create({agent_id:E.agentId,key:e,value:a,target:[`production`,`preview`],secret:!0,upsert:!0});H.push(t.key),i+=1,J(`${l.dim(`[${i}/${n}]`)} Updating environment variable: ${e} ${l.dim(`(.env.production)`)}`)}J(`${l.dim(`[${i}/${n}]`)} Updated environment variables! ${l.dim(`(.env.production)`)}`),process.stdout.write(`
22
- `)}let X=V.filter(e=>!H.includes(e));if(X.length>0){console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of X)console.log(`- ${e}`);let e=await p({message:`Do you want to deploy anyway?`});if(e===!1||d(e))return}let Z=await r.agents.deployments.create({agent_id:E.agentId,target:`production`,entrypoint:h(A.entry),files:z,message:t?.message}),Q=`https://blink.so/${D}/${O}/deployments/${Z.number}`;console.log(`Deployed:`,Q);let $=u();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:E.agentId,deployment_id:Z.id});if(e.status===`success`){let t=`Deployment successful.`;e.target===`production`&&(t+=` All chats will use this deployment!`),$.stop(t);break}if(e.status===`failed`){let t=`Deployment failed.`;e.error_message&&(t+=` ${e.error_message}`),$.stop(t),console.log(`Read logs for details:`,Q);return}await new Promise(e=>setTimeout(e,500))}}catch(e){$.stop(`Failed to poll for deployment status.`),console.log(`Read logs for details:`,Q);return}}const G=async e=>{try{return await S(e),!0}catch(e){return!1}};async function K(e,t,n){let r=Array(e.length),i=0,a=Array(Math.min(t,e.length)).fill(0).map(async()=>{for(;;){let t=i++;if(t>=e.length)break;r[t]=await n(e[t],t)}});return await Promise.all(a),r}function q(e){if(e===0)return`0B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t)),i=e/Math.pow(t,r);return`${i.toFixed(i>=100?0:i>=10?1:2)}${n[r]}`}function J(e){if(process.stdout.isTTY)try{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(e);return}catch{}console.log(e)}globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>m()),j.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(V).action(()=>{j.outputHelp()});const Y=e=>async(...t)=>{let{default:n}=await e();return n(...t)};j.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(Y(()=>import(`./init-BEvNUWUD.js`))),j.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(Y(()=>import(`./dev-BAQJ4XqP.js`))),j.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(W),j.command(`build [directory]`).description(`Build your agent for production.`).action(H),j.command(`telemetry [boolean]`).description(`Enable or disable telemetry.`),j.command(`start [directory]`).description("Starts the Blink runtime in production mode. The agent must be compiled with `blink build` first."),j.command(`connect`,{hidden:!0}).description(`Connect compute to the Blink Cloud.`).action(Y(()=>import(`./connect-BHyGYU8L.js`))),j.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(Y(()=>import(`./chat-L0VBV1Zr.js`))),j.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(Y(()=>import(`./login-DKW_KVCA.js`))),j.parse(process.argv);export{};
22
+ `)}let X=V.filter(e=>!H.includes(e));if(X.length>0){console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of X)console.log(`- ${e}`);let e=await p({message:`Do you want to deploy anyway?`});if(e===!1||d(e))return}let Z=await r.agents.deployments.create({agent_id:E.agentId,target:`production`,entrypoint:h(A.entry),files:z,message:t?.message}),Q=`https://blink.so/${D}/${O}/deployments/${Z.number}`;console.log(`Deployed:`,Q);let $=u();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:E.agentId,deployment_id:Z.id});if(e.status===`success`){let t=`Deployment successful.`;e.target===`production`&&(t+=` All chats will use this deployment!`),$.stop(t);break}if(e.status===`failed`){let t=`Deployment failed.`;e.error_message&&(t+=` ${e.error_message}`),$.stop(t),console.log(`Read logs for details:`,Q);return}await new Promise(e=>setTimeout(e,500))}}catch(e){$.stop(`Failed to poll for deployment status.`),console.log(`Read logs for details:`,Q);return}}const G=async e=>{try{return await S(e),!0}catch(e){return!1}};async function K(e,t,n){let r=Array(e.length),i=0,a=Array(Math.min(t,e.length)).fill(0).map(async()=>{for(;;){let t=i++;if(t>=e.length)break;r[t]=await n(e[t],t)}});return await Promise.all(a),r}function q(e){if(e===0)return`0B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t)),i=e/Math.pow(t,r);return`${i.toFixed(i>=100?0:i>=10?1:2)}${n[r]}`}function J(e){if(process.stdout.isTTY)try{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(e);return}catch{}console.log(e)}globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>m()),j.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(V).action(()=>{j.outputHelp()});const Y=e=>async(...t)=>{let{default:n}=await e();return n(...t)};j.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(Y(()=>import(`./init-BEvNUWUD.js`))),j.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(Y(()=>import(`./dev-BnaJT8A_.js`))),j.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(W),j.command(`build [directory]`).description(`Build your agent for production.`).action(H),j.command(`telemetry [boolean]`).description(`Enable or disable telemetry.`),j.command(`start [directory]`).description("Starts the Blink runtime in production mode. The agent must be compiled with `blink build` first."),j.command(`connect`,{hidden:!0}).description(`Connect compute to the Blink Cloud.`).action(Y(()=>import(`./connect-BHyGYU8L.js`))),j.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(Y(()=>import(`./chat-L0VBV1Zr.js`))),j.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(Y(()=>import(`./login-DKW_KVCA.js`))),j.parse(process.argv);export{};
@@ -1,9 +1,9 @@
1
- import{__commonJSMin as e,__require as t}from"./chunk-ByIbJXPc.js";import n,{dirname as r,join as i}from"path";import{existsSync as a}from"fs";import{builtinModules as o}from"module";import{mkdir as s,stat as c,writeFile as l}from"fs/promises";function u(e){return async t=>{let r=await import(`esbuild`),i=await r.context({entryPoints:[t.entry],outdir:t.outdir,bundle:!0,write:!1,logLevel:`silent`,format:`esm`,platform:`node`,target:`node22`,sourcemap:!1,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,r=RegExp(`\\b__require\\("(${o.join(`|`)})"\\)`,`gm`);if(t=t.replace(r,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
1
+ import{__commonJSMin as e,__require as t}from"./chunk-ByIbJXPc.js";import n,{dirname as r,join as i}from"path";import{existsSync as a}from"fs";import{builtinModules as o}from"module";import{mkdir as s,rm as c,stat as l,writeFile as u}from"fs/promises";function d(e){return async t=>{let r=await import(`esbuild`),i=await r.context({entryPoints:[t.entry],outdir:t.outdir,bundle:!0,write:!1,logLevel:`silent`,format:`esm`,platform:`node`,target:`node22`,sourcemap:!1,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,r=RegExp(`\\b__require\\("(${o.join(`|`)})"\\)`,`gm`);if(t=t.replace(r,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
2
2
  `);t=e+`
3
3
 
4
- `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{t.onStart(),r=performance.now()}),e.onEnd(async e=>{await s(t.outdir,{recursive:!0});let a=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];a.push({path:n.resolve(t.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of a)await l(e.path,e.contents);e.errors.length>0?t.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
5
- `)}}):t.onResult({entry:n.resolve(t.outdir,n.basename(t.entry).replace(`.ts`,`.js`)),duration:performance.now()-r,outdir:t.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),t.watch||(i.dispose(),i.cancel())})}}],...e});await i.watch()}}function d(e){let r=[`blink.config.ts`],i;for(let o of r){let r=n.resolve(e,o);if(a(r)){let e=t(r);if(e.default){i={...e.default};break}}}if(i||(i={}),!i.entry){let t=[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`];for(let r of t){let t=n.resolve(e,r);if(a(t)){i.entry=t;break}}if(!i.entry)throw Error(`Agent entrypoint not found.
4
+ `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{t.onStart(),r=performance.now()}),e.onEnd(async e=>{await c(t.outdir,{recursive:!0,force:!0}),await s(t.outdir,{recursive:!0});let a=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];a.push({path:n.resolve(t.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of a)await u(e.path,e.contents);e.errors.length>0?t.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
5
+ `)}}):t.onResult({entry:n.resolve(t.outdir,n.basename(t.entry).replace(`.ts`,`.js`)),duration:performance.now()-r,outdir:t.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),t.watch||(i.dispose(),i.cancel())})}}],...e});await i.watch()}}function f(e){let r=[`blink.config.ts`],i;for(let o of r){let r=n.resolve(e,o);if(a(r)){let e=t(r);if(e.default){i={...e.default};break}}}if(i||(i={}),!i.entry){let t=[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`];for(let r of t){let t=n.resolve(e,r);if(a(t)){i.entry=t;break}}if(!i.entry)throw Error(`Agent entrypoint not found.
6
6
 
7
- Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return i.outdir||(i.outdir=n.resolve(e,`.blink/build`)),i.build||(i.build=u()),i}var f=e(((exports,t)=>{t.exports={name:`dotenv`,version:`16.4.7`,description:`Loads environment variables from .env file`,main:`lib/main.js`,types:`lib/main.d.ts`,exports:{".":{types:`./lib/main.d.ts`,require:`./lib/main.js`,default:`./lib/main.js`},"./config":`./config.js`,"./config.js":`./config.js`,"./lib/env-options":`./lib/env-options.js`,"./lib/env-options.js":`./lib/env-options.js`,"./lib/cli-options":`./lib/cli-options.js`,"./lib/cli-options.js":`./lib/cli-options.js`,"./package.json":`./package.json`},scripts:{"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run --show-full-coverage --timeout=60000 --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},repository:{type:`git`,url:`git://github.com/motdotla/dotenv.git`},funding:`https://dotenvx.com`,keywords:[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],readmeFilename:`README.md`,license:`BSD-2-Clause`,devDependencies:{"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},engines:{node:`>=12`},browser:{fs:!1}}})),p=e(((exports,n)=>{let r=t(`fs`),i=t(`path`),a=t(`os`),o=t(`crypto`),s=f(),c=s.version,l=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function u(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
7
+ Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return i.outdir||(i.outdir=n.resolve(e,`.blink/build`)),i.build||(i.build=d()),i}var p=e(((exports,t)=>{t.exports={name:`dotenv`,version:`16.4.7`,description:`Loads environment variables from .env file`,main:`lib/main.js`,types:`lib/main.d.ts`,exports:{".":{types:`./lib/main.d.ts`,require:`./lib/main.js`,default:`./lib/main.js`},"./config":`./config.js`,"./config.js":`./config.js`,"./lib/env-options":`./lib/env-options.js`,"./lib/env-options.js":`./lib/env-options.js`,"./lib/cli-options":`./lib/cli-options.js`,"./lib/cli-options.js":`./lib/cli-options.js`,"./package.json":`./package.json`},scripts:{"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run --show-full-coverage --timeout=60000 --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},repository:{type:`git`,url:`git://github.com/motdotla/dotenv.git`},funding:`https://dotenvx.com`,keywords:[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],readmeFilename:`README.md`,license:`BSD-2-Clause`,devDependencies:{"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},engines:{node:`>=12`},browser:{fs:!1}}})),m=e(((exports,n)=>{let r=t(`fs`),i=t(`path`),a=t(`os`),o=t(`crypto`),s=p(),c=s.version,l=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function u(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
8
8
  `);let r;for(;(r=l.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
9
- `),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function d(e){let t=v(e),n=T.configDotenv({path:t});if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=g(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=r[e].trim(),i=_(n,t);a=T.decrypt(i.ciphertext,i.key);break}catch(t){if(e+1>=i)throw t}return T.parse(a)}function p(e){console.log(`[dotenv@${c}][INFO] ${e}`)}function m(e){console.log(`[dotenv@${c}][WARN] ${e}`)}function h(e){console.log(`[dotenv@${c}][DEBUG] ${e}`)}function g(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function _(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function v(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)r.existsSync(n)&&(t=n.endsWith(`.vault`)?n:`${n}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=i.resolve(process.cwd(),`.env.vault`);return r.existsSync(t)?t:null}function y(e){return e[0]===`~`?i.join(a.homedir(),e.slice(1)):e}function b(e){p(`Loading env from encrypted .env.vault`);let t=T._parseVault(e),n=process.env;return e&&e.processEnv!=null&&(n=e.processEnv),T.populate(n,t,e),{parsed:t}}function x(e){let t=i.resolve(process.cwd(),`.env`),n=`utf8`,a=!!(e&&e.debug);e&&e.encoding?n=e.encoding:a&&h(`No encoding is specified. UTF-8 is used by default`);let o=[t];if(e&&e.path)if(!Array.isArray(e.path))o=[y(e.path)];else{o=[];for(let t of e.path)o.push(y(t))}let s,c={};for(let t of o)try{let i=T.parse(r.readFileSync(t,{encoding:n}));T.populate(c,i,e)}catch(e){a&&h(`Failed to load ${t} ${e.message}`),s=e}let l=process.env;return e&&e.processEnv!=null&&(l=e.processEnv),T.populate(l,c,e),s?{parsed:c,error:s}:{parsed:c}}function S(e){if(g(e).length===0)return T.configDotenv(e);let t=v(e);return t?T._configVault(e):(m(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),T.configDotenv(e))}function C(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),a=r.subarray(-16);r=r.subarray(12,-16);try{let e=o.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(a),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function w(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override);if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n]),r&&h(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}let T={configDotenv:x,_configVault:b,_parseVault:d,config:S,decrypt:C,parse:u,populate:w};n.exports.configDotenv=T.configDotenv,n.exports._configVault=T._configVault,n.exports._parseVault=T._parseVault,n.exports.config=T.config,n.exports.decrypt=T.decrypt,n.exports.parse=T.parse,n.exports.populate=T.populate,n.exports=T}));async function m(e,t){let n=e;for(;n!==r(n);){let e=i(n,t);try{return await c(e),e}catch{}n=r(n)}}export{m as findNearestEntry,p as require_main,d as resolveConfig};
9
+ `),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function d(e){let t=v(e),n=T.configDotenv({path:t});if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=g(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=r[e].trim(),i=_(n,t);a=T.decrypt(i.ciphertext,i.key);break}catch(t){if(e+1>=i)throw t}return T.parse(a)}function f(e){console.log(`[dotenv@${c}][INFO] ${e}`)}function m(e){console.log(`[dotenv@${c}][WARN] ${e}`)}function h(e){console.log(`[dotenv@${c}][DEBUG] ${e}`)}function g(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function _(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function v(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)r.existsSync(n)&&(t=n.endsWith(`.vault`)?n:`${n}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=i.resolve(process.cwd(),`.env.vault`);return r.existsSync(t)?t:null}function y(e){return e[0]===`~`?i.join(a.homedir(),e.slice(1)):e}function b(e){f(`Loading env from encrypted .env.vault`);let t=T._parseVault(e),n=process.env;return e&&e.processEnv!=null&&(n=e.processEnv),T.populate(n,t,e),{parsed:t}}function x(e){let t=i.resolve(process.cwd(),`.env`),n=`utf8`,a=!!(e&&e.debug);e&&e.encoding?n=e.encoding:a&&h(`No encoding is specified. UTF-8 is used by default`);let o=[t];if(e&&e.path)if(!Array.isArray(e.path))o=[y(e.path)];else{o=[];for(let t of e.path)o.push(y(t))}let s,c={};for(let t of o)try{let i=T.parse(r.readFileSync(t,{encoding:n}));T.populate(c,i,e)}catch(e){a&&h(`Failed to load ${t} ${e.message}`),s=e}let l=process.env;return e&&e.processEnv!=null&&(l=e.processEnv),T.populate(l,c,e),s?{parsed:c,error:s}:{parsed:c}}function S(e){if(g(e).length===0)return T.configDotenv(e);let t=v(e);return t?T._configVault(e):(m(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),T.configDotenv(e))}function C(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),a=r.subarray(-16);r=r.subarray(12,-16);try{let e=o.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(a),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function w(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override);if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n]),r&&h(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}let T={configDotenv:x,_configVault:b,_parseVault:d,config:S,decrypt:C,parse:u,populate:w};n.exports.configDotenv=T.configDotenv,n.exports._configVault=T._configVault,n.exports._parseVault=T._parseVault,n.exports.config=T.config,n.exports.decrypt=T.decrypt,n.exports.parse=T.parse,n.exports.populate=T.populate,n.exports=T}));async function h(e,t){let n=e;for(;n!==r(n);){let e=i(n,t);try{return await l(e),e}catch{}n=r(n)}}export{h as findNearestEntry,m as require_main,f as resolveConfig};
@@ -1,4 +1,4 @@
1
- import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-wBJ4jcnM.cjs";
1
+ import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-C1lOzjkX.cjs";
2
2
  import * as ai0 from "ai";
3
3
  import { UIMessage } from "ai";
4
4
  import * as _ai_sdk_provider0 from "@ai-sdk/provider";
@@ -1,4 +1,4 @@
1
- import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-D1y2mwdW.js";
1
+ import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-BxnYzsYC.js";
2
2
  import http from "http";
3
3
  import * as ai0 from "ai";
4
4
  import { UIMessage } from "ai";
@@ -1,7 +1,7 @@
1
1
  const e=require(`../chunk-hhQzssFb.cjs`);let t=require(`path`);t=e.__toESM(t);let n=require(`fs`);n=e.__toESM(n);let r=require(`module`);r=e.__toESM(r);let i=require(`fs/promises`);i=e.__toESM(i);function a(e){return async n=>{let a=await import(`esbuild`),o=await a.context({entryPoints:[n.entry],outdir:n.outdir,bundle:!0,write:!1,logLevel:`silent`,format:`esm`,platform:`node`,target:`node22`,sourcemap:!1,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,i=RegExp(`\\b__require\\("(${r.builtinModules.join(`|`)})"\\)`,`gm`);if(t=t.replace(i,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
2
2
  `);t=e+`
3
3
 
4
- `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{n.onStart(),r=performance.now()}),e.onEnd(async e=>{await(0,i.mkdir)(n.outdir,{recursive:!0});let a=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];a.push({path:t.default.resolve(n.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of a)await(0,i.writeFile)(e.path,e.contents);e.errors.length>0?n.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
4
+ `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{n.onStart(),r=performance.now()}),e.onEnd(async e=>{await(0,i.rm)(n.outdir,{recursive:!0,force:!0}),await(0,i.mkdir)(n.outdir,{recursive:!0});let a=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];a.push({path:t.default.resolve(n.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of a)await(0,i.writeFile)(e.path,e.contents);e.errors.length>0?n.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
5
5
  `)}}):n.onResult({entry:t.default.resolve(n.outdir,t.default.basename(n.entry).replace(`.ts`,`.js`)),duration:performance.now()-r,outdir:n.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),n.watch||(o.dispose(),o.cancel())})}}],...e});await o.watch()}}function o(e){return e??{}}function s(e){let r=[`blink.config.ts`],i;for(let a of r){let r=t.default.resolve(e,a);if((0,n.existsSync)(r)){let e=require(r);if(e.default){i={...e.default};break}}}if(i||={},!i.entry){let r=[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`];for(let a of r){let r=t.default.resolve(e,a);if((0,n.existsSync)(r)){i.entry=r;break}}if(!i.entry)throw Error(`Agent entrypoint not found.
6
6
 
7
7
  Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return i.outdir||=t.default.resolve(e,`.blink/build`),i.build||=a(),i}exports.buildWithEsbuild=a,exports.defineConfig=o,exports.resolveConfig=s;
@@ -1,7 +1,7 @@
1
- import{__require as e}from"../chunk-___ucjiX.js";import t from"path";import{existsSync as n}from"fs";import{builtinModules as r}from"module";import{mkdir as i,writeFile as a}from"fs/promises";function o(e){return async n=>{let o=await import(`esbuild`),s=await o.context({entryPoints:[n.entry],outdir:n.outdir,bundle:!0,write:!1,logLevel:`silent`,format:`esm`,platform:`node`,target:`node22`,sourcemap:!1,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,i=RegExp(`\\b__require\\("(${r.join(`|`)})"\\)`,`gm`);if(t=t.replace(i,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
1
+ import{__require as e}from"../chunk-___ucjiX.js";import t from"path";import{existsSync as n}from"fs";import{builtinModules as r}from"module";import{mkdir as i,rm as a,writeFile as o}from"fs/promises";function s(e){return async n=>{let s=await import(`esbuild`),c=await s.context({entryPoints:[n.entry],outdir:n.outdir,bundle:!0,write:!1,logLevel:`silent`,format:`esm`,platform:`node`,target:`node22`,sourcemap:!1,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,i=RegExp(`\\b__require\\("(${r.join(`|`)})"\\)`,`gm`);if(t=t.replace(i,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
2
2
  `);t=e+`
3
3
 
4
- `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{n.onStart(),r=performance.now()}),e.onEnd(async e=>{await i(n.outdir,{recursive:!0});let o=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];o.push({path:t.resolve(n.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of o)await a(e.path,e.contents);e.errors.length>0?n.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
5
- `)}}):n.onResult({entry:t.resolve(n.outdir,t.basename(n.entry).replace(`.ts`,`.js`)),duration:performance.now()-r,outdir:n.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),n.watch||(s.dispose(),s.cancel())})}}],...e});await s.watch()}}function s(e){return e??{}}function c(r){let i=[`blink.config.ts`],a;for(let o of i){let i=t.resolve(r,o);if(n(i)){let t=e(i);if(t.default){a={...t.default};break}}}if(a||={},!a.entry){let e=[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`];for(let i of e){let e=t.resolve(r,i);if(n(e)){a.entry=e;break}}if(!a.entry)throw Error(`Agent entrypoint not found.
4
+ `+t}e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let r;e.onStart(()=>{n.onStart(),r=performance.now()}),e.onEnd(async e=>{await a(n.outdir,{recursive:!0,force:!0}),await i(n.outdir,{recursive:!0});let s=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];s.push({path:t.resolve(n.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of s)await o(e.path,e.contents);e.errors.length>0?n.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
5
+ `)}}):n.onResult({entry:t.resolve(n.outdir,t.basename(n.entry).replace(`.ts`,`.js`)),duration:performance.now()-r,outdir:n.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),n.watch||(c.dispose(),c.cancel())})}}],...e});await c.watch()}}function c(e){return e??{}}function l(r){let i=[`blink.config.ts`],a;for(let o of i){let i=t.resolve(r,o);if(n(i)){let t=e(i);if(t.default){a={...t.default};break}}}if(a||={},!a.entry){let e=[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`];for(let i of e){let e=t.resolve(r,i);if(n(e)){a.entry=e;break}}if(!a.entry)throw Error(`Agent entrypoint not found.
6
6
 
7
- Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return a.outdir||=t.resolve(r,`.blink/build`),a.build||=o(),a}export{o as buildWithEsbuild,s as defineConfig,c as resolveConfig};
7
+ Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return a.outdir||=t.resolve(r,`.blink/build`),a.build||=s(),a}export{s as buildWithEsbuild,c as defineConfig,l as resolveConfig};
@@ -25,19 +25,6 @@ declare const chat: Readonly<{
25
25
  message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
26
26
  }>;
27
27
  //#endregion
28
- //#region src/api/storage.d.ts
29
- /**
30
- * Storage allows agents to persist data.
31
- * Every agent has it's own persistent storage namespace.
32
- */
33
- declare const storage: Readonly<{
34
- kv: Readonly<{
35
- get: (key: string) => Promise<string | undefined>;
36
- set: (key: string, value: string) => Promise<void>;
37
- del: (key: string) => Promise<void>;
38
- }>;
39
- }>;
40
- //#endregion
41
28
  //#region src/api/tools.d.ts
42
29
  /**
43
30
  * ToolWithContext is a tool that supports the "withContext" method.
@@ -137,6 +124,19 @@ interface ToolApprovalOutput {
137
124
  */
138
125
  declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput;
139
126
  //#endregion
127
+ //#region src/api/storage.d.ts
128
+ /**
129
+ * Storage allows agents to persist data.
130
+ * Every agent has it's own persistent storage namespace.
131
+ */
132
+ declare const storage: Readonly<{
133
+ kv: Readonly<{
134
+ get: (key: string) => Promise<string | undefined>;
135
+ set: (key: string, value: string) => Promise<void>;
136
+ del: (key: string) => Promise<void>;
137
+ }>;
138
+ }>;
139
+ //#endregion
140
140
  //#region src/api/index.browser.d.ts
141
141
  /**
142
142
  * SendMessagesResponse is the response of the sendMessages function.
@@ -199,15 +199,49 @@ type ProvideOptionsRequest<MESSAGE extends UIMessage = UIMessage> = {
199
199
  */
200
200
  readonly selectedOptions?: ExtractUIOptions<MESSAGE>;
201
201
  };
202
+ type OptionIcon = `lucide:${string}` | `simple-icons:${string}`;
202
203
  type OptionSelectValue<ID extends string = string> = {
203
204
  readonly id: ID;
204
205
  readonly label: string;
206
+ /**
207
+ * description will provide additional context to the user in the UI.
208
+ */
209
+ readonly description?: string | Array<{
210
+ readonly text: string;
211
+ readonly color?: "primary" | "muted" | "warning";
212
+ }>;
213
+ /**
214
+ * icon is a slug of a Lucide or SimpleIcons icon.
215
+ * This will only be rendered in a web-based UI.
216
+ *
217
+ * Find icons:
218
+ * - https://simpleicons.org/
219
+ * - https://lucide.dev/icons/
220
+ */
221
+ readonly icon?: OptionIcon;
205
222
  };
206
223
  type OptionSelect<Values extends readonly OptionSelectValue[] = readonly OptionSelectValue[]> = {
207
224
  readonly type: "select";
208
- readonly label: string;
225
+ /**
226
+ * label indicates the purpose of the option.
227
+ * If omitted, it will not be displayed in the UI.
228
+ */
229
+ readonly label?: string;
230
+ /**
231
+ * icon is a slug of a Lucide or SimpleIcons icon.
232
+ * This will only be rendered in a web-based UI.
233
+ *
234
+ * Find icons:
235
+ * - https://simpleicons.org/
236
+ * - https://lucide.dev/icons/
237
+ */
238
+ readonly icon?: OptionIcon;
239
+ /**
240
+ * defaultValue is the default value for the option.
241
+ * If omitted, the option will not be selected by default.
242
+ */
243
+ readonly defaultValue?: Values[number]["id"];
209
244
  readonly values: Values;
210
- readonly defaultValue: Values[number]["id"];
211
245
  };
212
246
  type Options = Record<string, string>;
213
247
  type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessage> = MESSAGE & {
@@ -217,10 +251,7 @@ type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessag
217
251
  };
218
252
  };
219
253
  type ExtractUIOptions<M> = M extends WithUIOptions<infer O> ? O : never;
220
- type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<{
221
- id: OPTIONS[K];
222
- label: string;
223
- }>> };
254
+ type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<OptionSelectValue<OPTIONS[K]>>> };
224
255
  /**
225
256
  * lastUIOptions finds the last user message with options.
226
257
  * Options are stored in message metadata to preserve the history
@@ -25,19 +25,6 @@ declare const chat: Readonly<{
25
25
  message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
26
26
  }>;
27
27
  //#endregion
28
- //#region src/api/storage.d.ts
29
- /**
30
- * Storage allows agents to persist data.
31
- * Every agent has it's own persistent storage namespace.
32
- */
33
- declare const storage: Readonly<{
34
- kv: Readonly<{
35
- get: (key: string) => Promise<string | undefined>;
36
- set: (key: string, value: string) => Promise<void>;
37
- del: (key: string) => Promise<void>;
38
- }>;
39
- }>;
40
- //#endregion
41
28
  //#region src/api/tools.d.ts
42
29
  /**
43
30
  * ToolWithContext is a tool that supports the "withContext" method.
@@ -137,6 +124,19 @@ interface ToolApprovalOutput {
137
124
  */
138
125
  declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput;
139
126
  //#endregion
127
+ //#region src/api/storage.d.ts
128
+ /**
129
+ * Storage allows agents to persist data.
130
+ * Every agent has it's own persistent storage namespace.
131
+ */
132
+ declare const storage: Readonly<{
133
+ kv: Readonly<{
134
+ get: (key: string) => Promise<string | undefined>;
135
+ set: (key: string, value: string) => Promise<void>;
136
+ del: (key: string) => Promise<void>;
137
+ }>;
138
+ }>;
139
+ //#endregion
140
140
  //#region src/api/index.browser.d.ts
141
141
  /**
142
142
  * SendMessagesResponse is the response of the sendMessages function.
@@ -199,15 +199,49 @@ type ProvideOptionsRequest<MESSAGE extends UIMessage = UIMessage> = {
199
199
  */
200
200
  readonly selectedOptions?: ExtractUIOptions<MESSAGE>;
201
201
  };
202
+ type OptionIcon = `lucide:${string}` | `simple-icons:${string}`;
202
203
  type OptionSelectValue<ID extends string = string> = {
203
204
  readonly id: ID;
204
205
  readonly label: string;
206
+ /**
207
+ * description will provide additional context to the user in the UI.
208
+ */
209
+ readonly description?: string | Array<{
210
+ readonly text: string;
211
+ readonly color?: "primary" | "muted" | "warning";
212
+ }>;
213
+ /**
214
+ * icon is a slug of a Lucide or SimpleIcons icon.
215
+ * This will only be rendered in a web-based UI.
216
+ *
217
+ * Find icons:
218
+ * - https://simpleicons.org/
219
+ * - https://lucide.dev/icons/
220
+ */
221
+ readonly icon?: OptionIcon;
205
222
  };
206
223
  type OptionSelect<Values extends readonly OptionSelectValue[] = readonly OptionSelectValue[]> = {
207
224
  readonly type: "select";
208
- readonly label: string;
225
+ /**
226
+ * label indicates the purpose of the option.
227
+ * If omitted, it will not be displayed in the UI.
228
+ */
229
+ readonly label?: string;
230
+ /**
231
+ * icon is a slug of a Lucide or SimpleIcons icon.
232
+ * This will only be rendered in a web-based UI.
233
+ *
234
+ * Find icons:
235
+ * - https://simpleicons.org/
236
+ * - https://lucide.dev/icons/
237
+ */
238
+ readonly icon?: OptionIcon;
239
+ /**
240
+ * defaultValue is the default value for the option.
241
+ * If omitted, the option will not be selected by default.
242
+ */
243
+ readonly defaultValue?: Values[number]["id"];
209
244
  readonly values: Values;
210
- readonly defaultValue: Values[number]["id"];
211
245
  };
212
246
  type Options = Record<string, string>;
213
247
  type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessage> = MESSAGE & {
@@ -217,10 +251,7 @@ type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessag
217
251
  };
218
252
  };
219
253
  type ExtractUIOptions<M> = M extends WithUIOptions<infer O> ? O : never;
220
- type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<{
221
- id: OPTIONS[K];
222
- label: string;
223
- }>> };
254
+ type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<OptionSelectValue<OPTIONS[K]>>> };
224
255
  /**
225
256
  * lastUIOptions finds the last user message with options.
226
257
  * Options are stored in message metadata to preserve the history
@@ -1,4 +1,4 @@
1
- import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-wBJ4jcnM.cjs";
1
+ import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-C1lOzjkX.cjs";
2
2
  import { UIMessage, UIMessageChunk } from "ai";
3
3
 
4
4
  //#region src/http/client.d.ts
@@ -1,4 +1,4 @@
1
- import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-D1y2mwdW.js";
1
+ import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-BxnYzsYC.js";
2
2
  import { UIMessage, UIMessageChunk } from "ai";
3
3
 
4
4
  //#region src/http/client.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blink",
3
- "version": "0.1.67",
3
+ "version": "0.1.69",
4
4
  "description": "Blink is a JavaScript runtime for building and deploying AI agents.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -94,10 +94,5 @@
94
94
  "zod": ">= 4",
95
95
  "ai": ">= 5",
96
96
  "react": ">= 18"
97
- },
98
- "peerDependenciesMeta": {
99
- "react": {
100
- "optional": true
101
- }
102
97
  }
103
98
  }