@botpress/cognitive 0.1.38 → 0.1.40

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/index.cjs CHANGED
@@ -31,21 +31,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
 
32
32
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/options.js
33
33
  var require_options = __commonJS({
34
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/options.js"(exports) {
34
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/options.js"(exports2) {
35
35
  "use strict";
36
- var __assign = exports && exports.__assign || function() {
36
+ var __assign = exports2 && exports2.__assign || function() {
37
37
  __assign = Object.assign || function(t) {
38
38
  for (var s, i = 1, n = arguments.length; i < n; i++) {
39
39
  s = arguments[i];
40
- for (var p in s)
41
- if (Object.prototype.hasOwnProperty.call(s, p))
42
- t[p] = s[p];
40
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
41
+ t[p] = s[p];
43
42
  }
44
43
  return t;
45
44
  };
46
45
  return __assign.apply(this, arguments);
47
46
  };
48
- Object.defineProperty(exports, "__esModule", { value: true });
47
+ Object.defineProperty(exports2, "__esModule", { value: true });
49
48
  var defaultOptions = {
50
49
  delayFirstAttempt: false,
51
50
  jitter: "none",
@@ -64,40 +63,40 @@ var require_options = __commonJS({
64
63
  }
65
64
  return sanitized;
66
65
  }
67
- exports.getSanitizedOptions = getSanitizedOptions;
66
+ exports2.getSanitizedOptions = getSanitizedOptions;
68
67
  }
69
68
  });
70
69
 
71
70
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js
72
71
  var require_full_jitter = __commonJS({
73
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js"(exports) {
72
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js"(exports2) {
74
73
  "use strict";
75
- Object.defineProperty(exports, "__esModule", { value: true });
74
+ Object.defineProperty(exports2, "__esModule", { value: true });
76
75
  function fullJitter(delay) {
77
76
  var jitteredDelay = Math.random() * delay;
78
77
  return Math.round(jitteredDelay);
79
78
  }
80
- exports.fullJitter = fullJitter;
79
+ exports2.fullJitter = fullJitter;
81
80
  }
82
81
  });
83
82
 
84
83
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js
85
84
  var require_no_jitter = __commonJS({
86
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js"(exports) {
85
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js"(exports2) {
87
86
  "use strict";
88
- Object.defineProperty(exports, "__esModule", { value: true });
87
+ Object.defineProperty(exports2, "__esModule", { value: true });
89
88
  function noJitter(delay) {
90
89
  return delay;
91
90
  }
92
- exports.noJitter = noJitter;
91
+ exports2.noJitter = noJitter;
93
92
  }
94
93
  });
95
94
 
96
95
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/jitter.factory.js
97
96
  var require_jitter_factory = __commonJS({
98
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/jitter.factory.js"(exports) {
97
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/jitter/jitter.factory.js"(exports2) {
99
98
  "use strict";
100
- Object.defineProperty(exports, "__esModule", { value: true });
99
+ Object.defineProperty(exports2, "__esModule", { value: true });
101
100
  var full_jitter_1 = require_full_jitter();
102
101
  var no_jitter_1 = require_no_jitter();
103
102
  function JitterFactory(options) {
@@ -109,19 +108,19 @@ var require_jitter_factory = __commonJS({
109
108
  return no_jitter_1.noJitter;
110
109
  }
111
110
  }
112
- exports.JitterFactory = JitterFactory;
111
+ exports2.JitterFactory = JitterFactory;
113
112
  }
114
113
  });
115
114
 
116
115
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.base.js
117
116
  var require_delay_base = __commonJS({
118
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.base.js"(exports) {
117
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.base.js"(exports2) {
119
118
  "use strict";
120
- Object.defineProperty(exports, "__esModule", { value: true });
119
+ Object.defineProperty(exports2, "__esModule", { value: true });
121
120
  var jitter_factory_1 = require_jitter_factory();
122
121
  var Delay = (
123
122
  /** @class */
124
- function() {
123
+ (function() {
125
124
  function Delay2(options) {
126
125
  this.options = options;
127
126
  this.attempt = 0;
@@ -162,24 +161,22 @@ var require_delay_base = __commonJS({
162
161
  configurable: true
163
162
  });
164
163
  return Delay2;
165
- }()
164
+ })()
166
165
  );
167
- exports.Delay = Delay;
166
+ exports2.Delay = Delay;
168
167
  }
169
168
  });
170
169
 
