@koalaauto/agentchannel 3.78.1 → 3.78.2
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/dist/src/cli-run.d.ts +12 -3
- package/dist/src/cli-run.js +96 -21
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/cli.js +1 -1
- package/dist/src/runner/runner.d.ts +7 -5
- package/dist/src/runner/runner.js +14 -11
- package/dist/src/selfupdate.d.ts +1 -1
- package/dist/src/selfupdate.js +1 -1
- package/dist/src/service.d.ts +1 -1
- package/dist/src/service.js +2 -5
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/cli-run.d.ts
CHANGED
|
@@ -8,7 +8,19 @@ export declare function runInTerminal(line: string, env: NodeJS.ProcessEnv): Pro
|
|
|
8
8
|
* with npx or `node dist/src/cli.js`). Returns the dir to prepend to PATH.
|
|
9
9
|
*/
|
|
10
10
|
export declare function writeAchShim(home: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* `ach run`. A key that is missing or that the hub refuses does not end it: the runner waits (backing off, reading the config again
|
|
13
|
+
* each time, so a new `ach join` here is picked up) and starts again once the hub takes the key. 2026-11-24: during the ids cutover
|
|
14
|
+
* the hub refused every key for 3 minutes, and runners that exited for good on that 401 stayed down until someone restarted them.
|
|
15
|
+
*/
|
|
11
16
|
export declare function runCommand(p: Parsed, io: Io): Promise<number>;
|
|
17
|
+
/** Waits between tries for a key that works: 30 s, then longer, at most 15 minutes. ACH_AUTH_RETRY_MS: one fixed wait (tests). */
|
|
18
|
+
export declare const KEY_RETRY_MS: number[];
|
|
19
|
+
/**
|
|
20
|
+
* Until the hub takes this agent's key: read the config (a new `ach join` may have written a new key), ask the hub who this key is,
|
|
21
|
+
* wait and try again. Resolves true when the key works, false on SIGINT/SIGTERM.
|
|
22
|
+
*/
|
|
23
|
+
export declare function waitForKey(io: Io, why: string): Promise<boolean>;
|
|
12
24
|
/**
|
|
13
25
|
* `ach run` where the agent's key is not stored: the key lives only on its own machine and the hub keeps a hash of it, so it
|
|
14
26
|
* cannot be read back. The way back is a new key (the panel: the agent's page, Settings or the stopped-runner card) and its join line.
|
|
@@ -17,9 +29,6 @@ export declare const NO_KEY_MESSAGE: {
|
|
|
17
29
|
readonly en: "ach run: there is no key for this agent on this machine (deleted, or a new machine or directory).\nA key cannot be recovered: in the panel open the agent and rotate its key (an admin or its owner can), then run the new `join` line here, in the agent's project directory.";
|
|
18
30
|
readonly zh: "ach run:这台机器上没有它的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开它的页面,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。";
|
|
19
31
|
};
|
|
20
|
-
/** B7: `ach run` exit code when the hub answers 401 (systemd: RestartPreventExitStatus=78). */
|
|
21
|
-
export declare const AUTH_EXIT_CODE = 78;
|
|
22
|
-
export declare const AUTH_EXIT_MESSAGE = "ach run: key rotated or agent deactivated \u2014 run ach join";
|
|
23
32
|
/**
|
|
24
33
|
* The agent whose key this home already holds for `hub`, when it is another agent than `meId` and its key still works (a key the
|
|
25
34
|
* hub refuses belongs to nobody: replacing it loses nothing). Unknown (hub unreachable) counts as another agent: keeping a key
|
package/dist/src/cli-run.js
CHANGED
|
@@ -44,7 +44,90 @@ export function writeAchShim(home) {
|
|
|
44
44
|
chmodSync(f, 0o700);
|
|
45
45
|
return dir;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* `ach run`. A key that is missing or that the hub refuses does not end it: the runner waits (backing off, reading the config again
|
|
49
|
+
* each time, so a new `ach join` here is picked up) and starts again once the hub takes the key. 2026-11-24: during the ids cutover
|
|
50
|
+
* the hub refused every key for 3 minutes, and runners that exited for good on that 401 stayed down until someone restarted them.
|
|
51
|
+
*/
|
|
47
52
|
export async function runCommand(p, io) {
|
|
53
|
+
for (;;) {
|
|
54
|
+
const r = await runOnce(p, io);
|
|
55
|
+
if (!(r instanceof KeyRefused))
|
|
56
|
+
return r;
|
|
57
|
+
// one-shot commands (setting up the service, cleaning worktrees) say why and stop
|
|
58
|
+
if (p.values['install-service'] || p.values.gc) {
|
|
59
|
+
io.err(r.message);
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
if (!(await waitForKey(io, r.message)))
|
|
63
|
+
return 0;
|
|
64
|
+
io.err('ach run: the hub accepts the key; starting again');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Why runOnce stopped: no key here, or the hub refused it (401). */
|
|
68
|
+
class KeyRefused {
|
|
69
|
+
message;
|
|
70
|
+
constructor(message) {
|
|
71
|
+
this.message = message;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Waits between tries for a key that works: 30 s, then longer, at most 15 minutes. ACH_AUTH_RETRY_MS: one fixed wait (tests). */
|
|
75
|
+
export const KEY_RETRY_MS = [30_000, 60_000, 120_000, 300_000, 600_000, 900_000];
|
|
76
|
+
/**
|
|
77
|
+
* Until the hub takes this agent's key: read the config (a new `ach join` may have written a new key), ask the hub who this key is,
|
|
78
|
+
* wait and try again. Resolves true when the key works, false on SIGINT/SIGTERM.
|
|
79
|
+
*/
|
|
80
|
+
export async function waitForKey(io, why) {
|
|
81
|
+
const fixed = Number(io.env.ACH_AUTH_RETRY_MS);
|
|
82
|
+
const delay = (i) => (Number.isFinite(fixed) && fixed > 0 ? fixed : KEY_RETRY_MS[Math.min(i, KEY_RETRY_MS.length - 1)]);
|
|
83
|
+
io.err(`${why}
|
|
84
|
+
${isZh(io.env) ? 'ach run:先不退出,隔一段时间重试;在这里重新运行 `ach join` 换了新密钥也会自动接上。' : 'ach run: not exiting; trying again from time to time. A new `ach join` here is picked up.'}`);
|
|
85
|
+
let stop = false;
|
|
86
|
+
let wake = () => { };
|
|
87
|
+
const onSignal = () => {
|
|
88
|
+
stop = true;
|
|
89
|
+
wake();
|
|
90
|
+
};
|
|
91
|
+
process.once('SIGINT', onSignal);
|
|
92
|
+
process.once('SIGTERM', onSignal);
|
|
93
|
+
try {
|
|
94
|
+
let last = why;
|
|
95
|
+
for (let i = 0; !stop; i++) {
|
|
96
|
+
await new Promise((r) => {
|
|
97
|
+
const t = setTimeout(r, delay(i));
|
|
98
|
+
wake = () => {
|
|
99
|
+
clearTimeout(t);
|
|
100
|
+
r();
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
if (stop)
|
|
104
|
+
break;
|
|
105
|
+
let now;
|
|
106
|
+
try {
|
|
107
|
+
const cfg = loadConfig(io.env);
|
|
108
|
+
if (!cfg.key)
|
|
109
|
+
now = NO_KEY_MESSAGE[isZh(io.env) ? 'zh' : 'en'];
|
|
110
|
+
else {
|
|
111
|
+
await clientFromConfig(cfg, { fetch: io.fetch, role: 'runner' }).me();
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
now = e instanceof HubError && e.status === 401 ? `ach run: the hub refuses the key: ${e.message}` : `ach run: cannot check the key: ${e?.message ?? e}`;
|
|
117
|
+
}
|
|
118
|
+
// the same reason is said once; a change (the key works but the hub is down, a new reason) is said when it happens
|
|
119
|
+
if (now !== last)
|
|
120
|
+
io.err(now);
|
|
121
|
+
last = now;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
process.off('SIGINT', onSignal);
|
|
127
|
+
process.off('SIGTERM', onSignal);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function runOnce(p, io) {
|
|
48
131
|
const v = p.values;
|
|
49
132
|
const env = io.env;
|
|
50
133
|
if (env.ACH_RUN_TOKEN)
|
|
@@ -55,10 +138,9 @@ export async function runCommand(p, io) {
|
|
|
55
138
|
return env.ACH_SUPERVISED === '1' ? UPDATE_EXIT_CODE : superviseSelf({ log: io.err });
|
|
56
139
|
}
|
|
57
140
|
const cfg = loadConfig(env);
|
|
58
|
-
// No key on this machine (deleted, a new machine or directory)
|
|
59
|
-
// would be restarted for ever, and `ach login` is no way back for someone who no longer has the key.
|
|
141
|
+
// No key on this machine (deleted, a new machine or directory): wait for one, like a refused key (runCommand).
|
|
60
142
|
if (!cfg.key)
|
|
61
|
-
return
|
|
143
|
+
return new KeyRefused(NO_KEY_MESSAGE[isZh(env) ? 'zh' : 'en']);
|
|
62
144
|
// the hub names the newest release on every answer: the updater hears it at once instead of at its next 6-hourly check
|
|
63
145
|
let updater;
|
|
64
146
|
const c = clientFromConfig(cfg, { fetch: io.fetch, role: 'runner', onLatestClient: (latest) => void updater?.heardLatest(latest)?.catch(() => { }) });
|
|
@@ -103,9 +185,9 @@ export async function runCommand(p, io) {
|
|
|
103
185
|
me = await c.me();
|
|
104
186
|
}
|
|
105
187
|
catch (e) {
|
|
106
|
-
//
|
|
188
|
+
// a key the hub refuses at startup waits like a 401 mid-run (runCommand)
|
|
107
189
|
if (e instanceof HubError && e.status === 401)
|
|
108
|
-
return
|
|
190
|
+
return new KeyRefused(`ach run: the hub refuses the key: ${e.message}`);
|
|
109
191
|
throw e;
|
|
110
192
|
}
|
|
111
193
|
if (v['install-service'])
|
|
@@ -225,6 +307,10 @@ export async function runCommand(p, io) {
|
|
|
225
307
|
};
|
|
226
308
|
process.once('SIGINT', shutdown);
|
|
227
309
|
process.once('SIGTERM', shutdown);
|
|
310
|
+
const unhook = () => {
|
|
311
|
+
process.off('SIGINT', shutdown);
|
|
312
|
+
process.off('SIGTERM', shutdown);
|
|
313
|
+
};
|
|
228
314
|
// one runner per home: a second one would overwrite the first's state
|
|
229
315
|
let release = () => { };
|
|
230
316
|
try {
|
|
@@ -253,9 +339,11 @@ export async function runCommand(p, io) {
|
|
|
253
339
|
}
|
|
254
340
|
updater.stop();
|
|
255
341
|
desk?.stop();
|
|
256
|
-
//
|
|
257
|
-
if (end === 'unauthorized')
|
|
258
|
-
|
|
342
|
+
// the hub refused the agent key mid-run (rotated, agent disabled, owner deactivated, or the hub briefly wrong): wait for it
|
|
343
|
+
if (end === 'unauthorized') {
|
|
344
|
+
unhook();
|
|
345
|
+
return new KeyRefused(`ach run: the hub refuses the key: ${runner.fatalReason ?? 'unauthorized'}`);
|
|
346
|
+
}
|
|
259
347
|
if (updater.restarting && updater.installed === 'handoff') {
|
|
260
348
|
io.err(`ach run: exiting for the update; the installer starts the runner again when it is done`);
|
|
261
349
|
return UPDATE_HANDOFF_EXIT_CODE;
|
|
@@ -281,15 +369,6 @@ export const NO_KEY_MESSAGE = {
|
|
|
281
369
|
en: 'ach run: there is no key for this agent on this machine (deleted, or a new machine or directory).\nA key cannot be recovered: in the panel open the agent and rotate its key (an admin or its owner can), then run the new `join` line here, in the agent\'s project directory.',
|
|
282
370
|
zh: 'ach run:这台机器上没有它的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开它的页面,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。',
|
|
283
371
|
};
|
|
284
|
-
/** B7: print the rejoin hint and return the auth exit code (ACH_AUTH_EXIT_CODE overrides it). */
|
|
285
|
-
function authExit(io, message = AUTH_EXIT_MESSAGE) {
|
|
286
|
-
io.err(message);
|
|
287
|
-
const code = Number(io.env.ACH_AUTH_EXIT_CODE ?? AUTH_EXIT_CODE);
|
|
288
|
-
return Number.isInteger(code) && code >= 0 ? code : AUTH_EXIT_CODE;
|
|
289
|
-
}
|
|
290
|
-
/** B7: `ach run` exit code when the hub answers 401 (systemd: RestartPreventExitStatus=78). */
|
|
291
|
-
export const AUTH_EXIT_CODE = 78;
|
|
292
|
-
export const AUTH_EXIT_MESSAGE = 'ach run: key rotated or agent deactivated — run ach join';
|
|
293
372
|
/**
|
|
294
373
|
* P4: write a launchd plist (macOS) or systemd user unit (Linux) that runs this
|
|
295
374
|
* runner with the same flags, and load it: it runs now and at every login.
|
|
@@ -326,10 +405,6 @@ async function installService(p, io, o) {
|
|
|
326
405
|
svcEnv.AGENTCHANNEL_HOME = env.AGENTCHANNEL_HOME;
|
|
327
406
|
if (env.ACH_KEYSTORE)
|
|
328
407
|
svcEnv.ACH_KEYSTORE = env.ACH_KEYSTORE;
|
|
329
|
-
// B7: launchd restarts only after an unsuccessful exit (KeepAlive.SuccessfulExit
|
|
330
|
-
// = false), so under launchd a 401 exits 0 and the runner stays down.
|
|
331
|
-
if (platform === 'darwin')
|
|
332
|
-
svcEnv.ACH_AUTH_EXIT_CODE = '0';
|
|
333
408
|
mkdirSync(join(o.home, 'logs'), { recursive: true, mode: 0o700 });
|
|
334
409
|
const self = CLI_JS;
|
|
335
410
|
// the install in the AgentChannel home (appinstall.ts), so the service follows its updates; run through npx, this release is copied
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
export { VERSION } from './version.js';
|
|
3
3
|
import { type Io } from './cli-shared.js';
|
|
4
|
-
export {
|
|
4
|
+
export { KEY_RETRY_MS, NO_KEY_MESSAGE, waitForKey, writeAchShim } from './cli-run.js';
|
|
5
5
|
export type { Io } from './cli-shared.js';
|
|
6
6
|
export { channelFile, loginTokenOf } from './cli-shared.js';
|
|
7
7
|
/** Runs the opener and waits for it: a non-zero exit (no browser, no display) is a failure, not "opened". */
|
package/dist/src/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ import { adminCommand } from './cli-admin.js';
|
|
|
20
20
|
import { memoryCommand } from './cli-memory.js';
|
|
21
21
|
import { otherAgentHere, runCommand, runInTerminal } from './cli-run.js';
|
|
22
22
|
import { normalizeId } from './ids.js';
|
|
23
|
-
export {
|
|
23
|
+
export { KEY_RETRY_MS, NO_KEY_MESSAGE, waitForKey, writeAchShim } from './cli-run.js';
|
|
24
24
|
// moved to cli-shared.ts; still reachable from here for the code and tests that import them from cli.js
|
|
25
25
|
export { channelFile, loginTokenOf } from './cli-shared.js';
|
|
26
26
|
/** Why a task failed (docs/specs/task-failures.md); the hub's list. */
|
|
@@ -184,8 +184,10 @@ export declare class Runner {
|
|
|
184
184
|
private lastTooOld;
|
|
185
185
|
/** Last heartbeat sent for each parked run. */
|
|
186
186
|
private parkedHb;
|
|
187
|
-
/** B7: set when the hub answered 401 (key rotated, agent or owner deactivated):
|
|
187
|
+
/** B7: set when the hub answered 401 (key rotated, agent or owner deactivated, or the hub briefly wrong): this runner stops and
|
|
188
|
+
* `ach run` waits for a key that works (cli-run.ts waitForKey). `fatalReason` is what the hub said. */
|
|
188
189
|
fatal?: 'unauthorized';
|
|
190
|
+
fatalReason?: string;
|
|
189
191
|
private wake?;
|
|
190
192
|
/** The hub's change stream, when the runner follows it, and whether it said something since the last poll. */
|
|
191
193
|
private feed?;
|
|
@@ -207,10 +209,10 @@ export declare class Runner {
|
|
|
207
209
|
/** Re-claim runs that were active when the runner died (§14.10). */
|
|
208
210
|
recover(): void;
|
|
209
211
|
/**
|
|
210
|
-
* B7: a 401 from inbox, heartbeat or claim means the key
|
|
211
|
-
*
|
|
212
|
+
* B7: a 401 from inbox, heartbeat or claim means the key does not work now. Abort every job without posting anything (no fail,
|
|
213
|
+
* no usage: their runs stay on disk and resume when the runner starts again) and stop; `ach run` waits for the key.
|
|
212
214
|
*/
|
|
213
|
-
authFailed(where: string): void;
|
|
215
|
+
authFailed(where: string, e?: unknown): void;
|
|
214
216
|
/** One poll cycle. */
|
|
215
217
|
tick(): Promise<void>;
|
|
216
218
|
/** decisions §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
|
|
@@ -369,7 +371,7 @@ export declare class Runner {
|
|
|
369
371
|
* reaches it).
|
|
370
372
|
*/
|
|
371
373
|
private toolsFor;
|
|
372
|
-
/** Polls until stop() or a 401 (B7: resolves 'unauthorized' after aborting every job). */
|
|
374
|
+
/** Polls until stop() or a 401 (B7: resolves 'unauthorized' after aborting every job; `ach run` then waits for the key). */
|
|
373
375
|
start(): Promise<'stopped' | 'unauthorized'>;
|
|
374
376
|
/** Stop polling; abort running jobs without failing their tasks (they resume on restart). */
|
|
375
377
|
stop(): Promise<void>;
|
|
@@ -204,8 +204,10 @@ export class Runner {
|
|
|
204
204
|
lastTooOld = 0;
|
|
205
205
|
/** Last heartbeat sent for each parked run. */
|
|
206
206
|
parkedHb = new Map();
|
|
207
|
-
/** B7: set when the hub answered 401 (key rotated, agent or owner deactivated):
|
|
207
|
+
/** B7: set when the hub answered 401 (key rotated, agent or owner deactivated, or the hub briefly wrong): this runner stops and
|
|
208
|
+
* `ach run` waits for a key that works (cli-run.ts waitForKey). `fatalReason` is what the hub said. */
|
|
208
209
|
fatal;
|
|
210
|
+
fatalReason;
|
|
209
211
|
wake;
|
|
210
212
|
/** The hub's change stream, when the runner follows it, and whether it said something since the last poll. */
|
|
211
213
|
feed;
|
|
@@ -265,15 +267,16 @@ export class Runner {
|
|
|
265
267
|
}
|
|
266
268
|
}
|
|
267
269
|
/**
|
|
268
|
-
* B7: a 401 from inbox, heartbeat or claim means the key
|
|
269
|
-
*
|
|
270
|
+
* B7: a 401 from inbox, heartbeat or claim means the key does not work now. Abort every job without posting anything (no fail,
|
|
271
|
+
* no usage: their runs stay on disk and resume when the runner starts again) and stop; `ach run` waits for the key.
|
|
270
272
|
*/
|
|
271
|
-
authFailed(where) {
|
|
273
|
+
authFailed(where, e) {
|
|
272
274
|
if (this.fatal)
|
|
273
275
|
return;
|
|
274
276
|
this.fatal = 'unauthorized';
|
|
277
|
+
this.fatalReason = e instanceof HubError ? e.message : undefined;
|
|
275
278
|
this.stopped = true;
|
|
276
|
-
this.log(`${where}: 401 from the hub;
|
|
279
|
+
this.log(`${where}: 401 from the hub${this.fatalReason ? ` (${this.fatalReason})` : ''}; pausing until the key works`);
|
|
277
280
|
this.queue.length = 0;
|
|
278
281
|
for (const a of this.active.values()) {
|
|
279
282
|
a.reason = 'auth';
|
|
@@ -289,7 +292,7 @@ export class Runner {
|
|
|
289
292
|
}
|
|
290
293
|
catch (e) {
|
|
291
294
|
if (is401(e))
|
|
292
|
-
return this.authFailed('inbox');
|
|
295
|
+
return this.authFailed('inbox', e);
|
|
293
296
|
throw e;
|
|
294
297
|
}
|
|
295
298
|
await this.checkActive();
|
|
@@ -409,7 +412,7 @@ export class Runner {
|
|
|
409
412
|
}
|
|
410
413
|
catch (e) {
|
|
411
414
|
if (is401(e))
|
|
412
|
-
this.authFailed('setup');
|
|
415
|
+
this.authFailed('setup', e);
|
|
413
416
|
// an older hub without /me/setup: the log above is all there is
|
|
414
417
|
else if (e instanceof HubError && e.status === 404)
|
|
415
418
|
this.setupReported = key;
|
|
@@ -753,7 +756,7 @@ export class Runner {
|
|
|
753
756
|
}
|
|
754
757
|
catch (e) {
|
|
755
758
|
if (is401(e))
|
|
756
|
-
this.authFailed(`heartbeat ${rec.taskId}
|
|
759
|
+
this.authFailed(`heartbeat ${rec.taskId}`, e);
|
|
757
760
|
throw e;
|
|
758
761
|
}
|
|
759
762
|
if (r?.run_token) {
|
|
@@ -918,7 +921,7 @@ export class Runner {
|
|
|
918
921
|
}
|
|
919
922
|
catch (e) {
|
|
920
923
|
if (is401(e))
|
|
921
|
-
return this.authFailed(`prepare ${taskId}
|
|
924
|
+
return this.authFailed(`prepare ${taskId}`, e);
|
|
922
925
|
this.taskLog(taskId, `read-ahead: ${e?.message ?? e}`);
|
|
923
926
|
// a 404 for a task that exists is a hub without the route: stop reading ahead, the next poll works the task as before
|
|
924
927
|
if (e instanceof HubError && e.status === 404 && (await client.getTask(taskId).then(() => true, () => false))) {
|
|
@@ -993,7 +996,7 @@ export class Runner {
|
|
|
993
996
|
}
|
|
994
997
|
catch (e) {
|
|
995
998
|
if (is401(e))
|
|
996
|
-
return this.authFailed(`claim ${taskId}
|
|
999
|
+
return this.authFailed(`claim ${taskId}`, e);
|
|
997
1000
|
if (e instanceof HubError && e.code === 'budget_exceeded') {
|
|
998
1001
|
this.me = await this.o.client.me();
|
|
999
1002
|
const t = (await this.o.client.getTask(taskId)).task;
|
|
@@ -1953,7 +1956,7 @@ export class Runner {
|
|
|
1953
1956
|
return { servers, skills: runSkills, ...(runSkills.length ? { pluginDir: copied.pluginDir } : {}) };
|
|
1954
1957
|
}
|
|
1955
1958
|
// ---- the execution trace -------------------------------------------------------------------------------------------------
|
|
1956
|
-
/** Polls until stop() or a 401 (B7: resolves 'unauthorized' after aborting every job). */
|
|
1959
|
+
/** Polls until stop() or a 401 (B7: resolves 'unauthorized' after aborting every job; `ach run` then waits for the key). */
|
|
1957
1960
|
async start() {
|
|
1958
1961
|
this.recover();
|
|
1959
1962
|
this.pump();
|
package/dist/src/selfupdate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** A restart-worthy exit: not 0 (systemd on-failure and launchd restart only a failure)
|
|
1
|
+
/** A restart-worthy exit: not 0 (systemd on-failure and launchd restart only a failure). */
|
|
2
2
|
export declare const UPDATE_EXIT_CODE = 75;
|
|
3
3
|
/** Windows: the runner exited so that a helper can install the release (windowsHandoff); the process tree ends, nothing restarts here. */
|
|
4
4
|
export declare const UPDATE_HANDOFF_EXIT_CODE = 76;
|
package/dist/src/selfupdate.js
CHANGED
|
@@ -22,7 +22,7 @@ import { dirname, join, sep } from 'node:path';
|
|
|
22
22
|
import { appDir, appWritable, currentVersion, inApp, installIntoApp, setCurrent } from './appinstall.js';
|
|
23
23
|
import { thisCliPath } from './invite.js';
|
|
24
24
|
import { CLIENT_PROTO, newerVersion, PKG_NAME, VERSION } from './version.js';
|
|
25
|
-
/** A restart-worthy exit: not 0 (systemd on-failure and launchd restart only a failure)
|
|
25
|
+
/** A restart-worthy exit: not 0 (systemd on-failure and launchd restart only a failure). */
|
|
26
26
|
export const UPDATE_EXIT_CODE = 75;
|
|
27
27
|
/** Windows: the runner exited so that a helper can install the release (windowsHandoff); the process tree ends, nothing restarts here. */
|
|
28
28
|
export const UPDATE_HANDOFF_EXIT_CODE = 76;
|
package/dist/src/service.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function launchdPlist(s: ServiceSpec): string;
|
|
|
26
26
|
export declare function systemdUnit(s: ServiceSpec): string;
|
|
27
27
|
/**
|
|
28
28
|
* Windows: a VBScript in the Startup folder. It runs the runner with no window, appends its output to the log, and
|
|
29
|
-
* starts it again 10 s after it exits
|
|
29
|
+
* starts it again 10 s after it exits.
|
|
30
30
|
*/
|
|
31
31
|
export declare function windowsScript(s: ServiceSpec): string;
|
|
32
32
|
export declare function serviceFile(s: ServiceSpec, dir?: string, env?: NodeJS.ProcessEnv): ServiceFile;
|
package/dist/src/service.js
CHANGED
|
@@ -65,8 +65,6 @@ ExecStart=${exec}
|
|
|
65
65
|
${env}
|
|
66
66
|
Restart=on-failure
|
|
67
67
|
RestartSec=10
|
|
68
|
-
# B7: exit 78 = key rotated or agent deactivated; restarting cannot help.
|
|
69
|
-
RestartPreventExitStatus=78
|
|
70
68
|
|
|
71
69
|
[Install]
|
|
72
70
|
WantedBy=default.target
|
|
@@ -82,12 +80,12 @@ function cmdArg(s) {
|
|
|
82
80
|
}
|
|
83
81
|
/**
|
|
84
82
|
* Windows: a VBScript in the Startup folder. It runs the runner with no window, appends its output to the log, and
|
|
85
|
-
* starts it again 10 s after it exits
|
|
83
|
+
* starts it again 10 s after it exits.
|
|
86
84
|
*/
|
|
87
85
|
export function windowsScript(s) {
|
|
88
86
|
const line = `${[...s.command, 'run', ...s.args].map(cmdArg).join(' ')} >> ${cmdArg(s.logFile)} 2>&1`;
|
|
89
87
|
const env = Object.entries(s.env).map(([k, v]) => `env(${vbs(k)}) = ${vbs(v)}`).join('\n');
|
|
90
|
-
return `' AgentChannel runner (agent ${s.agentName}): starts at login, restarts after it exits
|
|
88
|
+
return `' AgentChannel runner (agent ${s.agentName}): starts at login, restarts after it exits.
|
|
91
89
|
Option Explicit
|
|
92
90
|
Dim sh, env, code
|
|
93
91
|
Set sh = CreateObject("WScript.Shell")
|
|
@@ -95,7 +93,6 @@ Set env = sh.Environment("Process")
|
|
|
95
93
|
${env}
|
|
96
94
|
Do
|
|
97
95
|
code = sh.Run("cmd /c " & ${vbs(`"${line}"`)}, 0, True)
|
|
98
|
-
If code = 78 Then Exit Do
|
|
99
96
|
WScript.Sleep 10000
|
|
100
97
|
Loop
|
|
101
98
|
`;
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaauto/agentchannel",
|
|
3
|
-
"version": "3.78.
|
|
3
|
+
"version": "3.78.2",
|
|
4
4
|
"description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentchannel",
|