@absolutejs/voice 0.0.22-beta.0 → 0.0.22-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ops.d.ts CHANGED
@@ -1,30 +1,79 @@
1
1
  import type { VoiceCallDisposition, VoiceSessionRecord, VoiceSessionSummary } from './types';
2
2
  import type { StoredVoiceCallReviewArtifact } from './testing/review';
3
3
  export type VoiceOpsTaskStatus = 'open' | 'in-progress' | 'done';
4
- export type VoiceOpsTaskKind = 'callback' | 'escalation' | 'transfer-check' | 'retry-review';
4
+ export type VoiceOpsTaskKind = 'appointment-booking' | 'callback' | 'escalation' | 'lead-qualification' | 'transfer-check' | 'retry-review' | 'support-triage';
5
+ export type VoiceOpsTaskPriority = 'low' | 'normal' | 'high' | 'urgent';
5
6
  export type VoiceOpsTaskHistoryEntry = {
6
7
  actor: string;
7
8
  at: number;
8
9
  detail?: string;
9
- type: 'created' | 'assigned' | 'started' | 'completed' | 'reopened';
10
+ type: 'created' | 'assigned' | 'started' | 'claimed' | 'heartbeat' | 'failed' | 'dead-lettered' | 'policy-applied' | 'sla-breached' | 'completed' | 'reopened' | 'requeued';
10
11
  };
11
12
  export type VoiceOpsTask = {
12
13
  assignee?: string;
14
+ claimExpiresAt?: number;
15
+ claimedAt?: number;
16
+ claimedBy?: string;
13
17
  createdAt: number;
18
+ deadLetteredAt?: number;
14
19
  description: string;
20
+ dueAt?: number;
15
21
  history: VoiceOpsTaskHistoryEntry[];
16
22
  id: string;
17
23
  intakeId?: string;
18
24
  kind: VoiceOpsTaskKind;
25
+ lastProcessedAt?: number;
26
+ policyName?: string;
27
+ processingAttempts?: number;
28
+ processingError?: string;
19
29
  outcome?: VoiceCallDisposition;
30
+ priority?: VoiceOpsTaskPriority;
31
+ queue?: string;
20
32
  recommendedAction: string;
21
33
  reviewId?: string;
34
+ slaBreachedAt?: number;
22
35
  status: VoiceOpsTaskStatus;
23
36
  target?: string;
24
37
  title: string;
25
38
  updatedAt: number;
26
39
  };
27
40
  export type StoredVoiceOpsTask = VoiceOpsTask;
41
+ export type VoiceExternalObjectMap = {
42
+ createdAt: number;
43
+ externalId: string;
44
+ id: string;
45
+ provider: string;
46
+ sinkId?: string;
47
+ sourceId: string;
48
+ sourceType: 'session' | 'review' | 'task' | 'event';
49
+ updatedAt: number;
50
+ };
51
+ export type StoredVoiceExternalObjectMap = VoiceExternalObjectMap;
52
+ export declare const createVoiceExternalObjectMapId: (input: {
53
+ provider: string;
54
+ sinkId?: string;
55
+ sourceId: string;
56
+ }) => string;
57
+ export declare const createVoiceExternalObjectMap: (input: {
58
+ at?: number;
59
+ externalId: string;
60
+ provider: string;
61
+ sinkId?: string;
62
+ sourceId: string;
63
+ sourceType: VoiceExternalObjectMap["sourceType"];
64
+ }) => StoredVoiceExternalObjectMap;
65
+ export type VoiceExternalObjectMapStore<TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap> = {
66
+ find: (input: {
67
+ provider: string;
68
+ sinkId?: string;
69
+ sourceId: string;
70
+ sourceType?: VoiceExternalObjectMap['sourceType'];
71
+ }) => Promise<TMapping | undefined> | TMapping | undefined;
72
+ get: (id: string) => Promise<TMapping | undefined> | TMapping | undefined;
73
+ list: () => Promise<TMapping[]> | TMapping[];
74
+ remove: (id: string) => Promise<void> | void;
75
+ set: (id: string, mapping: TMapping) => Promise<void> | void;
76
+ };
28
77
  export type VoiceOpsTaskStore<TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask> = {
29
78
  get: (id: string) => Promise<TTask | undefined> | TTask | undefined;
30
79
  list: () => Promise<TTask[]> | TTask[];
@@ -32,32 +81,141 @@ export type VoiceOpsTaskStore<TTask extends StoredVoiceOpsTask = StoredVoiceOpsT
32
81
  set: (id: string, task: TTask) => Promise<void> | void;
33
82
  };
