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
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/client/test/join-signed-out.test.ts?version=285&format=json
79 linespinch 100%Last change pinch in version 86, 3 versions changed it

You're reading version 285. The newest is 318, and no version since then changed this file. Go to the newestCompare with 318

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, and that --reader reads it here
3// (visitor.test.ts has that folder). The client runs as its own process with an
4// empty home, so no sign-in or token on this machine is found.
5
6import assert from "node:assert/strict";
7import { execFile } from "node:child_process";
8import { mkdtempSync, rmSync } from "node:fs";
9import { createServer, type Server } from "node:http";
10import type { AddressInfo } from "node:net";
11import { tmpdir } from "node:os";
12import { join, resolve } from "node:path";
13import { after, before, describe, it } from "node:test";
14import { type Fake, startFake } from "./fake-server.ts";
16const CLIENT = resolve(import.meta.dirname, "..", "abso.ts");
17let fake: Fake;
18// A server where every project is public: status answers signed out, and the agent routes want a sign-in.
19let open: Server;
20let openUrl: string;
21const dirs: string[] = [];
22const temp = () => {
23 const dir = mkdtempSync(join(tmpdir(), "abso-test-signed-out-"));
24 dirs.push(dir);
25 return dir;
26};
28before(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});
38after(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. */
45function 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 });
62describe("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+\/christopher\/abso-core \(every page is also JSON\), or here with abso join abso-core --reader\. To work on it: 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});