@jeffusion/bungee-core 6.14.1 → 6.15.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.
Files changed (49) hide show
  1. package/dist/config-storage-worker.js +413 -216
  2. package/dist/main.js +16093 -13501
  3. package/dist/plugins/anthropic-request-sanitizer/index.js.map +1 -1
  4. package/dist/plugins/anthropic-tool-name-transformer/index.js.map +1 -1
  5. package/dist/plugins/chatgpt-oauth/control.js +13 -5
  6. package/dist/plugins/chatgpt-oauth/control.js.map +4 -4
  7. package/dist/plugins/chatgpt-oauth/index.js.map +1 -1
  8. package/dist/plugins/codex-router/control.js +2 -2
  9. package/dist/plugins/codex-router/control.js.map +4 -4
  10. package/dist/plugins/codex-router/index.js +99 -3
  11. package/dist/plugins/codex-router/index.js.map +8 -7
  12. package/dist/plugins/codex-router/manifest.json +6 -0
  13. package/dist/plugins/deepseek-reasoning-fix/index.js.map +1 -1
  14. package/dist/plugins/key-access/control.js +2 -2
  15. package/dist/plugins/key-access/control.js.map +4 -4
  16. package/dist/plugins/key-access/index.js.map +1 -1
  17. package/dist/plugins/key-access/ingress.js.map +1 -1
  18. package/dist/plugins/key-rate-limit/control.js +2 -2
  19. package/dist/plugins/key-rate-limit/control.js.map +4 -4
  20. package/dist/plugins/key-rate-limit/index.js +19 -7
  21. package/dist/plugins/key-rate-limit/index.js.map +4 -4
  22. package/dist/plugins/key-rate-limit/ingress.js +19 -7
  23. package/dist/plugins/key-rate-limit/ingress.js.map +3 -3
  24. package/dist/plugins/llm-protocol-adapter/control.js +113 -20
  25. package/dist/plugins/llm-protocol-adapter/control.js.map +9 -9
  26. package/dist/plugins/llm-protocol-adapter/index.js +100 -16
  27. package/dist/plugins/llm-protocol-adapter/index.js.map +8 -8
  28. package/dist/plugins/llm-tps/control.js +2 -2
  29. package/dist/plugins/llm-tps/control.js.map +3 -3
  30. package/dist/plugins/llm-tps/index.js.map +1 -1
  31. package/dist/plugins/model-mapping/control.js +2 -2
  32. package/dist/plugins/model-mapping/control.js.map +3 -3
  33. package/dist/plugins/model-mapping/index.js.map +1 -1
  34. package/dist/plugins/models-dev/control.js +13 -7
  35. package/dist/plugins/models-dev/control.js.map +3 -3
  36. package/dist/plugins/models-dev/index.js.map +1 -1
  37. package/dist/plugins/request-logs/index.js.map +1 -1
  38. package/dist/plugins/signature-repair/index.js.map +1 -1
  39. package/dist/plugins/token-budget/control.js +58 -47
  40. package/dist/plugins/token-budget/control.js.map +5 -5
  41. package/dist/plugins/token-budget/index.js.map +1 -1
  42. package/dist/plugins/token-metering/index.js.map +1 -1
  43. package/dist/plugins/token-stats/control.js +2 -2
  44. package/dist/plugins/token-stats/control.js.map +4 -4
  45. package/dist/plugins/token-stats/index.js.map +1 -1
  46. package/dist/plugins/user-auth/control.js +16 -15
  47. package/dist/plugins/user-auth/control.js.map +4 -4
  48. package/dist/plugins/user-auth/index.js.map +1 -1
  49. package/package.json +2 -2
@@ -4671,7 +4671,9 @@ function readGeminiSignatures(item, budget) {
4671
4671
  }
