Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 87 to 88

Compare

+30 −18 in 10 places
Lines 179–195 at 88 (were 179–184 at 87)
179179 };
180180 }
181181
182+ /**
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+ }
182193 async json<T>(
183194 method: "GET" | "POST",
184195 path: string,
Lines 198–205 at 88 (were 187–195 at 87)
187198 atLeastMs = 0,
188199 ): Promise<T> {
189200 let res: Response | undefined;
190− // A visitor folder only reads, and follows no redirect, so nothing it sends goes anywhere it didn't name.
191− const visitor = this.config.visitor === true;
192− if (visitor && method !== "GET") throw new ApiError(`${path}: a folder that reads signed out sends only reads`);
201+ if (this.config.visitor && method !== "GET")
202+ throw new ApiError(`${path}: a folder that reads signed out sends only reads`);
193203 const sent = body === undefined ? undefined : JSON.stringify(body);
194204 const timeoutMs = Math.max(atLeastMs, timeoutFor(this.timeoutMs, sent));
195205 // A connection that never opened is tried once more, IPv4 first (#37, GAME - UI/UX: one IPv6
Lines 207–216 at 88 (were 197–207 at 87)
197207 // a POST is as safe to send again as a GET.
198208 for (let attempt = 0; res === undefined; attempt++) {
199209 try {
200− res = await fetch(this.url(path, server), {
210+ res = await this.send(this.url(path, server), {
201211 method,
202212 headers: this.headers(sent === undefined ? undefined : "application/json"),
203213 ...(sent === undefined ? {} : { body: sent }),
204− ...(visitor ? { redirect: "error" as const } : {}),
205214 signal: AbortSignal.timeout(timeoutMs),
206215 });
207216 } catch (err) {
Lines 299–305 at 88 (were 290–296 at 87)
290299 });
291300 let res: Response;
292301 try {
293− res = await fetch(`${this.url("/serve")}?${q}`, {
302+ res = await this.send(`${this.url("/serve")}?${q}`, {
294303 method: "POST",
295304 headers: this.headers(),
296305 signal: AbortSignal.timeout(20 * 60_000),
Lines 320–335 at 88 (were 311–323 at 87)
311320 async prep(command: string, tarGz: Uint8Array<ArrayBuffer>): Promise<PrepAnswer> {
312321 let res: Response;
313322 try {
314− res = await fetch(`${this.url(this.agentPath("prep"))}?cmd=${encodeURIComponent(command)}${boxQuery(this.box)}`, {
315− method: "POST",
316− headers: this.headers("application/gzip"),
317− body: tarGz,
318− // A setup command can take minutes (npm ci, a browser download).
319− signal: AbortSignal.timeout(30 * 60_000),
320− });
323+ 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+ );
321333 } catch (err) {
322334 const e = err as Error;
323335 throw new ApiError(
Lines 345–351 at 88 (were 333–339 at 87)
333345 async unprep(): Promise<boolean> {
334346 let res: Response;
335347 try {
336− res = await fetch(
348+ res = await this.send(
337349 `${this.url(this.agentPath("prep"))}${this.box ? `?box=${encodeURIComponent(this.box)}` : ""}`,
338350 { method: "DELETE", headers: this.headers(), signal: AbortSignal.timeout(this.timeoutMs) },
339351 );
Lines 381–387 at 88 (were 369–375 at 87)
369381 async bytes(method: "GET" | "PUT", path: string, body?: Uint8Array): Promise<Uint8Array> {
370382 let res: Response;
371383 try {
372− res = await fetch(this.url(path), {
384+ res = await this.send(this.url(path), {
373385 method,
374386 headers: this.headers(body === undefined ? undefined : "application/octet-stream"),
375387 ...(body === undefined ? {} : { body: body as Uint8Array<ArrayBuffer> }),
Lines 503–509 at 88 (were 491–497 at 87)
491503 const path = this.agentPath("attachments");
492504 let res: Response;
493505 try {
494− res = await fetch(this.url(path, this.issuesServer), {
506+ res = await this.send(this.url(path, this.issuesServer), {
495507 method: "POST",
496508 headers: { ...this.headers("application/octet-stream"), "x-abso-name": encodeURIComponent(name) },
497509 body: bytes as Uint8Array<ArrayBuffer>,
Lines 550–556 at 88 (were 538–544 at 87)
538550 const url = `${this.attachmentUrl(id)}${source ? "/source" : ""}`;
539551 let res: Response;
540552 try {
541− res = await fetch(url, {
553+ res = await this.send(url, {
542554 headers: this.headers(),
543555 signal: AbortSignal.timeout(Math.max(this.timeoutMs, 120_000)),
544556 });
Lines 948–954 at 88 (were 936–942 at 87)
936948 async logs(id: string, io: RunIO): Promise<number> {
937949 let res: Response;
938950 try {
939− res = await fetch(followUrl(this, id, { at: 0, errAt: 0 }), { headers: this.headers() });
951+ res = await this.send(followUrl(this, id, { at: 0, errAt: 0 }), { headers: this.headers() });
940952 } catch (err) {
941953 const e = err as Error;
942954 throw new ApiError(
MCP
compare on this site's /mcp
CLI
abso diff 87 88 client/src/api.ts --json
JSON
/christopher/abso-core/compare/87..88?file=client%2Fsrc%2Fapi.ts&format=json