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

Compare

+43 −13 in 7 places
Lines 3–17 at 318 (were 3–13 at 80)
33// when one fails. Neither prints a credential. plainError words the commonest failures the same way.
44
55import { ApiError } from "./api-error.ts";
6−import { type Answer, type BoxRecord, boxGet, boxText, originOf, readBox } from "./box.ts";
6+import { type Answer, type BoxRecord, boxGet, boxText, originOf, readBox, signedInServers } from "./box.ts";
77import { builtCopy } from "./client-version.ts";
8−import { type Config, credentialLabel, findRoot, readConfig } from "./config.ts";
8+import { type Config, credentialLabel, findRoot, readConfig, tokenFile } from "./config.ts";
9+import { sameServer } from "./server-choice.ts";
10−/** The lowest Node major each kind of copy runs on: the npm package is built for 20, a checkout runs its .ts as is. */
11+/**
12+ * The lowest Node major each kind of copy runs on: a built one (the npm package, or a checkout's client/bin/abso.mjs)
13+ * is built for 20; a checkout's client/abso.ts runs its .ts as is, which takes Node's type stripping.
14+ */
1115export function nodeNeeded(built: boolean): number {
1216 return built ? 20 : 24;
1317}
Lines 26–38 at 318 (were 22–28 at 80)
2226}
2327
2428export function realProbe(): Probe {
25− return { fetcher: fetch, now: Date.now(), node: process.versions.node, built: builtCopy() };
29+ // Bundled, this module is client/bin/abso.mjs (or the npm package's file); from client/abso.ts, it is this .ts.
30+ return {
31+ fetcher: fetch,
32+ now: Date.now(),
33+ node: process.versions.node,
34+ built: builtCopy() || !import.meta.url.endsWith(".ts"),
35+ };
2636}
2737
2838/** This folder's settings, or why they can't be read; undefined outside a folder. */
Lines 49–64 at 318 (were 39–44 at 80)
3949 }
4050}
4151
52+/**
53+ * The servers other than `server` this box is signed in to, as one sentence for a refusal or a report to end
54+ * with, naming how to use one: a box signed in elsewhere is never used for `server` by itself.
55+ */
56+export function elsewhereText(server: string, command: string, home?: string, now = Date.now()): string {
57+ const others = signedInServers(home, now).filter((s) => !sameServer(s, originOf(server)));
58+ if (others.length === 0) return "";
59+ return ` This box is signed in to ${others.join(" and ")}: ${command} --server <url> uses ${others.length === 1 ? "it" : "one"}.`;
60+}
4262const day = (ms: number) => new Date(ms).toISOString().slice(0, 16).replace("T", " ");
4363
4464/** The server's view of this box: GET /box, as the box. */
Lines 78–92 at 318 (were 58–64 at 80)
5878
5979function credentialWords(root: string, server: string, env: Readonly<Record<string, string | undefined>>): string {
6080 const c = credentialLabel(root, server, env);
61− return c.kind === "agent key" ? `the agent key ${c.id}` : c.kind === "shared token" ? "the shared token" : "no key";
81+ return c.kind === "agent key"
82+ ? `the agent key ${c.id}`
83+ : c.kind === "shared token"
84+ ? "the shared token"
85+ : c.kind === "pipeline run key"
86+ ? "a pipeline run's key"
87+ : tokenFile() !== undefined
88+ ? "no key (~/.abso/token is here, and is used only with --token-file)"
89+ : "no key";
6290}
6391
6492export async function whoami(
Lines 99–107 at 318 (were 71–77 at 80)
7199 const record = readBox(server, probe.home);
72100 let box: Record<string, unknown> | null = null;
73101 if (!record) {
74− lines.push(`This box isn't signed in to ${originOf(server)}. Run abso login.`);
102+ lines.push(
103+ `This box isn't signed in to ${originOf(server)}. Run abso login.${elsewhereText(server, "abso whoami", probe.home, probe.now)}`,
104+ );
75105 } else {
76106 const answer = await serverBox(record, probe);
77107 const [first, ...rest] = boxText(record, server, probe.now).split("\n");
Lines 169–176 at 318 (were 139–146 at 80)
139169 );
140170
141171 const folder = folderOf(cwd, env);
142− // The folder's own server when there is one: it's the one its commands talk to.
143− const target = folder?.config?.server ?? server;
172+ // Chosen as every command chooses (server-choice.ts): --server, else the folder's own, else ABSO_SERVER, else prod.
173+ const target = server;
144174 const origin = originOf(target);
145175 let reachable = false;
146176 const started = Date.now();
Lines 327–340 at 318 (were 297–310 at 80)
297327
298328/**
299329 * The commonest failures in plain words, with the next step: no credential, a credential the server refuses, and a
300− * server that can't be reached. Anything else is left as it was. `signedIn` is whether the call carried a key or token.
330+ * server that can't be reached. Anything else is left as it was. `sent` names the key or token the call carried, if any.
301331 */
302−export function plainError(err: unknown, signedIn: boolean): string | undefined {
332+export function plainError(err: unknown, sent: string | undefined, tokenFileUnasked = false): string | undefined {
303333 if (!(err instanceof ApiError)) return undefined;
304334 if (err.status === 401)
305− return signedIn
306− ? `The server didn't accept this folder's key: it may be revoked or expired. abso doctor checks it. (${err.message})`
307− : "You're not signed in. Run abso login, then abso join <project>.";
335+ return sent !== undefined
336+ ? `The server didn't accept ${sent}: it may be revoked or expired. abso doctor checks it. (${err.message})`
337+ : `You're not signed in. Run abso login, then abso join <project>.${tokenFileUnasked ? " ~/.abso/token is used only with --token-file." : ""}`;
308338 if (err.status === undefined && err.message.startsWith("could not reach ")) {
309339 const said = err.message.replace(/^could not reach /, "Can't reach ");
310340 // A message that already gives its next step (publish's "Run the same command again.") keeps it as the last word.
MCP
compare on this site's /mcp
CLI
abso diff 80 318 client/src/doctor.ts --json
JSON
/christopher/abso-core/compare/80..318?file=client%2Fsrc%2Fdoctor.ts&format=json