mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 12:11:20 +00:00
refactor: dedupe acp record helper
This commit is contained in:
@@ -3,6 +3,7 @@ import path from "node:path";
|
||||
import { isKnownCoreToolId } from "../agents/tool-catalog.js";
|
||||
import { isMutatingToolCall } from "../agents/tool-mutation.js";
|
||||
import { resolveOwnerOnlyToolApprovalClass } from "../agents/tool-policy.js";
|
||||
import { asRecord } from "./record-shared.js";
|
||||
|
||||
const SAFE_SEARCH_TOOL_IDS = new Set(["search", "web_search", "memory_search"]);
|
||||
const TRUSTED_SAFE_TOOL_ALIASES = new Set(["search"]);
|
||||
@@ -32,12 +33,6 @@ export type AcpApprovalClassification = {
|
||||
autoApprove: boolean;
|
||||
};
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function readFirstStringValue(
|
||||
source: Record<string, unknown> | undefined,
|
||||
keys: string[],
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
ToolCallLocation,
|
||||
ToolKind,
|
||||
} from "@agentclientprotocol/sdk";
|
||||
import { asRecord } from "./record-shared.js";
|
||||
|
||||
export type GatewayAttachment = {
|
||||
type: string;
|
||||
@@ -95,12 +96,6 @@ function escapeResourceTitle(value: string): string {
|
||||
return escapeInlineControlChars(value).replace(/[()[\]]/g, (char) => `\\${char}`);
|
||||
}
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function normalizeToolLocationPath(value: string): string | undefined {
|
||||
const trimmed = value.trim();
|
||||
if (
|
||||
|
||||
5
src/acp/record-shared.ts
Normal file
5
src/acp/record-shared.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export function asRecord(value: unknown): Record<string, unknown> | undefined {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user