UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.54 kB
import{M as e}from"./git-operation.worker-subsystem-DibpW_lB.mjs";import{n as t}from"./git-operation.worker-record-coerce-B9rMjEA7.mjs";import{i as n}from"./git-operation.worker-windows-encoding-MXq-JVgK.mjs";import"./git-operation.worker.js";import{c as r}from"./git-operation.worker-git-C2q2uQ5t.mjs";import{c as i,i as a,r as o,s}from"./git-operation.worker-schemas-OtWwONNf.mjs";import"node:crypto";import"node:os";e(Symbol.for(`openclaw.workspaceStagedManifestReads`));const c=6e5;async function readWorkspaceResultGit(e,t,i,a=`git ${t[0]} failed`){let o=await n(`workspace.result`,()=>r(e,t,{timeoutMs:c,...i}),`default`);if(o.termination!==`exit`||o.code!==0)throw Error(o.stderr.toString(`utf8`).trim()||a);return o.stdout}((e,t=256)=>a(e=>typeof e==`string`&&e.length>0&&e.length<=t&&e.trim()===e&&!e.includes(`\0`),{error:`INVALID_REQUEST: ${e} must be a bounded non-empty identifier`}))(`gatewayNamespace`).refine(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u.test(e),{error:`INVALID_REQUEST: gatewayNamespace must be a safe bounded path component`});function hasExactOwnKeys(e,t,n=[]){return t.every(t=>Object.hasOwn(e,t))&&n.every(t=>Object.hasOwn(e,t)||!Reflect.has(e,t))&&Object.keys(e).every(e=>t.includes(e)||n.includes(e))}function workerProtocolObject(e){let n=[],r=[];for(let[t,i]of Object.entries(e))(i.isOptional()?r:n).push(t);return a(e=>t(e)&&hasExactOwnKeys(e,n,r)).pipe(s(e))}const l=workerProtocolObject({baseCommit:i().regex(/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u),headCommit:i().regex(/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u),descendsFromBase:o(),unavailableReason:i().max(512).optional()}),u=`OpenClaw worker workspace result`,d=/^refs\/openclaw\/workspace-base-refresh\/[a-f0-9]{64}$/u;function isLocalWorkspaceBaseRefreshRef(e){return e!==null&&d.test(e)}function requireWorkerResultStorageRef(e){if(!(/* @__PURE__ */ RegExp(`^(?:refs/openclaw/worker-results|refs/openclaw/worker-result-candidates|refs/openclaw/worker-result-cleanup)/[A-Za-z0-9-]+$`,`u`)).test(e)&&!isLocalWorkspaceBaseRefreshRef(e))throw Error(`Cloud workspace staged result reference is invalid`);return e}const f=8388608;function stagedWorkspaceEntryBytes(e){return e.type===`file`?e.size:Buffer.byteLength(e.target)}function resolveStagedWorkspaceReadEntry(e,t){let n=e.get(t.path);if(!n)throw Error(`Cloud workspace result has no payload for ${t.path}`);return{object:n,entry:t}}export{resolveStagedWorkspaceReadEntry as a,readWorkspaceResultGit as c,requireWorkerResultStorageRef as i,f as n,stagedWorkspaceEntryBytes as o,l as r,c as s,u as t};