@dialgem/sdk 0.1.0-beta.0 → 0.1.0-beta.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
@@ -110,7 +110,12 @@ type Fetch = (url: string, init: FetchInit) => Promise<FetchResponse>;
110
110
  interface FetchInit {
111
111
  method: string;
112
112
  headers: Record<string, string>;
113
- body?: string;
113
+ /**
114
+ * A JSON string, or a `FormData` for a file upload — in which case
115
+ * `Content-Type` is deliberately absent, since only `fetch` knows the
116
+ * multipart boundary it is about to generate.
117
+ */
118
+ body?: string | FormData;
114
119
  signal: AbortSignal;
115
120
  /**
116
121
  * Always `"manual"`. A followed redirect re-sends the API key to wherever the
@@ -143,7 +148,9 @@ interface RequestOptions {
143
148
  /** Extra headers for this request only. */
144
149
  headers?: Record<string, string> | undefined;
145
150
  }
146
- type QueryValue = string | number | boolean | null | undefined;
151
+ type QueryScalar = string | number | boolean;
152
+ /** Arrays are sent as repeated parameters: `{ status: ["a", "b"] }` → `?status=a&status=b`. */
153
+ type QueryValue = QueryScalar | QueryScalar[] | null | undefined;
147
154
  type Query = Record<string, QueryValue>;
