Skip to content

coder/blink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License discord NPM Version

Blink is a tool for building and sharing AI agents.

  • Leverages the familiar AI SDK at it's core.
  • Built-in tools for making Slack, GitHub, and Discord bots.
  • Every agent is simply a Node HTTP server - no cloud required.

Getting Started

Install the blink package with your favorite package manager:

bun i -g blink

Create an agent:

mkdir my-agent cd my-agent blink init

Start development mode:

Note

You'll need to provide your own API keys to use language models. Put them in .env.local and the dev server will automatically load them.

blink dev

You can now edit src/agent.ts and the dev server will hot-reload your agent.

Bundle your agent as a Node package to share it with others:

blink build npm publish

Optionally, deploy your agent to blink.so:

Note

blink.so is not required to use Blink. We guarantee that Blink agents will always be local-first.

blink deploy

Building Your First Agent

Here are some examples of agents commonly built with Blink:

Developing an Agent

Blink has built-in APIs for managing chats, storage, and tools.

Chats

Blink allows you to start new chats from web requests:

import blink from "blink"; const agent = blink.agent(); agent.on("request", async (request, context) => { // Check if this is a request you'd like to start a chat for. // e.g. if this is a webhook from Slack, start a chat for that thread. // Specify a unique key for the chat so that on subsequent requests, the same chat is used. const chat = await blink.chat.upsert(`slack-${request.body.thread_ts}`); await blink.chat.message( chat.id, { role: "user", parts: [ { type: "text", text: "Hello, how can I help you today?", }, ], }, { // Blink manages chat state for you. Interrupt, enqueue, or append messages. behavior: "interrupt", } ); // This would trigger the chat event handler in your agent. }); // ... agent.on("chat", ...) ... agent.serve();

Locally, all chats are stored in ./.blink/chats/<key>.json relative to where your agent is running.

In the cloud, chats keys are namespaced per-agent.

Storage

Blink has a persistent key-value store for your agent:

import { convertToModelMessages, streamText, tool } from "ai"; import blink from "blink"; import { z } from "zod"; const agent = blink.agent(); agent.on("chat", async ({ messages }) => { return streamText({ model: "anthropic/claude-sonnet-4", system: "You are a helpful assistant.", messages: convertToModelMessages(messages), tools: { set_memory: tool({ description: "Set a value to remember later.", inputSchema: z.object({ key: z.string(), value: z.string(), }), execute: async ({ key, value }) => { await blink.storage.set(key, value); return "Saved memory!"; }, }), get_memory: tool({ description: "Get a value from your memory.", inputSchema: z.object({ key: z.string(), }), execute: async ({ key }) => { const value = await blink.storage.get(key); return `The value for ${key} is ${value}`; }, }), delete_memory: tool({ description: "Delete a value from your memory.", inputSchema: z.object({ key: z.string(), }), execute: async ({ key }) => { await blink.storage.delete(key); return `Deleted memory for ${key}`; }, }), }, }); }); agent.serve();

Locally, all storage is in ./.blink/storage.json relative to where your agent is running.

In the cloud, storage is namespaced per-agent.

Tools

Blink has helpers for tool approvals, and commonly used tools.

Manual Approval

Some tools you'd prefer to approve manually, particularly if they're destructive.

import { convertToModelMessages, streamText, tool } from "ai"; import blink from "blink"; import { z } from "zod"; const agent = blink.agent(); agent.on("chat", async ({ messages }) => { return streamText({ model: "anthropic/claude-sonnet-4", system: "You are a helpful assistant.", messages: convertToModelMessages(messages), tools: { harmless_tool: tool({ description: "A harmless tool.", inputSchema: z.object({ name: z.string(), }), execute: async ({ name }) => { return `Hello, ${name}!`; }, }), ...blink.tools.withApproval({ messages, tools: { destructive_tool: tool({ description: "A destructive tool.", inputSchema: z.object({ name: z.string(), }), execute: async ({ name }) => { return `Destructive tool executed!`; }, }), }, }), }, }); }); agent.serve();

Blink will require explicit approval by the user before destructive_tool is executed - displaying a UI to the user to approve or reject the tool call.

Toolsets

Blink has SDK packages for common tools, like Slack, GitHub, and Search:

import github from "@blink-sdk/github"; import { convertToModelMessages, streamText } from "ai"; import blink from "blink"; const agent = blink.agent(); agent.on("chat", async ({ messages }) => { return streamText({ model: "anthropic/claude-sonnet-4", system: "You are a helpful assistant.", messages: convertToModelMessages(messages), tools: { ...github.tools, }, }); }); agent.serve();

By default, GitHub tools will not have authentication. Provide context to tools:

import blink from "blink"; blink.tools.withContext(github.tools, { accessToken: process.env.GITHUB_TOKEN, // optionally, specify app auth, or your own Octokit instance });

Customizing Tools

You can override any descriptions to customize behavior:

import github from "@blink-sdk/github"; import { convertToModelMessages, streamText } from "ai"; import blink from "blink"; const agent = blink.agent(); agent.on("chat", async ({ messages }) => { return streamText({ model: "anthropic/claude-sonnet-4", system: "You are a helpful assistant.", messages: convertToModelMessages(messages), tools: { ...github.tools, // Override the default tool with your own description. create_issue: { ...github.tools.create_issue, description: "Create a GitHub issue. *Never* tag users.", }, }, }); }); agent.serve();

Custom Models

You do not need to use the AI SDK with Blink. Return a Response in sendMessages using withResponseFormat:

import * as blink from "blink"; import OpenAI from "openai"; const client = new OpenAI(); const agent = blink.agent(); agent.on("chat", async ({ messages }) => { const stream = await client.chat.completions .create({ model: "gpt-4o", messages: messages.map((m) => ({ role: m.role, content: m.parts .map((p) => { if (p.type === "text") { return p.text; } }) .join("\n"), })), stream: true, }) .withResponse(); return blink.withResponseFormat(stream.response, "openai-chat"); }); agent.serve();

Custom Bundling

Create a blink.config.ts file in your project root (next to package.json):

import { defineConfig, buildWithEsbuild } from "blink/build"; export default defineConfig({ entry: "src/agent.ts", outdir: "dist", build: buildWithEsbuild({ // ... esbuild options ... }), });

By default, Blink uses esbuild to bundle your agent.

The build function can be customized to use a different bundler if you wish.

Why Blink?

Blink is a tool for building AI agents, not a framework. It's simple at it's core. Every agent is an HTTP server that follows a basic protocol.

You provide the tools, and Blink handles the rest. We believe that the language models are the most important part of the equation, and we allow you to leverage the full power of them.

Blink will never require the cloud to run agents. Blink is MIT licensed - you don't have to trust us.

Cloud

blink deploy runs your agent in the cloud at blink.so.

This allows you to share your agent with others, and to access it from anywhere.

About

Blink is a tool for building and sharing AI agents.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Contributors 5

Languages