@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.
- package/README.md +205 -0
- package/dist/agent.d.ts +2 -0
- package/dist/angular/index.d.ts +6 -0
- package/dist/angular/index.js +833 -43
- package/dist/angular/voice-app-kit-status.service.d.ts +12 -0
- package/dist/angular/voice-ops-status.component.d.ts +15 -0
- package/dist/angular/voice-provider-capabilities.service.d.ts +12 -0
- package/dist/angular/voice-provider-status.service.d.ts +12 -0
- package/dist/angular/voice-routing-status.service.d.ts +11 -0
- package/dist/angular/voice-stream.service.d.ts +2 -0
- package/dist/angular/voice-turn-quality.service.d.ts +12 -0
- package/dist/angular/voice-workflow-status.service.d.ts +12 -0
- package/dist/appKit.d.ts +98 -0
- package/dist/assistantHealth.d.ts +81 -0
- package/dist/client/actions.d.ts +22 -0
- package/dist/client/appKitStatus.d.ts +19 -0
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/htmxBootstrap.js +44 -2
- package/dist/client/index.d.ts +26 -0
- package/dist/client/index.js +1290 -2
- package/dist/client/opsStatusWidget.d.ts +40 -0
- package/dist/client/providerCapabilities.d.ts +19 -0
- package/dist/client/providerCapabilitiesWidget.d.ts +32 -0
- package/dist/client/providerSimulationControls.d.ts +33 -0
- package/dist/client/providerSimulationControlsWidget.d.ts +20 -0
- package/dist/client/providerStatus.d.ts +19 -0
- package/dist/client/providerStatusWidget.d.ts +32 -0
- package/dist/client/routingStatus.d.ts +19 -0
- package/dist/client/routingStatusWidget.d.ts +28 -0
- package/dist/client/turnQuality.d.ts +19 -0
- package/dist/client/turnQualityWidget.d.ts +32 -0
- package/dist/client/workflowStatus.d.ts +19 -0
- package/dist/diagnosticsRoutes.d.ts +44 -0
- package/dist/evalRoutes.d.ts +213 -0
- package/dist/handoff.d.ts +54 -0
- package/dist/handoffHealth.d.ts +94 -0
- package/dist/index.d.ts +62 -7
- package/dist/index.js +10382 -2574
- package/dist/modelAdapters.d.ts +75 -0
- package/dist/openaiTTS.d.ts +18 -0
- package/dist/opsConsoleRoutes.d.ts +77 -0
- package/dist/opsWebhook.d.ts +126 -0
- package/dist/outcomeContract.d.ts +112 -0
- package/dist/postgresStore.d.ts +2 -0
- package/dist/productionReadiness.d.ts +111 -0
- package/dist/providerAdapters.d.ts +48 -0
- package/dist/providerCapabilities.d.ts +92 -0
- package/dist/providerHealth.d.ts +79 -0
- package/dist/qualityRoutes.d.ts +76 -0
- package/dist/queue.d.ts +61 -0
- package/dist/react/VoiceOpsStatus.d.ts +6 -0
- package/dist/react/VoiceProviderCapabilities.d.ts +6 -0
- package/dist/react/VoiceProviderSimulationControls.d.ts +5 -0
- package/dist/react/VoiceProviderStatus.d.ts +6 -0
- package/dist/react/VoiceRoutingStatus.d.ts +6 -0
- package/dist/react/VoiceTurnQuality.d.ts +6 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +1884 -11
- package/dist/react/useVoiceAppKitStatus.d.ts +8 -0
- package/dist/react/useVoiceController.d.ts +2 -0
- package/dist/react/useVoiceProviderCapabilities.d.ts +8 -0
- package/dist/react/useVoiceProviderSimulationControls.d.ts +10 -0
- package/dist/react/useVoiceProviderStatus.d.ts +8 -0
- package/dist/react/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/react/useVoiceStream.d.ts +2 -0
- package/dist/react/useVoiceTurnQuality.d.ts +8 -0
- package/dist/react/useVoiceWorkflowStatus.d.ts +8 -0
- package/dist/resilienceRoutes.d.ts +142 -0
- package/dist/sessionReplay.d.ts +175 -0
- package/dist/sqliteStore.d.ts +2 -0
- package/dist/svelte/createVoiceAppKitStatus.d.ts +8 -0
- package/dist/svelte/createVoiceOpsStatus.d.ts +9 -0
- package/dist/svelte/createVoiceProviderCapabilities.d.ts +10 -0
- package/dist/svelte/createVoiceProviderSimulationControls.d.ts +11 -0
- package/dist/svelte/createVoiceProviderStatus.d.ts +10 -0
- package/dist/svelte/createVoiceRoutingStatus.d.ts +10 -0
- package/dist/svelte/createVoiceTurnQuality.d.ts +10 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +8 -0
- package/dist/svelte/index.d.ts +8 -0
- package/dist/svelte/index.js +1330 -3
- package/dist/telephony/contract.d.ts +61 -0
- package/dist/telephony/matrix.d.ts +97 -0
- package/dist/telephony/plivo.d.ts +254 -0
- package/dist/telephony/telnyx.d.ts +247 -0
- package/dist/telephony/twilio.d.ts +132 -0
- package/dist/telephonyOutcome.d.ts +201 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +2543 -14
- package/dist/testing/ioProviderSimulator.d.ts +41 -0
- package/dist/testing/providerSimulator.d.ts +44 -0
- package/dist/toolContract.d.ts +130 -0
- package/dist/toolRuntime.d.ts +50 -0
- package/dist/trace.d.ts +1 -1
- package/dist/traceTimeline.d.ts +93 -0
- package/dist/turnQuality.d.ts +94 -0
- package/dist/types.d.ts +84 -2
- package/dist/vue/VoiceOpsStatus.d.ts +30 -0
- package/dist/vue/VoiceProviderCapabilities.d.ts +51 -0
- package/dist/vue/VoiceProviderSimulationControls.d.ts +88 -0
- package/dist/vue/VoiceProviderStatus.d.ts +51 -0
- package/dist/vue/VoiceRoutingStatus.d.ts +51 -0
- package/dist/vue/VoiceTurnQuality.d.ts +51 -0
- package/dist/vue/index.d.ts +13 -0
- package/dist/vue/index.js +1934 -25
- package/dist/vue/useVoiceAppKitStatus.d.ts +9 -0
- package/dist/vue/useVoiceProviderCapabilities.d.ts +9 -0
- package/dist/vue/useVoiceProviderSimulationControls.d.ts +24 -0
- package/dist/vue/useVoiceProviderStatus.d.ts +9 -0
- package/dist/vue/useVoiceRoutingStatus.d.ts +8 -0
- package/dist/vue/useVoiceStream.d.ts +2 -0
- package/dist/vue/useVoiceTurnQuality.d.ts +9 -0
- package/dist/vue/useVoiceWorkflowStatus.d.ts +9 -0
- package/dist/workflowContract.d.ts +91 -0
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type VoiceTelephonyProvider = 'generic' | 'plivo' | 'telnyx' | 'twilio';
|
|
2
|
+
export type VoiceTelephonySetupStatus<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
|
|
3
|
+
generatedAt: number;
|
|
4
|
+
missing: string[];
|
|
5
|
+
provider: TProvider;
|
|
6
|
+
ready: boolean;
|
|
7
|
+
signing: {
|
|
8
|
+
configured: boolean;
|
|
9
|
+
mode: 'custom' | 'none' | 'provider-signature' | 'twilio-signature';
|
|
10
|
+
verificationUrl?: string;
|
|
11
|
+
};
|
|
12
|
+
urls: {
|
|
13
|
+
stream: string;
|
|
14
|
+
twiml?: string;
|
|
15
|
+
webhook: string;
|
|
16
|
+
};
|
|
17
|
+
warnings: string[];
|
|
18
|
+
};
|
|
19
|
+
export type VoiceTelephonySmokeCheck = {
|
|
20
|
+
details?: Record<string, unknown>;
|
|
21
|
+
message?: string;
|
|
22
|
+
name: string;
|
|
23
|
+
status: 'fail' | 'pass' | 'warn';
|
|
24
|
+
};
|
|
25
|
+
export type VoiceTelephonySmokeReport<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
|
|
26
|
+
checks: VoiceTelephonySmokeCheck[];
|
|
27
|
+
generatedAt: number;
|
|
28
|
+
pass: boolean;
|
|
29
|
+
provider: TProvider;
|
|
30
|
+
setup: VoiceTelephonySetupStatus<TProvider>;
|
|
31
|
+
twiml?: {
|
|
32
|
+
status: number;
|
|
33
|
+
streamUrl?: string;
|
|
34
|
+
};
|
|
35
|
+
webhook?: {
|
|
36
|
+
body?: unknown;
|
|
37
|
+
status: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type VoiceTelephonyContractRequirement = 'signed-webhook' | 'smoke-pass' | 'stream-url' | 'webhook-url' | 'wss-stream';
|
|
41
|
+
export type VoiceTelephonyContractIssue = {
|
|
42
|
+
requirement: VoiceTelephonyContractRequirement;
|
|
43
|
+
severity: 'error' | 'warning';
|
|
44
|
+
message: string;
|
|
45
|
+
};
|
|
46
|
+
export type VoiceTelephonyContractReport<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
|
|
47
|
+
issues: VoiceTelephonyContractIssue[];
|
|
48
|
+
pass: boolean;
|
|
49
|
+
provider: TProvider;
|
|
50
|
+
requirements: VoiceTelephonyContractRequirement[];
|
|
51
|
+
setup: VoiceTelephonySetupStatus<TProvider>;
|
|
52
|
+
smoke?: VoiceTelephonySmokeReport<TProvider>;
|
|
53
|
+
};
|
|
54
|
+
export type VoiceTelephonyContractOptions = {
|
|
55
|
+
requirements?: VoiceTelephonyContractRequirement[];
|
|
56
|
+
};
|
|
57
|
+
export declare const evaluateVoiceTelephonyContract: <TProvider extends VoiceTelephonyProvider>(input: {
|
|
58
|
+
options?: VoiceTelephonyContractOptions;
|
|
59
|
+
setup: VoiceTelephonySetupStatus<TProvider>;
|
|
60
|
+
smoke?: VoiceTelephonySmokeReport<TProvider>;
|
|
61
|
+
}) => VoiceTelephonyContractReport<TProvider>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type VoiceTelephonyContractOptions, type VoiceTelephonyContractReport, type VoiceTelephonyProvider, type VoiceTelephonySetupStatus, type VoiceTelephonySmokeReport } from './contract';
|
|
3
|
+
export type VoiceTelephonyCarrierMatrixStatus = 'fail' | 'pass' | 'warn';
|
|
4
|
+
export type VoiceTelephonyCarrierMatrixInput<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
|
|
5
|
+
contract?: VoiceTelephonyContractReport<TProvider>;
|
|
6
|
+
name?: string;
|
|
7
|
+
setup: VoiceTelephonySetupStatus<TProvider>;
|
|
8
|
+
smoke?: VoiceTelephonySmokeReport<TProvider>;
|
|
9
|
+
};
|
|
10
|
+
export type VoiceTelephonyCarrierMatrixEntry<TProvider extends VoiceTelephonyProvider = VoiceTelephonyProvider> = {
|
|
11
|
+
contract: VoiceTelephonyContractReport<TProvider>;
|
|
12
|
+
issues: VoiceTelephonyContractReport<TProvider>['issues'];
|
|
13
|
+
name: string;
|
|
14
|
+
provider: TProvider;
|
|
15
|
+
ready: boolean;
|
|
16
|
+
setup: VoiceTelephonySetupStatus<TProvider>;
|
|
17
|
+
smoke?: VoiceTelephonySmokeReport<TProvider>;
|
|
18
|
+
status: VoiceTelephonyCarrierMatrixStatus;
|
|
19
|
+
summary: {
|
|
20
|
+
errors: number;
|
|
21
|
+
failures: number;
|
|
22
|
+
missing: number;
|
|
23
|
+
warnings: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type VoiceTelephonyCarrierMatrix = {
|
|
27
|
+
entries: VoiceTelephonyCarrierMatrixEntry[];
|
|
28
|
+
generatedAt: number;
|
|
29
|
+
pass: boolean;
|
|
30
|
+
summary: {
|
|
31
|
+
contractsPassing: number;
|
|
32
|
+
failing: number;
|
|
33
|
+
providers: number;
|
|
34
|
+
ready: number;
|
|
35
|
+
smokePassing: number;
|
|
36
|
+
warnings: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type VoiceTelephonyCarrierMatrixOptions = {
|
|
40
|
+
contract?: VoiceTelephonyContractOptions;
|
|
41
|
+
generatedAt?: number;
|
|
42
|
+
providers: VoiceTelephonyCarrierMatrixInput[];
|
|
43
|
+
};
|
|
44
|
+
export type VoiceTelephonyCarrierMatrixRoutesOptions = {
|
|
45
|
+
load: (input: {
|
|
46
|
+
query: Record<string, unknown>;
|
|
47
|
+
request: Request;
|
|
48
|
+
}) => Promise<VoiceTelephonyCarrierMatrixInput[]> | VoiceTelephonyCarrierMatrixInput[];
|
|
49
|
+
name?: string;
|
|
50
|
+
path?: string;
|
|
51
|
+
title?: string;
|
|
52
|
+
contract?: VoiceTelephonyContractOptions;
|
|
53
|
+
};
|
|
54
|
+
export declare const createVoiceTelephonyCarrierMatrix: (options: VoiceTelephonyCarrierMatrixOptions) => VoiceTelephonyCarrierMatrix;
|
|
55
|
+
export declare const renderVoiceTelephonyCarrierMatrixHTML: (matrix: VoiceTelephonyCarrierMatrix, options?: {
|
|
56
|
+
title?: string;
|
|
57
|
+
}) => string;
|
|
58
|
+
export declare const createVoiceTelephonyCarrierMatrixRoutes: (options: VoiceTelephonyCarrierMatrixRoutesOptions) => Elysia<"", {
|
|
59
|
+
decorator: {};
|
|
60
|
+
store: {};
|
|
61
|
+
derive: {};
|
|
62
|
+
resolve: {};
|
|
63
|
+
}, {
|
|
64
|
+
typebox: {};
|
|
65
|
+
error: {};
|
|
66
|
+
}, {
|
|
67
|
+
schema: {};
|
|
68
|
+
standaloneSchema: {};
|
|
69
|
+
macro: {};
|
|
70
|
+
macroFn: {};
|
|
71
|
+
parser: {};
|
|
72
|
+
response: {};
|
|
73
|
+
}, {
|
|
74
|
+
[x: string]: {
|
|
75
|
+
get: {
|
|
76
|
+
body: unknown;
|
|
77
|
+
params: {};
|
|
78
|
+
query: unknown;
|
|
79
|
+
headers: unknown;
|
|
80
|
+
response: {
|
|
81
|
+
200: Response | VoiceTelephonyCarrierMatrix;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}, {
|
|
86
|
+
derive: {};
|
|
87
|
+
resolve: {};
|
|
88
|
+
schema: {};
|
|
89
|
+
standaloneSchema: {};
|
|
90
|
+
response: {};
|
|
91
|
+
}, {
|
|
92
|
+
derive: {};
|
|
93
|
+
resolve: {};
|
|
94
|
+
schema: {};
|
|
95
|
+
standaloneSchema: {};
|
|
96
|
+
response: {};
|
|
97
|
+
}>;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type VoiceTelephonyContractReport, type VoiceTelephonySetupStatus, type VoiceTelephonySmokeCheck, type VoiceTelephonySmokeReport } from './contract';
|
|
3
|
+
import { type VoiceTelephonyOutcomePolicy, type VoiceTelephonyWebhookRoutesOptions, type VoiceTelephonyWebhookVerificationResult } from '../telephonyOutcome';
|
|
4
|
+
import type { VoiceServerMessage, VoiceSessionRecord } from '../types';
|
|
5
|
+
import { type TwilioMediaStreamBridgeOptions } from './twilio';
|
|
6
|
+
export type PlivoInboundMessage = {
|
|
7
|
+
event: 'start';
|
|
8
|
+
sequenceNumber?: number;
|
|
9
|
+
start?: {
|
|
10
|
+
callId?: string;
|
|
11
|
+
callUuid?: string;
|
|
12
|
+
extra_headers?: string;
|
|
13
|
+
mediaFormat?: {
|
|
14
|
+
channels?: number;
|
|
15
|
+
encoding?: string;
|
|
16
|
+
sampleRate?: number;
|
|
17
|
+
};
|
|
18
|
+
streamId?: string;
|
|
19
|
+
};
|
|
20
|
+
streamId?: string;
|
|
21
|
+
} | {
|
|
22
|
+
event: 'media';
|
|
23
|
+
media: {
|
|
24
|
+
payload: string;
|
|
25
|
+
timestamp?: string;
|
|
26
|
+
track?: 'inbound' | 'outbound';
|
|
27
|
+
};
|
|
28
|
+
sequenceNumber?: number;
|
|
29
|
+
streamId?: string;
|
|
30
|
+
} | {
|
|
31
|
+
event: 'dtmf';
|
|
32
|
+
dtmf?: {
|
|
33
|
+
digit?: string;
|
|
34
|
+
timestamp?: string;
|
|
35
|
+
track?: string;
|
|
36
|
+
};
|
|
37
|
+
sequenceNumber?: number;
|
|
38
|
+
streamId?: string;
|
|
39
|
+
} | {
|
|
40
|
+
event: 'playedStream';
|
|
41
|
+
name?: string;
|
|
42
|
+
sequenceNumber?: number;
|
|
43
|
+
streamId?: string;
|
|
44
|
+
} | {
|
|
45
|
+
event: 'clearedAudio';
|
|
46
|
+
sequenceNumber?: number;
|
|
47
|
+
streamId?: string;
|
|
48
|
+
} | {
|
|
49
|
+
event: 'stop';
|
|
50
|
+
sequenceNumber?: number;
|
|
51
|
+
stop?: {
|
|
52
|
+
callId?: string;
|
|
53
|
+
callUuid?: string;
|
|
54
|
+
};
|
|
55
|
+
streamId?: string;
|
|
56
|
+
};
|
|
57
|
+
export type PlivoOutboundPlayAudioMessage = {
|
|
58
|
+
event: 'playAudio';
|
|
59
|
+
media: {
|
|
60
|
+
contentType: 'audio/x-mulaw';
|
|
61
|
+
payload: string;
|
|
62
|
+
sampleRate: 8000;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type PlivoOutboundClearAudioMessage = {
|
|
66
|
+
event: 'clearAudio';
|
|
67
|
+
streamId?: string;
|
|
68
|
+
};
|
|
69
|
+
export type PlivoOutboundCheckpointMessage = {
|
|
70
|
+
event: 'checkpoint';
|
|
71
|
+
name: string;
|
|
72
|
+
streamId?: string;
|
|
73
|
+
};
|
|
74
|
+
export type PlivoOutboundMessage = PlivoOutboundPlayAudioMessage | PlivoOutboundClearAudioMessage | PlivoOutboundCheckpointMessage;
|
|
75
|
+
export type PlivoMediaStreamSocket = {
|
|
76
|
+
close: (code?: number, reason?: string) => void | Promise<void>;
|
|
77
|
+
send: (data: string) => void | Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
export type PlivoMediaStreamBridgeOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Omit<TwilioMediaStreamBridgeOptions<TContext, TSession, TResult>, 'onVoiceMessage'> & {
|
|
80
|
+
onVoiceMessage?: (input: {
|
|
81
|
+
callId?: string;
|
|
82
|
+
message: VoiceServerMessage<TResult>;
|
|
83
|
+
sessionId: string;
|
|
84
|
+
streamId?: string;
|
|
85
|
+
}) => Promise<void> | void;
|
|
86
|
+
};
|
|
87
|
+
export type PlivoMediaStreamBridge = {
|
|
88
|
+
close: (reason?: string) => Promise<void>;
|
|
89
|
+
getSessionId: () => string | null;
|
|
90
|
+
getStreamId: () => string | null;
|
|
91
|
+
handleMessage: (raw: string | PlivoInboundMessage) => Promise<void>;
|
|
92
|
+
};
|
|
93
|
+
export type PlivoVoiceResponseOptions = {
|
|
94
|
+
audioTrack?: 'both' | 'inbound' | 'outbound';
|
|
95
|
+
bidirectional?: boolean;
|
|
96
|
+
contentType?: 'audio/x-l16;rate=8000' | 'audio/x-l16;rate=16000' | 'audio/x-mulaw;rate=8000';
|
|
97
|
+
extraHeaders?: Record<string, string | number | boolean | undefined> | string;
|
|
98
|
+
keepCallAlive?: boolean;
|
|
99
|
+
noiseCancellation?: boolean;
|
|
100
|
+
noiseCancellationLevel?: number;
|
|
101
|
+
statusCallbackMethod?: 'GET' | 'POST';
|
|
102
|
+
statusCallbackUrl?: string;
|
|
103
|
+
streamTimeout?: number;
|
|
104
|
+
streamUrl: string;
|
|
105
|
+
};
|
|
106
|
+
export type PlivoVoiceSetupStatus = VoiceTelephonySetupStatus<'plivo'> & {
|
|
107
|
+
urls: VoiceTelephonySetupStatus<'plivo'>['urls'] & {
|
|
108
|
+
answer: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type PlivoVoiceSetupOptions = {
|
|
112
|
+
path?: false | string;
|
|
113
|
+
requiredEnv?: Record<string, string | undefined>;
|
|
114
|
+
title?: string;
|
|
115
|
+
};
|
|
116
|
+
export type PlivoVoiceSmokeCheck = VoiceTelephonySmokeCheck;
|
|
117
|
+
export type PlivoVoiceSmokeReport = VoiceTelephonySmokeReport<'plivo'> & {
|
|
118
|
+
answer?: {
|
|
119
|
+
status: number;
|
|
120
|
+
streamUrl?: string;
|
|
121
|
+
};
|
|
122
|
+
contract: VoiceTelephonyContractReport<'plivo'>;
|
|
123
|
+
setup: PlivoVoiceSetupStatus;
|
|
124
|
+
};
|
|
125
|
+
export type PlivoVoiceSmokeOptions = {
|
|
126
|
+
callUuid?: string;
|
|
127
|
+
eventType?: string;
|
|
128
|
+
path?: false | string;
|
|
129
|
+
sessionId?: string;
|
|
130
|
+
sipCode?: number;
|
|
131
|
+
status?: string;
|
|
132
|
+
title?: string;
|
|
133
|
+
};
|
|
134
|
+
export type PlivoVoiceRoutesOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
135
|
+
answer?: {
|
|
136
|
+
path?: string;
|
|
137
|
+
response?: Omit<PlivoVoiceResponseOptions, 'streamUrl'>;
|
|
138
|
+
streamUrl?: string | ((input: {
|
|
139
|
+
query: Record<string, unknown>;
|
|
140
|
+
request: Request;
|
|
141
|
+
streamPath: string;
|
|
142
|
+
}) => Promise<string> | string);
|
|
143
|
+
};
|
|
144
|
+
bridge?: PlivoMediaStreamBridgeOptions<TContext, TSession, TResult>;
|
|
145
|
+
context?: TContext;
|
|
146
|
+
name?: string;
|
|
147
|
+
outcomePolicy?: VoiceTelephonyOutcomePolicy;
|
|
148
|
+
setup?: PlivoVoiceSetupOptions;
|
|
149
|
+
smoke?: PlivoVoiceSmokeOptions;
|
|
150
|
+
streamPath?: string;
|
|
151
|
+
webhook?: Omit<VoiceTelephonyWebhookRoutesOptions<TContext, TSession, TResult>, 'context' | 'path' | 'policy' | 'provider'> & {
|
|
152
|
+
authToken?: string;
|
|
153
|
+
path?: string;
|
|
154
|
+
policy?: VoiceTelephonyOutcomePolicy;
|
|
155
|
+
verificationUrl?: string | ((input: {
|
|
156
|
+
query: Record<string, unknown>;
|
|
157
|
+
request: Request;
|
|
158
|
+
}) => string);
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export declare const createPlivoVoiceResponse: (options: PlivoVoiceResponseOptions) => string;
|
|
162
|
+
export declare const createPlivoMediaStreamBridge: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(socket: PlivoMediaStreamSocket, options: PlivoMediaStreamBridgeOptions<TContext, TSession, TResult>) => PlivoMediaStreamBridge;
|
|
163
|
+
export declare const signVoicePlivoWebhook: (input: {
|
|
164
|
+
authToken: string;
|
|
165
|
+
body?: unknown;
|
|
166
|
+
nonce: string;
|
|
167
|
+
url: string;
|
|
168
|
+
}) => Promise<string>;
|
|
169
|
+
export declare const verifyVoicePlivoWebhookSignature: (input: {
|
|
170
|
+
authToken?: string;
|
|
171
|
+
body?: unknown;
|
|
172
|
+
headers: Headers;
|
|
173
|
+
url: string;
|
|
174
|
+
}) => Promise<VoiceTelephonyWebhookVerificationResult>;
|
|
175
|
+
export declare const createPlivoVoiceRoutes: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(options?: PlivoVoiceRoutesOptions<TContext, TSession, TResult>) => Elysia<"", {
|
|
176
|
+
decorator: {};
|
|
177
|
+
store: {};
|
|
178
|
+
derive: {};
|
|
179
|
+
resolve: {};
|
|
180
|
+
}, {
|
|
181
|
+
typebox: {};
|
|
182
|
+
error: {};
|
|
183
|
+
}, {
|
|
184
|
+
schema: {};
|
|
185
|
+
standaloneSchema: {};
|
|
186
|
+
macro: {};
|
|
187
|
+
macroFn: {};
|
|
188
|
+
parser: {};
|
|
189
|
+
response: {};
|
|
190
|
+
}, {
|
|
191
|
+
[x: string]: {
|
|
192
|
+
get: {
|
|
193
|
+
body: unknown;
|
|
194
|
+
params: {};
|
|
195
|
+
query: unknown;
|
|
196
|
+
headers: unknown;
|
|
197
|
+
response: {
|
|
198
|
+
200: Response;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
} & {
|
|
203
|
+
[x: string]: {
|
|
204
|
+
post: {
|
|
205
|
+
body: unknown;
|
|
206
|
+
params: {};
|
|
207
|
+
query: unknown;
|
|
208
|
+
headers: unknown;
|
|
209
|
+
response: {
|
|
210
|
+
200: Response;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
} & {
|
|
215
|
+
[x: string]: {
|
|
216
|
+
subscribe: {
|
|
217
|
+
body: unknown;
|
|
218
|
+
params: {};
|
|
219
|
+
query: unknown;
|
|
220
|
+
headers: unknown;
|
|
221
|
+
response: {};
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
} & {
|
|
225
|
+
[x: string]: {
|
|
226
|
+
post: {
|
|
227
|
+
body: unknown;
|
|
228
|
+
params: {};
|
|
229
|
+
query: unknown;
|
|
230
|
+
headers: unknown;
|
|
231
|
+
response: {
|
|
232
|
+
200: Response | import("..").VoiceTelephonyWebhookDecision<TResult>;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
}, {
|
|
237
|
+
derive: {};
|
|
238
|
+
resolve: {};
|
|
239
|
+
schema: {};
|
|
240
|
+
standaloneSchema: {};
|
|
241
|
+
response: {};
|
|
242
|
+
}, {
|
|
243
|
+
derive: {};
|
|
244
|
+
resolve: {};
|
|
245
|
+
schema: {};
|
|
246
|
+
standaloneSchema: {};
|
|
247
|
+
response: {};
|
|
248
|
+
} & {
|
|
249
|
+
derive: {};
|
|
250
|
+
resolve: {};
|
|
251
|
+
schema: {};
|
|
252
|
+
standaloneSchema: {};
|
|
253
|
+
response: {};
|
|
254
|
+
}>;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type VoiceTelephonyContractReport, type VoiceTelephonySetupStatus, type VoiceTelephonySmokeCheck, type VoiceTelephonySmokeReport } from './contract';
|
|
3
|
+
import { type VoiceTelephonyOutcomePolicy, type VoiceTelephonyWebhookRoutesOptions, type VoiceTelephonyWebhookVerificationResult } from '../telephonyOutcome';
|
|
4
|
+
import type { VoiceServerMessage, VoiceSessionRecord } from '../types';
|
|
5
|
+
import { type TwilioMediaStreamBridgeOptions } from './twilio';
|
|
6
|
+
export type TelnyxMediaPayload = {
|
|
7
|
+
chunk?: string;
|
|
8
|
+
payload: string;
|
|
9
|
+
timestamp?: string;
|
|
10
|
+
track?: 'inbound' | 'outbound' | 'inbound_track' | 'outbound_track';
|
|
11
|
+
};
|
|
12
|
+
export type TelnyxInboundMessage = {
|
|
13
|
+
event: 'connected';
|
|
14
|
+
version?: string;
|
|
15
|
+
} | {
|
|
16
|
+
event: 'start';
|
|
17
|
+
sequence_number?: string;
|
|
18
|
+
start?: {
|
|
19
|
+
call_control_id?: string;
|
|
20
|
+
call_leg_id?: string;
|
|
21
|
+
call_session_id?: string;
|
|
22
|
+
custom_parameters?: Record<string, string>;
|
|
23
|
+
media_format?: {
|
|
24
|
+
channels?: number;
|
|
25
|
+
encoding?: string;
|
|
26
|
+
sample_rate?: number;
|
|
27
|
+
};
|
|
28
|
+
user_id?: string;
|
|
29
|
+
};
|
|
30
|
+
stream_id?: string;
|
|
31
|
+
} | {
|
|
32
|
+
event: 'media';
|
|
33
|
+
media: TelnyxMediaPayload;
|
|
34
|
+
sequence_number?: string;
|
|
35
|
+
stream_id?: string;
|
|
36
|
+
} | {
|
|
37
|
+
event: 'mark';
|
|
38
|
+
mark?: {
|
|
39
|
+
name?: string;
|
|
40
|
+
};
|
|
41
|
+
sequence_number?: string;
|
|
42
|
+
stream_id?: string;
|
|
43
|
+
} | {
|
|
44
|
+
event: 'dtmf';
|
|
45
|
+
dtmf?: {
|
|
46
|
+
digit?: string;
|
|
47
|
+
};
|
|
48
|
+
sequence_number?: string;
|
|
49
|
+
stream_id?: string;
|
|
50
|
+
} | {
|
|
51
|
+
event: 'error';
|
|
52
|
+
payload?: {
|
|
53
|
+
code?: number;
|
|
54
|
+
detail?: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
};
|
|
57
|
+
stream_id?: string;
|
|
58
|
+
} | {
|
|
59
|
+
event: 'stop';
|
|
60
|
+
sequence_number?: string;
|
|
61
|
+
stop?: {
|
|
62
|
+
call_control_id?: string;
|
|
63
|
+
user_id?: string;
|
|
64
|
+
};
|
|
65
|
+
stream_id?: string;
|
|
66
|
+
};
|
|
67
|
+
export type TelnyxOutboundMediaMessage = {
|
|
68
|
+
event: 'media';
|
|
69
|
+
media: {
|
|
70
|
+
payload: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export type TelnyxOutboundClearMessage = {
|
|
74
|
+
event: 'clear';
|
|
75
|
+
};
|
|
76
|
+
export type TelnyxOutboundMarkMessage = {
|
|
77
|
+
event: 'mark';
|
|
78
|
+
mark: {
|
|
79
|
+
name: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export type TelnyxOutboundMessage = TelnyxOutboundMediaMessage | TelnyxOutboundClearMessage | TelnyxOutboundMarkMessage;
|
|
83
|
+
export type TelnyxMediaStreamSocket = {
|
|
84
|
+
close: (code?: number, reason?: string) => void | Promise<void>;
|
|
85
|
+
send: (data: string) => void | Promise<void>;
|
|
86
|
+
};
|
|
87
|
+
export type TelnyxMediaStreamBridgeOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Omit<TwilioMediaStreamBridgeOptions<TContext, TSession, TResult>, 'onVoiceMessage'> & {
|
|
88
|
+
onVoiceMessage?: (input: {
|
|
89
|
+
callControlId?: string;
|
|
90
|
+
message: VoiceServerMessage<TResult>;
|
|
91
|
+
sessionId: string;
|
|
92
|
+
streamId?: string;
|
|
93
|
+
}) => Promise<void> | void;
|
|
94
|
+
};
|
|
95
|
+
export type TelnyxMediaStreamBridge = {
|
|
96
|
+
close: (reason?: string) => Promise<void>;
|
|
97
|
+
getSessionId: () => string | null;
|
|
98
|
+
getStreamId: () => string | null;
|
|
99
|
+
handleMessage: (raw: string | TelnyxInboundMessage) => Promise<void>;
|
|
100
|
+
};
|
|
101
|
+
export type TelnyxVoiceResponseOptions = {
|
|
102
|
+
bidirectionalCodec?: 'AMR-WB' | 'G722' | 'OPUS' | 'PCMA' | 'PCMU';
|
|
103
|
+
bidirectionalMode?: 'mp3' | 'rtp';
|
|
104
|
+
codec?: 'AMR-WB' | 'G722' | 'OPUS' | 'PCMA' | 'PCMU' | 'default';
|
|
105
|
+
streamName?: string;
|
|
106
|
+
streamUrl: string;
|
|
107
|
+
track?: 'both_tracks' | 'inbound_track' | 'outbound_track';
|
|
108
|
+
};
|
|
109
|
+
export type TelnyxVoiceSetupStatus = VoiceTelephonySetupStatus<'telnyx'> & {
|
|
110
|
+
urls: VoiceTelephonySetupStatus<'telnyx'>['urls'] & {
|
|
111
|
+
texml: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export type TelnyxVoiceSetupOptions = {
|
|
115
|
+
path?: false | string;
|
|
116
|
+
requiredEnv?: Record<string, string | undefined>;
|
|
117
|
+
title?: string;
|
|
118
|
+
};
|
|
119
|
+
export type TelnyxVoiceSmokeCheck = VoiceTelephonySmokeCheck;
|
|
120
|
+
export type TelnyxVoiceSmokeReport = VoiceTelephonySmokeReport<'telnyx'> & {
|
|
121
|
+
contract: VoiceTelephonyContractReport<'telnyx'>;
|
|
122
|
+
setup: TelnyxVoiceSetupStatus;
|
|
123
|
+
texml?: {
|
|
124
|
+
status: number;
|
|
125
|
+
streamUrl?: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export type TelnyxVoiceSmokeOptions = {
|
|
129
|
+
callControlId?: string;
|
|
130
|
+
callLegId?: string;
|
|
131
|
+
eventType?: string;
|
|
132
|
+
path?: false | string;
|
|
133
|
+
sessionId?: string;
|
|
134
|
+
title?: string;
|
|
135
|
+
};
|
|
136
|
+
export type TelnyxVoiceRoutesOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
137
|
+
bridge?: TelnyxMediaStreamBridgeOptions<TContext, TSession, TResult>;
|
|
138
|
+
context?: TContext;
|
|
139
|
+
name?: string;
|
|
140
|
+
outcomePolicy?: VoiceTelephonyOutcomePolicy;
|
|
141
|
+
setup?: TelnyxVoiceSetupOptions;
|
|
142
|
+
smoke?: TelnyxVoiceSmokeOptions;
|
|
143
|
+
streamPath?: string;
|
|
144
|
+
texml?: {
|
|
145
|
+
path?: string;
|
|
146
|
+
response?: Omit<TelnyxVoiceResponseOptions, 'streamUrl'>;
|
|
147
|
+
streamUrl?: string | ((input: {
|
|
148
|
+
query: Record<string, unknown>;
|
|
149
|
+
request: Request;
|
|
150
|
+
streamPath: string;
|
|
151
|
+
}) => Promise<string> | string);
|
|
152
|
+
};
|
|
153
|
+
webhook?: Omit<VoiceTelephonyWebhookRoutesOptions<TContext, TSession, TResult>, 'context' | 'path' | 'policy' | 'provider'> & {
|
|
154
|
+
path?: string;
|
|
155
|
+
policy?: VoiceTelephonyOutcomePolicy;
|
|
156
|
+
publicKey?: string;
|
|
157
|
+
toleranceSeconds?: number;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
export declare const createTelnyxVoiceResponse: (options: TelnyxVoiceResponseOptions) => string;
|
|
161
|
+
export declare const createTelnyxMediaStreamBridge: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(socket: TelnyxMediaStreamSocket, options: TelnyxMediaStreamBridgeOptions<TContext, TSession, TResult>) => TelnyxMediaStreamBridge;
|
|
162
|
+
export declare const verifyVoiceTelnyxWebhookSignature: (input: {
|
|
163
|
+
body: string;
|
|
164
|
+
headers: Headers;
|
|
165
|
+
publicKey?: string;
|
|
166
|
+
toleranceSeconds?: number;
|
|
167
|
+
}) => Promise<VoiceTelephonyWebhookVerificationResult>;
|
|
168
|
+
export declare const createTelnyxVoiceRoutes: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(options?: TelnyxVoiceRoutesOptions<TContext, TSession, TResult>) => Elysia<"", {
|
|
169
|
+
decorator: {};
|
|
170
|
+
store: {};
|
|
171
|
+
derive: {};
|
|
172
|
+
resolve: {};
|
|
173
|
+
}, {
|
|
174
|
+
typebox: {};
|
|
175
|
+
error: {};
|
|
176
|
+
}, {
|
|
177
|
+
schema: {};
|
|
178
|
+
standaloneSchema: {};
|
|
179
|
+
macro: {};
|
|
180
|
+
macroFn: {};
|
|
181
|
+
parser: {};
|
|
182
|
+
response: {};
|
|
183
|
+
}, {
|
|
184
|
+
[x: string]: {
|
|
185
|
+
get: {
|
|
186
|
+
body: unknown;
|
|
187
|
+
params: {};
|
|
188
|
+
query: unknown;
|
|
189
|
+
headers: unknown;
|
|
190
|
+
response: {
|
|
191
|
+
200: Response;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
} & {
|
|
196
|
+
[x: string]: {
|
|
197
|
+
post: {
|
|
198
|
+
body: unknown;
|
|
199
|
+
params: {};
|
|
200
|
+
query: unknown;
|
|
201
|
+
headers: unknown;
|
|
202
|
+
response: {
|
|
203
|
+
200: Response;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
} & {
|
|
208
|
+
[x: string]: {
|
|
209
|
+
subscribe: {
|
|
210
|
+
body: unknown;
|
|
211
|
+
params: {};
|
|
212
|
+
query: unknown;
|
|
213
|
+
headers: unknown;
|
|
214
|
+
response: {};
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
} & {
|
|
218
|
+
[x: string]: {
|
|
219
|
+
post: {
|
|
220
|
+
body: unknown;
|
|
221
|
+
params: {};
|
|
222
|
+
query: unknown;
|
|
223
|
+
headers: unknown;
|
|
224
|
+
response: {
|
|
225
|
+
200: Response | import("..").VoiceTelephonyWebhookDecision<TResult>;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
}, {
|
|
230
|
+
derive: {};
|
|
231
|
+
resolve: {};
|
|
232
|
+
schema: {};
|
|
233
|
+
standaloneSchema: {};
|
|
234
|
+
response: {};
|
|
235
|
+
}, {
|
|
236
|
+
derive: {};
|
|
237
|
+
resolve: {};
|
|
238
|
+
schema: {};
|
|
239
|
+
standaloneSchema: {};
|
|
240
|
+
response: {};
|
|
241
|
+
} & {
|
|
242
|
+
derive: {};
|
|
243
|
+
resolve: {};
|
|
244
|
+
schema: {};
|
|
245
|
+
standaloneSchema: {};
|
|
246
|
+
response: {};
|
|
247
|
+
}>;
|