@contractspec/lib.contracts-integrations 2.4.0 → 2.6.0

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 (37) hide show
  1. package/dist/index.js +381 -55
  2. package/dist/integrations/index.js +379 -53
  3. package/dist/integrations/providers/deepgram.d.ts +3 -0
  4. package/dist/integrations/providers/deepgram.js +99 -0
  5. package/dist/integrations/providers/elevenlabs.js +6 -3
  6. package/dist/integrations/providers/fal-image.d.ts +3 -0
  7. package/dist/integrations/providers/fal-image.js +92 -0
  8. package/dist/integrations/providers/fal.js +2 -2
  9. package/dist/integrations/providers/gradium.js +2 -2
  10. package/dist/integrations/providers/image.d.ts +85 -0
  11. package/dist/integrations/providers/image.js +16 -0
  12. package/dist/integrations/providers/index.d.ts +6 -0
  13. package/dist/integrations/providers/index.js +380 -54
  14. package/dist/integrations/providers/openai-image.d.ts +3 -0
  15. package/dist/integrations/providers/openai-image.js +96 -0
  16. package/dist/integrations/providers/openai-realtime.d.ts +3 -0
  17. package/dist/integrations/providers/openai-realtime.js +97 -0
  18. package/dist/integrations/providers/registry.js +192 -33
  19. package/dist/integrations/providers/video.d.ts +10 -0
  20. package/dist/integrations/providers/voice-video-sync.d.ts +29 -0
  21. package/dist/integrations/providers/voice-video-sync.js +1 -0
  22. package/dist/integrations/providers/voice.d.ts +149 -12
  23. package/dist/integrations/spec.d.ts +1 -1
  24. package/dist/node/index.js +381 -55
  25. package/dist/node/integrations/index.js +379 -53
  26. package/dist/node/integrations/providers/deepgram.js +98 -0
  27. package/dist/node/integrations/providers/elevenlabs.js +6 -3
  28. package/dist/node/integrations/providers/fal-image.js +91 -0
  29. package/dist/node/integrations/providers/fal.js +2 -2
  30. package/dist/node/integrations/providers/gradium.js +2 -2
  31. package/dist/node/integrations/providers/image.js +15 -0
  32. package/dist/node/integrations/providers/index.js +380 -54
  33. package/dist/node/integrations/providers/openai-image.js +95 -0
  34. package/dist/node/integrations/providers/openai-realtime.js +96 -0
  35. package/dist/node/integrations/providers/registry.js +192 -33
  36. package/dist/node/integrations/providers/voice-video-sync.js +0 -0
  37. package/package.json +77 -5
@@ -0,0 +1,29 @@
1
+ import type { WordTiming } from './voice';
2
+ /**
3
+ * Timing map produced by voice/tts, consumed by video-gen.
4
+ * Video-gen uses this to adjust scene durations to match voice.
5
+ */
6
+ export interface VoiceTimingMap {
7
+ totalDurationMs: number;
8
+ segments: VoiceSegmentTiming[];
9
+ fps: number;
10
+ }
11
+ export interface VoiceSegmentTiming {
12
+ /** Matches a sceneId from video-gen's ScenePlan */
13
+ sceneId: string;
14
+ /** Voice audio duration for this segment in ms */
15
+ durationMs: number;
16
+ /** Equivalent duration in frames */
17
+ durationInFrames: number;
18
+ /** Recommended scene duration (voice + breathing room) */
19
+ recommendedSceneDurationInFrames: number;
20
+ wordTimings?: WordTiming[];
21
+ }
22
+ export interface VoicePacingDirective {
23
+ sceneId: string;
24
+ rate: number;
25
+ emphasis: 'reduced' | 'normal' | 'strong';
26
+ tone: 'neutral' | 'urgent' | 'excited' | 'calm' | 'authoritative';
27
+ leadingSilenceMs: number;
28
+ trailingSilenceMs: number;
29
+ }
@@ -5,27 +5,164 @@ export interface Voice {
5
5
  language?: string;
6
6
  gender?: 'male' | 'female' | 'neutral';
7
7
  previewUrl?: string;
8
+ capabilities?: ('tts' | 'conversational')[];
8
9
  metadata?: Record<string, string>;
9
10
  }
