@koalaauto/agentchannel 3.69.0 → 3.71.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 CHANGED
@@ -142,6 +142,7 @@ ach notify --test # shows a test desktop notification
142
142
 
143
143
  ```sh
144
144
  ach inbox # what is waiting for you
145
+ ach dot "<message>" # ask your owner's Dot: who does what, what waits for you, work to hand on
145
146
  ach send --to <agent> ... # hand a task to another agent
146
147
  ach open # open the panel in your browser, logged in
147
148
  ach run --dir <repo> # work tasks on this machine (foreground)
@@ -156,6 +157,12 @@ ach admin invite <agent> --line # only the join line: npx -y @koalaauto/ag
156
157
  ach admin invite <person> [--feishu] # a one-time login link for the panel (--feishu sends it on Feishu)
157
158
  ```
158
159
 
160
+ To keep the cloud workspaces of a pool running (a machine the team runs; ACH_POOL_KEY from an admin):
161
+
162
+ ```sh
163
+ ach pool kiro --dir /srv/ach-pool
164
+ ```
165
+
159
166
  Every link and line works once or expires, and a new one replaces the old.
160
167
  Send them privately until they are used.
161
168
 
@@ -49,7 +49,7 @@ export async function probeAgy(o = {}) {
49
49
  }
50
50
  const token = join(home(env), '.gemini', 'antigravity-cli', 'antigravity-oauth-token');
51
51
  if (!(o.exists ?? existsSync)(token)) {
52
- return { tool, ok: false, problem: 'not-logged-in', detail: `agy ${version}; not logged in`, fix: { en: 'Antigravity is not logged in on this machine: run `agy` once as the user that runs this agent and sign in.', zh: 'Antigravity 在这台机器上没有登录:以运行这个智能体的用户身份执行一次 `agy` 并登录。', commands: ['agy'] } };
52
+ return { tool, ok: false, problem: 'not-logged-in', detail: `agy ${version}; not logged in`, fix: { en: 'Antigravity is not logged in on this machine: run `agy` once as the user that runs this agent and sign in.', zh: 'Antigravity 在这台机器上没有登录:以运行 runner 的用户身份执行一次 `agy` 并登录。', commands: ['agy'] } };
53
53
  }
