@agst/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -2
- package/bin/agst.js +144 -0
- package/package.json +27 -4
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# agst
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The CLI for [August](https://agst.me), the agent orchestrator.
|
|
4
|
+
|
|
5
|
+
August is a desktop home for coding agents. `agst` runs August headless on
|
|
6
|
+
your own machine, using its Claude Code and OpenCode installs, so you can
|
|
7
|
+
drive it from the August app on your Mac or phone over Tailscale, your LAN,
|
|
8
|
+
or August Cloud.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npx @agst/cli serve # on the machine; prints a pairing link
|
|
12
|
+
npx @agst/cli serve --install # the same, as a service that survives reboots (Linux)
|
|
13
|
+
npx @agst/cli pair # a fresh pairing link
|
|
14
|
+
npx @agst/cli link # optional: reach it through August Cloud too
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Open the pairing link on your Mac (or type its address and code under
|
|
18
|
+
Settings → Hosts in August). By default it only listens on your tailnet;
|
|
19
|
+
add `--lan` for your local network.
|
package/bin/agst.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* agst: the launcher npm installs (as `@agst/cli` for now, `agst` once npm
|
|
4
|
+
* releases the name). The real CLI is the August runner, a single signed
|
|
5
|
+
* binary per platform; this fetches the one for this machine (once per
|
|
6
|
+
* version), checks its ed25519 signature against the key below, and runs it
|
|
7
|
+
* with your arguments. No dependencies, so `npx @agst/cli` starts fast.
|
|
8
|
+
*
|
|
9
|
+
* Binaries live at <releases>/runner/<version>/august-runner-<platform>,
|
|
10
|
+
* cached in ~/.august/bin. ~/.august/bin/agst always points at the current
|
|
11
|
+
* one, so a systemd unit (`agst serve --install`) survives upgrades.
|
|
12
|
+
*
|
|
13
|
+
* Environment:
|
|
14
|
+
* AGST_HOME cache dir (default ~/.august/bin)
|
|
15
|
+
* AGST_RELEASES_URL where binaries are fetched (default releases.agst.me)
|
|
16
|
+
* AGST_RUNNER run this binary instead (development)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { spawn, execFileSync } from "node:child_process";
|
|
20
|
+
import { verify, createPublicKey } from "node:crypto";
|
|
21
|
+
import fs from "node:fs";
|
|
22
|
+
import os from "node:os";
|
|
23
|
+
import path from "node:path";
|
|
24
|
+
|
|
25
|
+
/** The runner this launcher ships with. Bumped with every agst release. */
|
|
26
|
+
const RUNNER_VERSION = "0.2.0";
|
|
27
|
+
const RELEASES =
|
|
28
|
+
process.env.AGST_RELEASES_URL ?? "https://releases.agst.me/runner";
|
|
29
|
+
/** The runner signing key (SPKI, base64): the same one sandboxes verify. */
|
|
30
|
+
const PUBLIC_KEY =
|
|
31
|
+
"MCowBQYDK2VwAyEANIOelkzkxgmMs+OxFfJuJQxF7uhKabc5ILj92UP2/uk=";
|
|
32
|
+
const PLATFORMS = new Set(["linux-x64", "linux-arm64", "darwin-arm64"]);
|
|
33
|
+
/**
|
|
34
|
+
* How people run this, for the hints the runner prints ("Run `npx @agst/cli
|
|
35
|
+
* pair`…"). From our own package name, so the scoped and bare packages
|
|
36
|
+
* both get it right.
|
|
37
|
+
*/
|
|
38
|
+
const { name: PACKAGE } = JSON.parse(
|
|
39
|
+
fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
function fail(message) {
|
|
43
|
+
console.error(`agst: ${message}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function download(url) {
|
|
48
|
+
const response = await fetch(url);
|
|
49
|
+
if (!response.ok) throw new Error(`${response.status} for ${url}`);
|
|
50
|
+
return Buffer.from(await response.arrayBuffer());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Fetches and verifies the binary unless it's already cached. */
|
|
54
|
+
async function ensureBinary(binDir, platform) {
|
|
55
|
+
const file = path.join(binDir, `august-runner-${RUNNER_VERSION}-${platform}`);
|
|
56
|
+
if (fs.existsSync(file)) return file;
|
|
57
|
+
|
|
58
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
59
|
+
const base = `${RELEASES}/${RUNNER_VERSION}/august-runner-${platform}`;
|
|
60
|
+
process.stderr.write(`agst: fetching the August runner ${RUNNER_VERSION}…\n`);
|
|
61
|
+
let binary;
|
|
62
|
+
let signature;
|
|
63
|
+
try {
|
|
64
|
+
[binary, signature] = await Promise.all([
|
|
65
|
+
download(base),
|
|
66
|
+
download(`${base}.sig`),
|
|
67
|
+
]);
|
|
68
|
+
} catch (cause) {
|
|
69
|
+
fail(`couldn't download the runner (${cause.message}).`);
|
|
70
|
+
}
|
|
71
|
+
const key = createPublicKey({
|
|
72
|
+
key: Buffer.from(PUBLIC_KEY, "base64"),
|
|
73
|
+
format: "der",
|
|
74
|
+
type: "spki",
|
|
75
|
+
});
|
|
76
|
+
if (!verify(null, binary, key, signature)) {
|
|
77
|
+
fail("the downloaded runner failed its signature check. Not running it.");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
81
|
+
fs.writeFileSync(temp, binary, { mode: 0o755 });
|
|
82
|
+
// A binary cross-compiled for macOS carries a signature the kernel
|
|
83
|
+
// rejects; an ad-hoc re-sign (always available there) fixes it.
|
|
84
|
+
if (platform.startsWith("darwin")) {
|
|
85
|
+
try {
|
|
86
|
+
execFileSync("codesign", ["--force", "--sign", "-", temp], {
|
|
87
|
+
stdio: "ignore",
|
|
88
|
+
});
|
|
89
|
+
} catch {
|
|
90
|
+
// Unsigned may still run; the exec below will say if not.
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
fs.renameSync(temp, file);
|
|
94
|
+
return file;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Points ~/.august/bin/agst at `target`, atomically. */
|
|
98
|
+
function linkCurrent(binDir, target) {
|
|
99
|
+
const link = path.join(binDir, "agst");
|
|
100
|
+
const temp = `${link}.${process.pid}.tmp`;
|
|
101
|
+
try {
|
|
102
|
+
fs.symlinkSync(target, temp);
|
|
103
|
+
fs.renameSync(temp, link);
|
|
104
|
+
} catch {
|
|
105
|
+
fs.rmSync(temp, { force: true });
|
|
106
|
+
}
|
|
107
|
+
return link;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function main() {
|
|
111
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
112
|
+
const binDir =
|
|
113
|
+
process.env.AGST_HOME ?? path.join(os.homedir(), ".august", "bin");
|
|
114
|
+
|
|
115
|
+
let runner = process.env.AGST_RUNNER;
|
|
116
|
+
let stable = runner;
|
|
117
|
+
if (!runner) {
|
|
118
|
+
if (!PLATFORMS.has(platform)) {
|
|
119
|
+
fail(
|
|
120
|
+
`no runner build for ${platform} yet (have: ${[...PLATFORMS].join(", ")}).`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
runner = await ensureBinary(binDir, platform);
|
|
124
|
+
stable = linkCurrent(binDir, runner);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const child = spawn(runner, process.argv.slice(2), {
|
|
128
|
+
stdio: "inherit",
|
|
129
|
+
// The runner writes these into systemd units it installs.
|
|
130
|
+
env: { ...process.env, AGST_BIN: stable, AGST_CMD: `npx ${PACKAGE}` },
|
|
131
|
+
});
|
|
132
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
133
|
+
process.on(signal, () => child.kill(signal));
|
|
134
|
+
}
|
|
135
|
+
child.on("exit", (code, signal) => {
|
|
136
|
+
if (!signal) process.exit(code ?? 0);
|
|
137
|
+
// Die the same way, without our forwarder catching it again.
|
|
138
|
+
process.removeAllListeners(signal);
|
|
139
|
+
process.kill(process.pid, signal);
|
|
140
|
+
});
|
|
141
|
+
child.on("error", (cause) => fail(cause.message));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
await main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agst/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "August agent orchestrator. Run Claude Code and OpenCode agents on any machine and drive them from the August app on your Mac or phone.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"august",
|
|
7
|
+
"agents",
|
|
8
|
+
"coding-agents",
|
|
9
|
+
"claude-code",
|
|
10
|
+
"opencode",
|
|
11
|
+
"orchestrator",
|
|
12
|
+
"cli"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://agst.me",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"bin": {
|
|
18
|
+
"agst": "bin/agst.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"bin"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|