openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
41 lines (40 loc) • 2.54 kB
JavaScript
import { r as isPathInside } from "./path-guards-Cp-mGr3-.js";
import { n as normalizeAgentId } from "./agent-id-CeT3w4ap.js";
import { i as listAgentEntries, m as resolveAgentWorkspaceDir } from "./agent-scope-config-DcbEhP0R.js";
import "./session-key-BnWWjqNc.js";
import "./agent-scope-DbtJyKUL.js";
import { n as resolveCanonicalWorkspacePath } from "./workspace-state-identity-UVKTnO1Z.js";
import { o as resolveSharedAuthStoreOwnership } from "./path-resolve-oRkRBkQd.js";
import { u as isSameOpenClawAgentDatabasePath } from "./openclaw-agent-db-maintenance-wTIy-jt-.js";
import { i as resolveLegacyInheritedAuthAgentId } from "./legacy-inherited-auth-dir-CMGSmv-F.js";
//#region src/agents/agent-delete-safety.ts
/** True when deleting this agent database would remove the legacy shared auth store. */
function isSharedAuthStoreOwner(params) {
return params.ownership.location === "legacy-main" && isSameOpenClawAgentDatabasePath(params.agentAuthDbPath, params.sharedAuthDbPath);
}
function formatSharedAuthStoreOwnerDeleteError(agentId) {
return `Agent "${agentId}" owns the legacy shared auth store and cannot be deleted. Run openclaw doctor --fix to migrate shared auth, then retry.`;
}
function isInheritedAuthStoreOwner(cfg, agentId) {
if (!cfg.agents?.defaults?.authInheritance?.agentId?.trim() && resolveSharedAuthStoreOwnership().location !== "legacy-main") return false;
return agentId === normalizeAgentId(resolveLegacyInheritedAuthAgentId(cfg));
}
function workspacePathsOverlap(left, right) {
const normalizedLeft = resolveCanonicalWorkspacePath(left.replaceAll("\0", ""));
const normalizedRight = resolveCanonicalWorkspacePath(right.replaceAll("\0", ""));
return isPathInside(normalizedRight, normalizedLeft) || isPathInside(normalizedLeft, normalizedRight);
}
/** Lists other agents whose workspaces overlap a candidate delete target. */
function findOverlappingWorkspaceAgentIds(cfg, agentId, workspaceDir, env) {
const entries = listAgentEntries(cfg);
const normalizedAgentId = normalizeAgentId(agentId);
const overlappingAgentIds = [];
for (const entry of entries) {
const otherAgentId = normalizeAgentId(entry.id);
if (otherAgentId === normalizedAgentId) continue;
if (workspacePathsOverlap(workspaceDir, resolveAgentWorkspaceDir(cfg, otherAgentId, env))) overlappingAgentIds.push(otherAgentId);
}
return overlappingAgentIds;
}
//#endregion
export { isSharedAuthStoreOwner as i, formatSharedAuthStoreOwnerDeleteError as n, isInheritedAuthStoreOwner as r, findOverlappingWorkspaceAgentIds as t };