@livx.cc/agentx 0.99.148 → 0.99.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +273 -68
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +23 -7
- package/dist/index.js +118 -62
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -940,7 +940,10 @@ declare const DEFAULT_CATALOG_BUDGET = 6000;
|
|
|
940
940
|
*/
|
|
941
941
|
declare function formatCatalog(entries: CatalogEntry[], opts: CatalogOptions): string;
|
|
942
942
|
|
|
943
|
-
|
|
943
|
+
/** keep = carry on · cut = give the floor · hold = stay paused and judge the line as it grows (a lone "wait" may be
|
|
944
|
+
* "Wait, really?"); the engine cedes if nothing more comes (bod-voice overlapDecideMs). A host that knows only keep/cut
|
|
945
|
+
* treats hold as cut. */
|
|
946
|
+
type OverlapVerdict = 'keep' | 'cut' | 'hold';
|
|
944
947
|
|
|
945
948
|
/** Does the user's line stop mid-phrase (trailing connective / spelled punctuation / comma / slash)? Only the user's own
|
|
946
949
|
* words count — host notes appended after a newline ("[the user interrupted you…]") are ignored. */
|
|
@@ -965,6 +968,10 @@ declare class TurnGateOptions {
|
|
|
965
968
|
dupWindowMs: number;
|
|
966
969
|
/** A fuller final within this window of the last turn (or with its sttId) is a re-final of it. */
|
|
967
970
|
refinalWindowMs: number;
|
|
971
|
+
/** A held final never goes out while the user is saying more (a partial with new words, not yet final): live
|
|
972
|
+
* 20261103-114604, "Okay." settled 700ms into "What will the…" and MAIN started, was aborted twice and merged. The
|
|
973
|
+
* rest's final merges in; capped at this long from the hold (an STT that never finalizes a partial). */
|
|
974
|
+
talkingMaxMs: number;
|
|
968
975
|
onTurn: (t: GateTurn) => void;
|
|
969
976
|
onDrop: (text: string, why: GateDrop) => void;
|
|
970
977
|
/** A final is being held (ends mid-phrase) — the fill channel may cover it with a filler, never a bridge. */
|
|
@@ -994,8 +1001,11 @@ declare class TurnGate {
|
|
|
994
1001
|
/** The user kept talking after turn `id` went out and before its reply made a sound: it was not over. Its words go back
|
|
995
1002
|
* to being held — the rest merges in and one whole turn replaces it; silence sends them again as they were. */
|
|
996
1003
|
reopen(id: string): void;
|
|
997
|
-
/** The user is speaking again (a partial): a held fragment waits for the rest.
|
|
998
|
-
|
|
1004
|
+
/** The user is speaking again (a partial — `text`, the whole partial): a held fragment waits for the rest. A partial
|
|
1005
|
+
* with words the held text lacks is more speech under way: the hold lasts until its final (≤ talkingMaxMs). */
|
|
1006
|
+
speaking(text?: string): void;
|
|
1007
|
+
/** The hold's quiet ran out: send it — unless the user is mid-line (a partial with no final yet). */
|
|
1008
|
+
private settle;
|
|
999
1009
|
/** MAIN started replying to turn `id` (its first text/tool/audio): a later re-final only adds its new words. */
|
|
1000
1010
|
replyStarted(id: string): void;
|
|
1001
1011
|
/** Send a held fragment now (e.g. the call ends). */
|
|
@@ -1672,8 +1682,10 @@ declare class ProgressOptions {
|
|
|
1672
1682
|
generateBudgetMs: number;
|
|
1673
1683
|
/** Speak only when nothing has been audible for this long. */
|
|
1674
1684
|
silenceMs: number;
|
|
1675
|
-
/** At most one
|
|
1685
|
+
/** At most one spoken work line (progress, bridge or aside) per this long. */
|
|
1676
1686
|
gapMs: number;
|
|
1687
|
+
/** One stage (a tool's topic) gets one line; a stage still running after this long may get another. 0 = 3 × gapMs. */
|
|
1688
|
+
stageRepeatMs: number;
|
|
1677
1689
|
now: () => number;
|
|
1678
1690
|
}
|
|
1679
1691
|
declare class Progress {
|
|
@@ -1682,6 +1694,7 @@ declare class Progress {
|
|
|
1682
1694
|
private lastAt;
|
|
1683
1695
|
private streamed;
|
|
1684
1696
|
private lines;
|
|
1697
|
+
private stages;
|
|
1685
1698
|
constructor(options?: Partial<ProgressOptions> | undefined);
|
|
1686
1699
|
private get o();
|
|
1687
1700
|
/** A new MAIN turn started. */
|
|
@@ -1691,9 +1704,12 @@ declare class Progress {
|
|
|
1691
1704
|
/** A tool started: MAIN is working again. */
|
|
1692
1705
|
tool(): void;
|
|
1693
1706
|
/** May a line play now, or `leadMs` from now? (the caller passes when the user last heard anything) */
|
|
1694
|
-
due(lastAudibleAt: number, leadMs?: number): boolean;
|
|
1695
|
-
/** Mark `line` spoken. */
|
|
1696
|
-
spoke(line: string): void;
|
|
1707
|
+
due(lastAudibleAt: number, leadMs?: number, tool?: string): boolean;
|
|
1708
|
+
/** Mark `line` spoken, for `tool`'s stage. */
|
|
1709
|
+
spoke(line: string, tool?: string): void;
|
|
1710
|
+
/** A work line played from elsewhere (a bridge, an aside): the same thought, so the gap counts from it. */
|
|
1711
|
+
heard(): void;
|
|
1712
|
+
private stage;
|
|
1697
1713
|
/** A line the user heard from elsewhere (an aside): progress never repeats it. */
|
|
1698
1714
|
note(line: string): void;
|
|
1699
1715
|
/** The last lines heard, for a writer to avoid. */
|
package/dist/index.js
CHANGED
|
@@ -7929,9 +7929,11 @@ var VoiceEngineOptions = class {
|
|
|
7929
7929
|
/** HOST-DECIDED short overlaps (opt-in; 0 = off = cede on ≥2 genuine words, as always). The fast "≥2 novel words →
|
|
7930
7930
|
* cede" rule cannot tell a reaction ("Oh, that's new") from a barge, and it fires ~300ms before a host-side judge
|
|
7931
7931
|
* (e.g. an AI instinct) can answer — so a judge could never keep a delivery going (live 20260923-125143: ceded on
|
|
7932
|
-
* "Oh, that", the judge said keep_talking 300ms later). When > 0, a SHORT genuine overlap (≤ overlapDecideMaxWords
|
|
7933
|
-
*
|
|
7934
|
-
*
|
|
7932
|
+
* "Oh, that", the judge said keep_talking 300ms later). When > 0, a SHORT genuine overlap (≤ overlapDecideMaxWords —
|
|
7933
|
+
* its words are the host's to judge: a '?' or "what" ceded "What?" / "You're serious?", reactions, live
|
|
7934
|
+
* 20261103-114604) keeps the pause and waits for `decideOverlap()`; every new partial while waiting is re-offered
|
|
7935
|
+
* (`overlap_pause` redecide); with no decision after this many ms it cedes. Long barges still cede instantly. Audio
|
|
7936
|
+
* is already paused, so waiting costs no talk-over. */
|
|
7935
7937
|
overlapDecideMs = 0;
|
|
7936
7938
|
/** Longest overlap (words) the host decides; also how far an overlap the host kept may grow before it cedes. */
|
|
7937
7939
|
overlapDecideMaxWords = 4;
|
|
@@ -8825,17 +8827,39 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
8825
8827
|
* that reuse a few of our words — live 20260923-102258, right after a barge over "…Gemini 3.8 Flash…":
|
|
8826
8828
|
* "Wait, there is a new Gemini model?" (3 novel / 6) was dropped twice and the user had to repeat it. Echo
|
|
8827
8829
|
* of our own audio reproduces RUNS of what we said, in order (mis-hearings break a word, not the run); a
|
|
8828
|
-
* reply that shares vocabulary scatters it. So a ≥4-word final that fails the bag test is echo only if
|
|
8829
|
-
*
|
|
8830
|
+
* reply that shares vocabulary scatters it. So a ≥4-word final that fails the bag test is echo only if ¾ of its
|
|
8831
|
+
* words line up, in order, inside ONE stretch of what we said (a mis-heard word breaks a word, not the line), or it
|
|
8832
|
+
* repeats ≥5 of our words verbatim in a row (a mis-heard tail: "…the latest email from you"). A user who quotes a few
|
|
8833
|
+
* of our last words in their own sentence is neither: live 20261103-114604, over "…Want me to open the thread?" the
|
|
8834
|
+
* 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
|
+
* (half the words in a word pair we said) counted it as echo. Shorter finals can't show order → bag rule. */
|
|
8830
8836
|
echoFinal(text) {
|
|
8831
8837
|
if (this.genuine(text)) return false;
|
|
8832
8838
|
const w = this.words(text);
|
|
8833
8839
|
if (w.length < 4) return true;
|
|
8834
8840
|
const said = this.words(`${this.prevReply} ${this.reply} ${this.lastAck}`);
|
|
8835
|
-
const
|
|
8836
|
-
|
|
8837
|
-
for (let i =
|
|
8838
|
-
|
|
8841
|
+
const span = w.length + 2;
|
|
8842
|
+
let best = 0, run = 0;
|
|
8843
|
+
for (let i = 0; i < said.length && best < w.length; i++) {
|
|
8844
|
+
if (!w.includes(said[i])) continue;
|
|
8845
|
+
for (let j = 0; j < w.length; j++) {
|
|
8846
|
+
let k = 0;
|
|
8847
|
+
while (w[j + k] !== void 0 && w[j + k] === said[i + k]) k++;
|
|
8848
|
+
run = Math.max(run, k);
|
|
8849
|
+
}
|
|
8850
|
+
const win = said.slice(i, i + span);
|
|
8851
|
+
const row = new Array(win.length + 1).fill(0);
|
|
8852
|
+
for (const x of w) {
|
|
8853
|
+
let diag = 0;
|
|
8854
|
+
for (let j = 1; j <= win.length; j++) {
|
|
8855
|
+
const up = row[j];
|
|
8856
|
+
row[j] = x === win[j - 1] ? diag + 1 : Math.max(row[j], row[j - 1]);
|
|
8857
|
+
diag = up;
|
|
8858
|
+
}
|
|
8859
|
+
}
|
|
8860
|
+
best = Math.max(best, row[win.length]);
|
|
8861
|
+
}
|
|
8862
|
+
return best * 4 >= w.length * 3 || run >= 5;
|
|
8839
8863
|
}
|
|
8840
8864
|
/** Display a partial — unless it's echo-shaped during/after our own speech (degraded-AEC bleed), or the STT's trailing
|
|
8841
8865
|
* re-emit of the line just dispatched (Soniox emits partials after <end>): the host types partials into its input box,
|
|
@@ -8908,7 +8932,8 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
8908
8932
|
this.cedeOverlap("overlap_cede", txt);
|
|
8909
8933
|
return;
|
|
8910
8934
|
}
|
|
8911
|
-
if (
|
|
8935
|
+
if (this.options.overlapDecideMs > 0) this.awaitOverlapDecision(txt);
|
|
8936
|
+
else if (!this.decideTimer) this.armResume();
|
|
8912
8937
|
return;
|
|
8913
8938
|
}
|
|
8914
8939
|
const barge = this.usingAec ? this.genuine(text) : this.novelWords(text).length >= (this.suspectUntil ? 1 : 2);
|
|
@@ -9454,29 +9479,10 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
9454
9479
|
return this.usingAec && this.options.overlapPause && this.player.canPause;
|
|
9455
9480
|
}
|
|
9456
9481
|
/** Stop/question words that make an overlap an obvious barge — never held for a host decision. */
|
|
9457
|
-
static OVERLAP_CEDE_WORDS = /* @__PURE__ */ new Set([
|
|
9458
|
-
"stop",
|
|
9459
|
-
"wait",
|
|
9460
|
-
"no",
|
|
9461
|
-
"hold",
|
|
9462
|
-
"hang",
|
|
9463
|
-
"pause",
|
|
9464
|
-
"quiet",
|
|
9465
|
-
"enough",
|
|
9466
|
-
"shut",
|
|
9467
|
-
"cancel",
|
|
9468
|
-
"what",
|
|
9469
|
-
"why",
|
|
9470
|
-
"how",
|
|
9471
|
-
"who",
|
|
9472
|
-
"when",
|
|
9473
|
-
"where",
|
|
9474
|
-
"which"
|
|
9475
|
-
]);
|
|
9476
9482
|
/** A short, non-urgent overlap: the kind a listener cue or reaction takes (see overlapDecideMs). */
|
|
9477
9483
|
shortOverlap(text) {
|
|
9478
9484
|
const w = this.words(text);
|
|
9479
|
-
return w.length <= this.options.overlapDecideMaxWords
|
|
9485
|
+
return w.length <= this.options.overlapDecideMaxWords;
|
|
9480
9486
|
}
|
|
9481
9487
|
/** Cede the floor to an overlap: interrupt, tell the host, then dispatch a final that was held while deciding. */
|
|
9482
9488
|
cedeOverlap(trigger, txt) {
|
|
@@ -9492,7 +9498,10 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
9492
9498
|
* was only just asked about it (live: "Oh," → "Oh, that" → "Oh, that— that's new" outgrew every verdict, and the
|
|
9493
9499
|
* first window ran out mid-chase, ceding a reaction Jev kept) — but the whole hold is capped at 3× the window. */
|
|
9494
9500
|
awaitOverlapDecision(txt, fresh = false) {
|
|
9495
|
-
if (this.decideTimer && !fresh)
|
|
9501
|
+
if (this.decideTimer && !fresh) {
|
|
9502
|
+
this.diag("overlap_pause", { text: txt.slice(0, 60), redecide: true });
|
|
9503
|
+
fresh = true;
|
|
9504
|
+
}
|
|
9496
9505
|
if (this.resumeTimer) {
|
|
9497
9506
|
this.clock.clearTimeout(this.resumeTimer);
|
|
9498
9507
|
this.resumeTimer = null;
|
|
@@ -10426,7 +10435,7 @@ import { AIClient, DecideClient, JevAdapter, LlmDecideAdapter } from "ai.libx.js
|
|
|
10426
10435
|
init_logging();
|
|
10427
10436
|
var log21 = forComponent("Overlap");
|
|
10428
10437
|
var norm2 = (s) => s.toLowerCase().replace(/[’']/g, "'").replace(/[^\p{L}\p{N}' -]+/gu, " ").replace(/\s+/g, " ").trim();
|
|
10429
|
-
var HARD =
|
|
10438
|
+
var HARD = /^(?:(?:stop|wait|no|nope|hold on|hang on|hold up|pause|cancel|quiet|enough|shut up|never ?mind)(?: |$))+$/;
|
|
10430
10439
|
var ACK = new Set("yeah yea yes yep yup ya ok okay k right sure true totally exactly definitely absolutely indeed mm mmm hmm mhm mm-hm uh-huh uh huh aha ah oh ooh wow nice cool great awesome perfect good fine interesting gotcha got it i see makes sense fair agreed correct of course for sure lol ha haha hahaha heh hehe yeah yeah alright all right sweet neat oh nice oh wow oh cool oh okay oh yeah oh right that's right that's true thats right thats true love it i know me too same".split(" "));
|
|
10431
10440
|
var LEAD = /* @__PURE__ */ new Set(["and", "so", "um", "uh", "er", "well", "oh"]);
|
|
10432
10441
|
var LEADER = /* @__PURE__ */ new Set(["yeah", "yea", "yes", "yep", "yup", "ok", "okay", "right", "sure", "alright", "mm", "mhm", "hmm", "uh-huh", "totally", "exactly", "true"]);
|
|
@@ -10445,8 +10454,8 @@ function cueKind(text) {
|
|
|
10445
10454
|
return r.split(" ").some((w) => AGREE.has(w)) ? "agree" : null;
|
|
10446
10455
|
}
|
|
10447
10456
|
var ASIDES = {
|
|
10448
|
-
en: { agree: ["Oh yeah, definitely.", "Yeah, exactly.", "Right, yeah."], continue: [
|
|
10449
|
-
he: { agree: ["\u05DB\u05DF, \u05D1\u05D3\u05D9\u05D5\u05E7.", "\u05DB\u05DF, \u05DE\u05DE\u05E9.", "\u05E0\u05DB\u05D5\u05DF, \u05DB\u05DF."], continue: [
|
|
10457
|
+
en: { agree: ["Oh yeah, definitely.", "Yeah, exactly.", "Right, yeah."], continue: [] },
|
|
10458
|
+
he: { agree: ["\u05DB\u05DF, \u05D1\u05D3\u05D9\u05D5\u05E7.", "\u05DB\u05DF, \u05DE\u05DE\u05E9.", "\u05E0\u05DB\u05D5\u05DF, \u05DB\u05DF."], continue: [] }
|
|
10450
10459
|
};
|
|
10451
10460
|
function overlapAside(text, lang, avoid = "", pick = (n) => Math.floor(Math.random() * n)) {
|
|
10452
10461
|
const kind = cueKind(text);
|
|
@@ -10458,25 +10467,26 @@ function overlapAside(text, lang, avoid = "", pick = (n) => Math.floor(Math.rand
|
|
|
10458
10467
|
}
|
|
10459
10468
|
function overlapRule(text) {
|
|
10460
10469
|
if (CONTINUE.test(norm2(text))) return "keep";
|
|
10461
|
-
if (/\?/.test(text)) return "cut";
|
|
10462
10470
|
let t = norm2(text);
|
|
10463
10471
|
if (!t) return void 0;
|
|
10464
|
-
if (HARD.test(t)) return "cut";
|
|
10472
|
+
if (HARD.test(t + " ")) return t.includes(" ") ? "cut" : "hold";
|
|
10465
10473
|
for (const p of PHRASES) t = t.split(p).join(" ");
|
|
10466
10474
|
const words3 = t.split(/[\s-]+/).filter(Boolean);
|
|
10467
10475
|
const ack = (w) => ACK.has(w) || HE_ACK.has(w) || /^(?:ha)+h?$|^(?:he)+h?$|^m+(?:hm+)?$|^h?m+$/.test(w);
|
|
10468
10476
|
if (words3.every(ack)) return "keep";
|
|
10469
10477
|
const lead2 = words3.findIndex((w) => !LEAD.has(w));
|
|
10470
|
-
if (lead2 >= 0 && LEADER.has(words3[lead2]) && words3.slice(lead2).filter((w) => !ack(w) && !LEAD.has(w)).length <= 1) return "keep";
|
|
10478
|
+
if (lead2 >= 0 && LEADER.has(words3[lead2]) && !words3.some((w) => HARD.test(w + " ")) && words3.slice(lead2).filter((w) => !ack(w) && !LEAD.has(w)).length <= 1) return "keep";
|
|
10471
10479
|
return void 0;
|
|
10472
10480
|
}
|
|
10473
10481
|
function fastOverlapModel(ai, model = "groq/qwen/qwen3.8-27b") {
|
|
10474
10482
|
return async (heard, signal) => {
|
|
10475
|
-
const prompt = 'Live voice call. The assistant is mid-sentence and the user just said this over it: "' + heard +
|
|
10483
|
+
const prompt = 'Live voice call. The assistant is mid-sentence and the user just said this over it: "' + heard + `"
|
|
10484
|
+
Are they STEERING \u2014 asking for something new, asking a real question about it, correcting it, or telling it to stop? A reaction is not steering: surprise, disbelief, "what?", "really?", "you're serious?", "that's serious", agreement, a laugh \u2014 the assistant just carries on.
|
|
10485
|
+
Answer yes (steering) or no (a reaction).`;
|
|
10476
10486
|
const reasoning = /qwen/.test(model) ? { providerOptions: { reasoning_effort: "none" } } : /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
|
|
10477
10487
|
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, temperature: 0, maxTokens: /gpt-oss/.test(model) ? 200 : 3, ...reasoning });
|
|
10478
10488
|
const a = (r.content ?? "").trim().toLowerCase();
|
|
10479
|
-
return /^yes/.test(a) ? "
|
|
10489
|
+
return /^yes/.test(a) ? "cut" : /^no/.test(a) ? "keep" : null;
|
|
10480
10490
|
};
|
|
10481
10491
|
}
|
|
10482
10492
|
var OverlapJudgeOptions = class {
|
|
@@ -10485,8 +10495,9 @@ var OverlapJudgeOptions = class {
|
|
|
10485
10495
|
/** A model verdict later than this is dropped → cut. 600ms: groq qwen measured p50 ~100ms / max ~230ms in isolation
|
|
10486
10496
|
* (24 calls, 2026-10-14) but live, beside the reflex + chatty-channel calls, 2 of 2 ambiguous verdicts missed 300ms
|
|
10487
10497
|
* and cut the reply. The engine holds the overlap up to 900ms (bindOverlapInstinct) — a slightly later keep beats
|
|
10488
|
-
* a cut, so the budget sits
|
|
10489
|
-
|
|
10498
|
+
* a cut, so the budget sits inside that hold. 800ms: at 600, 2 of 20 live reactions ("This is serious.") came back
|
|
10499
|
+
* late and cut the reply (2026-11-03). */
|
|
10500
|
+
budgetMs = 800;
|
|
10490
10501
|
onDecision = () => {
|
|
10491
10502
|
};
|
|
10492
10503
|
now = () => performance.now();
|
|
@@ -10511,6 +10522,7 @@ var OverlapJudge = class {
|
|
|
10511
10522
|
};
|
|
10512
10523
|
const rule = overlapRule(heard);
|
|
10513
10524
|
if (rule) return done(rule, "rule");
|
|
10525
|
+
if (norm2(heard).split(/[\s-]+/).filter(Boolean).length < 2) return done("keep", "lone");
|
|
10514
10526
|
if (!this.o.model) return done("cut", "none");
|
|
10515
10527
|
const ctl = new AbortController();
|
|
10516
10528
|
let timer;
|
|
@@ -11134,6 +11146,10 @@ var TurnGateOptions = class {
|
|
|
11134
11146
|
dupWindowMs = 5e3;
|
|
11135
11147
|
/** A fuller final within this window of the last turn (or with its sttId) is a re-final of it. */
|
|
11136
11148
|
refinalWindowMs = 5e3;
|
|
11149
|
+
/** A held final never goes out while the user is saying more (a partial with new words, not yet final): live
|
|
11150
|
+
* 20261103-114604, "Okay." settled 700ms into "What will the…" and MAIN started, was aborted twice and merged. The
|
|
11151
|
+
* rest's final merges in; capped at this long from the hold (an STT that never finalizes a partial). */
|
|
11152
|
+
talkingMaxMs = 6e3;
|
|
11137
11153
|
onTurn = () => {
|
|
11138
11154
|
};
|
|
11139
11155
|
onDrop = () => {
|
|
@@ -11192,7 +11208,7 @@ var TurnGate = class {
|
|
|
11192
11208
|
const mid = endsMidPhrase(t);
|
|
11193
11209
|
if (mid || this.o.settleMs && !/\?["')\]]*$/.test(t)) {
|
|
11194
11210
|
const ms = mid ? this.o.holdMs : this.o.settleMs;
|
|
11195
|
-
this.held = { text: t, sttId, ms, replaces, timer: setTimeout(() => this.
|
|
11211
|
+
this.held = { text: t, sttId, ms, replaces, since: now3, timer: setTimeout(() => this.settle(), ms) };
|
|
11196
11212
|
return this.o.onHold(t);
|
|
11197
11213
|
}
|
|
11198
11214
|
this.send(t, key, sttId, "new", replaces);
|
|
@@ -11203,13 +11219,25 @@ var TurnGate = class {
|
|
|
11203
11219
|
const l = this.last;
|
|
11204
11220
|
if (l?.id !== id || this.held) return;
|
|
11205
11221
|
this.last = void 0;
|
|
11206
|
-
this.held = { text: l.text, sttId: l.sttId, ms: this.o.holdMs, replaces: id, timer: setTimeout(() => this.
|
|
11222
|
+
this.held = { text: l.text, sttId: l.sttId, ms: this.o.holdMs, replaces: id, since: this.o.now(), timer: setTimeout(() => this.settle(), this.o.holdMs) };
|
|
11223
|
+
}
|
|
11224
|
+
/** The user is speaking again (a partial — `text`, the whole partial): a held fragment waits for the rest. A partial
|
|
11225
|
+
* with words the held text lacks is more speech under way: the hold lasts until its final (≤ talkingMaxMs). */
|
|
11226
|
+
speaking(text = "") {
|
|
11227
|
+
const h = this.held;
|
|
11228
|
+
if (!h) return;
|
|
11229
|
+
if (text && norm3(text).split(" ").some((w) => w && !` ${norm3(h.text)} `.includes(` ${w} `))) h.talking = true;
|
|
11230
|
+
clearTimeout(h.timer);
|
|
11231
|
+
h.timer = setTimeout(() => this.settle(), h.ms);
|
|
11207
11232
|
}
|
|
11208
|
-
/** The user is
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11233
|
+
/** The hold's quiet ran out: send it — unless the user is mid-line (a partial with no final yet). */
|
|
11234
|
+
settle() {
|
|
11235
|
+
const h = this.held;
|
|
11236
|
+
if (h?.talking && this.o.now() - h.since < this.o.talkingMaxMs) {
|
|
11237
|
+
h.timer = setTimeout(() => this.settle(), h.ms);
|
|
11238
|
+
return;
|
|
11239
|
+
}
|
|
11240
|
+
this.flush();
|
|
11213
11241
|
}
|
|
11214
11242
|
/** MAIN started replying to turn `id` (its first text/tool/audio): a later re-final only adds its new words. */
|
|
11215
11243
|
replyStarted(id) {
|
|
@@ -13944,8 +13972,10 @@ var ProgressOptions = class {
|
|
|
13944
13972
|
generateBudgetMs = 800;
|
|
13945
13973
|
/** Speak only when nothing has been audible for this long. */
|
|
13946
13974
|
silenceMs = 3e3;
|
|
13947
|
-
/** At most one
|
|
13975
|
+
/** At most one spoken work line (progress, bridge or aside) per this long. */
|
|
13948
13976
|
gapMs = 4e3;
|
|
13977
|
+
/** One stage (a tool's topic) gets one line; a stage still running after this long may get another. 0 = 3 × gapMs. */
|
|
13978
|
+
stageRepeatMs = 0;
|
|
13949
13979
|
now = () => performance.now();
|
|
13950
13980
|
};
|
|
13951
13981
|
function argsHint(args) {
|
|
@@ -13963,6 +13993,7 @@ var Progress = class {
|
|
|
13963
13993
|
lastAt = -Infinity;
|
|
13964
13994
|
streamed = false;
|
|
13965
13995
|
lines = [];
|
|
13996
|
+
stages = /* @__PURE__ */ new Map();
|
|
13966
13997
|
get o() {
|
|
13967
13998
|
return this.options;
|
|
13968
13999
|
}
|
|
@@ -13979,15 +14010,25 @@ var Progress = class {
|
|
|
13979
14010
|
this.streamed = false;
|
|
13980
14011
|
}
|
|
13981
14012
|
/** May a line play now, or `leadMs` from now? (the caller passes when the user last heard anything) */
|
|
13982
|
-
due(lastAudibleAt, leadMs = 0) {
|
|
13983
|
-
const now3 = this.o.now();
|
|
14013
|
+
due(lastAudibleAt, leadMs = 0, tool = "") {
|
|
14014
|
+
const now3 = this.o.now(), spoken = tool ? this.stages.get(this.stage(tool)) : void 0;
|
|
14015
|
+
if (spoken !== void 0 && now3 - spoken < (this.o.stageRepeatMs || 3 * this.o.gapMs) - leadMs) return false;
|
|
13984
14016
|
return !this.streamed && now3 - lastAudibleAt >= this.o.silenceMs - leadMs && now3 - this.lastAt >= this.o.gapMs - leadMs;
|
|
13985
14017
|
}
|
|
13986
|
-
/** Mark `line` spoken. */
|
|
13987
|
-
spoke(line) {
|
|
14018
|
+
/** Mark `line` spoken, for `tool`'s stage. */
|
|
14019
|
+
spoke(line, tool = "") {
|
|
13988
14020
|
this.note(line);
|
|
14021
|
+
this.heard();
|
|
14022
|
+
if (tool) this.stages.set(this.stage(tool), this.o.now());
|
|
14023
|
+
}
|
|
14024
|
+
/** A work line played from elsewhere (a bridge, an aside): the same thought, so the gap counts from it. */
|
|
14025
|
+
heard() {
|
|
13989
14026
|
this.lastAt = this.o.now();
|
|
13990
14027
|
}
|
|
14028
|
+
stage(tool) {
|
|
14029
|
+
const n = tool.toLowerCase();
|
|
14030
|
+
return TOPICS.find(([re]) => re.test(n))?.[1] ?? n;
|
|
14031
|
+
}
|
|
13991
14032
|
/** A line the user heard from elsewhere (an aside): progress never repeats it. */
|
|
13992
14033
|
note(line) {
|
|
13993
14034
|
this.said.add(norm3(line));
|
|
@@ -14017,26 +14058,34 @@ var Progress = class {
|
|
|
14017
14058
|
r(null);
|
|
14018
14059
|
}, this.o.generateBudgetMs);
|
|
14019
14060
|
});
|
|
14020
|
-
const
|
|
14061
|
+
const hint = argsHint(args) || about.slice(-80);
|
|
14062
|
+
const raw = await Promise.race([this.o.generate(tool, hint, lang, ac.signal, this.lines).catch((e) => {
|
|
14021
14063
|
log29.warn(`progress line failed: ${e?.message ?? e}`);
|
|
14022
14064
|
return null;
|
|
14023
14065
|
}), late]).finally(() => clearTimeout(t));
|
|
14024
14066
|
const l = cleanLine(raw ?? "", lang, 5);
|
|
14025
|
-
if (!l || about && !echoesHeard(l,
|
|
14067
|
+
if (!l || about && !echoesHeard(l, hint) || RESULT_CLAIM_RE.test(l) || HE_RESULT_CLAIM.test(l) || this.said.has(norm3(l)) || this.streamed) return "";
|
|
14026
14068
|
return l;
|
|
14027
14069
|
}
|
|
14028
14070
|
};
|
|
14029
14071
|
function fastProgressGenerator(ai, model, gender) {
|
|
14030
14072
|
return async (tool, hint, lang, signal, avoid = []) => {
|
|
14031
|
-
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 ?
|
|
14073
|
+
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.`;
|
|
14032
14074
|
const reasoning = /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
|
|
14033
14075
|
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, maxTokens: 150, ...reasoning });
|
|
14034
14076
|
return r.content ?? "";
|
|
14035
14077
|
};
|
|
14036
14078
|
}
|
|
14079
|
+
var WORK_CLAIM = /\b(?:none|nothing|nobody|zero|\d+|one|two|three|four|five|many|several|some|looks like|seems|turns out|apparently|it'?s|they'?re|there'?s)\b|(?:^|\s)(?:כלום|אף|נראה)(?=\s|$|[.,!…])/iu;
|
|
14080
|
+
var claimsResult = (l) => RESULT_CLAIM_RE.test(l) || HE_RESULT_CLAIM.test(l) || WORK_CLAIM.test(l);
|
|
14037
14081
|
function cleanWorkReply(raw, lang) {
|
|
14038
14082
|
const l = cleanLine(raw.replace(/^\s*(?:stop|work)\s*:/i, ""), lang, 8);
|
|
14039
|
-
return
|
|
14083
|
+
return claimsResult(l) ? "" : l;
|
|
14084
|
+
}
|
|
14085
|
+
function workAck(raw, lang, gender = "") {
|
|
14086
|
+
const l = cleanLine(raw.replace(/^\s*(?:stop|work)\s*:/i, ""), lang, 8);
|
|
14087
|
+
if (!l || !claimsResult(l)) return "";
|
|
14088
|
+
return (PROGRESS_TEMPLATES[gender ? `${lang}-${gender[0]}` : lang] ?? PROGRESS_TEMPLATES[lang])?.delegate[1] ?? "";
|
|
14040
14089
|
}
|
|
14041
14090
|
|
|
14042
14091
|
// src/voice/secondChannel.ts
|
|
@@ -14197,6 +14246,11 @@ var SecondChannelOptions = class {
|
|
|
14197
14246
|
random = Math.random;
|
|
14198
14247
|
};
|
|
14199
14248
|
var words2 = (s) => s.trim() ? s.trim().split(/\s+/) : [];
|
|
14249
|
+
var HESITATION = /^(?:a+y*|a+i|e+[hr]*|erm+|u+[hm]*|h?m+|o+h+|ooh|like|so|well|אה+|אמ+|אה?ם+|ממ+)$/u;
|
|
14250
|
+
var onlyHesitation = (s) => {
|
|
14251
|
+
const w = words2(s).slice(-3).map((x) => x.toLowerCase().replace(/[^\p{L}]/gu, "")).filter(Boolean);
|
|
14252
|
+
return !!w.length && w.every((x) => HESITATION.test(x));
|
|
14253
|
+
};
|
|
14200
14254
|
function withBudget(p, ms, what, ac) {
|
|
14201
14255
|
let t;
|
|
14202
14256
|
const late = new Promise((r) => {
|
|
@@ -14815,6 +14869,7 @@ var SecondChannel = class {
|
|
|
14815
14869
|
return p;
|
|
14816
14870
|
}
|
|
14817
14871
|
say(kind, text) {
|
|
14872
|
+
if (kind === "backchannel" && onlyHesitation(this.heard)) return false;
|
|
14818
14873
|
let r;
|
|
14819
14874
|
try {
|
|
14820
14875
|
r = this.o.speak(text, kind);
|
|
@@ -15045,7 +15100,7 @@ var VoiceCall = class {
|
|
|
15045
15100
|
interim(text, _atMs, aec) {
|
|
15046
15101
|
if (this.ended || !text.trim()) return;
|
|
15047
15102
|
if (typeof aec === "boolean") this.fill.options.aec = aec;
|
|
15048
|
-
this.gate.speaking();
|
|
15103
|
+
this.gate.speaking(text);
|
|
15049
15104
|
this.lastUserAt = this.o.now();
|
|
15050
15105
|
const c = this.cur, steers = !!this.o.noteTurn && this.working;
|
|
15051
15106
|
const resumed = !steers || c.marks.mainFirst === void 0 && this.o.now() - c.at < this.o.resumeMs;
|
|
@@ -15276,6 +15331,7 @@ var VoiceCall = class {
|
|
|
15276
15331
|
}
|
|
15277
15332
|
if (r === false) return false;
|
|
15278
15333
|
this.o.onMetric({ name: "fill", kind, text, lang: this.lang });
|
|
15334
|
+
if (kind !== "backchannel") this.progress.heard();
|
|
15279
15335
|
const c = this.cur && !this.cur.closed ? this.cur : void 0;
|
|
15280
15336
|
const forTurn = !!c && (kind === "bridge" || kind === "progress" || kind === "filler" && c.running && !c.sounded);
|
|
15281
15337
|
if (c && forTurn && c.marks.fill === void 0) {
|
|
@@ -15333,7 +15389,7 @@ var VoiceCall = class {
|
|
|
15333
15389
|
log31.warn(`work reply failed \u2014 MAIN only: ${e?.message ?? e}`);
|
|
15334
15390
|
return "";
|
|
15335
15391
|
}).finally(() => clearTimeout(late)) : "";
|
|
15336
|
-
const line = cleanWorkReply(raw, lang ?? ""), stop = /^\s*stop\s*:/i.test(raw), change = !line || /^\s*work\s*:/i.test(raw);
|
|
15392
|
+
const ack = workAck(raw, lang ?? "", this.o.gender), line = cleanWorkReply(raw, lang ?? "") || ack, stop = /^\s*stop\s*:/i.test(raw), change = !line || /^\s*work\s*:/i.test(raw);
|
|
15337
15393
|
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.]`;
|
|
15338
15394
|
if (line && !this.ended) {
|
|
15339
15395
|
for (let i = 0; i < 8 && this.say(line, "aside") === false; i++) {
|
|
@@ -15369,7 +15425,7 @@ var VoiceCall = class {
|
|
|
15369
15425
|
this.progressTimer = null;
|
|
15370
15426
|
if (this.ended || this.cur !== c || !c.running || c.streamed && c.open <= 0) return;
|
|
15371
15427
|
const lang = this.lang, now3 = this.o.now();
|
|
15372
|
-
if (lang && !c.draft && !c.drafting && now3 - c.draftAt >= 1e3 && this.progress.due(this.lastAudibleAt, this.o.progressLeadMs)) {
|
|
15428
|
+
if (lang && !c.draft && !c.drafting && now3 - c.draftAt >= 1e3 && this.progress.due(this.lastAudibleAt, this.o.progressLeadMs, c.tool)) {
|
|
15373
15429
|
c.drafting = true;
|
|
15374
15430
|
void this.progress.line(c.tool, c.args, lang, this.o.mode === "live" ? c.text : "").then((l) => {
|
|
15375
15431
|
c.drafting = false;
|
|
@@ -15383,9 +15439,9 @@ var VoiceCall = class {
|
|
|
15383
15439
|
this.progressTimer = setTimeout(tick, 250);
|
|
15384
15440
|
};
|
|
15385
15441
|
const sayDraft = () => {
|
|
15386
|
-
if (!c.draft || this.ended || this.cur !== c || !c.running || c.streamed && c.open <= 0 || this.o.now() - this.lastUserAt < this.o.userQuietMs || !this.progress.due(this.lastAudibleAt)) return;
|
|
15442
|
+
if (!c.draft || this.ended || this.cur !== c || !c.running || c.streamed && c.open <= 0 || this.o.now() - this.lastUserAt < this.o.userQuietMs || !this.progress.due(this.lastAudibleAt, 0, c.tool)) return;
|
|
15387
15443
|
if (this.say(c.draft, "progress") !== false) {
|
|
15388
|
-
this.progress.spoke(c.draft);
|
|
15444
|
+
this.progress.spoke(c.draft, c.tool);
|
|
15389
15445
|
this.fill.covered();
|
|
15390
15446
|
this.o.show(c.draft, "progress");
|
|
15391
15447
|
c.draft = "";
|