171
170
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js
172
171
  var require_skip_first_delay = __commonJS({
173
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js"(exports) {
172
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js"(exports2) {
174
173
  "use strict";
175
- var __extends = exports && exports.__extends || function() {
174
+ var __extends = exports2 && exports2.__extends || /* @__PURE__ */ (function() {
176
175
  var extendStatics = function(d, b) {
177
176
  extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
178
177
  d2.__proto__ = b2;
179
178
  } || function(d2, b2) {
180
- for (var p in b2)
181
- if (b2.hasOwnProperty(p))
182
- d2[p] = b2[p];
179
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
183
180
  };
184
181
  return extendStatics(d, b);
185
182
  };
@@ -190,8 +187,8 @@ var require_skip_first_delay = __commonJS({
190
187
  }
191
188
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
192
189
  };
193
- }();
194
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
190
+ })();
191
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
195
192
  function adopt(value) {
196
193
  return value instanceof P ? value : new P(function(resolve) {
197
194
  resolve(value);
@@ -218,10 +215,9 @@ var require_skip_first_delay = __commonJS({
218
215
  step((generator = generator.apply(thisArg, _arguments || [])).next());
219
216
  });
220
217
  };
221
- var __generator = exports && exports.__generator || function(thisArg, body) {
218
+ var __generator = exports2 && exports2.__generator || function(thisArg, body) {
222
219
  var _ = { label: 0, sent: function() {
223
- if (t[0] & 1)
224
- throw t[1];
220
+ if (t[0] & 1) throw t[1];
225
221
  return t[1];
226
222
  }, trys: [], ops: [] }, f, y, t, g;
227
223
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
@@ -233,72 +229,66 @@ var require_skip_first_delay = __commonJS({
233
229
  };
234
230
  }
235
231
  function step(op) {
236
- if (f)
237
- throw new TypeError("Generator is already executing.");
238
- while (_)
239
- try {
240
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
241
- return t;
242
- if (y = 0, t)
243
- op = [op[0] & 2, t.value];
244
- switch (op[0]) {
245
- case 0:
246
- case 1:
232
+ if (f) throw new TypeError("Generator is already executing.");
233
+ while (_) try {
234
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
235
+ if (y = 0, t) op = [op[0] & 2, t.value];
236
+ switch (op[0]) {
237
+ case 0:
238
+ case 1:
239
+ t = op;
240
+ break;
241
+ case 4:
242
+ _.label++;
243
+ return { value: op[1], done: false };
244
+ case 5:
245
+ _.label++;
246
+ y = op[1];
247
+ op = [0];
248
+ continue;
249
+ case 7:
250
+ op = _.ops.pop();
251
+ _.trys.pop();
252
+ continue;
253
+ default:
254
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
255
+ _ = 0;
256
+ continue;
257
+ }
258
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
259
+ _.label = op[1];
260
+ break;
261
+ }
262
+ if (op[0] === 6 && _.label < t[1]) {
263
+ _.label = t[1];
247
264
  t = op;
248
265
  break;
249
- case 4:
250
- _.label++;
251
- return { value: op[1], done: false };
252
- case 5:
253
- _.label++;
254
- y = op[1];
255
- op = [0];
256
- continue;
257
- case 7:
258
- op = _.ops.pop();
259
- _.trys.pop();
260
- continue;
261
- default:
262
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
263
- _ = 0;
264
- continue;
265
- }
266
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
267
- _.label = op[1];
268
- break;
269
- }
270
- if (op[0] === 6 && _.label < t[1]) {
271
- _.label = t[1];
272
- t = op;
273
- break;
274
- }
275
- if (t && _.label < t[2]) {
276
- _.label = t[2];
277
- _.ops.push(op);
278
- break;
279
- }
280
- if (t[2])
281
- _.ops.pop();
282
- _.trys.pop();
283
- continue;
284
- }
285
- op = body.call(thisArg, _);
286
- } catch (e) {
287
- op = [6, e];
288
- y = 0;
289
- } finally {
290
- f = t = 0;
266
+ }
267
+ if (t && _.label < t[2]) {
268
+ _.label = t[2];
269
+ _.ops.push(op);
270
+ break;
271
+ }
272
+ if (t[2]) _.ops.pop();
273
+ _.trys.pop();
274
+ continue;
291
275
  }
292
- if (op[0] & 5)
293
- throw op[1];
276
+ op = body.call(thisArg, _);
277
+ } catch (e) {
278
+ op = [6, e];
279
+ y = 0;
280
+ } finally {
281
+ f = t = 0;
282
+ }
283
+ if (op[0] & 5) throw op[1];
294
284
  return { value: op[0] ? op[1] : void 0, done: true };
295
285
  }
296
286
  };
297
- Object.defineProperty(exports, "__esModule", { value: true });
287
+ Object.defineProperty(exports2, "__esModule", { value: true });
298
288
  var delay_base_1 = require_delay_base();
299
289
  var SkipFirstDelay = (
300
290
  /** @class */
301
- function(_super) {
291
+ (function(_super) {
302
292
  __extends(SkipFirstDelay2, _super);
303
293
  function SkipFirstDelay2() {
304
294
  return _super !== null && _super.apply(this, arguments) || this;
@@ -325,24 +315,22 @@ var require_skip_first_delay = __commonJS({
325
315
  configurable: true
326
316
  });
327
317
  return SkipFirstDelay2;
328
- }(delay_base_1.Delay)
318
+ })(delay_base_1.Delay)
329
319
  );
330
- exports.SkipFirstDelay = SkipFirstDelay;
320
+ exports2.SkipFirstDelay = SkipFirstDelay;
331
321
  }
332
322
  });
