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

Compare

+29 −7 in 9 places
Lines 11–17 at 318 (were 11–16 at 269)
1111import { UsageError } from "./args.ts";
1212import { type MachineServers, machineServers, TOKEN_SERVERS, tokenGoesTo, trustedList } from "./core.ts";
1313import { fromEnv } from "./env-names.ts";
14+import { isLocal, storeDir } from "./local-store.ts";
1415import { homeFile, stateDir } from "./state-dir.ts";
1516
1617/** What .avcs/config.json holds. */
Lines 28–41 at 318 (were 27–36 at 269)
2728 * routes anyone can read and sends no credential. It has no agent; its config holds server, project and this.
2829 */
2930 readonly visitor?: boolean;
31+ /** A local project's store (abso init --local --store), when it isn't the machine's own: ABSO_STORE or the OS data folder. */
32+ readonly store?: string;
3033}
3134
3235export interface Config extends Settings {
3336 readonly token?: string;
37+ /** For a local project (server "local"): the store folder its history is in, or undefined when there's none to use. */
38+ readonly localStore?: string;
3439}
3540
3641export function configPath(root: string): string {
Lines 56–62 at 318 (were 51–57 at 269)
5156export function readConfig(
5257 root: string,
5358 env: Readonly<Record<string, string | undefined>> = process.env,
54− tokenFileOk = true,
59+ tokenFileOk = false,
5560): Config {
5661 const raw = JSON.parse(readFileSync(configPath(root), "utf8")) as Partial<Settings>;
5762 if (raw.visitor === true) {
Lines 69–83 at 318 (were 64–74 at 269)
6469 for (const key of ["server", "project", "agent"] as const) {
6570 if (typeof raw[key] !== "string" || raw[key] === "") throw new Error(`${configPath(root)} has no "${key}"`);
6671 }
67− const token = tokenFor(raw.server!, env, root, tokenFileOk);
72+ // A local project's calls never leave this process, so no credential goes with them.
73+ const local = isLocal(raw.server);
74+ const token = local ? undefined : tokenFor(raw.server!, env, root, tokenFileOk);
6875 return {
6976 server: raw.server!,
7077 project: raw.project!,
7178 agent: raw.agent!,
79+ ...(typeof raw.store === "string" && raw.store !== "" ? { store: raw.store } : {}),
80+ ...(local ? { localStore: storeDir(env, raw.store, root) } : {}),
7281 ...(typeof raw.follow === "string" && raw.follow !== "" ? { follow: raw.follow } : {}),
7382 ...(raw.reader === true ? { reader: true } : {}),
7483 ...(token ? { token } : {}),
Lines 111–117 at 318 (were 102–107 at 269)
102111 root: string,
103112 server: string,
104113 env: Readonly<Record<string, string | undefined>> = process.env,
114+ tokenFileOk = false,
105115): { kind: "agent key" | "shared token" | "pipeline run key" | "none"; id: string | null } {
106116 const key = readKeyFile(root);
107117 if (key) {
Lines 120–126 at 318 (were 110–116 at 269)
110120 }
111121 if (fromEnv(env, "TOKEN")) return { kind: "shared token", id: null };
112122 if (fromEnv(env, "KEY_FILE")) return { kind: "pipeline run key", id: null };
113− return { kind: readToken(env) ? "shared token" : "none", id: null };
123+ return { kind: tokenFileOk && tokenFile() ? "shared token" : "none", id: null };
114124}
115125
116126interface StoredKey {
Lines 192–206 at 318 (were 182–191 at 269)
182192 server: string,
183193 env: Readonly<Record<string, string | undefined>> = process.env,
184194 root?: string,
185− tokenFileOk = true,
195+ tokenFileOk = false,
186196): string | undefined {
187197 if (root) {
188198 const key = readKeyFile(root);
199+ // A folder with a key signs in with that key and nothing else, even when the server refuses it.
200+ if (!key && existsSync(keyPath(root)))
201+ throw new UsageError(
202+ `this folder's key file (${keyPath(root)}) can't be read, so abso sends nothing; abso key install puts a key back`,
203+ );
189204 if (key) {
190205 if (originOf(key.server) !== originOf(server))
191206 throw new UsageError("this folder's key was issued for a different server, so abso will not send it");
Lines 266–272 at 318 (were 251–257 at 269)
251266 return key;
252267}
253268
254−/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. abso init and join read it only with --token-file. */
269+/** This machine's token file (~/.abso/token, else ~/.avcs/token), or none. Read only for a command given --token-file. */
255270export function tokenFile(): string | undefined {
256271 return readToken({});
257272}
Lines 284–300 at 318 (were 269–278 at 269)
269284
270285export function writeConfig(root: string, settings: Settings): void {
271286 mkdirSync(stateDir(root), { recursive: true });
272− const { server, project, agent, follow, reader, visitor } = settings;
287+ const { server, project, agent, follow, reader, visitor, store } = settings;
273288 const written = visitor
274289 ? { server, project, visitor: true }
275− : { server, project, agent, ...(follow ? { follow } : {}), ...(reader ? { reader: true } : {}) };
290+ : {
291+ server,
292+ project,
293+ agent,
294+ ...(follow ? { follow } : {}),
295+ ...(reader ? { reader: true } : {}),
296+ ...(store ? { store } : {}),
297+ };
276298 writeFileSync(configPath(root), `${JSON.stringify(written, null, 2)}\n`);
277299 excludeFromGit(root);
278300}
MCP
compare on this site's /mcp
CLI
abso diff 269 318 client/src/config.ts --json
JSON
/christopher/abso-core/compare/269..318?file=client%2Fsrc%2Fconfig.ts&format=json