UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

57 lines (56 loc) 2.21 kB
import { t as formatCliCommand } from "./command-format-CKGmlpAQ.js"; import "./agent-scope-MrLta7Pq.js"; import { c as resolveDefaultAgentId, o as resolveAgentWorkspaceDir } from "./agent-scope-config-CgCYpZfK.js"; import { n as t } from "./i18n-7g_f4oaD.js"; import { t as buildWorkspaceHookStatus } from "./hooks-status-B7g6_KWP.js"; //#region src/commands/onboard-hooks.ts /** Interactive onboarding step for enabling workspace hooks. */ /** Prompts for loadable internal hooks and writes selected hook entries. */ async function setupInternalHooks(cfg, _runtime, prompter) { 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"), 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([ `Enabled ${selected.length} hook${selected.length > 1 ? "s" : ""}: ${selected.join(", ")}`, "", "You can manage hooks later with:", ` ${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 };