Kriya One 0.4.11 · generated by scripts/arch-map.mjs
How Kriya is built, and how it works end to end
Kriya is a personal assistant you talk to in a browser: chat on the left, a canvas on the right. Behind it, one small server keeps an AI coding agent (the master) running in a terminal, gives it tools, lets it start helper agents (workers), and shows you what they made, asking before anything goes out. This page is a map of that code for someone opening the repository for the first time.
The big picture
Four ideas explain most of the code:
- The agent is a real terminal program. Kriya doesn’t call an AI API itself. It runs an AI command-line tool (Claude Code, Codex, Antigravity or a local model) inside
tmux, pastes your message in, and reads what it does. - Everything for the agent goes through an inbox. Your messages, worker reports and approval decisions queue up; the master takes them one turn at a time, so nothing is lost if something restarts.
- The agent acts through “verbs”. Show a page, start a worker, ask for approval: each is a small, typed function the server offers to the session (over MCP).
- State is plain files. One folder (the “data home”) holds the conversation, the canvas pages, memory and settings. No database, no build step, no framework.
Kriya One: one person, one container
Kriya One is one Docker container per person. The installer (deploy/one/install.sh, or install.ps1 on Windows) makes it, updates it and changes its options, and stays on the machine as the kriya-one command; the control app, “Kriya One Server”, is buttons for that command. Inside the container the agent server runs with KRIYA_MODE=one: it has a first-run setup and a Settings page of its own, and keeps the vault, the task board and the machines joined with Kriya Host in the same process.
deploy/one/reach.sh). Several Kriya Ones on one machine each get their own pair of ports, data folder and network.| Kriya One | |
|---|---|
| Signing in | one password, set at first run (onethismachine.ts: no setup code on this machine) |
| Settings live in | /setup: web/one.html, web/one/, server/one*.ts; also from a terminal: kriya-one services | voice | vocab | brand | join-code |
| Vault, board, vocabulary | in-process (onevault.ts, onework.ts, through localwork.ts) |
| Kriya Host machines join | the agent itself (onehosts.ts runs server/hosts/) |
| Engines | Claude Code, Codex and Antigravity pre-installed, or a local model |
| Where it is defined | docker/one.Dockerfile (on top of the agent image), deploy/one/ |
The repository at a glance
server/
The agent server. Runs straight from TypeScript on Node 24: no build step. A flat folder; the groups below are how to read it.
web/
The control panel and the Settings page: hand-written ES modules and CSS, served as they are. web/kit/ holds the shared building blocks.
tools/
Plug-ins the agent can use. Each is a folder with a manifest.json, an MCP server and usually a canvas app.
host/
Kriya Host: one dependency-free binary for your other machines (Linux, macOS, Windows).
docker/ · deploy/ · npm/
The images (agent, Kriya One), the entrypoint and firewall, the installers and the control app (deploy/one/), and the npx wrappers for Kriya Host.
test/ · scripts/
Tests for the agent (unit and real-browser), the fakes they use, and the scripts that run, lint and release.
brands/ · templates/ · docs/
Design tokens (--ts-* colours, fonts) per brand pack, starter templates, and the guides.
The server, module by module
The server is one Node process. Its 166 files sit in one flat folder (and server/hosts/ for Kriya Host), but they fall into 15 groups. Read them in layers: entry points call features, features use the agent API and the engines, and everything stands on a small core.
await import() or by passing a callback.Core
Start-up, settings, storage, events and the front door. Everything else stands on these.
main.tsstart-up orderconfig.tssettings from the environment; the data home’s pathsstore.tsstate.json + chat.jsonl, written atomicallybus.tsevents inside the server, relayed to browsers as SSEhttp.tsevery URL: pages, REST, SSE, canvas, tool apps, filesfiles.tsuploads and which files a browser may load
+ 8 more
filelinks.tssigned download linksbrand.tsbrand packs, the HTML pages’ placeholderssvgsafe.tscleans uploaded SVG logospngbadge.tsdraws the accent dot on app iconsabout.tsSettings → Abouthelp.tsthe in-app helprelogin.tsthe “signed out” noticeloginlimit.tsslows password guessing at sign-in
Sessions
One AI command-line tool running in a tmux terminal: start it, paste a prompt, watch it, know when it is done.
session.tsa Claude Code session: start/resume, runTurn, interrupttmux.tsnew session, paste + Enter, capture the screenscreen.tsreads the screen text: idle, working, needs attentiontranscript.tsfollows the session’s transcript file for tool calls and textapiretry.ts“continue” after a provider errorlimits.tswaits for the plan’s usage window to reset
+ 1 more
usage.tsusage numbers from the status line
Engines
The same session idea for each AI CLI: Claude Code, Codex, Antigravity (agy) or a local model.
harness.tspicks the engine for a sessionclaudecode.tsthe pinned Claude Code versionlocal.tsClaude Code pointed at your own model serverlocalproto.tsthat server’s API detailscodex.tsCodex: one `codex exec` per turncodexproto.tsits config and event format
+ 15 more
agy.tsAntigravity: one `agy --print` per turnagyproto.tsits config and event formatopencode.tsOpenCode: one headless `opencode run` per turnopencodeproto.tsits config and event formatossengines.tsopen-source engines: harness × your model endpointosssession.tsPi and Qwen Code: one headless run per turnpiproto.tsPi’s config and event formatqwenproto.tsQwen Code’s config and event formatinstructions.tsa worker’s standing rules, per engineengineregistry.tsKriya One: which engines are installed, signed in, their quotaenginelogin.tssign-in flows for each engineclaudelogin.ts`claude auth login` driven for youengineinstall.tsinstalls Claude Code and agy on first use, at the tested versionharnesspins.tsthe harness versions Install puts on a joined machineengineresolve.tsan engine name to its harness and model endpoint, for host workers
Master and inbox
The main assistant: everything meant for it waits in an inbox, and it handles the inbox one turn at a time.
master.tsthe loop: drain the inbox → one turn → replypromptsetup.tsonly the instructions this setup needssetupevents.tsa setup change rewrites them and tells the sessioninbox.tsthe queue; who sent what (you, a worker, an approval)stubmaster.tsa canned master for testscompact.tscompacting a long conversation
+ 5 more
autocompact.tsdoing that automatically, carrying context overmodelswitch.tsswitching model mid-conversationdelegateguard.tsnudges the master to delegate long jobswatchdog.tsperiodic check-ins on running workskills.tsskills (SKILL.md): how recurring jobs are done
Agent API and workers
What an agent can ask the server to do (“verbs”), and the helpers the master starts.
verbs.tsthe table of verbs: input shape, who may call itmcp.tsthe verbs as an MCP server for the sessionsworkers.tsspawn, brief, follow, nudge, finishhostworkers.tsworkers that run on a joined machine
Canvas and approvals
The right-hand pane: pages the assistant shows, their versions, and your yes/no.
canvas.tsitems, versions, shared state, approvalscanvasorigin.tscanvas pages get their own origin (port + 100) and tokenscanvasprune.tskeeps the newest versionsapprovalsupersede.tswhich older approvals a new one replacesapps.tsstarts a page’s backend (start.sh) and proxies itreview.tsPoint & say: screenshots with your pins
+ 3 more
csp.tswhat canvas content may loadframecheck.tscan this URL be shown in a frame?panelauth.tsonly the panel itself may decide approvals
Tools
Plug-ins: an MCP server the agent calls plus an app the canvas shows.
tools.tsfinds tools, hands their MCP servers and secrets to sessionstoolguard.tseach tool in git; snapshot, start-up check, revert on failurevscode.tsVS Code (code-server) on the canvas: started on demand, proxied, code_open / code_diff / code_run / code_statevscodecmds.tswhich VS Code commands code_run may send (a denylist; terminal typing only when allowed)
Voice
Speech in and out: for the panel, the phone app and hands-free use.
voice.tstranscribe, speak, split a reply into what to sayvoicesession.tsthe phone’s live voice session over a WebSocketws.tsa minimal WebSocket serverservices.tswhich speech / model services are configuredvocab.tsyour vocabulary: names it should get rightvocabfix.tscorrects transcripts with it
+ 13 more
dictate.tssecure dictation into a pagedictategrammar.tsits spoken commandsaudiorender.tsrendering audio filesvoicemodels.tsmodel weights for speech in the browservoicefocus.tsonly the agent in focus speaksshortcuts.tsthe panel’s keyboard shortcuts, kept for every browserunheard.tsreplies held until you can hear themupdates.tsbackground updates to read outtakes.tseach spoken take delivered oncedevices.tsphone device tokensvoicewarn.tsthe title bar’s voice warningasrclient.tsspeech-to-text over Kriya’s or the OpenAI-compatible protocolvoiceruntime.tsKokoro’s pronunciation runtime, fetched once at run time
Security and the guard
Keeps secrets out of sessions and stops text from the web steering the agent.
safeenv.tsthe only environment child processes getguard.tsthe prompt-injection guardguardverbs.tsits verbsuntrusted.tswraps outside text as “untrusted”digest.tssummarises untrusted text with a tool-less modelvault.tsfills logins into pages without showing them to the agent
+ 5 more
vaultweb.tsHTTP auth and PDF unlock from the vaultotp.tsone-time codestotp.tsauthenticator codesbrowserhandoff.tshands a CAPTCHA or login to youbrowsersettings.tsthe web browser tool’s settings
Work: board, playbooks, activity
The task board, playbooks and vocabulary, answered in this process; screen time and desktop incidents.
localwork.tsthe work services, in-process (onework.ts, onevault.ts)apiutil.tsJSON route helpers; this agent’s identityboard.tsthe task board’s verbsplaybooks.tssite playbooksactivity.tsscreen time for break remindersactivitylog.tsits log
+ 1 more
deskincident.tsincident reports from a desktop
The Gmail tool’s server side.
mailbox.tsmailbox verbs and the panel’s viewimap.tsa minimal IMAP clientsmtp.tsa minimal SMTP client
Automations
Things that run on a schedule or when something happens.
automations.tsruns them; the panel’s viewautomationverbs.tsthe verbs to create and change themautotriggers.tspolled triggers: files, board, a web page, emailcron.tsschedules in cron or plain words
Phone, desktop, Kriya Host
The server’s side of the devices it works with.
phonelink.tslink a phone; its live viewphonerelay.tsthe phone’s WebSocket relayphonesnap.tsscreenshots when the video has no picturephoneaction.tsactions on the phonelinkws.tsa WebSocket server for the relaydesk.tsdesktop actions through the panel
+ 8 more
desktoplink.tsdesktop control through Kriya Hostoneclicker.tsclicker buttons from Kriya Hostonedesktop.tspairing Kriya Desktoponephones.tspairing phones by QRtelegram.tsthe Telegram channel: a paired chat, by long pollingonehostlink.tsthe registry of joined machinesonehosts.tsruns the Kriya Host link (server/hosts/) in-processonecomputer.tsthe Computer control switch per machine
Kriya One
What makes the single-container product: first-run setup, every Settings card’s API, the service registry.
one.tssetup, sign-in, and the /api/one/* routesoneservices.tsthe services registry: probe, test, health looponemodels.tswhat local models are used foronenetwork.tsnetworking and reachabilityonesettingsreg.tssettings the assistant may changeonesettingsverbs.tsthe verbs to change them (with approval)
+ 16 more
oneskills.tsskill switchesonecodetools.tsGraphviz and gortexonefilesearch.tssearch your files by meaningonehttps.tsHTTPS for other devicesqr.tsQR codesappinstall.tsinstall-as-app: asked once, reported by the apponecli.ts`kriya-one services`, `voice`, `vocab`, `brand`, `join-code`: the workonecli-run.tstheir socket for the CLIoneinstall.tsthe disk soft caponeversion.tsversion and update checkonevault.tsthe vault, in-processonework.tsboard, playbooks, vocabulary, in-processonehooks.tsincoming webhooksonereach-cli.tsa CLI helper for the HTTPS scriptonethismachine.tsno setup code on this machine; other devices need itownfile.tsis a .one file the server’s own (one rule, Mac file sharing too)
Kriya Host link · server/hosts/
Machines that join with one command and dial out to Kriya; the workers and task jobs it runs on them.
hosts/hostlink.tsjoin codes, /host/join, each machine’s outgoing WebSocket, folder copies, Update Kriya Hosthosts/hostworkers.tshost workers: start, turns, task jobs, /hw/mcphosts/enginehost.tsCodex, Antigravity and OpenCode workers on a joined machinehosts/opencodehost.tsOpenCode there: its config on your model endpoint, its eventshosts/guard.tsthe guard of each joined machine: folders, network, allow-all, “guard pending” for machines joined before it; what Kriya Host gets with a start; what it blockedhosts/codexhost.tsCodex turns as host workers
+ 10 more
hosts/agyhost.tsAntigravity turns as host workershosts/machines.tsthe machines workers can run on, and their healthhosts/hostclicker.tsa joined machine’s clicker buttons, cleanedhosts/heal.tsthe autoheal report a machine sendshosts/tar.tsfolder copies as tar, no links, no escapinghosts/registry.tsthis agent’s record for the subsystemhosts/users.tsthe owner; the audit loghosts/usage.tsthe plan usage the master last reportedhosts/config.tsthe subsystem’s settings and state folderhosts/bus.tsits events
The web UI
The browser side is plain JavaScript modules: the browser loads them directly from /ui/… (the web/ folder), so what you read is what runs. There are three pages, and a kit of shared pieces under them.
The panel · index.html → app.js
Chat, canvas, workers, memory, the terminal view. app.js is a thin entry; each feature is a module in web/app/ (chat, composer, canvas, workers, voice…). They share one store (state.js) and a paint scheduler (render.js): events mark what changed, and it is drawn once per frame.
Setup and Settings · one.html → one.js
Kriya One’s first-run steps and its Settings: a left nav of sections, cards in a grid, search. Each card is a module in web/one/cards/; the shell (routing, nav, search, inline feedback) is in web/one/.
The kit · web/kit/
Small functions that return real DOM elements: button, chip, toggle, tabs, card, formRow, status, dialog, toast… styled only with brand tokens, so light and dark just work. See them live at /kit.
Canvas pages · bridge.js
Pages on the canvas run in an iframe on their own origin. bridge.js is the small API they get (UPA.setState, UPA.send, UPA.decide) to talk to the panel safely.
The full module list with sizes is in web modules.
How it works: the main flows
Each diagram reads top to bottom. Columns are parts of the system; numbered arrows are what happens, in order.
1 · A chat turn
2 · Master → workers
progress, ask_master, finish.3 · Canvas and approvals
4 · Voice in and out
web/browservoice.js, web/voiceworker.js).5 · Services (Settings → Models & services)
6 · The Kriya Host link
host/ops.go), confined to the folders you allowed.7 · Settings
onesettingsreg.ts, where each setting declares whether it needs your approval.Tools
A tool is a folder: manifest.json names it, mcp.mjs is the processing the agent calls, and app/ is what the canvas shows. The agent can write new tools into its data home, so its toolbox grows; each of those is kept in git and rolled back if a change breaks it (toolguard.ts).
| Tool | What it does |
|---|---|
tools/web-browser | A persistent Chromium driven in plain words; vault fills, hand-offs to you, network capture |
tools/android-device | An Android phone or emulator with a live view, macros and quick actions |
tools/desktop | Your Linux desktop, through Kriya Host |
tools/gmail | Mail over IMAP/SMTP; sending needs your approval |
tools/file-search | Finds your files by meaning (embeddings) |
tools/file-downloader | A list of files to download from the canvas |
tools/music-player | An audio player the assistant can control |
tools/vscode | VS Code in the browser on the canvas; the assistant opens folders, files and diffs in it, and drives it (debugger, any command) |
Kriya Host (Go)
One small program, kriya-host, that you install on another computer to let Kriya work there: run workers on its GPU, control its desktop, bridge a phone plugged into it, or listen to a presenter clicker. It is written in Go with no dependencies, so it is a single file to download.
| Part | Files (host/) | What it does |
|---|---|---|
| The link | main.go, ws.go, caps.go, selfstats.go | Joins with a one-time code, then keeps one outgoing WebSocket open and answers calls. |
| Jobs | ops.go, jobs.go, jobd.go, tarsync.go, proc_*.go, vt.go | A fixed list of operations: start a worker in tmux, copy a folder in or out, run a task script. |
| Engines | engines.go, claudetoken.go | Detects which AI CLIs the machine has and whether they are signed in. |
| Desktop control | desk*.go | Pointer, keys, windows, a browser over CDP: for the desktop tool. |
| Phone bridge | phonebridge.go, pb_*.go, u2/ | Drives an Android phone over adb + scrcpy for the android-device tool. |
| Clicker | clicker*.go | Reads a presenter clicker’s buttons (Linux evdev, macOS IOKit, Windows Raw Input). |
| Service | service.go, lpheal*.go, tsserve.go | Installs itself as a user service (systemd, a LaunchAgent, a logon task); restarts a server it watches when it hangs; serves HTTPS through Tailscale. |
The tests
Tests use the real server and a real browser wherever they can, and fakes only for what costs money or needs a login: a fake Claude that behaves like the terminal app, fake speech servers, a fake Docker.
| Kind | Where | Files | What they check |
|---|---|---|---|
| Unit | test/*.test.ts, test/injection/ | 175 | server modules, alone or against a real server on a free port |
| Browser | test/*-browser.test.ts | 8 | the panel and Settings in headless Chromium: these are the UI’s contract |
| Tools | tools/*/test/ | 35 + 8 browser | each tool’s MCP server and app |
| Kriya Host | host/*_test.go | 272 tests | go test ./... (also in the image build) |
| Image, end-to-end | test/image/, test/e2e/ | 3 + 4 | the real Docker image; real containers (run by hand before a release) |
Commands: npm test (everything but Docker), npm run test:changed (only what your branch touches), npm run coverage (one merged report for server and browser code), npm run lint. Details: CONTRIBUTING.md.
The web UI’s modules
Every module of web/ in this tree, by group: the panel and Settings are feature modules built on the kit, with a lint rule that forbids import cycles. Bars show each file’s length; amber marks files over 800 lines.
Now
- 133
- JS modules
- 25,978
- lines of JS
- 1,092
- lines in the biggest (browservoicelib.js)
- 2
- modules over 800 lines
- 195
- lines per module on average
- 0
- import cycles
kit/ 8 files · 1,921 lines · The building blocks: button, chip, toggle, tabs, cards, form rows, dialog, toast…
app/ 31 files · 5,739 lines · The panel (chat + canvas), one module per feature
one/ 35 files · 7,226 lines · Kriya One: first-run setup and Settings, one module per card
voice 24 files · 5,910 lines · Speech: recording, playing, models in the browser, hands-free
devices 16 files · 3,087 lines · Clicker, gamepad, phone keys, desktop
canvas + review 7 files · 1,399 lines · The canvas frame, the page bridge, Point & say, approvals
help/ 7 files · 763 lines · The in-app guide
shell 35 files · 4,398 lines · Sign-in, PWA, icons, usage, small shared pieces
No import cycles (checked by npm run lint).
Glossary
| Master | The main assistant session you chat with. |
| Worker | A helper session the master starts for one job, with a brief and checks to pass. A host worker runs on a joined machine. |
| Engine / harness | The AI command-line tool a session runs: Claude Code, Codex, Antigravity (agy), or Claude Code on a local model. |
| Verb | One action the server offers to agents (canvas_show, spawn_worker…), defined in verbs.ts. |
| MCP | Model Context Protocol: the standard way an AI tool calls outside functions. The server and every tool speak it. |
| Canvas | The right-hand pane. A canvas item is a page or a tool’s app; each update is a new version. |
| Approval | The assistant asks; nothing goes out (a post, an email, a setting that matters) until you say yes. |
| SSE | Server-sent events: the one-way live stream (/api/events) that keeps the panel up to date. |
| tmux | A terminal multiplexer: lets the server keep terminal programs running and read their screens. You can attach to any agent yourself. |
| Data home | The one folder with all state ($UPA_HOME). “UPA” is the project’s older name, still in many identifiers. |
| Kit | The UI building blocks in web/kit/. |