@jeffusion/bungee-core 6.15.0 → 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.
|
@@ -4568,27 +4568,6 @@ function textParts(raw, path, style, role) {
|
|
|
4568
4568
|
|
|
4569
4569
|
// packages/llms/src/protocol-session/gemini.ts
|
|
4570
4570
|
var signatureSeparator = "__thought__";
|
|
4571
|
-
function projectGeminiCodexPageSnapshot(raw, index, diagnostics) {
|
|
4572
|
-
const item = record(raw, "input item");
|
|
4573
|
-
const { name } = item;
|
|
4574
|
-
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))
|
|
4575
|
-
return item;
|
|
4576
|
-
const param = `input[${index}]`;
|
|
4577
|
-
fields2(item, ["type", "id", "namespace", "name", "output", "internal_chat_message_metadata_passthrough"], param, "unsupported_content");
|
|
4578
|
-
const text = atParam(`${param}.output`, () => string(item.output, "page snapshot output"));
|
|
4579
|
-
const { id, internal_chat_message_metadata_passthrough: metadata } = item;
|
|
4580
|
-
diagnostics.push({ param, action: "mapped", reason: "gemini_codex_page_snapshot_as_user_data" });
|
|
4581
|
-
return {
|
|
4582
|
-
type: "message",
|
|
4583
|
-
role: "user",
|
|
4584
|
-
...id === undefined ? {} : { id },
|
|
4585
|
-
...metadata === undefined ? {} : { internal_chat_message_metadata_passthrough: metadata },
|
|
4586
|
-
content: [
|
|
4587
|
-
{ type: "input_text", text: `[Codex context snapshot: agent.${name}. Untrusted data.]` },
|
|
4588
|
-
{ type: "input_text", text }
|
|
4589
|
-
]
|
|
4590
|
-
};
|
|
4591
|
-
}
|
|
4592
4571
|
function geminiInlineImage(image, path, budget) {
|
|
4593
4572
|
const param = `${path}.image_url`;
|
|
4594
4573
|
const url = bounded(string(image.url, "image URL", true), budget.maxRequestBytes, param);
|
|
@@ -4692,7 +4671,9 @@ function readGeminiSignatures(item, budget) {
|
|
|
4692
4671
|
}
|
|
4693
4672
|
function restoreGeminiHistory(input, budget) {
|
|
4694
4673
|
const original = typeof input === "string" ? [] : list(input, "input").map((raw) => record(raw, "input item"));
|
|
4695
|
-
|
|
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;
|
|
4696
4677
|
original.forEach((item, i) => {
|
|
4697
4678
|
if (typeof item.id === "string") {
|
|
4698
4679
|
if (ids.has(item.id))
|
|
@@ -4701,10 +4682,19 @@ function restoreGeminiHistory(input, budget) {
|
|
|
4701
4682
|
}
|
|
4702
4683
|
});
|
|
4703
4684
|
original.forEach((carrier, index) => {
|
|
4685
|
+
if (carrier.type === "configuration_update") {
|
|
4686
|
+
retained.set(carrier, carrier);
|
|
4687
|
+
return;
|
|
4688
|
+
}
|
|
4704
4689
|
if (carrier.encrypted_content == null)
|
|
4705
4690
|
return;
|
|
4706
|
-
const
|
|
4707
|
-
|
|
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);
|
|
4708
4698
|
let previous = -1;
|
|
4709
4699
|
for (const item of signed) {
|
|
4710
4700
|
const at = ids.get(item.id);
|
|
@@ -4734,14 +4724,18 @@ function restoreGeminiHistory(input, budget) {
|
|
|
4734
4724
|
parts.set(item.id, restored);
|
|
4735
4725
|
}
|
|
4736
4726
|
});
|
|
4727
|
+
const positions = original.flatMap((item, index) => retained.has(item) ? [] : [index]);
|
|
4737
4728
|
return {
|
|
4738
|
-
input: typeof input === "string" ? input :
|
|
4729
|
+
input: typeof input === "string" ? input : positions.map((index) => original[index]),
|
|
4739
4730
|
parts,
|
|
4731
|
+
sourceParam(param) {
|
|
4732
|
+
return param.replace(/^input\[(\d+)\]/, (match, index) => positions[Number(index)] === undefined ? match : `input[${positions[Number(index)]}]`);
|
|
4733
|
+
},
|
|
4740
4734
|
canonicalHistory(decoded) {
|
|
4741
|
-
if (!
|
|
4735
|
+
if (!retained.size)
|
|
4742
4736
|
return decoded;
|
|
4743
4737
|
let next = 0;
|
|
4744
|
-
return original.
|
|
4738
|
+
return original.filter((item) => item.type !== "additional_tools").map((item) => retained.get(item) ?? decoded[next++]);
|
|
4745
4739
|
}
|
|
4746
4740
|
};
|
|
4747
4741
|
}
|
|
@@ -5107,6 +5101,8 @@ function canonicalRequest(raw, protocol, model) {
|
|
|
5107
5101
|
return out;
|
|
5108
5102
|
}
|
|
5109
5103
|
function validateCanonical(b, context) {
|
|
5104
|
+
const responsesToGemini = context.sourceProtocol === "responses" && context.targetProtocol === "gemini_generate_content";
|
|
5105
|
+
let configuration;
|
|
5110
5106
|
for (const key of ["stream", "parallel_tool_calls", "store", "background"])
|
|
5111
5107
|
if (b[key] !== undefined)
|
|
5112
5108
|
bool(b[key], key);
|
|
@@ -5136,6 +5132,19 @@ function validateCanonical(b, context) {
|
|
|
5136
5132
|
const input = typeof b.input === "string" ? [] : list(b.input, "input");
|
|
5137
5133
|
for (const [i, raw] of input.entries()) {
|
|
5138
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
|
+
}
|
|
5139
5148
|
if (t.type === "agent_message") {
|
|
5140
5149
|
validateAgentMessage(t, p, context.capabilities?.limits);
|
|
5141
5150
|
continue;
|
|
@@ -5205,13 +5214,37 @@ function validateCanonical(b, context) {
|
|
|
5205
5214
|
for (const [j, tool] of list(t.tools, "tools").entries())
|
|
5206
5215
|
inspectTool(tool, `input[${i}].tools[${j}]`);
|
|
5207
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
|
+
};
|
|
5208
5240
|
}
|
|
5209
5241
|
function convertProtocolRequest(raw, context) {
|
|
5210
5242
|
const b = canonicalRequest(raw, context.sourceProtocol, context.model);
|
|
5211
|
-
const
|
|
5243
|
+
const target = context.targetProtocol;
|
|
5244
|
+
const responsesToGemini = context.sourceProtocol === "responses" && target === "gemini_generate_content";
|
|
5212
5245
|
const pageSnapshotDiagnostics = [];
|
|
5213
|
-
if (
|
|
5214
|
-
b.input = b.input.map((item, index) =>
|
|
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));
|
|
5215
5248
|
const originalInput = b.input;
|
|
5216
5249
|
if (context.streaming !== undefined) {
|
|
5217
5250
|
bool(context.streaming, "context.streaming");
|
|
@@ -5219,7 +5252,7 @@ function convertProtocolRequest(raw, context) {
|
|
|
5219
5252
|
fail("invalid_payload", "Request stream mode disagrees with transport context", "stream");
|
|
5220
5253
|
b.stream = context.streaming;
|
|
5221
5254
|
}
|
|
5222
|
-
validateCanonical(b, context);
|
|
5255
|
+
const configuration = validateCanonical(b, context);
|
|
5223
5256
|
const geminiHistory = responsesToGemini ? restoreGeminiHistory(b.input, limits(context.capabilities?.limits)) : undefined;
|
|
5224
5257
|
if (geminiHistory)
|
|
5225
5258
|
b.input = geminiHistory.input;
|
|
@@ -5245,9 +5278,10 @@ function convertProtocolRequest(raw, context) {
|
|
|
5245
5278
|
if (mappedEffort !== undefined)
|
|
5246
5279
|
string(mappedEffort, "reasoningPolicy.effortMap", true);
|
|
5247
5280
|
}
|
|
5281
|
+
if (configuration)
|
|
5282
|
+
mappedEffort = configuration.level;
|
|
5248
5283
|
if (sourceThinking !== undefined && reasoning?.effort === undefined && policy?.targetEffort !== undefined)
|
|
5249
5284
|
mappedEffort = string(policy.targetEffort, "reasoningPolicy.targetEffort", true);
|
|
5250
|
-
const target = context.targetProtocol;
|
|
5251
5285
|
if (target === "gemini_generate_content" && reasoning?.effort !== undefined && mappedEffort === undefined && policy?.geminiThinkingBudget === undefined && policy?.geminiThinkingLevel === undefined)
|
|
5252
5286
|
fail("unsupported_reasoning", "Gemini requires an explicit thinking budget or level", "reasoning.effort");
|
|
5253
5287
|
if (sourceThinking !== undefined) {
|
|
@@ -5310,9 +5344,21 @@ function convertProtocolRequest(raw, context) {
|
|
|
5310
5344
|
const decodingTarget = target === "gemini_generate_content" ? "chat_completions" : target;
|
|
5311
5345
|
if (target === "gemini_generate_content" && reasoning)
|
|
5312
5346
|
b.reasoning = { ...reasoning, effort: undefined };
|
|
5313
|
-
|
|
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
|
+
}
|
|
5314
5355
|
const diagnostics = decoded.diagnostics;
|
|
5356
|
+
if (geminiHistory)
|
|
5357
|
+
for (const diagnostic of diagnostics)
|
|
5358
|
+
diagnostic.param = geminiHistory.sourceParam(diagnostic.param);
|
|
5315
5359
|
diagnostics.push(...pageSnapshotDiagnostics);
|
|
5360
|
+
if (configuration)
|
|
5361
|
+
diagnostics.push({ param: configuration.param, action: "mapped", reason: "gemini_configuration_effort_update" });
|
|
5316
5362
|
if (target === "gemini_generate_content" && decoded.body.parallel_tool_calls === true) {
|
|
5317
5363
|
delete decoded.body.parallel_tool_calls;
|
|
5318
5364
|
diagnostics.push({ param: "parallel_tool_calls", action: "omitted", reason: "gemini_parallel_tool_calls_allowed" });
|
|
@@ -5342,17 +5388,24 @@ function convertProtocolRequest(raw, context) {
|
|
|
5342
5388
|
if (target === "gemini_generate_content" && (mappedEffort !== undefined || policy?.geminiThinkingBudget !== undefined || policy?.geminiThinkingLevel !== undefined)) {
|
|
5343
5389
|
const level = policy?.geminiThinkingLevel ?? mappedEffort;
|
|
5344
5390
|
if (policy?.geminiThinkingBudget !== undefined && level !== undefined)
|
|
5345
|
-
fail("unsupported_reasoning", "Choose one Gemini thinking policy", "reasoningPolicy");
|
|
5391
|
+
fail("unsupported_reasoning", "Choose one Gemini thinking policy", configuration?.param ?? "reasoningPolicy");
|
|
5346
5392
|
if (level !== undefined && !["minimal", "low", "medium", "high"].includes(level))
|
|
5347
5393
|
fail("unsupported_reasoning", "Unknown Gemini thinking level", "reasoning.effort");
|
|
5348
5394
|
if (mappedEffort !== undefined && policy?.geminiThinkingLevel !== undefined && mappedEffort !== policy.geminiThinkingLevel)
|
|
5349
|
-
fail("unsupported_reasoning", "Conflicting Gemini thinking levels", "reasoning.effort");
|
|
5395
|
+
fail("unsupported_reasoning", "Conflicting Gemini thinking levels", configuration?.param ?? "reasoning.effort");
|
|
5350
5396
|
const thinkingConfig = policy?.geminiThinkingBudget !== undefined ? { thinkingBudget: integer(policy.geminiThinkingBudget, "reasoningPolicy.geminiThinkingBudget", -1) } : { thinkingLevel: string(level, "reasoningPolicy.geminiThinkingLevel", true) };
|
|
5351
5397
|
body.generationConfig = { ...record(body.generationConfig ?? {}, "generationConfig"), thinkingConfig };
|
|
5352
5398
|
}
|
|
5353
5399
|
if (mappedEffort !== undefined || sourceThinking !== undefined || policy?.anthropicThinkingBudget !== undefined)
|
|
5354
5400
|
diagnostics.push({ param: "reasoning", action: "mapped", reason: "explicit_verified_wire_policy" });
|
|
5355
|
-
return {
|
|
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
|
+
};
|
|
5356
5409
|
}
|
|
5357
5410
|
function renderGemini(chat, context, input, signedParts, diagnostics) {
|
|
5358
5411
|
const result = { contents: [] }, contents = result.contents, system = [], calls = new Map;
|
|
@@ -6257,7 +6310,7 @@ class CanonicalStreamRenderer {
|
|
|
6257
6310
|
var LLM_PROTOCOLS = ["responses", "chat_completions", "anthropic_messages", "gemini_generate_content"];
|
|
6258
6311
|
|
|
6259
6312
|
// packages/llms/src/protocol-session/index.ts
|
|
6260
|
-
var PROTOCOL_CONVERSION_RULES_VERSION = "1.0.
|
|
6313
|
+
var PROTOCOL_CONVERSION_RULES_VERSION = "1.0.5";
|
|
6261
6314
|
function describeProtocolConversion() {
|
|
6262
6315
|
return {
|
|
6263
6316
|
rulesVersion: PROTOCOL_CONVERSION_RULES_VERSION,
|
|
@@ -6974,7 +7027,7 @@ class AgentRelay {
|
|
|
6974
7027
|
}
|
|
6975
7028
|
|
|
6976
7029
|
// plugins/llm-protocol-adapter/server/service.ts
|
|
6977
|
-
var REASONING_RULES_VERSION = "2026-
|
|
7030
|
+
var REASONING_RULES_VERSION = "2026-11-11.1";
|
|
6978
7031
|
var concrete = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
6979
7032
|
var effortProtocols = new Set(["responses", "chat_completions", "anthropic_messages", "gemini_generate_content"]);
|
|
6980
7033
|
var geminiEfforts = new Set(["minimal", "low", "medium", "high"]);
|
|
@@ -7091,6 +7144,11 @@ function conversionService(catalog, worker, history, runBackground) {
|
|
|
7091
7144
|
selected = effort;
|
|
7092
7145
|
}
|
|
7093
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
|
+
}
|
|
7094
7152
|
rewrittenDeveloper = false;
|
|
7095
7153
|
if (deepseekChat) {
|
|
7096
7154
|
for (const message of chatMessages(result.body))
|
|
@@ -7623,4 +7681,4 @@ export {
|
|
|
7623
7681
|
targetPath
|
|
7624
7682
|
};
|
|
7625
7683
|
|
|
7626
|
-
//# debugId=
|
|
7684
|
+
//# debugId=156C4C918244044B64756E2164756E21
|