@voicelayer/sdk 0.2.0 → 0.3.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
@@ -1,12 +1,131 @@
1
- import { A as AgentDTO, a as AgentStatus, b as AgentEnvironment, c as AgentContext, P as Participant, C as CallInfo, d as ProcessSchemaDTO } from './text-session-BqMWaNsN.js';
2
- export { e as AgentTurnEvent, f as AudioProfile, g as AudioSurface, h as ChannelKind, D as DtmfEvent, i as DtmfHandler, E as EndCallControllerHandle, j as EndCallOutcome, F as FakeSessionAdapter, k as FloorControlConfig, I as InboundOptions, L as LK_AGENT_STATE_MAP, M as MemoryHandle, l as MetricsEvent, N as NON_BUSY_STATES, m as ParticipantId, n as ParticipantKind, o as ParticipantSet, p as ProcessSnapshot, R as RespondOptions, q as Room, r as RouteEntry, s as RoutingRule, t as RoutingSnapshot, u as RunTextSessionOptions, v as RunTextTranscriptOptions, S as SayOptions, w as SendDtmfOptions, x as SessionAdapter, y as SessionCapabilities, z as SessionErrorEvent, B as SessionEvent, G as SessionEventMap, H as SessionFactory, J as SessionFactoryInput, K as SessionOutbound, O as SessionState, Q as SpeechResult, T as SpeechTarget, U as StateChangeEvent, V as TextSession, W as TextTranscriptResult, X as TtsVoiceConfig, Y as TurnEvent, Z as Unsubscribe, _ as UserInputEvent, $ as UserStateEvent, a0 as UserTurn, a1 as applySpeechTurnHandling, a2 as dtmfCodeToDigit, a3 as dtmfDigitToCode, a4 as duck, a5 as mute, a6 as normalizeState, m as participantId, a7 as passthrough, a8 as runTextSession, a9 as runTextTranscript, aa as transform } from './text-session-BqMWaNsN.js';
3
- import { llm } from '@livekit/agents';
1
+ import { A as AgentDTO, a as AgentStatus, b as AgentEnvironment, c as AgentContext, P as Participant, C as CallInfo, d as ProcessSchemaDTO } from './text-session-oMqJh6SF.js';
2
+ export { e as AgentTurnEvent, f as AudioProfile, g as AudioSurface, h as ChannelKind, D as DtmfEvent, i as DtmfHandler, E as EndCallControllerHandle, j as EndCallOutcome, F as FakeSessionAdapter, k as FloorControlConfig, I as InboundOptions, L as LK_AGENT_STATE_MAP, M as MemoryHandle, l as MetricsEvent, N as NON_BUSY_STATES, m as ParticipantId, n as ParticipantKind, o as ParticipantSet, p as ProcessSnapshot, R as RespondOptions, q as Room, r as RouteEntry, s as RoutingRule, t as RoutingSnapshot, u as RunTextSessionOptions, v as RunTextTranscriptOptions, S as SayOptions, w as SendDtmfOptions, x as SessionAdapter, y as SessionCapabilities, z as SessionErrorEvent, B as SessionEvent, G as SessionEventMap, H as SessionFactory, J as SessionFactoryInput, K as SessionOutbound, O as SessionState, Q as SpeechResult, T as SpeechTarget, U as StateChangeEvent, V as TextSession, W as TextTranscriptResult, X as TtsVoiceConfig, Y as TurnEvent, Z as Unsubscribe, _ as UserInputEvent, $ as UserStateEvent, a0 as UserTurn, a1 as applySpeechTurnHandling, a2 as dtmfCodeToDigit, a3 as dtmfDigitToCode, a4 as duck, a5 as mute, a6 as normalizeState, m as participantId, a7 as passthrough, a8 as runTextSession, a9 as runTextTranscript, aa as transform } from './text-session-oMqJh6SF.js';
4
3
  import { z, ZodType } from 'zod';
5
4
  import { OnQuery, BrainTransport } from './brain/index.js';
6
5
  export { BrainCallMetadata, BrainCapabilities, BrainChunk, BrainConfigError, BrainEndpointConfig, BrainMessage, BrainPubSub, BrainRequest, BrainRequestError, ConnectorChatModel, ConnectorChatModelOptions, ConnectorLLMOptions, IncomingBrainRequest, OnQueryContext, OnQueryResult, RedisBrainPubSub, SseDelta, TunnelBrainTransportOptions, assertPublicHttpsUrl, buildRedisBrainPubSub, callbackTransport, createConnectorLLM, httpBrainTransport, parseChatCompletionSse, runBrainRequest, tunnelBrainTransport } from './brain/index.js';
6
+ import '@livekit/agents';
7
7
  import 'openai';
8
8
  import 'ioredis';
9
9
 