34
83
  export type VoiceOpsTaskSummary = {
84
+ byClaimedBy: Array<[string, number]>;
35
85
  byKind: Array<[VoiceOpsTaskKind, number]>;
36
86
  byOutcome: Array<[string, number]>;
87
+ byPriority: Array<[VoiceOpsTaskPriority, number]>;
88
+ byQueue: Array<[string, number]>;
89
+ claimed: number;
37
90
  done: number;
38
91
  inProgress: number;
39
92
  open: number;
93
+ overdue: number;
40
94
  topAssignees: Array<[string, number]>;
95
+ topQueues: Array<[string, number]>;
41
96
  topTargets: Array<[string, number]>;
42
97
  total: number;
43
98
  };
44
- export type VoiceIntegrationEventType = 'call.completed' | 'review.saved' | 'task.created' | 'task.updated';
99
+ export type VoiceOpsTaskAgeBucket = 'fresh' | 'aging' | 'due-soon' | 'overdue' | 'stale';
100
+ export type VoiceOpsTaskAssigneeAnalytics = {
101
+ assignee: string;
102
+ averageCompletionMs?: number;
103
+ claimed: number;
104
+ completed: number;
105
+ inProgress: number;
106
+ open: number;
107
+ overdue: number;
108
+ total: number;
109
+ };
110
+ export type VoiceOpsTaskWorkerAnalytics = {
111
+ activeClaims: number;
112
+ completed: number;
113
+ failed: number;
114
+ heartbeats: number;
115
+ requeued: number;
116
+ totalClaims: number;
117
+ workerId: string;
118
+ };
119
+ export type VoiceOpsTaskAnalyticsSummary = {
120
+ agingBuckets: Array<[VoiceOpsTaskAgeBucket, number]>;
121
+ assignees: VoiceOpsTaskAssigneeAnalytics[];
122
+ totalCompleted: number;
123
+ totalOverdue: number;
124
+ totalTasks: number;
125
+ workers: VoiceOpsTaskWorkerAnalytics[];
126
+ };
127
+ export type VoiceOpsTaskPolicy = {
128
+ assignee?: string;
129
+ dueInMs?: number;
130
+ name?: string;
131
+ priority?: VoiceOpsTaskPriority;
132
+ queue?: string;
133
+ recommendedAction?: string;
134
+ target?: string;
135
+ title?: string;
136
+ };
137
+ export type VoiceOpsTaskAssignmentRuleCondition = {
138
+ assignee?: string;
139
+ kind?: VoiceOpsTaskKind;
140
+ outcome?: VoiceCallDisposition;
141
+ policyName?: string;
142
+ priority?: VoiceOpsTaskPriority;
143
+ queue?: string;
144
+ status?: VoiceOpsTaskStatus;
145
+ };
146
+ export type VoiceOpsTaskAssignmentRule = {
147
+ assign?: string;
148
+ description?: string;
149
+ name?: string;
150
+ priority?: VoiceOpsTaskPriority;
151
+ queue?: string;
152
+ recommendedAction?: string;
153
+ title?: string;
154
+ when?: VoiceOpsTaskAssignmentRuleCondition;
155
+ };
156
+ export type VoiceOpsDispositionTaskPolicies = Partial<Record<VoiceCallDisposition, VoiceOpsTaskPolicy>>;
157
+ export type VoiceOpsTaskAssignmentRules = VoiceOpsTaskAssignmentRule[];
158
+ export type VoiceOpsTaskAnalyticsOptions = {
159
+ agingMs?: number;
160
+ at?: number;
161
+ dueSoonMs?: number;
162
+ staleMs?: number;
163
+ };
164
+ export type VoiceIntegrationEventType = 'call.completed' | 'review.saved' | 'task.created' | 'task.updated' | 'task.sla_breached';
165
+ export type VoiceOpsSLABreachPolicy = {
166
+ action?: 'event' | 'event-and-task' | 'task';
167
+ assignee?: string;
168
+ description?: string;
169
+ dueInMs?: number;
170
+ name?: string;
171
+ priority?: VoiceOpsTaskPriority;
172
+ queue?: string;
173
+ recommendedAction?: string;
174
+ title?: string;
175
+ };
176
+ export type VoiceIntegrationDeliveryStatus = 'pending' | 'delivered' | 'failed' | 'skipped';
177
+ export type VoiceIntegrationSinkDelivery = {
178
+ attempts: number;
179
+ deliveredAt?: number;
180
+ deliveredTo?: string;
181
+ error?: string;
182
+ sinkId: string;
183
+ sinkKind?: string;
184
+ status: VoiceIntegrationDeliveryStatus;
185
+ };
45
186
  export type VoiceIntegrationEvent = {
46
187
  createdAt: number;
47
188
  deliveredAt?: number;
189
+ deliveryAttempts?: number;
48
190
  deliveredTo?: string;
49
191
  deliveryError?: string;
192
+ deliveryStatus?: VoiceIntegrationDeliveryStatus;
50
193
  id: string;
51
194
  payload: Record<string, unknown>;
195
+ sinkDeliveries?: Record<string, VoiceIntegrationSinkDelivery>;
52
196
  type: VoiceIntegrationEventType;
53
197
  };
