@roarkanalytics/sdk 3.21.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/client.d.mts +6 -3
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +6 -3
  5. package/client.d.ts.map +1 -1
  6. package/client.js +6 -3
  7. package/client.js.map +1 -1
  8. package/client.mjs +6 -3
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/agent-config.d.mts +394 -0
  12. package/resources/agent-config.d.mts.map +1 -0
  13. package/resources/agent-config.d.ts +394 -0
  14. package/resources/agent-config.d.ts.map +1 -0
  15. package/resources/agent-config.js +98 -0
  16. package/resources/agent-config.js.map +1 -0
  17. package/resources/agent-config.mjs +94 -0
  18. package/resources/agent-config.mjs.map +1 -0
  19. package/resources/{autoimprove-fix.d.mts → autoimprove-job.d.mts} +117 -116
  20. package/resources/autoimprove-job.d.mts.map +1 -0
  21. package/resources/{autoimprove-fix.d.ts → autoimprove-job.d.ts} +117 -116
  22. package/resources/autoimprove-job.d.ts.map +1 -0
  23. package/resources/{autoimprove-fix.js → autoimprove-job.js} +42 -41
  24. package/resources/autoimprove-job.js.map +1 -0
  25. package/resources/{autoimprove-fix.mjs → autoimprove-job.mjs} +40 -39
  26. package/resources/autoimprove-job.mjs.map +1 -0
  27. package/resources/config.d.mts +9 -0
  28. package/resources/config.d.mts.map +1 -1
  29. package/resources/config.d.ts +9 -0
  30. package/resources/config.d.ts.map +1 -1
  31. package/resources/customer-flow.d.mts +104 -19
  32. package/resources/customer-flow.d.mts.map +1 -1
  33. package/resources/customer-flow.d.ts +104 -19
  34. package/resources/customer-flow.d.ts.map +1 -1
  35. package/resources/index.d.mts +2 -1
  36. package/resources/index.d.mts.map +1 -1
  37. package/resources/index.d.ts +2 -1
  38. package/resources/index.d.ts.map +1 -1
  39. package/resources/index.js +5 -3
  40. package/resources/index.js.map +1 -1
  41. package/resources/index.mjs +2 -1
  42. package/resources/index.mjs.map +1 -1
  43. package/resources/simulation-job.d.mts +2 -2
  44. package/resources/simulation-job.d.mts.map +1 -1
  45. package/resources/simulation-job.d.ts +2 -2
  46. package/resources/simulation-job.d.ts.map +1 -1
  47. package/resources/simulation-run-plan-job.d.mts +1 -1
  48. package/resources/simulation-run-plan-job.d.mts.map +1 -1
  49. package/resources/simulation-run-plan-job.d.ts +1 -1
  50. package/resources/simulation-run-plan-job.d.ts.map +1 -1
  51. package/src/client.ts +54 -27
  52. package/src/resources/agent-config.ts +487 -0
  53. package/src/resources/{autoimprove-fix.ts → autoimprove-job.ts} +139 -138
  54. package/src/resources/config.ts +13 -0
  55. package/src/resources/customer-flow.ts +135 -20
  56. package/src/resources/index.ts +25 -13
  57. package/src/resources/simulation-job.ts +2 -2
  58. package/src/resources/simulation-run-plan-job.ts +1 -1
  59. package/src/version.ts +1 -1
  60. package/version.d.mts +1 -1
  61. package/version.d.mts.map +1 -1
  62. package/version.d.ts +1 -1
  63. package/version.d.ts.map +1 -1
  64. package/version.js +1 -1
  65. package/version.js.map +1 -1
  66. package/version.mjs +1 -1
  67. package/version.mjs.map +1 -1
  68. package/resources/autoimprove-fix.d.mts.map +0 -1
  69. package/resources/autoimprove-fix.d.ts.map +0 -1
  70. package/resources/autoimprove-fix.js.map +0 -1
  71. package/resources/autoimprove-fix.mjs.map +0 -1
