Skip to content

abso-core

Public
Check passed

Versions 60 to 61

Compare

+27 −2 in 2 places
Lines 9–19 at 61 (were 9–19 at 60)
99// which answer as the person who approved the box.
1010
1111import { createHash } from "node:crypto";
12−import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
12+import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1313import { homedir, hostname } from "node:os";
1414import { dirname, join } from "node:path";
1515import { UsageError } from "./args.ts";
16−import { homeFile, homeWritePath, OLD_STATE_DIR } from "./state-dir.ts";
16+import { 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. */
1919export interface Grant {
Lines 59–89 at 61 (were 59–64 at 60)
5959 }
6060}
6161
62+/** The servers this box is signed in to and whose sign-in hasn't expired, from ~/.abso/boxes (and an older ~/.avcs/boxes). */
63+export function signedInServers(home = homedir(), now = Date.now()): string[] {
64+ const servers = new Set<string>();
65+ for (const dir of [STATE_DIR, OLD_STATE_DIR]) {
66+ let names: string[];
67+ try {
68+ names = readdirSync(join(home, dir, "boxes"));
69+ } catch {
70+ continue;
71+ }
72+ for (const name of names) {
73+ try {
74+ const server = (JSON.parse(readFileSync(join(home, dir, "boxes", name), "utf8")) as { server?: unknown })
75+ .server;
76+ if (typeof server !== "string") continue;
77+ const record = readBox(server, home);
78+ if (record && record.expiresAt > now) servers.add(originOf(record.server));
79+ } catch {
80+ // Not a sign-in this client wrote: left alone.
81+ }
82+ }
83+ }
84+ return [...servers].sort();
85+}
6287export function writeBox(record: BoxRecord, home = homedir()): void {
6388 const path = homeWritePath(home, "boxes", boxFile(record.server));
6489 mkdirSync(dirname(path), { recursive: true });
MCP
compare on this site's /mcp
CLI
abso diff 60 61 client/src/box.ts --json
JSON
/christopher/abso-core/compare/60..61?file=client%2Fsrc%2Fbox.ts&format=json