mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:54:30 +00:00
fix(agents): harden model-skip and tool-policy imports
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user