54
54
  if (agySandboxBlocked({ platform: o.platform, read: o.read })) {
55
55
  return { tool, ok: false, problem: 'userns-blocked', detail: `agy ${version}; its sandbox cannot start (AppArmor restricts unprivileged user namespaces)`, fix: { en: "AppArmor stops agy from creating the user namespaces its sandbox is made of: add a profile that lets it.", zh: 'AppArmor 不让 agy 创建沙箱需要的用户命名空间:加一条放行它的规则。', commands: [AGY_APPARMOR] } };
package/dist/src/args.js CHANGED
@@ -23,6 +23,8 @@ export const COMMANDS = {
23
23
  handoff: { file: s, note: s, priority: s, purpose: s, money: s, 'key-question': s, attach: sm, 'attach-url': sm, ...json },
24
24
  task: { ...json },
25
25
  download: { out: s, ...json },
26
+ 'artifact publish': { title: s, artifact: s, note: s, team: b, ...json },
27
+ 'artifact get': { version: s, out: s, ...json },
26
28
  inbox: { owner: b, ...json },
27
29
  channels: { all: b, ...json },
28
30
  channel: { since: s, before: s, limit: s, ...json },
@@ -90,7 +92,7 @@ export function parseCli(argv) {
90
92
  return { cmd: 'version', values: {}, positionals: [] };
91
93
  let cmd = first;
92
94
  // `ach admin --help`, `ach memory -h`: the group's help, before a subcommand is expected
93
- if (['admin', 'memory', 'wiki'].includes(first) && (rest[0] === '--help' || rest[0] === '-h'))
95
+ if (['admin', 'memory', 'wiki', 'artifact'].includes(first) && (rest[0] === '--help' || rest[0] === '-h'))
94
96
  return { cmd: 'help', values: {}, positionals: [first === 'wiki' ? 'memory' : first] };
95
97
  if (first === 'admin') {
96
98
  const sub = rest[0];
@@ -99,6 +101,13 @@ export function parseCli(argv) {
99
101
  cmd = `admin ${sub}`;
100
102
  rest = rest.slice(1);
101
103
  }
104
+ if (first === 'artifact') {
105
+ const sub = rest[0];
106
+ if (!sub)
107
+ throw new UsageError('artifact needs a subcommand: publish, get');
108
+ cmd = `artifact ${sub}`;
109
+ rest = rest.slice(1);
110
+ }
102
111
  // `ach wiki ...` is the older name of `ach memory ...` (kept as a hidden alias)
103
112
  if (first === 'memory' || first === 'wiki') {
104
113
  const sub = rest[0];
@@ -157,7 +166,7 @@ export const HELP = `ach - AgentChannel CLI
157
166
 
158
167
  Setup: npx -y @koalaauto/agentchannel@3 join <ach2.invite> [--name <n>] [--service] [--yes] [--dry-run] (run it in the
159
168
  project directory: a line from the panel's "Connect an agent" creates the agent there, named
160
- "<your name>-<directory>" (lowercase) unless --name says otherwise; a line from the panel or
169
+ "<your name>-<directory>" (lowercase); --name replaces the part after "<your name>-"; a line from the panel or
161
170
  \`ach admin invite <agent>\`: stores the agent's key and adds the \`ach\` MCP server to the agent's own tool
162
171
  (Claude Code or Codex). In a terminal it shows the hub and every command first and asks once; --yes skips
163
172
  that; run by an agent (no terminal) it just does it. --service also installs the background helper
@@ -177,6 +186,11 @@ Tasks: ach send --to <agent> --title <t> --priority P0..P3 --purpose <p> --
177
186
  ach task <id|TASK-128> (lists attachments with download URLs) | ach inbox [--owner]
178
187
  Every task argument also takes the TASK-<seq> number shown in the panel (TASK-128; T-128 still works).
179
188
  ach download <taskId> [--out <dir>] (fetches every attachment; default ./ach-files-<taskId>)
189
+ Artifacts: ach artifact publish <file.html> --title <t> [--note <what changed>] [--team] (a page people open in the panel with its
190
+ scripts running; gets its own link A-12; private to your owner's side until you name A-12 in a post, reply,
191
+ task message or handoff, then whoever reads that place can open it; --team: the whole team can)
192
+ ach artifact publish <file.html> --artifact A-12 [--note <what changed>] (a new version: same link, old versions kept)
193
+ ach artifact get A-12 [--version n] [--out <dir>] (its versions and where it is attached; saves the HTML, default ./ach-artifacts)
180
194
  Messages: ach ask [--task <id>] [--to <agent>] "<question>"
181
195
  ach answer [--task <id>] --reply-to <msgId> --evidence "<files/commands>" "<answer>"
182
196
  ach decide [--task <id>] <requestId> "<reply>" (interactive sessions only, with your agent key: your owner's reply, marked "via <agent>")
@@ -35,6 +35,7 @@ export declare function typeOf(path: string): string;
35
35
  export declare function resolveAttachments(paths: string[] | undefined, io: {
36
36
  env: NodeJS.ProcessEnv;
37
37
  cwd?: string;
38
+ textMaxBytes?: number;
38
39
  }): string[];
39
40
  /** Multipart body: the JSON body in field "json", files in "attachments". */
40
41
  export declare function attachmentForm(json: unknown, files: string[]): Promise<FormData>;
@@ -104,8 +104,9 @@ export function resolveAttachments(paths, io) {
104
104
  if (!typeOf(real))
105
105
  throw new AttachError(`attachment ${p}: only ${Object.keys(ATTACH_TYPES).join(', ')} files are accepted`);
106
106
  const ext = (/\.([A-Za-z0-9]+)$/.exec(real)?.[1] ?? '').toLowerCase();
107
- if (!BINARY_EXT.has(ext) && statSync(real).size > TEXT_MAX_BYTES)
108
- throw new AttachError(`attachment ${p}: text files are limited to 2 MB`);
107
+ const textMax = io.textMaxBytes ?? TEXT_MAX_BYTES;
108
+ if (!BINARY_EXT.has(ext) && statSync(real).size > textMax)
109
+ throw new AttachError(`attachment ${p}: text files are limited to ${Math.round(textMax / 1048576)} MB`);
109
110
  return real;
110
111
  });
111
112
  }
@@ -15,7 +15,7 @@ export declare function runCommand(p: Parsed, io: Io): Promise<number>;
15
15
  */
16
16
  export declare const NO_KEY_MESSAGE: {
17
17
  readonly en: "ach run: there is no key for this agent on this machine (deleted, or a new machine or directory).\nA key cannot be recovered: in the panel open the agent and rotate its key (an admin or its owner can), then run the new `join` line here, in the agent's project directory.";
18
- readonly zh: "ach run:这台机器上没有这个智能体的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开这个智能体,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。";
18
+ readonly zh: "ach run:这台机器上没有它的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开它的页面,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。";
19
19
  };
20
20
  /** B7: `ach run` exit code when the hub answers 401 (systemd: RestartPreventExitStatus=78). */
21
21
  export declare const AUTH_EXIT_CODE = 78;
@@ -269,7 +269,7 @@ export async function runCommand(p, io) {
269
269
  */
270
270
  export const NO_KEY_MESSAGE = {
271
271
  en: 'ach run: there is no key for this agent on this machine (deleted, or a new machine or directory).\nA key cannot be recovered: in the panel open the agent and rotate its key (an admin or its owner can), then run the new `join` line here, in the agent\'s project directory.',
272
- zh: 'ach run:这台机器上没有这个智能体的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开这个智能体,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。',
272
+ zh: 'ach run:这台机器上没有它的密钥(被删除了,或是新机器、新目录)。\n密钥找不回,只能换新:在面板里打开它的页面,点「换新密钥」(管理员或负责人可以),再到它的项目目录里运行新生成的 `join` 命令。',
273
273
  };
274
274
  /** B7: print the rejoin hint and return the auth exit code (ACH_AUTH_EXIT_CODE overrides it). */
275
275
  function authExit(io, message = AUTH_EXIT_MESSAGE) {
package/dist/src/cli.js CHANGED
@@ -308,7 +308,7 @@ async function dispatch(p, io) {
308
308
  // exchange the one-time join token for the agent key
309
309
  let key;
310
310
  try {
311
- // a connect invite creates its agent now, named after this directory ("<owner name>-<dir>") unless --name says otherwise;
311
+ // a connect invite creates its agent now, named "<owner's handle>-<dir>"; --name replaces the part after the handle;
312
312
  // an invite for an existing agent ignores both
313
313
  // only the directory's own name goes to the hub, never the path to it
314
314
  const dir = basename(io.cwd ?? process.cwd());
@@ -317,11 +317,11 @@ async function dispatch(p, io) {
317
317
  throw new Error('the hub returned no key');
318
318
  key = String(ex.key);
319
319
  if (ex.created && ex.agent?.name)
320
- io.err(zhJ ? `已创建智能体 ${ex.agent.name}(按这个目录命名;要换名字,下次加 --name)。` : `created the agent ${ex.agent.name} (named after this directory; use --name next time for another).`);
320
+ io.err(zhJ ? `已创建环境 ${ex.agent.name}。` : `created the environment ${ex.agent.name}.`);
321
321
  }
322
322
  catch (e) {
323
323
  if (e instanceof HubError && (e.code === 'conflict' || e.code === 'invalid_name')) {
324
- io.err(isZh(env) ? `ach join:${e.message}。换一个名字再运行:加上 --name <名字>(小写字母、数字和 -)。邀请还没有用掉。` : `ach join: ${e.message}. Run it again with --name <name> (lowercase letters, digits and -); the invite is still unused.`);
324
+ io.err(isZh(env) ? `ach join:${e.message}。换一个名字再运行:加上 --name <名字>(你的名字- 后面的部分,小写字母、数字和 -)。邀请还没有用掉。` : `ach join: ${e.message}. Run it again with --name <name> (the part after your name-, lowercase letters, digits and -); the invite is still unused.`);
325
325
  return 1;
326
326
  }
327
327
  if (e instanceof HubError && e.code === 'cf_access') {
@@ -367,11 +367,11 @@ async function dispatch(p, io) {
367
367
  if (other && !env.AGENTCHANNEL_HOME) {
368
368
  jenv = { ...env, AGENTCHANNEL_HOME: agentHome(me.name, env) };
369
369
  io.err(zh
370
- ? `这台机器的默认目录里已经是智能体 ${other} 的密钥,它保持不变;${me.name} 存到自己的目录 ${jenv.AGENTCHANNEL_HOME},只接入这个项目(${cwd})。`
370
+ ? `这台机器的默认目录里已经是 ${other} 的密钥,它保持不变;${me.name} 存到自己的目录 ${jenv.AGENTCHANNEL_HOME},只接入这个项目(${cwd})。`
371
371
  : `This machine's default home already holds agent ${other}'s key; it stays. ${me.name} gets a home of its own, ${jenv.AGENTCHANNEL_HOME}, and is added to this project (${cwd}) only.`);
372
372
  }
373
373
  else if (other) {
374
- io.err(zh ? `注意:AGENTCHANNEL_HOME(${env.AGENTCHANNEL_HOME})里原来是智能体 ${other} 的密钥,现在换成 ${me.name}。` : `Note: AGENTCHANNEL_HOME (${env.AGENTCHANNEL_HOME}) held agent ${other}'s key; it is now ${me.name}'s.`);
374
+ io.err(zh ? `注意:AGENTCHANNEL_HOME(${env.AGENTCHANNEL_HOME})里原来是 ${other} 的密钥,现在换成 ${me.name}。` : `Note: AGENTCHANNEL_HOME (${env.AGENTCHANNEL_HOME}) held agent ${other}'s key; it is now ${me.name}'s.`);
375
375
  }
376
376
  }
377
377
  const separate = jenv !== env;
@@ -389,7 +389,7 @@ async function dispatch(p, io) {
389
389
  return 0;
390
390
  }
391
391
  out(zh
392
- ? `已加入 ${inv.hub},智能体 ${me.name}${me.owner_name ? `(主人 ${me.owner_name})` : ''};密钥保存在${where === 'keychain' ? '系统钥匙串' : ' agent-key 文件(0600)'}。`
392
+ ? `已加入 ${inv.hub},身份 ${me.name}${me.owner_name ? `(主人 ${me.owner_name})` : ''};密钥保存在${where === 'keychain' ? '系统钥匙串' : ' agent-key 文件(0600)'}。`
393
393
  : `joined ${inv.hub} as agent ${me.name}${me.owner_name ? ` (owner ${me.owner_name})` : ''}; key stored in the ${where === 'keychain' ? 'OS keychain' : 'agent-key file (0600)'}.`);
394
394
  const { runSetup, doneLine } = await import('./onboard.js');
395
395
  const { defaultExec } = await import('./doctor.js');
@@ -580,6 +580,36 @@ async function dispatch(p, io) {
580
580
  }
581
581
  return 0;
582
582
  }
583
+ case 'artifact publish': {
584
+ const [path] = p.positionals;
585
+ if (!path)
586
+ throw new UsageError('artifact publish: <file.html> is required');
587
+ const [file] = resolveAttachments([path], { env, cwd: io.cwd ?? process.cwd(), textMaxBytes: 95 * 1048576 });
588
+ if (!/\.html?$/i.test(file))
589
+ throw new UsageError('artifact publish: the file must be .html');
590
+ if (!str(v.artifact) && !str(v.title))
591
+ throw new UsageError('artifact publish: --title is required for a new artifact');
592
+ const r = await client().publishArtifact(file, { title: str(v.title), note: str(v.note), artifact: str(v.artifact), ...(v.team ? { visibility: 'team' } : {}) });
593
+ out(v.json ? r : `${r.ref} v${r.version} (${r.visibility}): ${(env.ACH_PUBLIC_URL || client().hub).replace(/\/+$/, '')}/#/artifact/${r.ref}\nName ${r.ref} in a post, reply or task message to show it there.`);
594
+ return 0;
595
+ }
596
+ case 'artifact get': {
597
+ const [ref] = p.positionals;
598
+ if (!ref)
599
+ throw new UsageError('artifact get: <A-12> is required');
600
+ const cwd = io.cwd ?? process.cwd();
601
+ const dir = resolve(cwd, str(v.out) ?? 'ach-artifacts');
602
+ if (env.ACH_RUN_TOKEN) {
603
+ const rel = relative(realpathSync(cwd), dir);
604
+ if (rel.startsWith('..') || isAbsolute(rel))
605
+ throw new UsageError('artifact get: inside a spawned agent, --out must be inside the working directory');
606
+ }
607
+ const c = client();
608
+ const a = await c.getArtifact(ref);
609
+ const path = await c.downloadArtifact(a, Number(str(v.version)) || a.version, dir);
610
+ out(v.json ? { ...a, saved: path } : `${a.ref} "${a.title}" v${a.version} (${a.visibility})\nsaved: ${path}`);
611
+ return 0;
612
+ }
583
613
  case 'download': {
584
614
  const id = p.positionals[0] ?? str(env.ACH_TASK_ID);
585
615
  if (!id)
@@ -1114,11 +1144,11 @@ async function dispatch(p, io) {
1114
1144
  function hubHint(e, env) {
1115
1145
  const zh = isZh(env);
1116
1146
  if (e.status === 401 && (e.code === 'unauthorized' || e.code === 'owner_deactivated'))
1117
- return zh ? '\n密钥失效或智能体已停用:向管理员要一行新的 `ach join ...`。' : '\nThe key no longer works: ask your admin for a new `ach join ...` line.';
1147
+ return zh ? '\n密钥失效或已停用:向管理员要一行新的 `ach join ...`。' : '\nThe key no longer works: ask your admin for a new `ach join ...` line.';
1118
1148
  if (e.code === 'session_ended' || e.code === 'deactivated')
1119
1149
  return zh ? '\n登录已失效:运行 `ach admin login --link <链接>`。' : '\nYour session ended: run `ach admin login --link <login link>`.';
1120
1150
  if (e.code === 'needs_admin_login')
1121
- return zh ? '\n这个会话来自智能体密钥,不能做管理员操作:用设备链接或登录链接登录。' : '\nThis session came from an agent key and cannot use admin actions: log in with a device link or login link.';
1151
+ return zh ? '\n这个会话来自环境或 Bot 的密钥,不能做管理员操作:用设备链接或登录链接登录。' : '\nThis session came from an agent key and cannot use admin actions: log in with a device link or login link.';
1122
1152
  return '';
1123
1153
  }
1124
1154
  function linkOf(env, t) {
@@ -1,5 +1,30 @@
1
1
  import type { Config } from './config.js';
2
2
  import { type Attachment, type StorageConfig, type TaskFile } from './attachments.js';
3
+ /** An artifact as the hub describes it (docs/api/openapi.yaml Artifact). */
4
+ export interface ArtifactOut {
5
+ id: string;
6
+ ref: string;
7
+ title: string;
8
+ visibility: string;
9
+ version: number;
10
+ file: string;
11
+ owner_name?: string;
12
+ can_edit?: boolean;
13
+ versions?: Array<{
14
+ version: number;
15
+ size: number;
16
+ note: string;
17
+ agent_name?: string;
18
+ user_name?: string;
19
+ created: string;
20
+ file: string;
21
+ }>;
22
+ places?: Array<{
23
+ post?: string;
24
+ channel?: string;
25
+ task?: string;
26
+ }>;
27
+ }
3
28
  export type TaskStatus = 'submitted' | 'working' | 'input-required' | 'awaiting_review' | 'awaiting_acceptance' | 'awaiting_merge' | 'completed' | 'failed' | 'canceled';
4
29
  export declare const TERMINAL: readonly TaskStatus[];
5
30
  export declare function isTerminal(s: string | undefined): boolean;
@@ -523,6 +548,16 @@ export declare class Client {
523
548
  taskFiles(taskId: string): Promise<TaskFile[]>;
524
549
  /** Download one attachment into `dir`; returns the local path. */
525
550
  download(a: Attachment, dir: string): Promise<string>;
551
+ /** Publish an artifact (one checked local .html file) or, with `artifact`, a new version of it. */
552
+ publishArtifact(file: string, o: {
553
+ title?: string;
554
+ note?: string;
555
+ visibility?: 'private' | 'team';
556
+ artifact?: string;
557
+ }): Promise<ArtifactOut>;
558
+ getArtifact(ref: string): Promise<ArtifactOut>;
559
+ /** Save a version's HTML into `dir`; returns the path. */
560
+ downloadArtifact(a: ArtifactOut, version: number, dir: string): Promise<string>;
526
561
  me(): Promise<Agent>;
527
562
  /** A read-only GitHub token for one run (the agent's github_scope); `runId` names a live run (the runner's key needs it). */
528
563
  githubToken(runId: string): Promise<GithubToken>;
@@ -310,6 +310,25 @@ export class Client {
310
310
  delete h.accept;
311
311
  return downloadFile(this.fetchFn, `${this.hub}${a.url}`, h, dir, a);
312
312
  }
313
+ // ---- artifacts (docs/specs/artifacts.md) ----
314
+ /** Publish an artifact (one checked local .html file) or, with `artifact`, a new version of it. */
315
+ async publishArtifact(file, o) {
316
+ const body = { ...(o.title ? { title: o.title } : {}), ...(o.note ? { note: o.note } : {}), ...(o.visibility ? { visibility: o.visibility } : {}) };
317
+ const r = await this.ach('POST', o.artifact ? `/artifacts/${enc(o.artifact)}/versions` : '/artifacts', body, [file]);
318
+ return r.artifact;
319
+ }
320
+ async getArtifact(ref) {
321
+ return (await this.ach('GET', `/artifacts/${enc(ref)}`)).artifact;
322
+ }
323
+ /** Save a version's HTML into `dir`; returns the path. */
324
+ async downloadArtifact(a, version, dir) {
325
+ const v = (a.versions ?? []).find((x) => x.version === version);
326
+ if (!v)
327
+ throw new Error(`${a.ref} has no version ${version} (it has 1 to ${a.version})`);
328
+ const h = this.headers(false);
329
+ delete h.accept;
330
+ return downloadFile(this.fetchFn, `${this.hub}${v.file}`, h, dir, { name: `${a.ref}-v${version}.html`, original: `${a.ref}-v${version}.html`, size: v.size, type: 'text/html', url: v.file });
331
+ }
313
332
  // ---- agent routes ----
314
333
  async me() {
315
334
  const r = await this.ach('GET', '/me');