@absolutejs/voice 0.0.22-beta.12 → 0.0.22-beta.121

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.
Files changed (146) hide show
  1. package/README.md +411 -3
  2. package/dist/agent.d.ts +2 -0
  3. package/dist/angular/index.d.ts +9 -0
  4. package/dist/angular/index.js +1278 -44
  5. package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
  6. package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
  7. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  8. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  9. package/dist/angular/voice-provider-status.service.d.ts +12 -0
  10. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  11. package/dist/angular/voice-stream.service.d.ts +2 -0
  12. package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
  13. package/dist/angular/voice-turn-latency.service.d.ts +13 -0
  14. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  15. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  16. package/dist/appKit.d.ts +100 -0
  17. package/dist/assistantHealth.d.ts +81 -0
  18. package/dist/bargeInRoutes.d.ts +56 -0
  19. package/dist/campaign.d.ts +610 -0
  20. package/dist/campaignDialers.d.ts +90 -0
  21. package/dist/client/actions.d.ts +22 -0
  22. package/dist/client/appKitStatus.d.ts +19 -0
  23. package/dist/client/bargeInMonitor.d.ts +7 -0
  24. package/dist/client/campaignDialerProof.d.ts +23 -0
  25. package/dist/client/connection.d.ts +3 -0
  26. package/dist/client/duplex.d.ts +1 -1
  27. package/dist/client/htmxBootstrap.js +587 -13
  28. package/dist/client/index.d.ts +40 -0
  29. package/dist/client/index.js +2028 -8
  30. package/dist/client/liveTurnLatency.d.ts +41 -0
  31. package/dist/client/opsStatusWidget.d.ts +40 -0
  32. package/dist/client/providerCapabilities.d.ts +19 -0
  33. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  34. package/dist/client/providerSimulationControls.d.ts +33 -0
  35. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  36. package/dist/client/providerStatus.d.ts +19 -0
  37. package/dist/client/providerStatusWidget.d.ts +32 -0
  38. package/dist/client/routingStatus.d.ts +19 -0
  39. package/dist/client/routingStatusWidget.d.ts +28 -0
  40. package/dist/client/traceTimeline.d.ts +19 -0
  41. package/dist/client/traceTimelineWidget.d.ts +32 -0
  42. package/dist/client/turnLatency.d.ts +22 -0
  43. package/dist/client/turnLatencyWidget.d.ts +33 -0
  44. package/dist/client/turnQuality.d.ts +19 -0
  45. package/dist/client/turnQualityWidget.d.ts +32 -0
  46. package/dist/client/workflowStatus.d.ts +19 -0
  47. package/dist/diagnosticsRoutes.d.ts +44 -0
  48. package/dist/evalRoutes.d.ts +213 -0
  49. package/dist/fileStore.d.ts +3 -0
  50. package/dist/handoff.d.ts +54 -0
  51. package/dist/handoffHealth.d.ts +94 -0
  52. package/dist/index.d.ts +77 -8
  53. package/dist/index.js +12658 -3061
  54. package/dist/liveLatency.d.ts +78 -0
  55. package/dist/modelAdapters.d.ts +41 -2
  56. package/dist/openaiTTS.d.ts +18 -0
  57. package/dist/opsConsoleRoutes.d.ts +77 -0
  58. package/dist/opsWebhook.d.ts +126 -0
  59. package/dist/outcomeContract.d.ts +112 -0
  60. package/dist/phoneAgent.d.ts +58 -0
  61. package/dist/postgresStore.d.ts +5 -0
  62. package/dist/productionReadiness.d.ts +121 -0
  63. package/dist/providerAdapters.d.ts +48 -0
  64. package/dist/providerCapabilities.d.ts +92 -0
  65. package/dist/providerHealth.d.ts +79 -0
  66. package/dist/qualityRoutes.d.ts +76 -0
  67. package/dist/queue.d.ts +61 -0
  68. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  69. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  70. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  71. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  72. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  73. package/dist/react/VoiceTraceTimeline.d.ts +6 -0
  74. package/dist/react/VoiceTurnLatency.d.ts +6 -0
  75. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  76. package/dist/react/index.d.ts +18 -0
  77. package/dist/react/index.js +2606 -12
  78. package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
  79. package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
  80. package/dist/react/useVoiceController.d.ts +2 -0
  81. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  82. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  83. package/dist/react/useVoiceProviderStatus.d.ts +8 -0
  84. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  85. package/dist/react/useVoiceStream.d.ts +2 -0
  86. package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
  87. package/dist/react/useVoiceTurnLatency.d.ts +9 -0
  88. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  89. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  90. package/dist/resilienceRoutes.d.ts +142 -0
  91. package/dist/sessionReplay.d.ts +175 -0
  92. package/dist/simulationSuite.d.ts +120 -0
  93. package/dist/sqliteStore.d.ts +5 -0
  94. package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
  95. package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
  96. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  97. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  98. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  99. package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
  100. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  101. package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
  102. package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
  103. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  104. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  105. package/dist/svelte/index.d.ts +11 -0
  106. package/dist/svelte/index.js +1849 -4
  107. package/dist/telephony/contract.d.ts +61 -0
  108. package/dist/telephony/matrix.d.ts +97 -0
  109. package/dist/telephony/plivo.d.ts +254 -0
  110. package/dist/telephony/telnyx.d.ts +247 -0
  111. package/dist/telephony/twilio.d.ts +132 -0
  112. package/dist/telephonyOutcome.d.ts +201 -0
  113. package/dist/testing/index.d.ts +2 -0
  114. package/dist/testing/index.js +2640 -21
  115. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  116. package/dist/testing/providerSimulator.d.ts +44 -0
  117. package/dist/toolContract.d.ts +130 -0
  118. package/dist/toolRuntime.d.ts +50 -0
  119. package/dist/trace.d.ts +1 -1
  120. package/dist/traceTimeline.d.ts +93 -0
  121. package/dist/turnLatency.d.ts +95 -0
  122. package/dist/turnQuality.d.ts +94 -0
  123. package/dist/types.d.ts +125 -2
  124. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  125. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  126. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  127. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  128. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  129. package/dist/vue/VoiceTurnLatency.d.ts +69 -0
  130. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  131. package/dist/vue/index.d.ts +17 -0
  132. package/dist/vue/index.js +2520 -29
  133. package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
  134. package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
  135. package/dist/vue/useVoiceController.d.ts +1 -1
  136. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  137. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  138. package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
  139. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  140. package/dist/vue/useVoiceStream.d.ts +3 -1
  141. package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
  142. package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
  143. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  144. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  145. package/dist/workflowContract.d.ts +91 -0
  146. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { VoiceTraceEventStore } from './trace';
