mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:30:42 +00:00
refactor: trim gateway hook exports
This commit is contained in:
@@ -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 };
|
||||
|
||||
@@ -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(", ")}`;
|
||||
|
||||
Reference in New Issue
Block a user