blink 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/browser/control/index.d.cts +16 -16
  2. package/dist/browser/control/index.d.ts +16 -16
  3. package/dist/cli/{auth-CpUNsA0k.js → auth-DeHFQhPJ.js} +1 -1
  4. package/dist/cli/{chat-01Fdrhd_.js → chat-Jjsxhu91.js} +1 -1
  5. package/dist/cli/{dev-DQh5Ph18.js → dev-BPKpFAM3.js} +99 -420
  6. package/dist/cli/index.js +3 -3
  7. package/dist/cli/init-C45jjEXu.js +416 -0
  8. package/dist/cli/init-DAff8BFO.js +1 -0
  9. package/dist/cli/login-OOGg9_8j.js +1 -0
  10. package/dist/cli/{run-Dy4EpNVD.js → run-_bDe0KqM.js} +1 -1
  11. package/dist/cli/{util-CkrO2lHF.js → util-dGFzG4wT.js} +1 -1
  12. package/dist/node/agent/index.node.cjs +1 -1
  13. package/dist/node/agent/index.node.js +1 -1
  14. package/dist/node/build/index.cjs +1 -1
  15. package/dist/node/build/index.js +1 -1
  16. package/dist/node/{build-D_L0gFGa.js → build-M5Q2ZTGh.js} +5 -5
  17. package/dist/node/{build-BzoNpizh.cjs → build-lx6plR19.cjs} +4 -4
  18. package/dist/node/{getMachineId-bsd-B84ixt26.cjs → getMachineId-bsd-CUUgtcEk.cjs} +1 -1
  19. package/dist/node/{getMachineId-bsd-BxqlJcyA.js → getMachineId-bsd-CpiyZ31n.js} +1 -1
  20. package/dist/node/{getMachineId-bsd-C10eVJgT.js → getMachineId-bsd-DKc3Wh2z.js} +1 -1
  21. package/dist/node/{getMachineId-bsd-BudRe7J9.cjs → getMachineId-bsd-YA-Qh955.cjs} +1 -1
  22. package/dist/node/{getMachineId-darwin-Bf4P0U5b.js → getMachineId-darwin-BBDIi9K5.js} +1 -1
  23. package/dist/node/{getMachineId-darwin-JB29MQsG.js → getMachineId-darwin-CQ9-5u-a.js} +1 -1
  24. package/dist/node/{getMachineId-darwin-ZVi3EKE3.cjs → getMachineId-darwin-CcM48gLI.cjs} +1 -1
  25. package/dist/node/{getMachineId-darwin-Cyng5kFG.cjs → getMachineId-darwin-IcDjLpqm.cjs} +1 -1
  26. package/dist/node/{getMachineId-linux-B-CtXK0L.cjs → getMachineId-linux-BzwdWZoB.cjs} +1 -1
  27. package/dist/node/{getMachineId-linux-BPnkHJah.js → getMachineId-linux-Cc8c4coA.js} +1 -1
  28. package/dist/node/{getMachineId-linux-CJXPQ8U5.cjs → getMachineId-linux-DMvLmvRp.cjs} +1 -1
  29. package/dist/node/{getMachineId-linux-CmMSYp7C.js → getMachineId-linux-TNXyQsBB.js} +1 -1
  30. package/dist/node/{getMachineId-unsupported--0R36RP6.cjs → getMachineId-unsupported-ApoW5rxx.cjs} +1 -1
  31. package/dist/node/{getMachineId-unsupported-C_4fnT4Z.js → getMachineId-unsupported-CRrpolgF.js} +1 -1
  32. package/dist/node/{getMachineId-unsupported-Dtt3HTNZ.js → getMachineId-unsupported-DGhOj3l0.js} +1 -1
  33. package/dist/node/{getMachineId-unsupported-DM7fz1pP.cjs → getMachineId-unsupported-DYGwqELh.cjs} +1 -1
  34. package/dist/node/{getMachineId-win-CjJkZMZe.cjs → getMachineId-win-B-bRjIv0.cjs} +1 -1
  35. package/dist/node/{getMachineId-win-D1szVnqR.js → getMachineId-win-CSKzOPIT.js} +1 -1
  36. package/dist/node/{getMachineId-win-DDz2FyEp.cjs → getMachineId-win-CoAu5xDr.cjs} +1 -1
  37. package/dist/node/{getMachineId-win-C4G-fkEF.js → getMachineId-win-Dfq5UG8G.js} +1 -1
  38. package/dist/node/{index.node-C6sId3jT.cjs → index.node-DN4zHlM1.cjs} +4 -4
  39. package/dist/node/{index.node-BdbWMIX0.js → index.node-wsvVRWwb.js} +4 -4
  40. package/dist/node/react/index.node.cjs +455 -94
  41. package/dist/node/react/index.node.js +141 -121
  42. package/dist/node/{token-DOfE6QlD.js → token-B0ivJQut.js} +1 -1
  43. package/dist/node/{token-BBGr-czK.cjs → token-C10csUbV.cjs} +1 -1
  44. package/dist/node/{token-util-_pz5CtFI.js → token-util-1r_uDcp7.js} +1 -1
  45. package/dist/node/{token-util-BOoyY0PX.cjs → token-util-BwRq8n40.cjs} +1 -1
  46. package/dist/node/token-util-CSWJ2yfA.js +1 -0
  47. package/dist/node/token-util-beB2LRJ9.cjs +1 -0
  48. package/package.json +1 -1
  49. package/dist/cli/init-DFXOMY0k.js +0 -83
  50. package/dist/cli/login-yMSEGrjU.js +0 -1
  51. package/dist/node/token-util-C_uzN2q9.js +0 -1
  52. package/dist/node/token-util-D9kCwzE6.cjs +0 -1
  53. /package/dist/cli/{dist-wyfWuz5A.js → dist-BNbSDxaw.js} +0 -0
  54. /package/dist/cli/{open-S_jcQ0nw.js → open-DCYivxgo.js} +0 -0
  55. /package/dist/node/{esm-0UNjvroT.cjs → esm-C-vSI1Ww.cjs} +0 -0
  56. /package/dist/node/{esm-CbZfjZBn.js → esm-D1GEQyaY.js} +0 -0
  57. /package/dist/node/{token-error-BoNG8ooW.cjs → token-error-l6zIbPbZ.cjs} +0 -0
  58. /package/dist/node/{token-error-488npYdU.js → token-error-wsvzy87W.js} +0 -0
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-D9KrCrVq.js";import{import_websocket as r}from"./wrapper-B0SBsJWP.js";import{findNearestEntry as i,migrateBlinkToData as a,require_main as o,resolveConfig as s}from"./util-CkrO2lHF.js";import{Client as c,loginIfNeeded as l,require_source as u}from"./auth-CpUNsA0k.js";import{Y as d,pD as f,ve as p,ye as m}from"./dist-wyfWuz5A.js";import"./open-S_jcQ0nw.js";import{require_ignore as h}from"./ignore-NA4V6Pjc.js";import{randomUUID as g}from"crypto";import{basename as _,dirname as v,join as y,relative as ee}from"node:path";import{existsSync as te}from"node:fs";import{mkdir as ne,readdir as b,writeFile as re}from"fs/promises";import{readFile as x,stat as S}from"node:fs/promises";var C=e((e=>{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}};e.CommanderError=t,e.InvalidArgumentError=n})),w=e((e=>{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.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}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._collectValue(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+`]`}e.Argument=n,e.humanReadableArgName=r})),T=e((e=>{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&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),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))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).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))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).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-D9KrCrVq.js";import{import_websocket as r}from"./wrapper-B0SBsJWP.js";import{findNearestEntry as i,migrateBlinkToData as a,require_main as o,resolveConfig as s}from"./util-dGFzG4wT.js";import{Client as c,loginIfNeeded as l,require_source as u}from"./auth-DeHFQhPJ.js";import{Y as d,pD as f,ve as p,ye as m}from"./dist-BNbSDxaw.js";import"./open-DCYivxgo.js";import{require_ignore as h}from"./ignore-NA4V6Pjc.js";import{randomUUID as g}from"crypto";import{basename as _,dirname as v,join as y,relative as ee}from"node:path";import{existsSync as te}from"node:fs";import{mkdir as ne,readdir as b,writeFile as re}from"fs/promises";import{readFile as x,stat as S}from"node:fs/promises";var C=e((e=>{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}};e.CommanderError=t,e.InvalidArgumentError=n})),w=e((e=>{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.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}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._collectValue(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+`]`}e.Argument=n,e.humanReadableArgName=r})),T=e((e=>{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&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),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))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).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))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).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)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
4
4
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.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){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),E=e((e=>{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}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}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._collectValue(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;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||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,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?.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?!1: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+(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(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();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=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=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{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||=`-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=>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||={};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(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();t&&e.find(e=>t.is(e))&&(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}e.Command=h,e.useColor=_}));const{program:k,createCommand:ie,createArgument:A,createOption:j,CommanderError:ae,InvalidArgumentError:M,InvalidOptionArgumentError:oe,Command:N,Argument:P,Option:se,Help:F}=n(e((e=>{let{Argument:t}=w(),{Command:n}=O(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;var I=`1.0.6`;async function L(e){e||=process.cwd();let t=s(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 R=n(o(),1),z=n(u(),1),B=n(h(),1);async function V(e,t){e||=process.cwd(),await a(e);let n=await l(),r=new c({authToken:n,fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-blink-cli-version`,I),fetch(e,{...t,headers:n})}}),o=await i(e,`package.json`);if(!o)throw Error(`package.json not found`);let u=await x(o,`utf-8`),h=JSON.parse(u),g=v(o),C=y(g,`data`,`config.json`),w={};if(te(C)){let e=await x(C,`utf-8`);w=JSON.parse(e)}let T;if(w?.organizationId)try{T=(await r.organizations.get(w.organizationId)).name}catch{w.organizationId=void 0}if(!w?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];w.organizationId=t.id,T=t.name}else{let t=await p({message:`Which organization should contain this agent?`,options:e.map(e=>({value:e.id,label:e.name}))});if(f(t))return;w.organizationId=t,T=e.find(e=>e.id===t).name}}if(!w.organizationId)throw Error(`Developer error: No organization ID found.`);let E;if(w?.agentId)try{E=(await r.agents.get(w.agentId)).name}catch{w.agentId=void 0}if(!w?.agentId)try{let e=await r.organizations.agents.get({organization_id:w.organizationId,agent_name:h.name});w.agentId=e.id,E=e.name}catch{let e=await r.agents.create({name:h.name,organization_id:w.organizationId});w.agentId=e.id,E=e.name}if(!w.agentId)throw Error(`Developer error: No agent ID found.`);await ne(v(C),{recursive:!0}),await re(C,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...w},null,2),`utf-8`);let D=s(g),O=await new Promise((e,t)=>{D.build({cwd:g,entry:D.entry,outdir:D.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!O)throw Error(`Failed to build agent`);if(`error`in O)throw Error(O.error.message);let k={},ie=await b(O.outdir);for(let e of ie)k[y(O.outdir,e)]=e;let A=y(e,`README.md`);await H(A)&&(k[A]=`README.md`);let j={},ae=await le(g);for(let e of ae)j[e]=ee(g,e);let M=Object.entries(k),oe=Object.entries(j),N=[...M,...oe],P=N.length,se=0,F=0,L=0,B=Array(P);await ce(N,10,async([e,t],n)=>{let i=(await S(e)).size,a=++se;W(`${z.default.dim(`[${a}/${P}]`)} Uploading ${t} (${U(i)})...`);let o=await x(e),s=await r.files.upload(new File([Buffer.from(o)],t));B[n]={path:t,id:s.id},F+=1,L+=i}),W(`${z.default.dim(`[${F}/${P}]`)} Uploaded files (${U(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();t&&e.find(e=>t.is(e))&&(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}e.Command=h,e.useColor=_}));const{program:k,createCommand:ie,createArgument:A,createOption:j,CommanderError:ae,InvalidArgumentError:M,InvalidOptionArgumentError:oe,Command:N,Argument:P,Option:se,Help:F}=n(e((e=>{let{Argument:t}=w(),{Command:n}=O(),{CommanderError:r,InvalidArgumentError:i}=C(),{Help:a}=T(),{Option:o}=E();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i}))(),1).default;var I=`1.0.8`;async function L(e){e||=process.cwd();let t=s(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 R=n(o(),1),z=n(u(),1),B=n(h(),1);async function V(e,t){e||=process.cwd(),await a(e);let n=await l(),r=new c({authToken:n,fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-blink-cli-version`,I),fetch(e,{...t,headers:n})}}),o=await i(e,`package.json`);if(!o)throw Error(`package.json not found`);let u=await x(o,`utf-8`),h=JSON.parse(u),g=v(o),C=y(g,`data`,`config.json`),w={};if(te(C)){let e=await x(C,`utf-8`);w=JSON.parse(e)}let T;if(w?.organizationId)try{T=(await r.organizations.get(w.organizationId)).name}catch{w.organizationId=void 0}if(!w?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];w.organizationId=t.id,T=t.name}else{let t=await p({message:`Which organization should contain this agent?`,options:e.map(e=>({value:e.id,label:e.name}))});if(f(t))return;w.organizationId=t,T=e.find(e=>e.id===t).name}}if(!w.organizationId)throw Error(`Developer error: No organization ID found.`);let E;if(w?.agentId)try{E=(await r.agents.get(w.agentId)).name}catch{w.agentId=void 0}if(!w?.agentId)try{let e=await r.organizations.agents.get({organization_id:w.organizationId,agent_name:h.name});w.agentId=e.id,E=e.name}catch{let e=await r.agents.create({name:h.name,organization_id:w.organizationId});w.agentId=e.id,E=e.name}if(!w.agentId)throw Error(`Developer error: No agent ID found.`);await ne(v(C),{recursive:!0}),await re(C,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...w},null,2),`utf-8`);let D=s(g),O=await new Promise((e,t)=>{D.build({cwd:g,entry:D.entry,outdir:D.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!O)throw Error(`Failed to build agent`);if(`error`in O)throw Error(O.error.message);let k={},ie=await b(O.outdir);for(let e of ie)k[y(O.outdir,e)]=e;let A=y(e,`README.md`);await H(A)&&(k[A]=`README.md`);let j={},ae=await le(g);for(let e of ae)j[e]=ee(g,e);let M=Object.entries(k),oe=Object.entries(j),N=[...M,...oe],P=N.length,se=0,F=0,L=0,B=Array(P);await ce(N,10,async([e,t],n)=>{let i=(await S(e)).size,a=++se;W(`${z.default.dim(`[${a}/${P}]`)} Uploading ${t} (${U(i)})...`);let o=await x(e),s=await r.files.upload(new File([Buffer.from(o)],t));B[n]={path:t,id:s.id},F+=1,L+=i}),W(`${z.default.dim(`[${F}/${P}]`)} Uploaded files (${U(L)}).`),process.stdout.write(`
21
21
  `);let V=B.filter(Boolean),G=V.slice(0,M.length),ue=V.slice(M.length),K=y(e,`.env.local`),q=[];if(await H(K)){let e=(0,R.parse)(await x(K,`utf-8`));q=Object.keys(e)}let J=[];J=(await r.agents.env.list({agent_id:w.agentId})).map(e=>e.key);let Y=y(e,`.env.production`);if(await H(Y)){let e=(0,R.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:w.agentId,key:e,value:a,target:[`production`,`preview`],secret:!0,upsert:!0});J.push(t.key),i+=1,W(`${z.default.dim(`[${i}/${n}]`)} Updating environment variable: ${e} ${z.default.dim(`(.env.production)`)}`)}W(`${z.default.dim(`[${i}/${n}]`)} Updated environment variables! ${z.default.dim(`(.env.production)`)}`),process.stdout.write(`
22
- `)}let X=q.filter(e=>!J.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 m({message:`Do you want to deploy anyway?`});if(e===!1||f(e))return}let Z=await r.agents.deployments.create({agent_id:w.agentId,target:`production`,entrypoint:_(O.entry),output_files:G,source_files:ue,message:t?.message}),Q=`https://blink.so/${T}/${E}/deployments/${Z.number}`;console.log(`Deployed:`,Q);let $=d();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:w.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);let n=await r.agents.get(w.agentId);n.request_url&&console.log(`\nSend webhooks from anywhere: ${n.request_url}`);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{$.stop(`Failed to poll for deployment status.`),console.log(`Read logs for details:`,Q);return}}const H=async e=>{try{return await S(e),!0}catch{return!1}};async function ce(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 U(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/t**+r;return`${i.toFixed(i>=100?0:i>=10?1:2)}${n[r]}`}function W(e){if(process.stdout.isTTY)try{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(e);return}catch{}console.log(e)}async function le(e){let t=[],n=(0,B.default)().add([`.git`,`node_modules`,`data`,`.env`,`.env.*`]),r=y(e,`.gitignore`);if(await H(r)){let e=await x(r,`utf-8`);n.add(e)}async function i(r,a=e){let o=await b(r,{withFileTypes:!0});for(let e of o){let o=y(r,e.name),s=ee(a,o);n.ignores(s)||(e.isDirectory()?await i(o,a):e.isFile()&&t.push(o))}}return await i(e),t}if(globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.Bun!==void 0){let e=t(`perf_hooks`);e.monitorEventLoopDelay=()=>({enable:()=>{}})}globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>g()),k.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(I).action(()=>{k.outputHelp()});const G=e=>async(...t)=>{let{default:n}=await e();return n(...t)};k.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(G(()=>import(`./init-DFXOMY0k.js`))),k.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(G(()=>import(`./dev-DQh5Ph18.js`))),k.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(V),k.command(`build [directory]`).description(`Build your agent for production.`).action(L),k.command(`telemetry [boolean]`).description(`Enable or disable telemetry.`),k.command(`start [directory]`).description("Starts the Blink runtime in production mode. The agent must be compiled with `blink build` first."),k.command(`run <message...>`).description(`Run your agent programmatically and get the response.`).option(`-d, --directory <directory>`,`Directory to run the agent from (default: current directory)`).option(`-c, --chat <chat>`,`Chat key to use (default: 'default')`).action(G(()=>import(`./run-Dy4EpNVD.js`))),k.command(`connect`,{hidden:!0}).description(`Connect compute to the Blink Cloud.`).action(G(()=>import(`./connect-O43Nkqhm.js`))),k.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(G(()=>import(`./chat-01Fdrhd_.js`))),k.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(G(()=>import(`./login-yMSEGrjU.js`))),k.parse(process.argv);export{};
22
+ `)}let X=q.filter(e=>!J.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 m({message:`Do you want to deploy anyway?`});if(e===!1||f(e))return}let Z=await r.agents.deployments.create({agent_id:w.agentId,target:`production`,entrypoint:_(O.entry),output_files:G,source_files:ue,message:t?.message}),Q=`https://blink.so/${T}/${E}/deployments/${Z.number}`;console.log(`Deployed:`,Q);let $=d();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:w.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);let n=await r.agents.get(w.agentId);n.request_url&&console.log(`\nSend webhooks from anywhere: ${n.request_url}`);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{$.stop(`Failed to poll for deployment status.`),console.log(`Read logs for details:`,Q);return}}const H=async e=>{try{return await S(e),!0}catch{return!1}};async function ce(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 U(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/t**+r;return`${i.toFixed(i>=100?0:i>=10?1:2)}${n[r]}`}function W(e){if(process.stdout.isTTY)try{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(e);return}catch{}console.log(e)}async function le(e){let t=[],n=(0,B.default)().add([`.git`,`node_modules`,`data`,`.env`,`.env.*`]),r=y(e,`.gitignore`);if(await H(r)){let e=await x(r,`utf-8`);n.add(e)}async function i(r,a=e){let o=await b(r,{withFileTypes:!0});for(let e of o){let o=y(r,e.name),s=ee(a,o);n.ignores(s)||(e.isDirectory()?await i(o,a):e.isFile()&&t.push(o))}}return await i(e),t}if(globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.Bun!==void 0){let e=t(`perf_hooks`);e.monitorEventLoopDelay=()=>({enable:()=>{}})}globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>g()),k.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(I).action(()=>{k.outputHelp()});const G=e=>async(...t)=>{let{default:n}=await e();return n(...t)};k.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(G(()=>import(`./init-DAff8BFO.js`))),k.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(G(()=>import(`./dev-BPKpFAM3.js`))),k.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(V),k.command(`build [directory]`).description(`Build your agent for production.`).action(L),k.command(`telemetry [boolean]`).description(`Enable or disable telemetry.`),k.command(`start [directory]`).description("Starts the Blink runtime in production mode. The agent must be compiled with `blink build` first."),k.command(`run <message...>`).description(`Run your agent programmatically and get the response.`).option(`-d, --directory <directory>`,`Directory to run the agent from (default: current directory)`).option(`-c, --chat <chat>`,`Chat key to use (default: 'default')`).action(G(()=>import(`./run-_bDe0KqM.js`))),k.command(`connect`,{hidden:!0}).description(`Connect compute to the Blink Cloud.`).action(G(()=>import(`./connect-O43Nkqhm.js`))),k.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(G(()=>import(`./chat-Jjsxhu91.js`))),k.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(G(()=>import(`./login-OOGg9_8j.js`))),k.parse(process.argv);export{};
@@ -0,0 +1,416 @@
1
+ import{Ie as e,M as t,Se as n,pD as r,ve as i,xe as a,ye as o}from"./dist-BNbSDxaw.js";import{basename as s,join as c}from"path";import{mkdir as l,readdir as u,writeFile as d}from"fs/promises";import{spawn as f}from"child_process";async function p(p){if(p||=process.cwd(),e(`Initializing a new Blink Agent`),(await u(p)).length>0){let e=await o({message:`Directory is not empty. Create agent in ".blink" instead? Blink looks for the nearest ".blink" directory for agents.`});if(r(e)&&(a(`Initialization cancelled.`),process.exit(1)),e)p=c(p,`.blink`),await l(p,{recursive:!0}),t.info(`Creating project in ${p}`);else{let e=await o({message:`Initialize in non-empty directory anyway?`});(e===!1||r(e))&&(a(`Initialization cancelled.`),process.exit(1))}}let h=s(p).replace(/[^a-zA-Z0-9]/g,`-`),g;if(process.env.npm_config_user_agent?.includes(`bun/`)?g=`bun`:process.env.npm_config_user_agent?.includes(`pnpm/`)?g=`pnpm`:process.env.npm_config_user_agent?.includes(`yarn/`)?g=`yarn`:process.env.npm_config_user_agent?.includes(`npm/`)&&(g=`npm`),!g){let e=await i({options:[{label:`Bun`,value:`bun`},{label:`NPM`,value:`npm`},{label:`PNPM`,value:`pnpm`},{label:`Yarn`,value:`yarn`}],message:`What package manager do you want to use?`});r(e)&&process.exit(0),g=e}t.info(`Using ${g} as the package manager.`);let _={"package.json":JSON.stringify({name:h,main:`agent.ts`,type:`module`,private:!0,scripts:{dev:`blink dev`,deploy:`blink deploy`}}),"agent.ts":`import { convertToModelMessages, streamText, tool } from "ai";
2
+ import * as blink from "blink";
3
+ import { z } from "zod";
4
+
5
+ const agent = blink.agent();
6
+
7
+ agent.on("chat", async ({ messages }) => {
8
+ return streamText({
9
+ model: blink.model("anthropic/claude-sonnet-4.5"),
10
+ system: \`You are a basic agent the user will customize.
11
+
12
+ Suggest the user enters edit mode with Ctrl+E or /edit to customize the agent.
13
+ Demonstrate your capabilities with the IP tool.\`,
14
+ messages: convertToModelMessages(messages),
15
+ tools: {
16
+ get_ip_info: tool({
17
+ description: "Get IP address information of the computer.",
18
+ inputSchema: z.object({}),
19
+ execute: async () => {
20
+ const response = await fetch("https://ipinfo.io/json");
21
+ return response.json();
22
+ },
23
+ }),
24
+ },
25
+ });
26
+ });
27
+
28
+ agent.serve();
29
+ `,".gitignore":`# dependencies
30
+ node_modules
31
+
32
+ # config and build
33
+ data
34
+
35
+ # dotenv environment variables file
36
+ .env
37
+ .env.*
38
+
39
+ # Finder (MacOS) folder config
40
+ .DS_Store
41
+ `,".env.local":`
42
+ # Store local environment variables here.
43
+ # They will be used by blink dev for development.
44
+ # EXTERNAL_SERVICE_API_KEY=
45
+ `,".env.production":`
46
+ # Store production environment variables here.
47
+ # They will be upserted as secrets on blink deploy.
48
+ # EXTERNAL_SERVICE_API_KEY=
49
+ `,"AGENTS.md":m,"tsconfig.json":`{
50
+ "compilerOptions": {
51
+ "lib": ["ESNext"],
52
+ "target": "ESNext",
53
+ "module": "Preserve",
54
+ "moduleDetection": "force",
55
+
56
+ "moduleResolution": "bundler",
57
+ "allowImportingTsExtensions": true,
58
+ "verbatimModuleSyntax": true,
59
+ "resolveJsonModule": true,
60
+ "noEmit": true,
61
+
62
+ "strict": true,
63
+ "skipLibCheck": true,
64
+ "noFallthroughCasesInSwitch": true,
65
+ "noUncheckedIndexedAccess": true,
66
+ "noImplicitOverride": true,
67
+
68
+ "noUnusedLocals": false,
69
+ "noUnusedParameters": false,
70
+
71
+ "types": ["node"]
72
+ }
73
+ }`};await Promise.all(Object.entries(_).map(async([e,t])=>{await d(c(p,e),t)})),console.log(``);let v=f(g,[g===`yarn`?`add`:`install`,`--save-dev`,`zod`,`ai`,`blink`,`esbuild`,`@types/node`,`typescript`],{stdio:`inherit`,cwd:p});await new Promise((e,t)=>{v.on(`close`,t=>{t===0&&e(void 0)}),v.on(`error`,e=>{t(e)})}),console.log(``);let y={bun:`bun run dev`,npm:`npm run dev`,pnpm:`pnpm run dev`,yarn:`yarn dev`}[g];t.success(`To get started, run:
74
+
75
+ ${y??`blink dev`}`),n(`Edit agent.ts to hot-reload your agent.`)}const m=`This project is a Blink agent.
76
+
77
+ You are an expert software engineer, which makes you an expert agent developer. You are highly idiomatic, opinionated, concise, and precise. The user prefers accuracy over speed.
78
+
79
+ <communication>
80
+ 1. Be concise, direct, and to the point.
81
+ 2. You are communicating via a terminal interface, so avoid verbosity, preambles, postambles, and unnecessary whitespace.
82
+ 3. NEVER use emojis unless the user explicitly asks for them.
83
+ 4. You must avoid text before/after your response, such as "The answer is" or "Short answer:", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...".
84
+ 5. Mimic the style of the user's messages.
85
+ 6. Do not remind the user you are happy to help.
86
+ 7. Do not act with sycophantic flattery or over-the-top enthusiasm.
87
+ 8. Do not regurgitate tool output. e.g. if a command succeeds, acknowledge briefly (e.g. "Done" or "Formatted").
88
+ 9. *NEVER* create markdown files for the user - *always* guide the user through your efforts.
89
+ 10. *NEVER* create example scripts for the user, or examples scripts for you to run. Leverage your tools to accomplish the user's goals.
90
+ </communication>
91
+
92
+ <goals>
93
+ Your method of assisting the user is by iterating their agent using the context provided by the user in run mode.
94
+
95
+ You can obtain additional context by leveraging web search and compute tools to read files, run commands, and search the web.
96
+
97
+ The user is *extremely happy* to provide additional context. They prefer this over you guessing, and then potentially getting it wrong.
98
+
99
+ <example>
100
+ user: i want a coding agent
101
+ assistant: Let me take a look at your codebase...
102
+ ... tool calls to investigate the codebase...
103
+ assistant: I've created tools for linting, testing, and formatting. Hop back in run mode to use your agent! If you ever encounter undesired behavior from your agent, switch back to edit mode to refine your agent.
104
+ </example>
105
+
106
+ Always investigate the current state of the agent before assisting the user.
107
+ </goals>
108
+
109
+ <agent_development>
110
+ Agents are written in TypeScript, and mostly stored in a single \`agent.ts\` file. Complex agents will have multiple files, like a proper codebase.
111
+
112
+ Environment variables are stored in \`.env.local\` and \`.env.production\`. \`blink dev\` will hot-reload environment variable changes in \`.env.local\`.
113
+
114
+ Changes to the agent are hot-reloaded. As you make edits, the user can immediately try them in run mode.
115
+
116
+ 1. *ALWAYS* use the package manager the user is using (inferred from lock files or \`process.argv\`).
117
+ 2. You *MUST* use \`agent.store\` to persist state. The agent process is designed to be stateless.
118
+ 3. Test your changes to the user's agent by using the \`message_user_agent\` tool. This is a much better experience for the user than directing them to switch to run mode during iteration.
119
+ 4. Use console.log for debugging. The console output appears for the user.
120
+ 5. Blink uses the Vercel AI SDK v5 in many samples, remember that v5 uses \`inputSchema\` instead of \`parameters\` (which was in v4).
121
+ 6. Output tokens can be increased using the \`maxOutputTokens\` option on \`streamText\` (or other AI SDK functions). This may need to be increased if users are troubleshooting larger tool calls failing early.
122
+ 7. Use the TypeScript language service tools (\`typescript_completions\`, \`typescript_quickinfo\`, \`typescript_definition\`, \`typescript_diagnostics\`) to understand APIs, discover available methods, check types, and debug errors. These tools use tsserver to provide IDE-like intelligence.
123
+
124
+ If the user is asking for a behavioral change, you should update the agent's system prompt.
125
+ This will not ensure the behavior, but it will guide the agent towards the desired behavior.
126
+ If the user needs 100% behavioral certainty, adjust tool behavior instead.
127
+ </agent_development>
128
+
129
+ <agent_web_requests>
130
+ Agents are HTTP servers, so they can handle web requests. This is commonly used to async-invoke an agent. e.g. for a Slack bot, messages are sent to the agent via a webhook.
131
+
132
+ Blink automatically creates a reverse-tunnel to your local machine for simple local development with external services (think Slack Bot, GitHub Bot, etc.).
133
+
134
+ To trigger chats based on web requests, use the \`agent.chat.upsert\` and \`agent.chat.message\` APIs.
135
+ </agent_web_requests>
136
+
137
+ <technical_knowledge>
138
+ Blink agents are Node.js HTTP servers built on the Vercel AI SDK:
139
+
140
+ \`\`\`typescript
141
+ import { convertToModelMessages, streamText } from "ai";
142
+ import * as blink from "blink";
143
+
144
+ const agent = new blink.Agent();
145
+
146
+ agent.on("chat", async ({ messages, chat, abortSignal }) => {
147
+ return streamText({
148
+ model: blink.model("anthropic/claude-sonnet-4.5"),
149
+ system: "You are a helpful assistant.",
150
+ messages: convertToModelMessages(messages, {
151
+ ignoreIncompleteToolCalls: true,
152
+ }),
153
+ tools: { /* your tools */ },
154
+ });
155
+ });
156
+
157
+ agent.on("request", async (request) => {
158
+ // Handle webhooks, OAuth callbacks, etc.
159
+ });
160
+
161
+ agent.serve();
162
+ \`\`\`
163
+
164
+ Event Handlers:
165
+
166
+ **\`agent.on("chat", handler)\`**
167
+ 1. Triggered when a chat needs AI processing - invoked in a loop when the last model message is a tool call.
168
+ 2. Must return: \`streamText()\` result, \`Response\`, \`ReadableStream<UIMessageChunk>\`, or \`void\`
169
+ 3. Parameters: \`messages\`, \`id\`, \`abortSignal\`
170
+
171
+ *NEVER* use "maxSteps" from the Vercel AI SDK. It is unnecessary and will cause a worse experience for the user.
172
+
173
+ **\`agent.on("request", handler)\`**
174
+ • Handles raw HTTP requests before Blink processes them
175
+ • Use for: OAuth callbacks, webhook verification, custom endpoints
176
+ • Return \`Response\` to handle, or \`void\` to pass through
177
+
178
+ **\`agent.on("ui", handler)\`**
179
+ • Provides dynamic UI options for chat interfaces
180
+ • Returns schema defining user-selectable options
181
+
182
+ **\`agent.on("error", handler)\`**
183
+ • Global error handler for the agent
184
+
185
+ Chat Management:
186
+
187
+ Blink automatically manages chat state:
188
+
189
+ \`\`\`typescript
190
+ // Create or get existing chat
191
+ // The parameter can be any JSON-serializable value.
192
+ // e.g. for a Slack bot to preserve context in a thread, you might use: ["slack", teamId, channelId, threadTs]
193
+ const chat = await agent.chat.upsert("unique-key");
194
+
195
+ // Send a message to a chat
196
+ await agent.chat.sendMessages(chat.id, [{
197
+ role: "user",
198
+ parts: [{ type: "text", text: "Message" }],
199
+ }], {
200
+ behavior: "interrupt" | "enqueue" | "append"
201
+ });
202
+
203
+ // When sending messages, feel free to inject additional parts to direct the model.
204
+ // e.g. if the user is asking for specific behavior in specific scenarios, the simplest
205
+ // answer is to append a text part: "always do X when Y".
206
+ \`\`\`
207
+
208
+ Behaviors:
209
+ • "interrupt": Stop current processing and handle immediately
210
+ • "enqueue": Queue message, process when current chat finishes
211
+ • "append": Add to history without triggering processing
212
+
213
+ Chat keys: Use structured keys like \`"slack-\${teamId}-\${channelId}-\${threadTs}"\` for uniqueness.
214
+
215
+ Storage API:
216
+
217
+ Persistent key-value storage per agent:
218
+
219
+ \`\`\`typescript
220
+ // Store data
221
+ await agent.store.set("key", "value", { ttl: 3600 });
222
+
223
+ // Retrieve data
224
+ const value = await agent.store.get("key");
225
+
226
+ // Delete data
227
+ await agent.store.delete("key");
228
+
229
+ // List keys by prefix
230
+ const result = await agent.store.list("prefix-", { limit: 100 });
231
+ \`\`\`
232
+
233
+ Common uses: OAuth tokens, user preferences, caching, chat-resource associations.
234
+
235
+ Tools:
236
+
237
+ Tools follow Vercel AI SDK patterns with Zod validation:
238
+
239
+ \`\`\`typescript
240
+ import { tool } from "ai";
241
+ import { z } from "zod";
242
+
243
+ const myTool = tool({
244
+ description: "Clear description of what this tool does",
245
+ inputSchema: z.object({
246
+ param: z.string().describe("Parameter description"),
247
+ }),
248
+ execute: async (args, opts) => {
249
+ // opts.abortSignal for cancellation
250
+ // opts.toolCallId for unique identification
251
+ return result;
252
+ },
253
+ });
254
+ \`\`\`
255
+
256
+ Tool Approvals for destructive operations:
257
+
258
+ \`\`\`typescript
259
+ ...await blink.tools.withApproval({
260
+ messages,
261
+ tools: {
262
+ delete_database: tool({ /* ... */ }),
263
+ },
264
+ })
265
+ \`\`\`
266
+
267
+ Tool Context for dependency injection:
268
+
269
+ \`\`\`typescript
270
+ ...blink.tools.withContext(github.tools, {
271
+ accessToken: process.env.GITHUB_TOKEN,
272
+ })
273
+ \`\`\`
274
+
275
+ Tool Prefixing to avoid collisions:
276
+
277
+ \`\`\`typescript
278
+ ...blink.tools.prefix(github.tools, "github_")
279
+ \`\`\`
280
+
281
+ LLM Models:
282
+
283
+ **Option 1: Blink Gateway** (Quick Start)
284
+ \`\`\`typescript
285
+ model: blink.model("anthropic/claude-sonnet-4.5")
286
+ model: blink.model("openai/gpt-5")
287
+ \`\`\`
288
+ Requires: \`blink login\` or \`BLINK_TOKEN\` env var
289
+
290
+ **Option 2: Direct Provider** (Production Recommended)
291
+ \`\`\`typescript
292
+ import { anthropic } from "@ai-sdk/anthropic";
293
+ import { openai } from "@ai-sdk/openai";
294
+
295
+ model: anthropic("claude-sonnet-4.5", { apiKey: process.env.ANTHROPIC_API_KEY })
296
+ model: openai("gpt-5", { apiKey: process.env.OPENAI_API_KEY })
297
+ \`\`\`
298
+
299
+ **Note about Edit Mode:** Edit mode (this agent) automatically selects models in this priority:
300
+ 1. If \`ANTHROPIC_API_KEY\` is set: uses \`claude-sonnet-4.5\` via \`@ai-sdk/anthropic\`
301
+ 2. If \`OPENAI_API_KEY\` is set: uses \`gpt-5\` via \`@ai-sdk/openai\`
302
+ 3. Otherwise: falls back to \`blink.model("anthropic/claude-sonnet-4.5")\`
303
+
304
+ Available SDKs:
305
+
306
+ **@blink-sdk/compute**
307
+ \`\`\`typescript
308
+ import * as compute from "@blink-sdk/compute";
309
+
310
+ tools: {
311
+ ...compute.tools, // execute_bash, read_file, write_file, edit_file, process management
312
+ }
313
+ \`\`\`
314
+
315
+ **@blink-sdk/github**
316
+ \`\`\`typescript
317
+ import * as github from "@blink-sdk/github";
318
+
319
+ tools: {
320
+ ...blink.tools.withContext(github.tools, {
321
+ accessToken: process.env.GITHUB_TOKEN,
322
+ }),
323
+ }
324
+ \`\`\`
325
+
326
+ **@blink-sdk/slack**
327
+ \`\`\`typescript
328
+ import * as slack from "@blink-sdk/slack";
329
+ import { App } from "@slack/bolt";
330
+
331
+ const receiver = new slack.Receiver();
332
+ const app = new App({
333
+ token: process.env.SLACK_BOT_TOKEN,
334
+ signingSecret: process.env.SLACK_SIGNING_SECRET,
335
+ receiver,
336
+ })
337
+
338
+ // This will trigger when the bot is @mentioned.
339
+ app.event("app_mention", async ({ event }) => {
340
+ // The argument here is a JSON-serializable value.
341
+ // To maintain the same chat context, use the same key.
342
+ const chat = await agent.chat.upsert([
343
+ "slack",
344
+ event.team,
345
+ event.channel,
346
+ event.thread_ts ?? event.ts,
347
+ ]);
348
+ const message = await slack.createMessageFromEvent({
349
+ client: app.client,
350
+ event,
351
+ });
352
+ await agent.chat.sendMessages(chat.id, [message]);
353
+ // This is a nice immediate indicator for the user.
354
+ await app.client.assistant.threads.setStatus({
355
+ channel_id: event.channel,
356
+ status: "is typing...",
357
+ thread_ts: event.thread_ts ?? event.ts,
358
+ })
359
+ })
360
+
361
+ const agent = new blink.Agent();
362
+
363
+ agent.on("request", async (request) => {
364
+ return receiver.handle(app, request);
365
+ });
366
+
367
+ agent.on("chat", async ({ messages }) => {
368
+ const tools = slack.createTools({ client: app.client });
369
+ return streamText({
370
+ model: blink.model("anthropic/claude-sonnet-4.5"),
371
+ system: "You chatting with users in Slack.",
372
+ messages: convertToModelMessages(messages, {
373
+ ignoreIncompleteToolCalls: true,
374
+ tools,
375
+ }),
376
+ });
377
+ })
378
+ \`\`\`
379
+
380
+ Slack SDK Notes:
381
+ - "app_mention" event is triggered in both private channels and public channels.
382
+ - "message" event is triggered regardless of being mentioned or not, and will *also* be fired when "app_mention" is triggered.
383
+ - *NEVER* register app event listeners in the "on" handler of the agent. This will cause the handler to be called multiple times.
384
+ - Think about how you scope chats - for example, in IMs or if the user wants to make a bot for a whole channel, you would not want to add "ts" or "thread_ts" to the chat key.
385
+ - When using "assistant.threads.setStatus", you need to ensure the status of that same "thread_ts" is cleared. You can do this by inserting a message part that directs the agent to clear the status (there is a tool if using @blink-sdk/slack called "reportStatus" that does this). e.g. \`message.parts.push({ type: "text", text: "Clear the status of this thread after you finish: channel=\${channel} thread_ts=\${thread_ts}" })\`
386
+ - The Slack SDK has many functions that allow users to completely customize the message format. If the user asks for customization, look at the types for @blink-sdk/slack - specifically: "createPartsFromMessageMetadata", "createMessageFromEvent", and "extractMessagesMetadata".
387
+
388
+ WARNING: Beware of attaching multiple event listeners to the same chat. This could cause the agent to respond multiple times.
389
+
390
+ **@blink-sdk/web-search**
391
+ \`\`\`typescript
392
+ import * as webSearch from "@blink-sdk/web-search";
393
+
394
+ tools: {
395
+ ...webSearch.tools,
396
+ }
397
+ \`\`\`
398
+
399
+ State Management:
400
+
401
+ Blink agents are short-lived HTTP servers that restart on code changes and do not persist in-memory state between requests.
402
+
403
+ *NEVER* use module-level Maps, Sets, or variables to store state (e.g. \`const activeBots = new Map()\`).
404
+
405
+ Instead:
406
+ - Use \`agent.store\` for persistent key-value storage
407
+ - Query external APIs to fetch current state
408
+ - Use webhooks to trigger actions rather than polling in-memory state
409
+
410
+ The agent process can restart at any time, so all important state must be externalized.
411
+ </technical_knowledge>
412
+
413
+ <code_quality>
414
+ - Never use "as any" type assertions. Always figure out the correct typings.
415
+ </code_quality>
416
+ `;export{m as agentsMD,p as init};
@@ -0,0 +1 @@
1
+ import"./dist-BNbSDxaw.js";import{agentsMD as e,init as t}from"./init-C45jjEXu.js";export{e as agentsMD,t as default};
@@ -0,0 +1 @@
1
+ import{login as e}from"./auth-DeHFQhPJ.js";import"./dist-BNbSDxaw.js";import"./open-DCYivxgo.js";async function t(){await e()}export{t as default};
@@ -1 +1 @@
1
- import{__toESM as e}from"./chunk-D9KrCrVq.js";import{findNearestEntry as t,migrateBlinkToData as n,require_main as r,resolveConfig as i}from"./util-CkrO2lHF.js";import{getAuthToken as a}from"./auth-CpUNsA0k.js";import"./dist-wyfWuz5A.js";import"./open-S_jcQ0nw.js";import{ChatManager as o,Client as s}from"./chat-manager-DWh8MCAU.js";import{spawn as c}from"node:child_process";import{join as l,resolve as u}from"node:path";import{existsSync as d}from"node:fs";import{readFile as f}from"node:fs/promises";import{createServer as p}from"node:net";async function m(e){let t=e.env?.PORT??await h(),n=e.env?.HOST??`127.0.0.1`,r=`http://${n}:${t}`,i={...e.env??process.env,PORT:t.toString(),HOST:n},a=c(e.command,e.args,{stdio:`pipe`,env:i});e.signal?.addEventListener(`abort`,()=>{try{a.kill()}catch{}},{once:!0});let o=new AbortController,l=[o.signal];e.signal&&l.push(e.signal);let u=AbortSignal.any(l);a.stdout.on(`data`,t=>{e.onStdout?.(Buffer.from(t).toString(`utf-8`))});let d=``;a.stderr.on(`data`,t=>{o.signal.aborted||(d+=Buffer.from(t).toString(`utf-8`)),e.onStderr?.(Buffer.from(t).toString(`utf-8`))}),a.on(`error`,e=>{o.abort(e)}),a.on(`exit`,(t,n)=>{o.signal.aborted?e.onExit?.(t,n):o.abort()});let f=new s({baseUrl:r}),p=0;for(;!u.aborted;){try{await f.health();break}catch{}if(await new Promise(e=>setTimeout(e,p*5)),p++,p>100)throw Error(`Health endpoint timed out`)}if(u.aborted)throw u.reason;return o.abort(),{client:f,dispose:()=>{a.kill()}}}async function h(){let e=p();return new Promise((t,n)=>{e.listen(0,()=>{let n=e.address().port;t(n)}).on(`error`,e=>{n(e)})}).finally(()=>{e.close()})}var g=e(r(),1);async function _(e,r={}){if(!r.directory){let e=process.cwd();try{i(e),r.directory=e}catch{let n=await t(e,`.blink`);n&&d(l(n,`build`))&&(n=void 0),n?r.directory=n:r.directory=e}}await n(r.directory);let s=i(r.directory),c={};try{c=(0,g.parse)(await f(l(r.directory,`.env.local`),`utf-8`))}catch{}let p=await a(),h=await m({command:`node`,args:[`--experimental-strip-types`,`--no-deprecation`,s.entry],env:{...process.env,...c,BLINK_TOKEN:p}});console.log(`Agent spawned`);let _=u(r?.directory??process.cwd(),`data`,`chats`),v=new o({chatId:r?.chat,chatsDirectory:_});v.setAgent(h.client);try{let t=new Promise(e=>{let t=v.subscribe(n=>{(n.status===`idle`||n.status===`error`)&&(t(),e())})});await v.sendMessages([{id:crypto.randomUUID(),created_at:new Date().toISOString(),metadata:void 0,parts:[{type:`text`,text:e.join(` `)}],role:`user`,mode:`run`}]),await t;let n=v.getState();n.error&&console.error(`Error:`,n.error),console.log(`Final state:`,n.messages.pop())}finally{v.dispose(),h.dispose()}}export{_ as default};
1
+ import{__toESM as e}from"./chunk-D9KrCrVq.js";import{findNearestEntry as t,migrateBlinkToData as n,require_main as r,resolveConfig as i}from"./util-dGFzG4wT.js";import{getAuthToken as a}from"./auth-DeHFQhPJ.js";import"./dist-BNbSDxaw.js";import"./open-DCYivxgo.js";import{ChatManager as o,Client as s}from"./chat-manager-DWh8MCAU.js";import{spawn as c}from"node:child_process";import{join as l,resolve as u}from"node:path";import{existsSync as d}from"node:fs";import{readFile as f}from"node:fs/promises";import{createServer as p}from"node:net";async function m(e){let t=e.env?.PORT??await h(),n=e.env?.HOST??`127.0.0.1`,r=`http://${n}:${t}`,i={...e.env??process.env,PORT:t.toString(),HOST:n},a=c(e.command,e.args,{stdio:`pipe`,env:i});e.signal?.addEventListener(`abort`,()=>{try{a.kill()}catch{}},{once:!0});let o=new AbortController,l=[o.signal];e.signal&&l.push(e.signal);let u=AbortSignal.any(l);a.stdout.on(`data`,t=>{e.onStdout?.(Buffer.from(t).toString(`utf-8`))});let d=``;a.stderr.on(`data`,t=>{o.signal.aborted||(d+=Buffer.from(t).toString(`utf-8`)),e.onStderr?.(Buffer.from(t).toString(`utf-8`))}),a.on(`error`,e=>{o.abort(e)}),a.on(`exit`,(t,n)=>{o.signal.aborted?e.onExit?.(t,n):o.abort()});let f=new s({baseUrl:r}),p=0;for(;!u.aborted;){try{await f.health();break}catch{}if(await new Promise(e=>setTimeout(e,p*5)),p++,p>100)throw Error(`Health endpoint timed out`)}if(u.aborted)throw u.reason;return o.abort(),{client:f,dispose:()=>{a.kill()}}}async function h(){let e=p();return new Promise((t,n)=>{e.listen(0,()=>{let n=e.address().port;t(n)}).on(`error`,e=>{n(e)})}).finally(()=>{e.close()})}var g=e(r(),1);async function _(e,r={}){if(!r.directory){let e=process.cwd();try{i(e),r.directory=e}catch{let n=await t(e,`.blink`);n&&d(l(n,`build`))&&(n=void 0),n?r.directory=n:r.directory=e}}await n(r.directory);let s=i(r.directory),c={};try{c=(0,g.parse)(await f(l(r.directory,`.env.local`),`utf-8`))}catch{}let p=await a(),h=await m({command:`node`,args:[`--experimental-strip-types`,`--no-deprecation`,s.entry],env:{...process.env,...c,BLINK_TOKEN:p}});console.log(`Agent spawned`);let _=u(r?.directory??process.cwd(),`data`,`chats`),v=new o({chatId:r?.chat,chatsDirectory:_});v.setAgent(h.client);try{let t=new Promise(e=>{let t=v.subscribe(n=>{(n.status===`idle`||n.status===`error`)&&(t(),e())})});await v.sendMessages([{id:crypto.randomUUID(),created_at:new Date().toISOString(),metadata:void 0,parts:[{type:`text`,text:e.join(` `)}],role:`user`,mode:`run`}]),await t;let n=v.getState();n.error&&console.error(`Error:`,n.error),console.log(`Final state:`,n.messages.pop())}finally{v.dispose(),h.dispose()}}export{_ as default};
@@ -1,4 +1,4 @@
1
- import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-D9KrCrVq.js";import{require_source as r}from"./auth-CpUNsA0k.js";import i,{dirname as a,join as o}from"path";import{existsSync as s,readFileSync as c,readdirSync as l,writeFileSync as u}from"fs";import{builtinModules as d}from"module";import{mkdir as f,rename as p,rm as m,stat as h,writeFile as g}from"fs/promises";const _=`ai-telemetry-wrapper`;function v(e={}){let{functions:t=[`streamText`,`generateText`,`generateObject`,`streamObject`,`embed`,`embedMany`],telemetryConfig:n={isEnabled:!0}}=e;return{name:`ai-telemetry`,setup(e){e.onResolve({filter:/^ai$/},e=>{if(e.namespace!==_)return{path:`ai`,namespace:_,pluginData:{resolveDir:e.resolveDir}}}),e.onLoad({filter:/^ai$/,namespace:_},e=>{let r=JSON.stringify(n),i=e.pluginData;return{contents:`
1
+ import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-D9KrCrVq.js";import{require_source as r}from"./auth-DeHFQhPJ.js";import i,{dirname as a,join as o}from"path";import{existsSync as s,readFileSync as c,readdirSync as l,writeFileSync as u}from"fs";import{builtinModules as d}from"module";import{mkdir as f,rename as p,rm as m,stat as h,writeFile as g}from"fs/promises";const _=`ai-telemetry-wrapper`;function v(e={}){let{functions:t=[`streamText`,`generateText`,`generateObject`,`streamObject`,`embed`,`embedMany`],telemetryConfig:n={isEnabled:!0}}=e;return{name:`ai-telemetry`,setup(e){e.onResolve({filter:/^ai$/},e=>{if(e.namespace!==_)return{path:`ai`,namespace:_,pluginData:{resolveDir:e.resolveDir}}}),e.onLoad({filter:/^ai$/,namespace:_},e=>{let r=JSON.stringify(n),i=e.pluginData;return{contents:`
2
2
  // Import everything from the original 'ai' package
