@koalaauto/agentchannel 3.82.0 → 3.82.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/README.md CHANGED
@@ -83,7 +83,8 @@ Your hub names the newest `ach` release (`ach doctor` shows it), and the backgro
83
83
  new tasks, lets the runs in flight finish, installs the release (`npm install -g` for a global install; an `npx` start
84
84
  fetches it itself) and exits with code 75, which systemd and launchd restart. It never crosses to a new major release
85
85
  by itself, never moves a stable install onto a prerelease, leaves a source checkout alone, and tries a failed update
86
- again only after a day. `ACH_AUTO_UPDATE=0` turns the installing off; it still says so in the log.
86
+ again only after a day (a release npm does not serve yet, right after it is published, is tried again in five minutes).
87
+ `ACH_AUTO_UPDATE=0` turns the installing off; it still says so in the log.
87
88
  - **A session (`ach mcp`, started by Claude Code or Codex)** cannot be restarted from outside: it gets one line in the
88
89
  session saying it is behind. Restart the session (`npx` installs pick up the new release); run
89
90
  `npm install -g @koalaauto/agentchannel@latest` first if `ach` is installed globally.
package/dist/src/cli.js CHANGED
@@ -1032,7 +1032,10 @@ async function dispatch(p, io) {
1032
1032
  const cwd = io.cwd ?? process.cwd();
1033
1033
  const sess = sessionHome(cwd, env);
1034
1034
  const menv = sess.how === 'dir' ? { ...env, AGENTCHANNEL_HOME: sess.home } : env;
1035
- await startMcp(clientFromConfig(loadConfig(menv), { fetch: io.fetch }), { cwd, dir: sess.dir });
1035
+ // every answer names the newest release: this machine's install moves on to it even with no runner here (mcpupdate.ts)
1036
+ const { mcpUpdater } = await import('./mcpupdate.js');
1037
+ const upd = mcpUpdater({ env: menv, log: (s) => process.stderr.write(`[ach mcp] ${s}\n`) });
1038
+ await startMcp(clientFromConfig(loadConfig(menv), { fetch: io.fetch, onLatestClient: (latest) => void upd.heard(latest)?.catch(() => { }) }), { cwd, dir: sess.dir });
1036
1039
  return await new Promise(() => { }); // stdio server runs until killed
1037
1040
  }