4672
4672
  function restoreGeminiHistory(input, budget) {
4673
4673
  const original = typeof input === "string" ? [] : list(input, "input").map((raw) => record(raw, "input item"));
4674
- const carriers = new Set, parts = new Map, ids = new Map;
4674
+ if (original.length > budget.maxItems)
4675
+ fail("resource_limit", "Too many input items", "input");
4676
+ const retained = new Map, parts = new Map, ids = new Map;
4675
4677
  original.forEach((item, i) => {
4676
4678
  if (typeof item.id === "string") {
4677
4679
  if (ids.has(item.id))
@@ -4680,10 +4682,19 @@ function restoreGeminiHistory(input, budget) {
4680
4682
  }
4681
4683
  });
4682
4684
  original.forEach((carrier, index) => {
4685
+ if (carrier.type === "configuration_update") {
4686
+ retained.set(carrier, carrier);
4687
+ return;
4688
+ }
4683
4689
  if (carrier.encrypted_content == null)
4684
4690
  return;
4685
- const signed = readGeminiSignatures(carrier, budget);
4686
- carriers.add(carrier);
4691
+ const { content, internal_chat_message_metadata_passthrough: metadata, ...normalized } = carrier;
4692
+ if (content !== undefined && content !== null)
4693
+ fail("unsupported_reasoning", "Gemini signature carriers cannot contain reasoning content", `input[${index}].content`);
4694
+ if (metadata !== undefined)
4695
+ atParam(`input[${index}].internal_chat_message_metadata_passthrough`, () => record(metadata, "message metadata"));
4696
+ const signed = readGeminiSignatures(normalized, budget);
4697
+ retained.set(carrier, normalized);
4687
4698
  let previous = -1;
4688
4699
  for (const item of signed) {
4689
4700
  const at = ids.get(item.id);
@@ -4713,14 +4724,18 @@ function restoreGeminiHistory(input, budget) {
4713
4724
  parts.set(item.id, restored);
4714
4725
  }
4715
4726
  });
4727
+ const positions = original.flatMap((item, index) => retained.has(item) ? [] : [index]);
4716
4728
  return {
4717
- input: typeof input === "string" ? input : original.filter((item) => !carriers.has(item)),
4729
+ input: typeof input === "string" ? input : positions.map((index) => original[index]),
4718
4730
  parts,
4731
+ sourceParam(param) {
4732
+ return param.replace(/^input\[(\d+)\]/, (match, index) => positions[Number(index)] === undefined ? match : `input[${positions[Number(index)]}]`);
4733
+ },
4719
4734
  canonicalHistory(decoded) {
4720
- if (!carriers.size)
4735
+ if (!retained.size)
4721
4736
  return decoded;
4722
4737
  let next = 0;
4723
- return original.flatMap((item) => carriers.has(item) ? [item] : item.type === "additional_tools" ? [] : [decoded[next++]]);
4738
+ return original.filter((item) => item.type !== "additional_tools").map((item) => retained.get(item) ?? decoded[next++]);
4724
4739
  }
4725
4740
  };
4726
4741
  }
@@ -5086,6 +5101,8 @@ function canonicalRequest(raw, protocol, model) {
5086
5101
  return out;
5087
5102
  }
5088
5103
  function validateCanonical(b, context) {
5104
+ const responsesToGemini = context.sourceProtocol === "responses" && context.targetProtocol === "gemini_generate_content";
5105
+ let configuration;
5089
5106
  for (const key of ["stream", "parallel_tool_calls", "store", "background"])
5090
5107
  if (b[key] !== undefined)
5091
5108
  bool(b[key], key);
@@ -5115,6 +5132,19 @@ function validateCanonical(b, context) {
5115
5132
  const input = typeof b.input === "string" ? [] : list(b.input, "input");
5116
5133
  for (const [i, raw] of input.entries()) {
5117
5134
  const t = record(raw, "input item"), p = `input[${i}]`;
5135
+ if (responsesToGemini && t.type === "configuration_update") {
5136
+ fields2(t, ["type", "reasoning"], p, "unsupported_content");
5137
+ const reasoning = atParam(`${p}.reasoning`, () => record(t.reasoning, "configuration reasoning"));
5138
+ fields2(reasoning, ["effort"], `${p}.reasoning`, "unsupported_reasoning");
5139
+ const param = `${p}.reasoning.effort`;
5140
+ const effort = atParam(param, () => string(reasoning.effort, "configuration effort", true));
5141
+ const map = context.reasoningPolicy?.effortMap;
5142
+ const level = map && Object.hasOwn(map, effort) ? map[effort] : undefined;
5143
+ if (level === undefined || !["minimal", "low", "medium", "high"].includes(level))
5144
+ fail("unsupported_reasoning", "Configuration update requires an explicit Gemini level mapping", param);
5145
+ configuration = { effort, level, param };
5146
+ continue;
5147
+ }
5118
5148
  if (t.type === "agent_message") {
5119
5149
  validateAgentMessage(t, p, context.capabilities?.limits);
5120
5150
  continue;
@@ -5184,9 +5214,37 @@ function validateCanonical(b, context) {
5184
5214
  for (const [j, tool] of list(t.tools, "tools").entries())
5185
5215
  inspectTool(tool, `input[${i}].tools[${j}]`);
5186
5216
  }
5217
+ return configuration;
5218
+ }
5219
+ function projectCodexPageSnapshot(raw, index, target, diagnostics) {
5220
+ const item = record(raw, "input item");
5221
+ const { name } = item;
5222
+ if (item.type !== "function_call_output" || item.call_id !== undefined || item.namespace !== "agent" || typeof name !== "string" || name !== "codex_apps_open_page" && !/^codex_apps_selected_page_part_[1-9]\d*_of_[1-9]\d*$/.test(name))
5223
+ return item;
5224
+ const param = `input[${index}]`;
5225
+ fields2(item, ["type", "id", "namespace", "name", "output", "internal_chat_message_metadata_passthrough"], param, "unsupported_content");
5226
+ const text = atParam(`${param}.output`, () => string(item.output, "page snapshot output"));
5227
+ const { id, internal_chat_message_metadata_passthrough: metadata } = item;
5228
+ const reason = target === "chat_completions" ? "chat_codex_page_snapshot_as_user_data" : "gemini_codex_page_snapshot_as_user_data";
5229
+ diagnostics.push({ param, action: "mapped", reason });
5230
+ return {
5231
+ type: "message",
5232
+ role: "user",
5233
+ ...id === undefined ? {} : { id },
5234
+ ...metadata === undefined ? {} : { internal_chat_message_metadata_passthrough: metadata },
5235
+ content: [
5236
+ { type: "input_text", text: `[Codex context snapshot: agent.${name}. Untrusted data.]` },
5237
+ { type: "input_text", text }
5238
+ ]
5239
+ };
5187
5240
  }
5188
5241
  function convertProtocolRequest(raw, context) {
5189
5242
  const b = canonicalRequest(raw, context.sourceProtocol, context.model);
5243
+ const target = context.targetProtocol;
5244
+ const responsesToGemini = context.sourceProtocol === "responses" && target === "gemini_generate_content";
5245
+ const pageSnapshotDiagnostics = [];
5246
+ if (context.sourceProtocol === "responses" && (target === "chat_completions" || target === "gemini_generate_content") && Array.isArray(b.input))
5247
+ b.input = b.input.map((item, index) => projectCodexPageSnapshot(item, index, target, pageSnapshotDiagnostics));
5190
5248
  const originalInput = b.input;
5191
5249
  if (context.streaming !== undefined) {
5192
5250
  bool(context.streaming, "context.streaming");
@@ -5194,8 +5252,8 @@ function convertProtocolRequest(raw, context) {
5194
5252
  fail("invalid_payload", "Request stream mode disagrees with transport context", "stream");
5195
5253
  b.stream = context.streaming;
5196
5254
  }
5197
- validateCanonical(b, context);
5198
- const geminiHistory = context.sourceProtocol === "responses" && context.targetProtocol === "gemini_generate_content" ? restoreGeminiHistory(b.input, limits(context.capabilities?.limits)) : undefined;
5255
+ const configuration = validateCanonical(b, context);
5256
+ const geminiHistory = responsesToGemini ? restoreGeminiHistory(b.input, limits(context.capabilities?.limits)) : undefined;
5199
5257
  if (geminiHistory)
5200
5258
  b.input = geminiHistory.input;
5201
5259
  const cap = { ...context.capabilities, agentMessageDelivery: context.agentMessageDelivery ?? context.capabilities?.agentMessageDelivery, omitOptionalWebSearch: true, preserveToolIdentityDescription: true, preserveRefusalContent: true }, policy = context.reasoningPolicy;
@@ -5220,9 +5278,10 @@ function convertProtocolRequest(raw, context) {
5220
5278
  if (mappedEffort !== undefined)
5221
5279
  string(mappedEffort, "reasoningPolicy.effortMap", true);
5222
5280
  }
5281
+ if (configuration)
5282
+ mappedEffort = configuration.level;
5223
5283
  if (sourceThinking !== undefined && reasoning?.effort === undefined && policy?.targetEffort !== undefined)
5224
5284
  mappedEffort = string(policy.targetEffort, "reasoningPolicy.targetEffort", true);
5225
- const target = context.targetProtocol;
5226
5285
  if (target === "gemini_generate_content" && reasoning?.effort !== undefined && mappedEffort === undefined && policy?.geminiThinkingBudget === undefined && policy?.geminiThinkingLevel === undefined)
5227
5286
  fail("unsupported_reasoning", "Gemini requires an explicit thinking budget or level", "reasoning.effort");
5228
5287
  if (sourceThinking !== undefined) {
@@ -5285,8 +5344,21 @@ function convertProtocolRequest(raw, context) {
5285
5344
  const decodingTarget = target === "gemini_generate_content" ? "chat_completions" : target;
5286
5345
  if (target === "gemini_generate_content" && reasoning)
5287
5346
  b.reasoning = { ...reasoning, effort: undefined };
5288
- const decoded = decodeResponsesRequest(b, decodingTarget, { ...cap, reasoningHistory: target !== "anthropic_messages" && cap.reasoningHistory === true, reasoningEffort: target === "chat_completions" && cap.reasoningEffort === true, anthropicThinkingBudget: undefined }, { preserveContentOrder: target === "gemini_generate_content", toolOutputImages: context.sourceProtocol === "responses" && target === "gemini_generate_content" });
5347
+ let decoded;
5348
+ try {
5349
+ decoded = decodeResponsesRequest(b, decodingTarget, { ...cap, reasoningHistory: target !== "anthropic_messages" && cap.reasoningHistory === true, reasoningEffort: target === "chat_completions" && cap.reasoningEffort === true, anthropicThinkingBudget: undefined }, { preserveContentOrder: target === "gemini_generate_content", toolOutputImages: responsesToGemini });
5350
+ } catch (error) {
5351
+ if (geminiHistory && error instanceof ResponsesCodecError && error.param !== undefined)
5352
+ throw new ResponsesCodecError(error.code, error.message, geminiHistory.sourceParam(error.param));
5353
+ throw error;
5354
+ }
5289
5355
  const diagnostics = decoded.diagnostics;
5356
+ if (geminiHistory)
5357
+ for (const diagnostic of diagnostics)
5358
+ diagnostic.param = geminiHistory.sourceParam(diagnostic.param);
5359
+ diagnostics.push(...pageSnapshotDiagnostics);
5360
+ if (configuration)
5361
+ diagnostics.push({ param: configuration.param, action: "mapped", reason: "gemini_configuration_effort_update" });
5290
5362
  if (target === "gemini_generate_content" && decoded.body.parallel_tool_calls === true) {
5291
5363
  delete decoded.body.parallel_tool_calls;
5292
5364
  diagnostics.push({ param: "parallel_tool_calls", action: "omitted", reason: "gemini_parallel_tool_calls_allowed" });
@@ -5316,17 +5388,24 @@ function convertProtocolRequest(raw, context) {
5316
5388
  if (target === "gemini_generate_content" && (mappedEffort !== undefined || policy?.geminiThinkingBudget !== undefined || policy?.geminiThinkingLevel !== undefined)) {
5317
5389
  const level = policy?.geminiThinkingLevel ?? mappedEffort;
5318
5390
  if (policy?.geminiThinkingBudget !== undefined && level !== undefined)
5319
- fail("unsupported_reasoning", "Choose one Gemini thinking policy", "reasoningPolicy");
5391
+ fail("unsupported_reasoning", "Choose one Gemini thinking policy", configuration?.param ?? "reasoningPolicy");
5320
5392
  if (level !== undefined && !["minimal", "low", "medium", "high"].includes(level))
5321
5393
  fail("unsupported_reasoning", "Unknown Gemini thinking level", "reasoning.effort");
5322
5394
  if (mappedEffort !== undefined && policy?.geminiThinkingLevel !== undefined && mappedEffort !== policy.geminiThinkingLevel)
5323
- fail("unsupported_reasoning", "Conflicting Gemini thinking levels", "reasoning.effort");
5395
+ fail("unsupported_reasoning", "Conflicting Gemini thinking levels", configuration?.param ?? "reasoning.effort");
5324
5396
  const thinkingConfig = policy?.geminiThinkingBudget !== undefined ? { thinkingBudget: integer(policy.geminiThinkingBudget, "reasoningPolicy.geminiThinkingBudget", -1) } : { thinkingLevel: string(level, "reasoningPolicy.geminiThinkingLevel", true) };
5325
5397
  body.generationConfig = { ...record(body.generationConfig ?? {}, "generationConfig"), thinkingConfig };
5326
5398
  }
5327
5399
  if (mappedEffort !== undefined || sourceThinking !== undefined || policy?.anthropicThinkingBudget !== undefined)
5328
5400
  diagnostics.push({ param: "reasoning", action: "mapped", reason: "explicit_verified_wire_policy" });
5329
- return { body, canonicalHistory: geminiHistory?.canonicalHistory(decoded.canonicalInput) ?? decoded.canonicalInput, diagnostics, toolNames: decoded.toolNames, streaming: b.stream === true };
5401
+ return {
5402
+ body,
5403
+ canonicalHistory: geminiHistory?.canonicalHistory(decoded.canonicalInput) ?? decoded.canonicalInput,
5404
+ diagnostics,
5405
+ toolNames: decoded.toolNames,
5406
+ streaming: b.stream === true,
5407
+ ...configuration ? { effectiveReasoningEffort: configuration.effort } : {}
5408
+ };
5330
5409
  }
5331
5410
  function renderGemini(chat, context, input, signedParts, diagnostics) {
5332
5411
  const result = { contents: [] }, contents = result.contents, system = [], calls = new Map;
@@ -6231,7 +6310,7 @@ class CanonicalStreamRenderer {
6231
6310
  var LLM_PROTOCOLS = ["responses", "chat_completions", "anthropic_messages", "gemini_generate_content"];
6232
6311
 
6233
6312
  // packages/llms/src/protocol-session/index.ts
6234
- var PROTOCOL_CONVERSION_RULES_VERSION = "1.0.4";
6313
+ var PROTOCOL_CONVERSION_RULES_VERSION = "1.0.5";
6235
6314
  function describeProtocolConversion() {
6236
6315
  return {
6237
6316
  rulesVersion: PROTOCOL_CONVERSION_RULES_VERSION,
@@ -6948,7 +7027,7 @@ class AgentRelay {
6948
7027
  }
6949
7028
 
6950
7029
  // plugins/llm-protocol-adapter/server/service.ts
6951
- var REASONING_RULES_VERSION = "2026-10-27.1";
7030
+ var REASONING_RULES_VERSION = "2026-11-11.1";
6952
7031
  var concrete = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max"]);
6953
7032
  var effortProtocols = new Set(["responses", "chat_completions", "anthropic_messages", "gemini_generate_content"]);
6954
7033
  var geminiEfforts = new Set(["minimal", "low", "medium", "high"]);
@@ -7065,6 +7144,11 @@ function conversionService(catalog, worker, history, runBackground) {
7065
7144
  selected = effort;
7066
7145
  }
7067
7146
  const result = engine.convertRequest(raw);
7147
+ if (result.effectiveReasoningEffort !== undefined) {
7148
+ if (!profile?.supportedEfforts.includes(result.effectiveReasoningEffort))
7149
+ fail2("reasoning.effort");
7150
+ selected = result.effectiveReasoningEffort;
7151
+ }
7068
7152
  rewrittenDeveloper = false;
7069
7153
  if (deepseekChat) {
7070
7154
  for (const message of chatMessages(result.body))
@@ -7597,4 +7681,4 @@ export {
7597
7681
  targetPath
7598
7682
  };
7599
7683
 
7600
- //# debugId=05408A147707650464756E2164756E21
7684
+ //# debugId=156C4C918244044B64756E2164756E21