blink 0.1.78 → 0.1.79

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
@@ -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:M,createArgument:N,createOption:re,CommanderError:P,InvalidArgumentError:ie,InvalidOptionArgumentError:F,Command:I,Argument:ae,Option:L,Help:R}=A.default;var z=`0.1.78`;async function B(e){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 V=n(o(),1),H=n(a(),1);async function U(e,t){e||(e=process.cwd());let n=await u(),r=new c({authToken:n,fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-blink-cli-version`,z),fetch(e,{...t,headers:n})}}),a=await i(e,`package.json`);if(!a)throw Error(`package.json not found`);let o=await x(a,`utf-8`),h=JSON.parse(o),C=_(a),w=v(C,`.blink`,`config.json`),T={};if(ee(w)){let e=await x(w,`utf-8`);T=JSON.parse(e)}let E;if(T?.organizationId)try{let e=await r.organizations.get(T.organizationId);E=e.name}catch(e){T.organizationId=void 0}if(!T?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];T.organizationId=t.id,E=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(d(t))return;T.organizationId=t,E=e.find(e=>e.id===t).name}}if(!T.organizationId)throw Error(`Developer error: No organization ID found.`);let D;if(T?.agentId)try{let e=await r.agents.get(T.agentId);D=e.name}catch(e){T.agentId=void 0}if(!T?.agentId)try{let e=await r.organizations.agents.get({organization_id:T.organizationId,agent_name:h.name});T.agentId=e.id,D=e.name}catch(e){let t=await r.agents.create({name:h.name,organization_id:T.organizationId});T.agentId=t.id,D=t.name}if(!T.agentId)throw Error(`Developer error: No agent ID found.`);await te(_(w),{recursive:!0}),await ne(w,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...T},null,2),`utf-8`);let O=s(C),k=await new Promise((e,t)=>{O.build({cwd:C,entry:O.entry,outdir:O.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!k)throw Error(`Failed to build agent`);if(`error`in k)throw Error(k.error.message);let A={},j=await b(k.outdir);for(let e of j)A[v(k.outdir,e)]=e;let M=v(e,`README.md`);await W(M)&&(A[M]=`README.md`);let N={},re=await se(C);for(let e of re){let t=y(C,e);N[e]=t}let P=Object.entries(A),ie=Object.entries(N),F=[...P,...ie],I=F.length,ae=0,L=0,R=0,B=Array(I);await oe(F,10,async([e,t],n)=>{let i=await S(e),a=i.size,o=++ae;K(`${f.dim(`[${o}/${I}]`)} Uploading ${t} (${G(a)})...`);let s=await x(e),c=await r.files.upload(new File([s],t));B[n]={path:t,id:c.id},L+=1,R+=a}),K(`${f.dim(`[${L}/${I}]`)} Uploaded files (${G(R)}).`),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:M,createArgument:N,createOption:re,CommanderError:P,InvalidArgumentError:ie,InvalidOptionArgumentError:F,Command:I,Argument:ae,Option:L,Help:R}=A.default;var z=`0.1.79`;async function B(e){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 V=n(o(),1),H=n(a(),1);async function U(e,t){e||(e=process.cwd());let n=await u(),r=new c({authToken:n,fetch:(e,t)=>{let n=new Headers(t?.headers);return n.set(`x-blink-cli-version`,z),fetch(e,{...t,headers:n})}}),a=await i(e,`package.json`);if(!a)throw Error(`package.json not found`);let o=await x(a,`utf-8`),h=JSON.parse(o),C=_(a),w=v(C,`.blink`,`config.json`),T={};if(ee(w)){let e=await x(w,`utf-8`);T=JSON.parse(e)}let E;if(T?.organizationId)try{let e=await r.organizations.get(T.organizationId);E=e.name}catch(e){T.organizationId=void 0}if(!T?.organizationId){let e=await r.organizations.list();if(e.length===1){let t=e[0];T.organizationId=t.id,E=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(d(t))return;T.organizationId=t,E=e.find(e=>e.id===t).name}}if(!T.organizationId)throw Error(`Developer error: No organization ID found.`);let D;if(T?.agentId)try{let e=await r.agents.get(T.agentId);D=e.name}catch(e){T.agentId=void 0}if(!T?.agentId)try{let e=await r.organizations.agents.get({organization_id:T.organizationId,agent_name:h.name});T.agentId=e.id,D=e.name}catch(e){let t=await r.agents.create({name:h.name,organization_id:T.organizationId});T.agentId=t.id,D=t.name}if(!T.agentId)throw Error(`Developer error: No agent ID found.`);await te(_(w),{recursive:!0}),await ne(w,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...T},null,2),`utf-8`);let O=s(C),k=await new Promise((e,t)=>{O.build({cwd:C,entry:O.entry,outdir:O.outdir,watch:!1,onStart:()=>{},onResult:t=>{e(t)}}).catch(t)});if(!k)throw Error(`Failed to build agent`);if(`error`in k)throw Error(k.error.message);let A={},j=await b(k.outdir);for(let e of j)A[v(k.outdir,e)]=e;let M=v(e,`README.md`);await W(M)&&(A[M]=`README.md`);let N={},re=await se(C);for(let e of re){let t=y(C,e);N[e]=t}let P=Object.entries(A),ie=Object.entries(N),F=[...P,...ie],I=F.length,ae=0,L=0,R=0,B=Array(I);await oe(F,10,async([e,t],n)=>{let i=await S(e),a=i.size,o=++ae;K(`${f.dim(`[${o}/${I}]`)} Uploading ${t} (${G(a)})...`);let s=await x(e),c=await r.files.upload(new File([s],t));B[n]={path:t,id:c.id},L+=1,R+=a}),K(`${f.dim(`[${L}/${I}]`)} Uploaded files (${G(R)}).`),process.stdout.write(`
21
21
  `);let H=B.filter(Boolean),U=H.slice(0,P.length),q=H.slice(P.length),J=v(e,`.env.local`),Y=[];if(await W(J)){let e=(0,V.parse)(await x(J,`utf-8`));Y=Object.keys(e)}let X=[],ce=await r.agents.env.list({agent_id:T.agentId});X=ce.map(e=>e.key);let Z=v(e,`.env.production`);if(await W(Z)){let e=(0,V.parse)(await x(Z,`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:T.agentId,key:e,value:a,target:[`production`,`preview`],secret:!0,upsert:!0});X.push(t.key),i+=1,K(`${f.dim(`[${i}/${n}]`)} Updating environment variable: ${e} ${f.dim(`(.env.production)`)}`)}K(`${f.dim(`[${i}/${n}]`)} Updated environment variables! ${f.dim(`(.env.production)`)}`),process.stdout.write(`
22
- `)}let le=Y.filter(e=>!X.includes(e));if(le.length>0){console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of le)console.log(`- ${e}`);let e=await m({message:`Do you want to deploy anyway?`});if(e===!1||d(e))return}let ue=await r.agents.deployments.create({agent_id:T.agentId,target:`production`,entrypoint:g(k.entry),output_files:U,source_files:q,message:t?.message}),Q=`https://blink.so/${E}/${D}/deployments/${ue.number}`;console.log(`Deployed:`,Q);let $=l();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:T.agentId,deployment_id:ue.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 W=async e=>{try{return await S(e),!0}catch(e){return!1}};async function oe(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 G(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 K(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 se(e){let t=[],n=[`.git`,`node_modules`,`.blink`,`.env`,`.env.*`],r=(0,H.default)().add(n),i=v(e,`.gitignore`);if(await W(i)){let e=await x(i,`utf-8`);r.add(e)}async function a(n,i=e){let o=await b(n,{withFileTypes:!0});for(let e of o){let o=v(n,e.name),s=y(i,o);if(r.ignores(s))continue;e.isDirectory()?await a(o,i):e.isFile()&&t.push(o)}}return await a(e),t}globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>h()),j.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(z).action(()=>{j.outputHelp()});const q=e=>async(...t)=>{let{default:n}=await e();return n(...t)};j.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(q(()=>import(`./init-D-601hh-.js`))),j.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(q(()=>import(`./dev-CIl-UXl2.js`))),j.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(U),j.command(`build [directory]`).description(`Build your agent for production.`).action(B),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(q(()=>import(`./connect-DSyrG7KH.js`))),j.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(q(()=>import(`./chat-CChZ6Dgt.js`))),j.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(q(()=>import(`./login-CxmH7hHe.js`))),j.parse(process.argv);export{};
22
+ `)}let le=Y.filter(e=>!X.includes(e));if(le.length>0){console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of le)console.log(`- ${e}`);let e=await m({message:`Do you want to deploy anyway?`});if(e===!1||d(e))return}let ue=await r.agents.deployments.create({agent_id:T.agentId,target:`production`,entrypoint:g(k.entry),output_files:U,source_files:q,message:t?.message}),Q=`https://blink.so/${E}/${D}/deployments/${ue.number}`;console.log(`Deployed:`,Q);let $=l();$.start(`Waiting for deployment to be live...`);try{for(;;){let e=await r.agents.deployments.get({agent_id:T.agentId,deployment_id:ue.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 W=async e=>{try{return await S(e),!0}catch(e){return!1}};async function oe(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 G(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 K(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 se(e){let t=[],n=[`.git`,`node_modules`,`.blink`,`.env`,`.env.*`],r=(0,H.default)().add(n),i=v(e,`.gitignore`);if(await W(i)){let e=await x(i,`utf-8`);r.add(e)}async function a(n,i=e){let o=await b(n,{withFileTypes:!0});for(let e of o){let o=v(n,e.name),s=y(i,o);if(r.ignores(s))continue;e.isDirectory()?await a(o,i):e.isFile()&&t.push(o)}}return await a(e),t}globalThis.WebSocket||(globalThis.WebSocket=r.default),globalThis.crypto||(globalThis.crypto={}),globalThis.crypto.randomUUID||(globalThis.crypto.randomUUID=()=>h()),j.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(z).action(()=>{j.outputHelp()});const q=e=>async(...t)=>{let{default:n}=await e();return n(...t)};j.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(q(()=>import(`./init-BOMgt-vN.js`))),j.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(q(()=>import(`./dev-CBRHMw29.js`))),j.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(U),j.command(`build [directory]`).description(`Build your agent for production.`).action(B),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(q(()=>import(`./connect-KN0TcmCf.js`))),j.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(q(()=>import(`./chat-DwCkyfu8.js`))),j.command(`login`,{hidden:!0}).description(`Log in to the Blink Cloud.`).action(q(()=>import(`./login-CxmH7hHe.js`))),j.parse(process.argv);export{};
@@ -6,7 +6,7 @@ const agent = blink.agent();
6
6
 
7
7
  agent.on("chat", async ({ messages }) => {
8
8
  return streamText({
9
- model: blink.model("openai/gpt-oss-120b"),
9
+ model: blink.model("anthropic/claude-sonnet-4.5"),
10
10
  system: \`You are a basic agent the user will customize.
11
11
 
12
12
  Suggest the user adds tools to the agent. Demonstrate your capabilities with the IP tool.\`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blink",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "description": "Blink is a JavaScript runtime for building and deploying AI agents.",
5
5
  "type": "module",
6
6
  "bin": {