grix-connector
Version:
Connect local AI coding agents (Claude, Codex, Gemini, Qwen, DeepSeek, Cursor, OpenCode, Pi, OpenHuman, Reasonix) to the Grix scheduling platform. Also serves as an OpenClaw plugin for Grix channel transport.
3 lines (2 loc) • 992 B
JavaScript
import{execFile as l}from"node:child_process";import{promisify as u}from"node:util";const m=3e3;async function p(i){const o=u(l),s=process.platform==="win32"?"where":"which";try{const{stdout:c}=await o(s,[i],{timeout:3e3,encoding:"utf-8"}),r=c.trim().split(/\r?\n/).map(t=>t.trim()).filter(Boolean);if(r.length===0)return null;if(process.platform==="win32"){const t=r.find(n=>/\.(cmd|bat)$/i.test(n));if(t)return t;const e=r.find(n=>/\.exe$/i.test(n));if(e)return e}return r[0]}catch{return null}}async function h(i,o=["--version"],s=m){const c=u(l),r=process.platform==="win32";try{const{stdout:t,stderr:e}=await c(i,o,{timeout:s,encoding:"utf-8",...r?{shell:!0}:{}});return{version:(t||e||"").trim().split(`
`)[0]?.trim()||null||null}}catch(t){const e=t;return e.killed||e.code==="ETIMEDOUT"?{version:null,error:{code:"version_timeout",message:"version check timed out"}}:{version:null,error:{code:"cli_error",message:e.message??String(t)}}}}export{h as getCliVersion,p as resolveCliPath};