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
MCP
show on this site's /mcp
CLI
abso show 69 --json
JSON
/christopher/abso-core/versions/69?format=json

join, signed out: for a public project, the error names its page on the website and says the client needs a sign-in, even to read ('abso-core is public: read it at https://abso.dev/p/abso-core (every page is also JSON). The client needs a sign-in, even to read: abso login.'). Whether it's public is asked of the server with no credentials. A project that isn't public keeps the plain 'abso login signs it in'. Product Lead's wording.

of shared·pinch··Not checked

Version 68 · Files at version 69

2 files, 101 lines added, 2 removed.

--- a/client/src/join-commands.ts
+++ b/client/src/join-commands.ts
@@ -16,6 +16,7 @@
1616import { clearKnown, loadIgnore, readFolder, writeKnown } from "./folder.ts";
1717import { modInstalled } from "./install.ts";
1818import { type FullMode, foldModes, writeKnownModes } from "./modes.ts";
19+import { siteOf } from "./orgs.ts";
1920import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from "./project-file.ts";
2021import { refusedText } from "./safety.ts";
2122import { OLD_STATE_DIR, STATE_DIR, stateDir } from "./state-dir.ts";
@@ -123,6 +124,22 @@
123124 return sub;
124125}
125126
127+/**
128+ * Why a join failed signed out. The client reads only as an agent, which needs a
129+ * sign-in; a public project is read signed out on the website. Whether the
130+ * project is public is asked of the server with no credentials.
131+ */
132+async function signedOut(server: string, project: string): Promise<string> {
133+ let open = false;
134+ try {
135+ const response = await fetch(new URL(`/p/${project}/status`, server), { signal: AbortSignal.timeout(3000) });
136+ open = response.ok;
137+ } catch {}
138+ return open
139+ ? `${project} is public: read it at ${siteOf(server)}/p/${project} (every page is also JSON). The client needs a sign-in, even to read: abso login.`
140+ : `This box isn't signed in to ${server}. abso login signs it in.`;
141+}
126143export async function runJoin(args: Parsed, env: Env): Promise<Output> {
127144 if (args.positionals.length !== 1) throw new UsageError("join takes the project name: abso join <project>");
128145 const project = args.positionals[0]!;
@@ -144,7 +161,10 @@
144161 minted = box && !hasKey ? await mintKey(box, project, agent) : undefined;
145162 } else {
146163 // No --agent: the box's name, or the next free -2, -3.
147− if (!box) throw new UsageError("abso login signs this box in first (or give --agent <name>)");
164+ if (!box)
165+ throw new UsageError(
166+ `${await signedOut(server, project)} (A folder that already has a key joins with --agent <name>.)`,
167+ );
148168 if (hasKey) throw new UsageError(`${root} already has a key: give its agent's name with --agent <name>`);
149169 const free = await mintFreeName(box, project, defaultAgentName());
150170 agent = free.agent;
@@ -165,7 +185,7 @@
165185 } catch (error) {
166186 if (!(error instanceof ApiError && error.status === 401 && !box && !settings.token)) throw error;
167187 rmSync(stateDir(root), { recursive: true, force: true });
168− throw new UsageError(`This box isn't signed in to ${config.server}. abso login signs it in.`);
188+ throw new UsageError(await signedOut(config.server, project));
169189 }
170190 return {
171191 text: [
--- /dev/null
+++ b/client/test/join-signed-out.test.ts
@@ -0,0 +1,79 @@
1+// A join with no sign-in says abso login signs the box in. For a public project
2+// it also says where the website shows it, since the client needs a sign-in
3+// even to read. The client runs as its own process with an empty home, so no
4+// sign-in or token on this machine is found.
5+
6+import assert from "node:assert/strict";
7+import { execFile } from "node:child_process";
8+import { mkdtempSync, rmSync } from "node:fs";
9+import { createServer, type Server } from "node:http";
10+import type { AddressInfo } from "node:net";
11+import { tmpdir } from "node:os";
12+import { join, resolve } from "node:path";
13+import { after, before, describe, it } from "node:test";
14+import { type Fake, startFake } from "./fake-server.ts";
16+const CLIENT = resolve(import.meta.dirname, "..", "abso.ts");
17+let fake: Fake;
18+// A server where every project is public: status answers signed out, and the agent routes want a sign-in.
19+let open: Server;
20+let openUrl: string;
21+const dirs: string[] = [];
22+const temp = () => {
23+ const dir = mkdtempSync(join(tmpdir(), "abso-test-signed-out-"));
24+ dirs.push(dir);
25+ return dir;
26+};
28+before(async () => {
29+ fake = await startFake(0, "test-token-not-secret");
30+ open = createServer((req, res) => {
31+ if (req.method === "GET" && /^\/p\/[^/]+\/status$/.test(req.url ?? ""))
32+ return res.writeHead(200, { "content-type": "application/json" }).end('{"version":1,"agents":[]}');
33+ res.writeHead(401, { "content-type": "application/json" }).end('{"error":"sign in"}');
34+ });
35+ await new Promise<void>((done) => open.listen(0, "127.0.0.1", done));
36+ openUrl = `http://127.0.0.1:${(open.address() as AddressInfo).port}`;
37+});
38+after(async () => {
39+ await fake.close();
40+ open.close();
41+ for (const dir of dirs) rmSync(dir, { recursive: true, force: true });
42+});
44+/** Runs the client signed out: an empty home, and no token in the environment. */
45+function signedOut(...args: string[]): Promise<{ code: number; stderr: string }> {
46+ const home = temp();
47+ const env: Record<string, string> = {
48+ PATH: process.env.PATH ?? "",
49+ HOME: home,
50+ USERPROFILE: home,
51+ AVCS_SERVERS_FILE: "no-servers.json",
52+ };
53+ if (process.env.CLAUDE_CONFIG_DIR) env.CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR;
54+ if (process.env.SystemRoot) env.SystemRoot = process.env.SystemRoot;
55+ return new Promise((done) => {
56+ execFile(process.execPath, [CLIENT, ...args], { cwd: temp(), env }, (error, _stdout, stderr) =>
57+ done({ code: typeof error?.code === "number" ? error.code : 0, stderr }),
58+ );
59+ });
60+}
62+describe("join, signed out", () => {
63+ it("to a public project, as a reader, names its page on the website and abso login", async () => {
64+ const run = await signedOut("join", "abso-core", "--agent", "qa-reader", "--reader", "--server", openUrl);
65+ assert.notEqual(run.code, 0);
66+ assert.match(
67+ run.stderr,
68+ /abso-core is public: read it at http:\/\/127\.0\.0\.1:\d+\/p\/abso-core \(every page is also JSON\)\. The client needs a sign-in, even to read: abso login\./,
69+ );
70+ });
72+ it("to a project that isn't public, keeps to abso login, and says a folder with a key joins with --agent", async () => {
73+ const run = await signedOut("join", "secret", "--server", fake.url);
74+ assert.notEqual(run.code, 0);
75+ assert.match(run.stderr, /isn't signed in to .*abso login signs it in\./);
76+ assert.doesNotMatch(run.stderr, /is public/);
77+ assert.match(run.stderr, /A folder that already has a key joins with --agent <name>/);
78+ });
79+});