@livx.cc/agentx 0.99.150 → 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.js CHANGED
@@ -2962,7 +2962,7 @@ async function psGroupCpuSeconds(pgid) {
2962
2962
  try {
2963
2963
  return await winTreeCpuSeconds(pgid);
2964
2964
  } catch (e) {
2965
- log32.debug(`cpu probe failed for ${pgid}: ${e}`);
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
- log32.debug(`ps cpu probe failed for group ${pgid}: ${e}`);
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
- log32.debug("shell spawn error", err2);
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 log32, clean2, DETACHED, shellArgv, SECRET_ENV_RE, _spawn, ShellJobRegistry, shellStatus, NO_JOB2;
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
- log32 = forComponent("shell");
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 log27 = forComponent("ConvoTree");
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) log27.debug(`unusable tree: ${(r.content ?? "").slice(0, 160)}`);
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 reasoning = /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
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 log28 = forComponent("Progress");
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
- log28.warn(`progress line failed: ${e?.message ?? e}`);
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
- const reasoning = /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
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
- const reasoning = /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
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 log29 = forComponent("SecondChannel");
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
- log29.debug(`${what}: over the ${ms}ms budget \u2014 dropped`);
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)) log29.debug(`${what}: aborted after its budget`);
14667
- else log29.warn(`${what} failed \u2014 falling back: ${msg}`);
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,8 +14735,12 @@ 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
14742
+ barged = false;
14743
+ // the user cut in since their last turn: that turn is a steer, not a story to react to
14713
14744
  leafReady = Promise.resolve();
14714
14745
  // live: the turn-end leaf pick settled
14715
14746
  recent = [];
@@ -14765,7 +14796,7 @@ var SecondChannel = class {
14765
14796
  if (host) this.pinned = true;
14766
14797
  const lang = primaryLang(tag);
14767
14798
  if (!lang || lang === this.lang) return;
14768
- log29.debug(`language ${this.lang} \u2192 ${lang}`);
14799
+ log30.debug(`language ${this.lang} \u2192 ${lang}`);
14769
14800
  this.lang = lang;
14770
14801
  this.recent = [];
14771
14802
  this.picks.clear();
@@ -14915,6 +14946,16 @@ var SecondChannel = class {
14915
14946
  }, Math.max(late, wait + 1));
14916
14947
  }
14917
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
+ }
14918
14959
  /** The user's final line was dispatched to the main agent (its words are the bridge's micro-context). */
