mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 16:50:23 +00:00
fix(exec): default implicit target to auto
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import type { ExecAsk, ExecHost, ExecSecurity } from "../../../infra/exec-approvals.js";
|
||||
import {
|
||||
type ExecAsk,
|
||||
type ExecSecurity,
|
||||
type ExecTarget,
|
||||
normalizeExecTarget,
|
||||
} from "../../../infra/exec-approvals.js";
|
||||
import { skipDirectiveArgPrefix, takeDirectiveToken } from "../directive-parsing.js";
|
||||
|
||||
type ExecDirectiveParse = {
|
||||
cleaned: string;
|
||||
hasDirective: boolean;
|
||||
execHost?: ExecHost;
|
||||
execHost?: ExecTarget;
|
||||
execSecurity?: ExecSecurity;
|
||||
execAsk?: ExecAsk;
|
||||
execNode?: string;
|
||||
@@ -19,14 +24,6 @@ type ExecDirectiveParse = {
|
||||
invalidNode: boolean;
|
||||
};
|
||||
|
||||
function normalizeExecHost(value?: string): ExecHost | undefined {
|
||||
const normalized = value?.trim().toLowerCase();
|
||||
if (normalized === "sandbox" || normalized === "gateway" || normalized === "node") {
|
||||
return normalized;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function normalizeExecSecurity(value?: string): ExecSecurity | undefined {
|
||||
const normalized = value?.trim().toLowerCase();
|
||||
if (normalized === "deny" || normalized === "allowlist" || normalized === "full") {
|
||||
@@ -52,7 +49,7 @@ function parseExecDirectiveArgs(raw: string): Omit<
|
||||
const len = raw.length;
|
||||
let i = skipDirectiveArgPrefix(raw);
|
||||
let consumed = i;
|
||||
let execHost: ExecHost | undefined;
|
||||
let execHost: ExecTarget | undefined;
|
||||
let execSecurity: ExecSecurity | undefined;
|
||||
let execAsk: ExecAsk | undefined;
|
||||
let execNode: string | undefined;
|
||||
@@ -99,7 +96,7 @@ function parseExecDirectiveArgs(raw: string): Omit<
|
||||
const { key, value } = parsed;
|
||||
if (key === "host") {
|
||||
rawExecHost = value;
|
||||
execHost = normalizeExecHost(value);
|
||||
execHost = normalizeExecTarget(value) ?? undefined;
|
||||
if (!execHost) {
|
||||
invalidHost = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user