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

Compare

+46 −2 in 10 places
Lines 4–10 at 318 (were 4–9 at 258)
44
55import { randomUUID } from "node:crypto";
66import { setDefaultResultOrder } from "node:dns";
7+import { CALLER_HEADER } from "../../src/caller.ts";
78import type {
89 ChangeAnswer,
910 DraftSyncAnswer,
Lines 20–26 at 318 (were 19–24 at 258)
1920 SyncAnswer,
2021} from "./api-answers.ts";
2122import { ApiError, errorSentence, neverSent } from "./api-error.ts";
23+import { UsageError } from "./args.ts";
2224import type { AutosettleAnswer, AutosettleMode } from "./autosettle-commands.ts";
2325import {
2426 boxQuery,
Lines 69–75 at 318 (were 67–72 at 258)
6769 IssueRow,
6870 IssueSearchHit,
6971} from "./issues-wire.ts";
72+import { isLocal, LOCAL_BASE, localFetch, NO_STORE } from "./local-store.ts";
7073import type { Modes } from "./modes.ts";
7174
7275export * from "./api-answers.ts";
Lines 144–166 at 318 (were 141–146 at 258)
141144 | { dryRun: true; plan: CopyPlan }
142145 | { ok: true; id: number; from: { project: string; issue: number }; skipped: { comments: number[]; asks: number[] } };
143146
147+/**
148+ * The server's line when another chat just used this seat (seatNotice on an answer): kept until main() prints it with
149+ * the news, once however many answers carried it.
150+ */
151+const seatNotices = new Set<string>();
152+function noteSeat(answer: unknown): void {
153+ if (typeof answer !== "object" || answer === null || Array.isArray(answer)) return;
154+ const line = (answer as { seatNotice?: unknown }).seatNotice;
155+ if (typeof line === "string" && line !== "" && line.length <= 300 && !/[\u0000-\u001f]/.test(line))
156+ seatNotices.add(line);
157+}
158+export function takeSeatNotices(): string[] {
159+ const out = [...seatNotices];
160+ seatNotices.clear();
161+ return out;
162+}
144164export class Api {
145165 readonly config: Config;
146166 readonly timeoutMs: number;
Lines 189–205 at 318 (were 169–178 at 258)
169189 /** The Issues Worker (#54) this folder's issues calls go to; set by the issues commands (issues.ts). */
170190 issuesServer: string | undefined;
171191
192+ /** Who is calling this seat (src/caller.ts): this chat's session, this computer and this folder. Set by open(). */
193+ caller: string | undefined;
172195 url(path: string, server = this.config.server): string {
173− return `${server.replace(/\/+$/, "")}/p/${encodeURIComponent(this.config.project)}${path}`;
196+ const base = isLocal(server) ? LOCAL_BASE : server;
197+ return `${base.replace(/\/+$/, "")}/p/${encodeURIComponent(this.config.project)}${path}`;
174198 }
175199
200+ /** A local project's calls: answered in this process (local-store.ts). */
201+ private local: ((input: string, init?: RequestInit) => Promise<Response>) | undefined;
176203 agentPath(action: string): string {
177204 return `/a/${encodeURIComponent(this.config.agent)}/${action}`;
178205 }
Lines 209–216 at 318 (were 182–187 at 258)
182209 // Which client made the call (#29); the mods send theirs too.
183210 "x-abso-client": `abso-cli/${clientVersion()}`,
184211 ...(this.config.token && !this.config.visitor ? { authorization: `Bearer ${this.config.token}` } : {}),
212+ // A visitor says nothing about where it's reading from.
213+ ...(this.caller !== undefined && !this.config.visitor ? { [CALLER_HEADER]: this.caller } : {}),
185214 ...(contentType ? { "content-type": contentType } : {}),
186215 };
187216 }
Lines 220–231 at 318 (were 191–196 at 258)
191220 * and follows no redirect, so nothing it sends goes anywhere it didn't name (headers() adds no sign-in).
192221 */
193222 send(url: string, init: RequestInit = {}): Promise<Response> {
223+ if (isLocal(this.config.server)) {
224+ const dir = this.config.localStore;
225+ if (dir === undefined) return Promise.reject(new UsageError(NO_STORE));
226+ this.local ??= localFetch(dir);
227+ return this.local(url, init);
228+ }
194229 if (!this.config.visitor) return fetch(url, init);
195230 if ((init.method ?? "GET") !== "GET")
196231 return Promise.reject(new ApiError("a folder that reads signed out sends only reads"));
Lines 260–267 at 318 (were 225–230 at 258)
225260 signal: AbortSignal.timeout(timeoutMs),
226261 });
227262 } catch (err) {
263+ // A local project's refusal (no store, a Node without SQLite) says itself.
264+ if (err instanceof UsageError) throw err;
228265 const e = err as Error;
229266 const why =
230267 e.name === "TimeoutError"
Lines 295–303 at 318 (were 258–264 at 258)
258295 res.status,
259296 );
260297 try {
261− return JSON.parse(text) as T;
298+ const parsed = JSON.parse(text) as T;
299+ noteSeat(parsed);
300+ return parsed;
262301 } catch {
263302 throw new ApiError(
264303 `${method} ${path} answered with something that isn't JSON: ${text.slice(0, 300)}`,
Lines 1016–1026 at 318 (were 977–982 at 258)
9771016 return this.json("POST", this.agentPath("news"), {});
9781017 }
9791018
1019+ /** A ticket that opens this agent's news stream once, within a minute (abso 690; news-stream.ts). */
1020+ newsTicket(): Promise<{ url: string; protocols: string[]; expiresAt: number | string }> {
1021+ return this.json("POST", this.agentPath("news/ticket"), {});
1022+ }
9801024 /** This agent's unpublished changes, file by file. */
9811025 diff(): Promise<DiffAnswer> {
9821026 return this.json("POST", this.agentPath("diff"), {});
MCP
compare on this site's /mcp
CLI
abso diff 258 318 client/src/api.ts --json
JSON
/christopher/abso-core/compare/258..318?file=client%2Fsrc%2Fapi.ts&format=json