@jeffusion/bungee-core 5.22.0 → 5.23.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.
Files changed (34) hide show
  1. package/dist/main.js +3382 -3104
  2. package/dist/plugins/anthropic-request-sanitizer/index.js.map +2 -2
  3. package/dist/plugins/anthropic-tool-name-transformer/index.js.map +2 -2
  4. package/dist/plugins/chatgpt-oauth/control.js.map +2 -2
  5. package/dist/plugins/chatgpt-oauth/index.js +20 -7
  6. package/dist/plugins/chatgpt-oauth/index.js.map +6 -6
  7. package/dist/plugins/codex-router/index.js +174 -80
  8. package/dist/plugins/codex-router/index.js.map +8 -8
  9. package/dist/plugins/codex-router/manifest.json +63 -12
  10. package/dist/plugins/deepseek-reasoning-fix/index.js.map +2 -2
  11. package/dist/plugins/key-access/control.js.map +3 -3
  12. package/dist/plugins/key-access/index.js +19 -5
  13. package/dist/plugins/key-access/index.js.map +6 -6
  14. package/dist/plugins/key-access/ingress.js +19 -5
  15. package/dist/plugins/key-access/ingress.js.map +6 -6
  16. package/dist/plugins/key-rate-limit/index.js.map +2 -2
  17. package/dist/plugins/llm-protocol-adapter/control.js +785 -209
  18. package/dist/plugins/llm-protocol-adapter/control.js.map +21 -17
  19. package/dist/plugins/llm-protocol-adapter/index.js +861 -208
  20. package/dist/plugins/llm-protocol-adapter/index.js.map +21 -17
  21. package/dist/plugins/llm-protocol-adapter/manifest.json +7 -0
  22. package/dist/plugins/local-accounts/control.js.map +2 -2
  23. package/dist/plugins/local-accounts/index.js.map +2 -2
  24. package/dist/plugins/model-mapping/index.js.map +2 -2
  25. package/dist/plugins/models-dev/index.js.map +2 -2
  26. package/dist/plugins/signature-repair/index.js.map +2 -2
  27. package/dist/plugins/token-budget/control.js.map +2 -2
  28. package/dist/plugins/token-budget/index.js.map +3 -3
  29. package/dist/plugins/token-metering/index.js +9 -9
  30. package/dist/plugins/token-metering/index.js.map +7 -7
  31. package/dist/plugins/token-stats/control.js.map +2 -2
  32. package/dist/plugins/token-stats/index.js.map +3 -3
  33. package/dist/plugins/token-stats/ui/PriceModelPicker.svelte +3 -3
  34. package/package.json +2 -2
@@ -1438,10 +1438,19 @@ var CODEX_RESPONSES_ORIGINATOR = "codex-tui";
1438
1438
 
1439
1439
  // plugins/chatgpt-oauth/server/adapter.ts
1440
1440
  var CHAT_COMPLETIONS_PATH = "/v1/chat/completions";
1441
- var RESPONSES_PATH = "/v1/responses";
1441
+ var RESPONSES_PATH = "/responses";
1442
+ var SIWC_RESPONSES_PATH = "/v1/responses";
1442
1443
  var MODELS_PATH = "/v1/models";
1443
1444
  var CODEX_RESPONSES_PATH = "/backend-api/codex/responses";
1444
1445
  var CODEX_MODELS_PATH = "/backend-api/codex/models";
1446
+ function isResponsesRequest(url) {
1447
+ return url.pathname === RESPONSES_PATH;
1448
+ }
1449
+ function assertResponsesEntryPath(path) {
1450
+ if (path === SIWC_RESPONSES_PATH) {
1451
+ throw new CodexProtocolError("invalid_response", "Responses requests must use /responses; the plugin supplies the upstream prefix");
1452
+ }
1453
+ }
1445
1454
  var MAX_PROFILE_HEADER_VALUE_BYTES = 8192;
1446
1455
  var CHATGPT_ORIGIN = "https://chatgpt.com";
1447
1456
  var SIWC_ORIGIN = "https://api.openai.com";
