@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/cli.js
CHANGED
|
@@ -2077,8 +2077,8 @@ var init_tools_jobs = __esm({
|
|
|
2077
2077
|
arm() {
|
|
2078
2078
|
if (this.timer || !this.options.sweepMs) return;
|
|
2079
2079
|
this.timer = setInterval(() => {
|
|
2080
|
-
const
|
|
2081
|
-
if (!
|
|
2080
|
+
const live2 = [...this.jobs.values()].some((j) => j.status === "running" && (j.idleMs || j.hardCapMs));
|
|
2081
|
+
if (!live2) {
|
|
2082
2082
|
clearInterval(this.timer);
|
|
2083
2083
|
this.timer = void 0;
|
|
2084
2084
|
return;
|
|
@@ -3359,10 +3359,32 @@ var init_tools_shell = __esm({
|
|
|
3359
3359
|
|
|
3360
3360
|
// cli/cli.ts
|
|
3361
3361
|
import { createInterface } from "readline/promises";
|
|
3362
|
-
import { existsSync as existsSync9, readFileSync as readFileSync10, appendFileSync as appendFileSync2, mkdirSync as
|
|
3363
|
-
import { homedir as
|
|
3362
|
+
import { existsSync as existsSync9, readFileSync as readFileSync10, appendFileSync as appendFileSync2, mkdirSync as mkdirSync13, writeFileSync as writeFileSync10, readdirSync as readdirSync4, statSync as statSync7, unlinkSync as unlinkSync5 } from "fs";
|
|
3363
|
+
import { homedir as homedir11 } from "os";
|
|
3364
3364
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
3365
3365
|
|
|
3366
|
+
// src/runtimes.ts
|
|
3367
|
+
var RUNTIMES = {
|
|
3368
|
+
"claude-code": { keyless: true, ownsTools: true },
|
|
3369
|
+
cursor: { keyless: false, ownsTools: false }
|
|
3370
|
+
// host tools are bridged in through its toolExecutor
|
|
3371
|
+
};
|
|
3372
|
+
function runtimeOf(model) {
|
|
3373
|
+
const p = (model ?? "").split("/")[0];
|
|
3374
|
+
return (model ?? "").includes("/") && p in RUNTIMES ? p : void 0;
|
|
3375
|
+
}
|
|
3376
|
+
var isDelegated = (model) => !!runtimeOf(model);
|
|
3377
|
+
var isClaudeCode = (model) => runtimeOf(model) === "claude-code";
|
|
3378
|
+
var isCursor = (model) => runtimeOf(model) === "cursor";
|
|
3379
|
+
var isKeyless = (modelOrProvider) => {
|
|
3380
|
+
const p = (modelOrProvider ?? "").split("/")[0];
|
|
3381
|
+
return !!RUNTIMES[p]?.keyless;
|
|
3382
|
+
};
|
|
3383
|
+
var ownsTools = (model) => {
|
|
3384
|
+
const r = runtimeOf(model);
|
|
3385
|
+
return !!r && RUNTIMES[r].ownsTools;
|
|
3386
|
+
};
|
|
3387
|
+
|
|
3366
3388
|
// cli/clipboard.ts
|
|
3367
3389
|
import { execFileSync } from "child_process";
|
|
3368
3390
|
import { statSync, writeFileSync } from "fs";
|
|
@@ -3440,7 +3462,7 @@ function copyTextToClipboard(text, platform2 = process.platform) {
|
|
|
3440
3462
|
}
|
|
3441
3463
|
|
|
3442
3464
|
// cli/cli.ts
|
|
3443
|
-
import { join as
|
|
3465
|
+
import { join as join17, resolve as resolve5, basename as basename4, extname, dirname as dirname6 } from "path";
|
|
3444
3466
|
import { AIClient as AIClient2, listModels, listProviders, getProviderFromModel, getModelInfo, resolveModel, isModelSupported, disposeCursorSessions, disposeClaudeCodeSessions, rewindClaudeCodeSession } from "ai.libx.js";
|
|
3445
3467
|
|
|
3446
3468
|
// src/ccBridge.ts
|
|
@@ -4239,7 +4261,11 @@ var PermissionPolicy = class {
|
|
|
4239
4261
|
preToolUse: async (call) => {
|
|
4240
4262
|
const d = this.decide(call);
|
|
4241
4263
|
if (d === "allow") return;
|
|
4242
|
-
if (d === "deny")
|
|
4264
|
+
if (d === "deny") {
|
|
4265
|
+
const reason = `denied by permission policy (${call.name})`;
|
|
4266
|
+
this.options.onDeny?.(call, reason);
|
|
4267
|
+
return { block: true, reason };
|
|
4268
|
+
}
|
|
4243
4269
|
if (this.options.ask) {
|
|
4244
4270
|
const r = await this.options.ask(call);
|
|
4245
4271
|
const decision = r?.decision ?? "deny";
|
|
@@ -4738,7 +4764,7 @@ function pairOk(kind, main2, other) {
|
|
|
4738
4764
|
log8.warn(`${kind} off: both sides are ${main2}`);
|
|
4739
4765
|
return false;
|
|
4740
4766
|
}
|
|
4741
|
-
if (main2
|
|
4767
|
+
if (isCursor(main2) || isCursor(other)) {
|
|
4742
4768
|
log8.warn(`${kind} off: cursor models are not supported (${main2} / ${other})`);
|
|
4743
4769
|
return false;
|
|
4744
4770
|
}
|
|
@@ -5141,6 +5167,9 @@ var AgentOptions = class {
|
|
|
5141
5167
|
* caps, MCP soft timeout) live on `JobRegistryOptions`. Completion notices reach the model via `inject` unless
|
|
5142
5168
|
* the host set its own `onExit`. */
|
|
5143
5169
|
jobs;
|
|
5170
|
+
/** Called after every `inject()` (a background job's completion notice, a host steer). A REPL uses it to wake an
|
|
5171
|
+
* IDLE session — between turns nothing drains the queue, so a finished job would otherwise wait for the next prompt. */
|
|
5172
|
+
onInject;
|
|
5144
5173
|
/** Plan mode: block mutating tools until the agent calls `ExitPlanMode` (host-approved). */
|
|
5145
5174
|
planMode = false;
|
|
5146
5175
|
/** Permission policy gating each tool call (allow / ask / deny). */
|
|
@@ -5298,6 +5327,7 @@ var Agent = class _Agent {
|
|
|
5298
5327
|
* Pushing onto `transcript` directly from outside would race the loop — this drains inside it. */
|
|
5299
5328
|
inject(content) {
|
|
5300
5329
|
this.pendingInjections.push(content);
|
|
5330
|
+
this.options.onInject?.();
|
|
5301
5331
|
}
|
|
5302
5332
|
/** Drop any queued-but-unconsumed injections. The REPL calls this after a LOCAL command (/cmd, !bash)
|
|
5303
5333
|
* — which runs no send() to drain them — so a mid-command steer can't leak into the next real turn. */
|
|
@@ -5311,7 +5341,7 @@ var Agent = class _Agent {
|
|
|
5311
5341
|
/** claude-code/*: the providerOptions every step adds (and prewarm, so the session it starts is the one step 1 reuses). */
|
|
5312
5342
|
claudeCodePo() {
|
|
5313
5343
|
const o = this.options;
|
|
5314
|
-
if (!o.model
|
|
5344
|
+
if (!isClaudeCode(o.model)) return void 0;
|
|
5315
5345
|
const po = { steer: () => this.drainPendingSteers() };
|
|
5316
5346
|
const mode = ccModeOptions(this.modeKind, o.providerOptions?.hooks, () => this.adv?.used() ?? 0);
|
|
5317
5347
|
const bridged = (t) => o.ccBridge === "all" || CC_BRIDGED.has(t.name) || mode.bridge.has(t.name);
|
|
@@ -5341,7 +5371,7 @@ var Agent = class _Agent {
|
|
|
5341
5371
|
async prewarm() {
|
|
5342
5372
|
const o = this.options;
|
|
5343
5373
|
const api = o.model.startsWith("anthropic/") && o.promptCache;
|
|
5344
|
-
if (!api && (!o.model
|
|
5374
|
+
if (!api && (!isClaudeCode(o.model) || !o.providerOptions?.claudeCodeSession)) return;
|
|
5345
5375
|
await this.ensureFs();
|
|
5346
5376
|
const systemPrompt = await this.prepare(), startCtx = await this.fireSessionStart();
|
|
5347
5377
|
const sys = { role: "system", content: systemPrompt + (startCtx ? "\n\n" + startCtx : "") };
|
|
@@ -5658,8 +5688,8 @@ var Agent = class _Agent {
|
|
|
5658
5688
|
let res;
|
|
5659
5689
|
let sent = this.trimContext();
|
|
5660
5690
|
const frag = reasoningToChatFragment(o.model, o.reasoning);
|
|
5661
|
-
const sentTools = o.model
|
|
5662
|
-
const isCursorWithTools = o.model
|
|
5691
|
+
const sentTools = ownsTools(o.model) ? [] : wireTools;
|
|
5692
|
+
const isCursorWithTools = isCursor(o.model) && wireTools.length > 0;
|
|
5663
5693
|
const hostToolTimeoutMs = o.providerOptions?.toolTimeoutMs;
|
|
5664
5694
|
const derivedToolTimeoutMs = Math.max(TRANSPORT_TOOL_TIMEOUT_FLOOR_MS, ...this.activeTools.map(transportHeadroomMs));
|
|
5665
5695
|
const effectiveToolTimeoutMs = typeof hostToolTimeoutMs === "number" ? Math.max(hostToolTimeoutMs, derivedToolTimeoutMs) : derivedToolTimeoutMs;
|
|
@@ -5689,8 +5719,8 @@ var Agent = class _Agent {
|
|
|
5689
5719
|
const cursorPo = isCursorWithTools ? { toolTimeoutMs: effectiveToolTimeoutMs, toolExecutor: hostExec } : void 0;
|
|
5690
5720
|
const claudeSteerPo = this.claudeCodePo();
|
|
5691
5721
|
if (this.ccServer) this.ccExec = hostExec;
|
|
5692
|
-
const cursorDeny = o.model
|
|
5693
|
-
if (o.model
|
|
5722
|
+
const cursorDeny = isCursor(o.model) ? o.permissions?.denyRules(true) ?? [] : [];
|
|
5723
|
+
if (isCursor(o.model) && o.permissions?.options.default === "deny")
|
|
5694
5724
|
throw new Error("cursor/* cannot enforce --onlyTools: its native tools bypass it. Refusing to run \u2014 use a claude-code/* or API model.");
|
|
5695
5725
|
if (cursorDeny.length)
|
|
5696
5726
|
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.`);
|
|
@@ -9768,9 +9798,9 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
9768
9798
|
return false;
|
|
9769
9799
|
}
|
|
9770
9800
|
const epoch = ++this.asideEpoch, chunks = [], t0 = this.clock.now();
|
|
9771
|
-
const
|
|
9801
|
+
const live2 = () => epoch === this.asideEpoch;
|
|
9772
9802
|
const give = (reason) => {
|
|
9773
|
-
if (!
|
|
9803
|
+
if (!live2()) return;
|
|
9774
9804
|
this.asideEpoch++;
|
|
9775
9805
|
this.diag("aside_skipped", { reason, text: text.slice(0, 40) });
|
|
9776
9806
|
try {
|
|
@@ -9785,10 +9815,10 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
9785
9815
|
this.lastAck = text;
|
|
9786
9816
|
this.echoUntil = Math.max(this.echoUntil, t0 + 2500 + this.options.asideMaxMs);
|
|
9787
9817
|
t.onAudio = (c) => {
|
|
9788
|
-
if (
|
|
9818
|
+
if (live2()) chunks.push(c);
|
|
9789
9819
|
};
|
|
9790
9820
|
t.onDone = () => {
|
|
9791
|
-
if (!
|
|
9821
|
+
if (!live2()) return;
|
|
9792
9822
|
this.clock.clearTimeout(timer);
|
|
9793
9823
|
const n = chunks.reduce((a, c) => a + c.length, 0);
|
|
9794
9824
|
if (!n || !this.speaking || this.pausedAt) return give(!n ? "no_audio" : this.pausedAt ? "held_again" : "turn_over");
|
|
@@ -12429,7 +12459,7 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
12429
12459
|
* no other MCP server — the reflex only talks and routes; real work still goes through Act and its policy. */
|
|
12430
12460
|
claudeCodeReflex() {
|
|
12431
12461
|
const o = this.options;
|
|
12432
|
-
if (!o.reflexModel
|
|
12462
|
+
if (!isClaudeCode(o.reflexModel)) return {};
|
|
12433
12463
|
const po = o.providerOptionsFor?.(o.reflexModel) ?? {};
|
|
12434
12464
|
return {
|
|
12435
12465
|
ccBridge: "all",
|
|
@@ -17326,6 +17356,16 @@ function dotDirs(base, sub, opts = {}) {
|
|
|
17326
17356
|
const dirs = [`${base}/.agent/${sub}`, `${base}/.claude/${sub}`, `${home}/.agent/${sub}`, `${home}/.claude/${sub}`, ...extraDirs().map((d) => `${d}/${sub}`)];
|
|
17327
17357
|
return opts.existing ? dirs.filter((d) => existsSync2(d)) : dirs;
|
|
17328
17358
|
}
|
|
17359
|
+
function userInstructionFiles(o = {}) {
|
|
17360
|
+
const home = o.home ?? homedir(), cwd = o.cwd ?? process.cwd();
|
|
17361
|
+
const project = new Set(["AGENT.md", "AGENTS.md", "CLAUDE.md"].flatMap((n) => [`${cwd}/${n}`, `${cwd}/.claude/${n}`]));
|
|
17362
|
+
const tiers = [[`${home}/.agent/AGENTS.md`], extraDirs(o.env).map((d) => `${d.replace(/\/+$/, "")}/CLAUDE.md`), [`${home}/.claude/CLAUDE.md`]];
|
|
17363
|
+
for (const tier of tiers) {
|
|
17364
|
+
const hit = tier.filter((p) => existsSync2(p));
|
|
17365
|
+
if (hit.length) return hit.filter((p) => !project.has(p));
|
|
17366
|
+
}
|
|
17367
|
+
return [];
|
|
17368
|
+
}
|
|
17329
17369
|
function truncate(s, n, suffix = "\u2026") {
|
|
17330
17370
|
const t = s ?? "";
|
|
17331
17371
|
return t.length > n ? t.slice(0, n) + suffix : t;
|
|
@@ -17406,7 +17446,7 @@ function toCursorMcp(servers) {
|
|
|
17406
17446
|
return Object.keys(out).length ? { mcpServers: out } : void 0;
|
|
17407
17447
|
}
|
|
17408
17448
|
function cursorProviderOptions(model, cwd, mcpServers, hostMcpServers) {
|
|
17409
|
-
if (!(model
|
|
17449
|
+
if (!isCursor(model)) return void 0;
|
|
17410
17450
|
return { cwd, ...toCursorMcp(mcpServers) ?? {}, ...hostMcpServers?.length ? { hostMcpServers } : {}, ...process.env.CURSOR_WARM === "0" ? {} : { cursorSession: randomUUID() } };
|
|
17411
17451
|
}
|
|
17412
17452
|
function toClaudeCodeMcp(servers) {
|
|
@@ -17425,7 +17465,7 @@ function toClaudeCodeMcp(servers) {
|
|
|
17425
17465
|
return Object.keys(out).length ? { mcpServers: out } : void 0;
|
|
17426
17466
|
}
|
|
17427
17467
|
function claudeCodeProviderOptions(model, cwd, mcpServers) {
|
|
17428
|
-
if (!(model
|
|
17468
|
+
if (!isClaudeCode(model)) return void 0;
|
|
17429
17469
|
const env = (() => {
|
|
17430
17470
|
const base = plainEnv(process.env, process.env.AGENTX_CC_USE_API_KEY ? [] : ["ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"]);
|
|
17431
17471
|
return { ENABLE_CLAUDEAI_MCP_SERVERS: "false", ...base };
|
|
@@ -17448,12 +17488,12 @@ async function buildAgent(o) {
|
|
|
17448
17488
|
const jailedDisk = new JailedFilesystem(disk);
|
|
17449
17489
|
jailedDisk.setCwd(cwd);
|
|
17450
17490
|
const virtual = o.sandbox || !!o.boddb;
|
|
17451
|
-
const
|
|
17452
|
-
const
|
|
17453
|
-
const
|
|
17454
|
-
if (virtual &&
|
|
17491
|
+
const isCursor2 = isCursor(o.model);
|
|
17492
|
+
const isClaudeCode2 = isClaudeCode(o.model);
|
|
17493
|
+
const isDelegated2 = isDelegated(o.model);
|
|
17494
|
+
if (virtual && isDelegated2)
|
|
17455
17495
|
throw new Error(
|
|
17456
|
-
`${
|
|
17496
|
+
`${isCursor2 ? "cursor" : "claude-code"}/* models cannot run in --sandbox/--boddb: the delegated agent runs its own real-disk tools and bypasses the VFS jail. Use disk mode (default).`
|
|
17457
17497
|
);
|
|
17458
17498
|
let fs = jailedDisk;
|
|
17459
17499
|
const vcwd = toVfsPath(cwd);
|
|
@@ -17477,7 +17517,7 @@ async function buildAgent(o) {
|
|
|
17477
17517
|
let mountNote = "";
|
|
17478
17518
|
if (o.confine) {
|
|
17479
17519
|
if (virtual) throw new Error("--confine is a disk-mode jail; --sandbox/--boddb already contain the agent.");
|
|
17480
|
-
if (
|
|
17520
|
+
if (isClaudeCode2 && o.permissions?.options.default !== "deny") throw new Error("claude-code/* can be confined only with an allow-list (--onlyTools): its own tools bypass the jail.");
|
|
17481
17521
|
const roots = [...new Set([cwd, ...o.addDirs ?? []].map((d) => realpathSync3(resolve3(d))))];
|
|
17482
17522
|
const mem = new MemFilesystem3();
|
|
17483
17523
|
for (const r of roots) await mkdirp(mem, r);
|
|
@@ -17539,7 +17579,7 @@ Reference files in them by their mount path (the left side).`;
|
|
|
17539
17579
|
const agentRef = {};
|
|
17540
17580
|
const jobRegistry = new JobRegistry();
|
|
17541
17581
|
const useRealShell = o.realShell ?? !virtual;
|
|
17542
|
-
if (useRealShell && !virtual && !
|
|
17582
|
+
if (useRealShell && !virtual && !isClaudeCode2) {
|
|
17543
17583
|
const jobs = new ShellJobRegistry({
|
|
17544
17584
|
cwd,
|
|
17545
17585
|
killOnExit: true,
|
|
@@ -17566,8 +17606,8 @@ Reference files in them by their mount path (the left side).`;
|
|
|
17566
17606
|
// turns, amortising the ~2s Agent.create + h2 handshake. Keyed per agentx launch.
|
|
17567
17607
|
...(() => {
|
|
17568
17608
|
let po = providerOptionsFor(o.model, cwd, o.mcpServers, o.hostMcpServers);
|
|
17569
|
-
if (po && o.lean &&
|
|
17570
|
-
if (po && o.confine &&
|
|
17609
|
+
if (po && o.lean && isClaudeCode2) po = { ...po, settingSources: [] };
|
|
17610
|
+
if (po && o.confine && isClaudeCode2) {
|
|
17571
17611
|
if (!po.claudeCodeSession) throw new Error("claude-code/* cannot be confined without the warm session (AGENTX_CC_WARM=0): its own tools would bypass the jail.");
|
|
17572
17612
|
return { providerOptions: { ...po, tools: [] }, ccBridge: "all" };
|
|
17573
17613
|
}
|
|
@@ -17601,7 +17641,7 @@ Windows paths: file tools accept ${cwd} style paths and the same path written ${
|
|
|
17601
17641
|
const list = [...names];
|
|
17602
17642
|
return `You are agentx (an agent runtime) \u2014 NOT Claude Code or Claude Desktop, which are separate agents with their own config. Your MCP servers are configured in .agent/settings.json or .agent/config.* (this project's .agent/ or ~/.agent/), and their tools are already in your tool list as \`mcp__<server>__<tool>\`.${list.length ? ` Configured MCP servers: ${list.join(", ")}.` : " No MCP servers are currently configured."} When asked which MCPs/tools you have, answer from your own tool list \u2014 never read Claude Code/Desktop config (e.g. ~/.claude.json, claude_desktop_config.json) to answer; those belong to a different agent.`;
|
|
17603
17643
|
})();
|
|
17604
|
-
const closureNote =
|
|
17644
|
+
const closureNote = isDelegated2 ? "Never end your turn on an action you only announced. If you say you are about to search, read, check or run something, DO it in the same turn before you stop. Your last message must be the ANSWER \u2014 the result and what it means \u2014 or an explicit statement that you are blocked and why. Narration of what you are about to do is not an ending." : "";
|
|
17605
17645
|
const extra = [o.appendSystemPrompt, envNote, cwdNote, shellNote, toneNote, mountNote, mcpNote, closureNote].filter(Boolean).join("\n\n");
|
|
17606
17646
|
const basePrompt = (() => {
|
|
17607
17647
|
let p = new AgentOptions().systemPrompt;
|
|
@@ -17612,7 +17652,7 @@ Windows paths: file tools accept ${cwd} style paths and the same path written ${
|
|
|
17612
17652
|
return { systemPrompt: basePrompt + "\n\n" + extra };
|
|
17613
17653
|
})(),
|
|
17614
17654
|
tools: (() => {
|
|
17615
|
-
if (
|
|
17655
|
+
if (isClaudeCode2) return o.confine ? toolsByName(o.tools ?? DEFAULT_TOOLS).filter((t) => o.permissions?.decide({ name: t.name, args: {} }) !== "deny") : [];
|
|
17616
17656
|
const requested = o.tools ?? DEFAULT_TOOLS;
|
|
17617
17657
|
const base = toolsByName([...requested, ...autoWebTools()]);
|
|
17618
17658
|
const tail = [...o.extraTools ?? []];
|
|
@@ -17646,6 +17686,11 @@ Windows paths: file tools accept ${cwd} style paths and the same path written ${
|
|
|
17646
17686
|
memoryUserDir,
|
|
17647
17687
|
agentsDir: dot("agents"),
|
|
17648
17688
|
instructionFiles: o.lean ? false : o.instructionFiles ?? ["AGENTS.md", "CLAUDE.md"],
|
|
17689
|
+
// the user's global rules (~/.agent/AGENTS.md › AGENTX_EXTRA_DIRS/CLAUDE.md › ~/.claude/CLAUDE.md) — real disk only
|
|
17690
|
+
...o.lean || virtual ? {} : (() => {
|
|
17691
|
+
const f = userInstructionFiles({ cwd });
|
|
17692
|
+
return f.length ? { contextFiles: f.map((p) => ({ path: toVfsPath(p), label: "User instructions (global)" })) } : {};
|
|
17693
|
+
})(),
|
|
17649
17694
|
// Only override the Agent's safety defaults when explicitly configured.
|
|
17650
17695
|
...o.maxTokens != null ? { maxTokens: o.maxTokens } : {},
|
|
17651
17696
|
...o.timeoutMs != null ? { timeoutMs: o.timeoutMs } : {},
|
|
@@ -18096,27 +18141,27 @@ function takeCut(v, forVoiceLine) {
|
|
|
18096
18141
|
const cut = v?.takeInterruptedReply() ?? null;
|
|
18097
18142
|
return splitCut(forVoiceLine ? cut : null);
|
|
18098
18143
|
}
|
|
18099
|
-
function bindOverlapInstinct(v, instinct,
|
|
18144
|
+
function bindOverlapInstinct(v, instinct, live2, decideMs = 900) {
|
|
18100
18145
|
const o = v.options;
|
|
18101
18146
|
const { onDiag } = o;
|
|
18102
18147
|
o.overlapDecideMs = decideMs;
|
|
18103
18148
|
instinct.options.overlapSettleMs = 0;
|
|
18104
18149
|
o.onDiag = (ev) => {
|
|
18105
18150
|
onDiag(ev);
|
|
18106
|
-
if (!
|
|
18151
|
+
if (!live2()) return;
|
|
18107
18152
|
if (ev.kind === "overlap_pause") void instinct.overlap(String(ev.text ?? ""));
|
|
18108
18153
|
else if (/^(?:barge_in|overlap_resume|overlap_end|interrupt|tts_turn_begin)$/.test(ev.kind)) instinct.overlapEnded();
|
|
18109
18154
|
};
|
|
18110
18155
|
Object.assign(instinct.options, {
|
|
18111
18156
|
onYield: () => {
|
|
18112
|
-
if (!
|
|
18157
|
+
if (!live2()) return false;
|
|
18113
18158
|
if (v.decideOverlap("yield")) return;
|
|
18114
18159
|
if (!v.audible) return false;
|
|
18115
18160
|
v.interrupt();
|
|
18116
18161
|
o.onBargeIn("speaking");
|
|
18117
18162
|
},
|
|
18118
18163
|
// `heard` = what Jev judged: the engine absorbs only those words — a reaction that grows past them is re-decided.
|
|
18119
|
-
onKeepTalking: (heard) =>
|
|
18164
|
+
onKeepTalking: (heard) => live2() ? v.decideOverlap("keep_talking", heard) : false
|
|
18120
18165
|
});
|
|
18121
18166
|
}
|
|
18122
18167
|
function bindAckInstinct(v, instinct) {
|
|
@@ -18134,7 +18179,7 @@ function bindAckInstinct(v, instinct) {
|
|
|
18134
18179
|
onDiag(ev);
|
|
18135
18180
|
};
|
|
18136
18181
|
}
|
|
18137
|
-
function bindSecondChannel(v, sc,
|
|
18182
|
+
function bindSecondChannel(v, sc, live2) {
|
|
18138
18183
|
const o = v.options;
|
|
18139
18184
|
const { onPartial, onUtterance, onState, onBargeIn } = o;
|
|
18140
18185
|
let own = false;
|
|
@@ -18145,15 +18190,15 @@ function bindSecondChannel(v, sc, live) {
|
|
|
18145
18190
|
return r.queued.length ? { ...r, full: "", heard: "" } : null;
|
|
18146
18191
|
};
|
|
18147
18192
|
o.onPartial = (t) => {
|
|
18148
|
-
if (
|
|
18193
|
+
if (live2() && (own || !v.audible)) sc.onInterim(t);
|
|
18149
18194
|
onPartial(t);
|
|
18150
18195
|
};
|
|
18151
18196
|
o.onUtterance = ((t, meta) => {
|
|
18152
|
-
if (
|
|
18197
|
+
if (live2() && t.trim()) sc.onUserTurn(t);
|
|
18153
18198
|
onUtterance(t, meta);
|
|
18154
18199
|
});
|
|
18155
18200
|
o.onState = (s) => {
|
|
18156
|
-
if (
|
|
18201
|
+
if (live2() && !own) {
|
|
18157
18202
|
if (s === "speaking") sc.onAgentState("first_audio");
|
|
18158
18203
|
else if (s === "listening") sc.onAgentState("idle");
|
|
18159
18204
|
}
|
|
@@ -18165,14 +18210,14 @@ function bindSecondChannel(v, sc, live) {
|
|
|
18165
18210
|
};
|
|
18166
18211
|
const speakDelta = v.speakDelta.bind(v);
|
|
18167
18212
|
v.speakDelta = ((t, ...rest) => {
|
|
18168
|
-
if (
|
|
18213
|
+
if (live2()) sc.noteReply(t);
|
|
18169
18214
|
return speakDelta(t, ...rest);
|
|
18170
18215
|
});
|
|
18171
18216
|
Object.defineProperty(sc.options, "aec", { get: () => v.usingAec, set: () => {
|
|
18172
18217
|
}, enumerable: true, configurable: true });
|
|
18173
18218
|
Object.assign(sc.options, {
|
|
18174
18219
|
speak: (text, kind) => {
|
|
18175
|
-
if (!
|
|
18220
|
+
if (!live2() || v.audible) return false;
|
|
18176
18221
|
if (kind === "backchannel") return speakBlip(v, text);
|
|
18177
18222
|
own = true;
|
|
18178
18223
|
v.speakFiller(text);
|
|
@@ -18182,7 +18227,7 @@ function bindSecondChannel(v, sc, live) {
|
|
|
18182
18227
|
}
|
|
18183
18228
|
});
|
|
18184
18229
|
}
|
|
18185
|
-
function bindVoiceCall(v, call,
|
|
18230
|
+
function bindVoiceCall(v, call, live2, decideMs = 900) {
|
|
18186
18231
|
const o = v.options;
|
|
18187
18232
|
const { onPartial, onState, onBargeIn, onDiag } = o;
|
|
18188
18233
|
let own = false;
|
|
@@ -18209,17 +18254,17 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
|
|
|
18209
18254
|
v.takeInterruptedReply();
|
|
18210
18255
|
};
|
|
18211
18256
|
o.onPartial = (t) => {
|
|
18212
|
-
if (
|
|
18257
|
+
if (live2() && (own || !v.audible)) call.interim(t, performance.now(), v.usingAec);
|
|
18213
18258
|
onPartial(t);
|
|
18214
18259
|
};
|
|
18215
18260
|
o.onState = (s) => {
|
|
18216
|
-
if (
|
|
18261
|
+
if (live2() && !own && s === "speaking") call.main({ type: "audio" });
|
|
18217
18262
|
onState(s);
|
|
18218
18263
|
};
|
|
18219
18264
|
let filling = false;
|
|
18220
18265
|
const beginSpeech = v.beginSpeech.bind(v);
|
|
18221
18266
|
v.beginSpeech = ((...a) => {
|
|
18222
|
-
if (own && !filling &&
|
|
18267
|
+
if (own && !filling && live2()) {
|
|
18223
18268
|
own = false;
|
|
18224
18269
|
call.main({ type: "audio" }, v.player?.drainMs() ?? 0);
|
|
18225
18270
|
}
|
|
@@ -18227,16 +18272,16 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
|
|
|
18227
18272
|
});
|
|
18228
18273
|
o.onBargeIn = (phase) => {
|
|
18229
18274
|
held2 = void 0;
|
|
18230
|
-
if (
|
|
18275
|
+
if (live2()) call.barge();
|
|
18231
18276
|
onBargeIn(phase);
|
|
18232
18277
|
};
|
|
18233
18278
|
o.overlapDecideMs = decideMs;
|
|
18234
18279
|
o.onDiag = (ev) => {
|
|
18235
18280
|
onDiag(ev);
|
|
18236
|
-
if (!
|
|
18281
|
+
if (!live2() || ev.kind !== "overlap_pause") return;
|
|
18237
18282
|
const heard = String(ev.text ?? "");
|
|
18238
18283
|
void call.overlap(heard).then((verdict) => {
|
|
18239
|
-
if (!
|
|
18284
|
+
if (!live2()) return;
|
|
18240
18285
|
if (verdict === "keep") v.decideOverlap("keep_talking", heard, call.aside(heard) ?? void 0);
|
|
18241
18286
|
else if (verdict === "cut") v.decideOverlap("yield", heard);
|
|
18242
18287
|
});
|
|
@@ -18244,7 +18289,7 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
|
|
|
18244
18289
|
Object.defineProperty(call.fill.options, "aec", { get: () => v.usingAec, set: () => {
|
|
18245
18290
|
}, enumerable: true, configurable: true });
|
|
18246
18291
|
call.options.speak = (text, kind) => {
|
|
18247
|
-
if (!
|
|
18292
|
+
if (!live2() || v.audible) return false;
|
|
18248
18293
|
if (kind === "backchannel") return speakBlip(v, text);
|
|
18249
18294
|
own = true;
|
|
18250
18295
|
filling = true;
|
|
@@ -18716,14 +18761,14 @@ YOU PRESSED: ${s.pressed}` : ""}`).join("\n");
|
|
|
18716
18761
|
You placed this call and an automated phone menu is playing. What it said so far, oldest first:
|
|
18717
18762
|
${menu}
|
|
18718
18763
|
|
|
18719
|
-
Which key(s) do you press NOW for your task? Answer with only the keys (digits, * or #, e.g. "1" or "2#"), or WAIT when: the option for your task was not said yet, it is a greeting/recording/hold message, you already pressed for this same menu, or it asks
|
|
18764
|
+
Which key(s) do you press NOW for your task? Answer with only the keys (digits, * or #, e.g. "1" or "2#"), or WAIT when: the option for your task was not said yet, it is a greeting/recording/hold message, you already pressed for this same menu, or it asks you to type something (an ID, a code, a number) that is not written in your task above. Never guess or make up digits: an ID given in the task may be typed (with # when asked); a code the menu says it texted (SMS) is read for you: answer SMS (SMS# when it asks to end with #). After "wrong key"/"invalid choice", press the right menu key again.`;
|
|
18720
18765
|
}
|
|
18721
18766
|
/** "1", "2#", "WAIT", "Press 1." … → the keys, or '' (wait). */
|
|
18722
18767
|
static parse(raw) {
|
|
18723
18768
|
const t = raw.trim().replace(/^["'`]+|["'`.]+$/g, "");
|
|
18724
18769
|
if (/^wait\b/i.test(t)) return "";
|
|
18725
|
-
const m = t.match(/^(?:press\s*)?([0-9*#]{
|
|
18726
|
-
return m ? m[1] : "";
|
|
18770
|
+
const m = t.match(/^(?:press\s*)?((?:SMS)?[0-9*#]{0,12})$/i);
|
|
18771
|
+
return m && m[1] ? m[1].replace(/sms/i, "SMS") : "";
|
|
18727
18772
|
}
|
|
18728
18773
|
/** A menu line was heard: the keys to press now, or '' (wait). */
|
|
18729
18774
|
async hear(line) {
|
|
@@ -22129,8 +22174,8 @@ function makeRemoteTriggerTool(opts) {
|
|
|
22129
22174
|
if (!target) return `Error: no session matching '${id}' in the global index (~/.agent/sessions).`;
|
|
22130
22175
|
const full = target.meta.id;
|
|
22131
22176
|
if (opts.selfId && full === opts.selfId()) return "Error: that is THIS session \u2014 use Task/TaskBatch for self-delegation.";
|
|
22132
|
-
const
|
|
22133
|
-
if (
|
|
22177
|
+
const live2 = await triggerLive(full, { prompt: text, from: opts.selfId?.() }, dir);
|
|
22178
|
+
if (live2?.ok) return `Delivered to live session ${full} \u2014 it runs there; the user sees it in that terminal.`;
|
|
22134
22179
|
if (!target.meta.cwd || !existsSync8(target.meta.cwd)) return `Error: session ${full} has no reachable cwd (${target.meta.cwd ?? "unknown"}).`;
|
|
22135
22180
|
return new Promise((res) => {
|
|
22136
22181
|
const child = doSpawn(...headlessArgv(opts, text, full), {
|
|
@@ -22163,6 +22208,142 @@ ${answer || "(no output)"}` : `Error: headless run of ${full} exited ${code}: ${
|
|
|
22163
22208
|
};
|
|
22164
22209
|
}
|
|
22165
22210
|
|
|
22211
|
+
// cli/liveStatus.ts
|
|
22212
|
+
import { mkdirSync as mkdirSync12, renameSync as renameSync3, writeFileSync as writeFileSync9 } from "fs";
|
|
22213
|
+
import { homedir as homedir10 } from "os";
|
|
22214
|
+
import { join as join16 } from "path";
|
|
22215
|
+
var log47 = forComponent("live-status");
|
|
22216
|
+
var LiveStatusOptions = class {
|
|
22217
|
+
dir = join16(homedir10(), ".agent", "live");
|
|
22218
|
+
pid = process.pid;
|
|
22219
|
+
cwd = process.cwd();
|
|
22220
|
+
model = () => void 0;
|
|
22221
|
+
jobs = () => void 0;
|
|
22222
|
+
now = () => Date.now();
|
|
22223
|
+
};
|
|
22224
|
+
var LiveStatus = class {
|
|
22225
|
+
options;
|
|
22226
|
+
state = "idle";
|
|
22227
|
+
detail;
|
|
22228
|
+
sessionId;
|
|
22229
|
+
prompts = 0;
|
|
22230
|
+
denied;
|
|
22231
|
+
turns = 0;
|
|
22232
|
+
// turns in flight
|
|
22233
|
+
holds = 0;
|
|
22234
|
+
// open dispatch regions
|
|
22235
|
+
waits = 0;
|
|
22236
|
+
constructor(options) {
|
|
22237
|
+
this.options = { ...new LiveStatusOptions(), ...options };
|
|
22238
|
+
}
|
|
22239
|
+
get file() {
|
|
22240
|
+
return join16(this.options.dir, `${this.options.pid}.json`);
|
|
22241
|
+
}
|
|
22242
|
+
/** A turn, a dispatch region or a human wait is open (the REPL is not at rest). */
|
|
22243
|
+
get busy() {
|
|
22244
|
+
return this.turns > 0 || this.holds > 0 || this.waits > 0;
|
|
22245
|
+
}
|
|
22246
|
+
/** Session started or its id changed (/resume, /clear). */
|
|
22247
|
+
session(id) {
|
|
22248
|
+
this.sessionId = id;
|
|
22249
|
+
this.write();
|
|
22250
|
+
}
|
|
22251
|
+
/** A dispatch region opens: no `idle` until it closes. */
|
|
22252
|
+
hold() {
|
|
22253
|
+
this.holds++;
|
|
22254
|
+
}
|
|
22255
|
+
release() {
|
|
22256
|
+
this.holds = Math.max(0, this.holds - 1);
|
|
22257
|
+
this.settle();
|
|
22258
|
+
}
|
|
22259
|
+
/** A model turn starts. `machine` = not a human prompt (trigger / job wake / schedule): not counted. */
|
|
22260
|
+
turnStart(o = {}) {
|
|
22261
|
+
this.turns++;
|
|
22262
|
+
if (!o.machine) this.prompts++;
|
|
22263
|
+
this.denied = void 0;
|
|
22264
|
+
this.set("running", o.detail);
|
|
22265
|
+
}
|
|
22266
|
+
turnEnd() {
|
|
22267
|
+
this.turns = Math.max(0, this.turns - 1);
|
|
22268
|
+
this.settle();
|
|
22269
|
+
}
|
|
22270
|
+
/** A human wait (question, permission, confirm). Returns the release: back to running (or idle when nothing runs). */
|
|
22271
|
+
waiting(detail) {
|
|
22272
|
+
const prev = this.state === "waiting" ? void 0 : this.state;
|
|
22273
|
+
this.waits++;
|
|
22274
|
+
this.set("waiting", detail);
|
|
22275
|
+
let done = false;
|
|
22276
|
+
return () => {
|
|
22277
|
+
if (done) return;
|
|
22278
|
+
done = true;
|
|
22279
|
+
this.waits--;
|
|
22280
|
+
if (this.state === "exited" || this.waits > 0) return;
|
|
22281
|
+
this.set(this.turns > 0 ? "running" : prev ?? "idle");
|
|
22282
|
+
this.settle();
|
|
22283
|
+
};
|
|
22284
|
+
}
|
|
22285
|
+
/** Wrap a human wait. */
|
|
22286
|
+
async wait(detail, fn) {
|
|
22287
|
+
const end = this.waiting(detail);
|
|
22288
|
+
try {
|
|
22289
|
+
return await fn();
|
|
22290
|
+
} finally {
|
|
22291
|
+
end();
|
|
22292
|
+
}
|
|
22293
|
+
}
|
|
22294
|
+
/** The permission policy refused a tool: recorded on the current state until the next turn starts. */
|
|
22295
|
+
deny(d) {
|
|
22296
|
+
this.denied = d;
|
|
22297
|
+
this.write();
|
|
22298
|
+
}
|
|
22299
|
+
exited(detail) {
|
|
22300
|
+
if (this.state === "exited") return;
|
|
22301
|
+
this.set("exited", detail);
|
|
22302
|
+
}
|
|
22303
|
+
snapshot() {
|
|
22304
|
+
const jobs = this.options.jobs();
|
|
22305
|
+
return {
|
|
22306
|
+
state: this.state,
|
|
22307
|
+
...this.detail ? { detail: this.detail } : {},
|
|
22308
|
+
pid: this.options.pid,
|
|
22309
|
+
...this.sessionId ? { sessionId: this.sessionId } : {},
|
|
22310
|
+
cwd: this.options.cwd,
|
|
22311
|
+
...this.options.model() ? { model: this.options.model() } : {},
|
|
22312
|
+
prompts: this.prompts,
|
|
22313
|
+
...jobs !== void 0 ? { jobs } : {},
|
|
22314
|
+
...this.denied ? { denied: this.denied } : {},
|
|
22315
|
+
at: this.options.now()
|
|
22316
|
+
};
|
|
22317
|
+
}
|
|
22318
|
+
settle() {
|
|
22319
|
+
if (this.state === "exited" || this.turns > 0 || this.holds > 0 || this.waits > 0) return;
|
|
22320
|
+
if (this.state !== "idle") this.set("idle");
|
|
22321
|
+
}
|
|
22322
|
+
set(state, detail) {
|
|
22323
|
+
if (this.state === "exited") return;
|
|
22324
|
+
this.state = state;
|
|
22325
|
+
this.detail = detail;
|
|
22326
|
+
this.write();
|
|
22327
|
+
}
|
|
22328
|
+
write() {
|
|
22329
|
+
try {
|
|
22330
|
+
mkdirSync12(this.options.dir, { recursive: true, mode: 448 });
|
|
22331
|
+
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
22332
|
+
writeFileSync9(tmp, JSON.stringify(this.snapshot()) + "\n");
|
|
22333
|
+
renameSync3(tmp, this.file);
|
|
22334
|
+
} catch (e) {
|
|
22335
|
+
log47.debug("live status write failed", e);
|
|
22336
|
+
}
|
|
22337
|
+
}
|
|
22338
|
+
};
|
|
22339
|
+
var live;
|
|
22340
|
+
function setLive(s) {
|
|
22341
|
+
live = s;
|
|
22342
|
+
}
|
|
22343
|
+
function liveWait(detail, fn) {
|
|
22344
|
+
return live ? live.wait(detail, fn) : fn();
|
|
22345
|
+
}
|
|
22346
|
+
|
|
22166
22347
|
// cli/cli.ts
|
|
22167
22348
|
var forceColor = process.env.FORCE_COLOR != null && process.env.FORCE_COLOR !== "" && process.env.FORCE_COLOR !== "0";
|
|
22168
22349
|
var useColor = forceColor || !process.env.NO_COLOR && !!process.stdout.isTTY && !!process.stderr.isTTY;
|
|
@@ -22179,7 +22360,7 @@ var strike = C("9");
|
|
|
22179
22360
|
var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
|
|
22180
22361
|
var mdPalette = { bold, dim, cyan, italic, strike, green, link };
|
|
22181
22362
|
var err = (s) => process.stderr.write(s);
|
|
22182
|
-
var
|
|
22363
|
+
var log48 = forComponent("cli");
|
|
22183
22364
|
var VERSION = (() => {
|
|
22184
22365
|
try {
|
|
22185
22366
|
return JSON.parse(readFileSync10(new URL("../package.json", import.meta.url), "utf8")).version ?? "?";
|
|
@@ -22305,7 +22486,12 @@ function parseArgs(argv) {
|
|
|
22305
22486
|
else if (x === "--plan") a.plan = true;
|
|
22306
22487
|
else if (x === "--ask") a.ask = true;
|
|
22307
22488
|
else if (x === "--yes" || x === "-y") a.yes = true;
|
|
22308
|
-
else if (x === "--
|
|
22489
|
+
else if (x === "--trust") a.trust = true;
|
|
22490
|
+
else if (x === "--prompt") {
|
|
22491
|
+
a.prompt = argv.slice(i + 1).join(" ").trim();
|
|
22492
|
+
if (!a.prompt) throw new Error("--prompt requires a value (and must be the last argument)");
|
|
22493
|
+
break;
|
|
22494
|
+
} else if (x === "--vfs" || x === "--sandbox") a.vfs = true;
|
|
22309
22495
|
else if (x === "--scratch") a.scratch = true;
|
|
22310
22496
|
else if (x === "--no-scratch") a.scratch = false;
|
|
22311
22497
|
else if (x === "--update") a.update = true;
|
|
@@ -22390,6 +22576,7 @@ function parseArgs(argv) {
|
|
|
22390
22576
|
if (a.boddb && a.vfs) throw new Error("--boddb and --sandbox are mutually exclusive (both are non-disk filesystems; pick one)");
|
|
22391
22577
|
if (a.seed && !a.boddb) throw new Error("--seed only applies with --boddb (it seeds the database from cwd on first run)");
|
|
22392
22578
|
if (a.worktree && (a.vfs || a.boddb)) throw new Error("--worktree is a real-disk concept \u2014 incompatible with --vfs/--boddb");
|
|
22579
|
+
if (a.prompt !== void 0 && (a.task || a.print)) throw new Error("--prompt seeds an interactive session \u2014 drop the task/-p (a task runs one-shot and exits)");
|
|
22393
22580
|
if (a.duplex && (a.task || a.print)) throw new Error("--duplex is interactive-only (a conversational mode) \u2014 drop the task/-p");
|
|
22394
22581
|
if (a.inputFormat && (!a.duplex && !a.print && !a.channelOnly || a.outputFormat !== "stream-json")) throw new Error("--input-format stream-json needs --output-format stream-json and --duplex (or --voice), --channel-only or -p");
|
|
22395
22582
|
if (a.keepAlive && (!a.print || !a.inputFormat)) throw new Error("--keep-alive needs -p --input-format stream-json --output-format stream-json");
|
|
@@ -22443,6 +22630,8 @@ Flags:
|
|
|
22443
22630
|
--ask confirm each mutating tool (bash/Shell/Write/Edit/\u2026) \u2014 needs a terminal to
|
|
22444
22631
|
approve on; rejected up front when detached (use --yes / permissions rules)
|
|
22445
22632
|
--yes, -y auto-approve mutating tools (no prompts) \u2014 for trusted/unattended runs
|
|
22633
|
+
--trust trust this directory without asking (permission prompts unchanged)
|
|
22634
|
+
--prompt <text> start the REPL with this line typed in (/slash and /skill expand), stay open \u2014 LAST arg: the rest of argv is the text
|
|
22446
22635
|
--update check for updates and install if available (no keys needed)
|
|
22447
22636
|
--no-update-check skip the automatic update check on startup
|
|
22448
22637
|
--verbose, --debug verbose logs (sets DEBUG=* \u2014 tool args, hook decisions, retries)
|
|
@@ -22594,10 +22783,10 @@ function loadEnvFile(file) {
|
|
|
22594
22783
|
}
|
|
22595
22784
|
function loadInstallEnv() {
|
|
22596
22785
|
let dir = dirname6(import.meta.path);
|
|
22597
|
-
for (let i = 0; i < 5 && !existsSync9(
|
|
22786
|
+
for (let i = 0; i < 5 && !existsSync9(join17(dir, "package.json")); i++) dir = dirname6(dir);
|
|
22598
22787
|
for (const name of [".env", ".env.local"]) {
|
|
22599
|
-
loadEnvFile(
|
|
22600
|
-
loadEnvFile(
|
|
22788
|
+
loadEnvFile(join17(dir, name));
|
|
22789
|
+
loadEnvFile(join17(homedir11(), ".agent", name));
|
|
22601
22790
|
}
|
|
22602
22791
|
}
|
|
22603
22792
|
function paraVaultToken() {
|
|
@@ -22636,20 +22825,19 @@ function apiKeysFromEnv() {
|
|
|
22636
22825
|
}
|
|
22637
22826
|
return keys;
|
|
22638
22827
|
}
|
|
22639
|
-
var KEYLESS_PROVIDERS = /* @__PURE__ */ new Set(["claude-code"]);
|
|
22640
22828
|
function modelUsable(model, apiKeys) {
|
|
22641
22829
|
const p = model.split("/")[0];
|
|
22642
|
-
return
|
|
22830
|
+
return isKeyless(p) || !!apiKeys[p];
|
|
22643
22831
|
}
|
|
22644
22832
|
function duplexModels(o) {
|
|
22645
22833
|
const dflt = new DuplexAgentOptions(), notes = [];
|
|
22646
|
-
const cc = o.actModel
|
|
22834
|
+
const cc = isClaudeCode(o.actModel), anthropic = !!o.apiKeys.anthropic;
|
|
22647
22835
|
const why = (m) => `no ${m.split("/")[0].toUpperCase()}_API_KEY`;
|
|
22648
22836
|
const asked = o.voiceModel ?? o.reflexModel;
|
|
22649
22837
|
let reflexModel = asked ? resolveModelOrNewest(asked) : void 0;
|
|
22650
22838
|
const reflex = reflexModel ?? dflt.reflexModel;
|
|
22651
22839
|
if (!modelUsable(reflex, o.apiKeys)) {
|
|
22652
|
-
const to = anthropic ? latestClaude("haiku") : cc ? "claude-code/haiku" : o.actModel
|
|
22840
|
+
const to = anthropic ? latestClaude("haiku") : cc ? "claude-code/haiku" : isCursor(o.actModel) ? void 0 : o.actModel;
|
|
22653
22841
|
if (to) reflexModel = to;
|
|
22654
22842
|
notes.push(`voice model ${reflex} can't run here (${why(reflex)})${to ? ` \u2014 using ${to}` : ""}`);
|
|
22655
22843
|
}
|
|
@@ -22780,14 +22968,16 @@ function makeHost(format = "text", opts) {
|
|
|
22780
22968
|
`));
|
|
22781
22969
|
},
|
|
22782
22970
|
async confirm(prompt) {
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22971
|
+
return liveWait(`confirm: ${prompt}`, async () => {
|
|
22972
|
+
const v = await selectMenu(process.stderr, { title: `? ${prompt}`, items: [{ label: "Yes", value: "y" }, { label: "No", value: "n" }], current: "n" });
|
|
22973
|
+
if (v !== null) return v === "y";
|
|
22974
|
+
const io = createInterface({ input: keyInput, output: process.stderr });
|
|
22975
|
+
try {
|
|
22976
|
+
return /^y(es)?$/i.test((await io.question(yellow(` ? ${prompt} [y/N] `))).trim());
|
|
22977
|
+
} finally {
|
|
22978
|
+
io.close();
|
|
22979
|
+
}
|
|
22980
|
+
});
|
|
22791
22981
|
},
|
|
22792
22982
|
// Only offer `ask` when a human can actually SEE the prompt. Headless/piped (`-p`, redirected,
|
|
22793
22983
|
// no TTY) → omit it: AskUserQuestion then parks the question and ends the run with
|
|
@@ -22798,18 +22988,20 @@ function makeHost(format = "text", opts) {
|
|
|
22798
22988
|
async ask(q2) {
|
|
22799
22989
|
const title = `? ${q2.header ? "[" + q2.header + "] " : ""}${q2.question}`;
|
|
22800
22990
|
spinner.stop();
|
|
22801
|
-
|
|
22802
|
-
|
|
22803
|
-
|
|
22804
|
-
|
|
22805
|
-
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
22811
|
-
|
|
22812
|
-
|
|
22991
|
+
return liveWait(`question: ${q2.question}`, async () => {
|
|
22992
|
+
const v = await selectMenu(process.stderr, { title, items: q2.options.map((o) => ({ label: o.label, value: o.label, desc: o.description })) });
|
|
22993
|
+
if (v !== null) return v;
|
|
22994
|
+
const io = createInterface({ input: keyInput, output: process.stderr });
|
|
22995
|
+
try {
|
|
22996
|
+
const lines = [yellow(" " + title)];
|
|
22997
|
+
q2.options.forEach((o, i) => lines.push(` ${i + 1}) ${o.label}${o.description ? dim(" \u2014 " + o.description) : ""}`));
|
|
22998
|
+
const ans = (await io.question(lines.join("\n") + "\n > ")).trim();
|
|
22999
|
+
const n = Number(ans);
|
|
23000
|
+
return Number.isInteger(n) && q2.options[n - 1] ? q2.options[n - 1].label : ans;
|
|
23001
|
+
} finally {
|
|
23002
|
+
io.close();
|
|
23003
|
+
}
|
|
23004
|
+
});
|
|
22813
23005
|
}
|
|
22814
23006
|
} : {}
|
|
22815
23007
|
};
|
|
@@ -23096,10 +23288,10 @@ function autoRouteSend(args, agent, session, pof) {
|
|
|
23096
23288
|
};
|
|
23097
23289
|
}
|
|
23098
23290
|
function turnCost(model, usage) {
|
|
23099
|
-
const priced = model
|
|
23291
|
+
const priced = isClaudeCode(model) ? `anthropic/${resolveModelAlias(model.slice("claude-code/".length))}` : model;
|
|
23100
23292
|
return costOf(getModelInfo(priced)?.pricing, usage?.promptTokens ?? 0, usage?.completionTokens ?? 0, usage?.cacheCreationTokens ?? 0, usage?.cacheReadTokens ?? 0, priced);
|
|
23101
23293
|
}
|
|
23102
|
-
async function evaluateGoal(ai, condition, transcript,
|
|
23294
|
+
async function evaluateGoal(ai, condition, transcript, log49) {
|
|
23103
23295
|
const recent = transcript.filter((m) => m.role === "assistant").slice(-8).map((m) => {
|
|
23104
23296
|
const text = typeof m.content === "string" ? m.content : m.content.filter((p) => p.type === "text").map((p) => p.text).join(" ");
|
|
23105
23297
|
return text.slice(0, 600);
|
|
@@ -23119,7 +23311,7 @@ ${recent}` }
|
|
|
23119
23311
|
const match = r.content.match(/\{[\s\S]*\}/);
|
|
23120
23312
|
if (match) return JSON.parse(match[0]);
|
|
23121
23313
|
} catch (e) {
|
|
23122
|
-
|
|
23314
|
+
log49(dim(` (goal evaluator error: ${e?.message ?? e})
|
|
23123
23315
|
`));
|
|
23124
23316
|
}
|
|
23125
23317
|
return { met: false, reason: "evaluation unclear" };
|
|
@@ -23189,7 +23381,12 @@ function resolvePermMode(args, interactiveCapable) {
|
|
|
23189
23381
|
if (interactiveCapable && args.outputFormat === "text") return { gate: "ask" };
|
|
23190
23382
|
return { gate: "allow", notice: "unattended: mutating tools auto-approved \u2014 pass --ask to gate, --vfs to sandbox, --yes to silence" };
|
|
23191
23383
|
}
|
|
23384
|
+
var liveDeny = (call, reason) => live?.deny({ tool: call.name, what: summarizeCall(call.name, call.args).slice(0, 120), reason });
|
|
23192
23385
|
function makeAskResolver(cwd) {
|
|
23386
|
+
const resolve1 = askResolver(cwd);
|
|
23387
|
+
return (call) => canPrompt ? liveWait(`permission: ${call.name}`, () => resolve1(call)) : resolve1(call);
|
|
23388
|
+
}
|
|
23389
|
+
function askResolver(cwd) {
|
|
23193
23390
|
return async (call) => {
|
|
23194
23391
|
if (!canPrompt) {
|
|
23195
23392
|
err(dim(` \u26A0 ${call.name} needs approval but no terminal is attached \u2014 denied. Use --yes, or an allow rule in .agent/permissions.json.
|
|
@@ -23270,7 +23467,7 @@ function optsFor(args, ai, cfg = {}, extraTools = []) {
|
|
|
23270
23467
|
stream: args.stream,
|
|
23271
23468
|
host: makeHost(args.outputFormat, { stream: true }),
|
|
23272
23469
|
planMode: args.plan || cfg.planMode || false,
|
|
23273
|
-
permissions: rules.length || args.onlyTools ? new PermissionPolicy({ rules, default: args.onlyTools ? "deny" : "allow", host: makeHost(), ask: makeAskResolver(resolve5(args.cwd ?? process.cwd())) }) : void 0,
|
|
23470
|
+
permissions: rules.length || args.onlyTools ? new PermissionPolicy({ rules, default: args.onlyTools ? "deny" : "allow", host: makeHost(), ask: makeAskResolver(resolve5(args.cwd ?? process.cwd())), onDeny: liveDeny }) : void 0,
|
|
23274
23471
|
subagents: args.subagents || cfg.subagents || false,
|
|
23275
23472
|
maxSteps: args.maxSteps ?? cfg.maxSteps,
|
|
23276
23473
|
reasoning: args.reasoning ?? cfg.reasoning,
|
|
@@ -23348,13 +23545,13 @@ function mcpAgentTools(mounted, opts) {
|
|
|
23348
23545
|
return tools;
|
|
23349
23546
|
}
|
|
23350
23547
|
async function closeMcp(mounted) {
|
|
23351
|
-
await Promise.all(mounted.map((m) => m.client.close().catch((e) =>
|
|
23548
|
+
await Promise.all(mounted.map((m) => m.client.close().catch((e) => log48.debug("mcp close failed", e))));
|
|
23352
23549
|
}
|
|
23353
23550
|
var IMG_EXT = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
|
|
23354
23551
|
function mentionRefs(line) {
|
|
23355
23552
|
return [...line.matchAll(/(?:^|\s)@(?:"([^"]+)"|(\S+))/g)].map((m) => m[1] ?? m[2].replace(/[?!.,;:)\]}'">]+$/, "")).filter(Boolean);
|
|
23356
23553
|
}
|
|
23357
|
-
var untilde = (p) => p.startsWith("~/") || IS_WIN && p.startsWith("~\\") ?
|
|
23554
|
+
var untilde = (p) => p.startsWith("~/") || IS_WIN && p.startsWith("~\\") ? join17(homedir11(), p.slice(2)) : p;
|
|
23358
23555
|
var PATH_LIKE = IS_WIN ? /^(\/|~[\\/]|\.\.?[\\/]|[A-Za-z]:[\\/]|\\\\)/ : /^(\/|~\/|\.\/|\.\.\/)/;
|
|
23359
23556
|
var userPath = (cwd, p) => {
|
|
23360
23557
|
const t = untilde(p);
|
|
@@ -23407,7 +23604,7 @@ async function expandMentions(fs, line) {
|
|
|
23407
23604
|
if (loaded.includes(ref) || missing.includes(ref)) continue;
|
|
23408
23605
|
if (ref.includes(":") && mcpMentionResolver) {
|
|
23409
23606
|
const body = await mcpMentionResolver(ref).catch((e) => {
|
|
23410
|
-
|
|
23607
|
+
log48.debug("mcp mention resolve failed", e);
|
|
23411
23608
|
return null;
|
|
23412
23609
|
});
|
|
23413
23610
|
if (body != null) {
|
|
@@ -23433,7 +23630,7 @@ ${await fs.readFile(path)}`);
|
|
|
23433
23630
|
${blocks.join("\n\n")}` : line, loaded, missing };
|
|
23434
23631
|
}
|
|
23435
23632
|
function applyTurnMode(agent, session, task, flags = {}, onModel) {
|
|
23436
|
-
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) =>
|
|
23633
|
+
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log48.debug(m) });
|
|
23437
23634
|
const d = p.directives, isMode = !!(d.delegate || d.advisor || d.modeOff);
|
|
23438
23635
|
if (p.unresolvedModel && /->|<-|delegate:|advisor:/.test(task.slice(0, task.length - p.prompt.length))) {
|
|
23439
23636
|
err(red(` \u2717 unknown model "${p.unresolvedModel}"${p.ambiguous ? ` (could be: ${p.ambiguous.join(", ")})` : ""} \u2014 turn not sent
|
|
@@ -23526,7 +23723,7 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
|
|
|
23526
23723
|
try {
|
|
23527
23724
|
store.save(session);
|
|
23528
23725
|
} catch (ex) {
|
|
23529
|
-
|
|
23726
|
+
log48.debug("mid-turn session flush failed", ex);
|
|
23530
23727
|
}
|
|
23531
23728
|
}
|
|
23532
23729
|
return origNotify(e);
|
|
@@ -23609,7 +23806,7 @@ function bindClaudeCodeSession(agent, session) {
|
|
|
23609
23806
|
session.meta.cc = ok && id ? { id, n: agent.transcript.length, model } : void 0;
|
|
23610
23807
|
};
|
|
23611
23808
|
}
|
|
23612
|
-
var remintSessionImages = (data, store, cwd) => remintImageRefs(data.messages, [
|
|
23809
|
+
var remintSessionImages = (data, store, cwd) => remintImageRefs(data.messages, [join17(store.dir, `${data.meta.id}.images`), cwd]);
|
|
23613
23810
|
function startSession(args, store, agent, cwd) {
|
|
23614
23811
|
if (args.resume || args.cont) {
|
|
23615
23812
|
const data = args.resume ? store.load(args.resume) ?? globalSessionLoad(args.resume) : store.latestData();
|
|
@@ -23656,25 +23853,25 @@ var AGENTS_MD_TEMPLATE = `# ${"${name}"}
|
|
|
23656
23853
|
`;
|
|
23657
23854
|
function initInstructions(cwd) {
|
|
23658
23855
|
for (const f of ["AGENTS.md", "CLAUDE.md"]) {
|
|
23659
|
-
if (existsSync9(
|
|
23856
|
+
if (existsSync9(join17(cwd, f))) {
|
|
23660
23857
|
err(yellow(` ${f} already exists \u2014 leaving it as-is
|
|
23661
23858
|
`));
|
|
23662
23859
|
return;
|
|
23663
23860
|
}
|
|
23664
23861
|
}
|
|
23665
|
-
const path =
|
|
23666
|
-
|
|
23862
|
+
const path = join17(cwd, "AGENTS.md");
|
|
23863
|
+
writeFileSync10(path, AGENTS_MD_TEMPLATE.replace("${name}", basename4(cwd)));
|
|
23667
23864
|
err(green(` created ${path}
|
|
23668
23865
|
`) + dim(" edit it, then it auto-loads into every run.\n"));
|
|
23669
23866
|
}
|
|
23670
23867
|
function persistSetting(cwd, key, value) {
|
|
23671
|
-
const path =
|
|
23868
|
+
const path = join17(cwd, ".agent", "settings.json");
|
|
23672
23869
|
try {
|
|
23673
23870
|
const obj = existsSync9(path) ? JSON.parse(readFileSync10(path, "utf8")) : {};
|
|
23674
23871
|
if (obj[key] === value) return;
|
|
23675
23872
|
obj[key] = value;
|
|
23676
|
-
|
|
23677
|
-
|
|
23873
|
+
mkdirSync13(dirname6(path), { recursive: true });
|
|
23874
|
+
writeFileSync10(path, JSON.stringify(obj, null, 2) + "\n");
|
|
23678
23875
|
} catch (e) {
|
|
23679
23876
|
err(yellow(` \u26A0 couldn't persist ${key} to ${path} \u2014 ${e?.message ?? e}
|
|
23680
23877
|
`));
|
|
@@ -23690,23 +23887,24 @@ var isCancelTeardown = (e) => {
|
|
|
23690
23887
|
function installCancelGuards(mounted) {
|
|
23691
23888
|
process.on("unhandledRejection", (e) => {
|
|
23692
23889
|
if (isCancelTeardown(e)) {
|
|
23693
|
-
|
|
23890
|
+
log48.debug("suppressed unhandledRejection (cursor stream cancel)", e);
|
|
23694
23891
|
return;
|
|
23695
23892
|
}
|
|
23696
|
-
|
|
23893
|
+
log48.error("unhandledRejection", e);
|
|
23697
23894
|
});
|
|
23698
23895
|
process.on("uncaughtException", (e) => {
|
|
23699
23896
|
if (isCancelTeardown(e)) {
|
|
23700
|
-
|
|
23897
|
+
log48.debug("suppressed uncaughtException (cursor stream cancel)", e);
|
|
23701
23898
|
return;
|
|
23702
23899
|
}
|
|
23703
23900
|
console.error(e);
|
|
23901
|
+
live?.exited("crash");
|
|
23704
23902
|
void closeMcp(mounted);
|
|
23705
23903
|
process.exit(1);
|
|
23706
23904
|
});
|
|
23707
23905
|
}
|
|
23708
23906
|
async function repl(args, ai, cfg, cwd) {
|
|
23709
|
-
const oauth = new McpOAuth({ storePath:
|
|
23907
|
+
const oauth = new McpOAuth({ storePath: join17(cwd, ".agent", "mcp-auth.json") });
|
|
23710
23908
|
const mounted = await mountMcp(cfg, oauth);
|
|
23711
23909
|
let mcpToolNames = [];
|
|
23712
23910
|
const initialMcpTools = mcpAgentTools(mounted);
|
|
@@ -23816,11 +24014,11 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
23816
24014
|
const hint = summarizeCall(call2.name, call2.args).slice(0, 80);
|
|
23817
24015
|
if (cfg.voiceAskUi !== "relay") {
|
|
23818
24016
|
editorRef?.suspend();
|
|
23819
|
-
const v = await selectMenu(process.stderr, {
|
|
24017
|
+
const v = await liveWait(`permission: ${call2.name}`, () => selectMenu(process.stderr, {
|
|
23820
24018
|
title: `? background worker asks to run ${call2.name} ${hint}`,
|
|
23821
24019
|
items: [{ label: "Allow once", value: "y" }, { label: "Allow always", value: "a" }, { label: "Deny", value: "n" }],
|
|
23822
24020
|
current: "y"
|
|
23823
|
-
});
|
|
24021
|
+
}));
|
|
23824
24022
|
editorRef?.resume();
|
|
23825
24023
|
editorRef?.redrawNow();
|
|
23826
24024
|
if (v === "a") {
|
|
@@ -23981,14 +24179,14 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
23981
24179
|
onTaskStart: async (_id, label) => {
|
|
23982
24180
|
await checkpoints.begin(label);
|
|
23983
24181
|
},
|
|
23984
|
-
lookRoots: [
|
|
24182
|
+
lookRoots: [homedir11(), join17(homedir11(), "Documents")],
|
|
23985
24183
|
// QuickLook: a spoken "Projects/X" usually means ~/Documents/Projects/X
|
|
23986
24184
|
// The jail deny-lists .git/** (VCS internals can carry credentials), so the engine's fs-based
|
|
23987
24185
|
// 'branch' lookup can't see it — supply it host-side (one safe read-only file).
|
|
23988
24186
|
quickLook: {
|
|
23989
24187
|
branch: () => {
|
|
23990
24188
|
try {
|
|
23991
|
-
const head = readFileSync10(
|
|
24189
|
+
const head = readFileSync10(join17(cwd, ".git", "HEAD"), "utf8").trim();
|
|
23992
24190
|
return head.startsWith("ref: refs/heads/") ? `branch: ${head.slice("ref: refs/heads/".length)}` : `detached HEAD at ${head.slice(0, 12)}`;
|
|
23993
24191
|
} catch {
|
|
23994
24192
|
return "not a git repository";
|
|
@@ -24117,7 +24315,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
24117
24315
|
editorRef?.abort();
|
|
24118
24316
|
}
|
|
24119
24317
|
} catch (e) {
|
|
24120
|
-
|
|
24318
|
+
log48.error("call turn failed", e);
|
|
24121
24319
|
} finally {
|
|
24122
24320
|
rec.running = false;
|
|
24123
24321
|
call?.main({ type: "done", id });
|
|
@@ -24179,7 +24377,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
24179
24377
|
const applyPosture = (p) => {
|
|
24180
24378
|
posture = p;
|
|
24181
24379
|
const ask = p === "acceptEdits" ? askFor(["bash", "Shell"]) : askFor(ASK_MUTATING);
|
|
24182
|
-
work.permissions = new PermissionPolicy({ rules: [...baseRules(), ...ask], default: "allow", host: duplex ? void 0 : makeHost(), ask: duplex ? duplexAsk : makeAskResolver(cwd) });
|
|
24380
|
+
work.permissions = new PermissionPolicy({ rules: [...baseRules(), ...ask], default: "allow", host: duplex ? void 0 : makeHost(), ask: duplex ? duplexAsk : makeAskResolver(cwd), onDeny: liveDeny });
|
|
24183
24381
|
if (!duplex) {
|
|
24184
24382
|
agent.options.planMode = p === "plan";
|
|
24185
24383
|
agent.reprepare();
|
|
@@ -24267,16 +24465,17 @@ ${SPOKEN_TURN}`, { id });
|
|
|
24267
24465
|
const pendingImages = [];
|
|
24268
24466
|
const bangContext = [];
|
|
24269
24467
|
const grabClipboardAttachment = () => {
|
|
24270
|
-
const dir =
|
|
24468
|
+
const dir = join17(store.dir, `${session.meta.id}.images`);
|
|
24271
24469
|
try {
|
|
24272
|
-
|
|
24470
|
+
mkdirSync13(dir, { recursive: true });
|
|
24273
24471
|
} catch (e) {
|
|
24274
|
-
|
|
24472
|
+
log48.debug("paste image dir create failed", e);
|
|
24275
24473
|
}
|
|
24276
24474
|
const img = grabClipboardImage(dir, String(Date.now()));
|
|
24277
24475
|
return img ? { display: "Image", ref: "@" + img.path, path: img.path } : null;
|
|
24278
24476
|
};
|
|
24279
24477
|
const forceQuit = (code = 130) => {
|
|
24478
|
+
live?.exited(code === 130 ? "force-quit" : `exit ${code}`);
|
|
24280
24479
|
try {
|
|
24281
24480
|
voiceIO?.stop();
|
|
24282
24481
|
} catch {
|
|
@@ -24305,6 +24504,8 @@ ${SPOKEN_TURN}`, { id });
|
|
|
24305
24504
|
}
|
|
24306
24505
|
forceQuit();
|
|
24307
24506
|
});
|
|
24507
|
+
process.on("SIGHUP", () => forceQuit(129));
|
|
24508
|
+
process.on("SIGTERM", () => forceQuit(143));
|
|
24308
24509
|
installCancelGuards(mounted);
|
|
24309
24510
|
setMcpMentionResolver(async (ref) => {
|
|
24310
24511
|
const i = ref.indexOf(":");
|
|
@@ -24319,13 +24520,15 @@ ${SPOKEN_TURN}`, { id });
|
|
|
24319
24520
|
const store = new SessionStore(cwd);
|
|
24320
24521
|
let session = startSession(args, store, face, cwd);
|
|
24321
24522
|
triggerServer.start(session.meta.id);
|
|
24523
|
+
setLive(new LiveStatus({ cwd, model: () => session.meta.model ?? agent.options.model, jobs: () => agent.jobs.list().filter((j) => j.status === "running").length }));
|
|
24524
|
+
live.session(session.meta.id);
|
|
24322
24525
|
setTermTitle(`agentx \xB7 ${session.meta.title || cwd.split("/").pop() || "session"}`);
|
|
24323
24526
|
if (session.meta.scheduledJobs?.length) {
|
|
24324
24527
|
scheduler.restore(session.meta.scheduledJobs);
|
|
24325
24528
|
err(dim(` \u23F0 ${scheduler.size} scheduled job(s) re-armed
|
|
24326
24529
|
`));
|
|
24327
24530
|
}
|
|
24328
|
-
const checkpoints = args.vfs || args.boddb ? new CheckpointStack(agent.options.fs) : new GitCheckpoints({ workTree: cwd, gitDir:
|
|
24531
|
+
const checkpoints = args.vfs || args.boddb ? new CheckpointStack(agent.options.fs) : new GitCheckpoints({ workTree: cwd, gitDir: join17(cwd, ".agent", "checkpoints.git"), addDirs: args.addDirs, sessionId: session.meta.id });
|
|
24329
24532
|
const cpHooks = checkpoints.hooks?.();
|
|
24330
24533
|
if (cpHooks) {
|
|
24331
24534
|
agent.options.hooks = composeHooks(agent.options.hooks, cpHooks);
|
|
@@ -24377,14 +24580,14 @@ ${lines.join("\n")}
|
|
|
24377
24580
|
Added entries are loadable now via the Skill/SlashCommand tools; removed ones are gone even if still listed in the system prompt.
|
|
24378
24581
|
</system-reminder>`;
|
|
24379
24582
|
};
|
|
24380
|
-
const histPath =
|
|
24583
|
+
const histPath = join17(cwd, ".agent", "history");
|
|
24381
24584
|
const history = existsSync9(histPath) ? readFileSync10(histPath, "utf8").split("\n").filter(Boolean).reverse().slice(0, 500) : [];
|
|
24382
24585
|
const remember2 = (line) => {
|
|
24383
24586
|
try {
|
|
24384
|
-
|
|
24587
|
+
mkdirSync13(join17(cwd, ".agent"), { recursive: true });
|
|
24385
24588
|
appendFileSync2(histPath, line + "\n");
|
|
24386
24589
|
} catch (e) {
|
|
24387
|
-
|
|
24590
|
+
log48.debug("history write failed", e);
|
|
24388
24591
|
}
|
|
24389
24592
|
};
|
|
24390
24593
|
const ago = (t) => {
|
|
@@ -24397,6 +24600,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
24397
24600
|
session = data;
|
|
24398
24601
|
checkpoints.use?.(data.meta.id);
|
|
24399
24602
|
triggerServer.use(data.meta.id);
|
|
24603
|
+
live?.session(data.meta.id);
|
|
24400
24604
|
const m = data.meta;
|
|
24401
24605
|
goalCondition = m.goalCondition;
|
|
24402
24606
|
goalTurns = m.goalTurns ?? 0;
|
|
@@ -24456,7 +24660,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
24456
24660
|
try {
|
|
24457
24661
|
store.save(session);
|
|
24458
24662
|
} catch (e) {
|
|
24459
|
-
|
|
24663
|
+
log48.debug("session save after rewind failed", e);
|
|
24460
24664
|
}
|
|
24461
24665
|
err(green(" \u27F2 jumped back") + dim(` \u2014 ${face.transcript.length} message(s) kept; edit + resend
|
|
24462
24666
|
`));
|
|
@@ -24484,6 +24688,14 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
24484
24688
|
const announcedTasks = /* @__PURE__ */ new Set();
|
|
24485
24689
|
const replacedVoiceTurns = /* @__PURE__ */ new Set();
|
|
24486
24690
|
const turn = async (task, opts) => {
|
|
24691
|
+
live?.turnStart({ machine: opts?.machine });
|
|
24692
|
+
try {
|
|
24693
|
+
return await turnBody(task, opts);
|
|
24694
|
+
} finally {
|
|
24695
|
+
live?.turnEnd();
|
|
24696
|
+
}
|
|
24697
|
+
};
|
|
24698
|
+
const turnBody = async (task, opts) => {
|
|
24487
24699
|
if (bangContext.length) {
|
|
24488
24700
|
task = `${bangContext.join("\n\n")}
|
|
24489
24701
|
|
|
@@ -24491,7 +24703,7 @@ ${task}`;
|
|
|
24491
24703
|
bangContext.length = 0;
|
|
24492
24704
|
}
|
|
24493
24705
|
const delta = await refreshCatalogs().catch((e) => {
|
|
24494
|
-
|
|
24706
|
+
log48.debug("catalog refresh failed", e);
|
|
24495
24707
|
return "";
|
|
24496
24708
|
});
|
|
24497
24709
|
if (delta) {
|
|
@@ -24523,7 +24735,15 @@ ${task}`;
|
|
|
24523
24735
|
}
|
|
24524
24736
|
return r;
|
|
24525
24737
|
};
|
|
24526
|
-
scheduleTurn = turn;
|
|
24738
|
+
scheduleTurn = (prompt) => turn(prompt, { machine: true });
|
|
24739
|
+
if (!duplex) agent.options.onInject = () => setImmediate(() => {
|
|
24740
|
+
if (activeTurn || dispatchPending || live?.busy || exitRequested) return;
|
|
24741
|
+
const notes = agent.drainPendingSteers();
|
|
24742
|
+
if (!notes.length) return;
|
|
24743
|
+
err(dim(` \u2699 background job finished \u2014 resuming
|
|
24744
|
+
`));
|
|
24745
|
+
void turn(notes.join("\n\n"), { machine: true }).then(() => editorRef?.redrawNow());
|
|
24746
|
+
});
|
|
24527
24747
|
const runSkill = async (sk, extra = "") => {
|
|
24528
24748
|
try {
|
|
24529
24749
|
await turn(await expandEntry(fs, sk.path, extra));
|
|
@@ -24610,7 +24830,7 @@ ${task}`;
|
|
|
24610
24830
|
`));
|
|
24611
24831
|
aborting = false;
|
|
24612
24832
|
const tokensBefore = session.meta.tokens ?? 0;
|
|
24613
|
-
await turn(`Continue working toward the goal: ${goalCondition}
|
|
24833
|
+
await turn(`Continue working toward the goal: ${goalCondition}`, { machine: true });
|
|
24614
24834
|
goalTokens += (session.meta.tokens ?? 0) - tokensBefore;
|
|
24615
24835
|
goalTurns++;
|
|
24616
24836
|
persistGoal();
|
|
@@ -24732,12 +24952,12 @@ ${task}`;
|
|
|
24732
24952
|
}
|
|
24733
24953
|
const info = getModelInfo(work.model);
|
|
24734
24954
|
info?.pricing ? ok(`model ${work.model} \u2014 priced (${info.pricing.inputCostPer1K}/${info.pricing.outputCostPer1K} per 1k in/out)`) : warn(`model ${work.model} \u2014 no pricing in the catalog (costs will show ~$0; verify the id)`);
|
|
24735
|
-
const cfgFiles = ["ts", "js", "json"].flatMap((e) => [`${cwd}/.agent/config.${e}`, `${
|
|
24955
|
+
const cfgFiles = ["ts", "js", "json"].flatMap((e) => [`${cwd}/.agent/config.${e}`, `${homedir11()}/.agent/config.${e}`]).filter((p) => existsSync9(p));
|
|
24736
24956
|
cfgFiles.length ? ok(`config: ${cfgFiles.join(", ")}`) : warn("no .agent/config.* found (project or ~) \u2014 running on defaults");
|
|
24737
24957
|
try {
|
|
24738
24958
|
const probe = `${cwd}/.agent/sessions/.doctor-probe`;
|
|
24739
|
-
|
|
24740
|
-
|
|
24959
|
+
mkdirSync13(`${cwd}/.agent/sessions`, { recursive: true });
|
|
24960
|
+
writeFileSync10(probe, "ok");
|
|
24741
24961
|
unlinkSync5(probe);
|
|
24742
24962
|
ok(`session store writable (${cwd}/.agent/sessions)`);
|
|
24743
24963
|
} catch (e) {
|
|
@@ -24765,7 +24985,7 @@ ${task}`;
|
|
|
24765
24985
|
desc: "rescan skills/commands dirs and rebuild the system prompt (one cache miss) \u2014 picks up entries created mid-session",
|
|
24766
24986
|
run: async () => {
|
|
24767
24987
|
await refreshCatalogs().catch((e) => {
|
|
24768
|
-
|
|
24988
|
+
log48.debug("catalog refresh failed", e);
|
|
24769
24989
|
});
|
|
24770
24990
|
face.reprepare();
|
|
24771
24991
|
err(green(` \u2713 reloaded \u2014 ${skills.length} skill(s), ${cmds.length} command(s); system prompt rebuilds on next message
|
|
@@ -25199,6 +25419,7 @@ ${task}`;
|
|
|
25199
25419
|
bangContext.length = 0;
|
|
25200
25420
|
session = startSession({ ...args, cont: false, resume: void 0 }, store, face, cwd);
|
|
25201
25421
|
triggerServer.use(session.meta.id);
|
|
25422
|
+
live?.session(session.meta.id);
|
|
25202
25423
|
err("\x1Bc");
|
|
25203
25424
|
}
|
|
25204
25425
|
},
|
|
@@ -25268,7 +25489,7 @@ ${task}`;
|
|
|
25268
25489
|
try {
|
|
25269
25490
|
for (const def of (await loadAgents(fs2, d)).agents) if (!seen.has(def.name)) seen.set(def.name, { def, from: d });
|
|
25270
25491
|
} catch (e) {
|
|
25271
|
-
|
|
25492
|
+
log48.debug(`loadAgents(${d}) failed`, e);
|
|
25272
25493
|
}
|
|
25273
25494
|
}
|
|
25274
25495
|
if (!seen.size) {
|
|
@@ -25356,7 +25577,7 @@ ${task}`;
|
|
|
25356
25577
|
}
|
|
25357
25578
|
if (idx >= 0) {
|
|
25358
25579
|
const old = mounted.splice(idx, 1)[0];
|
|
25359
|
-
await old.client.close().catch((e) =>
|
|
25580
|
+
await old.client.close().catch((e) => log48.debug("mcp close failed", e));
|
|
25360
25581
|
}
|
|
25361
25582
|
try {
|
|
25362
25583
|
const m = await mountMcpServer(name, conf);
|
|
@@ -25384,7 +25605,7 @@ ${task}`;
|
|
|
25384
25605
|
}
|
|
25385
25606
|
const m = mounted.splice(idx, 1)[0];
|
|
25386
25607
|
remountMcpTools();
|
|
25387
|
-
await m.client.close().catch((e) =>
|
|
25608
|
+
await m.client.close().catch((e) => log48.debug("mcp close failed", e));
|
|
25388
25609
|
err(dim(` removed "${name}"
|
|
25389
25610
|
`));
|
|
25390
25611
|
return;
|
|
@@ -25499,11 +25720,11 @@ ${task}`;
|
|
|
25499
25720
|
return;
|
|
25500
25721
|
}
|
|
25501
25722
|
const md = exportMarkdown(session.meta, shown);
|
|
25502
|
-
const name = a[0] ? extname(a[0]) ? a[0] : a[0] + ".md" :
|
|
25723
|
+
const name = a[0] ? extname(a[0]) ? a[0] : a[0] + ".md" : join17(".agent", "exports", `${session.meta.id}.md`);
|
|
25503
25724
|
const path = resolve5(cwd, name);
|
|
25504
25725
|
try {
|
|
25505
|
-
|
|
25506
|
-
|
|
25726
|
+
mkdirSync13(dirname6(path), { recursive: true });
|
|
25727
|
+
writeFileSync10(path, md);
|
|
25507
25728
|
err(green(` \u2713 exported \u2192 ${path}
|
|
25508
25729
|
`) + dim(` ${shown.length} message(s) \xB7 ${md.length} chars
|
|
25509
25730
|
`));
|
|
@@ -25585,9 +25806,9 @@ ${task}`;
|
|
|
25585
25806
|
});
|
|
25586
25807
|
const listDir = (absDir) => {
|
|
25587
25808
|
try {
|
|
25588
|
-
return readdirSync4(
|
|
25809
|
+
return readdirSync4(join17(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
|
|
25589
25810
|
} catch (e) {
|
|
25590
|
-
|
|
25811
|
+
log48.debug("completion readdir failed", absDir, e);
|
|
25591
25812
|
return null;
|
|
25592
25813
|
}
|
|
25593
25814
|
};
|
|
@@ -25689,6 +25910,14 @@ ${task}`;
|
|
|
25689
25910
|
let prefill;
|
|
25690
25911
|
let tick = 0;
|
|
25691
25912
|
const dispatchLine = async (line, opts) => {
|
|
25913
|
+
live?.hold();
|
|
25914
|
+
try {
|
|
25915
|
+
return await dispatchLineBody(line, opts);
|
|
25916
|
+
} finally {
|
|
25917
|
+
live?.release();
|
|
25918
|
+
}
|
|
25919
|
+
};
|
|
25920
|
+
const dispatchLineBody = async (line, opts) => {
|
|
25692
25921
|
if (!opts?.id) takeCut(voiceIO, false);
|
|
25693
25922
|
if (/^[!#/]/.test(line)) dispatchPending = false;
|
|
25694
25923
|
history.unshift(line.replace(/\n+/g, " \u23CE "));
|
|
@@ -25726,7 +25955,7 @@ ${out}
|
|
|
25726
25955
|
return;
|
|
25727
25956
|
}
|
|
25728
25957
|
await refreshCatalogs().catch((e) => {
|
|
25729
|
-
|
|
25958
|
+
log48.debug("catalog refresh failed", e);
|
|
25730
25959
|
});
|
|
25731
25960
|
const sk = skills.find((x) => x.name === name);
|
|
25732
25961
|
if (sk) {
|
|
@@ -25777,7 +26006,7 @@ ${out}
|
|
|
25777
26006
|
return false;
|
|
25778
26007
|
}
|
|
25779
26008
|
const fakeVoice = process.env.AGENTX_VOICE_FAKE ? fakeVoiceParts(process.env.AGENTX_VOICE_FAKE) : null;
|
|
25780
|
-
voiceDiag = new JsonlDiagSink(
|
|
26009
|
+
voiceDiag = new JsonlDiagSink(join17(store.dir, `${session.meta.id}.voice.jsonl`));
|
|
25781
26010
|
const sttTerms = agent.options.fs && agent.options.memoryDir ? await memoryTerms(agent.options.fs, agent.options.memoryDir, [basename4(agent.options.fs?.getCwd() ?? process.cwd())]).catch((e) => {
|
|
25782
26011
|
err(dim(` (stt terms: ${e?.message ?? e})
|
|
25783
26012
|
`));
|
|
@@ -25856,7 +26085,7 @@ ${out}
|
|
|
25856
26085
|
if (delivery || cut) dx?.parkCutDelivery(delivery, !!cut, heard);
|
|
25857
26086
|
const cutReply = cut && cut.full.length - cut.heard.length > 40 ? cut : null;
|
|
25858
26087
|
const noteP = replaces ? replaces.note : !cutReply ? Promise.resolve("") : (instinct ? instinct.bargeIntent(text).catch((e) => {
|
|
25859
|
-
|
|
26088
|
+
log48.warn(`barge intent failed \u2014 model decides: ${e.message}`);
|
|
25860
26089
|
return void 0;
|
|
25861
26090
|
}) : Promise.resolve(void 0)).then(async (intent) => interruptionNote(cutReply, intent) + ackedNote(await instinct?.ackFor(text)));
|
|
25862
26091
|
const cutIn = replaces ? replaces.cutIn : interjectNote;
|
|
@@ -25993,7 +26222,7 @@ ${out}
|
|
|
25993
26222
|
const where = cwd.split("/").pop();
|
|
25994
26223
|
const resumed = session.messages.length > 0;
|
|
25995
26224
|
const prompt = resumed ? `[session resumed] You're rejoining a live voice conversation already in progress \u2014 the full history, including the user's memory/preferences, is already in context, so do NOT call QuickLook again. In one short spoken line, welcome the user back and pick the thread up where it left off: if your last turn ended on an open question or offer, continue it naturally rather than asking what they'd like to do.` : `[session started] First call QuickLook with what:"memory" \u2014 if it knows the user's name or preferences, use them. Then greet the user warmly in one or two short sentences, as the opener of a live voice conversation. Context: working directory "${where}". Personalize from whatever you learned (memory). Then ask what they'd like to do.`;
|
|
25996
|
-
void turn(prompt).finally(() => editorRef?.redrawNow());
|
|
26225
|
+
void turn(prompt, { machine: true }).finally(() => editorRef?.redrawNow());
|
|
25997
26226
|
}
|
|
25998
26227
|
return true;
|
|
25999
26228
|
} catch (e) {
|
|
@@ -26029,6 +26258,7 @@ ${out}
|
|
|
26029
26258
|
};
|
|
26030
26259
|
if (args.voice && (duplex || call) && process.stdin.isTTY) await startVoice(process.env.VOICE_GREETING !== "0");
|
|
26031
26260
|
let ctxWarned = 0;
|
|
26261
|
+
let seedLine = args.prompt;
|
|
26032
26262
|
while (true) {
|
|
26033
26263
|
if (pendingRewind) {
|
|
26034
26264
|
pendingRewind = false;
|
|
@@ -26086,7 +26316,13 @@ ${out}
|
|
|
26086
26316
|
const q2 = ask.question.replace(/\s+/g, " ").slice(0, 64);
|
|
26087
26317
|
return bold(yellow(`? ${q2}${ask.question.length > 64 ? "\u2026" : ""} \u2039yes/no\u203A `));
|
|
26088
26318
|
};
|
|
26089
|
-
const result =
|
|
26319
|
+
const result = seedLine !== void 0 ? (() => {
|
|
26320
|
+
const s = seedLine;
|
|
26321
|
+
seedLine = void 0;
|
|
26322
|
+
err(promptStr + s + "\n");
|
|
26323
|
+
dispatchPending = true;
|
|
26324
|
+
return s;
|
|
26325
|
+
})() : await readMultiline((cont) => {
|
|
26090
26326
|
dispatchPending = false;
|
|
26091
26327
|
return editor.readLine({
|
|
26092
26328
|
prompt: cont ? contPrompt : livePrompt,
|
|
@@ -26146,6 +26382,7 @@ ${out}
|
|
|
26146
26382
|
`));
|
|
26147
26383
|
continue;
|
|
26148
26384
|
}
|
|
26385
|
+
live?.hold();
|
|
26149
26386
|
let quit = await dispatchLine(line) === "quit";
|
|
26150
26387
|
const wasLocal = /^[!#/]/.test(line);
|
|
26151
26388
|
if (wasLocal) agent.clearInjections();
|
|
@@ -26160,7 +26397,7 @@ ${out}
|
|
|
26160
26397
|
const prompt = scheduleQueue.shift();
|
|
26161
26398
|
err(dim(` \u23F0 scheduled \u203A ${prompt.slice(0, 60)}${prompt.length > 60 ? "\u2026" : ""}
|
|
26162
26399
|
`));
|
|
26163
|
-
await turn(prompt);
|
|
26400
|
+
await turn(prompt, { machine: true });
|
|
26164
26401
|
}
|
|
26165
26402
|
dispatchPending = false;
|
|
26166
26403
|
session.meta.scheduledJobs = scheduler.snapshot();
|
|
@@ -26168,10 +26405,12 @@ ${out}
|
|
|
26168
26405
|
store.save(session);
|
|
26169
26406
|
} catch {
|
|
26170
26407
|
}
|
|
26408
|
+
live?.release();
|
|
26171
26409
|
if (quit) break;
|
|
26172
26410
|
}
|
|
26173
26411
|
scheduler.destroy();
|
|
26174
26412
|
triggerServer.stop();
|
|
26413
|
+
live?.exited("exit");
|
|
26175
26414
|
voiceIO?.stop();
|
|
26176
26415
|
if (dx) {
|
|
26177
26416
|
const running = [...dx.tasks.values()].filter((t) => t.status === "running");
|
|
@@ -26257,13 +26496,13 @@ function channelOptions(ai, model, gender) {
|
|
|
26257
26496
|
// 0: the reactive live path
|
|
26258
26497
|
pickLeaf: fastLeafPicker(ai, process.env.AGENTX_LEAF_MODEL || "groq/openai/gpt-oss-120b"),
|
|
26259
26498
|
persona: process.env.AGENTX_CALL_PERSONA ?? "",
|
|
26260
|
-
onTree: (e) =>
|
|
26499
|
+
onTree: (e) => log48.debug(`voice tree: ${e.branches} branches in ${e.ms}ms${e.tokens ? ` tokens ${e.tokens.input}/${e.tokens.output}` : ""}${e.error ? ` error ${e.error}` : ""}`),
|
|
26261
26500
|
onEvent: (e) => {
|
|
26262
|
-
if (e.moment)
|
|
26263
|
-
else
|
|
26501
|
+
if (e.moment) log48.debug(`voice leaf: ${e.moment} ${e.conf} "${e.text}" ${e.acted}`);
|
|
26502
|
+
else log48.debug(`channel ${e.trigger}: rule=${e.rule} choice=${e.choice ?? "-"} \u2192 ${e.acted}${e.text ? ` "${e.text}"` : ""}${e.cue ? " (planned cue)" : ""} ${e.ms}ms`);
|
|
26264
26503
|
},
|
|
26265
26504
|
// Banks in the user's language: generated once per language, cached + topped up across sessions (~/.agent/cache).
|
|
26266
|
-
banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir:
|
|
26505
|
+
banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir: join17(homedir11(), ".agent", "cache", "channel-banks") }),
|
|
26267
26506
|
decide: channelDecide(ai, instinct),
|
|
26268
26507
|
generate: fastLineGenerator(ai, model, gender),
|
|
26269
26508
|
// Anticipated backchannels: on in chatty mode (its preset), else off until the offline replay proves them (tests/voice-bc-anticipate-eval.ts)
|
|
@@ -26295,7 +26534,7 @@ function overlapResponder(ai, mode, out, aside) {
|
|
|
26295
26534
|
}
|
|
26296
26535
|
async function duplexServe(args, ai, cfg, cwd) {
|
|
26297
26536
|
const out = (o) => process.stdout.write(JSON.stringify(o) + "\n");
|
|
26298
|
-
const mounted = await mountMcp(cfg, new McpOAuth({ storePath:
|
|
26537
|
+
const mounted = await mountMcp(cfg, new McpOAuth({ storePath: join17(cwd, ".agent", "mcp-auth.json") }));
|
|
26299
26538
|
installCancelGuards(mounted);
|
|
26300
26539
|
const agent = await makeAgent(args, ai, cfg, mcpAgentTools(mounted, { quiet: true }), mounted.map((m) => m.name));
|
|
26301
26540
|
const { host: _h, stream: _s, signal: _g, providerOptions: _po, ...wo } = agent.options;
|
|
@@ -26354,7 +26593,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
26354
26593
|
try {
|
|
26355
26594
|
store.save(session);
|
|
26356
26595
|
} catch (e) {
|
|
26357
|
-
|
|
26596
|
+
log48.warn("duplex session save failed", e);
|
|
26358
26597
|
}
|
|
26359
26598
|
};
|
|
26360
26599
|
const overlap2 = overlapResponder(ai, args.duplexV2 ? args.channelMode : void 0, out);
|
|
@@ -26394,7 +26633,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
26394
26633
|
done2();
|
|
26395
26634
|
out({ type: "turn_done", id, finishReason: res?.finishReason ?? "error", ...why ? { error: why } : {} });
|
|
26396
26635
|
}).catch((e) => {
|
|
26397
|
-
|
|
26636
|
+
log48.error("duplex turn failed", e);
|
|
26398
26637
|
done2();
|
|
26399
26638
|
out({ type: "turn_done", id, finishReason: "error", error: String(e?.message ?? e) });
|
|
26400
26639
|
});
|
|
@@ -26553,7 +26792,7 @@ async function rollbackTurn(agent, store, session, start) {
|
|
|
26553
26792
|
session.meta.updated = Date.now();
|
|
26554
26793
|
session.meta.cc = void 0;
|
|
26555
26794
|
const cc = agent.options.providerOptions?.claudeCodeSession;
|
|
26556
|
-
if (typeof cc === "string" && agent.options.model
|
|
26795
|
+
if (typeof cc === "string" && isClaudeCode(agent.options.model)) await rewindClaudeCodeSession(cc);
|
|
26557
26796
|
store.save(session);
|
|
26558
26797
|
return dropped;
|
|
26559
26798
|
}
|
|
@@ -26620,7 +26859,7 @@ async function main() {
|
|
|
26620
26859
|
}
|
|
26621
26860
|
cfg.permissions = mergePerms(loadClaudeSettings(cwd), mergePerms(loadPersistedRules(cwd), cfg.permissions));
|
|
26622
26861
|
if (canPrompt && !args.yes && !isTrusted(cwd)) {
|
|
26623
|
-
const ok = await makeHost().confirm?.(`Trust this directory? agent.libx will read and edit files in:
|
|
26862
|
+
const ok = args.trust || await makeHost().confirm?.(`Trust this directory? agent.libx will read and edit files in:
|
|
26624
26863
|
${cwd}`);
|
|
26625
26864
|
if (!ok) {
|
|
26626
26865
|
console.error(red(" not trusted \u2014 exiting (re-run with --yes to skip this prompt)."));
|
|
@@ -26645,7 +26884,7 @@ async function main() {
|
|
|
26645
26884
|
loadInstallEnv();
|
|
26646
26885
|
await loadBodifySecrets();
|
|
26647
26886
|
const apiKeys = { ...cfg.apiKeys, ...apiKeysFromEnv() };
|
|
26648
|
-
const keyless = String(args.model ?? cfg.model ?? "")
|
|
26887
|
+
const keyless = isKeyless(String(args.model ?? cfg.model ?? ""));
|
|
26649
26888
|
if (!Object.keys(apiKeys).length && !keyless) {
|
|
26650
26889
|
console.error(red("No provider key found. Set ANTHROPIC_API_KEY (or OPENAI_API_KEY / GOOGLE_API_KEY / GROQ_API_KEY) in ~/.agent/.env, or set BODIFY_API_KEY + BODIFY_APP_ID to pull from Bodify."));
|
|
26651
26890
|
process.exit(1);
|
|
@@ -26679,7 +26918,7 @@ async function main() {
|
|
|
26679
26918
|
worktreeCleanup?.();
|
|
26680
26919
|
process.exit(0);
|
|
26681
26920
|
}
|
|
26682
|
-
const mounted = await mountMcp(cfg, new McpOAuth({ storePath:
|
|
26921
|
+
const mounted = await mountMcp(cfg, new McpOAuth({ storePath: join17(cwd, ".agent", "mcp-auth.json") }));
|
|
26683
26922
|
const agent = await makeAgent(args, ai, cfg, mcpAgentTools(mounted), mounted.map((m) => m.name));
|
|
26684
26923
|
const store = new SessionStore(cwd);
|
|
26685
26924
|
const session = startSession(args, store, agent, cwd);
|