openclaw/src/cli/command-path-policy.ts
Peter Steinberger 250376f885
Some checks are pending
CI / -4 (push) Blocked by required conditions
CI / -5 (push) Blocked by required conditions
CI / preflight (push) Waiting to run
CI / security-scm-fast (push) Waiting to run
CI / security-dependency-audit (push) Waiting to run
CI / security-fast (push) Blocked by required conditions
CI / build-artifacts (push) Blocked by required conditions
CI / (push) Blocked by required conditions
CI / -1 (push) Blocked by required conditions
CI / checks-fast-contracts-plugins (push) Blocked by required conditions
CI / -2 (push) Blocked by required conditions
CI / checks-fast-contracts-channels (push) Blocked by required conditions
CI / checks-fast-protocol (push) Blocked by required conditions
CI / -3 (push) Blocked by required conditions
CI / checks-node-compat-node22 (push) Blocked by required conditions
CI / checks-node-core (push) Blocked by required conditions
CI / check-dependencies (push) Blocked by required conditions
CI / check-lint (push) Blocked by required conditions
CI / check-policy-guards (push) Blocked by required conditions
CI / check-preflight-guards (push) Blocked by required conditions
CI / check-prod-types (push) Blocked by required conditions
CI / check-strict-smoke (push) Blocked by required conditions
CI / check-test-types (push) Blocked by required conditions
CI / check (push) Blocked by required conditions
CI / check-additional-boundaries (push) Blocked by required conditions
CI / check-additional-extension-bundled (push) Blocked by required conditions
CI / check-additional-extension-channels (push) Blocked by required conditions
CI / check-additional-extension-package-boundary (push) Blocked by required conditions
CI / check-additional-runtime-topology-architecture (push) Blocked by required conditions
CI / check-additional (push) Blocked by required conditions
CI / build-smoke (push) Blocked by required conditions
CI / check-docs (push) Blocked by required conditions
CI / skills-python (push) Blocked by required conditions
CI / -6 (push) Blocked by required conditions
CI / macos-swift (push) Blocked by required conditions
CI / -8 (push) Blocked by required conditions
ClawSweeper Dispatch / dispatch (push) Waiting to run
Docs Sync Publish Repo / sync-publish-repo (push) Waiting to run
Docs / docs (push) Waiting to run
Plugin NPM Release / preview_plugins_npm (push) Waiting to run
Plugin NPM Release / preview_plugin_pack (push) Blocked by required conditions
CI / -7 (push) Blocked by required conditions
Plugin NPM Release / publish_plugins_npm (push) Blocked by required conditions
Workflow Sanity / generated-doc-baselines (push) Waiting to run
Workflow Sanity / no-tabs (push) Waiting to run
Workflow Sanity / actionlint (push) Waiting to run
fix: simplify bundled runtime dependency repair (#75183)
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 head 04dc566534.
- Required merge gates passed before the squash merge.

Prepared head SHA: 04dc566534
Review: 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>
2026-05-01 07:49:02 +00:00

64 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;
}