supafone-labs 0.5.4 → 0.6.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/README.md CHANGED
@@ -6,7 +6,7 @@ Use this package to create hosted Supafone agents from code: inbound
6
6
  receptionists, outbound sales agents, web agents, Supafone-managed phone
7
7
  numbers, built-in stages, tools, recordings, transcripts, widgets, and Supafone
8
8
  Pro watcher. It also includes the [Supafone Labs cloud](https://labs.supafone.ai)
9
- sidecar oracle, hosted TTS/STT, live multilingual transcription, the builder,
9
+ Supervisor, hosted TTS/STT, live multilingual transcription, the builder,
10
10
  and the adversarial QA suite.
11
11
 
12
12
  Dependency-free. Works in Node 18+ and the browser (native `fetch` / `WebSocket`).
@@ -21,7 +21,7 @@ The SDK talks to two related APIs:
21
21
 
22
22
  | Environment variable | Key shape | Used for |
23
23
  | --- | --- | --- |
24
- | `SUPAFONE_LABS_API_KEY` | `sl_live_...` | Labs cloud oracle, hosted TTS/STT, logs, usage, QA, optimizer |
24
+ | `SUPAFONE_LABS_API_KEY` | `sl_live_...` | Labs Cloud Supervisor, hosted TTS/STT, logs, usage, QA, optimizer |
25
25
  | `SUPAFONE_API_KEY` | `sf_live_...` | Hosted Supafone agents on `/api/v1/labs/*` |
26
26
 
27
27
  If you only use hosted-agent methods, `SUPAFONE_API_KEY` is enough. If you use
@@ -114,6 +114,12 @@ filtering, structured Supervisor directives, and the same configuration model
114
114
  across TypeScript and Python. Fixed language selection does not enable
115
115
  mid-call language or voice switching.
116
116
 
117
+ The canonical packet separates interpersonal guidance, the next operational
118
+ move, observed evidence, policy/tool-truth boundaries, language, confidence,
119
+ and guidance kind. See
120
+ [Programmable Supervisor Directives](../gitbook/programmable-supervisor-directives.md)
121
+ for the human-supervisor mapping and field controls.
122
+
117
123
  Agent Factory can opt into managed live language and matching-voice routing
118
124
  with one field. It remains absent and disabled for existing agents:
119
125
 
@@ -407,7 +413,7 @@ const { analysis } = await supafone.reportCall({
407
413
  ```
408
414
 
409
415
  The enriched report is filed server-side (feeding `optimizer.improve()` and
410
- `/v1/optimizer/objective/stats`); billed one oracle call per analyzed call.
416
+ `/v1/optimizer/objective/stats`); billed one Supervisor inference per analyzed call.
411
417
  Reports without a transcript — or any analysis failure — fall back to the
412
418
  plain zero-billed report. You can also classify explicitly with
413
419
  `supafone.classifyCall({ transcript, agent })`.
@@ -539,11 +545,12 @@ and `const { Supafone } = require("supafone-labs")` both work, with full types.
539
545
  | `labs.agents.syncKnowledge/detachWebsiteKnowledge/reindexKnowledge` | Managed website corpus lifecycle using `agent.id` |
540
546
  | `labs.agents.uploadKnowledgeDocument/deleteKnowledgeDocument/chatKnowledge` | Account-isolated document and grounded-query methods |
541
547
  | `labs.phoneNumbers.search/buy/assign/list/buyAndAssign` | `/api/v1/labs/phone-numbers*` |
548
+ | `labs.phoneNumbers.pool/connectPool` | Safe shared developer-number snapshot and scoped realtime stream |
542
549
  | `labs.billing.checkout/status/portal` | Stripe-hosted Checkout, payment polling, and Customer Portal |
543
550
  | `labs.telephony.get/configure/useSupafoneManaged` | `/api/v1/labs/telephony` |
544
551
  | `labs.presets.list()` · `labs.tools.list()` · `labs.voices.list()` | Supafone hosted-agent discovery |
545
- | `whisper(transcript, opts?)` | convenience over the oracle |
546
- | `oracle({ messages, model?, ... })` | `POST /v1/oracle/complete` |
552
+ | `whisper(transcript, opts?)` | Convenience over Supervisor completion and directive extraction |
553
+ | `completeWithSupervisor({ messages, model?, ... })` | `POST /v1/supervisor/complete` |
547
554
  | `tts(text, voice?)` | `POST /v1/tts` |
548
555
  | `stt(audio, opts?)` | `POST /v1/stt` |
549
556
  | `liveTranscribe(opts?)` | `WS /v1/stt/live` |
@@ -553,7 +560,19 @@ and `const { Supafone } = require("supafone-labs")` both work, with full types.
553
560
  | `qa.run/generate/suite/history` | `/v1/qa/*` |
554
561
  | `optimizer.improve/standing` | `/v1/optimizer/*` |
555
562
 
556
- Get a key (5 free minutes, no card): <https://labs.supafone.ai/get-key.html>
563
+ Get a key (five account-wide managed-runtime minutes, no card):
564
+ <https://labs.supafone.ai/get-key.html>
565
+
566
+ That allowance is shared by every key, agent, WebRTC tab, PSTN call, SDK, CLI,
567
+ and MCP client linked to the account. Managed calls reserve time atomically
568
+ before provider startup; settlement refunds unused held seconds. HTTP 402
569
+ responses expose `detail.code=managed_minutes_exhausted` and a
570
+ `checkout_endpoint`. Create Checkout with `labs.billing.checkout()`, open the
571
+ returned `checkout_url`, poll `labs.billing.status()`, and retry after payment.
572
+
573
+ The older `oracle()` method and `POST /v1/oracle/complete` route remain only as
574
+ deprecated compatibility aliases. New integrations should use
575
+ `completeWithSupervisor()` and `POST /v1/supervisor/complete`.
557
576
 
558
577
  For `dedicated` or `premium`, `labs.phoneNumbers.buy()` first returns a public
559
578
  `checkout_url`. Open it, poll `labs.billing.status()`, then call `buy()` again
@@ -4,7 +4,7 @@
4
4
  * A dependency-free TypeScript client for creating hosted Supafone agents
5
5
  * through the Supafone API, including managed phone numbers, voices, stages,
6
6
  * tools, recordings, transcripts, widgets, and Supafone Supervisor. It also
7
- * includes the Labs cloud sidecar oracle, hosted TTS/STT, live multilingual
7
+ * includes Supafone Supervisor, hosted TTS/STT, live multilingual
8
8
  * transcription, telemetry, agent builder, and objective-driven optimizer.
9
9
  *
10
10
  * Works in Node 18+ (native fetch/WebSocket) and the browser.
@@ -49,7 +49,7 @@ export interface SupafoneLabsOptions {
49
49
  * (or structured messages) first classifies the finished call against the
50
50
  * agent's objective — generating labels (achieved/missed, per-criterion
51
51
  * verdicts, failure reasons) — and files the enriched report server-side.
52
- * Billed one oracle call per analyzed call; reports without a transcript
52
+ * Billed one Supervisor inference per analyzed call; reports without a transcript
53
53
  * fall back to the plain zero-billed report.
54
54
  */
55
55
  postCallAnalysis?: boolean;
@@ -66,18 +66,22 @@ export interface ChatMessage {
66
66
  role: "system" | "user" | "assistant";
67
67
  content: string;
68
68
  }
69
- export interface OracleRequest {
69
+ export interface SupervisorRequest {
70
70
  messages: ChatMessage[];
71
- /** Any claude-* / gpt-* / grok-* id, or the alias "supafone-labs-oracle". */
71
+ /** Any supported managed/BYOK model id, or the alias "supafone-supervisor". */
72
72
  model?: string;
73
73
  maxTokens?: number;
74
74
  temperature?: number;
75
75
  }
76
- export interface OracleResult {
76
+ export interface SupervisorResult {
77
77
  text: string;
78
78
  model: string;
79
79
  usage?: Record<string, number>;
80
80
  }
81
+ /** @deprecated Use SupervisorRequest. */
82
+ export type OracleRequest = SupervisorRequest;
83
+ /** @deprecated Use SupervisorResult. */
84
+ export type OracleResult = SupervisorResult;
81
85
  export interface WhisperOptions {
82
86
  model?: string;
83
87
  /** Extra operator rules folded into the coaching system prompt. */
@@ -195,7 +199,7 @@ export interface LabsCallStage {
195
199
  next_stages?: string[];
196
200
  metadata?: Record<string, unknown>;
197
201
  }
198
- export type LabsStageGeneration = "oracle" | "template" | "off";
202
+ export type LabsStageGeneration = "managed" | "template" | "off" | "oracle";
199
203
  export interface LabsCallPlan {
200
204
  version: "supafone_call_plan_v1" | string;
201
205
  summary: string;
@@ -347,6 +351,30 @@ export interface LabsVoicePreference {
347
351
  configured_only?: boolean;
348
352
  premium?: boolean;
349
353
  }
354
+ /** Direct speech-to-speech configuration for browser previews and carrier phone calls. */
355
+ export interface LabsRealtimeSelection {
356
+ provider: "openai" | "google" | "xai";
357
+ model?: string;
358
+ voice?: string;
359
+ }
360
+ export interface LabsBrowserTestSession {
361
+ simulated: boolean;
362
+ call_id: string | null;
363
+ call_record_id?: string | null;
364
+ join_url: string | null;
365
+ stage: string;
366
+ browser_session: {
367
+ version: string;
368
+ available: boolean;
369
+ provider: string;
370
+ transport: "ultravox" | "supafone_realtime";
371
+ join_url?: string | null;
372
+ websocket_url?: string;
373
+ token?: string;
374
+ input_sample_rate?: number;
375
+ output_sample_rate?: number;
376
+ };
377
+ }
350
378
  export interface LabsProviderKeys {
351
379
  /** Agent runtime/platform providers. */
352
380
  ultravox?: string;
@@ -409,6 +437,12 @@ export interface LabsProviderKeys {
409
437
  anthropic?: string;
410
438
  anthropicApiKey?: string;
411
439
  anthropic_api_key?: string;
440
+ google?: string;
441
+ googleApiKey?: string;
442
+ google_api_key?: string;
443
+ gemini?: string;
444
+ geminiApiKey?: string;
445
+ gemini_api_key?: string;
412
446
  openai?: string;
413
447
  openaiApiKey?: string;
414
448
  openai_api_key?: string;
@@ -440,6 +474,8 @@ export interface LabsProviderByokConfig {
440
474
  provider?: string;
441
475
  apiKey?: string;
442
476
  api_key?: string;
477
+ apiKeyConfigured?: boolean;
478
+ api_key_configured?: boolean;
443
479
  credentials?: Record<string, unknown>;
444
480
  settings?: Record<string, unknown>;
445
481
  model?: string;
@@ -629,15 +665,29 @@ export interface LabsArtifactsConfig {
629
665
  retention_days?: number;
630
666
  metadata?: Record<string, unknown>;
631
667
  }
668
+ export type LabsSupervisorProvider = "anthropic" | "claude" | "openai" | "gemini" | "google" | "openrouter" | "groq" | "cerebras";
669
+ export interface LabsByokSupervisorConfig {
670
+ enabled?: boolean;
671
+ mode?: "managed" | "supafone_managed" | "byok";
672
+ provider?: LabsSupervisorProvider;
673
+ model?: string;
674
+ apiKey?: string;
675
+ api_key?: string;
676
+ apiKeyConfigured?: boolean;
677
+ api_key_configured?: boolean;
678
+ }
632
679
  export interface LabsSupervisorConfig {
633
680
  enabled?: boolean;
634
- supervisor?: boolean;
681
+ supervisor?: boolean | LabsByokSupervisorConfig;
635
682
  /** @deprecated Use supervisor. */
636
683
  voiceWatcher?: boolean;
637
684
  /** @deprecated Use supervisor. */
638
685
  voice_watcher?: boolean;
639
686
  apiKey?: string;
640
687
  api_key?: string;
688
+ apiKeyConfigured?: boolean;
689
+ api_key_configured?: boolean;
690
+ provider?: LabsSupervisorProvider;
641
691
  model?: string;
642
692
  mode?: "supafone_managed" | "byok" | string;
643
693
  managedInfrastructure?: boolean;
@@ -818,6 +868,7 @@ export interface CreateLabsAgentRequest {
818
868
  direction?: string;
819
869
  presetKey?: string;
820
870
  preset_key?: string;
871
+ realtime?: LabsRealtimeSelection;
821
872
  runtimeMode?: LabsRuntimeMode;
822
873
  runtime_mode?: LabsRuntimeMode;
823
874
  /** Defaults to Supafone's hosted planner; model credentials remain server-side. */
@@ -869,7 +920,7 @@ export interface CreateLabsAgentRequest {
869
920
  email?: LabsEmailConfig;
870
921
  labs?: LabsSupervisorConfig;
871
922
  ultravox?: LabsUltravoxRuntime;
872
- supervisor?: boolean;
923
+ supervisor?: boolean | LabsByokSupervisorConfig;
873
924
  /** @deprecated Use supervisor. */
874
925
  voiceWatcher?: boolean;
875
926
  /** @deprecated Use supervisor. */
@@ -1192,6 +1243,44 @@ export interface LabsPhoneNumberListResponse {
1192
1243
  numbers: LabsPhoneNumberRecord[];
1193
1244
  telephony?: Record<string, unknown>;
1194
1245
  }
1246
+ export type LabsSharedPhonePoolStatus = "available" | "in_use" | "cooldown" | "reserved" | "unavailable";
1247
+ export interface LabsSharedPhonePoolNumber {
1248
+ id: string;
1249
+ pool_id: string;
1250
+ pool_name: string;
1251
+ phone_number: string;
1252
+ display_name: string;
1253
+ provider: string;
1254
+ status: LabsSharedPhonePoolStatus;
1255
+ status_color: "green" | "red";
1256
+ available: boolean;
1257
+ reason: string;
1258
+ health: string;
1259
+ capabilities: string[];
1260
+ cooldown_until?: string | null;
1261
+ updated_at: string;
1262
+ }
1263
+ export interface LabsSharedPhonePoolSnapshot {
1264
+ version: "developer_phone_pool_v1" | string;
1265
+ revision: string;
1266
+ counts: {
1267
+ total: number;
1268
+ available: number;
1269
+ in_use: number;
1270
+ unavailable: number;
1271
+ };
1272
+ numbers: LabsSharedPhonePoolNumber[];
1273
+ stream?: {
1274
+ url: string;
1275
+ token: string;
1276
+ expires_in_seconds: number;
1277
+ protocol: "developer_phone_pool_v1" | string;
1278
+ };
1279
+ }
1280
+ export interface LabsPhonePoolStreamOptions {
1281
+ /** Inject a WebSocket implementation for Node versions without a global WebSocket. */
1282
+ WebSocketImpl?: typeof WebSocket;
1283
+ }
1195
1284
  export interface LabsPhoneNumberProvisionRequest {
1196
1285
  agencyId?: string;
1197
1286
  agency_id?: string;
@@ -1414,6 +1503,8 @@ export interface BuilderChatResult {
1414
1503
  emotion?: string;
1415
1504
  language?: string;
1416
1505
  intent?: string;
1506
+ supervisor_ms?: number;
1507
+ /** @deprecated Use supervisor_ms. */
1417
1508
  oracle_ms?: number;
1418
1509
  standing_version?: number;
1419
1510
  }
@@ -1455,7 +1546,9 @@ export interface QASuiteResult {
1455
1546
  passed: number;
1456
1547
  avg_ssr_score: number;
1457
1548
  ssr_histogram: Record<SSRLabel, number>;
1458
- oracle_calls_billed: number;
1549
+ supervisor_inferences_billed?: number;
1550
+ /** @deprecated Legacy server field. */
1551
+ oracle_calls_billed?: number;
1459
1552
  };
1460
1553
  }
1461
1554
  export interface QAResult {
@@ -1484,7 +1577,9 @@ export interface QAResult {
1484
1577
  passed_supervised: number;
1485
1578
  passed_unsupervised: number;
1486
1579
  avg_lift: number;
1487
- oracle_calls_billed: number;
1580
+ supervisor_inferences_billed?: number;
1581
+ /** @deprecated Legacy server field. */
1582
+ oracle_calls_billed?: number;
1488
1583
  };
1489
1584
  }
1490
1585
  export type TesterScenario = "price_probe" | "false_booking" | "language_switch" | "distressed";
@@ -1677,8 +1772,10 @@ export declare class SupafoneLabs {
1677
1772
  industry?: string;
1678
1773
  apply?: boolean;
1679
1774
  }): Promise<GenerateIntakeResult>;
1680
- /** Raw oracle completion full control over messages and model. */
1681
- oracle(req: OracleRequest): Promise<OracleResult>;
1775
+ /** Raw Supervisor completion with either Supafone-managed or BYOK inference. */
1776
+ completeWithSupervisor(req: SupervisorRequest): Promise<SupervisorResult>;
1777
+ /** @deprecated Use completeWithSupervisor(). */
1778
+ oracle(req: SupervisorRequest): Promise<SupervisorResult>;
1682
1779
  /**
1683
1780
  * The one-liner: hand it the running transcript, get back a silent directive
1684
1781
  * (empty string when the agent is doing fine).
@@ -1709,7 +1806,7 @@ export declare class SupafoneLabs {
1709
1806
  liveTranscribe(opts?: LiveTranscribeOptions): LiveTranscription;
1710
1807
  /** Remaining prepaid balance. */
1711
1808
  balance(): Promise<Balance>;
1712
- /** Today's usage against your plan caps (oracle/tts/stt/…). */
1809
+ /** Today's usage across Supervisor, TTS, STT, and managed runtime meters. */
1713
1810
  usage(): Promise<UsageToday>;
1714
1811
  /** The auditable whisper/billing log. */
1715
1812
  logs(limit?: number): Promise<{
@@ -1732,7 +1829,7 @@ export declare class SupafoneLabs {
1732
1829
  *
1733
1830
  * With `postCallAnalysis: true` on the client and a transcript (or
1734
1831
  * messages) present, the call is automatically classified first: the
1735
- * oracle labels it against the agent's objective (achieved/missed,
1832
+ * Supervisor labels it against the agent's objective (achieved/missed,
1736
1833
  * per-criterion verdicts, failure reasons) and files the enriched report
1737
1834
  * server-side. The generated labels come back on `analysis`. Analysis is
1738
1835
  * best-effort — on any failure the plain zero-billed report still lands.
@@ -1743,10 +1840,10 @@ export declare class SupafoneLabs {
1743
1840
  * objective and get labels back — achieved/missed, per-criterion verdicts,
1744
1841
  * failure reasons, and the blended objective value. Files an enriched call
1745
1842
  * report server-side (feeding optimizer.improve() and objective stats).
1746
- * Billed one oracle call.
1843
+ * Billed one Supervisor inference.
1747
1844
  */
1748
1845
  classifyCall(input: ClassifyCallInput): Promise<CallClassification>;
1749
- /** Available oracle model ids (live vendor catalog). */
1846
+ /** Available managed and BYOK Supervisor model ids. */
1750
1847
  models(): Promise<string[]>;
1751
1848
  /** Available TTS voice ids. */
1752
1849
  voices(): Promise<string[]>;
@@ -2065,6 +2162,10 @@ declare class LabsNamespace {
2065
2162
  }
2066
2163
  export type LabsBillingCheckoutKind = "plan" | "credits" | "number_addon";
2067
2164
  export interface LabsBillingCheckoutInput {
2165
+ /** Current prepaid managed-minute package SKU. */
2166
+ sku?: string;
2167
+ packageSku?: string;
2168
+ package_sku?: string;
2068
2169
  kind?: LabsBillingCheckoutKind;
2069
2170
  planKey?: "developer" | "growth" | "scale" | string;
2070
2171
  plan_key?: string;
@@ -2079,10 +2180,16 @@ export interface LabsBillingCheckoutInput {
2079
2180
  cancel_url?: string;
2080
2181
  }
2081
2182
  export interface LabsBillingCheckoutResponse {
2082
- status: "requires_payment" | "pending" | "paid" | string;
2083
- checkout_session_id: string;
2183
+ status?: "requires_payment" | "pending" | "paid" | string;
2184
+ checkout_session_id?: string;
2084
2185
  checkout_url?: string;
2085
- kind: LabsBillingCheckoutKind | string;
2186
+ /** Canonical minute-top-up Checkout URL. */
2187
+ url?: string;
2188
+ kind?: LabsBillingCheckoutKind | string;
2189
+ sku?: string;
2190
+ minutes?: number;
2191
+ amount_cents?: number;
2192
+ purchase_id?: string;
2086
2193
  plan_key?: string | null;
2087
2194
  number_strategy?: string | null;
2088
2195
  phone_number?: string | null;
@@ -2095,6 +2202,8 @@ declare class LabsBillingNamespace {
2095
2202
  constructor(sm: SupafoneLabs);
2096
2203
  /** Start hosted Stripe Checkout. MCP callers should render checkout_url as a link. */
2097
2204
  checkout(input?: LabsBillingCheckoutInput): Promise<LabsBillingCheckoutResponse>;
2205
+ /** Start Stripe Checkout for one prepaid managed-minute package. */
2206
+ topUp(sku?: string): Promise<LabsBillingCheckoutResponse>;
2098
2207
  status(checkoutSessionId: string): Promise<LabsBillingCheckoutResponse>;
2099
2208
  portal(): Promise<{
2100
2209
  url: string;
@@ -2133,6 +2242,8 @@ declare class LabsAgentsNamespace {
2133
2242
  createOutboundWithNumber(input: CreateLabsAgentWithNumberRequest): Promise<CreateLabsAgentWithNumberResponse>;
2134
2243
  /** List durable agents created in the Supafone account tied to this API key. */
2135
2244
  list(opts?: ListLabsAgentsOptions): Promise<ListLabsAgentsResponse>;
2245
+ /** Start a rate-limited authenticated browser preview for this hosted agent. */
2246
+ testCall(agentKey: string, opts?: GetLabsAgentOptions): Promise<LabsBrowserTestSession>;
2136
2247
  /** Fetch one durable agent by key. */
2137
2248
  get(agentKey: string, opts?: GetLabsAgentOptions): Promise<GetLabsAgentResponse>;
2138
2249
  /** Update an existing durable agent without changing omitted fields. */
@@ -2267,6 +2378,16 @@ declare class LabsPhoneNumbersNamespace {
2267
2378
  constructor(sm: SupafoneLabs);
2268
2379
  /** List numbers already owned by this Supafone account. */
2269
2380
  list(opts?: LabsPhoneNumberListOptions): Promise<LabsPhoneNumberListResponse>;
2381
+ /**
2382
+ * Read the explicitly enrolled shared developer-number pool. This inventory
2383
+ * never infers customer or merely-unassigned numbers into the response.
2384
+ */
2385
+ pool(): Promise<LabsSharedPhonePoolSnapshot>;
2386
+ /**
2387
+ * Connect to realtime pool state using a short-lived pool-only token. The
2388
+ * Supafone API key is never placed in the WebSocket URL.
2389
+ */
2390
+ connectPool(opts?: LabsPhonePoolStreamOptions): Promise<WebSocket>;
2270
2391
  /** Search Supafone-managed inventory. This uses Supafone's master telephony account. */
2271
2392
  search(opts?: LabsPhoneNumberSearchOptions): Promise<LabsPhoneNumberSearchResponse>;
2272
2393
  /**