Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 302 --json
JSON
/christopher/abso-core/versions/302?format=json

abso login --web: a staging website session in an agent's own browser with no secret in its hands. It sends this box's sign-in (or, with --pat-file, a test account's PAT read from that file) to the staging website's /login/handoff and prints only the one-use link it answers, which signs whichever browser opens it in as that person, within a minute. Prod has no website for it: agents never sign in there. Tests: client/test/web-session.test.ts.

of shared·box-grants··Not checked

Version 301 · Files at version 302

3 files, 203 lines added, 2 removed.

--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -79,6 +79,7 @@
7979import { runAmend, runDrop, runFollow, runLabel, runLabels, runPluck } from "./versions.ts";
8080import { runVisibility } from "./visibility-commands.ts";
8181import { checkVisitor } from "./visitor.ts";
82+import { handoffText, patFromFile, siteFor, webHandoff } from "./web-session.ts";
8283
8384interface CommandDef {
8485 readonly flags: FlagSpec;
@@ -212,13 +213,25 @@
212213 projects: "string",
213214 role: "string",
214215 days: "string",
216+ web: "boolean",
217+ site: "string",
218+ "pat-file": "string",
215219 },
216220 usage:
217− "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]",
221+ "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>] | abso login --web [--pat-file <file>] [--site <url>]",
218222 about:
219− "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only.",
223+ "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only. --web, on staging only, signs a browser in to the website instead: it prints a link that works once, within a minute, and signs whichever browser opens it in as the person who approved this box (or, with --pat-file, the test account whose PAT that file holds). The box's sign-in, the PAT and the session never appear; agents never sign in to the website on prod.",
220224 run: async (args, env) => {
221225 const server = boxServer(args, env);
226+ if (bool(args, "web")) {
227+ const site = siteFor(server, str(args, "site"));
228+ const patFile = str(args, "pat-file");
229+ const record = patFile === undefined ? readBox(server) : undefined;
230+ if (patFile === undefined && (record === undefined || record.expiresAt <= Date.now()))
231+ throw new UsageError(`this box isn't signed in to ${server}: abso login first, or --pat-file <file>`);
232+ const handoff = await webHandoff(site, patFile === undefined ? record!.credential : patFromFile(patFile));
233+ return { text: handoffText(handoff, site), json: { ...handoff } };
234+ }
222235 const open =
223236 bool(args, "no-browser") || browserSkip(env.env, process.platform) !== null
224237 ? undefined
--- /dev/null
+++ b/client/src/web-session.ts
@@ -0,0 +1,117 @@
1+// abso login --web: a staging website session for the person a box is signed in as, opened in an agent's own browser, with
2+// no secret in the agent's hands. The website's /login/handoff takes this box's sign-in (or a test account's PAT, from a file)
3+// and answers a one-use link that works for a minute; opening it signs that browser in. Only the link is printed: never the
4+// box's sign-in, the PAT or the session cookie, which the website sets in the browser itself.
5+
6+import { readFileSync } from "node:fs";
7+import { UsageError } from "./args.ts";
8+
9+/** The website beside each staging server. Prod has none here: agents never sign in to the website on prod. */
10+const STAGING_SITES: Readonly<Record<string, string>> = {
11+ "https://abso-staging.chrisazy.workers.dev": "https://abso-website-staging.chrisazy.workers.dev",
12+ "https://avcs-staging.chrisazy.workers.dev": "https://abso-website-staging.chrisazy.workers.dev",
13+};
15+/** What the website answers: the link, when it stops working, and who and until when it signs in. */
16+export interface Handoff {
17+ readonly url: string;
18+ readonly expiresAt: string;
19+ readonly account: string;
20+ readonly name: string;
21+ readonly sessionEnds: string;
22+}
24+/** The website a server's handoff goes to: --site as given (https only), else the staging site beside it. */
25+export function siteFor(server: string, site?: string): string {
26+ if (site !== undefined) {
27+ let url: URL;
28+ try {
29+ url = new URL(site);
30+ } catch {
31+ throw new UsageError(
32+ `--site takes the website's address, like https://abso-website-staging.chrisazy.workers.dev`,
33+ );
34+ }
35+ if (url.protocol !== "https:" && url.hostname !== "localhost" && url.hostname !== "127.0.0.1")
36+ throw new UsageError("--site has to be https, or this machine");
37+ return url.origin;
38+ }
39+ const origin = new URL(server).origin;
40+ const known = STAGING_SITES[origin];
41+ if (known === undefined)
42+ throw new UsageError(
43+ `abso login --web is for staging: ${origin} has no staging website beside it that abso knows, and agents never sign in to the website on prod. --site names one.`,
44+ );
45+ return known;
46+}
48+/** A PAT from the file --pat-file names: read here, never printed. */
49+export function patFromFile(path: string): string {
50+ let text: string;
51+ try {
52+ text = readFileSync(path, "utf8").trim();
53+ } catch {
54+ throw new UsageError(`--pat-file names ${path}, which abso can't read`);
55+ }
56+ if (!/^abso_pat_[A-Za-z0-9_-]{16,200}$/.test(text))
57+ throw new UsageError(`--pat-file names ${path}, which doesn't hold a PAT`);
58+ return text;
59+}
61+/** Words from the website, with any secret this call sent taken out. */
62+function scrubbed(text: string, secret: string): string {
63+ return text.split(secret).join("[the credential]").slice(0, 300);
64+}
66+/** Asks the website for a handoff link with `credential` (a box sign-in or a PAT) in Authorization. */
67+export async function webHandoff(site: string, credential: string, fetcher: typeof fetch = fetch): Promise<Handoff> {
68+ let res: Response;
69+ try {
70+ res = await fetcher(`${site}/login/handoff`, {
71+ method: "POST",
72+ headers: { authorization: `Bearer ${credential}`, accept: "application/json" },
73+ redirect: "error",
74+ signal: AbortSignal.timeout(30_000),
75+ });
76+ } catch (err) {
77+ throw new UsageError(`couldn't reach ${site}: ${scrubbed((err as Error).message, credential)}`);
78+ }
79+ const text = await res.text().catch(() => "");
80+ let body: Partial<Handoff> & { error?: unknown } = {};
81+ try {
82+ body = JSON.parse(text) as typeof body;
83+ } catch {
84+ // Not JSON: the status says enough.
85+ }
86+ if (!res.ok) {
87+ const why = typeof body.error === "string" ? body.error : `it answered ${res.status}`;
88+ throw new UsageError(
89+ res.status === 404
90+ ? `${site} doesn't hand out sign-in links (its key sign-in is off, or it isn't staging)`
91+ : `${site} refused: ${scrubbed(why, credential)}`,
92+ );
93+ }
94+ if (
95+ typeof body.url !== "string" ||
96+ !body.url.startsWith(`${site}/login/handoff#`) ||
97+ typeof body.expiresAt !== "string" ||
98+ typeof body.account !== "string"
99+ )
100+ throw new UsageError(`${site} answered something that isn't a sign-in link`);
101+ return {
102+ url: body.url,
103+ expiresAt: body.expiresAt,
104+ account: body.account,
105+ name: typeof body.name === "string" ? body.name : body.account,
106+ sessionEnds: typeof body.sessionEnds === "string" ? body.sessionEnds : body.expiresAt,
107+ };
108+}
110+/** What abso login --web says: the one link, how long it works, and who it signs in as. */
111+export function handoffText(h: Handoff, site: string, now = Date.now()): string {
112+ const seconds = Math.max(0, Math.round((Date.parse(h.expiresAt) - now) / 1000));
113+ return [
114+ `Open this link in your browser within ${seconds} seconds. It signs that browser in to ${site} as ${h.name}, until ${h.sessionEnds}, and works once:`,
115+ h.url,
116+ ].join("\n");
117+}
--- /dev/null
+++ b/client/test/web-session.test.ts
@@ -0,0 +1,71 @@
1+// abso login --web: a staging website session handed to a browser as a one-use link, with no secret printed.
2+
3+import assert from "node:assert/strict";
4+import { mkdtempSync, writeFileSync } from "node:fs";
5+import { tmpdir } from "node:os";
6+import { join } from "node:path";
7+import { test } from "node:test";
8+import { handoffText, patFromFile, siteFor, webHandoff } from "../src/web-session.ts";
9+
10+const SITE = "https://abso-website-staging.chrisazy.workers.dev";
11+const BOX = `abso_bx_${"C".repeat(43)}`;
12+const NOW = Date.UTC(2026, 9, 16, 9, 0, 0);
14+test("the website is the staging one beside the server, or --site; prod has none, since agents never sign in there", () => {
15+ assert.equal(siteFor("https://abso-staging.chrisazy.workers.dev"), SITE);
16+ assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/"), SITE);
17+ assert.throws(() => siteFor("https://api.abso.dev"), /for staging.*never sign in to the website on prod/);
18+ assert.equal(siteFor("https://api.abso.dev", "http://localhost:8871/x"), "http://localhost:8871");
19+ assert.throws(() => siteFor("https://api.abso.dev", "http://elsewhere.example"), /https/);
20+});
22+test("the credential goes in Authorization only, and the answer is the one link and who it signs in as", async () => {
23+ const seen: { url: string; authorization: string | null; body: unknown }[] = [];
24+ const fetcher = (async (url: string, init: RequestInit) => {
25+ seen.push({ url, authorization: new Headers(init.headers).get("authorization"), body: init.body ?? null });
26+ return Response.json({
27+ url: `${SITE}/login/handoff#${"t".repeat(50)}`,
28+ expiresAt: new Date(NOW + 60_000).toISOString(),
29+ account: "acct_person1",
30+ name: "christopher",
31+ sessionEnds: "2026-10-16T21:00:00.000Z",
32+ });
33+ }) as typeof fetch;
34+ const h = await webHandoff(SITE, BOX, fetcher);
35+ assert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]);
36+ const text = handoffText(h, SITE, NOW);
37+ assert.match(text, /within 60 seconds/);
38+ assert.match(text, /as christopher, until 2026-10-16T21:00:00.000Z, and works once/);
39+ assert.match(text, /\/login\/handoff#t{50}$/);
40+ assert.doesNotMatch(text + JSON.stringify(h), /abso_bx_/);
41+});
43+test("a refusal says why without the credential; an answer that isn't the site's own link is refused", async () => {
44+ const echo = (async () =>
45+ Response.json({ error: `that key was refused: ${BOX}` }, { status: 401 })) as unknown as typeof fetch;
46+ await assert.rejects(webHandoff(SITE, BOX, echo), (err: Error) => {
47+ assert.match(err.message, /refused: that key was refused: \[the credential\]/);
48+ assert.doesNotMatch(err.message, /abso_bx_/);
49+ return true;
50+ });
51+ const off = (async () => Response.json({ error: "not found" }, { status: 404 })) as unknown as typeof fetch;
52+ await assert.rejects(webHandoff(SITE, BOX, off), /doesn't hand out sign-in links/);
53+ const elsewhere = (async () =>
54+ Response.json({
55+ url: "https://elsewhere.example/login/handoff#x",
56+ expiresAt: new Date(NOW).toISOString(),
57+ account: "acct_x",
58+ })) as unknown as typeof fetch;
59+ await assert.rejects(webHandoff(SITE, BOX, elsewhere), /isn't a sign-in link/);
60+});
62+test("--pat-file reads a PAT from its file, and refuses a file that doesn't hold one", () => {
63+ const dir = mkdtempSync(join(tmpdir(), "abso-web-"));
64+ const good = join(dir, "pat");
65+ writeFileSync(good, `abso_pat_${"A".repeat(40)}\n`);
66+ assert.equal(patFromFile(good), `abso_pat_${"A".repeat(40)}`);
67+ const bad = join(dir, "not");
68+ writeFileSync(bad, "hello");
69+ assert.throws(() => patFromFile(bad), /doesn't hold a PAT/);
70+ assert.throws(() => patFromFile(join(dir, "missing")), /can't read/);
71+});