@alvin0/ai-agent-sdk-provider-openai 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 alvin0 (chaulamdinhai) <chaulamdinhai@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @alvin0/ai-agent-sdk-provider-openai
2
+
3
+ Runtime: **Universal** (Edge/Worker, browser, Deno, Bun, and Node).
4
+
5
+ ```sh
6
+ pnpm add @alvin0/ai-agent-sdk-core @alvin0/ai-agent-sdk-provider-openai
7
+ ```
8
+
9
+ Universal OpenAI adapter and transactional provider plugin. Credentials are injected; this package never reads environment variables or files.
10
+
11
+ ```ts
12
+ import { ModelRegistry } from '@alvin0/ai-agent-sdk-core'
13
+ import { openAiPlugin } from '@alvin0/ai-agent-sdk-provider-openai'
14
+
15
+ const registry = new ModelRegistry()
16
+ registry.install(openAiPlugin({ apiKey: () => secretStore.get('openai') }))
17
+ ```
18
+
19
+ Use `openAiAdapter()` for manual route registration. Both APIs are Universal and
20
+ require an explicit `apiKey`; environment lookup belongs to a Node wrapper.
21
+
22
+ Both accept `models: [{ id, contextWindow, maxTokens }]` plus provider-level
23
+ `defaultContextWindow` and `defaultMaxTokens` fallbacks. Currently a catalog
24
+ model's `maxTokens` is both its default output budget and its SDK output ceiling;
25
+ set a lower `maxTokens` on the agent to request less output. See the
26
+ [provider model limits guide](../../web-documents/en/09-providers/index.md) for an example
27
+ and precedence rules. These declarations do not increase server-side limits.
28
+
29
+ Composition: `runtime.providers`. Lifecycle: `inert-runtime-owned-registration`;
30
+ the runtime activates and removes the captured provider registration.
@@ -0,0 +1,77 @@
1
+ import { ComposableModelProviderPlugin, CredentialInput, ModelTarget } from "@alvin0/ai-agent-sdk-core/provider";
2
+ import { CredentialSource, HttpModelAdapter, ProviderCatalogModel, ProviderRequestLogger } from "@alvin0/ai-agent-sdk-provider-http";
3
+ import { ResponsesDialect, openAiResponsesProtocol } from "@alvin0/ai-agent-sdk-protocol-responses";
4
+ import { ModelProviderPlugin, RetryPolicyConfig } from "@alvin0/ai-agent-sdk-core";
5
+ //#region src/adapter.d.ts
6
+ /** The OpenAI API base. */
7
+ declare const OPENAI_BASE_URL = "https://api.openai.com/v1";
8
+ /** How the API key is obtained. */
9
+ type OpenAiCredential = CredentialSource;
10
+ /** Options for {@link openAiAdapter}. */
11
+ interface OpenAiAdapterOptions {
12
+ /** Injected API key or resolver. Universal packages never read environment variables. */
13
+ apiKey: OpenAiCredential;
14
+ /**
15
+ * Endpoint base; defaults to {@link OPENAI_BASE_URL}.
16
+ *
17
+ * Point this at a compatible gateway to reuse this provider wholesale.
18
+ */
19
+ baseUrl?: string;
20
+ /** Organization to bill, when the key belongs to several. */
21
+ organization?: string;
22
+ /** Project to attribute usage to. */
23
+ project?: string;
24
+ /**
25
+ * Advisory model catalog.
26
+ *
27
+ * Empty by default: this package cannot know which model ids are current, and a
28
+ * stale built-in list would name retired models. Supply entries to declare
29
+ * capabilities the SDK cannot infer, such as image support.
30
+ */
31
+ models?: readonly ProviderCatalogModel[];
32
+ /** Whether the provider may retain responses server-side. Defaults to false. */
33
+ store?: boolean;
34
+ /** Output cap when neither caller nor catalog names one. */
35
+ defaultMaxTokens?: number;
36
+ /** Context capacity assumed for an uncatalogued model. */
37
+ defaultContextWindow?: number;
38
+ /** Idle bound while a stream read is outstanding. */
39
+ streamIdleTimeoutMs?: number;
40
+ requestTimeoutMs?: number;
41
+ maxRequestBytes?: number;
42
+ maxResponseBytes?: number;
43
+ maxResponseChunks?: number;
44
+ maxSseEvents?: number;
45
+ maxSseEventChars?: number;
46
+ maxErrorBodyBytes?: number;
47
+ requestLoggerTimeoutMs?: number;
48
+ /** Retry policy this route owns. */
49
+ retryPolicy?: RetryPolicyConfig;
50
+ /** Optional exact wire-request logger; credentials are redacted. */
51
+ requestLogger?: ProviderRequestLogger;
52
+ fetch?: typeof globalThis.fetch;
53
+ }
54
+ /**
55
+ * Create an OpenAI adapter.
56
+ * @param options - credential, endpoint, and catalog overrides.
57
+ * @returns the adapter, ready to register.
58
+ */
59
+ declare function openAiAdapter(options: OpenAiAdapterOptions): HttpModelAdapter;
60
+ interface OpenAiPluginOptions extends OpenAiAdapterOptions {
61
+ /** Registry routes installed by the plugin. Defaults to `['openai']`. */
62
+ readonly routes?: readonly string[];
63
+ }
64
+ interface OpenAiProviderOptions extends Omit<OpenAiAdapterOptions, 'apiKey'> {
65
+ readonly defaultModel?: string | ModelTarget;
66
+ readonly apiKey: CredentialInput;
67
+ readonly id?: string;
68
+ readonly routes?: readonly string[];
69
+ }
70
+ /** Preferred transactional plugin for installing the OpenAI provider. */
71
+ declare function openAiPlugin(options: OpenAiProviderOptions): ComposableModelProviderPlugin & {
72
+ readonly family: 'openai';
73
+ };
74
+ declare function openAiPlugin(options: OpenAiPluginOptions): ModelProviderPlugin;
75
+ //#endregion
76
+ export { OPENAI_BASE_URL, type OpenAiAdapterOptions, type OpenAiCredential, type OpenAiPluginOptions, type OpenAiProviderOptions, type ResponsesDialect, openAiAdapter, openAiPlugin, openAiResponsesProtocol };
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/adapter.ts"],"mappings":";;;;;;cAkCa;;KAGD,mBAAmB;;UAGd;;EAEf,QAAQ;;;;;;EAMR;;EAEA;;EAEA;;;;;;;;EAQA,kBAAkB;;EAElB;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,cAAc;;EAEd,gBAAgB;EAChB,eAAe,WAAW;;;;;;;iBAQZ,cAAc,SAAS,uBAAuB;UAiC7C,4BAA4B;;WAElC;;UAGM,8BAA8B,KAAK;WACzC,wBAAwB;WACxB,QAAQ;WACR;WACA;;;iBAIK,aACd,SAAS,wBACR;WAA2C;;iBAC9B,aAAa,SAAS,sBAAsB"}
package/dist/index.js ADDED
@@ -0,0 +1,122 @@
1
+ import { defineModelProviderPlugin } from "@alvin0/ai-agent-sdk-core/provider";
2
+ import { createHttpProvider, createRuntimeHttpProvider } from "@alvin0/ai-agent-sdk-provider-http";
3
+ import { openAiResponsesProtocol, openAiResponsesProtocol as openAiResponsesProtocol$1 } from "@alvin0/ai-agent-sdk-protocol-responses";
4
+
5
+ //#region src/adapter.ts
6
+ /** The OpenAI API base. */
7
+ const OPENAI_BASE_URL = "https://api.openai.com/v1";
8
+ /**
9
+ * Create an OpenAI adapter.
10
+ * @param options - credential, endpoint, and catalog overrides.
11
+ * @returns the adapter, ready to register.
12
+ */
13
+ function openAiAdapter(options) {
14
+ const dialect = options.store === void 0 ? {} : { store: options.store };
15
+ return createHttpProvider({
16
+ displayName: "OpenAI",
17
+ protocol: openAiResponsesProtocol$1,
18
+ baseUrl: options.baseUrl ?? "https://api.openai.com/v1",
19
+ auth: {
20
+ kind: "bearer",
21
+ token: options.apiKey,
22
+ label: "the `apiKey` option"
23
+ },
24
+ dialect,
25
+ headers: {
26
+ ...options.organization === void 0 ? {} : { "openai-organization": options.organization },
27
+ ...options.project === void 0 ? {} : { "openai-project": options.project }
28
+ },
29
+ ...options.models === void 0 ? {} : { models: options.models },
30
+ defaultMaxTokens: options.defaultMaxTokens ?? 32e3,
31
+ defaultContextWindow: options.defaultContextWindow ?? 128e3,
32
+ ...options.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: options.streamIdleTimeoutMs },
33
+ ...transportLimits(options),
34
+ ...options.retryPolicy === void 0 ? {} : { retryPolicy: options.retryPolicy },
35
+ ...options.requestLogger === void 0 ? {} : { requestLogger: options.requestLogger }
36
+ });
37
+ }
38
+ function openAiPlugin(options) {
39
+ if (!usesRuntimeComposition(options)) return legacyOpenAiPlugin(options);
40
+ const id = options.id ?? "openai";
41
+ const routes = Object.freeze([...options.routes ?? [id]]);
42
+ return defineModelProviderPlugin({
43
+ id,
44
+ family: "openai",
45
+ displayName: "OpenAI",
46
+ routes,
47
+ ...runtimeDefaultModel(options.defaultModel, routes),
48
+ setup(registrar) {
49
+ const adapter = createRuntimeOpenAiAdapter(options);
50
+ const remove = registrar.registerAdapter(adapter);
51
+ return () => {
52
+ remove();
53
+ };
54
+ }
55
+ });
56
+ }
57
+ function legacyOpenAiPlugin(options) {
58
+ const routes = Object.freeze([...options.routes ?? ["openai"]]);
59
+ const adapter = openAiAdapter(options);
60
+ return Object.freeze({
61
+ id: "openai",
62
+ displayName: "OpenAI",
63
+ setup(registrar) {
64
+ registrar.registerAdapter(routes, adapter);
65
+ }
66
+ });
67
+ }
68
+ function createRuntimeOpenAiAdapter(options) {
69
+ return createRuntimeHttpProvider({
70
+ displayName: "OpenAI",
71
+ protocol: openAiResponsesProtocol$1,
72
+ baseUrl: options.baseUrl ?? "https://api.openai.com/v1",
73
+ auth: {
74
+ kind: "bearer",
75
+ token: options.apiKey,
76
+ label: "the `apiKey` option"
77
+ },
78
+ dialect: options.store === void 0 ? {} : { store: options.store },
79
+ headers: {
80
+ ...options.organization === void 0 ? {} : { "openai-organization": options.organization },
81
+ ...options.project === void 0 ? {} : { "openai-project": options.project }
82
+ },
83
+ ...options.models === void 0 ? {} : { models: options.models },
84
+ defaultMaxTokens: options.defaultMaxTokens ?? 32e3,
85
+ defaultContextWindow: options.defaultContextWindow ?? 128e3,
86
+ ...options.streamIdleTimeoutMs === void 0 ? {} : { streamIdleTimeoutMs: options.streamIdleTimeoutMs },
87
+ ...transportLimits(options),
88
+ ...options.retryPolicy === void 0 ? {} : { retryPolicy: options.retryPolicy },
89
+ ...options.requestLogger === void 0 ? {} : { requestLogger: options.requestLogger }
90
+ });
91
+ }
92
+ function usesRuntimeComposition(options) {
93
+ if ("id" in options || "defaultModel" in options) return true;
94
+ if (typeof options.apiKey === "object" && options.apiKey !== null) return true;
95
+ return typeof options.apiKey !== "function";
96
+ }
97
+ function runtimeDefaultModel(value, routes) {
98
+ if (value === void 0) return {};
99
+ if (typeof value !== "string") return { defaultModel: value };
100
+ if (routes.length !== 1) throw new TypeError("A string defaultModel requires exactly one OpenAI route");
101
+ return { defaultModel: Object.freeze({
102
+ provider: routes[0],
103
+ id: value
104
+ }) };
105
+ }
106
+ function transportLimits(options) {
107
+ return {
108
+ ...options.requestTimeoutMs === void 0 ? {} : { requestTimeoutMs: options.requestTimeoutMs },
109
+ ...options.maxRequestBytes === void 0 ? {} : { maxRequestBytes: options.maxRequestBytes },
110
+ ...options.maxResponseBytes === void 0 ? {} : { maxResponseBytes: options.maxResponseBytes },
111
+ ...options.maxResponseChunks === void 0 ? {} : { maxResponseChunks: options.maxResponseChunks },
112
+ ...options.maxSseEvents === void 0 ? {} : { maxSseEvents: options.maxSseEvents },
113
+ ...options.maxSseEventChars === void 0 ? {} : { maxSseEventChars: options.maxSseEventChars },
114
+ ...options.maxErrorBodyBytes === void 0 ? {} : { maxErrorBodyBytes: options.maxErrorBodyBytes },
115
+ ...options.requestLoggerTimeoutMs === void 0 ? {} : { requestLoggerTimeoutMs: options.requestLoggerTimeoutMs },
116
+ ...options.fetch === void 0 ? {} : { fetch: options.fetch }
117
+ };
118
+ }
119
+
120
+ //#endregion
121
+ export { OPENAI_BASE_URL, openAiAdapter, openAiPlugin, openAiResponsesProtocol };
122
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["openAiResponsesProtocol"],"sources":["../src/adapter.ts"],"sourcesContent":["/**\n * The OpenAI provider: the Responses API on `api.openai.com`.\n *\n * Note how little there is here. Every endpoint fact is configuration handed to\n * {@link createHttpProvider}; the protocol, the pipeline, and the error mapping are\n * all shared. That is the intended shape for any endpoint speaking a protocol this\n * package already implements — including your own gateway.\n *\n * @module ai-agent-sdk/providers/openai/adapter\n */\n\nimport type { ModelProviderPlugin, ModelProviderRegistrar, RetryPolicyConfig } from '@alvin0/ai-agent-sdk-core'\nimport {\n defineModelProviderPlugin,\n type ComposableModelProviderPlugin,\n type CredentialInput,\n type ModelTarget,\n} from '@alvin0/ai-agent-sdk-core/provider'\nimport type {\n HttpModelAdapter,\n ProviderCatalogModel,\n ProviderRequestLogger,\n} from '@alvin0/ai-agent-sdk-provider-http'\nimport {\n createHttpProvider,\n createRuntimeHttpProvider,\n type CredentialSource,\n} from '@alvin0/ai-agent-sdk-provider-http'\nimport {\n openAiResponsesProtocol,\n type ResponsesDialect,\n} from '@alvin0/ai-agent-sdk-protocol-responses'\n\n/** The OpenAI API base. */\nexport const OPENAI_BASE_URL = 'https://api.openai.com/v1'\n\n/** How the API key is obtained. */\nexport type OpenAiCredential = CredentialSource\n\n/** Options for {@link openAiAdapter}. */\nexport interface OpenAiAdapterOptions {\n /** Injected API key or resolver. Universal packages never read environment variables. */\n apiKey: OpenAiCredential\n /**\n * Endpoint base; defaults to {@link OPENAI_BASE_URL}.\n *\n * Point this at a compatible gateway to reuse this provider wholesale.\n */\n baseUrl?: string\n /** Organization to bill, when the key belongs to several. */\n organization?: string\n /** Project to attribute usage to. */\n project?: string\n /**\n * Advisory model catalog.\n *\n * Empty by default: this package cannot know which model ids are current, and a\n * stale built-in list would name retired models. Supply entries to declare\n * capabilities the SDK cannot infer, such as image support.\n */\n models?: readonly ProviderCatalogModel[]\n /** Whether the provider may retain responses server-side. Defaults to false. */\n store?: boolean\n /** Output cap when neither caller nor catalog names one. */\n defaultMaxTokens?: number\n /** Context capacity assumed for an uncatalogued model. */\n defaultContextWindow?: number\n /** Idle bound while a stream read is outstanding. */\n streamIdleTimeoutMs?: number\n requestTimeoutMs?: number\n maxRequestBytes?: number\n maxResponseBytes?: number\n maxResponseChunks?: number\n maxSseEvents?: number\n maxSseEventChars?: number\n maxErrorBodyBytes?: number\n requestLoggerTimeoutMs?: number\n /** Retry policy this route owns. */\n retryPolicy?: RetryPolicyConfig\n /** Optional exact wire-request logger; credentials are redacted. */\n requestLogger?: ProviderRequestLogger\n fetch?: typeof globalThis.fetch\n}\n\n/**\n * Create an OpenAI adapter.\n * @param options - credential, endpoint, and catalog overrides.\n * @returns the adapter, ready to register.\n */\nexport function openAiAdapter(options: OpenAiAdapterOptions): HttpModelAdapter {\n const dialect: Partial<ResponsesDialect> = options.store === undefined\n ? {}\n : { store: options.store }\n\n return createHttpProvider({\n displayName: 'OpenAI',\n protocol: openAiResponsesProtocol,\n baseUrl: options.baseUrl ?? OPENAI_BASE_URL,\n auth: {\n kind: 'bearer',\n token: options.apiKey,\n label: 'the `apiKey` option',\n },\n dialect,\n headers: {\n ...options.organization === undefined\n ? {}\n : { 'openai-organization': options.organization },\n ...options.project === undefined ? {} : { 'openai-project': options.project },\n },\n ...options.models === undefined ? {} : { models: options.models },\n defaultMaxTokens: options.defaultMaxTokens ?? 32_000,\n defaultContextWindow: options.defaultContextWindow ?? 128_000,\n ...options.streamIdleTimeoutMs === undefined\n ? {}\n : { streamIdleTimeoutMs: options.streamIdleTimeoutMs },\n ...transportLimits(options),\n ...options.retryPolicy === undefined ? {} : { retryPolicy: options.retryPolicy },\n ...options.requestLogger === undefined ? {} : { requestLogger: options.requestLogger },\n })\n}\n\nexport interface OpenAiPluginOptions extends OpenAiAdapterOptions {\n /** Registry routes installed by the plugin. Defaults to `['openai']`. */\n readonly routes?: readonly string[]\n}\n\nexport interface OpenAiProviderOptions extends Omit<OpenAiAdapterOptions, 'apiKey'> {\n readonly defaultModel?: string | ModelTarget\n readonly apiKey: CredentialInput\n readonly id?: string\n readonly routes?: readonly string[]\n}\n\n/** Preferred transactional plugin for installing the OpenAI provider. */\nexport function openAiPlugin(\n options: OpenAiProviderOptions,\n): ComposableModelProviderPlugin & { readonly family: 'openai' }\nexport function openAiPlugin(options: OpenAiPluginOptions): ModelProviderPlugin\nexport function openAiPlugin(\n options: OpenAiProviderOptions | OpenAiPluginOptions,\n): ModelProviderPlugin | (ComposableModelProviderPlugin & { readonly family: 'openai' }) {\n if (!usesRuntimeComposition(options)) return legacyOpenAiPlugin(options)\n const id = options.id ?? 'openai'\n const routes = Object.freeze([...(options.routes ?? [id])])\n return defineModelProviderPlugin({\n id,\n family: 'openai',\n displayName: 'OpenAI',\n routes,\n ...runtimeDefaultModel(options.defaultModel, routes),\n setup(registrar) {\n const adapter = createRuntimeOpenAiAdapter(options)\n const remove = registrar.registerAdapter(adapter)\n return () => { remove(); return undefined }\n },\n }) as ComposableModelProviderPlugin & { readonly family: 'openai' }\n}\n\nfunction legacyOpenAiPlugin(options: OpenAiPluginOptions): ModelProviderPlugin {\n const routes = Object.freeze([...(options.routes ?? ['openai'])])\n const adapter = openAiAdapter(options)\n return Object.freeze({\n id: 'openai',\n displayName: 'OpenAI',\n setup(registrar: ModelProviderRegistrar) {\n registrar.registerAdapter(routes, adapter)\n },\n })\n}\n\nfunction createRuntimeOpenAiAdapter(options: OpenAiProviderOptions): HttpModelAdapter {\n return createRuntimeHttpProvider({\n displayName: 'OpenAI',\n protocol: openAiResponsesProtocol,\n baseUrl: options.baseUrl ?? OPENAI_BASE_URL,\n auth: { kind: 'bearer', token: options.apiKey, label: 'the `apiKey` option' },\n dialect: options.store === undefined ? {} : { store: options.store },\n headers: {\n ...(options.organization === undefined ? {} : { 'openai-organization': options.organization }),\n ...(options.project === undefined ? {} : { 'openai-project': options.project }),\n },\n ...(options.models === undefined ? {} : { models: options.models }),\n defaultMaxTokens: options.defaultMaxTokens ?? 32_000,\n defaultContextWindow: options.defaultContextWindow ?? 128_000,\n ...(options.streamIdleTimeoutMs === undefined ? {} : { streamIdleTimeoutMs: options.streamIdleTimeoutMs }),\n ...transportLimits(options),\n ...(options.retryPolicy === undefined ? {} : { retryPolicy: options.retryPolicy }),\n ...(options.requestLogger === undefined ? {} : { requestLogger: options.requestLogger }),\n })\n}\n\nfunction usesRuntimeComposition(\n options: OpenAiProviderOptions | OpenAiPluginOptions,\n): options is OpenAiProviderOptions {\n if ('id' in options || 'defaultModel' in options) return true\n if (typeof options.apiKey === 'object' && options.apiKey !== null) return true\n return typeof options.apiKey !== 'function'\n}\n\nfunction runtimeDefaultModel(\n value: string | ModelTarget | undefined,\n routes: readonly string[],\n): { readonly defaultModel?: ModelTarget } {\n if (value === undefined) return {}\n if (typeof value !== 'string') return { defaultModel: value }\n if (routes.length !== 1) {\n throw new TypeError('A string defaultModel requires exactly one OpenAI route')\n }\n return { defaultModel: Object.freeze({ provider: routes[0]!, id: value }) }\n}\n\nfunction transportLimits(options: OpenAiAdapterOptions | OpenAiProviderOptions) {\n return {\n ...options.requestTimeoutMs === undefined ? {} : { requestTimeoutMs: options.requestTimeoutMs },\n ...options.maxRequestBytes === undefined ? {} : { maxRequestBytes: options.maxRequestBytes },\n ...options.maxResponseBytes === undefined ? {} : { maxResponseBytes: options.maxResponseBytes },\n ...options.maxResponseChunks === undefined ? {} : { maxResponseChunks: options.maxResponseChunks },\n ...options.maxSseEvents === undefined ? {} : { maxSseEvents: options.maxSseEvents },\n ...options.maxSseEventChars === undefined ? {} : { maxSseEventChars: options.maxSseEventChars },\n ...options.maxErrorBodyBytes === undefined ? {} : { maxErrorBodyBytes: options.maxErrorBodyBytes },\n ...options.requestLoggerTimeoutMs === undefined ? {} : { requestLoggerTimeoutMs: options.requestLoggerTimeoutMs },\n ...options.fetch === undefined ? {} : { fetch: options.fetch },\n }\n}\n"],"mappings":";;;;;;AAkCA,MAAa,kBAAkB;;;;;;AAuD/B,SAAgB,cAAc,SAAiD;CAC7E,MAAM,UAAqC,QAAQ,UAAU,SACzD,CAAC,IACD,EAAE,OAAO,QAAQ,MAAM;CAE3B,OAAO,mBAAmB;EACxB,aAAa;EACb,UAAUA;EACV,SAAS,QAAQ;EACjB,MAAM;GACJ,MAAM;GACN,OAAO,QAAQ;GACf,OAAO;EACT;EACA;EACA,SAAS;GACP,GAAG,QAAQ,iBAAiB,SACxB,CAAC,IACD,EAAE,uBAAuB,QAAQ,aAAa;GAClD,GAAG,QAAQ,YAAY,SAAY,CAAC,IAAI,EAAE,kBAAkB,QAAQ,QAAQ;EAC9E;EACA,GAAG,QAAQ,WAAW,SAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;EAChE,kBAAkB,QAAQ,oBAAoB;EAC9C,sBAAsB,QAAQ,wBAAwB;EACtD,GAAG,QAAQ,wBAAwB,SAC/B,CAAC,IACD,EAAE,qBAAqB,QAAQ,oBAAoB;EACvD,GAAG,gBAAgB,OAAO;EAC1B,GAAG,QAAQ,gBAAgB,SAAY,CAAC,IAAI,EAAE,aAAa,QAAQ,YAAY;EAC/E,GAAG,QAAQ,kBAAkB,SAAY,CAAC,IAAI,EAAE,eAAe,QAAQ,cAAc;CACvF,CAAC;AACH;AAmBA,SAAgB,aACd,SACuF;CACvF,IAAI,CAAC,uBAAuB,OAAO,GAAG,OAAO,mBAAmB,OAAO;CACvE,MAAM,KAAK,QAAQ,MAAM;CACzB,MAAM,SAAS,OAAO,OAAO,CAAC,GAAI,QAAQ,UAAU,CAAC,EAAE,CAAE,CAAC;CAC1D,OAAO,0BAA0B;EAC/B;EACA,Q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@alvin0/ai-agent-sdk-provider-openai",
3
+ "author": {
4
+ "name": "alvin0 - chaulamdinhai",
5
+ "email": "chaulamdinhai@gmail.com"
6
+ },
7
+ "version": "0.1.0",
8
+ "description": "Universal OpenAI adapter and provider plugin for ai-agent-sdk",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/alvin0/ai-agent-sdk.git",
13
+ "directory": "packages/provider-openai"
14
+ },
15
+ "homepage": "https://github.com/alvin0/ai-agent-sdk/tree/main/packages/provider-openai#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/alvin0/ai-agent-sdk/issues"
18
+ },
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "provenance": true
39
+ },
40
+ "dependencies": {
41
+ "@alvin0/ai-agent-sdk-provider-http": "^0.1.0",
42
+ "@alvin0/ai-agent-sdk-protocol-responses": "^0.1.0"
43
+ },
44
+ "peerDependencies": {
45
+ "@alvin0/ai-agent-sdk-core": "^0.1.0"
46
+ },
47
+ "devDependencies": {
48
+ "@alvin0/ai-agent-sdk-core": "^0.1.0",
49
+ "@alvin0/ai-agent-sdk-testkit": "^0.1.0",
50
+ "@arethetypeswrong/cli": "0.18.5",
51
+ "playwright": "1.62.1",
52
+ "publint": "0.3.24",
53
+ "tsdown": "0.22.14",
54
+ "typescript": "7.0.2",
55
+ "vitest": "4.1.11",
56
+ "wrangler": "4.127.1"
57
+ },
58
+ "aiAgentSdk": {
59
+ "runtime": "universal",
60
+ "coreApi": 1,
61
+ "roles": [
62
+ "model-provider"
63
+ ]
64
+ },
65
+ "scripts": {
66
+ "build": "tsdown",
67
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true});require('node:fs').rmSync('artifacts',{recursive:true,force:true})\"",
68
+ "typecheck": "tsc --noEmit",
69
+ "test": "vitest run --config vitest.config.ts",
70
+ "pack": "pnpm pack --pack-destination artifacts",
71
+ "test:pack": "node ../../scripts/test-packed-provider.mts provider-openai",
72
+ "check:publint": "publint",
73
+ "check:types": "attw --profile esm-only --pack ."
74
+ }
75
+ }