@livx.cc/agentx 0.99.153 → 0.99.154
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 +310 -67
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +64 -3
- package/dist/index.js +133 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1676,6 +1676,44 @@ declare function makeTaskBatchTool(opts: TaskToolOptions): AgentTool;
|
|
|
1676
1676
|
/** Component-scoped logger (libx.js). debug/verbose gated via DEBUG env/localStorage. */
|
|
1677
1677
|
declare const forComponent: (name: string) => libx_js_src_modules_log.ComponentLogger;
|
|
1678
1678
|
|
|
1679
|
+
/**
|
|
1680
|
+
* The quick lane of a live call (#1331): a fast model that OWNS the conversation. Each user turn it either answers
|
|
1681
|
+
* itself (chit-chat, a reaction, a clarification, restating something already said), acknowledges and hands the turn
|
|
1682
|
+
* to the deep lane (MAIN: tools, facts it can't know, real thinking), resumes an answer the user cut, or stays quiet.
|
|
1683
|
+
* It knows only the call's shared history — what the user said and what was said aloud by either lane — so a fact
|
|
1684
|
+
* comes only from the deep lane or from what was already said; `quickMove` enforces it (a line that names a number or
|
|
1685
|
+
* a name the call never held goes to the deep lane instead).
|
|
1686
|
+
*/
|
|
1687
|
+
|
|
1688
|
+
interface LaneLine {
|
|
1689
|
+
who: 'user' | 'you';
|
|
1690
|
+
text: string;
|
|
1691
|
+
cut?: boolean;
|
|
1692
|
+
}
|
|
1693
|
+
interface QuickContext {
|
|
1694
|
+
/** The call so far, oldest first (the turn being decided is `heard`, not in here). */
|
|
1695
|
+
history: LaneLine[];
|
|
1696
|
+
/** The user's turn, verbatim from the STT. */
|
|
1697
|
+
heard: string;
|
|
1698
|
+
lang: string;
|
|
1699
|
+
/** The unsaid rest of an answer the user just cut ('' = none). */
|
|
1700
|
+
rest?: string;
|
|
1701
|
+
}
|
|
1702
|
+
type QuickMove = {
|
|
1703
|
+
kind: 'say';
|
|
1704
|
+
line: string;
|
|
1705
|
+
} | {
|
|
1706
|
+
kind: 'deep';
|
|
1707
|
+
ack: string;
|
|
1708
|
+
brief: string;
|
|
1709
|
+
} | {
|
|
1710
|
+
kind: 'resume';
|
|
1711
|
+
line: string;
|
|
1712
|
+
} | {
|
|
1713
|
+
kind: 'quiet';
|
|
1714
|
+
};
|
|
1715
|
+
type QuickDecider = (c: QuickContext, signal: AbortSignal) => Promise<QuickMove | null>;
|
|
1716
|
+
|
|
1679
1717
|
type Topic = 'board' | 'websearch' | 'page' | 'browser' | 'search' | 'mail' | 'calendar' | 'memory' | 'write' | 'run' | 'read' | 'delegate';
|
|
1680
1718
|
/** Two phrasings per topic and language (never the same line twice in a call). Hebrew is gendered on the speaker:
|
|
1681
1719
|
* 'he-f' / 'he-m' follow the voice (ProgressOptions.gender); 'he' (plural present) when the gender is unknown. */
|
|
@@ -1736,7 +1774,8 @@ interface WorkContext {
|
|
|
1736
1774
|
/** The spoken answer. `stop:` opens it when they called the work off, `work:` when they change or add to it. '' = silence. */
|
|
1737
1775
|
type WorkReply = (c: WorkContext, signal: AbortSignal) => Promise<string>;
|
|
1738
1776
|
|
|
1739
|
-
|
|
1777
|
+
/** 'ack'/'reply': the quick lane's own words (live with `quick`) — an acknowledgement before the deep lane, or its answer. */
|
|
1778
|
+
type FillKind = LineKind | 'progress' | 'aside' | 'ack' | 'reply';
|
|
1740
1779
|
/** MAIN's stream as the host forwards it. `id` = the turn (sendTurn's id); absent → the current turn. */
|
|
1741
1780
|
interface MainEvent {
|
|
1742
1781
|
type: 'start' | 'text' | 'tool' | 'tool_done' | 'audio' | 'done' | 'error';
|
|
@@ -1771,11 +1810,11 @@ interface TurnTimeline {
|
|
|
1771
1810
|
end?: 'answered' | 'cut' | 'replaced' | 'silent';
|
|
1772
1811
|
}
|
|
1773
1812
|
interface CallMetric {
|
|
1774
|
-
name: 'first_sound' | 'first_word' | 'turn' | 'drop' | 'hold' | 'fill' | 'lang' | 'timeline';
|
|
1813
|
+
name: 'first_sound' | 'first_word' | 'turn' | 'drop' | 'hold' | 'fill' | 'lang' | 'timeline' | 'lane';
|
|
1775
1814
|
id?: string;
|
|
1776
1815
|
/** ms from the user's last word (see TurnTimeline) */
|
|
1777
1816
|
ms?: number;
|
|
1778
|
-
by?: 'fill' | 'progress' | 'main';
|
|
1817
|
+
by?: 'fill' | 'progress' | 'main' | 'quick';
|
|
1779
1818
|
kind?: string;
|
|
1780
1819
|
text?: string;
|
|
1781
1820
|
lang?: string | null;
|
|
@@ -1801,6 +1840,15 @@ declare class VoiceCallOptions {
|
|
|
1801
1840
|
/** Writes that immediate answer (fastWorkReply). */
|
|
1802
1841
|
workReply?: WorkReply;
|
|
1803
1842
|
workReplyBudgetMs: number;
|
|
1843
|
+
/** Live: the quick lane (fastQuickLane) owns the conversation — each turn it answers, acks + hands to MAIN, resumes a
|
|
1844
|
+
* cut answer, or stays quiet. Absent (or another mode): every turn goes to MAIN as before. */
|
|
1845
|
+
quick?: QuickDecider;
|
|
1846
|
+
/** Past this the turn goes to MAIN as before (the bridge covers it). */
|
|
1847
|
+
quickBudgetMs: number;
|
|
1848
|
+
/** The unsaid rest of MAIN's reply a barge just cut (a peek, like heardCut), else null — what a resume says. */
|
|
1849
|
+
cutRest?: () => string | null;
|
|
1850
|
+
/** A resume said that rest: the host drops the cut (MAIN's history keeps the whole reply). */
|
|
1851
|
+
dropCut?: () => void;
|
|
1804
1852
|
/** Host TTS (fill lane): resolves when played; `false` = could not play. */
|
|
1805
1853
|
speak: (text: string, kind: FillKind) => Promise<unknown> | boolean;
|
|
1806
1854
|
/** Stop the in-flight fill line now (barge-in only). */
|
|
@@ -1854,6 +1902,10 @@ declare class VoiceCall {
|
|
|
1854
1902
|
private progressTimer;
|
|
1855
1903
|
private lastUserAt;
|
|
1856
1904
|
private ended;
|
|
1905
|
+
/** The call as both lanes know it: the user's turns and what was said aloud (quick lines, MAIN's heard replies). */
|
|
1906
|
+
readonly history: LaneLine[];
|
|
1907
|
+
private cutRest;
|
|
1908
|
+
private cutTurn?;
|
|
1857
1909
|
constructor(options?: Partial<VoiceCallOptions> | undefined);
|
|
1858
1910
|
private get o();
|
|
1859
1911
|
/** The language the fill channel speaks right now (null = unknown → silent). */
|
|
@@ -1908,7 +1960,16 @@ declare class VoiceCall {
|
|
|
1908
1960
|
/** Follow the user's language from their own words: a confident detection, else the current language if the words
|
|
1909
1961
|
* fit it, else unknown (silent). Pinned into the channel so its own detection never diverges. */
|
|
1910
1962
|
private follow;
|
|
1963
|
+
private get quickOn();
|
|
1911
1964
|
private onTurn;
|
|
1965
|
+
/** A MAIN reply cut while it played: the history keeps the part heard; a resume may say the rest. */
|
|
1966
|
+
private logCut;
|
|
1967
|
+
private logReply;
|
|
1968
|
+
/** The quick lane owns this turn: it answers, acks and hands it to MAIN, resumes a cut answer, or stays quiet. A late
|
|
1969
|
+
* or unusable decision hands the turn to MAIN as before (the fill channel's bridge covers it). */
|
|
1970
|
+
private quickTurn;
|
|
1971
|
+
/** say(), retried while the host's player is busy (up to 2s). */
|
|
1972
|
+
private sayRetry;
|
|
1912
1973
|
private onDrop;
|
|
1913
1974
|
/** Every fill/progress line passes here: only in the turn's known language, never after the call ended. */
|
|
1914
1975
|
private say;
|
package/dist/index.js
CHANGED
|
@@ -10456,11 +10456,13 @@ function cueKind(text) {
|
|
|
10456
10456
|
return r.split(" ").some((w) => AGREE.has(w)) ? "agree" : null;
|
|
10457
10457
|
}
|
|
10458
10458
|
var ASIDES = {
|
|
10459
|
-
en: { agree: ["Oh yeah, definitely.", "Yeah, exactly.", "Right, yeah."], continue: [] },
|
|
10460
|
-
he: { agree: ["\u05DB\u05DF, \u05D1\u05D3\u05D9\u05D5\u05E7.", "\u05DB\u05DF, \u05DE\u05DE\u05E9.", "\u05E0\u05DB\u05D5\u05DF, \u05DB\u05DF."], continue: [] }
|
|
10459
|
+
en: { agree: ["Oh yeah, definitely.", "Yeah, exactly.", "Right, yeah."], continue: [], react: ["I know, right?", "Right? Wild.", "Yeah, crazy, right?"] },
|
|
10460
|
+
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
10461
|
};
|
|
10462
|
-
|
|
10463
|
-
|
|
10462
|
+
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) => REACT.test(norm2(text));
|
|
10464
|
+
function overlapAside(text, lang, avoid = "", pick = (n) => Math.floor(Math.random() * n), react = false) {
|
|
10465
|
+
const kind = react && REACT.test(norm2(text)) ? "react" : cueKind(text);
|
|
10464
10466
|
const l = new RegExp("\\p{Script=Hebrew}", "u").test(text) ? "he" : /[a-z]/i.test(text) ? "en" : lang;
|
|
10465
10467
|
const pool = kind && l ? ASIDES[l]?.[kind] : void 0;
|
|
10466
10468
|
if (!pool?.length) return null;
|
|
@@ -13820,8 +13822,8 @@ var SOFT_CUE = "~";
|
|
|
13820
13822
|
var STOP4 = new Set("about after again also always been before being could does doing down even every from going have here into just know like look make many more most much must never only other over really right same should some still such sure take than that their them then there these they thing think this those through very want well were what when where which while will with would your yeah okay".split(" "));
|
|
13821
13823
|
var isContent = (w) => w.length >= 4 && !STOP4.has(w);
|
|
13822
13824
|
function echoesHeard(line, heard) {
|
|
13823
|
-
const said = cueWords(heard).
|
|
13824
|
-
return cueWords(lineWords(line)).
|
|
13825
|
+
const said = cueWords(heard).filter(echoable).map(stem);
|
|
13826
|
+
return cueWords(lineWords(line)).filter(echoable).map(stem).some((w) => said.some((h) => h === w || Math.min(h.length, w.length) >= 4 && (h.startsWith(w) || w.startsWith(h))));
|
|
13825
13827
|
}
|
|
13826
13828
|
var stem = (w) => w.replace(/['’]s$/, "").replace(new RegExp("(?<=\\p{L}{3})s$", "u"), "");
|
|
13827
13829
|
var SHORT_STOP = new Set("the and you are was for not but has had his her its our who why how can did get got let may one out see she two use way yes all any new now off old own say too him hey huh ooh wow yep".split(" "));
|
|
@@ -15044,6 +15046,15 @@ var VoiceCallOptions = class {
|
|
|
15044
15046
|
/** Writes that immediate answer (fastWorkReply). */
|
|
15045
15047
|
workReply;
|
|
15046
15048
|
workReplyBudgetMs = 1500;
|
|
15049
|
+
/** Live: the quick lane (fastQuickLane) owns the conversation — each turn it answers, acks + hands to MAIN, resumes a
|
|
15050
|
+
* cut answer, or stays quiet. Absent (or another mode): every turn goes to MAIN as before. */
|
|
15051
|
+
quick;
|
|
15052
|
+
/** Past this the turn goes to MAIN as before (the bridge covers it). */
|
|
15053
|
+
quickBudgetMs = 1800;
|
|
15054
|
+
/** The unsaid rest of MAIN's reply a barge just cut (a peek, like heardCut), else null — what a resume says. */
|
|
15055
|
+
cutRest;
|
|
15056
|
+
/** A resume said that rest: the host drops the cut (MAIN's history keeps the whole reply). */
|
|
15057
|
+
dropCut;
|
|
15047
15058
|
/** Host TTS (fill lane): resolves when played; `false` = could not play. */
|
|
15048
15059
|
speak = () => false;
|
|
15049
15060
|
/** Stop the in-flight fill line now (barge-in only). */
|
|
@@ -15085,6 +15096,7 @@ var VoiceCallOptions = class {
|
|
|
15085
15096
|
progressLeadMs = 1e3;
|
|
15086
15097
|
};
|
|
15087
15098
|
var VoiceCall = class {
|
|
15099
|
+
// a MAIN reply cut while audible: its heard part goes to the history at the next turn
|
|
15088
15100
|
constructor(options) {
|
|
15089
15101
|
this.options = options;
|
|
15090
15102
|
this.options = { ...new VoiceCallOptions(), ...options };
|
|
@@ -15147,6 +15159,11 @@ var VoiceCall = class {
|
|
|
15147
15159
|
progressTimer = null;
|
|
15148
15160
|
lastUserAt = -Infinity;
|
|
15149
15161
|
ended = false;
|
|
15162
|
+
/** The call as both lanes know it: the user's turns and what was said aloud (quick lines, MAIN's heard replies). */
|
|
15163
|
+
history = [];
|
|
15164
|
+
cutRest = "";
|
|
15165
|
+
// the unsaid rest of the last cut MAIN reply, until the next turn decides it
|
|
15166
|
+
cutTurn;
|
|
15150
15167
|
get o() {
|
|
15151
15168
|
return this.options;
|
|
15152
15169
|
}
|
|
@@ -15242,6 +15259,7 @@ var VoiceCall = class {
|
|
|
15242
15259
|
return;
|
|
15243
15260
|
case "text":
|
|
15244
15261
|
if (!ev.text) return;
|
|
15262
|
+
c.reply += ev.text;
|
|
15245
15263
|
c.marks.mainFirst ??= this.o.now();
|
|
15246
15264
|
c.marks.mainText ??= this.o.now();
|
|
15247
15265
|
if (!c.streamed) {
|
|
@@ -15318,6 +15336,7 @@ var VoiceCall = class {
|
|
|
15318
15336
|
} catch (e) {
|
|
15319
15337
|
log32.warn(`cancel threw: ${e.message}`);
|
|
15320
15338
|
}
|
|
15339
|
+
if (c?.worded && c.lane === "deep" && !c.cutRead) this.cutTurn = c;
|
|
15321
15340
|
if (c?.running) {
|
|
15322
15341
|
c.running = false;
|
|
15323
15342
|
this.o.abortTurn(c.id);
|
|
@@ -15326,6 +15345,7 @@ var VoiceCall = class {
|
|
|
15326
15345
|
}
|
|
15327
15346
|
/** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
|
|
15328
15347
|
async overlap(text) {
|
|
15348
|
+
if (this.o.mode === "live" && isReaction(text)) return "keep";
|
|
15329
15349
|
const d = await this.judge.judge(text);
|
|
15330
15350
|
if (d.verdict === "cut") this.barge();
|
|
15331
15351
|
return d.verdict;
|
|
@@ -15337,9 +15357,10 @@ var VoiceCall = class {
|
|
|
15337
15357
|
aside(text) {
|
|
15338
15358
|
const now3 = this.o.now();
|
|
15339
15359
|
if (now3 - this.lastAside.at < this.o.asideGapMs) return null;
|
|
15340
|
-
const line = overlapAside(text, this.lang, this.lastAside.text);
|
|
15360
|
+
const line = overlapAside(text, this.lang, this.lastAside.text, void 0, this.o.mode === "live");
|
|
15341
15361
|
if (!line) return null;
|
|
15342
15362
|
this.lastAside = { text: line, at: now3 };
|
|
15363
|
+
if (this.quickOn) this.history.push({ who: "user", text }, { who: "you", text: line });
|
|
15343
15364
|
this.o.onMetric({ name: "fill", kind: "aside", text: line, lang: this.lang });
|
|
15344
15365
|
return line;
|
|
15345
15366
|
}
|
|
@@ -15367,18 +15388,23 @@ var VoiceCall = class {
|
|
|
15367
15388
|
this.lang = l;
|
|
15368
15389
|
if (l) this.fill.setLanguage(l, true);
|
|
15369
15390
|
}
|
|
15391
|
+
get quickOn() {
|
|
15392
|
+
return this.o.mode === "live" && !!this.o.quick;
|
|
15393
|
+
}
|
|
15370
15394
|
onTurn(t) {
|
|
15371
15395
|
this.floor = "";
|
|
15372
15396
|
if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
|
|
15397
|
+
const prev = this.cur, quick = this.quickOn && !this.working && (t.kind === "new" || prev?.lane !== "deep");
|
|
15373
15398
|
const now3 = this.o.now(), lastWord = this.lastWordAt !== null;
|
|
15374
15399
|
const at = this.lastWordAt ?? this.firstFinalAt ?? now3;
|
|
15375
15400
|
const finalAt = this.finalAt || now3;
|
|
15376
15401
|
this.firstFinalAt = null;
|
|
15377
15402
|
this.lastWordAt = null;
|
|
15378
|
-
if (this.
|
|
15403
|
+
if (this.quickOn) this.logCut();
|
|
15404
|
+
if (prev) this.close(prev, t.replaces === prev.id ? "replaced" : void 0);
|
|
15379
15405
|
this.follow(t.text);
|
|
15380
15406
|
this.clearProgress();
|
|
15381
|
-
this.cur = { id: t.id, text: t.text, at, finalAt, lastWord, running:
|
|
15407
|
+
this.cur = { id: t.id, text: t.text, at, finalAt, lastWord, running: !quick, streamed: false, sounded: false, worded: false, done: false, marks: { sent: now3 }, closed: false, due: turnIntent(t.text) !== "closer", open: 0, tool: "", draft: "", drafting: false, draftAt: -Infinity, reply: "", ...this.quickOn ? { lane: quick ? "pending" : "deep" } : {} };
|
|
15382
15408
|
const early = this.earlyHeard;
|
|
15383
15409
|
this.earlyHeard = null;
|
|
15384
15410
|
if (early && early.at >= at) {
|
|
@@ -15387,9 +15413,99 @@ var VoiceCall = class {
|
|
|
15387
15413
|
}
|
|
15388
15414
|
this.progress.turn();
|
|
15389
15415
|
this.o.onMetric({ name: "turn", id: t.id, kind: t.kind, text: t.text });
|
|
15390
|
-
this.
|
|
15416
|
+
if (this.quickOn) {
|
|
15417
|
+
const last = this.history.at(-1);
|
|
15418
|
+
if (t.kind !== "new" && last?.who === "user") last.text = t.text;
|
|
15419
|
+
else this.history.push({ who: "user", text: t.text });
|
|
15420
|
+
}
|
|
15421
|
+
if (quick) return void this.quickTurn(this.cur, t);
|
|
15422
|
+
this.o.sendTurn(t.text, { id: t.id, ...t.replaces && (!this.quickOn || prev?.lane === "deep") ? { replaces: t.replaces } : {} });
|
|
15391
15423
|
if (t.kind === "new") this.fill.onUserTurn(t.text, now3 - at, this.o.heardCut?.() ?? void 0);
|
|
15392
15424
|
}
|
|
15425
|
+
/** A MAIN reply cut while it played: the history keeps the part heard; a resume may say the rest. */
|
|
15426
|
+
logCut() {
|
|
15427
|
+
const c = this.cutTurn;
|
|
15428
|
+
this.cutTurn = void 0;
|
|
15429
|
+
if (!c || c.cutRead) return;
|
|
15430
|
+
c.cutRead = true;
|
|
15431
|
+
this.cutRest = "";
|
|
15432
|
+
const heard = this.o.heardCut?.() ?? null;
|
|
15433
|
+
if (heard === null) return void this.logReply(c);
|
|
15434
|
+
if (c.logged) Object.assign(c.logged, { text: heard, cut: true });
|
|
15435
|
+
else this.history.push(c.logged = { who: "you", text: heard, cut: true });
|
|
15436
|
+
this.cutRest = this.o.cutRest?.() ?? "";
|
|
15437
|
+
}
|
|
15438
|
+
logReply(c) {
|
|
15439
|
+
if (c.lane !== "deep" || c.logged || !c.reply.trim()) return;
|
|
15440
|
+
this.history.push(c.logged = { who: "you", text: c.reply.replace(/\[[a-z ]+\]\s*/gi, "").trim() });
|
|
15441
|
+
}
|
|
15442
|
+
/** The quick lane owns this turn: it answers, acks and hands it to MAIN, resumes a cut answer, or stays quiet. A late
|
|
15443
|
+
* or unusable decision hands the turn to MAIN as before (the fill channel's bridge covers it). */
|
|
15444
|
+
async quickTurn(c, t) {
|
|
15445
|
+
const ac = new AbortController(), t0 = this.o.now(), lang = this.lang, rest = this.cutRest;
|
|
15446
|
+
c.ask = ac;
|
|
15447
|
+
const late = setTimeout(() => ac.abort(), this.o.quickBudgetMs);
|
|
15448
|
+
const mv = lang ? await this.o.quick({ history: this.history.slice(0, -1), heard: t.text, lang, rest }, ac.signal).catch((e) => {
|
|
15449
|
+
if (this.cur === c) log32.warn(`quick lane ${ac.signal.aborted ? `late (${this.o.quickBudgetMs}ms)` : `failed: ${e?.message ?? e}`} \u2014 deep lane`);
|
|
15450
|
+
return null;
|
|
15451
|
+
}).finally(() => clearTimeout(late)) : null;
|
|
15452
|
+
if (this.ended || this.cur !== c || c.closed) return;
|
|
15453
|
+
c.ask = void 0;
|
|
15454
|
+
this.o.onMetric({ name: "lane", id: c.id, kind: mv?.kind ?? "fallback", ms: Math.round(this.o.now() - t0), ...mv && "line" in mv && mv.line ? { text: mv.line } : mv?.kind === "deep" && mv.ack ? { text: mv.ack } : {} });
|
|
15455
|
+
const note = (n) => this.o.noteTurn?.(`[${n}]`);
|
|
15456
|
+
if (!mv || mv.kind === "deep") {
|
|
15457
|
+
c.lane = "deep";
|
|
15458
|
+
c.running = true;
|
|
15459
|
+
this.cutRest = "";
|
|
15460
|
+
const ack = mv?.kind === "deep" ? mv.ack : "", brief = mv?.kind === "deep" ? mv.brief : "";
|
|
15461
|
+
if (ack) {
|
|
15462
|
+
note(`You (the call's quick voice) already told them aloud: "${ack}". Do not acknowledge again \u2014 start with the answer itself.${brief && brief !== t.text ? ` It took their words to mean: ${brief}.` : ""}`);
|
|
15463
|
+
this.history.push({ who: "you", text: ack });
|
|
15464
|
+
}
|
|
15465
|
+
this.o.sendTurn(t.text, { id: t.id });
|
|
15466
|
+
if (!ack) return void this.fill.onUserTurn(t.text, this.o.now() - c.at, this.o.heardCut?.() ?? void 0);
|
|
15467
|
+
this.gate.replyStarted(c.id);
|
|
15468
|
+
if (await this.sayRetry(ack, "ack", c.id)) {
|
|
15469
|
+
this.o.show(ack, "ack");
|
|
15470
|
+
if (this.cur === c && c.running) this.beat(c);
|
|
15471
|
+
}
|
|
15472
|
+
return;
|
|
15473
|
+
}
|
|
15474
|
+
c.lane = "quick";
|
|
15475
|
+
if (mv.kind === "quiet") {
|
|
15476
|
+
c.due = false;
|
|
15477
|
+
return this.close(c, "silent");
|
|
15478
|
+
}
|
|
15479
|
+
const said = mv.kind === "resume" ? `${mv.line} ${rest}`.trim() : mv.line;
|
|
15480
|
+
this.gate.replyStarted(c.id);
|
|
15481
|
+
if (!await this.sayRetry(said, "reply", c.id)) return this.close(c, "silent");
|
|
15482
|
+
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
|
+
if (mv.kind === "resume") {
|
|
15489
|
+
this.cutRest = "";
|
|
15490
|
+
this.o.dropCut?.();
|
|
15491
|
+
this.history.push({ who: "you", text: rest });
|
|
15492
|
+
note(`They asked you to go on, and you continued your cut answer aloud: "${rest}". All of it has now been said.`);
|
|
15493
|
+
} else {
|
|
15494
|
+
this.history.push({ who: "you", text: said });
|
|
15495
|
+
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
|
+
}
|
|
15497
|
+
this.close(c, "answered");
|
|
15498
|
+
}
|
|
15499
|
+
/** say(), retried while the host's player is busy (up to 2s). */
|
|
15500
|
+
async sayRetry(line, kind, id) {
|
|
15501
|
+
for (let i = 0; i < 8; i++) {
|
|
15502
|
+
if (this.ended) return false;
|
|
15503
|
+
if (this.say(line, kind) !== false) return true;
|
|
15504
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
15505
|
+
}
|
|
15506
|
+
this.o.onMetric({ name: "drop", id, kind: `${kind} unplayed`, text: line });
|
|
15507
|
+
return false;
|
|
15508
|
+
}
|
|
15393
15509
|
onDrop(text, why) {
|
|
15394
15510
|
if (!this.gate.holding) {
|
|
15395
15511
|
this.firstFinalAt = null;
|
|
@@ -15413,7 +15529,7 @@ var VoiceCall = class {
|
|
|
15413
15529
|
this.o.onMetric({ name: "fill", kind, text, lang: this.lang });
|
|
15414
15530
|
if (kind !== "backchannel") this.progress.heard();
|
|
15415
15531
|
const c = this.cur && !this.cur.closed ? this.cur : void 0;
|
|
15416
|
-
const forTurn = !!c && (kind === "bridge" || kind === "progress" || kind === "filler" && c.running && !c.sounded);
|
|
15532
|
+
const forTurn = !!c && (kind === "bridge" || kind === "progress" || kind === "ack" || kind === "reply" || kind === "filler" && c.running && !c.sounded);
|
|
15417
15533
|
if (c && forTurn && c.marks.fill === void 0) {
|
|
15418
15534
|
c.marks.fill = this.o.now();
|
|
15419
15535
|
c.fillKind = kind;
|
|
@@ -15423,7 +15539,7 @@ var VoiceCall = class {
|
|
|
15423
15539
|
this.lastAudibleAt = this.o.now();
|
|
15424
15540
|
if (c && forTurn) {
|
|
15425
15541
|
c.marks.fillAudio ??= this.o.now();
|
|
15426
|
-
this.sounded(c, kind === "progress" ? "progress" : "fill");
|
|
15542
|
+
this.sounded(c, kind === "progress" ? "progress" : kind === "ack" || kind === "reply" ? "quick" : "fill");
|
|
15427
15543
|
}
|
|
15428
15544
|
return r;
|
|
15429
15545
|
}
|
|
@@ -15437,6 +15553,8 @@ var VoiceCall = class {
|
|
|
15437
15553
|
close(c, end) {
|
|
15438
15554
|
if (c.closed) return;
|
|
15439
15555
|
c.closed = true;
|
|
15556
|
+
c.ask?.abort();
|
|
15557
|
+
this.logReply(c);
|
|
15440
15558
|
c.end = c.worded ? "answered" : end ?? c.end ?? "silent";
|
|
15441
15559
|
if (!c.worded) this.o.onMetric({ name: "first_word", id: c.id, by: "main", kind: c.end });
|
|
15442
15560
|
const rel = (t) => t === void 0 ? void 0 : Math.round(t - c.at);
|
|
@@ -15473,17 +15591,13 @@ var VoiceCall = class {
|
|
|
15473
15591
|
const line = own || (this.o.mode === "live" ? "" : answer);
|
|
15474
15592
|
const stop = /^\s*stop\s*:/i.test(raw), change = !answer || /^\s*work\s*:/i.test(raw);
|
|
15475
15593
|
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
|
+
this.history.push({ who: "user", text: t.text });
|
|
15476
15595
|
if (line && !this.ended) {
|
|
15477
|
-
|
|
15478
|
-
if (i === 7) {
|
|
15479
|
-
this.o.onMetric({ name: "drop", id: t.id, kind: "aside unplayed", text: line });
|
|
15480
|
-
break;
|
|
15481
|
-
}
|
|
15482
|
-
await new Promise((r) => setTimeout(r, 250));
|
|
15483
|
-
}
|
|
15596
|
+
await this.sayRetry(line, "aside", t.id);
|
|
15484
15597
|
if (this.lastAudibleAt >= at) {
|
|
15485
15598
|
this.progress.note(line);
|
|
15486
15599
|
this.o.show(line, "aside");
|
|
15600
|
+
this.history.push({ who: "you", text: line });
|
|
15487
15601
|
}
|
|
15488
15602
|
} else if (!line) this.o.onMetric({ name: "drop", id: t.id, kind: "no aside line" });
|
|
15489
15603
|
if (stop) {
|