@hirefinn/sdk 0.0.0-stage → 0.2.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +217 -2
  3. package/dist/cjs/approval.d.ts +12 -0
  4. package/dist/cjs/approval.js +19 -0
  5. package/dist/cjs/client.d.ts +30 -0
  6. package/dist/cjs/client.js +35 -0
  7. package/dist/cjs/core.d.ts +81 -0
  8. package/dist/cjs/core.js +300 -0
  9. package/dist/cjs/errors.d.ts +90 -0
  10. package/dist/cjs/errors.js +165 -0
  11. package/dist/cjs/generated/openapi.d.ts +10729 -0
  12. package/dist/cjs/generated/openapi.js +2 -0
  13. package/dist/cjs/index.d.ts +13 -0
  14. package/dist/cjs/index.js +55 -0
  15. package/dist/cjs/package.json +1 -0
  16. package/dist/cjs/pagination.d.ts +36 -0
  17. package/dist/cjs/pagination.js +124 -0
  18. package/dist/cjs/resources.d.ts +845 -0
  19. package/dist/cjs/resources.js +395 -0
  20. package/dist/cjs/types.d.ts +148 -0
  21. package/dist/cjs/types.js +2 -0
  22. package/dist/cjs/webhooks.d.ts +57 -0
  23. package/dist/cjs/webhooks.js +181 -0
  24. package/dist/esm/approval.d.ts +12 -0
  25. package/dist/esm/approval.js +16 -0
  26. package/dist/esm/client.d.ts +30 -0
  27. package/dist/esm/client.js +31 -0
  28. package/dist/esm/core.d.ts +81 -0
  29. package/dist/esm/core.js +294 -0
  30. package/dist/esm/errors.d.ts +90 -0
  31. package/dist/esm/errors.js +155 -0
  32. package/dist/esm/generated/openapi.d.ts +10729 -0
  33. package/dist/esm/generated/openapi.js +1 -0
  34. package/dist/esm/index.d.ts +13 -0
  35. package/dist/esm/index.js +8 -0
  36. package/dist/esm/package.json +1 -0
  37. package/dist/esm/pagination.d.ts +36 -0
  38. package/dist/esm/pagination.js +116 -0
  39. package/dist/esm/resources.d.ts +845 -0
  40. package/dist/esm/resources.js +377 -0
  41. package/dist/esm/types.d.ts +148 -0
  42. package/dist/esm/types.js +1 -0
  43. package/dist/esm/webhooks.d.ts +57 -0
  44. package/dist/esm/webhooks.js +140 -0
  45. package/package.json +53 -4
