@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 +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +174 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +100 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1855,6 +1855,9 @@ declare class VoiceCallOptions {
|
|
|
1855
1855
|
cancel: () => void;
|
|
1856
1856
|
/** Host caption — never history. */
|
|
1857
1857
|
show: (text: string, kind: FillKind) => void;
|
|
1858
|
+
/** The user's words that start no MAIN turn — the host's transcript shows them (sendTurn shows the rest): `quick` = a
|
|
1859
|
+
* turn the quick lane answered, `aside` = said while MAIN worked, `kept` = a soft barge-in kept over the reply. */
|
|
1860
|
+
userLine: (text: string, how: 'quick' | 'aside' | 'kept') => void;
|
|
1858
1861
|
/** The fast model (lines, banks, progress) — used only with `ai`. */
|
|
1859
1862
|
fastModel: string;
|
|
1860
1863
|
/** Model client for the fast model + the channel decider / overlap judge. Absent → canned lines and rules only. */
|
|
@@ -1947,6 +1950,12 @@ declare class VoiceCall {
|
|
|
1947
1950
|
private giveWay;
|
|
1948
1951
|
/** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
|
|
1949
1952
|
overlap(text: string): Promise<OverlapVerdict>;
|
|
1953
|
+
/** An overlap kept over the reply (no turn): the transcript and the quick lane's history still hold their words — once,
|
|
1954
|
+
* in full: the host asks about every growing partial ("Oh," "Oh, wow" "Oh, wow—really?"; Para replay showed all four). */
|
|
1955
|
+
kept(text: string): void;
|
|
1956
|
+
private keptLine?;
|
|
1957
|
+
/** The kept words go to the transcript; `turn` = the words a new turn starts with (they grew into it: no line of their own). */
|
|
1958
|
+
private flushKept;
|
|
1950
1959
|
/** The fill channel's spoken aside for an overlap judged 'keep' ("yeah" → "Oh yeah, definitely."): the host plays it
|
|
1951
1960
|
* while the reply is held, then resumes the same reply (bod-voice decideOverlap's aside). ≤4 canned words, never a
|
|
1952
1961
|
* claim, the cue's language; null = stay quiet (a plain listener cue, too soon after the last, or no line). It is a
|
|
@@ -1968,6 +1977,8 @@ declare class VoiceCall {
|
|
|
1968
1977
|
/** The quick lane owns this turn: it answers, acks and hands it to MAIN, resumes a cut answer, or stays quiet. A late
|
|
1969
1978
|
* or unusable decision hands the turn to MAIN as before (the fill channel's bridge covers it). */
|
|
1970
1979
|
private quickTurn;
|
|
1980
|
+
/** The quick lane's answer became audible at `at`: the turn's first word, and it is answered. */
|
|
1981
|
+
private quickWorded;
|
|
1971
1982
|
/** say(), retried while the host's player is busy (up to 2s). */
|
|
1972
1983
|
private sayRetry;
|
|
1973
1984
|
private onDrop;
|
package/dist/index.js
CHANGED
|
@@ -7791,6 +7791,7 @@ function heardPrefix(text, spoken, lookahead = 4) {
|
|
|
7791
7791
|
}
|
|
7792
7792
|
return at;
|
|
7793
7793
|
}
|
|
7794
|
+
var ECHO_RECENT_SEC = 1.8;
|
|
7794
7795
|
var NumberedSpeakers = class {
|
|
7795
7796
|
ids = /* @__PURE__ */ new Map();
|
|
7796
7797
|
name(label) {
|
|
@@ -8063,6 +8064,10 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
8063
8064
|
drainTimer = null;
|
|
8064
8065
|
// heuristic tier state (inert under AEC) — frozen as validated in the experiment
|
|
8065
8066
|
echoWords = /* @__PURE__ */ new Set();
|
|
8067
|
+
/** Our words audible when this utterance's first partial came (undefined = no partial yet, null = no word timestamps). */
|
|
8068
|
+
uttEcho;
|
|
8069
|
+
/** The words of the line before this turn: its audio may still be playing ahead of this turn's first word. */
|
|
8070
|
+
lineBefore = /* @__PURE__ */ new Set();
|
|
8066
8071
|
prevReply = "";
|
|
8067
8072
|
reply = "";
|
|
8068
8073
|
echoUntil = 0;
|
|
@@ -8319,6 +8324,7 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
8319
8324
|
if (this.options.revealMode === "word") this.startWordReveal();
|
|
8320
8325
|
this.emo = this.options.emotions ? new EmotionStream(this.options.showEmotions) : null;
|
|
8321
8326
|
this.echoWords = new Set(this.words(this.prevReply));
|
|
8327
|
+
this.lineBefore = new Set(this.echoWords);
|
|
8322
8328
|
this.tts.newContext();
|
|
8323
8329
|
this.clause = "";
|
|
8324
8330
|
this.clearAckTimer("new_turn");
|
|
@@ -8807,6 +8813,18 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
8807
8813
|
this.diag("echo_head", { dropped: toks.slice(0, i).join(" ").slice(0, 60) });
|
|
8808
8814
|
return toks.slice(i).join(" ");
|
|
8809
8815
|
}
|
|
8816
|
+
/** Our words whose audio played in the last ECHO_RECENT_SEC (+ the ack just said) — what an echo can be made of right
|
|
8817
|
+
* now. null = no word timestamps (the bag rule judges alone). */
|
|
8818
|
+
audibleWords() {
|
|
8819
|
+
if (!this.echoActive() || !this.wordStarts.length) return null;
|
|
8820
|
+
const now3 = this.player.playedMs() / 1e3, out = /* @__PURE__ */ new Set();
|
|
8821
|
+
this.wordStarts.forEach((s, i) => {
|
|
8822
|
+
if (s <= now3 + 0.3 && s >= now3 - ECHO_RECENT_SEC) for (const w of this.words(this.wordTexts[i] ?? "")) out.add(w);
|
|
8823
|
+
});
|
|
8824
|
+
if (now3 < this.wordStarts[0] + ECHO_RECENT_SEC) for (const w of this.lineBefore) out.add(w);
|
|
8825
|
+
if (this.ackAt && this.clock.now() - this.ackAt < 3e3) for (const w of this.words(this.lastAck)) out.add(w);
|
|
8826
|
+
return out;
|
|
8827
|
+
}
|
|
8810
8828
|
novelWords(text) {
|
|
8811
8829
|
return this.words(text).filter((w) => !this.echoWords.has(w));
|
|
8812
8830
|
}
|
|
@@ -8833,10 +8851,10 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
8833
8851
|
* of our last words in their own sentence is neither: live 20261103-114604, over "…Want me to open the thread?" the
|
|
8834
8852
|
* 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
|
|
8835
8853
|
* (half the words in a word pair we said) counted it as echo. Shorter finals can't show order → bag rule. */
|
|
8836
|
-
echoFinal(text) {
|
|
8854
|
+
echoFinal(text, audible = null) {
|
|
8837
8855
|
if (this.genuine(text)) return false;
|
|
8838
8856
|
const w = this.words(text);
|
|
8839
|
-
if (w.length < 4) return true;
|
|
8857
|
+
if (w.length < 4) return audible ? w.every((x) => audible.has(x)) : true;
|
|
8840
8858
|
const said = this.words(`${this.prevReply} ${this.reply} ${this.lastAck}`);
|
|
8841
8859
|
const span = w.length + 2;
|
|
8842
8860
|
let best = 0, run = 0;
|
|
@@ -8878,6 +8896,7 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
8878
8896
|
return w.length === 1 && d.length > 0 && this.clock.now() - this.lastDispatchAt < _VoiceEngine.DUP_FINAL_MS && d[d.length - 1].startsWith(w[0]);
|
|
8879
8897
|
}
|
|
8880
8898
|
handlePartial(text) {
|
|
8899
|
+
if (text.trim() && !this.uttEcho) this.uttEcho = { at: this.clock.now(), words: this.audibleWords() };
|
|
8881
8900
|
if (this.speaking) {
|
|
8882
8901
|
if (!this.options.bargeIn) return;
|
|
8883
8902
|
if (this.clock.now() < this.bargeGraceUntil) {
|
|
@@ -9301,6 +9320,9 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
9301
9320
|
}
|
|
9302
9321
|
handleUtterance(text, langs, rawTurns) {
|
|
9303
9322
|
let turns;
|
|
9323
|
+
const cap = this.uttEcho;
|
|
9324
|
+
this.uttEcho = void 0;
|
|
9325
|
+
const audible = cap && this.clock.now() - cap.at < 15e3 ? cap.words : null;
|
|
9304
9326
|
if (this.echoHead) {
|
|
9305
9327
|
this.echoHead = false;
|
|
9306
9328
|
text = this.dropEchoHead(text);
|
|
@@ -9335,7 +9357,7 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
9335
9357
|
this.stt.reset();
|
|
9336
9358
|
return;
|
|
9337
9359
|
}
|
|
9338
|
-
if (this.echoActive() && (!this.options.bargeIn || (this.usingAec ? this.echoFinal(text) : this.novelWords(text).length < 2))) {
|
|
9360
|
+
if (this.echoActive() && (!this.options.bargeIn || (this.usingAec ? this.echoFinal(text, audible) : this.novelWords(text).length < 2))) {
|
|
9339
9361
|
this.diag("echo_swallow", { guard: "echo_gate", text: text.slice(0, 60) });
|
|
9340
9362
|
this.stt.reset();
|
|
9341
9363
|
return;
|
|
@@ -10460,7 +10482,10 @@ var ASIDES = {
|
|
|
10460
10482
|
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?"] }
|
|
10461
10483
|
};
|
|
10462
10484
|
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;
|
|
10463
|
-
var isReaction = (text) =>
|
|
10485
|
+
var isReaction = (text) => {
|
|
10486
|
+
const t = norm2(text);
|
|
10487
|
+
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"), ""));
|
|
10488
|
+
};
|
|
10464
10489
|
function overlapAside(text, lang, avoid = "", pick = (n) => Math.floor(Math.random() * n), react = false) {
|
|
10465
10490
|
const kind = react && REACT.test(norm2(text)) ? "react" : cueKind(text);
|
|
10466
10491
|
const l = new RegExp("\\p{Script=Hebrew}", "u").test(text) ? "he" : /[a-z]/i.test(text) ? "en" : lang;
|
|
@@ -15063,6 +15088,10 @@ var VoiceCallOptions = class {
|
|
|
15063
15088
|
/** Host caption — never history. */
|
|
15064
15089
|
show = () => {
|
|
15065
15090
|
};
|
|
15091
|
+
/** The user's words that start no MAIN turn — the host's transcript shows them (sendTurn shows the rest): `quick` = a
|
|
15092
|
+
* turn the quick lane answered, `aside` = said while MAIN worked, `kept` = a soft barge-in kept over the reply. */
|
|
15093
|
+
userLine = () => {
|
|
15094
|
+
};
|
|
15066
15095
|
/** The fast model (lines, banks, progress) — used only with `ai`. */
|
|
15067
15096
|
fastModel = latestClaude("haiku");
|
|
15068
15097
|
/** Model client for the fast model + the channel decider / overlap judge. Absent → canned lines and rules only. */
|
|
@@ -15230,6 +15259,13 @@ var VoiceCall = class {
|
|
|
15230
15259
|
if (this.ended) return;
|
|
15231
15260
|
if (by === "main") return this.main({ type: "audio", ...this.cur ? { id: this.cur.id } : {} }, inMs);
|
|
15232
15261
|
const at = this.o.now() + Math.max(0, inMs);
|
|
15262
|
+
const q = this.cur;
|
|
15263
|
+
if (q?.quickWord && !q.closed) {
|
|
15264
|
+
this.lastAudibleAt = at;
|
|
15265
|
+
q.marks.fillAudio ??= at;
|
|
15266
|
+
this.sounded(q, "quick", at);
|
|
15267
|
+
return this.quickWorded(q, at);
|
|
15268
|
+
}
|
|
15233
15269
|
if (this.gate.holding || !this.cur || this.cur.closed) {
|
|
15234
15270
|
this.earlyHeard ??= { at, by };
|
|
15235
15271
|
return;
|
|
@@ -15345,11 +15381,44 @@ var VoiceCall = class {
|
|
|
15345
15381
|
}
|
|
15346
15382
|
/** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
|
|
15347
15383
|
async overlap(text) {
|
|
15348
|
-
if (this.o.mode === "live" && isReaction(text)) return "keep";
|
|
15384
|
+
if (this.o.mode === "live" && isReaction(text)) return this.kept(text), "keep";
|
|
15349
15385
|
const d = await this.judge.judge(text);
|
|
15350
15386
|
if (d.verdict === "cut") this.barge();
|
|
15387
|
+
else if (d.verdict === "keep") this.kept(text);
|
|
15351
15388
|
return d.verdict;
|
|
15352
15389
|
}
|
|
15390
|
+
/** An overlap kept over the reply (no turn): the transcript and the quick lane's history still hold their words — once,
|
|
15391
|
+
* in full: the host asks about every growing partial ("Oh," "Oh, wow" "Oh, wow—really?"; Para replay showed all four). */
|
|
15392
|
+
kept(text) {
|
|
15393
|
+
if (!norm3(text)) return;
|
|
15394
|
+
const p = this.keptLine, a = norm3(text).replace(/ /g, ""), b = p ? norm3(p.text).replace(/ /g, "") : "";
|
|
15395
|
+
if (p && (a.startsWith(b) || b.startsWith(a))) {
|
|
15396
|
+
if (a.length > b.length) {
|
|
15397
|
+
p.text = text;
|
|
15398
|
+
if (p.line) p.line.text = text;
|
|
15399
|
+
}
|
|
15400
|
+
clearTimeout(p.timer);
|
|
15401
|
+
} else {
|
|
15402
|
+
this.flushKept();
|
|
15403
|
+
const line = this.quickOn ? { who: "user", text } : void 0;
|
|
15404
|
+
if (line) this.history.push(line);
|
|
15405
|
+
this.keptLine = { text, timer: void 0, line };
|
|
15406
|
+
}
|
|
15407
|
+
this.keptLine.timer = setTimeout(() => this.flushKept(), isReaction(this.keptLine.text) ? 1500 : 4e3);
|
|
15408
|
+
}
|
|
15409
|
+
keptLine;
|
|
15410
|
+
/** The kept words go to the transcript; `turn` = the words a new turn starts with (they grew into it: no line of their own). */
|
|
15411
|
+
flushKept(turn = "") {
|
|
15412
|
+
const p = this.keptLine;
|
|
15413
|
+
if (!p) return;
|
|
15414
|
+
this.keptLine = void 0;
|
|
15415
|
+
clearTimeout(p.timer);
|
|
15416
|
+
if (turn && norm3(turn).replace(/ /g, "").startsWith(norm3(p.text).replace(/ /g, ""))) {
|
|
15417
|
+
if (p.line) this.history.splice(this.history.indexOf(p.line), 1);
|
|
15418
|
+
return;
|
|
15419
|
+
}
|
|
15420
|
+
this.o.userLine(p.text, "kept");
|
|
15421
|
+
}
|
|
15353
15422
|
/** The fill channel's spoken aside for an overlap judged 'keep' ("yeah" → "Oh yeah, definitely."): the host plays it
|
|
15354
15423
|
* while the reply is held, then resumes the same reply (bod-voice decideOverlap's aside). ≤4 canned words, never a
|
|
15355
15424
|
* claim, the cue's language; null = stay quiet (a plain listener cue, too soon after the last, or no line). It is a
|
|
@@ -15360,7 +15429,7 @@ var VoiceCall = class {
|
|
|
15360
15429
|
const line = overlapAside(text, this.lang, this.lastAside.text, void 0, this.o.mode === "live");
|
|
15361
15430
|
if (!line) return null;
|
|
15362
15431
|
this.lastAside = { text: line, at: now3 };
|
|
15363
|
-
if (this.quickOn) this.history.push({ who: "
|
|
15432
|
+
if (this.quickOn) this.history.push({ who: "you", text: line });
|
|
15364
15433
|
this.o.onMetric({ name: "fill", kind: "aside", text: line, lang: this.lang });
|
|
15365
15434
|
return line;
|
|
15366
15435
|
}
|
|
@@ -15373,6 +15442,7 @@ var VoiceCall = class {
|
|
|
15373
15442
|
return this.fill.drain();
|
|
15374
15443
|
}
|
|
15375
15444
|
end() {
|
|
15445
|
+
this.flushKept();
|
|
15376
15446
|
if (this.cur) this.close(this.cur);
|
|
15377
15447
|
this.ended = true;
|
|
15378
15448
|
this.gate.end();
|
|
@@ -15393,6 +15463,7 @@ var VoiceCall = class {
|
|
|
15393
15463
|
}
|
|
15394
15464
|
onTurn(t) {
|
|
15395
15465
|
this.floor = "";
|
|
15466
|
+
this.flushKept(t.text);
|
|
15396
15467
|
if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
|
|
15397
15468
|
const prev = this.cur, quick = this.quickOn && !this.working && (t.kind === "new" || prev?.lane !== "deep");
|
|
15398
15469
|
const now3 = this.o.now(), lastWord = this.lastWordAt !== null;
|
|
@@ -15472,19 +15543,15 @@ var VoiceCall = class {
|
|
|
15472
15543
|
return;
|
|
15473
15544
|
}
|
|
15474
15545
|
c.lane = "quick";
|
|
15546
|
+
this.o.userLine(t.text, "quick");
|
|
15475
15547
|
if (mv.kind === "quiet") {
|
|
15476
15548
|
c.due = false;
|
|
15477
15549
|
return this.close(c, "silent");
|
|
15478
15550
|
}
|
|
15479
|
-
const said = mv.kind === "resume" ? `${mv.line} ${rest}`.trim() : mv.line;
|
|
15551
|
+
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;
|
|
15480
15552
|
this.gate.replyStarted(c.id);
|
|
15481
15553
|
if (!await this.sayRetry(said, "reply", c.id)) return this.close(c, "silent");
|
|
15482
15554
|
this.o.show(said, "reply");
|
|
15483
|
-
if (!c.worded) {
|
|
15484
|
-
c.worded = true;
|
|
15485
|
-
c.marks.mainAudio = this.lastAudibleAt;
|
|
15486
|
-
this.o.onMetric({ name: "first_word", id: c.id, ms: Math.round(this.lastAudibleAt - c.at), by: "quick" });
|
|
15487
|
-
}
|
|
15488
15555
|
if (mv.kind === "resume") {
|
|
15489
15556
|
this.cutRest = "";
|
|
15490
15557
|
this.o.dropCut?.();
|
|
@@ -15494,6 +15561,20 @@ var VoiceCall = class {
|
|
|
15494
15561
|
this.history.push({ who: "you", text: said });
|
|
15495
15562
|
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.`);
|
|
15496
15563
|
}
|
|
15564
|
+
if (this.o.hostAudio && !c.worded) {
|
|
15565
|
+
c.quickWord = true;
|
|
15566
|
+
return;
|
|
15567
|
+
}
|
|
15568
|
+
this.quickWorded(c, this.lastAudibleAt);
|
|
15569
|
+
}
|
|
15570
|
+
/** The quick lane's answer became audible at `at`: the turn's first word, and it is answered. */
|
|
15571
|
+
quickWorded(c, at) {
|
|
15572
|
+
c.quickWord = false;
|
|
15573
|
+
if (!c.worded) {
|
|
15574
|
+
c.worded = true;
|
|
15575
|
+
c.marks.mainAudio = at;
|
|
15576
|
+
this.o.onMetric({ name: "first_word", id: c.id, ms: Math.round(at - c.at), by: "quick" });
|
|
15577
|
+
}
|
|
15497
15578
|
this.close(c, "answered");
|
|
15498
15579
|
}
|
|
15499
15580
|
/** say(), retried while the host's player is busy (up to 2s). */
|
|
@@ -15592,6 +15673,7 @@ var VoiceCall = class {
|
|
|
15592
15673
|
const stop = /^\s*stop\s*:/i.test(raw), change = !answer || /^\s*work\s*:/i.test(raw);
|
|
15593
15674
|
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.]`;
|
|
15594
15675
|
this.history.push({ who: "user", text: t.text });
|
|
15676
|
+
if (!change) this.o.userLine(t.text, "aside");
|
|
15595
15677
|
if (line && !this.ended) {
|
|
15596
15678
|
await this.sayRetry(line, "aside", t.id);
|
|
15597
15679
|
if (this.lastAudibleAt >= at) {
|
|
@@ -15652,6 +15734,12 @@ var VoiceCall = class {
|
|
|
15652
15734
|
}
|
|
15653
15735
|
}
|
|
15654
15736
|
};
|
|
15737
|
+
function cutSentence(heard) {
|
|
15738
|
+
const tail = heard.trim().split(/(?<=[.!?…])\s+/).at(-1) ?? "";
|
|
15739
|
+
if (!tail || /[.!?…]["'”’)]*$/.test(tail)) return "";
|
|
15740
|
+
const w = tail.split(/\s+/);
|
|
15741
|
+
return w.length <= 6 ? tail : w.slice(-3).join(" ");
|
|
15742
|
+
}
|
|
15655
15743
|
|
|
15656
15744
|
// src/index.ts
|
|
15657
15745
|
init_llm();
|