mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 06:34:31 +00:00
refactor(gateway): dedupe auth and discord monitor suites
This commit is contained in:
@@ -46,6 +46,33 @@ function tryResolveRealpath(filePath: string | undefined): string | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
function buildCommandResolution(params: {
|
||||
rawExecutable: string;
|
||||
cwd?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
effectiveArgv: string[];
|
||||
wrapperChain: string[];
|
||||
policyBlocked: boolean;
|
||||
blockedWrapper?: string;
|
||||
}): CommandResolution {
|
||||
const resolvedPath = resolveExecutableCandidatePath(params.rawExecutable, {
|
||||
cwd: params.cwd,
|
||||
env: params.env,
|
||||
});
|
||||
const resolvedRealPath = tryResolveRealpath(resolvedPath);
|
||||
const executableName = resolvedPath ? path.basename(resolvedPath) : params.rawExecutable;
|
||||
return {
|
||||
rawExecutable: params.rawExecutable,
|
||||
resolvedPath,
|
||||
resolvedRealPath,
|
||||
executableName,
|
||||
effectiveArgv: params.effectiveArgv,
|
||||
wrapperChain: params.wrapperChain,
|
||||
policyBlocked: params.policyBlocked,
|
||||
blockedWrapper: params.blockedWrapper,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveCommandResolution(
|
||||
command: string,
|
||||
cwd?: string,
|
||||
@@ -55,18 +82,14 @@ export function resolveCommandResolution(
|
||||
if (!rawExecutable) {
|
||||
return null;
|
||||
}
|
||||
const resolvedPath = resolveExecutableCandidatePath(rawExecutable, { cwd, env });
|
||||
const resolvedRealPath = tryResolveRealpath(resolvedPath);
|
||||
const executableName = resolvedPath ? path.basename(resolvedPath) : rawExecutable;
|
||||
return {
|
||||
return buildCommandResolution({
|
||||
rawExecutable,
|
||||
resolvedPath,
|
||||
resolvedRealPath,
|
||||
executableName,
|
||||
effectiveArgv: [rawExecutable],
|
||||
wrapperChain: [],
|
||||
policyBlocked: false,
|
||||
};
|
||||
cwd,
|
||||
env,
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveCommandResolutionFromArgv(
|
||||
@@ -80,19 +103,15 @@ export function resolveCommandResolutionFromArgv(
|
||||
if (!rawExecutable) {
|
||||
return null;
|
||||
}
|
||||
const resolvedPath = resolveExecutableCandidatePath(rawExecutable, { cwd, env });
|
||||
const resolvedRealPath = tryResolveRealpath(resolvedPath);
|
||||
const executableName = resolvedPath ? path.basename(resolvedPath) : rawExecutable;
|
||||
return {
|
||||
return buildCommandResolution({
|
||||
rawExecutable,
|
||||
resolvedPath,
|
||||
resolvedRealPath,
|
||||
executableName,
|
||||
effectiveArgv,
|
||||
wrapperChain: plan.wrappers,
|
||||
policyBlocked: plan.policyBlocked,
|
||||
blockedWrapper: plan.blockedWrapper,
|
||||
};
|
||||
cwd,
|
||||
env,
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeMatchTarget(value: string): string {
|
||||
|
||||
Reference in New Issue
Block a user