openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 2.25 kB
JavaScript
import{k as e}from"./openclaw-state-read-workspace-path-exclusions-Cjo9Lmns.mjs";import{t}from"./openclaw-state-read-zstd-codec-Bwg8OR0e.mjs";import{u as n}from"./openclaw-state-read-workspace-manifest-B5vKGqPY.mjs";const r=-1n;function filePaths(e){let t=[];for(let{node:n}of e.values())n.type===`file`&&t.push(n.path);return t.sort(),t}function prepareLocalWorkspaceFingerprints(i,a,o,s,c){let sourceDevice=e=>c&&e===c.snapshotDev?c.sourceDev:e,l=o===null||Buffer.isBuffer(o)?o:Buffer.from(o.buffer,o.byteOffset,o.byteLength),u=filePaths(i),d;if(o)try{let e=t().decompress(o,45+n*16);e.length===45+u.length*16&&e.readUInt8(0)===1&&e.subarray(9,41).equals(Buffer.from(a.slice(7),`hex`))&&e.readUInt32LE(41)===u.length&&(d=e)}catch{}let f=/* @__PURE__ */ new Map;for(let e=0;e<u.length;e++)f.set(u[e],45+e*16);let p=d?.readBigUInt64LE(1),m=/* @__PURE__ */ new Map,h=/* @__PURE__ */ new Map,g=d!==void 0,_=0;return{reuseFile(t,n,r){let a=f.get(t),o=i.get(t)?.node;if(!d||a===void 0||o?.type!==`file`)g=!1;else{if(sourceDevice(r.dev)===p&&r.ino===d.readBigUInt64LE(a)&&r.ctimeNs===d.readBigInt64LE(a+8)&&o.size===Number(r.size)&&e(r.ctimeNs,s))return m.set(t,n),o;g=!1}},observe(e,t,n){m.get(e)===t?_++:(g=!1,m.delete(e),h.set(e,{identity:t,reusable:n}))},encode(n,i,o){if(o&&!d)return null;if(i===a&&g&&_===u.length)return l;let c=u;if(i!==a){let e=u.filter(e=>n.get(e)?.node.type===`file`),t=[];for(let{node:e}of n.values())e.type===`file`&&!f.has(e.path)&&t.push(e.path);t.sort(),c=[];let r=0;for(let n of e){for(;r<t.length&&t[r]<n;)c.push(t[r++]);c.push(n)}for(;r<t.length;)c.push(t[r++])}let v=Buffer.alloc(45+c.length*16);v.writeUInt8(1,0),Buffer.from(i.slice(7),`hex`).copy(v,9),v.writeUInt32LE(c.length,41);let y=o?p:void 0;for(let t=0;t<c.length;t++){let n=c[t],i=45+t*16;if(m.has(n)||o&&f.has(n)&&!o.has(n)){let e=f.get(n);if(y??=p,y!==p)return null;d.copy(v,i,e,e+16);continue}let a=h.get(n);if(!a){if(o){v.writeBigInt64LE(r,i+8);continue}return null}let l=a.identity.split(`:`),u=sourceDevice(BigInt(l[1]));if(y??=u,u!==y)return null;let g=BigInt(l[5]);v.writeBigUInt64LE(BigInt(l[2]),i),v.writeBigInt64LE(a.reusable??e(g,s)?g:r,i+8)}return v.writeBigUInt64LE(y??0n,1),t().compress(v)}}}export{prepareLocalWorkspaceFingerprints as t};