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

Compare

+38 −33 in 7 places
Lines 3–17 at 318 (were 3–16 at 85)
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 85)
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 85)
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 78–92 at 318 (were 83–89 at 85)
8378
8479function credentialWords(root: string, server: string, env: Readonly<Record<string, string | undefined>>): string {
8580 const c = credentialLabel(root, server, env);
86− 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";
8790}
8891
8992export async function whoami(
Lines 99–107 at 318 (were 96–102 at 85)
9699 const record = readBox(server, probe.home);
97100 let box: Record<string, unknown> | null = null;
98101 if (!record) {
99− 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+ );
100105 } else {
101106 const answer = await serverBox(record, probe);
102107 const [first, ...rest] = boxText(record, server, probe.now).split("\n");
Lines 169–176 at 318 (were 164–171 at 85)
164169 );
165170
166171 const folder = folderOf(cwd, env);
167− // The folder's own server when there is one: it's the one its commands talk to.
168− 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;
169174 const origin = originOf(target);
170175 let reachable = false;
171176 const started = Date.now();
Lines 327–340 at 318 (were 322–335 at 85)
322327
323328/**
324329 * The commonest failures in plain words, with the next step: no credential, a credential the server refuses, and a
325− * 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.
326331 */
327−export function plainError(err: unknown, signedIn: boolean): string | undefined {
332+export function plainError(err: unknown, sent: string | undefined, tokenFileUnasked = false): string | undefined {
328333 if (!(err instanceof ApiError)) return undefined;
329334 if (err.status === 401)
330− return signedIn
331− ? `The server didn't accept this folder's key: it may be revoked or expired. abso doctor checks it. (${err.message})`
332− : "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." : ""}`;
333338 if (err.status === undefined && err.message.startsWith("could not reach ")) {
334339 const said = err.message.replace(/^could not reach /, "Can't reach ");
335340 // 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 85 318 client/src/doctor.ts --json
JSON
/christopher/abso-core/compare/85..318?file=client%2Fsrc%2Fdoctor.ts&format=json