@jeffusion/bungee-core 4.4.2 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15015,15 +15015,29 @@ function convertChatCompletionsRequestToCodex(input, model = String(input.model
|
|
|
15015
15015
|
out.text ??= {};
|
|
15016
15016
|
out.text.format = { type: "json_schema", ...clone(input.response_format.json_schema) };
|
|
15017
15017
|
}
|
|
15018
|
+
if (input.service_tier === "priority")
|
|
15019
|
+
out.service_tier = input.service_tier;
|
|
15020
|
+
if (isCodexResponsesLite(input))
|
|
15021
|
+
out.client_metadata = clone(input.client_metadata);
|
|
15018
15022
|
return normalizeCodexResponsesRequest(out);
|
|
15019
15023
|
}
|
|
15024
|
+
function isCodexResponsesLite(input, headers) {
|
|
15025
|
+
if (Object.entries(headers ?? {}).some(([name, value]) => name.toLowerCase() === "x-openai-internal-codex-responses-lite" && value.trim().toLowerCase() === "true"))
|
|
15026
|
+
return true;
|
|
15027
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
15028
|
+
return false;
|
|
15029
|
+
const metadataValue = input.client_metadata?.ws_request_header_x_openai_internal_codex_responses_lite;
|
|
15030
|
+
return metadataValue === true || typeof metadataValue === "string" && metadataValue.trim().toLowerCase() === "true";
|
|
15031
|
+
}
|
|
15020
15032
|
function normalizeCodexResponsesRequest(input) {
|
|
15021
15033
|
const out = clone(input);
|
|
15034
|
+
if (out.instructions === undefined || out.instructions === null)
|
|
15035
|
+
out.instructions = "";
|
|
15022
15036
|
if (out.response_format?.type === "json_object")
|
|
15023
15037
|
throw new CodexProtocolError("invalid_response", "Codex Responses does not support response_format json_object");
|
|
15024
15038
|
out.stream = true;
|
|
15025
15039
|
out.store = false;
|
|
15026
|
-
out.parallel_tool_calls = true;
|
|
15040
|
+
out.parallel_tool_calls = isCodexResponsesLite(out) ? false : true;
|
|
15027
15041
|
out.include = ["reasoning.encrypted_content"];
|
|
15028
15042
|
if (typeof out.input === "string")
|
|
15029
15043
|
out.input = [{ type: "message", role: "user", content: [{ type: "input_text", text: out.input }] }];
|
|
@@ -15773,7 +15787,7 @@ function parseCodexModelsBody(body, maxBodyBytes = DEFAULT_MAX_BODY_BYTES, maxMo
|
|
|
15773
15787
|
// plugins/chatgpt-oauth/server/constants.ts
|
|
15774
15788
|
var CODEX_COMPATIBILITY_VERSION = "0.153.3";
|
|
15775
15789
|
var CODEX_MODELS_USER_AGENT = `codex_cli_rs/${CODEX_COMPATIBILITY_VERSION} (Mac OS 26.3.1; arm64) iTerm.app/3.6.9`;
|
|
15776
|
-
var CODEX_RESPONSES_USER_AGENT =
|
|
15790
|
+
var CODEX_RESPONSES_USER_AGENT = "codex-tui/0.154.0 (Mac OS 26.5.2; arm64) iTerm.app/3.6.11 (codex-tui; 0.154.0)";
|
|
15777
15791
|
var CODEX_MODELS_ORIGINATOR = "codex_cli_rs";
|
|
15778
15792
|
var CODEX_RESPONSES_ORIGINATOR = "codex-tui";
|
|
15779
15793
|
|
|
@@ -15787,6 +15801,7 @@ var MAX_DISCARD_BYTES = 64 * 1024;
|
|
|
15787
15801
|
var MAX_MODELS_BODY_BYTES = 256 * 1024;
|
|
15788
15802
|
var MAX_PROFILE_HEADER_VALUE_BYTES = 8192;
|
|
15789
15803
|
var CHATGPT_ORIGIN = "https://chatgpt.com";
|
|
15804
|
+
var CODEX_ROUTING_HINT_HEADER = "X-Codex-Routing-Hint";
|
|
15790
15805
|
function record(value) {
|
|
15791
15806
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15792
15807
|
throw new CodexProtocolError("invalid_response", "Request must be a JSON object");
|
|
@@ -15796,6 +15811,30 @@ function record(value) {
|
|
|
15796
15811
|
function validHeaderValue(value) {
|
|
15797
15812
|
return typeof value === "string" && new TextEncoder().encode(value).byteLength <= MAX_PROFILE_HEADER_VALUE_BYTES && value.trim().length > 0 && !/[\r\n\0]/.test(value);
|
|
15798
15813
|
}
|
|
15814
|
+
function validRoutingHintPart(value) {
|
|
15815
|
+
return validHeaderValue(value) && !/[\x00-\x1F\x7F;]/.test(value);
|
|
15816
|
+
}
|
|
15817
|
+
function setCodexRoutingHint(headers, body) {
|
|
15818
|
+
for (const key of Object.keys(headers)) {
|
|
15819
|
+
if (key.toLowerCase() === CODEX_ROUTING_HINT_HEADER.toLowerCase())
|
|
15820
|
+
delete headers[key];
|
|
15821
|
+
}
|
|
15822
|
+
if (typeof body !== "object" || body === null || Array.isArray(body))
|
|
15823
|
+
return;
|
|
15824
|
+
const requestBody = body;
|
|
15825
|
+
if (!validRoutingHintPart(requestBody.model))
|
|
15826
|
+
return;
|
|
15827
|
+
const hint = requestBody.service_tier === "priority" ? `model=${requestBody.model};tier=priority` : `model=${requestBody.model}`;
|
|
15828
|
+
if (validHeaderValue(hint))
|
|
15829
|
+
setHeader(headers, CODEX_ROUTING_HINT_HEADER, hint);
|
|
15830
|
+
}
|
|
15831
|
+
function enforceCodexResponsesLite(context) {
|
|
15832
|
+
if (context.url.pathname !== CODEX_RESPONSES_PATH || !isCodexResponsesLite(context.body, context.headers))
|
|
15833
|
+
return;
|
|
15834
|
+
if (typeof context.body === "object" && context.body !== null && !Array.isArray(context.body)) {
|
|
15835
|
+
context.body = { ...context.body, parallel_tool_calls: false };
|
|
15836
|
+
}
|
|
15837
|
+
}
|
|
15799
15838
|
function headerValue(headers, name) {
|
|
15800
15839
|
const lowerName = name.toLowerCase();
|
|
15801
15840
|
const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === lowerName);
|
|
@@ -16025,7 +16064,12 @@ class ChatgptOauthAdapter {
|
|
|
16025
16064
|
constructor() {}
|
|
16026
16065
|
beforeRequest(context) {
|
|
16027
16066
|
const target = context.url.pathname === MODELS_PATH ? "models" : context.url.pathname === CHAT_COMPLETIONS_PATH ? "chat" : context.url.pathname === RESPONSES_PATH ? "responses" : undefined;
|
|
16028
|
-
if (
|
|
16067
|
+
if (context.url.pathname === CODEX_RESPONSES_PATH) {
|
|
16068
|
+
setCodexRoutingHint(context.headers, context.body);
|
|
16069
|
+
enforceCodexResponsesLite(context);
|
|
16070
|
+
return context;
|
|
16071
|
+
}
|
|
16072
|
+
if (target === undefined)
|
|
16029
16073
|
return context;
|
|
16030
16074
|
if (target === "models") {
|
|
16031
16075
|
context.body = undefined;
|
|
@@ -16053,10 +16097,12 @@ class ChatgptOauthAdapter {
|
|
|
16053
16097
|
if (target === "chat" && promptCacheKey !== undefined)
|
|
16054
16098
|
context.body.prompt_cache_key = promptCacheKey;
|
|
16055
16099
|
context.url.pathname = CODEX_RESPONSES_PATH;
|
|
16100
|
+
enforceCodexResponsesLite(context);
|
|
16056
16101
|
setHeader(context.headers, "Accept", "text/event-stream");
|
|
16057
16102
|
setHeader(context.headers, "Content-Type", "application/json");
|
|
16058
16103
|
setHeader(context.headers, "User-Agent", CODEX_RESPONSES_USER_AGENT);
|
|
16059
16104
|
setHeader(context.headers, "Originator", CODEX_RESPONSES_ORIGINATOR);
|
|
16105
|
+
setCodexRoutingHint(context.headers, context.body);
|
|
16060
16106
|
for (const key of Object.keys(context.headers)) {
|
|
16061
16107
|
if (key.toLowerCase() === "session-id")
|
|
16062
16108
|
delete context.headers[key];
|
|
@@ -16072,6 +16118,13 @@ class ChatgptOauthAdapter {
|
|
|
16072
16118
|
}));
|
|
16073
16119
|
return context;
|
|
16074
16120
|
}
|
|
16121
|
+
reconcileOutboundRequest(context) {
|
|
16122
|
+
if (context.url.pathname === CODEX_RESPONSES_PATH) {
|
|
16123
|
+
setCodexRoutingHint(context.headers, context.body);
|
|
16124
|
+
enforceCodexResponsesLite(context);
|
|
16125
|
+
}
|
|
16126
|
+
return context;
|
|
16127
|
+
}
|
|
16075
16128
|
async rawResponse(result, context) {
|
|
16076
16129
|
const current = this.requests.get(context.requestId);
|
|
16077
16130
|
if (current === undefined || current.adaptedResponses.has(result.response))
|
|
@@ -16178,6 +16231,7 @@ var ChatgptOauthPlugin = definePlugin(class {
|
|
|
16178
16231
|
}
|
|
16179
16232
|
register(hooks) {
|
|
16180
16233
|
hooks.onBeforeRequest.tap({ name: "chatgpt-oauth", stage: -10 }, (context) => this.adapter.beforeRequest(context));
|
|
16234
|
+
hooks.onBeforeRequest.tap({ name: "chatgpt-oauth-outbound-reconciliation", stage: 1000 }, (context) => this.adapter.reconcileOutboundRequest(context));
|
|
16181
16235
|
hooks.onRawResponse.tapPromise({ name: "chatgpt-oauth", stage: -10 }, (result, context) => this.adapter.rawResponse(result, context));
|
|
16182
16236
|
}
|
|
16183
16237
|
});
|
|
@@ -16187,4 +16241,4 @@ export {
|
|
|
16187
16241
|
server_default as default
|
|
16188
16242
|
};
|
|
16189
16243
|
|
|
16190
|
-
//# debugId=
|
|
16244
|
+
//# debugId=E10DF2A073F962A664756E2164756E21
|