@unboundcx/sdk 4.13.117 → 4.13.118

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.117",
3
+ "version": "4.13.118",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import { internalRequest } from '../../base.js';
1
+ import { internalRequest } from "../../base.js";
2
2
  /**
3
3
  * Playbooks Service - Manage AI-driven playbook sessions for guided workflows
4
4
  */
@@ -28,8 +28,8 @@ export class PlaybooksService {
28
28
  this.sdk.validateParams(
29
29
  { name },
30
30
  {
31
- name: { type: 'string', required: true },
32
- recordTypeId: { type: 'string', required: false },
31
+ name: { type: "string", required: true },
32
+ recordTypeId: { type: "string", required: false },
33
33
  },
34
34
  );
35
35
 
@@ -37,7 +37,12 @@ export class PlaybooksService {
37
37
  body: { name, recordTypeId },
38
38
  };
39
39
 
40
- const result = await internalRequest(this.sdk, '/ai/playbooks', 'POST', params);
40
+ const result = await internalRequest(
41
+ this.sdk,
42
+ "/ai/playbooks",
43
+ "POST",
44
+ params,
45
+ );
41
46
  return result;
42
47
  }
43
48
 
@@ -57,11 +62,15 @@ export class PlaybooksService {
57
62
  this.sdk.validateParams(
58
63
  { playbookId },
59
64
  {
60
- playbookId: { type: 'string', required: true },
65
+ playbookId: { type: "string", required: true },
61
66
  },
62
67
  );
63
68
 
64
- const result = await internalRequest(this.sdk, `/ai/playbooks/${playbookId}`, 'GET');
69
+ const result = await internalRequest(
70
+ this.sdk,
71
+ `/ai/playbooks/${playbookId}`,
72
+ "GET",
73
+ );
65
74
  return result;
66
75
  }
67
76
 
@@ -93,7 +102,12 @@ export class PlaybooksService {
93
102
  query: { limit, orderBy, orderDirection, isPublished, recordTypeId },
94
103
  };
95
104
 
96
- const result = await internalRequest(this.sdk, '/ai/playbooks', 'GET', params);
105
+ const result = await internalRequest(
106
+ this.sdk,
107
+ "/ai/playbooks",
108
+ "GET",
109
+ params,
110
+ );
97
111
  return result;
98
112
  }
99
113
 
