fix(agents): harden model-skip and tool-policy imports

This commit is contained in:
Peter Steinberger
2026-02-21 11:48:02 +01:00
parent 55aaeb5085
commit 5cc631cc9c
2 changed files with 21 additions and 2 deletions

View File

@@ -50,6 +50,9 @@ function isGoogleModelNotFoundError(err: unknown): boolean {
if (!/not found/i.test(msg)) { if (!/not found/i.test(msg)) {
return false; return false;
} }
if (/\b404\b/.test(msg)) {
return true;
}
if (/models\/.+ is not found for api version/i.test(msg)) { if (/models\/.+ is not found for api version/i.test(msg)) {
return true; return true;
} }
@@ -445,7 +448,10 @@ describeLive("live models (profile keys)", () => {
logProgress(`${progressLabel}: skip (anthropic billing)`); logProgress(`${progressLabel}: skip (anthropic billing)`);
break; break;
} }
if (model.provider === "google" && isGoogleModelNotFoundError(err)) { if (
(model.provider === "google" || model.provider === "google-gemini-cli") &&
isGoogleModelNotFoundError(err)
) {
skipped.push({ model: id, reason: message }); skipped.push({ model: id, reason: message });
logProgress(`${progressLabel}: skip (google model not found)`); logProgress(`${progressLabel}: skip (google model not found)`);
break; break;

View File

@@ -1,4 +1,17 @@
import { type AnyAgentTool, wrapOwnerOnlyToolExecution } from "./tools/common.js"; import type { AnyAgentTool } from "./tools/common.js";
// Keep tool-policy browser-safe: do not import tools/common at runtime.
function wrapOwnerOnlyToolExecution(tool: AnyAgentTool, senderIsOwner: boolean): AnyAgentTool {
if (tool.ownerOnly !== true || senderIsOwner || !tool.execute) {
return tool;
}
return {
...tool,
execute: async () => {
throw new Error("Tool restricted to owner senders.");
},
};
}
export type ToolProfileId = "minimal" | "coding" | "messaging" | "full"; export type ToolProfileId = "minimal" | "coding" | "messaging" | "full";