10
+ /** What the worker fetches: the message, the conversation before it, and who sent it. */
11
+ declare const TextTurn: z.ZodObject<{
12
+ turnId: z.ZodString;
13
+ agentId: z.ZodString;
14
+ /** The Line the message came in on (`sms`, `discord`, `web`, `playground`, …). */
15
+ channel: z.ZodString;
16
+ /** The sender on that Line (phone number, Discord user, widget visitor) — the agent's caller-scoped memory key. */
17
+ from: z.ZodString;
18
+ /** The conversation this turn belongs to (stable across turns) — the tool context's call id. */
19
+ conversationKey: z.ZodString;
20
+ history: z.ZodArray<z.ZodObject<{
21
+ role: z.ZodEnum<["user", "assistant"]>;
22
+ content: z.ZodString;
23
+ }, "strip", z.ZodTypeAny, {
24
+ role: "user" | "assistant";
25
+ content: string;
26
+ }, {
27
+ role: "user" | "assistant";
28
+ content: string;
29
+ }>, "many">;
30
+ text: z.ZodString;
31
+ /** When the API stops waiting; the worker stops the run before it. */
32
+ deadlineAt: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ text: string;
35
+ agentId: string;
36
+ turnId: string;
37
+ channel: string;
38
+ from: string;
39
+ conversationKey: string;
40
+ history: {
41
+ role: "user" | "assistant";
42
+ content: string;
43
+ }[];
44
+ deadlineAt: string;
45
+ }, {
46
+ text: string;
47
+ agentId: string;
48
+ turnId: string;
49
+ channel: string;
50
+ from: string;
51
+ conversationKey: string;
52
+ history: {
53
+ role: "user" | "assistant";
54
+ content: string;
55
+ }[];
56
+ deadlineAt: string;
57
+ }>;
58
+ type TextTurn = z.infer<typeof TextTurn>;
59
+ declare const TextTurnReply: z.ZodUnion<[z.ZodObject<{
60
+ agentId: z.ZodString;
61
+ replies: z.ZodArray<z.ZodString, "many">;
62
+ usage: z.ZodDefault<z.ZodArray<z.ZodObject<{
63
+ provider: z.ZodString;
64
+ model: z.ZodString;
65
+ inputTokens: z.ZodNumber;
66
+ outputTokens: z.ZodNumber;
67
+ /** Only a first-party worker's label is used; a customer's worker runs on its own key (the API decides). */
68
+ byok: z.ZodBoolean;
69
+ }, "strip", z.ZodTypeAny, {
70
+ provider: string;
71
+ model: string;
72
+ inputTokens: number;
73
+ outputTokens: number;
74
+ byok: boolean;
75
+ }, {
76
+ provider: string;
77
+ model: string;
78
+ inputTokens: number;
79
+ outputTokens: number;
80
+ byok: boolean;
81
+ }>, "many">>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ agentId: string;
84
+ replies: string[];
85
+ usage: {
86
+ provider: string;
87
+ model: string;
88
+ inputTokens: number;
89
+ outputTokens: number;
90
+ byok: boolean;
91
+ }[];
92
+ }, {
93
+ agentId: string;
94
+ replies: string[];
95
+ usage?: {
96
+ provider: string;
97
+ model: string;
98
+ inputTokens: number;
99
+ outputTokens: number;
100
+ byok: boolean;
101
+ }[] | undefined;
102
+ }>, z.ZodObject<{
103
+ agentId: z.ZodString;
104
+ error: z.ZodObject<{
105
+ code: z.ZodEnum<["agent_unavailable", "agent_timeout"]>;
106
+ detail: z.ZodOptional<z.ZodString>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ code: "agent_unavailable" | "agent_timeout";
109
+ detail?: string | undefined;
110
+ }, {
111
+ code: "agent_unavailable" | "agent_timeout";
112
+ detail?: string | undefined;
113
+ }>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ error: {
116
+ code: "agent_unavailable" | "agent_timeout";
117
+ detail?: string | undefined;
118
+ };
119
+ agentId: string;
120
+ }, {
121
+ error: {
122
+ code: "agent_unavailable" | "agent_timeout";
123
+ detail?: string | undefined;
124
+ };
125
+ agentId: string;
126
+ }>]>;
127
+ type TextTurnReply = z.infer<typeof TextTurnReply>;
128
+
10
129
  /**
11
130
  * The plan itself. Everything the agent needs to run the call without the
12
131
  * host being present turn-by-turn.
@@ -2205,272 +2324,6 @@ interface CallOutcomeSummary {
2205
2324
  */
2206
2325
  declare function defineProcess<T extends Record<string, ProcessField>>(def: ProcessDefinition<T>): ProcessDefinition<T>;
2207
2326
 
