supercompat 3.0.0 → 3.1.0-beta.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 +70 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -30
- package/dist/index.js.map +1 -1
- package/dist/supercompat.cjs.map +1 -1
- package/dist/supercompat.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -3977,7 +3977,7 @@ var messages2 = /*#__PURE__*/ function() {
|
|
|
3977
3977
|
var responsesRunAdapter = function() {
|
|
3978
3978
|
return /*#__PURE__*/ function() {
|
|
3979
3979
|
var _ref = _async_to_generator(function(param) {
|
|
3980
|
-
var clientAdapter, run3, onEvent2, getMessages2, getThread2, client, thread, _thread_openaiConversationId, openaiConversationId, input, mappedTools, opts, providerResponse, e, _e_cause, _e_message, _e_cause_message, msg, message, toolCallsRunStep, currentContent, currentToolCalls, toolCallsByItemId, newConversationId, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, _ret, err, _run3_metadata, _run3_metadata1, _message_tool_calls;
|
|
3980
|
+
var clientAdapter, run3, onEvent2, getMessages2, getThread2, client, thread, _thread_openaiConversationId, openaiConversationId, input, mappedTools, opts, providerResponse, e, _e_cause, _e_message, _e_cause_message, msg, message, toolCallsRunStep, currentContent, currentToolCalls, toolCallsByItemId, newConversationId, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, _ret, err, _run3_metadata, threadForEvent, _run3_metadata1, _message_tool_calls;
|
|
3981
3981
|
return _ts_generator(this, function(_state) {
|
|
3982
3982
|
switch(_state.label){
|
|
3983
3983
|
case 0:
|
|
@@ -4454,7 +4454,7 @@ var responsesRunAdapter = function() {
|
|
|
4454
4454
|
];
|
|
4455
4455
|
return [
|
|
4456
4456
|
4,
|
|
4457
|
-
providerResponse.final()
|
|
4457
|
+
providerResponse.final()
|
|
4458
4458
|
];
|
|
4459
4459
|
case 21:
|
|
4460
4460
|
_state.sent();
|
|
@@ -4498,11 +4498,19 @@ var responsesRunAdapter = function() {
|
|
|
4498
4498
|
})
|
|
4499
4499
|
];
|
|
4500
4500
|
}
|
|
4501
|
+
return [
|
|
4502
|
+
4,
|
|
4503
|
+
getThread2()
|
|
4504
|
+
];
|
|
4505
|
+
case 24:
|
|
4506
|
+
threadForEvent = _state.sent();
|
|
4501
4507
|
return [
|
|
4502
4508
|
2,
|
|
4503
4509
|
onEvent2({
|
|
4504
4510
|
event: "thread.run.requires_action",
|
|
4505
4511
|
data: _object_spread_props(_object_spread(_object_spread_props(_object_spread({}, run3), {
|
|
4512
|
+
id: run3.id,
|
|
4513
|
+
thread_id: (threadForEvent === null || threadForEvent === void 0 ? void 0 : threadForEvent.openaiConversationId) || (threadForEvent === null || threadForEvent === void 0 ? void 0 : threadForEvent.id) || run3.thread_id,
|
|
4506
4514
|
status: "requires_action"
|
|
4507
4515
|
}), newConversationId ? {
|
|
4508
4516
|
metadata: _object_spread_props(_object_spread({}, (_run3_metadata1 = run3.metadata) !== null && _run3_metadata1 !== void 0 ? _run3_metadata1 : {}), {
|
|
@@ -4596,7 +4604,7 @@ var post11 = function(param) {
|
|
|
4596
4604
|
var openai = param.openai;
|
|
4597
4605
|
return /*#__PURE__*/ function() {
|
|
4598
4606
|
var _ref = _async_to_generator(function(urlString, options) {
|
|
4599
|
-
var url, _url_pathname_match, threadId, body, content, oai;
|
|
4607
|
+
var _conversation_metadata, url, _url_pathname_match, threadId, body, content, oai, conversation, openaiConversationId;
|
|
4600
4608
|
return _ts_generator(this, function(_state) {
|
|
4601
4609
|
switch(_state.label){
|
|
4602
4610
|
case 0:
|
|
@@ -4607,7 +4615,22 @@ var post11 = function(param) {
|
|
|
4607
4615
|
oai = openai;
|
|
4608
4616
|
return [
|
|
4609
4617
|
4,
|
|
4610
|
-
oai.conversations.
|
|
4618
|
+
oai.conversations.retrieve(threadId).catch(function() {
|
|
4619
|
+
return null;
|
|
4620
|
+
})
|
|
4621
|
+
];
|
|
4622
|
+
case 1:
|
|
4623
|
+
conversation = _state.sent();
|
|
4624
|
+
if (!conversation) return [
|
|
4625
|
+
2,
|
|
4626
|
+
new Response("Thread not found", {
|
|
4627
|
+
status: 404
|
|
4628
|
+
})
|
|
4629
|
+
];
|
|
4630
|
+
openaiConversationId = ((_conversation_metadata = conversation.metadata) === null || _conversation_metadata === void 0 ? void 0 : _conversation_metadata.openaiConversationId) || threadId;
|
|
4631
|
+
return [
|
|
4632
|
+
4,
|
|
4633
|
+
oai.conversations.items.create(openaiConversationId, {
|
|
4611
4634
|
items: [
|
|
4612
4635
|
{
|
|
4613
4636
|
type: "message",
|
|
@@ -4622,7 +4645,7 @@ var post11 = function(param) {
|
|
|
4622
4645
|
]
|
|
4623
4646
|
})
|
|
4624
4647
|
];
|
|
4625
|
-
case
|
|
4648
|
+
case 2:
|
|
4626
4649
|
_state.sent();
|
|
4627
4650
|
return [
|
|
4628
4651
|
2,
|
|
@@ -4630,7 +4653,7 @@ var post11 = function(param) {
|
|
|
4630
4653
|
id: "msg_".concat(Date.now()),
|
|
4631
4654
|
object: "thread.message",
|
|
4632
4655
|
created_at: (0, import_dayjs4.default)().unix(),
|
|
4633
|
-
thread_id:
|
|
4656
|
+
thread_id: openaiConversationId,
|
|
4634
4657
|
role: body.role,
|
|
4635
4658
|
content: [
|
|
4636
4659
|
{
|
|
@@ -4670,7 +4693,7 @@ var list = function(param) {
|
|
|
4670
4693
|
var openai = param.openai;
|
|
4671
4694
|
return /*#__PURE__*/ function() {
|
|
4672
4695
|
var _ref = _async_to_generator(function(urlString) {
|
|
4673
|
-
var url, _url_pathname_match, threadId, oai, items, messages5, _items_has_more;
|
|
4696
|
+
var _conversation_metadata, url, _url_pathname_match, threadId, oai, conversation, openaiConversationId, items, messages5, _items_has_more;
|
|
4674
4697
|
return _ts_generator(this, function(_state) {
|
|
4675
4698
|
switch(_state.label){
|
|
4676
4699
|
case 0:
|
|
@@ -4679,9 +4702,24 @@ var list = function(param) {
|
|
|
4679
4702
|
oai = openai;
|
|
4680
4703
|
return [
|
|
4681
4704
|
4,
|
|
4682
|
-
oai.conversations.
|
|
4705
|
+
oai.conversations.retrieve(threadId).catch(function() {
|
|
4706
|
+
return null;
|
|
4707
|
+
})
|
|
4683
4708
|
];
|
|
4684
4709
|
case 1:
|
|
4710
|
+
conversation = _state.sent();
|
|
4711
|
+
if (!conversation) return [
|
|
4712
|
+
2,
|
|
4713
|
+
new Response("Not found", {
|
|
4714
|
+
status: 404
|
|
4715
|
+
})
|
|
4716
|
+
];
|
|
4717
|
+
openaiConversationId = ((_conversation_metadata = conversation.metadata) === null || _conversation_metadata === void 0 ? void 0 : _conversation_metadata.openaiConversationId) || threadId;
|
|
4718
|
+
return [
|
|
4719
|
+
4,
|
|
4720
|
+
oai.conversations.items.list(openaiConversationId)
|
|
4721
|
+
];
|
|
4722
|
+
case 2:
|
|
4685
4723
|
items = _state.sent();
|
|
4686
4724
|
messages5 = (items.data || []).filter(function(item) {
|
|
4687
4725
|
return item.type === "message";
|
|
@@ -4691,7 +4729,7 @@ var list = function(param) {
|
|
|
4691
4729
|
id: item.id,
|
|
4692
4730
|
object: "thread.message",
|
|
4693
4731
|
created_at: (_item_created_at = item.created_at) !== null && _item_created_at !== void 0 ? _item_created_at : (0, import_dayjs5.default)().unix(),
|
|
4694
|
-
thread_id:
|
|
4732
|
+
thread_id: openaiConversationId,
|
|
4695
4733
|
role: item.role,
|
|
4696
4734
|
content: (item.content || []).map(function(c) {
|
|
4697
4735
|
return {
|
|
@@ -4778,7 +4816,7 @@ var post12 = function(param) {
|
|
|
4778
4816
|
metadata = (_conversation_metadata = conversation.metadata) !== null && _conversation_metadata !== void 0 ? _conversation_metadata : {};
|
|
4779
4817
|
openaiConversationId = metadata.openaiConversationId || threadId;
|
|
4780
4818
|
thread = {
|
|
4781
|
-
id:
|
|
4819
|
+
id: openaiConversationId,
|
|
4782
4820
|
object: "thread",
|
|
4783
4821
|
created_at: (_conversation_created_at = conversation.created_at) !== null && _conversation_created_at !== void 0 ? _conversation_created_at : (0, import_dayjs6.default)().unix(),
|
|
4784
4822
|
metadata: metadata,
|
|
@@ -4795,7 +4833,7 @@ var post12 = function(param) {
|
|
|
4795
4833
|
id: "run_".concat((0, import_radash9.uid)(24)),
|
|
4796
4834
|
object: "thread.run",
|
|
4797
4835
|
created_at: (0, import_dayjs6.default)().unix(),
|
|
4798
|
-
thread_id:
|
|
4836
|
+
thread_id: openaiConversationId,
|
|
4799
4837
|
assistant_id: assistant_id,
|
|
4800
4838
|
model: body.model || assistant.model,
|
|
4801
4839
|
instructions: body.instructions || "",
|
|
@@ -5005,6 +5043,12 @@ var post12 = function(param) {
|
|
|
5005
5043
|
return _ts_generator(this, function(_state) {
|
|
5006
5044
|
switch(_state.label){
|
|
5007
5045
|
case 0:
|
|
5046
|
+
return [
|
|
5047
|
+
4,
|
|
5048
|
+
saveRun()
|
|
5049
|
+
];
|
|
5050
|
+
case 1:
|
|
5051
|
+
_state.sent();
|
|
5008
5052
|
return [
|
|
5009
5053
|
4,
|
|
5010
5054
|
runAdapter({
|
|
@@ -5017,13 +5061,13 @@ var post12 = function(param) {
|
|
|
5017
5061
|
getThread: getThread2
|
|
5018
5062
|
})
|
|
5019
5063
|
];
|
|
5020
|
-
case
|
|
5064
|
+
case 2:
|
|
5021
5065
|
_state.sent();
|
|
5022
5066
|
return [
|
|
5023
5067
|
4,
|
|
5024
5068
|
saveRun()
|
|
5025
5069
|
];
|
|
5026
|
-
case
|
|
5070
|
+
case 3:
|
|
5027
5071
|
_state.sent();
|
|
5028
5072
|
controller.close();
|
|
5029
5073
|
return [
|
|
@@ -5203,7 +5247,7 @@ var post13 = function(param) {
|
|
|
5203
5247
|
metadata = (_conversation_metadata = conversation.metadata) !== null && _conversation_metadata !== void 0 ? _conversation_metadata : {};
|
|
5204
5248
|
openaiConversationId = metadata.openaiConversationId || threadId;
|
|
5205
5249
|
thread = {
|
|
5206
|
-
id:
|
|
5250
|
+
id: openaiConversationId,
|
|
5207
5251
|
object: "thread",
|
|
5208
5252
|
created_at: (_conversation_created_at = conversation.created_at) !== null && _conversation_created_at !== void 0 ? _conversation_created_at : (0, import_dayjs7.default)().unix(),
|
|
5209
5253
|
metadata: metadata,
|
|
@@ -5826,7 +5870,7 @@ var import_radash15 = require("radash");
|
|
|
5826
5870
|
// src/adapters/storage/prismaStorageAdapter/threads/runs/onEvent/handlers/threadRunInProgress.ts
|
|
5827
5871
|
var threadRunInProgress = function(param) {
|
|
5828
5872
|
var prisma = param.prisma, event = param.event, controller = param.controller;
|
|
5829
|
-
controller.enqueue(event);
|
|
5873
|
+
controller.enqueue("data: ".concat(JSON.stringify(event), "\n\n"));
|
|
5830
5874
|
return prisma.run.update({
|
|
5831
5875
|
where: {
|
|
5832
5876
|
id: event.data.id
|
|
@@ -5844,7 +5888,7 @@ var threadRunFailed = /*#__PURE__*/ function() {
|
|
|
5844
5888
|
switch(_state.label){
|
|
5845
5889
|
case 0:
|
|
5846
5890
|
prisma = param.prisma, event = param.event, controller = param.controller;
|
|
5847
|
-
controller.enqueue(event);
|
|
5891
|
+
controller.enqueue("data: ".concat(JSON.stringify(event), "\n\n"));
|
|
5848
5892
|
return [
|
|
5849
5893
|
4,
|
|
5850
5894
|
prisma.run.update({
|
|
@@ -5879,7 +5923,7 @@ var threadRunCompleted = /*#__PURE__*/ function() {
|
|
|
5879
5923
|
switch(_state.label){
|
|
5880
5924
|
case 0:
|
|
5881
5925
|
prisma = param.prisma, event = param.event, controller = param.controller;
|
|
5882
|
-
controller.enqueue(event);
|
|
5926
|
+
controller.enqueue("data: ".concat(JSON.stringify(event), "\n\n"));
|
|
5883
5927
|
return [
|
|
5884
5928
|
4,
|
|
5885
5929
|
prisma.run.update({
|
|
@@ -5913,7 +5957,7 @@ var threadRunRequiresAction = /*#__PURE__*/ function() {
|
|
|
5913
5957
|
switch(_state.label){
|
|
5914
5958
|
case 0:
|
|
5915
5959
|
prisma = param.prisma, event = param.event, controller = param.controller;
|
|
5916
|
-
controller.enqueue(event);
|
|
5960
|
+
controller.enqueue("data: ".concat(JSON.stringify(event), "\n\n"));
|
|
5917
5961
|
return [
|
|
5918
5962
|
4,
|
|
5919
5963
|
prisma.run.update({
|
|
@@ -6002,9 +6046,9 @@ var threadRunStepCreated = /*#__PURE__*/ function() {
|
|
|
6002
6046
|
serializedRunStep = serializeRunStep({
|
|
6003
6047
|
runStep: runStep
|
|
6004
6048
|
});
|
|
6005
|
-
controller.enqueue(_object_spread_props(_object_spread({}, event), {
|
|
6049
|
+
controller.enqueue("data: ".concat(JSON.stringify(_object_spread_props(_object_spread({}, event), {
|
|
6006
6050
|
data: serializedRunStep
|
|
6007
|
-
}));
|
|
6051
|
+
})), "\n\n"));
|
|
6008
6052
|
return [
|
|
6009
6053
|
2,
|
|
6010
6054
|
serializedRunStep
|
|
@@ -6019,7 +6063,7 @@ var threadRunStepCreated = /*#__PURE__*/ function() {
|
|
|
6019
6063
|
// src/adapters/storage/prismaStorageAdapter/threads/runs/onEvent/handlers/threadRunStepDelta.ts
|
|
6020
6064
|
var threadRunStepDelta = function(param) {
|
|
6021
6065
|
var event = param.event, controller = param.controller;
|
|
6022
|
-
return controller.enqueue(event);
|
|
6066
|
+
return controller.enqueue("data: ".concat(JSON.stringify(event), "\n\n"));
|
|
6023
6067
|
};
|
|
6024
6068
|
// src/adapters/storage/prismaStorageAdapter/threads/runs/onEvent/handlers/threadMessageCreated.ts
|
|
6025
6069
|
var status2 = function(event) {
|
|
@@ -6053,9 +6097,9 @@ var threadMessageCreated = /*#__PURE__*/ function() {
|
|
|
6053
6097
|
serializedMessage = serializeMessage5({
|
|
6054
6098
|
message: message
|
|
6055
6099
|
});
|
|
6056
|
-
controller.enqueue(_object_spread_props(_object_spread({}, event), {
|
|
6100
|
+
controller.enqueue("data: ".concat(JSON.stringify(_object_spread_props(_object_spread({}, event), {
|
|
6057
6101
|
data: serializedMessage
|
|
6058
|
-
}));
|
|
6102
|
+
})), "\n\n"));
|
|
6059
6103
|
return [
|
|
6060
6104
|
2,
|
|
6061
6105
|
serializedMessage
|
|
@@ -6070,7 +6114,7 @@ var threadMessageCreated = /*#__PURE__*/ function() {
|
|
|
6070
6114
|
// src/adapters/storage/prismaStorageAdapter/threads/runs/onEvent/handlers/threadMessageDelta.ts
|
|
6071
6115
|
var threadMessageDelta = function(param) {
|
|
6072
6116
|
var event = param.event, controller = param.controller;
|
|
6073
|
-
return controller.enqueue(event);
|
|
6117
|
+
return controller.enqueue("data: ".concat(JSON.stringify(event), "\n\n"));
|
|
6074
6118
|
};
|
|
6075
6119
|
// src/adapters/storage/prismaStorageAdapter/threads/runs/onEvent/handlers/threadMessageCompleted.ts
|
|
6076
6120
|
var threadMessageCompleted = /*#__PURE__*/ function() {
|
|
@@ -6080,7 +6124,7 @@ var threadMessageCompleted = /*#__PURE__*/ function() {
|
|
|
6080
6124
|
switch(_state.label){
|
|
6081
6125
|
case 0:
|
|
6082
6126
|
prisma = param.prisma, event = param.event, controller = param.controller;
|
|
6083
|
-
controller.enqueue(event);
|
|
6127
|
+
controller.enqueue("data: ".concat(JSON.stringify(event), "\n\n"));
|
|
6084
6128
|
data = event.data;
|
|
6085
6129
|
if (!data.tool_calls) return [
|
|
6086
6130
|
3,
|
|
@@ -6350,11 +6394,7 @@ var post16 = function(param) {
|
|
|
6350
6394
|
runAdapter({
|
|
6351
6395
|
run: data,
|
|
6352
6396
|
onEvent: onEvent({
|
|
6353
|
-
controller:
|
|
6354
|
-
enqueue: function(data2) {
|
|
6355
|
-
controller.enqueue("data: ".concat(JSON.stringify(data2), "\n\n"));
|
|
6356
|
-
}
|
|
6357
|
-
}),
|
|
6397
|
+
controller: controller,
|
|
6358
6398
|
prisma: prisma
|
|
6359
6399
|
}),
|
|
6360
6400
|
getMessages: getMessages({
|