@koalaauto/agentchannel 3.86.0 → 3.87.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/attention.d.ts +8 -1
- package/dist/src/attention.js +19 -3
- package/dist/src/client.d.ts +9 -0
- package/dist/src/client.js +5 -0
- package/dist/src/ids.d.ts +1 -1
- package/dist/src/ids.js +1 -1
- package/dist/src/mcp.js +3 -1
- package/dist/src/prompts.d.ts +0 -5
- package/dist/src/prompts.js +10 -2
- package/dist/src/runner/runner.d.ts +10 -2
- package/dist/src/runner/runner.js +50 -7
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/attention.d.ts
CHANGED
|
@@ -76,6 +76,12 @@ export interface ChangeFeedOptions {
|
|
|
76
76
|
wsCheckMs?: number;
|
|
77
77
|
/** Polling interval, when there is no socket. */
|
|
78
78
|
pollMs?: number;
|
|
79
|
+
/**
|
|
80
|
+
* After an event, wait a random moment up to this long before acting (events in that moment share the one act). For consumers
|
|
81
|
+
* many of which hear the same event: a person's sessions all hear what is addressed to that person, and asked the hub in the
|
|
82
|
+
* same instant. Absent: at once.
|
|
83
|
+
*/
|
|
84
|
+
spreadMs?: number;
|
|
79
85
|
/** In polling mode, try the socket again after this many polls (a hub that was down at start). */
|
|
80
86
|
wsRetryPolls?: number;
|
|
81
87
|
sleep?: (ms: number) => Promise<void>;
|
|
@@ -122,7 +128,8 @@ export declare function codexThreadId(env: NodeJS.ProcessEnv): string | undefine
|
|
|
122
128
|
export declare function codexQueue(text: string, env: NodeJS.ProcessEnv, exec?: Exec): Promise<boolean>;
|
|
123
129
|
/**
|
|
124
130
|
* Does this event mean a runner should look at its agent's inbox now? A task event that names the two agents it is between
|
|
125
|
-
* concerns only them; a post or a reply
|
|
131
|
+
* concerns only them; a post or a reply says which agents it is for (`agents`: the ones it mentions, its task's worker), and one
|
|
132
|
+
* from an older hub, which does not say, may mention anyone; what is addressed to a person (`notification`) or is about the
|
|
126
133
|
* channel list is not a runner's. An event that does not say (an older hub, a kind this release does not know) counts: asking
|
|
127
134
|
* once too often is harmless, missing work is not. `me` unknown yet: every event counts.
|
|
128
135
|
*/
|
package/dist/src/attention.js
CHANGED
|
@@ -299,6 +299,7 @@ export class ChangeFeed {
|
|
|
299
299
|
check = setInterval(() => void this.fire(), this.o.wsCheckMs ?? 5 * 60_000);
|
|
300
300
|
check.unref?.();
|
|
301
301
|
});
|
|
302
|
+
let spreading;
|
|
302
303
|
sock.addEventListener('message', (m) => {
|
|
303
304
|
if (done || this.stopped)
|
|
304
305
|
return;
|
|
@@ -313,7 +314,17 @@ export class ChangeFeed {
|
|
|
313
314
|
if (ev && typeof ev === 'object' && !this.o.relevant(ev))
|
|
314
315
|
return;
|
|
315
316
|
}
|
|
316
|
-
|
|
317
|
+
const spread = this.o.spreadMs ?? 0;
|
|
318
|
+
if (spread <= 0)
|
|
319
|
+
return void this.fire();
|
|
320
|
+
if (spreading)
|
|
321
|
+
return;
|
|
322
|
+
spreading = setTimeout(() => {
|
|
323
|
+
spreading = undefined;
|
|
324
|
+
if (!done && !this.stopped)
|
|
325
|
+
void this.fire();
|
|
326
|
+
}, Math.random() * spread);
|
|
327
|
+
spreading.unref?.();
|
|
317
328
|
});
|
|
318
329
|
sock.addEventListener('close', finish);
|
|
319
330
|
sock.addEventListener('error', () => {
|
|
@@ -394,14 +405,19 @@ export async function codexQueue(text, env, exec = defaultExec) {
|
|
|
394
405
|
}
|
|
395
406
|
/**
|
|
396
407
|
* Does this event mean a runner should look at its agent's inbox now? A task event that names the two agents it is between
|
|
397
|
-
* concerns only them; a post or a reply
|
|
408
|
+
* concerns only them; a post or a reply says which agents it is for (`agents`: the ones it mentions, its task's worker), and one
|
|
409
|
+
* from an older hub, which does not say, may mention anyone; what is addressed to a person (`notification`) or is about the
|
|
398
410
|
* channel list is not a runner's. An event that does not say (an older hub, a kind this release does not know) counts: asking
|
|
399
411
|
* once too often is harmless, missing work is not. `me` unknown yet: every event counts.
|
|
400
412
|
*/
|
|
401
413
|
export function wakesRunner(ev, me) {
|
|
402
414
|
if (ev.kind === 'notification' || ev.kind === 'channels')
|
|
403
415
|
return false;
|
|
404
|
-
if (
|
|
416
|
+
if (!me)
|
|
417
|
+
return true;
|
|
418
|
+
if ((ev.kind === 'post' || ev.kind === 'reply') && Array.isArray(ev.agents))
|
|
419
|
+
return ev.agents.includes(me);
|
|
420
|
+
if (ev.kind !== 'task')
|
|
405
421
|
return true;
|
|
406
422
|
if (typeof ev.to !== 'string' && typeof ev.from !== 'string')
|
|
407
423
|
return true;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -194,6 +194,13 @@ export interface ConventionsLayer {
|
|
|
194
194
|
/** The agent's own rules, kept on the hub with their versions (docs/specs/agent-definition.md); version 0 and '' when it has none. */
|
|
195
195
|
export interface RulesLayer extends ConventionsLayer {
|
|
196
196
|
version: number;
|
|
197
|
+
/** its reference files (an older hub leaves them out) */
|
|
198
|
+
files?: {
|
|
199
|
+
name: string;
|
|
200
|
+
size: number;
|
|
201
|
+
}[];
|
|
202
|
+
/** set by the runner: where this machine keeps that version's files for its runs to read */
|
|
203
|
+
dir?: string;
|
|
197
204
|
}
|
|
198
205
|
export interface Judgment {
|
|
199
206
|
team?: ConventionsLayer;
|
|
@@ -578,6 +585,8 @@ export declare class Client {
|
|
|
578
585
|
/** All attachments on a task (handoff versions and messages), with hub download URLs. */
|
|
579
586
|
taskFiles(taskId: string): Promise<TaskFile[]>;
|
|
580
587
|
/** Download one attachment into `dir`; returns the local path. */
|
|
588
|
+
/** One reference file of an agent's rules (docs/specs/agent-definition.md), of that version. */
|
|
589
|
+
ruleFile(agent: string, file: string, version: number): Promise<string>;
|
|
581
590
|
download(a: Attachment, dir: string): Promise<string>;
|
|
582
591
|
/** Publish an artifact (one checked local .html file) or, with `artifact`, a new version of it. */
|
|
583
592
|
publishArtifact(file: string, o: {
|
package/dist/src/client.js
CHANGED
|
@@ -343,6 +343,11 @@ export class Client {
|
|
|
343
343
|
return taskFiles(await this.getTask(taskId));
|
|
344
344
|
}
|
|
345
345
|
/** Download one attachment into `dir`; returns the local path. */
|
|
346
|
+
/** One reference file of an agent's rules (docs/specs/agent-definition.md), of that version. */
|
|
347
|
+
async ruleFile(agent, file, version) {
|
|
348
|
+
const r = await this.ach('GET', `/agents/${encodeURIComponent(agent)}/rules/files/${encodeURIComponent(file)}?version=${version}`);
|
|
349
|
+
return String(r?.text ?? '');
|
|
350
|
+
}
|
|
346
351
|
async download(a, dir) {
|
|
347
352
|
const h = this.headers(false);
|
|
348
353
|
delete h.accept;
|
package/dist/src/ids.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare const KIND: {
|
|
|
50
50
|
readonly wiki_versions: "X";
|
|
51
51
|
};
|
|
52
52
|
/** Tables without an `id` column of their own (keyed by the ids of other rows). */
|
|
53
|
-
export declare const NO_ID_TABLES: readonly ["ach_fts", "artifact_refs", "artifact_versions", "agent_rule_versions", "name_changes", "push_recalls", "rate_hits", "text_refs", "todos"];
|
|
53
|
+
export declare const NO_ID_TABLES: readonly ["ach_fts", "artifact_refs", "artifact_versions", "mechanism_versions", "agent_rule_files", "agent_rule_versions", "name_changes", "push_recalls", "rate_hits", "text_refs", "todos"];
|
|
54
54
|
export type IdTable = keyof typeof KIND;
|
|
55
55
|
export type IdKind = (typeof KIND)[IdTable];
|
|
56
56
|
/** Which format newId makes and normalizeId returns: 'legacy' before the cutover migrated the data (2026-11-24), 'kind' since. */
|
package/dist/src/ids.js
CHANGED
|
@@ -58,7 +58,7 @@ export const KIND = {
|
|
|
58
58
|
wiki_versions: 'X',
|
|
59
59
|
};
|
|
60
60
|
/** Tables without an `id` column of their own (keyed by the ids of other rows). */
|
|
61
|
-
export const NO_ID_TABLES = ['ach_fts', 'artifact_refs', 'artifact_versions', 'agent_rule_versions', 'name_changes', 'push_recalls', 'rate_hits', 'text_refs', 'todos'];
|
|
61
|
+
export const NO_ID_TABLES = ['ach_fts', 'artifact_refs', 'artifact_versions', 'mechanism_versions', 'agent_rule_files', 'agent_rule_versions', 'name_changes', 'push_recalls', 'rate_hits', 'text_refs', 'todos'];
|
|
62
62
|
/** Which format newId makes and normalizeId returns: 'legacy' before the cutover migrated the data (2026-11-24), 'kind' since. */
|
|
63
63
|
export const ID_FORMAT = 'kind';
|
|
64
64
|
const LETTERS = 'PMTHUGCDFKRSIX';
|
package/dist/src/mcp.js
CHANGED
|
@@ -648,7 +648,9 @@ export function startSessionNotices(server, client, o = {}) {
|
|
|
648
648
|
log: o.log,
|
|
649
649
|
});
|
|
650
650
|
// (only what is addressed to this person: counting again for every event of the team made this the hub's most asked question)
|
|
651
|
-
|
|
651
|
+
// (and not in the same instant as the person's other sessions: 2026-11-24, six of them counted together two seconds after one
|
|
652
|
+
// reply, and D1 refused them all as overloaded)
|
|
653
|
+
const feed = new ChangeFeed({ socket: () => client.eventsSocket(), onChange: () => notifier.check(), relevant: wakesAttention, spreadMs: 3000, log: o.log, ...o.feed });
|
|
652
654
|
const done = feed.run();
|
|
653
655
|
// a session cannot be restarted from outside: when the hub names a newer ach, say so once (see selfupdate.ts)
|
|
654
656
|
const stale = startStaleNotice({
|
package/dist/src/prompts.d.ts
CHANGED
|
@@ -64,11 +64,6 @@ export declare function linkedDocsText(docs?: LinkedDoc[]): string[];
|
|
|
64
64
|
export declare function linkedTasksText(tasks?: LinkedTask[]): string[];
|
|
65
65
|
/** Trusted: the language the people on this hub read; the instructions around it stay English. Nothing for a hub that sends none. */
|
|
66
66
|
export declare function langText(lang?: 'en' | 'zh'): string[];
|
|
67
|
-
/**
|
|
68
|
-
* Trusted: the team's conventions (admins; they only tighten the default), the owner's own (for all their agents), then the
|
|
69
|
-
* agent's own rules (written by whoever looks after it; the hub keeps them, with versions), in that order, each with who wrote it.
|
|
70
|
-
* The repository's instructions follow (projectText).
|
|
71
|
-
*/
|
|
72
67
|
export declare function conventionsText(j?: Judgment, ownerName?: string): string[];
|
|
73
68
|
/**
|
|
74
69
|
* How an agent decides between doing it, asking another agent and asking a person (docs/specs/agent-autonomy.md). The same for
|
package/dist/src/prompts.js
CHANGED
|
@@ -31,14 +31,22 @@ export function langText(lang) {
|
|
|
31
31
|
* agent's own rules (written by whoever looks after it; the hub keeps them, with versions), in that order, each with who wrote it.
|
|
32
32
|
* The repository's instructions follow (projectText).
|
|
33
33
|
*/
|
|
34
|
+
/** The reference files of the rules: where to read each here, or (a cloud run, a failed fetch) that they are not in this run. */
|
|
35
|
+
function ruleFilesText(r) {
|
|
36
|
+
if (!r.files?.length)
|
|
37
|
+
return [];
|
|
38
|
+
if (!r.dir)
|
|
39
|
+
return [`Your reference files (${r.files.map((f) => f.name).join(', ')}) are not available in this run; say so if you need one.`];
|
|
40
|
+
return [`Your reference files (read the one your rules point to when you need it; read-only, kept in step with the rules):`, ...r.files.map((f) => `- ${r.dir}/${f.name} (${f.size} characters)`)];
|
|
41
|
+
}
|
|
34
42
|
export function conventionsText(j, ownerName) {
|
|
35
43
|
const out = [];
|
|
36
44
|
if (j?.team?.text)
|
|
37
45
|
out.push(`Team conventions (set by ${j.team.by_name || 'an admin'}; every agent follows them; they only tighten the list above):`, j.team.text, '');
|
|
38
46
|
if (j?.owner?.text)
|
|
39
47
|
out.push(`${j.owner.by_name || ownerName || 'Your owner'}'s conventions (for all their agents; within the team's conventions they may tighten or loosen the list above, never the system's limits):`, j.owner.text, '');
|
|
40
|
-
if (j?.rules?.text)
|
|
41
|
-
out.push(`Your rules (how you work; version ${j.rules.version}, saved by ${j.rules.by_name || 'an admin'}${j.rules.at ? ` on ${j.rules.at.slice(0, 10)}` : ''}; kept on the hub for the whole team to read; they never loosen the team's conventions or the system's limits):`, j.rules.text, '');
|
|
48
|
+
if (j?.rules?.text || j?.rules?.files?.length)
|
|
49
|
+
out.push(`Your rules (how you work; version ${j.rules.version}, saved by ${j.rules.by_name || 'an admin'}${j.rules.at ? ` on ${j.rules.at.slice(0, 10)}` : ''}; kept on the hub for the whole team to read; they never loosen the team's conventions or the system's limits):`, ...(j.rules.text ? [j.rules.text] : []), ...ruleFilesText(j.rules), '');
|
|
42
50
|
return out;
|
|
43
51
|
}
|
|
44
52
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type AdapterResult, type RuntimeAdapter } from '../adapters/types.js';
|
|
2
2
|
import { type Agent, type Client, type MentionItem, type MentionOutcome, type Message } from '../client.js';
|
|
3
3
|
import { type Perm } from '../perm.js';
|
|
4
|
-
import { RunnerState } from './state.js';
|
|
4
|
+
import { RunnerState, type RunRecord } from './state.js';
|
|
5
5
|
import { type Workspace } from './workspace.js';
|
|
6
6
|
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, 'readOnly' | 'download' | 'githubToken' | 'channelPosts' | 'mentionRun' | 'mentionEnd' | 'mentionUsage' | 'promptSize' | 'reportSetup' | 'reportRepos' | 'reportProfile' | 'reportRunner' | 'reportModels' | 'release' | 'putTrace' | 'putMentionTrace' | 'pushToken' | 'taskPr' | 'prepareRun' | 'prepared' | 'readDoc'>>;
|
|
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' | 'ruleFile' | '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;
|
|
@@ -119,6 +119,8 @@ export type Job = {
|
|
|
119
119
|
taskId: string;
|
|
120
120
|
};
|
|
121
121
|
export declare function jobKey(j: Job): string;
|
|
122
|
+
/** Is no run going or queued? Parked runs do not count: they wait for an event, they do not need the hub asked every few seconds. */
|
|
123
|
+
export declare const nothingGoing: (active: number, queued: number, runs: Pick<RunRecord, "phase">[]) => boolean;
|
|
122
124
|
/** What the hub is told about a mention run that ended: whether it worked, why not, its last words, the commands that failed. */
|
|
123
125
|
/**
|
|
124
126
|
* The flags of an `ach reply` that failed (refused, or the hub said no): `--escalate`, `--to`, `--ask`, `--evidence`, read from the
|
|
@@ -354,6 +356,12 @@ export declare class Runner {
|
|
|
354
356
|
private teamOwned;
|
|
355
357
|
/** What a full task prompt carries besides the task: the owner's memory for this project and the project's instructions. */
|
|
356
358
|
private runContext;
|
|
359
|
+
/**
|
|
360
|
+
* The judgment with the agent's reference files on this machine: each version's files are fetched once into
|
|
361
|
+
* <home>/rules/v<N>/ (readable by every run, not a secret), and older versions are removed. A cloud run reads nothing of this
|
|
362
|
+
* machine, so it gets the names only; a failed fetch leaves the dir out and the prompt says the files are not here.
|
|
363
|
+
*/
|
|
364
|
+
private withRuleFiles;
|
|
357
365
|
/** Where a task's attachments are downloaded for its agents (readable, outside the worktree). */
|
|
358
366
|
filesDir(taskId: string): string;
|
|
359
367
|
/** The task's attachments, downloaded into filesDir (best effort: a failed download is listed without a path). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
@@ -51,6 +51,8 @@ export function jobKey(j) {
|
|
|
51
51
|
}
|
|
52
52
|
/** How many post ids a thread's session remembers having been shown (the newest; an older one shown again costs a few lines). */
|
|
53
53
|
const THREAD_SEEN_MAX = 400;
|
|
54
|
+
/** Is no run going or queued? Parked runs do not count: they wait for an event, they do not need the hub asked every few seconds. */
|
|
55
|
+
export const nothingGoing = (active, queued, runs) => active === 0 && queued === 0 && runs.every((r) => r.phase === 'parked');
|
|
54
56
|
/** The thread a mention job answers in ('' for any other job). */
|
|
55
57
|
const threadOf = (j) => (j.kind === 'mention' ? String(j.item.mention.thread || j.item.thread?.id || '') : '');
|
|
56
58
|
/** What the hub is told about a mention run that ended: whether it worked, why not, its last words, the commands that failed. */
|
|
@@ -1102,7 +1104,7 @@ export class Runner {
|
|
|
1102
1104
|
files: files.map(promptFile),
|
|
1103
1105
|
channel: await this.channelContext(claim.task),
|
|
1104
1106
|
wiki: claim.wiki,
|
|
1105
|
-
judgment: claim.judgment,
|
|
1107
|
+
judgment: await this.withRuleFiles(claim.judgment),
|
|
1106
1108
|
remote: !!this.cloud,
|
|
1107
1109
|
report: !this.o.adapter.spec.ach,
|
|
1108
1110
|
achTool: this.o.adapter.spec.achBy === 'tool',
|
|
@@ -1207,7 +1209,7 @@ export class Runner {
|
|
|
1207
1209
|
files: files.map(promptFile),
|
|
1208
1210
|
channel: await this.channelContext(bundle.task),
|
|
1209
1211
|
wiki: bundle.wiki,
|
|
1210
|
-
judgment: bundle.judgment,
|
|
1212
|
+
judgment: await this.withRuleFiles(bundle.judgment),
|
|
1211
1213
|
remote: !!this.cloud,
|
|
1212
1214
|
report: !this.o.adapter.spec.ach,
|
|
1213
1215
|
achTool: this.o.adapter.spec.achBy === 'tool',
|
|
@@ -1543,6 +1545,7 @@ export class Runner {
|
|
|
1543
1545
|
const material = [run.post?.body, run.thread?.body, ...(run.replies ?? []).map((p) => p.body), run.task?.handoff, ...(run.task?.messages ?? []).map((m) => m.body)];
|
|
1544
1546
|
const docs = structured ? await this.linkedDocs(material, key) : [];
|
|
1545
1547
|
const tasks = structured ? await this.linkedTasks([run.post?.body, run.thread?.body, ...(run.replies ?? []).map((p) => p.body)], key, run.task?.ref) : [];
|
|
1548
|
+
const judgment = await this.withRuleFiles(run.judgment);
|
|
1546
1549
|
const promptFor = (since) => buildMentionPrompt({
|
|
1547
1550
|
...(since ? { since } : {}),
|
|
1548
1551
|
docs,
|
|
@@ -1557,7 +1560,7 @@ export class Runner {
|
|
|
1557
1560
|
replies: run.replies ?? [],
|
|
1558
1561
|
recent: run.recent ?? [],
|
|
1559
1562
|
task: run.task,
|
|
1560
|
-
judgment
|
|
1563
|
+
judgment,
|
|
1561
1564
|
threadUrl: !this.o.publicUrl && typeof run.thread.url === 'string' && /^https?:\/\//.test(run.thread.url) ? run.thread.url : postUrl(this.base(), threadId),
|
|
1562
1565
|
structured,
|
|
1563
1566
|
});
|
|
@@ -1693,6 +1696,8 @@ export class Runner {
|
|
|
1693
1696
|
...[developerDir()].filter((d) => !!d),
|
|
1694
1697
|
...gitCommonDir(cwd),
|
|
1695
1698
|
join(this.o.home, 'bin'),
|
|
1699
|
+
// the reference files of the agent's rules, as the hub keeps them (withRuleFiles)
|
|
1700
|
+
join(this.o.home, 'rules'),
|
|
1696
1701
|
...readRepos.flatMap((r) => r.roots),
|
|
1697
1702
|
...(taskId ? [this.filesDir(taskId)] : []),
|
|
1698
1703
|
// the owner's Claude Code memory for this project, read-only (docs/specs/agent-autonomy.md); a team agent has no owner
|
|
@@ -1722,6 +1727,41 @@ export class Runner {
|
|
|
1722
1727
|
const ownerMemory = dir ? { dir, ...(this.o.adapter.spec.ownerMemory === 'native' ? {} : { index: memoryIndex(dir) }) } : undefined;
|
|
1723
1728
|
return { ownerMemory, project: projectInstructions(workdir, this.o.adapter.spec.ownFiles) };
|
|
1724
1729
|
}
|
|
1730
|
+
/**
|
|
1731
|
+
* The judgment with the agent's reference files on this machine: each version's files are fetched once into
|
|
1732
|
+
* <home>/rules/v<N>/ (readable by every run, not a secret), and older versions are removed. A cloud run reads nothing of this
|
|
1733
|
+
* machine, so it gets the names only; a failed fetch leaves the dir out and the prompt says the files are not here.
|
|
1734
|
+
*/
|
|
1735
|
+
async withRuleFiles(j) {
|
|
1736
|
+
const r = j?.rules;
|
|
1737
|
+
if (!r?.files?.length || !r.version || this.cloud || !this.o.client.ruleFile || !this.me?.name)
|
|
1738
|
+
return j;
|
|
1739
|
+
const root = join(this.o.home, 'rules');
|
|
1740
|
+
const dir = join(root, `v${r.version}`);
|
|
1741
|
+
try {
|
|
1742
|
+
if (!existsSync(join(dir, '.complete'))) {
|
|
1743
|
+
const tmp = `${dir}.tmp-${process.pid}`;
|
|
1744
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
1745
|
+
mkdirSync(tmp, { recursive: true, mode: 0o755 });
|
|
1746
|
+
for (const f of r.files) {
|
|
1747
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(f.name))
|
|
1748
|
+
continue;
|
|
1749
|
+
writeFileSync(join(tmp, f.name), await this.o.client.ruleFile(this.me.name, f.name, r.version), { mode: 0o644 });
|
|
1750
|
+
}
|
|
1751
|
+
writeFileSync(join(tmp, '.complete'), '');
|
|
1752
|
+
rmSync(dir, { recursive: true, force: true });
|
|
1753
|
+
renameSync(tmp, dir);
|
|
1754
|
+
}
|
|
1755
|
+
for (const old of readdirSync(root))
|
|
1756
|
+
if (old !== `v${r.version}`)
|
|
1757
|
+
rmSync(join(root, old), { recursive: true, force: true });
|
|
1758
|
+
return { ...j, rules: { ...r, dir } };
|
|
1759
|
+
}
|
|
1760
|
+
catch (e) {
|
|
1761
|
+
this.log(`reference files of rules v${r.version}: ${e?.message ?? e}`);
|
|
1762
|
+
return j;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1725
1765
|
/** Where a task's attachments are downloaded for its agents (readable, outside the worktree). */
|
|
1726
1766
|
filesDir(taskId) {
|
|
1727
1767
|
return join(this.o.home, 'files', taskId.replace(/[^A-Za-z0-9_-]/g, '_'));
|
|
@@ -2057,9 +2097,12 @@ export class Runner {
|
|
|
2057
2097
|
}
|
|
2058
2098
|
if (this.stopped)
|
|
2059
2099
|
break;
|
|
2060
|
-
// nothing
|
|
2061
|
-
// and the runner asks anyway every quietMs. With a run going
|
|
2062
|
-
|
|
2100
|
+
// nothing going and the stream is up: the hub says when there is something (asked at once, a second apart at most),
|
|
2101
|
+
// and the runner asks anyway every quietMs. With a run going or queued, or without the stream: as ever. A parked run
|
|
2102
|
+
// (waiting for an answer or a decision, often for days) is not a run going: its answer arrives as a task event that names
|
|
2103
|
+
// this agent, and its lease lasts far longer than quietMs. 2026-11-24: three runners with a parked run each asked every
|
|
2104
|
+
// 3 s around the clock, most of the hub's inbox reads.
|
|
2105
|
+
const idle = nothingGoing(this.active.size, this.queue.length, Object.values(this.state.runs.runs));
|
|
2063
2106
|
if (this.feed?.mode === 'ws' && idle && wait === this.o.intervalMs)
|
|
2064
2107
|
wait = this.nudged ? Math.min(1000, wait) : (this.o.quietMs ?? 20_000);
|
|
2065
2108
|
this.nudged = false;
|
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.87.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",
|