- MCP
- blame on this site's /mcp
- CLI
- abso blame client/src/api.ts --version 201 --json
- JSON
- /christopher/abso-core/blame/client/src/api.ts?version=201&format=json
991 linesFirst import 71% · pinch 23% · devops 2% · codex-prose-authorship-1 1% · candidates 1% · codex-capacity-chair 1% · Last change whytrail in version 193,
991 lines from 22 changes in 22 versions.
2// except `run`, which sends a tar.gz and reads the answer as a stream of JSON
3// lines (box-run.ts).
codex-capacity-chair162Add reviewed disk-first history and indexed graph storage for core issue 16; retain runtime activation gateCompare5import { randomUUID } from "node:crypto";
7import type {
8 ChangeAnswer,
9 DraftSyncAnswer,
10 EditAnswer,
11 EditBody,
12 News,
13 NoteAnswer,
14 NoteBody,
15 PublishAnswer,
16 RecordAnswer,
17 StatusAnswer,
18 SwitchAnswer,
19 SyncAnswer,
20} from "./api-answers.ts";
21import { ApiError, errorSentence, neverSent } from "./api-error.ts";
22import {
23 boxQuery,
24 consumeRun,
25 follow,
26 followUrl,
27 type PrepAnswer,
28 postRun,
29 RECONNECT_DELAYS_MS,
30 RUN_START_RETRY_MS,
31 type RunIO,
32 type RunKind,
33 type ServeAnswer,
34} from "./box-run.ts";
35import type { CiJob, CiStatus, QueueState } from "./ci-answers.ts";
36import { clientVersion } from "./client-version.ts";
37import type { Config } from "./config.ts";
38import type {
39 BlameAnswer,
40 DiffAnswer,
41 DropAnswer,
42 FileChange,
43 FilesAnswer,
44 LogAnswer,
45 Overlap,
46 PluckAnswer,
47 RestoreAnswer,
48 ShowAnswer,
49 View,
50 Where,
51 WhereAnswer,
52 WhyAnswer,
candidates186Read a version of shared without some earlier versions: abso show <N> --without A,B shows what differs and abso export <dir> --version N --without A,B writes the files. The server's GET without?version=&versions= checks the set left exactly as asked: when a version it keeps builds on one left out, it refuses with that chain, the files and the wider set that works, and never widens it. Atoms keep their ids and authors; shared and its log don't change; the same ask gives the same tree hash.Compare53 WithoutAnswer,
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.Compare55import type {
56 Ask,
57 Attachment,
58 Draft,
59 DraftBody,
60 News as IssueNews,
61 IssuePage,
62 IssueRow,
63 IssueSearchHit,
64} from "./issues-wire.ts";
67export * from "./api-answers.ts";
68export { ApiError, neverSent } from "./api-error.ts";
69export {
70 type PrepAnswer,
71 RECONNECT_DELAYS_MS,
72 RUN_START_RETRY_MS,
73 type RunIO,
74 type RunKind,
75 type ServeAnswer,
76} from "./box-run.ts";
77export * from "./ci-answers.ts";
78export * 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.Compare79export type { Ask, Attachment, Draft, DraftBody, IssueNews, IssuePage, IssueRow, IssueSearchHit };
81/**
82 * How long a call may take: the base, plus 1 s for each 100 KB it sends
83 * (abso issue 34: a sync that recorded 191 reformatted files first ran out of
84 * its 30 s while the server was still taking them in).
85 */
86export function timeoutFor(baseMs: number, sent: string | undefined): number {
87 return sent === undefined ? baseMs : baseMs + Math.floor(Buffer.byteLength(sent) / 100_000) * 1000;
88}
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.Compare90/**
91 * How long a publish or a land may take before the client stops waiting: the
92 * server gives one request up to 2 minutes of work, so a small body can still
93 * take that long (a large merge). Waiting less reported publishes as failed
94 * that went on to land.
95 */
96export const PUBLISH_TIMEOUT_MS = 150_000;
98/** The most versions the server's log sends at once. */
99export const LOG_PAGE = 200;
init0Start the project101/** A query string from the values that are set (null and undefined are left out). */
102function query(values: Record<string, string | number | null | undefined>): URLSearchParams {
103 const q = new URLSearchParams();
104 for (const [k, v] of Object.entries(values)) if (v !== null && v !== undefined) q.set(k, String(v));
105 return q;
106}
108export function newsLines(news: News): string[] {
109 if (news === undefined || news === null) return [];
110 return (typeof news === "string" ? [news] : [...news]).filter((s) => typeof s === "string" && s.trim() !== "");
111}
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.Compare113/** An issue copy's request: the source, and any texts given cleaned, by their source ids. */
114export interface CopyBody {
115 from: string;
116 issue: number;
117 title?: string;
118 description?: string;
119 comments?: { id: number; text?: string }[];
120 asks?: { id: number; question?: string; answer?: string }[];
121}
123/** What a copy writes, as a dry run answers it. */
124export interface CopyPlan {
125 from: { project: string; issue: number };
126 title: string;
127 edited: ("title" | "description")[];
128 labels: string[];
129 closed: { how: "done" | "dropped" } | null;
130 comments: { edited: boolean }[];
131 asks: { edited: boolean }[];
132 skipped: { comments: number[]; asks: number[] };
133}
135export type CopyAnswer =
136 | { dryRun: true; plan: CopyPlan }
137 | { ok: true; id: number; from: { project: string; issue: number }; skipped: { comments: number[]; asks: number[] } };
140 readonly config: Config;
141 readonly timeoutMs: number;
143 /** Waits between tries when a run's stream breaks; tests shorten them. */
144 readonly reconnectDelaysMs: readonly number[];
145 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)Compare146 /** Another box of this agent for run, logs and fetch (--box or ABSO_BOX, #37); undefined is its own box. */
149 constructor(
150 config: Config,
151 timeoutMs = 30_000,
152 reconnectDelaysMs: readonly number[] = RECONNECT_DELAYS_MS,
153 startRetryDelaysMs: readonly number[] = RUN_START_RETRY_MS,
154 ) {
155 this.config = config;
156 this.timeoutMs = timeoutMs;
157 this.reconnectDelaysMs = reconnectDelaysMs;
158 this.startRetryDelaysMs = startRetryDelaysMs;
159 }
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.Compare161 /** What a box run is for, for the server's box-run records (#39): X-Abso-Kind on POST /run. */
164 /** The Issues Worker (#54) this folder's issues calls go to; set by the issues commands (issues.ts). */
165 issuesServer: string | undefined;
167 url(path: string, server = this.config.server): string {
168 return `${server.replace(/\/+$/, "")}/p/${encodeURIComponent(this.config.project)}${path}`;
169 }
171 agentPath(action: string): string {
172 return `/a/${encodeURIComponent(this.config.agent)}/${action}`;
173 }
175 headers(contentType?: string): Record<string, string> {
176 return {
177 // 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.Compare178 "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.Compare179 ...(this.config.token && !this.config.visitor ? { authorization: `Bearer ${this.config.token}` } : {}),
181 };
182 }
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.Compare184 /**
185 * Every request this Api makes goes through here. In a visitor folder it never sends anything but a GET,
186 * and follows no redirect, so nothing it sends goes anywhere it didn't name (headers() adds no sign-in).
187 */
188 send(url: string, init: RequestInit = {}): Promise<Response> {
189 if (!this.config.visitor) return fetch(url, init);
190 if ((init.method ?? "GET") !== "GET")
191 return Promise.reject(new ApiError("a folder that reads signed out sends only reads"));
192 return fetch(url, { ...init, redirect: "error" });
193 }
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.Compare195 async json<T>(
196 method: "GET" | "POST",
197 path: string,
198 body?: unknown,
199 server = this.config.server,
200 atLeastMs = 0,
201 ): Promise<T> {
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.Compare203 if (this.config.visitor && method !== "GET")
204 throw new ApiError(`${path}: a folder that reads signed out sends only reads`);
codex-capacity-chair162Add reviewed disk-first history and indexed graph storage for core issue 16; retain runtime activation gateCompare206 const requestId = method === "POST" ? randomUUID() : undefined;
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.Compare207 const timeoutMs = Math.max(atLeastMs, timeoutFor(this.timeoutMs, sent));
init0Start the project208 // A connection that never opened is tried once more, IPv4 first (#37, GAME - UI/UX: one IPv6
209 // address timed out, and the same command went through seconds later). Nothing went out, so
210 // a POST is as safe to send again as a GET.
211 for (let attempt = 0; res === undefined; attempt++) {
212 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.Compare213 res = await this.send(this.url(path, server), {
codex-capacity-chair162Add reviewed disk-first history and indexed graph storage for core issue 16; retain runtime activation gateCompare215 headers: {
216 ...this.headers(sent === undefined ? undefined : "application/json"),
217 ...(requestId ? { "Idempotency-Key": requestId } : {}),
218 },
220 signal: AbortSignal.timeout(timeoutMs),
221 });
222 } catch (err) {
223 const e = err as Error;
224 const why =
225 e.name === "TimeoutError"
226 ? `no answer within ${timeoutMs} ms`
227 : ((e.cause as Error | undefined)?.message ?? e.message);
228 if (!neverSent(err)) throw new ApiError(`could not reach ${server}: ${why}`);
229 if (attempt >= 1) {
230 throw new ApiError(
231 `could not reach ${server}: ${why}. Tried twice, the second time IPv4 first; the connection never opened, so nothing reached the server`,
232 undefined,
233 true,
234 );
235 }
236 setDefaultResultOrder("ipv4first");
237 await new Promise((ok) => setTimeout(ok, 500));
238 }
239 }
codex-prose-authorship-1108Implement bounded sequential client recording for #606Compare240 let text: string;
241 try {
242 text = await res.text();
243 } catch (err) {
244 const reason = err instanceof Error ? err.message : String(err);
245 throw new ApiError(`${method} ${path} response body ended unexpectedly: ${reason}`, res.status);
246 }
init0Start the project247 // 409 is a refusal that says what to do (a drop took out lines your work builds on): print it as it is.
248 if (!res.ok)
249 throw new ApiError(
250 res.status === 409
251 ? `refused: ${errorSentence(text)}`
252 : `${method} ${path} answered ${res.status}: ${errorSentence(text)}`,
253 res.status,
254 );
255 try {
256 return JSON.parse(text) as T;
257 } catch {
258 throw new ApiError(
259 `${method} ${path} answered with something that isn't JSON: ${text.slice(0, 300)}`,
260 res.status,
261 );
262 }
263 }
265 init(
266 files: Record<string, string>,
267 modes: Modes = {},
268 blobs: Readonly<Record<string, string>> = {},
269 ): Promise<{ version: number; skipped?: readonly string[] }> {
270 return this.json("POST", "/init", {
271 files,
272 ...(Object.keys(modes).length > 0 ? { modes } : {}),
273 ...(Object.keys(blobs).length > 0 ? { blobs } : {}),
274 });
275 }
277 edit(body: EditBody): Promise<EditAnswer> {
278 return this.json("POST", this.agentPath("edit"), body);
279 }
281 record(
282 files: Record<string, string | null>,
283 extra: { session?: string; subagent?: string } = {},
284 modes: Modes = {},
285 blobs: Readonly<Record<string, string>> = {},
286 ): Promise<RecordAnswer> {
287 return this.json("POST", this.agentPath("record"), {
288 files,
289 ...(Object.keys(modes).length > 0 ? { modes } : {}),
290 ...(Object.keys(blobs).length > 0 ? { blobs } : {}),
291 ...extra,
292 });
293 }
295 /** Move a file in the draft (#49): its lines keep their ids. The way to change a file's case. */
296 move(from: string, to: string): Promise<{ ok: boolean; from: string; to: string; news?: News }> {
297 return this.json("POST", this.agentPath("move"), { from, to });
298 }
300 /** Upload a binary file's bytes under their sha256 (the server checks the hash). */
301 async putBlob(sha: string, bytes: Uint8Array): Promise<void> {
302 await this.bytes("PUT", `/blobs/${sha}`, bytes);
303 }
305 /** A preview of one version of shared at a stable URL (abso serve, #37); a build answers 422 with its output. */
306 async serve(version?: number, cmd?: string, out?: string): Promise<ServeAnswer> {
307 const q = new URLSearchParams({
308 ...(version !== undefined ? { version: String(version) } : {}),
309 ...(cmd ? { cmd } : {}),
310 ...(out ? { out } : {}),
311 });
312 let res: Response;
313 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.Compare314 res = await this.send(`${this.url("/serve")}?${q}`, {
316 headers: this.headers(),
317 signal: AbortSignal.timeout(20 * 60_000),
318 });
319 } catch (err) {
320 const e = err as Error;
321 throw new ApiError(
322 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
323 );
324 }
325 const text = await res.text();
326 if (!res.ok && res.status !== 422)
327 throw new ApiError(`serve answered ${res.status}: ${errorSentence(text)}`, res.status);
328 return JSON.parse(text) as ServeAnswer;
329 }
331 /** Runs a setup command on the folder in a fresh box and keeps the box as what it starts from (abso prep, #37). */
332 async prep(command: string, tarGz: Uint8Array<ArrayBuffer>): Promise<PrepAnswer> {
333 let res: Response;
334 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.Compare335 res = await this.send(
336 `${this.url(this.agentPath("prep"))}?cmd=${encodeURIComponent(command)}${boxQuery(this.box)}`,
337 {
338 method: "POST",
339 headers: this.headers("application/gzip"),
340 body: tarGz,
341 // A setup command can take minutes (npm ci, a browser download).
342 signal: AbortSignal.timeout(30 * 60_000),
343 },
344 );
346 const e = err as Error;
347 throw new ApiError(
348 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
349 );
350 }
351 const text = await res.text();
352 if (!res.ok) throw new ApiError(`prep answered ${res.status}: ${errorSentence(text)}`, res.status);
353 return JSON.parse(text) as PrepAnswer;
354 }
356 /** Forgets the box's prep: it starts from the plain image again. Answers whether it had one. */
357 async unprep(): Promise<boolean> {
358 let res: Response;
359 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.Compare360 res = await this.send(
init0Start the project361 `${this.url(this.agentPath("prep"))}${this.box ? `?box=${encodeURIComponent(this.box)}` : ""}`,
362 { method: "DELETE", headers: this.headers(), signal: AbortSignal.timeout(this.timeoutMs) },
363 );
364 } catch (err) {
365 const e = err as Error;
366 throw new ApiError(
367 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
368 );
369 }
370 const text = await res.text();
371 if (!res.ok) throw new ApiError(`prep answered ${res.status}: ${errorSentence(text)}`, res.status);
372 return (JSON.parse(text) as { forgot: boolean }).forgot;
373 }
375 /** A binary file's bytes by their sha256. */
376 /** 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. */
377 async boxFiles(glob: string): Promise<Uint8Array | null> {
378 try {
379 return await this.bytes(
380 "GET",
381 `${this.agentPath("box-files")}?${new URLSearchParams({ glob, ...(this.box ? { box: this.box } : {}) })}`,
382 );
383 } catch (err) {
384 if (err instanceof ApiError && err.status === 404) return null;
385 throw err;
386 }
387 }
389 getBlob(sha: string): Promise<Uint8Array> {
390 return this.bytes("GET", `/blobs/${sha}`);
391 }
393 async bytes(method: "GET" | "PUT", path: string, body?: Uint8Array): Promise<Uint8Array> {
394 let res: Response;
395 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.Compare396 res = await this.send(this.url(path), {
398 headers: this.headers(body === undefined ? undefined : "application/octet-stream"),
399 ...(body === undefined ? {} : { body: body as Uint8Array<ArrayBuffer> }),
400 signal: AbortSignal.timeout(Math.max(this.timeoutMs, 120_000)),
401 });
402 } catch (err) {
403 const e = err as Error;
404 throw new ApiError(
405 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
406 );
407 }
408 const data = new Uint8Array(await res.arrayBuffer());
409 if (!res.ok)
410 throw new ApiError(
411 `${method} ${path} answered ${res.status}: ${errorSentence(new TextDecoder().decode(data))}`,
412 res.status,
413 );
414 return data;
415 }
417 /** Make this agent a reader, or not (#37): a reader's edits, records and publishes are refused. */
418 reader(on: boolean): Promise<{ agent: string; reader: boolean }> {
419 return this.json("POST", this.agentPath("reader"), { reader: on });
420 }
422 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.Compare423 return this.json(
424 "POST",
425 this.agentPath("publish"),
426 { message, ...(asIs ? { asIs: true } : {}) },
427 undefined,
428 PUBLISH_TIMEOUT_MS,
429 );
432 /** One change (#44). */
433 change(id: number): Promise<ChangeAnswer> {
434 return this.json("GET", `/change/${id}`);
435 }
437 /** The changes with anything new at or after log position `since`, newest first (#44). */
438 /** Changes active since a log position, newest first; `older` is set when more come before the page (ask again with `before`). */
439 changes(
440 since: number,
441 limit = 50,
442 before?: number,
443 ): Promise<{ since: number; next: number; changes: readonly ChangeAnswer[]; older?: number }> {
444 return this.json("GET", `/changes?${query({ since, limit, before })}`);
445 }
447 /** A call to the Issues Worker (#54), with the same token. */
448 #issues<T>(method: "GET" | "POST", path: string, body?: unknown): Promise<T> {
449 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)Compare450 throw new ApiError(`${this.config.server} has no Issues Worker beside it; ABSO_ISSUES_SERVER names one`);
452 }
pinch89abso reply N, abso ask N and abso asked name a server without ask threads instead of answering its bare 404.Compare454 /** An ask-thread call, with a server from before ask threads named as that rather than a bare 404. */
455 async #threads<T>(call: Promise<T>): Promise<T> {
456 try {
457 return await call;
458 } catch (err) {
459 if (err instanceof ApiError && err.status === 404 && /no such issues route/.test(err.message))
460 throw new ApiError(`${this.config.server} doesn't have ask threads yet`, 404);
461 throw err;
462 }
463 }
466 issues(
467 q: { status?: string; agent?: string; parent?: number; open?: boolean; labels?: readonly string[] } = {},
468 ): Promise<{ issues: readonly IssueRow[] }> {
469 return this.#issues(
470 "GET",
471 `/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 })}`,
472 );
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.Compare473 }
475 /**
476 * The project's issues matching q, best first: by its words and, where
477 * the server has it on, by what it means.
478 */
479 issueSearch(q: string, limit?: number): Promise<{ hits: readonly IssueSearchHit[] }> {
480 return this.#issues("GET", `/search?${query({ q, limit })}`);
483 /** Every label in use, with how many issues have it and how many of those are open. */
484 issueLabels(): Promise<{ labels: readonly { label: string; open: number; total: number }[] }> {
485 return this.#issues("GET", "/labels");
486 }
488 issue(id: number): Promise<IssuePage> {
489 return this.#issues("GET", `/issue/${id}`);
490 }
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.Compare492 /** The asks this agent sent: the open ones, then the latest answered, each with its thread. */
493 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.Compare494 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.Compare495 }
497 /** One ask, open or closed, with its thread and who it waits on. */
498 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.Compare499 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.Compare500 }
init0Start the project502 /** Open asks of someone (an agent, or person:<id>), soonest due first; every open ask without `of`. */
503 waiting(of?: string): Promise<{ asks: readonly (Ask & { title: string | null })[] }> {
504 return this.#issues("GET", `/waiting?${query({ of })}`);
505 }
507 /** This agent's open asks; the Worker marks each it lists for the first time as seen (abso issue 124). */
508 async waitingMine(): Promise<{ asks: readonly (Ask & { title: string | null })[] }> {
509 try {
510 return await this.#issues("GET", this.agentPath("waiting"));
511 } catch (err) {
512 // An Issues Worker from before 124 has no /a/:agent/ reads.
513 if (err instanceof ApiError && err.status === 404) return this.waiting(this.config.agent);
514 throw err;
515 }
516 }
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 issueOpen(body: DraftBody & { title: string; attachments?: string[] }): Promise<{ id: number; news?: IssueNews }> {
520 }
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).Compare522 /** Uploads an image to the Issues Worker (abso issue 171): it checks the type by the bytes, strips metadata and answers its id. */
523 async attachmentUpload(bytes: Uint8Array, name: string): Promise<Attachment> {
524 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)Compare525 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).Compare526 const path = this.agentPath("attachments");
527 let res: Response;
528 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.Compare529 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).Compare530 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.Compare531 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).Compare532 body: bytes as Uint8Array<ArrayBuffer>,
533 signal: AbortSignal.timeout(Math.max(this.timeoutMs, 120_000)),
534 });
535 } catch (err) {
536 const e = err as Error;
537 throw new ApiError(
538 `could not reach ${this.issuesServer}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
539 );
540 }
541 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.Compare542 // A server from before attachments has no upload route: it answers 404, or 400 because the body isn't JSON;
543 // one with the route but nowhere to keep files answers 501. Say so plainly, and that nothing was sent.
544 if (res.status === 404 || res.status === 501 || (res.status === 400 && /the body is JSON/.test(text)))
545 throw new ApiError(
546 `${this.issuesServer} doesn't take attachments yet, so ${name} wasn't sent and nothing was written. Leave --attach off, or link the image instead.`,
547 res.status,
548 );
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).Compare549 if (!res.ok) throw new ApiError(`uploading ${name} answered ${res.status}: ${errorSentence(text)}`, res.status);
550 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.Compare551 }
553 /**
554 * Copies issue `body.issue` of this project into project `to`, keeping
555 * authors and times: the Issues server reads the source itself, and only
556 * texts may be given cleaned. A dry run answers the plan and writes nothing.
557 */
558 issueCopy(to: string, body: CopyBody & { dryRun?: boolean }): Promise<CopyAnswer> {
559 const there = new Api({ ...this.config, project: to }, this.timeoutMs);
560 there.issuesServer = this.issuesServer;
561 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).Compare562 }
564 /** Where an attachment is served. */
565 attachmentUrl(id: string): string {
566 return this.url(`/attachments/${id}`, this.issuesServer);
567 }
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.Compare568
569 /** An attachment's bytes, or with `source` the svg it was drawn from; refused past `max` bytes. */
570 async attachmentBytes(id: string, source: boolean, max: number): Promise<Uint8Array> {
571 if (this.issuesServer === undefined)
572 throw new ApiError(`${this.config.server} has no Issues Worker beside it; ABSO_ISSUES_SERVER names one`);
573 const url = `${this.attachmentUrl(id)}${source ? "/source" : ""}`;
574 let res: Response;
575 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.Compare576 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.Compare577 headers: this.headers(),
578 signal: AbortSignal.timeout(Math.max(this.timeoutMs, 120_000)),
579 });
580 } catch (err) {
581 const e = err as Error;
582 throw new ApiError(
583 `could not reach ${this.issuesServer}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
584 );
585 }
586 if (!res.ok) throw new ApiError(`${url} answered ${res.status}: ${errorSentence(await res.text())}`, res.status);
587 const bytes = new Uint8Array(await res.arrayBuffer());
588 if (bytes.length > max) throw new ApiError(`${url} sent ${bytes.length} bytes, more than an attachment may be`);
589 return bytes;
590 }
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).Compare591
init0Start the project592 /** An edit (abso issue 3): it tells the issue's watchers, and `also`, unless `notify` is false. null clears a parent or Agent. */
593 issueEdit(
594 id: number,
595 body: {
596 title?: string;
597 description?: string;
598 parent?: number | null;
599 agent?: string | null;
600 blockedBy?: number[];
601 notify?: boolean;
602 also?: string[];
603 addLabels?: string[];
604 removeLabels?: string[];
605 },
606 ): Promise<{ edit: number; notified: readonly string[]; news?: IssueNews }> {
607 return this.#issues("POST", this.agentPath(`issue/${id}/edit`), body);
608 }
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).Compare610 issueComment(
611 id: number,
612 text: string,
613 objection = false,
614 attachments: readonly string[] = [],
615 ): Promise<{ id: number; news?: IssueNews }> {
616 return this.#issues("POST", this.agentPath(`issue/${id}/comment`), {
617 text,
618 ...(objection ? { objection } : {}),
619 ...(attachments.length > 0 ? { attachments } : {}),
620 });
623 issueDrop(id: number): Promise<{ news?: IssueNews }> {
624 return this.#issues("POST", this.agentPath(`issue/${id}/drop`), {});
625 }
627 /** Opens a dropped issue again (abso issue 104). */
628 issueReopen(id: number): Promise<{ news?: IssueNews }> {
629 return this.#issues("POST", this.agentPath(`issue/${id}/reopen`), {});
630 }
632 /** Marks an issue done by hand (abso issue 38). `version` is the publish that did it, when there is one. */
633 issueDone(id: number, version: number | null): Promise<{ news?: IssueNews }> {
634 return this.#issues("POST", this.agentPath(`issue/${id}/done`), { ...(version !== null ? { version } : {}) });
635 }
637 /** This agent's drafts (abso issue 3): its own, with no number and no news, newest first. */
638 drafts(): Promise<{ drafts: readonly Draft[] }> {
639 return this.#issues("GET", this.agentPath("drafts"));
640 }
642 /** Saves a draft, new or (with id) over one of this agent's: the body replaces the draft's. */
643 saveDraft(body: DraftBody & { id?: number }): Promise<{ id: number }> {
644 return this.#issues("POST", this.agentPath("draft"), body);
645 }
647 /** Opens a draft as an issue, `body`'s fields over the draft's, and deletes the draft. */
648 openDraft(id: number, body: DraftBody = {}): Promise<{ id: number; news?: IssueNews }> {
649 return this.#issues("POST", this.agentPath(`draft/${id}/open`), body);
650 }
652 deleteDraft(id: number): Promise<{ ok: boolean }> {
653 return this.#issues("POST", this.agentPath(`draft/${id}/delete`), {});
654 }
656 ask(body: {
657 issue?: number;
658 of: string;
659 question: string;
660 review?: boolean;
661 kind?: "question" | "task";
662 due?: string;
663 blocks?: number[];
664 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.Compare665 attachments?: string[];
666 }): Promise<{ id: number; news?: IssueNews; attachments?: string[] }> {
668 }
670 answer(
671 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.Compare672 body: { words?: string; option?: number | string; note?: string; done?: boolean; attachments?: string[] },
674 return this.#issues("POST", this.agentPath(`answer/${id}`), body);
675 }
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).Compare676
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.Compare677 /** Acknowledges an ask of this agent without answering it: the asker hears it, and the ask stays open. */
678 ack(id: number, body: { note?: string }): Promise<{ ask: Ask; news?: IssueNews }> {
679 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.Compare680 }
682 /** 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. */
683 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.Compare684 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.Compare685 }
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).Compare687 /** Takes back an ask this agent made, with a note on why; the one asked hears it. */
688 withdraw(id: number, body: { note?: string }): Promise<{ ask: Ask; news?: IssueNews }> {
689 return this.#issues("POST", this.agentPath(`withdraw/${id}`), body);
690 }
692 /** Notes on lines (#44), by file or change; open ones only with `open`. */
693 notes(q: { file?: string; change?: number; open?: boolean } = {}): Promise<{ notes: readonly NoteAnswer[] }> {
694 return this.json("GET", `/notes?${query({ file: q.file, change: q.change, open: q.open ? 1 : undefined })}`);
695 }
697 note(body: NoteBody): Promise<{ id: number; change: number | null; lines: readonly [number, number] }> {
698 return this.json("POST", this.agentPath("note"), body);
699 }
701 noteClose(id: number, how: "resolved" | "withdrawn"): Promise<unknown> {
702 return this.json("POST", this.agentPath("note-close"), { id, how });
703 }
705 /** The merge queue now (#39). */
706 queueState(): Promise<QueueState> {
707 return this.json("GET", "/queue");
708 }
710 /** The project's visibility (abso issue 152): public or private. */
711 visibility(): Promise<{ project: string; visibility: "public" | "private" }> {
712 return this.json("GET", "/visibility");
713 }
715 /** Switch the project's visibility (abso issue 140): an owner's key, or the shared token on staging. */
716 setVisibility(v: "public" | "private"): Promise<{ project: string; visibility: "public" | "private" }> {
717 return this.json("POST", `/visibility?visibility=${v}`, {});
718 }
720 /** Take back this agent's queued publishes (#39); refused while one is being checked. */
721 unqueue(): Promise<{ pulled: readonly number[] }> {
722 return this.json("POST", this.agentPath("unqueue"), {});
723 }
725 /**
726 * Sync; a folder following a label goes to the newest version with that label.
727 * With `full`, the answer holds every file in the agent's view, as a first sync's does,
728 * not only what changed since its last sync (#37: a join for an agent the server knew).
729 */
730 sync(options: { full?: boolean } = {}): Promise<SyncAnswer> {
731 return this.json("POST", this.agentPath("sync"), {
732 ...(this.config.follow ? { label: this.config.follow } : {}),
733 ...(options.full ? { full: true } : {}),
734 });
735 }
737 /** Take published versions back out of shared (with the versions that build on them, when asked). */
738 drop(versions: readonly number[], message: string, withDependents = false): Promise<DropAnswer> {
739 return this.json("POST", this.agentPath("drop"), {
740 versions,
741 message,
742 ...(withDependents ? { withDependents: true } : {}),
743 });
744 }
746 /** Take some versions of a named draft into shared, as one version. */
747 pluck(draft: string, versions: readonly number[], message: string, withDependencies = false): Promise<PluckAnswer> {
748 return this.json("POST", this.agentPath("pluck"), {
749 draft,
750 versions,
751 message,
752 ...(withDependencies ? { withDependencies: true } : {}),
753 });
754 }
756 /** Correct the message of this agent's newest publish in its space. */
757 amend(message: string): Promise<{ version: number; draft: string | null; message: string; was: string }> {
758 return this.json("POST", this.agentPath("amend"), { message });
759 }
761 /** Put a label on a version of shared (the newest by default), or take it off. */
762 label(
763 name: string,
764 version?: number,
765 remove = false,
766 ): Promise<{ name: string; version: number; versions: readonly number[] }> {
767 return this.json("POST", this.agentPath("label"), {
768 name,
769 ...(version === undefined ? {} : { version }),
770 ...(remove ? { remove: true } : {}),
771 });
772 }
774 labels(): Promise<{ labels: Readonly<Record<string, readonly number[]>> }> {
775 return this.json("GET", "/labels");
776 }
778 status(): Promise<StatusAnswer> {
779 return this.json("GET", "/status");
780 }
782 /** The status and the paths in the agent's view, in one trip (abso issue 80). */
783 async statusAndFiles(): Promise<StatusAnswer & { files: FilesAnswer | undefined }> {
784 try {
785 return await this.json("GET", this.agentPath("status"));
786 } catch (err) {
787 // A server from before it has no /a/:agent/status; the listing itself is from #37.
788 if (!(err instanceof ApiError && err.status === 404)) throw err;
789 }
790 const status = await this.status();
791 return { ...status, files: await this.viewFiles().catch(() => undefined) };
792 }
794 /** CI's state (#39), or one version's job. */
795 ci(): Promise<CiStatus>;
796 ci(version: number): Promise<CiJob>;
797 ci(version?: number): Promise<CiStatus | CiJob> {
798 return this.json("GET", version === undefined ? "/ci" : `/ci?${query({ version })}`);
799 }
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>Compare801 /** The project's pipeline runs, newest first; one run with its jobs; or one job's log (`log` is pipeline.job). */
802 pipelineRuns(run?: number, log?: string): Promise<unknown> {
803 return this.json("GET", run === undefined ? "/pipelines" : `/pipelines?${query({ run, log })}`);
804 }
init0Start the project806 /** Ends every /latest link handed out so far; answers CI's state with the new link. */
807 ciRevoke(): Promise<CiStatus> {
808 return this.json("POST", "/ci/revoke", {});
809 }
811 /** Count versions up to `through` as seen by CI and end any red or bisect, so an import's history isn't checked (#56). */
812 ciSkip(through: number): Promise<unknown> {
813 return this.json("POST", "/ci/skip", { through });
814 }
816 /** Move to a named draft (null: shared). With carry, the current unpublished changes start a new draft. */
817 switchDraft(name: string | null, carry = false): Promise<SwitchAnswer> {
818 return this.json("POST", this.agentPath("draft"), { name, ...(carry ? { carry: true } : {}) });
819 }
821 /** Land never queues: with the merge queue on, the server refuses it (#39). */
822 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.Compare823 return this.json("POST", this.agentPath("land"), { message }, undefined, PUBLISH_TIMEOUT_MS);
826 draftSync(): Promise<DraftSyncAnswer> {
827 return this.json("POST", this.agentPath("draft-sync"), {});
828 }
830 blame(file: string, from?: number, to?: number, version?: number, view: View = {}): Promise<BlameAnswer> {
831 return this.json("GET", `/blame?${query({ file, from, to, version, ...view })}`);
832 }
834 /** The paths in the agent's view: what its folder should hold (#37). */
835 viewFiles(): Promise<FilesAnswer> {
836 return this.json("GET", this.agentPath("files"));
837 }
839 /** The paths in shared, or a named draft, at a version (the newest by default). */
840 filesAt(draft: string | null, version?: number): Promise<FilesAnswer> {
841 return this.json("GET", `/files?${query({ draft, version })}`);
842 }
844 /** 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.Compare845 /**
846 * The versions newest first, below `before` when it's given. The server
847 * sends at most LOG_PAGE at a time, so a longer log is read page by page,
848 * following each page's next. `next` on the answer says older ones are left.
849 */
850 async log(where: Where, limit?: number, path?: string, before?: number): Promise<LogAnswer> {
851 let page = await this.#logPage(where, limit === undefined ? undefined : Math.min(limit, LOG_PAGE), path, before);
852 const versions = [...page.versions];
853 while (limit !== undefined && versions.length < limit && page.next !== undefined) {
854 page = await this.#logPage(where, Math.min(limit - versions.length, LOG_PAGE), path, page.next);
855 versions.push(...page.versions);
856 }
857 const { next, ...rest } = page;
858 return { ...rest, versions, ...(next !== undefined ? { next } : {}) };
859 }
861 #logPage(
862 where: Where,
863 limit: number | undefined,
864 path: string | undefined,
865 before: number | undefined,
866 ): Promise<LogAnswer> {
867 return this.json("GET", `/log?${query({ ...where, limit, path, before })}`);
870 show(version: number, where: Where): Promise<ShowAnswer> {
871 return this.json("GET", `/show?${query({ version, ...where })}`);
872 }
874 fileAt(path: string, version: number, where: Where): Promise<{ path: string; version: number; text: string | null }> {
875 return this.json("GET", `/file?${query({ path, version, ...where })}`);
876 }
878 compare(from: number, to: number, where: Where): Promise<{ from: number; to: number; files: readonly FileChange[] }> {
879 return this.json("GET", `/compare?${query({ from, to, ...where })}`);
candidates186Read a version of shared without some earlier versions: abso show <N> --without A,B shows what differs and abso export <dir> --version N --without A,B writes the files. The server's GET without?version=&versions= checks the set left exactly as asked: when a version it keeps builds on one left out, it refuses with that chain, the files and the wider set that works, and never widens it. Atoms keep their ids and authors; shared and its log don't change; the same ask gives the same tree hash.Compare880 }
882 /** Version `version` of shared with `versions` left out, or the refusal naming what builds on them. */
883 without(version: number, versions: readonly number[]): Promise<WithoutAnswer> {
884 return this.json("GET", `/without?${query({ version, versions: versions.join(",") })}`);
887 /** A message to the project's other agents (or those named), delivered once as news. */
888 starting(
889 text: string | null,
890 files?: readonly string[],
891 options: { issue?: number; done?: boolean } = {},
892 ): Promise<{
893 starting: { text: string; files: readonly string[]; time: number; issue?: number } | null;
894 overlaps: readonly Overlap[];
895 }> {
896 return this.json("POST", this.agentPath("starting"), {
897 text,
898 ...(files && files.length > 0 ? { files } : {}),
899 ...(options.issue !== undefined ? { issue: options.issue } : {}),
900 ...(options.done ? { done: true } : {}),
901 });
902 }
904 announce(text: string, to?: readonly string[]): Promise<{ id: number; to: readonly string[] }> {
905 return this.json("POST", this.agentPath("announce"), { text, ...(to ? { to } : {}) });
906 }
908 /** The news waiting for this agent, handed over once. */
909 news(): Promise<{ news: News; items?: readonly { readonly text: string; readonly at: number | null }[] }> {
910 return this.json("POST", this.agentPath("news"), {});
911 }
913 /** This agent's unpublished changes, file by file. */
914 diff(): Promise<DiffAnswer> {
915 return this.json("POST", this.agentPath("diff"), {});
916 }
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.Compare917
918 /** Another agent's recorded, unpublished changes, file by file: read only, as the website's drafts show them. */
919 diffOf(agent: string): Promise<DiffAnswer> {
920 return this.json("GET", `/diff?${query({ agent })}`);
921 }
923 /** Discard this agent's unpublished changes to `files` (null: all of them). */
924 restore(files: readonly string[] | null): Promise<RestoreAnswer> {
925 return this.json("POST", this.agentPath("restore"), files === null ? { all: true } : { files });
926 }
whytrail193abso why follows a line back past formatting to its reason, and names git commits
why now lists a line's earlier changes, newest first, with what the line read before each. A change that rewrote a line left the line it replaced in the file's history; why pairs the two (same code formatted differently, the same code rewrapped, or the most similar line) and follows the pairs back. A change that only touched formatting (whitespace, line wrapping, quotes, trailing commas, line-end semicolons, parentheses around a lone arrow parameter) is skipped by default, and why names it: 'Skipped 1 formatting change since: version 366'. --all shows those too. --at <version> reads the line as it was at that version.
A push imported from git (client/scripts/import-git.ts, or a plain git push) names its commit and author in why and blame. import-git.ts now also records where the repository's issues are, from origin on GitHub or GitLab or --issues, and why says which issue #N in an imported message or line means. A project imported before this can say it once in abso.json: "gitIssues": "https://github.com/owner/repo/issues".
Closes issues 20 and 21's tool side.Compare928 why(file: string, line: number, view: View = {}, version?: number): Promise<WhyAnswer> {
929 return this.json("GET", `/why?${query({ file, line, version, ...view })}`);
932 where(): Promise<WhereAnswer> {
933 return this.json("GET", "/where");
934 }
936 /**
937 * Send the folder as a tar.gz and run a command in the agent's box. Output
938 * goes to `io.out` as it arrives, and the box's stderr to `io.err` (the
939 * server keeps them apart when asked; an older one sends both as out).
940 * Answers the command's exit code.
941 *
942 * When the stream breaks before the exit line and the server gave the run
943 * an id, the run goes on in the box: this reconnects to it and carries on
944 * from the last output printed, so nothing is lost or printed twice. The
945 * command itself is never sent twice.
946 */
947 async run(command: string, tarGz: Uint8Array<ArrayBuffer>, io: RunIO): Promise<number> {
948 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.Compare949 // X-Abso-Box: cold means the box started for this run; X-Abso-Prep says whether it started from the prep (#37).
950 io.onBox?.(res.headers.get("x-abso-box") === "cold", res.headers.get("x-abso-prep") ?? undefined);
951 return follow(this, res, res.headers.get("x-abso-run"), { at: 0, errAt: 0 }, io);
954 /**
955 * Start a run and answer its id without waiting: the job goes on in the box
956 * after this connection closes (abso run --detach; abso logs <id> follows it).
957 */
958 async startRun(
959 command: string,
960 tarGz: Uint8Array<ArrayBuffer>,
961 onRetry?: (why: string, attempt: number) => void,
962 replace = false,
963 ): Promise<string> {
964 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.Compare965 const id = res.headers.get("x-abso-run");
967 // No id: the box failed before the job started ({"error"} in the body), or the server can't detach.
968 await consumeRun(res, { out: () => {} }, { at: 0, errAt: 0 });
969 throw new ApiError("this server gives runs no id, so a run can't be detached");
970 }
971 await res.body?.cancel();
972 return id;
973 }
975 /** A run's output from its start, for as long as the box keeps it, until it ends (abso logs). Answers its exit code. */
976 async logs(id: string, io: RunIO): Promise<number> {
977 let res: Response;
978 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.Compare979 res = await this.send(followUrl(this, id, { at: 0, errAt: 0 }), { headers: this.headers() });
981 const e = err as Error;
982 throw new ApiError(
983 `could not reach ${this.config.server}: ${(e.cause as Error | undefined)?.message ?? e.message}`,
984 );
985 }
986 if (res.status === 404) throw new ApiError(`no run ${id} in this box: ${errorSentence(await res.text())}`, 404);
987 if (!res.ok || res.body === null)
988 throw new ApiError(`logs answered ${res.status}: ${errorSentence(await res.text())}`, res.status);
989 return follow(this, res, id, { at: 0, errAt: 0 }, io);
990 }
991}