@superinterface/react 3.5.4 → 3.6.1

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/server.cjs CHANGED
@@ -7,134 +7,12 @@ function _array_like_to_array(arr, len) {
7
7
  function _array_without_holes(arr) {
8
8
  if (Array.isArray(arr)) return _array_like_to_array(arr);
9
9
  }
10
- function _async_iterator(iterable) {
11
- var method, async, sync, retry = 2;
12
- for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
13
- if (async && null != (method = iterable[async])) return method.call(iterable);
14
- if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
15
- async = "@@asyncIterator", sync = "@@iterator";
16
- }
17
- throw new TypeError("Object is not async iterable");
18
- }
19
- function AsyncFromSyncIterator(s) {
20
- function AsyncFromSyncIteratorContinuation(r) {
21
- if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
22
- var done = r.done;
23
- return Promise.resolve(r.value).then(function(value) {
24
- return {
25
- value: value,
26
- done: done
27
- };
28
- });
29
- }
30
- return AsyncFromSyncIterator = function(s) {
31
- this.s = s, this.n = s.next;
32
- }, AsyncFromSyncIterator.prototype = {
33
- s: null,
34
- n: null,
35
- next: function() {
36
- return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
37
- },
38
- return: function(value) {
39
- var ret = this.s.return;
40
- return void 0 === ret ? Promise.resolve({
41
- value: value,
42
- done: !0
43
- }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
44
- },
45
- throw: function(value) {
46
- var thr = this.s.return;
47
- return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
48
- }
49
- }, new AsyncFromSyncIterator(s);
50
- }
51
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
52
- try {
53
- var info = gen[key](arg);
54
- var value = info.value;
55
- } catch (error) {
56
- reject(error);
57
- return;
58
- }
59
- if (info.done) {
60
- resolve(value);
61
- } else {
62
- Promise.resolve(value).then(_next, _throw);
63
- }
64
- }
65
- function _async_to_generator(fn) {
66
- return function() {
67
- var self = this, args = arguments;
68
- return new Promise(function(resolve, reject) {
69
- var gen = fn.apply(self, args);
70
- function _next(value) {
71
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
72
- }
73
- function _throw(err) {
74
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
75
- }
76
- _next(undefined);
77
- });
78
- };
79
- }
80
- function _define_property(obj, key, value) {
81
- if (key in obj) {
82
- Object.defineProperty(obj, key, {
83
- value: value,
84
- enumerable: true,
85
- configurable: true,
86
- writable: true
87
- });
88
- } else {
89
- obj[key] = value;
90
- }
91
- return obj;
92
- }
93
10
  function _iterable_to_array(iter) {
94
11
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
95
12
  }
96
13
  function _non_iterable_spread() {
97
14
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
15
  }
99
- function _object_spread(target) {
100
- for(var i = 1; i < arguments.length; i++){
101
- var source = arguments[i] != null ? arguments[i] : {};
102
- var ownKeys = Object.keys(source);
103
- if (typeof Object.getOwnPropertySymbols === "function") {
104
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
105
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
106
- }));
107
- }
108
- ownKeys.forEach(function(key) {
109
- _define_property(target, key, source[key]);
110
- });
111
- }
112
- return target;
113
- }
114
- function ownKeys(object, enumerableOnly) {
115
- var keys = Object.keys(object);
116
- if (Object.getOwnPropertySymbols) {
117
- var symbols = Object.getOwnPropertySymbols(object);
118
- if (enumerableOnly) {
119
- symbols = symbols.filter(function(sym) {
120
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
121
- });
122
- }
123
- keys.push.apply(keys, symbols);
124
- }
125
- return keys;
126
- }
127
- function _object_spread_props(target, source) {
128
- source = source != null ? source : {};
129
- if (Object.getOwnPropertyDescriptors) {
130
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
131
- } else {
132
- ownKeys(Object(source)).forEach(function(key) {
133
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
134
- });
135
- }
136
- return target;
137
- }
138
16
  function _to_consumable_array(arr) {
139
17
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
140
18
  }
