mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 21:14:31 +00:00
refactor(exec-approvals): share request event types
This commit is contained in:
@@ -3,7 +3,11 @@ import { ButtonStyle, Routes } from "discord-api-types/v10";
|
|||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import type { DiscordExecApprovalConfig } from "../../config/types.discord.js";
|
import type { DiscordExecApprovalConfig } from "../../config/types.discord.js";
|
||||||
import type { EventFrame } from "../../gateway/protocol/index.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 type { RuntimeEnv } from "../../runtime.js";
|
||||||
import { buildGatewayConnectionDetails } from "../../gateway/call.js";
|
import { buildGatewayConnectionDetails } from "../../gateway/call.js";
|
||||||
import { GatewayClient } from "../../gateway/client.js";
|
import { GatewayClient } from "../../gateway/client.js";
|
||||||
@@ -13,28 +17,7 @@ import { createDiscordClient } from "../send.shared.js";
|
|||||||
|
|
||||||
const EXEC_APPROVAL_KEY = "execapproval";
|
const EXEC_APPROVAL_KEY = "execapproval";
|
||||||
|
|
||||||
export type ExecApprovalRequest = {
|
export type { ExecApprovalRequest, ExecApprovalResolved };
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
type PendingApproval = {
|
type PendingApproval = {
|
||||||
discordMessageId: string;
|
discordMessageId: string;
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ import type {
|
|||||||
ExecApprovalForwardingConfig,
|
ExecApprovalForwardingConfig,
|
||||||
ExecApprovalForwardTarget,
|
ExecApprovalForwardTarget,
|
||||||
} from "../config/types.approvals.js";
|
} 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 { loadConfig } from "../config/config.js";
|
||||||
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
||||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||||
@@ -14,28 +18,7 @@ import { resolveSessionDeliveryTarget } from "./outbound/targets.js";
|
|||||||
|
|
||||||
const log = createSubsystemLogger("gateway/exec-approvals");
|
const log = createSubsystemLogger("gateway/exec-approvals");
|
||||||
|
|
||||||
export type ExecApprovalRequest = {
|
export type { ExecApprovalRequest, ExecApprovalResolved };
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ForwardTarget = ExecApprovalForwardTarget & { source: "session" | "target" };
|
type ForwardTarget = ExecApprovalForwardTarget & { source: "session" | "target" };
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,29 @@ export type ExecHost = "sandbox" | "gateway" | "node";
|
|||||||
export type ExecSecurity = "deny" | "allowlist" | "full";
|
export type ExecSecurity = "deny" | "allowlist" | "full";
|
||||||
export type ExecAsk = "off" | "on-miss" | "always";
|
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 = {
|
export type ExecApprovalsDefaults = {
|
||||||
security?: ExecSecurity;
|
security?: ExecSecurity;
|
||||||
ask?: ExecAsk;
|
ask?: ExecAsk;
|
||||||
|
|||||||
Reference in New Issue
Block a user