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
MCP
blame on this site's /mcp
CLI
abso blame client/src/api.ts --version 96 --json
JSON
/christopher/abso-core/blame/client/src/api.ts?version=96&format=json
974 linesFirst import 73% · pinch 24% · devops 2% · infra-pipeline 1% · infra-split 1% · review 1%Last change pinch in version 89,

974 lines from 18 changes in 18 versions.

init0Start the project1// Calls to the server's HTTP API (docs/v2-slice1.md). Every call is JSON
2// except `run`, which sends a tar.gz and reads the answer as a stream of JSON
3// lines (box-run.ts).
4
5import { setDefaultResultOrder } from "node:dns";
6import type {
7 ChangeAnswer,
8 DraftSyncAnswer,
9 EditAnswer,
10 EditBody,
11 News,
12 NoteAnswer,
13 NoteBody,
14 PublishAnswer,
15 RecordAnswer,
16 StatusAnswer,
17 SwitchAnswer,
18 SyncAnswer,
19} from "./api-answers.ts";
20import { ApiError, errorSentence, neverSent } from "./api-error.ts";
21import {
22 boxQuery,
23 consumeRun,
24 follow,
25 followUrl,
26 type PrepAnswer,
27 postRun,
28 RECONNECT_DELAYS_MS,
29 RUN_START_RETRY_MS,
30 type RunIO,
31 type RunKind,
32 type ServeAnswer,
33} from "./box-run.ts";
34import type { CiJob, CiStatus, QueueState } from "./ci-answers.ts";
35import { clientVersion } from "./client-version.ts";
36import type { Config } from "./config.ts";
37import type {
38 BlameAnswer,
39 DiffAnswer,
40 DropAnswer,
41 FileChange,
42 FilesAnswer,
43 LogAnswer,
44 Overlap,
45 PluckAnswer,
46 RestoreAnswer,
47 ShowAnswer,
48 View,
49 Where,
50 WhereAnswer,
51 WhyAnswer,
52} from "./history-answers.ts";
devops20Add abso search: find a project's issues by words or meaning `abso search "<words>" [--limit <N>]` lists the project's issues that match, best first, and is served as an MCP tool as well. - Each hit shows the issue, then where it matched: the title, the description, a comment, or "by meaning". - "#N" or "N" puts issue N first. - Where the server also searches by meaning, an issue worded unlike the search still turns up; the hit says so.Compare53import type {
54 Ask,
55 Attachment,
56 Draft,
57 DraftBody,
58 News as IssueNews,
59 IssuePage,
60 IssueRow,
61 IssueSearchHit,
62} from "./issues-wire.ts";
init0Start the project63import type { Modes } from "./modes.ts";
65export * from "./api-answers.ts";
66export { ApiError, neverSent } from "./api-error.ts";
67export {
68 type PrepAnswer,
69 RECONNECT_DELAYS_MS,
70 RUN_START_RETRY_MS,
71 type RunIO,
72 type RunKind,
73 type ServeAnswer,
74} from "./box-run.ts";
75export * from "./ci-answers.ts";
76export * from "./history-answers.ts";
devops20Add abso search: find a project's issues by words or meaning `abso search "<words>" [--limit <N>]` lists the project's issues that match, best first, and is served as an MCP tool as well. - Each hit shows the issue, then where it matched: the title, the description, a comment, or "by meaning". - "#N" or "N" puts issue N first. - Where the server also searches by meaning, an issue worded unlike the search still turns up; the hit says so.Compare77export type { Ask, Attachment, Draft, DraftBody, IssueNews, IssuePage, IssueRow, IssueSearchHit };
init0Start the project78
79/**
80 * How long a call may take: the base, plus 1 s for each 100 KB it sends
81 * (abso issue 34: a sync that recorded 191 reformatted files first ran out of
82 * its 30 s while the server was still taking them in).
83 */
84export function timeoutFor(baseMs: number, sent: string | undefined): number {
85 return sent === undefined ? baseMs : baseMs + Math.floor(Buffer.byteLength(sent) / 100_000) * 1000;
pinch26Publish and log fixes, and a flaky test removed. - A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed. - abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short. - The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET). Check: 722 pass, 0 fail.Compare88/**
89 * How long a publish or a land may take before the client stops waiting: the
90 * server gives one request up to 2 minutes of work, so a small body can still
91 * take that long (a large merge). Waiting less reported publishes as failed
92 * that went on to land.
93 */
94export const PUBLISH_TIMEOUT_MS = 150_000;
96/** The most versions the server's log sends at once. */
97export const LOG_PAGE = 200;
init0Start the project99/** A query string from the values that are set (null and undefined are left out). */
100function query(values: Record<string, string | number | null | undefined>): URLSearchParams {
101 const q = new URLSearchParams();
102 for (const [k, v] of Object.entries(values)) if (v !== null && v !== undefined) q.set(k, String(v));
103 return q;
106export function newsLines(news: News): string[] {
107 if (news === undefined || news === null) return [];
108 return (typeof news === "string" ? [news] : [...news]).filter((s) => typeof s === "string" && s.trim() !== "");
pinch23abso issue <N> --copy-to <project>: copy an issue into another project, with its comments, answered asks and labels, each keeping its author and time. The Issues server reads the source issue itself; the client sends only which issue, and any cleaned texts. - --dry-run shows what the copy would make (title, how many comments and asks, which were edited, labels) and what's left behind. It writes nothing. - --clean <file> gives cleaned texts by source id, as JSON: {title, description, comments: [{id, text}], asks: [{id, question, answer}]}. A comment left out of a given list isn't copied. - --copy-to goes alone, so a copy is never half an edit. Copying into the project the issue is already in is refused before any call. - When a live server refuses the copy (copying out of a project there takes an owner of it), the message says --dry-run still works. - The MCP issue tool's clean input is a file too, so it's confined to the server's start folder like attach. Tests: client/test/issues.test.ts, against a stand-in Issues server. The run --parallel test that sometimes times out under a full run passed when rerun.Compare111/** An issue copy's request: the source, and any texts given cleaned, by their source ids. */
112export interface CopyBody {
113 from: string;
114 issue: number;
115 title?: string;
116 description?: string;
117 comments?: { id: number; text?: string }[];
118 asks?: { id: number; question?: string; answer?: string }[];
121/** What a copy writes, as a dry run answers it. */
122export interface CopyPlan {
123 from: { project: string; issue: number };
124 title: string;
125 edited: ("title" | "description")[];
126 labels: string[];
127 closed: { how: "done" | "dropped" } | null;
128 comments: { edited: boolean }[];
129 asks: { edited: boolean }[];
130 skipped: { comments: number[]; asks: number[] };
133export type CopyAnswer =
134 | { dryRun: true; plan: CopyPlan }
135 | { ok: true; id: number; from: { project: string; issue: number }; skipped: { comments: number[]; asks: number[] } };
init0Start the project137export class Api {
138 readonly config: Config;
139 readonly timeoutMs: number;
141 /** Waits between tries when a run's stream breaks; tests shorten them. */
142 readonly reconnectDelaysMs: readonly number[];
143 readonly startRetryDelaysMs: readonly number[];
review27Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)Compare144 /** Another box of this agent for run, logs and fetch (--box or ABSO_BOX, #37); undefined is its own box. */
init0Start the project145 box: string | undefined;
147 constructor(
148 config: Config,
149 timeoutMs = 30_000,
150 reconnectDelaysMs: readonly number[] = RECONNECT_DELAYS_MS,
151 startRetryDelaysMs: readonly number[] = RUN_START_RETRY_MS,
152 ) {
153 this.config = config;
154 this.timeoutMs = timeoutMs;
155 this.reconnectDelaysMs = reconnectDelaysMs;
156 this.startRetryDelaysMs = startRetryDelaysMs;
157 }
pinch54The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.Compare159 /** What a box run is for, for the server's box-run records (#39): X-Abso-Kind on POST /run. */
init0Start the project160 runKind: RunKind = "run";
162 /** The Issues Worker (#54) this folder's issues calls go to; set by the issues commands (issues.ts). */
163 issuesServer: string | undefined;
165 url(path: string, server = this.config.server): string {
166 return `${server.replace(/\/+$/, "")}/p/${encodeURIComponent(this.config.project)}${path}`;
167 }
169 agentPath(action: string): string {
170 return `/a/${encodeURIComponent(this.config.agent)}/${action}`;
171 }
173 headers(contentType?: string): Record<string, string> {
174 return {
175 // Which client made the call (#29); the mods send theirs too.
pinch54The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.Compare176 "x-abso-client": `abso-cli/${clientVersion()}`,
pinch86Read a public project signed out: abso join <project> --reader with no sign-in makes a folder that reads it. The folder holds only its settings (server, project, visitor), sends no sign-in whatever the environment or the box holds, follows no redirect, and runs status, log, show, files, blame, why, where, issues, issue and search; every other command is refused before any call, from an allow-list a new command has to join. join answers a private project and a missing one alike, by the status answer's code alone. Tests in client/test/visitor.test.ts.Compare177 ...(this.config.token && !this.config.visitor ? { authorization: `Bearer ${this.config.token}` } : {}),
init0Start the project178 ...(contentType ? { "content-type": contentType } : {}),
179 };
180 }
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare182 /**
183 * Every request this Api makes goes through here. In a visitor folder it never sends anything but a GET,
184 * and follows no redirect, so nothing it sends goes anywhere it didn't name (headers() adds no sign-in).
185 */
186 send(url: string, init: RequestInit = {}): Promise<Response> {
187 if (!this.config.visitor) return fetch(url, init);
188 if ((init.method ?? "GET") !== "GET")
189 return Promise.reject(new ApiError("a folder that reads signed out sends only reads"));
190 return fetch(url, { ...init, redirect: "error" });
191 }
pinch26Publish and log fixes, and a flaky test removed. - A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed. - abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short. - The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET). Check: 722 pass, 0 fail.Compare193 async json<T>(
194 method: "GET" | "POST",
195 path: string,
196 body?: unknown,
197 server = this.config.server,
198 atLeastMs = 0,
199 ): Promise<T> {
init0Start the project200 let res: Response | undefined;
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare201 if (this.config.visitor && method !== "GET")
202 throw new ApiError(`${path}: a folder that reads signed out sends only reads`);
init0Start the project203 const sent = body === undefined ? undefined : JSON.stringify(body);
pinch26Publish and log fixes, and a flaky test removed. - A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed. - abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short. - The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET). Check: 722 pass, 0 fail.Compare204 const timeoutMs = Math.max(atLeastMs, timeoutFor(this.timeoutMs, sent));
init0Start the project205 // A connection that never opened is tried once more, IPv4 first (#37, GAME - UI/UX: one IPv6
206 // address timed out, and the same command went through seconds later). Nothing went out, so
207 // a POST is as safe to send again as a GET.
208 for (let attempt = 0; res === undefined; attempt++) {
209 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare210 res = await this.send(this.url(path, server), {
init0Start the project211 method,
212 headers: this.headers(sent === undefined ? undefined : "application/json"),
213 ...(sent === undefined ? {} : { body: sent }),
214 signal: AbortSignal.timeout(timeoutMs),
215 });
216 } catch (err) {
217 const e = err as Error;
218 const why =
219 e.name === "TimeoutError"
220 ? `no answer within ${timeoutMs} ms`
221 : ((e.cause as Error | undefined)?.message ?? e.message);
222 if (!neverSent(err)) throw new ApiError(`could not reach ${server}: ${why}`);
223 if (attempt >= 1) {
224 throw new ApiError(
225 `could not reach ${server}: ${why}. Tried twice, the second time IPv4 first; the connection never opened, so nothing reached the server`,
226 undefined,
227 true,
228 );
229 }
230 setDefaultResultOrder("ipv4first");
231 await new Promise((ok) => setTimeout(ok, 500));
232 }
233 }
234 const text = await res.text();
235 // 409 is a refusal that says what to do (a drop took out lines your work builds on): print it as it is.
236 if (!res.ok)
237 throw new ApiError(
238 res.status === 409
239 ? `refused: ${errorSentence(text)}`
240 : `${method} ${path} answered ${res.status}: ${errorSentence(text)}`,
241 res.status,
242 );
243 try {
244 return JSON.parse(text) as T;
245 } catch {
246 throw new ApiError(
247 `${method} ${path} answered with something that isn't JSON: ${text.slice(0, 300)}`,
248 res.status,
249 );
250 }
251 }
253 init(
254 files: Record<string, string>,
255 modes: Modes = {},
256 blobs: Readonly<Record<string, string>> = {},
257 ): Promise<{ version: number; skipped?: readonly string[] }> {
258 return this.json("POST", "/init", {
259 files,
260 ...(Object.keys(modes).length > 0 ? { modes } : {}),
261 ...(Object.keys(blobs).length > 0 ? { blobs } : {}),
262 });
263 }
265 edit(body: EditBody): Promise<EditAnswer> {
266 return this.json("POST", this.agentPath("edit"), body);
267 }
269 record(
270 files: Record<string, string | null>,
271 extra: { session?: string; subagent?: string } = {},
272 modes: Modes = {},
273 blobs: Readonly<Record<string, string>> = {},
274 ): Promise<RecordAnswer> {
275 return this.json("POST", this.agentPath("record"), {
276 files,
277 ...(Object.keys(modes).length > 0 ? { modes } : {}),
278 ...(Object.keys(blobs).length > 0 ? { blobs } : {}),
279 ...extra,
280 });
281 }
283 /** Move a file in the draft (#49): its lines keep their ids. The way to change a file's case. */
284 move(from: string, to: string): Promise<{ ok: boolean; from: string; to: string; news?: News }> {
285 return this.json("POST", this.agentPath("move"), { from, to });
286 }
288 /** Upload a binary file's bytes under their sha256 (the server checks the hash). */
289 async putBlob(sha: string, bytes: Uint8Array): Promise<void> {
290 await this.bytes("PUT", `/blobs/${sha}`, bytes);
291 }
293 /** A preview of one version of shared at a stable URL (abso serve, #37); a build answers 422 with its output. */
294 async serve(version?: number, cmd?: string, out?: string): Promise<ServeAnswer> {
295 const q = new URLSearchParams({
296 ...(version !== undefined ? { version: String(version) } : {}),
297 ...(cmd ? { cmd } : {}),
298 ...(out ? { out } : {}),
299 });
300 let res: Response;
301 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare302 res = await this.send(`${this.url("/serve")}?${q}`, {
init0Start the project303 method: "POST",
304 headers: this.headers(),
305 signal: AbortSignal.timeout(20 * 60_000),
306 });
307 } catch (err) {
308 const e = err as Error;
309 throw new ApiError(
310 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
311 );
312 }
313 const text = await res.text();
314 if (!res.ok && res.status !== 422)
315 throw new ApiError(`serve answered ${res.status}: ${errorSentence(text)}`, res.status);
316 return JSON.parse(text) as ServeAnswer;
317 }
319 /** Runs a setup command on the folder in a fresh box and keeps the box as what it starts from (abso prep, #37). */
320 async prep(command: string, tarGz: Uint8Array<ArrayBuffer>): Promise<PrepAnswer> {
321 let res: Response;
322 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare323 res = await this.send(
324 `${this.url(this.agentPath("prep"))}?cmd=${encodeURIComponent(command)}${boxQuery(this.box)}`,
325 {
326 method: "POST",
327 headers: this.headers("application/gzip"),
328 body: tarGz,
329 // A setup command can take minutes (npm ci, a browser download).
330 signal: AbortSignal.timeout(30 * 60_000),
331 },
332 );
init0Start the project333 } catch (err) {
334 const e = err as Error;
335 throw new ApiError(
336 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
337 );
338 }
339 const text = await res.text();
340 if (!res.ok) throw new ApiError(`prep answered ${res.status}: ${errorSentence(text)}`, res.status);
341 return JSON.parse(text) as PrepAnswer;
342 }
344 /** Forgets the box's prep: it starts from the plain image again. Answers whether it had one. */
345 async unprep(): Promise<boolean> {
346 let res: Response;
347 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare348 res = await this.send(
init0Start the project349 `${this.url(this.agentPath("prep"))}${this.box ? `?box=${encodeURIComponent(this.box)}` : ""}`,
350 { method: "DELETE", headers: this.headers(), signal: AbortSignal.timeout(this.timeoutMs) },
351 );
352 } catch (err) {
353 const e = err as Error;
354 throw new ApiError(
355 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
356 );
357 }
358 const text = await res.text();
359 if (!res.ok) throw new ApiError(`prep answered ${res.status}: ${errorSentence(text)}`, res.status);
360 return (JSON.parse(text) as { forgot: boolean }).forgot;
361 }
363 /** A binary file's bytes by their sha256. */
364 /** A tar.gz of the files under the box's /w that match a glob (bash globstar); null when none match or the box has stopped. */
365 async boxFiles(glob: string): Promise<Uint8Array | null> {
366 try {
367 return await this.bytes(
368 "GET",
369 `${this.agentPath("box-files")}?${new URLSearchParams({ glob, ...(this.box ? { box: this.box } : {}) })}`,
370 );
371 } catch (err) {
372 if (err instanceof ApiError && err.status === 404) return null;
373 throw err;
374 }
375 }
377 getBlob(sha: string): Promise<Uint8Array> {
378 return this.bytes("GET", `/blobs/${sha}`);
379 }
381 async bytes(method: "GET" | "PUT", path: string, body?: Uint8Array): Promise<Uint8Array> {
382 let res: Response;
383 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare384 res = await this.send(this.url(path), {
init0Start the project385 method,
386 headers: this.headers(body === undefined ? undefined : "application/octet-stream"),
387 ...(body === undefined ? {} : { body: body as Uint8Array<ArrayBuffer> }),
388 signal: AbortSignal.timeout(Math.max(this.timeoutMs, 120_000)),
389 });
390 } catch (err) {
391 const e = err as Error;
392 throw new ApiError(
393 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
394 );
395 }
396 const data = new Uint8Array(await res.arrayBuffer());
397 if (!res.ok)
398 throw new ApiError(
399 `${method} ${path} answered ${res.status}: ${errorSentence(new TextDecoder().decode(data))}`,
400 res.status,
401 );
402 return data;
403 }
405 /** Make this agent a reader, or not (#37): a reader's edits, records and publishes are refused. */
406 reader(on: boolean): Promise<{ agent: string; reader: boolean }> {
407 return this.json("POST", this.agentPath("reader"), { reader: on });
408 }
410 publish(message: string, asIs = false): Promise<PublishAnswer> {
pinch26Publish and log fixes, and a flaky test removed. - A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed. - abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short. - The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET). Check: 722 pass, 0 fail.Compare411 return this.json(
412 "POST",
413 this.agentPath("publish"),
414 { message, ...(asIs ? { asIs: true } : {}) },
415 undefined,
416 PUBLISH_TIMEOUT_MS,
417 );
init0Start the project418 }
420 /** One change (#44). */
421 change(id: number): Promise<ChangeAnswer> {
422 return this.json("GET", `/change/${id}`);
423 }
425 /** The changes with anything new at or after log position `since`, newest first (#44). */
426 /** Changes active since a log position, newest first; `older` is set when more come before the page (ask again with `before`). */
427 changes(
428 since: number,
429 limit = 50,
430 before?: number,
431 ): Promise<{ since: number; next: number; changes: readonly ChangeAnswer[]; older?: number }> {
432 return this.json("GET", `/changes?${query({ since, limit, before })}`);
433 }
435 /** A call to the Issues Worker (#54), with the same token. */
436 #issues<T>(method: "GET" | "POST", path: string, body?: unknown): Promise<T> {
437 if (this.issuesServer === undefined)
review27Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)Compare438 throw new ApiError(`${this.config.server} has no Issues Worker beside it; ABSO_ISSUES_SERVER names one`);
init0Start the project439 return this.json(method, path, body, this.issuesServer);
440 }
pinch89abso reply N, abso ask N and abso asked name a server without ask threads instead of answering its bare 404.Compare442 /** An ask-thread call, with a server from before ask threads named as that rather than a bare 404. */
443 async #threads<T>(call: Promise<T>): Promise<T> {
444 try {
445 return await call;
446 } catch (err) {
447 if (err instanceof ApiError && err.status === 404 && /no such issues route/.test(err.message))
448 throw new ApiError(`${this.config.server} doesn't have ask threads yet`, 404);
449 throw err;
450 }
451 }
init0Start the project453 /** Issues, most recently updated first. */
454 issues(
455 q: { status?: string; agent?: string; parent?: number; open?: boolean; labels?: readonly string[] } = {},
456 ): Promise<{ issues: readonly IssueRow[] }> {
457 return this.#issues(
458 "GET",
459 `/issues?${query({ status: q.status, agent: q.agent, parent: q.parent, open: q.open ? 1 : undefined, label: q.labels && q.labels.length > 0 ? q.labels.join(",") : undefined })}`,
460 );
devops20Add abso search: find a project's issues by words or meaning `abso search "<words>" [--limit <N>]` lists the project's issues that match, best first, and is served as an MCP tool as well. - Each hit shows the issue, then where it matched: the title, the description, a comment, or "by meaning". - "#N" or "N" puts issue N first. - Where the server also searches by meaning, an issue worded unlike the search still turns up; the hit says so.Compare461 }
463 /**
464 * The project's issues matching q, best first: by its words and, where
465 * the server has it on, by what it means.
466 */
467 issueSearch(q: string, limit?: number): Promise<{ hits: readonly IssueSearchHit[] }> {
468 return this.#issues("GET", `/search?${query({ q, limit })}`);
init0Start the project469 }
471 /** Every label in use, with how many issues have it and how many of those are open. */
472 issueLabels(): Promise<{ labels: readonly { label: string; open: number; total: number }[] }> {
473 return this.#issues("GET", "/labels");
474 }
476 issue(id: number): Promise<IssuePage> {
477 return this.#issues("GET", `/issue/${id}`);
478 }
pinch72Asks become threads: abso reply <ask> "..." adds to an ask from either side, open or answered, and --question hands the turn to the asker until they reply. abso ask <N> shows one ask with its whole thread and whose turn it is; abso waiting --asked lists the asks you sent. An ack's note is the thread's first reply. reply is an MCP tool too. Needs an Issues server with the reply, ask and asked routes.Compare480 /** The asks this agent sent: the open ones, then the latest answered, each with its thread. */
481 asked(): Promise<{ asks: readonly (Ask & { title: string | null })[] }> {
pinch89abso reply N, abso ask N and abso asked name a server without ask threads instead of answering its bare 404.Compare482 return this.#threads(this.#issues("GET", this.agentPath("asked")));
pinch72Asks become threads: abso reply <ask> "..." adds to an ask from either side, open or answered, and --question hands the turn to the asker until they reply. abso ask <N> shows one ask with its whole thread and whose turn it is; abso waiting --asked lists the asks you sent. An ack's note is the thread's first reply. reply is an MCP tool too. Needs an Issues server with the reply, ask and asked routes.Compare483 }
485 /** One ask, open or closed, with its thread and who it waits on. */
486 askThread(id: number): Promise<{ ask: Ask & { title: string | null } }> {
pinch89abso reply N, abso ask N and abso asked name a server without ask threads instead of answering its bare 404.Compare487 return this.#threads(this.#issues("GET", `/ask/${id}`));
pinch72Asks become threads: abso reply <ask> "..." adds to an ask from either side, open or answered, and --question hands the turn to the asker until they reply. abso ask <N> shows one ask with its whole thread and whose turn it is; abso waiting --asked lists the asks you sent. An ack's note is the thread's first reply. reply is an MCP tool too. Needs an Issues server with the reply, ask and asked routes.Compare488 }
init0Start the project490 /** Open asks of someone (an agent, or person:<id>), soonest due first; every open ask without `of`. */
491 waiting(of?: string): Promise<{ asks: readonly (Ask & { title: string | null })[] }> {
492 return this.#issues("GET", `/waiting?${query({ of })}`);
493 }
495 /** This agent's open asks; the Worker marks each it lists for the first time as seen (abso issue 124). */
496 async waitingMine(): Promise<{ asks: readonly (Ask & { title: string | null })[] }> {
497 try {
498 return await this.#issues("GET", this.agentPath("waiting"));
499 } catch (err) {
500 // An Issues Worker from before 124 has no /a/:agent/ reads.
501 if (err instanceof ApiError && err.status === 404) return this.waiting(this.config.agent);
502 throw err;
503 }
504 }
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare506 issueOpen(body: DraftBody & { title: string; attachments?: string[] }): Promise<{ id: number; news?: IssueNews }> {
init0Start the project507 return this.#issues("POST", this.agentPath("issue"), body);
508 }
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare510 /** Uploads an image to the Issues Worker (abso issue 171): it checks the type by the bytes, strips metadata and answers its id. */
511 async attachmentUpload(bytes: Uint8Array, name: string): Promise<Attachment> {
512 if (this.issuesServer === undefined)
review27Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)Compare513 throw new ApiError(`${this.config.server} has no Issues Worker beside it; ABSO_ISSUES_SERVER names one`);
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare514 const path = this.agentPath("attachments");
515 let res: Response;
516 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare517 res = await this.send(this.url(path, this.issuesServer), {
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare518 method: "POST",
pinch54The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.Compare519 headers: { ...this.headers("application/octet-stream"), "x-abso-name": encodeURIComponent(name) },
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare520 body: bytes as Uint8Array<ArrayBuffer>,
521 signal: AbortSignal.timeout(Math.max(this.timeoutMs, 120_000)),
522 });
523 } catch (err) {
524 const e = err as Error;
525 throw new ApiError(
526 `could not reach ${this.issuesServer}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
527 );
528 }
529 const text = await res.text();
pinch15--attach says plainly when the Issues server doesn't take attachments yet A server from before attachments has no upload route. It answered 400 'the body is JSON', or 404, and the client printed that as it came, which told nobody what had happened. Now the client says the server doesn't take attachments yet, that the file wasn't sent and nothing was written, and to leave --attach off or link the image instead. A server that has the route but nowhere to keep files (501) gets the same message. A test checks the message and that no issue is opened.Compare530 // A server from before attachments has no upload route: it answers 404, or 400 because the body isn't JSON;
531 // one with the route but nowhere to keep files answers 501. Say so plainly, and that nothing was sent.
532 if (res.status === 404 || res.status === 501 || (res.status === 400 && /the body is JSON/.test(text)))
533 throw new ApiError(
534 `${this.issuesServer} doesn't take attachments yet, so ${name} wasn't sent and nothing was written. Leave --attach off, or link the image instead.`,
535 res.status,
536 );
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare537 if (!res.ok) throw new ApiError(`uploading ${name} answered ${res.status}: ${errorSentence(text)}`, res.status);
538 return JSON.parse(text) as Attachment;
pinch23abso issue <N> --copy-to <project>: copy an issue into another project, with its comments, answered asks and labels, each keeping its author and time. The Issues server reads the source issue itself; the client sends only which issue, and any cleaned texts. - --dry-run shows what the copy would make (title, how many comments and asks, which were edited, labels) and what's left behind. It writes nothing. - --clean <file> gives cleaned texts by source id, as JSON: {title, description, comments: [{id, text}], asks: [{id, question, answer}]}. A comment left out of a given list isn't copied. - --copy-to goes alone, so a copy is never half an edit. Copying into the project the issue is already in is refused before any call. - When a live server refuses the copy (copying out of a project there takes an owner of it), the message says --dry-run still works. - The MCP issue tool's clean input is a file too, so it's confined to the server's start folder like attach. Tests: client/test/issues.test.ts, against a stand-in Issues server. The run --parallel test that sometimes times out under a full run passed when rerun.Compare539 }
541 /**
542 * Copies issue `body.issue` of this project into project `to`, keeping
543 * authors and times: the Issues server reads the source itself, and only
544 * texts may be given cleaned. A dry run answers the plan and writes nothing.
545 */
546 issueCopy(to: string, body: CopyBody & { dryRun?: boolean }): Promise<CopyAnswer> {
547 const there = new Api({ ...this.config, project: to }, this.timeoutMs);
548 there.issuesServer = this.issuesServer;
549 return there.#issues("POST", there.agentPath("copy"), body);
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare550 }
552 /** Where an attachment is served. */
553 attachmentUrl(id: string): string {
554 return this.url(`/attachments/${id}`, this.issuesServer);
555 }
pinch29Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.Compare556
557 /** An attachment's bytes, or with `source` the svg it was drawn from; refused past `max` bytes. */
558 async attachmentBytes(id: string, source: boolean, max: number): Promise<Uint8Array> {
559 if (this.issuesServer === undefined)
560 throw new ApiError(`${this.config.server} has no Issues Worker beside it; ABSO_ISSUES_SERVER names one`);
561 const url = `${this.attachmentUrl(id)}${source ? "/source" : ""}`;
562 let res: Response;
563 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare564 res = await this.send(url, {
pinch29Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.Compare565 headers: this.headers(),
566 signal: AbortSignal.timeout(Math.max(this.timeoutMs, 120_000)),
567 });
568 } catch (err) {
569 const e = err as Error;
570 throw new ApiError(
571 `could not reach ${this.issuesServer}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
572 );
573 }
574 if (!res.ok) throw new ApiError(`${url} answered ${res.status}: ${errorSentence(await res.text())}`, res.status);
575 const bytes = new Uint8Array(await res.arrayBuffer());
576 if (bytes.length > max) throw new ApiError(`${url} sent ${bytes.length} bytes, more than an attachment may be`);
577 return bytes;
578 }
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare579
init0Start the project580 /** An edit (abso issue 3): it tells the issue's watchers, and `also`, unless `notify` is false. null clears a parent or Agent. */
581 issueEdit(
582 id: number,
583 body: {
584 title?: string;
585 description?: string;
586 parent?: number | null;
587 agent?: string | null;
588 blockedBy?: number[];
589 notify?: boolean;
590 also?: string[];
591 addLabels?: string[];
592 removeLabels?: string[];
593 },
594 ): Promise<{ edit: number; notified: readonly string[]; news?: IssueNews }> {
595 return this.#issues("POST", this.agentPath(`issue/${id}/edit`), body);
596 }
pinch5abso issue new and abso issue N --comment take --attach <file,file> (abso issue 171). Each file goes up to the Issues Worker first (POST /p/:project/a/:agent/attachments, the bytes as the body and the name URI-encoded in X-Avcs-Name), and the write carries the ids the uploads answered. Nothing is sent if a file is missing or over 10 MB. --attach anywhere else is refused. The issue's page lists each attachment under the issue or comment carrying it: id, name, size and its link. The wire types gain Attachment and attachments?. MCP's issue tool takes attach too, since its parameters come from the flags. The server side is abso 621 (off until Cloud binds the bucket). Tests: client/test/attach.test.ts, against a stand-in Issues server. Checked: biome ci, npm run check (698 pass).Compare598 issueComment(
599 id: number,
600 text: string,
601 objection = false,
602 attachments: readonly string[] = [],
603 ): Promise<{ id: number; news?: IssueNews }> {
604 return this.#issues("POST", this.agentPath(`issue/${id}/comment`), {
605 text,
606 ...(objection ? { objection } : {}),
607 ...(attachments.length > 0 ? { attachments } : {}),
608 });
init0Start the project609 }
611 issueDrop(id: number): Promise<{ news?: IssueNews }> {
612 return this.#issues("POST", this.agentPath(`issue/${id}/drop`), {});
613 }
615 /** Opens a dropped issue again (abso issue 104). */
616 issueReopen(id: number): Promise<{ news?: IssueNews }> {
617 return this.#issues("POST", this.agentPath(`issue/${id}/reopen`), {});
618 }
620 /** Marks an issue done by hand (abso issue 38). `version` is the publish that did it, when there is one. */
621 issueDone(id: number, version: number | null): Promise<{ news?: IssueNews }> {
622 return this.#issues("POST", this.agentPath(`issue/${id}/done`), { ...(version !== null ? { version } : {}) });
623 }
625 /** This agent's drafts (abso issue 3): its own, with no number and no news, newest first. */
626 drafts(): Promise<{ drafts: readonly Draft[] }> {
627 return this.#issues("GET", this.agentPath("drafts"));
628 }
630 /** Saves a draft, new or (with id) over one of this agent's: the body replaces the draft's. */
631 saveDraft(body: DraftBody & { id?: number }): Promise<{ id: number }> {
632 return this.#issues("POST", this.agentPath("draft"), body);
633 }
635 /** Opens a draft as an issue, `body`'s fields over the draft's, and deletes the draft. */
636 openDraft(id: number, body: DraftBody = {}): Promise<{ id: number; news?: IssueNews }> {
637 return this.#issues("POST", this.agentPath(`draft/${id}/open`), body);
638 }
640 deleteDraft(id: number): Promise<{ ok: boolean }> {
641 return this.#issues("POST", this.agentPath(`draft/${id}/delete`), {});
642 }
644 ask(body: {
645 issue?: number;
646 of: string;
647 question: string;
648 review?: boolean;
649 kind?: "question" | "task";
650 due?: string;
651 blocks?: number[];
652 options?: string[];
pinch35Client: files on asks and answers. abso ask and abso answer take --attach (uploaded first, as on issues; not with --withdraw); an ask lists its question's files under it and its answer's under the answer; abso issue N --save-attachments takes them too. An Issues server from before asks carried files keeps the words and drops the files: abso says so (notKept in --json) instead of losing them quietly. Wire: Ask.attachments and answer.attachments, optional. Client tests 286/286, tsc and biome clean.Compare653 attachments?: string[];
654 }): Promise<{ id: number; news?: IssueNews; attachments?: string[] }> {
init0Start the project655 return this.#issues("POST", this.agentPath("ask"), body);
656 }
658 answer(
659 id: number,
pinch35Client: files on asks and answers. abso ask and abso answer take --attach (uploaded first, as on issues; not with --withdraw); an ask lists its question's files under it and its answer's under the answer; abso issue N --save-attachments takes them too. An Issues server from before asks carried files keeps the words and drops the files: abso says so (notKept in --json) instead of losing them quietly. Wire: Ask.attachments and answer.attachments, optional. Client tests 286/286, tsc and biome clean.Compare660 body: { words?: string; option?: number | string; note?: string; done?: boolean; attachments?: string[] },
init0Start the project661 ): Promise<{ ask: Ask; news?: IssueNews }> {
662 return this.#issues("POST", this.agentPath(`answer/${id}`), body);
663 }
infra-split14An asker can take back an ask: abso ask --withdraw <ask> [--note "why"] An ask that later decisions have overtaken used to sit in the asked person's waiting list for good. Only they could answer it, and "none of these" wasn't an option. Now the one who asked can withdraw it. - `abso ask --withdraw <ask> [--note "why"]` sends one call to the server's withdraw route. It's refused before any call when mixed with a question or the other ask flags. `--note-file` reads the note from a file or stdin, like every text flag. - A withdrawn ask closes the way an answered one does: it leaves the waiting list, and it stops holding its issue at Blocked. The ask keeps its question. The asker's note is kept as why, and the one asked hears it. - Ask gains `outcome?: "withdrawn"`. Older servers leave it out. The asks list and an issue's page show "withdrawn by <asker>" and the note, instead of "answered by". - The server side of the route comes with the hosted Issues service. Until it's there, the call answers with that server's error. Tests: the new usage mistakes, and the single POST to the asker's own route. Checked: npx biome ci . and npm run check exit 0 (704 pass, 1 skipped).Compare664
pinch53abso ack <ask> ["note"]: the one asked says they have an ask and will answer later. The ask stays open and keeps blocking; abso issue shows it as acknowledged with the note, and the asker hears it. The Ask wire type gains ack, the API client gains ack(), and the skill mentions the command.Compare665 /** Acknowledges an ask of this agent without answering it: the asker hears it, and the ask stays open. */
666 ack(id: number, body: { note?: string }): Promise<{ ask: Ask; news?: IssueNews }> {
667 return this.#issues("POST", this.agentPath(`ack/${id}`), body);
pinch72Asks become threads: abso reply <ask> "..." adds to an ask from either side, open or answered, and --question hands the turn to the asker until they reply. abso ask <N> shows one ask with its whole thread and whose turn it is; abso waiting --asked lists the asks you sent. An ack's note is the thread's first reply. reply is an MCP tool too. Needs an Issues server with the reply, ask and asked routes.Compare668 }
670 /** Adds to an ask's thread, as its asker or the one asked; the other side hears it, and the ask stays as it is. */
671 reply(id: number, body: { text: string; question?: boolean }): Promise<{ ask: Ask; news?: IssueNews }> {
pinch89abso reply N, abso ask N and abso asked name a server without ask threads instead of answering its bare 404.Compare672 return this.#threads(this.#issues("POST", this.agentPath(`reply/${id}`), body));
pinch53abso ack <ask> ["note"]: the one asked says they have an ask and will answer later. The ask stays open and keeps blocking; abso issue shows it as acknowledged with the note, and the asker hears it. The Ask wire type gains ack, the API client gains ack(), and the skill mentions the command.Compare673 }
infra-split14An asker can take back an ask: abso ask --withdraw <ask> [--note "why"] An ask that later decisions have overtaken used to sit in the asked person's waiting list for good. Only they could answer it, and "none of these" wasn't an option. Now the one who asked can withdraw it. - `abso ask --withdraw <ask> [--note "why"]` sends one call to the server's withdraw route. It's refused before any call when mixed with a question or the other ask flags. `--note-file` reads the note from a file or stdin, like every text flag. - A withdrawn ask closes the way an answered one does: it leaves the waiting list, and it stops holding its issue at Blocked. The ask keeps its question. The asker's note is kept as why, and the one asked hears it. - Ask gains `outcome?: "withdrawn"`. Older servers leave it out. The asks list and an issue's page show "withdrawn by <asker>" and the note, instead of "answered by". - The server side of the route comes with the hosted Issues service. Until it's there, the call answers with that server's error. Tests: the new usage mistakes, and the single POST to the asker's own route. Checked: npx biome ci . and npm run check exit 0 (704 pass, 1 skipped).Compare675 /** Takes back an ask this agent made, with a note on why; the one asked hears it. */
676 withdraw(id: number, body: { note?: string }): Promise<{ ask: Ask; news?: IssueNews }> {
677 return this.#issues("POST", this.agentPath(`withdraw/${id}`), body);
678 }
init0Start the project679
680 /** Notes on lines (#44), by file or change; open ones only with `open`. */
681 notes(q: { file?: string; change?: number; open?: boolean } = {}): Promise<{ notes: readonly NoteAnswer[] }> {
682 return this.json("GET", `/notes?${query({ file: q.file, change: q.change, open: q.open ? 1 : undefined })}`);
683 }
685 note(body: NoteBody): Promise<{ id: number; change: number | null; lines: readonly [number, number] }> {
686 return this.json("POST", this.agentPath("note"), body);
687 }
689 noteClose(id: number, how: "resolved" | "withdrawn"): Promise<unknown> {
690 return this.json("POST", this.agentPath("note-close"), { id, how });
691 }
693 /** The merge queue now (#39). */
694 queueState(): Promise<QueueState> {
695 return this.json("GET", "/queue");
696 }
698 /** The project's visibility (abso issue 152): public or private. */
699 visibility(): Promise<{ project: string; visibility: "public" | "private" }> {
700 return this.json("GET", "/visibility");
701 }
703 /** Switch the project's visibility (abso issue 140): an owner's key, or the shared token on staging. */
704 setVisibility(v: "public" | "private"): Promise<{ project: string; visibility: "public" | "private" }> {
705 return this.json("POST", `/visibility?visibility=${v}`, {});
706 }
708 /** Take back this agent's queued publishes (#39); refused while one is being checked. */
709 unqueue(): Promise<{ pulled: readonly number[] }> {
710 return this.json("POST", this.agentPath("unqueue"), {});
711 }
713 /**
714 * Sync; a folder following a label goes to the newest version with that label.
715 * With `full`, the answer holds every file in the agent's view, as a first sync's does,
716 * not only what changed since its last sync (#37: a join for an agent the server knew).
717 */
718 sync(options: { full?: boolean } = {}): Promise<SyncAnswer> {
719 return this.json("POST", this.agentPath("sync"), {
720 ...(this.config.follow ? { label: this.config.follow } : {}),
721 ...(options.full ? { full: true } : {}),
722 });
723 }
725 /** Take published versions back out of shared (with the versions that build on them, when asked). */
726 drop(versions: readonly number[], message: string, withDependents = false): Promise<DropAnswer> {
727 return this.json("POST", this.agentPath("drop"), {
728 versions,
729 message,
730 ...(withDependents ? { withDependents: true } : {}),
731 });
732 }
734 /** Take some versions of a named draft into shared, as one version. */
735 pluck(draft: string, versions: readonly number[], message: string, withDependencies = false): Promise<PluckAnswer> {
736 return this.json("POST", this.agentPath("pluck"), {
737 draft,
738 versions,
739 message,
740 ...(withDependencies ? { withDependencies: true } : {}),
741 });
742 }
744 /** Correct the message of this agent's newest publish in its space. */
745 amend(message: string): Promise<{ version: number; draft: string | null; message: string; was: string }> {
746 return this.json("POST", this.agentPath("amend"), { message });
747 }
749 /** Put a label on a version of shared (the newest by default), or take it off. */
750 label(
751 name: string,
752 version?: number,
753 remove = false,
754 ): Promise<{ name: string; version: number; versions: readonly number[] }> {
755 return this.json("POST", this.agentPath("label"), {
756 name,
757 ...(version === undefined ? {} : { version }),
758 ...(remove ? { remove: true } : {}),
759 });
760 }
762 labels(): Promise<{ labels: Readonly<Record<string, readonly number[]>> }> {
763 return this.json("GET", "/labels");
764 }
766 status(): Promise<StatusAnswer> {
767 return this.json("GET", "/status");
768 }
770 /** The status and the paths in the agent's view, in one trip (abso issue 80). */
771 async statusAndFiles(): Promise<StatusAnswer & { files: FilesAnswer | undefined }> {
772 try {
773 return await this.json("GET", this.agentPath("status"));
774 } catch (err) {
775 // A server from before it has no /a/:agent/status; the listing itself is from #37.
776 if (!(err instanceof ApiError && err.status === 404)) throw err;
777 }
778 const status = await this.status();
779 return { ...status, files: await this.viewFiles().catch(() => undefined) };
780 }
782 /** CI's state (#39), or one version's job. */
783 ci(): Promise<CiStatus>;
784 ci(version: number): Promise<CiJob>;
785 ci(version?: number): Promise<CiStatus | CiJob> {
786 return this.json("GET", version === undefined ? "/ci" : `/ci?${query({ version })}`);
787 }
infra-pipeline85abso pipeline runs: list a project's pipeline runs, show one run's jobs (state, why each stopped, exit, time, an npm or deploy job's phase), and print a job's log with --log <pipeline.job>Compare789 /** The project's pipeline runs, newest first; one run with its jobs; or one job's log (`log` is pipeline.job). */
790 pipelineRuns(run?: number, log?: string): Promise<unknown> {
791 return this.json("GET", run === undefined ? "/pipelines" : `/pipelines?${query({ run, log })}`);
792 }
init0Start the project794 /** Ends every /latest link handed out so far; answers CI's state with the new link. */
795 ciRevoke(): Promise<CiStatus> {
796 return this.json("POST", "/ci/revoke", {});
797 }
799 /** Count versions up to `through` as seen by CI and end any red or bisect, so an import's history isn't checked (#56). */
800 ciSkip(through: number): Promise<unknown> {
801 return this.json("POST", "/ci/skip", { through });
802 }
804 /** Move to a named draft (null: shared). With carry, the current unpublished changes start a new draft. */
805 switchDraft(name: string | null, carry = false): Promise<SwitchAnswer> {
806 return this.json("POST", this.agentPath("draft"), { name, ...(carry ? { carry: true } : {}) });
807 }
809 /** Land never queues: with the merge queue on, the server refuses it (#39). */
810 land(message: string): Promise<Exclude<PublishAnswer, { queued: number }>> {
pinch26Publish and log fixes, and a flaky test removed. - A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed. - abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short. - The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET). Check: 722 pass, 0 fail.Compare811 return this.json("POST", this.agentPath("land"), { message }, undefined, PUBLISH_TIMEOUT_MS);
init0Start the project812 }
814 draftSync(): Promise<DraftSyncAnswer> {
815 return this.json("POST", this.agentPath("draft-sync"), {});
816 }
818 blame(file: string, from?: number, to?: number, version?: number, view: View = {}): Promise<BlameAnswer> {
819 return this.json("GET", `/blame?${query({ file, from, to, version, ...view })}`);
820 }
822 /** The paths in the agent's view: what its folder should hold (#37). */
823 viewFiles(): Promise<FilesAnswer> {
824 return this.json("GET", this.agentPath("files"));
825 }
827 /** The paths in shared, or a named draft, at a version (the newest by default). */
828 filesAt(draft: string | null, version?: number): Promise<FilesAnswer> {
829 return this.json("GET", `/files?${query({ draft, version })}`);
830 }
832 /** The versions of a space, newest first; with `path`, only those that changed it. */
pinch26Publish and log fixes, and a flaky test removed. - A publish or a land now waits up to 150 s for the server's answer, not 30 s. The server may work on one request for up to 2 minutes, so a slow merge was reported as failed and then landed. - abso log reads any length of history. The server sends at most 200 versions a page, and the client now follows its pages: -n 2000 gives 2000, and --since or a folder reads up to 1000. abso log --before <version> starts below that version. The end of the list names the --before for the next older ones, and a filtered read says when it stopped short. - The test 'sends one run, and takes each command as one quoted word' is removed: it failed on Windows about half the time. The stand-in server the client tests use no longer closes idle kept-alive connections, which other tests also tripped on under load (ECONNRESET). Check: 722 pass, 0 fail.Compare833 /**
834 * The versions newest first, below `before` when it's given. The server
835 * sends at most LOG_PAGE at a time, so a longer log is read page by page,
836 * following each page's next. `next` on the answer says older ones are left.
837 */
838 async log(where: Where, limit?: number, path?: string, before?: number): Promise<LogAnswer> {
839 let page = await this.#logPage(where, limit === undefined ? undefined : Math.min(limit, LOG_PAGE), path, before);
840 const versions = [...page.versions];
841 while (limit !== undefined && versions.length < limit && page.next !== undefined) {
842 page = await this.#logPage(where, Math.min(limit - versions.length, LOG_PAGE), path, page.next);
843 versions.push(...page.versions);
844 }
845 const { next, ...rest } = page;
846 return { ...rest, versions, ...(next !== undefined ? { next } : {}) };
847 }
849 #logPage(
850 where: Where,
851 limit: number | undefined,
852 path: string | undefined,
853 before: number | undefined,
854 ): Promise<LogAnswer> {
855 return this.json("GET", `/log?${query({ ...where, limit, path, before })}`);
init0Start the project856 }
858 show(version: number, where: Where): Promise<ShowAnswer> {
859 return this.json("GET", `/show?${query({ version, ...where })}`);
860 }
862 fileAt(path: string, version: number, where: Where): Promise<{ path: string; version: number; text: string | null }> {
863 return this.json("GET", `/file?${query({ path, version, ...where })}`);
864 }
866 compare(from: number, to: number, where: Where): Promise<{ from: number; to: number; files: readonly FileChange[] }> {
867 return this.json("GET", `/compare?${query({ from, to, ...where })}`);
868 }
870 /** A message to the project's other agents (or those named), delivered once as news. */
871 starting(
872 text: string | null,
873 files?: readonly string[],
874 options: { issue?: number; done?: boolean } = {},
875 ): Promise<{
876 starting: { text: string; files: readonly string[]; time: number; issue?: number } | null;
877 overlaps: readonly Overlap[];
878 }> {
879 return this.json("POST", this.agentPath("starting"), {
880 text,
881 ...(files && files.length > 0 ? { files } : {}),
882 ...(options.issue !== undefined ? { issue: options.issue } : {}),
883 ...(options.done ? { done: true } : {}),
884 });
885 }
887 announce(text: string, to?: readonly string[]): Promise<{ id: number; to: readonly string[] }> {
888 return this.json("POST", this.agentPath("announce"), { text, ...(to ? { to } : {}) });
889 }
891 /** The news waiting for this agent, handed over once. */
892 news(): Promise<{ news: News; items?: readonly { readonly text: string; readonly at: number | null }[] }> {
893 return this.json("POST", this.agentPath("news"), {});
894 }
896 /** This agent's unpublished changes, file by file. */
897 diff(): Promise<DiffAnswer> {
898 return this.json("POST", this.agentPath("diff"), {});
899 }
pinch52abso diff --agent <name>: review another agent's unpublished changes Reviewing a teammate's work before it's published had no command: abso diff showed only your own draft, and abso status names files but not lines. Reviewers read the other agent's folder on disk, which only works on a shared machine and shows their disk, not what they recorded. abso diff --agent alice now prints alice's recorded, unpublished changes line by line, the way abso diff prints yours: "alice's recorded, unpublished changes in shared (on version 12): 2 files, 5 lines added, 1 removed." Paths narrow it as usual. It reads what the server holds, the same route the website's drafts use, so it records nothing and changes nothing. An agent with no changes says so; a name the project doesn't know is refused by the server. --agent doesn't go with two versions or --draft. The test server answers GET /p/:project/diff?agent= as the Worker does. Tested in client.test.ts.Compare900
901 /** Another agent's recorded, unpublished changes, file by file: read only, as the website's drafts show them. */
902 diffOf(agent: string): Promise<DiffAnswer> {
903 return this.json("GET", `/diff?${query({ agent })}`);
904 }
init0Start the project905
906 /** Discard this agent's unpublished changes to `files` (null: all of them). */
907 restore(files: readonly string[] | null): Promise<RestoreAnswer> {
908 return this.json("POST", this.agentPath("restore"), files === null ? { all: true } : { files });
909 }
911 why(file: string, line: number, view: View = {}): Promise<WhyAnswer> {
912 return this.json("GET", `/why?${query({ file, line, ...view })}`);
913 }
915 where(): Promise<WhereAnswer> {
916 return this.json("GET", "/where");
917 }
919 /**
920 * Send the folder as a tar.gz and run a command in the agent's box. Output
921 * goes to `io.out` as it arrives, and the box's stderr to `io.err` (the
922 * server keeps them apart when asked; an older one sends both as out).
923 * Answers the command's exit code.
924 *
925 * When the stream breaks before the exit line and the server gave the run
926 * an id, the run goes on in the box: this reconnects to it and carries on
927 * from the last output printed, so nothing is lost or printed twice. The
928 * command itself is never sent twice.
929 */
930 async run(command: string, tarGz: Uint8Array<ArrayBuffer>, io: RunIO): Promise<number> {
931 const res = await postRun(this, command, tarGz, io.onRetry, io.replace, io.fresh);
pinch54The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.Compare932 // X-Abso-Box: cold means the box started for this run; X-Abso-Prep says whether it started from the prep (#37).
933 io.onBox?.(res.headers.get("x-abso-box") === "cold", res.headers.get("x-abso-prep") ?? undefined);
934 return follow(this, res, res.headers.get("x-abso-run"), { at: 0, errAt: 0 }, io);
init0Start the project935 }
937 /**
938 * Start a run and answer its id without waiting: the job goes on in the box
939 * after this connection closes (abso run --detach; abso logs <id> follows it).
940 */
941 async startRun(
942 command: string,
943 tarGz: Uint8Array<ArrayBuffer>,
944 onRetry?: (why: string, attempt: number) => void,
945 replace = false,
946 ): Promise<string> {
947 const res = await postRun(this, command, tarGz, onRetry, replace);
pinch54The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.Compare948 const id = res.headers.get("x-abso-run");
init0Start the project949 if (id === null) {
950 // No id: the box failed before the job started ({"error"} in the body), or the server can't detach.
951 await consumeRun(res, { out: () => {} }, { at: 0, errAt: 0 });
952 throw new ApiError("this server gives runs no id, so a run can't be detached");
953 }
954 await res.body?.cancel();
955 return id;
956 }
958 /** A run's output from its start, for as long as the box keeps it, until it ends (abso logs). Answers its exit code. */
959 async logs(id: string, io: RunIO): Promise<number> {
960 let res: Response;
961 try {
pinch88Every request a folder's Api makes goes through one send(): a folder that reads signed out sends only GETs and follows no redirect on every path, box runs and serve included.Compare962 res = await this.send(followUrl(this, id, { at: 0, errAt: 0 }), { headers: this.headers() });
init0Start the project963 } catch (err) {
964 const e = err as Error;
965 throw new ApiError(
966 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
967 );
968 }
969 if (res.status === 404) throw new ApiError(`no run ${id} in this box: ${errorSentence(await res.text())}`, 404);
970 if (!res.ok || res.body === null)
971 throw new ApiError(`logs answered ${res.status}: ${errorSentence(await res.text())}`, res.status);
972 return follow(this, res, id, { at: 0, errAt: 0 }, io);
973 }