54
198
  export type StoredVoiceIntegrationEvent = VoiceIntegrationEvent;
199
+ export type VoiceIntegrationWebhookConfig = {
200
+ backoffMs?: number;
201
+ eventTypes?: VoiceIntegrationEventType[];
202
+ fetch?: typeof fetch;
203
+ headers?: Record<string, string>;
204
+ retries?: number;
205
+ signingSecret?: string;
206
+ timeoutMs?: number;
207
+ url: string;
208
+ };
55
209
  export type VoiceIntegrationEventStore<TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent> = {
56
210
  get: (id: string) => Promise<TEvent | undefined> | TEvent | undefined;
57
211
  list: () => Promise<TEvent[]> | TEvent[];
58
212
  remove: (id: string) => Promise<void> | void;
59
213
  set: (id: string, event: TEvent) => Promise<void> | void;
60
214
  };
215
+ export declare const deliverVoiceIntegrationEvent: (input: {
216
+ event: StoredVoiceIntegrationEvent;
217
+ webhook: VoiceIntegrationWebhookConfig;
218
+ }) => Promise<StoredVoiceIntegrationEvent>;
61
219
  export declare const withVoiceOpsTaskId: <TTask extends Omit<VoiceOpsTask, "id"> = Omit<VoiceOpsTask, "id">>(id: string, task: TTask) => TTask & {
62
220
  id: string;
63
221
  };
@@ -65,6 +223,39 @@ export declare const withVoiceIntegrationEventId: <TEvent extends Omit<VoiceInte
65
223
  id: string;
66
224
  };
67
225
  export declare const buildVoiceOpsTaskFromReview: (review: StoredVoiceCallReviewArtifact) => StoredVoiceOpsTask | null;
