@dialgem/sdk 0.1.0-beta.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.
@@ -0,0 +1,2240 @@
1
+ /**
2
+ * Every failure the SDK raises is a `DialgemError`.
3
+ *
4
+ * HTTP failures are `APIError` subclasses chosen by status, so a caller can
5
+ * `catch (e) { if (e instanceof NotFoundError) ... }`. Within a status, branch on
6
+ * `errCode`: the API documents `err_code` as the one field clients
7
+ * branch on, e.g. `flow_invalid`,
8
+ * `flow_not_runnable`, `NOT_A_MEMBER`.
9
+ */
10
+ /**
11
+ * One entry of `issues[]` (in an error body, or an agent's `flow_validation`): a
12
+ * field error or a flow graph rule.
13
+ */
14
+ interface ErrorIssue {
15
+ /** Stable machine-readable identifier of the rule. */
16
+ code?: string;
17
+ severity?: "error" | "warning";
18
+ message?: string;
19
+ node_id?: string | null;
20
+ edge_id?: string | null;
21
+ /** Path into the request body, for field errors. */
22
+ loc?: (string | number)[] | null;
23
+ meta?: Record<string, unknown>;
24
+ [key: string]: unknown;
25
+ }
26
+ /** The API's error envelope. */
27
+ interface ErrorBody {
28
+ err_code: string;
29
+ err_msg: string;
30
+ request_id: string;
31
+ issues?: ErrorIssue[];
32
+ [key: string]: unknown;
33
+ }
34
+ /** Minimal read-only view of response headers, independent of the fetch implementation. */
35
+ interface HeadersLike {
36
+ get(name: string): string | null;
37
+ }
38
+ declare class DialgemError extends Error {
39
+ name: string;
40
+ }
41
+ declare class APIError extends DialgemError {
42
+ name: string;
43
+ /** HTTP status code. */
44
+ readonly status: number;
45
+ /** The service's `err_code`, e.g. `flow_invalid` or `HTTP_404`. Undefined if the body was not the envelope. */
46
+ readonly errCode: string | undefined;
47
+ /** The service's `request_id`. Quote it when contacting support. */
48
+ readonly requestId: string | undefined;
49
+ /** Field/graph diagnostics, present on validation failures. */
50
+ readonly issues: readonly ErrorIssue[];
51
+ /** Parsed JSON body, or the raw text if the body was not JSON. */
52
+ readonly body: unknown;
53
+ readonly headers: HeadersLike;
54
+ constructor(status: number, body: unknown, message: string, headers: HeadersLike);
55
+ /** Build the subclass matching `status`. */
56
+ static from(status: number, body: unknown, statusText: string, headers: HeadersLike): APIError;
57
+ }
58
+ declare class BadRequestError extends APIError {
59
+ name: string;
60
+ }
61
+ declare class AuthenticationError extends APIError {
62
+ name: string;
63
+ }
64
+ declare class PermissionDeniedError extends APIError {
65
+ name: string;
66
+ }
67
+ declare class NotFoundError extends APIError {
68
+ name: string;
69
+ }
70
+ declare class ConflictError extends APIError {
71
+ name: string;
72
+ }
73
+ declare class UnprocessableEntityError extends APIError {
74
+ name: string;
75
+ }
76
+ declare class RateLimitError extends APIError {
77
+ name: string;
78
+ }
79
+ declare class InternalServerError extends APIError {
80
+ name: string;
81
+ }
82
+ /** The request never produced an HTTP response (DNS, TLS, reset, aborted by the caller). */
83
+ declare class APIConnectionError extends DialgemError {
84
+ name: string;
85
+ constructor(message?: string, options?: {
86
+ cause?: unknown;
87
+ });
88
+ }
89
+ /** The caller's `signal` aborted the request. Never retried. */
90
+ declare class APIUserAbortError extends DialgemError {
91
+ name: string;
92
+ constructor(message?: string);
93
+ }
94
+ /** The request exceeded the configured `timeout`. */
95
+ declare class APIConnectionTimeoutError extends APIConnectionError {
96
+ name: string;
97
+ constructor(message?: string);
98
+ }
99
+ /** A webhook's signature did not match its body. */
100
+ declare class WebhookVerificationError extends DialgemError {
101
+ name: string;
102
+ }
103
+
104
+ /**
105
+ * The slice of `fetch` the SDK uses. Declared structurally so any conforming
106
+ * implementation (Node's global fetch, undici, node-fetch, a test double) fits,
107
+ * without the SDK's public types depending on DOM lib typings.
108
+ */
109
+ type Fetch = (url: string, init: FetchInit) => Promise<FetchResponse>;
110
+ interface FetchInit {
111
+ method: string;
112
+ headers: Record<string, string>;
113
+ body?: string;
114
+ signal: AbortSignal;
115
+ /**
116
+ * Always `"manual"`. A followed redirect re-sends the API key to wherever the
117
+ * `Location` points (fetch strips only `Authorization` cross-origin, not
118
+ * `X-API-Key`), and turns a 301'd POST into a GET that "succeeds" with the
119
+ * wrong body. The API never redirects, so a 3xx is surfaced as an `APIError`.
120
+ */
121
+ redirect: "manual";
122
+ }
123
+ interface FetchResponse {
124
+ readonly status: number;
125
+ readonly statusText: string;
126
+ readonly headers: HeadersLike;
127
+ text(): Promise<string>;
128
+ }
129
+ /** Per-call overrides, accepted as the last argument of every resource method. */
130
+ interface RequestOptions {
131
+ /** Milliseconds (> 0) before the attempt is aborted. Applies per attempt, not across retries. */
132
+ timeout?: number | undefined;
133
+ /**
134
+ * Retries on 408/429/5xx and connection failures.
135
+ *
136
+ * GET, PATCH and DELETE use the client's `maxRetries` unless overridden here.
137
+ * **POST is never retried unless you set this explicitly**: most POSTs create
138
+ * things, and an outbound call retried after an ambiguous 502 dials the person twice.
139
+ */
140
+ maxRetries?: number | undefined;
141
+ /** Abort the request. Surfaces as `APIUserAbortError`. */
142
+ signal?: AbortSignal | undefined;
143
+ /** Extra headers for this request only. */
144
+ headers?: Record<string, string> | undefined;
145
+ }
146
+ type QueryValue = string | number | boolean | null | undefined;
147
+ type Query = Record<string, QueryValue>;
148
+ interface HttpClientOptions {
149
+ apiKey: string;
150
+ baseURL: string;
151
+ timeout: number;
152
+ maxRetries: number;
153
+ fetch: Fetch;
154
+ defaultHeaders: Record<string, string>;
155
+ }
156
+ type Method = "GET" | "POST" | "PATCH" | "DELETE";
157
+ declare class HttpClient {
158
+ #private;
159
+ readonly baseURL: string;
160
+ constructor(options: HttpClientOptions);
161
+ get<T>(path: string, query?: Query, options?: RequestOptions): Promise<T>;
162
+ post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
163
+ patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
164
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
165
+ request<T>(method: Method, path: string, { query, body, options }: {
166
+ query?: Query | undefined;
167
+ body?: unknown;
168
+ options?: RequestOptions | undefined;
169
+ }): Promise<T>;
170
+ buildURL(path: string, query?: Query): string;
171
+ private buildHeaders;
172
+ }
173
+
174
+ interface components {
175
+ schemas: {
176
+ /** AgentCreate */
177
+ AgentCreate: {
178
+ /**
179
+ * Agent Type
180
+ * @default llm
181
+ * @enum {string}
182
+ */
183
+ agent_type?: "llm" | "multi_prompt" | "flow";
184
+ /**
185
+ * Ambient Sound
186
+ * @default none
187
+ * @enum {string}
188
+ */
189
+ ambient_sound?: "none" | "coffee-shop" | "call-center" | "convention-hall" | "summer-outdoor" | "mountain-outdoor" | "static-noise";
190
+ /**
191
+ * Ambient Sound Volume
192
+ * @default 1
193
+ */
194
+ ambient_sound_volume?: number;
195
+ /**
196
+ * Backchannel Frequency
197
+ * @default 0.8
198
+ */
199
+ backchannel_frequency?: number;
200
+ /**
201
+ * Begin Message Delay Ms
202
+ * @default 0
203
+ */
204
+ begin_message_delay_ms?: number;
205
+ /** Boosted Keywords */
206
+ boosted_keywords?: string[];
207
+ /** Data Retention Days */
208
+ data_retention_days?: number | null;
209
+ /** Default Dynamic Variables */
210
+ default_dynamic_variables?: {
211
+ [key: string]: string;
212
+ };
213
+ /**
214
+ * Denoising Mode
215
+ * @default off
216
+ * @enum {string}
217
+ */
218
+ denoising_mode?: "off" | "noise-cancellation";
219
+ /**
220
+ * Enable Backchannel
221
+ * @default false
222
+ */
223
+ enable_backchannel?: boolean;
224
+ /**
225
+ * Enable Transcription Formatting
226
+ * @default false
227
+ */
228
+ enable_transcription_formatting?: boolean;
229
+ /**
230
+ * End Call After Silence Ms
231
+ * @default 600000
232
+ */
233
+ end_call_after_silence_ms?: number;
234
+ /** Fallback Llm Model */
235
+ fallback_llm_model?: string | null;
236
+ /** Fallback Llm Provider */
237
+ fallback_llm_provider?: ("anthropic" | "openai") | null;
238
+ /** Fallback Voice Id */
239
+ fallback_voice_id?: string | null;
240
+ /** First Message */
241
+ first_message?: string | null;
242
+ flow_config?: components["schemas"]["FlowConfig"] | null;
243
+ /**
244
+ * Interruption Sensitivity
245
+ * @default 1
246
+ */
247
+ interruption_sensitivity?: number;
248
+ /**
249
+ * Language
250
+ * @default en
251
+ */
252
+ language?: string;
253
+ /** Llm Model */
254
+ llm_model?: string;
255
+ /**
256
+ * Llm Provider
257
+ * @enum {string}
258
+ */
259
+ llm_provider?: "anthropic" | "openai";
260
+ /**
261
+ * Max Call Duration Ms
262
+ * @default 3600000
263
+ */
264
+ max_call_duration_ms?: number;
265
+ /**
266
+ * Max Tokens
267
+ * @default 150
268
+ */
269
+ max_tokens?: number;
270
+ /** Name */
271
+ name: string;
272
+ /**
273
+ * Opt Out Call Recording
274
+ * @default false
275
+ */
276
+ opt_out_call_recording?: boolean;
277
+ /**
278
+ * Opt Out Transcript Storage
279
+ * @default false
280
+ */
281
+ opt_out_transcript_storage?: boolean;
282
+ /**
283
+ * Pii Redaction Enabled
284
+ * @default false
285
+ */
286
+ pii_redaction_enabled?: boolean;
287
+ /** Post Call Analysis Data */
288
+ post_call_analysis_data?: components["schemas"]["PostCallAnalysisVariable"][];
289
+ /**
290
+ * Post Call Analysis Model
291
+ * @default claude-sonnet-4-6
292
+ */
293
+ post_call_analysis_model?: string;
294
+ /**
295
+ * Reminder Message
296
+ * @default
297
+ */
298
+ reminder_message?: string;
299
+ /**
300
+ * Reminder Trigger Ms
301
+ * @default 10000
302
+ */
303
+ reminder_trigger_ms?: number;
304
+ /**
305
+ * Responsiveness
306
+ * @default 1
307
+ */
308
+ responsiveness?: number;
309
+ /**
310
+ * Ring Duration Ms
311
+ * @default 30000
312
+ */
313
+ ring_duration_ms?: number;
314
+ /** Starting State */
315
+ starting_state?: string | null;
316
+ /** States */
317
+ states?: components["schemas"]["PromptState"][];
318
+ /**
319
+ * Stt Model
320
+ * @enum {string}
321
+ */
322
+ stt_model?: "whisper" | "conformer" | "deepgram";
323
+ /**
324
+ * System Prompt
325
+ * @default
326
+ */
327
+ system_prompt?: string;
328
+ /**
329
+ * Temperature
330
+ * @default 0.7
331
+ */
332
+ temperature?: number;
333
+ /**
334
+ * Tts Engine
335
+ * @default cartesia
336
+ */
337
+ tts_engine?: string;
338
+ /**
339
+ * Voice Id
340
+ * @default
341
+ */
342
+ voice_id?: string;
343
+ /**
344
+ * Voice Speed
345
+ * @default 1
346
+ */
347
+ voice_speed?: number;
348
+ /**
349
+ * Voice Temperature
350
+ * @default 0.5
351
+ */
352
+ voice_temperature?: number;
353
+ /**
354
+ * Voicemail Action
355
+ * @default hangup
356
+ * @enum {string}
357
+ */
358
+ voicemail_action?: "hangup" | "leave_message";
359
+ /**
360
+ * Voicemail Detection Enabled
361
+ * @default false
362
+ */
363
+ voicemail_detection_enabled?: boolean;
364
+ /**
365
+ * Voicemail Message
366
+ * @default
367
+ */
368
+ voicemail_message?: string;
369
+ /** Webhook Events */
370
+ webhook_events?: ("call_started" | "call_ended" | "call_analyzed")[];
371
+ /** Webhook Signing Secret */
372
+ webhook_signing_secret?: string | null;
373
+ /** Webhook Url */
374
+ webhook_url?: string | null;
375
+ };
376
+ /** AgenticTransferConfig */
377
+ AgenticTransferConfig: {
378
+ /** Action On Timeout */
379
+ action_on_timeout?: string | null;
380
+ transfer_agent?: components["schemas"]["TransferAgent"] | null;
381
+ /** Transfer Timeout Ms */
382
+ transfer_timeout_ms?: number | null;
383
+ } & {
384
+ [key: string]: unknown;
385
+ };
386
+ /** AgentSwapNode */
387
+ AgentSwapNode: {
388
+ /** Agent Id */
389
+ agent_id: string;
390
+ /** Agent Version */
391
+ agent_version?: string | number | null;
392
+ display_position?: components["schemas"]["DisplayPosition"] | null;
393
+ edge?: components["schemas"]["Edge"] | null;
394
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
395
+ /** Id */
396
+ id: string;
397
+ instruction?: components["schemas"]["Instruction"] | null;
398
+ /** Keep Current Language */
399
+ keep_current_language?: boolean | null;
400
+ /** Keep Current Voice */
401
+ keep_current_voice?: boolean | null;
402
+ /** Name */
403
+ name?: string | null;
404
+ /** Post Call Analysis Setting */
405
+ post_call_analysis_setting?: ("both_agents" | "only_destination_agent") | null;
406
+ /** Speak During Execution */
407
+ speak_during_execution?: boolean | null;
408
+ /**
409
+ * Type
410
+ * @constant
411
+ */
412
+ type: "agent_swap";
413
+ /** Webhook Setting */
414
+ webhook_setting?: ("both_agents" | "only_destination_agent" | "only_source_agent") | null;
415
+ } & {
416
+ [key: string]: unknown;
417
+ };
418
+ /** AgentUpdate */
419
+ AgentUpdate: {
420
+ /** Agent Type */
421
+ agent_type?: ("llm" | "multi_prompt" | "flow") | null;
422
+ /** Ambient Sound */
423
+ ambient_sound?: ("none" | "coffee-shop" | "call-center" | "convention-hall" | "summer-outdoor" | "mountain-outdoor" | "static-noise") | null;
424
+ /** Ambient Sound Volume */
425
+ ambient_sound_volume?: number | null;
426
+ /** Backchannel Frequency */
427
+ backchannel_frequency?: number | null;
428
+ /** Begin Message Delay Ms */
429
+ begin_message_delay_ms?: number | null;
430
+ /** Boosted Keywords */
431
+ boosted_keywords?: string[] | null;
432
+ /** Data Retention Days */
433
+ data_retention_days?: number | null;
434
+ /** Default Dynamic Variables */
435
+ default_dynamic_variables?: {
436
+ [key: string]: string;
437
+ } | null;
438
+ /** Denoising Mode */
439
+ denoising_mode?: ("off" | "noise-cancellation") | null;
440
+ /** Enable Backchannel */
441
+ enable_backchannel?: boolean | null;
442
+ /** Enable Transcription Formatting */
443
+ enable_transcription_formatting?: boolean | null;
444
+ /** End Call After Silence Ms */
445
+ end_call_after_silence_ms?: number | null;
446
+ /** Fallback Llm Model */
447
+ fallback_llm_model?: string | null;
448
+ /** Fallback Llm Provider */
449
+ fallback_llm_provider?: ("anthropic" | "openai") | null;
450
+ /** Fallback Voice Id */
451
+ fallback_voice_id?: string | null;
452
+ /** First Message */
453
+ first_message?: string | null;
454
+ flow_config?: components["schemas"]["FlowConfig"] | null;
455
+ /** Interruption Sensitivity */
456
+ interruption_sensitivity?: number | null;
457
+ /** Language */
458
+ language?: string | null;
459
+ /** Llm Model */
460
+ llm_model?: string | null;
461
+ /** Llm Provider */
462
+ llm_provider?: ("anthropic" | "openai") | null;
463
+ /** Max Call Duration Ms */
464
+ max_call_duration_ms?: number | null;
465
+ /** Max Tokens */
466
+ max_tokens?: number | null;
467
+ /** Name */
468
+ name?: string | null;
469
+ /** Opt Out Call Recording */
470
+ opt_out_call_recording?: boolean | null;
471
+ /** Opt Out Transcript Storage */
472
+ opt_out_transcript_storage?: boolean | null;
473
+ /** Pii Redaction Enabled */
474
+ pii_redaction_enabled?: boolean | null;
475
+ /** Post Call Analysis Data */
476
+ post_call_analysis_data?: components["schemas"]["PostCallAnalysisVariable"][] | null;
477
+ /** Post Call Analysis Model */
478
+ post_call_analysis_model?: string | null;
479
+ /** Reminder Message */
480
+ reminder_message?: string | null;
481
+ /** Reminder Trigger Ms */
482
+ reminder_trigger_ms?: number | null;
483
+ /** Responsiveness */
484
+ responsiveness?: number | null;
485
+ /** Ring Duration Ms */
486
+ ring_duration_ms?: number | null;
487
+ /** Starting State */
488
+ starting_state?: string | null;
489
+ /** States */
490
+ states?: components["schemas"]["PromptState"][] | null;
491
+ /** Stt Model */
492
+ stt_model?: ("whisper" | "conformer" | "deepgram") | null;
493
+ /** System Prompt */
494
+ system_prompt?: string | null;
495
+ /** Temperature */
496
+ temperature?: number | null;
497
+ /** Tts Engine */
498
+ tts_engine?: string | null;
499
+ /** Voice Id */
500
+ voice_id?: string | null;
501
+ /** Voice Speed */
502
+ voice_speed?: number | null;
503
+ /** Voice Temperature */
504
+ voice_temperature?: number | null;
505
+ /** Voicemail Action */
506
+ voicemail_action?: ("hangup" | "leave_message") | null;
507
+ /** Voicemail Detection Enabled */
508
+ voicemail_detection_enabled?: boolean | null;
509
+ /** Voicemail Message */
510
+ voicemail_message?: string | null;
511
+ /** Webhook Events */
512
+ webhook_events?: ("call_started" | "call_ended" | "call_analyzed")[] | null;
513
+ /** Webhook Signing Secret */
514
+ webhook_signing_secret?: string | null;
515
+ /** Webhook Url */
516
+ webhook_url?: string | null;
517
+ };
518
+ /** AgentWeightIn */
519
+ AgentWeightIn: {
520
+ /** Agent Id */
521
+ agent_id: string;
522
+ /**
523
+ * Agent Version
524
+ * @default 0
525
+ */
526
+ agent_version?: number;
527
+ /**
528
+ * Weight
529
+ * @default 1
530
+ */
531
+ weight?: number;
532
+ };
533
+ /** BranchNode */
534
+ BranchNode: {
535
+ display_position?: components["schemas"]["DisplayPosition"] | null;
536
+ /** Edges */
537
+ edges?: components["schemas"]["Edge"][];
538
+ else_edge?: components["schemas"]["Edge"] | null;
539
+ /** Finetune Transition Examples */
540
+ finetune_transition_examples?: unknown[] | null;
541
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
542
+ /** Id */
543
+ id: string;
544
+ /** Name */
545
+ name?: string | null;
546
+ /**
547
+ * Type
548
+ * @constant
549
+ */
550
+ type: "branch";
551
+ } & {
552
+ [key: string]: unknown;
553
+ };
554
+ /** ConversationNode */
555
+ ConversationNode: {
556
+ /** Allow Dtmf Interruption */
557
+ allow_dtmf_interruption?: boolean | null;
558
+ always_edge?: components["schemas"]["Edge"] | null;
559
+ display_position?: components["schemas"]["DisplayPosition"] | null;
560
+ /** Edges */
561
+ edges?: components["schemas"]["Edge"][];
562
+ else_edge?: components["schemas"]["Edge"] | null;
563
+ /** Finetune Conversation Examples */
564
+ finetune_conversation_examples?: unknown[] | null;
565
+ /** Finetune Transition Examples */
566
+ finetune_transition_examples?: unknown[] | null;
567
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
568
+ /** Id */
569
+ id: string;
570
+ instruction: components["schemas"]["Instruction"];
571
+ /** Interruption Sensitivity */
572
+ interruption_sensitivity?: number | null;
573
+ kb_config?: components["schemas"]["KBConfig"] | null;
574
+ /** Knowledge Base Ids */
575
+ knowledge_base_ids?: string[] | null;
576
+ model_choice?: components["schemas"]["ModelChoice"] | null;
577
+ /** Name */
578
+ name?: string | null;
579
+ /** Reminder Max Count */
580
+ reminder_max_count?: number | null;
581
+ /** Reminder Trigger Ms */
582
+ reminder_trigger_ms?: number | null;
583
+ /** Responsiveness */
584
+ responsiveness?: number | null;
585
+ skip_response_edge?: components["schemas"]["Edge"] | null;
586
+ /**
587
+ * Type
588
+ * @constant
589
+ */
590
+ type: "conversation";
591
+ /** Voice Speed */
592
+ voice_speed?: number | null;
593
+ } & {
594
+ [key: string]: unknown;
595
+ };
596
+ /** DialgemExtensions */
597
+ DialgemExtensions: {
598
+ /** Content Hash */
599
+ content_hash?: string | null;
600
+ /** Equation Grammar Version */
601
+ equation_grammar_version?: number | null;
602
+ /** Features */
603
+ features?: string[] | null;
604
+ /** Not Runnable */
605
+ not_runnable?: components["schemas"]["NotRunnableEntry"][] | null;
606
+ /** Uses Extensions */
607
+ uses_extensions?: boolean | null;
608
+ } & {
609
+ [key: string]: unknown;
610
+ };
611
+ /** DisplayPosition */
612
+ DisplayPosition: {
613
+ /** X */
614
+ x?: number | null;
615
+ /** Y */
616
+ y?: number | null;
617
+ } & {
618
+ [key: string]: unknown;
619
+ };
620
+ /** DocumentCreate */
621
+ DocumentCreate: {
622
+ /** Content */
623
+ content: string;
624
+ /** Filename */
625
+ filename: string;
626
+ };
627
+ /** Edge */
628
+ Edge: {
629
+ /** Destination Node Id */
630
+ destination_node_id: string;
631
+ /** Id */
632
+ id: string;
633
+ /** Transition Condition */
634
+ transition_condition: components["schemas"]["PromptCondition"] | components["schemas"]["EquationCondition"];
635
+ } & {
636
+ [key: string]: unknown;
637
+ };
638
+ /** EndNode */
639
+ EndNode: {
640
+ display_position?: components["schemas"]["DisplayPosition"] | null;
641
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
642
+ /** Id */
643
+ id: string;
644
+ instruction?: components["schemas"]["Instruction"] | null;
645
+ /** Name */
646
+ name?: string | null;
647
+ /** Speak During Execution */
648
+ speak_during_execution?: boolean | null;
649
+ /**
650
+ * Type
651
+ * @constant
652
+ */
653
+ type: "end";
654
+ } & {
655
+ [key: string]: unknown;
656
+ };
657
+ /** Equation */
658
+ Equation: {
659
+ /** Left */
660
+ left: string;
661
+ /**
662
+ * Operator
663
+ * @enum {string}
664
+ */
665
+ operator: "==" | "!=" | ">" | ">=" | "<" | "<=" | "contains" | "not_contains" | "exists" | "not_exist";
666
+ /** Right */
667
+ right?: string | null;
668
+ } & {
669
+ [key: string]: unknown;
670
+ };
671
+ /** EquationCondition */
672
+ EquationCondition: {
673
+ /** Equations */
674
+ equations: components["schemas"]["Equation"][];
675
+ /**
676
+ * Operator
677
+ * @enum {string}
678
+ */
679
+ operator: "&&" | "||";
680
+ /** Prompt */
681
+ prompt?: string | null;
682
+ /**
683
+ * Type
684
+ * @constant
685
+ */
686
+ type: "equation";
687
+ } & {
688
+ [key: string]: unknown;
689
+ };
690
+ /** ExtractDynamicVariablesNode */
691
+ ExtractDynamicVariablesNode: {
692
+ display_position?: components["schemas"]["DisplayPosition"] | null;
693
+ /** Edges */
694
+ edges?: components["schemas"]["Edge"][];
695
+ else_edge?: components["schemas"]["Edge"] | null;
696
+ /** Enable Typing Sound */
697
+ enable_typing_sound?: boolean | null;
698
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
699
+ /** Id */
700
+ id: string;
701
+ /** Name */
702
+ name?: string | null;
703
+ /**
704
+ * Type
705
+ * @constant
706
+ */
707
+ type: "extract_dynamic_variables";
708
+ /** Variables */
709
+ variables: {
710
+ [key: string]: unknown;
711
+ }[];
712
+ } & {
713
+ [key: string]: unknown;
714
+ };
715
+ /** FlowConfig */
716
+ FlowConfig: {
717
+ /** Begin After User Silence Ms */
718
+ begin_after_user_silence_ms?: number | null;
719
+ begin_tag_display_position?: components["schemas"]["DisplayPosition"] | null;
720
+ /** Components */
721
+ components?: unknown[] | null;
722
+ /** Conversation Flow Id */
723
+ conversation_flow_id?: string | null;
724
+ /** Default Dynamic Variables */
725
+ default_dynamic_variables?: {
726
+ [key: string]: string;
727
+ } | null;
728
+ dialgem_extensions?: components["schemas"]["DialgemExtensions"] | null;
729
+ /** Flex Mode */
730
+ flex_mode?: boolean | null;
731
+ /** Global Prompt */
732
+ global_prompt?: string | null;
733
+ /** Is Published */
734
+ is_published?: boolean | null;
735
+ /** Is Transfer Llm */
736
+ is_transfer_llm?: boolean | null;
737
+ kb_config?: components["schemas"]["KBConfig"] | null;
738
+ /** Knowledge Base Ids */
739
+ knowledge_base_ids?: string[] | null;
740
+ /** Last Modification Timestamp */
741
+ last_modification_timestamp?: number | null;
742
+ /** Mcps */
743
+ mcps?: unknown[] | null;
744
+ model_choice?: components["schemas"]["ModelChoice"] | null;
745
+ /** Model Temperature */
746
+ model_temperature?: number | null;
747
+ /** Nodes */
748
+ nodes?: (components["schemas"]["ConversationNode"] | components["schemas"]["SubagentNode"] | components["schemas"]["FunctionNode"] | components["schemas"]["McpNode"] | components["schemas"]["BranchNode"] | components["schemas"]["ExtractDynamicVariablesNode"] | components["schemas"]["TransferCallNode"] | components["schemas"]["PressDigitNode"] | components["schemas"]["AgentSwapNode"] | components["schemas"]["SmsNode"] | components["schemas"]["EndNode"] | components["schemas"]["OpaqueNode"])[];
749
+ /** Notes */
750
+ notes?: unknown[] | null;
751
+ /** Start Node Id */
752
+ start_node_id?: string | null;
753
+ /** Start Speaker */
754
+ start_speaker?: ("user" | "agent") | null;
755
+ /** Tool Call Strict Mode */
756
+ tool_call_strict_mode?: boolean | null;
757
+ /** Tools */
758
+ tools?: components["schemas"]["FlowTool"][] | null;
759
+ /** Version */
760
+ version?: number | null;
761
+ } & {
762
+ [key: string]: unknown;
763
+ };
764
+ /** FlowTool */
765
+ FlowTool: {
766
+ /** Description */
767
+ description?: string | null;
768
+ /** Method */
769
+ method?: string | null;
770
+ /** Name */
771
+ name?: string | null;
772
+ /** Parameters */
773
+ parameters?: {
774
+ [key: string]: unknown;
775
+ } | null;
776
+ /** Response Variables */
777
+ response_variables?: {
778
+ [key: string]: unknown;
779
+ } | null;
780
+ /** Speak After Execution */
781
+ speak_after_execution?: boolean | null;
782
+ /** Speak During Execution */
783
+ speak_during_execution?: boolean | null;
784
+ /** Timeout Ms */
785
+ timeout_ms?: number | null;
786
+ /** Tool Id */
787
+ tool_id: string;
788
+ /** Type */
789
+ type?: string | null;
790
+ /** Url */
791
+ url?: string | null;
792
+ } & {
793
+ [key: string]: unknown;
794
+ };
795
+ /** FunctionCreate */
796
+ FunctionCreate: {
797
+ /** Config */
798
+ config?: {
799
+ [key: string]: unknown;
800
+ };
801
+ /**
802
+ * Description
803
+ * @default
804
+ */
805
+ description?: string;
806
+ /** Headers */
807
+ headers?: components["schemas"]["KVPair"][];
808
+ /**
809
+ * Kind
810
+ * @default custom
811
+ * @enum {string}
812
+ */
813
+ kind?: "custom" | "end_call" | "transfer_call" | "press_digit" | "agent_swap" | "check_availability_cal" | "book_appointment_cal";
814
+ /**
815
+ * Method
816
+ * @default POST
817
+ */
818
+ method?: string;
819
+ /** Name */
820
+ name: string;
821
+ /** Parameters */
822
+ parameters?: {
823
+ [key: string]: unknown;
824
+ };
825
+ /** Query Params */
826
+ query_params?: components["schemas"]["KVPair"][];
827
+ /** Response Variables */
828
+ response_variables?: {
829
+ [key: string]: string;
830
+ };
831
+ /**
832
+ * Speak After Execution
833
+ * @default true
834
+ */
835
+ speak_after_execution?: boolean;
836
+ /** Speak During Execution */
837
+ speak_during_execution?: string | null;
838
+ /**
839
+ * Timeout Ms
840
+ * @default 10000
841
+ */
842
+ timeout_ms?: number;
843
+ /**
844
+ * Url
845
+ * @default
846
+ */
847
+ url?: string;
848
+ };
849
+ /** FunctionDef */
850
+ FunctionDef: {
851
+ /** Config */
852
+ config?: {
853
+ [key: string]: unknown;
854
+ };
855
+ /**
856
+ * Description
857
+ * @default
858
+ */
859
+ description?: string;
860
+ /** Headers */
861
+ headers?: components["schemas"]["KVPair"][];
862
+ /** Id */
863
+ id?: string | null;
864
+ /**
865
+ * Kind
866
+ * @default custom
867
+ * @enum {string}
868
+ */
869
+ kind?: "custom" | "check_availability_cal" | "book_appointment_cal" | "end_call" | "transfer_call" | "press_digit" | "agent_swap";
870
+ /**
871
+ * Method
872
+ * @default POST
873
+ */
874
+ method?: string;
875
+ /** Name */
876
+ name: string;
877
+ /** Parameters */
878
+ parameters?: {
879
+ [key: string]: unknown;
880
+ };
881
+ /** Query Params */
882
+ query_params?: components["schemas"]["KVPair"][];
883
+ /**
884
+ * Speak After Execution
885
+ * @default true
886
+ */
887
+ speak_after_execution?: boolean;
888
+ /** Speak During Execution */
889
+ speak_during_execution?: string | null;
890
+ /**
891
+ * Timeout Ms
892
+ * @default 10000
893
+ */
894
+ timeout_ms?: number;
895
+ /**
896
+ * Url
897
+ * @default
898
+ */
899
+ url?: string;
900
+ };
901
+ /** FunctionNode */
902
+ FunctionNode: {
903
+ display_position?: components["schemas"]["DisplayPosition"] | null;
904
+ /** Edges */
905
+ edges?: components["schemas"]["Edge"][];
906
+ else_edge?: components["schemas"]["Edge"] | null;
907
+ /** Enable Typing Sound */
908
+ enable_typing_sound?: boolean | null;
909
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
910
+ /** Id */
911
+ id: string;
912
+ instruction?: components["schemas"]["Instruction"] | null;
913
+ /** Name */
914
+ name?: string | null;
915
+ /** Speak During Execution */
916
+ speak_during_execution?: boolean | null;
917
+ /** Tool Id */
918
+ tool_id: string;
919
+ /** Tool Type */
920
+ tool_type?: ("local" | "shared") | null;
921
+ /**
922
+ * Type
923
+ * @constant
924
+ */
925
+ type: "function";
926
+ /** Wait For Result */
927
+ wait_for_result?: boolean | null;
928
+ } & {
929
+ [key: string]: unknown;
930
+ };
931
+ /** FunctionReorder */
932
+ FunctionReorder: {
933
+ /** Order */
934
+ order: string[];
935
+ };
936
+ /** FunctionUpdate */
937
+ FunctionUpdate: {
938
+ /** Config */
939
+ config?: {
940
+ [key: string]: unknown;
941
+ } | null;
942
+ /** Description */
943
+ description?: string | null;
944
+ /** Headers */
945
+ headers?: components["schemas"]["KVPair"][] | null;
946
+ /** Method */
947
+ method?: string | null;
948
+ /** Parameters */
949
+ parameters?: {
950
+ [key: string]: unknown;
951
+ } | null;
952
+ /** Query Params */
953
+ query_params?: components["schemas"]["KVPair"][] | null;
954
+ /** Response Variables */
955
+ response_variables?: {
956
+ [key: string]: string;
957
+ } | null;
958
+ /** Speak After Execution */
959
+ speak_after_execution?: boolean | null;
960
+ /** Speak During Execution */
961
+ speak_during_execution?: string | null;
962
+ /** Timeout Ms */
963
+ timeout_ms?: number | null;
964
+ /** Url */
965
+ url?: string | null;
966
+ };
967
+ /** GlobalNodeSetting */
968
+ GlobalNodeSetting: {
969
+ /** Condition */
970
+ condition: string;
971
+ /** Cool Down */
972
+ cool_down?: number | null;
973
+ /** Go Back Conditions */
974
+ go_back_conditions?: components["schemas"]["GoBackCondition"][] | null;
975
+ /** Negative Finetune Examples */
976
+ negative_finetune_examples?: unknown[] | null;
977
+ /** Positive Finetune Examples */
978
+ positive_finetune_examples?: unknown[] | null;
979
+ } & {
980
+ [key: string]: unknown;
981
+ };
982
+ /** GoBackCondition */
983
+ GoBackCondition: {
984
+ /** Id */
985
+ id?: string | null;
986
+ /** Transition Condition */
987
+ transition_condition?: components["schemas"]["PromptCondition"] | components["schemas"]["EquationCondition"] | null;
988
+ } & {
989
+ [key: string]: unknown;
990
+ };
991
+ /** HandoffOption */
992
+ HandoffOption: {
993
+ /** Message */
994
+ message?: string | null;
995
+ /** Prompt */
996
+ prompt?: string | null;
997
+ /** Type */
998
+ type?: string | null;
999
+ } & {
1000
+ [key: string]: unknown;
1001
+ };
1002
+ /** HTTPValidationError */
1003
+ HTTPValidationError: {
1004
+ /** Detail */
1005
+ detail?: components["schemas"]["ValidationError"][];
1006
+ };
1007
+ /** Instruction */
1008
+ Instruction: {
1009
+ /** Text */
1010
+ text: string;
1011
+ /**
1012
+ * Type
1013
+ * @enum {string}
1014
+ */
1015
+ type: "prompt" | "static_text";
1016
+ } & {
1017
+ [key: string]: unknown;
1018
+ };
1019
+ /** IvrOption */
1020
+ IvrOption: {
1021
+ /** Prompt */
1022
+ prompt?: string | null;
1023
+ /** Type */
1024
+ type?: string | null;
1025
+ } & {
1026
+ [key: string]: unknown;
1027
+ };
1028
+ /** KBConfig */
1029
+ KBConfig: {
1030
+ /** Filter Score */
1031
+ filter_score?: number | null;
1032
+ /** Top K */
1033
+ top_k?: number | null;
1034
+ } & {
1035
+ [key: string]: unknown;
1036
+ };
1037
+ /** KVPair */
1038
+ KVPair: {
1039
+ /** Key */
1040
+ key: string;
1041
+ /** Value */
1042
+ value: string;
1043
+ };
1044
+ /** McpNode */
1045
+ McpNode: {
1046
+ display_position?: components["schemas"]["DisplayPosition"] | null;
1047
+ /** Edges */
1048
+ edges?: components["schemas"]["Edge"][];
1049
+ else_edge?: components["schemas"]["Edge"] | null;
1050
+ /** Enable Typing Sound */
1051
+ enable_typing_sound?: boolean | null;
1052
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
1053
+ /** Id */
1054
+ id: string;
1055
+ instruction?: components["schemas"]["Instruction"] | null;
1056
+ /** Mcp Id */
1057
+ mcp_id: string;
1058
+ /** Mcp Tool Name */
1059
+ mcp_tool_name: string;
1060
+ /** Name */
1061
+ name?: string | null;
1062
+ /** Response Variables */
1063
+ response_variables?: {
1064
+ [key: string]: string;
1065
+ } | null;
1066
+ /** Speak During Execution */
1067
+ speak_during_execution?: boolean | null;
1068
+ /**
1069
+ * Type
1070
+ * @constant
1071
+ */
1072
+ type: "mcp";
1073
+ /** Wait For Result */
1074
+ wait_for_result?: boolean | null;
1075
+ } & {
1076
+ [key: string]: unknown;
1077
+ };
1078
+ /** MCPServerCreate */
1079
+ MCPServerCreate: {
1080
+ /** Auth Token */
1081
+ auth_token?: string | null;
1082
+ /**
1083
+ * Enabled
1084
+ * @default true
1085
+ */
1086
+ enabled?: boolean;
1087
+ /** Headers */
1088
+ headers?: components["schemas"]["KVPair"][];
1089
+ /** Name */
1090
+ name: string;
1091
+ /** Query Params */
1092
+ query_params?: components["schemas"]["KVPair"][];
1093
+ /**
1094
+ * Timeout Ms
1095
+ * @default 10000
1096
+ */
1097
+ timeout_ms?: number;
1098
+ /** Url */
1099
+ url: string;
1100
+ };
1101
+ /** MCPServerUpdate */
1102
+ MCPServerUpdate: {
1103
+ /** Auth Token */
1104
+ auth_token?: string | null;
1105
+ /** Enabled */
1106
+ enabled?: boolean | null;
1107
+ /** Headers */
1108
+ headers?: components["schemas"]["KVPair"][] | null;
1109
+ /** Query Params */
1110
+ query_params?: components["schemas"]["KVPair"][] | null;
1111
+ /** Timeout Ms */
1112
+ timeout_ms?: number | null;
1113
+ /** Url */
1114
+ url?: string | null;
1115
+ };
1116
+ /** ModelChoice */
1117
+ ModelChoice: {
1118
+ /** High Priority */
1119
+ high_priority?: boolean | null;
1120
+ /** Model */
1121
+ model?: string | null;
1122
+ /** Type */
1123
+ type?: string | null;
1124
+ } & {
1125
+ [key: string]: unknown;
1126
+ };
1127
+ /** NotRunnableEntry */
1128
+ NotRunnableEntry: {
1129
+ /**
1130
+ * Message
1131
+ * @default
1132
+ */
1133
+ message?: string;
1134
+ /** Node Ids */
1135
+ node_ids?: string[];
1136
+ /** Reason */
1137
+ reason: string;
1138
+ } & {
1139
+ [key: string]: unknown;
1140
+ };
1141
+ /** OpaqueNode */
1142
+ OpaqueNode: {
1143
+ display_position?: components["schemas"]["DisplayPosition"] | null;
1144
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
1145
+ /** Id */
1146
+ id: string;
1147
+ /** Name */
1148
+ name?: string | null;
1149
+ /** Type */
1150
+ type: string;
1151
+ } & {
1152
+ [key: string]: unknown;
1153
+ };
1154
+ /** OutboundCallRequest */
1155
+ OutboundCallRequest: {
1156
+ /** Agent Id */
1157
+ agent_id?: string | null;
1158
+ /** Dialgem Llm Dynamic Variables */
1159
+ dialgem_llm_dynamic_variables?: {
1160
+ [key: string]: unknown;
1161
+ } | null;
1162
+ /** From */
1163
+ from_: string;
1164
+ /** To */
1165
+ to: string;
1166
+ };
1167
+ /** PhoneNumberAssign */
1168
+ PhoneNumberAssign: {
1169
+ /** Agent Id */
1170
+ agent_id?: string | null;
1171
+ };
1172
+ /** PhoneNumberCreate */
1173
+ PhoneNumberCreate: {
1174
+ /**
1175
+ * Custom Sms Enabled
1176
+ * @default false
1177
+ */
1178
+ custom_sms_enabled?: boolean;
1179
+ /**
1180
+ * Flow Sms Sender Enabled
1181
+ * @default false
1182
+ */
1183
+ flow_sms_sender_enabled?: boolean;
1184
+ /** Inbound Agent Id */
1185
+ inbound_agent_id?: string | null;
1186
+ /** Nickname */
1187
+ nickname?: string | null;
1188
+ /** Number */
1189
+ number?: string | null;
1190
+ /** Outbound Agent Id */
1191
+ outbound_agent_id?: string | null;
1192
+ /** Phone Number */
1193
+ phone_number?: string | null;
1194
+ /**
1195
+ * Phone Number Type
1196
+ * @default custom
1197
+ */
1198
+ phone_number_type?: string;
1199
+ /**
1200
+ * Provider
1201
+ * @default twilio
1202
+ */
1203
+ provider?: string;
1204
+ /** Provider Sid */
1205
+ provider_sid?: string | null;
1206
+ sip_outbound_trunk_config?: components["schemas"]["SipOutboundTrunkConfigIn"] | null;
1207
+ };
1208
+ /** PhoneNumberUpdate */
1209
+ PhoneNumberUpdate: {
1210
+ /** Custom Sms Enabled */
1211
+ custom_sms_enabled?: boolean | null;
1212
+ /** Flow Sms Sender Enabled */
1213
+ flow_sms_sender_enabled?: boolean | null;
1214
+ /** Inbound Agent Id */
1215
+ inbound_agent_id?: string | null;
1216
+ /** Inbound Agents */
1217
+ inbound_agents?: components["schemas"]["AgentWeightIn"][] | null;
1218
+ /** Nickname */
1219
+ nickname?: string | null;
1220
+ /** Outbound Agent Id */
1221
+ outbound_agent_id?: string | null;
1222
+ /** Outbound Agents */
1223
+ outbound_agents?: components["schemas"]["AgentWeightIn"][] | null;
1224
+ /** Phone Number Type */
1225
+ phone_number_type?: string | null;
1226
+ /**
1227
+ * Set Inbound Agent
1228
+ * @default false
1229
+ */
1230
+ set_inbound_agent?: boolean;
1231
+ /**
1232
+ * Set Outbound Agent
1233
+ * @default false
1234
+ */
1235
+ set_outbound_agent?: boolean;
1236
+ sip_outbound_trunk_config?: components["schemas"]["SipOutboundTrunkConfigIn"] | null;
1237
+ };
1238
+ /** PostCallAnalysisVariable */
1239
+ PostCallAnalysisVariable: {
1240
+ /** Choices */
1241
+ choices?: string[] | null;
1242
+ /**
1243
+ * Description
1244
+ * @default
1245
+ */
1246
+ description?: string;
1247
+ /** Name */
1248
+ name: string;
1249
+ /**
1250
+ * Type
1251
+ * @enum {string}
1252
+ */
1253
+ type: "string" | "number" | "boolean" | "enum";
1254
+ };
1255
+ /** PressDigitNode */
1256
+ PressDigitNode: {
1257
+ /** Delay Ms */
1258
+ delay_ms?: number | null;
1259
+ display_position?: components["schemas"]["DisplayPosition"] | null;
1260
+ /** Edges */
1261
+ edges?: components["schemas"]["Edge"][];
1262
+ else_edge?: components["schemas"]["Edge"] | null;
1263
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
1264
+ /** Id */
1265
+ id: string;
1266
+ instruction: components["schemas"]["Instruction"];
1267
+ /** Name */
1268
+ name?: string | null;
1269
+ /**
1270
+ * Type
1271
+ * @constant
1272
+ */
1273
+ type: "press_digit";
1274
+ } & {
1275
+ [key: string]: unknown;
1276
+ };
1277
+ /** PromptCondition */
1278
+ PromptCondition: {
1279
+ /** Prompt */
1280
+ prompt: string;
1281
+ /**
1282
+ * Type
1283
+ * @constant
1284
+ */
1285
+ type: "prompt";
1286
+ } & {
1287
+ [key: string]: unknown;
1288
+ };
1289
+ /** PromptState */
1290
+ PromptState: {
1291
+ /** Edges */
1292
+ edges?: components["schemas"]["StateEdge"][];
1293
+ /** Name */
1294
+ name: string;
1295
+ /**
1296
+ * State Prompt
1297
+ * @default
1298
+ */
1299
+ state_prompt?: string;
1300
+ /** Tools */
1301
+ tools?: components["schemas"]["FunctionDef"][];
1302
+ } & {
1303
+ [key: string]: unknown;
1304
+ };
1305
+ /** PromptTemplateDetail */
1306
+ PromptTemplateDetail: {
1307
+ /**
1308
+ * Agent Type
1309
+ * @default llm
1310
+ */
1311
+ agent_type?: string;
1312
+ /** Base */
1313
+ base?: string | null;
1314
+ /** Category */
1315
+ category: string;
1316
+ /** Default Dynamic Variables */
1317
+ default_dynamic_variables?: {
1318
+ [key: string]: string;
1319
+ };
1320
+ /** Description */
1321
+ description: string;
1322
+ /** First Message */
1323
+ first_message: string;
1324
+ /** Icon */
1325
+ icon: string;
1326
+ /** Id */
1327
+ id: string;
1328
+ /** Name */
1329
+ name: string;
1330
+ /** Setup Note */
1331
+ setup_note: string;
1332
+ /** Source */
1333
+ source: string;
1334
+ /** System Prompt */
1335
+ system_prompt: string;
1336
+ /** System Prompt Chars */
1337
+ system_prompt_chars: number;
1338
+ /** Tags */
1339
+ tags: string[];
1340
+ /** Use Case */
1341
+ use_case: string;
1342
+ /** Variable Names */
1343
+ variable_names: string[];
1344
+ };
1345
+ /** PromptTemplateSummary */
1346
+ PromptTemplateSummary: {
1347
+ /**
1348
+ * Agent Type
1349
+ * @default llm
1350
+ */
1351
+ agent_type?: string;
1352
+ /** Base */
1353
+ base?: string | null;
1354
+ /** Category */
1355
+ category: string;
1356
+ /** Description */
1357
+ description: string;
1358
+ /** Icon */
1359
+ icon: string;
1360
+ /** Id */
1361
+ id: string;
1362
+ /** Name */
1363
+ name: string;
1364
+ /** Setup Note */
1365
+ setup_note: string;
1366
+ /** Source */
1367
+ source: string;
1368
+ /** System Prompt Chars */
1369
+ system_prompt_chars: number;
1370
+ /** Tags */
1371
+ tags: string[];
1372
+ /** Use Case */
1373
+ use_case: string;
1374
+ /** Variable Names */
1375
+ variable_names: string[];
1376
+ };
1377
+ /** RegisterCallRequest */
1378
+ RegisterCallRequest: {
1379
+ /** Agent Id */
1380
+ agent_id: string;
1381
+ /** Call Sid */
1382
+ call_sid?: string | null;
1383
+ /** Dialgem Llm Dynamic Variables */
1384
+ dialgem_llm_dynamic_variables?: {
1385
+ [key: string]: unknown;
1386
+ } | null;
1387
+ /**
1388
+ * Direction
1389
+ * @default inbound
1390
+ */
1391
+ direction?: string;
1392
+ /** From Number */
1393
+ from_number?: string | null;
1394
+ /** Metadata */
1395
+ metadata?: {
1396
+ [key: string]: unknown;
1397
+ } | null;
1398
+ /** To Number */
1399
+ to_number?: string | null;
1400
+ };
1401
+ /** RegisterCallResponse */
1402
+ RegisterCallResponse: {
1403
+ /** Call Id */
1404
+ call_id: string;
1405
+ /** Expires In */
1406
+ expires_in: number;
1407
+ /** Stream Url */
1408
+ stream_url: string;
1409
+ };
1410
+ /** SipOutboundTrunkConfigIn */
1411
+ SipOutboundTrunkConfigIn: {
1412
+ /** Auth Password */
1413
+ auth_password?: string | null;
1414
+ /** Auth Username */
1415
+ auth_username?: string | null;
1416
+ /** Termination Uri */
1417
+ termination_uri?: string | null;
1418
+ /** Transport */
1419
+ transport?: string | null;
1420
+ };
1421
+ /** SmsEdge */
1422
+ SmsEdge: {
1423
+ /** Destination Node Id */
1424
+ destination_node_id?: string | null;
1425
+ /** Id */
1426
+ id?: string | null;
1427
+ /** Transition Condition */
1428
+ transition_condition?: components["schemas"]["PromptCondition"] | components["schemas"]["EquationCondition"] | null;
1429
+ } & {
1430
+ [key: string]: unknown;
1431
+ };
1432
+ /** SmsInstruction */
1433
+ SmsInstruction: {
1434
+ /** Template */
1435
+ template?: string | null;
1436
+ /** Text */
1437
+ text?: string | null;
1438
+ /** Type */
1439
+ type?: string | null;
1440
+ } & {
1441
+ [key: string]: unknown;
1442
+ };
1443
+ /** SmsNode */
1444
+ SmsNode: {
1445
+ display_position?: components["schemas"]["DisplayPosition"] | null;
1446
+ failed_edge?: components["schemas"]["SmsEdge"] | null;
1447
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
1448
+ /** Id */
1449
+ id: string;
1450
+ instruction?: components["schemas"]["SmsInstruction"] | null;
1451
+ model_choice?: components["schemas"]["ModelChoice"] | null;
1452
+ /** Name */
1453
+ name?: string | null;
1454
+ success_edge?: components["schemas"]["SmsEdge"] | null;
1455
+ /**
1456
+ * Type
1457
+ * @constant
1458
+ */
1459
+ type: "sms";
1460
+ } & {
1461
+ [key: string]: unknown;
1462
+ };
1463
+ /** StateEdge */
1464
+ StateEdge: {
1465
+ /**
1466
+ * Description
1467
+ * @default
1468
+ */
1469
+ description?: string;
1470
+ /** Destination State Name */
1471
+ destination_state_name: string;
1472
+ /** Parameters */
1473
+ parameters?: {
1474
+ [key: string]: unknown;
1475
+ } | null;
1476
+ } & {
1477
+ [key: string]: unknown;
1478
+ };
1479
+ /** SubagentNode */
1480
+ SubagentNode: {
1481
+ always_edge?: components["schemas"]["Edge"] | null;
1482
+ display_position?: components["schemas"]["DisplayPosition"] | null;
1483
+ /** Edges */
1484
+ edges?: components["schemas"]["Edge"][];
1485
+ else_edge?: components["schemas"]["Edge"] | null;
1486
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
1487
+ /** Id */
1488
+ id: string;
1489
+ instruction: components["schemas"]["Instruction"];
1490
+ kb_config?: components["schemas"]["KBConfig"] | null;
1491
+ /** Knowledge Base Ids */
1492
+ knowledge_base_ids?: string[] | null;
1493
+ model_choice?: components["schemas"]["ModelChoice"] | null;
1494
+ /** Name */
1495
+ name?: string | null;
1496
+ skip_response_edge?: components["schemas"]["Edge"] | null;
1497
+ /** Tool Ids */
1498
+ tool_ids?: string[] | null;
1499
+ /** Tools */
1500
+ tools?: unknown[] | null;
1501
+ /**
1502
+ * Type
1503
+ * @constant
1504
+ */
1505
+ type: "subagent";
1506
+ } & {
1507
+ [key: string]: unknown;
1508
+ };
1509
+ /** TransferAgent */
1510
+ TransferAgent: {
1511
+ /** Agent Id */
1512
+ agent_id?: string | null;
1513
+ /** Agent Version */
1514
+ agent_version?: string | number | null;
1515
+ } & {
1516
+ [key: string]: unknown;
1517
+ };
1518
+ /** TransferCallNode */
1519
+ TransferCallNode: {
1520
+ /** Custom Sip Headers */
1521
+ custom_sip_headers?: {
1522
+ [key: string]: unknown;
1523
+ } | null;
1524
+ display_position?: components["schemas"]["DisplayPosition"] | null;
1525
+ edge?: components["schemas"]["Edge"] | null;
1526
+ global_node_setting?: components["schemas"]["GlobalNodeSetting"] | null;
1527
+ /** Id */
1528
+ id: string;
1529
+ /** Ignore E164 Validation */
1530
+ ignore_e164_validation?: boolean | null;
1531
+ instruction?: components["schemas"]["Instruction"] | null;
1532
+ /** Name */
1533
+ name?: string | null;
1534
+ /** Speak During Execution */
1535
+ speak_during_execution?: boolean | null;
1536
+ transfer_destination: components["schemas"]["TransferDestination"];
1537
+ transfer_option: components["schemas"]["TransferOption"];
1538
+ /**
1539
+ * Type
1540
+ * @constant
1541
+ */
1542
+ type: "transfer_call";
1543
+ } & {
1544
+ [key: string]: unknown;
1545
+ };
1546
+ /** TransferDestination */
1547
+ TransferDestination: {
1548
+ /** Extension */
1549
+ extension?: string | null;
1550
+ /** Number */
1551
+ number?: string | null;
1552
+ /** Prompt */
1553
+ prompt?: string | null;
1554
+ /** Type */
1555
+ type?: ("predefined" | "inferred") | null;
1556
+ } & {
1557
+ [key: string]: unknown;
1558
+ };
1559
+ /** TransferOption */
1560
+ TransferOption: {
1561
+ /** Agent Detection Timeout Ms */
1562
+ agent_detection_timeout_ms?: number | null;
1563
+ agentic_transfer_config?: components["schemas"]["AgenticTransferConfig"] | null;
1564
+ /** Cold Transfer Mode */
1565
+ cold_transfer_mode?: string | null;
1566
+ /** Custom On Hold Music Asset Id */
1567
+ custom_on_hold_music_asset_id?: string | null;
1568
+ /** Enable Bridge Audio Cue */
1569
+ enable_bridge_audio_cue?: boolean | null;
1570
+ ivr_option?: components["schemas"]["IvrOption"] | null;
1571
+ /** On Hold Music */
1572
+ on_hold_music?: string | null;
1573
+ /** Opt Out Human Detection */
1574
+ opt_out_human_detection?: boolean | null;
1575
+ private_handoff_option?: components["schemas"]["HandoffOption"] | null;
1576
+ public_handoff_option?: components["schemas"]["HandoffOption"] | null;
1577
+ /** Show Transferee As Caller */
1578
+ show_transferee_as_caller?: boolean | null;
1579
+ /** Transfer Ring Duration Ms */
1580
+ transfer_ring_duration_ms?: number | null;
1581
+ /** Type */
1582
+ type?: ("cold_transfer" | "warm_transfer" | "agentic_warm_transfer") | null;
1583
+ } & {
1584
+ [key: string]: unknown;
1585
+ };
1586
+ /** ValidationError */
1587
+ ValidationError: {
1588
+ /** Context */
1589
+ ctx?: Record<string, never>;
1590
+ /** Input */
1591
+ input?: unknown;
1592
+ /** Location */
1593
+ loc: (string | number)[];
1594
+ /** Message */
1595
+ msg: string;
1596
+ /** Error Type */
1597
+ type: string;
1598
+ };
1599
+ };
1600
+ responses: never;
1601
+ parameters: never;
1602
+ requestBodies: never;
1603
+ headers: never;
1604
+ pathItems: never;
1605
+ }
1606
+
1607
+ /**
1608
+ * Request-body types, aliased from the generated OpenAPI types so they track the
1609
+ * API's own schema exactly. Field names are the API's own
1610
+ * (snake_case); the SDK sends bodies as-is.
1611
+ */
1612
+
1613
+ type Schemas = components["schemas"];
1614
+ /**
1615
+ * Adds `| undefined` to the optional top-level fields of a request body, so
1616
+ * callers compiling with `exactOptionalPropertyTypes` can write
1617
+ * `{ agent_id: maybeId }`. An undefined field is dropped by `JSON.stringify`, which
1618
+ * is exactly "not sent". Required fields are left as they are.
1619
+ */
1620
+ type RequestBody<T> = {
1621
+ [K in keyof T]: {} extends Pick<T, K> ? T[K] | undefined : T[K];
1622
+ };
1623
+ type AgentCreateParams = RequestBody<Schemas["AgentCreate"]>;
1624
+ type AgentUpdateParams = RequestBody<Schemas["AgentUpdate"]>;
1625
+ type FunctionCreateParams = RequestBody<Schemas["FunctionCreate"]>;
1626
+ type FunctionUpdateParams = RequestBody<Schemas["FunctionUpdate"]>;
1627
+ type FunctionReorderParams = RequestBody<Schemas["FunctionReorder"]>;
1628
+ type KnowledgeDocumentCreateParams = RequestBody<Schemas["DocumentCreate"]>;
1629
+ type MCPServerCreateParams = RequestBody<Schemas["MCPServerCreate"]>;
1630
+ type MCPServerUpdateParams = RequestBody<Schemas["MCPServerUpdate"]>;
1631
+ type PhoneNumberCreateParams = RequestBody<Schemas["PhoneNumberCreate"]>;
1632
+ type PhoneNumberUpdateParams = RequestBody<Schemas["PhoneNumberUpdate"]>;
1633
+ type PhoneNumberAssignParams = RequestBody<Schemas["PhoneNumberAssign"]>;
1634
+ /**
1635
+ * `from_`, with the trailing underscore, is the wire name (`from` is a Python
1636
+ * keyword on the server). It must be a number registered on your organization.
1637
+ */
1638
+ type CallCreatePhoneCallParams = RequestBody<Schemas["OutboundCallRequest"]>;
1639
+ type CallRegisterParams = RequestBody<Schemas["RegisterCallRequest"]>;
1640
+ /** A conversation-flow definition (`agent_type: "flow"`). */
1641
+ type FlowConfig = Schemas["FlowConfig"];
1642
+ /** One state of a `multi_prompt` agent. */
1643
+ type PromptState = Schemas["PromptState"];
1644
+ /** A field extracted from the transcript after the call ends. */
1645
+ type PostCallAnalysisVariable = Schemas["PostCallAnalysisVariable"];
1646
+ type KeyValuePair = Schemas["KVPair"];
1647
+ type AgentWeight = Schemas["AgentWeightIn"];
1648
+ type AgentType = NonNullable<Schemas["AgentCreate"]["agent_type"]>;
1649
+ type WebhookEventType = NonNullable<Schemas["AgentCreate"]["webhook_events"]>[number];
1650
+ type FunctionKind = NonNullable<Schemas["FunctionCreate"]["kind"]>;
1651
+
1652
+ /**
1653
+ * An agent, as returned by `GET /v1/agents/{id}` and the create/update calls.
1654
+ * The shape is the same across all of those endpoints.
1655
+ */
1656
+ interface Agent {
1657
+ id: string;
1658
+ /** Same value as `id`. */
1659
+ agent_id: string;
1660
+ name: string;
1661
+ agent_type: AgentType;
1662
+ system_prompt: string;
1663
+ llm_provider: string;
1664
+ llm_model: string;
1665
+ tts_engine: string;
1666
+ voice_id: string;
1667
+ first_message: string | null;
1668
+ temperature: number;
1669
+ max_tokens: number;
1670
+ /** Set for `agent_type: "flow"`. */
1671
+ flow_config: FlowConfig | null;
1672
+ /** Set for `agent_type: "multi_prompt"`. */
1673
+ states: PromptState[];
1674
+ starting_state: string | null;
1675
+ /** Fallback values for `{{variables}}` not supplied by the call. */
1676
+ default_dynamic_variables: Record<string, string>;
1677
+ responsiveness: number;
1678
+ interruption_sensitivity: number;
1679
+ enable_backchannel: boolean;
1680
+ backchannel_frequency: number;
1681
+ reminder_trigger_ms: number;
1682
+ reminder_message: string;
1683
+ ambient_sound: NonNullable<AgentCreateParams["ambient_sound"]>;
1684
+ ambient_sound_volume: number;
1685
+ voice_speed: number;
1686
+ voice_temperature: number;
1687
+ stt_model: string;
1688
+ language: string;
1689
+ enable_transcription_formatting: boolean;
1690
+ boosted_keywords: string[];
1691
+ denoising_mode: NonNullable<AgentCreateParams["denoising_mode"]>;
1692
+ begin_message_delay_ms: number;
1693
+ end_call_after_silence_ms: number;
1694
+ max_call_duration_ms: number;
1695
+ ring_duration_ms: number;
1696
+ voicemail_detection_enabled: boolean;
1697
+ voicemail_action: NonNullable<AgentCreateParams["voicemail_action"]>;
1698
+ voicemail_message: string;
1699
+ post_call_analysis_data: PostCallAnalysisVariable[];
1700
+ post_call_analysis_model: string;
1701
+ fallback_llm_provider: string | null;
1702
+ fallback_llm_model: string | null;
1703
+ fallback_voice_id: string | null;
1704
+ pii_redaction_enabled: boolean;
1705
+ opt_out_call_recording: boolean;
1706
+ opt_out_transcript_storage: boolean;
1707
+ data_retention_days: number | null;
1708
+ webhook_url: string | null;
1709
+ webhook_events: WebhookEventType[];
1710
+ /**
1711
+ * Returned by `retrieve`, `create` and `update` only. **Always `null` in
1712
+ * `list()`**; use `has_webhook_signing_secret` there.
1713
+ */
1714
+ webhook_signing_secret: string | null;
1715
+ has_webhook_signing_secret: boolean;
1716
+ /** ISO 8601, no timezone suffix (UTC). */
1717
+ created_at: string | null;
1718
+ call_count: number;
1719
+ /**
1720
+ * Present only on `create` / `update` responses of a flow agent that saved with
1721
+ * warnings. Check it: an issue with `meta.not_runnable === true` means the agent
1722
+ * saved but cannot take calls; attaching it to a number or dialing with it is
1723
+ * refused with `err_code` `flow_not_runnable`.
1724
+ */
1725
+ flow_validation?: {
1726
+ issues: ErrorIssue[];
1727
+ };
1728
+ }
1729
+ interface AgentDeleteResponse {
1730
+ deleted: true;
1731
+ id: string;
1732
+ }
1733
+
1734
+ /** A tool the agent can call, as returned by `/v1/agents/{id}/functions`. */
1735
+ interface AgentFunction {
1736
+ id: string;
1737
+ agent_id: string;
1738
+ name: string;
1739
+ description: string;
1740
+ /** JSON Schema for the arguments the LLM supplies. */
1741
+ parameters: Record<string, unknown>;
1742
+ url: string;
1743
+ method: string;
1744
+ timeout_ms: number;
1745
+ headers: KeyValuePair[];
1746
+ query_params: KeyValuePair[];
1747
+ speak_during_execution: string | null;
1748
+ speak_after_execution: boolean;
1749
+ sort_order: number;
1750
+ kind: FunctionKind;
1751
+ /** Kind-specific settings (e.g. Cal.com credentials for the `*_cal` kinds). */
1752
+ config: Record<string, unknown>;
1753
+ /** Maps dynamic-variable names to JSON paths in the function's response. */
1754
+ response_variables: Record<string, string>;
1755
+ created_at: string | null;
1756
+ }
1757
+ /** A text document in the agent's knowledge base, summarised across its chunks. */
1758
+ interface KnowledgeDocument {
1759
+ source_id: string;
1760
+ filename: string;
1761
+ chunk_count: number;
1762
+ /**
1763
+ * From `list()`: false if **any** chunk failed to embed (those chunks are not
1764
+ * retrievable). From `create()`: true if **at least one** chunk embedded, so a
1765
+ * partial failure still reads true there; re-check with `list()`.
1766
+ */
1767
+ embedded: boolean;
1768
+ /** Present on `list()`; absent from the `create()` response. */
1769
+ created_at?: string | null;
1770
+ }
1771
+ /** A remote MCP tool server attached to an agent. The `auth_token` is write-only. */
1772
+ interface MCPServer {
1773
+ id: string;
1774
+ agent_id: string;
1775
+ name: string;
1776
+ url: string;
1777
+ has_auth_token: boolean;
1778
+ enabled: boolean;
1779
+ timeout_ms: number;
1780
+ headers: KeyValuePair[];
1781
+ query_params: KeyValuePair[];
1782
+ last_status: MCPServerTestResult | null;
1783
+ created_at: string | null;
1784
+ }
1785
+ interface MCPServerTestResult {
1786
+ ok: boolean;
1787
+ /** Tool names the server advertised. */
1788
+ tools: string[];
1789
+ error: string | null;
1790
+ /** ISO 8601. */
1791
+ at: string;
1792
+ }
1793
+
1794
+ declare abstract class APIResource {
1795
+ protected readonly _client: HttpClient;
1796
+ constructor(client: HttpClient);
1797
+ }
1798
+
1799
+ declare class Agents extends APIResource {
1800
+ /** Tools (HTTP functions and built-ins like `end_call`) the agent can call. */
1801
+ readonly functions: AgentFunctions;
1802
+ /** Text documents the agent retrieves from during the call. */
1803
+ readonly knowledge: AgentKnowledge;
1804
+ /** Remote MCP servers whose tools are exposed to the agent. */
1805
+ readonly mcpServers: AgentMCPServers;
1806
+ constructor(client: HttpClient);
1807
+ /** Create an agent. Only `name` is required; everything else has a server default. */
1808
+ create(body: AgentCreateParams, options?: RequestOptions): Promise<Agent>;
1809
+ retrieve(agentId: string, options?: RequestOptions): Promise<Agent>;
1810
+ /** Every agent in the organization. `webhook_signing_secret` is `null` in this list. */
1811
+ list(options?: RequestOptions): Promise<Agent[]>;
1812
+ /** Partial update: only the fields you send change. */
1813
+ update(agentId: string, body: AgentUpdateParams, options?: RequestOptions): Promise<Agent>;
1814
+ delete(agentId: string, options?: RequestOptions): Promise<AgentDeleteResponse>;
1815
+ }
1816
+ declare class AgentFunctions extends APIResource {
1817
+ list(agentId: string, options?: RequestOptions): Promise<AgentFunction[]>;
1818
+ create(agentId: string, body: FunctionCreateParams, options?: RequestOptions): Promise<AgentFunction>;
1819
+ update(agentId: string, functionId: string, body: FunctionUpdateParams, options?: RequestOptions): Promise<AgentFunction>;
1820
+ delete(agentId: string, functionId: string, options?: RequestOptions): Promise<void>;
1821
+ /** Set the order functions are offered to the LLM. `order` is function ids, first to last. */
1822
+ reorder(agentId: string, body: FunctionReorderParams, options?: RequestOptions): Promise<void>;
1823
+ }
1824
+ declare class AgentKnowledge extends APIResource {
1825
+ list(agentId: string, options?: RequestOptions): Promise<KnowledgeDocument[]>;
1826
+ /** Add a plain-text document (up to 500,000 characters). It is chunked and embedded server-side. */
1827
+ create(agentId: string, body: KnowledgeDocumentCreateParams, options?: RequestOptions): Promise<KnowledgeDocument>;
1828
+ delete(agentId: string, sourceId: string, options?: RequestOptions): Promise<void>;
1829
+ }
1830
+ declare class AgentMCPServers extends APIResource {
1831
+ list(agentId: string, options?: RequestOptions): Promise<MCPServer[]>;
1832
+ create(agentId: string, body: MCPServerCreateParams, options?: RequestOptions): Promise<MCPServer>;
1833
+ update(agentId: string, serverId: string, body: MCPServerUpdateParams, options?: RequestOptions): Promise<MCPServer>;
1834
+ delete(agentId: string, serverId: string, options?: RequestOptions): Promise<void>;
1835
+ /** Connect to the server now, list its tools, and store the result as `last_status`. */
1836
+ test(agentId: string, serverId: string, options?: RequestOptions): Promise<MCPServerTestResult>;
1837
+ }
1838
+
1839
+ interface PageFetcher<T> {
1840
+ (page: number): Promise<PageData<T>>;
1841
+ }
1842
+ interface PageData<T> {
1843
+ data: T[];
1844
+ total: number;
1845
+ page: number;
1846
+ page_size: number;
1847
+ }
1848
+ declare class Page<T> implements PageData<T> {
1849
+ #private;
1850
+ readonly data: T[];
1851
+ readonly total: number;
1852
+ readonly page: number;
1853
+ readonly page_size: number;
1854
+ constructor(data: PageData<T>, fetchPage: PageFetcher<T>);
1855
+ hasNextPage(): boolean;
1856
+ getNextPage(): Promise<Page<T>>;
1857
+ }
1858
+ declare class PagePromise<T> implements PromiseLike<Page<T>>, AsyncIterable<T> {
1859
+ #private;
1860
+ constructor(fetchPage: PageFetcher<T>, startPage: number);
1861
+ then<R1 = Page<T>, R2 = never>(onfulfilled?: ((value: Page<T>) => R1 | PromiseLike<R1>) | null, onrejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null): Promise<R1 | R2>;
1862
+ catch<R = never>(onrejected?: ((reason: unknown) => R | PromiseLike<R>) | null): Promise<Page<T> | R>;
1863
+ finally(onfinally?: (() => void) | null): Promise<Page<T>>;
1864
+ [Symbol.asyncIterator](): AsyncIterator<T>;
1865
+ }
1866
+
1867
+ /**
1868
+ * A call, as returned by `GET /v1/calls` and `GET /v1/calls/{id}`.
1869
+ * The shape is the same for both endpoints.
1870
+ */
1871
+ interface Call {
1872
+ id: string;
1873
+ /** Empty string when the call has no agent. */
1874
+ agent_id: string;
1875
+ agent_name: string;
1876
+ /** Dialgem's lifecycle state. */
1877
+ status: CallStatus;
1878
+ /** The same state in session vocabulary: active→ongoing, completed→ended, failed→error, queued→registered. */
1879
+ call_status: CallSessionStatus;
1880
+ duration_s: number;
1881
+ /**
1882
+ * Empty when the agent opts out of transcript storage, and once the agent's
1883
+ * `data_retention_days` purge has run. PII-redacted when redaction is on.
1884
+ */
1885
+ transcript: TranscriptTurn[];
1886
+ /** ISO 8601, no timezone suffix (UTC). Empty string if unknown. */
1887
+ started_at: string;
1888
+ phone_number: string;
1889
+ direction: "inbound" | "outbound" | (string & {});
1890
+ call_type: "phone_call" | "web_call" | (string & {});
1891
+ /** Carrier call id (Twilio CallSid). Empty string if none. */
1892
+ call_sid: string;
1893
+ from_number: string;
1894
+ to_number: string;
1895
+ origination_state: string | null;
1896
+ /** Presigned URL that expires; download it promptly rather than storing the link. */
1897
+ recording_url: string | null;
1898
+ amd_result: Record<string, unknown> | null;
1899
+ events: Record<string, unknown>[];
1900
+ /** Post-call extraction. `null` until the call has ended and been analyzed, and after a retention purge. */
1901
+ analysis: CallAnalysis | null;
1902
+ disconnection_reason: string | null;
1903
+ /** Set once the call is finalized. */
1904
+ call_cost: CallCost | null;
1905
+ /** Mean time from the caller's final transcript to the agent's first audio byte. */
1906
+ end_to_end_latency_ms: number | null;
1907
+ }
1908
+ /** Every amount is an integer in units of **$0.0001**: `combined_cost: 1700` is $0.17. */
1909
+ interface CallCost {
1910
+ combined_cost: number;
1911
+ total_duration_seconds: number;
1912
+ total_duration_unit_price: number;
1913
+ product_costs: {
1914
+ product: string;
1915
+ unit_price: number;
1916
+ cost: number;
1917
+ }[];
1918
+ }
1919
+ type CallStatus = "active" | "queued" | "completed" | "failed" | (string & {});
1920
+ type CallSessionStatus = "ongoing" | "registered" | "ended" | "error" | (string & {});
1921
+ interface TranscriptTurn {
1922
+ role: "user" | "agent";
1923
+ text: string;
1924
+ /** ISO 8601. */
1925
+ timestamp: string;
1926
+ }
1927
+ interface CallAnalysis {
1928
+ /** Values for the agent's `post_call_analysis_data` fields, keyed by name. */
1929
+ variables: Record<string, unknown>;
1930
+ model: string;
1931
+ extracted_at: string;
1932
+ user_sentiment: "Positive" | "Neutral" | "Negative" | (string & {}) | null;
1933
+ call_successful: boolean | null;
1934
+ /** Set when extraction failed; `variables` may then be partial or empty. */
1935
+ error: string | null;
1936
+ }
1937
+ interface CallListParams {
1938
+ /** Case-insensitive match on the agent's name. */
1939
+ search?: string | undefined;
1940
+ status?: CallStatus | "all" | undefined;
1941
+ /** 1-based. Default 1. */
1942
+ page?: number | undefined;
1943
+ /** 1–100. Default 10. */
1944
+ page_size?: number | undefined;
1945
+ }
1946
+ /** Result of `calls.createPhoneCall`. The call is dialing; its outcome arrives via webhooks or `calls.retrieve`. */
1947
+ interface PhoneCallCreateResponse {
1948
+ call_id: string;
1949
+ call_sid: string;
1950
+ origination_state: "queued" | (string & {});
1951
+ }
1952
+ /** Result of `calls.register`: return TwiML `<Connect><Stream url="{stream_url}"/></Connect>` to Twilio. */
1953
+ interface CallRegisterResponse {
1954
+ call_id: string;
1955
+ /** Signed `wss://` Twilio Media Streams URL. Hand it to Twilio before `expires_in` elapses. */
1956
+ stream_url: string;
1957
+ /** Seconds until `stream_url`'s signature expires. */
1958
+ expires_in: number;
1959
+ }
1960
+
1961
+ declare class Calls extends APIResource {
1962
+ /**
1963
+ * Calls, newest first. Await for one page, or iterate for every call:
1964
+ *
1965
+ * const page = await dialgem.calls.list({ page_size: 50 })
1966
+ * for await (const call of dialgem.calls.list({ status: "completed" })) {
1967
+ * if (call.started_at < cutoff) break // newest first: everything after is older
1968
+ * }
1969
+ */
1970
+ list(params?: CallListParams, options?: RequestOptions): PagePromise<Call>;
1971
+ /** One call, including its transcript, analysis and recording URL. */
1972
+ retrieve(callId: string, options?: RequestOptions): Promise<Call>;
1973
+ /**
1974
+ * Dial `to` from one of your organization's numbers, with `agent_id` (or the
1975
+ * number's outbound agent) on the line.
1976
+ *
1977
+ * Not retried by default: a retry after an ambiguous failure can place a
1978
+ * second call. Follow progress through webhooks or `retrieve(call_id)`.
1979
+ */
1980
+ createPhoneCall(body: CallCreatePhoneCallParams, options?: RequestOptions): Promise<PhoneCallCreateResponse>;
1981
+ /**
1982
+ * Bring-your-own-Twilio: call this from your Twilio voice webhook, then answer
1983
+ * Twilio with `<Response><Connect><Stream url="{stream_url}"/></Connect></Response>`.
1984
+ * No Twilio credentials are shared with Dialgem.
1985
+ */
1986
+ register(body: CallRegisterParams, options?: RequestOptions): Promise<CallRegisterResponse>;
1987
+ }
1988
+
1989
+ /** A TTS voice, as returned by `/v1/voices`. */
1990
+ interface Voice {
1991
+ /** Dialgem id. */
1992
+ id: string;
1993
+ provider: string;
1994
+ /** The id to put in an agent's `voice_id`. */
1995
+ provider_voice_id: string;
1996
+ name: string;
1997
+ gender: string | null;
1998
+ accent: string | null;
1999
+ age: string | null;
2000
+ voice_type: string | null;
2001
+ language: string[];
2002
+ preview_url: string | null;
2003
+ raw_metadata: Record<string, unknown> | null;
2004
+ created_at: string | null;
2005
+ updated_at: string | null;
2006
+ }
2007
+ interface VoiceListParams {
2008
+ provider?: string | undefined;
2009
+ gender?: string | undefined;
2010
+ accent?: string | undefined;
2011
+ /** Language code the voice supports, e.g. `en`. */
2012
+ language?: string | undefined;
2013
+ /** Case-insensitive substring match on the name. */
2014
+ search?: string | undefined;
2015
+ }
2016
+ interface TemplateListParams {
2017
+ category?: string | undefined;
2018
+ }
2019
+ type PromptTemplateSummary = components["schemas"]["PromptTemplateSummary"];
2020
+ /** Seed an agent from it: `agents.create({ name, system_prompt, first_message, default_dynamic_variables })`. */
2021
+ type PromptTemplate = components["schemas"]["PromptTemplateDetail"];
2022
+ /** A built-in flow template, as listed by `/v1/flow-templates`. */
2023
+ interface FlowTemplateSummary {
2024
+ id: string;
2025
+ name: string;
2026
+ description: string;
2027
+ setup_note: string;
2028
+ category: string;
2029
+ tags: string[];
2030
+ use_case: string;
2031
+ icon: string;
2032
+ source: string;
2033
+ node_count: number;
2034
+ node_types: string[];
2035
+ unsupported_node_types: string[];
2036
+ path_counts: Record<string, number>;
2037
+ runnable: boolean;
2038
+ }
2039
+ /** Seed a flow agent from it: `agents.create({ name, agent_type: "flow", flow_config })`. */
2040
+ interface FlowTemplate extends FlowTemplateSummary {
2041
+ unsupported_nodes: {
2042
+ node_id: string;
2043
+ name: string | null;
2044
+ type: string;
2045
+ support: string;
2046
+ }[];
2047
+ not_runnable_reasons: {
2048
+ reason: string;
2049
+ node_ids: string[];
2050
+ message: string;
2051
+ }[];
2052
+ flow_config: FlowConfig;
2053
+ }
2054
+
2055
+ declare class Voices extends APIResource {
2056
+ /** Voices available to agents, by name. Put a voice's `provider_voice_id` in an agent's `voice_id`. */
2057
+ list(params?: VoiceListParams, options?: RequestOptions): Promise<Voice[]>;
2058
+ }
2059
+ declare class FlowTemplates extends APIResource {
2060
+ /** Built-in conversation-flow templates (summaries, without `flow_config`). */
2061
+ list(params?: TemplateListParams, options?: RequestOptions): Promise<FlowTemplateSummary[]>;
2062
+ retrieve(templateId: string, options?: RequestOptions): Promise<FlowTemplate>;
2063
+ }
2064
+ declare class PromptTemplates extends APIResource {
2065
+ /** Built-in prompt templates (summaries, without the prompt text). */
2066
+ list(params?: TemplateListParams, options?: RequestOptions): Promise<PromptTemplateSummary[]>;
2067
+ retrieve(templateId: string, options?: RequestOptions): Promise<PromptTemplate>;
2068
+ }
2069
+
2070
+ /**
2071
+ * A phone number, as returned by `/v1/phone-numbers`.
2072
+ * The shape is the same across all phone-number endpoints.
2073
+ */
2074
+ interface PhoneNumber {
2075
+ /** Dialgem id. Use this (not the E.164 number) for update/assign/delete. */
2076
+ id: string;
2077
+ status: string;
2078
+ provider: string;
2079
+ /** E.164, e.g. `+14155550123`. */
2080
+ phone_number: string;
2081
+ phone_number_pretty: string;
2082
+ phone_number_type: string;
2083
+ nickname: string;
2084
+ inbound_agent_id: string | null;
2085
+ inbound_agent_version: number;
2086
+ outbound_agent_id: string | null;
2087
+ outbound_agent_version: number;
2088
+ /** Weighted inbound routing. `inbound_agent_id` is its primary entry. */
2089
+ inbound_agents: PhoneNumberAgentWeight[];
2090
+ outbound_agents: PhoneNumberAgentWeight[];
2091
+ custom_sms_enabled: boolean;
2092
+ flow_sms_sender_enabled: boolean;
2093
+ /** Epoch milliseconds (0 if unknown). */
2094
+ creation_timestamp: number;
2095
+ /** Epoch milliseconds (0 if unknown). */
2096
+ last_modification_timestamp: number;
2097
+ sip_outbound_trunk_config: SipOutboundTrunkConfig | null;
2098
+ }
2099
+ interface PhoneNumberAgentWeight {
2100
+ agent_id: string;
2101
+ agent_version: number;
2102
+ weight: number;
2103
+ }
2104
+ interface SipOutboundTrunkConfig {
2105
+ termination_uri?: string | null;
2106
+ transport?: string | null;
2107
+ auth_username?: string | null;
2108
+ [key: string]: unknown;
2109
+ }
2110
+
2111
+ declare class PhoneNumbers extends APIResource {
2112
+ /** Register a number you own (`phone_number` in E.164) with Dialgem. */
2113
+ create(body: PhoneNumberCreateParams, options?: RequestOptions): Promise<PhoneNumber>;
2114
+ /** Every active (not released) number in the organization, newest first. */
2115
+ list(options?: RequestOptions): Promise<PhoneNumber[]>;
2116
+ /**
2117
+ * Partial update.
2118
+ *
2119
+ * `inbound_agent_id` is **ignored unless `set_inbound_agent: true`** is sent with
2120
+ * it, both to set an agent and to clear one (`null`). Same for the outbound pair.
2121
+ * `inbound_agents` / `outbound_agents` (weighted routing), when sent, take
2122
+ * precedence over the single-agent fields.
2123
+ */
2124
+ update(phoneNumberId: string, body: PhoneNumberUpdateParams, options?: RequestOptions): Promise<PhoneNumber>;
2125
+ /** Set the number's **inbound** agent, or pass `agent_id: null` to clear it. For outbound, use `update`. */
2126
+ assign(phoneNumberId: string, body: PhoneNumberAssignParams, options?: RequestOptions): Promise<PhoneNumber>;
2127
+ /** Release the number from Dialgem. It stops routing calls and disappears from `list()`; your carrier account is untouched. */
2128
+ delete(phoneNumberId: string, options?: RequestOptions): Promise<void>;
2129
+ }
2130
+
2131
+ /**
2132
+ * Payloads Dialgem POSTs to an agent's `webhook_url`, subscribed per agent via
2133
+ * `webhook_events`. Flat objects with an `event` discriminator; see
2134
+ * the "Verify webhooks" section of the README.
2135
+ *
2136
+ * Delivery is at-least-once in practice: a failed POST is retried once after a
2137
+ * second, so a slow 2xx can arrive twice. Make handlers idempotent on
2138
+ * `(event, call_id)`.
2139
+ */
2140
+ type WebhookEvent = CallStartedEvent | CallEndedEvent | CallAnalyzedEvent;
2141
+ interface CallStartedEvent {
2142
+ event: "call_started";
2143
+ call_id: string;
2144
+ agent_id: string;
2145
+ }
2146
+ interface CallEndedEvent {
2147
+ event: "call_ended";
2148
+ call_id: string;
2149
+ agent_id: string;
2150
+ status: CallStatus;
2151
+ duration_s: number | null;
2152
+ }
2153
+ /** Sent before `call_ended`, and only for calls that produced a transcript. */
2154
+ interface CallAnalyzedEvent {
2155
+ event: "call_analyzed";
2156
+ call_id: string;
2157
+ agent_id: string;
2158
+ analysis: CallAnalysis;
2159
+ }
2160
+
2161
+ /** Header carrying the hex HMAC-SHA256 of the raw request body. */
2162
+ declare const WEBHOOK_SIGNATURE_HEADER = "x-dialgem-signature";
2163
+ /** Header naming the event; the same value as the body's `event`. */
2164
+ declare const WEBHOOK_EVENT_HEADER = "x-dialgem-event";
2165
+ /** The raw request body, byte-for-byte as received. Node `Buffer` is a `Uint8Array`. */
2166
+ type WebhookPayload = string | Uint8Array | ArrayBuffer;
2167
+ /** A header value as Node's `IncomingHttpHeaders`, `Headers.get()` or a framework hands it over. */
2168
+ type SignatureHeader = string | string[] | null | undefined;
2169
+ /**
2170
+ * Verifies and parses Dialgem webhooks.
2171
+ *
2172
+ * **Pass the raw body.** The signature covers the exact bytes Dialgem sent. A body
2173
+ * that was parsed and re-serialized (`express.json()`, `JSON.stringify(req.body)`)
2174
+ * will not match, even when the JSON is equal. Use `express.raw({ type: "application/json" })`,
2175
+ * Fastify's raw body, or `await request.text()` in a route handler.
2176
+ */
2177
+ declare class Webhooks {
2178
+ /**
2179
+ * Returns whether `signature` is the HMAC-SHA256 of `payload` under `secret`.
2180
+ * Constant-time. Returns `false` for a missing or malformed signature; throws only
2181
+ * if `secret` is empty, which is a configuration error rather than a bad request.
2182
+ */
2183
+ verify(payload: WebhookPayload, signature: SignatureHeader, secret: string): Promise<boolean>;
2184
+ /**
2185
+ * Verifies the signature, then parses the body.
2186
+ *
2187
+ * @throws WebhookVerificationError if the signature is missing or does not match.
2188
+ */
2189
+ constructEvent(payload: WebhookPayload, signature: SignatureHeader, secret: string): Promise<WebhookEvent>;
2190
+ }
2191
+ declare const webhooks: Webhooks;
2192
+
2193
+ declare const DEFAULT_BASE_URL = "https://api.dialgem.com";
2194
+ interface ClientOptions {
2195
+ /** Organization API key (`zk_…`). Defaults to `process.env.DIALGEM_API_KEY`. */
2196
+ apiKey?: string | undefined;
2197
+ /** Defaults to `process.env.DIALGEM_BASE_URL`, then `https://api.dialgem.com`. */
2198
+ baseURL?: string | undefined;
2199
+ /** Per-attempt timeout in milliseconds (> 0). Default 60000. */
2200
+ timeout?: number | undefined;
2201
+ /** Retries for GET/PATCH/DELETE on 408/429/5xx and connection errors. Default 2. POST is not retried. */
2202
+ maxRetries?: number | undefined;
2203
+ /** Custom fetch implementation (a proxy agent, instrumentation, tests). Defaults to the global `fetch`. */
2204
+ fetch?: Fetch | undefined;
2205
+ /** Headers sent with every request. */
2206
+ defaultHeaders?: Record<string, string> | undefined;
2207
+ /**
2208
+ * The API key grants full access to your organization, so constructing the
2209
+ * client in a browser throws by default. Only set this for a trusted internal tool.
2210
+ */
2211
+ dangerouslyAllowBrowser?: boolean | undefined;
2212
+ }
2213
+ /**
2214
+ * Dialgem API client, for use from your backend.
2215
+ *
2216
+ * ```ts
2217
+ * import { Dialgem } from "@dialgem/sdk"
2218
+ *
2219
+ * const dialgem = new Dialgem() // reads DIALGEM_API_KEY
2220
+ * const agent = await dialgem.agents.create({ name: "Front desk", system_prompt: "…" })
2221
+ * ```
2222
+ */
2223
+ declare class Dialgem {
2224
+ static readonly DEFAULT_BASE_URL = "https://api.dialgem.com";
2225
+ /** Webhook verification without a client instance: `Dialgem.webhooks.constructEvent(...)`. */
2226
+ static readonly webhooks: Webhooks;
2227
+ readonly agents: Agents;
2228
+ readonly calls: Calls;
2229
+ readonly phoneNumbers: PhoneNumbers;
2230
+ readonly voices: Voices;
2231
+ readonly flowTemplates: FlowTemplates;
2232
+ readonly promptTemplates: PromptTemplates;
2233
+ readonly webhooks: Webhooks;
2234
+ readonly baseURL: string;
2235
+ constructor(options?: ClientOptions);
2236
+ }
2237
+
2238
+ declare const VERSION = "0.1.0-beta.0";
2239
+
2240
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, APIUserAbortError, type Agent, type AgentCreateParams, type AgentDeleteResponse, type AgentFunction, AgentFunctions, AgentKnowledge, AgentMCPServers, type AgentType, type AgentUpdateParams, type AgentWeight, Agents, AuthenticationError, BadRequestError, type Call, type CallAnalysis, type CallAnalyzedEvent, type CallCost, type CallCreatePhoneCallParams, type CallEndedEvent, type CallListParams, type CallRegisterParams, type CallRegisterResponse, type CallSessionStatus, type CallStartedEvent, type CallStatus, Calls, type ClientOptions, ConflictError, DEFAULT_BASE_URL, Dialgem, DialgemError, type ErrorBody, type ErrorIssue, type Fetch, type FetchInit, type FetchResponse, type FlowConfig, type FlowTemplate, type FlowTemplateSummary, FlowTemplates, type FunctionCreateParams, type FunctionKind, type FunctionReorderParams, type FunctionUpdateParams, type HeadersLike, InternalServerError, type KeyValuePair, type KnowledgeDocument, type KnowledgeDocumentCreateParams, type MCPServer, type MCPServerCreateParams, type MCPServerTestResult, type MCPServerUpdateParams, NotFoundError, Page, type PageData, PagePromise, PermissionDeniedError, type PhoneCallCreateResponse, type PhoneNumber, type PhoneNumberAgentWeight, type PhoneNumberAssignParams, type PhoneNumberCreateParams, type PhoneNumberUpdateParams, PhoneNumbers, type PostCallAnalysisVariable, type PromptState, type PromptTemplate, type PromptTemplateSummary, PromptTemplates, RateLimitError, type RequestBody, type RequestOptions, type SignatureHeader, type SipOutboundTrunkConfig, type TemplateListParams, type TranscriptTurn, UnprocessableEntityError, VERSION, type Voice, type VoiceListParams, Voices, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, type WebhookEvent, type WebhookEventType, type WebhookPayload, WebhookVerificationError, Webhooks, webhooks };