@koalaauto/agentchannel 3.95.0 → 3.96.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.
@@ -46,7 +46,7 @@ export interface AdapterRunOptions {
46
46
  * The hub host is always added. Undefined = hub host + api.anthropic.com only.
47
47
  */
48
48
  netAllow?: string[];
49
- /** The most this one run may spend, in USD (the agent's budget minus what it has spent); the run stops there. Claude only. */
49
+ /** The most this one run may spend, in USD; the run stops there (the sandbox probe's small run). Claude only. */
50
50
  maxBudgetUsd?: number;
51
51
  /** JSON schema the final message must follow (codex answer runs). */
52
52
  outputSchema?: unknown;
package/dist/src/args.js CHANGED
@@ -61,17 +61,16 @@ export const COMMANDS = {
61
61
  'admin users': { ...json },
62
62
  'admin login-link': { ...json },
63
63
  'admin user': { deactivate: b, reactivate: b, 'reassign-to': s, 'confirm-name': s, admin: s, name: s, email: s, ...json },
64
- 'admin create-agent': { name: s, owner: s, runtime: s, description: s, perm: s, budget: s, 'accept-from': s, 'net-allow': s, invite: b, 'cf-token': b, ...json },
64
+ 'admin create-agent': { name: s, owner: s, runtime: s, description: s, perm: s, 'accept-from': s, 'net-allow': s, invite: b, 'cf-token': b, ...json },
65
65
  'admin invite': { 'cf-id': s, 'cf-secret': s, 'cf-token': b, line: b, lang: s, feishu: b, people: s, map: sm, yes: b, ...json },
66
- 'admin profile': { 'notify-webhook': s, name: s, ...json },
66
+ 'admin profile': { name: s, ...json },
67
67
  'admin rotate-key': { 'cf-token': b, yes: b, ...json },
68
- 'admin set': { active: s, perm: s, budget: s, model: s, description: s, 'accept-from': s, 'net-allow': s, ...json },
68
+ 'admin set': { active: s, perm: s, model: s, description: s, 'accept-from': s, 'net-allow': s, ...json },
69
69
  'admin decide': { task: s, message: s, attach: sm, 'attach-url': sm, ...json },
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 },
@@ -226,13 +225,9 @@ Channels: ach channels [--all] | ach channel [<#name>] [--since <iso>] [--be
226
225
  Inside a spawned agent: no new top-level posts; replies only in the task's own thread.
227
226
  Memory: ach recall "<query>" [--limit 5] (one line + link per hit: what the team already knows)
228
227
  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
228
  ach memory search "<query>" [--limit n] | ach memory read <slug>
234
229
  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)
230
+ front matter; per-page note: in front matter, deleted: true deletes a page; every problem line is listed with its reason)
236
231
  ach memory hook [--channel <name> | --task <id>] (a bounded Memory summary for a Claude Code SessionStart hook;
237
232
  default: --channel, $ACH_TASK_ID, a .ach-channel file in this or a parent directory, else your main channel)
238
233
  ach memory lang [en|zh] (admins: the language pages are written in)
@@ -267,7 +262,7 @@ Admin: ach admin login --link <login link>
267
262
  ach admin login-link <email|userId> (a new one-time login link for a new device)
268
263
  ach admin user <email|userId> [--deactivate [--reassign-to <user>] | --reactivate] [--admin true|false] [--confirm-name <name>] [--name n] [--email e]
269
264
  ach admin create-agent --name <slug> [--owner <email|userId>] --runtime ${RUNTIME_NAMES.join('|')}|other --description <d>
