@koalaauto/agentchannel 3.26.6 → 3.27.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.
@@ -20,6 +20,8 @@ export interface Agent {
20
20
  former_names?: string[];
21
21
  /** P2: domains the agent's sandbox may reach ("*" = any; admin-only). */
22
22
  net_allow?: string[];
23
+ /** The repo names its runner can work in, as the runner reported them (empty: never reported). */
24
+ repos?: string[];
23
25
  }
24
26
  export interface Task {
25
27
  id: string;
@@ -423,6 +425,8 @@ export declare class Client {
423
425
  traces(taskId: string): Promise<any>;
424
426
  /** The worker cannot run on its machine (not logged in, sandbox broken): the task goes back to submitted, not failed. */
425
427
  release(taskId: string, reason: string, run_id?: string): Promise<any>;
428
+ /** The repo names this runner can work in (never local paths): the directory shows them, and the hub refuses a task for another repo. */
429
+ reportRepos(repos: string[]): Promise<any>;
426
430
  reportSetup(sandbox: {
427
431
  tool: string;
428
432
  problem: string;
@@ -371,6 +371,10 @@ export class Client {
371
371
  async release(taskId, reason, run_id) {
372
372
  return this.ach('POST', `/tasks/${enc(taskId)}/release`, { reason, ...(run_id ? { run_id } : {}) });
373
373
  }
374
+ /** The repo names this runner can work in (never local paths): the directory shows them, and the hub refuses a task for another repo. */
375
+ async reportRepos(repos) {
376
+ return this.ach('PUT', '/me/repos', { repos });
377
+ }
374
378
  async reportSetup(sandbox) {
375
379
  return this.ach('PUT', '/me/setup', { sandbox });
376
380
  }
package/dist/src/mcp.js CHANGED
@@ -178,7 +178,7 @@ export function buildMcpServer(client, o = {}) {
178
178
  }
179
179
  return task.run_id;
180
180
  }
181
- server.registerTool('list_agents', { description: 'List the team\'s agents (name, owner, runtime, what they are good at). Use it to pick who to hand work to.', inputSchema: {} }, async () => wrap(() => client.agents()));
181
+ server.registerTool('list_agents', { description: 'List the team\'s agents (name, owner, runtime, what they are good at, the repos their runner works in). Use it to pick who to hand work to; a task\'s repo must be one of the receiver\'s repos when it lists any.', inputSchema: {} }, async () => wrap(() => client.agents()));
182
182
  server.registerTool('send_task', {
183
183
  description: `Hand a piece of work to another agent as a task. The receiving agent is woken on its machine (or its owner picks it up interactively) and works in a fresh git worktree. ${TASK_FIELDS_HELP} ${HANDOFF_HELP}`,
184
184
  inputSchema: {
@@ -4,7 +4,7 @@ import { type Perm } from '../perm.js';
4
4
  import { RunnerState } from './state.js';
5
5
  import type { Workspace } from './workspace.js';
6
6
  import { type SandboxStatus } from '../sandboxcheck.js';
7
- export type RunnerClient = Pick<Client, 'me' | 'inbox' | 'claim' | 'getTask' | 'postMessage' | 'complete' | 'fail' | 'usage' | 'heartbeat' | 'answerRun' | 'endRun'> & Partial<Pick<Client, 'download' | 'channelPosts' | 'mentionRun' | 'mentionEnd' | 'mentionUsage' | 'promptSize' | 'reportSetup' | 'release' | 'putTrace'>>;
7
+ export type RunnerClient = Pick<Client, 'me' | 'inbox' | 'claim' | 'getTask' | 'postMessage' | 'complete' | 'fail' | 'usage' | 'heartbeat' | 'answerRun' | 'endRun'> & Partial<Pick<Client, 'download' | 'channelPosts' | 'mentionRun' | 'mentionEnd' | 'mentionUsage' | 'promptSize' | 'reportSetup' | 'reportRepos' | 'release' | 'putTrace'>>;
8
8
  export interface RunnerOptions {
9
9
  client: RunnerClient;
10
10
  adapter: RuntimeAdapter;
@@ -192,6 +192,11 @@ export declare class Runner {
192
192
  tick(): Promise<void>;
193
193
  /** design §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
194
194
  private sandboxBlocked;
195
+ /** Tell the hub which repo names this runner knows, so a task for another repo is refused when it is sent. Tried on every
196
+ * poll until the hub has it: a hub that was unreachable at start would otherwise keep the previous list until a restart. */
197
+ private reposReported;
198
+ private reportRepos;
199
+ private reposLogged;
195
200
  private notifyBudget;
196
201
  /**
197
202
  * Cancel running jobs whose task went terminal; forget parked runs of
@@ -411,6 +411,32 @@ export class Runner {
411
411
  }
412
412
  return !st.ok;
413
413
  }
414
+ /** Tell the hub which repo names this runner knows, so a task for another repo is refused when it is sent. Tried on every
415
+ * poll until the hub has it: a hub that was unreachable at start would otherwise keep the previous list until a restart. */
416
+ reposReported = false;
417
+ async reportRepos() {
418
+ if (this.reposReported)
419
+ return;
420
+ const names = this.o.workspace.repoNames?.();
421
+ if (!names?.length || !this.o.client.reportRepos) {
422
+ this.reposReported = true;
423
+ return;
424
+ }
425
+ try {
426
+ await this.o.client.reportRepos(names);
427
+ this.reposReported = true;
428
+ }
429
+ catch (e) {
430
+ // an older hub without /me/repos: nothing is checked there, which is how it was
431
+ if (e instanceof HubError && e.status === 404)
432
+ this.reposReported = true;
433
+ else if (!this.reposLogged) {
434
+ this.reposLogged = true;
435
+ this.log(`repos report: ${e?.message ?? e} (trying again with the next poll)`);
436
+ }
437
+ }
438
+ }
439
+ reposLogged = false;
414
440
  async notifyBudget(t, me) {
415
441
  if (this.state.runs.budgetNotified[t.id])
416
442
  return;
@@ -1421,6 +1447,7 @@ export class Runner {
1421
1447
  while (!this.stopped) {
1422
1448
  let wait = this.o.intervalMs;
1423
1449
  try {
1450
+ await this.reportRepos();
1424
1451
  await this.tick();
1425
1452
  }
1426
1453
  catch (e) {
@@ -15,6 +15,8 @@ export interface Workspace {
15
15
  * task's links.base adds or changes relative to the runner's HEAD.
16
16
  */
17
17
  sensitiveChanges?(task: Task): Promise<string[]>;
18
+ /** The repo names a task may name (links.repo, links.repos): the runner tells the hub, which refuses others when sent. */
19
+ repoNames?(): string[];
18
20
  /**
19
21
  * Cross-repo: the task's links.repos (besides the primary repo), made readable.
20
22
  * Unknown names throw (the task fails with the message).
@@ -41,6 +43,7 @@ export declare class GitWorkspace implements Workspace {
41
43
  constructor(dir: string, home: string, log?: (s: string) => void, repos?: Record<string, string>);
42
44
  /** The local repo a task works in (P3). */
43
45
  repoDir(task: Task): string;
46
+ repoNames(): string[];
44
47
  /** Map a repo name to its local path, or fail with the names this runner knows. */
45
48
  lookup(r: unknown, what: string): string;
46
49
  /** Where read-only checkouts of a task's other repos go (next to, not inside, its worktree). */
@@ -65,6 +65,9 @@ export class GitWorkspace {
65
65
  return this.dir;
66
66
  return this.lookup(r, 'links.repo');
67
67
  }
68
+ repoNames() {
69
+ return [...new Set([...Object.keys(this.repos), basename(this.dir)])].filter((n) => REPO_NAME_RE.test(n)).sort();
70
+ }
68
71
  /** Map a repo name to its local path, or fail with the names this runner knows. */
69
72
  lookup(r, what) {
70
73
  if (typeof r !== 'string' || !REPO_NAME_RE.test(r))
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.26.6";
1
+ export declare const VERSION = "3.27.0";
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export declare const PKG_NAME = "@koalaauto/agentchannel";
4
4
  /**
@@ -1,4 +1,4 @@
1
- export const VERSION = '3.26.6';
1
+ export const VERSION = '3.27.0';
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export const PKG_NAME = '@koalaauto/agentchannel';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalaauto/agentchannel",
3
- "version": "3.26.6",
3
+ "version": "3.27.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",