@koalaauto/agentchannel 3.57.0 → 3.57.1
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 +35 -6
- 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,36 @@ 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
|
+
try {
|
|
442
|
+
writeFileSync(mark, '', { mode: 0o600 });
|
|
443
|
+
reloadService(platform, serviceFile(specOf(own, platform), undefined, env).start, env);
|
|
444
|
+
}
|
|
445
|
+
catch (e) {
|
|
446
|
+
io.err(`[ach run] could not have the supervisor read ${own.path} again: ${e?.message ?? e}`);
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
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`);
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
if (!startsThroughNpx(own))
|
|
453
|
+
return false;
|
|
433
454
|
// the new service must be able to start: without the install (the copy failed), the old one stays as it is
|
|
434
455
|
const command = adoptFromNpx({ self: thisCliPath(), env, log: (s) => io.err(`[ach run] ${s}`) }) ?? (currentVersion(appDir(env)) ? appAch(env) : undefined);
|
|
435
456
|
if (!command)
|
|
@@ -445,8 +466,16 @@ async function moveOldService(io, who, home) {
|
|
|
445
466
|
if (!m)
|
|
446
467
|
return false;
|
|
447
468
|
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
|
-
|
|
469
|
+
if (!env.ACH_SERVICE_DIR) {
|
|
470
|
+
try {
|
|
471
|
+
reloadService(platform, m.start, env);
|
|
472
|
+
}
|
|
473
|
+
catch (e) {
|
|
474
|
+
// not reloaded: the restart would start the old command, so keep going on it rather than exit for nothing
|
|
475
|
+
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`);
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
450
479
|
return true;
|
|
451
480
|
}
|
|
452
481
|
/** 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/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.1",
|
|
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",
|