148
155
  interface HttpClientOptions {
149
156
  apiKey: string;
@@ -160,6 +167,14 @@ declare class HttpClient {
160
167
  constructor(options: HttpClientOptions);
161
168
  get<T>(path: string, query?: Query, options?: RequestOptions): Promise<T>;
162
169
  post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
170
+ /**
171
+ * POST a `FormData` body — file uploads.
172
+ *
173
+ * The body is sent as-is and `Content-Type` is left unset, because only
174
+ * `fetch` knows the multipart boundary it is about to generate. Setting the
175
+ * header ourselves produces a request no server can parse.
176
+ */
177
+ postForm<T>(path: string, form: FormData, options?: RequestOptions): Promise<T>;
163
178
  patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
164
179
  delete<T>(path: string, options?: RequestOptions): Promise<T>;
165
180
  request<T>(method: Method, path: string, { query, body, options }: {
@@ -181,6 +196,11 @@ interface components {
181
196
  * @enum {string}
182
197
  */
183
198
  agent_type?: "llm" | "multi_prompt" | "flow";
199
+ /**
200
+ * Allow User Dtmf
201
+ * @default false
202
+ */
203
+ allow_user_dtmf?: boolean;
184
204
  /**
185
205
  * Ambient Sound
186
206
  * @default none
@@ -206,6 +226,12 @@ interface components {
206
226
  boosted_keywords?: string[];
207
227
  /** Data Retention Days */
208
228
  data_retention_days?: number | null;
229
+ /**
230
+ * Data Storage Setting
231
+ * @default everything
232
+ * @enum {string}
233
+ */
234
+ data_storage_setting?: "everything" | "everything_except_pii" | "basic_attributes_only";
209
235
  /** Default Dynamic Variables */
210
236
  default_dynamic_variables?: {
211
237
  [key: string]: string;
@@ -279,6 +305,8 @@ interface components {
279
305
  * @default false
280
306
  */
281
307
  opt_out_transcript_storage?: boolean;
308
+ /** Pii Categories */
309
+ pii_categories?: ("email" | "credit_card" | "ssn" | "phone_number")[];
282
310
  /**
283
311
  * Pii Redaction Enabled
284
312
  * @default false
@@ -291,6 +319,10 @@ interface components {
291
319
  * @default claude-sonnet-4-6
292
320
  */
293
321
  post_call_analysis_model?: string;
322
+ /** Pronunciation Dictionary */
323
+ pronunciation_dictionary?: components["schemas"]["PronunciationEntry"][];
324
+ /** Reminder Max Count */
325
+ reminder_max_count?: number | null;
294
326
  /**
295
327
  * Reminder Message
296
328
  * @default
@@ -335,6 +367,7 @@ interface components {
335
367
  * @default cartesia
336
368
  */
337
369
  tts_engine?: string;
370
+ user_dtmf_options?: components["schemas"]["UserDtmfOptions"];
338
371
  /**
339
372
  * Voice Id
340
373
  * @default
@@ -419,6 +452,8 @@ interface components {
419
452
  AgentUpdate: {
420
453
  /** Agent Type */
421
454
  agent_type?: ("llm" | "multi_prompt" | "flow") | null;
455
+ /** Allow User Dtmf */
456
+ allow_user_dtmf?: boolean | null;
422
457
  /** Ambient Sound */
423
458
  ambient_sound?: ("none" | "coffee-shop" | "call-center" | "convention-hall" | "summer-outdoor" | "mountain-outdoor" | "static-noise") | null;
424
459
  /** Ambient Sound Volume */
@@ -431,6 +466,8 @@ interface components {
431
466
  boosted_keywords?: string[] | null;
432
467
  /** Data Retention Days */
433
468
  data_retention_days?: number | null;
469
+ /** Data Storage Setting */
470
+ data_storage_setting?: ("everything" | "everything_except_pii" | "basic_attributes_only") | null;
434
471
  /** Default Dynamic Variables */
435
472
  default_dynamic_variables?: {
436
473
  [key: string]: string;
@@ -470,12 +507,18 @@ interface components {
470
507
  opt_out_call_recording?: boolean | null;
471
508
  /** Opt Out Transcript Storage */
472
509
  opt_out_transcript_storage?: boolean | null;
510
+ /** Pii Categories */
511
+ pii_categories?: ("email" | "credit_card" | "ssn" | "phone_number")[] | null;
473
512
  /** Pii Redaction Enabled */
474
513
  pii_redaction_enabled?: boolean | null;
475
514
  /** Post Call Analysis Data */
476
515
  post_call_analysis_data?: components["schemas"]["PostCallAnalysisVariable"][] | null;
477
516
  /** Post Call Analysis Model */
478
517
  post_call_analysis_model?: string | null;
518
+ /** Pronunciation Dictionary */
519
+ pronunciation_dictionary?: components["schemas"]["PronunciationEntry"][] | null;
520
+ /** Reminder Max Count */
521
+ reminder_max_count?: number | null;
479
522
  /** Reminder Message */
480
523
  reminder_message?: string | null;
481
524
  /** Reminder Trigger Ms */
@@ -496,6 +539,7 @@ interface components {
496
539
  temperature?: number | null;
497
540
  /** Tts Engine */
498
541
  tts_engine?: string | null;
542
+ user_dtmf_options?: components["schemas"]["UserDtmfOptions"] | null;
499
543
  /** Voice Id */
500
544
  voice_id?: string | null;
501
545
  /** Voice Speed */
@@ -515,6 +559,13 @@ interface components {
515
559
  /** Webhook Url */
516
560
  webhook_url?: string | null;
517
561
  };
562
+ /** AgentVersionCreate */
563
+ AgentVersionCreate: {
564
+ /** Description */
565
+ description?: string | null;
566
+ /** Title */
567
+ title?: string | null;
568
+ };
518
569
  /** AgentWeightIn */
519
570
  AgentWeightIn: {
520
571
  /** Agent Id */
@@ -523,13 +574,34 @@ interface components {
523
574
  * Agent Version
524
575
  * @default 0
525
576
  */
526
- agent_version?: number;
577
+ agent_version?: number | "latest_published";
527
578
  /**
528
579
  * Weight
529
580
  * @default 1
530
581
  */
531
582
  weight?: number;
532
583
  };
584
+ /** Body_clone_voice_v1_voices_clone_post */
585
+ Body_clone_voice_v1_voices_clone_post: {
586
+ /** Consent Confirmed */
587
+ consent_confirmed: boolean;
588
+ /** Description */
589
+ description?: string | null;
590
+ /**
591
+ * Engine
592
+ * @default elevenlabs
593
+ */
594
+ engine?: string;
595
+ /** Files */
596
+ files: string[];
597
+ /**
598
+ * Language
599
+ * @default en
600
+ */
601
+ language?: string;
602
+ /** Name */
603
+ name: string;
604
+ };
533
605
  /** BranchNode */
534
606
  BranchNode: {
535
607
  display_position?: components["schemas"]["DisplayPosition"] | null;
@@ -551,6 +623,39 @@ interface components {
551
623
  } & {
552
624
  [key: string]: unknown;
553
625
  };
626
+ /** CallPatch */
627
+ CallPatch: {
628
+ /** Amd Result */
629
+ amd_result?: {
630
+ [key: string]: unknown;
631
+ } | null;
632
+ /** Call Sid */
633
+ call_sid?: string | null;
634
+ /** Disconnection Reason */
635
+ disconnection_reason?: string | null;
636
+ /** Duration S */
637
+ duration_s?: number | null;
638
+ /** Ended At */
639
+ ended_at?: string | null;
640
+ /** Events */
641
+ events?: unknown[] | null;
642
+ /** Meta */
643
+ meta?: {
644
+ [key: string]: unknown;
645
+ } | null;
646
+ /** Metadata */
647
+ metadata?: {
648
+ [key: string]: unknown;
649
+ } | null;
650
+ /** Origination State */
651
+ origination_state?: string | null;
652
+ /** Recording Key */
653
+ recording_key?: string | null;
654
+ /** Status */
655
+ status?: string | null;
656
+ /** Transcript */
657
+ transcript?: unknown[] | null;
658
+ };
554
659
  /** ConversationNode */
555
660
  ConversationNode: {
556
661
  /** Allow Dtmf Interruption */
@@ -794,6 +899,11 @@ interface components {
794
899
  };
795
900
  /** FunctionCreate */
796
901
  FunctionCreate: {
902
+ /**
903
+ * Args At Root
904
+ * @default false
905
+ */
906
+ args_at_root?: boolean;
797
907
  /** Config */
798
908
  config?: {
799
909
  [key: string]: unknown;
@@ -848,6 +958,11 @@ interface components {
848
958
  };
849
959
  /** FunctionDef */
850
960
  FunctionDef: {
961
+ /**
962
+ * Args At Root
963
+ * @default false
964
+ */
965
+ args_at_root?: boolean;
851
966
  /** Config */
852
967
  config?: {
853
968
  [key: string]: unknown;
@@ -935,6 +1050,8 @@ interface components {
935
1050
  };
936
1051
  /** FunctionUpdate */
937
1052
  FunctionUpdate: {
1053
+ /** Args At Root */
1054
+ args_at_root?: boolean | null;
938
1055
  /** Config */
939
1056
  config?: {
940
1057
  [key: string]: unknown;
@@ -1155,12 +1272,21 @@ interface components {
1155
1272
  OutboundCallRequest: {
1156
1273
  /** Agent Id */
1157
1274
  agent_id?: string | null;
1275
+ /**
1276
+ * Agent Version
1277
+ * @default 0
1278
+ */
1279
+ agent_version?: number | "latest_published";
1158
1280
  /** Dialgem Llm Dynamic Variables */
1159
1281
  dialgem_llm_dynamic_variables?: {
1160
1282
  [key: string]: unknown;
1161
1283
  } | null;
1162
1284
  /** From */
1163
1285
  from_: string;
1286
+ /** Metadata */
1287
+ metadata?: {
1288
+ [key: string]: unknown;
1289
+ } | null;
1164
1290
  /** To */
1165
1291
  to: string;
1166
1292
  };
@@ -1168,6 +1294,8 @@ interface components {
1168
1294
  PhoneNumberAssign: {
1169
1295
  /** Agent Id */
1170
1296
  agent_id?: string | null;
1297
+ /** Agent Version */
1298
+ agent_version?: number | "latest_published" | null;
1171
1299
  };
1172
1300
  /** PhoneNumberCreate */
1173
1301
  PhoneNumberCreate: {
@@ -1183,12 +1311,26 @@ interface components {
1183
1311
  flow_sms_sender_enabled?: boolean;
1184
1312
  /** Inbound Agent Id */
1185
1313
  inbound_agent_id?: string | null;
1314
+ /**
1315
+ * Inbound Agent Version
1316
+ * @default 0
1317
+ */
1318
+ inbound_agent_version?: number | "latest_published";
1319
+ /** Inbound Agents */
1320
+ inbound_agents?: components["schemas"]["AgentWeightIn"][] | null;
1186
1321
  /** Nickname */
1187
1322
  nickname?: string | null;
1188
1323
  /** Number */
1189
1324
  number?: string | null;
1190
1325
  /** Outbound Agent Id */
1191
1326
  outbound_agent_id?: string | null;
1327
+ /**
1328
+ * Outbound Agent Version
1329
+ * @default 0
1330
+ */
1331
+ outbound_agent_version?: number | "latest_published";
1332
+ /** Outbound Agents */
1333
+ outbound_agents?: components["schemas"]["AgentWeightIn"][] | null;
1192
1334
  /** Phone Number */
1193
1335
  phone_number?: string | null;
1194
1336
  /**
@@ -1213,12 +1355,16 @@ interface components {
1213
1355
  flow_sms_sender_enabled?: boolean | null;
1214
1356
  /** Inbound Agent Id */
1215
1357
  inbound_agent_id?: string | null;
1358
+ /** Inbound Agent Version */
1359
+ inbound_agent_version?: number | "latest_published" | null;
1216
1360
  /** Inbound Agents */
1217
1361
  inbound_agents?: components["schemas"]["AgentWeightIn"][] | null;
1218
1362
  /** Nickname */
1219
1363
  nickname?: string | null;
1220
1364
  /** Outbound Agent Id */
1221
1365
  outbound_agent_id?: string | null;
1366
+ /** Outbound Agent Version */
1367
+ outbound_agent_version?: number | "latest_published" | null;
1222
1368
  /** Outbound Agents */
1223
1369
  outbound_agents?: components["schemas"]["AgentWeightIn"][] | null;
1224
1370
  /** Phone Number Type */
@@ -1244,8 +1390,15 @@ interface components {
1244
1390
  * @default
1245
1391
  */
1246
1392
  description?: string;
1393
+ /** Examples */
1394
+ examples?: string[];
1247
1395
  /** Name */
1248
1396
  name: string;
1397
+ /**
1398
+ * Required
1399
+ * @default false
1400
+ */
1401
+ required?: boolean;
1249
1402
  /**
1250
1403
  * Type
1251
1404
  * @enum {string}
@@ -1374,10 +1527,27 @@ interface components {
1374
1527
  /** Variable Names */
1375
1528
  variable_names: string[];
1376
1529
  };
1530
+ /** PronunciationEntry */
1531
+ PronunciationEntry: {
1532
+ /** Alias */
1533
+ alias: string;
1534
+ /**
1535
+ * Case Sensitive
1536
+ * @default false
1537
+ */
1538
+ case_sensitive?: boolean;
1539
+ /** Word */
1540
+ word: string;
1541
+ };
1377
1542
  /** RegisterCallRequest */
1378
1543
  RegisterCallRequest: {
1379
1544
  /** Agent Id */
1380
1545
  agent_id: string;
1546
+ /**
1547
+ * Agent Version
1548
+ * @default 0
1549
+ */
1550
+ agent_version?: number | "latest_published";
1381
1551
  /** Call Sid */
1382
1552
  call_sid?: string | null;
1383
1553
  /** Dialgem Llm Dynamic Variables */
@@ -1583,6 +1753,18 @@ interface components {
1583
1753
  } & {
1584
1754
  [key: string]: unknown;
1585
1755
  };
1756
+ /** UserDtmfOptions */
1757
+ UserDtmfOptions: {
1758
+ /** Digit Limit */
1759
+ digit_limit?: number | null;
1760
+ /** Termination Key */
1761
+ termination_key?: ("#" | "*") | null;
1762
+ /**
1763
+ * Timeout Ms
1764
+ * @default 2500
1765
+ */
1766
+ timeout_ms?: number;
1767
+ };
1586
1768
  /** ValidationError */
1587
1769
  ValidationError: {
1588
1770
  /** Context */
@@ -1746,6 +1928,11 @@ interface AgentFunction {
1746
1928
  query_params: KeyValuePair[];
1747
1929
  speak_during_execution: string | null;
1748
1930
  speak_after_execution: boolean;
1931
+ /**
1932
+ * `false` (the default for new functions): the request body is
1933
+ * `{ name, call, args }`. `true`: the body is the arguments object alone.
1934
+ */
1935
+ args_at_root: boolean;
1749
1936
  sort_order: number;
1750
1937
  kind: FunctionKind;
1751
1938
  /** Kind-specific settings (e.g. Cal.com credentials for the `*_cal` kinds). */
@@ -1791,6 +1978,77 @@ interface MCPServerTestResult {
1791
1978
  at: string;
1792
1979
  }
1793
1980
 
1981
+ /**
1982
+ * A published agent version: a frozen copy of the agent's configuration, its
1983
+ * functions and its MCP servers.
1984
+ *
1985
+ * The editable agent is the **draft**, version `0`, and is what a call runs
1986
+ * unless something pins a version. Publishing never changes the draft, and a
1987
+ * published version never changes at all — editing a function's URL afterwards
1988
+ * does not move the copy inside a version that already shipped.
1989
+ *
1990
+ * Pin one on a phone number (`inbound_agent_version` / `outbound_agent_version`),
1991
+ * on an outbound call, or on a registered call. The version a call ran is
1992
+ * reported as `agent_version` on its call record and in every webhook.
1993
+ */
1994
+ interface AgentVersionSummary {
1995
+ id: string;
1996
+ agent_id: string;
1997
+ /** 1 for the first publish, then upwards. The draft is 0 and is not listed here. */
1998
+ version: number;
1999
+ /** The agent's name at publish time. */
2000
+ name: string;
2001
+ /** Your label for the release, if you gave one. */
2002
+ title: string | null;
2003
+ description: string | null;
2004
+ /** ISO 8601, no timezone suffix (UTC). */
2005
+ published_at: string | null;
2006
+ /** Whoever published it, as the API identity that made the call. */
2007
+ published_by: string | null;
2008
+ function_count: number;
2009
+ mcp_server_count: number;
2010
+ }
2011
+ /** A version with its snapshot, returned by `publish` and `retrieve`. */
2012
+ interface AgentVersion extends AgentVersionSummary {
2013
+ /**
2014
+ * The frozen configuration. Same fields as {@link Agent}, minus the ones that
2015
+ * belong to the agent rather than to a snapshot (`id`, `created_at`,
2016
+ * `call_count`). `webhook_signing_secret` is never included; read it from the
2017
+ * agent itself.
2018
+ */
2019
+ config: AgentVersionConfig;
2020
+ functions: AgentFunction[];
2021
+ /** `auth_token` is stripped; `has_auth_token` says whether one is set. */
2022
+ mcp_servers: AgentVersionMCPServer[];
2023
+ }
2024
+ type AgentVersionConfig = Partial<Omit<Agent, "id" | "agent_id" | "created_at" | "call_count">> & {
2025
+ has_webhook_signing_secret: boolean;
2026
+ } & Record<string, unknown>;
2027
+ type AgentVersionMCPServer = Omit<MCPServer, "id"> & {
2028
+ id: string;
2029
+ has_auth_token: boolean;
2030
+ };
2031
+ interface AgentVersionListResponse {
2032
+ /** Newest first. */
2033
+ versions: AgentVersionSummary[];
2034
+ /** Whether older versions remain below the last one returned. */
2035
+ has_more: boolean;
2036
+ }
2037
+ interface AgentVersionListParams {
2038
+ /** Versions per page, 1-100. Default 50. */
2039
+ limit?: number | undefined;
2040
+ /**
2041
+ * Return versions below this one. Page by passing the `version` of the last
2042
+ * entry you received.
2043
+ */
2044
+ before_version?: number | undefined;
2045
+ }
2046
+ interface AgentVersionPublishParams {
2047
+ /** A label for the release, e.g. "adds the refund flow". */
2048
+ title?: string | undefined;
2049
+ description?: string | undefined;
2050
+ }
2051
+
1794
2052
  declare abstract class APIResource {
1795
2053
  protected readonly _client: HttpClient;
1796
2054
  constructor(client: HttpClient);
@@ -1803,6 +2061,8 @@ declare class Agents extends APIResource {
1803
2061
  readonly knowledge: AgentKnowledge;
1804
2062
  /** Remote MCP servers whose tools are exposed to the agent. */
1805
2063
  readonly mcpServers: AgentMCPServers;
2064
+ /** Frozen snapshots of the agent that a number or a call can pin. */
2065
+ readonly versions: AgentVersions;
1806
2066
  constructor(client: HttpClient);
1807
2067
  /** Create an agent. Only `name` is required; everything else has a server default. */
1808
2068
  create(body: AgentCreateParams, options?: RequestOptions): Promise<Agent>;
@@ -1813,6 +2073,29 @@ declare class Agents extends APIResource {
1813
2073
  update(agentId: string, body: AgentUpdateParams, options?: RequestOptions): Promise<Agent>;
1814
2074
  delete(agentId: string, options?: RequestOptions): Promise<AgentDeleteResponse>;
1815
2075
  }
2076
+ /**
2077
+ * Published versions of an agent.
2078
+ *
2079
+ * The agent itself is the draft, version 0, and every call runs it unless a
2080
+ * number or a request pins a published version. Publishing takes a copy;
2081
+ * editing the agent afterwards changes only the draft.
2082
+ */
2083
+ declare class AgentVersions extends APIResource {
2084
+ /** Freeze the agent as it is now. Returns the new version, snapshot included. */
2085
+ publish(agentId: string, body?: AgentVersionPublishParams, options?: RequestOptions): Promise<AgentVersion>;
2086
+ /**
2087
+ * One page of published versions, newest first, without their snapshots.
2088
+ *
2089
+ * Returns the array. When you need to page — an agent published on every
2090
+ * deploy accumulates versions, and nothing prunes them — read `has_more` from
2091
+ * {@link listPage} instead and pass the last `version` as `before_version`.
2092
+ */
2093
+ list(agentId: string, params?: AgentVersionListParams, options?: RequestOptions): Promise<AgentVersionSummary[]>;
2094
+ /** {@link list} with the `has_more` flag, for paging. */
2095
+ listPage(agentId: string, params?: AgentVersionListParams, options?: RequestOptions): Promise<AgentVersionListResponse>;
2096
+ /** One version with its full snapshot. Version 0 is the draft: use `agents.retrieve`. */
2097
+ retrieve(agentId: string, version: number, options?: RequestOptions): Promise<AgentVersion>;
2098
+ }
1816
2099
  declare class AgentFunctions extends APIResource {
1817
2100
  list(agentId: string, options?: RequestOptions): Promise<AgentFunction[]>;
1818
2101
  create(agentId: string, body: FunctionCreateParams, options?: RequestOptions): Promise<AgentFunction>;
@@ -1836,28 +2119,25 @@ declare class AgentMCPServers extends APIResource {
1836
2119
  test(agentId: string, serverId: string, options?: RequestOptions): Promise<MCPServerTestResult>;
1837
2120
  }
1838
2121
 
1839
- interface PageFetcher<T> {
1840
- (page: number): Promise<PageData<T>>;
1841
- }
1842
2122
  interface PageData<T> {
1843
2123
  data: T[];
1844
- total: number;
1845
- page: number;
1846
- page_size: number;
2124
+ has_more: boolean;
2125
+ /** Pass to the next request to continue; `null` on the last page. */
2126
+ pagination_key: string | null;
1847
2127
  }
2128
+ type PageFetcher<T> = (paginationKey: string | null) => Promise<PageData<T>>;
1848
2129
  declare class Page<T> implements PageData<T> {
1849
2130
  #private;
1850
2131
  readonly data: T[];
1851
- readonly total: number;
1852
- readonly page: number;
1853
- readonly page_size: number;
2132
+ readonly has_more: boolean;
2133
+ readonly pagination_key: string | null;
1854
2134
  constructor(data: PageData<T>, fetchPage: PageFetcher<T>);
1855
2135
  hasNextPage(): boolean;
1856
2136
  getNextPage(): Promise<Page<T>>;
1857
2137
  }
1858
2138
  declare class PagePromise<T> implements PromiseLike<Page<T>>, AsyncIterable<T> {
1859
2139
  #private;
1860
- constructor(fetchPage: PageFetcher<T>, startPage: number);
2140
+ constructor(fetchPage: PageFetcher<T>, startKey?: string | null);
1861
2141
  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
2142
  catch<R = never>(onrejected?: ((reason: unknown) => R | PromiseLike<R>) | null): Promise<Page<T> | R>;
1863
2143
  finally(onfinally?: (() => void) | null): Promise<Page<T>>;
@@ -1865,46 +2145,71 @@ declare class PagePromise<T> implements PromiseLike<Page<T>>, AsyncIterable<T> {
1865
2145
  }
1866
2146
 
1867
2147
  /**
1868
- * A call, as returned by `GET /v1/calls` and `GET /v1/calls/{id}`.
1869
- * The shape is the same for both endpoints.
2148
+ * A call, as returned by `GET /v1/calls`, `GET /v1/calls/{id}` and every call webhook.
2149
+ * The shape is the same everywhere.
1870
2150
  */
1871
2151
  interface Call {
1872
2152
  id: string;
1873
2153
  /** Empty string when the call has no agent. */
1874
2154
  agent_id: string;
2155
+ /**
2156
+ * The published agent version this call ran. 0 is the live draft, which is
2157
+ * what a call runs unless a number or the request that created it pinned a
2158
+ * version.
2159
+ */
2160
+ agent_version: number;
1875
2161
  agent_name: string;
1876
2162
  /** Dialgem's lifecycle state. */
1877
2163
  status: CallStatus;
1878
2164
  /** The same state in session vocabulary: active→ongoing, completed→ended, failed→error, queued→registered. */
1879
2165
  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[];
2166
+ call_type: "phone_call" | "web_call" | (string & {});
2167
+ direction: "inbound" | "outbound" | (string & {});
2168
+ /** Your own data, attached when the call was created or later with `calls.update`. */
2169
+ metadata: Record<string, unknown>;
2170
+ /** The dynamic variables the call was started with. */
2171
+ dynamic_variables: Record<string, string>;
1886
2172
  /** ISO 8601, no timezone suffix (UTC). Empty string if unknown. */
1887
2173
  started_at: string;
2174
+ /** ISO 8601, no timezone suffix (UTC). `null` while the call is ongoing. */
2175
+ ended_at: string | null;
2176
+ /** Epoch milliseconds. */
2177
+ start_timestamp: number | null;
2178
+ /** Epoch milliseconds. `null` while the call is ongoing. */
2179
+ end_timestamp: number | null;
2180
+ duration_s: number;
2181
+ duration_ms: number | null;
1888
2182
  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
2183
  from_number: string;
1894
2184
  to_number: string;
2185
+ /** Carrier call id (Twilio CallSid). Empty string if none. */
2186
+ call_sid: string;
1895
2187
  origination_state: string | null;
2188
+ /**
2189
+ * One entry per turn. Empty when the agent opts out of transcript storage, and
2190
+ * once the agent's `data_retention_days` purge has run. PII-redacted when
2191
+ * redaction is on.
2192
+ */
2193
+ transcript: TranscriptTurn[];
2194
+ /** The same transcript as one string, `Agent: …` / `User: …` per line. */
2195
+ transcript_text: string;
1896
2196
  /** Presigned URL that expires; download it promptly rather than storing the link. */
1897
2197
  recording_url: string | null;
1898
- amd_result: Record<string, unknown> | null;
1899
2198
  events: Record<string, unknown>[];
1900
- /** Post-call extraction. `null` until the call has ended and been analyzed, and after a retention purge. */
2199
+ disconnection_reason: DisconnectionReason | null;
2200
+ /** Whether the call reached voicemail or an answering machine. */
2201
+ in_voicemail: boolean;
2202
+ amd_result: Record<string, unknown> | null;
2203
+ /** Post-call analysis. `null` until the call has ended and been analyzed, and after a retention purge. */
1901
2204
  analysis: CallAnalysis | null;
1902
- disconnection_reason: string | null;
1903
2205
  /** Set once the call is finalized. */
1904
2206
  call_cost: CallCost | null;
1905
2207
  /** Mean time from the caller's final transcript to the agent's first audio byte. */
1906
2208
  end_to_end_latency_ms: number | null;
2209
+ /** Per-stage latency percentiles, recorded when the call ends. `null` if no turn completed. */
2210
+ latency: CallLatency | null;
1907
2211
  }
2212
+ type DisconnectionReason = "user_hangup" | "agent_hangup" | "call_transfer" | "voicemail_reached" | "inactivity" | "max_duration_reached" | "manual_stopped" | "dial_no_answer" | "flow_dead_end" | "flow_loop_guard" | "error" | (string & {});
1908
2213
  /** Every amount is an integer in units of **$0.0001**: `combined_cost: 1700` is $0.17. */
1909
2214
  interface CallCost {
1910
2215
  combined_cost: number;
@@ -1925,23 +2230,76 @@ interface TranscriptTurn {
1925
2230
  timestamp: string;
1926
2231
  }
1927
2232
  interface CallAnalysis {
2233
+ /** A one-to-three sentence summary of the call. */
2234
+ call_summary: string | null;
2235
+ user_sentiment: "Positive" | "Neutral" | "Negative" | (string & {}) | null;
2236
+ call_successful: boolean | null;
2237
+ in_voicemail: boolean;
1928
2238
  /** Values for the agent's `post_call_analysis_data` fields, keyed by name. */
1929
2239
  variables: Record<string, unknown>;
1930
2240
  model: string;
1931
2241
  extracted_at: string;
1932
- user_sentiment: "Positive" | "Neutral" | "Negative" | (string & {}) | null;
1933
- call_successful: boolean | null;
1934
2242
  /** Set when extraction failed; `variables` may then be partial or empty. */
1935
2243
  error: string | null;
1936
2244
  }
2245
+ /** Milliseconds. Each stage has at least one sample, or is omitted. */
2246
+ interface LatencyStats {
2247
+ p50: number;
2248
+ p90: number;
2249
+ p95: number;
2250
+ p99: number;
2251
+ min: number;
2252
+ max: number;
2253
+ num: number;
2254
+ }
2255
+ interface CallLatency {
2256
+ /** Caller's final transcript to the agent's first audio byte. */
2257
+ e2e?: LatencyStats;
2258
+ /** Time to the model's first sentence. */
2259
+ llm?: LatencyStats;
2260
+ /** Time to the first synthesized audio. */
2261
+ tts?: LatencyStats;
2262
+ /** How long end-of-speech detection waited. */
2263
+ endpointing?: LatencyStats;
2264
+ }
1937
2265
  interface CallListParams {
2266
+ agent_id?: string | string[] | undefined;
2267
+ status?: CallStatus | CallStatus[] | undefined;
2268
+ direction?: "inbound" | "outbound" | undefined;
2269
+ call_type?: "phone_call" | "web_call" | undefined;
2270
+ disconnection_reason?: DisconnectionReason | DisconnectionReason[] | undefined;
2271
+ from_number?: string | undefined;
2272
+ to_number?: string | undefined;
2273
+ user_sentiment?: "Positive" | "Neutral" | "Negative" | undefined;
2274
+ call_successful?: boolean | undefined;
2275
+ /** Started at or after this time, epoch ms. */
2276
+ start_after?: number | undefined;
2277
+ /** Started before this time, epoch ms. */
2278
+ start_before?: number | undefined;
2279
+ /**
2280
+ * Match calls whose metadata has these values, e.g. `{ crm_id: "42" }`.
2281
+ * Values are compared as strings.
2282
+ */
2283
+ metadata?: Record<string, string | number | boolean> | undefined;
1938
2284
  /** Case-insensitive match on the agent's name. */
1939
2285
  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;
2286
+ /** Default `desc` (newest first). */
2287
+ sort_order?: "asc" | "desc" | undefined;
2288
+ /** Calls per page, 1–100. Default 10. */
2289
+ limit?: number | undefined;
2290
+ }
2291
+ interface CallUpdateParams {
2292
+ /** Replaces the call's metadata. A JSON object of at most 16 KB. */
2293
+ metadata: Record<string, unknown>;
2294
+ }
2295
+ interface CallDeleteResponse {
2296
+ deleted: true;
2297
+ id: string;
2298
+ }
2299
+ interface CallStopResponse {
2300
+ id: string;
2301
+ /** The call is tearing down; it becomes `completed` with `disconnection_reason: "manual_stopped"` shortly. */
2302
+ stopping: true;
1945
2303
  }
1946
2304
  /** Result of `calls.createPhoneCall`. The call is dialing; its outcome arrives via webhooks or `calls.retrieve`. */
1947
2305
  interface PhoneCallCreateResponse {
@@ -1960,16 +2318,31 @@ interface CallRegisterResponse {
1960
2318
 
1961
2319
  declare class Calls extends APIResource {
1962
2320
  /**
1963
- * Calls, newest first. Await for one page, or iterate for every call:
2321
+ * Calls, newest first by default. Await for one page, or iterate for every call:
1964
2322
  *
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
- * }
2323
+ * const page = await dialgem.calls.list({ limit: 50 })
2324
+ * for await (const call of dialgem.calls.list({ status: "completed", start_after: since })) { ... }
1969
2325
  */
1970
2326
  list(params?: CallListParams, options?: RequestOptions): PagePromise<Call>;
1971
- /** One call, including its transcript, analysis and recording URL. */
2327
+ /** One call, including its transcript, analysis, latency and recording URL. */
1972
2328
  retrieve(callId: string, options?: RequestOptions): Promise<Call>;
2329
+ /** Replace the call's `metadata`. */
2330
+ update(callId: string, body: CallUpdateParams, options?: RequestOptions): Promise<Call>;
2331
+ /**
2332
+ * Permanently delete a finished call: its record, transcript, analysis and
2333
+ * recording. A call still in progress is refused with `ConflictError`; stop it first.
2334
+ */
2335
+ delete(callId: string, options?: RequestOptions): Promise<CallDeleteResponse>;
2336
+ /**
2337
+ * End an ongoing call now, as if the agent had hung up. The call becomes
2338
+ * `completed` with `disconnection_reason: "manual_stopped"` a moment later, and
2339
+ * the usual `call_ended` webhook follows.
2340
+ *
2341
+ * `ConflictError` with `errCode` `call_not_ongoing` if it already ended, or
2342
+ * `call_not_connected` if no agent is on the call yet (e.g. still ringing).
2343
+ * Not retried by default.
2344
+ */
2345
+ stop(callId: string, options?: RequestOptions): Promise<CallStopResponse>;
1973
2346
  /**
1974
2347
  * Dial `to` from one of your organization's numbers, with `agent_id` (or the
1975
2348
  * number's outbound agent) on the line.
@@ -2001,9 +2374,51 @@ interface Voice {
2001
2374
  language: string[];
2002
2375
  preview_url: string | null;
2003
2376
  raw_metadata: Record<string, unknown> | null;
2377
+ /** True for a voice your organization cloned; false for the shared catalog. */
2378
+ is_custom: boolean;
2379
+ /** Who uploaded the audio, for a cloned voice. */
2380
+ created_by: string | null;
2004
2381
  created_at: string | null;
2005
2382
  updated_at: string | null;
2006
2383
  }
2384
+ /** One audio sample for cloning. `Blob` and `File` both satisfy this. */
2385
+ type VoiceCloneFile = Blob | {
2386
+ name?: string;
2387
+ type?: string;
2388
+ };
2389
+ interface VoiceCloneParams {
2390
+ /** Display name for the new voice. */
2391
+ name: string;
2392
+ /**
2393
+ * The audio to clone from.
2394
+ *
2395
+ * ElevenLabs takes up to 25 files; **Cartesia takes exactly one** and refuses
2396
+ * more rather than silently picking one, since that would make the same
2397
+ * upload produce a noticeably different voice on the two providers.
2398
+ */
2399
+ files: Blob[];
2400
+ /**
2401
+ * You are asserting that you hold the rights to this audio and have the
2402
+ * speaker's consent to clone their voice. Required, and recorded against
2403
+ * your API identity — a cloned voice is built from a real person's speech.
2404
+ */
2405
+ consent_confirmed: true;
2406
+ /** Which provider clones it. Defaults to `elevenlabs`. */
2407
+ engine?: "elevenlabs" | "cartesia" | undefined;
2408
+ description?: string | undefined;
2409
+ /** Cartesia clones per language; ElevenLabs ignores this. Defaults to `en`. */
2410
+ language?: string | undefined;
2411
+ /**
2412
+ * Filenames sent with each blob, in order. The provider infers the audio
2413
+ * container from the extension, so a `Blob` with no name needs one here.
2414
+ * Defaults to `clip-1.wav`, `clip-2.wav`, …
2415
+ */
2416
+ filenames?: string[] | undefined;
2417
+ }
2418
+ interface VoiceDeleteResponse {
2419
+ deleted: boolean;
2420
+ voice_id: string;
2421
+ }
2007
2422
  interface VoiceListParams {
2008
2423
  provider?: string | undefined;
2009
2424
  gender?: string | undefined;
@@ -2053,8 +2468,33 @@ interface FlowTemplate extends FlowTemplateSummary {
2053
2468
  }
2054
2469
 
2055
2470
  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`. */
2471
+ /**
2472
+ * Voices available to agents: the shared catalog plus the ones your
2473
+ * organization cloned, yours first. Put a voice's `provider_voice_id` in an
2474
+ * agent's `voice_id`.
2475
+ */
2057
2476
  list(params?: VoiceListParams, options?: RequestOptions): Promise<Voice[]>;
2477
+ /**
2478
+ * Clone a voice from audio you upload. The new voice is private to your
2479
+ * organization and never appears in another one's catalog.
2480
+ *
2481
+ * Consent is required: you are asserting that you hold the rights to the
2482
+ * audio and have the speaker's consent, and that assertion is recorded
2483
+ * against your API identity.
2484
+ *
2485
+ * The upload is never retried, whatever `maxRetries` says — a retried
2486
+ * multipart body can send truncated audio, and a clone built from half the
2487
+ * recording succeeds and sounds wrong.
2488
+ */
2489
+ clone(params: VoiceCloneParams, options?: RequestOptions): Promise<Voice>;
2490
+ /**
2491
+ * Delete a voice your organization cloned, at the provider and here.
2492
+ *
2493
+ * Only your own cloned voices: the shared catalog is not deletable, and a
2494
+ * voice an agent still uses is refused with a 409 rather than leaving that
2495
+ * agent without one.
2496
+ */
2497
+ delete(voiceId: string, options?: RequestOptions): Promise<VoiceDeleteResponse>;
2058
2498
  }
2059
2499
  declare class FlowTemplates extends APIResource {
2060
2500
  /** Built-in conversation-flow templates (summaries, without `flow_config`). */
@@ -2067,6 +2507,18 @@ declare class PromptTemplates extends APIResource {
2067
2507
  retrieve(templateId: string, options?: RequestOptions): Promise<PromptTemplate>;
2068
2508
  }
2069
2509
 
2510
+ /**
2511
+ * Which published agent version a number answers on.
2512
+ *
2513
+ * A number is the frozen version with that number; `0` is the live draft, which
2514
+ * is what a number does when nothing is pinned. `"latest_published"` is a
2515
+ * pointer rather than a choice — it follows the newest publish, so shipping a
2516
+ * new version moves every number set to it without touching them.
2517
+ *
2518
+ * A *call* never reports this type: `Call.agent_version` is always the concrete
2519
+ * number that ran, resolved when the call was placed.
2520
+ */
2521
+ type AgentVersionRef = number | "latest_published";
2070
2522
  /**
2071
2523
  * A phone number, as returned by `/v1/phone-numbers`.
2072
2524
  * The shape is the same across all phone-number endpoints.
@@ -2082,9 +2534,9 @@ interface PhoneNumber {
2082
2534
  phone_number_type: string;
2083
2535
  nickname: string;
2084
2536
  inbound_agent_id: string | null;
2085
- inbound_agent_version: number;
2537
+ inbound_agent_version: AgentVersionRef;
2086
2538
  outbound_agent_id: string | null;
2087
- outbound_agent_version: number;
2539
+ outbound_agent_version: AgentVersionRef;
2088
2540
  /** Weighted inbound routing. `inbound_agent_id` is its primary entry. */
2089
2541
  inbound_agents: PhoneNumberAgentWeight[];
2090
2542
  outbound_agents: PhoneNumberAgentWeight[];
@@ -2098,7 +2550,7 @@ interface PhoneNumber {
2098
2550
  }
2099
2551
  interface PhoneNumberAgentWeight {
2100
2552
  agent_id: string;
2101
- agent_version: number;
2553
+ agent_version: AgentVersionRef;
2102
2554
  weight: number;
2103
2555
  }
2104
2556
  interface SipOutboundTrunkConfig {
@@ -2113,6 +2565,14 @@ declare class PhoneNumbers extends APIResource {
2113
2565
  create(body: PhoneNumberCreateParams, options?: RequestOptions): Promise<PhoneNumber>;
2114
2566
  /** Every active (not released) number in the organization, newest first. */
2115
2567
  list(options?: RequestOptions): Promise<PhoneNumber[]>;
2568
+ /**
2569
+ * One number by its E.164 value, e.g. `+14155550123`.
2570
+ *
2571
+ * Keyed on the number rather than on `id`, because the number is what you
2572
+ * have when you are asking whether it is registered at all. Throws
2573
+ * `NotFoundError` when it is not.
2574
+ */
2575
+ retrieve(phoneNumber: string, options?: RequestOptions): Promise<PhoneNumber>;
2116
2576
  /**
2117
2577
  * Partial update.
2118
2578
  *
@@ -2129,45 +2589,79 @@ declare class PhoneNumbers extends APIResource {
2129
2589
  }
2130
2590
 
2131
2591
  /**
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.
2592
+ * Payloads Dialgem POSTs to an agent's `webhook_url`, for the events subscribed in
2593
+ * `webhook_events`. Each carries the full call record; see the "Verify webhooks"
2594
+ * section of the README.
2135
2595
  *
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)`.
2596
+ * A failed delivery is retried up to three times, and every attempt carries the
2597
+ * same `x-dialgem-delivery` id. Use it (or `event` + `call_id`) to drop duplicates.
2139
2598
  */
2140
2599
  type WebhookEvent = CallStartedEvent | CallEndedEvent | CallAnalyzedEvent;
2141
- interface CallStartedEvent {
2142
- event: "call_started";
2600
+ interface CallEventBase {
2143
2601
  call_id: string;
2144
2602
  agent_id: string;
2603
+ /** The full call record at the moment the event was sent. */
2604
+ call: Call;
2145
2605
  }
2146
- interface CallEndedEvent {
2606
+ interface CallStartedEvent extends CallEventBase {
2607
+ event: "call_started";
2608
+ }
2609
+ /** Sent as soon as the call ends; post-call analysis follows in `call_analyzed`. */
2610
+ interface CallEndedEvent extends CallEventBase {
2147
2611
  event: "call_ended";
2148
- call_id: string;
2149
- agent_id: string;
2150
- status: CallStatus;
2151
- duration_s: number | null;
2152
2612
  }
2153
- /** Sent before `call_ended`, and only for calls that produced a transcript. */
2154
- interface CallAnalyzedEvent {
2613
+ /** Sent after `call_ended`, once analysis has run, and only for calls that produced a transcript. */
2614
+ interface CallAnalyzedEvent extends CallEventBase {
2155
2615
  event: "call_analyzed";
2616
+ }
2617
+ /**
2618
+ * The body Dialgem POSTs to a custom function's URL when the agent calls it,
2619
+ * unless the function has `args_at_root`, in which case the body is `args` alone.
2620
+ */
2621
+ interface FunctionCallRequest<Args = Record<string, unknown>> {
2622
+ /** The function's name. */
2623
+ name: string;
2624
+ call: FunctionCallContext;
2625
+ /** The arguments the agent supplied, per the function's `parameters` schema. */
2626
+ args: Args;
2627
+ }
2628
+ interface FunctionCallContext {
2156
2629
  call_id: string;
2157
- agent_id: string;
2158
- analysis: CallAnalysis;
2630
+ agent_id: string | null;
2631
+ call_type: "phone_call" | "web_call";
2632
+ direction: "inbound" | "outbound" | null;
2633
+ from_number: string | null;
2634
+ to_number: string | null;
2635
+ dynamic_variables: Record<string, string>;
2636
+ metadata: Record<string, unknown>;
2159
2637
  }
2160
2638
 
2161
- /** Header carrying the hex HMAC-SHA256 of the raw request body. */
2639
+ /** Header carrying the request signature: `v=<timestamp_ms>,d=<hex>`. */
2162
2640
  declare const WEBHOOK_SIGNATURE_HEADER = "x-dialgem-signature";
2163
2641
  /** Header naming the event; the same value as the body's `event`. */
2164
2642
  declare const WEBHOOK_EVENT_HEADER = "x-dialgem-event";
2643
+ /** Header with an id that stays the same across retries of one delivery. */
2644
+ declare const WEBHOOK_DELIVERY_HEADER = "x-dialgem-delivery";
2645
+ /** Signatures older or newer than this are rejected, so a captured request cannot be replayed. */
2646
+ declare const DEFAULT_SIGNATURE_TOLERANCE_MS: number;
2165
2647
  /** The raw request body, byte-for-byte as received. Node `Buffer` is a `Uint8Array`. */
2166
2648
  type WebhookPayload = string | Uint8Array | ArrayBuffer;
2167
2649
  /** A header value as Node's `IncomingHttpHeaders`, `Headers.get()` or a framework hands it over. */
2168
2650
  type SignatureHeader = string | string[] | null | undefined;
2651
+ interface VerifyOptions {
2652
+ /** Maximum age (and clock skew) of a signature, in ms. Default 5 minutes. */
2653
+ toleranceMs?: number | undefined;
2654
+ /** The current time in epoch ms. For tests; defaults to `Date.now()`. */
2655
+ now?: number | undefined;
2656
+ }
2169
2657
  /**
2170
- * Verifies and parses Dialgem webhooks.
2658
+ * Verifies and parses what Dialgem sends to your servers: event webhooks, and
2659
+ * requests to your custom functions. Both use one signature scheme:
2660
+ *
2661
+ * x-dialgem-signature: v=<timestamp_ms>,d=<hex>
2662
+ * hex = HMAC-SHA256(secret, raw_body + timestamp_ms)
2663
+ *
2664
+ * The secret is the agent's `webhook_signing_secret`.
2171
2665
  *
2172
2666
  * **Pass the raw body.** The signature covers the exact bytes Dialgem sent. A body
2173
2667
  * that was parsed and re-serialized (`express.json()`, `JSON.stringify(req.body)`)
@@ -2175,27 +2669,36 @@ type SignatureHeader = string | string[] | null | undefined;
2175
2669
  * Fastify's raw body, or `await request.text()` in a route handler.
2176
2670
  */
2177
2671
  declare class Webhooks {
2672
+ #private;
2178
2673
  /**
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.
2674
+ * Returns whether `signature` is a current, valid signature of `payload` under
2675
+ * `secret`. Constant-time. Returns `false` for a missing, malformed, tampered or
2676
+ * stale signature; throws only if `secret` is empty, which is a configuration
2677
+ * error rather than a bad request.
2678
+ */
2679
+ verify(payload: WebhookPayload, signature: SignatureHeader, secret: string, options?: VerifyOptions): Promise<boolean>;
2680
+ /**
2681
+ * Verifies a webhook's signature, then parses its body.
2682
+ *
2683
+ * @throws WebhookVerificationError if the signature is missing, invalid or stale.
2182
2684
  */
2183
- verify(payload: WebhookPayload, signature: SignatureHeader, secret: string): Promise<boolean>;
2685
+ constructEvent(payload: WebhookPayload, signature: SignatureHeader, secret: string, options?: VerifyOptions): Promise<WebhookEvent>;
2184
2686
  /**
2185
- * Verifies the signature, then parses the body.
2687
+ * Verifies a request Dialgem made to one of your custom functions, then parses
2688
+ * its body. For functions with `args_at_root`, the body is the arguments object
2689
+ * alone; use `verify` and parse it yourself.
2186
2690
  *
2187
- * @throws WebhookVerificationError if the signature is missing or does not match.
2691
+ * @throws WebhookVerificationError if the signature is missing, invalid or stale.
2188
2692
  */
2189
- constructEvent(payload: WebhookPayload, signature: SignatureHeader, secret: string): Promise<WebhookEvent>;
2693
+ constructFunctionCall<Args = Record<string, unknown>>(payload: WebhookPayload, signature: SignatureHeader, secret: string, options?: VerifyOptions): Promise<FunctionCallRequest<Args>>;
2190
2694
  }
2191
2695
  declare const webhooks: Webhooks;
2192
2696
 
2193
- declare const DEFAULT_BASE_URL = "https://api.dialgem.com";
2697
+ /** The Dialgem API. Fixed: the SDK talks to Dialgem and nothing else. */
2698
+ declare const BASE_URL = "https://api.dialgem.com";
2194
2699
  interface ClientOptions {
2195
2700
  /** Organization API key (`zk_…`). Defaults to `process.env.DIALGEM_API_KEY`. */
2196
2701
  apiKey?: string | undefined;
2197
- /** Defaults to `process.env.DIALGEM_BASE_URL`, then `https://api.dialgem.com`. */
2198
- baseURL?: string | undefined;
2199
2702
  /** Per-attempt timeout in milliseconds (> 0). Default 60000. */
2200
2703
  timeout?: number | undefined;
2201
2704
  /** Retries for GET/PATCH/DELETE on 408/429/5xx and connection errors. Default 2. POST is not retried. */
@@ -2221,7 +2724,7 @@ interface ClientOptions {
2221
2724
  * ```
2222
2725
  */
2223
2726
  declare class Dialgem {
2224
- static readonly DEFAULT_BASE_URL = "https://api.dialgem.com";
2727
+ static readonly BASE_URL = "https://api.dialgem.com";
2225
2728
  /** Webhook verification without a client instance: `Dialgem.webhooks.constructEvent(...)`. */
2226
2729
  static readonly webhooks: Webhooks;
2227
2730
  readonly agents: Agents;
@@ -2231,10 +2734,11 @@ declare class Dialgem {
2231
2734
  readonly flowTemplates: FlowTemplates;
2232
2735
  readonly promptTemplates: PromptTemplates;
2233
2736
  readonly webhooks: Webhooks;
2737
+ /** Always `https://api.dialgem.com`. */
2234
2738
  readonly baseURL: string;
2235
2739
  constructor(options?: ClientOptions);
2236
2740
  }
2237
2741
 
2238
- declare const VERSION = "0.1.0-beta.0";
2742
+ declare const VERSION = "0.1.0-beta.1";
2239
2743
 
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 };
2744
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, APIUserAbortError, type Agent, type AgentCreateParams, type AgentDeleteResponse, type AgentFunction, AgentFunctions, AgentKnowledge, AgentMCPServers, type AgentType, type AgentUpdateParams, type AgentVersion, type AgentVersionConfig, type AgentVersionListParams, type AgentVersionListResponse, type AgentVersionMCPServer, type AgentVersionPublishParams, type AgentVersionRef, type AgentVersionSummary, AgentVersions, type AgentWeight, Agents, AuthenticationError, BASE_URL, BadRequestError, type Call, type CallAnalysis, type CallAnalyzedEvent, type CallCost, type CallCreatePhoneCallParams, type CallDeleteResponse, type CallEndedEvent, type CallLatency, type CallListParams, type CallRegisterParams, type CallRegisterResponse, type CallSessionStatus, type CallStartedEvent, type CallStatus, type CallStopResponse, type CallUpdateParams, Calls, type ClientOptions, ConflictError, DEFAULT_SIGNATURE_TOLERANCE_MS, Dialgem, DialgemError, type DisconnectionReason, type ErrorBody, type ErrorIssue, type Fetch, type FetchInit, type FetchResponse, type FlowConfig, type FlowTemplate, type FlowTemplateSummary, FlowTemplates, type FunctionCallContext, type FunctionCallRequest, type FunctionCreateParams, type FunctionKind, type FunctionReorderParams, type FunctionUpdateParams, type HeadersLike, InternalServerError, type KeyValuePair, type KnowledgeDocument, type KnowledgeDocumentCreateParams, type LatencyStats, 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 VerifyOptions, type Voice, type VoiceCloneFile, type VoiceCloneParams, type VoiceDeleteResponse, type VoiceListParams, Voices, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, type WebhookEvent, type WebhookEventType, type WebhookPayload, WebhookVerificationError, Webhooks, webhooks };