@koalaauto/agentchannel 3.95.1 → 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 CHANGED
@@ -70,8 +70,7 @@ export const COMMANDS = {
70
70
  'admin channels': { name: s, folder: s, title: s, description: s, add: s, remove: s, cascade: b, ...json },
71
71
  'admin memory-upkeep': { ...json },
72
72
  'admin note': { task: s, attach: sm, 'attach-url': sm, ...json },
73
- remember: { source: s, channel: s, topic: s, 'to-team': b, ...json },
74
- 'decide-draft': { source: s, by: s, channel: s, topic: s, task: s, scope: s, ...json },
73
+ remember: { source: s, channel: s, topic: s, ...json },
75
74
  recall: { limit: s, ...json },
76
75
  'memory pull': { channel: s, ...json },
77
76
  'memory push': { note: s, ...json },
@@ -170,7 +169,8 @@ Setup: npx -y @koalaauto/agentchannel@3 join <ach2.line> (a line from the
170
169
  everywhere but in a directory an agent was joined from)
171
170
  npx -y @koalaauto/agentchannel@3 join <ach2.invite> [--name <n>] [--service] [--yes] [--dry-run] (run it in the
172
171
  project directory: a line from the panel's "Connect an agent" creates the agent there, named
173
- "<your name>-<directory>" (lowercase); --name replaces the part after "<your name>-"; a line from the panel or
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
174
174
  \`ach admin invite <agent>\`: stores the agent's key and adds the \`ach\` MCP server to the agent's own tool
175
175
  (Claude Code or Codex). In a terminal it shows the hub and every command first and asks once; --yes skips
176
176
  that; run by an agent (no terminal) it just does it. --service also installs the background helper
@@ -226,13 +226,9 @@ Channels: ach channels [--all] | ach channel [<#name>] [--since <iso>] [--be
226
226
  Inside a spawned agent: no new top-level posts; replies only in the task's own thread.
227
227
  Memory: ach recall "<query>" [--limit 5] (one line + link per hit: what the team already knows)
228
228
  ach remember [--channel <name>] [--topic <slug>] --source <link> "<one fact or lesson>" (source: hub permalink or GitHub URL)
229
- ach remember --to-team --source <link> "<one fact>" (members of a private channel: make one statement team-visible;
230
- its source stays private: others see "source: private channel")
231
- ach decide-draft [--by <person>] --source <link> [--task <id>] [--topic <slug>] [--scope task|channel] "<the decision>"
232
- (asks that person; their reply records it. Task-only unless it says "from now on"/"always"/"以后都")
233
229
  ach memory search "<query>" [--limit n] | ach memory read <slug>
234
230
  ach memory pull <dir> [--channel <name>] | ach memory push <dir> --note "<what changed>" (maintainers; Markdown + YAML
235
- front matter; per-page note: in front matter; every problem line is listed with its reason)
231
+ front matter; per-page note: in front matter, deleted: true deletes a page; every problem line is listed with its reason)
236
232
  ach memory hook [--channel <name> | --task <id>] (a bounded Memory summary for a Claude Code SessionStart hook;
237
233
  default: --channel, $ACH_TASK_ID, a .ach-channel file in this or a parent directory, else your main channel)
238
234
  ach memory lang [en|zh] (admins: the language pages are written in)
@@ -25,7 +25,7 @@ export function attentionKind(type) {
25
25
  const t = String(type ?? '').toLowerCase();
26
26
  if (/decision/.test(t))
27
27
  return 'decision';
28
- if (/question|escalat|ask|memory_held/.test(t))
28
+ if (/question|escalat|ask/.test(t))
29
29
  return 'question';
30
30
  if (/mention|assigned/.test(t))
31
31
  return 'mention';
@@ -1,3 +1,3 @@
1
1
  import { type CmdCtx } from './cli-shared.js';
2
- /** `ach remember`, `ach recall`, `ach decide-draft`, `ach memory ...`: the team Memory. */
2
+ /** `ach remember`, `ach recall`, `ach memory ...`: the team Memory. */
3
3
  export declare function memoryCommand(ctx: CmdCtx): Promise<number | undefined>;
@@ -1,11 +1,11 @@
1
- // `ach remember`, `ach recall`, `ach decide-draft` and `ach memory ...`: the team Memory from the command line.
1
+ // `ach remember`, `ach recall` and `ach memory ...`: the team Memory from the command line.
2
2
  import { isAbsolute, resolve } from 'node:path';
3
3
  import { UsageError } from './args.js';
4
4
  import { lintProblemLines } from './client.js';
5
5
  import { loadConfig } from './config.js';
6
6
  import { untrustedBlock as wrapUntrusted } from './prompts.js';
7
7
  import { MEMORY_NOTE, absUrl, channelFile, noAgentHint, str, text } from './cli-shared.js';
8
- /** `ach remember`, `ach recall`, `ach decide-draft`, `ach memory ...`: the team Memory. */
8
+ /** `ach remember`, `ach recall`, `ach memory ...`: the team Memory. */
9
9
  export async function memoryCommand(ctx) {
10
10
  const { p, io, env, v, out, client, admin } = ctx;
11
11
  switch (p.cmd) {
@@ -13,29 +13,13 @@ export async function memoryCommand(ctx) {
13
13
  const source = str(v.source);
14
14
  if (!source)
15
15
  throw new UsageError('remember: --source <link> is required (a hub permalink like <hub>/t/TASK-12 or a GitHub URL)');
16
- const r = await client().remember(text(p, '"<fact or lesson>"'), source, { channel: str(v.channel), topic: str(v.topic), toTeam: !!v['to-team'] });
16
+ const r = await client().remember(text(p, '"<fact or lesson>"'), source, { channel: str(v.channel), topic: str(v.topic) });
17
17
  if (v.json)
18
18
  out(r);
19
- else if (r?.held)
20
- out(`held for review: ${r.conflicts?.[0]?.reason ?? 'it contradicts Memory'} (an admin or the decider accepts or discards it in the Inbox)`);
21
- else if (v['to-team'])
22
- out(`promoted to the team overview ${r?.id ?? ''}${r?.source_private ? ' (source stays private: others see "source: private channel")' : ''}`);
23
19
  else
24
20
  out(`remembered ${r?.id ?? ''} (the Memory maintainer folds it into a page)`);
25
21
  return 0;
26
22
  }
27
- case 'decide-draft': {
28
- const source = str(v.source);
29
- if (!source)
30
- throw new UsageError('decide-draft: --source <link> is required');
31
- const task = str(v.task) ?? str(env.ACH_TASK_ID);
32
- const r = await client().decideDraft({ text: text(p, '"<who decided what>"'), source, by: str(v.by), channel: str(v.channel), topic: str(v.topic), task, ...(str(v.scope) ? { scope: str(v.scope) } : {}) });
33
- if (v.json)
34
- out(r);
35
- else
36
- out(`asked ${r?.decider_name ?? 'the decider'} ${r?.request_url ?? ''} (decision ${r?.id ?? ''}, ${r?.scope === 'task' ? 'for this task only, not a channel rule' : 'a standing channel rule'}${r?.money ? ' [money]' : ''}): their reply records it; nothing counts until they reply`);
37
- return 0;
38
- }
39
23
  case 'recall':
40
24
  case 'memory search': {
41
25
  const limit = str(v.limit) ? Number(str(v.limit)) : p.cmd === 'recall' ? 5 : undefined;
@@ -121,13 +105,7 @@ export async function memoryCommand(ctx) {
121
105
  out(r);
122
106
  return 0;
123
107
  }
124
- if (r.held) {
125
- out(`held for review, nothing written: ${r.message ?? ''}`);
126
- for (const c of r.conflicts ?? [])
127
- io.err(` ${c.reason}`);
128
- return 0;
129
- }
130
- out(`pushed: ${r.pages.length ? r.pages.map((x) => `${x.slug} v${x.version}${x.note && x.note !== note ? ` (${x.note})` : ''}`).join(', ') : 'no page changes'}; ${r.figures.length} new figure(s)`);
108
+ out(`pushed: ${r.pages.length ? r.pages.map((x) => `${x.slug} v${x.version}${x.note && x.note !== note ? ` (${x.note})` : ''}`).join(', ') : 'no page changes'}; ${r.figures.length} new figure(s)${r.deleted?.length ? `; deleted: ${r.deleted.join(', ')}` : ''}`);
131
109
  // warnings do not block the push: fix them in the next one
132
110
  for (const w of r.warnings ?? [])
133
111
  io.err(`warning: ${w.slug}.md line ${w.line}: ${w.problem}: ${w.text}`);
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}。换一个名字再运行:加上 --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.`);
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') {
@@ -220,15 +220,6 @@ export interface Judgment {
220
220
  /** §21-revised: what the hub picked from the team wiki for a worker prompt (≤ ~1k tokens). */
221
221
  export interface WikiContext {
222
222
  budget_chars?: number;
223
- decisions: {
224
- id: string;
225
- text: string;
226
- decider?: string;
227
- as_of?: string;
228
- url?: string;
229
- human_confirmed?: boolean;
230
- use?: string;
231
- }[];
232
223
  figures: {
233
224
  topic: string;
234
225
  metric: string;
@@ -670,6 +661,15 @@ export declare class Client {
670
661
  pending: YodaItem[];
671
662
  url?: string;
672
663
  }>;
664
+ /**
665
+ * What a session connected as a person sends itself, as written: a task, a post or a reply in the person's name. The hub
666
+ * decides whether it goes at once or waits on a card on the Yoda page (`status`).
667
+ */
668
+ yodaAct(tool: 'send_task' | 'post' | 'reply', args: Record<string, unknown>): Promise<{
669
+ status: 'done' | 'waiting' | 'failed';
670
+ text: string;
671
+ url?: string;
672
+ }>;
673
673
  yodaMemory(): Promise<{
674
674
  memory: {
675
675
  id: string;
@@ -875,21 +875,10 @@ export declare class Client {
875
875
  mentionEnd(mentionId: string, run_id: string, outcome?: MentionOutcome): Promise<any>;
876
876
  mentionUsage(mentionId: string, run_id: string, cost_usd: number, estimated: boolean, used?: RunUsed): Promise<any>;
877
877
  agentProfile(name: string): Promise<any>;
878
- /** `ach remember`: a fact or lesson with its source (hub permalink or GitHub URL); toTeam promotes it to the team overview. */
878
+ /** `ach remember`: a fact or lesson with its source (hub permalink or GitHub URL). */
879
879
  remember(text: string, source: string, o?: {
880
880
  channel?: string;
881
881
  topic?: string;
882
- toTeam?: boolean;
883
- }): Promise<any>;
884
- /** `ach decide-draft`: ask the person (a decision request); their reply records the decision. */
885
- decideDraft(input: {
886
- text: string;
887
- source: string;
888
- by?: string;
889
- channel?: string;
890
- topic?: string;
891
- task?: string;
892
- scope?: string;
893
882
  }): Promise<any>;
894
883
  wikiIndex(channel?: string): Promise<any>;
895
884
  wikiPage(slug: string): Promise<any>;
@@ -911,18 +900,13 @@ export declare class Client {
911
900
  figures?: unknown[];
912
901
  note: string;
913
902
  }): Promise<{
914
- held?: boolean;
915
- id?: string;
916
- conflicts?: {
917
- reason: string;
918
- }[];
919
- message?: string;
920
903
  pages: {
921
904
  slug: string;
922
905
  version: number;
923
906
  note?: string;
924
907
  }[];
925
908
  figures: unknown[];
909
+ deleted?: string[];
926
910
  warnings?: {
927
911
  slug: string;
928
912
  line: number;
@@ -419,6 +419,13 @@ export class Client {
419
419
  async yoda(after) {
420
420
  return this.ach('GET', `/yoda${after !== undefined ? `?after=${after}` : ''}`);
421
421
  }
422
+ /**
423
+ * What a session connected as a person sends itself, as written: a task, a post or a reply in the person's name. The hub
424
+ * decides whether it goes at once or waits on a card on the Yoda page (`status`).
425
+ */
426
+ async yodaAct(tool, args) {
427
+ return this.ach('POST', '/yoda/acts', { tool, args, ...(this.yodaFrom ? { from: this.yodaFrom } : {}) });
428
+ }
422
429
  async yodaMemory() {
423
430
  return this.ach('GET', '/yoda/memory');
424
431
  }
@@ -693,13 +700,9 @@ export class Client {
693
700
  return this.ach('GET', `/profiles/agents/${enc(name)}`);
694
701
  }
695
702
  // ---- team Memory (§21-revised; routes /api/ach/memory/*, formerly /wiki/*) ----
696
- /** `ach remember`: a fact or lesson with its source (hub permalink or GitHub URL); toTeam promotes it to the team overview. */
703
+ /** `ach remember`: a fact or lesson with its source (hub permalink or GitHub URL). */
697
704
  async remember(text, source, o = {}) {
698
- return this.ach('POST', '/memory/contributions', { text, source, ...(o.channel ? { channel: channelRef(o.channel) } : {}), ...(o.topic ? { topic: o.topic } : {}), ...(o.toTeam ? { to_team: true } : {}) });
699
- }
700
- /** `ach decide-draft`: ask the person (a decision request); their reply records the decision. */
701
- async decideDraft(input) {
702
- return this.ach('POST', '/memory/decisions', { ...input, ...(input.channel ? { channel: channelRef(input.channel) } : {}) });
705
+ return this.ach('POST', '/memory/contributions', { text, source, ...(o.channel ? { channel: channelRef(o.channel) } : {}), ...(o.topic ? { topic: o.topic } : {}) });
703
706
  }
704
707
  async wikiIndex(channel) {
705
708
  return this.ach('GET', `/memory${channel ? `?channel=${enc(channelRef(channel))}` : ''}`);