Files
openclaw/src/agents/tool-call-shared.ts
martingarramon ef86d8c95c fix(agents): preserve sessions_spawn transcript payloads (#82203)
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>
2026-05-26 21:30:01 +01:00

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));
}