supercompat 3.15.5 → 3.15.7

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
@@ -493,18 +493,13 @@ var requestHandlers = function(param) {
493
493
  var findRequestHandler = function(param) {
494
494
  var url = param.url, requestHandlers2 = param.requestHandlers;
495
495
  var pathname = new URL(url).pathname;
496
- console.log("[findRequestHandler] Looking for handler for pathname:", pathname);
497
- console.log("[findRequestHandler] Available patterns:", Object.keys(requestHandlers2));
498
496
  for(var key in requestHandlers2){
499
497
  var regex = new RegExp(key);
500
498
  var matches = regex.test(pathname);
501
- console.log("[findRequestHandler] Testing pattern:", key, "- Matches:", matches);
502
499
  if (matches) {
503
- console.log("[findRequestHandler] Found handler!");
504
500
  return requestHandlers2[key];
505
501
  }
506
502
  }
507
- console.log("[findRequestHandler] No handler found for pathname:", pathname);
508
503
  };
509
504
  // src/supercompatFetch/originalFetch.ts
510
505
  var originalFetch = function(param) {
@@ -567,13 +562,11 @@ var supercompatFetch = function(param) {
567
562
  var _ref, _args, url, options, pathHandler, method, requestHandler;
568
563
  return _ts_generator(this, function(_state) {
569
564
  _args = _sliced_to_array(args, 2), url = _args[0], options = _args[1];
570
- console.log("[supercompatFetch] Request:", (options === null || options === void 0 ? void 0 : options.method) || "GET", url);
571
565
  pathHandler = findRequestHandler({
572
566
  url: url,
573
567
  requestHandlers: requestHandlers2
574
568
  });
575
569
  if (!pathHandler) {
576
- console.log("[supercompatFetch] No handler found, using originalFetch");
577
570
  return [
578
571
  2,
579
572
  originalFetch({
@@ -585,7 +578,6 @@ var supercompatFetch = function(param) {
585
578
  method = (_ref = options === null || options === void 0 ? void 0 : options.method) !== null && _ref !== void 0 ? _ref : "";
586
579
  requestHandler = pathHandler[method.toLowerCase()];
587
580
  if (!requestHandler) {
588
- console.log("[supercompatFetch] Handler found but no method handler, using originalFetch");
589
581
  return [
590
582
  2,
591
583
  originalFetch({
@@ -594,7 +586,6 @@ var supercompatFetch = function(param) {
594
586
  })
595
587
  ];
596
588
  }
597
- console.log("[supercompatFetch] Handler found, calling it");
598
589
  return [
599
590
  2,
600
591
  requestHandler.apply(void 0, _to_consumable_array(args))
@@ -8767,18 +8758,20 @@ var post20 = function(param) {
8767
8758
  ];
8768
8759
  case 1:
8769
8760
  openaiAssistant = _state.sent();
8770
- if (assistantId.length > 0 && openaiAssistant && (typeof openaiAssistant === "undefined" ? "undefined" : _type_of(openaiAssistant)) === "object") {
8771
- openaiAssistant.id = assistantId;
8772
- openaiAssistant.name = assistantId;
8773
- }
8774
8761
  _ref = (0, import_radash24.assign)(_object_spread({}, defaultAssistant, openaiAssistant), body), model = _ref.model, instructions = _ref.instructions, tools = _ref.tools, metadata = _ref.metadata, response_format = _ref.response_format, truncation_strategy = _ref.truncation_strategy;
8775
- azureAgentId = assistantId.length > 0 ? assistantId : void 0;
8762
+ azureAgentId = openaiAssistant && (typeof openaiAssistant === "undefined" ? "undefined" : _type_of(openaiAssistant)) === "object" && typeof openaiAssistant.id === "string" && typeof openaiAssistant.name === "string" && openaiAssistant.id.trim().length > 0 && openaiAssistant.id === openaiAssistant.name && openaiAssistant.id === assistantId ? openaiAssistant.id : void 0;
8776
8763
  shouldSendInstructions = !azureAgentId && typeof instructions === "string" && instructions.trim().length > 0;
8777
8764
  responseBody = {
8778
8765
  conversation: threadId,
8779
8766
  stream: stream,
8780
8767
  input: createResponseItems
8781
8768
  };
8769
+ if (azureAgentId) {
8770
+ responseBody.agent = {
8771
+ name: azureAgentId,
8772
+ type: "agent_reference"
8773
+ };
8774
+ }
8782
8775
  if (!azureAgentId) {
8783
8776
  responseBody.model = model;
8784
8777
  responseBody.metadata = metadata;
@@ -8802,14 +8795,7 @@ var post20 = function(param) {
8802
8795
  }
8803
8796
  return [
8804
8797
  4,
8805
- client.responses.create(responseBody, azureAgentId ? {
8806
- body: {
8807
- agent: {
8808
- name: azureAgentId,
8809
- type: "agent_reference"
8810
- }
8811
- }
8812
- } : void 0)
8798
+ client.responses.create(responseBody)
8813
8799
  ];
8814
8800
  case 2:
8815
8801
  response = _state.sent();
@@ -8984,6 +8970,12 @@ var post21 = function(param) {
8984
8970
  stream: stream,
8985
8971
  input: input
8986
8972
  };
8973
+ if (azureAgentId) {
8974
+ responseBody.agent = {
8975
+ name: azureAgentId,
8976
+ type: "agent_reference"
8977
+ };
8978
+ }
8987
8979
  if (!azureAgentId) {
8988
8980
  responseBody.model = openaiAssistant.model;
8989
8981
  Object.assign(responseBody, serializeTools3({
@@ -8998,14 +8990,7 @@ var post21 = function(param) {
8998
8990
  }
8999
8991
  return [
9000
8992
  4,
9001
- client.responses.create(responseBody, azureAgentId ? {
9002
- body: {
9003
- agent: {
9004
- name: azureAgentId,
9005
- type: "agent_reference"
9006
- }
9007
- }
9008
- } : void 0)
8993
+ client.responses.create(responseBody)
9009
8994
  ];
9010
8995
  case 3:
9011
8996
  response = _state.sent();
@@ -9156,41 +9141,54 @@ var azureResponsesStorageAdapter = function() {
9156
9141
  };
9157
9142
  var getAzureClient = function() {
9158
9143
  return _async_to_generator(function() {
9159
- var aiProjectClient, _azureClient_apiKey, azureClient;
9144
+ var _aiProjectClient__options, aiProjectClient, apiVersion, azureClient, azureClient1;
9160
9145
  return _ts_generator(this, function(_state) {
9161
9146
  switch(_state.label){
9162
9147
  case 0:
9163
- console.log("[azureResponsesStorageAdapter] getAzureClient called");
9164
9148
  if (cachedClient) {
9165
- console.log("[azureResponsesStorageAdapter] Returning cached Azure client");
9166
9149
  return [
9167
9150
  2,
9168
9151
  cachedClient
9169
9152
  ];
9170
9153
  }
9171
9154
  aiProjectClient = getAIProjectClient();
9172
- console.log("[azureResponsesStorageAdapter] aiProjectClient obtained");
9173
- if (!(aiProjectClient && (typeof aiProjectClient === "undefined" ? "undefined" : _type_of(aiProjectClient)) === "object" && "getOpenAIClient" in aiProjectClient && typeof aiProjectClient.getOpenAIClient === "function")) return [
9155
+ apiVersion = (typeof aiProjectClient === "undefined" ? "undefined" : _type_of(aiProjectClient)) === "object" ? (_aiProjectClient__options = aiProjectClient._options) === null || _aiProjectClient__options === void 0 ? void 0 : _aiProjectClient__options.apiVersion : void 0;
9156
+ if (!(aiProjectClient && (typeof aiProjectClient === "undefined" ? "undefined" : _type_of(aiProjectClient)) === "object" && "getAzureOpenAIClient" in aiProjectClient && typeof aiProjectClient.getAzureOpenAIClient === "function")) return [
9174
9157
  3,
9175
9158
  2
9176
9159
  ];
9177
- console.log("[azureResponsesStorageAdapter] Calling getOpenAIClient()");
9178
9160
  return [
9179
9161
  4,
9180
- aiProjectClient.getOpenAIClient()
9162
+ aiProjectClient.getAzureOpenAIClient(apiVersion ? {
9163
+ apiVersion: apiVersion
9164
+ } : void 0)
9181
9165
  ];
9182
9166
  case 1:
9183
9167
  azureClient = _state.sent();
9184
- console.log("[azureResponsesStorageAdapter] Azure OpenAI client obtained");
9185
- console.log("[azureResponsesStorageAdapter] Azure client baseURL:", azureClient.baseURL);
9186
- console.log("[azureResponsesStorageAdapter] Azure client apiKey:", ((_azureClient_apiKey = azureClient.apiKey) === null || _azureClient_apiKey === void 0 ? void 0 : _azureClient_apiKey.substring(0, 20)) + "...");
9187
9168
  cachedClient = azureClient;
9188
9169
  return [
9189
9170
  2,
9190
9171
  azureClient
9191
9172
  ];
9192
9173
  case 2:
9193
- console.log("[azureResponsesStorageAdapter] Not an AIProjectClient, treating as OpenAI client");
9174
+ if (!(aiProjectClient && (typeof aiProjectClient === "undefined" ? "undefined" : _type_of(aiProjectClient)) === "object" && "getOpenAIClient" in aiProjectClient && typeof aiProjectClient.getOpenAIClient === "function")) return [
9175
+ 3,
9176
+ 4
9177
+ ];
9178
+ return [
9179
+ 4,
9180
+ aiProjectClient.getOpenAIClient(apiVersion ? {
9181
+ apiVersion: apiVersion
9182
+ } : void 0)
9183
+ ];
9184
+ case 3:
9185
+ azureClient1 = _state.sent();
9186
+ cachedClient = azureClient1;
9187
+ return [
9188
+ 2,
9189
+ azureClient1
9190
+ ];
9191
+ case 4:
9194
9192
  cachedClient = aiProjectClient;
9195
9193
  return [
9196
9194
  2,
@@ -9265,7 +9263,6 @@ var azureResponsesStorageAdapter = function() {
9265
9263
  return _ts_generator(this, function(_state) {
9266
9264
  switch(_state.label){
9267
9265
  case 0:
9268
- console.log("[azureResponsesStorageAdapter] Handler called for:", urlString);
9269
9266
  return [
9270
9267
  4,
9271
9268
  getAzureClient()