3
+ export type VoiceLiveLatencyStatus = 'empty' | 'fail' | 'pass' | 'warn';
4
+ export type VoiceLiveLatencySample = {
5
+ at: number;
6
+ latencyMs: number;
7
+ sessionId: string;
8
+ status?: string;
9
+ traceId?: string;
10
+ };
11
+ export type VoiceLiveLatencyReport = {
12
+ averageLatencyMs?: number;
13
+ checkedAt: number;
14
+ failed: number;
15
+ p50LatencyMs?: number;
16
+ p95LatencyMs?: number;
17
+ recent: VoiceLiveLatencySample[];
18
+ status: VoiceLiveLatencyStatus;
19
+ total: number;
20
+ warnings: number;
21
+ };
22
+ export type VoiceLiveLatencyOptions = {
23
+ failAfterMs?: number;
24
+ limit?: number;
25
+ store: VoiceTraceEventStore;
26
+ warnAfterMs?: number;
27
+ };
28
+ export type VoiceLiveLatencyRoutesOptions = VoiceLiveLatencyOptions & {
29
+ headers?: HeadersInit;
30
+ htmlPath?: false | string;
31
+ name?: string;
32
+ path?: string;
33
+ title?: string;
34
+ };
35
+ export declare const summarizeVoiceLiveLatency: (options: VoiceLiveLatencyOptions) => Promise<VoiceLiveLatencyReport>;
36
+ export declare const renderVoiceLiveLatencyHTML: (report: VoiceLiveLatencyReport, options?: {
37
+ title?: string;
38
+ }) => string;
39
+ export declare const createVoiceLiveLatencyRoutes: (options: VoiceLiveLatencyRoutesOptions) => Elysia<"", {
40
+ decorator: {};
41
+ store: {};
42
+ derive: {};
43
+ resolve: {};
44
+ }, {
45
+ typebox: {};
46
+ error: {};
47
+ }, {
48
+ schema: {};
49
+ standaloneSchema: {};
50
+ macro: {};
51
+ macroFn: {};
52
+ parser: {};
53
+ response: {};
54
+ }, {
55
+ [x: string]: {
56
+ get: {
57
+ body: unknown;
58
+ params: {};
59
+ query: unknown;
60
+ headers: unknown;
61
+ response: {
62
+ 200: VoiceLiveLatencyReport;
63
+ };
64
+ };
65
+ };
66
+ }, {
67
+ derive: {};
68
+ resolve: {};
69
+ schema: {};
70
+ standaloneSchema: {};
71
+ response: {};
72
+ }, {
73
+ derive: {};
74
+ resolve: {};
75
+ schema: {};
76
+ standaloneSchema: {};
77
+ response: {};
78
+ }>;
@@ -36,25 +36,61 @@ export type GeminiVoiceAssistantModelOptions = {
36
36
  };
