@roarkanalytics/sdk 3.5.0 → 3.7.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 (67) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/client.d.mts +7 -4
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +7 -4
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/call.d.mts +199 -1
  12. package/resources/call.d.mts.map +1 -1
  13. package/resources/call.d.ts +199 -1
  14. package/resources/call.d.ts.map +1 -1
  15. package/resources/call.js +30 -0
  16. package/resources/call.js.map +1 -1
  17. package/resources/call.mjs +30 -0
  18. package/resources/call.mjs.map +1 -1
  19. package/resources/config.d.mts +1 -1
  20. package/resources/config.d.mts.map +1 -1
  21. package/resources/config.d.ts +1 -1
  22. package/resources/config.d.ts.map +1 -1
  23. package/resources/customer-flow.d.mts +17 -2
  24. package/resources/customer-flow.d.mts.map +1 -1
  25. package/resources/customer-flow.d.ts +17 -2
  26. package/resources/customer-flow.d.ts.map +1 -1
  27. package/resources/index.d.mts +3 -2
  28. package/resources/index.d.mts.map +1 -1
  29. package/resources/index.d.ts +3 -2
  30. package/resources/index.d.ts.map +1 -1
  31. package/resources/index.js +3 -1
  32. package/resources/index.js.map +1 -1
  33. package/resources/index.mjs +1 -0
  34. package/resources/index.mjs.map +1 -1
  35. package/resources/metric-variant.d.mts +357 -0
  36. package/resources/metric-variant.d.mts.map +1 -0
  37. package/resources/metric-variant.d.ts +357 -0
  38. package/resources/metric-variant.d.ts.map +1 -0
  39. package/resources/metric-variant.js +112 -0
  40. package/resources/metric-variant.js.map +1 -0
  41. package/resources/metric-variant.mjs +108 -0
  42. package/resources/metric-variant.mjs.map +1 -0
  43. package/resources/metric.d.mts +696 -1
  44. package/resources/metric.d.mts.map +1 -1
  45. package/resources/metric.d.ts +696 -1
  46. package/resources/metric.d.ts.map +1 -1
  47. package/resources/metric.js +22 -0
  48. package/resources/metric.js.map +1 -1
  49. package/resources/metric.mjs +22 -0
  50. package/resources/metric.mjs.map +1 -1
  51. package/resources/simulation-job.d.mts +90 -0
  52. package/resources/simulation-job.d.mts.map +1 -1
  53. package/resources/simulation-job.d.ts +90 -0
  54. package/resources/simulation-job.d.ts.map +1 -1
  55. package/src/client.ts +35 -0
  56. package/src/resources/call.ts +236 -0
  57. package/src/resources/config.ts +1 -0
  58. package/src/resources/customer-flow.ts +24 -2
  59. package/src/resources/index.ts +16 -0
  60. package/src/resources/metric-variant.ts +458 -0
  61. package/src/resources/metric.ts +1008 -124
  62. package/src/resources/simulation-job.ts +104 -0
  63. package/src/version.ts +1 -1
  64. package/version.d.mts +1 -1
  65. package/version.d.ts +1 -1
  66. package/version.js +1 -1
  67. package/version.mjs +1 -1
@@ -38,6 +38,41 @@ export class Call extends APIResource {
38
38
  return this._client.get('/v1/call', { query, ...options });
39
39
  }
40
40
 
