blink 1.1.10 → 1.1.12
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/browser/agent/client/index.d.cts +2 -2
- package/dist/browser/agent/client/index.d.ts +2 -2
- package/dist/browser/agent/index.browser.d.cts +1 -1
- package/dist/browser/agent/index.browser.d.ts +1 -1
- package/dist/browser/{index-DUDNYE9g.d.ts → index-C-Slllhb.d.ts} +1 -1
- package/dist/browser/{index-Crila3ki.d.cts → index-DSU-sZKL.d.cts} +1 -1
- package/dist/browser/{index.browser-B7J1hNLv.d.cts → index.browser-DB9UGGdN.d.cts} +1 -1
- package/dist/browser/{index.browser-DTgCIWGS.d.ts → index.browser-yBhWIAxZ.d.ts} +1 -1
- package/dist/browser/react/index.browser.d.cts +2 -2
- package/dist/browser/react/index.browser.d.ts +2 -2
- package/dist/cli/{dev-s0j6vbYi.js → dev-HFrCUIkP.js} +1 -1
- package/dist/cli/index.js +3 -3
- package/dist/cli/init-Dll2PDYb.js +1108 -0
- package/dist/cli/init-Ii8ZeW1G.js +1 -0
- package/dist/node/agent/index.node.d.cts +1 -1
- package/dist/node/agent/index.node.d.ts +1 -1
- package/dist/node/{index.node-UFiKZRHB.d.cts → index.node-B6plkLLA.d.cts} +1 -1
- package/dist/node/{index.node-CiqENj_g.d.ts → index.node-qJt_7e9E.d.ts} +1 -1
- package/dist/node/react/index.node.cjs +5 -819
- package/dist/node/react/index.node.d.cts +1 -1
- package/dist/node/react/index.node.d.ts +1 -1
- package/dist/node/react/index.node.js +1 -408
- package/package.json +1 -1
- package/dist/cli/init-DYOLPWi7.js +0 -482
- package/dist/cli/init-lHUh7gYE.js +0 -1
|
@@ -257,414 +257,7 @@ for await (const chunk of exa.streamAnswer(query)) {
|
|
|
257
257
|
// Handle chunks
|
|
258
258
|
}`,400);let n=t?.outputSchema;n&&ov(n)&&(n=sv(n));let r={query:e,stream:!1,text:t?.text??!1,model:t?.model??`exa`,systemPrompt:t?.systemPrompt,outputSchema:n,userLocation:t?.userLocation};return await this.request(`/answer`,`POST`,r)}async*streamAnswer(e,t){let n=t?.outputSchema;n&&ov(n)&&(n=sv(n));let r={query:e,text:t?.text??!1,stream:!0,model:t?.model??`exa`,systemPrompt:t?.systemPrompt,outputSchema:n},i=await bv(this.baseURL+`/answer`,{method:`POST`,headers:this.headers,body:JSON.stringify(r)});if(!i.ok){let e=await i.text();throw new av(e,i.status,new Date().toISOString())}let a=i.body?.getReader();if(!a)throw new av(`No response body available for streaming.`,500,new Date().toISOString());let o=new TextDecoder,s=``;try{for(;;){let{done:e,value:t}=await a.read();if(e)break;s+=o.decode(t,{stream:!0});let n=s.split(`
|
|
259
259
|
`);s=n.pop()||``;for(let e of n){if(!e.startsWith(`data: `))continue;let t=e.replace(/^data:\s*/,``).trim();if(!t||t===`[DONE]`)continue;let n;try{n=JSON.parse(t)}catch{continue}let r=this.processChunk(n);(r.content||r.citations)&&(yield r)}}if(s.startsWith(`data: `)){let e=s.replace(/^data:\s*/,``).trim();if(e&&e!==`[DONE]`)try{let t=JSON.parse(e),n=this.processChunk(t);(n.content||n.citations)&&(yield n)}catch{}}}finally{a.releaseLock()}}processChunk(e){let t,n;return e.choices&&e.choices[0]&&e.choices[0].delta&&(t=e.choices[0].delta.content),e.citations&&e.citations!==`null`&&(n=e.citations.map(e=>({id:e.id,url:e.url,title:e.title,publishedDate:e.publishedDate,author:e.author,text:e.text}))),{content:t,citations:n}}async parseSSEStream(e){let t=e.body?.getReader();if(!t)throw new av(`No response body available for streaming.`,500,new Date().toISOString());let n=new TextDecoder,r=``;return new Promise(async(e,i)=>{try{for(;;){let{done:a,value:o}=await t.read();if(a)break;r+=n.decode(o,{stream:!0});let s=r.split(`
|
|
260
|
-
`);r=s.pop()||``;for(let n of s){if(!n.startsWith(`data: `))continue;let r=n.replace(/^data:\s*/,``).trim();if(!r||r===`[DONE]`)continue;let a;try{a=JSON.parse(r)}catch{continue}switch(a.tag){case`complete`:t.releaseLock(),e(a.data);return;case`error`:{let e=a.error?.message||`Unknown error`;t.releaseLock(),i(new av(e,500,new Date().toISOString()));return}default:break}}}i(new av(`Stream ended without a completion event.`,500,new Date().toISOString()))}catch(e){i(e)}finally{try{t.releaseLock()}catch{}}})}};const Cv=()=>{let e;if(process.env.EXA_API_KEY)e=new Sv(process.env.EXA_API_KEY);else if(process.env.BLINK_INVOCATION_AUTH_TOKEN)e=new Sv(process.env.BLINK_INVOCATION_AUTH_TOKEN,`https://blink.so/api/tools/exa`);else if(process.env.BLINK_TOKEN)e=new Sv(process.env.BLINK_TOKEN,`https://blink.so/api/tools/exa`);else throw console.warn(`You must set the EXA_API_KEY environment variable or be authenticated with Blink to use the web search SDK.`),Error(`The EXA_API_KEY environment variable or a Blink token must be set to use the web search SDK.`);return e},wv={web_search:Sg({description:`Perform a search query on the web, and retrieve the most relevant URLs/web data.`,inputSchema:y.z.object({query:y.z.string()}),execute:async({query:e})=>await Cv().searchAndContents(e,{numResults:5,type:`auto`,text:{maxCharacters:3e3},livecrawl:`preferred`})})},
|
|
261
|
-
|
|
262
|
-
You are an expert software engineer, which makes you an expert agent developer. You are highly idiomatic, opinionated, concise, and precise. The user prefers accuracy over speed.
|
|
263
|
-
|
|
264
|
-
<communication>
|
|
265
|
-
1. Be concise, direct, and to the point.
|
|
266
|
-
2. You are communicating via a terminal interface, so avoid verbosity, preambles, postambles, and unnecessary whitespace.
|
|
267
|
-
3. NEVER use emojis unless the user explicitly asks for them.
|
|
268
|
-
4. You must avoid text before/after your response, such as "The answer is" or "Short answer:", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...".
|
|
269
|
-
5. Mimic the style of the user's messages.
|
|
270
|
-
6. Do not remind the user you are happy to help.
|
|
271
|
-
7. Do not act with sycophantic flattery or over-the-top enthusiasm.
|
|
272
|
-
8. Do not regurgitate tool output. e.g. if a command succeeds, acknowledge briefly (e.g. "Done" or "Formatted").
|
|
273
|
-
9. *NEVER* create markdown files for the user - *always* guide the user through your efforts.
|
|
274
|
-
10. *NEVER* create example scripts for the user, or examples scripts for you to run. Leverage your tools to accomplish the user's goals.
|
|
275
|
-
</communication>
|
|
276
|
-
|
|
277
|
-
<goals>
|
|
278
|
-
Your method of assisting the user is by iterating their agent using the context provided by the user in run mode.
|
|
279
|
-
|
|
280
|
-
You can obtain additional context by leveraging web search and compute tools to read files, run commands, and search the web.
|
|
281
|
-
|
|
282
|
-
The user is *extremely happy* to provide additional context. They prefer this over you guessing, and then potentially getting it wrong.
|
|
283
|
-
|
|
284
|
-
<example>
|
|
285
|
-
user: i want a coding agent
|
|
286
|
-
assistant: Let me take a look at your codebase...
|
|
287
|
-
... tool calls to investigate the codebase...
|
|
288
|
-
assistant: I've created tools for linting, testing, and formatting. Hop back in run mode to use your agent! If you ever encounter undesired behavior from your agent, switch back to edit mode to refine your agent.
|
|
289
|
-
</example>
|
|
290
|
-
|
|
291
|
-
Always investigate the current state of the agent before assisting the user.
|
|
292
|
-
</goals>
|
|
293
|
-
|
|
294
|
-
<agent_development>
|
|
295
|
-
Agents are written in TypeScript, and mostly stored in a single \`agent.ts\` file. Complex agents will have multiple files, like a proper codebase.
|
|
296
|
-
|
|
297
|
-
Environment variables are stored in \`.env.local\` and \`.env.production\`. \`blink dev\` will hot-reload environment variable changes in \`.env.local\`.
|
|
298
|
-
|
|
299
|
-
Changes to the agent are hot-reloaded. As you make edits, the user can immediately try them in run mode.
|
|
300
|
-
|
|
301
|
-
1. *ALWAYS* use the package manager the user is using (inferred from lock files or \`process.argv\`).
|
|
302
|
-
2. You *MUST* use \`agent.store\` to persist state. The agent process is designed to be stateless.
|
|
303
|
-
3. Test your changes to the user's agent by using the \`message_user_agent\` tool. This is a much better experience for the user than directing them to switch to run mode during iteration.
|
|
304
|
-
4. Use console.log for debugging. The console output appears for the user.
|
|
305
|
-
5. Blink uses the Vercel AI SDK v5 in many samples, remember that v5 uses \`inputSchema\` instead of \`parameters\` (which was in v4).
|
|
306
|
-
6. Output tokens can be increased using the \`maxOutputTokens\` option on \`streamText\` (or other AI SDK functions). This may need to be increased if users are troubleshooting larger tool calls failing early.
|
|
307
|
-
7. Use the TypeScript language service tools (\`typescript_completions\`, \`typescript_quickinfo\`, \`typescript_definition\`, \`typescript_diagnostics\`) to understand APIs, discover available methods, check types, and debug errors. These tools use tsserver to provide IDE-like intelligence.
|
|
308
|
-
|
|
309
|
-
If the user is asking for a behavioral change, you should update the agent's system prompt.
|
|
310
|
-
This will not ensure the behavior, but it will guide the agent towards the desired behavior.
|
|
311
|
-
If the user needs 100% behavioral certainty, adjust tool behavior instead.
|
|
312
|
-
</agent_development>
|
|
313
|
-
|
|
314
|
-
<agent_web_requests>
|
|
315
|
-
Agents are HTTP servers, so they can handle web requests. This is commonly used to async-invoke an agent. e.g. for a Slack bot, messages are sent to the agent via a webhook.
|
|
316
|
-
|
|
317
|
-
Blink automatically creates a reverse-tunnel to your local machine for simple local development with external services (think Slack Bot, GitHub Bot, etc.).
|
|
318
|
-
|
|
319
|
-
To trigger chats based on web requests, use the \`agent.chat.upsert\` and \`agent.chat.message\` APIs.
|
|
320
|
-
</agent_web_requests>
|
|
321
|
-
|
|
322
|
-
<technical_knowledge>
|
|
323
|
-
Blink agents are Node.js HTTP servers built on the Vercel AI SDK:
|
|
324
|
-
|
|
325
|
-
\`\`\`typescript
|
|
326
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
327
|
-
import * as blink from "blink";
|
|
328
|
-
|
|
329
|
-
const agent = new blink.Agent();
|
|
330
|
-
|
|
331
|
-
agent.on("chat", async ({ messages, chat, abortSignal }) => {
|
|
332
|
-
return streamText({
|
|
333
|
-
model: blink.model("anthropic/claude-sonnet-4.5"),
|
|
334
|
-
system: "You are a helpful assistant.",
|
|
335
|
-
messages: convertToModelMessages(messages, {
|
|
336
|
-
ignoreIncompleteToolCalls: true,
|
|
337
|
-
}),
|
|
338
|
-
tools: { /* your tools */ },
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
agent.on("request", async (request) => {
|
|
343
|
-
// Handle webhooks, OAuth callbacks, etc.
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
agent.serve();
|
|
347
|
-
\`\`\`
|
|
348
|
-
|
|
349
|
-
Event Handlers:
|
|
350
|
-
|
|
351
|
-
**\`agent.on("chat", handler)\`**
|
|
352
|
-
1. Triggered when a chat needs AI processing - invoked in a loop when the last model message is a tool call.
|
|
353
|
-
2. Must return: \`streamText()\` result, \`Response\`, \`ReadableStream<UIMessageChunk>\`, or \`void\`
|
|
354
|
-
3. Parameters: \`messages\`, \`id\`, \`abortSignal\`
|
|
355
|
-
|
|
356
|
-
*NEVER* use "maxSteps" from the Vercel AI SDK. It is unnecessary and will cause a worse experience for the user.
|
|
357
|
-
|
|
358
|
-
**\`agent.on("request", handler)\`**
|
|
359
|
-
• Handles raw HTTP requests before Blink processes them
|
|
360
|
-
• Use for: OAuth callbacks, webhook verification, custom endpoints
|
|
361
|
-
• Return \`Response\` to handle, or \`void\` to pass through
|
|
362
|
-
|
|
363
|
-
**\`agent.on("ui", handler)\`**
|
|
364
|
-
• Provides dynamic UI options for chat interfaces
|
|
365
|
-
• Returns schema defining user-selectable options
|
|
366
|
-
|
|
367
|
-
**\`agent.on("error", handler)\`**
|
|
368
|
-
• Global error handler for the agent
|
|
369
|
-
|
|
370
|
-
Chat Management:
|
|
371
|
-
|
|
372
|
-
Blink automatically manages chat state:
|
|
373
|
-
|
|
374
|
-
\`\`\`typescript
|
|
375
|
-
// Create or get existing chat
|
|
376
|
-
// The parameter can be any JSON-serializable value.
|
|
377
|
-
// e.g. for a Slack bot to preserve context in a thread, you might use: ["slack", teamId, channelId, threadTs]
|
|
378
|
-
const chat = await agent.chat.upsert("unique-key");
|
|
379
|
-
|
|
380
|
-
// Send a message to a chat
|
|
381
|
-
await agent.chat.sendMessages(chat.id, [{
|
|
382
|
-
role: "user",
|
|
383
|
-
parts: [{ type: "text", text: "Message" }],
|
|
384
|
-
}], {
|
|
385
|
-
behavior: "interrupt" | "enqueue" | "append"
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
// When sending messages, feel free to inject additional parts to direct the model.
|
|
389
|
-
// e.g. if the user is asking for specific behavior in specific scenarios, the simplest
|
|
390
|
-
// answer is to append a text part: "always do X when Y".
|
|
391
|
-
\`\`\`
|
|
392
|
-
|
|
393
|
-
Behaviors:
|
|
394
|
-
• "interrupt": Stop current processing and handle immediately
|
|
395
|
-
• "enqueue": Queue message, process when current chat finishes
|
|
396
|
-
• "append": Add to history without triggering processing
|
|
397
|
-
|
|
398
|
-
Chat keys: Use structured keys like \`"slack-\${teamId}-\${channelId}-\${threadTs}"\` for uniqueness.
|
|
399
|
-
|
|
400
|
-
Storage API:
|
|
401
|
-
|
|
402
|
-
Persistent key-value storage per agent:
|
|
403
|
-
|
|
404
|
-
\`\`\`typescript
|
|
405
|
-
// Store data
|
|
406
|
-
await agent.store.set("key", "value", { ttl: 3600 });
|
|
407
|
-
|
|
408
|
-
// Retrieve data
|
|
409
|
-
const value = await agent.store.get("key");
|
|
410
|
-
|
|
411
|
-
// Delete data
|
|
412
|
-
await agent.store.delete("key");
|
|
413
|
-
|
|
414
|
-
// List keys by prefix
|
|
415
|
-
const result = await agent.store.list("prefix-", { limit: 100 });
|
|
416
|
-
\`\`\`
|
|
417
|
-
|
|
418
|
-
Common uses: OAuth tokens, user preferences, caching, chat-resource associations.
|
|
419
|
-
|
|
420
|
-
Tools:
|
|
421
|
-
|
|
422
|
-
Tools follow Vercel AI SDK patterns with Zod validation:
|
|
423
|
-
|
|
424
|
-
\`\`\`typescript
|
|
425
|
-
import { tool } from "ai";
|
|
426
|
-
import { z } from "zod";
|
|
427
|
-
|
|
428
|
-
const myTool = tool({
|
|
429
|
-
description: "Clear description of what this tool does",
|
|
430
|
-
inputSchema: z.object({
|
|
431
|
-
param: z.string().describe("Parameter description"),
|
|
432
|
-
}),
|
|
433
|
-
execute: async (args, opts) => {
|
|
434
|
-
// opts.abortSignal for cancellation
|
|
435
|
-
// opts.toolCallId for unique identification
|
|
436
|
-
return result;
|
|
437
|
-
},
|
|
438
|
-
});
|
|
439
|
-
\`\`\`
|
|
440
|
-
|
|
441
|
-
Tool Approvals for destructive operations:
|
|
442
|
-
|
|
443
|
-
\`\`\`typescript
|
|
444
|
-
...await blink.tools.withApproval({
|
|
445
|
-
messages,
|
|
446
|
-
tools: {
|
|
447
|
-
delete_database: tool({ /* ... */ }),
|
|
448
|
-
},
|
|
449
|
-
})
|
|
450
|
-
\`\`\`
|
|
451
|
-
|
|
452
|
-
Tool Context for dependency injection:
|
|
453
|
-
|
|
454
|
-
\`\`\`typescript
|
|
455
|
-
...blink.tools.withContext(github.tools, {
|
|
456
|
-
accessToken: process.env.GITHUB_TOKEN,
|
|
457
|
-
})
|
|
458
|
-
\`\`\`
|
|
459
|
-
|
|
460
|
-
Tool Prefixing to avoid collisions:
|
|
461
|
-
|
|
462
|
-
\`\`\`typescript
|
|
463
|
-
...blink.tools.prefix(github.tools, "github_")
|
|
464
|
-
\`\`\`
|
|
465
|
-
|
|
466
|
-
LLM Models:
|
|
467
|
-
|
|
468
|
-
**Option 1: Blink Gateway** (Quick Start)
|
|
469
|
-
\`\`\`typescript
|
|
470
|
-
model: blink.model("anthropic/claude-sonnet-4.5")
|
|
471
|
-
model: blink.model("openai/gpt-5")
|
|
472
|
-
\`\`\`
|
|
473
|
-
Requires: \`blink login\` or \`BLINK_TOKEN\` env var
|
|
474
|
-
|
|
475
|
-
**Option 2: Direct Provider** (Production Recommended)
|
|
476
|
-
\`\`\`typescript
|
|
477
|
-
import { anthropic } from "@ai-sdk/anthropic";
|
|
478
|
-
import { openai } from "@ai-sdk/openai";
|
|
479
|
-
|
|
480
|
-
model: anthropic("claude-sonnet-4.5", { apiKey: process.env.ANTHROPIC_API_KEY })
|
|
481
|
-
model: openai("gpt-5", { apiKey: process.env.OPENAI_API_KEY })
|
|
482
|
-
\`\`\`
|
|
483
|
-
|
|
484
|
-
**Note about Edit Mode:** Edit mode (this agent) automatically selects models in this priority:
|
|
485
|
-
1. If \`ANTHROPIC_API_KEY\` is set: uses \`claude-sonnet-4.5\` via \`@ai-sdk/anthropic\`
|
|
486
|
-
2. If \`OPENAI_API_KEY\` is set: uses \`gpt-5\` via \`@ai-sdk/openai\`
|
|
487
|
-
3. Otherwise: falls back to \`blink.model("anthropic/claude-sonnet-4.5")\`
|
|
488
|
-
|
|
489
|
-
Available SDKs:
|
|
490
|
-
|
|
491
|
-
**@blink-sdk/compute**
|
|
492
|
-
\`\`\`typescript
|
|
493
|
-
import * as compute from "@blink-sdk/compute";
|
|
494
|
-
|
|
495
|
-
tools: {
|
|
496
|
-
...compute.tools, // execute_bash, read_file, write_file, edit_file, process management
|
|
497
|
-
}
|
|
498
|
-
\`\`\`
|
|
499
|
-
|
|
500
|
-
**@blink-sdk/github**
|
|
501
|
-
\`\`\`typescript
|
|
502
|
-
import * as github from "@blink-sdk/github";
|
|
503
|
-
|
|
504
|
-
tools: {
|
|
505
|
-
...blink.tools.withContext(github.tools, {
|
|
506
|
-
accessToken: process.env.GITHUB_TOKEN,
|
|
507
|
-
}),
|
|
508
|
-
}
|
|
509
|
-
\`\`\`
|
|
510
|
-
|
|
511
|
-
**@blink-sdk/slack**
|
|
512
|
-
\`\`\`typescript
|
|
513
|
-
import * as slack from "@blink-sdk/slack";
|
|
514
|
-
import { App } from "@slack/bolt";
|
|
515
|
-
|
|
516
|
-
const receiver = new slack.Receiver();
|
|
517
|
-
const app = new App({
|
|
518
|
-
token: process.env.SLACK_BOT_TOKEN,
|
|
519
|
-
signingSecret: process.env.SLACK_SIGNING_SECRET,
|
|
520
|
-
receiver,
|
|
521
|
-
})
|
|
522
|
-
|
|
523
|
-
// This will trigger when the bot is @mentioned.
|
|
524
|
-
app.event("app_mention", async ({ event }) => {
|
|
525
|
-
// The argument here is a JSON-serializable value.
|
|
526
|
-
// To maintain the same chat context, use the same key.
|
|
527
|
-
const chat = await agent.chat.upsert([
|
|
528
|
-
"slack",
|
|
529
|
-
event.channel,
|
|
530
|
-
event.thread_ts ?? event.ts,
|
|
531
|
-
]);
|
|
532
|
-
const { message } = await slack.createMessageFromEvent({
|
|
533
|
-
client: app.client,
|
|
534
|
-
event,
|
|
535
|
-
});
|
|
536
|
-
await agent.chat.sendMessages(chat.id, [message]);
|
|
537
|
-
// This is a nice immediate indicator for the user.
|
|
538
|
-
await app.client.assistant.threads.setStatus({
|
|
539
|
-
channel_id: event.channel,
|
|
540
|
-
status: "is typing...",
|
|
541
|
-
thread_ts: event.thread_ts ?? event.ts,
|
|
542
|
-
})
|
|
543
|
-
})
|
|
544
|
-
|
|
545
|
-
const agent = new blink.Agent();
|
|
546
|
-
|
|
547
|
-
agent.on("request", async (request) => {
|
|
548
|
-
return receiver.handle(app, request);
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
agent.on("chat", async ({ messages }) => {
|
|
552
|
-
const tools = slack.createTools({ client: app.client });
|
|
553
|
-
return streamText({
|
|
554
|
-
model: blink.model("anthropic/claude-sonnet-4.5"),
|
|
555
|
-
system: "You chatting with users in Slack.",
|
|
556
|
-
messages: convertToModelMessages(messages, {
|
|
557
|
-
ignoreIncompleteToolCalls: true,
|
|
558
|
-
tools,
|
|
559
|
-
}),
|
|
560
|
-
});
|
|
561
|
-
})
|
|
562
|
-
\`\`\`
|
|
563
|
-
|
|
564
|
-
Slack SDK Notes:
|
|
565
|
-
- "app_mention" event is triggered in both private channels and public channels.
|
|
566
|
-
- "message" event is triggered regardless of being mentioned or not, and will *also* be fired when "app_mention" is triggered.
|
|
567
|
-
- *NEVER* register app event listeners in the "on" handler of the agent. This will cause the handler to be called multiple times.
|
|
568
|
-
- Think about how you scope chats - for example, in IMs or if the user wants to make a bot for a whole channel, you would not want to add "ts" or "thread_ts" to the chat key.
|
|
569
|
-
- When using "assistant.threads.setStatus", you need to ensure the status of that same "thread_ts" is cleared. You can do this by inserting a message part that directs the agent to clear the status (there is a tool if using @blink-sdk/slack called "reportStatus" that does this). e.g. \`message.parts.push({ type: "text", text: "*INTERNAL INSTRUCTION*: Clear the status of this thread after you finish: channel=\${channel} thread_ts=\${thread_ts}" })\`
|
|
570
|
-
- The Slack SDK has many functions that allow users to completely customize the message format. If the user asks for customization, look at the types for @blink-sdk/slack - specifically: "createPartsFromMessageMetadata", "createMessageFromEvent", and "extractMessagesMetadata".
|
|
571
|
-
|
|
572
|
-
Slack App Manifest:
|
|
573
|
-
- *ALWAYS* include the "assistant:write" scope unless the user explicitly states otherwise - this allows Slack apps to set their status, which makes for a significantly better user experience. You *MUST* provide "assistant_view" if you provide this scope.
|
|
574
|
-
- The user can always edit the manifest after creation, but you'd have to suggest it to them.
|
|
575
|
-
- "oauth_config" MUST BE PROVIDED - otherwise the app will have NO ACCESS.
|
|
576
|
-
- *ALWAYS* default "token_rotation_enabled" to false unless the user explicitly asks for it. It is a *much* simpler user-experience to not rotate tokens.
|
|
577
|
-
- For the best user experience, default to the following bot scopes (in the "oauth_config" > "scopes" > "bot"):
|
|
578
|
-
- "app_mentions:read"
|
|
579
|
-
- "reactions:write"
|
|
580
|
-
- "reactions:read"
|
|
581
|
-
- "channels:history"
|
|
582
|
-
- "chat:write"
|
|
583
|
-
- "groups:history"
|
|
584
|
-
- "groups:read"
|
|
585
|
-
- "files:read"
|
|
586
|
-
- "im:history"
|
|
587
|
-
- "im:read"
|
|
588
|
-
- "im:write"
|
|
589
|
-
- "mpim:history"
|
|
590
|
-
- "mpim:read"
|
|
591
|
-
- "users:read"
|
|
592
|
-
- "links:read"
|
|
593
|
-
- "commands"
|
|
594
|
-
- For the best user experience, default to the following bot events (in the "settings" > "event_subscriptions" > "bot_events"):
|
|
595
|
-
- "app_mention"
|
|
596
|
-
- "message.channels",
|
|
597
|
-
- "message.groups",
|
|
598
|
-
- "message.im",
|
|
599
|
-
- "reaction_added"
|
|
600
|
-
- "reaction_removed"
|
|
601
|
-
- "assistant_thread_started"
|
|
602
|
-
- "member_joined_channel"
|
|
603
|
-
- *NEVER* include USER SCOPES unless the user explicitly asks for them.
|
|
604
|
-
|
|
605
|
-
WARNING: Beware of attaching multiple event listeners to the same chat. This could cause the agent to respond multiple times.
|
|
606
|
-
|
|
607
|
-
**@blink-sdk/web-search**
|
|
608
|
-
\`\`\`typescript
|
|
609
|
-
import * as webSearch from "@blink-sdk/web-search";
|
|
610
|
-
|
|
611
|
-
tools: {
|
|
612
|
-
...webSearch.tools,
|
|
613
|
-
}
|
|
614
|
-
\`\`\`
|
|
615
|
-
|
|
616
|
-
State Management:
|
|
617
|
-
|
|
618
|
-
Blink agents are short-lived HTTP servers that restart on code changes and do not persist in-memory state between requests.
|
|
619
|
-
|
|
620
|
-
*NEVER* use module-level Maps, Sets, or variables to store state (e.g. \`const activeBots = new Map()\`).
|
|
621
|
-
|
|
622
|
-
For global state persistence, you can use the agent store:
|
|
623
|
-
- Use \`agent.store\` for persistent key-value storage
|
|
624
|
-
- Query external APIs to fetch current state
|
|
625
|
-
- Use webhooks to trigger actions rather than polling in-memory state
|
|
626
|
-
|
|
627
|
-
For message-level state persistence, use message metadata:
|
|
628
|
-
\`\`\`typescript
|
|
629
|
-
import { UIMessage } from "blink";
|
|
630
|
-
import * as blink from "blink";
|
|
631
|
-
|
|
632
|
-
const agent = new blink.Agent<UIMessage<{
|
|
633
|
-
source: "github";
|
|
634
|
-
associated_id: string;
|
|
635
|
-
}>>();
|
|
636
|
-
|
|
637
|
-
agent.on("request", async (request) => {
|
|
638
|
-
// comes from github, we want to do something deterministic in the chat loop with that ID...
|
|
639
|
-
// insert a message with that metadata into the chat
|
|
640
|
-
const chat = await agent.chat.upsert("some-github-key");
|
|
641
|
-
await agent.chat.sendMessages(request.chat.id, [{
|
|
642
|
-
role: "user",
|
|
643
|
-
parts: [{
|
|
644
|
-
type: "text",
|
|
645
|
-
text: "example",
|
|
646
|
-
}],
|
|
647
|
-
metadata: {
|
|
648
|
-
source: "github",
|
|
649
|
-
associated_id: "some-github-id",
|
|
650
|
-
}
|
|
651
|
-
}])
|
|
652
|
-
})
|
|
653
|
-
|
|
654
|
-
agent.on("chat", async ({ messages }) => {
|
|
655
|
-
const message = messages.find(message => message.metadata?.source === "github")
|
|
656
|
-
|
|
657
|
-
// Now we can use that metadata...
|
|
658
|
-
})
|
|
659
|
-
\`\`\`
|
|
660
|
-
|
|
661
|
-
The agent process can restart at any time, so all important state must be externalized.
|
|
662
|
-
</technical_knowledge>
|
|
663
|
-
|
|
664
|
-
<code_quality>
|
|
665
|
-
- Never use "as any" type assertions. Always figure out the correct typings.
|
|
666
|
-
</code_quality>
|
|
667
|
-
`;function Ev(e,t,r){let i,a=m.default.createServer(n.createServerAdapter(async n=>{let o=new URL(n.url,i);if(o.pathname!==`/`)return new Response(`Not found`,{status:404});let s=o.searchParams.get(`code`);if(s)try{let e=await fetch(`https://api.github.com/app-manifests/${s}/conversions`,{method:`POST`,headers:{Accept:`application/vnd.github+json`,"User-Agent":`blink.so`,"X-GitHub-Api-Version":`2022-11-28`}});if(!e.ok){let t=await e.text();throw Error(`GitHub API error: ${e.status} ${e.statusText}${t?` - ${t}`:``}`)}let t=await e.json();return await r?.(null,t),new Response(`GitHub App created successfully! Return to your terminal to continue.`,{headers:{"Content-Type":`text/plain`}})}catch(e){let t=e instanceof Error?e:Error(String(e));try{await r?.(t,null)}catch(e){t=e instanceof Error?e:Error(String(e))}let n=t.message;return new Response(`Error: ${n}\n\nReturn to your terminal for more details.`,{status:500,headers:{"Content-Type":`text/plain`}})}finally{a.close()}let c={...e,redirect_url:i},l=`<!DOCTYPE html>
|
|
260
|
+
`);r=s.pop()||``;for(let n of s){if(!n.startsWith(`data: `))continue;let r=n.replace(/^data:\s*/,``).trim();if(!r||r===`[DONE]`)continue;let a;try{a=JSON.parse(r)}catch{continue}switch(a.tag){case`complete`:t.releaseLock(),e(a.data);return;case`error`:{let e=a.error?.message||`Unknown error`;t.releaseLock(),i(new av(e,500,new Date().toISOString()));return}default:break}}}i(new av(`Stream ended without a completion event.`,500,new Date().toISOString()))}catch(e){i(e)}finally{try{t.releaseLock()}catch{}}})}};const Cv=()=>{let e;if(process.env.EXA_API_KEY)e=new Sv(process.env.EXA_API_KEY);else if(process.env.BLINK_INVOCATION_AUTH_TOKEN)e=new Sv(process.env.BLINK_INVOCATION_AUTH_TOKEN,`https://blink.so/api/tools/exa`);else if(process.env.BLINK_TOKEN)e=new Sv(process.env.BLINK_TOKEN,`https://blink.so/api/tools/exa`);else throw console.warn(`You must set the EXA_API_KEY environment variable or be authenticated with Blink to use the web search SDK.`),Error(`The EXA_API_KEY environment variable or a Blink token must be set to use the web search SDK.`);return e},wv={web_search:Sg({description:`Perform a search query on the web, and retrieve the most relevant URLs/web data.`,inputSchema:y.z.object({query:y.z.string()}),execute:async({query:e})=>await Cv().searchAndContents(e,{numResults:5,type:`auto`,text:{maxCharacters:3e3},livecrawl:`preferred`})})};function Tv(e,t,r){let i,a=m.default.createServer(n.createServerAdapter(async n=>{let o=new URL(n.url,i);if(o.pathname!==`/`)return new Response(`Not found`,{status:404});let s=o.searchParams.get(`code`);if(s)try{let e=await fetch(`https://api.github.com/app-manifests/${s}/conversions`,{method:`POST`,headers:{Accept:`application/vnd.github+json`,"User-Agent":`blink.so`,"X-GitHub-Api-Version":`2022-11-28`}});if(!e.ok){let t=await e.text();throw Error(`GitHub API error: ${e.status} ${e.statusText}${t?` - ${t}`:``}`)}let t=await e.json();return await r?.(null,t),new Response(`GitHub App created successfully! Return to your terminal to continue.`,{headers:{"Content-Type":`text/plain`}})}catch(e){let t=e instanceof Error?e:Error(String(e));try{await r?.(t,null)}catch(e){t=e instanceof Error?e:Error(String(e))}let n=t.message;return new Response(`Error: ${n}\n\nReturn to your terminal for more details.`,{status:500,headers:{"Content-Type":`text/plain`}})}finally{a.close()}let c={...e,redirect_url:i},l=`<!DOCTYPE html>
|
|
668
261
|
<html>
|
|
669
262
|
<body>
|
|
670
263
|
<form id="f" method="POST" action="${t?`https://github.com/organizations/${t}/settings/apps/new`:`https://github.com/settings/apps/new`}">
|
|
@@ -672,7 +265,7 @@ The agent process can restart at any time, so all important state must be extern
|
|
|
672
265
|
</form>
|
|
673
266
|
<script>document.getElementById('f').submit()<\/script>
|
|
674
267
|
</body>
|
|
675
|
-
</html>`;return new Response(l,{headers:{"Content-Type":`text/html`}})}));return new Promise((e,t)=>{a.on(`error`,t),a.listen(0,`127.0.0.1`,()=>{let n=a.address();if(!n||typeof n==`string`){t(Error(`Failed to get server address`));return}i=`http://127.0.0.1:${n.port}`,e(i)})})}const Dv=y.z.enum([`read`,`write`]),Ov=y.z.union([y.z.literal(`branch_protection_rule`).describe(`Branch protection rule created, edited, or deleted`),y.z.literal(`check_run`).describe(`Check run created, completed, or requested`),y.z.literal(`check_suite`).describe(`Check suite completed or requested`),y.z.literal(`code_scanning_alert`).describe(`Code scanning alert created, fixed, or reopened`),y.z.literal(`commit_comment`).describe(`Commit comment created`),y.z.literal(`create`).describe(`Branch or tag created`),y.z.literal(`delete`).describe(`Branch or tag deleted`),y.z.literal(`deployment`).describe(`Deployment created`),y.z.literal(`deployment_status`).describe(`Deployment status created`),y.z.literal(`deployment_protection_rule`).describe(`Deployment protection rule requested`),y.z.literal(`discussion`).describe(`Discussion created, edited, or deleted`),y.z.literal(`discussion_comment`).describe(`Discussion comment created, edited, or deleted`),y.z.literal(`fork`).describe(`Repository forked`),y.z.literal(`gollum`).describe(`Wiki page created or updated`),y.z.literal(`issue_comment`).describe(`Issue comment created, edited, or deleted`),y.z.literal(`issues`).describe(`Issue opened, edited, closed, or labeled`),y.z.literal(`label`).describe(`Label created, edited, or deleted`),y.z.literal(`member`).describe(`Collaborator added, removed, or edited`),y.z.literal(`membership`).describe(`Team membership added or removed`),y.z.literal(`meta`).describe(`GitHub App webhook configuration changed`),y.z.literal(`milestone`).describe(`Milestone created, closed, or deleted`),y.z.literal(`organization`).describe(`Organization member added, removed, or invited`),y.z.literal(`org_block`).describe(`Organization blocked or unblocked a user`),y.z.literal(`package`).describe(`Package published or updated`),y.z.literal(`page_build`).describe(`GitHub Pages site built`),y.z.literal(`project`).describe(`Project created, updated, or deleted`),y.z.literal(`project_card`).describe(`Project card created, edited, or deleted`),y.z.literal(`project_column`).describe(`Project column created, updated, or deleted`),y.z.literal(`public`).describe(`Repository visibility changed to public`),y.z.literal(`pull_request`).describe(`Pull request opened, closed, edited, or synchronized`),y.z.literal(`pull_request_review`).describe(`Pull request review submitted, edited, or dismissed`),y.z.literal(`pull_request_review_comment`).describe(`Pull request review comment created or edited`),y.z.literal(`pull_request_review_thread`).describe(`Pull request review thread resolved or unresolved`),y.z.literal(`push`).describe(`Git push to a repository`),y.z.literal(`registry_package`).describe(`Registry package published or updated`),y.z.literal(`release`).describe(`Release published or edited`),y.z.literal(`repository`).describe(`Repository created, deleted, archived, or publicized`),y.z.literal(`repository_dispatch`).describe(`Custom webhook event triggered`),y.z.literal(`secret_scanning_alert`).describe(`Secret scanning alert created or resolved`),y.z.literal(`security_and_analysis`).describe(`Security features enabled or disabled`),y.z.literal(`star`).describe(`Repository starred or unstarred`),y.z.literal(`status`).describe(`Commit status created`),y.z.literal(`team`).describe(`Team created, deleted, or edited`),y.z.literal(`team_add`).describe(`Repository added to team`),y.z.literal(`watch`).describe(`User started watching repository`),y.z.literal(`workflow_dispatch`).describe(`Workflow manually triggered`),y.z.literal(`workflow_job`).describe(`Workflow job queued, started, or completed`),y.z.literal(`workflow_run`).describe(`Workflow run requested or completed`)]),kv=y.z.object({name:y.z.string().optional().describe(`The name of the GitHub App. Leave blank to let the user name it on GitHub.`),url:y.z.url().describe(`The homepage URL of the GitHub App. If unknown, set to https://blink.so.`),description:y.z.string().optional().describe(`The description of the GitHub App.`),public:y.z.boolean().optional().describe(`Whether the GitHub App is public. Always default to false unless the user explicitly requests otherwise.`),hook_attributes:y.z.object({url:y.z.url(),active:y.z.boolean().optional().default(!0)}).optional().describe(`The webhook configuration for the GitHub App.`),callback_urls:y.z.array(y.z.url()).max(10).optional().describe(`Callback URLs for the GitHub App after the user authenticates with GitHub.`),setup_url:y.z.url().optional().describe(`The URL to redirect the user to after they install the GitHub App.`),setup_on_update:y.z.boolean().optional().describe(`Whether to redirect the user to the setup URL after an update to the installed app.`),request_oauth_on_install:y.z.boolean().optional().describe(`Whether to request OAuth on install.`),default_events:y.z.array(Ov).optional().describe(`Webhook events sent to the webhook URL.`),default_permissions:y.z.record(y.z.string(),Dv).optional().describe(`Repository and organization permissions for the GitHub App. Available permissions: actions (GitHub Actions workflows), administration (repository settings), checks (check runs), contents (repository code), deployments, environments, issues, metadata (always granted), packages, pages, pull_requests, repository_hooks (webhooks), repository_projects, secret_scanning_alerts, secrets (Actions secrets), security_events (code scanning/Dependabot), single_file, statuses (commit statuses), vulnerability_alerts (Dependabot), workflows (workflow files), members (collaborators). Values can be 'read' or 'write'.`)});function Av(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const jv=y.z.union([y.z.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),y.z.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),y.z.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),y.z.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),y.z.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),y.z.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),y.z.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),y.z.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),y.z.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),y.z.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),y.z.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),y.z.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),y.z.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),y.z.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),y.z.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),y.z.literal(`file_created`).describe(`File was created. Requires scope: files:read`),y.z.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),y.z.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),y.z.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),y.z.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),y.z.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),y.z.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),y.z.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),y.z.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),y.z.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),y.z.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),y.z.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),y.z.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),y.z.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),y.z.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),y.z.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),y.z.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),y.z.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),y.z.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),y.z.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),Mv=y.z.union([y.z.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),y.z.literal(`assistant:write`).describe(`Update bot status and write assistant messages. This should *always* be included for Slack bots. It improves the UX dramatically for users. Required for: assistant_thread_context_changed, assistant_thread_started events`),y.z.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),y.z.literal(`channels:join`).describe(`Join public channels`),y.z.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),y.z.literal(`channels:read`).describe(`View basic information about public channels. Required for: channel_archive, channel_created, channel_deleted, channel_rename, channel_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`chat:write`).describe(`Send messages as the bot`),y.z.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),y.z.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),y.z.literal(`commands`).describe(`Add and use slash commands`),y.z.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),y.z.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),y.z.literal(`files:read`).describe(`View files shared in channels and conversations. Required for: file_change, file_created, file_deleted, file_public, file_shared, file_unshared events`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files`),y.z.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),y.z.literal(`groups:read`).describe(`View basic information about private channels. Required for: group_archive, group_deleted, group_rename, group_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),y.z.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),y.z.literal(`im:read`).describe(`View basic information about direct messages with the bot`),y.z.literal(`im:write`).describe(`Start and manage direct messages with users`),y.z.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),y.z.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),y.z.literal(`metadata.message:read`).describe(`Read message metadata`),y.z.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),y.z.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),y.z.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),y.z.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),y.z.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),y.z.literal(`reminders:read`).describe(`View reminders created by the bot`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders`),y.z.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),y.z.literal(`usergroups:read`).describe(`View user groups and their members`),y.z.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),y.z.literal(`users.profile:read`).describe(`View profile information about users`),y.z.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),y.z.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),y.z.literal(`users:write`).describe(`Set presence and status for the bot user`)]),Nv=y.z.union([y.z.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),y.z.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),y.z.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),y.z.literal(`chat:write`).describe(`Send messages on behalf of the user`),y.z.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),y.z.literal(`files:read`).describe(`View files on behalf of the user`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),y.z.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),y.z.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),y.z.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),y.z.literal(`im:history`).describe(`Read direct message history on behalf of the user`),y.z.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),y.z.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),y.z.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),y.z.literal(`links:write`).describe(`Show URL previews on behalf of the user`),y.z.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),y.z.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),y.z.literal(`pins:read`).describe(`View pinned items on behalf of the user`),y.z.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),y.z.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),y.z.literal(`reminders:read`).describe(`View reminders on behalf of the user`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),y.z.literal(`search:read`).describe(`Search messages and files on behalf of the user`),y.z.literal(`stars:read`).describe(`View starred items on behalf of the user`),y.z.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),y.z.literal(`team:read`).describe(`View workspace information on behalf of the user`),y.z.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),y.z.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),y.z.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),y.z.literal(`users.profile:write`).describe(`Edit the user's profile information`),y.z.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),y.z.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),y.z.literal(`users:write`).describe(`Set presence for the user`)]),Pv=y.z.object({display_information:y.z.object({name:y.z.string().describe(`The name of the Slack app.`),description:y.z.string().optional().describe(`A short description of the app.`),background_color:y.z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:y.z.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:y.z.object({bot_user:y.z.object({display_name:y.z.string().describe(`The display name for the bot user.`),always_online:y.z.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:y.z.object({home_tab_enabled:y.z.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:y.z.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:y.z.boolean().optional().describe(`Make the Messages tab read-only.`)}).optional().describe(`Configuration for the App Home. If specified, the "bot" scope is *REQUIRED*.`),assistant_view:y.z.object({assistant_description:y.z.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:y.z.array(y.z.object({command:y.z.string().regex(/^\//).describe(`The command (must start with /).`),description:y.z.string().describe(`Description of the command.`),usage_hint:y.z.string().optional().describe(`Usage hint for the command.`),should_escape:y.z.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:y.z.array(y.z.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:y.z.object({redirect_urls:y.z.array(y.z.url()).optional().describe(`OAuth redirect URLs.`),scopes:y.z.object({bot:y.z.array(y.z.union([Mv,y.z.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:y.z.array(y.z.union([Nv,y.z.string()])).optional().describe(`User scopes required by the app. Each scope defines specific permissions for actions performed on behalf of users.`)}).describe(`OAuth scopes for bot and user tokens.`)}).describe(`OAuth configuration for the Slack app.`),settings:y.z.object({event_subscriptions:y.z.object({request_url:y.z.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:y.z.array(y.z.union([jv,y.z.string()])).optional().describe(`Bot events to subscribe to. Each event notifies your app when specific actions occur in the workspace.`)}).optional().describe(`Event subscriptions configuration.`),interactivity:y.z.object({is_enabled:y.z.boolean().describe(`Enable interactivity.`),request_url:y.z.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:y.z.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:y.z.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:y.z.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:y.z.boolean().optional().default(!1).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function Fv(e){let t=new n.Agent,i,a;return t.on(`chat`,async({id:a,messages:s,abortSignal:c})=>{let l=s.findLastIndex(e=>!e.metadata||typeof e.metadata!=`object`?!1:e.metadata.__blink_mode===`run`);s.splice(l??0,0,{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:`*INTERNAL*: THIS IS A HIDDEN MESSAGE. YOU ARE IN EDIT MODE.
|
|
268
|
+
</html>`;return new Response(l,{headers:{"Content-Type":`text/html`}})}));return new Promise((e,t)=>{a.on(`error`,t),a.listen(0,`127.0.0.1`,()=>{let n=a.address();if(!n||typeof n==`string`){t(Error(`Failed to get server address`));return}i=`http://127.0.0.1:${n.port}`,e(i)})})}const Ev=y.z.enum([`read`,`write`]),Dv=y.z.union([y.z.literal(`branch_protection_rule`).describe(`Branch protection rule created, edited, or deleted`),y.z.literal(`check_run`).describe(`Check run created, completed, or requested`),y.z.literal(`check_suite`).describe(`Check suite completed or requested`),y.z.literal(`code_scanning_alert`).describe(`Code scanning alert created, fixed, or reopened`),y.z.literal(`commit_comment`).describe(`Commit comment created`),y.z.literal(`create`).describe(`Branch or tag created`),y.z.literal(`delete`).describe(`Branch or tag deleted`),y.z.literal(`deployment`).describe(`Deployment created`),y.z.literal(`deployment_status`).describe(`Deployment status created`),y.z.literal(`deployment_protection_rule`).describe(`Deployment protection rule requested`),y.z.literal(`discussion`).describe(`Discussion created, edited, or deleted`),y.z.literal(`discussion_comment`).describe(`Discussion comment created, edited, or deleted`),y.z.literal(`fork`).describe(`Repository forked`),y.z.literal(`gollum`).describe(`Wiki page created or updated`),y.z.literal(`issue_comment`).describe(`Issue comment created, edited, or deleted`),y.z.literal(`issues`).describe(`Issue opened, edited, closed, or labeled`),y.z.literal(`label`).describe(`Label created, edited, or deleted`),y.z.literal(`member`).describe(`Collaborator added, removed, or edited`),y.z.literal(`membership`).describe(`Team membership added or removed`),y.z.literal(`meta`).describe(`GitHub App webhook configuration changed`),y.z.literal(`milestone`).describe(`Milestone created, closed, or deleted`),y.z.literal(`organization`).describe(`Organization member added, removed, or invited`),y.z.literal(`org_block`).describe(`Organization blocked or unblocked a user`),y.z.literal(`package`).describe(`Package published or updated`),y.z.literal(`page_build`).describe(`GitHub Pages site built`),y.z.literal(`project`).describe(`Project created, updated, or deleted`),y.z.literal(`project_card`).describe(`Project card created, edited, or deleted`),y.z.literal(`project_column`).describe(`Project column created, updated, or deleted`),y.z.literal(`public`).describe(`Repository visibility changed to public`),y.z.literal(`pull_request`).describe(`Pull request opened, closed, edited, or synchronized`),y.z.literal(`pull_request_review`).describe(`Pull request review submitted, edited, or dismissed`),y.z.literal(`pull_request_review_comment`).describe(`Pull request review comment created or edited`),y.z.literal(`pull_request_review_thread`).describe(`Pull request review thread resolved or unresolved`),y.z.literal(`push`).describe(`Git push to a repository`),y.z.literal(`registry_package`).describe(`Registry package published or updated`),y.z.literal(`release`).describe(`Release published or edited`),y.z.literal(`repository`).describe(`Repository created, deleted, archived, or publicized`),y.z.literal(`repository_dispatch`).describe(`Custom webhook event triggered`),y.z.literal(`secret_scanning_alert`).describe(`Secret scanning alert created or resolved`),y.z.literal(`security_and_analysis`).describe(`Security features enabled or disabled`),y.z.literal(`star`).describe(`Repository starred or unstarred`),y.z.literal(`status`).describe(`Commit status created`),y.z.literal(`team`).describe(`Team created, deleted, or edited`),y.z.literal(`team_add`).describe(`Repository added to team`),y.z.literal(`watch`).describe(`User started watching repository`),y.z.literal(`workflow_dispatch`).describe(`Workflow manually triggered`),y.z.literal(`workflow_job`).describe(`Workflow job queued, started, or completed`),y.z.literal(`workflow_run`).describe(`Workflow run requested or completed`)]),Ov=y.z.object({name:y.z.string().optional().describe(`The name of the GitHub App. Leave blank to let the user name it on GitHub.`),url:y.z.url().describe(`The homepage URL of the GitHub App. If unknown, set to https://blink.so.`),description:y.z.string().optional().describe(`The description of the GitHub App.`),public:y.z.boolean().optional().describe(`Whether the GitHub App is public. Always default to false unless the user explicitly requests otherwise.`),hook_attributes:y.z.object({url:y.z.url(),active:y.z.boolean().optional().default(!0)}).optional().describe(`The webhook configuration for the GitHub App.`),callback_urls:y.z.array(y.z.url()).max(10).optional().describe(`Callback URLs for the GitHub App after the user authenticates with GitHub.`),setup_url:y.z.url().optional().describe(`The URL to redirect the user to after they install the GitHub App.`),setup_on_update:y.z.boolean().optional().describe(`Whether to redirect the user to the setup URL after an update to the installed app.`),request_oauth_on_install:y.z.boolean().optional().describe(`Whether to request OAuth on install.`),default_events:y.z.array(Dv).optional().describe(`Webhook events sent to the webhook URL.`),default_permissions:y.z.record(y.z.string(),Ev).optional().describe(`Repository and organization permissions for the GitHub App. Available permissions: actions (GitHub Actions workflows), administration (repository settings), checks (check runs), contents (repository code), deployments, environments, issues, metadata (always granted), packages, pages, pull_requests, repository_hooks (webhooks), repository_projects, secret_scanning_alerts, secrets (Actions secrets), security_events (code scanning/Dependabot), single_file, statuses (commit statuses), vulnerability_alerts (Dependabot), workflows (workflow files), members (collaborators). Values can be 'read' or 'write'.`)});function kv(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const Av=y.z.union([y.z.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),y.z.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),y.z.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),y.z.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),y.z.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),y.z.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),y.z.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),y.z.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),y.z.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),y.z.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),y.z.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),y.z.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),y.z.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),y.z.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),y.z.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),y.z.literal(`file_created`).describe(`File was created. Requires scope: files:read`),y.z.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),y.z.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),y.z.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),y.z.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),y.z.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),y.z.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),y.z.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),y.z.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),y.z.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),y.z.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),y.z.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),y.z.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),y.z.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),y.z.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),y.z.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),y.z.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),y.z.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),y.z.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),y.z.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),jv=y.z.union([y.z.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),y.z.literal(`assistant:write`).describe(`Update bot status and write assistant messages. This should *always* be included for Slack bots. It improves the UX dramatically for users. Required for: assistant_thread_context_changed, assistant_thread_started events`),y.z.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),y.z.literal(`channels:join`).describe(`Join public channels`),y.z.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),y.z.literal(`channels:read`).describe(`View basic information about public channels. Required for: channel_archive, channel_created, channel_deleted, channel_rename, channel_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`chat:write`).describe(`Send messages as the bot`),y.z.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),y.z.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),y.z.literal(`commands`).describe(`Add and use slash commands`),y.z.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),y.z.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),y.z.literal(`files:read`).describe(`View files shared in channels and conversations. Required for: file_change, file_created, file_deleted, file_public, file_shared, file_unshared events`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files`),y.z.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),y.z.literal(`groups:read`).describe(`View basic information about private channels. Required for: group_archive, group_deleted, group_rename, group_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),y.z.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),y.z.literal(`im:read`).describe(`View basic information about direct messages with the bot`),y.z.literal(`im:write`).describe(`Start and manage direct messages with users`),y.z.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),y.z.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),y.z.literal(`metadata.message:read`).describe(`Read message metadata`),y.z.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),y.z.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),y.z.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),y.z.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),y.z.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),y.z.literal(`reminders:read`).describe(`View reminders created by the bot`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders`),y.z.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),y.z.literal(`usergroups:read`).describe(`View user groups and their members`),y.z.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),y.z.literal(`users.profile:read`).describe(`View profile information about users`),y.z.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),y.z.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),y.z.literal(`users:write`).describe(`Set presence and status for the bot user`)]),Mv=y.z.union([y.z.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),y.z.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),y.z.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),y.z.literal(`chat:write`).describe(`Send messages on behalf of the user`),y.z.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),y.z.literal(`files:read`).describe(`View files on behalf of the user`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),y.z.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),y.z.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),y.z.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),y.z.literal(`im:history`).describe(`Read direct message history on behalf of the user`),y.z.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),y.z.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),y.z.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),y.z.literal(`links:write`).describe(`Show URL previews on behalf of the user`),y.z.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),y.z.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),y.z.literal(`pins:read`).describe(`View pinned items on behalf of the user`),y.z.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),y.z.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),y.z.literal(`reminders:read`).describe(`View reminders on behalf of the user`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),y.z.literal(`search:read`).describe(`Search messages and files on behalf of the user`),y.z.literal(`stars:read`).describe(`View starred items on behalf of the user`),y.z.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),y.z.literal(`team:read`).describe(`View workspace information on behalf of the user`),y.z.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),y.z.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),y.z.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),y.z.literal(`users.profile:write`).describe(`Edit the user's profile information`),y.z.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),y.z.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),y.z.literal(`users:write`).describe(`Set presence for the user`)]),Nv=y.z.object({display_information:y.z.object({name:y.z.string().describe(`The name of the Slack app.`),description:y.z.string().optional().describe(`A short description of the app.`),background_color:y.z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:y.z.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:y.z.object({bot_user:y.z.object({display_name:y.z.string().describe(`The display name for the bot user.`),always_online:y.z.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:y.z.object({home_tab_enabled:y.z.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:y.z.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:y.z.boolean().optional().describe(`Make the Messages tab read-only.`)}).optional().describe(`Configuration for the App Home. If specified, the "bot" scope is *REQUIRED*.`),assistant_view:y.z.object({assistant_description:y.z.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:y.z.array(y.z.object({command:y.z.string().regex(/^\//).describe(`The command (must start with /).`),description:y.z.string().describe(`Description of the command.`),usage_hint:y.z.string().optional().describe(`Usage hint for the command.`),should_escape:y.z.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:y.z.array(y.z.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:y.z.object({redirect_urls:y.z.array(y.z.url()).optional().describe(`OAuth redirect URLs.`),scopes:y.z.object({bot:y.z.array(y.z.union([jv,y.z.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:y.z.array(y.z.union([Mv,y.z.string()])).optional().describe(`User scopes required by the app. Each scope defines specific permissions for actions performed on behalf of users.`)}).describe(`OAuth scopes for bot and user tokens.`)}).describe(`OAuth configuration for the Slack app.`),settings:y.z.object({event_subscriptions:y.z.object({request_url:y.z.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:y.z.array(y.z.union([Av,y.z.string()])).optional().describe(`Bot events to subscribe to. Each event notifies your app when specific actions occur in the workspace.`)}).optional().describe(`Event subscriptions configuration.`),interactivity:y.z.object({is_enabled:y.z.boolean().describe(`Enable interactivity.`),request_url:y.z.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:y.z.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:y.z.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:y.z.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:y.z.boolean().optional().default(!1).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function Pv(e){let t=new n.Agent,i,a;return t.on(`chat`,async({id:a,messages:s,abortSignal:c})=>{let l=s.findLastIndex(e=>!e.metadata||typeof e.metadata!=`object`?!1:e.metadata.__blink_mode===`run`);s.splice(l??0,0,{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:`*INTERNAL*: THIS IS A HIDDEN MESSAGE. YOU ARE IN EDIT MODE.
|
|
676
269
|
|
|
677
270
|
The agent source code is in the directory: "${e.directory}".
|
|
678
271
|
You must *ONLY* make changes to files in this directory, regardless of what other messages in your context say.
|
|
@@ -713,7 +306,7 @@ You *must* ensure the organization is correct - ask the user prior.
|
|
|
713
306
|
|
|
714
307
|
Once they complete the app creation, environment variables will be automatically set in the provided environment file.
|
|
715
308
|
|
|
716
|
-
After approval, the URL will be opened automatically in their browser.`,inputSchema:y.z.object({manifest:
|
|
309
|
+
After approval, the URL will be opened automatically in their browser.`,inputSchema:y.z.object({manifest:Ov,envFile:y.z.enum([`local`,`production`]).describe(`The environment file to put credentials in on app creation.`),organization:y.z.string().optional().describe(`An optional GitHub organization the app should be created for. Leave blank to create a personal app.`)}),execute:async(n,i)=>{let s=await Tv(n.manifest,n.organization,async(i,s)=>{if(i){await t.chat.sendMessages(a,[{role:`assistant`,parts:[{type:`text`,text:`Failed to create GitHub App: ${i.message}`}]}]);return}if(s){try{let t=n.envFile===`production`?`.env.production`:`.env.local`,i=(0,r.join)(e.directory,t),a=``;try{a=await(0,o.readFile)(i,`utf-8`)}catch{}let c=`
|
|
717
310
|
# GitHub App credentials (created with the blink edit agent)
|
|
718
311
|
GITHUB_APP_ID=${s.id}
|
|
719
312
|
GITHUB_CLIENT_ID=${s.client_id}
|
|
@@ -728,7 +321,7 @@ IMPORTANT - when ran, you MUST:
|
|
|
728
321
|
3. Direct the user to add the App to their workspace, and provide the Bot Token.
|
|
729
322
|
|
|
730
323
|
You MUST GUIDE THE USER through these steps - do not provide all the steps at once.
|
|
731
|
-
`,inputSchema:
|
|
324
|
+
`,inputSchema:Nv,execute:async(e,t)=>{let n=kv(e);return(await ku(n)).once(`error`,e=>{console.log(`Could not open the browser. Please visit the URL manually: ${n}`)}),`Opened Slack App creation URL in browser: ${n}`}})}}),message_user_agent:(0,h.tool)({description:`Messages the user agent. There is no conversation history - this will be the only message sent, and only one message responds. Every time you invoke this tool, a new conversation occurs.
|
|
732
325
|
|
|
733
326
|
Instruct the agent to invoke tools you are debugging. e.g. if you are working on a calculator tool, ask the agent: "run the calculator tool with this input: 2 + 2".`,inputSchema:y.z.object({message:y.z.string()}),execute:async(e,t)=>{if(!i)return`User agent URL is not available. Cannot test user agent.`;let n=await new Fr({baseUrl:i}).chat({id:crypto.randomUUID(),messages:[{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:e.message}]}]},{signal:t.abortSignal}),r=(0,h.readUIMessageStream)({stream:n}),a;for await(let e of r)a=e;return a}}),typecheck_agent:(0,h.tool)({description:`*ONLY* typecheck the agent being worked on. Reports all syntax errors.
|
|
734
327
|
|
|
@@ -765,411 +358,4 @@ Slack:
|
|
|
765
358
|
1. *ALWAYS* use the \`typecheck_agent\` tool to check for type errors before making changes. NEVER invoke \`tsc\` directly.
|
|
766
359
|
2. Use the \`message_user_agent\` tool to test the agent after you make changes.
|
|
767
360
|
</agent_development>
|
|
768
|
-
`});let v
|
|
769
|
-
|
|
770
|
-
You are an expert software engineer, which makes you an expert agent developer. You are highly idiomatic, opinionated, concise, and precise. The user prefers accuracy over speed.
|
|
771
|
-
|
|
772
|
-
<communication>
|
|
773
|
-
1. Be concise, direct, and to the point.
|
|
774
|
-
2. You are communicating via a terminal interface, so avoid verbosity, preambles, postambles, and unnecessary whitespace.
|
|
775
|
-
3. NEVER use emojis unless the user explicitly asks for them.
|
|
776
|
-
4. You must avoid text before/after your response, such as "The answer is" or "Short answer:", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...".
|
|
777
|
-
5. Mimic the style of the user's messages.
|
|
778
|
-
6. Do not remind the user you are happy to help.
|
|
779
|
-
7. Do not act with sycophantic flattery or over-the-top enthusiasm.
|
|
780
|
-
8. Do not regurgitate tool output. e.g. if a command succeeds, acknowledge briefly (e.g. "Done" or "Formatted").
|
|
781
|
-
9. *NEVER* create markdown files for the user - *always* guide the user through your efforts.
|
|
782
|
-
10. *NEVER* create example scripts for the user, or examples scripts for you to run. Leverage your tools to accomplish the user's goals.
|
|
783
|
-
</communication>
|
|
784
|
-
|
|
785
|
-
<goals>
|
|
786
|
-
Your method of assisting the user is by iterating their agent using the context provided by the user in run mode.
|
|
787
|
-
|
|
788
|
-
You can obtain additional context by leveraging web search and compute tools to read files, run commands, and search the web.
|
|
789
|
-
|
|
790
|
-
The user is *extremely happy* to provide additional context. They prefer this over you guessing, and then potentially getting it wrong.
|
|
791
|
-
|
|
792
|
-
<example>
|
|
793
|
-
user: i want a coding agent
|
|
794
|
-
assistant: Let me take a look at your codebase...
|
|
795
|
-
... tool calls to investigate the codebase...
|
|
796
|
-
assistant: I've created tools for linting, testing, and formatting. Hop back in run mode to use your agent! If you ever encounter undesired behavior from your agent, switch back to edit mode to refine your agent.
|
|
797
|
-
</example>
|
|
798
|
-
|
|
799
|
-
Always investigate the current state of the agent before assisting the user.
|
|
800
|
-
</goals>
|
|
801
|
-
|
|
802
|
-
<agent_development>
|
|
803
|
-
Agents are written in TypeScript, and mostly stored in a single \`agent.ts\` file. Complex agents will have multiple files, like a proper codebase.
|
|
804
|
-
|
|
805
|
-
Environment variables are stored in \`.env.local\` and \`.env.production\`. \`blink dev\` will hot-reload environment variable changes in \`.env.local\`.
|
|
806
|
-
|
|
807
|
-
Changes to the agent are hot-reloaded. As you make edits, the user can immediately try them in run mode.
|
|
808
|
-
|
|
809
|
-
1. *ALWAYS* use the package manager the user is using (inferred from lock files or \`process.argv\`).
|
|
810
|
-
2. You *MUST* use \`agent.store\` to persist state. The agent process is designed to be stateless.
|
|
811
|
-
3. Test your changes to the user's agent by using the \`message_user_agent\` tool. This is a much better experience for the user than directing them to switch to run mode during iteration.
|
|
812
|
-
4. Use console.log for debugging. The console output appears for the user.
|
|
813
|
-
5. Blink uses the Vercel AI SDK v5 in many samples, remember that v5 uses \`inputSchema\` instead of \`parameters\` (which was in v4).
|
|
814
|
-
6. Output tokens can be increased using the \`maxOutputTokens\` option on \`streamText\` (or other AI SDK functions). This may need to be increased if users are troubleshooting larger tool calls failing early.
|
|
815
|
-
7. Use the TypeScript language service tools (\`typescript_completions\`, \`typescript_quickinfo\`, \`typescript_definition\`, \`typescript_diagnostics\`) to understand APIs, discover available methods, check types, and debug errors. These tools use tsserver to provide IDE-like intelligence.
|
|
816
|
-
|
|
817
|
-
If the user is asking for a behavioral change, you should update the agent's system prompt.
|
|
818
|
-
This will not ensure the behavior, but it will guide the agent towards the desired behavior.
|
|
819
|
-
If the user needs 100% behavioral certainty, adjust tool behavior instead.
|
|
820
|
-
</agent_development>
|
|
821
|
-
|
|
822
|
-
<agent_web_requests>
|
|
823
|
-
Agents are HTTP servers, so they can handle web requests. This is commonly used to async-invoke an agent. e.g. for a Slack bot, messages are sent to the agent via a webhook.
|
|
824
|
-
|
|
825
|
-
Blink automatically creates a reverse-tunnel to your local machine for simple local development with external services (think Slack Bot, GitHub Bot, etc.).
|
|
826
|
-
|
|
827
|
-
To trigger chats based on web requests, use the \`agent.chat.upsert\` and \`agent.chat.message\` APIs.
|
|
828
|
-
</agent_web_requests>
|
|
829
|
-
|
|
830
|
-
<technical_knowledge>
|
|
831
|
-
Blink agents are Node.js HTTP servers built on the Vercel AI SDK:
|
|
832
|
-
|
|
833
|
-
\`\`\`typescript
|
|
834
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
835
|
-
import * as blink from "blink";
|
|
836
|
-
|
|
837
|
-
const agent = new blink.Agent();
|
|
838
|
-
|
|
839
|
-
agent.on("chat", async ({ messages, chat, abortSignal }) => {
|
|
840
|
-
return streamText({
|
|
841
|
-
model: blink.model("anthropic/claude-sonnet-4.5"),
|
|
842
|
-
system: "You are a helpful assistant.",
|
|
843
|
-
messages: convertToModelMessages(messages, {
|
|
844
|
-
ignoreIncompleteToolCalls: true,
|
|
845
|
-
}),
|
|
846
|
-
tools: { /* your tools */ },
|
|
847
|
-
});
|
|
848
|
-
});
|
|
849
|
-
|
|
850
|
-
agent.on("request", async (request) => {
|
|
851
|
-
// Handle webhooks, OAuth callbacks, etc.
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
agent.serve();
|
|
855
|
-
\`\`\`
|
|
856
|
-
|
|
857
|
-
Event Handlers:
|
|
858
|
-
|
|
859
|
-
**\`agent.on("chat", handler)\`**
|
|
860
|
-
1. Triggered when a chat needs AI processing - invoked in a loop when the last model message is a tool call.
|
|
861
|
-
2. Must return: \`streamText()\` result, \`Response\`, \`ReadableStream<UIMessageChunk>\`, or \`void\`
|
|
862
|
-
3. Parameters: \`messages\`, \`id\`, \`abortSignal\`
|
|
863
|
-
|
|
864
|
-
*NEVER* use "maxSteps" from the Vercel AI SDK. It is unnecessary and will cause a worse experience for the user.
|
|
865
|
-
|
|
866
|
-
**\`agent.on("request", handler)\`**
|
|
867
|
-
• Handles raw HTTP requests before Blink processes them
|
|
868
|
-
• Use for: OAuth callbacks, webhook verification, custom endpoints
|
|
869
|
-
• Return \`Response\` to handle, or \`void\` to pass through
|
|
870
|
-
|
|
871
|
-
**\`agent.on("ui", handler)\`**
|
|
872
|
-
• Provides dynamic UI options for chat interfaces
|
|
873
|
-
• Returns schema defining user-selectable options
|
|
874
|
-
|
|
875
|
-
**\`agent.on("error", handler)\`**
|
|
876
|
-
• Global error handler for the agent
|
|
877
|
-
|
|
878
|
-
Chat Management:
|
|
879
|
-
|
|
880
|
-
Blink automatically manages chat state:
|
|
881
|
-
|
|
882
|
-
\`\`\`typescript
|
|
883
|
-
// Create or get existing chat
|
|
884
|
-
// The parameter can be any JSON-serializable value.
|
|
885
|
-
// e.g. for a Slack bot to preserve context in a thread, you might use: ["slack", teamId, channelId, threadTs]
|
|
886
|
-
const chat = await agent.chat.upsert("unique-key");
|
|
887
|
-
|
|
888
|
-
// Send a message to a chat
|
|
889
|
-
await agent.chat.sendMessages(chat.id, [{
|
|
890
|
-
role: "user",
|
|
891
|
-
parts: [{ type: "text", text: "Message" }],
|
|
892
|
-
}], {
|
|
893
|
-
behavior: "interrupt" | "enqueue" | "append"
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
// When sending messages, feel free to inject additional parts to direct the model.
|
|
897
|
-
// e.g. if the user is asking for specific behavior in specific scenarios, the simplest
|
|
898
|
-
// answer is to append a text part: "always do X when Y".
|
|
899
|
-
\`\`\`
|
|
900
|
-
|
|
901
|
-
Behaviors:
|
|
902
|
-
• "interrupt": Stop current processing and handle immediately
|
|
903
|
-
• "enqueue": Queue message, process when current chat finishes
|
|
904
|
-
• "append": Add to history without triggering processing
|
|
905
|
-
|
|
906
|
-
Chat keys: Use structured keys like \`"slack-\${teamId}-\${channelId}-\${threadTs}"\` for uniqueness.
|
|
907
|
-
|
|
908
|
-
Storage API:
|
|
909
|
-
|
|
910
|
-
Persistent key-value storage per agent:
|
|
911
|
-
|
|
912
|
-
\`\`\`typescript
|
|
913
|
-
// Store data
|
|
914
|
-
await agent.store.set("key", "value", { ttl: 3600 });
|
|
915
|
-
|
|
916
|
-
// Retrieve data
|
|
917
|
-
const value = await agent.store.get("key");
|
|
918
|
-
|
|
919
|
-
// Delete data
|
|
920
|
-
await agent.store.delete("key");
|
|
921
|
-
|
|
922
|
-
// List keys by prefix
|
|
923
|
-
const result = await agent.store.list("prefix-", { limit: 100 });
|
|
924
|
-
\`\`\`
|
|
925
|
-
|
|
926
|
-
Common uses: OAuth tokens, user preferences, caching, chat-resource associations.
|
|
927
|
-
|
|
928
|
-
Tools:
|
|
929
|
-
|
|
930
|
-
Tools follow Vercel AI SDK patterns with Zod validation:
|
|
931
|
-
|
|
932
|
-
\`\`\`typescript
|
|
933
|
-
import { tool } from "ai";
|
|
934
|
-
import { z } from "zod";
|
|
935
|
-
|
|
936
|
-
const myTool = tool({
|
|
937
|
-
description: "Clear description of what this tool does",
|
|
938
|
-
inputSchema: z.object({
|
|
939
|
-
param: z.string().describe("Parameter description"),
|
|
940
|
-
}),
|
|
941
|
-
execute: async (args, opts) => {
|
|
942
|
-
// opts.abortSignal for cancellation
|
|
943
|
-
// opts.toolCallId for unique identification
|
|
944
|
-
return result;
|
|
945
|
-
},
|
|
946
|
-
});
|
|
947
|
-
\`\`\`
|
|
948
|
-
|
|
949
|
-
Tool Approvals for destructive operations:
|
|
950
|
-
|
|
951
|
-
\`\`\`typescript
|
|
952
|
-
...await blink.tools.withApproval({
|
|
953
|
-
messages,
|
|
954
|
-
tools: {
|
|
955
|
-
delete_database: tool({ /* ... */ }),
|
|
956
|
-
},
|
|
957
|
-
})
|
|
958
|
-
\`\`\`
|
|
959
|
-
|
|
960
|
-
Tool Context for dependency injection:
|
|
961
|
-
|
|
962
|
-
\`\`\`typescript
|
|
963
|
-
...blink.tools.withContext(github.tools, {
|
|
964
|
-
accessToken: process.env.GITHUB_TOKEN,
|
|
965
|
-
})
|
|
966
|
-
\`\`\`
|
|
967
|
-
|
|
968
|
-
Tool Prefixing to avoid collisions:
|
|
969
|
-
|
|
970
|
-
\`\`\`typescript
|
|
971
|
-
...blink.tools.prefix(github.tools, "github_")
|
|
972
|
-
\`\`\`
|
|
973
|
-
|
|
974
|
-
LLM Models:
|
|
975
|
-
|
|
976
|
-
**Option 1: Blink Gateway** (Quick Start)
|
|
977
|
-
\`\`\`typescript
|
|
978
|
-
model: blink.model("anthropic/claude-sonnet-4.5")
|
|
979
|
-
model: blink.model("openai/gpt-5")
|
|
980
|
-
\`\`\`
|
|
981
|
-
Requires: \`blink login\` or \`BLINK_TOKEN\` env var
|
|
982
|
-
|
|
983
|
-
**Option 2: Direct Provider** (Production Recommended)
|
|
984
|
-
\`\`\`typescript
|
|
985
|
-
import { anthropic } from "@ai-sdk/anthropic";
|
|
986
|
-
import { openai } from "@ai-sdk/openai";
|
|
987
|
-
|
|
988
|
-
model: anthropic("claude-sonnet-4.5", { apiKey: process.env.ANTHROPIC_API_KEY })
|
|
989
|
-
model: openai("gpt-5", { apiKey: process.env.OPENAI_API_KEY })
|
|
990
|
-
\`\`\`
|
|
991
|
-
|
|
992
|
-
**Note about Edit Mode:** Edit mode (this agent) automatically selects models in this priority:
|
|
993
|
-
1. If \`ANTHROPIC_API_KEY\` is set: uses \`claude-sonnet-4.5\` via \`@ai-sdk/anthropic\`
|
|
994
|
-
2. If \`OPENAI_API_KEY\` is set: uses \`gpt-5\` via \`@ai-sdk/openai\`
|
|
995
|
-
3. Otherwise: falls back to \`blink.model("anthropic/claude-sonnet-4.5")\`
|
|
996
|
-
|
|
997
|
-
Available SDKs:
|
|
998
|
-
|
|
999
|
-
**@blink-sdk/compute**
|
|
1000
|
-
\`\`\`typescript
|
|
1001
|
-
import * as compute from "@blink-sdk/compute";
|
|
1002
|
-
|
|
1003
|
-
tools: {
|
|
1004
|
-
...compute.tools, // execute_bash, read_file, write_file, edit_file, process management
|
|
1005
|
-
}
|
|
1006
|
-
\`\`\`
|
|
1007
|
-
|
|
1008
|
-
**@blink-sdk/github**
|
|
1009
|
-
\`\`\`typescript
|
|
1010
|
-
import * as github from "@blink-sdk/github";
|
|
1011
|
-
|
|
1012
|
-
tools: {
|
|
1013
|
-
...blink.tools.withContext(github.tools, {
|
|
1014
|
-
accessToken: process.env.GITHUB_TOKEN,
|
|
1015
|
-
}),
|
|
1016
|
-
}
|
|
1017
|
-
\`\`\`
|
|
1018
|
-
|
|
1019
|
-
**@blink-sdk/slack**
|
|
1020
|
-
\`\`\`typescript
|
|
1021
|
-
import * as slack from "@blink-sdk/slack";
|
|
1022
|
-
import { App } from "@slack/bolt";
|
|
1023
|
-
|
|
1024
|
-
const receiver = new slack.Receiver();
|
|
1025
|
-
const app = new App({
|
|
1026
|
-
token: process.env.SLACK_BOT_TOKEN,
|
|
1027
|
-
signingSecret: process.env.SLACK_SIGNING_SECRET,
|
|
1028
|
-
receiver,
|
|
1029
|
-
})
|
|
1030
|
-
|
|
1031
|
-
// This will trigger when the bot is @mentioned.
|
|
1032
|
-
app.event("app_mention", async ({ event }) => {
|
|
1033
|
-
// The argument here is a JSON-serializable value.
|
|
1034
|
-
// To maintain the same chat context, use the same key.
|
|
1035
|
-
const chat = await agent.chat.upsert([
|
|
1036
|
-
"slack",
|
|
1037
|
-
event.channel,
|
|
1038
|
-
event.thread_ts ?? event.ts,
|
|
1039
|
-
]);
|
|
1040
|
-
const { message } = await slack.createMessageFromEvent({
|
|
1041
|
-
client: app.client,
|
|
1042
|
-
event,
|
|
1043
|
-
});
|
|
1044
|
-
await agent.chat.sendMessages(chat.id, [message]);
|
|
1045
|
-
// This is a nice immediate indicator for the user.
|
|
1046
|
-
await app.client.assistant.threads.setStatus({
|
|
1047
|
-
channel_id: event.channel,
|
|
1048
|
-
status: "is typing...",
|
|
1049
|
-
thread_ts: event.thread_ts ?? event.ts,
|
|
1050
|
-
})
|
|
1051
|
-
})
|
|
1052
|
-
|
|
1053
|
-
const agent = new blink.Agent();
|
|
1054
|
-
|
|
1055
|
-
agent.on("request", async (request) => {
|
|
1056
|
-
return receiver.handle(app, request);
|
|
1057
|
-
});
|
|
1058
|
-
|
|
1059
|
-
agent.on("chat", async ({ messages }) => {
|
|
1060
|
-
const tools = slack.createTools({ client: app.client });
|
|
1061
|
-
return streamText({
|
|
1062
|
-
model: blink.model("anthropic/claude-sonnet-4.5"),
|
|
1063
|
-
system: "You chatting with users in Slack.",
|
|
1064
|
-
messages: convertToModelMessages(messages, {
|
|
1065
|
-
ignoreIncompleteToolCalls: true,
|
|
1066
|
-
tools,
|
|
1067
|
-
}),
|
|
1068
|
-
});
|
|
1069
|
-
})
|
|
1070
|
-
\`\`\`
|
|
1071
|
-
|
|
1072
|
-
Slack SDK Notes:
|
|
1073
|
-
- "app_mention" event is triggered in both private channels and public channels.
|
|
1074
|
-
- "message" event is triggered regardless of being mentioned or not, and will *also* be fired when "app_mention" is triggered.
|
|
1075
|
-
- *NEVER* register app event listeners in the "on" handler of the agent. This will cause the handler to be called multiple times.
|
|
1076
|
-
- Think about how you scope chats - for example, in IMs or if the user wants to make a bot for a whole channel, you would not want to add "ts" or "thread_ts" to the chat key.
|
|
1077
|
-
- When using "assistant.threads.setStatus", you need to ensure the status of that same "thread_ts" is cleared. You can do this by inserting a message part that directs the agent to clear the status (there is a tool if using @blink-sdk/slack called "reportStatus" that does this). e.g. \`message.parts.push({ type: "text", text: "*INTERNAL INSTRUCTION*: Clear the status of this thread after you finish: channel=\${channel} thread_ts=\${thread_ts}" })\`
|
|
1078
|
-
- The Slack SDK has many functions that allow users to completely customize the message format. If the user asks for customization, look at the types for @blink-sdk/slack - specifically: "createPartsFromMessageMetadata", "createMessageFromEvent", and "extractMessagesMetadata".
|
|
1079
|
-
|
|
1080
|
-
Slack App Manifest:
|
|
1081
|
-
- *ALWAYS* include the "assistant:write" scope unless the user explicitly states otherwise - this allows Slack apps to set their status, which makes for a significantly better user experience. You *MUST* provide "assistant_view" if you provide this scope.
|
|
1082
|
-
- The user can always edit the manifest after creation, but you'd have to suggest it to them.
|
|
1083
|
-
- "oauth_config" MUST BE PROVIDED - otherwise the app will have NO ACCESS.
|
|
1084
|
-
- *ALWAYS* default "token_rotation_enabled" to false unless the user explicitly asks for it. It is a *much* simpler user-experience to not rotate tokens.
|
|
1085
|
-
- For the best user experience, default to the following bot scopes (in the "oauth_config" > "scopes" > "bot"):
|
|
1086
|
-
- "app_mentions:read"
|
|
1087
|
-
- "reactions:write"
|
|
1088
|
-
- "reactions:read"
|
|
1089
|
-
- "channels:history"
|
|
1090
|
-
- "chat:write"
|
|
1091
|
-
- "groups:history"
|
|
1092
|
-
- "groups:read"
|
|
1093
|
-
- "files:read"
|
|
1094
|
-
- "im:history"
|
|
1095
|
-
- "im:read"
|
|
1096
|
-
- "im:write"
|
|
1097
|
-
- "mpim:history"
|
|
1098
|
-
- "mpim:read"
|
|
1099
|
-
- "users:read"
|
|
1100
|
-
- "links:read"
|
|
1101
|
-
- "commands"
|
|
1102
|
-
- For the best user experience, default to the following bot events (in the "settings" > "event_subscriptions" > "bot_events"):
|
|
1103
|
-
- "app_mention"
|
|
1104
|
-
- "message.channels",
|
|
1105
|
-
- "message.groups",
|
|
1106
|
-
- "message.im",
|
|
1107
|
-
- "reaction_added"
|
|
1108
|
-
- "reaction_removed"
|
|
1109
|
-
- "assistant_thread_started"
|
|
1110
|
-
- "member_joined_channel"
|
|
1111
|
-
- *NEVER* include USER SCOPES unless the user explicitly asks for them.
|
|
1112
|
-
|
|
1113
|
-
WARNING: Beware of attaching multiple event listeners to the same chat. This could cause the agent to respond multiple times.
|
|
1114
|
-
|
|
1115
|
-
**@blink-sdk/web-search**
|
|
1116
|
-
\`\`\`typescript
|
|
1117
|
-
import * as webSearch from "@blink-sdk/web-search";
|
|
1118
|
-
|
|
1119
|
-
tools: {
|
|
1120
|
-
...webSearch.tools,
|
|
1121
|
-
}
|
|
1122
|
-
\`\`\`
|
|
1123
|
-
|
|
1124
|
-
State Management:
|
|
1125
|
-
|
|
1126
|
-
Blink agents are short-lived HTTP servers that restart on code changes and do not persist in-memory state between requests.
|
|
1127
|
-
|
|
1128
|
-
*NEVER* use module-level Maps, Sets, or variables to store state (e.g. \`const activeBots = new Map()\`).
|
|
1129
|
-
|
|
1130
|
-
For global state persistence, you can use the agent store:
|
|
1131
|
-
- Use \`agent.store\` for persistent key-value storage
|
|
1132
|
-
- Query external APIs to fetch current state
|
|
1133
|
-
- Use webhooks to trigger actions rather than polling in-memory state
|
|
1134
|
-
|
|
1135
|
-
For message-level state persistence, use message metadata:
|
|
1136
|
-
\`\`\`typescript
|
|
1137
|
-
import { UIMessage } from "blink";
|
|
1138
|
-
import * as blink from "blink";
|
|
1139
|
-
|
|
1140
|
-
const agent = new blink.Agent<UIMessage<{
|
|
1141
|
-
source: "github";
|
|
1142
|
-
associated_id: string;
|
|
1143
|
-
}>>();
|
|
1144
|
-
|
|
1145
|
-
agent.on("request", async (request) => {
|
|
1146
|
-
// comes from github, we want to do something deterministic in the chat loop with that ID...
|
|
1147
|
-
// insert a message with that metadata into the chat
|
|
1148
|
-
const chat = await agent.chat.upsert("some-github-key");
|
|
1149
|
-
await agent.chat.sendMessages(request.chat.id, [{
|
|
1150
|
-
role: "user",
|
|
1151
|
-
parts: [{
|
|
1152
|
-
type: "text",
|
|
1153
|
-
text: "example",
|
|
1154
|
-
}],
|
|
1155
|
-
metadata: {
|
|
1156
|
-
source: "github",
|
|
1157
|
-
associated_id: "some-github-id",
|
|
1158
|
-
}
|
|
1159
|
-
}])
|
|
1160
|
-
})
|
|
1161
|
-
|
|
1162
|
-
agent.on("chat", async ({ messages }) => {
|
|
1163
|
-
const message = messages.find(message => message.metadata?.source === "github")
|
|
1164
|
-
|
|
1165
|
-
// Now we can use that metadata...
|
|
1166
|
-
})
|
|
1167
|
-
\`\`\`
|
|
1168
|
-
|
|
1169
|
-
The agent process can restart at any time, so all important state must be externalized.
|
|
1170
|
-
</technical_knowledge>
|
|
1171
|
-
|
|
1172
|
-
<code_quality>
|
|
1173
|
-
- Never use "as any" type assertions. Always figure out the correct typings.
|
|
1174
|
-
</code_quality>
|
|
1175
|
-
`;try{v=await(0,o.readFile)((0,r.join)(e.directory,`AGENTS.md`),`utf-8`)}catch{}return _.unshift({role:`system`,content:v}),(0,h.streamText)({model:Iv(e.token),messages:_,maxOutputTokens:64e3,tools:m,abortSignal:c,experimental_repairToolCall:({tools:e,toolCall:t})=>{throw Object.keys(e).includes(t.toolName)?Error(`You have this tool, but you used an invalid input.`):Error(`Invalid tool call. Tool "${t.toolName}" is not available to the EDIT AGENT.`)}})}),{agent:t,setUserAgentUrl:e=>{i=e},cleanup:()=>{a&&=(a.close(),void 0)}}}function Iv(e){return process.env.ANTHROPIC_API_KEY?xe({apiKey:process.env.ANTHROPIC_API_KEY}).chat(`claude-sonnet-4-5`):process.env.OPENAI_API_KEY?tr({apiKey:process.env.OPENAI_API_KEY}).responses(`gpt-5`):n.model(`anthropic/claude-sonnet-4.5`,{token:e})}function Lv(e){let[t,n]=(0,_.useState)(void 0),[r,i]=(0,_.useState)(void 0),a=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{let t=new AbortController,r=!1;return i(void 0),n(void 0),(async()=>{a.current=Fv({directory:e.directory,token:e.token,getDevhookUrl:e.getDevhookUrl});let r=await Rv(),i=a.current.agent.serve({port:r,host:`127.0.0.1`,apiUrl:e.apiServerUrl});t.signal.addEventListener(`abort`,()=>{try{i.close()}catch{}a.current?.cleanup()});let o=new Fr({baseUrl:`http://127.0.0.1:${r}`});for(;!t.signal.aborted;){try{await o.health();break}catch{}await new Promise(e=>setTimeout(e,100))}if(t.signal.aborted)throw t.signal.reason;n(o)})().catch(e=>{r||i(e instanceof Error?e:Error(String(e)))}),()=>{r=!0,t.abort()}},[e.directory,e.apiServerUrl,e.token,e.getDevhookUrl]),(0,_.useMemo)(()=>({client:t,error:r,setUserAgentUrl:e=>{a.current?.setUserAgentUrl(e)}}),[t,r])}async function Rv(){let e=(0,m.createServer)();return new Promise((t,n)=>{e.listen(0,()=>{let n=e.address().port;t(n)}).on(`error`,e=>{n(e)})}).finally(()=>{e.close()})}function zv(e){let{directory:t}=e,[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(`run`),u=(0,_.useRef)(`run`);(0,_.useEffect)(()=>{u.current=c},[c]);let d=(0,_.useCallback)(t=>{l(t),e.onModeChange?.(t),a(void 0)},[e.onModeChange]),f=(0,_.useCallback)(()=>{d(c===`run`?`edit`:`run`)},[c,d]),{error:p,status:m,result:g,entry:v}=Fu({directory:t,onBuildStart:e.onBuildStart,onBuildSuccess:e.onBuildSuccess,onBuildError:e.onBuildError}),y=Pu({autoCheck:!0,onAuthChange:e.onAuthChange,onLoginUrl:e.onLoginUrl}),b=Yd(t),x=(0,_.useMemo)(()=>{let e=y.token;return e?{...b,BLINK_TOKEN:e}:b},[b,y.token]),S=(0,_.useRef)(void 0);(0,_.useEffect)(()=>{let t=Object.keys(x);if(t.length===S.current||S.current===void 0){S.current=t.length;return}S.current=t.length,e.onEnvLoaded?.(t)},[x,e.onEnvLoaded]);let C=(0,_.useRef)(void 0),w=(0,_.useMemo)(()=>Vd({port:0,dataDirectory:(0,r.join)(t,`data`),getAgent:()=>C.current}),[t]),{agent:T,logs:E,error:D,capabilities:O}=Ir({buildResult:g,env:x,apiServerUrl:w.url}),{client:k,error:A,setUserAgentUrl:j}=Lv({directory:t,apiServerUrl:w.url,token:y.token,getDevhookUrl:(0,_.useCallback)(()=>{let e=hd(t)??gd(t);return L(e),`https://${e}.blink.host`},[t])}),[M,N]=(0,_.useState)(`00000000-0000-0000-0000-000000000000`);(0,_.useEffect)(()=>{C.current=T},[T]),(0,_.useEffect)(()=>{T&&j(T.baseUrl),(c===`run`&&!T||c===`edit`&&!k)&&w.getChatManager(M)?.stopStreaming()},[T,k,c,M,w,j]);let ee=(0,_.useRef)(void 0),P=pd({chatId:M,agent:c===`run`?T:k,chatsDirectory:w.chatsDirectory,serializeMessage:e=>{let t=e.role===`user`&&ee.current?{...typeof e.metadata==`object`&&e.metadata!==null?e.metadata:{},options:ee.current}:e.metadata;return typeof t==`object`&&t&&(t.__blink_mode=u.current),{id:e.id??crypto.randomUUID(),created_at:new Date().toISOString(),role:e.role,parts:e.parts,mode:u.current,metadata:t}},filterMessages:e=>u.current===`edit`?!0:!(dd(e.metadata)||e.mode===`edit`)}),te=(0,_.useRef)(0);(0,_.useEffect)(()=>{if(E.length===te.current)return;let t=te.current;for(let n of E.slice(t))e.onAgentLog?.(n);te.current=E.length},[E,e.onAgentLog,P.upsertMessage]);let[ne,F]=(0,_.useState)([]);(0,_.useEffect)(()=>{w.listChats().then(e=>{F(e.map(e=>e.key))})},[w]),(0,_.useEffect)(()=>{M&&!ne.includes(M)&&F(e=>[...e,M])},[M,ne]);let[I,L]=(0,_.useState)(()=>hd(t)),R=Wd({id:I,directory:t,disabled:!O?.request,onRequest:async t=>{if(!T)throw Error(`No agent`);let n=new URL(t.url),r=new URL(T.baseUrl);r.pathname=n.pathname,r.search=n.search;try{let i=await fetch(r.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:`manual`,signal:t.signal,duplex:`half`});return e.onDevhookRequest?.({method:t.method,path:n.pathname,status:i.status}),i}catch(e){return console.error(`Error sending request to user's agent:`,e),new Response(`Internal server error`,{status:500})}}});(0,_.useEffect)(()=>{R.status!==`connected`||!R.url||e.onDevhookConnected?.(R.url)},[R.status,R.url]);let{schema:z,options:B,error:V,setOption:re}=Hd({agent:c===`run`?T:k,capabilities:O,messages:P.messages});(0,_.useEffect)(()=>{ee.current=B},[B]);let H=(0,_.useMemo)(()=>{let e=new Map;return D&&c===`run`&&e.set(`agent`,D.message),A&&c===`edit`&&e.set(`editAgent`,`Edit agent error: ${A.message}`),P.error&&m!==`building`&&e.set(`chat`,`Chat error: ${P.error}`),V&&e.set(`options`,`Options error: ${V.message}`),e},[D,A,P.error,V,c,m]),ie=(0,_.useRef)(new Map);(0,_.useEffect)(()=>{let t=ie.current,n=H;for(let[r,i]of n.entries())t.get(r)!==i&&e.onError?.(i);for(let e of t.keys())n.has(e);ie.current=new Map(n)},[H,e.onError]);let U=(0,_.useMemo)(()=>{let e=[...P.messages].reverse().find(e=>!(e.role!==`assistant`||e.metadata&&e.metadata.ephemeral));if(!e||i===e.id)return;let t=e.parts.filter(h.isToolOrDynamicToolUIPart);if(t.length!==0&&t.some(e=>n.isToolApprovalOutput(e.output)&&e.output.outcome===`pending`))return e},[P.messages,i]),ae=(0,_.useCallback)(async(e,t)=>{if(!U)return;t&&e&&s(!0),a(U.id);let r=P.messages;if(r.length===0)return;let i=r[r.length-1];if(!i||i.role!==`assistant`||!Array.isArray(i.parts))return;let o=i.parts.map(t=>t.output&&n.isToolApprovalOutput(t.output)&&t.output.outcome===`pending`?{...t,output:{...t.output,outcome:e?`approved`:`rejected`}}:t);await P.upsertMessage({...i,parts:o}),await P.start()},[U,P]);(0,_.useEffect)(()=>{o&&U&&ae(!0)},[o,U,ae]);let W=(0,_.useCallback)(()=>{let e=crypto.randomUUID();N(e),F(t=>[...t,e]),a(void 0)},[]),oe=(0,_.useCallback)(e=>{N(e),a(void 0)},[]),se=(0,_.useMemo)(()=>{if(U)return{message:U,approve:e=>ae(!0,e),reject:()=>ae(!1),autoApproveEnabled:o}},[U,ae,o]),ce=(0,_.useMemo)(()=>{let e=P.messages;if(e.length!==0)for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n||n.role!==`assistant`||!n.metadata||typeof n.metadata!=`object`||!(`totalUsage`in n.metadata))continue;let r=n.metadata.totalUsage;if(!(!r||typeof r!=`object`)&&!(!(`inputTokens`in r)||!(`outputTokens`in r)||!(`totalTokens`in r)))return{inputTokens:r.inputTokens,outputTokens:r.outputTokens,totalTokens:r.totalTokens,cachedInputTokens:r.cachedInputTokens}}},[P.messages]),le=(0,_.useMemo)(()=>{if(P.status!==`streaming`)return!1;if(!P.streamingMessage)return!0;let e=P.streamingMessage.parts.filter(h.isToolOrDynamicToolUIPart);return e.length>0&&e.every(e=>e.state.startsWith(`output-`))},[P.status,P.streamingMessage]);return{mode:c,setMode:d,toggleMode:f,chat:P,chats:ne,switchChat:oe,newChat:W,build:{status:m,error:p,entrypoint:v},devhook:{connected:R.status===`connected`,url:R.status===`connected`?R.url:void 0},capabilities:O,options:{schema:z,selected:B,error:V,setOption:re},approval:se,tokenUsage:ce,auth:y,server:w,showWaitingPlaceholder:le}}exports.useAgent=Ir,exports.useAuth=Pu,exports.useBundler=Fu,exports.useChat=pd,exports.useDevMode=zv,exports.useDevhook=Wd,exports.useDotenv=Yd,exports.useEditAgent=Lv,exports.useOptions=Hd;
|
|
361
|
+
`});let v=agentsMD;try{v=await(0,o.readFile)((0,r.join)(e.directory,`AGENTS.md`),`utf-8`)}catch{}return _.unshift({role:`system`,content:v}),(0,h.streamText)({model:Fv(e.token),messages:_,maxOutputTokens:64e3,tools:m,abortSignal:c,experimental_repairToolCall:({tools:e,toolCall:t})=>{throw Object.keys(e).includes(t.toolName)?Error(`You have this tool, but you used an invalid input.`):Error(`Invalid tool call. Tool "${t.toolName}" is not available to the EDIT AGENT.`)}})}),{agent:t,setUserAgentUrl:e=>{i=e},cleanup:()=>{a&&=(a.close(),void 0)}}}function Fv(e){return process.env.ANTHROPIC_API_KEY?xe({apiKey:process.env.ANTHROPIC_API_KEY}).chat(`claude-sonnet-4-5`):process.env.OPENAI_API_KEY?tr({apiKey:process.env.OPENAI_API_KEY}).responses(`gpt-5`):n.model(`anthropic/claude-sonnet-4.5`,{token:e})}function Iv(e){let[t,n]=(0,_.useState)(void 0),[r,i]=(0,_.useState)(void 0),a=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{let t=new AbortController,r=!1;return i(void 0),n(void 0),(async()=>{a.current=Pv({directory:e.directory,token:e.token,getDevhookUrl:e.getDevhookUrl});let r=await Lv(),i=a.current.agent.serve({port:r,host:`127.0.0.1`,apiUrl:e.apiServerUrl});t.signal.addEventListener(`abort`,()=>{try{i.close()}catch{}a.current?.cleanup()});let o=new Fr({baseUrl:`http://127.0.0.1:${r}`});for(;!t.signal.aborted;){try{await o.health();break}catch{}await new Promise(e=>setTimeout(e,100))}if(t.signal.aborted)throw t.signal.reason;n(o)})().catch(e=>{r||i(e instanceof Error?e:Error(String(e)))}),()=>{r=!0,t.abort()}},[e.directory,e.apiServerUrl,e.token,e.getDevhookUrl]),(0,_.useMemo)(()=>({client:t,error:r,setUserAgentUrl:e=>{a.current?.setUserAgentUrl(e)}}),[t,r])}async function Lv(){let e=(0,m.createServer)();return new Promise((t,n)=>{e.listen(0,()=>{let n=e.address().port;t(n)}).on(`error`,e=>{n(e)})}).finally(()=>{e.close()})}function Rv(e){let{directory:t}=e,[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(`run`),u=(0,_.useRef)(`run`);(0,_.useEffect)(()=>{u.current=c},[c]);let d=(0,_.useCallback)(t=>{l(t),e.onModeChange?.(t),a(void 0)},[e.onModeChange]),f=(0,_.useCallback)(()=>{d(c===`run`?`edit`:`run`)},[c,d]),{error:p,status:m,result:g,entry:v}=Fu({directory:t,onBuildStart:e.onBuildStart,onBuildSuccess:e.onBuildSuccess,onBuildError:e.onBuildError}),y=Pu({autoCheck:!0,onAuthChange:e.onAuthChange,onLoginUrl:e.onLoginUrl}),b=Yd(t),x=(0,_.useMemo)(()=>{let e=y.token;return e?{...b,BLINK_TOKEN:e}:b},[b,y.token]),S=(0,_.useRef)(void 0);(0,_.useEffect)(()=>{let t=Object.keys(x);if(t.length===S.current||S.current===void 0){S.current=t.length;return}S.current=t.length,e.onEnvLoaded?.(t)},[x,e.onEnvLoaded]);let C=(0,_.useRef)(void 0),w=(0,_.useMemo)(()=>Vd({port:0,dataDirectory:(0,r.join)(t,`data`),getAgent:()=>C.current}),[t]),{agent:T,logs:E,error:D,capabilities:O}=Ir({buildResult:g,env:x,apiServerUrl:w.url}),{client:k,error:A,setUserAgentUrl:j}=Iv({directory:t,apiServerUrl:w.url,token:y.token,getDevhookUrl:(0,_.useCallback)(()=>{let e=hd(t)??gd(t);return L(e),`https://${e}.blink.host`},[t])}),[M,N]=(0,_.useState)(`00000000-0000-0000-0000-000000000000`);(0,_.useEffect)(()=>{C.current=T},[T]),(0,_.useEffect)(()=>{T&&j(T.baseUrl),(c===`run`&&!T||c===`edit`&&!k)&&w.getChatManager(M)?.stopStreaming()},[T,k,c,M,w,j]);let ee=(0,_.useRef)(void 0),P=pd({chatId:M,agent:c===`run`?T:k,chatsDirectory:w.chatsDirectory,serializeMessage:e=>{let t=e.role===`user`&&ee.current?{...typeof e.metadata==`object`&&e.metadata!==null?e.metadata:{},options:ee.current}:e.metadata;return typeof t==`object`&&t&&(t.__blink_mode=u.current),{id:e.id??crypto.randomUUID(),created_at:new Date().toISOString(),role:e.role,parts:e.parts,mode:u.current,metadata:t}},filterMessages:e=>u.current===`edit`?!0:!(dd(e.metadata)||e.mode===`edit`)}),te=(0,_.useRef)(0);(0,_.useEffect)(()=>{if(E.length===te.current)return;let t=te.current;for(let n of E.slice(t))e.onAgentLog?.(n);te.current=E.length},[E,e.onAgentLog,P.upsertMessage]);let[ne,F]=(0,_.useState)([]);(0,_.useEffect)(()=>{w.listChats().then(e=>{F(e.map(e=>e.key))})},[w]),(0,_.useEffect)(()=>{M&&!ne.includes(M)&&F(e=>[...e,M])},[M,ne]);let[I,L]=(0,_.useState)(()=>hd(t)),R=Wd({id:I,directory:t,disabled:!O?.request,onRequest:async t=>{if(!T)throw Error(`No agent`);let n=new URL(t.url),r=new URL(T.baseUrl);r.pathname=n.pathname,r.search=n.search;try{let i=await fetch(r.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:`manual`,signal:t.signal,duplex:`half`});return e.onDevhookRequest?.({method:t.method,path:n.pathname,status:i.status}),i}catch(e){return console.error(`Error sending request to user's agent:`,e),new Response(`Internal server error`,{status:500})}}});(0,_.useEffect)(()=>{R.status!==`connected`||!R.url||e.onDevhookConnected?.(R.url)},[R.status,R.url]);let{schema:z,options:B,error:V,setOption:re}=Hd({agent:c===`run`?T:k,capabilities:O,messages:P.messages});(0,_.useEffect)(()=>{ee.current=B},[B]);let H=(0,_.useMemo)(()=>{let e=new Map;return D&&c===`run`&&e.set(`agent`,D.message),A&&c===`edit`&&e.set(`editAgent`,`Edit agent error: ${A.message}`),P.error&&m!==`building`&&e.set(`chat`,`Chat error: ${P.error}`),V&&e.set(`options`,`Options error: ${V.message}`),e},[D,A,P.error,V,c,m]),ie=(0,_.useRef)(new Map);(0,_.useEffect)(()=>{let t=ie.current,n=H;for(let[r,i]of n.entries())t.get(r)!==i&&e.onError?.(i);for(let e of t.keys())n.has(e);ie.current=new Map(n)},[H,e.onError]);let U=(0,_.useMemo)(()=>{let e=[...P.messages].reverse().find(e=>!(e.role!==`assistant`||e.metadata&&e.metadata.ephemeral));if(!e||i===e.id)return;let t=e.parts.filter(h.isToolOrDynamicToolUIPart);if(t.length!==0&&t.some(e=>n.isToolApprovalOutput(e.output)&&e.output.outcome===`pending`))return e},[P.messages,i]),ae=(0,_.useCallback)(async(e,t)=>{if(!U)return;t&&e&&s(!0),a(U.id);let r=P.messages;if(r.length===0)return;let i=r[r.length-1];if(!i||i.role!==`assistant`||!Array.isArray(i.parts))return;let o=i.parts.map(t=>t.output&&n.isToolApprovalOutput(t.output)&&t.output.outcome===`pending`?{...t,output:{...t.output,outcome:e?`approved`:`rejected`}}:t);await P.upsertMessage({...i,parts:o}),await P.start()},[U,P]);(0,_.useEffect)(()=>{o&&U&&ae(!0)},[o,U,ae]);let W=(0,_.useCallback)(()=>{let e=crypto.randomUUID();N(e),F(t=>[...t,e]),a(void 0)},[]),oe=(0,_.useCallback)(e=>{N(e),a(void 0)},[]),se=(0,_.useMemo)(()=>{if(U)return{message:U,approve:e=>ae(!0,e),reject:()=>ae(!1),autoApproveEnabled:o}},[U,ae,o]),ce=(0,_.useMemo)(()=>{let e=P.messages;if(e.length!==0)for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n||n.role!==`assistant`||!n.metadata||typeof n.metadata!=`object`||!(`totalUsage`in n.metadata))continue;let r=n.metadata.totalUsage;if(!(!r||typeof r!=`object`)&&!(!(`inputTokens`in r)||!(`outputTokens`in r)||!(`totalTokens`in r)))return{inputTokens:r.inputTokens,outputTokens:r.outputTokens,totalTokens:r.totalTokens,cachedInputTokens:r.cachedInputTokens}}},[P.messages]),le=(0,_.useMemo)(()=>{if(P.status!==`streaming`)return!1;if(!P.streamingMessage)return!0;let e=P.streamingMessage.parts.filter(h.isToolOrDynamicToolUIPart);return e.length>0&&e.every(e=>e.state.startsWith(`output-`))},[P.status,P.streamingMessage]);return{mode:c,setMode:d,toggleMode:f,chat:P,chats:ne,switchChat:oe,newChat:W,build:{status:m,error:p,entrypoint:v},devhook:{connected:R.status===`connected`,url:R.status===`connected`?R.url:void 0},capabilities:O,options:{schema:z,selected:B,error:V,setOption:re},approval:se,tokenUsage:ce,auth:y,server:w,showWaitingPlaceholder:le}}exports.useAgent=Ir,exports.useAuth=Pu,exports.useBundler=Fu,exports.useChat=pd,exports.useDevMode=Rv,exports.useDevhook=Wd,exports.useDotenv=Yd,exports.useEditAgent=Iv,exports.useOptions=Hd;
|