openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 1.99 kB
JavaScript
import{f as e,p as t}from"./git-operation.worker-schemas-OtWwONNf.mjs";import{c as n,d as r,r as i,s as a,t as o}from"./git-operation.worker-workspace-manifest-Zk1wvpHZ.mjs";function sameEntry(e,t){if(e===t)return!0;if(!e||!t||e.path!==t.path||e.type!==t.type)return!1;switch(e.type){case`file`:return t.type===`file`&&e.mode===t.mode&&e.size===t.size&&e.sha256===t.sha256;case`symlink`:return t.type===`symlink`&&e.mode===t.mode&&e.target===t.target;default:return!0}}function manifestNodes(r){let i=t(r.entries),o=a(r.buildCacheInputs),s=/* @__PURE__ */ new Map;for(let t of r.directories??[])n(t,o.has(t)||e(t,i),r.buildCacheInputs!==void 0)||s.set(t,{path:t,type:`directory`});for(let t of r.entries)n(t.path,o.has(t.path)||e(t.path,i),r.buildCacheInputs!==void 0)||s.set(t.path,t);return s}function hasPathAncestor(e,t){for(let n of r(t))if(e.has(n))return!0;return!1}function diffNodePaths(e,t){let n=/* @__PURE__ */ new Set;for(let r of e.values())sameEntry(r,t.get(r.path))||n.add(r.path);for(let r of t.keys())e.has(r)||n.add(r);return n}function parseChangedWorkspaceResult(e,t,n=!0){let r=manifestNodes(e),a=0,s=[],c=[];for(let e of manifestNodes(t).values()){let t=r.get(e.path);sameEntry(t,e)||(a+=t?2:1,e.type!==`directory`&&(s.push(e),!t&&e.type===`file`&&e.size>0&&c.push(e))),r.delete(e.path)}if(a+=r.size,n&&a>o)throw Error(`Cloud workspace reconciliation exceeds the ${o} entry limit`);let l=0;for(let e of s){if(e.type===`file`&&e.size>67108864)throw Error(`Cloud workspace result is too large: `+e.path);l+=e.type===`file`?e.size:Buffer.byteLength(e.target)}if(l>805306368){let e=c.toSorted((e,t)=>t.size-e.size).slice(0,5);throw Error(`Cloud workspace staged result exceeds its byte limit: `+l+` bytes across `+s.length+` changed files/symlinks; `+i+` byte limit.
Largest new files: `+JSON.stringify(e.map(e=>e.path)))}return{changed:a>0,entries:s}}export{sameEntry as a,parseChangedWorkspaceResult as i,hasPathAncestor as n,manifestNodes as r,diffNodePaths as t};