@roarkanalytics/sdk 5.11.0 → 5.13.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 (44) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/lib/config.d.mts +45 -0
  9. package/lib/config.d.mts.map +1 -0
  10. package/lib/config.d.ts +45 -0
  11. package/lib/config.d.ts.map +1 -0
  12. package/lib/config.js +91 -0
  13. package/lib/config.js.map +1 -0
  14. package/lib/config.mjs +73 -0
  15. package/lib/config.mjs.map +1 -0
  16. package/package.json +11 -1
  17. package/resources/call.d.mts +12 -6
  18. package/resources/call.d.mts.map +1 -1
  19. package/resources/call.d.ts +12 -6
  20. package/resources/call.d.ts.map +1 -1
  21. package/resources/index.d.mts +1 -1
  22. package/resources/index.d.mts.map +1 -1
  23. package/resources/index.d.ts +1 -1
  24. package/resources/index.d.ts.map +1 -1
  25. package/resources/index.js.map +1 -1
  26. package/resources/index.mjs.map +1 -1
  27. package/resources/metric-collection-job.d.mts +102 -10
  28. package/resources/metric-collection-job.d.mts.map +1 -1
  29. package/resources/metric-collection-job.d.ts +102 -10
  30. package/resources/metric-collection-job.d.ts.map +1 -1
  31. package/resources/metric-collection-job.js +21 -0
  32. package/resources/metric-collection-job.js.map +1 -1
  33. package/resources/metric-collection-job.mjs +21 -0
  34. package/resources/metric-collection-job.mjs.map +1 -1
  35. package/src/client.ts +2 -0
  36. package/src/lib/config.ts +131 -0
  37. package/src/resources/call.ts +12 -6
  38. package/src/resources/index.ts +1 -0
  39. package/src/resources/metric-collection-job.ts +118 -9
  40. package/src/version.ts +1 -1
  41. package/version.d.mts +1 -1
  42. package/version.d.ts +1 -1
  43. package/version.js +1 -1
  44. package/version.mjs +1 -1
