import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { formatCliCommand } from "../cli/command-format.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { buildWorkspaceHookStatus } from "../hooks/hooks-status.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js";
export async function setupInternalHooks(
cfg: OpenClawConfig,
runtime: RuntimeEnv,
prompter: WizardPrompter,
): Promise<OpenClawConfig> {
await prompter.note(
[ "Hooks let you automate actions when agent commands are issued.", "Example: Save session context to memory when you issue /new or /reset.", "", "Learn more: https://docs.openclaw.ai/automation/hooks",
].join("\n"), "Hooks",
);
// Discover available hooks using the hook discovery system const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg)); const report = buildWorkspaceHookStatus(workspaceDir, { config: cfg });
// Show every eligible hook so users can opt in during setup. const eligibleHooks = report.hooks.filter((h) => h.loadable);
if (eligibleHooks.length === 0) {
await prompter.note( "No eligible hooks found. You can configure hooks later in your config.", "No Hooks Available",
); return cfg;
}
const selected = toEnable.filter((name) => name !== "__skip__"); if (selected.length === 0) { return cfg;
}
// Enable selected hooks using the new entries config format const entries = { ...cfg.hooks?.internal?.entries }; for (const name of selected) {
entries[name] = { enabled: true };
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.16Bemerkung:
(vorverarbeitet am 2026-09-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.