UNPKG

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.

6 lines (5 loc) 777 B
#!/usr/bin/env node import e from"node:process";import{WebSocket as u}from"ws";function d(){const n=e.argv.slice(2);for(let s=0;s<n.length;s++)if(n[s]==="--ws-url"&&n[s+1])return n[s+1];const o=e.env.GRIX_CONNECTOR_MCP_BRIDGE_WS;if(o)return o;e.stderr.write(`FATAL: --ws-url required `),e.exit(1)}const m=d();let t=null,i=!1;const l=[];function f(){t=new u(m),t.on("open",()=>{for(i=!0;l.length>0;){const n=l.shift();t.send(n)}}),t.on("message",n=>{const o=n.toString("utf8");e.stdout.write(`${o} `)}),t.on("close",()=>{i=!1,t=null,setTimeout(f,500)}),t.on("error",()=>{})}f();let c="";e.stdin.setEncoding("utf8"),e.stdin.on("data",n=>{c+=n;const o=c.split(` `);c=o.pop()??"";for(const s of o){const r=s.trim();r&&(i&&t?t.send(r):l.push(r))}}),e.stdin.on("end",()=>e.exit(0));