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

Versions 101 to 102

Compare

+43 −2 in 4 places
Lines 12–18 at 102 (were 12–18 at 101)
1212import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1313import { homedir, hostname } from "node:os";
1414import { dirname, join } from "node:path";
15−import { UsageError } from "./args.ts";
15+import { type Parsed, str, UsageError } from "./args.ts";
1616import { homeFile, homeWritePath, OLD_STATE_DIR, STATE_DIR } from "./state-dir.ts";
1717
1818/** What the person who approved the code allowed: each project with the highest role its agents get there, and how many agents. */
Lines 21–60 at 102 (were 21–26 at 101)
2121 readonly max_agents: number;
2222}
2323
24+/** Requested access is a suggestion for the person approving, never an authorization. */
25+export interface LoginRequest {
26+ readonly projects?: readonly { readonly project: string; readonly role: "reader" | "writer" | "owner" }[];
27+ readonly max_agents?: number;
28+ readonly days?: number;
29+}
31+export function loginRequest(args: Parsed): LoginRequest | undefined {
32+ const projects = str(args, "projects");
33+ const role = str(args, "role");
34+ const maxAgents = str(args, "max-agents");
35+ const days = str(args, "days");
36+ if (projects === undefined && role === undefined && maxAgents === undefined && days === undefined) return undefined;
37+ if (role !== undefined && projects === undefined) throw new UsageError("--role needs --projects");
38+ const requestedRole = role ?? "writer";
39+ if (requestedRole !== "reader" && requestedRole !== "writer" && requestedRole !== "owner")
40+ throw new UsageError("--role is reader, writer or owner");
41+ const names = projects?.split(",").map((name) => name.trim());
42+ if (names && (names.length > 100 || names.some((name) => !/^[A-Za-z0-9._-]+$/.test(name))))
43+ throw new UsageError(
44+ "--projects is a comma-separated list of up to 100 project names (letters, digits, dot, dash and underscore)",
45+ );
46+ const integer = (value: string, name: string, max: number): number => {
47+ if (!/^[0-9]+$/.test(value) || !Number.isInteger(Number(value)) || Number(value) < 1 || Number(value) > max)
48+ throw new UsageError(`--${name} is from 1 to ${max}`);
49+ return Number(value);
50+ };
51+ return {
52+ ...(names ? { projects: [...new Set(names)].map((project) => ({ project, role: requestedRole })) } : {}),
53+ ...(maxAgents === undefined ? {} : { max_agents: integer(maxAgents, "max-agents", 50) }),
54+ ...(days === undefined ? {} : { days: integer(days, "days", 90) }),
55+ };
56+}
2458export interface BoxRecord {
2559 readonly server: string;
2660 readonly id: string;
Lines 239–245 at 102 (were 205–210 at 101)
205239const STILL_WAITING_MS = 60_000;
206240
207241export interface LoginIo {
242+ readonly request?: LoginRequest;
208243 readonly fetch?: typeof fetch;
209244 readonly sleep?: (ms: number) => Promise<void>;
210245 readonly now?: () => number;
Lines 257–269 at 102 (were 222–228 at 101)
222257 const fetcher = io.fetch ?? fetch;
223258 const sleep = io.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
224259 const now = io.now ?? Date.now;
225− const start = await call(server, "/login/device", { name: boxName(), client: "abso" }, undefined, fetcher);
260+ const start = await call(
261+ server,
262+ "/login/device",
263+ { name: boxName(), client: "abso", ...(io.request ? { requested_grant: io.request } : {}) },
264+ undefined,
265+ fetcher,
266+ );
226267 const { device_code: device, user_code: code, verification_uri_complete: link } = start.body;
227268 let interval = Number(start.body.interval) || 5;
228269 // The server says when its code runs out; a server that says never still gets an end.
MCP
compare on this site's /mcp
CLI
abso diff 101 102 client/src/box.ts --json
JSON
/christopher/abso-core/compare/101..102?file=client%2Fsrc%2Fbox.ts&format=json