agent.libx.js 0.92.8 → 0.92.9

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
@@ -855,6 +855,7 @@ declare class VoiceEngine {
855
855
  private pausedAt;
856
856
  private overlapLoud;
857
857
  private overlapLastLoudAt;
858
+ private loudTimes;
858
859
  private resumeTimer;
859
860
  constructor(options?: Partial<VoiceEngineOptions>);
860
861
  start(): Promise<void>;
package/dist/index.js CHANGED
@@ -3689,6 +3689,7 @@ ${recent}` : brief;
3689
3689
  let steps = 0;
3690
3690
  let inflight = null;
3691
3691
  const due = () => {
3692
+ if (this.pendingAsks.size) return void 0;
3692
3693
  const rec = this.tasks.get(id);
3693
3694
  return rec && rec.status === "running" && Date.now() - lastAt >= this.options.progressIntervalMs ? rec : void 0;
3694
3695
  };
@@ -4067,7 +4068,7 @@ var VoiceEngineOptions = class {
4067
4068
  * vocabulary) resume from the precise sample and are dropped. false disables. */
4068
4069
  overlapPause = true;
4069
4070
  /** sustained overlap ≥ this → cede the turn */
4070
- overlapSustainMs = 350;
4071
+ overlapSustainMs = 450;
4071
4072
  /** quiet for this long while paused → resume, drop the interjection */
4072
4073
  overlapResumeMs = 700;
4073
4074
  /** energy floor for "overlap candidate" — must sit ABOVE typical room ambient (~110 rms measured;
@@ -4109,6 +4110,8 @@ var VoiceEngine = class {
4109
4110
  // loud chunks since pause (sustain must be real sound, not two clicks)
4110
4111
  overlapLastLoudAt = 0;
4111
4112
  // continuity guard: a gap re-arms the onset (sparse noise ≠ sustained speech)
4113
+ loudTimes = [];
4114
+ // recent loud-chunk timestamps (sliding onset window)
4112
4115
  resumeTimer = null;
4113
4116
  constructor(options) {
4114
4117
  this.options = { ...new VoiceEngineOptions(), ...options };
@@ -4328,15 +4331,18 @@ var VoiceEngine = class {
4328
4331
  if (rms < o.overlapRms) return;
4329
4332
  const t = now();
4330
4333
  if (!this.pausedAt) {
4331
- this.overlapLoud = t - this.overlapLastLoudAt <= 60 ? this.overlapLoud + 1 : 1;
4332
- this.overlapLastLoudAt = t;
4333
- if (this.overlapLoud < 3) return;
4334
+ this.loudTimes = this.loudTimes.filter((x) => t - x < 400);
4335
+ this.loudTimes.push(t);
4336
+ if (this.loudTimes.length < 2) return;
4337
+ this.loudTimes = [];
4334
4338
  this.pausedAt = t;
4339
+ this.overlapLoud = 2;
4340
+ this.overlapLastLoudAt = t;
4335
4341
  this.player.pause();
4336
4342
  this.armResume();
4337
4343
  return;
4338
4344
  }
4339
- if (t - this.overlapLastLoudAt > 300) {
4345
+ if (t - this.overlapLastLoudAt > 450) {
4340
4346
  this.pausedAt = t;
4341
4347
  this.overlapLoud = 1;
4342
4348
  this.overlapLastLoudAt = t;
@@ -4345,7 +4351,7 @@ var VoiceEngine = class {
4345
4351
  }
4346
4352
  this.overlapLastLoudAt = t;
4347
4353
  this.overlapLoud++;
4348
- if (t - this.pausedAt >= o.overlapSustainMs && this.overlapLoud >= 4) {
4354
+ if (t - this.pausedAt >= o.overlapSustainMs && this.overlapLoud >= 3) {
4349
4355
  const phase = this.ctxOpen ? "speaking" : "drain";
4350
4356
  this.interrupt();
4351
4357
  this.options.onBargeIn(phase);
@@ -4369,6 +4375,7 @@ var VoiceEngine = class {
4369
4375
  if (this.pausedAt && resume) this.player.resume?.();
4370
4376
  this.pausedAt = 0;
4371
4377
  this.overlapLoud = 0;
4378
+ this.loudTimes = [];
4372
4379
  }
4373
4380
  /** energy two-stage barge-in (heuristic tier only): spike over echo baseline → pause + confirm via STT */
4374
4381
  handleLevel(rms) {