41
+ /**
42
+ * Attach tool invocations that fired during a call to an already-existing call,
43
+ * asynchronously after the call was created. Use this when the tool-call data
44
+ * becomes available later than the call itself (e.g. a Roark simulation, or a call
45
+ * submitted via POST /v1/call before its tools were ready). Writes are idempotent:
46
+ * re-sending an invocation already present on the call (same tool name and timing)
47
+ * is skipped, so retries converge instead of double-counting. Optionally pass
48
+ * `metrics` to (re)score metrics over the newly attached tools, which triggers a
49
+ * billed metric collection job and requires the `metric:create` permission.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const response = await client.call.appendToolInvocations(
54
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
55
+ * {
56
+ * toolInvocations: [
57
+ * {
58
+ * name: 'name',
59
+ * parameters: { foo: 'string' },
60
+ * result: 'string',
61
+ * startOffsetMs: 0,
62
+ * },
63
+ * ],
64
+ * },
65
+ * );
66
+ * ```
67
+ */
68
+ appendToolInvocations(
69
+ callID: string,
70
+ body: CallAppendToolInvocationsParams,
71
+ options?: RequestOptions,
72
+ ): APIPromise<CallAppendToolInvocationsResponse> {
73
+ return this._client.post(path`/v1/call/${callID}/tool-invocations`, { body, ...options });
74
+ }
75
+
41
76
  /**
42
77
  * Retrieve an existing call by its unique identifier
43
78
  *
@@ -358,6 +393,117 @@ export namespace CallListResponse {
358
393
  }
359
394
  }
360
395
 
396
+ export interface CallAppendToolInvocationsResponse {
397
+ /**
398
+ * Result of appending tool invocations to a call.
399
+ */
400
+ data: CallAppendToolInvocationsResponse.Data;
401
+ }
402
+
403
+ export namespace CallAppendToolInvocationsResponse {
404
+ /**
405
+ * Result of appending tool invocations to a call.
406
+ */
407
+ export interface Data {
408
+ /**
409
+ * Number of tool invocations newly written
410
+ */
411
+ added: number;
412
+
413
+ /**
414
+ * The call the tool invocations were attached to
415
+ */
416
+ callId: string;
417
+
418
+ /**
419
+ * Present (non-null) only when `metrics` were requested but the collection job
420
+ * could not be started (e.g. insufficient credits, or an unknown metric id). The
421
+ * tool invocations were still attached — retry scoring via POST
422
+ * /v1/metric/collection-jobs, or re-send this request (attaching is idempotent).
423
+ * Null on success or when no metrics were requested.
424
+ */
425
+ metricCollectionError: string | null;
426
+
427
+ /**
428
+ * A metric collection job that processes metrics for calls or chats
429
+ */
430
+ metricCollectionJob: Data.MetricCollectionJob | null;
431
+
432
+ /**
433
+ * Number of tool invocations skipped because an identical one (same tool and
434
+ * timing) already existed on the call
435
+ */
436
+ skipped: number;
437
+ }
438
+
439
+ export namespace Data {
440
+ /**
441
+ * A metric collection job that processes metrics for calls or chats
442
+ */
443
+ export interface MetricCollectionJob {
444
+ /**
445
+ * Unique identifier of the metric collection job
446
+ */
447
+ id: string;
448
+
449
+ /**
450
+ * When the job completed
451
+ */
452
+ completedAt: string | null;
453
+
454
+ /**
455
+ * Number of successfully completed items
456
+ */
457
+ completedItems: number;
458
+
459
+ /**
460
+ * When the job was created
461
+ */
462
+ createdAt: string;
463
+
464
+ /**
465
+ * Error message if the job failed
466
+ */
467
+ errorMessage: string | null;
468
+
469
+ /**
470
+ * Number of failed items
471
+ */
472
+ failedItems: number;
473
+
474
+ /**
475
+ * IDs of the metric policies that triggered this job
476
+ */
477
+ policyIds: Array<string>;
478
+
479
+ /**
480
+ * When the job started processing
481
+ */
482
+ startedAt: string | null;
483
+
484
+ /**
485
+ * Current status of the job
486
+ */
487
+ status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'CANCELED';
488
+
489
+ /**
490
+ * Total number of call-metric pairs to process
491
+ */
492
+ totalItems: number;
493
+
494
+ /**
495
+ * What triggered this job
496
+ */
497
+ triggeredBy: 'USER_MANUAL' | 'USER_API' | 'METRIC_POLICY' | 'SIMULATION';
498
+
499
+ /**
500
+ * When the job was last updated
501
+ */
502
+ updatedAt: string;
503
+ }
504
+ }
505
+ }
506
+
361
507
  export interface CallGetByIDResponse {
362
508
  /**
363
509
  * Response containing call information
@@ -1657,6 +1803,94 @@ export interface CallListParams {
1657
1803
  status?: 'RINGING' | 'IN_PROGRESS' | 'ENDED';
1658
1804
  }
1659
1805
 
1806
+ export interface CallAppendToolInvocationsParams {
1807
+ /**
1808
+ * Tool invocations that fired during the call, to attach to it. Max 500 per
1809
+ * request. Re-sending an invocation already present on the call (same tool name
1810
+ * and timing) is skipped, so retries are safe.
1811
+ */
1812
+ toolInvocations: Array<CallAppendToolInvocationsParams.ToolInvocation>;
1813
+
1814
+ /**
1815
+ * Optional. Metric definitions to (re)score on this call after the tool
1816
+ * invocations are attached, e.g. the Tool Invocation Analysis metrics. Triggers a
1817
+ * metric collection job (billed, credit-gated) and requires the 'metric:create'
1818
+ * permission. Omit to attach tools without scoring. Max 20.
1819
+ */
1820
+ metrics?: Array<CallAppendToolInvocationsParams.Metric>;
1821
+ }
1822
+
1823
+ export namespace CallAppendToolInvocationsParams {
1824
+ export interface ToolInvocation {
1825
+ /**
1826
+ * Name of the tool that was invoked
1827
+ */
1828
+ name: string;
1829
+
1830
+ /**
1831
+ * Parameters provided to the tool during invocation
1832
+ */
1833
+ parameters: { [key: string]: ToolInvocation.UnionMember0 | unknown };
1834
+
1835
+ /**
1836
+ * Result returned by the tool after execution. Can be a string or a JSON object
1837
+ */
1838
+ result: string | { [key: string]: unknown };
1839
+
1840
+ /**
1841
+ * Offset in milliseconds from the start of the call when the tool was invoked
1842
+ */
1843
+ startOffsetMs: number;
1844
+
1845
+ /**
1846
+ * Metadata about the agent that invoked this tool - used to match which agent from
1847
+ * the agents array this tool invocation belongs to
1848
+ */
1849
+ agent?: ToolInvocation.Agent;
1850
+
1851
+ /**
1852
+ * Description of when the tool should be invoked
1853
+ */
1854
+ description?: string;
1855
+
1856
+ /**
1857
+ * Offset in milliseconds from the start of the call when the tool execution
1858
+ * completed. Used to calculate duration of the tool execution
1859
+ */
1860
+ endOffsetMs?: number;
1861
+ }
1862
+
1863
+ export namespace ToolInvocation {
1864
+ export interface UnionMember0 {
1865
+ description?: string;
1866
+
1867
+ type?: 'string' | 'number' | 'boolean';
1868
+
1869
+ value?: unknown;
1870
+ }
1871
+
1872
+ /**
1873
+ * Metadata about the agent that invoked this tool - used to match which agent from
1874
+ * the agents array this tool invocation belongs to
1875
+ */
1876
+ export interface Agent {
1877
+ /**
1878
+ * The custom ID set on the agent
1879
+ */
1880
+ customId?: string;
1881
+
1882
+ /**
1883
+ * The Roark ID of the agent
1884
+ */
1885
+ roarkId?: string;
1886
+ }
1887
+ }
1888
+
1889
+ export interface Metric {
1890
+ id: string;
1891
+ }
1892
+ }
1893
+
1660
1894
  export interface CallGetTranscriptParams {
1661
1895
  /**
1662
1896
  * Transcription source to fetch. When omitted, uses the preferred source based on
@@ -1687,12 +1921,14 @@ export declare namespace Call {
1687
1921
  export {
1688
1922
  type CallCreateResponse as CallCreateResponse,
1689
1923
  type CallListResponse as CallListResponse,
1924
+ type CallAppendToolInvocationsResponse as CallAppendToolInvocationsResponse,
1690
1925
  type CallGetByIDResponse as CallGetByIDResponse,
1691
1926
  type CallGetTranscriptResponse as CallGetTranscriptResponse,
1692
1927
  type CallListMetricsResponse as CallListMetricsResponse,
1693
1928
  type CallListSentimentRunsResponse as CallListSentimentRunsResponse,
1694
1929
  type CallCreateParams as CallCreateParams,
1695
1930
  type CallListParams as CallListParams,
1931
+ type CallAppendToolInvocationsParams as CallAppendToolInvocationsParams,
1696
1932
  type CallGetTranscriptParams as CallGetTranscriptParams,
1697
1933
  type CallListMetricsParams as CallListMetricsParams,
1698
1934
  };
@@ -371,6 +371,7 @@ export interface ConfigFlowStep {
371
371
  | 'CUSTOMER_FIRST_MESSAGE'
372
372
  | 'CUSTOMER_SILENCE'
373
373
  | 'CUSTOMER_DTMF'
374
+ | 'AGENT_DTMF'
374
375
  | 'VOICEMAIL'
375
376
  | 'SCENARIO_LINK';
376
377
 
@@ -164,6 +164,13 @@ export class CustomerFlow extends APIResource {
164
164
  * under the first branch that reaches it and point the others at it: a top-level
165
165
  * step is a root wired straight from the start of the flow, so a merge target
166
166
  * parked there would also be reachable directly.
167
+ *
168
+ * The two DTMF types are mirror images and both require `dtmfDigits`.
169
+ * `CUSTOMER_DTMF` is keys the simulated caller presses while navigating your
170
+ * agent. `AGENT_DTMF` is keys your agent under test is expected to press while
171
+ * navigating a menu the simulation is playing, so its digits are an assertion the
172
+ * run is graded against rather than an instruction, and it counts as an agent turn
173
+ * for role alternation.
167
174
  */
168
175
  export type FlowStep =
169
176
  | FlowStep.UnionMember0
@@ -172,7 +179,8 @@ export type FlowStep =
172
179
  | FlowStep.UnionMember3
173
180
  | FlowStep.UnionMember4
174
181
  | FlowStep.UnionMember5
175
- | FlowStep.UnionMember6;
182
+ | FlowStep.UnionMember6
183
+ | FlowStep.UnionMember7;
176
184
 
177
185
  export namespace FlowStep {
178
186
  export interface UnionMember0 {
@@ -246,7 +254,9 @@ export namespace FlowStep {
246
254
  }
247
255
 
248
256
  export interface UnionMember5 {
249
- type: 'VOICEMAIL';
257
+ type: 'AGENT_DTMF';
258
+
259
+ dtmfDigits?: string | null;
250
260
 
251
261
  mergeIntoNodeIds?: Array<string>;
252
262
 
@@ -258,6 +268,18 @@ export namespace FlowStep {
258
268
  }
259
269
 
260
270
  export interface UnionMember6 {
271
+ type: 'VOICEMAIL';
272
+
273
+ mergeIntoNodeIds?: Array<string>;
274
+
275
+ nodeId?: string;
276
+
277
+ ref?: string;
278
+
279
+ steps?: Array<CustomerFlowAPI.FlowStep>;
280
+ }
281
+
282
+ export interface UnionMember7 {
261
283
  type: 'SCENARIO_LINK';
262
284
 
263
285
  linkedCustomerFlowId?: string | null;
@@ -24,12 +24,14 @@ export {
24
24
  Call,
25
25
  type CallCreateResponse,
26
26
  type CallListResponse,
27
+ type CallAppendToolInvocationsResponse,
27
28
  type CallGetByIDResponse,
28
29
  type CallGetTranscriptResponse,
29
30
  type CallListMetricsResponse,
30
31
  type CallListSentimentRunsResponse,
31
32
  type CallCreateParams,
32
33
  type CallListParams,
34
+ type CallAppendToolInvocationsParams,
33
35
  type CallGetTranscriptParams,
34
36
  type CallListMetricsParams,
35
37
  } from './call';
@@ -84,8 +86,10 @@ export {
84
86
  Metric,
85
87
  type MetricCreateDefinitionResponse,
86
88
  type MetricListDefinitionsResponse,
89
+ type MetricUpdateDefinitionResponse,
87
90
  type MetricCreateDefinitionParams,
88
91
  type MetricListDefinitionsParams,
92
+ type MetricUpdateDefinitionParams,
89
93
  } from './metric';
90
94
  export {
91
95
  MetricCollectionJob,
@@ -106,6 +110,18 @@ export {
106
110
  type MetricPolicyUpdateParams,
107
111
  type MetricPolicyListParams,
108
112
  } from './metric-policy';
113
+ export {
114
+ MetricVariant,
115
+ type MetricVariantCreateResponse,
116
+ type MetricVariantUpdateResponse,
117
+ type MetricVariantListResponse,
118
+ type MetricVariantDeleteResponse,
119
+ type MetricVariantGetByIDResponse,
120
+ type MetricVariantCreateParams,
121
+ type MetricVariantUpdateParams,
122
+ type MetricVariantDeleteParams,
123
+ type MetricVariantGetByIDParams,
124
+ } from './metric-variant';
109
125
  export { Simulation, type SimulationRunResponse, type SimulationRunParams } from './simulation';
110
126
  export {
111
127
  SimulationEnvironment,