supercompat 2.8.0 → 2.9.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 CHANGED
@@ -165,6 +165,33 @@ function _object_spread_props(target, source) {
165
165
  }
166
166
  return target;
167
167
  }
168
+ function _object_without_properties(source, excluded) {
169
+ if (source == null) return {};
170
+ var target = _object_without_properties_loose(source, excluded);
171
+ var key, i;
172
+ if (Object.getOwnPropertySymbols) {
173
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
174
+ for(i = 0; i < sourceSymbolKeys.length; i++){
175
+ key = sourceSymbolKeys[i];
176
+ if (excluded.indexOf(key) >= 0) continue;
177
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
178
+ target[key] = source[key];
179
+ }
180
+ }
181
+ return target;
182
+ }
183
+ function _object_without_properties_loose(source, excluded) {
184
+ if (source == null) return {};
185
+ var target = {};
186
+ var sourceKeys = Object.keys(source);
187
+ var key, i;
188
+ for(i = 0; i < sourceKeys.length; i++){
189
+ key = sourceKeys[i];
190
+ if (excluded.indexOf(key) >= 0) continue;
191
+ target[key] = source[key];
192
+ }
193
+ return target;
194
+ }
168
195
  function _sliced_to_array(arr, i) {
169
196
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
170
197
  }
@@ -908,30 +935,88 @@ var azureOpenaiClientAdapter = function(param) {
908
935
  }
909
936
  };
910
937
  };
938
+ // src/adapters/client/mistralClientAdapter/completions/serializeChunk.ts
939
+ var serializeDelta = function(_param) {
940
+ var toolCalls = _param.delta.toolCalls, rest = _object_without_properties(_param.delta, [
941
+ "toolCalls"
942
+ ]);
943
+ return _object_spread({}, rest, toolCalls ? {
944
+ tool_calls: toolCalls
945
+ } : {});
946
+ };
947
+ var serializeChoice = function(_param) {
948
+ var _param_choice = _param.choice, finishReason = _param_choice.finishReason, delta = _param_choice.delta, rest = _object_without_properties(_param.choice, [
949
+ "finishReason",
950
+ "delta"
951
+ ]);
952
+ return _object_spread_props(_object_spread({}, rest), {
953
+ finish_reason: finishReason !== null && finishReason !== void 0 ? finishReason : null,
954
+ delta: serializeDelta({
955
+ delta: delta
956
+ })
957
+ });
958
+ };
959
+ var serializeChunk = function(param) {
960
+ var chunk = param.chunk;
961
+ return _object_spread({}, chunk.data, chunk.data.choices ? {
962
+ choices: chunk.data.choices.map(function(choice) {
963
+ return serializeChoice({
964
+ choice: choice
965
+ });
966
+ })
967
+ } : {});
968
+ };
969
+ // src/adapters/client/mistralClientAdapter/completions/serializeBody.ts
970
+ var serializeMessage = function(_param) {
971
+ var _param_message = _param.message, // @ts-ignore-next-line
972
+ tool_calls = _param_message.tool_calls, // @ts-ignore-next-line
973
+ tool_call_id = _param_message.tool_call_id, rest = _object_without_properties(_param.message, [
974
+ "tool_calls",
975
+ "tool_call_id"
976
+ ]);
977
+ return _object_spread({}, rest, tool_call_id ? {
978
+ toolCallId: tool_call_id
979
+ } : {}, tool_calls ? {
980
+ toolCalls: tool_calls
981
+ } : {});
982
+ };
983
+ var serializeBody = function(param) {
984
+ var body = param.body;
985
+ return _object_spread_props(_object_spread({}, body), {
986
+ messages: body.messages.map(function(message) {
987
+ return serializeMessage({
988
+ message: message
989
+ });
990
+ })
991
+ });
992
+ };
911
993
  // src/adapters/client/mistralClientAdapter/completions/post.ts
