@livx.cc/agentx 0.99.154 → 0.99.156
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 +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +278 -43
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.js +141 -23
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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) =>
|
|
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;
|
|
@@ -14406,9 +14431,17 @@ var ProgressOptions = class {
|
|
|
14406
14431
|
now = () => performance.now();
|
|
14407
14432
|
};
|
|
14408
14433
|
function argsHint(args) {
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14434
|
+
const s = !args || typeof args !== "object" ? args : Object.values(args).find((v) => typeof v === "string" && v.trim());
|
|
14435
|
+
return typeof s === "string" ? urlWords(s.trim()).replace(/\s+/g, " ").slice(0, 40).trim() : "";
|
|
14436
|
+
}
|
|
14437
|
+
function urlWords(s) {
|
|
14438
|
+
if (!/^https?:\/\/\S+$/i.test(s)) return s;
|
|
14439
|
+
try {
|
|
14440
|
+
const u = new URL(s), host = u.hostname.replace(/^www\./, "").split(".").slice(0, -1).filter((p) => p.length > 2);
|
|
14441
|
+
return [...host, ...decodeURIComponent(u.pathname).split(/[/._-]+/)].filter((w) => new RegExp("\\p{L}{2}", "u").test(w) && !/^(?:html?|php|aspx?|index)$/i.test(w)).join(" ");
|
|
14442
|
+
} catch {
|
|
14443
|
+
return s;
|
|
14444
|
+
}
|
|
14412
14445
|
}
|
|
14413
14446
|
var Progress = class {
|
|
14414
14447
|
constructor(options) {
|
|
@@ -14491,13 +14524,17 @@ var Progress = class {
|
|
|
14491
14524
|
return null;
|
|
14492
14525
|
}), late]).finally(() => clearTimeout(t));
|
|
14493
14526
|
const l = cleanLine(raw ?? "", lang, 5);
|
|
14494
|
-
|
|
14527
|
+
const why = raw === null ? "late or failed" : !l ? `unusable "${raw}"` : about && !echoesHeard(l, `${hint} ${about}`) ? `names nothing of "${hint}": "${l}"` : RESULT_CLAIM_RE.test(l) || HE_RESULT_CLAIM.test(l) ? `claims a result: "${l}"` : this.said.has(norm3(l)) ? `repeat: "${l}"` : this.streamed ? "reply streamed" : "";
|
|
14528
|
+
if (why) {
|
|
14529
|
+
log29.debug(`no line for ${tool || "(no tool)"}: ${why}`);
|
|
14530
|
+
return "";
|
|
14531
|
+
}
|
|
14495
14532
|
return l;
|
|
14496
14533
|
}
|
|
14497
14534
|
};
|
|
14498
14535
|
function fastProgressGenerator(ai, model, gender) {
|
|
14499
14536
|
return async (tool, hint, lang, signal, avoid = []) => {
|
|
14500
|
-
const prompt = `An assistant on a live voice call is running the tool "${tool}"${hint ? ` (about: "${hint}")` : ""}. Write ONE spoken line of 2-5 words, in ${languageName(lang)}, saying what it is doing right now (like "checking the board\u2026"). ${hint ? 'Name what it works on the way a person would say it ("looking up that Astra post\u2026"), never a string of its keywords ("scanning Astra weights\u2026"). ' : ""}${avoid.length ? `It already said ${avoid.map((a) => `"${a}"`).join(", ")}: say something new, a different angle on the same work. ` : ""}Never state a result or a finding. ${personaHint(gender)} Output only the line.`;
|
|
14537
|
+
const prompt = `An assistant on a live voice call is ${tool ? `running the tool "${tool}"` : "working on a request"}${hint ? ` (about: "${hint}")` : ""}. Write ONE spoken line of 2-5 words, in ${languageName(lang)}, saying what it is doing right now (like "checking the board\u2026"). ${hint ? 'Name what it works on the way a person would say it ("looking up that Astra post\u2026"), never a string of its keywords ("scanning Astra weights\u2026"). ' : ""}${avoid.length ? `It already said ${avoid.map((a) => `"${a}"`).join(", ")}: say something new, a different angle on the same work. ` : ""}Never state a result or a finding. ${personaHint(gender)} Output only the line.`;
|
|
14501
14538
|
return fastText(ai, { model, prompt, signal });
|
|
14502
14539
|
};
|
|
14503
14540
|
}
|
|
@@ -15453,6 +15490,9 @@ var VoiceCallOptions = class {
|
|
|
15453
15490
|
/** Live: the quick lane (fastQuickLane) owns the conversation — each turn it answers, acks + hands to MAIN, resumes a
|
|
15454
15491
|
* cut answer, or stays quiet. Absent (or another mode): every turn goes to MAIN as before. */
|
|
15455
15492
|
quick;
|
|
15493
|
+
/** The quick lane said a farewell to someone ending the call (QuickMove `end`): the host hangs up once that line has
|
|
15494
|
+
* played (as Para's [[hangup]] marker does for MAIN). The call takes no more turns after it. */
|
|
15495
|
+
hangUp;
|
|
15456
15496
|
/** Past this the turn goes to MAIN as before (the bridge covers it). */
|
|
15457
15497
|
quickBudgetMs = 1800;
|
|
15458
15498
|
/** The unsaid rest of MAIN's reply a barge just cut (a peek, like heardCut), else null — what a resume says. */
|
|
@@ -15467,6 +15507,10 @@ var VoiceCallOptions = class {
|
|
|
15467
15507
|
/** Host caption — never history. */
|
|
15468
15508
|
show = () => {
|
|
15469
15509
|
};
|
|
15510
|
+
/** The user's words that start no MAIN turn — the host's transcript shows them (sendTurn shows the rest): `quick` = a
|
|
15511
|
+
* turn the quick lane answered, `aside` = said while MAIN worked, `kept` = a soft barge-in kept over the reply. */
|
|
15512
|
+
userLine = () => {
|
|
15513
|
+
};
|
|
15470
15514
|
/** The fast model (lines, banks, progress) — used only with `ai`. */
|
|
15471
15515
|
fastModel = latestClaude("haiku");
|
|
15472
15516
|
/** Model client for the fast model + the channel decider / overlap judge. Absent → canned lines and rules only. */
|
|
@@ -15534,7 +15578,9 @@ var VoiceCall = class {
|
|
|
15534
15578
|
cancel: () => o.cancel(),
|
|
15535
15579
|
now: o.now
|
|
15536
15580
|
});
|
|
15537
|
-
|
|
15581
|
+
const po = { ...o.mode === "live" ? { templates: {}, generateBudgetMs: 1500, gapMs: 5e3 } : {}, ...ai ? { generate: fastProgressGenerator(ai, o.fastModel, o.gender) } : {}, gender: o.gender, now: o.now, ...o.progress };
|
|
15582
|
+
if (o.mode === "live") po.stageRepeatMs ??= po.gapMs;
|
|
15583
|
+
this.progress = new Progress(po);
|
|
15538
15584
|
this.judge = new OverlapJudge({ ...ai ? { model: overlapModelFor(ai) } : {}, now: o.now });
|
|
15539
15585
|
this.gate = new TurnGate({
|
|
15540
15586
|
now: o.now,
|
|
@@ -15634,6 +15680,13 @@ var VoiceCall = class {
|
|
|
15634
15680
|
if (this.ended) return;
|
|
15635
15681
|
if (by === "main") return this.main({ type: "audio", ...this.cur ? { id: this.cur.id } : {} }, inMs);
|
|
15636
15682
|
const at = this.o.now() + Math.max(0, inMs);
|
|
15683
|
+
const q2 = this.cur;
|
|
15684
|
+
if (q2?.quickWord && !q2.closed) {
|
|
15685
|
+
this.lastAudibleAt = at;
|
|
15686
|
+
q2.marks.fillAudio ??= at;
|
|
15687
|
+
this.sounded(q2, "quick", at);
|
|
15688
|
+
return this.quickWorded(q2, at);
|
|
15689
|
+
}
|
|
15637
15690
|
if (this.gate.holding || !this.cur || this.cur.closed) {
|
|
15638
15691
|
this.earlyHeard ??= { at, by };
|
|
15639
15692
|
return;
|
|
@@ -15749,11 +15802,44 @@ var VoiceCall = class {
|
|
|
15749
15802
|
}
|
|
15750
15803
|
/** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
|
|
15751
15804
|
async overlap(text) {
|
|
15752
|
-
if (this.o.mode === "live" && isReaction(text)) return "keep";
|
|
15805
|
+
if (this.o.mode === "live" && isReaction(text)) return this.kept(text), "keep";
|
|
15753
15806
|
const d = await this.judge.judge(text);
|
|
15754
15807
|
if (d.verdict === "cut") this.barge();
|
|
15808
|
+
else if (d.verdict === "keep") this.kept(text);
|
|
15755
15809
|
return d.verdict;
|
|
15756
15810
|
}
|
|
15811
|
+
/** An overlap kept over the reply (no turn): the transcript and the quick lane's history still hold their words — once,
|
|
15812
|
+
* in full: the host asks about every growing partial ("Oh," "Oh, wow" "Oh, wow—really?"; Para replay showed all four). */
|
|
15813
|
+
kept(text) {
|
|
15814
|
+
if (!norm3(text)) return;
|
|
15815
|
+
const p = this.keptLine, a = norm3(text).replace(/ /g, ""), b = p ? norm3(p.text).replace(/ /g, "") : "";
|
|
15816
|
+
if (p && (a.startsWith(b) || b.startsWith(a))) {
|
|
15817
|
+
if (a.length > b.length) {
|
|
15818
|
+
p.text = text;
|
|
15819
|
+
if (p.line) p.line.text = text;
|
|
15820
|
+
}
|
|
15821
|
+
clearTimeout(p.timer);
|
|
15822
|
+
} else {
|
|
15823
|
+
this.flushKept();
|
|
15824
|
+
const line = this.quickOn ? { who: "user", text } : void 0;
|
|
15825
|
+
if (line) this.history.push(line);
|
|
15826
|
+
this.keptLine = { text, timer: void 0, line };
|
|
15827
|
+
}
|
|
15828
|
+
this.keptLine.timer = setTimeout(() => this.flushKept(), isReaction(this.keptLine.text) ? 1500 : 4e3);
|
|
15829
|
+
}
|
|
15830
|
+
keptLine;
|
|
15831
|
+
/** The kept words go to the transcript; `turn` = the words a new turn starts with (they grew into it: no line of their own). */
|
|
15832
|
+
flushKept(turn = "") {
|
|
15833
|
+
const p = this.keptLine;
|
|
15834
|
+
if (!p) return;
|
|
15835
|
+
this.keptLine = void 0;
|
|
15836
|
+
clearTimeout(p.timer);
|
|
15837
|
+
if (turn && norm3(turn).replace(/ /g, "").startsWith(norm3(p.text).replace(/ /g, ""))) {
|
|
15838
|
+
if (p.line) this.history.splice(this.history.indexOf(p.line), 1);
|
|
15839
|
+
return;
|
|
15840
|
+
}
|
|
15841
|
+
this.o.userLine(p.text, "kept");
|
|
15842
|
+
}
|
|
15757
15843
|
/** The fill channel's spoken aside for an overlap judged 'keep' ("yeah" → "Oh yeah, definitely."): the host plays it
|
|
15758
15844
|
* while the reply is held, then resumes the same reply (bod-voice decideOverlap's aside). ≤4 canned words, never a
|
|
15759
15845
|
* 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 +15850,7 @@ var VoiceCall = class {
|
|
|
15764
15850
|
const line = overlapAside(text, this.lang, this.lastAside.text, void 0, this.o.mode === "live");
|
|
15765
15851
|
if (!line) return null;
|
|
15766
15852
|
this.lastAside = { text: line, at: now4 };
|
|
15767
|
-
if (this.quickOn) this.history.push({ who: "
|
|
15853
|
+
if (this.quickOn) this.history.push({ who: "you", text: line });
|
|
15768
15854
|
this.o.onMetric({ name: "fill", kind: "aside", text: line, lang: this.lang });
|
|
15769
15855
|
return line;
|
|
15770
15856
|
}
|
|
@@ -15777,6 +15863,7 @@ var VoiceCall = class {
|
|
|
15777
15863
|
return this.fill.drain();
|
|
15778
15864
|
}
|
|
15779
15865
|
end() {
|
|
15866
|
+
this.flushKept();
|
|
15780
15867
|
if (this.cur) this.close(this.cur);
|
|
15781
15868
|
this.ended = true;
|
|
15782
15869
|
this.gate.end();
|
|
@@ -15797,6 +15884,7 @@ var VoiceCall = class {
|
|
|
15797
15884
|
}
|
|
15798
15885
|
onTurn(t) {
|
|
15799
15886
|
this.floor = "";
|
|
15887
|
+
this.flushKept(t.text);
|
|
15800
15888
|
if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
|
|
15801
15889
|
const prev = this.cur, quick = this.quickOn && !this.working && (t.kind === "new" || prev?.lane !== "deep");
|
|
15802
15890
|
const now4 = this.o.now(), lastWord = this.lastWordAt !== null;
|
|
@@ -15876,19 +15964,17 @@ var VoiceCall = class {
|
|
|
15876
15964
|
return;
|
|
15877
15965
|
}
|
|
15878
15966
|
c.lane = "quick";
|
|
15967
|
+
this.o.userLine(t.text, "quick");
|
|
15879
15968
|
if (mv.kind === "quiet") {
|
|
15880
15969
|
c.due = false;
|
|
15881
15970
|
return this.close(c, "silent");
|
|
15882
15971
|
}
|
|
15883
|
-
const said = mv.kind === "resume" ? `${mv.line} ${rest}`.trim() : mv.line;
|
|
15972
|
+
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
15973
|
this.gate.replyStarted(c.id);
|
|
15885
|
-
|
|
15886
|
-
this.
|
|
15887
|
-
if (!c
|
|
15888
|
-
|
|
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
|
-
}
|
|
15974
|
+
const end = mv.kind === "say" && !!mv.end;
|
|
15975
|
+
const played = await this.sayRetry(said, "reply", c.id, end ? 240 : 8);
|
|
15976
|
+
if (!played && !end) return this.close(c, "silent");
|
|
15977
|
+
if (played) this.o.show(said, "reply");
|
|
15892
15978
|
if (mv.kind === "resume") {
|
|
15893
15979
|
this.cutRest = "";
|
|
15894
15980
|
this.o.dropCut?.();
|
|
@@ -15898,11 +15984,36 @@ var VoiceCall = class {
|
|
|
15898
15984
|
this.history.push({ who: "you", text: said });
|
|
15899
15985
|
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
15986
|
}
|
|
15987
|
+
if (end) {
|
|
15988
|
+
this.o.onMetric({ name: "hangup", id: c.id, text: said });
|
|
15989
|
+
if (played && (!this.o.hostAudio || c.worded)) this.quickWorded(c, this.lastAudibleAt);
|
|
15990
|
+
this.end();
|
|
15991
|
+
try {
|
|
15992
|
+
this.o.hangUp?.();
|
|
15993
|
+
} catch (e) {
|
|
15994
|
+
log31.warn(`hangUp threw: ${e.message}`);
|
|
15995
|
+
}
|
|
15996
|
+
return;
|
|
15997
|
+
}
|
|
15998
|
+
if (this.o.hostAudio && !c.worded) {
|
|
15999
|
+
c.quickWord = true;
|
|
16000
|
+
return;
|
|
16001
|
+
}
|
|
16002
|
+
this.quickWorded(c, this.lastAudibleAt);
|
|
16003
|
+
}
|
|
16004
|
+
/** The quick lane's answer became audible at `at`: the turn's first word, and it is answered. */
|
|
16005
|
+
quickWorded(c, at) {
|
|
16006
|
+
c.quickWord = false;
|
|
16007
|
+
if (!c.worded) {
|
|
16008
|
+
c.worded = true;
|
|
16009
|
+
c.marks.mainAudio = at;
|
|
16010
|
+
this.o.onMetric({ name: "first_word", id: c.id, ms: Math.round(at - c.at), by: "quick" });
|
|
16011
|
+
}
|
|
15901
16012
|
this.close(c, "answered");
|
|
15902
16013
|
}
|
|
15903
|
-
/** say(), retried while the host's player is busy (
|
|
15904
|
-
async sayRetry(line, kind, id) {
|
|
15905
|
-
for (let i = 0; i <
|
|
16014
|
+
/** say(), retried while the host's player is busy (`tries` × 250ms: 2s). */
|
|
16015
|
+
async sayRetry(line, kind, id, tries = 8) {
|
|
16016
|
+
for (let i = 0; i < tries; i++) {
|
|
15906
16017
|
if (this.ended) return false;
|
|
15907
16018
|
if (this.say(line, kind) !== false) return true;
|
|
15908
16019
|
await new Promise((r) => setTimeout(r, 250));
|
|
@@ -15996,6 +16107,7 @@ var VoiceCall = class {
|
|
|
15996
16107
|
const stop = /^\s*stop\s*:/i.test(raw), change = !answer || /^\s*work\s*:/i.test(raw);
|
|
15997
16108
|
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
16109
|
this.history.push({ who: "user", text: t.text });
|
|
16110
|
+
if (!change) this.o.userLine(t.text, "aside");
|
|
15999
16111
|
if (line && !this.ended) {
|
|
16000
16112
|
await this.sayRetry(line, "aside", t.id);
|
|
16001
16113
|
if (this.lastAudibleAt >= at) {
|
|
@@ -16056,6 +16168,12 @@ var VoiceCall = class {
|
|
|
16056
16168
|
}
|
|
16057
16169
|
}
|
|
16058
16170
|
};
|
|
16171
|
+
function cutSentence(heard) {
|
|
16172
|
+
const tail = heard.trim().split(/(?<=[.!?…])\s+/).at(-1) ?? "";
|
|
16173
|
+
if (!tail || /[.!?…]["'”’)]*$/.test(tail)) return "";
|
|
16174
|
+
const w = tail.split(/\s+/);
|
|
16175
|
+
return w.length <= 6 ? tail : w.slice(-3).join(" ");
|
|
16176
|
+
}
|
|
16059
16177
|
|
|
16060
16178
|
// src/index.ts
|
|
16061
16179
|
init_llm();
|
|
@@ -17953,7 +18071,36 @@ var JsonlDiagSink = class {
|
|
|
17953
18071
|
};
|
|
17954
18072
|
|
|
17955
18073
|
// src/voice/spokenFilter.ts
|
|
17956
|
-
var SPOKEN_TURN =
|
|
18074
|
+
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.`;
|
|
18075
|
+
var HANGUP = "[[hangup]]";
|
|
18076
|
+
var CALL_HANGUP = `When the user means to end the call \u2014 in any words or language: a goodbye ("okay, bye", "talk later"), or that they're done ("that's all, thanks") \u2014 say one short farewell and finish that reply with ${HANGUP}: the call hangs up once it has played. Judge the intent, not the word: "say bye to Dan" or "before I go, one more thing" keep the call. Never write ${HANGUP} otherwise.`;
|
|
18077
|
+
function markerStrip(marker) {
|
|
18078
|
+
let held2 = "", hit = false;
|
|
18079
|
+
return {
|
|
18080
|
+
get hit() {
|
|
18081
|
+
return hit;
|
|
18082
|
+
},
|
|
18083
|
+
push(t) {
|
|
18084
|
+
let s = held2 + t;
|
|
18085
|
+
held2 = "";
|
|
18086
|
+
for (let i; (i = s.indexOf(marker)) >= 0; ) {
|
|
18087
|
+
hit = true;
|
|
18088
|
+
s = s.slice(0, i) + s.slice(i + marker.length);
|
|
18089
|
+
}
|
|
18090
|
+
for (let k = Math.min(marker.length - 1, s.length); k > 0; k--) if (marker.startsWith(s.slice(-k))) {
|
|
18091
|
+
held2 = s.slice(-k);
|
|
18092
|
+
s = s.slice(0, -k);
|
|
18093
|
+
break;
|
|
18094
|
+
}
|
|
18095
|
+
return s;
|
|
18096
|
+
},
|
|
18097
|
+
flush() {
|
|
18098
|
+
const s = held2;
|
|
18099
|
+
held2 = "";
|
|
18100
|
+
return s;
|
|
18101
|
+
}
|
|
18102
|
+
};
|
|
18103
|
+
}
|
|
17957
18104
|
var HEADS = ["sources", "source", "references", "citations", "links"];
|
|
17958
18105
|
var MARKS = String.raw`[#*_>\s-]*`;
|
|
17959
18106
|
var SOURCES = new RegExp(String.raw`(^|\n|[.!?…]\s)${MARKS}(?:${HEADS.join("|")})${MARKS}[::]`, "i");
|
|
@@ -18042,35 +18189,69 @@ init_logging();
|
|
|
18042
18189
|
var log39 = forComponent("QuickLane");
|
|
18043
18190
|
var SAY_WORDS = 30;
|
|
18044
18191
|
var ACK_WORDS = 10;
|
|
18045
|
-
var ACKS = { en: ["On it.", "Sure, one sec.", "Okay
|
|
18192
|
+
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."] };
|
|
18046
18193
|
function quickMove(raw, c) {
|
|
18047
|
-
const
|
|
18194
|
+
const mv = rawMove(raw, c), owns = quickOwns(c.heard);
|
|
18195
|
+
if (owns === "reaction" && (!mv || mv.kind === "deep")) {
|
|
18196
|
+
const l = ownLine(ASIDES[c.lang]?.react, c);
|
|
18197
|
+
return l ? { kind: "say", line: l } : { kind: "quiet" };
|
|
18198
|
+
}
|
|
18199
|
+
if (isClosing(c.heard) && (!mv || mv.kind === "quiet")) {
|
|
18200
|
+
const l = ownLine(BYES[c.lang], c);
|
|
18201
|
+
return l ? { kind: "say", line: l } : mv;
|
|
18202
|
+
}
|
|
18203
|
+
return mv;
|
|
18204
|
+
}
|
|
18205
|
+
var BYES = { en: ["Bye, talk soon!", "Take care, bye!"], he: ["\u05D1\u05D9\u05D9, \u05E0\u05D3\u05D1\u05E8!", "\u05DC\u05D4\u05EA\u05E8\u05D0\u05D5\u05EA!"] };
|
|
18206
|
+
var ownLine = (pool, c) => {
|
|
18207
|
+
const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
|
|
18208
|
+
return (pool ?? []).find((x) => !said.has(norm3(x))) ?? "";
|
|
18209
|
+
};
|
|
18210
|
+
function rawMove(raw, c) {
|
|
18211
|
+
const m = /^\s*(SAY|BYE|DEEP|RESUME|QUIET)\b\s*:?\s*(.*)$/im.exec(raw.trim());
|
|
18048
18212
|
if (!m) return null;
|
|
18049
|
-
const kind = m[1].toUpperCase(), body = m[2].trim();
|
|
18213
|
+
const bye = m[1].toUpperCase() === "BYE", kind = bye ? "SAY" : m[1].toUpperCase(), body = m[2].trim();
|
|
18214
|
+
const owns = quickOwns(c.heard);
|
|
18215
|
+
if (!owns && kind !== "DEEP") return { kind: "deep", ack: stockAck(c), brief: "" };
|
|
18050
18216
|
if (kind === "QUIET") return { kind: "quiet" };
|
|
18051
18217
|
if (kind === "RESUME") {
|
|
18052
18218
|
const l = sayLine(body, c.lang);
|
|
18053
18219
|
return !c.rest ? null : GO_ON.test(c.heard) ? { kind: "resume", line: l.split(/\s+/).length <= 5 ? l : "" } : { kind: "quiet" };
|
|
18054
18220
|
}
|
|
18055
18221
|
if (kind === "DEEP") {
|
|
18056
|
-
const [ack = "", brief = ""] = body.split("|").map((s) => s.trim());
|
|
18057
|
-
const a = cleanLine(ack, c.lang, ACK_WORDS);
|
|
18222
|
+
const [ack = "", brief = ""] = body.split(body.includes("|") ? "|" : /\s+[—–-]\s+/).map((s) => s.trim());
|
|
18223
|
+
const a = cleanLine(ack, c.lang, ACK_WORDS).replace(/[\s,;:—–-]+$/u, "");
|
|
18058
18224
|
const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
|
|
18059
18225
|
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 : (
|
|
18226
|
+
return { kind: "deep", ack: ok ? a : stockAck(c), brief };
|
|
18061
18227
|
}
|
|
18062
18228
|
const line = sayLine(body, c.lang);
|
|
18063
18229
|
if (!line) return null;
|
|
18064
|
-
if (parrots(line, c.heard)) return { kind: "quiet" };
|
|
18065
|
-
if (c.history.some((h) => h.who === "you" && norm3(h.text) === norm3(line))) return { kind: "quiet" };
|
|
18230
|
+
if (!bye && parrots(line, c.heard)) return { kind: "quiet" };
|
|
18231
|
+
if (!bye && c.history.some((h) => h.who === "you" && norm3(h.text) === norm3(line))) return { kind: "quiet" };
|
|
18066
18232
|
const facts = unknownFacts(line, c), novel = novelWords(line, c);
|
|
18067
18233
|
const unknown = facts.length || novel.length >= 2 ? [...facts, ...novel] : [];
|
|
18068
18234
|
if (unknown.length) {
|
|
18069
18235
|
log39.debug(`quick line "${line}" names ${unknown.join(", ")} \u2014 not in the call: deep lane`);
|
|
18070
18236
|
return { kind: "deep", ack: "", brief: "" };
|
|
18071
18237
|
}
|
|
18072
|
-
return { kind: "say", line };
|
|
18238
|
+
return bye && isClosing(c.heard) ? { kind: "say", line, end: true } : { kind: "say", line };
|
|
18239
|
+
}
|
|
18240
|
+
var stockAck = (c) => ownLine(ACKS[c.lang], c);
|
|
18241
|
+
function quickOwns(heard) {
|
|
18242
|
+
const t = heard.replace(/\s*[—–]\s*/g, " ").trim(), n = norm3(t);
|
|
18243
|
+
if (!n) return null;
|
|
18244
|
+
if (HOLD.test(t)) return "hold";
|
|
18245
|
+
if (GO_ON.test(t) && t.split(/\s+/).length <= 5) return "goon";
|
|
18246
|
+
if (!/(?:^|\s)(?:what|מה)(?:\s|$)/u.test(n) && isReaction(t)) return "reaction";
|
|
18247
|
+
if (GREET.test(n) || SMALL_TALK.test(n)) return "greeting";
|
|
18248
|
+
if (isClosing(t) || turnIntent(t) === "closer") return "closer";
|
|
18249
|
+
if (RESTATE.test(n)) return "restate";
|
|
18250
|
+
return null;
|
|
18073
18251
|
}
|
|
18252
|
+
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;
|
|
18253
|
+
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;
|
|
18254
|
+
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
18255
|
function sayLine(s, lang) {
|
|
18075
18256
|
const l = s.split("\n")[0].replace(/^["'“”«»]+|["'“”«»]+$/g, "").trim();
|
|
18076
18257
|
const d = detectLanguage(l);
|
|
@@ -18105,7 +18286,7 @@ function novelWords(line, c, within) {
|
|
|
18105
18286
|
}
|
|
18106
18287
|
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
18288
|
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)?|רגע|שנייה|חכי|חכה)(?:[
|
|
18289
|
+
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
18290
|
var HOLDS = { en: ["Sure.", "Sure, take your time.", "No problem."], he: ["\u05D1\u05D8\u05D7.", "\u05D0\u05D9\u05DF \u05D1\u05E2\u05D9\u05D4."] };
|
|
18110
18291
|
function holdLine(c) {
|
|
18111
18292
|
if (!HOLD.test(c.heard.trim())) return "";
|
|
@@ -18149,8 +18330,9 @@ They just said: "${c.heard}"
|
|
|
18149
18330
|
` + (c.rest ? `Your last answer was cut. Its unsaid rest: "${c.rest.slice(0, 300)}"
|
|
18150
18331
|
` : "") + `
|
|
18151
18332
|
Reply with exactly ONE line, one of:
|
|
18152
|
-
|
|
18153
|
-
|
|
18333
|
+
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.
|
|
18334
|
+
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.
|
|
18335
|
+
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: a lookup says you're on it and names what you'll look at ("Sure, let me pull up the kitty changelog."); 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).
|
|
18154
18336
|
QUIET \u2014 nothing is owed: a bare "okay", "mm-hm", or a reaction you already answered.
|
|
18155
18337
|
"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.
|
|
18156
18338
|
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.`;
|
|
@@ -21500,6 +21682,7 @@ function parseArgs(argv) {
|
|
|
21500
21682
|
} else if (x === "--lean") a.lean = true;
|
|
21501
21683
|
else if (x === "--keep-alive") a.keepAlive = true;
|
|
21502
21684
|
else if (x === "--channel-only") a.channelOnly = true;
|
|
21685
|
+
else if (x === "--quick-lane") a.quickLane = true;
|
|
21503
21686
|
else if (x === "--channel-mode") a.channelMode = parseChannelMode(val(++i, x));
|
|
21504
21687
|
else if (x === "--conversational" || x === "--convo" || x === "--voice") {
|
|
21505
21688
|
a.voice = true;
|
|
@@ -21550,6 +21733,7 @@ function parseArgs(argv) {
|
|
|
21550
21733
|
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
21734
|
if (a.keepAlive && (!a.print || !a.inputFormat)) throw new Error("--keep-alive needs -p --input-format stream-json --output-format stream-json");
|
|
21552
21735
|
if (a.channelOnly && !a.inputFormat) throw new Error("--channel-only needs --input-format stream-json --output-format stream-json");
|
|
21736
|
+
if (a.quickLane && !a.channelOnly) throw new Error("--quick-lane only applies with --channel-only (--call has it in live)");
|
|
21553
21737
|
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
21738
|
if (a.voiceSystemPrompt && !a.duplex) throw new Error("--voice-system-prompt only applies with --duplex");
|
|
21555
21739
|
if (a.voicePersona && !a.duplex && !a.channelOnly) throw new Error("--voice-persona only applies with --call or --channel-only");
|
|
@@ -21616,6 +21800,9 @@ Flags:
|
|
|
21616
21800
|
enter the agent's history (headless: stdin interim/pause/agent_state, stdout channel)
|
|
21617
21801
|
--channel-only headless (--input-format stream-json): ONLY the second channel, for a host whose main
|
|
21618
21802
|
answer comes from elsewhere (stdin user/text/barge/interim/pause/agent_state, stdout channel)
|
|
21803
|
+
--quick-lane with --channel-only --channel-mode live: two lanes, as --call \u2014 the quick lane answers chit-chat
|
|
21804
|
+
and reactions itself and acks real work before MAIN's turn; the host takes {type:'note'} lines
|
|
21805
|
+
into MAIN's next turn and sends {type:'cut', full, heard} (README: Fill channel for host apps)
|
|
21619
21806
|
--voice-persona <f> call persona from a file: replaces the default call style in MAIN's prompt and tells the live
|
|
21620
21807
|
prediction tree who is speaking (--call / --channel-only; as Para's Settings > Call persona)
|
|
21621
21808
|
--channel-mode <m> second-channel talkativeness: turn (only a bridge when the answer is slow) | normal
|
|
@@ -23172,12 +23359,25 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
23172
23359
|
let callFastModel = "";
|
|
23173
23360
|
let callReplyOpen = false;
|
|
23174
23361
|
let spoken = new SpokenFilter();
|
|
23362
|
+
let hang = markerStrip(HANGUP);
|
|
23363
|
+
const hangUpCall = () => {
|
|
23364
|
+
voiceDiag?.push({ t: performance.now(), kind: "call_hangup" });
|
|
23365
|
+
call?.end();
|
|
23366
|
+
void (async () => {
|
|
23367
|
+
for (let i = 0; i < 60 && voiceIO; i++) {
|
|
23368
|
+
await voiceIO.awaitIdle();
|
|
23369
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
23370
|
+
if (!voiceIO?.audible && !(voiceIO?.player?.drainMs() ?? 0)) break;
|
|
23371
|
+
}
|
|
23372
|
+
editorRef?.abort();
|
|
23373
|
+
})();
|
|
23374
|
+
};
|
|
23175
23375
|
let greetNote = "";
|
|
23176
23376
|
const callTurns = /* @__PURE__ */ new Map();
|
|
23177
23377
|
const callTools = /* @__PURE__ */ new Set();
|
|
23178
23378
|
if (args.call) {
|
|
23179
23379
|
if (args.voice || args.voicePersona) agent.options.systemPrompt += "\n\n" + (args.voicePersona ?? CALL_PROMPT);
|
|
23180
|
-
agent.options.systemPrompt += "\n\n" + CALL_WEB_PROMPT;
|
|
23380
|
+
agent.options.systemPrompt += "\n\n" + CALL_WEB_PROMPT + "\n\n" + CALL_HANGUP;
|
|
23181
23381
|
if (args.voiceSystemPrompt) agent.options.systemPrompt += "\n\n" + args.voiceSystemPrompt;
|
|
23182
23382
|
const fast = callFast(args, ai, cfg);
|
|
23183
23383
|
for (const n of fast.notes) err(yellow(` \u26A0 ${n}
|
|
@@ -23189,11 +23389,19 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
23189
23389
|
// live: the quick lane owns the conversation, MAIN is its deep lane (#1331). Only here: its lines reach MAIN through
|
|
23190
23390
|
// noteTurn, which a --channel-only host (Para) does not take yet.
|
|
23191
23391
|
...args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0" ? { quick: fastQuickLane(ai, fast.options.fastModel, args.voiceGender, args.voicePersona) } : {},
|
|
23392
|
+
// the quick lane's farewell to a goodbye ends the call, as an ExitSession 'quit' does: the line plays out, then exit
|
|
23393
|
+
hangUp: hangUpCall,
|
|
23192
23394
|
show: (t, kind) => {
|
|
23193
23395
|
err("\r\x1B[0J" + dim(` \u21B3 ${kind === "progress" ? "\u22EF " : ""}${t}
|
|
23194
23396
|
`));
|
|
23195
23397
|
editorRef?.redrawNow();
|
|
23196
23398
|
},
|
|
23399
|
+
// every user line shows, not only the ones MAIN runs on (live 20261104-111333: quick-lane turns and kept "Oh, wow." were missing)
|
|
23400
|
+
userLine: (t, how) => {
|
|
23401
|
+
err(`\r\x1B[0J ${bold(cyan("\u{1F3A4} \u203A"))} ${t}${how === "kept" ? dim(" (over the reply)") : ""}
|
|
23402
|
+
`);
|
|
23403
|
+
editorRef?.redrawNow();
|
|
23404
|
+
},
|
|
23197
23405
|
onMetric: (m) => voiceDiag?.push({ t: performance.now(), ...m, kind: `call_${m.name}`, ...m.kind ? { what: m.kind } : {} }),
|
|
23198
23406
|
abortTurn: (id) => {
|
|
23199
23407
|
if (callTurns.get(id)?.running) {
|
|
@@ -23229,6 +23437,7 @@ ${note}`;
|
|
|
23229
23437
|
greetNote = "";
|
|
23230
23438
|
callReplyOpen = false;
|
|
23231
23439
|
spoken = new SpokenFilter();
|
|
23440
|
+
hang = markerStrip(HANGUP);
|
|
23232
23441
|
try {
|
|
23233
23442
|
const r = await dispatchLine(`${text}${note}
|
|
23234
23443
|
|
|
@@ -23243,14 +23452,18 @@ ${SPOKEN_TURN}`, { id });
|
|
|
23243
23452
|
rec.running = false;
|
|
23244
23453
|
call?.main({ type: "done", id });
|
|
23245
23454
|
editorRef?.redrawNow();
|
|
23455
|
+
if (hang.hit) hangUpCall();
|
|
23246
23456
|
}
|
|
23247
23457
|
});
|
|
23248
23458
|
}
|
|
23249
23459
|
});
|
|
23250
23460
|
const host = agent.options.host, notify = host.notify.bind(host);
|
|
23251
23461
|
host.notify = (e) => {
|
|
23252
|
-
if (e.kind === "text_delta" && typeof e.message === "string")
|
|
23253
|
-
|
|
23462
|
+
if (e.kind === "text_delta" && typeof e.message === "string") {
|
|
23463
|
+
e = { ...e, message: hang.push(e.message) };
|
|
23464
|
+
if (!e.message) return;
|
|
23465
|
+
call.main({ type: "text", text: e.message });
|
|
23466
|
+
} else if (e.kind === "tool_use") call.main({ type: "tool", name: String(e.name ?? ""), args: e.input });
|
|
23254
23467
|
else if (e.kind === "tool_result") call.main({ type: "tool_done" });
|
|
23255
23468
|
else if (e.kind === "tool_activity") {
|
|
23256
23469
|
if (!callTools.has(e.id)) {
|
|
@@ -25404,7 +25617,7 @@ function overlapResponder(ai, mode, out, aside) {
|
|
|
25404
25617
|
const judge = softBarge(mode) ? new OverlapJudge({ model: overlapModelFor(ai) }) : void 0;
|
|
25405
25618
|
return (m) => {
|
|
25406
25619
|
const text = String(m.text ?? "");
|
|
25407
|
-
void (judge ? judge.judge(text) : Promise.resolve({ verdict: "cut", by: "mode", ms: 0 })).then((d) => {
|
|
25620
|
+
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
25621
|
const line = d.verdict === "keep" ? aside?.(text) : null;
|
|
25409
25622
|
out({ type: "overlap", ...m.id !== void 0 ? { id: m.id } : {}, verdict: d.verdict, by: d.by, ms: d.ms, ...line ? { aside: line } : {} });
|
|
25410
25623
|
});
|
|
@@ -25528,9 +25741,25 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25528
25741
|
async function channelServe(args, ai, cfg) {
|
|
25529
25742
|
const out = (o) => process.stdout.write(JSON.stringify(o) + "\n");
|
|
25530
25743
|
const { model, notes, options: fast } = callFast(args, ai, cfg);
|
|
25744
|
+
const quick = args.quickLane && args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0";
|
|
25745
|
+
let cut = null;
|
|
25531
25746
|
const call = new VoiceCall({
|
|
25532
25747
|
...fast,
|
|
25533
25748
|
// no `ai` here: the channel's model wiring is explicit
|
|
25749
|
+
...quick ? {
|
|
25750
|
+
quick: fastQuickLane(ai, fast.fastModel, args.voiceGender, process.env.AGENTX_CALL_PERSONA ?? ""),
|
|
25751
|
+
noteTurn: (text) => out({ type: "note", text }),
|
|
25752
|
+
heardCut: () => cut?.heard ?? null,
|
|
25753
|
+
cutRest: () => cut && cut.full.slice(cut.heard.length).trim() || null,
|
|
25754
|
+
dropCut: () => {
|
|
25755
|
+
cut = null;
|
|
25756
|
+
out({ type: "resumed" });
|
|
25757
|
+
},
|
|
25758
|
+
// the rest was said: the host's cut note no longer holds
|
|
25759
|
+
userLine: (text, how) => out({ type: "user_line", text, how }),
|
|
25760
|
+
hangUp: () => out({ type: "hangup" })
|
|
25761
|
+
// the farewell went out as a {type:'channel', kind:'reply'}: end the call once it played
|
|
25762
|
+
} : {},
|
|
25534
25763
|
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
25764
|
speak: (line, kind) => {
|
|
25536
25765
|
out(channelLine(line, kind));
|
|
@@ -25549,8 +25778,11 @@ async function channelServe(args, ai, cfg) {
|
|
|
25549
25778
|
const overlap2 = overlapResponder(ai, args.channelMode, (o) => {
|
|
25550
25779
|
if (o.verdict === "cut") call.barge();
|
|
25551
25780
|
out(o);
|
|
25552
|
-
}, (t) =>
|
|
25553
|
-
|
|
25781
|
+
}, (t) => {
|
|
25782
|
+
call.kept(t);
|
|
25783
|
+
return call.aside(t);
|
|
25784
|
+
});
|
|
25785
|
+
out({ type: "ready", model, channelMode: args.channelMode, softBarge: softBarge(args.channelMode), call: true, ...quick ? { quickLane: true } : {}, ...notes.length ? { notes } : {} });
|
|
25554
25786
|
const rl = createInterface({ input: process.stdin });
|
|
25555
25787
|
rl.on("line", (line) => {
|
|
25556
25788
|
let m;
|
|
@@ -25564,7 +25796,10 @@ async function channelServe(args, ai, cfg) {
|
|
|
25564
25796
|
if (typeof m.text === "string") call.interim(m.text, Date.now(), typeof m.aec === "boolean" ? m.aec : void 0);
|
|
25565
25797
|
} 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
25798
|
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 === "
|
|
25799
|
+
else if (m.type === "cut") {
|
|
25800
|
+
const full = String(m.full ?? "").trim(), heard = String(m.heard ?? "").trim();
|
|
25801
|
+
cut = full && heard.length < full.length && full.startsWith(heard) ? { full, heard } : null;
|
|
25802
|
+
} else if (m.type === "main" && m.ev && typeof m.ev.type === "string") call.main(m.ev);
|
|
25568
25803
|
else if (m.type === "barge") call.barge();
|
|
25569
25804
|
else if (channelInput(call.fill, m)) return;
|
|
25570
25805
|
else if (m.type === "user" && typeof m.text === "string") call.hostTurn(m.text);
|