@absolutejs/voice 0.0.22-beta.397 → 0.0.22-beta.399

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.
@@ -18,6 +18,7 @@ export { VoiceTurnQuality } from './VoiceTurnQuality';
18
18
  export { useVoiceOpsStatus } from './useVoiceOpsStatus';
19
19
  export { useVoicePlatformCoverage } from './useVoicePlatformCoverage';
20
20
  export { useVoiceProofTrends } from './useVoiceProofTrends';
21
+ export { useVoiceSessionSnapshot } from './useVoiceSessionSnapshot';
21
22
  export { useVoiceProfileComparison } from './useVoiceProfileComparison';
22
23
  export { useVoiceProfileSwitchRecommendation } from './useVoiceProfileSwitchRecommendation';
23
24
  export { useVoiceReadinessFailures } from './useVoiceReadinessFailures';
@@ -8871,9 +8871,122 @@ var VoiceTurnQuality = ({
8871
8871
  ]
8872
8872
  }, undefined, true, undefined, this);
8873
8873
  };
8874
- // src/react/useVoiceLiveOps.tsx
8874
+ // src/react/useVoiceSessionSnapshot.tsx
8875
8875
  import { useEffect as useEffect18, useRef as useRef18, useSyncExternalStore as useSyncExternalStore18 } from "react";
8876
8876
 
8877
+ // src/client/sessionSnapshot.ts
8878
+ var withTurnId = (path, turnId) => {
8879
+ if (!turnId) {
8880
+ return path;
8881
+ }
8882
+ const url = new URL(path, "http://absolutejs.local");
8883
+ url.searchParams.set("turnId", turnId);
8884
+ return `${url.pathname}${url.search}`;
8885
+ };
8886
+ var fetchVoiceSessionSnapshot = async (path, options = {}) => {
8887
+ const fetchImpl = options.fetch ?? globalThis.fetch;
8888
+ const response = await fetchImpl(withTurnId(path, options.turnId));
8889
+ if (!response.ok) {
8890
+ throw new Error(`Voice session snapshot failed: HTTP ${response.status}`);
8891
+ }
8892
+ return await response.json();
8893
+ };
8894
+ var createVoiceSessionSnapshotStore = (path, options = {}) => {
8895
+ const listeners = new Set;
8896
+ let closed = false;
8897
+ let timer;
8898
+ let snapshot = {
8899
+ error: null,
8900
+ isLoading: false
8901
+ };
8902
+ const emit = () => {
8903
+ for (const listener of listeners) {
8904
+ listener();
8905
+ }
8906
+ };
8907
+ const refresh = async () => {
8908
+ if (closed) {
8909
+ return snapshot.snapshot;
8910
+ }
8911
+ snapshot = { ...snapshot, error: null, isLoading: true };
8912
+ emit();
8913
+ try {
8914
+ const next = await fetchVoiceSessionSnapshot(path, options);
8915
+ snapshot = {
8916
+ error: null,
8917
+ isLoading: false,
8918
+ snapshot: next,
8919
+ updatedAt: Date.now()
8920
+ };
8921
+ emit();
8922
+ return next;
8923
+ } catch (error) {
8924
+ snapshot = {
8925
+ ...snapshot,
8926
+ error: error instanceof Error ? error.message : String(error),
8927
+ isLoading: false
8928
+ };
8929
+ emit();
8930
+ throw error;
8931
+ }
8932
+ };
8933
+ const download = () => {
8934
+ const current = snapshot.snapshot;
8935
+ if (current === undefined) {
8936
+ throw new Error("Voice session snapshot has not been loaded.");
8937
+ }
8938
+ return new Blob([JSON.stringify(current, null, 2)], {
8939
+ type: "application/json"
8940
+ });
8941
+ };
8942
+ const close = () => {
8943
+ closed = true;
8944
+ if (timer) {
8945
+ clearInterval(timer);
8946
+ timer = undefined;
8947
+ }
8948
+ listeners.clear();
8949
+ };
8950
+ if (options.intervalMs && options.intervalMs > 0) {
8951
+ timer = setInterval(() => {
8952
+ refresh().catch(() => {});
8953
+ }, options.intervalMs);
8954
+ }
8955
+ return {
8956
+ close,
8957
+ download,
8958
+ getServerSnapshot: () => snapshot,
8959
+ getSnapshot: () => snapshot,
8960
+ refresh,
8961
+ subscribe: (listener) => {
8962
+ listeners.add(listener);
8963
+ return () => {
8964
+ listeners.delete(listener);
8965
+ };
8966
+ }
8967
+ };
8968
+ };
8969
+
8970
+ // src/react/useVoiceSessionSnapshot.tsx
8971
+ var useVoiceSessionSnapshot = (path, options = {}) => {
8972
+ const storeRef = useRef18(null);
8973
+ if (!storeRef.current) {
8974
+ storeRef.current = createVoiceSessionSnapshotStore(path, options);
8975
+ }
8976
+ const store = storeRef.current;
8977
+ useEffect18(() => {
8978
+ store.refresh().catch(() => {});
8979
+ return () => store.close();
8980
+ }, [store]);
8981
+ return {
8982
+ ...useSyncExternalStore18(store.subscribe, store.getSnapshot, store.getServerSnapshot),
8983
+ download: store.download,
8984
+ refresh: store.refresh
8985
+ };
8986
+ };
8987
+ // src/react/useVoiceLiveOps.tsx
8988
+ import { useEffect as useEffect19, useRef as useRef19, useSyncExternalStore as useSyncExternalStore19 } from "react";
8989
+
8877
8990
  // src/client/liveOps.ts
