mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:00:43 +00:00
Summary: - Merged fix: simplify bundled runtime dependency repair after ClawSweeper review. ClawSweeper fixups: - Included follow-up commit: fix: verify cached bundled runtime roots - Included follow-up commit: refactor: simplify plugin runtime startup paths - Included follow-up commit: refactor: trim plugin startup policy helpers - Included follow-up commit: refactor: trust package manager runtime deps materialization - Included follow-up commit: fix: narrow channel runtime deps skip policy - Included follow-up commit: refactor: defer startup plugin runtime deps - Ran the ClawSweeper repair loop before final review. Validation: - ClawSweeper review passed for head04dc566534. - Required merge gates passed before the squash merge. Prepared head SHA:04dc566534Review: https://github.com/openclaw/openclaw/pull/75183#issuecomment-4358383786 Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: Shakker <shakkerdroid@gmail.com> Co-authored-by: clawsweeper-repair <clawsweeper-repair@users.noreply.github.com>
65 lines
2.2 KiB
TypeScript
65 lines
2.2 KiB
TypeScript
import { isGatewayConfigBypassCommandPath } from "../gateway/explicit-connection-policy.js";
|
|
import { getCommandPathWithRootOptions } from "./argv.js";
|
|
import {
|
|
cliCommandCatalog,
|
|
type CliCommandPathPolicy,
|
|
type CliNetworkProxyPolicy,
|
|
} from "./command-catalog.js";
|
|
import { matchesCommandPath } from "./command-path-matches.js";
|
|
import { resolveGatewayCatalogCommandPath } from "./gateway-run-argv.js";
|
|
|
|
const DEFAULT_CLI_COMMAND_PATH_POLICY: CliCommandPathPolicy = {
|
|
bypassConfigGuard: false,
|
|
routeConfigGuard: "never",
|
|
loadPlugins: "never",
|
|
pluginRegistry: { scope: "all" },
|
|
hideBanner: false,
|
|
ensureCliPath: true,
|
|
networkProxy: "default",
|
|
};
|
|
|
|
export function resolveCliCommandPathPolicy(commandPath: string[]): CliCommandPathPolicy {
|
|
let resolvedPolicy: CliCommandPathPolicy = { ...DEFAULT_CLI_COMMAND_PATH_POLICY };
|
|
for (const entry of cliCommandCatalog) {
|
|
if (!entry.policy) {
|
|
continue;
|
|
}
|
|
if (!matchesCommandPath(commandPath, entry.commandPath, { exact: entry.exact })) {
|
|
continue;
|
|
}
|
|
Object.assign(resolvedPolicy, entry.policy);
|
|
}
|
|
if (isGatewayConfigBypassCommandPath(commandPath)) {
|
|
resolvedPolicy.bypassConfigGuard = true;
|
|
}
|
|
return resolvedPolicy;
|
|
}
|
|
|
|
function isCommandPathPrefix(commandPath: string[], pattern: readonly string[]): boolean {
|
|
return pattern.every((segment, index) => commandPath[index] === segment);
|
|
}
|
|
|
|
export function resolveCliCatalogCommandPath(argv: string[]): string[] {
|
|
const tokens =
|
|
resolveGatewayCatalogCommandPath(argv) ?? getCommandPathWithRootOptions(argv, argv.length);
|
|
if (tokens.length === 0) {
|
|
return [];
|
|
}
|
|
let bestMatch: readonly string[] | null = null;
|
|
for (const entry of cliCommandCatalog) {
|
|
if (!isCommandPathPrefix(tokens, entry.commandPath)) {
|
|
continue;
|
|
}
|
|
if (!bestMatch || entry.commandPath.length > bestMatch.length) {
|
|
bestMatch = entry.commandPath;
|
|
}
|
|
}
|
|
return bestMatch ? [...bestMatch] : [tokens[0]];
|
|
}
|
|
|
|
export function resolveCliNetworkProxyPolicy(argv: string[]): CliNetworkProxyPolicy {
|
|
const commandPath = resolveCliCatalogCommandPath(argv);
|
|
const networkProxy = resolveCliCommandPathPolicy(commandPath).networkProxy;
|
|
return typeof networkProxy === "function" ? networkProxy({ argv, commandPath }) : networkProxy;
|
|
}
|