mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-19 17:11:42 -06:00
5ebfbbf8d7
* fix(plugins): resolve per-agent config through SDK * test(codex): preserve agent runtime exports * test(telegram): make default owner explicit * refactor(plugins): use lightweight agent scope runtime * fix(codex): preserve multi-agent execution ownership * chore(plugin-sdk): record approved agent scope exports * fix(codex): keep scoped sandbox ownership authoritative * fix(codex): preserve agent scope in native side actions * fix(ci): avoid counting node check as environment variable
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { listAgentIds, resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
/**
|
|
* Browser setup entry. It auto-enables the Browser plugin when config or tool
|
|
* policies reference browser control.
|
|
*/
|
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/plugin-entry";
|
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
import {
|
|
isRecord,
|
|
normalizeOptionalLowercaseString,
|
|
} from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
|
|
function listContainsBrowser(value: unknown): boolean {
|
|
return (
|
|
Array.isArray(value) &&
|
|
value.some((entry) => normalizeOptionalLowercaseString(entry) === "browser")
|
|
);
|
|
}
|
|
|
|
function toolPolicyReferencesBrowser(value: unknown): boolean {
|
|
return (
|
|
isRecord(value) && (listContainsBrowser(value.allow) || listContainsBrowser(value.alsoAllow))
|
|
);
|
|
}
|
|
|
|
function hasBrowserToolReference(config: OpenClawConfig): boolean {
|
|
if (toolPolicyReferencesBrowser(config.tools)) {
|
|
return true;
|
|
}
|
|
return listAgentIds(config).some((agentId) =>
|
|
toolPolicyReferencesBrowser(resolveAgentConfig(config, agentId)?.tools),
|
|
);
|
|
}
|
|
|
|
/** Setup entry that detects existing Browser configuration references. */
|
|
export default definePluginEntry({
|
|
id: "browser",
|
|
name: "Browser Setup",
|
|
description: "Lightweight Browser setup hooks",
|
|
register(api) {
|
|
api.registerAutoEnableProbe(({ config }) => {
|
|
if (
|
|
config.browser?.enabled === false ||
|
|
config.plugins?.entries?.browser?.enabled === false
|
|
) {
|
|
return null;
|
|
}
|
|
if (Object.hasOwn(config, "browser")) {
|
|
return "browser configured";
|
|
}
|
|
if (config.plugins?.entries && Object.hasOwn(config.plugins.entries, "browser")) {
|
|
return "browser plugin configured";
|
|
}
|
|
if (hasBrowserToolReference(config)) {
|
|
return "browser tool referenced";
|
|
}
|
|
return null;
|
|
});
|
|
},
|
|
});
|