@koalaauto/agentchannel 3.74.0 → 3.76.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 +4 -3
- package/dist/src/attachments.js +3 -2
- package/dist/src/cli.js +10 -2
- package/dist/src/client.d.ts +19 -0
- package/dist/src/client.js +68 -26
- package/dist/src/guide-text.d.ts +7 -7
- package/dist/src/guide-text.js +7 -7
- package/dist/src/ids.d.ts +74 -0
- package/dist/src/ids.js +135 -0
- package/dist/src/invite.d.ts +2 -1
- package/dist/src/invite.js +5 -2
- package/dist/src/mcp.js +13 -5
- package/dist/src/prompts.d.ts +15 -0
- package/dist/src/prompts.js +14 -0
- package/dist/src/runner/linked-docs.d.ts +8 -0
- package/dist/src/runner/linked-docs.js +33 -0
- package/dist/src/runner/runner.d.ts +3 -1
- package/dist/src/runner/runner.js +18 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A Feishu/Lark document or wiki link, as people paste it. */
|
|
2
|
+
const FEISHU_LINK = /https?:\/\/[A-Za-z0-9.-]*(?:feishu\.cn|larksuite\.com|larkoffice\.com)\/(?:docx|wiki)\/[A-Za-z0-9]{10,64}/g;
|
|
3
|
+
export const DOCS_MAX = 3;
|
|
4
|
+
export const DOC_TEXT_MAX = 20_000;
|
|
5
|
+
/** The distinct Feishu document links in `texts`, first seen first. */
|
|
6
|
+
export function feishuLinks(texts) {
|
|
7
|
+
const out = [];
|
|
8
|
+
for (const t of texts)
|
|
9
|
+
for (const m of (t ?? '').matchAll(FEISHU_LINK))
|
|
10
|
+
if (!out.includes(m[0]))
|
|
11
|
+
out.push(m[0]);
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
/** Read up to DOCS_MAX of them; a document that cannot be read says why, so the run can say so instead of guessing. */
|
|
15
|
+
export async function linkedDocs(texts, read) {
|
|
16
|
+
if (!read)
|
|
17
|
+
return [];
|
|
18
|
+
const links = feishuLinks(texts);
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const url of links.slice(0, DOCS_MAX)) {
|
|
21
|
+
try {
|
|
22
|
+
const d = await read(url);
|
|
23
|
+
const cut = d.text.length > DOC_TEXT_MAX;
|
|
24
|
+
out.push({ url, title: d.title, chars: d.chars, ...(cut || d.truncated ? { note: `first ${Math.min(DOC_TEXT_MAX, d.text.length).toLocaleString('en')} of ${d.chars.toLocaleString('en')} characters` } : {}), text: d.text.slice(0, DOC_TEXT_MAX) });
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
out.push({ url, error: String(e?.message ?? e).slice(0, 300) });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
for (const url of links.slice(DOCS_MAX))
|
|
31
|
+
out.push({ url, error: `not read: at most ${DOCS_MAX} documents are read for one run` });
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
@@ -7,7 +7,7 @@ import { TraceRecorder } from '../trace.js';
|
|
|
7
7
|
import { type SandboxStatus } from '../sandboxcheck.js';
|
|
8
8
|
export * from './home.js';
|
|
9
9
|
export * from './structured.js';
|
|
10
|
-
export type RunnerClient = Pick<Client, 'me' | 'inbox' | 'claim' | 'getTask' | 'postMessage' | 'complete' | 'fail' | 'usage' | 'heartbeat' | 'answerRun' | 'endRun'> & Partial<Pick<Client, 'download' | 'githubToken' | 'channelPosts' | 'mentionRun' | 'mentionEnd' | 'mentionUsage' | 'promptSize' | 'reportSetup' | 'reportRepos' | 'reportProfile' | 'reportRunner' | 'reportModels' | 'release' | 'putTrace' | 'putMentionTrace' | 'pushToken' | 'taskPr' | 'prepareRun' | 'prepared'>>;
|
|
10
|
+
export type RunnerClient = Pick<Client, 'me' | 'inbox' | 'claim' | 'getTask' | 'postMessage' | 'complete' | 'fail' | 'usage' | 'heartbeat' | 'answerRun' | 'endRun'> & Partial<Pick<Client, 'readOnly' | 'download' | 'githubToken' | 'channelPosts' | 'mentionRun' | 'mentionEnd' | 'mentionUsage' | 'promptSize' | 'reportSetup' | 'reportRepos' | 'reportProfile' | 'reportRunner' | 'reportModels' | 'release' | 'putTrace' | 'putMentionTrace' | 'pushToken' | 'taskPr' | 'prepareRun' | 'prepared' | 'readDoc'>>;
|
|
11
11
|
export interface RunnerOptions {
|
|
12
12
|
client: RunnerClient;
|
|
13
13
|
adapter: RuntimeAdapter;
|
|
@@ -327,6 +327,8 @@ export declare class Runner {
|
|
|
327
327
|
private reportPromptSize;
|
|
328
328
|
/** §16: the latest posts of the task's channel (best effort). */
|
|
329
329
|
private channelContext;
|
|
330
|
+
/** Feishu documents linked in a run's material, read through the hub for a run that cannot call `ach doc`. */
|
|
331
|
+
private linkedDocs;
|
|
330
332
|
/**
|
|
331
333
|
* §16 mention run: read-only, in --dir, with a run token that may only read
|
|
332
334
|
* the channel and reply in this thread. The hub hands each mention out once.
|
|
@@ -18,6 +18,7 @@ import { buildAgentEnv, inheritedEnv } from '../env.js';
|
|
|
18
18
|
import { unlinkWindowsSandbox } from '../codexhome.js';
|
|
19
19
|
import { effectivePerm } from '../perm.js';
|
|
20
20
|
import { ANSWER_SCHEMA, MENTION_SCHEMA, buildAnswerPrompt, buildMentionPrompt, buildPreparePrompt, buildResumePrompt, buildTaskPrompt, postUrl, refOf, REMOTE_FAILED_PREFIX, taskUrl } from '../prompts.js';
|
|
21
|
+
import { linkedDocs } from './linked-docs.js';
|
|
21
22
|
import { RunnerState } from './state.js';
|
|
22
23
|
import { ChangeFeed, wakesRunner } from '../attention.js';
|
|
23
24
|
import { isGitRepo } from './workspace.js';
|
|
@@ -296,6 +297,8 @@ export class Runner {
|
|
|
296
297
|
await this.traces.flush();
|
|
297
298
|
if (this.paused)
|
|
298
299
|
return; // heartbeats of parked runs went out in checkActive; nothing new is taken (it waits in the hub's inbox)
|
|
300
|
+
if (this.o.client.readOnly)
|
|
301
|
+
return; // the hub is read-only (a cutover): runs going on finish, nothing new is taken
|
|
299
302
|
if (await this.sandboxBlocked())
|
|
300
303
|
return; // decisions §27: same, until the sandbox works
|
|
301
304
|
if (!this.me || inbox.tasks_to_me.length) {
|
|
@@ -1066,7 +1069,10 @@ export class Runner {
|
|
|
1066
1069
|
const files = await this.fetchFiles(taskId, claim);
|
|
1067
1070
|
rec.files = files.map((f) => f.key);
|
|
1068
1071
|
this.state.put(rec);
|
|
1072
|
+
// a run without `ach` cannot read a linked Feishu document itself (docs/specs/tools.md §4)
|
|
1073
|
+
const docs = this.o.adapter.spec.ach ? [] : await this.linkedDocs([claim.handoff, ...claim.messages.map((m) => m.body)], taskId);
|
|
1069
1074
|
const prompt = buildTaskPrompt({
|
|
1075
|
+
docs,
|
|
1070
1076
|
agentName: me.name,
|
|
1071
1077
|
ownerName: me.owner_name,
|
|
1072
1078
|
lang: me.lang,
|
|
@@ -1460,6 +1466,14 @@ export class Runner {
|
|
|
1460
1466
|
return undefined;
|
|
1461
1467
|
}
|
|
1462
1468
|
}
|
|
1469
|
+
/** Feishu documents linked in a run's material, read through the hub for a run that cannot call `ach doc`. */
|
|
1470
|
+
async linkedDocs(texts, logKey) {
|
|
1471
|
+
const read = this.o.client.readDoc?.bind(this.o.client);
|
|
1472
|
+
const docs = await linkedDocs(texts, read);
|
|
1473
|
+
for (const d of docs)
|
|
1474
|
+
this.taskLog(logKey, `linked document ${d.url}: ${d.error ? `not read (${d.error})` : `${d.chars} characters`}`);
|
|
1475
|
+
return docs;
|
|
1476
|
+
}
|
|
1463
1477
|
/**
|
|
1464
1478
|
* §16 mention run: read-only, in --dir, with a run token that may only read
|
|
1465
1479
|
* the channel and reply in this thread. The hub hands each mention out once.
|
|
@@ -1496,7 +1510,9 @@ export class Runner {
|
|
|
1496
1510
|
let outcome = { ok: false, error: 'the run did not finish' };
|
|
1497
1511
|
let recorded;
|
|
1498
1512
|
try {
|
|
1513
|
+
const docs = structured ? await this.linkedDocs([run.post?.body, run.thread?.body, ...(run.replies ?? []).map((p) => p.body), run.task?.handoff, ...(run.task?.messages ?? []).map((m) => m.body)], key) : [];
|
|
1499
1514
|
const prompt = buildMentionPrompt({
|
|
1515
|
+
docs,
|
|
1500
1516
|
agentName: me.name,
|
|
1501
1517
|
ownerName: me.owner_name,
|
|
1502
1518
|
lang: me.lang,
|
|
@@ -1579,7 +1595,9 @@ export class Runner {
|
|
|
1579
1595
|
const cwd = this.state.get(taskId)?.workdir ?? this.o.dir;
|
|
1580
1596
|
const rec = { taskId, runId, phase: 'running', workdir: cwd, runToken: token, tokenAt: Date.now(), seen: [] };
|
|
1581
1597
|
const structured = !!this.structured;
|
|
1598
|
+
const docs = structured ? await this.linkedDocs([q.body, bundle.handoff, ...bundle.messages.map((m) => m.body)], taskId) : [];
|
|
1582
1599
|
const prompt = buildAnswerPrompt({
|
|
1600
|
+
docs,
|
|
1583
1601
|
agentName: me.name,
|
|
1584
1602
|
ownerName: me.owner_name,
|
|
1585
1603
|
lang: me.lang,
|
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.76.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",
|