openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
38 lines (37 loc) • 1.78 kB
JavaScript
import { v as requireActivePluginRegistry } from "./runtime-ezCEpumg.mjs";
import { n as normalizeAgentPromptSurfaceKind } from "./agent-prompt-surface-kind-Pc74Jn6j.mjs";
import { t as listRegisteredPluginCommands } from "./plugin-command-registry-Djk4s-ty.mjs";
//#region src/plugins/command-registry-state.ts
function clearPluginCommands() {
requireActivePluginRegistry().commands.length = 0;
}
function isTrustedReservedCommandOwner(e) {
return e.ownership === "reserved";
}
function canExposeSenderIsOwner(e) {
return Array.isArray(e.requiredScopes) && e.requiredScopes.length > 0 || e.trustedOwnerStatusExposure === true;
}
function listRegisteredPluginAgentPromptGuidance(e) {
const t = /* @__PURE__ */ new Set();
const n = listRegisteredPluginCommands(requireActivePluginRegistry()).toSorted((e, t) => {
if (e.pluginId !== t.pluginId) return e.pluginId < t.pluginId ? -1 : 1;
return e.name < t.name ? -1 : e.name > t.name ? 1 : 0;
});
for (const r of n) for (const n of r.agentPromptGuidance ?? []) {
const r = resolveAgentPromptGuidanceTextForSurface(n, {
surface: e?.surface ? normalizeAgentPromptSurfaceKind(e.surface) : void 0,
includeLegacyGlobalGuidance: e?.includeLegacyGlobalGuidance ?? true
});
if (r) t.add(r);
}
return [...t];
}
function resolveAgentPromptGuidanceTextForSurface(e, t) {
if (typeof e === "string") return t.includeLegacyGlobalGuidance ? e.trim() : void 0;
const n = e.text.trim();
if (!t.surface) return n;
if (!e.surfaces || e.surfaces.length === 0) return t.includeLegacyGlobalGuidance ? n : void 0;
return e.surfaces.includes(t.surface) ? n : void 0;
}
//#endregion
export { listRegisteredPluginAgentPromptGuidance as i, clearPluginCommands as n, isTrustedReservedCommandOwner as r, canExposeSenderIsOwner as t };