refactor: trim gateway hook exports

This commit is contained in:
Peter Steinberger
2026-05-01 22:48:21 +01:00
parent 6af6688ce2
commit 236bd42bb3
2 changed files with 10 additions and 10 deletions

View File

@@ -27,19 +27,19 @@ export type HookMappingResolved = {
transform?: HookMappingTransformResolved;
};
export type HookMappingTransformResolved = {
type HookMappingTransformResolved = {
modulePath: string;
exportName?: string;
};
export type HookMappingContext = {
type HookMappingContext = {
payload: Record<string, unknown>;
headers: Record<string, string>;
url: URL;
path: string;
};
export type HookAction =
type HookAction =
| {
kind: "wake";
text: string;
@@ -62,9 +62,9 @@ export type HookAction =
timeoutSeconds?: number;
};
export type HookSessionKeyTemplateSource = "static" | "templated";
type HookSessionKeyTemplateSource = "static" | "templated";
export type HookMappingResult =
type HookMappingResult =
| { ok: true; action: HookAction }
| { ok: true; action: null; skipped: true }
| { ok: false; error: string };

View File

@@ -32,19 +32,19 @@ export type HooksConfigResolved = {
sessionPolicy: HookSessionPolicyResolved;
};
export type HookAgentPolicyResolved = {
type HookAgentPolicyResolved = {
defaultAgentId: string;
knownAgentIds: Set<string>;
allowedAgentIds?: Set<string>;
};
export type HookSessionPolicyResolved = {
type HookSessionPolicyResolved = {
defaultSessionKey?: string;
allowRequestSessionKey: boolean;
allowedSessionKeyPrefixes?: string[];
};
export type HookSessionKeySource = "request" | "mapping-static" | "mapping-templated";
type HookSessionKeySource = "request" | "mapping-static" | "mapping-templated";
export function resolveHooksConfig(cfg: OpenClawConfig): HooksConfigResolved | null {
if (cfg.hooks?.enabled !== true) {
@@ -210,7 +210,7 @@ export function normalizeWakePayload(
return { ok: true, value: { text: normalizedText, mode } };
}
export type HookAgentPayload = {
type HookAgentPayload = {
message: string;
name: string;
agentId?: string;
@@ -312,7 +312,7 @@ export function isHookAgentAllowed(
}
export const getHookAgentPolicyError = () => "agentId is not allowed by hooks.allowedAgentIds";
export const getHookSessionKeyRequestPolicyError = () =>
const getHookSessionKeyRequestPolicyError = () =>
"sessionKey is disabled for externally supplied hook payload values; set hooks.allowRequestSessionKey=true to enable";
export const getHookSessionKeyPrefixError = (prefixes: string[]) =>
`sessionKey must start with one of: ${prefixes.join(", ")}`;