@robota-sdk/agent-provider-openai 3.0.6 → 3.1.1
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/CHANGELOG.md +59 -0
- package/README.md +34 -5
- package/dist/index.cjs +3 -0
- package/dist/{node/index.d.cts → index.d.cts} +12 -10
- package/dist/index.d.cts.map +1 -0
- package/dist/{node/index.d.ts → index.d.ts} +12 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/loggers/index.cjs +1 -0
- package/dist/loggers/index.d.cts +43 -0
- package/dist/loggers/index.d.cts.map +1 -0
- package/dist/loggers/index.d.ts +43 -0
- package/dist/loggers/index.d.ts.map +1 -0
- package/dist/loggers/index.js +2 -0
- package/dist/loggers/index.js.map +1 -0
- package/dist/node.cjs +1 -0
- package/dist/node.d.cts +54 -0
- package/dist/node.d.cts.map +1 -0
- package/dist/node.d.ts +54 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2 -0
- package/dist/node.js.map +1 -0
- package/dist/payload-logger-n89AQdUn.d.cts.map +1 -0
- package/dist/payload-logger-n89AQdUn.d.ts.map +1 -0
- package/dist/sanitize-openai-log-data-CZ9jMqeC.cjs +1 -0
- package/dist/sanitize-openai-log-data-DI2gyZvi.js +2 -0
- package/dist/sanitize-openai-log-data-DI2gyZvi.js.map +1 -0
- package/package.json +29 -41
- package/src/node.ts +9 -0
- package/src/openai/__tests__/native-web-search.test.ts +941 -0
- package/src/openai/__tests__/strict-tools-closure.test.ts +42 -0
- package/src/openai/__tests__/tool-schema-projection.test.ts +35 -1
- package/src/openai/loggers/file-payload-logger.ts +3 -3
- package/src/openai/loggers/index.ts +1 -5
- package/src/openai/provider-definition.test.ts +3 -4
- package/src/openai/provider-definition.ts +22 -50
- package/src/openai/provider.ts +81 -25
- package/src/openai/responses-chat.ts +51 -21
- package/src/openai/responses-converter.ts +31 -8
- package/src/openai/responses-parser.ts +126 -6
- package/src/openai/responses-types.ts +22 -2
- package/src/openai/responses-web-search.ts +157 -0
- package/src/openai/types.ts +7 -8
- package/dist/node/index.cjs +0 -3
- package/dist/node/index.d.cts.map +0 -1
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js +0 -4
- package/dist/node/index.js.map +0 -1
- package/dist/node/loggers/index.cjs +0 -1
- package/dist/node/loggers/index.d.cts +0 -94
- package/dist/node/loggers/index.d.cts.map +0 -1
- package/dist/node/loggers/index.d.ts +0 -94
- package/dist/node/loggers/index.d.ts.map +0 -1
- package/dist/node/loggers/index.js +0 -2
- package/dist/node/loggers/index.js.map +0 -1
- package/dist/node/payload-logger-n89AQdUn.d.cts.map +0 -1
- package/dist/node/payload-logger-n89AQdUn.d.ts.map +0 -1
- package/src/openai/loggers/file.ts +0 -9
- /package/dist/{node/payload-logger-n89AQdUn.d.cts → payload-logger-n89AQdUn.d.cts} +0 -0
- /package/dist/{node/payload-logger-n89AQdUn.d.ts → payload-logger-n89AQdUn.d.ts} +0 -0
- /package/dist/{node/rolldown-runtime-CMqjfN_6.cjs → rolldown-runtime-CMqjfN_6.cjs} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nonVisualObservationText } from '@robota-sdk/agent-core';
|
|
2
|
+
import { decodeResponsesContinuation } from './responses-parser';
|
|
2
3
|
import type {
|
|
3
4
|
IOpenAIResponsesFunctionTool,
|
|
4
5
|
IOpenAIResponsesMessageInput,
|
|
@@ -12,10 +13,20 @@ import type {
|
|
|
12
13
|
TUniversalMessagePart,
|
|
13
14
|
} from '@robota-sdk/agent-core';
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A reply goes back as OpenAI's own items only while its turn runs, and only under the scope that
|
|
18
|
+
* recorded it: its search results are kept for a limited time and belong to one account and model,
|
|
19
|
+
* so a turn that is over, another scope or none, on a request that cannot send them, reads the reply
|
|
20
|
+
* from its text.
|
|
21
|
+
*/
|
|
15
22
|
export function convertToOpenAIResponsesInput(
|
|
16
23
|
messages: TUniversalMessage[],
|
|
24
|
+
replayScope?: string,
|
|
17
25
|
): TOpenAIResponsesInputItem[] {
|
|
18
|
-
|
|
26
|
+
const turnStart = messages.map((message) => message.role).lastIndexOf('user');
|
|
27
|
+
return messages.flatMap((message, index) =>
|
|
28
|
+
convertMessage(message, index > turnStart ? replayScope : undefined),
|
|
29
|
+
);
|
|
19
30
|
}
|
|
20
31
|
|
|
21
32
|
/**
|
|
@@ -43,7 +54,10 @@ export function convertToOpenAIResponsesTools(
|
|
|
43
54
|
return converted.length > 0 ? converted : undefined;
|
|
44
55
|
}
|
|
45
56
|
|
|
46
|
-
function convertMessage(
|
|
57
|
+
function convertMessage(
|
|
58
|
+
message: TUniversalMessage,
|
|
59
|
+
replayScope: string | undefined,
|
|
60
|
+
): TOpenAIResponsesInputItem[] {
|
|
47
61
|
if (message.role === 'user') {
|
|
48
62
|
return [createMessageInput('user', getUserContent(message.content, message.parts))];
|
|
49
63
|
}
|
|
@@ -70,10 +84,18 @@ function convertMessage(message: TUniversalMessage): TOpenAIResponsesInputItem[]
|
|
|
70
84
|
},
|
|
71
85
|
];
|
|
72
86
|
}
|
|
73
|
-
return convertAssistantMessage(message);
|
|
87
|
+
return convertAssistantMessage(message, replayScope);
|
|
74
88
|
}
|
|
75
89
|
|
|
76
|
-
function convertAssistantMessage(
|
|
90
|
+
function convertAssistantMessage(
|
|
91
|
+
message: IAssistantMessage,
|
|
92
|
+
replayScope: string | undefined,
|
|
93
|
+
): TOpenAIResponsesInputItem[] {
|
|
94
|
+
const continuation =
|
|
95
|
+
replayScope !== undefined ? decodeResponsesContinuation(message, replayScope) : undefined;
|
|
96
|
+
if (continuation !== undefined) {
|
|
97
|
+
return continuation;
|
|
98
|
+
}
|
|
77
99
|
const items: TOpenAIResponsesInputItem[] = [];
|
|
78
100
|
if (message.content && message.content.length > 0) {
|
|
79
101
|
items.push(createMessageInput('assistant', message.content));
|
|
@@ -114,10 +136,11 @@ function convertPart(part: TUniversalMessagePart): TOpenAIResponsesInputContent
|
|
|
114
136
|
if (part.type === 'image_uri') {
|
|
115
137
|
return { type: 'input_image', image_url: part.uri };
|
|
116
138
|
}
|
|
117
|
-
if (part.type === 'image_inline')
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
139
|
+
if (part.type === 'image_inline')
|
|
140
|
+
return {
|
|
141
|
+
type: 'input_image',
|
|
142
|
+
image_url: `data:${part.mimeType};base64,${part.data}`,
|
|
143
|
+
};
|
|
121
144
|
return { type: 'input_text', text: nonVisualObservationText(part) ?? 'Unsupported observation' };
|
|
122
145
|
}
|
|
123
146
|
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomId } from '@robota-sdk/agent-core';
|
|
2
|
+
|
|
3
|
+
import { PROVIDER_CONTINUATION_METADATA_KEY } from '@robota-sdk/agent-core';
|
|
2
4
|
|
|
3
5
|
import { streamWithAbort } from './responses-stream-utils';
|
|
6
|
+
import {
|
|
7
|
+
addWebSearchUsage,
|
|
8
|
+
collectWebSearchUsage,
|
|
9
|
+
createEmptyWebSearchUsage,
|
|
10
|
+
isWebSearchCallItem,
|
|
11
|
+
mergeWebSearchUsage,
|
|
12
|
+
webSearchMetadata,
|
|
13
|
+
} from './responses-web-search';
|
|
4
14
|
|
|
5
15
|
import type {
|
|
6
16
|
IOpenAIResponsesErrorEvent,
|
|
@@ -13,7 +23,9 @@ import type {
|
|
|
13
23
|
TOpenAIResponsesOutputItem,
|
|
14
24
|
TOpenAIResponsesStreamEvent,
|
|
15
25
|
} from './responses-types';
|
|
26
|
+
import type { IOpenAIWebSearchUsage } from './responses-web-search';
|
|
16
27
|
import type {
|
|
28
|
+
IAssistantMessage,
|
|
17
29
|
IToolCall,
|
|
18
30
|
ITokenUsageWithCacheRead,
|
|
19
31
|
TTextDeltaCallback,
|
|
@@ -28,7 +40,14 @@ const THOUGHT_PART_SEPARATOR = '\n\n';
|
|
|
28
40
|
type TResponsesMessageUsage = Omit<ITokenUsageWithCacheRead, 'totalTokens'> &
|
|
29
41
|
Partial<Pick<ITokenUsageWithCacheRead, 'totalTokens'>>;
|
|
30
42
|
|
|
31
|
-
|
|
43
|
+
/** What the request that produced the response carried, which decides what its metadata may claim. */
|
|
44
|
+
interface IOpenAIResponsesParseOptions {
|
|
45
|
+
hostedWebSearch?: boolean;
|
|
46
|
+
/** Who may send the reply's items back (see `encodeResponsesContinuation`); absent for an unstored request. */
|
|
47
|
+
replayScope?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface IOpenAIResponsesStreamAssemblyOptions extends IOpenAIResponsesParseOptions {
|
|
32
51
|
stream: AsyncIterable<TOpenAIResponsesStreamEvent>;
|
|
33
52
|
onTextDelta?: TTextDeltaCallback;
|
|
34
53
|
onThinkingDelta?: TThinkingDeltaCallback;
|
|
@@ -59,10 +78,12 @@ interface IOpenAIResponsesStreamState {
|
|
|
59
78
|
completedResponse?: IOpenAIResponsesResponse;
|
|
60
79
|
reasoning: IOpenAIResponsesReasoningMetadata;
|
|
61
80
|
thought: IOpenAIResponsesThoughtStreamState;
|
|
81
|
+
webSearch: IOpenAIWebSearchUsage;
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
export function parseOpenAIResponsesResponse(
|
|
65
85
|
response: IOpenAIResponsesResponse,
|
|
86
|
+
options?: IOpenAIResponsesParseOptions,
|
|
66
87
|
): TUniversalMessage {
|
|
67
88
|
assertUsableResponse(response);
|
|
68
89
|
const output = response.output ?? [];
|
|
@@ -72,6 +93,9 @@ export function parseOpenAIResponsesResponse(
|
|
|
72
93
|
toolCalls: extractFunctionToolCalls(output),
|
|
73
94
|
response,
|
|
74
95
|
reasoning: collectReasoningMetadata(output),
|
|
96
|
+
hostedWebSearch: options?.hostedWebSearch === true,
|
|
97
|
+
replayScope: options?.replayScope,
|
|
98
|
+
webSearch: collectWebSearchUsage(output),
|
|
75
99
|
});
|
|
76
100
|
}
|
|
77
101
|
|
|
@@ -83,6 +107,7 @@ export async function assembleOpenAIResponsesStream(
|
|
|
83
107
|
toolCalls: [],
|
|
84
108
|
reasoning: createEmptyReasoningMetadata(),
|
|
85
109
|
thought: { sentText: false },
|
|
110
|
+
webSearch: createEmptyWebSearchUsage(),
|
|
86
111
|
};
|
|
87
112
|
|
|
88
113
|
for await (const event of streamWithAbort(options.stream, options.signal)) {
|
|
@@ -90,13 +115,15 @@ export async function assembleOpenAIResponsesStream(
|
|
|
90
115
|
}
|
|
91
116
|
|
|
92
117
|
if (state.completedResponse !== undefined) {
|
|
93
|
-
return buildMessageFromCompletedResponse(state);
|
|
118
|
+
return buildMessageFromCompletedResponse(state, options);
|
|
94
119
|
}
|
|
95
120
|
|
|
96
121
|
return buildAssistantMessage({
|
|
97
122
|
content: state.textParts.join(''),
|
|
98
123
|
toolCalls: state.toolCalls,
|
|
99
124
|
reasoning: state.reasoning,
|
|
125
|
+
hostedWebSearch: options.hostedWebSearch === true,
|
|
126
|
+
webSearch: state.webSearch,
|
|
100
127
|
});
|
|
101
128
|
}
|
|
102
129
|
|
|
@@ -127,6 +154,7 @@ function applyStreamEvent(
|
|
|
127
154
|
if (event.type === 'response.completed') {
|
|
128
155
|
state.completedResponse = event.response;
|
|
129
156
|
mergeReasoningMetadata(state.reasoning, collectReasoningMetadata(event.response.output ?? []));
|
|
157
|
+
mergeWebSearchUsage(state.webSearch, collectWebSearchUsage(event.response.output ?? []));
|
|
130
158
|
return;
|
|
131
159
|
}
|
|
132
160
|
|
|
@@ -180,10 +208,15 @@ function applyOutputItem(
|
|
|
180
208
|
}
|
|
181
209
|
if (isReasoningOutputItem(item)) {
|
|
182
210
|
mergeReasoningMetadata(state.reasoning, collectReasoningMetadata([item]));
|
|
211
|
+
return;
|
|
183
212
|
}
|
|
213
|
+
addWebSearchUsage(state.webSearch, collectWebSearchUsage([item]));
|
|
184
214
|
}
|
|
185
215
|
|
|
186
|
-
function buildMessageFromCompletedResponse(
|
|
216
|
+
function buildMessageFromCompletedResponse(
|
|
217
|
+
state: IOpenAIResponsesStreamState,
|
|
218
|
+
options: IOpenAIResponsesParseOptions,
|
|
219
|
+
): TUniversalMessage {
|
|
187
220
|
const response = state.completedResponse;
|
|
188
221
|
if (response === undefined) {
|
|
189
222
|
throw new Error('OpenAI Responses stream completed without response metadata');
|
|
@@ -204,6 +237,9 @@ function buildMessageFromCompletedResponse(state: IOpenAIResponsesStreamState):
|
|
|
204
237
|
toolCalls: responseToolCalls.length > 0 ? responseToolCalls : state.toolCalls,
|
|
205
238
|
response,
|
|
206
239
|
reasoning,
|
|
240
|
+
hostedWebSearch: options.hostedWebSearch === true,
|
|
241
|
+
replayScope: options.replayScope,
|
|
242
|
+
webSearch: state.webSearch,
|
|
207
243
|
});
|
|
208
244
|
}
|
|
209
245
|
|
|
@@ -212,9 +248,12 @@ function buildAssistantMessage(input: {
|
|
|
212
248
|
toolCalls: IToolCall[];
|
|
213
249
|
response?: IOpenAIResponsesResponse;
|
|
214
250
|
reasoning: IOpenAIResponsesReasoningMetadata;
|
|
251
|
+
hostedWebSearch: boolean;
|
|
252
|
+
replayScope?: string;
|
|
253
|
+
webSearch: IOpenAIWebSearchUsage;
|
|
215
254
|
}): TUniversalMessage {
|
|
216
255
|
return {
|
|
217
|
-
id:
|
|
256
|
+
id: randomId(),
|
|
218
257
|
role: 'assistant',
|
|
219
258
|
content: input.content,
|
|
220
259
|
state: 'complete',
|
|
@@ -222,7 +261,13 @@ function buildAssistantMessage(input: {
|
|
|
222
261
|
...(input.toolCalls.length > 0 && { toolCalls: input.toolCalls }),
|
|
223
262
|
...(input.response?.usage !== undefined && { usage: mapUsage(input.response.usage) }),
|
|
224
263
|
metadata: {
|
|
225
|
-
...buildMetadata(
|
|
264
|
+
...buildMetadata(
|
|
265
|
+
input.response,
|
|
266
|
+
input.reasoning,
|
|
267
|
+
input.hostedWebSearch,
|
|
268
|
+
input.webSearch,
|
|
269
|
+
input.replayScope,
|
|
270
|
+
),
|
|
226
271
|
...(input.response?.usage !== undefined && {
|
|
227
272
|
usageProvenance:
|
|
228
273
|
input.response.usage.input_tokens !== undefined &&
|
|
@@ -238,7 +283,11 @@ function buildAssistantMessage(input: {
|
|
|
238
283
|
function buildMetadata(
|
|
239
284
|
response: IOpenAIResponsesResponse | undefined,
|
|
240
285
|
reasoning: IOpenAIResponsesReasoningMetadata,
|
|
286
|
+
hostedWebSearch: boolean,
|
|
287
|
+
webSearch: IOpenAIWebSearchUsage,
|
|
288
|
+
replayScope: string | undefined,
|
|
241
289
|
): NonNullable<TUniversalMessage['metadata']> {
|
|
290
|
+
const continuation = encodeResponsesContinuation(response, replayScope);
|
|
242
291
|
return {
|
|
243
292
|
providerApiSurface: 'responses',
|
|
244
293
|
...(response?.id !== undefined && { responseId: response.id }),
|
|
@@ -249,9 +298,80 @@ function buildMetadata(
|
|
|
249
298
|
reasoningSummaries: reasoning.reasoningSummaries,
|
|
250
299
|
}),
|
|
251
300
|
...(reasoning.hasEncryptedReasoning && { hasEncryptedReasoning: true }),
|
|
301
|
+
...webSearchMetadata(hostedWebSearch, webSearch),
|
|
302
|
+
...(continuation !== undefined && { [PROVIDER_CONTINUATION_METADATA_KEY]: continuation }),
|
|
252
303
|
};
|
|
253
304
|
}
|
|
254
305
|
|
|
306
|
+
/**
|
|
307
|
+
* The reply's own output items, for the next request to send back as they came: hosted search
|
|
308
|
+
* results exist only on OpenAI's side, named by these items, and a search item is refused without
|
|
309
|
+
* its reasoning item, so the reply goes back whole. They are recorded with the scope that may send
|
|
310
|
+
* them back, because they belong to the account and model that made them. A reply with no function
|
|
311
|
+
* call ends its turn and is never sent back in-turn; an unstored one has no items on OpenAI's side
|
|
312
|
+
* to find.
|
|
313
|
+
*/
|
|
314
|
+
function encodeResponsesContinuation(
|
|
315
|
+
response: IOpenAIResponsesResponse | undefined,
|
|
316
|
+
replayScope: string | undefined,
|
|
317
|
+
): string | undefined {
|
|
318
|
+
const output = response?.output ?? [];
|
|
319
|
+
const searchedAndCalled =
|
|
320
|
+
output.some(isWebSearchCallItem) && output.some(isFunctionCallOutputItem);
|
|
321
|
+
if (replayScope === undefined || response?.store === false || !searchedAndCalled) {
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
return JSON.stringify({ replayScope, openaiOutput: output });
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* The output items to send back for a message, or undefined to rebuild it from the message. A
|
|
329
|
+
* continuation from another provider, one recorded under another replay scope (another model, or
|
|
330
|
+
* another provider instance, whose account, retention and restarts the items do not share), or items
|
|
331
|
+
* that no longer say what the message says because something rewrote it, are not sent: the message
|
|
332
|
+
* is what the conversation holds.
|
|
333
|
+
*/
|
|
334
|
+
export function decodeResponsesContinuation(
|
|
335
|
+
message: IAssistantMessage,
|
|
336
|
+
replayScope: string,
|
|
337
|
+
): TOpenAIResponsesOutputItem[] | undefined {
|
|
338
|
+
const encoded = message.metadata?.[PROVIDER_CONTINUATION_METADATA_KEY];
|
|
339
|
+
if (typeof encoded !== 'string') {
|
|
340
|
+
return undefined;
|
|
341
|
+
}
|
|
342
|
+
const output = parseOpenAIOutput(encoded, replayScope);
|
|
343
|
+
if (output === undefined) {
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
const calls = extractFunctionToolCalls(output);
|
|
347
|
+
const messageCalls = message.toolCalls ?? [];
|
|
348
|
+
const sameCalls =
|
|
349
|
+
calls.length === messageCalls.length &&
|
|
350
|
+
calls.every((call, index) => {
|
|
351
|
+
const messageCall = messageCalls[index];
|
|
352
|
+
return (
|
|
353
|
+
call.id === messageCall?.id &&
|
|
354
|
+
call.function.name === messageCall.function.name &&
|
|
355
|
+
call.function.arguments === messageCall.function.arguments
|
|
356
|
+
);
|
|
357
|
+
});
|
|
358
|
+
return extractMessageText(output) === (message.content ?? '') && sameCalls ? output : undefined;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function parseOpenAIOutput(
|
|
362
|
+
encoded: string,
|
|
363
|
+
replayScope: string,
|
|
364
|
+
): TOpenAIResponsesOutputItem[] | undefined {
|
|
365
|
+
try {
|
|
366
|
+
const parsed = JSON.parse(encoded) as { replayScope?: unknown; openaiOutput?: unknown };
|
|
367
|
+
return parsed.replayScope === replayScope && Array.isArray(parsed.openaiOutput)
|
|
368
|
+
? (parsed.openaiOutput as TOpenAIResponsesOutputItem[])
|
|
369
|
+
: undefined;
|
|
370
|
+
} catch {
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
255
375
|
function mapUsage(usage: IOpenAIResponsesUsage): TResponsesMessageUsage {
|
|
256
376
|
const cachedTokens = usage.input_tokens_details?.cached_tokens;
|
|
257
377
|
return {
|
|
@@ -43,7 +43,9 @@ export interface IOpenAIResponsesFunctionCallOutputInput {
|
|
|
43
43
|
export type TOpenAIResponsesInputItem =
|
|
44
44
|
| IOpenAIResponsesMessageInput
|
|
45
45
|
| IOpenAIResponsesFunctionCallInput
|
|
46
|
-
| IOpenAIResponsesFunctionCallOutputInput
|
|
46
|
+
| IOpenAIResponsesFunctionCallOutputInput
|
|
47
|
+
// A reply's own items go back as they came.
|
|
48
|
+
| TOpenAIResponsesOutputItem;
|
|
47
49
|
|
|
48
50
|
export interface IOpenAIResponsesFunctionTool {
|
|
49
51
|
type: 'function';
|
|
@@ -53,7 +55,12 @@ export interface IOpenAIResponsesFunctionTool {
|
|
|
53
55
|
description?: string;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
/** OpenAI's hosted search tool: the model decides when to search, and OpenAI runs it. */
|
|
59
|
+
export interface IOpenAIResponsesWebSearchTool {
|
|
60
|
+
type: 'web_search';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type TOpenAIResponsesTool = IOpenAIResponsesFunctionTool | IOpenAIResponsesWebSearchTool;
|
|
57
64
|
|
|
58
65
|
export interface IOpenAIResponsesTextFormatText {
|
|
59
66
|
type: 'text';
|
|
@@ -102,6 +109,8 @@ export interface IOpenAIResponsesRequestStreaming extends IOpenAIResponsesReques
|
|
|
102
109
|
export interface IOpenAIResponsesTextOutputContent {
|
|
103
110
|
type: 'output_text' | 'text';
|
|
104
111
|
text: string;
|
|
112
|
+
/** Sources of the text; a hosted web search adds `url_citation` entries. */
|
|
113
|
+
annotations?: Array<{ type: string; url?: string; title?: string }>;
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
export interface IOpenAIResponsesRefusalOutputContent {
|
|
@@ -133,6 +142,14 @@ export interface IOpenAIResponsesReasoningOutputItem {
|
|
|
133
142
|
encrypted_content?: string;
|
|
134
143
|
}
|
|
135
144
|
|
|
145
|
+
/** One step of a hosted web search; only a `search` action is a search, the others read a found page. */
|
|
146
|
+
export interface IOpenAIResponsesWebSearchCallOutputItem {
|
|
147
|
+
type: 'web_search_call';
|
|
148
|
+
id?: string;
|
|
149
|
+
status?: string;
|
|
150
|
+
action?: { type?: string; query?: string };
|
|
151
|
+
}
|
|
152
|
+
|
|
136
153
|
export interface IOpenAIResponsesGenericOutputItem {
|
|
137
154
|
type: string;
|
|
138
155
|
id?: string;
|
|
@@ -143,6 +160,7 @@ export type TOpenAIResponsesOutputItem =
|
|
|
143
160
|
| IOpenAIResponsesMessageOutputItem
|
|
144
161
|
| IOpenAIResponsesFunctionCallOutputItem
|
|
145
162
|
| IOpenAIResponsesReasoningOutputItem
|
|
163
|
+
| IOpenAIResponsesWebSearchCallOutputItem
|
|
146
164
|
| IOpenAIResponsesGenericOutputItem;
|
|
147
165
|
|
|
148
166
|
export interface IOpenAIResponsesUsage {
|
|
@@ -165,6 +183,8 @@ export interface IOpenAIResponsesResponse {
|
|
|
165
183
|
usage?: IOpenAIResponsesUsage;
|
|
166
184
|
status?: string;
|
|
167
185
|
error?: IOpenAIResponsesErrorBody | null;
|
|
186
|
+
/** The response says whether it was stored; an unstored one leaves nothing to find later. */
|
|
187
|
+
store?: boolean;
|
|
168
188
|
}
|
|
169
189
|
|
|
170
190
|
export interface IOpenAIResponsesTextDeltaEvent {
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IOpenAIResponsesMessageOutputItem,
|
|
3
|
+
IOpenAIResponsesWebSearchCallOutputItem,
|
|
4
|
+
TOpenAIResponsesOutputItem,
|
|
5
|
+
} from './responses-types';
|
|
6
|
+
import type { IOpenAIProviderOptions, IOpenAIResponsesReasoningOptions } from './types';
|
|
7
|
+
import type { IChatOptions, TUniversalMessage } from '@robota-sdk/agent-core';
|
|
8
|
+
|
|
9
|
+
// OpenAI's model pages list no web search for these (`gpt-4.1-nano`, `o1`, `o1-pro`, `o3-mini`; the
|
|
10
|
+
// `gpt-3.5` and `gpt-4` pages list no tools), verified 2026-11-04. A default-on profile on one of
|
|
11
|
+
// them would otherwise fail every turn. Dated snapshots match too.
|
|
12
|
+
const MODELS_WITHOUT_WEB_SEARCH = /^(?:gpt-3\.5|gpt-4(?:-|$)|gpt-4\.1-nano|o1(?:-|$)|o3-mini)/;
|
|
13
|
+
|
|
14
|
+
export interface IHostedWebSearchRequest {
|
|
15
|
+
providerOptions: IOpenAIProviderOptions;
|
|
16
|
+
chatOptions: IChatOptions | undefined;
|
|
17
|
+
model: string;
|
|
18
|
+
reasoning: IOpenAIResponsesReasoningOptions | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** What a response says about its hosted web searches. */
|
|
22
|
+
export interface IOpenAIWebSearchUsage {
|
|
23
|
+
calls: number;
|
|
24
|
+
citations: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function modelOffersWebSearch(model: string): boolean {
|
|
28
|
+
return !MODELS_WITHOUT_WEB_SEARCH.test(model);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether the hosted `web_search` tool joins this request. Search rides on a request whose tool use
|
|
33
|
+
* is the model's free choice: `none` forbids tools, and a forced choice asks for a function the
|
|
34
|
+
* caller will run, which a hosted search could otherwise satisfy without one. A call can withhold it
|
|
35
|
+
* (`nativeWebTools.webSearch: false`), minimal reasoning excludes it (per OpenAI's guide), and the
|
|
36
|
+
* models above do not offer it. A call that requires search where the model or its reasoning cannot
|
|
37
|
+
* run it fails instead of going without.
|
|
38
|
+
*/
|
|
39
|
+
export function includesHostedWebSearch(request: IHostedWebSearchRequest): boolean {
|
|
40
|
+
const { providerOptions, chatOptions, model, reasoning } = request;
|
|
41
|
+
const toolChoice = chatOptions?.toolChoice;
|
|
42
|
+
if (
|
|
43
|
+
providerOptions.nativeWebTools?.webSearch !== true ||
|
|
44
|
+
chatOptions?.nativeWebTools?.webSearch === false ||
|
|
45
|
+
(toolChoice !== undefined && toolChoice !== 'auto')
|
|
46
|
+
) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (reasoning?.effort !== 'minimal' && modelOffersWebSearch(model)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (chatOptions?.nativeWebTools?.webSearch === true) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Provider openai cannot run hosted web search on model ${model} with reasoning effort ${reasoning?.effort ?? 'unset'}.`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function createEmptyWebSearchUsage(): IOpenAIWebSearchUsage {
|
|
61
|
+
return { calls: 0, citations: [] };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Searches and cited URLs in a response's output. Only `search` actions are billed searches
|
|
66
|
+
* (`open_page` and `find_in_page` read a page already found); an item with no action counts as one.
|
|
67
|
+
* Citations are the unique `url_citation` URLs of the reply text, in first-seen order.
|
|
68
|
+
*/
|
|
69
|
+
export function collectWebSearchUsage(
|
|
70
|
+
output: readonly TOpenAIResponsesOutputItem[],
|
|
71
|
+
): IOpenAIWebSearchUsage {
|
|
72
|
+
const usage = createEmptyWebSearchUsage();
|
|
73
|
+
for (const item of output) {
|
|
74
|
+
if (isWebSearchCallItem(item)) {
|
|
75
|
+
if (item.action?.type === undefined || item.action.type === 'search') {
|
|
76
|
+
usage.calls += 1;
|
|
77
|
+
}
|
|
78
|
+
} else if (isMessageItem(item)) {
|
|
79
|
+
for (const content of item.content) {
|
|
80
|
+
if (content.type === 'output_text') {
|
|
81
|
+
addCitations(usage, content.annotations);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return usage;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Usage seen item by item adds up: each finished search item is one more search. */
|
|
90
|
+
export function addWebSearchUsage(
|
|
91
|
+
target: IOpenAIWebSearchUsage,
|
|
92
|
+
source: IOpenAIWebSearchUsage,
|
|
93
|
+
): void {
|
|
94
|
+
target.calls += source.calls;
|
|
95
|
+
addCitationUrls(target, source.citations);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Two reports of the same response (the stream's items and its completed response) agree rather than
|
|
100
|
+
* add up, so the larger search count stands and the citations are their union.
|
|
101
|
+
*/
|
|
102
|
+
export function mergeWebSearchUsage(
|
|
103
|
+
target: IOpenAIWebSearchUsage,
|
|
104
|
+
source: IOpenAIWebSearchUsage,
|
|
105
|
+
): void {
|
|
106
|
+
target.calls = Math.max(target.calls, source.calls);
|
|
107
|
+
addCitationUrls(target, source.citations);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Nothing when the request did not carry the tool: it cannot have searched, so nothing is claimed. */
|
|
111
|
+
export function webSearchMetadata(
|
|
112
|
+
hostedWebSearch: boolean,
|
|
113
|
+
usage: IOpenAIWebSearchUsage,
|
|
114
|
+
): NonNullable<TUniversalMessage['metadata']> {
|
|
115
|
+
if (!hostedWebSearch) {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
providerBuiltInToolsEnabled: ['web_search'],
|
|
120
|
+
openaiWebSearchCalls: usage.calls,
|
|
121
|
+
...(usage.calls > 0 && { providerBuiltInToolsUsed: ['web_search'] }),
|
|
122
|
+
...(usage.citations.length > 0 && { openaiWebSearchCitations: usage.citations }),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function addCitations(
|
|
127
|
+
usage: IOpenAIWebSearchUsage,
|
|
128
|
+
annotations: ReadonlyArray<{ type: string; url?: string }> | undefined,
|
|
129
|
+
): void {
|
|
130
|
+
const urls: string[] = [];
|
|
131
|
+
for (const annotation of annotations ?? []) {
|
|
132
|
+
if (annotation.type === 'url_citation' && typeof annotation.url === 'string') {
|
|
133
|
+
urls.push(annotation.url);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
addCitationUrls(usage, urls);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function addCitationUrls(usage: IOpenAIWebSearchUsage, urls: readonly string[]): void {
|
|
140
|
+
for (const url of urls) {
|
|
141
|
+
if (!usage.citations.includes(url)) {
|
|
142
|
+
usage.citations.push(url);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function isWebSearchCallItem(
|
|
148
|
+
item: TOpenAIResponsesOutputItem,
|
|
149
|
+
): item is IOpenAIResponsesWebSearchCallOutputItem {
|
|
150
|
+
return item.type === 'web_search_call';
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function isMessageItem(
|
|
154
|
+
item: TOpenAIResponsesOutputItem,
|
|
155
|
+
): item is IOpenAIResponsesMessageOutputItem {
|
|
156
|
+
return item.type === 'message' && 'content' in item && Array.isArray(item.content);
|
|
157
|
+
}
|
package/src/openai/types.ts
CHANGED
|
@@ -194,11 +194,10 @@ export interface IOpenAIProviderOptions {
|
|
|
194
194
|
readonly extraBody?: TOpenAIExtraBody;
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* any model request is sent.
|
|
197
|
+
* Hosted web search on OpenAI's own Responses API: `{ webSearch: true }` adds a `web_search` tool
|
|
198
|
+
* to each request that may use tools, and OpenAI runs the searches. Any other surface (Chat
|
|
199
|
+
* Completions, or a custom `baseURL`) rejects it at construction, before a request is sent.
|
|
200
|
+
* OpenAI offers no separate hosted web fetch here, so `webFetch: true` is rejected too.
|
|
202
201
|
*/
|
|
203
202
|
nativeWebTools?: IOpenAINativeWebToolsOptions;
|
|
204
203
|
|
|
@@ -213,14 +212,14 @@ export interface IOpenAIProviderOptions {
|
|
|
213
212
|
* response content. Not called on the Responses API surface.
|
|
214
213
|
*
|
|
215
214
|
* Use different implementations based on your environment:
|
|
216
|
-
* - FilePayloadLogger: Node.js file-based logging
|
|
217
|
-
* - ConsolePayloadLogger:
|
|
215
|
+
* - FilePayloadLogger (`@robota-sdk/agent-provider-openai/node`): Node.js file-based logging
|
|
216
|
+
* - ConsolePayloadLogger (`@robota-sdk/agent-provider-openai/loggers`): console logging on any runtime
|
|
218
217
|
* - Custom: Implement IPayloadLogger interface
|
|
219
218
|
*
|
|
220
219
|
* @example
|
|
221
220
|
* ```typescript
|
|
222
221
|
* // Node.js
|
|
223
|
-
* import { FilePayloadLogger } from '@robota-sdk/agent-provider-openai/
|
|
222
|
+
* import { FilePayloadLogger } from '@robota-sdk/agent-provider-openai/node';
|
|
224
223
|
* const provider = new OpenAIProvider({
|
|
225
224
|
* client: openaiClient,
|
|
226
225
|
* payloadLogger: new FilePayloadLogger({ logDir: './logs/openai' })
|
package/dist/node/index.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-CMqjfN_6.cjs");let t=require("node:crypto"),n=require("@robota-sdk/agent-core"),r=require("openai");r=e.t(r,1);let i=require("@robota-sdk/agent-provider-openai-compatible/shared");const a=new Set(`model.messages.input.previous_response_id.conversation.tools.tool_choice.parallel_tool_calls.functions.function_call.web_search_options.stream.stream_options.n.background.modalities.audio.response_format.text.max_tokens.max_completion_tokens.max_output_tokens.temperature.reasoning.reasoning_effort.include.store`.split(`.`));function o(e){if(e===void 0)return;if(!l(e))throw Error(`extraBody must be a plain JSON object`);let t=d(e,new Set);for(let e of Object.keys(t))if(a.has(e))throw Error(`extraBody cannot set the provider-managed field ${e}`);return Object.keys(t).length===0?void 0:t}function s(e,t){if(e!==void 0&&t)throw Error(`extraBody cannot be used with an executor`)}function c(e){return e===void 0?{}:d(e,new Set)}function l(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function u(e,t){if(e===null||typeof e==`boolean`||typeof e==`string`||typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return ee(e,t);if(l(e))return d(e,t);throw p()}function ee(e,t){if(f(e,t),Object.keys(e).length!==e.length)throw p();let n=[];for(let r=0;r<e.length;r+=1){if(!(r in e))throw p();n.push(u(e[r],t))}return t.delete(e),n}function d(e,t){f(e,t);let n=Reflect.ownKeys(e).map(n=>{if(typeof n!=`string`||!Object.prototype.propertyIsEnumerable.call(e,n))throw p();return[n,u(Reflect.get(e,n),t)]});return t.delete(e),Object.fromEntries(n)}function f(e,t){if(t.has(e))throw p();t.add(e)}function p(){return Error(`extraBody must contain only JSON data: null, booleans, strings, finite numbers, arrays and plain objects`)}function te(e){return(0,i.convertToOpenAICompatibleMessages)(e)}function ne(e,t){return(0,i.convertToOpenAICompatibleTools)(e,{strict:t===!0})}function re(e,t){return t?.type===void 0?e:t.type===`json_schema`?{...e,responseFormat:`json_schema`,jsonSchema:{name:t.name??`structured_output`,schema:t.schema}}:{...e,responseFormat:t.type}}function ie(e){if(e.responseFormat===void 0||e.responseFormat===`text`)return;if(e.responseFormat===`json_object`)return{type:`json_object`};let t=m(e);return{type:`json_schema`,json_schema:{name:t.name,schema:t.schema,...t.description!==void 0&&{description:t.description},...t.strict!==void 0&&{strict:t.strict}}}}function ae(e){if(e.responseFormat===void 0||e.responseFormat===`text`)return;if(e.responseFormat===`json_object`)return{format:{type:`json_object`}};let t=m(e);return{format:{type:`json_schema`,name:t.name,schema:t.schema,...t.description!==void 0&&{description:t.description},...t.strict!==void 0&&{strict:t.strict}}}}function m(e){let t=e.jsonSchema;if(e.responseFormat!==`json_schema`)throw Error(`Unsupported OpenAI response format: ${e.responseFormat}`);if(!t?.schema)throw Error(`OpenAI jsonSchema.schema is required when responseFormat is json_schema`);return{name:t.name,schema:t.schema,...t.description!==void 0&&{description:t.description},...t.strict!==void 0&&{strict:t.strict}}}function h(e,t){if(e!==void 0){if(typeof e!=`boolean`)throw Error(`parallelToolCalls must be a boolean`);if(t!==void 0&&t!==`chat-completions`&&t!==`responses`)throw Error(`parallelToolCalls requires a supported OpenAI API surface`);return e}}function g(e,t){if(e!==void 0&&t)throw Error(`parallelToolCalls cannot be used with an executor`)}function _(e){return e===void 0?{}:{parallel_tool_calls:e}}async function v(e){if(typeof e.withResponse==`function`){let{data:t,request_id:n}=await e.withResponse();return{data:t,...typeof n==`string`&&n.length>0&&{providerRequestId:n}}}return{data:await e}}function y(e){let t=e?._request_id;return typeof t==`string`&&t.length>0?t:void 0}function b(e,t){return t===void 0?e:{...e,metadata:{...e.metadata,providerRequestId:t}}}function x(e,t){let n=t!==void 0&&Object.keys(t).length>0;if(!(!e&&!n))return{...e?{signal:e}:{},...n?{headers:{...t}}:{}}}async function oe(e){let t=E(e.client);try{let n=w(e);if(e.chatOptions?.onTextDelta??e.onTextDelta)return await se(t,e,{...n,stream:!0,...C(e)});await T(e,n,`chat`),e.chatOptions?.onProviderNativeRawPayload?.({provider:`openai`,apiSurface:`chat-completions`,payloadKind:`request`,payload:n});let r=x(e.chatOptions?.signal,e.requestHeaders),i=r?await t.chat.completions.create(n,r):await t.chat.completions.create(n);return e.chatOptions?.onProviderNativeRawPayload?.({provider:`openai`,apiSurface:`chat-completions`,payloadKind:`response`,payload:i}),b(e.responseParser.parseResponse(i),y(i))}catch(e){throw(0,n.toProviderError)(e,`openai`,`OpenAI chat failed`)}}async function*S(e){let t=E(e.client);try{let n={...w(e),stream:!0,...C(e)};await T(e,n,`stream`),e.chatOptions?.onProviderNativeRawPayload?.({provider:`openai`,apiSurface:`chat-completions`,payloadKind:`request`,payload:n});let{data:r,providerRequestId:a}=await v(t.chat.completions.create(n,x(e.chatOptions?.signal,e.requestHeaders)));for await(let t of(0,i.observeProviderNativeRawPayloadStream)(r,{provider:`openai`,apiSurface:`chat-completions`,onProviderNativeRawPayload:e.chatOptions?.onProviderNativeRawPayload})){let n=e.responseParser.parseStreamingChunk(t);n&&(yield b(n,a))}}catch(e){throw(0,n.toProviderError)(e,`openai`,`OpenAI stream failed`)}}function C(e){return e.providerOptions.includeStreamUsage===!1?{}:{stream_options:{include_usage:!0}}}function w(e){let t=te(e.messages),n=e.chatOptions?.model??e.providerOptions.defaultModel;if(!n)throw Error(`Model is required in chat options. Please specify a model in defaultModel configuration.`);let r=ie(re(e.providerOptions,e.chatOptions?.responseFormat));return{...c(e.extraBody),model:n,messages:t,...e.chatOptions?.temperature!==void 0&&{temperature:e.chatOptions.temperature},...e.chatOptions?.maxTokens!==void 0&&{max_tokens:e.chatOptions.maxTokens},...e.chatOptions?.tools&&{tools:ne(e.chatOptions.tools,e.providerOptions.strictTools),tool_choice:(0,i.toOpenAICompatibleToolChoice)(e.chatOptions.toolChoice),..._(e.parallelToolCalls)},...r!==void 0&&{response_format:r}}}async function se(e,t,r){try{await T(t,r,`stream`),t.chatOptions?.onProviderNativeRawPayload?.({provider:`openai`,apiSurface:`chat-completions`,payloadKind:`request`,payload:r});let{data:n,providerRequestId:a}=await v(e.chat.completions.create(r,x(t.chatOptions?.signal,t.requestHeaders)));return b(await(0,i.assembleOpenAICompatibleStream)({stream:(0,i.observeProviderNativeRawPayloadStream)(n,{provider:`openai`,apiSurface:`chat-completions`,onProviderNativeRawPayload:t.chatOptions?.onProviderNativeRawPayload}),onTextDelta:t.chatOptions?.onTextDelta??t.onTextDelta,signal:t.chatOptions?.signal}),a)}catch(e){throw(0,n.toProviderError)(e,`openai`,`OpenAI stream failed`)}}async function T(e,t,n){if(!e.payloadLogger?.isEnabled())return;let r={model:t.model,messagesCount:t.messages.length,hasTools:!!t.tools,temperature:t.temperature??void 0,maxTokens:t.max_tokens??void 0,timestamp:new Date().toISOString()};await e.payloadLogger.logPayload(r,n)}function E(e){if(!e)throw Error(`OpenAI client not available. Either provide a client/apiKey or use an executor.`);return e}const ce={verifiedAt:`2026-09-11`,sourceUrl:`https://platform.openai.com/docs/api-reference/responses`,models:{"gpt-5.1":{supportedEfforts:[`none`,`low`,`medium`,`high`],defaultEffort:`none`,nativeControlId:`responses.reasoning.effort`}}};var le=class{parser;constructor(e){this.parser=new i.OpenAICompatibleResponseParser({logger:e})}parseResponse(e){try{return this.parser.parseResponse(e)}catch(e){let t=D(e instanceof Error?e.message:`OpenAI response parsing failed`);throw Error(`OpenAI response parsing failed: ${t}`)}}parseStreamingChunk(e){try{return this.parser.parseStreamingChunk(e)}catch(e){let t=D(e instanceof Error?e.message:`OpenAI chunk parsing failed`);throw Error(`OpenAI chunk parsing failed: ${t}`)}}};function D(e){return e.replace(/^OpenAI-compatible response parsing failed: /,``).replace(/^OpenAI-compatible chunk parsing failed: /,``).replace(`OpenAI-compatible response`,`OpenAI response`)}function ue(e){return e}function de(e,t){if(t===void 0)return e;if(t.effective===null||t.disposition===`model-default`){if(e?.effort!==void 0)throw Error(`Static reasoning.effort ${e.effort} conflicts with ${t.disposition===`model-default`?`provider-default selection`:`an effort resolution that does not apply a native control`}.`);return e}let n=ue(t.effective);if(e?.effort!==void 0&&e.effort!==n)throw Error(`Resolved effort ${n} conflicts with static reasoning.effort ${e.effort}.`);return{...e,effort:n}}function fe(e){return e.flatMap(e=>me(e))}function pe(e,t){let n=t??!1,r=e?.map(e=>({type:`function`,name:e.name,description:e.description,parameters:e.parameters,strict:n}))??[];return r.length>0?r:void 0}function me(e){if(e.role===`user`)return[k(`user`,ge(e.content,e.parts))];if(e.role===`system`)return[k(`system`,e.content)];if(e.role===`tool`){if(!e.toolCallId||e.toolCallId.trim().length===0)throw Error(`Tool message missing toolCallId: ${JSON.stringify(e)}`);return[{type:`function_call_output`,call_id:e.toolCallId,output:e.parts?.length?[...e.content&&!e.parts.some(t=>t.type===`text`&&t.text===e.content)?[{type:`input_text`,text:e.content}]:[],...e.parts.map(O)]:e.content||``}]}return he(e)}function he(e){let t=[];e.content&&e.content.length>0&&t.push(k(`assistant`,e.content));for(let n of e.toolCalls??[])t.push({type:`function_call`,call_id:n.id,name:n.function.name,arguments:n.function.arguments});return t.length===0&&t.push(k(`assistant`,``)),t}function ge(e,t){if(!t||t.length===0)return e;let n=t.map(e=>O(e));return e.length>0&&!t.some(e=>e.type===`text`)?[{type:`input_text`,text:e},...n]:n}function O(e){return e.type===`text`?{type:`input_text`,text:e.text}:e.type===`image_uri`?{type:`input_image`,image_url:e.uri}:e.type===`image_inline`?{type:`input_image`,image_url:`data:${e.mimeType};base64,${e.data}`}:{type:`input_text`,text:(0,n.nonVisualObservationText)(e)??`Unsupported observation`}}function k(e,t){return{role:e,content:t}}async function*_e(e,t){let n=e[Symbol.asyncIterator]();try{for(;!t?.aborted;){let e=await ve(n,t);if(e.done||t?.aborted)break;yield e.value}}finally{t?.aborted&&await n.return?.()}}async function ve(e,t){if(!t)return e.next();if(t.aborted)return{done:!0,value:void 0};let n,r=new Promise(e=>{n=()=>e({done:!0,value:void 0}),t.addEventListener(`abort`,n,{once:!0})});try{return await Promise.race([e.next(),r])}finally{n&&t.removeEventListener(`abort`,n)}}function A(e){G(e);let t=e.output??[];return I({content:e.output_text??B(t),toolCalls:L(t),response:e,reasoning:V(t)})}async function j(e){let t={textParts:[],toolCalls:[],reasoning:U(),thought:{sentText:!1}};for await(let n of _e(e.stream,e.signal))M(t,n,e);return t.completedResponse===void 0?I({content:t.textParts.join(``),toolCalls:t.toolCalls,reasoning:t.reasoning}):ye(t)}function M(e,t,n){if(t.type===`response.output_text.delta`){e.textParts.push(t.delta),n.onTextDelta?.(t.delta);return}if(t.type===`response.reasoning_summary_part.added`){N(e.thought,t);return}if(t.type===`response.reasoning_summary_text.delta`){N(e.thought,t),n.onThinkingDelta?.(P(e.thought,t.delta));return}if(t.type===`response.completed`){e.completedResponse=t.response,W(e.reasoning,V(t.response.output??[]));return}if(t.type===`response.output_item.done`){F(e,t.item);return}if(t.type===`response.error`||t.type===`response.failed`||t.type===`response.incomplete`)throw Error(`OpenAI Responses API failed: ${Te(t)}`)}function N(e,t){(t.item_id!==void 0||t.summary_index!==void 0)&&(e.currentPart=`${t.item_id??``}#${t.summary_index??0}`)}function P(e,t){if(t.length===0)return t;let n=e.sentText&&e.currentPart!==e.sentPart;return e.sentText=!0,e.sentPart=e.currentPart,n?`
|
|
2
|
-
|
|
3
|
-
${t}`:t}function F(e,t){if(R(t)){e.toolCalls.push(z(t));return}H(t)&&W(e.reasoning,V([t]))}function ye(e){let t=e.completedResponse;if(t===void 0)throw Error(`OpenAI Responses stream completed without response metadata`);G(t);let n=t.output??[],r=L(n),i=e.textParts.length>0?e.textParts.join(``):t.output_text??B(n),a=V(n);return W(a,e.reasoning),I({content:i,toolCalls:r.length>0?r:e.toolCalls,response:t,reasoning:a})}function I(e){return{id:(0,t.randomUUID)(),role:`assistant`,content:e.content,state:`complete`,timestamp:new Date,...e.toolCalls.length>0&&{toolCalls:e.toolCalls},...e.response?.usage!==void 0&&{usage:xe(e.response.usage)},metadata:{...be(e.response,e.reasoning),...e.response?.usage!==void 0&&{usageProvenance:e.response.usage.input_tokens!==void 0&&e.response.usage.output_tokens!==void 0&&e.response.usage.total_tokens!==void 0?`complete`:`partial`}}}}function be(e,t){return{providerApiSurface:`responses`,...e?.id!==void 0&&{responseId:e.id},...e?.model!==void 0&&{model:e.model},...e?.status!==void 0&&{finishReason:e.status},...t.reasoningSummaryCount>0&&{reasoningSummaryCount:t.reasoningSummaryCount,reasoningSummaries:t.reasoningSummaries},...t.hasEncryptedReasoning&&{hasEncryptedReasoning:!0}}}function xe(e){let t=e.input_tokens_details?.cached_tokens;return{promptTokens:e.input_tokens??0,completionTokens:e.output_tokens??0,...e.total_tokens!==void 0&&{totalTokens:e.total_tokens},...typeof t==`number`&&{cacheReadTokens:t}}}function L(e){return e.filter(R).map(e=>z(e))}function R(e){return e.type===`function_call`&&`call_id`in e&&`name`in e&&`arguments`in e}function z(e){return{id:e.call_id,type:`function`,function:{name:e.name,arguments:e.arguments}}}function B(e){return e.filter(Ce).flatMap(e=>e.content).map(Se).join(``)}function Se(e){return e.type===`refusal`?e.refusal:e.text}function Ce(e){return e.type===`message`&&`content`in e&&Array.isArray(e.content)}function V(e){let t=U();for(let n of e){if(!H(n))continue;let e=n.summary?.map(e=>e.text).filter(we)??[];t.reasoningSummaryCount+=e.length,t.reasoningSummaries.push(...e),t.hasEncryptedReasoning=t.hasEncryptedReasoning||!!n.encrypted_content}return t}function H(e){return e.type===`reasoning`}function U(){return{reasoningSummaryCount:0,reasoningSummaries:[],hasEncryptedReasoning:!1}}function W(e,t){e.reasoningSummaryCount+=t.reasoningSummaryCount,e.reasoningSummaries.push(...t.reasoningSummaries),e.hasEncryptedReasoning=e.hasEncryptedReasoning||t.hasEncryptedReasoning}function we(e){return e!==void 0}function G(e){if(e.status===`failed`||e.status===`incomplete`)throw Error(`OpenAI Responses API failed: ${e.error?.message??e.status}`)}function Te(e){return e.message??e.error?.message??e.response?.error?.message??`unknown error`}async function Ee(e){let t=e.chatOptions?.onTextDelta??e.onTextDelta;if(t)return K({...e,chatOptions:{...e.chatOptions,onTextDelta:t}});if(!e.client)throw Error(`OpenAI Responses client not available.`);try{let t=q(e);e.chatOptions?.onProviderNativeRawPayload?.({provider:`openai`,apiSurface:`responses`,payloadKind:`request`,payload:t});let n=await e.client.responses.create(t,x(e.chatOptions?.signal,e.requestHeaders));return e.chatOptions?.onProviderNativeRawPayload?.({provider:`openai`,apiSurface:`responses`,payloadKind:`response`,payload:n}),b(A(n),y(n))}catch(e){throw(0,n.toProviderError)(e,`openai`,`OpenAI responses failed`)}}async function*De(e){let t={deltas:[]},n=e.chatOptions?.onTextDelta??e.onTextDelta,r=K({...e,chatOptions:{...e.chatOptions,onTextDelta:e=>{n?.(e),je(t,ke(e))}}}).then(e=>Me(t,e)).catch(e=>Ne(t,Ie(e)));yield*Ae(t),await r}async function K(e){if(!e.client)throw Error(`OpenAI Responses client not available.`);try{let t=Oe(e);e.chatOptions?.onProviderNativeRawPayload?.({provider:`openai`,apiSurface:`responses`,payloadKind:`request`,payload:t});let{data:n,providerRequestId:r}=await v(e.client.responses.create(t,x(e.chatOptions?.signal,e.requestHeaders)));return b(await j({stream:(0,i.observeProviderNativeRawPayloadStream)(n,{provider:`openai`,apiSurface:`responses`,onProviderNativeRawPayload:e.chatOptions?.onProviderNativeRawPayload}),onTextDelta:e.chatOptions?.onTextDelta,onThinkingDelta:e.chatOptions?.onThinkingDelta,signal:e.chatOptions?.signal}),r)}catch(e){throw(0,n.toProviderError)(e,`openai`,`OpenAI responses stream failed`)}}function q(e){let t=e.chatOptions?.model??e.providerOptions.defaultModel;if(!t)throw Error(`Model is required in chat options. Please specify a model in defaultModel configuration.`);let n=pe(e.chatOptions?.tools,e.providerOptions.strictTools),r=ae(e.providerOptions),a=de(e.providerOptions.reasoning,e.chatOptions?.effortResolution);return{...c(e.extraBody),model:t,..._(e.parallelToolCalls),input:fe(e.messages),...n!==void 0&&{tools:n,tool_choice:(0,i.toOpenAIResponsesToolChoice)(e.chatOptions?.toolChoice)},...e.chatOptions?.temperature!==void 0&&{temperature:e.chatOptions.temperature},...e.chatOptions?.maxTokens!==void 0&&{max_output_tokens:e.chatOptions.maxTokens},...r!==void 0&&{text:r},...a!==void 0&&{reasoning:a},...e.providerOptions.includeEncryptedReasoning===!0&&{include:[`reasoning.encrypted_content`]},...e.providerOptions.store!==void 0&&{store:e.providerOptions.store}}}function Oe(e){return{...q(e),stream:!0}}function ke(e){return{id:(0,t.randomUUID)(),role:`assistant`,content:e,state:`complete`,timestamp:new Date,metadata:{providerApiSurface:`responses`,isStreamChunk:!0,isComplete:!1}}}async function*Ae(e){for(;;){let t=e.deltas.shift();if(t!==void 0){yield t;continue}if(e.error!==void 0)throw e.error;if(e.finalMessage!==void 0){yield Fe(e.finalMessage);return}await Pe(e)}}function je(e,t){e.deltas.push(t),J(e)}function Me(e,t){e.finalMessage=t,J(e)}function Ne(e,t){e.error=t,J(e)}function Pe(e){return new Promise(t=>{e.wake=t})}function J(e){e.wake?.(),e.wake=void 0}function Fe(e){return{...e,content:``,metadata:{...e.metadata,isStreamChunk:!0,isComplete:!0}}}function Ie(e){return e instanceof Error?e:Error(String(e))}var Y=class extends n.AbstractAIProvider{name=`openai`;version=`1.0.0`;client;options;apiSurface;parallelToolCalls;extraBody;payloadLogger;responseParser;onTextDelta;constructor(e){if(super(e.logger||n.SilentLogger),this.options=e,this.parallelToolCalls=h(e.parallelToolCalls,e.apiSurface),g(this.parallelToolCalls,e.executor!==void 0),this.extraBody=o(e.extraBody),s(this.extraBody,e.executor!==void 0),this.apiSurface=Le(e),Z(this.apiSurface,e.nativeWebTools),e.executor&&(this.executor=e.executor),!this.executor)if(e.client)this.client=e.client;else if(e.apiKey)this.client=new r.default({apiKey:e.apiKey,...e.organization&&{organization:e.organization},...e.timeout&&{timeout:e.timeout},...e.baseURL&&{baseURL:e.baseURL}});else throw Error(`Either OpenAI client, apiKey, or executor is required`);this.responseParser=new le(this.logger),this.payloadLogger=e.payloadLogger}async chat(e,t){g(this.parallelToolCalls,this.executor!==void 0),s(this.extraBody,this.executor!==void 0),this.validateMessages(e),this.validateNativeWebTools(t?.nativeWebTools);let n=this.resolveEffortOptions(t);if(this.executor)try{let t=await this.executeViaExecutorOrDirect(e,n);return t.modelEffortOutcome===void 0&&this.publishModelEffortOutcome(n,`opaque-executor`),t.message}catch(e){throw this.logger.error(`OpenAI Provider executor chat error:`,e instanceof Error?e.message:String(e)),e}if(this.apiSurface===`responses`){let t=await Ee({client:this.client,messages:e,chatOptions:this.projectChatOptions(n),providerOptions:this.options,parallelToolCalls:this.parallelToolCalls,extraBody:this.extraBody,onTextDelta:this.onTextDelta,requestHeaders:this.traceRequestHeaders(n)});return this.publishModelEffortOutcome(n),t}let r=await oe({client:this.client,messages:e,chatOptions:this.projectChatOptions(n),providerOptions:this.options,parallelToolCalls:this.parallelToolCalls,extraBody:this.extraBody,payloadLogger:this.payloadLogger,responseParser:this.responseParser,onTextDelta:this.onTextDelta,requestHeaders:this.traceRequestHeaders(n)});return this.publishModelEffortOutcome(n),r}async*chatStream(e,t){g(this.parallelToolCalls,this.executor!==void 0),s(this.extraBody,this.executor!==void 0),this.validateNativeWebTools(t?.nativeWebTools);let n=this.resolveEffortOptions(t);if(this.executor)try{let t=!1;for await(let r of this.executeStreamViaExecutorOrDirect(e,n))r.kind===`message`?yield r.message:t=r.modelEffortOutcome!==void 0;t||this.publishModelEffortOutcome(n,`opaque-executor`);return}catch(e){throw this.logger.error(`OpenAI Provider executor stream error:`,e instanceof Error?e.message:String(e)),e}yield*this.streamDirect(e,n)}async*streamDirect(e,t){if(this.apiSurface===`responses`){yield*De({client:this.client,messages:e,chatOptions:this.projectChatOptions(t),providerOptions:this.options,parallelToolCalls:this.parallelToolCalls,extraBody:this.extraBody,onTextDelta:this.onTextDelta,requestHeaders:this.traceRequestHeaders(t)}),this.publishModelEffortOutcome(t);return}yield*S({client:this.client,messages:e,chatOptions:this.projectChatOptions(t),providerOptions:this.options,parallelToolCalls:this.parallelToolCalls,extraBody:this.extraBody,payloadLogger:this.payloadLogger,responseParser:this.responseParser,onTextDelta:this.onTextDelta,requestHeaders:this.traceRequestHeaders(t)}),this.publishModelEffortOutcome(t)}endpointIsVendorDefault(){return this.options.baseURL===void 0}canPropagateTraceContext(){return!this.executor&&this.effectiveBaseUrl()!==void 0}effectiveBaseUrl(){let e=this.client?.baseURL;return typeof e==`string`&&e.length>0?e:void 0}traceRequestHeaders(e){return{...this.canPropagateTraceContext()?(0,n.traceHeadersFor)(this.effectiveBaseUrl(),e?.outboundTraceContext):{},...this.options.durableOperations===!0?{"Idempotency-Key":(0,t.randomUUID)()}:{}}}effortTable(){return this.endpointIsVendorDefault()&&this.apiSurface===`responses`?ce:void 0}resolveEffortOptions(e){if(e?.effort===void 0||e.effortResolution!==void 0)return e;let t=e.model??this.options.defaultModel;return t===void 0?e:{...e,effortResolution:(0,n.resolveModelEffort)(this.effortTable(),t,e.effort)}}projectionProfile(){return this.options.strictTools?{...n.STRICT_TOOL_SCHEMA_PROFILE,providerName:`openai`}:{...n.PERMISSIVE_TOOL_SCHEMA_PROFILE,providerName:`openai`}}projectChatOptions(e){if(!e?.tools)return e;let t=e.model??this.options.defaultModel??``,n=this.projectTools(e.tools,t);return{...e,tools:n&&n.length>0?n:void 0}}publishModelEffortOutcome(e,t){let r=e?.effortResolution,i=e?.onModelEffortOutcome;if(r===void 0||i===void 0)return;let a=t===void 0?r.effective!==null&&r.disposition!==`model-default`?{state:`sent`,id:`responses.reasoning.effort`}:{state:`omitted`,reason:r.disposition===`model-default`?`provider-default-selection`:`model-effort-not-applied`}:{state:`omitted`,reason:t},o=t===void 0?{state:`sent`}:{state:`not-dispatched`,reason:t};try{i((0,n.createModelEffortOutcome)(r,{nativeControl:a,providerDispatch:o}))}catch(e){this.logger.warn(`Model-effort outcome observer failed`,{error:e instanceof Error?e.message:String(e)})}}supportsTools(){return!0}getCapabilities(){let e=this.apiSurface===`chat-completions`?`openai-compatible-chat-completions`:`openai-responses`;return{functionCalling:{supported:!0},nativeWebTools:{webSearch:{supported:!1,enabled:!1,source:e,reason:X(this.apiSurface,`search`)},webFetch:{supported:!1,enabled:!1,source:e,reason:X(this.apiSurface,`fetch`)}}}}validateConfig(){return!!this.client&&!!this.options}async dispose(){}validateMessages(e){super.validateMessages(e);for(let t of e)if(t.role===`assistant`){let e=t;if(e.toolCalls&&e.toolCalls.length>0&&e.content===``)continue}}};function Le(e){return e.apiSurface===void 0?e.baseURL?`chat-completions`:`responses`:e.apiSurface}function X(e,t){return e===`chat-completions`?`OpenAI-compatible Chat Completions endpoints support declared function tools, not provider-native web ${t}.`:`OpenAI Responses native web ${t} is not wired in this provider version.`}function Z(e,t){if(t?.webSearch===!0||t?.webFetch===!0)throw Error(`Provider openai native web search/fetch is not supported for apiSurface ${e} in this provider version.`)}var Re=class{static filterMessagesForOpenAI(e){return e.filter(e=>e.role===`user`||e.role===`assistant`||e.role===`system`||e.role===`tool`&&!!(e.toolCallId&&e.toolCallId.trim()!==``&&e.toolCallId!==`unknown`))}static toOpenAIFormat(e){return this.filterMessagesForOpenAI(e).map(e=>this.convertMessage(e))}static convertMessage(e){let t=e.role;if(t===`user`)return{role:`user`,content:e.content};if(t===`assistant`){let t=e;return t.toolCalls&&t.toolCalls.length>0?{role:`assistant`,content:t.content===``?null:t.content||null,tool_calls:t.toolCalls.map(e=>({id:e.id,type:`function`,function:{name:e.function.name,arguments:e.function.arguments}}))}:{role:`assistant`,content:t.content===null||t.content===``?null:t.content||``}}if(t===`system`)return{role:`system`,content:e.content};if(t===`tool`){if(!e.toolCallId||e.toolCallId.trim()===``)throw Error(`Tool message missing toolCallId: ${JSON.stringify(e)}`);return{role:`tool`,content:e.content,tool_call_id:e.toolCallId}}throw Error(`Unsupported message role: ${t}`)}static addSystemPromptIfNeeded(e,t){return!t||e.some(e=>e.role===`system`)?e:[{role:`system`,content:t},...e]}};const Q=`$ENV:OPENAI_API_KEY`,ze=[{kind:`api-key`,label:`OpenAI API keys`,url:`https://platform.openai.com/api-keys`,sourceUrl:`https://developers.openai.com/api/reference/overview#authentication`,lastVerifiedAt:`2026-05-08`}];function Be(){return{type:`openai`,displayName:`OpenAI`,description:`GPT series — general-purpose assistant. API key required.`,category:`cloud-paid`,costPerTokenUsd:.001,defaults:{apiKey:Q},endpoint:{host:`api.openai.com`,port:443},modelCatalog:{status:`unavailable`,sourceUrl:`https://platform.openai.com/docs/api-reference/models/list`,message:`OpenAI model availability should be discovered live from GET /v1/models.`},setupHelpLinks:ze,setupSteps:[{key:`model`,title:`OpenAI model`,required:!0},{key:`apiKey`,title:`OpenAI API key`,defaultValue:Q,masked:!0}],requiresApiKey:!0,probeProfile:i.probeOpenAICompatibleProfile,destinationEnvironment:[`OPENAI_BASE_URL`,`OPENAI_ORG_ID`,`OPENAI_PROJECT_ID`],createProvider:e=>{let t=h(e.options?.parallelToolCalls,e.options?.apiSurface),n=o(e.options?.extraBody),r=He(e.options),i=Ue(e.options);return We(e.baseURL,r,i),new Y({apiKey:Ve(e.apiKey),...e.baseURL!==void 0&&{baseURL:e.baseURL},...e.timeout!==void 0&&{timeout:e.timeout},...r!==void 0&&{apiSurface:r},...t!==void 0&&{parallelToolCalls:t},...n!==void 0&&{extraBody:n},...i!==void 0&&{nativeWebTools:i},...e.options?.durableOperations===!0&&{durableOperations:!0},defaultModel:e.model})}}}function Ve(e){if(!e)throw Error(`Provider openai requires apiKey`);return e}function He(e){let t=e?.apiSurface;if(t===`responses`||t===`chat-completions`)return t}function Ue(e){let t=$(e?.nativeWebTools)??$(e?.builtInWebTools);if(t!==void 0)return t}function $(e){if(e==null||e instanceof Date||Array.isArray(e)||typeof e!=`object`)return;let t=e.webSearch,n=e.webFetch;return{...typeof t==`boolean`&&{webSearch:t},...typeof n==`boolean`&&{webFetch:n}}}function We(e,t,n){if(n?.webSearch===!0||n?.webFetch===!0)throw Error(e!==void 0||t===`chat-completions`?`Provider openai profile uses an OpenAI-compatible Chat Completions endpoint; native web search/fetch is not supported for this profile. Use local WebSearch/WebFetch tools or a provider with documented hosted web support.`:`Provider openai native web search/fetch is not wired in this provider version. Use local WebSearch/WebFetch tools or a provider with documented hosted web support.`)}exports.DEFAULT_OPENAI_PROVIDER_API_KEY_REFERENCE=Q,exports.DEFAULT_OPENAI_PROVIDER_MODEL=void 0,exports.OpenAIConversationAdapter=Re,exports.OpenAIProvider=Y,exports.createOpenAIProviderDefinition=Be;
|
|
@@ -1 +0,0 @@
|
|
|
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;;;KAIU,oEAKC;YACG,cAAc;;;KAGlB,mBAAmB,SAAS,eAAe;;;;KAK3C,4EAMR,8BACA,+BACA,mCACA,mBACA,SACA,iBACA,UACA,YACA,2BACA;GACG,cAAc;;;;;UAKJ;;EAEf;;;;GAIC,cAAc;;;;EAKf;;;;EAKA;;;;EAKA;;;;;;;EAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA;;;;EAKA;;;;;;;EAQA,aAAa;;;;;;;EAQb;;;;EAKA,aAAa;;;;;EAMb,YAAY;;;;EAKZ;;;;EAKA;;;;;;;;;;;;;;;;;EAkBA;;;;;;;WAQS;;;;;;;WAQA,YAAY;;;;;;;;EASrB,iBAAiB;;;;EAKjB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BT,gBAAgB;;;;;;;;;;;;;;;;;;EAmBhB,WAAW;;;;;EAMX,SAAS;;;;;;;;;;;;cC9NE,uBAAuB;WAChB;WACA;mBAED;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;;;;;;;EAQjB,cAAc;EAEF,YAAA,SAAS;EAiCN,KACb,UAAU,qBACV,UAAU,eACT,QAAQ;EAsDK,WACd,UAAU,qBACV,UAAU,eACT,cAAc;UAmCF;;;;;;;;;;EA2Cf;;;;;;EASA;UAIQ;UAKA;EASC,eAAe;UAMhB;;;;;YAcW,qBAAqB;;;;;;;;UAahC;UAYA;EAiCC;EAIA,mBAAmB;EAwBnB;EAIM,WAAW;YAIP,iBAAiB,UAAU;;;;;;;;;;;;cCxWnC;;;;;;;;;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;;;;cCxHJ;cACA;iBAeG,kCAAkC"}
|
package/dist/node/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","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;;;KAIU,oEAKC;YACG,cAAc;;;KAGlB,mBAAmB,SAAS,eAAe;;;;KAK3C,4EAMR,8BACA,+BACA,mCACA,mBACA,SACA,iBACA,UACA,YACA,2BACA;GACG,cAAc;;;;;UAKJ;;EAEf;;;;GAIC,cAAc;;;;EAKf;;;;EAKA;;;;EAKA;;;;;;;EAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA;;;;EAKA;;;;;;;EAQA,aAAa;;;;;;;EAQb;;;;EAKA,aAAa;;;;;EAMb,YAAY;;;;EAKZ;;;;EAKA;;;;;;;;;;;;;;;;;EAkBA;;;;;;;WAQS;;;;;;;WAQA,YAAY;;;;;;;;EASrB,iBAAiB;;;;EAKjB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BT,gBAAgB;;;;;;;;;;;;;;;;;;EAmBhB,WAAW;;;;;EAMX,SAAS;;;;;;;;;;;;cC9NE,uBAAuB;WAChB;WACA;mBAED;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;;;;;;;EAQjB,cAAc;EAEF,YAAA,SAAS;EAiCN,KACb,UAAU,qBACV,UAAU,eACT,QAAQ;EAsDK,WACd,UAAU,qBACV,UAAU,eACT,cAAc;UAmCF;;;;;;;;;;EA2Cf;;;;;;EASA;UAIQ;UAKA;EASC,eAAe;UAMhB;;;;;YAcW,qBAAqB;;;;;;;;UAahC;UAYA;EAiCC;EAIA,mBAAmB;EAwBnB;EAIM,WAAW;YAIP,iBAAiB,UAAU;;;;;;;;;;;;cCxWnC;;;;;;;;;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;;;;cCxHJ;cACA;iBAeG,kCAAkC"}
|