openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
55 lines (54 loc) • 1.95 kB
JavaScript
import { c as normalizeOptionalLowercaseString, l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs";
//#region src/plugins/manifest-command-aliases.ts
/** Normalizes manifest-declared CLI command aliases. */
/** Normalizes manifest command alias records, omitting invalid entries. */
function normalizeManifestCommandAliases(e) {
if (!Array.isArray(e)) return;
const t = [];
for (const n of e) {
const e = typeof n === "string" ? { name: n } : n;
if (!isRecord(e)) continue;
const r = normalizeOptionalString(e.name) ?? "";
if (!r) continue;
const i = e.kind === "runtime-slash" ? e.kind : void 0;
const a = normalizeOptionalString(e.cliCommand) ?? "";
t.push({
name: r,
...i ? { kind: i } : {},
...a ? { cliCommand: a } : {}
});
}
return t.length > 0 ? t : void 0;
}
function resolveManifestToolOwnerInRegistry(e) {
const t = normalizeOptionalLowercaseString(e.toolName);
if (!t) return;
for (const n of e.registry.plugins) {
const e = n.contracts?.tools;
if (!e || e.length === 0) continue;
const r = e.find((e) => normalizeOptionalLowercaseString(e) === t);
if (r) return {
toolName: r,
pluginId: n.id
};
}
}
function resolveManifestCommandAliasOwnerInRegistry(e) {
const t = normalizeOptionalLowercaseString(e.command);
if (!t) return;
const n = e.registry.plugins.some((e) => normalizeOptionalLowercaseString(e.id) === t);
for (const r of e.registry.plugins) {
const e = r.commandAliases?.find((e) => normalizeOptionalLowercaseString(e.name) === t);
if (e) {
if (n && normalizeOptionalLowercaseString(r.id) !== t) continue;
return {
...e,
pluginId: r.id,
...r.enabledByDefault === true ? { enabledByDefault: true } : {}
};
}
}
}
//#endregion
export { resolveManifestCommandAliasOwnerInRegistry as n, resolveManifestToolOwnerInRegistry as r, normalizeManifestCommandAliases as t };