openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.76 kB
JavaScript
import{dn as e}from"./openclaw-state-read-subsystem-Dwoo5bcz.mjs";import t from"node:fs";import n from"node:path";import{createHash as r}from"node:crypto";function normalizeWorkspaceIdentityPath(e){let t=n.normalize(e).normalize(`NFC`);return process.platform===`win32`?t.toLowerCase():t}function canonicalizeWorkspacePath(r,i){let a=n.resolve(e(r)),o=i(a),s=/* @__PURE__ */ new Set;for(let e=0;e<40;e+=1){let e=[],r=a;for(;;){try{return i(n.join(t.realpathSync.native(r),...e.toReversed()))}catch{}try{if(t.lstatSync(r).isSymbolicLink()){let i=n.normalize(r);if(s.has(i))return o;s.add(i),a=n.resolve(n.dirname(r),t.readlinkSync(r),...e.toReversed());break}}catch{}let c=n.dirname(r);if(c===r)return o;e.push(n.basename(r)),r=c}}return o}function createWorkspaceStateIdentity(e){return{workspacePath:e,workspaceKey:r(`sha256`).update(e).digest(`hex`)}}function resolveWorkspaceStateAliases(t){let r=normalizeWorkspaceIdentityPath(n.resolve(e(t))),i=canonicalizeWorkspacePath(t,normalizeWorkspaceIdentityPath);return[.../* @__PURE__ */ new Set([r,i])].map(createWorkspaceStateIdentity)}var WorkspaceAliasRepointedError=class extends Error{constructor(e){super(`workspace path alias points to a different current target: ${e.aliasPath} now resolves to ${e.currentWorkspacePath}, but its stored workspace state belongs to ${e.storedWorkspacePath}. Run \`openclaw doctor --fix\` and confirm the move, or use \`openclaw doctor --fix --force\`.`),this.code=`WORKSPACE_ALIAS_REPOINTED`,this.name=`WorkspaceAliasRepointedError`,this.aliasPath=e.aliasPath,this.storedWorkspacePath=e.storedWorkspacePath,this.currentWorkspacePath=e.currentWorkspacePath}};export{createWorkspaceStateIdentity as n,resolveWorkspaceStateAliases as r,WorkspaceAliasRepointedError as t};