@koalaauto/agentchannel 3.53.4 → 3.55.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.
- package/README.md +5 -2
- package/dist/src/adapters/antigravity.d.ts +154 -0
- package/dist/src/adapters/antigravity.js +345 -0
- package/dist/src/adapters/claude.d.ts +24 -0
- package/dist/src/adapters/claude.js +2 -0
- package/dist/src/adapters/codex.d.ts +24 -1
- package/dist/src/adapters/codex.js +2 -1
- package/dist/src/adapters/fake.d.ts +6 -3
- package/dist/src/adapters/fake.js +21 -5
- package/dist/src/adapters/index.d.ts +2 -0
- package/dist/src/adapters/index.js +7 -1
- package/dist/src/adapters/kiro.d.ts +20 -2
- package/dist/src/adapters/kiro.js +2 -2
- package/dist/src/adapters/spec.d.ts +164 -0
- package/dist/src/adapters/spec.js +104 -0
- package/dist/src/adapters/types.d.ts +4 -7
- package/dist/src/agycheck.d.ts +21 -0
- package/dist/src/agycheck.js +58 -0
- package/dist/src/appinstall.d.ts +54 -0
- package/dist/src/appinstall.js +216 -0
- package/dist/src/args.d.ts +1 -1
- package/dist/src/args.js +3 -2
- package/dist/src/cli-run.js +93 -26
- package/dist/src/client.d.ts +19 -0
- package/dist/src/doctor.d.ts +3 -3
- package/dist/src/doctor.js +13 -7
- package/dist/src/invite.js +6 -2
- package/dist/src/onboard.d.ts +21 -2
- package/dist/src/onboard.js +56 -3
- package/dist/src/prompts.d.ts +9 -2
- package/dist/src/prompts.js +57 -5
- package/dist/src/runner/context.d.ts +2 -2
- package/dist/src/runner/context.js +3 -3
- package/dist/src/runner/runner.d.ts +4 -0
- package/dist/src/runner/runner.js +49 -24
- package/dist/src/runtimecheck.d.ts +26 -0
- package/dist/src/runtimecheck.js +20 -0
- package/dist/src/sandboxcheck.d.ts +2 -1
- package/dist/src/sandboxcheck.js +10 -5
- package/dist/src/selfupdate.d.ts +10 -1
- package/dist/src/selfupdate.js +28 -5
- package/dist/src/service.d.ts +5 -4
- package/dist/src/service.js +2 -0
- package/dist/src/servicefix.d.ts +4 -4
- package/dist/src/servicefix.js +10 -8
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/selfupdate.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Keeping a running `ach` current. Two jobs:
|
|
2
2
|
//
|
|
3
3
|
// - the runner (`ach run`, a long-lived daemon under systemd / launchd): SelfUpdater asks the hub which CLI release is the
|
|
4
|
-
// newest, and when this one is behind it stops taking new work, waits for the runs in flight, installs the release (
|
|
5
|
-
// global install) or relies on npx to fetch it (a service
|
|
4
|
+
// newest, and when this one is behind it stops taking new work, waits for the runs in flight, installs the release (into its
|
|
5
|
+
// own dir of the install in the AgentChannel home, appinstall.ts; or a global install) or relies on npx to fetch it (a service
|
|
6
|
+
// started from the npx cache), and exits with UPDATE_EXIT_CODE.
|
|
6
7
|
// systemd (Restart=on-failure) and launchd (KeepAlive/SuccessfulExit=false) restart a non-zero exit, so the service comes
|
|
7
8
|
// back on the new release. Parked runs and queued answers live in the hub and the runner's state file: nothing is lost.
|
|
8
9
|
// - an MCP session (`ach mcp`, started by Claude Code or Codex): it cannot be restarted from outside, so startStaleNotice
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
import { execFile, spawn } from 'node:child_process';
|
|
19
20
|
import { accessSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
20
21
|
import { dirname, join, sep } from 'node:path';
|
|
22
|
+
import { appDir, appWritable, inApp, installIntoApp, setCurrent } from './appinstall.js';
|
|
21
23
|
import { thisCliPath } from './invite.js';
|
|
22
24
|
import { CLIENT_PROTO, newerVersion, PKG_NAME, VERSION } from './version.js';
|
|
23
25
|
/** A restart-worthy exit: not 0 (systemd on-failure and launchd restart only a failure) and not 78 (key refused: do not restart). */
|
|
@@ -81,6 +83,9 @@ const real = (p) => {
|
|
|
81
83
|
/** How this CLI was installed, so that the right update is used (or none). */
|
|
82
84
|
export async function detectInstall(o = {}) {
|
|
83
85
|
const self = real(o.self ?? thisCliPath());
|
|
86
|
+
const app = real(o.app ?? appDir());
|
|
87
|
+
if (inApp(self, app))
|
|
88
|
+
return { kind: 'app', dir: app };
|
|
84
89
|
if (/[\\/]_npx[\\/]/.test(self)) {
|
|
85
90
|
// `...@3` re-resolves on a restart; an exact prerelease spec (`...@3.5.0-rc.1`) never moves
|
|
86
91
|
return (o.version ?? VERSION).includes('-') ? { kind: 'other', why: 'started with npx from an exact prerelease version: run the join line (or `ach run --install-service`) again with the new release' } : { kind: 'npx' };
|
|
@@ -102,6 +107,8 @@ export async function preflight(kind, target, exec = defaultInstallExec) {
|
|
|
102
107
|
const v = await exec('npm', ['view', `${PKG_NAME}@${target}`, 'version'], { timeoutMs: 30_000 });
|
|
103
108
|
if (v.code !== 0 || !v.stdout.split(/\s+/).includes(target))
|
|
104
109
|
return { ok: false, detail: `${PKG_NAME}@${target} is not on npm (yet), or npm cannot reach it` };
|
|
110
|
+
if (kind.kind === 'app' && !appWritable(kind.dir))
|
|
111
|
+
return { ok: false, detail: `no permission to write ${kind.dir}` };
|
|
105
112
|
if (kind.kind === 'global') {
|
|
106
113
|
try {
|
|
107
114
|
accessSync(dirname(kind.dir), constants.W_OK); // <npm root -g>/@koalaauto: where npm replaces the package
|
|
@@ -118,6 +125,8 @@ export async function installRelease(kind, target, exec = defaultInstallExec) {
|
|
|
118
125
|
return { ok: false, detail: kind.why };
|
|
119
126
|
if (kind.kind === 'npx')
|
|
120
127
|
return { ok: true, detail: 'npx fetches it on restart' };
|
|
128
|
+
if (kind.kind === 'app')
|
|
129
|
+
return installIntoApp(kind.dir, target, exec);
|
|
121
130
|
const r = await exec('npm', ['install', '-g', '--ignore-scripts', '--no-audit', '--no-fund', `${PKG_NAME}@${target}`], { timeoutMs: 5 * 60_000 });
|
|
122
131
|
if (r.code !== 0)
|
|
123
132
|
return { ok: false, detail: `npm install -g ${PKG_NAME}@${target} failed (${(r.stderr || r.stdout).trim().split('\n').slice(-3).join(' | ').slice(0, 300)})` };
|
|
@@ -255,7 +264,7 @@ export class SelfUpdater {
|
|
|
255
264
|
this.once(`backoff:${v.target}`, `ach ${v.target} is out but the last try ${new Date(last.at).toISOString()} did not end on it; trying again after a day`);
|
|
256
265
|
return 'backoff';
|
|
257
266
|
}
|
|
258
|
-
const kind = await detectInstall({ self: this.o.self, exec: this.o.exec, version });
|
|
267
|
+
const kind = await detectInstall({ self: this.o.self, exec: this.o.exec, version, app: this.o.app });
|
|
259
268
|
if (kind.kind === 'other') {
|
|
260
269
|
this.once(`other:${v.target}`, `ach ${v.target} is out (this is ${version}) and cannot be installed by itself: ${kind.why}`);
|
|
261
270
|
return 'manual';
|
|
@@ -495,7 +504,7 @@ export function markHealthy(home, version = VERSION) {
|
|
|
495
504
|
/**
|
|
496
505
|
* Called first thing when `ach run` starts. A release this runner updated itself to, that has started BOOT_LIMIT times within
|
|
497
506
|
* ten minutes without once becoming healthy, is marked bad here and the release before it is installed again (a global install;
|
|
498
|
-
* an npx install has nothing to go back to and only marks it). Returns what it did; 'rolledback' means: exit UPDATE_EXIT_CODE.
|
|
507
|
+
* the install in the AgentChannel home points its launcher back; an npx install has nothing to go back to and only marks it). Returns what it did; 'rolledback' means: exit UPDATE_EXIT_CODE.
|
|
499
508
|
*/
|
|
500
509
|
export async function bootGuard(home, o = {}) {
|
|
501
510
|
const version = o.version ?? VERSION;
|
|
@@ -512,7 +521,21 @@ export async function bootGuard(home, o = {}) {
|
|
|
512
521
|
const log = o.log ?? ((s) => console.error(s));
|
|
513
522
|
writeJson(home, badFile(home), [...new Set([...localBad(home), version])]);
|
|
514
523
|
log(`[ach update] ${version} started ${b.starts.length} times in ten minutes without working: marked bad here, going back to ${upd.previous}`);
|
|
515
|
-
const kind = await detectInstall({ self: o.self, exec: o.exec, version });
|
|
524
|
+
const kind = await detectInstall({ self: o.self, exec: o.exec, version, app: o.app });
|
|
525
|
+
if (kind.kind === 'app') {
|
|
526
|
+
// the release before is still in its own dir (or installed again): the launcher is pointed back at it
|
|
527
|
+
let r;
|
|
528
|
+
try {
|
|
529
|
+
setCurrent(kind.dir, upd.previous);
|
|
530
|
+
r = { ok: true, detail: '' };
|
|
531
|
+
}
|
|
532
|
+
catch {
|
|
533
|
+
r = await installRelease(kind, upd.previous, o.exec);
|
|
534
|
+
}
|
|
535
|
+
log(`[ach update] ${r.ok ? `back on ${upd.previous}` : `going back failed: ${r.detail}`}`);
|
|
536
|
+
writeJson(home, bootsFile(home), { version: upd.previous, starts: [], healthy: false });
|
|
537
|
+
return r.ok ? 'rolledback' : 'marked';
|
|
538
|
+
}
|
|
516
539
|
if (kind.kind !== 'global') {
|
|
517
540
|
log(`[ach update] cannot go back by itself (${kind.kind === 'npx' ? 'an npx install fetches the newest release on every start' : kind.why}): ask the hub's admin to mark ${version} bad (ACH_BAD_CLIENTS)`);
|
|
518
541
|
return 'marked';
|
package/dist/src/service.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export interface ServiceSpec {
|
|
8
8
|
platform: 'darwin' | 'linux' | 'win32';
|
|
9
9
|
agentName: string;
|
|
10
|
-
/** What starts the CLI: node + cli.js of
|
|
10
|
+
/** What starts the CLI: node + the launcher of the install in the AgentChannel home, node + cli.js of another install, or `npx -y <spec>`. */
|
|
11
11
|
command: string[];
|
|
12
12
|
/** `run` arguments, without --install-service. */
|
|
13
13
|
args: string[];
|
|
@@ -40,9 +40,10 @@ export interface FoundService {
|
|
|
40
40
|
args: string[];
|
|
41
41
|
env: Record<string, string>;
|
|
42
42
|
logFile: string;
|
|
43
|
-
/** `
|
|
44
|
-
*
|
|
45
|
-
|
|
43
|
+
/** `app`: node on the launcher of the install in the AgentChannel home (appinstall.ts). `npx`: starts `npx -y <spec>`, which re-resolves
|
|
44
|
+
* the spec at every start (and fails while npm catches up with a release). `node-cache`: starts node on a file inside the npx cache,
|
|
45
|
+
* which only ever runs the release that was cached. `node`: node on some other install. */
|
|
46
|
+
format: 'app' | 'npx' | 'node-cache' | 'node' | 'unknown';
|
|
46
47
|
}
|
|
47
48
|
/** Where this platform keeps the files serviceFile() writes. */
|
|
48
49
|
export declare function serviceDir(platform: ServiceSpec['platform'], env?: NodeJS.ProcessEnv): string;
|
package/dist/src/service.js
CHANGED
|
@@ -163,6 +163,8 @@ const formatOf = (command) => {
|
|
|
163
163
|
return 'unknown';
|
|
164
164
|
if (/(^|[\\/])npx(\.cmd)?$/.test(command[0]))
|
|
165
165
|
return 'npx';
|
|
166
|
+
if (command.length === 2 && /[\\/]app[\\/]ach\.mjs$/.test(command[1]))
|
|
167
|
+
return 'app';
|
|
166
168
|
return command.slice(1).some((x) => /[\\/]_npx[\\/]/.test(x)) ? 'node-cache' : 'node';
|
|
167
169
|
};
|
|
168
170
|
/** Read a service file this module wrote (launchd plist or systemd unit); null for anything else, a Windows script included. */
|
package/dist/src/servicefix.d.ts
CHANGED
|
@@ -29,8 +29,9 @@ export interface Migration {
|
|
|
29
29
|
start: string[];
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* This agent's own service, when it
|
|
33
|
-
* none, or it is already fine. Writing only; the caller decides when
|
|
32
|
+
* This agent's own service, when it starts through the npx cache (`npx -y <spec>`, or node on a file in the cache): rewritten to start
|
|
33
|
+
* `command`, the install in the AgentChannel home. Null when there is none, or it is already fine. Writing only; the caller decides when
|
|
34
|
+
* to reload (that ends this very process).
|
|
34
35
|
*/
|
|
35
36
|
export declare function migrateOldService(o: {
|
|
36
37
|
agentName: string;
|
|
@@ -38,8 +39,7 @@ export declare function migrateOldService(o: {
|
|
|
38
39
|
dir?: string;
|
|
39
40
|
env: NodeJS.ProcessEnv;
|
|
40
41
|
home: string;
|
|
41
|
-
|
|
42
|
-
spec: string;
|
|
42
|
+
command: string[];
|
|
43
43
|
}): Migration | null;
|
|
44
44
|
/** Run the reload so that it outlives this process (the reload stops it): a detached shell. */
|
|
45
45
|
export declare function reloadDetached(start: string[], env: NodeJS.ProcessEnv): void;
|
package/dist/src/servicefix.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// Keeping an agent's runner service right (issue #4): one service per agent, and a service that starts
|
|
1
|
+
// Keeping an agent's runner service right (issue #4): one service per agent, and a service that starts the install in the AgentChannel home.
|
|
2
2
|
// - Installing a service retires the others on this machine that run the same agent (same AGENTCHANNEL_HOME): a renamed agent
|
|
3
3
|
// gets a new service label, and the old one went on running beside it.
|
|
4
|
-
// - A service
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// - A service that starts through the npx cache: node on a cached file (early releases) never moves to a newer release, and
|
|
5
|
+
// `npx -y <spec>` re-resolves the spec at every start, which fails while npm catches up with a release. At start the runner
|
|
6
|
+
// copies itself into the install in the AgentChannel home (appinstall.ts), rewrites the service to start that, and has the
|
|
7
|
+
// supervisor reload it.
|
|
7
8
|
import { execFileSync, spawn } from 'node:child_process';
|
|
8
9
|
import { unlinkSync } from 'node:fs';
|
|
9
10
|
import { achHome } from './config.js';
|
|
@@ -59,15 +60,16 @@ export function startedByService(agentName, platform, env) {
|
|
|
59
60
|
return false;
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
|
-
* This agent's own service, when it
|
|
63
|
-
* none, or it is already fine. Writing only; the caller decides when
|
|
63
|
+
* This agent's own service, when it starts through the npx cache (`npx -y <spec>`, or node on a file in the cache): rewritten to start
|
|
64
|
+
* `command`, the install in the AgentChannel home. Null when there is none, or it is already fine. Writing only; the caller decides when
|
|
65
|
+
* to reload (that ends this very process).
|
|
64
66
|
*/
|
|
65
67
|
export function migrateOldService(o) {
|
|
66
68
|
const name = o.agentName.replace(/[^A-Za-z0-9-]/g, '-');
|
|
67
69
|
const own = listServices(o.platform, o.dir, o.env).find((s) => s.agentName === name && homeOfService(s, o.env) === o.home);
|
|
68
|
-
if (!own || own.format !== 'node-cache')
|
|
70
|
+
if (!own || (own.format !== 'npx' && own.format !== 'node-cache'))
|
|
69
71
|
return null;
|
|
70
|
-
const f = serviceFile(specOf(own, o.platform,
|
|
72
|
+
const f = serviceFile(specOf(own, o.platform, o.command), o.dir, o.env);
|
|
71
73
|
writeServiceFile(f);
|
|
72
74
|
return { path: f.path, start: f.start };
|
|
73
75
|
}
|
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.
|
|
3
|
+
"version": "3.55.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",
|