Lines 80–122 at 318 (were 80–85 at 293)
83+/** A stored pipeline run as runRuns lists it: what the CI lines need of it. */ 86+ readonly version: number; 87+ readonly state: string; 88+ readonly file: string; 91+/** The stored pipeline runs, newest first, from the server's `pipelines` read; empty for anything else. */ 92+export function storedRuns(raw: unknown): StoredRun[] { 93+ const runs = (raw as { runs?: unknown } | null)?.runs; 94+ if (!Array.isArray(runs)) return []; 96+ (r): r is StoredRun => 97+ typeof r === "object" && 99+ Number.isInteger((r as StoredRun).id) && 100+ Number.isInteger((r as StoredRun).version) && 101+ typeof (r as StoredRun).state === "string" && 102+ typeof (r as StoredRun).file === "string", 106+/** One stored run in a line, with where its jobs are. */ 107+export function runLine(run: StoredRun): string { 108+ const how = run.state === "planned" ? "was planned, not run," : run.state === "running" ? "is running" : run.state; 109+ return `Pipeline run ${run.id} (${run.file}) ${how} on version ${run.version}. abso pipeline runs ${run.id} shows its jobs.`; 113+ * Whether the built-in check (abso.json's setup, build and check) had nothing of its own to run. With stored runs, that is 114+ * about the built-in check, not the project's CI, so it isn't said as the project's (abso 719). 116+export function builtInHasNothing(ci: CiStatus): boolean { 117+ return ci.red === null && ci.skipped?.reason.startsWith("nothing to run") === true; 83120/** A shared version's mark in abso log; "not checked" says nothing, since most versions in a busy hour are covered by a newer one's job. */ 84121export function ciMarkText(mark: CiMark | undefined): string { Lines 180–199 at 318 (were 143–153 at 293)
144181 if (typed !== undefined) { 145182 if (!/^\d+$/.test(typed)) throw new UsageError(`a version is a number (got ${JSON.stringify(typed)})`); 146− const job = await api.ci(Number(typed));
147− return { text: jobText(job).join("\n"), json: { ...job } };
183+ const [job, raw] = await Promise.all([api.ci(Number(typed)), api.pipelineRuns().catch(() => null)]); 184+ const run = storedRuns(raw).find((r) => r.version === job.version); 185+ // A version the built-in check never ran, with a pipeline run of its own: the run is its CI (abso 719). 186+ const text = run !== undefined && job.result === "none" ? [runLine(run)] : jobText(job); 187+ return { text: text.join("\n"), json: { ...job } }; 149− const [ci, status] = await Promise.all([api.ci(), api.status()]);
150− const lines = ciText(ci, status.version);
189+ const [ci, status, raw] = await Promise.all([api.ci(), api.status(), api.pipelineRuns().catch(() => null)]); 190+ const newest = storedRuns(raw)[0]; 192+ newest === undefined 193+ ? ciText(ci, status.version) 194+ : builtInHasNothing(ci) 196+ : [...ciText(ci, status.version), runLine(newest)]; 153199 `shared is at version ${status.version}.`, Lines 28–34 at 318 (were 28–33 at 293)
2828import { ignoredHere } from "./fetch.ts"; 2929import { loadIgnore, relativeTo } from "./folder.ts"; 3030import type { AskReply } from "./issues-wire.ts"; 31+import { isLocal, LOCAL_BASE } from "./local-store.ts"; 3132import { queuedLines, standing } from "./queue.ts"; 3233import { seenText, shortWhen } from "./times.ts"; Lines 37–47 at 318 (were 36–41 at 293)
3637/** The folder, with its Api pointed at the Issues Worker: the token goes only where tokenGoesTo allows, as for the avcs server. */ 3738export function openIssues(env: Env): { root: string; config: Config; api: Api } { 3839 const { root, config, api } = open(env); 40+ // A local project's issues are in its store, where the open server keeps them: at /issues. 41+ if (isLocal(config.server)) { 42+ api.issuesServer = `${LOCAL_BASE}/issues`; 43+ return { root, config, api }; 3945 // An explicit --server goes to that server's own Issues Worker: ABSO_ISSUES_SERVER doesn't redirect it. 4147 (env.server === undefined ? fromEnv(env.env, "ISSUES_SERVER") : undefined) || Lines 154–164 at 318 (were 154–159 at 293)
154154 if (findRoot(root) === root) throw new UsageError(`${root} already has .abso/config.json`); 155155 const project = str(args, "project"); 156156 if (!project) throw new UsageError("give the project a name with --project <name>"); 157+ // Checked before any call: a name like ".." would otherwise go out as part of the request's path. 158+ if (!NAME.test(project)) 159+ throw new UsageError( 160+ `project names are letters, digits, dot, dash and underscore (got ${JSON.stringify(project)})`, 157162 if (bool(args, "public") && bool(args, "private")) throw new UsageError("--public or --private, not both"); 158163 const local = localFrom(args, env, "init"); 159164 // A box signed in here, and no other credential asked for: the project is made as the person who approved the box, Lines 1–5 at 318 (were 1–3 at 293)
11// The types of local-server.mjs: as much of the open server as the client calls. 22export declare function handle(request: Request, env: unknown, ctx: unknown, issues: unknown): Promise<Response>; 33export declare const ProjectObject: new (ctx: unknown, env: unknown) => object; 4+export declare const IssueProject: new (ctx: unknown, env: unknown) => object; 5+export declare function issuesFetch(request: Request, env: unknown, ctx: unknown, route: unknown): Promise<Response>; Lines 1–7 at 318 (were 1–6 at 293)
1−// The open server's router and project object, for local projects (local-store.ts). Plain JS, with its types in
2−// local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types
1+// The open server's router, project object and issues, for local projects (local-store.ts). Plain JS, with its types 2+// in local-server.d.mts, so the client's typecheck stops here: server/src is typechecked with the Workers' types 33// (server/tsconfig.json). The build and Node follow these imports as usual. 5+export { IssueProject, issuesFetch } from "../../server/src/issues-entry.ts"; 56export { ProjectObject } from "../../server/src/project-object.ts"; 67export { handle } from "../../server/src/router.ts"; Lines 159–166 at 318 (were 159–165 at 293)
160160/** Workers' crypto.DigestStream, which the blob store hashes uploads with. */ 161161async function installDigestStream(): Promise<void> { 162− const c = globalThis.crypto as unknown as { DigestStream?: unknown };
162+ // Through a cast: abso's worker compiles this file too (tool.lock.json), and its types have no globalThis.crypto. 163+ const c = (globalThis as unknown as { crypto: { DigestStream?: unknown } }).crypto; 163164 if (c.DigestStream) return; 164165 const { createHash } = await import("node:crypto"); 165166 class DigestStream extends WritableStream<Uint8Array> { Lines 190–197 at 318 (were 189–194 at 293)
189190 DatabaseSync: new (path: string) => Db; 190191 handle: (request: Request, env: unknown, ctx: unknown, issues: unknown) => Promise<Response>; 191192 ProjectObject: new (ctx: unknown, env: unknown) => object; 193+ IssueProject: new (ctx: unknown, env: unknown) => object; 194+ issuesFetch: (request: Request, env: unknown, ctx: unknown, route: unknown) => Promise<Response>; 193196let server: Promise<Server> | undefined; Lines 243–255 at 318 (were 240–246 at 293)
240243 `local projects couldn't load the server's code: ${e instanceof Error ? e.message : String(e)}`, 243− return { DatabaseSync: sqlite.DatabaseSync, handle: loaded.handle, ProjectObject: loaded.ProjectObject };
247+ DatabaseSync: sqlite.DatabaseSync, 248+ handle: loaded.handle, 249+ ProjectObject: loaded.ProjectObject, 250+ IssueProject: loaded.IssueProject, 251+ issuesFetch: loaded.issuesFetch, Lines 265–274 at 318 (were 256–261 at 293)
256265 object: object | undefined; 257266 /** PRAGMA data_version when this process last used the project: it changes when another process writes. */ 258267 seen: number | undefined; 268+ /** The project's issues, asks and news: issues.sqlite beside it, opened when a call first reaches them. */ 269+ issues?: { db: Db; storage: ReturnType<typeof storageOver> }; 270+ /** The issues object for the call under way: made again for each call, as another process may have written. */ 271+ issueObject?: object; 261274/** Every store file this process has open: closed when its command ends (closeLocalStores). */ Lines 284–293 at 318 (were 271–278 at 293)
274−const PROJECT_PATH = /^\/p\/([^/]+)\//;
275−const NAME = /^[A-Za-z0-9._-]{1,100}$/;
287+/** A project's calls, and its issues, asks and news, which the open server keeps at /issues/p/<project>/. */ 288+const PROJECT_PATH = /^(?:\/issues)?\/p\/([^/]+)\//; 289+/** A project's name is also its folder in the store, so it never starts with a dot ("." and ".." would leave it). */ 290+const NAME = /^[A-Za-z0-9_-][A-Za-z0-9._-]{0,99}$/; 276291const json = (status: number, body: unknown) => Response.json(body, { status }); Lines 327–365 at 318 (were 312–321 at 293)
315− // Issues, asks and news aren't in local projects yet: a start note's issue hooks find nothing to call.
316− ISSUES_DO: { idFromName: (n: string) => n, get: () => ({}) },
331+ idFromName: (n: string) => n, 332+ get: (n: string) => { 333+ const p = open.get(n); 334+ if (!p || n !== name) throw new LocalError(`no local project ${n}`); 335+ if (p.issues === undefined || !opened.has(p.issues.db)) { 336+ const db = new opening!.DatabaseSync(join(dir, name, "issues.sqlite")); 338+ db.exec("PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 120000; PRAGMA synchronous = NORMAL"); 339+ p.issues = { db, storage: storageOver(db) }; 341+ // Its writes need no lock of their own: every call holds the project file's (see below). 342+ p.issueObject ??= new opening!.IssueProject( 343+ { id: { toString: () => n, name: n }, storage: p.issues.storage }, 346+ return p.issueObject; 318− return async (input, init = {}) => {
350+ // One call at a time, as a Durable Object takes them: a call holds its project's write transaction across awaits, 351+ // and the connection can't start a second (two calls at once come from Promise.all in ci and waiting --mine). 352+ let last: Promise<unknown> = Promise.resolve(); 353+ return (input, init) => { 354+ const next = last.then( 355+ () => call(input, init), 356+ () => call(input, init), 358+ last = next.catch(() => {}); 362+ async function call(input: string, init: RequestInit = {}): Promise<Response> { 319363 const s = await loadServer(); 321365 const url = new URL(input); Lines 373–382 at 318 (were 329–335 at 293)
329373 headers.set("authorization", `Bearer ${LOCAL_TOKEN}`); 330374 const request = new Request(url, { ...init, headers }); 331375 const waits: Promise<unknown>[] = []; 376+ // Every call, issues ones too, holds the project file's lock, so local writers of the project and of its 377+ // issues take one lock in one order. 332378 p.db.exec("BEGIN IMMEDIATE"); 379+ p.issueObject = undefined; 334381 const version = (p.db.prepare("PRAGMA data_version").get() as { data_version: number }).data_version; 335382 if (p.seen !== undefined && version !== p.seen) p.object = undefined; Lines 384–390 at 318 (were 337–343 at 293)
339386 { waitUntil: (w: Promise<unknown>) => waits.push(w) }, 340− issuesNone,
342389 await Promise.allSettled(waits); 343390 // The answer is read whole before the write is kept, so a body that fails to arrive keeps nothing either. Lines 403–407 at 318 (were 356–362 at 293)
356403 // Where the Workers runtime answers a throw with a 500, so does this. 357404 return json(500, { error: e instanceof Error ? e.message : String(e) }); 359− };
361−
362−const issuesNone = async () => json(404, { error: "issues, asks and news aren't in local projects yet" });
Lines 79–85 at 318 (were 79–84 at 293)
7979import { runAmend, runDrop, runFollow, runLabel, runLabels, runPluck } from "./versions.ts"; 8080import { runVisibility } from "./visibility-commands.ts"; 8181import { checkVisitor } from "./visitor.ts"; 82+import { handoffText, patFromFile, webLogin } from "./web-session.ts"; 8384interface CommandDef { 8485 readonly flags: FlagSpec; Lines 213–244 at 318 (were 212–224 at 293)
212213 projects: "string", 218+ "pat-file": "string", 217− "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]",
221+ "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>] | abso login --web [--pat-file <file> [--site http://localhost:<port>]]", 219− "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.",
223+ "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. --web, on staging only, signs a browser in to the website instead: it prints a link that works once, within a minute, and signs whichever browser opens it in as the person who approved this box, but only to the projects the box was granted and at most as a writer, until the box is revoked or ends (or, with --pat-file, as the test account whose PAT that file holds, at most as a writer). It writes issues, replies, answers, groups and announcements, and changes no members, roles, visibility, keys, boxes or settings. The box's sign-in, the PAT and the session never appear. It goes only to the staging website beside this folder's staging server; any other server, prod included, is refused and nothing is sent. --site, with --pat-file only, points it at a website on this machine (http://localhost or 127.0.0.1).", 220224 run: async (args, env) => { 221225 const server = boxServer(args, env); 226+ if (bool(args, "web")) { 227+ const patFile = str(args, "pat-file"); 228+ const { handoff, site } = await webLogin({ 230+ site: str(args, "site"), 231+ kind: patFile === undefined ? "box" : "pat", 233+ if (patFile !== undefined) return patFromFile(patFile); 234+ const record = readBox(server); 235+ if (record === undefined || record.expiresAt <= Date.now()) 236+ throw new UsageError(`this box isn't signed in to ${server}: abso login first, or --pat-file <file>`); 237+ return record.credential; 240+ return { text: handoffText(handoff, site, patFile === undefined), json: { ...handoff } }; 223243 bool(args, "no-browser") || browserSkip(env.env, process.platform) !== null Lines 135–144 at 318 (were 135–142 at 293)
136136 deps.note(`(abso news --follow: couldn't read the news: ${(err as Error).message}; showing the frames)`); 138− if (items.length > 0) for (const line of items) show(line);
139− else for (const line of these) if (!shown.includes(line)) show(line);
138+ for (const line of items) show(line); 139+ // A frame the read didn't cover still shows: on a server that counts a frame as heard, its item never comes back 140+ // from the read. A catch-up frame names several items, so a frame holding a shown item counts as covered. 141+ for (const frame of these) if (!shown.some((line) => frame.includes(line) || line.includes(frame))) show(frame); 141143 running = undefined; new file, 141 lines
1+// abso login --web: a staging website session for the person a box is signed in as, opened in an agent's own browser, with 2+// no secret in the agent's hands. The website's /login/handoff takes this box's sign-in (or a test account's PAT, from a file) 3+// and answers a one-use link that works for a minute; opening it signs that browser in. Only the link is printed: never the 4+// box's sign-in, the PAT or the session cookie, which the website sets in the browser itself. 6+import { readFileSync } from "node:fs"; 7+import { UsageError } from "./args.ts"; 9+/** The website beside each staging server. Prod has none here: agents never sign in to the website on prod. */ 10+const STAGING_SITES: Readonly<Record<string, string>> = { 11+ "https://abso-staging.chrisazy.workers.dev": "https://abso-website-staging.chrisazy.workers.dev", 12+ "https://avcs-staging.chrisazy.workers.dev": "https://abso-website-staging.chrisazy.workers.dev", 15+/** What the website answers: the link, when it stops working, and who and until when it signs in. */ 16+export interface Handoff { 17+ readonly url: string; 18+ readonly expiresAt: string; 19+ readonly account: string; 20+ readonly name: string; 21+ readonly sessionEnds: string; 25+ * The website a handoff's credential goes to (Security condition 6, Code Review): the staging website beside the folder's own 26+ * staging server, from the fixed list above, and never an origin from a flag. A server that isn't on the list is refused, 27+ * prod included. --site is only for a test account's PAT on this machine (http://localhost or 127.0.0.1); a box's sign-in 28+ * takes no --site at all. 30+export function siteFor(server: string, site: string | undefined, kind: "box" | "pat"): string { 31+ const origin = new URL(server).origin; 32+ const known = STAGING_SITES[origin]; 33+ if (known === undefined) 34+ throw new UsageError( 35+ `abso login --web is for staging: ${origin} has no staging website beside it that abso knows, and agents never sign in to the website on prod. Nothing was sent.`, 37+ if (site === undefined) return known; 39+ throw new UsageError(`--site isn't taken with a box's sign-in, which goes only to ${known}. Nothing was sent.`); 40+ let url: URL | null = null; 44+ // Not an address: refused below. 46+ if (url === null || url.protocol !== "http:" || (url.hostname !== "localhost" && url.hostname !== "127.0.0.1")) 47+ throw new UsageError( 48+ "--site, with --pat-file, names this machine only (http://localhost:<port> or http://127.0.0.1:<port>). Nothing was sent.", 54+ * abso login --web: where the credential would go is settled before it is read, so a refusal reads and sends nothing 55+ * (Security). `credential` reads the box's sign-in or the PAT only once the website is one it may go to. 57+export async function webLogin(options: { 58+ readonly server: string; 59+ readonly site: string | undefined; 60+ /** A box's sign-in, or a test account's PAT (--pat-file). */ 61+ readonly kind: "box" | "pat"; 62+ readonly credential: () => string; 63+ readonly fetcher?: typeof fetch; 64+}): Promise<{ handoff: Handoff; site: string }> { 65+ const site = siteFor(options.server, options.site, options.kind); 66+ return { handoff: await webHandoff(site, options.credential(), options.fetcher), site }; 69+/** A PAT from the file --pat-file names: read here, never printed. */ 70+export function patFromFile(path: string): string { 73+ text = readFileSync(path, "utf8").trim(); 75+ throw new UsageError(`--pat-file names ${path}, which abso can't read`); 77+ if (!/^abso_pat_[A-Za-z0-9_-]{16,200}$/.test(text)) 78+ throw new UsageError(`--pat-file names ${path}, which doesn't hold a PAT`); 82+/** Words from the website, with any secret this call sent taken out. */ 83+function scrubbed(text: string, secret: string): string { 84+ return text.split(secret).join("[the credential]").slice(0, 300); 87+/** Asks the website for a handoff link with `credential` (a box sign-in or a PAT) in Authorization. */ 88+export async function webHandoff(site: string, credential: string, fetcher: typeof fetch = fetch): Promise<Handoff> { 91+ res = await fetcher(`${site}/login/handoff`, { 93+ headers: { authorization: `Bearer ${credential}`, accept: "application/json" }, 95+ signal: AbortSignal.timeout(30_000), 98+ throw new UsageError(`couldn't reach ${site}: ${scrubbed((err as Error).message, credential)}`); 100+ const text = await res.text().catch(() => ""); 101+ let body: Partial<Handoff> & { error?: unknown } = {}; 103+ body = JSON.parse(text) as typeof body; 105+ // Not JSON: the status says enough. 108+ const why = typeof body.error === "string" ? body.error : `it answered ${res.status}`; 109+ throw new UsageError( 111+ ? `${site} doesn't hand out sign-in links (its key sign-in is off, or it isn't staging)` 112+ : `${site} refused: ${scrubbed(why, credential)}`, 116+ typeof body.url !== "string" || 117+ !body.url.startsWith(`${site}/login/handoff#`) || 118+ typeof body.expiresAt !== "string" || 119+ typeof body.account !== "string" 121+ throw new UsageError(`${site} answered something that isn't a sign-in link`); 124+ expiresAt: body.expiresAt, 125+ account: body.account, 126+ name: typeof body.name === "string" ? body.name : body.account, 127+ sessionEnds: typeof body.sessionEnds === "string" ? body.sessionEnds : body.expiresAt, 131+/** What abso login --web says: the one link, how long it works, who it signs in as, and what it reaches (Security). */ 132+export function handoffText(h: Handoff, site: string, boxed = true, now = Date.now()): string { 133+ const seconds = Math.max(0, Math.round((Date.parse(h.expiresAt) - now) / 1000)); 135+ ? "only to the projects this box was granted, at most as a writer, until the box is revoked or ends" 136+ : "at most as a writer"; 138+ `Open this link in your browser within ${seconds} seconds. It signs that browser in to ${site} as ${h.name}, until ${h.sessionEnds}, and works once. It reaches ${reach}:`, new file, 60 lines
1+// abso ci for a project whose CI is its pipeline file (abso 719): test-byoc on 2026-10-16 had no abso.json, and abso ci 2+// said "nothing to run" while its abso.yml's run 8 was going. The stored run is the project's CI there. 4+import assert from "node:assert/strict"; 5+import { test } from "node:test"; 6+import { builtInHasNothing, runLine, storedRuns } from "../src/ci.ts"; 8+const base = { latest: null, checked: null, running: null, red: null, behind: null } as const; 12+ reason: "nothing to run: no abso.json, and package.json has no test, typecheck or vite", 13+ at: "2026-10-16T16:47:00.000Z", 16+test("the stored runs are read strictly, newest first as the server lists them", () => { 17+ const runs = storedRuns({ 20+ { id: 8, version: 6, state: "running", file: "abso.yml", started: 1 }, 21+ { id: "7", version: 6, state: "failed", file: "abso.yml" }, 22+ { id: 6, version: 5, state: "failed", file: "abso.yml" }, 26+ runs.map((r) => r.id), 29+ assert.deepEqual(storedRuns(null), []); 30+ assert.deepEqual(storedRuns({ runs: "no" }), []); 33+test("a run in a line names its file, its state and where its jobs are", () => { 35+ runLine({ id: 8, version: 6, state: "running", file: "abso.yml" }), 36+ "Pipeline run 8 (abso.yml) is running on version 6. abso pipeline runs 8 shows its jobs.", 39+ runLine({ id: 7, version: 6, state: "failed", file: "abso.yml" }), 40+ "Pipeline run 7 (abso.yml) failed on version 6. abso pipeline runs 7 shows its jobs.", 43+ runLine({ id: 2, version: 1, state: "planned", file: "abso.yml" }), 44+ "Pipeline run 2 (abso.yml) was planned, not run, on version 1. abso pipeline runs 2 shows its jobs.", 48+test("only the built-in check's own nothing to run is set aside, never a red or another skip", () => { 49+ assert.equal(builtInHasNothing({ ...base, skipped: nothing }), true); 50+ assert.equal(builtInHasNothing({ ...base, skipped: { ...nothing, reason: "CI is off" } }), false); 51+ assert.equal(builtInHasNothing({ ...base }), false); 55+ red: { version: 6, agent: null, message: null, lastGood: null }, Lines 4–15 at 318 (were 4–14 at 293)
55import assert from "node:assert/strict"; 66import { spawnSync } from "node:child_process"; 7−import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; 88import { tmpdir } from "node:os"; 99import { join } from "node:path"; 1010import { after, before, describe, it } from "node:test"; 1111import { fileURLToPath } from "node:url"; 12+import { closeLocalStores, LOCAL_BASE, localFetch } from "../src/local-store.ts"; 1213import { main } from "../src/main.ts"; 1314import { stateDir } from "../src/state-dir.ts"; Lines 42–53 at 318 (were 41–47 at 293)
4243const text = (dir: string, rel: string) => readFileSync(join(dir, rel), "utf8"); 44−describe("a local project, with the network off", () => {
45+/** A copy of the client without the open server beside it (a platform that pins only client/) has no local projects to test. */ 46+const noServer = existsSync(fileURLToPath(new URL("../../server/src/router.ts", import.meta.url))) 48+ : "no server/src beside this client, so no local projects"; 50+describe("a local project, with the network off", { skip: noServer }, () => { Lines 110–162 at 318 (were 104–112 at 293)
104110 assert.notEqual(held.exit, 0); 105111 assert.match(held.out + held.err, /collision/); 114+ it("issues, asks and news work too, kept in issues.sqlite beside the project", async () => { 115+ const opened = await run(alice, "issue", "new", "Fix the parser", "--agent", "bob"); 116+ assert.equal(opened.exit, 0, opened.out + opened.err); 117+ assert.ok(existsSync(join(store, "demo", "issues.sqlite"))); 118+ const listed = await run(bob, "issues"); 119+ assert.equal(listed.exit, 0, listed.err); 120+ assert.match(listed.out, /Fix the parser/); 121+ const started = await run(bob, "start", "Parser fix", "--issue", "1"); 122+ assert.equal(started.exit, 0, started.out + started.err); 123+ const asked = await run(alice, "ask", "bob", "Which grammar?", "--issue", "1"); 124+ assert.equal(asked.exit, 0, asked.out + asked.err); 125+ const waiting = await run(bob, "waiting", "--mine"); 126+ assert.equal(waiting.exit, 0, waiting.err); 127+ assert.match(waiting.out, /Which grammar\?/); 128+ const answered = await run(bob, "answer", "1", "The new one"); 129+ assert.equal(answered.exit, 0, answered.out + answered.err); 130+ const news = await run(alice, "news"); 131+ assert.equal(news.exit, 0, news.err); 132+ assert.match(news.out, /The new one/); 133+ const issue = await run(alice, "issue", "1"); 134+ assert.match(issue.out, /In progress|bob/); 137+ it("two calls at once on one project are both answered, one after the other", async () => { 138+ // As abso ci and waiting --mine make them, with Promise.all. 139+ const local = localFetch(store); 140+ const answers = await Promise.all([local(`${LOCAL_BASE}/p/demo/queue`), local(`${LOCAL_BASE}/p/demo/queue`)]); 142+ for (const a of answers) assert.equal(a.status, 200, await a.text()); 145+ it("a project's name can't start with a dot, so its folder stays inside the store", async () => { 146+ const dir = temp("dots"); 147+ writeFileSync(join(dir, "a.txt"), "x\n"); 148+ for (const name of ["..", ".hidden"]) { 149+ const r = await run(dir, "init", "--local", "--project", name, "--agent", "a"); 150+ assert.equal(r.exit, 1, r.out + r.err); 151+ // The name rule says why, before any call is made (a ".." would collapse the call's path). 152+ assert.match(r.err, /project names are letters, digits, dot, dash and underscore/); 154+ assert.ok(!existsSync(join(store, "..", "project.sqlite"))); 155+ assert.deepEqual(readdirSync(dir), ["a.txt"], "init left nothing behind"); 109−describe("where a local project's store is", () => {
159+describe("where a local project's store is", { skip: noServer }, () => { 110160 it("--store inside the folder is kept in its settings and left out of its files", async () => { 111161 store = temp("unused"); 112162 const dir = temp("venv"); Lines 191–197 at 318 (were 141–147 at 293)
144−describe("local commands as their own processes", () => {
194+describe("local commands as their own processes", { skip: noServer }, () => { 145195 // The way people and agents run them: client/abso.ts, a process per command, Node's compile cache as it is. 146196 const entry = fileURLToPath(new URL("../abso.ts", import.meta.url)); 147197 const cli = (cwd: string, processStore: string, ...argv: string[]) => Lines 155–172 at 318 (were 155–160 at 293)
155155 await follow(old.deps); 156156 assert.deepEqual(old.lines, ["fe told you: hello"]); 158+ // On that server a read can find other news waiting: the frame's own item still shows (Code Review, 291). 159+ const mixed = world([{ frames: ["fe told you: hello"], close: { code: 1006 } }]); 160+ mixed.deps.take = async () => ["cloud: an older item"]; 161+ await follow(mixed.deps); 162+ assert.deepEqual(mixed.lines, ["cloud: an older item", "fe told you: hello"]); 164+ // A catch-up frame names the first few waiting items and how many more: the read shows them all, the frame adds nothing. 165+ const catchUp = world([{ frames: ["fe told you: hello\ncloud: ship it?\nand 1 more"], close: { code: 1006 } }]); 166+ catchUp.deps.take = async () => ["fe told you: hello", "cloud: ship it?", "desk: a third"]; 167+ await follow(catchUp.deps); 168+ assert.deepEqual(catchUp.lines, ["fe told you: hello", "cloud: ship it?", "desk: a third"]); 158170 // A read that fails shows the frames and says why. 159171 const down = world([{ frames: ["fe told you: hello"], close: { code: 1006 } }]); 160172 down.deps.take = async () => { new file, 106 lines
1+// abso login --web: a staging website session handed to a browser as a one-use link, with no secret printed. 3+import assert from "node:assert/strict"; 4+import { mkdtempSync, writeFileSync } from "node:fs"; 5+import { tmpdir } from "node:os"; 6+import { join } from "node:path"; 7+import { test } from "node:test"; 8+import { handoffText, patFromFile, siteFor, webHandoff, webLogin } from "../src/web-session.ts"; 10+const SITE = "https://abso-website-staging.chrisazy.workers.dev"; 11+const STAGING = "https://abso-staging.chrisazy.workers.dev"; 12+const BOX = `abso_bx_${"C".repeat(43)}`; 13+const PAT = `abso_pat_${"A".repeat(40)}`; 14+const NOW = Date.UTC(2026, 9, 16, 9, 0, 0); 16+test("the credential goes only to the staging website beside the folder's staging server (Security condition 6)", () => { 17+ assert.equal(siteFor(STAGING, undefined, "box"), SITE); 18+ assert.equal(siteFor("https://avcs-staging.chrisazy.workers.dev/", undefined, "pat"), SITE); 19+ // A server that isn't staging is refused, prod included, whatever is asked. 21+ () => siteFor("https://api.abso.dev", undefined, "box"), 22+ /for staging.*never sign in to the website on prod/, 24+ assert.throws(() => siteFor("https://api.abso.dev", "http://localhost:8871", "pat"), /for staging/); 25+ // A box's sign-in takes no --site, not even the staging website's own address. 26+ assert.throws(() => siteFor(STAGING, SITE, "box"), /isn't taken with a box's sign-in/); 27+ assert.throws(() => siteFor(STAGING, "http://localhost:8871", "box"), /isn't taken with a box's sign-in/); 28+ // A PAT may name this machine over http, and nothing else. 29+ assert.equal(siteFor(STAGING, "http://localhost:8871/x", "pat"), "http://localhost:8871"); 30+ assert.equal(siteFor(STAGING, "http://127.0.0.1:8871", "pat"), "http://127.0.0.1:8871"); 31+ for (const elsewhere of ["https://anywhere.example", SITE, "https://localhost:8871", "not a url"]) 32+ assert.throws(() => siteFor(STAGING, elsewhere, "pat"), /names this machine only/, elsewhere); 35+test("a refused handoff reads no credential and sends no request", async () => { 36+ const sent: string[] = []; 37+ const fetcher = (async (url: string) => (sent.push(url), Response.json({}))) as unknown as typeof fetch; 39+ const credential = () => (read++, BOX); 40+ for (const asked of [ 41+ { server: "https://api.abso.dev", site: undefined, kind: "box" as const }, 42+ { server: STAGING, site: "https://anywhere.example", kind: "box" as const }, 43+ { server: STAGING, site: SITE, kind: "box" as const }, 44+ { server: "https://api.abso.dev", site: "http://localhost:8871", kind: "pat" as const }, 45+ { server: STAGING, site: "https://anywhere.example", kind: "pat" as const }, 47+ await assert.rejects(webLogin({ ...asked, credential, fetcher }), /Nothing was sent/, JSON.stringify(asked)); 48+ assert.deepEqual(sent, []); 49+ assert.equal(read, 0); 50+ // Allowed, it goes to the staging website only. 51+ await webLogin({ server: STAGING, site: undefined, kind: "pat", credential: () => PAT, fetcher }).catch(() => {}); 52+ assert.deepEqual(sent, [`${SITE}/login/handoff`]); 55+test("the credential goes in Authorization only, and the answer is the one link and who it signs in as", async () => { 56+ const seen: { url: string; authorization: string | null; body: unknown }[] = []; 57+ const fetcher = (async (url: string, init: RequestInit) => { 58+ seen.push({ url, authorization: new Headers(init.headers).get("authorization"), body: init.body ?? null }); 59+ return Response.json({ 60+ url: `${SITE}/login/handoff#${"t".repeat(50)}`, 61+ expiresAt: new Date(NOW + 60_000).toISOString(), 62+ account: "acct_person1", 64+ sessionEnds: "2026-10-16T21:00:00.000Z", 67+ const h = await webHandoff(SITE, BOX, fetcher); 68+ assert.deepEqual(seen, [{ url: `${SITE}/login/handoff`, authorization: `Bearer ${BOX}`, body: null }]); 69+ const text = handoffText(h, SITE, true, NOW); 70+ assert.match(text, /within 60 seconds/); 71+ assert.match(text, /as christopher, until 2026-10-16T21:00:00.000Z, and works once/); 72+ assert.match(text, /only to the projects this box was granted, at most as a writer/); 73+ assert.match(handoffText(h, SITE, false, NOW), /It reaches at most as a writer:/); 74+ assert.match(text, /\/login\/handoff#t{50}$/); 75+ assert.doesNotMatch(text + JSON.stringify(h), /abso_bx_/); 78+test("a refusal says why without the credential; an answer that isn't the site's own link is refused", async () => { 79+ const echo = (async () => 80+ Response.json({ error: `that key was refused: ${BOX}` }, { status: 401 })) as unknown as typeof fetch; 81+ await assert.rejects(webHandoff(SITE, BOX, echo), (err: Error) => { 82+ assert.match(err.message, /refused: that key was refused: \[the credential\]/); 83+ assert.doesNotMatch(err.message, /abso_bx_/); 86+ const off = (async () => Response.json({ error: "not found" }, { status: 404 })) as unknown as typeof fetch; 87+ await assert.rejects(webHandoff(SITE, BOX, off), /doesn't hand out sign-in links/); 88+ const elsewhere = (async () => 90+ url: "https://elsewhere.example/login/handoff#x", 91+ expiresAt: new Date(NOW).toISOString(), 93+ })) as unknown as typeof fetch; 94+ await assert.rejects(webHandoff(SITE, BOX, elsewhere), /isn't a sign-in link/); 97+test("--pat-file reads a PAT from its file, and refuses a file that doesn't hold one", () => { 98+ const dir = mkdtempSync(join(tmpdir(), "abso-web-")); 99+ const good = join(dir, "pat"); 100+ writeFileSync(good, `abso_pat_${"A".repeat(40)}\n`); 101+ assert.equal(patFromFile(good), `abso_pat_${"A".repeat(40)}`); 102+ const bad = join(dir, "not"); 103+ writeFileSync(bad, "hello"); 104+ assert.throws(() => patFromFile(bad), /doesn't hold a PAT/); 105+ assert.throws(() => patFromFile(join(dir, "missing")), /can't read/);