mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 10:41:23 +00:00
fix(gateway): split hook channel types
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<HookAgentPayload, "sessionKey"> & {
|
||||
|
||||
const listHookChannelValues = () => ["last", ...listChannelPlugins().map((plugin) => plugin.id)];
|
||||
|
||||
export type HookMessageChannel = ChannelId;
|
||||
export type { HookMessageChannel } from "./hooks.types.js";
|
||||
|
||||
const getHookChannelSet = () => new Set<string>(listHookChannelValues());
|
||||
export const getHookChannelError = () => `channel must be ${listHookChannelValues().join("|")}`;
|
||||
|
||||
3
src/gateway/hooks.types.ts
Normal file
3
src/gateway/hooks.types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { ChannelId } from "../channels/plugins/types.js";
|
||||
|
||||
export type HookMessageChannel = ChannelId;
|
||||
Reference in New Issue
Block a user