37
37
  export type VoiceProviderRouterEvent<TProvider extends string = string> = {
38
38
  at: number;
39
+ attempt: number;
39
40
  elapsedMs: number;
40
41
  error?: string;
41
42
  fallbackProvider?: TProvider;
43
+ latencyBudgetMs?: number;
42
44
  provider: TProvider;
45
+ providerHealth?: VoiceProviderRouterProviderHealth<TProvider>;
43
46
  rateLimited?: boolean;
44
47
  recovered?: boolean;
45
48
  selectedProvider: TProvider;
49
+ suppressionRemainingMs?: number;
50
+ suppressedUntil?: number;
46
51
  status: 'error' | 'fallback' | 'success';
52
+ timedOut?: boolean;
47
53
  };
48
54
  export type VoiceProviderRouterFallbackMode = 'never' | 'provider-error' | 'rate-limit';
49
- export type VoiceProviderRouterPolicy<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TProvider extends string = string> = 'ordered' | 'prefer-cheapest' | 'prefer-fastest' | 'prefer-selected' | {
55
+ export type VoiceProviderRouterStrategy = 'balanced' | 'ordered' | 'prefer-cheapest' | 'prefer-fastest' | 'prefer-selected' | 'quality-first';
56
+ export type VoiceProviderRouterPolicyPreset = 'balanced' | 'cost-cap' | 'cost-first' | 'latency-first' | 'quality-first';
57
+ export type VoiceProviderRouterPolicyWeights = {
58
+ cost?: number;
59
+ latencyMs?: number;
60
+ priority?: number;
61
+ quality?: number;
62
+ };
63
+ export type VoiceProviderRouterPolicy<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TProvider extends string = string> = VoiceProviderRouterStrategy | VoiceProviderRouterPolicyPreset | {
50
64
  allowProviders?: readonly TProvider[] | ((input: VoiceAgentModelInput<TContext, TSession>) => readonly TProvider[] | Promise<readonly TProvider[]>);
51
65
  fallbackMode?: VoiceProviderRouterFallbackMode;
52
- strategy?: 'ordered' | 'prefer-cheapest' | 'prefer-fastest' | 'prefer-selected';
66
+ maxCost?: number;
67
+ maxLatencyMs?: number;
68
+ minQuality?: number;
69
+ scoreProvider?: (provider: TProvider, profile: VoiceProviderRouterProviderProfile | undefined) => number;
70
+ strategy?: VoiceProviderRouterStrategy;
71
+ weights?: VoiceProviderRouterPolicyWeights;
53
72
  };
54
73
  export type VoiceProviderRouterProviderProfile = {
55
74
  cost?: number;
56
75
  latencyMs?: number;
57
76
  priority?: number;
77
+ quality?: number;
78
+ timeoutMs?: number;
79
+ };
80
+ export declare const resolveVoiceProviderRoutingPolicyPreset: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TProvider extends string = string>(preset: VoiceProviderRouterPolicyPreset, options?: Omit<Extract<VoiceProviderRouterPolicy<TContext, TSession, TProvider>, Record<string, unknown>>, "strategy">) => Extract<VoiceProviderRouterPolicy<TContext, TSession, TProvider>, Record<string, unknown>>;
81
+ export type VoiceProviderRouterHealthOptions = {
82
+ cooldownMs?: number;
83
+ failureThreshold?: number;
84
+ now?: () => number;
85
+ rateLimitCooldownMs?: number;
86
+ };
87
+ export type VoiceProviderRouterProviderHealth<TProvider extends string = string> = {
88
+ consecutiveFailures: number;
89
+ lastFailureAt?: number;
90
+ lastRateLimitedAt?: number;
91
+ provider: TProvider;
92
+ status: 'healthy' | 'suppressed';
93
+ suppressedUntil?: number;
58
94
  };
59
95
  export type VoiceProviderRouterOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown, TProvider extends string = string> = {
60
96
  allowProviders?: readonly TProvider[] | ((input: VoiceAgentModelInput<TContext, TSession>) => readonly TProvider[] | Promise<readonly TProvider[]>);
@@ -62,9 +98,12 @@ export type VoiceProviderRouterOptions<TContext = unknown, TSession extends Voic
62
98
  fallbackMode?: VoiceProviderRouterFallbackMode;
63
99
  isProviderError?: (error: unknown, provider: TProvider) => boolean;
64
100
  isRateLimitError?: (error: unknown, provider: TProvider) => boolean;
101
+ isTimeoutError?: (error: unknown, provider: TProvider) => boolean;
65
102
  onProviderEvent?: (event: VoiceProviderRouterEvent<TProvider>, input: VoiceAgentModelInput<TContext, TSession>) => Promise<void> | void;
66
103
  policy?: VoiceProviderRouterPolicy<TContext, TSession, TProvider>;
104
+ providerHealth?: boolean | VoiceProviderRouterHealthOptions;
67
105
  providerProfiles?: Partial<Record<TProvider, VoiceProviderRouterProviderProfile>>;
106
+ timeoutMs?: number;
68
107
  providers: Partial<Record<TProvider, VoiceAgentModel<TContext, TSession, TResult>>>;
69
108
  selectProvider?: (input: VoiceAgentModelInput<TContext, TSession>) => TProvider | undefined | Promise<TProvider | undefined>;
70
109
  };
@@ -0,0 +1,18 @@
1
+ import type { TTSAdapter, TTSAdapterOpenOptions, VoiceLexiconEntry } from './types';
2
+ export type OpenAIVoiceTTSVoice = 'alloy' | 'ash' | 'ballad' | 'cedar' | 'coral' | 'echo' | 'fable' | 'marin' | 'nova' | 'onyx' | 'sage' | 'shimmer' | 'verse' | (string & {});
3
+ export type OpenAIVoiceTTSOptions = {
4
+ apiKey: string;
5
+ baseUrl?: string;
6
+ fetch?: typeof fetch;
7
+ instructions?: string | ((input: {
8
+ lexicon?: VoiceLexiconEntry[];
9
+ sessionId: string;
10
+ text: string;
11
+ }) => Promise<string | undefined> | string | undefined);
12
+ model?: 'gpt-4o-mini-tts' | 'tts-1' | 'tts-1-hd' | (string & {});
13
+ speed?: number;
14
+ voice?: OpenAIVoiceTTSVoice | {
15
+ id: string;
16
+ };
17
+ };
18
+ export declare const createOpenAIVoiceTTS: (options: OpenAIVoiceTTSOptions) => TTSAdapter<TTSAdapterOpenOptions>;
@@ -0,0 +1,77 @@
1
+ import { Elysia } from 'elysia';
2
+ import { type VoiceQualityReport } from './qualityRoutes';
3
+ import { type VoiceRoutingEvent } from './resilienceRoutes';
4
+ import { type VoiceSessionListItem } from './sessionReplay';
5
+ import { summarizeVoiceTrace, type VoiceTraceEventStore } from './trace';
6
+ export type VoiceOpsConsoleLink = {
7
+ description?: string;
8
+ href: string;
9
+ label: string;
10
+ statusHref?: string;
11
+ };
12
+ export type VoiceOpsConsoleReport = {
13
+ checkedAt: number;
14
+ eventCount: number;
15
+ handoffs: {
16
+ failed: number;
17
+ total: number;
18
+ };
19
+ links: VoiceOpsConsoleLink[];
20
+ providers: {
21
+ degraded: number;
22
+ healthy: number;
23
+ total: number;
24
+ };
25
+ quality: VoiceQualityReport;
26
+ recentRoutingEvents: VoiceRoutingEvent[];
27
+ recentSessions: VoiceSessionListItem[];
28
+ sessions: {
29
+ failed: number;
30
+ healthy: number;
31
+ total: number;
32
+ };
33
+ trace: ReturnType<typeof summarizeVoiceTrace>;
34
+ };
35
+ export type VoiceOpsConsoleRoutesOptions = {
36
+ headers?: HeadersInit;
37
+ links?: VoiceOpsConsoleLink[];
38
+ llmProviders?: readonly string[];
39
+ name?: string;
40
+ path?: string;
41
+ store: VoiceTraceEventStore;
42
+ sttProviders?: readonly string[];
43
+ title?: string;
44
+ ttsProviders?: readonly string[];
45
+ };
46
+ export declare const buildVoiceOpsConsoleReport: (options: VoiceOpsConsoleRoutesOptions) => Promise<VoiceOpsConsoleReport>;
47
+ export declare const renderVoiceOpsConsoleHTML: (report: VoiceOpsConsoleReport, options?: {
48
+ title?: string;
49
+ }) => string;
50
+ export declare const createVoiceOpsConsoleRoutes: (options: VoiceOpsConsoleRoutesOptions) => Elysia<"", {
51
+ decorator: {};
52
+ store: {};
53
+ derive: {};
54
+ resolve: {};
55
+ }, {
56
+ typebox: {};
57
+ error: {};
58
+ }, {
59
+ schema: {};
60
+ standaloneSchema: {};
61
+ macro: {};
62
+ macroFn: {};
63
+ parser: {};
64
+ response: {};
65
+ }, {}, {
66
+ derive: {};
67
+ resolve: {};
68
+ schema: {};
69
+ standaloneSchema: {};
70
+ response: {};
71
+ }, {
72
+ derive: {};
73
+ resolve: {};
74
+ schema: {};
75
+ standaloneSchema: {};
76
+ response: {};
77
+ }>;
@@ -0,0 +1,126 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { StoredVoiceIntegrationEvent, VoiceIntegrationEventType } from './ops';
3
+ import type { VoiceIntegrationHTTPSinkOptions, VoiceIntegrationSink } from './opsSinks';
4
+ type MaybePromise<T> = T | Promise<T>;
5
+ export type VoiceOpsWebhookLinkResolver = string | ((input: {
6
+ event: StoredVoiceIntegrationEvent;
7
+ }) => MaybePromise<string | undefined>);
8
+ export type VoiceOpsWebhookEntity = {
9
+ disposition?: string;
10
+ outcome?: string;
11
+ priority?: string;
12
+ queue?: string;
13
+ reviewId?: string;
14
+ scenarioId?: string;
15
+ sessionId?: string;
16
+ status?: string;
17
+ target?: string;
18
+ taskId?: string;
19
+ };
20
+ export type VoiceOpsWebhookEnvelope = {
21
+ entity: VoiceOpsWebhookEntity;
22
+ event: {
23
+ createdAt: number;
24
+ id: string;
25
+ payload: Record<string, unknown>;
26
+ type: VoiceIntegrationEventType;
27
+ };
28
+ links?: {
29
+ event?: string;
30
+ replay?: string;
31
+ review?: string;
32
+ task?: string;
33
+ };
34
+ schemaVersion: 1;
35
+ source: 'absolutejs-voice';
36
+ };
37
+ export type VoiceOpsWebhookSinkOptions = Omit<VoiceIntegrationHTTPSinkOptions<VoiceOpsWebhookEnvelope>, 'body'> & {
38
+ baseUrl?: string;
39
+ eventHref?: VoiceOpsWebhookLinkResolver;
40
+ replayHref?: VoiceOpsWebhookLinkResolver;
41
+ reviewHref?: VoiceOpsWebhookLinkResolver;
42
+ taskHref?: VoiceOpsWebhookLinkResolver;
43
+ };
44
+ export type VoiceOpsWebhookVerificationResult = {
45
+ ok: true;
46
+ } | {
47
+ ok: false;
48
+ reason: 'invalid-signature' | 'missing-secret' | 'missing-signature' | 'missing-timestamp' | 'stale-timestamp' | 'unsupported-algorithm';
49
+ };
50
+ export type VoiceOpsWebhookReceiverRoutesOptions = {
51
+ onEnvelope?: (input: {
52
+ envelope: VoiceOpsWebhookEnvelope;
53
+ request: Request;
54
+ }) => MaybePromise<void>;
55
+ path?: string;
56
+ signingSecret?: string;
57
+ toleranceMs?: number;
58
+ };
59
+ export declare const createVoiceOpsWebhookEnvelope: (input: {
60
+ baseUrl?: string;
61
+ event: StoredVoiceIntegrationEvent;
62
+ eventHref?: VoiceOpsWebhookLinkResolver;
63
+ replayHref?: VoiceOpsWebhookLinkResolver;
64
+ reviewHref?: VoiceOpsWebhookLinkResolver;
65
+ taskHref?: VoiceOpsWebhookLinkResolver;
66
+ }) => Promise<VoiceOpsWebhookEnvelope>;
67
+ export declare const createVoiceOpsWebhookSink: (options: VoiceOpsWebhookSinkOptions) => VoiceIntegrationSink;
68
+ export declare const verifyVoiceOpsWebhookSignature: (input: {
69
+ body: string;
70
+ now?: number;
71
+ secret?: string;
72
+ signature?: string | null;
73
+ timestamp?: string | null;
74
+ toleranceMs?: number;
75
+ }) => Promise<VoiceOpsWebhookVerificationResult>;
76
+ export declare const createVoiceOpsWebhookReceiverRoutes: (options?: VoiceOpsWebhookReceiverRoutesOptions) => Elysia<"", {
77
+ decorator: {};
78
+ store: {};
79
+ derive: {};
80
+ resolve: {};
81
+ }, {
82
+ typebox: {};
83
+ error: {};
84
+ }, {
85
+ schema: {};
86
+ standaloneSchema: {};
87
+ macro: {};
88
+ macroFn: {};
89
+ parser: {};
90
+ response: {};
91
+ }, {
92
+ [x: string]: {
93
+ post: {
94
+ body: unknown;
95
+ params: {};
96
+ query: unknown;
97
+ headers: unknown;
98
+ response: {
99
+ 200: {
100
+ ok: boolean;
101
+ reason: "invalid-signature" | "missing-secret" | "missing-signature" | "missing-timestamp" | "stale-timestamp" | "unsupported-algorithm";
102
+ eventId?: undefined;
103
+ type?: undefined;
104
+ } | {
105
+ eventId: string;
106
+ ok: boolean;
107
+ type: VoiceIntegrationEventType;
108
+ reason?: undefined;
109
+ };
110
+ };
111
+ };
112
+ };
113
+ }, {
114
+ derive: {};
115
+ resolve: {};
116
+ schema: {};
117
+ standaloneSchema: {};
118
+ response: {};
119
+ }, {
120
+ derive: {};
121
+ resolve: {};
122
+ schema: {};
123
+ standaloneSchema: {};
124
+ response: {};
125
+ }>;
126
+ export {};
@@ -0,0 +1,112 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { StoredVoiceHandoffDelivery, VoiceCallDisposition, VoiceHandoffAction, VoiceHandoffDeliveryStore, VoiceSessionRecord, VoiceSessionStore } from './types';
3
+ import type { StoredVoiceIntegrationEvent, StoredVoiceOpsTask, VoiceIntegrationEventType } from './ops';
4
+ import type { StoredVoiceCallReviewArtifact } from './testing/review';
5
+ export type VoiceOutcomeContractStatus = 'pass' | 'fail';
6
+ export type VoiceOutcomeContractDefinition = {
7
+ description?: string;
8
+ expectedDisposition?: VoiceCallDisposition;
9
+ id: string;
10
+ label?: string;
11
+ minSessions?: number;
12
+ minTasks?: number;
13
+ requireHandoffActions?: VoiceHandoffAction[];
14
+ requireIntegrationEvents?: VoiceIntegrationEventType[];
15
+ requireReview?: boolean;
16
+ requireTask?: boolean;
17
+ scenarioId?: string;
18
+ };
19
+ export type VoiceOutcomeContractIssue = {
20
+ code: string;
21
+ message: string;
22
+ };
23
+ export type VoiceOutcomeContractReport = {
24
+ contractId: string;
25
+ description?: string;
26
+ issues: VoiceOutcomeContractIssue[];
27
+ label?: string;
28
+ matched: {
29
+ handoffs: number;
30
+ integrationEvents: number;
31
+ reviews: number;
32
+ sessions: number;
33
+ tasks: number;
34
+ };
35
+ pass: boolean;
36
+ };
37
+ export type VoiceOutcomeContractSuiteReport = {
38
+ checkedAt: number;
39
+ contracts: VoiceOutcomeContractReport[];
40
+ failed: number;
41
+ passed: number;
42
+ status: VoiceOutcomeContractStatus;
43
+ total: number;
44
+ };
45
+ type ListStore<T> = {
46
+ list: () => Promise<T[]> | T[];
47
+ };
48
+ export type VoiceOutcomeContractOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord> = {
49
+ contracts: VoiceOutcomeContractDefinition[];
50
+ events?: StoredVoiceIntegrationEvent[] | ListStore<StoredVoiceIntegrationEvent>;
51
+ handoffs?: StoredVoiceHandoffDelivery[] | VoiceHandoffDeliveryStore;
52
+ reviews?: StoredVoiceCallReviewArtifact[] | ListStore<StoredVoiceCallReviewArtifact>;
53
+ sessions?: TSession[] | VoiceSessionStore<TSession>;
54
+ tasks?: StoredVoiceOpsTask[] | ListStore<StoredVoiceOpsTask>;
55
+ };
56
+ export type VoiceOutcomeContractHTMLHandlerOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord> = VoiceOutcomeContractOptions<TSession> & {
57
+ headers?: HeadersInit;
58
+ render?: (report: VoiceOutcomeContractSuiteReport) => string | Promise<string>;
59
+ title?: string;
60
+ };
61
+ export type VoiceOutcomeContractRoutesOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord> = VoiceOutcomeContractHTMLHandlerOptions<TSession> & {
62
+ htmlPath?: false | string;
63
+ name?: string;
64
+ path?: string;
65
+ };
66
+ export declare const runVoiceOutcomeContractSuite: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceOutcomeContractOptions<TSession>) => Promise<VoiceOutcomeContractSuiteReport>;
67
+ export declare const renderVoiceOutcomeContractHTML: (report: VoiceOutcomeContractSuiteReport, options?: {
68
+ title?: string;
69
+ }) => string;
70
+ export declare const createVoiceOutcomeContractJSONHandler: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceOutcomeContractOptions<TSession>) => () => Promise<VoiceOutcomeContractSuiteReport>;
71
+ export declare const createVoiceOutcomeContractHTMLHandler: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceOutcomeContractHTMLHandlerOptions<TSession>) => () => Promise<Response>;
72
+ export declare const createVoiceOutcomeContractRoutes: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceOutcomeContractRoutesOptions<TSession>) => Elysia<"", {
73
+ decorator: {};
74
+ store: {};
75
+ derive: {};
76
+ resolve: {};
77
+ }, {
78
+ typebox: {};
79
+ error: {};
80
+ }, {
81
+ schema: {};
82
+ standaloneSchema: {};
83
+ macro: {};
84
+ macroFn: {};
85
+ parser: {};
86
+ response: {};
87
+ }, {
88
+ [x: string]: {
89
+ get: {
90
+ body: unknown;
91
+ params: {};
92
+ query: unknown;
93
+ headers: unknown;
94
+ response: {
95
+ 200: VoiceOutcomeContractSuiteReport;
96
+ };
97
+ };
98
+ };
99
+ }, {
100
+ derive: {};
101
+ resolve: {};
102
+ schema: {};
103
+ standaloneSchema: {};
104
+ response: {};
105
+ }, {
106
+ derive: {};
107
+ resolve: {};
108
+ schema: {};
109
+ standaloneSchema: {};
110
+ response: {};
111
+ }>;
112
+ export {};
@@ -0,0 +1,58 @@
1
+ import { Elysia } from 'elysia';
2
+ import { type PlivoVoiceRoutesOptions } from './telephony/plivo';
3
+ import { type TelnyxVoiceRoutesOptions } from './telephony/telnyx';
4
+ import { type TwilioVoiceRoutesOptions } from './telephony/twilio';
5
+ import { type VoiceTelephonyCarrierMatrix, type VoiceTelephonyCarrierMatrixRoutesOptions } from './telephony/matrix';
6
+ import type { VoiceSessionRecord } from './types';
7
+ export type VoicePhoneAgentLifecycleStage = 'ringing' | 'answered' | 'media-started' | 'transcript' | 'assistant-response' | 'transfer' | 'voicemail' | 'no-answer' | 'completed' | 'failed';
8
+ type VoicePhoneAgentCarrierBase = {
9
+ name?: string;
10
+ smokePath?: false | string;
11
+ setupPath?: false | string;
12
+ };
13
+ export type VoicePhoneAgentTwilioCarrier<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoicePhoneAgentCarrierBase & {
14
+ options: TwilioVoiceRoutesOptions<TContext, TSession, TResult>;
15
+ provider: 'twilio';
16
+ };
17
+ export type VoicePhoneAgentTelnyxCarrier<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoicePhoneAgentCarrierBase & {
18
+ options?: TelnyxVoiceRoutesOptions<TContext, TSession, TResult>;
19
+ provider: 'telnyx';
20
+ };
21
+ export type VoicePhoneAgentPlivoCarrier<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoicePhoneAgentCarrierBase & {
22
+ options?: PlivoVoiceRoutesOptions<TContext, TSession, TResult>;
23
+ provider: 'plivo';
24
+ };
25
+ export type VoicePhoneAgentCarrier<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoicePhoneAgentTwilioCarrier<TContext, TSession, TResult> | VoicePhoneAgentTelnyxCarrier<TContext, TSession, TResult> | VoicePhoneAgentPlivoCarrier<TContext, TSession, TResult>;
26
+ export type VoicePhoneAgentRoutesOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
27
+ carriers: readonly VoicePhoneAgentCarrier<TContext, TSession, TResult>[];
28
+ matrix?: false | Omit<VoiceTelephonyCarrierMatrixRoutesOptions, 'load'>;
29
+ name?: string;
30
+ setup?: false | {
31
+ path?: string;
32
+ title?: string;
33
+ };
34
+ };
35
+ export type VoicePhoneAgentCarrierSummary = {
36
+ name?: string;
37
+ provider: 'plivo' | 'telnyx' | 'twilio';
38
+ setupPath?: false | string;
39
+ smokePath?: false | string;
40
+ };
41
+ export type VoicePhoneAgentRoutes = {
42
+ carriers: VoicePhoneAgentCarrierSummary[];
43
+ matrixPath?: string;
44
+ routes: Elysia;
45
+ setupPath?: string;
46
+ };
47
+ export type VoicePhoneAgentSetupReport = {
48
+ carriers: VoicePhoneAgentCarrierSummary[];
49
+ generatedAt: number;
50
+ lifecycleStages: VoicePhoneAgentLifecycleStage[];
51
+ matrix?: VoiceTelephonyCarrierMatrix;
52
+ matrixPath?: string;
53
+ ready: boolean;
54
+ setupPath?: string;
55
+ title: string;
56
+ };
57
+ export declare const createVoicePhoneAgent: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(options: VoicePhoneAgentRoutesOptions<TContext, TSession, TResult>) => VoicePhoneAgentRoutes;
58
+ export {};
@@ -1,6 +1,8 @@
1
1
  import { type StoredVoiceTraceEvent, type VoiceTraceSinkDeliveryRecord, type VoiceTraceSinkDeliveryStore, type VoiceTraceEventStore } from './trace';
