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.js CHANGED
@@ -372,18 +372,13 @@ var requestHandlers = function(param) {
372
372
  var findRequestHandler = function(param) {
373
373
  var url = param.url, requestHandlers2 = param.requestHandlers;
374
374
  var pathname = new URL(url).pathname;
375
- console.log("[findRequestHandler] Looking for handler for pathname:", pathname);
376
- console.log("[findRequestHandler] Available patterns:", Object.keys(requestHandlers2));
377
375
  for(var key in requestHandlers2){
378
376
  var regex = new RegExp(key);
379
377
  var matches = regex.test(pathname);
380
- console.log("[findRequestHandler] Testing pattern:", key, "- Matches:", matches);
381
378
  if (matches) {
382
- console.log("[findRequestHandler] Found handler!");
383
379
  return requestHandlers2[key];
384
380
  }
385
381
  }
386
- console.log("[findRequestHandler] No handler found for pathname:", pathname);
387
382
  };
388
383
  // src/supercompatFetch/originalFetch.ts
389
384
  var originalFetch = function(param) {
@@ -446,13 +441,11 @@ var supercompatFetch = function(param) {
446
441
  var _ref, _args, url, options, pathHandler, method, requestHandler;
447
442
  return _ts_generator(this, function(_state) {
448
443
  _args = _sliced_to_array(args, 2), url = _args[0], options = _args[1];
449
- console.log("[supercompatFetch] Request:", (options === null || options === void 0 ? void 0 : options.method) || "GET", url);
450
444
  pathHandler = findRequestHandler({
451
445
  url: url,
452
446
  requestHandlers: requestHandlers2
453
447
  });
454
448
  if (!pathHandler) {
455
- console.log("[supercompatFetch] No handler found, using originalFetch");
456
449
  return [
457
450
  2,
458
451
  originalFetch({
@@ -464,7 +457,6 @@ var supercompatFetch = function(param) {
464
457
  method = (_ref = options === null || options === void 0 ? void 0 : options.method) !== null && _ref !== void 0 ? _ref : "";
465
458
  requestHandler = pathHandler[method.toLowerCase()];
466
459
  if (!requestHandler) {
467
- console.log("[supercompatFetch] Handler found but no method handler, using originalFetch");
468
460
  return [
469
461
  2,
470
462
  originalFetch({
@@ -473,7 +465,6 @@ var supercompatFetch = function(param) {
473
465
  })
474
466
  ];
475
467
  }
476
- console.log("[supercompatFetch] Handler found, calling it");
477
468
  return [
478
469
  2,
479
470
  requestHandler.apply(void 0, _to_consumable_array(args))
@@ -8645,18 +8636,20 @@ var post20 = function(param) {
8645
8636
  ];
8646
8637
  case 1:
8647
8638
  openaiAssistant = _state.sent();
8648
- if (assistantId.length > 0 && openaiAssistant && (typeof openaiAssistant === "undefined" ? "undefined" : _type_of(openaiAssistant)) === "object") {
8649
- openaiAssistant.id = assistantId;
8650
- openaiAssistant.name = assistantId;
8651
- }
8652
8639
  _assign9 = assign9(_object_spread({}, defaultAssistant, openaiAssistant), body), model = _assign9.model, instructions = _assign9.instructions, tools = _assign9.tools, metadata = _assign9.metadata, response_format = _assign9.response_format, truncation_strategy = _assign9.truncation_strategy;
8653
- azureAgentId = assistantId.length > 0 ? assistantId : void 0;
8640
+ 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;
8654
8641
  shouldSendInstructions = !azureAgentId && typeof instructions === "string" && instructions.trim().length > 0;
8655
8642
  responseBody = {
8656
8643
  conversation: threadId,
8657
8644
  stream: stream,
8658
8645
  input: createResponseItems
8659
8646
  };
8647
+ if (azureAgentId) {
8648
+ responseBody.agent = {
8649
+ name: azureAgentId,
8650
+ type: "agent_reference"
8651
+ };
8652
+ }
8660
8653
  if (!azureAgentId) {
8661
8654
  responseBody.model = model;
8662
8655
  responseBody.metadata = metadata;
@@ -8680,14 +8673,7 @@ var post20 = function(param) {
8680
8673
  }
8681
8674
  return [
8682
8675
  4,
8683
- client.responses.create(responseBody, azureAgentId ? {
8684
- body: {
8685
- agent: {
8686
- name: azureAgentId,
8687
- type: "agent_reference"
8688
- }
8689
- }
8690
- } : void 0)
8676
+ client.responses.create(responseBody)
8691
8677
  ];
8692
8678
  case 2:
8693
8679
  response = _state.sent();
@@ -8862,6 +8848,12 @@ var post21 = function(param) {
8862
8848
  stream: stream,
8863
8849
  input: input
8864
8850
  };
8851
+ if (azureAgentId) {
8852
+ responseBody.agent = {
8853
+ name: azureAgentId,
8854
+ type: "agent_reference"
8855
+ };
8856
+ }
8865
8857
  if (!azureAgentId) {
8866
8858
  responseBody.model = openaiAssistant.model;
8867
8859
  Object.assign(responseBody, serializeTools3({
@@ -8876,14 +8868,7 @@ var post21 = function(param) {
8876
8868
  }
8877
8869
  return [
8878
8870
  4,
8879
- client.responses.create(responseBody, azureAgentId ? {
8880
- body: {
8881
- agent: {
8882
- name: azureAgentId,
8883
- type: "agent_reference"
8884
- }
8885
- }
8886
- } : void 0)
8871
+ client.responses.create(responseBody)
8887
8872
  ];
8888
8873
  case 3:
8889
8874
  response = _state.sent();
@@ -9034,41 +9019,54 @@ var azureResponsesStorageAdapter = function() {
9034
9019
  };
9035
9020
  var getAzureClient = function() {
9036
9021
  return _async_to_generator(function() {
9037
- var aiProjectClient, _azureClient_apiKey, azureClient;
9022
+ var _aiProjectClient__options, aiProjectClient, apiVersion, azureClient, azureClient1;
9038
9023
  return _ts_generator(this, function(_state) {
9039
9024
  switch(_state.label){
9040
9025
  case 0:
9041
- console.log("[azureResponsesStorageAdapter] getAzureClient called");
9042
9026
  if (cachedClient) {
9043
- console.log("[azureResponsesStorageAdapter] Returning cached Azure client");
9044
9027
  return [
9045
9028
  2,
9046
9029
  cachedClient
9047
9030
  ];
9048
9031
  }
9049
9032
  aiProjectClient = getAIProjectClient();
9050
- console.log("[azureResponsesStorageAdapter] aiProjectClient obtained");
9051
- if (!(aiProjectClient && (typeof aiProjectClient === "undefined" ? "undefined" : _type_of(aiProjectClient)) === "object" && "getOpenAIClient" in aiProjectClient && typeof aiProjectClient.getOpenAIClient === "function")) return [
9033
+ 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;
9034
+ if (!(aiProjectClient && (typeof aiProjectClient === "undefined" ? "undefined" : _type_of(aiProjectClient)) === "object" && "getAzureOpenAIClient" in aiProjectClient && typeof aiProjectClient.getAzureOpenAIClient === "function")) return [
9052
9035
  3,
9053
9036
  2
9054
9037
  ];
9055
- console.log("[azureResponsesStorageAdapter] Calling getOpenAIClient()");
9056
9038
  return [
9057
9039
  4,
9058
- aiProjectClient.getOpenAIClient()
9040
+ aiProjectClient.getAzureOpenAIClient(apiVersion ? {
9041
+ apiVersion: apiVersion
9042
+ } : void 0)
9059
9043
  ];
9060
9044
  case 1:
9061
9045
  azureClient = _state.sent();
9062
- console.log("[azureResponsesStorageAdapter] Azure OpenAI client obtained");
9063
- console.log("[azureResponsesStorageAdapter] Azure client baseURL:", azureClient.baseURL);
9064
- console.log("[azureResponsesStorageAdapter] Azure client apiKey:", ((_azureClient_apiKey = azureClient.apiKey) === null || _azureClient_apiKey === void 0 ? void 0 : _azureClient_apiKey.substring(0, 20)) + "...");
9065
9046
  cachedClient = azureClient;
9066
9047
  return [
9067
9048
  2,
9068
9049
  azureClient
9069
9050
  ];
9070
9051
  case 2:
9071
- console.log("[azureResponsesStorageAdapter] Not an AIProjectClient, treating as OpenAI client");
9052
+ if (!(aiProjectClient && (typeof aiProjectClient === "undefined" ? "undefined" : _type_of(aiProjectClient)) === "object" && "getOpenAIClient" in aiProjectClient && typeof aiProjectClient.getOpenAIClient === "function")) return [
9053
+ 3,
9054
+ 4
9055
+ ];
9056
+ return [
9057
+ 4,
9058
+ aiProjectClient.getOpenAIClient(apiVersion ? {
9059
+ apiVersion: apiVersion
9060
+ } : void 0)
9061
+ ];
9062
+ case 3:
9063
+ azureClient1 = _state.sent();
9064
+ cachedClient = azureClient1;
9065
+ return [
9066
+ 2,
9067
+ azureClient1
9068
+ ];
9069
+ case 4:
9072
9070
  cachedClient = aiProjectClient;
9073
9071
  return [
9074
9072
  2,
@@ -9143,7 +9141,6 @@ var azureResponsesStorageAdapter = function() {
9143
9141
  return _ts_generator(this, function(_state) {
9144
9142
  switch(_state.label){
9145
9143
  case 0:
9146
- console.log("[azureResponsesStorageAdapter] Handler called for:", urlString);
9147
9144
  return [
9148
9145
  4,
9149
9146
  getAzureClient()