@livx.cc/agentx 0.99.154 → 0.99.155

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/README.md CHANGED
@@ -121,7 +121,7 @@ agentx --resume <id> "…" # resume a specific session
121
121
  - **Raise, don't guess** (`AskUserQuestion` + `finishReason: 'needs_input'`) — when a decision is genuinely the user's, the agent asks. Interactively that's an arrow-select prompt. **Headless** (`-p`, piped, no TTY) there's nobody to prompt, so instead of blocking on a prompt no one can see — or, worse, "proceeding with best judgment" — the run **stops and hands the question to its caller**: exit code `2`, a yellow `? needs input` footer, and `{finishReason:'needs_input', question:{…}, sessionId}` in `--output-format json`. The transcript is preserved, so the caller answers and continues (`--resume <id> -p "<answer>"`) instead of re-running. A delegated agent silently deciding something that was never its to decide is the failure this closes.
122
122
  - **Tab-completion** — `Tab` completes `/<command>` names and `@<path>` file/dir references (descends subdirs, dotfiles hidden unless typed) straight from the working tree.
123
123
  - **Voice call (duplex v3)** — `agentx --call --voice` (also what interactive `--duplex`/`--duplex-v2`/`--voice` run now; `AGENTX_DUPLEX_V1=1` keeps the reflex engine below for one release): the main agent (`-m`, full tools, real history) hears the user's exact words and answers every turn; a fast model (`--voice-model`, default Claude Haiku) only covers the wait — backchannels, fillers, bridges and tool-progress lines — and has no path into the history. `VoiceCall` (`src/voice/call.ts`, exported) is the host-agnostic core: `TurnGate` holds mid-phrase finals, merges re-finals, drops duplicates and a second goodbye; `Progress` speaks "checking the board…" during long tool runs. `--voice-persona <file>` sets who the call is: it replaces the default call style in MAIN's prompt and feeds the live prediction tree. In `--channel-mode live`, bridges and progress carry the request's own words ("Hacker News, one sec.": a tree leaf, else the fast model, else silence), never a stock line. A call's greeting uses no tools and its prompt is warmed first. While MAIN works (`noteTurn` + `workReply`), a remark gets an immediate fast-model answer and reaches MAIN as a note on its next turn; a change runs as MAIN's next turn; a stop aborts it. Progress lines start about 3 s into a silence and repeat about every 5 s, never the same line. `--call` sets `ENABLE_TOOL_SEARCH=false` (claude-code/*: tools loaded up front, a larger prompt for no ToolSearch round trip). A persona should say to react first, then give the fact: `When they react or push back ("what?", "are you serious?"), react first, like a person, then give the fact.`
