@jeffusion/bungee-core 5.23.3 → 5.24.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/dist/main.js +25 -3
- package/dist/plugins/chatgpt-oauth/index.js +16 -2
- package/dist/plugins/chatgpt-oauth/index.js.map +3 -3
- package/dist/plugins/chatgpt-oauth/manifest.json +23 -2
- package/dist/plugins/codex-router/index.js +90 -16
- package/dist/plugins/codex-router/index.js.map +4 -4
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -201027,7 +201027,7 @@ var package_default;
|
|
|
201027
201027
|
var init_package = __esm(() => {
|
|
201028
201028
|
package_default = {
|
|
201029
201029
|
name: "@jeffusion/bungee-core",
|
|
201030
|
-
version: "5.
|
|
201030
|
+
version: "5.24.1",
|
|
201031
201031
|
description: "Bungee reverse proxy core engine",
|
|
201032
201032
|
main: "./dist/main.js",
|
|
201033
201033
|
types: "./dist/main.d.ts",
|
|
@@ -220107,6 +220107,16 @@ async function executePreFailoverPhase(phase, ctx, options) {
|
|
|
220107
220107
|
}
|
|
220108
220108
|
const interceptResult = await phase.hooks.onInterceptRequest.promise(ctx);
|
|
220109
220109
|
if (interceptResult?.action === "respond") {
|
|
220110
|
+
if (interceptResult.response.ok) {
|
|
220111
|
+
try {
|
|
220112
|
+
await options.authorizeResponse?.();
|
|
220113
|
+
} catch (error) {
|
|
220114
|
+
await interceptResult.response.body?.cancel().catch(() => {
|
|
220115
|
+
return;
|
|
220116
|
+
});
|
|
220117
|
+
throw error;
|
|
220118
|
+
}
|
|
220119
|
+
}
|
|
220110
220120
|
return interceptResult.response;
|
|
220111
220121
|
}
|
|
220112
220122
|
if (interceptResult?.action === "failover") {
|
|
@@ -220838,12 +220848,23 @@ async function executeHttpRequestInternal(req, config, runtimeContextOrSelector,
|
|
|
220838
220848
|
phaseContext.url = new URL(dispatch.context.url);
|
|
220839
220849
|
phaseContext.bodyRequirements = routeDemand;
|
|
220840
220850
|
applyRoutePathRewriteToContext(phaseContext, route, requestLog);
|
|
220851
|
+
const authorizePhaseResponse = async () => {
|
|
220852
|
+
await dataAdmission?.inspect({
|
|
220853
|
+
attemptId: requestId,
|
|
220854
|
+
upstreamId: endpoints[0]?.id ?? "0",
|
|
220855
|
+
url: phaseContext.url.href,
|
|
220856
|
+
model: typeof phaseContext.body?.model === "string" ? phaseContext.body.model : null,
|
|
220857
|
+
body: phaseContext.body,
|
|
220858
|
+
transport: runtimeContext?.transport
|
|
220859
|
+
}, processingSignal);
|
|
220860
|
+
};
|
|
220841
220861
|
const routePhaseResponse = await executePreFailoverPhase(requestPhaseHooks?.routePhase, phaseContext, {
|
|
220842
220862
|
phaseName: "route",
|
|
220843
220863
|
requestLog,
|
|
220844
220864
|
requestId,
|
|
220845
220865
|
routeId: currentRouteId,
|
|
220846
|
-
serviceName: routeServiceName
|
|
220866
|
+
serviceName: routeServiceName,
|
|
220867
|
+
authorizeResponse: authorizePhaseResponse
|
|
220847
220868
|
});
|
|
220848
220869
|
if (routePhaseResponse) {
|
|
220849
220870
|
responseStatus = routePhaseResponse.status;
|
|
@@ -220855,7 +220876,8 @@ async function executeHttpRequestInternal(req, config, runtimeContextOrSelector,
|
|
|
220855
220876
|
requestLog,
|
|
220856
220877
|
requestId,
|
|
220857
220878
|
routeId: currentRouteId,
|
|
220858
|
-
serviceName: routeServiceName
|
|
220879
|
+
serviceName: routeServiceName,
|
|
220880
|
+
authorizeResponse: authorizePhaseResponse
|
|
220859
220881
|
});
|
|
220860
220882
|
if (servicePhaseResponse) {
|
|
220861
220883
|
responseStatus = servicePhaseResponse.status;
|
|
@@ -1439,10 +1439,12 @@ var CODEX_RESPONSES_ORIGINATOR = "codex-tui";
|
|
|
1439
1439
|
// plugins/chatgpt-oauth/server/adapter.ts
|
|
1440
1440
|
var CHAT_COMPLETIONS_PATH = "/v1/chat/completions";
|
|
1441
1441
|
var RESPONSES_PATH = "/responses";
|
|
1442
|
+
var SEARCH_PATH = "/alpha/search";
|
|
1442
1443
|
var SIWC_RESPONSES_PATH = "/v1/responses";
|
|
1443
1444
|
var MODELS_PATH = "/v1/models";
|
|
1444
1445
|
var CODEX_RESPONSES_PATH = "/backend-api/codex/responses";
|
|
1445
1446
|
var CODEX_MODELS_PATH = "/backend-api/codex/models";
|
|
1447
|
+
var CODEX_SEARCH_PATH = "/backend-api/codex/alpha/search";
|
|
1446
1448
|
function isResponsesRequest(url) {
|
|
1447
1449
|
return url.pathname === RESPONSES_PATH;
|
|
1448
1450
|
}
|
|
@@ -1879,6 +1881,10 @@ class ChatgptOauthAdapter {
|
|
|
1879
1881
|
}));
|
|
1880
1882
|
return context;
|
|
1881
1883
|
}
|
|
1884
|
+
if (context.method.toUpperCase() === "POST" && context.url.pathname === SEARCH_PATH) {
|
|
1885
|
+
context.url.pathname = CODEX_SEARCH_PATH;
|
|
1886
|
+
return context;
|
|
1887
|
+
}
|
|
1882
1888
|
if (context.url.pathname === CODEX_RESPONSES_PATH) {
|
|
1883
1889
|
setCodexRoutingHint(context.headers, context.body);
|
|
1884
1890
|
enforceCodexResponsesLite(context);
|
|
@@ -2006,6 +2012,10 @@ class ChatgptOauthAdapter {
|
|
|
2006
2012
|
result.completion.then(cleanup, cleanup);
|
|
2007
2013
|
return result;
|
|
2008
2014
|
}
|
|
2015
|
+
if (state.target === "models" && result.response.status === 304) {
|
|
2016
|
+
trackCompletion(result.completion);
|
|
2017
|
+
return result;
|
|
2018
|
+
}
|
|
2009
2019
|
if (!context.bodyHandle) {
|
|
2010
2020
|
return errorResponse(502, Promise.resolve({ status: "failed", code: "body_view_missing" }));
|
|
2011
2021
|
}
|
|
@@ -2031,10 +2041,14 @@ class ChatgptOauthAdapter {
|
|
|
2031
2041
|
data: models.map(({ id }) => ({ id, object: "model", owned_by: "openai" }))
|
|
2032
2042
|
};
|
|
2033
2043
|
const completion = joinCompletion(result.completion, Promise.resolve({ status: "completed" }), context.signal);
|
|
2044
|
+
const headers = responseHeaders(result.response, "application/json; charset=utf-8");
|
|
2045
|
+
const etag = result.response.headers.get("etag");
|
|
2046
|
+
if (etag !== null)
|
|
2047
|
+
headers.set("etag", etag);
|
|
2034
2048
|
const response = mark(new Response(JSON.stringify(body), {
|
|
2035
2049
|
status: result.response.status,
|
|
2036
2050
|
statusText: result.response.statusText,
|
|
2037
|
-
headers
|
|
2051
|
+
headers
|
|
2038
2052
|
}));
|
|
2039
2053
|
trackCompletion(completion);
|
|
2040
2054
|
return { response, completion };
|
|
@@ -2128,4 +2142,4 @@ export {
|
|
|
2128
2142
|
server_default as default
|
|
2129
2143
|
};
|
|
2130
2144
|
|
|
2131
|
-
//# debugId=
|
|
2145
|
+
//# debugId=6AB7BD049B59B52A64756E2164756E21
|