This page has the design of version 0, the facts that it rests on, and what is not done.
- One daemon process (
serve) with one event loop. Each agent is a coroutine of the loop, so many agents run at one time. A model call and a command of theruntool are pipelines or thread messages with events: each wait yields. - One HTTP port on 127.0.0.1 for the API, the web page, and the sign-in.
- The clients: the command line, the TUI, the window client, and the web page. The first three use the API with the token. The page uses it with a session cookie.
| File | What it has |
|---|---|
token |
The key of the command line, 32 random bytes as hex, mode 0600. |
port |
The port of the running daemon. |
config.json |
Optional: isolation, region, max_turns, max_tokens, max_out. |
passkeys.json |
The passkeys: the credential id, the COSE algorithm, the public key, and the counter. |
next-id |
The number of the next agent. |
agents/ID/meta.json |
The state of the agent. |
agents/ID/messages.jsonl |
The messages of the Converse API, one for each line. A restart goes on from them. |
agents/ID/transcript.jsonl |
The transcript: n, t (ms), kind, text. |
agents/ID/req-*.json |
The files of the last request to Bedrock. |
The folder has the mode 0700. Each file of an agent has the mode 0600.
Each route needs the token (Authorization: Bearer) or a session.
| Route | What it does |
|---|---|
GET /api/agents |
The list. |
POST /api/agents |
Starts an agent: model, dir, brief, level, net, run, max_turns, max_tokens, max_out. |
GET /api/agents/ID |
The state of one agent. |
GET /api/agents/ID/read?since=N&wait=S |
The entries after N. With wait, the reply waits up to S seconds (30 at most) for a new entry. |
GET /api/agents/ID/wait?timeout=S |
Waits until the state is not running, up to S seconds (60 at most). |
POST /api/agents/ID/send |
{text}. It answers a question, starts a new turn, or joins the next tool results. |
POST /api/agents/ID/stop |
Stops the agent. |
- Add the user message: the held tool results, an answer for an open
ask_coordinator, a note for each other open tool use, the texts that came while the agent ran, and the input. Two user messages in a row become one. - Check the caps: the turns and the tokens (input plus output of each reply).
- Call the model. On a failure, the agent waits; the next
sendtries again. - Run each tool use.
ask_coordinatorends the turn with the question; the nextsendis its answer. - With no tool use, the agent waits.
A restart marks each running agent waiting. The next send starts a new loop from messages.jsonl.
Measured with ztcl 1.0.0-beta.7 (Debug, x86-64 Linux) and ztk 1.0.0-beta.8 on 2026-12-03.
- A script has no environment (
envis empty), and a program ofexecgets only the variables of--exec-env.bin/jcodegivesHOME,PATH, and the AWS variables. - ztcl 1.0.0-beta.7 has no HTTP client of its own, and no SQLite package in this build. The pull request beetlebugorg/ztcl#1327 (stacked on #1319) adds
ztcl::crypto hashandhmac. With them,lib/sigv4.tclsigns the calls of Bedrock. Without them,lib/sig.tcluses the fieldscript_sha256ofztcl::meter record, and theawsprogram is the transport. - The name lookup of ztcl (
sys.resolve) reads only literal addresses,localhost, and/etc/hosts. It sends no DNS query.lib/sigv4.tclgets the address of Bedrock fromgetent ahostsv4and opens it with-servername. So the daemon runs with--net any: a rule for a host name does not match an address. ztcl::tls socketgives a channel with no non-blocking mode. The wait for the first byte of a reply yields, and the read of the rest blocks the daemon.ztcl::meter verifychecks only a meter record. ztcl has no command that checks an Ed25519 or ECDSA signature of other bytes. Pull request beetlebugorg/ztcl#1319 (issue #1318) addsztcl::crypto verify,sign, andpubkey. With a ztcl that has it, the sign-in works; with no such ztcl, each sign-in fails.file normalizedoes not follow a symbolic link in the middle of a path.lib/paths.tclwalks each path itself.- A
catchthat spans ayieldcrashes the Debug runner (an assertion inrunCaughtBody) when the coroutine resumes from the event loop (beetlebugorg/ztcl#1321). The code has no catch around a yield. The agent loop has no catch;bgerrorends an agent whose loop failed. expr rand()has a fixed seed. Secrets come from/dev/urandom.thread::create -isolation process -files host -caps {exec channels file} -write [list DIR]works on this host (Landlock, user namespaces, cgroup v2 with cpu, memory, pids). A write outside DIR fails with "Permission denied". A TCP connection fails with nosocketcapability, and UDP gets "Network is unreachable" (a new network namespace with onlylo). A program ofexeccan still look up names with the network off (beetlebugorg/ztcl#1328); beetlebugorg/ztcl#1329 closes it. A program that allocates 700 MB under--thread-mem 268435456ends with the code 137.- The level
vmruns with the signed imagevm-image-v1(x86-64, kernel 7.3.6, busybox). A call starts a guest in about 450 ms. The first share mounts only at/mnt/share: another folder gives "mount failed" (errno 2 or 16). The guest has busybox and no other program, so the shell gets a function for each applet. With no-net, DNS and TCP fail ("Network is unreachable"). A guest of-memory 128keeps a write of 300 MB to its/tmpunder 128 MB. The root is read-only. The close of the channel ofexec -isolation vmdoes not end the guest (beetlebugorg/ztcl#1330):lib/isolate.tclmakes the guest withztcl::vm createand deletes it at the end of the call or at a stop. - ztcl has a TLS client and no TLS server, so the daemon serves HTTP on 127.0.0.1 only. A passkey needs a secure context:
http://localhostis one, and another host needs HTTPS.
lib/isolate.tcl has one interface (check, open, run, close, kill) and a backend for each level. start calls open, and open fails when check gives a reason. The level applies to the run tool. The file tools run in the daemon with the path check at each level.
The memory limit of process is the limit of one thread of the daemon (--thread-mem), the same for each agent. ztcl has no option for the memory of one thread.
The RP id is localhost and the origin is http://localhost:PORT. The checks are in lib/webauthn.tcl. The attestation statement is not checked: the one-time code of the terminal is the trust of the first passkey. A session can add more passkeys with no code.
- The file tools of an agent at the level
vmact on the host folder, with the path check, and not in the guest. - The credentials come from
~/.aws/credentialsor fromaws configure export-credentials. Theawsprogram has the full power of the user, as eachexechas. - The check of a path and the open of the file are two steps. A program of the agent can change a folder into a link between them.
- No streaming of model output. The transcript gets each reply when it is complete.
- No cap of the total spend of all agents, and no per-agent memory limit.
- No TLS, so no access from another host.
tests/browser.mjstests the page in headless Chromium. It is not part oftools/test.sh: runnode tests/browser.mjs /usr/bin/chromium ZTCL.- The TUI is a line interface.
ztcl::vtkeeps the state of a terminal and does not draw on the terminal of the user. - No
ztcl.project: itsnamekey would be a second place of the working name. The tests run throughtools/test.sh.
From the live runs of the level vm (issue #2):
- The guest image has no
/bin/shand no links of the applets, and its root is read-only. A script with#!/bin/shfailed, and a child shell found notrorawk. jcode mounts a tmpfs on/binwith busybox and its links before each command. The image should have them. - The image has busybox only: no git, no compiler, and no way to add a package. Most agents cannot build or test in the guest. A larger signed image, or a second share with tools of the host read-only, would help.
- Only the first share mounts (
EBUSYfor another folder), so--writecannot reach the guest. - The close of the channel does not end the guest (ztcl#1330), and the delete of the guest gives the channel no end of file. jcode deletes the guest and wakes the waiting coroutine itself.
- No cgroups and no Landlock in the guest (ztcl#1315).
- A runner built with
zig buildhas no download forimage fetch(ZTCL VM UNAVAILABLE). This was the cause of the refused fetch in round 2. A release runner has it.
- Merge ztcl#1319 and #1327. The sign-in and SigV4 wait for them.
- Merge ztcl#1329 (issue #1328).
- A DNS client in
sys.resolveof ztcl would removegetentand--net any. - The default level is
process. Keep it, or choosenonefor speed.
The daemon listens on 127.0.0.1 only. The checks are in lib/daemon.tcl and lib/web.tcl. tests/browser.mjs and tests/web.test test them.
A page of another origin, in the browser of the owner:
- It can send a request, but it cannot read the reply: the daemon sends no CORS header.
- A POST with a cookie needs the header
X-CSRFwith the token of the session. A page of another origin cannot set it with no CORS preflight, and the reply to the preflight allows nothing. The cookie isSameSite=Stricttoo, and each POST of a session must have theOriginof the daemon. - DNS rebinding: a request with a
Hostother thanlocalhost:PORTor127.0.0.1:PORTgets 421. - A frame of the page:
frame-ancestors 'none'refuses it. - The sign-in: the client data must have the origin
http://localhost:PORTand the challenge of the session. A challenge is good for one use.
A local process of another user:
- It can connect to the port. It cannot read the token: the state folder is 0700 and the files are 0600.
- With no token, no cookie, and no passkey, each route of the API gives 401. The first registration needs the one-time code of the terminal, with 5 tries.
- It can see the traffic on the loopback only with root. The connection has no TLS.
A process of the same user is out of scope: it can read the token and the state folder.
The output of an agent in the page:
- The page puts each text of the API into the DOM with
textContentorvalue, and never withinnerHTML.tests/browser.mjssends agent text with<script>and anonerrorattribute, and checks that no element is made and no script runs. - The CSP is
default-src 'none'; script-src 'self', with no inline script, so an injected element could still run no script. - The page shows no link and no image of an agent, so agent text cannot make the browser fetch a URL.
- The CLI and the TUI change each control character of agent text to a space, so agent text cannot send escape sequences to a terminal.
What the model found: no gap in the page. Two gaps of the host: ztcl#1328 (above) and the use of --net any for SigV4.
The review before the first public version fixed these, each with a test:
- A byte that is not UTF-8 in the body or the query ended the read of the request with an error, and the connection stayed open until its timer. Now it becomes U+FFFD (web-7).
- The count of open connections had no cap. Now the server closes each one past 64 (web-8).
/auth/register/beginand/auth/logoutof a session checked the Origin but not the CSRF token. Now they check both (web-9).read_fileandedit_fileread a file of each size into the memory of the daemon, so a sparse file of the agent could end the daemon. Now they refuse a file larger than 16 MiB (tools-9).- A stop killed the process group of each process with the marker of the command in its arguments. A process in the group of the daemon with that marker made the stop end the daemon. Now a stop never kills the group of the daemon (isolate-17).
Not checked: the time of a search with a hostile regular expression (it runs in the event loop of the daemon), the CBOR and COSE parser against fuzzed input, the window client, and a race of a link change between the check of a path and its open (lib/paths.tcl states it).
A backend host above vm: the daemon starts a host in the cloud (AWS EC2 first), runs a job there, streams the result lines, and stops the host. Nothing of it is built.
Commands:
jcode host start --profile P: starts a host from the profile P (an image, a type of instance, a region, the caps) and gives its id.jcode host run ID --commit HASH --job NAME: runs a job on a commit and streams the result lines to the transcript.jcode host stop ID.start --isolation host --profile P: an agent whoseruntool runs on the host.
The interface of lib/isolate.tcl stays the same: check gives a reason when the profile or the AWS access is absent, open starts or takes a host, run sends one command and yields until its end, and close stops the host.
Requirements:
- The host has no secret: a read-only clone of the repository, no token that can write, and no AWS key that can start an instance. The daemon holds the launch rights; the host gets none.
- The host stops itself after a time limit that it gets at the start, also when the daemon is gone (a shutdown timer in the image, and the instance setting "terminate on shutdown").
- A cap on the count of hosts at one time and on the run time of each host, in
config.json. A start past a cap fails with the reason. - The result names the exact commit hash and the tree hash that ran.
- A prepared image with the tools and a warm build cache (the Zig cache of the main branch), so a job does not build from nothing.
- The first user is the gate of ztcl in lanes: a quick phase, then the slow checks in lanes. A host for each lane runs a part of the checks of one commit, and the daemon joins the result lines in the form of
gate.tcl.