diff --git a/patches/@mariozechner__pi-ai@0.42.2.patch b/patches/@mariozechner__pi-ai@0.42.2.patch index 34f40a0ed..1d0d2ec6b 100644 --- a/patches/@mariozechner__pi-ai@0.42.2.patch +++ b/patches/@mariozechner__pi-ai@0.42.2.patch @@ -1,5 +1,5 @@ diff --git a/dist/providers/google-gemini-cli.js b/dist/providers/google-gemini-cli.js -index 93aa26c395e9bd0df64376408a13d15ee9e7cce7..beb585e2f2c13eec3bca98acade761101e4572ff 100644 +index 93aa26c395e9bd0df64376408a13d15ee9e7cce7..41a439e5fc370038a5febef9e8f021ee279cf8aa 100644 --- a/dist/providers/google-gemini-cli.js +++ b/dist/providers/google-gemini-cli.js @@ -248,6 +248,11 @@ export const streamGoogleGeminiCli = (model, context, options) => { @@ -14,8 +14,43 @@ index 93aa26c395e9bd0df64376408a13d15ee9e7cce7..beb585e2f2c13eec3bca98acade76110 // Check if retryable if (attempt < MAX_RETRIES && isRetryableError(response.status, errorText)) { // Use server-provided delay or exponential backoff +diff --git a/dist/providers/google-shared.js b/dist/providers/google-shared.js +index a130bad0df74a2d9f1baa9713c1c62902d77aaae..94d7297ee983f54de9ef11aedb2ef410bca04e90 100644 +--- a/dist/providers/google-shared.js ++++ b/dist/providers/google-shared.js +@@ -41,6 +41,8 @@ export function retainThoughtSignature(existing, incoming) { + export function convertMessages(model, context) { + const contents = []; + const transformedMessages = transformMessages(context.messages, model); ++ const shouldStripFunctionId = typeof model.provider === "string" && ++ model.provider.startsWith("google"); + for (const msg of transformedMessages) { + if (msg.role === "user") { + if (typeof msg.content === "string") { +@@ -110,8 +112,8 @@ export function convertMessages(model, context) { + args: block.arguments, + }, + }; +- if (model.provider === "google-vertex" && part?.functionCall?.id) { +- delete part.functionCall.id; // Vertex AI does not support 'id' in functionCall ++ if (shouldStripFunctionId && part?.functionCall?.id) { ++ delete part.functionCall.id; // Google Gemini/Vertex do not support 'id' in functionCall + } + if (block.thoughtSignature) { + part.thoughtSignature = block.thoughtSignature; +@@ -156,8 +158,8 @@ export function convertMessages(model, context) { + ...(hasImages && supportsMultimodalFunctionResponse && { parts: imageParts }), + }, + }; +- if (model.provider === "google-vertex" && functionResponsePart.functionResponse?.id) { +- delete functionResponsePart.functionResponse.id; // Vertex AI does not support 'id' in functionResponse ++ if (shouldStripFunctionId && functionResponsePart.functionResponse?.id) { ++ delete functionResponsePart.functionResponse.id; // Google Gemini/Vertex do not support 'id' in functionResponse + } + // Cloud Code Assist API requires all function responses to be in a single user turn. + // Check if the last content is already a user turn with function responses and merge. diff --git a/dist/providers/openai-codex-responses.js b/dist/providers/openai-codex-responses.js -index 188a8294f26fe1bfe3fb298a7f58e4d8eaf2a529..ccfe2e835918530ddf9d2ce17b44b0069b41648e 100644 +index 188a8294f26fe1bfe3fb298a7f58e4d8eaf2a529..2f543a3ee9ea7603519562ac52ee00b6a7d0432c 100644 --- a/dist/providers/openai-codex-responses.js +++ b/dist/providers/openai-codex-responses.js @@ -515,7 +515,7 @@ function convertTools(tools) { @@ -62,39 +97,6 @@ index f07085c64390b211340d6a826b28ea9c2e77302f..7f758532246cc7b062df48e9cec4e6c9 + } + } + } - if (output.length === 0) - continue; - messages.push(...output); -diff --git a/dist/providers/google-shared.js b/dist/providers/google-shared.js -index 866446158b0ee3e4c4a4f3f78c71ce72b9aab6a1..c7f9d8a0b0c7a25b62a0bb5f8a4f9d63ccad1d24 100644 ---- a/dist/providers/google-shared.js -+++ b/dist/providers/google-shared.js -@@ -52,6 +52,8 @@ export function convertMessages(model, context) { - const contents = []; - const transformedMessages = transformMessages(context.messages, model); -+ const shouldStripFunctionId = typeof model.provider === "string" && -+ model.provider.startsWith("google"); - for (const msg of transformedMessages) { - if (msg.role === "user") { -@@ -110,8 +112,8 @@ export function convertMessages(model, context) { - args: block.arguments, - }, - }; -- if (model.provider === "google-vertex" && part?.functionCall?.id) { -- delete part.functionCall.id; // Vertex AI does not support 'id' in functionCall -+ if (shouldStripFunctionId && part?.functionCall?.id) { -+ delete part.functionCall.id; // Google Gemini/Vertex do not support 'id' in functionCall - } - if (block.thoughtSignature) { - part.thoughtSignature = block.thoughtSignature; -@@ -159,8 +161,8 @@ export function convertMessages(model, context) { - ...(hasImages && supportsMultimodalFunctionResponse && { parts: imageParts }), - }, - }; -- if (model.provider === "google-vertex" && functionResponsePart.functionResponse?.id) { -- delete functionResponsePart.functionResponse.id; // Vertex AI does not support 'id' in functionResponse -+ if (shouldStripFunctionId && functionResponsePart.functionResponse?.id) { -+ delete functionResponsePart.functionResponse.id; // Google Gemini/Vertex do not support 'id' in functionResponse - } - // Cloud Code Assist API requires all function responses to be in a single user turn. - // Check if the last content is already a user turn with function responses and merge. + if (output.length === 0) + continue; + messages.push(...output); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 70669f9e1..4e910eb77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,7 +9,7 @@ overrides: patchedDependencies: '@mariozechner/pi-ai@0.42.2': - hash: 3fdce5d80680357fe70c0af04efd43c85cea49d59bf3563f502b24d647c058f2 + hash: 448e906b80285162ebd0b9fa9a7f9695c64c64236ee8cc1b0fe612e5ae2ade1e path: patches/@mariozechner__pi-ai@0.42.2.patch importers: @@ -36,7 +36,7 @@ importers: version: 0.42.2(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-ai': specifier: ^0.42.2 - version: 0.42.2(patch_hash=3fdce5d80680357fe70c0af04efd43c85cea49d59bf3563f502b24d647c058f2)(ws@8.19.0)(zod@4.3.5) + version: 0.42.2(patch_hash=448e906b80285162ebd0b9fa9a7f9695c64c64236ee8cc1b0fe612e5ae2ade1e)(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-coding-agent': specifier: ^0.42.2 version: 0.42.2(ws@8.19.0)(zod@4.3.5) @@ -3807,7 +3807,7 @@ snapshots: '@mariozechner/pi-agent-core@0.42.2(ws@8.19.0)(zod@4.3.5)': dependencies: - '@mariozechner/pi-ai': 0.42.2(patch_hash=3fdce5d80680357fe70c0af04efd43c85cea49d59bf3563f502b24d647c058f2)(ws@8.19.0)(zod@4.3.5) + '@mariozechner/pi-ai': 0.42.2(patch_hash=448e906b80285162ebd0b9fa9a7f9695c64c64236ee8cc1b0fe612e5ae2ade1e)(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-tui': 0.42.2 transitivePeerDependencies: - '@modelcontextprotocol/sdk' @@ -3817,7 +3817,7 @@ snapshots: - ws - zod - '@mariozechner/pi-ai@0.42.2(patch_hash=3fdce5d80680357fe70c0af04efd43c85cea49d59bf3563f502b24d647c058f2)(ws@8.19.0)(zod@4.3.5)': + '@mariozechner/pi-ai@0.42.2(patch_hash=448e906b80285162ebd0b9fa9a7f9695c64c64236ee8cc1b0fe612e5ae2ade1e)(ws@8.19.0)(zod@4.3.5)': dependencies: '@anthropic-ai/sdk': 0.71.2(zod@4.3.5) '@google/genai': 1.34.0 @@ -3841,7 +3841,7 @@ snapshots: dependencies: '@mariozechner/clipboard': 0.3.0 '@mariozechner/pi-agent-core': 0.42.2(ws@8.19.0)(zod@4.3.5) - '@mariozechner/pi-ai': 0.42.2(patch_hash=3fdce5d80680357fe70c0af04efd43c85cea49d59bf3563f502b24d647c058f2)(ws@8.19.0)(zod@4.3.5) + '@mariozechner/pi-ai': 0.42.2(patch_hash=448e906b80285162ebd0b9fa9a7f9695c64c64236ee8cc1b0fe612e5ae2ade1e)(ws@8.19.0)(zod@4.3.5) '@mariozechner/pi-tui': 0.42.2 chalk: 5.6.2 cli-highlight: 2.1.11