UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

65 lines (64 loc) • 3.4 kB
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; import { i as INCLUDE_KEY } from "./includes-wjVi5Ymt.mjs"; import "./utils-C8YECn2Q.mjs"; import { n as listAgentEntries, t as hasAgentRosterProperty } from "./agent-roster-t1ooUdXp.mjs"; import "./agent-scope-config-DmXgFGKP.mjs"; //#region src/config/agent-roster-provenance.ts function rosterEntryBoundaryContainsInclude(e) { if (!isRecord(e)) return false; if (Object.hasOwn(e, "$include")) return true; return [e.id, e.default].some((e) => isRecord(e) && Object.hasOwn(e, "$include")); } function authoredRosterBoundaryContainsInclude(e) { if (isRecord(e) && Object.hasOwn(e, "$include")) return true; if (Array.isArray(e)) return e.some(rosterEntryBoundaryContainsInclude); if (!isRecord(e)) return false; return Object.values(e).some(rosterEntryBoundaryContainsInclude); } function readRosterValue(e) { if (!isRecord(e) || !isRecord(e.agents)) return; if (Object.hasOwn(e.agents, "entries")) return e.agents.entries; return Object.hasOwn(e.agents, "list") ? e.agents.list : void 0; } /** * Roster include ownership decision table: * - Include-owned: an include contributes membership or default metadata at agents.entries/list, * an entry object, an id/default field, a nested entries/list $include, or an ambiguous * byte-identical roster contribution. * - Locally owned: ancestor includes contribute only unrelated config, or an include is nested * inside entry-internal identity/model/etc. fields that cannot change membership or default; * canonical roster writes preserve those entry-internal authored include nodes in place. */ function includeContributionOwnsAgentRoster(e) { if (e.path.length === 0) return hasAgentRosterProperty(e.value); if (e.path.length === 1 && e.path[0] === "agents") return isRecord(e.value) && (Object.hasOwn(e.value, "entries") || Object.hasOwn(e.value, "list")); if (e.path[0] !== "agents") return false; if (e.path[1] === "entries") return e.path.length <= 3 || e.path[3] === "default"; if (e.path[1] === "list") return e.path.length <= 3 || e.path[3] === "id" || e.path[3] === "default"; return false; } function includeContributionOwnsBindings(e) { if (e.path.length === 0) return isRecord(e.value) && Object.hasOwn(e.value, "bindings"); return e.path[0] === "bindings"; } /** Whether include/env resolution produced a non-empty roster before raw migrations. */ function hasResolvedRosterBeforeMigrations(e) { return listAgentEntries(e.sourceConfigBeforeMigrations ?? {}).length > 0; } /** Whether an include, rather than the authored root, owns agents.entries. */ function configIncludeOwnsAgentRosterValues(e) { const t = e.sourceConfigBeforeMigrations; if (!hasAgentRosterProperty(t)) return false; if (authoredRosterBoundaryContainsInclude(readRosterValue(e.parsed))) return true; return e.includeContributesRoster === true; } /** Whether an include, rather than the authored root, owns agents.entries. */ function configIncludeOwnsAgentRoster(e) { return configIncludeOwnsAgentRosterValues({ parsed: e.parsed, sourceConfigBeforeMigrations: e.sourceConfigBeforeMigrations, includeContributesRoster: e.agentRosterIncludeOwned }); } //#endregion export { includeContributionOwnsBindings as a, includeContributionOwnsAgentRoster as i, configIncludeOwnsAgentRosterValues as n, hasResolvedRosterBeforeMigrations as r, configIncludeOwnsAgentRoster as t };