supercompat 4.1.0 → 4.2.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/openai/index.cjs +32 -32
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.d.cts +28 -12
- package/dist/openai/index.d.ts +28 -12
- package/dist/openai/index.js +32 -32
- package/dist/openai/index.js.map +1 -1
- package/dist/supercompat.cjs +29 -29
- package/dist/supercompat.cjs.map +1 -1
- package/dist/supercompat.d.cts +3 -3
- package/dist/supercompat.d.ts +3 -3
- package/dist/supercompat.js +29 -29
- package/dist/supercompat.js.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/openai/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import { Mistral } from '@mistralai/mistralai';
|
|
|
5
5
|
import Anthropic from '@anthropic-ai/sdk';
|
|
6
6
|
import { GoogleGenAI } from '@google/genai';
|
|
7
7
|
import { OpenRouter } from '@openrouter/sdk';
|
|
8
|
-
import { AssistantsRunBody, ResponsesRunBody, MessageWithRun, RunAdapterBody,
|
|
8
|
+
import { AssistantsRunBody, ResponsesRunBody, MessageWithRun, RunAdapterBody, StorageAdapterArgs, RequestHandler, RunAdapterWithAssistant } from '../types/index.cjs';
|
|
9
9
|
import { PrismaClient } from '@prisma/client';
|
|
10
10
|
|
|
11
11
|
declare const groqClientAdapter: ({ groq, }: {
|
|
@@ -56,8 +56,8 @@ declare const azureOpenaiClientAdapter: ({ azureOpenai, }: {
|
|
|
56
56
|
* @example Azure Agents API
|
|
57
57
|
* ```typescript
|
|
58
58
|
* const client = supercompat({
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* clientAdapter: azureAiProjectClientAdapter({ azureAiProject }),
|
|
60
|
+
* storageAdapter: azureAgentsStorageAdapter(),
|
|
61
61
|
* runAdapter: azureAgentsRunAdapter({ ... })
|
|
62
62
|
* })
|
|
63
63
|
* ```
|
|
@@ -65,8 +65,8 @@ declare const azureOpenaiClientAdapter: ({ azureOpenai, }: {
|
|
|
65
65
|
* @example Azure Responses API
|
|
66
66
|
* ```typescript
|
|
67
67
|
* const client = supercompat({
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
* clientAdapter: azureAiProjectClientAdapter({ azureAiProject }),
|
|
69
|
+
* storageAdapter: azureResponsesStorageAdapter(),
|
|
70
70
|
* runAdapter: azureResponsesRunAdapter({ ... })
|
|
71
71
|
* })
|
|
72
72
|
* ```
|
|
@@ -240,7 +240,11 @@ declare const perplexityAgentRunAdapter: ({ apiKey, baseURL, preset, }: {
|
|
|
240
240
|
*/
|
|
241
241
|
|
|
242
242
|
declare const openaiResponsesRunAdapter: ({ getOpenaiAssistant, waitUntil, }?: {
|
|
243
|
-
getOpenaiAssistant?:
|
|
243
|
+
getOpenaiAssistant?: (args?: {
|
|
244
|
+
select?: {
|
|
245
|
+
id?: boolean;
|
|
246
|
+
};
|
|
247
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>;
|
|
244
248
|
waitUntil?: <T>(p: Promise<T>) => void | Promise<void>;
|
|
245
249
|
}) => {
|
|
246
250
|
handleRun: ({ client, body, onEvent, }: {
|
|
@@ -248,7 +252,11 @@ declare const openaiResponsesRunAdapter: ({ getOpenaiAssistant, waitUntil, }?: {
|
|
|
248
252
|
body: RunAdapterBody;
|
|
249
253
|
onEvent: (event: OpenAI.Responses.ResponseStreamEvent) => Promise<void>;
|
|
250
254
|
}) => Promise<void>;
|
|
251
|
-
getOpenaiAssistant?:
|
|
255
|
+
getOpenaiAssistant?: ((args?: {
|
|
256
|
+
select?: {
|
|
257
|
+
id?: boolean;
|
|
258
|
+
};
|
|
259
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>) | undefined;
|
|
252
260
|
type: "responses-openai";
|
|
253
261
|
};
|
|
254
262
|
|
|
@@ -262,14 +270,22 @@ declare const openaiResponsesRunAdapter: ({ getOpenaiAssistant, waitUntil, }?: {
|
|
|
262
270
|
|
|
263
271
|
declare const azureResponsesRunAdapter: ({ azureAiProject, getOpenaiAssistant, }: {
|
|
264
272
|
azureAiProject: AIProjectClient;
|
|
265
|
-
getOpenaiAssistant?:
|
|
273
|
+
getOpenaiAssistant?: (args?: {
|
|
274
|
+
select?: {
|
|
275
|
+
id?: boolean;
|
|
276
|
+
};
|
|
277
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>;
|
|
266
278
|
}) => {
|
|
267
279
|
handleRun: ({ body, onEvent, }: {
|
|
268
280
|
client?: OpenAI;
|
|
269
281
|
body: RunAdapterBody;
|
|
270
282
|
onEvent: (event: OpenAI.Responses.ResponseStreamEvent) => Promise<void>;
|
|
271
283
|
}) => Promise<void>;
|
|
272
|
-
getOpenaiAssistant?:
|
|
284
|
+
getOpenaiAssistant?: ((args?: {
|
|
285
|
+
select?: {
|
|
286
|
+
id?: boolean;
|
|
287
|
+
};
|
|
288
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>) | undefined;
|
|
273
289
|
type: "responses-azure";
|
|
274
290
|
};
|
|
275
291
|
|
|
@@ -465,7 +481,7 @@ type MethodHandlers = {
|
|
|
465
481
|
};
|
|
466
482
|
type AzureResponsesStorageAdapterArgs = StorageAdapterArgs & {
|
|
467
483
|
runAdapter: RunAdapterWithAssistant;
|
|
468
|
-
|
|
484
|
+
originalClientAdapter?: any;
|
|
469
485
|
};
|
|
470
486
|
/**
|
|
471
487
|
* Storage adapter for Azure's Responses API (conversations + responses endpoints).
|
|
@@ -477,8 +493,8 @@ type AzureResponsesStorageAdapterArgs = StorageAdapterArgs & {
|
|
|
477
493
|
* const azureAiProject = new AIProjectClient(endpoint, credential)
|
|
478
494
|
*
|
|
479
495
|
* const client = supercompat({
|
|
480
|
-
*
|
|
481
|
-
*
|
|
496
|
+
* clientAdapter: azureAiProjectClientAdapter({ azureAiProject }),
|
|
497
|
+
* storageAdapter: azureResponsesStorageAdapter(),
|
|
482
498
|
* runAdapter: azureResponsesRunAdapter({ getOpenaiAssistant: () => assistant }),
|
|
483
499
|
* })
|
|
484
500
|
* ```
|
package/dist/openai/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Mistral } from '@mistralai/mistralai';
|
|
|
5
5
|
import Anthropic from '@anthropic-ai/sdk';
|
|
6
6
|
import { GoogleGenAI } from '@google/genai';
|
|
7
7
|
import { OpenRouter } from '@openrouter/sdk';
|
|
8
|
-
import { AssistantsRunBody, ResponsesRunBody, MessageWithRun, RunAdapterBody,
|
|
8
|
+
import { AssistantsRunBody, ResponsesRunBody, MessageWithRun, RunAdapterBody, StorageAdapterArgs, RequestHandler, RunAdapterWithAssistant } from '../types/index.js';
|
|
9
9
|
import { PrismaClient } from '@prisma/client';
|
|
10
10
|
|
|
11
11
|
declare const groqClientAdapter: ({ groq, }: {
|
|
@@ -56,8 +56,8 @@ declare const azureOpenaiClientAdapter: ({ azureOpenai, }: {
|
|
|
56
56
|
* @example Azure Agents API
|
|
57
57
|
* ```typescript
|
|
58
58
|
* const client = supercompat({
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* clientAdapter: azureAiProjectClientAdapter({ azureAiProject }),
|
|
60
|
+
* storageAdapter: azureAgentsStorageAdapter(),
|
|
61
61
|
* runAdapter: azureAgentsRunAdapter({ ... })
|
|
62
62
|
* })
|
|
63
63
|
* ```
|
|
@@ -65,8 +65,8 @@ declare const azureOpenaiClientAdapter: ({ azureOpenai, }: {
|
|
|
65
65
|
* @example Azure Responses API
|
|
66
66
|
* ```typescript
|
|
67
67
|
* const client = supercompat({
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
* clientAdapter: azureAiProjectClientAdapter({ azureAiProject }),
|
|
69
|
+
* storageAdapter: azureResponsesStorageAdapter(),
|
|
70
70
|
* runAdapter: azureResponsesRunAdapter({ ... })
|
|
71
71
|
* })
|
|
72
72
|
* ```
|
|
@@ -240,7 +240,11 @@ declare const perplexityAgentRunAdapter: ({ apiKey, baseURL, preset, }: {
|
|
|
240
240
|
*/
|
|
241
241
|
|
|
242
242
|
declare const openaiResponsesRunAdapter: ({ getOpenaiAssistant, waitUntil, }?: {
|
|
243
|
-
getOpenaiAssistant?:
|
|
243
|
+
getOpenaiAssistant?: (args?: {
|
|
244
|
+
select?: {
|
|
245
|
+
id?: boolean;
|
|
246
|
+
};
|
|
247
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>;
|
|
244
248
|
waitUntil?: <T>(p: Promise<T>) => void | Promise<void>;
|
|
245
249
|
}) => {
|
|
246
250
|
handleRun: ({ client, body, onEvent, }: {
|
|
@@ -248,7 +252,11 @@ declare const openaiResponsesRunAdapter: ({ getOpenaiAssistant, waitUntil, }?: {
|
|
|
248
252
|
body: RunAdapterBody;
|
|
249
253
|
onEvent: (event: OpenAI.Responses.ResponseStreamEvent) => Promise<void>;
|
|
250
254
|
}) => Promise<void>;
|
|
251
|
-
getOpenaiAssistant?:
|
|
255
|
+
getOpenaiAssistant?: ((args?: {
|
|
256
|
+
select?: {
|
|
257
|
+
id?: boolean;
|
|
258
|
+
};
|
|
259
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>) | undefined;
|
|
252
260
|
type: "responses-openai";
|
|
253
261
|
};
|
|
254
262
|
|
|
@@ -262,14 +270,22 @@ declare const openaiResponsesRunAdapter: ({ getOpenaiAssistant, waitUntil, }?: {
|
|
|
262
270
|
|
|
263
271
|
declare const azureResponsesRunAdapter: ({ azureAiProject, getOpenaiAssistant, }: {
|
|
264
272
|
azureAiProject: AIProjectClient;
|
|
265
|
-
getOpenaiAssistant?:
|
|
273
|
+
getOpenaiAssistant?: (args?: {
|
|
274
|
+
select?: {
|
|
275
|
+
id?: boolean;
|
|
276
|
+
};
|
|
277
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>;
|
|
266
278
|
}) => {
|
|
267
279
|
handleRun: ({ body, onEvent, }: {
|
|
268
280
|
client?: OpenAI;
|
|
269
281
|
body: RunAdapterBody;
|
|
270
282
|
onEvent: (event: OpenAI.Responses.ResponseStreamEvent) => Promise<void>;
|
|
271
283
|
}) => Promise<void>;
|
|
272
|
-
getOpenaiAssistant?:
|
|
284
|
+
getOpenaiAssistant?: ((args?: {
|
|
285
|
+
select?: {
|
|
286
|
+
id?: boolean;
|
|
287
|
+
};
|
|
288
|
+
}) => Promise<OpenAI.Beta.Assistants.Assistant> | OpenAI.Beta.Assistants.Assistant | Pick<OpenAI.Beta.Assistants.Assistant, "id"> | Promise<Pick<OpenAI.Beta.Assistants.Assistant, "id">>) | undefined;
|
|
273
289
|
type: "responses-azure";
|
|
274
290
|
};
|
|
275
291
|
|
|
@@ -465,7 +481,7 @@ type MethodHandlers = {
|
|
|
465
481
|
};
|
|
466
482
|
type AzureResponsesStorageAdapterArgs = StorageAdapterArgs & {
|
|
467
483
|
runAdapter: RunAdapterWithAssistant;
|
|
468
|
-
|
|
484
|
+
originalClientAdapter?: any;
|
|
469
485
|
};
|
|
470
486
|
/**
|
|
471
487
|
* Storage adapter for Azure's Responses API (conversations + responses endpoints).
|
|
@@ -477,8 +493,8 @@ type AzureResponsesStorageAdapterArgs = StorageAdapterArgs & {
|
|
|
477
493
|
* const azureAiProject = new AIProjectClient(endpoint, credential)
|
|
478
494
|
*
|
|
479
495
|
* const client = supercompat({
|
|
480
|
-
*
|
|
481
|
-
*
|
|
496
|
+
* clientAdapter: azureAiProjectClientAdapter({ azureAiProject }),
|
|
497
|
+
* storageAdapter: azureResponsesStorageAdapter(),
|
|
482
498
|
* runAdapter: azureResponsesRunAdapter({ getOpenaiAssistant: () => assistant }),
|
|
483
499
|
* })
|
|
484
500
|
* ```
|
package/dist/openai/index.js
CHANGED
|
@@ -448,29 +448,29 @@ import OpenAI, { AzureOpenAI } from "openai";
|
|
|
448
448
|
// src/supercompatFetch/requestHandlers.ts
|
|
449
449
|
import { assign, partob } from "radash";
|
|
450
450
|
var storageRequestHandlers = function(param) {
|
|
451
|
-
var
|
|
452
|
-
if (!
|
|
451
|
+
var storageAdapter = param.storageAdapter, runAdapter = param.runAdapter, clientAdapter = param.clientAdapter;
|
|
452
|
+
if (!storageAdapter) return {};
|
|
453
453
|
if (!runAdapter) return {};
|
|
454
454
|
var wrappedClient = supercompat({
|
|
455
|
-
|
|
455
|
+
clientAdapter: clientAdapter
|
|
456
456
|
});
|
|
457
|
-
var result =
|
|
457
|
+
var result = storageAdapter({
|
|
458
458
|
runAdapter: _object_spread_props(_object_spread({}, runAdapter), {
|
|
459
459
|
handleRun: partob(runAdapter.handleRun, {
|
|
460
460
|
client: wrappedClient
|
|
461
461
|
})
|
|
462
462
|
}),
|
|
463
463
|
client: wrappedClient,
|
|
464
|
-
|
|
464
|
+
originalClientAdapter: clientAdapter
|
|
465
465
|
});
|
|
466
466
|
return result.requestHandlers;
|
|
467
467
|
};
|
|
468
468
|
var requestHandlers = function(param) {
|
|
469
|
-
var
|
|
470
|
-
return assign(
|
|
471
|
-
|
|
469
|
+
var clientAdapter = param.clientAdapter, storageAdapter = param.storageAdapter, runAdapter = param.runAdapter;
|
|
470
|
+
return assign(clientAdapter.requestHandlers, storageRequestHandlers({
|
|
471
|
+
storageAdapter: storageAdapter,
|
|
472
472
|
runAdapter: runAdapter,
|
|
473
|
-
|
|
473
|
+
clientAdapter: clientAdapter
|
|
474
474
|
}));
|
|
475
475
|
};
|
|
476
476
|
// src/supercompatFetch/findRequestHandler.ts
|
|
@@ -487,20 +487,20 @@ var findRequestHandler = function(param) {
|
|
|
487
487
|
};
|
|
488
488
|
// src/supercompatFetch/originalFetch.ts
|
|
489
489
|
var originalFetch = function(param) {
|
|
490
|
-
var args = param.args,
|
|
490
|
+
var args = param.args, clientAdapter = param.clientAdapter;
|
|
491
491
|
return _async_to_generator(function() {
|
|
492
|
-
var
|
|
492
|
+
var _clientAdapter_client, _args, url, options, clientHeaders, newOptions;
|
|
493
493
|
return _ts_generator(this, function(_state) {
|
|
494
494
|
switch(_state.label){
|
|
495
495
|
case 0:
|
|
496
|
-
if (!((
|
|
496
|
+
if (!((_clientAdapter_client = clientAdapter.client) === null || _clientAdapter_client === void 0 ? void 0 : _clientAdapter_client.fetch)) return [
|
|
497
497
|
3,
|
|
498
498
|
2
|
|
499
499
|
];
|
|
500
500
|
_args = _sliced_to_array(args, 2), url = _args[0], options = _args[1];
|
|
501
501
|
return [
|
|
502
502
|
4,
|
|
503
|
-
|
|
503
|
+
clientAdapter.client.buildHeaders({
|
|
504
504
|
options: {},
|
|
505
505
|
method: args[1].method.toLowerCase(),
|
|
506
506
|
bodyHeaders: args[1].headers,
|
|
@@ -509,13 +509,13 @@ var originalFetch = function(param) {
|
|
|
509
509
|
];
|
|
510
510
|
case 1:
|
|
511
511
|
clientHeaders = _state.sent();
|
|
512
|
-
clientHeaders.set("Authorization", "Bearer ".concat(
|
|
512
|
+
clientHeaders.set("Authorization", "Bearer ".concat(clientAdapter.client.apiKey));
|
|
513
513
|
newOptions = _object_spread_props(_object_spread({}, options), {
|
|
514
514
|
headers: clientHeaders
|
|
515
515
|
});
|
|
516
516
|
return [
|
|
517
517
|
2,
|
|
518
|
-
|
|
518
|
+
clientAdapter.client.fetch(url, newOptions)
|
|
519
519
|
];
|
|
520
520
|
case 2:
|
|
521
521
|
return [
|
|
@@ -532,10 +532,10 @@ var originalFetch = function(param) {
|
|
|
532
532
|
};
|
|
533
533
|
// src/supercompatFetch/index.ts
|
|
534
534
|
var supercompatFetch = function(param) {
|
|
535
|
-
var
|
|
535
|
+
var clientAdapter = param.clientAdapter, storageAdapter = param.storageAdapter, runAdapter = param.runAdapter;
|
|
536
536
|
var requestHandlers2 = requestHandlers({
|
|
537
|
-
|
|
538
|
-
|
|
537
|
+
clientAdapter: clientAdapter,
|
|
538
|
+
storageAdapter: storageAdapter,
|
|
539
539
|
runAdapter: runAdapter
|
|
540
540
|
});
|
|
541
541
|
return function() {
|
|
@@ -554,7 +554,7 @@ var supercompatFetch = function(param) {
|
|
|
554
554
|
return [
|
|
555
555
|
2,
|
|
556
556
|
originalFetch({
|
|
557
|
-
|
|
557
|
+
clientAdapter: clientAdapter,
|
|
558
558
|
args: args
|
|
559
559
|
})
|
|
560
560
|
];
|
|
@@ -565,7 +565,7 @@ var supercompatFetch = function(param) {
|
|
|
565
565
|
return [
|
|
566
566
|
2,
|
|
567
567
|
originalFetch({
|
|
568
|
-
|
|
568
|
+
clientAdapter: clientAdapter,
|
|
569
569
|
args: args
|
|
570
570
|
})
|
|
571
571
|
];
|
|
@@ -585,17 +585,17 @@ var endpointFromBaseUrl = function(param) {
|
|
|
585
585
|
};
|
|
586
586
|
// src/supercompat.ts
|
|
587
587
|
var supercompat = function(param) {
|
|
588
|
-
var
|
|
589
|
-
if (
|
|
588
|
+
var clientAdapter = param.clientAdapter, storageAdapter = param.storageAdapter, runAdapter = param.runAdapter;
|
|
589
|
+
if (clientAdapter.type === "AZURE_OPENAI") {
|
|
590
590
|
return new AzureOpenAI({
|
|
591
|
-
apiKey:
|
|
592
|
-
apiVersion:
|
|
591
|
+
apiKey: clientAdapter.client.apiKey,
|
|
592
|
+
apiVersion: clientAdapter.client.apiVersion,
|
|
593
593
|
endpoint: endpointFromBaseUrl({
|
|
594
|
-
baseURL:
|
|
594
|
+
baseURL: clientAdapter.client.baseURL
|
|
595
595
|
}),
|
|
596
596
|
fetch: supercompatFetch({
|
|
597
|
-
|
|
598
|
-
|
|
597
|
+
clientAdapter: clientAdapter,
|
|
598
|
+
storageAdapter: storageAdapter,
|
|
599
599
|
runAdapter: runAdapter
|
|
600
600
|
})
|
|
601
601
|
});
|
|
@@ -603,8 +603,8 @@ var supercompat = function(param) {
|
|
|
603
603
|
return new OpenAI({
|
|
604
604
|
apiKey: "SUPERCOMPAT_PLACEHOLDER_OPENAI_KEY",
|
|
605
605
|
fetch: supercompatFetch({
|
|
606
|
-
|
|
607
|
-
|
|
606
|
+
clientAdapter: clientAdapter,
|
|
607
|
+
storageAdapter: storageAdapter,
|
|
608
608
|
runAdapter: runAdapter
|
|
609
609
|
})
|
|
610
610
|
});
|
|
@@ -27961,10 +27961,10 @@ var azureResponsesStorageAdapter = function() {
|
|
|
27961
27961
|
var createResponseItems = [];
|
|
27962
27962
|
var cachedClient = null;
|
|
27963
27963
|
return function(param) {
|
|
27964
|
-
var runAdapter = param.runAdapter, client = param.client,
|
|
27964
|
+
var runAdapter = param.runAdapter, client = param.client, originalClientAdapter = param.originalClientAdapter;
|
|
27965
27965
|
var getAIProjectClient = function() {
|
|
27966
|
-
if (
|
|
27967
|
-
return
|
|
27966
|
+
if (originalClientAdapter && (typeof originalClientAdapter === "undefined" ? "undefined" : _type_of(originalClientAdapter)) === "object" && "client" in originalClientAdapter) {
|
|
27967
|
+
return originalClientAdapter.client;
|
|
27968
27968
|
}
|
|
27969
27969
|
return client;
|
|
27970
27970
|
};
|