@absolutejs/voice 0.0.22-beta.9 → 0.0.22-beta.90

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 (114) hide show
  1. package/README.md +205 -0
  2. package/dist/agent.d.ts +2 -0
  3. package/dist/angular/index.d.ts +6 -0
  4. package/dist/angular/index.js +833 -43
  5. package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
  6. package/dist/angular/voice-ops-status.component.d.ts +15 -0
  7. package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
  8. package/dist/angular/voice-provider-status.service.d.ts +12 -0
  9. package/dist/angular/voice-routing-status.service.d.ts +11 -0
  10. package/dist/angular/voice-stream.service.d.ts +2 -0
  11. package/dist/angular/voice-turn-quality.service.d.ts +12 -0
  12. package/dist/angular/voice-workflow-status.service.d.ts +12 -0
  13. package/dist/appKit.d.ts +98 -0
  14. package/dist/assistantHealth.d.ts +81 -0
  15. package/dist/client/actions.d.ts +22 -0
  16. package/dist/client/appKitStatus.d.ts +19 -0
  17. package/dist/client/connection.d.ts +3 -0
  18. package/dist/client/htmxBootstrap.js +44 -2
  19. package/dist/client/index.d.ts +26 -0
  20. package/dist/client/index.js +1290 -2
  21. package/dist/client/opsStatusWidget.d.ts +40 -0
  22. package/dist/client/providerCapabilities.d.ts +19 -0
  23. package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
  24. package/dist/client/providerSimulationControls.d.ts +33 -0
  25. package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
  26. package/dist/client/providerStatus.d.ts +19 -0
  27. package/dist/client/providerStatusWidget.d.ts +32 -0
  28. package/dist/client/routingStatus.d.ts +19 -0
  29. package/dist/client/routingStatusWidget.d.ts +28 -0
  30. package/dist/client/turnQuality.d.ts +19 -0
  31. package/dist/client/turnQualityWidget.d.ts +32 -0
  32. package/dist/client/workflowStatus.d.ts +19 -0
  33. package/dist/diagnosticsRoutes.d.ts +44 -0
  34. package/dist/evalRoutes.d.ts +213 -0
  35. package/dist/handoff.d.ts +54 -0
  36. package/dist/handoffHealth.d.ts +94 -0
  37. package/dist/index.d.ts +62 -7
  38. package/dist/index.js +10382 -2574
  39. package/dist/modelAdapters.d.ts +75 -0
  40. package/dist/openaiTTS.d.ts +18 -0
  41. package/dist/opsConsoleRoutes.d.ts +77 -0
  42. package/dist/opsWebhook.d.ts +126 -0
  43. package/dist/outcomeContract.d.ts +112 -0
  44. package/dist/postgresStore.d.ts +2 -0
  45. package/dist/productionReadiness.d.ts +111 -0
  46. package/dist/providerAdapters.d.ts +48 -0
  47. package/dist/providerCapabilities.d.ts +92 -0
  48. package/dist/providerHealth.d.ts +79 -0
  49. package/dist/qualityRoutes.d.ts +76 -0
  50. package/dist/queue.d.ts +61 -0
  51. package/dist/react/VoiceOpsStatus.d.ts +6 -0
  52. package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
  53. package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
  54. package/dist/react/VoiceProviderStatus.d.ts +6 -0
  55. package/dist/react/VoiceRoutingStatus.d.ts +6 -0
  56. package/dist/react/VoiceTurnQuality.d.ts +6 -0
  57. package/dist/react/index.d.ts +13 -0
  58. package/dist/react/index.js +1884 -11
  59. package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
  60. package/dist/react/useVoiceController.d.ts +2 -0
  61. package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
  62. package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
  63. package/dist/react/useVoiceProviderStatus.d.ts +8 -0
  64. package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
  65. package/dist/react/useVoiceStream.d.ts +2 -0
  66. package/dist/react/useVoiceTurnQuality.d.ts +8 -0
  67. package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
  68. package/dist/resilienceRoutes.d.ts +142 -0
  69. package/dist/sessionReplay.d.ts +175 -0
  70. package/dist/sqliteStore.d.ts +2 -0
  71. package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
  72. package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
  73. package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
  74. package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
  75. package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
  76. package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
  77. package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
  78. package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
  79. package/dist/svelte/index.d.ts +8 -0
  80. package/dist/svelte/index.js +1330 -3
  81. package/dist/telephony/contract.d.ts +61 -0
  82. package/dist/telephony/matrix.d.ts +97 -0
  83. package/dist/telephony/plivo.d.ts +254 -0
  84. package/dist/telephony/telnyx.d.ts +247 -0
  85. package/dist/telephony/twilio.d.ts +132 -0
  86. package/dist/telephonyOutcome.d.ts +201 -0
  87. package/dist/testing/index.d.ts +2 -0
  88. package/dist/testing/index.js +2543 -14
  89. package/dist/testing/ioProviderSimulator.d.ts +41 -0
  90. package/dist/testing/providerSimulator.d.ts +44 -0
  91. package/dist/toolContract.d.ts +130 -0
  92. package/dist/toolRuntime.d.ts +50 -0
  93. package/dist/trace.d.ts +1 -1
  94. package/dist/traceTimeline.d.ts +93 -0
  95. package/dist/turnQuality.d.ts +94 -0
  96. package/dist/types.d.ts +84 -2
  97. package/dist/vue/VoiceOpsStatus.d.ts +30 -0
  98. package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
  99. package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
  100. package/dist/vue/VoiceProviderStatus.d.ts +51 -0
  101. package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
  102. package/dist/vue/VoiceTurnQuality.d.ts +51 -0
  103. package/dist/vue/index.d.ts +13 -0
  104. package/dist/vue/index.js +1934 -25
  105. package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
  106. package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
  107. package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
  108. package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
  109. package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
  110. package/dist/vue/useVoiceStream.d.ts +2 -0
  111. package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
  112. package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
  113. package/dist/workflowContract.d.ts +91 -0
  114. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ import type { VoiceIOProviderRouterEvent } from '../providerAdapters';
