UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

86 lines (85 loc) • 2.99 kB
import { t as CONFIG_DIR } from "./utils-C8YECn2Q.mjs"; import { n as resolveHookEnableState, r as resolveHookEntries, t as resolveHookConfig } from "./policy-9WWlcycM.mjs"; import { n as hasBinary } from "./config-eval-nIkprN5m.mjs"; import { t as resolveHookKey } from "./frontmatter-CTZaq8xF.mjs"; import { n as isHookEnvSatisfied, t as isHookConfigPathTruthy } from "./config-DHhSuG97.mjs"; import { t as evaluateEntryRequirementsForCurrentPlatform } from "./entry-status-DGwSR8dn.mjs"; import { t as isKnownInternalHookEventKey } from "./internal-hook-types-B0QGfnTY.mjs"; import { t as loadWorkspaceHookEntries } from "./workspace-DyN-emhI.mjs"; import path from "node:path"; //#region src/hooks/hooks-status.ts function buildWorkspaceHookStatus(e, t) { const n = resolveHookEntries(t?.entries ?? loadWorkspaceHookEntries(e, t)); return { workspaceDir: e, managedHooksDir: path.join(CONFIG_DIR, "hooks"), hooks: n.map((e) => { const n = t?.config; const r = resolveHookKey(e.hook.name, e); const i = resolveHookConfig(n, r); const a = e.hook.source === "openclaw-plugin"; const o = resolveHookEnableState({ entry: e, hookConfig: i }); const s = e.metadata?.always === true; const c = e.metadata?.events ?? []; const l = c.filter((e) => !isKnownInternalHookEventKey(e)); const isEnvSatisfied = (e) => isHookEnvSatisfied(e, i); const isConfigSatisfied = (e) => isHookConfigPathTruthy(n, e); const { emoji: u, homepage: d, required: f, missing: p, requirementsSatisfied: m, configChecks: h } = evaluateEntryRequirementsForCurrentPlatform({ always: s, entry: e, hasLocalBin: hasBinary, isEnvSatisfied, isConfigSatisfied }); const g = o.enabled; const _ = c.length > 0; const v = g && m && _; const y = o.reason ?? (!m ? "missing requirements" : _ ? void 0 : "no events defined"); return { name: e.hook.name, description: e.hook.description, source: e.hook.source, pluginId: e.hook.pluginId, filePath: e.hook.filePath, baseDir: e.hook.baseDir, handlerPath: e.hook.handlerPath, hookKey: r, emoji: u, homepage: d, events: c, unknownEvents: l, always: s, enabledByConfig: g, requirementsSatisfied: m, loadable: v, blockedReason: y, managedByPlugin: a, requirements: f, missing: p, configChecks: h, install: (e.metadata?.install ?? []).map((e, t) => { const n = (e.id ?? `${e.kind}-${t}`).trim(); const r = e.bins ?? []; let i = (e.label ?? "").trim(); if (!i) { if (e.kind === "bundled") i = "Bundled with OpenClaw"; else if (e.kind === "npm" && e.package) i = `Install ${e.package} (npm)`; else if (e.kind === "git" && e.repository) i = `Install from ${e.repository}`; else i = "Run installer"; } return { id: n, kind: e.kind, label: i, bins: r }; }) }; }) }; } //#endregion export { buildWorkspaceHookStatus as t };