mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 14:21:45 +00:00
fix: sanitize node invoke result params
This commit is contained in:
@@ -833,19 +833,52 @@ async function sendInvokeResult(
|
||||
},
|
||||
) {
|
||||
try {
|
||||
await client.request("node.invoke.result", {
|
||||
id: frame.id,
|
||||
nodeId: frame.nodeId,
|
||||
ok: result.ok,
|
||||
payload: result.payload,
|
||||
payloadJSON: result.payloadJSON ?? null,
|
||||
error: result.error ?? null,
|
||||
});
|
||||
await client.request("node.invoke.result", buildNodeInvokeResultParams(frame, result));
|
||||
} catch {
|
||||
// ignore: node invoke responses are best-effort
|
||||
}
|
||||
}
|
||||
|
||||
export function buildNodeInvokeResultParams(
|
||||
frame: NodeInvokeRequestPayload,
|
||||
result: {
|
||||
ok: boolean;
|
||||
payload?: unknown;
|
||||
payloadJSON?: string | null;
|
||||
error?: { code?: string; message?: string } | null;
|
||||
},
|
||||
): {
|
||||
id: string;
|
||||
nodeId: string;
|
||||
ok: boolean;
|
||||
payload?: unknown;
|
||||
payloadJSON?: string;
|
||||
error?: { code?: string; message?: string };
|
||||
} {
|
||||
const params: {
|
||||
id: string;
|
||||
nodeId: string;
|
||||
ok: boolean;
|
||||
payload?: unknown;
|
||||
payloadJSON?: string;
|
||||
error?: { code?: string; message?: string };
|
||||
} = {
|
||||
id: frame.id,
|
||||
nodeId: frame.nodeId,
|
||||
ok: result.ok,
|
||||
};
|
||||
if (result.payload !== undefined) {
|
||||
params.payload = result.payload;
|
||||
}
|
||||
if (typeof result.payloadJSON === "string") {
|
||||
params.payloadJSON = result.payloadJSON;
|
||||
}
|
||||
if (result.error) {
|
||||
params.error = result.error;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
async function sendNodeEvent(client: GatewayClient, event: string, payload: unknown) {
|
||||
try {
|
||||
await client.request("node.event", {
|
||||
|
||||
Reference in New Issue
Block a user