openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
75 lines (74 loc) • 2.36 kB
JavaScript
//#region src/plugins/hook-types.ts
const PLUGIN_HOOK_METADATA = {
before_model_resolve: { conversationAccess: true },
agent_turn_prepare: {
conversationAccess: true,
promptInjection: true
},
before_prompt_build: {
conversationAccess: true,
promptInjection: true,
modifyingTimeoutMs: 15e3
},
before_agent_reply: { conversationAccess: true },
model_call_started: {},
model_call_ended: {},
llm_input: { conversationAccess: true },
llm_output: { conversationAccess: true },
before_agent_finalize: {
conversationAccess: true,
modifyingTimeoutMs: 15e3
},
agent_end: {
conversationAccess: true,
voidTimeoutMs: 3e4
},
before_compaction: { voidTimeoutMs: 3e4 },
after_compaction: { voidTimeoutMs: 3e4 },
before_reset: {},
before_channel_ingress: {
conversationAccess: true,
modifyingTimeoutMs: 15e3
},
inbound_claim: {},
channel_pairing_requested: { voidTimeoutMs: 2e3 },
message_received: {},
message_sending: { modifyingTimeoutMs: 15e3 },
reply_payload_sending: { modifyingTimeoutMs: 15e3 },
message_sent: {},
before_tool_call: { modifyingTimeoutMs: 15e3 },
after_tool_call: {},
tool_result_persist: {},
before_message_write: {},
session_start: {},
session_end: {},
subagent_delivery_target: {},
subagent_spawned: {},
subagent_progress: {},
subagent_ended: {},
gateway_start: {},
gateway_stop: { voidTimeoutMs: 5e3 },
heartbeat_prompt_contribution: { promptInjection: true },
cron_reconciled: {},
cron_changed: {},
skill_changed: { voidTimeoutMs: 3e4 },
before_dispatch: {},
reply_dispatch: {},
before_install: { modifyingTimeoutMs: 15e3 },
before_agent_run: {
conversationAccess: true,
modifyingTimeoutMs: 15e3
},
resolve_exec_env: { modifyingTimeoutMs: 15e3 }
};
const isPluginHookName = (e) => typeof e === "string" && Object.hasOwn(PLUGIN_HOOK_METADATA, e);
const isPromptInjectionHookName = (e) => PLUGIN_HOOK_METADATA[e]?.promptInjection === true;
const pluginHookAgentTriggerSet = /* @__PURE__ */ new Set([
"cron",
"heartbeat",
"user"
]);
const isPluginHookAgentTrigger = (e) => typeof e === "string" && pluginHookAgentTriggerSet.has(e);
const isPluginHookReplyDispatchKind = (e) => e === "agent" || e === "acp";
//#endregion
export { isPromptInjectionHookName as a, isPluginHookReplyDispatchKind as i, isPluginHookAgentTrigger as n, isPluginHookName as r, PLUGIN_HOOK_METADATA as t };