@livx.cc/agentx 0.99.151 → 0.99.152
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 +1 -1
- package/dist/cli.js +180 -136
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.js +82 -33
- package/dist/index.js.map +1 -1
- package/dist/{secondChannel--iqPHPO_.d.ts → secondChannel-BVmp2lze.d.ts} +5 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2962,7 +2962,7 @@ async function psGroupCpuSeconds(pgid) {
|
|
|
2962
2962
|
try {
|
|
2963
2963
|
return await winTreeCpuSeconds(pgid);
|
|
2964
2964
|
} catch (e) {
|
|
2965
|
-
|
|
2965
|
+
log33.debug(`cpu probe failed for ${pgid}: ${e}`);
|
|
2966
2966
|
return void 0;
|
|
2967
2967
|
}
|
|
2968
2968
|
}
|
|
@@ -2971,7 +2971,7 @@ async function psGroupCpuSeconds(pgid) {
|
|
|
2971
2971
|
const out = await new Promise((res, rej) => execFile5("ps", ["-A", "-o", "pid=,ppid=,pgid=,time="], { timeout: 5e3, env: { ...process.env, LC_ALL: "C" } }, (e, so) => e ? rej(e) : res(String(so))));
|
|
2972
2972
|
return sumTreeCpu(out, pgid);
|
|
2973
2973
|
} catch (e) {
|
|
2974
|
-
|
|
2974
|
+
log33.debug(`ps cpu probe failed for group ${pgid}: ${e}`);
|
|
2975
2975
|
return void 0;
|
|
2976
2976
|
}
|
|
2977
2977
|
}
|
|
@@ -3121,7 +3121,7 @@ function makeRealShellTool(options) {
|
|
|
3121
3121
|
proc.stderr?.on("data", collect);
|
|
3122
3122
|
proc.on("error", (err2) => {
|
|
3123
3123
|
if (err2?.name === "AbortError" || ctl.signal.aborted) return finish(reasonFor(timedOut, timeoutMs, clean2(out)));
|
|
3124
|
-
|
|
3124
|
+
log33.debug("shell spawn error", err2);
|
|
3125
3125
|
finish(`[exit 1] ${err2?.message ?? err2}${out ? "\n" + clean2(out) : ""}`);
|
|
3126
3126
|
});
|
|
3127
3127
|
proc.on("close", (code) => {
|
|
@@ -3200,7 +3200,7 @@ ${clean2(out) || "(no output yet)"}`;
|
|
|
3200
3200
|
}
|
|
3201
3201
|
];
|
|
3202
3202
|
}
|
|
3203
|
-
var
|
|
3203
|
+
var log33, clean2, DETACHED, shellArgv, SECRET_ENV_RE, _spawn, ShellJobRegistry, shellStatus, NO_JOB2;
|
|
3204
3204
|
var init_tools_shell = __esm({
|
|
3205
3205
|
"src/tools.shell.ts"() {
|
|
3206
3206
|
"use strict";
|
|
@@ -3210,7 +3210,7 @@ var init_tools_shell = __esm({
|
|
|
3210
3210
|
init_shell_sandbox();
|
|
3211
3211
|
init_tools_jobs();
|
|
3212
3212
|
init_platform();
|
|
3213
|
-
|
|
3213
|
+
log33 = forComponent("shell");
|
|
3214
3214
|
clean2 = (s) => truncateOutput(redactSecrets(s.replace(/\n+$/, "")));
|
|
3215
3215
|
DETACHED = { stdio: ["ignore", "pipe", "pipe"], ...DETACH_OPTIONS };
|
|
3216
3216
|
shellArgv = (sh, command) => ({ bin: sh.bin, args: sh.args(command), ...sh.spawnOptions ? { spawnOptions: sh.spawnOptions } : {} });
|
|
@@ -10446,12 +10446,14 @@ var LEADER = /* @__PURE__ */ new Set(["yeah", "yea", "yes", "yep", "yup", "ok",
|
|
|
10446
10446
|
var PHRASES = ["got it", "i see", "makes sense", "of course", "for sure", "all right", "that's right", "that's true", "thats right", "thats true", "love it", "i know", "me too", "uh huh"];
|
|
10447
10447
|
var CONTINUE = /^(?:(?:and|so|oh) )?(?:and|so|really|seriously|then what|and then|go on|keep going|ואז|באמת|נו)$/;
|
|
10448
10448
|
var AGREE = new Set("yeah yea yes yep yup right sure true totally exactly definitely absolutely agreed correct indeed \u05DB\u05DF \u05E0\u05DB\u05D5\u05DF \u05D1\u05D3\u05D9\u05D5\u05E7 \u05D1\u05E8\u05D5\u05E8 \u05D1\u05D8\u05D7 \u05D0\u05DB\u05DF \u05DC\u05D2\u05DE\u05E8\u05D9 \u05DE\u05E1\u05DB\u05D9\u05DD \u05DE\u05E1\u05DB\u05D9\u05DE\u05D4 \u05DE\u05DE\u05E9".split(" "));
|
|
10449
|
+
var DOUBT = /^(?:(?:and|so|oh|wait|but) )*(?:really|seriously|are|is|was|were|do|does|did|you|no way|באמת|בטוח|בטוחה|רצינית?)(?=\s|$)/u;
|
|
10449
10450
|
var AGREE_PHRASES = ["of course", "for sure", "that's right", "that's true", "thats right", "thats true", "makes sense", "i agree"];
|
|
10450
10451
|
var HE_ACK = new Set("\u05DB\u05DF \u05E0\u05DB\u05D5\u05DF \u05D1\u05D3\u05D9\u05D5\u05E7 \u05D1\u05E8\u05D5\u05E8 \u05D1\u05D8\u05D7 \u05D0\u05DB\u05DF \u05DC\u05D2\u05DE\u05E8\u05D9 \u05DE\u05DE\u05E9 \u05D0\u05D5\u05E7\u05D9\u05D9 \u05D0\u05D5\u05E7\u05D9 \u05E1\u05D1\u05D1\u05D4 \u05D9\u05E4\u05D4 \u05DE\u05E2\u05D5\u05DC\u05D4 \u05D5\u05D5\u05D0\u05D5 \u05D0\u05D4\u05D4 \u05D0\u05D4 \u05D4\u05DE\u05DE \u05DE\u05DE\u05DE".split(" "));
|
|
10451
10452
|
function cueKind(text) {
|
|
10452
10453
|
const t = norm2(text);
|
|
10453
10454
|
if (!t) return null;
|
|
10454
10455
|
if (CONTINUE.test(t)) return "continue";
|
|
10456
|
+
if (/\?/.test(text) || DOUBT.test(t)) return null;
|
|
10455
10457
|
let r = t;
|
|
10456
10458
|
for (const p of AGREE_PHRASES) if (r.includes(p)) return "agree";
|
|
10457
10459
|
r = r.split(/[\s-]+/).filter((w) => !LEAD.has(w)).join(" ");
|
|
@@ -11462,6 +11464,10 @@ var TurnGateOptions = class {
|
|
|
11462
11464
|
* 20261103-114604, "Okay." settled 700ms into "What will the…" and MAIN started, was aborted twice and merged. The
|
|
11463
11465
|
* rest's final merges in; capped at this long from the hold (an STT that never finalizes a partial). */
|
|
11464
11466
|
talkingMaxMs = 6e3;
|
|
11467
|
+
/** With settleMs: a final of acknowledgement words only ("Ok Okay.") waits this long. No answer is due, and it is
|
|
11468
|
+
* mostly the start of the turn: live 20261103-210433, "Ok Okay." settled at 700ms, the rest began 1s after it, and
|
|
11469
|
+
* MAIN was started and aborted. Quiet past this sends it as it was. */
|
|
11470
|
+
openerMs = 2e3;
|
|
11465
11471
|
onTurn = () => {
|
|
11466
11472
|
};
|
|
11467
11473
|
onDrop = () => {
|
|
@@ -11519,7 +11525,7 @@ var TurnGate = class {
|
|
|
11519
11525
|
if (this.closed && isClosing(t)) return this.o.onDrop(t, "goodbye");
|
|
11520
11526
|
const mid = endsMidPhrase(t);
|
|
11521
11527
|
if (mid || this.o.settleMs && !/\?["')\]]*$/.test(t)) {
|
|
11522
|
-
const ms = mid ? this.o.holdMs : this.o.settleMs;
|
|
11528
|
+
const ms = mid ? this.o.holdMs : this.o.settleMs && this.opener(t) ? Math.max(this.o.settleMs, this.o.openerMs) : this.o.settleMs;
|
|
11523
11529
|
this.held = { text: t, sttId, ms, replaces, since: now4, timer: setTimeout(() => this.settle(), ms) };
|
|
11524
11530
|
return this.o.onHold(t);
|
|
11525
11531
|
}
|
|
@@ -11564,6 +11570,11 @@ var TurnGate = class {
|
|
|
11564
11570
|
if (this.closed && isClosing(h.text)) return this.o.onDrop(h.text, "goodbye");
|
|
11565
11571
|
this.send(h.text, norm3(h.text), h.sttId, "new", h.replaces);
|
|
11566
11572
|
}
|
|
11573
|
+
/** Only acknowledgement words ("Ok Okay.", "Alright.") and no goodbye: no answer is due, and it usually opens what
|
|
11574
|
+
* comes next. */
|
|
11575
|
+
opener(t) {
|
|
11576
|
+
return turnIntent(t) === "closer" && !isClosing(t);
|
|
11577
|
+
}
|
|
11567
11578
|
end() {
|
|
11568
11579
|
if (this.held) {
|
|
11569
11580
|
clearTimeout(this.held.timer);
|
|
@@ -14084,8 +14095,30 @@ Reply JSON only: {"turn":"...","density":"...","cues":[{"when":["phrase",...],"l
|
|
|
14084
14095
|
}
|
|
14085
14096
|
};
|
|
14086
14097
|
|
|
14098
|
+
// src/voice/fastText.ts
|
|
14099
|
+
init_logging();
|
|
14100
|
+
var log27 = forComponent("FastText");
|
|
14101
|
+
var isReasoningFast = (model) => /gpt-oss/.test(model);
|
|
14102
|
+
async function fastText(ai, o) {
|
|
14103
|
+
const reasons = isReasoningFast(o.model);
|
|
14104
|
+
const r = await ai.chat({
|
|
14105
|
+
model: o.model,
|
|
14106
|
+
messages: [{ role: "user", content: o.prompt }],
|
|
14107
|
+
stream: false,
|
|
14108
|
+
...o.signal ? { signal: o.signal } : {},
|
|
14109
|
+
maxTokens: reasons ? Math.max(o.maxTokens ?? 0, 400) : o.maxTokens ?? 150,
|
|
14110
|
+
...o.temperature !== void 0 ? { temperature: o.temperature } : {},
|
|
14111
|
+
...reasons ? { providerOptions: { reasoning_effort: "low" } } : {}
|
|
14112
|
+
});
|
|
14113
|
+
if (reasons && r.finishReason === "length") {
|
|
14114
|
+
log27.debug(`${o.model} hit its token cap \u2014 no answer: ${(r.content ?? "").slice(0, 80)}`);
|
|
14115
|
+
return "";
|
|
14116
|
+
}
|
|
14117
|
+
return r.content ?? "";
|
|
14118
|
+
}
|
|
14119
|
+
|
|
14087
14120
|
// src/voice/convoTree.ts
|
|
14088
|
-
var
|
|
14121
|
+
var log28 = forComponent("ConvoTree");
|
|
14089
14122
|
var MOMENTS = ["turn_end", "barge_in", "in_between", "ask"];
|
|
14090
14123
|
var MAX_LINE_WORDS = 5;
|
|
14091
14124
|
var SOFT_CUE = "~";
|
|
@@ -14250,7 +14283,7 @@ Reply JSON only: {"soft":["...","..."],"branches":[{"when":["..."],"p":0.5,"mome
|
|
|
14250
14283
|
const seen = new Set(c.recent.map(leafKey));
|
|
14251
14284
|
const fresh = (l) => l.filter((n) => !seen.has(leafKey(n.line))).map((n) => ({ ...n, next: fresh(n.next) }));
|
|
14252
14285
|
const nodes = fresh(parseTree(r.content ?? "", c.lang, o.levels));
|
|
14253
|
-
if (!nodes.length)
|
|
14286
|
+
if (!nodes.length) log28.debug(`unusable tree: ${(r.content ?? "").slice(0, 160)}`);
|
|
14254
14287
|
return { nodes, ...r.usage ? { tokens: { input: r.usage.promptTokens, output: r.usage.completionTokens } } : {} };
|
|
14255
14288
|
}
|
|
14256
14289
|
};
|
|
@@ -14260,16 +14293,14 @@ function fastLeafPicker(ai, model = "groq/openai/gpt-oss-120b") {
|
|
|
14260
14293
|
They may still be talking. A warm listener reacts often: does one of these fit the words they just said? It must fit those words.
|
|
14261
14294
|
` + lines.map((l) => `${l.i}: ${l.line} (fits: ${l.when.join(", ").replace("~", "any moment, when no topic line fits")})`).join("\n") + `
|
|
14262
14295
|
Answer only the number, or "none".`;
|
|
14263
|
-
const
|
|
14264
|
-
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, temperature: 0, maxTokens: /gpt-oss/.test(model) ? 200 : 4, ...reasoning });
|
|
14265
|
-
const m = (r.content ?? "").trim().match(/^\d+/);
|
|
14296
|
+
const m = (await fastText(ai, { model, prompt, signal, temperature: 0, maxTokens: 4 })).trim().match(/^\d+/);
|
|
14266
14297
|
return m ? Number(m[0]) : -1;
|
|
14267
14298
|
};
|
|
14268
14299
|
}
|
|
14269
14300
|
|
|
14270
14301
|
// src/voice/progress.ts
|
|
14271
14302
|
init_logging();
|
|
14272
|
-
var
|
|
14303
|
+
var log29 = forComponent("Progress");
|
|
14273
14304
|
var HE_RESULT_CLAIM = /(?:^|\s)(?:מצאתי|סיימתי|בוצע|הנה|אין)(?=\s|$|[.,!…])/u;
|
|
14274
14305
|
var PLUMBING = /toolsearch|^mcp__.*__(list_commands|call_info)$/;
|
|
14275
14306
|
var isPlumbing = (tool) => PLUMBING.test(tool.toLowerCase());
|
|
@@ -14444,7 +14475,7 @@ var Progress = class {
|
|
|
14444
14475
|
});
|
|
14445
14476
|
const hint = argsHint(args) || about.slice(-80);
|
|
14446
14477
|
const raw = await Promise.race([this.o.generate(tool, hint, lang, ac.signal, this.lines).catch((e) => {
|
|
14447
|
-
|
|
14478
|
+
log29.warn(`progress line failed: ${e?.message ?? e}`);
|
|
14448
14479
|
return null;
|
|
14449
14480
|
}), late]).finally(() => clearTimeout(t));
|
|
14450
14481
|
const l = cleanLine(raw ?? "", lang, 5);
|
|
@@ -14455,9 +14486,7 @@ var Progress = class {
|
|
|
14455
14486
|
function fastProgressGenerator(ai, model, gender) {
|
|
14456
14487
|
return async (tool, hint, lang, signal, avoid = []) => {
|
|
14457
14488
|
const prompt = `An assistant on a live voice call is running the tool "${tool}"${hint ? ` (about: "${hint}")` : ""}. Write ONE spoken line of 2-5 words, in ${languageName(lang)}, saying what it is doing right now (like "checking the board\u2026"). ${hint ? 'Name what it works on the way a person would say it ("looking up that Astra post\u2026"), never a string of its keywords ("scanning Astra weights\u2026"). ' : ""}${avoid.length ? `It already said ${avoid.map((a) => `"${a}"`).join(", ")}: say something new, a different angle on the same work. ` : ""}Never state a result or a finding. ${personaHint(gender)} Output only the line.`;
|
|
14458
|
-
|
|
14459
|
-
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, maxTokens: 150, ...reasoning });
|
|
14460
|
-
return r.content ?? "";
|
|
14489
|
+
return fastText(ai, { model, prompt, signal });
|
|
14461
14490
|
};
|
|
14462
14491
|
}
|
|
14463
14492
|
var WORK_CLAIM = /\b(?:none|nothing|nobody|zero|\d+|one|two|three|four|five|many|several|some|looks like|seems|turns out|apparently|it'?s|they'?re|there'?s)\b|(?:^|\s)(?:כלום|אף|נראה)(?=\s|$|[.,!…])/iu;
|
|
@@ -14478,15 +14507,13 @@ ${persona.slice(0, 500)}
|
|
|
14478
14507
|
|
|
14479
14508
|
` : ""}You are on a live voice call, in the middle of doing this for them: "${c.request.slice(-160)}"${c.tool ? ` (right now: ${c.tool}${c.hint ? ` on ${c.hint}` : ""})` : ""}. They just said, while you work: "${c.heard.slice(-200)}"
|
|
14480
14509
|
Answer them at once with ONE short spoken line of 2-7 words in ${languageName(c.lang)}, the way a person busy on it would ("yeah, looking now"). You have NO results yet and cannot know any: only acknowledge the work, never say what was or was not found, not even "nothing yet" or "none so far". ` + (c.avoid.length ? `Do not reuse: ${c.avoid.map((a) => `"${a}"`).join(", ")}. ` : "") + `If they tell you to stop or drop the work, start the line with "stop:". If they change the request or add to it, start it with "work:". ${personaHint(gender)} Output only the line, no tone tag.`;
|
|
14481
|
-
|
|
14482
|
-
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, maxTokens: 150, ...reasoning });
|
|
14483
|
-
return r.content ?? "";
|
|
14510
|
+
return fastText(ai, { model, prompt, signal });
|
|
14484
14511
|
};
|
|
14485
14512
|
}
|
|
14486
14513
|
|
|
14487
14514
|
// src/voice/secondChannel.ts
|
|
14488
14515
|
init_logging();
|
|
14489
|
-
var
|
|
14516
|
+
var log30 = forComponent("SecondChannel");
|
|
14490
14517
|
var CHANNEL_MODES = {
|
|
14491
14518
|
turn: { kinds: ["bridge"], bridgeDelayMs: 1500 },
|
|
14492
14519
|
normal: {},
|
|
@@ -14656,15 +14683,15 @@ function withBudget(p, ms, what, ac) {
|
|
|
14656
14683
|
let t;
|
|
14657
14684
|
const late = new Promise((r) => {
|
|
14658
14685
|
t = setTimeout(() => {
|
|
14659
|
-
|
|
14686
|
+
log30.debug(`${what}: over the ${ms}ms budget \u2014 dropped`);
|
|
14660
14687
|
ac?.abort();
|
|
14661
14688
|
r(null);
|
|
14662
14689
|
}, ms);
|
|
14663
14690
|
});
|
|
14664
14691
|
return Promise.race([p.catch((e) => {
|
|
14665
14692
|
const msg = String(e?.message ?? e);
|
|
14666
|
-
if (e?.name === "AbortError" || /aborted/i.test(msg))
|
|
14667
|
-
else
|
|
14693
|
+
if (e?.name === "AbortError" || /aborted/i.test(msg)) log30.debug(`${what}: aborted after its budget`);
|
|
14694
|
+
else log30.warn(`${what} failed \u2014 falling back: ${msg}`);
|
|
14668
14695
|
return null;
|
|
14669
14696
|
}), late]).finally(() => clearTimeout(t));
|
|
14670
14697
|
}
|
|
@@ -14708,6 +14735,8 @@ var SecondChannel = class {
|
|
|
14708
14735
|
// a bridge generated ahead, used only if ready in time
|
|
14709
14736
|
bridgeReady = Promise.resolve();
|
|
14710
14737
|
// live: that draft settled
|
|
14738
|
+
noLine = "";
|
|
14739
|
+
// live: why that draft gave no line
|
|
14711
14740
|
askLeaf = null;
|
|
14712
14741
|
// live: this turn's ask leaf
|
|
14713
14742
|
barged = false;
|
|
@@ -14767,7 +14796,7 @@ var SecondChannel = class {
|
|
|
14767
14796
|
if (host) this.pinned = true;
|
|
14768
14797
|
const lang = primaryLang(tag);
|
|
14769
14798
|
if (!lang || lang === this.lang) return;
|
|
14770
|
-
|
|
14799
|
+
log30.debug(`language ${this.lang} \u2192 ${lang}`);
|
|
14771
14800
|
this.lang = lang;
|
|
14772
14801
|
this.recent = [];
|
|
14773
14802
|
this.picks.clear();
|
|
@@ -14917,6 +14946,16 @@ var SecondChannel = class {
|
|
|
14917
14946
|
}, Math.max(late, wait + 1));
|
|
14918
14947
|
}
|
|
14919
14948
|
}
|
|
14949
|
+
/** The STT closed the user's line (a final that ends a sentence), before it is a turn (the host may still hold it): a
|
|
14950
|
+
* listener cue armed on its last words is late now. Replay of 20261103-210433: "oh wow" played 330ms after "…and
|
|
14951
|
+
* hacker news." while the gate held the turn, and spaced the request's own line to 1.5s. */
|
|
14952
|
+
onLineEnd() {
|
|
14953
|
+
this.userSpeaking = false;
|
|
14954
|
+
for (const k of ["bcTimer", "leafTimer", "breathTimer"]) {
|
|
14955
|
+
if (this[k]) clearTimeout(this[k]);
|
|
14956
|
+
this[k] = null;
|
|
14957
|
+
}
|
|
14958
|
+
}
|
|
14920
14959
|
/** The user's final line was dispatched to the main agent (its words are the bridge's micro-context). */
|
|
14921
14960
|
onUserTurn(text, lastWordAgoMs = 0) {
|
|
14922
14961
|
this.heard = text.trim();
|
|
@@ -14952,7 +14991,7 @@ var SecondChannel = class {
|
|
|
14952
14991
|
try {
|
|
14953
14992
|
this.o.cancel();
|
|
14954
14993
|
} catch (e) {
|
|
14955
|
-
|
|
14994
|
+
log30.warn(`cancel threw: ${e.message}`);
|
|
14956
14995
|
}
|
|
14957
14996
|
}
|
|
14958
14997
|
}
|
|
@@ -15062,7 +15101,7 @@ var SecondChannel = class {
|
|
|
15062
15101
|
if (r.nodes.length) tree.grow(r.nodes, this.userSpeaking ? words3(this.heard).length : 0);
|
|
15063
15102
|
this.o.onTree({ ms: Math.round(this.o.now() - t0), branches: r.nodes.length, lines: r.nodes.flatMap((n) => [n.line, ...n.next.map((k) => k.line)]), ...r.tokens ? { tokens: r.tokens } : {} });
|
|
15064
15103
|
}, (e) => {
|
|
15065
|
-
|
|
15104
|
+
log30.warn(`tree failed: ${e?.message ?? e}`);
|
|
15066
15105
|
this.o.onTree({ ms: Math.round(this.o.now() - t0), branches: 0, error: String(e?.message ?? e) });
|
|
15067
15106
|
}).finally(() => {
|
|
15068
15107
|
clearTimeout(late);
|
|
@@ -15116,7 +15155,7 @@ var SecondChannel = class {
|
|
|
15116
15155
|
if (gen === this.gen && echoesHeard(hit.node.line, heard)) this.askLeaf = { gen, text: hit.node.line };
|
|
15117
15156
|
return;
|
|
15118
15157
|
}
|
|
15119
|
-
if (hit && steer) return;
|
|
15158
|
+
if (hit && (steer || turnIntent(heard) === "ask")) return;
|
|
15120
15159
|
if (hit && gen === this.gen && (this.main === "queued" || this.main === "thinking")) {
|
|
15121
15160
|
this.playLeaf(hit, "working", "bridge");
|
|
15122
15161
|
if (this.lastKind === "bridge" && this.bridged) {
|
|
@@ -15171,7 +15210,7 @@ var SecondChannel = class {
|
|
|
15171
15210
|
const opts = this.options;
|
|
15172
15211
|
if (opts.mode === "chatty" && !opts.aec && !this.degradedLogged) {
|
|
15173
15212
|
this.degradedLogged = true;
|
|
15174
|
-
|
|
15213
|
+
log30.info("chatty mode without echo cancellation \u2014 normal timing (our lines would re-trigger the mic)");
|
|
15175
15214
|
}
|
|
15176
15215
|
const rule = this.rule(trigger, pauseMs, breath, cue);
|
|
15177
15216
|
if (rule === "silence") {
|
|
@@ -15190,14 +15229,14 @@ var SecondChannel = class {
|
|
|
15190
15229
|
const d = await withBudget(this.o.decide(this.tail(), { ...this.state(pauseMs), rule }, ac.signal), this.o.decisionBudgetMs, "channel decision", ac);
|
|
15191
15230
|
choice = d?.choice;
|
|
15192
15231
|
if (choice && choice in CHANNEL_ACTIONS && (choice === "silence" || this.allowed(choice))) kind = choice;
|
|
15193
|
-
else if (choice && choice in CHANNEL_ACTIONS)
|
|
15232
|
+
else if (choice && choice in CHANNEL_ACTIONS) log30.debug(`decider chose ${choice} for a ${rule} moment \u2014 the rule stands`);
|
|
15194
15233
|
}
|
|
15195
15234
|
if (kind === "silence") return ev({ choice, acted: "silence" });
|
|
15196
15235
|
if (stale()) return ev({ choice, kind, acted: "stale" });
|
|
15197
15236
|
if (!this.allowed(kind)) return ev({ choice, kind, acted: "gated" });
|
|
15198
15237
|
const react = kind === "backchannel" && !this.answeringUs && this.o.now() - this.lastReactAt >= this.o.reactionGapMs;
|
|
15199
15238
|
const text = cue && react && !this.recent.some((r) => norm3(r) === norm3(cue.line)) ? cue.line : await this.line(kind, react);
|
|
15200
|
-
if (!text) return ev({ choice, kind, acted: "no_bank" });
|
|
15239
|
+
if (!text) return ev({ choice, kind, acted: "no_bank", ...kind === "bridge" && this.ownWords ? { reason: this.noLine || (gen !== this.gen ? "turn moved on" : "no line") } : {} });
|
|
15201
15240
|
if (stale()) return ev({ choice, kind, text, acted: "stale" });
|
|
15202
15241
|
if (!this.allowed(kind)) return ev({ choice, kind, text, acted: "gated" });
|
|
15203
15242
|
const said = this.say(kind, text);
|
|
@@ -15224,13 +15263,15 @@ var SecondChannel = class {
|
|
|
15224
15263
|
this.bridgeDraft = null;
|
|
15225
15264
|
this.askLeaf = null;
|
|
15226
15265
|
this.bridgeReady = Promise.resolve();
|
|
15266
|
+
this.noLine = "";
|
|
15227
15267
|
if (!this.o.generate || !(this.ownWords || this.o.generateFor.includes("bridge")) || !this.lang || !this.heard) return;
|
|
15228
15268
|
const gen = this.gen, ac = new AbortController(), own = this.ownWords, heard = this.heard;
|
|
15229
15269
|
const ctx = { kind: "bridge", heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...own ? { ask: true } : {} };
|
|
15230
15270
|
this.bridgeReady = withBudget(this.o.generate(ctx, ac.signal), own ? this.o.bridgeBudgetMs : Math.max(this.o.generateBudgetMs, this.o.bridgeDelayMs), "bridge generate", ac).then((raw) => {
|
|
15231
|
-
const
|
|
15232
|
-
if (text && gen === this.gen &&
|
|
15233
|
-
|
|
15271
|
+
const none = own && /^\s*none\b/i.test(raw ?? ""), text = none ? "" : cleanLine(raw ?? "", ctx.lang), echoes = !own || echoesHeard(text, heard);
|
|
15272
|
+
if (text && gen === this.gen && echoes) this.bridgeDraft = { gen, text };
|
|
15273
|
+
else if (gen === this.gen) this.noLine = raw === null ? "fast model late or failed" : none ? "fast model: none" : !text ? "fast model line unusable" : "line names nothing heard";
|
|
15274
|
+
}).catch((e) => log30.debug(`bridge prefetch failed: ${e?.message ?? e}`));
|
|
15234
15275
|
}
|
|
15235
15276
|
async line(kind, react = true) {
|
|
15236
15277
|
if (kind === "bridge" && this.ownWords) {
|
|
@@ -15257,7 +15298,7 @@ var SecondChannel = class {
|
|
|
15257
15298
|
if (raw === null) ac.abort();
|
|
15258
15299
|
const text = cleanLine(raw ?? "", this.lang);
|
|
15259
15300
|
if (text && !this.recent.some((r) => norm3(r) === norm3(text))) return text;
|
|
15260
|
-
if (text)
|
|
15301
|
+
if (text) log30.debug(`generated "${text}" repeats a recent line \u2014 canned`);
|
|
15261
15302
|
}
|
|
15262
15303
|
return this.pick(kind);
|
|
15263
15304
|
}
|
|
@@ -15281,7 +15322,7 @@ var SecondChannel = class {
|
|
|
15281
15322
|
try {
|
|
15282
15323
|
r = this.o.speak(text, kind);
|
|
15283
15324
|
} catch (e) {
|
|
15284
|
-
|
|
15325
|
+
log30.warn(`speak threw \u2014 line dropped: ${e.message}`);
|
|
15285
15326
|
return false;
|
|
15286
15327
|
}
|
|
15287
15328
|
if (r === false) return false;
|
|
@@ -15295,7 +15336,7 @@ var SecondChannel = class {
|
|
|
15295
15336
|
if (words4) this.o.show(words4, kind);
|
|
15296
15337
|
const p = Promise.resolve(r).then(() => {
|
|
15297
15338
|
}, (e) => {
|
|
15298
|
-
|
|
15339
|
+
log30.warn(`channel line playback failed: ${e?.message ?? e}`);
|
|
15299
15340
|
}).finally(() => {
|
|
15300
15341
|
if (this.inflight === p) this.inflight = null;
|
|
15301
15342
|
});
|
|
@@ -15348,9 +15389,7 @@ ${personaHint(gender)} Output only the line.` : `You voice the tiny side-sounds
|
|
|
15348
15389
|
The assistant is: ${c.state}.
|
|
15349
15390
|
` + (c.avoid.length ? `Do not reuse any of: ${c.avoid.map((a) => `"${a}"`).join(", ")}.
|
|
15350
15391
|
` : "") + `React to their actual words, casually, in ${languageName(c.lang)}. ${personaHint(gender)} Output only the line.`;
|
|
15351
|
-
|
|
15352
|
-
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, maxTokens: 150, ...reasoning });
|
|
15353
|
-
return r.content ?? "";
|
|
15392
|
+
return fastText(ai, { model, prompt, signal });
|
|
15354
15393
|
};
|
|
15355
15394
|
}
|
|
15356
15395
|
function closedQuestion(reply) {
|
|
@@ -15361,7 +15400,7 @@ function closedQuestion(reply) {
|
|
|
15361
15400
|
}
|
|
15362
15401
|
|
|
15363
15402
|
// src/voice/call.ts
|
|
15364
|
-
var
|
|
15403
|
+
var log31 = forComponent("VoiceCall");
|
|
15365
15404
|
function newWords(text, turn) {
|
|
15366
15405
|
const said = new Set(norm3(turn).split(" "));
|
|
15367
15406
|
return norm3(text).split(" ").filter((w) => w && !said.has(w)).length;
|
|
@@ -15516,7 +15555,7 @@ var VoiceCall = class {
|
|
|
15516
15555
|
const c = this.cur, steers = !!this.o.noteTurn && this.working;
|
|
15517
15556
|
const resumed = !steers || c.marks.mainFirst === void 0 && this.o.now() - c.at < this.o.resumeMs;
|
|
15518
15557
|
if (this.o.mode === "live" && c?.running && !c.worded && resumed && newWords(text, c.text) >= 2) {
|
|
15519
|
-
|
|
15558
|
+
log31.debug("user resumed before the reply \u2014 yielded");
|
|
15520
15559
|
this.giveWay(c);
|
|
15521
15560
|
this.gate.reopen(c.id);
|
|
15522
15561
|
}
|
|
@@ -15535,9 +15574,13 @@ var VoiceCall = class {
|
|
|
15535
15574
|
this.sttLang = o.lang ? primaryLang(o.lang) : null;
|
|
15536
15575
|
this.lastWordAt = typeof lastWordAgoMs === "number" && lastWordAgoMs >= 0 ? now4 - lastWordAgoMs : null;
|
|
15537
15576
|
this.finalAt = now4;
|
|
15577
|
+
this.floor = `${this.floor} ${text}`.trim();
|
|
15578
|
+
if (!endsMidPhrase(text) && turnIntent(this.floor) !== "say") this.fill.onLineEnd();
|
|
15538
15579
|
this.gate.final(text, sttId);
|
|
15539
15580
|
}
|
|
15540
15581
|
finalAt = 0;
|
|
15582
|
+
floor = "";
|
|
15583
|
+
// the finals said since the last turn went out
|
|
15541
15584
|
sttLang = null;
|
|
15542
15585
|
// the STT's language for the final being followed
|
|
15543
15586
|
/** The host's player started a line's audio now (or in `inMs`): `fill`/`progress` = the fill channel's, `main` = MAIN's
|
|
@@ -15637,7 +15680,7 @@ var VoiceCall = class {
|
|
|
15637
15680
|
try {
|
|
15638
15681
|
this.o.cancel();
|
|
15639
15682
|
} catch (e) {
|
|
15640
|
-
|
|
15683
|
+
log31.warn(`cancel threw: ${e.message}`);
|
|
15641
15684
|
}
|
|
15642
15685
|
return;
|
|
15643
15686
|
}
|
|
@@ -15649,7 +15692,7 @@ var VoiceCall = class {
|
|
|
15649
15692
|
try {
|
|
15650
15693
|
this.o.cancel();
|
|
15651
15694
|
} catch (e) {
|
|
15652
|
-
|
|
15695
|
+
log31.warn(`cancel threw: ${e.message}`);
|
|
15653
15696
|
}
|
|
15654
15697
|
if (c?.running) {
|
|
15655
15698
|
c.running = false;
|
|
@@ -15701,6 +15744,7 @@ var VoiceCall = class {
|
|
|
15701
15744
|
if (l) this.fill.setLanguage(l, true);
|
|
15702
15745
|
}
|
|
15703
15746
|
onTurn(t) {
|
|
15747
|
+
this.floor = "";
|
|
15704
15748
|
if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
|
|
15705
15749
|
const now4 = this.o.now(), lastWord = this.lastWordAt !== null;
|
|
15706
15750
|
const at = this.lastWordAt ?? this.firstFinalAt ?? now4;
|
|
@@ -15727,6 +15771,7 @@ var VoiceCall = class {
|
|
|
15727
15771
|
this.firstFinalAt = null;
|
|
15728
15772
|
this.lastWordAt = null;
|
|
15729
15773
|
this.earlyHeard = null;
|
|
15774
|
+
this.floor = "";
|
|
15730
15775
|
}
|
|
15731
15776
|
this.o.onMetric({ name: "drop", kind: why, text });
|
|
15732
15777
|
}
|
|
@@ -15737,7 +15782,7 @@ var VoiceCall = class {
|
|
|
15737
15782
|
try {
|
|
15738
15783
|
r = this.o.speak(text, kind);
|
|
15739
15784
|
} catch (e) {
|
|
15740
|
-
|
|
15785
|
+
log31.warn(`speak threw: ${e.message}`);
|
|
15741
15786
|
return false;
|
|
15742
15787
|
}
|
|
15743
15788
|
if (r === false) return false;
|
|
@@ -15797,7 +15842,7 @@ var VoiceCall = class {
|
|
|
15797
15842
|
this.o.onMetric({ name: "turn", id: t.id, kind: "aside", text: t.text });
|
|
15798
15843
|
const ac = new AbortController(), late = setTimeout(() => ac.abort(), this.o.workReplyBudgetMs), lang = this.lang;
|
|
15799
15844
|
const raw = lang ? await this.o.workReply({ request: c.text, heard: t.text, tool: c.tool, hint: argsHint(c.args), lang, avoid: this.progress.recent }, ac.signal).catch((e) => {
|
|
15800
|
-
|
|
15845
|
+
log31.warn(`work reply failed \u2014 MAIN only: ${e?.message ?? e}`);
|
|
15801
15846
|
return "";
|
|
15802
15847
|
}).finally(() => clearTimeout(late)) : "";
|
|
15803
15848
|
const own = cleanWorkReply(raw, lang ?? ""), answer = own || workAck(raw, lang ?? "", this.o.gender);
|
|
@@ -15880,7 +15925,7 @@ init_logging();
|
|
|
15880
15925
|
init_platform();
|
|
15881
15926
|
import { spawn } from "child_process";
|
|
15882
15927
|
import { createHash } from "crypto";
|
|
15883
|
-
var
|
|
15928
|
+
var log32 = forComponent("mcp");
|
|
15884
15929
|
var PROTOCOL_VERSION = "2025-06-18";
|
|
15885
15930
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
15886
15931
|
var DEFAULT_CALL_TIMEOUT_MS = 30 * 6e4;
|
|
@@ -15912,7 +15957,7 @@ var StdioTransport = class {
|
|
|
15912
15957
|
proc.stdout.setEncoding("utf8");
|
|
15913
15958
|
proc.stdout.on("data", (chunk) => this.onData(chunk));
|
|
15914
15959
|
proc.stderr.setEncoding("utf8");
|
|
15915
|
-
proc.stderr.on("data", (chunk) =>
|
|
15960
|
+
proc.stderr.on("data", (chunk) => log32.debug(`[${command}] stderr:`, chunk.trimEnd()));
|
|
15916
15961
|
proc.on("exit", (code) => this.failAll(new Error(`MCP server "${command}" exited (code ${code})`)));
|
|
15917
15962
|
proc.on("error", (e) => this.failAll(e instanceof Error ? e : new Error(String(e))));
|
|
15918
15963
|
}
|
|
@@ -15926,7 +15971,7 @@ var StdioTransport = class {
|
|
|
15926
15971
|
try {
|
|
15927
15972
|
this.dispatch(JSON.parse(line));
|
|
15928
15973
|
} catch (e) {
|
|
15929
|
-
|
|
15974
|
+
log32.debug("dropping non-JSON line from MCP server:", line, e);
|
|
15930
15975
|
}
|
|
15931
15976
|
}
|
|
15932
15977
|
}
|
|
@@ -15936,7 +15981,7 @@ var StdioTransport = class {
|
|
|
15936
15981
|
try {
|
|
15937
15982
|
p2?.onProgress?.(msg.params ?? {});
|
|
15938
15983
|
} catch (e) {
|
|
15939
|
-
|
|
15984
|
+
log32.debug("onProgress handler threw", e);
|
|
15940
15985
|
}
|
|
15941
15986
|
return;
|
|
15942
15987
|
}
|
|
@@ -15974,7 +16019,7 @@ var StdioTransport = class {
|
|
|
15974
16019
|
const onAbort = () => {
|
|
15975
16020
|
if (!this.pending.delete(id)) return;
|
|
15976
16021
|
clearTimeout(timer);
|
|
15977
|
-
this.notify("notifications/cancelled", { requestId: id, reason: String(signal?.reason?.message ?? "cancelled") }).catch((e) =>
|
|
16022
|
+
this.notify("notifications/cancelled", { requestId: id, reason: String(signal?.reason?.message ?? "cancelled") }).catch((e) => log32.debug("cancel notify failed", e));
|
|
15978
16023
|
reject(abortError(signal));
|
|
15979
16024
|
};
|
|
15980
16025
|
const done = () => signal?.removeEventListener("abort", onAbort);
|
|
@@ -15998,7 +16043,7 @@ var StdioTransport = class {
|
|
|
15998
16043
|
try {
|
|
15999
16044
|
this.proc?.stdin?.end();
|
|
16000
16045
|
} catch (e) {
|
|
16001
|
-
|
|
16046
|
+
log32.debug("stdin end failed", e);
|
|
16002
16047
|
}
|
|
16003
16048
|
if (!(IS_WIN && killTree(this.proc?.pid, "SIGTERM"))) this.proc?.kill();
|
|
16004
16049
|
}
|
|
@@ -16033,7 +16078,7 @@ var HttpTransport = class {
|
|
|
16033
16078
|
return await this.post({ jsonrpc: "2.0", id, method, params: opts.onProgress ? withProgressToken(params, id) : params }, false, signal, opts.onProgress);
|
|
16034
16079
|
} catch (e) {
|
|
16035
16080
|
if (opts.signal?.aborted) {
|
|
16036
|
-
void this.notify("notifications/cancelled", { requestId: id, reason: String(opts.signal.reason?.message ?? "cancelled") }).catch((err2) =>
|
|
16081
|
+
void this.notify("notifications/cancelled", { requestId: id, reason: String(opts.signal.reason?.message ?? "cancelled") }).catch((err2) => log32.debug("cancel notify failed", err2));
|
|
16037
16082
|
throw abortError(opts.signal);
|
|
16038
16083
|
}
|
|
16039
16084
|
throw e;
|
|
@@ -16076,7 +16121,7 @@ function sseMessage(line) {
|
|
|
16076
16121
|
try {
|
|
16077
16122
|
return JSON.parse(trimmed.slice(5).trim());
|
|
16078
16123
|
} catch (e) {
|
|
16079
|
-
|
|
16124
|
+
log32.debug("skipping unparseable SSE data line", e);
|
|
16080
16125
|
return void 0;
|
|
16081
16126
|
}
|
|
16082
16127
|
}
|
|
@@ -16086,7 +16131,7 @@ async function readSseResponse(resp, id, onProgress) {
|
|
|
16086
16131
|
try {
|
|
16087
16132
|
onProgress?.(obj.params ?? {});
|
|
16088
16133
|
} catch (e) {
|
|
16089
|
-
|
|
16134
|
+
log32.debug("onProgress handler threw", e);
|
|
16090
16135
|
}
|
|
16091
16136
|
return void 0;
|
|
16092
16137
|
}
|
|
@@ -16185,7 +16230,7 @@ async function mountWithDeadline(name, cfg, mountTimeoutMs) {
|
|
|
16185
16230
|
return { name, client, tools, specs, serverInfo: init?.serverInfo, config: cfg };
|
|
16186
16231
|
})(), mountTimeoutMs, name);
|
|
16187
16232
|
} catch (e) {
|
|
16188
|
-
await client.close().catch((err2) =>
|
|
16233
|
+
await client.close().catch((err2) => log32.debug(`close after failed mount of "${name}": ${err2}`));
|
|
16189
16234
|
throw e;
|
|
16190
16235
|
}
|
|
16191
16236
|
}
|
|
@@ -16196,15 +16241,15 @@ function validEntries(servers) {
|
|
|
16196
16241
|
return Object.entries(servers).filter(([name, cfg]) => {
|
|
16197
16242
|
if (!cfg || cfg.disabled) return false;
|
|
16198
16243
|
if (!cfg.command && !cfg.url) {
|
|
16199
|
-
|
|
16244
|
+
log32.warn(`MCP server "${name}" needs a command (stdio) or url (http) \u2014 skipping`);
|
|
16200
16245
|
return false;
|
|
16201
16246
|
}
|
|
16202
16247
|
return true;
|
|
16203
16248
|
});
|
|
16204
16249
|
}
|
|
16205
16250
|
function logMountFailure(name, e) {
|
|
16206
|
-
if (e instanceof McpAuthError)
|
|
16207
|
-
else
|
|
16251
|
+
if (e instanceof McpAuthError) log32.warn(`MCP "${name}" needs-auth: HTTP ${e.status} \u2014 set bearerToken or headers in its config; skipping`);
|
|
16252
|
+
else log32.error(`MCP server "${name}" failed to mount: ${e?.message ?? e}`);
|
|
16208
16253
|
}
|
|
16209
16254
|
async function mountMcpServers(servers = {}, opts = {}) {
|
|
16210
16255
|
const entries = validEntries(servers);
|
|
@@ -16214,7 +16259,7 @@ async function mountMcpServers(servers = {}, opts = {}) {
|
|
|
16214
16259
|
const name = entries[i][0];
|
|
16215
16260
|
if (r.status === "fulfilled") {
|
|
16216
16261
|
out.push(r.value);
|
|
16217
|
-
|
|
16262
|
+
log32.debug(`MCP "${name}" mounted \u2014 ${r.value.tools.length} tool(s)${r.value.serverInfo?.name ? ` from ${r.value.serverInfo.name}` : ""}`);
|
|
16218
16263
|
} else logMountFailure(name, r.reason);
|
|
16219
16264
|
});
|
|
16220
16265
|
return out;
|
|
@@ -16254,7 +16299,7 @@ var McpPool = class {
|
|
|
16254
16299
|
const prev = this.warm.get(key);
|
|
16255
16300
|
if (prev) {
|
|
16256
16301
|
clearTimeout(prev.timer);
|
|
16257
|
-
if (prev.client !== client) void prev.client.close().catch((err2) =>
|
|
16302
|
+
if (prev.client !== client) void prev.client.close().catch((err2) => log32.debug(`warm-pool replace close failed: ${err2}`));
|
|
16258
16303
|
}
|
|
16259
16304
|
const e = { client, timer: void 0 };
|
|
16260
16305
|
this.warm.set(key, e);
|
|
@@ -16271,7 +16316,7 @@ var McpPool = class {
|
|
|
16271
16316
|
const e = this.warm.get(key);
|
|
16272
16317
|
if (!e) return;
|
|
16273
16318
|
this.warm.delete(key);
|
|
16274
|
-
await e.client.close().catch((err2) =>
|
|
16319
|
+
await e.client.close().catch((err2) => log32.debug(`warm-pool evict close failed: ${err2}`));
|
|
16275
16320
|
}
|
|
16276
16321
|
async closeAll() {
|
|
16277
16322
|
for (const e of this.warm.values()) {
|
|
@@ -16517,7 +16562,7 @@ init_tools_shell();
|
|
|
16517
16562
|
// src/tools.notify.ts
|
|
16518
16563
|
init_logging();
|
|
16519
16564
|
import { execFile as execFile2 } from "child_process";
|
|
16520
|
-
var
|
|
16565
|
+
var log34 = forComponent("notify");
|
|
16521
16566
|
var WIN_TOAST = [
|
|
16522
16567
|
"[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null",
|
|
16523
16568
|
"$t = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)",
|
|
@@ -16548,7 +16593,7 @@ function makeNotifyTool(opts = {}) {
|
|
|
16548
16593
|
return new Promise((resolve6) => {
|
|
16549
16594
|
run(argv[0], argv[1], { timeout: 5e3, ...extra }, (e) => {
|
|
16550
16595
|
if (e) {
|
|
16551
|
-
|
|
16596
|
+
log34.debug("notification failed", e);
|
|
16552
16597
|
resolve6(`Notification failed: ${e.message}`);
|
|
16553
16598
|
} else resolve6("Notification shown.");
|
|
16554
16599
|
});
|
|
@@ -16565,7 +16610,7 @@ init_logging();
|
|
|
16565
16610
|
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
16566
16611
|
import { homedir } from "os";
|
|
16567
16612
|
import { delimiter as delimiter2 } from "path";
|
|
16568
|
-
var
|
|
16613
|
+
var log35 = forComponent("cli-util");
|
|
16569
16614
|
function extraDirs(env = process.env) {
|
|
16570
16615
|
return (env.AGENTX_EXTRA_DIRS || "").split(delimiter2).map((d) => d.trim()).filter(Boolean);
|
|
16571
16616
|
}
|
|
@@ -16585,7 +16630,7 @@ function parseJson(text, fallback, what = "json") {
|
|
|
16585
16630
|
try {
|
|
16586
16631
|
return JSON.parse(text);
|
|
16587
16632
|
} catch (e) {
|
|
16588
|
-
|
|
16633
|
+
log35.debug(`parseJson(${what}) failed: ${e.message}`);
|
|
16589
16634
|
return fallback;
|
|
16590
16635
|
}
|
|
16591
16636
|
}
|
|
@@ -16595,7 +16640,7 @@ function readJsonFile(path, fallback) {
|
|
|
16595
16640
|
try {
|
|
16596
16641
|
text = readFileSync5(path, "utf8");
|
|
16597
16642
|
} catch (e) {
|
|
16598
|
-
|
|
16643
|
+
log35.debug(`readJsonFile(${path}) unreadable: ${e.message}`);
|
|
16599
16644
|
return fallback;
|
|
16600
16645
|
}
|
|
16601
16646
|
return parseJson(text, fallback, path);
|
|
@@ -16909,7 +16954,7 @@ import { appendFileSync, existsSync as existsSync4, mkdirSync as mkdirSync5, rea
|
|
|
16909
16954
|
import { homedir as homedir3 } from "os";
|
|
16910
16955
|
import { dirname as dirname4, join as join8 } from "path";
|
|
16911
16956
|
import { fileURLToPath } from "url";
|
|
16912
|
-
var
|
|
16957
|
+
var log36 = forComponent("VoiceIO");
|
|
16913
16958
|
var now3 = () => performance.now();
|
|
16914
16959
|
var Player = class {
|
|
16915
16960
|
proc = null;
|
|
@@ -16923,7 +16968,7 @@ var Player = class {
|
|
|
16923
16968
|
["-loglevel", "quiet", "-nodisp", "-fflags", "nobuffer", "-flags", "low_delay", "-probesize", "32", "-f", "s16le", "-ar", String(TTS_SAMPLE_RATE), "-ch_layout", "mono", "-i", "-"],
|
|
16924
16969
|
{ stdio: ["pipe", "ignore", "ignore"] }
|
|
16925
16970
|
);
|
|
16926
|
-
this.proc.on("error", (e) =>
|
|
16971
|
+
this.proc.on("error", (e) => log36.warn(`ffplay error: ${e.message}`));
|
|
16927
16972
|
this.proc.stdin.on("error", () => {
|
|
16928
16973
|
});
|
|
16929
16974
|
this.bytesWritten = 0;
|
|
@@ -16961,7 +17006,7 @@ function detectFfmpegMic() {
|
|
|
16961
17006
|
const devices = [...audio.matchAll(/\[(\d+)\] (.+)/g)].map(([, idx, name]) => ({ idx, name: name.trim() }));
|
|
16962
17007
|
const mic = devices.find((d) => /microphone|built-in/i.test(d.name) && !/teams|blackhole|loopback/i.test(d.name)) ?? devices[0];
|
|
16963
17008
|
if (!mic) throw new Error("no audio input device found");
|
|
16964
|
-
|
|
17009
|
+
log36.debug(`ffmpeg mic: [${mic.idx}] ${mic.name}`);
|
|
16965
17010
|
return `:${mic.idx}`;
|
|
16966
17011
|
}
|
|
16967
17012
|
function detectDshowMic() {
|
|
@@ -16972,7 +17017,7 @@ function detectDshowMic() {
|
|
|
16972
17017
|
const devices = [...(r.stderr ?? "").matchAll(/"([^"]+)"\s*\(audio\)/g)].map((m) => m[1]);
|
|
16973
17018
|
const mic = devices.find((d) => !/stereo mix|loopback|virtual|cable|teams/i.test(d)) ?? devices[0];
|
|
16974
17019
|
if (!mic) throw new Error("no audio input device found (set MIC_DEVICE to the DirectShow device name)");
|
|
16975
|
-
|
|
17020
|
+
log36.debug(`ffmpeg dshow mic: ${mic}`);
|
|
16976
17021
|
return `audio=${mic}`;
|
|
16977
17022
|
}
|
|
16978
17023
|
function detectedInputDevice() {
|
|
@@ -17008,15 +17053,15 @@ function resolveAecBinary() {
|
|
|
17008
17053
|
if (existsSync4(bin) && statSync6(bin).mtimeMs >= statSync6(src).mtimeMs) return bin;
|
|
17009
17054
|
if (spawnSync3("which", ["swiftc"]).status !== 0) return null;
|
|
17010
17055
|
mkdirSync5(cacheDir, { recursive: true });
|
|
17011
|
-
|
|
17056
|
+
log36.info("compiling AEC mic helper (first run)\u2026");
|
|
17012
17057
|
const build = spawnSync3("swiftc", ["-O", "-o", bin, src, "-Xlinker", "-sectcreate", "-Xlinker", "__TEXT", "-Xlinker", "__info_plist", "-Xlinker", plist], { encoding: "utf8" });
|
|
17013
17058
|
if (build.status !== 0) {
|
|
17014
|
-
|
|
17059
|
+
log36.warn(`AEC build failed: ${build.stderr?.slice(0, 400)}`);
|
|
17015
17060
|
return null;
|
|
17016
17061
|
}
|
|
17017
17062
|
const sign = spawnSync3("codesign", ["-fs", "-", bin], { encoding: "utf8" });
|
|
17018
17063
|
if (sign.status !== 0) {
|
|
17019
|
-
|
|
17064
|
+
log36.warn(`codesign failed: ${sign.stderr?.slice(0, 200)}`);
|
|
17020
17065
|
return null;
|
|
17021
17066
|
}
|
|
17022
17067
|
return bin;
|
|
@@ -17058,17 +17103,17 @@ var NodeMicSource = class {
|
|
|
17058
17103
|
this.proc = spawn2(this.bin, [], { stdio: ["ignore", "pipe", "ignore"] });
|
|
17059
17104
|
} else {
|
|
17060
17105
|
if (!hasCommand("ffmpeg")) throw new Error("voice I/O unavailable: no AEC helper and no ffmpeg on PATH");
|
|
17061
|
-
|
|
17106
|
+
log36.info("mic: raw capture (no AEC) \u2014 echo handled heuristically; headphones recommended");
|
|
17062
17107
|
const input = process.platform === "win32" ? ["-f", "dshow", "-i", detectDshowMic()] : ["-f", "avfoundation", "-i", detectFfmpegMic()];
|
|
17063
17108
|
this.proc = spawn2(
|
|
17064
17109
|
"ffmpeg",
|
|
17065
17110
|
["-loglevel", "error", ...input, "-ar", String(STT_SAMPLE_RATE), "-ac", "1", "-f", "s16le", "-"],
|
|
17066
17111
|
{ stdio: ["ignore", "pipe", "pipe"], ...process.platform === "win32" ? { windowsHide: true } : {} }
|
|
17067
17112
|
);
|
|
17068
|
-
this.proc.stderr.on("data", (d) =>
|
|
17113
|
+
this.proc.stderr.on("data", (d) => log36.warn(`ffmpeg: ${String(d).trim()}`));
|
|
17069
17114
|
}
|
|
17070
17115
|
this.proc.on("exit", (c) => {
|
|
17071
|
-
if (c && !this.stopped)
|
|
17116
|
+
if (c && !this.stopped) log36.error(`mic capture exited (${c}) \u2014 check mic permission / MIC_DEVICE / MIC_AEC=0`);
|
|
17072
17117
|
});
|
|
17073
17118
|
this.proc.stdout.on("data", (chunk) => onChunk(chunk));
|
|
17074
17119
|
}
|
|
@@ -17134,7 +17179,7 @@ var AecDuplexAudio = class {
|
|
|
17134
17179
|
this.proc.stdin.on("error", () => {
|
|
17135
17180
|
});
|
|
17136
17181
|
this.proc.on("exit", (c) => {
|
|
17137
|
-
if (c && !this.stopped)
|
|
17182
|
+
if (c && !this.stopped) log36.error(`aec duplex audio exited (${c}) \u2014 check mic permission / MIC_AEC=0`);
|
|
17138
17183
|
});
|
|
17139
17184
|
this.proc.stdout.on("data", (chunk) => {
|
|
17140
17185
|
this.gotChunk = true;
|
|
@@ -17150,7 +17195,7 @@ var AecDuplexAudio = class {
|
|
|
17150
17195
|
openMicSettings();
|
|
17151
17196
|
this.onFatal?.("microphone permission denied \u2014 enable it in System Settings \u2192 Privacy & Security \u2192 Microphone for your terminal, then restart it");
|
|
17152
17197
|
}
|
|
17153
|
-
} else
|
|
17198
|
+
} else log36.debug(`mic-aec: ${s}`);
|
|
17154
17199
|
}
|
|
17155
17200
|
});
|
|
17156
17201
|
if (!this.noVpio && !this.triedFallback) {
|
|
@@ -17159,7 +17204,7 @@ var AecDuplexAudio = class {
|
|
|
17159
17204
|
this.triedFallback = true;
|
|
17160
17205
|
this.noVpio = true;
|
|
17161
17206
|
this._aec = false;
|
|
17162
|
-
|
|
17207
|
+
log36.warn("mic-aec: VPIO delivered no audio in 2.5s \u2014 falling back to non-VPIO capture (no AEC \u2192 half-duplex, no barge-in)");
|
|
17163
17208
|
this.onDegrade?.();
|
|
17164
17209
|
this.killProc();
|
|
17165
17210
|
this.spawnHelper();
|
|
@@ -17330,7 +17375,7 @@ function bindAckInstinct(v, instinct) {
|
|
|
17330
17375
|
if (ev.kind === "ack_fired") instinct.ackOutcome(String(ev.phrase));
|
|
17331
17376
|
else if (ev.kind === "ack_skipped" || ev.kind === "ack_cancelled") instinct.ackOutcome(null);
|
|
17332
17377
|
} catch (e) {
|
|
17333
|
-
|
|
17378
|
+
log36.warn(`ack outcome tap failed: ${e instanceof Error ? e.message : e}`);
|
|
17334
17379
|
}
|
|
17335
17380
|
onDiag(ev);
|
|
17336
17381
|
};
|
|
@@ -17452,7 +17497,7 @@ function speakBlip(v, text) {
|
|
|
17452
17497
|
v.fireBackchannel();
|
|
17453
17498
|
return true;
|
|
17454
17499
|
} catch (e) {
|
|
17455
|
-
|
|
17500
|
+
log36.warn(`backchannel blip failed \u2014 line dropped: ${e.message}`);
|
|
17456
17501
|
return false;
|
|
17457
17502
|
} finally {
|
|
17458
17503
|
E.BACKCHANNELS = pool;
|
|
@@ -17471,7 +17516,7 @@ function channelInput(sc, m) {
|
|
|
17471
17516
|
}
|
|
17472
17517
|
if (m.type === "agent_state") {
|
|
17473
17518
|
if (typeof m.state === "string" && MAIN_STATES.has(m.state)) sc.onAgentState(m.state);
|
|
17474
|
-
else
|
|
17519
|
+
else log36.warn(`agent_state: unknown state ${JSON.stringify(m.state)} \u2014 ignored`);
|
|
17475
17520
|
return true;
|
|
17476
17521
|
}
|
|
17477
17522
|
return false;
|
|
@@ -17681,7 +17726,7 @@ function fakeTape(heardFile, saidFile) {
|
|
|
17681
17726
|
init_logging();
|
|
17682
17727
|
import { appendFile, mkdirSync as mkdirSync6 } from "fs";
|
|
17683
17728
|
import { dirname as dirname5 } from "path";
|
|
17684
|
-
var
|
|
17729
|
+
var log37 = forComponent("VoiceDiag");
|
|
17685
17730
|
var JsonlDiagSink = class {
|
|
17686
17731
|
constructor(path) {
|
|
17687
17732
|
this.path = path;
|
|
@@ -17722,7 +17767,7 @@ var JsonlDiagSink = class {
|
|
|
17722
17767
|
disable(e) {
|
|
17723
17768
|
this.disabled = true;
|
|
17724
17769
|
this.queue.length = 0;
|
|
17725
|
-
|
|
17770
|
+
log37.debug(`voice diag sink disabled (${this.path}): ${e instanceof Error ? e.message : e}`);
|
|
17726
17771
|
}
|
|
17727
17772
|
/** True once a failure permanently disabled the sink (tests/inspection). */
|
|
17728
17773
|
get isDisabled() {
|
|
@@ -17790,7 +17835,7 @@ var SpokenFilter = class {
|
|
|
17790
17835
|
|
|
17791
17836
|
// src/voice/greeting.ts
|
|
17792
17837
|
init_logging();
|
|
17793
|
-
var
|
|
17838
|
+
var log38 = forComponent("CallGreeting");
|
|
17794
17839
|
var CallGreetingOptions = class {
|
|
17795
17840
|
model = "groq/openai/gpt-oss-120b";
|
|
17796
17841
|
persona = "";
|
|
@@ -17803,7 +17848,6 @@ async function callGreeting(ai, options) {
|
|
|
17803
17848
|
${o.persona}
|
|
17804
17849
|
|
|
17805
17850
|
` : ""}You open a live voice call. Write ONE short spoken sentence that greets the caller and asks what they would like to do. Keep the persona's tone tags if it uses them. Output only the line.`;
|
|
17806
|
-
const reasoning = /gpt-oss/.test(o.model) ? { providerOptions: { reasoning_effort: "low" } } : {};
|
|
17807
17851
|
let timer;
|
|
17808
17852
|
const late = new Promise((r) => {
|
|
17809
17853
|
timer = setTimeout(() => {
|
|
@@ -17811,8 +17855,8 @@ ${o.persona}
|
|
|
17811
17855
|
r("");
|
|
17812
17856
|
}, o.budgetMs);
|
|
17813
17857
|
});
|
|
17814
|
-
const asked =
|
|
17815
|
-
|
|
17858
|
+
const asked = fastText(ai, { model: o.model, prompt, signal: ac.signal, maxTokens: 200 }).then((r) => r.trim().split("\n")[0].replace(/^["']|["']$/g, "")).catch((e) => {
|
|
17859
|
+
log38.warn(`greeting failed \u2014 canned line: ${e?.message ?? e}`);
|
|
17816
17860
|
return "";
|
|
17817
17861
|
});
|
|
17818
17862
|
const line = await Promise.race([asked, late]);
|
|
@@ -17967,7 +18011,7 @@ function applyOverlay(cfg, file) {
|
|
|
17967
18011
|
// cli/hooks-config.ts
|
|
17968
18012
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
17969
18013
|
init_platform();
|
|
17970
|
-
var
|
|
18014
|
+
var log39 = forComponent("hooks");
|
|
17971
18015
|
var escapeRegex = (s) => s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
17972
18016
|
function ruleMatches(rule, toolName) {
|
|
17973
18017
|
if (!rule.tool || rule.tool === "*") return true;
|
|
@@ -17986,7 +18030,7 @@ function runCmd(rule, env) {
|
|
|
17986
18030
|
});
|
|
17987
18031
|
return { code: r.status ?? 1, out: ((r.stdout ?? "") + (r.stderr ?? "")).trim() };
|
|
17988
18032
|
} catch (e) {
|
|
17989
|
-
|
|
18033
|
+
log39.debug(`hook command failed: ${rule.command}`, e);
|
|
17990
18034
|
return { code: 1, out: String(e?.message ?? e) };
|
|
17991
18035
|
}
|
|
17992
18036
|
}
|
|
@@ -18094,7 +18138,7 @@ import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as rea
|
|
|
18094
18138
|
import { homedir as homedir6 } from "os";
|
|
18095
18139
|
import { join as join11 } from "path";
|
|
18096
18140
|
init_platform();
|
|
18097
|
-
var
|
|
18141
|
+
var log40 = forComponent("session");
|
|
18098
18142
|
var globalDir = () => join11(homedir6(), ".agent", "sessions");
|
|
18099
18143
|
function indexLink(target, link2) {
|
|
18100
18144
|
try {
|
|
@@ -18157,7 +18201,7 @@ var SessionStore = class {
|
|
|
18157
18201
|
}
|
|
18158
18202
|
load(id) {
|
|
18159
18203
|
if (!this.safeId(id)) {
|
|
18160
|
-
|
|
18204
|
+
log40.debug(`rejecting unsafe session id: ${id}`);
|
|
18161
18205
|
return void 0;
|
|
18162
18206
|
}
|
|
18163
18207
|
const path = join11(this.dir, `${id}.json`);
|
|
@@ -18165,7 +18209,7 @@ var SessionStore = class {
|
|
|
18165
18209
|
try {
|
|
18166
18210
|
return JSON.parse(readFileSync8(path, "utf8"));
|
|
18167
18211
|
} catch (e) {
|
|
18168
|
-
|
|
18212
|
+
log40.debug(`unreadable session ${id} \u2014 ignoring`, e);
|
|
18169
18213
|
return void 0;
|
|
18170
18214
|
}
|
|
18171
18215
|
}
|
|
@@ -18178,7 +18222,7 @@ var SessionStore = class {
|
|
|
18178
18222
|
try {
|
|
18179
18223
|
metas.push(JSON.parse(readFileSync8(join11(this.dir, f), "utf8")).meta);
|
|
18180
18224
|
} catch (e) {
|
|
18181
|
-
|
|
18225
|
+
log40.debug(`skipping unreadable session file ${f}`, e);
|
|
18182
18226
|
}
|
|
18183
18227
|
}
|
|
18184
18228
|
return metas.sort((a, b) => b.updated - a.updated);
|
|
@@ -18610,7 +18654,7 @@ import { promisify } from "util";
|
|
|
18610
18654
|
import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync9 } from "fs";
|
|
18611
18655
|
import { homedir as homedir7 } from "os";
|
|
18612
18656
|
import { join as join12, resolve as resolve4, sep as sep3, parse as parsePath } from "path";
|
|
18613
|
-
var
|
|
18657
|
+
var log41 = forComponent("checkpoints");
|
|
18614
18658
|
var exec = promisify(execFile4);
|
|
18615
18659
|
var DEFAULT_EXCLUDE = [".agent/", ".git/", "node_modules/", "dist/", "build/", ".next/", "target/", ".venv/", "__pycache__/", "*.log"];
|
|
18616
18660
|
function isBroadRoot(p) {
|
|
@@ -18658,7 +18702,7 @@ var ShadowRepo = class {
|
|
|
18658
18702
|
writeFileSync6(join12(this.gitDir, "info", "exclude"), this.exclude.join("\n") + "\n");
|
|
18659
18703
|
this.ready = true;
|
|
18660
18704
|
} catch (e) {
|
|
18661
|
-
|
|
18705
|
+
log41.debug(`git checkpoints unavailable for ${this.workTree}`, e);
|
|
18662
18706
|
this.ready = false;
|
|
18663
18707
|
}
|
|
18664
18708
|
return this.ready;
|
|
@@ -18669,7 +18713,7 @@ var ShadowRepo = class {
|
|
|
18669
18713
|
}
|
|
18670
18714
|
async commit(label, forced = []) {
|
|
18671
18715
|
await this.run("add", "-A");
|
|
18672
|
-
for (const p of forced) await this.run("add", "-f", "--", p).catch((e) =>
|
|
18716
|
+
for (const p of forced) await this.run("add", "-f", "--", p).catch((e) => log41.debug(`force-add failed: ${p}`, e));
|
|
18673
18717
|
await this.run("commit", "--allow-empty", "-q", "-m", label);
|
|
18674
18718
|
}
|
|
18675
18719
|
/** Inject the CURRENT (pre-edit) content of `paths` into the turn-open restore point by amending it.
|
|
@@ -18677,8 +18721,8 @@ var ShadowRepo = class {
|
|
|
18677
18721
|
* turn-boundary `add -A` would never have captured it. Amend (vs a new commit) keeps one restore
|
|
18678
18722
|
* point per turn, so the REPL's turn↔frame mapping stays intact. */
|
|
18679
18723
|
async amendForced(paths) {
|
|
18680
|
-
for (const p of paths) await this.run("add", "-f", "--", p).catch((e) =>
|
|
18681
|
-
await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) =>
|
|
18724
|
+
for (const p of paths) await this.run("add", "-f", "--", p).catch((e) => log41.debug(`force-capture failed: ${p}`, e));
|
|
18725
|
+
await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) => log41.debug("amend failed", e));
|
|
18682
18726
|
}
|
|
18683
18727
|
/** Commits on `ref`, oldest-first (canonical index space). */
|
|
18684
18728
|
async log(ref) {
|
|
@@ -18738,7 +18782,7 @@ var ShadowRepo = class {
|
|
|
18738
18782
|
await this.run("gc", "--auto", "-q").catch(() => {
|
|
18739
18783
|
});
|
|
18740
18784
|
} catch (e) {
|
|
18741
|
-
|
|
18785
|
+
log41.debug("checkpoint prune failed", e);
|
|
18742
18786
|
}
|
|
18743
18787
|
}
|
|
18744
18788
|
};
|
|
@@ -18806,7 +18850,7 @@ var GitCheckpoints = class {
|
|
|
18806
18850
|
use(sessionId) {
|
|
18807
18851
|
if (sessionId === this.session) return;
|
|
18808
18852
|
this.session = sessionId;
|
|
18809
|
-
if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) =>
|
|
18853
|
+
if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) => log41.debug("re-point failed", e));
|
|
18810
18854
|
}
|
|
18811
18855
|
async begin(label) {
|
|
18812
18856
|
if (!await this.start()) return;
|
|
@@ -18826,7 +18870,7 @@ var GitCheckpoints = class {
|
|
|
18826
18870
|
process.stderr.write(`\x1B[2m checkpoints: '${this.repos[i].root}' too large to snapshot in ${Math.round(this.options.opTimeoutMs / 1e3)}s \u2014 file rewind disabled here\x1B[0m
|
|
18827
18871
|
`);
|
|
18828
18872
|
} else {
|
|
18829
|
-
|
|
18873
|
+
log41.debug("checkpoint commit failed", e);
|
|
18830
18874
|
survivors.push(this.repos[i]);
|
|
18831
18875
|
survivorCaches.push(this.caches[i] ?? []);
|
|
18832
18876
|
}
|
|
@@ -18861,7 +18905,7 @@ var GitCheckpoints = class {
|
|
|
18861
18905
|
if (this.forced.has(abs)) continue;
|
|
18862
18906
|
this.forced.add(abs);
|
|
18863
18907
|
const i = this.repoIndexFor(abs);
|
|
18864
|
-
if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) =>
|
|
18908
|
+
if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) => log41.debug("amendForced failed", e));
|
|
18865
18909
|
}
|
|
18866
18910
|
}
|
|
18867
18911
|
};
|
|
@@ -20651,7 +20695,7 @@ import { spawnSync as spawnSync6 } from "child_process";
|
|
|
20651
20695
|
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as existsSync7 } from "fs";
|
|
20652
20696
|
import { homedir as homedir8 } from "os";
|
|
20653
20697
|
import { join as join14 } from "path";
|
|
20654
|
-
var
|
|
20698
|
+
var log42 = forComponent("os-sched");
|
|
20655
20699
|
var OsScheduler = class {
|
|
20656
20700
|
options;
|
|
20657
20701
|
constructor(options) {
|
|
@@ -20713,7 +20757,7 @@ var OsScheduler = class {
|
|
|
20713
20757
|
}
|
|
20714
20758
|
}
|
|
20715
20759
|
} catch (e) {
|
|
20716
|
-
|
|
20760
|
+
log42.debug(`cancel ${id}`, e);
|
|
20717
20761
|
}
|
|
20718
20762
|
for (const f of [`${id}.json`, `${id}.sh`]) {
|
|
20719
20763
|
try {
|
|
@@ -20831,7 +20875,7 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync11, unlinkSync as unli
|
|
|
20831
20875
|
import { homedir as homedir9 } from "os";
|
|
20832
20876
|
import { join as join15 } from "path";
|
|
20833
20877
|
init_platform();
|
|
20834
|
-
var
|
|
20878
|
+
var log43 = forComponent("remote-trigger");
|
|
20835
20879
|
var TRIGGER_DIR = () => join15(homedir9(), ".agent", "triggers");
|
|
20836
20880
|
var sockPath = (sessionId, dir = TRIGGER_DIR()) => join15(dir, `${sessionId}.sock`);
|
|
20837
20881
|
var TriggerServer = class {
|
|
@@ -20869,13 +20913,13 @@ var TriggerServer = class {
|
|
|
20869
20913
|
conn.end(JSON.stringify({ ok: false, error: String(e) }) + "\n");
|
|
20870
20914
|
}
|
|
20871
20915
|
});
|
|
20872
|
-
conn.on("error", (e) =>
|
|
20916
|
+
conn.on("error", (e) => log43.debug("trigger conn error", e));
|
|
20873
20917
|
});
|
|
20874
|
-
this.server.on("error", (e) =>
|
|
20918
|
+
this.server.on("error", (e) => log43.debug("trigger server error", e));
|
|
20875
20919
|
this.server.listen(p);
|
|
20876
20920
|
this.path = p;
|
|
20877
20921
|
} catch (e) {
|
|
20878
|
-
|
|
20922
|
+
log43.debug("trigger server unavailable", e);
|
|
20879
20923
|
}
|
|
20880
20924
|
}
|
|
20881
20925
|
/** Re-bind on /resume (the session id changed). */
|
|
@@ -21007,7 +21051,7 @@ var strike = C("9");
|
|
|
21007
21051
|
var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
|
|
21008
21052
|
var mdPalette = { bold, dim, cyan, italic, strike, green, link };
|
|
21009
21053
|
var err = (s) => process.stderr.write(s);
|
|
21010
|
-
var
|
|
21054
|
+
var log44 = forComponent("cli");
|
|
21011
21055
|
var VERSION = (() => {
|
|
21012
21056
|
try {
|
|
21013
21057
|
return JSON.parse(readFileSync10(new URL("../package.json", import.meta.url), "utf8")).version ?? "?";
|
|
@@ -21911,7 +21955,7 @@ function turnCost(model, usage) {
|
|
|
21911
21955
|
const priced = model.startsWith("claude-code/") ? `anthropic/${resolveModelAlias(model.slice("claude-code/".length))}` : model;
|
|
21912
21956
|
return costOf(getModelInfo(priced)?.pricing, usage?.promptTokens ?? 0, usage?.completionTokens ?? 0, usage?.cacheCreationTokens ?? 0, usage?.cacheReadTokens ?? 0, priced);
|
|
21913
21957
|
}
|
|
21914
|
-
async function evaluateGoal(ai, condition, transcript,
|
|
21958
|
+
async function evaluateGoal(ai, condition, transcript, log45) {
|
|
21915
21959
|
const recent = transcript.filter((m) => m.role === "assistant").slice(-8).map((m) => {
|
|
21916
21960
|
const text = typeof m.content === "string" ? m.content : m.content.filter((p) => p.type === "text").map((p) => p.text).join(" ");
|
|
21917
21961
|
return text.slice(0, 600);
|
|
@@ -21931,7 +21975,7 @@ ${recent}` }
|
|
|
21931
21975
|
const match = r.content.match(/\{[\s\S]*\}/);
|
|
21932
21976
|
if (match) return JSON.parse(match[0]);
|
|
21933
21977
|
} catch (e) {
|
|
21934
|
-
|
|
21978
|
+
log45(dim(` (goal evaluator error: ${e?.message ?? e})
|
|
21935
21979
|
`));
|
|
21936
21980
|
}
|
|
21937
21981
|
return { met: false, reason: "evaluation unclear" };
|
|
@@ -22159,7 +22203,7 @@ function mcpAgentTools(mounted, opts) {
|
|
|
22159
22203
|
return tools;
|
|
22160
22204
|
}
|
|
22161
22205
|
async function closeMcp(mounted) {
|
|
22162
|
-
await Promise.all(mounted.map((m) => m.client.close().catch((e) =>
|
|
22206
|
+
await Promise.all(mounted.map((m) => m.client.close().catch((e) => log44.debug("mcp close failed", e))));
|
|
22163
22207
|
}
|
|
22164
22208
|
var IMG_EXT = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
|
|
22165
22209
|
function mentionRefs(line) {
|
|
@@ -22218,7 +22262,7 @@ async function expandMentions(fs, line) {
|
|
|
22218
22262
|
if (loaded.includes(ref) || missing.includes(ref)) continue;
|
|
22219
22263
|
if (ref.includes(":") && mcpMentionResolver) {
|
|
22220
22264
|
const body = await mcpMentionResolver(ref).catch((e) => {
|
|
22221
|
-
|
|
22265
|
+
log44.debug("mcp mention resolve failed", e);
|
|
22222
22266
|
return null;
|
|
22223
22267
|
});
|
|
22224
22268
|
if (body != null) {
|
|
@@ -22244,7 +22288,7 @@ ${await fs.readFile(path)}`);
|
|
|
22244
22288
|
${blocks.join("\n\n")}` : line, loaded, missing };
|
|
22245
22289
|
}
|
|
22246
22290
|
function applyTurnMode(agent, session, task, flags = {}, onModel) {
|
|
22247
|
-
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) =>
|
|
22291
|
+
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log44.debug(m) });
|
|
22248
22292
|
const d = p.directives, isMode = !!(d.delegate || d.advisor || d.modeOff);
|
|
22249
22293
|
if (p.unresolvedModel && /->|<-|delegate:|advisor:/.test(task.slice(0, task.length - p.prompt.length))) {
|
|
22250
22294
|
err(red(` \u2717 unknown model "${p.unresolvedModel}"${p.ambiguous ? ` (could be: ${p.ambiguous.join(", ")})` : ""} \u2014 turn not sent
|
|
@@ -22337,7 +22381,7 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
|
|
|
22337
22381
|
try {
|
|
22338
22382
|
store.save(session);
|
|
22339
22383
|
} catch (ex) {
|
|
22340
|
-
|
|
22384
|
+
log44.debug("mid-turn session flush failed", ex);
|
|
22341
22385
|
}
|
|
22342
22386
|
}
|
|
22343
22387
|
return origNotify(e);
|
|
@@ -22501,14 +22545,14 @@ var isCancelTeardown = (e) => {
|
|
|
22501
22545
|
function installCancelGuards(mounted) {
|
|
22502
22546
|
process.on("unhandledRejection", (e) => {
|
|
22503
22547
|
if (isCancelTeardown(e)) {
|
|
22504
|
-
|
|
22548
|
+
log44.debug("suppressed unhandledRejection (cursor stream cancel)", e);
|
|
22505
22549
|
return;
|
|
22506
22550
|
}
|
|
22507
|
-
|
|
22551
|
+
log44.error("unhandledRejection", e);
|
|
22508
22552
|
});
|
|
22509
22553
|
process.on("uncaughtException", (e) => {
|
|
22510
22554
|
if (isCancelTeardown(e)) {
|
|
22511
|
-
|
|
22555
|
+
log44.debug("suppressed uncaughtException (cursor stream cancel)", e);
|
|
22512
22556
|
return;
|
|
22513
22557
|
}
|
|
22514
22558
|
console.error(e);
|
|
@@ -22898,7 +22942,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
22898
22942
|
editorRef?.abort();
|
|
22899
22943
|
}
|
|
22900
22944
|
} catch (e) {
|
|
22901
|
-
|
|
22945
|
+
log44.error("call turn failed", e);
|
|
22902
22946
|
} finally {
|
|
22903
22947
|
rec.running = false;
|
|
22904
22948
|
call?.main({ type: "done", id });
|
|
@@ -23048,7 +23092,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
23048
23092
|
try {
|
|
23049
23093
|
mkdirSync12(dir, { recursive: true });
|
|
23050
23094
|
} catch (e) {
|
|
23051
|
-
|
|
23095
|
+
log44.debug("paste image dir create failed", e);
|
|
23052
23096
|
}
|
|
23053
23097
|
const img = grabClipboardImage(dir, String(Date.now()));
|
|
23054
23098
|
return img ? { display: "Image", ref: "@" + img.path, path: img.path } : null;
|
|
@@ -23161,7 +23205,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23161
23205
|
mkdirSync12(join16(cwd, ".agent"), { recursive: true });
|
|
23162
23206
|
appendFileSync2(histPath, line + "\n");
|
|
23163
23207
|
} catch (e) {
|
|
23164
|
-
|
|
23208
|
+
log44.debug("history write failed", e);
|
|
23165
23209
|
}
|
|
23166
23210
|
};
|
|
23167
23211
|
const ago = (t) => {
|
|
@@ -23233,7 +23277,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23233
23277
|
try {
|
|
23234
23278
|
store.save(session);
|
|
23235
23279
|
} catch (e) {
|
|
23236
|
-
|
|
23280
|
+
log44.debug("session save after rewind failed", e);
|
|
23237
23281
|
}
|
|
23238
23282
|
err(green(" \u27F2 jumped back") + dim(` \u2014 ${face.transcript.length} message(s) kept; edit + resend
|
|
23239
23283
|
`));
|
|
@@ -23268,7 +23312,7 @@ ${task}`;
|
|
|
23268
23312
|
bangContext.length = 0;
|
|
23269
23313
|
}
|
|
23270
23314
|
const delta = await refreshCatalogs().catch((e) => {
|
|
23271
|
-
|
|
23315
|
+
log44.debug("catalog refresh failed", e);
|
|
23272
23316
|
return "";
|
|
23273
23317
|
});
|
|
23274
23318
|
if (delta) {
|
|
@@ -23542,7 +23586,7 @@ ${task}`;
|
|
|
23542
23586
|
desc: "rescan skills/commands dirs and rebuild the system prompt (one cache miss) \u2014 picks up entries created mid-session",
|
|
23543
23587
|
run: async () => {
|
|
23544
23588
|
await refreshCatalogs().catch((e) => {
|
|
23545
|
-
|
|
23589
|
+
log44.debug("catalog refresh failed", e);
|
|
23546
23590
|
});
|
|
23547
23591
|
face.reprepare();
|
|
23548
23592
|
err(green(` \u2713 reloaded \u2014 ${skills.length} skill(s), ${cmds.length} command(s); system prompt rebuilds on next message
|
|
@@ -24045,7 +24089,7 @@ ${task}`;
|
|
|
24045
24089
|
try {
|
|
24046
24090
|
for (const def of (await loadAgents(fs2, d)).agents) if (!seen.has(def.name)) seen.set(def.name, { def, from: d });
|
|
24047
24091
|
} catch (e) {
|
|
24048
|
-
|
|
24092
|
+
log44.debug(`loadAgents(${d}) failed`, e);
|
|
24049
24093
|
}
|
|
24050
24094
|
}
|
|
24051
24095
|
if (!seen.size) {
|
|
@@ -24133,7 +24177,7 @@ ${task}`;
|
|
|
24133
24177
|
}
|
|
24134
24178
|
if (idx >= 0) {
|
|
24135
24179
|
const old = mounted.splice(idx, 1)[0];
|
|
24136
|
-
await old.client.close().catch((e) =>
|
|
24180
|
+
await old.client.close().catch((e) => log44.debug("mcp close failed", e));
|
|
24137
24181
|
}
|
|
24138
24182
|
try {
|
|
24139
24183
|
const m = await mountMcpServer(name, conf);
|
|
@@ -24161,7 +24205,7 @@ ${task}`;
|
|
|
24161
24205
|
}
|
|
24162
24206
|
const m = mounted.splice(idx, 1)[0];
|
|
24163
24207
|
remountMcpTools();
|
|
24164
|
-
await m.client.close().catch((e) =>
|
|
24208
|
+
await m.client.close().catch((e) => log44.debug("mcp close failed", e));
|
|
24165
24209
|
err(dim(` removed "${name}"
|
|
24166
24210
|
`));
|
|
24167
24211
|
return;
|
|
@@ -24364,7 +24408,7 @@ ${task}`;
|
|
|
24364
24408
|
try {
|
|
24365
24409
|
return readdirSync4(join16(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
|
|
24366
24410
|
} catch (e) {
|
|
24367
|
-
|
|
24411
|
+
log44.debug("completion readdir failed", absDir, e);
|
|
24368
24412
|
return null;
|
|
24369
24413
|
}
|
|
24370
24414
|
};
|
|
@@ -24503,7 +24547,7 @@ ${out}
|
|
|
24503
24547
|
return;
|
|
24504
24548
|
}
|
|
24505
24549
|
await refreshCatalogs().catch((e) => {
|
|
24506
|
-
|
|
24550
|
+
log44.debug("catalog refresh failed", e);
|
|
24507
24551
|
});
|
|
24508
24552
|
const sk = skills.find((x) => x.name === name);
|
|
24509
24553
|
if (sk) {
|
|
@@ -24633,7 +24677,7 @@ ${out}
|
|
|
24633
24677
|
if (delivery || cut) dx?.parkCutDelivery(delivery, !!cut, heard);
|
|
24634
24678
|
const cutReply = cut && cut.full.length - cut.heard.length > 40 ? cut : null;
|
|
24635
24679
|
const noteP = replaces ? replaces.note : !cutReply ? Promise.resolve("") : (instinct ? instinct.bargeIntent(text).catch((e) => {
|
|
24636
|
-
|
|
24680
|
+
log44.warn(`barge intent failed \u2014 model decides: ${e.message}`);
|
|
24637
24681
|
return void 0;
|
|
24638
24682
|
}) : Promise.resolve(void 0)).then(async (intent) => interruptionNote(cutReply, intent) + ackedNote(await instinct?.ackFor(text)));
|
|
24639
24683
|
const cutIn = replaces ? replaces.cutIn : interjectNote;
|
|
@@ -25034,10 +25078,10 @@ function channelOptions(ai, model, gender) {
|
|
|
25034
25078
|
// 0: the reactive live path
|
|
25035
25079
|
pickLeaf: fastLeafPicker(ai, process.env.AGENTX_LEAF_MODEL || "groq/openai/gpt-oss-120b"),
|
|
25036
25080
|
persona: process.env.AGENTX_CALL_PERSONA ?? "",
|
|
25037
|
-
onTree: (e) =>
|
|
25081
|
+
onTree: (e) => log44.debug(`voice tree: ${e.branches} branches in ${e.ms}ms${e.tokens ? ` tokens ${e.tokens.input}/${e.tokens.output}` : ""}${e.error ? ` error ${e.error}` : ""}`),
|
|
25038
25082
|
onEvent: (e) => {
|
|
25039
|
-
if (e.moment)
|
|
25040
|
-
else
|
|
25083
|
+
if (e.moment) log44.debug(`voice leaf: ${e.moment} ${e.conf} "${e.text}" ${e.acted}`);
|
|
25084
|
+
else log44.debug(`channel ${e.trigger}: rule=${e.rule} choice=${e.choice ?? "-"} \u2192 ${e.acted}${e.text ? ` "${e.text}"` : ""}${e.cue ? " (planned cue)" : ""} ${e.ms}ms`);
|
|
25041
25085
|
},
|
|
25042
25086
|
// Banks in the user's language: generated once per language, cached + topped up across sessions (~/.agent/cache).
|
|
25043
25087
|
banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir: join16(homedir10(), ".agent", "cache", "channel-banks") }),
|
|
@@ -25131,7 +25175,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25131
25175
|
try {
|
|
25132
25176
|
store.save(session);
|
|
25133
25177
|
} catch (e) {
|
|
25134
|
-
|
|
25178
|
+
log44.warn("duplex session save failed", e);
|
|
25135
25179
|
}
|
|
25136
25180
|
};
|
|
25137
25181
|
const overlap2 = overlapResponder(ai, args.duplexV2 ? args.channelMode : void 0, out);
|
|
@@ -25171,7 +25215,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25171
25215
|
done2();
|
|
25172
25216
|
out({ type: "turn_done", id, finishReason: res?.finishReason ?? "error", ...why ? { error: why } : {} });
|
|
25173
25217
|
}).catch((e) => {
|
|
25174
|
-
|
|
25218
|
+
log44.error("duplex turn failed", e);
|
|
25175
25219
|
done2();
|
|
25176
25220
|
out({ type: "turn_done", id, finishReason: "error", error: String(e?.message ?? e) });
|
|
25177
25221
|
});
|