@gradientlabs/client 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.
@@ -0,0 +1,1507 @@
1
+ /** A subset of the global `fetch` signature, so callers can inject their own. */
2
+ type FetchLike = (input: string, init: {
3
+ method: string;
4
+ headers: Record<string, string>;
5
+ body?: string;
6
+ signal?: AbortSignal;
7
+ }) => Promise<{
8
+ status: number;
9
+ text(): Promise<string>;
10
+ }>;
11
+ interface HttpClientConfig {
12
+ baseUrl: string;
13
+ apiKey: string;
14
+ fetch: FetchLike;
15
+ timeoutMs?: number;
16
+ }
17
+ interface RequestOptions {
18
+ /** Query parameters. Undefined/null values are omitted. */
19
+ query?: Record<string, string | number | boolean | undefined | null>;
20
+ /** JSON request body. Serialised with JSON.stringify. */
21
+ body?: unknown;
22
+ /** Caller-supplied cancellation signal. */
23
+ signal?: AbortSignal;
24
+ }
25
+ /**
26
+ * Thin wrapper around `fetch` that handles auth, headers, JSON
27
+ * (de)serialisation, cancellation, and error mapping. It never retries — retry
28
+ * policy is left entirely to the caller.
29
+ */
30
+ declare class HttpClient {
31
+ private readonly config;
32
+ constructor(config: HttpClientConfig);
33
+ request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
34
+ private buildUrl;
35
+ private buildSignal;
36
+ }
37
+
38
+ /** Per-request options accepted by every client method. */
39
+ interface RequestConfig {
40
+ /** Cancellation signal, the Node equivalent of Go's context.Context. */
41
+ signal?: AbortSignal;
42
+ }
43
+
44
+ declare const ArticleStatus: {
45
+ readonly Draft: "draft";
46
+ readonly Published: "published";
47
+ readonly Deleted: "deleted";
48
+ readonly Excluded: "excluded";
49
+ readonly Unknown: "unknown";
50
+ };
51
+ type ArticleStatus = (typeof ArticleStatus)[keyof typeof ArticleStatus] | (string & {});
52
+ declare const ArticleUsageStatus: {
53
+ readonly On: "on";
54
+ readonly Off: "off";
55
+ };
56
+ type ArticleUsageStatus = (typeof ArticleUsageStatus)[keyof typeof ArticleUsageStatus] | (string & {});
57
+ declare const ArticleVisibility: {
58
+ readonly Public: "public";
59
+ readonly Users: "users";
60
+ readonly Internal: "internal";
61
+ readonly Unknown: "unknown";
62
+ };
63
+ type ArticleVisibility = (typeof ArticleVisibility)[keyof typeof ArticleVisibility] | (string & {});
64
+ declare const AttachmentType: {
65
+ readonly Image: "image";
66
+ readonly File: "file";
67
+ };
68
+ type AttachmentType = (typeof AttachmentType)[keyof typeof AttachmentType] | (string & {});
69
+ declare const Channel: {
70
+ readonly Web: "web";
71
+ readonly Email: "email";
72
+ readonly Voice: "voice";
73
+ readonly Unmapped: "unmapped";
74
+ };
75
+ type Channel = (typeof Channel)[keyof typeof Channel] | (string & {});
76
+ declare const CustomerSource: {
77
+ readonly Dixa: "dixa";
78
+ readonly Intercom: "intercom";
79
+ readonly Freshchat: "freshchat";
80
+ readonly Freshdesk: "freshdesk";
81
+ readonly PublicApi: "public-api";
82
+ readonly ChatSdk: "chat-sdk";
83
+ readonly Salesforce: "salesforce";
84
+ readonly Zendesk: "zendesk";
85
+ readonly Livekit: "livekit";
86
+ readonly Twilio: "twilio";
87
+ readonly Talkdesk: "talkdesk";
88
+ readonly IntercomVoice: "intercom-voice";
89
+ readonly Livechat: "livechat";
90
+ readonly WebApp: "web-app";
91
+ readonly Gmail: "gmail";
92
+ readonly File: "file";
93
+ };
94
+ type CustomerSource = (typeof CustomerSource)[keyof typeof CustomerSource] | (string & {});
95
+ declare const ParticipantType: {
96
+ readonly Customer: "Customer";
97
+ readonly Agent: "Agent";
98
+ readonly AIAgent: "AI Agent";
99
+ readonly Bot: "Bot";
100
+ };
101
+ type ParticipantType = (typeof ParticipantType)[keyof typeof ParticipantType] | (string & {});
102
+ declare const ConversationEventType: {
103
+ readonly Assigned: "assigned";
104
+ readonly Cancelled: "cancelled";
105
+ readonly Finished: "finished";
106
+ readonly Resumed: "resumed";
107
+ readonly InternalNote: "internal-note";
108
+ readonly Message: "message";
109
+ readonly Delivered: "delivered";
110
+ readonly Read: "read";
111
+ readonly Rated: "rated";
112
+ readonly Started: "started";
113
+ readonly Typing: "typing";
114
+ readonly AsyncToolResult: "async-tool-result";
115
+ };
116
+ type ConversationEventType = (typeof ConversationEventType)[keyof typeof ConversationEventType] | (string & {});
117
+ declare const ProcedureStatus: {
118
+ readonly Unsaved: "unsaved";
119
+ readonly Draft: "draft";
120
+ readonly Live: "live";
121
+ readonly Archived: "archived";
122
+ };
123
+ type ProcedureStatus = (typeof ProcedureStatus)[keyof typeof ProcedureStatus] | (string & {});
124
+ declare const NoteStatus: {
125
+ readonly Draft: "draft";
126
+ readonly Live: "live";
127
+ readonly Deleted: "deleted";
128
+ };
129
+ type NoteStatus = (typeof NoteStatus)[keyof typeof NoteStatus] | (string & {});
130
+ declare const BackOfficeTaskStatus: {
131
+ readonly Pending: "pending";
132
+ readonly InProgress: "in-progress";
133
+ readonly Completed: "completed";
134
+ readonly Failed: "failed";
135
+ readonly HandedOff: "handed-off";
136
+ };
137
+ type BackOfficeTaskStatus = (typeof BackOfficeTaskStatus)[keyof typeof BackOfficeTaskStatus] | (string & {});
138
+ declare const BackOfficeTaskResultType: {
139
+ readonly Custom: "custom";
140
+ };
141
+ type BackOfficeTaskResultType = (typeof BackOfficeTaskResultType)[keyof typeof BackOfficeTaskResultType] | (string & {});
142
+ declare const AttributeCardinality: {
143
+ readonly One: "one";
144
+ readonly Many: "many";
145
+ };
146
+ type AttributeCardinality = (typeof AttributeCardinality)[keyof typeof AttributeCardinality] | (string & {});
147
+ declare const AttributeType: {
148
+ readonly String: "string";
149
+ readonly Date: "date";
150
+ readonly Timestamp: "timestamp";
151
+ readonly Boolean: "boolean";
152
+ readonly Number: "number";
153
+ readonly Array: "array";
154
+ readonly Complex: "complex";
155
+ };
156
+ type AttributeType = (typeof AttributeType)[keyof typeof AttributeType] | (string & {});
157
+ declare const ResourceSourceRefreshStrategy: {
158
+ readonly Dynamic: "dynamic";
159
+ readonly Static: "static";
160
+ };
161
+ type ResourceSourceRefreshStrategy = (typeof ResourceSourceRefreshStrategy)[keyof typeof ResourceSourceRefreshStrategy] | (string & {});
162
+ declare const ResourceSourceScope: {
163
+ readonly Global: "global";
164
+ readonly Local: "local";
165
+ };
166
+ type ResourceSourceScope = (typeof ResourceSourceScope)[keyof typeof ResourceSourceScope] | (string & {});
167
+ declare const ResourceSourceType: {
168
+ readonly Http: "http";
169
+ readonly Internal: "internal";
170
+ readonly Webhook: "webhook";
171
+ };
172
+ type ResourceSourceType = (typeof ResourceSourceType)[keyof typeof ResourceSourceType] | (string & {});
173
+ declare const SchemaUpdateStrategy: {
174
+ readonly Replace: "replace";
175
+ readonly Merge: "merge";
176
+ };
177
+ type SchemaUpdateStrategy = (typeof SchemaUpdateStrategy)[keyof typeof SchemaUpdateStrategy] | (string & {});
178
+ declare const ResourceTypeRefreshStrategy: {
179
+ readonly Dynamic: "dynamic";
180
+ readonly Static: "static";
181
+ };
182
+ type ResourceTypeRefreshStrategy = (typeof ResourceTypeRefreshStrategy)[keyof typeof ResourceTypeRefreshStrategy] | (string & {});
183
+ declare const ResourceTypeScope: {
184
+ readonly Global: "global";
185
+ readonly Local: "local";
186
+ };
187
+ type ResourceTypeScope = (typeof ResourceTypeScope)[keyof typeof ResourceTypeScope] | (string & {});
188
+ declare const SupportPlatform: {
189
+ readonly Dixa: "dixa";
190
+ readonly Freshchat: "freshchat";
191
+ readonly Freshdesk: "freshdesk";
192
+ readonly Gmail: "gmail";
193
+ readonly Intercom: "intercom";
194
+ readonly Livechat: "livechat";
195
+ readonly PublicApi: "public-api";
196
+ readonly ChatSdk: "chat-sdk";
197
+ readonly Salesforce: "salesforce";
198
+ readonly Zendesk: "zendesk";
199
+ readonly Livekit: "livekit";
200
+ readonly Twilio: "twilio";
201
+ readonly Talkdesk: "talkdesk";
202
+ readonly IntercomVoice: "intercom-voice";
203
+ readonly ConversationSynthesizor: "conversation-synthesizor";
204
+ readonly WebApp: "web-app";
205
+ };
206
+ type SupportPlatform = (typeof SupportPlatform)[keyof typeof SupportPlatform] | (string & {});
207
+ declare const BodyEncoding: {
208
+ readonly Json: "application/json";
209
+ readonly Form: "application/x-www-form-urlencoded";
210
+ };
211
+ type BodyEncoding = (typeof BodyEncoding)[keyof typeof BodyEncoding] | (string & {});
212
+ declare const ParameterSource: {
213
+ readonly Llm: "llm";
214
+ readonly Literal: "literal";
215
+ readonly Resource: "resource";
216
+ };
217
+ type ParameterSource = (typeof ParameterSource)[keyof typeof ParameterSource] | (string & {});
218
+ declare const ParameterType: {
219
+ readonly String: "string";
220
+ readonly StringArray: "string_array";
221
+ readonly Integer: "integer";
222
+ readonly Float: "float";
223
+ readonly Boolean: "boolean";
224
+ readonly Date: "date";
225
+ readonly Timestamp: "timestamp";
226
+ readonly Duration: "duration";
227
+ };
228
+ type ParameterType = (typeof ParameterType)[keyof typeof ParameterType] | (string & {});
229
+
230
+ interface UpsertArticleParams {
231
+ /** External identifier the company uses for this article. */
232
+ id: string;
233
+ author_id: string;
234
+ title: string;
235
+ description: string;
236
+ body: string;
237
+ visibility: ArticleVisibility;
238
+ /** External identifier of the topic this article belongs to. */
239
+ topic_id: string;
240
+ status: ArticleStatus;
241
+ /** Additional meta-data about the article. */
242
+ data: Record<string, unknown>;
243
+ created: string;
244
+ last_edited: string;
245
+ public_url: string;
246
+ }
247
+ interface SetArticleUsageStatusParams {
248
+ usage_status: ArticleUsageStatus;
249
+ }
250
+ /** An article topic. */
251
+ interface Topic {
252
+ Source: string;
253
+ ExternalID: string;
254
+ Name: string;
255
+ Description: string;
256
+ Visibility: ArticleVisibility;
257
+ ParentExternalID: string;
258
+ Created: string;
259
+ LastEdited: string;
260
+ LastSeen: string;
261
+ /** Base64-encoded raw representation of the topic from the support platform. */
262
+ Data: string;
263
+ PublicURL: string;
264
+ }
265
+ interface ListTopicsParams {
266
+ /** Which platform's topics to read. Defaults to "public-api". */
267
+ support_platform?: string;
268
+ }
269
+ interface ReadTopicParams {
270
+ /** Which platform's topic to read. Defaults to "public-api". */
271
+ support_platform?: string;
272
+ }
273
+ interface UpsertTopicParams {
274
+ /** External identifier the company uses for this topic. */
275
+ id: string;
276
+ /** External identifier of this topic's parent topic. */
277
+ parent_id: string;
278
+ name: string;
279
+ description: string;
280
+ visibility: ArticleVisibility;
281
+ status: ArticleStatus;
282
+ data: Record<string, unknown>;
283
+ created: string;
284
+ last_edited: string;
285
+ public_url: string;
286
+ }
287
+
288
+ /**
289
+ * Article management endpoints. Requires a Management API key.
290
+ */
291
+ declare class Articles {
292
+ private readonly http;
293
+ constructor(http: HttpClient);
294
+ /** Creates or updates a help article. */
295
+ upsert(params: UpsertArticleParams, config?: RequestConfig): Promise<void>;
296
+ /** Updates whether the AI agent can use an article or not. */
297
+ setUsageStatus(id: string, params: SetArticleUsageStatusParams, config?: RequestConfig): Promise<void>;
298
+ /** Marks an article as deleted. */
299
+ delete(id: string, config?: RequestConfig): Promise<void>;
300
+ }
301
+
302
+ /** An attachment uploaded with a back-office task. URL and base64 are mutually exclusive. */
303
+ interface BackOfficeTaskAttachmentInput {
304
+ file_name: string;
305
+ url?: string;
306
+ base_64_contents?: string;
307
+ }
308
+ /** An attachment as returned on a back-office task. */
309
+ interface BackOfficeTaskAttachment {
310
+ idempotency_key: string;
311
+ file_name: string;
312
+ external_url?: string;
313
+ raw_contents?: string;
314
+ }
315
+ /** The result of a back-office task, validated against the procedure's result schema. */
316
+ interface BackOfficeTaskResult {
317
+ result_type: BackOfficeTaskResultType;
318
+ custom?: Record<string, unknown>;
319
+ }
320
+ /** A back-office (Tier 2) task processed by a configurable agent. */
321
+ interface BackOfficeTask {
322
+ id: string;
323
+ agent_id: string;
324
+ input: Record<string, unknown>;
325
+ created: string;
326
+ updated?: string;
327
+ status?: BackOfficeTaskStatus;
328
+ result?: BackOfficeTaskResult;
329
+ metadata?: Record<string, string>;
330
+ attachments?: BackOfficeTaskAttachment[];
331
+ completed?: string;
332
+ failed?: string;
333
+ failure_reasons?: string[];
334
+ handed_off?: string;
335
+ hand_off_reason?: string;
336
+ }
337
+ interface CreateBackOfficeTaskParams {
338
+ /** Unique external identifier for the task. */
339
+ id: string;
340
+ /** Input data for the task; shape depends on the task type. */
341
+ input: Record<string, unknown>;
342
+ /** Identifies the configurable back-office agent to run the task against. Required. */
343
+ agent_id: string;
344
+ /** Optional free-format metadata the agent can read. */
345
+ metadata?: Record<string, string>;
346
+ attachments?: BackOfficeTaskAttachmentInput[];
347
+ /** Optional creation timestamp (RFC3339). Defaults to now. */
348
+ created?: string;
349
+ }
350
+
351
+ /**
352
+ * Back-office task endpoints. Requires an Integration API key.
353
+ */
354
+ declare class BackOfficeTasks {
355
+ private readonly http;
356
+ constructor(http: HttpClient);
357
+ /** Creates a new back-office task. */
358
+ create(params: CreateBackOfficeTaskParams, config?: RequestConfig): Promise<BackOfficeTask>;
359
+ /** Retrieves detailed information about a back-office task. */
360
+ get(id: string, config?: RequestConfig): Promise<BackOfficeTask>;
361
+ }
362
+
363
+ /** Basic information about a user, e.g. the author of a procedure. */
364
+ interface UserDetails {
365
+ email: string;
366
+ }
367
+ /** A file or media item attached to a conversation message. */
368
+ interface Attachment {
369
+ type: AttachmentType;
370
+ /** Original file name including extension. */
371
+ file_name: string;
372
+ /** Publicly accessible URL where the attachment can be downloaded. */
373
+ url: string;
374
+ /** Optional short summary of what the attachment is. */
375
+ summary?: string;
376
+ /** Optional full textual extract of the attachment's contents. */
377
+ description?: string;
378
+ }
379
+
380
+ /** Agent-derived metadata about how a conversation was processed. */
381
+ interface AgentMetadata {
382
+ intent: string;
383
+ intent_handoff_target: string;
384
+ handoff_reason: string;
385
+ handoff_note: string;
386
+ }
387
+ /** A series of messages between a customer, human agent, and the AI agent. */
388
+ interface Conversation {
389
+ id: string;
390
+ customer_id: string;
391
+ channel: Channel;
392
+ created: string;
393
+ updated: string;
394
+ status: string;
395
+ /** Whether an AI agent is currently actively handling this conversation. */
396
+ agent_is_active: boolean;
397
+ latest_intent: string;
398
+ latest_handoff_target: string;
399
+ latest_agent_metadata?: AgentMetadata;
400
+ }
401
+ /** A single message within a conversation. */
402
+ interface Message {
403
+ id: string;
404
+ body: string;
405
+ participant_id: string;
406
+ participant_type: ParticipantType;
407
+ subject?: string;
408
+ attachments?: Attachment[];
409
+ created?: string;
410
+ conversation_token?: string;
411
+ }
412
+ interface StartConversationParams {
413
+ /** Unique external identifier for the conversation. */
414
+ id: string;
415
+ /** Unique external identifier for the customer. */
416
+ customer_id: string;
417
+ channel: Channel;
418
+ /** Optional identifier of the participant the conversation is assigned to. */
419
+ assignee_id?: string;
420
+ /** Set to "AI Agent" to assign the conversation to the Gradient Labs AI. */
421
+ assignee_type?: ParticipantType;
422
+ /** Arbitrary metadata attached to the conversation; echoed back in webhooks. */
423
+ metadata?: unknown;
424
+ /** Optional creation timestamp (RFC3339). Defaults to now. */
425
+ created?: string;
426
+ /** Structured context data the AI agent can use, keyed by resource type. */
427
+ resources?: Record<string, unknown>;
428
+ /** Optional traffic group to scope which procedures the conversation can access. */
429
+ traffic_group_id?: string;
430
+ /** Raw sensitive token echoed back in future tool/webhook calls. */
431
+ conversation_token?: string;
432
+ }
433
+ interface AddMessageParams {
434
+ id: string;
435
+ body?: string;
436
+ participant_id: string;
437
+ participant_type: ParticipantType;
438
+ subject?: string;
439
+ attachments?: Attachment[];
440
+ created?: string;
441
+ conversation_token?: string;
442
+ }
443
+ interface AssignConversationParams {
444
+ assignee_type: ParticipantType;
445
+ assignee_id?: string;
446
+ reason?: string;
447
+ timestamp?: string;
448
+ }
449
+ interface ResumeConversationParams {
450
+ assignee_type: ParticipantType;
451
+ resources?: Record<string, unknown>;
452
+ assignee_id?: string;
453
+ reason?: string;
454
+ timestamp?: string;
455
+ }
456
+ interface CancelConversationParams {
457
+ reason?: string;
458
+ timestamp?: string;
459
+ }
460
+ interface FinishConversationParams {
461
+ reason?: string;
462
+ timestamp?: string;
463
+ }
464
+ interface ConversationEventParams {
465
+ type: ConversationEventType;
466
+ participant_id: string;
467
+ participant_type: ParticipantType;
468
+ body?: string;
469
+ message_id?: string;
470
+ idempotency_key?: string;
471
+ timestamp?: string;
472
+ }
473
+ interface RateConversationParams {
474
+ type: string;
475
+ value: number;
476
+ max_value: number;
477
+ min_value: number;
478
+ comments?: string;
479
+ timestamp?: string;
480
+ }
481
+ interface ReturnAsyncToolResultParams {
482
+ async_tool_execution_id: string;
483
+ /** Required by the API: the JSON result of the async tool execution. */
484
+ payload: Record<string, unknown>;
485
+ timestamp?: string;
486
+ }
487
+ interface ReadConversationParams {
488
+ /** Which platform's conversation to read. Defaults to "public-api". */
489
+ support_platform?: string;
490
+ }
491
+ interface StartOutboundConversationParams {
492
+ customer_id: string;
493
+ customer_source: CustomerSource;
494
+ procedure_id: string;
495
+ channel?: Channel;
496
+ support_platform?: string;
497
+ body?: string;
498
+ subject?: string;
499
+ resources?: Record<string, unknown>;
500
+ }
501
+ interface OutboundConversation {
502
+ conversation_id: string;
503
+ }
504
+
505
+ /**
506
+ * Conversation endpoints. Requires an Integration API key.
507
+ */
508
+ declare class Conversations {
509
+ private readonly http;
510
+ constructor(http: HttpClient);
511
+ /** Begins a conversation. */
512
+ start(params: StartConversationParams, config?: RequestConfig): Promise<Conversation>;
513
+ /** Retrieves a conversation, including the latest AI agent metadata. */
514
+ get(id: string, params?: ReadConversationParams, config?: RequestConfig): Promise<Conversation>;
515
+ /**
516
+ * Retrieves a conversation.
517
+ *
518
+ * @deprecated Use {@link Conversations.get} instead, which reads from the
519
+ * canonical `/read` endpoint.
520
+ */
521
+ getDeprecated(id: string, config?: RequestConfig): Promise<Conversation>;
522
+ /** Adds a new message to an existing conversation. */
523
+ addMessage(id: string, params: AddMessageParams, config?: RequestConfig): Promise<Message>;
524
+ /** Transfers responsibility for handling a conversation to a participant. */
525
+ assign(id: string, params: AssignConversationParams, config?: RequestConfig): Promise<void>;
526
+ /** Logs an event against the conversation (e.g. typing, delivered, read). */
527
+ addEvent(id: string, params: ConversationEventParams, config?: RequestConfig): Promise<void>;
528
+ /** Adds the result of a customer survey (e.g. CSAT) to a conversation. */
529
+ rate(id: string, params: RateConversationParams, config?: RequestConfig): Promise<void>;
530
+ /** Cancels a conversation (e.g. because a human has taken it over). */
531
+ cancel(id: string, params?: CancelConversationParams, config?: RequestConfig): Promise<void>;
532
+ /** Finishes a conversation that has reached a natural end state. */
533
+ finish(id: string, params?: FinishConversationParams, config?: RequestConfig): Promise<void>;
534
+ /** Re-opens a conversation that was previously finished. */
535
+ resume(id: string, params: ResumeConversationParams, config?: RequestConfig): Promise<void>;
536
+ /** Returns the result of an async tool execution. */
537
+ returnAsyncToolResult(id: string, params: ReturnAsyncToolResultParams, config?: RequestConfig): Promise<void>;
538
+ }
539
+
540
+ /** A hand-off target (team, agent, or queue) a conversation can be routed to. */
541
+ interface HandOffTarget {
542
+ id: string;
543
+ name: string;
544
+ }
545
+ interface UpsertHandOffTargetParams {
546
+ id: string;
547
+ name: string;
548
+ }
549
+ interface DeleteHandOffTargetParams {
550
+ id: string;
551
+ }
552
+ interface GetDefaultHandOffTargetParams {
553
+ /** The conversation channel to get the default for. */
554
+ channel: string;
555
+ }
556
+ interface SetDefaultHandOffTargetParams {
557
+ /** Target ID to set as default. Empty string clears the default. */
558
+ id: string;
559
+ channel: string;
560
+ }
561
+
562
+ /**
563
+ * Hand-off target management endpoints. Requires a Management API key.
564
+ */
565
+ declare class HandOffTargets {
566
+ private readonly http;
567
+ constructor(http: HttpClient);
568
+ /** Lists the available hand-off targets. */
569
+ list(config?: RequestConfig): Promise<HandOffTarget[]>;
570
+ /** Creates or updates a hand-off target. */
571
+ upsert(params: UpsertHandOffTargetParams, config?: RequestConfig): Promise<void>;
572
+ /** Deletes a hand-off target. */
573
+ delete(params: DeleteHandOffTargetParams, config?: RequestConfig): Promise<void>;
574
+ /** Gets the current default hand-off target for a channel. Returns "" if unset. */
575
+ getDefault(params: GetDefaultHandOffTargetParams, config?: RequestConfig): Promise<string>;
576
+ /** Sets the default hand-off target for a channel. */
577
+ setDefault(params: SetDefaultHandOffTargetParams, config?: RequestConfig): Promise<void>;
578
+ }
579
+
580
+ /** The IP addresses Gradient Labs uses, in CIDR format. */
581
+ interface IpAddresses {
582
+ /** Addresses the public API is served from. */
583
+ api: string[];
584
+ /** Addresses outbound (egress) requests originate from. */
585
+ egress: string[];
586
+ }
587
+ /**
588
+ * IP address endpoints. Requires a Management API key.
589
+ */
590
+ declare class IpAddressesResource {
591
+ private readonly http;
592
+ constructor(http: HttpClient);
593
+ /** Returns the list of IP addresses Gradient Labs uses, in CIDR format. */
594
+ list(config?: RequestConfig): Promise<IpAddresses>;
595
+ }
596
+
597
+ /** A note that provides the AI agent with time-bound context. */
598
+ interface Note {
599
+ /** Gradient Labs' internal ID for this note. */
600
+ gradient_labs_id: string;
601
+ /** The company's external ID for this note. */
602
+ id: string;
603
+ title: string;
604
+ body: string;
605
+ url: string;
606
+ valid_from: string;
607
+ valid_to: string;
608
+ last_modified_by: string;
609
+ created: string;
610
+ updated: string;
611
+ status: NoteStatus;
612
+ }
613
+ interface CreateNoteParams {
614
+ /** External identifier the company uses for this note. */
615
+ id: string;
616
+ title: string;
617
+ /** Main contents of the note. Mutually exclusive with webpage_url. */
618
+ body: string;
619
+ /** Webpage to use as the note body. Mutually exclusive with body. */
620
+ webpage_url: string;
621
+ /** When the note becomes relevant. */
622
+ start_time: string;
623
+ /** When the note is no longer relevant. */
624
+ end_time: string;
625
+ }
626
+ interface UpdateNoteParams {
627
+ title: string;
628
+ body: string;
629
+ webpage_url: string;
630
+ start_time: string;
631
+ end_time: string;
632
+ }
633
+ interface SetNoteStatusParams {
634
+ status: NoteStatus;
635
+ }
636
+
637
+ /**
638
+ * Note management endpoints. Requires a Management API key.
639
+ */
640
+ declare class Notes {
641
+ private readonly http;
642
+ constructor(http: HttpClient);
643
+ /** Creates a new note. */
644
+ create(params: CreateNoteParams, config?: RequestConfig): Promise<Note>;
645
+ /** Updates an existing note's contents. */
646
+ update(id: string, params: UpdateNoteParams, config?: RequestConfig): Promise<Note>;
647
+ /** Updates a note's status. */
648
+ setStatus(id: string, params: SetNoteStatusParams, config?: RequestConfig): Promise<void>;
649
+ /** Marks a note as deleted. */
650
+ delete(id: string, config?: RequestConfig): Promise<void>;
651
+ }
652
+
653
+ /**
654
+ * Outbound conversation endpoints. Requires an Integration API key.
655
+ */
656
+ declare class OutboundConversations {
657
+ private readonly http;
658
+ constructor(http: HttpClient);
659
+ /** Creates and starts a new outbound conversation initiated by the AI agent. */
660
+ start(params: StartOutboundConversationParams, config?: RequestConfig): Promise<OutboundConversation>;
661
+ }
662
+
663
+ /**
664
+ * Cursor-based pagination metadata returned by list endpoints. Cursors are
665
+ * opaque strings; pass `next`/`prev` back via the `after`/`before` parameters
666
+ * to page through results.
667
+ */
668
+ interface PageInfo {
669
+ next?: string;
670
+ prev?: string;
671
+ }
672
+ /** A single page of a paginated list response. */
673
+ interface Page<T> {
674
+ data: T[];
675
+ pageInfo: PageInfo;
676
+ }
677
+
678
+ /** An AI agent procedure that defines how the agent should handle conversations. */
679
+ interface Procedure {
680
+ id: string;
681
+ name: string;
682
+ description: string;
683
+ status: ProcedureStatus;
684
+ author: UserDetails;
685
+ created: string;
686
+ updated: string;
687
+ has_daily_limit: boolean;
688
+ max_daily_conversations: number;
689
+ }
690
+ /** Configuration limiting a gated procedure version. */
691
+ interface GatedConfig {
692
+ MaxDailyConversations: number;
693
+ }
694
+ /** A specific saved version of a procedure. */
695
+ interface ProcedureVersion {
696
+ Name: string;
697
+ Description: string;
698
+ Version: number;
699
+ Author: string;
700
+ Created: string;
701
+ Gated: boolean;
702
+ /** Present only when the version is gated. */
703
+ GatedConfig?: GatedConfig;
704
+ Live: boolean;
705
+ }
706
+ interface ListProceduresParams {
707
+ /** Opaque pagination cursor from a previous response. */
708
+ cursor?: string;
709
+ /** Filter by status, e.g. "live" or "draft". */
710
+ status?: ProcedureStatus;
711
+ }
712
+ interface SetProcedureLimitParams {
713
+ has_daily_limit?: boolean;
714
+ max_daily_conversations?: number;
715
+ }
716
+ interface SetGatedVersionParams {
717
+ max_daily_conversations: number;
718
+ /** Replace an existing gated version if one exists. */
719
+ replace: boolean;
720
+ }
721
+
722
+ /**
723
+ * Procedure management endpoints. Requires a Management API key.
724
+ */
725
+ declare class Procedures {
726
+ private readonly http;
727
+ constructor(http: HttpClient);
728
+ /** Retrieves one page of procedures. */
729
+ list(params?: ListProceduresParams, config?: RequestConfig): Promise<Page<Procedure>>;
730
+ /** Iterates over all procedures, transparently following pagination cursors. */
731
+ listAll(params?: Omit<ListProceduresParams, "cursor">, config?: RequestConfig): AsyncGenerator<Procedure, void, undefined>;
732
+ /** Retrieves a specific procedure by ID. */
733
+ get(id: string, config?: RequestConfig): Promise<Procedure>;
734
+ /** Configures daily usage limits for a procedure. Returns the updated procedure. */
735
+ setLimit(id: string, params: SetProcedureLimitParams, config?: RequestConfig): Promise<Procedure>;
736
+ /** Lists the non-ephemeral versions of a procedure. */
737
+ listVersions(id: string, config?: RequestConfig): Promise<ProcedureVersion[]>;
738
+ /** Promotes a procedure version to be the live (production) version. */
739
+ setLiveVersion(id: string, version: number, config?: RequestConfig): Promise<void>;
740
+ /** Removes a procedure version from being the live revision. */
741
+ unsetLiveVersion(id: string, version: number, config?: RequestConfig): Promise<void>;
742
+ /** Marks a procedure version as gated for A/B testing. */
743
+ setGatedVersion(id: string, version: number, params: SetGatedVersionParams, config?: RequestConfig): Promise<void>;
744
+ /** Removes the gated marking from a procedure version. */
745
+ unsetGatedVersion(id: string, version: number, config?: RequestConfig): Promise<void>;
746
+ }
747
+
748
+ /** A single data field within a resource schema. */
749
+ interface Attribute {
750
+ path: string;
751
+ type: AttributeType;
752
+ cardinality: AttributeCardinality;
753
+ description: string;
754
+ is_root: boolean;
755
+ name: string;
756
+ }
757
+ /** The structure of data provided by a resource source or type. */
758
+ interface Schema {
759
+ /** The complete JSON schema definition in its original format. */
760
+ raw: Record<string, unknown>;
761
+ attributes?: Attribute[];
762
+ }
763
+ /** HTTP body configuration for a resource source. */
764
+ interface ResourceSourceHttpBodyDefinition {
765
+ encoding: string;
766
+ json_template?: string;
767
+ form_field_templates?: Record<string, string>;
768
+ }
769
+ /** HTTP configuration for a resource source. */
770
+ interface ResourceSourceHttpConfig {
771
+ method: string;
772
+ url_template: string;
773
+ header_templates?: Record<string, string>;
774
+ body?: ResourceSourceHttpBodyDefinition;
775
+ }
776
+ /** Webhook configuration for a resource source. */
777
+ interface ResourceSourceWebhookConfig {
778
+ name: string;
779
+ }
780
+ /** A data source that provides structured information to AI agents. */
781
+ interface ResourceSource {
782
+ id: string;
783
+ display_name: string;
784
+ description: string;
785
+ source_type: ResourceSourceType;
786
+ available_refresh_strategies: ResourceSourceRefreshStrategy[];
787
+ available_scopes: ResourceSourceScope[];
788
+ created: string;
789
+ updated: string;
790
+ attribute_descriptions?: Record<string, string>;
791
+ schema?: Schema;
792
+ http_config?: ResourceSourceHttpConfig;
793
+ webhook_config?: ResourceSourceWebhookConfig;
794
+ }
795
+ interface CreateResourceSourceParams {
796
+ display_name: string;
797
+ source_type: ResourceSourceType;
798
+ description?: string;
799
+ attribute_descriptions?: Record<string, string>;
800
+ http_config?: ResourceSourceHttpConfig;
801
+ webhook_config?: ResourceSourceWebhookConfig;
802
+ }
803
+ interface UpdateResourceSourceParams {
804
+ display_name?: string;
805
+ description?: string;
806
+ source_type?: ResourceSourceType;
807
+ attribute_descriptions?: Record<string, string>;
808
+ schema?: Schema;
809
+ http_config?: ResourceSourceHttpConfig;
810
+ webhook_config?: ResourceSourceWebhookConfig;
811
+ }
812
+ interface UpdateSchemaByExamplesParams {
813
+ /** Resource payload examples to infer the schema from. */
814
+ examples: Record<string, unknown>[];
815
+ schema_update_strategy?: SchemaUpdateStrategy;
816
+ }
817
+ /** How a resource type connects to and retrieves data from a source. */
818
+ interface SourceConfig {
819
+ source_id: string;
820
+ /** Which attributes to include. Empty means all. */
821
+ attributes: string[];
822
+ /** Cache duration, e.g. "1h", "30m", "never". */
823
+ cache: string;
824
+ }
825
+ /** A specific type of structured data accessible by AI agents. */
826
+ interface ResourceType {
827
+ id: string;
828
+ display_name: string;
829
+ description: string;
830
+ scope: ResourceTypeScope;
831
+ refresh_strategy: ResourceTypeRefreshStrategy;
832
+ is_enabled: boolean;
833
+ created: string;
834
+ updated: string;
835
+ schema?: Schema;
836
+ source_config?: SourceConfig;
837
+ }
838
+ interface CreateResourceTypeParams {
839
+ display_name: string;
840
+ scope: ResourceTypeScope;
841
+ refresh_strategy: ResourceTypeRefreshStrategy;
842
+ description?: string;
843
+ is_enabled?: boolean;
844
+ source_config?: SourceConfig;
845
+ }
846
+ interface UpdateResourceTypeParams {
847
+ display_name?: string;
848
+ description?: string;
849
+ scope?: ResourceTypeScope;
850
+ refresh_strategy?: ResourceTypeRefreshStrategy;
851
+ is_enabled?: boolean;
852
+ source_config?: SourceConfig;
853
+ }
854
+
855
+ /**
856
+ * Resource source management endpoints. Requires a Management API key.
857
+ */
858
+ declare class ResourceSources {
859
+ private readonly http;
860
+ constructor(http: HttpClient);
861
+ /** Lists all resource sources accessible to the company. */
862
+ list(config?: RequestConfig): Promise<ResourceSource[]>;
863
+ /** Creates a new resource source. */
864
+ create(params: CreateResourceSourceParams, config?: RequestConfig): Promise<ResourceSource>;
865
+ /** Retrieves a specific resource source by ID. */
866
+ get(id: string, config?: RequestConfig): Promise<ResourceSource>;
867
+ /** Updates an existing resource source. */
868
+ update(id: string, params: UpdateResourceSourceParams, config?: RequestConfig): Promise<ResourceSource>;
869
+ /** Deletes a resource source. */
870
+ delete(id: string, config?: RequestConfig): Promise<void>;
871
+ /** Modifies the source schema based on the provided payload examples. */
872
+ updateSchemaByExamples(id: string, params: UpdateSchemaByExamplesParams, config?: RequestConfig): Promise<ResourceSource>;
873
+ }
874
+
875
+ /**
876
+ * Resource type management endpoints. Requires a Management API key.
877
+ */
878
+ declare class ResourceTypes {
879
+ private readonly http;
880
+ constructor(http: HttpClient);
881
+ /** Lists all resource types accessible to the company. */
882
+ list(config?: RequestConfig): Promise<ResourceType[]>;
883
+ /** Creates a new resource type. */
884
+ create(params: CreateResourceTypeParams, config?: RequestConfig): Promise<ResourceType>;
885
+ /** Retrieves a specific resource type by ID. */
886
+ get(id: string, config?: RequestConfig): Promise<ResourceType>;
887
+ /** Updates an existing resource type. */
888
+ update(id: string, params: UpdateResourceTypeParams, config?: RequestConfig): Promise<ResourceType>;
889
+ /** Deletes a resource type. */
890
+ delete(id: string, config?: RequestConfig): Promise<void>;
891
+ }
892
+
893
+ /** Request body configuration for an HTTP tool. */
894
+ interface HttpBodyDefinition {
895
+ encoding: BodyEncoding;
896
+ /** JSON body template when encoding is "application/json". */
897
+ json_template?: string;
898
+ /** Form fields when encoding is form-encoded. */
899
+ form_field_templates?: Record<string, string>;
900
+ }
901
+ /** Configures a tool to make direct HTTP requests to external APIs. */
902
+ interface HttpDefinition {
903
+ method: string;
904
+ /** URL with `${params.name}` substitution. */
905
+ url_template: string;
906
+ header_templates?: Record<string, string>;
907
+ body?: HttpBodyDefinition;
908
+ }
909
+ /** Configures a tool to call a webhook. */
910
+ interface ToolWebhookConfiguration {
911
+ name: string;
912
+ }
913
+ /** Configures a tool to execute via a Temporal workflow. */
914
+ interface WorkflowConfiguration {
915
+ workflow_type: string;
916
+ task_queue: string;
917
+ }
918
+ /** Configures a tool to execute via a Model Context Protocol server. */
919
+ interface McpConfiguration {
920
+ server_id: string;
921
+ external_tool_name: string;
922
+ }
923
+ /** A tool configuration embedded within another tool (e.g. async start/cancel). */
924
+ interface ChildTool {
925
+ http?: HttpDefinition;
926
+ webhook?: ToolWebhookConfiguration;
927
+ workflow?: WorkflowConfiguration;
928
+ }
929
+ /**
930
+ * Configures a tool for long-running asynchronous operations.
931
+ *
932
+ * `timeout` is a duration in nanoseconds (the API's native representation).
933
+ */
934
+ interface AsyncDefinition {
935
+ start_execution_tool: ChildTool;
936
+ /** Maximum duration to wait, in nanoseconds. */
937
+ timeout: number;
938
+ cancel_execution_tool?: ChildTool;
939
+ }
940
+ /** A predefined choice for a tool parameter. */
941
+ interface ParameterOption {
942
+ value: string;
943
+ text: string;
944
+ }
945
+ /** An input parameter a tool accepts when invoked. */
946
+ interface ToolParameter {
947
+ name: string;
948
+ description: string;
949
+ type: ParameterType;
950
+ allowed_sources: ParameterSource[];
951
+ /** If nil, defaults to true (required). */
952
+ required?: boolean;
953
+ options?: ParameterOption[];
954
+ }
955
+ /** A group of parameters that become active for a discriminator value. */
956
+ interface ToolParameterSet {
957
+ discriminator_parameter_name: string;
958
+ discriminator_value: string;
959
+ parameters: ToolParameter[];
960
+ }
961
+ /** A custom tool the AI agent can use during conversations. */
962
+ interface Tool {
963
+ id: string;
964
+ name: string;
965
+ description: string;
966
+ parameters: ToolParameter[];
967
+ parameter_sets?: ToolParameterSet[];
968
+ draft?: boolean;
969
+ http?: HttpDefinition;
970
+ webhook?: ToolWebhookConfiguration;
971
+ async?: AsyncDefinition;
972
+ mcp?: McpConfiguration;
973
+ }
974
+ interface CreateToolParams {
975
+ id: string;
976
+ name: string;
977
+ description: string;
978
+ parameters: ToolParameter[];
979
+ parameter_sets?: ToolParameterSet[];
980
+ draft?: boolean;
981
+ http?: HttpDefinition;
982
+ webhook?: ToolWebhookConfiguration;
983
+ async?: AsyncDefinition;
984
+ mcp?: McpConfiguration;
985
+ }
986
+ interface UpdateToolParams {
987
+ description: string;
988
+ parameters: ToolParameter[];
989
+ http?: HttpDefinition;
990
+ webhook?: ToolWebhookConfiguration;
991
+ async?: AsyncDefinition;
992
+ }
993
+ interface ReadToolParams {
994
+ /** Read a specific tool version. */
995
+ version?: number;
996
+ }
997
+ /** A name/value argument passed to a tool execution. */
998
+ interface ToolArgument {
999
+ name: string;
1000
+ value: string;
1001
+ }
1002
+ interface ExecuteToolParams {
1003
+ arguments: ToolArgument[];
1004
+ /** Optional conversation-scoped token, if the tool requires one. */
1005
+ token?: string;
1006
+ }
1007
+ interface ToolExecutionResult {
1008
+ id: string;
1009
+ /** JSON result of the execution, if it succeeded. */
1010
+ result?: Record<string, unknown>;
1011
+ /** Error that occurred during execution, if it failed. */
1012
+ error?: string;
1013
+ }
1014
+
1015
+ /** HTTP mechanism for refreshing a secret's value. */
1016
+ interface RefreshMechanismHttp {
1017
+ request_definition: HttpDefinition;
1018
+ /** Name of the parameter in the (JSON) response body. */
1019
+ response_param_name: string;
1020
+ }
1021
+ /** A configured secret. The value itself is never returned. */
1022
+ interface Secret {
1023
+ name: string;
1024
+ created: string;
1025
+ updated: string;
1026
+ expiry?: string;
1027
+ refresh_mechanism_http?: RefreshMechanismHttp;
1028
+ }
1029
+ interface WriteSecretParams {
1030
+ value: string;
1031
+ expiry?: string;
1032
+ refresh_mechanism_http?: RefreshMechanismHttp;
1033
+ }
1034
+
1035
+ /**
1036
+ * Secret management endpoints. Requires a Management API key.
1037
+ */
1038
+ declare class Secrets {
1039
+ private readonly http;
1040
+ constructor(http: HttpClient);
1041
+ /** Lists the company's configured secrets. */
1042
+ list(config?: RequestConfig): Promise<Secret[]>;
1043
+ /** Creates or updates a secret. */
1044
+ write(name: string, params: WriteSecretParams, config?: RequestConfig): Promise<Secret>;
1045
+ /** Revokes a secret so it can no longer be used. */
1046
+ revoke(name: string, config?: RequestConfig): Promise<void>;
1047
+ }
1048
+
1049
+ /** A term the agent should avoid and its replacement, optionally resource-scoped. */
1050
+ interface TerminologySubstitution {
1051
+ id: string;
1052
+ blocked: string;
1053
+ blocked_description: string;
1054
+ replacement: string;
1055
+ resource_type_id: string;
1056
+ resource_attribute_json_path: string;
1057
+ resource_value_to_match: string;
1058
+ created: string;
1059
+ updated: string;
1060
+ }
1061
+ interface CreateTerminologySubstitutionParams {
1062
+ blocked: string;
1063
+ blocked_description: string;
1064
+ replacement: string;
1065
+ resource_type_id?: string;
1066
+ resource_attribute_json_path?: string;
1067
+ resource_value_to_match?: string;
1068
+ }
1069
+ interface UpdateTerminologySubstitutionParams {
1070
+ blocked: string;
1071
+ blocked_description: string;
1072
+ replacement: string;
1073
+ resource_type_id?: string;
1074
+ resource_attribute_json_path?: string;
1075
+ resource_value_to_match?: string;
1076
+ }
1077
+
1078
+ /**
1079
+ * Terminology substitution management endpoints. Requires a Management API key.
1080
+ */
1081
+ declare class TerminologySubstitutions {
1082
+ private readonly http;
1083
+ constructor(http: HttpClient);
1084
+ /** Returns all terminology substitutions configured for the organization. */
1085
+ list(config?: RequestConfig): Promise<TerminologySubstitution[]>;
1086
+ /** Creates a new terminology substitution. */
1087
+ create(params: CreateTerminologySubstitutionParams, config?: RequestConfig): Promise<TerminologySubstitution>;
1088
+ /** Returns a single terminology substitution by ID. */
1089
+ get(id: string, config?: RequestConfig): Promise<TerminologySubstitution>;
1090
+ /** Updates an existing terminology substitution. */
1091
+ update(id: string, params: UpdateTerminologySubstitutionParams, config?: RequestConfig): Promise<TerminologySubstitution>;
1092
+ /** Deletes a terminology substitution by ID. */
1093
+ delete(id: string, config?: RequestConfig): Promise<void>;
1094
+ }
1095
+
1096
+ /**
1097
+ * Tool management endpoints. Requires a Management API key.
1098
+ */
1099
+ declare class Tools {
1100
+ private readonly http;
1101
+ constructor(http: HttpClient);
1102
+ /** Returns all tools created by the company. */
1103
+ list(config?: RequestConfig): Promise<Tool[]>;
1104
+ /** Creates a new custom tool. */
1105
+ create(params: CreateToolParams, config?: RequestConfig): Promise<Tool>;
1106
+ /** Reads a tool by ID and optional version. */
1107
+ get(id: string, params?: ReadToolParams, config?: RequestConfig): Promise<Tool>;
1108
+ /** Creates a new revision of a tool. The name and type cannot be changed. */
1109
+ update(id: string, params: UpdateToolParams, config?: RequestConfig): Promise<Tool>;
1110
+ /** Deletes a tool. */
1111
+ delete(id: string, config?: RequestConfig): Promise<void>;
1112
+ /** Executes a tool, enabling you to test it without an actual conversation. */
1113
+ execute(id: string, params: ExecuteToolParams, config?: RequestConfig): Promise<ToolExecutionResult>;
1114
+ }
1115
+
1116
+ /**
1117
+ * Article topic management endpoints. Requires a Management API key.
1118
+ */
1119
+ declare class Topics {
1120
+ private readonly http;
1121
+ constructor(http: HttpClient);
1122
+ /** Lists the company's topics, optionally filtered by support platform. */
1123
+ list(params?: ListTopicsParams, config?: RequestConfig): Promise<Topic[]>;
1124
+ /** Reads a single article topic. */
1125
+ get(id: string, params?: ReadTopicParams, config?: RequestConfig): Promise<Topic>;
1126
+ /** Creates or updates an article topic. */
1127
+ upsert(params: UpsertTopicParams, config?: RequestConfig): Promise<void>;
1128
+ }
1129
+
1130
+ /** An assigned or excluded target within a traffic group. */
1131
+ interface TrafficGroupTarget {
1132
+ target_type: string;
1133
+ target_id: string;
1134
+ }
1135
+ /** A traffic group scoping which procedures conversations can access. */
1136
+ interface TrafficGroup {
1137
+ id: string;
1138
+ name: string;
1139
+ targets: TrafficGroupTarget[];
1140
+ excluded_targets: TrafficGroupTarget[];
1141
+ }
1142
+ interface CreateTrafficGroupParams {
1143
+ name: string;
1144
+ }
1145
+ interface UpdateTrafficGroupParams {
1146
+ name: string;
1147
+ }
1148
+ interface TrafficGroupTargetParams {
1149
+ /** Type of target, e.g. "procedure". */
1150
+ target_type: string;
1151
+ target_id: string;
1152
+ }
1153
+
1154
+ /**
1155
+ * Traffic group management endpoints. Requires a Management API key.
1156
+ */
1157
+ declare class TrafficGroups {
1158
+ private readonly http;
1159
+ constructor(http: HttpClient);
1160
+ /** Lists all traffic groups for the company. */
1161
+ list(config?: RequestConfig): Promise<TrafficGroup[]>;
1162
+ /** Creates a new traffic group. */
1163
+ create(params: CreateTrafficGroupParams, config?: RequestConfig): Promise<TrafficGroup>;
1164
+ /** Updates an existing traffic group. */
1165
+ update(id: string, params: UpdateTrafficGroupParams, config?: RequestConfig): Promise<TrafficGroup>;
1166
+ /** Deletes a traffic group and all associated targets. */
1167
+ delete(id: string, config?: RequestConfig): Promise<void>;
1168
+ /** Adds a target to a traffic group. */
1169
+ addTarget(id: string, params: TrafficGroupTargetParams, config?: RequestConfig): Promise<TrafficGroupTarget>;
1170
+ /** Removes a target from a traffic group. */
1171
+ removeTarget(id: string, targetId: string, config?: RequestConfig): Promise<void>;
1172
+ /** Excludes a target (e.g. a procedure) from a traffic group. */
1173
+ addExclusion(id: string, params: TrafficGroupTargetParams, config?: RequestConfig): Promise<TrafficGroupTarget>;
1174
+ /** Removes a target exclusion from a traffic group. */
1175
+ removeExclusion(id: string, targetId: string, config?: RequestConfig): Promise<void>;
1176
+ }
1177
+
1178
+ /** The most recent voice call context for a phone number. */
1179
+ interface VoiceCallContext {
1180
+ /** Timestamp (RFC3339) when the call was received by the AI voice agent. */
1181
+ started_at: string;
1182
+ summary?: string;
1183
+ transcript?: string;
1184
+ handoff_reason?: string;
1185
+ last_executed_procedure?: string;
1186
+ last_executed_procedure_url?: string;
1187
+ gradient_labs_url?: string;
1188
+ }
1189
+ interface ReadVoiceCallContextParams {
1190
+ /** Time window (seconds) to look back for recent call events. Default 60, min 5. */
1191
+ lookback_seconds?: number;
1192
+ /** Include large fields (full transcript and untruncated summary). */
1193
+ include_large_fields?: boolean;
1194
+ }
1195
+
1196
+ /**
1197
+ * Voice endpoints. Requires an Integration API key.
1198
+ */
1199
+ declare class Voice {
1200
+ private readonly http;
1201
+ constructor(http: HttpClient);
1202
+ /**
1203
+ * Retrieves the most recent call context for a given phone number. Throws an
1204
+ * {@link ApiError} with status 404 if there have been no recent call events.
1205
+ */
1206
+ getLatestCallContext(phoneNumber: string, params?: ReadVoiceCallContextParams, config?: RequestConfig): Promise<VoiceCallContext>;
1207
+ }
1208
+
1209
+ /**
1210
+ * Well-known error codes returned by the Gradient Labs API in the `code` field
1211
+ * of an error response. Callers can switch on {@link ApiError.code} rather than
1212
+ * comparing message strings.
1213
+ *
1214
+ * The union is intentionally open (`| (string & {})`) so that a future
1215
+ * server-side code never breaks a consumer at compile time.
1216
+ */
1217
+ declare const ErrorCode: {
1218
+ readonly NotFound: "not_found";
1219
+ readonly Unauthenticated: "unauthenticated";
1220
+ readonly PermissionDenied: "permission_denied";
1221
+ readonly InvalidArgument: "invalid_argument";
1222
+ readonly FailedPrecondition: "failed_precondition";
1223
+ readonly ResourceExhausted: "resource_exhausted";
1224
+ readonly AlreadyExists: "already_exists";
1225
+ readonly Unavailable: "unavailable";
1226
+ readonly DeadlineExceeded: "deadline_exceeded";
1227
+ readonly Internal: "internal";
1228
+ };
1229
+ type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode] | (string & {});
1230
+ /**
1231
+ * Base class for every error thrown by this client. Catch this to handle any
1232
+ * failure originating from the library.
1233
+ */
1234
+ declare class GradientLabsError extends Error {
1235
+ constructor(message: string, options?: {
1236
+ cause?: unknown;
1237
+ });
1238
+ }
1239
+ /**
1240
+ * Thrown when the client is misconfigured (e.g. a missing API key). These are
1241
+ * raised before any network request is made.
1242
+ */
1243
+ declare class ConfigurationError extends GradientLabsError {
1244
+ constructor(message: string);
1245
+ }
1246
+ /**
1247
+ * Thrown when the API returns a non-2xx response. It carries the HTTP status
1248
+ * code along with the parsed error envelope (`code`, `message`, `details`).
1249
+ */
1250
+ declare class ApiError extends GradientLabsError {
1251
+ /** HTTP status code of the response. */
1252
+ readonly statusCode: number;
1253
+ /** Machine-readable error code from the response envelope. */
1254
+ readonly code: ErrorCode;
1255
+ /** Arbitrary structured details returned with the error. */
1256
+ readonly details: Record<string, unknown>;
1257
+ constructor(args: {
1258
+ statusCode: number;
1259
+ code: ErrorCode;
1260
+ message: string;
1261
+ details?: Record<string, unknown>;
1262
+ });
1263
+ /**
1264
+ * The identifier that can be given to Gradient Labs technical support to
1265
+ * investigate an error, if present in the error details.
1266
+ */
1267
+ get traceId(): string | undefined;
1268
+ }
1269
+
1270
+ /** The set of webhook event types currently delivered by Gradient Labs. */
1271
+ declare const WebhookType: {
1272
+ readonly AgentMessage: "agent.message";
1273
+ readonly ConversationHandOff: "conversation.hand_off";
1274
+ readonly ConversationFinished: "conversation.finished";
1275
+ readonly ActionExecute: "action.execute";
1276
+ readonly ResourcePull: "resource.pull";
1277
+ readonly BackOfficeTaskComplete: "back-office-task.complete";
1278
+ readonly BackOfficeTaskHandOff: "back-office-task.hand-off";
1279
+ readonly BackOfficeTaskFail: "back-office-task.fail";
1280
+ };
1281
+ type WebhookType = (typeof WebhookType)[keyof typeof WebhookType];
1282
+ /**
1283
+ * The conversation an `agent.message`, `conversation.hand_off`, or
1284
+ * `conversation.finished` event relates to.
1285
+ */
1286
+ interface WebhookConversation {
1287
+ id: string;
1288
+ customer_id: string;
1289
+ }
1290
+ /**
1291
+ * The conversation an `action.execute` or `resource.pull` event relates to.
1292
+ * Present only when the action ran in a conversation context.
1293
+ */
1294
+ interface ActionWebhookConversation {
1295
+ id: string;
1296
+ customer_id: string;
1297
+ customer_source: CustomerSource;
1298
+ /** Metadata attached to the conversation when it was started. */
1299
+ metadata: unknown;
1300
+ }
1301
+ /**
1302
+ * The back-office task an `action.execute` or `resource.pull` event relates to.
1303
+ * Present only when the action ran in a back-office task context.
1304
+ */
1305
+ interface ActionWebhookBackOfficeTask {
1306
+ id: string;
1307
+ }
1308
+ interface AgentMessageEvent {
1309
+ conversation: WebhookConversation;
1310
+ body: string;
1311
+ total?: number;
1312
+ sequence?: number;
1313
+ intent?: string;
1314
+ /** Whether this is a holding response sent while the agent works. */
1315
+ is_holding?: boolean;
1316
+ /** External ID of the customer message this turn is responding to. */
1317
+ last_customer_message_id?: string;
1318
+ }
1319
+ interface ConversationHandOffEvent {
1320
+ conversation: WebhookConversation;
1321
+ target?: string;
1322
+ /** Coded reason the agent wants to hand off. */
1323
+ reason_code: string;
1324
+ /** Human-legible description of the reason code. */
1325
+ reason: string;
1326
+ note?: string;
1327
+ intent?: string;
1328
+ }
1329
+ interface ConversationFinishedEvent {
1330
+ conversation: WebhookConversation;
1331
+ reason_code?: string;
1332
+ intent?: string;
1333
+ }
1334
+ interface ActionExecuteEvent {
1335
+ action: string;
1336
+ /** Arguments to execute the action with. */
1337
+ params: unknown;
1338
+ /** Set when the action ran in a conversation context. */
1339
+ conversation?: ActionWebhookConversation;
1340
+ /** Set when the action ran in a back-office task context. */
1341
+ back_office_task?: ActionWebhookBackOfficeTask;
1342
+ }
1343
+ interface ResourcePullEvent {
1344
+ resource_type: string;
1345
+ /** Set when the pull ran in a conversation context. */
1346
+ conversation?: ActionWebhookConversation;
1347
+ /** Set when the pull ran in a back-office task context. */
1348
+ back_office_task?: ActionWebhookBackOfficeTask;
1349
+ }
1350
+ /**
1351
+ * The three back-office task events all carry the full task under a single
1352
+ * `back_office_task` key. The outcome (result / failure reasons / hand-off
1353
+ * reason) lives inside that task object.
1354
+ */
1355
+ interface BackOfficeTaskCompleteEvent {
1356
+ back_office_task: BackOfficeTask;
1357
+ }
1358
+ interface BackOfficeTaskHandOffEvent {
1359
+ back_office_task: BackOfficeTask;
1360
+ }
1361
+ interface BackOfficeTaskFailEvent {
1362
+ back_office_task: BackOfficeTask;
1363
+ }
1364
+ /** Fields common to every webhook envelope. */
1365
+ interface WebhookBase {
1366
+ id: string;
1367
+ sequence_number: number;
1368
+ /** RFC3339 timestamp of when the event was generated. */
1369
+ timestamp: string;
1370
+ }
1371
+ /**
1372
+ * A parsed, verified webhook event. Discriminate on `type` for exhaustive,
1373
+ * type-safe handling of the `data` payload.
1374
+ */
1375
+ type WebhookEvent = (WebhookBase & {
1376
+ type: "agent.message";
1377
+ data: AgentMessageEvent;
1378
+ }) | (WebhookBase & {
1379
+ type: "conversation.hand_off";
1380
+ data: ConversationHandOffEvent;
1381
+ }) | (WebhookBase & {
1382
+ type: "conversation.finished";
1383
+ data: ConversationFinishedEvent;
1384
+ }) | (WebhookBase & {
1385
+ type: "action.execute";
1386
+ data: ActionExecuteEvent;
1387
+ }) | (WebhookBase & {
1388
+ type: "resource.pull";
1389
+ data: ResourcePullEvent;
1390
+ }) | (WebhookBase & {
1391
+ type: "back-office-task.complete";
1392
+ data: BackOfficeTaskCompleteEvent;
1393
+ }) | (WebhookBase & {
1394
+ type: "back-office-task.hand-off";
1395
+ data: BackOfficeTaskHandOffEvent;
1396
+ }) | (WebhookBase & {
1397
+ type: "back-office-task.fail";
1398
+ data: BackOfficeTaskFailEvent;
1399
+ });
1400
+ /** The result of parsing a webhook request. */
1401
+ interface ParsedWebhook {
1402
+ event: WebhookEvent;
1403
+ /**
1404
+ * The optional sensitive conversation token from the `X-GradientLabs-Token`
1405
+ * header, if present.
1406
+ */
1407
+ token?: string;
1408
+ }
1409
+
1410
+ /** Thrown when a webhook's signature or timestamp cannot be verified. Respond 401. */
1411
+ declare class InvalidWebhookSignatureError extends GradientLabsError {
1412
+ constructor(message?: string);
1413
+ }
1414
+ /** Thrown when a webhook of an unrecognised type is received. Log it and respond 200. */
1415
+ declare class UnknownWebhookTypeError extends GradientLabsError {
1416
+ readonly type: string;
1417
+ constructor(type: string);
1418
+ }
1419
+ /** A source of request headers: a Fetch `Headers`, a Node headers object, or a plain map. */
1420
+ type HeadersLike = {
1421
+ get(name: string): string | null;
1422
+ } | Record<string, string | string[] | undefined>;
1423
+ /** The raw request body. Signatures are computed over the exact bytes received. */
1424
+ type WebhookBody = string | Uint8Array;
1425
+ interface WebhookVerifierConfig {
1426
+ /** The webhook signing key configured for your workspace. */
1427
+ signingKey: string;
1428
+ /** Maximum accepted age of a webhook, in milliseconds. Defaults to 5 minutes. */
1429
+ leewayMs?: number;
1430
+ /** Injectable clock for testing. Defaults to Date.now. */
1431
+ now?: () => number;
1432
+ }
1433
+ /**
1434
+ * Verifies the authenticity of requests to your webhook endpoint using the
1435
+ * `X-GradientLabs-Signature` header (format `t=<unix_ts>,v1=<hex>`).
1436
+ */
1437
+ declare class WebhookVerifier {
1438
+ private readonly signingKey;
1439
+ private readonly leewayMs;
1440
+ private readonly now;
1441
+ constructor(config: WebhookVerifierConfig);
1442
+ /**
1443
+ * Verifies a webhook's signature and timestamp. Throws
1444
+ * {@link InvalidWebhookSignatureError} if verification fails.
1445
+ */
1446
+ verify(args: {
1447
+ body: WebhookBody;
1448
+ signature: string | null | undefined;
1449
+ }): void;
1450
+ /**
1451
+ * Verifies a webhook request, then parses it into a typed event. Returns the
1452
+ * event along with the optional `X-GradientLabs-Token` passthrough.
1453
+ *
1454
+ * Verification always happens before the event type is inspected.
1455
+ */
1456
+ parse(args: {
1457
+ body: WebhookBody;
1458
+ headers: HeadersLike;
1459
+ }): ParsedWebhook;
1460
+ private computeSignature;
1461
+ }
1462
+
1463
+ interface GradientLabsConfig {
1464
+ /** Your Gradient Labs API key. Required. */
1465
+ apiKey: string;
1466
+ /** Override the base URL. Defaults to https://api.gradient-labs.ai. */
1467
+ baseUrl?: string;
1468
+ /** The webhook signing key, required to verify incoming webhooks. */
1469
+ webhookSigningKey?: string;
1470
+ /** Maximum accepted age of a webhook, in milliseconds. Defaults to 5 minutes. */
1471
+ webhookLeewayMs?: number;
1472
+ /** Inject a custom fetch implementation (tests, proxies, instrumentation). */
1473
+ fetch?: FetchLike;
1474
+ /** Per-request timeout in milliseconds. No timeout by default. */
1475
+ timeoutMs?: number;
1476
+ }
1477
+ /**
1478
+ * The Gradient Labs API client. Construct one with your API key, then access
1479
+ * endpoints through the resource namespaces (e.g. `client.conversations.start`).
1480
+ */
1481
+ declare class GradientLabs {
1482
+ readonly conversations: Conversations;
1483
+ readonly outboundConversations: OutboundConversations;
1484
+ readonly backOfficeTasks: BackOfficeTasks;
1485
+ readonly voice: Voice;
1486
+ readonly tools: Tools;
1487
+ readonly articles: Articles;
1488
+ readonly topics: Topics;
1489
+ readonly procedures: Procedures;
1490
+ readonly handOffTargets: HandOffTargets;
1491
+ readonly resourceSources: ResourceSources;
1492
+ readonly resourceTypes: ResourceTypes;
1493
+ readonly secrets: Secrets;
1494
+ readonly notes: Notes;
1495
+ readonly terminologySubstitutions: TerminologySubstitutions;
1496
+ readonly trafficGroups: TrafficGroups;
1497
+ readonly ipAddresses: IpAddressesResource;
1498
+ private readonly webhookVerifier?;
1499
+ constructor(config: GradientLabsConfig);
1500
+ /**
1501
+ * The webhook verifier. Throws {@link ConfigurationError} if the client was
1502
+ * created without a `webhookSigningKey`.
1503
+ */
1504
+ get webhooks(): WebhookVerifier;
1505
+ }
1506
+
1507
+ export { type ActionExecuteEvent, type ActionWebhookBackOfficeTask, type ActionWebhookConversation, type AddMessageParams, type AgentMessageEvent, type AgentMetadata, ApiError, ArticleStatus, ArticleUsageStatus, ArticleVisibility, Articles, type AssignConversationParams, type AsyncDefinition, type Attachment, AttachmentType, type Attribute, AttributeCardinality, AttributeType, type BackOfficeTask, type BackOfficeTaskAttachment, type BackOfficeTaskAttachmentInput, type BackOfficeTaskCompleteEvent, type BackOfficeTaskFailEvent, type BackOfficeTaskHandOffEvent, type BackOfficeTaskResult, BackOfficeTaskResultType, BackOfficeTaskStatus, BackOfficeTasks, BodyEncoding, type CancelConversationParams, Channel, type ChildTool, ConfigurationError, type Conversation, type ConversationEventParams, ConversationEventType, type ConversationFinishedEvent, type ConversationHandOffEvent, Conversations, type CreateBackOfficeTaskParams, type CreateNoteParams, type CreateResourceSourceParams, type CreateResourceTypeParams, type CreateTerminologySubstitutionParams, type CreateToolParams, type CreateTrafficGroupParams, CustomerSource, type DeleteHandOffTargetParams, ErrorCode, type ExecuteToolParams, type FetchLike, type FinishConversationParams, type GatedConfig, type GetDefaultHandOffTargetParams, GradientLabs, type GradientLabsConfig, GradientLabsError, type HandOffTarget, HandOffTargets, type HeadersLike, type HttpBodyDefinition, type HttpDefinition, InvalidWebhookSignatureError, type IpAddresses, IpAddressesResource, type ListProceduresParams, type ListTopicsParams, type McpConfiguration, type Message, type Note, NoteStatus, Notes, type OutboundConversation, OutboundConversations, type Page, type PageInfo, type ParameterOption, ParameterSource, ParameterType, type ParsedWebhook, ParticipantType, type Procedure, ProcedureStatus, type ProcedureVersion, Procedures, type RateConversationParams, type ReadConversationParams, type ReadToolParams, type ReadTopicParams, type ReadVoiceCallContextParams, type RefreshMechanismHttp, type RequestConfig, type ResourcePullEvent, type ResourceSource, type ResourceSourceHttpBodyDefinition, type ResourceSourceHttpConfig, ResourceSourceRefreshStrategy, ResourceSourceScope, ResourceSourceType, type ResourceSourceWebhookConfig, ResourceSources, type ResourceType, ResourceTypeRefreshStrategy, ResourceTypeScope, ResourceTypes, type ResumeConversationParams, type ReturnAsyncToolResultParams, type Schema, SchemaUpdateStrategy, type Secret, Secrets, type SetArticleUsageStatusParams, type SetDefaultHandOffTargetParams, type SetGatedVersionParams, type SetNoteStatusParams, type SetProcedureLimitParams, type SourceConfig, type StartConversationParams, type StartOutboundConversationParams, SupportPlatform, type TerminologySubstitution, TerminologySubstitutions, type Tool, type ToolArgument, type ToolExecutionResult, type ToolParameter, type ToolParameterSet, type ToolWebhookConfiguration, Tools, type Topic, Topics, type TrafficGroup, type TrafficGroupTarget, type TrafficGroupTargetParams, TrafficGroups, UnknownWebhookTypeError, type UpdateNoteParams, type UpdateResourceSourceParams, type UpdateResourceTypeParams, type UpdateSchemaByExamplesParams, type UpdateTerminologySubstitutionParams, type UpdateToolParams, type UpdateTrafficGroupParams, type UpsertArticleParams, type UpsertHandOffTargetParams, type UpsertTopicParams, type UserDetails, Voice, type VoiceCallContext, type WebhookBody, type WebhookConversation, type WebhookEvent, WebhookType, WebhookVerifier, type WebhookVerifierConfig, type WorkflowConfiguration, type WriteSecretParams };