agent.libx.js 0.92.5 → 0.92.6

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 CHANGED
@@ -3978,9 +3978,20 @@ var VoiceEngine = class {
3978
3978
  echoActive() {
3979
3979
  return this.speaking || now() < this.echoUntil;
3980
3980
  }
3981
+ /** Genuine user speech vs our own bleed (AEC tier): novel words must DOMINATE, not merely exist.
3982
+ * Degraded AEC + an STT mis-hearing manufactures a single novel word out of pure echo (a name or
3983
+ * rare word in our own reply comes back transcribed slightly differently — 1 novel / N words).
3984
+ * A real interjection is mostly novel ("stop", "wait what") — short utterances pass on ratio,
3985
+ * longer ones on count. */
3986
+ genuine(text) {
3987
+ const total = this.words(text).length;
3988
+ const novel = this.novelWords(text).length;
3989
+ if (!novel) return false;
3990
+ return novel >= 2 || novel / Math.max(1, total) > 0.5;
3991
+ }
3981
3992
  handlePartial(text) {
3982
3993
  if (this.speaking) {
3983
- const barge = this.novelWords(text).length >= (this.usingAec ? 1 : this.suspectUntil ? 1 : 2);
3994
+ const barge = this.usingAec ? this.genuine(text) : this.novelWords(text).length >= (this.suspectUntil ? 1 : 2);
3984
3995
  if (barge) {
3985
3996
  const phase = this.ctxOpen ? "speaking" : "drain";
3986
3997
  this.interrupt();
@@ -3994,10 +4005,10 @@ var VoiceEngine = class {
3994
4005
  this.pendingTimer = null;
3995
4006
  }
3996
4007
  }
3997
- if (!this.echoActive() || this.novelWords(text).length >= 1) this.options.onPartial(text);
4008
+ if (!this.echoActive() || (this.usingAec ? this.genuine(text) : this.novelWords(text).length >= 1)) this.options.onPartial(text);
3998
4009
  }
3999
4010
  handleUtterance(text) {
4000
- if (this.echoActive() && this.novelWords(text).length < (this.usingAec ? 1 : 2)) {
4011
+ if (this.echoActive() && (this.usingAec ? !this.genuine(text) : this.novelWords(text).length < 2)) {
4001
4012
  this.stt.reset();
4002
4013
  return;
4003
4014
  }