2
+ export type VoiceIOProviderFailureSimulationMode = 'failure' | 'recovery';
3
+ export type VoiceIOProviderFailureSimulationKind = 'stt' | 'tts';
4
+ export type VoiceIOProviderFailureSimulationOperation = 'open' | 'send';
5
+ export type VoiceIOProviderFailureSimulationResult<TProvider extends string = string> = {
6
+ fallbackProvider?: TProvider;
7
+ mode: VoiceIOProviderFailureSimulationMode;
8
+ provider: TProvider;
9
+ sessionId: string;
10
+ status: 'simulated';
11
+ suppressedUntil?: number;
12
+ };
13
+ export type VoiceIOProviderFailureSimulatorOptions<TProvider extends string = string> = {
14
+ cooldownMs?: number;
15
+ fallback?: readonly TProvider[] | ((provider: TProvider) => readonly TProvider[] | Promise<readonly TProvider[]>);
16
+ failureElapsedMs?: number;
17
+ failureMessage?: (input: {
18
+ kind: VoiceIOProviderFailureSimulationKind;
19
+ operation: VoiceIOProviderFailureSimulationOperation;
20
+ provider: TProvider;
21
+ }) => string;
22
+ kind: VoiceIOProviderFailureSimulationKind;
23
+ latencyBudgets?: Partial<Record<TProvider, number>>;
24
+ now?: () => number;
25
+ onProviderEvent?: (event: VoiceIOProviderRouterEvent<TProvider>, input: {
26
+ mode: VoiceIOProviderFailureSimulationMode;
27
+ provider: TProvider;
28
+ sessionId: string;
29
+ }) => Promise<void> | void;
30
+ operation?: VoiceIOProviderFailureSimulationOperation;
31
+ providers: readonly TProvider[];
32
+ recoveryElapsedMs?: number | Partial<Record<TProvider, number>>;
33
+ sessionId?: (input: {
34
+ mode: VoiceIOProviderFailureSimulationMode;
35
+ now: number;
36
+ provider: TProvider;
37
+ }) => string;
38
+ };
39
+ export declare const createVoiceIOProviderFailureSimulator: <TProvider extends string>(options: VoiceIOProviderFailureSimulatorOptions<TProvider>) => {
40
+ run: (provider: TProvider, mode: VoiceIOProviderFailureSimulationMode) => Promise<VoiceIOProviderFailureSimulationResult<TProvider>>;
41
+ };
@@ -0,0 +1,44 @@
1
+ import type { VoiceAgentModelInput, VoiceAgentModelOutput } from '../agent';
2
+ import type { VoiceSessionRecord } from '../types';
3
+ import type { VoiceProviderRouterEvent, VoiceProviderRouterHealthOptions } from '../modelAdapters';
4
+ export type VoiceProviderFailureSimulationMode = 'failure' | 'recovery';
5
+ export type VoiceProviderFailureSimulationContext<TProvider extends string = string> = {
6
+ query: {
7
+ provider: TProvider;
8
+ recoverProvider?: TProvider;
9
+ simulateFailureProvider?: TProvider;
10
+ };
11
+ };
12
+ export type VoiceProviderFailureSimulationResult<TProvider extends string = string, TResult = unknown> = {
13
+ mode: VoiceProviderFailureSimulationMode;
14
+ provider: TProvider;
15
+ replayHref?: string;
16
+ result: VoiceAgentModelOutput<TResult>;
17
+ sessionId: string;
18
+ status: 'simulated';
19
+ turnId: string;
20
+ };
21
+ type ProviderListResolver<TContext, TSession extends VoiceSessionRecord, TProvider extends string> = readonly TProvider[] | ((input: VoiceAgentModelInput<TContext, TSession>) => readonly TProvider[] | Promise<readonly TProvider[]>);
22
+ export type VoiceProviderFailureSimulatorOptions<TContext extends VoiceProviderFailureSimulationContext<TProvider>, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown, TProvider extends string = string> = {
23
+ allowProviders?: ProviderListResolver<TContext, TSession, TProvider>;
24
+ fallback?: readonly TProvider[] | ((provider: TProvider, input: VoiceAgentModelInput<TContext, TSession>) => readonly TProvider[] | Promise<readonly TProvider[]>);
25
+ isProviderError?: (error: unknown, provider: TProvider) => boolean;
26
+ isRateLimitError?: (error: unknown, provider: TProvider) => boolean;
27
+ onProviderEvent?: (event: VoiceProviderRouterEvent<TProvider>, input: VoiceAgentModelInput<TContext, TSession>) => Promise<void> | void;
28
+ providerHealth?: boolean | VoiceProviderRouterHealthOptions;
29
+ providerLabel?: (provider: TProvider) => string;
30
+ providers: readonly TProvider[];
31
+ replayHref?: false | string | ((input: {
32
+ provider: TProvider;
33
+ sessionId: string;
34
+ turnId: string;
35
+ }) => string);
36
+ response?: (input: {
37
+ mode: VoiceProviderFailureSimulationMode;
38
+ provider: TProvider;
39
+ } & VoiceAgentModelInput<TContext, TSession>) => VoiceAgentModelOutput<TResult> | Promise<VoiceAgentModelOutput<TResult>>;
40
+ };
41
+ export declare const createVoiceProviderFailureSimulator: <TProvider extends string, TResult = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TContext extends VoiceProviderFailureSimulationContext<TProvider> = VoiceProviderFailureSimulationContext<TProvider>>(options: VoiceProviderFailureSimulatorOptions<TContext, TSession, TResult, TProvider>) => {
42
+ run: (provider: TProvider, mode: VoiceProviderFailureSimulationMode) => Promise<VoiceProviderFailureSimulationResult<TProvider, TResult>>;
43
+ };
44
+ export {};
@@ -0,0 +1,130 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { VoiceAgentTool } from './agent';
3
+ import { type VoiceToolRuntimeOptions } from './toolRuntime';
4
+ import type { VoiceSessionRecord, VoiceTurnRecord } from './types';
5
+ export type VoiceToolContractExpectation = {
6
+ expectedAttempts?: number;
7
+ expectedErrorIncludes?: string;
8
+ expectedResult?: unknown;
9
+ expectIdempotent?: boolean;
10
+ expectStatus?: 'error' | 'ok';
11
+ expectTimedOut?: boolean;
12
+ maxElapsedMs?: number;
13
+ };
14
+ export type VoiceToolContractCase<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TArgs = Record<string, unknown>, TToolResult = unknown, TRouteResult = unknown> = {
15
+ args: TArgs;
16
+ context?: TContext;
17
+ expect?: VoiceToolContractExpectation;
18
+ id: string;
19
+ label?: string;
20
+ runtime?: VoiceToolRuntimeOptions<TContext, TSession, TRouteResult>;
21
+ session?: TSession;
22
+ toolCallId?: string;
23
+ turn?: VoiceTurnRecord;
24
+ };
25
+ export type VoiceToolContractDefinition<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TArgs = Record<string, unknown>, TToolResult = unknown, TRouteResult = unknown> = {
26
+ cases: Array<VoiceToolContractCase<TContext, TSession, TArgs, TToolResult, TRouteResult>>;
27
+ defaultRuntime?: VoiceToolRuntimeOptions<TContext, TSession, TRouteResult>;
28
+ description?: string;
29
+ id: string;
30
+ label?: string;
31
+ tool: VoiceAgentTool<TContext, TSession, TArgs, TToolResult, TRouteResult>;
32
+ };
33
+ export type VoiceToolContractIssue = {
34
+ caseId: string;
35
+ code: string;
36
+ message: string;
37
+ };
38
+ export type VoiceToolContractCaseReport = {
39
+ attempts: number;
40
+ caseId: string;
41
+ elapsedMs: number;
42
+ error?: string;
43
+ issues: VoiceToolContractIssue[];
44
+ label?: string;
45
+ pass: boolean;
46
+ status: 'error' | 'ok';
47
+ timedOut: boolean;
48
+ };
49
+ export type VoiceToolContractReport = {
50
+ cases: VoiceToolContractCaseReport[];
51
+ contractId: string;
52
+ label?: string;
53
+ issues: VoiceToolContractIssue[];
54
+ pass: boolean;
55
+ toolName: string;
56
+ };
57
+ export type VoiceToolContractSuiteReport = {
58
+ checkedAt: number;
59
+ contracts: VoiceToolContractReport[];
60
+ failed: number;
61
+ passed: number;
62
+ status: 'fail' | 'pass';
63
+ total: number;
64
+ };
65
+ export type VoiceToolContractHandlerOptions = {
66
+ contracts: VoiceToolContractDefinition[];
67
+ };
68
+ export type VoiceToolContractHTMLHandlerOptions = VoiceToolContractHandlerOptions & {
69
+ headers?: HeadersInit;
70
+ render?: (report: VoiceToolContractSuiteReport) => string | Promise<string>;
71
+ title?: string;
72
+ };
73
+ export type VoiceToolContractRoutesOptions = VoiceToolContractHTMLHandlerOptions & {
74
+ htmlPath?: false | string;
75
+ name?: string;
76
+ path?: string;
77
+ };
78
+ export declare const runVoiceToolContract: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TArgs = Record<string, unknown>, TToolResult = unknown, TRouteResult = unknown>(definition: VoiceToolContractDefinition<TContext, TSession, TArgs, TToolResult, TRouteResult>) => Promise<VoiceToolContractReport>;
79
+ export declare const createVoiceToolContract: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TArgs = Record<string, unknown>, TToolResult = unknown, TRouteResult = unknown>(definition: VoiceToolContractDefinition<TContext, TSession, TArgs, TToolResult, TRouteResult>) => {
80
+ assert: () => Promise<VoiceToolContractReport>;
81
+ definition: VoiceToolContractDefinition<TContext, TSession, TArgs, TToolResult, TRouteResult>;
82
+ run: () => Promise<VoiceToolContractReport>;
83
+ };
84
+ export declare const createVoiceToolRuntimeContractDefaults: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TRouteResult = unknown>() => VoiceToolRuntimeOptions<TContext, TSession, TRouteResult>;
85
+ export declare const runVoiceToolContractSuite: (options: VoiceToolContractHandlerOptions) => Promise<VoiceToolContractSuiteReport>;
86
+ export declare const renderVoiceToolContractHTML: (report: VoiceToolContractSuiteReport, options?: {
87
+ title?: string;
88
+ }) => string;
89
+ export declare const createVoiceToolContractJSONHandler: (options: VoiceToolContractHandlerOptions) => () => Promise<VoiceToolContractSuiteReport>;
90
+ export declare const createVoiceToolContractHTMLHandler: (options: VoiceToolContractHTMLHandlerOptions) => () => Promise<Response>;
91
+ export declare const createVoiceToolContractRoutes: (options: VoiceToolContractRoutesOptions) => Elysia<"", {
92
+ decorator: {};
93
+ store: {};
94
+ derive: {};
95
+ resolve: {};
96
+ }, {
97
+ typebox: {};
98
+ error: {};
99
+ }, {
100
+ schema: {};
101
+ standaloneSchema: {};
102
+ macro: {};
103
+ macroFn: {};
104
+ parser: {};
105
+ response: {};
106
+ }, {
107
+ [x: string]: {
108
+ get: {
109
+ body: unknown;
110
+ params: {};
111
+ query: unknown;
112
+ headers: unknown;
113
+ response: {
114
+ 200: VoiceToolContractSuiteReport;
115
+ };
116
+ };
117
+ };
118
+ }, {
119
+ derive: {};
120
+ resolve: {};
121
+ schema: {};
122
+ standaloneSchema: {};
123
+ response: {};
124
+ }, {
125
+ derive: {};
126
+ resolve: {};
127
+ schema: {};
128
+ standaloneSchema: {};
129
+ response: {};
130
+ }>;
@@ -0,0 +1,50 @@
1
+ import type { VoiceAgentTool, VoiceAgentToolResult } from './agent';
2
+ import type { VoiceSessionHandle, VoiceSessionRecord, VoiceTurnRecord } from './types';
3
+ import type { VoiceTraceEventStore } from './trace';
4
+ export type VoiceToolRetryDelay = number | ((input: {
5
+ attempt: number;
6
+ error: unknown;
7
+ toolName: string;
8
+ }) => number);
9
+ export type VoiceToolRuntimeOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TRouteResult = unknown> = {
10
+ idempotencyKey?: (input: {
11
+ args: unknown;
12
+ context: TContext;
13
+ session: TSession;
14
+ toolCallId?: string;
15
+ toolName: string;
16
+ turn: VoiceTurnRecord;
17
+ }) => string | undefined;
18
+ idempotencyTtlMs?: number;
19
+ maxRetries?: number;
20
+ retryDelayMs?: VoiceToolRetryDelay;
21
+ timeoutMs?: number;
22
+ trace?: VoiceTraceEventStore;
23
+ };
24
+ export type VoiceToolRuntimeExecuteInput<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TArgs = Record<string, unknown>, TToolResult = unknown, TRouteResult = unknown> = {
25
+ api: VoiceSessionHandle<TContext, TSession, TRouteResult>;
26
+ args: TArgs;
27
+ context: TContext;
28
+ session: TSession;
29
+ tool: VoiceAgentTool<TContext, TSession, TArgs, TToolResult, TRouteResult>;
30
+ toolCallId?: string;
31
+ turn: VoiceTurnRecord;
32
+ };
33
+ export type VoiceToolRuntimeResult<TToolResult = unknown> = VoiceAgentToolResult<TToolResult> & {
34
+ attempts: number;
35
+ elapsedMs: number;
36
+ idempotencyKey?: string;
37
+ timedOut: boolean;
38
+ };
39
+ export type VoiceToolRuntime<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TRouteResult = unknown> = {
40
+ execute: <TArgs = Record<string, unknown>, TToolResult = unknown>(input: VoiceToolRuntimeExecuteInput<TContext, TSession, TArgs, TToolResult, TRouteResult>) => Promise<VoiceToolRuntimeResult<TToolResult>>;
41
+ wrapTool: <TArgs = Record<string, unknown>, TToolResult = unknown>(tool: VoiceAgentTool<TContext, TSession, TArgs, TToolResult, TRouteResult>) => VoiceAgentTool<TContext, TSession, TArgs, TToolResult, TRouteResult>;
42
+ };
43
+ export declare const createVoiceToolRuntime: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TRouteResult = unknown>(options?: VoiceToolRuntimeOptions<TContext, TSession, TRouteResult>) => VoiceToolRuntime<TContext, TSession, TRouteResult>;
44
+ export declare const createVoiceToolIdempotencyKey: (input: {
45
+ args: unknown;
46
+ sessionId: string;
47
+ toolCallId?: string;
48
+ toolName: string;
49
+ turnId: string;
50
+ }) => string;
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.lifecycle' | 'session.error' | 'turn.assistant' | 'turn.committed' | 'turn.cost' | 'turn.transcript';
1
+ export type VoiceTraceEventType = 'assistant.guardrail' | 'assistant.memory' | 'assistant.run' | 'agent.handoff' | 'agent.model' | 'agent.result' | 'agent.tool' | 'call.handoff' | 'call.lifecycle' | 'session.error' | 'turn.assistant' | 'turn.committed' | 'turn.cost' | '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;
@@ -0,0 +1,93 @@
1
+ import { Elysia } from 'elysia';
2
+ import { evaluateVoiceTrace, type StoredVoiceTraceEvent, type VoiceTraceEvaluationOptions, type VoiceTraceEventStore, type VoiceTraceRedactionConfig, type VoiceTraceSummary } from './trace';
3
+ export type VoiceTraceTimelineEvent = {
4
+ at: number;
5
+ elapsedMs?: number;
6
+ id: string;
7
+ label: string;
8
+ offsetMs: number;
9
+ provider?: string;
10
+ status?: string;
11
+ turnId?: string;
12
+ type: StoredVoiceTraceEvent['type'];
13
+ };
14
+ export type VoiceTraceTimelineProviderSummary = {
15
+ averageElapsedMs?: number;
16
+ errorCount: number;
17
+ eventCount: number;
18
+ fallbackCount: number;
19
+ maxElapsedMs?: number;
20
+ provider: string;
21
+ successCount: number;
22
+ timeoutCount: number;
23
+ };
24
+ export type VoiceTraceTimelineSession = {
25
+ endedAt?: number;
26
+ evaluation: ReturnType<typeof evaluateVoiceTrace>;
27
+ events: VoiceTraceTimelineEvent[];
28
+ lastEventAt?: number;
29
+ providers: VoiceTraceTimelineProviderSummary[];
30
+ sessionId: string;
31
+ startedAt?: number;
32
+ status: 'failed' | 'healthy' | 'warning';
33
+ summary: VoiceTraceSummary;
34
+ };
35
+ export type VoiceTraceTimelineReport = {
36
+ checkedAt: number;
37
+ failed: number;
38
+ sessions: VoiceTraceTimelineSession[];
39
+ total: number;
40
+ warnings: number;
41
+ };
42
+ export type VoiceTraceTimelineRoutesOptions = {
43
+ evaluation?: VoiceTraceEvaluationOptions;
44
+ headers?: HeadersInit;
45
+ htmlPath?: string;
46
+ limit?: number;
47
+ name?: string;
48
+ path?: string;
49
+ redact?: VoiceTraceRedactionConfig;
50
+ render?: (report: VoiceTraceTimelineReport) => string | Promise<string>;
51
+ renderSession?: (session: VoiceTraceTimelineSession) => string | Promise<string>;
52
+ store: VoiceTraceEventStore;
53
+ title?: string;
54
+ };
55
+ export declare const summarizeVoiceTraceTimeline: (events: StoredVoiceTraceEvent[], options?: {
56
+ evaluation?: VoiceTraceEvaluationOptions;
57
+ limit?: number;
58
+ redact?: VoiceTraceRedactionConfig;
59
+ }) => VoiceTraceTimelineReport;
60
+ export declare const renderVoiceTraceTimelineSessionHTML: (session: VoiceTraceTimelineSession, options?: {
61
+ title?: string;
62
+ }) => string;
63
+ export declare const renderVoiceTraceTimelineHTML: (report: VoiceTraceTimelineReport, options?: {
64
+ title?: string;
65
+ }) => string;
66
+ export declare const createVoiceTraceTimelineRoutes: (options: VoiceTraceTimelineRoutesOptions) => Elysia<"", {
67
+ decorator: {};
68
+ store: {};
69
+ derive: {};
70
+ resolve: {};
71
+ }, {
72
+ typebox: {};
73
+ error: {};
74
+ }, {
75
+ schema: {};
76
+ standaloneSchema: {};
77
+ macro: {};
78
+ macroFn: {};
79
+ parser: {};
80
+ response: {};
81
+ }, {}, {
82
+ derive: {};
83
+ resolve: {};
84
+ schema: {};
85
+ standaloneSchema: {};
86
+ response: {};
87
+ }, {
88
+ derive: {};
89
+ resolve: {};
90
+ schema: {};
91
+ standaloneSchema: {};
92
+ response: {};
93
+ }>;
@@ -0,0 +1,94 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { VoiceSessionRecord, VoiceSessionStore, VoiceTranscriptQuality } from './types';
3
+ export type VoiceTurnQualityStatus = 'pass' | 'warn' | 'fail' | 'unknown';
4
+ export type VoiceTurnQualityItem = {
5
+ averageConfidence?: number;
6
+ committedAt: number;
7
+ correctionChanged: boolean;
8
+ correctionProvider?: string;
9
+ correctionReason?: string;
10
+ costUnits?: number;
11
+ fallbackSelectionReason?: string;
12
+ fallbackUsed: boolean;
13
+ finalTranscriptCount: number;
14
+ latencyMs?: number;
15
+ partialTranscriptCount: number;
16
+ selectedTranscriptCount: number;
17
+ sessionId: string;
18
+ source?: VoiceTranscriptQuality['source'];
19
+ status: VoiceTurnQualityStatus;
20
+ text: string;
21
+ turnId: string;
22
+ };
23
+ export type VoiceTurnQualityReport = {
24
+ checkedAt: number;
25
+ failed: number;
26
+ sessions: number;
27
+ status: VoiceTurnQualityStatus;
28
+ total: number;
29
+ turns: VoiceTurnQualityItem[];
30
+ warnings: number;
31
+ };
32
+ export type VoiceTurnQualityOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord> = {
33
+ confidenceWarnThreshold?: number;
34
+ limit?: number;
35
+ sessionIds?: string[];
36
+ sessions?: TSession[];
37
+ store?: VoiceSessionStore<TSession>;
38
+ };
39
+ export type VoiceTurnQualityHTMLHandlerOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord> = VoiceTurnQualityOptions<TSession> & {
40
+ headers?: HeadersInit;
41
+ render?: (report: VoiceTurnQualityReport) => string | Promise<string>;
42
+ title?: string;
43
+ };
44
+ export type VoiceTurnQualityRoutesOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord> = VoiceTurnQualityHTMLHandlerOptions<TSession> & {
45
+ htmlPath?: false | string;
46
+ name?: string;
47
+ path?: string;
48
+ };
49
+ export declare const summarizeVoiceTurnQuality: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceTurnQualityOptions<TSession>) => Promise<VoiceTurnQualityReport>;
50
+ export declare const renderVoiceTurnQualityHTML: (report: VoiceTurnQualityReport, options?: {
51
+ title?: string;
52
+ }) => string;
53
+ export declare const createVoiceTurnQualityJSONHandler: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceTurnQualityOptions<TSession>) => () => Promise<VoiceTurnQualityReport>;
54
+ export declare const createVoiceTurnQualityHTMLHandler: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceTurnQualityHTMLHandlerOptions<TSession>) => () => Promise<Response>;
55
+ export declare const createVoiceTurnQualityRoutes: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoiceTurnQualityRoutesOptions<TSession>) => Elysia<"", {
56
+ decorator: {};
57
+ store: {};
58
+ derive: {};
59
+ resolve: {};
60
+ }, {
61
+ typebox: {};
62
+ error: {};
63
+ }, {
64
+ schema: {};
65
+ standaloneSchema: {};
66
+ macro: {};
67
+ macroFn: {};
68
+ parser: {};
69
+ response: {};
70
+ }, {
71
+ [x: string]: {
72
+ get: {
73
+ body: unknown;
74
+ params: {};
75
+ query: unknown;
76
+ headers: unknown;
77
+ response: {
78
+ 200: VoiceTurnQualityReport;
79
+ };
80
+ };
81
+ };
82
+ }, {
83
+ derive: {};
84
+ resolve: {};
85
+ schema: {};
86
+ standaloneSchema: {};
87
+ response: {};
88
+ }, {
89
+ derive: {};
90
+ resolve: {};
91
+ schema: {};
92
+ standaloneSchema: {};
93
+ response: {};
94
+ }>;
package/dist/types.d.ts CHANGED
@@ -269,6 +269,65 @@ export type VoiceCallLifecycleState = {
269
269
  lastEventAt: number;
270
270
  startedAt: number;
271
271
  };
