supafone-labs 0.3.1 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  */
22
22
  export interface SupafoneLabsOptions {
23
23
  /** Your key from https://labs.supafone.ai/get-key.html */
24
- apiKey: string;
24
+ apiKey?: string;
25
25
  /** Override the gateway (default: the hosted cloud). */
26
26
  baseUrl?: string;
27
27
  /** Supafone app/API key for hosted agent provisioning. Defaults to apiKey. */
@@ -32,6 +32,17 @@ export interface SupafoneLabsOptions {
32
32
  timeoutMs?: number;
33
33
  /** Optional pre-obtained session token (else use login()). */
34
34
  sessionToken?: string;
35
+ /**
36
+ * Account (app.supafone.ai) auth — powers campaigns + real calls. Pass a
37
+ * JWT directly, or accountEmail + accountPassword and the client logs in
38
+ * lazily (and re-logs-in once when the token expires). With account auth
39
+ * present, apiKey becomes optional.
40
+ */
41
+ accountToken?: string;
42
+ accountEmail?: string;
43
+ accountPassword?: string;
44
+ /** Portal base for listen/monitor links (default https://app.supafone.ai). */
45
+ appUrl?: string;
35
46
  }
36
47
  export interface ChatMessage {
37
48
  role: "system" | "user" | "assistant";
@@ -74,11 +85,39 @@ export interface UsageToday {
74
85
  cap: number;
75
86
  }>;
76
87
  }
88
+ export interface LabsLogEntry {
89
+ id: number;
90
+ at: string;
91
+ endpoint: string;
92
+ seconds_billed: number;
93
+ duration_ms: number;
94
+ detail: string;
95
+ meta: Record<string, unknown>;
96
+ }
97
+ export interface StreamLogsOptions {
98
+ limit?: number;
99
+ afterId?: number;
100
+ pollMs?: number;
101
+ snapshot?: boolean;
102
+ signal?: AbortSignal;
103
+ }
77
104
  export type LabsAgentType = "phone" | "web" | "campaign";
78
105
  export type LabsAgentStyle = "inbound" | "outbound";
79
106
  export type LabsRuntimeMode = "multi_stage" | "single_stage";
80
107
  export type LabsTelephonyMode = "supafone_managed" | "byok";
81
- export type LabsTelephonyProvider = "supafone" | "twilio" | "telnyx" | "plivo" | "sip" | string;
108
+ export type LabsTelephonyProvider = "supafone" | "twilio" | "telnyx" | "plivo" | "signalwire" | "sip" | "custom_sip" | "custom" | string;
109
+ export type LabsNumberStrategy = "default_pool" | "dedicated" | "premium" | "byok" | string;
110
+ export interface LabsCallStage {
111
+ key?: string;
112
+ id?: string;
113
+ name: string;
114
+ goal?: string;
115
+ instructions?: string;
116
+ exitCriteria?: string[];
117
+ exit_criteria?: string[];
118
+ tools?: string[];
119
+ metadata?: Record<string, unknown>;
120
+ }
82
121
  export interface LabsVoiceSelection {
83
122
  provider?: string;
84
123
  voiceId?: string;
@@ -86,9 +125,51 @@ export interface LabsVoiceSelection {
86
125
  model?: string;
87
126
  }
88
127
  export interface LabsProviderKeys {
128
+ /** Agent runtime/platform providers. */
89
129
  ultravox?: string;
90
130
  ultravoxApiKey?: string;
91
131
  ultravox_api_key?: string;
132
+ retell?: string;
133
+ retellApiKey?: string;
134
+ retell_api_key?: string;
135
+ vapi?: string;
136
+ vapiApiKey?: string;
137
+ vapi_api_key?: string;
138
+ bland?: string;
139
+ blandApiKey?: string;
140
+ bland_api_key?: string;
141
+ livekit?: string;
142
+ livekitApiKey?: string;
143
+ livekit_api_key?: string;
144
+ livekitApiSecret?: string;
145
+ livekit_api_secret?: string;
146
+ pipecat?: string;
147
+ pipecatApiKey?: string;
148
+ pipecat_api_key?: string;
149
+ /** Telephony/carrier providers. */
150
+ twilio?: string;
151
+ twilioAccountSid?: string;
152
+ twilio_account_sid?: string;
153
+ twilioAuthToken?: string;
154
+ twilio_auth_token?: string;
155
+ twilioApiKeySid?: string;
156
+ twilio_api_key_sid?: string;
157
+ twilioApiKeySecret?: string;
158
+ twilio_api_key_secret?: string;
159
+ telnyx?: string;
160
+ telnyxApiKey?: string;
161
+ telnyx_api_key?: string;
162
+ plivo?: string;
163
+ plivoAuthId?: string;
164
+ plivo_auth_id?: string;
165
+ plivoAuthToken?: string;
166
+ plivo_auth_token?: string;
167
+ signalwire?: string;
168
+ signalwireApiToken?: string;
169
+ signalwire_api_token?: string;
170
+ signalwireProjectId?: string;
171
+ signalwire_project_id?: string;
172
+ /** TTS providers. */
92
173
  elevenlabs?: string;
93
174
  elevenlabsApiKey?: string;
94
175
  elevenlabs_api_key?: string;
@@ -101,6 +182,62 @@ export interface LabsProviderKeys {
101
182
  deepgram?: string;
102
183
  deepgramApiKey?: string;
103
184
  deepgram_api_key?: string;
185
+ /** Brain/STT providers used by Labs watcher or customer BYOK stacks. */
186
+ anthropic?: string;
187
+ anthropicApiKey?: string;
188
+ anthropic_api_key?: string;
189
+ openai?: string;
190
+ openaiApiKey?: string;
191
+ openai_api_key?: string;
192
+ xai?: string;
193
+ xaiApiKey?: string;
194
+ xai_api_key?: string;
195
+ [extra: string]: unknown;
196
+ }
197
+ export interface LabsCustomSipConfig {
198
+ sipTrunkUri?: string;
199
+ sip_trunk_uri?: string;
200
+ trunkUri?: string;
201
+ trunk_uri?: string;
202
+ sipHost?: string;
203
+ sip_host?: string;
204
+ fromNumber?: string;
205
+ from_number?: string;
206
+ username?: string;
207
+ password?: string;
208
+ transport?: string;
209
+ headers?: Record<string, string>;
210
+ codecs?: string[];
211
+ dtmfMode?: string;
212
+ dtmf_mode?: string;
213
+ metadata?: Record<string, unknown>;
214
+ [extra: string]: unknown;
215
+ }
216
+ export interface LabsProviderByokConfig {
217
+ provider?: string;
218
+ apiKey?: string;
219
+ api_key?: string;
220
+ credentials?: Record<string, unknown>;
221
+ settings?: Record<string, unknown>;
222
+ model?: string;
223
+ voiceId?: string;
224
+ voice_id?: string;
225
+ [extra: string]: unknown;
226
+ }
227
+ export interface LabsByokConfig {
228
+ providerKeys?: LabsProviderKeys;
229
+ provider_keys?: LabsProviderKeys;
230
+ agentProvider?: LabsProviderByokConfig;
231
+ agent_provider?: LabsProviderByokConfig;
232
+ runtime?: LabsProviderByokConfig;
233
+ telephony?: LabsTelephonyConfig;
234
+ tts?: LabsProviderByokConfig;
235
+ stt?: LabsProviderByokConfig;
236
+ llm?: LabsProviderByokConfig;
237
+ customSip?: LabsCustomSipConfig;
238
+ custom_sip?: LabsCustomSipConfig;
239
+ sip?: LabsCustomSipConfig;
240
+ [extra: string]: unknown;
104
241
  }
105
242
  export interface LabsTelephonyCredentials {
106
243
  accountSid?: string;
@@ -115,6 +252,20 @@ export interface LabsTelephonyCredentials {
115
252
  auth_id?: string;
116
253
  connectionId?: string;
117
254
  connection_id?: string;
255
+ telnyxConnectionId?: string;
256
+ telnyx_connection_id?: string;
257
+ signalwireSpaceUrl?: string;
258
+ signalwire_space_url?: string;
259
+ projectId?: string;
260
+ project_id?: string;
261
+ applicationId?: string;
262
+ application_id?: string;
263
+ trunkId?: string;
264
+ trunk_id?: string;
265
+ endpointId?: string;
266
+ endpoint_id?: string;
267
+ token?: string;
268
+ secret?: string;
118
269
  fromNumber?: string;
119
270
  from_number?: string;
120
271
  sipTrunkUri?: string;
@@ -125,6 +276,9 @@ export interface LabsTelephonyCredentials {
125
276
  password?: string;
126
277
  webhookSecret?: string;
127
278
  webhook_secret?: string;
279
+ customSip?: LabsCustomSipConfig;
280
+ custom_sip?: LabsCustomSipConfig;
281
+ [extra: string]: unknown;
128
282
  }
129
283
  export interface LabsTelephonyConfig {
130
284
  agencyId?: string;
@@ -132,9 +286,22 @@ export interface LabsTelephonyConfig {
132
286
  /** Default is Supafone-managed; developers do not need Twilio for this path. */
133
287
  mode?: LabsTelephonyMode;
134
288
  provider?: LabsTelephonyProvider;
289
+ /** default_pool reuses idle Supafone numbers; dedicated/premium reserve a number-month. */
290
+ numberStrategy?: LabsNumberStrategy;
291
+ number_strategy?: LabsNumberStrategy;
292
+ numberPool?: string;
293
+ number_pool?: string;
294
+ numberId?: string;
295
+ number_id?: string;
296
+ premium?: boolean;
135
297
  label?: string;
136
298
  credentials?: LabsTelephonyCredentials;
299
+ providerSettings?: Record<string, unknown>;
300
+ provider_settings?: Record<string, unknown>;
301
+ customSip?: LabsCustomSipConfig;
302
+ custom_sip?: LabsCustomSipConfig;
137
303
  metadata?: Record<string, unknown>;
304
+ [extra: string]: unknown;
138
305
  }
139
306
  export interface LabsToolsConfig {
140
307
  callRouting?: boolean;
@@ -154,11 +321,58 @@ export interface LabsToolsConfig {
154
321
  customTools?: Array<Record<string, unknown>>;
155
322
  custom_tools?: Array<Record<string, unknown>>;
156
323
  }
324
+ export interface LabsRecordingConfig {
325
+ enabled?: boolean;
326
+ recordAudio?: boolean;
327
+ record_audio?: boolean;
328
+ consentRequired?: boolean;
329
+ consent_required?: boolean;
330
+ announcement?: string;
331
+ retentionDays?: number;
332
+ retention_days?: number;
333
+ storage?: "supafone_managed" | "byok" | string;
334
+ redactPii?: boolean;
335
+ redact_pii?: boolean;
336
+ metadata?: Record<string, unknown>;
337
+ }
338
+ export interface LabsTranscriptionConfig {
339
+ enabled?: boolean;
340
+ provider?: string;
341
+ model?: string;
342
+ language?: string;
343
+ redactPii?: boolean;
344
+ redact_pii?: boolean;
345
+ diarization?: boolean;
346
+ timestamps?: boolean;
347
+ metadata?: Record<string, unknown>;
348
+ }
349
+ export interface LabsArtifactsConfig {
350
+ recordings?: boolean;
351
+ transcripts?: boolean;
352
+ summaries?: boolean;
353
+ qaReports?: boolean;
354
+ qa_reports?: boolean;
355
+ logs?: boolean;
356
+ webhooks?: boolean;
357
+ retentionDays?: number;
358
+ retention_days?: number;
359
+ metadata?: Record<string, unknown>;
360
+ }
157
361
  export interface LabsWatcherConfig {
158
362
  enabled?: boolean;
159
363
  voiceWatcher?: boolean;
160
364
  voice_watcher?: boolean;
365
+ apiKey?: string;
366
+ api_key?: string;
161
367
  model?: string;
368
+ mode?: "supafone_managed" | "byok" | string;
369
+ managedInfrastructure?: boolean;
370
+ managed_infrastructure?: boolean;
371
+ stt?: Record<string, unknown>;
372
+ llm?: Record<string, unknown>;
373
+ tts?: Record<string, unknown>;
374
+ providerKeys?: Record<string, unknown>;
375
+ provider_keys?: Record<string, unknown>;
162
376
  label?: string;
163
377
  }
164
378
  export interface LabsUltravoxRuntime {
@@ -203,6 +417,10 @@ export interface LabsUltravoxRuntime {
203
417
  retention_policy?: string;
204
418
  callTemplate?: Record<string, unknown>;
205
419
  call_template?: Record<string, unknown>;
420
+ customSip?: LabsCustomSipConfig;
421
+ custom_sip?: LabsCustomSipConfig;
422
+ sip?: LabsCustomSipConfig;
423
+ [extra: string]: unknown;
206
424
  }
207
425
  export interface CreateLabsAgentRequest {
208
426
  agencyId?: string;
@@ -225,11 +443,22 @@ export interface CreateLabsAgentRequest {
225
443
  website_url?: string;
226
444
  phoneNumber?: string;
227
445
  phone_number?: string;
446
+ numberStrategy?: LabsNumberStrategy;
447
+ number_strategy?: LabsNumberStrategy;
448
+ numberPool?: string;
449
+ number_pool?: string;
450
+ premium?: boolean;
228
451
  direction?: string;
229
452
  presetKey?: string;
230
453
  preset_key?: string;
231
454
  runtimeMode?: LabsRuntimeMode;
232
455
  runtime_mode?: LabsRuntimeMode;
456
+ /** Default true. When true, the SDK creates sensible call stages from prompt metadata. */
457
+ callStages?: boolean | LabsCallStage[];
458
+ call_stages?: boolean | LabsCallStage[];
459
+ stages?: LabsCallStage[];
460
+ autoCallStages?: boolean;
461
+ auto_call_stages?: boolean;
233
462
  goal?: string;
234
463
  greeting?: string;
235
464
  systemPrompt?: string;
@@ -238,8 +467,15 @@ export interface CreateLabsAgentRequest {
238
467
  voice?: LabsVoiceSelection;
239
468
  providerKeys?: LabsProviderKeys;
240
469
  provider_keys?: LabsProviderKeys;
241
- byok?: LabsProviderKeys;
470
+ byok?: LabsProviderKeys | LabsByokConfig;
242
471
  telephony?: LabsTelephonyConfig;
472
+ customSip?: LabsCustomSipConfig;
473
+ custom_sip?: LabsCustomSipConfig;
474
+ sip?: LabsCustomSipConfig;
475
+ recording?: LabsRecordingConfig;
476
+ transcription?: LabsTranscriptionConfig;
477
+ artifacts?: LabsArtifactsConfig;
478
+ compliance?: Record<string, unknown>;
243
479
  tools?: LabsToolsConfig;
244
480
  labs?: LabsWatcherConfig;
245
481
  ultravox?: LabsUltravoxRuntime;
@@ -256,6 +492,19 @@ export interface ListLabsAgentsOptions {
256
492
  }
257
493
  export interface GetLabsAgentOptions extends ListLabsAgentsOptions {
258
494
  }
495
+ export interface DeleteLabsAgentOptions {
496
+ agencyId?: string;
497
+ agency_id?: string;
498
+ releaseNumbers?: boolean;
499
+ release_numbers?: boolean;
500
+ }
501
+ export interface DeleteLabsAgentResponse {
502
+ success?: boolean;
503
+ deleted?: boolean;
504
+ agent_key?: string;
505
+ released_numbers?: unknown[];
506
+ [extra: string]: unknown;
507
+ }
259
508
  export interface LabsCapabilitiesResponse {
260
509
  product: string;
261
510
  api_namespace: string;
@@ -283,9 +532,50 @@ export interface LabsVoiceListResponse {
283
532
  provider_accounts?: Record<string, unknown>;
284
533
  errors?: Record<string, string>;
285
534
  }
535
+ export interface LabsCallListOptions {
536
+ agencyId?: string;
537
+ agentKey?: string;
538
+ agent_key?: string;
539
+ limit?: number;
540
+ }
541
+ export interface LabsCallArtifact {
542
+ id?: string;
543
+ call_id?: string;
544
+ agent_key?: string;
545
+ status?: string;
546
+ started_at?: string;
547
+ duration_seconds?: number;
548
+ recording_url?: string;
549
+ transcript_url?: string;
550
+ [extra: string]: unknown;
551
+ }
552
+ export interface LabsCallListResponse {
553
+ calls: LabsCallArtifact[];
554
+ [extra: string]: unknown;
555
+ }
556
+ export interface LabsRecordingListOptions extends LabsCallListOptions {
557
+ callId?: string;
558
+ call_id?: string;
559
+ }
560
+ export interface LabsRecordingListResponse {
561
+ recordings: Array<Record<string, unknown>>;
562
+ [extra: string]: unknown;
563
+ }
564
+ export interface LabsTranscriptListOptions extends LabsCallListOptions {
565
+ callId?: string;
566
+ call_id?: string;
567
+ }
568
+ export interface LabsTranscriptListResponse {
569
+ transcripts: Array<Record<string, unknown>>;
570
+ [extra: string]: unknown;
571
+ }
286
572
  export interface LabsPhoneNumberSearchOptions {
287
573
  agencyId?: string;
288
574
  agency_id?: string;
575
+ numberPool?: string;
576
+ number_pool?: string;
577
+ numberStrategy?: LabsNumberStrategy;
578
+ number_strategy?: LabsNumberStrategy;
289
579
  countryCode?: string;
290
580
  country_code?: string;
291
581
  areaCode?: string;
@@ -354,6 +644,11 @@ export interface LabsPhoneNumberProvisionRequest {
354
644
  agent_name?: string;
355
645
  presetKey?: string;
356
646
  preset_key?: string;
647
+ numberStrategy?: LabsNumberStrategy;
648
+ number_strategy?: LabsNumberStrategy;
649
+ numberPool?: string;
650
+ number_pool?: string;
651
+ premium?: boolean;
357
652
  style?: LabsAgentStyle;
358
653
  agentStyle?: LabsAgentStyle;
359
654
  agent_style?: LabsAgentStyle;
@@ -363,6 +658,14 @@ export interface LabsPhoneNumberProvisionRequest {
363
658
  }
364
659
  export interface LabsPhoneNumberAssignRequest extends Omit<LabsPhoneNumberProvisionRequest, "phoneNumber" | "phone_number" | "departmentId" | "department_id"> {
365
660
  }
661
+ export interface LabsPhoneNumberReleaseRequest {
662
+ agencyId?: string;
663
+ agency_id?: string;
664
+ reason?: string;
665
+ returnToPool?: boolean;
666
+ return_to_pool?: boolean;
667
+ metadata?: Record<string, unknown>;
668
+ }
366
669
  export interface LabsPhoneNumberProvisionResponse {
367
670
  success: boolean;
368
671
  number: LabsPhoneNumberRecord;
@@ -375,6 +678,13 @@ export interface LabsPhoneNumberAssignResponse {
375
678
  number: LabsPhoneNumberRecord;
376
679
  assignment?: Record<string, unknown>;
377
680
  }
681
+ export interface LabsPhoneNumberReleaseResponse {
682
+ success: boolean;
683
+ number?: LabsPhoneNumberRecord;
684
+ released?: boolean;
685
+ returned_to_pool?: boolean;
686
+ [extra: string]: unknown;
687
+ }
378
688
  export interface LabsPhoneNumberBuyAndAssignRequest extends LabsPhoneNumberProvisionRequest {
379
689
  search?: LabsPhoneNumberSearchOptions;
380
690
  }
@@ -508,14 +818,20 @@ export declare class SupafoneLabsError extends Error {
508
818
  export declare class SupafoneLabs {
509
819
  readonly baseUrl: string;
510
820
  readonly supafoneApiBaseUrl: string;
821
+ readonly appUrl: string;
511
822
  private readonly apiKey;
512
823
  private readonly supafoneApiKey;
513
824
  private readonly timeoutMs;
514
825
  private sessionToken?;
826
+ private accountToken?;
827
+ private accountSessionToken?;
828
+ private readonly accountEmail?;
829
+ private readonly accountPassword?;
515
830
  readonly labs: LabsNamespace;
516
831
  readonly builder: BuilderNamespace;
517
832
  readonly qa: QANamespace;
518
833
  readonly optimizer: OptimizerNamespace;
834
+ readonly campaigns: CampaignsNamespace;
519
835
  constructor(opts: SupafoneLabsOptions);
520
836
  /** True once login() (or a passed sessionToken) is in effect. */
521
837
  get isLoggedIn(): boolean;
@@ -528,6 +844,32 @@ export declare class SupafoneLabs {
528
844
  request<T>(method: string, path: string, body?: unknown, useSession?: boolean): Promise<T>;
529
845
  /** @internal Authenticated JSON request to the Supafone app API (`/api/v1/labs/*`). */
530
846
  requestSupafoneApi<T>(method: string, path: string, body?: unknown): Promise<T>;
847
+ /**
848
+ * Exchange the account email/password for a product-API JWT (the same login
849
+ * as app.supafone.ai). Called lazily by campaigns/calls — call directly only
850
+ * to fail fast.
851
+ */
852
+ accountLogin(email?: string, password?: string): Promise<string>;
853
+ /**
854
+ * @internal JSON request to the Supafone product API with the ACCOUNT JWT
855
+ * (campaigns + real calls). A minted token that expires gets one transparent
856
+ * re-login; an explicit accountToken is the caller's to refresh.
857
+ */
858
+ requestAccountApi<T>(method: string, path: string, body?: unknown): Promise<T>;
859
+ /** @internal Raw product-API request with an explicit bearer ("" = none). */
860
+ private accountHttp;
861
+ /**
862
+ * PLACE A REAL OUTBOUND PHONE CALL: dials toNumber from the account's
863
+ * calling provider and bridges the voice agent onto the line.
864
+ */
865
+ placeCall(opts: {
866
+ agentId: string;
867
+ toNumber: string;
868
+ }): Promise<PlaceCallResult>;
869
+ /** The account's voice agents — pick an agent id for campaigns/calls. */
870
+ listVoiceAgents(): Promise<{
871
+ agents: Record<string, unknown>[];
872
+ }>;
531
873
  /** Raw oracle completion — full control over messages and model. */
532
874
  oracle(req: OracleRequest): Promise<OracleResult>;
533
875
  /**
@@ -537,6 +879,8 @@ export declare class SupafoneLabs {
537
879
  whisper(transcript: string, opts?: WhisperOptions): Promise<string>;
538
880
  /** Hosted TTS — returns raw audio bytes (WAV/PCM per voice). */
539
881
  tts(text: string, voice?: string): Promise<Uint8Array>;
882
+ /** Convenience alias for voice preview UI/buttons. */
883
+ previewVoice(voice?: string, text?: string): Promise<Uint8Array>;
540
884
  /** Hosted STT for a finished audio clip — returns transcript + language tags. */
541
885
  stt(audio: Uint8Array | ArrayBuffer, opts?: {
542
886
  language?: string;
@@ -554,8 +898,10 @@ export declare class SupafoneLabs {
554
898
  usage(): Promise<UsageToday>;
555
899
  /** The auditable whisper/billing log. */
556
900
  logs(limit?: number): Promise<{
557
- logs: unknown[];
901
+ logs: LabsLogEntry[];
558
902
  }>;
903
+ /** Live audit-log stream. Works in Node 18+ and browsers via fetch streaming. */
904
+ streamLogs(opts?: StreamLogsOptions): AsyncGenerator<LabsLogEntry>;
559
905
  /** The structured whisper feed (what the console shows). */
560
906
  nudges(limit?: number): Promise<{
561
907
  nudges: unknown[];
@@ -572,6 +918,10 @@ export declare class SupafoneLabs {
572
918
  models(): Promise<string[]>;
573
919
  /** Available TTS voice ids. */
574
920
  voices(): Promise<string[]>;
921
+ /** Full hosted voice catalog with provider live/configured flags. */
922
+ voiceCatalog(): Promise<{
923
+ voices: Array<Record<string, unknown>>;
924
+ }>;
575
925
  }
576
926
  export interface LiveTranscribeOptions {
577
927
  language?: string;
@@ -598,6 +948,139 @@ declare class LiveTranscription {
598
948
  get socket(): WebSocket;
599
949
  }
600
950
  /** Programmatic hosted Supafone agents, inside the Supafone API. */
951
+ export interface PlaceCallResult {
952
+ success: boolean;
953
+ simulated?: boolean;
954
+ call_sid?: string | null;
955
+ provider?: string;
956
+ }
957
+ export interface CampaignRecipientInput {
958
+ name?: string;
959
+ phone?: string;
960
+ email?: string;
961
+ /** Warm-outreach consent — required before any voice/email touch. */
962
+ outreach_consent?: string;
963
+ [field: string]: unknown;
964
+ }
965
+ export interface CampaignSummary {
966
+ id: string;
967
+ name: string;
968
+ goal: string;
969
+ status: string;
970
+ agent_id?: string | null;
971
+ stats?: Record<string, unknown>;
972
+ settings?: Record<string, unknown>;
973
+ [field: string]: unknown;
974
+ }
975
+ export interface CampaignLiveCall {
976
+ id: string;
977
+ status: string;
978
+ /** Portal deep link to watch this call (live transcript while in flight). */
979
+ listen_url: string;
980
+ [field: string]: unknown;
981
+ }
982
+ export interface CampaignLiveView {
983
+ campaign_id: string;
984
+ in_flight: CampaignLiveCall[];
985
+ /** Developer-portal link showing this campaign's agents/calls live. */
986
+ portal_url: string;
987
+ stats?: Record<string, unknown> | null;
988
+ }
989
+ export interface CampaignUpdateInput {
990
+ name?: string;
991
+ goal?: string;
992
+ agentId?: string;
993
+ emailSubject?: string;
994
+ emailBody?: string;
995
+ cadence?: {
996
+ channel: "voice" | "email";
997
+ delay_hours: number;
998
+ }[];
999
+ settings?: Record<string, unknown>;
1000
+ }
1001
+ /**
1002
+ * Typical flow:
1003
+ * ```ts
1004
+ * const sf = new Supafone({ accountEmail, accountPassword });
1005
+ * const { agents } = await sf.listVoiceAgents();
1006
+ * const { campaign } = await sf.campaigns.create({ name: "Q3 win-back", goal: "reengage", agentId: agents[0].id });
1007
+ * await sf.campaigns.applyPreset(campaign.id, "win_back");
1008
+ * await sf.campaigns.addRecipients(campaign.id, [{ name: "Jane", phone: "+15551234567", outreach_consent: "yes" }]);
1009
+ * await sf.campaigns.launch(campaign.id);
1010
+ * const live = await sf.campaigns.live(campaign.id); // in-flight calls + portal links
1011
+ * ```
1012
+ */
1013
+ declare class CampaignsNamespace {
1014
+ private sm;
1015
+ constructor(sm: SupafoneLabs);
1016
+ list(opts?: {
1017
+ accountId?: string;
1018
+ }): Promise<{
1019
+ campaigns: CampaignSummary[];
1020
+ }>;
1021
+ create(opts?: {
1022
+ name?: string;
1023
+ goal?: string;
1024
+ agentId?: string;
1025
+ accountId?: string;
1026
+ }): Promise<{
1027
+ campaign: CampaignSummary;
1028
+ }>;
1029
+ get(campaignId: string): Promise<{
1030
+ campaign: CampaignSummary;
1031
+ }>;
1032
+ update(campaignId: string, input: CampaignUpdateInput): Promise<{
1033
+ campaign: CampaignSummary;
1034
+ }>;
1035
+ /** Add consented leads: [{name, phone, email, outreach_consent: "yes"}]. */
1036
+ addRecipients(campaignId: string, recipients: CampaignRecipientInput[]): Promise<{
1037
+ added: number;
1038
+ stats: Record<string, unknown>;
1039
+ }>;
1040
+ recipients(campaignId: string): Promise<{
1041
+ recipients: Record<string, unknown>[];
1042
+ }>;
1043
+ /** Starts REAL calls/emails on the cadence immediately. */
1044
+ launch(campaignId: string): Promise<{
1045
+ campaign: CampaignSummary;
1046
+ }>;
1047
+ pause(campaignId: string): Promise<{
1048
+ campaign: CampaignSummary;
1049
+ }>;
1050
+ /** Built-in playbooks + the account's saved custom presets. */
1051
+ presets(): Promise<{
1052
+ built_in: Record<string, unknown>[];
1053
+ custom: Record<string, unknown>[];
1054
+ }>;
1055
+ /** Materialize a preset (goal, questions, scripts, signing doc) in one write. */
1056
+ applyPreset(campaignId: string, presetId: string): Promise<{
1057
+ campaign: CampaignSummary;
1058
+ }>;
1059
+ stats(campaignId: string): Promise<{
1060
+ stats: Record<string, unknown>;
1061
+ }>;
1062
+ /** The live funnel + the campaign's most recent calls (newest first). */
1063
+ activity(campaignId: string): Promise<{
1064
+ stats?: Record<string, unknown>;
1065
+ calls?: Record<string, unknown>[];
1066
+ }>;
1067
+ /**
1068
+ * In-flight calls right now, each with a portal link to watch/listen. Poll
1069
+ * getCall(callId) (or open the link) for the transcript as it grows.
1070
+ */
1071
+ live(campaignId: string): Promise<CampaignLiveView>;
1072
+ /** One call — while in_progress the transcript grows on each poll. */
1073
+ getCall(callId: string): Promise<{
1074
+ call: Record<string, unknown>;
1075
+ }>;
1076
+ /** Mint a recipient's tracked tap-to-sign link (inherits the campaign's signing PDF). */
1077
+ createSignLink(campaignId: string, recipientId: string, opts?: {
1078
+ title?: string;
1079
+ message?: string;
1080
+ }): Promise<{
1081
+ link: Record<string, unknown>;
1082
+ }>;
1083
+ }
601
1084
  declare class LabsNamespace {
602
1085
  private sm;
603
1086
  readonly agents: LabsAgentsNamespace;
@@ -606,6 +1089,9 @@ declare class LabsNamespace {
606
1089
  readonly voices: LabsVoicesNamespace;
607
1090
  readonly phoneNumbers: LabsPhoneNumbersNamespace;
608
1091
  readonly telephony: LabsTelephonyNamespace;
1092
+ readonly calls: LabsCallsNamespace;
1093
+ readonly recordings: LabsRecordingsNamespace;
1094
+ readonly transcripts: LabsTranscriptsNamespace;
609
1095
  constructor(sm: SupafoneLabs);
610
1096
  /** Discover the Supafone convenience layer over Ultravox. */
611
1097
  capabilities(): Promise<LabsCapabilitiesResponse>;
@@ -633,6 +1119,8 @@ declare class LabsAgentsNamespace {
633
1119
  list(opts?: ListLabsAgentsOptions): Promise<ListLabsAgentsResponse>;
634
1120
  /** Fetch one durable agent by key. */
635
1121
  get(agentKey: string, opts?: GetLabsAgentOptions): Promise<GetLabsAgentResponse>;
1122
+ /** Delete an agent. Optionally ask the backend to release assigned numbers. */
1123
+ delete(agentKey: string, opts?: DeleteLabsAgentOptions): Promise<DeleteLabsAgentResponse>;
636
1124
  }
637
1125
  declare class LabsPresetsNamespace {
638
1126
  private sm;
@@ -652,6 +1140,34 @@ declare class LabsVoicesNamespace {
652
1140
  /** Supafone-managed Ultravox, Cartesia, Inworld, and ElevenLabs-compatible voices. */
653
1141
  list(opts?: LabsVoiceListOptions): Promise<LabsVoiceListResponse>;
654
1142
  }
1143
+ declare class LabsCallsNamespace {
1144
+ private sm;
1145
+ constructor(sm: SupafoneLabs);
1146
+ list(opts?: LabsCallListOptions): Promise<LabsCallListResponse>;
1147
+ get(callId: string, opts?: {
1148
+ agencyId?: string;
1149
+ }): Promise<Record<string, unknown>>;
1150
+ }
1151
+ declare class LabsRecordingsNamespace {
1152
+ private sm;
1153
+ constructor(sm: SupafoneLabs);
1154
+ list(opts?: LabsRecordingListOptions): Promise<LabsRecordingListResponse>;
1155
+ get(recordingId: string, opts?: {
1156
+ agencyId?: string;
1157
+ }): Promise<Record<string, unknown>>;
1158
+ delete(recordingId: string, opts?: {
1159
+ agencyId?: string;
1160
+ reason?: string;
1161
+ }): Promise<Record<string, unknown>>;
1162
+ }
1163
+ declare class LabsTranscriptsNamespace {
1164
+ private sm;
1165
+ constructor(sm: SupafoneLabs);
1166
+ list(opts?: LabsTranscriptListOptions): Promise<LabsTranscriptListResponse>;
1167
+ get(transcriptId: string, opts?: {
1168
+ agencyId?: string;
1169
+ }): Promise<Record<string, unknown>>;
1170
+ }
655
1171
  declare class LabsPhoneNumbersNamespace {
656
1172
  private sm;
657
1173
  constructor(sm: SupafoneLabs);
@@ -663,6 +1179,14 @@ declare class LabsPhoneNumbersNamespace {
663
1179
  buy(input: LabsPhoneNumberProvisionRequest): Promise<LabsPhoneNumberProvisionResponse>;
664
1180
  /** Attach an existing Supafone number to an inbound or outbound agent. */
665
1181
  assign(numberId: string, input?: LabsPhoneNumberAssignRequest): Promise<LabsPhoneNumberAssignResponse>;
1182
+ /** Unassign a number from an agent but keep it reserved on the account. */
1183
+ unassign(numberId: string, input?: LabsPhoneNumberReleaseRequest): Promise<LabsPhoneNumberReleaseResponse>;
1184
+ /** Give a number back to the shared pool or release the reservation. */
1185
+ release(numberId: string, input?: LabsPhoneNumberReleaseRequest): Promise<LabsPhoneNumberReleaseResponse>;
1186
+ /** Alias for release(numberId, { returnToPool: true }). */
1187
+ returnToPool(numberId: string, input?: LabsPhoneNumberReleaseRequest): Promise<LabsPhoneNumberReleaseResponse>;
1188
+ /** Delete/release a number reservation. Backend policy decides whether this is allowed. */
1189
+ delete(numberId: string, input?: LabsPhoneNumberReleaseRequest): Promise<LabsPhoneNumberReleaseResponse>;
666
1190
  /**
667
1191
  * Search if needed, buy the first matching Supafone-managed number, and assign
668
1192
  * it to the supplied agent. This is the zero-Twilio-account happy path.
@@ -732,6 +1256,7 @@ declare class OptimizerNamespace {
732
1256
  reports: unknown[];
733
1257
  }>;
734
1258
  }
1259
+ export declare function generateCallStages(input: CreateLabsAgentRequest): LabsCallStage[];
735
1260
  export { SupafoneLabs as Supafone };
736
1261
  export default SupafoneLabs;
737
1262
  //# sourceMappingURL=index.d.ts.map