@koalaauto/agentchannel 3.57.0 → 3.57.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.js +38 -6
- package/dist/src/selfupdate.js +11 -2
- package/dist/src/servicefix.d.ts +8 -2
- package/dist/src/servicefix.js +12 -2
- 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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `ach run`: the runner on this machine. Starting it (one per agent home, a lock), its self-update supervision, and installing
|
|
2
2
|
// it as a user service (systemd, launchd) that starts it again after a reboot or an update.
|
|
3
3
|
import { execFileSync, execSync, spawn } from 'node:child_process';
|
|
4
|
-
import { chmodSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { chmodSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { basename, delimiter, dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { tmpdir } from 'node:os';
|
|
7
7
|
import { developerDir } from './adapters/scope.js';
|
|
@@ -421,15 +421,39 @@ async function moveOldService(io, who, home) {
|
|
|
421
421
|
const platform = (env.ACH_SERVICE_PLATFORM || process.platform);
|
|
422
422
|
if (platform !== 'darwin' && platform !== 'linux')
|
|
423
423
|
return false;
|
|
424
|
-
const { migrateOldService, ownService,
|
|
424
|
+
const { migrateOldService, ownService, reloadService, startedByService, startsThroughNpx } = await import('./servicefix.js');
|
|
425
|
+
const { serviceFile, specOf } = await import('./service.js');
|
|
426
|
+
const { VERSION } = await import('./version.js');
|
|
425
427
|
const own = ownService({ ...who, platform, dir: env.ACH_SERVICE_DIR || undefined, env, home });
|
|
426
|
-
if (!own
|
|
428
|
+
if (!own)
|
|
427
429
|
return false;
|
|
428
430
|
// launchd names the service by its file's label: a renamed agent's service still has the old name
|
|
429
431
|
if (!env.ACH_SERVICE_DIR && !startedByService(own.agentName, platform, env))
|
|
430
432
|
return false;
|
|
431
|
-
const { adoptFromNpx, appAch, appDir, currentVersion } = await import('./appinstall.js');
|
|
433
|
+
const { adoptFromNpx, appAch, appDir, currentVersion, npxModulesOf } = await import('./appinstall.js');
|
|
432
434
|
const { thisCliPath } = await import('./invite.js');
|
|
435
|
+
if (own.format === 'app' && npxModulesOf(thisCliPath())) {
|
|
436
|
+
// the file starts the install but this run came from npx: the supervisor still holds the old unit (3.55 to 3.57 rewrote it
|
|
437
|
+
// and its reload died with the runner). Reload once per release: a reload that does not help must not become a restart loop.
|
|
438
|
+
const mark = join(home, `reload-${VERSION}`);
|
|
439
|
+
if (env.ACH_SERVICE_DIR || existsSync(mark))
|
|
440
|
+
return false;
|
|
441
|
+
// this release goes into the install first: the launcher would otherwise start the older one copied when the file was rewritten
|
|
442
|
+
if (!adoptFromNpx({ self: thisCliPath(), env, log: (s) => io.err(`[ach run] ${s}`) }))
|
|
443
|
+
return false;
|
|
444
|
+
try {
|
|
445
|
+
writeFileSync(mark, '', { mode: 0o600 });
|
|
446
|
+
reloadService(platform, serviceFile(specOf(own, platform), undefined, env).start, env);
|
|
447
|
+
}
|
|
448
|
+
catch (e) {
|
|
449
|
+
io.err(`[ach run] could not have the supervisor read ${own.path} again: ${e?.message ?? e}`);
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
io.err(`[ach run] ${own.path} starts the install in the AgentChannel home, but this run came from npx (the supervisor held the old file): reloaded it`);
|
|
453
|
+
return true;
|
|
454
|
+
}
|
|
455
|
+
if (!startsThroughNpx(own))
|
|
456
|
+
return false;
|
|
433
457
|
// the new service must be able to start: without the install (the copy failed), the old one stays as it is
|
|
434
458
|
const command = adoptFromNpx({ self: thisCliPath(), env, log: (s) => io.err(`[ach run] ${s}`) }) ?? (currentVersion(appDir(env)) ? appAch(env) : undefined);
|
|
435
459
|
if (!command)
|
|
@@ -445,8 +469,16 @@ async function moveOldService(io, who, home) {
|
|
|
445
469
|
if (!m)
|
|
446
470
|
return false;
|
|
447
471
|
io.err(`[ach run] this service started ach through the npx cache: rewrote ${m.path} to start ${command.join(' ')} and reloading it`);
|
|
448
|
-
if (!env.ACH_SERVICE_DIR)
|
|
449
|
-
|
|
472
|
+
if (!env.ACH_SERVICE_DIR) {
|
|
473
|
+
try {
|
|
474
|
+
reloadService(platform, m.start, env);
|
|
475
|
+
}
|
|
476
|
+
catch (e) {
|
|
477
|
+
// not reloaded: the restart would start the old command, so keep going on it rather than exit for nothing
|
|
478
|
+
io.err(`[ach run] could not have the supervisor read the rewritten service (${e?.message ?? e}); it takes effect at the next reboot or reload`);
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
450
482
|
return true;
|
|
451
483
|
}
|
|
452
484
|
/** A runner of the install in the AgentChannel home points the `ach` MCP entries that still start npx at it (mcpmove.ts). */
|
package/dist/src/selfupdate.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { execFile, spawn } from 'node:child_process';
|
|
20
20
|
import { accessSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
21
21
|
import { dirname, join, sep } from 'node:path';
|
|
22
|
-
import { appDir, appWritable, inApp, installIntoApp, setCurrent } from './appinstall.js';
|
|
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
25
|
/** A restart-worthy exit: not 0 (systemd on-failure and launchd restart only a failure) and not 78 (key refused: do not restart). */
|
|
@@ -123,8 +123,17 @@ export async function preflight(kind, target, exec = defaultInstallExec) {
|
|
|
123
123
|
export async function installRelease(kind, target, exec = defaultInstallExec) {
|
|
124
124
|
if (kind.kind === 'other')
|
|
125
125
|
return { ok: false, detail: kind.why };
|
|
126
|
-
if (kind.kind === 'npx')
|
|
126
|
+
if (kind.kind === 'npx') {
|
|
127
|
+
// a home install already here (appinstall.ts): the restart may start its launcher instead of npx (the service was moved to it, or
|
|
128
|
+
// is moved at that start), and the launcher must not find an older release there
|
|
129
|
+
const app = appDir();
|
|
130
|
+
if (currentVersion(app)) {
|
|
131
|
+
const r = await installIntoApp(app, target, exec);
|
|
132
|
+
if (!r.ok)
|
|
133
|
+
return r;
|
|
134
|
+
}
|
|
127
135
|
return { ok: true, detail: 'npx fetches it on restart' };
|
|
136
|
+
}
|
|
128
137
|
if (kind.kind === 'app')
|
|
129
138
|
return installIntoApp(kind.dir, target, exec);
|
|
130
139
|
const r = await exec('npm', ['install', '-g', '--ignore-scripts', '--no-audit', '--no-fund', `${PKG_NAME}@${target}`], { timeoutMs: 5 * 60_000 });
|
package/dist/src/servicefix.d.ts
CHANGED
|
@@ -58,5 +58,11 @@ export declare function migrateOldService(o: {
|
|
|
58
58
|
home: string;
|
|
59
59
|
command: string[];
|
|
60
60
|
}): Migration | null;
|
|
61
|
-
/**
|
|
62
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Make the supervisor start the rewritten file, from the runner that is about to exit 75. systemd kills every process of the unit's
|
|
63
|
+
* cgroup when the runner exits, a detached shell included (2026-11-20: seven units were rewritten and none reloaded), but it reads the
|
|
64
|
+
* unit again on daemon-reload, and its restart after exit 75 then starts the new ExecStart: so on Linux only that, now, waited for.
|
|
65
|
+
* launchd keeps the loaded plist until it is booted out and in again, which stops this process: a detached shell (its own process
|
|
66
|
+
* group, which launchd leaves alone) does that after it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function reloadService(platform: ServiceSpec['platform'], start: string[], env: NodeJS.ProcessEnv, run?: (file: string, args: string[]) => void): void;
|
package/dist/src/servicefix.js
CHANGED
|
@@ -91,8 +91,18 @@ export function migrateOldService(o) {
|
|
|
91
91
|
writeServiceFile(f);
|
|
92
92
|
return { path: f.path, start: f.start };
|
|
93
93
|
}
|
|
94
|
-
/**
|
|
95
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Make the supervisor start the rewritten file, from the runner that is about to exit 75. systemd kills every process of the unit's
|
|
96
|
+
* cgroup when the runner exits, a detached shell included (2026-11-20: seven units were rewritten and none reloaded), but it reads the
|
|
97
|
+
* unit again on daemon-reload, and its restart after exit 75 then starts the new ExecStart: so on Linux only that, now, waited for.
|
|
98
|
+
* launchd keeps the loaded plist until it is booted out and in again, which stops this process: a detached shell (its own process
|
|
99
|
+
* group, which launchd leaves alone) does that after it.
|
|
100
|
+
*/
|
|
101
|
+
export function reloadService(platform, start, env, run = (f, a) => void execFileSync(f, a, { env, stdio: 'ignore', timeout: 30_000 })) {
|
|
102
|
+
if (platform === 'linux') {
|
|
103
|
+
run('systemctl', ['--user', 'daemon-reload']);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
96
106
|
const child = spawn('/bin/sh', ['-c', `sleep 2; ${start.join(' && ')}`], { env, detached: true, stdio: 'ignore' });
|
|
97
107
|
child.unref();
|
|
98
108
|
}
|
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.57.
|
|
3
|
+
"version": "3.57.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",
|