@koalaauto/agentchannel 3.97.0 → 3.97.2

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.
@@ -1,13 +1,16 @@
1
- import { type AdapterResult, type RuntimeAdapter } from '../adapters/types.js';
2
- import { type Agent, type Client, type MentionItem, type MentionOutcome, type Message } from '../client.js';
1
+ import { type RuntimeAdapter } from '../adapters/types.js';
2
+ import { type Agent, type Client } from '../client.js';
3
3
  import { type Perm } from '../perm.js';
4
- import { RunnerState, type RunRecord } from './state.js';
4
+ import { RunnerState } from './state.js';
5
5
  import { type Workspace } from './workspace.js';
6
- import { TraceRecorder } from '../trace.js';
7
6
  import { type SandboxStatus } from '../sandboxcheck.js';
7
+ import { RunnerReports } from './reports.js';
8
+ import { type Active, type Job } from './jobs.js';
8
9
  export * from './home.js';
9
10
  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' | 'mentionHeartbeat' | 'mentionUsage' | 'promptSize' | 'ruleFile' | 'reportSetup' | 'reportRepos' | 'reportProfile' | 'reportProjectMemory' | 'yodaRemember' | 'reportRunner' | 'reportModels' | 'release' | 'putTrace' | 'putMentionTrace' | 'pushToken' | 'taskPr' | 'prepareRun' | 'prepared' | 'readDoc'>>;