333
323
 
334
324
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/always/always.delay.js
335
325
  var require_always_delay = __commonJS({
336
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/always/always.delay.js"(exports) {
326
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/always/always.delay.js"(exports2) {
337
327
  "use strict";
338
- var __extends = exports && exports.__extends || function() {
328
+ var __extends = exports2 && exports2.__extends || /* @__PURE__ */ (function() {
339
329
  var extendStatics = function(d, b) {
340
330
  extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
341
331
  d2.__proto__ = b2;
342
332
  } || function(d2, b2) {
343
- for (var p in b2)
344
- if (b2.hasOwnProperty(p))
345
- d2[p] = b2[p];
333
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
346
334
  };
347
335
  return extendStatics(d, b);
348
336
  };
@@ -353,28 +341,28 @@ var require_always_delay = __commonJS({
353
341
  }
354
342
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
355
343
  };
356
- }();
357
- Object.defineProperty(exports, "__esModule", { value: true });
344
+ })();
345
+ Object.defineProperty(exports2, "__esModule", { value: true });
358
346
  var delay_base_1 = require_delay_base();
359
347
  var AlwaysDelay = (
360
348
  /** @class */
361
- function(_super) {
349
+ (function(_super) {
362
350
  __extends(AlwaysDelay2, _super);
363
351
  function AlwaysDelay2() {
364
352
  return _super !== null && _super.apply(this, arguments) || this;
365
353
  }
366
354
  return AlwaysDelay2;
367
- }(delay_base_1.Delay)
355
+ })(delay_base_1.Delay)
368
356
  );
369
- exports.AlwaysDelay = AlwaysDelay;
357
+ exports2.AlwaysDelay = AlwaysDelay;
370
358
  }
371
359
  });
372
360
 