912
994
  var post3 = function(param) {
913
995
  var mistral = param.mistral;
914
996
  return /*#__PURE__*/ function() {
915
997
  var _ref = _async_to_generator(function(_url, options) {
916
- var body, response, stream, data, error;
998
+ var body, serializedBody, response, stream, data, error;
917
999
  return _ts_generator(this, function(_state) {
918
1000
  switch(_state.label){
919
1001
  case 0:
920
1002
  body = JSON.parse(options.body);
1003
+ serializedBody = serializeBody({
1004
+ body: body
1005
+ });
921
1006
  if (!body.stream) return [
922
1007
  3,
923
1008
  2
924
1009
  ];
925
1010
  return [
926
1011
  4,
927
- mistral.chat.stream(body)
1012
+ mistral.chat.stream(serializedBody)
928
1013
  ];
929
1014
  case 1:
930
1015
  response = _state.sent();
931
1016
  stream = new ReadableStream({
932
1017
  start: function start(controller) {
933
1018
  return _async_to_generator(function() {
934
- var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err;
1019
+ var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, serializedChunk, err;
935
1020
  return _ts_generator(this, function(_state) {
936
1021
  switch(_state.label){
937
1022
  case 0:
@@ -958,7 +1043,10 @@ var post3 = function(param) {
958
1043
  ];
959
1044
  _value = _step.value;
960
1045
  chunk = _value;
961
- controller.enqueue("data: ".concat(JSON.stringify(chunk), "\n\n"));
1046
+ serializedChunk = serializeChunk({
1047
+ chunk: chunk
1048
+ });
1049
+ controller.enqueue("data: ".concat(JSON.stringify(serializedChunk), "\n\n"));
962
1050
  _state.label = 4;
963
1051
  case 4:
964
1052
  _iteratorAbruptCompletion = false;
@@ -1040,7 +1128,7 @@ var post3 = function(param) {
1040
1128
  ]);
1041
1129
  return [
1042
1130
  4,
1043
- mistral.chat.complete(body)
1131
+ mistral.chat.complete(serializedBody)
1044
1132
  ];
1045
1133
  case 3:
1046
1134
  data = _state.sent();
@@ -1372,7 +1460,7 @@ var serializeTools = function(param) {
1372
1460
  });
1373
1461
  };
1374
1462
  // src/adapters/client/anthropicClientAdapter/completions/serializeMessages/serializeMessage.ts
1375
- var serializeMessage = function(param) {
1463
+ var serializeMessage2 = function(param) {
1376
1464
  var message = param.message;
1377
1465
  if (message.role === "user") {
1378
1466
  return {
@@ -1414,7 +1502,7 @@ var serializeMessage = function(param) {
1414
1502
  var serializeMessages = function(param) {
1415
1503
  var messages3 = param.messages;
1416
1504
  return messages3.map(function(message) {
1417
- return serializeMessage({
1505
+ return serializeMessage2({
1418
1506
  message: message
1419
1507
  });
1420
1508
  });
@@ -1740,7 +1828,7 @@ var serializeContent = function(param) {
1740
1828
  return content2.text.value;
1741
1829
  }).join("\n");
1742
1830
  };
1743
- var serializeMessage2 = function(param) {
1831
+ var serializeMessage3 = function(param) {
1744
1832
  var message = param.message;
1745
1833
  var _message_metadata;
1746
1834
  var result = [
@@ -1796,7 +1884,7 @@ var messages = /*#__PURE__*/ function() {
1796
1884
  _to_consumable_array.apply(void 0, [
1797
1885
  _2.apply(void 0, [
1798
1886
  _state.sent().map(function(message) {
1799
- return serializeMessage2({
1887
+ return serializeMessage3({
1800
1888
  message: message
1801
1889
  });
1802
1890
  })
@@ -1882,7 +1970,7 @@ var toolCallsData = function(param) {
1882
1970
  var completionsRunAdapter = function() {
1883
1971
  return /*#__PURE__*/ function() {
1884
1972
  var _ref = _async_to_generator(function(param) {
1885
- var clientAdapter, run2, onEvent2, getMessages2, client, opts, _tmp, providerResponse, e, _e_cause, _e_message, _e_cause_message, message, toolCallsRunStep, currentContent, currentToolCalls, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, choice, delta, _delta_content, err;
1973
+ var clientAdapter, run2, onEvent2, getMessages2, client, opts, _tmp, providerResponse, e, _e_cause, _e_message, _e_cause_message, message, toolCallsRunStep, currentContent, currentToolCalls, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, _chunk_choices, choices, choice, delta, _delta_content, err;
1886
1974
  return _ts_generator(this, function(_state) {
1887
1975
  switch(_state.label){
1888
1976
  case 0:
@@ -2032,7 +2120,8 @@ var completionsRunAdapter = function() {
2032
2120
  ];
2033
2121
  _value = _step.value;
2034
2122
  chunk = _value;
2035
- choice = chunk.choices[0];
2123
+ choices = (_chunk_choices = chunk.choices) !== null && _chunk_choices !== void 0 ? _chunk_choices : [];
2124
+ choice = choices[0];
2036
2125
  if (!choice) return [
2037
2126
  3,
2038
2127
  13
@@ -2340,7 +2429,7 @@ var threads = function(param) {
2340
2429
  // src/adapters/storage/prismaStorageAdapter/threads/messages/serializeMessage.ts
2341
2430
  var import_dayjs4 = __toESM(require("dayjs"), 1);
2342
2431
  var import_radash6 = require("radash");
2343
- var serializeMessage3 = function(param) {
2432
+ var serializeMessage4 = function(param) {
2344
2433
  var message = param.message;
2345
2434
  var _message_metadata;
2346
2435
  return {
@@ -2403,7 +2492,7 @@ var post7 = function(param) {
2403
2492
  message = _state.sent();
2404
2493
  return [
2405
2494
  2,
2406
- new Response(JSON.stringify(serializeMessage3({
2495
+ new Response(JSON.stringify(serializeMessage4({
2407
2496
  message: message
2408
2497
  })), {
2409
2498
  status: 200,
@@ -2459,7 +2548,7 @@ var get = function(param) {
2459
2548
  2,
2460
2549
  new Response(JSON.stringify({
2461
2550
  data: messages3.map(function(message) {
2462
- return serializeMessage3({
2551
+ return serializeMessage4({
2463
2552
  message: message
2464
2553
  });
2465
2554
  }),
@@ -2770,7 +2859,7 @@ var threadMessageCreated = /*#__PURE__*/ function() {
2770
2859
  ];
2771
2860
  case 1:
2772
2861
  message = _state.sent();
2773
- serializedMessage = serializeMessage3({
2862
+ serializedMessage = serializeMessage4({
2774
2863
  message: message
2775
2864
  });
2776
2865
  controller.enqueue(_object_spread_props(_object_spread({}, event), {
@@ -2939,7 +3028,7 @@ var getMessages = function(param) {
2939
3028
  return [
2940
3029
  2,
2941
3030
  messages3.map(function(message) {
2942
- return _object_spread_props(_object_spread({}, serializeMessage3({
3031
+ return _object_spread_props(_object_spread({}, serializeMessage4({
2943
3032
  message: message
2944
3033
  })), {
2945
3034
  run: message.run ? _object_spread_props(_object_spread({}, serializeRun({