272
+ export type VoiceHandoffAction = 'escalate' | 'no-answer' | 'transfer' | 'voicemail';
273
+ export type VoiceHandoffStatus = 'delivered' | 'failed' | 'skipped';
274
+ export type VoiceHandoffResult = {
275
+ deliveredAt?: number;
276
+ deliveredTo?: string;
277
+ error?: string;
278
+ metadata?: Record<string, unknown>;
279
+ status: VoiceHandoffStatus;
280
+ };
281
+ export type VoiceHandoffDeliveryQueueStatus = VoiceHandoffStatus | 'pending';
282
+ export type StoredVoiceHandoffDelivery<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
283
+ action: VoiceHandoffAction;
284
+ context: TContext;
285
+ createdAt: number;
286
+ deliveredAt?: number;
287
+ deliveries?: Record<string, VoiceHandoffResult & {
288
+ adapterId: string;
289
+ adapterKind?: string;
290
+ }>;
291
+ deliveryAttempts?: number;
292
+ deliveryError?: string;
293
+ deliveryStatus: VoiceHandoffDeliveryQueueStatus;
294
+ id: string;
295
+ metadata?: Record<string, unknown>;
296
+ reason?: string;
297
+ result?: TResult;
298
+ session: TSession;
299
+ sessionId: string;
300
+ target?: string;
301
+ updatedAt: number;
302
+ };
303
+ export type VoiceHandoffDeliveryStore<TDelivery extends StoredVoiceHandoffDelivery = StoredVoiceHandoffDelivery> = {
304
+ get: (id: string) => Promise<TDelivery | undefined> | TDelivery | undefined;
305
+ list: () => Promise<TDelivery[]> | TDelivery[];
306
+ remove: (id: string) => Promise<void> | void;
307
+ set: (id: string, delivery: TDelivery) => Promise<void> | void;
308
+ };
309
+ export type VoiceHandoffInput<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
310
+ action: VoiceHandoffAction;
311
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
312
+ context: TContext;
313
+ metadata?: Record<string, unknown>;
314
+ reason?: string;
315
+ result?: TResult;
316
+ session: TSession;
317
+ target?: string;
318
+ };
319
+ export type VoiceHandoffAdapter<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
320
+ actions?: VoiceHandoffAction[];
321
+ handoff: (input: VoiceHandoffInput<TContext, TSession, TResult>) => Promise<VoiceHandoffResult> | VoiceHandoffResult;
322
+ id: string;
323
+ kind?: string;
324
+ };
325
+ export type VoiceHandoffConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
326
+ adapters: VoiceHandoffAdapter<TContext, TSession, TResult>[];
327
+ deliveryQueue?: VoiceHandoffDeliveryStore<StoredVoiceHandoffDelivery<TContext, TSession, TResult>>;
328
+ enqueueOnly?: boolean;
329
+ failMode?: 'record' | 'throw';
330
+ };
272
331
  export type VoiceSessionStore<TSession extends VoiceSessionRecord = VoiceSessionRecord> = SessionStore<TSession, VoiceSessionSummary>;
