mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:58:26 +00:00
refactor(gateway): centralize node.invoke param sanitization
This commit is contained in:
21
src/gateway/node-invoke-sanitize.ts
Normal file
21
src/gateway/node-invoke-sanitize.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { ExecApprovalManager } from "./exec-approval-manager.js";
|
||||
import type { GatewayClient } from "./server-methods/types.js";
|
||||
import { sanitizeSystemRunParamsForForwarding } from "./node-invoke-system-run-approval.js";
|
||||
|
||||
export function sanitizeNodeInvokeParamsForForwarding(opts: {
|
||||
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({
|
||||
rawParams: opts.rawParams,
|
||||
client: opts.client,
|
||||
execApprovalManager: opts.execApprovalManager,
|
||||
});
|
||||
}
|
||||
return { ok: true, params: opts.rawParams };
|
||||
}
|
||||
Reference in New Issue
Block a user