@koalaauto/agentchannel 3.43.0 → 3.45.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/client.d.ts +8 -4
- package/dist/src/client.js +1 -1
- package/dist/src/doctor.js +10 -3
- package/dist/src/import.d.ts +1 -2
- package/dist/src/import.js +4 -8
- package/dist/src/prompts.d.ts +4 -2
- package/dist/src/prompts.js +1 -1
- package/dist/src/runner/runner.d.ts +4 -2
- package/dist/src/runner/runner.js +14 -10
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/client.d.ts
CHANGED
|
@@ -30,8 +30,10 @@ export interface Agent {
|
|
|
30
30
|
name: string;
|
|
31
31
|
owner?: string;
|
|
32
32
|
owner_name?: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/** Who it belongs to (docs/mechanisms.md): a person (personal) or the team (team: no one person, the admins look after it). */
|
|
34
|
+
kind?: 'personal' | 'team';
|
|
35
|
+
/** system: the team's one system agent (a team agent that does the hub's own work). */
|
|
36
|
+
role?: '' | 'system';
|
|
35
37
|
runtime?: string;
|
|
36
38
|
description?: string;
|
|
37
39
|
perm_level?: string;
|
|
@@ -45,8 +47,10 @@ export interface Agent {
|
|
|
45
47
|
net_allow?: string[];
|
|
46
48
|
/** The repo names its runner can work in, as the runner reported them (empty: never reported). */
|
|
47
49
|
repos?: string[];
|
|
48
|
-
/** GitHub repositories ("owner/name", "owner/*")
|
|
50
|
+
/** GitHub repositories ("owner/name", "owner/*") an admin picked for the agent's runs; empty: none picked. */
|
|
49
51
|
github_repos?: string[];
|
|
52
|
+
/** What its runs may read on GitHub: github_repos, else the repositories its runner works in (one owner); empty: nothing. */
|
|
53
|
+
github_scope?: string[];
|
|
50
54
|
}
|
|
51
55
|
/** A read-only GitHub token the hub issued for one run, valid an hour. `repos`: the repository names it covers, or ["*"]. */
|
|
52
56
|
export interface GithubToken {
|
|
@@ -430,7 +434,7 @@ export declare class Client {
|
|
|
430
434
|
/** Download one attachment into `dir`; returns the local path. */
|
|
431
435
|
download(a: Attachment, dir: string): Promise<string>;
|
|
432
436
|
me(): Promise<Agent>;
|
|
433
|
-
/** A read-only GitHub token for one run (
|
|
437
|
+
/** A read-only GitHub token for one run (the agent's github_scope); `runId` names a live run (the runner's key needs it). */
|
|
434
438
|
githubToken(runId: string): Promise<GithubToken>;
|
|
435
439
|
/** A one-hour token that pushes to one repository, for delivering a task's branch (the runner's key, the task's run). */
|
|
436
440
|
pushToken(taskId: string, runId: string, github: string): Promise<GithubToken>;
|
package/dist/src/client.js
CHANGED
|
@@ -265,7 +265,7 @@ export class Client {
|
|
|
265
265
|
a.owner_name = r.owner_name;
|
|
266
266
|
return a;
|
|
267
267
|
}
|
|
268
|
-
/** A read-only GitHub token for one run (
|
|
268
|
+
/** A read-only GitHub token for one run (the agent's github_scope); `runId` names a live run (the runner's key needs it). */
|
|
269
269
|
async githubToken(runId) {
|
|
270
270
|
return this.ach('POST', '/github/token', { run_id: runId });
|
|
271
271
|
}
|
package/dist/src/doctor.js
CHANGED
|
@@ -108,6 +108,7 @@ export async function runDoctor(o) {
|
|
|
108
108
|
let runtime;
|
|
109
109
|
let agentName;
|
|
110
110
|
let githubRepos = [];
|
|
111
|
+
let githubScope = null;
|
|
111
112
|
if (cfg.hub) {
|
|
112
113
|
const fetchFn = o.fetch ?? ((u, i) => fetch(u, i));
|
|
113
114
|
let host = cfg.hub;
|
|
@@ -170,6 +171,7 @@ export async function runDoctor(o) {
|
|
|
170
171
|
runtime = typeof me.runtime === 'string' ? me.runtime : undefined;
|
|
171
172
|
agentName = me.name;
|
|
172
173
|
githubRepos = Array.isArray(me.github_repos) ? me.github_repos : [];
|
|
174
|
+
githubScope = Array.isArray(me.github_scope) ? me.github_scope : null;
|
|
173
175
|
add('hub login', 'ok', `agent ${me.name}${me.owner_name ? ` (owner ${me.owner_name})` : ''}, runtime ${me.runtime ?? '?'}`, 'key');
|
|
174
176
|
}
|
|
175
177
|
catch (e) {
|
|
@@ -189,10 +191,15 @@ export async function runDoctor(o) {
|
|
|
189
191
|
hubLatest = c.latest_client;
|
|
190
192
|
if (c && Number.isInteger(c.min_client_proto))
|
|
191
193
|
hubMinProto = c.min_client_proto;
|
|
192
|
-
// a run's GitHub token comes from the hub's GitHub App
|
|
194
|
+
// a run's GitHub token comes from the hub's GitHub App, for the agent's scope: the repositories an admin picked, else the
|
|
195
|
+
// ones this runner works in (an older hub without github_scope: the picked ones, else every repository the App sees)
|
|
193
196
|
if (c && typeof c.github_app === 'boolean') {
|
|
194
|
-
if (c.github_app)
|
|
195
|
-
add('github', '
|
|
197
|
+
if (c.github_app && githubScope && !githubScope.length)
|
|
198
|
+
add('github', 'warn', 'no GitHub repository: this runner works in no GitHub checkout and no admin picked any', 'key', 'start the runner in a checkout, or ask your admin to pick repositories for this agent');
|
|
199
|
+
else if (c.github_app) {
|
|
200
|
+
const s = githubScope ?? githubRepos;
|
|
201
|
+
add('github', 'ok', s.length ? `a read-only token for ${s.join(', ')}, issued for each run` : 'a read-only token for every repository the hub\'s GitHub App sees, issued for each run', 'key');
|
|
202
|
+
}
|
|
196
203
|
else if (githubRepos.length)
|
|
197
204
|
add('github', 'warn', `${githubRepos.join(', ')} are listed for this agent, but the hub has no GitHub App`, 'key', 'ask your admin to set ACH_GITHUB_APP_ID and ACH_GITHUB_APP_KEY on the hub');
|
|
198
205
|
}
|
package/dist/src/import.d.ts
CHANGED
|
@@ -69,7 +69,6 @@ export interface PlanPerson {
|
|
|
69
69
|
is_admin?: boolean;
|
|
70
70
|
self?: boolean;
|
|
71
71
|
invite: boolean;
|
|
72
|
-
role?: string;
|
|
73
72
|
note?: string;
|
|
74
73
|
channels?: string[];
|
|
75
74
|
stats?: {
|
|
@@ -169,7 +168,7 @@ export declare function collectGithub(exec: Exec, org: string, since: string, o?
|
|
|
169
168
|
* `maxChannels` channels besides #general. The plan is a starting point: edit it.
|
|
170
169
|
*/
|
|
171
170
|
export declare function defaultChannels(repos: RepoData[], maxChannels?: number): PlanChannel[];
|
|
172
|
-
/** People from commits, issues and PRs;
|
|
171
|
+
/** People from commits, issues and PRs; bots excluded. */
|
|
173
172
|
export declare function inferPeople(c: Collected, channels: PlanChannel[]): {
|
|
174
173
|
people: PlanPerson[];
|
|
175
174
|
bots: string[];
|
package/dist/src/import.js
CHANGED
|
@@ -327,7 +327,7 @@ function chanOut(name, rs, desc) {
|
|
|
327
327
|
},
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
|
-
/** "(12 commits, 3 issues, 2 PRs, 5 assigned)" for the plan printout
|
|
330
|
+
/** "(12 commits, 3 issues, 2 PRs, 5 assigned)" for the plan printout. */
|
|
331
331
|
const personActivity = (p) => {
|
|
332
332
|
const s = p.stats;
|
|
333
333
|
if (!s)
|
|
@@ -335,7 +335,7 @@ const personActivity = (p) => {
|
|
|
335
335
|
const parts = [[s.commits, 'commits'], [s.issues_opened, 'issues'], [s.prs_opened, 'PRs'], [s.assigned, 'assigned']].filter(([n]) => Number(n) > 0).map(([n, w]) => `${n} ${w}`);
|
|
336
336
|
return parts.length ? ` (${parts.join(', ')})` : '';
|
|
337
337
|
};
|
|
338
|
-
/** People from commits, issues and PRs;
|
|
338
|
+
/** People from commits, issues and PRs; bots excluded. */
|
|
339
339
|
export function inferPeople(c, channels) {
|
|
340
340
|
const chanOf = new Map();
|
|
341
341
|
for (const ch of channels)
|
|
@@ -402,8 +402,6 @@ export function inferPeople(c, channels) {
|
|
|
402
402
|
for (const a of acc.values()) {
|
|
403
403
|
const total = a.commits + a.opened + a.prs + a.assigned;
|
|
404
404
|
const self = !!c.self && a.login.toLowerCase() === c.self.toLowerCase();
|
|
405
|
-
// a short label a person can read on their page; the counts stay in `stats` (admin is a permission, shown apart)
|
|
406
|
-
const label = a.commits >= 10 ? 'maintainer' : a.opened >= 5 && a.commits < 3 ? 'reporter / tester' : 'contributor';
|
|
407
405
|
const invite = self || total >= 3 || a.assigned > 0;
|
|
408
406
|
const u = c.users[a.login];
|
|
409
407
|
people.push({
|
|
@@ -413,7 +411,6 @@ export function inferPeople(c, channels) {
|
|
|
413
411
|
is_admin: self,
|
|
414
412
|
...(self ? { self: true } : {}),
|
|
415
413
|
invite,
|
|
416
|
-
role: label,
|
|
417
414
|
...(invite ? {} : { note: 'occasional contributor: confirm who this is before inviting' }),
|
|
418
415
|
channels: [...a.chans.entries()].sort((x, y) => y[1] - x[1]).map(([n]) => n),
|
|
419
416
|
stats: { commits: a.commits, issues_opened: a.opened, prs_opened: a.prs, assigned: a.assigned, commits_by_repo: a.byRepo },
|
|
@@ -523,7 +520,6 @@ export async function pushToHub(admin, source, o) {
|
|
|
523
520
|
})),
|
|
524
521
|
people: o.plan.people.map((p) => ({
|
|
525
522
|
github_login: p.github_login, name: p.name, email: p.email, is_admin: !!p.is_admin, self: !!p.self, invite: p.invite !== false,
|
|
526
|
-
...(p.role ? { role: p.role } : {}),
|
|
527
523
|
...(Array.isArray(p.channels) ? { channels: p.channels } : {}),
|
|
528
524
|
...(p.feishu_open_id ? { feishu_open_id: p.feishu_open_id } : {}),
|
|
529
525
|
})),
|
|
@@ -596,7 +592,7 @@ export function planSummary(plan, file, sel) {
|
|
|
596
592
|
L.push('');
|
|
597
593
|
L.push('People:');
|
|
598
594
|
for (const p of plan.people.filter((x) => x.invite !== false)) {
|
|
599
|
-
L.push(` ${pad(p.github_login, 18)}${pad(p.name, 18)}${p.is_admin ? '[admin] ' : ''}${
|
|
595
|
+
L.push(` ${pad(p.github_login, 18)}${pad(p.name, 18)}${p.is_admin ? '[admin] ' : ''}${personActivity(p).trim()}${p.channels?.length ? ` -> ${p.channels.map((c) => '#' + c).join(' ')}` : ''}`);
|
|
600
596
|
}
|
|
601
597
|
const later = plan.people.filter((x) => x.invite === false);
|
|
602
598
|
if (later.length)
|
|
@@ -609,7 +605,7 @@ export function planSummary(plan, file, sel) {
|
|
|
609
605
|
L.push('');
|
|
610
606
|
L.push(`Plan written to ${file}. Nothing was changed on GitHub or the hub.`);
|
|
611
607
|
L.push(`Edit it (channel names, which repos go where, "visibility": "private" for members-only channels,`);
|
|
612
|
-
L.push(`people's "channels" (their membership)
|
|
608
|
+
L.push(`people's "channels" (their membership), names, emails, invite true/false), then:`);
|
|
613
609
|
L.push(`Note: the hub widens access compared with GitHub: every hub member can read a "team" channel even if`);
|
|
614
610
|
L.push(`they cannot see that repo on GitHub. Mark channels of private repos "private" and list their members.`);
|
|
615
611
|
L.push(` ach admin import github --org ${plan.source.org} --plan ${file}`);
|
package/dist/src/prompts.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import type { Judgment, Message, Post, Task, WikiContext } from './client.js';
|
|
|
2
2
|
export interface PromptCtx {
|
|
3
3
|
agentName: string;
|
|
4
4
|
ownerName?: string;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/** Who it belongs to: a team agent has no owner and no one's personal memory; the admins look after it. */
|
|
6
|
+
kind?: 'personal' | 'team';
|
|
7
|
+
/** system: the team's one system agent. */
|
|
8
|
+
role?: '' | 'system';
|
|
7
9
|
senderName?: string;
|
|
8
10
|
task: Task;
|
|
9
11
|
handoff: string;
|
package/dist/src/prompts.js
CHANGED
|
@@ -274,7 +274,7 @@ function channelText(c) {
|
|
|
274
274
|
function header(c) {
|
|
275
275
|
const t = c.task;
|
|
276
276
|
return [
|
|
277
|
-
`You are agent "${c.agentName}"${c.system ? ", the team's system agent (owned by no one; the team's admins look after you)" : c.ownerName ? `, owned by ${c.ownerName}` : ''}. Agent "${c.senderName ?? t.from_agent ?? 'unknown'}" sent you task ${refOf(t)} via AgentChannel.`,
|
|
277
|
+
`You are agent "${c.agentName}"${c.role === 'system' ? ", the team's system agent (owned by no one; the team's admins look after you)" : c.kind === 'team' ? ", a team agent (owned by no one person; the team's admins look after you)" : c.ownerName ? `, owned by ${c.ownerName}` : ''}. Agent "${c.senderName ?? t.from_agent ?? 'unknown'}" sent you task ${refOf(t)} via AgentChannel.`,
|
|
278
278
|
`Priority: ${t.priority ?? 'n/a'}. Handoff version: ${c.handoffVersion ?? t.handoff_version ?? 1}.`,
|
|
279
279
|
...(c.taskUrl ? [`Task page: ${c.taskUrl}`] : []),
|
|
280
280
|
].join('\n');
|
|
@@ -319,6 +319,8 @@ export declare class Runner {
|
|
|
319
319
|
private postStructuredAnswer;
|
|
320
320
|
/** Readable roots for the spawned agent besides its cwd (S4). */
|
|
321
321
|
private readRoots;
|
|
322
|
+
/** Owned by no one person (the system agent, or a team agent such as one that does a channel mechanism for the team). */
|
|
323
|
+
private teamOwned;
|
|
322
324
|
/** What a full task prompt carries besides the task: the owner's memory for this project and the project's instructions. */
|
|
323
325
|
private runContext;
|
|
324
326
|
/** Where a task's attachments are downloaded for its agents (readable, outside the worktree). */
|
|
@@ -326,8 +328,8 @@ export declare class Runner {
|
|
|
326
328
|
/** The task's attachments, downloaded into filesDir (best effort: a failed download is listed without a path). */
|
|
327
329
|
private fetchFiles;
|
|
328
330
|
/**
|
|
329
|
-
* The GitHub token of a run: read-only, issued by the hub from its GitHub App for this one run and valid an hour (
|
|
330
|
-
*
|
|
331
|
+
* The GitHub token of a run: read-only, issued by the hub from its GitHub App for this one run and valid an hour (the
|
|
332
|
+
* repositories an admin picked for this agent, else the ones this runner works in). A hub that cannot issue one does not fail the run: the
|
|
331
333
|
* agent finds `gh` without a login, and the runner's log for the task says why. After a failure the hub is not asked again
|
|
332
334
|
* for a minute (ten when it has no GitHub App).
|
|
333
335
|
*/
|
|
@@ -371,7 +371,7 @@ export class Runner {
|
|
|
371
371
|
this.meAt = Date.now();
|
|
372
372
|
}
|
|
373
373
|
const me = await this.ensureMe();
|
|
374
|
-
if (me.system && (await this.systemInCheckout()))
|
|
374
|
+
if (me.role === 'system' && (await this.systemInCheckout()))
|
|
375
375
|
return;
|
|
376
376
|
// New tasks.
|
|
377
377
|
const blocked = budgetBlocked(me);
|
|
@@ -776,7 +776,7 @@ export class Runner {
|
|
|
776
776
|
/** Whether this runner reads new tasks ahead: a local runtime in a git checkout that delivers pull requests, and a hub that knows how. */
|
|
777
777
|
readsAhead(me) {
|
|
778
778
|
const { client, workspace, adapter } = this.o;
|
|
779
|
-
return !!this.o.readAhead && !this.noReadAhead &&
|
|
779
|
+
return !!this.o.readAhead && !this.noReadAhead && me.role !== 'system' && !adapter.remote && !!workspace.deliverable && !!client.prepareRun && !!client.prepared;
|
|
780
780
|
}
|
|
781
781
|
/**
|
|
782
782
|
* The read-ahead (owner-pulls-tasks.md): a short read-only run on a task nobody took yet. It reports whether the task changes code,
|
|
@@ -945,7 +945,7 @@ export class Runner {
|
|
|
945
945
|
const prompt = buildTaskPrompt({
|
|
946
946
|
agentName: me.name,
|
|
947
947
|
ownerName: me.owner_name,
|
|
948
|
-
|
|
948
|
+
kind: me.kind, role: me.role,
|
|
949
949
|
senderName: claim.task.from_agent_name,
|
|
950
950
|
task: claim.task,
|
|
951
951
|
handoff: claim.handoff,
|
|
@@ -1045,7 +1045,7 @@ export class Runner {
|
|
|
1045
1045
|
: buildTaskPrompt({
|
|
1046
1046
|
agentName: me.name,
|
|
1047
1047
|
ownerName: me.owner_name,
|
|
1048
|
-
|
|
1048
|
+
kind: me.kind, role: me.role,
|
|
1049
1049
|
senderName: bundle.task.from_agent_name,
|
|
1050
1050
|
task: bundle.task,
|
|
1051
1051
|
handoff: bundle.handoff,
|
|
@@ -1487,16 +1487,20 @@ export class Runner {
|
|
|
1487
1487
|
join(this.o.home, 'bin'),
|
|
1488
1488
|
...readRepos.flatMap((r) => r.roots),
|
|
1489
1489
|
...(taskId ? [this.filesDir(taskId)] : []),
|
|
1490
|
-
// the owner's Claude Code memory for this project, read-only (docs/specs/agent-autonomy.md);
|
|
1491
|
-
...(this.
|
|
1490
|
+
// the owner's Claude Code memory for this project, read-only (docs/specs/agent-autonomy.md); a team agent has no owner
|
|
1491
|
+
...(this.teamOwned() ? [] : [ownerMemoryDir(cwd, home)].filter((d) => !!d)),
|
|
1492
1492
|
];
|
|
1493
1493
|
}
|
|
1494
|
+
/** Owned by no one person (the system agent, or a team agent such as one that does a channel mechanism for the team). */
|
|
1495
|
+
teamOwned() {
|
|
1496
|
+
return this.me?.kind === 'team';
|
|
1497
|
+
}
|
|
1494
1498
|
/** What a full task prompt carries besides the task: the owner's memory for this project and the project's instructions. */
|
|
1495
1499
|
runContext(workdir) {
|
|
1496
1500
|
if (this.o.adapter.remote)
|
|
1497
1501
|
return { project: [] };
|
|
1498
|
-
// the system agent works for the team: no person's memory, whatever machine it runs on (docs/
|
|
1499
|
-
const dir = this.
|
|
1502
|
+
// a team agent (the system agent too) works for the team: no person's memory, whatever machine it runs on (docs/mechanisms.md)
|
|
1503
|
+
const dir = this.teamOwned() ? undefined : ownerMemoryDir(workdir, realHomeOf(this.o.baseEnv ?? process.env));
|
|
1500
1504
|
// Claude Code shows the index itself (it keys memory by the repository); other runtimes get it in the prompt
|
|
1501
1505
|
const ownerMemory = dir ? { dir, ...(this.o.adapter.name === 'claude' ? {} : { index: memoryIndex(dir) }) } : undefined;
|
|
1502
1506
|
return { ownerMemory, project: projectInstructions(workdir, this.o.adapter.name) };
|
|
@@ -1523,8 +1527,8 @@ export class Runner {
|
|
|
1523
1527
|
return out;
|
|
1524
1528
|
}
|
|
1525
1529
|
/**
|
|
1526
|
-
* The GitHub token of a run: read-only, issued by the hub from its GitHub App for this one run and valid an hour (
|
|
1527
|
-
*
|
|
1530
|
+
* The GitHub token of a run: read-only, issued by the hub from its GitHub App for this one run and valid an hour (the
|
|
1531
|
+
* repositories an admin picked for this agent, else the ones this runner works in). A hub that cannot issue one does not fail the run: the
|
|
1528
1532
|
* agent finds `gh` without a login, and the runner's log for the task says why. After a failure the hub is not asked again
|
|
1529
1533
|
* for a minute (ten when it has no GitHub App).
|
|
1530
1534
|
*/
|
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.45.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",
|