2
2
  import type { StoredVoiceIntegrationEvent, StoredVoiceExternalObjectMap, StoredVoiceOpsTask, VoiceExternalObjectMapStore, VoiceIntegrationEventStore, VoiceOpsTaskStore } from './ops';
3
3
  import type { StoredVoiceCallReviewArtifact, VoiceCallReviewStore } from './testing/review';
4
+ import type { VoiceTelephonyWebhookIdempotencyStore } from './telephonyOutcome';
5
+ import type { VoiceCampaignStore } from './campaign';
4
6
  import type { VoiceSessionRecord, VoiceSessionStore } from './types';
5
7
  export type VoicePostgresClient = {
6
8
  unsafe: <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, parameters?: unknown[]) => Promise<TRow[]>;
@@ -13,6 +15,7 @@ export type VoicePostgresStoreOptions = {
13
15
  tablePrefix?: string;
14
16
  };
15
17
  export type VoicePostgresRuntimeStorage<TSession extends VoiceSessionRecord = VoiceSessionRecord, TReview extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact, TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask, TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent, TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap, TTrace extends StoredVoiceTraceEvent = StoredVoiceTraceEvent, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord> = {
18
+ campaigns: VoiceCampaignStore;
16
19
  events: VoiceIntegrationEventStore<TEvent>;
17
20
  externalObjects: VoiceExternalObjectMapStore<TMapping>;
18
21
  reviews: VoiceCallReviewStore<TReview>;
@@ -28,4 +31,6 @@ export declare const createVoicePostgresIntegrationEventStore: <TEvent extends S
28
31
  export declare const createVoicePostgresExternalObjectMapStore: <TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap>(options: VoicePostgresStoreOptions) => VoiceExternalObjectMapStore<TMapping>;
29
32
  export declare const createVoicePostgresTraceEventStore: <TEvent extends StoredVoiceTraceEvent = StoredVoiceTraceEvent>(options: VoicePostgresStoreOptions) => VoiceTraceEventStore<TEvent>;
30
33
  export declare const createVoicePostgresTraceSinkDeliveryStore: <TDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord>(options: VoicePostgresStoreOptions) => VoiceTraceSinkDeliveryStore<TDelivery>;
34
+ export declare const createVoicePostgresTelephonyWebhookIdempotencyStore: <TResult = unknown>(options: VoicePostgresStoreOptions) => VoiceTelephonyWebhookIdempotencyStore<TResult>;
35
+ export declare const createVoicePostgresCampaignStore: (options: VoicePostgresStoreOptions) => VoiceCampaignStore;
31
36
  export declare const createVoicePostgresRuntimeStorage: <TSession extends VoiceSessionRecord = VoiceSessionRecord, TReview extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact, TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask, TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent, TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap, TTrace extends StoredVoiceTraceEvent = StoredVoiceTraceEvent, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord>(options: VoicePostgresStoreOptions) => VoicePostgresRuntimeStorage<TSession, TReview, TTask, TEvent, TMapping, TTrace, TTraceDelivery>;