@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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// The CLI's own install in the user's AgentChannel home: <defaultHome>/app. No root (a global npm install often needs it), and no
|
|
2
|
+
// npx at start-up (npx re-resolves `@3` on every start: in the minutes after a release npm names a version it does not serve yet,
|
|
3
|
+
// and the start fails with ETARGET; and every `@3` process shares one npx cache dir that the next release is written over).
|
|
4
|
+
//
|
|
5
|
+
// app/<version>/node_modules/... one release per dir, never changed once written
|
|
6
|
+
// app/current the version the launcher starts
|
|
7
|
+
// app/ach.mjs the launcher: MCP entries and services run `node app/ach.mjs ...`
|
|
8
|
+
//
|
|
9
|
+
// A new release goes into a dir of its own and `current` is switched by a rename, so processes running the old one keep their files
|
|
10
|
+
// (Windows included: nothing they hold is replaced). Old dirs are removed once they are a few releases back and some days old.
|
|
11
|
+
import { accessSync, constants, cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { delimiter, join, sep } from 'node:path';
|
|
13
|
+
import { defaultHome } from './config.js';
|
|
14
|
+
import { newerVersion, PKG_NAME, VERSION } from './version.js';
|
|
15
|
+
const isVersion = (v) => typeof v === 'string' && /^\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?$/.test(v);
|
|
16
|
+
/** Where the install lives: one per user, shared by every agent home on the machine (they run the same CLI). */
|
|
17
|
+
export function appDir(env = process.env) {
|
|
18
|
+
return join(defaultHome(env), 'app');
|
|
19
|
+
}
|
|
20
|
+
export const launcherPath = (app) => join(app, 'ach.mjs');
|
|
21
|
+
const currentFile = (app) => join(app, 'current');
|
|
22
|
+
const pkgDir = (app, version) => join(app, version, 'node_modules', ...PKG_NAME.split('/'));
|
|
23
|
+
/** The CLI file of one release in the install. */
|
|
24
|
+
export const cliOf = (app, version) => join(pkgDir(app, version), 'dist', 'src', 'cli.js');
|
|
25
|
+
/** Plain JS, run by node: starts the release named in ./current. The CLI checks that it is the entry by process.argv[1]. */
|
|
26
|
+
export const LAUNCHER_SCRIPT = `// written by agentchannel (ach): starts the release named in ./current
|
|
27
|
+
import { readFileSync } from 'node:fs';
|
|
28
|
+
import { dirname, join } from 'node:path';
|
|
29
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
30
|
+
const app = dirname(fileURLToPath(import.meta.url));
|
|
31
|
+
const version = readFileSync(join(app, 'current'), 'utf8').trim();
|
|
32
|
+
const cli = join(app, version, 'node_modules', ${PKG_NAME.split('/').map((s) => JSON.stringify(s)).join(', ')}, 'dist', 'src', 'cli.js');
|
|
33
|
+
process.argv[1] = cli;
|
|
34
|
+
await import(pathToFileURL(cli).href);
|
|
35
|
+
`;
|
|
36
|
+
const readVersion = (dir) => {
|
|
37
|
+
try {
|
|
38
|
+
return String(JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')).version ?? '');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/** The release `current` names, when its files are there. */
|
|
45
|
+
export function currentVersion(app = appDir()) {
|
|
46
|
+
let v = '';
|
|
47
|
+
try {
|
|
48
|
+
v = readFileSync(currentFile(app), 'utf8').trim();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return isVersion(v) && existsSync(launcherPath(app)) && readVersion(pkgDir(app, v)) === v ? v : undefined;
|
|
54
|
+
}
|
|
55
|
+
/** Is this CLI file inside the install? */
|
|
56
|
+
export function inApp(self, app = appDir()) {
|
|
57
|
+
return self.startsWith(app + sep);
|
|
58
|
+
}
|
|
59
|
+
/** The release of the install this CLI file belongs to (from its dir name). */
|
|
60
|
+
export function appVersionOf(self, app = appDir()) {
|
|
61
|
+
if (!inApp(self, app))
|
|
62
|
+
return undefined;
|
|
63
|
+
const v = self.slice(app.length + 1).split(/[\\/]/)[0];
|
|
64
|
+
return isVersion(v) ? v : undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The node to start the launcher with: the first `node` on PATH as PATH names it (a version manager's or Homebrew's stable link, not
|
|
68
|
+
* the versioned file behind it, which an upgrade removes), else this one.
|
|
69
|
+
*/
|
|
70
|
+
export function nodeCommand(env = process.env, execPath = process.execPath) {
|
|
71
|
+
if (process.platform === 'win32')
|
|
72
|
+
return execPath;
|
|
73
|
+
for (const d of (env.PATH ?? '').split(delimiter)) {
|
|
74
|
+
if (!d || /[\\/]_npx[\\/]|[\\/]node_modules[\\/]\.bin$/.test(d))
|
|
75
|
+
continue;
|
|
76
|
+
const f = join(d, 'node');
|
|
77
|
+
try {
|
|
78
|
+
accessSync(f, constants.X_OK);
|
|
79
|
+
return f;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
/* next */
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return execPath;
|
|
86
|
+
}
|
|
87
|
+
/** How an MCP entry or a service starts the install. */
|
|
88
|
+
export function appAch(env = process.env, app = appDir(env)) {
|
|
89
|
+
return [nodeCommand(env), launcherPath(app)];
|
|
90
|
+
}
|
|
91
|
+
const writeAtomic = (f, s) => {
|
|
92
|
+
const tmp = `${f}.${process.pid}.tmp`;
|
|
93
|
+
writeFileSync(tmp, s, { mode: 0o644 });
|
|
94
|
+
renameSync(tmp, f);
|
|
95
|
+
};
|
|
96
|
+
/** Point the launcher at `version` (its files must be there). Writes the launcher too, so an install that lost it gets it back. */
|
|
97
|
+
export function setCurrent(app, version) {
|
|
98
|
+
if (readVersion(pkgDir(app, version)) !== version)
|
|
99
|
+
throw new Error(`${pkgDir(app, version)} does not hold ${version}`);
|
|
100
|
+
writeAtomic(launcherPath(app), LAUNCHER_SCRIPT);
|
|
101
|
+
writeAtomic(currentFile(app), `${version}\n`);
|
|
102
|
+
}
|
|
103
|
+
/** The node_modules dir an npx cache run of this CLI lives in, or undefined when it is not one. */
|
|
104
|
+
export function npxModulesOf(self) {
|
|
105
|
+
const m = /^(.*[\\/]_npx[\\/][^\\/]+[\\/]node_modules)[\\/]/.exec(self);
|
|
106
|
+
return m?.[1];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Put the release this CLI is into the install by copying its npx cache dir (nothing is downloaded, so nothing waits on npm), and point
|
|
110
|
+
* `current` at it unless `current` already names a newer release. Returns the install's command, or undefined when this is not an npx
|
|
111
|
+
* run or the copy failed (the caller keeps using npx then).
|
|
112
|
+
*/
|
|
113
|
+
export function adoptFromNpx(o) {
|
|
114
|
+
const env = o.env ?? process.env;
|
|
115
|
+
const version = o.version ?? VERSION;
|
|
116
|
+
const modules = npxModulesOf(o.self);
|
|
117
|
+
if (!modules || !isVersion(version) || !existsSync(join(modules, ...PKG_NAME.split('/'))))
|
|
118
|
+
return undefined;
|
|
119
|
+
const app = appDir(env);
|
|
120
|
+
try {
|
|
121
|
+
mkdirSync(app, { recursive: true, mode: 0o700 });
|
|
122
|
+
if (readVersion(pkgDir(app, version)) !== version) {
|
|
123
|
+
const tmp = join(app, `.${version}.${process.pid}.tmp`);
|
|
124
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
125
|
+
cpSync(modules, join(tmp, 'node_modules'), { recursive: true, verbatimSymlinks: true });
|
|
126
|
+
try {
|
|
127
|
+
renameSync(tmp, join(app, version));
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
131
|
+
if (readVersion(pkgDir(app, version)) !== version)
|
|
132
|
+
throw e; // another process put the same release there first: fine
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const cur = currentVersion(app);
|
|
136
|
+
if (!cur || cur === version || newerVersion(version, cur))
|
|
137
|
+
setCurrent(app, version);
|
|
138
|
+
return appAch(env, app);
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
o.log?.(`could not install ach ${version} into ${app}: ${e?.message ?? e}`);
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** Can the install be written (the updater asks before it stops taking work)? */
|
|
146
|
+
export function appWritable(app) {
|
|
147
|
+
try {
|
|
148
|
+
accessSync(app, constants.W_OK);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** Install `version` from npm into a dir of its own (`npm install --prefix`, scripts off), read it back, point `current` at it, prune. */
|
|
156
|
+
export async function installIntoApp(app, version, exec) {
|
|
157
|
+
if (!isVersion(version))
|
|
158
|
+
return { ok: false, detail: `not a version: ${version}` };
|
|
159
|
+
if (readVersion(pkgDir(app, version)) !== version) {
|
|
160
|
+
const tmp = join(app, `.${version}.${process.pid}.tmp`);
|
|
161
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
162
|
+
mkdirSync(tmp, { recursive: true, mode: 0o700 });
|
|
163
|
+
const r = await exec('npm', ['install', '--prefix', tmp, '--ignore-scripts', '--no-audit', '--no-fund', '--no-save', '--no-package-lock', `${PKG_NAME}@${version}`], { timeoutMs: 5 * 60_000 });
|
|
164
|
+
const got = readVersion(join(tmp, 'node_modules', ...PKG_NAME.split('/')));
|
|
165
|
+
if (r.code !== 0 || got !== version) {
|
|
166
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
167
|
+
return { ok: false, detail: `npm install ${PKG_NAME}@${version} into ${app} failed (${r.code !== 0 ? (r.stderr || r.stdout).trim().split('\n').slice(-3).join(' | ').slice(0, 300) : `got ${got || 'nothing'}`})` };
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
renameSync(tmp, join(app, version));
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
174
|
+
if (readVersion(pkgDir(app, version)) !== version)
|
|
175
|
+
return { ok: false, detail: `could not move ${version} into place: ${e?.message ?? e}` };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
setCurrent(app, version);
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
return { ok: false, detail: `installed ${version} but could not switch to it: ${e?.message ?? e}` };
|
|
183
|
+
}
|
|
184
|
+
pruneApp(app);
|
|
185
|
+
return { ok: true, detail: `installed ${version} into ${app}` };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Remove releases nothing should still run: not `current`, not among the three newest, and untouched for three days (an MCP session
|
|
189
|
+
* started on an old release keeps reading its files until it is restarted).
|
|
190
|
+
*/
|
|
191
|
+
export function pruneApp(app, now = Date.now(), keep = 3, minAgeMs = 3 * 24 * 3600_000) {
|
|
192
|
+
const cur = currentVersion(app);
|
|
193
|
+
let names = [];
|
|
194
|
+
try {
|
|
195
|
+
names = readdirSync(app).filter(isVersion);
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
const newest = [...names].sort((a, b) => (newerVersion(a, b) ? -1 : newerVersion(b, a) ? 1 : 0)).slice(0, keep);
|
|
201
|
+
const out = [];
|
|
202
|
+
for (const v of names) {
|
|
203
|
+
if (v === cur || newest.includes(v))
|
|
204
|
+
continue;
|
|
205
|
+
try {
|
|
206
|
+
if (now - statSync(join(app, v)).mtimeMs < minAgeMs)
|
|
207
|
+
continue;
|
|
208
|
+
rmSync(join(app, v), { recursive: true, force: true });
|
|
209
|
+
out.push(v);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
/* left for the next prune */
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return out;
|
|
216
|
+
}
|
package/dist/src/args.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export declare function parseCli(argv: string[]): Parsed;
|
|
|
16
16
|
* runs over the more indented lines under it.
|
|
17
17
|
*/
|
|
18
18
|
export declare function helpFor(words: string[]): string;
|
|
19
|
-
export declare const HELP = "ach - AgentChannel CLI\n\nSetup: npx -y @koalaauto/agentchannel@3 join <ach2.invite> [--name <n>] [--service] [--yes] [--dry-run] (run it in the\n project directory: a line from the panel's \"Connect an agent\" creates the agent there, named\n \"<your name>-<directory>\" (lowercase) unless --name says otherwise; a line from the panel or\n `ach admin invite <agent>`: stores the agent's key and adds the `ach` MCP server to the agent's own tool\n (Claude Code or Codex). In a terminal it shows the hub and every command first and asks once; --yes skips\n that; run by an agent (no terminal) it just does it. --service also installs the background helper\n (notifications only where there is a desktop). --dry-run prints the plan and uses nothing)\n ach login --hub <url> --key <ach_sk_...> | ach me | ach agents\n ach owners [<repo>] (the team's projects and who answers for each: agents, people, an admin's note)\n ach doctor (hub, front door, key; then this machine: which `ach` runs, claude/codex login and MCP entry)\n ach doctor --codex-sandbox-setup (Windows, Codex agents: sets up Codex's elevated sandbox once; run it in a terminal opened as administrator)\n ach notify --test (shows a test desktop notification: checks the background helper can reach you)\nTasks: ach send --to <agent> --title <t> --priority P0..P3 --purpose <p> --key-question <q> --money <m> --handoff-file <f>\n [--depends <id> ...] (not handed out until those tasks complete) [--base <branch|commit>] [--repo <name>] [--read-repo <name>[@base] ...] [--attach <file> ...]\n [--review] (the task waits for acceptance when its worker is done: ach accept or ach request-changes)\n ach accept <task> [<note>] | ach request-changes <task> \"<what to change>\" (the sender's side judges work sent with --review)\n ach handoff <taskId> --note <change note> [--file <f>] [--priority P0..P3] [--purpose p] [--money m] [--key-question q] [--attach <file> ...]\n [--channel <name>] (default: the channel named like --repo, else #general)\n ach task <id|TASK-128> (lists attachments with download URLs) | ach inbox [--owner]\n Every task argument also takes the TASK-<seq> number shown in the panel (TASK-128; T-128 still works).\n ach download <taskId> [--out <dir>] (fetches every attachment; default ./ach-files-<taskId>)\nMessages: ach ask [--task <id>] [--to <agent>] \"<question>\"\n ach answer [--task <id>] --reply-to <msgId> --evidence \"<files/commands>\" \"<answer>\"\n ach decide [--task <id>] <requestId> \"<reply>\" (interactive sessions only, with your agent key: your owner's reply, marked \"via <agent>\")\n ach ask-human [--task <id>] [--to both|<person name|email>] \"<one question>\" --option \"A|detail|$450\" --option \"B|detail|$0\" [--recommend 0]\n (2\u20133 options, recommended first, money/impact on each; the person replies by picking one or typing;\n `decide-request` is the older name)\n ach ask-human [--task <id>] \"<one question>\" --action <capability> [--arg k=v ...] [--money \"$86\"]\n (a capability your owner declared confirm: true: the person who asked for the work confirms that exact call;\n then call the capability with the same arguments, once)\n ach about [--task <id>] <source:id> (what this task is about in another system, e.g. batch:20261118_003; set once)\n ach related <source:id> (the tasks and outside events about it)\n ach progress [--task <id>] \"<text>\" | ach note [--task <id>] \"<text>\"\n Each takes --attach <file> (repeatable; png, jpg, webp, gif, mp4, webm, mov, pdf, zip; text/code up to 2 MB:\n txt md json ts js py go sh diff patch log csv yaml sql; .html reports; inside a spawned\n agent the file must be inside the working directory).\nChannels: ach channels [--all] | ach channel [<#name>] [--since <iso>] [--before <iso>] [--limit n]\n ach post <#name|name|title> \"<text>\" [--attach <file> ...] [--announce] (@agent mentions wake that agent for a read-only reply;\n an @name that matches nobody is warned about, with the closest name;\n --announce: \"shipped\" / \"data published\": an announcement every channel reader is notified of)\n ach post <#name> --card '<json>' | --card @card.json (a card instead of text, e.g. a #product-log entry:\n {\"type\":\"change\",\"tag\":\"feature|fix|change\",\"title\",\"date\",\"summary\",\"by\":[logins],\"refs\":[links]})\n ach reply [<postId>] \"<text>\"|- [--evidence \"<files/commands>\"] [--escalate [--to owner|asker] [--ask \"<one line to decide>\"] | --as-owner] [--attach <file> ...]\n (postId defaults to $ACH_THREAD_ID in a mention run; \"-\" reads the text from stdin, e.g. a quoted heredoc)\n ach thread <postId> | ach search \"<query>\" [--channel <name>] [--author <agent|person>] [--limit n]\n Inside a spawned agent: no new top-level posts; replies only in the task's own thread.\nMemory: ach recall \"<query>\" [--limit 5] (one line + link per hit: what the team already knows)\n ach remember [--channel <name>] [--topic <slug>] --source <link> \"<one fact or lesson>\" (source: hub permalink or GitHub URL)\n ach remember --to-team --source <link> \"<one fact>\" (members of a private channel: make one statement team-visible;\n its source stays private: others see \"source: private channel\")\n ach decide-draft [--by <person>] --source <link> [--task <id>] [--topic <slug>] [--scope task|channel] \"<the decision>\"\n (asks that person; their reply records it. Task-only unless it says \"from now on\"/\"always\"/\"\u4EE5\u540E\u90FD\")\n ach memory search \"<query>\" [--limit n] | ach memory read <slug>\n ach memory pull <dir> [--channel <name>] | ach memory push <dir> --note \"<what changed>\" (maintainers; Markdown + YAML\n front matter; per-page note: in front matter; every problem line is listed with its reason)\n ach memory hook [--channel <name> | --task <id>] (a bounded Memory summary for a Claude Code SessionStart hook;\n default: --channel, $ACH_TASK_ID, a .ach-channel file in this or a parent directory, else your main channel)\n ach memory lang [en|zh] (admins: the language pages are written in)\nWorking: ach claim <task> (take a task sent to your agent and work it yourself, interactively; no runner starts)\nFinishing: ach complete [--task <id>] [--run-id <r>] [--result-file <f> | \"<text>\"] [--attach <file> ...]\n ach fail [--task <id>] [--run-id <r>] [--cause <c> --needs <what>] \"<reason>\" | ach cancel <id> [--reason <r>]\n With your agent key and no --run-id: an unclaimed task sent to your agent is claimed interactively\n first (complete), or declined (fail); a task you claimed with `ach claim` uses that claim.\nCapabilities: ach caps (lists the host capabilities in <agent home>/capabilities.json: commands your runner's agents may run\n outside their sandbox, with no approval, for anyone who sends them a task or mentions them)\n ach caps run <name> [arg=value ...] (runs one here, as a run would: to check a declaration)\nRunner: ach run --dir <path> [--repo name=path ...] [--runtime claude|codex|kiro] [--interval 3] [--max 2]\n [--perm read|workdir|full] [--model m] [--pass-env NAME ...]\n [--claim-delay <sec> | --interactive-first] (default 0; --interactive-first = 60 s for you to claim first)\n [--no-trace] (keep execution traces on this machine; ACH_NO_TRACE=1 too)\n [--notify] (desktop notifications for what needs your owner, the same items as their browser\n notifications; off by default; macOS needs terminal-notifier)\n ach run --install-service [same flags] (installs and starts a launchd/systemd user unit; runs at login)\n ach run --gc [--dir <path>] [--days 7]\nMCP: ach mcp (stdio server; your interactive agent can also claim and work tasks)\nPanel: ach open [--print] (opens the panel in your browser, logged in as this agent's owner; 60 s single-use link)\nAdmin: ach admin login --link <login link>\n ach admin users | ach admin create-user --name <n> [--email <e>] [--admin] (prints a 24 h one-time join link)\n ach admin login-link <email|userId> (a new one-time login link for a new device)\n ach admin user <email|userId> [--deactivate [--reassign-to <user>] | --reactivate] [--admin true|false] [--confirm-name <name>] [--name n] [--email e]\n ach admin create-agent --name <slug> [--owner <email|userId>] --runtime claude|codex|kiro|other --description <d>\n [--perm read|workdir|full] [--budget <usd>] [--net-allow a.com,b.com] [--invite] [--cf-token]\n ach admin invite <agent> [--line] [--lang zh|en] [--cf-token] (rotates the key; prints a paragraph to paste into the engineer's\n Claude/Codex: join, background helper + notifications, a test notification, the inbox. --line: only\n the join line npx -y @koalaauto/agentchannel@3 join <blob>. Language: --lang, else the hub's (Memory) language.\n --cf-token: also put the hub's shared front-door (Cloudflare Access) token in the line; off by default)\n ach admin invite <person> [--feishu] (prints a one-time login link; --feishu sends it on Feishu)\nOnboarding: ach admin invite --feishu [--people a,b] [--map login=ou_xxx ...] [--yes] (Feishu DMs via lark-cli; preview without --yes)\n ach admin invite --people a,b --yes (prints one-time login links to send yourself)\n ach admin rotate-key <name|id> | ach admin set <agentId> [--active true|false] [--perm p] [--budget usd]\n [--model m|default] [--description d] [--accept-from a,b] [--net-allow a.com,b.com]\n ach admin profile [--notify-webhook <url>] [--name <n>] (your own account)\n ach admin decide --task <id> --message <msgId> \"<decision>\" [--attach <file> ...]\n ach admin note --task <id> \"<text>\" [--attach <file> ...] (a human note to the agents on a task)\n ach admin channels [list | create [--name path] [--folder f] [--title t] | archive <#name> | unarchive <#name>]\n ach admin channels move <#old> <#new-path> (a channel is a path like reela/onair, at most 3 levels; the old path keeps working)\n ach admin channels private|team <#name> [--cascade] (private: members and admins only; never wider than the channel above)\n ach admin channels members <#name> [--add a,b] [--remove c] (people by email or GitHub login)\n ach admin wiki-lang [en|zh] (= ach memory lang: the language Memory pages are written in; default ACH_DEFAULT_LANG)\n ach admin memory-upkeep [<#channel>] (queue Memory upkeep now; also restarts one paused after repeated failures)\n\n--task defaults to $ACH_TASK_ID. Links use ACH_PUBLIC_URL when set (else the hub URL). Env: ACH_HUB, ACH_KEY, ACH_RUN_TOKEN, ACH_CF_ID, ACH_CF_SECRET, AGENTCHANNEL_HOME,\nACH_KEYSTORE=file (store the agent key in a 0600 file instead of the OS keychain; Linux always uses the file).\nHome: ~/.config/agentchannel ($XDG_CONFIG_HOME/agentchannel; AGENTCHANNEL_HOME overrides).\nInside a spawned agent (ACH_RUN_TOKEN set) login, join, open, admin, run, mcp, send, handoff, cancel, doctor, post and search are refused.\n";
|
|
19
|
+
export declare const HELP: string;
|
|
20
20
|
export {};
|
package/dist/src/args.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseArgs } from 'node:util';
|
|
2
|
+
import { RUNTIME_NAMES } from './adapters/spec.js';
|
|
2
3
|
const s = { type: 'string' };
|
|
3
4
|
const b = { type: 'boolean' };
|
|
4
5
|
const sm = { type: 'string', multiple: true };
|
|
@@ -216,7 +217,7 @@ Finishing: ach complete [--task <id>] [--run-id <r>] [--result-file <f> | "<tex
|
|
|
216
217
|
Capabilities: ach caps (lists the host capabilities in <agent home>/capabilities.json: commands your runner's agents may run
|
|
217
218
|
outside their sandbox, with no approval, for anyone who sends them a task or mentions them)
|
|
218
219
|
ach caps run <name> [arg=value ...] (runs one here, as a run would: to check a declaration)
|
|
219
|
-
Runner: ach run --dir <path> [--repo name=path ...] [--runtime
|
|
220
|
+
Runner: ach run --dir <path> [--repo name=path ...] [--runtime ${RUNTIME_NAMES.join('|')}] [--interval 3] [--max 2]
|
|
220
221
|
[--perm read|workdir|full] [--model m] [--pass-env NAME ...]
|
|
221
222
|
[--claim-delay <sec> | --interactive-first] (default 0; --interactive-first = 60 s for you to claim first)
|
|
222
223
|
[--no-trace] (keep execution traces on this machine; ACH_NO_TRACE=1 too)
|
|
@@ -230,7 +231,7 @@ Admin: ach admin login --link <login link>
|
|
|
230
231
|
ach admin users | ach admin create-user --name <n> [--email <e>] [--admin] (prints a 24 h one-time join link)
|
|
231
232
|
ach admin login-link <email|userId> (a new one-time login link for a new device)
|
|
232
233
|
ach admin user <email|userId> [--deactivate [--reassign-to <user>] | --reactivate] [--admin true|false] [--confirm-name <name>] [--name n] [--email e]
|
|
233
|
-
ach admin create-agent --name <slug> [--owner <email|userId>] --runtime
|
|
234
|
+
ach admin create-agent --name <slug> [--owner <email|userId>] --runtime ${RUNTIME_NAMES.join('|')}|other --description <d>
|
|
234
235
|
[--perm read|workdir|full] [--budget <usd>] [--net-allow a.com,b.com] [--invite] [--cf-token]
|
|
235
236
|
ach admin invite <agent> [--line] [--lang zh|en] [--cf-token] (rotates the key; prints a paragraph to paste into the engineer's
|
|
236
237
|
Claude/Codex: join, background helper + notifications, a test notification, the inbox. --line: only
|
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,
|
|
4
|
+
import { chmodSync, 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';
|
|
@@ -10,6 +10,7 @@ import { UsageError } from './args.js';
|
|
|
10
10
|
import { Client, clientFromConfig, HubError, isZh } from './client.js';
|
|
11
11
|
import { achHome, defaultHome, loadConfig, readFileConfig, resolveClaimDelay, writeFileConfig } from './config.js';
|
|
12
12
|
import { isPerm } from './perm.js';
|
|
13
|
+
import { isRuntime, runtimePerm } from './adapters/spec.js';
|
|
13
14
|
import { bootGuard, markHealthy, SelfUpdater, superviseSelf, UPDATE_EXIT_CODE, UPDATE_HANDOFF_EXIT_CODE, waitForWindowsUpdate } from './selfupdate.js';
|
|
14
15
|
import { inheritedEnv } from './env.js';
|
|
15
16
|
import { parseNum, splitList, str } from './cli-shared.js';
|
|
@@ -90,8 +91,8 @@ export async function runCommand(p, io) {
|
|
|
90
91
|
io.out(removed.length ? `removed ${removed.length} worktree(s): ${removed.join(', ')}` : 'nothing to remove');
|
|
91
92
|
return 0;
|
|
92
93
|
}
|
|
93
|
-
const
|
|
94
|
-
if (!isPerm(
|
|
94
|
+
const asked = (str(v.perm) ?? 'workdir');
|
|
95
|
+
if (!isPerm(asked))
|
|
95
96
|
throw new UsageError('run: --perm must be read|workdir|full');
|
|
96
97
|
const claimDelay = resolveClaimDelay({
|
|
97
98
|
claimDelay: str(v['claim-delay']) ? parseNum(str(v['claim-delay']), 'claim-delay') : undefined,
|
|
@@ -109,13 +110,14 @@ export async function runCommand(p, io) {
|
|
|
109
110
|
}
|
|
110
111
|
if (v['install-service'])
|
|
111
112
|
return installService(p, io, { agentName: me.name, formerNames: me.former_names ?? [], dir, repos: repoFlags, home });
|
|
112
|
-
// started by a service
|
|
113
|
+
// started by a service that starts through the npx cache: make it start the install in the AgentChannel home
|
|
113
114
|
const moved = await moveOldService(io, me.name, home);
|
|
114
115
|
if (moved)
|
|
115
116
|
return UPDATE_EXIT_CODE;
|
|
116
|
-
|
|
117
|
+
void moveMcpEntries(io, dir).catch(() => { });
|
|
118
|
+
const runtime = str(v.runtime) ?? (isRuntime(me.runtime) ? me.runtime : 'claude');
|
|
117
119
|
// what the permission and the network list do not cover, said where the person starting the runner will read it
|
|
118
|
-
if (
|
|
120
|
+
if (asked === 'full')
|
|
119
121
|
io.err('warning: --perm full runs commands with no sandbox (bypassPermissions): anything in a task that reaches the agent can run anything with your rights.');
|
|
120
122
|
const { makeAdapter } = await import('./adapters/index.js');
|
|
121
123
|
let adapter;
|
|
@@ -125,6 +127,15 @@ export async function runCommand(p, io) {
|
|
|
125
127
|
catch (e) {
|
|
126
128
|
throw new UsageError(`run: ${e.message}`);
|
|
127
129
|
}
|
|
130
|
+
// the level this runtime can enforce, never above the one asked for (docs/specs/runtimes.md §4)
|
|
131
|
+
const perm = runtimePerm(adapter.spec, asked);
|
|
132
|
+
if (!perm)
|
|
133
|
+
throw new UsageError(`run: ${adapter.spec.label} cannot enforce --perm ${asked} (it enforces: ${adapter.spec.perms.join(', ')})`);
|
|
134
|
+
if (perm !== asked)
|
|
135
|
+
io.err(`ach run: ${adapter.spec.label} cannot enforce --perm ${asked}; running with ${perm}`);
|
|
136
|
+
// what this tool's sandbox does not hold, said where the person starting the runner reads it (docs/specs/runtimes.md §4)
|
|
137
|
+
if (adapter.spec.reads === 'machine' && perm !== 'full')
|
|
138
|
+
io.err(`warning: ${adapter.spec.label} can read files outside the task directory on this machine (other checkouts, /tmp); only your home directory is hidden from its commands.`);
|
|
128
139
|
// keeps this runner on the hub's release: waits for the runs in flight, installs, exits UPDATE_EXIT_CODE so the service restarts
|
|
129
140
|
const passEnv = (Array.isArray(v['pass-env']) ? v['pass-env'] : []).flatMap(splitList);
|
|
130
141
|
const baseEnv = (() => {
|
|
@@ -168,14 +179,10 @@ export async function runCommand(p, io) {
|
|
|
168
179
|
baseEnv,
|
|
169
180
|
log: io.err,
|
|
170
181
|
sandboxCheck: async () => {
|
|
171
|
-
// kiro runs in Kiro's cloud sandbox: what this machine needs is kiro-cli and its key
|
|
172
|
-
if (runtime === 'kiro')
|
|
173
|
-
return (await import('./kirocheck.js')).probeKiro({ env });
|
|
174
|
-
const { probeEnvironment } = await import('./envcheck.js');
|
|
175
182
|
// the sandboxed command gets the env a run gets (inherited vars and a scratch home like a task's), so what a run cannot start
|
|
176
183
|
// without shows here, not in the first task (TASK-59)
|
|
177
184
|
const { env: homeEnv } = prepareAgentHome(join(tmpdir(), 'ach-homes'), me.name, 'startup-check', realHomeOf(baseEnv), baseEnv.CODEX_HOME || undefined);
|
|
178
|
-
return
|
|
185
|
+
return (await import('./runtimecheck.js')).probeRuntime(adapter.spec.name, { env, hub: cfg.hub, runEnv: { ...inheritedEnv(baseEnv, passEnv), ...homeEnv } });
|
|
179
186
|
},
|
|
180
187
|
});
|
|
181
188
|
io.err(`ach run: agent ${me.name}, runtime ${runtime}, perm min(${me.perm_level}, ${perm}), model ${me.model || str(v.model) || 'default'}, dir ${dir}` +
|
|
@@ -242,10 +249,12 @@ export async function runCommand(p, io) {
|
|
|
242
249
|
return UPDATE_HANDOFF_EXIT_CODE;
|
|
243
250
|
}
|
|
244
251
|
if (updater.restarting) {
|
|
245
|
-
// started by hand (no systemd / launchd behind it) from a global install: nothing would start it again, so it does that itself
|
|
246
|
-
if (updater.installed === 'global' && process.env.ACH_SUPERVISED !== '1' && !(await import('./servicefix.js')).startedByService(me.name, process.platform, process.env)) {
|
|
252
|
+
// started by hand (no systemd / launchd behind it) from a global or home install: nothing would start it again, so it does that itself
|
|
253
|
+
if ((updater.installed === 'global' || updater.installed === 'app') && process.env.ACH_SUPERVISED !== '1' && !(await import('./servicefix.js')).startedByService(me.name, process.platform, process.env)) {
|
|
247
254
|
io.err('ach run: updated; starting the new release here');
|
|
248
|
-
|
|
255
|
+
// the install in the AgentChannel home: through its launcher (this process's argv names the old release's own file)
|
|
256
|
+
const { appDir, launcherPath } = await import('./appinstall.js');
|
|
257
|
+
return superviseSelf({ log: io.err, ...(updater.installed === 'app' ? { argv: [process.argv[0], launcherPath(appDir(env)), ...process.argv.slice(2)] } : {}) });
|
|
249
258
|
}
|
|
250
259
|
io.err(`ach run: updated; exiting ${UPDATE_EXIT_CODE} so the service restarts on the new release (started by hand? run it again)`);
|
|
251
260
|
return UPDATE_EXIT_CODE;
|
|
@@ -311,11 +320,16 @@ async function installService(p, io, o) {
|
|
|
311
320
|
svcEnv.ACH_AUTH_EXIT_CODE = '0';
|
|
312
321
|
mkdirSync(join(o.home, 'logs'), { recursive: true, mode: 0o700 });
|
|
313
322
|
const self = CLI_JS;
|
|
314
|
-
|
|
323
|
+
// the install in the AgentChannel home (appinstall.ts), so the service follows its updates; run through npx, this release is copied
|
|
324
|
+
// there first. npx itself only when that copy failed; node on this very file for any other install (a global one, a checkout).
|
|
325
|
+
const { adoptFromNpx, appAch, appDir, inApp } = await import('./appinstall.js');
|
|
326
|
+
const npxRun = /[\\/]_npx[\\/]/.test(self);
|
|
327
|
+
const app = inApp(self, appDir(env)) ? appAch(env) : npxRun ? adoptFromNpx({ self, env, log: (s) => io.err(`[ach run] ${s}`) }) : undefined;
|
|
328
|
+
const npx = !app && npxRun ? (whichAll('npx', env).find((x) => !isBundledBin(x)) ?? join(dirname(process.execPath), 'npx')) : undefined;
|
|
315
329
|
const f = serviceFile({
|
|
316
330
|
platform,
|
|
317
331
|
agentName: o.agentName,
|
|
318
|
-
command: npx ? [npx, '-y', npmSpec()] : [process.execPath, self],
|
|
332
|
+
command: app ?? (npx ? [npx, '-y', npmSpec()] : [process.execPath, self]),
|
|
319
333
|
args,
|
|
320
334
|
env: svcEnv,
|
|
321
335
|
logFile: join(o.home, 'logs', 'runner.log'),
|
|
@@ -395,7 +409,11 @@ function lingers(env) {
|
|
|
395
409
|
return true;
|
|
396
410
|
}
|
|
397
411
|
}
|
|
398
|
-
/**
|
|
412
|
+
/**
|
|
413
|
+
* The runner is the service's own process and the service starts through the npx cache: this release is copied into the install in
|
|
414
|
+
* the AgentChannel home, the service rewritten to start that, the supervisor has it reloaded, and this one stops (the reload starts the
|
|
415
|
+
* new one).
|
|
416
|
+
*/
|
|
399
417
|
async function moveOldService(io, agentName, home) {
|
|
400
418
|
const env = io.env;
|
|
401
419
|
const platform = (env.ACH_SERVICE_PLATFORM || process.platform);
|
|
@@ -404,17 +422,19 @@ async function moveOldService(io, agentName, home) {
|
|
|
404
422
|
const { migrateOldService, reloadDetached, startedByService } = await import('./servicefix.js');
|
|
405
423
|
if (!env.ACH_SERVICE_DIR && !startedByService(agentName, platform, env))
|
|
406
424
|
return false;
|
|
407
|
-
const {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
425
|
+
const { listServices } = await import('./service.js');
|
|
426
|
+
const own = listServices(platform, env.ACH_SERVICE_DIR || undefined, env).find((s) => s.agentName === agentName.replace(/[^A-Za-z0-9-]/g, '-'));
|
|
427
|
+
if (!own || (own.format !== 'npx' && own.format !== 'node-cache'))
|
|
428
|
+
return false;
|
|
429
|
+
const { adoptFromNpx, appAch, appDir, currentVersion } = await import('./appinstall.js');
|
|
430
|
+
const { thisCliPath } = await import('./invite.js');
|
|
431
|
+
// the new service must be able to start: without the install (the copy failed), the old one stays as it is
|
|
432
|
+
const command = adoptFromNpx({ self: thisCliPath(), env, log: (s) => io.err(`[ach run] ${s}`) }) ?? (currentVersion(appDir(env)) ? appAch(env) : undefined);
|
|
433
|
+
if (!command)
|
|
413
434
|
return false;
|
|
414
|
-
}
|
|
415
435
|
let m;
|
|
416
436
|
try {
|
|
417
|
-
m = migrateOldService({ agentName, platform, dir: env.ACH_SERVICE_DIR || undefined, env, home,
|
|
437
|
+
m = migrateOldService({ agentName, platform, dir: env.ACH_SERVICE_DIR || undefined, env, home, command });
|
|
418
438
|
}
|
|
419
439
|
catch (e) {
|
|
420
440
|
io.err(`[ach run] could not rewrite the service file: ${e?.message ?? e}`);
|
|
@@ -422,8 +442,55 @@ async function moveOldService(io, agentName, home) {
|
|
|
422
442
|
}
|
|
423
443
|
if (!m)
|
|
424
444
|
return false;
|
|
425
|
-
io.err(`[ach run] this service started
|
|
445
|
+
io.err(`[ach run] this service started ach through the npx cache: rewrote ${m.path} to start ${command.join(' ')} and reloading it`);
|
|
426
446
|
if (!env.ACH_SERVICE_DIR)
|
|
427
447
|
reloadDetached(m.start, env);
|
|
428
448
|
return true;
|
|
429
449
|
}
|
|
450
|
+
/** A runner of the install in the AgentChannel home points the `ach` MCP entries that still start npx at it (onboard moveNpxMcpEntries). */
|
|
451
|
+
async function moveMcpEntries(io, dir) {
|
|
452
|
+
const { appAch, appDir, inApp } = await import('./appinstall.js');
|
|
453
|
+
const { thisCliPath } = await import('./invite.js');
|
|
454
|
+
if (io.env.ACH_SERVICE_DIR || !inApp(thisCliPath(), appDir(io.env)))
|
|
455
|
+
return; // tests, and runs of other installs
|
|
456
|
+
const { moveNpxMcpEntries } = await import('./onboard.js');
|
|
457
|
+
const { execFile } = await import('node:child_process');
|
|
458
|
+
const execIn = (cwd) => (file, args, env) => new Promise((res) => execFile(file, args, { cwd, env, timeout: 30_000, encoding: 'utf8' }, (err, stdout, stderr) => res({ code: err ? (typeof err.code === 'number' ? err.code : 1) : 0, stdout: String(stdout ?? ''), stderr: String(stderr ?? '') })));
|
|
459
|
+
// the user-scope entry is seen from a dir with no local entry: an empty one of ours
|
|
460
|
+
const empty = join(appDir(io.env), 'mcp-cwd');
|
|
461
|
+
(await import('node:fs')).mkdirSync(empty, { recursive: true });
|
|
462
|
+
// the runners of one machine restart together after a release: one at a time, since each `claude mcp add` rewrites ~/.claude.json
|
|
463
|
+
const { openSync, closeSync, statSync, unlinkSync } = await import('node:fs');
|
|
464
|
+
const lock = join(appDir(io.env), 'mcp-move.lock');
|
|
465
|
+
for (let i = 0;; i++) {
|
|
466
|
+
try {
|
|
467
|
+
closeSync(openSync(lock, 'wx'));
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
try {
|
|
472
|
+
if (Date.now() - statSync(lock).mtimeMs > 120_000)
|
|
473
|
+
unlinkSync(lock); // left by a runner that died holding it
|
|
474
|
+
}
|
|
475
|
+
catch {
|
|
476
|
+
/* gone already */
|
|
477
|
+
}
|
|
478
|
+
if (i >= 90)
|
|
479
|
+
return;
|
|
480
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
const moved = await moveNpxMcpEntries({ env: io.env, exec: execIn(dir), userExec: execIn(empty), achCmd: appAch(io.env), log: (s) => io.err(`[ach run] ${s}`) });
|
|
485
|
+
if (moved.length)
|
|
486
|
+
io.err(`[ach run] the \`ach\` MCP entry (${moved.join(', ')}) started npx: it starts ${appAch(io.env).join(' ')} now (new sessions)`);
|
|
487
|
+
}
|
|
488
|
+
finally {
|
|
489
|
+
try {
|
|
490
|
+
unlinkSync(lock);
|
|
491
|
+
}
|
|
492
|
+
catch {
|
|
493
|
+
/* gone already */
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -298,10 +298,29 @@ export interface MentionOutcome {
|
|
|
298
298
|
evidence?: string;
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
+
/** The task behind a task's thread, handed to its worker or sender when a mention wakes it there. */
|
|
302
|
+
export interface ThreadTask {
|
|
303
|
+
ref: string;
|
|
304
|
+
url?: string;
|
|
305
|
+
title: string;
|
|
306
|
+
status: string;
|
|
307
|
+
from_agent_name: string;
|
|
308
|
+
to_agent_name: string;
|
|
309
|
+
handoff: string;
|
|
310
|
+
messages: {
|
|
311
|
+
kind: string;
|
|
312
|
+
author_type: string;
|
|
313
|
+
author_name: string;
|
|
314
|
+
body: string;
|
|
315
|
+
created: string;
|
|
316
|
+
}[];
|
|
317
|
+
}
|
|
301
318
|
export interface MentionRun extends MentionItem {
|
|
302
319
|
replies: Post[];
|
|
303
320
|
recent: Post[];
|
|
304
321
|
run_token: string;
|
|
322
|
+
/** set when the thread is a task's and the agent is a party to it (an older hub leaves it out) */
|
|
323
|
+
task?: ThreadTask;
|
|
305
324
|
}
|
|
306
325
|
export interface SearchResult {
|
|
307
326
|
type: 'post' | 'task' | 'message' | 'handoff';
|
package/dist/src/doctor.d.ts
CHANGED
|
@@ -54,10 +54,10 @@ export declare function runDoctor(o: {
|
|
|
54
54
|
env: NodeJS.ProcessEnv;
|
|
55
55
|
hub?: string;
|
|
56
56
|
}) => Promise<import('./sandboxcheck.js').SandboxStatus>;
|
|
57
|
-
/** Tests: the
|
|
58
|
-
|
|
57
|
+
/** Tests: the machine check of a runtime that has its own (kiro: kiro-cli and KIRO_API_KEY), by runtime name. */
|
|
58
|
+
toolCheck?: Record<string, (o: {
|
|
59
59
|
env: NodeJS.ProcessEnv;
|
|
60
|
-
}) => Promise<import('./sandboxcheck.js').SandboxStatus
|
|
60
|
+
}) => Promise<import('./sandboxcheck.js').SandboxStatus>>;
|
|
61
61
|
}): Promise<DoctorCheck[]>;
|
|
62
62
|
/**
|
|
63
63
|
* Command, args and AGENTCHANNEL_HOME of an MCP entry from `claude mcp get`
|
package/dist/src/doctor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
|
+
import { runtimeSpec } from './adapters/spec.js';
|
|
2
3
|
import { existsSync } from 'node:fs';
|
|
3
4
|
import { createRequire } from 'node:module';
|
|
4
5
|
import { dirname, join } from 'node:path';
|
|
@@ -316,18 +317,23 @@ export async function runDoctor(o) {
|
|
|
316
317
|
if (codexPath)
|
|
317
318
|
await mcpCheck('codex', codexPath);
|
|
318
319
|
}
|
|
319
|
-
//
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
// runtimes with their own machine check (kiro: kiro-cli new enough for headless --cloud and KIRO_API_KEY; the run itself is in
|
|
321
|
+
// Kiro's cloud sandbox): checked when it is this agent's runtime, or when the tool is on this machine
|
|
322
|
+
const { TOOL_CHECKS } = await import('./runtimecheck.js');
|
|
323
|
+
for (const [name, check] of Object.entries(TOOL_CHECKS)) {
|
|
324
|
+
const mine = runtime === name;
|
|
325
|
+
if (!mine && !(await check.installed(env)))
|
|
326
|
+
continue;
|
|
327
|
+
const spec = runtimeSpec(name);
|
|
328
|
+
const st = await (o.toolCheck?.[name] ?? check.probe)({ env });
|
|
323
329
|
if (st.ok)
|
|
324
|
-
add(
|
|
330
|
+
add(name, 'ok', `${st.detail}${spec.where === 'cloud' ? `; runs go to ${spec.label} cloud sandboxes` : ''}`);
|
|
325
331
|
else
|
|
326
|
-
add(
|
|
332
|
+
add(name, mine ? 'fail' : 'info', `${st.detail}.${mine ? ' The background runner takes no tasks until this is fixed.' : ` (needed only for the ${name} runtime)`}`, 'machine', st.fix?.commands.length ? st.fix.commands.join('\n ') : st.fix?.en);
|
|
327
333
|
}
|
|
328
334
|
// decisions §27: the agent tool's sandbox, probed for real (every run that answers a question or an @mention is sandboxed)
|
|
329
335
|
const { probeSandbox } = await import('./sandboxcheck.js');
|
|
330
|
-
const tools = runtime
|
|
336
|
+
const tools = runtime && runtimeSpec(runtime)?.check !== 'sandbox' ? [] : runtime === 'codex' ? ['codex'] : runtime === 'claude' ? ['claude'] : [...(claude ? ['claude'] : []), ...(codexPath || bundled ? ['codex'] : [])];
|
|
331
337
|
for (const t of tools) {
|
|
332
338
|
const st = await (o.sandbox ?? probeSandbox)(t, { env, hub: cfg.hub });
|
|
333
339
|
const name = `${t} sandbox`;
|
package/dist/src/invite.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { accessSync, constants, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
2
2
|
import { delimiter, dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { appAch, appDir, currentVersion, inApp } from './appinstall.js';
|
|
4
5
|
import { PKG_NAME, VERSION } from './version.js';
|
|
5
6
|
const PREFIX = 'ach2.';
|
|
6
7
|
export const JOIN_TOKEN_RE = /^ach_jt_[a-z0-9]{15}_[A-Za-z0-9]{40}$/;
|
|
@@ -203,9 +204,12 @@ export function mcpCommands(o) {
|
|
|
203
204
|
* earlier on PATH, or none, must never be what the MCP entry runs).
|
|
204
205
|
*/
|
|
205
206
|
export function achCommand(env = process.env, self = thisCliPath()) {
|
|
206
|
-
//
|
|
207
|
+
// the install in the AgentChannel home (appinstall.ts): its launcher, which follows the updates
|
|
208
|
+
if (inApp(self, appDir(env)))
|
|
209
|
+
return appAch(env);
|
|
210
|
+
// run through npx: the install when join put one there, else the pinned npx spec (the cache may be cleared)
|
|
207
211
|
if (/[\\/]_npx[\\/]/.test(self))
|
|
208
|
-
return npxAch();
|
|
212
|
+
return currentVersion(appDir(env)) ? appAch(env) : npxAch();
|
|
209
213
|
const first = whichAll('ach', env)[0];
|
|
210
214
|
if (first && isOurs(identifyAch(first, self)))
|
|
211
215
|
return ['ach'];
|
package/dist/src/onboard.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExecLike } from './doctor.js';
|
|
2
2
|
import { type SandboxStatus, type SandboxTool } from './sandboxcheck.js';
|
|
3
3
|
/**
|
|
4
4
|
* One-line onboarding: what `ach join` sets up after the key is stored.
|
|
@@ -84,7 +84,7 @@ export interface Detected {
|
|
|
84
84
|
/** An `ach` entry already registered (it is replaced). */
|
|
85
85
|
claudeHasAch: boolean;
|
|
86
86
|
codexHasAch: boolean;
|
|
87
|
-
/** How the MCP entry and service start ach: the
|
|
87
|
+
/** How the MCP entry and service start ach: the install in the AgentChannel home when run through npx, else an absolute `ach`. */
|
|
88
88
|
achCmd: Argv;
|
|
89
89
|
}
|
|
90
90
|
/** The absolute command that starts this CLI: the first `ach` on PATH when it is this package, else node + this file. */
|
|
@@ -117,3 +117,22 @@ export interface SetupResult {
|
|
|
117
117
|
export declare function runSetup(io: SetupIo, o: SetupOptions): Promise<SetupResult>;
|
|
118
118
|
/** The Linux command that lets a user's services outlive their logins. */
|
|
119
119
|
export declare const LINGER_CMD = "sudo loginctl enable-linger \"$USER\"";
|
|
120
|
+
/** An entry that starts this package through npx (`npx -y @koalaauto/agentchannel@3 mcp`). */
|
|
121
|
+
export declare function isNpxEntry(e: {
|
|
122
|
+
command?: string;
|
|
123
|
+
args: string[];
|
|
124
|
+
}): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* The `ach` MCP entries of Claude Code and Codex that join wrote as `npx -y <spec> mcp` are pointed at the install in the AgentChannel
|
|
127
|
+
* home (`achCmd`), keeping their scope and AGENTCHANNEL_HOME: npx re-resolves the spec at every session start and fails while npm catches
|
|
128
|
+
* up with a release. `exec` runs in the runner's project dir, where Claude Code keeps a local-scope entry; `userExec` in a dir with no
|
|
129
|
+
* entries of its own, where `claude mcp get` shows the user-scope one (a local entry hides it). A project-scope entry (.mcp.json, in the
|
|
130
|
+
* repository) is left alone. Returns what was moved, as `<tool> <scope>`.
|
|
131
|
+
*/
|
|
132
|
+
export declare function moveNpxMcpEntries(o: {
|
|
133
|
+
env: NodeJS.ProcessEnv;
|
|
134
|
+
exec: ExecLike;
|
|
135
|
+
userExec?: ExecLike;
|
|
136
|
+
achCmd: Argv;
|
|
137
|
+
log?: (s: string) => void;
|
|
138
|
+
}): Promise<string[]>;
|