8878
8991
  var postVoiceLiveOpsAction = async (input, options = {}) => {
8879
8992
  if (!input.sessionId) {
@@ -8962,19 +9075,19 @@ var createVoiceLiveOpsStore = (options = {}) => {
8962
9075
 
8963
9076
  // src/react/useVoiceLiveOps.tsx
8964
9077
  var useVoiceLiveOps = (options = {}) => {
8965
- const storeRef = useRef18(null);
9078
+ const storeRef = useRef19(null);
8966
9079
  if (!storeRef.current) {
8967
9080
  storeRef.current = createVoiceLiveOpsStore(options);
8968
9081
  }
8969
9082
  const store = storeRef.current;
8970
- useEffect18(() => () => store.close(), [store]);
9083
+ useEffect19(() => () => store.close(), [store]);
8971
9084
  return {
8972
- ...useSyncExternalStore18(store.subscribe, store.getSnapshot, store.getServerSnapshot),
9085
+ ...useSyncExternalStore19(store.subscribe, store.getSnapshot, store.getServerSnapshot),
8973
9086
  run: store.run
8974
9087
  };
8975
9088
  };
8976
9089
  // src/react/useVoiceCampaignDialerProof.tsx
8977
- import { useEffect as useEffect19, useRef as useRef19, useSyncExternalStore as useSyncExternalStore19 } from "react";
9090
+ import { useEffect as useEffect20, useRef as useRef20, useSyncExternalStore as useSyncExternalStore20 } from "react";
8978
9091
 
8979
9092
  // src/client/campaignDialerProof.ts
8980
9093
  var fetchVoiceCampaignDialerProofStatus = async (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
@@ -9096,23 +9209,23 @@ var createVoiceCampaignDialerProofStore = (path = "/api/voice/campaigns/dialer-p
9096
9209
 
9097
9210
  // src/react/useVoiceCampaignDialerProof.tsx
9098
9211
  var useVoiceCampaignDialerProof = (path = "/api/voice/campaigns/dialer-proof", options = {}) => {
9099
- const storeRef = useRef19(null);
9212
+ const storeRef = useRef20(null);
9100
9213
  if (!storeRef.current) {
9101
9214
  storeRef.current = createVoiceCampaignDialerProofStore(path, options);
9102
9215
  }
9103
9216
  const store = storeRef.current;
9104
- useEffect19(() => {
9217
+ useEffect20(() => {
9105
9218
  store.refresh().catch(() => {});
9106
9219
  return () => store.close();
9107
9220
  }, [store]);
9108
9221
  return {
9109
- ...useSyncExternalStore19(store.subscribe, store.getSnapshot, store.getServerSnapshot),
9222
+ ...useSyncExternalStore20(store.subscribe, store.getSnapshot, store.getServerSnapshot),
9110
9223
  refresh: store.refresh,
9111
9224
  runProof: store.runProof
9112
9225
  };
9113
9226
  };
9114
9227
  // src/react/useVoiceStream.tsx
9115
- import { useEffect as useEffect20, useRef as useRef20, useSyncExternalStore as useSyncExternalStore20 } from "react";
9228
+ import { useEffect as useEffect21, useRef as useRef21, useSyncExternalStore as useSyncExternalStore21 } from "react";
9116
9229
 
9117
9230
  // src/client/actions.ts
9118
9231
  var normalizeErrorMessage = (value) => {
@@ -10523,13 +10636,13 @@ var EMPTY_SNAPSHOT = {
10523
10636
  turns: []
10524
10637
  };
10525
10638
  var useVoiceStream = (path, options = {}) => {
10526
- const streamRef = useRef20(null);
10639
+ const streamRef = useRef21(null);
10527
10640
  if (!streamRef.current) {
10528
10641
  streamRef.current = createVoiceStream(path, options);
10529
10642
  }
10530
10643
  const stream = streamRef.current;
10531
- useEffect20(() => () => stream.close(), [stream]);
10532
- const snapshot = useSyncExternalStore20(stream.subscribe, stream.getSnapshot, stream.getServerSnapshot) ?? EMPTY_SNAPSHOT;
10644
+ useEffect21(() => () => stream.close(), [stream]);
10645
+ const snapshot = useSyncExternalStore21(stream.subscribe, stream.getSnapshot, stream.getServerSnapshot) ?? EMPTY_SNAPSHOT;
10533
10646
  return {
10534
10647
  ...snapshot,
10535
10648
  callControl: (message) => stream.callControl(message),
@@ -10539,7 +10652,7 @@ var useVoiceStream = (path, options = {}) => {
10539
10652
  };
10540
10653
  };
10541
10654
  // src/react/useVoiceController.tsx
10542
- import { useEffect as useEffect21, useRef as useRef21, useSyncExternalStore as useSyncExternalStore21 } from "react";
10655
+ import { useEffect as useEffect22, useRef as useRef22, useSyncExternalStore as useSyncExternalStore22 } from "react";
10543
10656
 
10544
10657
  // src/client/htmx.ts
10545
10658
  var DEFAULT_EVENT_NAME = "voice-refresh";
@@ -11207,13 +11320,13 @@ var EMPTY_SNAPSHOT2 = {
11207
11320
  turns: []
11208
11321
  };
11209
11322
  var useVoiceController = (path, options = {}) => {
11210
- const controllerRef = useRef21(null);
11323
+ const controllerRef = useRef22(null);
11211
11324
  if (!controllerRef.current) {
11212
11325
  controllerRef.current = createVoiceController(path, options);
11213
11326
  }
11214
11327
  const controller = controllerRef.current;
11215
- useEffect21(() => () => controller.close(), [controller]);
11216
- const snapshot = useSyncExternalStore21(controller.subscribe, controller.getSnapshot, controller.getServerSnapshot) ?? EMPTY_SNAPSHOT2;
11328
+ useEffect22(() => () => controller.close(), [controller]);
11329
+ const snapshot = useSyncExternalStore22(controller.subscribe, controller.getSnapshot, controller.getServerSnapshot) ?? EMPTY_SNAPSHOT2;
11217
11330
  return {
11218
11331
  ...snapshot,
11219
11332
  bindHTMX: controller.bindHTMX,
@@ -11227,7 +11340,7 @@ var useVoiceController = (path, options = {}) => {
11227
11340
  };
11228
11341
  };
11229
11342
  // src/react/useVoiceWorkflowStatus.tsx
11230
- import { useEffect as useEffect22, useRef as useRef22, useSyncExternalStore as useSyncExternalStore22 } from "react";
11343
+ import { useEffect as useEffect23, useRef as useRef23, useSyncExternalStore as useSyncExternalStore23 } from "react";
11231
11344
 
11232
11345
  // src/client/workflowStatus.ts
11233
11346
  var fetchVoiceWorkflowStatus = async (path = "/evals/scenarios/json", options = {}) => {
@@ -11310,17 +11423,17 @@ var createVoiceWorkflowStatusStore = (path = "/evals/scenarios/json", options =
11310
11423
 
11311
11424
  // src/react/useVoiceWorkflowStatus.tsx
11312
11425
  var useVoiceWorkflowStatus = (path = "/evals/scenarios/json", options = {}) => {
11313
- const storeRef = useRef22(null);
11426
+ const storeRef = useRef23(null);
11314
11427
  if (!storeRef.current) {
11315
11428
  storeRef.current = createVoiceWorkflowStatusStore(path, options);
11316
11429
  }
11317
11430
  const store = storeRef.current;
11318
- useEffect22(() => {
11431
+ useEffect23(() => {
11319
11432
  store.refresh().catch(() => {});
11320
11433
  return () => store.close();
11321
11434
  }, [store]);
11322
11435
  return {
11323
- ...useSyncExternalStore22(store.subscribe, store.getSnapshot, store.getServerSnapshot),
11436
+ ...useSyncExternalStore23(store.subscribe, store.getSnapshot, store.getServerSnapshot),
11324
11437
  refresh: store.refresh
11325
11438
  };
11326
11439
  };
@@ -11330,6 +11443,7 @@ export {
11330
11443
  useVoiceTurnLatency,
11331
11444
  useVoiceTraceTimeline,
11332
11445
  useVoiceStream,
11446
+ useVoiceSessionSnapshot,
11333
11447
  useVoiceRoutingStatus,
11334
11448
  useVoiceReadinessFailures,
11335
11449
  useVoiceProviderStatus,
@@ -0,0 +1,9 @@
1
+ import { type VoiceSessionSnapshotClientOptions } from '../client/sessionSnapshot';
2
+ export declare const useVoiceSessionSnapshot: (path: string, options?: VoiceSessionSnapshotClientOptions) => {
3
+ download: () => Blob;
4
+ refresh: () => Promise<import("..").VoiceSessionSnapshot | undefined>;
5
+ error: string | null;
6
+ isLoading: boolean;
7
+ snapshot?: import("..").VoiceSessionSnapshot;
8
+ updatedAt?: number;
9
+ };
@@ -1,3 +1,4 @@
1
+ import { Elysia } from 'elysia';
1
2
  import type { MediaProcessorGraphSnapshot } from '@absolutejs/media';
2
3
  import type { VoiceProofAssertionResult, VoiceProofAssertionSummary } from './proofAssertions';
3
4
  import type { VoiceCampaignTelephonyOutcomeSnapshot } from './campaign';
@@ -34,6 +35,19 @@ export type VoiceSessionSnapshotInput = {
34
35
  telephonyOutcomes?: readonly VoiceCampaignTelephonyOutcomeSnapshot[];
35
36
  turnId?: string;
36
37
  };
38
+ export type VoiceSessionSnapshotRouteSourceInput = {
39
+ request: Request;
40
+ sessionId: string;
41
+ turnId?: string;
42
+ };
43
+ export type VoiceSessionSnapshotRouteSource = VoiceSessionSnapshot | VoiceSessionSnapshotInput | ((input: VoiceSessionSnapshotRouteSourceInput) => Promise<VoiceSessionSnapshot | VoiceSessionSnapshotInput> | VoiceSessionSnapshot | VoiceSessionSnapshotInput);
44
+ export type VoiceSessionSnapshotRoutesOptions = Partial<VoiceSessionSnapshotInput> & {
45
+ downloadPath?: false | string;
46
+ headers?: HeadersInit;
47
+ name?: string;
48
+ path?: string;
49
+ source?: VoiceSessionSnapshotRouteSource;
50
+ };
37
51
  export declare const buildVoiceSessionSnapshotStatus: (input: {
38
52
  media?: readonly Pick<MediaProcessorGraphSnapshot, "report">[];
39
53
  proofSummary?: Pick<VoiceProofAssertionSummary, "ok">;
@@ -42,3 +56,43 @@ export declare const buildVoiceSessionSnapshotStatus: (input: {
42
56
  }) => VoiceSessionSnapshotStatus;
43
57
  export declare const buildVoiceSessionSnapshot: (input: VoiceSessionSnapshotInput) => VoiceSessionSnapshot;
44
58
  export declare const parseVoiceSessionSnapshot: (snapshot: VoiceSessionSnapshot) => VoiceSessionSnapshot;
59
+ export declare const createVoiceSessionSnapshotRoutes: (options?: VoiceSessionSnapshotRoutesOptions) => Elysia<"", {
60
+ decorator: {};
61
+ store: {};
62
+ derive: {};
63
+ resolve: {};
64
+ }, {
65
+ typebox: {};
66
+ error: {};
67
+ }, {
68
+ schema: {};
69
+ standaloneSchema: {};
70
+ macro: {};
71
+ macroFn: {};
72
+ parser: {};
73
+ response: {};
74
+ }, {
75
+ [x: string]: {
76
+ get: {
77
+ body: unknown;
78
+ params: {};
79
+ query: unknown;
80
+ headers: unknown;
81
+ response: {
82
+ 200: Response;
83
+ };
84
+ };
85
+ };
86
+ }, {
87
+ derive: {};
88
+ resolve: {};
89
+ schema: {};
90
+ standaloneSchema: {};
91
+ response: {};
92
+ }, {
93
+ derive: {};
94
+ resolve: {};
95
+ schema: {};
96
+ standaloneSchema: {};
97
+ response: {};
98
+ }>;
@@ -0,0 +1,9 @@
1
+ import { type VoiceSessionSnapshotClientOptions } from '../client/sessionSnapshot';
2
+ export declare const createVoiceSessionSnapshot: (path: string, options?: VoiceSessionSnapshotClientOptions) => {
3
+ close: () => void;
4
+ download: () => Blob;
5
+ getServerSnapshot: () => import("../client").VoiceSessionSnapshotClientState;
6
+ getSnapshot: () => import("../client").VoiceSessionSnapshotClientState;
7
+ refresh: () => Promise<import("..").VoiceSessionSnapshot | undefined>;
8
+ subscribe: (listener: () => void) => () => void;
9
+ };
@@ -5,6 +5,7 @@ export { createVoiceLiveOps } from './createVoiceLiveOps';
5
5
  export { createVoiceOpsStatus } from './createVoiceOpsStatus';
6
6
  export { createVoicePlatformCoverage } from './createVoicePlatformCoverage';
7
7
  export { createVoiceProofTrends } from './createVoiceProofTrends';
8
+ export { createVoiceSessionSnapshot } from './createVoiceSessionSnapshot';
8
9
  export { createVoiceProfileComparison } from './createVoiceProfileComparison';
9
10
  export { createVoiceReadinessFailures } from './createVoiceReadinessFailures';
10
11
  export { createVoiceProviderSimulationControls } from './createVoiceProviderSimulationControls';
@@ -2629,6 +2629,101 @@ var createVoiceProofTrends = (path = "/api/voice/proof-trends", options = {}) =>
2629
2629
  subscribe: store.subscribe
2630
2630
  };
2631
2631
  };
2632
+ // src/client/sessionSnapshot.ts
2633
+ var withTurnId = (path, turnId) => {
2634
+ if (!turnId) {
2635
+ return path;
2636
+ }
2637
+ const url = new URL(path, "http://absolutejs.local");
2638
+ url.searchParams.set("turnId", turnId);
2639
+ return `${url.pathname}${url.search}`;
2640
+ };
2641
+ var fetchVoiceSessionSnapshot = async (path, options = {}) => {
2642
+ const fetchImpl = options.fetch ?? globalThis.fetch;
2643
+ const response = await fetchImpl(withTurnId(path, options.turnId));
2644
+ if (!response.ok) {
2645
+ throw new Error(`Voice session snapshot failed: HTTP ${response.status}`);
2646
+ }
2647
+ return await response.json();
2648
+ };
2649
+ var createVoiceSessionSnapshotStore = (path, options = {}) => {
2650
+ const listeners = new Set;
2651
+ let closed = false;
2652
+ let timer;
2653
+ let snapshot = {
2654
+ error: null,
2655
+ isLoading: false
2656
+ };
2657
+ const emit = () => {
2658
+ for (const listener of listeners) {
2659
+ listener();
2660
+ }
2661
+ };
2662
+ const refresh = async () => {
2663
+ if (closed) {
2664
+ return snapshot.snapshot;
2665
+ }
2666
+ snapshot = { ...snapshot, error: null, isLoading: true };
2667
+ emit();
2668
+ try {
2669
+ const next = await fetchVoiceSessionSnapshot(path, options);
2670
+ snapshot = {
2671
+ error: null,
2672
+ isLoading: false,
2673
+ snapshot: next,
2674
+ updatedAt: Date.now()
2675
+ };
2676
+ emit();
2677
+ return next;
2678
+ } catch (error) {
2679
+ snapshot = {
2680
+ ...snapshot,
2681
+ error: error instanceof Error ? error.message : String(error),
2682
+ isLoading: false
2683
+ };
2684
+ emit();
2685
+ throw error;
2686
+ }
2687
+ };
2688
+ const download = () => {
2689
+ const current = snapshot.snapshot;
2690
+ if (current === undefined) {
2691
+ throw new Error("Voice session snapshot has not been loaded.");
2692
+ }
2693
+ return new Blob([JSON.stringify(current, null, 2)], {
2694
+ type: "application/json"
2695
+ });
2696
+ };
2697
+ const close = () => {
2698
+ closed = true;
2699
+ if (timer) {
2700
+ clearInterval(timer);
2701
+ timer = undefined;
2702
+ }
2703
+ listeners.clear();
2704
+ };
2705
+ if (options.intervalMs && options.intervalMs > 0) {
2706
+ timer = setInterval(() => {
2707
+ refresh().catch(() => {});
2708
+ }, options.intervalMs);
2709
+ }
2710
+ return {
2711
+ close,
2712
+ download,
2713
+ getServerSnapshot: () => snapshot,
2714
+ getSnapshot: () => snapshot,
2715
+ refresh,
2716
+ subscribe: (listener) => {
2717
+ listeners.add(listener);
2718
+ return () => {
2719
+ listeners.delete(listener);
2720
+ };
2721
+ }
2722
+ };
2723
+ };
2724
+
2725
+ // src/svelte/createVoiceSessionSnapshot.ts
2726
+ var createVoiceSessionSnapshot = (path, options = {}) => createVoiceSessionSnapshotStore(path, options);
2632
2727
  // src/client/profileComparison.ts
2633
2728
  var fetchVoiceProfileComparison = async (path = "/api/voice/real-call-profile-history", options = {}) => {
2634
2729
  const fetchImpl = options.fetch ?? globalThis.fetch;
@@ -6719,6 +6814,7 @@ export {
6719
6814
  createVoiceTurnLatency,
6720
6815
  createVoiceTraceTimeline,
6721
6816
  createVoiceStream2 as createVoiceStream,
6817
+ createVoiceSessionSnapshot,
6722
6818
  createVoiceRoutingStatus,
6723
6819
  createVoiceReadinessFailures,
6724
6820
  createVoiceProviderStatus,
@@ -15,6 +15,7 @@ export { VoiceTurnQuality } from './VoiceTurnQuality';
15
15
  export { useVoiceOpsStatus } from './useVoiceOpsStatus';
16
16
  export { useVoicePlatformCoverage } from './useVoicePlatformCoverage';
17
17
  export { useVoiceProofTrends } from './useVoiceProofTrends';
18
+ export { useVoiceSessionSnapshot } from './useVoiceSessionSnapshot';
18
19
  export { useVoiceProfileComparison } from './useVoiceProfileComparison';
19
20
  export { useVoiceReadinessFailures } from './useVoiceReadinessFailures';
20
21
  export { useVoiceOpsActionCenter } from './useVoiceOpsActionCenter';