UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.03 kB
import{C as e}from"./transcript-plugin-instance-invocation-7y9lfaeO.mjs";import{t}from"./transcript-state-dir-DEo0wD2Q.mjs";import n from"node:path";const r=`/tmp/openclaw`;let i;function loadResolveSecureTempRoot(){if(i)return i;let t=e();if(t)return i=t,t;if(typeof SEALED_RUNTIME_BUILD==`boolean`&&SEALED_RUNTIME_BUILD)throw Error(`sealed temp-root runtime was not registered before use`);if(typeof process.getBuiltinModule!=`function`)throw Error(`Node module loading is unavailable for secure temp-root resolution`);return i=process.getBuiltinModule(`module`).createRequire(import.meta.url)(`@openclaw/fs-safe/secure-temp-root`).resolveSecureTempRoot,i}function assertSafeTempAncestors(e,t){let r=t.platform??process.platform;if(r===`win32`||r===`android`)return;let i=process.getBuiltinModule(`fs`),a=t.lstatSync??i.lstatSync,o=t.lstatSync?n.resolve(e):i.realpathSync.native(e);for(let e=n.dirname(o);;e=n.dirname(e)){let t=a(e);if(t.mode!==void 0&&t.mode&18&&!(t.mode&512)){let t=`'${e.replaceAll(`'`,`'\\''`)}'`;throw Error(`Temp workspace ancestor ${JSON.stringify(e)} is group/world writable without sticky protection; have its owner run chmod +t ${t} for a shared temp directory or chmod go-w ${t} for a private ancestor.`)}if(n.dirname(e)===e)return}}function resolvePreferredOpenClawTmpDir(e={}){let r=loadResolveSecureTempRoot(),i={...e,preferredDir:e.preferredDir??`/tmp/openclaw`,fallbackPrefix:`openclaw`,warningPrefix:`[openclaw]`,unsafeFallbackLabel:`OpenClaw temp dir`,skipPreferredOnWindows:!0},a=r(i);if(e.purpose===`coordination`)return a;let o;try{return assertSafeTempAncestors(a,e),a}catch(e){o=e}let s=t();try{let t=r({...i,preferredDir:void 0,tmpdir:()=>n.join(s,`tmp`)});return assertSafeTempAncestors(t,e),(e.warn??console.warn)(`[openclaw] ${String(o)} Using private state temp dir: ${t}`),t}catch(e){throw Error(`No safe OpenClaw temp root is available. Default root: ${String(o)} State fallback ${JSON.stringify(s)}: ${String(e)}`,{cause:e})}}export{resolvePreferredOpenClawTmpDir as n,r as t};