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

Compare

+32 −33 in 7 places
Lines 3–17 at 318 (were 3–16 at 116)
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 { UsageError } from "./args.ts";
76import { type Answer, type BoxRecord, boxGet, boxText, originOf, readBox, signedInServers } from "./box.ts";
87import { builtCopy } from "./client-version.ts";
9−import { type Config, credentialLabel, findRoot, readConfig } from "./config.ts";
10−import { TOKEN_SERVERS } from "./core.ts";
11−import { fromEnv } from "./env-names.ts";
8+import { type Config, credentialLabel, findRoot, readConfig, tokenFile } from "./config.ts";
9+import { sameServer } from "./server-choice.ts";
1210
13−/** 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+ */
1415export function nodeNeeded(built: boolean): number {
1516 return built ? 20 : 24;
1617}
Lines 26–38 at 318 (were 25–31 at 116)
2526}
2627
2728export function realProbe(): Probe {
28− 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+ };
2936}
3037
3138/** This folder's settings, or why they can't be read; undefined outside a folder. */
Lines 50–62 at 318 (were 43–67 at 116)
4350}
4451
4552/**
46− * The server whoami and doctor look at, in the order join picks one: --server, then ABSO_SERVER, then this
47− * folder's server, then the one this box signed in to with abso login, then https://api.abso.dev. A box signed
48− * in to more than one server has to say which.
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.
4955 */
50−export function checkServer(
51− flag: string | undefined,
52− cwd: string,
53− env: Readonly<Record<string, string | undefined>>,
54− home?: string,
55− now = Date.now(),
56−): string {
57− const named = flag ?? fromEnv(env, "SERVER");
58− if (named) return named;
59− const folder = folderOf(cwd, env)?.config?.server;
60− if (folder) return folder;
61− const signedIn = signedInServers(home, now);
62− if (signedIn.length > 1)
63− throw new UsageError(`this box is signed in to ${signedIn.join(" and ")}: say which with --server <url>`);
64− return signedIn[0] ?? TOKEN_SERVERS[0]!;
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"}.`;
6560}
6661
6762const day = (ms: number) => new Date(ms).toISOString().slice(0, 16).replace("T", " ");
Lines 84–92 at 318 (were 89–95 at 116)
8984 ? "the shared token"
9085 : c.kind === "pipeline run key"
9186 ? "a pipeline run's key"
92− : "no key";
87+ : tokenFile() !== undefined
88+ ? "no key (~/.abso/token is here, and is used only with --token-file)"
89+ : "no key";
9390}
9491
9592export async function whoami(
Lines 99–107 at 318 (were 102–108 at 116)
10299 const record = readBox(server, probe.home);
103100 let box: Record<string, unknown> | null = null;
104101 if (!record) {
105− 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+ );
106105 } else {
107106 const answer = await serverBox(record, probe);
108107 const [first, ...rest] = boxText(record, server, probe.now).split("\n");
Lines 169–176 at 318 (were 170–177 at 116)
170169 );
171170
172171 const folder = folderOf(cwd, env);
173− // The folder's own server when there is one: it's the one its commands talk to.
174− 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;
175174 const origin = originOf(target);
176175 let reachable = false;
177176 const started = Date.now();
Lines 327–340 at 318 (were 328–341 at 116)
328327
329328/**
330329 * The commonest failures in plain words, with the next step: no credential, a credential the server refuses, and a
331− * 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.
332331 */
333−export function plainError(err: unknown, signedIn: boolean): string | undefined {
332+export function plainError(err: unknown, sent: string | undefined, tokenFileUnasked = false): string | undefined {
334333 if (!(err instanceof ApiError)) return undefined;
335334 if (err.status === 401)
336− return signedIn
337− ? `The server didn't accept this folder's key: it may be revoked or expired. abso doctor checks it. (${err.message})`
338− : "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." : ""}`;
339338 if (err.status === undefined && err.message.startsWith("could not reach ")) {
340339 const said = err.message.replace(/^could not reach /, "Can't reach ");
341340 // 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 116 318 client/src/doctor.ts --json
JSON
/christopher/abso-core/compare/116..318?file=client%2Fsrc%2Fdoctor.ts&format=json