273
332
  export type VoiceLogger = {
274
333
  debug?: (message: string, meta?: Record<string, unknown>) => void;
@@ -567,6 +626,7 @@ export type VoicePluginConfig<TContext = unknown, TSession extends VoiceSessionR
567
626
  audioConditioning?: VoiceAudioConditioningConfig;
568
627
  logger?: VoiceLogger;
569
628
  htmx?: boolean | VoiceHTMXConfig<TSession, NoInfer<TResult>>;
629
+ handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
570
630
  ops?: VoiceRuntimeOpsConfig<TContext, TSession, TResult>;
571
631
  trace?: VoiceTraceEventStore;
572
632
  } & VoiceRouteConfig<TContext, TSession, TResult>;
@@ -588,6 +648,7 @@ export type CreateVoiceSessionOptions<TContext = unknown, TSession extends Voice
588
648
  sttLifecycle: VoiceSTTLifecycle;
589
649
  turnDetection: VoiceResolvedTurnDetectionConfig;
590
650
  audioConditioning?: VoiceResolvedAudioConditioningConfig;
651
+ handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
591
652
  route: VoiceNormalizedRouteConfig<TContext, TSession, TResult>;
592
653
  logger?: VoiceLogger;
593
654
  };
@@ -604,10 +665,17 @@ export type VoiceClientCloseMessage = {
604
665
  type: 'close';
605
666
  reason?: string;
606
667
  };
