import { t as formatCliCommand } from "./command-format-BPjMauol.js";
import "./agent-scope-CI3KK9ir.js";
import { c as resolveDefaultAgentId, o as resolveAgentWorkspaceDir } from "./agent-scope-config-CmpG8BCp.js";
import { n as t } from "./i18n-BFKL8XM2.js";
import { t as buildWorkspaceHookStatus } from "./hooks-status-jyYwOZyK.js";
//#region src/commands/onboard-hooks.ts
async function setupInternalHooks(cfg, _runtime, prompter) {
	await prompter.note([
		"Hooks 让你在触发 Agent 命令时自动执行操作。",
		"示例：当你执行 /new 或 /reset 时保存会话上下文到记忆。",
		"",
		"了解更多：https://docs.openclaw.ai/automation/hooks"
	].join("\n"), t("wizard.hooks.introTitle"));
	const eligibleHooks = buildWorkspaceHookStatus(resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg)), { config: cfg }).hooks.filter((h) => h.loadable);
	if (eligibleHooks.length === 0) {
		await prompter.note(t("wizard.hooks.noHooksMessage"), t("wizard.hooks.noHooksTitle"));
		return cfg;
	}
	const selected = (await prompter.multiselect({
		message: t("wizard.hooks.enable"),
		options: [{
			value: "__skip__",
			label: t("common.skipForNow")
		}, ...eligibleHooks.map((hook) => ({
			value: hook.name,
			label: `${hook.emoji ?? "🔗"} ${hook.name}`,
			hint: hook.description
		}))]
	})).filter((name) => name !== "__skip__");
	if (selected.length === 0) return cfg;
	const entries = { ...cfg.hooks?.internal?.entries };
	for (const name of selected) entries[name] = { enabled: true };
	const next = {
		...cfg,
		hooks: {
			...cfg.hooks,
			internal: {
				enabled: true,
				entries
			}
		}
	};
	await prompter.note([
		`已启用 ${selected.length} 个 Hook：${selected.join(", ")}`,
		"",
		"你可以稍后通过以下命令管理 Hooks：",
		`  ${formatCliCommand("openclaw hooks list")}`,
		`  ${formatCliCommand("openclaw hooks enable <name>")}`,
		`  ${formatCliCommand("openclaw hooks disable <name>")}`
	].join("\n"), t("wizard.hooks.configuredTitle"));
	return next;
}
//#endregion
export { setupInternalHooks };
