@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.js CHANGED
@@ -7,137 +7,19 @@ 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
  }
19
+ function _type_of(obj) {
20
+ "@swc/helpers - typeof";
21
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
22
+ }
141
23
  function _unsupported_iterable_to_array(o, minLen) {
142
24
  if (!o) return;
143
25
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -242,8 +124,8 @@ function _ts_generator(thisArg, body) {
242
124
  }
243
125
  }
244
126
  import { pick } from "radash";
245
- var serializeRunStep = function(param) {
246
- var runStep = param.runStep;
127
+ var serializeRunStep = function(_ref) {
128
+ var runStep = _ref.runStep;
247
129
  return pick(runStep, [
248
130
  "id",
249
131
  "run_id",
@@ -255,9 +137,9 @@ var serializeRunStep = function(param) {
255
137
  ]);
256
138
  };
257
139
  // src/lib/messages/serializeMessage.ts
258
- var serializeMessage = function(param) {
259
- var message = param.message;
260
- var _message_runSteps;
140
+ var serializeMessage = function(_ref) {
141
+ var _message$runSteps;
142
+ var message = _ref.message;
261
143
  return {
262
144
  id: message.id,
263
145
  role: message.role,
@@ -268,7 +150,7 @@ var serializeMessage = function(param) {
268
150
  thread_id: message.thread_id,
269
151
  attachments: message.attachments,
270
152
  metadata: message.metadata,
271
- runSteps: ((_message_runSteps = message.runSteps) !== null && _message_runSteps !== void 0 ? _message_runSteps : []).map(function(runStep) {
153
+ runSteps: ((_message$runSteps = message.runSteps) !== null && _message$runSteps !== void 0 ? _message$runSteps : []).map(function(runStep) {
272
154
  return serializeRunStep({
273
155
  runStep: runStep
274
156
  });
@@ -279,13 +161,36 @@ var serializeMessage = function(param) {
279
161
  // src/lib/messages/messagesResponse/data/messages/index.ts
280
162
  import pMap from "p-map";
281
163
  // src/lib/runSteps/getRunSteps/index.ts
282
- var getRunSteps = /*#__PURE__*/ function() {
283
- var _ref = _async_to_generator(function(param) {
164
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
165
+ try {
166
+ var i = n[a](c), u = i.value;
167
+ } catch (n2) {
168
+ return void e(n2);
169
+ }
170
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
171
+ }
172
+ function _asyncToGenerator(n) {
173
+ return function() {
174
+ var t = this, e = arguments;
175
+ return new Promise(function(r, o) {
176
+ var a = n.apply(t, e);
177
+ function _next(n2) {
178
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n2);
179
+ }
180
+ function _throw(n2) {
181
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2);
182
+ }
183
+ _next(void 0);
184
+ });
185
+ };
186
+ }
187
+ var getRunSteps = /* @__PURE__ */ function() {
188
+ var _ref2 = _asyncToGenerator(function(_ref) {
284
189
  var threadId, runId, client, runStepsResponse;
285
190
  return _ts_generator(this, function(_state) {
286
191
  switch(_state.label){
287
192
  case 0:
288
- threadId = param.threadId, runId = param.runId, client = param.client;
193
+ threadId = _ref.threadId, runId = _ref.runId, client = _ref.client;
289
194
  return [
290
195
  4,
291
196
  client.beta.threads.runs.steps.list(threadId, runId)
@@ -299,28 +204,95 @@ var getRunSteps = /*#__PURE__*/ function() {
299
204
  }
300
205
  });
301
206
  });
302
- return function getRunSteps(_) {
303
- return _ref.apply(this, arguments);
207
+ return function getRunSteps2(_x) {
208
+ return _ref2.apply(this, arguments);
304
209
  };
305
210
  }();
306
211
  // src/lib/messages/extendMessage.ts
307
- var extendMessage = /*#__PURE__*/ function() {
308
- var _ref = _async_to_generator(function(param) {
212
+ function ownKeys(e, r) {
213
+ var t = Object.keys(e);
214
+ if (Object.getOwnPropertySymbols) {
215
+ var o = Object.getOwnPropertySymbols(e);
216
+ r && (o = o.filter(function(r2) {
217
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
218
+ })), t.push.apply(t, o);
219
+ }
220
+ return t;
221
+ }
222
+ function _objectSpread(e) {
223
+ for(var r = 1; r < arguments.length; r++){
224
+ var t = null != arguments[r] ? arguments[r] : {};
225
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
226
+ _defineProperty(e, r2, t[r2]);
227
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
228
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
229
+ });
230
+ }
231
+ return e;
232
+ }
233
+ function _defineProperty(e, r, t) {
234
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
235
+ value: t,
236
+ enumerable: true,
237
+ configurable: true,
238
+ writable: true
239
+ }) : e[r] = t, e;
240
+ }
241
+ function _toPropertyKey(t) {
242
+ var i = _toPrimitive(t, "string");
243
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
244
+ }
245
+ function _toPrimitive(t, r) {
246
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
247
+ var e = t[Symbol.toPrimitive];
248
+ if (void 0 !== e) {
249
+ var i = e.call(t, r || "default");
250
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
251
+ throw new TypeError("@@toPrimitive must return a primitive value.");
252
+ }
253
+ return ("string" === r ? String : Number)(t);
254
+ }
255
+ function asyncGeneratorStep2(n, t, e, r, o, a, c) {
256
+ try {
257
+ var i = n[a](c), u = i.value;
258
+ } catch (n2) {
259
+ return void e(n2);
260
+ }
261
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
262
+ }
263
+ function _asyncToGenerator2(n) {
264
+ return function() {
265
+ var t = this, e = arguments;
266
+ return new Promise(function(r, o) {
267
+ var a = n.apply(t, e);
268
+ function _next(n2) {
269
+ asyncGeneratorStep2(a, r, o, _next, _throw, "next", n2);
270
+ }
271
+ function _throw(n2) {
272
+ asyncGeneratorStep2(a, r, o, _next, _throw, "throw", n2);
273
+ }
274
+ _next(void 0);
275
+ });
276
+ };
277
+ }
278
+ var extendMessage = /* @__PURE__ */ function() {
279
+ var _ref2 = _asyncToGenerator2(function(_ref) {
309
280
  var message, client, _tmp, _tmp1;
310
281
  return _ts_generator(this, function(_state) {
311
282
  switch(_state.label){
312
283
  case 0:
313
- message = param.message, client = param.client;
284
+ message = _ref.message, client = _ref.client;
314
285
  if (!message.run_id) {
315
286
  return [
316
287
  2,
317
- _object_spread_props(_object_spread({}, message), {
288
+ _objectSpread(_objectSpread({}, message), {}, {
318
289
  runSteps: []
319
290
  })
320
291
  ];
321
292
  }
322
293
  _tmp = [
323
- _object_spread({}, message)
294
+ _objectSpread({}, message),
295
+ {}
324
296
  ];
325
297
  _tmp1 = {};
326
298
  return [
@@ -334,27 +306,50 @@ var extendMessage = /*#__PURE__*/ function() {
334
306
  case 1:
335
307
  return [
336
308
  2,
337
- _object_spread_props.apply(void 0, _tmp.concat([
309
+ _objectSpread.apply(void 0, _tmp.concat([
338
310
  (_tmp1.runSteps = _state.sent(), _tmp1)
339
311
  ]))
340
312
  ];
341
313
  }
342
314
  });
343
315
  });
344
- return function extendMessage(_) {
345
- return _ref.apply(this, arguments);
316
+ return function extendMessage2(_x) {
317
+ return _ref2.apply(this, arguments);
346
318
  };
347
319
  }();
348
320
  // src/lib/messages/messagesResponse/data/messages/runMessages/index.ts
349
321
  import dayjs from "dayjs";
350
322
  // src/lib/messages/messagesResponse/data/messages/runMessages/getLatestRun.ts
351
- var getLatestRun = /*#__PURE__*/ function() {
352
- var _ref = _async_to_generator(function(param) {
323
+ function asyncGeneratorStep3(n, t, e, r, o, a, c) {
324
+ try {
325
+ var i = n[a](c), u = i.value;
326
+ } catch (n2) {
327
+ return void e(n2);
328
+ }
329
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
330
+ }
331
+ function _asyncToGenerator3(n) {
332
+ return function() {
333
+ var t = this, e = arguments;
334
+ return new Promise(function(r, o) {
335
+ var a = n.apply(t, e);
336
+ function _next(n2) {
337
+ asyncGeneratorStep3(a, r, o, _next, _throw, "next", n2);
338
+ }
339
+ function _throw(n2) {
340
+ asyncGeneratorStep3(a, r, o, _next, _throw, "throw", n2);
341
+ }
342
+ _next(void 0);
343
+ });
344
+ };
345
+ }
346
+ var getLatestRun = /* @__PURE__ */ function() {
347
+ var _ref2 = _asyncToGenerator3(function(_ref) {
353
348
  var threadId, client, runsResponse;
354
349
  return _ts_generator(this, function(_state) {
355
350
  switch(_state.label){
356
351
  case 0:
357
- threadId = param.threadId, client = param.client;
352
+ threadId = _ref.threadId, client = _ref.client;
358
353
  return [
359
354
  4,
360
355
  client.beta.threads.runs.list(threadId, {
@@ -370,8 +365,8 @@ var getLatestRun = /*#__PURE__*/ function() {
370
365
  }
371
366
  });
372
367
  });
373
- return function getLatestRun(_) {
374
- return _ref.apply(this, arguments);
368
+ return function getLatestRun2(_x) {
369
+ return _ref2.apply(this, arguments);
375
370
  };
376
371
  }();
377
372
  // src/lib/optimistic/optimisticId.ts
@@ -380,19 +375,42 @@ var optimisticId = function() {
380
375
  return "-".concat(uid(24));
381
376
  };
382
377
  // src/lib/messages/messagesResponse/data/messages/runMessages/index.ts
378
+ function asyncGeneratorStep4(n, t, e, r, o, a, c) {
379
+ try {
380
+ var i = n[a](c), u = i.value;
381
+ } catch (n2) {
382
+ return void e(n2);
383
+ }
384
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
385
+ }
386
+ function _asyncToGenerator4(n) {
387
+ return function() {
388
+ var t = this, e = arguments;
389
+ return new Promise(function(r, o) {
390
+ var a = n.apply(t, e);
391
+ function _next(n2) {
392
+ asyncGeneratorStep4(a, r, o, _next, _throw, "next", n2);
393
+ }
394
+ function _throw(n2) {
395
+ asyncGeneratorStep4(a, r, o, _next, _throw, "throw", n2);
396
+ }
397
+ _next(void 0);
398
+ });
399
+ };
400
+ }
383
401
  var progressStatuses = [
384
402
  "queued",
385
403
  "in_progress",
386
404
  "requires_action",
387
405
  "cancelling"
388
406
  ];
389
- var runMessages = /*#__PURE__*/ function() {
390
- var _ref = _async_to_generator(function(param) {
407
+ var runMessages = /* @__PURE__ */ function() {
408
+ var _ref2 = _asyncToGenerator4(function(_ref) {
391
409
  var result, threadId, client, latestRun, messageFromLatestRun;
392
410
  return _ts_generator(this, function(_state) {
393
411
  switch(_state.label){
394
412
  case 0:
395
- result = param.result, threadId = param.threadId, client = param.client;
413
+ result = _ref.result, threadId = _ref.threadId, client = _ref.client;
396
414
  return [
397
415
  4,
398
416
  getLatestRun({
@@ -455,18 +473,41 @@ var runMessages = /*#__PURE__*/ function() {
455
473
  }
456
474
  });
457
475
  });
458
- return function runMessages(_) {
459
- return _ref.apply(this, arguments);
476
+ return function runMessages2(_x) {
477
+ return _ref2.apply(this, arguments);
460
478
  };
461
479
  }();
462
480
  // src/lib/messages/messagesResponse/data/messages/index.ts
463
- var messages = /*#__PURE__*/ function() {
464
- var _ref = _async_to_generator(function(param) {
481
+ function asyncGeneratorStep5(n, t, e, r, o, a, c) {
482
+ try {
483
+ var i = n[a](c), u = i.value;
484
+ } catch (n2) {
485
+ return void e(n2);
486
+ }
487
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
488
+ }
489
+ function _asyncToGenerator5(n) {
490
+ return function() {
491
+ var t = this, e = arguments;
492
+ return new Promise(function(r, o) {
493
+ var a = n.apply(t, e);
494
+ function _next(n2) {
495
+ asyncGeneratorStep5(a, r, o, _next, _throw, "next", n2);
496
+ }
497
+ function _throw(n2) {
498
+ asyncGeneratorStep5(a, r, o, _next, _throw, "throw", n2);
499
+ }
500
+ _next(void 0);
501
+ });
502
+ };
503
+ }
504
+ var messages = /* @__PURE__ */ function() {
505
+ var _ref2 = _asyncToGenerator5(function(_ref) {
465
506
  var messagesResponse2, pageParam, threadId, client, result;
466
507
  return _ts_generator(this, function(_state) {
467
508
  switch(_state.label){
468
509
  case 0:
469
- messagesResponse2 = param.messagesResponse, pageParam = param.pageParam, threadId = param.threadId, client = param.client;
510
+ messagesResponse2 = _ref.messagesResponse, pageParam = _ref.pageParam, threadId = _ref.threadId, client = _ref.client;
470
511
  return [
471
512
  4,
472
513
  pMap(messagesResponse2.data, function(message) {
@@ -502,18 +543,41 @@ var messages = /*#__PURE__*/ function() {
502
543
  }
503
544
  });
504
545
  });
505
- return function messages(_) {
506
- return _ref.apply(this, arguments);
546
+ return function messages2(_x) {
547
+ return _ref2.apply(this, arguments);
507
548
  };
508
549
  }();
509
550
  // src/lib/messages/messagesResponse/data/index.ts
510
- var data = /*#__PURE__*/ function() {
511
- var _ref = _async_to_generator(function(param) {
551
+ function asyncGeneratorStep6(n, t, e, r, o, a, c) {
552
+ try {
553
+ var i = n[a](c), u = i.value;
554
+ } catch (n2) {
555
+ return void e(n2);
556
+ }
557
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
558
+ }
559
+ function _asyncToGenerator6(n) {
560
+ return function() {
561
+ var t = this, e = arguments;
562
+ return new Promise(function(r, o) {
563
+ var a = n.apply(t, e);
564
+ function _next(n2) {
565
+ asyncGeneratorStep6(a, r, o, _next, _throw, "next", n2);
566
+ }
567
+ function _throw(n2) {
568
+ asyncGeneratorStep6(a, r, o, _next, _throw, "throw", n2);
569
+ }
570
+ _next(void 0);
571
+ });
572
+ };
573
+ }
574
+ var data = /* @__PURE__ */ function() {
575
+ var _ref2 = _asyncToGenerator6(function(_ref) {
512
576
  var messagesResponse2, pageParam, threadId, client;
513
577
  return _ts_generator(this, function(_state) {
514
578
  switch(_state.label){
515
579
  case 0:
516
- messagesResponse2 = param.messagesResponse, pageParam = param.pageParam, threadId = param.threadId, client = param.client;
580
+ messagesResponse2 = _ref.messagesResponse, pageParam = _ref.pageParam, threadId = _ref.threadId, client = _ref.client;
517
581
  return [
518
582
  4,
519
583
  messages({
@@ -535,31 +599,97 @@ var data = /*#__PURE__*/ function() {
535
599
  }
536
600
  });
537
601
  });
538
- return function data(_) {
539
- return _ref.apply(this, arguments);
602
+ return function data2(_x) {
603
+ return _ref2.apply(this, arguments);
540
604
  };
541
605
  }();
542
606
  // src/lib/messages/messagesResponse/limit.ts
543
607
  var limit = 10;
544
608
  // src/lib/messages/messagesResponse/hasNextPage.ts
545
- var hasNextPage = function(param) {
546
- var messagesResponse2 = param.messagesResponse;
609
+ var hasNextPage = function(_ref) {
610
+ var messagesResponse2 = _ref.messagesResponse;
547
611
  if (messagesResponse2.data.length < limit) return false;
548
612
  return messagesResponse2.hasNextPage();
549
613
  };
550
614
  // src/lib/messages/messagesResponse/index.ts
551
- var messagesResponse = /*#__PURE__*/ function() {
552
- var _ref = _async_to_generator(function(param) {
615
+ function ownKeys2(e, r) {
616
+ var t = Object.keys(e);
617
+ if (Object.getOwnPropertySymbols) {
618
+ var o = Object.getOwnPropertySymbols(e);
619
+ r && (o = o.filter(function(r2) {
620
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
621
+ })), t.push.apply(t, o);
622
+ }
623
+ return t;
624
+ }
625
+ function _objectSpread2(e) {
626
+ for(var r = 1; r < arguments.length; r++){
627
+ var t = null != arguments[r] ? arguments[r] : {};
628
+ r % 2 ? ownKeys2(Object(t), true).forEach(function(r2) {
629
+ _defineProperty2(e, r2, t[r2]);
630
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r2) {
631
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
632
+ });
633
+ }
634
+ return e;
635
+ }
636
+ function _defineProperty2(e, r, t) {
637
+ return (r = _toPropertyKey2(r)) in e ? Object.defineProperty(e, r, {
638
+ value: t,
639
+ enumerable: true,
640
+ configurable: true,
641
+ writable: true
642
+ }) : e[r] = t, e;
643
+ }
644
+ function _toPropertyKey2(t) {
645
+ var i = _toPrimitive2(t, "string");
646
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
647
+ }
648
+ function _toPrimitive2(t, r) {
649
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
650
+ var e = t[Symbol.toPrimitive];
651
+ if (void 0 !== e) {
652
+ var i = e.call(t, r || "default");
653
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
654
+ throw new TypeError("@@toPrimitive must return a primitive value.");
655
+ }
656
+ return ("string" === r ? String : Number)(t);
657
+ }
658
+ function asyncGeneratorStep7(n, t, e, r, o, a, c) {
659
+ try {
660
+ var i = n[a](c), u = i.value;
661
+ } catch (n2) {
662
+ return void e(n2);
663
+ }
664
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
665
+ }
666
+ function _asyncToGenerator7(n) {
667
+ return function() {
668
+ var t = this, e = arguments;
669
+ return new Promise(function(r, o) {
670
+ var a = n.apply(t, e);
671
+ function _next(n2) {
672
+ asyncGeneratorStep7(a, r, o, _next, _throw, "next", n2);
673
+ }
674
+ function _throw(n2) {
675
+ asyncGeneratorStep7(a, r, o, _next, _throw, "throw", n2);
676
+ }
677
+ _next(void 0);
678
+ });
679
+ };
680
+ }
681
+ var messagesResponse = /* @__PURE__ */ function() {
682
+ var _ref2 = _asyncToGenerator7(function(_ref) {
553
683
  var client, threadId, pageParam, messagesResponse2, _tmp;
554
684
  return _ts_generator(this, function(_state) {
555
685
  switch(_state.label){
556
686
  case 0:
557
- client = param.client, threadId = param.threadId, pageParam = param.pageParam;
687
+ client = _ref.client, threadId = _ref.threadId, pageParam = _ref.pageParam;
558
688
  return [
559
689
  4,
560
- client.beta.threads.messages.list(threadId, _object_spread_props(_object_spread({}, pageParam ? {
690
+ client.beta.threads.messages.list(threadId, _objectSpread2(_objectSpread2({}, pageParam ? {
561
691
  after: pageParam
562
- } : {}), {
692
+ } : {}), {}, {
563
693
  limit: limit
564
694
  }))
565
695
  ];
@@ -586,14 +716,14 @@ var messagesResponse = /*#__PURE__*/ function() {
586
716
  }
587
717
  });
588
718
  });
589
- return function messagesResponse(_) {
590
- return _ref.apply(this, arguments);
719
+ return function messagesResponse2(_x) {
720
+ return _ref2.apply(this, arguments);
591
721
  };
592
722
  }();
593
723
  // src/lib/runs/serializeRun.ts
594
724
  import { pick as pick2 } from "radash";
595
- var serializeRun = function(param) {
596
- var run = param.run;
725
+ var serializeRun = function(_ref) {
726
+ var run = _ref.run;
597
727
  return pick2(run, [
598
728
  "id",
599
729
  "thread_id",
@@ -602,19 +732,42 @@ var serializeRun = function(param) {
602
732
  ]);
603
733
  };
604
734
  // src/lib/streams/enqueueJson.ts
605
- var enqueueJson = function(param) {
606
- var controller = param.controller, value = param.value;
735
+ var enqueueJson = function(_ref) {
736
+ var controller = _ref.controller, value = _ref.value;
607
737
  return controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
608
738
  };
609
739
  // src/lib/messages/createMessageResponse/actionsStream.ts
610
740
  import pMap2 from "p-map";
611
- var actionsStream = /*#__PURE__*/ function() {
612
- var _ref = _async_to_generator(function(param) {
741
+ function asyncGeneratorStep8(n, t, e, r, o, a, c) {
742
+ try {
743
+ var i = n[a](c), u = i.value;
744
+ } catch (n2) {
745
+ return void e(n2);
746
+ }
747
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
748
+ }
749
+ function _asyncToGenerator8(n) {
750
+ return function() {
751
+ var t = this, e = arguments;
752
+ return new Promise(function(r, o) {
753
+ var a = n.apply(t, e);
754
+ function _next(n2) {
755
+ asyncGeneratorStep8(a, r, o, _next, _throw, "next", n2);
756
+ }
757
+ function _throw(n2) {
758
+ asyncGeneratorStep8(a, r, o, _next, _throw, "throw", n2);
759
+ }
760
+ _next(void 0);
761
+ });
762
+ };
763
+ }
764
+ var actionsStream = /* @__PURE__ */ function() {
765
+ var _ref2 = _asyncToGenerator8(function(_ref) {
613
766
  var client, run, handleToolCall, controller, toolCalls, _, _1, _tmp, _tmp1;
614
767
  return _ts_generator(this, function(_state) {
615
768
  switch(_state.label){
616
769
  case 0:
617
- client = param.client, run = param.run, handleToolCall = param.handleToolCall, controller = param.controller;
770
+ client = _ref.client, run = _ref.run, handleToolCall = _ref.handleToolCall, controller = _ref.controller;
618
771
  if (!run.required_action) {
619
772
  throw new Error("Run does not have a required action");
620
773
  }
@@ -645,19 +798,84 @@ var actionsStream = /*#__PURE__*/ function() {
645
798
  }
646
799
  });
647
800
  });
648
- return function actionsStream(_) {
649
- return _ref.apply(this, arguments);
801
+ return function actionsStream2(_x) {
802
+ return _ref2.apply(this, arguments);
650
803
  };
651
804
  }();
652
805
  // src/lib/messages/createMessageResponse/handleStream.ts
653
- var handleStream = /*#__PURE__*/ function() {
654
- var _ref = _async_to_generator(function(param) {
655
- var client, stream, controller, handleToolCall, onEvent, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value, _tmp, err;
806
+ function asyncGeneratorStep9(n, t, e, r, o, a, c) {
807
+ try {
808
+ var i = n[a](c), u = i.value;
809
+ } catch (n2) {
810
+ return void e(n2);
811
+ }
812
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
813
+ }
814
+ function _asyncToGenerator9(n) {
815
+ return function() {
816
+ var t = this, e = arguments;
817
+ return new Promise(function(r, o) {
818
+ var a = n.apply(t, e);
819
+ function _next(n2) {
820
+ asyncGeneratorStep9(a, r, o, _next, _throw, "next", n2);
821
+ }
822
+ function _throw(n2) {
823
+ asyncGeneratorStep9(a, r, o, _next, _throw, "throw", n2);
824
+ }
825
+ _next(void 0);
826
+ });
827
+ };
828
+ }
829
+ function _asyncIterator(r) {
830
+ var n, t, o, e = 2;
831
+ for("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;){
832
+ if (t && null != (n = r[t])) return n.call(r);
833
+ if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
834
+ t = "@@asyncIterator", o = "@@iterator";
835
+ }
836
+ throw new TypeError("Object is not async iterable");
837
+ }
838
+ function AsyncFromSyncIterator(r) {
839
+ function AsyncFromSyncIteratorContinuation(r2) {
840
+ if (Object(r2) !== r2) return Promise.reject(new TypeError(r2 + " is not an object."));
841
+ var n = r2.done;
842
+ return Promise.resolve(r2.value).then(function(r3) {
843
+ return {
844
+ value: r3,
845
+ done: n
846
+ };
847
+ });
848
+ }
849
+ return AsyncFromSyncIterator = function AsyncFromSyncIterator2(r2) {
850
+ this.s = r2, this.n = r2.next;
851
+ }, AsyncFromSyncIterator.prototype = {
852
+ s: null,
853
+ n: null,
854
+ next: function next() {
855
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
856
+ },
857
+ return: function _return(r2) {
858
+ var n = this.s.return;
859
+ return void 0 === n ? Promise.resolve({
860
+ value: r2,
861
+ done: true
862
+ }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
863
+ },
864
+ throw: function _throw(r2) {
865
+ var n = this.s.return;
866
+ return void 0 === n ? Promise.reject(r2) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
867
+ }
868
+ }, new AsyncFromSyncIterator(r);
869
+ }
870
+ var _handleStream = /* @__PURE__ */ function() {
871
+ var _ref2 = _asyncToGenerator9(function(_ref) {
872
+ var client, stream, controller, handleToolCall, onEvent, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, value, _tmp, err;
656
873
  return _ts_generator(this, function(_state) {
657
874
  switch(_state.label){
658
875
  case 0:
659
- client = param.client, stream = param.stream, controller = param.controller, handleToolCall = param.handleToolCall, onEvent = param.onEvent;
660
- _iteratorAbruptCompletion = false, _didIteratorError = false;
876
+ client = _ref.client, stream = _ref.stream, controller = _ref.controller, handleToolCall = _ref.handleToolCall, onEvent = _ref.onEvent;
877
+ _iteratorAbruptCompletion = false;
878
+ _didIteratorError = false;
661
879
  _state.label = 1;
662
880
  case 1:
663
881
  _state.trys.push([
@@ -666,7 +884,7 @@ var handleStream = /*#__PURE__*/ function() {
666
884
  15,
667
885
  20
668
886
  ]);
669
- _iterator = _async_iterator(stream);
887
+ _iterator = _asyncIterator(stream);
670
888
  _state.label = 2;
671
889
  case 2:
672
890
  return [
@@ -678,8 +896,7 @@ var handleStream = /*#__PURE__*/ function() {
678
896
  3,
679
897
  13
680
898
  ];
681
- _value = _step.value;
682
- value = _value;
899
+ value = _step.value;
683
900
  onEvent({
684
901
  controller: controller,
685
902
  event: value.event,
@@ -802,7 +1019,7 @@ var handleStream = /*#__PURE__*/ function() {
802
1019
  case 9:
803
1020
  return [
804
1021
  4,
805
- handleStream.apply(void 0, [
1022
+ _handleStream.apply(void 0, [
806
1023
  (_tmp.stream = _state.sent(), _tmp.controller = controller, _tmp.handleToolCall = handleToolCall, _tmp.onEvent = onEvent, _tmp)
807
1024
  ])
808
1025
  ];
@@ -879,16 +1096,39 @@ var handleStream = /*#__PURE__*/ function() {
879
1096
  }
880
1097
  });
881
1098
  });
882
- return function handleStream(_) {
883
- return _ref.apply(this, arguments);
1099
+ return function handleStream(_x) {
1100
+ return _ref2.apply(this, arguments);
884
1101
  };
885
1102
  }();
886
1103
  // src/lib/messages/createMessageResponse/index.ts
887
- var createMessageResponse = function(param) {
888
- 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;
1104
+ function asyncGeneratorStep10(n, t, e, r, o, a, c) {
1105
+ try {
1106
+ var i = n[a](c), u = i.value;
1107
+ } catch (n2) {
1108
+ return void e(n2);
1109
+ }
1110
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
1111
+ }
1112
+ function _asyncToGenerator10(n) {
1113
+ return function() {
1114
+ var t = this, e = arguments;
1115
+ return new Promise(function(r, o) {
1116
+ var a = n.apply(t, e);
1117
+ function _next(n2) {
1118
+ asyncGeneratorStep10(a, r, o, _next, _throw, "next", n2);
1119
+ }
1120
+ function _throw(n2) {
1121
+ asyncGeneratorStep10(a, r, o, _next, _throw, "throw", n2);
1122
+ }
1123
+ _next(void 0);
1124
+ });
1125
+ };
1126
+ }
1127
+ var createMessageResponse = function(_ref) {
1128
+ 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;
889
1129
  return new ReadableStream({
890
1130
  start: function start(controller) {
891
- return _async_to_generator(function() {
1131
+ return _asyncToGenerator10(function() {
892
1132
  var error;
893
1133
  return _ts_generator(this, function(_state) {
894
1134
  switch(_state.label){
@@ -906,7 +1146,7 @@ var createMessageResponse = function(param) {
906
1146
  ]);
907
1147
  return [
908
1148
  4,
909
- handleStream({
1149
+ _handleStream({
910
1150
  client: client,
911
1151
  stream: createRunStream,
912
1152
  controller: controller,