From e9de24215993e7139b4f902775db8f348f22213f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Feb 2026 15:09:30 +0000 Subject: [PATCH] refactor(exec-approvals): share request event types --- src/discord/monitor/exec-approvals.ts | 29 ++++++--------------------- src/infra/exec-approval-forwarder.ts | 29 ++++++--------------------- src/infra/exec-approvals.ts | 23 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 46 deletions(-) diff --git a/src/discord/monitor/exec-approvals.ts b/src/discord/monitor/exec-approvals.ts index f8cc632a7ec..72818e36ed3 100644 --- a/src/discord/monitor/exec-approvals.ts +++ b/src/discord/monitor/exec-approvals.ts @@ -3,7 +3,11 @@ import { ButtonStyle, Routes } from "discord-api-types/v10"; import type { OpenClawConfig } from "../../config/config.js"; import type { DiscordExecApprovalConfig } from "../../config/types.discord.js"; import type { EventFrame } from "../../gateway/protocol/index.js"; -import type { ExecApprovalDecision } from "../../infra/exec-approvals.js"; +import type { + ExecApprovalDecision, + ExecApprovalRequest, + ExecApprovalResolved, +} from "../../infra/exec-approvals.js"; import type { RuntimeEnv } from "../../runtime.js"; import { buildGatewayConnectionDetails } from "../../gateway/call.js"; import { GatewayClient } from "../../gateway/client.js"; @@ -13,28 +17,7 @@ import { createDiscordClient } from "../send.shared.js"; const EXEC_APPROVAL_KEY = "execapproval"; -export type ExecApprovalRequest = { - id: string; - request: { - command: string; - cwd?: string | null; - host?: string | null; - security?: string | null; - ask?: string | null; - agentId?: string | null; - resolvedPath?: string | null; - sessionKey?: string | null; - }; - createdAtMs: number; - expiresAtMs: number; -}; - -export type ExecApprovalResolved = { - id: string; - decision: ExecApprovalDecision; - resolvedBy?: string | null; - ts: number; -}; +export type { ExecApprovalRequest, ExecApprovalResolved }; type PendingApproval = { discordMessageId: string; diff --git a/src/infra/exec-approval-forwarder.ts b/src/infra/exec-approval-forwarder.ts index 0dd657b25c0..51e785b60aa 100644 --- a/src/infra/exec-approval-forwarder.ts +++ b/src/infra/exec-approval-forwarder.ts @@ -3,7 +3,11 @@ import type { ExecApprovalForwardingConfig, ExecApprovalForwardTarget, } from "../config/types.approvals.js"; -import type { ExecApprovalDecision } from "./exec-approvals.js"; +import type { + ExecApprovalDecision, + ExecApprovalRequest, + ExecApprovalResolved, +} from "./exec-approvals.js"; import { loadConfig } from "../config/config.js"; import { loadSessionStore, resolveStorePath } from "../config/sessions.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; @@ -14,28 +18,7 @@ import { resolveSessionDeliveryTarget } from "./outbound/targets.js"; const log = createSubsystemLogger("gateway/exec-approvals"); -export type ExecApprovalRequest = { - id: string; - request: { - command: string; - cwd?: string | null; - host?: string | null; - security?: string | null; - ask?: string | null; - agentId?: string | null; - resolvedPath?: string | null; - sessionKey?: string | null; - }; - createdAtMs: number; - expiresAtMs: number; -}; - -export type ExecApprovalResolved = { - id: string; - decision: ExecApprovalDecision; - resolvedBy?: string | null; - ts: number; -}; +export type { ExecApprovalRequest, ExecApprovalResolved }; type ForwardTarget = ExecApprovalForwardTarget & { source: "session" | "target" }; diff --git a/src/infra/exec-approvals.ts b/src/infra/exec-approvals.ts index 0217027d22c..efecc7c1183 100644 --- a/src/infra/exec-approvals.ts +++ b/src/infra/exec-approvals.ts @@ -11,6 +11,29 @@ export type ExecHost = "sandbox" | "gateway" | "node"; export type ExecSecurity = "deny" | "allowlist" | "full"; export type ExecAsk = "off" | "on-miss" | "always"; +export type ExecApprovalRequest = { + id: string; + request: { + command: string; + cwd?: string | null; + host?: string | null; + security?: string | null; + ask?: string | null; + agentId?: string | null; + resolvedPath?: string | null; + sessionKey?: string | null; + }; + createdAtMs: number; + expiresAtMs: number; +}; + +export type ExecApprovalResolved = { + id: string; + decision: ExecApprovalDecision; + resolvedBy?: string | null; + ts: number; +}; + export type ExecApprovalsDefaults = { security?: ExecSecurity; ask?: ExecAsk;