1038
1041
  case 'caps': {
@@ -0,0 +1,12 @@
1
+ import { type InstallExec } from './appinstall.js';
2
+ export interface McpUpdater {
3
+ heard(latest: string): Promise<string> | undefined;
4
+ }
5
+ export declare function mcpUpdater(o?: {
6
+ env?: NodeJS.ProcessEnv;
7
+ self?: string;
8
+ version?: string;
9
+ exec?: InstallExec;
10
+ now?: () => number;
11
+ log?: (s: string) => void;
12
+ }): McpUpdater;
@@ -0,0 +1,43 @@
1
+ // The MCP server keeps this machine's install current by itself (docs/decisions.md §47).
2
+ //
3
+ // The install in the AgentChannel home (appinstall.ts: app/current names the release every `ach` here starts) was only ever moved on
4
+ // by a runner's updater. A machine whose runner had stopped kept starting the old release in every Claude Code or Codex session, so
5
+ // nothing new (the runner watchdog, a fix) ever reached it. Every hub answer names the newest release (x-ach-latest-client): when it
6
+ // is newer and this MCP runs from that install, it installs it there and points `current` at it. This session goes on with the
7
+ // files it has; the next one starts the new release.
8
+ import { appDir, appWritable, inApp, installIntoApp } from './appinstall.js';
9
+ import { thisCliPath } from './invite.js';
10
+ import { defaultInstallExec } from './selfupdate.js';
11
+ import { newerVersion, VERSION } from './version.js';
12
+ const isVersion = (v) => /^\d+\.\d+\.\d+$/.test(v);
13
+ export function mcpUpdater(o = {}) {
14
+ const env = o.env ?? process.env;
15
+ const now = o.now ?? Date.now;
16
+ const tried = new Map();
17
+ let working = false;
18
+ return {
19
+ heard(latest) {
20
+ if (env.ACH_AUTO_UPDATE === '0' || working || !isVersion(latest) || !newerVersion(latest, o.version ?? VERSION))
21
+ return undefined;
22
+ const app = appDir(env);
23
+ if (!inApp(o.self ?? thisCliPath(), app))
24
+ return undefined; // npx re-resolves by itself, a global install is its runner's or its person's
25
+ const at = tried.get(latest);
26
+ if (at !== undefined && now() - at < 10 * 60_000)
27
+ return undefined; // npm serves a release a minute or two after the hub names it
28
+ tried.set(latest, now());
29
+ if (!appWritable(app))
30
+ return Promise.resolve('not writable');
31
+ working = true;
32
+ return installIntoApp(app, latest, o.exec ?? defaultInstallExec)
33
+ .then((r) => {
34
+ o.log?.(r.ok ? `${r.detail}: the next session starts it` : r.detail);
35
+ return r.ok ? `installed ${latest}` : 'failed';
36
+ })
37
+ .catch((e) => `failed: ${e?.message ?? e}`)
38
+ .finally(() => {
39
+ working = false;
40
+ });
41
+ },
42
+ };
43
+ }
@@ -27,6 +27,8 @@ 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;
29
29
  const DAY_MS = 24 * 3600_000;
30
+ /** npm's answer when the version is not (yet) served where it asked: E404, ETARGET / No matching version. */
31
+ const NOT_ON_NPM = /\bE404\b|\b404 Not Found\b|npm error 404|\bETARGET\b|No matching version found/i;
30
32
  const CHECK_EVERY_MS = 6 * 3600_000;
31
33
  const isVersion = (v) => typeof v === 'string' && /^\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?$/.test(v);
32
34
  const major = (v) => Number(v.split('.')[0]);
@@ -287,6 +289,7 @@ export class SelfUpdater {
287
289
  try {
288
290
  this.log(`ach ${v.target} is out (this is ${version}): taking no new work, ${this.o.runner.busy()} run(s) to finish first`);
289
291
  await this.o.runner.quiesce();
292
+ const before = loadUpdateState(this.o.home);
290
293
  saveUpdateState(this.o.home, { target: v.target, at: now, attempts: (last?.attempts ?? 0) + 1, previous: version });
291
294
  if ((this.o.platform ?? process.platform) === 'win32' && kind.kind === 'global') {
292
295
  // Windows will not replace files a running process holds (its native modules: npm EBUSY, and the install left half
@@ -305,7 +308,13 @@ export class SelfUpdater {
305
308
  }
306
309
  const r = await installRelease(kind, v.target, this.o.exec);
307
310
  if (!r.ok) {
308
- this.log(`update to ${v.target} failed: ${r.detail}; staying on ${version}`);
311
+ // npm said "no such version" although its view had just named it: the release is still spreading over npm's servers
312
+ // (seen 2026-11-24, a 404 five minutes after publish). That is no failed install: it is tried again in five minutes
313
+ // (heardLatest), not after the day's back-off, which kept every runner that met it a day behind.
314
+ const notYet = NOT_ON_NPM.test(r.detail);
315
+ if (notYet)
316
+ saveUpdateState(this.o.home, before);
317
+ this.log(`update to ${v.target} failed: ${r.detail}; staying on ${version}${notYet ? ' (npm does not serve it yet; trying again soon)' : ''}`);
309
318
  this.o.runner.unquiesce();
310
319
  return 'failed';
311
320
  }
@@ -1,11 +1,13 @@
1
- export declare const VERSION = "3.82.0";
1
+ export declare const VERSION = "3.82.2";
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
  /**
5
5
  * What this CLI says about itself on every request (x-ach-proto). The hub's ACH_MIN_CLIENT_PROTO refuses a CLI below its
6
6
  * floor. Raise this only when the CLI starts to need something an older hub does not have, and a hub only when it can no
7
- * longer serve the older CLIs: docs/api/README.md, "Client compatibility". 1 = the CLI announces itself (3.5). 2 = ids carry a kind letter and the hub may be read-only (3.75, 2026-11-24).
7
+ * longer serve the older CLIs: docs/api/README.md, "Client compatibility". 1 = the CLI announces itself (3.5). 2 = ids carry a kind letter and the hub may be read-only (3.77, 2026-11-24).
8
8
  */
9
9
  export declare const CLIENT_PROTO = 2;
10
+ /** The first release of each protocol: scripts/deploy.mjs refuses a floor raise while runners in use are older (decisions §47). */
11
+ export declare const PROTO_SINCE: Record<number, string>;
10
12
  /** True when version a is newer than b (x.y.z, a release beats its own prereleases; prerelease parts compared by number when numeric). */
11
13
  export declare function newerVersion(a: string, b: string): boolean;
@@ -1,12 +1,14 @@
1
- export const VERSION = '3.82.0';
1
+ export const VERSION = '3.82.2';
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
  /**
5
5
  * What this CLI says about itself on every request (x-ach-proto). The hub's ACH_MIN_CLIENT_PROTO refuses a CLI below its
6
6
  * floor. Raise this only when the CLI starts to need something an older hub does not have, and a hub only when it can no
7
- * longer serve the older CLIs: docs/api/README.md, "Client compatibility". 1 = the CLI announces itself (3.5). 2 = ids carry a kind letter and the hub may be read-only (3.75, 2026-11-24).
7
+ * longer serve the older CLIs: docs/api/README.md, "Client compatibility". 1 = the CLI announces itself (3.5). 2 = ids carry a kind letter and the hub may be read-only (3.77, 2026-11-24).
8
8
  */
9
9
  export const CLIENT_PROTO = 2;
10
+ /** The first release of each protocol: scripts/deploy.mjs refuses a floor raise while runners in use are older (decisions §47). */
11
+ export const PROTO_SINCE = { 1: '3.5.0', 2: '3.77.0' };
10
12
  /** True when version a is newer than b (x.y.z, a release beats its own prereleases; prerelease parts compared by number when numeric). */
11
13
  export function newerVersion(a, b) {
12
14
  const parse = (v) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalaauto/agentchannel",
3
- "version": "3.82.0",
3
+ "version": "3.82.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",