refactor: tidy directive parsing + queue status

This commit is contained in:
Peter Steinberger
2026-01-08 03:40:39 +01:00
parent e657e59b46
commit 8aa3efb9e8
7 changed files with 342 additions and 211 deletions

View File

@@ -1,3 +1,5 @@
import { normalizeCommandBody } from "./commands-registry.js";
export type SendPolicyOverride = "allow" | "deny";
export function normalizeSendPolicyOverride(
@@ -17,11 +19,10 @@ export function parseSendPolicyCommand(raw?: string): {
if (!raw) return { hasCommand: false };
const trimmed = raw.trim();
if (!trimmed) return { hasCommand: false };
const match = trimmed.match(
/^\/send(?:\s*:\s*([a-zA-Z]+)?\s*|\s+([a-zA-Z]+)\s*)?$/i,
);
const normalized = normalizeCommandBody(trimmed);
const match = normalized.match(/^\/send(?:\s+([a-zA-Z]+))?\s*$/i);
if (!match) return { hasCommand: false };
const token = (match[1] ?? match[2])?.trim().toLowerCase();
const token = match[1]?.trim().toLowerCase();
if (!token) return { hasCommand: true };
if (token === "inherit" || token === "default" || token === "reset") {
return { hasCommand: true, mode: "inherit" };