


























@@ -2,9 +2,9 @@ import crypto from "node:crypto";
22import { Type } from "@sinclair/typebox";
33import type { OpenClawConfig } from "../../config/types.openclaw.js";
44import type { OperatorScope } from "../../gateway/method-scopes.js";
5+import { readConnectPairingRequiredMessage } from "../../gateway/protocol/connect-error-details.js";
56import { formatErrorMessage } from "../../infra/errors.js";
67import { resolveNodePairApprovalScopes } from "../../infra/node-pairing-authz.js";
7-import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js";
88import type { GatewayMessageChannel } from "../../utils/message-channel.js";
99import { resolveSessionAgentId } from "../agent-scope.js";
1010import { resolveImageSanitizationLimits } from "../image-sanitization.js";
@@ -74,20 +74,6 @@ async function resolveNodePairApproveScopes(
7474return resolveApproveScopes(match?.commands);
7575}
767677-function isPairingRequiredMessage(message: string): boolean {
78-const lower = normalizeLowercaseStringOrEmpty(message);
79-return lower.includes("pairing required") || lower.includes("not_paired");
80-}
81-82-function extractPairingRequestId(message: string): string | null {
83-const match = message.match(/\(requestId:\s*([^)]+)\)/i);
84-if (!match) {
85-return null;
86-}
87-const value = (match[1] ?? "").trim();
88-return value.length > 0 ? value : null;
89-}
90-9177// Flattened schema: runtime validates per-action requirements.
9278const NodesToolSchema = Type.Object({
9379action: stringEnum(NODES_TOOL_ACTIONS),
@@ -307,8 +293,9 @@ export function createNodesTool(options?: {
307293 : "default";
308294const agentLabel = agentId ?? "unknown";
309295let message = formatErrorMessage(err);
310-if (action === "invoke" && isPairingRequiredMessage(message)) {
311-const requestId = extractPairingRequestId(message);
296+const pairing = action === "invoke" ? readConnectPairingRequiredMessage(message) : null;
297+if (pairing) {
298+const requestId = pairing.requestId ?? null;
312299const approveHint = requestId
313300 ? `Approve pairing request ${requestId} and retry.`
314301 : "Approve the pending pairing request and retry.";
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。