@livx.cc/agentx 0.99.161 → 0.99.162

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/index.d.ts CHANGED
@@ -1002,6 +1002,9 @@ declare class TurnGate {
1002
1002
  text: string;
1003
1003
  started: boolean;
1004
1004
  } | undefined;
1005
+ /** The user's own line is not over: a fragment is held, or the last turn went out mid-phrase ("where is the—") within
1006
+ * `withinMs`. Their next words finish it — never a reaction to the reply. */
1007
+ unfinished(withinMs: number): boolean;
1005
1008
  /** An STT final. */
1006
1009
  final(text: string, sttId?: string): void;
1007
1010
  /** The user kept talking after turn `id` went out and before its reply made a sound: it was not over. Its words go back
package/dist/index.js CHANGED
@@ -11405,6 +11405,11 @@ var TurnGate = class {
11405
11405
  get lastTurn() {
11406
11406
  return this.last && { id: this.last.id, text: this.last.text, started: this.last.started };
11407
11407
  }
11408
+ /** The user's own line is not over: a fragment is held, or the last turn went out mid-phrase ("where is the—") within
11409
+ * `withinMs`. Their next words finish it — never a reaction to the reply. */
11410
+ unfinished(withinMs) {
11411
+ return !!this.held || !!this.last && endsMidPhrase(this.last.text) && this.o.now() - this.last.at < withinMs;
11412
+ }
11408
11413
  /** An STT final. */
11409
11414
  final(text, sttId) {
11410
11415
  let t = text.trim(), replaces;
@@ -11500,7 +11505,7 @@ var TurnGate = class {
11500
11505
  }
11501
11506
  }
11502
11507
  refinal(last, t, key, sttId) {
11503
- if (!last.started) return this.send(t, key, sttId ?? last.sttId, "replace", last.id);
11508
+ if (!last.started || endsMidPhrase(last.text)) return this.send(t, key, sttId ?? last.sttId, "replace", last.id);
11504
11509
  const a = words2(last.text), b = words2(t);
11505
11510
  let i = 0;
11506
11511
  while (i < a.length && i < b.length && norm3(a[i]) === norm3(b[i])) i++;
@@ -15621,6 +15626,10 @@ var VoiceCall = class {
15621
15626
  }
15622
15627
  /** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
15623
15628
  async overlap(text) {
15629
+ if (this.gate.unfinished(UNFINISHED_MS)) {
15630
+ this.barge();
15631
+ return "cut";
15632
+ }
15624
15633
  if (this.o.mode === "live" && isReaction(text)) return this.kept(text), "keep";
15625
15634
  const d = await this.judge.judge(text);
15626
15635
  if (d.verdict === "cut") this.barge();
@@ -15998,6 +16007,7 @@ var VoiceCall = class {
15998
16007
  }
15999
16008
  }
16000
16009
  };
16010
+ var UNFINISHED_MS = 8e3;
16001
16011
  var BACK_TO = { en: "Anyway,", he: "\u05D1\u05DB\u05DC \u05DE\u05E7\u05E8\u05D4," };
16002
16012
  function cutSentence(heard) {
16003
16013
  const tail = heard.trim().split(/(?<=[.!?…])\s+/).at(-1) ?? "";