openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 2.69 kB
JavaScript
import{t as e}from"./transcript-map-size-DkeBKk4z.mjs";import{t}from"./transcript-path-existence-DsAt-_G2.mjs";import{n}from"./transcript-tmp-openclaw-dir-BXMyB42n.mjs";import{r,t as i}from"./transcript-windows-install-roots-D5D0JgeT.mjs";import a from"node:path";import o from"node:fs";import{createRastermill as s}from"rastermill";const c=[`/usr/bin`,`/bin`,`/usr/sbin`,`/sbin`],l=[`/opt/homebrew/bin`,`/usr/local/bin`],u=[`/usr/local/bin`],d=[`.exe`,`.cmd`,`.bat`,`.com`],f=[`ImageMagick-`,`GraphicsMagick-`],p=[`ImageMagick`,`GraphicsMagick`],m=/* @__PURE__ */ new Map,h=/* @__PURE__ */ new Map;function cacheResolvedSystemBin(t,n,r){t.set(n,r),e(t,512)}function collectWindowsProgramFilesToolDirs(e){let t=p.map(t=>a.win32.join(e,t));try{for(let n of o.readdirSync(e,{withFileTypes:!0}))n.isDirectory()&&f.some(e=>n.name.startsWith(e))&&t.push(a.win32.join(e,n.name))}catch{}return t}function buildWindowsTrustedDirs(){let e=[],{systemRoot:t}=i();e.push(a.win32.join(t,`System32`)),e.push(a.win32.join(t,`SysWOW64`)),e.push(a.win32.join(t,`System32`,`WindowsPowerShell`,`v1.0`));for(let t of r())e.push(a.win32.join(t,`OpenSSL-Win64`,`bin`)),e.push(a.win32.join(t,`OpenSSL`,`bin`)),e.push(a.win32.join(t,`ffmpeg`,`bin`));return e}function buildWindowsStandardDirs(){let{systemRoot:e}=i(),t=a.win32.parse(e).root,n=[a.win32.join(t,`ProgramData`,`chocolatey`,`bin`)];for(let e of r())n.push(...collectWindowsProgramFilesToolDirs(e));return n}function buildUnixTrustedDirs(e){let t=[...c],n=process.platform;return n===`linux`&&(t.push(`/run/current-system/sw/bin`),t.push(`/snap/bin`)),e===`standard`&&(n===`darwin`?t.push(...l):n===`linux`&&t.push(...u)),t}const g={};function getTrustedDirs(e){return g[e]??=process.platform===`win32`?e===`strict`?buildWindowsTrustedDirs():[...getTrustedDirs(`strict`),...buildWindowsStandardDirs()]:buildUnixTrustedDirs(e)}function resolveSystemBin(e,n){let r=n?.trust??`strict`,i=(n?.extraDirs?.length??0)>0,s=r===`standard`?h:m;if(!i){let t=s.get(e);if(t!==void 0)return s.delete(e),s.set(e,t),t}let c=[...getTrustedDirs(r),...n?.extraDirs??[]],l=process.platform===`win32`,u=l&&a.win32.extname(e).length>0;for(let n of c){let r=l&&!u?d.map(t=>a.win32.join(n,e+t)):[a.join(n,e)];for(let n of r)if(t(n,l?o.constants.R_OK:o.constants.X_OK))return i||cacheResolvedSystemBin(s,e,n),n}return null}const _=25e6,v=64e6;function createLocalImageProcessor(e,t={inputPixels:_,outputPixels:_}){return s({execution:e,limits:t,temp:{rootDir:n(),prefix:`openclaw-img-`},commandResolver:e=>resolveSystemBin(e,{trust:e===`powershell`?`strict`:`standard`})})}export{v as MAX_IMAGE_DOWNSCALE_SOURCE_PIXELS,_ as MAX_IMAGE_INPUT_PIXELS,createLocalImageProcessor};