@koalaauto/agentchannel 3.78.1 → 3.79.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.
@@ -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): the runner stops. */
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 no longer works.
269
- * Abort every job without posting anything (no fail, no usage) and stop.
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; stopping`);
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();
@@ -1,4 +1,4 @@
1
- /** A restart-worthy exit: not 0 (systemd on-failure and launchd restart only a failure) and not 78 (key refused: do not restart). */
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;
@@ -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) and not 78 (key refused: do not restart). */
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;
@@ -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, except after exit 78 (key rotated or agent deactivated: restarting cannot help).
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;
@@ -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, except after exit 78 (key rotated or agent deactivated: restarting cannot help).
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 (not after exit 78).
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
  `;
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.78.1";
1
+ export declare const VERSION = "3.79.0";
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export declare const PKG_NAME = "@koalaauto/agentchannel";
4
4
  /**
@@ -1,4 +1,4 @@
1
- export const VERSION = '3.78.1';
1
+ export const VERSION = '3.79.0';
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export const PKG_NAME = '@koalaauto/agentchannel';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalaauto/agentchannel",
3
- "version": "3.78.1",
3
+ "version": "3.79.0",
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",