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
blame on this site's /mcp
CLI
abso blame client/test/box.test.ts --json
JSON
/christopher/abso-core/blame/client/test/box.test.ts?format=json
554 linesFirst import 34% · approvals-page 17% · codex-mac-1 16% · speed 12% · trials 8% · box-grants 7% · Last change approvals-page in version 259,

554 lines from 12 changes in 12 versions.

init0Start the project1// Signing in once per box (abso issue 108): login waits for approval and keeps
2// the credential outside every project folder; it never shows up in output and
3// only goes to the server that issued it.
4
5import assert from "node:assert/strict";
6import { mkdtempSync, readdirSync, readFileSync } from "node:fs";
7import { tmpdir } from "node:os";
8import { join } from "node:path";
9import { test } from "node:test";
codex-mac-1102Let login request projects, roles, agent limits and durationCompare10import { parseArgs } from "../src/args.ts";
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare11import {
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare12 boxCreateProject,
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare13 boxPublic,
14 boxText,
15 forgetBox,
16 login,
codex-mac-1102Let login request projects, roles, agent limits and durationCompare17 loginRequest,
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare18 logout,
trials63abso join <project> works with no --agent and no --dir (abso issue 351), so the project page can show npx abso-cli join <project>. - Agent: the box's name (the hostname abso login sends), lower-cased; if taken, <name>-2, -3, up to 20 tries. Names this box already holds in the project (GET /box) are skipped without minting, since minting one again replaces that agent's key and would cut off its folder. A 409 for a taken name moves on; the agent-limit 409 says the limit and where to revoke. No box sign-in: abso login first, or --agent. - Folder: --dir, else here when empty, else ./<project>, which must be new or empty; it prints cd <folder> when it isn't here. - --agent, --dir and --server still win. Project names are checked before use as a folder. Tests: box.test.ts (mintFreeName: held name skipped, 409 moves on, agent limit), client.test.ts (empty folder, ./<project>, refusing a non-empty one); the git line-endings test now joins with --dir . since its folder has files.Compare19 mintFreeName,
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare20 mintKey,
21 readBox,
22 signedInServers,
23 writeBox,
24} from "../src/box.ts";
25import { serverFrom } from "../src/join-commands.ts";
codex-mac-1102Let login request projects, roles, agent limits and durationCompare26import { main } from "../src/main.ts";
init0Start the project27
28const SERVER = "https://staging.abso.example";
29const CREDENTIAL = "abso_bx_the-secret-credential";
30const grant = {
31 projects: [
32 { project: "abso", role: "writer" },
33 { project: "game", role: "reader" },
34 ],
35};
36const EXPIRES = "2026-10-15T00:00:00.000Z";
37const record = { server: SERVER, id: "b_0123abcd", credential: CREDENTIAL, grant, expiresAt: Date.parse(EXPIRES) };
39const home = () => mkdtempSync(join(tmpdir(), "abso-box-"));
41type Seen = { url: string; auth: string | null; body: unknown }[];
42function server(answers: [number, unknown][], seen: Seen): typeof fetch {
43 return (async (url, init) => {
44 seen.push({
45 url: String(url),
46 auth: new Headers(init?.headers).get("authorization"),
47 body: JSON.parse(String(init?.body ?? "null")),
48 });
49 const [status, body] = answers.shift() ?? [500, { error: "no more answers" }];
50 return new Response(JSON.stringify(body), { status });
51 }) as typeof fetch;
54const started = {
55 device_code: "device-code-long-enough",
56 user_code: "WXYZ-BCDF",
57 verification_uri_complete: "https://abso.dev/login/box?code=WXYZ-BCDF",
58 expires_in: 60,
59 interval: 2,
60};
62function clock() {
63 let t = 0;
64 return {
65 sleep: async (ms: number) => {
66 t += ms;
67 },
68 now: () => t,
69 slept: () => t,
70 };
codex-mac-1102Let login request projects, roles, agent limits and durationCompare72
open171abso login drops --max-agents (abso ask 1947; Christopher, 2026-10-14: no arbitrary free limits). A box lets in any number of agents (the server stopped enforcing max_agents in abso 642): abso box no longer prints 'Up to N agents', the 'agent limit' 409 message is gone, and a stored grant without max_agents reads fine. Instant cutover, no alias. Bundle rebuilt.Compare73test("login grant options validate project lists, roles and duration", () => {
codex-mac-1102Let login request projects, roles, agent limits and durationCompare74 const request = (...words: string[]) =>
75 loginRequest(
76 parseArgs("login", words, {
77 projects: "string",
78 role: "string",
79 days: "string",
80 }),
81 );
82 assert.equal(request(), undefined);
open171abso login drops --max-agents (abso ask 1947; Christopher, 2026-10-14: no arbitrary free limits). A box lets in any number of agents (the server stopped enforcing max_agents in abso 642): abso box no longer prints 'Up to N agents', the 'agent limit' 409 message is gone, and a stored grant without max_agents reads fine. Instant cutover, no alias. Bundle rebuilt.Compare83 assert.deepEqual(request("--projects", "alpha, beta,alpha", "--days", "30"), {
codex-mac-1102Let login request projects, roles, agent limits and durationCompare84 projects: [
85 { project: "alpha", role: "writer" },
86 { project: "beta", role: "writer" },
87 ],
88 days: 30,
89 });
90 assert.deepEqual(request("--projects", "alpha", "--role", "reader"), {
91 projects: [{ project: "alpha", role: "reader" }],
92 });
93 assert.deepEqual(request("--projects", "alpha", "--role", "owner"), {
94 projects: [{ project: "alpha", role: "owner" }],
95 });
open171abso login drops --max-agents (abso ask 1947; Christopher, 2026-10-14: no arbitrary free limits). A box lets in any number of agents (the server stopped enforcing max_agents in abso 642): abso box no longer prints 'Up to N agents', the 'agent limit' 409 message is gone, and a stored grant without max_agents reads fine. Instant cutover, no alias. Bundle rebuilt.Compare96 assert.deepEqual(request("--days", "90"), { days: 90 });
codex-mac-1102Let login request projects, roles, agent limits and durationCompare97 for (const words of [
98 ["--role", "writer"],
99 ["--projects", ""],
100 ["--projects", "alpha,"],
101 ["--projects", "../alpha"],
102 ["--projects", "alpha", "--role", "admin"],
103 ["--projects", Array.from({ length: 101 }, (_, i) => `p${i}`).join(",")],
104 ])
105 assert.throws(() => request(...words));
open171abso login drops --max-agents (abso ask 1947; Christopher, 2026-10-14: no arbitrary free limits). A box lets in any number of agents (the server stopped enforcing max_agents in abso 642): abso box no longer prints 'Up to N agents', the 'agent limit' 409 message is gone, and a stored grant without max_agents reads fine. Instant cutover, no alias. Bundle rebuilt.Compare106 for (const value of ["0", "-1", "1.5", "1e1", "Infinity", "100", "abc", ""])
107 assert.throws(() => request("--days", value));
codex-mac-1102Let login request projects, roles, agent limits and durationCompare108});
110test("login sends requested grants only at device start and retains the user's actual approval", async () => {
111 const h = home();
112 const seen: Seen = [];
113 const c = clock();
open171abso login drops --max-agents (abso ask 1947; Christopher, 2026-10-14: no arbitrary free limits). A box lets in any number of agents (the server stopped enforcing max_agents in abso 642): abso box no longer prints 'Up to N agents', the 'agent limit' 409 message is gone, and a stored grant without max_agents reads fine. Instant cutover, no alias. Bundle rebuilt.Compare114 const requested = { projects: [{ project: "abso", role: "owner" as const }], days: 90 };
115 const approved = { projects: [{ project: "abso", role: "reader" }] };
codex-mac-1102Let login request projects, roles, agent limits and durationCompare116 const got = await login(
117 SERVER,
118 {
119 request: requested,
120 fetch: server(
121 [
122 [200, started],
123 [400, { error: "authorization_pending" }],
124 [200, { box_id: "b_test", box_token: CREDENTIAL, expires_at: EXPIRES, grant: approved }],
125 ],
126 seen,
127 ),
128 sleep: c.sleep,
129 now: c.now,
130 say: () => {},
131 },
132 h,
133 );
134 assert.ok(seen[0]);
135 assert.deepEqual((seen[0].body as Record<string, unknown>).requested_grant, requested);
136 assert.deepEqual(
137 seen.slice(1).map((call) => call.body),
138 [{ device_code: started.device_code }, { device_code: started.device_code }],
139 );
140 assert.deepEqual(got.grant, approved);
141 assert.deepEqual(readBox(SERVER, h)?.grant, approved);
142});
144test("invalid login grant flags fail before a network request through the CLI", async () => {
145 const original = globalThis.fetch;
146 let calls = 0;
147 globalThis.fetch = (async () => {
148 calls++;
149 throw new Error("unexpected request");
150 }) as typeof fetch;
151 try {
152 const result = await main(["login", "--projects", "alpha", "--days", "0", "--no-browser"], {
153 cwd: home(),
154 env: {},
155 write: () => {},
156 });
157 assert.equal(result.exit, 1);
158 assert.match(result.stderr, /--days is from 1 to 90/);
159 assert.equal(calls, 0);
160 } finally {
161 globalThis.fetch = original;
162 }
163});
init0Start the project164
165test("login shows the code, waits while it's pending, and keeps the credential in the user folder", async () => {
166 const h = home();
167 const seen: Seen = [];
168 const said: string[] = [];
169 const c = clock();
170 const got = await login(
171 `${SERVER}/some/path`,
172 {
173 fetch: server(
174 [
175 [200, started],
176 [400, { error: "authorization_pending" }],
177 [400, { error: "slow_down" }],
178 [200, { box_id: "b_0123abcd", box_token: CREDENTIAL, expires_at: EXPIRES, grant }],
179 ],
180 seen,
181 ),
182 sleep: c.sleep,
183 now: c.now,
184 say: (line) => said.push(line),
185 },
186 h,
187 );
188 assert.equal(got.server, SERVER);
189 assert.deepEqual(
190 seen.map((s) => s.url),
191 [`${SERVER}/login/device`, `${SERVER}/login/token`, `${SERVER}/login/token`, `${SERVER}/login/token`],
192 );
193 assert.deepEqual(seen[1]?.body, { device_code: "device-code-long-enough" });
194 assert.equal(c.slept(), 2000 + 2000 + 7000, "slow_down adds 5 s to the wait");
195 assert.ok(
196 seen.every((s) => s.auth === null),
197 "nothing is sent with login's calls",
198 );
199 assert.deepEqual(said, [
200 "To sign this box in, open https://abso.dev/login/box?code=WXYZ-BCDF and approve the code WXYZ-BCDF.",
pinch58abso login says it is waiting for approval, and that Ctrl-C stops it, then says it is still waiting about once a minute. It stops by itself when the code runs out, and never waits past 30 minutes whatever the server's expires_in says. A login that said nothing for 15 minutes looked like a hang.Compare201 "Waiting for approval. Ctrl-C stops waiting, and abso stops by itself when the code runs out.",
init0Start the project202 ]);
203 assert.equal(readBox(SERVER, h)?.credential, CREDENTIAL);
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare204 const files = readdirSync(join(h, ".abso", "boxes"));
init0Start the project205 assert.equal(files.length, 1);
review17New folders keep their state in .abso/, and the machine's sign-in, servers and admin token are read from ~/.abso/ first, then ~/.avcs/. A folder made before, with only .avcs/, is untouched: it keeps working, is never half-moved, and no older client or mod loses it. stateDir(root) and homeFile/homeWritePath are in the new client/src/state-dir.ts and replace the old AVCS_DIR constant everywhere. abso login writes only to ~/.abso/ and leaves ~/.avcs/ alone; logout removes both copies. The edit mod and the view mod read either folder. .abso is skipped like .avcs (including its odd spellings), the git exclude names whichever folder is in use, and the messages name .abso. Not changed: avcs.json (the server reads that name, so abso.json needs the server to learn it first), .avcsignore, env var names and wire headers. Tests: 709 run, 708 pass (one is skipped), including new ones for the folder choice, the home-file order and box sign-in; biome ci has no errors.Compare206 assert.ok(readFileSync(join(h, ".abso", "boxes", files[0]!), "utf8").includes(CREDENTIAL));
init0Start the project207 assert.equal(boxText(got, SERVER, 0).includes(CREDENTIAL), false);
open171abso login drops --max-agents (abso ask 1947; Christopher, 2026-10-14: no arbitrary free limits). A box lets in any number of agents (the server stopped enforcing max_agents in abso 642): abso box no longer prints 'Up to N agents', the 'agent limit' 409 message is gone, and a stored grant without max_agents reads fine. Instant cutover, no alias. Bundle rebuilt.Compare208 assert.match(boxText(got, SERVER, 0), /abso \(writer\), game \(reader\)\.\n/);
209 assert.doesNotMatch(boxText(got, SERVER, 0), /agents/);
init0Start the project210 assert.equal(JSON.stringify(boxPublic(got)).includes(CREDENTIAL), false);
211});
speed60abso login opens the approve page in the browser Like gh auth login and wrangler login: abso login opens the approve page in the default browser with the code already in it, so nobody copies a link by hand. It still prints the link and the code, which stand when the open fails or is skipped. - Windows opens with rundll32 url.dll,FileProtocolHandler, macOS with open, Linux with xdg-open. There's no shell, so a link with & in it arrives whole (cmd's start would cut it). - No browser with --no-browser or ABSO_NO_BROWSER, over SSH (SSH_CONNECTION or SSH_TTY), under CI, or on Linux and other Unixes with neither DISPLAY nor WAYLAND_DISPLAY. - Only http and https links are opened, so a link from a server is never handed to the desktop as a file or a program. - The opener starts detached and isn't waited on; a failure is silent. Tests: open-browser.test.ts (each skip, each platform's command, web links only, a failing opener is silent), and two login tests with an injected opener.Compare213test("login opens the approve page with the code in it, and prints the link and code all the same", async () => {
214 const said: string[] = [];
215 const opened: string[] = [];
216 const c = clock();
217 await login(
218 SERVER,
219 {
220 fetch: server(
221 [
222 [200, started],
223 [200, { box_id: "b_0123abcd", box_token: CREDENTIAL, expires_at: EXPIRES, grant }],
224 ],
225 [],
226 ),
227 sleep: c.sleep,
228 now: c.now,
229 say: (line) => said.push(line),
230 open: (url) => (opened.push(url), true),
231 },
232 home(),
233 );
234 assert.deepEqual(opened, ["https://abso.dev/login/box?code=WXYZ-BCDF"]);
235 assert.deepEqual(said.slice(0, 2), [
236 "Opening the approve page in your browser.",
237 "To sign this box in, open https://abso.dev/login/box?code=WXYZ-BCDF and approve the code WXYZ-BCDF.",
238 ]);
239});
241test("an open that doesn't start says nothing about a browser, and the printed link stands", async () => {
242 const said: string[] = [];
243 const c = clock();
244 await login(
245 SERVER,
246 {
247 fetch: server(
248 [
249 [200, started],
250 [200, { box_id: "b_0123abcd", box_token: CREDENTIAL, expires_at: EXPIRES, grant }],
251 ],
252 [],
253 ),
254 sleep: c.sleep,
255 now: c.now,
256 say: (line) => said.push(line),
257 open: () => false,
258 },
259 home(),
260 );
261 assert.equal(
262 said[0],
263 "To sign this box in, open https://abso.dev/login/box?code=WXYZ-BCDF and approve the code WXYZ-BCDF.",
264 );
265 assert.equal(
266 said.some((l) => l.includes("browser")),
267 false,
268 );
269});
init0Start the project271test("a code that's turned down or runs out says so and keeps nothing", async () => {
272 const h = home();
273 const c = clock();
274 const io = { sleep: c.sleep, now: c.now, say: () => {} };
275 await assert.rejects(
276 login(
277 SERVER,
278 {
279 ...io,
280 fetch: server(
281 [
282 [200, started],
283 [400, { error: "access_denied" }],
284 ],
285 [],
286 ),
287 },
288 h,
289 ),
290 /was turned down/,
291 );
292 await assert.rejects(
293 login(
294 SERVER,
295 {
296 ...io,
297 fetch: server(
298 [
299 [200, started],
300 [400, { error: "expired_token" }],
301 ],
302 [],
303 ),
304 },
305 h,
306 ),
307 /ran out\. Run abso login again/,
308 );
309 await assert.rejects(
310 login(
311 SERVER,
312 {
313 ...io,
314 fetch: server(
315 [
316 [200, { ...started, expires_in: 3 }],
317 [400, { error: "authorization_pending" }],
318 [400, { error: "authorization_pending" }],
319 ],
320 [],
321 ),
322 },
323 h,
324 ),
325 /in time\. Run abso login again/,
326 );
327 assert.equal(readBox(SERVER, h), undefined);
pinch58abso login says it is waiting for approval, and that Ctrl-C stops it, then says it is still waiting about once a minute. It stops by itself when the code runs out, and never waits past 30 minutes whatever the server's expires_in says. A login that said nothing for 15 minutes looked like a hang.Compare328});
330test("login says it's still waiting about once a minute, and stops in the end whatever the server says", async () => {
331 const c = clock();
332 const said: string[] = [];
333 const pending = Array.from({ length: 2000 }, (): [number, unknown] => [400, { error: "authorization_pending" }]);
334 await assert.rejects(
335 login(
336 SERVER,
337 {
338 fetch: server([[200, { ...started, expires_in: 10 ** 9, interval: 5 }], ...pending], []),
339 sleep: c.sleep,
340 now: c.now,
341 say: (line) => said.push(line),
342 },
343 home(),
344 ),
345 /nobody approved the code WXYZ-BCDF in time\. Run abso login again\./,
346 );
347 assert.equal(c.slept(), 30 * 60 * 1000, "a server that says never still gets an end");
348 const still = said.filter((line) => line === "Still waiting for the code WXYZ-BCDF to be approved.");
349 assert.equal(still.length, 30);
350 assert.equal(said.length, 2 + 30);
init0Start the project351});
353test("a key is minted with the box credential, sent only to the box's own server", async () => {
354 const seen: Seen = [];
355 const minted = await mintKey(
356 record,
357 "abso",
358 "tester-1",
359 server([[200, { key: "abso_sk_x", id: "k_0123abcd" }]], seen),
360 );
361 assert.deepEqual(minted, { key: "abso_sk_x", id: "k_0123abcd" });
362 assert.equal(seen[0]?.url.startsWith(`${SERVER}/`), true);
363 assert.equal(seen[0]?.auth, `Box ${CREDENTIAL}`);
364 await assert.rejects(
365 mintKey(record, "secret-project", "a", server([[403, { error: `outside the grant ${CREDENTIAL}` }]], [])),
366 (e: Error) => /refused \(403\)/.test(e.message) && !e.message.includes(CREDENTIAL),
367 );
368});
370test("a box's sign-in is kept per server, and logout forgets it even when the server is down", async () => {
371 const h = home();
372 writeBox(record, h);
373 assert.equal(readBox("https://abso.example", h), undefined, "another server's box isn't this one");
374 assert.match(boxText(undefined, SERVER), /isn't signed in/);
375 const down = (async () => {
376 throw new Error("offline");
377 }) as typeof fetch;
378 assert.equal(await logout(readBox(SERVER, h)!, down, h), false);
379 assert.equal(readBox(SERVER, h), undefined);
380 assert.equal(forgetBox(SERVER, h), false);
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare381});
speed156With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.Compare383test("join and init pick the server in the one order: --server, the folder's, ABSO_SERVER, then prod", () => {
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare384 const h = home();
speed156With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.Compare385 const outside = home();
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare386 const args = (server?: string) => ({ positionals: [], flags: new Map(server ? [["server", server]] : []) });
speed156With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.Compare387 const none = { env: {}, cwd: outside };
388 assert.equal(serverFrom(args(), none), "https://api.abso.dev", "nothing named: prod");
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare389 writeBox({ ...record, expiresAt: Date.now() + 1e6 }, h);
390 assert.deepEqual(signedInServers(h), [SERVER]);
speed156With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.Compare391 assert.equal(serverFrom(args(), none), "https://api.abso.dev", "a sign-in elsewhere doesn't pick the server");
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare392 assert.deepEqual(signedInServers(h, Date.now() + 2e6), [], "an expired sign-in doesn't count");
speed156With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.Compare393 assert.equal(serverFrom(args(), { ...none, env: { ABSO_SERVER: "https://env.example" } }), "https://env.example");
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare394 assert.equal(
speed156With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.Compare395 serverFrom(args("https://flag.example"), { ...none, env: { ABSO_SERVER: "https://env.example" } }),
trials61abso join and abso init no longer need --server (abso issue 349): --server, then ABSO_SERVER, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which. Usage, about text and the README's join line updated; box.test.ts covers the order.Compare396 "https://flag.example",
397 );
speed156With nothing naming a server, the client now uses prod (https://api.abso.dev). Every command picks its server in one order: --server, else the joined folder's own server, else ABSO_SERVER, else prod. Which servers this box is signed in to no longer picks one, so a box signed in to staging and prod both, or to staging alone, goes to prod instead of refusing or quietly using staging; staging is a deliberate --server, a joined staging folder, or ABSO_SERVER. An explicit choice is used as given. A malformed ABSO_SERVER is refused like a malformed --server. When this box isn't signed in to the chosen server but is to others, whoami and join name them and how to pick one. Help states the order for every command that picks its server. For abso-core issue 9.Compare398 assert.equal(serverFrom(args(SERVER), none), SERVER, "--server is used as given");
trials63abso join <project> works with no --agent and no --dir (abso issue 351), so the project page can show npx abso-cli join <project>. - Agent: the box's name (the hostname abso login sends), lower-cased; if taken, <name>-2, -3, up to 20 tries. Names this box already holds in the project (GET /box) are skipped without minting, since minting one again replaces that agent's key and would cut off its folder. A 409 for a taken name moves on; the agent-limit 409 says the limit and where to revoke. No box sign-in: abso login first, or --agent. - Folder: --dir, else here when empty, else ./<project>, which must be new or empty; it prints cd <folder> when it isn't here. - --agent, --dir and --server still win. Project names are checked before use as a folder. Tests: box.test.ts (mintFreeName: held name skipped, 409 moves on, agent limit), client.test.ts (empty folder, ./<project>, refusing a non-empty one); the git line-endings test now joins with --dir . since its folder has files.Compare399});
trials64join: a folder prepared with abso key install --server is joined where it is again (Pinch's catch on 63). - --agent keeps 'here' as the default, as before 63, so scripts that join into a prepared folder still do. The ./<project> rule is only for a join with no --agent. - A folder holding only abso's own state folder (.abso, or the older .avcs) counts as empty. - New tests: joinFolder's rule (empty, only .abso, files here, --agent, --dir, a taken ./<project>), and a runJoin test that installs a key with --server and joins with --agent and no --dir: it joins here and sends that key (the shared token is wrong, so only the key gets through). The git line-endings test is back to joining without --dir. - Issue numbers taken out of the new code comments and test names.Compare401test("join with no --agent takes the box's name, skips names this box holds, and moves past a taken one", async () => {
trials63abso join <project> works with no --agent and no --dir (abso issue 351), so the project page can show npx abso-cli join <project>. - Agent: the box's name (the hostname abso login sends), lower-cased; if taken, <name>-2, -3, up to 20 tries. Names this box already holds in the project (GET /box) are skipped without minting, since minting one again replaces that agent's key and would cut off its folder. A 409 for a taken name moves on; the agent-limit 409 says the limit and where to revoke. No box sign-in: abso login first, or --agent. - Folder: --dir, else here when empty, else ./<project>, which must be new or empty; it prints cd <folder> when it isn't here. - --agent, --dir and --server still win. Project names are checked before use as a folder. Tests: box.test.ts (mintFreeName: held name skipped, 409 moves on, agent limit), client.test.ts (empty folder, ./<project>, refusing a non-empty one); the git line-endings test now joins with --dir . since its folder has files.Compare402 const seen: Seen = [];
403 const fetcher = server(
404 [
405 [200, { box_id: record.id, agents: [{ project: "abso", agent: "snow", key_id: "k_0" }] }],
406 [409, { error: "that agent name is already in use in this project; pick a new one" }],
407 [200, { key: "abso_sk_new", id: "k_3" }],
408 ],
409 seen,
410 );
411 const got = await mintFreeName(record, "abso", "snow", fetcher);
412 assert.deepEqual(got, { key: "abso_sk_new", id: "k_3", agent: "snow-3" });
413 assert.deepEqual(
414 seen.map((s) => [new URL(s.url).pathname, (s.body as { agent?: string } | null)?.agent ?? null]),
415 [
416 ["/box", null],
417 ["/box/agent-key", "snow-2"],
418 ["/box/agent-key", "snow-3"],
419 ],
420 "snow is this box's already: never minted again, which would replace its key",
box-grants185abso init, init --org and org new from a signed-in box (abso 663). On a server this box is signed in to and with no token for it, abso init makes the project as the person who approved the box, through the server's POST /box/projects (the website's own create): its folder (up to 24 MB) is the first version, --public or --private picks visibility (private by default), --org makes it an organization's project, and one Idempotency-Key per folder (kept in .abso/init-key until it finishes) makes a retry the same project. The folder then joins at once with its own key from the box (--agent, else the box's name). abso org new <name> [--name] makes an organization through POST /box/orgs. abso box and login say 'all of yours, now and later' for a member-all grant. Without a box, init and init --org say to abso login. Tests: orgs, box, help; full suite passes.Compare421 );
422});
424test("abso init from a box (abso 663): one key for every try, waiting out a pending create; abso box says all projects", async () => {
425 const record = { server: SERVER, id: "b_1", credential: CREDENTIAL, grant, expiresAt: Date.now() + 86_400_000 };
426 const seen: { path: string; key: string | null; auth: string | null; body: string }[] = [];
427 let calls = 0;
428 const fetcher = (async (url: string | URL | Request, init?: RequestInit) => {
429 const headers = new Headers(init?.headers);
430 seen.push({
431 path: new URL(String(url)).pathname,
432 key: headers.get("idempotency-key"),
433 auth: headers.get("authorization"),
434 body: String(init?.body),
435 });
436 calls++;
437 const body =
438 calls < 3
439 ? { operation: { id: "op", state: "pending" } }
440 : { project: "made", id: "proj_1", visibility: "private" };
441 return new Response(JSON.stringify(body), { status: calls < 3 ? 202 : 200 });
442 }) as typeof fetch;
443 const made = await boxCreateProject(
444 record,
445 { name: "made", files: [{ path: "a.txt", text: "hi\n" }] },
446 "33333333-3333-4333-8333-333333333333",
447 fetcher,
448 async () => {},
449 );
450 assert.equal(made.id, "proj_1");
451 assert.equal(seen.length, 3);
452 assert.ok(seen.every((s) => s.path === "/box/projects" && s.key === "33333333-3333-4333-8333-333333333333"));
453 assert.ok(seen.every((s) => s.auth === `Box ${CREDENTIAL}`));
454 assert.deepEqual(JSON.parse(seen[0]!.body), { name: "made", files: [{ path: "a.txt", text: "hi\n" }] });
455 const all = { ...record, grant: { projects: [], scopes: [{ kind: "member-all", role: "writer" }] } };
456 assert.match(
457 boxText(all, SERVER),
458 /Projects: all of yours, now and later \(writer at most\)\. abso init makes a new one/,
trials63abso join <project> works with no --agent and no --dir (abso issue 351), so the project page can show npx abso-cli join <project>. - Agent: the box's name (the hostname abso login sends), lower-cased; if taken, <name>-2, -3, up to 20 tries. Names this box already holds in the project (GET /box) are skipped without minting, since minting one again replaces that agent's key and would cut off its folder. A 409 for a taken name moves on; the agent-limit 409 says the limit and where to revoke. No box sign-in: abso login first, or --agent. - Folder: --dir, else here when empty, else ./<project>, which must be new or empty; it prints cd <folder> when it isn't here. - --agent, --dir and --server still win. Project names are checked before use as a folder. Tests: box.test.ts (mintFreeName: held name skipped, 409 moves on, agent limit), client.test.ts (empty folder, ./<project>, refusing a non-empty one); the git line-endings test now joins with --dir . since its folder has files.Compare459 );
init0Start the project460});
approvals-page259Box 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).Compare461
462// abso 684: in an agent's folder, login asks a person in the project instead of relaying the code.
463function 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 };
478test("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});
506test("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});
530test("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});