@livx.cc/agentx 0.99.160 → 0.99.162

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
@@ -10668,6 +10668,9 @@ var ASIDES = {
10668
10668
  he: { agree: ["\u05DB\u05DF, \u05D1\u05D3\u05D9\u05D5\u05E7.", "\u05DB\u05DF, \u05DE\u05DE\u05E9.", "\u05E0\u05DB\u05D5\u05DF, \u05DB\u05DF."], continue: [], react: ["\u05E0\u05DB\u05D5\u05DF? \u05DE\u05D8\u05D5\u05E8\u05E3.", "\u05DB\u05DF, \u05DE\u05D8\u05D5\u05E8\u05E3.", "\u05DE\u05D8\u05D5\u05E8\u05E3, \u05E0\u05DB\u05D5\u05DF?"] }
10669
10669
  };
10670
10670
  var REACT = /^(?:(?:oh|and|so|wait|but|ok|okay|yeah)\s+)*(?:wow|whoa|woah|really|seriously|no way|oh my god|omg|crazy|insane|amazing|unbelievable|what|are you serious|you're kidding|וואו|באמת|מה|מטורף|רצינית?|לא נכון)(?:\s+(?:wow|really|seriously|that's crazy|that's wild|no way|באמת|וואו))*$/u;
10671
+ var WH_LEAD = "^(?:(?:oh|and|so|wait|but|ok|okay|um|uh|sorry)\\s+)*";
10672
+ var WH_QUESTION = new RegExp(WH_LEAD + "(?:who|whom|whose|where|which|why|how|when|what|\u05DE\u05D9|\u05D0\u05D9\u05E4\u05D4|\u05DC\u05DE\u05D4|\u05D0\u05D9\u05DA|\u05DE\u05EA\u05D9|\u05DE\u05D4)\\s+\\S", "u");
10673
+ var WH_EXCLAIM = new RegExp(WH_LEAD + "(?:what an? |how (?:cool|nice|fun|sweet|sad|funny|weird|crazy|strange|interesting|beautiful|lovely|cute|amazing|awesome)\\b)", "u");
10671
10674
  var isReaction = (text) => {
10672
10675
  const t = norm2(text);
10673
10676
  return REACT.test(t) || new RegExp("\\s\\p{L}{1,3}$", "u").test(t) && REACT.test(t.replace(new RegExp("\\s\\p{L}{1,3}$", "u"), ""));
@@ -10686,6 +10689,7 @@ function overlapRule(text) {
10686
10689
  if (!t) return void 0;
10687
10690
  if (isClosing(text)) return "cut";
10688
10691
  if (HARD.test(t + " ")) return t.includes(" ") ? "cut" : "hold";
10692
+ if (WH_QUESTION.test(t) && !REACT.test(t) && !WH_EXCLAIM.test(t)) return "cut";
10689
10693
  for (const p of PHRASES) t = t.split(p).join(" ");
10690
10694
  const words5 = t.split(/[\s-]+/).filter(Boolean);
10691
10695
  const ack = (w) => ACK.has(w) || HE_ACK.has(w) || /^(?:ha)+h?$|^(?:he)+h?$|^m+(?:hm+)?$|^h?m+$/.test(w);
@@ -10697,7 +10701,7 @@ function overlapRule(text) {
10697
10701
  function fastOverlapModel(ai, model = "groq/qwen/qwen3.8-27b") {
10698
10702
  return async (heard, signal) => {
10699
10703
  const prompt = 'Live voice call. The assistant is mid-sentence and the user just said this over it: "' + heard + `"
10700
- Are they STEERING \u2014 asking for something new, asking a real question about it, correcting it, telling it to stop, or saying goodbye? A reaction is not steering: surprise, disbelief, "what?", "really?", "you're serious?", "that's serious", agreement, a laugh \u2014 the assistant just carries on.
10704
+ Are they STEERING \u2014 asking for something new, asking a real question about it, correcting it, telling it to stop, or saying goodbye? A question about what it said ("who did that?", "where?", "which one?") IS steering. A reaction is not steering: surprise, disbelief, a lone "what?", "really?", "you're serious?", "that's serious", agreement, a laugh \u2014 the assistant just carries on.
10701
10705
  Answer yes (steering) or no (a reaction).`;
10702
10706
  const reasoning = /qwen/.test(model) ? { providerOptions: { reasoning_effort: "none" } } : /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
10703
10707
  const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, temperature: 0, maxTokens: /gpt-oss/.test(model) ? 200 : 3, ...reasoning });
@@ -10787,6 +10791,19 @@ function voiceDecider(env = process.env, timeoutMs = 1500) {
10787
10791
  const llm = new LlmDecideAdapter({ client: { chat: (c) => ai.chat({ reasoningEffort: "low", ...c }) } });
10788
10792
  return new DecideClient({ ...o, timeoutMs, adapters: { typesafe: new JevAdapter(), llm } });
10789
10793
  }
10794
+ var TURN_ACTIONS = {
10795
+ answer: "Their line is complete and calls for your reply now (a question, a request, a greeting, an answer to what you asked).",
10796
+ ack_then_answer: "Complete, and a real answer needs a moment: a short acknowledgement now, then the answer.",
10797
+ backchannel: 'They are telling something longer and only paused: a tiny listener sound ("mm", "right") at most, keep listening.',
10798
+ wait: 'They are mid-thought (cut off, a list, "and...", a number being said): say nothing, they will go on.',
10799
+ silence: "Not for you to answer (a recording, a menu, talk to someone else, or an ending that needs nothing)."
10800
+ };
10801
+ function turnJudgeFor(env = process.env, timeoutMs = 900) {
10802
+ const decider = voiceDecider(env, timeoutMs);
10803
+ if (!decider) return void 0;
10804
+ const instinct = new Instinct({ decider });
10805
+ return (heard, state) => instinct.turnEnd(heard, state);
10806
+ }
10790
10807
  var InstinctOptions = class {
10791
10808
  decider;
10792
10809
  /** Partial unchanged this long (a micro-pause) → consult. */
@@ -11112,6 +11129,18 @@ var Instinct = class {
11112
11129
  CHANNEL_ACTIONS
11113
11130
  );
11114
11131
  }
11132
+ /** A held final (the STT ended a line; the gate waits to see if more comes): is it our turn, and how to react.
11133
+ * answer / ack_then_answer → the turn goes out now; wait / backchannel → it waits the long hold; silence → it goes
11134
+ * out and the quick lane may stay quiet. The choice also reaches the quick lane as a hint. */
11135
+ turnEnd(heard, state = {}) {
11136
+ return this.ask(
11137
+ "turn_end",
11138
+ heard,
11139
+ { their_line: heard, ...state },
11140
+ FRAME + "The other person just paused after this line. Decide, as a person on a phone call would, whether it is your turn now and how you would react.",
11141
+ TURN_ACTIONS
11142
+ );
11143
+ }
11115
11144
  /** A random phrase from `pool`, never the one said last (no back-to-back repeat across keys). */
11116
11145
  rotate(pool) {
11117
11146
  const fresh = pool.filter((x) => x !== this.lastAckSaid);
@@ -11449,18 +11478,18 @@ function fitsLanguage(line, lang) {
11449
11478
  return !ws.some((w) => !mine?.has(w) && Object.entries(STOP3).some(([l, s]) => l !== lang && s.has(w)));
11450
11479
  }
11451
11480
  var norm3 = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}' ]/gu, "").replace(/\s+/g, " ").trim();
11452
- function cleanLine(s, lang, maxWords = 6) {
11481
+ function cleanLine(s, lang, maxWords = 6, maxChars = 60) {
11453
11482
  if (/^(?:gasp|quiet|laughter)[.!?…]*$/i.test(s.trim())) return "";
11454
11483
  const first = s.trim().split("\n")[0];
11455
11484
  const tags = [...first.matchAll(LINE_TAG)].map((m) => `[${m[1].toLowerCase()}]`).filter((t, i, a) => a.indexOf(t) === i).join(" ");
11456
11485
  const raw = first.replace(LINE_TAG, " ").trim();
11457
11486
  if (tags && !/[\p{L}\p{N}]/u.test(raw)) return /laughter|gasp/.test(tags) ? tags : "";
11458
- const words5 = cleanWords(raw, lang, maxWords);
11487
+ const words5 = cleanWords(raw, lang, maxWords, maxChars);
11459
11488
  return words5 && tags ? `${tags} ${words5}` : words5;
11460
11489
  }
11461
11490
  var LINE_TAG = /\[(laughter|gasp|quiet)\]/gi;
11462
11491
  var lineWords = (line) => line.replace(LINE_TAG, " ").trim();
11463
- function cleanWords(raw, lang, maxWords) {
11492
+ function cleanWords(raw, lang, maxWords, maxChars = 60) {
11464
11493
  const l = raw.replace(/^[-*•\d.)\s]+/, "").replace(/^["'“”«»]+|["'“”«»]+$/g, "").replace(new RegExp("^\\p{L}+:\\s*", "u"), "").trim();
11465
11494
  if (!l || isLeakSuspect(raw) || isLeakSuspect(l)) {
11466
11495
  if (l) log23.debug(`line "${raw}" reads as meta \u2014 rejected`);
@@ -11470,7 +11499,7 @@ function cleanWords(raw, lang, maxWords) {
11470
11499
  log23.debug(`line "${l}" is not ${lang} \u2014 rejected`);
11471
11500
  return "";
11472
11501
  }
11473
- return l.split(/\s+/).length > maxWords || l.length > 60 ? "" : l;
11502
+ return l.split(/\s+/).length > maxWords || l.length > maxChars ? "" : l;
11474
11503
  }
11475
11504
  var SPEAKER_FILLER = /^(?:so|well|actually|basically|anyway|anyways|like|you know|i mean|kind of|sort of|literally|honestly|and|but|because|then|the thing is)\b/i;
11476
11505
  function validateBank(raw, lang, minPerKind = 3) {
@@ -11716,6 +11745,11 @@ var TurnGate = class {
11716
11745
  get lastTurn() {
11717
11746
  return this.last && { id: this.last.id, text: this.last.text, started: this.last.started };
11718
11747
  }
11748
+ /** The user's own line is not over: a fragment is held, or the last turn went out mid-phrase ("where is the—") within
11749
+ * `withinMs`. Their next words finish it — never a reaction to the reply. */
11750
+ unfinished(withinMs) {
11751
+ return !!this.held || !!this.last && endsMidPhrase(this.last.text) && this.o.now() - this.last.at < withinMs;
11752
+ }
11719
11753
  /** An STT final. */
11720
11754
  final(text, sttId) {
11721
11755
  let t = text.trim(), replaces;
@@ -11762,6 +11796,21 @@ var TurnGate = class {
11762
11796
  clearTimeout(h.timer);
11763
11797
  h.timer = setTimeout(() => this.settle(), h.ms);
11764
11798
  }
11799
+ /** A turn judge says the held `text` is a whole turn: send it now (not while they are mid-line). */
11800
+ release(text) {
11801
+ const h = this.held;
11802
+ if (!h || h.talking || norm3(h.text) !== norm3(text)) return false;
11803
+ this.flush();
11804
+ return true;
11805
+ }
11806
+ /** A turn judge says they are not done: the held `text` waits the long hold (more speech still merges in). */
11807
+ extend(text) {
11808
+ const h = this.held;
11809
+ if (!h || norm3(h.text) !== norm3(text) || h.ms >= this.o.holdMs) return;
11810
+ h.ms = this.o.holdMs;
11811
+ clearTimeout(h.timer);
11812
+ h.timer = setTimeout(() => this.settle(), h.ms);
11813
+ }
11765
11814
  /** The hold's quiet ran out: send it — unless the user is mid-line (a partial with no final yet). */
11766
11815
  settle() {
11767
11816
  const h = this.held;
@@ -11796,7 +11845,7 @@ var TurnGate = class {
11796
11845
  }
11797
11846
  }
11798
11847
  refinal(last, t, key, sttId) {
11799
- if (!last.started) return this.send(t, key, sttId ?? last.sttId, "replace", last.id);
11848
+ if (!last.started || endsMidPhrase(last.text)) return this.send(t, key, sttId ?? last.sttId, "replace", last.id);
11800
11849
  const a = words3(last.text), b = words3(t);
11801
11850
  let i = 0;
11802
11851
  while (i < a.length && i < b.length && norm3(a[i]) === norm3(b[i])) i++;
@@ -14930,6 +14979,7 @@ var SecondChannel = class {
14930
14979
  const preset = CHANNEL_MODES[options?.mode ?? "normal"] ?? {};
14931
14980
  const base = new SecondChannelOptions();
14932
14981
  this.options = { ...base, ...preset, ...options };
14982
+ if (process.env.AGENTX_CALL_ROLE === "caller") this.options.kinds = (this.options.kinds ?? []).filter((k) => k === "backchannel");
14933
14983
  for (const k of Object.keys(preset)) if (!options || !(k in options)) this.normalTiming[k] = base[k];
14934
14984
  this.startedAt = this.o.now();
14935
14985
  if (this.o.lang) this.setLanguage(this.o.lang, true);
@@ -15696,6 +15746,9 @@ var VoiceCallOptions = class {
15696
15746
  };
15697
15747
  /** The fast model (lines, banks, progress) — used only with `ai`. */
15698
15748
  fastModel = latestClaude("haiku");
15749
+ /** The turn-end judge (Instinct.turnEnd over Jev): a held final goes out at once or waits, and its read of how to
15750
+ * react reaches the quick lane. Absent → the gate's timers alone. */
15751
+ turnJudge;
15699
15752
  /** Model client for the fast model + the channel decider / overlap judge. Absent → canned lines and rules only. */
15700
15753
  ai;
15701
15754
  /** Cache dir for per-language banks (ChannelBanks). */
@@ -15771,7 +15824,10 @@ var VoiceCall = class {
15771
15824
  ...o.gate,
15772
15825
  onTurn: (t) => this.onTurn(t),
15773
15826
  onDrop: (text, why) => this.onDrop(text, why),
15774
- onHold: (text) => o.onMetric({ name: "hold", text })
15827
+ onHold: (text) => {
15828
+ o.onMetric({ name: "hold", text });
15829
+ this.judgeHold(text);
15830
+ }
15775
15831
  });
15776
15832
  }
15777
15833
  options;
@@ -15800,6 +15856,20 @@ var VoiceCall = class {
15800
15856
  get o() {
15801
15857
  return this.options;
15802
15858
  }
15859
+ /** The turn judge's last read (choice for `text`): the quick lane's hint for that turn. */
15860
+ hint;
15861
+ judgeHold(text) {
15862
+ const j = this.o.turnJudge;
15863
+ if (!j || this.ended) return;
15864
+ const said = [...this.history].reverse().find((h) => h.who === "you")?.text;
15865
+ j(text, { agent_last_said: said ?? null, agent_speaking: !!this.cur?.running }).then((d) => {
15866
+ if (!d) return;
15867
+ this.hint = { text, choice: d.choice };
15868
+ const go = d.choice === "answer" || d.choice === "ack_then_answer" || d.choice === "silence";
15869
+ const acted2 = go ? this.gate.release(text) ? "released" : "late" : (this.gate.extend(text), "extended");
15870
+ this.o.onMetric({ name: "judge", ms: d.ms, kind: `${d.choice} ${acted2}`, text });
15871
+ }).catch((e) => log31.warn(`turn judge failed \u2014 the gate's timers decide: ${e?.message ?? e}`));
15872
+ }
15803
15873
  /** The language the fill channel speaks right now (null = unknown → silent). */
15804
15874
  get language() {
15805
15875
  return this.lang;
@@ -15985,6 +16055,10 @@ var VoiceCall = class {
15985
16055
  }
15986
16056
  /** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
15987
16057
  async overlap(text) {
16058
+ if (this.gate.unfinished(UNFINISHED_MS)) {
16059
+ this.barge();
16060
+ return "cut";
16061
+ }
15988
16062
  if (this.o.mode === "live" && isReaction(text)) return this.kept(text), "keep";
15989
16063
  const d = await this.judge.judge(text);
15990
16064
  if (d.verdict === "cut") this.barge();
@@ -16120,7 +16194,7 @@ var VoiceCall = class {
16120
16194
  const ac = new AbortController(), t0 = this.o.now(), lang = this.lang, rest = this.cutRest;
16121
16195
  c.ask = ac;
16122
16196
  const late = setTimeout(() => ac.abort(), this.o.quickBudgetMs);
16123
- const mv = lang ? await this.o.quick({ history: this.history.slice(0, -1), heard: t.text, lang, rest }, ac.signal).catch((e) => {
16197
+ const mv = lang ? await this.o.quick({ history: this.history.slice(0, -1), heard: t.text, lang, rest, ...this.hint && t.text.includes(this.hint.text) ? { hint: this.hint.choice } : {} }, ac.signal).catch((e) => {
16124
16198
  if (this.cur === c) log31.warn(`quick lane ${ac.signal.aborted ? `late (${this.o.quickBudgetMs}ms)` : `failed: ${e?.message ?? e}`} \u2014 deep lane`);
16125
16199
  return null;
16126
16200
  }).finally(() => clearTimeout(late)) : null;
@@ -16152,7 +16226,8 @@ var VoiceCall = class {
16152
16226
  c.due = false;
16153
16227
  return this.close(c, "silent");
16154
16228
  }
16155
- const said = mv.kind === "resume" ? `${mv.line} ${cutSentence([...this.history].reverse().find((h) => h.who === "you" && h.cut)?.text ?? "")} ${rest}`.replace(/\s+/g, " ").trim() : mv.line;
16229
+ const cutAt = () => cutSentence([...this.history].reverse().find((h) => h.who === "you" && h.cut)?.text ?? "");
16230
+ const said = mv.kind === "resume" ? `${mv.line} ${cutAt()} ${rest}`.replace(/\s+/g, " ").trim() : mv.kind === "clarify" ? `${mv.line} ${lang && BACK_TO[lang] || ""} ${cutAt()} ${rest}`.replace(/\s+/g, " ").trim() : mv.line;
16156
16231
  this.gate.replyStarted(c.id);
16157
16232
  const end = mv.kind === "say" && !!mv.end;
16158
16233
  if (end) try {
@@ -16168,6 +16243,11 @@ var VoiceCall = class {
16168
16243
  this.o.dropCut?.();
16169
16244
  this.history.push({ who: "you", text: rest });
16170
16245
  note(`They asked you to go on, and you continued your cut answer aloud: "${rest}". All of it has now been said.`);
16246
+ } else if (mv.kind === "clarify") {
16247
+ this.cutRest = "";
16248
+ this.o.dropCut?.();
16249
+ this.history.push({ who: "you", text: mv.line }, { who: "you", text: rest });
16250
+ note(`They cut your answer to ask "${t.text}". You (the call's quick voice) answered aloud "${mv.line}" and then continued your cut answer: "${rest}". All of it has now been said.`);
16171
16251
  } else {
16172
16252
  this.history.push({ who: "you", text: said });
16173
16253
  note(`On the call they said "${t.text}" and you (the call's quick voice) answered aloud: "${said}". Already said \u2014 do not repeat it.`);
@@ -16356,6 +16436,8 @@ var VoiceCall = class {
16356
16436
  }
16357
16437
  }
16358
16438
  };
16439
+ var UNFINISHED_MS = 8e3;
16440
+ var BACK_TO = { en: "Anyway,", he: "\u05D1\u05DB\u05DC \u05DE\u05E7\u05E8\u05D4," };
16359
16441
  function cutSentence(heard) {
16360
16442
  const tail = heard.trim().split(/(?<=[.!?…])\s+/).at(-1) ?? "";
16361
16443
  if (!tail || /[.!?…]["'”’)]*$/.test(tail)) return "";
@@ -17601,6 +17683,7 @@ var NodeMicSource = class {
17601
17683
  }, 500).unref?.();
17602
17684
  }
17603
17685
  };
17686
+ var vpioProbeMs = () => Number(process.env.MIC_VPIO_PROBE_MS) || 5e3;
17604
17687
  var AecDuplexAudio = class {
17605
17688
  constructor(bin) {
17606
17689
  this.bin = bin;
@@ -17629,6 +17712,9 @@ var AecDuplexAudio = class {
17629
17712
  fallbackTimer = null;
17630
17713
  bytesWritten = 0;
17631
17714
  startedAt = 0;
17715
+ /** This turn's TTS while VPIO is unproven (no mic chunk yet). A dead VPIO engine plays nothing either, so the
17716
+ * fallback helper replays it — else the greeting, spoken inside the VPIO probe window, is never heard. */
17717
+ unproven = [];
17632
17718
  // --- AudioSource ---
17633
17719
  start(onChunk) {
17634
17720
  this.onChunk = onChunk;
@@ -17641,7 +17727,7 @@ var AecDuplexAudio = class {
17641
17727
  this.spawnHelper();
17642
17728
  }
17643
17729
  /** (Re)spawn the helper. On the first spawn, arm a fast watchdog: if VPIO delivers NO audio within
17644
- * ~2.5s, the VP input tap is dead on this machine (seen on macOS 26.5.x) — respawn once with
17730
+ * vpioProbeMs(), the VP input tap is dead on this machine (seen on macOS 26.5.x) — respawn once with
17645
17731
  * MIC_NO_VPIO=1 (plain capture, heuristic echo) so the mic actually works instead of starving STT. */
17646
17732
  spawnHelper() {
17647
17733
  const env = this.noVpio ? { ...process.env, MIC_NO_VPIO: "1" } : process.env;
@@ -17652,7 +17738,10 @@ var AecDuplexAudio = class {
17652
17738
  if (c && !this.stopped) log36.error(`aec duplex audio exited (${c}) \u2014 check mic permission / MIC_AEC=0`);
17653
17739
  });
17654
17740
  this.proc.stdout.on("data", (chunk) => {
17655
- this.gotChunk = true;
17741
+ if (!this.gotChunk) {
17742
+ this.gotChunk = true;
17743
+ this.unproven = [];
17744
+ }
17656
17745
  this.onChunk(chunk);
17657
17746
  });
17658
17747
  this.proc.stderr.on("data", (d) => {
@@ -17674,11 +17763,19 @@ var AecDuplexAudio = class {
17674
17763
  this.triedFallback = true;
17675
17764
  this.noVpio = true;
17676
17765
  this._aec = false;
17677
- 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)");
17766
+ log36.warn(`mic-aec: VPIO delivered no audio in ${vpioProbeMs() / 1e3}s \u2014 falling back to non-VPIO capture (no AEC \u2192 half-duplex, no barge-in)`);
17678
17767
  this.onDegrade?.();
17679
17768
  this.killProc();
17680
17769
  this.spawnHelper();
17681
- }, 2500);
17770
+ const replay = this.unproven;
17771
+ this.unproven = [];
17772
+ if (replay.length) {
17773
+ this.startedAt = now3();
17774
+ this.pausedSince = 0;
17775
+ this.pausedAccum = 0;
17776
+ for (const c of replay) this.frame(c);
17777
+ }
17778
+ }, vpioProbeMs());
17682
17779
  this.fallbackTimer.unref?.();
17683
17780
  }
17684
17781
  }
@@ -17713,12 +17810,14 @@ var AecDuplexAudio = class {
17713
17810
  this.frame(null);
17714
17811
  this.bytesWritten = 0;
17715
17812
  this.startedAt = 0;
17813
+ this.unproven = [];
17716
17814
  this.pausedSince = 0;
17717
17815
  this.pausedAccum = 0;
17718
17816
  }
17719
17817
  write(chunk) {
17720
17818
  if (!this.startedAt) this.startedAt = now3();
17721
17819
  this.bytesWritten += chunk.length;
17820
+ if (!this.gotChunk && !this.noVpio) this.unproven.push(chunk);
17722
17821
  this.frame(chunk);
17723
17822
  }
17724
17823
  playedMs() {
@@ -17734,6 +17833,7 @@ var AecDuplexAudio = class {
17734
17833
  this.frame(null);
17735
17834
  this.bytesWritten = 0;
17736
17835
  this.startedAt = 0;
17836
+ this.unproven = [];
17737
17837
  this.pausedSince = 0;
17738
17838
  this.pausedAccum = 0;
17739
17839
  }
@@ -18406,9 +18506,68 @@ ${o.persona}
18406
18506
  return line || o.fallback;
18407
18507
  }
18408
18508
 
18509
+ // src/voice/menuKeys.ts
18510
+ init_logging();
18511
+ var log39 = forComponent("MenuKeys");
18512
+ var MenuKeysOptions = class {
18513
+ ai;
18514
+ model = "groq/openai/gpt-oss-120b";
18515
+ /** Who we are and what the call is for (the call persona / task). */
18516
+ persona = "";
18517
+ timeoutMs = 4e3;
18518
+ };
18519
+ var MenuKeys = class _MenuKeys {
18520
+ options;
18521
+ /** The menu so far: each line heard, and what we pressed after it. */
18522
+ steps = [];
18523
+ constructor(options) {
18524
+ this.options = { ...new MenuKeysOptions(), ...options };
18525
+ }
18526
+ /** The prompt for the menu so far (exported for tests). */
18527
+ static prompt(persona, steps) {
18528
+ const menu = steps.map((s) => `MENU: ${s.line}${s.pressed ? `
18529
+ YOU PRESSED: ${s.pressed}` : ""}`).join("\n");
18530
+ return `${persona.slice(0, 800)}
18531
+
18532
+ You placed this call and an automated phone menu is playing. What it said so far, oldest first:
18533
+ ${menu}
18534
+
18535
+ Which key(s) do you press NOW for your task? Answer with only the keys (digits, * or #, e.g. "1" or "2#"), or WAIT when: the option for your task was not said yet, it is a greeting/recording/hold message, you already pressed for this same menu, or it asks for something the task does not give (an ID, a number). After "wrong key"/"invalid choice", press the right key for the menu again.`;
18536
+ }
18537
+ /** "1", "2#", "WAIT", "Press 1." … → the keys, or '' (wait). */
18538
+ static parse(raw) {
18539
+ const t = raw.trim().replace(/^["'`]+|["'`.]+$/g, "");
18540
+ if (/^wait\b/i.test(t)) return "";
18541
+ const m = t.match(/^(?:press\s*)?([0-9*#]{1,12})$/i);
18542
+ return m ? m[1] : "";
18543
+ }
18544
+ /** A menu line was heard: the keys to press now, or '' (wait). */
18545
+ async hear(line) {
18546
+ const t0 = performance.now();
18547
+ this.steps.push({ line });
18548
+ const ac = new AbortController(), timer = setTimeout(() => ac.abort(), this.options.timeoutMs);
18549
+ try {
18550
+ const raw = await fastText(this.options.ai, { model: this.options.model, prompt: _MenuKeys.prompt(this.options.persona, this.steps.slice(-8)), signal: ac.signal, maxTokens: 20, temperature: 0 });
18551
+ const digits = _MenuKeys.parse(raw);
18552
+ if (digits) this.steps[this.steps.length - 1].pressed = digits;
18553
+ return { digits, ms: Math.round(performance.now() - t0) };
18554
+ } catch (e) {
18555
+ log39.debug(`menu keys failed \u2014 the main agent decides: ${e?.message ?? e}`);
18556
+ return { digits: "", ms: Math.round(performance.now() - t0) };
18557
+ } finally {
18558
+ clearTimeout(timer);
18559
+ }
18560
+ }
18561
+ /** The host pressed keys itself (the main agent's press_keys): later reads know it. */
18562
+ pressed(digits) {
18563
+ const s = this.steps.at(-1);
18564
+ if (s) s.pressed = digits;
18565
+ }
18566
+ };
18567
+
18409
18568
  // src/voice/quickLane.ts
18410
18569
  init_logging();
18411
- var log39 = forComponent("QuickLane");
18570
+ var log40 = forComponent("QuickLane");
18412
18571
  var SAY_WORDS = 30;
18413
18572
  var ACK_WORDS = 10;
18414
18573
  var ACKS = { en: ["On it.", "Sure, one sec.", "Okay.", "Alright."], he: ["\u05E8\u05D2\u05E2 \u05D0\u05D7\u05D3.", "\u05D0\u05D5\u05E7\u05D9\u05D9, \u05E9\u05E0\u05D9\u05D9\u05D4.", "\u05E9\u05E0\u05D9\u05D9\u05D4."] };
@@ -18430,9 +18589,20 @@ var ownLine = (pool, c) => {
18430
18589
  return (pool ?? []).find((x) => !said.has(norm3(x))) ?? "";
18431
18590
  };
18432
18591
  function rawMove(raw, c) {
18433
- const m = /^\s*(SAY|BYE|DEEP|RESUME|QUIET)\b\s*:?\s*(.*)$/im.exec(raw.trim());
18592
+ const m = /^\s*(SAY|BYE|DEEP|RESUME|CLARIFY|QUIET)\b\s*:?\s*(.*)$/im.exec(raw.trim());
18434
18593
  if (!m) return null;
18435
18594
  const bye = m[1].toUpperCase() === "BYE", kind = bye ? "SAY" : m[1].toUpperCase(), body = m[2].trim();
18595
+ if (kind === "CLARIFY") {
18596
+ const deep = { kind: "deep", ack: stockAck(c), brief: "" };
18597
+ if (!c.rest) return deep;
18598
+ const [ans = "", quote = ""] = body.split("|").map((s) => s.trim());
18599
+ const line2 = sayLine(ans, c.lang);
18600
+ if (!line2) return null;
18601
+ if (unknownFacts(line2, c).length || novelWords(line2, c).length >= 2) return deep;
18602
+ const answer = norm3([...c.history.filter((h) => h.who === "you" && h.cut).slice(-1).map((h) => h.text), c.rest].join(" ")), q2 = norm3(quote);
18603
+ if (!q2 || !answer.includes(q2) || !asksAbout(c.heard, q2) || novelWords(line2, c, quote).length < novelWords(line2, c, answer).length) return deep;
18604
+ return { kind: "clarify", line: line2 };
18605
+ }
18436
18606
  const owns = quickOwns(c.heard);
18437
18607
  if (!owns && kind !== "DEEP") return { kind: "deep", ack: stockAck(c), brief: "" };
18438
18608
  if (kind === "QUIET") return { kind: "quiet" };
@@ -18442,7 +18612,7 @@ function rawMove(raw, c) {
18442
18612
  }
18443
18613
  if (kind === "DEEP") {
18444
18614
  const [ack = "", brief = ""] = body.split(body.includes("|") ? "|" : /\s+[—–-]\s+/).map((s) => s.trim());
18445
- const a = cleanLine(ack, c.lang, ACK_WORDS).replace(/[\s,;:—–-]+$/u, "");
18615
+ const a = cleanLine(ack, c.lang, c.plan ? 18 : ACK_WORDS, c.plan ? 140 : 60).replace(/[\s,;:—–-]+$/u, "");
18446
18616
  const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
18447
18617
  const ok = a && !said.has(norm3(a)) && !RESULT_CLAIM_RE.test(a) && !new RegExp("\\p{N}", "u").test(a);
18448
18618
  return { kind: "deep", ack: ok ? a : stockAck(c), brief };
@@ -18454,12 +18624,18 @@ function rawMove(raw, c) {
18454
18624
  const facts = unknownFacts(line, c), novel = novelWords(line, c);
18455
18625
  const unknown = facts.length || novel.length >= 2 ? [...facts, ...novel] : [];
18456
18626
  if (unknown.length) {
18457
- log39.debug(`quick line "${line}" names ${unknown.join(", ")} \u2014 not in the call: deep lane`);
18627
+ log40.debug(`quick line "${line}" names ${unknown.join(", ")} \u2014 not in the call: deep lane`);
18458
18628
  return { kind: "deep", ack: "", brief: "" };
18459
18629
  }
18460
18630
  return bye && isClosing(c.heard) ? { kind: "say", line, end: true } : { kind: "say", line };
18461
18631
  }
18462
- var stockAck = (c) => ownLine(ACKS[c.lang], c);
18632
+ var Q_STOP = new Set("who whom whose where which why how when what do does did is are was were the a an they she he it you your that this of in on at to and or one ones there their them about mean meant wait sorry so okay \u05DE\u05D9 \u05D0\u05D9\u05E4\u05D4 \u05DC\u05DE\u05D4 \u05D0\u05D9\u05DA \u05DE\u05EA\u05D9 \u05DE\u05D4 \u05D0\u05EA \u05D6\u05D4 \u05D6\u05D0\u05EA \u05D4\u05DD \u05D4\u05DF \u05D4\u05D5\u05D0 \u05D4\u05D9\u05D0".split(" "));
18633
+ function asksAbout(heard, normQuote) {
18634
+ const st = (w) => w.replace(/['’]s$/, "").replace(new RegExp("(?<=\\p{L}{3})(?:es|s)$", "u"), "");
18635
+ const qs = new Set(normQuote.split(" ").map(st));
18636
+ return norm3(heard).split(" ").some((w) => w && !Q_STOP.has(w) && qs.has(st(w)));
18637
+ }
18638
+ var stockAck = (c) => c.caller ? "" : ownLine(ACKS[c.lang], c);
18463
18639
  function quickOwns(heard) {
18464
18640
  const t = heard.replace(/\s*[—–]\s*/g, " ").trim(), n = norm3(t);
18465
18641
  if (!n) return null;
@@ -18515,15 +18691,17 @@ function holdLine(c) {
18515
18691
  const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
18516
18692
  return (HOLDS[c.lang] ?? []).find((x) => !said.has(norm3(x))) ?? "";
18517
18693
  }
18518
- function fastQuickLane(ai, model, gender, persona = "", hedgeMs = 900, tools = true) {
18519
- return async (c, signal) => {
18694
+ function fastQuickLane(ai, model, gender, persona = "", hedgeMs = 900, tools = true, caller = false, plan) {
18695
+ return async (c0, signal) => {
18696
+ const c = caller ? { ...c0, caller: true, ...plan?.text ? { plan: plan.text } : {} } : c0;
18697
+ if (caller && plan?.opener && !c.history.some((h) => h.who === "you")) return { kind: "deep", ack: plan.opener, brief: "" };
18520
18698
  if (c.rest && GO_ON.test(c.heard)) return { kind: "resume", line: "" };
18521
18699
  const hold = holdLine(c);
18522
18700
  if (hold) return { kind: "say", line: hold };
18523
18701
  const ask = async () => {
18524
18702
  const raw = await fastText(ai, { model, prompt: quickPrompt(c, gender, persona, tools), signal, temperature: 0.4 });
18525
18703
  const mv = quickMove(raw, c);
18526
- if (!mv) log39.debug(`quick lane: unusable "${raw.slice(0, 80)}"`);
18704
+ if (!mv) log40.debug(`quick lane: unusable "${raw.slice(0, 80)}"`);
18527
18705
  return mv;
18528
18706
  };
18529
18707
  let timer;
@@ -18553,13 +18731,83 @@ They just said: "${c.heard}"
18553
18731
  ` : "") + `
18554
18732
  Reply with exactly ONE line, one of:
18555
18733
  BYE: <a short farewell> \u2014 they mean to end the call ("no, thank you, bye", "okay, talk later"): the call hangs up after it. Judge the intent: "say bye to Dan" or "before I go, one more thing" is not an end.
18556
- SAY: <your words> \u2014 ONLY a greeting or how-are-you, a short reaction ("wow", "really?"), or when they ask exactly to repeat something ALREADY said ("say that again", "which one was that?"). Any request ("tell me a story\u2026"), any question about content ("what is\u2026?", "wait, what?", "how long is it?") is DEEP, even if you could guess. Max two short sentences. Use only facts from the call above; never invent a name, number, news item or result.
18734
+ SAY: <your words> \u2014 ONLY a greeting or how-are-you, a short reaction ("wow", "really?"), or when they ask exactly to repeat something ALREADY said ("say that again", "which one was that?"). Any request ("tell me a story\u2026"), any question about content ("what is\u2026?", "wait, what?", "how long is it?") is DEEP, even if you could guess${c.rest ? " (or CLARIFY, below)" : ""}. Max two short sentences. Use only facts from the call above; never invent a name, number, news item or result.
18557
18735
  DEEP: <a 2-8 word acknowledgement> | <what the colleague must do, names spelled right> \u2014 anything needing a lookup, current information, tools, files, or real thinking. The acknowledgement is your natural first reaction to THIS kind of ask, in your own voice: ${tools ? `a lookup says you're on it and names what you'll look at ("Sure, let me pull up the kitty changelog."); ` : `never say you will check, look up, pull up, find or fetch anything \u2014 nothing can be; a question gets a short thinking reaction ("Hmm, okay\u2026", "Right, so\u2026"); `}a story, joke or idea gets a reaction to the idea itself (a story about a dragon: "Ooh, a dragon story, okay\u2026"); a question about what was said gets a short "ah"-type reaction ("Ah, good question."). Say "checking" or "looking" only when something is actually looked up. Never a result. The speech-to-text misspells names: fix them from context ("Haka News" \u2192 Hacker News).
18558
- QUIET \u2014 nothing is owed: a bare "okay", "mm-hm", or a reaction you already answered.
18736
+ ` + (c.rest ? `CLARIFY: <one short answer> | <the exact words of your cut answer or its rest that answer it, copied verbatim> \u2014 they cut your answer to ask a quick question ABOUT it ("who?", "where do they sit?", "which one?") that your words above or the unsaid rest already answer. Find the exact span first, then answer from it only; your cut answer then goes on by itself. A new request, a change of topic, or a question those words do not answer is DEEP.
18737
+ ` : "") + `QUIET \u2014 nothing is owed: a bare "okay", "mm-hm", or a reaction you already answered.
18559
18738
  "Wait" / "hold on" with nothing new: a brief SAY ("Sure.") \u2014 no work for the colleague. Vary your words: never reuse an acknowledgement or reaction already said in this call.
18560
- A reaction ("wow", "really?") gets a short fitting reply in your own words ("I know, right?"), never their word back. Never repeat what was already said. Speak ${languageName(c.lang)}. ${personaHint(gender)} Output only the line.`;
18739
+ A reaction ("wow", "really?") gets a short fitting reply in your own words ("I know, right?"), never their word back. Never repeat what was already said. ` + (c.hint ? `
18740
+ A listener judge read this moment as: ${c.hint} (a hint; your own reading of their words wins).
18741
+ ` : "") + (c.plan ? `
18742
+ YOUR PLAN for this call (made before dialing; follow it, adapt to what they say):
18743
+ ${c.plan}
18744
+ When their words match a case in your plan, answer DEEP with that planned line as the acknowledgement (said at once; the colleague goes on from it).
18745
+ ` : "") + (c.caller ? `
18746
+ YOU PLACED THIS CALL: you ask, they answer; they are not your user. Never say you will check, wait or look anything up ("one moment", "checking", "\u05E8\u05D2\u05E2", "\u05D1\u05D5\u05D3\u05E7"). "Hello?" / "are you there?" from them = they lost you: SAY a short presence line in their language ("Yes, hi, I'm here" / "\u05DB\u05DF, \u05E9\u05DC\u05D5\u05DD, \u05D0\u05E0\u05D9 \u05E4\u05D4"). A DEEP acknowledgement may be empty ("DEEP: | \u2026"): prefer empty to a filler.
18747
+ ` : "") + `Speak ${languageName(c.lang)}. ${personaHint(gender)} Output only the line.`;
18561
18748
  }
18562
18749
 
18750
+ // src/voice/callPlan.ts
18751
+ init_logging();
18752
+ var log41 = forComponent("CallPlan");
18753
+ var CallPlanOptions = class {
18754
+ ai;
18755
+ model = "";
18756
+ /** Who calls whom and why (the call's task): the plan's only input. */
18757
+ persona = "";
18758
+ /** The call's language ('' = the persona's). */
18759
+ lang = "";
18760
+ gender;
18761
+ /** Give up after this long (the call goes on without a plan). */
18762
+ timeoutMs = 1e4;
18763
+ };
18764
+ var CallPlan = class _CallPlan {
18765
+ options;
18766
+ /** The whole plan as text ('' until ready / when it failed). */
18767
+ text = "";
18768
+ /** The first thing to say when a person answers: a hello + one short question. */
18769
+ opener = "";
18770
+ ready;
18771
+ /** How long the plan took (ms; 0 = not made). */
18772
+ ms = 0;
18773
+ /** The model's raw answer (diagnostics: a plan with no opener). */
18774
+ raw = "";
18775
+ constructor(options) {
18776
+ this.options = { ...new CallPlanOptions(), ...options };
18777
+ this.ready = this.options.persona ? this.make() : Promise.resolve();
18778
+ }
18779
+ /** The plan's prompt (exported for tests). */
18780
+ static prompt(persona, lang, gender) {
18781
+ return `${persona.slice(0, 800)}
18782
+
18783
+ You are about to dial this call. Plan it in your head first, like a person does: what you say first, what you ask and in what order, and how you answer what they will most likely say. One line each:
18784
+ OPENER: <only a casual greeting, the way people really open a call \u2014 may start with a small filler ("hmm", "uh") \u2014 1-3 words, no question yet>
18785
+ ASK: <your first short question, said after they answer the greeting; then the follow-ups in order> (2-4 lines)
18786
+ IF <a likely reply \u2014 yes, no, not in stock, don't know, hold on, transfer, who is this, a question back\u2026>: <what you say then> (4-7 lines)
18787
+ CLOSE: <a short thanks + bye>
18788
+ Every line is what you would say aloud: ${lang ? languageName(lang) : "the persona's language"}, casual and spoken like a real person (fillers, short turns, never formal), max 14 words, never a list in one breath, never "I am an AI", never a name for yourself or anyone that the task does not give, numbers as words ("five", not "5"). ${personaHint(gender)} Output only these lines.`;
18789
+ }
18790
+ /** "OPENER: …" → the opener (cleaned for speech). */
18791
+ static parse(raw, lang) {
18792
+ const lines = raw.split("\n").map((l) => l.replace(/^[\s>*_`#\-\d.)]+/, "").replace(/\*\*|__/g, "").trim()).filter((l) => /^(OPENER|ASK|IF|CLOSE)\b/i.test(l));
18793
+ const op = lines.find((l) => /^OPENER\b/i.test(l))?.replace(/^OPENER\s*:\s*/i, "").replace(/^["'\s]+|["'\s]+$/g, "") ?? "";
18794
+ return { text: lines.join("\n").slice(0, 1200), opener: op ? cleanLine(op, lang || "en", 18, 140) : "" };
18795
+ }
18796
+ async make() {
18797
+ const o = this.options, t0 = Date.now(), ac = new AbortController(), timer = setTimeout(() => ac.abort(), o.timeoutMs);
18798
+ try {
18799
+ const raw = this.raw = await fastText(o.ai, { model: o.model, prompt: _CallPlan.prompt(o.persona, o.lang, o.gender), signal: ac.signal, temperature: 0.4, maxTokens: 1500 });
18800
+ Object.assign(this, _CallPlan.parse(raw, o.lang));
18801
+ this.ms = Date.now() - t0;
18802
+ log41.debug(`plan ready in ${Date.now() - t0}ms: ${this.opener ? `opener "${this.opener}"` : "no opener"}`);
18803
+ } catch (e) {
18804
+ log41.debug(`no plan (${e?.message || e}) \u2014 the call goes on without one`);
18805
+ } finally {
18806
+ clearTimeout(timer);
18807
+ }
18808
+ }
18809
+ };
18810
+
18563
18811
  // cli/config.ts
18564
18812
  import { homedir as homedir5 } from "os";
18565
18813
  import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
@@ -18707,7 +18955,7 @@ function applyOverlay(cfg, file) {
18707
18955
  // cli/hooks-config.ts
18708
18956
  import { spawnSync as spawnSync4 } from "child_process";
18709
18957
  init_platform();
18710
- var log40 = forComponent("hooks");
18958
+ var log42 = forComponent("hooks");
18711
18959
  var escapeRegex = (s) => s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
18712
18960
  function ruleMatches(rule, toolName) {
18713
18961
  if (!rule.tool || rule.tool === "*") return true;
@@ -18726,7 +18974,7 @@ function runCmd(rule, env) {
18726
18974
  });
18727
18975
  return { code: r.status ?? 1, out: ((r.stdout ?? "") + (r.stderr ?? "")).trim() };
18728
18976
  } catch (e) {
18729
- log40.debug(`hook command failed: ${rule.command}`, e);
18977
+ log42.debug(`hook command failed: ${rule.command}`, e);
18730
18978
  return { code: 1, out: String(e?.message ?? e) };
18731
18979
  }
18732
18980
  }
@@ -18834,7 +19082,7 @@ import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as rea
18834
19082
  import { homedir as homedir6 } from "os";
18835
19083
  import { join as join11 } from "path";
18836
19084
  init_platform();
18837
- var log41 = forComponent("session");
19085
+ var log43 = forComponent("session");
18838
19086
  var globalDir = () => join11(homedir6(), ".agent", "sessions");
18839
19087
  function indexLink(target, link2) {
18840
19088
  try {
@@ -18897,7 +19145,7 @@ var SessionStore = class {
18897
19145
  }
18898
19146
  load(id) {
18899
19147
  if (!this.safeId(id)) {
18900
- log41.debug(`rejecting unsafe session id: ${id}`);
19148
+ log43.debug(`rejecting unsafe session id: ${id}`);
18901
19149
  return void 0;
18902
19150
  }
18903
19151
  const path = join11(this.dir, `${id}.json`);
@@ -18905,7 +19153,7 @@ var SessionStore = class {
18905
19153
  try {
18906
19154
  return JSON.parse(readFileSync8(path, "utf8"));
18907
19155
  } catch (e) {
18908
- log41.debug(`unreadable session ${id} \u2014 ignoring`, e);
19156
+ log43.debug(`unreadable session ${id} \u2014 ignoring`, e);
18909
19157
  return void 0;
18910
19158
  }
18911
19159
  }
@@ -18918,7 +19166,7 @@ var SessionStore = class {
18918
19166
  try {
18919
19167
  metas.push(JSON.parse(readFileSync8(join11(this.dir, f), "utf8")).meta);
18920
19168
  } catch (e) {
18921
- log41.debug(`skipping unreadable session file ${f}`, e);
19169
+ log43.debug(`skipping unreadable session file ${f}`, e);
18922
19170
  }
18923
19171
  }
18924
19172
  return metas.sort((a, b) => b.updated - a.updated);
@@ -19350,7 +19598,7 @@ import { promisify } from "util";
19350
19598
  import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync9 } from "fs";
19351
19599
  import { homedir as homedir7 } from "os";
19352
19600
  import { join as join12, resolve as resolve4, sep as sep3, parse as parsePath } from "path";
19353
- var log42 = forComponent("checkpoints");
19601
+ var log44 = forComponent("checkpoints");
19354
19602
  var exec = promisify(execFile4);
19355
19603
  var DEFAULT_EXCLUDE = [".agent/", ".git/", "node_modules/", "dist/", "build/", ".next/", "target/", ".venv/", "__pycache__/", "*.log"];
19356
19604
  function isBroadRoot(p) {
@@ -19398,7 +19646,7 @@ var ShadowRepo = class {
19398
19646
  writeFileSync6(join12(this.gitDir, "info", "exclude"), this.exclude.join("\n") + "\n");
19399
19647
  this.ready = true;
19400
19648
  } catch (e) {
19401
- log42.debug(`git checkpoints unavailable for ${this.workTree}`, e);
19649
+ log44.debug(`git checkpoints unavailable for ${this.workTree}`, e);
19402
19650
  this.ready = false;
19403
19651
  }
19404
19652
  return this.ready;
@@ -19409,7 +19657,7 @@ var ShadowRepo = class {
19409
19657
  }
19410
19658
  async commit(label, forced = []) {
19411
19659
  await this.run("add", "-A");
19412
- for (const p of forced) await this.run("add", "-f", "--", p).catch((e) => log42.debug(`force-add failed: ${p}`, e));
19660
+ for (const p of forced) await this.run("add", "-f", "--", p).catch((e) => log44.debug(`force-add failed: ${p}`, e));
19413
19661
  await this.run("commit", "--allow-empty", "-q", "-m", label);
19414
19662
  }
19415
19663
  /** Inject the CURRENT (pre-edit) content of `paths` into the turn-open restore point by amending it.
@@ -19417,8 +19665,8 @@ var ShadowRepo = class {
19417
19665
  * turn-boundary `add -A` would never have captured it. Amend (vs a new commit) keeps one restore
19418
19666
  * point per turn, so the REPL's turn↔frame mapping stays intact. */
19419
19667
  async amendForced(paths) {
19420
- for (const p of paths) await this.run("add", "-f", "--", p).catch((e) => log42.debug(`force-capture failed: ${p}`, e));
19421
- await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) => log42.debug("amend failed", e));
19668
+ for (const p of paths) await this.run("add", "-f", "--", p).catch((e) => log44.debug(`force-capture failed: ${p}`, e));
19669
+ await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) => log44.debug("amend failed", e));
19422
19670
  }
19423
19671
  /** Commits on `ref`, oldest-first (canonical index space). */
19424
19672
  async log(ref) {
@@ -19478,7 +19726,7 @@ var ShadowRepo = class {
19478
19726
  await this.run("gc", "--auto", "-q").catch(() => {
19479
19727
  });
19480
19728
  } catch (e) {
19481
- log42.debug("checkpoint prune failed", e);
19729
+ log44.debug("checkpoint prune failed", e);
19482
19730
  }
19483
19731
  }
19484
19732
  };
@@ -19546,7 +19794,7 @@ var GitCheckpoints = class {
19546
19794
  use(sessionId) {
19547
19795
  if (sessionId === this.session) return;
19548
19796
  this.session = sessionId;
19549
- if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) => log42.debug("re-point failed", e));
19797
+ if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) => log44.debug("re-point failed", e));
19550
19798
  }
19551
19799
  async begin(label) {
19552
19800
  if (!await this.start()) return;
@@ -19566,7 +19814,7 @@ var GitCheckpoints = class {
19566
19814
  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
19567
19815
  `);
19568
19816
  } else {
19569
- log42.debug("checkpoint commit failed", e);
19817
+ log44.debug("checkpoint commit failed", e);
19570
19818
  survivors.push(this.repos[i]);
19571
19819
  survivorCaches.push(this.caches[i] ?? []);
19572
19820
  }
@@ -19601,7 +19849,7 @@ var GitCheckpoints = class {
19601
19849
  if (this.forced.has(abs)) continue;
19602
19850
  this.forced.add(abs);
19603
19851
  const i = this.repoIndexFor(abs);
19604
- if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) => log42.debug("amendForced failed", e));
19852
+ if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) => log44.debug("amendForced failed", e));
19605
19853
  }
19606
19854
  }
19607
19855
  };
@@ -21391,7 +21639,7 @@ import { spawnSync as spawnSync6 } from "child_process";
21391
21639
  import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as existsSync7 } from "fs";
21392
21640
  import { homedir as homedir8 } from "os";
21393
21641
  import { join as join14 } from "path";
21394
- var log43 = forComponent("os-sched");
21642
+ var log45 = forComponent("os-sched");
21395
21643
  var OsScheduler = class {
21396
21644
  options;
21397
21645
  constructor(options) {
@@ -21453,7 +21701,7 @@ var OsScheduler = class {
21453
21701
  }
21454
21702
  }
21455
21703
  } catch (e) {
21456
- log43.debug(`cancel ${id}`, e);
21704
+ log45.debug(`cancel ${id}`, e);
21457
21705
  }
21458
21706
  for (const f of [`${id}.json`, `${id}.sh`]) {
21459
21707
  try {
@@ -21571,7 +21819,7 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync11, unlinkSync as unli
21571
21819
  import { homedir as homedir9 } from "os";
21572
21820
  import { join as join15 } from "path";
21573
21821
  init_platform();
21574
- var log44 = forComponent("remote-trigger");
21822
+ var log46 = forComponent("remote-trigger");
21575
21823
  var TRIGGER_DIR = () => join15(homedir9(), ".agent", "triggers");
21576
21824
  var sockPath = (sessionId, dir = TRIGGER_DIR()) => join15(dir, `${sessionId}.sock`);
21577
21825
  var TriggerServer = class {
@@ -21609,13 +21857,13 @@ var TriggerServer = class {
21609
21857
  conn.end(JSON.stringify({ ok: false, error: String(e) }) + "\n");
21610
21858
  }
21611
21859
  });
21612
- conn.on("error", (e) => log44.debug("trigger conn error", e));
21860
+ conn.on("error", (e) => log46.debug("trigger conn error", e));
21613
21861
  });
21614
- this.server.on("error", (e) => log44.debug("trigger server error", e));
21862
+ this.server.on("error", (e) => log46.debug("trigger server error", e));
21615
21863
  this.server.listen(p);
21616
21864
  this.path = p;
21617
21865
  } catch (e) {
21618
- log44.debug("trigger server unavailable", e);
21866
+ log46.debug("trigger server unavailable", e);
21619
21867
  }
21620
21868
  }
21621
21869
  /** Re-bind on /resume (the session id changed). */
@@ -21747,7 +21995,7 @@ var strike = C("9");
21747
21995
  var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
21748
21996
  var mdPalette = { bold, dim, cyan, italic, strike, green, link };
21749
21997
  var err = (s) => process.stderr.write(s);
21750
- var log45 = forComponent("cli");
21998
+ var log47 = forComponent("cli");
21751
21999
  var VERSION = (() => {
21752
22000
  try {
21753
22001
  return JSON.parse(readFileSync10(new URL("../package.json", import.meta.url), "utf8")).version ?? "?";
@@ -21909,6 +22157,12 @@ function parseArgs(argv) {
21909
22157
  else if (x === "--conversational" || x === "--convo" || x === "--voice") {
21910
22158
  a.voice = true;
21911
22159
  a.duplex = true;
22160
+ } else if (x === "--live") {
22161
+ a.voice = true;
22162
+ a.call = true;
22163
+ a.duplex = true;
22164
+ a.lean = true;
22165
+ a.channelMode ??= "live";
21912
22166
  } else if (x === "--voice-model") a.voiceModel = val(++i, x);
21913
22167
  else if (x === "--voice-gender") {
21914
22168
  const g = val(++i, x);
@@ -22016,6 +22270,8 @@ Flags:
22016
22270
  --call voice call (duplex v3): the main agent (-m, full tools) answers every turn; a fast model
22017
22271
  (--voice-model, default Claude Haiku) only fills the wait \u2014 backchannels, fillers, bridges,
22018
22272
  progress lines \u2014 and never enters the history. --duplex/--duplex-v2/--voice alias it
22273
+ --live live voice call: --call + mic on at start + --channel-mode live (Jev turn judge, quick lane,
22274
+ live prediction tree); TYPESAFE_AI_KEY enables Jev, else Groq decides
22019
22275
  interactively (AGENTX_DUPLEX_V1=1 keeps the v1 reflex below for one release)
22020
22276
  --duplex duplex mode: a fast voice model replies instantly and delegates real work
22021
22277
  to a background worker agent (-m model); results are re-voiced when ready
@@ -22659,7 +22915,7 @@ function turnCost(model, usage) {
22659
22915
  const priced = model.startsWith("claude-code/") ? `anthropic/${resolveModelAlias(model.slice("claude-code/".length))}` : model;
22660
22916
  return costOf(getModelInfo(priced)?.pricing, usage?.promptTokens ?? 0, usage?.completionTokens ?? 0, usage?.cacheCreationTokens ?? 0, usage?.cacheReadTokens ?? 0, priced);
22661
22917
  }
22662
- async function evaluateGoal(ai, condition, transcript, log46) {
22918
+ async function evaluateGoal(ai, condition, transcript, log48) {
22663
22919
  const recent = transcript.filter((m) => m.role === "assistant").slice(-8).map((m) => {
22664
22920
  const text = typeof m.content === "string" ? m.content : m.content.filter((p) => p.type === "text").map((p) => p.text).join(" ");
22665
22921
  return text.slice(0, 600);
@@ -22679,7 +22935,7 @@ ${recent}` }
22679
22935
  const match = r.content.match(/\{[\s\S]*\}/);
22680
22936
  if (match) return JSON.parse(match[0]);
22681
22937
  } catch (e) {
22682
- log46(dim(` (goal evaluator error: ${e?.message ?? e})
22938
+ log48(dim(` (goal evaluator error: ${e?.message ?? e})
22683
22939
  `));
22684
22940
  }
22685
22941
  return { met: false, reason: "evaluation unclear" };
@@ -22908,7 +23164,7 @@ function mcpAgentTools(mounted, opts) {
22908
23164
  return tools;
22909
23165
  }
22910
23166
  async function closeMcp(mounted) {
22911
- await Promise.all(mounted.map((m) => m.client.close().catch((e) => log45.debug("mcp close failed", e))));
23167
+ await Promise.all(mounted.map((m) => m.client.close().catch((e) => log47.debug("mcp close failed", e))));
22912
23168
  }
22913
23169
  var IMG_EXT = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
22914
23170
  function mentionRefs(line) {
@@ -22967,7 +23223,7 @@ async function expandMentions(fs, line) {
22967
23223
  if (loaded.includes(ref) || missing.includes(ref)) continue;
22968
23224
  if (ref.includes(":") && mcpMentionResolver) {
22969
23225
  const body = await mcpMentionResolver(ref).catch((e) => {
22970
- log45.debug("mcp mention resolve failed", e);
23226
+ log47.debug("mcp mention resolve failed", e);
22971
23227
  return null;
22972
23228
  });
22973
23229
  if (body != null) {
@@ -22993,7 +23249,7 @@ ${await fs.readFile(path)}`);
22993
23249
  ${blocks.join("\n\n")}` : line, loaded, missing };
22994
23250
  }
22995
23251
  function applyTurnMode(agent, session, task, flags = {}, onModel) {
22996
- const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log45.debug(m) });
23252
+ const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log47.debug(m) });
22997
23253
  const d = p.directives, isMode = !!(d.delegate || d.advisor || d.modeOff);
22998
23254
  if (p.unresolvedModel && /->|<-|delegate:|advisor:/.test(task.slice(0, task.length - p.prompt.length))) {
22999
23255
  err(red(` \u2717 unknown model "${p.unresolvedModel}"${p.ambiguous ? ` (could be: ${p.ambiguous.join(", ")})` : ""} \u2014 turn not sent
@@ -23086,7 +23342,7 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
23086
23342
  try {
23087
23343
  store.save(session);
23088
23344
  } catch (ex) {
23089
- log45.debug("mid-turn session flush failed", ex);
23345
+ log47.debug("mid-turn session flush failed", ex);
23090
23346
  }
23091
23347
  }
23092
23348
  return origNotify(e);
@@ -23250,14 +23506,14 @@ var isCancelTeardown = (e) => {
23250
23506
  function installCancelGuards(mounted) {
23251
23507
  process.on("unhandledRejection", (e) => {
23252
23508
  if (isCancelTeardown(e)) {
23253
- log45.debug("suppressed unhandledRejection (cursor stream cancel)", e);
23509
+ log47.debug("suppressed unhandledRejection (cursor stream cancel)", e);
23254
23510
  return;
23255
23511
  }
23256
- log45.error("unhandledRejection", e);
23512
+ log47.error("unhandledRejection", e);
23257
23513
  });
23258
23514
  process.on("uncaughtException", (e) => {
23259
23515
  if (isCancelTeardown(e)) {
23260
- log45.debug("suppressed uncaughtException (cursor stream cancel)", e);
23516
+ log47.debug("suppressed uncaughtException (cursor stream cancel)", e);
23261
23517
  return;
23262
23518
  }
23263
23519
  console.error(e);
@@ -23612,6 +23868,10 @@ async function repl(args, ai, cfg, cwd) {
23612
23868
  call = new VoiceCall({
23613
23869
  ai,
23614
23870
  ...fast.options,
23871
+ ...args.channelMode === "live" ? (() => {
23872
+ const turnJudge = turnJudgeFor();
23873
+ return turnJudge ? { turnJudge } : {};
23874
+ })() : {},
23615
23875
  // live: the quick lane owns the conversation, MAIN is its deep lane (#1331). Only here: its lines reach MAIN through
23616
23876
  // noteTurn, which a --channel-only host (Para) does not take yet.
23617
23877
  ...args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0" ? { quick: fastQuickLane(ai, fast.options.fastModel, args.voiceGender, args.voicePersona) } : {},
@@ -23673,7 +23933,7 @@ ${SPOKEN_TURN}`, { id });
23673
23933
  editorRef?.abort();
23674
23934
  }
23675
23935
  } catch (e) {
23676
- log45.error("call turn failed", e);
23936
+ log47.error("call turn failed", e);
23677
23937
  } finally {
23678
23938
  rec.running = false;
23679
23939
  call?.main({ type: "done", id });
@@ -23827,7 +24087,7 @@ ${SPOKEN_TURN}`, { id });
23827
24087
  try {
23828
24088
  mkdirSync12(dir, { recursive: true });
23829
24089
  } catch (e) {
23830
- log45.debug("paste image dir create failed", e);
24090
+ log47.debug("paste image dir create failed", e);
23831
24091
  }
23832
24092
  const img = grabClipboardImage(dir, String(Date.now()));
23833
24093
  return img ? { display: "Image", ref: "@" + img.path, path: img.path } : null;
@@ -23940,7 +24200,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
23940
24200
  mkdirSync12(join16(cwd, ".agent"), { recursive: true });
23941
24201
  appendFileSync2(histPath, line + "\n");
23942
24202
  } catch (e) {
23943
- log45.debug("history write failed", e);
24203
+ log47.debug("history write failed", e);
23944
24204
  }
23945
24205
  };
23946
24206
  const ago = (t) => {
@@ -24012,7 +24272,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
24012
24272
  try {
24013
24273
  store.save(session);
24014
24274
  } catch (e) {
24015
- log45.debug("session save after rewind failed", e);
24275
+ log47.debug("session save after rewind failed", e);
24016
24276
  }
24017
24277
  err(green(" \u27F2 jumped back") + dim(` \u2014 ${face.transcript.length} message(s) kept; edit + resend
24018
24278
  `));
@@ -24047,7 +24307,7 @@ ${task}`;
24047
24307
  bangContext.length = 0;
24048
24308
  }
24049
24309
  const delta = await refreshCatalogs().catch((e) => {
24050
- log45.debug("catalog refresh failed", e);
24310
+ log47.debug("catalog refresh failed", e);
24051
24311
  return "";
24052
24312
  });
24053
24313
  if (delta) {
@@ -24321,7 +24581,7 @@ ${task}`;
24321
24581
  desc: "rescan skills/commands dirs and rebuild the system prompt (one cache miss) \u2014 picks up entries created mid-session",
24322
24582
  run: async () => {
24323
24583
  await refreshCatalogs().catch((e) => {
24324
- log45.debug("catalog refresh failed", e);
24584
+ log47.debug("catalog refresh failed", e);
24325
24585
  });
24326
24586
  face.reprepare();
24327
24587
  err(green(` \u2713 reloaded \u2014 ${skills.length} skill(s), ${cmds.length} command(s); system prompt rebuilds on next message
@@ -24824,7 +25084,7 @@ ${task}`;
24824
25084
  try {
24825
25085
  for (const def of (await loadAgents(fs2, d)).agents) if (!seen.has(def.name)) seen.set(def.name, { def, from: d });
24826
25086
  } catch (e) {
24827
- log45.debug(`loadAgents(${d}) failed`, e);
25087
+ log47.debug(`loadAgents(${d}) failed`, e);
24828
25088
  }
24829
25089
  }
24830
25090
  if (!seen.size) {
@@ -24912,7 +25172,7 @@ ${task}`;
24912
25172
  }
24913
25173
  if (idx >= 0) {
24914
25174
  const old = mounted.splice(idx, 1)[0];
24915
- await old.client.close().catch((e) => log45.debug("mcp close failed", e));
25175
+ await old.client.close().catch((e) => log47.debug("mcp close failed", e));
24916
25176
  }
24917
25177
  try {
24918
25178
  const m = await mountMcpServer(name, conf);
@@ -24940,7 +25200,7 @@ ${task}`;
24940
25200
  }
24941
25201
  const m = mounted.splice(idx, 1)[0];
24942
25202
  remountMcpTools();
24943
- await m.client.close().catch((e) => log45.debug("mcp close failed", e));
25203
+ await m.client.close().catch((e) => log47.debug("mcp close failed", e));
24944
25204
  err(dim(` removed "${name}"
24945
25205
  `));
24946
25206
  return;
@@ -25143,7 +25403,7 @@ ${task}`;
25143
25403
  try {
25144
25404
  return readdirSync4(join16(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
25145
25405
  } catch (e) {
25146
- log45.debug("completion readdir failed", absDir, e);
25406
+ log47.debug("completion readdir failed", absDir, e);
25147
25407
  return null;
25148
25408
  }
25149
25409
  };
@@ -25282,7 +25542,7 @@ ${out}
25282
25542
  return;
25283
25543
  }
25284
25544
  await refreshCatalogs().catch((e) => {
25285
- log45.debug("catalog refresh failed", e);
25545
+ log47.debug("catalog refresh failed", e);
25286
25546
  });
25287
25547
  const sk = skills.find((x) => x.name === name);
25288
25548
  if (sk) {
@@ -25412,7 +25672,7 @@ ${out}
25412
25672
  if (delivery || cut) dx?.parkCutDelivery(delivery, !!cut, heard);
25413
25673
  const cutReply = cut && cut.full.length - cut.heard.length > 40 ? cut : null;
25414
25674
  const noteP = replaces ? replaces.note : !cutReply ? Promise.resolve("") : (instinct ? instinct.bargeIntent(text).catch((e) => {
25415
- log45.warn(`barge intent failed \u2014 model decides: ${e.message}`);
25675
+ log47.warn(`barge intent failed \u2014 model decides: ${e.message}`);
25416
25676
  return void 0;
25417
25677
  }) : Promise.resolve(void 0)).then(async (intent) => interruptionNote(cutReply, intent) + ackedNote(await instinct?.ackFor(text)));
25418
25678
  const cutIn = replaces ? replaces.cutIn : interjectNote;
@@ -25813,10 +26073,10 @@ function channelOptions(ai, model, gender) {
25813
26073
  // 0: the reactive live path
25814
26074
  pickLeaf: fastLeafPicker(ai, process.env.AGENTX_LEAF_MODEL || "groq/openai/gpt-oss-120b"),
25815
26075
  persona: process.env.AGENTX_CALL_PERSONA ?? "",
25816
- onTree: (e) => log45.debug(`voice tree: ${e.branches} branches in ${e.ms}ms${e.tokens ? ` tokens ${e.tokens.input}/${e.tokens.output}` : ""}${e.error ? ` error ${e.error}` : ""}`),
26076
+ onTree: (e) => log47.debug(`voice tree: ${e.branches} branches in ${e.ms}ms${e.tokens ? ` tokens ${e.tokens.input}/${e.tokens.output}` : ""}${e.error ? ` error ${e.error}` : ""}`),
25817
26077
  onEvent: (e) => {
25818
- if (e.moment) log45.debug(`voice leaf: ${e.moment} ${e.conf} "${e.text}" ${e.acted}`);
25819
- else log45.debug(`channel ${e.trigger}: rule=${e.rule} choice=${e.choice ?? "-"} \u2192 ${e.acted}${e.text ? ` "${e.text}"` : ""}${e.cue ? " (planned cue)" : ""} ${e.ms}ms`);
26078
+ if (e.moment) log47.debug(`voice leaf: ${e.moment} ${e.conf} "${e.text}" ${e.acted}`);
26079
+ else log47.debug(`channel ${e.trigger}: rule=${e.rule} choice=${e.choice ?? "-"} \u2192 ${e.acted}${e.text ? ` "${e.text}"` : ""}${e.cue ? " (planned cue)" : ""} ${e.ms}ms`);
25820
26080
  },
25821
26081
  // Banks in the user's language: generated once per language, cached + topped up across sessions (~/.agent/cache).
25822
26082
  banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir: join16(homedir10(), ".agent", "cache", "channel-banks") }),
@@ -25910,7 +26170,7 @@ async function duplexServe(args, ai, cfg, cwd) {
25910
26170
  try {
25911
26171
  store.save(session);
25912
26172
  } catch (e) {
25913
- log45.warn("duplex session save failed", e);
26173
+ log47.warn("duplex session save failed", e);
25914
26174
  }
25915
26175
  };
25916
26176
  const overlap2 = overlapResponder(ai, args.duplexV2 ? args.channelMode : void 0, out);
@@ -25950,7 +26210,7 @@ async function duplexServe(args, ai, cfg, cwd) {
25950
26210
  done2();
25951
26211
  out({ type: "turn_done", id, finishReason: res?.finishReason ?? "error", ...why ? { error: why } : {} });
25952
26212
  }).catch((e) => {
25953
- log45.error("duplex turn failed", e);
26213
+ log47.error("duplex turn failed", e);
25954
26214
  done2();
25955
26215
  out({ type: "turn_done", id, finishReason: "error", error: String(e?.message ?? e) });
25956
26216
  });
@@ -25969,12 +26229,22 @@ async function channelServe(args, ai, cfg) {
25969
26229
  const { model, notes, options: fast } = callFast(args, ai, cfg);
25970
26230
  const quick = args.quickLane && args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0";
25971
26231
  let cut = null;
26232
+ const caller = process.env.AGENTX_CALL_ROLE === "caller", persona = process.env.AGENTX_CALL_PERSONA ?? "";
26233
+ const plan = quick && caller && persona ? new CallPlan({ ai, model: fast.fastModel, persona, lang: process.env.AGENTX_CALL_LANG ?? "", gender: args.voiceGender }) : void 0;
26234
+ void plan?.ready.then(() => {
26235
+ out({ type: "metric", name: "plan", ms: plan.ms, ...plan.opener ? { text: plan.opener } : {}, kind: plan.opener ? `opener "${plan.opener}"` : `no opener: ${JSON.stringify(plan.raw.slice(0, 300))}` });
26236
+ if (plan.text) out({ type: "note", text: `Your plan for this call (made before dialing \u2014 follow it, adapt to what they say; your quick voice may already have said its lines):
26237
+ ${plan.text}` });
26238
+ });
26239
+ const menu = caller ? new MenuKeys({ ai, model: process.env.AGENTX_MENU_MODEL || "groq/openai/gpt-oss-120b", persona }) : void 0;
26240
+ const turnJudge = args.channelMode === "live" ? turnJudgeFor() : void 0;
25972
26241
  const call = new VoiceCall({
25973
26242
  ...fast,
25974
26243
  // no `ai` here: the channel's model wiring is explicit
26244
+ ...turnJudge ? { turnJudge } : {},
25975
26245
  ...quick ? {
25976
- quick: fastQuickLane(ai, fast.fastModel, args.voiceGender, process.env.AGENTX_CALL_PERSONA ?? "", void 0, process.env.AGENTX_CALL_NO_TOOLS !== "1"),
25977
- // (1: MAIN has no tools — a sandboxed phone call)
26246
+ quick: fastQuickLane(ai, fast.fastModel, args.voiceGender, persona, void 0, process.env.AGENTX_CALL_NO_TOOLS !== "1", caller, plan),
26247
+ // (NO_TOOLS 1: MAIN has no tools — a sandboxed phone call; ROLE caller: we placed it)
25978
26248
  noteTurn: (text) => out({ type: "note", text }),
25979
26249
  heardCut: () => cut?.heard ?? null,
25980
26250
  cutRest: () => cut && cut.full.slice(cut.heard.length).trim() || null,
@@ -26010,6 +26280,7 @@ async function channelServe(args, ai, cfg) {
26010
26280
  return call.aside(t);
26011
26281
  });
26012
26282
  out({ type: "ready", model, channelMode: args.channelMode, softBarge: softBarge(args.channelMode), call: true, ...quick ? { quickLane: true } : {}, ...notes.length ? { notes } : {} });
26283
+ if (args.channelMode === "live") out({ type: "metric", name: "judge", kind: turnJudge ? `on (${process.env.TYPESAFE_AI_KEY ? "jev" : "groq"})` : "off (no decider key)" });
26013
26284
  const rl = createInterface({ input: process.stdin });
26014
26285
  rl.on("line", (line) => {
26015
26286
  let m;
@@ -26032,6 +26303,8 @@ async function channelServe(args, ai, cfg) {
26032
26303
  else if (m.type === "user" && typeof m.text === "string") call.hostTurn(m.text);
26033
26304
  else if (m.type === "text" && typeof m.text === "string") call.fill.onMainTokens(m.text);
26034
26305
  else if (m.type === "overlap") overlap2(m);
26306
+ else if (m.type === "menu" && menu && typeof m.text === "string") void menu.hear(m.text).then((r) => out({ type: "keys", digits: r.digits, ms: r.ms, text: m.text }));
26307
+ else if (m.type === "pressed" && menu && typeof m.digits === "string") menu.pressed(m.digits);
26035
26308
  else if (m.type === "exit") rl.close();
26036
26309
  });
26037
26310
  await new Promise((r) => rl.on("close", () => r()));