@absolutejs/voice 0.0.22-beta.550 → 0.0.22-beta.552

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.
@@ -516,6 +516,18 @@ export type VoiceSessionHandle<TContext = unknown, TSession extends VoiceSession
516
516
  }) => Promise<void>;
517
517
  close: (reason?: string) => Promise<void>;
518
518
  snapshot: () => Promise<TSession>;
519
+ /**
520
+ * Mutate the live turn-detection config for this session — useful when a
521
+ * tool call wants to dial silenceMs up ("the caller asked for more time")
522
+ * or down. The change takes effect on the NEXT silence-timer schedule, so
523
+ * an in-flight commit isn't cancelled. Returns the merged config so the
524
+ * caller can confirm.
525
+ */
526
+ setTurnDetection: (patch: Partial<VoiceTurnDetectionConfig>) => Promise<{
527
+ silenceMs: number;
528
+ speechThreshold: number;
529
+ transcriptStabilityMs: number;
530
+ }>;
519
531
  };
520
532
  export type VoiceRouteResult<TResult = unknown> = {
521
533
  complete?: boolean;
package/dist/index.js CHANGED
@@ -5904,6 +5904,22 @@ var createVoiceSession = (options) => {
5904
5904
  snapshot: async () => runSerial("api.snapshot", async () => readSession()),
5905
5905
  transfer: async (input) => runSerial("api.transfer", async () => {
5906
5906
  await transferInternal(input);
5907
+ }),
5908
+ setTurnDetection: async (patch) => runSerial("api.setTurnDetection", async () => {
5909
+ if (patch.silenceMs !== undefined && Number.isFinite(patch.silenceMs)) {
5910
+ turnDetection.silenceMs = Math.max(300, Math.min(15000, Math.round(patch.silenceMs)));
5911
+ }
5912
+ if (patch.speechThreshold !== undefined && Number.isFinite(patch.speechThreshold)) {
5913
+ turnDetection.speechThreshold = Math.max(0, Math.min(1, patch.speechThreshold));
5914
+ }
5915
+ if (patch.transcriptStabilityMs !== undefined && Number.isFinite(patch.transcriptStabilityMs)) {
5916
+ turnDetection.transcriptStabilityMs = Math.max(0, Math.min(5000, Math.round(patch.transcriptStabilityMs)));
5917
+ }
5918
+ return {
5919
+ silenceMs: turnDetection.silenceMs,
5920
+ speechThreshold: turnDetection.speechThreshold,
5921
+ transcriptStabilityMs: turnDetection.transcriptStabilityMs
5922
+ };
5907
5923
  })
5908
5924
  };
5909
5925
  return api;
@@ -24545,6 +24561,7 @@ var createTwilioMediaStreamBridge = (socket, options) => {
24545
24561
  stt: options.stt,
24546
24562
  sttFallback: resolveSTTFallbackConfig(options.sttFallback),
24547
24563
  sttLifecycle: options.sttLifecycle ?? runtimePreset.sttLifecycle,
24564
+ ...options.semanticTurnDetector ? { semanticTurnDetector: options.semanticTurnDetector } : {},
24548
24565
  trace: options.trace,
24549
24566
  tts: options.tts,
24550
24567
  turnDetection
@@ -43023,6 +43040,11 @@ var createContractApi = (session) => ({
43023
43040
  markNoAnswer: async () => {},
43024
43041
  markVoicemail: async () => {},
43025
43042
  receiveAudio: async () => {},
43043
+ setTurnDetection: async () => ({
43044
+ silenceMs: 0,
43045
+ speechThreshold: 0,
43046
+ transcriptStabilityMs: 0
43047
+ }),
43026
43048
  snapshot: async () => session,
43027
43049
  transfer: async () => {}
43028
43050
  });
@@ -115,6 +115,14 @@ export type TwilioMediaStreamBridgeOptions<TContext = unknown, TSession extends
115
115
  costTelephony?: {
116
116
  provider?: string;
117
117
  };
118
+ /**
119
+ * Per-transcript semantic end-of-turn detector. Called on every transcript
120
+ * event; an `endOfTurn=true` verdict EARLY-commits the turn (the runtime
121
+ * still falls back to `turnDetection.silenceMs` if the detector says
122
+ * `false`). Useful for raising silenceMs for thinking time while keeping
123
+ * snappy responses on clear-cut answers. See VoiceSemanticTurnDetector.
124
+ */
125
+ semanticTurnDetector?: import("../core/semanticTurn").VoiceSemanticTurnDetector;
118
126
  };
119
127
  export type TwilioMediaStreamBridge = {
120
128
  close: (reason?: string) => Promise<void>;
@@ -7721,6 +7721,22 @@ var createVoiceSession = (options) => {
7721
7721
  snapshot: async () => runSerial("api.snapshot", async () => readSession()),
7722
7722
  transfer: async (input) => runSerial("api.transfer", async () => {
7723
7723
  await transferInternal(input);
7724
+ }),
7725
+ setTurnDetection: async (patch) => runSerial("api.setTurnDetection", async () => {
7726
+ if (patch.silenceMs !== undefined && Number.isFinite(patch.silenceMs)) {
7727
+ turnDetection.silenceMs = Math.max(300, Math.min(15000, Math.round(patch.silenceMs)));
7728
+ }
7729
+ if (patch.speechThreshold !== undefined && Number.isFinite(patch.speechThreshold)) {
7730
+ turnDetection.speechThreshold = Math.max(0, Math.min(1, patch.speechThreshold));
7731
+ }
7732
+ if (patch.transcriptStabilityMs !== undefined && Number.isFinite(patch.transcriptStabilityMs)) {
7733
+ turnDetection.transcriptStabilityMs = Math.max(0, Math.min(5000, Math.round(patch.transcriptStabilityMs)));
7734
+ }
7735
+ return {
7736
+ silenceMs: turnDetection.silenceMs,
7737
+ speechThreshold: turnDetection.speechThreshold,
7738
+ transcriptStabilityMs: turnDetection.transcriptStabilityMs
7739
+ };
7724
7740
  })
7725
7741
  };
7726
7742
  return api;
@@ -13081,6 +13097,7 @@ var createTwilioMediaStreamBridge = (socket, options) => {
13081
13097
  stt: options.stt,
13082
13098
  sttFallback: resolveSTTFallbackConfig(options.sttFallback),
13083
13099
  sttLifecycle: options.sttLifecycle ?? runtimePreset.sttLifecycle,
13100
+ ...options.semanticTurnDetector ? { semanticTurnDetector: options.semanticTurnDetector } : {},
13084
13101
  trace: options.trace,
13085
13102
  tts: options.tts,
13086
13103
  turnDetection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.550",
3
+ "version": "0.0.22-beta.552",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",