226
+ export declare const resolveVoiceOpsTaskPolicy: (input: {
227
+ disposition?: VoiceCallDisposition;
228
+ policies?: VoiceOpsDispositionTaskPolicies;
229
+ }) => {
230
+ assignee?: string;
231
+ dueInMs?: number;
232
+ name?: string;
233
+ priority?: VoiceOpsTaskPriority;
234
+ queue?: string;
235
+ recommendedAction?: string;
236
+ target?: string;
237
+ title?: string;
238
+ } | undefined;
239
+ export declare const isVoiceOpsTaskOverdue: (task: StoredVoiceOpsTask, input?: {
240
+ at?: number;
241
+ }) => boolean;
242
+ export declare const hasVoiceOpsTaskSLABreach: (task: StoredVoiceOpsTask) => boolean;
243
+ export declare const resolveVoiceOpsTaskAgeBucket: (task: StoredVoiceOpsTask, input?: VoiceOpsTaskAnalyticsOptions) => VoiceOpsTaskAgeBucket;
244
+ export declare const applyVoiceOpsTaskPolicy: (task: StoredVoiceOpsTask, policy: VoiceOpsTaskPolicy, input?: {
245
+ at?: number;
246
+ actor?: string;
247
+ detail?: string;
248
+ }) => StoredVoiceOpsTask;
249
+ export declare const matchesVoiceOpsTaskAssignmentRule: (task: StoredVoiceOpsTask, rule: VoiceOpsTaskAssignmentRule) => boolean;
250
+ export declare const resolveVoiceOpsTaskAssignment: (input: {
251
+ rules?: VoiceOpsTaskAssignmentRules;
252
+ task: StoredVoiceOpsTask;
253
+ }) => VoiceOpsTaskAssignmentRule | undefined;
254
+ export declare const applyVoiceOpsTaskAssignmentRule: (task: StoredVoiceOpsTask, rule: VoiceOpsTaskAssignmentRule, input?: {
255
+ at?: number;
256
+ actor?: string;
257
+ detail?: string;
258
+ }) => StoredVoiceOpsTask;
68
259
  export declare const assignVoiceOpsTask: (task: StoredVoiceOpsTask, owner: string, input?: {
69
260
  at?: number;
70
261
  actor?: string;
@@ -74,6 +265,34 @@ export declare const startVoiceOpsTask: (task: StoredVoiceOpsTask, input?: {
74
265
  actor?: string;
75
266
  detail?: string;
76
267
  }) => StoredVoiceOpsTask;
268
+ export declare const claimVoiceOpsTask: (task: StoredVoiceOpsTask, workerId: string, input?: {
269
+ at?: number;
270
+ actor?: string;
271
+ detail?: string;
272
+ leaseMs: number;
273
+ }) => StoredVoiceOpsTask;
274
+ export declare const heartbeatVoiceOpsTask: (task: StoredVoiceOpsTask, workerId: string, input?: {
275
+ at?: number;
276
+ actor?: string;
277
+ detail?: string;
278
+ leaseMs: number;
279
+ }) => StoredVoiceOpsTask;
280
+ export declare const failVoiceOpsTask: (task: StoredVoiceOpsTask, input?: {
281
+ at?: number;
282
+ actor?: string;
283
+ detail?: string;
284
+ error?: string;
285
+ }) => StoredVoiceOpsTask;
286
+ export declare const deadLetterVoiceOpsTask: (task: StoredVoiceOpsTask, input?: {
287
+ at?: number;
288
+ actor?: string;
289
+ detail?: string;
290
+ }) => StoredVoiceOpsTask;
291
+ export declare const markVoiceOpsTaskSLABreached: (task: StoredVoiceOpsTask, input?: {
292
+ at?: number;
293
+ actor?: string;
294
+ detail?: string;
295
+ }) => StoredVoiceOpsTask;
77
296
  export declare const completeVoiceOpsTask: (task: StoredVoiceOpsTask, input?: {
78
297
  at?: number;
79
298
  actor?: string;
@@ -84,8 +303,14 @@ export declare const reopenVoiceOpsTask: (task: StoredVoiceOpsTask, input?: {
84
303
  actor?: string;
85
304
  detail?: string;
86
305
  }) => StoredVoiceOpsTask;
306
+ export declare const requeueVoiceOpsTask: (task: StoredVoiceOpsTask, input?: {
307
+ at?: number;
308
+ actor?: string;
309
+ detail?: string;
310
+ }) => StoredVoiceOpsTask;
87
311
  export declare const listVoiceOpsTasks: (tasks: StoredVoiceOpsTask[]) => VoiceOpsTask[];
88
312
  export declare const summarizeVoiceOpsTasks: (tasks: StoredVoiceOpsTask[]) => VoiceOpsTaskSummary;
313
+ export declare const summarizeVoiceOpsTaskAnalytics: (tasks: StoredVoiceOpsTask[], input?: VoiceOpsTaskAnalyticsOptions) => VoiceOpsTaskAnalyticsSummary;
89
314
  export declare const createVoiceIntegrationEvent: <TPayload extends Record<string, unknown> = Record<string, unknown>>(type: VoiceIntegrationEventType, payload: TPayload, input?: {
90
315
  createdAt?: number;
91
316
  id?: string;
@@ -98,3 +323,5 @@ export declare const createVoiceCallCompletedEvent: (input: {
98
323
  export declare const createVoiceReviewSavedEvent: (review: StoredVoiceCallReviewArtifact) => StoredVoiceIntegrationEvent;
99
324
  export declare const createVoiceTaskCreatedEvent: (task: StoredVoiceOpsTask) => StoredVoiceIntegrationEvent;
100
325
  export declare const createVoiceTaskUpdatedEvent: (task: StoredVoiceOpsTask) => StoredVoiceIntegrationEvent;
326
+ export declare const createVoiceTaskSLABreachedEvent: (task: StoredVoiceOpsTask) => StoredVoiceIntegrationEvent;
327
+ export declare const buildVoiceOpsTaskFromSLABreach: (task: StoredVoiceOpsTask, policy?: VoiceOpsSLABreachPolicy) => StoredVoiceOpsTask;
@@ -0,0 +1,19 @@
1
+ import type { VoiceOpsDispositionTaskPolicies, VoiceOpsTaskAssignmentRules, VoiceOpsSLABreachPolicy } from './ops';
2
+ export type VoiceOpsPresetName = 'support-default' | 'sales-default' | 'collections-default';
3
+ export type VoiceResolvedOpsPreset = {
4
+ assignmentRules: VoiceOpsTaskAssignmentRules;
5
+ description: string;
6
+ name: VoiceOpsPresetName;
7
+ sla: {
8
+ followUpTask?: VoiceOpsSLABreachPolicy;
9
+ };
10
+ taskPolicies: VoiceOpsDispositionTaskPolicies;
11
+ };
12
+ export type VoiceOpsPresetOverrides = {
13
+ assignmentRules?: VoiceOpsTaskAssignmentRules;
14
+ sla?: {
15
+ followUpTask?: VoiceOpsSLABreachPolicy;
16
+ };
17
+ taskPolicies?: VoiceOpsDispositionTaskPolicies;
18
+ };
19
+ export declare const resolveVoiceOpsPreset: (name: VoiceOpsPresetName, overrides?: VoiceOpsPresetOverrides) => VoiceResolvedOpsPreset;
@@ -0,0 +1,66 @@
1
+ import type { StoredVoiceIntegrationEvent, StoredVoiceOpsTask, VoiceIntegrationWebhookConfig, VoiceOpsSLABreachPolicy } from './ops';
2
+ import type { VoiceIntegrationSinkWorkerOptions, VoiceIntegrationSinkWorkerResult, VoiceIntegrationEventQueueSummary, VoiceOpsTaskProcessorWorkerOptions, VoiceOpsTaskProcessorWorkerResult, VoiceOpsTaskQueueSummary, VoiceRedisTaskLeaseCoordinator, VoiceWebhookDeliveryWorkerOptions, VoiceWebhookDeliveryWorkerResult } from './queue';
3
+ import type { VoiceCallDisposition, VoiceRuntimeOpsConfig, VoiceSessionHandle, VoiceSessionRecord } from './types';
4
+ export type VoiceOpsRuntimeWebhookWorkerConfig<TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent> = Omit<VoiceWebhookDeliveryWorkerOptions<StoredVoiceIntegrationEvent>, 'events' | 'webhook'> & VoiceIntegrationWebhookConfig & {
5
+ autoStart?: boolean;
6
+ pollIntervalMs?: number;
7
+ };
8
+ export type VoiceOpsRuntimeSinkWorkerConfig<TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent> = Omit<VoiceIntegrationSinkWorkerOptions<StoredVoiceIntegrationEvent>, 'events' | 'sinks'> & {
9
+ autoStart?: boolean;
10
+ pollIntervalMs?: number;
11
+ };
12
+ export type VoiceOpsRuntimeTaskWorkerConfig<TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask> = Omit<VoiceOpsTaskProcessorWorkerOptions<StoredVoiceOpsTask>, 'tasks' | 'worker'> & {
13
+ autoStart?: boolean;
14
+ leaseMs?: number;
15
+ leases: VoiceRedisTaskLeaseCoordinator;
16
+ pollIntervalMs?: number;
17
+ workerId: string;
18
+ };
19
+ export type VoiceOpsRuntimeConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
20
+ ops: VoiceRuntimeOpsConfig<TContext, TSession, TResult>;
21
+ sla?: {
22
+ followUpTask?: VoiceOpsSLABreachPolicy;
23
+ };
24
+ sinks?: VoiceOpsRuntimeSinkWorkerConfig;
25
+ tasks?: VoiceOpsRuntimeTaskWorkerConfig;
26
+ webhooks?: VoiceOpsRuntimeWebhookWorkerConfig;
27
+ };
28
+ export type VoiceOpsRuntimeTickResult = {
29
+ sla?: {
30
+ breached: number;
31
+ events: number;
32
+ followUpTasks: number;
33
+ };
34
+ sinks?: VoiceIntegrationSinkWorkerResult;
35
+ tasks?: VoiceOpsTaskProcessorWorkerResult;
36
+ webhooks?: VoiceWebhookDeliveryWorkerResult;
37
+ };
38
+ export type VoiceOpsRuntimeSummary = {
39
+ sinks?: VoiceIntegrationEventQueueSummary;
40
+ tasks?: VoiceOpsTaskQueueSummary;
41
+ webhooks?: VoiceIntegrationEventQueueSummary;
42
+ };
43
+ export type VoiceOpsRuntime<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
44
+ isRunning: () => boolean;
45
+ checkSLA: (input?: {
46
+ at?: number;
47
+ }) => Promise<{
48
+ breached: number;
49
+ events: number;
50
+ followUpTasks: number;
51
+ }>;
52
+ record: (input: {
53
+ api: VoiceSessionHandle<TContext, TSession, TResult>;
54
+ context: TContext;
55
+ disposition: VoiceCallDisposition;
56
+ metadata?: Record<string, unknown>;
57
+ reason?: string;
58
+ session: TSession;
59
+ target?: string;
60
+ }) => Promise<void>;
61
+ start: () => void;
62
+ stop: () => void;
63
+ summarize: () => Promise<VoiceOpsRuntimeSummary>;
64
+ tick: () => Promise<VoiceOpsRuntimeTickResult>;
65
+ };
66
+ export declare const createVoiceOpsRuntime: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(config: VoiceOpsRuntimeConfig<TContext, TSession, TResult>) => VoiceOpsRuntime<TContext, TSession, TResult>;
@@ -0,0 +1,149 @@
1
+ import type { StoredVoiceIntegrationEvent, VoiceExternalObjectMapStore, VoiceIntegrationDeliveryStatus, VoiceIntegrationEventType, VoiceIntegrationWebhookConfig } from './ops';
2
+ export type VoiceIntegrationSinkDeliveryResult = {
3
+ attempts: number;
4
+ deliveredAt?: number;
5
+ deliveredTo?: string;
6
+ error?: string;
7
+ responseBody?: unknown;
8
+ status: VoiceIntegrationDeliveryStatus;
9
+ };
10
+ export type VoiceIntegrationSink = {
11
+ deliver: (input: {
12
+ event: StoredVoiceIntegrationEvent;
13
+ }) => Promise<VoiceIntegrationSinkDeliveryResult> | VoiceIntegrationSinkDeliveryResult;
14
+ eventTypes?: VoiceIntegrationEventType[];
15
+ id: string;
16
+ kind?: string;
17
+ };
18
+ export type VoiceIntegrationHTTPSinkOptions<TBody extends Record<string, unknown> = Record<string, unknown>> = VoiceIntegrationWebhookConfig & {
19
+ body?: (input: {
20
+ event: StoredVoiceIntegrationEvent;
21
+ }) => TBody | Promise<TBody>;
22
+ id: string;
23
+ kind?: string;
24
+ method?: 'POST' | 'PUT' | 'PATCH';
25
+ };
26
+ export type VoiceHelpdeskTicketSinkOptions = VoiceIntegrationHTTPSinkOptions & {
27
+ project?: string;
28
+ };
29
+ export type VoiceCRMActivitySinkOptions = VoiceIntegrationHTTPSinkOptions & {
30
+ pipeline?: string;
31
+ };
32
+ export type VoiceZendeskTicketSinkOptions = Omit<VoiceIntegrationHTTPSinkOptions, 'body' | 'url'> & {
33
+ accessToken: string;
34
+ baseUrl?: string;
35
+ buildTicket?: (input: {
36
+ event: StoredVoiceIntegrationEvent;
37
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>;
38
+ externalObjects?: VoiceExternalObjectMapStore;
39
+ resolveExternalId?: (input: {
40
+ event: StoredVoiceIntegrationEvent;
41
+ responseBody: unknown;
42
+ }) => Promise<string | undefined> | string | undefined;
43
+ requester?: {
44
+ email?: string;
45
+ name?: string;
46
+ };
47
+ subdomain?: string;
48
+ };
49
+ export type VoiceZendeskTicketSyncSinkOptions = Omit<VoiceZendeskTicketSinkOptions, 'eventTypes'> & {
50
+ create?: Partial<VoiceZendeskTicketSinkOptions>;
51
+ createId?: string;
52
+ update?: Partial<VoiceZendeskTicketUpdateSinkOptions>;
53
+ updateId?: string;
54
+ };
55
+ type VoiceSinkValueResolver = string | ((input: {
56
+ event: StoredVoiceIntegrationEvent;
57
+ }) => Promise<string | undefined> | string | undefined);
58
+ export type VoiceZendeskTicketUpdateSinkOptions = Omit<VoiceIntegrationHTTPSinkOptions, 'body' | 'url'> & {
59
+ accessToken: string;
60
+ baseUrl?: string;
61
+ buildTicket?: (input: {
62
+ event: StoredVoiceIntegrationEvent;
63
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>;
64
+ externalObjects?: VoiceExternalObjectMapStore;
65
+ status?: string;
66
+ subdomain?: string;
67
+ ticketId?: VoiceSinkValueResolver;
68
+ };
69
+ export type VoiceHubSpotTaskSinkOptions = Omit<VoiceIntegrationHTTPSinkOptions, 'body' | 'url'> & {
70
+ accessToken: string;
71
+ associations?: Array<Record<string, unknown>> | ((input: {
72
+ event: StoredVoiceIntegrationEvent;
73
+ }) => Array<Record<string, unknown>> | Promise<Array<Record<string, unknown>>>);
74
+ baseUrl?: string;
75
+ buildProperties?: (input: {
76
+ event: StoredVoiceIntegrationEvent;
77
+ }) => Record<string, string | number> | Promise<Record<string, string | number>>;
78
+ externalObjects?: VoiceExternalObjectMapStore;
79
+ ownerId?: string;
80
+ resolveExternalId?: (input: {
81
+ event: StoredVoiceIntegrationEvent;
82
+ responseBody: unknown;
83
+ }) => Promise<string | undefined> | string | undefined;
84
+ };
85
+ export type VoiceHubSpotTaskSyncSinkOptions = Omit<VoiceHubSpotTaskSinkOptions, 'eventTypes'> & {
86
+ create?: Partial<VoiceHubSpotTaskSinkOptions>;
87
+ createId?: string;
88
+ update?: Partial<VoiceHubSpotTaskUpdateSinkOptions>;
89
+ updateId?: string;
90
+ };
91
+ export type VoiceHubSpotTaskUpdateSinkOptions = Omit<VoiceIntegrationHTTPSinkOptions, 'body' | 'url'> & {
92
+ accessToken: string;
93
+ baseUrl?: string;
94
+ buildProperties?: (input: {
95
+ event: StoredVoiceIntegrationEvent;
96
+ }) => Record<string, string | number> | Promise<Record<string, string | number>>;
97
+ externalObjects?: VoiceExternalObjectMapStore;
98
+ taskId?: VoiceSinkValueResolver;
99
+ };
100
+ export type VoiceLinearIssueSinkOptions = Omit<VoiceIntegrationHTTPSinkOptions, 'body' | 'url'> & {
101
+ apiKey?: string;
102
+ authMode?: 'api-key' | 'bearer';
103
+ accessToken?: string;
104
+ apiUrl?: string;
105
+ buildIssueInput?: (input: {
106
+ event: StoredVoiceIntegrationEvent;
107
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>;
108
+ externalObjects?: VoiceExternalObjectMapStore;
109
+ resolveExternalId?: (input: {
110
+ event: StoredVoiceIntegrationEvent;
111
+ responseBody: unknown;
112
+ }) => Promise<string | undefined> | string | undefined;
113
+ teamId: string;
114
+ };
115
+ export type VoiceLinearIssueSyncSinkOptions = Omit<VoiceLinearIssueSinkOptions, 'eventTypes'> & {
116
+ create?: Partial<VoiceLinearIssueSinkOptions>;
117
+ createId?: string;
118
+ update?: Partial<VoiceLinearIssueUpdateSinkOptions>;
119
+ updateId?: string;
120
+ };
121
+ export type VoiceLinearIssueUpdateSinkOptions = Omit<VoiceIntegrationHTTPSinkOptions, 'body' | 'url'> & {
122
+ apiKey?: string;
123
+ authMode?: 'api-key' | 'bearer';
124
+ accessToken?: string;
125
+ apiUrl?: string;
126
+ buildIssueInput?: (input: {
127
+ event: StoredVoiceIntegrationEvent;
128
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>;
129
+ externalObjects?: VoiceExternalObjectMapStore;
130
+ issueId?: VoiceSinkValueResolver;
131
+ stateId?: string;
132
+ };
133
+ export declare const createVoiceIntegrationHTTPSink: <TBody extends Record<string, unknown> = Record<string, unknown>>(options: VoiceIntegrationHTTPSinkOptions<TBody>) => VoiceIntegrationSink;
134
+ export declare const createVoiceHelpdeskTicketSink: (options: VoiceHelpdeskTicketSinkOptions) => VoiceIntegrationSink;
135
+ export declare const createVoiceCRMActivitySink: (options: VoiceCRMActivitySinkOptions) => VoiceIntegrationSink;
136
+ export declare const createVoiceZendeskTicketSink: (options: VoiceZendeskTicketSinkOptions) => VoiceIntegrationSink;
137
+ export declare const createVoiceZendeskTicketUpdateSink: (options: VoiceZendeskTicketUpdateSinkOptions) => VoiceIntegrationSink;
138
+ export declare const createVoiceZendeskTicketSyncSinks: (options: VoiceZendeskTicketSyncSinkOptions) => VoiceIntegrationSink[];
139
+ export declare const createVoiceHubSpotTaskSink: (options: VoiceHubSpotTaskSinkOptions) => VoiceIntegrationSink;
140
+ export declare const createVoiceHubSpotTaskUpdateSink: (options: VoiceHubSpotTaskUpdateSinkOptions) => VoiceIntegrationSink;
141
+ export declare const createVoiceHubSpotTaskSyncSinks: (options: VoiceHubSpotTaskSyncSinkOptions) => VoiceIntegrationSink[];
142
+ export declare const createVoiceLinearIssueSink: (options: VoiceLinearIssueSinkOptions) => VoiceIntegrationSink;
143
+ export declare const createVoiceLinearIssueSyncSinks: (options: VoiceLinearIssueSyncSinkOptions) => VoiceIntegrationSink[];
144
+ export declare const createVoiceLinearIssueUpdateSink: (options: VoiceLinearIssueUpdateSinkOptions) => VoiceIntegrationSink;
145
+ export declare const deliverVoiceIntegrationEventToSinks: (input: {
146
+ event: StoredVoiceIntegrationEvent;
147
+ sinks: VoiceIntegrationSink[];
148
+ }) => Promise<StoredVoiceIntegrationEvent>;
149
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { VoiceOpsTaskPriority } from './ops';
2
+ import type { VoiceRuntimeOpsConfig, VoiceSessionRecord } from './types';
3
+ export type VoiceOutcomeRecipeName = 'appointment-booking' | 'lead-qualification' | 'support-triage' | 'voicemail-callback' | 'warm-transfer';
4
+ export type VoiceOutcomeRecipeOptions = {
5
+ assignee?: string;
6
+ completedCreatesTask?: boolean;
7
+ dueInMs?: number;
8
+ escalationAssignee?: string;
9
+ escalationQueue?: string;
10
+ priority?: VoiceOpsTaskPriority;
11
+ queue?: string;
12
+ target?: string;
13
+ };
14
+ export type VoiceOutcomeRecipe<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Pick<VoiceRuntimeOpsConfig<TContext, TSession, TResult>, 'createTaskFromReview' | 'resolveTaskPolicy' | 'taskAssignmentRules' | 'taskPolicies'> & {
15
+ description: string;
16
+ name: VoiceOutcomeRecipeName;
17
+ };
18
+ export declare const resolveVoiceOutcomeRecipe: <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(name: VoiceOutcomeRecipeName, options?: VoiceOutcomeRecipeOptions) => VoiceOutcomeRecipe<TContext, TSession, TResult>;
@@ -0,0 +1,31 @@
1
+ import { type StoredVoiceTraceEvent, type VoiceTraceSinkDeliveryRecord, type VoiceTraceSinkDeliveryStore, type VoiceTraceEventStore } from './trace';
2
+ import type { StoredVoiceIntegrationEvent, StoredVoiceExternalObjectMap, StoredVoiceOpsTask, VoiceExternalObjectMapStore, VoiceIntegrationEventStore, VoiceOpsTaskStore } from './ops';
3
+ import type { StoredVoiceCallReviewArtifact, VoiceCallReviewStore } from './testing/review';
4
+ import type { VoiceSessionRecord, VoiceSessionStore } from './types';
5
+ export type VoicePostgresClient = {
6
+ unsafe: <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, parameters?: unknown[]) => Promise<TRow[]>;
7
+ };
8
+ export type VoicePostgresStoreOptions = {
9
+ connectionString?: string;
10
+ schemaName?: string;
11
+ sql?: VoicePostgresClient;
12
+ tableName?: string;
13
+ tablePrefix?: string;
14
+ };
15
+ export type VoicePostgresRuntimeStorage<TSession extends VoiceSessionRecord = VoiceSessionRecord, TReview extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact, TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask, TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent, TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap, TTrace extends StoredVoiceTraceEvent = StoredVoiceTraceEvent, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord> = {
16
+ events: VoiceIntegrationEventStore<TEvent>;
17
+ externalObjects: VoiceExternalObjectMapStore<TMapping>;
18
+ reviews: VoiceCallReviewStore<TReview>;
19
+ session: VoiceSessionStore<TSession>;
20
+ tasks: VoiceOpsTaskStore<TTask>;
21
+ traceDeliveries: VoiceTraceSinkDeliveryStore<TTraceDelivery>;
22
+ traces: VoiceTraceEventStore<TTrace>;
23
+ };
24
+ export declare const createVoicePostgresSessionStore: <TSession extends VoiceSessionRecord = VoiceSessionRecord>(options: VoicePostgresStoreOptions) => VoiceSessionStore<TSession>;
25
+ export declare const createVoicePostgresReviewStore: <TArtifact extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact>(options: VoicePostgresStoreOptions) => VoiceCallReviewStore<TArtifact>;
26
+ export declare const createVoicePostgresTaskStore: <TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask>(options: VoicePostgresStoreOptions) => VoiceOpsTaskStore<TTask>;
27
+ export declare const createVoicePostgresIntegrationEventStore: <TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent>(options: VoicePostgresStoreOptions) => VoiceIntegrationEventStore<TEvent>;
28
+ export declare const createVoicePostgresExternalObjectMapStore: <TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap>(options: VoicePostgresStoreOptions) => VoiceExternalObjectMapStore<TMapping>;
29
+ export declare const createVoicePostgresTraceEventStore: <TEvent extends StoredVoiceTraceEvent = StoredVoiceTraceEvent>(options: VoicePostgresStoreOptions) => VoiceTraceEventStore<TEvent>;
30
+ export declare const createVoicePostgresTraceSinkDeliveryStore: <TDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord>(options: VoicePostgresStoreOptions) => VoiceTraceSinkDeliveryStore<TDelivery>;
31
+ export declare const createVoicePostgresRuntimeStorage: <TSession extends VoiceSessionRecord = VoiceSessionRecord, TReview extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact, TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask, TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent, TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap, TTrace extends StoredVoiceTraceEvent = StoredVoiceTraceEvent, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord>(options: VoicePostgresStoreOptions) => VoicePostgresRuntimeStorage<TSession, TReview, TTask, TEvent, TMapping, TTrace, TTraceDelivery>;