@agst/cli 0.2.5 → 0.2.7

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.
Files changed (2) hide show
  1. package/bin/agst.js +41 -15
  2. package/package.json +1 -1
package/bin/agst.js CHANGED
@@ -25,7 +25,7 @@ import os from "node:os";
25
25
  import path from "node:path";
26
26
 
27
27
  /** The runner this launcher ships with. Bumped with every agst release. */
28
- const RUNNER_VERSION = "0.3.5";
28
+ const RUNNER_VERSION = "0.3.6";
29
29
  const RELEASES =
30
30
  process.env.AGST_RELEASES_URL ?? "https://releases.agst.me/runner";
31
31
  /** The runner signing key (SPKI, base64): the same one sandboxes verify. */
@@ -133,6 +133,24 @@ function newer(a, b) {
133
133
  return false;
134
134
  }
135
135
 
136
+ /**
137
+ * The file the agst service is running right now (resolved, as the kernel
138
+ * sees it), or undefined if it isn't running or there's no systemd.
139
+ */
140
+ function serviceBinary() {
141
+ try {
142
+ const pid = execFileSync(
143
+ "systemctl",
144
+ ["--user", "show", "agst.service", "-p", "MainPID", "--value"],
145
+ { encoding: "utf8" },
146
+ ).trim();
147
+ if (!pid || pid === "0") return undefined;
148
+ return fs.readlinkSync(`/proc/${pid}/exe`);
149
+ } catch {
150
+ return undefined;
151
+ }
152
+ }
153
+
136
154
  /**
137
155
  * `agst update`: bring this box to the newest release and restart the
138
156
  * service onto it. Runs in the newest launcher: an older one (a stale npx
@@ -175,24 +193,32 @@ async function update(binDir, platform) {
175
193
  }
176
194
  const runner = await ensureBinary(binDir, platform);
177
195
  linkCurrent(binDir, runner);
196
+ const hasUnit = process.platform === "linux" && fs.existsSync(UNIT_FILE);
178
197
 
179
198
  if (previous === RUNNER_VERSION) {
180
- console.log(`agst: already on the newest runner (${RUNNER_VERSION}).`);
181
- return;
182
- }
183
- console.log(
184
- `agst: runner ${previous ? `${previous} → ` : ""}${RUNNER_VERSION}.`,
185
- );
186
-
187
- // Keep the current binary and the one before it (a quick way back).
188
- for (const name of fs.readdirSync(binDir)) {
189
- const version = versionOf(name);
190
- if (!version || version === RUNNER_VERSION || version === previous)
191
- continue;
192
- fs.rmSync(path.join(binDir, name), { force: true });
199
+ // The link can be current while the service still runs the old binary:
200
+ // an earlier update linked it and then failed before the restart.
201
+ const running = hasUnit ? serviceBinary() : undefined;
202
+ if (!running || running === fs.realpathSync(runner)) {
203
+ console.log(`agst: already on the newest runner (${RUNNER_VERSION}).`);
204
+ return;
205
+ }
206
+ console.log(`agst: the service is behind, moving it to ${RUNNER_VERSION}.`);
207
+ } else {
208
+ console.log(
209
+ `agst: runner ${previous ? `${previous} → ` : ""}${RUNNER_VERSION}.`,
210
+ );
211
+
212
+ // Keep the current binary and the one before it (a quick way back).
213
+ for (const name of fs.readdirSync(binDir)) {
214
+ const version = versionOf(name);
215
+ if (!version || version === RUNNER_VERSION || version === previous)
216
+ continue;
217
+ fs.rmSync(path.join(binDir, name), { force: true });
218
+ }
193
219
  }
194
220
 
195
- if (process.platform === "linux" && fs.existsSync(UNIT_FILE)) {
221
+ if (hasUnit) {
196
222
  try {
197
223
  execFileSync("systemctl", ["--user", "restart", "agst.service"], {
198
224
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agst/cli",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
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
5
  "keywords": [
6
6
  "august",