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 2 to 318

Compare

+48 −12 in 15 places
Lines 89–99 at 318 (were 89–97 at 2)
8989 queueHold: boolean;
9090 /** The next publish: commit it and answer 500 ('after'), or answer 500 without it ('before'), as a storage reset does. */
9191 failPublish: "after" | "before" | undefined;
92+ /** How many of the next pulls to carry out and then cut before answering, as an answer that never arrives (abso-core 26). */
93+ loseSyncAnswers: number;
9294 /** Run the merge queue's rounds now (after queueHold is let go). */
9395 kickQueue(name: string): Promise<void>;
94− /** Each run POST's X-Avcs-Run-Key, and whether a run started for it. */
96+ /** Each run POST's X-Abso-Run-Key, and whether a run started for it. */
9597 runStarts: { key: string | undefined; started: boolean; cmd: string; kind?: string }[];
9698 close(): Promise<void>;
9799}
Lines 101–107 at 318 (were 99–105 at 2)
99101const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/;
100102
101103function isLocal(path: string): boolean {
102− return path === ".avcs" || path.startsWith(".avcs/") || path.startsWith("./.avcs/");
104+ return [".abso", ".avcs"].some((d) => path === d || path.startsWith(`${d}/`) || path.startsWith(`./${d}/`));
103105}
104106
105107async function readBody(req: IncomingMessage): Promise<Buffer> {
Lines 157–163 at 318 (were 155–160 at 2)
155157 boxExtra: undefined,
156158 queueHold: false,
157159 failPublish: undefined,
160+ loseSyncAnswers: 0,
158161 kickQueue: async () => {},
159162 close: async () => {},
160163 };
Lines 253–259 at 318 (were 250–256 at 2)
250253 ...files.map((rel) => ({ path: rel, data: readFileSync(join(box!, ...rel.split("/"))) })),
251254 ...extra,
252255 ]);
253− res.writeHead(200, { "content-type": "application/gzip", "x-avcs-files": String(files.length) });
256+ res.writeHead(200, { "content-type": "application/gzip", "x-abso-files": String(files.length) });
254257 res.end(Buffer.from(gz));
255258 return;
256259 }
Lines 274–280 at 318 (were 271–277 at 2)
271274 return;
272275 }
273276 const m =
274− /^\/p\/([^/]+)\/(init|status|queue|change\/\d+|changes|notes|ci\/revoke|ci|blame|why|where|labels|files|log|show|file|compare|a\/([^/]+)\/(edit|record|publish|sync|run|draft|land|draft-sync|diff|restore|announce|news|starting|reader|drop|pluck|amend|label|files|unqueue|note|note-close|move))$/.exec(
277+ /^\/p\/([^/]+)\/(init|status|queue|change\/\d+|changes|notes|ci\/revoke|ci|blame|why|where|labels|files|diff|log|show|file|compare|without|a\/([^/]+)\/(edit|record|publish|sync|run|draft|land|draft-sync|diff|restore|announce|news|starting|reader|drop|pluck|amend|label|files|unqueue|note|note-close|move))$/.exec(
275278 url.pathname,
276279 );
277280 if (!m) return send(res, 404, { error: "no such route; see docs/v2-slice1.md" });
Lines 298–304 at 318 (were 295–301 at 2)
295298 if (!files || typeof files !== "object") return send(res, 400, { error: "init needs {files: {path: text}}" });
296299 if (hosted) return send(res, 409, { error: "the project already exists" });
297300 const bad = Object.keys(files).find(isLocal);
298− if (bad) return send(res, 400, { error: `${bad} is under .avcs/, which stays in the agent's folder` });
301+ if (bad) return send(res, 400, { error: `${bad} is under .abso/, which stays in the agent's folder` });
299302 const store = new MemoryStore();
300303 const blobs = pendingBlobs(name);
301304 waiting.delete(name);
Lines 408–424 at 318 (were 405–410 at 2)
405408 }
406409 if (op === "where") return send(res, 200, where(hosted.project));
407410 if (op === "labels") return send(res, 200, hosted.project.labels());
411+ if (op === "diff" && agent === undefined) {
412+ // Another agent's draft, read only (abso diff --agent), as the Worker answers GET /p/:project/diff?agent=.
413+ const of = url.searchParams.get("agent");
414+ if (!of) return send(res, 400, { error: "diff needs ?agent=<name>" });
415+ try {
416+ return send(res, 200, hosted.project.diffOf(of));
417+ } catch (e) {
418+ const code = (e as { code?: string }).code;
419+ return send(res, code === "not-found" ? 404 : 500, { error: e instanceof Error ? e.message : String(e) });
420+ }
421+ }
408422 if (op === "files" && agent === undefined) {
409423 const q = Object.fromEntries(url.searchParams) as Record<string, string | undefined>;
410424 try {
Lines 437–462 at 318 (were 423–434 at 2)
423437 return send(res, 200, blame(hosted.project, q.file, num(q.from), num(q.to), num(q.version), view));
424438 const line = num(q.line);
425439 if (!line || !Number.isInteger(line)) return send(res, 400, { error: "why needs ?line=<number>" });
426− return send(res, 200, why(hosted.project, q.file, line, view));
440+ return send(res, 200, why(hosted.project, q.file, line, { ...view, version: num(q.version) }));
427441 } catch (e) {
428442 const code = (e as { code?: string }).code;
429443 return send(res, code === "bad-request" ? 400 : 500, { error: e instanceof Error ? e.message : String(e) });
430444 }
431445 }
446+ if (op === "without") {
447+ // GET ?version=<n>&versions=<n,n>, as worker/project/http.ts routes it.
448+ const q = Object.fromEntries(url.searchParams) as Record<string, string | undefined>;
449+ try {
450+ return send(
451+ res,
452+ 200,
453+ hosted.project.without(Number(q.version), (q.versions ?? "").split(",").filter(Boolean).map(Number)),
454+ );
455+ } catch (e) {
456+ const code = (e as { code?: string }).code;
457+ return send(res, code === "bad-request" ? 400 : 500, { error: e instanceof Error ? e.message : String(e) });
458+ }
459+ }
432460 if (op === "log" || op === "show" || op === "file" || op === "compare") {
433461 // As the Worker routes them: ?draft=<name>, shared when absent.
434462 const q = Object.fromEntries(url.searchParams) as Record<string, string | undefined>;
Lines 499–511 at 318 (were 471–483 at 2)
471499 if (agent === undefined || !NAME.test(agent))
472500 return send(res, 400, { error: "agent names use letters, digits, '.', '_' and '-'" });
473501 if (op === "run") {
474− const key = req.headers["x-avcs-run-key"];
502+ const key = req.headers["x-abso-run-key"];
475503 const dropped = fake.dropRunStarts > 0;
476504 fake.runStarts.push({
477505 key: typeof key === "string" ? key : undefined,
478506 started: !dropped,
479507 cmd: url.searchParams.get("cmd") ?? "",
480− kind: String(req.headers["x-avcs-kind"] ?? ""),
508+ kind: String(req.headers["x-abso-kind"] ?? ""),
481509 });
482510 if (dropped) {
483511 fake.dropRunStarts--;
Lines 526–532 at 318 (were 498–504 at 2)
498526 if (typeof body.file !== "string")
499527 return send(res, 400, { error: "edit needs {file, old, new}, {file, content} or {file, edits}" });
500528 if (isLocal(body.file))
501− return send(res, 400, { error: `${body.file} is under .avcs/, which stays in the agent's folder` });
529+ return send(res, 400, { error: `${body.file} is under .abso/, which stays in the agent's folder` });
502530 return send(res, 200, project.edit(agent, body as unknown as Parameters<Project["edit"]>[1], Date.now()));
503531 }
504532 if (op === "record") {
Lines 534–540 at 318 (were 506–512 at 2)
506534 if (!files || typeof files !== "object")
507535 return send(res, 400, { error: "record needs {files: {path: text or null}}" });
508536 const bad = Object.keys(files).find(isLocal);
509− if (bad) return send(res, 400, { error: `${bad} is under .avcs/, which stays in the agent's folder` });
537+ if (bad) return send(res, 400, { error: `${bad} is under .abso/, which stays in the agent's folder` });
510538 const meta = {
511539 ...(typeof body.session === "string" ? { session: body.session } : {}),
512540 ...(typeof body.subagent === "string" ? { subagent: body.subagent } : {}),
Lines 555–561 at 318 (were 527–533 at 2)
527555 if (op === "publish") {
528556 const message = body.message;
529557 if (typeof message !== "string" || !message.trim())
530− return send(res, 400, { error: "publish needs {message} saying why" });
558+ return send(res, 400, { error: "push needs {message} saying why" });
531559 const fail = fake.failPublish;
532560 fake.failPublish = undefined;
533561 const storageReset = { error: "Internal error in Durable Object storage caused object to be reset." };
Lines 635–645 at 318 (were 607–612 at 2)
607635 ...(typeof body.label === "string" ? { label: body.label } : {}),
608636 ...(body.full === true ? { full: true } : {}),
609637 });
638+ if (fake.loseSyncAnswers > 0) {
639+ fake.loseSyncAnswers--;
640+ res.destroy();
641+ return;
642+ }
610643 const extra = fake.injectSync;
611644 fake.injectSync = undefined;
612645 if (extra === undefined) return send(res, 200, synced);
Lines 678–684 at 318 (were 645–651 at 2)
645678 const run: Run = { out: Buffer.alloc(0), err: Buffer.alloc(0), split, end: undefined, listeners: new Set() };
646679 hosted.runs.clear();
647680 hosted.runs.set(id, run);
648− res.writeHead(200, { "content-type": "application/x-ndjson", "x-avcs-box": "warm", "x-avcs-run": id });
681+ res.writeHead(200, { "content-type": "application/x-ndjson", "x-abso-box": "warm", "x-abso-run": id });
649682 res.write(`${JSON.stringify({ run: id, ...(split ? { stderr: "split" } : {}) })}\n`);
650683 streamRun(res, run);
651684 const emit = (line: string): void => {
Lines 759–767 at 318 (were 726–731 at 2)
726759 else res.end();
727760 });
728761 });
762+ // Never close an idle kept-alive connection: on Windows, under load, the client could reuse one in the moment
763+ // the server closed it, and the next call failed with ECONNRESET. close() below drops every connection.
764+ server.keepAliveTimeout = 0;
729765 await new Promise<void>((ok) => server.listen(port, "127.0.0.1", ok));
730766 const address = server.address() as AddressInfo;
731767 return Object.assign(fake, {
MCP
compare on this site's /mcp
CLI
abso diff 2 318 client/test/fake-server.ts --json
JSON
/christopher/abso-core/compare/2..318?file=client%2Ftest%2Ffake-server.ts&format=json