fix(multi): corrected auth messaging and google tool schemas

This commit is contained in:
can1357
2026-01-11 01:06:05 +01:00
parent 0729d340b7
commit 0a9dd36e3d
5 changed files with 43 additions and 7 deletions
+3
View File
@@ -1,6 +1,9 @@
# Changelog
## [Unreleased]
### Fixed
- Fixed Cloud Code Assist tool schema conversion to avoid unsupported `const` fields
## [4.2.0] - 2026-01-10
+33 -1
View File
@@ -189,6 +189,38 @@ export function convertMessages<T extends GoogleApiType>(model: Model<T>, contex
return contents;
}
function sanitizeSchemaForGoogle(value: unknown): unknown {
if (Array.isArray(value)) {
return value.map((entry) => sanitizeSchemaForGoogle(entry));
}
if (!value || typeof value !== "object") {
return value;
}
const result: Record<string, unknown> = {};
let constValue: unknown | undefined;
for (const [key, entry] of Object.entries(value)) {
if (key === "const") {
constValue = entry;
continue;
}
result[key] = sanitizeSchemaForGoogle(entry);
}
if (constValue !== undefined) {
const existingEnum = Array.isArray(result.enum) ? [...result.enum] : undefined;
const enumValues = existingEnum ?? [];
if (!enumValues.some((item) => Object.is(item, constValue))) {
enumValues.push(constValue);
}
result.enum = enumValues;
}
return result;
}
/**
* Convert tools to Gemini function declarations format.
*/
@@ -201,7 +233,7 @@ export function convertTools(
functionDeclarations: tools.map((tool) => ({
name: tool.name,
description: tool.description,
parameters: tool.parameters as Schema,
parameters: sanitizeSchemaForGoogle(tool.parameters) as Schema,
})),
},
];
+1
View File
@@ -8,6 +8,7 @@
### Fixed
- Fixed editor border rendering glitch after canceling slash command autocomplete
- Fixed login/logout credential path message to reference agent.db
### Removed
@@ -17,7 +17,7 @@ import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLe
import type { AssistantMessage, ImageContent, Message, Model, TextContent, Usage } from "@oh-my-pi/pi-ai";
import { isContextOverflow, modelsAreEqual, supportsXhigh } from "@oh-my-pi/pi-ai";
import type { Rule } from "../capability/rule";
import { getAuthPath } from "../config";
import { getAgentDbPath } from "../config";
import { theme } from "../modes/interactive/theme/theme";
import { type BashResult, executeBash as executeBashCommand, executeBashWithOperations } from "./bash-executor";
import {
@@ -761,7 +761,7 @@ export class AgentSession {
if (!this.model) {
throw new Error(
"No model selected.\n\n" +
`Use /login, set an API key environment variable, or create ${getAuthPath()}\n\n` +
`Use /login, set an API key environment variable, or create ${getAgentDbPath()}\n\n` +
"Then use /model to select a model.",
);
}
@@ -771,7 +771,7 @@ export class AgentSession {
if (!apiKey) {
throw new Error(
`No API key found for ${this.model.provider}.\n\n` +
`Use /login, set an API key environment variable, or create ${getAuthPath()}`,
`Use /login, set an API key environment variable, or create ${getAgentDbPath()}`,
);
}
@@ -2,7 +2,7 @@ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
import type { OAuthProvider } from "@oh-my-pi/pi-ai";
import type { Component } from "@oh-my-pi/pi-tui";
import { Input, Loader, Spacer, Text } from "@oh-my-pi/pi-tui";
import { getAuthPath } from "../../../config";
import { getAgentDbPath } from "../../../config";
import { SessionManager } from "../../../core/session-manager";
import { setPreferredImageProvider, setPreferredWebSearchProvider } from "../../../core/tools/index";
import { disableProvider, enableProvider } from "../../../discovery";
@@ -546,7 +546,7 @@ export class SelectorController {
),
);
this.ctx.chatContainer.addChild(
new Text(theme.fg("dim", `Credentials saved to ${getAuthPath()}`), 1, 0),
new Text(theme.fg("dim", `Credentials saved to ${getAgentDbPath()}`), 1, 0),
);
this.ctx.ui.requestRender();
} catch (error: unknown) {
@@ -566,7 +566,7 @@ export class SelectorController {
),
);
this.ctx.chatContainer.addChild(
new Text(theme.fg("dim", `Credentials removed from ${getAuthPath()}`), 1, 0),
new Text(theme.fg("dim", `Credentials removed from ${getAgentDbPath()}`), 1, 0),
);
this.ctx.ui.requestRender();
} catch (error: unknown) {