14919
14960
  onUserTurn(text, lastWordAgoMs = 0) {
14920
14961
  this.heard = text.trim();
@@ -14924,9 +14965,11 @@ var SecondChannel = class {
14924
14965
  this.detect(this.heard);
14925
14966
  this.main = "idle";
14926
14967
  this.onAgentState("queued");
14968
+ const steer = this.barged;
14969
+ this.barged = false;
14927
14970
  if (this.tree) {
14928
14971
  this.noteTalk("them", this.heard);
14929
- this.leafReady = this.turnEndLeaf();
14972
+ this.leafReady = this.turnEndLeaf(steer);
14930
14973
  }
14931
14974
  }
14932
14975
  /** The main answer's streamed text (before its audio): channel-1 is responding — no bridge from here on. */
@@ -14941,13 +14984,14 @@ var SecondChannel = class {
14941
14984
  /** The user barged in: cut the in-flight line now and drop every pending decision. */
14942
14985
  onBargeIn() {
14943
14986
  this.gen++;
14987
+ this.barged = true;
14944
14988
  this.cutLine = this.inflight || this.live ? this.live : null;
14945
14989
  if (this.inflight) {
14946
14990
  this.inflight = null;
14947
14991
  try {
14948
14992
  this.o.cancel();
14949
14993
  } catch (e) {
14950
- log29.warn(`cancel threw: ${e.message}`);
14994
+ log30.warn(`cancel threw: ${e.message}`);
14951
14995
  }
14952
14996
  }
14953
14997
  }
@@ -15057,7 +15101,7 @@ var SecondChannel = class {
15057
15101
  if (r.nodes.length) tree.grow(r.nodes, this.userSpeaking ? words3(this.heard).length : 0);
15058
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 } : {} });
15059
15103
  }, (e) => {
15060
- log29.warn(`tree failed: ${e?.message ?? e}`);
15104
+ log30.warn(`tree failed: ${e?.message ?? e}`);
15061
15105
  this.o.onTree({ ms: Math.round(this.o.now() - t0), branches: 0, error: String(e?.message ?? e) });
15062
15106
  }).finally(() => {
15063
15107
  clearTimeout(late);
@@ -15098,7 +15142,7 @@ var SecondChannel = class {
15098
15142
  }
15099
15143
  /** The user's turn went to MAIN: the armed leaf at once, else the quick model may name one in time. It plays only while
15100
15144
  * MAIN is still silent, as the turn's first sound. */
15101
- async turnEndLeaf() {
15145
+ async turnEndLeaf(steer = false) {
15102
15146
  const tree = this.tree, gen = this.gen, heard = this.heard;
15103
15147
  let hit = tree.turnLeaf();
15104
15148
  if (!hit && this.o.pickLeaf && !tree.empty) {
@@ -15111,6 +15155,7 @@ var SecondChannel = class {
15111
15155
  if (gen === this.gen && echoesHeard(hit.node.line, heard)) this.askLeaf = { gen, text: hit.node.line };
15112
15156
  return;
15113
15157
  }
15158
+ if (hit && (steer || turnIntent(heard) === "ask")) return;
15114
15159
  if (hit && gen === this.gen && (this.main === "queued" || this.main === "thinking")) {
15115
15160
  this.playLeaf(hit, "working", "bridge");
15116
15161
  if (this.lastKind === "bridge" && this.bridged) {
@@ -15165,7 +15210,7 @@ var SecondChannel = class {
15165
15210
  const opts = this.options;
15166
15211
  if (opts.mode === "chatty" && !opts.aec && !this.degradedLogged) {
15167
15212
  this.degradedLogged = true;
15168
- log29.info("chatty mode without echo cancellation \u2014 normal timing (our lines would re-trigger the mic)");
15213
+ log30.info("chatty mode without echo cancellation \u2014 normal timing (our lines would re-trigger the mic)");
15169
15214
  }
15170
15215
  const rule = this.rule(trigger, pauseMs, breath, cue);
15171
15216
  if (rule === "silence") {
@@ -15184,14 +15229,14 @@ var SecondChannel = class {
15184
15229
  const d = await withBudget(this.o.decide(this.tail(), { ...this.state(pauseMs), rule }, ac.signal), this.o.decisionBudgetMs, "channel decision", ac);
15185
15230
  choice = d?.choice;
15186
15231
  if (choice && choice in CHANNEL_ACTIONS && (choice === "silence" || this.allowed(choice))) kind = choice;
15187
- else if (choice && choice in CHANNEL_ACTIONS) log29.debug(`decider chose ${choice} for a ${rule} moment \u2014 the rule stands`);
15232
+ else if (choice && choice in CHANNEL_ACTIONS) log30.debug(`decider chose ${choice} for a ${rule} moment \u2014 the rule stands`);
15188
15233
  }
15189
15234
  if (kind === "silence") return ev({ choice, acted: "silence" });
15190
15235
  if (stale()) return ev({ choice, kind, acted: "stale" });
15191
15236
  if (!this.allowed(kind)) return ev({ choice, kind, acted: "gated" });
15192
15237
  const react = kind === "backchannel" && !this.answeringUs && this.o.now() - this.lastReactAt >= this.o.reactionGapMs;
15193
15238
  const text = cue && react && !this.recent.some((r) => norm3(r) === norm3(cue.line)) ? cue.line : await this.line(kind, react);
15194
- 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") } : {} });
15195
15240
  if (stale()) return ev({ choice, kind, text, acted: "stale" });
15196
15241
  if (!this.allowed(kind)) return ev({ choice, kind, text, acted: "gated" });
15197
15242
  const said = this.say(kind, text);
@@ -15218,13 +15263,15 @@ var SecondChannel = class {
15218
15263
  this.bridgeDraft = null;
15219
15264
  this.askLeaf = null;
15220
15265
  this.bridgeReady = Promise.resolve();
15266
+ this.noLine = "";
15221
15267
  if (!this.o.generate || !(this.ownWords || this.o.generateFor.includes("bridge")) || !this.lang || !this.heard) return;
15222
15268
  const gen = this.gen, ac = new AbortController(), own = this.ownWords, heard = this.heard;
15223
15269
  const ctx = { kind: "bridge", heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...own ? { ask: true } : {} };
15224
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) => {
15225
- const text = own && /^\s*none\b/i.test(raw ?? "") ? "" : cleanLine(raw ?? "", ctx.lang);
15226
- if (text && gen === this.gen && (!own || echoesHeard(text, heard))) this.bridgeDraft = { gen, text };
15227
- }).catch((e) => log29.debug(`bridge prefetch failed: ${e?.message ?? e}`));
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}`));
15228
15275
  }
15229
15276
  async line(kind, react = true) {
15230
15277
  if (kind === "bridge" && this.ownWords) {
@@ -15251,7 +15298,7 @@ var SecondChannel = class {
15251
15298
  if (raw === null) ac.abort();
15252
15299
  const text = cleanLine(raw ?? "", this.lang);
15253
15300
  if (text && !this.recent.some((r) => norm3(r) === norm3(text))) return text;
15254
- if (text) log29.debug(`generated "${text}" repeats a recent line \u2014 canned`);
15301
+ if (text) log30.debug(`generated "${text}" repeats a recent line \u2014 canned`);
15255
15302
  }
15256
15303
  return this.pick(kind);
15257
15304
  }
@@ -15275,7 +15322,7 @@ var SecondChannel = class {
15275
15322
  try {
15276
15323
  r = this.o.speak(text, kind);
15277
15324
  } catch (e) {
15278
- log29.warn(`speak threw \u2014 line dropped: ${e.message}`);
15325
+ log30.warn(`speak threw \u2014 line dropped: ${e.message}`);
15279
15326
  return false;
15280
15327
  }
15281
15328
  if (r === false) return false;
@@ -15289,7 +15336,7 @@ var SecondChannel = class {
15289
15336
  if (words4) this.o.show(words4, kind);
15290
15337
  const p = Promise.resolve(r).then(() => {
15291
15338
  }, (e) => {
15292
- log29.warn(`channel line playback failed: ${e?.message ?? e}`);
15339
+ log30.warn(`channel line playback failed: ${e?.message ?? e}`);
15293
15340
  }).finally(() => {
15294
15341
  if (this.inflight === p) this.inflight = null;
15295
15342
  });
@@ -15342,9 +15389,7 @@ ${personaHint(gender)} Output only the line.` : `You voice the tiny side-sounds
15342
15389
  The assistant is: ${c.state}.
15343
15390
  ` + (c.avoid.length ? `Do not reuse any of: ${c.avoid.map((a) => `"${a}"`).join(", ")}.
15344
15391
  ` : "") + `React to their actual words, casually, in ${languageName(c.lang)}. ${personaHint(gender)} Output only the line.`;
15345
- const reasoning = /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
15346
- const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, maxTokens: 150, ...reasoning });
15347
- return r.content ?? "";
15392
+ return fastText(ai, { model, prompt, signal });
15348
15393
  };
15349
15394
  }
15350
15395
  function closedQuestion(reply) {
@@ -15355,7 +15400,7 @@ function closedQuestion(reply) {
15355
15400
  }
15356
15401
 
15357
15402
  // src/voice/call.ts
15358
- var log30 = forComponent("VoiceCall");
15403
+ var log31 = forComponent("VoiceCall");
15359
15404
  function newWords(text, turn) {
15360
15405
  const said = new Set(norm3(turn).split(" "));
15361
15406
  return norm3(text).split(" ").filter((w) => w && !said.has(w)).length;
@@ -15510,7 +15555,7 @@ var VoiceCall = class {
15510
15555
  const c = this.cur, steers = !!this.o.noteTurn && this.working;
15511
15556
  const resumed = !steers || c.marks.mainFirst === void 0 && this.o.now() - c.at < this.o.resumeMs;
15512
15557
  if (this.o.mode === "live" && c?.running && !c.worded && resumed && newWords(text, c.text) >= 2) {
15513
- log30.debug("user resumed before the reply \u2014 yielded");
15558
+ log31.debug("user resumed before the reply \u2014 yielded");
15514
15559
  this.giveWay(c);
15515
15560
  this.gate.reopen(c.id);
15516
15561
  }
@@ -15529,9 +15574,13 @@ var VoiceCall = class {
15529
15574
  this.sttLang = o.lang ? primaryLang(o.lang) : null;
15530
15575
  this.lastWordAt = typeof lastWordAgoMs === "number" && lastWordAgoMs >= 0 ? now4 - lastWordAgoMs : null;
15531
15576
  this.finalAt = now4;
15577
+ this.floor = `${this.floor} ${text}`.trim();
15578
+ if (!endsMidPhrase(text) && turnIntent(this.floor) !== "say") this.fill.onLineEnd();
15532
15579
  this.gate.final(text, sttId);
15533
15580
  }
15534
15581
  finalAt = 0;
15582
+ floor = "";
15583
+ // the finals said since the last turn went out
15535
15584
  sttLang = null;
15536
15585
  // the STT's language for the final being followed
15537
15586
  /** The host's player started a line's audio now (or in `inMs`): `fill`/`progress` = the fill channel's, `main` = MAIN's
@@ -15631,7 +15680,7 @@ var VoiceCall = class {
15631
15680
  try {
15632
15681
  this.o.cancel();
15633
15682
  } catch (e) {
15634
- log30.warn(`cancel threw: ${e.message}`);
15683
+ log31.warn(`cancel threw: ${e.message}`);
15635
15684
  }
15636
15685
  return;
15637
15686
  }
@@ -15643,7 +15692,7 @@ var VoiceCall = class {
15643
15692
  try {
15644
15693
  this.o.cancel();
15645
15694
  } catch (e) {
15646
- log30.warn(`cancel threw: ${e.message}`);
15695
+ log31.warn(`cancel threw: ${e.message}`);
15647
15696
  }
15648
15697
  if (c?.running) {
15649
15698
  c.running = false;
@@ -15695,6 +15744,7 @@ var VoiceCall = class {
15695
15744
  if (l) this.fill.setLanguage(l, true);
15696
15745
  }
15697
15746
  onTurn(t) {
15747
+ this.floor = "";
15698
15748
  if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
15699
15749
  const now4 = this.o.now(), lastWord = this.lastWordAt !== null;
15700
15750
  const at = this.lastWordAt ?? this.firstFinalAt ?? now4;
@@ -15721,6 +15771,7 @@ var VoiceCall = class {
15721
15771
  this.firstFinalAt = null;
15722
15772
  this.lastWordAt = null;
15723
15773
  this.earlyHeard = null;
15774
+ this.floor = "";
15724
15775
  }
15725
15776
  this.o.onMetric({ name: "drop", kind: why, text });
15726
15777
  }
@@ -15731,7 +15782,7 @@ var VoiceCall = class {
15731
15782
  try {
15732
15783
  r = this.o.speak(text, kind);
15733
15784
  } catch (e) {
15734
- log30.warn(`speak threw: ${e.message}`);
15785
+ log31.warn(`speak threw: ${e.message}`);
15735
15786
  return false;
15736
15787
  }
15737
15788
  if (r === false) return false;
@@ -15791,10 +15842,12 @@ var VoiceCall = class {
15791
15842
  this.o.onMetric({ name: "turn", id: t.id, kind: "aside", text: t.text });
15792
15843
  const ac = new AbortController(), late = setTimeout(() => ac.abort(), this.o.workReplyBudgetMs), lang = this.lang;
15793
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) => {
15794
- log30.warn(`work reply failed \u2014 MAIN only: ${e?.message ?? e}`);
15845
+ log31.warn(`work reply failed \u2014 MAIN only: ${e?.message ?? e}`);
15795
15846
  return "";
15796
15847
  }).finally(() => clearTimeout(late)) : "";
15797
- const ack = workAck(raw, lang ?? "", this.o.gender), line = cleanWorkReply(raw, lang ?? "") || ack, stop = /^\s*stop\s*:/i.test(raw), change = !line || /^\s*work\s*:/i.test(raw);
15848
+ const own = cleanWorkReply(raw, lang ?? ""), answer = own || workAck(raw, lang ?? "", this.o.gender);
15849
+ const line = own || (this.o.mode === "live" ? "" : answer);
15850
+ const stop = /^\s*stop\s*:/i.test(raw), change = !answer || /^\s*work\s*:/i.test(raw);
15798
15851
  const noted = `[The user said this on the call while you worked: "${t.text}".${line ? ` You answered aloud: "${line}".` : ""}${stop ? " That stopped the work." : ""} Take it into account; do not answer it again.]`;
15799
15852
  if (line && !this.ended) {
15800
15853
  for (let i = 0; i < 8 && this.say(line, "aside") === false; i++) {
@@ -15872,7 +15925,7 @@ init_logging();
15872
15925
  init_platform();
15873
15926
  import { spawn } from "child_process";
15874
15927
  import { createHash } from "crypto";
15875
- var log31 = forComponent("mcp");
15928
+ var log32 = forComponent("mcp");
15876
15929
  var PROTOCOL_VERSION = "2025-06-18";
15877
15930
  var DEFAULT_TIMEOUT_MS = 3e4;
15878
15931
  var DEFAULT_CALL_TIMEOUT_MS = 30 * 6e4;
@@ -15904,7 +15957,7 @@ var StdioTransport = class {
15904
15957
  proc.stdout.setEncoding("utf8");
15905
15958
  proc.stdout.on("data", (chunk) => this.onData(chunk));
15906
15959
  proc.stderr.setEncoding("utf8");
15907
- proc.stderr.on("data", (chunk) => log31.debug(`[${command}] stderr:`, chunk.trimEnd()));
15960
+ proc.stderr.on("data", (chunk) => log32.debug(`[${command}] stderr:`, chunk.trimEnd()));
15908
15961
  proc.on("exit", (code) => this.failAll(new Error(`MCP server "${command}" exited (code ${code})`)));
15909
15962
  proc.on("error", (e) => this.failAll(e instanceof Error ? e : new Error(String(e))));
15910
15963
  }
@@ -15918,7 +15971,7 @@ var StdioTransport = class {
15918
15971
  try {
15919
15972
  this.dispatch(JSON.parse(line));
15920
15973
  } catch (e) {
15921
- log31.debug("dropping non-JSON line from MCP server:", line, e);
15974
+ log32.debug("dropping non-JSON line from MCP server:", line, e);
15922
15975
  }
15923
15976
  }
15924
15977
  }
@@ -15928,7 +15981,7 @@ var StdioTransport = class {
15928
15981
  try {
15929
15982
  p2?.onProgress?.(msg.params ?? {});
15930
15983
  } catch (e) {
15931
- log31.debug("onProgress handler threw", e);
15984
+ log32.debug("onProgress handler threw", e);
15932
15985
  }
15933
15986
  return;
15934
15987
  }
@@ -15966,7 +16019,7 @@ var StdioTransport = class {
15966
16019
  const onAbort = () => {
15967
16020
  if (!this.pending.delete(id)) return;
15968
16021
  clearTimeout(timer);
15969
- this.notify("notifications/cancelled", { requestId: id, reason: String(signal?.reason?.message ?? "cancelled") }).catch((e) => log31.debug("cancel notify failed", e));
16022
+ this.notify("notifications/cancelled", { requestId: id, reason: String(signal?.reason?.message ?? "cancelled") }).catch((e) => log32.debug("cancel notify failed", e));
15970
16023
  reject(abortError(signal));
15971
16024
  };
15972
16025
  const done = () => signal?.removeEventListener("abort", onAbort);
@@ -15990,7 +16043,7 @@ var StdioTransport = class {
15990
16043
  try {
15991
16044
  this.proc?.stdin?.end();
15992
16045
  } catch (e) {
15993
- log31.debug("stdin end failed", e);
16046
+ log32.debug("stdin end failed", e);
15994
16047
  }
15995
16048
  if (!(IS_WIN && killTree(this.proc?.pid, "SIGTERM"))) this.proc?.kill();
15996
16049
  }
@@ -16025,7 +16078,7 @@ var HttpTransport = class {
16025
16078
  return await this.post({ jsonrpc: "2.0", id, method, params: opts.onProgress ? withProgressToken(params, id) : params }, false, signal, opts.onProgress);
16026
16079
  } catch (e) {
16027
16080
  if (opts.signal?.aborted) {
16028
- void this.notify("notifications/cancelled", { requestId: id, reason: String(opts.signal.reason?.message ?? "cancelled") }).catch((err2) => log31.debug("cancel notify failed", err2));
16081
+ void this.notify("notifications/cancelled", { requestId: id, reason: String(opts.signal.reason?.message ?? "cancelled") }).catch((err2) => log32.debug("cancel notify failed", err2));
16029
16082
  throw abortError(opts.signal);
16030
16083
  }
16031
16084
  throw e;
@@ -16068,7 +16121,7 @@ function sseMessage(line) {
16068
16121
  try {
16069
16122
  return JSON.parse(trimmed.slice(5).trim());
16070
16123
  } catch (e) {
16071
- log31.debug("skipping unparseable SSE data line", e);
16124
+ log32.debug("skipping unparseable SSE data line", e);
16072
16125
  return void 0;
16073
16126
  }
16074
16127
  }
@@ -16078,7 +16131,7 @@ async function readSseResponse(resp, id, onProgress) {
16078
16131
  try {
16079
16132
  onProgress?.(obj.params ?? {});
16080
16133
  } catch (e) {
16081
- log31.debug("onProgress handler threw", e);
16134
+ log32.debug("onProgress handler threw", e);
16082
16135
  }
16083
16136
  return void 0;
16084
16137
  }
@@ -16177,7 +16230,7 @@ async function mountWithDeadline(name, cfg, mountTimeoutMs) {
16177
16230
  return { name, client, tools, specs, serverInfo: init?.serverInfo, config: cfg };
16178
16231
  })(), mountTimeoutMs, name);
16179
16232
  } catch (e) {
16180
- await client.close().catch((err2) => log31.debug(`close after failed mount of "${name}": ${err2}`));
16233
+ await client.close().catch((err2) => log32.debug(`close after failed mount of "${name}": ${err2}`));
16181
16234
  throw e;
16182
16235
  }
16183
16236
  }
@@ -16188,15 +16241,15 @@ function validEntries(servers) {
16188
16241
  return Object.entries(servers).filter(([name, cfg]) => {
16189
16242
  if (!cfg || cfg.disabled) return false;
16190
16243
  if (!cfg.command && !cfg.url) {
16191
- log31.warn(`MCP server "${name}" needs a command (stdio) or url (http) \u2014 skipping`);
16244
+ log32.warn(`MCP server "${name}" needs a command (stdio) or url (http) \u2014 skipping`);
16192
16245
  return false;
16193
16246
  }
16194
16247
  return true;
16195
16248
  });
16196
16249
  }
16197
16250
  function logMountFailure(name, e) {
16198
- if (e instanceof McpAuthError) log31.warn(`MCP "${name}" needs-auth: HTTP ${e.status} \u2014 set bearerToken or headers in its config; skipping`);
16199
- else log31.error(`MCP server "${name}" failed to mount: ${e?.message ?? e}`);
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}`);
16200
16253
  }
16201
16254
  async function mountMcpServers(servers = {}, opts = {}) {
16202
16255
  const entries = validEntries(servers);
@@ -16206,7 +16259,7 @@ async function mountMcpServers(servers = {}, opts = {}) {
16206
16259
  const name = entries[i][0];
16207
16260
  if (r.status === "fulfilled") {
16208
16261
  out.push(r.value);
16209
- log31.debug(`MCP "${name}" mounted \u2014 ${r.value.tools.length} tool(s)${r.value.serverInfo?.name ? ` from ${r.value.serverInfo.name}` : ""}`);
16262
+ log32.debug(`MCP "${name}" mounted \u2014 ${r.value.tools.length} tool(s)${r.value.serverInfo?.name ? ` from ${r.value.serverInfo.name}` : ""}`);
16210
16263
  } else logMountFailure(name, r.reason);
16211
16264
  });
16212
16265
  return out;
@@ -16246,7 +16299,7 @@ var McpPool = class {
16246
16299
  const prev = this.warm.get(key);
16247
16300
  if (prev) {
16248
16301
  clearTimeout(prev.timer);
16249
- if (prev.client !== client) void prev.client.close().catch((err2) => log31.debug(`warm-pool replace close failed: ${err2}`));
16302
+ if (prev.client !== client) void prev.client.close().catch((err2) => log32.debug(`warm-pool replace close failed: ${err2}`));
16250
16303
  }
16251
16304
  const e = { client, timer: void 0 };
16252
16305
  this.warm.set(key, e);
@@ -16263,7 +16316,7 @@ var McpPool = class {
16263
16316
  const e = this.warm.get(key);
16264
16317
  if (!e) return;
16265
16318
  this.warm.delete(key);
16266
- await e.client.close().catch((err2) => log31.debug(`warm-pool evict close failed: ${err2}`));
16319
+ await e.client.close().catch((err2) => log32.debug(`warm-pool evict close failed: ${err2}`));
16267
16320
  }
16268
16321
  async closeAll() {
16269
16322
  for (const e of this.warm.values()) {
@@ -16509,7 +16562,7 @@ init_tools_shell();
16509
16562
  // src/tools.notify.ts
16510
16563
  init_logging();
16511
16564
  import { execFile as execFile2 } from "child_process";
16512
- var log33 = forComponent("notify");
16565
+ var log34 = forComponent("notify");
16513
16566
  var WIN_TOAST = [
16514
16567
  "[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null",
16515
16568
  "$t = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)",
@@ -16540,7 +16593,7 @@ function makeNotifyTool(opts = {}) {
16540
16593
  return new Promise((resolve6) => {
16541
16594
  run(argv[0], argv[1], { timeout: 5e3, ...extra }, (e) => {
16542
16595
  if (e) {
16543
- log33.debug("notification failed", e);
16596
+ log34.debug("notification failed", e);
16544
16597
  resolve6(`Notification failed: ${e.message}`);
16545
16598
  } else resolve6("Notification shown.");
16546
16599
  });
@@ -16557,7 +16610,7 @@ init_logging();
16557
16610
  import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
16558
16611
  import { homedir } from "os";
16559
16612
  import { delimiter as delimiter2 } from "path";
16560
- var log34 = forComponent("cli-util");
16613
+ var log35 = forComponent("cli-util");
16561
16614
  function extraDirs(env = process.env) {
16562
16615
  return (env.AGENTX_EXTRA_DIRS || "").split(delimiter2).map((d) => d.trim()).filter(Boolean);
16563
16616
  }
@@ -16577,7 +16630,7 @@ function parseJson(text, fallback, what = "json") {
16577
16630
  try {
16578
16631
  return JSON.parse(text);
16579
16632
  } catch (e) {
16580
- log34.debug(`parseJson(${what}) failed: ${e.message}`);
16633
+ log35.debug(`parseJson(${what}) failed: ${e.message}`);
16581
16634
  return fallback;
16582
16635
  }
16583
16636
  }
@@ -16587,7 +16640,7 @@ function readJsonFile(path, fallback) {
16587
16640
  try {
16588
16641
  text = readFileSync5(path, "utf8");
16589
16642
  } catch (e) {
16590
- log34.debug(`readJsonFile(${path}) unreadable: ${e.message}`);
16643
+ log35.debug(`readJsonFile(${path}) unreadable: ${e.message}`);
16591
16644
  return fallback;
16592
16645
  }
16593
16646
  return parseJson(text, fallback, path);
@@ -16901,7 +16954,7 @@ import { appendFileSync, existsSync as existsSync4, mkdirSync as mkdirSync5, rea
16901
16954
  import { homedir as homedir3 } from "os";
16902
16955
  import { dirname as dirname4, join as join8 } from "path";
16903
16956
  import { fileURLToPath } from "url";
16904
- var log35 = forComponent("VoiceIO");
16957
+ var log36 = forComponent("VoiceIO");
16905
16958
  var now3 = () => performance.now();
16906
16959
  var Player = class {
16907
16960
  proc = null;
@@ -16915,7 +16968,7 @@ var Player = class {
16915
16968
  ["-loglevel", "quiet", "-nodisp", "-fflags", "nobuffer", "-flags", "low_delay", "-probesize", "32", "-f", "s16le", "-ar", String(TTS_SAMPLE_RATE), "-ch_layout", "mono", "-i", "-"],
16916
16969
  { stdio: ["pipe", "ignore", "ignore"] }
16917
16970
  );
16918
- this.proc.on("error", (e) => log35.warn(`ffplay error: ${e.message}`));
16971
+ this.proc.on("error", (e) => log36.warn(`ffplay error: ${e.message}`));
16919
16972
  this.proc.stdin.on("error", () => {
16920
16973
  });
16921
16974
  this.bytesWritten = 0;
@@ -16953,7 +17006,7 @@ function detectFfmpegMic() {
16953
17006
  const devices = [...audio.matchAll(/\[(\d+)\] (.+)/g)].map(([, idx, name]) => ({ idx, name: name.trim() }));
16954
17007
  const mic = devices.find((d) => /microphone|built-in/i.test(d.name) && !/teams|blackhole|loopback/i.test(d.name)) ?? devices[0];
16955
17008
  if (!mic) throw new Error("no audio input device found");
16956
- log35.debug(`ffmpeg mic: [${mic.idx}] ${mic.name}`);
17009
+ log36.debug(`ffmpeg mic: [${mic.idx}] ${mic.name}`);
16957
17010
  return `:${mic.idx}`;
16958
17011
  }
16959
17012
  function detectDshowMic() {
@@ -16964,7 +17017,7 @@ function detectDshowMic() {
16964
17017
  const devices = [...(r.stderr ?? "").matchAll(/"([^"]+)"\s*\(audio\)/g)].map((m) => m[1]);
16965
17018
  const mic = devices.find((d) => !/stereo mix|loopback|virtual|cable|teams/i.test(d)) ?? devices[0];
16966
17019
  if (!mic) throw new Error("no audio input device found (set MIC_DEVICE to the DirectShow device name)");
16967
- log35.debug(`ffmpeg dshow mic: ${mic}`);
17020
+ log36.debug(`ffmpeg dshow mic: ${mic}`);
16968
17021
  return `audio=${mic}`;
16969
17022
  }
16970
17023
  function detectedInputDevice() {
@@ -17000,15 +17053,15 @@ function resolveAecBinary() {
17000
17053
  if (existsSync4(bin) && statSync6(bin).mtimeMs >= statSync6(src).mtimeMs) return bin;
17001
17054
  if (spawnSync3("which", ["swiftc"]).status !== 0) return null;
17002
17055
  mkdirSync5(cacheDir, { recursive: true });
17003
- log35.info("compiling AEC mic helper (first run)\u2026");
17056
+ log36.info("compiling AEC mic helper (first run)\u2026");
17004
17057
  const build = spawnSync3("swiftc", ["-O", "-o", bin, src, "-Xlinker", "-sectcreate", "-Xlinker", "__TEXT", "-Xlinker", "__info_plist", "-Xlinker", plist], { encoding: "utf8" });
17005
17058
  if (build.status !== 0) {
17006
- log35.warn(`AEC build failed: ${build.stderr?.slice(0, 400)}`);
17059
+ log36.warn(`AEC build failed: ${build.stderr?.slice(0, 400)}`);
17007
17060
  return null;
17008
17061
  }
17009
17062
  const sign = spawnSync3("codesign", ["-fs", "-", bin], { encoding: "utf8" });
17010
17063
  if (sign.status !== 0) {
17011
- log35.warn(`codesign failed: ${sign.stderr?.slice(0, 200)}`);
17064
+ log36.warn(`codesign failed: ${sign.stderr?.slice(0, 200)}`);
17012
17065
  return null;
17013
17066
  }
17014
17067
  return bin;
@@ -17050,17 +17103,17 @@ var NodeMicSource = class {
17050
17103
  this.proc = spawn2(this.bin, [], { stdio: ["ignore", "pipe", "ignore"] });
17051
17104
  } else {
17052
17105
  if (!hasCommand("ffmpeg")) throw new Error("voice I/O unavailable: no AEC helper and no ffmpeg on PATH");
17053
- log35.info("mic: raw capture (no AEC) \u2014 echo handled heuristically; headphones recommended");
17106
+ log36.info("mic: raw capture (no AEC) \u2014 echo handled heuristically; headphones recommended");
17054
17107
  const input = process.platform === "win32" ? ["-f", "dshow", "-i", detectDshowMic()] : ["-f", "avfoundation", "-i", detectFfmpegMic()];
17055
17108
  this.proc = spawn2(
17056
17109
  "ffmpeg",
17057
17110
  ["-loglevel", "error", ...input, "-ar", String(STT_SAMPLE_RATE), "-ac", "1", "-f", "s16le", "-"],
17058
17111
  { stdio: ["ignore", "pipe", "pipe"], ...process.platform === "win32" ? { windowsHide: true } : {} }
17059
17112
  );
17060
- this.proc.stderr.on("data", (d) => log35.warn(`ffmpeg: ${String(d).trim()}`));
17113
+ this.proc.stderr.on("data", (d) => log36.warn(`ffmpeg: ${String(d).trim()}`));
17061
17114
  }
17062
17115
  this.proc.on("exit", (c) => {
17063
- if (c && !this.stopped) log35.error(`mic capture exited (${c}) \u2014 check mic permission / MIC_DEVICE / MIC_AEC=0`);
17116
+ if (c && !this.stopped) log36.error(`mic capture exited (${c}) \u2014 check mic permission / MIC_DEVICE / MIC_AEC=0`);
17064
17117
  });
17065
17118
  this.proc.stdout.on("data", (chunk) => onChunk(chunk));
17066
17119
  }
@@ -17126,7 +17179,7 @@ var AecDuplexAudio = class {
17126
17179
  this.proc.stdin.on("error", () => {
17127
17180
  });
17128
17181
  this.proc.on("exit", (c) => {
17129
- if (c && !this.stopped) log35.error(`aec duplex audio exited (${c}) \u2014 check mic permission / MIC_AEC=0`);
17182
+ if (c && !this.stopped) log36.error(`aec duplex audio exited (${c}) \u2014 check mic permission / MIC_AEC=0`);
17130
17183
  });
17131
17184
  this.proc.stdout.on("data", (chunk) => {
17132
17185
  this.gotChunk = true;
@@ -17142,7 +17195,7 @@ var AecDuplexAudio = class {
17142
17195
  openMicSettings();
17143
17196
  this.onFatal?.("microphone permission denied \u2014 enable it in System Settings \u2192 Privacy & Security \u2192 Microphone for your terminal, then restart it");
17144
17197
  }
17145
- } else log35.debug(`mic-aec: ${s}`);
17198
+ } else log36.debug(`mic-aec: ${s}`);
17146
17199
  }
17147
17200
  });
17148
17201
  if (!this.noVpio && !this.triedFallback) {
@@ -17151,7 +17204,7 @@ var AecDuplexAudio = class {
17151
17204
  this.triedFallback = true;
17152
17205
  this.noVpio = true;
17153
17206
  this._aec = false;
17154
- log35.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)");
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)");
17155
17208
  this.onDegrade?.();
17156
17209
  this.killProc();
17157
17210
  this.spawnHelper();
@@ -17322,7 +17375,7 @@ function bindAckInstinct(v, instinct) {
17322
17375
  if (ev.kind === "ack_fired") instinct.ackOutcome(String(ev.phrase));
17323
17376
  else if (ev.kind === "ack_skipped" || ev.kind === "ack_cancelled") instinct.ackOutcome(null);
17324
17377
  } catch (e) {
17325
- log35.warn(`ack outcome tap failed: ${e instanceof Error ? e.message : e}`);
17378
+ log36.warn(`ack outcome tap failed: ${e instanceof Error ? e.message : e}`);
17326
17379
  }
17327
17380
  onDiag(ev);
17328
17381
  };
@@ -17444,7 +17497,7 @@ function speakBlip(v, text) {
17444
17497
  v.fireBackchannel();
17445
17498
  return true;
17446
17499
  } catch (e) {
17447
- log35.warn(`backchannel blip failed \u2014 line dropped: ${e.message}`);
17500
+ log36.warn(`backchannel blip failed \u2014 line dropped: ${e.message}`);
17448
17501
  return false;
17449
17502
  } finally {
17450
17503
  E.BACKCHANNELS = pool;
@@ -17463,7 +17516,7 @@ function channelInput(sc, m) {
17463
17516
  }
17464
17517
  if (m.type === "agent_state") {
17465
17518
  if (typeof m.state === "string" && MAIN_STATES.has(m.state)) sc.onAgentState(m.state);
17466
- else log35.warn(`agent_state: unknown state ${JSON.stringify(m.state)} \u2014 ignored`);
17519
+ else log36.warn(`agent_state: unknown state ${JSON.stringify(m.state)} \u2014 ignored`);
17467
17520
  return true;
17468
17521
  }
17469
17522
  return false;
@@ -17673,7 +17726,7 @@ function fakeTape(heardFile, saidFile) {
17673
17726
  init_logging();
17674
17727
  import { appendFile, mkdirSync as mkdirSync6 } from "fs";
17675
17728
  import { dirname as dirname5 } from "path";
17676
- var log36 = forComponent("VoiceDiag");
17729
+ var log37 = forComponent("VoiceDiag");
17677
17730
  var JsonlDiagSink = class {
17678
17731
  constructor(path) {
17679
17732
  this.path = path;
@@ -17714,7 +17767,7 @@ var JsonlDiagSink = class {
17714
17767
  disable(e) {
17715
17768
  this.disabled = true;
17716
17769
  this.queue.length = 0;
17717
- log36.debug(`voice diag sink disabled (${this.path}): ${e instanceof Error ? e.message : e}`);
17770
+ log37.debug(`voice diag sink disabled (${this.path}): ${e instanceof Error ? e.message : e}`);
17718
17771
  }
17719
17772
  /** True once a failure permanently disabled the sink (tests/inspection). */
17720
17773
  get isDisabled() {
@@ -17782,7 +17835,7 @@ var SpokenFilter = class {
17782
17835
 
17783
17836
  // src/voice/greeting.ts
17784
17837
  init_logging();
17785
- var log37 = forComponent("CallGreeting");
17838
+ var log38 = forComponent("CallGreeting");
17786
17839
  var CallGreetingOptions = class {
17787
17840
  model = "groq/openai/gpt-oss-120b";
17788
17841
  persona = "";
@@ -17795,7 +17848,6 @@ async function callGreeting(ai, options) {
17795
17848
  ${o.persona}
17796
17849
 
17797
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.`;
17798
- const reasoning = /gpt-oss/.test(o.model) ? { providerOptions: { reasoning_effort: "low" } } : {};
17799
17851
  let timer;
17800
17852
  const late = new Promise((r) => {
17801
17853
  timer = setTimeout(() => {
@@ -17803,8 +17855,8 @@ ${o.persona}
17803
17855
  r("");
17804
17856
  }, o.budgetMs);
17805
17857
  });
17806
- const asked = Promise.resolve(ai.chat({ model: o.model, messages: [{ role: "user", content: prompt }], stream: false, signal: ac.signal, maxTokens: 200, ...reasoning })).then((r) => (r.content ?? "").trim().split("\n")[0].replace(/^["']|["']$/g, "")).catch((e) => {
17807
- log37.warn(`greeting failed \u2014 canned line: ${e?.message ?? e}`);
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}`);
17808
17860
  return "";
17809
17861
  });
17810
17862
  const line = await Promise.race([asked, late]);
@@ -17959,7 +18011,7 @@ function applyOverlay(cfg, file) {
17959
18011
  // cli/hooks-config.ts
17960
18012
  import { spawnSync as spawnSync4 } from "child_process";
17961
18013
  init_platform();
17962
- var log38 = forComponent("hooks");
18014
+ var log39 = forComponent("hooks");
17963
18015
  var escapeRegex = (s) => s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
17964
18016
  function ruleMatches(rule, toolName) {
17965
18017
  if (!rule.tool || rule.tool === "*") return true;
@@ -17978,7 +18030,7 @@ function runCmd(rule, env) {
17978
18030
  });
17979
18031
  return { code: r.status ?? 1, out: ((r.stdout ?? "") + (r.stderr ?? "")).trim() };
17980
18032
  } catch (e) {
17981
- log38.debug(`hook command failed: ${rule.command}`, e);
18033
+ log39.debug(`hook command failed: ${rule.command}`, e);
17982
18034
  return { code: 1, out: String(e?.message ?? e) };
17983
18035
  }
17984
18036
  }
@@ -18086,7 +18138,7 @@ import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as rea
18086
18138
  import { homedir as homedir6 } from "os";
18087
18139
  import { join as join11 } from "path";
18088
18140
  init_platform();
18089
- var log39 = forComponent("session");
18141
+ var log40 = forComponent("session");
18090
18142
  var globalDir = () => join11(homedir6(), ".agent", "sessions");
18091
18143
  function indexLink(target, link2) {
18092
18144
  try {
@@ -18149,7 +18201,7 @@ var SessionStore = class {
18149
18201
  }
18150
18202
  load(id) {
18151
18203
  if (!this.safeId(id)) {
18152
- log39.debug(`rejecting unsafe session id: ${id}`);
18204
+ log40.debug(`rejecting unsafe session id: ${id}`);
18153
18205
  return void 0;
18154
18206
  }
18155
18207
  const path = join11(this.dir, `${id}.json`);
@@ -18157,7 +18209,7 @@ var SessionStore = class {
18157
18209
  try {
18158
18210
  return JSON.parse(readFileSync8(path, "utf8"));
18159
18211
  } catch (e) {
18160
- log39.debug(`unreadable session ${id} \u2014 ignoring`, e);
18212
+ log40.debug(`unreadable session ${id} \u2014 ignoring`, e);
18161
18213
  return void 0;
18162
18214
  }
18163
18215
  }
@@ -18170,7 +18222,7 @@ var SessionStore = class {
18170
18222
  try {
18171
18223
  metas.push(JSON.parse(readFileSync8(join11(this.dir, f), "utf8")).meta);
18172
18224
  } catch (e) {
18173
- log39.debug(`skipping unreadable session file ${f}`, e);
18225
+ log40.debug(`skipping unreadable session file ${f}`, e);
18174
18226
  }
18175
18227
  }
18176
18228
  return metas.sort((a, b) => b.updated - a.updated);
@@ -18602,7 +18654,7 @@ import { promisify } from "util";
18602
18654
  import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync9 } from "fs";
18603
18655
  import { homedir as homedir7 } from "os";
18604
18656
  import { join as join12, resolve as resolve4, sep as sep3, parse as parsePath } from "path";
18605
- var log40 = forComponent("checkpoints");
18657
+ var log41 = forComponent("checkpoints");
18606
18658
  var exec = promisify(execFile4);
18607
18659
  var DEFAULT_EXCLUDE = [".agent/", ".git/", "node_modules/", "dist/", "build/", ".next/", "target/", ".venv/", "__pycache__/", "*.log"];
18608
18660
  function isBroadRoot(p) {
@@ -18650,7 +18702,7 @@ var ShadowRepo = class {
18650
18702
  writeFileSync6(join12(this.gitDir, "info", "exclude"), this.exclude.join("\n") + "\n");
18651
18703
  this.ready = true;
18652
18704
  } catch (e) {
18653
- log40.debug(`git checkpoints unavailable for ${this.workTree}`, e);
18705
+ log41.debug(`git checkpoints unavailable for ${this.workTree}`, e);
18654
18706
  this.ready = false;
18655
18707
  }
18656
18708
  return this.ready;
@@ -18661,7 +18713,7 @@ var ShadowRepo = class {
18661
18713
  }
18662
18714
  async commit(label, forced = []) {
18663
18715
  await this.run("add", "-A");
18664
- for (const p of forced) await this.run("add", "-f", "--", p).catch((e) => log40.debug(`force-add failed: ${p}`, e));
18716
+ for (const p of forced) await this.run("add", "-f", "--", p).catch((e) => log41.debug(`force-add failed: ${p}`, e));
18665
18717
  await this.run("commit", "--allow-empty", "-q", "-m", label);
18666
18718
  }
18667
18719
  /** Inject the CURRENT (pre-edit) content of `paths` into the turn-open restore point by amending it.
@@ -18669,8 +18721,8 @@ var ShadowRepo = class {
18669
18721
  * turn-boundary `add -A` would never have captured it. Amend (vs a new commit) keeps one restore
18670
18722
  * point per turn, so the REPL's turn↔frame mapping stays intact. */
18671
18723
  async amendForced(paths) {
18672
- for (const p of paths) await this.run("add", "-f", "--", p).catch((e) => log40.debug(`force-capture failed: ${p}`, e));
18673
- await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) => log40.debug("amend failed", 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));
18674
18726
  }
18675
18727
  /** Commits on `ref`, oldest-first (canonical index space). */
18676
18728
  async log(ref) {
@@ -18730,7 +18782,7 @@ var ShadowRepo = class {
18730
18782
  await this.run("gc", "--auto", "-q").catch(() => {
18731
18783
  });
18732
18784
  } catch (e) {
18733
- log40.debug("checkpoint prune failed", e);
18785
+ log41.debug("checkpoint prune failed", e);
18734
18786
  }
18735
18787
  }
18736
18788
  };
@@ -18798,7 +18850,7 @@ var GitCheckpoints = class {
18798
18850
  use(sessionId) {
18799
18851
  if (sessionId === this.session) return;
18800
18852
  this.session = sessionId;
18801
- if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) => log40.debug("re-point failed", e));
18853
+ if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) => log41.debug("re-point failed", e));
18802
18854
  }
18803
18855
  async begin(label) {
18804
18856
  if (!await this.start()) return;
@@ -18818,7 +18870,7 @@ var GitCheckpoints = class {
18818
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
18819
18871
  `);
18820
18872
  } else {
18821
- log40.debug("checkpoint commit failed", e);
18873
+ log41.debug("checkpoint commit failed", e);
18822
18874
  survivors.push(this.repos[i]);
18823
18875
  survivorCaches.push(this.caches[i] ?? []);
18824
18876
  }
@@ -18853,7 +18905,7 @@ var GitCheckpoints = class {
18853
18905
  if (this.forced.has(abs)) continue;
18854
18906
  this.forced.add(abs);
18855
18907
  const i = this.repoIndexFor(abs);
18856
- if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) => log40.debug("amendForced failed", e));
18908
+ if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) => log41.debug("amendForced failed", e));
18857
18909
  }
18858
18910
  }
18859
18911
  };
@@ -20643,7 +20695,7 @@ import { spawnSync as spawnSync6 } from "child_process";
20643
20695
  import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as existsSync7 } from "fs";
20644
20696
  import { homedir as homedir8 } from "os";
20645
20697
  import { join as join14 } from "path";
20646
- var log41 = forComponent("os-sched");
20698
+ var log42 = forComponent("os-sched");
20647
20699
  var OsScheduler = class {
20648
20700
  options;
20649
20701
  constructor(options) {
@@ -20705,7 +20757,7 @@ var OsScheduler = class {
20705
20757
  }
20706
20758
  }
20707
20759
  } catch (e) {
20708
- log41.debug(`cancel ${id}`, e);
20760
+ log42.debug(`cancel ${id}`, e);
20709
20761
  }
20710
20762
  for (const f of [`${id}.json`, `${id}.sh`]) {
20711
20763
  try {
@@ -20823,7 +20875,7 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync11, unlinkSync as unli
20823
20875
  import { homedir as homedir9 } from "os";
20824
20876
  import { join as join15 } from "path";
20825
20877
  init_platform();
20826
- var log42 = forComponent("remote-trigger");
20878
+ var log43 = forComponent("remote-trigger");
20827
20879
  var TRIGGER_DIR = () => join15(homedir9(), ".agent", "triggers");
20828
20880
  var sockPath = (sessionId, dir = TRIGGER_DIR()) => join15(dir, `${sessionId}.sock`);
20829
20881
  var TriggerServer = class {
@@ -20861,13 +20913,13 @@ var TriggerServer = class {
20861
20913
  conn.end(JSON.stringify({ ok: false, error: String(e) }) + "\n");
20862
20914
  }
20863
20915
  });
20864
- conn.on("error", (e) => log42.debug("trigger conn error", e));
20916
+ conn.on("error", (e) => log43.debug("trigger conn error", e));
20865
20917
  });
20866
- this.server.on("error", (e) => log42.debug("trigger server error", e));
20918
+ this.server.on("error", (e) => log43.debug("trigger server error", e));
20867
20919
  this.server.listen(p);
20868
20920
  this.path = p;
20869
20921
  } catch (e) {
20870
- log42.debug("trigger server unavailable", e);
20922
+ log43.debug("trigger server unavailable", e);
20871
20923
  }
20872
20924
  }
20873
20925
  /** Re-bind on /resume (the session id changed). */
@@ -20999,7 +21051,7 @@ var strike = C("9");
20999
21051
  var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
21000
21052
  var mdPalette = { bold, dim, cyan, italic, strike, green, link };
21001
21053
  var err = (s) => process.stderr.write(s);
21002
- var log43 = forComponent("cli");
21054
+ var log44 = forComponent("cli");
21003
21055
  var VERSION = (() => {
21004
21056
  try {
21005
21057
  return JSON.parse(readFileSync10(new URL("../package.json", import.meta.url), "utf8")).version ?? "?";
@@ -21903,7 +21955,7 @@ function turnCost(model, usage) {
21903
21955
  const priced = model.startsWith("claude-code/") ? `anthropic/${resolveModelAlias(model.slice("claude-code/".length))}` : model;
21904
21956
  return costOf(getModelInfo(priced)?.pricing, usage?.promptTokens ?? 0, usage?.completionTokens ?? 0, usage?.cacheCreationTokens ?? 0, usage?.cacheReadTokens ?? 0, priced);
21905
21957
  }
21906
- async function evaluateGoal(ai, condition, transcript, log44) {
21958
+ async function evaluateGoal(ai, condition, transcript, log45) {
21907
21959
  const recent = transcript.filter((m) => m.role === "assistant").slice(-8).map((m) => {
21908
21960
  const text = typeof m.content === "string" ? m.content : m.content.filter((p) => p.type === "text").map((p) => p.text).join(" ");
21909
21961
  return text.slice(0, 600);
@@ -21923,7 +21975,7 @@ ${recent}` }
21923
21975
  const match = r.content.match(/\{[\s\S]*\}/);
21924
21976
  if (match) return JSON.parse(match[0]);
21925
21977
  } catch (e) {
21926
- log44(dim(` (goal evaluator error: ${e?.message ?? e})
21978
+ log45(dim(` (goal evaluator error: ${e?.message ?? e})
21927
21979
  `));
21928
21980
  }
21929
21981
  return { met: false, reason: "evaluation unclear" };
@@ -22151,7 +22203,7 @@ function mcpAgentTools(mounted, opts) {
22151
22203
  return tools;
22152
22204
  }
22153
22205
  async function closeMcp(mounted) {
22154
- await Promise.all(mounted.map((m) => m.client.close().catch((e) => log43.debug("mcp close failed", e))));
22206
+ await Promise.all(mounted.map((m) => m.client.close().catch((e) => log44.debug("mcp close failed", e))));
22155
22207
  }
22156
22208
  var IMG_EXT = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
22157
22209
  function mentionRefs(line) {
@@ -22210,7 +22262,7 @@ async function expandMentions(fs, line) {
22210
22262
  if (loaded.includes(ref) || missing.includes(ref)) continue;
22211
22263
  if (ref.includes(":") && mcpMentionResolver) {
22212
22264
  const body = await mcpMentionResolver(ref).catch((e) => {
22213
- log43.debug("mcp mention resolve failed", e);
22265
+ log44.debug("mcp mention resolve failed", e);
22214
22266
  return null;
22215
22267
  });
22216
22268
  if (body != null) {
@@ -22236,7 +22288,7 @@ ${await fs.readFile(path)}`);
22236
22288
  ${blocks.join("\n\n")}` : line, loaded, missing };
22237
22289
  }
22238
22290
  function applyTurnMode(agent, session, task, flags = {}, onModel) {
22239
- const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log43.debug(m) });
22291
+ const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log44.debug(m) });
22240
22292
  const d = p.directives, isMode = !!(d.delegate || d.advisor || d.modeOff);
22241
22293
  if (p.unresolvedModel && /->|<-|delegate:|advisor:/.test(task.slice(0, task.length - p.prompt.length))) {
22242
22294
  err(red(` \u2717 unknown model "${p.unresolvedModel}"${p.ambiguous ? ` (could be: ${p.ambiguous.join(", ")})` : ""} \u2014 turn not sent
@@ -22329,7 +22381,7 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
22329
22381
  try {
22330
22382
  store.save(session);
22331
22383
  } catch (ex) {
22332
- log43.debug("mid-turn session flush failed", ex);
22384
+ log44.debug("mid-turn session flush failed", ex);
22333
22385
  }
22334
22386
  }
22335
22387
  return origNotify(e);
@@ -22493,14 +22545,14 @@ var isCancelTeardown = (e) => {
22493
22545
  function installCancelGuards(mounted) {
22494
22546
  process.on("unhandledRejection", (e) => {
22495
22547
  if (isCancelTeardown(e)) {
22496
- log43.debug("suppressed unhandledRejection (cursor stream cancel)", e);
22548
+ log44.debug("suppressed unhandledRejection (cursor stream cancel)", e);
22497
22549
  return;
22498
22550
  }
22499
- log43.error("unhandledRejection", e);
22551
+ log44.error("unhandledRejection", e);
22500
22552
  });
22501
22553
  process.on("uncaughtException", (e) => {
22502
22554
  if (isCancelTeardown(e)) {
22503
- log43.debug("suppressed uncaughtException (cursor stream cancel)", e);
22555
+ log44.debug("suppressed uncaughtException (cursor stream cancel)", e);
22504
22556
  return;
22505
22557
  }
22506
22558
  console.error(e);
@@ -22890,7 +22942,7 @@ ${SPOKEN_TURN}`, { id });
22890
22942
  editorRef?.abort();
22891
22943
  }
22892
22944
  } catch (e) {
22893
- log43.error("call turn failed", e);
22945
+ log44.error("call turn failed", e);
22894
22946
  } finally {
22895
22947
  rec.running = false;
22896
22948
  call?.main({ type: "done", id });
@@ -23040,7 +23092,7 @@ ${SPOKEN_TURN}`, { id });
23040
23092
  try {
23041
23093
  mkdirSync12(dir, { recursive: true });
23042
23094
  } catch (e) {
23043
- log43.debug("paste image dir create failed", e);
23095
+ log44.debug("paste image dir create failed", e);
23044
23096
  }
23045
23097
  const img = grabClipboardImage(dir, String(Date.now()));
23046
23098
  return img ? { display: "Image", ref: "@" + img.path, path: img.path } : null;
@@ -23153,7 +23205,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
23153
23205
  mkdirSync12(join16(cwd, ".agent"), { recursive: true });
23154
23206
  appendFileSync2(histPath, line + "\n");
23155
23207
  } catch (e) {
23156
- log43.debug("history write failed", e);
23208
+ log44.debug("history write failed", e);
23157
23209
  }
23158
23210
  };
23159
23211
  const ago = (t) => {
@@ -23225,7 +23277,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
23225
23277
  try {
23226
23278
  store.save(session);
23227
23279
  } catch (e) {
23228
- log43.debug("session save after rewind failed", e);
23280
+ log44.debug("session save after rewind failed", e);
23229
23281
  }
23230
23282
  err(green(" \u27F2 jumped back") + dim(` \u2014 ${face.transcript.length} message(s) kept; edit + resend
23231
23283
  `));
@@ -23260,7 +23312,7 @@ ${task}`;
23260
23312
  bangContext.length = 0;
23261
23313
  }
23262
23314
  const delta = await refreshCatalogs().catch((e) => {
23263
- log43.debug("catalog refresh failed", e);
23315
+ log44.debug("catalog refresh failed", e);
23264
23316
  return "";
23265
23317
  });
23266
23318
  if (delta) {
@@ -23534,7 +23586,7 @@ ${task}`;
23534
23586
  desc: "rescan skills/commands dirs and rebuild the system prompt (one cache miss) \u2014 picks up entries created mid-session",
23535
23587
  run: async () => {
23536
23588
  await refreshCatalogs().catch((e) => {
23537
- log43.debug("catalog refresh failed", e);
23589
+ log44.debug("catalog refresh failed", e);
23538
23590
  });
23539
23591
  face.reprepare();
23540
23592
  err(green(` \u2713 reloaded \u2014 ${skills.length} skill(s), ${cmds.length} command(s); system prompt rebuilds on next message
@@ -24037,7 +24089,7 @@ ${task}`;
24037
24089
  try {
24038
24090
  for (const def of (await loadAgents(fs2, d)).agents) if (!seen.has(def.name)) seen.set(def.name, { def, from: d });
24039
24091
  } catch (e) {
24040
- log43.debug(`loadAgents(${d}) failed`, e);
24092
+ log44.debug(`loadAgents(${d}) failed`, e);
24041
24093
  }
24042
24094
  }
24043
24095
  if (!seen.size) {
@@ -24125,7 +24177,7 @@ ${task}`;
24125
24177
  }
24126
24178
  if (idx >= 0) {
24127
24179
  const old = mounted.splice(idx, 1)[0];
24128
- await old.client.close().catch((e) => log43.debug("mcp close failed", e));
24180
+ await old.client.close().catch((e) => log44.debug("mcp close failed", e));
24129
24181
  }
24130
24182
  try {
24131
24183
  const m = await mountMcpServer(name, conf);
@@ -24153,7 +24205,7 @@ ${task}`;
24153
24205
  }
24154
24206
  const m = mounted.splice(idx, 1)[0];
24155
24207
  remountMcpTools();
24156
- await m.client.close().catch((e) => log43.debug("mcp close failed", e));
24208
+ await m.client.close().catch((e) => log44.debug("mcp close failed", e));
24157
24209
  err(dim(` removed "${name}"
24158
24210
  `));
24159
24211
  return;
@@ -24356,7 +24408,7 @@ ${task}`;
24356
24408
  try {
24357
24409
  return readdirSync4(join16(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
24358
24410
  } catch (e) {
24359
- log43.debug("completion readdir failed", absDir, e);
24411
+ log44.debug("completion readdir failed", absDir, e);
24360
24412
  return null;
24361
24413
  }
24362
24414
  };
@@ -24495,7 +24547,7 @@ ${out}
24495
24547
  return;
24496
24548
  }
24497
24549
  await refreshCatalogs().catch((e) => {
24498
- log43.debug("catalog refresh failed", e);
24550
+ log44.debug("catalog refresh failed", e);
24499
24551
  });
24500
24552
  const sk = skills.find((x) => x.name === name);
24501
24553
  if (sk) {
@@ -24625,7 +24677,7 @@ ${out}
24625
24677
  if (delivery || cut) dx?.parkCutDelivery(delivery, !!cut, heard);
24626
24678
  const cutReply = cut && cut.full.length - cut.heard.length > 40 ? cut : null;
24627
24679
  const noteP = replaces ? replaces.note : !cutReply ? Promise.resolve("") : (instinct ? instinct.bargeIntent(text).catch((e) => {
24628
- log43.warn(`barge intent failed \u2014 model decides: ${e.message}`);
24680
+ log44.warn(`barge intent failed \u2014 model decides: ${e.message}`);
24629
24681
  return void 0;
24630
24682
  }) : Promise.resolve(void 0)).then(async (intent) => interruptionNote(cutReply, intent) + ackedNote(await instinct?.ackFor(text)));
24631
24683
  const cutIn = replaces ? replaces.cutIn : interjectNote;
@@ -25026,10 +25078,10 @@ function channelOptions(ai, model, gender) {
25026
25078
  // 0: the reactive live path
25027
25079
  pickLeaf: fastLeafPicker(ai, process.env.AGENTX_LEAF_MODEL || "groq/openai/gpt-oss-120b"),
25028
25080
  persona: process.env.AGENTX_CALL_PERSONA ?? "",
25029
- onTree: (e) => log43.debug(`voice tree: ${e.branches} branches in ${e.ms}ms${e.tokens ? ` tokens ${e.tokens.input}/${e.tokens.output}` : ""}${e.error ? ` error ${e.error}` : ""}`),
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}` : ""}`),
25030
25082
  onEvent: (e) => {
25031
- if (e.moment) log43.debug(`voice leaf: ${e.moment} ${e.conf} "${e.text}" ${e.acted}`);
25032
- else log43.debug(`channel ${e.trigger}: rule=${e.rule} choice=${e.choice ?? "-"} \u2192 ${e.acted}${e.text ? ` "${e.text}"` : ""}${e.cue ? " (planned cue)" : ""} ${e.ms}ms`);
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`);
25033
25085
  },
25034
25086
  // Banks in the user's language: generated once per language, cached + topped up across sessions (~/.agent/cache).
25035
25087
  banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir: join16(homedir10(), ".agent", "cache", "channel-banks") }),
@@ -25123,7 +25175,7 @@ async function duplexServe(args, ai, cfg, cwd) {
25123
25175
  try {
25124
25176
  store.save(session);
25125
25177
  } catch (e) {
25126
- log43.warn("duplex session save failed", e);
25178
+ log44.warn("duplex session save failed", e);
25127
25179
  }
25128
25180
  };
25129
25181
  const overlap2 = overlapResponder(ai, args.duplexV2 ? args.channelMode : void 0, out);
@@ -25163,7 +25215,7 @@ async function duplexServe(args, ai, cfg, cwd) {
25163
25215
  done2();
25164
25216
  out({ type: "turn_done", id, finishReason: res?.finishReason ?? "error", ...why ? { error: why } : {} });
25165
25217
  }).catch((e) => {
25166
- log43.error("duplex turn failed", e);
25218
+ log44.error("duplex turn failed", e);
25167
25219
  done2();
25168
25220
  out({ type: "turn_done", id, finishReason: "error", error: String(e?.message ?? e) });
25169
25221
  });