@koalaauto/agentchannel 3.99.3 → 3.101.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 +3 -3
- package/dist/src/cli-run.js +23 -2
- package/dist/src/cli.js +6 -2
- package/dist/src/client.d.ts +3 -0
- package/dist/src/guide-text.d.ts +33 -33
- package/dist/src/guide-text.js +33 -33
- package/dist/src/mcp.d.ts +10 -1
- package/dist/src/mcp.js +27 -6
- package/dist/src/onboard.d.ts +3 -0
- package/dist/src/onboard.js +2 -2
- package/dist/src/perm.d.ts +9 -0
- package/dist/src/perm.js +14 -0
- package/dist/src/prompts.d.ts +12 -0
- package/dist/src/prompts.js +15 -0
- package/dist/src/runner/reports.js +1 -1
- package/dist/src/runner/runner.d.ts +13 -0
- package/dist/src/runner/runner.js +44 -2
- package/dist/src/runner/state.d.ts +2 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,8 @@ export interface RunnerOptions {
|
|
|
21
21
|
dir: string;
|
|
22
22
|
max?: number;
|
|
23
23
|
perm?: Perm;
|
|
24
|
+
/** --owner-perm: the level of a task on the owner's word (perm.ts runPerm). Unset: the usual level. */
|
|
25
|
+
ownerPerm?: Perm;
|
|
24
26
|
intervalMs?: number;
|
|
25
27
|
/**
|
|
26
28
|
* Opens the hub's change stream (Client.eventsSocket). With it, an idle runner asks for its inbox when an event concerns its
|
|
@@ -88,6 +90,8 @@ export interface RunnerOptions {
|
|
|
88
90
|
export interface RunnerStartInfo {
|
|
89
91
|
/** --dir, absolute. */
|
|
90
92
|
dir: string;
|
|
93
|
+
/** This machine's name: where the agent's owner opens a session to take a task over (docs/specs/takeover.md). */
|
|
94
|
+
host?: string;
|
|
91
95
|
/** AGENTCHANNEL_HOME when it is not the default home. */
|
|
92
96
|
home?: string;
|
|
93
97
|
/** --repo name=path given on the command line (config.json's repos need nothing). */
|
|
@@ -280,6 +284,15 @@ export declare class Runner {
|
|
|
280
284
|
* for a minute (ten when it has no GitHub App).
|
|
281
285
|
*/
|
|
282
286
|
private githubToken;
|
|
287
|
+
/**
|
|
288
|
+
* The level a task on the owner's word runs at, undefined when there is none. The owner is the one this machine first saw
|
|
289
|
+
* with --owner-perm set (kept in <home>/owner.json): a hub where someone made themselves this agent's owner later does not
|
|
290
|
+
* get this machine with it. Removing the file accepts the new owner.
|
|
291
|
+
*/
|
|
292
|
+
private ownerLevel;
|
|
293
|
+
private ownerChangedSaid;
|
|
294
|
+
/** What the owner's word means for this task's prompt: 'on' its runs have the owner's level, 'ask' the owner's answer would give it. */
|
|
295
|
+
private ownerAccess;
|
|
283
296
|
/** Run the adapter with heartbeat, idle watchdog, session persistence and usage posting. */
|
|
284
297
|
private execute;
|
|
285
298
|
/**
|
|
@@ -15,7 +15,7 @@ import { Client as HubClient, HubError, isTerminal } from '../client.js';
|
|
|
15
15
|
import { taskFiles } from '../attachments.js';
|
|
16
16
|
import { buildAgentEnv } from '../env.js';
|
|
17
17
|
import { unlinkWindowsSandbox } from '../codexhome.js';
|
|
18
|
-
import {
|
|
18
|
+
import { runPerm } from '../perm.js';
|
|
19
19
|
import { ANSWER_SCHEMA, MENTION_SCHEMA, splitYodaNotes, buildAnswerPrompt, buildMentionPrompt, buildPreparePrompt, buildResumePrompt, buildTaskPrompt, postUrl, refOf, REMOTE_FAILED_PREFIX, taskUrl } from '../prompts.js';
|
|
20
20
|
import { linkedArtifacts } from './linked-artifacts.js';
|
|
21
21
|
import { linkedDocs } from './linked-docs.js';
|
|
@@ -27,6 +27,7 @@ import { accountProblem, effortRejected, looksLikeLoginError, modelRejected, pro
|
|
|
27
27
|
import { TraceRecorder } from '../trace.js';
|
|
28
28
|
import { removeQuietly } from '../removequiet.js';
|
|
29
29
|
import { detectHost, looksLikeSandboxError, sandboxFix } from '../sandboxcheck.js';
|
|
30
|
+
import { readJson, writeJsonPrivate } from '../config.js';
|
|
30
31
|
import { prepareAgentHome, realHomeOf, secretPaths } from './home.js';
|
|
31
32
|
import { draftText, parsePrepared, parseStructured } from './structured.js';
|
|
32
33
|
import { TraceQueue } from './traces.js';
|
|
@@ -699,6 +700,7 @@ export class Runner {
|
|
|
699
700
|
tokenAt: Date.now(),
|
|
700
701
|
handoffVersion: claim.task.handoff_version,
|
|
701
702
|
...(claim.task.perm === 'read' ? { readOnly: true } : {}),
|
|
703
|
+
...(claim.task.owner_word ? { ownerWord: true } : {}),
|
|
702
704
|
seen: Array.from(new Set([...(prev?.seen ?? []), ...claim.messages.map((m) => m.id)])),
|
|
703
705
|
...(prev?.gate ? { gate: prev.gate } : {}),
|
|
704
706
|
...(readRepos.length ? { readRepos } : {}),
|
|
@@ -752,6 +754,7 @@ export class Runner {
|
|
|
752
754
|
remote: !!this.cloud,
|
|
753
755
|
report: !this.o.adapter.spec.ach,
|
|
754
756
|
achTool: this.o.adapter.spec.achBy === 'tool',
|
|
757
|
+
ownerAccess: this.ownerAccess(me, rec),
|
|
755
758
|
...this.runContext(workdir),
|
|
756
759
|
});
|
|
757
760
|
this.reportPromptSize(taskId, rec.runId, prompt);
|
|
@@ -770,6 +773,11 @@ export class Runner {
|
|
|
770
773
|
this.state.drop(taskId);
|
|
771
774
|
return;
|
|
772
775
|
}
|
|
776
|
+
// the owner may have answered since it parked: the runs from here on are on their word
|
|
777
|
+
if (!!bundle.task.owner_word !== !!rec.ownerWord) {
|
|
778
|
+
rec.ownerWord = !!bundle.task.owner_word;
|
|
779
|
+
this.state.put(rec);
|
|
780
|
+
}
|
|
773
781
|
// Lease lost while parked (runner was down): re-claim with the same run_id.
|
|
774
782
|
const leaseLost = bundle.task.status === 'submitted' || (bundle.task.run_id ?? '') !== rec.runId;
|
|
775
783
|
if (leaseLost || Date.now() - rec.tokenAt > TOKEN_REFRESH_MS) {
|
|
@@ -838,6 +846,8 @@ export class Runner {
|
|
|
838
846
|
remote: !!this.cloud,
|
|
839
847
|
report: !this.o.adapter.spec.ach,
|
|
840
848
|
achTool: this.o.adapter.spec.achBy === 'tool',
|
|
849
|
+
ownerAccess: this.ownerAccess(me, rec),
|
|
850
|
+
ownerName: me.owner_name,
|
|
841
851
|
})
|
|
842
852
|
: buildTaskPrompt({
|
|
843
853
|
artifacts: await this.linkedArtifacts([bundle.handoff, ...bundle.messages.map((m) => m.body)], taskId),
|
|
@@ -858,6 +868,7 @@ export class Runner {
|
|
|
858
868
|
remote: !!this.cloud,
|
|
859
869
|
report: !this.o.adapter.spec.ach,
|
|
860
870
|
achTool: this.o.adapter.spec.achBy === 'tool',
|
|
871
|
+
ownerAccess: this.ownerAccess(me, rec),
|
|
861
872
|
...this.runContext(rec.workdir),
|
|
862
873
|
});
|
|
863
874
|
if (!resume)
|
|
@@ -1492,6 +1503,36 @@ export class Runner {
|
|
|
1492
1503
|
return '';
|
|
1493
1504
|
}
|
|
1494
1505
|
}
|
|
1506
|
+
/**
|
|
1507
|
+
* The level a task on the owner's word runs at, undefined when there is none. The owner is the one this machine first saw
|
|
1508
|
+
* with --owner-perm set (kept in <home>/owner.json): a hub where someone made themselves this agent's owner later does not
|
|
1509
|
+
* get this machine with it. Removing the file accepts the new owner.
|
|
1510
|
+
*/
|
|
1511
|
+
ownerLevel(me) {
|
|
1512
|
+
if (!this.o.ownerPerm || !me.owner || me.kind === 'team')
|
|
1513
|
+
return undefined;
|
|
1514
|
+
const file = join(this.o.home, 'owner.json');
|
|
1515
|
+
const pinned = readJson(file, {}).owner;
|
|
1516
|
+
if (!pinned) {
|
|
1517
|
+
writeJsonPrivate(file, { owner: me.owner, name: me.owner_name ?? '' });
|
|
1518
|
+
return this.o.ownerPerm;
|
|
1519
|
+
}
|
|
1520
|
+
if (pinned === me.owner)
|
|
1521
|
+
return this.o.ownerPerm;
|
|
1522
|
+
if (!this.ownerChangedSaid) {
|
|
1523
|
+
this.ownerChangedSaid = true;
|
|
1524
|
+
this.log(`--owner-perm is off: this agent's owner on the hub (${me.owner_name ?? me.owner}) is not the one this machine set it for. To accept the new owner, remove ${file} and restart.`);
|
|
1525
|
+
}
|
|
1526
|
+
return undefined;
|
|
1527
|
+
}
|
|
1528
|
+
ownerChangedSaid = false;
|
|
1529
|
+
/** What the owner's word means for this task's prompt: 'on' its runs have the owner's level, 'ask' the owner's answer would give it. */
|
|
1530
|
+
ownerAccess(me, rec) {
|
|
1531
|
+
const level = this.ownerLevel(me);
|
|
1532
|
+
if (!level || rec.readOnly || runPerm(me.perm_level, this.o.perm, level, true) === runPerm(me.perm_level, this.o.perm, level, false))
|
|
1533
|
+
return undefined;
|
|
1534
|
+
return rec.ownerWord ? 'on' : 'ask';
|
|
1535
|
+
}
|
|
1495
1536
|
/** Run the adapter with heartbeat, idle watchdog, session persistence and usage posting. */
|
|
1496
1537
|
async execute(rec, entry, prompt, resume, mode, outputSchema, extra = {}) {
|
|
1497
1538
|
const { client } = this.o;
|
|
@@ -1501,7 +1542,8 @@ export class Runner {
|
|
|
1501
1542
|
const sessKey = mode === 'mention' ? (extra.threadId ? threadKey(extra.threadId) : '') : mode === 'prepare' ? '' : taskId;
|
|
1502
1543
|
const sessKind = mode;
|
|
1503
1544
|
// a read-only task (perm: read) runs with read access only, whatever the agent's own level
|
|
1504
|
-
|
|
1545
|
+
// a task on the owner's word runs at the level this machine set for the owner (perm.ts runPerm)
|
|
1546
|
+
const perm = mode === 'work' && !rec.readOnly ? runPerm(me.perm_level, this.o.perm, this.ownerLevel(me), !!rec.ownerWord) : 'read';
|
|
1505
1547
|
const env = buildAgentEnv(this.o.baseEnv ?? process.env, {
|
|
1506
1548
|
hub: this.o.hub,
|
|
1507
1549
|
runToken: rec.runToken,
|
|
@@ -8,6 +8,8 @@ export interface RunRecord {
|
|
|
8
8
|
handoffVersion?: number;
|
|
9
9
|
/** A read-only task (`perm: read`): its runs get read access only, whatever the agent's own level. */
|
|
10
10
|
readOnly?: boolean;
|
|
11
|
+
/** The task is on the owner's word (hub `owner_word`), as last read: its runs get the machine's --owner-perm. */
|
|
12
|
+
ownerWord?: boolean;
|
|
11
13
|
/** The agent stopped once without finishing and was asked to finish (runner afterWork). */
|
|
12
14
|
nudged?: boolean;
|
|
13
15
|
/** Message ids the worker has already been shown. */
|
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.101.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",
|