blink 1.1.40 → 1.1.41
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/{config-2GO8ol_o.js → config-BABu3-Yx.js} +1 -1
- package/dist/cli/{dev-B4Xmjy-k.js → dev-BurNoMMH.js} +11 -5
- package/dist/cli/index.js +2 -2
- package/dist/cli/{init-DlL0Hqpe.js → init-CQVF2vAw.js} +1 -1
- package/dist/cli/{init-templates-Br3bKUNT.js → init-templates-Daj0GxEe.js} +9 -9
- package/dist/cli/{pull-Cz1_1InT.js → pull-Dx50Z0Ty.js} +1 -1
- package/dist/node/agent/index.node.cjs +1 -1
- package/dist/node/agent/index.node.js +1 -1
- package/dist/node/{index.node-B1vVJ49J.js → index.node--S8bRadX.js} +1 -1
- package/dist/node/{index.node-DL1tnrix.cjs → index.node-BC3MdmB8.cjs} +1 -1
- package/dist/node/react/index.node.cjs +10 -10
- package/dist/node/react/index.node.js +10 -10
- package/package.json +1 -1
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-DRdRnzOz.js";import{version as i,writeBlinkConfig as a}from"./config-
|
|
2
|
+
import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-D9KrCrVq.js";import{import_websocket as r}from"./wrapper-DRdRnzOz.js";import{version as i,writeBlinkConfig as a}from"./config-BABu3-Yx.js";import{findNearestEntry as o,migrateDataToBlink as s,require_main as c,resolveConfig as l}from"./util-Gf_yR-5b.js";import{Client as u,M as d,Y as f,getHost as p,loginIfNeeded as m,pD as h,source_default as g,ve as _,ye as v}from"./auth-DcHT4wFv.js";import{require_ignore as y}from"./ignore-ltyKbzfl.js";import{getDevhookID as ee,resetDevhookID as te}from"./create-github-app-BeSDE8GT.js";import"./usingCtx-CCxav2be.js";import{setupGithubAppCommand as b,setupSlackAppCommand as x}from"./setup-github-app-Cvt5RYA-.js";import"./utils-BWKsfIcI.js";import{randomUUID as S}from"crypto";import{basename as C,dirname as ne,join as w,relative as T}from"node:path";import{existsSync as re}from"node:fs";import{mkdir as ie,readdir as ae,writeFile as oe}from"fs/promises";import{readFile as E,stat as D}from"node:fs/promises";import{inspect as se}from"node:util";var O=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})),k=e((e=>{let{InvalidArgumentError:t}=O();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})),A=e((e=>{let{humanReadableArgName:t}=k();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})),j=e((e=>{let{InvalidArgumentError:t}=O();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}
|
|
@@ -22,4 +22,4 @@ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let
|
|
|
22
22
|
`+g.cyan(`Environment Variables`)),console.log(g.dim(` Missing ${a.length} var${a.length===1?``:`s`} in .env.production: ${a.join(`, `)}`));let e=await v({message:`Copy missing vars from .env.local to .env.production?`,initialValue:!0});if(h(e))return;if(console.log(),e){for(let e of a)Y[e]=i[e];await oe(r,`# Environment variables for production deployment\n${Object.entries(Y).map(([e,t])=>`${e}=${t}`).join(`
|
|
23
23
|
`)}`,`utf-8`)}}let o=ee(e);if(o)if(n)console.log(g.dim(` Skipping webhook tunnel migration in CI mode`));else{let e=await d.devhook.getUrl(o);console.log(`
|
|
24
24
|
`+g.cyan(`Webhook Tunnel`)),console.log(g.dim(` Current: ${e} → local dev`)),console.log(g.dim(` After: ${e} → production`)),console.log(g.dim(` Migrating will keep your webhooks working in production`));let t=await v({message:`Migrate tunnel to production?`});if(h(t))return;console.log(),t&&(M=!0)}}let X=Object.entries(Y);if(j){let t=ee(e),n=await d.agents.create({name:x.name,organization_id:O.organizationId,request_id:M?t:void 0,entrypoint:C(P.entry),output_files:ge,source_files:_e,env:X.map(([e,t])=>({key:e,value:t,target:[`production`,`preview`],secret:!0}))});O.agentId=n.id,A=n.name;let r=`${c}/${k}/${A}`;console.log(g.gray(`Agent created ${g.dim(r)}`))}else if(X.length>0){let e=0;for(let[t,n]of X)await d.agents.env.create({agent_id:O.agentId,key:t,value:n,target:[`production`,`preview`],secret:!0,upsert:!0}),K(`${g.dim(`[${++e}/${X.length}]`)} Updating environment variable: ${t} ${g.dim(`(.env.production)`)}`);K(g.gray(`Updated ${X.length} environment ${X.length===1?`variable`:`variables`} ${g.dim(`(.env.production)`)}`)),process.stdout.write(`
|
|
25
|
-
`)}let ve=await W(w(e,`.env.local`)),Z=Object.keys(ve).filter(e=>!Object.keys(Y).includes(e));if(Z.length>0)if(n){console.log(g.yellow(`Warning:`)+` The following environment variables are set in .env.local but not in .env.production:`);for(let e of Z)console.log(`- ${e}`);console.log(g.dim(` Continuing deployment in CI mode`))}else{console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of Z)console.log(`- ${e}`);let e=await v({message:`Do you want to deploy anyway?`});if(e===!1||h(e))return}let ye=j?(await d.agents.deployments.list({agent_id:O.agentId})).items[0]:await d.agents.deployments.create({agent_id:O.agentId,target:`production`,entrypoint:C(P.entry),output_files:ge,source_files:_e,message:t?.message}),Q=`${c}/${k}/${A}/deployments/${ye.number}`;console.log(g.gray(`View Deployment ${g.dim(Q)}`)),n||await a(S,O);let $=f();$.start(`Waiting for deployment to be live...`);try{for(;;){let t=await d.agents.deployments.get({agent_id:O.agentId,deployment_id:ye.id});if(t.status===`success`){$.stop(),j?(console.log(`Your agent is live.`),console.log(g.dim(Q))):(console.log(`Deployed. All new chats will use this version.`),console.log(g.dim(Q))),M&&(te(e),console.log(g.yellow(`Note:`)+` To continue developing locally with webhooks, you'll need to reconfigure external services (Slack, GitHub, etc.)`),Object.keys(ve).some(e=>e.toLowerCase().includes(`slack`))&&console.log(`Run ${g.cyan(`blink setup slack-app`)} to create a new Slack app for development.`));break}if(t.status===`failed`){$.stop(`Failed`+(t.error_message?`: ${t.error_message}`:``)),console.log(),console.log(`Logs: `+g.dim(Q));return}await new Promise(e=>setTimeout(e,500))}}catch(e){$.stop(`Failed to poll deployment status`),console.log(),console.log(`Error: `+se(e)),console.log(`Logs: `+g.dim(Q))}}const U=async e=>{try{return await D(e),!0}catch{return!1}};async function W(e){return await U(e)?(0,B.parse)(await E(e,`utf-8`)):{}}async function me(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/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 he(e){let t=[],n=(0,V.default)().add([`.git`,`node_modules`,`.blink`,`.env`,`.env.*`]),r=w(e,`.gitignore`);if(await U(r)){let e=await E(r,`utf-8`);n.add(e)}async function i(r,a=e){let o=await ae(r,{withFileTypes:!0});for(let e of o){let o=w(r,e.name),s=T(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=()=>S()),N.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(i).action(()=>{N.outputHelp()});const q=e=>async(...t)=>{let{default:n}=await e();return n(...t)};N.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(q(()=>import(`./init-
|
|
25
|
+
`)}let ve=await W(w(e,`.env.local`)),Z=Object.keys(ve).filter(e=>!Object.keys(Y).includes(e));if(Z.length>0)if(n){console.log(g.yellow(`Warning:`)+` The following environment variables are set in .env.local but not in .env.production:`);for(let e of Z)console.log(`- ${e}`);console.log(g.dim(` Continuing deployment in CI mode`))}else{console.log(`Warning: The following environment variables are set in .env.local but not in .env.production:`);for(let e of Z)console.log(`- ${e}`);let e=await v({message:`Do you want to deploy anyway?`});if(e===!1||h(e))return}let ye=j?(await d.agents.deployments.list({agent_id:O.agentId})).items[0]:await d.agents.deployments.create({agent_id:O.agentId,target:`production`,entrypoint:C(P.entry),output_files:ge,source_files:_e,message:t?.message}),Q=`${c}/${k}/${A}/deployments/${ye.number}`;console.log(g.gray(`View Deployment ${g.dim(Q)}`)),n||await a(S,O);let $=f();$.start(`Waiting for deployment to be live...`);try{for(;;){let t=await d.agents.deployments.get({agent_id:O.agentId,deployment_id:ye.id});if(t.status===`success`){$.stop(),j?(console.log(`Your agent is live.`),console.log(g.dim(Q))):(console.log(`Deployed. All new chats will use this version.`),console.log(g.dim(Q))),M&&(te(e),console.log(g.yellow(`Note:`)+` To continue developing locally with webhooks, you'll need to reconfigure external services (Slack, GitHub, etc.)`),Object.keys(ve).some(e=>e.toLowerCase().includes(`slack`))&&console.log(`Run ${g.cyan(`blink setup slack-app`)} to create a new Slack app for development.`));break}if(t.status===`failed`){$.stop(`Failed`+(t.error_message?`: ${t.error_message}`:``)),console.log(),console.log(`Logs: `+g.dim(Q));return}await new Promise(e=>setTimeout(e,500))}}catch(e){$.stop(`Failed to poll deployment status`),console.log(),console.log(`Error: `+se(e)),console.log(`Logs: `+g.dim(Q))}}const U=async e=>{try{return await D(e),!0}catch{return!1}};async function W(e){return await U(e)?(0,B.parse)(await E(e,`utf-8`)):{}}async function me(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/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 he(e){let t=[],n=(0,V.default)().add([`.git`,`node_modules`,`.blink`,`.env`,`.env.*`]),r=w(e,`.gitignore`);if(await U(r)){let e=await E(r,`utf-8`);n.add(e)}async function i(r,a=e){let o=await ae(r,{withFileTypes:!0});for(let e of o){let o=w(r,e.name),s=T(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=()=>S()),N.name(`blink`).description(`Blink is a runtime for building and deploying AI agents.`).version(i).action(()=>{N.outputHelp()});const q=e=>async(...t)=>{let{default:n}=await e();return n(...t)};N.command(`init [directory]`).description(`Initialize a new Blink agent.`).action(q(()=>import(`./init-CQVF2vAw.js`))),N.command(`dev [directory] [options]`).description(`Start a development server for your agent.`).action(q(()=>import(`./dev-BurNoMMH.js`))),N.command(`deploy [directory]`).description(`Deploy your agent to the Blink Cloud.`).option(`-m, --message <message>`,`Message for this deployment`).action(H),N.command(`pull [agent]`).description(`Pull an agent's source code to a local directory.`).option(`-d, --dir <directory>`,`Target directory (default: current directory)`).action((e=>async(...t)=>{let{default:n}=await e(),r=await n(...t);r!==0&&process.exit(r)})(()=>import(`./pull-Dx50Z0Ty.js`))),N.command(`build [directory]`).description(`Build your agent for production.`).action(z);const J=N.command(`setup`).description(`Set up integrations for your agent.`);J.command(`slack-app [directory]`).description(`Set up Slack app integration`).action(x),J.command(`github-app [directory]`).description(`Set up GitHub App integration`).action(b),N.command(`telemetry [boolean]`).description(`Enable or disable telemetry.`),N.command(`start [directory]`).description("Starts the Blink runtime in production mode. The agent must be compiled with `blink build` first."),N.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(q(()=>import(`./run-DO2Nc565.js`))),N.command(`connect`,{hidden:!0}).description(`Connect compute to the Blink Cloud.`).action(q(()=>import(`./connect-Crx6klCf.js`))),N.command(`chat`,{hidden:!0}).description(`Start a Blink chat connected to your machine.`).action(q(()=>import(`./chat-CH6IX_Ao.js`))),N.command(`login [url]`).description(`Log in to a Blink platform. Optionally specify a custom host URL.`).action(q(()=>import(`./login-gyqns-J2.js`))),N.command(`logout`).description(`Log out from the Blink platform and remove saved credentials.`).action(q(()=>import(`./logout-DBSOwqWf.js`))),N.command(`compute`).description(`Compute-related commands.`).command(`server`).description(`Run a compute protocol server on localhost.`).action(q(()=>import(`./compute-server-Cw1pzwJv.js`))),N.configureOutput({writeErr:e=>{let t=e.replace(/\x1b\[[0-9;]*m/g,``);d.error(t.trim())}}),process.on(`unhandledRejection`,e=>{d.error(e?.message||String(e)),process.exit(1)}),N.parse(process.argv);export{};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-D9KrCrVq.js";import{Ie as r,M as i,Se as a,he as o,pD as s,ve as c,xe as l,ye as u}from"./auth-DcHT4wFv.js";import"./create-github-app-BeSDE8GT.js";import"./usingCtx-CCxav2be.js";import{setupGithubApp as d,setupSlackApp as f}from"./setup-github-app-Cvt5RYA-.js";import"./utils-BWKsfIcI.js";import{templates as p}from"./init-templates-
|
|
1
|
+
import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-D9KrCrVq.js";import{Ie as r,M as i,Se as a,he as o,pD as s,ve as c,xe as l,ye as u}from"./auth-DcHT4wFv.js";import"./create-github-app-BeSDE8GT.js";import"./usingCtx-CCxav2be.js";import{setupGithubApp as d,setupSlackApp as f}from"./setup-github-app-Cvt5RYA-.js";import"./utils-BWKsfIcI.js";import{templates as p}from"./init-templates-Daj0GxEe.js";import{exec as m,spawn as h}from"node:child_process";import{basename as g,join as _}from"node:path";import{readdir as v,writeFile as y}from"node:fs/promises";var b=e((e=>{e.__esModule=!0,e.extend=a,e.indexOf=l,e.escapeExpression=u,e.isEmpty=d,e.createFrame=f,e.blockParams=p,e.appendContextPath=m;var t={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"`":```,"=":`=`},n=/[&<>"'`=]/g,r=/[&<>"'`=]/;function i(e){return t[e]}function a(e){for(var t=1;t<arguments.length;t++)for(var n in arguments[t])Object.prototype.hasOwnProperty.call(arguments[t],n)&&(e[n]=arguments[t][n]);return e}var o=Object.prototype.toString;e.toString=o;var s=function(e){return typeof e==`function`};s(/x/)&&(e.isFunction=s=function(e){return typeof e==`function`&&o.call(e)===`[object Function]`}),e.isFunction=s;var c=Array.isArray||function(e){return e&&typeof e==`object`?o.call(e)===`[object Array]`:!1};e.isArray=c;function l(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function u(e){if(typeof e!=`string`){if(e&&e.toHTML)return e.toHTML();if(e==null)return``;if(!e)return e+``;e=``+e}return r.test(e)?e.replace(n,i):e}function d(e){return!e&&e!==0?!0:!!(c(e)&&e.length===0)}function f(e){var t=a({},e);return t._parent=e,t}function p(e,t){return e.path=t,e}function m(e,t){return(e?e+`.`:``)+t}})),x=e(((e,t)=>{e.__esModule=!0;var n=[`description`,`fileName`,`lineNumber`,`endLineNumber`,`message`,`name`,`number`,`stack`];function r(e,t){var i=t&&t.loc,a=void 0,o=void 0,s=void 0,c=void 0;i&&(a=i.start.line,o=i.end.line,s=i.start.column,c=i.end.column,e+=` - `+a+`:`+s);for(var l=Error.prototype.constructor.call(this,e),u=0;u<n.length;u++)this[n[u]]=l[n[u]];Error.captureStackTrace&&Error.captureStackTrace(this,r);try{i&&(this.lineNumber=a,this.endLineNumber=o,Object.defineProperty?(Object.defineProperty(this,`column`,{value:s,enumerable:!0}),Object.defineProperty(this,`endColumn`,{value:c,enumerable:!0})):(this.column=s,this.endColumn=c))}catch{}}r.prototype=Error(),e.default=r,t.exports=e.default})),S=e(((e,t)=>{e.__esModule=!0;var n=b();e.default=function(e){e.registerHelper(`blockHelperMissing`,function(t,r){var i=r.inverse,a=r.fn;if(t===!0)return a(this);if(t===!1||t==null)return i(this);if(n.isArray(t))return t.length>0?(r.ids&&=[r.name],e.helpers.each(t,r)):i(this);if(r.data&&r.ids){var o=n.createFrame(r.data);o.contextPath=n.appendContextPath(r.data.contextPath,r.name),r={data:o}}return a(t,r)})},t.exports=e.default})),C=e(((e,t)=>{e.__esModule=!0;function n(e){return e&&e.__esModule?e:{default:e}}var r=b(),i=x(),a=n(i);e.default=function(e){e.registerHelper(`each`,function(e,t){if(!t)throw new a.default(`Must pass iterator to #each`);var n=t.fn,i=t.inverse,o=0,s=``,c=void 0,l=void 0;t.data&&t.ids&&(l=r.appendContextPath(t.data.contextPath,t.ids[0])+`.`),r.isFunction(e)&&(e=e.call(this)),t.data&&(c=r.createFrame(t.data));function u(t,i,a){c&&(c.key=t,c.index=i,c.first=i===0,c.last=!!a,l&&(c.contextPath=l+t)),s+=n(e[t],{data:c,blockParams:r.blockParams([e[t],t],[l+t,null])})}if(e&&typeof e==`object`)if(r.isArray(e))for(var d=e.length;o<d;o++)o in e&&u(o,o,o===e.length-1);else if(typeof Symbol==`function`&&e[Symbol.iterator]){for(var f=[],p=e[Symbol.iterator](),m=p.next();!m.done;m=p.next())f.push(m.value);e=f;for(var d=e.length;o<d;o++)u(o,o,o===e.length-1)}else (function(){var t=void 0;Object.keys(e).forEach(function(e){t!==void 0&&u(t,o-1),t=e,o++}),t!==void 0&&u(t,o-1,!0)})();return o===0&&(s=i(this)),s})},t.exports=e.default})),w=e(((e,t)=>{e.__esModule=!0;function n(e){return e&&e.__esModule?e:{default:e}}var r=x(),i=n(r);e.default=function(e){e.registerHelper(`helperMissing`,function(){if(arguments.length!==1)throw new i.default(`Missing helper: "`+arguments[arguments.length-1].name+`"`)})},t.exports=e.default})),T=e(((e,t)=>{e.__esModule=!0;function n(e){return e&&e.__esModule?e:{default:e}}var r=b(),i=x(),a=n(i);e.default=function(e){e.registerHelper(`if`,function(e,t){if(arguments.length!=2)throw new a.default(`#if requires exactly one argument`);return r.isFunction(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||r.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper(`unless`,function(t,n){if(arguments.length!=2)throw new a.default(`#unless requires exactly one argument`);return e.helpers.if.call(this,t,{fn:n.inverse,inverse:n.fn,hash:n.hash})})},t.exports=e.default})),E=e(((e,t)=>{e.__esModule=!0,e.default=function(e){e.registerHelper(`log`,function(){for(var t=[void 0],n=arguments[arguments.length-1],r=0;r<arguments.length-1;r++)t.push(arguments[r]);var i=1;n.hash.level==null?n.data&&n.data.level!=null&&(i=n.data.level):i=n.hash.level,t[0]=i,e.log.apply(e,t)})},t.exports=e.default})),D=e(((e,t)=>{e.__esModule=!0,e.default=function(e){e.registerHelper(`lookup`,function(e,t,n){return e&&n.lookupProperty(e,t)})},t.exports=e.default})),O=e(((e,t)=>{e.__esModule=!0;function n(e){return e&&e.__esModule?e:{default:e}}var r=b(),i=x(),a=n(i);e.default=function(e){e.registerHelper(`with`,function(e,t){if(arguments.length!=2)throw new a.default(`#with requires exactly one argument`);r.isFunction(e)&&(e=e.call(this));var n=t.fn;if(r.isEmpty(e))return t.inverse(this);var i=t.data;return t.data&&t.ids&&(i=r.createFrame(t.data),i.contextPath=r.appendContextPath(t.data.contextPath,t.ids[0])),n(e,{data:i,blockParams:r.blockParams([e],[i&&i.contextPath])})})},t.exports=e.default})),k=e((e=>{e.__esModule=!0,e.registerDefaultHelpers=g,e.moveHelperToHooks=_;function t(e){return e&&e.__esModule?e:{default:e}}var n=S(),r=t(n),i=C(),a=t(i),o=w(),s=t(o),c=T(),l=t(c),u=E(),d=t(u),f=D(),p=t(f),m=O(),h=t(m);function g(e){r.default(e),a.default(e),s.default(e),l.default(e),d.default(e),p.default(e),h.default(e)}function _(e,t,n){e.helpers[t]&&(e.hooks[t]=e.helpers[t],n||delete e.helpers[t])}})),A=e(((e,t)=>{e.__esModule=!0;var n=b();e.default=function(e){e.registerDecorator(`inline`,function(e,t,r,i){var a=e;return t.partials||(t.partials={},a=function(i,a){var o=r.partials;r.partials=n.extend({},o,t.partials);var s=e(i,a);return r.partials=o,s}),t.partials[i.args[0]]=i.fn,a})},t.exports=e.default})),ee=e((e=>{e.__esModule=!0,e.registerDefaultDecorators=i;function t(e){return e&&e.__esModule?e:{default:e}}var n=A(),r=t(n);function i(e){r.default(e)}})),j=e(((e,t)=>{e.__esModule=!0;var n=b(),r={methodMap:[`debug`,`info`,`warn`,`error`],level:`info`,lookupLevel:function(e){if(typeof e==`string`){var t=n.indexOf(r.methodMap,e.toLowerCase());e=t>=0?t:parseInt(e,10)}return e},log:function(e){if(e=r.lookupLevel(e),typeof console<`u`&&r.lookupLevel(r.level)<=e){var t=r.methodMap[e];console[t]||(t=`log`);var n=[...arguments].slice(1);console[t].apply(console,n)}}};e.default=r,t.exports=e.default})),M=e((e=>{e.__esModule=!0,e.createNewLookupObject=n;var t=b();function n(){var e=[...arguments];return t.extend.apply(void 0,[Object.create(null)].concat(e))}})),N=e((e=>{e.__esModule=!0,e.createProtoAccessControl=o,e.resultIsAllowed=s,e.resetLoggedProperties=u;function t(e){return e&&e.__esModule?e:{default:e}}var n=M(),r=j(),i=t(r),a=Object.create(null);function o(e){var t=Object.create(null);t.constructor=!1,t.__defineGetter__=!1,t.__defineSetter__=!1,t.__lookupGetter__=!1;var r=Object.create(null);return r.__proto__=!1,{properties:{whitelist:n.createNewLookupObject(r,e.allowedProtoProperties),defaultValue:e.allowProtoPropertiesByDefault},methods:{whitelist:n.createNewLookupObject(t,e.allowedProtoMethods),defaultValue:e.allowProtoMethodsByDefault}}}function s(e,t,n){return c(typeof e==`function`?t.methods:t.properties,n)}function c(e,t){return e.whitelist[t]===void 0?e.defaultValue===void 0?(l(t),!1):e.defaultValue:e.whitelist[t]===!0}function l(e){a[e]!==!0&&(a[e]=!0,i.default.log(`error`,`Handlebars: Access has been denied to resolve the property "`+e+`" because it is not an "own property" of its parent.
|
|
2
2
|
You can add a runtime option to disable the check or this warning:
|
|
3
3
|
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details`))}function u(){Object.keys(a).forEach(function(e){delete a[e]})}})),P=e((e=>{e.__esModule=!0,e.HandlebarsEnvironment=d;function t(e){return e&&e.__esModule?e:{default:e}}var n=b(),r=x(),i=t(r),a=k(),o=ee(),s=j(),c=t(s),l=N();e.VERSION=`4.7.8`,e.COMPILER_REVISION=8,e.LAST_COMPATIBLE_COMPILER_REVISION=7,e.REVISION_CHANGES={1:`<= 1.0.rc.2`,2:`== 1.0.0-rc.3`,3:`== 1.0.0-rc.4`,4:`== 1.x.x`,5:`== 2.0.0-alpha.x`,6:`>= 2.0.0-beta.1`,7:`>= 4.0.0 <4.3.0`,8:`>= 4.3.0`};var u=`[object Object]`;function d(e,t,n){this.helpers=e||{},this.partials=t||{},this.decorators=n||{},a.registerDefaultHelpers(this),o.registerDefaultDecorators(this)}d.prototype={constructor:d,logger:c.default,log:c.default.log,registerHelper:function(e,t){if(n.toString.call(e)===u){if(t)throw new i.default(`Arg not supported with multiple helpers`);n.extend(this.helpers,e)}else this.helpers[e]=t},unregisterHelper:function(e){delete this.helpers[e]},registerPartial:function(e,t){if(n.toString.call(e)===u)n.extend(this.partials,e);else{if(t===void 0)throw new i.default(`Attempting to register a partial called "`+e+`" as undefined`);this.partials[e]=t}},unregisterPartial:function(e){delete this.partials[e]},registerDecorator:function(e,t){if(n.toString.call(e)===u){if(t)throw new i.default(`Arg not supported with multiple decorators`);n.extend(this.decorators,e)}else this.decorators[e]=t},unregisterDecorator:function(e){delete this.decorators[e]},resetLoggedPropertyAccesses:function(){l.resetLoggedProperties()}},e.log=c.default.log,e.createFrame=n.createFrame,e.logger=c.default})),F=e(((e,t)=>{e.__esModule=!0;function n(e){this.string=e}n.prototype.toString=n.prototype.toHTML=function(){return``+this.string},e.default=n,t.exports=e.default})),I=e((e=>{e.__esModule=!0,e.wrapHelper=t;function t(e,t){return typeof e==`function`?function(){var n=arguments[arguments.length-1];return arguments[arguments.length-1]=t(n),e.apply(this,arguments)}:e}})),te=e((e=>{e.__esModule=!0,e.checkRevision=d,e.template=f,e.wrapProgram=p,e.resolvePartial=m,e.invokePartial=h,e.noop=g;function t(e){return e&&e.__esModule?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}var r=b(),i=n(r),a=x(),o=t(a),s=P(),c=k(),l=I(),u=N();function d(e){var t=e&&e[0]||1,n=s.COMPILER_REVISION;if(!(t>=s.LAST_COMPATIBLE_COMPILER_REVISION&&t<=s.COMPILER_REVISION))if(t<s.LAST_COMPATIBLE_COMPILER_REVISION){var r=s.REVISION_CHANGES[n],i=s.REVISION_CHANGES[t];throw new o.default(`Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version (`+r+`) or downgrade your runtime to an older version (`+i+`).`)}else throw new o.default(`Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version (`+e[1]+`).`)}function f(e,t){if(!t)throw new o.default(`No environment passed to template`);if(!e||!e.main)throw new o.default(`Unknown template object: `+typeof e);e.main.decorator=e.main_d,t.VM.checkRevision(e.compiler);var n=e.compiler&&e.compiler[0]===7;function r(n,r,a){a.hash&&(r=i.extend({},r,a.hash),a.ids&&(a.ids[0]=!0)),n=t.VM.resolvePartial.call(this,n,r,a);var s=i.extend({},a,{hooks:this.hooks,protoAccessControl:this.protoAccessControl}),c=t.VM.invokePartial.call(this,n,r,s);if(c==null&&t.compile&&(a.partials[a.name]=t.compile(n,e.compilerOptions,t),c=a.partials[a.name](r,s)),c!=null){if(a.indent){for(var l=c.split(`
|
|
4
4
|
`),u=0,d=l.length;u<d&&!(!l[u]&&u+1===d);u++)l[u]=a.indent+l[u];c=l.join(`
|
|
@@ -572,12 +572,12 @@ agent.serve();
|
|
|
572
572
|
"deploy": "blink deploy"
|
|
573
573
|
},
|
|
574
574
|
"devDependencies": {
|
|
575
|
-
"zod": "
|
|
575
|
+
"zod": "^4",
|
|
576
576
|
"ai": "^5",
|
|
577
577
|
{{#if (eq aiProvider "anthropic")}}
|
|
578
|
-
"@ai-sdk/anthropic": "
|
|
578
|
+
"@ai-sdk/anthropic": "^2",
|
|
579
579
|
{{else if (eq aiProvider "openai")}}
|
|
580
|
-
"@ai-sdk/openai": "
|
|
580
|
+
"@ai-sdk/openai": "^2",
|
|
581
581
|
{{/if}}
|
|
582
582
|
"blink": "latest",
|
|
583
583
|
"esbuild": "latest",
|
|
@@ -1109,12 +1109,12 @@ agent.serve();
|
|
|
1109
1109
|
"deploy": "blink deploy"
|
|
1110
1110
|
},
|
|
1111
1111
|
"devDependencies": {
|
|
1112
|
-
"zod": "
|
|
1112
|
+
"zod": "^4",
|
|
1113
1113
|
"ai": "^5",
|
|
1114
1114
|
{{#if (eq aiProvider "anthropic")}}
|
|
1115
|
-
"@ai-sdk/anthropic": "
|
|
1115
|
+
"@ai-sdk/anthropic": "^2",
|
|
1116
1116
|
{{else if (eq aiProvider "openai")}}
|
|
1117
|
-
"@ai-sdk/openai": "
|
|
1117
|
+
"@ai-sdk/openai": "^2",
|
|
1118
1118
|
{{/if}}
|
|
1119
1119
|
"blink": "latest",
|
|
1120
1120
|
"esbuild": "latest",
|
|
@@ -1714,12 +1714,12 @@ agent.serve();`,"package.json.hbs":`{
|
|
|
1714
1714
|
"deploy": "blink deploy"
|
|
1715
1715
|
},
|
|
1716
1716
|
"devDependencies": {
|
|
1717
|
-
"zod": "
|
|
1717
|
+
"zod": "^4",
|
|
1718
1718
|
"ai": "^5",
|
|
1719
1719
|
{{#if (eq aiProvider "anthropic")}}
|
|
1720
|
-
"@ai-sdk/anthropic": "
|
|
1720
|
+
"@ai-sdk/anthropic": "^2",
|
|
1721
1721
|
{{else if (eq aiProvider "openai")}}
|
|
1722
|
-
"@ai-sdk/openai": "
|
|
1722
|
+
"@ai-sdk/openai": "^2",
|
|
1723
1723
|
{{/if}}
|
|
1724
1724
|
"blink": "latest",
|
|
1725
1725
|
"esbuild": "latest",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{version as e,writeBlinkConfig as t}from"./config-
|
|
1
|
+
import{version as e,writeBlinkConfig as t}from"./config-BABu3-Yx.js";import{Client as n,dist_exports as r,getHost as i,loginIfNeeded as a,source_default as o}from"./auth-DcHT4wFv.js";import{dirname as s,join as c,resolve as l}from"node:path";import{existsSync as u}from"node:fs";import{mkdir as d,readdir as f,writeFile as p}from"node:fs/promises";const m=Error(`request for lock canceled`);var h=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},g=class{constructor(e,t=m){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=v(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return h(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),_(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function _(e,t){let n=v(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function v(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}async function y(m,h){let _=h?._deps,{intro:v,cancel:y,confirm:x,select:S,spinner:C,log:w,isCancel:T}=r,E=_?.authenticate??a,D=_?.getHost??i,O=await E(),k=D();if(!k)throw Error(`No Blink host configured`);let A=_?.client??new n({baseURL:k,authToken:O,fetch:((t,n)=>{let r=new Headers(n?.headers);return r.set(`x-blink-cli-version`,e),fetch(t,{...n,headers:r})})}),j,M,N,P,F=l(h?.dir||process.cwd());if(v(`Pulling a Blink Agent into ${o.bold(F)}`),m){let e=m.split(`/`);if(e.length!==2)throw Error(`Agent must be in format: org-name/agent-name`);[M,P]=e;let t=C();t.start(`Finding ${M}/${P}...`);let n=(await A.organizations.list()).find(e=>e.name===M);if(!n)return t.stop(`Organization "${M}" not found`),1;j=n.id;let r;try{r=await A.organizations.agents.get({organization_id:j,agent_name:P})}catch{return t.stop(`Agent "${P}" not found in organization "${M}"`),1}N=r.id,t.stop(`Found ${M}/${P}`)}else{let e=await A.organizations.list();if(e.length===0)throw Error(`You don't have access to any organizations`);if(e.length===1){let t=e[0];j=t.id,M=t.name,w.info(`Using organization: ${o.bold(M)}`)}else{let t=await S({message:`Select an organization:`,options:e.map(e=>({value:e.id,label:e.name}))});if(T(t))return 1;j=t,M=e.find(e=>e.id===j)?.name??``}let t=(await A.agents.list({organization_id:j})).items;if(t.length===0)throw Error(`No agents found in organization "${M}"`);if(t.length===1){let e=t[0],n=await x({message:`Pull agent ${o.bold(e.name)}?`});if(n===!1||T(n))return y(`Pull cancelled.`),1;N=e.id,P=e.name}else{let e=await S({message:`Select an agent to pull:`,options:t.map(e=>({value:e.id,label:e.name}))});if(T(e))return 1;N=e,P=t.find(e=>e.id===N)?.name??``}}if(u(F)){if((await f(F)).length>0){let e=await x({message:`Directory ${o.bold(F)} is not empty. Pull anyway?`});if(e===!1||T(e))return y(`Pull cancelled.`),1}}else await d(F,{recursive:!0});let I=await A.agents.get(N);if(!I.active_deployment_id)throw Error(`Agent has no active deployment`);let L=await A.agents.deployments.get({agent_id:N,deployment_id:I.active_deployment_id});if(!L.source_files||L.source_files.length===0)throw Error(`No source files found in active deployment`);let R=L.source_files.length,z=0,B=C(),V=()=>{B.message(`Downloading ${o.dim(`(${z}/${R})`)}`)};B.start(`Downloading ${o.dim(`(0/${R})`)}`);let H=new g(30);await Promise.all(L.source_files.map(async e=>{await H.runExclusive(async()=>{let t=await(await A.files.get(e.id)).text(),n=c(F,e.path);await d(s(n),{recursive:!0}),await p(n,t,`utf-8`),z++,V()})})),B.stop(`Downloaded ${R} files`),await t(F,{organizationId:j,agentId:N});let U=L.source_files.map(e=>e.path),W=b(U),G={bun:`bun install`,npm:`npm install`,pnpm:`pnpm install`,yarn:`yarn install`}[W],K={bun:`bun run dev`,npm:`npm run dev`,pnpm:`pnpm run dev`,yarn:`yarn dev`}[W];return w.success(`Pulled ${o.bold(`${M}/${P}`)} to ${o.dim(F)}`),w.info(`Next steps:
|
|
2
2
|
|
|
3
3
|
1. Install dependencies:
|
|
4
4
|
${o.cyan(G)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../index.node-
|
|
1
|
+
const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../index.node-BC3MdmB8.cjs`);require(`../token-error-BoNG8ooW.cjs`),require(`../esm-DAl5TNhv.cjs`),require(`../context-Cp_cUqvc.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.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,toolWithApproval as o,tools as s,waitUntil as c,withResponseFormat as l}from"../index.node
|
|
1
|
+
import{Agent as e,StreamResponseFormatHeader as t,agent as n,api as r,isToolApprovalOutput as i,lastUIOptions as a,toolWithApproval as o,tools as s,waitUntil as c,withResponseFormat as l}from"../index.node--S8bRadX.js";import"../token-error-488npYdU.js";import"../esm-CSXsVdYr.js";import"../context-Ch5QyxHM.js";export{e as Agent,t as StreamResponseFormatHeader,n as agent,r as api,i as isToolApprovalOutput,a as lastUIOptions,o as toolWithApproval,s as tools,c as waitUntil,l as withResponseFormat};
|