From ea54beb08a2342cac0ce8f40fde47e71e333270e Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 9 Apr 2026 07:41:40 +0100 Subject: [PATCH] fix(gateway): split hook channel types --- src/gateway/hooks-mapping.ts | 2 +- src/gateway/hooks.ts | 4 ++-- src/gateway/hooks.types.ts | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/gateway/hooks.types.ts diff --git a/src/gateway/hooks-mapping.ts b/src/gateway/hooks-mapping.ts index 1fc99ebc3d1..df1aa024785 100644 --- a/src/gateway/hooks-mapping.ts +++ b/src/gateway/hooks-mapping.ts @@ -3,7 +3,7 @@ import path from "node:path"; import { CONFIG_PATH, type HookMappingConfig, type HooksConfig } from "../config/config.js"; import { importFileModule, resolveFunctionModuleExport } from "../hooks/module-loader.js"; import { normalizeOptionalString, readStringValue } from "../shared/string-coerce.js"; -import type { HookMessageChannel } from "./hooks.js"; +import type { HookMessageChannel } from "./hooks.types.js"; export type HookMappingResolved = { id: string; diff --git a/src/gateway/hooks.ts b/src/gateway/hooks.ts index 68a5d8fdd50..47d785a140a 100644 --- a/src/gateway/hooks.ts +++ b/src/gateway/hooks.ts @@ -2,7 +2,6 @@ import { randomUUID } from "node:crypto"; import type { IncomingMessage } from "node:http"; import { listAgentIds, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { listChannelPlugins } from "../channels/plugins/index.js"; -import type { ChannelId } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; import { readJsonBodyWithLimit, requestBodyErrorToText } from "../infra/http-body.js"; import { normalizeAgentId, parseAgentSessionKey } from "../routing/session-key.js"; @@ -14,6 +13,7 @@ import { import { normalizeMessageChannel } from "../utils/message-channel.js"; import { type HookMappingResolved, resolveHookMappings } from "./hooks-mapping.js"; import { resolveAllowedAgentIds } from "./hooks-policy.js"; +import type { HookMessageChannel } from "./hooks.types.js"; const DEFAULT_HOOKS_PATH = "/hooks"; const DEFAULT_HOOKS_MAX_BODY_BYTES = 256 * 1024; @@ -222,7 +222,7 @@ export type HookAgentDispatchPayload = Omit & { const listHookChannelValues = () => ["last", ...listChannelPlugins().map((plugin) => plugin.id)]; -export type HookMessageChannel = ChannelId; +export type { HookMessageChannel } from "./hooks.types.js"; const getHookChannelSet = () => new Set(listHookChannelValues()); export const getHookChannelError = () => `channel must be ${listHookChannelValues().join("|")}`; diff --git a/src/gateway/hooks.types.ts b/src/gateway/hooks.types.ts new file mode 100644 index 00000000000..ecca775d152 --- /dev/null +++ b/src/gateway/hooks.types.ts @@ -0,0 +1,3 @@ +import type { ChannelId } from "../channels/plugins/types.js"; + +export type HookMessageChannel = ChannelId;