@koalaauto/agentchannel 3.96.0 → 3.97.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/dist/src/args.js +2 -1
- package/dist/src/cli.js +12 -3
- package/dist/src/invite.d.ts +8 -0
- package/dist/src/invite.js +27 -3
- package/dist/src/selfupdate.d.ts +2 -1
- package/dist/src/selfupdate.js +6 -3
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/args.js
CHANGED
|
@@ -169,7 +169,8 @@ Setup: npx -y @koalaauto/agentchannel@3 join <ach2.line> (a line from the
|
|
|
169
169
|
everywhere but in a directory an agent was joined from)
|
|
170
170
|
npx -y @koalaauto/agentchannel@3 join <ach2.invite> [--name <n>] [--service] [--yes] [--dry-run] (run it in the
|
|
171
171
|
project directory: a line from the panel's "Connect an agent" creates the agent there, named
|
|
172
|
-
"<your name>-<directory>" (lowercase); --name replaces the part after "<your name>-"
|
|
172
|
+
"<your name>-<directory>" (lowercase); --name replaces the part after "<your name>-" and names the project, never
|
|
173
|
+
the tool (agentchannel, claude, codex …); not in the home, Desktop, Documents or Downloads itself; a line from the panel or
|
|
173
174
|
\`ach admin invite <agent>\`: stores the agent's key and adds the \`ach\` MCP server to the agent's own tool
|
|
174
175
|
(Claude Code or Codex). In a terminal it shows the hub and every command first and asks once; --yes skips
|
|
175
176
|
that; run by an agent (no terminal) it just does it. --service also installs the background helper
|
package/dist/src/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { hostname } from 'node:os';
|
|
2
|
+
import { homedir, hostname, tmpdir } from 'node:os';
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
4
|
import { randomBytes } from 'node:crypto';
|
|
5
5
|
import { readFileSync, realpathSync, writeFileSync } from 'node:fs';
|
|
@@ -11,7 +11,7 @@ import { guideHeader, GuideSectionUnknown, readGuide } from './guide.js';
|
|
|
11
11
|
import { channelTails, closest, decisionTo, explainToUser, matchChannel, unreachedLines } from './names.js';
|
|
12
12
|
import { refOf, untrustedBlock as wrapUntrusted } from './prompts.js';
|
|
13
13
|
import { agentHome, homeForDir, loadConfig, personHome, readFileConfig, saveAgentKey, saveCfSecret, sessionHome, sessionParts, writeFileConfig } from './config.js';
|
|
14
|
-
import { achCommand, decodeInvite, mcpCommands, shadowHint } from './invite.js';
|
|
14
|
+
import { achCommand, decodeInvite, isConnectInvite, mcpCommands, notAProjectDir, shadowHint } from './invite.js';
|
|
15
15
|
import { AttachError, humanSize, isLinkRef, resolveAttachments, taskFiles } from './attachments.js';
|
|
16
16
|
export { VERSION } from './version.js';
|
|
17
17
|
import { VERSION } from './version.js';
|
|
@@ -339,6 +339,15 @@ async function dispatch(p, io) {
|
|
|
339
339
|
catch (e) {
|
|
340
340
|
throw new UsageError(`join: ${e.message}`);
|
|
341
341
|
}
|
|
342
|
+
// a line that makes a new agent names it after this directory, and its runner works in it: a catch-all folder is no
|
|
343
|
+
// project (refused before anything is used or written)
|
|
344
|
+
const notProject = isConnectInvite(inv) ? notAProjectDir(io.cwd ?? process.cwd(), env.HOME || homedir(), tmpdir()) : undefined;
|
|
345
|
+
if (notProject) {
|
|
346
|
+
io.err(zhJ
|
|
347
|
+
? `ach join:这里不是一个项目目录(${io.cwd ?? process.cwd()})。这行会建一个以所在目录命名的智能体,它的运行器在这个目录里干活。请到项目的目录里再运行这一行;要让 Claude Code 或 Codex 当你自己的助手,请在面板「连接」里选「这台电脑」,它连到你的 Yoda,不建智能体。邀请还没有用掉。`
|
|
348
|
+
: `ach join: this is not a project directory (${io.cwd ?? process.cwd()}). This line makes an agent named after the directory it runs in, and its runner works there. Run it again in the project's directory; to use Claude Code or Codex as your own helper, pick "This computer" under Connect in the panel: it connects to your Yoda and makes no agent. The invite is still unused.`);
|
|
349
|
+
return 1;
|
|
350
|
+
}
|
|
342
351
|
// the hub this line sends the key to: shown always, confirmed when a person is at the terminal
|
|
343
352
|
const hubHost = new URL(inv.hub).host;
|
|
344
353
|
if (io.ask && !v.yes && !v.json && !v['dry-run']) {
|
|
@@ -393,7 +402,7 @@ async function dispatch(p, io) {
|
|
|
393
402
|
}
|
|
394
403
|
catch (e) {
|
|
395
404
|
if (e instanceof HubError && (e.code === 'conflict' || e.code === 'invalid_name')) {
|
|
396
|
-
io.err(isZh(env) ? `ach join:${e.message}
|
|
405
|
+
io.err(isZh(env) ? `ach join:${e.message}。用项目的名字再运行:加上 --name <项目名>(你的名字- 后面的部分,小写字母、数字和 -,不要用 agentchannel、claude、codex 这类词)。邀请还没有用掉。` : `ach join: ${e.message}. Run it again with --name <project> (the part after your name-, lowercase letters, digits and -; not a word like agentchannel, claude or codex); the invite is still unused.`);
|
|
397
406
|
return 1;
|
|
398
407
|
}
|
|
399
408
|
if (e instanceof HubError && e.code === 'cf_access') {
|
package/dist/src/invite.d.ts
CHANGED
|
@@ -20,6 +20,14 @@ export interface Invite {
|
|
|
20
20
|
}
|
|
21
21
|
/** A join token: ach_jt_<agent id, either format>_<secret>. */
|
|
22
22
|
export declare const isJoinToken: (s: string) => boolean;
|
|
23
|
+
/** A line that makes a new agent named after the directory it runs in (a connect invite), not one for an agent that exists. */
|
|
24
|
+
export declare const isConnectInvite: (i: Invite) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Why `dir` is no project for an agent of its own, or undefined: the home directory, the root, the temporary directory or
|
|
27
|
+
* one of the home's catch-all folders (Desktop, Documents, Downloads). An agent there would work in all of a person's files
|
|
28
|
+
* under a name that says nothing; a person's general helper is their Yoda, reached by connecting a client instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare function notAProjectDir(dir: string, home: string, tmp: string): 'root' | 'home' | 'tmp' | 'container' | undefined;
|
|
23
31
|
export declare function encodeInvite(i: Invite): string;
|
|
24
32
|
export declare function decodeInvite(blob: string): Invite;
|
|
25
33
|
/**
|
package/dist/src/invite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { accessSync, constants, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
-
import { delimiter, dirname, join } from 'node:path';
|
|
2
|
+
import { basename, delimiter, dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { appAch, appDir, currentVersion, inApp } from './appinstall.js';
|
|
5
5
|
import { PKG_NAME, VERSION } from './version.js';
|
|
@@ -8,6 +8,30 @@ const PREFIX = 'ach2.';
|
|
|
8
8
|
const JOIN_SHAPE_RE = /^ach_jt_([0-9A-Za-z]{15,16})_[A-Za-z0-9]{40}$/;
|
|
9
9
|
/** A join token: ach_jt_<agent id, either format>_<secret>. */
|
|
10
10
|
export const isJoinToken = (s) => isId(JOIN_SHAPE_RE.exec(s)?.[1], 'G');
|
|
11
|
+
/** The agent part of a connect invite's join token: the invite makes its agent when it is used (hub OPEN_JOIN). */
|
|
12
|
+
const CONNECT_JOIN = 'newagent0000000';
|
|
13
|
+
/** A line that makes a new agent named after the directory it runs in (a connect invite), not one for an agent that exists. */
|
|
14
|
+
export const isConnectInvite = (i) => !i.link && JOIN_SHAPE_RE.exec(i.join)?.[1] === CONNECT_JOIN;
|
|
15
|
+
/** Folders that hold everything on a computer: below them are projects. */
|
|
16
|
+
const CONTAINER_DIRS = ['desktop', 'documents', 'downloads', '桌面', '文档', '下载'];
|
|
17
|
+
/**
|
|
18
|
+
* Why `dir` is no project for an agent of its own, or undefined: the home directory, the root, the temporary directory or
|
|
19
|
+
* one of the home's catch-all folders (Desktop, Documents, Downloads). An agent there would work in all of a person's files
|
|
20
|
+
* under a name that says nothing; a person's general helper is their Yoda, reached by connecting a client instead.
|
|
21
|
+
*/
|
|
22
|
+
export function notAProjectDir(dir, home, tmp) {
|
|
23
|
+
const clean = (p) => resolve(p).replace(/[\\/]+$/, '') || '/';
|
|
24
|
+
const d = clean(dir);
|
|
25
|
+
if (d === '/' || /^[A-Za-z]:$/.test(d))
|
|
26
|
+
return 'root';
|
|
27
|
+
if (home && d === clean(home))
|
|
28
|
+
return 'home';
|
|
29
|
+
if (tmp && d === clean(tmp))
|
|
30
|
+
return 'tmp';
|
|
31
|
+
if (home && dirname(d) === clean(home) && CONTAINER_DIRS.includes(basename(d).toLowerCase()))
|
|
32
|
+
return 'container';
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
11
35
|
const LINK_CODE_RE = /^ach_lc_[A-Za-z0-9]{40}$/;
|
|
12
36
|
export function encodeInvite(i) {
|
|
13
37
|
const o = i.link ? { hub: i.hub.replace(/\/+$/, ''), link: i.link } : { hub: i.hub.replace(/\/+$/, ''), join: i.join };
|
|
@@ -250,11 +274,11 @@ export function agentInvitePrompt(line, lang = 'en') {
|
|
|
250
274
|
const npx = `npx -y ${spec}`;
|
|
251
275
|
const run = / --service(\s|$)/.test(line) ? line : `${line} --service`;
|
|
252
276
|
if (lang === 'zh') {
|
|
253
|
-
return (
|
|
277
|
+
return (`请把这个项目接入团队的 AgentChannel:在这个项目的目录里运行 \`${run}\`,不加 --name,也不要为它新建目录;当前目录不是一个项目的话,先问我。` +
|
|
254
278
|
`它会保存这个智能体的密钥,把 AgentChannel 接入你自己,并安装一个后台运行器(登录后自动在这个项目目录里领取并执行派给它的任务);这行只能用一次。` +
|
|
255
279
|
`完成后告诉我收件箱里有什么,以及后台运行器有没有装好、在不在运行。如果这行报错或某一步失败,先把报错原文告诉我,再运行 \`${npx} doctor\`,按提示修好再继续。`);
|
|
256
280
|
}
|
|
257
|
-
return (`Please connect
|
|
281
|
+
return (`Please connect this project to my team's AgentChannel: run \`${run}\` in this project's directory, without --name, and make no new directory for it; if the current directory is not a project, ask me first. ` +
|
|
258
282
|
`It stores this agent's key, adds AgentChannel to you, and installs a background runner (it starts at login and picks up the tasks sent to this agent, working in this project's directory); the line works once. ` +
|
|
259
283
|
`Then tell me what is in my inbox and whether the background runner is installed and running. If the line fails or a step fails, tell me its exact error first, then run \`${npx} doctor\`, fix what it says, and continue.`);
|
|
260
284
|
}
|
package/dist/src/selfupdate.d.ts
CHANGED
|
@@ -101,7 +101,8 @@ export interface Quiescable {
|
|
|
101
101
|
busy(): number;
|
|
102
102
|
stop(): Promise<void>;
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
/** 'unreachable': the hub's versions could not be read (offline, an old hub, or the hub failing for a while) */
|
|
105
|
+
export type CheckResult = 'none' | 'unreachable' | 'manual' | 'off' | 'backoff' | 'busy' | 'failed' | 'restarting';
|
|
105
106
|
export interface SelfUpdaterOptions {
|
|
106
107
|
fetchVersions: () => Promise<HubVersions | null>;
|
|
107
108
|
platform?: NodeJS.Platform;
|
package/dist/src/selfupdate.js
CHANGED
|
@@ -238,8 +238,11 @@ export class SelfUpdater {
|
|
|
238
238
|
if (r === 'manual' || r === 'off')
|
|
239
239
|
this.heard.set(latest, -1);
|
|
240
240
|
// the hub names a release the moment it is deployed, a minute or two before npm serves it: that try fails with nothing
|
|
241
|
-
// paused, and waiting the hour for it kept every runner an hour behind each release.
|
|
242
|
-
|
|
241
|
+
// paused, and waiting the hour for it kept every runner an hour behind each release. A hub that names the release on an
|
|
242
|
+
// error and then fails the versions read is the same: 2026-11-25 three of twelve pool runners heard 3.95.1 while the hub
|
|
243
|
+
// was failing, waited the hour, and held their pool (which restarts once every runner has moved) half an hour. Both are
|
|
244
|
+
// asked again in five minutes.
|
|
245
|
+
this.heardWait.set(latest, r === 'failed' || r === 'unreachable' ? 5 * 60_000 : 3600_000);
|
|
243
246
|
return r;
|
|
244
247
|
});
|
|
245
248
|
}
|
|
@@ -253,7 +256,7 @@ export class SelfUpdater {
|
|
|
253
256
|
hub = await this.o.fetchVersions();
|
|
254
257
|
}
|
|
255
258
|
catch {
|
|
256
|
-
return '
|
|
259
|
+
return 'unreachable';
|
|
257
260
|
}
|
|
258
261
|
const prior = loadUpdateState(this.o.home);
|
|
259
262
|
if (prior && prior.target === version && isHealthy(this.o.home, version))
|
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.97.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",
|