3
3
  import * as aiOriginal from 'ai';
4
4
 
@@ -1 +1 @@
1
- const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../index.node-C6sId3jT.cjs`);require(`../token-error-BoNG8ooW.cjs`),require(`../esm-0UNjvroT.cjs`),exports.Agent=t.Agent,exports.StreamResponseFormatHeader=t.StreamResponseFormatHeader,exports.agent=t.agent,exports.api=t.api,exports.isToolApprovalOutput=t.isToolApprovalOutput,exports.lastUIOptions=t.lastUIOptions,exports.model=t.model,exports.toolWithApproval=t.toolWithApproval,exports.tools=t.tools,exports.waitUntil=t.waitUntil,exports.withResponseFormat=t.withResponseFormat;
1
+ const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../index.node-DN4zHlM1.cjs`);require(`../token-error-l6zIbPbZ.cjs`),require(`../esm-C-vSI1Ww.cjs`),exports.Agent=t.Agent,exports.StreamResponseFormatHeader=t.StreamResponseFormatHeader,exports.agent=t.agent,exports.api=t.api,exports.isToolApprovalOutput=t.isToolApprovalOutput,exports.lastUIOptions=t.lastUIOptions,exports.model=t.model,exports.toolWithApproval=t.toolWithApproval,exports.tools=t.tools,exports.waitUntil=t.waitUntil,exports.withResponseFormat=t.withResponseFormat;
@@ -1 +1 @@
1
- import{Agent as e,StreamResponseFormatHeader as t,agent as n,api as r,isToolApprovalOutput as i,lastUIOptions as a,model as o,toolWithApproval as s,tools as c,waitUntil as l,withResponseFormat as u}from"../index.node-BdbWMIX0.js";import"../token-error-488npYdU.js";import"../esm-CbZfjZBn.js";export{e as Agent,t as StreamResponseFormatHeader,n as agent,r as api,i as isToolApprovalOutput,a as lastUIOptions,o as model,s as toolWithApproval,c as tools,l as waitUntil,u as withResponseFormat};
1
+ import{Agent as e,StreamResponseFormatHeader as t,agent as n,api as r,isToolApprovalOutput as i,lastUIOptions as a,model as o,toolWithApproval as s,tools as c,waitUntil as l,withResponseFormat as u}from"../index.node-wsvVRWwb.js";import"../token-error-wsvzy87W.js";import"../esm-D1GEQyaY.js";export{e as Agent,t as StreamResponseFormatHeader,n as agent,r as api,i as isToolApprovalOutput,a as lastUIOptions,o as model,s as toolWithApproval,c as tools,l as waitUntil,u as withResponseFormat};
@@ -1 +1 @@
1
- const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../build-BzoNpizh.cjs`);exports.buildWithEsbuild=t.buildWithEsbuild,exports.defineConfig=t.defineConfig,exports.resolveConfig=t.resolveConfig,exports.setEsbuildInstance=t.setEsbuildInstance;
1
+ const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../build-lx6plR19.cjs`);exports.buildWithEsbuild=t.buildWithEsbuild,exports.defineConfig=t.defineConfig,exports.resolveConfig=t.resolveConfig,exports.setEsbuildInstance=t.setEsbuildInstance;
@@ -1 +1 @@
1
- import{buildWithEsbuild as e,defineConfig as t,resolveConfig as n,setEsbuildInstance as r}from"../build-D_L0gFGa.js";export{e as buildWithEsbuild,t as defineConfig,n as resolveConfig,r as setEsbuildInstance};
1
+ import{buildWithEsbuild as e,defineConfig as t,resolveConfig as n,setEsbuildInstance as r}from"../build-M5Q2ZTGh.js";export{e as buildWithEsbuild,t as defineConfig,n as resolveConfig,r as setEsbuildInstance};
@@ -1,4 +1,4 @@
1
- import{__require as e}from"./chunk-D9KrCrVq.js";import t from"path";import{builtinModules as n}from"module";import{existsSync as r}from"fs";import{mkdir as i,rm as a,writeFile as o}from"fs/promises";const s=`ai-telemetry-wrapper`;function c(e={}){let{functions:t=[`streamText`,`generateText`,`generateObject`,`streamObject`,`embed`,`embedMany`],telemetryConfig:n={isEnabled:!0}}=e;return{name:`ai-telemetry`,setup(e){e.onResolve({filter:/^ai$/},e=>{if(e.namespace!==s)return{path:`ai`,namespace:s,pluginData:{resolveDir:e.resolveDir}}}),e.onLoad({filter:/^ai$/,namespace:s},e=>{let r=JSON.stringify(n),i=e.pluginData;return{contents:`
1
+ import{__require as e}from"./chunk-D9KrCrVq.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";const s=`ai-telemetry-wrapper`;function c(e={}){let{functions:t=[`streamText`,`generateText`,`generateObject`,`streamObject`,`embed`,`embedMany`],telemetryConfig:n={isEnabled:!0}}=e;return{name:`ai-telemetry`,setup(e){e.onResolve({filter:/^ai$/},e=>{if(e.namespace!==s)return{path:`ai`,namespace:s,pluginData:{resolveDir:e.resolveDir}}}),e.onLoad({filter:/^ai$/,namespace:s},e=>{let r=JSON.stringify(n),i=e.pluginData;return{contents:`
2
2
  // Import everything from the original 'ai' package
3
3
  import * as aiOriginal from 'ai';
4
4
 
@@ -19,10 +19,10 @@ export function ${e}(options) {
19
19
  return aiOriginal.${e}(options);
20
20
  }
21
21
  `).join(``)}
22
- `,loader:`js`,resolveDir:i?.resolveDir}})}}}let l;function u(e){l=e}function d(e){return async r=>{let s=await(l??await import(`esbuild`)).context({entryPoints:[r.entry],outdir:r.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`),r=new Map,i=RegExp(`\\b__require\\("(node:)?(${n.join(`|`)})(/[^"]+)?"\\)`,`gm`);t=t.replace(i,(e,t,n,i=``)=>{let a=n+i,o=`__import_${a.toUpperCase().replace(/[/-]/g,`_`)}`,s=`node:${a}`;return r.set(o,s),o}),r.size>0&&(t=Array.from(r.entries()).map(([e,t])=>`import ${e} from "${t}";`).join(`
22
+ `,loader:`js`,resolveDir:i?.resolveDir}})}}}let l;function u(e){l=e}function d(e){return async n=>{let s=await(l??await import(`esbuild`)).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\\("(node:)?(${r.join(`|`)})(/[^"]+)?"\\)`,`gm`);t=t.replace(i,(e,t,r,i=``)=>{let a=r+i,o=`__import_${a.toUpperCase().replace(/[/-]/g,`_`)}`,s=`node:${a}`;return n.set(o,s),o}),n.size>0&&(t=Array.from(n.entries()).map(([e,t])=>`import ${e} from "${t}";`).join(`
23
23
  `)+`
24
24
 
25
- `+t),e.contents=Buffer.from(t,`utf-8`)}})})}},{name:`blink-dev-server`,setup(e){let n;e.onStart(()=>{r.onStart(),n=performance.now()}),e.onEnd(async e=>{await a(r.outdir,{recursive:!0,force:!0}),await i(r.outdir,{recursive:!0});let c=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];c.push({path:t.resolve(r.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of c)await o(e.path,e.contents);e.errors.length>0?r.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
26
- `)}}):r.onResult({entry:t.resolve(r.outdir,t.basename(r.entry).replace(`.ts`,`.js`)),duration:performance.now()-n,outdir:r.outdir,warnings:e.warnings.map(e=>({message:e.text,file:e.location?.file}))}),r.watch||(s.dispose(),s.cancel())})}},c()],...e});await s.watch()}}function f(e){return e??{}}function p(n){let i=[`blink.config.ts`],a;for(let o of i){let i=t.resolve(n,o);if(r(i)){let t=e(i);if(t.default){a={...t.default};break}}}if(a||={},!a.entry){for(let e of[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`]){let i=t.resolve(n,e);if(r(i)){a.entry=i;break}}if(!a.entry)throw Error(`Agent entrypoint not found.
25
+ `+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 c=e.outputFiles?.map(e=>({path:e.path,contents:e.contents}))??[];c.push({path:t.resolve(n.outdir,`package.json`),contents:Buffer.from(JSON.stringify({type:`module`},null,2),`utf-8`)});for(let e of c)await o(e.path,e.contents);e.errors.length>0?n.onResult({error:{message:e.errors.map(e=>`${e.text} (${e.location?.file})`).join(`
26
+ `)}}):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())})}},c()],...e});await s.watch()}}function f(e){return e??{}}function p(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){for(let e of[`src/agent.ts`,`src/agent.js`,`agent.ts`,`agent.js`]){let i=t.resolve(r,e);if(n(i)){a.entry=i;break}}if(!a.entry)throw Error(`Agent entrypoint not found.
27
27
 
28
- Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return a.outdir||=t.resolve(n,`data/build`),a.build||=d(),a}export{d as buildWithEsbuild,f as defineConfig,p as resolveConfig,u as setEsbuildInstance};
28
+ Try creating "agent.ts" or specify "entry" in a blink.config.ts file.`)}return a.outdir||=t.resolve(r,`data/build`),a.build||=d(),a}export{d as buildWithEsbuild,f as defineConfig,p as resolveConfig,u as setEsbuildInstance};