124
- - **Fill channel for host apps** — `agentx --channel-only --input-format stream-json --output-format stream-json` hosts a `VoiceCall` behind NDJSON for an app whose MAIN is its own agent: stdin `{type:'final', text, sttId?}`, `{type:'main', ev}` (MAIN's start/text/tool/tool_done/audio/done/error), `{type:'interim'|'pause'|'barge'|'overlap'}`; stdout `{type:'turn', id, text, replaces?}` (run MAIN on it), `{type:'abort', id}`, `{type:'channel', kind, text, speech?}` (`speech`: what to play when it differs: tagged; `text` is '' for a sound alone). The v2 inputs (`user`/`text`/`agent_state`) still work.
124
+ - **Fill channel for host apps** — `agentx --channel-only --input-format stream-json --output-format stream-json` hosts a `VoiceCall` behind NDJSON for an app whose MAIN is its own agent: stdin `{type:'final', text, sttId?}`, `{type:'main', ev}` (MAIN's start/text/tool/tool_done/audio/done/error), `{type:'interim'|'pause'|'barge'|'overlap'}`; stdout `{type:'turn', id, text, replaces?}` (run MAIN on it), `{type:'abort', id}`, `{type:'channel', kind, text, speech?}` (`speech`: what to play when it differs: tagged; `text` is '' for a sound alone). The v2 inputs (`user`/`text`/`agent_state`) still work. With `--quick-lane --channel-mode live` it runs two lanes like `--call`: the quick lane answers chit-chat, reactions and exact restates itself and acks real work before the `turn`; stdin adds `{type:'cut', full, heard}` (a barge cut MAIN's reply), stdout adds `{type:'note', text}` (put it, model-only, in MAIN's next turn), `{type:'user_line', text, how: quick|aside|kept}` (user words that start no turn), `{type:'resumed'}` (a "go on" said the cut rest: drop your cut note) and `channel` kinds `ack`/`reply`. Hosts without the flag are unchanged.
125
125
  - **Duplex mode** — `agentx --duplex` runs the full standard REPL (slash commands, sessions, postures, rewind, MCP) with the three-tier engine driving turns: a fast voice model (`--voice-model`, default `groq/openai/gpt-oss-120b`) answers every line instantly and delegates real work to background workers built with the same wiring as a normal run (fs mode, permissions, MCP); worker activity shows as dim chrome and results are re-voiced when ready. Switch any tier live with `/model` (opens a reflex/act/think picker), or the `/voice-model` · `/think-model` shortcuts. `/tasks` lists background tasks, inspects a task's live output tail, and cancels a running one from a picker (Esc mid-turn cancels the foreground turn; Esc again at the idle prompt cancels running workers).
126
126
  - **Headless duplex for host apps** — `agentx --voice --input-format stream-json --output-format stream-json` runs the same duplex engine behind an NDJSON pipe, for an app that owns its own mic/TTS (the Bare browser uses it). stdin: `{type:'user', text, id?, replaces?, cut?}` (`cut` = the host voice engine's `takeInterruptedReply()`, so "heard up to" / parked deliveries work exactly as in the CLI), `{type:'barge'}`, `{type:'cancel', task}`, `{type:'exit'}`. stdout: reflex `text`/`thinking` deltas, worker `speak` utterances, `filler`, `task` lifecycle events, `turn_done`, `revoice_done`, `exit`. `--append-system-prompt` goes to the workers, `--voice-system-prompt` to the voice model.
127
127
  - **MCP servers** — declare `mcpServers: { name: { command, args } | { url } }` in config and they're auto-mounted at startup (in parallel, with an optional `mountTimeoutMs` deadline so one slow/dead server never blocks the rest): the client does the JSON-RPC handshake (stdio or HTTP) + `tools/list`, and the discovered tools appear as `mcp__<name>__<tool>` in `/tools` (inspect with `/mcp`). A bad server is logged and skipped, never blocking the agent. For large tool sets, **deferred mode** (`makeMcpToolSearch` / `mountMcpDeferred`) exposes just two bounded tools (`ToolSearch` + `McpCall`) instead of N defs — dodging the provider tool-cap and improving selection accuracy; the CLI applies this automatically past 12 mounted tools (a 42-tool server was costing ~80k tok/turn in schema alone), and permission rules written against the real `mcp__<name>__<tool>` names still match through `McpCall`. **`mountMcpCatalog`** goes further: a cached, hash-keyed catalog + lazy connect means a turn that uses no MCP tool opens **zero** connections, and one that uses a tool connects exactly that server — latency scales with tools-used, not servers-configured. A down server is **negative-cached** (`failureCooldownMs`) so it never re-floors a later turn at the deadline. For zero turn-path latency even on a cold process, call **`warmMcpCatalog`** at boot + on a timer (off-turn discovery) and mount with **`{ discover: 'cache-only' }`** — the turn then never synchronously connects: it serves the warmed catalog and discovers any miss in the background. **Slow tools are jobs, not timeouts**: `timeoutMs` (default 30s) bounds protocol requests (`initialize`, `tools/list`) only; a `tools/call` still running after the soft foreground timeout (`foregroundMs.mcp`, 30s) returns `[still running] … background job job-N` while the request keeps going, and its result is delivered when it lands. The client sends a `progressToken` and reads progress over stdio and incrementally over HTTP/SSE; a call is cancelled (`notifications/cancelled`) only by `JobKill`, the stuck-job reaper, or its hard cap `callTimeoutMs` (per server, default 30 min).
package/dist/cli.d.ts CHANGED
@@ -159,6 +159,7 @@ interface Args {
159
159
  duplexV2?: boolean;
160
160
  call?: boolean;
161
161
  channelOnly?: boolean;
162
+ quickLane?: boolean;
162
163
  channelMode?: ChannelMode;
163
164
  voiceModel?: string;
164
165
  thinkModel?: string | false;
package/dist/cli.js CHANGED
@@ -7795,6 +7795,7 @@ function heardPrefix(text, spoken, lookahead = 4) {
7795
7795
  }
7796
7796
  return at;
7797
7797
  }
7798
+ var ECHO_RECENT_SEC = 1.8;
7798
7799
  var NumberedSpeakers = class {
7799
7800
  ids = /* @__PURE__ */ new Map();
7800
7801
  name(label) {
@@ -8067,6 +8068,10 @@ var VoiceEngine = class _VoiceEngine {
8067
8068
  drainTimer = null;
8068
8069
  // heuristic tier state (inert under AEC) — frozen as validated in the experiment
8069
8070
  echoWords = /* @__PURE__ */ new Set();
8071
+ /** Our words audible when this utterance's first partial came (undefined = no partial yet, null = no word timestamps). */
8072
+ uttEcho;
8073
+ /** The words of the line before this turn: its audio may still be playing ahead of this turn's first word. */
8074
+ lineBefore = /* @__PURE__ */ new Set();
8070
8075
  prevReply = "";
8071
8076
  reply = "";
8072
8077
  echoUntil = 0;
@@ -8323,6 +8328,7 @@ var VoiceEngine = class _VoiceEngine {
8323
8328
  if (this.options.revealMode === "word") this.startWordReveal();
8324
8329
  this.emo = this.options.emotions ? new EmotionStream(this.options.showEmotions) : null;
8325
8330
  this.echoWords = new Set(this.words(this.prevReply));
8331
+ this.lineBefore = new Set(this.echoWords);
8326
8332
  this.tts.newContext();
8327
8333
  this.clause = "";
8328
8334
  this.clearAckTimer("new_turn");
@@ -8811,6 +8817,18 @@ var VoiceEngine = class _VoiceEngine {
8811
8817
  this.diag("echo_head", { dropped: toks.slice(0, i).join(" ").slice(0, 60) });
8812
8818
  return toks.slice(i).join(" ");
8813
8819
  }
8820
+ /** Our words whose audio played in the last ECHO_RECENT_SEC (+ the ack just said) — what an echo can be made of right
8821
+ * now. null = no word timestamps (the bag rule judges alone). */
8822
+ audibleWords() {
8823
+ if (!this.echoActive() || !this.wordStarts.length) return null;
8824
+ const now4 = this.player.playedMs() / 1e3, out = /* @__PURE__ */ new Set();
8825
+ this.wordStarts.forEach((s, i) => {
8826
+ if (s <= now4 + 0.3 && s >= now4 - ECHO_RECENT_SEC) for (const w of this.words(this.wordTexts[i] ?? "")) out.add(w);
8827
+ });
8828
+ if (now4 < this.wordStarts[0] + ECHO_RECENT_SEC) for (const w of this.lineBefore) out.add(w);
8829
+ if (this.ackAt && this.clock.now() - this.ackAt < 3e3) for (const w of this.words(this.lastAck)) out.add(w);
8830
+ return out;
8831
+ }
8814
8832
  novelWords(text) {
8815
8833
  return this.words(text).filter((w) => !this.echoWords.has(w));
8816
8834
  }
@@ -8837,10 +8855,10 @@ var VoiceEngine = class _VoiceEngine {
8837
8855
  * of our last words in their own sentence is neither: live 20261103-114604, over "…Want me to open the thread?" the
8838
8856
  * user's "You can't open the thread?" (3 of 5 in line) was swallowed and they had to say it again — the old rule
8839
8857
  * (half the words in a word pair we said) counted it as echo. Shorter finals can't show order → bag rule. */
8840
- echoFinal(text) {
8858
+ echoFinal(text, audible = null) {
8841
8859
  if (this.genuine(text)) return false;
8842
8860
  const w = this.words(text);
8843
- if (w.length < 4) return true;
8861
+ if (w.length < 4) return audible ? w.every((x) => audible.has(x)) : true;
8844
8862
  const said = this.words(`${this.prevReply} ${this.reply} ${this.lastAck}`);
8845
8863
  const span = w.length + 2;
8846
8864
  let best = 0, run = 0;
@@ -8882,6 +8900,7 @@ var VoiceEngine = class _VoiceEngine {
8882
8900
  return w.length === 1 && d.length > 0 && this.clock.now() - this.lastDispatchAt < _VoiceEngine.DUP_FINAL_MS && d[d.length - 1].startsWith(w[0]);
8883
8901
  }
8884
8902
  handlePartial(text) {
8903
+ if (text.trim() && !this.uttEcho) this.uttEcho = { at: this.clock.now(), words: this.audibleWords() };
8885
8904
  if (this.speaking) {
8886
8905
  if (!this.options.bargeIn) return;
8887
8906
  if (this.clock.now() < this.bargeGraceUntil) {
@@ -9305,6 +9324,9 @@ var VoiceEngine = class _VoiceEngine {
9305
9324
  }
9306
9325
  handleUtterance(text, langs, rawTurns) {
9307
9326
  let turns;
9327
+ const cap = this.uttEcho;
9328
+ this.uttEcho = void 0;
9329
+ const audible = cap && this.clock.now() - cap.at < 15e3 ? cap.words : null;
9308
9330
  if (this.echoHead) {
9309
9331
  this.echoHead = false;
9310
9332
  text = this.dropEchoHead(text);
@@ -9339,7 +9361,7 @@ var VoiceEngine = class _VoiceEngine {
9339
9361
  this.stt.reset();
9340
9362
  return;
9341
9363
  }
9342
- if (this.echoActive() && (!this.options.bargeIn || (this.usingAec ? this.echoFinal(text) : this.novelWords(text).length < 2))) {
9364
+ if (this.echoActive() && (!this.options.bargeIn || (this.usingAec ? this.echoFinal(text, audible) : this.novelWords(text).length < 2))) {
9343
9365
  this.diag("echo_swallow", { guard: "echo_gate", text: text.slice(0, 60) });
9344
9366
  this.stt.reset();
9345
9367
  return;
@@ -10464,7 +10486,10 @@ var ASIDES = {
10464
10486
  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?"] }
10465
10487
  };
10466
10488
  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;
10467
- var isReaction = (text) => REACT.test(norm2(text));
10489
+ var isReaction = (text) => {
10490
+ const t = norm2(text);
10491
+ 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"), ""));
10492
+ };
10468
10493
  function overlapAside(text, lang, avoid = "", pick = (n) => Math.floor(Math.random() * n), react = false) {
10469
10494
  const kind = react && REACT.test(norm2(text)) ? "react" : cueKind(text);
10470
10495
  const l = new RegExp("\\p{Script=Hebrew}", "u").test(text) ? "he" : /[a-z]/i.test(text) ? "en" : lang;
@@ -15467,6 +15492,10 @@ var VoiceCallOptions = class {
15467
15492
  /** Host caption — never history. */
15468
15493
  show = () => {
15469
15494
  };
15495
+ /** The user's words that start no MAIN turn — the host's transcript shows them (sendTurn shows the rest): `quick` = a
15496
+ * turn the quick lane answered, `aside` = said while MAIN worked, `kept` = a soft barge-in kept over the reply. */
15497
+ userLine = () => {
15498
+ };
15470
15499
  /** The fast model (lines, banks, progress) — used only with `ai`. */
15471
15500
  fastModel = latestClaude("haiku");
15472
15501
  /** Model client for the fast model + the channel decider / overlap judge. Absent → canned lines and rules only. */
@@ -15634,6 +15663,13 @@ var VoiceCall = class {
15634
15663
  if (this.ended) return;
15635
15664
  if (by === "main") return this.main({ type: "audio", ...this.cur ? { id: this.cur.id } : {} }, inMs);
15636
15665
  const at = this.o.now() + Math.max(0, inMs);
15666
+ const q2 = this.cur;
15667
+ if (q2?.quickWord && !q2.closed) {
15668
+ this.lastAudibleAt = at;
15669
+ q2.marks.fillAudio ??= at;
15670
+ this.sounded(q2, "quick", at);
15671
+ return this.quickWorded(q2, at);
15672
+ }
15637
15673
  if (this.gate.holding || !this.cur || this.cur.closed) {
15638
15674
  this.earlyHeard ??= { at, by };
15639
15675
  return;
@@ -15749,11 +15785,44 @@ var VoiceCall = class {
15749
15785
  }
15750
15786
  /** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
15751
15787
  async overlap(text) {
15752
- if (this.o.mode === "live" && isReaction(text)) return "keep";
15788
+ if (this.o.mode === "live" && isReaction(text)) return this.kept(text), "keep";
15753
15789
  const d = await this.judge.judge(text);
15754
15790
  if (d.verdict === "cut") this.barge();
15791
+ else if (d.verdict === "keep") this.kept(text);
15755
15792
  return d.verdict;
15756
15793
  }
15794
+ /** An overlap kept over the reply (no turn): the transcript and the quick lane's history still hold their words — once,
15795
+ * in full: the host asks about every growing partial ("Oh," "Oh, wow" "Oh, wow—really?"; Para replay showed all four). */
15796
+ kept(text) {
15797
+ if (!norm3(text)) return;
15798
+ const p = this.keptLine, a = norm3(text).replace(/ /g, ""), b = p ? norm3(p.text).replace(/ /g, "") : "";
15799
+ if (p && (a.startsWith(b) || b.startsWith(a))) {
15800
+ if (a.length > b.length) {
15801
+ p.text = text;
15802
+ if (p.line) p.line.text = text;
15803
+ }
15804
+ clearTimeout(p.timer);
15805
+ } else {
15806
+ this.flushKept();
15807
+ const line = this.quickOn ? { who: "user", text } : void 0;
15808
+ if (line) this.history.push(line);
15809
+ this.keptLine = { text, timer: void 0, line };
15810
+ }
15811
+ this.keptLine.timer = setTimeout(() => this.flushKept(), isReaction(this.keptLine.text) ? 1500 : 4e3);
15812
+ }
15813
+ keptLine;
15814
+ /** The kept words go to the transcript; `turn` = the words a new turn starts with (they grew into it: no line of their own). */
15815
+ flushKept(turn = "") {
15816
+ const p = this.keptLine;
15817
+ if (!p) return;
15818
+ this.keptLine = void 0;
15819
+ clearTimeout(p.timer);
15820
+ if (turn && norm3(turn).replace(/ /g, "").startsWith(norm3(p.text).replace(/ /g, ""))) {
15821
+ if (p.line) this.history.splice(this.history.indexOf(p.line), 1);
15822
+ return;
15823
+ }
15824
+ this.o.userLine(p.text, "kept");
15825
+ }
15757
15826
  /** The fill channel's spoken aside for an overlap judged 'keep' ("yeah" → "Oh yeah, definitely."): the host plays it
15758
15827
  * while the reply is held, then resumes the same reply (bod-voice decideOverlap's aside). ≤4 canned words, never a
15759
15828
  * claim, the cue's language; null = stay quiet (a plain listener cue, too soon after the last, or no line). It is a
@@ -15764,7 +15833,7 @@ var VoiceCall = class {
15764
15833
  const line = overlapAside(text, this.lang, this.lastAside.text, void 0, this.o.mode === "live");
15765
15834
  if (!line) return null;
15766
15835
  this.lastAside = { text: line, at: now4 };
15767
- if (this.quickOn) this.history.push({ who: "user", text }, { who: "you", text: line });
15836
+ if (this.quickOn) this.history.push({ who: "you", text: line });
15768
15837
  this.o.onMetric({ name: "fill", kind: "aside", text: line, lang: this.lang });
15769
15838
  return line;
15770
15839
  }
@@ -15777,6 +15846,7 @@ var VoiceCall = class {
15777
15846
  return this.fill.drain();
15778
15847
  }
15779
15848
  end() {
15849
+ this.flushKept();
15780
15850
  if (this.cur) this.close(this.cur);
15781
15851
  this.ended = true;
15782
15852
  this.gate.end();
@@ -15797,6 +15867,7 @@ var VoiceCall = class {
15797
15867
  }
15798
15868
  onTurn(t) {
15799
15869
  this.floor = "";
15870
+ this.flushKept(t.text);
15800
15871
  if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
15801
15872
  const prev = this.cur, quick = this.quickOn && !this.working && (t.kind === "new" || prev?.lane !== "deep");
15802
15873
  const now4 = this.o.now(), lastWord = this.lastWordAt !== null;
@@ -15876,19 +15947,15 @@ var VoiceCall = class {
15876
15947
  return;
15877
15948
  }
15878
15949
  c.lane = "quick";
15950
+ this.o.userLine(t.text, "quick");
15879
15951
  if (mv.kind === "quiet") {
15880
15952
  c.due = false;
15881
15953
  return this.close(c, "silent");
15882
15954
  }
15883
- const said = mv.kind === "resume" ? `${mv.line} ${rest}`.trim() : mv.line;
15955
+ 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;
15884
15956
  this.gate.replyStarted(c.id);
15885
15957
  if (!await this.sayRetry(said, "reply", c.id)) return this.close(c, "silent");
15886
15958
  this.o.show(said, "reply");
15887
- if (!c.worded) {
15888
- c.worded = true;
15889
- c.marks.mainAudio = this.lastAudibleAt;
15890
- this.o.onMetric({ name: "first_word", id: c.id, ms: Math.round(this.lastAudibleAt - c.at), by: "quick" });
15891
- }
15892
15959
  if (mv.kind === "resume") {
15893
15960
  this.cutRest = "";
15894
15961
  this.o.dropCut?.();
@@ -15898,6 +15965,20 @@ var VoiceCall = class {
15898
15965
  this.history.push({ who: "you", text: said });
15899
15966
  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.`);
15900
15967
  }
15968
+ if (this.o.hostAudio && !c.worded) {
15969
+ c.quickWord = true;
15970
+ return;
15971
+ }
15972
+ this.quickWorded(c, this.lastAudibleAt);
15973
+ }
15974
+ /** The quick lane's answer became audible at `at`: the turn's first word, and it is answered. */
15975
+ quickWorded(c, at) {
15976
+ c.quickWord = false;
15977
+ if (!c.worded) {
15978
+ c.worded = true;
15979
+ c.marks.mainAudio = at;
15980
+ this.o.onMetric({ name: "first_word", id: c.id, ms: Math.round(at - c.at), by: "quick" });
15981
+ }
15901
15982
  this.close(c, "answered");
15902
15983
  }
15903
15984
  /** say(), retried while the host's player is busy (up to 2s). */
@@ -15996,6 +16077,7 @@ var VoiceCall = class {
15996
16077
  const stop = /^\s*stop\s*:/i.test(raw), change = !answer || /^\s*work\s*:/i.test(raw);
15997
16078
  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.]`;
15998
16079
  this.history.push({ who: "user", text: t.text });
16080
+ if (!change) this.o.userLine(t.text, "aside");
15999
16081
  if (line && !this.ended) {
16000
16082
  await this.sayRetry(line, "aside", t.id);
16001
16083
  if (this.lastAudibleAt >= at) {
@@ -16056,6 +16138,12 @@ var VoiceCall = class {
16056
16138
  }
16057
16139
  }
16058
16140
  };
16141
+ function cutSentence(heard) {
16142
+ const tail = heard.trim().split(/(?<=[.!?…])\s+/).at(-1) ?? "";
16143
+ if (!tail || /[.!?…]["'”’)]*$/.test(tail)) return "";
16144
+ const w = tail.split(/\s+/);
16145
+ return w.length <= 6 ? tail : w.slice(-3).join(" ");
16146
+ }
16059
16147
 
16060
16148
  // src/index.ts
16061
16149
  init_llm();
@@ -17953,7 +18041,7 @@ var JsonlDiagSink = class {
17953
18041
  };
17954
18042
 
17955
18043
  // src/voice/spokenFilter.ts
17956
- var SPOKEN_TURN = "Your reply is spoken aloud: answer in one to three short plain sentences \u2014 no markdown, headings, lists, links or code, and no sources line even when a tool asks you to cite them (offer to send them if asked) \u2014 and offer more detail only if asked.";
18044
+ var SPOKEN_TURN = `Your reply is spoken aloud: answer in one to three short plain sentences \u2014 no markdown, headings, lists, links or code, and no sources line even when a tool asks you to cite them (offer to send them if asked) \u2014 and offer more detail only if asked. Say only facts from this turn's tool results or this call, and keep a list in its source's order: "top" or "first" is its rank 1.`;
17957
18045
  var HEADS = ["sources", "source", "references", "citations", "links"];
17958
18046
  var MARKS = String.raw`[#*_>\s-]*`;
17959
18047
  var SOURCES = new RegExp(String.raw`(^|\n|[.!?…]\s)${MARKS}(?:${HEADS.join("|")})${MARKS}[::]`, "i");
@@ -18044,20 +18132,39 @@ var SAY_WORDS = 30;
18044
18132
  var ACK_WORDS = 10;
18045
18133
  var ACKS = { en: ["On it.", "Sure, one sec.", "Okay, looking.", "Got it, checking."], he: ["\u05E8\u05D2\u05E2 \u05D0\u05D7\u05D3.", "\u05D0\u05D5\u05E7\u05D9\u05D9, \u05E9\u05E0\u05D9\u05D9\u05D4.", "\u05E9\u05E0\u05D9\u05D9\u05D4."] };
18046
18134
  function quickMove(raw, c) {
18135
+ const mv = rawMove(raw, c), owns = quickOwns(c.heard);
18136
+ if (owns === "reaction" && (!mv || mv.kind === "deep")) {
18137
+ const l = ownLine(ASIDES[c.lang]?.react, c);
18138
+ return l ? { kind: "say", line: l } : { kind: "quiet" };
18139
+ }
18140
+ if (isClosing(c.heard) && (!mv || mv.kind !== "say")) {
18141
+ const l = ownLine(BYES[c.lang], c);
18142
+ return l ? { kind: "say", line: l } : mv;
18143
+ }
18144
+ return mv;
18145
+ }
18146
+ var BYES = { en: ["Bye, talk soon!", "Take care, bye!"], he: ["\u05D1\u05D9\u05D9, \u05E0\u05D3\u05D1\u05E8!", "\u05DC\u05D4\u05EA\u05E8\u05D0\u05D5\u05EA!"] };
18147
+ var ownLine = (pool, c) => {
18148
+ const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
18149
+ return (pool ?? []).find((x) => !said.has(norm3(x))) ?? "";
18150
+ };
18151
+ function rawMove(raw, c) {
18047
18152
  const m = /^\s*(SAY|DEEP|RESUME|QUIET)\b\s*:?\s*(.*)$/im.exec(raw.trim());
18048
18153
  if (!m) return null;
18049
18154
  const kind = m[1].toUpperCase(), body = m[2].trim();
18155
+ const owns = quickOwns(c.heard);
18156
+ if (!owns && kind !== "DEEP") return { kind: "deep", ack: stockAck(c), brief: "" };
18050
18157
  if (kind === "QUIET") return { kind: "quiet" };
18051
18158
  if (kind === "RESUME") {
18052
18159
  const l = sayLine(body, c.lang);
18053
18160
  return !c.rest ? null : GO_ON.test(c.heard) ? { kind: "resume", line: l.split(/\s+/).length <= 5 ? l : "" } : { kind: "quiet" };
18054
18161
  }
18055
18162
  if (kind === "DEEP") {
18056
- const [ack = "", brief = ""] = body.split("|").map((s) => s.trim());
18163
+ const [ack = "", brief = ""] = body.split(body.includes("|") ? "|" : /\s+[—–-]\s+/).map((s) => s.trim());
18057
18164
  const a = cleanLine(ack, c.lang, ACK_WORDS);
18058
18165
  const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
18059
18166
  const ok = a && !said.has(norm3(a)) && !RESULT_CLAIM_RE.test(a) && !new RegExp("\\p{N}", "u").test(a);
18060
- return { kind: "deep", ack: ok ? a : (ACKS[c.lang] ?? []).find((x) => !said.has(norm3(x))) ?? "", brief };
18167
+ return { kind: "deep", ack: ok ? a : stockAck(c), brief };
18061
18168
  }
18062
18169
  const line = sayLine(body, c.lang);
18063
18170
  if (!line) return null;
@@ -18071,6 +18178,21 @@ function quickMove(raw, c) {
18071
18178
  }
18072
18179
  return { kind: "say", line };
18073
18180
  }
18181
+ var stockAck = (c) => ownLine(ACKS[c.lang], c);
18182
+ function quickOwns(heard) {
18183
+ const t = heard.replace(/\s*[—–]\s*/g, " ").trim(), n = norm3(t);
18184
+ if (!n) return null;
18185
+ if (HOLD.test(t)) return "hold";
18186
+ if (GO_ON.test(t) && t.split(/\s+/).length <= 5) return "goon";
18187
+ if (!/(?:^|\s)(?:what|מה)(?:\s|$)/u.test(n) && isReaction(t)) return "reaction";
18188
+ if (GREET.test(n) || SMALL_TALK.test(n)) return "greeting";
18189
+ if (isClosing(t) || turnIntent(t) === "closer") return "closer";
18190
+ if (RESTATE.test(n)) return "restate";
18191
+ return null;
18192
+ }
18193
+ var GREET = /^(?:(?:hi|hey|hello|hiya|yo|good (?:morning|afternoon|evening)|שלום|היי|הי|בוקר טוב|ערב טוב)(?:\s+there)?\s*)+(?:(?:how are you|how are you doing|how's it going|hows it going|how is it going|what's up|whats up|how have you been|מה שלומך|מה נשמע|מה קורה)(?:\s+today)?)?$|^(?:how are you|how are you doing|how's it going|hows it going|how is it going|what's up|whats up|how have you been|מה שלומך|מה נשמע|מה קורה)(?:\s+today)?$/u;
18194
+ var SMALL_TALK = /^(?:(?:oh|yeah|well|so)\s+)*(?:i'?m|im|i am)\s+(?:good|fine|great|ok|okay|alright|well|doing (?:good|well|great|fine|ok|okay))(?:\s+(?:thanks|thank you))?(?:\s+(?:and|how about)?\s*(?:you|yourself))?$/u;
18195
+ var RESTATE = /^(?:(?:sorry|wait|okay|ok|so|and)\s+)*(?:say (?:that|it) again|come again|repeat (?:that|it)|can you repeat (?:that|it)|what did you (?:just )?say|which one was (?:that|it)|what was (?:that|it) again|pardon)$/u;
18074
18196
  function sayLine(s, lang) {
18075
18197
  const l = s.split("\n")[0].replace(/^["'“”«»]+|["'“”«»]+$/g, "").trim();
18076
18198
  const d = detectLanguage(l);
@@ -18105,7 +18227,7 @@ function novelWords(line, c, within) {
18105
18227
  }
18106
18228
  var SOCIAL = new Set("thanks thank doing well good great fine help assist today glad sure right crazy wild sorry problem welcome talk later hear nice awesome pretty happy know okay cool stuff night morning evening love care chat again anything else there think sounds absolutely course totally really amazing exactly definitely listening ahead want need would could like going about what that this these those something someone tell more much maybe just wanna gonna kidding believe insane unreal huh yeah sounds fun hope busy pleasure great".split(" "));
18107
18229
  var GO_ON = new RegExp("(?<!\\p{L})(?:go on|go ahead|continue|keep going|carry on|you were saying|as you were|finish (?:that|it)|\u05D4\u05DE\u05E9\u05D9\u05DB\u05D9|\u05D4\u05DE\u05E9\u05DA|\u05EA\u05DE\u05E9\u05D9\u05DB\u05D9|\u05EA\u05DE\u05E9\u05D9\u05DA|\u05DB\u05DF,? \u05EA\u05DE\u05E9\u05D9\u05DB\u05D9)(?!\\p{L})", "iu");
18108
- var HOLD = /^(?:(?:okay|ok|oh|um|uh|so|sorry|no)[,.]?\s+)*(?:wait|hold on|hang on|one sec(?:ond)?|just a sec(?:ond)?|give me a sec(?:ond)?|רגע|שנייה|חכי|חכה)(?:[,.!]?\s*(?:wait|hold on|hang on|a sec(?:ond)?|please|רגע))*[.!?…]*$/iu;
18230
+ var HOLD = /^(?:(?:okay|ok|oh|um|uh|so|sorry|no)[,.]?\s+)*(?:wait|hold on|hang on|one sec(?:ond)?|just a sec(?:ond)?|give me a sec(?:ond)?|רגע|שנייה|חכי|חכה)(?:[,.!—–-]?\s*(?:wait|hold on|hang on|a sec(?:ond)?|please|רגע))*[.!?…—–-]*$/iu;
18109
18231
  var HOLDS = { en: ["Sure.", "Sure, take your time.", "No problem."], he: ["\u05D1\u05D8\u05D7.", "\u05D0\u05D9\u05DF \u05D1\u05E2\u05D9\u05D4."] };
18110
18232
  function holdLine(c) {
18111
18233
  if (!HOLD.test(c.heard.trim())) return "";
@@ -18149,7 +18271,7 @@ They just said: "${c.heard}"
18149
18271
  ` + (c.rest ? `Your last answer was cut. Its unsaid rest: "${c.rest.slice(0, 300)}"
18150
18272
  ` : "") + `
18151
18273
  Reply with exactly ONE line, one of:
18152
- SAY: <your words> \u2014 greetings, chit-chat, a short reaction, a clarification, or restating/explaining something ALREADY said in this call. Max two short sentences. Use only facts from the call above; never invent a name, number, news item or result.
18274
+ SAY: <your words> \u2014 ONLY a greeting or how-are-you, a short reaction ("wow", "really?"), a goodbye, 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.
18153
18275
  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 says you're on it ("Sure, checking Hacker News.") and never a result. The speech-to-text misspells names: fix them from context ("Haka News" \u2192 Hacker News).
18154
18276
  QUIET \u2014 nothing is owed: a bare "okay", "mm-hm", or a reaction you already answered.
18155
18277
  "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.
@@ -21500,6 +21622,7 @@ function parseArgs(argv) {
21500
21622
  } else if (x === "--lean") a.lean = true;
21501
21623
  else if (x === "--keep-alive") a.keepAlive = true;
21502
21624
  else if (x === "--channel-only") a.channelOnly = true;
21625
+ else if (x === "--quick-lane") a.quickLane = true;
21503
21626
  else if (x === "--channel-mode") a.channelMode = parseChannelMode(val(++i, x));
21504
21627
  else if (x === "--conversational" || x === "--convo" || x === "--voice") {
21505
21628
  a.voice = true;
@@ -21550,6 +21673,7 @@ function parseArgs(argv) {
21550
21673
  if (a.inputFormat && (!a.duplex && !a.print && !a.channelOnly || a.outputFormat !== "stream-json")) throw new Error("--input-format stream-json needs --output-format stream-json and --duplex (or --voice), --channel-only or -p");
21551
21674
  if (a.keepAlive && (!a.print || !a.inputFormat)) throw new Error("--keep-alive needs -p --input-format stream-json --output-format stream-json");
21552
21675
  if (a.channelOnly && !a.inputFormat) throw new Error("--channel-only needs --input-format stream-json --output-format stream-json");
21676
+ if (a.quickLane && !a.channelOnly) throw new Error("--quick-lane only applies with --channel-only (--call has it in live)");
21553
21677
  if (a.duplex && a.plan) throw new Error("--plan is not supported in --duplex (workers are non-interactive; a plan could never be approved)");
21554
21678
  if (a.voiceSystemPrompt && !a.duplex) throw new Error("--voice-system-prompt only applies with --duplex");
21555
21679
  if (a.voicePersona && !a.duplex && !a.channelOnly) throw new Error("--voice-persona only applies with --call or --channel-only");
@@ -21616,6 +21740,9 @@ Flags:
21616
21740
  enter the agent's history (headless: stdin interim/pause/agent_state, stdout channel)
21617
21741
  --channel-only headless (--input-format stream-json): ONLY the second channel, for a host whose main
21618
21742
  answer comes from elsewhere (stdin user/text/barge/interim/pause/agent_state, stdout channel)
21743
+ --quick-lane with --channel-only --channel-mode live: two lanes, as --call \u2014 the quick lane answers chit-chat
21744
+ and reactions itself and acks real work before MAIN's turn; the host takes {type:'note'} lines
21745
+ into MAIN's next turn and sends {type:'cut', full, heard} (README: Fill channel for host apps)
21619
21746
  --voice-persona <f> call persona from a file: replaces the default call style in MAIN's prompt and tells the live
21620
21747
  prediction tree who is speaking (--call / --channel-only; as Para's Settings > Call persona)
21621
21748
  --channel-mode <m> second-channel talkativeness: turn (only a bridge when the answer is slow) | normal
@@ -23194,6 +23321,12 @@ async function repl(args, ai, cfg, cwd) {
23194
23321
  `));
23195
23322
  editorRef?.redrawNow();
23196
23323
  },
23324
+ // every user line shows, not only the ones MAIN runs on (live 20261104-111333: quick-lane turns and kept "Oh, wow." were missing)
23325
+ userLine: (t, how) => {
23326
+ err(`\r\x1B[0J ${bold(cyan("\u{1F3A4} \u203A"))} ${t}${how === "kept" ? dim(" (over the reply)") : ""}
23327
+ `);
23328
+ editorRef?.redrawNow();
23329
+ },
23197
23330
  onMetric: (m) => voiceDiag?.push({ t: performance.now(), ...m, kind: `call_${m.name}`, ...m.kind ? { what: m.kind } : {} }),
23198
23331
  abortTurn: (id) => {
23199
23332
  if (callTurns.get(id)?.running) {
@@ -25404,7 +25537,7 @@ function overlapResponder(ai, mode, out, aside) {
25404
25537
  const judge = softBarge(mode) ? new OverlapJudge({ model: overlapModelFor(ai) }) : void 0;
25405
25538
  return (m) => {
25406
25539
  const text = String(m.text ?? "");
25407
- void (judge ? judge.judge(text) : Promise.resolve({ verdict: "cut", by: "mode", ms: 0 })).then((d) => {
25540
+ void (mode === "live" && isReaction(text) ? Promise.resolve({ verdict: "keep", by: "reaction", ms: 0 }) : judge ? judge.judge(text) : Promise.resolve({ verdict: "cut", by: "mode", ms: 0 })).then((d) => {
25408
25541
  const line = d.verdict === "keep" ? aside?.(text) : null;
25409
25542
  out({ type: "overlap", ...m.id !== void 0 ? { id: m.id } : {}, verdict: d.verdict, by: d.by, ms: d.ms, ...line ? { aside: line } : {} });
25410
25543
  });
@@ -25528,9 +25661,23 @@ async function duplexServe(args, ai, cfg, cwd) {
25528
25661
  async function channelServe(args, ai, cfg) {
25529
25662
  const out = (o) => process.stdout.write(JSON.stringify(o) + "\n");
25530
25663
  const { model, notes, options: fast } = callFast(args, ai, cfg);
25664
+ const quick = args.quickLane && args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0";
25665
+ let cut = null;
25531
25666
  const call = new VoiceCall({
25532
25667
  ...fast,
25533
25668
  // no `ai` here: the channel's model wiring is explicit
25669
+ ...quick ? {
25670
+ quick: fastQuickLane(ai, fast.fastModel, args.voiceGender, process.env.AGENTX_CALL_PERSONA ?? ""),
25671
+ noteTurn: (text) => out({ type: "note", text }),
25672
+ heardCut: () => cut?.heard ?? null,
25673
+ cutRest: () => cut && cut.full.slice(cut.heard.length).trim() || null,
25674
+ dropCut: () => {
25675
+ cut = null;
25676
+ out({ type: "resumed" });
25677
+ },
25678
+ // the rest was said: the host's cut note no longer holds
25679
+ userLine: (text, how) => out({ type: "user_line", text, how })
25680
+ } : {},
25534
25681
  channel: { ...fast.channel, onTree: (e) => out({ type: "metric", name: "tree", ms: e.ms, kind: `${e.tokens ? `${e.tokens.input}/${e.tokens.output} tok ` : ""}${e.error ?? (e.lines ?? []).join(" | ")}` }), onLeaf: (e) => out({ type: "metric", name: "leaf", ms: e.ms, kind: `${e.moment} ${e.conf} ${e.acted}`, text: e.text }) },
25535
25682
  speak: (line, kind) => {
25536
25683
  out(channelLine(line, kind));
@@ -25549,8 +25696,11 @@ async function channelServe(args, ai, cfg) {
25549
25696
  const overlap2 = overlapResponder(ai, args.channelMode, (o) => {
25550
25697
  if (o.verdict === "cut") call.barge();
25551
25698
  out(o);
25552
- }, (t) => call.aside(t));
25553
- out({ type: "ready", model, channelMode: args.channelMode, softBarge: softBarge(args.channelMode), call: true, ...notes.length ? { notes } : {} });
25699
+ }, (t) => {
25700
+ call.kept(t);
25701
+ return call.aside(t);
25702
+ });
25703
+ out({ type: "ready", model, channelMode: args.channelMode, softBarge: softBarge(args.channelMode), call: true, ...quick ? { quickLane: true } : {}, ...notes.length ? { notes } : {} });
25554
25704
  const rl = createInterface({ input: process.stdin });
25555
25705
  rl.on("line", (line) => {
25556
25706
  let m;
@@ -25564,7 +25714,10 @@ async function channelServe(args, ai, cfg) {
25564
25714
  if (typeof m.text === "string") call.interim(m.text, Date.now(), typeof m.aec === "boolean" ? m.aec : void 0);
25565
25715
  } else if (m.type === "final" && typeof m.text === "string") call.final(m.text, m.sttId === void 0 ? void 0 : String(m.sttId), { ...typeof m.lastWordAgoMs === "number" ? { lastWordAgoMs: m.lastWordAgoMs } : {}, ...typeof m.lang === "string" ? { lang: m.lang } : {} });
25566
25716
  else if (m.type === "heard" && ["fill", "progress", "main"].includes(m.by)) call.heard(m.by, typeof m.inMs === "number" ? m.inMs : 0);
25567
- else if (m.type === "main" && m.ev && typeof m.ev.type === "string") call.main(m.ev);
25717
+ else if (m.type === "cut") {
25718
+ const full = String(m.full ?? "").trim(), heard = String(m.heard ?? "").trim();
25719
+ cut = full && heard.length < full.length && full.startsWith(heard) ? { full, heard } : null;
25720
+ } else if (m.type === "main" && m.ev && typeof m.ev.type === "string") call.main(m.ev);
25568
25721
  else if (m.type === "barge") call.barge();
25569
25722
  else if (channelInput(call.fill, m)) return;
25570
25723
  else if (m.type === "user" && typeof m.text === "string") call.hostTurn(m.text);