@rymi/sdk-types 1.0.0 → 1.0.1

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/dist/index.d.ts CHANGED
@@ -1,834 +1,858 @@
1
- import { AgentAdvancedConfig } from './agent.js';
2
- import { AgentFeatures as AgentFeatures_2 } from './agent.js';
3
- import { AgentLlmProvider } from './agent.js';
4
- import { AgentPayload as AgentPayload_2 } from './agent.js';
5
- import { AgentPersona as AgentPersona_2 } from './agent.js';
6
- import { AgentPlaybook as AgentPlaybook_2 } from './agent.js';
7
- import { AgentToolBinding } from './agentTools.js';
8
-
9
- export declare interface Agent {
10
- id: string;
11
- name: string;
12
- agent_role: AgentRole;
13
- language?: string | null;
14
- voice?: string;
15
- persona?: AgentPersona_2;
16
- playbook?: AgentPlaybook_2;
17
- advanced?: AgentAdvancedConfig;
18
- post_call?: AgentPayload_2['post_call'];
19
- features?: AgentFeatures_2;
20
- llm_provider?: AgentLlmProvider;
21
- llm_model?: string;
22
- stt_provider?: string;
23
- stt_model?: string;
24
- tts_provider?: string;
25
- tts_model?: string;
26
- provider_config?: any;
27
- raw_system_prompt?: string | null;
28
- compiled_prompt?: string;
29
- created_at?: string;
30
- }
31
-
32
- /** Runtime and speech configuration. */
33
- declare interface AgentAdvancedConfig_2 {
34
- offLimitsTopics?: string;
35
- prohibitedClaims?: string;
36
- maxTurnLength?: number;
37
- silencePromptDelay?: number;
38
- postSilenceHangup?: number;
39
- maxCallDuration?: number;
40
- startSpeakingThreshold?: number;
41
- startSpeakingPhrasing?: 'agent_greets' | 'wait_for_user';
42
- replyDelay?: number;
43
- stopSpeakingThreshold?: number;
44
- resumeAfterInterruption?: boolean;
45
- smartEndpointing?: boolean;
46
- waitAfterSentence?: number;
47
- waitAfterNoPunctuation?: number;
48
- waitAfterNumbers?: number;
49
- stt_confidence_threshold?: number;
50
- stt_numeral_formatting?: boolean;
51
- stt_profanity_filter?: boolean;
52
- stt_keywords?: string;
53
- /** Server-side noise suppression on inbound audio (Deepgram). */
54
- stt_background_denoising?: boolean;
55
- /** LLM sampling temperature (0–2). 0.5 is balanced. */
56
- temperature?: number;
57
- /** Hard cap on LLM response tokens per turn. */
58
- maxTokens?: number;
59
- /** Pipecat-style LLM turn-completion gating: the reply's first token is a
60
- * completion marker; incomplete markers suppress the spoken reply. Default off.
61
- * Stored in `agents.advanced_config` JSONB — no migration. Independent of the
62
- * agent's core-LLM choice (eval results are advisory; works best on gpt-4o-mini). */
63
- turnCompletion?: {
64
- enabled?: boolean;
65
- markerSet?: 'unicode' | 'ascii';
66
- incompleteShortMs?: number;
67
- incompleteLongMs?: number;
68
- };
69
- prompt_mode?: 'builder' | 'raw';
70
- }
71
-
72
- export declare interface AgentCallerPersona {
73
- type?: string;
74
- approach?: string;
75
- }
76
-
77
- export declare interface AgentConfig {
78
- id?: string;
79
- name: string;
80
- companyName: string;
81
- companyWebsite: string;
82
- companyDescription: string;
83
- knowledgeBase: string[];
84
- role: string;
85
- audienceDescription: string;
86
- tone: string;
87
- llm_provider: 'gemini' | 'openai' | 'anthropic' | 'sarvam';
88
- llm_model: string | null;
89
- llm_fallback_provider?: string | null;
90
- llm_fallback_model?: string | null;
91
- stt_provider?: string;
92
- stt_model?: string | null;
93
- stt_fallback_provider?: string | null;
94
- stt_fallback_model?: string | null;
95
- tts_provider?: string;
96
- tts_model?: string | null;
97
- tts_fallback_provider?: string | null;
98
- tts_fallback_model?: string | null;
99
- custom_llm_url?: string | null;
100
- custom_voice_url?: string | null;
101
- /** Wire shape used by the custom voice endpoint when tts_provider is 'custom-voice'. */
102
- custom_voice_mode?: 'rymi' | 'openai-compat';
103
- custom_transcriber_url?: string | null;
104
- agent_role: 'operator' | 'specialist' | 'executive' | 'concierge';
105
- language: string | null;
106
- supported_languages: string[];
107
- voice: string;
108
- accent: string;
109
- bargeInEnabled: boolean;
110
- callerPersonas: any[];
111
- opener: string;
112
- qualificationFlow: AgentQualificationStep[];
113
- requiredSlots: string[];
114
- primaryCTA: string;
115
- backupGoal?: string;
116
- fallbackCTA: string;
117
- escalationRule: string;
118
- /** Final line the agent says right before hanging up a successful call. */
119
- endCallMessage: string;
120
- scripts: any[];
121
- objections: any[];
122
- successCriteria: any[];
123
- extractionTags: any[];
124
- postCallSchema: string[];
125
- restrictedTopics: string[];
126
- forbiddenPromises: string[];
127
- offLimits: string;
128
- prohibitedClaims: string;
129
- maxTurnLength: number;
130
- silencePromptDelay: number;
131
- postSilenceHangup: number;
132
- maxCallDuration: number;
133
- startSpeakingThreshold: number;
134
- startSpeakingPhrasing: 'agent_greets' | 'wait_for_user';
135
- replyDelay: number;
136
- stopSpeakingThreshold: number;
137
- resumeAfterInterruption: boolean;
138
- smartEndpointing: boolean;
139
- waitAfterSentence: number;
140
- waitAfterNoPunctuation: number;
141
- waitAfterNumbers: number;
142
- stt_confidence_threshold: number;
143
- stt_numeral_formatting: boolean;
144
- stt_profanity_filter: boolean;
145
- stt_keywords: string;
146
- stt_background_denoising: boolean;
147
- /** LLM sampling temperature (0–2). Defaults to 0.5. */
148
- temperature: number;
149
- /** Hard cap on LLM response tokens per turn. Defaults to 250. */
150
- maxTokens: number;
151
- recordingEnabled: boolean;
152
- transcriptionEnabled: boolean;
153
- requireConsent: boolean;
154
- postCallSummaryEnabled: boolean;
155
- postCallSummaryPrompt: string;
156
- postCallExtractionEnabled: boolean;
157
- postCallExtractionFields: string[];
158
- postCallEvaluationEnabled: boolean;
159
- postCallEvaluationRubric: string;
160
- postCallLlmProvider: 'gemini' | 'openai' | '';
161
- postCallLlmModel: string;
162
- transferNumber: string;
163
- smsContinuationEnabled: boolean;
164
- smsContinuationReconnectUrl: string;
165
- voicemailBehavior: 'leave_message' | 'hangup';
166
- voicemailScript: string;
167
- disableCallerMemory: boolean;
168
- provider_config?: any;
169
- attached_numbers?: string[];
170
- chat_summary?: string;
171
- /**
172
- * Per-agent built-in tool bindings. v1 ships three vetted tools (calendar /
173
- * ticket / customer lookup) — see BUILTIN_TOOL_CATALOG. Optional for back-
174
- * compat: agents that pre-date this field default to "no tools enabled".
175
- */
176
- tools?: AgentToolBinding[];
177
- variables?: AgentVariable[];
178
- promptMode?: 'builder' | 'raw';
179
- rawSystemPrompt?: string | null;
180
- }
181
-
182
- /** Feature flags for recording, transcription, and consent. */
183
- export declare interface AgentFeatures {
184
- recording_enabled?: boolean;
185
- transcription_enabled?: boolean;
186
- require_consent?: boolean;
187
- }
188
-
189
- /**
190
- * Typed interfaces for the Rymi Agent configuration schema.
191
- *
192
- * These match the shape accepted by POST /v1/agents and PUT /v1/agents/:id.
193
- * The canonical JSON Schema definitions live in agentRouteSchemas.ts (API).
194
- */
195
- declare type AgentLlmProvider_2 = 'gemini' | 'openai' | 'anthropic' | 'sarvam';
196
-
197
- declare interface AgentObjectionHandler {
198
- trigger?: string;
199
- response?: string;
200
- }
201
-
202
- /**
203
- * The complete agent payload shape accepted by the REST API.
204
- * Use this as the canonical "middle JSON" for serialisation, import/export, and cloning.
205
- */
206
- export declare interface AgentPayload {
207
- name: string;
208
- voice?: string;
209
- language?: string | null;
210
- supported_languages?: string[];
211
- agent_role?: 'operator' | 'specialist' | 'executive' | 'concierge';
212
- llm_provider?: AgentLlmProvider_2;
213
- llm_model?: string;
214
- llm_fallback_provider?: string | null;
215
- llm_fallback_model?: string | null;
216
- stt_provider?: string;
217
- stt_model?: string;
218
- stt_fallback_provider?: string | null;
219
- stt_fallback_model?: string | null;
220
- tts_provider?: string;
221
- tts_model?: string;
222
- tts_fallback_provider?: string | null;
223
- tts_fallback_model?: string | null;
224
- persona?: AgentPersona;
225
- playbook?: AgentPlaybook;
226
- advanced?: AgentAdvancedConfig_2;
227
- features?: AgentFeatures;
228
- post_call?: {
229
- summary?: {
230
- enabled?: boolean;
231
- prompt?: string | null;
232
- };
233
- evaluation?: {
234
- rubric?: string | null;
235
- };
236
- structured_extraction?: {
237
- prompt?: string | null;
238
- json_schema?: Record<string, any> | null;
239
- };
240
- model?: {
241
- provider?: AgentLlmProvider_2 | null;
242
- model?: string | null;
243
- };
244
- };
245
- }
246
-
247
- /** Structured persona: who the agent is, who it talks to, and how it sounds. */
248
- export declare interface AgentPersona {
249
- role?: string;
250
- audienceDescription?: string;
251
- toneOverride?: string;
252
- successCriteria?: string[];
253
- voiceConfig?: AgentVoiceConfig;
254
- callerPersonas?: AgentCallerPersona[];
255
- /** Company context injected into the system prompt. */
256
- companyName?: string;
257
- companyWebsite?: string;
258
- companyDescription?: string;
259
- knowledgeBase?: string[];
260
- }
261
-
262
- /** Structured playbook: conversation flow, objections, scripts, and CTAs. */
263
- export declare interface AgentPlaybook {
264
- opener?: string;
265
- qualificationFlow?: AgentQualificationStep[];
266
- requiredSlots?: AgentRequiredSlot[];
267
- objectionHandlers?: AgentObjectionHandler[];
268
- scripts?: AgentScript[];
269
- closingCTA?: string;
270
- fallbackCTA?: string;
271
- escalationRule?: string;
272
- /** Final line the agent says right before hanging up a successful call. */
273
- endCallMessage?: string;
274
- }
275
-
276
- declare interface AgentQualificationStep {
277
- question?: string;
278
- prompt?: string;
279
- listensFor?: string;
280
- listens_for?: string;
281
- listenFor?: string;
282
- slotName?: string;
283
- slot_name?: string;
284
- }
285
-
286
- export declare interface AgentRequiredSlot {
287
- name?: string;
288
- description?: string;
289
- required?: boolean;
290
- }
291
-
292
- export declare type AgentRole = 'operator' | 'specialist' | 'executive' | 'concierge';
293
-
294
- export declare interface AgentScript {
295
- title?: string;
296
- when?: string;
297
- content?: string;
298
- }
299
-
300
- export declare interface AgentTemplate {
301
- id: string;
302
- label: string;
303
- icon: string;
304
- description: string;
305
- color: string;
306
- defaults: AgentTemplateDefaults;
307
- }
308
-
309
- declare interface AgentTemplateDefaults {
310
- role: string;
311
- audienceDescription: string;
312
- tone: string;
313
- opener: string;
314
- qualificationFlow: Array<{
315
- question: string;
316
- listens_for: string;
317
- }>;
318
- requiredSlots: string[];
319
- primaryCTA: string;
320
- fallbackCTA: string;
321
- escalationRule: string;
322
- scripts: Array<{
323
- title: string;
324
- when_to_use: string;
325
- content: string;
326
- }>;
327
- objections: Array<{
328
- trigger: string;
329
- response: string;
330
- }>;
331
- successCriteria: string[];
332
- offLimits: string;
333
- prohibitedClaims: string;
334
- language?: string;
335
- agentRole?: 'operator' | 'specialist' | 'executive' | 'concierge';
336
- bargeInEnabled?: boolean;
337
- maxCallDuration?: number;
338
- knowledgeBaseHints?: string[];
339
- extractionTags?: string[];
340
- restrictedTopics?: string[];
341
- forbiddenPromises?: string[];
342
- recordingEnabled?: boolean;
343
- transcriptionEnabled?: boolean;
344
- requireConsent?: boolean;
345
- postCallSummaryEnabled?: boolean;
346
- postCallSummaryPrompt?: string;
347
- postCallExtractionEnabled?: boolean;
348
- postCallExtractionFields?: string[];
349
- postCallEvaluationEnabled?: boolean;
350
- postCallEvaluationRubric?: string;
351
- stt_keywords?: string;
352
- callerPersonas?: Array<{
353
- type: string;
354
- detectedWhen: string;
355
- approach: string;
356
- }>;
357
- setupQuestions?: SetupQuestion[];
358
- variables?: AgentVariable[];
359
- matchKeywords?: string[];
360
- }
361
-
362
- export declare type AgentTemplateStatus = 'draft' | 'submitted' | 'approved' | 'published' | 'rejected' | 'archived';
363
-
364
- export declare type AgentTemplateVisibility = 'private' | 'tenant' | 'public';
365
-
366
- export declare interface AgentVariable {
367
- key: string;
368
- description: string;
369
- metadataKey?: string;
370
- required: boolean;
371
- default?: string;
372
- /**
373
- * Live METHOD when not satisfied by input/default. Optional on the wire for
374
- * legacy rows; use `normalizeVariableAcquisition` to read a concrete value.
375
- */
376
- acquisition?: VariableAcquisition;
377
- origin?: VariableOrigin;
378
- /**
379
- * Value type used to validate incoming metadata. When omitted the variable
380
- * behaves as a free-form string (legacy behavior, byte-identical resolution).
381
- * A metadata value that does not satisfy this type is treated as missing.
382
- */
383
- type?: AgentVariableType;
384
- /**
385
- * Allowed values when `type === 'enum'`. A metadata value not in this list is
386
- * treated as missing. Ignored for non-enum types. An enum with no/empty
387
- * `enumValues` falls back to lenient string passthrough.
388
- */
389
- enumValues?: string[];
390
- }
391
-
392
- /** Allowed value-type for a caller variable. Absent ⇒ treated as 'string'. */
393
- declare type AgentVariableType = 'string' | 'number' | 'boolean' | 'enum';
394
-
395
- export declare interface AgentVoiceConfig {
396
- voiceId?: string;
397
- language?: string;
398
- accent?: string;
399
- bargeInEnabled?: boolean;
400
- }
401
-
402
- export declare type BuiltinAgentToolId = 'handoff_to_human' | 'check_calendar_availability' | 'list_calendar_events' | 'create_calendar_event' | 'update_calendar_event' | 'delete_calendar_event' | 'lookup_customer' | 'send_whatsapp_message' | 'send_telegram_message' | 'send_asset';
403
-
404
- export declare interface Call {
405
- id: string;
406
- room_name: string;
407
- user_id?: string;
408
- tenant_id?: string;
409
- agent_id: string;
410
- status: CallStatus;
411
- recording_status: 'none' | 'requested' | 'active' | 'processing' | 'completed' | 'failed';
412
- started_at: string | null;
413
- ended_at: string | null;
414
- end_reason?: string | null;
415
- error_code?: string | null;
416
- error_message?: string | null;
417
- metadata: Record<string, any>;
418
- created_at: string;
419
- updated_at: string;
420
- }
421
-
422
- export declare interface CallEvaluationResult {
423
- rubric: string;
424
- passed: boolean | null;
425
- score: number | null;
426
- reasoning: string | null;
427
- }
428
-
429
- export declare type CallIntelligenceStatus = 'not_started' | 'pending' | 'processing' | 'completed' | 'partial' | 'failed' | 'dead_letter';
430
-
431
- export declare interface CallParticipant {
432
- id: string;
433
- call_id: string;
434
- user_id?: string | null;
435
- role: CallParticipantRole;
436
- transport: CallParticipantTransport;
437
- identity: string;
438
- status: CallParticipantStatus;
439
- metadata: Record<string, any>;
440
- joined_at: string;
441
- left_at: string | null;
442
- created_at: string;
443
- }
444
-
445
- export declare type CallParticipantRole = 'agent' | 'customer' | 'observer';
446
-
447
- export declare type CallParticipantStatus = 'joining' | 'active' | 'left' | 'failed';
448
-
449
- export declare type CallParticipantTransport = 'webrtc' | 'pstn' | 'sip' | 'internal';
450
-
451
- export declare interface CallRecording {
452
- id: string;
453
- call_id: string;
454
- participant_id?: string | null;
455
- recording_url?: string | null;
456
- provider_recording_id?: string | null;
457
- format: string;
458
- status: 'processing' | 'completed' | 'failed';
459
- duration?: number | null;
460
- size_bytes?: number | null;
461
- metadata: Record<string, any>;
462
- created_at: string;
463
- }
464
-
465
- export declare type CallSentiment = 'positive' | 'neutral' | 'negative' | 'unknown';
466
-
467
- export declare type CallStatus = 'queued' | 'ringing' | 'in_progress' | 'completed' | 'failed' | 'no_answer' | 'busy' | 'canceled';
468
-
469
- export declare interface CallStatusChangedEvent extends TelephonyBaseEvent {
470
- type: 'call.status_changed';
471
- status: TelephonyCallStatus;
472
- callId: string;
473
- }
474
-
475
- export declare interface CallTranscriptEvent {
476
- id: string;
477
- call_id: string;
478
- participant_id: string | null;
479
- role: 'user' | 'agent';
480
- text: string;
481
- sequence: number;
482
- source: 'runtime' | 'stt' | 'post_call';
483
- started_at_ms: number | null;
484
- ended_at_ms: number | null;
485
- metadata: Record<string, any>;
486
- created_at: string;
487
- }
488
-
489
- declare type CallTranscriptSpeaker = 'user' | 'agent';
490
-
491
- declare interface CapabilityUnsupportedEvent extends TelephonyBaseEvent {
492
- type: 'capability.unsupported';
493
- requestedType: TelephonyEventType;
494
- }
495
-
496
- declare type ConnectorCategory = 'calendar' | 'crm' | 'ticketing' | 'messaging';
497
-
498
- /** Safe view of a workspace connector connection. NEVER includes tokens. */
499
- export declare interface ConnectorConnectionSafeView {
500
- id: string;
501
- provider: string;
502
- category: ConnectorCategory;
503
- displayName: string;
504
- accountName: string;
505
- status: 'connected' | 'expired' | 'error';
506
- scopes: string[];
507
- connectedAt: string;
508
- expiresAt: string | null;
509
- }
510
-
511
- export declare type CreateKnowledgeSourceRequest = CreateKnowledgeSourceTextRequest | CreateKnowledgeSourceUrlRequest;
512
-
513
- /** Request body for POST /agents/:id/knowledge-sources (text mode). */
514
- export declare interface CreateKnowledgeSourceTextRequest {
515
- kind: 'text';
516
- title: string;
517
- text: string;
518
- }
519
-
520
- /** Request body for POST /agents/:id/knowledge-sources (url mode). */
521
- export declare interface CreateKnowledgeSourceUrlRequest {
522
- kind: 'url';
523
- title: string;
524
- url: string;
525
- }
526
-
527
- declare interface DtmfReceivedEvent extends TelephonyBaseEvent {
528
- type: 'dtmf.received';
529
- digit: string;
530
- }
531
-
532
- export declare interface Invoice {
533
- id: string;
534
- invoice_number: string;
535
- tenant_id: string;
536
- kind: InvoiceKind;
537
- status: InvoiceStatus;
538
- currency: string;
539
- subtotal_minor: number;
540
- tax_minor: number;
541
- discount_minor: number;
542
- total_minor: number;
543
- gateway: InvoiceGateway;
544
- gateway_invoice_id: string | null;
545
- payment_event_id: string | null;
546
- period_start: string | null;
547
- period_end: string | null;
548
- issued_at: string;
549
- paid_at: string | null;
550
- voided_at: string | null;
551
- }
552
-
553
- export declare interface InvoiceDetailResponse {
554
- invoice: Invoice;
555
- items: InvoiceItem[];
556
- }
557
-
558
- export declare type InvoiceGateway = 'stripe' | 'razorpay';
559
-
560
- export declare interface InvoiceItem {
561
- id: string;
562
- invoice_id: string;
563
- kind: InvoiceItemKind;
564
- description: string;
565
- quantity: number;
566
- unit_amount_minor: number;
567
- amount_minor: number;
568
- plan_id: string | null;
569
- credit_transaction_id: string | null;
570
- }
571
-
572
- export declare type InvoiceItemKind = 'topup' | 'discount' | 'tax_line' | 'adjustment';
573
-
574
- export declare type InvoiceKind = 'topup' | 'adjustment';
575
-
576
- export declare interface InvoiceListResponse {
577
- invoices: Invoice[];
578
- next_cursor: string | null;
579
- }
580
-
581
- export declare type InvoiceStatus = 'paid' | 'failed' | 'pending' | 'void' | 'refunded';
582
-
583
- /**
584
- * Single embedded chunk produced by the ingestion pipeline.
585
- * Returned by the runtime knowledge_search tool with a similarity score.
586
- */
587
- export declare interface KnowledgeChunk {
588
- id: string;
589
- source_id: string;
590
- agent_id: string;
591
- tenant_id: string;
592
- chunk_index: number;
593
- text: string;
594
- /** Cosine similarity in [0, 1]. Only present on retrieval results. */
595
- score?: number;
596
- bytes: number;
597
- created_at: string;
598
- }
599
-
600
- /**
601
- * A user-supplied knowledge unit attached to an agent. Chunked and
602
- * embedded into KnowledgeChunk rows for retrieval.
603
- */
604
- export declare interface KnowledgeSource {
605
- id: string;
606
- agent_id: string;
607
- tenant_id: string;
608
- kind: KnowledgeSourceKind;
609
- title: string;
610
- /** URL when kind='url', filename when kind='file', null for kind='text'. */
611
- source_uri: string | null;
612
- status: KnowledgeSourceStatus;
613
- failure_reason: KnowledgeSourceFailureReason | string | null;
614
- /** SHA-256 of the raw source content. Used to detect stale chunks. */
615
- content_hash: string | null;
616
- /** Incremented on each successful re-ingest. */
617
- version: number;
618
- chunk_count: number;
619
- bytes: number;
620
- created_at: string;
621
- updated_at: string;
622
- }
623
-
624
- /**
625
- * Stable reason codes for knowledge source failure and quota enforcement.
626
- * UI copy lives separately; branch on these codes, not on message strings.
627
- */
628
- declare type KnowledgeSourceFailureReason = 'fetch_failed' | 'extraction_failed' | 'embedding_failed' | 'quota_exceeded' | 'file_too_large' | 'unsupported_mime_type' | 'permission_denied' | 'storage_error' | 'unknown';
629
-
630
- export declare type KnowledgeSourceKind = 'text' | 'url' | 'file';
631
-
632
- /** Full lifecycle state for a knowledge source. */
633
- export declare type KnowledgeSourceStatus = 'pending' | 'indexing' | 'ready' | 'failed';
634
-
635
- export declare interface MachineDetectedEvent extends TelephonyBaseEvent {
636
- type: 'machine.detected';
637
- confidence: number;
638
- /** Whether a voicemail beep was also detected. */
639
- beepDetected: boolean;
640
- }
641
-
642
- declare interface MediaConnectedEvent extends TelephonyBaseEvent {
643
- type: 'media.connected';
644
- sampleRate: number;
645
- channels: number;
646
- }
647
-
648
- declare interface MediaDisconnectedEvent extends TelephonyBaseEvent {
649
- type: 'media.disconnected';
650
- reason: string;
651
- }
652
-
653
- export declare interface PostCallStructuredExtractionConfig {
654
- prompt: string | null;
655
- json_schema: Record<string, any> | null;
656
- }
657
-
658
- export declare interface RecordingCompletedEvent extends TelephonyBaseEvent {
659
- type: 'recording.completed';
660
- recordingId: string;
661
- durationMs: number;
662
- url?: string;
663
- }
664
-
665
- declare interface RecordingStartedEvent extends TelephonyBaseEvent {
666
- type: 'recording.started';
667
- recordingId: string;
668
- }
669
-
670
- /**
671
- * Public-facing labels for runtime reason codes the backend emits on call
672
- * records (`end_reason`, end-reason distributions, handoff metadata).
673
- *
674
- * The codes themselves are the source of truth in
675
- * `@rymi/agents-core/src/reasonCodes.ts`. This module is the UI label layer:
676
- * Studio, call detail, dashboards, and admin views map codes to copy here
677
- * instead of de-snake-casing the wire format on the fly.
678
- *
679
- * Rules:
680
- * - Adding/changing a public label is a UI copy change, never a contract
681
- * change. The backend code remains untouched.
682
- * - Unknown codes fall back to a Title Case of the snake_case so legacy
683
- * call rows still render readably.
684
- * - Labels stay short and declarative per `design.md` voice rules.
685
- */
686
- /** Known session-close reasons rendered on call records. */
687
- export declare type SessionEndReasonCode = 'end_call_tool' | 'handoff_to_human' | 'handoff_to_agent' | 'user_disconnect' | 'provider_disconnect' | 'error' | 'timeout' | 'closed';
688
-
689
- export declare interface SetupQuestion {
690
- id: string;
691
- header: string;
692
- question: string;
693
- helper?: string;
694
- options: SetupQuestionOption[];
695
- multiSelect: boolean;
696
- writes: SetupWrite[];
697
- defaultValue?: string | string[];
698
- allowFreeText?: boolean;
699
- placeholder?: string;
700
- required: boolean;
701
- dependsOn?: {
702
- id: string;
703
- equals: string;
704
- };
705
- }
706
-
707
- declare interface SetupQuestionOption {
708
- label: string;
709
- description: string;
710
- }
711
-
712
- declare type SetupWrite = {
713
- kind: 'set';
714
- key: string;
715
- } | {
716
- kind: 'append';
717
- key: string;
718
- } | {
719
- kind: 'replace';
720
- key: string;
721
- } | {
722
- kind: 'append-csv';
723
- key: string;
724
- } | {
725
- kind: 'opener-template';
726
- token: string;
727
- };
728
-
729
- declare interface TelephonyBaseEvent {
730
- type: TelephonyEventType;
731
- timestampMs: number;
732
- /** Provider-specific raw event — for debugging only, never branch on this. */
733
- providerRaw?: unknown;
734
- }
735
-
736
- declare type TelephonyCallStatus = 'ringing' | 'answered' | 'in_progress' | 'completed' | 'failed' | 'busy' | 'no_answer' | 'canceled';
737
-
738
- export declare type TelephonyEvent = CallStatusChangedEvent | MediaConnectedEvent | MediaDisconnectedEvent | DtmfReceivedEvent | MachineDetectedEvent | VoicemailBeepEvent | RecordingStartedEvent | RecordingCompletedEvent | TransferInitiatedEvent | TransferCompletedEvent | TransferFailedEvent | CapabilityUnsupportedEvent;
739
-
740
- /**
741
- * Provider-neutral telephony event vocabulary.
742
- *
743
- * Transport packages (LiveKit, Twilio, browser, WebSocket) normalize their
744
- * provider-specific callbacks into this shared event model. Future
745
- * DTMF/voicemail/recording/machine-detection UI controls consume these
746
- * events without knowing the underlying provider.
747
- *
748
- * Rules:
749
- * - Use `TelephonyEventType` values in all transport adapters — never raw strings.
750
- * - Unsupported event types on a transport should emit `'capability.unsupported'`
751
- * rather than silently dropping.
752
- * - `TelephonyCapabilityReport` lets callers discover what a transport can do
753
- * without a runtime try/catch.
754
- */
755
- export declare type TelephonyEventType = 'call.status_changed' | 'media.connected' | 'media.disconnected' | 'dtmf.received' | 'machine.detected' | 'voicemail.beep' | 'recording.started' | 'recording.completed' | 'transfer.initiated' | 'transfer.completed' | 'transfer.failed' | 'capability.unsupported';
756
-
757
- export declare interface TelephonyLeg {
758
- id: string;
759
- call_id: string;
760
- participant_id: string;
761
- provider: 'plivo' | 'twilio' | 'vonage';
762
- provider_call_id?: string | null;
763
- direction: 'inbound' | 'outbound';
764
- status: string;
765
- from_number?: string | null;
766
- to_number?: string | null;
767
- cost: number;
768
- duration: number;
769
- metadata: Record<string, any>;
770
- created_at: string;
771
- }
772
-
773
- /**
774
- * Safe view of tool capability state for SDK/MCP responses.
775
- * Omits internal fields that expose tenant credential structure.
776
- */
777
- export declare interface ToolCapabilitySafeView {
778
- toolId: string;
779
- available: boolean;
780
- unavailableReason: ToolUnavailableReason | null;
781
- sideEffect: 'read' | 'write';
782
- }
783
-
784
- /** Stable reason codes for why a tool is unavailable on a given call. */
785
- declare type ToolUnavailableReason = 'agent_tool_disabled' | 'missing_credential' | 'missing_caller_phone' | 'missing_telegram_chat_id' | 'missing_transfer_number' | 'blocked_by_mvp_policy' | 'not_supported_in_runtime' | 'provider_not_configured' | 'auth_error' | 'credential_expired' | 'context_missing' | 'policy_blocked' | 'plan_gate' | 'runtime_not_initialized' | 'rate_limited';
786
-
787
- export declare interface TranscriptionResult {
788
- text: string;
789
- confidence: number | null;
790
- languageCode?: string | null;
791
- isFinal?: boolean;
792
- provider?: string | null;
793
- model?: string | null;
794
- }
795
-
796
- export declare interface TranscriptSegment {
797
- id?: string;
798
- speaker: CallTranscriptSpeaker;
799
- text: string;
800
- sequence: number;
801
- started_at_ms: number;
802
- ended_at_ms: number;
803
- is_final: boolean;
804
- source: string;
805
- created_at?: string;
806
- }
807
-
808
- export declare interface TransferCompletedEvent extends TelephonyBaseEvent {
809
- type: 'transfer.completed';
810
- target: string;
811
- }
812
-
813
- declare interface TransferFailedEvent extends TelephonyBaseEvent {
814
- type: 'transfer.failed';
815
- target: string;
816
- reason: string;
817
- }
818
-
819
- declare interface TransferInitiatedEvent extends TelephonyBaseEvent {
820
- type: 'transfer.initiated';
821
- target: string;
822
- }
823
-
824
- /** How the agent obtains a variable live when input/default did not satisfy it. */
825
- declare type VariableAcquisition = 'ask' | 'extract' | 'none';
826
-
827
- /** Where a variable was first authored (for Studio UX / badges). */
828
- declare type VariableOrigin = 'caller' | 'playbook' | 'postcall' | 'prompt' | 'template';
829
-
830
- declare interface VoicemailBeepEvent extends TelephonyBaseEvent {
831
- type: 'voicemail.beep';
832
- }
833
-
834
- export { }
1
+ declare type AgentAdvancedConfig_2 = AgentAdvancedConfig;
2
+ declare type AgentFeatures_2 = AgentFeatures;
3
+ declare type AgentLlmProvider_2 = AgentLlmProvider;
4
+ declare type AgentPayload_2 = AgentPayload;
5
+ declare type AgentPersona_2 = AgentPersona;
6
+ declare type AgentPlaybook_2 = AgentPlaybook;
7
+ declare type AgentToolBinding_2 = AgentToolBinding;
8
+
9
+ export declare interface Agent {
10
+ id: string;
11
+ name: string;
12
+ agent_role: AgentRole;
13
+ language?: string | null;
14
+ voice?: string;
15
+ persona?: AgentPersona_2;
16
+ playbook?: AgentPlaybook_2;
17
+ advanced?: AgentAdvancedConfig_2;
18
+ post_call?: AgentPayload_2['post_call'];
19
+ features?: AgentFeatures_2;
20
+ llm_provider?: AgentLlmProvider_2;
21
+ llm_model?: string;
22
+ stt_provider?: string;
23
+ stt_model?: string;
24
+ tts_provider?: string;
25
+ tts_model?: string;
26
+ provider_config?: any;
27
+ raw_system_prompt?: string | null;
28
+ compiled_prompt?: string;
29
+ created_at?: string;
30
+ }
31
+
32
+ /** Runtime and speech configuration. */
33
+ export declare interface AgentAdvancedConfig {
34
+ offLimitsTopics?: string;
35
+ prohibitedClaims?: string;
36
+ maxTurnLength?: number;
37
+ silencePromptDelay?: number;
38
+ postSilenceHangup?: number;
39
+ maxCallDuration?: number;
40
+ startSpeakingThreshold?: number;
41
+ startSpeakingPhrasing?: 'agent_greets' | 'wait_for_user';
42
+ replyDelay?: number;
43
+ stopSpeakingThreshold?: number;
44
+ resumeAfterInterruption?: boolean;
45
+ smartEndpointing?: boolean;
46
+ waitAfterSentence?: number;
47
+ waitAfterNoPunctuation?: number;
48
+ waitAfterNumbers?: number;
49
+ stt_confidence_threshold?: number;
50
+ stt_numeral_formatting?: boolean;
51
+ stt_profanity_filter?: boolean;
52
+ stt_keywords?: string;
53
+ /** Server-side noise suppression on inbound audio (Deepgram). */
54
+ stt_background_denoising?: boolean;
55
+ /** LLM sampling temperature (0–2). 0.5 is balanced. */
56
+ temperature?: number;
57
+ /** Hard cap on LLM response tokens per turn. */
58
+ maxTokens?: number;
59
+ /** Pipecat-style LLM turn-completion gating: the reply's first token is a
60
+ * completion marker; incomplete markers suppress the spoken reply. Default off.
61
+ * Stored in `agents.advanced_config` JSONB — no migration. Independent of the
62
+ * agent's core-LLM choice (eval results are advisory; works best on gpt-4o-mini). */
63
+ turnCompletion?: {
64
+ enabled?: boolean;
65
+ markerSet?: 'unicode' | 'ascii';
66
+ incompleteShortMs?: number;
67
+ incompleteLongMs?: number;
68
+ };
69
+ prompt_mode?: 'builder' | 'raw';
70
+ }
71
+
72
+ export declare interface AgentCallerPersona {
73
+ type?: string;
74
+ approach?: string;
75
+ }
76
+
77
+ export declare interface AgentConfig {
78
+ id?: string;
79
+ name: string;
80
+ companyName: string;
81
+ companyWebsite: string;
82
+ companyDescription: string;
83
+ knowledgeBase: string[];
84
+ role: string;
85
+ audienceDescription: string;
86
+ tone: string;
87
+ llm_provider: 'gemini' | 'openai' | 'anthropic' | 'sarvam';
88
+ llm_model: string | null;
89
+ llm_fallback_provider?: string | null;
90
+ llm_fallback_model?: string | null;
91
+ stt_provider?: string;
92
+ stt_model?: string | null;
93
+ stt_fallback_provider?: string | null;
94
+ stt_fallback_model?: string | null;
95
+ tts_provider?: string;
96
+ tts_model?: string | null;
97
+ tts_fallback_provider?: string | null;
98
+ tts_fallback_model?: string | null;
99
+ custom_llm_url?: string | null;
100
+ custom_voice_url?: string | null;
101
+ /** Wire shape used by the custom voice endpoint when tts_provider is 'custom-voice'. */
102
+ custom_voice_mode?: 'rymi' | 'openai-compat';
103
+ custom_transcriber_url?: string | null;
104
+ agent_role: 'operator' | 'specialist' | 'executive' | 'concierge';
105
+ language: string | null;
106
+ supported_languages: string[];
107
+ voice: string;
108
+ accent: string;
109
+ bargeInEnabled: boolean;
110
+ callerPersonas: any[];
111
+ opener: string;
112
+ qualificationFlow: AgentQualificationStep[];
113
+ requiredSlots: string[];
114
+ primaryCTA: string;
115
+ backupGoal?: string;
116
+ fallbackCTA: string;
117
+ escalationRule: string;
118
+ /** Final line the agent says right before hanging up a successful call. */
119
+ endCallMessage: string;
120
+ scripts: any[];
121
+ objections: any[];
122
+ successCriteria: any[];
123
+ extractionTags: any[];
124
+ postCallSchema: string[];
125
+ restrictedTopics: string[];
126
+ forbiddenPromises: string[];
127
+ offLimits: string;
128
+ prohibitedClaims: string;
129
+ maxTurnLength: number;
130
+ silencePromptDelay: number;
131
+ postSilenceHangup: number;
132
+ maxCallDuration: number;
133
+ startSpeakingThreshold: number;
134
+ startSpeakingPhrasing: 'agent_greets' | 'wait_for_user';
135
+ replyDelay: number;
136
+ stopSpeakingThreshold: number;
137
+ resumeAfterInterruption: boolean;
138
+ smartEndpointing: boolean;
139
+ waitAfterSentence: number;
140
+ waitAfterNoPunctuation: number;
141
+ waitAfterNumbers: number;
142
+ stt_confidence_threshold: number;
143
+ stt_numeral_formatting: boolean;
144
+ stt_profanity_filter: boolean;
145
+ stt_keywords: string;
146
+ stt_background_denoising: boolean;
147
+ /** LLM sampling temperature (0–2). Defaults to 0.5. */
148
+ temperature: number;
149
+ /** Hard cap on LLM response tokens per turn. Defaults to 250. */
150
+ maxTokens: number;
151
+ recordingEnabled: boolean;
152
+ transcriptionEnabled: boolean;
153
+ requireConsent: boolean;
154
+ postCallSummaryEnabled: boolean;
155
+ postCallSummaryPrompt: string;
156
+ postCallExtractionEnabled: boolean;
157
+ postCallExtractionFields: string[];
158
+ postCallEvaluationEnabled: boolean;
159
+ postCallEvaluationRubric: string;
160
+ postCallLlmProvider: 'gemini' | 'openai' | '';
161
+ postCallLlmModel: string;
162
+ transferNumber: string;
163
+ smsContinuationEnabled: boolean;
164
+ smsContinuationReconnectUrl: string;
165
+ voicemailBehavior: 'leave_message' | 'hangup';
166
+ voicemailScript: string;
167
+ disableCallerMemory: boolean;
168
+ provider_config?: any;
169
+ attached_numbers?: string[];
170
+ chat_summary?: string;
171
+ /**
172
+ * Per-agent built-in tool bindings. v1 ships three vetted tools (calendar /
173
+ * ticket / customer lookup) — see BUILTIN_TOOL_CATALOG. Optional for back-
174
+ * compat: agents that pre-date this field default to "no tools enabled".
175
+ */
176
+ tools?: AgentToolBinding_2[];
177
+ variables?: AgentVariable[];
178
+ promptMode?: 'builder' | 'raw';
179
+ rawSystemPrompt?: string | null;
180
+ }
181
+
182
+ /** Feature flags for recording, transcription, and consent. */
183
+ export declare interface AgentFeatures {
184
+ recording_enabled?: boolean;
185
+ transcription_enabled?: boolean;
186
+ require_consent?: boolean;
187
+ }
188
+
189
+ /**
190
+ * Typed interfaces for the Rymi Agent configuration schema.
191
+ *
192
+ * These match the shape accepted by POST /v1/agents and PUT /v1/agents/:id.
193
+ * The canonical JSON Schema definitions live in agentRouteSchemas.ts (API).
194
+ */
195
+ export declare type AgentLlmProvider = 'gemini' | 'openai' | 'anthropic' | 'sarvam';
196
+
197
+ declare interface AgentObjectionHandler {
198
+ trigger?: string;
199
+ response?: string;
200
+ }
201
+
202
+ /**
203
+ * The complete agent payload shape accepted by the REST API.
204
+ * Use this as the canonical "middle JSON" for serialisation, import/export, and cloning.
205
+ */
206
+ export declare interface AgentPayload {
207
+ name: string;
208
+ voice?: string;
209
+ language?: string | null;
210
+ supported_languages?: string[];
211
+ agent_role?: 'operator' | 'specialist' | 'executive' | 'concierge';
212
+ llm_provider?: AgentLlmProvider;
213
+ llm_model?: string;
214
+ llm_fallback_provider?: string | null;
215
+ llm_fallback_model?: string | null;
216
+ stt_provider?: string;
217
+ stt_model?: string;
218
+ stt_fallback_provider?: string | null;
219
+ stt_fallback_model?: string | null;
220
+ tts_provider?: string;
221
+ tts_model?: string;
222
+ tts_fallback_provider?: string | null;
223
+ tts_fallback_model?: string | null;
224
+ persona?: AgentPersona;
225
+ playbook?: AgentPlaybook;
226
+ advanced?: AgentAdvancedConfig;
227
+ features?: AgentFeatures;
228
+ post_call?: {
229
+ summary?: {
230
+ enabled?: boolean;
231
+ prompt?: string | null;
232
+ };
233
+ evaluation?: {
234
+ rubric?: string | null;
235
+ };
236
+ structured_extraction?: {
237
+ prompt?: string | null;
238
+ json_schema?: Record<string, any> | null;
239
+ };
240
+ model?: {
241
+ provider?: AgentLlmProvider | null;
242
+ model?: string | null;
243
+ };
244
+ };
245
+ }
246
+
247
+ /** Structured persona: who the agent is, who it talks to, and how it sounds. */
248
+ export declare interface AgentPersona {
249
+ role?: string;
250
+ audienceDescription?: string;
251
+ toneOverride?: string;
252
+ successCriteria?: string[];
253
+ voiceConfig?: AgentVoiceConfig;
254
+ callerPersonas?: AgentCallerPersona[];
255
+ /** Company context injected into the system prompt. */
256
+ companyName?: string;
257
+ companyWebsite?: string;
258
+ companyDescription?: string;
259
+ knowledgeBase?: string[];
260
+ }
261
+
262
+ /** Structured playbook: conversation flow, objections, scripts, and CTAs. */
263
+ export declare interface AgentPlaybook {
264
+ opener?: string;
265
+ qualificationFlow?: AgentQualificationStep[];
266
+ requiredSlots?: AgentRequiredSlot[];
267
+ objectionHandlers?: AgentObjectionHandler[];
268
+ scripts?: AgentScript[];
269
+ closingCTA?: string;
270
+ fallbackCTA?: string;
271
+ escalationRule?: string;
272
+ /** Final line the agent says right before hanging up a successful call. */
273
+ endCallMessage?: string;
274
+ }
275
+
276
+ declare interface AgentQualificationStep {
277
+ question?: string;
278
+ prompt?: string;
279
+ listensFor?: string;
280
+ listens_for?: string;
281
+ listenFor?: string;
282
+ slotName?: string;
283
+ slot_name?: string;
284
+ }
285
+
286
+ export declare interface AgentRequiredSlot {
287
+ name?: string;
288
+ description?: string;
289
+ required?: boolean;
290
+ }
291
+
292
+ export declare type AgentRole = 'operator' | 'specialist' | 'executive' | 'concierge';
293
+
294
+ export declare interface AgentScript {
295
+ title?: string;
296
+ when?: string;
297
+ content?: string;
298
+ }
299
+
300
+ export declare interface AgentTemplate {
301
+ id: string;
302
+ label: string;
303
+ icon: string;
304
+ description: string;
305
+ color: string;
306
+ defaults: AgentTemplateDefaults;
307
+ }
308
+
309
+ declare interface AgentTemplateDefaults {
310
+ role: string;
311
+ audienceDescription: string;
312
+ tone: string;
313
+ opener: string;
314
+ qualificationFlow: Array<{
315
+ question: string;
316
+ listens_for: string;
317
+ }>;
318
+ requiredSlots: string[];
319
+ primaryCTA: string;
320
+ fallbackCTA: string;
321
+ escalationRule: string;
322
+ scripts: Array<{
323
+ title: string;
324
+ when_to_use: string;
325
+ content: string;
326
+ }>;
327
+ objections: Array<{
328
+ trigger: string;
329
+ response: string;
330
+ }>;
331
+ successCriteria: string[];
332
+ offLimits: string;
333
+ prohibitedClaims: string;
334
+ language?: string;
335
+ agentRole?: 'operator' | 'specialist' | 'executive' | 'concierge';
336
+ bargeInEnabled?: boolean;
337
+ maxCallDuration?: number;
338
+ knowledgeBaseHints?: string[];
339
+ extractionTags?: string[];
340
+ restrictedTopics?: string[];
341
+ forbiddenPromises?: string[];
342
+ recordingEnabled?: boolean;
343
+ transcriptionEnabled?: boolean;
344
+ requireConsent?: boolean;
345
+ postCallSummaryEnabled?: boolean;
346
+ postCallSummaryPrompt?: string;
347
+ postCallExtractionEnabled?: boolean;
348
+ postCallExtractionFields?: string[];
349
+ postCallEvaluationEnabled?: boolean;
350
+ postCallEvaluationRubric?: string;
351
+ stt_keywords?: string;
352
+ callerPersonas?: Array<{
353
+ type: string;
354
+ detectedWhen: string;
355
+ approach: string;
356
+ }>;
357
+ setupQuestions?: SetupQuestion[];
358
+ variables?: AgentVariable[];
359
+ matchKeywords?: string[];
360
+ }
361
+
362
+ export declare type AgentTemplateStatus = 'draft' | 'submitted' | 'approved' | 'published' | 'rejected' | 'archived';
363
+
364
+ export declare type AgentTemplateVisibility = 'private' | 'tenant' | 'public';
365
+
366
+ /**
367
+ * Per-agent binding for one built-in tool. Credentials are referenced
368
+ * by id (resolved server-side from a secrets store), never embedded.
369
+ *
370
+ * `provider_settings` is an opaque per-tool config bag — e.g. for
371
+ * check_calendar_availability it might hold `{ calendar_id, timezone }`.
372
+ * Schema is intentionally `unknown` here because each tool validates its
373
+ * own settings against a Zod schema at registration time.
374
+ */
375
+ export declare interface AgentToolBinding {
376
+ tool_id: BuiltinAgentToolId;
377
+ enabled: boolean;
378
+ /** Reference into tenant_credentials. Null means "use the platform default". */
379
+ credential_ref: string | null;
380
+ /** Per-call execution timeout. Capped at 10s by the runtime. */
381
+ timeout_ms: number;
382
+ side_effect: ToolSideEffect;
383
+ /** Free-form per-tool config — see provider_settings note above. */
384
+ provider_settings?: Record<string, unknown>;
385
+ }
386
+
387
+ export declare interface AgentVariable {
388
+ key: string;
389
+ description: string;
390
+ metadataKey?: string;
391
+ required: boolean;
392
+ default?: string;
393
+ /**
394
+ * Live METHOD when not satisfied by input/default. Optional on the wire for
395
+ * legacy rows; use `normalizeVariableAcquisition` to read a concrete value.
396
+ */
397
+ acquisition?: VariableAcquisition;
398
+ origin?: VariableOrigin;
399
+ /**
400
+ * Value type used to validate incoming metadata. When omitted the variable
401
+ * behaves as a free-form string (legacy behavior, byte-identical resolution).
402
+ * A metadata value that does not satisfy this type is treated as missing.
403
+ */
404
+ type?: AgentVariableType;
405
+ /**
406
+ * Allowed values when `type === 'enum'`. A metadata value not in this list is
407
+ * treated as missing. Ignored for non-enum types. An enum with no/empty
408
+ * `enumValues` falls back to lenient string passthrough.
409
+ */
410
+ enumValues?: string[];
411
+ }
412
+
413
+ /** Allowed value-type for a caller variable. Absent ⇒ treated as 'string'. */
414
+ declare type AgentVariableType = 'string' | 'number' | 'boolean' | 'enum';
415
+
416
+ export declare interface AgentVoiceConfig {
417
+ voiceId?: string;
418
+ language?: string;
419
+ accent?: string;
420
+ bargeInEnabled?: boolean;
421
+ }
422
+
423
+ export declare type BuiltinAgentToolId = 'handoff_to_human' | 'check_calendar_availability' | 'list_calendar_events' | 'create_calendar_event' | 'update_calendar_event' | 'delete_calendar_event' | 'lookup_customer' | 'send_whatsapp_message' | 'send_telegram_message' | 'send_asset';
424
+
425
+ export declare interface Call {
426
+ id: string;
427
+ room_name: string;
428
+ user_id?: string;
429
+ tenant_id?: string;
430
+ agent_id: string;
431
+ status: CallStatus;
432
+ recording_status: 'none' | 'requested' | 'active' | 'processing' | 'completed' | 'failed';
433
+ started_at: string | null;
434
+ ended_at: string | null;
435
+ end_reason?: string | null;
436
+ error_code?: string | null;
437
+ error_message?: string | null;
438
+ metadata: Record<string, any>;
439
+ created_at: string;
440
+ updated_at: string;
441
+ }
442
+
443
+ export declare interface CallEvaluationResult {
444
+ rubric: string;
445
+ passed: boolean | null;
446
+ score: number | null;
447
+ reasoning: string | null;
448
+ }
449
+
450
+ export declare type CallIntelligenceStatus = 'not_started' | 'pending' | 'processing' | 'completed' | 'partial' | 'failed' | 'dead_letter';
451
+
452
+ export declare interface CallParticipant {
453
+ id: string;
454
+ call_id: string;
455
+ user_id?: string | null;
456
+ role: CallParticipantRole;
457
+ transport: CallParticipantTransport;
458
+ identity: string;
459
+ status: CallParticipantStatus;
460
+ metadata: Record<string, any>;
461
+ joined_at: string;
462
+ left_at: string | null;
463
+ created_at: string;
464
+ }
465
+
466
+ export declare type CallParticipantRole = 'agent' | 'customer' | 'observer';
467
+
468
+ export declare type CallParticipantStatus = 'joining' | 'active' | 'left' | 'failed';
469
+
470
+ export declare type CallParticipantTransport = 'webrtc' | 'pstn' | 'sip' | 'internal';
471
+
472
+ export declare interface CallRecording {
473
+ id: string;
474
+ call_id: string;
475
+ participant_id?: string | null;
476
+ recording_url?: string | null;
477
+ provider_recording_id?: string | null;
478
+ format: string;
479
+ status: 'processing' | 'completed' | 'failed';
480
+ duration?: number | null;
481
+ size_bytes?: number | null;
482
+ metadata: Record<string, any>;
483
+ created_at: string;
484
+ }
485
+
486
+ export declare type CallSentiment = 'positive' | 'neutral' | 'negative' | 'unknown';
487
+
488
+ export declare type CallStatus = 'queued' | 'ringing' | 'in_progress' | 'completed' | 'failed' | 'no_answer' | 'busy' | 'canceled';
489
+
490
+ export declare interface CallStatusChangedEvent extends TelephonyBaseEvent {
491
+ type: 'call.status_changed';
492
+ status: TelephonyCallStatus;
493
+ callId: string;
494
+ }
495
+
496
+ export declare interface CallTranscriptEvent {
497
+ id: string;
498
+ call_id: string;
499
+ participant_id: string | null;
500
+ role: 'user' | 'agent';
501
+ text: string;
502
+ sequence: number;
503
+ source: 'runtime' | 'stt' | 'post_call';
504
+ started_at_ms: number | null;
505
+ ended_at_ms: number | null;
506
+ metadata: Record<string, any>;
507
+ created_at: string;
508
+ }
509
+
510
+ declare type CallTranscriptSpeaker = 'user' | 'agent';
511
+
512
+ declare interface CapabilityUnsupportedEvent extends TelephonyBaseEvent {
513
+ type: 'capability.unsupported';
514
+ requestedType: TelephonyEventType;
515
+ }
516
+
517
+ declare type ConnectorCategory = 'calendar' | 'crm' | 'ticketing' | 'messaging';
518
+
519
+ /** Safe view of a workspace connector connection. NEVER includes tokens. */
520
+ export declare interface ConnectorConnectionSafeView {
521
+ id: string;
522
+ provider: string;
523
+ category: ConnectorCategory;
524
+ displayName: string;
525
+ accountName: string;
526
+ status: 'connected' | 'expired' | 'error';
527
+ scopes: string[];
528
+ connectedAt: string;
529
+ expiresAt: string | null;
530
+ }
531
+
532
+ export declare type CreateKnowledgeSourceRequest = CreateKnowledgeSourceTextRequest | CreateKnowledgeSourceUrlRequest;
533
+
534
+ /** Request body for POST /agents/:id/knowledge-sources (text mode). */
535
+ export declare interface CreateKnowledgeSourceTextRequest {
536
+ kind: 'text';
537
+ title: string;
538
+ text: string;
539
+ }
540
+
541
+ /** Request body for POST /agents/:id/knowledge-sources (url mode). */
542
+ export declare interface CreateKnowledgeSourceUrlRequest {
543
+ kind: 'url';
544
+ title: string;
545
+ url: string;
546
+ }
547
+
548
+ declare interface DtmfReceivedEvent extends TelephonyBaseEvent {
549
+ type: 'dtmf.received';
550
+ digit: string;
551
+ }
552
+
553
+ export declare interface Invoice {
554
+ id: string;
555
+ invoice_number: string;
556
+ tenant_id: string;
557
+ kind: InvoiceKind;
558
+ status: InvoiceStatus;
559
+ currency: string;
560
+ subtotal_minor: number;
561
+ tax_minor: number;
562
+ discount_minor: number;
563
+ total_minor: number;
564
+ gateway: InvoiceGateway;
565
+ gateway_invoice_id: string | null;
566
+ payment_event_id: string | null;
567
+ period_start: string | null;
568
+ period_end: string | null;
569
+ issued_at: string;
570
+ paid_at: string | null;
571
+ voided_at: string | null;
572
+ }
573
+
574
+ export declare interface InvoiceDetailResponse {
575
+ invoice: Invoice;
576
+ items: InvoiceItem[];
577
+ }
578
+
579
+ export declare type InvoiceGateway = 'stripe' | 'razorpay';
580
+
581
+ export declare interface InvoiceItem {
582
+ id: string;
583
+ invoice_id: string;
584
+ kind: InvoiceItemKind;
585
+ description: string;
586
+ quantity: number;
587
+ unit_amount_minor: number;
588
+ amount_minor: number;
589
+ plan_id: string | null;
590
+ credit_transaction_id: string | null;
591
+ }
592
+
593
+ export declare type InvoiceItemKind = 'topup' | 'discount' | 'tax_line' | 'adjustment';
594
+
595
+ export declare type InvoiceKind = 'topup' | 'adjustment';
596
+
597
+ export declare interface InvoiceListResponse {
598
+ invoices: Invoice[];
599
+ next_cursor: string | null;
600
+ }
601
+
602
+ export declare type InvoiceStatus = 'paid' | 'failed' | 'pending' | 'void' | 'refunded';
603
+
604
+ /**
605
+ * Single embedded chunk produced by the ingestion pipeline.
606
+ * Returned by the runtime knowledge_search tool with a similarity score.
607
+ */
608
+ export declare interface KnowledgeChunk {
609
+ id: string;
610
+ source_id: string;
611
+ agent_id: string;
612
+ tenant_id: string;
613
+ chunk_index: number;
614
+ text: string;
615
+ /** Cosine similarity in [0, 1]. Only present on retrieval results. */
616
+ score?: number;
617
+ bytes: number;
618
+ created_at: string;
619
+ }
620
+
621
+ /**
622
+ * A user-supplied knowledge unit attached to an agent. Chunked and
623
+ * embedded into KnowledgeChunk rows for retrieval.
624
+ */
625
+ export declare interface KnowledgeSource {
626
+ id: string;
627
+ agent_id: string;
628
+ tenant_id: string;
629
+ kind: KnowledgeSourceKind;
630
+ title: string;
631
+ /** URL when kind='url', filename when kind='file', null for kind='text'. */
632
+ source_uri: string | null;
633
+ status: KnowledgeSourceStatus;
634
+ failure_reason: KnowledgeSourceFailureReason | string | null;
635
+ /** SHA-256 of the raw source content. Used to detect stale chunks. */
636
+ content_hash: string | null;
637
+ /** Incremented on each successful re-ingest. */
638
+ version: number;
639
+ chunk_count: number;
640
+ bytes: number;
641
+ created_at: string;
642
+ updated_at: string;
643
+ }
644
+
645
+ /**
646
+ * Stable reason codes for knowledge source failure and quota enforcement.
647
+ * UI copy lives separately; branch on these codes, not on message strings.
648
+ */
649
+ declare type KnowledgeSourceFailureReason = 'fetch_failed' | 'extraction_failed' | 'embedding_failed' | 'quota_exceeded' | 'file_too_large' | 'unsupported_mime_type' | 'permission_denied' | 'storage_error' | 'unknown';
650
+
651
+ export declare type KnowledgeSourceKind = 'text' | 'url' | 'file';
652
+
653
+ /** Full lifecycle state for a knowledge source. */
654
+ export declare type KnowledgeSourceStatus = 'pending' | 'indexing' | 'ready' | 'failed';
655
+
656
+ export declare interface MachineDetectedEvent extends TelephonyBaseEvent {
657
+ type: 'machine.detected';
658
+ confidence: number;
659
+ /** Whether a voicemail beep was also detected. */
660
+ beepDetected: boolean;
661
+ }
662
+
663
+ declare interface MediaConnectedEvent extends TelephonyBaseEvent {
664
+ type: 'media.connected';
665
+ sampleRate: number;
666
+ channels: number;
667
+ }
668
+
669
+ declare interface MediaDisconnectedEvent extends TelephonyBaseEvent {
670
+ type: 'media.disconnected';
671
+ reason: string;
672
+ }
673
+
674
+ export declare interface PostCallStructuredExtractionConfig {
675
+ prompt: string | null;
676
+ json_schema: Record<string, any> | null;
677
+ }
678
+
679
+ export declare interface RecordingCompletedEvent extends TelephonyBaseEvent {
680
+ type: 'recording.completed';
681
+ recordingId: string;
682
+ durationMs: number;
683
+ url?: string;
684
+ }
685
+
686
+ declare interface RecordingStartedEvent extends TelephonyBaseEvent {
687
+ type: 'recording.started';
688
+ recordingId: string;
689
+ }
690
+
691
+ /**
692
+ * Public-facing labels for runtime reason codes the backend emits on call
693
+ * records (`end_reason`, end-reason distributions, handoff metadata).
694
+ *
695
+ * The codes themselves are the source of truth in
696
+ * `@rymi/agents-core/src/reasonCodes.ts`. This module is the UI label layer:
697
+ * Studio, call detail, dashboards, and admin views map codes to copy here
698
+ * instead of de-snake-casing the wire format on the fly.
699
+ *
700
+ * Rules:
701
+ * - Adding/changing a public label is a UI copy change, never a contract
702
+ * change. The backend code remains untouched.
703
+ * - Unknown codes fall back to a Title Case of the snake_case so legacy
704
+ * call rows still render readably.
705
+ * - Labels stay short and declarative per `design.md` voice rules.
706
+ */
707
+ /** Known session-close reasons rendered on call records. */
708
+ export declare type SessionEndReasonCode = 'end_call_tool' | 'handoff_to_human' | 'handoff_to_agent' | 'user_disconnect' | 'provider_disconnect' | 'error' | 'timeout' | 'closed';
709
+
710
+ export declare interface SetupQuestion {
711
+ id: string;
712
+ header: string;
713
+ question: string;
714
+ helper?: string;
715
+ options: SetupQuestionOption[];
716
+ multiSelect: boolean;
717
+ writes: SetupWrite[];
718
+ defaultValue?: string | string[];
719
+ allowFreeText?: boolean;
720
+ placeholder?: string;
721
+ required: boolean;
722
+ dependsOn?: {
723
+ id: string;
724
+ equals: string;
725
+ };
726
+ }
727
+
728
+ declare interface SetupQuestionOption {
729
+ label: string;
730
+ description: string;
731
+ }
732
+
733
+ declare type SetupWrite = {
734
+ kind: 'set';
735
+ key: string;
736
+ } | {
737
+ kind: 'append';
738
+ key: string;
739
+ } | {
740
+ kind: 'replace';
741
+ key: string;
742
+ } | {
743
+ kind: 'append-csv';
744
+ key: string;
745
+ } | {
746
+ kind: 'opener-template';
747
+ token: string;
748
+ };
749
+
750
+ declare interface TelephonyBaseEvent {
751
+ type: TelephonyEventType;
752
+ timestampMs: number;
753
+ /** Provider-specific raw event — for debugging only, never branch on this. */
754
+ providerRaw?: unknown;
755
+ }
756
+
757
+ declare type TelephonyCallStatus = 'ringing' | 'answered' | 'in_progress' | 'completed' | 'failed' | 'busy' | 'no_answer' | 'canceled';
758
+
759
+ export declare type TelephonyEvent = CallStatusChangedEvent | MediaConnectedEvent | MediaDisconnectedEvent | DtmfReceivedEvent | MachineDetectedEvent | VoicemailBeepEvent | RecordingStartedEvent | RecordingCompletedEvent | TransferInitiatedEvent | TransferCompletedEvent | TransferFailedEvent | CapabilityUnsupportedEvent;
760
+
761
+ /**
762
+ * Provider-neutral telephony event vocabulary.
763
+ *
764
+ * Transport packages (LiveKit, Twilio, browser, WebSocket) normalize their
765
+ * provider-specific callbacks into this shared event model. Future
766
+ * DTMF/voicemail/recording/machine-detection UI controls consume these
767
+ * events without knowing the underlying provider.
768
+ *
769
+ * Rules:
770
+ * - Use `TelephonyEventType` values in all transport adapters — never raw strings.
771
+ * - Unsupported event types on a transport should emit `'capability.unsupported'`
772
+ * rather than silently dropping.
773
+ * - `TelephonyCapabilityReport` lets callers discover what a transport can do
774
+ * without a runtime try/catch.
775
+ */
776
+ export declare type TelephonyEventType = 'call.status_changed' | 'media.connected' | 'media.disconnected' | 'dtmf.received' | 'machine.detected' | 'voicemail.beep' | 'recording.started' | 'recording.completed' | 'transfer.initiated' | 'transfer.completed' | 'transfer.failed' | 'capability.unsupported';
777
+
778
+ export declare interface TelephonyLeg {
779
+ id: string;
780
+ call_id: string;
781
+ participant_id: string;
782
+ provider: 'plivo' | 'twilio' | 'vonage';
783
+ provider_call_id?: string | null;
784
+ direction: 'inbound' | 'outbound';
785
+ status: string;
786
+ from_number?: string | null;
787
+ to_number?: string | null;
788
+ cost: number;
789
+ duration: number;
790
+ metadata: Record<string, any>;
791
+ created_at: string;
792
+ }
793
+
794
+ /**
795
+ * Safe view of tool capability state for SDK/MCP responses.
796
+ * Omits internal fields that expose tenant credential structure.
797
+ */
798
+ export declare interface ToolCapabilitySafeView {
799
+ toolId: string;
800
+ available: boolean;
801
+ unavailableReason: ToolUnavailableReason | null;
802
+ sideEffect: 'read' | 'write';
803
+ }
804
+
805
+ /** What the tool does to the world — drives audit-logging requirements. */
806
+ export declare type ToolSideEffect = 'read' | 'write';
807
+
808
+ /** Stable reason codes for why a tool is unavailable on a given call. */
809
+ declare type ToolUnavailableReason = 'agent_tool_disabled' | 'missing_credential' | 'missing_caller_phone' | 'missing_telegram_chat_id' | 'missing_transfer_number' | 'blocked_by_mvp_policy' | 'not_supported_in_runtime' | 'provider_not_configured' | 'auth_error' | 'credential_expired' | 'context_missing' | 'policy_blocked' | 'plan_gate' | 'runtime_not_initialized' | 'rate_limited';
810
+
811
+ export declare interface TranscriptionResult {
812
+ text: string;
813
+ confidence: number | null;
814
+ languageCode?: string | null;
815
+ isFinal?: boolean;
816
+ provider?: string | null;
817
+ model?: string | null;
818
+ }
819
+
820
+ export declare interface TranscriptSegment {
821
+ id?: string;
822
+ speaker: CallTranscriptSpeaker;
823
+ text: string;
824
+ sequence: number;
825
+ started_at_ms: number;
826
+ ended_at_ms: number;
827
+ is_final: boolean;
828
+ source: string;
829
+ created_at?: string;
830
+ }
831
+
832
+ export declare interface TransferCompletedEvent extends TelephonyBaseEvent {
833
+ type: 'transfer.completed';
834
+ target: string;
835
+ }
836
+
837
+ declare interface TransferFailedEvent extends TelephonyBaseEvent {
838
+ type: 'transfer.failed';
839
+ target: string;
840
+ reason: string;
841
+ }
842
+
843
+ declare interface TransferInitiatedEvent extends TelephonyBaseEvent {
844
+ type: 'transfer.initiated';
845
+ target: string;
846
+ }
847
+
848
+ /** How the agent obtains a variable live when input/default did not satisfy it. */
849
+ declare type VariableAcquisition = 'ask' | 'extract' | 'none';
850
+
851
+ /** Where a variable was first authored (for Studio UX / badges). */
852
+ declare type VariableOrigin = 'caller' | 'playbook' | 'postcall' | 'prompt' | 'template';
853
+
854
+ declare interface VoicemailBeepEvent extends TelephonyBaseEvent {
855
+ type: 'voicemail.beep';
856
+ }
857
+
858
+ export { }