supafone-labs 0.3.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/LICENSE +21 -0
- package/README.md +259 -0
- package/dist/cjs/index.d.ts +736 -0
- package/dist/cjs/index.js +761 -0
- package/dist/cjs/package.json +1 -0
- package/dist/index.d.ts +737 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +757 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
- package/src/index.ts +1370 -0
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supafone Labs — the agent framework behind Supafone.
|
|
3
|
+
*
|
|
4
|
+
* A dependency-free TypeScript client for creating hosted Supafone agents
|
|
5
|
+
* through the Supafone API, including managed phone numbers, voices, stages,
|
|
6
|
+
* tools, recordings, transcripts, widgets, and Supafone Pro watcher. It also
|
|
7
|
+
* includes the Labs cloud sidecar oracle, hosted TTS/STT, live multilingual
|
|
8
|
+
* transcription, telemetry, agent builder, and objective-driven optimizer.
|
|
9
|
+
*
|
|
10
|
+
* Works in Node 18+ (native fetch/WebSocket) and the browser.
|
|
11
|
+
*
|
|
12
|
+
* npm i @supafonesupafone-labs
|
|
13
|
+
*
|
|
14
|
+
* import { Supafone } from "@supafonesupafone-labs";
|
|
15
|
+
* const supafone = new Supafone({ apiKey: process.env.SUPAFONE_API_KEY! });
|
|
16
|
+
* const agent = await supafone.labs.agents.createInboundWithNumber({
|
|
17
|
+
* agentKey: "northline-intake",
|
|
18
|
+
* name: "Northline intake",
|
|
19
|
+
* number: { search: { areaCode: "415" } },
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export interface SupafoneLabsOptions {
|
|
23
|
+
/** Your key from https:/supafone-labs.supafone.ai/get-key.html */
|
|
24
|
+
apiKey: string;
|
|
25
|
+
/** Override the gateway (default: the hosted cloud). */
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
/** Supafone app/API key for hosted agent provisioning. Defaults to apiKey. */
|
|
28
|
+
supafoneApiKey?: string;
|
|
29
|
+
/** Override the Supafone API used by supafone.labs.* (default: https://api.supafone.ai). */
|
|
30
|
+
supafoneApiBaseUrl?: string;
|
|
31
|
+
/** Per-request timeout in ms (default 30_000). */
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
/** Optional pre-obtained session token (else use login()). */
|
|
34
|
+
sessionToken?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ChatMessage {
|
|
37
|
+
role: "system" | "user" | "assistant";
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
export interface OracleRequest {
|
|
41
|
+
messages: ChatMessage[];
|
|
42
|
+
/** Any claude-* / gpt-* / grok-* id, or the alias "supafone-labs-oracle". */
|
|
43
|
+
model?: string;
|
|
44
|
+
maxTokens?: number;
|
|
45
|
+
temperature?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface OracleResult {
|
|
48
|
+
text: string;
|
|
49
|
+
model: string;
|
|
50
|
+
usage?: Record<string, number>;
|
|
51
|
+
}
|
|
52
|
+
export interface WhisperOptions {
|
|
53
|
+
model?: string;
|
|
54
|
+
/** Extra operator rules folded into the coaching system prompt. */
|
|
55
|
+
guardrails?: string;
|
|
56
|
+
maxTokens?: number;
|
|
57
|
+
temperature?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface Balance {
|
|
60
|
+
plan: string;
|
|
61
|
+
seconds_remaining: number;
|
|
62
|
+
minutes_remaining: number;
|
|
63
|
+
top_up?: {
|
|
64
|
+
subscribe_monthly?: string;
|
|
65
|
+
buy_credit_pack?: string;
|
|
66
|
+
note?: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export interface UsageToday {
|
|
70
|
+
plan: string;
|
|
71
|
+
day: string;
|
|
72
|
+
usage: Record<string, {
|
|
73
|
+
used: number;
|
|
74
|
+
cap: number;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
export type LabsAgentType = "phone" | "web" | "campaign";
|
|
78
|
+
export type LabsAgentStyle = "inbound" | "outbound";
|
|
79
|
+
export type LabsRuntimeMode = "multi_stage" | "single_stage";
|
|
80
|
+
export type LabsTelephonyMode = "supafone_managed" | "byok";
|
|
81
|
+
export type LabsTelephonyProvider = "supafone" | "twilio" | "telnyx" | "plivo" | "sip" | string;
|
|
82
|
+
export interface LabsVoiceSelection {
|
|
83
|
+
provider?: string;
|
|
84
|
+
voiceId?: string;
|
|
85
|
+
voice_id?: string;
|
|
86
|
+
model?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface LabsProviderKeys {
|
|
89
|
+
ultravox?: string;
|
|
90
|
+
ultravoxApiKey?: string;
|
|
91
|
+
ultravox_api_key?: string;
|
|
92
|
+
elevenlabs?: string;
|
|
93
|
+
elevenlabsApiKey?: string;
|
|
94
|
+
elevenlabs_api_key?: string;
|
|
95
|
+
cartesia?: string;
|
|
96
|
+
cartesiaApiKey?: string;
|
|
97
|
+
cartesia_api_key?: string;
|
|
98
|
+
inworld?: string;
|
|
99
|
+
inworldApiKey?: string;
|
|
100
|
+
inworld_api_key?: string;
|
|
101
|
+
deepgram?: string;
|
|
102
|
+
deepgramApiKey?: string;
|
|
103
|
+
deepgram_api_key?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface LabsTelephonyCredentials {
|
|
106
|
+
accountSid?: string;
|
|
107
|
+
account_sid?: string;
|
|
108
|
+
authToken?: string;
|
|
109
|
+
auth_token?: string;
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
api_key?: string;
|
|
112
|
+
apiSecret?: string;
|
|
113
|
+
api_secret?: string;
|
|
114
|
+
authId?: string;
|
|
115
|
+
auth_id?: string;
|
|
116
|
+
connectionId?: string;
|
|
117
|
+
connection_id?: string;
|
|
118
|
+
fromNumber?: string;
|
|
119
|
+
from_number?: string;
|
|
120
|
+
sipTrunkUri?: string;
|
|
121
|
+
sip_trunk_uri?: string;
|
|
122
|
+
sipHost?: string;
|
|
123
|
+
sip_host?: string;
|
|
124
|
+
username?: string;
|
|
125
|
+
password?: string;
|
|
126
|
+
webhookSecret?: string;
|
|
127
|
+
webhook_secret?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface LabsTelephonyConfig {
|
|
130
|
+
agencyId?: string;
|
|
131
|
+
agency_id?: string;
|
|
132
|
+
/** Default is Supafone-managed; developers do not need Twilio for this path. */
|
|
133
|
+
mode?: LabsTelephonyMode;
|
|
134
|
+
provider?: LabsTelephonyProvider;
|
|
135
|
+
label?: string;
|
|
136
|
+
credentials?: LabsTelephonyCredentials;
|
|
137
|
+
metadata?: Record<string, unknown>;
|
|
138
|
+
}
|
|
139
|
+
export interface LabsToolsConfig {
|
|
140
|
+
callRouting?: boolean;
|
|
141
|
+
call_routing?: boolean;
|
|
142
|
+
scheduling?: boolean;
|
|
143
|
+
sms?: boolean;
|
|
144
|
+
email?: boolean;
|
|
145
|
+
intakeForms?: boolean;
|
|
146
|
+
intake_forms?: boolean;
|
|
147
|
+
firmKnowledge?: boolean;
|
|
148
|
+
firm_knowledge?: boolean;
|
|
149
|
+
existingClientLookup?: boolean;
|
|
150
|
+
existing_client_lookup?: boolean;
|
|
151
|
+
voicemail?: boolean;
|
|
152
|
+
emergencyEscalation?: boolean;
|
|
153
|
+
emergency_escalation?: boolean;
|
|
154
|
+
customTools?: Array<Record<string, unknown>>;
|
|
155
|
+
custom_tools?: Array<Record<string, unknown>>;
|
|
156
|
+
}
|
|
157
|
+
export interface LabsWatcherConfig {
|
|
158
|
+
enabled?: boolean;
|
|
159
|
+
voiceWatcher?: boolean;
|
|
160
|
+
voice_watcher?: boolean;
|
|
161
|
+
model?: string;
|
|
162
|
+
label?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface LabsUltravoxRuntime {
|
|
165
|
+
model?: string;
|
|
166
|
+
temperature?: number;
|
|
167
|
+
medium?: Record<string, unknown>;
|
|
168
|
+
vadSettings?: Record<string, unknown>;
|
|
169
|
+
vad_settings?: Record<string, unknown>;
|
|
170
|
+
speakerFirst?: boolean;
|
|
171
|
+
speaker_first?: boolean;
|
|
172
|
+
firstSpeaker?: string;
|
|
173
|
+
first_speaker?: string;
|
|
174
|
+
firstSpeakerSettings?: Record<string, unknown>;
|
|
175
|
+
first_speaker_settings?: Record<string, unknown>;
|
|
176
|
+
selectedTools?: Array<Record<string, unknown>>;
|
|
177
|
+
selected_tools?: Array<Record<string, unknown>>;
|
|
178
|
+
initialMessages?: Array<Record<string, unknown>>;
|
|
179
|
+
initial_messages?: Array<Record<string, unknown>>;
|
|
180
|
+
initialState?: Record<string, unknown>;
|
|
181
|
+
initial_state?: Record<string, unknown>;
|
|
182
|
+
initialOutputMedium?: string;
|
|
183
|
+
initial_output_medium?: string;
|
|
184
|
+
joinTimeout?: string;
|
|
185
|
+
join_timeout?: string;
|
|
186
|
+
maxDuration?: string;
|
|
187
|
+
max_duration?: string;
|
|
188
|
+
maxDurationSeconds?: number;
|
|
189
|
+
max_duration_seconds?: number;
|
|
190
|
+
timeExceededMessage?: string;
|
|
191
|
+
time_exceeded_message?: string;
|
|
192
|
+
inactivityMessages?: Array<Record<string, unknown>>;
|
|
193
|
+
inactivity_messages?: Array<Record<string, unknown>>;
|
|
194
|
+
dataConnection?: Record<string, unknown>;
|
|
195
|
+
data_connection?: Record<string, unknown>;
|
|
196
|
+
callbacks?: Record<string, unknown>;
|
|
197
|
+
metadata?: Record<string, unknown>;
|
|
198
|
+
experimentalSettings?: Record<string, unknown>;
|
|
199
|
+
experimental_settings?: Record<string, unknown>;
|
|
200
|
+
voiceOverrides?: Record<string, unknown>;
|
|
201
|
+
voice_overrides?: Record<string, unknown>;
|
|
202
|
+
retentionPolicy?: string;
|
|
203
|
+
retention_policy?: string;
|
|
204
|
+
callTemplate?: Record<string, unknown>;
|
|
205
|
+
call_template?: Record<string, unknown>;
|
|
206
|
+
}
|
|
207
|
+
export interface CreateLabsAgentRequest {
|
|
208
|
+
agencyId?: string;
|
|
209
|
+
agency_id?: string;
|
|
210
|
+
agentKey?: string;
|
|
211
|
+
agent_key?: string;
|
|
212
|
+
agentType?: LabsAgentType;
|
|
213
|
+
agent_type?: LabsAgentType;
|
|
214
|
+
/** inbound = receptionist/intake, outbound = sales/speed-to-lead/campaign. */
|
|
215
|
+
style?: LabsAgentStyle;
|
|
216
|
+
agentStyle?: LabsAgentStyle;
|
|
217
|
+
agent_style?: LabsAgentStyle;
|
|
218
|
+
name: string;
|
|
219
|
+
assistantName?: string;
|
|
220
|
+
assistant_name?: string;
|
|
221
|
+
businessName?: string;
|
|
222
|
+
business_name?: string;
|
|
223
|
+
industry?: string;
|
|
224
|
+
websiteUrl?: string;
|
|
225
|
+
website_url?: string;
|
|
226
|
+
phoneNumber?: string;
|
|
227
|
+
phone_number?: string;
|
|
228
|
+
direction?: string;
|
|
229
|
+
presetKey?: string;
|
|
230
|
+
preset_key?: string;
|
|
231
|
+
runtimeMode?: LabsRuntimeMode;
|
|
232
|
+
runtime_mode?: LabsRuntimeMode;
|
|
233
|
+
goal?: string;
|
|
234
|
+
greeting?: string;
|
|
235
|
+
systemPrompt?: string;
|
|
236
|
+
system_prompt?: string;
|
|
237
|
+
language?: string;
|
|
238
|
+
voice?: LabsVoiceSelection;
|
|
239
|
+
providerKeys?: LabsProviderKeys;
|
|
240
|
+
provider_keys?: LabsProviderKeys;
|
|
241
|
+
byok?: LabsProviderKeys;
|
|
242
|
+
telephony?: LabsTelephonyConfig;
|
|
243
|
+
tools?: LabsToolsConfig;
|
|
244
|
+
labs?: LabsWatcherConfig;
|
|
245
|
+
ultravox?: LabsUltravoxRuntime;
|
|
246
|
+
voiceWatcher?: boolean;
|
|
247
|
+
voice_watcher?: boolean;
|
|
248
|
+
voiceWatcherModel?: string;
|
|
249
|
+
voice_watcher_model?: string;
|
|
250
|
+
metadata?: Record<string, unknown>;
|
|
251
|
+
}
|
|
252
|
+
export interface ListLabsAgentsOptions {
|
|
253
|
+
agencyId?: string;
|
|
254
|
+
agentType?: LabsAgentType;
|
|
255
|
+
style?: LabsAgentStyle;
|
|
256
|
+
}
|
|
257
|
+
export interface GetLabsAgentOptions extends ListLabsAgentsOptions {
|
|
258
|
+
}
|
|
259
|
+
export interface LabsCapabilitiesResponse {
|
|
260
|
+
product: string;
|
|
261
|
+
api_namespace: string;
|
|
262
|
+
compatibility_namespace?: string;
|
|
263
|
+
default_agent_contract: Record<string, unknown>;
|
|
264
|
+
capabilities: Array<Record<string, unknown>>;
|
|
265
|
+
recommended_next_api_additions?: Array<Record<string, unknown>>;
|
|
266
|
+
[extra: string]: unknown;
|
|
267
|
+
}
|
|
268
|
+
export interface LabsPresetListResponse {
|
|
269
|
+
default_preset_key: string;
|
|
270
|
+
router_policies?: Record<string, string>;
|
|
271
|
+
presets: Array<Record<string, unknown>>;
|
|
272
|
+
}
|
|
273
|
+
export interface LabsToolListResponse {
|
|
274
|
+
tools: Array<Record<string, unknown>>;
|
|
275
|
+
}
|
|
276
|
+
export interface LabsVoiceListOptions {
|
|
277
|
+
provider?: string;
|
|
278
|
+
}
|
|
279
|
+
export interface LabsVoiceListResponse {
|
|
280
|
+
voices: Array<Record<string, unknown>>;
|
|
281
|
+
total: number;
|
|
282
|
+
providers: Array<Record<string, unknown>>;
|
|
283
|
+
provider_accounts?: Record<string, unknown>;
|
|
284
|
+
errors?: Record<string, string>;
|
|
285
|
+
}
|
|
286
|
+
export interface LabsPhoneNumberSearchOptions {
|
|
287
|
+
agencyId?: string;
|
|
288
|
+
agency_id?: string;
|
|
289
|
+
countryCode?: string;
|
|
290
|
+
country_code?: string;
|
|
291
|
+
areaCode?: string;
|
|
292
|
+
area_code?: string;
|
|
293
|
+
postalCode?: string;
|
|
294
|
+
postal_code?: string;
|
|
295
|
+
zipCode?: string;
|
|
296
|
+
zip_code?: string;
|
|
297
|
+
contains?: string;
|
|
298
|
+
numberType?: "local" | "toll_free" | "mobile" | string;
|
|
299
|
+
number_type?: string;
|
|
300
|
+
limit?: number;
|
|
301
|
+
capabilities?: string[];
|
|
302
|
+
}
|
|
303
|
+
export interface LabsPhoneNumberOption {
|
|
304
|
+
phone_number: string;
|
|
305
|
+
number_type?: string;
|
|
306
|
+
region?: string;
|
|
307
|
+
locality?: string;
|
|
308
|
+
monthly_cost?: number;
|
|
309
|
+
setup_cost?: number;
|
|
310
|
+
capabilities?: string[];
|
|
311
|
+
managed_by?: string;
|
|
312
|
+
telephony_mode?: LabsTelephonyMode | string;
|
|
313
|
+
[extra: string]: unknown;
|
|
314
|
+
}
|
|
315
|
+
export interface LabsPhoneNumberSearchResponse {
|
|
316
|
+
numbers: LabsPhoneNumberOption[];
|
|
317
|
+
search_context?: Record<string, unknown>;
|
|
318
|
+
}
|
|
319
|
+
export interface LabsPhoneNumberRecord {
|
|
320
|
+
number_id?: string;
|
|
321
|
+
phone_number?: string;
|
|
322
|
+
status?: string;
|
|
323
|
+
friendly_name?: string;
|
|
324
|
+
number_type?: string;
|
|
325
|
+
monthly_cost?: number;
|
|
326
|
+
provisioned_at?: string;
|
|
327
|
+
capabilities?: string[];
|
|
328
|
+
managed_by?: string;
|
|
329
|
+
telephony_mode?: LabsTelephonyMode | string;
|
|
330
|
+
[extra: string]: unknown;
|
|
331
|
+
}
|
|
332
|
+
export interface LabsPhoneNumberListOptions {
|
|
333
|
+
agencyId?: string;
|
|
334
|
+
activeOnly?: boolean;
|
|
335
|
+
}
|
|
336
|
+
export interface LabsPhoneNumberListResponse {
|
|
337
|
+
numbers: LabsPhoneNumberRecord[];
|
|
338
|
+
telephony?: Record<string, unknown>;
|
|
339
|
+
}
|
|
340
|
+
export interface LabsPhoneNumberProvisionRequest {
|
|
341
|
+
agencyId?: string;
|
|
342
|
+
agency_id?: string;
|
|
343
|
+
phoneNumber?: string;
|
|
344
|
+
phone_number?: string;
|
|
345
|
+
friendlyName?: string;
|
|
346
|
+
friendly_name?: string;
|
|
347
|
+
departmentId?: string;
|
|
348
|
+
department_id?: string;
|
|
349
|
+
agentKey?: string;
|
|
350
|
+
agent_key?: string;
|
|
351
|
+
agentId?: string;
|
|
352
|
+
agent_id?: string;
|
|
353
|
+
agentName?: string;
|
|
354
|
+
agent_name?: string;
|
|
355
|
+
presetKey?: string;
|
|
356
|
+
preset_key?: string;
|
|
357
|
+
style?: LabsAgentStyle;
|
|
358
|
+
agentStyle?: LabsAgentStyle;
|
|
359
|
+
agent_style?: LabsAgentStyle;
|
|
360
|
+
direction?: LabsAgentStyle;
|
|
361
|
+
telephony?: LabsTelephonyConfig;
|
|
362
|
+
metadata?: Record<string, unknown>;
|
|
363
|
+
}
|
|
364
|
+
export interface LabsPhoneNumberAssignRequest extends Omit<LabsPhoneNumberProvisionRequest, "phoneNumber" | "phone_number" | "departmentId" | "department_id"> {
|
|
365
|
+
}
|
|
366
|
+
export interface LabsPhoneNumberProvisionResponse {
|
|
367
|
+
success: boolean;
|
|
368
|
+
number: LabsPhoneNumberRecord;
|
|
369
|
+
assignment?: Record<string, unknown>;
|
|
370
|
+
telephony?: Record<string, unknown>;
|
|
371
|
+
[extra: string]: unknown;
|
|
372
|
+
}
|
|
373
|
+
export interface LabsPhoneNumberAssignResponse {
|
|
374
|
+
success: boolean;
|
|
375
|
+
number: LabsPhoneNumberRecord;
|
|
376
|
+
assignment?: Record<string, unknown>;
|
|
377
|
+
}
|
|
378
|
+
export interface LabsPhoneNumberBuyAndAssignRequest extends LabsPhoneNumberProvisionRequest {
|
|
379
|
+
search?: LabsPhoneNumberSearchOptions;
|
|
380
|
+
}
|
|
381
|
+
export interface LabsTelephonyResponse {
|
|
382
|
+
telephony: Record<string, unknown>;
|
|
383
|
+
default?: Record<string, unknown>;
|
|
384
|
+
byok?: Record<string, unknown>;
|
|
385
|
+
}
|
|
386
|
+
export interface LabsTelephonyConfigureResponse {
|
|
387
|
+
success: boolean;
|
|
388
|
+
telephony: Record<string, unknown>;
|
|
389
|
+
}
|
|
390
|
+
export interface CreateLabsAgentWithNumberRequest extends CreateLabsAgentRequest {
|
|
391
|
+
number?: LabsPhoneNumberBuyAndAssignRequest;
|
|
392
|
+
}
|
|
393
|
+
export interface CreateLabsAgentWithNumberResponse extends CreateLabsAgentResponse {
|
|
394
|
+
number?: LabsPhoneNumberProvisionResponse;
|
|
395
|
+
}
|
|
396
|
+
export interface LabsAgentResponse {
|
|
397
|
+
id?: string;
|
|
398
|
+
agency_id?: string;
|
|
399
|
+
agent_type?: LabsAgentType | string;
|
|
400
|
+
agent_key?: string;
|
|
401
|
+
source_id?: string;
|
|
402
|
+
display_name?: string;
|
|
403
|
+
runtime_mode?: string;
|
|
404
|
+
preset_key?: string;
|
|
405
|
+
profile?: Record<string, unknown>;
|
|
406
|
+
runtime?: Record<string, unknown>;
|
|
407
|
+
[extra: string]: unknown;
|
|
408
|
+
}
|
|
409
|
+
export interface CreateLabsAgentResponse {
|
|
410
|
+
success: boolean;
|
|
411
|
+
agent: LabsAgentResponse;
|
|
412
|
+
runtime: Record<string, unknown>;
|
|
413
|
+
widget?: {
|
|
414
|
+
widget_key?: string;
|
|
415
|
+
snippet?: string;
|
|
416
|
+
[extra: string]: unknown;
|
|
417
|
+
};
|
|
418
|
+
[extra: string]: unknown;
|
|
419
|
+
}
|
|
420
|
+
export interface ListLabsAgentsResponse {
|
|
421
|
+
agents: LabsAgentResponse[];
|
|
422
|
+
total: number;
|
|
423
|
+
}
|
|
424
|
+
export interface GetLabsAgentResponse {
|
|
425
|
+
agent: LabsAgentResponse;
|
|
426
|
+
}
|
|
427
|
+
export interface STTResult {
|
|
428
|
+
transcript: string;
|
|
429
|
+
languages: string[];
|
|
430
|
+
duration: number;
|
|
431
|
+
raw?: unknown;
|
|
432
|
+
}
|
|
433
|
+
/** A whisper/nudge event you log for the console feed + metrics (zero-billed). */
|
|
434
|
+
export interface NudgeEvent {
|
|
435
|
+
text: string;
|
|
436
|
+
session_id?: string;
|
|
437
|
+
provider?: string;
|
|
438
|
+
confidence?: number;
|
|
439
|
+
injected?: boolean;
|
|
440
|
+
kind?: string;
|
|
441
|
+
language?: string;
|
|
442
|
+
emotion?: string;
|
|
443
|
+
intent?: string;
|
|
444
|
+
urgency?: number;
|
|
445
|
+
latency_ms?: number;
|
|
446
|
+
model?: string;
|
|
447
|
+
turns?: number;
|
|
448
|
+
}
|
|
449
|
+
/** A post-call report — the fuel the optimizer improves against. */
|
|
450
|
+
export interface CallReportInput {
|
|
451
|
+
session_id?: string;
|
|
452
|
+
agent?: string;
|
|
453
|
+
score?: number;
|
|
454
|
+
outcome?: string;
|
|
455
|
+
summary?: string;
|
|
456
|
+
nudges?: number;
|
|
457
|
+
turns?: number;
|
|
458
|
+
language?: string;
|
|
459
|
+
[extra: string]: unknown;
|
|
460
|
+
}
|
|
461
|
+
export interface BuilderTurn {
|
|
462
|
+
role: "caller" | "agent" | "whisper";
|
|
463
|
+
text: string;
|
|
464
|
+
}
|
|
465
|
+
export interface BuilderChatResult {
|
|
466
|
+
whisper: string;
|
|
467
|
+
agent_reply: string;
|
|
468
|
+
emotion?: string;
|
|
469
|
+
language?: string;
|
|
470
|
+
intent?: string;
|
|
471
|
+
oracle_ms?: number;
|
|
472
|
+
standing_version?: number;
|
|
473
|
+
}
|
|
474
|
+
export interface QAResult {
|
|
475
|
+
agent: string;
|
|
476
|
+
turns: number;
|
|
477
|
+
results: Array<{
|
|
478
|
+
scenario: string;
|
|
479
|
+
title: string;
|
|
480
|
+
assertion: string;
|
|
481
|
+
unsupervised: {
|
|
482
|
+
passed: boolean;
|
|
483
|
+
score: number;
|
|
484
|
+
evidence: string;
|
|
485
|
+
whispers: number;
|
|
486
|
+
};
|
|
487
|
+
supervised: {
|
|
488
|
+
passed: boolean;
|
|
489
|
+
score: number;
|
|
490
|
+
evidence: string;
|
|
491
|
+
whispers: number;
|
|
492
|
+
};
|
|
493
|
+
lift: number;
|
|
494
|
+
}>;
|
|
495
|
+
summary: {
|
|
496
|
+
scenarios: number;
|
|
497
|
+
passed_supervised: number;
|
|
498
|
+
passed_unsupervised: number;
|
|
499
|
+
avg_lift: number;
|
|
500
|
+
oracle_calls_billed: number;
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
export declare class SupafoneLabsError extends Error {
|
|
504
|
+
readonly status?: number | undefined;
|
|
505
|
+
readonly body?: unknown | undefined;
|
|
506
|
+
constructor(message: string, status?: number | undefined, body?: unknown | undefined);
|
|
507
|
+
}
|
|
508
|
+
export declare class SupafoneLabs {
|
|
509
|
+
readonly baseUrl: string;
|
|
510
|
+
readonly supafoneApiBaseUrl: string;
|
|
511
|
+
private readonly apiKey;
|
|
512
|
+
private readonly supafoneApiKey;
|
|
513
|
+
private readonly timeoutMs;
|
|
514
|
+
private sessionToken?;
|
|
515
|
+
readonly labs: LabsNamespace;
|
|
516
|
+
readonly builder: BuilderNamespace;
|
|
517
|
+
readonly qa: QANamespace;
|
|
518
|
+
readonly optimizer: OptimizerNamespace;
|
|
519
|
+
constructor(opts: SupafoneLabsOptions);
|
|
520
|
+
/** True once login() (or a passed sessionToken) is in effect. */
|
|
521
|
+
get isLoggedIn(): boolean;
|
|
522
|
+
/**
|
|
523
|
+
* Exchange email/password for a console session. Required by the builder.*
|
|
524
|
+
* methods and qa.run (which are account/session-scoped, not key-scoped).
|
|
525
|
+
*/
|
|
526
|
+
login(email: string, password: string): Promise<void>;
|
|
527
|
+
/** @internal Authenticated JSON request. `useSession` prefers the login token. */
|
|
528
|
+
request<T>(method: string, path: string, body?: unknown, useSession?: boolean): Promise<T>;
|
|
529
|
+
/** @internal Authenticated JSON request to the Supafone app API (`/api/v1supafone-labs/*`). */
|
|
530
|
+
requestSupafoneApi<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
531
|
+
/** Raw oracle completion — full control over messages and model. */
|
|
532
|
+
oracle(req: OracleRequest): Promise<OracleResult>;
|
|
533
|
+
/**
|
|
534
|
+
* The one-liner: hand it the running transcript, get back a silent directive
|
|
535
|
+
* (empty string when the agent is doing fine).
|
|
536
|
+
*/
|
|
537
|
+
whisper(transcript: string, opts?: WhisperOptions): Promise<string>;
|
|
538
|
+
/** Hosted TTS — returns raw audio bytes (WAV/PCM per voice). */
|
|
539
|
+
tts(text: string, voice?: string): Promise<Uint8Array>;
|
|
540
|
+
/** Hosted STT for a finished audio clip — returns transcript + language tags. */
|
|
541
|
+
stt(audio: Uint8Array | ArrayBuffer, opts?: {
|
|
542
|
+
language?: string;
|
|
543
|
+
mimetype?: string;
|
|
544
|
+
}): Promise<STTResult>;
|
|
545
|
+
/**
|
|
546
|
+
* Open a live multilingual transcription socket. Feed PCM frames with
|
|
547
|
+
* `feed()`; language-tagged results arrive via `onResult`. Uses the global
|
|
548
|
+
* WebSocket (browser, Node 22+); pass one in `opts.WebSocketImpl` on older Node.
|
|
549
|
+
*/
|
|
550
|
+
liveTranscribe(opts?: LiveTranscribeOptions): LiveTranscription;
|
|
551
|
+
/** Remaining prepaid balance. */
|
|
552
|
+
balance(): Promise<Balance>;
|
|
553
|
+
/** Today's usage against your plan caps (oracle/tts/stt/…). */
|
|
554
|
+
usage(): Promise<UsageToday>;
|
|
555
|
+
/** The auditable whisper/billing log. */
|
|
556
|
+
logs(limit?: number): Promise<{
|
|
557
|
+
logs: unknown[];
|
|
558
|
+
}>;
|
|
559
|
+
/** The structured whisper feed (what the console shows). */
|
|
560
|
+
nudges(limit?: number): Promise<{
|
|
561
|
+
nudges: unknown[];
|
|
562
|
+
}>;
|
|
563
|
+
/** Aggregated metrics — injection rate, latency, by-dimension breakdowns. */
|
|
564
|
+
metrics(days?: number): Promise<Record<string, unknown>>;
|
|
565
|
+
/** Log one whisper event (zero-billed) for the console feed + metrics. */
|
|
566
|
+
reportNudge(event: NudgeEvent): Promise<{
|
|
567
|
+
ok?: boolean;
|
|
568
|
+
}>;
|
|
569
|
+
/** File a post-call report — the fuel optimizer.improve() learns from. */
|
|
570
|
+
reportCall(report: CallReportInput): Promise<Record<string, unknown>>;
|
|
571
|
+
/** Available oracle model ids (live vendor catalog). */
|
|
572
|
+
models(): Promise<string[]>;
|
|
573
|
+
/** Available TTS voice ids. */
|
|
574
|
+
voices(): Promise<string[]>;
|
|
575
|
+
}
|
|
576
|
+
export interface LiveTranscribeOptions {
|
|
577
|
+
language?: string;
|
|
578
|
+
encoding?: string;
|
|
579
|
+
sampleRate?: number;
|
|
580
|
+
onResult?: (r: LiveResult) => void;
|
|
581
|
+
onError?: (e: unknown) => void;
|
|
582
|
+
onClose?: () => void;
|
|
583
|
+
/** Inject a WebSocket implementation for Node < 22 (e.g. `ws`). */
|
|
584
|
+
WebSocketImpl?: typeof WebSocket;
|
|
585
|
+
}
|
|
586
|
+
export interface LiveResult {
|
|
587
|
+
transcript: string;
|
|
588
|
+
languages: string[];
|
|
589
|
+
isFinal: boolean;
|
|
590
|
+
}
|
|
591
|
+
declare class LiveTranscription {
|
|
592
|
+
private ws;
|
|
593
|
+
constructor(sm: SupafoneLabs, opts: LiveTranscribeOptions);
|
|
594
|
+
/** Send one PCM audio frame. */
|
|
595
|
+
feed(frame: Uint8Array | ArrayBuffer): void;
|
|
596
|
+
/** Signal end-of-stream and close. */
|
|
597
|
+
close(): void;
|
|
598
|
+
get socket(): WebSocket;
|
|
599
|
+
}
|
|
600
|
+
/** Programmatic hosted Supafone agents, inside the Supafone API. */
|
|
601
|
+
declare class LabsNamespace {
|
|
602
|
+
private sm;
|
|
603
|
+
readonly agents: LabsAgentsNamespace;
|
|
604
|
+
readonly presets: LabsPresetsNamespace;
|
|
605
|
+
readonly tools: LabsToolsNamespace;
|
|
606
|
+
readonly voices: LabsVoicesNamespace;
|
|
607
|
+
readonly phoneNumbers: LabsPhoneNumbersNamespace;
|
|
608
|
+
readonly telephony: LabsTelephonyNamespace;
|
|
609
|
+
constructor(sm: SupafoneLabs);
|
|
610
|
+
/** Discover the Supafone convenience layer over Ultravox. */
|
|
611
|
+
capabilities(): Promise<LabsCapabilitiesResponse>;
|
|
612
|
+
}
|
|
613
|
+
declare class LabsAgentsNamespace {
|
|
614
|
+
private sm;
|
|
615
|
+
constructor(sm: SupafoneLabs);
|
|
616
|
+
/** Spawn a durable hosted Supafone agent backed by Ultravox and Supafone-managed providers. */
|
|
617
|
+
create(input: CreateLabsAgentRequest): Promise<CreateLabsAgentResponse>;
|
|
618
|
+
/** Create an inbound receptionist/intake agent. No Twilio account is required. */
|
|
619
|
+
createInbound(input: CreateLabsAgentRequest): Promise<CreateLabsAgentResponse>;
|
|
620
|
+
/** Create an outbound sales/speed-to-lead/campaign agent. No Twilio account is required. */
|
|
621
|
+
createOutbound(input: CreateLabsAgentRequest): Promise<CreateLabsAgentResponse>;
|
|
622
|
+
/**
|
|
623
|
+
* Create an inbound agent, buy a Supafone-managed phone number, and assign it.
|
|
624
|
+
* This is the zero-Twilio-account happy path.
|
|
625
|
+
*/
|
|
626
|
+
createInboundWithNumber(input: CreateLabsAgentWithNumberRequest): Promise<CreateLabsAgentWithNumberResponse>;
|
|
627
|
+
/**
|
|
628
|
+
* Create an outbound agent, buy a Supafone-managed caller ID, and assign it.
|
|
629
|
+
* For sales teams this is the easiest path: Supafone owns telephony setup.
|
|
630
|
+
*/
|
|
631
|
+
createOutboundWithNumber(input: CreateLabsAgentWithNumberRequest): Promise<CreateLabsAgentWithNumberResponse>;
|
|
632
|
+
/** List durable agents created in the Supafone account tied to this API key. */
|
|
633
|
+
list(opts?: ListLabsAgentsOptions): Promise<ListLabsAgentsResponse>;
|
|
634
|
+
/** Fetch one durable agent by key. */
|
|
635
|
+
get(agentKey: string, opts?: GetLabsAgentOptions): Promise<GetLabsAgentResponse>;
|
|
636
|
+
}
|
|
637
|
+
declare class LabsPresetsNamespace {
|
|
638
|
+
private sm;
|
|
639
|
+
constructor(sm: SupafoneLabs);
|
|
640
|
+
/** Out-of-the-box multistage agent presets. */
|
|
641
|
+
list(): Promise<LabsPresetListResponse>;
|
|
642
|
+
}
|
|
643
|
+
declare class LabsToolsNamespace {
|
|
644
|
+
private sm;
|
|
645
|
+
constructor(sm: SupafoneLabs);
|
|
646
|
+
/** Built-in tools Supafone agents can use. */
|
|
647
|
+
list(): Promise<LabsToolListResponse>;
|
|
648
|
+
}
|
|
649
|
+
declare class LabsVoicesNamespace {
|
|
650
|
+
private sm;
|
|
651
|
+
constructor(sm: SupafoneLabs);
|
|
652
|
+
/** Supafone-managed Ultravox, Cartesia, Inworld, and ElevenLabs-compatible voices. */
|
|
653
|
+
list(opts?: LabsVoiceListOptions): Promise<LabsVoiceListResponse>;
|
|
654
|
+
}
|
|
655
|
+
declare class LabsPhoneNumbersNamespace {
|
|
656
|
+
private sm;
|
|
657
|
+
constructor(sm: SupafoneLabs);
|
|
658
|
+
/** List numbers already owned by this Supafone account. */
|
|
659
|
+
list(opts?: LabsPhoneNumberListOptions): Promise<LabsPhoneNumberListResponse>;
|
|
660
|
+
/** Search Supafone-managed inventory. This uses Supafone's master telephony account. */
|
|
661
|
+
search(opts?: LabsPhoneNumberSearchOptions): Promise<LabsPhoneNumberSearchResponse>;
|
|
662
|
+
/** Buy a Supafone-managed number. Developers do not need a Twilio account. */
|
|
663
|
+
buy(input: LabsPhoneNumberProvisionRequest): Promise<LabsPhoneNumberProvisionResponse>;
|
|
664
|
+
/** Attach an existing Supafone number to an inbound or outbound agent. */
|
|
665
|
+
assign(numberId: string, input?: LabsPhoneNumberAssignRequest): Promise<LabsPhoneNumberAssignResponse>;
|
|
666
|
+
/**
|
|
667
|
+
* Search if needed, buy the first matching Supafone-managed number, and assign
|
|
668
|
+
* it to the supplied agent. This is the zero-Twilio-account happy path.
|
|
669
|
+
*/
|
|
670
|
+
buyAndAssign(input: LabsPhoneNumberBuyAndAssignRequest): Promise<LabsPhoneNumberProvisionResponse>;
|
|
671
|
+
}
|
|
672
|
+
declare class LabsTelephonyNamespace {
|
|
673
|
+
private sm;
|
|
674
|
+
constructor(sm: SupafoneLabs);
|
|
675
|
+
/** Read the account telephony contract. Defaults to Supafone-managed. */
|
|
676
|
+
get(opts?: {
|
|
677
|
+
agencyId?: string;
|
|
678
|
+
}): Promise<LabsTelephonyResponse>;
|
|
679
|
+
/** Configure advanced BYOK telephony, or reset back to Supafone-managed. */
|
|
680
|
+
configure(input: LabsTelephonyConfig): Promise<LabsTelephonyConfigureResponse>;
|
|
681
|
+
/** Reset to the seamless default where Supafone buys and routes numbers. */
|
|
682
|
+
useSupafoneManaged(agencyId?: string): Promise<LabsTelephonyConfigureResponse>;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* The agent builder. These methods are account/session-scoped — call
|
|
686
|
+
* `login(email, password)` first, or the gateway returns 401 "Log in first".
|
|
687
|
+
*/
|
|
688
|
+
declare class BuilderNamespace {
|
|
689
|
+
private sm;
|
|
690
|
+
constructor(sm: SupafoneLabs);
|
|
691
|
+
/** One supervised builder turn: whisper + guided agent reply. */
|
|
692
|
+
chat(sessionId: string, messages: BuilderTurn[]): Promise<BuilderChatResult>;
|
|
693
|
+
/** End a test call: grades it and files a report for the optimizer. */
|
|
694
|
+
finish(sessionId: string, messages: BuilderTurn[]): Promise<{
|
|
695
|
+
score: number;
|
|
696
|
+
outcome: string;
|
|
697
|
+
summary: string;
|
|
698
|
+
}>;
|
|
699
|
+
config(): Promise<unknown>;
|
|
700
|
+
saveConfig(config: unknown): Promise<unknown>;
|
|
701
|
+
}
|
|
702
|
+
declare class QANamespace {
|
|
703
|
+
private sm;
|
|
704
|
+
constructor(sm: SupafoneLabs);
|
|
705
|
+
/**
|
|
706
|
+
* Run the adversarial QA suite, A/B (supervised vs unsupervised).
|
|
707
|
+
* Session-scoped — call login() first.
|
|
708
|
+
*/
|
|
709
|
+
run(opts?: {
|
|
710
|
+
scenarios?: string[];
|
|
711
|
+
turns?: number;
|
|
712
|
+
}): Promise<QAResult>;
|
|
713
|
+
/** Past QA runs (works with the API key). */
|
|
714
|
+
history(agent?: string, limit?: number): Promise<unknown>;
|
|
715
|
+
}
|
|
716
|
+
declare class OptimizerNamespace {
|
|
717
|
+
private sm;
|
|
718
|
+
constructor(sm: SupafoneLabs);
|
|
719
|
+
/** Improve the standing directive from accumulated call reports (OPRO-style). */
|
|
720
|
+
improve(agent?: string): Promise<{
|
|
721
|
+
version: number;
|
|
722
|
+
text: string;
|
|
723
|
+
rationale: string;
|
|
724
|
+
}>;
|
|
725
|
+
/** Fetch the current standing directive. */
|
|
726
|
+
standing(agent?: string): Promise<{
|
|
727
|
+
version: number;
|
|
728
|
+
text: string;
|
|
729
|
+
}>;
|
|
730
|
+
/** List the post-call reports behind the optimizer. */
|
|
731
|
+
reports(agent?: string, limit?: number): Promise<{
|
|
732
|
+
reports: unknown[];
|
|
733
|
+
}>;
|
|
734
|
+
}
|
|
735
|
+
export { SupafoneLabs as Supafone };
|
|
736
|
+
export default SupafoneLabs;
|