@@ -0,0 +1,845 @@
1
+ /**
2
+ * Resource classes: one typed method per operation in the spec, grouped the way the API reference groups them.
3
+ * Every method takes an optional last `options` argument (RequestOptions): idempotencyKey, org, version,
4
+ * maxRetries, timeoutMs, signal, headers.
5
+ */
6
+ import type { FinnCore } from './core.js';
7
+ import { Paginator, cursorStrategy } from './pagination.js';
8
+ import type { ApprovalHold, BodyOf, HttpMethod, Operation, PathsFor, QueryOf, RequestOptions, ResultOf, Schemas, paths } from './types.js';
9
+ type Q<P extends keyof paths, M extends HttpMethod> = QueryOf<Operation<P, M>>;
10
+ type B<P extends keyof paths, M extends HttpMethod> = BodyOf<Operation<P, M>>;
11
+ type R<P extends keyof paths, M extends HttpMethod> = ResultOf<P & string, M, Operation<P, M>>;
12
+ type Id = string;
13
+ interface Params {
14
+ path?: Record<string, string | number>;
15
+ query?: unknown;
16
+ body?: unknown;
17
+ }
18
+ declare abstract class Resource {
19
+ protected readonly core: FinnCore;
20
+ constructor(core: FinnCore);
21
+ protected do<M extends HttpMethod, P extends PathsFor<M>>(method: M, path: P, params?: Params, options?: RequestOptions): Promise<R<P, M>>;
22
+ protected pager<Item>(path: PathsFor<'get'>, strategy: ReturnType<typeof cursorStrategy<Item>>, query: unknown, pathParams?: Record<string, string>, options?: RequestOptions): Paginator<Item>;
23
+ }
24
+ export declare class Calls extends Resource {
25
+ /** Place an outbound call. Gets an automatic Idempotency-Key. May answer `pending_approval` (see isPendingApproval). */
26
+ create(body: B<'/calls', 'post'>, options?: RequestOptions): Promise<{
27
+ success: true;
28
+ data: import("./types.js").components["schemas"]["CallCreated"];
29
+ } | import("./types.js").PendingApproval>;
30
+ list(query?: Q<'/calls', 'get'>, options?: RequestOptions): Promise<{
31
+ success: true;
32
+ data: import("./types.js").components["schemas"]["CallSummary"][];
33
+ total: number;
34
+ limit: number;
35
+ offset: number;
36
+ }>;
37
+ /** Every call matching the filters, page by page. */
38
+ listAll(query?: Q<'/calls', 'get'>, options?: RequestOptions): Paginator<{
39
+ call_uuid: string;
40
+ finn_id?: string | null;
41
+ deployment_id?: string | null;
42
+ status?: string | null;
43
+ disconnect_reason?: string | null;
44
+ direction?: "inbound" | "outbound" | null;
45
+ from_number?: string | null;
46
+ to_number?: string | null;
47
+ duration_seconds?: number | null;
48
+ user_sentiment?: string | null;
49
+ call_successful?: boolean | null;
50
+ created_at?: string | null;
51
+ updated_at?: string | null;
52
+ }, unknown>;
53
+ retrieve(callUuid: Id, options?: RequestOptions): Promise<{
54
+ success: true;
55
+ data: import("./types.js").components["schemas"]["Call"];
56
+ }>;
57
+ }
58
+ export declare class Finns extends Resource {
59
+ list(query?: Q<'/finns', 'get'>, options?: RequestOptions): Promise<{
60
+ success: true;
61
+ data: import("./types.js").components["schemas"]["Finn"][];
62
+ limit: number;
63
+ offset: number;
64
+ }>;
65
+ listAll(query?: Q<'/finns', 'get'>, options?: RequestOptions): Paginator<{
66
+ id: string;
67
+ name: string;
68
+ status: string;
69
+ voice: string | null;
70
+ language: string | null;
71
+ language_group: string | null;
72
+ time_zone: string | null;
73
+ use_case: string | null;
74
+ identity_text: string | null;
75
+ style_guardrails: string | null;
76
+ response_guidelines: string | null;
77
+ begin_message: string | null;
78
+ system_prompt: string | null;
79
+ max_call_duration_minutes: number | null;
80
+ idle_reminder_message: string | null;
81
+ idle_reminder_after_seconds: number | null;
82
+ end_call_on_silence_seconds: number | null;
83
+ handoff_number: import("./types.js").components["schemas"]["HandoffNumber"] | null;
84
+ post_call_analysis: import("./types.js").components["schemas"]["PostCallAnalysisQuestion"][];
85
+ call_flow: import("./types.js").components["schemas"]["CallFlow"] | null;
86
+ created_at: string;
87
+ updated_at: string;
88
+ }, unknown>;
89
+ create(body: B<'/finns', 'post'>, options?: RequestOptions): Promise<{
90
+ success: true;
91
+ data: import("./types.js").components["schemas"]["Finn"];
92
+ }>;
93
+ retrieve(finnId: Id, options?: RequestOptions): Promise<{
94
+ success: true;
95
+ data: import("./types.js").components["schemas"]["Finn"];
96
+ }>;
97
+ update(finnId: Id, body: B<'/finns/{finn_id}', 'patch'>, options?: RequestOptions): Promise<{
98
+ success: true;
99
+ data: import("./types.js").components["schemas"]["Finn"];
100
+ }>;
101
+ delete(finnId: Id, options?: RequestOptions): Promise<{
102
+ success: true;
103
+ data: import("./types.js").components["schemas"]["DeletedFinn"];
104
+ }>;
105
+ listKnowledgeBase(finnId: Id, options?: RequestOptions): Promise<{
106
+ success: true;
107
+ data: import("./types.js").components["schemas"]["KnowledgeBaseDocument"][];
108
+ }>;
109
+ /** JSON body, or a FormData with the file for multipart upload. */
110
+ addKnowledgeBaseDocument(finnId: Id, body: B<'/finns/{finn_id}/knowledge_base', 'post'> | FormData, options?: RequestOptions): Promise<{
111
+ success: true;
112
+ data: import("./types.js").components["schemas"]["KnowledgeBaseDocument"];
113
+ }>;
114
+ postCallAnalysis(finnId: Id, query?: Q<'/finns/{finn_id}/post_call_analysis', 'get'>, options?: RequestOptions): Promise<{
115
+ success: true;
116
+ data: import("./types.js").components["schemas"]["FinnPostCallAnalysis"];
117
+ }>;
118
+ }
119
+ export declare class Voices extends Resource {
120
+ list(query?: Q<'/voices', 'get'>, options?: RequestOptions): Promise<{
121
+ success: true;
122
+ data: import("./types.js").components["schemas"]["Voice"][];
123
+ total: number;
124
+ limit: number;
125
+ offset: number;
126
+ }>;
127
+ listAll(query?: Q<'/voices', 'get'>, options?: RequestOptions): Paginator<{
128
+ voice_id: string;
129
+ name: string | null;
130
+ description: string;
131
+ preview_url: string | null;
132
+ category: string | null;
133
+ labels: {
134
+ [key: string]: unknown;
135
+ };
136
+ languages: string[];
137
+ }, unknown>;
138
+ retrieve(voiceId: Id, options?: RequestOptions): Promise<{
139
+ success: true;
140
+ data: import("./types.js").components["schemas"]["Voice"];
141
+ }>;
142
+ }
143
+ export declare class PhoneNumbers extends Resource {
144
+ list(query?: Q<'/phone_numbers', 'get'>, options?: RequestOptions): Promise<{
145
+ success: true;
146
+ data: import("./types.js").components["schemas"]["PhoneNumber"][];
147
+ limit: number;
148
+ offset: number;
149
+ }>;
150
+ listAll(query?: Q<'/phone_numbers', 'get'>, options?: RequestOptions): Paginator<{
151
+ id: string;
152
+ phone_number: string;
153
+ status: string;
154
+ provider: string | null;
155
+ country: string | null;
156
+ capabilities: {
157
+ voice: boolean | null;
158
+ sms: boolean | null;
159
+ mms: boolean | null;
160
+ };
161
+ allocation: import("./types.js").components["schemas"]["PhoneNumberAllocation"] | null;
162
+ created_at: string;
163
+ updated_at: string;
164
+ }, unknown>;
165
+ searchAvailable(query?: Q<'/phone_numbers/available', 'get'>, options?: RequestOptions): Promise<{
166
+ success: true;
167
+ data: import("./types.js").components["schemas"]["AvailablePhoneNumber"][];
168
+ }>;
169
+ /** Rent a number (spends credits). Gets an automatic Idempotency-Key. May answer `pending_approval`. */
170
+ rent(body: B<'/phone_numbers', 'post'>, options?: RequestOptions): Promise<{
171
+ success: true;
172
+ data: import("./types.js").components["schemas"]["PhoneNumberRental"];
173
+ } | import("./types.js").PendingApproval>;
174
+ retrieve(id: Id, options?: RequestOptions): Promise<{
175
+ success: true;
176
+ data: import("./types.js").components["schemas"]["PhoneNumber"];
177
+ }>;
178
+ release(id: Id, options?: RequestOptions): Promise<{
179
+ success: true;
180
+ data: import("./types.js").components["schemas"]["ReleasedPhoneNumber"];
181
+ }>;
182
+ }
183
+ export declare class Audiences extends Resource {
184
+ list(query?: Q<'/audiences', 'get'>, options?: RequestOptions): Promise<{
185
+ success: true;
186
+ data: import("./types.js").components["schemas"]["Audience"][];
187
+ limit: number;
188
+ offset: number;
189
+ }>;
190
+ listAll(query?: Q<'/audiences', 'get'>, options?: RequestOptions): Paginator<{
191
+ id: string;
192
+ name: string;
193
+ contact_count: number;
194
+ source: string;
195
+ is_dynamic: boolean;
196
+ created_at: string;
197
+ updated_at: string | null;
198
+ }, unknown>;
199
+ create(body: B<'/audiences', 'post'>, options?: RequestOptions): Promise<{
200
+ success: true;
201
+ data: import("./types.js").components["schemas"]["Audience"];
202
+ contacts_added: number;
203
+ duplicates_skipped: number;
204
+ }>;
205
+ retrieve(audienceId: Id, options?: RequestOptions): Promise<{
206
+ success: true;
207
+ data: import("./types.js").components["schemas"]["Audience"];
208
+ }>;
209
+ archive(audienceId: Id, options?: RequestOptions): Promise<{
210
+ success: true;
211
+ data: import("./types.js").components["schemas"]["ArchivedAudience"];
212
+ }>;
213
+ listContacts(audienceId: Id, query?: Q<'/audiences/{audience_id}/contacts', 'get'>, options?: RequestOptions): Promise<{
214
+ success: true;
215
+ data: import("./types.js").components["schemas"]["Contact"][];
216
+ total: number;
217
+ limit: number;
218
+ offset: number;
219
+ }>;
220
+ listAllContacts(audienceId: Id, query?: Q<'/audiences/{audience_id}/contacts', 'get'>, options?: RequestOptions): Paginator<{
221
+ name?: string;
222
+ phone_number?: string;
223
+ country_code?: string;
224
+ } & {
225
+ [key: string]: string;
226
+ }, unknown>;
227
+ addContacts(audienceId: Id, body: B<'/audiences/{audience_id}/contacts', 'post'>, options?: RequestOptions): Promise<{
228
+ success: true;
229
+ data: import("./types.js").components["schemas"]["Audience"];
230
+ contacts_added: number;
231
+ duplicates_skipped: number;
232
+ }>;
233
+ removeContact(audienceId: Id, phone: string, options?: RequestOptions): Promise<{
234
+ success: true;
235
+ data: import("./types.js").components["schemas"]["Audience"];
236
+ contacts_removed: number;
237
+ }>;
238
+ }
239
+ export declare class Deployments extends Resource {
240
+ list(query?: Q<'/deployments', 'get'>, options?: RequestOptions): Promise<{
241
+ success: true;
242
+ data: import("./types.js").components["schemas"]["Deployment"][];
243
+ limit: number;
244
+ offset: number;
245
+ }>;
246
+ listAll(query?: Q<'/deployments', 'get'>, options?: RequestOptions): Paginator<{
247
+ id: string;
248
+ finn_id?: string | null;
249
+ audience_id?: string | null;
250
+ phone_number_id?: string | null;
251
+ call_type?: string | null;
252
+ status?: string | null;
253
+ from_number?: string | null;
254
+ number_pool?: string[] | null;
255
+ max_parallel_calls?: number | null;
256
+ schedule?: import("./types.js").components["schemas"]["DeploymentSchedule"] | null;
257
+ total_calls?: number | null;
258
+ completed_calls?: number | null;
259
+ recording_enabled?: boolean;
260
+ created_at?: string | null;
261
+ updated_at?: string | null;
262
+ }, unknown>;
263
+ /** Start an outbound campaign (spends credits). Gets an automatic Idempotency-Key. May answer `pending_approval`. */
264
+ createOutbound(body: B<'/deployments', 'post'>, options?: RequestOptions): Promise<{
265
+ success: true;
266
+ data: import("./types.js").components["schemas"]["Deployment"];
267
+ } | import("./types.js").PendingApproval>;
268
+ /** Gets an automatic Idempotency-Key. */
269
+ createInbound(body: B<'/deployments/inbound', 'post'>, options?: RequestOptions): Promise<{
270
+ success: true;
271
+ data: import("./types.js").components["schemas"]["Deployment"];
272
+ }>;
273
+ retrieve(id: Id, options?: RequestOptions): Promise<{
274
+ success: true;
275
+ data: import("./types.js").components["schemas"]["Deployment"];
276
+ }>;
277
+ stop(id: Id, options?: RequestOptions): Promise<{
278
+ success: true;
279
+ data: import("./types.js").components["schemas"]["StoppedDeployment"];
280
+ }>;
281
+ stopInbound(finnId: Id, options?: RequestOptions): Promise<{
282
+ success: true;
283
+ data: import("./types.js").components["schemas"]["StoppedInboundDeployment"];
284
+ }>;
285
+ analytics(id: Id, query?: Q<'/deployments/{id}/analytics', 'get'>, options?: RequestOptions): Promise<{
286
+ success: true;
287
+ data: import("./types.js").components["schemas"]["DeploymentAnalytics"];
288
+ }>;
289
+ }
290
+ export declare class Wallet extends Resource {
291
+ retrieve(options?: RequestOptions): Promise<{
292
+ success: true;
293
+ data: import("./types.js").components["schemas"]["Wallet"];
294
+ }>;
295
+ listTransactions(query?: Q<'/wallet/transactions', 'get'>, options?: RequestOptions): Promise<{
296
+ success: true;
297
+ data: import("./types.js").components["schemas"]["WalletTransaction"][];
298
+ limit: number;
299
+ offset: number;
300
+ }>;
301
+ listAllTransactions(query?: Q<'/wallet/transactions', 'get'>, options?: RequestOptions): Paginator<{
302
+ id: string;
303
+ type: string;
304
+ credits_delta: number;
305
+ new_balance: number;
306
+ call_uuid: string | null;
307
+ created_at: string;
308
+ }, unknown>;
309
+ }
310
+ export declare class DoNotCall extends Resource {
311
+ list(query?: Q<'/do_not_call', 'get'>, options?: RequestOptions): Promise<{
312
+ success: true;
313
+ data: import("./types.js").components["schemas"]["DoNotCallEntry"][];
314
+ total: number;
315
+ limit: number;
316
+ offset: number;
317
+ }>;
318
+ listAll(query?: Q<'/do_not_call', 'get'>, options?: RequestOptions): Paginator<{
319
+ phone_key: string;
320
+ phone_number: string;
321
+ sources: ("manual" | "crm_stage" | "rep_dialer" | "call_opt_out" | "chat_opt_out" | "import" | "api" | "operator" | "sales_ai")[];
322
+ reason: string | null;
323
+ created_at: string;
324
+ }, unknown>;
325
+ add(body: B<'/do_not_call', 'post'>, options?: RequestOptions): Promise<{
326
+ success: true;
327
+ data: import("./types.js").components["schemas"]["DoNotCallEntry"];
328
+ created: false;
329
+ } | {
330
+ success: true;
331
+ data: import("./types.js").components["schemas"]["DoNotCallEntry"];
332
+ created: true;
333
+ }>;
334
+ /** Needs the `voice:dnc:write` scope. */
335
+ remove(phone: string, options?: RequestOptions): Promise<{
336
+ success: true;
337
+ removed_sources: string[];
338
+ }>;
339
+ }
340
+ export declare class Contacts extends Resource {
341
+ list(query?: Q<'/contacts', 'get'>, options?: RequestOptions): Promise<{
342
+ contacts: import("./types.js").components["schemas"]["Record"][];
343
+ totalCount: number;
344
+ page: number;
345
+ pageSize: number;
346
+ totalPages: number;
347
+ }>;
348
+ listAll(query?: Q<'/contacts', 'get'>, options?: RequestOptions): Paginator<{
349
+ id: string;
350
+ phone: string;
351
+ phoneKey?: string;
352
+ name: string;
353
+ email?: string;
354
+ kind?: string;
355
+ ref_no?: string;
356
+ stage: string;
357
+ stageManual?: boolean;
358
+ substatus?: string | null;
359
+ substatusLabel?: string | null;
360
+ substatusAt?: string | null;
361
+ leadStatus?: "new" | "contacted" | "qualified" | "converted" | "lost";
362
+ leadStatusAt?: string;
363
+ leadStatusBy?: string;
364
+ assigneeId?: string | null;
365
+ assigneeName?: string | null;
366
+ tags?: string[];
367
+ sources?: string[];
368
+ segments?: unknown[];
369
+ fields?: Record<string, never>;
370
+ customFields?: {
371
+ [key: string]: unknown | import("./types.js").components["schemas"]["RedactedValue"];
372
+ };
373
+ closeReason?: string;
374
+ aiTemperature?: string;
375
+ aiTemperatureReason?: string;
376
+ stats?: {
377
+ count?: number;
378
+ connected?: number;
379
+ lastContacted?: string;
380
+ lastOutcome?: string;
381
+ lastSentiment?: string;
382
+ };
383
+ createdAt?: string;
384
+ updatedAt?: string;
385
+ } & {
386
+ [key: string]: unknown;
387
+ }, unknown>;
388
+ create(body: B<'/contacts', 'post'>, options?: RequestOptions): Promise<{
389
+ contact: import("./types.js").components["schemas"]["Record"];
390
+ }>;
391
+ retrieve(id: Id, options?: RequestOptions): Promise<{
392
+ contact: import("./types.js").components["schemas"]["Record"];
393
+ }>;
394
+ update(id: Id, body: B<'/contacts/{id}', 'patch'>, options?: RequestOptions): Promise<{
395
+ contact: import("./types.js").components["schemas"]["Record"];
396
+ }>;
397
+ timeline(id: Id, query?: Q<'/contacts/{id}/timeline', 'get'>, options?: RequestOptions): Promise<{
398
+ items: import("./types.js").components["schemas"]["TimelineItem"][];
399
+ next: string | null;
400
+ counts?: {
401
+ [key: string]: number;
402
+ };
403
+ }>;
404
+ timelineAll(id: Id, query?: Q<'/contacts/{id}/timeline', 'get'>, options?: RequestOptions): Paginator<{
405
+ id: string;
406
+ kind: "call" | "chat" | "message" | "operator" | "note" | "form" | "change" | "file" | "view";
407
+ type?: string;
408
+ source?: string | null;
409
+ channel?: string | null;
410
+ direction?: string | null;
411
+ at: string;
412
+ text?: string | null;
413
+ author?: string | null;
414
+ } & {
415
+ [key: string]: unknown;
416
+ }, unknown>;
417
+ addNote(id: Id, body: B<'/contacts/{id}/notes', 'post'>, options?: RequestOptions): Promise<{
418
+ note: import("./types.js").components["schemas"]["Note"];
419
+ }>;
420
+ /** Record kinds (contact, company, ...). */
421
+ listKinds(options?: RequestOptions): Promise<{
422
+ enabled: boolean;
423
+ kinds: import("./types.js").components["schemas"]["RecordKind"][];
424
+ }>;
425
+ listFields(query?: Q<'/fields', 'get'>, options?: RequestOptions): Promise<{
426
+ fields: import("./types.js").components["schemas"]["FieldDefinition"][];
427
+ }>;
428
+ }
429
+ export declare class Cases extends Resource {
430
+ list(query?: Q<'/cases', 'get'>, options?: RequestOptions): Promise<{
431
+ cases: import("./types.js").components["schemas"]["CaseSummary"][];
432
+ next_before: string | null;
433
+ }>;
434
+ listAll(query?: Q<'/cases', 'get'>, options?: RequestOptions): Paginator<{
435
+ id: string;
436
+ agent_id: string;
437
+ agent_name: string;
438
+ version_no?: number;
439
+ status: string;
440
+ title?: string | null;
441
+ subject_type?: string | null;
442
+ subject_ref?: string | null;
443
+ stage?: string | null;
444
+ owner_id?: string | null;
445
+ outcome_key?: string | null;
446
+ cost_minor?: number;
447
+ participants?: {
448
+ role?: string;
449
+ name?: string | null;
450
+ }[];
451
+ waiting?: Record<string, never> | null;
452
+ opened_at: string;
453
+ closed_at?: string | null;
454
+ } & {
455
+ [key: string]: unknown;
456
+ }, unknown>;
457
+ retrieve(id: Id, options?: RequestOptions): Promise<{
458
+ id: string;
459
+ org_id?: string;
460
+ agent_id: string;
461
+ version_id?: string;
462
+ version_no?: number;
463
+ status: string;
464
+ test?: boolean;
465
+ title?: string | null;
466
+ subject_type?: string | null;
467
+ subject_ref?: string | null;
468
+ subject?: unknown;
469
+ memory?: unknown;
470
+ stage?: string | null;
471
+ owner_id?: string | null;
472
+ outcome_key?: string | null;
473
+ outcome_reason?: string | null;
474
+ error_code?: string | null;
475
+ error_message?: string | null;
476
+ cost_minor?: number;
477
+ currency?: string;
478
+ event_seq?: number;
479
+ next_wake_at?: string | null;
480
+ opened_at: string;
481
+ closed_at?: string | null;
482
+ participants?: import("./types.js").components["schemas"]["CaseParticipant"][];
483
+ threads?: Record<string, never>[];
484
+ open_waits?: Record<string, never>[];
485
+ steps?: Record<string, never>[];
486
+ resolutions?: Record<string, never>[];
487
+ } & {
488
+ [key: string]: unknown;
489
+ }>;
490
+ listEvents(id: Id, options?: RequestOptions): Promise<{
491
+ events: import("./types.js").components["schemas"]["CaseEvent"][];
492
+ next_after: number;
493
+ }>;
494
+ /** Start a case on an agent. Gets an automatic Idempotency-Key. May answer `pending_approval` (see isPendingApproval). */
495
+ start(agentId: Id, body?: B<'/agents/{id}/cases', 'post'>, options?: RequestOptions): Promise<{
496
+ case_id: string;
497
+ trigger_event_id: string;
498
+ result: "opened" | "matched" | "reopened";
499
+ replayed: boolean;
500
+ } | import("./types.js").PendingApproval>;
501
+ }
502
+ export interface WaitForApprovalOptions {
503
+ /** Time between polls. Default 3000 ms. */
504
+ intervalMs?: number;
505
+ /** Give up after this long and throw FinnApprovalTimeoutError. Default 15 minutes. */
506
+ timeoutMs?: number;
507
+ signal?: AbortSignal;
508
+ /** Called after each poll with the approval as it stands. */
509
+ onPoll?: (approval: ApprovalHold | Schemas['Approval']) => void;
510
+ /** Replaces the wait between polls (for tests). */
511
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
512
+ }
513
+ export declare class Approvals extends Resource {
514
+ list(query?: Q<'/approvals', 'get'>, options?: RequestOptions): Promise<{
515
+ approvals: import("./types.js").components["schemas"]["Approval"][];
516
+ next_cursor: string | null;
517
+ }>;
518
+ listAll(query?: Q<'/approvals', 'get'>, options?: RequestOptions): Paginator<{
519
+ id: string;
520
+ case_id: string;
521
+ case_title?: string | null;
522
+ agent_id?: string | null;
523
+ agent_name?: string | null;
524
+ node_id?: string | null;
525
+ contact_id?: string | null;
526
+ question: string;
527
+ allowed_answers: string[];
528
+ status: string;
529
+ assignee_role?: string | null;
530
+ assignee_user_id?: string | null;
531
+ assignee_user_ids?: string[];
532
+ proposal?: unknown;
533
+ payment?: unknown;
534
+ payment_hash?: string | null;
535
+ why?: unknown;
536
+ final?: unknown;
537
+ escalated_to?: unknown;
538
+ deadline_at?: string | null;
539
+ reminders?: number;
540
+ answer?: string | null;
541
+ comment?: string | null;
542
+ decided_by?: string | null;
543
+ decided_via?: string | null;
544
+ decided_at?: string | null;
545
+ created_at: string;
546
+ } & {
547
+ [key: string]: unknown;
548
+ }, unknown>;
549
+ /** An Operator approval, or a held API request (`source: 'api_hold'`) made by this caller. */
550
+ retrieve(id: Id, options?: RequestOptions): Promise<ApprovalHold | Schemas['Approval']>;
551
+ decide(id: Id, body: B<'/approvals/{id}/decide', 'post'>, options?: RequestOptions): Promise<{
552
+ id: string;
553
+ case_id: string;
554
+ case_title?: string | null;
555
+ agent_id?: string | null;
556
+ agent_name?: string | null;
557
+ node_id?: string | null;
558
+ contact_id?: string | null;
559
+ question: string;
560
+ allowed_answers: string[];
561
+ status: string;
562
+ assignee_role?: string | null;
563
+ assignee_user_id?: string | null;
564
+ assignee_user_ids?: string[];
565
+ proposal?: unknown;
566
+ payment?: unknown;
567
+ payment_hash?: string | null;
568
+ why?: unknown;
569
+ final?: unknown;
570
+ escalated_to?: unknown;
571
+ deadline_at?: string | null;
572
+ reminders?: number;
573
+ answer?: string | null;
574
+ comment?: string | null;
575
+ decided_by?: string | null;
576
+ decided_via?: string | null;
577
+ decided_at?: string | null;
578
+ created_at: string;
579
+ } & {
580
+ [key: string]: unknown;
581
+ }>;
582
+ approve(id: Id, body?: B<'/approvals/{id}/approve', 'post'>, options?: RequestOptions): Promise<{
583
+ id: string;
584
+ case_id: string;
585
+ case_title?: string | null;
586
+ agent_id?: string | null;
587
+ agent_name?: string | null;
588
+ node_id?: string | null;
589
+ contact_id?: string | null;
590
+ question: string;
591
+ allowed_answers: string[];
592
+ status: string;
593
+ assignee_role?: string | null;
594
+ assignee_user_id?: string | null;
595
+ assignee_user_ids?: string[];
596
+ proposal?: unknown;
597
+ payment?: unknown;
598
+ payment_hash?: string | null;
599
+ why?: unknown;
600
+ final?: unknown;
601
+ escalated_to?: unknown;
602
+ deadline_at?: string | null;
603
+ reminders?: number;
604
+ answer?: string | null;
605
+ comment?: string | null;
606
+ decided_by?: string | null;
607
+ decided_via?: string | null;
608
+ decided_at?: string | null;
609
+ created_at: string;
610
+ } & {
611
+ [key: string]: unknown;
612
+ }>;
613
+ reject(id: Id, body?: B<'/approvals/{id}/reject', 'post'>, options?: RequestOptions): Promise<{
614
+ id: string;
615
+ case_id: string;
616
+ case_title?: string | null;
617
+ agent_id?: string | null;
618
+ agent_name?: string | null;
619
+ node_id?: string | null;
620
+ contact_id?: string | null;
621
+ question: string;
622
+ allowed_answers: string[];
623
+ status: string;
624
+ assignee_role?: string | null;
625
+ assignee_user_id?: string | null;
626
+ assignee_user_ids?: string[];
627
+ proposal?: unknown;
628
+ payment?: unknown;
629
+ payment_hash?: string | null;
630
+ why?: unknown;
631
+ final?: unknown;
632
+ escalated_to?: unknown;
633
+ deadline_at?: string | null;
634
+ reminders?: number;
635
+ answer?: string | null;
636
+ comment?: string | null;
637
+ decided_by?: string | null;
638
+ decided_via?: string | null;
639
+ decided_at?: string | null;
640
+ created_at: string;
641
+ } & {
642
+ [key: string]: unknown;
643
+ }>;
644
+ /**
645
+ * Polls `GET /approvals/{id}` until the approval leaves `pending` / `running` / `open`, and returns it.
646
+ * For a held API request, `status` ends as `succeeded`, `failed`, `declined` or `expired`, and `result` holds
647
+ * the held request's own answer.
648
+ */
649
+ wait(id: Id, opts?: WaitForApprovalOptions): Promise<ApprovalHold | Schemas['Approval']>;
650
+ }
651
+ export declare class Agents extends Resource {
652
+ list(query?: Q<'/agents', 'get'>, options?: RequestOptions): Promise<{
653
+ data: import("./types.js").components["schemas"]["AgentSummary"][];
654
+ next_cursor: string | null;
655
+ has_more: boolean;
656
+ }>;
657
+ listAll(query?: Q<'/agents', 'get'>, options?: RequestOptions): Paginator<{
658
+ id: string;
659
+ name: string;
660
+ status: "draft" | "live" | "paused" | "archived";
661
+ halted?: boolean;
662
+ live_version_no?: number | null;
663
+ last_published_at?: string | null;
664
+ open_cases?: number;
665
+ updated_at: string;
666
+ start_trigger?: Record<string, never>;
667
+ } & {
668
+ [key: string]: unknown;
669
+ }, unknown>;
670
+ /** Create a draft agent (never live). Gets an automatic Idempotency-Key. */
671
+ create(body: B<'/agents', 'post'>, options?: RequestOptions): Promise<{
672
+ id: string;
673
+ name: string;
674
+ status: "draft" | "live" | "paused" | "archived";
675
+ draft?: Record<string, never>;
676
+ draft_rev: number;
677
+ } & {
678
+ [key: string]: unknown;
679
+ }>;
680
+ /** Draft an agent from a description, without saving it. */
681
+ draft(body: B<'/agents/draft', 'post'>, options?: RequestOptions): Promise<{
682
+ name: string;
683
+ graph: Record<string, never>;
684
+ notes?: string[];
685
+ problems?: {
686
+ [key: string]: unknown;
687
+ }[];
688
+ }>;
689
+ retrieve(id: Id, options?: RequestOptions): Promise<{
690
+ id: string;
691
+ name: string;
692
+ status: "draft" | "live" | "paused" | "archived";
693
+ draft?: Record<string, never>;
694
+ draft_rev: number;
695
+ } & {
696
+ [key: string]: unknown;
697
+ }>;
698
+ saveDraft(id: Id, body: B<'/agents/{id}/draft', 'put'>, options?: RequestOptions): Promise<{
699
+ id: string;
700
+ name: string;
701
+ status: "draft" | "live" | "paused" | "archived";
702
+ draft?: Record<string, never>;
703
+ draft_rev: number;
704
+ } & {
705
+ [key: string]: unknown;
706
+ }>;
707
+ validate(id: Id, options?: RequestOptions): Promise<{
708
+ [key: string]: unknown;
709
+ }>;
710
+ test(id: Id, body?: B<'/agents/{id}/test', 'post'>, options?: RequestOptions): Promise<{
711
+ id: string;
712
+ org_id?: string;
713
+ agent_id: string;
714
+ version_id?: string;
715
+ version_no?: number;
716
+ status: string;
717
+ test?: boolean;
718
+ title?: string | null;
719
+ subject_type?: string | null;
720
+ subject_ref?: string | null;
721
+ subject?: unknown;
722
+ memory?: unknown;
723
+ stage?: string | null;
724
+ owner_id?: string | null;
725
+ outcome_key?: string | null;
726
+ outcome_reason?: string | null;
727
+ error_code?: string | null;
728
+ error_message?: string | null;
729
+ cost_minor?: number;
730
+ currency?: string;
731
+ event_seq?: number;
732
+ next_wake_at?: string | null;
733
+ opened_at: string;
734
+ closed_at?: string | null;
735
+ participants?: import("./types.js").components["schemas"]["CaseParticipant"][];
736
+ threads?: Record<string, never>[];
737
+ open_waits?: Record<string, never>[];
738
+ steps?: Record<string, never>[];
739
+ resolutions?: Record<string, never>[];
740
+ } & {
741
+ [key: string]: unknown;
742
+ }>;
743
+ publish(id: Id, options?: RequestOptions): Promise<never>;
744
+ /** Drive a test case one step (`action` as the spec lists it). */
745
+ driveTest(caseId: Id, action: string, body?: B<'/cases/{id}/test/{action}', 'post'>, options?: RequestOptions): Promise<{
746
+ id: string;
747
+ org_id?: string;
748
+ agent_id: string;
749
+ version_id?: string;
750
+ version_no?: number;
751
+ status: string;
752
+ test?: boolean;
753
+ title?: string | null;
754
+ subject_type?: string | null;
755
+ subject_ref?: string | null;
756
+ subject?: unknown;
757
+ memory?: unknown;
758
+ stage?: string | null;
759
+ owner_id?: string | null;
760
+ outcome_key?: string | null;
761
+ outcome_reason?: string | null;
762
+ error_code?: string | null;
763
+ error_message?: string | null;
764
+ cost_minor?: number;
765
+ currency?: string;
766
+ event_seq?: number;
767
+ next_wake_at?: string | null;
768
+ opened_at: string;
769
+ closed_at?: string | null;
770
+ participants?: import("./types.js").components["schemas"]["CaseParticipant"][];
771
+ threads?: Record<string, never>[];
772
+ open_waits?: Record<string, never>[];
773
+ steps?: Record<string, never>[];
774
+ resolutions?: Record<string, never>[];
775
+ } & {
776
+ [key: string]: unknown;
777
+ }>;
778
+ }
779
+ type ChatItem = Record<string, unknown>;
780
+ export declare class ChatConversations extends Resource {
781
+ list(query?: Q<'/chat/conversations', 'get'>, options?: RequestOptions): Promise<{
782
+ data: {
783
+ [key: string]: unknown;
784
+ }[];
785
+ next_cursor: string | null;
786
+ has_more: boolean;
787
+ }>;
788
+ listAll(query?: Q<'/chat/conversations', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
789
+ /** Start a conversation (sends the first message). Gets an automatic Idempotency-Key (the API requires one). May answer `pending_approval`. */
790
+ start(body: B<'/chat/conversations', 'post'>, options?: RequestOptions): Promise<{
791
+ [key: string]: unknown;
792
+ } | import("./types.js").PendingApproval>;
793
+ retrieve(id: Id, options?: RequestOptions): Promise<{
794
+ conversation: {
795
+ [key: string]: unknown;
796
+ };
797
+ messages: {
798
+ [key: string]: unknown;
799
+ }[];
800
+ messages_next_cursor: string | null;
801
+ }>;
802
+ listMessages(id: Id, query?: Q<'/chat/conversations/{id}/messages', 'get'>, options?: RequestOptions): Promise<{
803
+ data: {
804
+ [key: string]: unknown;
805
+ }[];
806
+ next_cursor: string | null;
807
+ has_more: boolean;
808
+ }>;
809
+ listAllMessages(id: Id, query?: Q<'/chat/conversations/{id}/messages', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
810
+ /** Send a message. Gets an automatic Idempotency-Key (the API requires one). May answer `pending_approval`. */
811
+ send(id: Id, body: B<'/chat/conversations/{id}/messages', 'post'>, options?: RequestOptions): Promise<{
812
+ [key: string]: unknown;
813
+ } | import("./types.js").PendingApproval>;
814
+ }
815
+ export declare class ChatContacts extends Resource {
816
+ list(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): Promise<{
817
+ data: {
818
+ [key: string]: unknown;
819
+ }[];
820
+ next_cursor: string | null;
821
+ has_more: boolean;
822
+ } & {
823
+ total?: number | null;
824
+ }>;
825
+ listAll(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
826
+ retrieve(id: Id, options?: RequestOptions): Promise<{
827
+ [key: string]: unknown;
828
+ }>;
829
+ update(id: Id, body: B<'/chat/contacts/{id}', 'patch'>, options?: RequestOptions): Promise<{
830
+ [key: string]: unknown;
831
+ }>;
832
+ }
833
+ export declare class Chat extends Resource {
834
+ readonly conversations: ChatConversations;
835
+ readonly contacts: ChatContacts;
836
+ constructor(core: FinnCore);
837
+ listChannels(options?: RequestOptions): Promise<{
838
+ data: {
839
+ [key: string]: unknown;
840
+ }[];
841
+ next_cursor: string | null;
842
+ has_more: boolean;
843
+ }>;
844
+ }
845
+ export {};