373
361
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.factory.js
374
362
  var require_delay_factory = __commonJS({
375
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.factory.js"(exports) {
363
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/delay/delay.factory.js"(exports2) {
376
364
  "use strict";
377
- Object.defineProperty(exports, "__esModule", { value: true });
365
+ Object.defineProperty(exports2, "__esModule", { value: true });
378
366
  var skip_first_delay_1 = require_skip_first_delay();
379
367
  var always_delay_1 = require_always_delay();
380
368
  function DelayFactory(options, attempt) {
@@ -382,7 +370,7 @@ var require_delay_factory = __commonJS({
382
370
  delay.setAttemptNumber(attempt);
383
371
  return delay;
384
372
  }
385
- exports.DelayFactory = DelayFactory;
373
+ exports2.DelayFactory = DelayFactory;
386
374
  function initDelayClass(options) {
387
375
  if (!options.delayFirstAttempt) {
388
376
  return new skip_first_delay_1.SkipFirstDelay(options);
@@ -394,9 +382,9 @@ var require_delay_factory = __commonJS({
394
382
 
395
383
  // ../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/backoff.js
396
384
  var require_backoff = __commonJS({
397
- "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/backoff.js"(exports) {
385
+ "../../node_modules/.pnpm/exponential-backoff@3.1.1/node_modules/exponential-backoff/dist/backoff.js"(exports2) {
398
386
  "use strict";
399
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
387
+ var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
400
388
  function adopt(value) {
401
389
  return value instanceof P ? value : new P(function(resolve) {
402
390
  resolve(value);
@@ -423,10 +411,9 @@ var require_backoff = __commonJS({
423
411
  step((generator = generator.apply(thisArg, _arguments || [])).next());
424
412
  });
425
413
  };
426
- var __generator = exports && exports.__generator || function(thisArg, body) {
414
+ var __generator = exports2 && exports2.__generator || function(thisArg, body) {
427
415
  var _ = { label: 0, sent: function() {
428
- if (t[0] & 1)
429
- throw t[1];
416
+ if (t[0] & 1) throw t[1];
430
417
  return t[1];
431
418
  }, trys: [], ops: [] }, f, y, t, g;
432
419
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
@@ -438,68 +425,62 @@ var require_backoff = __commonJS({
438
425
  };
439
426
  }
440
427
  function step(op) {
441
- if (f)
442
- throw new TypeError("Generator is already executing.");
443
- while (_)
444
- try {
445
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
446
- return t;
447
- if (y = 0, t)
448
- op = [op[0] & 2, t.value];
449
- switch (op[0]) {
450
- case 0:
451
- case 1:
428
+ if (f) throw new TypeError("Generator is already executing.");
429
+ while (_) try {
430
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
431
+ if (y = 0, t) op = [op[0] & 2, t.value];
432
+ switch (op[0]) {
433
+ case 0:
434
+ case 1:
435
+ t = op;
436
+ break;
437
+ case 4:
438
+ _.label++;
439
+ return { value: op[1], done: false };
440
+ case 5:
441
+ _.label++;
442
+ y = op[1];
443
+ op = [0];
444
+ continue;
445
+ case 7:
446
+ op = _.ops.pop();
447
+ _.trys.pop();
448
+ continue;
449
+ default:
450
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
451
+ _ = 0;
452
+ continue;
453
+ }
454
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
455
+ _.label = op[1];
456
+ break;
457
+ }
458
+ if (op[0] === 6 && _.label < t[1]) {
459
+ _.label = t[1];
452
460
  t = op;
453
461
  break;
454
- case 4:
455
- _.label++;
456
- return { value: op[1], done: false };
457
- case 5:
458
- _.label++;
459
- y = op[1];
460
- op = [0];
461
- continue;
462
- case 7:
463
- op = _.ops.pop();
464
- _.trys.pop();
465
- continue;
466
- default:
467
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
468
- _ = 0;
469
- continue;
470
- }
471
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
472
- _.label = op[1];
473
- break;
474
- }
475
- if (op[0] === 6 && _.label < t[1]) {
476
- _.label = t[1];
477
- t = op;
478
- break;
479
- }
480
- if (t && _.label < t[2]) {
481
- _.label = t[2];
482
- _.ops.push(op);
483
- break;
484
- }
485
- if (t[2])
486
- _.ops.pop();
487
- _.trys.pop();
488
- continue;
489
- }
490
- op = body.call(thisArg, _);
491
- } catch (e) {
492
- op = [6, e];
493
- y = 0;
494
- } finally {
495
- f = t = 0;
462
+ }
463
+ if (t && _.label < t[2]) {
464
+ _.label = t[2];
465
+ _.ops.push(op);
466
+ break;
467
+ }
468
+ if (t[2]) _.ops.pop();
469
+ _.trys.pop();
470
+ continue;
496
471
  }
497
- if (op[0] & 5)
498
- throw op[1];
472
+ op = body.call(thisArg, _);
473
+ } catch (e) {
474
+ op = [6, e];
475
+ y = 0;
476
+ } finally {
477
+ f = t = 0;
478
+ }
479
+ if (op[0] & 5) throw op[1];
499
480
  return { value: op[0] ? op[1] : void 0, done: true };
500
481
  }
501
482
  };
502
- Object.defineProperty(exports, "__esModule", { value: true });
483
+ Object.defineProperty(exports2, "__esModule", { value: true });
503
484
  var options_1 = require_options();
504
485
  var delay_factory_1 = require_delay_factory();
505
486
  function backOff3(request, options) {
@@ -520,10 +501,10 @@ var require_backoff = __commonJS({
520
501
  });
521
502
  });
522
503
  }
523
- exports.backOff = backOff3;
504
+ exports2.backOff = backOff3;
524
505
  var BackOff = (
525
506
  /** @class */
526
- function() {
507
+ (function() {
527
508
  function BackOff2(request, options) {
528
509
  this.request = request;
529
510
  this.options = options;
@@ -535,8 +516,7 @@ var require_backoff = __commonJS({
535
516
  return __generator(this, function(_a) {
536
517
  switch (_a.label) {
537
518
  case 0:
538
- if (!!this.attemptLimitReached)
539
- return [3, 7];
519
+ if (!!this.attemptLimitReached) return [3, 7];
540
520
  _a.label = 1;
541
521
  case 1:
542
522
  _a.trys.push([1, 4, , 6]);
@@ -590,20 +570,20 @@ var require_backoff = __commonJS({
590
570
  });
591
571
  };
592
572
  return BackOff2;
593
- }()
573
+ })()
594
574
  );
595
575
  }
596
576
  });
597
577
 
598
578
  // src/index.ts
599
- var src_exports = {};
600
- __export(src_exports, {
579
+ var index_exports = {};
580
+ __export(index_exports, {
601
581
  Cognitive: () => Cognitive,
602
582
  CognitiveBeta: () => CognitiveBeta,
603
583
  ModelProvider: () => ModelProvider,
604
584
  RemoteModelProvider: () => RemoteModelProvider
605
585
  });
606
- module.exports = __toCommonJS(src_exports);
586
+ module.exports = __toCommonJS(index_exports);
607
587
 
608
588
  // src/client.ts
609
589
  var import_exponential_backoff2 = __toESM(require_backoff());
@@ -671,54 +651,57 @@ var import_exponential_backoff = __toESM(require_backoff());
671
651
  var isBrowser = () => typeof window !== "undefined" && typeof window.fetch === "function";
672
652
  var CognitiveBeta = class {
673
653
  _axiosClient;
674
- _config;
654
+ _apiUrl;
655
+ _timeout;
656
+ _withCredentials;
657
+ _headers;
675
658
  constructor(props) {
676
- this._config = {
677
- baseUrl: props.baseUrl || "https://cognitive.botpress.cloud",
678
- timeout: props.timeout || 60001,
679
- token: props.token || "",
680
- botId: props.botId || "",
681
- headers: props.headers || {}
682
- };
659
+ this._apiUrl = props.apiUrl || "https://api.botpress.cloud";
660
+ this._timeout = props.timeout || 60001;
661
+ this._withCredentials = props.withCredentials || false;
662
+ this._headers = { ...props.headers };
663
+ if (props.botId) {
664
+ this._headers["X-Bot-Id"] = props.botId;
665
+ }
666
+ if (props.token) {
667
+ this._headers["Authorization"] = `Bearer ${props.token}`;
668
+ }
683
669
  this._axiosClient = import_axios.default.create({
684
- headers: {
685
- Authorization: `Bearer ${this._config.token}`,
686
- "X-Bot-Id": this._config.botId,
687
- ...this._config.headers
688
- },
689
- baseURL: this._config.baseUrl
670
+ headers: this._headers,
671
+ withCredentials: this._withCredentials,
672
+ baseURL: this._apiUrl
690
673
  });
691
674
  }
692
675
  async generateText(input, options = {}) {
693
- const signal = options.signal ?? AbortSignal.timeout(this._config.timeout);
676
+ const signal = options.signal ?? AbortSignal.timeout(this._timeout);
694
677
  const { data } = await this._withServerRetry(
695
- () => this._axiosClient.post("/v1/generate-text", input, {
678
+ () => this._axiosClient.post("/v2/cognitive/generate-text", input, {
696
679
  signal,
697
- timeout: options.timeout ?? this._config.timeout
680
+ timeout: options.timeout ?? this._timeout
698
681
  })
699
682
  );
700
683
  return data;
701
684
  }
702
685
  async listModels(input, options = {}) {
703
- const signal = options.signal ?? AbortSignal.timeout(this._config.timeout);
686
+ const signal = options.signal ?? AbortSignal.timeout(this._timeout);
704
687
  const { data } = await this._withServerRetry(
705
- () => this._axiosClient.post("/v1/models", input, {
688
+ () => this._axiosClient.post("/v2/cognitive/models", input, {
706
689
  signal,
707
- timeout: options.timeout ?? this._config.timeout
690
+ timeout: options.timeout ?? this._timeout
708
691
  })
709
692
  );
710
693
  return data;
711
694
  }
712
695
  async *generateTextStream(request, options = {}) {
713
- const signal = options.signal ?? AbortSignal.timeout(this._config.timeout);
696
+ const signal = options.signal ?? AbortSignal.timeout(this._timeout);
714
697
  if (isBrowser()) {
715
- const res2 = await fetch(`${this._config.baseUrl}/v1/generate-text-stream`, {
698
+ const res2 = await fetch(`${this._apiUrl}/v2/cognitive/generate-text-stream`, {
716
699
  method: "POST",
717
700
  headers: {
718
- Authorization: `Bearer ${this._config.token}`,
719
- "X-Bot-Id": this._config.botId,
701
+ ...this._headers,
720
702
  "Content-Type": "application/json"
721
703
  },
704
+ credentials: this._withCredentials ? "include" : "omit",
722
705
  body: JSON.stringify({ ...request, stream: true }),
723
706
  signal
724
707
  });
@@ -733,7 +716,7 @@ var CognitiveBeta = class {
733
716
  throw new Error("No response body received for streaming request");
734
717
  }
735
718
  const reader = body.getReader();
736
- const iterable = async function* () {
719
+ const iterable = (async function* () {
737
720
  for (; ; ) {
738
721
  const { value, done } = await reader.read();
739
722
  if (done) {
@@ -743,7 +726,7 @@ var CognitiveBeta = class {
743
726
  yield value;
744
727
  }
745
728
  }
746
- }();
729
+ })();
747
730
  for await (const obj of this._ndjson(iterable)) {
748
731
  yield obj;
749
732
  }
@@ -756,7 +739,7 @@ var CognitiveBeta = class {
756
739
  {
757
740
  responseType: "stream",
758
741
  signal,
759
- timeout: options.timeout ?? this._config.timeout
742
+ timeout: options.timeout ?? this._timeout
760
743
  }
761
744
  )
762
745
  );
@@ -938,7 +921,7 @@ var getBestModels = (models, boosts = {}) => models.sort((a, b) => scoreModel(b,
938
921
  var getFastModels = (models, boosts = {}) => models.sort((a, b) => scoreModel(b, "fast", boosts) - scoreModel(a, "fast", boosts));
939
922
  var pickModel = (models, downtimes = []) => {
940
923
  const copy = [...models];
941
- const elasped = (date) => new Date().getTime() - new Date(date).getTime();
924
+ const elasped = (date) => (/* @__PURE__ */ new Date()).getTime() - new Date(date).getTime();
942
925
  const DOWNTIME_THRESHOLD = 1e3 * 60 * DOWNTIME_THRESHOLD_MINUTES;
943
926
  if (!copy.length) {
944
927
  throw new Error("At least one model is required");
@@ -1052,7 +1035,7 @@ var RemoteModelProvider = class extends ModelProvider {
1052
1035
  };
1053
1036
 
1054
1037
  // src/client.ts
1055
- var Cognitive = class {
1038
+ var Cognitive = class _Cognitive {
1056
1039
  ["$$IS_COGNITIVE"] = true;
1057
1040
  static isCognitiveClient(obj) {
1058
1041
  return obj?.$$IS_COGNITIVE === true;
@@ -1083,7 +1066,7 @@ var Cognitive = class {
1083
1066
  return this._client;
1084
1067
  }
1085
1068
  clone() {
1086
- const copy = new Cognitive({
1069
+ const copy = new _Cognitive({
1087
1070
  client: this._client.clone(),
1088
1071
  provider: this._provider,
1089
1072
  timeout: this._timeoutMs,
@@ -1167,10 +1150,7 @@ var Cognitive = class {
1167
1150
  if (!this._useBeta) {
1168
1151
  return this._generateContent(input);
1169
1152
  }
1170
- const betaClient = new CognitiveBeta({
1171
- headers: this._client.config.headers,
1172
- baseUrl: this._client.config.apiUrl.includes(".cloud") ? "https://cognitive.botpress.cloud" : "https://cognitive.botpress.dev"
1173
- });
1153
+ const betaClient = new CognitiveBeta(this._client.config);
1174
1154
  const response = await betaClient.generateText(input);
1175
1155
  return {
1176
1156
  output: {
@@ -1252,7 +1232,7 @@ var Cognitive = class {
1252
1232
  if (action === "fallback") {
1253
1233
  this._downtimes.push({
1254
1234
  ref: `${integration}:${model}`,
1255
- startedAt: new Date().toISOString(),
1235
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1256
1236
  reason: "Model is down"
1257
1237
  });
1258
1238
  this._cleanupOldDowntimes();