mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 01:20:24 +00:00
refactor: dedupe browser string readers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import crypto from "node:crypto";
|
||||
import { normalizeOptionalString, readStringValue } from "openclaw/plugin-sdk/text-runtime";
|
||||
import {
|
||||
executeActAction,
|
||||
executeConsoleAction,
|
||||
@@ -114,7 +115,7 @@ export const __testing = {
|
||||
};
|
||||
|
||||
function readOptionalTargetAndTimeout(params: Record<string, unknown>) {
|
||||
const targetId = typeof params.targetId === "string" ? params.targetId.trim() : undefined;
|
||||
const targetId = normalizeOptionalString(params.targetId);
|
||||
const timeoutMs =
|
||||
typeof params.timeoutMs === "number" && Number.isFinite(params.timeoutMs)
|
||||
? params.timeoutMs
|
||||
@@ -647,7 +648,7 @@ export function createBrowserTool(opts?: {
|
||||
proxyRequest,
|
||||
});
|
||||
case "pdf": {
|
||||
const targetId = typeof params.targetId === "string" ? params.targetId.trim() : undefined;
|
||||
const targetId = normalizeOptionalString(params.targetId);
|
||||
const result = proxyRequest
|
||||
? ((await proxyRequest({
|
||||
method: "POST",
|
||||
@@ -709,7 +710,7 @@ export function createBrowserTool(opts?: {
|
||||
}
|
||||
case "dialog": {
|
||||
const accept = Boolean(params.accept);
|
||||
const promptText = typeof params.promptText === "string" ? params.promptText : undefined;
|
||||
const promptText = readStringValue(params.promptText);
|
||||
const { targetId, timeoutMs } = readOptionalTargetAndTimeout(params);
|
||||
if (proxyRequest) {
|
||||
const result = await proxyRequest({
|
||||
|
||||
Reference in New Issue
Block a user