@superinterface/react 2.4.5 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -20
- package/dist/index.d.ts +29 -20
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/{queryFns.cjs → server.cjs} +437 -172
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +39 -0
- package/dist/server.d.ts +39 -0
- package/dist/server.js +879 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +17 -21
- package/dist/types/index.d.ts +17 -21
- package/dist/utils.cjs +41 -248
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +15 -19
- package/dist/utils.d.ts +15 -19
- package/dist/utils.js +37 -244
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-CGpJFXMu.d.cts +0 -5
- package/dist/index-CGpJFXMu.d.ts +0 -5
- package/dist/index-u67QcaWg.d.cts +0 -11
- package/dist/index-u67QcaWg.d.ts +0 -11
- package/dist/mutationFns.cjs +0 -357
- package/dist/mutationFns.cjs.map +0 -1
- package/dist/mutationFns.d.cts +0 -15
- package/dist/mutationFns.d.ts +0 -15
- package/dist/mutationFns.js +0 -287
- package/dist/mutationFns.js.map +0 -1
- package/dist/queryFns.cjs.map +0 -1
- package/dist/queryFns.d.cts +0 -26
- package/dist/queryFns.d.ts +0 -26
- package/dist/queryFns.js +0 -618
- package/dist/queryFns.js.map +0 -1
|
@@ -4,12 +4,50 @@ function _array_like_to_array(arr, len) {
|
|
|
4
4
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
5
|
return arr2;
|
|
6
6
|
}
|
|
7
|
-
function _array_with_holes(arr) {
|
|
8
|
-
if (Array.isArray(arr)) return arr;
|
|
9
|
-
}
|
|
10
7
|
function _array_without_holes(arr) {
|
|
11
8
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
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
|
+
}
|
|
13
51
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
14
52
|
try {
|
|
15
53
|
var info = gen[key](arg);
|
|
@@ -55,33 +93,6 @@ function _define_property(obj, key, value) {
|
|
|
55
93
|
function _iterable_to_array(iter) {
|
|
56
94
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
57
95
|
}
|
|
58
|
-
function _iterable_to_array_limit(arr, i) {
|
|
59
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
60
|
-
if (_i == null) return;
|
|
61
|
-
var _arr = [];
|
|
62
|
-
var _n = true;
|
|
63
|
-
var _d = false;
|
|
64
|
-
var _s, _e;
|
|
65
|
-
try {
|
|
66
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
67
|
-
_arr.push(_s.value);
|
|
68
|
-
if (i && _arr.length === i) break;
|
|
69
|
-
}
|
|
70
|
-
} catch (err) {
|
|
71
|
-
_d = true;
|
|
72
|
-
_e = err;
|
|
73
|
-
} finally{
|
|
74
|
-
try {
|
|
75
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
76
|
-
} finally{
|
|
77
|
-
if (_d) throw _e;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return _arr;
|
|
81
|
-
}
|
|
82
|
-
function _non_iterable_rest() {
|
|
83
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
84
|
-
}
|
|
85
96
|
function _non_iterable_spread() {
|
|
86
97
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
87
98
|
}
|
|
@@ -124,9 +135,6 @@ function _object_spread_props(target, source) {
|
|
|
124
135
|
}
|
|
125
136
|
return target;
|
|
126
137
|
}
|
|
127
|
-
function _sliced_to_array(arr, i) {
|
|
128
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
129
|
-
}
|
|
130
138
|
function _to_consumable_array(arr) {
|
|
131
139
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
132
140
|
}
|
|
@@ -291,23 +299,57 @@ var __toCommonJS = function(mod) {
|
|
|
291
299
|
value: true
|
|
292
300
|
}), mod);
|
|
293
301
|
};
|
|
294
|
-
// src/
|
|
295
|
-
var
|
|
296
|
-
__export(
|
|
297
|
-
|
|
298
|
-
return
|
|
302
|
+
// src/server.ts
|
|
303
|
+
var server_exports = {};
|
|
304
|
+
__export(server_exports, {
|
|
305
|
+
createMessageResponse: function() {
|
|
306
|
+
return createMessageResponse;
|
|
299
307
|
},
|
|
300
|
-
|
|
301
|
-
return
|
|
308
|
+
extendMessage: function() {
|
|
309
|
+
return extendMessage;
|
|
310
|
+
},
|
|
311
|
+
messagesResponse: function() {
|
|
312
|
+
return messagesResponse;
|
|
302
313
|
}
|
|
303
314
|
});
|
|
304
|
-
module.exports = __toCommonJS(
|
|
305
|
-
// src/lib/
|
|
306
|
-
var
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
module.exports = __toCommonJS(server_exports);
|
|
316
|
+
// src/lib/runSteps/serializeRunStep.ts
|
|
317
|
+
var import_radash = require("radash");
|
|
318
|
+
var serializeRunStep = function(param) {
|
|
319
|
+
var runStep = param.runStep;
|
|
320
|
+
return (0, import_radash.pick)(runStep, [
|
|
321
|
+
"id",
|
|
322
|
+
"run_id",
|
|
323
|
+
"step_details",
|
|
324
|
+
"completed_at",
|
|
325
|
+
"cancelled_at",
|
|
326
|
+
"failed_at",
|
|
327
|
+
"status"
|
|
328
|
+
]);
|
|
329
|
+
};
|
|
330
|
+
// src/lib/messages/serializeMessage.ts
|
|
331
|
+
var serializeMessage = function(param) {
|
|
332
|
+
var message = param.message;
|
|
333
|
+
var _message_runSteps;
|
|
334
|
+
return {
|
|
335
|
+
id: message.id,
|
|
336
|
+
role: message.role,
|
|
337
|
+
created_at: message.created_at,
|
|
338
|
+
content: message.content,
|
|
339
|
+
run_id: message.run_id,
|
|
340
|
+
assistant_id: message.assistant_id,
|
|
341
|
+
thread_id: message.thread_id,
|
|
342
|
+
file_ids: message.file_ids,
|
|
343
|
+
metadata: message.metadata,
|
|
344
|
+
runSteps: ((_message_runSteps = message.runSteps) !== null && _message_runSteps !== void 0 ? _message_runSteps : []).map(function(runStep) {
|
|
345
|
+
return serializeRunStep({
|
|
346
|
+
runStep: runStep
|
|
347
|
+
});
|
|
348
|
+
}),
|
|
349
|
+
status: message.status
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
// src/lib/messages/messagesResponse/data/messages/index.ts
|
|
311
353
|
var import_p_map = __toESM(require("p-map"), 1);
|
|
312
354
|
// src/lib/runSteps/getRunSteps/index.ts
|
|
313
355
|
var getRunSteps = function() {
|
|
@@ -376,9 +418,9 @@ var extendMessage = function() {
|
|
|
376
418
|
return _ref.apply(this, arguments);
|
|
377
419
|
};
|
|
378
420
|
}();
|
|
379
|
-
// src/lib/messages/
|
|
421
|
+
// src/lib/messages/messagesResponse/data/messages/runMessages/index.ts
|
|
380
422
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
381
|
-
// src/lib/messages/
|
|
423
|
+
// src/lib/messages/messagesResponse/data/messages/runMessages/getLatestRun.ts
|
|
382
424
|
var getLatestRun = function() {
|
|
383
425
|
var _ref = _async_to_generator(function(param) {
|
|
384
426
|
var threadId, client, runsResponse;
|
|
@@ -406,11 +448,11 @@ var getLatestRun = function() {
|
|
|
406
448
|
};
|
|
407
449
|
}();
|
|
408
450
|
// src/lib/optimistic/optimisticId.ts
|
|
409
|
-
var
|
|
451
|
+
var import_radash2 = require("radash");
|
|
410
452
|
var optimisticId = function() {
|
|
411
|
-
return "-".concat((0,
|
|
453
|
+
return "-".concat((0, import_radash2.uid)(24));
|
|
412
454
|
};
|
|
413
|
-
// src/lib/messages/
|
|
455
|
+
// src/lib/messages/messagesResponse/data/messages/runMessages/index.ts
|
|
414
456
|
var progressStatuses = [
|
|
415
457
|
"queued",
|
|
416
458
|
"in_progress",
|
|
@@ -419,11 +461,11 @@ var progressStatuses = [
|
|
|
419
461
|
];
|
|
420
462
|
var runMessages = function() {
|
|
421
463
|
var _ref = _async_to_generator(function(param) {
|
|
422
|
-
var
|
|
464
|
+
var result, threadId, client, latestRun, messageFromLatestRun;
|
|
423
465
|
return _ts_generator(this, function(_state) {
|
|
424
466
|
switch(_state.label){
|
|
425
467
|
case 0:
|
|
426
|
-
|
|
468
|
+
result = param.result, threadId = param.threadId, client = param.client;
|
|
427
469
|
return [
|
|
428
470
|
4,
|
|
429
471
|
getLatestRun({
|
|
@@ -439,7 +481,7 @@ var runMessages = function() {
|
|
|
439
481
|
[]
|
|
440
482
|
];
|
|
441
483
|
}
|
|
442
|
-
messageFromLatestRun =
|
|
484
|
+
messageFromLatestRun = result.find(function(m) {
|
|
443
485
|
return m.run_id === latestRun.id;
|
|
444
486
|
});
|
|
445
487
|
if (messageFromLatestRun) {
|
|
@@ -490,17 +532,17 @@ var runMessages = function() {
|
|
|
490
532
|
return _ref.apply(this, arguments);
|
|
491
533
|
};
|
|
492
534
|
}();
|
|
493
|
-
// src/lib/messages/
|
|
494
|
-
var
|
|
535
|
+
// src/lib/messages/messagesResponse/data/messages/index.ts
|
|
536
|
+
var messages = function() {
|
|
495
537
|
var _ref = _async_to_generator(function(param) {
|
|
496
|
-
var
|
|
538
|
+
var messagesResponse2, pageParam, threadId, client, result;
|
|
497
539
|
return _ts_generator(this, function(_state) {
|
|
498
540
|
switch(_state.label){
|
|
499
541
|
case 0:
|
|
500
|
-
|
|
542
|
+
messagesResponse2 = param.messagesResponse, pageParam = param.pageParam, threadId = param.threadId, client = param.client;
|
|
501
543
|
return [
|
|
502
544
|
4,
|
|
503
|
-
(0, import_p_map.default)(
|
|
545
|
+
(0, import_p_map.default)(messagesResponse2.data, function(message) {
|
|
504
546
|
return extendMessage({
|
|
505
547
|
client: client,
|
|
506
548
|
message: message
|
|
@@ -508,17 +550,17 @@ var data = function() {
|
|
|
508
550
|
})
|
|
509
551
|
];
|
|
510
552
|
case 1:
|
|
511
|
-
|
|
553
|
+
result = _state.sent();
|
|
512
554
|
if (pageParam) {
|
|
513
555
|
return [
|
|
514
556
|
2,
|
|
515
|
-
|
|
557
|
+
result
|
|
516
558
|
];
|
|
517
559
|
}
|
|
518
560
|
return [
|
|
519
561
|
4,
|
|
520
562
|
runMessages({
|
|
521
|
-
|
|
563
|
+
result: result,
|
|
522
564
|
threadId: threadId,
|
|
523
565
|
client: client
|
|
524
566
|
})
|
|
@@ -528,7 +570,40 @@ var data = function() {
|
|
|
528
570
|
2,
|
|
529
571
|
_to_consumable_array.apply(void 0, [
|
|
530
572
|
_state.sent()
|
|
531
|
-
]).concat(_to_consumable_array(
|
|
573
|
+
]).concat(_to_consumable_array(result))
|
|
574
|
+
];
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
return function messages(_) {
|
|
579
|
+
return _ref.apply(this, arguments);
|
|
580
|
+
};
|
|
581
|
+
}();
|
|
582
|
+
// src/lib/messages/messagesResponse/data/index.ts
|
|
583
|
+
var data = function() {
|
|
584
|
+
var _ref = _async_to_generator(function(param) {
|
|
585
|
+
var messagesResponse2, pageParam, threadId, client;
|
|
586
|
+
return _ts_generator(this, function(_state) {
|
|
587
|
+
switch(_state.label){
|
|
588
|
+
case 0:
|
|
589
|
+
messagesResponse2 = param.messagesResponse, pageParam = param.pageParam, threadId = param.threadId, client = param.client;
|
|
590
|
+
return [
|
|
591
|
+
4,
|
|
592
|
+
messages({
|
|
593
|
+
messagesResponse: messagesResponse2,
|
|
594
|
+
pageParam: pageParam,
|
|
595
|
+
threadId: threadId,
|
|
596
|
+
client: client
|
|
597
|
+
})
|
|
598
|
+
];
|
|
599
|
+
case 1:
|
|
600
|
+
return [
|
|
601
|
+
2,
|
|
602
|
+
_state.sent().map(function(message) {
|
|
603
|
+
return serializeMessage({
|
|
604
|
+
message: message
|
|
605
|
+
});
|
|
606
|
+
})
|
|
532
607
|
];
|
|
533
608
|
}
|
|
534
609
|
});
|
|
@@ -537,38 +612,38 @@ var data = function() {
|
|
|
537
612
|
return _ref.apply(this, arguments);
|
|
538
613
|
};
|
|
539
614
|
}();
|
|
540
|
-
// src/lib/messages/
|
|
541
|
-
var
|
|
542
|
-
// src/lib/messages/
|
|
615
|
+
// src/lib/messages/messagesResponse/limit.ts
|
|
616
|
+
var limit = 10;
|
|
617
|
+
// src/lib/messages/messagesResponse/hasNextPage.ts
|
|
543
618
|
var hasNextPage = function(param) {
|
|
544
|
-
var
|
|
545
|
-
if (
|
|
546
|
-
return
|
|
619
|
+
var messagesResponse2 = param.messagesResponse;
|
|
620
|
+
if (messagesResponse2.data.length < limit) return false;
|
|
621
|
+
return messagesResponse2.hasNextPage();
|
|
547
622
|
};
|
|
548
|
-
// src/lib/messages/
|
|
549
|
-
var
|
|
623
|
+
// src/lib/messages/messagesResponse/index.ts
|
|
624
|
+
var messagesResponse = function() {
|
|
550
625
|
var _ref = _async_to_generator(function(param) {
|
|
551
|
-
var
|
|
626
|
+
var client, threadId, pageParam, messagesResponse2, _tmp;
|
|
552
627
|
return _ts_generator(this, function(_state) {
|
|
553
628
|
switch(_state.label){
|
|
554
629
|
case 0:
|
|
555
|
-
|
|
630
|
+
client = param.client, threadId = param.threadId, pageParam = param.pageParam;
|
|
556
631
|
return [
|
|
557
632
|
4,
|
|
558
633
|
client.beta.threads.messages.list(threadId, _object_spread_props(_object_spread({}, pageParam ? {
|
|
559
634
|
after: pageParam
|
|
560
635
|
} : {}), {
|
|
561
|
-
limit:
|
|
636
|
+
limit: limit
|
|
562
637
|
}))
|
|
563
638
|
];
|
|
564
639
|
case 1:
|
|
565
|
-
|
|
640
|
+
messagesResponse2 = _state.sent();
|
|
566
641
|
_tmp = {};
|
|
567
642
|
return [
|
|
568
643
|
4,
|
|
569
644
|
data({
|
|
570
645
|
client: client,
|
|
571
|
-
messagesResponse:
|
|
646
|
+
messagesResponse: messagesResponse2,
|
|
572
647
|
pageParam: pageParam,
|
|
573
648
|
threadId: threadId
|
|
574
649
|
})
|
|
@@ -577,116 +652,306 @@ var messagesQueryFn = function() {
|
|
|
577
652
|
return [
|
|
578
653
|
2,
|
|
579
654
|
(_tmp.data = _state.sent(), _tmp.hasNextPage = hasNextPage({
|
|
580
|
-
messagesResponse:
|
|
655
|
+
messagesResponse: messagesResponse2
|
|
581
656
|
}), _tmp.// @ts-ignore-next-line
|
|
582
|
-
lastId =
|
|
657
|
+
lastId = messagesResponse2.body.last_id, _tmp)
|
|
583
658
|
];
|
|
584
659
|
}
|
|
585
660
|
});
|
|
586
661
|
});
|
|
587
|
-
return function
|
|
662
|
+
return function messagesResponse(_) {
|
|
588
663
|
return _ref.apply(this, arguments);
|
|
589
664
|
};
|
|
590
665
|
}();
|
|
591
|
-
// src/lib/
|
|
592
|
-
var
|
|
593
|
-
var
|
|
594
|
-
var
|
|
595
|
-
|
|
596
|
-
|
|
666
|
+
// src/lib/runs/serializeRun.ts
|
|
667
|
+
var import_radash3 = require("radash");
|
|
668
|
+
var serializeRun = function(param) {
|
|
669
|
+
var run = param.run;
|
|
670
|
+
return (0, import_radash3.pick)(run, [
|
|
671
|
+
"id",
|
|
672
|
+
"thread_id",
|
|
673
|
+
"assistant_id",
|
|
674
|
+
"created_at"
|
|
597
675
|
]);
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
676
|
+
};
|
|
677
|
+
// src/lib/messages/createMessageResponse/actionsStream.ts
|
|
678
|
+
var import_p_map2 = __toESM(require("p-map"), 1);
|
|
679
|
+
var actionsStream = function() {
|
|
680
|
+
var _ref = _async_to_generator(function(param) {
|
|
681
|
+
var client, run, handleToolCall, toolCalls, _, _1, _tmp, _tmp1;
|
|
682
|
+
return _ts_generator(this, function(_state) {
|
|
683
|
+
switch(_state.label){
|
|
684
|
+
case 0:
|
|
685
|
+
client = param.client, run = param.run, handleToolCall = param.handleToolCall;
|
|
686
|
+
if (!run.required_action) {
|
|
687
|
+
throw new Error("Run does not have a required action");
|
|
688
|
+
}
|
|
689
|
+
toolCalls = run.required_action.submit_tool_outputs.tool_calls;
|
|
690
|
+
_1 = (_ = client.beta.threads.runs).submitToolOutputsStream;
|
|
691
|
+
_tmp = [
|
|
692
|
+
run.thread_id,
|
|
693
|
+
run.id
|
|
694
|
+
];
|
|
695
|
+
_tmp1 = {};
|
|
609
696
|
return [
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
Authorization: "Bearer ".concat(superinterfaceContext.publicApiKey)
|
|
616
|
-
}
|
|
617
|
-
} : {})).then(function() {
|
|
618
|
-
var _ref = _async_to_generator(function(response) {
|
|
619
|
-
var errorResponse, error;
|
|
620
|
-
return _ts_generator(this, function(_state) {
|
|
621
|
-
switch(_state.label){
|
|
622
|
-
case 0:
|
|
623
|
-
if (!(response.status !== 200)) return [
|
|
624
|
-
3,
|
|
625
|
-
4
|
|
626
|
-
];
|
|
627
|
-
_state.label = 1;
|
|
628
|
-
case 1:
|
|
629
|
-
_state.trys.push([
|
|
630
|
-
1,
|
|
631
|
-
3,
|
|
632
|
-
,
|
|
633
|
-
4
|
|
634
|
-
]);
|
|
635
|
-
return [
|
|
636
|
-
4,
|
|
637
|
-
response.json()
|
|
638
|
-
];
|
|
639
|
-
case 2:
|
|
640
|
-
errorResponse = _state.sent();
|
|
641
|
-
throw new Error(errorResponse.error);
|
|
642
|
-
case 3:
|
|
643
|
-
error = _state.sent();
|
|
644
|
-
throw new Error("Failed to fetch");
|
|
645
|
-
case 4:
|
|
646
|
-
return [
|
|
647
|
-
2,
|
|
648
|
-
response.json()
|
|
649
|
-
];
|
|
650
|
-
}
|
|
651
|
-
});
|
|
697
|
+
4,
|
|
698
|
+
(0, import_p_map2.default)(toolCalls, function(toolCall) {
|
|
699
|
+
return handleToolCall({
|
|
700
|
+
toolCall: toolCall,
|
|
701
|
+
run: run
|
|
652
702
|
});
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
703
|
+
})
|
|
704
|
+
];
|
|
705
|
+
case 1:
|
|
706
|
+
return [
|
|
707
|
+
2,
|
|
708
|
+
_1.apply(_, _tmp.concat([
|
|
709
|
+
(_tmp1.tool_outputs = _state.sent(), _tmp1)
|
|
710
|
+
]))
|
|
711
|
+
];
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
return function actionsStream(_) {
|
|
716
|
+
return _ref.apply(this, arguments);
|
|
717
|
+
};
|
|
718
|
+
}();
|
|
719
|
+
// src/lib/messages/createMessageResponse/handleStream.ts
|
|
720
|
+
var handleStream = function() {
|
|
721
|
+
var _ref = _async_to_generator(function(param) {
|
|
722
|
+
var client, stream, controller, handleToolCall, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value, _tmp, err;
|
|
723
|
+
return _ts_generator(this, function(_state) {
|
|
724
|
+
switch(_state.label){
|
|
725
|
+
case 0:
|
|
726
|
+
client = param.client, stream = param.stream, controller = param.controller, handleToolCall = param.handleToolCall;
|
|
727
|
+
_iteratorAbruptCompletion = false, _didIteratorError = false;
|
|
728
|
+
_state.label = 1;
|
|
729
|
+
case 1:
|
|
730
|
+
_state.trys.push([
|
|
731
|
+
1,
|
|
732
|
+
13,
|
|
733
|
+
14,
|
|
734
|
+
19
|
|
735
|
+
]);
|
|
736
|
+
_iterator = _async_iterator(stream);
|
|
737
|
+
_state.label = 2;
|
|
738
|
+
case 2:
|
|
739
|
+
return [
|
|
740
|
+
4,
|
|
741
|
+
_iterator.next()
|
|
742
|
+
];
|
|
743
|
+
case 3:
|
|
744
|
+
if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
|
|
745
|
+
3,
|
|
746
|
+
12
|
|
747
|
+
];
|
|
748
|
+
_value = _step.value;
|
|
749
|
+
value = _value;
|
|
750
|
+
if (![
|
|
751
|
+
"thread.message.created",
|
|
752
|
+
"thread.message.completed"
|
|
753
|
+
].includes(value.event)) return [
|
|
754
|
+
3,
|
|
755
|
+
4
|
|
756
|
+
];
|
|
757
|
+
controller.enqueue(JSON.stringify({
|
|
758
|
+
event: value.event,
|
|
759
|
+
data: serializeMessage({
|
|
760
|
+
message: value.data
|
|
761
|
+
})
|
|
762
|
+
}));
|
|
763
|
+
return [
|
|
764
|
+
3,
|
|
765
|
+
11
|
|
766
|
+
];
|
|
767
|
+
case 4:
|
|
768
|
+
if (![
|
|
769
|
+
"thread.message.delta",
|
|
770
|
+
"thread.run.step.delta"
|
|
771
|
+
].includes(value.event)) return [
|
|
772
|
+
3,
|
|
773
|
+
5
|
|
774
|
+
];
|
|
775
|
+
controller.enqueue(JSON.stringify(value));
|
|
776
|
+
return [
|
|
777
|
+
3,
|
|
778
|
+
11
|
|
779
|
+
];
|
|
780
|
+
case 5:
|
|
781
|
+
if (!(value.event === "thread.run.created")) return [
|
|
782
|
+
3,
|
|
783
|
+
6
|
|
784
|
+
];
|
|
785
|
+
controller.enqueue(JSON.stringify({
|
|
786
|
+
event: value.event,
|
|
787
|
+
data: serializeRun({
|
|
788
|
+
run: value.data
|
|
789
|
+
})
|
|
790
|
+
}));
|
|
791
|
+
return [
|
|
792
|
+
3,
|
|
793
|
+
11
|
|
794
|
+
];
|
|
795
|
+
case 6:
|
|
796
|
+
if (![
|
|
797
|
+
"thread.run.step.created",
|
|
798
|
+
"thread.run.step.completed"
|
|
799
|
+
].includes(value.event)) return [
|
|
800
|
+
3,
|
|
801
|
+
7
|
|
802
|
+
];
|
|
803
|
+
controller.enqueue(JSON.stringify({
|
|
804
|
+
event: value.event,
|
|
805
|
+
data: serializeRunStep({
|
|
806
|
+
runStep: value.data
|
|
807
|
+
})
|
|
808
|
+
}));
|
|
809
|
+
return [
|
|
810
|
+
3,
|
|
811
|
+
11
|
|
812
|
+
];
|
|
813
|
+
case 7:
|
|
814
|
+
if (!(value.event === "thread.run.requires_action")) return [
|
|
815
|
+
3,
|
|
816
|
+
10
|
|
817
|
+
];
|
|
818
|
+
controller.enqueue(JSON.stringify(value));
|
|
819
|
+
console.log("starting to handle in handleStream");
|
|
820
|
+
console.dir({
|
|
821
|
+
value: value
|
|
822
|
+
}, {
|
|
823
|
+
depth: null
|
|
824
|
+
});
|
|
825
|
+
_tmp = {
|
|
826
|
+
client: client
|
|
827
|
+
};
|
|
828
|
+
return [
|
|
829
|
+
4,
|
|
830
|
+
actionsStream({
|
|
831
|
+
client: client,
|
|
832
|
+
run: value.data,
|
|
833
|
+
handleToolCall: handleToolCall
|
|
834
|
+
})
|
|
657
835
|
];
|
|
836
|
+
case 8:
|
|
837
|
+
return [
|
|
838
|
+
4,
|
|
839
|
+
handleStream.apply(void 0, [
|
|
840
|
+
(_tmp.stream = _state.sent(), _tmp.controller = controller, _tmp.handleToolCall = handleToolCall, _tmp)
|
|
841
|
+
])
|
|
842
|
+
];
|
|
843
|
+
case 9:
|
|
844
|
+
_state.sent();
|
|
845
|
+
return [
|
|
846
|
+
3,
|
|
847
|
+
11
|
|
848
|
+
];
|
|
849
|
+
case 10:
|
|
850
|
+
console.dir({
|
|
851
|
+
value: value
|
|
852
|
+
}, {
|
|
853
|
+
depth: null
|
|
854
|
+
});
|
|
855
|
+
_state.label = 11;
|
|
856
|
+
case 11:
|
|
857
|
+
_iteratorAbruptCompletion = false;
|
|
858
|
+
return [
|
|
859
|
+
3,
|
|
860
|
+
2
|
|
861
|
+
];
|
|
862
|
+
case 12:
|
|
863
|
+
return [
|
|
864
|
+
3,
|
|
865
|
+
19
|
|
866
|
+
];
|
|
867
|
+
case 13:
|
|
868
|
+
err = _state.sent();
|
|
869
|
+
_didIteratorError = true;
|
|
870
|
+
_iteratorError = err;
|
|
871
|
+
return [
|
|
872
|
+
3,
|
|
873
|
+
19
|
|
874
|
+
];
|
|
875
|
+
case 14:
|
|
876
|
+
_state.trys.push([
|
|
877
|
+
14,
|
|
878
|
+
,
|
|
879
|
+
17,
|
|
880
|
+
18
|
|
881
|
+
]);
|
|
882
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
|
|
883
|
+
3,
|
|
884
|
+
16
|
|
885
|
+
];
|
|
886
|
+
return [
|
|
887
|
+
4,
|
|
888
|
+
_iterator.return()
|
|
889
|
+
];
|
|
890
|
+
case 15:
|
|
891
|
+
_state.sent();
|
|
892
|
+
_state.label = 16;
|
|
893
|
+
case 16:
|
|
894
|
+
return [
|
|
895
|
+
3,
|
|
896
|
+
18
|
|
897
|
+
];
|
|
898
|
+
case 17:
|
|
899
|
+
if (_didIteratorError) {
|
|
900
|
+
throw _iteratorError;
|
|
901
|
+
}
|
|
902
|
+
return [
|
|
903
|
+
7
|
|
904
|
+
];
|
|
905
|
+
case 18:
|
|
906
|
+
return [
|
|
907
|
+
7
|
|
908
|
+
];
|
|
909
|
+
case 19:
|
|
910
|
+
return [
|
|
911
|
+
2
|
|
912
|
+
];
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
});
|
|
916
|
+
return function handleStream(_) {
|
|
917
|
+
return _ref.apply(this, arguments);
|
|
918
|
+
};
|
|
919
|
+
}();
|
|
920
|
+
// src/lib/messages/createMessageResponse/index.ts
|
|
921
|
+
var createMessageResponse = function(param) {
|
|
922
|
+
var client = param.client, createRunStream = param.createRunStream, handleToolCall = param.handleToolCall;
|
|
923
|
+
return new ReadableStream({
|
|
924
|
+
start: function start(controller) {
|
|
925
|
+
return _async_to_generator(function() {
|
|
926
|
+
return _ts_generator(this, function(_state) {
|
|
927
|
+
switch(_state.label){
|
|
928
|
+
case 0:
|
|
929
|
+
return [
|
|
930
|
+
4,
|
|
931
|
+
handleStream({
|
|
932
|
+
client: client,
|
|
933
|
+
stream: createRunStream,
|
|
934
|
+
controller: controller,
|
|
935
|
+
handleToolCall: handleToolCall
|
|
936
|
+
})
|
|
937
|
+
];
|
|
938
|
+
case 1:
|
|
939
|
+
_state.sent();
|
|
940
|
+
console.log("Stream ended");
|
|
941
|
+
controller.close();
|
|
942
|
+
return [
|
|
943
|
+
2
|
|
944
|
+
];
|
|
945
|
+
}
|
|
658
946
|
});
|
|
659
|
-
});
|
|
660
|
-
|
|
661
|
-
return _ref.apply(this, arguments);
|
|
662
|
-
};
|
|
663
|
-
}(),
|
|
664
|
-
initialPageParam: void 0,
|
|
665
|
-
getNextPageParam: function(lastPage) {
|
|
666
|
-
if (!lastPage.hasNextPage) return null;
|
|
667
|
-
return lastPage.lastId;
|
|
668
|
-
},
|
|
669
|
-
limit: 10
|
|
670
|
-
}, threadContext.defaultOptions.queries, queryClient.getQueryDefaults(queryKey)), {
|
|
671
|
-
queryKey: queryKey
|
|
672
|
-
}));
|
|
673
|
-
};
|
|
674
|
-
// src/lib/messages/messagesQueryOptions.ts
|
|
675
|
-
var messagesQueryOptions = function(param) {
|
|
676
|
-
var queryClient = param.queryClient, threadContext = param.threadContext, superinterfaceContext = param.superinterfaceContext;
|
|
677
|
-
return queryOptions({
|
|
678
|
-
queryKeyBase: [
|
|
679
|
-
"messages"
|
|
680
|
-
],
|
|
681
|
-
path: "/messages",
|
|
682
|
-
queryClient: queryClient,
|
|
683
|
-
threadContext: threadContext,
|
|
684
|
-
superinterfaceContext: superinterfaceContext
|
|
947
|
+
})();
|
|
948
|
+
}
|
|
685
949
|
});
|
|
686
950
|
};
|
|
687
951
|
// Annotate the CommonJS export names for ESM import in node:
|
|
688
952
|
0 && (module.exports = {
|
|
689
|
-
|
|
690
|
-
|
|
953
|
+
createMessageResponse: createMessageResponse,
|
|
954
|
+
extendMessage: extendMessage,
|
|
955
|
+
messagesResponse: messagesResponse
|
|
691
956
|
});
|
|
692
|
-
//# sourceMappingURL=
|
|
957
|
+
//# sourceMappingURL=server.cjs.map
|