mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:51:37 +00:00
refactor(node-host): share invoke type definitions
This commit is contained in:
@@ -20,46 +20,12 @@ import {
|
|||||||
import type { ExecHostRequest, ExecHostResponse, ExecHostRunResult } from "../infra/exec-host.js";
|
import type { ExecHostRequest, ExecHostResponse, ExecHostRunResult } from "../infra/exec-host.js";
|
||||||
import { getTrustedSafeBinDirs } from "../infra/exec-safe-bin-trust.js";
|
import { getTrustedSafeBinDirs } from "../infra/exec-safe-bin-trust.js";
|
||||||
import { resolveSystemRunCommand } from "../infra/system-run-command.js";
|
import { resolveSystemRunCommand } from "../infra/system-run-command.js";
|
||||||
|
import type {
|
||||||
type SystemRunParams = {
|
ExecEventPayload,
|
||||||
command: string[];
|
RunResult,
|
||||||
rawCommand?: string | null;
|
SkillBinsProvider,
|
||||||
cwd?: string | null;
|
SystemRunParams,
|
||||||
env?: Record<string, string>;
|
} from "./invoke-types.js";
|
||||||
timeoutMs?: number | null;
|
|
||||||
needsScreenRecording?: boolean | null;
|
|
||||||
agentId?: string | null;
|
|
||||||
sessionKey?: string | null;
|
|
||||||
approved?: boolean | null;
|
|
||||||
approvalDecision?: string | null;
|
|
||||||
runId?: string | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
type RunResult = {
|
|
||||||
exitCode?: number;
|
|
||||||
timedOut: boolean;
|
|
||||||
success: boolean;
|
|
||||||
stdout: string;
|
|
||||||
stderr: string;
|
|
||||||
error?: string | null;
|
|
||||||
truncated: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ExecEventPayload = {
|
|
||||||
sessionKey: string;
|
|
||||||
runId: string;
|
|
||||||
host: string;
|
|
||||||
command?: string;
|
|
||||||
exitCode?: number;
|
|
||||||
timedOut?: boolean;
|
|
||||||
success?: boolean;
|
|
||||||
output?: string;
|
|
||||||
reason?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type SkillBinsProvider = {
|
|
||||||
current(force?: boolean): Promise<Set<string>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
type SystemRunInvokeResult = {
|
type SystemRunInvokeResult = {
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
|
|||||||
39
src/node-host/invoke-types.ts
Normal file
39
src/node-host/invoke-types.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
export type SystemRunParams = {
|
||||||
|
command: string[];
|
||||||
|
rawCommand?: string | null;
|
||||||
|
cwd?: string | null;
|
||||||
|
env?: Record<string, string>;
|
||||||
|
timeoutMs?: number | null;
|
||||||
|
needsScreenRecording?: boolean | null;
|
||||||
|
agentId?: string | null;
|
||||||
|
sessionKey?: string | null;
|
||||||
|
approved?: boolean | null;
|
||||||
|
approvalDecision?: string | null;
|
||||||
|
runId?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RunResult = {
|
||||||
|
exitCode?: number;
|
||||||
|
timedOut: boolean;
|
||||||
|
success: boolean;
|
||||||
|
stdout: string;
|
||||||
|
stderr: string;
|
||||||
|
error?: string | null;
|
||||||
|
truncated: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ExecEventPayload = {
|
||||||
|
sessionKey: string;
|
||||||
|
runId: string;
|
||||||
|
host: string;
|
||||||
|
command?: string;
|
||||||
|
exitCode?: number;
|
||||||
|
timedOut?: boolean;
|
||||||
|
success?: boolean;
|
||||||
|
output?: string;
|
||||||
|
reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SkillBinsProvider = {
|
||||||
|
current(force?: boolean): Promise<Set<string>>;
|
||||||
|
};
|
||||||
@@ -21,6 +21,12 @@ import {
|
|||||||
import { sanitizeHostExecEnv } from "../infra/host-env-security.js";
|
import { sanitizeHostExecEnv } from "../infra/host-env-security.js";
|
||||||
import { runBrowserProxyCommand } from "./invoke-browser.js";
|
import { runBrowserProxyCommand } from "./invoke-browser.js";
|
||||||
import { handleSystemRunInvoke } from "./invoke-system-run.js";
|
import { handleSystemRunInvoke } from "./invoke-system-run.js";
|
||||||
|
import type {
|
||||||
|
ExecEventPayload,
|
||||||
|
RunResult,
|
||||||
|
SkillBinsProvider,
|
||||||
|
SystemRunParams,
|
||||||
|
} from "./invoke-types.js";
|
||||||
|
|
||||||
const OUTPUT_CAP = 200_000;
|
const OUTPUT_CAP = 200_000;
|
||||||
const OUTPUT_EVENT_TAIL = 20_000;
|
const OUTPUT_EVENT_TAIL = 20_000;
|
||||||
@@ -30,20 +36,6 @@ const execHostEnforced = process.env.OPENCLAW_NODE_EXEC_HOST?.trim().toLowerCase
|
|||||||
const execHostFallbackAllowed =
|
const execHostFallbackAllowed =
|
||||||
process.env.OPENCLAW_NODE_EXEC_FALLBACK?.trim().toLowerCase() !== "0";
|
process.env.OPENCLAW_NODE_EXEC_FALLBACK?.trim().toLowerCase() !== "0";
|
||||||
|
|
||||||
type SystemRunParams = {
|
|
||||||
command: string[];
|
|
||||||
rawCommand?: string | null;
|
|
||||||
cwd?: string | null;
|
|
||||||
env?: Record<string, string>;
|
|
||||||
timeoutMs?: number | null;
|
|
||||||
needsScreenRecording?: boolean | null;
|
|
||||||
agentId?: string | null;
|
|
||||||
sessionKey?: string | null;
|
|
||||||
approved?: boolean | null;
|
|
||||||
approvalDecision?: string | null;
|
|
||||||
runId?: string | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
type SystemWhichParams = {
|
type SystemWhichParams = {
|
||||||
bins: string[];
|
bins: string[];
|
||||||
};
|
};
|
||||||
@@ -60,28 +52,6 @@ type ExecApprovalsSnapshot = {
|
|||||||
file: ExecApprovalsFile;
|
file: ExecApprovalsFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RunResult = {
|
|
||||||
exitCode?: number;
|
|
||||||
timedOut: boolean;
|
|
||||||
success: boolean;
|
|
||||||
stdout: string;
|
|
||||||
stderr: string;
|
|
||||||
error?: string | null;
|
|
||||||
truncated: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ExecEventPayload = {
|
|
||||||
sessionKey: string;
|
|
||||||
runId: string;
|
|
||||||
host: string;
|
|
||||||
command?: string;
|
|
||||||
exitCode?: number;
|
|
||||||
timedOut?: boolean;
|
|
||||||
success?: boolean;
|
|
||||||
output?: string;
|
|
||||||
reason?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type NodeInvokeRequestPayload = {
|
export type NodeInvokeRequestPayload = {
|
||||||
id: string;
|
id: string;
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
@@ -91,9 +61,7 @@ export type NodeInvokeRequestPayload = {
|
|||||||
idempotencyKey?: string | null;
|
idempotencyKey?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SkillBinsProvider = {
|
export type { SkillBinsProvider } from "./invoke-types.js";
|
||||||
current(force?: boolean): Promise<Set<string>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
function resolveExecSecurity(value?: string): ExecSecurity {
|
function resolveExecSecurity(value?: string): ExecSecurity {
|
||||||
return value === "deny" || value === "allowlist" || value === "full" ? value : "allowlist";
|
return value === "deny" || value === "allowlist" || value === "full" ? value : "allowlist";
|
||||||
|
|||||||
Reference in New Issue
Block a user