Skip to content
58 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Every agent can have its own computer. A session that needs one wakes it: a home of its own on g1t cloud, one per agent and never shared, where it runs commands, reads and writes files and keeps what it made, with each session working in its own folder under a shared home; after ten idle minutes it sleeps, its home kept as a snapshot and restored when it wakes, and Reset wipes the home while memory and artifacts stay. Its shell and files are abilities with the usual choices, Alone, Alone when asked, Ask first or Never, offered only inside sessions and never to a chat reply; every command shows on the session with its output, and the agent's new Computer tab shows the state, the disk used of the five gigabytes included, the recent commands, and Wake, Put to sleep and Reset. Machine time counts only while it is awake, on the sandbox lines of the ledger that name the agent and who asked, held to the same spend caps as the session; the disk itself costs nothing in this version. The runner gained a long-lived supervisor that answers the computer's requests inside the container, and the runner service a computer per agent that keeps its snapshot in the agent homes bucket when one is attached, and says so when none is. The REST API and the agent tool can read a computer, wake it, put it to sleep and reset it. The agents, abilities, sessions, runners, billing and deploy guides say how it works and what an operator sets up; pinning a computer to your own runner, its browser and take-over come next.1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { gather, homeKey, ndjson, outcomeLine, transcriptOf } from "./computer-shape.ts";
5
6test("a computer's home is kept under one key per agent", () => {
7 assert.equal(homeKey("agt_1"), "homes/agt_1.tar.zst");
8});
9
10test("lines gather in order and stop at the cap", () => {
11 const lines = [
12 { stream: "stdout", line: "one" },
13 { stream: "stderr", line: "two" },
14 { stream: "stdout", line: "three" },
15 ];
16 assert.deepEqual(gather(lines), { output: "one\ntwo\nthree", truncated: false });
17 assert.deepEqual(gather(lines, 7), { output: "one\ntwo", truncated: true });
18 assert.deepEqual(gather([]), { output: "", truncated: false });
19});
20
21test("how a command ended reads as one line", () => {
22 assert.equal(outcomeLine({ exit_code: 0, duration_ms: 1234, timed_out: false, truncated: false }), "exit 0 · 1.2 s");
23 assert.equal(outcomeLine({ exit_code: 1, duration_ms: 42_000, timed_out: false, truncated: true }), "exit 1 · 42 s · output cut");
24 assert.equal(outcomeLine({ exit_code: 124, duration_ms: 300_000, timed_out: true, truncated: false }), "exit 124 · 5 min · timed out");
25});
26
27test("a transcript carries the closing note, or says the computer stopped answering", () => {
28 const lines = [{ stream: "stdout", line: "hello" }];
29 const plain = transcriptOf(lines, { exit_code: 0, duration_ms: 10 }, null);
30 assert.equal(plain.output, "hello");
31 assert.equal(plain.exit_code, 0);
32 assert.equal(plain.duration_ms, 10);
33 const cut = transcriptOf(lines, { exit_code: 0, duration_ms: 10, truncated: true, note: "Output past 1.0 MB was dropped: 5 more bytes." }, null);
34 assert.equal(cut.output, "hello\n[Output past 1.0 MB was dropped: 5 more bytes.]");
35 assert.equal(cut.truncated, true);
36 const gone = transcriptOf(lines, null, "connection reset");
37 assert.equal(gone.exit_code, -1);
38 assert.equal(gone.duration_ms, null);
39 assert.equal(gone.output, "hello\n[The computer stopped answering: connection reset.]");
40 assert.equal(transcriptOf([], null, null).output, "[The computer stopped answering.]");
41});
42
43test("NDJSON is read line by line across chunks, skipping what is not an object", async () => {
44 const parts = ['{"stream":"stdout","li', 'ne":"a"}\n{"stream":"stderr","line":"b"}\nnot json\n[1]\n{"exit_code":0,"duration_ms":5}'];
45 const body = new ReadableStream<Uint8Array>({
46 start(controller) {
47 for (const part of parts) controller.enqueue(new TextEncoder().encode(part));
48 controller.close();
49 },
50 });
51 const seen: Record<string, unknown>[] = [];
52 for await (const line of ndjson(body)) seen.push(line);
53 assert.deepEqual(seen, [
54 { stream: "stdout", line: "a" },
55 { stream: "stderr", line: "b" },
56 { exit_code: 0, duration_ms: 5 },
57 ]);
58});