@livx.cc/agentx 0.99.166 → 0.99.167
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/cli.d.ts +5 -1
- package/dist/cli.js +388 -149
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +34 -9
- package/dist/index.js.map +1 -1
- package/dist/{secondChannel-BNDDJv6d.d.ts → secondChannel-DLB-hDny.d.ts} +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as AgentOptions, H as Hooks, x as RunResult, k as Decider, b as Agent, q as PermissionPolicy, G as Gender, L as LineKind, d as ChannelMode, y as SecondChannelOptions, S as SecondChannel } from './secondChannel-
|
|
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, j as ContextFileSpec, D as DEFAULT_MUTATING, l as Decision, M as ModelRouter, m as ModelRouterOptions, P as PLANNER_BLOCKED, n as PLANNER_REFUSAL, o as PLAN_FIRST, p as PermissionOptions, r as PermissionRule, s as PreToolUseDecision, R as ReasoningEffort, t as RecordingHooks, u as RecordingLifecycle, v as RouteDecision, w as RouterState, T as Tier, z as ToolUse, B as ToolUseMeta, W as WRITE_TOOLS, E as advisorFor, F as advisorPrompt, I as ccModeOptions, J as claudeCodeDisallowedTools, K as composeHooks, N as delegatePrompt, O as delegateTools, Q as delegateWorkerFor, U as estimateTokens, V as jevAvailable, X as jevClassifier, Y as loadContextFiles, Z as loadInstructions, _ as makeAdvisor, $ as meterWorkers, a0 as pickTier, a1 as planMode, a2 as plannerBlocks, a3 as reasoningToChatFragment } from './secondChannel-
|
|
1
|
+
import { c as AgentOptions, H as Hooks, x as RunResult, k as Decider, b as Agent, q as PermissionPolicy, G as Gender, L as LineKind, d as ChannelMode, y as SecondChannelOptions, S as SecondChannel } from './secondChannel-DLB-hDny.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, j as ContextFileSpec, D as DEFAULT_MUTATING, l as Decision, M as ModelRouter, m as ModelRouterOptions, P as PLANNER_BLOCKED, n as PLANNER_REFUSAL, o as PLAN_FIRST, p as PermissionOptions, r as PermissionRule, s as PreToolUseDecision, R as ReasoningEffort, t as RecordingHooks, u as RecordingLifecycle, v as RouteDecision, w as RouterState, T as Tier, z as ToolUse, B as ToolUseMeta, W as WRITE_TOOLS, E as advisorFor, F as advisorPrompt, I as ccModeOptions, J as claudeCodeDisallowedTools, K as composeHooks, N as delegatePrompt, O as delegateTools, Q as delegateWorkerFor, U as estimateTokens, V as jevAvailable, X as jevClassifier, Y as loadContextFiles, Z as loadInstructions, _ as makeAdvisor, $ as meterWorkers, a0 as pickTier, a1 as planMode, a2 as plannerBlocks, a3 as reasoningToChatFragment } from './secondChannel-DLB-hDny.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';
|
package/dist/index.js
CHANGED
|
@@ -3195,6 +3195,23 @@ function ccToolServer(name, tools, call) {
|
|
|
3195
3195
|
return { type: "sdk", name, instance };
|
|
3196
3196
|
}
|
|
3197
3197
|
|
|
3198
|
+
// src/runtimes.ts
|
|
3199
|
+
var RUNTIMES = {
|
|
3200
|
+
"claude-code": { keyless: true, ownsTools: true },
|
|
3201
|
+
cursor: { keyless: false, ownsTools: false }
|
|
3202
|
+
// host tools are bridged in through its toolExecutor
|
|
3203
|
+
};
|
|
3204
|
+
function runtimeOf(model) {
|
|
3205
|
+
const p = (model ?? "").split("/")[0];
|
|
3206
|
+
return (model ?? "").includes("/") && p in RUNTIMES ? p : void 0;
|
|
3207
|
+
}
|
|
3208
|
+
var isClaudeCode = (model) => runtimeOf(model) === "claude-code";
|
|
3209
|
+
var isCursor = (model) => runtimeOf(model) === "cursor";
|
|
3210
|
+
var ownsTools = (model) => {
|
|
3211
|
+
const r = runtimeOf(model);
|
|
3212
|
+
return !!r && RUNTIMES[r].ownsTools;
|
|
3213
|
+
};
|
|
3214
|
+
|
|
3198
3215
|
// src/Agent.ts
|
|
3199
3216
|
init_llm();
|
|
3200
3217
|
init_tools();
|
|
@@ -3980,7 +3997,11 @@ var PermissionPolicy = class {
|
|
|
3980
3997
|
preToolUse: async (call) => {
|
|
3981
3998
|
const d = this.decide(call);
|
|
3982
3999
|
if (d === "allow") return;
|
|
3983
|
-
if (d === "deny")
|
|
4000
|
+
if (d === "deny") {
|
|
4001
|
+
const reason = `denied by permission policy (${call.name})`;
|
|
4002
|
+
this.options.onDeny?.(call, reason);
|
|
4003
|
+
return { block: true, reason };
|
|
4004
|
+
}
|
|
3984
4005
|
if (this.options.ask) {
|
|
3985
4006
|
const r = await this.options.ask(call);
|
|
3986
4007
|
const decision = r?.decision ?? "deny";
|
|
@@ -4629,7 +4650,7 @@ function pairOk(kind, main, other) {
|
|
|
4629
4650
|
log8.warn(`${kind} off: both sides are ${main}`);
|
|
4630
4651
|
return false;
|
|
4631
4652
|
}
|
|
4632
|
-
if (main
|
|
4653
|
+
if (isCursor(main) || isCursor(other)) {
|
|
4633
4654
|
log8.warn(`${kind} off: cursor models are not supported (${main} / ${other})`);
|
|
4634
4655
|
return false;
|
|
4635
4656
|
}
|
|
@@ -5032,6 +5053,9 @@ var AgentOptions = class {
|
|
|
5032
5053
|
* caps, MCP soft timeout) live on `JobRegistryOptions`. Completion notices reach the model via `inject` unless
|
|
5033
5054
|
* the host set its own `onExit`. */
|
|
5034
5055
|
jobs;
|
|
5056
|
+
/** Called after every `inject()` (a background job's completion notice, a host steer). A REPL uses it to wake an
|
|
5057
|
+
* IDLE session — between turns nothing drains the queue, so a finished job would otherwise wait for the next prompt. */
|
|
5058
|
+
onInject;
|
|
5035
5059
|
/** Plan mode: block mutating tools until the agent calls `ExitPlanMode` (host-approved). */
|
|
5036
5060
|
planMode = false;
|
|
5037
5061
|
/** Permission policy gating each tool call (allow / ask / deny). */
|
|
@@ -5189,6 +5213,7 @@ var Agent = class _Agent {
|
|
|
5189
5213
|
* Pushing onto `transcript` directly from outside would race the loop — this drains inside it. */
|
|
5190
5214
|
inject(content) {
|
|
5191
5215
|
this.pendingInjections.push(content);
|
|
5216
|
+
this.options.onInject?.();
|
|
5192
5217
|
}
|
|
5193
5218
|
/** Drop any queued-but-unconsumed injections. The REPL calls this after a LOCAL command (/cmd, !bash)
|
|
5194
5219
|
* — which runs no send() to drain them — so a mid-command steer can't leak into the next real turn. */
|
|
@@ -5202,7 +5227,7 @@ var Agent = class _Agent {
|
|
|
5202
5227
|
/** claude-code/*: the providerOptions every step adds (and prewarm, so the session it starts is the one step 1 reuses). */
|
|
5203
5228
|
claudeCodePo() {
|
|
5204
5229
|
const o = this.options;
|
|
5205
|
-
if (!o.model
|
|
5230
|
+
if (!isClaudeCode(o.model)) return void 0;
|
|
5206
5231
|
const po = { steer: () => this.drainPendingSteers() };
|
|
5207
5232
|
const mode = ccModeOptions(this.modeKind, o.providerOptions?.hooks, () => this.adv?.used() ?? 0);
|
|
5208
5233
|
const bridged = (t) => o.ccBridge === "all" || CC_BRIDGED.has(t.name) || mode.bridge.has(t.name);
|
|
@@ -5232,7 +5257,7 @@ var Agent = class _Agent {
|
|
|
5232
5257
|
async prewarm() {
|
|
5233
5258
|
const o = this.options;
|
|
5234
5259
|
const api = o.model.startsWith("anthropic/") && o.promptCache;
|
|
5235
|
-
if (!api && (!o.model
|
|
5260
|
+
if (!api && (!isClaudeCode(o.model) || !o.providerOptions?.claudeCodeSession)) return;
|
|
5236
5261
|
await this.ensureFs();
|
|
5237
5262
|
const systemPrompt = await this.prepare(), startCtx = await this.fireSessionStart();
|
|
5238
5263
|
const sys = { role: "system", content: systemPrompt + (startCtx ? "\n\n" + startCtx : "") };
|
|
@@ -5549,8 +5574,8 @@ var Agent = class _Agent {
|
|
|
5549
5574
|
let res;
|
|
5550
5575
|
let sent = this.trimContext();
|
|
5551
5576
|
const frag = reasoningToChatFragment(o.model, o.reasoning);
|
|
5552
|
-
const sentTools = o.model
|
|
5553
|
-
const isCursorWithTools = o.model
|
|
5577
|
+
const sentTools = ownsTools(o.model) ? [] : wireTools;
|
|
5578
|
+
const isCursorWithTools = isCursor(o.model) && wireTools.length > 0;
|
|
5554
5579
|
const hostToolTimeoutMs = o.providerOptions?.toolTimeoutMs;
|
|
5555
5580
|
const derivedToolTimeoutMs = Math.max(TRANSPORT_TOOL_TIMEOUT_FLOOR_MS, ...this.activeTools.map(transportHeadroomMs));
|
|
5556
5581
|
const effectiveToolTimeoutMs = typeof hostToolTimeoutMs === "number" ? Math.max(hostToolTimeoutMs, derivedToolTimeoutMs) : derivedToolTimeoutMs;
|
|
@@ -5580,8 +5605,8 @@ var Agent = class _Agent {
|
|
|
5580
5605
|
const cursorPo = isCursorWithTools ? { toolTimeoutMs: effectiveToolTimeoutMs, toolExecutor: hostExec } : void 0;
|
|
5581
5606
|
const claudeSteerPo = this.claudeCodePo();
|
|
5582
5607
|
if (this.ccServer) this.ccExec = hostExec;
|
|
5583
|
-
const cursorDeny = o.model
|
|
5584
|
-
if (o.model
|
|
5608
|
+
const cursorDeny = isCursor(o.model) ? o.permissions?.denyRules(true) ?? [] : [];
|
|
5609
|
+
if (isCursor(o.model) && o.permissions?.options.default === "deny")
|
|
5585
5610
|
throw new Error("cursor/* cannot enforce --onlyTools: its native tools bypass it. Refusing to run \u2014 use a claude-code/* or API model.");
|
|
5586
5611
|
if (cursorDeny.length)
|
|
5587
5612
|
throw new Error(`cursor/* cannot enforce --disallowedTools (${cursorDeny.join(", ")}): its native tools bypass them. Refusing to run \u2014 use a claude-code/* or API model, or drop --disallowedTools.`);
|
|
@@ -12089,7 +12114,7 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
12089
12114
|
* no other MCP server — the reflex only talks and routes; real work still goes through Act and its policy. */
|
|
12090
12115
|
claudeCodeReflex() {
|
|
12091
12116
|
const o = this.options;
|
|
12092
|
-
if (!o.reflexModel
|
|
12117
|
+
if (!isClaudeCode(o.reflexModel)) return {};
|
|
12093
12118
|
const po = o.providerOptionsFor?.(o.reflexModel) ?? {};
|
|
12094
12119
|
return {
|
|
12095
12120
|
ccBridge: "all",
|