mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 18:30:25 +00:00
Exec approvals: unify effective policy reporting and actions (#59283)
Merged via squash.
Prepared head SHA: d579b97a93
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
dc66c36b9e
commit
ba735d0158
@@ -30,6 +30,9 @@ type ParsedApproveCommand =
|
||||
| { ok: true; id: string; decision: "allow-once" | "allow-always" | "deny" }
|
||||
| { ok: false; error: string };
|
||||
|
||||
const APPROVE_USAGE_TEXT =
|
||||
"Usage: /approve <id> <decision> (see the pending approval message for available decisions)";
|
||||
|
||||
function parseApproveCommand(raw: string): ParsedApproveCommand | null {
|
||||
const trimmed = raw.trim();
|
||||
if (FOREIGN_COMMAND_MENTION_REGEX.test(trimmed)) {
|
||||
@@ -41,11 +44,11 @@ function parseApproveCommand(raw: string): ParsedApproveCommand | null {
|
||||
}
|
||||
const rest = trimmed.slice(commandMatch[0].length).trim();
|
||||
if (!rest) {
|
||||
return { ok: false, error: "Usage: /approve <id> allow-once|allow-always|deny" };
|
||||
return { ok: false, error: APPROVE_USAGE_TEXT };
|
||||
}
|
||||
const tokens = rest.split(/\s+/).filter(Boolean);
|
||||
if (tokens.length < 2) {
|
||||
return { ok: false, error: "Usage: /approve <id> allow-once|allow-always|deny" };
|
||||
return { ok: false, error: APPROVE_USAGE_TEXT };
|
||||
}
|
||||
|
||||
const first = tokens[0].toLowerCase();
|
||||
@@ -65,7 +68,7 @@ function parseApproveCommand(raw: string): ParsedApproveCommand | null {
|
||||
id: tokens[0],
|
||||
};
|
||||
}
|
||||
return { ok: false, error: "Usage: /approve <id> allow-once|allow-always|deny" };
|
||||
return { ok: false, error: APPROVE_USAGE_TEXT };
|
||||
}
|
||||
|
||||
function buildResolvedByLabel(params: Parameters<CommandHandler>[0]): string {
|
||||
|
||||
Reference in New Issue
Block a user