11
+ export { cleanDescription, MODELS_EVERY_MS } from './reports.js';
12
+ export { approves, isHumanNoteTo, jobKey, mentionOutcome, newRunId, nothingGoing, openRequests, refusedReply, takenOver, unseenReplies, type Job } from './jobs.js';
13
+ 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' | 'mentionHeartbeat' | 'mentionUsage' | 'promptSize' | 'ruleFile' | 'reportSetup' | 'reportRepos' | 'reportProfile' | 'reportProjectMemory' | 'yodaRemember' | 'reportRunner' | 'reportModels' | 'release' | 'putTrace' | 'putMentionTrace' | 'pushToken' | 'taskPr' | 'prepareRun' | 'prepared' | 'readDoc' | 'getArtifact' | 'artifactHtml'>>;
11
14
  export interface RunnerOptions {
12
15
  client: RunnerClient;
13
16
  adapter: RuntimeAdapter;
@@ -95,68 +98,6 @@ export interface RunnerStartInfo {
95
98
  /** Linux service whose user does not linger: it stops when that user's last login ends (an SSH session). */
96
99
  linger?: boolean;
97
100
  }
98
- export type Job = {
99
- kind: 'work';
100
- taskId: string;
101
- }
102
- /** nudge: the agent stopped without finishing; ask it once to complete, fail or ask. */
103
- | {
104
- kind: 'resume';
105
- taskId: string;
106
- replies: Message[];
107
- nudge?: boolean;
108
- } | {
109
- kind: 'answer';
110
- taskId: string;
111
- question: Message;
112
- } | {
113
- kind: 'mention';
114
- item: MentionItem;
115
- }
116
- /** read a new task ahead before anyone works it (owner-pulls-tasks.md) */
117
- | {
118
- kind: 'prepare';
119
- taskId: string;
120
- };
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;
124
- /** What the hub is told about a mention run that ended: whether it worked, why not, its last words, the commands that failed. */
125
- /**
126
- * The flags of an `ach reply` that failed (refused, or the hub said no): `--escalate`, `--to`, `--ask`, `--evidence`, read from the
127
- * command's first line as a shell would split it. Undefined when it had none of them. 2026-11-19: a reply with `--escalate --to owner`
128
- * was refused, its text was posted from the last message, and the owner never saw the decision in their Inbox.
129
- */
130
- export declare function refusedReply(commands: string[]): MentionOutcome['reply'];
131
- export declare function mentionOutcome(result: AdapterResult, reason: Active['reason'], recorder?: TraceRecorder, secrets?: readonly string[]): MentionOutcome;
132
- interface Active {
133
- job: Job;
134
- controller: AbortController;
135
- /** lost: the hub says this run no longer owns the task (heartbeat 409, C3). */
136
- reason?: 'cancel' | 'idle' | 'stop' | 'lost' | 'auth';
137
- done: Promise<void>;
138
- /** Job to start right after this one frees its slot (e.g. resume on replies that arrived mid-run). */
139
- followUp?: Job;
140
- }
141
- /** A gate decision that lets the run go ahead (S1). Anything else rejects. */
142
- export declare function approves(decision: string): boolean;
143
- export declare function newRunId(): string;
144
- /**
145
- * What the worker is still waiting on: its own open questions, blocking decision
146
- * requests, and (non-blocking) decision requests that replace one of its questions.
147
- */
148
- export declare function openRequests(messages: Message[], myId: string): Message[];
149
- /** The agent's own session claimed the task from this run (claim_task takeover): the run has nothing left to do on it. */
150
- export declare const takenOver: (task: {
151
- claim_mode?: string;
152
- run_id?: string;
153
- }, runId: string) => boolean;
154
- /** A human note addressed to me (panel composer / `ach admin note`): wakes a parked run. */
155
- export declare function isHumanNoteTo(m: Message, myId: string): boolean;
156
- /** Answers / decisions replying to something I asked, and human notes to me, that the worker has not been shown yet. */
157
- export declare function unseenReplies(messages: Message[], myId: string, seen: string[]): Message[];
158
- /** How often the runner lists the runtime's models again (besides at start and after a rejected model). */
159
- export declare const MODELS_EVERY_MS: number;
160
101
  export declare class Runner {
161
102
  readonly state: RunnerState;
162
103
  readonly queue: Job[];
@@ -198,10 +139,11 @@ export declare class Runner {
198
139
  st: SandboxStatus;
199
140
  at: number;
200
141
  };
201
- private setupReported?;
202
142
  private sandboxRecheck;
203
143
  /** Execution traces the hub has not taken yet (kept on disk too), and the last trace of each task (a commit joins it). */
204
144
  private traces;
145
+ /** what this runner tells the hub about itself (reports.ts) */
146
+ readonly reports: RunnerReports;
205
147
  constructor(opts: RunnerOptions);
206
148
  private log;
207
149
  private taskLog;
@@ -218,49 +160,14 @@ export declare class Runner {
218
160
  tick(): Promise<void>;
219
161
  /** decisions §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
220
162
  private sandboxBlocked;
221
- /** Tell the hub what keeps this runner from working, when that changed: a failed check first, else an account that cannot run. */
222
- private reportSetup;
223
163
  /**
224
164
  * What a run says about the account behind the runtime: a limit or a plan that is not usable pauses new work (whatever the run
225
165
  * was for: a task, an answer, a mention), and the plan problem is the owner's to fix, so it is reported like a broken sandbox.
226
166
  * A run that works clears it.
227
167
  */
228
168
  private noteAccount;
229
- /** Tell the hub which repo names this runner knows, so a task for another repo is refused when it is sent. Tried on every
230
- * poll until the hub has it: a hub that was unreachable at start would otherwise keep the previous list until a restart. */
231
- private reposReported;
232
- private reportRepos;
233
- private reposLogged;
234
- /** An agent with no profile yet gets a first one, once: a short read-only run on a light model reads the repositories it works in
235
- * and writes a sentence or two. The hub keeps it only while the profile is empty; the weekly refresh (the system agent, from what the
236
- * agent did) rewrites it after. The description is the owner's and is never written here. Tried again at the next start when it
237
- * could not be had. */
238
- private describeDone;
239
- private describeBusy;
240
- private describeTries;
241
- private describeNextAt;
242
- private describeAgent;
243
- /** Tell the hub how this runner runs tasks (its --perm, the tool, the names it passes with --pass-env), once, so the agent's
244
- * owner sees on its page what a task sent to it can reach. Tried on every poll until the hub has it; an older hub (404) is left alone. */
245
- private runnerReported;
246
169
  /** the capabilities file problems last logged (logged again only when they change) */
247
170
  private capsProblems;
248
- /** the capabilities last told to the hub (decisions §34, §38): an edit of the file is reported again on the next poll */
249
- private capsReported;
250
- private reportRunner;
251
- /**
252
- * Tell the hub which models the runtime offers here and which one a run uses when none is picked (the agent's settings
253
- * page lists them): when the runner starts, again a day later (a login or the tool's catalog changes), and at once after
254
- * a run's model was rejected. Asked with the environment a run gets, so the list is what this agent's login can use.
255
- */
256
- private modelsAt;
257
- private modelsBusy;
258
- /** set when a run's model was rejected: the list on the hub is out of date */
259
- private modelsStale;
260
- /** an older hub without /me/models, or a runtime that cannot list: asked no more */
261
- private modelsOff;
262
- private modelsLogged;
263
- private reportModels;
264
171
  /**
265
172
  * Cancel running jobs whose task went terminal; forget parked runs of
266
173
  * terminal tasks; keep parked leases alive; and (C1) resume a parked run
@@ -331,6 +238,8 @@ export declare class Runner {
331
238
  private channelContext;
332
239
  /** Feishu documents linked in a run's material, read through the hub for a run that cannot call `ach doc`. */
333
240
  private linkedDocs;
241
+ /** Artifacts (A-12) named in a run's material, read through the hub for every run: none has a command that shows one. */
242
+ private linkedArtifacts;
334
243
  /** Tasks a thread names, read through the hub for a mention run that cannot call `ach task`. */
335
244
  private linkedTasks;
336
245
  /**
@@ -350,15 +259,6 @@ export declare class Runner {
350
259
  private get cloud();
351
260
  /** Short runs return JSON by a schema and the runner posts it: the runtime's way, and the only way without `ach` in the run. */
352
261
  private get structured();
353
- /** the project memory index last told to the hub, and when the file was last looked at */
354
- private projectMemoryReported;
355
- private projectMemoryCheckedAt;
356
- /**
357
- * Tell the hub what this agent knows about its project: the index of the owner's memory for it on this machine (one line per
358
- * note, never the notes). The owner's Yoda reads it, so it knows what each of its parts knows (primary-agent-design §11.15).
359
- * Looked at every few minutes, sent when it changed. Not for a team agent (no person) or a cloud run (no machine).
360
- */
361
- private reportProjectMemory;
362
262
  /** Owned by no one person (the system agent, or a team agent such as one that does a channel mechanism for the team). */
363
263
  private teamOwned;
364
264
  /** What a full task prompt carries besides the task: the owner's memory for this project and the project's instructions. */
@@ -400,5 +300,3 @@ export declare function gcWorktrees(client: Pick<Client, 'getTask'>, ws: Workspa
400
300
  log?: (s: string) => void;
401
301
  keepFailed?: boolean;
402
302
  }): Promise<string[]>;
403
- /** The model's text as a profile: its first paragraph, without markdown marks or wrapping quotes, at most 300 characters. */
404
- export declare function cleanDescription(raw: string): string;