@robota-sdk/agent-provider-openai 3.0.0-beta.63 → 3.0.0-beta.82
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 +661 -21
- package/dist/node/index.cjs +1 -2
- package/dist/node/index.d.cts +271 -267
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.d.ts +271 -267
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +2 -2
- package/dist/node/index.js.map +1 -0
- package/dist/node/loggers/index.cjs +1 -0
- package/dist/node/loggers/index.d.cts +94 -0
- package/dist/node/loggers/index.d.cts.map +1 -0
- package/dist/node/loggers/index.d.ts +94 -0
- package/dist/node/loggers/index.d.ts.map +1 -0
- package/dist/node/loggers/index.js +2 -0
- package/dist/node/loggers/index.js.map +1 -0
- package/dist/node/payload-logger-BaW0K8yI.d.cts +61 -0
- package/dist/node/payload-logger-BaW0K8yI.d.cts.map +1 -0
- package/dist/node/payload-logger-BaW0K8yI.d.ts +61 -0
- package/dist/node/payload-logger-BaW0K8yI.d.ts.map +1 -0
- package/dist/node/rolldown-runtime-CMqjfN_6.cjs +1 -0
- package/package.json +69 -86
- package/src/index.ts +1 -0
- package/src/openai/__tests__/endpoint-provenance.test.ts +44 -0
- package/src/openai/__tests__/provider-errors.test.ts +114 -0
- package/src/openai/__tests__/request-format.test.ts +59 -0
- package/src/openai/__tests__/strict-tools-closure.test.ts +136 -0
- package/src/openai/__tests__/tool-schema-projection.test.ts +302 -0
- package/src/openai/__tests__/trace-context-wire.test.ts +114 -0
- package/src/openai/adapter.test.ts +494 -0
- package/src/openai/adapter.ts +145 -0
- package/src/openai/chat-completions-chat.ts +225 -0
- package/src/openai/executor-integration.test.ts +213 -0
- package/src/openai/index.ts +19 -0
- package/src/openai/interfaces/payload-logger.ts +48 -0
- package/src/openai/loggers/console-payload-logger.test.ts +173 -0
- package/src/openai/loggers/console-payload-logger.ts +96 -0
- package/src/openai/loggers/console.ts +9 -0
- package/src/openai/loggers/file-payload-logger.test.ts +243 -0
- package/src/openai/loggers/file-payload-logger.ts +124 -0
- package/src/openai/loggers/file.ts +9 -0
- package/src/openai/loggers/index.ts +12 -0
- package/src/openai/loggers/sanitize-openai-log-data.test.ts +89 -0
- package/src/openai/loggers/sanitize-openai-log-data.ts +14 -0
- package/src/openai/message-converter.ts +23 -0
- package/src/openai/model-effort-table.ts +19 -0
- package/src/openai/model-effort-verification-config.test.ts +45 -0
- package/src/openai/model-effort-verification-config.ts +35 -0
- package/src/openai/openai-request-format.ts +116 -0
- package/src/openai/parsers/response-parser.test.ts +407 -0
- package/src/openai/parsers/response-parser.ts +48 -0
- package/src/openai/provider-definition.test.ts +74 -0
- package/src/openai/provider-definition.ts +139 -0
- package/src/openai/provider.test.ts +1686 -0
- package/src/openai/provider.ts +392 -0
- package/src/openai/reasoning-effort.test.ts +272 -0
- package/src/openai/reasoning-effort.ts +49 -0
- package/src/openai/request-id.ts +39 -0
- package/src/openai/request-options.ts +14 -0
- package/src/openai/responses-chat.ts +285 -0
- package/src/openai/responses-converter.ts +122 -0
- package/src/openai/responses-parser.ts +297 -0
- package/src/openai/responses-stream-utils.ts +45 -0
- package/src/openai/responses-types.ts +193 -0
- package/src/openai/streaming/stream-assembler.ts +3 -0
- package/src/openai/types/api-types.ts +113 -0
- package/src/openai/types.ts +235 -0
- package/CHANGELOG.md +0 -614
- package/README.md +0 -467
- package/dist/browser/index.d.ts +0 -307
- package/dist/browser/index.js +0 -2
package/dist/node/index.d.cts
CHANGED
|
@@ -1,216 +1,204 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Payload logging data structure
|
|
6
|
-
*/
|
|
7
|
-
interface IOpenAILogData {
|
|
8
|
-
model: string;
|
|
9
|
-
messagesCount: number;
|
|
10
|
-
hasTools: boolean;
|
|
11
|
-
temperature?: number | undefined;
|
|
12
|
-
maxTokens?: number | undefined;
|
|
13
|
-
timestamp: string;
|
|
14
|
-
requestId?: string | undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* IPayloadLogger interface for logging OpenAI API payloads
|
|
19
|
-
*
|
|
20
|
-
* This interface provides a contract for different logging implementations:
|
|
21
|
-
* - FilePayloadLogger: Node.js file-based logging
|
|
22
|
-
* - ConsolePayloadLogger: Browser console-based logging
|
|
23
|
-
* - Custom implementations: User-defined loggers
|
|
24
|
-
*/
|
|
25
|
-
interface IPayloadLogger {
|
|
26
|
-
/**
|
|
27
|
-
* Check if logging is enabled
|
|
28
|
-
* @returns true if logging is active, false otherwise
|
|
29
|
-
*/
|
|
30
|
-
isEnabled(): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Log API payload data
|
|
33
|
-
* @param payload - The API request/response payload data
|
|
34
|
-
* @param type - Type of operation ('chat' or 'stream')
|
|
35
|
-
*/
|
|
36
|
-
logPayload(payload: IOpenAILogData, type: 'chat' | 'stream'): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Configuration options for payload loggers
|
|
40
|
-
*/
|
|
41
|
-
interface IPayloadLoggerOptions {
|
|
42
|
-
/**
|
|
43
|
-
* Whether logging is enabled
|
|
44
|
-
* @defaultValue true
|
|
45
|
-
*/
|
|
46
|
-
enabled?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Include timestamp in log entries
|
|
49
|
-
* @defaultValue true
|
|
50
|
-
*/
|
|
51
|
-
includeTimestamp?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Logger instance for console output
|
|
54
|
-
* @defaultValue SilentLogger
|
|
55
|
-
*/
|
|
56
|
-
logger?: ILogger;
|
|
57
|
-
}
|
|
58
|
-
|
|
1
|
+
import { n as IPayloadLoggerOptions, t as IPayloadLogger } from "./payload-logger-BaW0K8yI.cjs";
|
|
2
|
+
import { AbstractAIProvider, IChatOptions, IExecutor, ILogger, IProviderCapabilities, IProviderDefinition, IProviderModelEffortTable, IToolSchemaProjectionProfile, TProviderOptionValueBase, TTextDeltaCallback, TUniversalMessage } from "@robota-sdk/agent-core";
|
|
3
|
+
import OpenAI from "openai";
|
|
4
|
+
//#region src/openai/types.d.ts
|
|
59
5
|
type TOpenAIApiSurface = 'responses' | 'chat-completions';
|
|
60
6
|
interface IOpenAIJsonSchemaDefinition {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
schema?: Record<string, TOpenAIProviderOptionValue>;
|
|
10
|
+
strict?: boolean;
|
|
65
11
|
}
|
|
66
12
|
interface IOpenAIResponsesReasoningOptions {
|
|
67
|
-
|
|
68
|
-
|
|
13
|
+
effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
14
|
+
summary?: 'auto' | 'concise' | 'detailed';
|
|
69
15
|
}
|
|
70
16
|
interface IOpenAINativeWebToolsOptions {
|
|
71
|
-
|
|
72
|
-
|
|
17
|
+
webSearch?: boolean;
|
|
18
|
+
webFetch?: boolean;
|
|
73
19
|
}
|
|
74
20
|
/**
|
|
75
21
|
* Valid provider option value types
|
|
76
22
|
*/
|
|
77
23
|
type TOpenAIProviderOptionValue = string | number | boolean | undefined | null | IOpenAIJsonSchemaDefinition | IOpenAINativeWebToolsOptions | IOpenAIResponsesReasoningOptions | OpenAI | IPayloadLogger | ILogger | IExecutor | TProviderOptionValueBase | TOpenAIProviderOptionValue[] | {
|
|
78
|
-
|
|
24
|
+
[key: string]: TOpenAIProviderOptionValue;
|
|
79
25
|
};
|
|
80
26
|
/**
|
|
81
27
|
* OpenAI provider options
|
|
82
28
|
*/
|
|
83
29
|
interface IOpenAIProviderOptions {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Additional provider-specific options
|
|
32
|
+
*/
|
|
33
|
+
[key: string]: TOpenAIProviderOptionValue;
|
|
34
|
+
/**
|
|
35
|
+
* OpenAI API key (required when client is not provided)
|
|
36
|
+
*/
|
|
37
|
+
apiKey?: string;
|
|
38
|
+
/**
|
|
39
|
+
* OpenAI organization ID (optional)
|
|
40
|
+
*/
|
|
41
|
+
organization?: string;
|
|
42
|
+
/**
|
|
43
|
+
* API request timeout (milliseconds)
|
|
44
|
+
*/
|
|
45
|
+
timeout?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Whether to request token usage on streaming turns via
|
|
48
|
+
* `stream_options: { include_usage: true }` (default `true`). Set `false` for
|
|
49
|
+
* OpenAI-compatible endpoints that reject `stream_options`; usage is then absent
|
|
50
|
+
* on streaming turns for this provider.
|
|
51
|
+
*/
|
|
52
|
+
includeStreamUsage?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* API base URL (default: `'https://api.openai.com/v1'`).
|
|
55
|
+
*
|
|
56
|
+
* Point this at ANY OpenAI-compatible endpoint — this provider is a protocol
|
|
57
|
+
* client, not an OpenAI-vendor lock:
|
|
58
|
+
*
|
|
59
|
+
* - AI gateways: Vercel AI Gateway, LiteLLM, OpenRouter, …
|
|
60
|
+
* - Hosted compatibles: Azure OpenAI, Groq, Together, …
|
|
61
|
+
* - Local/self-hosted: vLLM, Ollama, LM Studio, …
|
|
62
|
+
*
|
|
63
|
+
* Setting `baseURL` switches the default {@link apiSurface} to
|
|
64
|
+
* `'chat-completions'` for broad endpoint compatibility (official OpenAI calls
|
|
65
|
+
* default to the Responses API). Model slugs are passed through verbatim, so
|
|
66
|
+
* gateway-namespaced ids like `anthropic/claude-sonnet-4-5` or
|
|
67
|
+
* `meta-llama/llama-3.1-70b` work as `defaultModel`/`model` values — streaming
|
|
68
|
+
* and tool calling ride the same chat-completions protocol.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* // Vercel AI Gateway with a non-OpenAI model slug
|
|
73
|
+
* createOpenAIProvider({
|
|
74
|
+
* apiKey: process.env.AI_GATEWAY_API_KEY,
|
|
75
|
+
* baseURL: 'https://ai-gateway.vercel.sh/v1',
|
|
76
|
+
* defaultModel: 'anthropic/claude-sonnet-4-5',
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
baseURL?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Default model used when chat options do not provide a model.
|
|
83
|
+
*/
|
|
84
|
+
defaultModel?: string;
|
|
85
|
+
/**
|
|
86
|
+
* API surface to use for direct OpenAI calls.
|
|
87
|
+
*
|
|
88
|
+
* Defaults to Responses for official OpenAI calls. Profiles with baseURL use
|
|
89
|
+
* Chat Completions by default for OpenAI-compatible endpoint compatibility.
|
|
90
|
+
*/
|
|
91
|
+
apiSurface?: TOpenAIApiSurface;
|
|
92
|
+
/**
|
|
93
|
+
* Response format (default: 'text')
|
|
94
|
+
* - 'text': Plain text response
|
|
95
|
+
* - 'json_object': JSON object mode (requires system message)
|
|
96
|
+
* - 'json_schema': Structured Outputs with schema validation
|
|
97
|
+
*/
|
|
98
|
+
responseFormat?: 'text' | 'json_object' | 'json_schema';
|
|
99
|
+
/**
|
|
100
|
+
* JSON schema for structured outputs (required when responseFormat is 'json_schema')
|
|
101
|
+
*/
|
|
102
|
+
jsonSchema?: IOpenAIJsonSchemaDefinition;
|
|
103
|
+
/**
|
|
104
|
+
* Responses API reasoning controls. Hidden reasoning is never exposed in message
|
|
105
|
+
* content; only explicit summaries/encrypted items requested here are represented.
|
|
106
|
+
*/
|
|
107
|
+
reasoning?: IOpenAIResponsesReasoningOptions;
|
|
108
|
+
/**
|
|
109
|
+
* Whether OpenAI should store Responses API results. Defaults to OpenAI API behavior.
|
|
110
|
+
*/
|
|
111
|
+
store?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Include encrypted reasoning items for stateless reasoning continuation.
|
|
114
|
+
*/
|
|
115
|
+
includeEncryptedReasoning?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Opt into strict custom function parameter validation where supported.
|
|
118
|
+
*
|
|
119
|
+
* PROV-007: the tool schema is rewritten for strict mode on the way out — every object node,
|
|
120
|
+
* nested ones included, is closed and given a complete `required` list. That transformation is
|
|
121
|
+
* lossy, so it runs ONLY when this flag is on; with it off the schema is forwarded exactly as
|
|
122
|
+
* authored.
|
|
123
|
+
*
|
|
124
|
+
* What "lossy" means for a caller: strict mode has no way to say "optional", so a field the
|
|
125
|
+
* schema marked optional becomes required and gains a `null` branch. The model must then supply
|
|
126
|
+
* the key explicitly, with `null` standing for "not provided". A tool whose handler distinguishes
|
|
127
|
+
* an absent key from a null value will see the difference.
|
|
128
|
+
*/
|
|
129
|
+
strictTools?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Provider-native hosted web tool request from provider profile options.
|
|
132
|
+
*
|
|
133
|
+
* OpenAI-compatible Chat Completions endpoints do not support this Robota
|
|
134
|
+
* native web contract. The provider rejects unsupported configurations before
|
|
135
|
+
* any model request is sent.
|
|
136
|
+
*/
|
|
137
|
+
nativeWebTools?: IOpenAINativeWebToolsOptions;
|
|
138
|
+
/**
|
|
139
|
+
* OpenAI client instance (optional: will be created from apiKey if not provided)
|
|
140
|
+
*/
|
|
141
|
+
client?: OpenAI;
|
|
142
|
+
/**
|
|
143
|
+
* Payload logger instance for debugging API requests/responses
|
|
144
|
+
*
|
|
145
|
+
* Use different implementations based on your environment:
|
|
146
|
+
* - FilePayloadLogger: Node.js file-based logging
|
|
147
|
+
* - ConsolePayloadLogger: Browser console-based logging
|
|
148
|
+
* - Custom: Implement IPayloadLogger interface
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* // Node.js
|
|
153
|
+
* import { FilePayloadLogger } from '@robota-sdk/agent-provider-openai/loggers';
|
|
154
|
+
* const provider = new OpenAIProvider({
|
|
155
|
+
* client: openaiClient,
|
|
156
|
+
* payloadLogger: new FilePayloadLogger({ logDir: './logs/openai' })
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* // Browser
|
|
160
|
+
* import { ConsolePayloadLogger } from '@robota-sdk/agent-provider-openai/loggers';
|
|
161
|
+
* const provider = new OpenAIProvider({
|
|
162
|
+
* client: openaiClient,
|
|
163
|
+
* payloadLogger: new ConsolePayloadLogger()
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
payloadLogger?: IPayloadLogger;
|
|
168
|
+
/**
|
|
169
|
+
* Optional executor for handling AI requests
|
|
170
|
+
*
|
|
171
|
+
* When provided, the provider will delegate all chat operations to this executor
|
|
172
|
+
* instead of making direct API calls. This enables remote execution capabilities.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* import { LocalExecutor, RemoteExecutor } from '@robota-sdk/agent-core';
|
|
177
|
+
*
|
|
178
|
+
* // Local execution (registers this provider)
|
|
179
|
+
* const localExecutor = new LocalExecutor();
|
|
180
|
+
* localExecutor.registerProvider('openai', new OpenAIProvider({ apiKey: 'sk-...' }));
|
|
181
|
+
*
|
|
182
|
+
* // Remote execution
|
|
183
|
+
* const remoteExecutor = new RemoteExecutor({
|
|
184
|
+
* serverUrl: 'https://api.robota.io',
|
|
185
|
+
* userApiKey: 'user-token-123'
|
|
186
|
+
* });
|
|
187
|
+
*
|
|
188
|
+
* const provider = new OpenAIProvider({
|
|
189
|
+
* executor: remoteExecutor // No direct API key needed
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
executor?: IExecutor;
|
|
194
|
+
/**
|
|
195
|
+
* Logger instance for internal OpenAI provider logging
|
|
196
|
+
* @defaultValue SilentLogger
|
|
197
|
+
*/
|
|
198
|
+
logger?: ILogger;
|
|
212
199
|
}
|
|
213
|
-
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/openai/provider.d.ts
|
|
214
202
|
/**
|
|
215
203
|
* OpenAI provider implementation for Robota
|
|
216
204
|
*
|
|
@@ -220,30 +208,66 @@ interface IOpenAIProviderOptions {
|
|
|
220
208
|
* @public
|
|
221
209
|
*/
|
|
222
210
|
declare class OpenAIProvider extends AbstractAIProvider {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
211
|
+
readonly name = "openai";
|
|
212
|
+
readonly version = "1.0.0";
|
|
213
|
+
private readonly client?;
|
|
214
|
+
private readonly options;
|
|
215
|
+
private readonly apiSurface;
|
|
216
|
+
private readonly payloadLogger;
|
|
217
|
+
private readonly responseParser;
|
|
218
|
+
/**
|
|
219
|
+
* Optional callback for text deltas during streaming.
|
|
220
|
+
* Set by the consumer (e.g., Session) to receive real-time text chunks.
|
|
221
|
+
* When set, chat() uses streaming internally while still returning
|
|
222
|
+
* the complete assembled message.
|
|
223
|
+
*/
|
|
224
|
+
onTextDelta?: TTextDeltaCallback;
|
|
225
|
+
constructor(options: IOpenAIProviderOptions);
|
|
226
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
227
|
+
chatStream(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
228
|
+
private streamDirect;
|
|
229
|
+
/**
|
|
230
|
+
* CORE-043: this provider declares no capability table — nobody has verified one for OpenAI, and
|
|
231
|
+
* inventing one would be a fabricated claim. It can still answer THIS question honestly, which is
|
|
232
|
+
* why the endpoint signal is not a field on the table.
|
|
233
|
+
*
|
|
234
|
+
* It matters most here of all the providers: setting `baseURL` also switches the API surface to
|
|
235
|
+
* `chat-completions` (see `resolveApiSurface`), so the advertised gateway configuration is exactly
|
|
236
|
+
* the one where a structured request is least likely to be enforced by whatever is on the far end.
|
|
237
|
+
*/
|
|
238
|
+
endpointIsVendorDefault(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* The client's own base URL is the origin every request goes to (the SDK has already applied a
|
|
241
|
+
* constructor option or `OPENAI_BASE_URL`). An executor sends elsewhere, and an injected client
|
|
242
|
+
* whose base URL cannot be read gives no origin to compare, so neither can propagate.
|
|
243
|
+
*/
|
|
244
|
+
canPropagateTraceContext(): boolean;
|
|
245
|
+
private effectiveBaseUrl;
|
|
246
|
+
private traceRequestHeaders;
|
|
247
|
+
effortTable(): IProviderModelEffortTable | undefined;
|
|
248
|
+
private resolveEffortOptions;
|
|
249
|
+
/**
|
|
250
|
+
* MCP-005: strict mode's supported subset is documented; non-strict accepts standard JSON Schema.
|
|
251
|
+
* Both the Responses and Chat Completions surfaces honor `strictTools` identically (§ Profiles).
|
|
252
|
+
*/
|
|
253
|
+
protected projectionProfile(): IToolSchemaProjectionProfile | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Project `chatOptions.tools` through `projectionProfile()` before either request-building module
|
|
256
|
+
* (`responses-chat.ts`, `chat-completions-chat.ts`) sees them — the module helpers receive the
|
|
257
|
+
* projected array as a parameter; `options.tools` itself is never mutated. An empty projected array
|
|
258
|
+
* (every tool quarantined) becomes `undefined` so the downstream `tools &&` truthiness checks treat
|
|
259
|
+
* it the same as "no tools", not as a zero-length `tools: []` request field.
|
|
260
|
+
*/
|
|
261
|
+
private projectChatOptions;
|
|
262
|
+
private publishModelEffortOutcome;
|
|
263
|
+
supportsTools(): boolean;
|
|
264
|
+
getCapabilities(): IProviderCapabilities;
|
|
265
|
+
validateConfig(): boolean;
|
|
266
|
+
dispose(): Promise<void>;
|
|
267
|
+
protected validateMessages(messages: TUniversalMessage[]): void;
|
|
245
268
|
}
|
|
246
|
-
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/openai/adapter.d.ts
|
|
247
271
|
/**
|
|
248
272
|
* OpenAI Conversation Adapter
|
|
249
273
|
*
|
|
@@ -253,55 +277,35 @@ declare class OpenAIProvider extends AbstractAIProvider {
|
|
|
253
277
|
* @public
|
|
254
278
|
*/
|
|
255
279
|
declare class OpenAIConversationAdapter {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
interface IOpenAIModelCatalogResponse {
|
|
282
|
-
data?: readonly IOpenAIModelCatalogResource[];
|
|
283
|
-
}
|
|
284
|
-
interface IOpenAIModelCatalogResource {
|
|
285
|
-
id?: string;
|
|
286
|
-
}
|
|
287
|
-
interface IOpenAIModelCatalogFetchInit {
|
|
288
|
-
headers: Record<string, string>;
|
|
289
|
-
}
|
|
290
|
-
interface IOpenAIModelCatalogFetchResponse {
|
|
291
|
-
ok: boolean;
|
|
292
|
-
status: number;
|
|
293
|
-
statusText?: string;
|
|
294
|
-
json: () => Promise<IOpenAIModelCatalogResponse>;
|
|
295
|
-
}
|
|
296
|
-
type TOpenAIModelCatalogFetch = (url: string, init: IOpenAIModelCatalogFetchInit) => Promise<IOpenAIModelCatalogFetchResponse>;
|
|
297
|
-
interface IRefreshOpenAIModelCatalogOptions {
|
|
298
|
-
fetcher?: TOpenAIModelCatalogFetch;
|
|
299
|
-
now?: () => Date;
|
|
280
|
+
/**
|
|
281
|
+
* Filter messages for OpenAI compatibility
|
|
282
|
+
*
|
|
283
|
+
* OpenAI has specific requirements:
|
|
284
|
+
* - Tool messages must have valid toolCallId
|
|
285
|
+
* - Messages must be in proper sequence
|
|
286
|
+
* - Tool messages without toolCallId should be excluded
|
|
287
|
+
*/
|
|
288
|
+
static filterMessagesForOpenAI(messages: TUniversalMessage[]): TUniversalMessage[];
|
|
289
|
+
/**
|
|
290
|
+
* Convert TUniversalMessage array to OpenAI message format
|
|
291
|
+
* Now properly handles tool messages for OpenAI's tool calling feature
|
|
292
|
+
*/
|
|
293
|
+
static toOpenAIFormat(messages: TUniversalMessage[]): OpenAI.Chat.ChatCompletionMessageParam[];
|
|
294
|
+
/**
|
|
295
|
+
* Convert a single TUniversalMessage to OpenAI format
|
|
296
|
+
* Handles all message types including tool messages
|
|
297
|
+
*/
|
|
298
|
+
static convertMessage(msg: TUniversalMessage): OpenAI.Chat.ChatCompletionMessageParam;
|
|
299
|
+
/**
|
|
300
|
+
* Add system prompt to message array if needed
|
|
301
|
+
*/
|
|
302
|
+
static addSystemPromptIfNeeded(messages: OpenAI.Chat.ChatCompletionMessageParam[], systemPrompt?: string): OpenAI.Chat.ChatCompletionMessageParam[];
|
|
300
303
|
}
|
|
301
|
-
|
|
302
|
-
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/openai/provider-definition.d.ts
|
|
303
306
|
declare const DEFAULT_OPENAI_PROVIDER_MODEL: string | undefined;
|
|
304
307
|
declare const DEFAULT_OPENAI_PROVIDER_API_KEY_REFERENCE = "$ENV:OPENAI_API_KEY";
|
|
305
308
|
declare function createOpenAIProviderDefinition(): IProviderDefinition;
|
|
306
|
-
|
|
307
|
-
export { DEFAULT_OPENAI_PROVIDER_API_KEY_REFERENCE, DEFAULT_OPENAI_PROVIDER_MODEL,
|
|
309
|
+
//#endregion
|
|
310
|
+
export { DEFAULT_OPENAI_PROVIDER_API_KEY_REFERENCE, DEFAULT_OPENAI_PROVIDER_MODEL, IOpenAIJsonSchemaDefinition, IOpenAINativeWebToolsOptions, IOpenAIProviderOptions, IOpenAIResponsesReasoningOptions, type IPayloadLogger, type IPayloadLoggerOptions, OpenAIConversationAdapter, OpenAIProvider, TOpenAIApiSurface, TOpenAIProviderOptionValue, createOpenAIProviderDefinition };
|
|
311
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/openai/types.ts","../../src/openai/provider.ts","../../src/openai/adapter.ts","../../src/openai/provider-definition.ts"],"mappings":";;;;KAIY;UAEK;EACf;EACA;EACA,SAAS,eAAe;EACxB;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;;;;KAMU,4EAMR,8BACA,+BACA,mCACA,SACA,iBACA,UACA,YACA,2BACA;GACG,cAAc;;;;;UAKJ;;;;GAId,cAAc;;;;EAKf;;;;EAKA;;;;EAKA;;;;;;;EAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA;;;;EAKA;;;;;;;EAQA,aAAa;;;;;;;EAQb;;;;EAKA,aAAa;;;;;EAMb,YAAY;;;;EAKZ;;;;EAKA;;;;;;;;;;;;;;EAeA;;;;;;;;EASA,iBAAiB;;;;EAKjB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BT,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BhB,WAAW;;;;;EAMX,SAAS;;;;;;;;;;;;cCrME,uBAAuB;WAChB;WACA;mBAED;mBACA;mBACA;mBACA;mBACA;;;;;;;EAQjB,cAAc;EAEF,YAAA,SAAS;EA6BN,KACb,UAAU,qBACV,UAAU,eACT,QAAQ;EAgDK,WACd,UAAU,qBACV,UAAU,eACT,cAAc;UAiCF;;;;;;;;;;EAuCf;;;;;;EASA;UAIQ;UAKA;EAKC,eAAe;UAMhB;;;;;YAcW,qBAAqB;;;;;;;;UAahC;UAYA;EAiCC;EAIA,mBAAmB;EAwBnB;EAIM,WAAW;YAIP,iBAAiB,UAAU;;;;;;;;;;;;cC/UnC;;;;;;;;;SASJ,wBAAwB,UAAU,sBAAsB;;;;;SAqBxD,eAAe,UAAU,sBAAsB,OAAO,KAAK;;;;;SAU3D,eAAe,KAAK,oBAAoB,OAAO,KAAK;;;;SA2EpD,wBACL,UAAU,OAAO,KAAK,8BACtB,wBACC,OAAO,KAAK;;;;cC1HJ;cACA;iBAeG,kCAAkC"}
|