@omnicross/core 0.1.10 → 0.2.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/README.md +7 -0
- package/dist/{BuiltinToolExecutor-CS2WpXhM.d.cts → BuiltinToolExecutor-BHgH-EaZ.d.cts} +25 -2
- package/dist/{BuiltinToolExecutor-BluWyeob.d.ts → BuiltinToolExecutor-Bi1LmiTP.d.ts} +25 -2
- package/dist/{CompletionService-kNA17cfI.d.cts → CompletionService-BniP7j88.d.cts} +2 -2
- package/dist/{CompletionService-C3BX0Ovy.d.ts → CompletionService-BqrKPwfA.d.ts} +2 -2
- package/dist/{ProviderProxy-QdwNV6l1.d.cts → ProviderProxy-Bz_nkOwq.d.cts} +1 -1
- package/dist/{ProviderProxy--ROec6VI.d.ts → ProviderProxy-Ckr6oTrE.d.ts} +1 -1
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -6
- package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -4
- package/dist/{chunk-NGYOO5TO.js → chunk-2C3TTBS7.js} +7 -7
- package/dist/{chunk-QUSEZNYS.cjs → chunk-32SRZFFP.cjs} +4 -1
- package/dist/chunk-4JOU54M5.js +200 -0
- package/dist/{chunk-2UTGX6FM.js → chunk-4VVCXVB7.js} +1 -1
- package/dist/{chunk-RJUONLUQ.cjs → chunk-4Z3ZLLC2.cjs} +14 -8
- package/dist/chunk-6DDYNS2B.cjs +384 -0
- package/dist/{chunk-GXEZ2R3E.js → chunk-6OKXH2TW.js} +18 -7
- package/dist/{chunk-YWL7YZWS.cjs → chunk-7LRTPNFL.cjs} +5 -0
- package/dist/{chunk-CCVRRJOX.js → chunk-7PIUVCKK.js} +9 -2
- package/dist/chunk-7RJI3NDI.cjs +236 -0
- package/dist/{chunk-IIRPUVPH.cjs → chunk-7ZHBN75N.cjs} +3 -1
- package/dist/chunk-D4WNI6BR.cjs +386 -0
- package/dist/chunk-DBBR6RHF.js +236 -0
- package/dist/chunk-E4QHVXV5.cjs +118 -0
- package/dist/{chunk-HKB656B4.js → chunk-EUZRH544.js} +55 -287
- package/dist/{chunk-WNKWAEUR.js → chunk-EYGBM2VC.js} +3 -1
- package/dist/{chunk-UWDW6PN3.cjs → chunk-FX325I5Q.cjs} +20 -9
- package/dist/chunk-G4CZIUIB.cjs +200 -0
- package/dist/chunk-HCOQQAZE.cjs +123 -0
- package/dist/chunk-HL2YSPL7.cjs +673 -0
- package/dist/{chunk-55FMGZ3L.js → chunk-HN74IGEO.js} +1 -1
- package/dist/{chunk-ZY6KU6P3.js → chunk-HOMUGKHR.js} +8 -5
- package/dist/{chunk-AOFWNWLT.cjs → chunk-IUL4VWNU.cjs} +22 -1
- package/dist/{chunk-5LNYGCIW.cjs → chunk-KIQ2HA2A.cjs} +5 -5
- package/dist/{chunk-MUHWHQVM.cjs → chunk-KQBLZMP6.cjs} +4 -3
- package/dist/chunk-LFEH7CEO.js +384 -0
- package/dist/chunk-LFPQ2OVH.js +386 -0
- package/dist/{chunk-FEBAQI5A.js → chunk-LKDAN4D7.js} +6363 -1350
- package/dist/chunk-LQYS2N47.js +3923 -0
- package/dist/{chunk-NZYN7C3P.cjs → chunk-MPXOKQJP.cjs} +53 -53
- package/dist/chunk-MZEGQSKQ.js +118 -0
- package/dist/chunk-N76KU6F5.js +123 -0
- package/dist/chunk-NLUOTJWB.js +673 -0
- package/dist/{chunk-CMVXX7ON.cjs → chunk-NOITAVHA.cjs} +114 -58
- package/dist/{chunk-Q27JY5RG.cjs → chunk-OIKREZVQ.cjs} +7 -4
- package/dist/{chunk-ZQQUD66M.cjs → chunk-POUTD5AM.cjs} +63 -295
- package/dist/{chunk-6D4W22P4.js → chunk-QIIAMBTM.js} +4 -1
- package/dist/{chunk-56QD3YW6.cjs → chunk-QWNUOR7F.cjs} +11 -4
- package/dist/{chunk-S3DYFEBE.js → chunk-R4VCO2CB.js} +10 -1
- package/dist/{chunk-4VZX5F4T.cjs → chunk-T6NWPIYZ.cjs} +5 -2
- package/dist/{chunk-EBLFCNPY.js → chunk-U47LQXPB.js} +5 -2
- package/dist/chunk-UPQIWJIE.cjs +3923 -0
- package/dist/{chunk-N7OOJI5V.js → chunk-V2UKUTJ3.js} +5 -0
- package/dist/{chunk-45FHEOKW.js → chunk-V53ZEFXC.js} +92 -36
- package/dist/{chunk-RJ5ZGNI3.js → chunk-VL5TUDTM.js} +8 -2
- package/dist/{chunk-TIT74RIL.cjs → chunk-VSYQ6XYN.cjs} +6837 -1824
- package/dist/{chunk-OC6DOOFX.cjs → chunk-VXRTQZF2.cjs} +5 -5
- package/dist/{chunk-RICPANBY.cjs → chunk-WX2E2G7H.cjs} +13 -4
- package/dist/{chunk-DE2SRBFZ.js → chunk-X335TJNS.js} +4 -3
- package/dist/{chunk-CDHS2QDC.js → chunk-Y4CRNHJO.js} +53 -53
- package/dist/{chunk-P7EM6BND.cjs → chunk-ZAPN7XA6.cjs} +10 -10
- package/dist/{chunk-N2EIM2XJ.js → chunk-ZLNHPUFA.js} +22 -1
- package/dist/completion/BuiltinToolExecutor.cjs +2 -2
- package/dist/completion/BuiltinToolExecutor.d.cts +3 -1
- package/dist/completion/BuiltinToolExecutor.d.ts +3 -1
- package/dist/completion/BuiltinToolExecutor.js +1 -1
- package/dist/completion/CompletionService.cjs +32 -28
- package/dist/completion/CompletionService.d.cts +7 -3
- package/dist/completion/CompletionService.d.ts +7 -3
- package/dist/completion/CompletionService.js +31 -27
- package/dist/completion.cjs +40 -36
- package/dist/completion.d.cts +7 -3
- package/dist/completion.d.ts +7 -3
- package/dist/completion.js +39 -35
- package/dist/egress-I46O_p5L.d.cts +126 -0
- package/dist/egress-I46O_p5L.d.ts +126 -0
- package/dist/frontends-Doz0RaWu.d.cts +97 -0
- package/dist/frontends-Doz0RaWu.d.ts +97 -0
- package/dist/image-generation.cjs +52 -0
- package/dist/image-generation.d.cts +96 -0
- package/dist/image-generation.d.ts +96 -0
- package/dist/image-generation.js +52 -0
- package/dist/index.cjs +142 -32
- package/dist/index.d.cts +16 -8
- package/dist/index.d.ts +16 -8
- package/dist/index.js +159 -49
- package/dist/openai-operation.cjs +18 -0
- package/dist/openai-operation.d.cts +22 -0
- package/dist/openai-operation.d.ts +22 -0
- package/dist/openai-operation.js +18 -0
- package/dist/outbound-api/auditCapture.cjs +3 -3
- package/dist/outbound-api/auditCapture.d.cts +13 -2
- package/dist/outbound-api/auditCapture.d.ts +13 -2
- package/dist/outbound-api/auditCapture.js +2 -2
- package/dist/outbound-api/auditRedact.cjs +2 -2
- package/dist/outbound-api/auditRedact.js +1 -1
- package/dist/outbound-api/routeResolver.cjs +2 -2
- package/dist/outbound-api/routeResolver.d.cts +11 -4
- package/dist/outbound-api/routeResolver.d.ts +11 -4
- package/dist/outbound-api/routeResolver.js +1 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +5 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +5 -1
- package/dist/outbound-api/types.d.cts +10 -3
- package/dist/outbound-api/types.d.ts +10 -3
- package/dist/outbound-api.cjs +65 -33
- package/dist/outbound-api.d.cts +205 -10
- package/dist/outbound-api.d.ts +205 -10
- package/dist/outbound-api.js +64 -32
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +22 -15
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +22 -15
- package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
- package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.cjs +2 -2
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +7 -0
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +7 -0
- package/dist/pipeline/SubscriptionAccountHealth.js +1 -1
- package/dist/pipeline/executeProviderCall.cjs +2 -2
- package/dist/pipeline/executeProviderCall.d.cts +11 -6
- package/dist/pipeline/executeProviderCall.d.ts +11 -6
- package/dist/pipeline/executeProviderCall.js +1 -1
- package/dist/pipeline/upstreamFetch.cjs +2 -2
- package/dist/pipeline/upstreamFetch.d.cts +5 -0
- package/dist/pipeline/upstreamFetch.d.ts +5 -0
- package/dist/pipeline/upstreamFetch.js +1 -1
- package/dist/ports.d.cts +10 -3
- package/dist/ports.d.ts +10 -3
- package/dist/provider-proxy/ProviderProxy.cjs +32 -28
- package/dist/provider-proxy/ProviderProxy.d.cts +6 -2
- package/dist/provider-proxy/ProviderProxy.d.ts +6 -2
- package/dist/provider-proxy/ProviderProxy.js +31 -27
- package/dist/provider-proxy/identity/codexCliHeaders.cjs +4 -2
- package/dist/provider-proxy/identity/codexCliHeaders.d.cts +26 -6
- package/dist/provider-proxy/identity/codexCliHeaders.d.ts +26 -6
- package/dist/provider-proxy/identity/codexCliHeaders.js +5 -3
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +36 -28
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +41 -9
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +41 -9
- package/dist/provider-proxy/ingress/providerProxyShared.js +35 -27
- package/dist/provider-proxy/types.d.cts +17 -483
- package/dist/provider-proxy/types.d.ts +17 -483
- package/dist/provider-proxy.cjs +46 -28
- package/dist/provider-proxy.d.cts +34 -8
- package/dist/provider-proxy.d.ts +34 -8
- package/dist/provider-proxy.js +45 -27
- package/dist/proxy-UZTtjPZx.d.cts +18 -0
- package/dist/proxy-UZTtjPZx.d.ts +18 -0
- package/dist/{routeResolver-CVFE8KKe.d.cts → routeResolver-Da0yvkL1.d.cts} +4 -2
- package/dist/{routeResolver-C0mkkZaM.d.ts → routeResolver-STwMz_G4.d.ts} +4 -2
- package/dist/runtime-6QXNU526.cjs +8 -0
- package/dist/runtime-M5WXLD2R.js +8 -0
- package/dist/runtime-t8AZacFF.d.cts +233 -0
- package/dist/runtime-t8AZacFF.d.ts +233 -0
- package/dist/search/api.cjs +761 -0
- package/dist/search/api.d.cts +370 -0
- package/dist/search/api.d.ts +370 -0
- package/dist/search/api.js +761 -0
- package/dist/search/http.cjs +37 -0
- package/dist/search/http.d.cts +269 -0
- package/dist/search/http.d.ts +269 -0
- package/dist/search/http.js +37 -0
- package/dist/search.cjs +57 -0
- package/dist/search.d.cts +113 -0
- package/dist/search.d.ts +113 -0
- package/dist/search.js +57 -0
- package/dist/transformer/TransformerChainExecutor.cjs +2 -2
- package/dist/transformer/TransformerChainExecutor.d.cts +2 -2
- package/dist/transformer/TransformerChainExecutor.d.ts +2 -2
- package/dist/transformer/TransformerChainExecutor.js +1 -1
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.cjs +16 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.cts +53 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.ts +53 -0
- package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.js +16 -0
- package/dist/transformer/transformers/AnthropicTransformer.cjs +4 -3
- package/dist/transformer/transformers/AnthropicTransformer.js +3 -2
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +4 -4
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +3 -3
- package/dist/transformer/transformers/GeminiTransformer.cjs +4 -4
- package/dist/transformer/transformers/GeminiTransformer.js +3 -3
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -3
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -2
- package/dist/transformer/transformers/OpenAITransformer.cjs +3 -3
- package/dist/transformer/transformers/OpenAITransformer.js +2 -2
- package/dist/transformer/transformers.cjs +11 -10
- package/dist/transformer/transformers.js +12 -11
- package/dist/transformer/types.d.cts +39 -4
- package/dist/transformer/types.d.ts +39 -4
- package/dist/transformer.cjs +14 -13
- package/dist/transformer.js +13 -12
- package/dist/types-BSIJdsyl.d.cts +1130 -0
- package/dist/types-Be-yt_6T.d.cts +196 -0
- package/dist/types-By9Tg6-I.d.ts +1130 -0
- package/dist/types-CbCZqLGg.d.cts +127 -0
- package/dist/types-CbCZqLGg.d.ts +127 -0
- package/dist/{types-C2MwkLah.d.cts → types-D-oHYusb.d.cts} +250 -21
- package/dist/types-Dm4_36V4.d.ts +196 -0
- package/dist/{types-BB8pxk_3.d.ts → types-Dvlpjn0d.d.ts} +250 -21
- package/dist/usage.cjs +2 -2
- package/dist/usage.d.cts +6 -1
- package/dist/usage.d.ts +6 -1
- package/dist/usage.js +1 -1
- package/package.json +71 -64
- package/dist/chunk-FCR77GYM.cjs +0 -33
- package/dist/chunk-K5NM7VAH.js +0 -33
- /package/dist/{chunk-XXFYLL7R.js → chunk-ECZ3ZE2C.js} +0 -0
- /package/dist/{chunk-3SCOLIPT.cjs → chunk-MXI2PWIC.cjs} +0 -0
|
@@ -6,7 +6,8 @@ var _chunk5RSZYQJHcjs = require('./chunk-5RSZYQJH.cjs');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
var _chunkIUL4VWNUcjs = require('./chunk-IUL4VWNU.cjs');
|
|
10
11
|
|
|
11
12
|
// src/transformer/transformers/OpenAIResponseTransformer.ts
|
|
12
13
|
var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
@@ -33,6 +34,7 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
33
34
|
*/
|
|
34
35
|
async transformRequestIn(request, provider, context) {
|
|
35
36
|
const input = [];
|
|
37
|
+
const codexTools = _optionalChain([request, 'access', _ => _.meta, 'optionalAccess', _2 => _2.codexTools]);
|
|
36
38
|
for (const msg of request.messages) {
|
|
37
39
|
if (msg.role === "system") {
|
|
38
40
|
const sysText = typeof msg.content === "string" ? msg.content : flattenContent(msg.content);
|
|
@@ -41,9 +43,10 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
41
43
|
content: [{ type: "input_text", text: sysText }]
|
|
42
44
|
});
|
|
43
45
|
} else if (msg.role === "tool") {
|
|
46
|
+
const callId = msg.tool_call_id;
|
|
44
47
|
input.push({
|
|
45
|
-
type: "function_call_output",
|
|
46
|
-
call_id:
|
|
48
|
+
type: _optionalChain([codexTools, 'optionalAccess', _3 => _3.customToolCallIds, 'optionalAccess', _4 => _4.includes, 'call', _5 => _5(_nullishCoalesce(callId, () => ( "")))]) ? "custom_tool_call_output" : "function_call_output",
|
|
49
|
+
call_id: callId,
|
|
47
50
|
output: typeof msg.content === "string" ? msg.content : ""
|
|
48
51
|
});
|
|
49
52
|
} else {
|
|
@@ -52,18 +55,17 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
52
55
|
role: msg.role,
|
|
53
56
|
content: [{ type: msg.role === "assistant" ? "output_text" : "input_text", text }]
|
|
54
57
|
};
|
|
55
|
-
if (msg.role === "assistant" && _optionalChain([msg, 'access',
|
|
58
|
+
if (msg.role === "assistant" && _optionalChain([msg, 'access', _6 => _6.tool_calls, 'optionalAccess', _7 => _7.length])) {
|
|
56
59
|
input.push(entry);
|
|
57
60
|
for (const tc of msg.tool_calls) {
|
|
58
61
|
const callId = tc.id;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
62
|
+
input.push(encodeToolCallItem(
|
|
63
|
+
callId,
|
|
64
|
+
tc.function.name,
|
|
65
|
+
tc.function.arguments,
|
|
66
|
+
"completed",
|
|
67
|
+
codexTools
|
|
68
|
+
));
|
|
67
69
|
}
|
|
68
70
|
continue;
|
|
69
71
|
}
|
|
@@ -77,34 +79,50 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
77
79
|
// set to true" otherwise). Always force it; a non-streaming CLIENT is
|
|
78
80
|
// served by aggregating the SSE upstream of the wire (the ingress buffers
|
|
79
81
|
// it into a single message), not by asking codex for a non-streaming reply.
|
|
80
|
-
stream: true,
|
|
82
|
+
stream: context.responsesSourceFormat === this.name ? request.stream : true,
|
|
81
83
|
// `store:false` is required by the codex backend and accepted by the
|
|
82
84
|
// public Responses API (which defaults to store:true). Always set it so
|
|
83
85
|
// codex relays (no discoverable url token) work without configuration.
|
|
84
86
|
store: false,
|
|
85
|
-
// `max_output_tokens
|
|
86
|
-
//
|
|
87
|
-
// public
|
|
88
|
-
...request.temperature !== void 0 ? { temperature: request.temperature } : {}
|
|
87
|
+
// `max_output_tokens`: the codex backend REJECTS it, so it maps only when
|
|
88
|
+
// the client already speaks the Responses wire (public providers); the
|
|
89
|
+
// public API falls back to its default when absent.
|
|
90
|
+
...request.temperature !== void 0 ? { temperature: request.temperature } : {},
|
|
91
|
+
// R7 (claude-api-transform-fidelity): the Responses wire HAS `top_p`, so
|
|
92
|
+
// the decoded hub value maps through — conditionally (absent ⇒ absent).
|
|
93
|
+
...request.top_p !== void 0 ? { top_p: request.top_p } : {},
|
|
94
|
+
...context.responsesSourceFormat === this.name && request.max_tokens !== void 0 ? { max_output_tokens: request.max_tokens } : {}
|
|
89
95
|
};
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
if (request.stop !== void 0) _chunkIUL4VWNUcjs.recordDroppedField.call(void 0, request, "stop", "openai-responses");
|
|
97
|
+
if (request.top_k !== void 0) _chunkIUL4VWNUcjs.recordDroppedField.call(void 0, request, "top_k", "openai-responses");
|
|
98
|
+
if (request.metadata_user_id !== void 0) {
|
|
99
|
+
_chunkIUL4VWNUcjs.recordDroppedField.call(void 0, request, "metadata_user_id", "openai-responses");
|
|
100
|
+
}
|
|
101
|
+
const reasoningPlan = _chunkIUL4VWNUcjs.resolveReasoningPlan.call(void 0, {
|
|
102
|
+
intent: _chunkIUL4VWNUcjs.extractReasoningIntent.call(void 0, request),
|
|
92
103
|
model: request.model,
|
|
93
104
|
provider,
|
|
94
105
|
target: "openai-responses",
|
|
95
106
|
requestMaxTokens: request.max_tokens,
|
|
96
107
|
preserveNativeEffort: context.reasoningSourceFormat === this.name
|
|
97
108
|
});
|
|
98
|
-
if (_optionalChain([reasoningPlan, 'optionalAccess',
|
|
99
|
-
body.reasoning = {
|
|
109
|
+
if (_optionalChain([reasoningPlan, 'optionalAccess', _8 => _8.kind]) === "level" && reasoningPlan.enabled) {
|
|
110
|
+
body.reasoning = {
|
|
111
|
+
effort: reasoningPlan.effort,
|
|
112
|
+
summary: typeof context.responsesReasoningSummary === "string" ? context.responsesReasoningSummary : "auto"
|
|
113
|
+
};
|
|
100
114
|
}
|
|
101
|
-
if (_optionalChain([request, 'access',
|
|
102
|
-
body.tools = request.tools.map((tool) => ({
|
|
115
|
+
if (_optionalChain([request, 'access', _9 => _9.tools, 'optionalAccess', _10 => _10.length])) {
|
|
116
|
+
body.tools = request.tools.map((tool) => _optionalChain([codexTools, 'optionalAccess', _11 => _11.customToolNames, 'optionalAccess', _12 => _12.includes, 'call', _13 => _13(tool.function.name)]) ? {
|
|
117
|
+
type: "custom",
|
|
118
|
+
name: tool.function.name,
|
|
119
|
+
description: tool.function.description
|
|
120
|
+
} : {
|
|
103
121
|
type: "function",
|
|
104
122
|
name: tool.function.name,
|
|
105
123
|
description: tool.function.description,
|
|
106
124
|
parameters: tool.function.parameters
|
|
107
|
-
})
|
|
125
|
+
});
|
|
108
126
|
}
|
|
109
127
|
if (request.tool_choice) {
|
|
110
128
|
if (typeof request.tool_choice === "string") {
|
|
@@ -122,7 +140,11 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
122
140
|
async transformRequestOut(request, context) {
|
|
123
141
|
const req = request;
|
|
124
142
|
const messages = [];
|
|
125
|
-
let codexTools =
|
|
143
|
+
let codexTools = collectCodexTools({ tools: req.tools });
|
|
144
|
+
context.responsesSourceFormat = this.name;
|
|
145
|
+
if (typeof _optionalChain([req, 'access', _14 => _14.reasoning, 'optionalAccess', _15 => _15.summary]) === "string") {
|
|
146
|
+
context.responsesReasoningSummary = req.reasoning.summary;
|
|
147
|
+
}
|
|
126
148
|
const instructions = typeof req.instructions === "string" ? req.instructions.trim() : "";
|
|
127
149
|
if (instructions) {
|
|
128
150
|
messages.push({ role: "system", content: instructions });
|
|
@@ -133,10 +155,11 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
133
155
|
const itemType = typeof entry.type === "string" ? entry.type : void 0;
|
|
134
156
|
if (itemType && SKIPPED_INPUT_ITEM_TYPES.has(itemType)) continue;
|
|
135
157
|
if (itemType === "additional_tools") {
|
|
136
|
-
codexTools = collectCodexTools(entry);
|
|
158
|
+
codexTools = mergeCodexTools(codexTools, collectCodexTools(entry));
|
|
137
159
|
continue;
|
|
138
160
|
}
|
|
139
161
|
if (itemType === "custom_tool_call_output") {
|
|
162
|
+
rememberCustomCall(codexTools, entry.call_id);
|
|
140
163
|
messages.push({
|
|
141
164
|
role: "tool",
|
|
142
165
|
content: flattenContent(entry.output),
|
|
@@ -145,6 +168,7 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
145
168
|
continue;
|
|
146
169
|
}
|
|
147
170
|
if (itemType === "custom_tool_call") {
|
|
171
|
+
rememberCustomCall(codexTools, _nullishCoalesce(entry.call_id, () => ( entry.id)), entry.name);
|
|
148
172
|
const toolCall = {
|
|
149
173
|
id: (_nullishCoalesce(entry.call_id, () => ( entry.id))) || "",
|
|
150
174
|
type: "function",
|
|
@@ -172,6 +196,7 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
172
196
|
continue;
|
|
173
197
|
}
|
|
174
198
|
if (itemType === "function_call") {
|
|
199
|
+
rememberToolNamespace(codexTools, entry.name, entry.namespace);
|
|
175
200
|
const toolCall = {
|
|
176
201
|
id: (_nullishCoalesce(entry.call_id, () => ( entry.id))) || "",
|
|
177
202
|
type: "function",
|
|
@@ -205,7 +230,7 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
205
230
|
temperature: req.temperature,
|
|
206
231
|
stream: req.stream
|
|
207
232
|
};
|
|
208
|
-
const effort =
|
|
233
|
+
const effort = _chunkIUL4VWNUcjs.normalizeThinkLevel.call(void 0, _optionalChain([req, 'access', _16 => _16.reasoning, 'optionalAccess', _17 => _17.effort]));
|
|
209
234
|
if (effort) {
|
|
210
235
|
context.reasoningSourceFormat = this.name;
|
|
211
236
|
result.reasoning = {
|
|
@@ -214,28 +239,17 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
214
239
|
};
|
|
215
240
|
}
|
|
216
241
|
const tools = [];
|
|
217
|
-
if (
|
|
218
|
-
tools.push(
|
|
219
|
-
...req.tools.filter((t) => t.type === "function").map((t) => ({
|
|
220
|
-
type: "function",
|
|
221
|
-
function: {
|
|
222
|
-
name: t.name || "",
|
|
223
|
-
description: t.description || "",
|
|
224
|
-
parameters: t.parameters || {}
|
|
225
|
-
}
|
|
226
|
-
}))
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
if (_optionalChain([codexTools, 'optionalAccess', _10 => _10.tools, 'access', _11 => _11.length])) {
|
|
242
|
+
if (codexTools.tools.length) {
|
|
230
243
|
const declared = new Set(tools.map((t) => t.function.name));
|
|
231
244
|
tools.push(...codexTools.tools.filter((t) => !declared.has(t.function.name)));
|
|
232
245
|
}
|
|
233
246
|
if (tools.length) result.tools = tools;
|
|
234
|
-
if (
|
|
247
|
+
if (codexTools.customToolNames.length || codexTools.customToolCallIds.length || Object.keys(codexTools.toolNamespaces).length) {
|
|
235
248
|
result.meta = {
|
|
236
249
|
...result.meta,
|
|
237
250
|
codexTools: {
|
|
238
251
|
...codexTools.customToolNames.length ? { customToolNames: codexTools.customToolNames } : {},
|
|
252
|
+
...codexTools.customToolCallIds.length ? { customToolCallIds: codexTools.customToolCallIds } : {},
|
|
239
253
|
...Object.keys(codexTools.toolNamespaces).length ? { toolNamespaces: codexTools.toolNamespaces } : {}
|
|
240
254
|
}
|
|
241
255
|
};
|
|
@@ -281,7 +295,7 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
|
|
|
281
295
|
*/
|
|
282
296
|
async transformResponseIn(response, context) {
|
|
283
297
|
const contentType = _nullishCoalesce(response.headers.get("Content-Type"), () => ( ""));
|
|
284
|
-
const codexTools = _optionalChain([context, 'optionalAccess',
|
|
298
|
+
const codexTools = _optionalChain([context, 'optionalAccess', _18 => _18.req, 'optionalAccess', _19 => _19.meta, 'optionalAccess', _20 => _20.codexTools]);
|
|
285
299
|
if (contentType.includes("text/event-stream")) {
|
|
286
300
|
if (!response.body) {
|
|
287
301
|
throw new Error("Stream response body is null");
|
|
@@ -324,7 +338,7 @@ function unwrapCustomToolInput(argumentsJson) {
|
|
|
324
338
|
}
|
|
325
339
|
function encodeToolCallItem(callId, name, argumentsJson, status, codexTools) {
|
|
326
340
|
const bareId = callId.replace(/^(call_|fc_|ctc_)/, "");
|
|
327
|
-
if (_optionalChain([codexTools, 'optionalAccess',
|
|
341
|
+
if (_optionalChain([codexTools, 'optionalAccess', _21 => _21.customToolNames, 'optionalAccess', _22 => _22.includes, 'call', _23 => _23(name)])) {
|
|
328
342
|
return {
|
|
329
343
|
id: `ctc_${bareId}`,
|
|
330
344
|
type: "custom_tool_call",
|
|
@@ -334,7 +348,7 @@ function encodeToolCallItem(callId, name, argumentsJson, status, codexTools) {
|
|
|
334
348
|
input: unwrapCustomToolInput(argumentsJson)
|
|
335
349
|
};
|
|
336
350
|
}
|
|
337
|
-
const namespace = _optionalChain([codexTools, 'optionalAccess',
|
|
351
|
+
const namespace = _optionalChain([codexTools, 'optionalAccess', _24 => _24.toolNamespaces, 'optionalAccess', _25 => _25[name]]);
|
|
338
352
|
return {
|
|
339
353
|
id: callId.startsWith("fc_") ? callId : `fc_${bareId}`,
|
|
340
354
|
type: "function_call",
|
|
@@ -346,7 +360,12 @@ function encodeToolCallItem(callId, name, argumentsJson, status, codexTools) {
|
|
|
346
360
|
};
|
|
347
361
|
}
|
|
348
362
|
function collectCodexTools(entry) {
|
|
349
|
-
const result = {
|
|
363
|
+
const result = {
|
|
364
|
+
tools: [],
|
|
365
|
+
customToolNames: [],
|
|
366
|
+
customToolCallIds: [],
|
|
367
|
+
toolNamespaces: {}
|
|
368
|
+
};
|
|
350
369
|
const visit = (declarations, namespace) => {
|
|
351
370
|
if (!Array.isArray(declarations)) return;
|
|
352
371
|
for (const raw of declarations) {
|
|
@@ -387,6 +406,32 @@ function collectCodexTools(entry) {
|
|
|
387
406
|
visit(entry.tools);
|
|
388
407
|
return result;
|
|
389
408
|
}
|
|
409
|
+
function mergeCodexTools(left, right) {
|
|
410
|
+
const tools = [...left.tools];
|
|
411
|
+
const names = new Set(tools.map((tool) => tool.function.name));
|
|
412
|
+
for (const tool of right.tools) {
|
|
413
|
+
if (!names.has(tool.function.name)) tools.push(tool);
|
|
414
|
+
}
|
|
415
|
+
return {
|
|
416
|
+
tools,
|
|
417
|
+
customToolNames: [.../* @__PURE__ */ new Set([...left.customToolNames, ...right.customToolNames])],
|
|
418
|
+
customToolCallIds: [.../* @__PURE__ */ new Set([...left.customToolCallIds, ...right.customToolCallIds])],
|
|
419
|
+
toolNamespaces: { ...left.toolNamespaces, ...right.toolNamespaces }
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function rememberCustomCall(state, rawCallId, rawName) {
|
|
423
|
+
if (typeof rawCallId === "string" && rawCallId && !state.customToolCallIds.includes(rawCallId)) {
|
|
424
|
+
state.customToolCallIds.push(rawCallId);
|
|
425
|
+
}
|
|
426
|
+
if (typeof rawName === "string" && rawName && !state.customToolNames.includes(rawName)) {
|
|
427
|
+
state.customToolNames.push(rawName);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function rememberToolNamespace(state, rawName, rawNamespace) {
|
|
431
|
+
if (typeof rawName === "string" && rawName && typeof rawNamespace === "string" && rawNamespace) {
|
|
432
|
+
state.toolNamespaces[rawName] = rawNamespace;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
390
435
|
function flattenContent(content) {
|
|
391
436
|
if (typeof content === "string") return content;
|
|
392
437
|
if (!content) return "";
|
|
@@ -458,7 +503,7 @@ function convertResponseApiJsonToOpenAI(data) {
|
|
|
458
503
|
}
|
|
459
504
|
function convertOpenAIJsonToResponseApi(data, codexTools) {
|
|
460
505
|
const choices = data.choices;
|
|
461
|
-
const message = _optionalChain([choices, 'optionalAccess',
|
|
506
|
+
const message = _optionalChain([choices, 'optionalAccess', _26 => _26[0], 'optionalAccess', _27 => _27.message]);
|
|
462
507
|
const output = [];
|
|
463
508
|
if (message) {
|
|
464
509
|
const contentParts = [];
|
|
@@ -469,14 +514,14 @@ function convertOpenAIJsonToResponseApi(data, codexTools) {
|
|
|
469
514
|
output.push({ type: "message", role: "assistant", content: contentParts });
|
|
470
515
|
}
|
|
471
516
|
const toolCalls = message.tool_calls;
|
|
472
|
-
if (_optionalChain([toolCalls, 'optionalAccess',
|
|
517
|
+
if (_optionalChain([toolCalls, 'optionalAccess', _28 => _28.length])) {
|
|
473
518
|
for (const tc of toolCalls) {
|
|
474
519
|
const func = tc.function;
|
|
475
520
|
output.push(
|
|
476
521
|
encodeToolCallItem(
|
|
477
522
|
tc.id || "",
|
|
478
|
-
_optionalChain([func, 'optionalAccess',
|
|
479
|
-
typeof _optionalChain([func, 'optionalAccess',
|
|
523
|
+
_optionalChain([func, 'optionalAccess', _29 => _29.name]) || "",
|
|
524
|
+
typeof _optionalChain([func, 'optionalAccess', _30 => _30.arguments]) === "string" ? func.arguments : "",
|
|
480
525
|
"completed",
|
|
481
526
|
codexTools
|
|
482
527
|
)
|
|
@@ -542,7 +587,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
542
587
|
if (data === "[DONE]") continue;
|
|
543
588
|
try {
|
|
544
589
|
const event = JSON.parse(data);
|
|
545
|
-
model = event.model || _optionalChain([event, 'access',
|
|
590
|
+
model = event.model || _optionalChain([event, 'access', _31 => _31.response, 'optionalAccess', _32 => _32.model]) || model;
|
|
546
591
|
switch (event.type) {
|
|
547
592
|
case "response.output_text.delta":
|
|
548
593
|
if (event.delta) {
|
|
@@ -564,7 +609,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
564
609
|
break;
|
|
565
610
|
case "response.output_item.added": {
|
|
566
611
|
const item = event.item;
|
|
567
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
612
|
+
if (_optionalChain([item, 'optionalAccess', _33 => _33.type]) !== "function_call") break;
|
|
568
613
|
if (!hasEmittedRole) {
|
|
569
614
|
emitChunk([{ index: 0, delta: { role: "assistant", content: null }, finish_reason: null }]);
|
|
570
615
|
hasEmittedRole = true;
|
|
@@ -600,7 +645,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
600
645
|
}
|
|
601
646
|
case "response.completed": {
|
|
602
647
|
const resp = event.response;
|
|
603
|
-
const respUsage = _optionalChain([resp, 'optionalAccess',
|
|
648
|
+
const respUsage = _optionalChain([resp, 'optionalAccess', _34 => _34.usage]);
|
|
604
649
|
const usage = _chunk5RSZYQJHcjs.responsesUsageToChatUsage.call(void 0, respUsage);
|
|
605
650
|
emitChunk([{ index: 0, delta: {}, finish_reason: hasToolCalls ? "tool_calls" : "stop" }], usage);
|
|
606
651
|
safeEnqueue("data: [DONE]\n\n");
|
|
@@ -609,10 +654,21 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
|
|
|
609
654
|
case "error":
|
|
610
655
|
emitChunk([{
|
|
611
656
|
index: 0,
|
|
612
|
-
delta: { content: `[Error: ${_optionalChain([event, 'access',
|
|
657
|
+
delta: { content: `[Error: ${_optionalChain([event, 'access', _35 => _35.error, 'optionalAccess', _36 => _36.message]) || "Unknown error"}]` },
|
|
613
658
|
finish_reason: "stop"
|
|
614
659
|
}]);
|
|
615
660
|
break;
|
|
661
|
+
case "response.failed": {
|
|
662
|
+
safeEnqueue(
|
|
663
|
+
`data: ${JSON.stringify({
|
|
664
|
+
error: _nullishCoalesce(_optionalChain([event, 'access', _37 => _37.response, 'optionalAccess', _38 => _38.error]), () => ( { message: "response.failed" }))
|
|
665
|
+
})}
|
|
666
|
+
|
|
667
|
+
`
|
|
668
|
+
);
|
|
669
|
+
safeEnqueue("data: [DONE]\n\n");
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
616
672
|
default:
|
|
617
673
|
break;
|
|
618
674
|
}
|
|
@@ -682,10 +738,10 @@ function convertOpenAIStreamToResponseApi(openaiStream, codexTools) {
|
|
|
682
738
|
if (data === "[DONE]") continue;
|
|
683
739
|
try {
|
|
684
740
|
const chunk = JSON.parse(data);
|
|
685
|
-
const choice = _optionalChain([chunk, 'access',
|
|
741
|
+
const choice = _optionalChain([chunk, 'access', _39 => _39.choices, 'optionalAccess', _40 => _40[0]]);
|
|
686
742
|
model = chunk.model || model;
|
|
687
743
|
if (!choice) continue;
|
|
688
|
-
if (_optionalChain([choice, 'access',
|
|
744
|
+
if (_optionalChain([choice, 'access', _41 => _41.delta, 'optionalAccess', _42 => _42.content])) {
|
|
689
745
|
if (!messageItemAdded) {
|
|
690
746
|
messageItemAdded = true;
|
|
691
747
|
emitEvent({
|
|
@@ -708,14 +764,14 @@ function convertOpenAIStreamToResponseApi(openaiStream, codexTools) {
|
|
|
708
764
|
delta: choice.delta.content
|
|
709
765
|
});
|
|
710
766
|
}
|
|
711
|
-
const reasoningDelta = _nullishCoalesce(_optionalChain([choice, 'access',
|
|
767
|
+
const reasoningDelta = _nullishCoalesce(_optionalChain([choice, 'access', _43 => _43.delta, 'optionalAccess', _44 => _44.thinking, 'optionalAccess', _45 => _45.content]), () => ( _optionalChain([choice, 'access', _46 => _46.delta, 'optionalAccess', _47 => _47.reasoning_content])));
|
|
712
768
|
if (reasoningDelta) {
|
|
713
769
|
emitEvent({
|
|
714
770
|
type: "response.reasoning_summary_text.delta",
|
|
715
771
|
delta: reasoningDelta
|
|
716
772
|
});
|
|
717
773
|
}
|
|
718
|
-
if (_optionalChain([choice, 'access',
|
|
774
|
+
if (_optionalChain([choice, 'access', _48 => _48.delta, 'optionalAccess', _49 => _49.tool_calls])) {
|
|
719
775
|
for (const tc of choice.delta.tool_calls) {
|
|
720
776
|
const tcIndex = typeof tc["index"] === "number" ? tc["index"] : 0;
|
|
721
777
|
const func = _nullishCoalesce(tc["function"], () => ( {}));
|
|
@@ -727,7 +783,7 @@ function convertOpenAIStreamToResponseApi(openaiStream, codexTools) {
|
|
|
727
783
|
callId,
|
|
728
784
|
name,
|
|
729
785
|
arguments: "",
|
|
730
|
-
isCustom: _nullishCoalesce(_optionalChain([codexTools, 'optionalAccess',
|
|
786
|
+
isCustom: _nullishCoalesce(_optionalChain([codexTools, 'optionalAccess', _50 => _50.customToolNames, 'optionalAccess', _51 => _51.includes, 'call', _52 => _52(name)]), () => ( false))
|
|
731
787
|
};
|
|
732
788
|
toolCalls.set(tcIndex, entry);
|
|
733
789
|
const outIdx = nextOutputIndex++;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var _chunkA2YMUCBTcjs = require('./chunk-A2YMUCBT.cjs');
|
|
4
3
|
|
|
4
|
+
var _chunkUNEFIWXIcjs = require('./chunk-UNEFIWXI.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkA2YMUCBTcjs = require('./chunk-A2YMUCBT.cjs');
|
|
8
8
|
|
|
9
9
|
// src/completion/header-builder.ts
|
|
10
10
|
function getProviderHeaders(provider, apiKey) {
|
|
@@ -17,8 +17,11 @@ function getProviderHeaders(provider, apiKey) {
|
|
|
17
17
|
// Third-party Anthropic-Messages relays often gate on a Bearer token
|
|
18
18
|
// rather than x-api-key; `provider.useBearer` opts into that.
|
|
19
19
|
...provider.useBearer ? { Authorization: `Bearer ${apiKey}` } : { "x-api-key": apiKey },
|
|
20
|
-
|
|
21
|
-
//
|
|
20
|
+
// Official documented version date (claude-api-protocol-fidelity, R5);
|
|
21
|
+
// the former non-official future-dated value was removed. The BYO
|
|
22
|
+
// same-format path additionally forwards the caller's own
|
|
23
|
+
// `anthropic-version` verbatim when present (see `runSameFormatFetch`).
|
|
24
|
+
"anthropic-version": "2023-06-01"
|
|
22
25
|
};
|
|
23
26
|
break;
|
|
24
27
|
case "google":
|