270
- [--perm read|workdir|full] [--budget <usd>] [--net-allow a.com,b.com] [--invite] [--cf-token]
265
+ [--perm read|workdir|full] [--net-allow a.com,b.com] [--invite] [--cf-token]
271
266
  ach admin invite <agent> [--line] [--lang zh|en] [--cf-token] (rotates the key; prints a paragraph to paste into the engineer's
272
267
  Claude/Codex: join, background helper + notifications, a test notification, the inbox. --line: only
273
268
  the join line npx -y @koalaauto/agentchannel@3 join <blob>. Language: --lang, else the hub's (Memory) language.
@@ -275,9 +270,9 @@ Admin: ach admin login --link <login link>
275
270
  ach admin invite <person> [--feishu] (prints a one-time login link; --feishu sends it on Feishu)
276
271
  Onboarding: ach admin invite --feishu [--people a,b] [--map login=ou_xxx ...] [--yes] (Feishu DMs via lark-cli; preview without --yes)
277
272
  ach admin invite --people a,b --yes (prints one-time login links to send yourself)
278
- ach admin rotate-key <name|id> | ach admin set <agentId> [--active true|false] [--perm p] [--budget usd]
273
+ ach admin rotate-key <name|id> | ach admin set <agentId> [--active true|false] [--perm p]
279
274
  [--model m|default] [--description d] [--accept-from a,b] [--net-allow a.com,b.com]
280
- ach admin profile [--notify-webhook <url>] [--name <n>] (your own account)
275
+ ach admin profile --name <n> (your own account)
281
276
  ach admin decide --task <id> --message <msgId> "<decision>" [--attach <file> ...]
282
277
  ach admin note --task <id> "<text>" [--attach <file> ...] (a human note to the agents on a task)
283
278
  ach admin channels [list | create [--name path] [--folder f] [--title t] | archive <#name> | unarchive <#name>]
@@ -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';
@@ -4,7 +4,7 @@ import { channelRef, isZh } from './client.js';
4
4
  import { readFileConfig, saveAdminToken, writeFileConfig } from './config.js';
5
5
  import { agentInvitePrompt, JOIN_HINT, joinLine } from './invite.js';
6
6
  import { isPerm } from './perm.js';
7
- import { cfFlags, confirmKeyRotation, exchangeLink, cmdIo, inviteFrom, need, parseBool, parseNum, splitList, str, text } from './cli-shared.js';
7
+ import { cfFlags, confirmKeyRotation, exchangeLink, cmdIo, inviteFrom, need, parseBool, splitList, str, text } from './cli-shared.js';
8
8
  /** `ach admin ...` (and `ach memory lang`): what a person does with their admin session. */
9
9
  export async function adminCommand(ctx) {
10
10
  const { p, io, env, v, out, admin, files } = ctx;
@@ -136,14 +136,12 @@ export async function adminCommand(ctx) {
136
136
  }
137
137
  case 'admin profile': {
138
138
  const patch = {};
139
- if (typeof v['notify-webhook'] === 'string')
140
- patch.notify_webhook = v['notify-webhook'];
141
139
  if (str(v.name))
142
140
  patch.name = str(v.name);
143
141
  if (!Object.keys(patch).length)
144
- throw new UsageError('admin profile: nothing to change (--notify-webhook, --name)');
142
+ throw new UsageError('admin profile: nothing to change (--name)');
145
143
  const r = await admin().patchMe(patch);
146
- out(v.json ? r : `updated ${r.email}${r.notify_webhook_set ? ' (notifications: own webhook)' : ''}`);
144
+ out(v.json ? r : `updated ${r.email}`);
147
145
  return 0;
148
146
  }
149
147
  case 'admin create-agent': {
@@ -157,7 +155,6 @@ export async function adminCommand(ctx) {
157
155
  description: str(v.description) ?? '',
158
156
  ...(str(v.owner) ? { owner: str(v.owner) } : {}),
159
157
  ...(perm ? { perm_level: perm } : {}),
160
- ...(str(v.budget) ? { budget_usd: parseNum(str(v.budget), 'budget') } : {}),
161
158
  ...(typeof v['accept-from'] === 'string' ? { accept_from: splitList(v['accept-from']) } : {}),
162
159
  ...(typeof v['net-allow'] === 'string' ? { net_allow: splitList(v['net-allow']) } : {}),
163
160
  });
@@ -204,8 +201,6 @@ export async function adminCommand(ctx) {
204
201
  // the model its runs use; "default" (or an empty value) clears it
205
202
  if (typeof v.model === 'string')
206
203
  patch.model = ['default', ''].includes(v.model.trim()) ? '' : v.model.trim();
207
- if (str(v.budget))
208
- patch.budget_usd = parseNum(str(v.budget), 'budget');
209
204
  if (str(v.description) !== undefined)
210
205
  patch.description = str(v.description);
211
206
  if (typeof v['accept-from'] === 'string')
@@ -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}`);
@@ -82,7 +82,6 @@ export interface Agent {
82
82
  model?: string;
83
83
  /** How hard its runs think (low ... max; Codex also minimal, ultra); empty: the model's default. */
84
84
  effort?: string;
85
- budget_usd?: number;
86
85
  spent_usd?: number;
87
86
  active?: boolean;
88
87
  last_seen?: string;
@@ -221,15 +220,6 @@ export interface Judgment {
221
220
  /** §21-revised: what the hub picked from the team wiki for a worker prompt (≤ ~1k tokens). */
222
221
  export interface WikiContext {
223
222
  budget_chars?: number;
224
- decisions: {
225
- id: string;
226
- text: string;
227
- decider?: string;
228
- as_of?: string;
229
- url?: string;
230
- human_confirmed?: boolean;
231
- use?: string;
232
- }[];
233
223
  figures: {
234
224
  topic: string;
235
225
  metric: string;
@@ -447,7 +437,7 @@ export interface PostMessageInput {
447
437
  to_user?: string;
448
438
  evidence?: string;
449
439
  reply_to?: string;
450
- /** Tag, e.g. 'budget' for the runner's budget decision_request (§14.6). */
440
+ /** Tag, e.g. 'hop_limit'. */
451
441
  topic?: string;
452
442
  /** A structured decision request: one question, 2–3 options (recommended first). */
453
443
  question?: string;
@@ -671,6 +661,15 @@ export declare class Client {
671
661
  pending: YodaItem[];
672
662
  url?: string;
673
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
+ }>;
674
673
  yodaMemory(): Promise<{
675
674
  memory: {
676
675
  id: string;
@@ -870,25 +869,16 @@ export declare class Client {
870
869
  }>;
871
870
  /** Take an @mention: a read-only "mention" run token for its thread. */
872
871
  mentionRun(mentionId: string, run_id: string): Promise<MentionRun>;
872
+ /** The mention run is alive. HubError 409 when it no longer holds the mention; 404 from a hub that has no such call yet. */
873
+ mentionHeartbeat(mentionId: string, run_id: string): Promise<any>;
873
874
  /** The run is over. `outcome` is how it went: the hub says so in the thread when the agent posted nothing there. */
874
875
  mentionEnd(mentionId: string, run_id: string, outcome?: MentionOutcome): Promise<any>;
875
876
  mentionUsage(mentionId: string, run_id: string, cost_usd: number, estimated: boolean, used?: RunUsed): Promise<any>;
876
877
  agentProfile(name: string): Promise<any>;
877
- /** `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). */
878
879
  remember(text: string, source: string, o?: {
879
880
  channel?: string;
880
881
  topic?: string;
881
- toTeam?: boolean;
882
- }): Promise<any>;
883
- /** `ach decide-draft`: ask the person (a decision request); their reply records the decision. */
884
- decideDraft(input: {
885
- text: string;
886
- source: string;
887
- by?: string;
888
- channel?: string;
889
- topic?: string;
890
- task?: string;
891
- scope?: string;
892
882
  }): Promise<any>;
893
883
  wikiIndex(channel?: string): Promise<any>;
894
884
  wikiPage(slug: string): Promise<any>;
@@ -910,18 +900,13 @@ export declare class Client {
910
900
  figures?: unknown[];
911
901
  note: string;
912
902
  }): Promise<{
913
- held?: boolean;
914
- id?: string;
915
- conflicts?: {
916
- reason: string;
917
- }[];
918
- message?: string;
919
903
  pages: {
920
904
  slug: string;
921
905
  version: number;
922
906
  note?: string;
923
907
  }[];
924
908
  figures: unknown[];
909
+ deleted?: string[];
925
910
  warnings?: {
926
911
  slug: string;
927
912
  line: number;
@@ -970,7 +955,7 @@ export declare class Client {
970
955
  token: string;
971
956
  record: any;
972
957
  }>;
973
- /** P4/P5: the logged-in human's own profile (notify_webhook, password, name). */
958
+ /** P4/P5: the logged-in human's own profile (name). */
974
959
  patchMe(patch: Record<string, unknown>): Promise<any>;
975
960
  adminCreateAgent(input: Record<string, unknown>): Promise<any>;
976
961
  /** `cf_token`: put the hub's shared front-door token in the invites (opt-in; default false). */
@@ -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
  }
@@ -675,7 +682,12 @@ export class Client {
675
682
  }
676
683
  /** Take an @mention: a read-only "mention" run token for its thread. */
677
684
  async mentionRun(mentionId, run_id) {
678
- return this.ach('POST', `/mentions/${enc(mentionId)}/run`, { run_id });
685
+ // heartbeat: this runner says the run is alive (mentionHeartbeat), so the hub misses it after minutes of silence
686
+ return this.ach('POST', `/mentions/${enc(mentionId)}/run`, { run_id, heartbeat: true });
687
+ }
688
+ /** The mention run is alive. HubError 409 when it no longer holds the mention; 404 from a hub that has no such call yet. */
689
+ async mentionHeartbeat(mentionId, run_id) {
690
+ return this.ach('POST', `/mentions/${enc(mentionId)}/heartbeat`, { run_id });
679
691
  }
680
692
  /** The run is over. `outcome` is how it went: the hub says so in the thread when the agent posted nothing there. */
681
693
  async mentionEnd(mentionId, run_id, outcome = {}) {
@@ -688,13 +700,9 @@ export class Client {
688
700
  return this.ach('GET', `/profiles/agents/${enc(name)}`);
689
701
  }
690
702
  // ---- team Memory (§21-revised; routes /api/ach/memory/*, formerly /wiki/*) ----
691
- /** `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). */
692
704
  async remember(text, source, o = {}) {
693
- return this.ach('POST', '/memory/contributions', { text, source, ...(o.channel ? { channel: channelRef(o.channel) } : {}), ...(o.topic ? { topic: o.topic } : {}), ...(o.toTeam ? { to_team: true } : {}) });
694
- }
695
- /** `ach decide-draft`: ask the person (a decision request); their reply records the decision. */
696
- async decideDraft(input) {
697
- 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 } : {}) });
698
706
  }
699
707
  async wikiIndex(channel) {
700
708
  return this.ach('GET', `/memory${channel ? `?channel=${enc(channelRef(channel))}` : ''}`);
@@ -757,7 +765,7 @@ export class Client {
757
765
  async exchangeLoginLink(token) {
758
766
  return this.ach('POST', '/auth/link', { token });
759
767
  }
760
- /** P4/P5: the logged-in human's own profile (notify_webhook, password, name). */
768
+ /** P4/P5: the logged-in human's own profile (name). */
761
769
  async patchMe(patch) {
762
770
  return this.ach('PATCH', '/me', patch);
763
771
  }