@@ -124,11 +138,11 @@ export class PlaybooksService {
124
138
  this.sdk.validateParams(
125
139
  { playbookId },
126
140
  {
127
- playbookId: { type: 'string', required: true },
128
- name: { type: 'string', required: false },
129
- isPublished: { type: 'boolean', required: false },
130
- recordTypeId: { type: 'string', required: false },
131
- passScore: { type: 'number', required: false },
141
+ playbookId: { type: "string", required: true },
142
+ name: { type: "string", required: false },
143
+ isPublished: { type: "boolean", required: false },
144
+ recordTypeId: { type: "string", required: false },
145
+ passScore: { type: "number", required: false },
132
146
  },
133
147
  );
134
148
 
@@ -136,9 +150,10 @@ export class PlaybooksService {
136
150
  body: { name, isPublished, recordTypeId, passScore },
137
151
  };
138
152
 
139
- const result = await internalRequest(this.sdk,
153
+ const result = await internalRequest(
154
+ this.sdk,
140
155
  `/ai/playbooks/${playbookId}`,
141
- 'PUT',
156
+ "PUT",
142
157
  params,
143
158
  );
144
159
  return result;
@@ -160,13 +175,14 @@ export class PlaybooksService {
160
175
  this.sdk.validateParams(
161
176
  { playbookId },
162
177
  {
163
- playbookId: { type: 'string', required: true },
178
+ playbookId: { type: "string", required: true },
164
179
  },
165
180
  );
166
181
 
167
- const result = await internalRequest(this.sdk,
182
+ const result = await internalRequest(
183
+ this.sdk,
168
184
  `/ai/playbooks/${playbookId}`,
169
- 'DELETE',
185
+ "DELETE",
170
186
  );
171
187
  return result;
172
188
  }
@@ -202,6 +218,7 @@ export class PlaybooksService {
202
218
  async createPlaybookGoal({
203
219
  playbookId,
204
220
  playbookGoalTypeId,
221
+ playbookVersionId,
205
222
  goal,
206
223
  description,
207
224
  criteria,
@@ -220,6 +237,7 @@ export class PlaybooksService {
220
237
  playbookId,
221
238
  playbookGoalTypeId,
222
239
  goal,
240
+ playbookVersionId,
223
241
  description,
224
242
  criteria,
225
243
  scoreType,
@@ -230,26 +248,28 @@ export class PlaybooksService {
230
248
  recordTypeId,
231
249
  },
232
250
  {
233
- playbookId: { type: 'string', required: true },
234
- playbookGoalTypeId: { type: 'string', required: true },
235
- goal: { type: 'string', required: true },
236
- description: { type: 'string', required: false },
237
- criteria: { type: 'object', required: false },
238
- scoreType: { type: 'string', required: false },
239
- weight: { type: 'number', required: false },
240
- requiredForPass: { type: 'boolean', required: false },
241
- role: { type: 'string', required: false },
242
- signal: { type: 'string', required: false },
243
- window: { type: 'string', required: false },
244
- windowTurns: { type: 'number', required: false },
245
- visibility: { type: 'string', required: false },
246
- recordTypeId: { type: 'string', required: false },
251
+ playbookId: { type: "string", required: true },
252
+ playbookGoalTypeId: { type: "string", required: true },
253
+ goal: { type: "string", required: true },
254
+ playbookVersionId: { type: "string", required: true },
255
+ description: { type: "string", required: false },
256
+ criteria: { type: "object", required: false },
257
+ scoreType: { type: "string", required: false },
258
+ weight: { type: "number", required: false },
259
+ requiredForPass: { type: "boolean", required: false },
260
+ role: { type: "string", required: false },
261
+ signal: { type: "string", required: false },
262
+ window: { type: "string", required: false },
263
+ windowTurns: { type: "number", required: false },
264
+ visibility: { type: "string", required: false },
265
+ recordTypeId: { type: "string", required: false },
247
266
  },
248
267
  );
249
268
 
250
269
  const params = {
251
270
  body: {
252
271
  playbookGoalTypeId,
272
+ playbookVersionId,
253
273
  goal,
254
274
  description,
255
275
  criteria,
@@ -265,9 +285,10 @@ export class PlaybooksService {
265
285
  },
266
286
  };
267
287
 
268
- const result = await internalRequest(this.sdk,
288
+ const result = await internalRequest(
289
+ this.sdk,
269
290
  `/ai/playbooks/${playbookId}/goals`,
270
- 'POST',
291
+ "POST",
271
292
  params,
272
293
  );
273
294
  return result;
@@ -291,14 +312,15 @@ export class PlaybooksService {
291
312
  this.sdk.validateParams(
292
313
  { playbookId, goalId },
293
314
  {
294
- playbookId: { type: 'string', required: true },
295
- goalId: { type: 'string', required: true },
315
+ playbookId: { type: "string", required: true },
316
+ goalId: { type: "string", required: true },
296
317
  },
297
318
  );
298
319
 
299
- const result = await internalRequest(this.sdk,
320
+ const result = await internalRequest(
321
+ this.sdk,
300
322
  `/ai/playbooks/${playbookId}/goals/${goalId}`,
301
- 'GET',
323
+ "GET",
302
324
  );
303
325
  return result;
304
326
  }
@@ -319,13 +341,14 @@ export class PlaybooksService {
319
341
  this.sdk.validateParams(
320
342
  { playbookId },
321
343
  {
322
- playbookId: { type: 'string', required: true },
344
+ playbookId: { type: "string", required: true },
323
345
  },
324
346
  );
325
347
 
326
- const result = await internalRequest(this.sdk,
348
+ const result = await internalRequest(
349
+ this.sdk,
327
350
  `/ai/playbooks/${playbookId}/goals`,
328
- 'GET',
351
+ "GET",
329
352
  );
330
353
  return result;
331
354
  }
@@ -383,20 +406,20 @@ export class PlaybooksService {
383
406
  recordTypeId,
384
407
  },
385
408
  {
386
- goalId: { type: 'string', required: true },
387
- playbookGoalTypeId: { type: 'string', required: true },
388
- goal: { type: 'string', required: false },
389
- description: { type: 'string', required: false },
390
- criteria: { type: 'object', required: false },
391
- scoreType: { type: 'string', required: false },
392
- weight: { type: 'number', required: false },
393
- requiredForPass: { type: 'boolean', required: false },
394
- role: { type: 'string', required: false },
395
- signal: { type: 'string', required: false },
396
- window: { type: 'string', required: false },
397
- windowTurns: { type: 'number', required: false },
398
- visibility: { type: 'string', required: false },
399
- recordTypeId: { type: 'string', required: false },
409
+ goalId: { type: "string", required: true },
410
+ playbookGoalTypeId: { type: "string", required: true },
411
+ goal: { type: "string", required: false },
412
+ description: { type: "string", required: false },
413
+ criteria: { type: "object", required: false },
414
+ scoreType: { type: "string", required: false },
415
+ weight: { type: "number", required: false },
416
+ requiredForPass: { type: "boolean", required: false },
417
+ role: { type: "string", required: false },
418
+ signal: { type: "string", required: false },
419
+ window: { type: "string", required: false },
420
+ windowTurns: { type: "number", required: false },
421
+ visibility: { type: "string", required: false },
422
+ recordTypeId: { type: "string", required: false },
400
423
  },
401
424
  );
402
425
 
@@ -418,9 +441,10 @@ export class PlaybooksService {
418
441
  },
419
442
  };
420
443
 
421
- const result = await internalRequest(this.sdk,
444
+ const result = await internalRequest(
445
+ this.sdk,
422
446
  `/ai/playbooks/goals/${goalId}`,
423
- 'PUT',
447
+ "PUT",
424
448
  params,
425
449
  );
426
450
  return result;
@@ -442,13 +466,14 @@ export class PlaybooksService {
442
466
  this.sdk.validateParams(
443
467
  { goalId },
444
468
  {
445
- goalId: { type: 'string', required: true },
469
+ goalId: { type: "string", required: true },
446
470
  },
447
471
  );
448
472
 
449
- const result = await internalRequest(this.sdk,
473
+ const result = await internalRequest(
474
+ this.sdk,
450
475
  `/ai/playbooks/goals/${goalId}`,
451
- 'DELETE',
476
+ "DELETE",
452
477
  );
453
478
  return result;
454
479
  }
@@ -467,24 +492,27 @@ export class PlaybooksService {
467
492
  * goalOrder: ['goal_3', 'goal_1', 'goal_2']
468
493
  * });
469
494
  */
470
- async reorderPlaybookGoals({ playbookId, goalOrder }) {
495
+ async reorderPlaybookGoals({ playbookId, playbookVersionId, goalOrder }) {
471
496
  this.sdk.validateParams(
472
- { playbookId, goalOrder },
497
+ { playbookId, playbookVersionId, goalOrder },
473
498
  {
474
- playbookId: { type: 'string', required: true },
475
- goalOrder: { type: 'array', required: true },
499
+ playbookId: { type: "string", required: true },
500
+ playbookVersionId: { type: "string", required: true },
501
+ goalOrder: { type: "array", required: true },
476
502
  },
477
503
  );
478
504
 
479
505
  const params = {
480
506
  body: {
507
+ playbookVersionId,
481
508
  goalOrder,
482
509
  },
483
510
  };
484
511
 
485
- const result = await internalRequest(this.sdk,
512
+ const result = await internalRequest(
513
+ this.sdk,
486
514
  `/ai/playbooks/${playbookId}/goals/reorder`,
487
- 'PUT',
515
+ "PUT",
488
516
  params,
489
517
  );
490
518
  return result;
@@ -527,15 +555,15 @@ export class PlaybooksService {
527
555
  this.sdk.validateParams(
528
556
  { name },
529
557
  {
530
- name: { type: 'string', required: true },
531
- description: { type: 'string', required: false },
532
- keywords: { type: 'array', required: false },
533
- recommendedPhase: { type: 'string', required: false },
534
- window: { type: 'string', required: false },
535
- windowTurns: { type: 'number', required: false },
536
- role: { type: 'string', required: false },
537
- signal: { type: 'string', required: false },
538
- recordTypeId: { type: 'string', required: false },
558
+ name: { type: "string", required: true },
559
+ description: { type: "string", required: false },
560
+ keywords: { type: "array", required: false },
561
+ recommendedPhase: { type: "string", required: false },
562
+ window: { type: "string", required: false },
563
+ windowTurns: { type: "number", required: false },
564
+ role: { type: "string", required: false },
565
+ signal: { type: "string", required: false },
566
+ recordTypeId: { type: "string", required: false },
539
567
  },
540
568
  );
541
569
 
@@ -553,9 +581,10 @@ export class PlaybooksService {
553
581
  },
554
582
  };
555
583
 
556
- const result = await internalRequest(this.sdk,
557
- '/ai/playbooks/goalTypes',
558
- 'POST',
584
+ const result = await internalRequest(
585
+ this.sdk,
586
+ "/ai/playbooks/goalTypes",
587
+ "POST",
559
588
  params,
560
589
  );
561
590
  return result;
@@ -577,13 +606,14 @@ export class PlaybooksService {
577
606
  this.sdk.validateParams(
578
607
  { goalTypeId },
579
608
  {
580
- goalTypeId: { type: 'string', required: true },
609
+ goalTypeId: { type: "string", required: true },
581
610
  },
582
611
  );
583
612
 
584
- const result = await internalRequest(this.sdk,
613
+ const result = await internalRequest(
614
+ this.sdk,
585
615
  `/ai/playbooks/goalTypes/${goalTypeId}`,
586
- 'GET',
616
+ "GET",
587
617
  );
588
618
  return result;
589
619
  }
@@ -616,9 +646,10 @@ export class PlaybooksService {
616
646
  query: { limit, orderBy, orderDirection, recommendedPhase, recordTypeId },
617
647
  };
618
648
 
619
- const result = await internalRequest(this.sdk,
620
- '/ai/playbooks/goalTypes',
621
- 'GET',
649
+ const result = await internalRequest(
650
+ this.sdk,
651
+ "/ai/playbooks/goalTypes",
652
+ "GET",
622
653
  params,
623
654
  );
624
655
  return result;
@@ -660,16 +691,16 @@ export class PlaybooksService {
660
691
  this.sdk.validateParams(
661
692
  { goalTypeId: id },
662
693
  {
663
- goalTypeId: { type: 'string', required: true },
664
- name: { type: 'string', required: false },
665
- description: { type: 'string', required: false },
666
- keywords: { type: 'array', required: false },
667
- recommendedPhase: { type: 'string', required: false },
668
- window: { type: 'string', required: false },
669
- windowTurns: { type: 'number', required: false },
670
- role: { type: 'string', required: false },
671
- signal: { type: 'string', required: false },
672
- recordTypeId: { type: 'string', required: false },
694
+ goalTypeId: { type: "string", required: true },
695
+ name: { type: "string", required: false },
696
+ description: { type: "string", required: false },
697
+ keywords: { type: "array", required: false },
698
+ recommendedPhase: { type: "string", required: false },
699
+ window: { type: "string", required: false },
700
+ windowTurns: { type: "number", required: false },
701
+ role: { type: "string", required: false },
702
+ signal: { type: "string", required: false },
703
+ recordTypeId: { type: "string", required: false },
673
704
  },
674
705
  );
675
706
 
@@ -687,9 +718,10 @@ export class PlaybooksService {
687
718
  },
688
719
  };
689
720
 
690
- const result = await internalRequest(this.sdk,
721
+ const result = await internalRequest(
722
+ this.sdk,
691
723
  `/ai/playbooks/goalTypes/${id}`,
692
- 'PUT',
724
+ "PUT",
693
725
  params,
694
726
  );
695
727
  return result;
@@ -711,13 +743,14 @@ export class PlaybooksService {
711
743
  this.sdk.validateParams(
712
744
  { goalTypeId },
713
745
  {
714
- goalTypeId: { type: 'string', required: true },
746
+ goalTypeId: { type: "string", required: true },
715
747
  },
716
748
  );
717
749
 
718
- const result = await internalRequest(this.sdk,
750
+ const result = await internalRequest(
751
+ this.sdk,
719
752
  `/ai/playbooks/goalTypes/${goalTypeId}`,
720
- 'DELETE',
753
+ "DELETE",
721
754
  );
722
755
  return result;
723
756
  }
@@ -771,14 +804,14 @@ export class PlaybooksService {
771
804
  this.sdk.validateParams(
772
805
  { playbookId, sipCallId, taskId, workerId },
773
806
  {
774
- playbookId: { type: 'string', required: true },
775
- transcriptionSessionId: { type: 'string', required: false },
776
- method: { type: 'string', required: false },
777
- userId: { type: 'string', required: false },
778
- recordTypeId: { type: 'string', required: false },
779
- sipCallId: { type: 'string', required: false },
780
- taskId: { type: 'string', required: false },
781
- workerId: { type: 'string', required: false },
807
+ playbookId: { type: "string", required: true },
808
+ transcriptionSessionId: { type: "string", required: false },
809
+ method: { type: "string", required: false },
810
+ userId: { type: "string", required: false },
811
+ recordTypeId: { type: "string", required: false },
812
+ sipCallId: { type: "string", required: false },
813
+ taskId: { type: "string", required: false },
814
+ workerId: { type: "string", required: false },
782
815
  },
783
816
  );
784
817
 
@@ -794,9 +827,10 @@ export class PlaybooksService {
794
827
  },
795
828
  };
796
829
 
797
- const result = await internalRequest(this.sdk,
830
+ const result = await internalRequest(
831
+ this.sdk,
798
832
  `/ai/playbooks/sessions/${playbookId}`,
799
- 'POST',
833
+ "POST",
800
834
  params,
801
835
  );
802
836
  return result;
@@ -843,20 +877,21 @@ export class PlaybooksService {
843
877
  this.sdk.validateParams(
844
878
  { sessionId, taskId, workerId, userId },
845
879
  {
846
- sessionId: { type: 'string', required: false },
847
- taskId: { type: 'string', required: false },
848
- workerId: { type: 'string', required: false },
849
- userId: { type: 'string', required: false },
850
- includeQa: { type: 'boolean', required: false },
880
+ sessionId: { type: "string", required: false },
881
+ taskId: { type: "string", required: false },
882
+ workerId: { type: "string", required: false },
883
+ userId: { type: "string", required: false },
884
+ includeQa: { type: "boolean", required: false },
851
885
  },
852
886
  );
853
887
 
854
888
  if (sessionId) {
855
889
  const query = {};
856
890
  if (includeQa) query.includeQa = 1;
857
- const result = await internalRequest(this.sdk,
891
+ const result = await internalRequest(
892
+ this.sdk,
858
893
  `/ai/playbooks/sessions/${sessionId}`,
859
- 'GET',
894
+ "GET",
860
895
  { query },
861
896
  );
862
897
  return result;
@@ -868,9 +903,10 @@ export class PlaybooksService {
868
903
  if (userId) query.userId = userId;
869
904
  if (includeQa) query.includeQa = 1;
870
905
 
871
- const result = await internalRequest(this.sdk,
906
+ const result = await internalRequest(
907
+ this.sdk,
872
908
  `/ai/playbooks/sessions`,
873
- 'GET',
909
+ "GET",
874
910
  { query },
875
911
  );
876
912
  return result;
@@ -923,14 +959,14 @@ export class PlaybooksService {
923
959
  this.sdk.validateParams(
924
960
  { sessionId },
925
961
  {
926
- sessionId: { type: 'string', required: true },
927
- passed: { type: 'boolean', required: false },
928
- totalScore: { type: 'number', required: false },
929
- achievedGoals: { type: 'number', required: false },
930
- totalGoals: { type: 'number', required: false },
931
- customerTotalScore: { type: 'number', required: false },
932
- customerAchievedGoals: { type: 'number', required: false },
933
- customerTotalGoals: { type: 'number', required: false },
962
+ sessionId: { type: "string", required: true },
963
+ passed: { type: "boolean", required: false },
964
+ totalScore: { type: "number", required: false },
965
+ achievedGoals: { type: "number", required: false },
966
+ totalGoals: { type: "number", required: false },
967
+ customerTotalScore: { type: "number", required: false },
968
+ customerAchievedGoals: { type: "number", required: false },
969
+ customerTotalGoals: { type: "number", required: false },
934
970
  },
935
971
  );
936
972
 
@@ -946,9 +982,10 @@ export class PlaybooksService {
946
982
  },
947
983
  };
948
984
 
949
- const result = await internalRequest(this.sdk,
985
+ const result = await internalRequest(
986
+ this.sdk,
950
987
  `/ai/playbooks/sessions/${sessionId}/complete`,
951
- 'PUT',
988
+ "PUT",
952
989
  params,
953
990
  );
954
991
  return result;
@@ -1026,15 +1063,15 @@ export class PlaybooksService {
1026
1063
  this.sdk.validateParams(
1027
1064
  { sessionId, goalId },
1028
1065
  {
1029
- sessionId: { type: 'string', required: true },
1030
- goalId: { type: 'string', required: true },
1031
- achieved: { type: 'boolean', required: false },
1032
- score: { type: 'number', required: false },
1033
- reason: { type: 'string', required: false },
1034
- confidence: { type: 'number', required: false },
1035
- evidence: { type: 'array', required: false },
1036
- role: { type: 'string', required: false },
1037
- missed: { type: 'boolean', required: false },
1066
+ sessionId: { type: "string", required: true },
1067
+ goalId: { type: "string", required: true },
1068
+ achieved: { type: "boolean", required: false },
1069
+ score: { type: "number", required: false },
1070
+ reason: { type: "string", required: false },
1071
+ confidence: { type: "number", required: false },
1072
+ evidence: { type: "array", required: false },
1073
+ role: { type: "string", required: false },
1074
+ missed: { type: "boolean", required: false },
1038
1075
  },
1039
1076
  );
1040
1077
 
@@ -1051,9 +1088,10 @@ export class PlaybooksService {
1051
1088
  },
1052
1089
  };
1053
1090
 
1054
- const result = await internalRequest(this.sdk,
1091
+ const result = await internalRequest(
1092
+ this.sdk,
1055
1093
  `/ai/playbooks/sessions/${sessionId}/goal`,
1056
- 'POST',
1094
+ "POST",
1057
1095
  params,
1058
1096
  );
1059
1097
  return result;
@@ -1071,15 +1109,15 @@ export class PlaybooksService {
1071
1109
  this.sdk.validateParams(
1072
1110
  { sessionId, goals },
1073
1111
  {
1074
- sessionId: { type: 'string', required: true },
1075
- goals: { type: 'array', required: true },
1112
+ sessionId: { type: "string", required: true },
1113
+ goals: { type: "array", required: true },
1076
1114
  },
1077
1115
  );
1078
1116
 
1079
1117
  const result = await internalRequest(
1080
1118
  this.sdk,
1081
1119
  `/ai/playbooks/sessions/${sessionId}/qa`,
1082
- 'PUT',
1120
+ "PUT",
1083
1121
  { body: { goals } },
1084
1122
  );
1085
1123
  return result;
@@ -1096,14 +1134,14 @@ export class PlaybooksService {
1096
1134
  this.sdk.validateParams(
1097
1135
  { sessionId },
1098
1136
  {
1099
- sessionId: { type: 'string', required: true },
1137
+ sessionId: { type: "string", required: true },
1100
1138
  },
1101
1139
  );
1102
1140
 
1103
1141
  const result = await internalRequest(
1104
1142
  this.sdk,
1105
1143
  `/ai/playbooks/sessions/${sessionId}/qa`,
1106
- 'GET',
1144
+ "GET",
1107
1145
  );
1108
1146
  return result;
1109
1147
  }
@@ -1123,14 +1161,16 @@ export class PlaybooksService {
1123
1161
  limit,
1124
1162
  beforeReviewedAt,
1125
1163
  beforeId,
1164
+ lookbackDays,
1126
1165
  }) {
1127
1166
  this.sdk.validateParams(
1128
1167
  { playbookGoalId },
1129
1168
  {
1130
- playbookGoalId: { type: 'string', required: true },
1131
- limit: { type: 'number', required: false },
1132
- beforeReviewedAt: { type: 'string', required: false },
1133
- beforeId: { type: 'string', required: false },
1169
+ playbookGoalId: { type: "string", required: true },
1170
+ limit: { type: "number", required: false },
1171
+ beforeReviewedAt: { type: "string", required: false },
1172
+ beforeId: { type: "string", required: false },
1173
+ lookbackDays: { type: "number", required: false },
1134
1174
  },
1135
1175
  );
1136
1176
 
@@ -1138,11 +1178,12 @@ export class PlaybooksService {
1138
1178
  if (limit != null) query.limit = limit;
1139
1179
  if (beforeReviewedAt) query.beforeReviewedAt = beforeReviewedAt;
1140
1180
  if (beforeId) query.beforeId = beforeId;
1181
+ if (lookbackDays != null) query.lookbackDays = lookbackDays;
1141
1182
 
1142
1183
  const result = await internalRequest(
1143
1184
  this.sdk,
1144
1185
  `/ai/playbooks/goals/${playbookGoalId}/disagreements`,
1145
- 'GET',
1186
+ "GET",
1146
1187
  { query },
1147
1188
  );
1148
1189
  return result;
@@ -1155,18 +1196,287 @@ export class PlaybooksService {
1155
1196
  * @param {string} options.playbookId
1156
1197
  * @returns {Promise<Object>} agree-rate payload
1157
1198
  */
1158
- async getQaAgreeRate({ playbookId }) {
1199
+ async getQaAgreeRate({ playbookId, lookbackDays }) {
1159
1200
  this.sdk.validateParams(
1160
1201
  { playbookId },
1161
1202
  {
1162
- playbookId: { type: 'string', required: true },
1203
+ playbookId: { type: "string", required: true },
1204
+ lookbackDays: { type: "number", required: false },
1163
1205
  },
1164
1206
  );
1165
1207
 
1208
+ const query = {};
1209
+ if (lookbackDays != null) query.lookbackDays = lookbackDays;
1210
+
1166
1211
  const result = await internalRequest(
1167
1212
  this.sdk,
1168
1213
  `/ai/playbooks/${playbookId}/qa/agree-rate`,
1169
- 'GET',
1214
+ "GET",
1215
+ { query },
1216
+ );
1217
+ return result;
1218
+ }
1219
+
1220
+ /**
1221
+ * Pending recommendations for a playbook. Does not generate or apply.
1222
+ *
1223
+ * @param {Object} options
1224
+ * @param {string} options.playbookId
1225
+ * @returns {Promise<Object>}
1226
+ */
1227
+ async listRecommendations({ playbookId, playbookVersionId }) {
1228
+ this.sdk.validateParams(
1229
+ { playbookId },
1230
+ {
1231
+ playbookId: { type: "string", required: true },
1232
+ playbookVersionId: { type: "string", required: false },
1233
+ },
1234
+ );
1235
+
1236
+ const query = {};
1237
+ if (playbookVersionId) query.playbookVersionId = playbookVersionId;
1238
+
1239
+ const result = await internalRequest(
1240
+ this.sdk,
1241
+ `/ai/playbooks/${playbookId}/recommendations`,
1242
+ "GET",
1243
+ { query },
1244
+ );
1245
+ return result;
1246
+ }
1247
+
1248
+ /**
1249
+ * One set of goal edits from QA disagreements in a lookback window.
1250
+ * Does not apply them.
1251
+ *
1252
+ * @param {Object} options
1253
+ * @param {string} options.playbookId
1254
+ * @param {number} options.lookbackDays - 7, 30, or 90
1255
+ * @param {string} [options.playbookGoalId]
1256
+ * @returns {Promise<Object>}
1257
+ */
1258
+ async generateRecommendations({
1259
+ playbookId,
1260
+ lookbackDays,
1261
+ playbookGoalId,
1262
+ playbookVersionId,
1263
+ }) {
1264
+ this.sdk.validateParams(
1265
+ { playbookId, lookbackDays },
1266
+ {
1267
+ playbookId: { type: "string", required: true },
1268
+ lookbackDays: { type: "number", required: true },
1269
+ playbookGoalId: { type: "string", required: false },
1270
+ playbookVersionId: { type: "string", required: false },
1271
+ },
1272
+ );
1273
+
1274
+ const result = await internalRequest(
1275
+ this.sdk,
1276
+ `/ai/playbooks/${playbookId}/recommendations`,
1277
+ "POST",
1278
+ { body: { lookbackDays, playbookGoalId, playbookVersionId } },
1279
+ );
1280
+ return result;
1281
+ }
1282
+
1283
+ /**
1284
+ * Apply pending recommendations together. One failure rolls the set back.
1285
+ *
1286
+ * @param {Object} options
1287
+ * @param {string} options.playbookId
1288
+ * @param {string[]} options.suggestionIds
1289
+ * @returns {Promise<Object>}
1290
+ */
1291
+ async applyRecommendations({ playbookId, sourceVersionId, suggestionIds }) {
1292
+ this.sdk.validateParams(
1293
+ { playbookId, sourceVersionId, suggestionIds },
1294
+ {
1295
+ playbookId: { type: "string", required: true },
1296
+ sourceVersionId: { type: "string", required: true },
1297
+ suggestionIds: { type: "array", required: true },
1298
+ },
1299
+ );
1300
+
1301
+ const result = await internalRequest(
1302
+ this.sdk,
1303
+ `/ai/playbooks/${playbookId}/recommendations/apply`,
1304
+ "POST",
1305
+ { body: { sourceVersionId, suggestionIds } },
1306
+ );
1307
+ return result;
1308
+ }
1309
+
1310
+ /**
1311
+ * Versions of a playbook. Backfills version 1 when none exist.
1312
+ *
1313
+ * @param {Object} options
1314
+ * @param {string} options.playbookId
1315
+ * @returns {Promise<Object>} { versions, currentVersionId }
1316
+ */
1317
+ async listVersions({ playbookId }) {
1318
+ this.sdk.validateParams(
1319
+ { playbookId },
1320
+ { playbookId: { type: "string", required: true } },
1321
+ );
1322
+
1323
+ const result = await internalRequest(
1324
+ this.sdk,
1325
+ `/ai/playbooks/${playbookId}/versions`,
1326
+ "GET",
1327
+ );
1328
+ return result;
1329
+ }
1330
+
1331
+ /**
1332
+ * Copy a version into a new draft. Optional suggestions apply onto the copies.
1333
+ *
1334
+ * @param {Object} options
1335
+ * @param {string} options.playbookId
1336
+ * @param {string} options.sourceVersionId
1337
+ * @param {string[]} [options.suggestionIds]
1338
+ * @returns {Promise<Object>} { version, goals }
1339
+ */
1340
+ async createVersion({ playbookId, sourceVersionId, suggestionIds }) {
1341
+ this.sdk.validateParams(
1342
+ { playbookId, sourceVersionId },
1343
+ {
1344
+ playbookId: { type: "string", required: true },
1345
+ sourceVersionId: { type: "string", required: true },
1346
+ suggestionIds: { type: "array", required: false },
1347
+ },
1348
+ );
1349
+
1350
+ const result = await internalRequest(
1351
+ this.sdk,
1352
+ `/ai/playbooks/${playbookId}/versions`,
1353
+ "POST",
1354
+ { body: { sourceVersionId, suggestionIds } },
1355
+ );
1356
+ return result;
1357
+ }
1358
+
1359
+ /**
1360
+ * Publish a draft version. Does not make it current.
1361
+ *
1362
+ * @param {Object} options
1363
+ * @param {string} options.playbookId
1364
+ * @param {string} options.versionId
1365
+ * @returns {Promise<Object>}
1366
+ */
1367
+ async publishVersion({ playbookId, versionId }) {
1368
+ this.sdk.validateParams(
1369
+ { playbookId, versionId },
1370
+ {
1371
+ playbookId: { type: "string", required: true },
1372
+ versionId: { type: "string", required: true },
1373
+ },
1374
+ );
1375
+
1376
+ const result = await internalRequest(
1377
+ this.sdk,
1378
+ `/ai/playbooks/${playbookId}/versions/${versionId}/publish`,
1379
+ "POST",
1380
+ { body: {} },
1381
+ );
1382
+ return result;
1383
+ }
1384
+
1385
+ /**
1386
+ * Point new sessions at a published version and mark the playbook published.
1387
+ *
1388
+ * @param {Object} options
1389
+ * @param {string} options.playbookId
1390
+ * @param {string} options.versionId
1391
+ * @returns {Promise<Object>} { currentVersionId, isPublished, version }
1392
+ */
1393
+ /**
1394
+ * Delete a draft that was never published.
1395
+ *
1396
+ * @param {Object} options
1397
+ * @param {string} options.playbookId
1398
+ * @param {string} options.versionId
1399
+ * @returns {Promise<Object>} { deleted, versionId }
1400
+ */
1401
+ async deleteVersion({ playbookId, versionId }) {
1402
+ this.sdk.validateParams(
1403
+ { playbookId, versionId },
1404
+ {
1405
+ playbookId: { type: "string", required: true },
1406
+ versionId: { type: "string", required: true },
1407
+ },
1408
+ );
1409
+
1410
+ const result = await internalRequest(
1411
+ this.sdk,
1412
+ `/ai/playbooks/${playbookId}/versions/${versionId}`,
1413
+ "DELETE",
1414
+ );
1415
+ return result;
1416
+ }
1417
+
1418
+ async setCurrentVersion({ playbookId, versionId }) {
1419
+ this.sdk.validateParams(
1420
+ { playbookId, versionId },
1421
+ {
1422
+ playbookId: { type: "string", required: true },
1423
+ versionId: { type: "string", required: true },
1424
+ },
1425
+ );
1426
+
1427
+ const result = await internalRequest(
1428
+ this.sdk,
1429
+ `/ai/playbooks/${playbookId}/versions/${versionId}/current`,
1430
+ "POST",
1431
+ { body: {} },
1432
+ );
1433
+ return result;
1434
+ }
1435
+
1436
+ /**
1437
+ * QA disagreements across a playbook version.
1438
+ *
1439
+ * @param {Object} options
1440
+ * @param {string} options.playbookId
1441
+ * @param {string} [options.playbookVersionId]
1442
+ * @param {number} [options.lookbackDays]
1443
+ * @param {number} [options.limit]
1444
+ * @param {string} [options.beforeReviewedAt]
1445
+ * @param {string} [options.beforeId]
1446
+ * @returns {Promise<Object>}
1447
+ */
1448
+ async listPlaybookDisagreements({
1449
+ playbookId,
1450
+ playbookVersionId,
1451
+ lookbackDays,
1452
+ limit,
1453
+ beforeReviewedAt,
1454
+ beforeId,
1455
+ }) {
1456
+ this.sdk.validateParams(
1457
+ { playbookId },
1458
+ {
1459
+ playbookId: { type: "string", required: true },
1460
+ playbookVersionId: { type: "string", required: false },
1461
+ lookbackDays: { type: "number", required: false },
1462
+ limit: { type: "number", required: false },
1463
+ beforeReviewedAt: { type: "string", required: false },
1464
+ beforeId: { type: "string", required: false },
1465
+ },
1466
+ );
1467
+
1468
+ const query = {};
1469
+ if (playbookVersionId) query.playbookVersionId = playbookVersionId;
1470
+ if (lookbackDays != null) query.lookbackDays = lookbackDays;
1471
+ if (limit != null) query.limit = limit;
1472
+ if (beforeReviewedAt) query.beforeReviewedAt = beforeReviewedAt;
1473
+ if (beforeId) query.beforeId = beforeId;
1474
+
1475
+ const result = await internalRequest(
1476
+ this.sdk,
1477
+ `/ai/playbooks/${playbookId}/qa/disagreements`,
1478
+ "GET",
1479
+ { query },
1170
1480
  );
1171
1481
  return result;
1172
1482
  }
@@ -1182,14 +1492,14 @@ export class PlaybooksService {
1182
1492
  this.sdk.validateParams(
1183
1493
  { playbookGoalId },
1184
1494
  {
1185
- playbookGoalId: { type: 'string', required: true },
1495
+ playbookGoalId: { type: "string", required: true },
1186
1496
  },
1187
1497
  );
1188
1498
 
1189
1499
  const result = await internalRequest(
1190
1500
  this.sdk,
1191
1501
  `/ai/playbooks/goals/${playbookGoalId}/suggest`,
1192
- 'POST',
1502
+ "POST",
1193
1503
  { body: {} },
1194
1504
  );
1195
1505
  return result;
@@ -1208,15 +1518,15 @@ export class PlaybooksService {
1208
1518
  this.sdk.validateParams(
1209
1519
  { suggestionId, action },
1210
1520
  {
1211
- suggestionId: { type: 'string', required: true },
1212
- action: { type: 'string', required: true },
1521
+ suggestionId: { type: "string", required: true },
1522
+ action: { type: "string", required: true },
1213
1523
  },
1214
1524
  );
1215
1525
 
1216
1526
  const result = await internalRequest(
1217
1527
  this.sdk,
1218
1528
  `/ai/playbooks/suggestions/${suggestionId}/resolve`,
1219
- 'POST',
1529
+ "POST",
1220
1530
  { body: { action, proposed } },
1221
1531
  );
1222
1532
  return result;