10
- export interface VoiceSynthesisInput {
11
+ export type AudioFormat = 'mp3' | 'wav' | 'ogg' | 'pcm' | 'opus';
12
+ export interface AudioData {
13
+ data: Uint8Array;
14
+ format: AudioFormat;
15
+ sampleRateHz: number;
16
+ durationMs?: number;
17
+ channels?: 1 | 2;
18
+ }
19
+ export interface WordTiming {
20
+ word: string;
21
+ startMs: number;
22
+ endMs: number;
23
+ confidence?: number;
24
+ }
25
+ export interface TTSSynthesisInput {
11
26
  text: string;
12
- voiceId?: string;
27
+ voiceId: string;
13
28
  language?: string;
29
+ format?: AudioFormat;
30
+ sampleRateHz?: number;
31
+ /** Speech rate multiplier (0.5-2.0). Default 1.0 */
32
+ rate?: number;
33
+ /** Pitch adjustment in semitones (-12 to +12). Default 0 */
34
+ pitch?: number;
35
+ /** Emphasis level */
36
+ emphasis?: 'reduced' | 'normal' | 'strong';
37
+ /** Style (0-1, provider-specific) */
14
38
  style?: number;
39
+ /** Stability (0-1, provider-specific) */
15
40
  stability?: number;
16
- similarityBoost?: number;
17
- format?: 'mp3' | 'wav' | 'ogg' | 'pcm';
18
- sampleRateHz?: number;
41
+ /** SSML markup. Overrides text if set. */
42
+ ssml?: string;
43
+ metadata?: Record<string, string>;
44
+ }
45
+ export interface TTSSynthesisResult {
46
+ audio: AudioData;
47
+ wordTimings?: WordTiming[];
48
+ /** Provider may return revised/normalized text */
49
+ normalizedText?: string;
50
+ }
51
+ export interface TTSProvider {
52
+ synthesize(input: TTSSynthesisInput): Promise<TTSSynthesisResult>;
53
+ listVoices(): Promise<Voice[]>;
54
+ }
55
+ export interface STTTranscriptionInput {
56
+ audio: AudioData;
57
+ language?: string;
58
+ /** Enable speaker diarization */
59
+ diarize?: boolean;
60
+ /** Expected number of speakers (hint for diarization) */
61
+ speakerCount?: number;
62
+ /** Include word-level timestamps */
63
+ wordTimestamps?: boolean;
64
+ /** Vocabulary hints for domain-specific terms */
65
+ vocabularyHints?: string[];
66
+ /** Model to use (provider-specific) */
67
+ model?: string;
19
68
  metadata?: Record<string, string>;
20
69
  }
21
- export interface VoiceSynthesisResult {
70
+ export interface TranscriptionSegment {
71
+ text: string;
72
+ startMs: number;
73
+ endMs: number;
74
+ speakerId?: string;
75
+ speakerName?: string;
76
+ confidence?: number;
77
+ wordTimings?: WordTiming[];
78
+ }
79
+ export interface STTTranscriptionResult {
80
+ text: string;
81
+ segments: TranscriptionSegment[];
82
+ language: string;
83
+ durationMs: number;
84
+ speakers?: {
85
+ id: string;
86
+ name?: string;
87
+ }[];
88
+ wordTimings?: WordTiming[];
89
+ }
90
+ export interface STTProvider {
91
+ transcribe(input: STTTranscriptionInput): Promise<STTTranscriptionResult>;
92
+ /** Stream transcription (real-time audio input) */
93
+ transcribeStream?(audio: AsyncIterable<Uint8Array>, options?: Omit<STTTranscriptionInput, 'audio'>): AsyncIterable<TranscriptionSegment>;
94
+ }
95
+ export interface ConversationalSessionConfig {
96
+ voiceId: string;
97
+ language?: string;
98
+ systemPrompt?: string;
99
+ /** LLM model for response generation */
100
+ llmModel?: string;
101
+ /** Audio input format */
102
+ inputFormat?: AudioFormat;
103
+ /** Audio output format */
104
+ outputFormat?: AudioFormat;
105
+ /** Turn detection mode */
106
+ turnDetection?: 'server_vad' | 'push_to_talk';
107
+ /** Silence threshold in ms to detect end of turn */
108
+ silenceThresholdMs?: number;
109
+ /** Maximum session duration in seconds */
110
+ maxDurationSeconds?: number;
111
+ metadata?: Record<string, string>;
112
+ }
113
+ export type ConversationalEvent = {
114
+ type: 'session_started';
115
+ sessionId: string;
116
+ } | {
117
+ type: 'user_speech_started';
118
+ } | {
119
+ type: 'user_speech_ended';
120
+ transcript: string;
121
+ } | {
122
+ type: 'agent_speech_started';
123
+ text: string;
124
+ } | {
125
+ type: 'agent_audio';
22
126
  audio: Uint8Array;
23
- format: string;
24
- sampleRateHz: number;
25
- durationSeconds?: number;
26
- url?: string;
127
+ } | {
128
+ type: 'agent_speech_ended';
129
+ } | {
130
+ type: 'transcript';
131
+ role: 'user' | 'agent';
132
+ text: string;
133
+ timestamp: number;
134
+ } | {
135
+ type: 'error';
136
+ error: Error;
137
+ } | {
138
+ type: 'session_ended';
139
+ reason: string;
140
+ durationMs: number;
141
+ };
142
+ export interface ConversationalSession {
143
+ /** Send audio chunk from user */
144
+ sendAudio(chunk: Uint8Array): void;
145
+ /** Send text input (bypass STT) */
146
+ sendText(text: string): void;
147
+ /** Interrupt the agent's current speech */
148
+ interrupt(): void;
149
+ /** End the session */
150
+ close(): Promise<ConversationalSessionSummary>;
151
+ /** Event stream */
152
+ events: AsyncIterable<ConversationalEvent>;
153
+ }
154
+ export interface ConversationalSessionSummary {
155
+ sessionId: string;
156
+ durationMs: number;
157
+ turns: {
158
+ role: 'user' | 'agent';
159
+ text: string;
160
+ startMs: number;
161
+ endMs: number;
162
+ }[];
163
+ transcript: string;
27
164
  }
28
- export interface VoiceProvider {
165
+ export interface ConversationalProvider {
166
+ startSession(config: ConversationalSessionConfig): Promise<ConversationalSession>;
29
167
  listVoices(): Promise<Voice[]>;
30
- synthesize(input: VoiceSynthesisInput): Promise<VoiceSynthesisResult>;
31
168
  }
@@ -1,7 +1,7 @@
1
1
  import type { OwnerShipMeta } from '@contractspec/lib.contracts-spec/ownership';
2
2
  import type { CapabilityRef, CapabilityRequirement } from '@contractspec/lib.contracts-spec/capabilities';
3
3
  import { SpecContractRegistry } from '@contractspec/lib.contracts-spec/registry';
4
- export type IntegrationCategory = 'payments' | 'email' | 'calendar' | 'sms' | 'ai-llm' | 'ai-voice' | 'analytics' | 'speech-to-text' | 'vector-db' | 'storage' | 'accounting' | 'crm' | 'helpdesk' | 'project-management' | 'open-banking' | 'meeting-recorder' | 'database' | 'custom';
4
+ export type IntegrationCategory = 'payments' | 'email' | 'calendar' | 'sms' | 'ai-llm' | 'ai-voice-tts' | 'ai-voice-stt' | 'ai-voice-conversational' | 'ai-image' | 'analytics' | 'vector-db' | 'storage' | 'accounting' | 'crm' | 'helpdesk' | 'project-management' | 'open-banking' | 'meeting-recorder' | 'database' | 'custom';
5
5
  export type IntegrationOwnershipMode = 'managed' | 'byok';
6
6
  export interface IntegrationMeta extends OwnerShipMeta {
7
7
  category: IntegrationCategory;