2208
- interface RunAgentTextTranscriptOptions {
2209
- /** The agent's system prompt / instructions (its code-defined behavior). */
2210
- readonly instructions: string;
2211
- /** The LLM that generates replies — injected so this stays provider-agnostic and
2212
- * unit-testable (real inference/openai LLM in prod; a scripted fake in tests). */
2213
- readonly llm: llm.LLM;
2214
- /** Scripted caller turns, run in order; each produces the agent's reply turn(s). */
2215
- readonly messages: readonly string[];
2216
- /** Optional id surfaced on the Agent (for traceability). */
2217
- readonly agentId?: string;
2218
- }
2219
- interface AgentTextTranscriptResult {
2220
- readonly replies: string[];
2221
- }
2222
- interface RunLiveAgentTextOptions {
2223
- /** The agent's system prompt / instructions (its code-defined behavior). */
2224
- readonly instructions: string;
2225
- /** The LLM that generates replies (injected — real provider LLM or a fake). */
2226
- readonly llm: llm.LLM;
2227
- /** Optional id surfaced on the Agent (for traceability). */
2228
- readonly agentId?: string;
2229
- /**
2230
- * Labels for the model usage each turn reports (the surface that owns the reply meters it): which provider and
2231
- * model this session's LLM is, and whether the workspace's own key (BYOK) serves it. Absent ⇒ turns report no usage.
2232
- */
2233
- readonly meter?: {
2234
- readonly provider: string;
2235
- readonly model: string;
2236
- readonly byok: boolean;
2237
- };
2238
- }
2239
- /** Model usage behind one turn (one entry per model request) — the host-sdk `TurnModelUsage` shape, structurally. */
2240
- interface LiveAgentTurnUsage {
2241
- readonly provider: string;
2242
- readonly model: string;
2243
- readonly inputTokens: number;
2244
- readonly outputTokens: number;
2245
- readonly byok: boolean;
2246
- }
2247
- /** One live turn of a code-first agent: the assistant text for that turn, and
2248
- * whether the conversation ended (code-first sessions stay open until `end`). */
2249
- interface LiveAgentTurn {
2250
- readonly replies: string[];
2251
- readonly done: boolean;
2252
- /** The model requests this turn made (only when the session was given `meter` labels). */
2253
- readonly usage?: readonly LiveAgentTurnUsage[];
2254
- }
2255
- /** A live, turn-by-turn conversation with a code-first agent — the AgentSession is
2256
- * kept alive across turns (it carries chat history internally), so this is the
2257
- * code-first analogue of `runLiveTextConversation` (the flow driver). Shape
2258
- * matches the engine's AgentConversation so the agent-runner drives both alike. */
2259
- interface LiveAgentTextSession {
2260
- /** Start the session. Code-first agents don't auto-greet in no-room text mode,
2261
- * so the opening turn is empty; the first user turn produces the first reply. */
2262
- start(): Promise<LiveAgentTurn>;
2263
- /** Feed one user message; resolves with the agent's replies for that turn. */
2264
- turn(text: string): Promise<LiveAgentTurn>;
2265
- /** Close the session. */
2266
- end(): Promise<void>;
2267
- }
2268
- declare function runLiveAgentTextSession(opts: RunLiveAgentTextOptions): LiveAgentTextSession;
2269
- /** Drive an instruction-based agent over text and collect its replies. Stateless
2270
- * batch turn — built on the live driver (start → turn per message → end). */
2271
- declare function runAgentTextTranscript(opts: RunAgentTextTranscriptOptions): Promise<AgentTextTranscriptResult>;
2272
-
2273
- interface WrapOptions<T> {
2274
- /** Emit OTel spans around each method call. Default: true. */
2275
- readonly trace?: boolean;
2276
- /** Tag spans with `vl.provider.label` for easy filtering. */
2277
- readonly label?: string;
2278
- /**
2279
- * Fallback provider used if the primary throws. Accepts an instance OR a
2280
- * ProviderFactory (so `deepgram.tts(...)` works directly). The fallback is
2281
- * resolved lazily on first error.
2282
- */
2283
- readonly fallback?: T | ProviderFactory<T>;
2284
- /**
2285
- * Methods to instrument. By default the wrapper instruments every method
2286
- * call. Pass an explicit list to limit overhead on hot paths.
2287
- */
2288
- readonly methods?: readonly string[];
2289
- }
2290
- /**
2291
- * Returns either the wrapped instance directly (when called with one) or a
2292
- * ProviderFactory that produces the wrapped instance (when called with one of
2293
- * those). This keeps the lazy import story intact: `wrap(deepgram.tts(...))`
2294
- * is itself a factory.
2295
- */
2296
- declare function wrap<T extends object>(target: T | ProviderFactory<T>, options?: WrapOptions<T>): T | ProviderFactory<T>;
2297
-
2298
- interface ProviderCreds {
2299
- readonly apiKey?: string;
2300
- readonly baseURL?: string;
2301
- }
2302
- declare const deepgram: {
2303
- stt(options?: {
2304
- model?: string;
2305
- language?: string;
2306
- apiKey?: string;
2307
- baseURL?: string;
2308
- }): ProviderFactory<STTProvider>;
2309
- tts(options?: {
2310
- model?: string;
2311
- apiKey?: string;
2312
- baseURL?: string;
2313
- }): ProviderFactory<TTSProvider>;
2314
- };
2315
- declare const openai: {
2316
- llm(options?: {
2317
- model?: string;
2318
- apiKey?: string;
2319
- baseURL?: string;
2320
- }): ProviderFactory<LLMProvider>;
2321
- tts(options?: {
2322
- model?: string;
2323
- voice?: string;
2324
- instructions?: string;
2325
- apiKey?: string;
2326
- baseURL?: string;
2327
- }): ProviderFactory<TTSProvider>;
2328
- realtime(options?: {
2329
- model?: string;
2330
- voice?: string;
2331
- apiKey?: string;
2332
- baseURL?: string;
2333
- }): ProviderFactory<RealtimeProvider>;
2334
- };
2335
- declare const cartesia: {
2336
- tts(options?: {
2337
- voice?: string;
2338
- model?: string;
2339
- apiKey?: string;
2340
- baseURL?: string;
2341
- }): ProviderFactory<TTSProvider>;
2342
- stt(options?: {
2343
- model?: string;
2344
- language?: string;
2345
- apiKey?: string;
2346
- baseURL?: string;
2347
- }): ProviderFactory<STTProvider>;
2348
- };
2349
- declare const elevenlabs: {
2350
- tts(options?: {
2351
- voice?: string;
2352
- model?: string;
2353
- apiKey?: string;
2354
- baseURL?: string;
2355
- }): ProviderFactory<TTSProvider>;
2356
- };
2357
- declare const assemblyai: {
2358
- stt(options?: {
2359
- language?: string;
2360
- apiKey?: string;
2361
- baseURL?: string;
2362
- }): ProviderFactory<STTProvider>;
2363
- };
2364
- declare const google: {
2365
- llm(options?: {
2366
- model?: string;
2367
- apiKey?: string;
2368
- baseURL?: string;
2369
- }): ProviderFactory<LLMProvider>;
2370
- realtime(options?: {
2371
- model?: string;
2372
- voice?: string;
2373
- apiKey?: string;
2374
- baseURL?: string;
2375
- }): ProviderFactory<RealtimeProvider>;
2376
- };
2377
- declare const silero: {
2378
- vad(): ProviderFactory<VADProvider>;
2379
- };
2380
- declare const livekitTurn: {
2381
- english(): ProviderFactory<TurnDetectorProvider>;
2382
- multilingual(): ProviderFactory<TurnDetectorProvider>;
2383
- };
2384
- interface ConnectorLLMConfig {
2385
- /** Upstream model id / alias (defaults to the brain's own default). */
2386
- readonly model?: string;
2387
- readonly temperature?: number;
2388
- /** Spoken instead of dead air when the brain errors before replying. */
2389
- readonly fallbackText?: string;
2390
- /** In-process brain. */
2391
- readonly onQuery?: OnQuery;
2392
- /** Direct-egress brain — a public OpenAI-compatible base URL. */
2393
- readonly url?: string;
2394
- /** API key for the direct-egress endpoint. */
2395
- readonly apiKey?: string;
2396
- /** Hostnames that bypass the SSRF IP checks (direct mode). */
2397
- readonly allowHosts?: readonly string[];
2398
- /** Advanced: a custom transport (tunnel, etc.). */
2399
- readonly transport?: BrainTransport;
2400
- }
2401
- declare const connector: {
2402
- llm(config?: ConnectorLLMConfig): ProviderFactory<LLMProvider>;
2403
- };
2404
-
2405
- /** The control-plane reads the resolver needs. Structural (not the full
2406
- * VoiceLayerClient) so it stays trivially fakeable in tests — a real client
2407
- * satisfies it. */
2408
- interface AgentTextRuntimeClient {
2409
- readonly agents: {
2410
- getPrompt(agentId: string): Promise<string | null>;
2411
- getConfig(agentId: string): Promise<{
2412
- readonly model?: {
2413
- readonly provider: string;
2414
- readonly model: string;
2415
- };
2416
- readonly routingInstructions?: string | undefined;
2417
- } | null>;
2418
- };
2419
- readonly connections: {
2420
- resolveProviderCredential(provider: string): Promise<{
2421
- readonly apiKey: string;
2422
- readonly baseUrl?: string | undefined;
2423
- } | null>;
2424
- };
2425
- }
2426
- interface ResolvedAgentTextRuntime {
2427
- /** The composed system prompt (persona + routing), ready for the AgentSession. */
2428
- readonly instructions: string;
2429
- /** The concrete provider LLM that generates replies. */
2430
- readonly llm: llm.LLM;
2431
- /** Which provider/model resolved — surfaced for traceability/logging. */
2432
- readonly model: {
2433
- readonly provider: string;
2434
- readonly model: string;
2435
- };
2436
- /** True when a project BYOK key backed the LLM (vs the platform env key). */
2437
- readonly byok: boolean;
2438
- }
2439
- /** Builds the concrete provider LLM from (provider, model, BYOK creds). Injectable
2440
- * so tests can substitute a fake without loading a provider plugin. */
2441
- type BuildTextLlm = (providerId: string, modelId: string, creds: ProviderCreds | undefined) => Promise<llm.LLM>;
2442
- interface ResolveAgentTextRuntimeOptions {
2443
- /** Override the LLM build (tests). Defaults to the real provider registry. */
2444
- readonly buildLlm?: BuildTextLlm;
2445
- }
2446
- /** A code-first agent's resolved text runtime WITHOUT the built LLM — the cheap,
2447
- * shareable part (instructions + which provider/model + BYOK creds). Cache THIS
2448
- * and build a fresh LLM per session, never the LLM itself (an lk.LLM is a live
2449
- * EventEmitter — sharing one across concurrent sessions cross-fires errors). */
2450
- interface AgentTextPlan {
2451
- readonly instructions: string;
2452
- readonly provider: string;
2453
- readonly model: string;
2454
- readonly creds?: ProviderCreds;
2455
- readonly byok: boolean;
2456
- }
2457
- /**
2458
- * Resolve a code-first agent's text PLAN (instructions + provider/model + BYOK),
2459
- * or `null` when it isn't code-first-runnable (no synced prompt). No LLM built —
2460
- * this is the cacheable part. Best-effort on the pipeline: a missing/blank config
2461
- * falls back to the platform default model, mirroring the live path.
2462
- */
2463
- declare function resolveAgentTextPlan(agentId: string, client: AgentTextRuntimeClient): Promise<AgentTextPlan | null>;
2464
- /** Build a fresh provider LLM for a plan. Call once PER SESSION so no two live
2465
- * sessions ever share an lk.LLM instance. */
2466
- declare function buildTextLlm(plan: AgentTextPlan, buildLlm?: BuildTextLlm): Promise<llm.LLM>;
2467
- /**
2468
- * Resolve a code-first agent's text runtime (plan + a freshly-built LLM), or
2469
- * `null` when it isn't runnable. Convenience over resolveAgentTextPlan +
2470
- * buildTextLlm — kept for callers that want a one-shot runtime (and tests).
2471
- */
2472
- declare function resolveAgentTextRuntime(agentId: string, client: AgentTextRuntimeClient, opts?: ResolveAgentTextRuntimeOptions): Promise<ResolvedAgentTextRuntime | null>;
2473
-
2474
2327
  interface TransportOptions {
2475
2328
  readonly apiKey: string;
2476
2329
  readonly baseUrl: string;
@@ -2512,10 +2365,15 @@ interface RegisterInput {
2512
2365
  readonly processSchema?: ProcessSchemaDTO | null;
2513
2366
  /**
2514
2367
  * A code-first agent's base prompt (its `defineAgent({ prompt })`). Synced to
2515
- * the agent's record so a generic runner can run it over text by id (P2). Omit
2516
- * for flow agents (their behavior lives in the compiled program).
2368
+ * the agent's record (the dashboard shows it). Omit for flow agents (their
2369
+ * behavior lives in the compiled program).
2517
2370
  */
2518
2371
  readonly prompt?: string | null;
2372
+ /**
2373
+ * The text-turn protocol this worker speaks (burn-down G-4): it registered `<name>::text` and answers text turns as
2374
+ * the agent. Omit when it doesn't — the agent is then not text-runnable.
2375
+ */
2376
+ readonly textTurns?: number;
2519
2377
  /**
2520
2378
  * Opt this agent into MCP exposure. When true, the API upserts a matching
2521
2379
  * agent_config row keyed by (project_id, name, environment) so MCP /
@@ -2603,6 +2461,10 @@ declare class AgentsClient {
2603
2461
  * through the engine over text. Returns null on 404 or when the agent has no
2604
2462
  * synced prompt (flow agents, or agents registered before the sync landed).
2605
2463
  */
2464
+ /** A text turn dispatched to this worker (burn-down G-4); null when it's gone or isn't this agent's. */
2465
+ fetchTextTurn(turnId: string, agentId: string): Promise<TextTurn | null>;
2466
+ /** Answer a text turn. False when the API no longer waits for it (answered already, or past its deadline). */
2467
+ replyTextTurn(turnId: string, reply: TextTurnReply): Promise<boolean>;
2606
2468
  getPrompt(agentId: string): Promise<string | null>;
2607
2469
  /**
2608
2470
  * Fetch a deployed agent's PUBLISHED AgentConfig — the pipeline the owner
@@ -3165,6 +3027,8 @@ declare function formTools(vl: VoiceLayerClient, options?: FormToolsOptions): Re
3165
3027
  declare class Agent {
3166
3028
  private readonly config;
3167
3029
  private registered;
3030
+ /** Whether this process registered `<name>::text` and takes text turns (said so at registration). */
3031
+ private textTurns;
3168
3032
  private processStatePublisher;
3169
3033
  constructor(config: AgentConfig);
3170
3034
  /**
@@ -3205,41 +3069,6 @@ declare function defineFlowRuntime(opts: {
3205
3069
  readonly version?: string;
3206
3070
  }): Agent;
3207
3071
 
3208
- interface PuppetControlDeps {
3209
- /**
3210
- * LiveKit room name — used as the control-channel key. This is the only
3211
- * identifier the agent reliably has at dispatch time (the API-side
3212
- * project_calls UUID may not even exist yet when the agent boots, since
3213
- * the LK `room_started` webhook fires after dispatch).
3214
- *
3215
- * The API translates UUID → room name before publishing — see
3216
- * apps/api/src/routes/call-control.ts.
3217
- */
3218
- readonly roomName: string;
3219
- readonly session: unknown;
3220
- readonly onHangup: () => Promise<void>;
3221
- readonly onDtmf?: (digits: string) => Promise<void>;
3222
- readonly log?: (msg: string, attrs?: Record<string, unknown>) => void;
3223
- }
3224
- interface PuppetControlHandle {
3225
- /** Stop listening for commands and tear down the Redis subscription. */
3226
- close(): Promise<void>;
3227
- }
3228
- /** @deprecated since 0.2.0 — see startPuppetControl. True if we should run puppet wiring — REDIS_URL must be set. */
3229
- declare function puppetEnvAvailable(): boolean;
3230
- /**
3231
- * @deprecated since 0.2.0 (burn-down G-5): every agent now listens on its call's control channel and confirms each
3232
- * command (runtime/call-control.ts + runtime/host-control.ts). This listener never confirms, so the API refuses its
3233
- * commands. Kept for SDK consumers that call it directly; removed in the next major.
3234
- *
3235
- * Start a puppet-mode control listener for the given call. Returns a handle
3236
- * the caller invokes when the call ends to release the Redis connection.
3237
- *
3238
- * Pubsub semantics: one IORedis subscriber per call. Cheap (Valkey handles
3239
- * thousands of subscriptions per node) and isolates listener teardown from
3240
- * other calls in the same agent process.
3241
- */
3242
- declare function startPuppetControl(deps: PuppetControlDeps): Promise<PuppetControlHandle>;
3243
3072
  /**
3244
3073
  * Build a no-op LLM compatible with @livekit/agents voice.AgentSession.
3245
3074
  * Used in puppet mode to suppress autonomous replies — every STT turn
@@ -3282,6 +3111,134 @@ declare function webhook(config: WebhookConfig): ConnectorInstance<'webhook', We
3282
3111
  /** Subset of ModelConfig the Agent class converts AgentConfig.models into. */
3283
3112
  type PipelineConfig = ModelConfig;
3284
3113
 
3114
+ interface WrapOptions<T> {
3115
+ /** Emit OTel spans around each method call. Default: true. */
3116
+ readonly trace?: boolean;
3117
+ /** Tag spans with `vl.provider.label` for easy filtering. */
3118
+ readonly label?: string;
3119
+ /**
3120
+ * Fallback provider used if the primary throws. Accepts an instance OR a
3121
+ * ProviderFactory (so `deepgram.tts(...)` works directly). The fallback is
3122
+ * resolved lazily on first error.
3123
+ */
3124
+ readonly fallback?: T | ProviderFactory<T>;
3125
+ /**
3126
+ * Methods to instrument. By default the wrapper instruments every method
3127
+ * call. Pass an explicit list to limit overhead on hot paths.
3128
+ */
3129
+ readonly methods?: readonly string[];
3130
+ }
3131
+ /**
3132
+ * Returns either the wrapped instance directly (when called with one) or a
3133
+ * ProviderFactory that produces the wrapped instance (when called with one of
3134
+ * those). This keeps the lazy import story intact: `wrap(deepgram.tts(...))`
3135
+ * is itself a factory.
3136
+ */
3137
+ declare function wrap<T extends object>(target: T | ProviderFactory<T>, options?: WrapOptions<T>): T | ProviderFactory<T>;
3138
+
3139
+ declare const deepgram: {
3140
+ stt(options?: {
3141
+ model?: string;
3142
+ language?: string;
3143
+ apiKey?: string;
3144
+ baseURL?: string;
3145
+ }): ProviderFactory<STTProvider>;
3146
+ tts(options?: {
3147
+ model?: string;
3148
+ apiKey?: string;
3149
+ baseURL?: string;
3150
+ }): ProviderFactory<TTSProvider>;
3151
+ };
3152
+ declare const openai: {
3153
+ llm(options?: {
3154
+ model?: string;
3155
+ apiKey?: string;
3156
+ baseURL?: string;
3157
+ }): ProviderFactory<LLMProvider>;
3158
+ tts(options?: {
3159
+ model?: string;
3160
+ voice?: string;
3161
+ instructions?: string;
3162
+ apiKey?: string;
3163
+ baseURL?: string;
3164
+ }): ProviderFactory<TTSProvider>;
3165
+ realtime(options?: {
3166
+ model?: string;
3167
+ voice?: string;
3168
+ apiKey?: string;
3169
+ baseURL?: string;
3170
+ }): ProviderFactory<RealtimeProvider>;
3171
+ };
3172
+ declare const cartesia: {
3173
+ tts(options?: {
3174
+ voice?: string;
3175
+ model?: string;
3176
+ apiKey?: string;
3177
+ baseURL?: string;
3178
+ }): ProviderFactory<TTSProvider>;
3179
+ stt(options?: {
3180
+ model?: string;
3181
+ language?: string;
3182
+ apiKey?: string;
3183
+ baseURL?: string;
3184
+ }): ProviderFactory<STTProvider>;
3185
+ };
3186
+ declare const elevenlabs: {
3187
+ tts(options?: {
3188
+ voice?: string;
3189
+ model?: string;
3190
+ apiKey?: string;
3191
+ baseURL?: string;
3192
+ }): ProviderFactory<TTSProvider>;
3193
+ };
3194
+ declare const assemblyai: {
3195
+ stt(options?: {
3196
+ language?: string;
3197
+ apiKey?: string;
3198
+ baseURL?: string;
3199
+ }): ProviderFactory<STTProvider>;
3200
+ };
3201
+ declare const google: {
3202
+ llm(options?: {
3203
+ model?: string;
3204
+ apiKey?: string;
3205
+ baseURL?: string;
3206
+ }): ProviderFactory<LLMProvider>;
3207
+ realtime(options?: {
3208
+ model?: string;
3209
+ voice?: string;
3210
+ apiKey?: string;
3211
+ baseURL?: string;
3212
+ }): ProviderFactory<RealtimeProvider>;
3213
+ };
3214
+ declare const silero: {
3215
+ vad(): ProviderFactory<VADProvider>;
3216
+ };
3217
+ declare const livekitTurn: {
3218
+ english(): ProviderFactory<TurnDetectorProvider>;
3219
+ multilingual(): ProviderFactory<TurnDetectorProvider>;
3220
+ };
3221
+ interface ConnectorLLMConfig {
3222
+ /** Upstream model id / alias (defaults to the brain's own default). */
3223
+ readonly model?: string;
3224
+ readonly temperature?: number;
3225
+ /** Spoken instead of dead air when the brain errors before replying. */
3226
+ readonly fallbackText?: string;
3227
+ /** In-process brain. */
3228
+ readonly onQuery?: OnQuery;
3229
+ /** Direct-egress brain — a public OpenAI-compatible base URL. */
3230
+ readonly url?: string;
3231
+ /** API key for the direct-egress endpoint. */
3232
+ readonly apiKey?: string;
3233
+ /** Hostnames that bypass the SSRF IP checks (direct mode). */
3234
+ readonly allowHosts?: readonly string[];
3235
+ /** Advanced: a custom transport (tunnel, etc.). */
3236
+ readonly transport?: BrainTransport;
3237
+ }
3238
+ declare const connector: {
3239
+ llm(config?: ConnectorLLMConfig): ProviderFactory<LLMProvider>;
3240
+ };
3241
+
3285
3242
  /**
3286
3243
  * Turn the persisted `agents.process_schema` (or a freshly-compiled flow) into a
3287
3244
  * ProcessDefinition. The completion gate drives the `required` flags so the
@@ -3321,13 +3278,6 @@ interface ExchangeWorkerTokenInput {
3321
3278
  * attributable to a specific call in the API's audit log. Returns null when
3322
3279
  * the exchange isn't configured or fails — callers fall back to the env key. */
3323
3280
  declare function exchangeWorkerToken(input: ExchangeWorkerTokenInput): Promise<string | null>;
3324
- /** Build a client directly from a PRE-MINTED worker token (W3-lite control-plane
3325
- * mint). The authority (API for text, call-router for voice) minted the token
3326
- * from the projectId it already holds and handed it to the worker — so the
3327
- * worker never self-mints via /v1/internal/worker-token, closing the master-key
3328
- * path where a worker asserts its own projectId. Returns null on a bad token so
3329
- * callers can fall back to the self-mint chain (resolveWorkerClient). */
3330
- declare function workerClientFromToken(token: string): VoiceLayerClient | null;
3331
3281
  /** Build the per-call SDK client under the calling project's identity, with
3332
3282
  * the env-key fallback chain above. `md` is the parsed dispatch metadata. */
3333
3283
  declare function resolveWorkerClient(md: Record<string, unknown>, fetchImpl?: typeof fetch): Promise<VoiceLayerClient | null>;
@@ -3383,4 +3333,4 @@ interface HttpToolSpec {
3383
3333
  */
3384
3334
  declare function httpTool(spec: HttpToolSpec): Record<string, ToolDefinition>;
3385
3335
 
3386
- export { Agent, type AgentConfig, AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AgentTextPlan, type AgentTextRuntimeClient, type AgentTextTranscriptResult, type AppendDtmfEventInput, type AppendTranscriptInput, BaseTool, BrainTransport, type BuildTextLlm, type CallAttributeValue, CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, type ConnectorInstance, type ConnectorLLMConfig, ConsultationPolicy, type CreateClientOptions, type CreatedFormSession, type DefaultMetadata, type DtmfDirection, EmailClient, type SendEmailInput as EmailSendInput, type EndCallInfo, type EndCallPolicy, type EndCallTrigger, type EndpointingConfig, type EnsureCallByRoomInput, type ExchangeWorkerTokenInput, type CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type InferProcessData, type InterruptionConfig, type LLMProvider, type LiveAgentTextSession, type LiveAgentTurn, type LiveAgentTurnUsage, type MemoryConfig, type MemoryScope, type ModelConfig, OnQuery, Participant, type ParticipantsConfig, type PipelineConfig, PlansClient, type ProcessBackendAck, type ProcessDefinition, type ProcessField, type ProcessFieldType, type PronunciationDict, type ProviderFactory, type PublicFormSessionView, type PuppetControlDeps, type PuppetControlHandle, type ReadinessProbe, type ReadinessReport, type ReadinessResult, type RealtimeProvider, type RegisterInput, type RegisterOptions, type RegisteredAgent, type ResendCredentials, type ResendEmailToolOptions, type ResolveAgentTextRuntimeOptions, type ResolvedAgentTextRuntime, type RunAgentTextTranscriptOptions, type RunLiveAgentTextOptions, type STTProvider, type SecurityConfig, type SentEmail, type ShorthandPrimitive$1 as ShorthandPrimitive, type SpeechConfig, type SyncCallStateInput, type TTSProvider, type ToolDefinition$1 as ToolDefinition, type ToolInputShape$1 as ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TurnDetectorProvider, type VADProvider, VoiceLayerAuthError, type VoiceLayerClient, VoiceLayerError, VoiceLayerHttpError, VoiceLayerNetworkError, VoiceLayerValidationError, type WebhookApi, type WebhookConfig, type WrapOptions, applyPronunciations, assemblyai, asyncProbe, buildTextLlm, cartesia, collectDefaultMetadata, connector, createClient, createNoOpLLM, deepgram, defineAgent, defineFlowRuntime, defineProcess, defineTool, elevenlabs, envProbe, exchangeWorkerToken, formTools, google, httpTool, livekitTurn, mergeMetadata, openai, processSchemaToAgentParts, processSchemaToDefinition, puppetEnvAvailable, resendEmailTool, resolveAgentTextPlan, resolveAgentTextRuntime, resolveWorkerClient, runAgentTextTranscript, runLiveAgentTextSession, runProbes, silero, startPuppetControl, urlProbe, webhook, workerClientFromToken, wrap };
3336
+ export { Agent, type AgentConfig, AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AppendDtmfEventInput, type AppendTranscriptInput, BaseTool, BrainTransport, type CallAttributeValue, CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, type ConnectorInstance, type ConnectorLLMConfig, ConsultationPolicy, type CreateClientOptions, type CreatedFormSession, type DefaultMetadata, type DtmfDirection, EmailClient, type SendEmailInput as EmailSendInput, type EndCallInfo, type EndCallPolicy, type EndCallTrigger, type EndpointingConfig, type EnsureCallByRoomInput, type ExchangeWorkerTokenInput, type CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type InferProcessData, type InterruptionConfig, type LLMProvider, type MemoryConfig, type MemoryScope, type ModelConfig, OnQuery, Participant, type ParticipantsConfig, type PipelineConfig, PlansClient, type ProcessBackendAck, type ProcessDefinition, type ProcessField, type ProcessFieldType, type PronunciationDict, type ProviderFactory, type PublicFormSessionView, type ReadinessProbe, type ReadinessReport, type ReadinessResult, type RealtimeProvider, type RegisterInput, type RegisterOptions, type RegisteredAgent, type ResendCredentials, type ResendEmailToolOptions, type STTProvider, type SecurityConfig, type SentEmail, type ShorthandPrimitive$1 as ShorthandPrimitive, type SpeechConfig, type SyncCallStateInput, type TTSProvider, type ToolDefinition$1 as ToolDefinition, type ToolInputShape$1 as ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TurnDetectorProvider, type VADProvider, VoiceLayerAuthError, type VoiceLayerClient, VoiceLayerError, VoiceLayerHttpError, VoiceLayerNetworkError, VoiceLayerValidationError, type WebhookApi, type WebhookConfig, type WrapOptions, applyPronunciations, assemblyai, asyncProbe, cartesia, collectDefaultMetadata, connector, createClient, createNoOpLLM, deepgram, defineAgent, defineFlowRuntime, defineProcess, defineTool, elevenlabs, envProbe, exchangeWorkerToken, formTools, google, httpTool, livekitTurn, mergeMetadata, openai, processSchemaToAgentParts, processSchemaToDefinition, resendEmailTool, resolveWorkerClient, runProbes, silero, urlProbe, webhook, wrap };