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 259 --json
JSON
/christopher/abso-core/versions/259?format=json

Box sign-ins asked of a person (abso 684, client; Security's yes with changes on ask 2097). In an agent's folder on the same server, abso login also asks a person in that project to approve it, through POST /login/ask with the folder's agent key and this client's own device code, then an ordinary abso ask (to person:<id>) with the request link, linked with /login/ask/link. It says who it asked and until when, keeps the code link as a fallback, says who turned it down on a deny, and withdraws its ask when nobody answers in time. --no-ask shows the code only. Tests: client/test/box.test.ts, three new (abso 684).

of shared·approvals-page··Not checked

Version 258 · Files at version 259

3 files, 213 lines added, 12 removed.

--- a/client/src/box.ts
+++ b/client/src/box.ts
@@ -222,7 +222,7 @@
222222}
223223
224224/** This machine's name, as the server takes a box's name: 1-64 letters, digits, '.', '_' or '-'. */
225−function boxName(): string {
225+export function boxName(): string {
226226 const name = hostname()
227227 .replace(/[^A-Za-z0-9._-]/g, "-")
228228 .replace(/^[^A-Za-z0-9]+/, "")
@@ -254,8 +254,29 @@
254254 readonly say: (line: string) => void;
255255 /** Opens the approve page in a browser, answering whether it tried. None where it shouldn't (--no-browser, SSH, CI). */
256256 readonly open?: (url: string) => boolean;
257+ /**
258+ * abso 684: in a joined folder, asks a person in its project to approve this sign-in, through an abso ask, so nobody
259+ * relays the code. Answers who was asked, or null to fall back to the code alone.
260+ */
261+ readonly ask?: (codes: { readonly device: string; readonly user: string }) => Promise<LoginAsked | null>;
257262}
258263
264+/** A sign-in asked of people (abso 684). */
265+export interface LoginAsked {
266+ readonly project: string;
267+ /** "the person who approved this agent's box", or "the owners of <project>". */
268+ readonly who: string;
269+ readonly asks: readonly number[];
270+ /** Milliseconds: when the asked sign-in runs out. */
271+ readonly expiresAt: number;
272+ /** The most the box may be granted: the asking agent's own role. */
273+ readonly role: string;
274+ /** Withdraws the asks once nobody answered in time. */
275+ readonly withdraw: () => Promise<void>;
276+}
278+const CENTRAL = new Intl.DateTimeFormat("en-US", { timeZone: "America/Chicago", hour: "numeric", minute: "2-digit" });
259280/**
260281 * Asks `server` for a code, shows it with its link, and waits for a person to
261282 * approve it. Answers the box's record, already written to the config folder.
@@ -278,16 +299,29 @@
278299 if (typeof code !== "string" || typeof link !== "string" || typeof device !== "string")
279300 throw new UsageError(`${originOf(server)} didn't give a code to approve`);
280301 // The page opens with the code in it, so nobody copies a link by hand. The link and code are printed all the same.
281− if (io.open?.(link)) io.say("Opening the approve page in your browser.");
282− io.say(`To sign this box in, open ${link} and approve the code ${code}.`);
283− io.say("Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.");
284− const until = now() + expiresIn * 1000;
302+ const asked = io.ask ? await io.ask({ device, user: code }).catch(() => null) : null;
303+ if (asked) {
304+ const askWord = asked.asks.length === 1 ? `ask ${asked.asks[0]}` : `asks ${asked.asks.join(", ")}`;
305+ io.say(`Asked ${asked.who} (${askWord} in ${asked.project}) to sign this box in, as at most ${asked.role}.`);
306+ io.say(
307+ `Waiting for their answer, until ${CENTRAL.format(new Date(asked.expiresAt))} CT. To approve it yourself instead: ${link}`,
308+ );
309+ } else {
310+ if (io.open?.(link)) io.say("Opening the approve page in your browser.");
311+ io.say(`To sign this box in, open ${link} and approve the code ${code}.`);
312+ io.say("Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.");
313+ }
314+ const until = asked ? Math.min(asked.expiresAt, now() + MAX_LOGIN_WAIT_S * 1000) : now() + expiresIn * 1000;
285315 let toldAt = now();
286316 while (now() < until) {
287317 await sleep(interval * 1000);
288318 // A wait with no word looks like a hang, so say it's still waiting now and then.
289319 if (now() - toldAt >= STILL_WAITING_MS) {
290− io.say(`Still waiting for the code ${code} to be approved.`);
320+ io.say(
321+ asked
322+ ? `Still waiting (${asked.who} hasn't answered yet).`
323+ : `Still waiting for the code ${code} to be approved.`,
324+ );
291325 toldAt = now();
292326 }
293327 const a = await call(server, "/login/token", { device_code: device }, undefined, fetcher);
@@ -297,8 +331,14 @@
297331 interval += 5;
298332 continue;
299333 }
300− if (a.body.error === "access_denied") throw new UsageError(`the code ${code} was turned down.`);
301− throw new UsageError(`the code ${code} ran out. Run abso login again.`);
334+ if (a.body.error === "access_denied")
335+ throw new UsageError(asked ? `${asked.who} turned this sign-in down.` : `the code ${code} was turned down.`);
336+ if (asked) await asked.withdraw().catch(() => undefined);
337+ throw new UsageError(
338+ asked
339+ ? "nobody answered in time, so nothing was granted. Run abso login again."
340+ : `the code ${code} ran out. Run abso login again.`,
341+ );
302342 }
303343 const { box_token: credential, box_id: id, grant, expires_at } = a.body;
304344 const expiresAt = typeof expires_at === "string" ? Date.parse(expires_at) : Number.NaN;
@@ -308,6 +348,10 @@
308348 writeBox(record, home);
309349 return record;
310350 }
351+ if (asked) {
352+ await asked.withdraw().catch(() => undefined);
353+ throw new UsageError("nobody answered in time, so nothing was granted. Run abso login again.");
354+ }
311355 throw new UsageError(`nobody approved the code ${code} in time. Run abso login again.`);
312356}
313357
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -8,7 +8,7 @@
88import { bool, type FlagSpec, type Parsed, parseArgs, str, UsageError } from "./args.ts";
99import { runAutosettle } from "./autosettle-commands.ts";
1010import { bodyFilesHelp, readBodyFiles, withBodyFiles } from "./body-files.ts";
11−import { boxPublic, boxText, login, loginRequest, logout, readBox } from "./box.ts";
11+import { boxName, boxPublic, boxText, login, loginRequest, logout, originOf, readBox } from "./box.ts";
1212import { runDiff, runFiles, runLog, runRestore, runShow } from "./changes.ts";
1313import { runCheckIgnore } from "./check-ignore.ts";
1414import { runCi } from "./ci.ts";
@@ -45,7 +45,17 @@
4545import { runExport } from "./export.ts";
4646import { runGroup, runGroups } from "./group-commands.ts";
4747import { runBlame, runWhere, runWho, runWhy } from "./history.ts";
48−import { runAck, runAnswer, runAsk, runIssue, runIssues, runReply, runSearch, runWaiting } from "./issues.ts";
48+import {
49+ openIssues,
50+ runAck,
51+ runAnswer,
52+ runAsk,
53+ runIssue,
54+ runIssues,
55+ runReply,
56+ runSearch,
57+ runWaiting,
58+} from "./issues.ts";
4959import { adminToken, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from "./key-admin.ts";
5060import { browserSkip, openInBrowser } from "./open-browser.ts";
5161import { runOrg, runOrgs } from "./orgs.ts";
@@ -189,13 +199,15 @@
189199 flags: {
190200 server: "string",
191201 "no-browser": "boolean",
202+ "no-ask": "boolean",
192203 projects: "string",
193204 role: "string",
194205 days: "string",
195206 },
196− usage: "abso login [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]",
207+ usage:
208+ "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]",
197209 about:
198− "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.",
210+ "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.",
199211 run: async (args, env) => {
200212 const server = boxServer(args, env);
201213 const open =
@@ -203,6 +215,7 @@
203215 ? undefined
204216 : (url: string) => openInBrowser(url);
205217 const record = await login(server, {
218+ ask: bool(args, "no-ask") ? undefined : loginAsk(server, env),
206219 request: loginRequest(args),
207220 say: (line) => process.stderr.write(terminalText(`${line}\n`, colorsPass(process.stderr, env.env))),
208221 open,
@@ -1063,3 +1076,53 @@
10631076 };
10641077 }
10651078}
1080+/**
1081+ * abso 684: in an agent's folder on this same server, the ask `abso login` makes of a person in that project, so nobody
1082+ * relays the code. The folder's agent key proves the agent; the device code proves the sign-in is this client's own.
1083+ * Null outside such a folder, or when nobody could be asked: login then shows the code alone.
1084+ */
1085+function loginAsk(server: string, env: Env): NonNullable<Parameters<typeof login>[1]["ask"]> | undefined {
1086+ const root = findRoot(env.cwd);
1087+ if (root === undefined || isVisitor(root)) return undefined;
1088+ const config = readConfig(root, env.env);
1089+ if (config.token === undefined || originOf(config.server) !== originOf(server)) return undefined;
1090+ return async ({ device, user }) => {
1091+ const asked = await fetch(`${originOf(server)}/login/ask`, {
1092+ method: "POST",
1093+ headers: { "content-type": "application/json", authorization: `Bearer ${config.token}` },
1094+ body: JSON.stringify({ project: config.project, agent: config.agent, device_code: device, user_code: user }),
1095+ });
1096+ const body = (await asked.json().catch(() => ({}))) as {
1097+ error?: string;
1098+ people?: string[];
1099+ expires_at?: string;
1100+ request_url?: string;
1101+ role?: string;
1102+ };
1103+ if (!asked.ok || !Array.isArray(body.people) || typeof body.request_url !== "string") return null;
1104+ const expiresAt = Date.parse(body.expires_at ?? "");
1105+ const { api } = openIssues(env);
1106+ const when = new Intl.DateTimeFormat("en-US", { timeZone: "America/Chicago", hour: "numeric", minute: "2-digit" });
1107+ const question = `Please sign in my box "${boxName()}" for ${config.project}, as at most ${body.role}. It expires at ${when.format(new Date(expiresAt))} CT. Approve or deny: ${body.request_url}`;
1108+ const asks: number[] = [];
1109+ for (const of of body.people) asks.push((await api.ask({ of, question })).id);
1110+ const first = asks[0];
1111+ if (first !== undefined)
1112+ await fetch(`${originOf(server)}/login/ask/link`, {
1113+ method: "POST",
1114+ headers: { "content-type": "application/json" },
1115+ body: JSON.stringify({ device_code: device, ask: first }),
1116+ });
1117+ return {
1118+ project: config.project,
1119+ who: body.people.length === 1 ? "the person who approved this agent's box" : `the owners of ${config.project}`,
1120+ asks,
1121+ expiresAt,
1122+ role: body.role ?? "writer",
1123+ withdraw: async () => {
1124+ for (const id of asks) await api.withdraw(id, { note: "The sign-in ran out; nothing was granted." });
1125+ },
1126+ };
1127+ };
--- a/client/test/box.test.ts
+++ b/client/test/box.test.ts
@@ -458,3 +458,97 @@
458458 /Projects: all of yours, now and later \(writer at most\)\. abso init makes a new one/,
459459 );
460460});
462+// abso 684: in an agent's folder, login asks a person in the project instead of relaying the code.
463+function askedOf(withdrawn: number[]): NonNullable<Parameters<typeof login>[1]["ask"]> {
464+ return async ({ device, user }) => {
465+ assert.equal(device, started.device_code, "the ask is made with this client's own device code");
466+ assert.equal(user, started.user_code);
467+ return {
468+ project: "abso",
469+ who: "the person who approved this agent's box",
470+ asks: [41],
471+ expiresAt: Date.parse("2026-10-15T19:30:00Z"),
472+ role: "writer",
473+ withdraw: async () => void withdrawn.push(41),
474+ };
475+ };
476+}
478+test("an asked login says who was asked and until when, and doesn't lead with the code (abso 684)", async () => {
479+ const said: string[] = [];
480+ const c = clock();
481+ await login(
482+ SERVER,
483+ {
484+ ask: askedOf([]),
485+ fetch: server(
486+ [
487+ [200, started],
488+ [200, { box_id: "b_test", box_token: CREDENTIAL, expires_at: EXPIRES, grant: { projects: [] } }],
489+ ],
490+ [],
491+ ),
492+ sleep: c.sleep,
493+ now: c.now,
494+ say: (line) => said.push(line),
495+ },
496+ home(),
497+ );
498+ assert.match(
499+ said[0]!,
500+ /^Asked the person who approved this agent's box \(ask 41 in abso\) to sign this box in, as at most writer\.$/,
501+ );
502+ assert.match(said[1]!, /^Waiting for their answer, until .* CT\. To approve it yourself instead: /);
503+ assert.doesNotMatch(said.join("\n"), /approve the code/);
504+});
506+test("an asked login that's turned down says who turned it down (abso 684)", async () => {
507+ const c = clock();
508+ await assert.rejects(
509+ login(
510+ SERVER,
511+ {
512+ ask: askedOf([]),
513+ fetch: server(
514+ [
515+ [200, started],
516+ [400, { error: "access_denied" }],
517+ ],
518+ [],
519+ ),
520+ sleep: c.sleep,
521+ now: c.now,
522+ say: () => {},
523+ },
524+ home(),
525+ ),
526+ /the person who approved this agent's box turned this sign-in down/,
527+ );
528+});
530+test("an asked login that nobody answers withdraws its ask and grants nothing (abso 684)", async () => {
531+ const withdrawn: number[] = [];
532+ const c = clock();
533+ await assert.rejects(
534+ login(
535+ SERVER,
536+ {
537+ ask: askedOf(withdrawn),
538+ fetch: server(
539+ [
540+ [200, started],
541+ [400, { error: "expired_token" }],
542+ ],
543+ [],
544+ ),
545+ sleep: c.sleep,
546+ now: c.now,
547+ say: () => {},
548+ },
549+ home(),
550+ ),
551+ /nobody answered in time, so nothing was granted/,
552+ );
553+ assert.deepEqual(withdrawn, [41]);
554+});