668
+ export type VoiceClientCallControlMessage = {
669
+ type: 'call_control';
670
+ action: 'complete' | 'escalate' | 'no-answer' | 'transfer' | 'voicemail';
671
+ metadata?: Record<string, unknown>;
672
+ reason?: string;
673
+ target?: string;
674
+ };
607
675
  export type VoiceClientPingMessage = {
608
676
  type: 'ping';
609
677
  };
610
- export type VoiceClientMessage = VoiceClientStartMessage | VoiceClientEndTurnMessage | VoiceClientCloseMessage | VoiceClientPingMessage;
678
+ export type VoiceClientMessage = VoiceClientStartMessage | VoiceClientEndTurnMessage | VoiceClientCloseMessage | VoiceClientCallControlMessage | VoiceClientPingMessage;
611
679
  export type VoiceServerSessionMessage = {
612
680
  type: 'session';
613
681
  sessionId: string;
@@ -642,6 +710,11 @@ export type VoiceServerCompleteMessage = {
642
710
  type: 'complete';
643
711
  sessionId: string;
644
712
  };
713
+ export type VoiceServerCallLifecycleMessage = {
714
+ type: 'call_lifecycle';
715
+ event: VoiceCallLifecycleEvent;
716
+ sessionId: string;
717
+ };
645
718
  export type VoiceServerErrorMessage = {
646
719
  type: 'error';
647
720
  message: string;
@@ -650,7 +723,7 @@ export type VoiceServerErrorMessage = {
650
723
  export type VoiceServerPongMessage = {
651
724
  type: 'pong';
652
725
  };
653
- export type VoiceServerMessage<TResult = unknown> = VoiceServerSessionMessage | VoiceServerPartialMessage | VoiceServerFinalMessage | VoiceServerTurnMessage<TResult> | VoiceServerAssistantMessage | VoiceServerAudioMessage | VoiceServerCompleteMessage | VoiceServerErrorMessage | VoiceServerPongMessage;
726
+ export type VoiceServerMessage<TResult = unknown> = VoiceServerSessionMessage | VoiceServerPartialMessage | VoiceServerFinalMessage | VoiceServerTurnMessage<TResult> | VoiceServerAssistantMessage | VoiceServerAudioMessage | VoiceServerCallLifecycleMessage | VoiceServerCompleteMessage | VoiceServerErrorMessage | VoiceServerPongMessage;
654
727
  export type VoiceConnectionOptions = {
655
728
  protocols?: string[];
656
729
  scenarioId?: string;
@@ -728,6 +801,7 @@ export type VoiceHTMXOptions<TSession extends VoiceSessionRecord = VoiceSessionR
728
801
  };
729
802
  export type VoiceHTMXConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderer<TSession, TResult> | VoiceHTMXOptions<TSession, TResult>;
730
803
  export type VoiceStreamState<TResult = unknown> = {
804
+ call: VoiceCallLifecycleState | null;
731
805
  sessionId: string | null;
732
806
  scenarioId: string | null;
733
807
  status: VoiceSessionStatus | 'idle';
@@ -744,6 +818,8 @@ export type VoiceStreamState<TResult = unknown> = {
744
818
  isConnected: boolean;
745
819
  };
746
820
  export type VoiceStream<TResult = unknown> = {
821
+ call: VoiceCallLifecycleState | null;
822
+ callControl: (message: Omit<VoiceClientCallControlMessage, 'type'>) => void;
747
823
  close: () => void;
748
824
  start: (input?: {
749
825
  scenarioId?: string;
@@ -810,6 +886,8 @@ export type VoiceBargeInBinding = {
810
886
  };
811
887
  export type VoiceController<TResult = unknown> = {
812
888
  bindHTMX: (options: VoiceHTMXBindingOptions) => () => void;
889
+ call: VoiceCallLifecycleState | null;
890
+ callControl: (message: Omit<VoiceClientCallControlMessage, 'type'>) => void;
813
891
  close: () => void;
814
892
  endTurn: () => void;
815
893
  start: (input?: {
@@ -855,6 +933,10 @@ export type VoiceStoreAction<TResult = unknown> = {
855
933
  sessionId: string;
856
934
  scenarioId?: string;
857
935
  status: VoiceSessionStatus;
936
+ } | {
937
+ type: 'call_lifecycle';
938
+ event: VoiceCallLifecycleEvent;
939
+ sessionId: string;
858
940
  } | {
859
941
  type: 'partial';
860
942
  transcript: Transcript;
@@ -0,0 +1,30 @@
1
+ export declare const VoiceOpsStatus: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ description: StringConstructor;
3
+ includeLinks: {
4
+ default: boolean;
5
+ type: BooleanConstructor;
6
+ };
7
+ intervalMs: NumberConstructor;
8
+ path: {
9
+ default: string;
10
+ type: StringConstructor;
11
+ };
12
+ title: StringConstructor;
13
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
14
+ [key: string]: any;
15
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ description: StringConstructor;
17
+ includeLinks: {
18
+ default: boolean;
19
+ type: BooleanConstructor;
20
+ };
21
+ intervalMs: NumberConstructor;
22
+ path: {
23
+ default: string;
24
+ type: StringConstructor;
25
+ };
26
+ title: StringConstructor;
27
+ }>> & Readonly<{}>, {
28
+ path: string;
29
+ includeLinks: boolean;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;