@omnicross/core 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ApiConverter.cjs +2 -2
- package/dist/ApiConverter.js +1 -1
- package/dist/{CompletionService-DdWaAxq0.d.ts → CompletionService-C3BX0Ovy.d.ts} +4 -3
- package/dist/{CompletionService-D3a47vdU.d.cts → CompletionService-kNA17cfI.d.cts} +4 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +7 -5
- package/dist/auth/GeminiCodeAssistProjectResolver.js +5 -3
- package/dist/{chunk-HRRYG2AX.js → chunk-23S5OPIO.js} +10 -1
- package/dist/chunk-25GXJCEZ.cjs +40 -0
- package/dist/chunk-2JYRIADS.js +40 -0
- package/dist/chunk-3Z5BQZFM.cjs +52 -0
- package/dist/{chunk-4VAVYUZS.cjs → chunk-4VLRHHFE.cjs} +82 -40
- package/dist/{chunk-VACWOIRE.cjs → chunk-4VZX5F4T.cjs} +39 -15
- package/dist/{chunk-FTQ7IQUC.js → chunk-6CL5HTPQ.js} +52 -10
- package/dist/chunk-6QQG7YG3.cjs +153 -0
- package/dist/{chunk-SU2GCLAC.cjs → chunk-6VUQPOV3.cjs} +359 -60
- package/dist/chunk-7AK7B36B.cjs +44 -0
- package/dist/{chunk-5ZQBEOMD.js → chunk-AT7B7SOZ.js} +25 -2
- package/dist/{chunk-IK3KE3AU.js → chunk-DE2SRBFZ.js} +1 -1
- package/dist/chunk-DLXZEZWO.cjs +285 -0
- package/dist/{chunk-UHGVBFU3.js → chunk-EBLFCNPY.js} +38 -14
- package/dist/chunk-EJLH6NFT.cjs +166 -0
- package/dist/chunk-HVBBDBS3.cjs +350 -0
- package/dist/{chunk-7Y47UCF2.js → chunk-IFXJ2BG7.js} +5 -38
- package/dist/{chunk-46ZIFWYG.cjs → chunk-IIRPUVPH.cjs} +7 -1
- package/dist/{chunk-YGXJGRFI.cjs → chunk-KBM2W6UY.cjs} +111 -24
- package/dist/{chunk-OCEUVQHW.cjs → chunk-KCVJWJST.cjs} +73 -3
- package/dist/chunk-LB6EBS6Y.js +69 -0
- package/dist/{chunk-C7PSERMH.js → chunk-LVUCAWMK.js} +1 -1
- package/dist/chunk-MKF46GNZ.js +350 -0
- package/dist/{chunk-HYN75H6G.cjs → chunk-MUHWHQVM.cjs} +1 -1
- package/dist/{chunk-Z7Y2NPHY.js → chunk-N5T4M4GU.js} +1 -1
- package/dist/{chunk-TIER4SUC.js → chunk-OEWZUX4G.js} +346 -47
- package/dist/chunk-OF3BECU2.cjs +69 -0
- package/dist/{chunk-RSJ3TWJQ.cjs → chunk-OKMJLEXX.cjs} +5 -5
- package/dist/chunk-OPRS4IQZ.js +153 -0
- package/dist/{chunk-XK5CIRMQ.js → chunk-SIZQQD6T.js} +72 -2
- package/dist/{chunk-DKPXN34V.cjs → chunk-SQYVORNP.cjs} +1334 -510
- package/dist/chunk-SYQF7OIR.js +52 -0
- package/dist/{chunk-S4WBV25P.js → chunk-TOVPMMHM.js} +111 -24
- package/dist/{chunk-QYTT6GE3.js → chunk-UDCC7EMR.js} +1093 -269
- package/dist/{chunk-E3UCVHLP.cjs → chunk-UNWKG6EI.cjs} +5 -38
- package/dist/{chunk-ZLX3KGXX.js → chunk-UX7VWA46.js} +135 -23
- package/dist/{chunk-7YN22L2H.cjs → chunk-V4TXMEJS.cjs} +5 -5
- package/dist/chunk-VRFBB5DB.js +44 -0
- package/dist/chunk-WB6PH56J.js +166 -0
- package/dist/{chunk-G2UTNSGU.js → chunk-WNKWAEUR.js} +7 -1
- package/dist/{chunk-SUEGJ75D.cjs → chunk-WYTEQ4Q5.cjs} +25 -2
- package/dist/{chunk-5ENKBSWO.js → chunk-YJVHCHQX.js} +42 -6
- package/dist/{chunk-VQY5W4YW.cjs → chunk-YK57NMIF.cjs} +44 -8
- package/dist/{chunk-KFI44N2R.cjs → chunk-YNJNTCSQ.cjs} +10 -1
- package/dist/completion/ApiKeyPoolService.cjs +12 -0
- package/dist/completion/ApiKeyPoolService.d.cts +6 -0
- package/dist/completion/ApiKeyPoolService.d.ts +6 -0
- package/dist/completion/ApiKeyPoolService.js +12 -0
- package/dist/completion/CompletionService.cjs +27 -24
- package/dist/completion/CompletionService.d.cts +2 -1
- package/dist/completion/CompletionService.d.ts +2 -1
- package/dist/completion/CompletionService.js +26 -23
- package/dist/completion.cjs +27 -24
- package/dist/completion.d.cts +2 -1
- package/dist/completion.d.ts +2 -1
- package/dist/completion.js +26 -23
- package/dist/index.cjs +53 -29
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +56 -32
- package/dist/{keyPolicy-Cp0FntZl.d.cts → keyPolicy-zdWTu3CQ.d.cts} +1 -1
- package/dist/{keyPolicy-Cp0FntZl.d.ts → keyPolicy-zdWTu3CQ.d.ts} +1 -1
- package/dist/outbound-api/auditCapture.cjs +2 -2
- package/dist/outbound-api/auditCapture.d.cts +5 -3
- package/dist/outbound-api/auditCapture.d.ts +5 -3
- package/dist/outbound-api/auditCapture.js +1 -1
- package/dist/outbound-api/quotaWarn.d.cts +1 -1
- package/dist/outbound-api/quotaWarn.d.ts +1 -1
- package/dist/outbound-api/routeResolver.cjs +2 -2
- package/dist/outbound-api/routeResolver.d.cts +4 -3
- package/dist/outbound-api/routeResolver.d.ts +4 -3
- package/dist/outbound-api/routeResolver.js +1 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +1 -0
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +1 -0
- package/dist/outbound-api/types.d.cts +3 -2
- package/dist/outbound-api/types.d.ts +3 -2
- package/dist/outbound-api.cjs +49 -25
- package/dist/outbound-api.d.cts +127 -85
- package/dist/outbound-api.d.ts +127 -85
- package/dist/outbound-api.js +52 -28
- package/dist/pipeline/AccountAllowanceScheduling.cjs +15 -0
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +90 -0
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +90 -0
- package/dist/pipeline/AccountAllowanceScheduling.js +15 -0
- package/dist/pipeline/AccountAllowanceStore.cjs +20 -0
- package/dist/pipeline/AccountAllowanceStore.d.cts +77 -0
- package/dist/pipeline/AccountAllowanceStore.d.ts +77 -0
- package/dist/pipeline/AccountAllowanceStore.js +20 -0
- package/dist/pipeline/AuthSource.d.cts +11 -2
- package/dist/pipeline/AuthSource.d.ts +11 -2
- package/dist/pipeline/BoundAccountSelectionError.cjs +10 -0
- package/dist/pipeline/BoundAccountSelectionError.d.cts +28 -0
- package/dist/pipeline/BoundAccountSelectionError.d.ts +28 -0
- package/dist/pipeline/BoundAccountSelectionError.js +10 -0
- package/dist/pipeline/LlmConfigProviderAuth.d.cts +1 -0
- package/dist/pipeline/LlmConfigProviderAuth.d.ts +1 -0
- package/dist/pipeline/SubscriptionAccountHealth.cjs +4 -2
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +34 -6
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +34 -6
- package/dist/pipeline/SubscriptionAccountHealth.js +3 -1
- package/dist/pipeline/SubscriptionAuthSource.cjs +5 -2
- package/dist/pipeline/SubscriptionAuthSource.d.cts +1 -0
- package/dist/pipeline/SubscriptionAuthSource.d.ts +1 -0
- package/dist/pipeline/SubscriptionAuthSource.js +4 -1
- package/dist/pipeline/SubscriptionAuthStrategy.d.cts +8 -3
- package/dist/pipeline/SubscriptionAuthStrategy.d.ts +8 -3
- package/dist/pipeline/executeProviderCall.cjs +2 -2
- package/dist/pipeline/executeProviderCall.d.cts +8 -3
- package/dist/pipeline/executeProviderCall.d.ts +8 -3
- package/dist/pipeline/executeProviderCall.js +1 -1
- package/dist/pipeline/resolveProviderChain.d.cts +2 -3
- package/dist/pipeline/resolveProviderChain.d.ts +2 -3
- package/dist/pipeline/resolveSubscriptionChain.d.cts +1 -0
- package/dist/pipeline/resolveSubscriptionChain.d.ts +1 -0
- package/dist/pipeline/upstreamFetch.cjs +4 -2
- package/dist/pipeline/upstreamFetch.d.cts +6 -0
- package/dist/pipeline/upstreamFetch.d.ts +6 -0
- package/dist/pipeline/upstreamFetch.js +3 -1
- package/dist/pipeline/upstreamTrace.cjs +14 -0
- package/dist/pipeline/upstreamTrace.d.cts +85 -0
- package/dist/pipeline/upstreamTrace.d.ts +85 -0
- package/dist/pipeline/upstreamTrace.js +14 -0
- package/dist/ports/pricing-store.d.cts +4 -3
- package/dist/ports/pricing-store.d.ts +4 -3
- package/dist/ports.d.cts +4 -3
- package/dist/ports.d.ts +4 -3
- package/dist/provider-proxy/ProviderProxy.cjs +27 -24
- package/dist/provider-proxy/ProviderProxy.d.cts +1 -0
- package/dist/provider-proxy/ProviderProxy.d.ts +1 -0
- package/dist/provider-proxy/ProviderProxy.js +26 -23
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +31 -24
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +50 -5
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +50 -5
- package/dist/provider-proxy/ingress/providerProxyShared.js +30 -23
- package/dist/provider-proxy/matchText.cjs +4 -2
- package/dist/provider-proxy/matchText.d.cts +41 -6
- package/dist/provider-proxy/matchText.d.ts +41 -6
- package/dist/provider-proxy/matchText.js +3 -1
- package/dist/provider-proxy/types.d.cts +30 -2
- package/dist/provider-proxy/types.d.ts +30 -2
- package/dist/provider-proxy.cjs +27 -24
- package/dist/provider-proxy.d.cts +1 -0
- package/dist/provider-proxy.d.ts +1 -0
- package/dist/provider-proxy.js +26 -23
- package/dist/{routeResolver-C4T7yClx.d.ts → routeResolver-CHTv_Bs5.d.ts} +1 -1
- package/dist/{routeResolver-CB3tvJKy.d.cts → routeResolver-kepxnfcC.d.cts} +1 -1
- package/dist/transformer/TransformerChainExecutor.cjs +2 -2
- package/dist/transformer/TransformerChainExecutor.js +1 -1
- package/dist/transformer/transformers/AnthropicTransformer.cjs +2 -2
- package/dist/transformer/transformers/AnthropicTransformer.js +1 -1
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
- package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
- package/dist/transformer/transformers/GeminiTransformer.js +2 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +1 -1
- package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +1 -1
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
- package/dist/transformer/transformers/OpenAITransformer.cjs +6 -0
- package/dist/transformer/transformers/OpenAITransformer.d.cts +68 -0
- package/dist/transformer/transformers/OpenAITransformer.d.ts +68 -0
- package/dist/transformer/transformers/OpenAITransformer.js +6 -0
- package/dist/transformer/transformers.cjs +8 -14
- package/dist/transformer/transformers.d.cts +12 -48
- package/dist/transformer/transformers.d.ts +12 -48
- package/dist/transformer/transformers.js +11 -17
- package/dist/transformer/types.d.cts +17 -0
- package/dist/transformer/types.d.ts +17 -0
- package/dist/transformer.cjs +11 -12
- package/dist/transformer.d.cts +1 -2
- package/dist/transformer.d.ts +1 -2
- package/dist/transformer.js +11 -12
- package/dist/{types-B8Arpxn0.d.cts → types-H3wGZSOo.d.cts} +134 -7
- package/dist/{types-lgPYQuZS.d.ts → types-hsoKrVQS.d.ts} +134 -7
- package/dist/usage/pricing-engine.cjs +2 -2
- package/dist/usage/pricing-engine.d.cts +9 -1
- package/dist/usage/pricing-engine.d.ts +9 -1
- package/dist/usage/pricing-engine.js +1 -1
- package/dist/usage.cjs +2 -2
- package/dist/usage.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-C72S6TTV.cjs +0 -49
- package/dist/chunk-DWKQZ2SK.cjs +0 -254
- package/dist/chunk-IAXWICZU.js +0 -69
- package/dist/chunk-QWBWGODS.cjs +0 -69
- package/dist/chunk-RGTR7CIO.cjs +0 -235
- package/dist/chunk-VPBAUQ2M.js +0 -235
- package/dist/chunk-YMFAJFQT.cjs +0 -173
- package/dist/chunk-Z7LUNECE.js +0 -49
- package/dist/chunk-ZJZAOKI7.js +0 -254
- package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +0 -6
- package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +0 -51
- package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +0 -51
- package/dist/transformer/transformers/OpenCodeGoTransformer.js +0 -6
- package/dist/transformer/transformers/ReasoningTransformer.cjs +0 -6
- package/dist/transformer/transformers/ReasoningTransformer.d.cts +0 -47
- package/dist/transformer/transformers/ReasoningTransformer.d.ts +0 -47
- package/dist/transformer/transformers/ReasoningTransformer.js +0 -6
|
@@ -45,10 +45,12 @@ var OpenAIResponseTransformer = class {
|
|
|
45
45
|
if (msg.role === "assistant" && msg.tool_calls?.length) {
|
|
46
46
|
input.push(entry);
|
|
47
47
|
for (const tc of msg.tool_calls) {
|
|
48
|
+
const callId = tc.id;
|
|
49
|
+
const itemId = callId.startsWith("fc_") ? callId : `fc_${callId.replace(/^(call_|fc_)/, "")}`;
|
|
48
50
|
input.push({
|
|
49
51
|
type: "function_call",
|
|
50
|
-
id:
|
|
51
|
-
call_id:
|
|
52
|
+
id: itemId,
|
|
53
|
+
call_id: callId,
|
|
52
54
|
name: tc.function.name,
|
|
53
55
|
arguments: tc.function.arguments
|
|
54
56
|
});
|
|
@@ -61,7 +63,11 @@ var OpenAIResponseTransformer = class {
|
|
|
61
63
|
const body = {
|
|
62
64
|
model: request.model,
|
|
63
65
|
input,
|
|
64
|
-
stream:
|
|
66
|
+
// codex's backend REQUIRES `stream:true` (it 400s with "Stream must be
|
|
67
|
+
// set to true" otherwise). Always force it; a non-streaming CLIENT is
|
|
68
|
+
// served by aggregating the SSE upstream of the wire (the ingress buffers
|
|
69
|
+
// it into a single message), not by asking codex for a non-streaming reply.
|
|
70
|
+
stream: true,
|
|
65
71
|
// `store:false` is required by the codex backend and accepted by the
|
|
66
72
|
// public Responses API (which defaults to store:true). Always set it so
|
|
67
73
|
// codex relays (no discoverable url token) work without configuration.
|
|
@@ -98,24 +104,37 @@ var OpenAIResponseTransformer = class {
|
|
|
98
104
|
async transformRequestOut(request, _context) {
|
|
99
105
|
const req = request;
|
|
100
106
|
const messages = [];
|
|
107
|
+
let codexTools = null;
|
|
108
|
+
const instructions = typeof req.instructions === "string" ? req.instructions.trim() : "";
|
|
109
|
+
if (instructions) {
|
|
110
|
+
messages.push({ role: "system", content: instructions });
|
|
111
|
+
}
|
|
101
112
|
if (req.input) {
|
|
102
113
|
for (const item of req.input) {
|
|
103
114
|
const entry = item;
|
|
104
|
-
|
|
115
|
+
const itemType = typeof entry.type === "string" ? entry.type : void 0;
|
|
116
|
+
if (itemType && SKIPPED_INPUT_ITEM_TYPES.has(itemType)) continue;
|
|
117
|
+
if (itemType === "additional_tools") {
|
|
118
|
+
codexTools = collectCodexTools(entry);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (itemType === "custom_tool_call_output") {
|
|
105
122
|
messages.push({
|
|
106
123
|
role: "tool",
|
|
107
|
-
content: entry.output
|
|
124
|
+
content: flattenContent(entry.output),
|
|
108
125
|
tool_call_id: entry.call_id || void 0
|
|
109
126
|
});
|
|
110
127
|
continue;
|
|
111
128
|
}
|
|
112
|
-
if (
|
|
129
|
+
if (itemType === "custom_tool_call") {
|
|
113
130
|
const toolCall = {
|
|
114
131
|
id: (entry.call_id ?? entry.id) || "",
|
|
115
132
|
type: "function",
|
|
116
133
|
function: {
|
|
117
134
|
name: entry.name || "",
|
|
118
|
-
arguments:
|
|
135
|
+
arguments: JSON.stringify({
|
|
136
|
+
input: typeof entry.input === "string" ? entry.input : ""
|
|
137
|
+
})
|
|
119
138
|
}
|
|
120
139
|
};
|
|
121
140
|
const last = messages[messages.length - 1];
|
|
@@ -126,17 +145,38 @@ var OpenAIResponseTransformer = class {
|
|
|
126
145
|
}
|
|
127
146
|
continue;
|
|
128
147
|
}
|
|
129
|
-
|
|
130
|
-
if (role === "developer") {
|
|
148
|
+
if (itemType === "function_call_output") {
|
|
131
149
|
messages.push({
|
|
132
|
-
role: "
|
|
133
|
-
content:
|
|
150
|
+
role: "tool",
|
|
151
|
+
content: flattenContent(entry.output),
|
|
152
|
+
tool_call_id: entry.call_id || void 0
|
|
134
153
|
});
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (itemType === "function_call") {
|
|
157
|
+
const toolCall = {
|
|
158
|
+
id: (entry.call_id ?? entry.id) || "",
|
|
159
|
+
type: "function",
|
|
160
|
+
function: {
|
|
161
|
+
name: entry.name || "",
|
|
162
|
+
arguments: typeof entry.arguments === "string" ? entry.arguments : ""
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const last = messages[messages.length - 1];
|
|
166
|
+
if (last && last.role === "assistant") {
|
|
167
|
+
(last.tool_calls ??= []).push(toolCall);
|
|
168
|
+
} else {
|
|
169
|
+
messages.push({ role: "assistant", content: null, tool_calls: [toolCall] });
|
|
170
|
+
}
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const role = entry.role;
|
|
174
|
+
const text = flattenContent(entry.content);
|
|
175
|
+
if (!text) continue;
|
|
176
|
+
if (role === "developer" || role === "system") {
|
|
177
|
+
messages.push({ role: "system", content: text });
|
|
135
178
|
} else if (role === "user" || role === "assistant") {
|
|
136
|
-
messages.push({
|
|
137
|
-
role,
|
|
138
|
-
content: typeof entry.content === "string" ? entry.content : JSON.stringify(entry.content)
|
|
139
|
-
});
|
|
179
|
+
messages.push({ role, content: text });
|
|
140
180
|
}
|
|
141
181
|
}
|
|
142
182
|
}
|
|
@@ -153,15 +193,32 @@ var OpenAIResponseTransformer = class {
|
|
|
153
193
|
enabled: true
|
|
154
194
|
};
|
|
155
195
|
}
|
|
196
|
+
const tools = [];
|
|
156
197
|
if (req.tools?.length) {
|
|
157
|
-
|
|
158
|
-
type
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
198
|
+
tools.push(
|
|
199
|
+
...req.tools.filter((t) => t.type === "function").map((t) => ({
|
|
200
|
+
type: "function",
|
|
201
|
+
function: {
|
|
202
|
+
name: t.name || "",
|
|
203
|
+
description: t.description || "",
|
|
204
|
+
parameters: t.parameters || {}
|
|
205
|
+
}
|
|
206
|
+
}))
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
if (codexTools?.tools.length) {
|
|
210
|
+
const declared = new Set(tools.map((t) => t.function.name));
|
|
211
|
+
tools.push(...codexTools.tools.filter((t) => !declared.has(t.function.name)));
|
|
212
|
+
}
|
|
213
|
+
if (tools.length) result.tools = tools;
|
|
214
|
+
if (codexTools?.customToolNames.length || Object.keys(codexTools?.toolNamespaces ?? {}).length) {
|
|
215
|
+
result.meta = {
|
|
216
|
+
...result.meta,
|
|
217
|
+
codexTools: {
|
|
218
|
+
...codexTools.customToolNames.length ? { customToolNames: codexTools.customToolNames } : {},
|
|
219
|
+
...Object.keys(codexTools.toolNamespaces).length ? { toolNamespaces: codexTools.toolNamespaces } : {}
|
|
163
220
|
}
|
|
164
|
-
}
|
|
221
|
+
};
|
|
165
222
|
}
|
|
166
223
|
return result;
|
|
167
224
|
}
|
|
@@ -202,13 +259,14 @@ var OpenAIResponseTransformer = class {
|
|
|
202
259
|
/**
|
|
203
260
|
* Transform OpenAI CC response → Response API format
|
|
204
261
|
*/
|
|
205
|
-
async transformResponseIn(response,
|
|
262
|
+
async transformResponseIn(response, context) {
|
|
206
263
|
const contentType = response.headers.get("Content-Type") ?? "";
|
|
264
|
+
const codexTools = context?.req?.meta?.codexTools;
|
|
207
265
|
if (contentType.includes("text/event-stream")) {
|
|
208
266
|
if (!response.body) {
|
|
209
267
|
throw new Error("Stream response body is null");
|
|
210
268
|
}
|
|
211
|
-
return new Response(convertOpenAIStreamToResponseApi(response.body), {
|
|
269
|
+
return new Response(convertOpenAIStreamToResponseApi(response.body, codexTools), {
|
|
212
270
|
headers: {
|
|
213
271
|
"Content-Type": "text/event-stream",
|
|
214
272
|
"Cache-Control": "no-cache",
|
|
@@ -217,16 +275,114 @@ var OpenAIResponseTransformer = class {
|
|
|
217
275
|
});
|
|
218
276
|
}
|
|
219
277
|
const data = await response.json();
|
|
220
|
-
return new Response(JSON.stringify(convertOpenAIJsonToResponseApi(data)), {
|
|
278
|
+
return new Response(JSON.stringify(convertOpenAIJsonToResponseApi(data, codexTools)), {
|
|
221
279
|
headers: { "Content-Type": "application/json" }
|
|
222
280
|
});
|
|
223
281
|
}
|
|
224
282
|
};
|
|
283
|
+
var TEXT_PART_TYPES = /* @__PURE__ */ new Set(["text", "input_text", "output_text", "summary_text"]);
|
|
284
|
+
var SKIPPED_INPUT_ITEM_TYPES = /* @__PURE__ */ new Set(["reasoning", "agent_message"]);
|
|
285
|
+
var CUSTOM_TOOL_PARAMETERS = {
|
|
286
|
+
type: "object",
|
|
287
|
+
properties: {
|
|
288
|
+
input: {
|
|
289
|
+
type: "string",
|
|
290
|
+
description: "The complete free-form input for this tool, passed through verbatim."
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
required: ["input"]
|
|
294
|
+
};
|
|
295
|
+
function unwrapCustomToolInput(argumentsJson) {
|
|
296
|
+
try {
|
|
297
|
+
const parsed = JSON.parse(argumentsJson);
|
|
298
|
+
if (parsed && typeof parsed === "object" && typeof parsed.input === "string") {
|
|
299
|
+
return parsed.input;
|
|
300
|
+
}
|
|
301
|
+
} catch {
|
|
302
|
+
}
|
|
303
|
+
return argumentsJson;
|
|
304
|
+
}
|
|
305
|
+
function encodeToolCallItem(callId, name, argumentsJson, status, codexTools) {
|
|
306
|
+
const bareId = callId.replace(/^(call_|fc_|ctc_)/, "");
|
|
307
|
+
if (codexTools?.customToolNames?.includes(name)) {
|
|
308
|
+
return {
|
|
309
|
+
id: `ctc_${bareId}`,
|
|
310
|
+
type: "custom_tool_call",
|
|
311
|
+
status,
|
|
312
|
+
call_id: callId,
|
|
313
|
+
name,
|
|
314
|
+
input: unwrapCustomToolInput(argumentsJson)
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const namespace = codexTools?.toolNamespaces?.[name];
|
|
318
|
+
return {
|
|
319
|
+
id: callId.startsWith("fc_") ? callId : `fc_${bareId}`,
|
|
320
|
+
type: "function_call",
|
|
321
|
+
status,
|
|
322
|
+
call_id: callId,
|
|
323
|
+
name,
|
|
324
|
+
...namespace ? { namespace } : {},
|
|
325
|
+
arguments: argumentsJson
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function collectCodexTools(entry) {
|
|
329
|
+
const result = { tools: [], customToolNames: [], toolNamespaces: {} };
|
|
330
|
+
const visit = (declarations, namespace) => {
|
|
331
|
+
if (!Array.isArray(declarations)) return;
|
|
332
|
+
for (const raw of declarations) {
|
|
333
|
+
if (!raw || typeof raw !== "object") continue;
|
|
334
|
+
const tool = raw;
|
|
335
|
+
const name = typeof tool.name === "string" ? tool.name : "";
|
|
336
|
+
if (!name) continue;
|
|
337
|
+
const description = typeof tool.description === "string" ? tool.description : "";
|
|
338
|
+
if (tool.type === "namespace") {
|
|
339
|
+
visit(tool.tools, name);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (tool.type === "custom") {
|
|
343
|
+
result.customToolNames.push(name);
|
|
344
|
+
result.tools.push({
|
|
345
|
+
type: "function",
|
|
346
|
+
function: {
|
|
347
|
+
name,
|
|
348
|
+
description,
|
|
349
|
+
parameters: CUSTOM_TOOL_PARAMETERS
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
} else if (tool.type === "function") {
|
|
353
|
+
result.tools.push({
|
|
354
|
+
type: "function",
|
|
355
|
+
function: {
|
|
356
|
+
name,
|
|
357
|
+
description,
|
|
358
|
+
parameters: tool.parameters || {}
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
} else {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (namespace) result.toolNamespaces[name] = namespace;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
visit(entry.tools);
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
225
370
|
function flattenContent(content) {
|
|
226
371
|
if (typeof content === "string") return content;
|
|
227
372
|
if (!content) return "";
|
|
228
373
|
if (Array.isArray(content)) {
|
|
229
|
-
return content.
|
|
374
|
+
return content.map((part) => {
|
|
375
|
+
if (typeof part === "string") return part;
|
|
376
|
+
if (!part || typeof part !== "object") return "";
|
|
377
|
+
const c = part;
|
|
378
|
+
if (typeof c.type === "string" && !TEXT_PART_TYPES.has(c.type)) return "";
|
|
379
|
+
return typeof c.text === "string" ? c.text : "";
|
|
380
|
+
}).filter((text) => text !== "").join("\n");
|
|
381
|
+
}
|
|
382
|
+
if (typeof content === "object") {
|
|
383
|
+
const obj = content;
|
|
384
|
+
if (typeof obj.text === "string") return obj.text;
|
|
385
|
+
if (Array.isArray(obj.content)) return flattenContent(obj.content);
|
|
230
386
|
}
|
|
231
387
|
return "";
|
|
232
388
|
}
|
|
@@ -284,7 +440,7 @@ function convertResponseApiJsonToOpenAI(data) {
|
|
|
284
440
|
} : void 0
|
|
285
441
|
};
|
|
286
442
|
}
|
|
287
|
-
function convertOpenAIJsonToResponseApi(data) {
|
|
443
|
+
function convertOpenAIJsonToResponseApi(data, codexTools) {
|
|
288
444
|
const choices = data.choices;
|
|
289
445
|
const message = choices?.[0]?.message;
|
|
290
446
|
const output = [];
|
|
@@ -300,13 +456,15 @@ function convertOpenAIJsonToResponseApi(data) {
|
|
|
300
456
|
if (toolCalls?.length) {
|
|
301
457
|
for (const tc of toolCalls) {
|
|
302
458
|
const func = tc.function;
|
|
303
|
-
output.push(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
459
|
+
output.push(
|
|
460
|
+
encodeToolCallItem(
|
|
461
|
+
tc.id || "",
|
|
462
|
+
func?.name || "",
|
|
463
|
+
typeof func?.arguments === "string" ? func.arguments : "",
|
|
464
|
+
"completed",
|
|
465
|
+
codexTools
|
|
466
|
+
)
|
|
467
|
+
);
|
|
310
468
|
}
|
|
311
469
|
}
|
|
312
470
|
}
|
|
@@ -335,6 +493,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
335
493
|
const messageId = `chatcmpl-${Date.now()}`;
|
|
336
494
|
let model = "unknown";
|
|
337
495
|
let hasEmittedRole = false;
|
|
496
|
+
let hasToolCalls = false;
|
|
338
497
|
const safeEnqueue = (str) => {
|
|
339
498
|
if (!isClosed) {
|
|
340
499
|
try {
|
|
@@ -391,6 +550,42 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
391
550
|
}]);
|
|
392
551
|
}
|
|
393
552
|
break;
|
|
553
|
+
case "response.output_item.added": {
|
|
554
|
+
const item = event.item;
|
|
555
|
+
if (item?.type !== "function_call") break;
|
|
556
|
+
if (!hasEmittedRole) {
|
|
557
|
+
emitChunk([{ index: 0, delta: { role: "assistant", content: null }, finish_reason: null }]);
|
|
558
|
+
hasEmittedRole = true;
|
|
559
|
+
}
|
|
560
|
+
hasToolCalls = true;
|
|
561
|
+
emitChunk([{
|
|
562
|
+
index: 0,
|
|
563
|
+
delta: {
|
|
564
|
+
tool_calls: [{
|
|
565
|
+
index: event.output_index ?? 0,
|
|
566
|
+
id: item.call_id,
|
|
567
|
+
type: "function",
|
|
568
|
+
function: { name: item.name, arguments: "" }
|
|
569
|
+
}]
|
|
570
|
+
},
|
|
571
|
+
finish_reason: null
|
|
572
|
+
}]);
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
case "response.function_call_arguments.delta": {
|
|
576
|
+
hasToolCalls = true;
|
|
577
|
+
emitChunk([{
|
|
578
|
+
index: 0,
|
|
579
|
+
delta: {
|
|
580
|
+
tool_calls: [{
|
|
581
|
+
index: event.output_index ?? 0,
|
|
582
|
+
function: { arguments: event.delta ?? "" }
|
|
583
|
+
}]
|
|
584
|
+
},
|
|
585
|
+
finish_reason: null
|
|
586
|
+
}]);
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
394
589
|
case "response.completed": {
|
|
395
590
|
const resp = event.response;
|
|
396
591
|
const respUsage = resp?.usage;
|
|
@@ -399,7 +594,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
399
594
|
completion_tokens: respUsage.output_tokens || 0,
|
|
400
595
|
total_tokens: (respUsage.input_tokens || 0) + (respUsage.output_tokens || 0)
|
|
401
596
|
} : void 0;
|
|
402
|
-
emitChunk([{ index: 0, delta: {}, finish_reason: "stop" }], usage);
|
|
597
|
+
emitChunk([{ index: 0, delta: {}, finish_reason: hasToolCalls ? "tool_calls" : "stop" }], usage);
|
|
403
598
|
safeEnqueue("data: [DONE]\n\n");
|
|
404
599
|
break;
|
|
405
600
|
}
|
|
@@ -431,7 +626,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
431
626
|
}
|
|
432
627
|
});
|
|
433
628
|
}
|
|
434
|
-
function convertOpenAIStreamToResponseApi(openaiStream) {
|
|
629
|
+
function convertOpenAIStreamToResponseApi(openaiStream, codexTools) {
|
|
435
630
|
const decoder = new TextDecoder();
|
|
436
631
|
const encoder = new TextEncoder();
|
|
437
632
|
return new ReadableStream({
|
|
@@ -442,6 +637,11 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
|
|
|
442
637
|
let accumulatedContent = "";
|
|
443
638
|
let model = "unknown";
|
|
444
639
|
const responseId = `resp_${Date.now()}`;
|
|
640
|
+
const messageId = `msg_${Date.now()}`;
|
|
641
|
+
let messageItemAdded = false;
|
|
642
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
643
|
+
const toolOutputIndex = /* @__PURE__ */ new Map();
|
|
644
|
+
let nextOutputIndex = 1;
|
|
445
645
|
const safeEnqueue = (str) => {
|
|
446
646
|
if (!isClosed) {
|
|
447
647
|
try {
|
|
@@ -478,30 +678,129 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
|
|
|
478
678
|
model = chunk.model || model;
|
|
479
679
|
if (!choice) continue;
|
|
480
680
|
if (choice.delta?.content) {
|
|
681
|
+
if (!messageItemAdded) {
|
|
682
|
+
messageItemAdded = true;
|
|
683
|
+
emitEvent({
|
|
684
|
+
type: "response.output_item.added",
|
|
685
|
+
output_index: 0,
|
|
686
|
+
item: {
|
|
687
|
+
id: messageId,
|
|
688
|
+
type: "message",
|
|
689
|
+
role: "assistant",
|
|
690
|
+
status: "in_progress",
|
|
691
|
+
content: []
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
}
|
|
481
695
|
accumulatedContent += choice.delta.content;
|
|
482
|
-
emitEvent({
|
|
696
|
+
emitEvent({
|
|
697
|
+
type: "response.output_text.delta",
|
|
698
|
+
output_index: 0,
|
|
699
|
+
content_index: 0,
|
|
700
|
+
delta: choice.delta.content
|
|
701
|
+
});
|
|
483
702
|
}
|
|
484
|
-
|
|
703
|
+
const reasoningDelta = choice.delta?.thinking?.content ?? choice.delta?.reasoning_content;
|
|
704
|
+
if (reasoningDelta) {
|
|
485
705
|
emitEvent({
|
|
486
706
|
type: "response.reasoning_summary_text.delta",
|
|
487
|
-
delta:
|
|
707
|
+
delta: reasoningDelta
|
|
488
708
|
});
|
|
489
709
|
}
|
|
710
|
+
if (choice.delta?.tool_calls) {
|
|
711
|
+
for (const tc of choice.delta.tool_calls) {
|
|
712
|
+
const tcIndex = typeof tc["index"] === "number" ? tc["index"] : 0;
|
|
713
|
+
const func = tc["function"] ?? {};
|
|
714
|
+
let entry = toolCalls.get(tcIndex);
|
|
715
|
+
if (!entry) {
|
|
716
|
+
const callId = typeof tc["id"] === "string" ? tc["id"] : `call_${Date.now()}_${tcIndex}`;
|
|
717
|
+
const name = typeof func["name"] === "string" ? func["name"] : "";
|
|
718
|
+
entry = {
|
|
719
|
+
callId,
|
|
720
|
+
name,
|
|
721
|
+
arguments: "",
|
|
722
|
+
isCustom: codexTools?.customToolNames?.includes(name) ?? false
|
|
723
|
+
};
|
|
724
|
+
toolCalls.set(tcIndex, entry);
|
|
725
|
+
const outIdx = nextOutputIndex++;
|
|
726
|
+
toolOutputIndex.set(tcIndex, outIdx);
|
|
727
|
+
emitEvent({
|
|
728
|
+
type: "response.output_item.added",
|
|
729
|
+
output_index: outIdx,
|
|
730
|
+
item: encodeToolCallItem(callId, name, "", "in_progress", codexTools)
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
const argsFragment = typeof func["arguments"] === "string" ? func["arguments"] : "";
|
|
734
|
+
if (argsFragment) {
|
|
735
|
+
entry.arguments += argsFragment;
|
|
736
|
+
if (!entry.isCustom) {
|
|
737
|
+
emitEvent({
|
|
738
|
+
type: "response.function_call_arguments.delta",
|
|
739
|
+
output_index: toolOutputIndex.get(tcIndex),
|
|
740
|
+
delta: argsFragment
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
490
746
|
if (choice.finish_reason) {
|
|
491
|
-
|
|
747
|
+
const output = [];
|
|
748
|
+
if (messageItemAdded) {
|
|
749
|
+
emitEvent({
|
|
750
|
+
type: "response.output_text.done",
|
|
751
|
+
output_index: 0,
|
|
752
|
+
content_index: 0,
|
|
753
|
+
text: accumulatedContent
|
|
754
|
+
});
|
|
755
|
+
const messageItem = {
|
|
756
|
+
id: messageId,
|
|
757
|
+
type: "message",
|
|
758
|
+
role: "assistant",
|
|
759
|
+
status: "completed",
|
|
760
|
+
content: [{ type: "output_text", text: accumulatedContent }]
|
|
761
|
+
};
|
|
762
|
+
emitEvent({
|
|
763
|
+
type: "response.output_item.done",
|
|
764
|
+
output_index: 0,
|
|
765
|
+
item: messageItem
|
|
766
|
+
});
|
|
767
|
+
output.push(messageItem);
|
|
768
|
+
}
|
|
769
|
+
for (const [tcIndex, entry] of toolCalls) {
|
|
770
|
+
const outIdx = toolOutputIndex.get(tcIndex);
|
|
771
|
+
const item = encodeToolCallItem(
|
|
772
|
+
entry.callId,
|
|
773
|
+
entry.name,
|
|
774
|
+
entry.arguments,
|
|
775
|
+
"completed",
|
|
776
|
+
codexTools
|
|
777
|
+
);
|
|
778
|
+
if (entry.isCustom) {
|
|
779
|
+
emitEvent({
|
|
780
|
+
type: "response.custom_tool_call_input.delta",
|
|
781
|
+
output_index: outIdx,
|
|
782
|
+
delta: item.input
|
|
783
|
+
});
|
|
784
|
+
emitEvent({
|
|
785
|
+
type: "response.custom_tool_call_input.done",
|
|
786
|
+
output_index: outIdx,
|
|
787
|
+
input: item.input
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
output.push(item);
|
|
791
|
+
emitEvent({
|
|
792
|
+
type: "response.output_item.done",
|
|
793
|
+
output_index: outIdx,
|
|
794
|
+
item
|
|
795
|
+
});
|
|
796
|
+
}
|
|
492
797
|
emitEvent({
|
|
493
798
|
type: "response.completed",
|
|
494
799
|
response: {
|
|
495
800
|
id: responseId,
|
|
496
801
|
status: "completed",
|
|
497
802
|
model,
|
|
498
|
-
output
|
|
499
|
-
{
|
|
500
|
-
type: "message",
|
|
501
|
-
role: "assistant",
|
|
502
|
-
content: [{ type: "output_text", text: accumulatedContent }]
|
|
503
|
-
}
|
|
504
|
-
],
|
|
803
|
+
output,
|
|
505
804
|
usage: chunk.usage ? {
|
|
506
805
|
input_tokens: chunk.usage.prompt_tokens || 0,
|
|
507
806
|
output_tokens: chunk.usage.completion_tokens || 0,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/transformer/transformers/OpenAITransformer.ts
|
|
2
|
+
var FOREIGN_MESSAGE_KEYS = ["cache_control", "thinking"];
|
|
3
|
+
var FOREIGN_BODY_KEYS = ["meta", "reasoning", "thinking"];
|
|
4
|
+
function normalizeContent(content) {
|
|
5
|
+
if (!Array.isArray(content)) return content;
|
|
6
|
+
const cleaned = content.map((block) => {
|
|
7
|
+
if (block && typeof block === "object" && "cache_control" in block) {
|
|
8
|
+
const { cache_control: _dropped, ...rest } = block;
|
|
9
|
+
return rest;
|
|
10
|
+
}
|
|
11
|
+
return block;
|
|
12
|
+
});
|
|
13
|
+
if (cleaned.length === 1) {
|
|
14
|
+
const only = cleaned[0];
|
|
15
|
+
if (_optionalChain([only, 'optionalAccess', _ => _.type]) === "text" && typeof only.text === "string") return only.text;
|
|
16
|
+
}
|
|
17
|
+
return cleaned;
|
|
18
|
+
}
|
|
19
|
+
var OpenAITransformer = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
20
|
+
static __initStatic() {this.TransformerName = "openai"}
|
|
21
|
+
__init() {this.name = "openai"}
|
|
22
|
+
__init2() {this.endPoint = "/v1/chat/completions"}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Unified → OpenAI Chat Completions.
|
|
26
|
+
*/
|
|
27
|
+
async transformRequestIn(request, _provider, _context) {
|
|
28
|
+
const source = request;
|
|
29
|
+
const out = {};
|
|
30
|
+
for (const key of Object.keys(source)) {
|
|
31
|
+
if (FOREIGN_BODY_KEYS.includes(key)) continue;
|
|
32
|
+
out[key] = source[key];
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(request.messages)) {
|
|
35
|
+
out.messages = request.messages.map((message) => {
|
|
36
|
+
const src = message;
|
|
37
|
+
const encoded = {};
|
|
38
|
+
for (const key of Object.keys(src)) {
|
|
39
|
+
if (FOREIGN_MESSAGE_KEYS.includes(key)) continue;
|
|
40
|
+
encoded[key] = src[key];
|
|
41
|
+
}
|
|
42
|
+
if (message.content !== void 0) {
|
|
43
|
+
encoded.content = normalizeContent(message.content);
|
|
44
|
+
}
|
|
45
|
+
const thinkingContent = _optionalChain([message, 'access', _2 => _2.thinking, 'optionalAccess', _3 => _3.content]);
|
|
46
|
+
if (typeof thinkingContent === "string" && thinkingContent.length > 0) {
|
|
47
|
+
encoded.reasoning_content = thinkingContent;
|
|
48
|
+
}
|
|
49
|
+
return encoded;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const effort = _optionalChain([request, 'access', _4 => _4.reasoning, 'optionalAccess', _5 => _5.effort]);
|
|
53
|
+
if (typeof effort === "string" && effort !== "none") {
|
|
54
|
+
out.reasoning_effort = effort;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* OpenAI Chat Completions → Unified. Identity — see the module JSDoc for why
|
|
60
|
+
* `reasoning_content` is NOT rewritten here.
|
|
61
|
+
*/
|
|
62
|
+
async transformResponseOut(response, _context) {
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
65
|
+
}, _class.__initStatic(), _class);
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.OpenAITransformer = OpenAITransformer;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkKBM2W6UYcjs = require('./chunk-KBM2W6UY.cjs');
|
|
7
7
|
|
|
8
8
|
// src/transformer/transformers/GeminiCodeAssistTransformer.ts
|
|
9
9
|
var DEFAULT_CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|
|
@@ -117,7 +117,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
117
117
|
* openaiResponsesIngress). `undefined` is the valid fresh free-tier value.
|
|
118
118
|
*/
|
|
119
119
|
async transformRequestIn(request, provider, _context) {
|
|
120
|
-
const inner =
|
|
120
|
+
const inner = _chunkKBM2W6UYcjs.buildRequestBody.call(void 0, request);
|
|
121
121
|
const envelope = {
|
|
122
122
|
model: request.model,
|
|
123
123
|
project: provider.geminiProject,
|
|
@@ -147,7 +147,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
147
147
|
if (inner && typeof inner === "object" && !("model" in inner) && "model" in r) {
|
|
148
148
|
inner.model = r.model;
|
|
149
149
|
}
|
|
150
|
-
return
|
|
150
|
+
return _chunkKBM2W6UYcjs.transformRequestOut.call(void 0, inner);
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* Code Assist response → OpenAI-compatible. PEEL the `.response` envelope from
|
|
@@ -155,7 +155,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
155
155
|
*/
|
|
156
156
|
async transformResponseOut(response, _context) {
|
|
157
157
|
const unwrapped = await unwrapCodeAssistResponse(response);
|
|
158
|
-
return
|
|
158
|
+
return _chunkKBM2W6UYcjs.transformResponseOut.call(void 0, unwrapped, this.name, this.logger);
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* OpenAI-compatible response → Code Assist (endpoint-encode parity). Re-wraps
|
|
@@ -164,7 +164,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
|
|
|
164
164
|
* `transformResponseOut`'s peel.
|
|
165
165
|
*/
|
|
166
166
|
async transformResponseIn(response, _context) {
|
|
167
|
-
const geminiResponse = await
|
|
167
|
+
const geminiResponse = await _chunkKBM2W6UYcjs.transformResponseIn.call(void 0, response, this.logger);
|
|
168
168
|
const contentType = _nullishCoalesce(geminiResponse.headers.get("Content-Type"), () => ( ""));
|
|
169
169
|
if (contentType.includes("text/event-stream")) {
|
|
170
170
|
return geminiResponse;
|