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 258 to 259

Compare

+67 −4 in 5 places
Lines 8–14 at 259 (were 8–14 at 258)
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";
Lines 45–61 at 259 (were 45–51 at 258)
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";
Lines 199–213 at 259 (were 189–201 at 258)
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 =
Lines 215–221 at 259 (were 203–208 at 258)
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,
Lines 1076–1128 at 259 (were 1063–1065 at 258)
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+ };
MCP
compare on this site's /mcp
CLI
abso diff 258 259 client/src/main.ts --json
JSON
/christopher/abso-core/compare/258..259?file=client%2Fsrc%2Fmain.ts&format=json