mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 03:54:57 +00:00
Remove the transcript redaction path for sessions_spawn arguments and inline attachments. OpenClaw transcripts are local trusted-operator state, and streamTo/resumeSessionId are runtime routing fields that must not be rewritten before replay or dispatch. Co-authored-by: Peter Steinberger <steipete@gmail.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
|
|
|
const TOOL_CALL_NAME_MAX_CHARS = 64;
|
|
const TOOL_CALL_NAME_RE = /^[A-Za-z0-9_:.-]+$/;
|
|
|
|
export function normalizeAllowedToolNames(allowedToolNames?: Iterable<string>): Set<string> | null {
|
|
if (!allowedToolNames) {
|
|
return null;
|
|
}
|
|
const normalized = new Set<string>();
|
|
for (const name of allowedToolNames) {
|
|
if (typeof name !== "string") {
|
|
continue;
|
|
}
|
|
const trimmed = name.trim();
|
|
if (!trimmed) {
|
|
continue;
|
|
}
|
|
normalized.add(normalizeLowercaseStringOrEmpty(trimmed));
|
|
}
|
|
return normalized.size > 0 ? normalized : null;
|
|
}
|
|
|
|
export function isAllowedToolCallName(
|
|
name: unknown,
|
|
allowedToolNames: Set<string> | null,
|
|
): boolean {
|
|
if (typeof name !== "string") {
|
|
return false;
|
|
}
|
|
const trimmed = name.trim();
|
|
if (!trimmed) {
|
|
return false;
|
|
}
|
|
if (trimmed.length > TOOL_CALL_NAME_MAX_CHARS || !TOOL_CALL_NAME_RE.test(trimmed)) {
|
|
return false;
|
|
}
|
|
if (!allowedToolNames) {
|
|
return true;
|
|
}
|
|
return allowedToolNames.has(normalizeLowercaseStringOrEmpty(trimmed));
|
|
}
|