mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(tool-display): satisfy format/lint and address review feedback
- extract web_search/web_fetch detail resolvers into common module\n- fix node -c classification so file path remains positional\n- remove dead git subcommands set\n- keep exec summary refinements (heredoc/node check/git -C/preamble strip)\n- make tests cover node -c syntax-check path\n- run format:check, tsgo, lint, and focused e2e tests
This commit is contained in:
committed by
Peter Steinberger
parent
24f213e7ed
commit
facfa410a7
@@ -7,6 +7,8 @@ import {
|
||||
resolveDetailFromKeys,
|
||||
resolveExecDetail,
|
||||
resolveReadDetail,
|
||||
resolveWebFetchDetail,
|
||||
resolveWebSearchDetail,
|
||||
resolveWriteDetail,
|
||||
type ToolDisplaySpec as ToolDisplaySpecBase,
|
||||
} from "../../../src/agents/tool-display-common.js";
|
||||
@@ -92,36 +94,12 @@ export function resolveToolDisplay(params: {
|
||||
detail = resolveWriteDetail(key, params.args);
|
||||
}
|
||||
|
||||
if (!detail && key === "web_search" && params.args && typeof params.args === "object") {
|
||||
const record = params.args as Record<string, unknown>;
|
||||
const query = typeof record.query === "string" ? record.query.trim() : undefined;
|
||||
const count =
|
||||
typeof record.count === "number" && Number.isFinite(record.count) && record.count > 0
|
||||
? Math.floor(record.count)
|
||||
: undefined;
|
||||
if (query) {
|
||||
detail = count !== undefined ? `for "${query}" (top ${count})` : `for "${query}"`;
|
||||
}
|
||||
if (!detail && key === "web_search") {
|
||||
detail = resolveWebSearchDetail(params.args);
|
||||
}
|
||||
|
||||
if (!detail && key === "web_fetch" && params.args && typeof params.args === "object") {
|
||||
const record = params.args as Record<string, unknown>;
|
||||
const url = typeof record.url === "string" ? record.url.trim() : undefined;
|
||||
const mode =
|
||||
typeof record.extractMode === "string" ? record.extractMode.trim() : undefined;
|
||||
const maxChars =
|
||||
typeof record.maxChars === "number" && Number.isFinite(record.maxChars) && record.maxChars > 0
|
||||
? Math.floor(record.maxChars)
|
||||
: undefined;
|
||||
if (url) {
|
||||
const suffix = [
|
||||
mode ? `mode ${mode}` : undefined,
|
||||
maxChars !== undefined ? `max ${maxChars} chars` : undefined,
|
||||
]
|
||||
.filter((value): value is string => Boolean(value))
|
||||
.join(", ");
|
||||
detail = suffix ? `from ${url} (${suffix})` : `from ${url}`;
|
||||
}
|
||||
if (!detail && key === "web_fetch") {
|
||||
detail = resolveWebFetchDetail(params.args);
|
||||
}
|
||||
|
||||
const detailKeys = actionSpec?.detailKeys ?? spec?.detailKeys ?? FALLBACK.detailKeys ?? [];
|
||||
|
||||
Reference in New Issue
Block a user