mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-27 21:43:35 +00:00
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
// Node invocation forwarding sanitizer.
|
|
// Strips or validates gateway-only control fields before node transport.
|
|
import type { ExecApprovalManager } from "./exec-approval-manager.js";
|
|
import { sanitizeSystemRunParamsForForwarding } from "./node-invoke-system-run-approval.js";
|
|
import type { GatewayClient } from "./server-methods/types.js";
|
|
|
|
// Node invoke forwarding sanitizes command-specific payloads before they leave
|
|
// the gateway. system.run carries approval bindings and therefore needs special
|
|
// handling; other commands pass through unchanged.
|
|
/** Sanitizes node.invoke params before forwarding them to a connected node. */
|
|
export function sanitizeNodeInvokeParamsForForwarding(opts: {
|
|
nodeId: string;
|
|
command: string;
|
|
rawParams: unknown;
|
|
client: GatewayClient | null;
|
|
execApprovalManager?: ExecApprovalManager;
|
|
}):
|
|
| { ok: true; params: unknown }
|
|
| { ok: false; message: string; details?: Record<string, unknown> } {
|
|
if (opts.command === "system.run") {
|
|
return sanitizeSystemRunParamsForForwarding({
|
|
nodeId: opts.nodeId,
|
|
rawParams: opts.rawParams,
|
|
client: opts.client,
|
|
execApprovalManager: opts.execApprovalManager,
|
|
});
|
|
}
|
|
return { ok: true, params: opts.rawParams };
|
|
}
|