@@ -319,8 +197,8 @@ __export(server_exports, {
319
197
  module.exports = __toCommonJS(server_exports);
320
198
  // src/lib/runSteps/serializeRunStep.ts
321
199
  var import_radash = require("radash");
322
- var serializeRunStep = function(param) {
323
- var runStep = param.runStep;
200
+ var serializeRunStep = function(_ref) {
201
+ var runStep = _ref.runStep;
324
202
  return (0, import_radash.pick)(runStep, [
325
203
  "id",
326
204
  "run_id",
@@ -332,9 +210,9 @@ var serializeRunStep = function(param) {
332
210
  ]);
333
211
  };
334
212
  // src/lib/messages/serializeMessage.ts
335
- var serializeMessage = function(param) {
336
- var message = param.message;
337
- var _message_runSteps;
213
+ var serializeMessage = function(_ref) {
214
+ var _message$runSteps;
215
+ var message = _ref.message;
338
216
  return {
339
217
  id: message.id,
340
218
  role: message.role,
@@ -345,7 +223,7 @@ var serializeMessage = function(param) {
345
223
  thread_id: message.thread_id,
346
224
  attachments: message.attachments,
347
225
  metadata: message.metadata,
348
- runSteps: ((_message_runSteps = message.runSteps) !== null && _message_runSteps !== void 0 ? _message_runSteps : []).map(function(runStep) {
226
+ runSteps: ((_message$runSteps = message.runSteps) !== null && _message$runSteps !== void 0 ? _message$runSteps : []).map(function(runStep) {
349
227
  return serializeRunStep({
350
228
  runStep: runStep
351
229
  });
@@ -356,13 +234,36 @@ var serializeMessage = function(param) {
356
234
  // src/lib/messages/messagesResponse/data/messages/index.ts
357
235
  var import_p_map = __toESM(require("p-map"), 1);
358
236
  // src/lib/runSteps/getRunSteps/index.ts
359
- var getRunSteps = /*#__PURE__*/ function() {
360
- var _ref = _async_to_generator(function(param) {
237
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
238
+ try {
239
+ var i = n[a](c), u = i.value;
240
+ } catch (n2) {
241
+ return void e(n2);
242
+ }
243
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
244
+ }
245
+ function _asyncToGenerator(n) {
246
+ return function() {
247
+ var t = this, e = arguments;
248
+ return new Promise(function(r, o) {
249
+ var a = n.apply(t, e);
250
+ function _next(n2) {
251
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n2);
252
+ }
253
+ function _throw(n2) {
254
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2);
255
+ }
256
+ _next(void 0);
257
+ });
258
+ };
259
+ }
260
+ var getRunSteps = /* @__PURE__ */ function() {
261
+ var _ref2 = _asyncToGenerator(function(_ref) {
361
262
  var threadId, runId, client, runStepsResponse;
362
263
  return _ts_generator(this, function(_state) {
363
264
  switch(_state.label){
364
265
  case 0:
365
- threadId = param.threadId, runId = param.runId, client = param.client;
266
+ threadId = _ref.threadId, runId = _ref.runId, client = _ref.client;
366
267
  return [
367
268
  4,
368
269
  client.beta.threads.runs.steps.list(threadId, runId)
@@ -376,28 +277,95 @@ var getRunSteps = /*#__PURE__*/ function() {
376
277
  }
377
278
  });
378
279
  });
379
- return function getRunSteps(_) {
380
- return _ref.apply(this, arguments);
280
+ return function getRunSteps2(_x) {
281
+ return _ref2.apply(this, arguments);
381
282
  };
382
283
  }();
383
284
  // src/lib/messages/extendMessage.ts
384
- var extendMessage = /*#__PURE__*/ function() {
385
- var _ref = _async_to_generator(function(param) {
285
+ function ownKeys(e, r) {
286
+ var t = Object.keys(e);
287
+ if (Object.getOwnPropertySymbols) {
288
+ var o = Object.getOwnPropertySymbols(e);
289
+ r && (o = o.filter(function(r2) {
290
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
291
+ })), t.push.apply(t, o);
292
+ }
293
+ return t;
294
+ }
295
+ function _objectSpread(e) {
296
+ for(var r = 1; r < arguments.length; r++){
297
+ var t = null != arguments[r] ? arguments[r] : {};
298
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
299
+ _defineProperty(e, r2, t[r2]);
300
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
301
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
302
+ });
303
+ }
304
+ return e;
305
+ }
306
+ function _defineProperty(e, r, t) {
307
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
308
+ value: t,
309
+ enumerable: true,
310
+ configurable: true,
311
+ writable: true
312
+ }) : e[r] = t, e;
313
+ }
314
+ function _toPropertyKey(t) {
315
+ var i = _toPrimitive(t, "string");
316
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
317
+ }
318
+ function _toPrimitive(t, r) {
319
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
320
+ var e = t[Symbol.toPrimitive];
321
+ if (void 0 !== e) {
322
+ var i = e.call(t, r || "default");
323
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
324
+ throw new TypeError("@@toPrimitive must return a primitive value.");
325
+ }
326
+ return ("string" === r ? String : Number)(t);
327
+ }
328
+ function asyncGeneratorStep2(n, t, e, r, o, a, c) {
329
+ try {
330
+ var i = n[a](c), u = i.value;
331
+ } catch (n2) {
332
+ return void e(n2);
333
+ }
334
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
335
+ }
336
+ function _asyncToGenerator2(n) {
337
+ return function() {
338
+ var t = this, e = arguments;
339
+ return new Promise(function(r, o) {
340
+ var a = n.apply(t, e);
341
+ function _next(n2) {
342
+ asyncGeneratorStep2(a, r, o, _next, _throw, "next", n2);
343
+ }
344
+ function _throw(n2) {
345
+ asyncGeneratorStep2(a, r, o, _next, _throw, "throw", n2);
346
+ }
347
+ _next(void 0);
348
+ });
349
+ };
350
+ }
351
+ var extendMessage = /* @__PURE__ */ function() {
352
+ var _ref2 = _asyncToGenerator2(function(_ref) {
386
353
  var message, client, _tmp, _tmp1;
387
354
  return _ts_generator(this, function(_state) {
388
355
  switch(_state.label){
389
356
  case 0:
390
- message = param.message, client = param.client;
357
+ message = _ref.message, client = _ref.client;
391
358
  if (!message.run_id) {
392
359
  return [
393
360
  2,
394
- _object_spread_props(_object_spread({}, message), {
361
+ _objectSpread(_objectSpread({}, message), {}, {
395
362
  runSteps: []
396
363
  })
397
364
  ];
398
365
  }
399
366
  _tmp = [
400
- _object_spread({}, message)
367
+ _objectSpread({}, message),
368
+ {}
401
369
  ];
402
370
  _tmp1 = {};
403
371
  return [
@@ -411,27 +379,50 @@ var extendMessage = /*#__PURE__*/ function() {
411
379
  case 1:
412
380
  return [
413
381
  2,
414
- _object_spread_props.apply(void 0, _tmp.concat([
382
+ _objectSpread.apply(void 0, _tmp.concat([
415
383
  (_tmp1.runSteps = _state.sent(), _tmp1)
416
384
  ]))
417
385
  ];
418
386
  }
419
387
  });
420
388
  });
421
- return function extendMessage(_) {
422
- return _ref.apply(this, arguments);
389
+ return function extendMessage2(_x) {
390
+ return _ref2.apply(this, arguments);
423
391
  };
424
392
  }();
425
393
  // src/lib/messages/messagesResponse/data/messages/runMessages/index.ts
426
394
  var import_dayjs = __toESM(require("dayjs"), 1);
427
395
  // src/lib/messages/messagesResponse/data/messages/runMessages/getLatestRun.ts
428
- var getLatestRun = /*#__PURE__*/ function() {
429
- var _ref = _async_to_generator(function(param) {
396
+ function asyncGeneratorStep3(n, t, e, r, o, a, c) {
397
+ try {
398
+ var i = n[a](c), u = i.value;
399
+ } catch (n2) {
400
+ return void e(n2);
401
+ }
402
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
403
+ }
404
+ function _asyncToGenerator3(n) {
405
+ return function() {
406
+ var t = this, e = arguments;
407
+ return new Promise(function(r, o) {
408
+ var a = n.apply(t, e);
409
+ function _next(n2) {
410
+ asyncGeneratorStep3(a, r, o, _next, _throw, "next", n2);
411
+ }
412
+ function _throw(n2) {
413
+ asyncGeneratorStep3(a, r, o, _next, _throw, "throw", n2);
414
+ }
415
+ _next(void 0);
416
+ });
417
+ };
418
+ }
419
+ var getLatestRun = /* @__PURE__ */ function() {
420
+ var _ref2 = _asyncToGenerator3(function(_ref) {
430
421
  var threadId, client, runsResponse;
431
422
  return _ts_generator(this, function(_state) {
432
423
  switch(_state.label){
433
424
  case 0:
434
- threadId = param.threadId, client = param.client;
425
+ threadId = _ref.threadId, client = _ref.client;
435
426
  return [
436
427
  4,
437
428
  client.beta.threads.runs.list(threadId, {
@@ -447,8 +438,8 @@ var getLatestRun = /*#__PURE__*/ function() {
447
438
  }
448
439
  });
449
440
  });
450
- return function getLatestRun(_) {
451
- return _ref.apply(this, arguments);
441
+ return function getLatestRun2(_x) {
442
+ return _ref2.apply(this, arguments);
452
443
  };
453
444
  }();
454
445
  // src/lib/optimistic/optimisticId.ts
@@ -457,19 +448,42 @@ var optimisticId = function() {
457
448
  return "-".concat((0, import_radash2.uid)(24));
458
449
  };
459
450
  // src/lib/messages/messagesResponse/data/messages/runMessages/index.ts
451
+ function asyncGeneratorStep4(n, t, e, r, o, a, c) {
452
+ try {
453
+ var i = n[a](c), u = i.value;
454
+ } catch (n2) {
455
+ return void e(n2);
456
+ }
457
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
458
+ }
459
+ function _asyncToGenerator4(n) {
460
+ return function() {
461
+ var t = this, e = arguments;
462
+ return new Promise(function(r, o) {
463
+ var a = n.apply(t, e);
464
+ function _next(n2) {
465
+ asyncGeneratorStep4(a, r, o, _next, _throw, "next", n2);
466
+ }
467
+ function _throw(n2) {
468
+ asyncGeneratorStep4(a, r, o, _next, _throw, "throw", n2);
469
+ }
470
+ _next(void 0);
471
+ });
472
+ };
473
+ }
460
474
  var progressStatuses = [
461
475
  "queued",
462
476
  "in_progress",
463
477
  "requires_action",
464
478
  "cancelling"
465
479
  ];
466
- var runMessages = /*#__PURE__*/ function() {
467
- var _ref = _async_to_generator(function(param) {
480
+ var runMessages = /* @__PURE__ */ function() {
481
+ var _ref2 = _asyncToGenerator4(function(_ref) {
468
482
  var result, threadId, client, latestRun, messageFromLatestRun;
469
483
  return _ts_generator(this, function(_state) {
470
484
  switch(_state.label){
471
485
  case 0:
472
- result = param.result, threadId = param.threadId, client = param.client;
486
+ result = _ref.result, threadId = _ref.threadId, client = _ref.client;
473
487
  return [
474
488
  4,
475
489
  getLatestRun({
@@ -532,18 +546,41 @@ var runMessages = /*#__PURE__*/ function() {
532
546
  }
533
547
  });
534
548
  });
535
- return function runMessages(_) {
536
- return _ref.apply(this, arguments);
549
+ return function runMessages2(_x) {
550
+ return _ref2.apply(this, arguments);
537
551
  };
538
552
  }();
539
553
  // src/lib/messages/messagesResponse/data/messages/index.ts
540
- var messages = /*#__PURE__*/ function() {
541
- var _ref = _async_to_generator(function(param) {
554
+ function asyncGeneratorStep5(n, t, e, r, o, a, c) {
555
+ try {
556
+ var i = n[a](c), u = i.value;
557
+ } catch (n2) {
558
+ return void e(n2);
559
+ }
560
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
561
+ }
562
+ function _asyncToGenerator5(n) {
563
+ return function() {
564
+ var t = this, e = arguments;
565
+ return new Promise(function(r, o) {
566
+ var a = n.apply(t, e);
567
+ function _next(n2) {
568
+ asyncGeneratorStep5(a, r, o, _next, _throw, "next", n2);
569
+ }
570
+ function _throw(n2) {
571
+ asyncGeneratorStep5(a, r, o, _next, _throw, "throw", n2);
572
+ }
573
+ _next(void 0);
574
+ });
575
+ };
576
+ }
577
+ var messages = /* @__PURE__ */ function() {
578
+ var _ref2 = _asyncToGenerator5(function(_ref) {
542
579
  var messagesResponse2, pageParam, threadId, client, result;
543
580
  return _ts_generator(this, function(_state) {
544
581
  switch(_state.label){
545
582
  case 0:
546
- messagesResponse2 = param.messagesResponse, pageParam = param.pageParam, threadId = param.threadId, client = param.client;
583
+ messagesResponse2 = _ref.messagesResponse, pageParam = _ref.pageParam, threadId = _ref.threadId, client = _ref.client;
547
584
  return [
548
585
  4,
549
586
  (0, import_p_map.default)(messagesResponse2.data, function(message) {
@@ -579,18 +616,41 @@ var messages = /*#__PURE__*/ function() {
579
616
  }
580
617
  });
581
618
  });
582
- return function messages(_) {
583
- return _ref.apply(this, arguments);
619
+ return function messages2(_x) {
620
+ return _ref2.apply(this, arguments);
584
621
  };
585
622
  }();
586
623
  // src/lib/messages/messagesResponse/data/index.ts
587
- var data = /*#__PURE__*/ function() {
588
- var _ref = _async_to_generator(function(param) {
624
+ function asyncGeneratorStep6(n, t, e, r, o, a, c) {
625
+ try {
626
+ var i = n[a](c), u = i.value;
627
+ } catch (n2) {
628
+ return void e(n2);
629
+ }
630
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
631
+ }
632
+ function _asyncToGenerator6(n) {
633
+ return function() {
634
+ var t = this, e = arguments;
635
+ return new Promise(function(r, o) {
636
+ var a = n.apply(t, e);
637
+ function _next(n2) {
638
+ asyncGeneratorStep6(a, r, o, _next, _throw, "next", n2);
639
+ }
640
+ function _throw(n2) {
641
+ asyncGeneratorStep6(a, r, o, _next, _throw, "throw", n2);
642
+ }
643
+ _next(void 0);
644
+ });
645
+ };
646
+ }
647
+ var data = /* @__PURE__ */ function() {
648
+ var _ref2 = _asyncToGenerator6(function(_ref) {
589
649
  var messagesResponse2, pageParam, threadId, client;
590
650
  return _ts_generator(this, function(_state) {
591
651
  switch(_state.label){
592
652
  case 0:
593
- messagesResponse2 = param.messagesResponse, pageParam = param.pageParam, threadId = param.threadId, client = param.client;
653
+ messagesResponse2 = _ref.messagesResponse, pageParam = _ref.pageParam, threadId = _ref.threadId, client = _ref.client;
594
654
  return [
595
655
  4,
596
656
  messages({
@@ -612,31 +672,97 @@ var data = /*#__PURE__*/ function() {
612
672
  }
613
673
  });
614
674
  });
615
- return function data(_) {
616
- return _ref.apply(this, arguments);
675
+ return function data2(_x) {
676
+ return _ref2.apply(this, arguments);
617
677
  };
618
678
  }();
619
679
  // src/lib/messages/messagesResponse/limit.ts
620
680
  var limit = 10;
621
681
  // src/lib/messages/messagesResponse/hasNextPage.ts
622
- var hasNextPage = function(param) {
623
- var messagesResponse2 = param.messagesResponse;
682
+ var hasNextPage = function(_ref) {
683
+ var messagesResponse2 = _ref.messagesResponse;
624
684
  if (messagesResponse2.data.length < limit) return false;
625
685
  return messagesResponse2.hasNextPage();
626
686
  };
627
687
  // src/lib/messages/messagesResponse/index.ts
628
- var messagesResponse = /*#__PURE__*/ function() {
629
- var _ref = _async_to_generator(function(param) {
688
+ function ownKeys2(e, r) {
689
+ var t = Object.keys(e);
690
+ if (Object.getOwnPropertySymbols) {
691
+ var o = Object.getOwnPropertySymbols(e);
692
+ r && (o = o.filter(function(r2) {
693
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
694
+ })), t.push.apply(t, o);
695
+ }
696
+ return t;
697
+ }
698
+ function _objectSpread2(e) {
699
+ for(var r = 1; r < arguments.length; r++){
700
+ var t = null != arguments[r] ? arguments[r] : {};
701
+ r % 2 ? ownKeys2(Object(t), true).forEach(function(r2) {
702
+ _defineProperty2(e, r2, t[r2]);
703
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r2) {
704
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
705
+ });
706
+ }
707
+ return e;
708
+ }
709
+ function _defineProperty2(e, r, t) {
710
+ return (r = _toPropertyKey2(r)) in e ? Object.defineProperty(e, r, {
711
+ value: t,
712
+ enumerable: true,
713
+ configurable: true,
714
+ writable: true
715
+ }) : e[r] = t, e;
716
+ }
717
+ function _toPropertyKey2(t) {
718
+ var i = _toPrimitive2(t, "string");
719
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
720
+ }
721
+ function _toPrimitive2(t, r) {
722
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
723
+ var e = t[Symbol.toPrimitive];
724
+ if (void 0 !== e) {
725
+ var i = e.call(t, r || "default");
726
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
727
+ throw new TypeError("@@toPrimitive must return a primitive value.");
728
+ }
729
+ return ("string" === r ? String : Number)(t);
730
+ }
731
+ function asyncGeneratorStep7(n, t, e, r, o, a, c) {
732
+ try {
733
+ var i = n[a](c), u = i.value;
734
+ } catch (n2) {
735
+ return void e(n2);
736
+ }
737
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
738
+ }
739
+ function _asyncToGenerator7(n) {
740
+ return function() {
741
+ var t = this, e = arguments;
742
+ return new Promise(function(r, o) {
743
+ var a = n.apply(t, e);
744
+ function _next(n2) {
745
+ asyncGeneratorStep7(a, r, o, _next, _throw, "next", n2);
746
+ }
747
+ function _throw(n2) {
748
+ asyncGeneratorStep7(a, r, o, _next, _throw, "throw", n2);
749
+ }
750
+ _next(void 0);
751
+ });
752
+ };
753
+ }
754
+ var messagesResponse = /* @__PURE__ */ function() {
755
+ var _ref2 = _asyncToGenerator7(function(_ref) {
630
756
  var client, threadId, pageParam, messagesResponse2, _tmp;
631
757
  return _ts_generator(this, function(_state) {
632
758
  switch(_state.label){
633
759
  case 0:
634
- client = param.client, threadId = param.threadId, pageParam = param.pageParam;
760
+ client = _ref.client, threadId = _ref.threadId, pageParam = _ref.pageParam;
635
761
  return [
636
762
  4,
637
- client.beta.threads.messages.list(threadId, _object_spread_props(_object_spread({}, pageParam ? {
763
+ client.beta.threads.messages.list(threadId, _objectSpread2(_objectSpread2({}, pageParam ? {
638
764
  after: pageParam
639
- } : {}), {
765
+ } : {}), {}, {
640
766
  limit: limit
641
767
  }))
642
768
  ];
@@ -663,14 +789,14 @@ var messagesResponse = /*#__PURE__*/ function() {
663
789
  }
664
790
  });
665
791
  });
666
- return function messagesResponse(_) {
667
- return _ref.apply(this, arguments);
792
+ return function messagesResponse2(_x) {
793
+ return _ref2.apply(this, arguments);
668
794
  };
669
795
  }();
670
796
  // src/lib/runs/serializeRun.ts
671
797
  var import_radash3 = require("radash");
672
- var serializeRun = function(param) {
673
- var run = param.run;
798
+ var serializeRun = function(_ref) {
799
+ var run = _ref.run;
674
800
  return (0, import_radash3.pick)(run, [
675
801
  "id",
676
802
  "thread_id",
@@ -679,19 +805,42 @@ var serializeRun = function(param) {
679
805
  ]);
680
806
  };
681
807
  // src/lib/streams/enqueueJson.ts
682
- var enqueueJson = function(param) {
683
- var controller = param.controller, value = param.value;
808
+ var enqueueJson = function(_ref) {
809
+ var controller = _ref.controller, value = _ref.value;
684
810
  return controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
685
811
  };
686
812
  // src/lib/messages/createMessageResponse/actionsStream.ts
687
813
  var import_p_map2 = __toESM(require("p-map"), 1);
688
- var actionsStream = /*#__PURE__*/ function() {
689
- var _ref = _async_to_generator(function(param) {
814
+ function asyncGeneratorStep8(n, t, e, r, o, a, c) {
815
+ try {
816
+ var i = n[a](c), u = i.value;
817
+ } catch (n2) {
818
+ return void e(n2);
819
+ }
820
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
821
+ }
822
+ function _asyncToGenerator8(n) {
823
+ return function() {
824
+ var t = this, e = arguments;
825
+ return new Promise(function(r, o) {
826
+ var a = n.apply(t, e);
827
+ function _next(n2) {
828
+ asyncGeneratorStep8(a, r, o, _next, _throw, "next", n2);
829
+ }
830
+ function _throw(n2) {
831
+ asyncGeneratorStep8(a, r, o, _next, _throw, "throw", n2);
832
+ }
833
+ _next(void 0);
834
+ });
835
+ };
836
+ }
837
+ var actionsStream = /* @__PURE__ */ function() {
838
+ var _ref2 = _asyncToGenerator8(function(_ref) {
690
839
  var client, run, handleToolCall, controller, toolCalls, _, _1, _tmp, _tmp1;
691
840
  return _ts_generator(this, function(_state) {
692
841
  switch(_state.label){
693
842
  case 0:
694
- client = param.client, run = param.run, handleToolCall = param.handleToolCall, controller = param.controller;
843
+ client = _ref.client, run = _ref.run, handleToolCall = _ref.handleToolCall, controller = _ref.controller;
695
844
  if (!run.required_action) {
696
845
  throw new Error("Run does not have a required action");
697
846
  }
@@ -722,19 +871,84 @@ var actionsStream = /*#__PURE__*/ function() {
722
871
  }
723
872
  });
724
873
  });
725
- return function actionsStream(_) {
726
- return _ref.apply(this, arguments);
874
+ return function actionsStream2(_x) {
875
+ return _ref2.apply(this, arguments);
727
876
  };
728
877
  }();
729
878
  // src/lib/messages/createMessageResponse/handleStream.ts
730
- var handleStream = /*#__PURE__*/ function() {
731
- var _ref = _async_to_generator(function(param) {
732
- var client, stream, controller, handleToolCall, onEvent, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value, _tmp, err;
879
+ function asyncGeneratorStep9(n, t, e, r, o, a, c) {
880
+ try {
881
+ var i = n[a](c), u = i.value;
882
+ } catch (n2) {
883
+ return void e(n2);
884
+ }
885
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
886
+ }
887
+ function _asyncToGenerator9(n) {
888
+ return function() {
889
+ var t = this, e = arguments;
890
+ return new Promise(function(r, o) {
891
+ var a = n.apply(t, e);
892
+ function _next(n2) {
893
+ asyncGeneratorStep9(a, r, o, _next, _throw, "next", n2);
894
+ }
895
+ function _throw(n2) {
896
+ asyncGeneratorStep9(a, r, o, _next, _throw, "throw", n2);
897
+ }
898
+ _next(void 0);
899
+ });
900
+ };
901
+ }
902
+ function _asyncIterator(r) {
903
+ var n, t, o, e = 2;
904
+ for("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;){
905
+ if (t && null != (n = r[t])) return n.call(r);
906
+ if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
907
+ t = "@@asyncIterator", o = "@@iterator";
908
+ }
909
+ throw new TypeError("Object is not async iterable");
910
+ }
911
+ function AsyncFromSyncIterator(r) {
912
+ function AsyncFromSyncIteratorContinuation(r2) {
913
+ if (Object(r2) !== r2) return Promise.reject(new TypeError(r2 + " is not an object."));
914
+ var n = r2.done;
915
+ return Promise.resolve(r2.value).then(function(r3) {
916
+ return {
917
+ value: r3,
918
+ done: n
919
+ };
920
+ });
921
+ }
922
+ return AsyncFromSyncIterator = function AsyncFromSyncIterator2(r2) {
923
+ this.s = r2, this.n = r2.next;
924
+ }, AsyncFromSyncIterator.prototype = {
925
+ s: null,
926
+ n: null,
927
+ next: function next() {
928
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
929
+ },
930
+ return: function _return(r2) {
931
+ var n = this.s.return;
932
+ return void 0 === n ? Promise.resolve({
933
+ value: r2,
934
+ done: true
935
+ }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
936
+ },
937
+ throw: function _throw(r2) {
938
+ var n = this.s.return;
939
+ return void 0 === n ? Promise.reject(r2) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
940
+ }
941
+ }, new AsyncFromSyncIterator(r);
942
+ }
943
+ var _handleStream = /* @__PURE__ */ function() {
944
+ var _ref2 = _asyncToGenerator9(function(_ref) {
945
+ var client, stream, controller, handleToolCall, onEvent, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, _tmp, err;
733
946
  return _ts_generator(this, function(_state) {
734
947
  switch(_state.label){
735
948
  case 0:
736
- client = param.client, stream = param.stream, controller = param.controller, handleToolCall = param.handleToolCall, onEvent = param.onEvent;
737
- _iteratorAbruptCompletion = false, _didIteratorError = false;
949
+ client = _ref.client, stream = _ref.stream, controller = _ref.controller, handleToolCall = _ref.handleToolCall, onEvent = _ref.onEvent;
950
+ _iteratorAbruptCompletion = false;
951
+ _didIteratorError = false;
738
952
  _state.label = 1;
739
953
  case 1:
740
954
  _state.trys.push([
@@ -743,7 +957,7 @@ var handleStream = /*#__PURE__*/ function() {
743
957
  15,
744
958
  20
745
959
  ]);
746
- _iterator = _async_iterator(stream);
960
+ _iterator = _asyncIterator(stream);
747
961
  _state.label = 2;
748
962
  case 2:
749
963
  return [
@@ -755,8 +969,7 @@ var handleStream = /*#__PURE__*/ function() {
755
969
  3,
756
970
  13
757
971
  ];
758
- _value = _step.value;
759
- value = _value;
972
+ value = _step.value;
760
973
  onEvent({
761
974
  controller: controller,
762
975
  event: value.event,
@@ -879,7 +1092,7 @@ var handleStream = /*#__PURE__*/ function() {
879
1092
  case 9:
880
1093
  return [
881
1094
  4,
882
- handleStream.apply(void 0, [
1095
+ _handleStream.apply(void 0, [
883
1096
  (_tmp.stream = _state.sent(), _tmp.controller = controller, _tmp.handleToolCall = handleToolCall, _tmp.onEvent = onEvent, _tmp)
884
1097
  ])
885
1098
  ];
@@ -956,16 +1169,39 @@ var handleStream = /*#__PURE__*/ function() {
956
1169
  }
957
1170
  });
958
1171
  });
959
- return function handleStream(_) {
960
- return _ref.apply(this, arguments);
1172
+ return function handleStream(_x) {
1173
+ return _ref2.apply(this, arguments);
961
1174
  };
962
1175
  }();
963
1176
  // src/lib/messages/createMessageResponse/index.ts
964
- var createMessageResponse = function(param) {
965
- var client = param.client, createRunStream = param.createRunStream, handleToolCall = param.handleToolCall, _param_onStart = param.onStart, onStart = _param_onStart === void 0 ? function() {} : _param_onStart, _param_onError = param.onError, onError = _param_onError === void 0 ? function() {} : _param_onError, _param_onClose = param.onClose, onClose = _param_onClose === void 0 ? function() {} : _param_onClose, _param_onEvent = param.onEvent, onEvent = _param_onEvent === void 0 ? function() {} : _param_onEvent;
1177
+ function asyncGeneratorStep10(n, t, e, r, o, a, c) {
1178
+ try {
1179
+ var i = n[a](c), u = i.value;
1180
+ } catch (n2) {
1181
+ return void e(n2);
1182
+ }
1183
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
1184
+ }
1185
+ function _asyncToGenerator10(n) {
1186
+ return function() {
1187
+ var t = this, e = arguments;
1188
+ return new Promise(function(r, o) {
1189
+ var a = n.apply(t, e);
1190
+ function _next(n2) {
1191
+ asyncGeneratorStep10(a, r, o, _next, _throw, "next", n2);
1192
+ }
1193
+ function _throw(n2) {
1194
+ asyncGeneratorStep10(a, r, o, _next, _throw, "throw", n2);
1195
+ }
1196
+ _next(void 0);
1197
+ });
1198
+ };
1199
+ }
1200
+ var createMessageResponse = function(_ref) {
1201
+ var client = _ref.client, createRunStream = _ref.createRunStream, handleToolCall = _ref.handleToolCall, _ref_onStart = _ref.onStart, onStart = _ref_onStart === void 0 ? function() {} : _ref_onStart, _ref_onError = _ref.onError, onError = _ref_onError === void 0 ? function() {} : _ref_onError, _ref_onClose = _ref.onClose, onClose = _ref_onClose === void 0 ? function() {} : _ref_onClose, _ref_onEvent = _ref.onEvent, onEvent = _ref_onEvent === void 0 ? function() {} : _ref_onEvent;
966
1202
  return new ReadableStream({
967
1203
  start: function start(controller) {
968
- return _async_to_generator(function() {
1204
+ return _asyncToGenerator10(function() {
969
1205
  var error;
970
1206
  return _ts_generator(this, function(_state) {
971
1207
  switch(_state.label){
@@ -983,7 +1219,7 @@ var createMessageResponse = function(param) {
983
1219
  ]);
984
1220
  return [
985
1221
  4,
986
- handleStream({
1222
+ _handleStream({
987
1223
  client: client,
988
1224
  stream: createRunStream,
989
1225
  controller: controller,