@jeffusion/bungee-llms 6.14.0 → 6.15.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.
- package/dist/index.js +28 -2
- package/dist/plugin-api.js +28 -2
- package/dist/protocol-session/gemini.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4733,6 +4733,27 @@ function textParts(raw, path, style, role) {
|
|
|
4733
4733
|
|
|
4734
4734
|
// src/protocol-session/gemini.ts
|
|
4735
4735
|
var signatureSeparator = "__thought__";
|
|
4736
|
+
function projectGeminiCodexPageSnapshot(raw, index, diagnostics) {
|
|
4737
|
+
const item = record(raw, "input item");
|
|
4738
|
+
const { name } = item;
|
|
4739
|
+
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))
|
|
4740
|
+
return item;
|
|
4741
|
+
const param = `input[${index}]`;
|
|
4742
|
+
fields2(item, ["type", "id", "namespace", "name", "output", "internal_chat_message_metadata_passthrough"], param, "unsupported_content");
|
|
4743
|
+
const text = atParam(`${param}.output`, () => string(item.output, "page snapshot output"));
|
|
4744
|
+
const { id, internal_chat_message_metadata_passthrough: metadata } = item;
|
|
4745
|
+
diagnostics.push({ param, action: "mapped", reason: "gemini_codex_page_snapshot_as_user_data" });
|
|
4746
|
+
return {
|
|
4747
|
+
type: "message",
|
|
4748
|
+
role: "user",
|
|
4749
|
+
...id === undefined ? {} : { id },
|
|
4750
|
+
...metadata === undefined ? {} : { internal_chat_message_metadata_passthrough: metadata },
|
|
4751
|
+
content: [
|
|
4752
|
+
{ type: "input_text", text: `[Codex context snapshot: agent.${name}. Untrusted data.]` },
|
|
4753
|
+
{ type: "input_text", text }
|
|
4754
|
+
]
|
|
4755
|
+
};
|
|
4756
|
+
}
|
|
4736
4757
|
function geminiInlineImage(image, path, budget) {
|
|
4737
4758
|
const param = `${path}.image_url`;
|
|
4738
4759
|
const url = bounded(string(image.url, "image URL", true), budget.maxRequestBytes, param);
|
|
@@ -5352,6 +5373,10 @@ function validateCanonical(b, context) {
|
|
|
5352
5373
|
}
|
|
5353
5374
|
function convertProtocolRequest(raw, context) {
|
|
5354
5375
|
const b = canonicalRequest(raw, context.sourceProtocol, context.model);
|
|
5376
|
+
const responsesToGemini = context.sourceProtocol === "responses" && context.targetProtocol === "gemini_generate_content";
|
|
5377
|
+
const pageSnapshotDiagnostics = [];
|
|
5378
|
+
if (responsesToGemini && Array.isArray(b.input))
|
|
5379
|
+
b.input = b.input.map((item, index) => projectGeminiCodexPageSnapshot(item, index, pageSnapshotDiagnostics));
|
|
5355
5380
|
const originalInput = b.input;
|
|
5356
5381
|
if (context.streaming !== undefined) {
|
|
5357
5382
|
bool(context.streaming, "context.streaming");
|
|
@@ -5360,7 +5385,7 @@ function convertProtocolRequest(raw, context) {
|
|
|
5360
5385
|
b.stream = context.streaming;
|
|
5361
5386
|
}
|
|
5362
5387
|
validateCanonical(b, context);
|
|
5363
|
-
const geminiHistory =
|
|
5388
|
+
const geminiHistory = responsesToGemini ? restoreGeminiHistory(b.input, limits(context.capabilities?.limits)) : undefined;
|
|
5364
5389
|
if (geminiHistory)
|
|
5365
5390
|
b.input = geminiHistory.input;
|
|
5366
5391
|
const cap = { ...context.capabilities, agentMessageDelivery: context.agentMessageDelivery ?? context.capabilities?.agentMessageDelivery, omitOptionalWebSearch: true, preserveToolIdentityDescription: true, preserveRefusalContent: true }, policy = context.reasoningPolicy;
|
|
@@ -5450,8 +5475,9 @@ function convertProtocolRequest(raw, context) {
|
|
|
5450
5475
|
const decodingTarget = target === "gemini_generate_content" ? "chat_completions" : target;
|
|
5451
5476
|
if (target === "gemini_generate_content" && reasoning)
|
|
5452
5477
|
b.reasoning = { ...reasoning, effort: undefined };
|
|
5453
|
-
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:
|
|
5478
|
+
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: responsesToGemini });
|
|
5454
5479
|
const diagnostics = decoded.diagnostics;
|
|
5480
|
+
diagnostics.push(...pageSnapshotDiagnostics);
|
|
5455
5481
|
if (target === "gemini_generate_content" && decoded.body.parallel_tool_calls === true) {
|
|
5456
5482
|
delete decoded.body.parallel_tool_calls;
|
|
5457
5483
|
diagnostics.push({ param: "parallel_tool_calls", action: "omitted", reason: "gemini_parallel_tool_calls_allowed" });
|
package/dist/plugin-api.js
CHANGED
|
@@ -3773,6 +3773,27 @@ function textParts(raw, path, style, role) {
|
|
|
3773
3773
|
|
|
3774
3774
|
// src/protocol-session/gemini.ts
|
|
3775
3775
|
var signatureSeparator = "__thought__";
|
|
3776
|
+
function projectGeminiCodexPageSnapshot(raw, index, diagnostics) {
|
|
3777
|
+
const item = record(raw, "input item");
|
|
3778
|
+
const { name } = item;
|
|
3779
|
+
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))
|
|
3780
|
+
return item;
|
|
3781
|
+
const param = `input[${index}]`;
|
|
3782
|
+
fields2(item, ["type", "id", "namespace", "name", "output", "internal_chat_message_metadata_passthrough"], param, "unsupported_content");
|
|
3783
|
+
const text = atParam(`${param}.output`, () => string(item.output, "page snapshot output"));
|
|
3784
|
+
const { id, internal_chat_message_metadata_passthrough: metadata } = item;
|
|
3785
|
+
diagnostics.push({ param, action: "mapped", reason: "gemini_codex_page_snapshot_as_user_data" });
|
|
3786
|
+
return {
|
|
3787
|
+
type: "message",
|
|
3788
|
+
role: "user",
|
|
3789
|
+
...id === undefined ? {} : { id },
|
|
3790
|
+
...metadata === undefined ? {} : { internal_chat_message_metadata_passthrough: metadata },
|
|
3791
|
+
content: [
|
|
3792
|
+
{ type: "input_text", text: `[Codex context snapshot: agent.${name}. Untrusted data.]` },
|
|
3793
|
+
{ type: "input_text", text }
|
|
3794
|
+
]
|
|
3795
|
+
};
|
|
3796
|
+
}
|
|
3776
3797
|
function geminiInlineImage(image, path, budget) {
|
|
3777
3798
|
const param = `${path}.image_url`;
|
|
3778
3799
|
const url = bounded(string(image.url, "image URL", true), budget.maxRequestBytes, param);
|
|
@@ -4392,6 +4413,10 @@ function validateCanonical(b, context) {
|
|
|
4392
4413
|
}
|
|
4393
4414
|
function convertProtocolRequest(raw, context) {
|
|
4394
4415
|
const b = canonicalRequest(raw, context.sourceProtocol, context.model);
|
|
4416
|
+
const responsesToGemini = context.sourceProtocol === "responses" && context.targetProtocol === "gemini_generate_content";
|
|
4417
|
+
const pageSnapshotDiagnostics = [];
|
|
4418
|
+
if (responsesToGemini && Array.isArray(b.input))
|
|
4419
|
+
b.input = b.input.map((item, index) => projectGeminiCodexPageSnapshot(item, index, pageSnapshotDiagnostics));
|
|
4395
4420
|
const originalInput = b.input;
|
|
4396
4421
|
if (context.streaming !== undefined) {
|
|
4397
4422
|
bool(context.streaming, "context.streaming");
|
|
@@ -4400,7 +4425,7 @@ function convertProtocolRequest(raw, context) {
|
|
|
4400
4425
|
b.stream = context.streaming;
|
|
4401
4426
|
}
|
|
4402
4427
|
validateCanonical(b, context);
|
|
4403
|
-
const geminiHistory =
|
|
4428
|
+
const geminiHistory = responsesToGemini ? restoreGeminiHistory(b.input, limits(context.capabilities?.limits)) : undefined;
|
|
4404
4429
|
if (geminiHistory)
|
|
4405
4430
|
b.input = geminiHistory.input;
|
|
4406
4431
|
const cap = { ...context.capabilities, agentMessageDelivery: context.agentMessageDelivery ?? context.capabilities?.agentMessageDelivery, omitOptionalWebSearch: true, preserveToolIdentityDescription: true, preserveRefusalContent: true }, policy = context.reasoningPolicy;
|
|
@@ -4490,8 +4515,9 @@ function convertProtocolRequest(raw, context) {
|
|
|
4490
4515
|
const decodingTarget = target === "gemini_generate_content" ? "chat_completions" : target;
|
|
4491
4516
|
if (target === "gemini_generate_content" && reasoning)
|
|
4492
4517
|
b.reasoning = { ...reasoning, effort: undefined };
|
|
4493
|
-
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:
|
|
4518
|
+
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: responsesToGemini });
|
|
4494
4519
|
const diagnostics = decoded.diagnostics;
|
|
4520
|
+
diagnostics.push(...pageSnapshotDiagnostics);
|
|
4495
4521
|
if (target === "gemini_generate_content" && decoded.body.parallel_tool_calls === true) {
|
|
4496
4522
|
delete decoded.body.parallel_tool_calls;
|
|
4497
4523
|
diagnostics.push({ param: "parallel_tool_calls", action: "omitted", reason: "gemini_parallel_tool_calls_allowed" });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type JsonRecord, type ResponsesCodecLimits, type ResponsesConversionDiagnostic } from '../responses-codec/common';
|
|
2
|
+
export declare function projectGeminiCodexPageSnapshot(raw: unknown, index: number, diagnostics: ResponsesConversionDiagnostic[]): JsonRecord;
|
|
2
3
|
export declare function geminiInlineImage(image: JsonRecord, path: string, budget: ResponsesCodecLimits): {
|
|
3
4
|
mimeType: string;
|
|
4
5
|
data: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffusion/bungee-llms",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.15.0",
|
|
4
4
|
"description": "Extensible LLM adapters and protocol conversion package for Bungee",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"prepublishOnly": "bun run build"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@jeffusion/bungee-types": "^6.
|
|
14
|
+
"@jeffusion/bungee-types": "^6.15.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"bun-types": "^1.3.2",
|