@absolutejs/voice 0.0.22-beta.100 → 0.0.22-beta.101

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.
@@ -1758,6 +1758,23 @@ var createVoiceLiveTurnLatencyMonitor = (options = {}) => {
1758
1758
  listener();
1759
1759
  }
1760
1760
  };
1761
+ const reportCompletedEvent = async (event) => {
1762
+ await options.onComplete?.(event);
1763
+ if (!options.reportPath) {
1764
+ return;
1765
+ }
1766
+ const fetchImpl = options.fetch ?? globalThis.fetch;
1767
+ const response = await fetchImpl(options.reportPath, {
1768
+ body: JSON.stringify(event),
1769
+ headers: {
1770
+ "content-type": "application/json"
1771
+ },
1772
+ method: "POST"
1773
+ });
1774
+ if (!response.ok) {
1775
+ throw new Error(`Voice live turn latency report failed: HTTP ${response.status}`);
1776
+ }
1777
+ };
1761
1778
  const completePending = (input) => {
1762
1779
  if (!pending) {
1763
1780
  return;
@@ -1773,6 +1790,7 @@ var createVoiceLiveTurnLatencyMonitor = (options = {}) => {
1773
1790
  status
1774
1791
  };
1775
1792
  events = [pending, ...events].slice(0, maxEvents);
1793
+ reportCompletedEvent(pending).catch(() => {});
1776
1794
  pending = undefined;
1777
1795
  emit();
1778
1796
  };
@@ -26,7 +26,10 @@ export type VoiceLiveTurnLatencySnapshot = {
26
26
  export type VoiceLiveTurnLatencyMonitorOptions = {
27
27
  clock?: () => number;
28
28
  failAfterMs?: number;
29
+ fetch?: typeof fetch;
29
30
  maxEvents?: number;
31
+ onComplete?: (event: VoiceLiveTurnLatencyEvent) => Promise<void> | void;
32
+ reportPath?: string;
30
33
  speechThreshold?: number;
31
34
  warnAfterMs?: number;
32
35
  };
package/dist/index.js CHANGED
@@ -10017,6 +10017,8 @@ var timelineLabel = (event) => {
10017
10017
  return `Guardrail ${eventStatus(event) ?? "check"}`;
10018
10018
  case "call.handoff":
10019
10019
  return `Call handoff ${eventStatus(event) ?? ""}`.trim();
10020
+ case "client.live_latency":
10021
+ return `Live latency${eventElapsedMs(event) !== undefined ? ` ${eventElapsedMs(event)}ms` : ""}`;
10020
10022
  case "session.error":
10021
10023
  return `Error${getString9(event.payload.error) ? `: ${getString9(event.payload.error)}` : ""}`;
10022
10024
  case "turn.cost":
package/dist/trace.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type VoiceTraceEventType = 'assistant.guardrail' | 'assistant.memory' | 'assistant.run' | 'agent.handoff' | 'agent.model' | 'agent.result' | 'agent.tool' | 'call.handoff' | 'call.lifecycle' | 'client.barge_in' | 'session.error' | 'turn.assistant' | 'turn.committed' | 'turn.cost' | 'turn_latency.stage' | 'turn.transcript' | 'workflow.contract';
1
+ export type VoiceTraceEventType = 'assistant.guardrail' | 'assistant.memory' | 'assistant.run' | 'agent.handoff' | 'agent.model' | 'agent.result' | 'agent.tool' | 'call.handoff' | 'call.lifecycle' | 'client.barge_in' | 'client.live_latency' | 'session.error' | 'turn.assistant' | 'turn.committed' | 'turn.cost' | 'turn_latency.stage' | 'turn.transcript' | 'workflow.contract';
2
2
  export type VoiceTraceEvent<TPayload extends Record<string, unknown> = Record<string, unknown>> = {
3
3
  at: number;
4
4
  id?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.100",
3
+ "version": "0.0.22-beta.101",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",