@livx.cc/agentx 0.99.120 → 0.99.122
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/README.md +2 -0
- package/dist/cli.d.ts +29 -2
- package/dist/cli.js +719 -254
- package/dist/cli.js.map +1 -1
- package/dist/directives.d.ts +15 -1
- package/dist/directives.js +47 -2
- package/dist/directives.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +392 -158
- package/dist/index.js.map +1 -1
- package/dist/{secondChannel-DepBV0Zv.d.ts → secondChannel-BddfVzTp.d.ts} +109 -2
- package/package.json +1 -1
|
@@ -260,6 +260,85 @@ declare function planMode(opts?: {
|
|
|
260
260
|
/** Run several Hooks as one: preToolUse stops at the first block; post/stop all fire. */
|
|
261
261
|
declare function composeHooks(...list: (Hooks | undefined)[]): Hooks;
|
|
262
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Two-model modes (ported from Blank #258/#272) — generic, host-agnostic.
|
|
265
|
+
*
|
|
266
|
+
* DELEGATE `[planner->worker]` — the (premium) agent model PLANS, a cheaper worker model WRITES.
|
|
267
|
+
* The planner keeps every read tool plus `Task`/`TaskBatch`, but may not write: a nudge in the prompt
|
|
268
|
+
* was not enough (Opus, told to delegate, wrote the whole app itself 8 runs of 8). So the rule is
|
|
269
|
+
* enforced at EXECUTION. Workers inherit this exact toolbelt (children get the parent's tools), so the
|
|
270
|
+
* one thing that tells a planner call from a worker call is the calling agent's own model, which the
|
|
271
|
+
* Agent puts on `ToolContext.model`. That is why delegate mode refuses to start when the models are equal.
|
|
272
|
+
*
|
|
273
|
+
* ADVISOR `[worker<-advisor]` — the inverse. The cheap model drives with every tool; `Advise` makes a
|
|
274
|
+
* few short calls to the premium model that see only the request, an optional host snapshot and the
|
|
275
|
+
* question — never the system prompt or the conversation (Anthropic's advisor tool / Aider's architect).
|
|
276
|
+
* A prompt rule was not enough here either (Haiku, told to consult, wrote everything with 0 calls), so
|
|
277
|
+
* the first write waits for one consult.
|
|
278
|
+
*
|
|
279
|
+
* Both modes run the second model through the agent's shared `ai`; `meterWorkers` sums every call on
|
|
280
|
+
* a model other than the agent's own, which the Agent reports as `RunResult.workerUsage`.
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
/** Tools that change files — refused for the planner, gated for an advised worker. */
|
|
284
|
+
declare const WRITE_TOOLS: Set<string>;
|
|
285
|
+
/** The planner also loses the shells: either one can write files. */
|
|
286
|
+
declare const PLANNER_BLOCKED: Set<string>;
|
|
287
|
+
declare const PLANNER_REFUSAL = "Refused: you are the planner and do not write files. Delegate the change with Task/TaskBatch (model set to the worker) and give the worker a full spec.";
|
|
288
|
+
declare const PLAN_FIRST = "Refused: check your plan with `Advise` before the first write (files, data shape, the hard parts). Then write.";
|
|
289
|
+
/** A build may consult at most this many times by default: plan + review + one spare. */
|
|
290
|
+
declare const ADVISE_LIMIT = 3;
|
|
291
|
+
type ModeTool = {
|
|
292
|
+
name: string;
|
|
293
|
+
run: (...a: any[]) => any;
|
|
294
|
+
};
|
|
295
|
+
/** The worker model when delegate mode can run for this planner, else undefined (why: in the log). */
|
|
296
|
+
declare function delegateWorkerFor(planner: string, worker?: string | false | null): string | undefined;
|
|
297
|
+
/** The advisor model when advisor mode can run for this worker, else undefined. */
|
|
298
|
+
declare function advisorFor(worker: string, advisor?: string | false | null): string | undefined;
|
|
299
|
+
/** Refuse the planner's file-changing tools; a worker (any other `ctx.model`) runs them as usual. */
|
|
300
|
+
declare function delegateTools<T extends ModeTool>(tools: T[], planner: string): T[];
|
|
301
|
+
/** Appended to the PLANNER's system prompt only (workers inherit the host's base prompt). */
|
|
302
|
+
declare function delegatePrompt(worker: string): string;
|
|
303
|
+
/** Appended to the advised worker's system prompt. */
|
|
304
|
+
declare function advisorPrompt(advisor: string): string;
|
|
305
|
+
interface AdvisorSetup {
|
|
306
|
+
ai: ChatLike;
|
|
307
|
+
advisor: string;
|
|
308
|
+
/** The user's request as the advisor should read it (the current turn's text). */
|
|
309
|
+
request: () => string;
|
|
310
|
+
/** Host-supplied state the advisor reads NOW (mid-run): files, a diff, a summary. Capped. Default: none. */
|
|
311
|
+
snapshot?: () => string | Promise<string>;
|
|
312
|
+
limit?: number;
|
|
313
|
+
}
|
|
314
|
+
/** The `Advise` tool, plus `gate` for the file tools: the first write waits for one consult
|
|
315
|
+
* (a failed consult counts — it never blocks the work). */
|
|
316
|
+
type Advisor = {
|
|
317
|
+
tool: ModeTool & {
|
|
318
|
+
description: string;
|
|
319
|
+
parameters: Record<string, unknown>;
|
|
320
|
+
};
|
|
321
|
+
gate: <T extends ModeTool>(tools: T[]) => T[];
|
|
322
|
+
used: () => number;
|
|
323
|
+
};
|
|
324
|
+
declare function makeAdvisor(o: AdvisorSetup): Advisor;
|
|
325
|
+
type ChatUsage = {
|
|
326
|
+
promptTokens: number;
|
|
327
|
+
completionTokens: number;
|
|
328
|
+
totalTokens: number;
|
|
329
|
+
cacheCreationTokens?: number;
|
|
330
|
+
cacheReadTokens?: number;
|
|
331
|
+
};
|
|
332
|
+
/** Meter the second model's calls: every call on the shared `ai` that names a model other than `main`
|
|
333
|
+
* (workers, the advisor). Streams count their LAST usage chunk, as the agent loop does. `model()` is
|
|
334
|
+
* the provider's resolved id of the last such call (captured right after it, before `main` overwrites it). */
|
|
335
|
+
declare function meterWorkers<T extends ChatLike>(ai: T, main: string): {
|
|
336
|
+
ai: T;
|
|
337
|
+
usage: () => ChatUsage | undefined;
|
|
338
|
+
model: () => string | undefined;
|
|
339
|
+
reset: () => void;
|
|
340
|
+
};
|
|
341
|
+
|
|
263
342
|
/**
|
|
264
343
|
* Normalized reasoning/thinking control → provider-specific request fragment.
|
|
265
344
|
*
|
|
@@ -337,6 +416,10 @@ interface RunResult {
|
|
|
337
416
|
* ran it"), and on the guard's own success path that sentence is false. Whether a turn needed rescuing
|
|
338
417
|
* is a telemetry question, and the `log.warn` at the nudge already answers it. */
|
|
339
418
|
fabricatedToolClaims?: string[];
|
|
419
|
+
/** Delegate/advisor mode: the second model (provider-resolved id when known) and the summed usage of its
|
|
420
|
+
* calls this run — NOT included in `usage`, which is the agent's own model. */
|
|
421
|
+
workerModel?: string;
|
|
422
|
+
workerUsage?: ChatUsage;
|
|
340
423
|
error?: unknown;
|
|
341
424
|
}
|
|
342
425
|
/** What a manual `/compact` actually freed (token estimates, ~4 chars/token). */
|
|
@@ -468,6 +551,19 @@ declare class AgentOptions {
|
|
|
468
551
|
hooks?: Hooks;
|
|
469
552
|
/** If true: add the `Task` tool so the agent can spawn depth-limited child agents over the VFS. */
|
|
470
553
|
subagents: boolean;
|
|
554
|
+
/** DELEGATE MODE: `model` plans, `worker` writes. The planner's Write/Edit/MultiEdit/ApplyEdits/bash/Shell are
|
|
555
|
+
* refused at execution; Task/TaskBatch are on (maxDepth 1, children default to `worker`) and children get the
|
|
556
|
+
* parent's `postToolUse` too. Off when the models are equal or either is cursor/*. Wins over `advisor`. */
|
|
557
|
+
delegate?: {
|
|
558
|
+
worker: string;
|
|
559
|
+
};
|
|
560
|
+
/** ADVISOR MODE: `model` does the work; an `Advise` tool asks `advisor.model` (≤`limit`, default 3) with only
|
|
561
|
+
* the request + `snapshot()` (host state, optional) + the question. The first write waits for one consult. */
|
|
562
|
+
advisor?: {
|
|
563
|
+
model: string;
|
|
564
|
+
limit?: number;
|
|
565
|
+
snapshot?: () => string | Promise<string>;
|
|
566
|
+
};
|
|
471
567
|
/** VFS dir of typed-subagent defs (`<dir>/<name>.md`). If set with `subagents`: inject a catalog + enable the `Task` `agentType` param. */
|
|
472
568
|
agentsDir?: string;
|
|
473
569
|
/** Current recursion depth (0 = top-level); spawned children run at depth+1. */
|
|
@@ -566,6 +662,9 @@ declare class Agent {
|
|
|
566
662
|
private ctx;
|
|
567
663
|
private lastTrimNotified;
|
|
568
664
|
private activeTools;
|
|
665
|
+
private meter?;
|
|
666
|
+
private modeModel?;
|
|
667
|
+
private lastTask;
|
|
569
668
|
/** claude-code bridge for agentx-only tools (ccBridge.ts) + the current step's executor it calls. */
|
|
570
669
|
private ccServer?;
|
|
571
670
|
private ccExec?;
|
|
@@ -687,6 +786,7 @@ declare class Agent {
|
|
|
687
786
|
/** Drop inline base64 images from older messages so Bun/JSC can reclaim the heap (see contentBytes). */
|
|
688
787
|
releaseStaleImages(keepRecent?: number): void;
|
|
689
788
|
private runLoop;
|
|
789
|
+
private loop;
|
|
690
790
|
/**
|
|
691
791
|
* Drain a streamed chat() response: emit each text delta to the host
|
|
692
792
|
* (`{kind:'text_delta'}`) and fold all chunks back into the single
|
|
@@ -960,6 +1060,9 @@ declare class SecondChannelOptions {
|
|
|
960
1060
|
/** Duplex v3 (§3 first sound): a bridge skips the decider (the veto stays for backchannels/fillers) and speaks a
|
|
961
1061
|
* canned line at once; a generated one is started at dispatch and used only if it already landed. */
|
|
962
1062
|
instantBridge: boolean;
|
|
1063
|
+
/** Duplex v3 §3 late bridge: a turn that expects an answer (not a closer) and got no bridge yet gets one canned bridge
|
|
1064
|
+
* this long after the user's last word if channel-1 is still silent — the short turns the 0ms rule skips ("Hi"). 0 = off. */
|
|
1065
|
+
lateBridgeMs: number;
|
|
963
1066
|
/** No new interim for this long → a pause (hosts may also call onPause). */
|
|
964
1067
|
fillerPauseMs: number;
|
|
965
1068
|
fillerMinWords: number;
|
|
@@ -994,6 +1097,9 @@ declare class SecondChannel {
|
|
|
994
1097
|
private pauseTimer;
|
|
995
1098
|
private bcTimer;
|
|
996
1099
|
private bridgeTimer;
|
|
1100
|
+
private lateTimer;
|
|
1101
|
+
private late;
|
|
1102
|
+
private lastWordAgo;
|
|
997
1103
|
private lastAt;
|
|
998
1104
|
private lastKind;
|
|
999
1105
|
private live;
|
|
@@ -1038,7 +1144,7 @@ declare class SecondChannel {
|
|
|
1038
1144
|
/** Channel-1 lifecycle. `queued` = the user's turn was dispatched to the main agent. */
|
|
1039
1145
|
onAgentState(s: MainState): void;
|
|
1040
1146
|
/** The user's final line was dispatched to the main agent (its words are the bridge's micro-context). */
|
|
1041
|
-
onUserTurn(text: string): void;
|
|
1147
|
+
onUserTurn(text: string, lastWordAgoMs?: number): void;
|
|
1042
1148
|
/** The main answer's streamed text (before its audio): channel-1 is responding — no bridge from here on. */
|
|
1043
1149
|
onMainTokens(text: string): void;
|
|
1044
1150
|
/** Channel-1's reply text (a delta) — only the plan's context; no state change (hosts without onMainTokens). */
|
|
@@ -1061,6 +1167,7 @@ declare class SecondChannel {
|
|
|
1061
1167
|
blocked(k: LineKind): string;
|
|
1062
1168
|
/** Why this turn gets no bridge by rule ('' = it may) — language, a quick/phatic turn, or blocked(). */
|
|
1063
1169
|
bridgeBlock(): string;
|
|
1170
|
+
private shortTurn;
|
|
1064
1171
|
private bcTimes;
|
|
1065
1172
|
private capped;
|
|
1066
1173
|
/** 0ms rule: the candidate line for this trigger, or silence. */
|
|
@@ -1082,4 +1189,4 @@ declare class SecondChannel {
|
|
|
1082
1189
|
private say;
|
|
1083
1190
|
}
|
|
1084
1191
|
|
|
1085
|
-
export {
|
|
1192
|
+
export { ADVISE_LIMIT as A, advisorPrompt as B, type ChannelMode as C, DEFAULT_MUTATING as D, claudeCodeDisallowedTools as E, composeHooks as F, type Gender as G, type Hooks as H, delegatePrompt as I, delegateTools as J, delegateWorkerFor as K, type LineKind as L, ModelRouter as M, estimateTokens as N, jevAvailable as O, PLANNER_BLOCKED as P, jevClassifier as Q, type ReasoningEffort as R, SecondChannel as S, type Tier as T, makeAdvisor as U, meterWorkers as V, WRITE_TOOLS as W, pickTier as X, planMode as Y, reasoningToChatFragment as Z, type AdvisorSetup as a, Agent as b, AgentOptions as c, type ChatFragment as d, type ChatUsage as e, type Classification as f, type Classifier as g, type CompactResult as h, type Decider as i, type Decision as j, ModelRouterOptions as k, PLANNER_REFUSAL as l, PLAN_FIRST as m, PermissionOptions as n, PermissionPolicy as o, type PermissionRule as p, type PreToolUseDecision as q, RecordingHooks as r, RecordingLifecycle as s, type RouteDecision as t, type RouterState as u, type RunResult as v, SecondChannelOptions as w, type ToolUse as x, type ToolUseMeta as y, advisorFor as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livx.cc/agentx",
|
|
3
|
-
"version": "0.99.
|
|
3
|
+
"version": "0.99.122",
|
|
4
4
|
"description": "Edge-native AI agent runtime — drives a virtual filesystem via any LLM (ai.libx.js). Same bytes run in node, browser, or edge.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|