blink 1.1.23 → 1.1.25

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 (106) hide show
  1. package/dist/browser/agent/client/index.cjs +1 -1
  2. package/dist/browser/agent/client/index.d.cts +1 -1
  3. package/dist/browser/agent/client/index.d.ts +1 -1
  4. package/dist/browser/agent/client/index.js +1 -1
  5. package/dist/browser/{index-C-Slllhb.d.ts → index-BXZCP58f.d.ts} +51 -0
  6. package/dist/browser/{index-DSU-sZKL.d.cts → index-orp-VO8g.d.cts} +51 -0
  7. package/dist/browser/react/index.browser.cjs +1 -1
  8. package/dist/browser/react/index.browser.d.cts +16 -2
  9. package/dist/browser/react/index.browser.d.ts +16 -2
  10. package/dist/browser/react/index.browser.js +1 -1
  11. package/dist/cli/{chat-CAtArOPl.js → chat-CYrdzv1d.js} +1 -1
  12. package/dist/cli/chat-manager-B3eOpIG8.js +21 -0
  13. package/dist/cli/connect-Bpv7PF3y.js +1 -0
  14. package/dist/cli/{dev-DwwSnzeH.js → dev-BYcnkDFn.js} +23 -29
  15. package/dist/cli/{getMachineId-bsd-0cOO_RKK.js → getMachineId-bsd-BECgXpZb.js} +1 -1
  16. package/dist/cli/{getMachineId-bsd-BDrKPt3B.js → getMachineId-bsd-BgAyii4H.js} +1 -1
  17. package/dist/cli/{getMachineId-bsd-BJ3yH7j4.js → getMachineId-bsd-Cc73dhdJ.js} +1 -1
  18. package/dist/cli/{getMachineId-bsd-BpxYEV3F.js → getMachineId-bsd-DJn61I3m.js} +1 -1
  19. package/dist/cli/{getMachineId-bsd-CHVQhSq2.js → getMachineId-bsd-Doah6QJP.js} +1 -1
  20. package/dist/cli/getMachineId-bsd-aoAkh_W6.js +1 -0
  21. package/dist/cli/getMachineId-bsd-iPOb0TqF.js +1 -0
  22. package/dist/cli/getMachineId-bsd-io5tPlFg.js +1 -0
  23. package/dist/cli/{getMachineId-darwin-0AdOS_kz.js → getMachineId-darwin-BMnMBte0.js} +1 -1
  24. package/dist/cli/{getMachineId-darwin-CJ2gOzlU.js → getMachineId-darwin-BP9BSYcd.js} +1 -1
  25. package/dist/cli/{getMachineId-darwin-BeAdNwpL.js → getMachineId-darwin-Bs3mlKrs.js} +1 -1
  26. package/dist/cli/{getMachineId-darwin-C8-xkmnZ.js → getMachineId-darwin-D-l4_nyT.js} +1 -1
  27. package/dist/cli/{getMachineId-darwin-BaA8JJgE.js → getMachineId-darwin-DFronuaU.js} +1 -1
  28. package/dist/cli/getMachineId-darwin-DJO6fOdc.js +2 -0
  29. package/dist/cli/getMachineId-darwin-DlRRGl6M.js +2 -0
  30. package/dist/cli/getMachineId-darwin-Wp0usMIp.js +2 -0
  31. package/dist/cli/{getMachineId-linux-BQISLgy5.js → getMachineId-linux-B2r_HEgX.js} +1 -1
  32. package/dist/cli/{getMachineId-linux-Bg5YnekM.js → getMachineId-linux-Bj52Hdvy.js} +1 -1
  33. package/dist/cli/{getMachineId-linux-Boq-GGfA.js → getMachineId-linux-C9o1dYwI.js} +1 -1
  34. package/dist/cli/{getMachineId-linux-C9BHlxRm.js → getMachineId-linux-CGcBOg7J.js} +1 -1
  35. package/dist/cli/getMachineId-linux-CV2HmJXY.js +1 -0
  36. package/dist/cli/getMachineId-linux-Cv44Y8ZY.js +1 -0
  37. package/dist/cli/getMachineId-linux-CzNEh3DJ.js +1 -0
  38. package/dist/cli/getMachineId-linux-_RiwpX2J.js +1 -0
  39. package/dist/cli/{getMachineId-unsupported-4qhSqb7w.js → getMachineId-unsupported-BtmyS2eg.js} +1 -1
  40. package/dist/cli/{getMachineId-unsupported-BsEK_LG9.js → getMachineId-unsupported-C8az6JKm.js} +1 -1
  41. package/dist/cli/{getMachineId-unsupported-C6cVb167.js → getMachineId-unsupported-CBS2qXAs.js} +1 -1
  42. package/dist/cli/{getMachineId-unsupported-CqJy0sqq.js → getMachineId-unsupported-Cu0DvxaU.js} +1 -1
  43. package/dist/cli/getMachineId-unsupported-Dni2ujA-.js +1 -0
  44. package/dist/cli/getMachineId-unsupported-MPNVP8rP.js +1 -0
  45. package/dist/cli/getMachineId-unsupported-mBJd3oBN.js +1 -0
  46. package/dist/cli/getMachineId-unsupported-rdNf8ej6.js +1 -0
  47. package/dist/cli/{getMachineId-win-4Psd7Tlr.js → getMachineId-win-BCAO7ld1.js} +1 -1
  48. package/dist/cli/{getMachineId-win-BzRwVWue.js → getMachineId-win-BDQszRKi.js} +1 -1
  49. package/dist/cli/{getMachineId-win-BA0Li8oF.js → getMachineId-win-BOnF6rL7.js} +1 -1
  50. package/dist/cli/{getMachineId-win-BvGLfEpq.js → getMachineId-win-BOuIHcz_.js} +1 -1
  51. package/dist/cli/getMachineId-win-BQ_C7kS3.js +1 -0
  52. package/dist/cli/getMachineId-win-Bw0-Mlkn.js +1 -0
  53. package/dist/cli/getMachineId-win-DrJTv2qi.js +1 -0
  54. package/dist/cli/{getMachineId-win-C4wjvjxC.js → getMachineId-win-pnMl0wak.js} +1 -1
  55. package/dist/cli/index.js +3 -3
  56. package/dist/cli/{init-em410TZP.js → init-CAbtPm4f.js} +1 -1
  57. package/dist/cli/run-DYgfawiE.js +1 -0
  58. package/dist/cli/setup-slack-app-C9L0iIDZ.js +1 -0
  59. package/dist/cli/{token-BdYp2nw_.js → token-Bk68OrJt.js} +1 -1
  60. package/dist/cli/{token-util-KdD-UX1l.js → token-util-BKLboTb2.js} +1 -1
  61. package/dist/cli/token-util-Dui5nOLw.js +1 -0
  62. package/dist/cli/undici-mM2IfLwA.js +1 -0
  63. package/dist/cli/usingCtx-B1FpoePI.js +1 -0
  64. package/dist/node/react/index.node.cjs +89 -89
  65. package/dist/node/react/index.node.d.cts +83 -3
  66. package/dist/node/react/index.node.d.ts +83 -3
  67. package/dist/node/react/index.node.js +47 -47
  68. package/package.json +4 -2
  69. package/dist/cli/chat-manager-GWR_v50X.js +0 -21
  70. package/dist/cli/connect-DWScpJzS.js +0 -1
  71. package/dist/cli/getMachineId-bsd-BrJwIGYU.js +0 -1
  72. package/dist/cli/getMachineId-bsd-C6osJ6-S.js +0 -1
  73. package/dist/cli/getMachineId-bsd-DeIJ5F9l.js +0 -1
  74. package/dist/cli/getMachineId-darwin-CYvRIQbp.js +0 -2
  75. package/dist/cli/getMachineId-darwin-DWSKszGZ.js +0 -2
  76. package/dist/cli/getMachineId-darwin-wYLDmdQt.js +0 -2
  77. package/dist/cli/getMachineId-linux-D0cDy6Ik.js +0 -1
  78. package/dist/cli/getMachineId-linux-DgyKUIyK.js +0 -1
  79. package/dist/cli/getMachineId-linux-DnzutOBC.js +0 -1
  80. package/dist/cli/getMachineId-linux-nBO1QX9q.js +0 -1
  81. package/dist/cli/getMachineId-unsupported-DQBLgw4s.js +0 -1
  82. package/dist/cli/getMachineId-unsupported-DTFeADdG.js +0 -1
  83. package/dist/cli/getMachineId-unsupported-DgVzHx1H.js +0 -1
  84. package/dist/cli/getMachineId-unsupported-TE5qi9PD.js +0 -1
  85. package/dist/cli/getMachineId-win-DXCyELQJ.js +0 -1
  86. package/dist/cli/getMachineId-win-hHwtD9GX.js +0 -1
  87. package/dist/cli/getMachineId-win-lhgCxX3y.js +0 -1
  88. package/dist/cli/run-CZZ6WAdr.js +0 -1
  89. package/dist/cli/setup-slack-app-DagQxNol.js +0 -1
  90. package/dist/cli/token-util-C9doIH9w.js +0 -1
  91. package/dist/cli/undici-Bm_EanIy.js +0 -1
  92. /package/dist/cli/{connect-BCK40kvG.js → connect-DIUub9Pr.js} +0 -0
  93. /package/dist/cli/{devtools-DsAYEmyP.js → devtools-DqYysfX1.js} +0 -0
  94. /package/dist/cli/{esm-C_RXU0lI.js → esm-CYkSi8_o.js} +0 -0
  95. /package/dist/cli/{execAsync-BOPj9Mml.js → execAsync-9jtK4I3l.js} +0 -0
  96. /package/dist/cli/{execAsync-Bv4jTnD3.js → execAsync-B4_pEoEJ.js} +0 -0
  97. /package/dist/cli/{execAsync-CyP3Ojec.js → execAsync-BdK7RB6d.js} +0 -0
  98. /package/dist/cli/{execAsync-DHh3DKKp.js → execAsync-Bjxs-bO2.js} +0 -0
  99. /package/dist/cli/{execAsync-DdLzES9n.js → execAsync-CM_C8SBr.js} +0 -0
  100. /package/dist/cli/{execAsync-Dv6XOE2I.js → execAsync-CNFaXJjR.js} +0 -0
  101. /package/dist/cli/{execAsync-Dwktgsum.js → execAsync-Dl3hbWiU.js} +0 -0
  102. /package/dist/cli/{execAsync-qNF4iDpO.js → execAsync-qGIZ8XA8.js} +0 -0
  103. /package/dist/cli/{init-templates-By3gx42M.js → init-templates-BgcZAdJh.js} +0 -0
  104. /package/dist/cli/{login-BDP8JC4X.js → login-Bu2acoVp.js} +0 -0
  105. /package/dist/cli/{token-error-COQY18OP.js → token-error-CGIVaIg6.js} +0 -0
  106. /package/dist/cli/{undici-CRntNDHY.js → undici-BiTrd9-R.js} +0 -0
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__require as t,__toCommonJS as n}from"./chunk-D9KrCrVq.js";import{esm_exports as r,init_esm as i}from"./esm-C_RXU0lI.js";var a=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let a=t(`fs`),o=(i(),n(r));async function s(){for(let e of[`/etc/machine-id`,`/var/lib/dbus/machine-id`])try{return(await a.promises.readFile(e,{encoding:`utf8`})).trim()}catch(e){o.diag.debug(`error reading machine id: ${e}`)}}e.getMachineId=s}));export default a();export{};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__toCommonJS as t}from"./chunk-D9KrCrVq.js";import{esm_exports as n,init_esm as r}from"./esm-C_RXU0lI.js";var i=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let i=(r(),t(n));async function a(){i.diag.debug(`could not read machine-id: unsupported platform`)}e.getMachineId=a}));export default i();export{};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__toCommonJS as t}from"./chunk-D9KrCrVq.js";import{esm_exports as n,init_esm as r}from"./esm-C_RXU0lI.js";var i=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let i=(r(),t(n));async function a(){i.diag.debug(`could not read machine-id: unsupported platform`)}e.getMachineId=a}));export default i();export{};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__toCommonJS as t}from"./chunk-D9KrCrVq.js";import{esm_exports as n,init_esm as r}from"./esm-C_RXU0lI.js";var i=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let i=(r(),t(n));async function a(){i.diag.debug(`could not read machine-id: unsupported platform`)}e.getMachineId=a}));export default i();export{};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__toCommonJS as t}from"./chunk-D9KrCrVq.js";import{esm_exports as n,init_esm as r}from"./esm-C_RXU0lI.js";var i=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let i=(r(),t(n));async function a(){i.diag.debug(`could not read machine-id: unsupported platform`)}e.getMachineId=a}));export default i();export{};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__require as t,__toCommonJS as n}from"./chunk-D9KrCrVq.js";import{esm_exports as r,init_esm as i}from"./esm-C_RXU0lI.js";import{require_execAsync as a}from"./execAsync-Dv6XOE2I.js";var o=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let o=t(`process`),s=a(),c=(i(),n(r));async function l(){let e=`%windir%\\System32\\REG.exe`;o.arch===`ia32`&&`PROCESSOR_ARCHITEW6432`in o.env&&(e=`%windir%\\sysnative\\cmd.exe /c `+e);try{let t=(await(0,s.execAsync)(`${e} QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`)).stdout.split(`REG_SZ`);if(t.length===2)return t[1].trim()}catch(e){c.diag.debug(`error reading machine id: ${e}`)}}e.getMachineId=l}));export default o();export{};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__require as t,__toCommonJS as n}from"./chunk-D9KrCrVq.js";import{esm_exports as r,init_esm as i}from"./esm-C_RXU0lI.js";import{require_execAsync as a}from"./execAsync-CyP3Ojec.js";var o=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let o=t(`process`),s=a(),c=(i(),n(r));async function l(){let e=`%windir%\\System32\\REG.exe`;o.arch===`ia32`&&`PROCESSOR_ARCHITEW6432`in o.env&&(e=`%windir%\\sysnative\\cmd.exe /c `+e);try{let t=(await(0,s.execAsync)(`${e} QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`)).stdout.split(`REG_SZ`);if(t.length===2)return t[1].trim()}catch(e){c.diag.debug(`error reading machine id: ${e}`)}}e.getMachineId=l}));export default o();export{};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e,__require as t,__toCommonJS as n}from"./chunk-D9KrCrVq.js";import{esm_exports as r,init_esm as i}from"./esm-C_RXU0lI.js";import{require_execAsync as a}from"./execAsync-qNF4iDpO.js";var o=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let o=t(`process`),s=a(),c=(i(),n(r));async function l(){let e=`%windir%\\System32\\REG.exe`;o.arch===`ia32`&&`PROCESSOR_ARCHITEW6432`in o.env&&(e=`%windir%\\sysnative\\cmd.exe /c `+e);try{let t=(await(0,s.execAsync)(`${e} QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`)).stdout.split(`REG_SZ`);if(t.length===2)return t[1].trim()}catch(e){c.diag.debug(`error reading machine id: ${e}`)}}e.getMachineId=l}));export default o();export{};
@@ -1 +0,0 @@
1
- import{__toESM as e}from"./chunk-D9KrCrVq.js";import{findNearestEntry as t,migrateDataToBlink as n,require_main as r,resolveConfig as i}from"./util-k3x8m_i5.js";import"./dist-Ceoe3h7v.js";import{getAuthToken as a}from"./auth-DbpOUCTO.js";import"./util-CUfifM0g.js";import{ChatManager as o,Client as s}from"./chat-manager-GWR_v50X.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(),`.blink`,`chats`),v=new o({chatId:r?.chat,chatsDirectory:_,onError:e=>{console.error(`Error:`,e)}});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();console.log(`Final state:`,n.messages.pop())}finally{v.dispose(),h.dispose()}}export{_ as default};
@@ -1 +0,0 @@
1
- import{Client as e,Ie as t,M as n,Se as r,Y as i,ge as a,he as o,pD as s,ye as c}from"./dist-Ceoe3h7v.js";import{openUrl as l,source_default as u}from"./util-CUfifM0g.js";import{createDevhookID as d,createSlackApp as f,getDevhookID as p,hasDevhook as m}from"./create-slack-app-CyVPwWsG.js";import h from"crypto";import{basename as g,join as _}from"path";import{access as v,readFile as y,readdir as b,writeFile as x}from"fs/promises";import S from"node:util";function C(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}async function w(e){try{let t=await(await fetch(`https://slack.com/api/auth.test`,{method:`POST`,headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`}})).json();return t.ok?{valid:!0,botName:t.user}:{valid:!1,error:t.error||`Invalid bot token`}}catch(e){return{valid:!1,error:`Failed to verify credentials: ${e}`}}}function T(e,t,n,r){let i=Math.floor(Date.now()/1e3),a=parseInt(t,10);if(Math.abs(i-a)>300)return!1;let o=h.createHmac(`sha256`,e),s=`v0:${t}:${n}`;o.update(s);let c=`v0=${o.digest(`hex`)}`;return h.timingSafeEqual(Buffer.from(c),Buffer.from(r))}const E=e=>{if(!(typeof e==`object`&&e))throw Error(`Unable to make value disposable, it's not an object`);if(Symbol.dispose in e)return e;if(`dispose`in e&&typeof e.dispose==`function`)return e[Symbol.dispose]=()=>e.dispose(),e;throw Error(`Unable to make value disposable`)};async function D(e,t,n){let r=await y(e,`utf-8`);t&&(r=r.replace(/SLACK_BOT_TOKEN=.*/,`SLACK_BOT_TOKEN=${t}`)),n&&(r=r.replace(/SLACK_SIGNING_SECRET=.*/,`SLACK_SIGNING_SECRET=${n}`)),await x(e,r)}async function O(e){let t=await b(e);for(let[e,n]of[[`bun`,`bun.lock`],[`npm`,`package-lock.json`],[`pnpm`,`pnpm-lock.yaml`],[`yarn`,`yarn.lock`]])for(let r of t)if(r.includes(n))return e;return`npm`}async function k(t,h){try{var y=C();let b=h?.name||g(t).replace(/[^a-zA-Z0-9]/g,`-`),x=h?.packageManager||await O(t),k=_(t,`.env.local`);try{await v(k)}catch{n.error(`No .env.local file found in this directory. Please run this command from a Blink agent directory.`),r(`Slack app setup cancelled`);return}let A=await o({message:`What should your Slack app be called? This will be the name displayed in Slack. You can change it later.`,placeholder:b,defaultValue:b,validate:e=>{if(!e||e.trim().length===0)return`App name cannot be empty`}});if(s(A))return;let j=m(t)?p(t):d(t),M=`https://${j}.blink.host`;if(!j)throw Error(`Failed to obtain devhook ID`);n.info(`Starting webhook listener...`);let N=``,P=``,F=!1,I=``,L=``,R=!1,z,B=new e({baseURL:`https://blink.so`}),V=()=>{},H=e=>{},U=new Promise((e,t)=>{V=e,H=t}),W=B.devhook.listen({id:j,onRequest:async e=>{let t=await e.text(),r;try{r=JSON.parse(t)}catch{return new Response(`Invalid JSON`,{status:400})}if(r.type===`url_verification`)return n.info(`✓ Webhook challenge received`),new Response(JSON.stringify({challenge:r.challenge}),{headers:{"Content-Type":`application/json`}});if(N){let n=e.headers.get(`x-slack-signature`),i=e.headers.get(`x-slack-request-timestamp`);if(!n||!i)return new Response(`Missing signature`,{status:401});if(!T(N,i,t,n))return R=!0,r.event?.type===`message`&&r.event.channel_type===`im`&&!r.event.bot_id&&(z=r.event.channel),new Response(`Invalid signature`,{status:401})}return r.event?.type===`message`&&r.event.channel_type===`im`&&!r.event.bot_id&&(F=!0,I=r.event.channel,L=r.event.ts),new Response(`OK`)},onConnect:()=>{V()},onDisconnect:()=>{},onError:e=>{H(e)}});y.u(E(W));let G={display_information:{name:A.toString(),description:`A Blink agent for Slack`,background_color:`#4A154B`},features:{bot_user:{display_name:A.toString(),always_online:!0},app_home:{home_tab_enabled:!1,messages_tab_enabled:!0,messages_tab_read_only_enabled:!1},assistant_view:{assistant_description:`A helpful assistant powered by Blink`}},oauth_config:{scopes:{bot:[`app_mentions:read`,`assistant:write`,`reactions:write`,`reactions:read`,`channels:history`,`chat:write`,`groups:history`,`groups:read`,`files:read`,`im:history`,`im:read`,`im:write`,`mpim:history`,`mpim:read`,`users:read`,`links:read`,`commands`]}},settings:{event_subscriptions:{request_url:M,bot_events:[`app_mention`,`message.channels`,`message.groups`,`message.im`,`reaction_added`,`reaction_removed`,`assistant_thread_started`,`member_joined_channel`]},interactivity:{is_enabled:!0,request_url:M},token_rotation_enabled:!1,org_deploy_enabled:!1,socket_mode_enabled:!1}},K=f(G);n.info(`Please visit this URL to create your Slack app and return here after finishing:\n\n${u.gray(K)}\n`);let q=await c({message:`Open this URL in your browser automatically?`,initialValue:!0});if(s(q)){n.warn(`Skipping Slack app setup`);return}q&&await l(K,`Could not open the browser. Please visit the URL manually.`);let J=await o({message:`After creating the app, paste the App ID from the "Basic Information" page:`,placeholder:`A01234567AB`,validate:e=>{if(!e||e.trim().length===0)return`App ID is required`}});if(s(J)){n.warn(`Skipping Slack app setup`);return}if(N=await a({message:`Paste your Signing Secret from the same page:`,validate:e=>{if(!e||e.trim().length===0)return`Signing secret is required`}}),s(N)){n.warn(`Skipping Slack app setup`);return}let Y=!1;for(;!Y;){if(P=await a({message:`Install your app and paste your Bot Token from ${u.cyan(`https://api.slack.com/apps/${J}/install-on-team`)}`,validate:e=>{if(!e||e.trim().length===0)return`Bot token is required`}}),s(P)){n.warn(`Skipping Slack app setup`);return}let e=i();e.start(`Verifying bot token...`);let t=await w(P);if(t.valid)e.stop(`✓ Bot token verified!`),Y=!0;else{e.stop(`✗ Failed to verify bot token: ${t.error}`);let r=await c({message:`Would you like to try again?`,initialValue:!0});if(s(r)||!r){n.warn(`Skipping Slack app setup`);return}}}await D(k,P,N),n.success(`Credentials saved to .env.local`),await U;let X=i();X.start(`Try sending a DM to the bot on Slack - it's ${u.bold(u.cyan(A))} in the search bar.`);let Z={bun:`bun run dev`,npm:`npm run dev`,pnpm:`pnpm run dev`,yarn:`yarn dev`}[x];for(;!F;){if(R){if(X.stop(`✗ Invalid signing secret detected`),z&&P)try{await fetch(`https://slack.com/api/chat.postMessage`,{method:`POST`,headers:{Authorization:`Bearer ${P}`,"Content-Type":`application/json`},body:JSON.stringify({channel:z,text:`⚠️ There seems to be a problem with the signing secret. Please check the CLI for instructions on how to fix it.`})})}catch{}let e=await a({message:`The signing secret appears to be incorrect. Please paste the correct Signing Secret from ${u.cyan(`https://api.slack.com/apps/${J}/general`)}`,validate:e=>{if(!e||e.trim().length===0)return`Signing secret is required`}});if(s(e)){n.warn(`Skipping Slack app setup`);return}N=e,R=!1,z=void 0,await D(k,void 0,N),X.start(`Please try sending a DM to the bot again on Slack...`)}await new Promise(e=>setTimeout(e,500))}X.stop(u.green(`✓ DM received!`));try{await fetch(`https://slack.com/api/chat.postMessage`,{method:`POST`,headers:{Authorization:`Bearer ${P}`,"Content-Type":`application/json`},body:JSON.stringify({channel:I,thread_ts:L,text:`Congrats, your app is now installed and ready to use! Run \`${Z}\` to use your agent.`})})}catch(e){n.warn(`Could not send message to Slack: ${S.inspect(e)}`)}n.success(`Slack app setup complete!`)}catch(e){y.e=e}finally{y.d()}}async function A(e){e||=process.cwd(),t(`Setting up Slack app`),await k(e),process.exit(0)}export{k as setupSlackApp,A as setupSlackAppCommand};
@@ -1 +0,0 @@
1
- import"./token-error-COQY18OP.js";import{require_token_util as e}from"./token-util-KdD-UX1l.js";export default e();export{};
@@ -1 +0,0 @@
1
- import{require_undici as e}from"./undici-CRntNDHY.js";export default e();export{};
File without changes