@voicelayer/sdk 0.1.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 +201 -0
- package/README.md +286 -0
- package/dist/index.d.ts +4305 -0
- package/dist/index.js +11177 -0
- package/dist/index.js.map +1 -0
- package/package.json +130 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4305 @@
|
|
|
1
|
+
import { z, ZodType } from 'zod';
|
|
2
|
+
import { JobContext, voice } from '@livekit/agents';
|
|
3
|
+
|
|
4
|
+
declare const brand: unique symbol;
|
|
5
|
+
type Brand<T, B> = T & {
|
|
6
|
+
readonly [brand]: B;
|
|
7
|
+
};
|
|
8
|
+
type TenantId = Brand<string, 'TenantId'>;
|
|
9
|
+
declare const TenantId: (s: string) => TenantId;
|
|
10
|
+
type CallId = Brand<string, 'CallId'>;
|
|
11
|
+
declare const CallId: (s: string) => CallId;
|
|
12
|
+
type ModuleId = Brand<string, 'ModuleId'>;
|
|
13
|
+
declare const ModuleId: (s: string) => ModuleId;
|
|
14
|
+
|
|
15
|
+
declare const participantBrand: unique symbol;
|
|
16
|
+
type ParticipantId = string & {
|
|
17
|
+
readonly [participantBrand]: 'ParticipantId';
|
|
18
|
+
};
|
|
19
|
+
declare const ParticipantId: (s: string) => ParticipantId;
|
|
20
|
+
/**
|
|
21
|
+
* How this participant is connected to the room. Determines which transport
|
|
22
|
+
* adapter owns the underlying media track.
|
|
23
|
+
* - `sip` — PSTN-side via LiveKit SIP (Twilio/Telnyx trunk)
|
|
24
|
+
* - `webrtc` — browser/native WebRTC peer
|
|
25
|
+
* - `agent` — the AI agent itself (server-published track)
|
|
26
|
+
* - `bridge` — incoming non-WebRTC ingress (e.g. an Egress recorder)
|
|
27
|
+
*/
|
|
28
|
+
type ParticipantKind = 'sip' | 'webrtc' | 'agent' | 'bridge';
|
|
29
|
+
/**
|
|
30
|
+
* One participant in a room. Snapshot semantics: callers read from
|
|
31
|
+
* `ParticipantSet`, which owns lifecycle. Fields are readonly because
|
|
32
|
+
* mutations must go through the routing primitive to stay observable.
|
|
33
|
+
*/
|
|
34
|
+
interface Participant {
|
|
35
|
+
readonly id: ParticipantId;
|
|
36
|
+
readonly kind: ParticipantKind;
|
|
37
|
+
/** True iff `kind === 'agent'`. Convenience for filtering. */
|
|
38
|
+
readonly isAgent: boolean;
|
|
39
|
+
/** E.164 when known (always for SIP, never for agent, sometimes for WebRTC). */
|
|
40
|
+
readonly phone: string | null;
|
|
41
|
+
/** Human-readable label (caller name, agent name). */
|
|
42
|
+
readonly displayName: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Free-form attributes attached by the dispatcher or runtime. Standardised
|
|
45
|
+
* keys the platform reads:
|
|
46
|
+
* - `lang` — BCP-47 (e.g. `en-US`, `es-MX`). Used by audio-experience.
|
|
47
|
+
* - `role` — e.g. `claimant`, `witness`, `interpreter`. Used by handoff.
|
|
48
|
+
* - `tier` — e.g. `vip`, `standard`. Used by audio-experience.
|
|
49
|
+
*/
|
|
50
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
51
|
+
readonly joinedAt: Date;
|
|
52
|
+
/** Set when the participant has left. Stays in the set until call end. */
|
|
53
|
+
readonly leftAt: Date | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Live view of room participants. The agent-worker owns the underlying
|
|
57
|
+
* collection; primitives consume it read-only. Snapshot semantics: methods
|
|
58
|
+
* return arrays/values valid at call time. The set itself updates in place
|
|
59
|
+
* as participants join/leave — re-call to see new state.
|
|
60
|
+
*/
|
|
61
|
+
interface ParticipantSet {
|
|
62
|
+
/** All participants ever in the room, including those who have left. */
|
|
63
|
+
readonly all: readonly Participant[];
|
|
64
|
+
/** Currently-connected, non-agent participants. */
|
|
65
|
+
readonly humans: readonly Participant[];
|
|
66
|
+
/** Currently-connected agents. Usually exactly one. */
|
|
67
|
+
readonly agents: readonly Participant[];
|
|
68
|
+
readonly size: number;
|
|
69
|
+
get(id: ParticipantId): Participant | undefined;
|
|
70
|
+
where(pred: (p: Participant) => boolean): readonly Participant[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The call container. One Room per call. Replaces the singular call+caller
|
|
74
|
+
* model for multi-participant primitives; existing single-caller primitives
|
|
75
|
+
* keep reading CallContext.callerId until migrated.
|
|
76
|
+
*/
|
|
77
|
+
interface Room {
|
|
78
|
+
readonly id: CallId;
|
|
79
|
+
readonly tenantId: TenantId;
|
|
80
|
+
readonly moduleId: ModuleId;
|
|
81
|
+
readonly startedAt: Date;
|
|
82
|
+
readonly participants: ParticipantSet;
|
|
83
|
+
/** Dispatch metadata (LK job metadata) — projectId, agentId, etc. */
|
|
84
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare const AgentEnvironment: z.ZodEnum<["dev", "stg", "prd"]>;
|
|
88
|
+
type AgentEnvironment = z.infer<typeof AgentEnvironment>;
|
|
89
|
+
declare const AgentStatus: z.ZodEnum<["online", "offline", "degraded"]>;
|
|
90
|
+
type AgentStatus = z.infer<typeof AgentStatus>;
|
|
91
|
+
declare const ProcessSchemaDTO: z.ZodObject<{
|
|
92
|
+
id: z.ZodString;
|
|
93
|
+
prompts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
text: z.ZodString;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
id: string;
|
|
98
|
+
text: string;
|
|
99
|
+
}, {
|
|
100
|
+
id: string;
|
|
101
|
+
text: string;
|
|
102
|
+
}>, "many">>;
|
|
103
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
104
|
+
name: z.ZodString;
|
|
105
|
+
required: z.ZodBoolean;
|
|
106
|
+
type: z.ZodEnum<["string", "string[]", "number", "boolean", "datetime", "email", "phone"]>;
|
|
107
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
108
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
111
|
+
ask: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
114
|
+
name: string;
|
|
115
|
+
required: boolean;
|
|
116
|
+
ask?: string | undefined;
|
|
117
|
+
pattern?: string | undefined;
|
|
118
|
+
min?: number | undefined;
|
|
119
|
+
max?: number | undefined;
|
|
120
|
+
enum?: string[] | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
123
|
+
name: string;
|
|
124
|
+
required: boolean;
|
|
125
|
+
ask?: string | undefined;
|
|
126
|
+
pattern?: string | undefined;
|
|
127
|
+
min?: number | undefined;
|
|
128
|
+
max?: number | undefined;
|
|
129
|
+
enum?: string[] | undefined;
|
|
130
|
+
}>, "many">;
|
|
131
|
+
completionGate: z.ZodObject<{
|
|
132
|
+
requiredFields: z.ZodArray<z.ZodString, "many">;
|
|
133
|
+
backendAck: z.ZodOptional<z.ZodObject<{
|
|
134
|
+
url: z.ZodString;
|
|
135
|
+
timeoutMs: z.ZodNumber;
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
url: string;
|
|
138
|
+
timeoutMs: number;
|
|
139
|
+
}, {
|
|
140
|
+
url: string;
|
|
141
|
+
timeoutMs: number;
|
|
142
|
+
}>>;
|
|
143
|
+
}, "strip", z.ZodTypeAny, {
|
|
144
|
+
requiredFields: string[];
|
|
145
|
+
backendAck?: {
|
|
146
|
+
url: string;
|
|
147
|
+
timeoutMs: number;
|
|
148
|
+
} | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
requiredFields: string[];
|
|
151
|
+
backendAck?: {
|
|
152
|
+
url: string;
|
|
153
|
+
timeoutMs: number;
|
|
154
|
+
} | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
on: z.ZodString;
|
|
159
|
+
then: z.ZodString;
|
|
160
|
+
onlyWhile: z.ZodOptional<z.ZodString>;
|
|
161
|
+
}, "strip", z.ZodTypeAny, {
|
|
162
|
+
then: string;
|
|
163
|
+
name: string;
|
|
164
|
+
on: string;
|
|
165
|
+
onlyWhile?: string | undefined;
|
|
166
|
+
}, {
|
|
167
|
+
then: string;
|
|
168
|
+
name: string;
|
|
169
|
+
on: string;
|
|
170
|
+
onlyWhile?: string | undefined;
|
|
171
|
+
}>, "many">>;
|
|
172
|
+
handoff: z.ZodOptional<z.ZodObject<{
|
|
173
|
+
fallback: z.ZodOptional<z.ZodString>;
|
|
174
|
+
routes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
fallback?: string | undefined;
|
|
177
|
+
routes?: Record<string, string> | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
fallback?: string | undefined;
|
|
180
|
+
routes?: Record<string, string> | undefined;
|
|
181
|
+
}>>;
|
|
182
|
+
memory: z.ZodOptional<z.ZodObject<{
|
|
183
|
+
scope: z.ZodOptional<z.ZodEnum<["call", "caller", "participant", "account", "platform"]>>;
|
|
184
|
+
retentionDays: z.ZodOptional<z.ZodNumber>;
|
|
185
|
+
piiFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
188
|
+
retentionDays?: number | undefined;
|
|
189
|
+
piiFields?: string[] | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
192
|
+
retentionDays?: number | undefined;
|
|
193
|
+
piiFields?: string[] | undefined;
|
|
194
|
+
}>>;
|
|
195
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
196
|
+
name: z.ZodString;
|
|
197
|
+
description: z.ZodString;
|
|
198
|
+
input: z.ZodRecord<z.ZodString, z.ZodEnum<["string", "number", "boolean"]>>;
|
|
199
|
+
url: z.ZodString;
|
|
200
|
+
method: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>;
|
|
201
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
202
|
+
auth: z.ZodEnum<["none", "connection"]>;
|
|
203
|
+
connectionRef: z.ZodOptional<z.ZodString>;
|
|
204
|
+
}, "strip", z.ZodTypeAny, {
|
|
205
|
+
name: string;
|
|
206
|
+
description: string;
|
|
207
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
208
|
+
url: string;
|
|
209
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
210
|
+
auth: "none" | "connection";
|
|
211
|
+
headers?: Record<string, string> | undefined;
|
|
212
|
+
connectionRef?: string | undefined;
|
|
213
|
+
}, {
|
|
214
|
+
name: string;
|
|
215
|
+
description: string;
|
|
216
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
217
|
+
url: string;
|
|
218
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
219
|
+
auth: "none" | "connection";
|
|
220
|
+
headers?: Record<string, string> | undefined;
|
|
221
|
+
connectionRef?: string | undefined;
|
|
222
|
+
}>, "many">>;
|
|
223
|
+
program: z.ZodOptional<z.ZodObject<{
|
|
224
|
+
v: z.ZodLiteral<1>;
|
|
225
|
+
id: z.ZodString;
|
|
226
|
+
entry: z.ZodArray<z.ZodString, "many">;
|
|
227
|
+
nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
228
|
+
id: z.ZodString;
|
|
229
|
+
type: z.ZodEnum<["say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "route", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
|
|
230
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
231
|
+
out: z.ZodArray<z.ZodObject<{
|
|
232
|
+
to: z.ZodString;
|
|
233
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
234
|
+
sourceHandle: z.ZodOptional<z.ZodString>;
|
|
235
|
+
label: z.ZodOptional<z.ZodString>;
|
|
236
|
+
}, "strip", z.ZodTypeAny, {
|
|
237
|
+
to: string;
|
|
238
|
+
sourceHandle?: string | undefined;
|
|
239
|
+
label?: string | undefined;
|
|
240
|
+
condition?: string | undefined;
|
|
241
|
+
}, {
|
|
242
|
+
to: string;
|
|
243
|
+
sourceHandle?: string | undefined;
|
|
244
|
+
label?: string | undefined;
|
|
245
|
+
condition?: string | undefined;
|
|
246
|
+
}>, "many">;
|
|
247
|
+
}, "strip", z.ZodTypeAny, {
|
|
248
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
249
|
+
id: string;
|
|
250
|
+
config: Record<string, unknown>;
|
|
251
|
+
out: {
|
|
252
|
+
to: string;
|
|
253
|
+
sourceHandle?: string | undefined;
|
|
254
|
+
label?: string | undefined;
|
|
255
|
+
condition?: string | undefined;
|
|
256
|
+
}[];
|
|
257
|
+
}, {
|
|
258
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
259
|
+
id: string;
|
|
260
|
+
config: Record<string, unknown>;
|
|
261
|
+
out: {
|
|
262
|
+
to: string;
|
|
263
|
+
sourceHandle?: string | undefined;
|
|
264
|
+
label?: string | undefined;
|
|
265
|
+
condition?: string | undefined;
|
|
266
|
+
}[];
|
|
267
|
+
}>>;
|
|
268
|
+
completionGate: z.ZodObject<{
|
|
269
|
+
requiredFields: z.ZodArray<z.ZodString, "many">;
|
|
270
|
+
}, "strip", z.ZodTypeAny, {
|
|
271
|
+
requiredFields: string[];
|
|
272
|
+
}, {
|
|
273
|
+
requiredFields: string[];
|
|
274
|
+
}>;
|
|
275
|
+
diagnostics: z.ZodOptional<z.ZodObject<{
|
|
276
|
+
acyclic: z.ZodBoolean;
|
|
277
|
+
droppedEdges: z.ZodArray<z.ZodString, "many">;
|
|
278
|
+
unsupportedNodes: z.ZodArray<z.ZodString, "many">;
|
|
279
|
+
}, "strip", z.ZodTypeAny, {
|
|
280
|
+
acyclic: boolean;
|
|
281
|
+
droppedEdges: string[];
|
|
282
|
+
unsupportedNodes: string[];
|
|
283
|
+
}, {
|
|
284
|
+
acyclic: boolean;
|
|
285
|
+
droppedEdges: string[];
|
|
286
|
+
unsupportedNodes: string[];
|
|
287
|
+
}>>;
|
|
288
|
+
}, "strip", z.ZodTypeAny, {
|
|
289
|
+
v: 1;
|
|
290
|
+
id: string;
|
|
291
|
+
nodes: Record<string, {
|
|
292
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
293
|
+
id: string;
|
|
294
|
+
config: Record<string, unknown>;
|
|
295
|
+
out: {
|
|
296
|
+
to: string;
|
|
297
|
+
sourceHandle?: string | undefined;
|
|
298
|
+
label?: string | undefined;
|
|
299
|
+
condition?: string | undefined;
|
|
300
|
+
}[];
|
|
301
|
+
}>;
|
|
302
|
+
entry: string[];
|
|
303
|
+
completionGate: {
|
|
304
|
+
requiredFields: string[];
|
|
305
|
+
};
|
|
306
|
+
diagnostics?: {
|
|
307
|
+
acyclic: boolean;
|
|
308
|
+
droppedEdges: string[];
|
|
309
|
+
unsupportedNodes: string[];
|
|
310
|
+
} | undefined;
|
|
311
|
+
}, {
|
|
312
|
+
v: 1;
|
|
313
|
+
id: string;
|
|
314
|
+
nodes: Record<string, {
|
|
315
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
316
|
+
id: string;
|
|
317
|
+
config: Record<string, unknown>;
|
|
318
|
+
out: {
|
|
319
|
+
to: string;
|
|
320
|
+
sourceHandle?: string | undefined;
|
|
321
|
+
label?: string | undefined;
|
|
322
|
+
condition?: string | undefined;
|
|
323
|
+
}[];
|
|
324
|
+
}>;
|
|
325
|
+
entry: string[];
|
|
326
|
+
completionGate: {
|
|
327
|
+
requiredFields: string[];
|
|
328
|
+
};
|
|
329
|
+
diagnostics?: {
|
|
330
|
+
acyclic: boolean;
|
|
331
|
+
droppedEdges: string[];
|
|
332
|
+
unsupportedNodes: string[];
|
|
333
|
+
} | undefined;
|
|
334
|
+
}>>;
|
|
335
|
+
}, "strip", z.ZodTypeAny, {
|
|
336
|
+
id: string;
|
|
337
|
+
completionGate: {
|
|
338
|
+
requiredFields: string[];
|
|
339
|
+
backendAck?: {
|
|
340
|
+
url: string;
|
|
341
|
+
timeoutMs: number;
|
|
342
|
+
} | undefined;
|
|
343
|
+
};
|
|
344
|
+
fields: {
|
|
345
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
346
|
+
name: string;
|
|
347
|
+
required: boolean;
|
|
348
|
+
ask?: string | undefined;
|
|
349
|
+
pattern?: string | undefined;
|
|
350
|
+
min?: number | undefined;
|
|
351
|
+
max?: number | undefined;
|
|
352
|
+
enum?: string[] | undefined;
|
|
353
|
+
}[];
|
|
354
|
+
handoff?: {
|
|
355
|
+
fallback?: string | undefined;
|
|
356
|
+
routes?: Record<string, string> | undefined;
|
|
357
|
+
} | undefined;
|
|
358
|
+
memory?: {
|
|
359
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
360
|
+
retentionDays?: number | undefined;
|
|
361
|
+
piiFields?: string[] | undefined;
|
|
362
|
+
} | undefined;
|
|
363
|
+
prompts?: {
|
|
364
|
+
id: string;
|
|
365
|
+
text: string;
|
|
366
|
+
}[] | undefined;
|
|
367
|
+
triggers?: {
|
|
368
|
+
then: string;
|
|
369
|
+
name: string;
|
|
370
|
+
on: string;
|
|
371
|
+
onlyWhile?: string | undefined;
|
|
372
|
+
}[] | undefined;
|
|
373
|
+
tools?: {
|
|
374
|
+
name: string;
|
|
375
|
+
description: string;
|
|
376
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
377
|
+
url: string;
|
|
378
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
379
|
+
auth: "none" | "connection";
|
|
380
|
+
headers?: Record<string, string> | undefined;
|
|
381
|
+
connectionRef?: string | undefined;
|
|
382
|
+
}[] | undefined;
|
|
383
|
+
program?: {
|
|
384
|
+
v: 1;
|
|
385
|
+
id: string;
|
|
386
|
+
nodes: Record<string, {
|
|
387
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
388
|
+
id: string;
|
|
389
|
+
config: Record<string, unknown>;
|
|
390
|
+
out: {
|
|
391
|
+
to: string;
|
|
392
|
+
sourceHandle?: string | undefined;
|
|
393
|
+
label?: string | undefined;
|
|
394
|
+
condition?: string | undefined;
|
|
395
|
+
}[];
|
|
396
|
+
}>;
|
|
397
|
+
entry: string[];
|
|
398
|
+
completionGate: {
|
|
399
|
+
requiredFields: string[];
|
|
400
|
+
};
|
|
401
|
+
diagnostics?: {
|
|
402
|
+
acyclic: boolean;
|
|
403
|
+
droppedEdges: string[];
|
|
404
|
+
unsupportedNodes: string[];
|
|
405
|
+
} | undefined;
|
|
406
|
+
} | undefined;
|
|
407
|
+
}, {
|
|
408
|
+
id: string;
|
|
409
|
+
completionGate: {
|
|
410
|
+
requiredFields: string[];
|
|
411
|
+
backendAck?: {
|
|
412
|
+
url: string;
|
|
413
|
+
timeoutMs: number;
|
|
414
|
+
} | undefined;
|
|
415
|
+
};
|
|
416
|
+
fields: {
|
|
417
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
418
|
+
name: string;
|
|
419
|
+
required: boolean;
|
|
420
|
+
ask?: string | undefined;
|
|
421
|
+
pattern?: string | undefined;
|
|
422
|
+
min?: number | undefined;
|
|
423
|
+
max?: number | undefined;
|
|
424
|
+
enum?: string[] | undefined;
|
|
425
|
+
}[];
|
|
426
|
+
handoff?: {
|
|
427
|
+
fallback?: string | undefined;
|
|
428
|
+
routes?: Record<string, string> | undefined;
|
|
429
|
+
} | undefined;
|
|
430
|
+
memory?: {
|
|
431
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
432
|
+
retentionDays?: number | undefined;
|
|
433
|
+
piiFields?: string[] | undefined;
|
|
434
|
+
} | undefined;
|
|
435
|
+
prompts?: {
|
|
436
|
+
id: string;
|
|
437
|
+
text: string;
|
|
438
|
+
}[] | undefined;
|
|
439
|
+
triggers?: {
|
|
440
|
+
then: string;
|
|
441
|
+
name: string;
|
|
442
|
+
on: string;
|
|
443
|
+
onlyWhile?: string | undefined;
|
|
444
|
+
}[] | undefined;
|
|
445
|
+
tools?: {
|
|
446
|
+
name: string;
|
|
447
|
+
description: string;
|
|
448
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
449
|
+
url: string;
|
|
450
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
451
|
+
auth: "none" | "connection";
|
|
452
|
+
headers?: Record<string, string> | undefined;
|
|
453
|
+
connectionRef?: string | undefined;
|
|
454
|
+
}[] | undefined;
|
|
455
|
+
program?: {
|
|
456
|
+
v: 1;
|
|
457
|
+
id: string;
|
|
458
|
+
nodes: Record<string, {
|
|
459
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
460
|
+
id: string;
|
|
461
|
+
config: Record<string, unknown>;
|
|
462
|
+
out: {
|
|
463
|
+
to: string;
|
|
464
|
+
sourceHandle?: string | undefined;
|
|
465
|
+
label?: string | undefined;
|
|
466
|
+
condition?: string | undefined;
|
|
467
|
+
}[];
|
|
468
|
+
}>;
|
|
469
|
+
entry: string[];
|
|
470
|
+
completionGate: {
|
|
471
|
+
requiredFields: string[];
|
|
472
|
+
};
|
|
473
|
+
diagnostics?: {
|
|
474
|
+
acyclic: boolean;
|
|
475
|
+
droppedEdges: string[];
|
|
476
|
+
unsupportedNodes: string[];
|
|
477
|
+
} | undefined;
|
|
478
|
+
} | undefined;
|
|
479
|
+
}>;
|
|
480
|
+
type ProcessSchemaDTO = z.infer<typeof ProcessSchemaDTO>;
|
|
481
|
+
declare const AgentDTO: z.ZodObject<{
|
|
482
|
+
id: z.ZodString;
|
|
483
|
+
projectId: z.ZodString;
|
|
484
|
+
name: z.ZodString;
|
|
485
|
+
version: z.ZodString;
|
|
486
|
+
environment: z.ZodEnum<["dev", "stg", "prd"]>;
|
|
487
|
+
status: z.ZodEnum<["online", "offline", "degraded"]>;
|
|
488
|
+
statusDetail: z.ZodNullable<z.ZodString>;
|
|
489
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
490
|
+
readiness: z.ZodArray<z.ZodObject<{
|
|
491
|
+
probe: z.ZodString;
|
|
492
|
+
ok: z.ZodBoolean;
|
|
493
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
494
|
+
}, "strip", z.ZodTypeAny, {
|
|
495
|
+
probe: string;
|
|
496
|
+
ok: boolean;
|
|
497
|
+
detail?: string | undefined;
|
|
498
|
+
}, {
|
|
499
|
+
probe: string;
|
|
500
|
+
ok: boolean;
|
|
501
|
+
detail?: string | undefined;
|
|
502
|
+
}>, "many">;
|
|
503
|
+
lastSeenAt: z.ZodNullable<z.ZodString>;
|
|
504
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
505
|
+
processSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
506
|
+
id: z.ZodString;
|
|
507
|
+
prompts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
508
|
+
id: z.ZodString;
|
|
509
|
+
text: z.ZodString;
|
|
510
|
+
}, "strip", z.ZodTypeAny, {
|
|
511
|
+
id: string;
|
|
512
|
+
text: string;
|
|
513
|
+
}, {
|
|
514
|
+
id: string;
|
|
515
|
+
text: string;
|
|
516
|
+
}>, "many">>;
|
|
517
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
518
|
+
name: z.ZodString;
|
|
519
|
+
required: z.ZodBoolean;
|
|
520
|
+
type: z.ZodEnum<["string", "string[]", "number", "boolean", "datetime", "email", "phone"]>;
|
|
521
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
522
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
523
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
524
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
525
|
+
ask: z.ZodOptional<z.ZodString>;
|
|
526
|
+
}, "strip", z.ZodTypeAny, {
|
|
527
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
528
|
+
name: string;
|
|
529
|
+
required: boolean;
|
|
530
|
+
ask?: string | undefined;
|
|
531
|
+
pattern?: string | undefined;
|
|
532
|
+
min?: number | undefined;
|
|
533
|
+
max?: number | undefined;
|
|
534
|
+
enum?: string[] | undefined;
|
|
535
|
+
}, {
|
|
536
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
537
|
+
name: string;
|
|
538
|
+
required: boolean;
|
|
539
|
+
ask?: string | undefined;
|
|
540
|
+
pattern?: string | undefined;
|
|
541
|
+
min?: number | undefined;
|
|
542
|
+
max?: number | undefined;
|
|
543
|
+
enum?: string[] | undefined;
|
|
544
|
+
}>, "many">;
|
|
545
|
+
completionGate: z.ZodObject<{
|
|
546
|
+
requiredFields: z.ZodArray<z.ZodString, "many">;
|
|
547
|
+
backendAck: z.ZodOptional<z.ZodObject<{
|
|
548
|
+
url: z.ZodString;
|
|
549
|
+
timeoutMs: z.ZodNumber;
|
|
550
|
+
}, "strip", z.ZodTypeAny, {
|
|
551
|
+
url: string;
|
|
552
|
+
timeoutMs: number;
|
|
553
|
+
}, {
|
|
554
|
+
url: string;
|
|
555
|
+
timeoutMs: number;
|
|
556
|
+
}>>;
|
|
557
|
+
}, "strip", z.ZodTypeAny, {
|
|
558
|
+
requiredFields: string[];
|
|
559
|
+
backendAck?: {
|
|
560
|
+
url: string;
|
|
561
|
+
timeoutMs: number;
|
|
562
|
+
} | undefined;
|
|
563
|
+
}, {
|
|
564
|
+
requiredFields: string[];
|
|
565
|
+
backendAck?: {
|
|
566
|
+
url: string;
|
|
567
|
+
timeoutMs: number;
|
|
568
|
+
} | undefined;
|
|
569
|
+
}>;
|
|
570
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
571
|
+
name: z.ZodString;
|
|
572
|
+
on: z.ZodString;
|
|
573
|
+
then: z.ZodString;
|
|
574
|
+
onlyWhile: z.ZodOptional<z.ZodString>;
|
|
575
|
+
}, "strip", z.ZodTypeAny, {
|
|
576
|
+
then: string;
|
|
577
|
+
name: string;
|
|
578
|
+
on: string;
|
|
579
|
+
onlyWhile?: string | undefined;
|
|
580
|
+
}, {
|
|
581
|
+
then: string;
|
|
582
|
+
name: string;
|
|
583
|
+
on: string;
|
|
584
|
+
onlyWhile?: string | undefined;
|
|
585
|
+
}>, "many">>;
|
|
586
|
+
handoff: z.ZodOptional<z.ZodObject<{
|
|
587
|
+
fallback: z.ZodOptional<z.ZodString>;
|
|
588
|
+
routes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
589
|
+
}, "strip", z.ZodTypeAny, {
|
|
590
|
+
fallback?: string | undefined;
|
|
591
|
+
routes?: Record<string, string> | undefined;
|
|
592
|
+
}, {
|
|
593
|
+
fallback?: string | undefined;
|
|
594
|
+
routes?: Record<string, string> | undefined;
|
|
595
|
+
}>>;
|
|
596
|
+
memory: z.ZodOptional<z.ZodObject<{
|
|
597
|
+
scope: z.ZodOptional<z.ZodEnum<["call", "caller", "participant", "account", "platform"]>>;
|
|
598
|
+
retentionDays: z.ZodOptional<z.ZodNumber>;
|
|
599
|
+
piiFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
600
|
+
}, "strip", z.ZodTypeAny, {
|
|
601
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
602
|
+
retentionDays?: number | undefined;
|
|
603
|
+
piiFields?: string[] | undefined;
|
|
604
|
+
}, {
|
|
605
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
606
|
+
retentionDays?: number | undefined;
|
|
607
|
+
piiFields?: string[] | undefined;
|
|
608
|
+
}>>;
|
|
609
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
610
|
+
name: z.ZodString;
|
|
611
|
+
description: z.ZodString;
|
|
612
|
+
input: z.ZodRecord<z.ZodString, z.ZodEnum<["string", "number", "boolean"]>>;
|
|
613
|
+
url: z.ZodString;
|
|
614
|
+
method: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>;
|
|
615
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
616
|
+
auth: z.ZodEnum<["none", "connection"]>;
|
|
617
|
+
connectionRef: z.ZodOptional<z.ZodString>;
|
|
618
|
+
}, "strip", z.ZodTypeAny, {
|
|
619
|
+
name: string;
|
|
620
|
+
description: string;
|
|
621
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
622
|
+
url: string;
|
|
623
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
624
|
+
auth: "none" | "connection";
|
|
625
|
+
headers?: Record<string, string> | undefined;
|
|
626
|
+
connectionRef?: string | undefined;
|
|
627
|
+
}, {
|
|
628
|
+
name: string;
|
|
629
|
+
description: string;
|
|
630
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
631
|
+
url: string;
|
|
632
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
633
|
+
auth: "none" | "connection";
|
|
634
|
+
headers?: Record<string, string> | undefined;
|
|
635
|
+
connectionRef?: string | undefined;
|
|
636
|
+
}>, "many">>;
|
|
637
|
+
program: z.ZodOptional<z.ZodObject<{
|
|
638
|
+
v: z.ZodLiteral<1>;
|
|
639
|
+
id: z.ZodString;
|
|
640
|
+
entry: z.ZodArray<z.ZodString, "many">;
|
|
641
|
+
nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
642
|
+
id: z.ZodString;
|
|
643
|
+
type: z.ZodEnum<["say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "route", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
|
|
644
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
645
|
+
out: z.ZodArray<z.ZodObject<{
|
|
646
|
+
to: z.ZodString;
|
|
647
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
648
|
+
sourceHandle: z.ZodOptional<z.ZodString>;
|
|
649
|
+
label: z.ZodOptional<z.ZodString>;
|
|
650
|
+
}, "strip", z.ZodTypeAny, {
|
|
651
|
+
to: string;
|
|
652
|
+
sourceHandle?: string | undefined;
|
|
653
|
+
label?: string | undefined;
|
|
654
|
+
condition?: string | undefined;
|
|
655
|
+
}, {
|
|
656
|
+
to: string;
|
|
657
|
+
sourceHandle?: string | undefined;
|
|
658
|
+
label?: string | undefined;
|
|
659
|
+
condition?: string | undefined;
|
|
660
|
+
}>, "many">;
|
|
661
|
+
}, "strip", z.ZodTypeAny, {
|
|
662
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
663
|
+
id: string;
|
|
664
|
+
config: Record<string, unknown>;
|
|
665
|
+
out: {
|
|
666
|
+
to: string;
|
|
667
|
+
sourceHandle?: string | undefined;
|
|
668
|
+
label?: string | undefined;
|
|
669
|
+
condition?: string | undefined;
|
|
670
|
+
}[];
|
|
671
|
+
}, {
|
|
672
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
673
|
+
id: string;
|
|
674
|
+
config: Record<string, unknown>;
|
|
675
|
+
out: {
|
|
676
|
+
to: string;
|
|
677
|
+
sourceHandle?: string | undefined;
|
|
678
|
+
label?: string | undefined;
|
|
679
|
+
condition?: string | undefined;
|
|
680
|
+
}[];
|
|
681
|
+
}>>;
|
|
682
|
+
completionGate: z.ZodObject<{
|
|
683
|
+
requiredFields: z.ZodArray<z.ZodString, "many">;
|
|
684
|
+
}, "strip", z.ZodTypeAny, {
|
|
685
|
+
requiredFields: string[];
|
|
686
|
+
}, {
|
|
687
|
+
requiredFields: string[];
|
|
688
|
+
}>;
|
|
689
|
+
diagnostics: z.ZodOptional<z.ZodObject<{
|
|
690
|
+
acyclic: z.ZodBoolean;
|
|
691
|
+
droppedEdges: z.ZodArray<z.ZodString, "many">;
|
|
692
|
+
unsupportedNodes: z.ZodArray<z.ZodString, "many">;
|
|
693
|
+
}, "strip", z.ZodTypeAny, {
|
|
694
|
+
acyclic: boolean;
|
|
695
|
+
droppedEdges: string[];
|
|
696
|
+
unsupportedNodes: string[];
|
|
697
|
+
}, {
|
|
698
|
+
acyclic: boolean;
|
|
699
|
+
droppedEdges: string[];
|
|
700
|
+
unsupportedNodes: string[];
|
|
701
|
+
}>>;
|
|
702
|
+
}, "strip", z.ZodTypeAny, {
|
|
703
|
+
v: 1;
|
|
704
|
+
id: string;
|
|
705
|
+
nodes: Record<string, {
|
|
706
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
707
|
+
id: string;
|
|
708
|
+
config: Record<string, unknown>;
|
|
709
|
+
out: {
|
|
710
|
+
to: string;
|
|
711
|
+
sourceHandle?: string | undefined;
|
|
712
|
+
label?: string | undefined;
|
|
713
|
+
condition?: string | undefined;
|
|
714
|
+
}[];
|
|
715
|
+
}>;
|
|
716
|
+
entry: string[];
|
|
717
|
+
completionGate: {
|
|
718
|
+
requiredFields: string[];
|
|
719
|
+
};
|
|
720
|
+
diagnostics?: {
|
|
721
|
+
acyclic: boolean;
|
|
722
|
+
droppedEdges: string[];
|
|
723
|
+
unsupportedNodes: string[];
|
|
724
|
+
} | undefined;
|
|
725
|
+
}, {
|
|
726
|
+
v: 1;
|
|
727
|
+
id: string;
|
|
728
|
+
nodes: Record<string, {
|
|
729
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
730
|
+
id: string;
|
|
731
|
+
config: Record<string, unknown>;
|
|
732
|
+
out: {
|
|
733
|
+
to: string;
|
|
734
|
+
sourceHandle?: string | undefined;
|
|
735
|
+
label?: string | undefined;
|
|
736
|
+
condition?: string | undefined;
|
|
737
|
+
}[];
|
|
738
|
+
}>;
|
|
739
|
+
entry: string[];
|
|
740
|
+
completionGate: {
|
|
741
|
+
requiredFields: string[];
|
|
742
|
+
};
|
|
743
|
+
diagnostics?: {
|
|
744
|
+
acyclic: boolean;
|
|
745
|
+
droppedEdges: string[];
|
|
746
|
+
unsupportedNodes: string[];
|
|
747
|
+
} | undefined;
|
|
748
|
+
}>>;
|
|
749
|
+
}, "strip", z.ZodTypeAny, {
|
|
750
|
+
id: string;
|
|
751
|
+
completionGate: {
|
|
752
|
+
requiredFields: string[];
|
|
753
|
+
backendAck?: {
|
|
754
|
+
url: string;
|
|
755
|
+
timeoutMs: number;
|
|
756
|
+
} | undefined;
|
|
757
|
+
};
|
|
758
|
+
fields: {
|
|
759
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
760
|
+
name: string;
|
|
761
|
+
required: boolean;
|
|
762
|
+
ask?: string | undefined;
|
|
763
|
+
pattern?: string | undefined;
|
|
764
|
+
min?: number | undefined;
|
|
765
|
+
max?: number | undefined;
|
|
766
|
+
enum?: string[] | undefined;
|
|
767
|
+
}[];
|
|
768
|
+
handoff?: {
|
|
769
|
+
fallback?: string | undefined;
|
|
770
|
+
routes?: Record<string, string> | undefined;
|
|
771
|
+
} | undefined;
|
|
772
|
+
memory?: {
|
|
773
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
774
|
+
retentionDays?: number | undefined;
|
|
775
|
+
piiFields?: string[] | undefined;
|
|
776
|
+
} | undefined;
|
|
777
|
+
prompts?: {
|
|
778
|
+
id: string;
|
|
779
|
+
text: string;
|
|
780
|
+
}[] | undefined;
|
|
781
|
+
triggers?: {
|
|
782
|
+
then: string;
|
|
783
|
+
name: string;
|
|
784
|
+
on: string;
|
|
785
|
+
onlyWhile?: string | undefined;
|
|
786
|
+
}[] | undefined;
|
|
787
|
+
tools?: {
|
|
788
|
+
name: string;
|
|
789
|
+
description: string;
|
|
790
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
791
|
+
url: string;
|
|
792
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
793
|
+
auth: "none" | "connection";
|
|
794
|
+
headers?: Record<string, string> | undefined;
|
|
795
|
+
connectionRef?: string | undefined;
|
|
796
|
+
}[] | undefined;
|
|
797
|
+
program?: {
|
|
798
|
+
v: 1;
|
|
799
|
+
id: string;
|
|
800
|
+
nodes: Record<string, {
|
|
801
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
802
|
+
id: string;
|
|
803
|
+
config: Record<string, unknown>;
|
|
804
|
+
out: {
|
|
805
|
+
to: string;
|
|
806
|
+
sourceHandle?: string | undefined;
|
|
807
|
+
label?: string | undefined;
|
|
808
|
+
condition?: string | undefined;
|
|
809
|
+
}[];
|
|
810
|
+
}>;
|
|
811
|
+
entry: string[];
|
|
812
|
+
completionGate: {
|
|
813
|
+
requiredFields: string[];
|
|
814
|
+
};
|
|
815
|
+
diagnostics?: {
|
|
816
|
+
acyclic: boolean;
|
|
817
|
+
droppedEdges: string[];
|
|
818
|
+
unsupportedNodes: string[];
|
|
819
|
+
} | undefined;
|
|
820
|
+
} | undefined;
|
|
821
|
+
}, {
|
|
822
|
+
id: string;
|
|
823
|
+
completionGate: {
|
|
824
|
+
requiredFields: string[];
|
|
825
|
+
backendAck?: {
|
|
826
|
+
url: string;
|
|
827
|
+
timeoutMs: number;
|
|
828
|
+
} | undefined;
|
|
829
|
+
};
|
|
830
|
+
fields: {
|
|
831
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
832
|
+
name: string;
|
|
833
|
+
required: boolean;
|
|
834
|
+
ask?: string | undefined;
|
|
835
|
+
pattern?: string | undefined;
|
|
836
|
+
min?: number | undefined;
|
|
837
|
+
max?: number | undefined;
|
|
838
|
+
enum?: string[] | undefined;
|
|
839
|
+
}[];
|
|
840
|
+
handoff?: {
|
|
841
|
+
fallback?: string | undefined;
|
|
842
|
+
routes?: Record<string, string> | undefined;
|
|
843
|
+
} | undefined;
|
|
844
|
+
memory?: {
|
|
845
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
846
|
+
retentionDays?: number | undefined;
|
|
847
|
+
piiFields?: string[] | undefined;
|
|
848
|
+
} | undefined;
|
|
849
|
+
prompts?: {
|
|
850
|
+
id: string;
|
|
851
|
+
text: string;
|
|
852
|
+
}[] | undefined;
|
|
853
|
+
triggers?: {
|
|
854
|
+
then: string;
|
|
855
|
+
name: string;
|
|
856
|
+
on: string;
|
|
857
|
+
onlyWhile?: string | undefined;
|
|
858
|
+
}[] | undefined;
|
|
859
|
+
tools?: {
|
|
860
|
+
name: string;
|
|
861
|
+
description: string;
|
|
862
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
863
|
+
url: string;
|
|
864
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
865
|
+
auth: "none" | "connection";
|
|
866
|
+
headers?: Record<string, string> | undefined;
|
|
867
|
+
connectionRef?: string | undefined;
|
|
868
|
+
}[] | undefined;
|
|
869
|
+
program?: {
|
|
870
|
+
v: 1;
|
|
871
|
+
id: string;
|
|
872
|
+
nodes: Record<string, {
|
|
873
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
874
|
+
id: string;
|
|
875
|
+
config: Record<string, unknown>;
|
|
876
|
+
out: {
|
|
877
|
+
to: string;
|
|
878
|
+
sourceHandle?: string | undefined;
|
|
879
|
+
label?: string | undefined;
|
|
880
|
+
condition?: string | undefined;
|
|
881
|
+
}[];
|
|
882
|
+
}>;
|
|
883
|
+
entry: string[];
|
|
884
|
+
completionGate: {
|
|
885
|
+
requiredFields: string[];
|
|
886
|
+
};
|
|
887
|
+
diagnostics?: {
|
|
888
|
+
acyclic: boolean;
|
|
889
|
+
droppedEdges: string[];
|
|
890
|
+
unsupportedNodes: string[];
|
|
891
|
+
} | undefined;
|
|
892
|
+
} | undefined;
|
|
893
|
+
}>>>;
|
|
894
|
+
createdAt: z.ZodString;
|
|
895
|
+
updatedAt: z.ZodString;
|
|
896
|
+
}, "strip", z.ZodTypeAny, {
|
|
897
|
+
status: "online" | "offline" | "degraded";
|
|
898
|
+
id: string;
|
|
899
|
+
projectId: string;
|
|
900
|
+
name: string;
|
|
901
|
+
createdAt: string;
|
|
902
|
+
updatedAt: string;
|
|
903
|
+
version: string;
|
|
904
|
+
environment: "dev" | "stg" | "prd";
|
|
905
|
+
statusDetail: string | null;
|
|
906
|
+
capabilities: string[];
|
|
907
|
+
readiness: {
|
|
908
|
+
probe: string;
|
|
909
|
+
ok: boolean;
|
|
910
|
+
detail?: string | undefined;
|
|
911
|
+
}[];
|
|
912
|
+
metadata: Record<string, unknown>;
|
|
913
|
+
lastSeenAt: string | null;
|
|
914
|
+
processSchema?: {
|
|
915
|
+
id: string;
|
|
916
|
+
completionGate: {
|
|
917
|
+
requiredFields: string[];
|
|
918
|
+
backendAck?: {
|
|
919
|
+
url: string;
|
|
920
|
+
timeoutMs: number;
|
|
921
|
+
} | undefined;
|
|
922
|
+
};
|
|
923
|
+
fields: {
|
|
924
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
925
|
+
name: string;
|
|
926
|
+
required: boolean;
|
|
927
|
+
ask?: string | undefined;
|
|
928
|
+
pattern?: string | undefined;
|
|
929
|
+
min?: number | undefined;
|
|
930
|
+
max?: number | undefined;
|
|
931
|
+
enum?: string[] | undefined;
|
|
932
|
+
}[];
|
|
933
|
+
handoff?: {
|
|
934
|
+
fallback?: string | undefined;
|
|
935
|
+
routes?: Record<string, string> | undefined;
|
|
936
|
+
} | undefined;
|
|
937
|
+
memory?: {
|
|
938
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
939
|
+
retentionDays?: number | undefined;
|
|
940
|
+
piiFields?: string[] | undefined;
|
|
941
|
+
} | undefined;
|
|
942
|
+
prompts?: {
|
|
943
|
+
id: string;
|
|
944
|
+
text: string;
|
|
945
|
+
}[] | undefined;
|
|
946
|
+
triggers?: {
|
|
947
|
+
then: string;
|
|
948
|
+
name: string;
|
|
949
|
+
on: string;
|
|
950
|
+
onlyWhile?: string | undefined;
|
|
951
|
+
}[] | undefined;
|
|
952
|
+
tools?: {
|
|
953
|
+
name: string;
|
|
954
|
+
description: string;
|
|
955
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
956
|
+
url: string;
|
|
957
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
958
|
+
auth: "none" | "connection";
|
|
959
|
+
headers?: Record<string, string> | undefined;
|
|
960
|
+
connectionRef?: string | undefined;
|
|
961
|
+
}[] | undefined;
|
|
962
|
+
program?: {
|
|
963
|
+
v: 1;
|
|
964
|
+
id: string;
|
|
965
|
+
nodes: Record<string, {
|
|
966
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
967
|
+
id: string;
|
|
968
|
+
config: Record<string, unknown>;
|
|
969
|
+
out: {
|
|
970
|
+
to: string;
|
|
971
|
+
sourceHandle?: string | undefined;
|
|
972
|
+
label?: string | undefined;
|
|
973
|
+
condition?: string | undefined;
|
|
974
|
+
}[];
|
|
975
|
+
}>;
|
|
976
|
+
entry: string[];
|
|
977
|
+
completionGate: {
|
|
978
|
+
requiredFields: string[];
|
|
979
|
+
};
|
|
980
|
+
diagnostics?: {
|
|
981
|
+
acyclic: boolean;
|
|
982
|
+
droppedEdges: string[];
|
|
983
|
+
unsupportedNodes: string[];
|
|
984
|
+
} | undefined;
|
|
985
|
+
} | undefined;
|
|
986
|
+
} | null | undefined;
|
|
987
|
+
}, {
|
|
988
|
+
status: "online" | "offline" | "degraded";
|
|
989
|
+
id: string;
|
|
990
|
+
projectId: string;
|
|
991
|
+
name: string;
|
|
992
|
+
createdAt: string;
|
|
993
|
+
updatedAt: string;
|
|
994
|
+
version: string;
|
|
995
|
+
environment: "dev" | "stg" | "prd";
|
|
996
|
+
statusDetail: string | null;
|
|
997
|
+
capabilities: string[];
|
|
998
|
+
readiness: {
|
|
999
|
+
probe: string;
|
|
1000
|
+
ok: boolean;
|
|
1001
|
+
detail?: string | undefined;
|
|
1002
|
+
}[];
|
|
1003
|
+
metadata: Record<string, unknown>;
|
|
1004
|
+
lastSeenAt: string | null;
|
|
1005
|
+
processSchema?: {
|
|
1006
|
+
id: string;
|
|
1007
|
+
completionGate: {
|
|
1008
|
+
requiredFields: string[];
|
|
1009
|
+
backendAck?: {
|
|
1010
|
+
url: string;
|
|
1011
|
+
timeoutMs: number;
|
|
1012
|
+
} | undefined;
|
|
1013
|
+
};
|
|
1014
|
+
fields: {
|
|
1015
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1016
|
+
name: string;
|
|
1017
|
+
required: boolean;
|
|
1018
|
+
ask?: string | undefined;
|
|
1019
|
+
pattern?: string | undefined;
|
|
1020
|
+
min?: number | undefined;
|
|
1021
|
+
max?: number | undefined;
|
|
1022
|
+
enum?: string[] | undefined;
|
|
1023
|
+
}[];
|
|
1024
|
+
handoff?: {
|
|
1025
|
+
fallback?: string | undefined;
|
|
1026
|
+
routes?: Record<string, string> | undefined;
|
|
1027
|
+
} | undefined;
|
|
1028
|
+
memory?: {
|
|
1029
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
1030
|
+
retentionDays?: number | undefined;
|
|
1031
|
+
piiFields?: string[] | undefined;
|
|
1032
|
+
} | undefined;
|
|
1033
|
+
prompts?: {
|
|
1034
|
+
id: string;
|
|
1035
|
+
text: string;
|
|
1036
|
+
}[] | undefined;
|
|
1037
|
+
triggers?: {
|
|
1038
|
+
then: string;
|
|
1039
|
+
name: string;
|
|
1040
|
+
on: string;
|
|
1041
|
+
onlyWhile?: string | undefined;
|
|
1042
|
+
}[] | undefined;
|
|
1043
|
+
tools?: {
|
|
1044
|
+
name: string;
|
|
1045
|
+
description: string;
|
|
1046
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
1047
|
+
url: string;
|
|
1048
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
1049
|
+
auth: "none" | "connection";
|
|
1050
|
+
headers?: Record<string, string> | undefined;
|
|
1051
|
+
connectionRef?: string | undefined;
|
|
1052
|
+
}[] | undefined;
|
|
1053
|
+
program?: {
|
|
1054
|
+
v: 1;
|
|
1055
|
+
id: string;
|
|
1056
|
+
nodes: Record<string, {
|
|
1057
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
1058
|
+
id: string;
|
|
1059
|
+
config: Record<string, unknown>;
|
|
1060
|
+
out: {
|
|
1061
|
+
to: string;
|
|
1062
|
+
sourceHandle?: string | undefined;
|
|
1063
|
+
label?: string | undefined;
|
|
1064
|
+
condition?: string | undefined;
|
|
1065
|
+
}[];
|
|
1066
|
+
}>;
|
|
1067
|
+
entry: string[];
|
|
1068
|
+
completionGate: {
|
|
1069
|
+
requiredFields: string[];
|
|
1070
|
+
};
|
|
1071
|
+
diagnostics?: {
|
|
1072
|
+
acyclic: boolean;
|
|
1073
|
+
droppedEdges: string[];
|
|
1074
|
+
unsupportedNodes: string[];
|
|
1075
|
+
} | undefined;
|
|
1076
|
+
} | undefined;
|
|
1077
|
+
} | null | undefined;
|
|
1078
|
+
}>;
|
|
1079
|
+
type AgentDTO = z.infer<typeof AgentDTO>;
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* The plan itself. Everything the agent needs to run the call without the
|
|
1083
|
+
* host being present turn-by-turn.
|
|
1084
|
+
*/
|
|
1085
|
+
declare const CallPlan: z.ZodObject<{
|
|
1086
|
+
planId: z.ZodString;
|
|
1087
|
+
projectId: z.ZodString;
|
|
1088
|
+
status: z.ZodEnum<["drafting", "clarifying", "ready", "committed", "abandoned"]>;
|
|
1089
|
+
objective: z.ZodString;
|
|
1090
|
+
callee: z.ZodObject<{
|
|
1091
|
+
e164: z.ZodOptional<z.ZodString>;
|
|
1092
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
1093
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1094
|
+
}, "strip", z.ZodTypeAny, {
|
|
1095
|
+
description?: string | undefined;
|
|
1096
|
+
e164?: string | undefined;
|
|
1097
|
+
displayName?: string | undefined;
|
|
1098
|
+
}, {
|
|
1099
|
+
description?: string | undefined;
|
|
1100
|
+
e164?: string | undefined;
|
|
1101
|
+
displayName?: string | undefined;
|
|
1102
|
+
}>;
|
|
1103
|
+
draftConfig: z.ZodDefault<z.ZodObject<{
|
|
1104
|
+
source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["sdk", "flow"]>>>;
|
|
1105
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1106
|
+
triggers: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1107
|
+
on: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
1108
|
+
kind: z.ZodLiteral<"regex">;
|
|
1109
|
+
pattern: z.ZodString;
|
|
1110
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
1111
|
+
}, "strip", z.ZodTypeAny, {
|
|
1112
|
+
kind: "regex";
|
|
1113
|
+
pattern: string;
|
|
1114
|
+
flags?: string | undefined;
|
|
1115
|
+
}, {
|
|
1116
|
+
kind: "regex";
|
|
1117
|
+
pattern: string;
|
|
1118
|
+
flags?: string | undefined;
|
|
1119
|
+
}>, z.ZodObject<{
|
|
1120
|
+
kind: z.ZodLiteral<"signal">;
|
|
1121
|
+
name: z.ZodString;
|
|
1122
|
+
}, "strip", z.ZodTypeAny, {
|
|
1123
|
+
kind: "signal";
|
|
1124
|
+
name: string;
|
|
1125
|
+
}, {
|
|
1126
|
+
kind: "signal";
|
|
1127
|
+
name: string;
|
|
1128
|
+
}>]>;
|
|
1129
|
+
then: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
1130
|
+
kind: z.ZodLiteral<"handoff">;
|
|
1131
|
+
}, "strip", z.ZodTypeAny, {
|
|
1132
|
+
kind: "handoff";
|
|
1133
|
+
}, {
|
|
1134
|
+
kind: "handoff";
|
|
1135
|
+
}>, z.ZodObject<{
|
|
1136
|
+
kind: z.ZodLiteral<"endCall">;
|
|
1137
|
+
}, "strip", z.ZodTypeAny, {
|
|
1138
|
+
kind: "endCall";
|
|
1139
|
+
}, {
|
|
1140
|
+
kind: "endCall";
|
|
1141
|
+
}>, z.ZodObject<{
|
|
1142
|
+
kind: z.ZodLiteral<"say">;
|
|
1143
|
+
text: z.ZodString;
|
|
1144
|
+
}, "strip", z.ZodTypeAny, {
|
|
1145
|
+
kind: "say";
|
|
1146
|
+
text: string;
|
|
1147
|
+
}, {
|
|
1148
|
+
kind: "say";
|
|
1149
|
+
text: string;
|
|
1150
|
+
}>]>;
|
|
1151
|
+
onlyWhile: z.ZodOptional<z.ZodString>;
|
|
1152
|
+
}, "strip", z.ZodTypeAny, {
|
|
1153
|
+
then: {
|
|
1154
|
+
kind: "handoff";
|
|
1155
|
+
} | {
|
|
1156
|
+
kind: "endCall";
|
|
1157
|
+
} | {
|
|
1158
|
+
kind: "say";
|
|
1159
|
+
text: string;
|
|
1160
|
+
};
|
|
1161
|
+
on: {
|
|
1162
|
+
kind: "regex";
|
|
1163
|
+
pattern: string;
|
|
1164
|
+
flags?: string | undefined;
|
|
1165
|
+
} | {
|
|
1166
|
+
kind: "signal";
|
|
1167
|
+
name: string;
|
|
1168
|
+
};
|
|
1169
|
+
onlyWhile?: string | undefined;
|
|
1170
|
+
}, {
|
|
1171
|
+
then: {
|
|
1172
|
+
kind: "handoff";
|
|
1173
|
+
} | {
|
|
1174
|
+
kind: "endCall";
|
|
1175
|
+
} | {
|
|
1176
|
+
kind: "say";
|
|
1177
|
+
text: string;
|
|
1178
|
+
};
|
|
1179
|
+
on: {
|
|
1180
|
+
kind: "regex";
|
|
1181
|
+
pattern: string;
|
|
1182
|
+
flags?: string | undefined;
|
|
1183
|
+
} | {
|
|
1184
|
+
kind: "signal";
|
|
1185
|
+
name: string;
|
|
1186
|
+
};
|
|
1187
|
+
onlyWhile?: string | undefined;
|
|
1188
|
+
}>>>>;
|
|
1189
|
+
tools: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1190
|
+
toolName: z.ZodString;
|
|
1191
|
+
defaultArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1192
|
+
}, "strip", z.ZodTypeAny, {
|
|
1193
|
+
toolName: string;
|
|
1194
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
1195
|
+
}, {
|
|
1196
|
+
toolName: string;
|
|
1197
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
1198
|
+
}>, "many">>>;
|
|
1199
|
+
mode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["cascade", "realtime"]>>>;
|
|
1200
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
1201
|
+
provider: z.ZodEnum<["openai", "anthropic", "gemini"]>;
|
|
1202
|
+
model: z.ZodString;
|
|
1203
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1204
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1205
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
1206
|
+
}, "strip", z.ZodTypeAny, {
|
|
1207
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
1208
|
+
model: string;
|
|
1209
|
+
temperature?: number | undefined;
|
|
1210
|
+
maxOutputTokens?: number | undefined;
|
|
1211
|
+
topP?: number | undefined;
|
|
1212
|
+
}, {
|
|
1213
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
1214
|
+
model: string;
|
|
1215
|
+
temperature?: number | undefined;
|
|
1216
|
+
maxOutputTokens?: number | undefined;
|
|
1217
|
+
topP?: number | undefined;
|
|
1218
|
+
}>>;
|
|
1219
|
+
language: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
1220
|
+
voice: z.ZodOptional<z.ZodObject<{
|
|
1221
|
+
provider: z.ZodEnum<["deepgram", "elevenlabs", "openai", "cartesia"]>;
|
|
1222
|
+
voiceId: z.ZodString;
|
|
1223
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1224
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
1225
|
+
}, "strip", z.ZodTypeAny, {
|
|
1226
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
1227
|
+
voiceId: string;
|
|
1228
|
+
model?: string | undefined;
|
|
1229
|
+
rate?: number | undefined;
|
|
1230
|
+
}, {
|
|
1231
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
1232
|
+
voiceId: string;
|
|
1233
|
+
model?: string | undefined;
|
|
1234
|
+
rate?: number | undefined;
|
|
1235
|
+
}>>;
|
|
1236
|
+
realtime: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1237
|
+
provider: z.ZodEnum<["openai", "google"]>;
|
|
1238
|
+
model: z.ZodString;
|
|
1239
|
+
voice: z.ZodOptional<z.ZodString>;
|
|
1240
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1241
|
+
}, "strip", z.ZodTypeAny, {
|
|
1242
|
+
provider: "openai" | "google";
|
|
1243
|
+
model: string;
|
|
1244
|
+
temperature?: number | undefined;
|
|
1245
|
+
voice?: string | undefined;
|
|
1246
|
+
}, {
|
|
1247
|
+
provider: "openai" | "google";
|
|
1248
|
+
model: string;
|
|
1249
|
+
temperature?: number | undefined;
|
|
1250
|
+
voice?: string | undefined;
|
|
1251
|
+
}>>>;
|
|
1252
|
+
systemPrompt: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1253
|
+
routingInstructions: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1254
|
+
stt: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1255
|
+
provider: z.ZodEnum<["deepgram", "cartesia", "assemblyai"]>;
|
|
1256
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1257
|
+
language: z.ZodOptional<z.ZodString>;
|
|
1258
|
+
endOfTurnConfidence: z.ZodOptional<z.ZodNumber>;
|
|
1259
|
+
endOfTurnTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1260
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1261
|
+
}, "strip", z.ZodTypeAny, {
|
|
1262
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
1263
|
+
model?: string | undefined;
|
|
1264
|
+
language?: string | undefined;
|
|
1265
|
+
endOfTurnConfidence?: number | undefined;
|
|
1266
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
1267
|
+
keywords?: string[] | undefined;
|
|
1268
|
+
}, {
|
|
1269
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
1270
|
+
model?: string | undefined;
|
|
1271
|
+
language?: string | undefined;
|
|
1272
|
+
endOfTurnConfidence?: number | undefined;
|
|
1273
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
1274
|
+
keywords?: string[] | undefined;
|
|
1275
|
+
}>>>;
|
|
1276
|
+
consultation: z.ZodOptional<z.ZodObject<{
|
|
1277
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1278
|
+
defaultTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
1279
|
+
maxTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
1280
|
+
maxCumulativeHoldMs: z.ZodDefault<z.ZodNumber>;
|
|
1281
|
+
holdPhrase: z.ZodDefault<z.ZodString>;
|
|
1282
|
+
fallbackPhrase: z.ZodDefault<z.ZodString>;
|
|
1283
|
+
callEndFallback: z.ZodDefault<z.ZodString>;
|
|
1284
|
+
urgencyOverrides: z.ZodOptional<z.ZodObject<{
|
|
1285
|
+
low: z.ZodOptional<z.ZodNumber>;
|
|
1286
|
+
normal: z.ZodOptional<z.ZodNumber>;
|
|
1287
|
+
high: z.ZodOptional<z.ZodNumber>;
|
|
1288
|
+
}, "strip", z.ZodTypeAny, {
|
|
1289
|
+
low?: number | undefined;
|
|
1290
|
+
high?: number | undefined;
|
|
1291
|
+
normal?: number | undefined;
|
|
1292
|
+
}, {
|
|
1293
|
+
low?: number | undefined;
|
|
1294
|
+
high?: number | undefined;
|
|
1295
|
+
normal?: number | undefined;
|
|
1296
|
+
}>>;
|
|
1297
|
+
}, "strip", z.ZodTypeAny, {
|
|
1298
|
+
enabled: boolean;
|
|
1299
|
+
defaultTimeoutMs: number;
|
|
1300
|
+
maxTimeoutMs: number;
|
|
1301
|
+
maxCumulativeHoldMs: number;
|
|
1302
|
+
holdPhrase: string;
|
|
1303
|
+
fallbackPhrase: string;
|
|
1304
|
+
callEndFallback: string;
|
|
1305
|
+
urgencyOverrides?: {
|
|
1306
|
+
low?: number | undefined;
|
|
1307
|
+
high?: number | undefined;
|
|
1308
|
+
normal?: number | undefined;
|
|
1309
|
+
} | undefined;
|
|
1310
|
+
}, {
|
|
1311
|
+
enabled?: boolean | undefined;
|
|
1312
|
+
defaultTimeoutMs?: number | undefined;
|
|
1313
|
+
maxTimeoutMs?: number | undefined;
|
|
1314
|
+
maxCumulativeHoldMs?: number | undefined;
|
|
1315
|
+
holdPhrase?: string | undefined;
|
|
1316
|
+
fallbackPhrase?: string | undefined;
|
|
1317
|
+
callEndFallback?: string | undefined;
|
|
1318
|
+
urgencyOverrides?: {
|
|
1319
|
+
low?: number | undefined;
|
|
1320
|
+
high?: number | undefined;
|
|
1321
|
+
normal?: number | undefined;
|
|
1322
|
+
} | undefined;
|
|
1323
|
+
}>>;
|
|
1324
|
+
process: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1325
|
+
collect: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1326
|
+
type: z.ZodEnum<["string", "string[]", "number", "boolean", "datetime", "email", "phone"]>;
|
|
1327
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
1328
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
1329
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
1330
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
1331
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1332
|
+
ask: z.ZodOptional<z.ZodString>;
|
|
1333
|
+
extract: z.ZodOptional<z.ZodString>;
|
|
1334
|
+
}, "strip", z.ZodTypeAny, {
|
|
1335
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1336
|
+
ask?: string | undefined;
|
|
1337
|
+
required?: boolean | undefined;
|
|
1338
|
+
pattern?: string | undefined;
|
|
1339
|
+
min?: number | undefined;
|
|
1340
|
+
max?: number | undefined;
|
|
1341
|
+
enum?: string[] | undefined;
|
|
1342
|
+
extract?: string | undefined;
|
|
1343
|
+
}, {
|
|
1344
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1345
|
+
ask?: string | undefined;
|
|
1346
|
+
required?: boolean | undefined;
|
|
1347
|
+
pattern?: string | undefined;
|
|
1348
|
+
min?: number | undefined;
|
|
1349
|
+
max?: number | undefined;
|
|
1350
|
+
enum?: string[] | undefined;
|
|
1351
|
+
extract?: string | undefined;
|
|
1352
|
+
}>>>;
|
|
1353
|
+
completeWhen: z.ZodDefault<z.ZodEnum<["all-required-captured", "all-captured"]>>;
|
|
1354
|
+
backendAck: z.ZodOptional<z.ZodObject<{
|
|
1355
|
+
url: z.ZodString;
|
|
1356
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1357
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1358
|
+
}, "strip", z.ZodTypeAny, {
|
|
1359
|
+
url: string;
|
|
1360
|
+
headers?: Record<string, string> | undefined;
|
|
1361
|
+
timeoutMs?: number | undefined;
|
|
1362
|
+
}, {
|
|
1363
|
+
url: string;
|
|
1364
|
+
headers?: Record<string, string> | undefined;
|
|
1365
|
+
timeoutMs?: number | undefined;
|
|
1366
|
+
}>>;
|
|
1367
|
+
}, "strip", z.ZodTypeAny, {
|
|
1368
|
+
collect: Record<string, {
|
|
1369
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1370
|
+
ask?: string | undefined;
|
|
1371
|
+
required?: boolean | undefined;
|
|
1372
|
+
pattern?: string | undefined;
|
|
1373
|
+
min?: number | undefined;
|
|
1374
|
+
max?: number | undefined;
|
|
1375
|
+
enum?: string[] | undefined;
|
|
1376
|
+
extract?: string | undefined;
|
|
1377
|
+
}>;
|
|
1378
|
+
completeWhen: "all-required-captured" | "all-captured";
|
|
1379
|
+
backendAck?: {
|
|
1380
|
+
url: string;
|
|
1381
|
+
headers?: Record<string, string> | undefined;
|
|
1382
|
+
timeoutMs?: number | undefined;
|
|
1383
|
+
} | undefined;
|
|
1384
|
+
}, {
|
|
1385
|
+
backendAck?: {
|
|
1386
|
+
url: string;
|
|
1387
|
+
headers?: Record<string, string> | undefined;
|
|
1388
|
+
timeoutMs?: number | undefined;
|
|
1389
|
+
} | undefined;
|
|
1390
|
+
collect?: Record<string, {
|
|
1391
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1392
|
+
ask?: string | undefined;
|
|
1393
|
+
required?: boolean | undefined;
|
|
1394
|
+
pattern?: string | undefined;
|
|
1395
|
+
min?: number | undefined;
|
|
1396
|
+
max?: number | undefined;
|
|
1397
|
+
enum?: string[] | undefined;
|
|
1398
|
+
extract?: string | undefined;
|
|
1399
|
+
}> | undefined;
|
|
1400
|
+
completeWhen?: "all-required-captured" | "all-captured" | undefined;
|
|
1401
|
+
}>>>;
|
|
1402
|
+
tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
1403
|
+
modeLocked: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
1404
|
+
requiredInfo: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1405
|
+
name: z.ZodString;
|
|
1406
|
+
type: z.ZodEnum<["string", "string[]", "number", "boolean", "datetime", "email", "phone"]>;
|
|
1407
|
+
required: z.ZodBoolean;
|
|
1408
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1409
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1410
|
+
}, "strip", z.ZodTypeAny, {
|
|
1411
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1412
|
+
name: string;
|
|
1413
|
+
required: boolean;
|
|
1414
|
+
enum?: string[] | undefined;
|
|
1415
|
+
description?: string | undefined;
|
|
1416
|
+
}, {
|
|
1417
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1418
|
+
name: string;
|
|
1419
|
+
required: boolean;
|
|
1420
|
+
enum?: string[] | undefined;
|
|
1421
|
+
description?: string | undefined;
|
|
1422
|
+
}>, "many">>>;
|
|
1423
|
+
}, "strip", z.ZodTypeAny, {
|
|
1424
|
+
source?: "sdk" | "flow" | undefined;
|
|
1425
|
+
name?: string | undefined;
|
|
1426
|
+
triggers?: Record<string, {
|
|
1427
|
+
then: {
|
|
1428
|
+
kind: "handoff";
|
|
1429
|
+
} | {
|
|
1430
|
+
kind: "endCall";
|
|
1431
|
+
} | {
|
|
1432
|
+
kind: "say";
|
|
1433
|
+
text: string;
|
|
1434
|
+
};
|
|
1435
|
+
on: {
|
|
1436
|
+
kind: "regex";
|
|
1437
|
+
pattern: string;
|
|
1438
|
+
flags?: string | undefined;
|
|
1439
|
+
} | {
|
|
1440
|
+
kind: "signal";
|
|
1441
|
+
name: string;
|
|
1442
|
+
};
|
|
1443
|
+
onlyWhile?: string | undefined;
|
|
1444
|
+
}> | undefined;
|
|
1445
|
+
tools?: {
|
|
1446
|
+
toolName: string;
|
|
1447
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
1448
|
+
}[] | undefined;
|
|
1449
|
+
mode?: "cascade" | "realtime" | undefined;
|
|
1450
|
+
model?: {
|
|
1451
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
1452
|
+
model: string;
|
|
1453
|
+
temperature?: number | undefined;
|
|
1454
|
+
maxOutputTokens?: number | undefined;
|
|
1455
|
+
topP?: number | undefined;
|
|
1456
|
+
} | undefined;
|
|
1457
|
+
language?: string | undefined;
|
|
1458
|
+
voice?: {
|
|
1459
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
1460
|
+
voiceId: string;
|
|
1461
|
+
model?: string | undefined;
|
|
1462
|
+
rate?: number | undefined;
|
|
1463
|
+
} | undefined;
|
|
1464
|
+
realtime?: {
|
|
1465
|
+
provider: "openai" | "google";
|
|
1466
|
+
model: string;
|
|
1467
|
+
temperature?: number | undefined;
|
|
1468
|
+
voice?: string | undefined;
|
|
1469
|
+
} | undefined;
|
|
1470
|
+
systemPrompt?: string | undefined;
|
|
1471
|
+
routingInstructions?: string | undefined;
|
|
1472
|
+
stt?: {
|
|
1473
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
1474
|
+
model?: string | undefined;
|
|
1475
|
+
language?: string | undefined;
|
|
1476
|
+
endOfTurnConfidence?: number | undefined;
|
|
1477
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
1478
|
+
keywords?: string[] | undefined;
|
|
1479
|
+
} | undefined;
|
|
1480
|
+
consultation?: {
|
|
1481
|
+
enabled: boolean;
|
|
1482
|
+
defaultTimeoutMs: number;
|
|
1483
|
+
maxTimeoutMs: number;
|
|
1484
|
+
maxCumulativeHoldMs: number;
|
|
1485
|
+
holdPhrase: string;
|
|
1486
|
+
fallbackPhrase: string;
|
|
1487
|
+
callEndFallback: string;
|
|
1488
|
+
urgencyOverrides?: {
|
|
1489
|
+
low?: number | undefined;
|
|
1490
|
+
high?: number | undefined;
|
|
1491
|
+
normal?: number | undefined;
|
|
1492
|
+
} | undefined;
|
|
1493
|
+
} | undefined;
|
|
1494
|
+
process?: {
|
|
1495
|
+
collect: Record<string, {
|
|
1496
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1497
|
+
ask?: string | undefined;
|
|
1498
|
+
required?: boolean | undefined;
|
|
1499
|
+
pattern?: string | undefined;
|
|
1500
|
+
min?: number | undefined;
|
|
1501
|
+
max?: number | undefined;
|
|
1502
|
+
enum?: string[] | undefined;
|
|
1503
|
+
extract?: string | undefined;
|
|
1504
|
+
}>;
|
|
1505
|
+
completeWhen: "all-required-captured" | "all-captured";
|
|
1506
|
+
backendAck?: {
|
|
1507
|
+
url: string;
|
|
1508
|
+
headers?: Record<string, string> | undefined;
|
|
1509
|
+
timeoutMs?: number | undefined;
|
|
1510
|
+
} | undefined;
|
|
1511
|
+
} | undefined;
|
|
1512
|
+
tags?: string[] | undefined;
|
|
1513
|
+
modeLocked?: boolean | undefined;
|
|
1514
|
+
requiredInfo?: {
|
|
1515
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1516
|
+
name: string;
|
|
1517
|
+
required: boolean;
|
|
1518
|
+
enum?: string[] | undefined;
|
|
1519
|
+
description?: string | undefined;
|
|
1520
|
+
}[] | undefined;
|
|
1521
|
+
}, {
|
|
1522
|
+
source?: "sdk" | "flow" | undefined;
|
|
1523
|
+
name?: string | undefined;
|
|
1524
|
+
triggers?: Record<string, {
|
|
1525
|
+
then: {
|
|
1526
|
+
kind: "handoff";
|
|
1527
|
+
} | {
|
|
1528
|
+
kind: "endCall";
|
|
1529
|
+
} | {
|
|
1530
|
+
kind: "say";
|
|
1531
|
+
text: string;
|
|
1532
|
+
};
|
|
1533
|
+
on: {
|
|
1534
|
+
kind: "regex";
|
|
1535
|
+
pattern: string;
|
|
1536
|
+
flags?: string | undefined;
|
|
1537
|
+
} | {
|
|
1538
|
+
kind: "signal";
|
|
1539
|
+
name: string;
|
|
1540
|
+
};
|
|
1541
|
+
onlyWhile?: string | undefined;
|
|
1542
|
+
}> | undefined;
|
|
1543
|
+
tools?: {
|
|
1544
|
+
toolName: string;
|
|
1545
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
1546
|
+
}[] | undefined;
|
|
1547
|
+
mode?: "cascade" | "realtime" | undefined;
|
|
1548
|
+
model?: {
|
|
1549
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
1550
|
+
model: string;
|
|
1551
|
+
temperature?: number | undefined;
|
|
1552
|
+
maxOutputTokens?: number | undefined;
|
|
1553
|
+
topP?: number | undefined;
|
|
1554
|
+
} | undefined;
|
|
1555
|
+
language?: string | undefined;
|
|
1556
|
+
voice?: {
|
|
1557
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
1558
|
+
voiceId: string;
|
|
1559
|
+
model?: string | undefined;
|
|
1560
|
+
rate?: number | undefined;
|
|
1561
|
+
} | undefined;
|
|
1562
|
+
realtime?: {
|
|
1563
|
+
provider: "openai" | "google";
|
|
1564
|
+
model: string;
|
|
1565
|
+
temperature?: number | undefined;
|
|
1566
|
+
voice?: string | undefined;
|
|
1567
|
+
} | undefined;
|
|
1568
|
+
systemPrompt?: string | undefined;
|
|
1569
|
+
routingInstructions?: string | undefined;
|
|
1570
|
+
stt?: {
|
|
1571
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
1572
|
+
model?: string | undefined;
|
|
1573
|
+
language?: string | undefined;
|
|
1574
|
+
endOfTurnConfidence?: number | undefined;
|
|
1575
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
1576
|
+
keywords?: string[] | undefined;
|
|
1577
|
+
} | undefined;
|
|
1578
|
+
consultation?: {
|
|
1579
|
+
enabled?: boolean | undefined;
|
|
1580
|
+
defaultTimeoutMs?: number | undefined;
|
|
1581
|
+
maxTimeoutMs?: number | undefined;
|
|
1582
|
+
maxCumulativeHoldMs?: number | undefined;
|
|
1583
|
+
holdPhrase?: string | undefined;
|
|
1584
|
+
fallbackPhrase?: string | undefined;
|
|
1585
|
+
callEndFallback?: string | undefined;
|
|
1586
|
+
urgencyOverrides?: {
|
|
1587
|
+
low?: number | undefined;
|
|
1588
|
+
high?: number | undefined;
|
|
1589
|
+
normal?: number | undefined;
|
|
1590
|
+
} | undefined;
|
|
1591
|
+
} | undefined;
|
|
1592
|
+
process?: {
|
|
1593
|
+
backendAck?: {
|
|
1594
|
+
url: string;
|
|
1595
|
+
headers?: Record<string, string> | undefined;
|
|
1596
|
+
timeoutMs?: number | undefined;
|
|
1597
|
+
} | undefined;
|
|
1598
|
+
collect?: Record<string, {
|
|
1599
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1600
|
+
ask?: string | undefined;
|
|
1601
|
+
required?: boolean | undefined;
|
|
1602
|
+
pattern?: string | undefined;
|
|
1603
|
+
min?: number | undefined;
|
|
1604
|
+
max?: number | undefined;
|
|
1605
|
+
enum?: string[] | undefined;
|
|
1606
|
+
extract?: string | undefined;
|
|
1607
|
+
}> | undefined;
|
|
1608
|
+
completeWhen?: "all-required-captured" | "all-captured" | undefined;
|
|
1609
|
+
} | undefined;
|
|
1610
|
+
tags?: string[] | undefined;
|
|
1611
|
+
modeLocked?: boolean | undefined;
|
|
1612
|
+
requiredInfo?: {
|
|
1613
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1614
|
+
name: string;
|
|
1615
|
+
required: boolean;
|
|
1616
|
+
enum?: string[] | undefined;
|
|
1617
|
+
description?: string | undefined;
|
|
1618
|
+
}[] | undefined;
|
|
1619
|
+
}>>;
|
|
1620
|
+
openQuestions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1621
|
+
id: z.ZodString;
|
|
1622
|
+
prompt: z.ZodString;
|
|
1623
|
+
kind: z.ZodEnum<["fact", "decision", "auth"]>;
|
|
1624
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1625
|
+
deferrableToCallee: z.ZodDefault<z.ZodBoolean>;
|
|
1626
|
+
}, "strip", z.ZodTypeAny, {
|
|
1627
|
+
kind: "decision" | "auth" | "fact";
|
|
1628
|
+
id: string;
|
|
1629
|
+
prompt: string;
|
|
1630
|
+
deferrableToCallee: boolean;
|
|
1631
|
+
options?: string[] | undefined;
|
|
1632
|
+
}, {
|
|
1633
|
+
kind: "decision" | "auth" | "fact";
|
|
1634
|
+
id: string;
|
|
1635
|
+
prompt: string;
|
|
1636
|
+
options?: string[] | undefined;
|
|
1637
|
+
deferrableToCallee?: boolean | undefined;
|
|
1638
|
+
}>, "many">>;
|
|
1639
|
+
unresolvedQuestions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1640
|
+
id: z.ZodString;
|
|
1641
|
+
prompt: z.ZodString;
|
|
1642
|
+
kind: z.ZodEnum<["fact", "decision", "auth"]>;
|
|
1643
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1644
|
+
deferrableToCallee: z.ZodDefault<z.ZodBoolean>;
|
|
1645
|
+
}, "strip", z.ZodTypeAny, {
|
|
1646
|
+
kind: "decision" | "auth" | "fact";
|
|
1647
|
+
id: string;
|
|
1648
|
+
prompt: string;
|
|
1649
|
+
deferrableToCallee: boolean;
|
|
1650
|
+
options?: string[] | undefined;
|
|
1651
|
+
}, {
|
|
1652
|
+
kind: "decision" | "auth" | "fact";
|
|
1653
|
+
id: string;
|
|
1654
|
+
prompt: string;
|
|
1655
|
+
options?: string[] | undefined;
|
|
1656
|
+
deferrableToCallee?: boolean | undefined;
|
|
1657
|
+
}>, "many">>;
|
|
1658
|
+
escalation: z.ZodObject<{
|
|
1659
|
+
onUncertainty: z.ZodDefault<z.ZodEnum<["consult_host", "ask_callee", "fallback_phrase"]>>;
|
|
1660
|
+
maxHostConsults: z.ZodOptional<z.ZodNumber>;
|
|
1661
|
+
hostTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1662
|
+
secondary: z.ZodDefault<z.ZodEnum<["ask_callee", "fallback_phrase"]>>;
|
|
1663
|
+
}, "strip", z.ZodTypeAny, {
|
|
1664
|
+
onUncertainty: "consult_host" | "ask_callee" | "fallback_phrase";
|
|
1665
|
+
secondary: "ask_callee" | "fallback_phrase";
|
|
1666
|
+
maxHostConsults?: number | undefined;
|
|
1667
|
+
hostTimeoutMs?: number | undefined;
|
|
1668
|
+
}, {
|
|
1669
|
+
onUncertainty?: "consult_host" | "ask_callee" | "fallback_phrase" | undefined;
|
|
1670
|
+
maxHostConsults?: number | undefined;
|
|
1671
|
+
hostTimeoutMs?: number | undefined;
|
|
1672
|
+
secondary?: "ask_callee" | "fallback_phrase" | undefined;
|
|
1673
|
+
}>;
|
|
1674
|
+
clarificationRounds: z.ZodDefault<z.ZodNumber>;
|
|
1675
|
+
committedCallId: z.ZodOptional<z.ZodString>;
|
|
1676
|
+
createdAt: z.ZodString;
|
|
1677
|
+
updatedAt: z.ZodString;
|
|
1678
|
+
}, "strip", z.ZodTypeAny, {
|
|
1679
|
+
status: "drafting" | "clarifying" | "ready" | "committed" | "abandoned";
|
|
1680
|
+
projectId: string;
|
|
1681
|
+
createdAt: string;
|
|
1682
|
+
updatedAt: string;
|
|
1683
|
+
planId: string;
|
|
1684
|
+
objective: string;
|
|
1685
|
+
callee: {
|
|
1686
|
+
description?: string | undefined;
|
|
1687
|
+
e164?: string | undefined;
|
|
1688
|
+
displayName?: string | undefined;
|
|
1689
|
+
};
|
|
1690
|
+
draftConfig: {
|
|
1691
|
+
source?: "sdk" | "flow" | undefined;
|
|
1692
|
+
name?: string | undefined;
|
|
1693
|
+
triggers?: Record<string, {
|
|
1694
|
+
then: {
|
|
1695
|
+
kind: "handoff";
|
|
1696
|
+
} | {
|
|
1697
|
+
kind: "endCall";
|
|
1698
|
+
} | {
|
|
1699
|
+
kind: "say";
|
|
1700
|
+
text: string;
|
|
1701
|
+
};
|
|
1702
|
+
on: {
|
|
1703
|
+
kind: "regex";
|
|
1704
|
+
pattern: string;
|
|
1705
|
+
flags?: string | undefined;
|
|
1706
|
+
} | {
|
|
1707
|
+
kind: "signal";
|
|
1708
|
+
name: string;
|
|
1709
|
+
};
|
|
1710
|
+
onlyWhile?: string | undefined;
|
|
1711
|
+
}> | undefined;
|
|
1712
|
+
tools?: {
|
|
1713
|
+
toolName: string;
|
|
1714
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
1715
|
+
}[] | undefined;
|
|
1716
|
+
mode?: "cascade" | "realtime" | undefined;
|
|
1717
|
+
model?: {
|
|
1718
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
1719
|
+
model: string;
|
|
1720
|
+
temperature?: number | undefined;
|
|
1721
|
+
maxOutputTokens?: number | undefined;
|
|
1722
|
+
topP?: number | undefined;
|
|
1723
|
+
} | undefined;
|
|
1724
|
+
language?: string | undefined;
|
|
1725
|
+
voice?: {
|
|
1726
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
1727
|
+
voiceId: string;
|
|
1728
|
+
model?: string | undefined;
|
|
1729
|
+
rate?: number | undefined;
|
|
1730
|
+
} | undefined;
|
|
1731
|
+
realtime?: {
|
|
1732
|
+
provider: "openai" | "google";
|
|
1733
|
+
model: string;
|
|
1734
|
+
temperature?: number | undefined;
|
|
1735
|
+
voice?: string | undefined;
|
|
1736
|
+
} | undefined;
|
|
1737
|
+
systemPrompt?: string | undefined;
|
|
1738
|
+
routingInstructions?: string | undefined;
|
|
1739
|
+
stt?: {
|
|
1740
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
1741
|
+
model?: string | undefined;
|
|
1742
|
+
language?: string | undefined;
|
|
1743
|
+
endOfTurnConfidence?: number | undefined;
|
|
1744
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
1745
|
+
keywords?: string[] | undefined;
|
|
1746
|
+
} | undefined;
|
|
1747
|
+
consultation?: {
|
|
1748
|
+
enabled: boolean;
|
|
1749
|
+
defaultTimeoutMs: number;
|
|
1750
|
+
maxTimeoutMs: number;
|
|
1751
|
+
maxCumulativeHoldMs: number;
|
|
1752
|
+
holdPhrase: string;
|
|
1753
|
+
fallbackPhrase: string;
|
|
1754
|
+
callEndFallback: string;
|
|
1755
|
+
urgencyOverrides?: {
|
|
1756
|
+
low?: number | undefined;
|
|
1757
|
+
high?: number | undefined;
|
|
1758
|
+
normal?: number | undefined;
|
|
1759
|
+
} | undefined;
|
|
1760
|
+
} | undefined;
|
|
1761
|
+
process?: {
|
|
1762
|
+
collect: Record<string, {
|
|
1763
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1764
|
+
ask?: string | undefined;
|
|
1765
|
+
required?: boolean | undefined;
|
|
1766
|
+
pattern?: string | undefined;
|
|
1767
|
+
min?: number | undefined;
|
|
1768
|
+
max?: number | undefined;
|
|
1769
|
+
enum?: string[] | undefined;
|
|
1770
|
+
extract?: string | undefined;
|
|
1771
|
+
}>;
|
|
1772
|
+
completeWhen: "all-required-captured" | "all-captured";
|
|
1773
|
+
backendAck?: {
|
|
1774
|
+
url: string;
|
|
1775
|
+
headers?: Record<string, string> | undefined;
|
|
1776
|
+
timeoutMs?: number | undefined;
|
|
1777
|
+
} | undefined;
|
|
1778
|
+
} | undefined;
|
|
1779
|
+
tags?: string[] | undefined;
|
|
1780
|
+
modeLocked?: boolean | undefined;
|
|
1781
|
+
requiredInfo?: {
|
|
1782
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1783
|
+
name: string;
|
|
1784
|
+
required: boolean;
|
|
1785
|
+
enum?: string[] | undefined;
|
|
1786
|
+
description?: string | undefined;
|
|
1787
|
+
}[] | undefined;
|
|
1788
|
+
};
|
|
1789
|
+
openQuestions: {
|
|
1790
|
+
kind: "decision" | "auth" | "fact";
|
|
1791
|
+
id: string;
|
|
1792
|
+
prompt: string;
|
|
1793
|
+
deferrableToCallee: boolean;
|
|
1794
|
+
options?: string[] | undefined;
|
|
1795
|
+
}[];
|
|
1796
|
+
unresolvedQuestions: {
|
|
1797
|
+
kind: "decision" | "auth" | "fact";
|
|
1798
|
+
id: string;
|
|
1799
|
+
prompt: string;
|
|
1800
|
+
deferrableToCallee: boolean;
|
|
1801
|
+
options?: string[] | undefined;
|
|
1802
|
+
}[];
|
|
1803
|
+
escalation: {
|
|
1804
|
+
onUncertainty: "consult_host" | "ask_callee" | "fallback_phrase";
|
|
1805
|
+
secondary: "ask_callee" | "fallback_phrase";
|
|
1806
|
+
maxHostConsults?: number | undefined;
|
|
1807
|
+
hostTimeoutMs?: number | undefined;
|
|
1808
|
+
};
|
|
1809
|
+
clarificationRounds: number;
|
|
1810
|
+
committedCallId?: string | undefined;
|
|
1811
|
+
}, {
|
|
1812
|
+
status: "drafting" | "clarifying" | "ready" | "committed" | "abandoned";
|
|
1813
|
+
projectId: string;
|
|
1814
|
+
createdAt: string;
|
|
1815
|
+
updatedAt: string;
|
|
1816
|
+
planId: string;
|
|
1817
|
+
objective: string;
|
|
1818
|
+
callee: {
|
|
1819
|
+
description?: string | undefined;
|
|
1820
|
+
e164?: string | undefined;
|
|
1821
|
+
displayName?: string | undefined;
|
|
1822
|
+
};
|
|
1823
|
+
escalation: {
|
|
1824
|
+
onUncertainty?: "consult_host" | "ask_callee" | "fallback_phrase" | undefined;
|
|
1825
|
+
maxHostConsults?: number | undefined;
|
|
1826
|
+
hostTimeoutMs?: number | undefined;
|
|
1827
|
+
secondary?: "ask_callee" | "fallback_phrase" | undefined;
|
|
1828
|
+
};
|
|
1829
|
+
draftConfig?: {
|
|
1830
|
+
source?: "sdk" | "flow" | undefined;
|
|
1831
|
+
name?: string | undefined;
|
|
1832
|
+
triggers?: Record<string, {
|
|
1833
|
+
then: {
|
|
1834
|
+
kind: "handoff";
|
|
1835
|
+
} | {
|
|
1836
|
+
kind: "endCall";
|
|
1837
|
+
} | {
|
|
1838
|
+
kind: "say";
|
|
1839
|
+
text: string;
|
|
1840
|
+
};
|
|
1841
|
+
on: {
|
|
1842
|
+
kind: "regex";
|
|
1843
|
+
pattern: string;
|
|
1844
|
+
flags?: string | undefined;
|
|
1845
|
+
} | {
|
|
1846
|
+
kind: "signal";
|
|
1847
|
+
name: string;
|
|
1848
|
+
};
|
|
1849
|
+
onlyWhile?: string | undefined;
|
|
1850
|
+
}> | undefined;
|
|
1851
|
+
tools?: {
|
|
1852
|
+
toolName: string;
|
|
1853
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
1854
|
+
}[] | undefined;
|
|
1855
|
+
mode?: "cascade" | "realtime" | undefined;
|
|
1856
|
+
model?: {
|
|
1857
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
1858
|
+
model: string;
|
|
1859
|
+
temperature?: number | undefined;
|
|
1860
|
+
maxOutputTokens?: number | undefined;
|
|
1861
|
+
topP?: number | undefined;
|
|
1862
|
+
} | undefined;
|
|
1863
|
+
language?: string | undefined;
|
|
1864
|
+
voice?: {
|
|
1865
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
1866
|
+
voiceId: string;
|
|
1867
|
+
model?: string | undefined;
|
|
1868
|
+
rate?: number | undefined;
|
|
1869
|
+
} | undefined;
|
|
1870
|
+
realtime?: {
|
|
1871
|
+
provider: "openai" | "google";
|
|
1872
|
+
model: string;
|
|
1873
|
+
temperature?: number | undefined;
|
|
1874
|
+
voice?: string | undefined;
|
|
1875
|
+
} | undefined;
|
|
1876
|
+
systemPrompt?: string | undefined;
|
|
1877
|
+
routingInstructions?: string | undefined;
|
|
1878
|
+
stt?: {
|
|
1879
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
1880
|
+
model?: string | undefined;
|
|
1881
|
+
language?: string | undefined;
|
|
1882
|
+
endOfTurnConfidence?: number | undefined;
|
|
1883
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
1884
|
+
keywords?: string[] | undefined;
|
|
1885
|
+
} | undefined;
|
|
1886
|
+
consultation?: {
|
|
1887
|
+
enabled?: boolean | undefined;
|
|
1888
|
+
defaultTimeoutMs?: number | undefined;
|
|
1889
|
+
maxTimeoutMs?: number | undefined;
|
|
1890
|
+
maxCumulativeHoldMs?: number | undefined;
|
|
1891
|
+
holdPhrase?: string | undefined;
|
|
1892
|
+
fallbackPhrase?: string | undefined;
|
|
1893
|
+
callEndFallback?: string | undefined;
|
|
1894
|
+
urgencyOverrides?: {
|
|
1895
|
+
low?: number | undefined;
|
|
1896
|
+
high?: number | undefined;
|
|
1897
|
+
normal?: number | undefined;
|
|
1898
|
+
} | undefined;
|
|
1899
|
+
} | undefined;
|
|
1900
|
+
process?: {
|
|
1901
|
+
backendAck?: {
|
|
1902
|
+
url: string;
|
|
1903
|
+
headers?: Record<string, string> | undefined;
|
|
1904
|
+
timeoutMs?: number | undefined;
|
|
1905
|
+
} | undefined;
|
|
1906
|
+
collect?: Record<string, {
|
|
1907
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1908
|
+
ask?: string | undefined;
|
|
1909
|
+
required?: boolean | undefined;
|
|
1910
|
+
pattern?: string | undefined;
|
|
1911
|
+
min?: number | undefined;
|
|
1912
|
+
max?: number | undefined;
|
|
1913
|
+
enum?: string[] | undefined;
|
|
1914
|
+
extract?: string | undefined;
|
|
1915
|
+
}> | undefined;
|
|
1916
|
+
completeWhen?: "all-required-captured" | "all-captured" | undefined;
|
|
1917
|
+
} | undefined;
|
|
1918
|
+
tags?: string[] | undefined;
|
|
1919
|
+
modeLocked?: boolean | undefined;
|
|
1920
|
+
requiredInfo?: {
|
|
1921
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
1922
|
+
name: string;
|
|
1923
|
+
required: boolean;
|
|
1924
|
+
enum?: string[] | undefined;
|
|
1925
|
+
description?: string | undefined;
|
|
1926
|
+
}[] | undefined;
|
|
1927
|
+
} | undefined;
|
|
1928
|
+
openQuestions?: {
|
|
1929
|
+
kind: "decision" | "auth" | "fact";
|
|
1930
|
+
id: string;
|
|
1931
|
+
prompt: string;
|
|
1932
|
+
options?: string[] | undefined;
|
|
1933
|
+
deferrableToCallee?: boolean | undefined;
|
|
1934
|
+
}[] | undefined;
|
|
1935
|
+
unresolvedQuestions?: {
|
|
1936
|
+
kind: "decision" | "auth" | "fact";
|
|
1937
|
+
id: string;
|
|
1938
|
+
prompt: string;
|
|
1939
|
+
options?: string[] | undefined;
|
|
1940
|
+
deferrableToCallee?: boolean | undefined;
|
|
1941
|
+
}[] | undefined;
|
|
1942
|
+
clarificationRounds?: number | undefined;
|
|
1943
|
+
committedCallId?: string | undefined;
|
|
1944
|
+
}>;
|
|
1945
|
+
type CallPlan = z.infer<typeof CallPlan>;
|
|
1946
|
+
|
|
1947
|
+
declare const MemoryScope$1: z.ZodEnum<["call", "caller", "account", "platform"]>;
|
|
1948
|
+
type MemoryScope$1 = z.infer<typeof MemoryScope$1>;
|
|
1949
|
+
declare const RelevantContext: z.ZodObject<{
|
|
1950
|
+
call: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1951
|
+
caller: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1952
|
+
account: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1953
|
+
platform: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1954
|
+
}, "strip", z.ZodTypeAny, {
|
|
1955
|
+
caller: Record<string, unknown>;
|
|
1956
|
+
call: Record<string, unknown>;
|
|
1957
|
+
account: Record<string, unknown>;
|
|
1958
|
+
platform: Record<string, unknown>;
|
|
1959
|
+
}, {
|
|
1960
|
+
caller: Record<string, unknown>;
|
|
1961
|
+
call: Record<string, unknown>;
|
|
1962
|
+
account: Record<string, unknown>;
|
|
1963
|
+
platform: Record<string, unknown>;
|
|
1964
|
+
}>;
|
|
1965
|
+
type RelevantContext = z.infer<typeof RelevantContext>;
|
|
1966
|
+
declare const ResolveCallerResponse: z.ZodObject<{
|
|
1967
|
+
caller: z.ZodObject<{
|
|
1968
|
+
id: z.ZodString;
|
|
1969
|
+
projectId: z.ZodString;
|
|
1970
|
+
externalKey: z.ZodString;
|
|
1971
|
+
displayName: z.ZodNullable<z.ZodString>;
|
|
1972
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1973
|
+
createdAt: z.ZodString;
|
|
1974
|
+
updatedAt: z.ZodString;
|
|
1975
|
+
}, "strip", z.ZodTypeAny, {
|
|
1976
|
+
id: string;
|
|
1977
|
+
projectId: string;
|
|
1978
|
+
createdAt: string;
|
|
1979
|
+
updatedAt: string;
|
|
1980
|
+
metadata: Record<string, unknown>;
|
|
1981
|
+
displayName: string | null;
|
|
1982
|
+
externalKey: string;
|
|
1983
|
+
}, {
|
|
1984
|
+
id: string;
|
|
1985
|
+
projectId: string;
|
|
1986
|
+
createdAt: string;
|
|
1987
|
+
updatedAt: string;
|
|
1988
|
+
metadata: Record<string, unknown>;
|
|
1989
|
+
displayName: string | null;
|
|
1990
|
+
externalKey: string;
|
|
1991
|
+
}>;
|
|
1992
|
+
}, "strip", z.ZodTypeAny, {
|
|
1993
|
+
caller: {
|
|
1994
|
+
id: string;
|
|
1995
|
+
projectId: string;
|
|
1996
|
+
createdAt: string;
|
|
1997
|
+
updatedAt: string;
|
|
1998
|
+
metadata: Record<string, unknown>;
|
|
1999
|
+
displayName: string | null;
|
|
2000
|
+
externalKey: string;
|
|
2001
|
+
};
|
|
2002
|
+
}, {
|
|
2003
|
+
caller: {
|
|
2004
|
+
id: string;
|
|
2005
|
+
projectId: string;
|
|
2006
|
+
createdAt: string;
|
|
2007
|
+
updatedAt: string;
|
|
2008
|
+
metadata: Record<string, unknown>;
|
|
2009
|
+
displayName: string | null;
|
|
2010
|
+
externalKey: string;
|
|
2011
|
+
};
|
|
2012
|
+
}>;
|
|
2013
|
+
type ResolveCallerResponse = z.infer<typeof ResolveCallerResponse>;
|
|
2014
|
+
declare const DeleteCallerResponse: z.ZodObject<{
|
|
2015
|
+
ok: z.ZodLiteral<true>;
|
|
2016
|
+
scopesPurged: z.ZodArray<z.ZodEnum<["call", "caller", "account", "platform"]>, "many">;
|
|
2017
|
+
}, "strip", z.ZodTypeAny, {
|
|
2018
|
+
ok: true;
|
|
2019
|
+
scopesPurged: ("caller" | "call" | "account" | "platform")[];
|
|
2020
|
+
}, {
|
|
2021
|
+
ok: true;
|
|
2022
|
+
scopesPurged: ("caller" | "call" | "account" | "platform")[];
|
|
2023
|
+
}>;
|
|
2024
|
+
type DeleteCallerResponse = z.infer<typeof DeleteCallerResponse>;
|
|
2025
|
+
|
|
2026
|
+
/** Policy embedded in AgentConfig — caps + UX wording. */
|
|
2027
|
+
declare const ConsultationPolicy: z.ZodObject<{
|
|
2028
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
2029
|
+
defaultTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
2030
|
+
maxTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
2031
|
+
maxCumulativeHoldMs: z.ZodDefault<z.ZodNumber>;
|
|
2032
|
+
holdPhrase: z.ZodDefault<z.ZodString>;
|
|
2033
|
+
fallbackPhrase: z.ZodDefault<z.ZodString>;
|
|
2034
|
+
callEndFallback: z.ZodDefault<z.ZodString>;
|
|
2035
|
+
urgencyOverrides: z.ZodOptional<z.ZodObject<{
|
|
2036
|
+
low: z.ZodOptional<z.ZodNumber>;
|
|
2037
|
+
normal: z.ZodOptional<z.ZodNumber>;
|
|
2038
|
+
high: z.ZodOptional<z.ZodNumber>;
|
|
2039
|
+
}, "strip", z.ZodTypeAny, {
|
|
2040
|
+
low?: number | undefined;
|
|
2041
|
+
high?: number | undefined;
|
|
2042
|
+
normal?: number | undefined;
|
|
2043
|
+
}, {
|
|
2044
|
+
low?: number | undefined;
|
|
2045
|
+
high?: number | undefined;
|
|
2046
|
+
normal?: number | undefined;
|
|
2047
|
+
}>>;
|
|
2048
|
+
}, "strip", z.ZodTypeAny, {
|
|
2049
|
+
enabled: boolean;
|
|
2050
|
+
defaultTimeoutMs: number;
|
|
2051
|
+
maxTimeoutMs: number;
|
|
2052
|
+
maxCumulativeHoldMs: number;
|
|
2053
|
+
holdPhrase: string;
|
|
2054
|
+
fallbackPhrase: string;
|
|
2055
|
+
callEndFallback: string;
|
|
2056
|
+
urgencyOverrides?: {
|
|
2057
|
+
low?: number | undefined;
|
|
2058
|
+
high?: number | undefined;
|
|
2059
|
+
normal?: number | undefined;
|
|
2060
|
+
} | undefined;
|
|
2061
|
+
}, {
|
|
2062
|
+
enabled?: boolean | undefined;
|
|
2063
|
+
defaultTimeoutMs?: number | undefined;
|
|
2064
|
+
maxTimeoutMs?: number | undefined;
|
|
2065
|
+
maxCumulativeHoldMs?: number | undefined;
|
|
2066
|
+
holdPhrase?: string | undefined;
|
|
2067
|
+
fallbackPhrase?: string | undefined;
|
|
2068
|
+
callEndFallback?: string | undefined;
|
|
2069
|
+
urgencyOverrides?: {
|
|
2070
|
+
low?: number | undefined;
|
|
2071
|
+
high?: number | undefined;
|
|
2072
|
+
normal?: number | undefined;
|
|
2073
|
+
} | undefined;
|
|
2074
|
+
}>;
|
|
2075
|
+
type ConsultationPolicy = z.infer<typeof ConsultationPolicy>;
|
|
2076
|
+
|
|
2077
|
+
declare const AgentConfig$1: z.ZodObject<{
|
|
2078
|
+
id: z.ZodString;
|
|
2079
|
+
projectId: z.ZodString;
|
|
2080
|
+
name: z.ZodString;
|
|
2081
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
2082
|
+
routingInstructions: z.ZodOptional<z.ZodString>;
|
|
2083
|
+
voice: z.ZodObject<{
|
|
2084
|
+
provider: z.ZodEnum<["deepgram", "elevenlabs", "openai", "cartesia"]>;
|
|
2085
|
+
voiceId: z.ZodString;
|
|
2086
|
+
model: z.ZodOptional<z.ZodString>;
|
|
2087
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
2088
|
+
}, "strip", z.ZodTypeAny, {
|
|
2089
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
2090
|
+
voiceId: string;
|
|
2091
|
+
model?: string | undefined;
|
|
2092
|
+
rate?: number | undefined;
|
|
2093
|
+
}, {
|
|
2094
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
2095
|
+
voiceId: string;
|
|
2096
|
+
model?: string | undefined;
|
|
2097
|
+
rate?: number | undefined;
|
|
2098
|
+
}>;
|
|
2099
|
+
model: z.ZodObject<{
|
|
2100
|
+
provider: z.ZodEnum<["openai", "anthropic", "gemini"]>;
|
|
2101
|
+
model: z.ZodString;
|
|
2102
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2103
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
2104
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
2105
|
+
}, "strip", z.ZodTypeAny, {
|
|
2106
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
2107
|
+
model: string;
|
|
2108
|
+
temperature?: number | undefined;
|
|
2109
|
+
maxOutputTokens?: number | undefined;
|
|
2110
|
+
topP?: number | undefined;
|
|
2111
|
+
}, {
|
|
2112
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
2113
|
+
model: string;
|
|
2114
|
+
temperature?: number | undefined;
|
|
2115
|
+
maxOutputTokens?: number | undefined;
|
|
2116
|
+
topP?: number | undefined;
|
|
2117
|
+
}>;
|
|
2118
|
+
stt: z.ZodOptional<z.ZodObject<{
|
|
2119
|
+
provider: z.ZodEnum<["deepgram", "cartesia", "assemblyai"]>;
|
|
2120
|
+
model: z.ZodOptional<z.ZodString>;
|
|
2121
|
+
language: z.ZodOptional<z.ZodString>;
|
|
2122
|
+
endOfTurnConfidence: z.ZodOptional<z.ZodNumber>;
|
|
2123
|
+
endOfTurnTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
2124
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2125
|
+
}, "strip", z.ZodTypeAny, {
|
|
2126
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
2127
|
+
model?: string | undefined;
|
|
2128
|
+
language?: string | undefined;
|
|
2129
|
+
endOfTurnConfidence?: number | undefined;
|
|
2130
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
2131
|
+
keywords?: string[] | undefined;
|
|
2132
|
+
}, {
|
|
2133
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
2134
|
+
model?: string | undefined;
|
|
2135
|
+
language?: string | undefined;
|
|
2136
|
+
endOfTurnConfidence?: number | undefined;
|
|
2137
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
2138
|
+
keywords?: string[] | undefined;
|
|
2139
|
+
}>>;
|
|
2140
|
+
mode: z.ZodDefault<z.ZodEnum<["cascade", "realtime"]>>;
|
|
2141
|
+
realtime: z.ZodOptional<z.ZodObject<{
|
|
2142
|
+
provider: z.ZodEnum<["openai", "google"]>;
|
|
2143
|
+
model: z.ZodString;
|
|
2144
|
+
voice: z.ZodOptional<z.ZodString>;
|
|
2145
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2146
|
+
}, "strip", z.ZodTypeAny, {
|
|
2147
|
+
provider: "openai" | "google";
|
|
2148
|
+
model: string;
|
|
2149
|
+
temperature?: number | undefined;
|
|
2150
|
+
voice?: string | undefined;
|
|
2151
|
+
}, {
|
|
2152
|
+
provider: "openai" | "google";
|
|
2153
|
+
model: string;
|
|
2154
|
+
temperature?: number | undefined;
|
|
2155
|
+
voice?: string | undefined;
|
|
2156
|
+
}>>;
|
|
2157
|
+
language: z.ZodDefault<z.ZodString>;
|
|
2158
|
+
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
2159
|
+
toolName: z.ZodString;
|
|
2160
|
+
defaultArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2161
|
+
}, "strip", z.ZodTypeAny, {
|
|
2162
|
+
toolName: string;
|
|
2163
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
2164
|
+
}, {
|
|
2165
|
+
toolName: string;
|
|
2166
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
2167
|
+
}>, "many">>;
|
|
2168
|
+
consultation: z.ZodObject<{
|
|
2169
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
2170
|
+
defaultTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
2171
|
+
maxTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
2172
|
+
maxCumulativeHoldMs: z.ZodDefault<z.ZodNumber>;
|
|
2173
|
+
holdPhrase: z.ZodDefault<z.ZodString>;
|
|
2174
|
+
fallbackPhrase: z.ZodDefault<z.ZodString>;
|
|
2175
|
+
callEndFallback: z.ZodDefault<z.ZodString>;
|
|
2176
|
+
urgencyOverrides: z.ZodOptional<z.ZodObject<{
|
|
2177
|
+
low: z.ZodOptional<z.ZodNumber>;
|
|
2178
|
+
normal: z.ZodOptional<z.ZodNumber>;
|
|
2179
|
+
high: z.ZodOptional<z.ZodNumber>;
|
|
2180
|
+
}, "strip", z.ZodTypeAny, {
|
|
2181
|
+
low?: number | undefined;
|
|
2182
|
+
high?: number | undefined;
|
|
2183
|
+
normal?: number | undefined;
|
|
2184
|
+
}, {
|
|
2185
|
+
low?: number | undefined;
|
|
2186
|
+
high?: number | undefined;
|
|
2187
|
+
normal?: number | undefined;
|
|
2188
|
+
}>>;
|
|
2189
|
+
}, "strip", z.ZodTypeAny, {
|
|
2190
|
+
enabled: boolean;
|
|
2191
|
+
defaultTimeoutMs: number;
|
|
2192
|
+
maxTimeoutMs: number;
|
|
2193
|
+
maxCumulativeHoldMs: number;
|
|
2194
|
+
holdPhrase: string;
|
|
2195
|
+
fallbackPhrase: string;
|
|
2196
|
+
callEndFallback: string;
|
|
2197
|
+
urgencyOverrides?: {
|
|
2198
|
+
low?: number | undefined;
|
|
2199
|
+
high?: number | undefined;
|
|
2200
|
+
normal?: number | undefined;
|
|
2201
|
+
} | undefined;
|
|
2202
|
+
}, {
|
|
2203
|
+
enabled?: boolean | undefined;
|
|
2204
|
+
defaultTimeoutMs?: number | undefined;
|
|
2205
|
+
maxTimeoutMs?: number | undefined;
|
|
2206
|
+
maxCumulativeHoldMs?: number | undefined;
|
|
2207
|
+
holdPhrase?: string | undefined;
|
|
2208
|
+
fallbackPhrase?: string | undefined;
|
|
2209
|
+
callEndFallback?: string | undefined;
|
|
2210
|
+
urgencyOverrides?: {
|
|
2211
|
+
low?: number | undefined;
|
|
2212
|
+
high?: number | undefined;
|
|
2213
|
+
normal?: number | undefined;
|
|
2214
|
+
} | undefined;
|
|
2215
|
+
}>;
|
|
2216
|
+
process: z.ZodOptional<z.ZodObject<{
|
|
2217
|
+
collect: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
2218
|
+
type: z.ZodEnum<["string", "string[]", "number", "boolean", "datetime", "email", "phone"]>;
|
|
2219
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
2220
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
2221
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
2222
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
2223
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2224
|
+
ask: z.ZodOptional<z.ZodString>;
|
|
2225
|
+
extract: z.ZodOptional<z.ZodString>;
|
|
2226
|
+
}, "strip", z.ZodTypeAny, {
|
|
2227
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2228
|
+
ask?: string | undefined;
|
|
2229
|
+
required?: boolean | undefined;
|
|
2230
|
+
pattern?: string | undefined;
|
|
2231
|
+
min?: number | undefined;
|
|
2232
|
+
max?: number | undefined;
|
|
2233
|
+
enum?: string[] | undefined;
|
|
2234
|
+
extract?: string | undefined;
|
|
2235
|
+
}, {
|
|
2236
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2237
|
+
ask?: string | undefined;
|
|
2238
|
+
required?: boolean | undefined;
|
|
2239
|
+
pattern?: string | undefined;
|
|
2240
|
+
min?: number | undefined;
|
|
2241
|
+
max?: number | undefined;
|
|
2242
|
+
enum?: string[] | undefined;
|
|
2243
|
+
extract?: string | undefined;
|
|
2244
|
+
}>>>;
|
|
2245
|
+
completeWhen: z.ZodDefault<z.ZodEnum<["all-required-captured", "all-captured"]>>;
|
|
2246
|
+
backendAck: z.ZodOptional<z.ZodObject<{
|
|
2247
|
+
url: z.ZodString;
|
|
2248
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
2249
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2250
|
+
}, "strip", z.ZodTypeAny, {
|
|
2251
|
+
url: string;
|
|
2252
|
+
headers?: Record<string, string> | undefined;
|
|
2253
|
+
timeoutMs?: number | undefined;
|
|
2254
|
+
}, {
|
|
2255
|
+
url: string;
|
|
2256
|
+
headers?: Record<string, string> | undefined;
|
|
2257
|
+
timeoutMs?: number | undefined;
|
|
2258
|
+
}>>;
|
|
2259
|
+
}, "strip", z.ZodTypeAny, {
|
|
2260
|
+
collect: Record<string, {
|
|
2261
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2262
|
+
ask?: string | undefined;
|
|
2263
|
+
required?: boolean | undefined;
|
|
2264
|
+
pattern?: string | undefined;
|
|
2265
|
+
min?: number | undefined;
|
|
2266
|
+
max?: number | undefined;
|
|
2267
|
+
enum?: string[] | undefined;
|
|
2268
|
+
extract?: string | undefined;
|
|
2269
|
+
}>;
|
|
2270
|
+
completeWhen: "all-required-captured" | "all-captured";
|
|
2271
|
+
backendAck?: {
|
|
2272
|
+
url: string;
|
|
2273
|
+
headers?: Record<string, string> | undefined;
|
|
2274
|
+
timeoutMs?: number | undefined;
|
|
2275
|
+
} | undefined;
|
|
2276
|
+
}, {
|
|
2277
|
+
backendAck?: {
|
|
2278
|
+
url: string;
|
|
2279
|
+
headers?: Record<string, string> | undefined;
|
|
2280
|
+
timeoutMs?: number | undefined;
|
|
2281
|
+
} | undefined;
|
|
2282
|
+
collect?: Record<string, {
|
|
2283
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2284
|
+
ask?: string | undefined;
|
|
2285
|
+
required?: boolean | undefined;
|
|
2286
|
+
pattern?: string | undefined;
|
|
2287
|
+
min?: number | undefined;
|
|
2288
|
+
max?: number | undefined;
|
|
2289
|
+
enum?: string[] | undefined;
|
|
2290
|
+
extract?: string | undefined;
|
|
2291
|
+
}> | undefined;
|
|
2292
|
+
completeWhen?: "all-required-captured" | "all-captured" | undefined;
|
|
2293
|
+
}>>;
|
|
2294
|
+
triggers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
2295
|
+
on: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
2296
|
+
kind: z.ZodLiteral<"regex">;
|
|
2297
|
+
pattern: z.ZodString;
|
|
2298
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
2299
|
+
}, "strip", z.ZodTypeAny, {
|
|
2300
|
+
kind: "regex";
|
|
2301
|
+
pattern: string;
|
|
2302
|
+
flags?: string | undefined;
|
|
2303
|
+
}, {
|
|
2304
|
+
kind: "regex";
|
|
2305
|
+
pattern: string;
|
|
2306
|
+
flags?: string | undefined;
|
|
2307
|
+
}>, z.ZodObject<{
|
|
2308
|
+
kind: z.ZodLiteral<"signal">;
|
|
2309
|
+
name: z.ZodString;
|
|
2310
|
+
}, "strip", z.ZodTypeAny, {
|
|
2311
|
+
kind: "signal";
|
|
2312
|
+
name: string;
|
|
2313
|
+
}, {
|
|
2314
|
+
kind: "signal";
|
|
2315
|
+
name: string;
|
|
2316
|
+
}>]>;
|
|
2317
|
+
then: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
2318
|
+
kind: z.ZodLiteral<"handoff">;
|
|
2319
|
+
}, "strip", z.ZodTypeAny, {
|
|
2320
|
+
kind: "handoff";
|
|
2321
|
+
}, {
|
|
2322
|
+
kind: "handoff";
|
|
2323
|
+
}>, z.ZodObject<{
|
|
2324
|
+
kind: z.ZodLiteral<"endCall">;
|
|
2325
|
+
}, "strip", z.ZodTypeAny, {
|
|
2326
|
+
kind: "endCall";
|
|
2327
|
+
}, {
|
|
2328
|
+
kind: "endCall";
|
|
2329
|
+
}>, z.ZodObject<{
|
|
2330
|
+
kind: z.ZodLiteral<"say">;
|
|
2331
|
+
text: z.ZodString;
|
|
2332
|
+
}, "strip", z.ZodTypeAny, {
|
|
2333
|
+
kind: "say";
|
|
2334
|
+
text: string;
|
|
2335
|
+
}, {
|
|
2336
|
+
kind: "say";
|
|
2337
|
+
text: string;
|
|
2338
|
+
}>]>;
|
|
2339
|
+
onlyWhile: z.ZodOptional<z.ZodString>;
|
|
2340
|
+
}, "strip", z.ZodTypeAny, {
|
|
2341
|
+
then: {
|
|
2342
|
+
kind: "handoff";
|
|
2343
|
+
} | {
|
|
2344
|
+
kind: "endCall";
|
|
2345
|
+
} | {
|
|
2346
|
+
kind: "say";
|
|
2347
|
+
text: string;
|
|
2348
|
+
};
|
|
2349
|
+
on: {
|
|
2350
|
+
kind: "regex";
|
|
2351
|
+
pattern: string;
|
|
2352
|
+
flags?: string | undefined;
|
|
2353
|
+
} | {
|
|
2354
|
+
kind: "signal";
|
|
2355
|
+
name: string;
|
|
2356
|
+
};
|
|
2357
|
+
onlyWhile?: string | undefined;
|
|
2358
|
+
}, {
|
|
2359
|
+
then: {
|
|
2360
|
+
kind: "handoff";
|
|
2361
|
+
} | {
|
|
2362
|
+
kind: "endCall";
|
|
2363
|
+
} | {
|
|
2364
|
+
kind: "say";
|
|
2365
|
+
text: string;
|
|
2366
|
+
};
|
|
2367
|
+
on: {
|
|
2368
|
+
kind: "regex";
|
|
2369
|
+
pattern: string;
|
|
2370
|
+
flags?: string | undefined;
|
|
2371
|
+
} | {
|
|
2372
|
+
kind: "signal";
|
|
2373
|
+
name: string;
|
|
2374
|
+
};
|
|
2375
|
+
onlyWhile?: string | undefined;
|
|
2376
|
+
}>>>;
|
|
2377
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2378
|
+
source: z.ZodOptional<z.ZodEnum<["sdk", "flow"]>>;
|
|
2379
|
+
modeLocked: z.ZodOptional<z.ZodBoolean>;
|
|
2380
|
+
requiredInfo: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
2381
|
+
name: z.ZodString;
|
|
2382
|
+
type: z.ZodEnum<["string", "string[]", "number", "boolean", "datetime", "email", "phone"]>;
|
|
2383
|
+
required: z.ZodBoolean;
|
|
2384
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2385
|
+
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2386
|
+
}, "strip", z.ZodTypeAny, {
|
|
2387
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2388
|
+
name: string;
|
|
2389
|
+
required: boolean;
|
|
2390
|
+
enum?: string[] | undefined;
|
|
2391
|
+
description?: string | undefined;
|
|
2392
|
+
}, {
|
|
2393
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2394
|
+
name: string;
|
|
2395
|
+
required: boolean;
|
|
2396
|
+
enum?: string[] | undefined;
|
|
2397
|
+
description?: string | undefined;
|
|
2398
|
+
}>, "many">>;
|
|
2399
|
+
createdAt: z.ZodString;
|
|
2400
|
+
updatedAt: z.ZodString;
|
|
2401
|
+
}, "strip", z.ZodTypeAny, {
|
|
2402
|
+
id: string;
|
|
2403
|
+
projectId: string;
|
|
2404
|
+
name: string;
|
|
2405
|
+
createdAt: string;
|
|
2406
|
+
updatedAt: string;
|
|
2407
|
+
tools: {
|
|
2408
|
+
toolName: string;
|
|
2409
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
2410
|
+
}[];
|
|
2411
|
+
mode: "cascade" | "realtime";
|
|
2412
|
+
model: {
|
|
2413
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
2414
|
+
model: string;
|
|
2415
|
+
temperature?: number | undefined;
|
|
2416
|
+
maxOutputTokens?: number | undefined;
|
|
2417
|
+
topP?: number | undefined;
|
|
2418
|
+
};
|
|
2419
|
+
language: string;
|
|
2420
|
+
voice: {
|
|
2421
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
2422
|
+
voiceId: string;
|
|
2423
|
+
model?: string | undefined;
|
|
2424
|
+
rate?: number | undefined;
|
|
2425
|
+
};
|
|
2426
|
+
consultation: {
|
|
2427
|
+
enabled: boolean;
|
|
2428
|
+
defaultTimeoutMs: number;
|
|
2429
|
+
maxTimeoutMs: number;
|
|
2430
|
+
maxCumulativeHoldMs: number;
|
|
2431
|
+
holdPhrase: string;
|
|
2432
|
+
fallbackPhrase: string;
|
|
2433
|
+
callEndFallback: string;
|
|
2434
|
+
urgencyOverrides?: {
|
|
2435
|
+
low?: number | undefined;
|
|
2436
|
+
high?: number | undefined;
|
|
2437
|
+
normal?: number | undefined;
|
|
2438
|
+
} | undefined;
|
|
2439
|
+
};
|
|
2440
|
+
requiredInfo: {
|
|
2441
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2442
|
+
name: string;
|
|
2443
|
+
required: boolean;
|
|
2444
|
+
enum?: string[] | undefined;
|
|
2445
|
+
description?: string | undefined;
|
|
2446
|
+
}[];
|
|
2447
|
+
source?: "sdk" | "flow" | undefined;
|
|
2448
|
+
triggers?: Record<string, {
|
|
2449
|
+
then: {
|
|
2450
|
+
kind: "handoff";
|
|
2451
|
+
} | {
|
|
2452
|
+
kind: "endCall";
|
|
2453
|
+
} | {
|
|
2454
|
+
kind: "say";
|
|
2455
|
+
text: string;
|
|
2456
|
+
};
|
|
2457
|
+
on: {
|
|
2458
|
+
kind: "regex";
|
|
2459
|
+
pattern: string;
|
|
2460
|
+
flags?: string | undefined;
|
|
2461
|
+
} | {
|
|
2462
|
+
kind: "signal";
|
|
2463
|
+
name: string;
|
|
2464
|
+
};
|
|
2465
|
+
onlyWhile?: string | undefined;
|
|
2466
|
+
}> | undefined;
|
|
2467
|
+
realtime?: {
|
|
2468
|
+
provider: "openai" | "google";
|
|
2469
|
+
model: string;
|
|
2470
|
+
temperature?: number | undefined;
|
|
2471
|
+
voice?: string | undefined;
|
|
2472
|
+
} | undefined;
|
|
2473
|
+
systemPrompt?: string | undefined;
|
|
2474
|
+
routingInstructions?: string | undefined;
|
|
2475
|
+
stt?: {
|
|
2476
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
2477
|
+
model?: string | undefined;
|
|
2478
|
+
language?: string | undefined;
|
|
2479
|
+
endOfTurnConfidence?: number | undefined;
|
|
2480
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
2481
|
+
keywords?: string[] | undefined;
|
|
2482
|
+
} | undefined;
|
|
2483
|
+
process?: {
|
|
2484
|
+
collect: Record<string, {
|
|
2485
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2486
|
+
ask?: string | undefined;
|
|
2487
|
+
required?: boolean | undefined;
|
|
2488
|
+
pattern?: string | undefined;
|
|
2489
|
+
min?: number | undefined;
|
|
2490
|
+
max?: number | undefined;
|
|
2491
|
+
enum?: string[] | undefined;
|
|
2492
|
+
extract?: string | undefined;
|
|
2493
|
+
}>;
|
|
2494
|
+
completeWhen: "all-required-captured" | "all-captured";
|
|
2495
|
+
backendAck?: {
|
|
2496
|
+
url: string;
|
|
2497
|
+
headers?: Record<string, string> | undefined;
|
|
2498
|
+
timeoutMs?: number | undefined;
|
|
2499
|
+
} | undefined;
|
|
2500
|
+
} | undefined;
|
|
2501
|
+
tags?: string[] | undefined;
|
|
2502
|
+
modeLocked?: boolean | undefined;
|
|
2503
|
+
}, {
|
|
2504
|
+
id: string;
|
|
2505
|
+
projectId: string;
|
|
2506
|
+
name: string;
|
|
2507
|
+
createdAt: string;
|
|
2508
|
+
updatedAt: string;
|
|
2509
|
+
model: {
|
|
2510
|
+
provider: "openai" | "anthropic" | "gemini";
|
|
2511
|
+
model: string;
|
|
2512
|
+
temperature?: number | undefined;
|
|
2513
|
+
maxOutputTokens?: number | undefined;
|
|
2514
|
+
topP?: number | undefined;
|
|
2515
|
+
};
|
|
2516
|
+
voice: {
|
|
2517
|
+
provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
|
|
2518
|
+
voiceId: string;
|
|
2519
|
+
model?: string | undefined;
|
|
2520
|
+
rate?: number | undefined;
|
|
2521
|
+
};
|
|
2522
|
+
consultation: {
|
|
2523
|
+
enabled?: boolean | undefined;
|
|
2524
|
+
defaultTimeoutMs?: number | undefined;
|
|
2525
|
+
maxTimeoutMs?: number | undefined;
|
|
2526
|
+
maxCumulativeHoldMs?: number | undefined;
|
|
2527
|
+
holdPhrase?: string | undefined;
|
|
2528
|
+
fallbackPhrase?: string | undefined;
|
|
2529
|
+
callEndFallback?: string | undefined;
|
|
2530
|
+
urgencyOverrides?: {
|
|
2531
|
+
low?: number | undefined;
|
|
2532
|
+
high?: number | undefined;
|
|
2533
|
+
normal?: number | undefined;
|
|
2534
|
+
} | undefined;
|
|
2535
|
+
};
|
|
2536
|
+
source?: "sdk" | "flow" | undefined;
|
|
2537
|
+
triggers?: Record<string, {
|
|
2538
|
+
then: {
|
|
2539
|
+
kind: "handoff";
|
|
2540
|
+
} | {
|
|
2541
|
+
kind: "endCall";
|
|
2542
|
+
} | {
|
|
2543
|
+
kind: "say";
|
|
2544
|
+
text: string;
|
|
2545
|
+
};
|
|
2546
|
+
on: {
|
|
2547
|
+
kind: "regex";
|
|
2548
|
+
pattern: string;
|
|
2549
|
+
flags?: string | undefined;
|
|
2550
|
+
} | {
|
|
2551
|
+
kind: "signal";
|
|
2552
|
+
name: string;
|
|
2553
|
+
};
|
|
2554
|
+
onlyWhile?: string | undefined;
|
|
2555
|
+
}> | undefined;
|
|
2556
|
+
tools?: {
|
|
2557
|
+
toolName: string;
|
|
2558
|
+
defaultArgs?: Record<string, unknown> | undefined;
|
|
2559
|
+
}[] | undefined;
|
|
2560
|
+
mode?: "cascade" | "realtime" | undefined;
|
|
2561
|
+
language?: string | undefined;
|
|
2562
|
+
realtime?: {
|
|
2563
|
+
provider: "openai" | "google";
|
|
2564
|
+
model: string;
|
|
2565
|
+
temperature?: number | undefined;
|
|
2566
|
+
voice?: string | undefined;
|
|
2567
|
+
} | undefined;
|
|
2568
|
+
systemPrompt?: string | undefined;
|
|
2569
|
+
routingInstructions?: string | undefined;
|
|
2570
|
+
stt?: {
|
|
2571
|
+
provider: "deepgram" | "cartesia" | "assemblyai";
|
|
2572
|
+
model?: string | undefined;
|
|
2573
|
+
language?: string | undefined;
|
|
2574
|
+
endOfTurnConfidence?: number | undefined;
|
|
2575
|
+
endOfTurnTimeoutMs?: number | undefined;
|
|
2576
|
+
keywords?: string[] | undefined;
|
|
2577
|
+
} | undefined;
|
|
2578
|
+
process?: {
|
|
2579
|
+
backendAck?: {
|
|
2580
|
+
url: string;
|
|
2581
|
+
headers?: Record<string, string> | undefined;
|
|
2582
|
+
timeoutMs?: number | undefined;
|
|
2583
|
+
} | undefined;
|
|
2584
|
+
collect?: Record<string, {
|
|
2585
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2586
|
+
ask?: string | undefined;
|
|
2587
|
+
required?: boolean | undefined;
|
|
2588
|
+
pattern?: string | undefined;
|
|
2589
|
+
min?: number | undefined;
|
|
2590
|
+
max?: number | undefined;
|
|
2591
|
+
enum?: string[] | undefined;
|
|
2592
|
+
extract?: string | undefined;
|
|
2593
|
+
}> | undefined;
|
|
2594
|
+
completeWhen?: "all-required-captured" | "all-captured" | undefined;
|
|
2595
|
+
} | undefined;
|
|
2596
|
+
tags?: string[] | undefined;
|
|
2597
|
+
modeLocked?: boolean | undefined;
|
|
2598
|
+
requiredInfo?: {
|
|
2599
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2600
|
+
name: string;
|
|
2601
|
+
required: boolean;
|
|
2602
|
+
enum?: string[] | undefined;
|
|
2603
|
+
description?: string | undefined;
|
|
2604
|
+
}[] | undefined;
|
|
2605
|
+
}>;
|
|
2606
|
+
type AgentConfig$1 = z.infer<typeof AgentConfig$1>;
|
|
2607
|
+
|
|
2608
|
+
interface TransportOptions {
|
|
2609
|
+
readonly apiKey: string;
|
|
2610
|
+
readonly baseUrl: string;
|
|
2611
|
+
readonly fetch?: typeof fetch;
|
|
2612
|
+
readonly maxRetries?: number;
|
|
2613
|
+
readonly initialBackoffMs?: number;
|
|
2614
|
+
readonly userAgent?: string;
|
|
2615
|
+
}
|
|
2616
|
+
interface RequestOptions {
|
|
2617
|
+
readonly method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
2618
|
+
readonly path: string;
|
|
2619
|
+
readonly body?: unknown;
|
|
2620
|
+
readonly query?: Record<string, string | undefined>;
|
|
2621
|
+
readonly signal?: AbortSignal;
|
|
2622
|
+
/** Extra request headers, merged on top of the defaults (auth/content-type
|
|
2623
|
+
* etc). Lowercase keys recommended. */
|
|
2624
|
+
readonly headers?: Record<string, string>;
|
|
2625
|
+
}
|
|
2626
|
+
declare class Transport {
|
|
2627
|
+
private readonly options;
|
|
2628
|
+
private readonly fetchImpl;
|
|
2629
|
+
private readonly maxRetries;
|
|
2630
|
+
private readonly initialBackoffMs;
|
|
2631
|
+
constructor(options: TransportOptions);
|
|
2632
|
+
request<T>(opts: RequestOptions, schema: ZodType<T>): Promise<T>;
|
|
2633
|
+
private backoffMs;
|
|
2634
|
+
}
|
|
2635
|
+
|
|
2636
|
+
interface ReadinessResult {
|
|
2637
|
+
readonly ok: boolean;
|
|
2638
|
+
/** Human-readable explanation when ok=false. Surfaced in metadata. */
|
|
2639
|
+
readonly detail?: string;
|
|
2640
|
+
}
|
|
2641
|
+
interface ReadinessProbe {
|
|
2642
|
+
readonly name: string;
|
|
2643
|
+
check(): Promise<ReadinessResult>;
|
|
2644
|
+
}
|
|
2645
|
+
/** Aggregate result the SDK records in metadata.readiness. */
|
|
2646
|
+
interface ReadinessReport {
|
|
2647
|
+
readonly probe: string;
|
|
2648
|
+
readonly ok: boolean;
|
|
2649
|
+
readonly detail?: string;
|
|
2650
|
+
}
|
|
2651
|
+
/**
|
|
2652
|
+
* Run all probes in parallel. A probe that throws is reported as not-ok with
|
|
2653
|
+
* the error message as detail; one bad probe never sinks the others.
|
|
2654
|
+
*/
|
|
2655
|
+
declare function runProbes(probes: readonly ReadinessProbe[]): Promise<ReadinessReport[]>;
|
|
2656
|
+
/** Probe that passes iff process.env[name] is non-empty after trimming. */
|
|
2657
|
+
declare function envProbe(name: string): ReadinessProbe;
|
|
2658
|
+
/**
|
|
2659
|
+
* Probe wrapping an arbitrary async function. Returning a value (or void)
|
|
2660
|
+
* means ok; throwing means not-ok. Compact escape hatch — promote to a real
|
|
2661
|
+
* probe class when reuse appears.
|
|
2662
|
+
*/
|
|
2663
|
+
declare function asyncProbe(name: string, fn: () => Promise<unknown>): ReadinessProbe;
|
|
2664
|
+
/**
|
|
2665
|
+
* Probe that fetches a URL and considers any 2xx/3xx response ok. Useful for
|
|
2666
|
+
* upstream health-checks (e.g. an LLM gateway's /healthz). Default 3s timeout.
|
|
2667
|
+
*/
|
|
2668
|
+
declare function urlProbe(name: string, url: string, opts?: {
|
|
2669
|
+
timeoutMs?: number;
|
|
2670
|
+
method?: 'GET' | 'HEAD';
|
|
2671
|
+
}): ReadinessProbe;
|
|
2672
|
+
|
|
2673
|
+
declare class VoiceLayerError extends Error {
|
|
2674
|
+
readonly name: string;
|
|
2675
|
+
}
|
|
2676
|
+
declare class VoiceLayerAuthError extends VoiceLayerError {
|
|
2677
|
+
readonly status: number;
|
|
2678
|
+
readonly name: string;
|
|
2679
|
+
constructor(message: string, status: number);
|
|
2680
|
+
}
|
|
2681
|
+
declare class VoiceLayerNetworkError extends VoiceLayerError {
|
|
2682
|
+
readonly name: string;
|
|
2683
|
+
readonly cause?: unknown;
|
|
2684
|
+
constructor(message: string, cause?: unknown);
|
|
2685
|
+
}
|
|
2686
|
+
declare class VoiceLayerValidationError extends VoiceLayerError {
|
|
2687
|
+
readonly issues: unknown;
|
|
2688
|
+
readonly name: string;
|
|
2689
|
+
constructor(message: string, issues: unknown);
|
|
2690
|
+
}
|
|
2691
|
+
declare class VoiceLayerHttpError extends VoiceLayerError {
|
|
2692
|
+
readonly status: number;
|
|
2693
|
+
readonly body: unknown;
|
|
2694
|
+
readonly name: string;
|
|
2695
|
+
constructor(message: string, status: number, body: unknown);
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
type AgentLifecycleEvent = {
|
|
2699
|
+
type: 'registered';
|
|
2700
|
+
agent: AgentDTO;
|
|
2701
|
+
} | {
|
|
2702
|
+
type: 'readiness';
|
|
2703
|
+
report: readonly ReadinessReport[];
|
|
2704
|
+
allOk: boolean;
|
|
2705
|
+
} | {
|
|
2706
|
+
type: 'heartbeat';
|
|
2707
|
+
agent: AgentDTO;
|
|
2708
|
+
} | {
|
|
2709
|
+
type: 'heartbeat_error';
|
|
2710
|
+
error: VoiceLayerError | Error;
|
|
2711
|
+
consecutiveFailures: number;
|
|
2712
|
+
willRetry: boolean;
|
|
2713
|
+
} | {
|
|
2714
|
+
type: 'heartbeat_recovered';
|
|
2715
|
+
afterFailures: number;
|
|
2716
|
+
} | {
|
|
2717
|
+
type: 're_registered';
|
|
2718
|
+
agent: AgentDTO;
|
|
2719
|
+
reason: 'agent_not_found';
|
|
2720
|
+
} | {
|
|
2721
|
+
type: 'status_changed';
|
|
2722
|
+
status: AgentStatus;
|
|
2723
|
+
detail?: string;
|
|
2724
|
+
} | {
|
|
2725
|
+
type: 'metadata_updated';
|
|
2726
|
+
} | {
|
|
2727
|
+
type: 'deregistered';
|
|
2728
|
+
reason: 'manual' | 'signal';
|
|
2729
|
+
};
|
|
2730
|
+
type AgentEventListener = (event: AgentLifecycleEvent) => void;
|
|
2731
|
+
interface AgentEventEmitter {
|
|
2732
|
+
on(listener: AgentEventListener): () => void;
|
|
2733
|
+
/** @internal — used by the lifecycle to publish events. */
|
|
2734
|
+
emit(event: AgentLifecycleEvent): void;
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
interface RegisterInput {
|
|
2738
|
+
readonly name: string;
|
|
2739
|
+
readonly version: string;
|
|
2740
|
+
readonly environment: AgentEnvironment;
|
|
2741
|
+
/** Capability tags (e.g. ['fnol', 'es-MX']). Surfaced in the dashboard. */
|
|
2742
|
+
readonly capabilities?: readonly string[];
|
|
2743
|
+
/**
|
|
2744
|
+
* JSON-serializable process schema for the dashboard "what this agent does"
|
|
2745
|
+
* view. Built by `buildProcessSchemaDTO` from the agent's ProcessDefinition.
|
|
2746
|
+
*/
|
|
2747
|
+
readonly processSchema?: ProcessSchemaDTO | null;
|
|
2748
|
+
/**
|
|
2749
|
+
* Opt this agent into MCP exposure. When true, the API upserts a matching
|
|
2750
|
+
* agent_config row keyed by (project_id, name, environment) so MCP /
|
|
2751
|
+
* dashboard / REST can list and inspect this agent. Default false — pure
|
|
2752
|
+
* SDK agents that don't need MCP visibility stay invisible to it. See
|
|
2753
|
+
* docs/architecture/contracts-design.md §2b.
|
|
2754
|
+
*/
|
|
2755
|
+
readonly mcpExposed?: boolean;
|
|
2756
|
+
/**
|
|
2757
|
+
* Self-checks run before sending the register request. Each result is
|
|
2758
|
+
* recorded on the agent. See RegisterOptions.requireReady for failure
|
|
2759
|
+
* policy.
|
|
2760
|
+
*/
|
|
2761
|
+
readonly readiness?: readonly ReadinessProbe[];
|
|
2762
|
+
/** User metadata. Merged on top of default metadata (user wins on conflict). */
|
|
2763
|
+
readonly metadata?: Record<string, unknown>;
|
|
2764
|
+
/**
|
|
2765
|
+
* Whether to auto-collect host/runtime/build metadata. Default true. Set
|
|
2766
|
+
* false to send exactly what you pass in `metadata`.
|
|
2767
|
+
*/
|
|
2768
|
+
readonly collectDefaults?: boolean;
|
|
2769
|
+
}
|
|
2770
|
+
interface RegisterOptions {
|
|
2771
|
+
/**
|
|
2772
|
+
* Override server-suggested heartbeat cadence (ms). When omitted, the SDK
|
|
2773
|
+
* uses the value returned by /v1/agents/register, falling back to
|
|
2774
|
+
* AGENT_HEARTBEAT_INTERVAL_MS.
|
|
2775
|
+
*/
|
|
2776
|
+
readonly heartbeatIntervalMs?: number;
|
|
2777
|
+
/**
|
|
2778
|
+
* Disable signal handlers (SIGTERM/SIGINT). Useful in tests and in hosts
|
|
2779
|
+
* that own their own shutdown lifecycle.
|
|
2780
|
+
*/
|
|
2781
|
+
readonly attachSignalHandlers?: boolean;
|
|
2782
|
+
/**
|
|
2783
|
+
* On SIGTERM/SIGINT, call DELETE /v1/agents/:id before exiting so the
|
|
2784
|
+
* dashboard reflects "gone" immediately instead of waiting for offline
|
|
2785
|
+
* timeout. Default true. Best-effort: errors are swallowed.
|
|
2786
|
+
*/
|
|
2787
|
+
readonly deregisterOnSignal?: boolean;
|
|
2788
|
+
/**
|
|
2789
|
+
* If any readiness probe reports !ok, throw before calling register.
|
|
2790
|
+
* Default false: probes that fail mark the agent as `degraded` instead.
|
|
2791
|
+
*/
|
|
2792
|
+
readonly requireReady?: boolean;
|
|
2793
|
+
/**
|
|
2794
|
+
* Listener for lifecycle events. Equivalent to `agent.events.on(fn)` after
|
|
2795
|
+
* register; register-time events (readiness, registered) are also delivered.
|
|
2796
|
+
*/
|
|
2797
|
+
readonly onEvent?: (event: AgentLifecycleEvent) => void;
|
|
2798
|
+
}
|
|
2799
|
+
interface RegisteredAgent {
|
|
2800
|
+
readonly agent: AgentDTO;
|
|
2801
|
+
readonly events: AgentEventEmitter;
|
|
2802
|
+
/** Push a status change immediately (next heartbeat carries it too). */
|
|
2803
|
+
setStatus(status: 'online' | 'degraded', detail?: string): Promise<void>;
|
|
2804
|
+
/** Replace metadata on the next heartbeat. Pass {} to clear. */
|
|
2805
|
+
updateMetadata(metadata: Record<string, unknown>): Promise<void>;
|
|
2806
|
+
/** Best-effort DELETE; safe to call multiple times. */
|
|
2807
|
+
deregister(): Promise<void>;
|
|
2808
|
+
/** Stop the heartbeat ticker without deleting the row. Idempotent. */
|
|
2809
|
+
stop(): Promise<void>;
|
|
2810
|
+
}
|
|
2811
|
+
interface SchedulerLike {
|
|
2812
|
+
setTimeout(cb: () => void, ms: number): NodeJS.Timeout | number;
|
|
2813
|
+
clearTimeout(handle: NodeJS.Timeout | number | undefined): void;
|
|
2814
|
+
}
|
|
2815
|
+
interface AgentsClientOptions {
|
|
2816
|
+
readonly scheduler?: SchedulerLike;
|
|
2817
|
+
readonly attachSignalHandlers?: boolean;
|
|
2818
|
+
}
|
|
2819
|
+
declare class AgentsClient {
|
|
2820
|
+
private readonly transport;
|
|
2821
|
+
private readonly options;
|
|
2822
|
+
constructor(transport: Transport, options?: AgentsClientOptions);
|
|
2823
|
+
/**
|
|
2824
|
+
* Fetch a deployed agent's compiled process_schema. A flow-runtime worker
|
|
2825
|
+
* calls this per dispatched call to boot a visually-built flow. Returns
|
|
2826
|
+
* null on 404 or when the agent has no schema.
|
|
2827
|
+
*/
|
|
2828
|
+
getProcessSchema(agentId: string): Promise<ProcessSchemaDTO | null>;
|
|
2829
|
+
/**
|
|
2830
|
+
* Fetch a deployed agent's stored AgentConfig — the pipeline the dashboard
|
|
2831
|
+
* set (model / voice / stt / mode / realtime). A flow-runtime worker reads
|
|
2832
|
+
* this per call so the no-code agent's runtime matches the builder. Returns
|
|
2833
|
+
* null on 404 (agent not MCP-exposed or absent).
|
|
2834
|
+
*/
|
|
2835
|
+
getConfig(agentId: string): Promise<AgentConfig$1 | null>;
|
|
2836
|
+
register(input: RegisterInput, opts?: RegisterOptions): Promise<RegisteredAgent>;
|
|
2837
|
+
list(query?: {
|
|
2838
|
+
environment?: AgentEnvironment;
|
|
2839
|
+
}): Promise<{
|
|
2840
|
+
agents: {
|
|
2841
|
+
status: "online" | "offline" | "degraded";
|
|
2842
|
+
id: string;
|
|
2843
|
+
projectId: string;
|
|
2844
|
+
name: string;
|
|
2845
|
+
createdAt: string;
|
|
2846
|
+
updatedAt: string;
|
|
2847
|
+
version: string;
|
|
2848
|
+
environment: "dev" | "stg" | "prd";
|
|
2849
|
+
statusDetail: string | null;
|
|
2850
|
+
capabilities: string[];
|
|
2851
|
+
readiness: {
|
|
2852
|
+
probe: string;
|
|
2853
|
+
ok: boolean;
|
|
2854
|
+
detail?: string | undefined;
|
|
2855
|
+
}[];
|
|
2856
|
+
metadata: Record<string, unknown>;
|
|
2857
|
+
lastSeenAt: string | null;
|
|
2858
|
+
processSchema?: {
|
|
2859
|
+
id: string;
|
|
2860
|
+
completionGate: {
|
|
2861
|
+
requiredFields: string[];
|
|
2862
|
+
backendAck?: {
|
|
2863
|
+
url: string;
|
|
2864
|
+
timeoutMs: number;
|
|
2865
|
+
} | undefined;
|
|
2866
|
+
};
|
|
2867
|
+
fields: {
|
|
2868
|
+
type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
|
|
2869
|
+
name: string;
|
|
2870
|
+
required: boolean;
|
|
2871
|
+
ask?: string | undefined;
|
|
2872
|
+
pattern?: string | undefined;
|
|
2873
|
+
min?: number | undefined;
|
|
2874
|
+
max?: number | undefined;
|
|
2875
|
+
enum?: string[] | undefined;
|
|
2876
|
+
}[];
|
|
2877
|
+
handoff?: {
|
|
2878
|
+
fallback?: string | undefined;
|
|
2879
|
+
routes?: Record<string, string> | undefined;
|
|
2880
|
+
} | undefined;
|
|
2881
|
+
memory?: {
|
|
2882
|
+
scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
|
|
2883
|
+
retentionDays?: number | undefined;
|
|
2884
|
+
piiFields?: string[] | undefined;
|
|
2885
|
+
} | undefined;
|
|
2886
|
+
prompts?: {
|
|
2887
|
+
id: string;
|
|
2888
|
+
text: string;
|
|
2889
|
+
}[] | undefined;
|
|
2890
|
+
triggers?: {
|
|
2891
|
+
then: string;
|
|
2892
|
+
name: string;
|
|
2893
|
+
on: string;
|
|
2894
|
+
onlyWhile?: string | undefined;
|
|
2895
|
+
}[] | undefined;
|
|
2896
|
+
tools?: {
|
|
2897
|
+
name: string;
|
|
2898
|
+
description: string;
|
|
2899
|
+
input: Record<string, "string" | "number" | "boolean">;
|
|
2900
|
+
url: string;
|
|
2901
|
+
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
2902
|
+
auth: "none" | "connection";
|
|
2903
|
+
headers?: Record<string, string> | undefined;
|
|
2904
|
+
connectionRef?: string | undefined;
|
|
2905
|
+
}[] | undefined;
|
|
2906
|
+
program?: {
|
|
2907
|
+
v: 1;
|
|
2908
|
+
id: string;
|
|
2909
|
+
nodes: Record<string, {
|
|
2910
|
+
type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
|
|
2911
|
+
id: string;
|
|
2912
|
+
config: Record<string, unknown>;
|
|
2913
|
+
out: {
|
|
2914
|
+
to: string;
|
|
2915
|
+
sourceHandle?: string | undefined;
|
|
2916
|
+
label?: string | undefined;
|
|
2917
|
+
condition?: string | undefined;
|
|
2918
|
+
}[];
|
|
2919
|
+
}>;
|
|
2920
|
+
entry: string[];
|
|
2921
|
+
completionGate: {
|
|
2922
|
+
requiredFields: string[];
|
|
2923
|
+
};
|
|
2924
|
+
diagnostics?: {
|
|
2925
|
+
acyclic: boolean;
|
|
2926
|
+
droppedEdges: string[];
|
|
2927
|
+
unsupportedNodes: string[];
|
|
2928
|
+
} | undefined;
|
|
2929
|
+
} | undefined;
|
|
2930
|
+
} | null | undefined;
|
|
2931
|
+
}[];
|
|
2932
|
+
}>;
|
|
2933
|
+
delete(agentId: string): Promise<{
|
|
2934
|
+
ok: true;
|
|
2935
|
+
}>;
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
interface ContextInput {
|
|
2939
|
+
readonly callerId: string;
|
|
2940
|
+
readonly scopes?: readonly MemoryScope$1[];
|
|
2941
|
+
}
|
|
2942
|
+
interface WriteInput {
|
|
2943
|
+
readonly scope: MemoryScope$1;
|
|
2944
|
+
readonly callerId: string;
|
|
2945
|
+
readonly delta: Record<string, unknown>;
|
|
2946
|
+
readonly callId?: string;
|
|
2947
|
+
}
|
|
2948
|
+
interface SnapshotInput {
|
|
2949
|
+
readonly callId: string;
|
|
2950
|
+
readonly stage: string;
|
|
2951
|
+
readonly snapshot: Record<string, unknown>;
|
|
2952
|
+
}
|
|
2953
|
+
interface ResolveInput {
|
|
2954
|
+
readonly externalKey: string;
|
|
2955
|
+
readonly displayName?: string;
|
|
2956
|
+
readonly identifiers?: ReadonlyArray<{
|
|
2957
|
+
type: string;
|
|
2958
|
+
value: string;
|
|
2959
|
+
}>;
|
|
2960
|
+
}
|
|
2961
|
+
declare class MemoryClient {
|
|
2962
|
+
private readonly transport;
|
|
2963
|
+
constructor(transport: Transport);
|
|
2964
|
+
context(input: ContextInput): Promise<RelevantContext>;
|
|
2965
|
+
write(input: WriteInput): Promise<void>;
|
|
2966
|
+
snapshot(input: SnapshotInput): Promise<{
|
|
2967
|
+
id: string;
|
|
2968
|
+
}>;
|
|
2969
|
+
resolveCaller(input: ResolveInput): Promise<ResolveCallerResponse['caller']>;
|
|
2970
|
+
deleteCaller(callerId: string): Promise<DeleteCallerResponse>;
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
type CallStatus = 'in_progress' | 'completed' | 'failed';
|
|
2974
|
+
type CallAttributeValue = string | number | boolean;
|
|
2975
|
+
type CallParticipantRole = 'caller' | 'agent' | 'callee' | 'supervisor' | 'observer' | 'unknown';
|
|
2976
|
+
type CallParticipantKind = 'human' | 'agent' | 'phone' | 'sip' | 'system';
|
|
2977
|
+
type CallLegKind = 'sip-inbound' | 'sip-outbound' | 'agent-session' | 'conference' | 'transfer' | 'unknown';
|
|
2978
|
+
type CallLegStatus = 'starting' | 'active' | 'ended';
|
|
2979
|
+
interface CallSummary {
|
|
2980
|
+
readonly id: string;
|
|
2981
|
+
readonly projectId: string;
|
|
2982
|
+
readonly livekitRoom: string;
|
|
2983
|
+
readonly phoneNumberId: string | null;
|
|
2984
|
+
readonly agentId: string | null;
|
|
2985
|
+
readonly bindingId: string | null;
|
|
2986
|
+
readonly callerE164: string | null;
|
|
2987
|
+
readonly toE164: string | null;
|
|
2988
|
+
readonly status: CallStatus;
|
|
2989
|
+
readonly startedAt: string;
|
|
2990
|
+
}
|
|
2991
|
+
interface AppendTranscriptInput {
|
|
2992
|
+
readonly speaker: 'caller' | 'agent';
|
|
2993
|
+
readonly text: string;
|
|
2994
|
+
readonly startMs: number;
|
|
2995
|
+
readonly endMs: number;
|
|
2996
|
+
readonly final?: boolean;
|
|
2997
|
+
}
|
|
2998
|
+
interface EnsureCallByRoomInput {
|
|
2999
|
+
readonly roomName: string;
|
|
3000
|
+
readonly phoneNumberId?: string;
|
|
3001
|
+
readonly agentId?: string;
|
|
3002
|
+
readonly bindingId?: string;
|
|
3003
|
+
readonly callerE164?: string;
|
|
3004
|
+
readonly toE164?: string;
|
|
3005
|
+
readonly attributes?: Record<string, CallAttributeValue>;
|
|
3006
|
+
readonly participants?: CallParticipantInput[];
|
|
3007
|
+
readonly legs?: CallLegInput[];
|
|
3008
|
+
readonly startedAt?: string;
|
|
3009
|
+
}
|
|
3010
|
+
interface CallParticipantInput {
|
|
3011
|
+
readonly participantKey: string;
|
|
3012
|
+
readonly role: CallParticipantRole;
|
|
3013
|
+
readonly kind: CallParticipantKind;
|
|
3014
|
+
readonly identity?: string | null;
|
|
3015
|
+
readonly address?: string | null;
|
|
3016
|
+
readonly displayName?: string | null;
|
|
3017
|
+
readonly joinedAt?: string;
|
|
3018
|
+
readonly leftAt?: string | null;
|
|
3019
|
+
readonly metadata?: Record<string, unknown>;
|
|
3020
|
+
}
|
|
3021
|
+
interface CallLegInput {
|
|
3022
|
+
readonly legKey: string;
|
|
3023
|
+
readonly kind: CallLegKind;
|
|
3024
|
+
readonly status: CallLegStatus;
|
|
3025
|
+
readonly fromParticipantKey?: string | null;
|
|
3026
|
+
readonly toParticipantKey?: string | null;
|
|
3027
|
+
readonly fromAddress?: string | null;
|
|
3028
|
+
readonly toAddress?: string | null;
|
|
3029
|
+
readonly startedAt?: string;
|
|
3030
|
+
readonly endedAt?: string | null;
|
|
3031
|
+
readonly metadata?: Record<string, unknown>;
|
|
3032
|
+
}
|
|
3033
|
+
interface SyncCallStateInput {
|
|
3034
|
+
readonly attributes?: Record<string, CallAttributeValue>;
|
|
3035
|
+
readonly participants?: CallParticipantInput[];
|
|
3036
|
+
readonly legs?: CallLegInput[];
|
|
3037
|
+
}
|
|
3038
|
+
declare class CallsClient {
|
|
3039
|
+
private readonly transport;
|
|
3040
|
+
constructor(transport: Transport);
|
|
3041
|
+
getByRoom(roomName: string): Promise<CallSummary>;
|
|
3042
|
+
ensureByRoom(input: EnsureCallByRoomInput): Promise<CallSummary>;
|
|
3043
|
+
syncState(callId: string, input: SyncCallStateInput): Promise<void>;
|
|
3044
|
+
appendTranscriptSegment(callId: string, input: AppendTranscriptInput): Promise<void>;
|
|
3045
|
+
/**
|
|
3046
|
+
* Append a structured call event. Today the API accepts consultation
|
|
3047
|
+
* lifecycle kinds only — see apps/api/src/routes/calls.ts AppendEventBody.
|
|
3048
|
+
*
|
|
3049
|
+
* The agent SDK's built-in `ask_host` tool calls this on consultation start
|
|
3050
|
+
* / end so the MCP host (via SSE) and dashboard see the "let me check" UX
|
|
3051
|
+
* in real time.
|
|
3052
|
+
*/
|
|
3053
|
+
appendEvent(callId: string, input: {
|
|
3054
|
+
readonly kind: 'consultation.requested' | 'consultation.resolved';
|
|
3055
|
+
readonly payload: Record<string, unknown>;
|
|
3056
|
+
}): Promise<void>;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
interface CreateFormSessionInput {
|
|
3060
|
+
readonly formId: string;
|
|
3061
|
+
readonly recipientPhone: string;
|
|
3062
|
+
readonly recipientName?: string;
|
|
3063
|
+
readonly prefill?: Record<string, unknown>;
|
|
3064
|
+
readonly webhookUrl?: string;
|
|
3065
|
+
readonly callbackFromNumber?: string;
|
|
3066
|
+
readonly ttlSeconds?: number;
|
|
3067
|
+
/**
|
|
3068
|
+
* When set, the API will SMS the link from this phone number immediately
|
|
3069
|
+
* after creating the session. This is the common case for agent-led use:
|
|
3070
|
+
* the agent calls sendFormLink during a conversation and the recipient
|
|
3071
|
+
* gets a text right away.
|
|
3072
|
+
*/
|
|
3073
|
+
readonly sendSms?: {
|
|
3074
|
+
readonly phoneNumberId: string;
|
|
3075
|
+
readonly bodyPrefix?: string;
|
|
3076
|
+
};
|
|
3077
|
+
/**
|
|
3078
|
+
* When set, the API will email the link to `to` immediately after creating
|
|
3079
|
+
* the session. Independent from sendSms — set both for belt-and-braces
|
|
3080
|
+
* delivery, set neither to just receive the URL back. Use this when SMS is
|
|
3081
|
+
* blocked by toll-fraud / 10DLC registration.
|
|
3082
|
+
*/
|
|
3083
|
+
readonly sendEmail?: {
|
|
3084
|
+
readonly to: string;
|
|
3085
|
+
readonly subject?: string;
|
|
3086
|
+
readonly bodyPrefix?: string;
|
|
3087
|
+
};
|
|
3088
|
+
}
|
|
3089
|
+
interface CreatedFormSession {
|
|
3090
|
+
readonly sessionId: string;
|
|
3091
|
+
readonly token: string;
|
|
3092
|
+
readonly url: string;
|
|
3093
|
+
readonly smsId: string | null;
|
|
3094
|
+
readonly emailId: string | null;
|
|
3095
|
+
readonly expiresAt: string;
|
|
3096
|
+
}
|
|
3097
|
+
interface PublicFormSessionView {
|
|
3098
|
+
readonly schema: {
|
|
3099
|
+
readonly id: string;
|
|
3100
|
+
readonly version: number;
|
|
3101
|
+
readonly title: string;
|
|
3102
|
+
readonly description?: string | undefined;
|
|
3103
|
+
readonly survey: Record<string, unknown>;
|
|
3104
|
+
};
|
|
3105
|
+
readonly values: Record<string, unknown>;
|
|
3106
|
+
readonly status: 'pending' | 'active' | 'live' | 'submitted' | 'expired';
|
|
3107
|
+
readonly recipientPhoneMasked: string;
|
|
3108
|
+
readonly hasActiveCall: boolean;
|
|
3109
|
+
readonly submittedAt: string | null;
|
|
3110
|
+
readonly expiresAt: string;
|
|
3111
|
+
}
|
|
3112
|
+
declare class FormsClient {
|
|
3113
|
+
private readonly transport;
|
|
3114
|
+
constructor(transport: Transport);
|
|
3115
|
+
createSession(input: CreateFormSessionInput): Promise<CreatedFormSession>;
|
|
3116
|
+
getByToken(token: string): Promise<PublicFormSessionView>;
|
|
3117
|
+
patchValues(token: string, values: Record<string, unknown>): Promise<{
|
|
3118
|
+
values: Record<string, unknown>;
|
|
3119
|
+
updatedAt: string;
|
|
3120
|
+
}>;
|
|
3121
|
+
submit(token: string, values: Record<string, unknown>): Promise<{
|
|
3122
|
+
responseId: string;
|
|
3123
|
+
submittedAt: string;
|
|
3124
|
+
}>;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
interface SendEmailInput {
|
|
3128
|
+
readonly to: string;
|
|
3129
|
+
readonly subject: string;
|
|
3130
|
+
readonly text: string;
|
|
3131
|
+
readonly html?: string;
|
|
3132
|
+
}
|
|
3133
|
+
interface SentEmail {
|
|
3134
|
+
readonly emailId: string;
|
|
3135
|
+
}
|
|
3136
|
+
declare class EmailClient {
|
|
3137
|
+
private readonly transport;
|
|
3138
|
+
constructor(transport: Transport);
|
|
3139
|
+
send(input: SendEmailInput): Promise<SentEmail>;
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
declare class PlansClient {
|
|
3143
|
+
private readonly transport;
|
|
3144
|
+
constructor(transport: Transport);
|
|
3145
|
+
/**
|
|
3146
|
+
* Fetch a plan by id. Project scoping is enforced by the API via the
|
|
3147
|
+
* caller's VOICELAYER_API_KEY — a cross-project planId surfaces as 404.
|
|
3148
|
+
* Returns `null` on 404 so the caller can fall back to legacy boot.
|
|
3149
|
+
*/
|
|
3150
|
+
getById(planId: string): Promise<CallPlan | null>;
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
declare const ProviderCredential: z.ZodObject<{
|
|
3154
|
+
apiKey: z.ZodString;
|
|
3155
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
3156
|
+
}, "strip", z.ZodTypeAny, {
|
|
3157
|
+
apiKey: string;
|
|
3158
|
+
baseUrl?: string | undefined;
|
|
3159
|
+
}, {
|
|
3160
|
+
apiKey: string;
|
|
3161
|
+
baseUrl?: string | undefined;
|
|
3162
|
+
}>;
|
|
3163
|
+
type ProviderCredential = z.infer<typeof ProviderCredential>;
|
|
3164
|
+
declare class ConnectionsClient {
|
|
3165
|
+
private readonly transport;
|
|
3166
|
+
constructor(transport: Transport);
|
|
3167
|
+
resolveProviderCredential(provider: string): Promise<ProviderCredential | null>;
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
interface DefaultMetadata {
|
|
3171
|
+
readonly hostname: string;
|
|
3172
|
+
readonly platform: NodeJS.Platform;
|
|
3173
|
+
readonly arch: string;
|
|
3174
|
+
readonly nodeVersion: string;
|
|
3175
|
+
readonly pid: number;
|
|
3176
|
+
/** From BUILD_SHA / GIT_COMMIT / VERCEL_GIT_COMMIT_SHA, or null. */
|
|
3177
|
+
readonly buildSha: string | null;
|
|
3178
|
+
readonly startedAt: string;
|
|
3179
|
+
}
|
|
3180
|
+
declare function collectDefaultMetadata(): DefaultMetadata;
|
|
3181
|
+
/**
|
|
3182
|
+
* Merge default metadata with user-supplied metadata. User values win on
|
|
3183
|
+
* conflict; defaults fill in the rest. Returns a plain object suitable for
|
|
3184
|
+
* the registry's metadata field.
|
|
3185
|
+
*/
|
|
3186
|
+
declare function mergeMetadata(user: Record<string, unknown> | undefined, defaults: DefaultMetadata): Record<string, unknown>;
|
|
3187
|
+
|
|
3188
|
+
interface TtsVoiceConfig {
|
|
3189
|
+
readonly provider: 'deepgram' | 'openai' | 'elevenlabs' | 'cartesia';
|
|
3190
|
+
readonly model: string;
|
|
3191
|
+
readonly voice?: string;
|
|
3192
|
+
readonly instructions?: string;
|
|
3193
|
+
}
|
|
3194
|
+
interface AudioProfile {
|
|
3195
|
+
readonly holdMusicUrl: string;
|
|
3196
|
+
readonly duckingDb: number;
|
|
3197
|
+
readonly dtmfFallbackThreshold: number;
|
|
3198
|
+
readonly languageHint: string;
|
|
3199
|
+
readonly tts: TtsVoiceConfig;
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
type RoutingRule = {
|
|
3203
|
+
readonly kind: 'passthrough';
|
|
3204
|
+
} | {
|
|
3205
|
+
readonly kind: 'mute';
|
|
3206
|
+
} | {
|
|
3207
|
+
readonly kind: 'duck';
|
|
3208
|
+
readonly db: number;
|
|
3209
|
+
} | {
|
|
3210
|
+
readonly kind: 'transform';
|
|
3211
|
+
readonly id: string;
|
|
3212
|
+
};
|
|
3213
|
+
declare const passthrough: () => RoutingRule;
|
|
3214
|
+
declare const mute: () => RoutingRule;
|
|
3215
|
+
declare const duck: (db: number) => RoutingRule;
|
|
3216
|
+
declare const transform: (id: string) => RoutingRule;
|
|
3217
|
+
interface RouteEntry {
|
|
3218
|
+
readonly source: ParticipantId;
|
|
3219
|
+
readonly destination: ParticipantId;
|
|
3220
|
+
readonly rule: RoutingRule;
|
|
3221
|
+
}
|
|
3222
|
+
interface FloorControlConfig {
|
|
3223
|
+
/**
|
|
3224
|
+
* Minimum quiet window (ms) after the last human utterance before the
|
|
3225
|
+
* agent is allowed to speak. Prevents the agent from talking over a
|
|
3226
|
+
* human who hasn't yielded the floor. Default 400ms.
|
|
3227
|
+
*/
|
|
3228
|
+
readonly humanQuietWindowMs: number;
|
|
3229
|
+
/**
|
|
3230
|
+
* If true, the agent may speak immediately at call start before any
|
|
3231
|
+
* human has spoken (the greeting). Default true.
|
|
3232
|
+
*/
|
|
3233
|
+
readonly allowAgentGreeting: boolean;
|
|
3234
|
+
}
|
|
3235
|
+
interface RoutingSnapshot {
|
|
3236
|
+
readonly entries: readonly RouteEntry[];
|
|
3237
|
+
readonly lastSpokeAt: ReadonlyMap<ParticipantId, number>;
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
interface CallInfo {
|
|
3241
|
+
/** Stable id for the call; comes from dispatch metadata or room name. */
|
|
3242
|
+
readonly callId: string;
|
|
3243
|
+
/** Caller phone number (E.164) when available, else participant identity. */
|
|
3244
|
+
readonly callerId: string;
|
|
3245
|
+
/** Phone number that was called (E.164) when available. */
|
|
3246
|
+
readonly to: string | null;
|
|
3247
|
+
/** Wall-clock when the agent joined. */
|
|
3248
|
+
readonly startedAt: Date;
|
|
3249
|
+
/** Free-form metadata from the dispatch rule (e.g. projectId, agentId). */
|
|
3250
|
+
readonly metadata: Record<string, unknown>;
|
|
3251
|
+
}
|
|
3252
|
+
interface MemoryHandle {
|
|
3253
|
+
get(key: string): Promise<unknown>;
|
|
3254
|
+
set(key: string, value: unknown): Promise<void>;
|
|
3255
|
+
}
|
|
3256
|
+
interface ProcessSnapshot {
|
|
3257
|
+
/** Captured field values. */
|
|
3258
|
+
readonly data: Record<string, unknown>;
|
|
3259
|
+
/** True once the process completion gate has fired. */
|
|
3260
|
+
readonly complete: boolean;
|
|
3261
|
+
}
|
|
3262
|
+
/**
|
|
3263
|
+
* Input to ctx.recordEvent — id and timestamp are stamped by the runtime so
|
|
3264
|
+
* callers only supply the semantic fields. `source` defaults to 'agent' for
|
|
3265
|
+
* tool-call events; pass 'form'/'platform'/'caller' when emitting from a
|
|
3266
|
+
* different surface (form-page bridge, webhook handler).
|
|
3267
|
+
*/
|
|
3268
|
+
interface RecordEventInput {
|
|
3269
|
+
readonly kind: string;
|
|
3270
|
+
readonly source?: 'agent' | 'caller' | 'form' | 'platform';
|
|
3271
|
+
readonly data?: Record<string, unknown>;
|
|
3272
|
+
}
|
|
3273
|
+
/**
|
|
3274
|
+
* Targets for participant-scoped speech operations. Either a raw
|
|
3275
|
+
* `ParticipantId`, a `Participant` snapshot, or an array of either.
|
|
3276
|
+
* `'broadcast'` is the explicit form of the default — everyone in the room.
|
|
3277
|
+
*/
|
|
3278
|
+
type SpeechTarget = ParticipantId | Participant | readonly (ParticipantId | Participant)[] | 'broadcast';
|
|
3279
|
+
/**
|
|
3280
|
+
* Audio surface — per-participant profiles, routing matrix, and floor
|
|
3281
|
+
* control. Exposed on `ctx.audio` so user hooks (e.g. translation in
|
|
3282
|
+
* onUtterance) can drive the underlying primitives without importing
|
|
3283
|
+
* them directly.
|
|
3284
|
+
*
|
|
3285
|
+
* In PR#4 these are wired to live LK participant events but the audio
|
|
3286
|
+
* fanout itself (per-participant STT, per-listener TTS) is still single-
|
|
3287
|
+
* pipeline; users that need actual per-listener delivery should go
|
|
3288
|
+
* through `ctx.livekit` for now.
|
|
3289
|
+
*/
|
|
3290
|
+
interface AudioSurface {
|
|
3291
|
+
/** Profile (voice/lang/DTMF) for one participant. */
|
|
3292
|
+
profileFor(participantId: ParticipantId): AudioProfile;
|
|
3293
|
+
/** Update one participant's language hint (also swaps TTS voice). */
|
|
3294
|
+
setLanguage(participantId: ParticipantId, languageHint: string): AudioProfile;
|
|
3295
|
+
/** Current routing matrix snapshot. */
|
|
3296
|
+
routes(): RoutingSnapshot;
|
|
3297
|
+
/** Override a single (source, destination) edge in the routing matrix. */
|
|
3298
|
+
setRoute(source: ParticipantId, destination: ParticipantId, rule: RoutingRule): void;
|
|
3299
|
+
/** Floor-control: true iff no human has spoken inside the quiet window. */
|
|
3300
|
+
canAgentSpeak(): boolean;
|
|
3301
|
+
}
|
|
3302
|
+
interface SayOptions {
|
|
3303
|
+
/** Restrict the spoken track to one or more participants. Default: broadcast. */
|
|
3304
|
+
readonly to?: SpeechTarget;
|
|
3305
|
+
}
|
|
3306
|
+
/**
|
|
3307
|
+
* A DTMF keypress received from a participant. `code` is the RFC 4733 event
|
|
3308
|
+
* code (0–15: digits 0–9, *=10, #=11, A–D=12–15); `digit` is the canonical
|
|
3309
|
+
* single-character representation. `participantId` identifies the sender in
|
|
3310
|
+
* the synthesized room (matches Room.participants).
|
|
3311
|
+
*/
|
|
3312
|
+
interface DtmfEvent {
|
|
3313
|
+
readonly participantId: ParticipantId;
|
|
3314
|
+
readonly code: number;
|
|
3315
|
+
readonly digit: string;
|
|
3316
|
+
readonly at: Date;
|
|
3317
|
+
}
|
|
3318
|
+
/** Handler signature for ctx.onDtmf. Returning false unsubscribes. */
|
|
3319
|
+
type DtmfHandler = (event: DtmfEvent) => void | Promise<void>;
|
|
3320
|
+
interface SendDtmfOptions {
|
|
3321
|
+
/** Milliseconds between consecutive digits. Default 100. */
|
|
3322
|
+
readonly delayMs?: number;
|
|
3323
|
+
}
|
|
3324
|
+
interface RespondOptions {
|
|
3325
|
+
readonly instructions?: string;
|
|
3326
|
+
readonly to?: SpeechTarget;
|
|
3327
|
+
}
|
|
3328
|
+
interface AgentContext {
|
|
3329
|
+
readonly call: CallInfo;
|
|
3330
|
+
readonly memory: MemoryHandle;
|
|
3331
|
+
/** Typed connector APIs. Empty record when no connectors are configured. */
|
|
3332
|
+
readonly connectors: Readonly<Record<string, unknown>>;
|
|
3333
|
+
/** Read-only view of process state. Undefined when no process is configured. */
|
|
3334
|
+
readonly process: ProcessSnapshot | undefined;
|
|
3335
|
+
/**
|
|
3336
|
+
* Record a side-channel lifecycle event into the process actor. Visible
|
|
3337
|
+
* to the dashboard React Flow board in real time alongside field
|
|
3338
|
+
* captures. Use for "this happened on the call" facts — tool calls,
|
|
3339
|
+
* form-page activity, webhook dispatches — that aren't field captures.
|
|
3340
|
+
* No-op when the agent has no process configured.
|
|
3341
|
+
*/
|
|
3342
|
+
recordEvent(event: RecordEventInput): void;
|
|
3343
|
+
/**
|
|
3344
|
+
* Subscribe the agent to a form-page session's WS stream so values typed
|
|
3345
|
+
* on the form-page mirror into the process actor (channel-agnostic field
|
|
3346
|
+
* capture). Tools call this after a successful sendFormLink; the runtime
|
|
3347
|
+
* owns the lifecycle of the underlying WebSocket.
|
|
3348
|
+
*
|
|
3349
|
+
* Returns a function the tool can call to tear down the subscription
|
|
3350
|
+
* early. The subscription also self-closes on form submission or idle.
|
|
3351
|
+
*
|
|
3352
|
+
* No-op (returns a no-op teardown) when the agent has no process or
|
|
3353
|
+
* VOICELAYER_API_URL is unset.
|
|
3354
|
+
*/
|
|
3355
|
+
watchFormSession(token: string): () => void;
|
|
3356
|
+
/** Free-form scratch space for hooks to share state within a call. */
|
|
3357
|
+
readonly metadata: Record<string, unknown>;
|
|
3358
|
+
/**
|
|
3359
|
+
* Live view of the call as a participant room. Always populated — for
|
|
3360
|
+
* 1:1 calls the room contains one human participant + the agent.
|
|
3361
|
+
*/
|
|
3362
|
+
readonly room: Room;
|
|
3363
|
+
/** Per-participant audio profiles + routing matrix + floor control. */
|
|
3364
|
+
readonly audio: AudioSurface;
|
|
3365
|
+
/**
|
|
3366
|
+
* Speak text (via TTS). Returns when the speech is queued.
|
|
3367
|
+
* `opts.to` selects a participant subset; default is broadcast. The
|
|
3368
|
+
* runtime currently publishes a single shared track; targeted delivery
|
|
3369
|
+
* lands with the per-listener track work (PR#4).
|
|
3370
|
+
*/
|
|
3371
|
+
say(text: string, opts?: SayOptions): Promise<void>;
|
|
3372
|
+
/** Ask the LLM to produce a reply now (optionally with extra instructions). */
|
|
3373
|
+
respond(instructionsOrOpts?: string | RespondOptions): Promise<void>;
|
|
3374
|
+
/** Pose a question and resolve with the caller's transcribed answer. */
|
|
3375
|
+
ask(question: string): Promise<string>;
|
|
3376
|
+
/** Transfer the caller to another phone number. Ends the agent's leg.
|
|
3377
|
+
* `mode` overrides the agent-level warm/cold default for this transfer. */
|
|
3378
|
+
handoff(to: string, opts?: {
|
|
3379
|
+
reason?: string;
|
|
3380
|
+
briefing?: string;
|
|
3381
|
+
mode?: 'warm' | 'cold';
|
|
3382
|
+
}): Promise<void>;
|
|
3383
|
+
/**
|
|
3384
|
+
* Hang up the call. Optionally records a reason (surfaced to logs and
|
|
3385
|
+
* `endCall.onEnd`). Teardown is owned by the SDK end-call controller, which
|
|
3386
|
+
* deletes the whole LiveKit room by default so the SIP/PSTN leg drops too —
|
|
3387
|
+
* not just the agent participant.
|
|
3388
|
+
*/
|
|
3389
|
+
endCall(opts?: {
|
|
3390
|
+
reason?: string;
|
|
3391
|
+
}): Promise<void>;
|
|
3392
|
+
/**
|
|
3393
|
+
* Subscribe to inbound DTMF keypresses from participants. Returns an
|
|
3394
|
+
* unsubscribe function. Handlers are called once per digit in the order
|
|
3395
|
+
* received. Errors thrown inside a handler are caught and logged so one
|
|
3396
|
+
* bad handler can't break others.
|
|
3397
|
+
*
|
|
3398
|
+
* @example
|
|
3399
|
+
* ctx.onDtmf(async (ev) => {
|
|
3400
|
+
* if (ev.digit === '0') await ctx.handoff('+18005551212');
|
|
3401
|
+
* });
|
|
3402
|
+
*/
|
|
3403
|
+
onDtmf(handler: DtmfHandler): () => void;
|
|
3404
|
+
/**
|
|
3405
|
+
* Send DTMF digits from the agent's leg. Each character is published as
|
|
3406
|
+
* a separate RFC 4733 event; non-DTMF characters (anything not in
|
|
3407
|
+
* 0-9*#A-D) are dropped. `opts.delayMs` controls pacing between digits.
|
|
3408
|
+
*
|
|
3409
|
+
* Useful for IVR navigation post-handoff or during outbound calls.
|
|
3410
|
+
*/
|
|
3411
|
+
sendDtmf(digits: string, opts?: SendDtmfOptions): Promise<void>;
|
|
3412
|
+
/** Escape hatch to LiveKit primitives — use when a hook isn't enough. */
|
|
3413
|
+
readonly livekit: {
|
|
3414
|
+
readonly job: JobContext;
|
|
3415
|
+
readonly session: voice.AgentSession;
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
/**
|
|
3419
|
+
* Map a single character to its RFC 4733 event code, or null when the
|
|
3420
|
+
* character isn't a valid DTMF digit. 0–9 → 0–9, * → 10, # → 11, A–D → 12–15.
|
|
3421
|
+
*/
|
|
3422
|
+
declare function dtmfDigitToCode(digit: string): number | null;
|
|
3423
|
+
/** Inverse of dtmfDigitToCode. Returns null for codes outside 0..15. */
|
|
3424
|
+
declare function dtmfCodeToDigit(code: number): string | null;
|
|
3425
|
+
|
|
3426
|
+
/** Primitive shorthand types accepted in tool input. Extendable. */
|
|
3427
|
+
type ShorthandPrimitive$1 = 'string' | 'number' | 'boolean';
|
|
3428
|
+
/** What the user passes for a tool's input shape. */
|
|
3429
|
+
type ToolInputShape$1 = Record<string, ShorthandPrimitive$1> | z.ZodTypeAny;
|
|
3430
|
+
interface ToolDefinition$1<I = unknown, R = unknown> {
|
|
3431
|
+
readonly description: string;
|
|
3432
|
+
readonly input: ToolInputShape$1;
|
|
3433
|
+
/** Implementation. Receives parsed input and the agent context. */
|
|
3434
|
+
readonly run: (input: I, ctx: AgentContext) => Promise<R> | R;
|
|
3435
|
+
/** Capability required for Action Guard. Defaults to `tool.<name>`. */
|
|
3436
|
+
readonly capability?: string;
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3439
|
+
interface ResendCredentials {
|
|
3440
|
+
/** Resend API key — find under "API Keys" in the Resend dashboard. */
|
|
3441
|
+
readonly apiKey: string;
|
|
3442
|
+
/**
|
|
3443
|
+
* The verified `From:` address — must be a sender on a domain you've
|
|
3444
|
+
* verified in Resend (Settings → Domains). Accepts plain
|
|
3445
|
+
* "you@yourdomain.com" or "Display Name <you@yourdomain.com>" format.
|
|
3446
|
+
*/
|
|
3447
|
+
readonly from: string;
|
|
3448
|
+
}
|
|
3449
|
+
interface ResendEmailToolOptions extends ResendCredentials {
|
|
3450
|
+
/**
|
|
3451
|
+
* Optional subject prefix prepended to every send. Useful when an agent
|
|
3452
|
+
* should always brand its emails consistently (e.g. "[Acme Support]").
|
|
3453
|
+
* Agents can still override the full subject per call.
|
|
3454
|
+
*/
|
|
3455
|
+
readonly subjectPrefix?: string;
|
|
3456
|
+
/**
|
|
3457
|
+
* Optional canned signature appended to the plain-text body. Lets agent
|
|
3458
|
+
* authors enforce a sign-off without prompting the LLM to remember.
|
|
3459
|
+
*/
|
|
3460
|
+
readonly signature?: string;
|
|
3461
|
+
}
|
|
3462
|
+
declare function resendEmailTool(options: ResendEmailToolOptions): ToolDefinition$1;
|
|
3463
|
+
|
|
3464
|
+
interface FormToolsOptions {
|
|
3465
|
+
/**
|
|
3466
|
+
* Optional default webhook URL to attach to every form session the agent
|
|
3467
|
+
* creates. Customers usually want this set globally per environment.
|
|
3468
|
+
*/
|
|
3469
|
+
readonly defaultWebhookUrl?: string;
|
|
3470
|
+
/**
|
|
3471
|
+
* Customer-supplied Resend credentials. When set, sendFormLink mints the
|
|
3472
|
+
* form session via the platform (so token/state lives on the platform)
|
|
3473
|
+
* but sends the email DIRECTLY from the agent worker using the customer's
|
|
3474
|
+
* Resend account. The API key never leaves the customer's process; the
|
|
3475
|
+
* platform receives a structured log event after the send instead.
|
|
3476
|
+
*
|
|
3477
|
+
* When omitted, sendFormLink falls back to the platform's email path
|
|
3478
|
+
* (POST /v1/forms with `sendEmail` block), which uses VoiceLayer's
|
|
3479
|
+
* shared Resend account.
|
|
3480
|
+
*/
|
|
3481
|
+
readonly resend?: ResendCredentials;
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Build the standard set of form tools, bound to a VoiceLayer client.
|
|
3485
|
+
*
|
|
3486
|
+
* Each entry conforms to ToolDefinition and can be spread directly into an
|
|
3487
|
+
* agent's `tools: {}` map (see defineAgent).
|
|
3488
|
+
*/
|
|
3489
|
+
declare function formTools(vl: VoiceLayerClient, options?: FormToolsOptions): Record<string, ToolDefinition$1>;
|
|
3490
|
+
|
|
3491
|
+
/** Primitive field types accepted in a process definition. */
|
|
3492
|
+
type ProcessFieldType = 'string' | 'string[]' | 'number' | 'boolean' | 'datetime' | 'email' | 'phone';
|
|
3493
|
+
interface ProcessField {
|
|
3494
|
+
readonly type: ProcessFieldType;
|
|
3495
|
+
readonly required?: boolean;
|
|
3496
|
+
/** Regex pattern for `string` / `string[]` items. */
|
|
3497
|
+
readonly pattern?: RegExp;
|
|
3498
|
+
/** Inclusive lower bound on a number or array length. */
|
|
3499
|
+
readonly min?: number;
|
|
3500
|
+
/** Inclusive upper bound on a number or array length. */
|
|
3501
|
+
readonly max?: number;
|
|
3502
|
+
/** One of N — restricts the captured value to this set. */
|
|
3503
|
+
readonly enum?: readonly string[];
|
|
3504
|
+
/** Override the auto-generated prompt for capturing this field. */
|
|
3505
|
+
readonly ask?: string;
|
|
3506
|
+
/** Override the field-extraction hint shown to the LLM. */
|
|
3507
|
+
readonly extract?: string;
|
|
3508
|
+
}
|
|
3509
|
+
type CompletionStrategy = 'all-required-captured' | 'all-captured' | {
|
|
3510
|
+
custom: (data: Record<string, unknown>, ctx: AgentContext) => boolean | Promise<boolean>;
|
|
3511
|
+
};
|
|
3512
|
+
interface ProcessBackendAck {
|
|
3513
|
+
/** URL to POST captured data to. The call cannot complete until this 2xx's. */
|
|
3514
|
+
readonly url: string;
|
|
3515
|
+
readonly timeoutMs?: number;
|
|
3516
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
3517
|
+
}
|
|
3518
|
+
interface ProcessDefinition<T extends Record<string, ProcessField> = Record<string, ProcessField>> {
|
|
3519
|
+
/** Field schema. Order is preserved when the SDK auto-asks for fields. */
|
|
3520
|
+
readonly collect: T;
|
|
3521
|
+
/** When the call can end. Defaults to 'all-required-captured'. */
|
|
3522
|
+
readonly completeWhen?: CompletionStrategy;
|
|
3523
|
+
/** Optional external system that must ACK before completion. */
|
|
3524
|
+
readonly backendAck?: ProcessBackendAck;
|
|
3525
|
+
/** Fires once all completion conditions are met. */
|
|
3526
|
+
readonly onComplete?: (data: InferProcessData<T>, ctx: AgentContext) => Promise<void> | void;
|
|
3527
|
+
/** Fires whenever a field is captured (good for live CRM updates). */
|
|
3528
|
+
readonly onField?: <K extends keyof T>(field: K, value: InferFieldValue<T[K]>, ctx: AgentContext) => Promise<void> | void;
|
|
3529
|
+
}
|
|
3530
|
+
/** Inferred TS type for the data bag a process produces. */
|
|
3531
|
+
type InferProcessData<T extends Record<string, ProcessField>> = {
|
|
3532
|
+
[K in keyof T]: T[K]['required'] extends true ? InferFieldValue<T[K]> : InferFieldValue<T[K]> | undefined;
|
|
3533
|
+
};
|
|
3534
|
+
type InferFieldValue<F extends ProcessField> = F['type'] extends 'string' ? string : F['type'] extends 'string[]' ? string[] : F['type'] extends 'number' ? number : F['type'] extends 'boolean' ? boolean : F['type'] extends 'datetime' ? Date : F['type'] extends 'email' ? string : F['type'] extends 'phone' ? string : never;
|
|
3535
|
+
type TriggerCondition = RegExp | `signal:${string}` | ((text: string, ctx: AgentContext) => boolean | Promise<boolean>);
|
|
3536
|
+
type TriggerAction = 'handoff' | 'endCall' | {
|
|
3537
|
+
say: string;
|
|
3538
|
+
} | {
|
|
3539
|
+
run: (ctx: AgentContext) => Promise<void> | void;
|
|
3540
|
+
}
|
|
3541
|
+
/** Jump the flow-graph cursor to a node id. Only meaningful under the graph
|
|
3542
|
+
* interpreter (the flat goals+rails path has no cursor and ignores it). */
|
|
3543
|
+
| {
|
|
3544
|
+
goto: string;
|
|
3545
|
+
};
|
|
3546
|
+
interface TriggerDefinition {
|
|
3547
|
+
readonly on: TriggerCondition;
|
|
3548
|
+
readonly then: TriggerAction;
|
|
3549
|
+
/** If set, the trigger only fires while the named field is uncaptured. */
|
|
3550
|
+
readonly onlyWhile?: string;
|
|
3551
|
+
}
|
|
3552
|
+
interface HandoffConfig {
|
|
3553
|
+
/** Default human number when a trigger says { then: 'handoff' }. */
|
|
3554
|
+
readonly fallback: string;
|
|
3555
|
+
/** Map signal/trigger names to specific destinations. */
|
|
3556
|
+
readonly routes?: Readonly<Record<string, string>>;
|
|
3557
|
+
/** Build the briefing text passed to the human agent (or PSTN whisper). */
|
|
3558
|
+
readonly briefing?: (args: {
|
|
3559
|
+
readonly data: Record<string, unknown>;
|
|
3560
|
+
readonly transcript: TranscriptHandle;
|
|
3561
|
+
readonly call: AgentContext['call'];
|
|
3562
|
+
}) => string | Promise<string>;
|
|
3563
|
+
/**
|
|
3564
|
+
* 'warm' (default) dials the human into the room as a conference, lets the
|
|
3565
|
+
* agent brief them live, then drops the agent — caller + human stay
|
|
3566
|
+
* connected. 'cold' is a blind SIP REFER: the caller is transferred away
|
|
3567
|
+
* immediately. Warm falls back to cold when no outbound trunk is configured.
|
|
3568
|
+
*/
|
|
3569
|
+
readonly mode?: 'warm' | 'cold';
|
|
3570
|
+
}
|
|
3571
|
+
interface TranscriptHandle {
|
|
3572
|
+
/** Last N turns as `speaker: text` lines. */
|
|
3573
|
+
tail(n: number): string;
|
|
3574
|
+
full(): string;
|
|
3575
|
+
}
|
|
3576
|
+
/**
|
|
3577
|
+
* Memory scope. `'participant'` and `'caller'` are synonyms — `'caller'`
|
|
3578
|
+
* is the historical name from the 1:1 era; new code should prefer
|
|
3579
|
+
* `'participant'`, which makes the multi-party semantics explicit.
|
|
3580
|
+
*/
|
|
3581
|
+
type MemoryScope = 'call' | 'caller' | 'participant' | 'account' | 'platform';
|
|
3582
|
+
interface MemoryConfig {
|
|
3583
|
+
/** Which scope to persist to. Defaults to 'caller'. */
|
|
3584
|
+
readonly scope?: MemoryScope;
|
|
3585
|
+
readonly retentionDays?: number;
|
|
3586
|
+
/** Fields auto-redacted on write. Recognized: ssn, dob, email, phone, ccn. */
|
|
3587
|
+
readonly piiFields?: readonly string[];
|
|
3588
|
+
/** Opt in to cross-tenant aggregate memory (anonymized). */
|
|
3589
|
+
readonly platformOptIn?: boolean;
|
|
3590
|
+
}
|
|
3591
|
+
/**
|
|
3592
|
+
* Multi-participant configuration. Optional — when omitted, the agent runs
|
|
3593
|
+
* in 1:1 mode (one human + one agent) and the SDK still populates
|
|
3594
|
+
* `ctx.room.participants` so participant-aware code paths work.
|
|
3595
|
+
*/
|
|
3596
|
+
interface ParticipantsConfig {
|
|
3597
|
+
/**
|
|
3598
|
+
* Fires when a human participant joins the room. In 1:1 calls this
|
|
3599
|
+
* fires once at session start for the caller. In multi-party calls it
|
|
3600
|
+
* fires per join.
|
|
3601
|
+
*/
|
|
3602
|
+
readonly onJoin?: (participant: Participant, ctx: AgentContext) => Promise<void> | void;
|
|
3603
|
+
/** Fires when a participant disconnects (hangup, transfer, kick). */
|
|
3604
|
+
readonly onLeave?: (participant: Participant, ctx: AgentContext) => Promise<void> | void;
|
|
3605
|
+
/**
|
|
3606
|
+
* Synchronously enrich a participant's attribute bag before `onJoin`
|
|
3607
|
+
* fires. Useful for phone-number → language lookups, etc. The returned
|
|
3608
|
+
* map is merged into `participant.attributes`.
|
|
3609
|
+
*/
|
|
3610
|
+
readonly attributes?: (participant: Participant) => Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
|
|
3611
|
+
/**
|
|
3612
|
+
* Reject participants beyond this count. Default: unlimited. The cap
|
|
3613
|
+
* is enforced by the worker when wiring participant lifecycle.
|
|
3614
|
+
*/
|
|
3615
|
+
readonly max?: number;
|
|
3616
|
+
}
|
|
3617
|
+
/**
|
|
3618
|
+
* A connector instance. Created by per-system factories like `salesforce()`,
|
|
3619
|
+
* `twilio()`, etc. The factory returns an opaque handle that the SDK wires
|
|
3620
|
+
* into `ctx.connectors` and (when `expose: true`) into the LLM tool list.
|
|
3621
|
+
*/
|
|
3622
|
+
interface ConnectorInstance<TName extends string = string, TApi = unknown> {
|
|
3623
|
+
readonly __connector: true;
|
|
3624
|
+
readonly name: TName;
|
|
3625
|
+
readonly api: TApi;
|
|
3626
|
+
/** If true, every method on `api` becomes an LLM-callable tool. */
|
|
3627
|
+
readonly expose?: boolean;
|
|
3628
|
+
}
|
|
3629
|
+
type ComplianceTag = 'tcpa' | 'hipaa' | 'pci' | 'gdpr' | 'soc2';
|
|
3630
|
+
/**
|
|
3631
|
+
* Duck-typed pipeline component markers. The SDK never inspects these — they
|
|
3632
|
+
* are passed through to LiveKit's AgentSession as-is. Three ways to satisfy:
|
|
3633
|
+
*
|
|
3634
|
+
* 1. SDK factory: `deepgram.tts({ model: 'aura-2' })`
|
|
3635
|
+
* 2. Wrapped LK: `wrap(new TTS({...}), { trace: true })`
|
|
3636
|
+
* 3. User-built: class MyTTS extends BaseTTS { ... } // BaseTTS
|
|
3637
|
+
* // re-exported
|
|
3638
|
+
* // from the SDK
|
|
3639
|
+
*
|
|
3640
|
+
* Anything implementing the duck-type — even a plain object — is accepted.
|
|
3641
|
+
*/
|
|
3642
|
+
interface STTProvider {
|
|
3643
|
+
readonly __vlPipeline?: 'stt';
|
|
3644
|
+
}
|
|
3645
|
+
interface LLMProvider {
|
|
3646
|
+
readonly __vlPipeline?: 'llm';
|
|
3647
|
+
}
|
|
3648
|
+
interface TTSProvider {
|
|
3649
|
+
readonly __vlPipeline?: 'tts';
|
|
3650
|
+
}
|
|
3651
|
+
interface VADProvider {
|
|
3652
|
+
readonly __vlPipeline?: 'vad';
|
|
3653
|
+
}
|
|
3654
|
+
interface TurnDetectorProvider {
|
|
3655
|
+
readonly __vlPipeline?: 'turn';
|
|
3656
|
+
}
|
|
3657
|
+
/**
|
|
3658
|
+
* Speech-to-speech / realtime model marker (OpenAI Realtime, Gemini Live).
|
|
3659
|
+
* A realtime model handles STT + LLM + TTS + turn-taking server-side, so when
|
|
3660
|
+
* `models.realtime` is set the SDK builds the AgentSession around it and
|
|
3661
|
+
* ignores the stt/llm/tts slots.
|
|
3662
|
+
*/
|
|
3663
|
+
interface RealtimeProvider {
|
|
3664
|
+
readonly __vlPipeline?: 'realtime';
|
|
3665
|
+
}
|
|
3666
|
+
/**
|
|
3667
|
+
* Lazy form so users can pick a provider per call (e.g. by caller locale).
|
|
3668
|
+
* The factory runs once per call, before AgentSession is constructed, so it
|
|
3669
|
+
* receives the call envelope (callerId, to, metadata) rather than the full
|
|
3670
|
+
* AgentContext (which depends on AgentSession existing).
|
|
3671
|
+
*/
|
|
3672
|
+
type ProviderFactory<T> = (call: CallInfo) => T | Promise<T>;
|
|
3673
|
+
interface ModelConfig {
|
|
3674
|
+
/**
|
|
3675
|
+
* String form: 'openai/gpt-4o' (resolves via SDK defaults).
|
|
3676
|
+
* Instance form: any LLMProvider (LK plugin, wrap()-ed, or user-built).
|
|
3677
|
+
* Factory form: `(ctx) => provider` for per-call selection.
|
|
3678
|
+
*/
|
|
3679
|
+
readonly llm?: string | LLMProvider | ProviderFactory<LLMProvider>;
|
|
3680
|
+
readonly stt?: string | STTProvider | ProviderFactory<STTProvider>;
|
|
3681
|
+
readonly tts?: string | TTSProvider | ProviderFactory<TTSProvider>;
|
|
3682
|
+
/** VAD has no string form — always pass an instance or factory. */
|
|
3683
|
+
readonly vad?: VADProvider | ProviderFactory<VADProvider>;
|
|
3684
|
+
readonly turnDetector?: TurnDetectorProvider | ProviderFactory<TurnDetectorProvider>;
|
|
3685
|
+
/**
|
|
3686
|
+
* Speech-to-speech / realtime model. When set, the STT→LLM→TTS pipeline is
|
|
3687
|
+
* bypassed: the realtime model drives the whole turn. No string form — pass
|
|
3688
|
+
* an instance (`openai.realtime({ voice: 'alloy' })`) or a per-call factory.
|
|
3689
|
+
*/
|
|
3690
|
+
readonly realtime?: RealtimeProvider | ProviderFactory<RealtimeProvider>;
|
|
3691
|
+
/** Spoken language; defaults to 'en-US'. Used by string-form defaults. */
|
|
3692
|
+
readonly language?: string;
|
|
3693
|
+
}
|
|
3694
|
+
/**
|
|
3695
|
+
* Answering-machine detection mode for outbound calls. Mirrors
|
|
3696
|
+
* `OutboundConfig.amd` in @voicelayer/agent-spec.
|
|
3697
|
+
*
|
|
3698
|
+
* 'off' — never run AMD; treat every answer as a human.
|
|
3699
|
+
* 'detect' — leave the voicemail message (or hang up) the moment
|
|
3700
|
+
* a machine greeting is recognised.
|
|
3701
|
+
* 'detectMessageEnd' — recognise the machine, then wait for the greeting to
|
|
3702
|
+
* finish (an explicit "after the tone"-style cue or the
|
|
3703
|
+
* greeting going quiet) before leaving the message.
|
|
3704
|
+
*/
|
|
3705
|
+
type AmdMode = 'off' | 'detect' | 'detectMessageEnd';
|
|
3706
|
+
/**
|
|
3707
|
+
* Outbound-only behavior. AMD never runs on inbound calls (the runtime gates
|
|
3708
|
+
* on the dispatch-metadata `direction`), so these knobs are inert unless the
|
|
3709
|
+
* call was placed via the outbound path.
|
|
3710
|
+
*/
|
|
3711
|
+
interface OutboundCallConfig {
|
|
3712
|
+
/** Answering-machine detection mode. Defaults to 'off'. */
|
|
3713
|
+
readonly amd?: AmdMode;
|
|
3714
|
+
/**
|
|
3715
|
+
* Spoken (via TTS) when a machine is detected. When unset, the agent hangs
|
|
3716
|
+
* up on detection instead of leaving a message.
|
|
3717
|
+
*/
|
|
3718
|
+
readonly voicemailScript?: string;
|
|
3719
|
+
}
|
|
3720
|
+
/**
|
|
3721
|
+
* Speech polish. `pronunciations` rewrites brand names / acronyms / jargon to
|
|
3722
|
+
* a spoken form before TTS (e.g. `{ VoiceLayer: 'Voice Layer', API: 'A P I' }`)
|
|
3723
|
+
* via applyPronunciations(). `backgroundAudio` plays ambient room tone under
|
|
3724
|
+
* the agent so silence feels less dead (a URL or a named preset).
|
|
3725
|
+
*/
|
|
3726
|
+
interface SpeechConfig {
|
|
3727
|
+
readonly pronunciations?: Readonly<Record<string, string>>;
|
|
3728
|
+
readonly backgroundAudio?: string | {
|
|
3729
|
+
readonly url?: string;
|
|
3730
|
+
readonly volume?: number;
|
|
3731
|
+
};
|
|
3732
|
+
}
|
|
3733
|
+
/** What caused the call to end. Surfaced to `endCall.onEnd` + logs. */
|
|
3734
|
+
type EndCallTrigger =
|
|
3735
|
+
/** The LLM invoked the built-in `end_call` tool. */
|
|
3736
|
+
'tool'
|
|
3737
|
+
/** An external controller (MCP host) sent a `hangup` command. */
|
|
3738
|
+
| 'host'
|
|
3739
|
+
/** The dead-air backstop fired (`idleHangupMs` of silence while idle). */
|
|
3740
|
+
| 'idle'
|
|
3741
|
+
/** The last non-agent participant left the room. */
|
|
3742
|
+
| 'participant-left'
|
|
3743
|
+
/** A flow/graph run finished and asked to hang up. */
|
|
3744
|
+
| 'flow'
|
|
3745
|
+
/** The realtime engine closed / disconnected under the session. */
|
|
3746
|
+
| 'engine-closed'
|
|
3747
|
+
/** `ctx.endCall()` called directly from user code. */
|
|
3748
|
+
| 'user';
|
|
3749
|
+
/** Passed to `endCall.onEnd` describing the teardown about to happen. */
|
|
3750
|
+
interface EndCallInfo {
|
|
3751
|
+
/** Why the call is ending (e.g. the `end_call` tool's `reason`). */
|
|
3752
|
+
readonly reason?: string;
|
|
3753
|
+
/** What triggered the hang-up. */
|
|
3754
|
+
readonly trigger: EndCallTrigger;
|
|
3755
|
+
/** The teardown strategy that will run (after the policy is resolved). */
|
|
3756
|
+
readonly teardown: 'room' | 'agent';
|
|
3757
|
+
}
|
|
3758
|
+
/**
|
|
3759
|
+
* Controls how the agent ENDS a call. The SDK — not the agent prompt or an
|
|
3760
|
+
* external puppet driver — owns teardown, so a hang-up is reliable even when
|
|
3761
|
+
* the realtime transport has died mid-wrap.
|
|
3762
|
+
*
|
|
3763
|
+
* Defaults are "best case" and active without opt-in: the whole LiveKit room
|
|
3764
|
+
* is deleted (which drops the SIP/PSTN leg too, so the carrier gets a BYE),
|
|
3765
|
+
* a guarantee-watchdog re-attempts teardown if the first try doesn't land, and
|
|
3766
|
+
* a dead-air backstop hangs up after the line has been silent too long. Every
|
|
3767
|
+
* knob is overridable; set a field to `false` to disable that guard.
|
|
3768
|
+
*/
|
|
3769
|
+
interface EndCallPolicy {
|
|
3770
|
+
/**
|
|
3771
|
+
* Teardown strategy. `'room'` (default) deletes the LiveKit room via the
|
|
3772
|
+
* room service — this removes the SIP participant too, so the call actually
|
|
3773
|
+
* disconnects on the carrier side. `'agent'` only drops the agent's own
|
|
3774
|
+
* participant (leaves any SIP leg up); use it only when something else owns
|
|
3775
|
+
* the room lifecycle.
|
|
3776
|
+
*/
|
|
3777
|
+
readonly teardown?: 'room' | 'agent';
|
|
3778
|
+
/**
|
|
3779
|
+
* After a hang-up is requested, keep re-attempting teardown until the room
|
|
3780
|
+
* is actually gone or this many ms elapse. Guards against a teardown call
|
|
3781
|
+
* that silently doesn't land (transport race, transient room-service error).
|
|
3782
|
+
* Default 4000. `false` disables (single best-effort attempt).
|
|
3783
|
+
*/
|
|
3784
|
+
readonly guaranteeMs?: number | false;
|
|
3785
|
+
/**
|
|
3786
|
+
* Dead-air backstop: when the agent is idle (waiting on the caller) and the
|
|
3787
|
+
* line stays silent — no agent turn, no caller speech — for this many ms,
|
|
3788
|
+
* end the call. Catches a wedged session whose normal `end_call` never ran.
|
|
3789
|
+
* Only armed while the agent is idle, so it never interrupts agent speech or
|
|
3790
|
+
* a long tool call. Default 20000. `false` disables.
|
|
3791
|
+
*/
|
|
3792
|
+
readonly idleHangupMs?: number | false;
|
|
3793
|
+
/**
|
|
3794
|
+
* Hook fired the moment a hang-up is decided, just before teardown. Return
|
|
3795
|
+
* `false` to take over teardown yourself (the SDK then does nothing — the
|
|
3796
|
+
* call will NOT end unless you end it). Returning anything else (or nothing)
|
|
3797
|
+
* runs the default teardown. Throwing is caught + logged, then the default
|
|
3798
|
+
* teardown still runs (safe by default).
|
|
3799
|
+
*/
|
|
3800
|
+
readonly onEnd?: (ctx: AgentContext, info: EndCallInfo) => boolean | void | Promise<boolean | void>;
|
|
3801
|
+
}
|
|
3802
|
+
type ShorthandPrimitive = 'string' | 'number' | 'boolean';
|
|
3803
|
+
type ToolInputShape = Record<string, ShorthandPrimitive> | z.ZodTypeAny;
|
|
3804
|
+
interface ToolDefinition<I = unknown, R = unknown> {
|
|
3805
|
+
readonly description: string;
|
|
3806
|
+
readonly input: ToolInputShape;
|
|
3807
|
+
readonly run: (input: I, ctx: AgentContext) => Promise<R> | R;
|
|
3808
|
+
/**
|
|
3809
|
+
* Capability this tool requires. Action Guard hard-blocks the call if not
|
|
3810
|
+
* declared (PRD §B.5 — "no soft failures, ever"). Defaults to
|
|
3811
|
+
* `tool.<name>` when omitted; passing a domain-scoped string
|
|
3812
|
+
* (`crm.write`, `payment.refund`) lets multiple tools share a capability
|
|
3813
|
+
* for centralised policy.
|
|
3814
|
+
*/
|
|
3815
|
+
readonly capability?: string;
|
|
3816
|
+
}
|
|
3817
|
+
/**
|
|
3818
|
+
* Optional security adapters. The SDK always enforces the local-only synchronous
|
|
3819
|
+
* guards (PRD §B.2 input regex, §B.3 system seal + PII tokenisation, §B.4
|
|
3820
|
+
* markdown strip + PII partial-mask, §B.5 capability check). Setting any of
|
|
3821
|
+
* these augments the local floor with external services. Each is independently
|
|
3822
|
+
* optional — none has to be live for the floor guards to function.
|
|
3823
|
+
*
|
|
3824
|
+
* URLs can also come from env (`SECURITY_LLM_GUARD_URL`,
|
|
3825
|
+
* `SECURITY_PRESIDIO_ANALYZER_URL`, `SECURITY_PRESIDIO_ANONYMIZER_URL`,
|
|
3826
|
+
* `SECURITY_OPA_URL`, `SECURITY_OPA_DECISION_PATH`); explicit config wins.
|
|
3827
|
+
*/
|
|
3828
|
+
interface SecurityConfig {
|
|
3829
|
+
/** Disable the primitive entirely. Use only for tests. Production code MUST NOT set this. */
|
|
3830
|
+
readonly disabled?: boolean;
|
|
3831
|
+
/** External LLM-Guard adapter for richer injection detection. */
|
|
3832
|
+
readonly llmGuardUrl?: string;
|
|
3833
|
+
/** Presidio analyzer URL for PII detection beyond local regex. */
|
|
3834
|
+
readonly presidioAnalyzerUrl?: string;
|
|
3835
|
+
/** Presidio anonymizer URL — if set, output is redacted before TTS. */
|
|
3836
|
+
readonly presidioAnonymizerUrl?: string;
|
|
3837
|
+
/** OPA decision API base URL (e.g. `http://opa:8181`). */
|
|
3838
|
+
readonly opaUrl?: string;
|
|
3839
|
+
/** OPA decision path (e.g. `voicelayer/security/decision`). */
|
|
3840
|
+
readonly opaDecisionPath?: string;
|
|
3841
|
+
/** Per-request timeout for security adapter calls. */
|
|
3842
|
+
readonly adapterTimeoutMs?: number;
|
|
3843
|
+
}
|
|
3844
|
+
/**
|
|
3845
|
+
* Marks an agent as a *flow-runtime* worker: instead of a fixed process it
|
|
3846
|
+
* resolves the deployed flow from the dispatch metadata (`agentId`) at call
|
|
3847
|
+
* time, fetches that agent's compiled process_schema, and boots from it. One
|
|
3848
|
+
* process serves many flows (the shared pool). See defineFlowRuntime().
|
|
3849
|
+
*/
|
|
3850
|
+
interface FlowRuntimeConfig {
|
|
3851
|
+
/** Prepended to the flow's compiled say/confirm prompt fragments. */
|
|
3852
|
+
readonly basePrompt?: string;
|
|
3853
|
+
}
|
|
3854
|
+
interface AgentConfig<TProcess extends Record<string, ProcessField> = Record<string, ProcessField>> {
|
|
3855
|
+
/** Lowercase, kebab-case identifier. Used for LiveKit dispatch + presence. */
|
|
3856
|
+
readonly name: string;
|
|
3857
|
+
/** System prompt the LLM sees. */
|
|
3858
|
+
readonly prompt: string;
|
|
3859
|
+
/** Agent-level Instructions (the routing/decision layer): plain-language guidance
|
|
3860
|
+
* for WHEN the agent acts, appended below the persona under a `# Routing` header.
|
|
3861
|
+
* Interpolated with {{ }} by the process runtime. Optional. */
|
|
3862
|
+
readonly routingInstructions?: string;
|
|
3863
|
+
/** Capability tags surfaced in the dashboard. */
|
|
3864
|
+
readonly capabilities?: readonly string[];
|
|
3865
|
+
/** Semantic version. Defaults to AGENT_VERSION env or '0.0.0'. */
|
|
3866
|
+
readonly version?: string;
|
|
3867
|
+
/** dev / stg / prd. Defaults to AGENT_ENVIRONMENT env or 'dev'. */
|
|
3868
|
+
readonly environment?: AgentEnvironment;
|
|
3869
|
+
readonly process?: ProcessDefinition<TProcess>;
|
|
3870
|
+
readonly triggers?: Readonly<Record<string, TriggerDefinition>>;
|
|
3871
|
+
readonly handoff?: HandoffConfig;
|
|
3872
|
+
readonly memory?: MemoryConfig;
|
|
3873
|
+
readonly participants?: ParticipantsConfig;
|
|
3874
|
+
readonly connectors?: Readonly<Record<string, ConnectorInstance>>;
|
|
3875
|
+
readonly compliance?: readonly ComplianceTag[];
|
|
3876
|
+
readonly models?: ModelConfig;
|
|
3877
|
+
readonly outbound?: OutboundCallConfig;
|
|
3878
|
+
readonly speech?: SpeechConfig;
|
|
3879
|
+
readonly endCall?: EndCallPolicy;
|
|
3880
|
+
readonly tools?: Readonly<Record<string, ToolDefinition>>;
|
|
3881
|
+
readonly security?: SecurityConfig;
|
|
3882
|
+
/**
|
|
3883
|
+
* Per-call ConsultationPolicy used by the built-in `ask_host` tool. When
|
|
3884
|
+
* omitted the SDK uses the contract defaults (30s per-consult, 120s
|
|
3885
|
+
* cumulative). Plan-first calls override this at boot from
|
|
3886
|
+
* `plan.draftConfig.consultation`. See
|
|
3887
|
+
* packages/contracts/src/consultation.ts for the schema + semantics.
|
|
3888
|
+
*/
|
|
3889
|
+
readonly consultation?: ConsultationPolicy;
|
|
3890
|
+
readonly onUtterance?: (text: string, ctx: AgentContext) => Promise<void> | void;
|
|
3891
|
+
readonly onFieldCaptured?: (field: string, value: unknown, ctx: AgentContext) => Promise<void> | void;
|
|
3892
|
+
readonly onCallEnd?: (outcome: CallOutcomeSummary, ctx: AgentContext) => Promise<void> | void;
|
|
3893
|
+
readonly onEvent?: (event: AgentLifecycleEvent) => void;
|
|
3894
|
+
/** Replace the default conversation loop. The SDK does NOT auto-greet. */
|
|
3895
|
+
readonly onCall?: (ctx: AgentContext) => Promise<void>;
|
|
3896
|
+
readonly readiness?: readonly ReadinessProbe[];
|
|
3897
|
+
/**
|
|
3898
|
+
* Run as a remote-controlled (puppet) agent: no autonomous LLM loop, no
|
|
3899
|
+
* process/triggers pipeline. STT utterances are still published to
|
|
3900
|
+
* `call-events:{callId}` via the existing transcript-segments sync, and
|
|
3901
|
+
* the SDK subscribes to `call-control:{callId}` to receive `say`,
|
|
3902
|
+
* `hangup`, `dtmf` commands from an external driver (typically the MCP
|
|
3903
|
+
* server invoked by a coding agent).
|
|
3904
|
+
*
|
|
3905
|
+
* When this is on, `process`, `triggers`, `onUtterance`, `onCall` are
|
|
3906
|
+
* ignored. `tools`, `connectors`, `memory` still work.
|
|
3907
|
+
*/
|
|
3908
|
+
readonly puppetMode?: boolean;
|
|
3909
|
+
/**
|
|
3910
|
+
* Host-controlled autonomous agent (the "smart puppet"). UNLIKE puppetMode,
|
|
3911
|
+
* the agent keeps its REAL LLM and drives the conversation itself from its
|
|
3912
|
+
* prompt (the per-call `intent` is appended at boot). This flag only wires
|
|
3913
|
+
* the `call-control:{room}` channel so the MCP host can still interject
|
|
3914
|
+
* (`say`), end the call (`hangup`), or send `dtmf` — and answer the agent's
|
|
3915
|
+
* `ask_host` consultations. Use this for an agent that takes a customer's
|
|
3916
|
+
* intent and runs the call like a human secretary, asking the host for any
|
|
3917
|
+
* info it's missing. Mutually exclusive in spirit with puppetMode (which is
|
|
3918
|
+
* the older NoOp "dumb mouth").
|
|
3919
|
+
*/
|
|
3920
|
+
readonly hostControlled?: boolean;
|
|
3921
|
+
/** When set, this agent boots each call from a deployed flow's process_schema. */
|
|
3922
|
+
readonly flowRuntime?: FlowRuntimeConfig;
|
|
3923
|
+
/**
|
|
3924
|
+
* Opt a hand-coded (non-flow) agent into the dashboard-driven pipeline: on
|
|
3925
|
+
* each call the SDK fetches this agent's stored `agent_config` and applies
|
|
3926
|
+
* the operator-selected voice / model / STT over the coded defaults. The
|
|
3927
|
+
* pipeline *mode* (cascade vs realtime) stays pinned to what the code
|
|
3928
|
+
* declares — a stale `mode=realtime` in the dashboard can't flip a
|
|
3929
|
+
* cascade-only worker. Flow agents (`flowRuntime`) get this implicitly and
|
|
3930
|
+
* may additionally switch mode; this flag is the SDK opt-in. The agent id is
|
|
3931
|
+
* read from dispatch metadata (the inbound router injects it from
|
|
3932
|
+
* phone_numbers.agentId), so it's a no-op for calls without one.
|
|
3933
|
+
*/
|
|
3934
|
+
readonly pipelineFromConfig?: boolean;
|
|
3935
|
+
/**
|
|
3936
|
+
* Opt this agent into MCP-layer visibility. When true, on register the API
|
|
3937
|
+
* also writes an `agent_config` row keyed by (project_id, name,
|
|
3938
|
+
* environment) so MCP / dashboard / REST can list and inspect this agent
|
|
3939
|
+
* (and, post-step-7, drive call_say / call_send_guidance / etc against
|
|
3940
|
+
* its live calls).
|
|
3941
|
+
*
|
|
3942
|
+
* Defaults to true so newly-registered agents show up in dashboards and
|
|
3943
|
+
* MCP-host listings without opt-in. Pass `false` for autonomous-only
|
|
3944
|
+
* agents that should stay invisible to MCP. See
|
|
3945
|
+
* docs/architecture/contracts-design.md §2b.
|
|
3946
|
+
*/
|
|
3947
|
+
readonly mcpExposed?: boolean;
|
|
3948
|
+
}
|
|
3949
|
+
interface CallOutcomeSummary {
|
|
3950
|
+
readonly reason: 'completed' | 'handoff' | 'caller_hung_up' | 'agent_hung_up' | 'error';
|
|
3951
|
+
readonly durationMs: number;
|
|
3952
|
+
readonly processCompleted: boolean;
|
|
3953
|
+
readonly fieldsCaptured: number;
|
|
3954
|
+
readonly handoffOccurred: boolean;
|
|
3955
|
+
}
|
|
3956
|
+
/**
|
|
3957
|
+
* Identity helper that gives users a typed `defineProcess` entry point with
|
|
3958
|
+
* full inference on `onComplete`'s `data` argument.
|
|
3959
|
+
*
|
|
3960
|
+
* defineProcess({
|
|
3961
|
+
* collect: { name: { type: 'string', required: true } },
|
|
3962
|
+
* onComplete: (data) => { data.name // string },
|
|
3963
|
+
* })
|
|
3964
|
+
*/
|
|
3965
|
+
declare function defineProcess<T extends Record<string, ProcessField>>(def: ProcessDefinition<T>): ProcessDefinition<T>;
|
|
3966
|
+
|
|
3967
|
+
declare class Agent {
|
|
3968
|
+
private readonly config;
|
|
3969
|
+
private registered;
|
|
3970
|
+
private processStatePublisher;
|
|
3971
|
+
constructor(config: AgentConfig);
|
|
3972
|
+
/**
|
|
3973
|
+
* Boot the LiveKit worker and register presence. Idempotent. Returns the
|
|
3974
|
+
* LiveKit agent definition so the caller can `export default` it; LK's
|
|
3975
|
+
* child processes find that definition when re-importing the file.
|
|
3976
|
+
*
|
|
3977
|
+
* Pass `import.meta.url` so cli.runApp knows where to fork from.
|
|
3978
|
+
*/
|
|
3979
|
+
start(moduleUrl: string): Promise<unknown>;
|
|
3980
|
+
/**
|
|
3981
|
+
* Build the LiveKit defineAgent return value without booting cli.runApp.
|
|
3982
|
+
* Useful for tests and for users who want to compose multiple agents in one
|
|
3983
|
+
* process.
|
|
3984
|
+
*/
|
|
3985
|
+
toLivekitAgent(): Promise<unknown>;
|
|
3986
|
+
private runJob;
|
|
3987
|
+
private runCallSpan;
|
|
3988
|
+
private registerPresence;
|
|
3989
|
+
}
|
|
3990
|
+
|
|
3991
|
+
declare function defineAgent<TProcess extends Record<string, ProcessField> = Record<string, ProcessField>>(config: AgentConfig<TProcess>): Agent;
|
|
3992
|
+
/**
|
|
3993
|
+
* defineFlowRuntime — a worker that serves many visually-built flows from one
|
|
3994
|
+
* process (the shared pool). It registers under a single LiveKit agent name;
|
|
3995
|
+
* per dispatched call it resolves the deployed flow from the dispatch metadata
|
|
3996
|
+
* (`agentId`), fetches that agent's compiled process_schema, and boots from it
|
|
3997
|
+
* via the same per-job override path that plans use. The STT/LLM/TTS pipeline
|
|
3998
|
+
* is shared infrastructure set here; the flow supplies prompt/process/triggers.
|
|
3999
|
+
*
|
|
4000
|
+
* export default await defineFlowRuntime({ models: {...} }).start(import.meta.url);
|
|
4001
|
+
*/
|
|
4002
|
+
declare function defineFlowRuntime(opts: {
|
|
4003
|
+
readonly name?: string;
|
|
4004
|
+
readonly models?: ModelConfig;
|
|
4005
|
+
readonly basePrompt?: string;
|
|
4006
|
+
readonly capabilities?: readonly string[];
|
|
4007
|
+
readonly version?: string;
|
|
4008
|
+
}): Agent;
|
|
4009
|
+
|
|
4010
|
+
interface PuppetControlDeps {
|
|
4011
|
+
/**
|
|
4012
|
+
* LiveKit room name — used as the control-channel key. This is the only
|
|
4013
|
+
* identifier the agent reliably has at dispatch time (the API-side
|
|
4014
|
+
* project_calls UUID may not even exist yet when the agent boots, since
|
|
4015
|
+
* the LK `room_started` webhook fires after dispatch).
|
|
4016
|
+
*
|
|
4017
|
+
* The API translates UUID → room name before publishing — see
|
|
4018
|
+
* apps/api/src/routes/call-control.ts.
|
|
4019
|
+
*/
|
|
4020
|
+
readonly roomName: string;
|
|
4021
|
+
readonly session: unknown;
|
|
4022
|
+
readonly onHangup: () => Promise<void>;
|
|
4023
|
+
readonly onDtmf?: (digits: string) => Promise<void>;
|
|
4024
|
+
readonly log?: (msg: string, attrs?: Record<string, unknown>) => void;
|
|
4025
|
+
}
|
|
4026
|
+
interface PuppetControlHandle {
|
|
4027
|
+
/** Stop listening for commands and tear down the Redis subscription. */
|
|
4028
|
+
close(): Promise<void>;
|
|
4029
|
+
}
|
|
4030
|
+
/** True if we should run puppet wiring — REDIS_URL must be set. */
|
|
4031
|
+
declare function puppetEnvAvailable(): boolean;
|
|
4032
|
+
/**
|
|
4033
|
+
* Start a puppet-mode control listener for the given call. Returns a handle
|
|
4034
|
+
* the caller invokes when the call ends to release the Redis connection.
|
|
4035
|
+
*
|
|
4036
|
+
* Pubsub semantics: one IORedis subscriber per call. Cheap (Valkey handles
|
|
4037
|
+
* thousands of subscriptions per node) and isolates listener teardown from
|
|
4038
|
+
* other calls in the same agent process.
|
|
4039
|
+
*/
|
|
4040
|
+
declare function startPuppetControl(deps: PuppetControlDeps): Promise<PuppetControlHandle>;
|
|
4041
|
+
/**
|
|
4042
|
+
* Build a no-op LLM compatible with @livekit/agents voice.AgentSession.
|
|
4043
|
+
* Used in puppet mode to suppress autonomous replies — every STT turn
|
|
4044
|
+
* triggers an LLM call inside AgentSession; we want that call to produce
|
|
4045
|
+
* nothing so the session stays silent until `session.say()` is invoked
|
|
4046
|
+
* externally via the control channel.
|
|
4047
|
+
*
|
|
4048
|
+
* Signature assumes LK Agents 1.x `llm.LLM` base class. If your installed
|
|
4049
|
+
* version differs, replace this with whatever shape AgentSession accepts
|
|
4050
|
+
* as its `llm` field while producing no output.
|
|
4051
|
+
*/
|
|
4052
|
+
declare function createNoOpLLM(): Promise<unknown>;
|
|
4053
|
+
|
|
4054
|
+
type PronunciationDict = Readonly<Record<string, string>>;
|
|
4055
|
+
declare function applyPronunciations(text: string, dict: PronunciationDict): string;
|
|
4056
|
+
|
|
4057
|
+
interface WebhookConfig {
|
|
4058
|
+
readonly url: string;
|
|
4059
|
+
readonly auth?: {
|
|
4060
|
+
readonly type: 'bearer';
|
|
4061
|
+
readonly token: string;
|
|
4062
|
+
} | {
|
|
4063
|
+
readonly type: 'basic';
|
|
4064
|
+
readonly username: string;
|
|
4065
|
+
readonly password: string;
|
|
4066
|
+
} | {
|
|
4067
|
+
readonly type: 'header';
|
|
4068
|
+
readonly header: string;
|
|
4069
|
+
readonly value: string;
|
|
4070
|
+
};
|
|
4071
|
+
readonly timeoutMs?: number;
|
|
4072
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
4073
|
+
}
|
|
4074
|
+
interface WebhookApi {
|
|
4075
|
+
post(path: string, body: unknown): Promise<unknown>;
|
|
4076
|
+
get(path: string): Promise<unknown>;
|
|
4077
|
+
}
|
|
4078
|
+
declare function webhook(config: WebhookConfig): ConnectorInstance<'webhook', WebhookApi>;
|
|
4079
|
+
|
|
4080
|
+
/** Subset of ModelConfig the Agent class converts AgentConfig.models into. */
|
|
4081
|
+
type PipelineConfig = ModelConfig;
|
|
4082
|
+
|
|
4083
|
+
type ProviderKind = 'tts' | 'stt' | 'llm' | 'vad' | 'turn';
|
|
4084
|
+
interface WrapOptions<T> {
|
|
4085
|
+
/** Emit OTel spans around each method call. Default: true. */
|
|
4086
|
+
readonly trace?: boolean;
|
|
4087
|
+
/** Tag spans with `vl.provider.label` for easy filtering. */
|
|
4088
|
+
readonly label?: string;
|
|
4089
|
+
/**
|
|
4090
|
+
* Provider role. When set, the wrapper additionally emits OTel Counters
|
|
4091
|
+
* (vl.tts.chars / vl.llm.input_tokens / vl.stt.seconds) so /v1/calls/:id/
|
|
4092
|
+
* metrics returns real per-call usage. The TTS path is wired today —
|
|
4093
|
+
* chars are counted from the synthesize() text argument. LLM/STT counters
|
|
4094
|
+
* still depend on the underlying adapter exposing usage on its response
|
|
4095
|
+
* shape; see TODO below.
|
|
4096
|
+
*/
|
|
4097
|
+
readonly kind?: ProviderKind;
|
|
4098
|
+
/**
|
|
4099
|
+
* Provider name surfaced in metric attributes (deepgram, openai, …).
|
|
4100
|
+
* Falls back to `label` when omitted.
|
|
4101
|
+
*/
|
|
4102
|
+
readonly provider?: string;
|
|
4103
|
+
/**
|
|
4104
|
+
* Fallback provider used if the primary throws. Accepts an instance OR a
|
|
4105
|
+
* ProviderFactory (so `deepgram.tts(...)` works directly). The fallback is
|
|
4106
|
+
* resolved lazily on first error.
|
|
4107
|
+
*/
|
|
4108
|
+
readonly fallback?: T | ProviderFactory<T>;
|
|
4109
|
+
/**
|
|
4110
|
+
* Methods to instrument. By default the wrapper instruments every method
|
|
4111
|
+
* call. Pass an explicit list to limit overhead on hot paths.
|
|
4112
|
+
*/
|
|
4113
|
+
readonly methods?: readonly string[];
|
|
4114
|
+
}
|
|
4115
|
+
/**
|
|
4116
|
+
* Returns either the wrapped instance directly (when called with one) or a
|
|
4117
|
+
* ProviderFactory that produces the wrapped instance (when called with one of
|
|
4118
|
+
* those). This keeps the lazy import story intact: `wrap(deepgram.tts(...))`
|
|
4119
|
+
* is itself a factory.
|
|
4120
|
+
*/
|
|
4121
|
+
declare function wrap<T extends object>(target: T | ProviderFactory<T>, options?: WrapOptions<T>): T | ProviderFactory<T>;
|
|
4122
|
+
|
|
4123
|
+
declare const deepgram: {
|
|
4124
|
+
stt(options?: {
|
|
4125
|
+
model?: string;
|
|
4126
|
+
language?: string;
|
|
4127
|
+
apiKey?: string;
|
|
4128
|
+
baseURL?: string;
|
|
4129
|
+
}): ProviderFactory<STTProvider>;
|
|
4130
|
+
tts(options?: {
|
|
4131
|
+
model?: string;
|
|
4132
|
+
apiKey?: string;
|
|
4133
|
+
baseURL?: string;
|
|
4134
|
+
}): ProviderFactory<TTSProvider>;
|
|
4135
|
+
};
|
|
4136
|
+
declare const openai: {
|
|
4137
|
+
llm(options?: {
|
|
4138
|
+
model?: string;
|
|
4139
|
+
apiKey?: string;
|
|
4140
|
+
baseURL?: string;
|
|
4141
|
+
}): ProviderFactory<LLMProvider>;
|
|
4142
|
+
tts(options?: {
|
|
4143
|
+
model?: string;
|
|
4144
|
+
voice?: string;
|
|
4145
|
+
instructions?: string;
|
|
4146
|
+
apiKey?: string;
|
|
4147
|
+
baseURL?: string;
|
|
4148
|
+
}): ProviderFactory<TTSProvider>;
|
|
4149
|
+
realtime(options?: {
|
|
4150
|
+
model?: string;
|
|
4151
|
+
voice?: string;
|
|
4152
|
+
apiKey?: string;
|
|
4153
|
+
baseURL?: string;
|
|
4154
|
+
}): ProviderFactory<RealtimeProvider>;
|
|
4155
|
+
};
|
|
4156
|
+
declare const cartesia: {
|
|
4157
|
+
tts(options?: {
|
|
4158
|
+
voice?: string;
|
|
4159
|
+
model?: string;
|
|
4160
|
+
apiKey?: string;
|
|
4161
|
+
baseURL?: string;
|
|
4162
|
+
}): ProviderFactory<TTSProvider>;
|
|
4163
|
+
stt(options?: {
|
|
4164
|
+
model?: string;
|
|
4165
|
+
language?: string;
|
|
4166
|
+
apiKey?: string;
|
|
4167
|
+
baseURL?: string;
|
|
4168
|
+
}): ProviderFactory<STTProvider>;
|
|
4169
|
+
};
|
|
4170
|
+
declare const elevenlabs: {
|
|
4171
|
+
tts(options?: {
|
|
4172
|
+
voice?: string;
|
|
4173
|
+
model?: string;
|
|
4174
|
+
apiKey?: string;
|
|
4175
|
+
baseURL?: string;
|
|
4176
|
+
}): ProviderFactory<TTSProvider>;
|
|
4177
|
+
};
|
|
4178
|
+
declare const assemblyai: {
|
|
4179
|
+
stt(options?: {
|
|
4180
|
+
language?: string;
|
|
4181
|
+
apiKey?: string;
|
|
4182
|
+
baseURL?: string;
|
|
4183
|
+
}): ProviderFactory<STTProvider>;
|
|
4184
|
+
};
|
|
4185
|
+
declare const google: {
|
|
4186
|
+
llm(options?: {
|
|
4187
|
+
model?: string;
|
|
4188
|
+
apiKey?: string;
|
|
4189
|
+
baseURL?: string;
|
|
4190
|
+
}): ProviderFactory<LLMProvider>;
|
|
4191
|
+
realtime(options?: {
|
|
4192
|
+
model?: string;
|
|
4193
|
+
voice?: string;
|
|
4194
|
+
apiKey?: string;
|
|
4195
|
+
baseURL?: string;
|
|
4196
|
+
}): ProviderFactory<RealtimeProvider>;
|
|
4197
|
+
};
|
|
4198
|
+
declare const silero: {
|
|
4199
|
+
vad(): ProviderFactory<VADProvider>;
|
|
4200
|
+
};
|
|
4201
|
+
declare const livekitTurn: {
|
|
4202
|
+
english(): ProviderFactory<TurnDetectorProvider>;
|
|
4203
|
+
multilingual(): ProviderFactory<TurnDetectorProvider>;
|
|
4204
|
+
};
|
|
4205
|
+
|
|
4206
|
+
/**
|
|
4207
|
+
* Turn the persisted `agents.process_schema` (or a freshly-compiled flow) into a
|
|
4208
|
+
* ProcessDefinition. The completion gate drives the `required` flags so the
|
|
4209
|
+
* SDK's `all-required-captured` strategy matches the flow's gate exactly; the
|
|
4210
|
+
* JSON-safe string `pattern` is rehydrated to a RegExp for the SDK validators.
|
|
4211
|
+
*/
|
|
4212
|
+
declare function processSchemaToDefinition(schema: ProcessSchemaDTO): ProcessDefinition;
|
|
4213
|
+
/** The `defineAgent` slice a flow-runtime worker spreads to boot a built flow. */
|
|
4214
|
+
interface CompiledAgentParts {
|
|
4215
|
+
readonly prompt: string;
|
|
4216
|
+
readonly process: ProcessDefinition;
|
|
4217
|
+
readonly triggers?: Record<string, TriggerDefinition>;
|
|
4218
|
+
readonly handoff?: HandoffConfig;
|
|
4219
|
+
readonly memory?: MemoryConfig;
|
|
4220
|
+
readonly tools?: Record<string, ToolDefinition>;
|
|
4221
|
+
}
|
|
4222
|
+
/**
|
|
4223
|
+
* Turn a compiled ProcessSchemaDTO into the full set of `defineAgent` parts a
|
|
4224
|
+
* flow-runtime worker boots a visually-built conversation with: the composed
|
|
4225
|
+
* prompt (say/confirm fragments), the process (slots + gate), the deterministic
|
|
4226
|
+
* triggers (rails), and the handoff destination. Pure.
|
|
4227
|
+
*/
|
|
4228
|
+
declare function processSchemaToAgentParts(schema: ProcessSchemaDTO, opts?: {
|
|
4229
|
+
readonly basePrompt?: string;
|
|
4230
|
+
readonly graphNodeIds?: ReadonlySet<string>;
|
|
4231
|
+
}): CompiledAgentParts;
|
|
4232
|
+
|
|
4233
|
+
/**
|
|
4234
|
+
* Extend this to author a tool with the least ceremony. `run` receives the
|
|
4235
|
+
* parsed input and the live AgentContext; whatever it returns is handed back to
|
|
4236
|
+
* the LLM. Override `capability` to share an Action-Guard capability across
|
|
4237
|
+
* tools (defaults to `tool.<name>`).
|
|
4238
|
+
*/
|
|
4239
|
+
declare abstract class BaseTool<I = unknown, R = unknown> {
|
|
4240
|
+
abstract readonly name: string;
|
|
4241
|
+
abstract readonly description: string;
|
|
4242
|
+
abstract readonly input: ToolInputShape$1;
|
|
4243
|
+
readonly capability?: string;
|
|
4244
|
+
abstract run(input: I, ctx: AgentContext): Promise<R> | R;
|
|
4245
|
+
/** The ToolDefinition the runtime consumes. */
|
|
4246
|
+
toDefinition(): ToolDefinition$1<I, R>;
|
|
4247
|
+
/** `{ [name]: definition }` — spread straight into `defineAgent({ tools })`. */
|
|
4248
|
+
register(): Record<string, ToolDefinition$1>;
|
|
4249
|
+
}
|
|
4250
|
+
/** Functional equivalent of BaseTool — same output, no class. */
|
|
4251
|
+
declare function defineTool<I = unknown, R = unknown>(spec: {
|
|
4252
|
+
readonly name: string;
|
|
4253
|
+
readonly description: string;
|
|
4254
|
+
readonly input: ToolInputShape$1;
|
|
4255
|
+
readonly capability?: string;
|
|
4256
|
+
readonly run: (input: I, ctx: AgentContext) => Promise<R> | R;
|
|
4257
|
+
}): Record<string, ToolDefinition$1>;
|
|
4258
|
+
interface HttpToolResult {
|
|
4259
|
+
readonly ok: boolean;
|
|
4260
|
+
readonly status: number;
|
|
4261
|
+
readonly data: unknown;
|
|
4262
|
+
}
|
|
4263
|
+
interface HttpToolSpec {
|
|
4264
|
+
readonly name: string;
|
|
4265
|
+
readonly description: string;
|
|
4266
|
+
readonly input: ToolInputShape$1;
|
|
4267
|
+
/** May contain `{field}` placeholders filled from input (URL-encoded). */
|
|
4268
|
+
readonly url: string;
|
|
4269
|
+
readonly method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
4270
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
4271
|
+
/** Build the request body from input (non-GET). Defaults to the input bag. */
|
|
4272
|
+
readonly body?: (input: Record<string, unknown>) => unknown;
|
|
4273
|
+
readonly capability?: string;
|
|
4274
|
+
/** Injectable for tests. Defaults to global fetch. */
|
|
4275
|
+
readonly fetchImpl?: typeof fetch;
|
|
4276
|
+
}
|
|
4277
|
+
/**
|
|
4278
|
+
* A config-only HTTP tool — no subclass needed for the common "call an API"
|
|
4279
|
+
* case. Use this for public/no-auth endpoints (e.g. an n8n webhook). Secrets
|
|
4280
|
+
* should NOT be inlined here; vault-backed credentials resolve server-side.
|
|
4281
|
+
*/
|
|
4282
|
+
declare function httpTool(spec: HttpToolSpec): Record<string, ToolDefinition$1>;
|
|
4283
|
+
|
|
4284
|
+
interface CreateClientOptions {
|
|
4285
|
+
readonly apiKey?: string;
|
|
4286
|
+
readonly baseUrl?: string;
|
|
4287
|
+
readonly fetch?: typeof fetch;
|
|
4288
|
+
readonly maxRetries?: number;
|
|
4289
|
+
readonly initialBackoffMs?: number;
|
|
4290
|
+
readonly userAgent?: string;
|
|
4291
|
+
readonly scheduler?: AgentsClientOptions['scheduler'];
|
|
4292
|
+
readonly attachSignalHandlers?: boolean;
|
|
4293
|
+
}
|
|
4294
|
+
interface VoiceLayerClient {
|
|
4295
|
+
readonly agents: AgentsClient;
|
|
4296
|
+
readonly memory: MemoryClient;
|
|
4297
|
+
readonly calls: CallsClient;
|
|
4298
|
+
readonly forms: FormsClient;
|
|
4299
|
+
readonly email: EmailClient;
|
|
4300
|
+
readonly plans: PlansClient;
|
|
4301
|
+
readonly connections: ConnectionsClient;
|
|
4302
|
+
}
|
|
4303
|
+
declare function createClient(options?: CreateClientOptions): VoiceLayerClient;
|
|
4304
|
+
|
|
4305
|
+
export { Agent, type AgentConfig, type AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AppendTranscriptInput, type AudioProfile, type AudioSurface, BaseTool, type CallAttributeValue, type CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, type ConnectorInstance, ConsultationPolicy, type CreateClientOptions, type CreatedFormSession, type DefaultMetadata, type DtmfEvent, type DtmfHandler, EmailClient, type SendEmailInput as EmailSendInput, type EndCallInfo, type EndCallPolicy, type EndCallTrigger, type EnsureCallByRoomInput, type FloorControlConfig, type CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type InferProcessData, type LLMProvider, type MemoryConfig, type MemoryHandle, type MemoryScope, type ModelConfig, type Participant, ParticipantId, type ParticipantKind, type ParticipantSet, type ParticipantsConfig, type PipelineConfig, PlansClient, type ProcessBackendAck, type ProcessDefinition, type ProcessField, type ProcessFieldType, type ProcessSnapshot, 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 RespondOptions, type Room, type RouteEntry, type RoutingRule, type RoutingSnapshot, type STTProvider, type SayOptions, type SecurityConfig, type SendDtmfOptions, type SentEmail, type ShorthandPrimitive, type SpeechConfig, type SpeechTarget, type SyncCallStateInput, type TTSProvider, type ToolDefinition, type ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TtsVoiceConfig, type TurnDetectorProvider, type VADProvider, VoiceLayerAuthError, type VoiceLayerClient, VoiceLayerError, VoiceLayerHttpError, VoiceLayerNetworkError, VoiceLayerValidationError, type WebhookApi, type WebhookConfig, type WrapOptions, applyPronunciations, assemblyai, asyncProbe, cartesia, collectDefaultMetadata, createClient, createNoOpLLM, deepgram, defineAgent, defineFlowRuntime, defineProcess, defineTool, dtmfCodeToDigit, dtmfDigitToCode, duck, elevenlabs, envProbe, formTools, google, httpTool, livekitTurn, mergeMetadata, mute, openai, ParticipantId as participantId, passthrough, processSchemaToAgentParts, processSchemaToDefinition, puppetEnvAvailable, resendEmailTool, runProbes, silero, startPuppetControl, transform, urlProbe, webhook, wrap };
|