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.

STAGE 0Skeletonthe loop
STAGE 1Channelidentity
STAGE 2Read toolscapability
STAGE 3Gatekeepercontrol
STAGE 4Browsercoverage
STAGE 5Computerdata work
STAGE 6Daily briefproactivity

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.

REFERENCE MODEL PRIMITIVE IN STEWARD 1 · Channel Receives requests. Returns questions, approvals and receipts. Not the worker. Webhook channel + identity mapping Linq line · Vercel Connect · linqChannel onMessage → principal "owner" or drop agent/channels/linq.ts agent/lib/linq-inbound.ts agent/lib/owner.ts 2 · Control plane Identity, queues, task state, scheduling, notifications. Durable session + workflow + cron eve sessions · Workflow · Cron park at session.waiting, resume on answer rented, no file of ours agent/schedules/daily-brief.ts the one schedule 3 · Reasoning model Interprets intent, picks the next action. Does not contain Gmail or a browser. Model behind a gateway + instructions AI Gateway id string · system prompt file per-session spend cap agent/agent.ts agent/instructions.md (+ clock.ts) agent/memory/profile.ts 4 · Tool router Named capabilities with schemas, credentials and policy checks. Tool contract · approval · receipts eve defineTool · approval pause GATEKEEPER: THE PART WE WROTE agent/lib/policy.ts agent/lib/gatekeeper.ts agent/lib/receipts.ts 5 · Execution plane Does the work: direct APIs, a cloud browser, an isolated computer. Connectors · sandbox · cloud browser Google APIs · GitHub MCP · Vercel Sandbox Kernel browser in a subagent agent/tools/*.ts agent/connections/github.ts agent/subagents/browser/
Blue boxes are rented primitives. The amber box is the layer where Steward adds its own design.

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.

YOU WRITE A FILEEVE GIVES YOU agent/ agent.ts instructions.md · instructions/ tools/gmail_send.ts connections/github.ts channels/linq.ts memory/profile.ts subagents/browser/ sandbox.ts schedules/daily-brief.ts hooks/untrusted-results.ts model choice, spend limits, default tools on or off the system prompt, static or resolved per turn a tool named gmail_send, with typed input and an optional approval pause every tool a remote MCP server publishes, found by search a verified webhook route, thread-to-session mapping, reply delivery a document recalled before each turn, scoped to the caller a child agent with its own prompt, tools and context an isolated /workspace with a network policy a cron job that starts a session and delivers through a channel a subscriber on the event stream, for audit and side effects
Names come from paths. There is no registry to keep in sync: the directory listing is the list of what the agent can do.
Channel normalises inbound messages maps an address to a session renders replies and approvals for its platform Harness does one step of AI work: model call, tool run, approval check then: continue, wait or finish compacts long history Durable runtime (workflow engine) records each step; a crash replays the last parks a waiting session with no compute holds session state, streams events Vercel Workflow, or a Node server elsewhere Local development runs all three in one process: terminal chat, hot reload, and an eval runner over HTTP.
The approval pause, the login handover and the OAuth consent link all use the same mechanism: a session parked until a person answers.
An assistant needseve featureWhat you would otherwise build
To wait for a personDurable pause and resume on approvals, questions and sign-inA task table, a queue, callback routes, replay logic
To be reachable by textNative channels: iMessage, SMS, Slack, Telegram and othersWebhook verification, thread routing, delivery, read receipts
To use your accountsConnections with a token broker; user-scoped grants per principalOAuth flows, encrypted token storage, refresh jobs
A bounded set of abilitiesOne file per tool; defaults can be switched offA tool registry and a permission layer
To act unpromptedSchedules that start sessions and deliver through a channelA job runner and proactive messaging
Evidence that it behavesEvals that assert on tool calls, parked runs and repliesA 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.

StageProvisionWriteDone when
0 SkeletonA model gateway keyScaffold 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 ChannelHosting 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 toolsOAuth 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 GatekeeperA Postgres databasePolicy 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 BrowserA cloud browser accountA 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 ComputerNothing newSandbox 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 briefNothing newOne 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.

Your phone Channel Model Gatekeeper Gmail API iMessage → Linq webhook owner? → session instructions + memory + message propose gmail_send{to,subject,body} consequential → ask approval card: exact recipient and text · session parks Approve (minutes or days later) · session resumes receipt: started send with short-lived token {sent:true,id} · receipt: ok "Sent. Told Peter you're 15 behind."


      
front channel (to or from you)back channel (server side)call that carries a credential

The session lifecycle underneath

idlestored, no compute running a turnmodel ⇄ tools waiting on youapproval · sign-in · browser takeover message / cron reply sent gate says "ask" you answer every step is checkpointed by the workflow engine, so a crash or redeploy replays from the last step
Every pause in the user journey (a question, a login, an approval) is the amber state. A parked session uses no compute, and it can wait for days.

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.

Loop

Agent loop

Model reads context, replies or calls a tool, reads the result, repeats.

EnablesMulti-step work from one request.
Without itA tool-calling loop, retries, context compaction.
eve harness · agent/agent.ts
State

Durable session

One conversation equals one stored session that survives restarts and deploys.

EnablesPauses of days. Replies that remember the thread.
Without itA task table, a queue, a state machine, replay logic.
eve sessions on Vercel Workflow
Surface

Channel

Verifies a provider's webhook, maps a thread to a session, delivers replies.

EnablesiMessage as the whole user interface.
Without itAn iMessage relay, signature checks, thread routing.
agent/channels/linq.ts · 8 lines
Identity

Principal

Who a turn is acting for. Set by the channel before the model runs.

EnablesOwner-only access. Per-person tokens and memory.
Without itAccounts, login, phone verification.
agent/lib/linq-inbound.ts · owner.ts
Capability

Tool contract

A named function with a typed input schema, a description the model reads, and an executor.

EnablesA short, auditable menu of what the agent can do.
Without itFree-form code execution with every credential in reach.
agent/tools/*.ts · defaultTools: false
Control

Approval pause

A tool can require a person's yes. The run parks and the channel shows the exact input.

EnablesConsequential actions with a human in the loop.
Without itCallback URLs, pending-action storage, resume logic.
eve HITL · gate() in gatekeeper.ts
Control

Policy table

Every tool classed observe, reversible or consequential. Unknown tools count as consequential.

EnablesOne file that answers "what may it do alone?"
Without itRisk decisions scattered across prompts and tools.
agent/lib/policy.ts · ours
Control

Session taint

A durable flag set when the session reads third-party text. It removes auto-approval for reversible actions.

EnablesLess freedom after reading a web page or email.
Without itInjected text acts with the same freedom as you.
defineState in gatekeeper.ts · ours
Audit

Receipts

Append-only rows: tool, class, hash of the exact input, outcome. Written before non-read actions run.

Enables"What did you do today?" answered from a log.
Without itTrusting the model's recollection.
agent/lib/receipts.ts · Postgres · ours
Credentials

Token broker

OAuth grants held by Vercel Connect. A tool asks for a short-lived token for the current principal.

EnablesNo token storage, refresh or consent UI in our code.
Without itAn OAuth client, encrypted token store, refresh jobs.
agent/lib/google.ts · ctx.getToken()
Integration

MCP connection

A remote server publishes its own tools. The agent discovers them by search.

EnablesA whole product's API in 18 lines.
Without itOne hand-written tool per endpoint.
agent/connections/github.ts
Memory

Memory slot

A small document recalled before every turn and edited by the model through two tools.

EnablesPreferences that outlive a conversation.
Without itStorage, recall and scoping per person.
agent/memory/profile.ts · Blob store
Context

Per-turn clock

One system line each turn: today's date, local time, zone, and tomorrow's date written out.

Enables"Tomorrow" and "Friday" resolved correctly.
Without itThe model guesses the date, and guesses wrong.
agent/instructions/clock.ts · dynamic instructions
Execution

Subagent + cloud browser

A child agent with its own prompt and tools drives a remote Chromium with a saved profile.

EnablesSites with no API. Logins you do once by hand.
Without itBrowser fleet, anti-bot handling, live view, profiles.
agent/subagents/browser/ · Kernel
Execution

Sandbox + schedule

An isolated Linux workspace for files and scripts. A cron entry that starts a session with no message from you.

Enables"Chart this CSV." A morning brief.
Without itContainer lifecycle, egress rules, a job runner.
agent/sandbox.ts · agent/schedules/

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.

STRUCTUREDFRAGILE 1 · Connectors typed API calls and MCP tools gmail_search · gmail_read_thread gmail_send · calendar_* github__* · web_search · web_fetch RELIABILITY COVERAGE YOUR EFFORT One OAuth consent, then silent. 2 · Computer sandbox with shell and files bash · read_file · write_file send_file (result back to thread) network: default deny RELIABILITY COVERAGE YOUR EFFORT Companion's "personal computer". 3 · Browser a subagent drives remote Chromium navigate · read page · act hand over for login or CAPTCHA stop before the last click RELIABILITY COVERAGE YOUR EFFORT Covers any site. Fails most often.
Bars are relative judgments, not measurements.

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.

Action class
Session is clean
Session has read third-party text
observegmail_search, web_fetch, receipts, calendar_list_events, github__*, browser
allow
allow
reversiblewrite_file, bash, send_file, download_file
allow
ask you
consequentialgmail_send, calendar_create_event
ask you
ask you
not in the tableany tool nobody classified
ask you
ask you
model proposes gate(name)decide(class, taint) you approve withReceipt(name)"started" row or abort tool runs allow ask result was written by a third party → session tainted → "ok" receipt
Two kinds of tool run outside our process: 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.

RelationshipCompanionStewardWho holds the secret
Model accountYou 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 integrationsChatGPT apps, MCPOAuth consent once per service. Tools call ctx.getToken() for a short-lived token.Vercel Connect
Website sessionsNot disclosedYou log in by hand in a live view of the remote browser. The cookie stays in a persistent browser profile.Kernel
Zone

Your phone

  • The thread
  • Approve / deny
  • Passwords and 2FA, typed by you only
Zone

Steward process

  • OWNER_PHONE
  • DATABASE_URL, KERNEL_API_KEY
  • Short-lived OAuth tokens, in memory, per call
Zone

Vercel Connect

  • Google refresh token
  • GitHub grant
  • Linq API token
Zone

Kernel

  • Browser profile: cookies, local storage
  • Live-view stream
Zone

Postgres + Blob

  • Receipts, including sent-email text
  • Profile memory document
What the model sees

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.

ALWAYS REACHABLE · SCALES TO ZERO Vercel Functionswebhook, health and cron routes Vercel Workflowsession steps, parked runs, replay AI Gateway → model provider Connect → Linq, Google, GitHub ON DEMAND · BILLED WHILE A TASK RUNS Kernel browsercreated on first use, deleted afterkept alive only while waiting for you Vercel SandboxmicroVM with /workspaceegress limited to package registries One owner, so one of each at most. An isolated worker per user follows from having one user. PERSISTENCE BOUNDARY Workflow store · history, taint Neon Postgres · receipts Vercel Blob · profile memory Kernel profile · site logins Sandbox files do not persist.
On the free hosting plan a cron job runs at most once a day, some time within its hour. That is why stage 6 is one morning brief, and user-created reminders are left out.

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.

StageRentedNative to StewardLines (excl. tests)
0 Skeletoneve loop, sessions, AI Gateway, eval runnerInstructions, config, the per-turn clock line113
1 ChannelLinq line, Vercel Connect, linqChannel, hostingOwner allowlist, fail-closed webhook check90
2 Read toolsGoogle APIs, GitHub MCP server, token broker, file memory, web searchFive thin tool wrappers, body parsing260
3 GatekeeperThe approval pause, durable state, PostgresPolicy table, taint, receipts, receipt hook, MIME builder, two write tools429
4 BrowserKernel browsers, profiles, live view, browser-loop toolsTool adapter, browser lifecycle, approval matching, result contract417 + a 63-line prompt
5 ComputerVercel Sandbox, built-in bash and file toolsNetwork policy, guarded download, path guard, attachment delivery301
6 Daily briefVercel Cron, proactive channel sendOne schedule file, brief prompt96

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.

QuestionReference answerDetail
Isolated worker and browser profile per user?yesSingle owner. One Kernel profile, one sandbox, one Vercel project.
Can the model read raw passwords, refresh tokens, cookies or payment data?noPasswords 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?partlygmail_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?manualRevoke 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?partlyThe 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 callsTools 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

DimensionCompanionInstinctMuseSteward
SurfaceiMessageText and callsApp, web, WhatsAppiMessage
ModelYour ChatGPT planUndisclosedMeta's ownAny, via gateway
ComputerPer-user cloud PCPhone and computer usePersistent per-user VMEphemeral sandbox + cloud browser
Who authorisesUndisclosedUndisclosedSentinel, outside the agent's container, on every network requestGatekeeper, same process, on every tool call
CredentialsUndisclosedUndisclosedAuthd holds them; agent sees surrogatesVercel Connect and Kernel hold them; our code sees short-lived tokens
Taint trackingNot disclosedNot disclosedPer process, in the kernel (eBPF)Per conversation, one flag
ProactiveNot advertisedFollows up unpromptedSchedules and eventsOne daily brief

Limits

Largest limitThe Gatekeeper protects against a model that has been fooled. It does not protect against compromised code, because it runs in the same process as the agent. Muse's Sentinel runs outside the agent's container, where the agent cannot change it. Closing that gap takes host-level isolation, a credential service and an egress monitor, which is far more work than everything on this page.
LimitConsequence
Approvals arrive in the chat threadAnyone holding your unlocked phone can approve. Muse sends approvals on a separate path.
SMS sender IDs can be forgedThe allowlist is strong for iMessage, weaker for SMS. Approvals are the backstop.
Group chats not handledAdd the number to a group and Steward answers you in front of everyone.
Prompt injection is unsolvedTaint removes auto-approval. It cannot tell you whether an approved action is wise.
Four trusted providersVercel, Linq, Kernel and Neon can each read the data that passes through them.
No idempotency on email sendA replayed step could send twice. The approval gate makes this unlikely, not impossible.
Google OAuth in testing modeRestricted Gmail scope means the grant expires every seven days until the app is verified.
A session can outlive a deploymentA 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 memoryThe 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 codeIt rests on the worker's prompt, an approval-matching check, and the root agent writing APPROVED: only after a yes.
eve is preview softwarePinned 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.

MeterDriven byBound
Model tokensEvery 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 storageFree-tier quotas. Check the sandbox and workflow quotas of your plan before relying on them.
Linq lineFlat per line, not per messageFree sandbox to start. Paid line price is not public.
KernelBrowser-minutesFree developer plan. Worker deletes the browser at task end and sets an inactivity timeout.
Neon PostgresOne small append-only tableFree tier.
Google, GitHub APIsCallsFree at personal volume.

Sources

Product descriptions are taken from each vendor's own pages. Plan limits change; check them before you rely on them.

TopicSource
eveRepository · Documentation
MuseMeta, Introducing Muse · Meta AI Research, security and safety approach
CompanionProduct page
InstinctProduct page
OpenInstinctRepository, which showed these services work together. It is independent of Instinct.
Cron limits on the free planVercel, Cron jobs usage and pricing
Rented servicesVercel AI Gateway · Kernel · Linq · Model Context Protocol
Security principlesSaltzer 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.

LessonConceptOpen these files
lessons/00-skeleton.mdThe loop. Why the agent starts with no tools.agent/agent.ts, agent/instructions.md, evals/stage-0/
lessons/01-channel.mdThe thread is a remote control. Identity before anything else.agent/channels/linq.ts, agent/lib/owner.ts
lessons/02-tools-and-memory.mdThree 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.mdPropose versus authorise. Taint. Receipts.agent/lib/policy.ts, gatekeeper.ts, receipts.ts
lessons/04-browser-worker.mdSubagents. No password vault. Never the last click.agent/subagents/browser/
lessons/05-computer.mdDefault-deny sandbox. Downloads outside it. Getting a file back to the thread.agent/sandbox.ts, agent/lib/sandbox-*.ts
lessons/06-proactive.mdSchedules. What an unattended run may do.agent/schedules/daily-brief.ts, agent/lib/brief.ts

Created by Varma Chanderraju. Built with Claude.