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

@@ -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";