@@ -0,0 +1,131 @@
1
+ // Code-first config authoring: a typed, ergonomic alternative to hand-written
2
+ // config YAML. Build agents, tools, personas, flows, metrics and the rest in
3
+ // TypeScript, then ship them with `client.config.apply(...)` (or preview with
4
+ // `client.config.diff(...)`).
5
+ //
6
+ // Each `define*` helper injects the resource's `kind` (and any fixed
7
+ // discriminator) and returns the exact param object the config endpoints expect,
8
+ // so the output is identical to the YAML path: both produce a config bundle.
9
+ // Input types are DERIVED from the generated `ConfigApplyParams`, so a new field
10
+ // on a resource (for example a tool `handler`) shows up here automatically on the
11
+ // next codegen, with no change to this file.
12
+ //
13
+ // This lives in `src/lib`, which Stainless codegen never touches. Import it from
14
+ // `@roarkanalytics/sdk/lib/config`.
15
+
16
+ import type { ConfigApplyParams } from '../resources/config';
17
+
18
+ // ── Cross-references ──
19
+ // A resource that points at another by name accepts either the construct a
20
+ // `define*` helper returned (its `name` is used) or a bare name string.
21
+ export type Ref<T extends { name: string }> = T | string;
22
+
23
+ const refName = <T extends { name: string }>(ref: Ref<T>): string =>
24
+ typeof ref === 'string' ? ref : ref.name;
25
+
26
+ // ── Friendly aliases for the generated param types ──
27
+ export type AgentConfig = ConfigApplyParams.AgentConfig;
28
+ export type HTTPRequestDefinitionConfig = ConfigApplyParams.HTTPRequestDefinitionConfig;
29
+ export type PersonaConfig = ConfigApplyParams.PersonaConfig;
30
+ export type ImprovFlowConfig = ConfigApplyParams.ImprovFlowConfig;
31
+ export type ScriptedFlowConfig = ConfigApplyParams.ScriptedFlowConfig;
32
+ export type CollectorConfig = ConfigApplyParams.CollectorConfig;
33
+ export type MetricConfig = ConfigApplyParams.MetricConfig;
34
+ export type SimulationPlanConfig = ConfigApplyParams.SimulationPlanConfig;
35
+ export type QaSimulationPlanConfig = ConfigApplyParams.QaSimulationPlanConfig;
36
+ export type SimulationGroupConfig = ConfigApplyParams.SimulationGroupConfig;
37
+ export type AlertConfig = ConfigApplyParams.AlertConfig;
38
+ export type ToolConfig = ConfigApplyParams.ToolConfig;
39
+ export type DashboardConfig = ConfigApplyParams.DashboardConfig;
40
+ export type ProjectConfig = ConfigApplyParams.ProjectConfig;
41
+
42
+ /** Any resource a config bundle can carry. */
43
+ export type ResourceConfig = ConfigApplyParams['resources'][number];
44
+
45
+ // ── Builders ──
46
+ // Prompts are just strings here: pass an inline template literal or
47
+ // `readFileSync('./prompt.md', 'utf8')`. No `file://` sentinel needed.
48
+
49
+ export const defineAgent = (agent: Omit<AgentConfig, 'kind'>): AgentConfig => ({ kind: 'agent', ...agent });
50
+
51
+ export const defineHTTPRequestDefinition = (
52
+ def: Omit<HTTPRequestDefinitionConfig, 'kind'>,
53
+ ): HTTPRequestDefinitionConfig => ({ kind: 'httpRequestDefinition', ...def });
54
+
55
+ export const definePersona = (persona: Omit<PersonaConfig, 'kind'>): PersonaConfig => ({
56
+ kind: 'persona',
57
+ ...persona,
58
+ });
59
+
60
+ export const defineImprovFlow = (flow: Omit<ImprovFlowConfig, 'kind' | 'type'>): ImprovFlowConfig => ({
61
+ kind: 'flow',
62
+ type: 'improv',
63
+ ...flow,
64
+ });
65
+
66
+ export const defineScriptedFlow = (flow: Omit<ScriptedFlowConfig, 'kind' | 'type'>): ScriptedFlowConfig => ({
67
+ kind: 'flow',
68
+ type: 'scripted',
69
+ ...flow,
70
+ });
71
+
72
+ export const defineCollector = (collector: Omit<CollectorConfig, 'kind'>): CollectorConfig => ({
73
+ kind: 'collector',
74
+ ...collector,
75
+ });
76
+
77
+ export const defineMetric = (metric: Omit<MetricConfig, 'kind'>): MetricConfig => ({
78
+ kind: 'metric',
79
+ ...metric,
80
+ });
81
+
82
+ export const defineSimulationPlan = (plan: Omit<SimulationPlanConfig, 'kind'>): SimulationPlanConfig => ({
83
+ kind: 'simulationPlan',
84
+ ...plan,
85
+ });
86
+
87
+ export const defineQaSimulationPlan = (
88
+ plan: Omit<QaSimulationPlanConfig, 'kind' | 'template'>,
89
+ ): QaSimulationPlanConfig => ({ kind: 'simulationPlan', template: 'question-answer-check', ...plan });
90
+
91
+ export const defineSimulationGroup = (group: Omit<SimulationGroupConfig, 'kind'>): SimulationGroupConfig => ({
92
+ kind: 'simulationGroup',
93
+ ...group,
94
+ });
95
+
96
+ export const defineAlert = (alert: Omit<AlertConfig, 'kind'>): AlertConfig => ({ kind: 'alert', ...alert });
97
+
98
+ export const defineDashboard = (dashboard: Omit<DashboardConfig, 'kind'>): DashboardConfig => ({
99
+ kind: 'dashboard',
100
+ ...dashboard,
101
+ });
102
+
103
+ export const defineProject = (project: Omit<ProjectConfig, 'kind'>): ProjectConfig => ({
104
+ kind: 'project',
105
+ ...project,
106
+ });
107
+
108
+ /** Input to `defineTool`: `agent` accepts the agent construct or a name string. */
109
+ export type DefineToolInput = Omit<ToolConfig, 'kind' | 'agent'> & {
110
+ /** Scope the tool to one agent (omit for a project-wide tool). */
111
+ agent?: Ref<AgentConfig>;
112
+ };
113
+
114
+ export const defineTool = (tool: DefineToolInput): ToolConfig => {
115
+ const { agent, ...rest } = tool;
116
+ return { kind: 'tool', ...rest, ...(agent === undefined ? {} : { agent: refName(agent) }) };
117
+ };
118
+
119
+ // ── The bundle ──
120
+ // `defineConfig` assembles the bundle you hand to `client.config.apply(bundle)`
121
+ // or `client.config.diff(bundle)`. `resources` accepts both construct outputs
122
+ // and raw resource objects, so a kind without a dedicated builder still fits.
123
+
124
+ export const defineConfig = (bundle: {
125
+ resources: Array<ResourceConfig>;
126
+ /** When true (the server default) config-managed resources absent from the bundle are deleted. */
127
+ prune?: boolean;
128
+ }): ConfigApplyParams => ({
129
+ resources: bundle.resources,
130
+ ...(bundle.prune === undefined ? {} : { prune: bundle.prune }),
131
+ });
@@ -560,7 +560,8 @@ export namespace CallAppendToolInvocationsResponse {
560
560
  completedAt: string | null;
561
561
 
562
562
  /**
563
- * Number of successfully completed items
563
+ * Number of items that finished without failing: a value was written, or the
564
+ * metric did not apply to the conversation
564
565
  */
565
566
  completedItems: number;
566
567
 
@@ -570,12 +571,14 @@ export namespace CallAppendToolInvocationsResponse {
570
571
  createdAt: string;
571
572
 
572
573
  /**
573
- * Error message if the job failed
574
+ * Why the job failed or, on a COMPLETED job with failedItems above 0, why those
575
+ * items failed
574
576
  */
575
577
  errorMessage: string | null;
576
578
 
577
579
  /**
578
- * Number of failed items
580
+ * Number of items that could not be computed, for example because an artifact the
581
+ * metric reads (such as diarization) failed to generate
579
582
  */
580
583
  failedItems: number;
581
584
 
@@ -1764,7 +1767,8 @@ export namespace CallUpdatePropertiesResponse {
1764
1767
  completedAt: string | null;
1765
1768
 
1766
1769
  /**
1767
- * Number of successfully completed items
1770
+ * Number of items that finished without failing: a value was written, or the
1771
+ * metric did not apply to the conversation
1768
1772
  */
1769
1773
  completedItems: number;
1770
1774
 
@@ -1774,12 +1778,14 @@ export namespace CallUpdatePropertiesResponse {
1774
1778
  createdAt: string;
1775
1779
 
1776
1780
  /**
1777
- * Error message if the job failed
1781
+ * Why the job failed or, on a COMPLETED job with failedItems above 0, why those
1782
+ * items failed
1778
1783
  */
1779
1784
  errorMessage: string | null;
1780
1785
 
1781
1786
  /**
1782
- * Number of failed items
1787
+ * Number of items that could not be computed, for example because an artifact the
1788
+ * metric reads (such as diarization) failed to generate
1783
1789
  */
1784
1790
  failedItems: number;
1785
1791
 
@@ -189,6 +189,7 @@ export {
189
189
  MetricCollectionJob,
190
190
  type MetricCollectionJobCreateResponse,
191
191
  type MetricCollectionJobListResponse,
192
+ type MetricCollectionJobCancelResponse,
192
193
  type MetricCollectionJobGetByIDResponse,
193
194
  type MetricCollectionJobCreateParams,
194
195
  type MetricCollectionJobListParams,
@@ -42,6 +42,28 @@ export class MetricCollectionJob extends APIResource {
42
42
  return this._client.get('/v1/metric/collection-jobs', { query, ...options });
43
43
  }
44
44
 
45
+ /**
46
+ * Stops a metric collection job that has not finished. No further conversations
47
+ * are processed and the job ends in CANCELED.
48
+ *
49
+ * Items the job had not reached are marked SKIPPED. Metric values already produced
50
+ * are kept, and items that were mid-computation when the cancel arrived may still
51
+ * complete. Only the items that completed are billed.
52
+ *
53
+ * Safe to call more than once: a job that has already finished (COMPLETED, FAILED,
54
+ * or CANCELED) is returned unchanged.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const response = await client.metricCollectionJob.cancel(
59
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
60
+ * );
61
+ * ```
62
+ */
63
+ cancel(jobID: string, options?: RequestOptions): APIPromise<MetricCollectionJobCancelResponse> {
64
+ return this._client.post(path`/v1/metric/collection-jobs/${jobID}/cancel`, options);
65
+ }
66
+
45
67
  /**
46
68
  * Returns a specific metric collection job with progress information.
47
69
  *
@@ -80,7 +102,8 @@ export namespace MetricCollectionJobCreateResponse {
80
102
  completedAt: string | null;
81
103
 
82
104
  /**
83
- * Number of successfully completed items
105
+ * Number of items that finished without failing: a value was written, or the
106
+ * metric did not apply to the conversation
84
107
  */
85
108
  completedItems: number;
86
109
 
@@ -90,12 +113,14 @@ export namespace MetricCollectionJobCreateResponse {
90
113
  createdAt: string;
91
114
 
92
115
  /**
93
- * Error message if the job failed
116
+ * Why the job failed or, on a COMPLETED job with failedItems above 0, why those
117
+ * items failed
94
118
  */
95
119
  errorMessage: string | null;
96
120
 
97
121
  /**
98
- * Number of failed items
122
+ * Number of items that could not be computed, for example because an artifact the
123
+ * metric reads (such as diarization) failed to generate
99
124
  */
100
125
  failedItems: number;
101
126
 
@@ -156,7 +181,8 @@ export namespace MetricCollectionJobListResponse {
156
181
  completedAt: string | null;
157
182
 
158
183
  /**
159
- * Number of successfully completed items
184
+ * Number of items that finished without failing: a value was written, or the
185
+ * metric did not apply to the conversation
160
186
  */
161
187
  completedItems: number;
162
188
 
@@ -166,12 +192,14 @@ export namespace MetricCollectionJobListResponse {
166
192
  createdAt: string;
167
193
 
168
194
  /**
169
- * Error message if the job failed
195
+ * Why the job failed or, on a COMPLETED job with failedItems above 0, why those
196
+ * items failed
170
197
  */
171
198
  errorMessage: string | null;
172
199
 
173
200
  /**
174
- * Number of failed items
201
+ * Number of items that could not be computed, for example because an artifact the
202
+ * metric reads (such as diarization) failed to generate
175
203
  */
176
204
  failedItems: number;
177
205
 
@@ -224,6 +252,83 @@ export namespace MetricCollectionJobListResponse {
224
252
  }
225
253
  }
226
254
 
255
+ export interface MetricCollectionJobCancelResponse {
256
+ /**
257
+ * A metric collection job that processes metrics for calls or chats
258
+ */
259
+ data: MetricCollectionJobCancelResponse.Data;
260
+ }
261
+
262
+ export namespace MetricCollectionJobCancelResponse {
263
+ /**
264
+ * A metric collection job that processes metrics for calls or chats
265
+ */
266
+ export interface Data {
267
+ /**
268
+ * Unique identifier of the metric collection job
269
+ */
270
+ id: string;
271
+
272
+ /**
273
+ * When the job completed
274
+ */
275
+ completedAt: string | null;
276
+
277
+ /**
278
+ * Number of items that finished without failing: a value was written, or the
279
+ * metric did not apply to the conversation
280
+ */
281
+ completedItems: number;
282
+
283
+ /**
284
+ * When the job was created
285
+ */
286
+ createdAt: string;
287
+
288
+ /**
289
+ * Why the job failed or, on a COMPLETED job with failedItems above 0, why those
290
+ * items failed
291
+ */
292
+ errorMessage: string | null;
293
+
294
+ /**
295
+ * Number of items that could not be computed, for example because an artifact the
296
+ * metric reads (such as diarization) failed to generate
297
+ */
298
+ failedItems: number;
299
+
300
+ /**
301
+ * IDs of the metric policies that triggered this job
302
+ */
303
+ policyIds: Array<string>;
304
+
305
+ /**
306
+ * When the job started processing
307
+ */
308
+ startedAt: string | null;
309
+
310
+ /**
311
+ * Current status of the job
312
+ */
313
+ status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'CANCELED';
314
+
315
+ /**
316
+ * Total number of call-metric pairs to process
317
+ */
318
+ totalItems: number;
319
+
320
+ /**
321
+ * What triggered this job
322
+ */
323
+ triggeredBy: 'USER_MANUAL' | 'USER_API' | 'METRIC_POLICY' | 'SIMULATION';
324
+
325
+ /**
326
+ * When the job was last updated
327
+ */
328
+ updatedAt: string;
329
+ }
330
+ }
331
+
227
332
  export interface MetricCollectionJobGetByIDResponse {
228
333
  /**
229
334
  * A metric collection job that processes metrics for calls or chats
@@ -247,7 +352,8 @@ export namespace MetricCollectionJobGetByIDResponse {
247
352
  completedAt: string | null;
248
353
 
249
354
  /**
250
- * Number of successfully completed items
355
+ * Number of items that finished without failing: a value was written, or the
356
+ * metric did not apply to the conversation
251
357
  */
252
358
  completedItems: number;
253
359
 
@@ -257,12 +363,14 @@ export namespace MetricCollectionJobGetByIDResponse {
257
363
  createdAt: string;
258
364
 
259
365
  /**
260
- * Error message if the job failed
366
+ * Why the job failed or, on a COMPLETED job with failedItems above 0, why those
367
+ * items failed
261
368
  */
262
369
  errorMessage: string | null;
263
370
 
264
371
  /**
265
- * Number of failed items
372
+ * Number of items that could not be computed, for example because an artifact the
373
+ * metric reads (such as diarization) failed to generate
266
374
  */
267
375
  failedItems: number;
268
376
 
@@ -356,6 +464,7 @@ export declare namespace MetricCollectionJob {
356
464
  export {
357
465
  type MetricCollectionJobCreateResponse as MetricCollectionJobCreateResponse,
358
466
  type MetricCollectionJobListResponse as MetricCollectionJobListResponse,
467
+ type MetricCollectionJobCancelResponse as MetricCollectionJobCancelResponse,
359
468
  type MetricCollectionJobGetByIDResponse as MetricCollectionJobGetByIDResponse,
360
469
  type MetricCollectionJobCreateParams as MetricCollectionJobCreateParams,
361
470
  type MetricCollectionJobListParams as MetricCollectionJobListParams,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '5.11.0'; // x-release-please-version
1
+ export const VERSION = '5.13.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.11.0";
1
+ export declare const VERSION = "5.13.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.11.0";
1
+ export declare const VERSION = "5.13.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '5.11.0'; // x-release-please-version
4
+ exports.VERSION = '5.13.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '5.11.0'; // x-release-please-version
1
+ export const VERSION = '5.13.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map