{"draft":null,"from":60,"to":61,"files":[{"path":"client/src/box.ts","added":27,"removed":2,"diff":"--- a/client/src/box.ts\n+++ b/client/src/box.ts\n@@ -9,11 +9,11 @@\n // which answer as the person who approved the box.\n \n import { createHash } from \"node:crypto\";\n-import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n+import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n import { homedir, hostname } from \"node:os\";\n import { dirname, join } from \"node:path\";\n import { UsageError } from \"./args.ts\";\n-import { homeFile, homeWritePath, OLD_STATE_DIR } from \"./state-dir.ts\";\n+import { homeFile, homeWritePath, OLD_STATE_DIR, STATE_DIR } from \"./state-dir.ts\";\n \n /** What the person who approved the code allowed: each project with the highest role its agents get there, and how many agents. */\n export interface Grant {\n@@ -59,6 +59,31 @@\n \t}\n }\n \n+/** The servers this box is signed in to and whose sign-in hasn't expired, from ~/.abso/boxes (and an older ~/.avcs/boxes). */\n+export function signedInServers(home = homedir(), now = Date.now()): string[] {\n+\tconst servers = new Set<string>();\n+\tfor (const dir of [STATE_DIR, OLD_STATE_DIR]) {\n+\t\tlet names: string[];\n+\t\ttry {\n+\t\t\tnames = readdirSync(join(home, dir, \"boxes\"));\n+\t\t} catch {\n+\t\t\tcontinue;\n+\t\t}\n+\t\tfor (const name of names) {\n+\t\t\ttry {\n+\t\t\t\tconst server = (JSON.parse(readFileSync(join(home, dir, \"boxes\", name), \"utf8\")) as { server?: unknown })\n+\t\t\t\t\t.server;\n+\t\t\t\tif (typeof server !== \"string\") continue;\n+\t\t\t\tconst record = readBox(server, home);\n+\t\t\t\tif (record && record.expiresAt > now) servers.add(originOf(record.server));\n+\t\t\t} catch {\n+\t\t\t\t// Not a sign-in this client wrote: left alone.\n+\t\t\t}\n+\t\t}\n+\t}\n+\treturn [...servers].sort();\n+}\n+\n export function writeBox(record: BoxRecord, home = homedir()): void {\n \tconst path = homeWritePath(home, \"boxes\", boxFile(record.server));\n \tmkdirSync(dirname(path), { recursive: true });"}],"unmatched":[]}