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

Compare

+15 −9 in 5 places
Lines 3–12 at 318 (were 3–11 at 8)
33
44import { readFileSync } from "node:fs";
55import { homedir } from "node:os";
6−import { join } from "node:path";
76import { UsageError } from "./args.ts";
87import type { Config } from "./config.ts";
8+import { fromEnv } from "./env-names.ts";
9+import { homeFile } from "./state-dir.ts";
1011function originOf(server: string): string {
1112 try {
Lines 16–22 at 318 (were 15–21 at 8)
1516 }
1617}
1718
18−/** The admin token goes only to a server named in AVCS_ADMIN_SERVERS (comma-separated): none is built in. */
19+/** The admin token goes only to a server named in ABSO_ADMIN_SERVERS (comma-separated): none is built in. */
1920export function adminGoesTo(server: string, extra = ""): boolean {
2021 const allowed = [
2122 ...extra
Lines 29–48 at 318 (were 28–42 at 8)
2829}
2930
3031export function adminToken(env: Readonly<Record<string, string | undefined>> = process.env): string {
31− const fromEnv = env.AVCS_ADMIN_TOKEN?.trim();
32− if (fromEnv) return fromEnv;
32+ const fromVar = fromEnv(env, "ADMIN_TOKEN")?.trim();
33+ if (fromVar) return fromVar;
3334 try {
34− const fromFile = readFileSync(join(homedir(), ".avcs", "admin-token"), "utf8").trim();
35+ const fromFile = readFileSync(homeFile(homedir(), "admin-token"), "utf8").trim();
3536 if (fromFile) return fromFile;
3637 } catch {}
37− throw new UsageError("abso key needs the admin token in AVCS_ADMIN_TOKEN or ~/.avcs/admin-token");
38+ throw new UsageError("abso key needs the admin token in ABSO_ADMIN_TOKEN or ~/.abso/admin-token");
3839}
3940
41+/** What an admin command says each time it uses the admin token, and where it came from. Never the token. */
42+export function adminTokenWords(env: Readonly<Record<string, string | undefined>> = process.env): string {
43+ return `Using the admin token, from ${fromEnv(env, "ADMIN_TOKEN")?.trim() ? "ABSO_ADMIN_TOKEN" : "~/.abso/admin-token"}.`;
44+}
4046function scrub(text: string, secrets: readonly string[]): string {
4147 let out = text.replace(/abso_sk_[A-Za-z0-9_-]+/g, "[redacted]");
4248 for (const secret of secrets) if (secret.length > 0) out = out.split(secret).join("[redacted]");
Lines 50–58 at 318 (were 44–52 at 8)
4450}
4551
4652async function call(config: Config, admin: string, method: "GET" | "POST", path: string): Promise<unknown> {
47− if (!adminGoesTo(config.server, process.env.AVCS_ADMIN_SERVERS))
53+ if (!adminGoesTo(config.server, fromEnv(process.env, "ADMIN_SERVERS")))
4854 throw new UsageError(
49− `abso key will not send the admin token to ${config.server}; AVCS_ADMIN_SERVERS names the servers it may go to`,
55+ `abso key will not send the admin token to ${config.server}; ABSO_ADMIN_SERVERS names the servers it may go to`,
5056 );
5157 const secrets = [admin, config.token ?? ""].filter((s) => s.length > 0);
5258 let response: Response;
Lines 61–67 at 318 (were 55–61 at 8)
5561 method,
5662 headers: {
5763 ...(config.token ? { authorization: `Bearer ${config.token}` } : {}),
58− "x-avcs-admin": admin,
64+ "x-abso-admin": admin,
5965 },
6066 signal: AbortSignal.timeout(30_000),
6167 });
MCP
compare on this site's /mcp
CLI
abso diff 8 318 client/src/key-admin.ts --json
JSON
/christopher/abso-core/compare/8..318?file=client%2Fsrc%2Fkey-admin.ts&format=json