@koalaauto/agentchannel 3.100.0 → 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/cli-run.js +12 -1
- package/dist/src/mcp.d.ts +10 -1
- package/dist/src/mcp.js +27 -6
- package/dist/src/runner/runner.d.ts +2 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/cli-run.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { execFileSync, execSync, spawn } from 'node:child_process';
|
|
4
4
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { basename, delimiter, dirname, join, resolve } from 'node:path';
|
|
6
|
-
import { tmpdir } from 'node:os';
|
|
6
|
+
import { hostname, tmpdir } from 'node:os';
|
|
7
7
|
import { developerDir } from './adapters/scope.js';
|
|
8
8
|
import { acquireRunnerLock, RunnerLockedError, runnerLockHolder } from './runner/lock.js';
|
|
9
9
|
import { UsageError } from './args.js';
|
|
@@ -276,6 +276,7 @@ async function runOnce(p, io) {
|
|
|
276
276
|
const service = !startedByService(me.name, process.platform, env) ? '' : process.platform === 'darwin' ? 'launchd' : 'systemd';
|
|
277
277
|
return {
|
|
278
278
|
dir,
|
|
279
|
+
...(hostName() ? { host: hostName() } : {}),
|
|
279
280
|
...(env.AGENTCHANNEL_HOME ? { home: home } : {}),
|
|
280
281
|
...(Object.keys(repoFlags).length ? { repos: repoFlags } : {}),
|
|
281
282
|
...(v['interactive-first'] ? { interactive_first: true } : {}),
|
|
@@ -508,6 +509,16 @@ export async function otherAgentHere(env, hub, newKey, meId, cfId, cfSecret, fet
|
|
|
508
509
|
}
|
|
509
510
|
}
|
|
510
511
|
/** Linux: does this user's systemd outlive their logins (loginctl linger)? Unknown counts as yes (no false alarm). */
|
|
512
|
+
/** This machine's name as the hub takes it (a name, nothing else); '' when the system gives none of that shape. */
|
|
513
|
+
function hostName() {
|
|
514
|
+
try {
|
|
515
|
+
const h = hostname().trim();
|
|
516
|
+
return /^[A-Za-z0-9][A-Za-z0-9._-]{0,252}$/.test(h) ? h : '';
|
|
517
|
+
}
|
|
518
|
+
catch {
|
|
519
|
+
return '';
|
|
520
|
+
}
|
|
521
|
+
}
|
|
511
522
|
function lingers(env) {
|
|
512
523
|
try {
|
|
513
524
|
return execFileSync('loginctl', ['show-user', env.USER || String(process.getuid?.() ?? ''), '-p', 'Linger', '--value'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() !== 'no';
|
package/dist/src/mcp.d.ts
CHANGED
|
@@ -82,7 +82,16 @@ export declare const noticeInResult: (lines: string[]) => string;
|
|
|
82
82
|
*/
|
|
83
83
|
export declare function askToConfirm(server: McpServer, what: string, env?: NodeJS.ProcessEnv): Promise<'confirm' | 'decline' | null>;
|
|
84
84
|
/** Which tool settles a waiting item of the person's Inbox (hub: api/person-inbox.ts), in one line; '' when none of ours does. */
|
|
85
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Where a task that waits to be taken over is worked (the hub's `takeover`: docs/specs/takeover.md): in a session opened in the
|
|
87
|
+
* directory of the agent it was sent to. `hand`: the agent whose directory this session is in, if any.
|
|
88
|
+
*/
|
|
89
|
+
export declare function takeoverWhere(place: unknown, hand?: string): {
|
|
90
|
+
here: boolean;
|
|
91
|
+
where: string;
|
|
92
|
+
review: boolean;
|
|
93
|
+
};
|
|
94
|
+
export declare function inboxHandle(i: Record<string, unknown>, hand?: string): string;
|
|
86
95
|
export declare function buildMcpServer(client: Client, o?: {
|
|
87
96
|
brief?: string;
|
|
88
97
|
identity?: string;
|
package/dist/src/mcp.js
CHANGED
|
@@ -126,8 +126,9 @@ export function personInstructions(name, hand) {
|
|
|
126
126
|
'Which tool when:',
|
|
127
127
|
`- send_task, post, reply: when your user says what to send and to whom (an agent or a person by name, a channel, a thread), send it yourself: it goes out exactly as you wrote it, as ${name}. A post, a reply and a task to one of ${name}'s own agents go out at once (take_back with the act id of the result undoes one); a task to anyone else, and anything ${name} asked to be asked about first, waits on a card until they confirm it: where the client can, they are asked right here; else give them the link to the Yoda page. You never confirm for them, and do not send it again. Send only what your user asked you to send.`,
|
|
128
128
|
`- ask_yoda: when your user names work and not who does it ("get the gateway team to..."), asks what goes on in the team, or wants anything else done there (answer a question, schedule): say it to Yoda in their words. Yoda knows who does what and acts as ${name} under the same rules.`,
|
|
129
|
-
`- handle_task: ${name}'s own word on a task, when they give it to you here: accept it, approve their agent's work, send it back (request_changes), cancel it,
|
|
129
|
+
`- handle_task: ${name}'s own word on a task, when they give it to you here: accept it, approve their agent's work, send it back (request_changes), cancel it, a note to its worker, or hand one that waits for them to take it over to their agent's runner (to_runner).`,
|
|
130
130
|
`- owner_inbox: what waits for ${name}. An item may carry "yoda": what Yoda already said about it (what it is, what it would choose and why); tell ${name} that with the item, as Yoda's word, before they answer. Each item's "handle" says which tool settles it; "cards" are acts waiting for ${name}'s confirmation (confirm_card asks them). decide: ${name}'s own answer to a decision request addressed to them, when they give it to you here in so many words (never your guess of it). get_task, list_channels, read_channel, search, list_agents: read the team as ${name} sees it. read_doc: a Feishu/Lark document or wiki link.`,
|
|
131
|
+
`- A code task sent to one of ${name}'s agents waits for ${name} to take it over (an owner_inbox item of type takeover; \`takeover\` on the task get_task returns). It is worked in a session opened in that agent's directory: \`takeover\` names the agent, its directory and its machine. ${hand ? `When that agent is ${hand}, that is here: claim_task. Otherwise` : 'From here'} tell ${name} where to open the session and to say "take over TASK-12" there; do not start the work in a session that is elsewhere. Their other answer is to hand it to that agent's runner (handle_task, action to_runner): theirs to choose, never yours.`,
|
|
131
132
|
'- memory_search (one line + link per hit), memory_read: the team Memory (current state, decisions, lessons, figures). Check it when your user asks how something is done or why something fails.',
|
|
132
133
|
`- yoda_memory: what Yoda remembers about ${name}; propose one more when you learn how they want something done (it counts once they accept it).`,
|
|
133
134
|
...(hand
|
|
@@ -253,6 +254,7 @@ const TASK_ACTS = {
|
|
|
253
254
|
request_changes: ['request_changes', 'body'],
|
|
254
255
|
cancel: ['cancel_task', 'reason'],
|
|
255
256
|
note: ['task_note', 'body'],
|
|
257
|
+
to_runner: ['hand_to_runner', 'note'],
|
|
256
258
|
};
|
|
257
259
|
const oneLine = (s) => { const t = String(s ?? '').replace(/\s+/g, ' ').trim(); return t.length > 120 ? `${t.slice(0, 120)}…` : t; };
|
|
258
260
|
/**
|
|
@@ -278,9 +280,28 @@ export async function askToConfirm(server, what, env = process.env) {
|
|
|
278
280
|
}
|
|
279
281
|
}
|
|
280
282
|
/** Which tool settles a waiting item of the person's Inbox (hub: api/person-inbox.ts), in one line; '' when none of ours does. */
|
|
281
|
-
|
|
283
|
+
/**
|
|
284
|
+
* Where a task that waits to be taken over is worked (the hub's `takeover`: docs/specs/takeover.md): in a session opened in the
|
|
285
|
+
* directory of the agent it was sent to. `hand`: the agent whose directory this session is in, if any.
|
|
286
|
+
*/
|
|
287
|
+
export function takeoverWhere(place, hand) {
|
|
288
|
+
const p = (place && typeof place === 'object' ? place : {});
|
|
289
|
+
const agent = String(p.agent ?? '');
|
|
290
|
+
const here = !!hand && hand === agent;
|
|
291
|
+
const dir = String(p.dir ?? '');
|
|
292
|
+
const host = String(p.host ?? '');
|
|
293
|
+
return { here, review: p.review === true, where: here ? 'this session' : `a session opened in ${dir ? `${dir}${host ? ` on ${host}` : ''} (the directory of their agent ${agent})` : `the directory of their agent ${agent || 'it was sent to'}`}` };
|
|
294
|
+
}
|
|
295
|
+
export function inboxHandle(i, hand) {
|
|
282
296
|
const task = String(i.task_ref ?? i.task_id ?? i.id ?? '');
|
|
283
297
|
switch (i.type) {
|
|
298
|
+
case 'takeover': {
|
|
299
|
+
const w = takeoverWhere(i.takeover, hand);
|
|
300
|
+
const runner = `handle_task {task_id: ${task}, action: to_runner, text}: their agent's runner does it${w.review ? ' and they review what it writes' : ' (nobody reviews what it writes: that agent delivers no pull requests)'}`;
|
|
301
|
+
return w.here
|
|
302
|
+
? `your user's choice of two: claim_task {task_id: ${task}}: they take it over and work it here ("take over ${task}"); or ${runner}. \`text\` is what the runner read ahead`
|
|
303
|
+
: `your user's choice of two: they take it over in ${w.where}, by saying "take over ${task}" (接 ${task}) there (it is not worked in this session: tell them that place); or ${runner}. \`text\` is what the runner read ahead`;
|
|
304
|
+
}
|
|
284
305
|
case 'decision': return `decide {task_id: ${String(i.task_ref ?? i.task_id ?? '')}, message_id: ${String(i.message_id ?? '')}, reply}: your user's own answer`;
|
|
285
306
|
case 'acceptance': return `handle_task {task_id: ${task}, action: accept | request_changes}`;
|
|
286
307
|
case 'review': return `handle_task {task_id: ${task}, action: approve | request_changes}`;
|
|
@@ -416,11 +437,11 @@ export function buildMcpServer(client, o = {}) {
|
|
|
416
437
|
inputSchema: { post_id: z.string(), text: z.string().describe('The reply, Markdown') },
|
|
417
438
|
}, async (a) => sent('reply', { post: a.post_id, body: a.text }, `reply in ${a.post_id}: ${oneLine(a.text)}`));
|
|
418
439
|
server.registerTool('handle_task', {
|
|
419
|
-
description: "Your user's own word on a task, when they give it to you here (never your guess of it), done at once in their name. action: accept (a task that waits for them to accept it); approve (work of their own agent that waits for their review); request_changes (send it back with what is to change: also runs a completed or failed task again); cancel (a task they sent); note (more context for the worker agent; a word for a person about a task is a reply in its thread). `text` is required for request_changes and note, optional otherwise.",
|
|
440
|
+
description: "Your user's own word on a task, when they give it to you here (never your guess of it), done at once in their name. action: accept (a task that waits for them to accept it); approve (work of their own agent that waits for their review); request_changes (send it back with what is to change: also runs a completed or failed task again); cancel (a task they sent); note (more context for the worker agent; a word for a person about a task is a reply in its thread); to_runner (a code task that waits for them to take it over goes to their agent's runner instead: it starts at once, and where that agent delivers pull requests, what it writes waits for their review; `text` is their word to the worker, such as answers to what the read-ahead asked). `text` is required for request_changes and note, optional otherwise.",
|
|
420
441
|
inputSchema: {
|
|
421
442
|
task_id: z.string().describe('TASK-128, or the task id'),
|
|
422
|
-
action: z.enum(['accept', 'approve', 'request_changes', 'cancel', 'note']),
|
|
423
|
-
text: z.string().optional().describe('What is to change, the note, the reason for a cancel,
|
|
443
|
+
action: z.enum(['accept', 'approve', 'request_changes', 'cancel', 'note', 'to_runner']),
|
|
444
|
+
text: z.string().optional().describe('What is to change, the note, the reason for a cancel, a few words with an accept, or their word to the worker with to_runner'),
|
|
424
445
|
},
|
|
425
446
|
}, async (a) => {
|
|
426
447
|
const [tool, key] = TASK_ACTS[a.action];
|
|
@@ -555,7 +576,7 @@ export function buildMcpServer(client, o = {}) {
|
|
|
555
576
|
if (!o.person)
|
|
556
577
|
return wrapUntrusted(inbox);
|
|
557
578
|
// a session that is the person: each waiting item says which tool settles it, and the cards waiting for their word come along
|
|
558
|
-
const items = Array.isArray(inbox.items) ? inbox.items.map((i) => { const h = i.pending ? inboxHandle(i) : ''; return h ? { ...i, handle: h } : i; }) : inbox.items;
|
|
579
|
+
const items = Array.isArray(inbox.items) ? inbox.items.map((i) => { const h = i.pending ? inboxHandle(i, o.hand?.name) : ''; return h ? { ...i, handle: h } : i; }) : inbox.items;
|
|
559
580
|
const cards = await client.yoda().then((y) => y.pending.filter((i) => i.kind === 'confirm' && i.act_id).map((i) => ({ act: i.act_id, what: i.body, handle: 'confirm_card {act}: asks your user here' })), () => []);
|
|
560
581
|
// nothing reaches them outside a session: said with what waits, since that is when it matters
|
|
561
582
|
const notice = o.notifyOff ? { notice: `No browser of ${o.person}'s takes notifications: when no session is open, nothing tells them something waits. They turn them on once at ${o.notifyOff}` } : {};
|
|
@@ -90,6 +90,8 @@ export interface RunnerOptions {
|
|
|
90
90
|
export interface RunnerStartInfo {
|
|
91
91
|
/** --dir, absolute. */
|
|
92
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;
|
|
93
95
|
/** AGENTCHANNEL_HOME when it is not the default home. */
|
|
94
96
|
home?: string;
|
|
95
97
|
/** --repo name=path given on the command line (config.json's repos need nothing). */
|
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",
|