@@ -0,0 +1,487 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as AgentConfigAPI from './agent-config';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { RequestOptions } from '../internal/request-options';
7
+ import { path } from '../internal/utils/path';
8
+
9
+ export class AgentConfig extends APIResource {
10
+ /**
11
+ * Write a new revision onto a channel. Writing production creates the key when it
12
+ * does not exist; writing staging stages a candidate that only Roark-recognized
13
+ * simulation sessions will read. Every write is a new revision; nothing is
14
+ * overwritten.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const agentConfig = await client.agentConfig.update('x', {
19
+ * channel: 'production',
20
+ * document: { foo: 'string' },
21
+ * });
22
+ * ```
23
+ */
24
+ update(
25
+ key: string,
26
+ body: AgentConfigUpdateParams,
27
+ options?: RequestOptions,
28
+ ): APIPromise<AgentConfigUpdateResponse> {
29
+ return this._client.put(path`/v1/agent-config/${key}`, { body, ...options });
30
+ }
31
+
32
+ /**
33
+ * List the managed agent configs in this project, most recent first.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const agentConfigs = await client.agentConfig.list();
38
+ * ```
39
+ */
40
+ list(options?: RequestOptions): APIPromise<AgentConfigListResponse> {
41
+ return this._client.get('/v1/agent-config', options);
42
+ }
43
+
44
+ /**
45
+ * Clear the staging channel. Production is untouched; recognized simulation
46
+ * sessions go back to reading production.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const response =
51
+ * await client.agentConfig.deleteStaging('x');
52
+ * ```
53
+ */
54
+ deleteStaging(key: string, options?: RequestOptions): APIPromise<AgentConfigDeleteStagingResponse> {
55
+ return this._client.delete(path`/v1/agent-config/${key}/staging`, options);
56
+ }
57
+
58
+ /**
59
+ * Fetch one managed config with its channel pointers and recent revisions, newest
60
+ * first.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const response = await client.agentConfig.getByID('x');
65
+ * ```
66
+ */
67
+ getByID(key: string, options?: RequestOptions): APIPromise<AgentConfigGetByIDResponse> {
68
+ return this._client.get(path`/v1/agent-config/${key}`, options);
69
+ }
70
+
71
+ /**
72
+ * Point the production channel at the staging revision. Real traffic reads it from
73
+ * the next session onward; roll back by writing the prior revision id to
74
+ * production (the chain preserves every state).
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const response = await client.agentConfig.promote('x');
79
+ * ```
80
+ */
81
+ promote(key: string, options?: RequestOptions): APIPromise<AgentConfigPromoteResponse> {
82
+ return this._client.post(path`/v1/agent-config/${key}/promote`, options);
83
+ }
84
+
85
+ /**
86
+ * The call your agent makes at session start. Returns the config JSON for this
87
+ * session, with per-session simulation recognition built in: when the session was
88
+ * originated by a Roark simulation (matched by caller number against the calls
89
+ * Roark has in flight), the STAGING revision is served for that session only, so
90
+ * Autoimprove candidates are tested on your real deployment. Real traffic always
91
+ * resolves to production; any recognition miss degrades to production too.
92
+ *
93
+ * On the first fetch of an unknown key, pass `defaults` (your baked-in config):
94
+ * the key is registered and the defaults become revision 1. That makes integration
95
+ * a single call.
96
+ *
97
+ * Cache the response per session; do not fetch per turn.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const response = await client.agentConfig.resolve('x');
102
+ * ```
103
+ */
104
+ resolve(
105
+ key: string,
106
+ body: AgentConfigResolveParams | null | undefined = {},
107
+ options?: RequestOptions,
108
+ ): APIPromise<AgentConfigResolveResponse> {
109
+ return this._client.post(path`/v1/agent-config/${key}/resolve`, { body, ...options });
110
+ }
111
+ }
112
+
113
+ export interface ManagedAgentConfigRevision {
114
+ id: string;
115
+
116
+ /**
117
+ * ISO 8601.
118
+ */
119
+ createdAt: string;
120
+
121
+ /**
122
+ * Who wrote it: your own pushes, or the Autoimprove loop staging a candidate.
123
+ */
124
+ createdByType: 'CUSTOMER' | 'AUTOIMPROVE';
125
+
126
+ /**
127
+ * The config JSON, verbatim.
128
+ */
129
+ document: { [key: string]: unknown };
130
+
131
+ parentRevisionId: string | null;
132
+
133
+ /**
134
+ * One-line story of the change.
135
+ */
136
+ summary: string | null;
137
+ }
138
+
139
+ export interface AgentConfigUpdateResponse {
140
+ /**
141
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
142
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
143
+ * Two channels: production for real traffic, staging for candidates under test.
144
+ */
145
+ data: AgentConfigUpdateResponse.Data;
146
+ }
147
+
148
+ export namespace AgentConfigUpdateResponse {
149
+ /**
150
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
151
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
152
+ * Two channels: production for real traffic, staging for candidates under test.
153
+ */
154
+ export interface Data {
155
+ id: string;
156
+
157
+ /**
158
+ * The linked Roark agent, when one exists.
159
+ */
160
+ agentId: string | null;
161
+
162
+ /**
163
+ * ISO 8601.
164
+ */
165
+ createdAt: string;
166
+
167
+ /**
168
+ * The stable handle your code fetches by.
169
+ */
170
+ key: string;
171
+
172
+ /**
173
+ * The revision real traffic reads.
174
+ */
175
+ productionRevisionId: string | null;
176
+
177
+ /**
178
+ * The candidate revision Roark test calls read. Null when nothing is staged.
179
+ */
180
+ stagingRevisionId: string | null;
181
+
182
+ /**
183
+ * ISO 8601.
184
+ */
185
+ updatedAt: string;
186
+ }
187
+ }
188
+
189
+ export interface AgentConfigListResponse {
190
+ data: Array<AgentConfigListResponse.Data>;
191
+ }
192
+
193
+ export namespace AgentConfigListResponse {
194
+ /**
195
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
196
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
197
+ * Two channels: production for real traffic, staging for candidates under test.
198
+ */
199
+ export interface Data {
200
+ id: string;
201
+
202
+ /**
203
+ * The linked Roark agent, when one exists.
204
+ */
205
+ agentId: string | null;
206
+
207
+ /**
208
+ * ISO 8601.
209
+ */
210
+ createdAt: string;
211
+
212
+ /**
213
+ * The stable handle your code fetches by.
214
+ */
215
+ key: string;
216
+
217
+ /**
218
+ * The revision real traffic reads.
219
+ */
220
+ productionRevisionId: string | null;
221
+
222
+ /**
223
+ * The candidate revision Roark test calls read. Null when nothing is staged.
224
+ */
225
+ stagingRevisionId: string | null;
226
+
227
+ /**
228
+ * ISO 8601.
229
+ */
230
+ updatedAt: string;
231
+ }
232
+ }
233
+
234
+ export interface AgentConfigDeleteStagingResponse {
235
+ /**
236
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
237
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
238
+ * Two channels: production for real traffic, staging for candidates under test.
239
+ */
240
+ data: AgentConfigDeleteStagingResponse.Data;
241
+ }
242
+
243
+ export namespace AgentConfigDeleteStagingResponse {
244
+ /**
245
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
246
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
247
+ * Two channels: production for real traffic, staging for candidates under test.
248
+ */
249
+ export interface Data {
250
+ id: string;
251
+
252
+ /**
253
+ * The linked Roark agent, when one exists.
254
+ */
255
+ agentId: string | null;
256
+
257
+ /**
258
+ * ISO 8601.
259
+ */
260
+ createdAt: string;
261
+
262
+ /**
263
+ * The stable handle your code fetches by.
264
+ */
265
+ key: string;
266
+
267
+ /**
268
+ * The revision real traffic reads.
269
+ */
270
+ productionRevisionId: string | null;
271
+
272
+ /**
273
+ * The candidate revision Roark test calls read. Null when nothing is staged.
274
+ */
275
+ stagingRevisionId: string | null;
276
+
277
+ /**
278
+ * ISO 8601.
279
+ */
280
+ updatedAt: string;
281
+ }
282
+ }
283
+
284
+ export interface AgentConfigGetByIDResponse {
285
+ data: AgentConfigGetByIDResponse.Data;
286
+ }
287
+
288
+ export namespace AgentConfigGetByIDResponse {
289
+ /**
290
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
291
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
292
+ * Two channels: production for real traffic, staging for candidates under test.
293
+ */
294
+ export interface Data {
295
+ id: string;
296
+
297
+ /**
298
+ * The linked Roark agent, when one exists.
299
+ */
300
+ agentId: string | null;
301
+
302
+ /**
303
+ * ISO 8601.
304
+ */
305
+ createdAt: string;
306
+
307
+ /**
308
+ * The stable handle your code fetches by.
309
+ */
310
+ key: string;
311
+
312
+ /**
313
+ * The revision real traffic reads.
314
+ */
315
+ productionRevisionId: string | null;
316
+
317
+ /**
318
+ * Recent revisions, newest first.
319
+ */
320
+ revisions: Array<AgentConfigAPI.ManagedAgentConfigRevision>;
321
+
322
+ /**
323
+ * The candidate revision Roark test calls read. Null when nothing is staged.
324
+ */
325
+ stagingRevisionId: string | null;
326
+
327
+ /**
328
+ * ISO 8601.
329
+ */
330
+ updatedAt: string;
331
+ }
332
+ }
333
+
334
+ export interface AgentConfigPromoteResponse {
335
+ /**
336
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
337
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
338
+ * Two channels: production for real traffic, staging for candidates under test.
339
+ */
340
+ data: AgentConfigPromoteResponse.Data;
341
+ }
342
+
343
+ export namespace AgentConfigPromoteResponse {
344
+ /**
345
+ * A managed config for a code-first agent (LiveKit, Pipecat, or any stack using
346
+ * the SDK): your agent fetches its tunable surface from Roark at session start.
347
+ * Two channels: production for real traffic, staging for candidates under test.
348
+ */
349
+ export interface Data {
350
+ id: string;
351
+
352
+ /**
353
+ * The linked Roark agent, when one exists.
354
+ */
355
+ agentId: string | null;
356
+
357
+ /**
358
+ * ISO 8601.
359
+ */
360
+ createdAt: string;
361
+
362
+ /**
363
+ * The stable handle your code fetches by.
364
+ */
365
+ key: string;
366
+
367
+ /**
368
+ * The revision real traffic reads.
369
+ */
370
+ productionRevisionId: string | null;
371
+
372
+ /**
373
+ * The candidate revision Roark test calls read. Null when nothing is staged.
374
+ */
375
+ stagingRevisionId: string | null;
376
+
377
+ /**
378
+ * ISO 8601.
379
+ */
380
+ updatedAt: string;
381
+ }
382
+ }
383
+
384
+ export interface AgentConfigResolveResponse {
385
+ data: AgentConfigResolveResponse.Data;
386
+ }
387
+
388
+ export namespace AgentConfigResolveResponse {
389
+ export interface Data {
390
+ /**
391
+ * Which channel this session resolved to.
392
+ */
393
+ channel: 'production' | 'staging';
394
+
395
+ /**
396
+ * The config JSON to apply.
397
+ */
398
+ document: { [key: string]: unknown };
399
+
400
+ key: string;
401
+
402
+ revisionId: string;
403
+
404
+ /**
405
+ * Set when this session is a Roark simulation call. Stamp it (and the revisionId)
406
+ * into your session metadata so analysis attributes the call correctly.
407
+ */
408
+ simulationJobId: string | null;
409
+ }
410
+ }
411
+
412
+ export interface AgentConfigUpdateParams {
413
+ /**
414
+ * Which channel to write.
415
+ */
416
+ channel: 'production' | 'staging';
417
+
418
+ /**
419
+ * The full config JSON for the new revision.
420
+ */
421
+ document: { [key: string]: unknown };
422
+
423
+ /**
424
+ * Link this config to a Roark agent (the one your calls report). Required before
425
+ * Autoimprove can run on it: the link is how a fix finds the config channel.
426
+ */
427
+ agentId?: string;
428
+
429
+ /**
430
+ * One-line story of the change.
431
+ */
432
+ summary?: string;
433
+ }
434
+
435
+ export interface AgentConfigResolveParams {
436
+ /**
437
+ * Your baked-in config. On the first fetch of an unknown key this registers the
438
+ * config and becomes revision 1, so integration is a single call. Ignored once the
439
+ * key exists.
440
+ */
441
+ defaults?: { [key: string]: unknown };
442
+
443
+ /**
444
+ * Session context. When the call was originated by a Roark simulation, Roark
445
+ * recognizes it here and serves the staging revision for this session only; real
446
+ * traffic always gets production.
447
+ */
448
+ session?: AgentConfigResolveParams.Session;
449
+ }
450
+
451
+ export namespace AgentConfigResolveParams {
452
+ /**
453
+ * Session context. When the call was originated by a Roark simulation, Roark
454
+ * recognizes it here and serves the staging revision for this session only; real
455
+ * traffic always gets production.
456
+ */
457
+ export interface Session {
458
+ /**
459
+ * The number your agent was reached on (E.164).
460
+ */
461
+ calledNumber?: string;
462
+
463
+ /**
464
+ * The number calling your agent (E.164). Required for simulation recognition.
465
+ */
466
+ callerNumber?: string;
467
+
468
+ /**
469
+ * Your session or room identifier, for correlation.
470
+ */
471
+ sessionId?: string;
472
+ }
473
+ }
474
+
475
+ export declare namespace AgentConfig {
476
+ export {
477
+ type ManagedAgentConfigRevision as ManagedAgentConfigRevision,
478
+ type AgentConfigUpdateResponse as AgentConfigUpdateResponse,
479
+ type AgentConfigListResponse as AgentConfigListResponse,
480
+ type AgentConfigDeleteStagingResponse as AgentConfigDeleteStagingResponse,
481
+ type AgentConfigGetByIDResponse as AgentConfigGetByIDResponse,
482
+ type AgentConfigPromoteResponse as AgentConfigPromoteResponse,
483
+ type AgentConfigResolveResponse as AgentConfigResolveResponse,
484
+ type AgentConfigUpdateParams as AgentConfigUpdateParams,
485
+ type AgentConfigResolveParams as AgentConfigResolveParams,
486
+ };
487
+ }