@livx.cc/agentx 0.99.122 → 0.99.123
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 +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +42 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +36 -9
- package/dist/index.js.map +1 -1
- package/dist/{mcp-CUo-9LUe.d.ts → mcp-DZhcLur2.d.ts} +1 -1
- package/dist/mcp.client.d.ts +2 -2
- package/dist/{secondChannel-BddfVzTp.d.ts → secondChannel-DES_VIeN.d.ts} +25 -2
- package/dist/{tools-DZHZIyxh.d.ts → tools-DwfeF8VQ.d.ts} +3 -0
- package/dist/tools.shell.d.ts +1 -1
- package/dist/tools.shell.js +1 -0
- package/dist/tools.shell.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { c as AgentOptions, H as Hooks,
|
|
2
|
-
export { A as ADVISE_LIMIT, a as AdvisorSetup,
|
|
1
|
+
import { c as AgentOptions, H as Hooks, w as RunResult, j as Decider, b as Agent, p as PermissionPolicy, G as Gender, L as LineKind, d as ChannelMode, x as SecondChannelOptions, S as SecondChannel } from './secondChannel-DES_VIeN.js';
|
|
2
|
+
export { A as ADVISE_LIMIT, a as AdvisorSetup, C as CC_WRITE_TOOLS, e as ChatFragment, f as ChatUsage, g as Classification, h as Classifier, i as CompactResult, D as DEFAULT_MUTATING, k as Decision, M as ModelRouter, l as ModelRouterOptions, P as PLANNER_BLOCKED, m as PLANNER_REFUSAL, n as PLAN_FIRST, o as PermissionOptions, q as PermissionRule, r as PreToolUseDecision, R as ReasoningEffort, s as RecordingHooks, t as RecordingLifecycle, u as RouteDecision, v as RouterState, T as Tier, y as ToolUse, z as ToolUseMeta, W as WRITE_TOOLS, B as advisorFor, E as advisorPrompt, F as ccModeOptions, I as claudeCodeDisallowedTools, J as composeHooks, K as delegatePrompt, N as delegateTools, O as delegateWorkerFor, Q as estimateTokens, U as jevAvailable, V as jevClassifier, X as makeAdvisor, Y as meterWorkers, Z as pickTier, _ as planMode, $ as plannerBlocks, a0 as reasoningToChatFragment } from './secondChannel-DES_VIeN.js';
|
|
3
3
|
export { MODEL_ALIASES, ModelSwitch, ResolveModelSwitchOpts, latestClaude, modelShortLabel, resolveModelAlias, resolveModelSwitch } from './models.js';
|
|
4
4
|
import { IFilesystem, FileMetadata } from '@livx.cc/wcli/core';
|
|
5
5
|
export { CommandExecutor, FileMetadata, IFilesystem, IndexedDbFilesystem, MemFilesystem, registerHeadlessCommands } from '@livx.cc/wcli/core';
|
|
6
6
|
import { BodDB } from '@bod.ee/db';
|
|
7
|
-
import { A as AgentTool, C as ChatLike, a as ChatOptions, b as ChatResponse, r as ToolCall, H as HostBridge, U as UserQuestion, o as MessageContent } from './tools-
|
|
8
|
-
export { c as ContentPart, d as HostEvent, I as IMAGE_ELIDE_STUB, e as IMAGE_REF_SCHEME, f as ImageRef, J as JobCtx, g as JobHandle, h as JobInfo, i as JobKind, j as JobNotice, k as JobRegistry, l as JobRegistryOptions, n as JobTrackOptions, M as Message, m as RegistryJobStatus, R as Role, S as SandboxJobRegistry, p as StreamChunk, T as TodoItem, q as Tool, s as ToolContext, t as bashTool, u as clearImageRefs, v as contentBytes, w as contentText, x as defaultTools, y as editTool, z as elideImages, B as elideInlineImages, D as elideStaleImages, E as exitSessionTool, F as expandImagesForSend, G as formatJobNotice, K as imagePart, L as imageRefPart, N as imageRefResult, O as makeContext, P as makeJobTools, Q as messageHasImage, V as messageHasImageRef, W as messageHasInlineImage, X as mintImageRef, Y as parseImageRef, Z as readTool, _ as remintImageRefs, $ as sendBytes, a0 as sendBytesPer, a1 as toWireTools, a2 as todoWriteTool, a3 as toolImageRef, a4 as toolRegistry, a5 as toolsByName } from './tools-
|
|
7
|
+
import { A as AgentTool, C as ChatLike, a as ChatOptions, b as ChatResponse, r as ToolCall, H as HostBridge, U as UserQuestion, o as MessageContent } from './tools-DwfeF8VQ.js';
|
|
8
|
+
export { c as ContentPart, d as HostEvent, I as IMAGE_ELIDE_STUB, e as IMAGE_REF_SCHEME, f as ImageRef, J as JobCtx, g as JobHandle, h as JobInfo, i as JobKind, j as JobNotice, k as JobRegistry, l as JobRegistryOptions, n as JobTrackOptions, M as Message, m as RegistryJobStatus, R as Role, S as SandboxJobRegistry, p as StreamChunk, T as TodoItem, q as Tool, s as ToolContext, t as bashTool, u as clearImageRefs, v as contentBytes, w as contentText, x as defaultTools, y as editTool, z as elideImages, B as elideInlineImages, D as elideStaleImages, E as exitSessionTool, F as expandImagesForSend, G as formatJobNotice, K as imagePart, L as imageRefPart, N as imageRefResult, O as makeContext, P as makeJobTools, Q as messageHasImage, V as messageHasImageRef, W as messageHasInlineImage, X as mintImageRef, Y as parseImageRef, Z as readTool, _ as remintImageRefs, $ as sendBytes, a0 as sendBytesPer, a1 as toWireTools, a2 as todoWriteTool, a3 as toolImageRef, a4 as toolRegistry, a5 as toolsByName } from './tools-DwfeF8VQ.js';
|
|
9
9
|
import { ShellJobRegistry } from './tools.shell.js';
|
|
10
10
|
import { SpokenSplitter } from '@bod.ee/voice';
|
|
11
11
|
export { AudioSink, AudioSource, AuthProvider, CartesiaTTS, CartesiaTTSOptions, STT_SAMPLE_RATE, SonioxSTT, SonioxSTTOptions, SttLike, TTS_SAMPLE_RATE, TtsLike, VoiceEngine, VoiceEngineOptions, VoiceState, resolveAuth } from '@bod.ee/voice';
|
|
12
|
-
export { M as McpCall, a as McpImage, b as McpRoute, c as McpRouteResolver, d as McpToolResult, e as McpToolSearchOptions, f as McpToolSpec, g as MountedMcpLike, h as buildMcpCatalog, m as makeLazyMcpToolSearch, i as makeMcpToolSearch, j as makeMcpToolSearchFromMounted, k as mcpToolToAgentTool, l as mcpToolsToAgentTools } from './mcp-
|
|
12
|
+
export { M as McpCall, a as McpImage, b as McpRoute, c as McpRouteResolver, d as McpToolResult, e as McpToolSearchOptions, f as McpToolSpec, g as MountedMcpLike, h as buildMcpCatalog, m as makeLazyMcpToolSearch, i as makeMcpToolSearch, j as makeMcpToolSearchFromMounted, k as mcpToolToAgentTool, l as mcpToolsToAgentTools } from './mcp-DZhcLur2.js';
|
|
13
13
|
import * as libx_js_src_modules_log from 'libx.js/src/modules/log';
|
|
14
14
|
export { log } from 'libx.js/src/modules/log';
|
|
15
15
|
|
package/dist/index.js
CHANGED
|
@@ -799,6 +799,7 @@ var init_tools_structured = __esm({
|
|
|
799
799
|
};
|
|
800
800
|
writeTool = {
|
|
801
801
|
name: "Write",
|
|
802
|
+
writes: true,
|
|
802
803
|
description: "Create or overwrite a file with the given contents, creating parent directories as needed. Use for new files instead of `bash echo >`. To replace an EXISTING file you must Read it first \u2014 overwriting an un-Read file is refused (it would destroy unseen content).",
|
|
803
804
|
parameters: {
|
|
804
805
|
type: "object",
|
|
@@ -824,6 +825,7 @@ var init_tools_structured = __esm({
|
|
|
824
825
|
};
|
|
825
826
|
multiEditTool = {
|
|
826
827
|
name: "MultiEdit",
|
|
828
|
+
writes: true,
|
|
827
829
|
description: "Apply several exact-substring replacements to one file in order, in a single call. Requires a prior Read. Each `old_string` must be unique at the time it is applied. All-or-nothing: if any edit fails, none are written.",
|
|
828
830
|
parameters: {
|
|
829
831
|
type: "object",
|
|
@@ -865,6 +867,7 @@ var init_tools_structured = __esm({
|
|
|
865
867
|
};
|
|
866
868
|
applyEditsTool = {
|
|
867
869
|
name: "ApplyEdits",
|
|
870
|
+
writes: true,
|
|
868
871
|
description: "Apply edits across one or MORE files in a single call \u2014 for cross-file refactors (rename/extract/move). edits=[{path, old_string?, new_string}]. WITH old_string: replace that exact substring (must be UNIQUE in the file \u2014 add surrounding context; read fresh + verified, no prior Read needed). WITHOUT old_string: write new_string as the whole file (creates it + parent dirs; but to OVERWRITE a file that already exists you must Read it first, else use old_string to edit part of it). Locate sites first with Grep (its output shows the exact text). Atomic: validated across all files before any write.",
|
|
869
872
|
parameters: {
|
|
870
873
|
type: "object",
|
|
@@ -1579,6 +1582,7 @@ var init_tools = __esm({
|
|
|
1579
1582
|
};
|
|
1580
1583
|
bashTool = {
|
|
1581
1584
|
name: "bash",
|
|
1585
|
+
writes: true,
|
|
1582
1586
|
description: "Run a shell command. Supports ls, cat, grep, find, head, tail, echo, mkdir, rm, mv, cp, wc, pipes (|), redirects (>, >>), and chaining (&&, ||, ;). Best for: running tests/builds, file operations (mkdir/mv/rm), and piped workflows. For searching file contents, prefer `Grep` (structured results, no re-parse). For finding files by name, prefer `Glob`.",
|
|
1583
1587
|
parameters: {
|
|
1584
1588
|
type: "object",
|
|
@@ -1656,6 +1660,7 @@ var init_tools = __esm({
|
|
|
1656
1660
|
};
|
|
1657
1661
|
editTool = {
|
|
1658
1662
|
name: "Edit",
|
|
1663
|
+
writes: true,
|
|
1659
1664
|
description: "Replace an exact substring in a file. Requires a prior Read of the same file. `old_string` must occur exactly once \u2014 include surrounding context to disambiguate.",
|
|
1660
1665
|
parameters: {
|
|
1661
1666
|
type: "object",
|
|
@@ -2792,6 +2797,7 @@ function makeRealShellTool(options) {
|
|
|
2792
2797
|
};
|
|
2793
2798
|
return {
|
|
2794
2799
|
name: "Shell",
|
|
2800
|
+
writes: true,
|
|
2795
2801
|
// Rebind for an isolated child agent (git worktree): same policy/env/timeouts, new cwd. The
|
|
2796
2802
|
// `registry` is deliberately dropped — it is bound to the PARENT's cwd (and, in hosts like
|
|
2797
2803
|
// shraga-ee, to the parent's session), so a background job started from the child would run
|
|
@@ -3708,8 +3714,8 @@ function memorySearchTool(fs, dirs) {
|
|
|
3708
3714
|
return `Error: invalid regex: ${e}`;
|
|
3709
3715
|
}
|
|
3710
3716
|
} else {
|
|
3711
|
-
const
|
|
3712
|
-
matcher = (l) => l.toLowerCase().includes(
|
|
3717
|
+
const lower2 = q.toLowerCase();
|
|
3718
|
+
matcher = (l) => l.toLowerCase().includes(lower2);
|
|
3713
3719
|
}
|
|
3714
3720
|
const loaded = [];
|
|
3715
3721
|
for (const slug2 of slugs) {
|
|
@@ -4509,6 +4515,11 @@ init_logging();
|
|
|
4509
4515
|
var log8 = forComponent("modes");
|
|
4510
4516
|
var WRITE_TOOLS = /* @__PURE__ */ new Set(["Write", "Edit", "MultiEdit", "ApplyEdits"]);
|
|
4511
4517
|
var PLANNER_BLOCKED = /* @__PURE__ */ new Set([...WRITE_TOOLS, "bash", "Shell"]);
|
|
4518
|
+
var lower = (xs) => new Set([...xs].map((x) => x.toLowerCase()));
|
|
4519
|
+
var PLANNER_BLOCKED_LC = lower(PLANNER_BLOCKED);
|
|
4520
|
+
var WRITE_TOOLS_LC = lower(WRITE_TOOLS);
|
|
4521
|
+
var plannerBlocks = (t) => !!t.writes || PLANNER_BLOCKED_LC.has(t.name.toLowerCase());
|
|
4522
|
+
var isFileWrite = (t) => WRITE_TOOLS_LC.has(t.name.toLowerCase());
|
|
4512
4523
|
var 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.";
|
|
4513
4524
|
var PLAN_FIRST = "Refused: check your plan with `Advise` before the first write (files, data shape, the hard parts). Then write.";
|
|
4514
4525
|
var ADVISE_LIMIT = 3;
|
|
@@ -4531,7 +4542,7 @@ function advisorFor(worker, advisor) {
|
|
|
4531
4542
|
return advisor && pairOk("advisor", worker, advisor) ? advisor : void 0;
|
|
4532
4543
|
}
|
|
4533
4544
|
function delegateTools(tools, planner) {
|
|
4534
|
-
return tools.map((t) => !
|
|
4545
|
+
return tools.map((t) => !plannerBlocks(t) ? t : {
|
|
4535
4546
|
...t,
|
|
4536
4547
|
run: async (...a) => a[1]?.model === planner ? PLANNER_REFUSAL : t.run(...a)
|
|
4537
4548
|
});
|
|
@@ -4601,7 +4612,7 @@ ${question}` }
|
|
|
4601
4612
|
}
|
|
4602
4613
|
}
|
|
4603
4614
|
};
|
|
4604
|
-
const gate = (tools) => tools.map((t) => !
|
|
4615
|
+
const gate = (tools) => tools.map((t) => !isFileWrite(t) ? t : { ...t, run: async (...a) => used ? t.run(...a) : PLAN_FIRST });
|
|
4605
4616
|
return { tool, gate, used: () => used };
|
|
4606
4617
|
}
|
|
4607
4618
|
function meterWorkers(ai, main) {
|
|
@@ -4644,6 +4655,13 @@ function meterWorkers(ai, main) {
|
|
|
4644
4655
|
resolved = void 0;
|
|
4645
4656
|
} };
|
|
4646
4657
|
}
|
|
4658
|
+
var CC_WRITE_TOOLS = ["Write", "Edit", "MultiEdit", "NotebookEdit"];
|
|
4659
|
+
function ccModeOptions(kind, hostHooks, used) {
|
|
4660
|
+
if (kind === "delegate") return { bridge: /* @__PURE__ */ new Set(["Task", "TaskBatch"]), disallow: [...CC_WRITE_TOOLS, "Bash", "Task", "Agent"] };
|
|
4661
|
+
if (kind !== "advisor") return { bridge: /* @__PURE__ */ new Set(), disallow: [] };
|
|
4662
|
+
const gate = { matcher: CC_WRITE_TOOLS.join("|"), hooks: [async () => used() ? {} : { hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: PLAN_FIRST.replace("`Advise`", "`mcp__agentx__Advise`") } }] };
|
|
4663
|
+
return { bridge: /* @__PURE__ */ new Set(["Advise"]), disallow: [], hooks: { ...hostHooks, PreToolUse: [...hostHooks?.PreToolUse ?? [], gate] } };
|
|
4664
|
+
}
|
|
4647
4665
|
|
|
4648
4666
|
// src/lint.ts
|
|
4649
4667
|
var CODE_RE = /\.(ts|tsx|js|jsx|mjs|cjs)$/;
|
|
@@ -4971,6 +4989,8 @@ var Agent = class _Agent {
|
|
|
4971
4989
|
meter;
|
|
4972
4990
|
// delegate/advisor: meters the second model's calls
|
|
4973
4991
|
modeModel;
|
|
4992
|
+
modeKind;
|
|
4993
|
+
adv;
|
|
4974
4994
|
lastTask = "";
|
|
4975
4995
|
// the current turn's text — what the advisor reads as the request
|
|
4976
4996
|
/** claude-code bridge for agentx-only tools (ccBridge.ts) + the current step's executor it calls. */
|
|
@@ -5075,12 +5095,15 @@ var Agent = class _Agent {
|
|
|
5075
5095
|
const o = this.options;
|
|
5076
5096
|
if (!o.model.startsWith("claude-code/")) return void 0;
|
|
5077
5097
|
const po = { steer: () => this.drainPendingSteers() };
|
|
5078
|
-
const
|
|
5098
|
+
const mode = ccModeOptions(this.modeKind, o.providerOptions?.hooks, () => this.adv?.used() ?? 0);
|
|
5099
|
+
const bridged = (t) => o.ccBridge === "all" || CC_BRIDGED.has(t.name) || mode.bridge.has(t.name);
|
|
5079
5100
|
if (o.providerOptions?.claudeCodeSession && this.activeTools.some(bridged)) {
|
|
5080
5101
|
this.ccServer ??= ccToolServer("agentx", () => this.activeTools.filter(bridged), (n, a) => this.ccExec(n, a));
|
|
5081
5102
|
po.mcpServers = { ...o.providerOptions?.mcpServers, agentx: this.ccServer };
|
|
5082
5103
|
}
|
|
5083
|
-
const denyTools = claudeCodeDisallowedTools(o.permissions);
|
|
5104
|
+
const denyTools = [...claudeCodeDisallowedTools(o.permissions), ...mode.disallow];
|
|
5105
|
+
if (mode.hooks) po.hooks = mode.hooks;
|
|
5106
|
+
if (this.modeKind && o.providerOptions?.claudeCodeSession) po.claudeCodeSession = `${o.providerOptions.claudeCodeSession}:${this.modeKind}`;
|
|
5084
5107
|
if (denyTools.length) {
|
|
5085
5108
|
const prior = o.providerOptions?.disallowedTools ?? [];
|
|
5086
5109
|
po.disallowedTools = [.../* @__PURE__ */ new Set([...prior, ...denyTools])];
|
|
@@ -5178,7 +5201,8 @@ var Agent = class _Agent {
|
|
|
5178
5201
|
const advisor = !worker && o.advisor ? advisorFor(o.model, o.advisor.model) : void 0;
|
|
5179
5202
|
this.meter = worker || advisor ? meterWorkers(o.ai, o.model) : void 0;
|
|
5180
5203
|
const ai = this.meter?.ai ?? o.ai;
|
|
5181
|
-
|
|
5204
|
+
this.modeKind = worker ? "delegate" : advisor ? "advisor" : void 0;
|
|
5205
|
+
const adv = this.adv = advisor ? makeAdvisor({ ai, advisor, request: () => this.lastTask, snapshot: o.advisor.snapshot, limit: o.advisor.limit }) : void 0;
|
|
5182
5206
|
if (o.instructionFiles !== false) {
|
|
5183
5207
|
const names = Array.isArray(o.instructionFiles) ? o.instructionFiles : void 0;
|
|
5184
5208
|
const ins = await loadInstructions(fs, names);
|
|
@@ -7365,8 +7389,8 @@ function isTranscriptComplete(text) {
|
|
|
7365
7389
|
const lastWord = words3[words3.length - 1];
|
|
7366
7390
|
if (COMPLETE_ENDINGS.has(lastWord)) return true;
|
|
7367
7391
|
if (INCOMPLETE_ENDINGS.has(lastWord)) return false;
|
|
7368
|
-
const
|
|
7369
|
-
for (const marker of CONTINUATION_MARKERS) if (
|
|
7392
|
+
const lower2 = trimmed.toLowerCase();
|
|
7393
|
+
for (const marker of CONTINUATION_MARKERS) if (lower2.endsWith(marker)) return false;
|
|
7370
7394
|
if (words3.length <= 2) return false;
|
|
7371
7395
|
return true;
|
|
7372
7396
|
}
|
|
@@ -13961,6 +13985,7 @@ export {
|
|
|
13961
13985
|
Agent,
|
|
13962
13986
|
AgentOptions,
|
|
13963
13987
|
BodDbFilesystem,
|
|
13988
|
+
CC_WRITE_TOOLS,
|
|
13964
13989
|
CartesiaTTS,
|
|
13965
13990
|
CartesiaTTSOptions,
|
|
13966
13991
|
CommandExecutor2 as CommandExecutor,
|
|
@@ -14022,6 +14047,7 @@ export {
|
|
|
14022
14047
|
askUserQuestionTool,
|
|
14023
14048
|
bashTool,
|
|
14024
14049
|
buildMcpCatalog,
|
|
14050
|
+
ccModeOptions,
|
|
14025
14051
|
checkpointTool,
|
|
14026
14052
|
checkpointTools,
|
|
14027
14053
|
claudeCodeDisallowedTools,
|
|
@@ -14107,6 +14133,7 @@ export {
|
|
|
14107
14133
|
parseImageRef,
|
|
14108
14134
|
pickTier,
|
|
14109
14135
|
planMode,
|
|
14136
|
+
plannerBlocks,
|
|
14110
14137
|
raceAttempts,
|
|
14111
14138
|
readTool,
|
|
14112
14139
|
reasoningToChatFragment,
|