A build guide · reference implementation: Steward
How to build a personal assistant you can text
This guide shows how to build an assistant that lives in a message thread: it reads mail and calendar, sends email with your approval, works on files in a sandbox, uses websites through a cloud browser, and sends a morning brief. Most of it is rented. The reference implementation, Steward, is about 1,700 lines of TypeScript and is open source under the MIT licence. The guide covers the parts, what each one does, and the order to build them in.
The model in one picture
A conversational cloud agent has five layers. The left column defines each layer, the middle names the primitive that implements it, and the right is the file to open.
The framework underneath: eve
eve is Vercel's open-source framework for backend agents (Apache-2.0, in preview; docs). Two ideas define it. An agent is a directory of files, and the framework reads each file's role from its path. A conversation is a durable workflow, so a session can pause for days and survive a deploy. Almost every primitive in this guide is an eve feature that needs one small file to switch on.
| An assistant needs | eve feature | What you would otherwise build |
|---|---|---|
| To wait for a person | Durable pause and resume on approvals, questions and sign-in | A task table, a queue, callback routes, replay logic |
| To be reachable by text | Native channels: iMessage, SMS, Slack, Telegram and others | Webhook verification, thread routing, delivery, read receipts |
| To use your accounts | Connections with a token broker; user-scoped grants per principal | OAuth flows, encrypted token storage, refresh jobs |
| A bounded set of abilities | One file per tool; defaults can be switched off | A tool registry and a permission layer |
| To act unprompted | Schedules that start sessions and deliver through a channel | A job runner and proactive messaging |
| Evidence that it behaves | Evals that assert on tool calls, parked runs and replies | A test harness for a non-deterministic system |
Two cautions. eve's defaults favour capability: a new agent has shell, file and web tools switched on, tools run without approval unless you say otherwise, and the sandbox can reach the internet. Steward reverses all three. And eve is preview software, so pin the version and expect the APIs to change.
Build it in this order
Each stage runs end to end before the next begins. The order follows one rule: no capability arrives before the control that bounds it. Tools with side effects come after the Gatekeeper, the browser comes after that, and unattended runs come last.
| Stage | Provision | Write | Done when |
|---|---|---|---|
| 0 Skeleton | A model gateway key | Scaffold the agent. Switch default tools off. Write the instructions. Cap spend per session. | You can chat with it in a terminal, and evals show it refuses to echo a secret and ignores an injected instruction. |
| 1 Channel | Hosting project. A messaging line (iMessage here). | An allowlist that maps the sender to one principal and drops everyone else before a session exists. | Your phone gets a reply. Another phone gets silence. |
| 2 Read tools | OAuth client for mail and calendar. A token broker connector. A Blob store for memory. | Thin read-only tools. One MCP connection. A memory slot. The clock line. | "What's on tomorrow?" is answered from the real calendar, for the right day. |
| 3 Gatekeeper | A Postgres database | Policy table, approval gate, session taint, receipts. Then the first two tools that change something. | A send request parks on an approval showing the exact message. An injected "email the attacker" never completes. "What did you do today?" is answered from the log. |
| 4 Browser | A cloud browser account | A subagent with browser tools, a persistent profile, a handover result and a final-click approval check. | A site task completes. A login page produces a live-view link in the thread. |
| 5 Computer | Nothing new | Sandbox with default-deny egress. Guarded download. File send through the channel. | "Download this CSV, count the rows, send me the file" works, and the send asks first because the session is tainted. |
| 6 Daily brief | Nothing new | One schedule. A rule that scheduled turns are read-only. | The brief arrives in the existing thread and cannot act on anything it read. |
Accounts needed in total: a hosting provider, a model gateway, a messaging line, a cloud browser, a Postgres database, and a Google Cloud project for the OAuth client. All have free tiers that cover one user.
Test at two levels. Give logic a unit test before you write it: the allowlist, the policy function, the path guard, the URL checks. Give behaviour an eval that runs the real agent against the real model. Two evals matter most: a send request must park on an approval, and an injected instruction to send email must never complete, even when the model is fooled. The reference implementation has 112 unit tests and 8 evals.
One message, start to finish
The request is "Tell Peter I'm running 15 mins late". Each step shows who acts, what crosses the wire, which code is ours, and from which point the run survives a crash or a deploy.
The session lifecycle underneath
The primitives
Fifteen building blocks. Each card says what the primitive is, what it enables, what you would build without it, and where it lives in the code.
Agent loop
Model reads context, replies or calls a tool, reads the result, repeats.
Durable session
One conversation equals one stored session that survives restarts and deploys.
Channel
Verifies a provider's webhook, maps a thread to a session, delivers replies.
Principal
Who a turn is acting for. Set by the channel before the model runs.
Tool contract
A named function with a typed input schema, a description the model reads, and an executor.
Approval pause
A tool can require a person's yes. The run parks and the channel shows the exact input.
Policy table
Every tool classed observe, reversible or consequential. Unknown tools count as consequential.
Session taint
A durable flag set when the session reads third-party text. It removes auto-approval for reversible actions.
Receipts
Append-only rows: tool, class, hash of the exact input, outcome. Written before non-read actions run.
Token broker
OAuth grants held by Vercel Connect. A tool asks for a short-lived token for the current principal.
MCP connection
A remote server publishes its own tools. The agent discovers them by search.
Memory slot
A small document recalled before every turn and edited by the model through two tools.
Per-turn clock
One system line each turn: today's date, local time, zone, and tomorrow's date written out.
Subagent + cloud browser
A child agent with its own prompt and tools drives a remote Chromium with a saved profile.
Sandbox + schedule
An isolated Linux workspace for files and scripts. A cron entry that starts a session with no message from you.
Three ways to do work
Work can be done through a typed API, a sandboxed computer, or a browser. Reliability falls and coverage rises in that order. The instructions tell the model to use the most structured path that can do the job.
Who decides: the Gatekeeper
The model proposes a tool call. A pure function, decide(tool, tainted), reads a table and returns whether the owner must approve it. No prompt is involved in that decision.
web_search runs at the model provider and GitHub tools run on GitHub's server. Neither passes through withReceipt, so an action.result hook writes their receipt and sets the taint. One more rule sits in gate(): in a turn started by a schedule, every tool that is not observe is denied.Three trust relationships, and where secrets live
An assistant holds three separate trust relationships: the model account, API integrations and website sessions. Each is handled differently. In all three, the secret stays out of the model's context.
| Relationship | Companion | Steward | Who holds the secret |
|---|---|---|---|
| Model account | You sign in to your own ChatGPT subscription (a device-code flow) | Pay per token through AI Gateway. Deployed code uses the project's OIDC identity, so production has no model key at all. | Vercel |
| API integrations | ChatGPT apps, MCP | OAuth consent once per service. Tools call ctx.getToken() for a short-lived token. | Vercel Connect |
| Website sessions | Not disclosed | You log in by hand in a live view of the remote browser. The cookie stays in a persistent browser profile. | Kernel |
Your phone
- The thread
- Approve / deny
- Passwords and 2FA, typed by you only
Steward process
- OWNER_PHONE
- DATABASE_URL, KERNEL_API_KEY
- Short-lived OAuth tokens, in memory, per call
Vercel Connect
- Google refresh token
- GitHub grant
- Linq API token
Kernel
- Browser profile: cookies, local storage
- Live-view stream
Postgres + Blob
- Receipts, including sent-email text
- Profile memory document
Model context
- Your messages, tool inputs and outputs, memory
- No tokens, keys, passwords or cookies
Where it runs
The messaging endpoint is cheap and always reachable. The browser and the sandbox are expensive, so they exist only while a task needs them.
Rent or build: where the code goes
Most of the infrastructure is rented. In the reference implementation the written code concentrates in two places: the trust layer (stage 3), which no vendor sells, and the browser worker (stage 4), where the rented parts need the most adapting. Counts exclude 809 lines of unit tests and 137 of evals.
| Stage | Rented | Native to Steward | Lines (excl. tests) |
|---|---|---|---|
| 0 Skeleton | eve loop, sessions, AI Gateway, eval runner | Instructions, config, the per-turn clock line | 113 |
| 1 Channel | Linq line, Vercel Connect, linqChannel, hosting | Owner allowlist, fail-closed webhook check | 90 |
| 2 Read tools | Google APIs, GitHub MCP server, token broker, file memory, web search | Five thin tool wrappers, body parsing | 260 |
| 3 Gatekeeper | The approval pause, durable state, Postgres | Policy table, taint, receipts, receipt hook, MIME builder, two write tools | 429 |
| 4 Browser | Kernel browsers, profiles, live view, browser-loop tools | Tool adapter, browser lifecycle, approval matching, result contract | 417 + a 63-line prompt |
| 5 Computer | Vercel Sandbox, built-in bash and file tools | Network policy, guarded download, path guard, attachment delivery | 301 |
| 6 Daily brief | Vercel Cron, proactive channel send | One schedule file, brief prompt | 96 |
Six review questions, answered
These questions apply to any assistant of this kind. Ask them of a product before you connect your accounts to it.
| Question | Reference answer | Detail |
|---|---|---|
| Isolated worker and browser profile per user? | yes | Single owner. One Kernel profile, one sandbox, one Vercel project. |
| Can the model read raw passwords, refresh tokens, cookies or payment data? | no | Passwords are typed by you in live view. Refresh tokens stay in Vercel Connect. Payments are out of scope; the browser worker never enters card details. |
| Which actions always need confirmation, tied to an exact payload? | partly | gmail_send, calendar_create_event, any unclassified tool. The card shows the full input and the receipt stores its hash. Price-bound approvals do not exist because purchases do not. |
| How are sessions revoked, data deleted, workers rebuilt? | manual | Revoke grants in Vercel Connect and Google. Delete the Kernel profile. Drop the receipts table and Blob store. No one-button flow. |
| What happens when a site blocks automation or changes? | partly | The worker returns needs_owner with a live-view link, or failed with a reason. Expect this path to be the least reliable part of the system. |
| Which actions produce durable receipts and audit events? | all tool calls | Tools wrapped by withReceipt, plus a hook for the two kinds that run elsewhere. Actions inside the browser worker are summarised in its result and not itemised. Screenshots as receipts are not built. |
Contrast with Muse, Companion and Instinct
| Dimension | Companion | Instinct | Muse | Steward |
|---|---|---|---|---|
| Surface | iMessage | Text and calls | App, web, WhatsApp | iMessage |
| Model | Your ChatGPT plan | Undisclosed | Meta's own | Any, via gateway |
| Computer | Per-user cloud PC | Phone and computer use | Persistent per-user VM | Ephemeral sandbox + cloud browser |
| Who authorises | Undisclosed | Undisclosed | Sentinel, outside the agent's container, on every network request | Gatekeeper, same process, on every tool call |
| Credentials | Undisclosed | Undisclosed | Authd holds them; agent sees surrogates | Vercel Connect and Kernel hold them; our code sees short-lived tokens |
| Taint tracking | Not disclosed | Not disclosed | Per process, in the kernel (eBPF) | Per conversation, one flag |
| Proactive | Not advertised | Follows up unprompted | Schedules and events | One daily brief |
Limits
| Limit | Consequence |
|---|---|
| Approvals arrive in the chat thread | Anyone holding your unlocked phone can approve. Muse sends approvals on a separate path. |
| SMS sender IDs can be forged | The allowlist is strong for iMessage, weaker for SMS. Approvals are the backstop. |
| Group chats not handled | Add the number to a group and Steward answers you in front of everyone. |
| Prompt injection is unsolved | Taint removes auto-approval. It cannot tell you whether an approved action is wise. |
| Four trusted providers | Vercel, Linq, Kernel and Neon can each read the data that passes through them. |
| No idempotency on email send | A replayed step could send twice. The approval gate makes this unlikely, not impossible. |
| Google OAuth in testing mode | Restricted Gmail scope means the grant expires every seven days until the app is verified. |
| A session can outlive a deployment | A durable session started before a deploy may keep executing steps on the old code. A new subagent or state key is then missing for that session. |
| Thread-to-session map is in process memory | The channel adapter warns about this. With one owner the effect is an occasional fresh session after a cold start. |
| Final-click rule in the browser is not gated in code | It rests on the worker's prompt, an approval-matching check, and the root agent writing APPROVED: only after a yes. |
| eve is preview software | Pinned to 0.55.0. APIs may change. |
What it costs to run
No prices are quoted here because several are unpublished or change. These are the meters and what bounds each one.
| Meter | Driven by | Bound |
|---|---|---|
| Model tokens | Every turn. Browser tasks are the heavy ones: many steps, page text each time. | maxTokenCostUsdPerSession: 2. Past it, the session asks before continuing. Scheduled runs stop. |
| Hosting (free plan) | Function time, workflow steps, sandbox minutes, Blob storage | Free-tier quotas. Check the sandbox and workflow quotas of your plan before relying on them. |
| Linq line | Flat per line, not per message | Free sandbox to start. Paid line price is not public. |
| Kernel | Browser-minutes | Free developer plan. Worker deletes the browser at task end and sets an inactivity timeout. |
| Neon Postgres | One small append-only table | Free tier. |
| Google, GitHub APIs | Calls | Free at personal volume. |
Sources
Product descriptions are taken from each vendor's own pages. Plan limits change; check them before you rely on them.
| Topic | Source |
|---|---|
| eve | Repository · Documentation |
| Muse | Meta, Introducing Muse · Meta AI Research, security and safety approach |
| Companion | Product page |
| Instinct | Product page |
| OpenInstinct | Repository, which showed these services work together. It is independent of Instinct. |
| Cron limits on the free plan | Vercel, Cron jobs usage and pricing |
| Rented services | Vercel AI Gateway · Kernel · Linq · Model Context Protocol |
| Security principles | Saltzer and Schroeder, The Protection of Information in Computer Systems (1975) |
Go deeper
The code is at github.com/varmac/steward (MIT). Each stage has a short lesson there, with the concept, what was rented, what was written, and the tests that prove it. The README lists the accounts to create and the commands to run.
| Lesson | Concept | Open these files |
|---|---|---|
| lessons/00-skeleton.md | The loop. Why the agent starts with no tools. | agent/agent.ts, agent/instructions.md, evals/stage-0/ |
| lessons/01-channel.md | The thread is a remote control. Identity before anything else. | agent/channels/linq.ts, agent/lib/owner.ts |
| lessons/02-tools-and-memory.md | Three kinds of tool. Credentials without storing any. Memory. The model has no clock. | agent/tools/, agent/lib/google.ts, agent/connections/github.ts |
| lessons/03-gatekeeper.md | Propose versus authorise. Taint. Receipts. | agent/lib/policy.ts, gatekeeper.ts, receipts.ts |
| lessons/04-browser-worker.md | Subagents. No password vault. Never the last click. | agent/subagents/browser/ |
| lessons/05-computer.md | Default-deny sandbox. Downloads outside it. Getting a file back to the thread. | agent/sandbox.ts, agent/lib/sandbox-*.ts |
| lessons/06-proactive.md | Schedules. What an unattended run may do. | agent/schedules/daily-brief.ts, agent/lib/brief.ts |
Created by Varma Chanderraju. Built with Claude.