@@ -1813,7 +1822,8 @@ class ChatgptOauthAdapter {
1813
1822
  requests = new Map;
1814
1823
  constructor() {}
1815
1824
  beforeRequest(context) {
1816
- const target = context.url.pathname === MODELS_PATH || context.originalUrl.searchParams.has("client_version") && context.url.pathname === "/models" ? "models" : context.url.pathname === CHAT_COMPLETIONS_PATH ? "chat" : context.url.pathname === RESPONSES_PATH ? "responses" : undefined;
1825
+ assertResponsesEntryPath(context.url.pathname);
1826
+ const target = context.url.pathname === MODELS_PATH || context.originalUrl.searchParams.has("client_version") && context.url.pathname === "/models" ? "models" : context.url.pathname === CHAT_COMPLETIONS_PATH ? "chat" : isResponsesRequest(context.url) ? "responses" : undefined;
1817
1827
  if (context.url.origin === SIWC_ORIGIN) {
1818
1828
  if (target === undefined)
1819
1829
  return context;
@@ -1822,7 +1832,7 @@ class ChatgptOauthAdapter {
1822
1832
  const includeUsage = input ? streamIncludesUsage(input) : false;
1823
1833
  context.body = input ? normalizeSiwcRequest(input, target) : undefined;
1824
1834
  if (target !== "models")
1825
- context.url.pathname = RESPONSES_PATH;
1835
+ context.url.pathname = SIWC_RESPONSES_PATH;
1826
1836
  setSiwcHeaders(context, target);
1827
1837
  this.requests.set(context.requestId, Object.freeze({
1828
1838
  target,
@@ -1891,7 +1901,7 @@ class ChatgptOauthAdapter {
1891
1901
  }
1892
1902
  reconcileOutboundRequest(context) {
1893
1903
  if (context.url.origin === SIWC_ORIGIN) {
1894
- if (context.url.pathname === RESPONSES_PATH) {
1904
+ if (context.url.pathname === SIWC_RESPONSES_PATH) {
1895
1905
  context.body = normalizeSiwcRequest(record(context.body), "responses");
1896
1906
  setSiwcHeaders(context, "responses");
1897
1907
  } else if (context.url.pathname === MODELS_PATH)
@@ -2024,12 +2034,15 @@ var ChatgptOauthPlugin = definePlugin(class {
2024
2034
  const path = context.url.pathname;
2025
2035
  if (path === "/v1/models" && context.method.toUpperCase() === "GET")
2026
2036
  return { request: "none", response: ["json"] };
2027
- return context.method.toUpperCase() === "POST" && ["/v1/chat/completions", "/v1/responses", "/backend-api/codex/responses"].includes(path) ? { request: "json-write", response: path === "/backend-api/codex/responses" ? [] : ["json", "sse-json"] } : { request: "none" };
2037
+ return context.method.toUpperCase() === "POST" && (isResponsesRequest(context.url) || ["/v1/chat/completions", "/backend-api/codex/responses"].includes(path)) ? { request: "json-write", response: path === "/backend-api/codex/responses" ? [] : ["json", "sse-json"] } : { request: "none" };
2028
2038
  }
2029
2039
  register(hooks) {
2030
2040
  hooks.onWebSocketHandshake.tap("chatgpt-oauth", (context) => {
2031
- if (context.url.origin === "https://chatgpt.com" && context.url.pathname === "/v1/responses")
2041
+ assertResponsesEntryPath(context.url.pathname);
2042
+ if (context.url.origin === "https://chatgpt.com" && isResponsesRequest(context.url))
2032
2043
  context.url.pathname = "/backend-api/codex/responses";
2044
+ else if (context.url.origin === "https://api.openai.com" && isResponsesRequest(context.url))
2045
+ context.url.pathname = "/v1/responses";
2033
2046
  return context;
2034
2047
  });
2035
2048
  hooks.onBeforeRequest.tap({ name: "chatgpt-oauth", stage: -10 }, (context) => this.adapter.beforeRequest(context));
@@ -2043,4 +2056,4 @@ export {
2043
2056
  server_default as default
2044
2057
  };
2045
2058
 
2046
- //# debugId=5BB6E67C75D33EDE64756E2164756E21
2059
+ //# debugId=F44D362B53E644C964756E2164756E21