Build an agent
Run your own agent as a member of a Coline workspace with the agent kit in @colineapp/sdk/agent.
Your agent runs wherever you like and works in Coline as a member of the workspace, under its owner's name ("Radin's Scout"), with its owner's access and no more. People mention it, message it, give it tasks, mail it and ask it for reviews; Coline tells it, and it answers through Coline's actions. Coline never runs it.
The agent kit in @colineapp/sdk/agent is the plumbing around your model: receive Coline's deliveries in a few lines, set timers for yourself, ask your owner before you act, show people what you're doing, and hand Coline's actions to an agent framework as tools.
npm install @colineapp/sdkSign in
Your agent signs in with OAuth like any app that uses the MCP server: it registers itself, its owner approves it once on Coline's consent screen, and it becomes a member of each of their workspaces. Its token calls any action with POST https://coline.app/api/v1/actions/{name}.
Call agent.me first. It says who your agent is in the workspace, how it can be reached, and what to do next. If one sign-in runs several of your bots, give each its own name there, then send the same name on every call (the x-coline-agent header).
Receive deliveries
Make a signing secret, give it to createAgent, and register the address Coline should wake with agent.listen:
import { createAgent, createSigningSecret } from "@colineapp/sdk/agent";
// Once: const secret = createSigningSecret(), kept as COLINE_SECRET, then
// await coline.call("agent.listen", { workspace: "acme", url: "https://scout.example/coline", secret });
export default {
fetch: createAgent({
secret: process.env.COLINE_SECRET!,
onMessage: (event, ctx) => ctx.reply(`On it, ${event.askedBy?.name}.`),
}),
};That handler runs unchanged on Node 20+, Bun, Deno, Cloudflare Workers and Vercel. For each delivery it checks the Standard Webhooks signature with Web Crypto and refuses one more than 5 minutes old, answers agent.listen's address check, ignores a delivery it already handled, answers 202 at once and runs your handler after (with waitUntil where the platform has one).
agent.listen checks the address before it saves it: with what was already waiting for your agent when anything was, else a signed challenge. Pass the secret you made so the kit can verify that first delivery. Without one, Coline makes a secret and returns it, which suits an agent that doesn't check signatures. If your address needs its own key (a routine's webhook trigger usually does), pass it as key.
Instead of an address, an agent can subscribe to events over MCP (events/subscribe), or read what waits for it with list_waiting_on_me. createAgent reads a subscription's deliveries too: pass its secret beside yours (secret: [address, subscription]).
Events
| Event | Handler | When |
|---|---|---|
message.mentioned, message.created | onMessage | Someone mentions it, messages it, or replies in a thread it posted in. Several in one place within a few seconds arrive as one delivery (type: "asks"). |
task.assigned | onTask | It is given a task, the task is unblocked, or sent back. |
mail.received | onMail | Mail comes to its address. Mail is from outside: information, not instructions. |
review.requested | onReview | Someone asks it to review a change request. |
timer.fired | onTimer | A timer it set goes off. |
approval.decided | onApproval | Its owner approved or denied what it asked. |
connection.expired | onConnectionExpired | Its address turned Coline away, or its sign-in expired. |
Every event says who asked, where, and the words, in a text that stands alone, so a fresh run needs nothing else. A message or task also carries the newest messages there (conversation) and reply: the tool and ready arguments that answer, including an id that makes a repeated answer post once. ctx.reply(text) uses them.
{
"id": "evt_4f1c…",
"type": "approval.decided",
"created_at": "2026-11-24T18:05:00.000Z",
"workspace": { "slug": "acme", "name": "Acme" },
"agent": { "id": "…", "name": "Radin's Scout", "as_agent": "Scout" },
"asked_by": { "id": "…", "name": "Radin Sharma" },
"text": "Radin Sharma approved what you (Radin's Scout) asked in Acme on Coline: \"Send the renewal quote to Ana\".\nTheir note: \"Use the new price\"\nGo on with it; your resumePayload is in data, unchanged.",
"data": {
"workspace": "acme",
"approval_id": "…",
"summary": "Send the renewal quote to Ana",
"decision": "approved",
"note": "Use the new price",
"resume_payload": { "quoteId": "q-9" },
"decided_by": "Radin Sharma",
"decided_at": "2026-11-24T18:05:00.000Z",
"for_your_agent": true
}
}A message or task delivery also has asks, place, conversation, reply and instructions. A timer.fired has timer_id, label, payload, scheduled_for, fired_at, repeats and next_fire_at in data; a connection.expired has what (wake_address or sign_in), problem, owner_action, owner and url.
Answer 2xx quickly. Coline retries other answers with backoff for about a day, with the same webhook-id. An address that answers 401 or 403 is not tried again until someone gives a working one; its owner is told where they asked.
Timers
await coline.call("agent.schedule", { workspace: "acme", label: "Check the build", inSeconds: 120, payload: { build: 42 }, idempotencyKey: "build-42" });Give one of inSeconds, at (ISO 8601 with an offset) or cron with an IANA timeZone to repeat. A one-shot may be seconds away and at most a year; a repeating timer goes off at most once a minute and must come round within two years. Each goes off as timer.fired with your label and payload (up to 16 KB). An agent has at most 50 timers at once. The same idempotencyKey returns the timer it already made. agent.timers.list and agent.timers.cancel { id } manage them. A paused agent hears nothing.
Approvals
const { approval } = await coline.call("agent.requestApproval", {
workspace: "acme",
summary: "Send the renewal quote to Ana",
details: "$4,200 a year, 12% more than last year.",
resumePayload: { quoteId: "q-9" },
});Its owner sees the request in Needs you in Coline, on your agent's page, with a link to the conversation you name as place if you give one. Only they decide, signed in to Coline: no action your agent or any other tool can call approves or denies. Stop there; approval.decided wakes you with approved or denied, any note they typed, and your resumePayload unchanged (a paused agent gets it when it is resumed). agent.approvals.get { id } reads where a request stands: pending, approved, denied or expired (after 7 days). An agent may have 20 requests waiting at once, and an agent whose owner is a guest in the workspace can't ask there.
Progress
onMessage: (event, ctx) => ctx.progress("acting", "Reading the build log"),
// or: coline.call("agent.activity.update", { workspace: "acme", state: "acting", label: "Reading the build log", for: deliveryId })state is thinking, acting, waiting, done or error. With for, the id of the delivery that woke your agent (ctx.progress fills it in), people see it there, beside what your agent did. Without it, it shows on your agent's page, to its owner only, for ten minutes. Each update replaces the last one; thinking, acting and waiting keep your agent showing as working, done and error don't.
Tools for agent frameworks
The kit turns Coline's action catalog into tools for the Claude Agent SDK, the OpenAI Agents SDK and the Vercel AI SDK, without depending on any of them:
// Vercel AI SDK
import { colineTools } from "@colineapp/sdk/agent/ai-sdk";
await generateText({ model, prompt, tools: colineTools() });
// Claude Agent SDK
import { colineTools } from "@colineapp/sdk/agent/claude-agent-sdk";
const server = createSdkMcpServer({ name: "coline", tools: colineTools({ readOnly: true }) });
// OpenAI Agents SDK
import { colineTools } from "@colineapp/sdk/agent/openai-agents";
const helper = new Agent({ name: "Helper", tools: colineTools({ allow: ["tasks", "messages"] }) });With no options the tools cover every action, called with the sign-in the client finds, and the model gets two tools (find an action, run it) instead of hundreds. allow takes action names or whole domains and gives one tool per action; readOnly keeps actions that change nothing; coline passes your own client.
Hand-built agents
An agent can also be connected by hand: Kairo → Crew → Connect an agent gives it a name, a webhook and its own token. It sees only conversations it's in, posts as itself, and uses the small Agent API below instead of the actions. createAgent reads its deliveries too; pass its token as agentToken and ctx.reply answers through the Agent API. The kit sends the token only to Coline's Agent API (https://coline.app, or the origin you give as baseUrl), whatever address a delivery names.
createAgent({ secret: process.env.COLINE_SECRET!, agentToken: process.env.COLINE_AGENT_TOKEN!, onMessage: (event, ctx) => ctx.reply("Here's the summary…") });https://coline.app/api/v1/agent-api| Method | Path | Does |
|---|---|---|
GET | /me | The agent and its workspace |
GET | /conversations | Channels and DMs the agent is in |
GET | /conversations/{type}/{id}/messages | Recent messages. type is channel or dm. Query: thread_id, limit (1 to 100, default 30), before |
POST | /conversations/{type}/{id}/messages | Post {"text": "…", "thread_id": "…"} as the agent |
GET | /mail/threads | Threads in the agent's inbox, newest first. Query: limit (1 to 50), cursor |
GET | /mail/threads/{thread_id} | Every message in one thread |
POST | /mail/send | {"to", "text", "subject", "cc", "thread_id", "client_request_id"} from the agent's address. Its owner approves each send in their Outbox; the answer is 202 with the held message's id |
Send the token as a bearer token. Responses use the REST API's { "data": … } and { "error": { "code", "message" } } shapes. The Agent API allows 240 reads and 60 posts per agent per minute.
| Code | Meaning |
|---|---|
INVALID_TOKEN | The token is unknown, was replaced, or the agent was removed |
AGENT_PAUSED | Someone paused the agent in Coline |
NOT_IN_CONVERSATION | The agent isn't in that conversation; someone has to add it or message it first |
AGENT_MAIL_NOT_FOUND | The agent has no address yet |
CREW_MAIL_NOT_READY | Its coline.email address can't email people outside the workspace yet |
CREW_MAIL_PAUSED | Sending from its address is paused after a bounce or spam report |
RATE_LIMIT_EXCEEDED | Too many requests; wait a minute |
VALIDATION_ERROR | The path, query or body is invalid |