borgmcp 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{mkdirSync as w,chmodSync as k,readdirSync as v,rmSync as C,writeFileSync as b,readFileSync as y}from"node:fs";import{homedir as g}from"node:os";import{join as u}from"node:path";import{randomBytes as S}from"node:crypto";import{spawn as A}from"node:child_process";import{CodexAppServerClient as $}from"./codex-app-server.js";const E=u(g(),".config","borgmcp","codex-remote");function F(e,t){return R(e)?e:["--cd",t,...e]}function R(e){return e.some(t=>t==="--cd"||t.startsWith("--cd=")||t==="-C")}function x(e){try{return process.kill(e,0),!0}catch(t){return t?.code==="EPERM"}}function O(e,t={}){if(!e)return null;const c=t.isAlive??x,i=t.readPidFile??(o=>y(o,"utf-8")),a=e.replace(/\.sock$/,".pid");try{const o=Number.parseInt(i(a).trim(),10);return Number.isNaN(o)?null:c(o)}catch{return null}}function s(e){try{C(e,{force:!0})}catch{}}function M(e,t){let c;try{c=v(e)}catch{return}for(const i of c){if(!i.endsWith(".pid"))continue;const a=u(e,i),o=u(e,i.replace(/\.pid$/,".sock"));let r;try{r=Number.parseInt(y(a,"utf-8").trim(),10)}catch{s(a);continue}(Number.isNaN(r)||!t(r))&&(s(o),s(a))}}function p(e){return{args:[],env:{},warning:e}}async function B(e){const t=e.runtimeDir??E,c=e.isAlive??x,i=e.readyTimeoutMs??8e3,a=e.pollIntervalMs??250;try{w(t,{recursive:!0,mode:448}),k(t,448),M(t,c)}catch(n){return p(`Codex remote-wake disabled: could not prepare ${t} (${n?.message??n}); run borg:regen manually.`)}const o=(e.socketId??(()=>S(16).toString("hex")))(),r=u(t,`${o}.sock`),m=u(t,`${o}.pid`);let l;try{l=e.spawnAppServer(r)}catch(n){return s(r),p(`Codex remote-wake disabled: could not start \`codex app-server\` (${n?.message??n}) \u2014 is Codex installed + up to date? This session only wakes on the ~30min /loop fallback; run borg:regen manually.`)}if(l.pid!=null)try{b(m,String(l.pid))}catch{}const f=()=>{try{l.kill()}catch{}s(r),s(m)},h=Math.max(1,Math.ceil(i/a));let d=!1;for(let n=0;n<h&&!d;n++){try{d=await e.probeReady(r)}catch{d=!1}!d&&n<h-1&&await e.sleep(a)}return d?{args:["--remote",`unix://${r}`],env:{BORG_CODEX_REMOTE_WAKE:"1"},server:{pid:l.pid,socketPath:r,cleanup:f}}:(f(),p(`Codex remote-wake disabled: could not reach a Codex app-server at ${r} within ${i}ms (is Codex up to date? \`codex app-server --listen\` is required). This session only wakes on the ~30min /loop fallback \u2014 run borg:regen manually when you return.`))}function L(){return{spawnAppServer:e=>{const t=A("codex",["app-server","--listen",`unix://${e}`],{stdio:"ignore",shell:!1});return{pid:t.pid,kill:()=>{try{t.kill()}catch{}}}},probeReady:async e=>{const t=new $(e);try{return await t.connect(),await t.loadedThreadIds(),!0}catch{return!1}finally{try{t.close()}catch{}}},sleep:e=>new Promise(t=>setTimeout(t,e))}}export{E as DEFAULT_CODEX_REMOTE_DIR,O as checkCodexBridgeHealthy,L as defaultCodexRemoteDeps,x as defaultIsAlive,B as prepareCodexRemoteLaunch,F as withCodexCwdArg};
1
+ import{mkdirSync as w,chmodSync as v,readdirSync as k,rmSync as C,writeFileSync as g,readFileSync as y}from"node:fs";import{homedir as S}from"node:os";import{join as u}from"node:path";import{randomBytes as b}from"node:crypto";import{spawn as A}from"node:child_process";import{CodexAppServerClient as E}from"./codex-app-server.js";import{codexBorgSessionConfigArgs as R,BORG_SESSION_ENV as $}from"./launch-gate.js";const N=u(S(),".config","borgmcp","codex-remote");function L(e,r){return I(e)?e:["--cd",r,...e]}function I(e){return e.some(r=>r==="--cd"||r.startsWith("--cd=")||r==="-C")}function x(e){try{return process.kill(e,0),!0}catch(r){return r?.code==="EPERM"}}function W(e,r={}){if(!e)return null;const a=r.isAlive??x,i=r.readPidFile??(o=>y(o,"utf-8")),c=e.replace(/\.sock$/,".pid");try{const o=Number.parseInt(i(c).trim(),10);return Number.isNaN(o)?null:a(o)}catch{return null}}function s(e){try{C(e,{force:!0})}catch{}}function M(e,r){let a;try{a=k(e)}catch{return}for(const i of a){if(!i.endsWith(".pid"))continue;const c=u(e,i),o=u(e,i.replace(/\.pid$/,".sock"));let t;try{t=Number.parseInt(y(c,"utf-8").trim(),10)}catch{s(c);continue}(Number.isNaN(t)||!r(t))&&(s(o),s(c))}}function p(e){return{args:[],env:{},warning:e}}async function G(e){const r=e.runtimeDir??N,a=e.isAlive??x,i=e.readyTimeoutMs??8e3,c=e.pollIntervalMs??250;try{w(r,{recursive:!0,mode:448}),v(r,448),M(r,a)}catch(n){return p(`Codex remote-wake disabled: could not prepare ${r} (${n?.message??n}); run borg:regen manually.`)}const o=(e.socketId??(()=>b(16).toString("hex")))(),t=u(r,`${o}.sock`),m=u(r,`${o}.pid`);let l;try{l=e.spawnAppServer(t)}catch(n){return s(t),p(`Codex remote-wake disabled: could not start \`codex app-server\` (${n?.message??n}) \u2014 is Codex installed + up to date? This session only wakes on the ~30min /loop fallback; run borg:regen manually.`)}if(l.pid!=null)try{g(m,String(l.pid))}catch{}const f=()=>{try{l.kill()}catch{}s(t),s(m)},h=Math.max(1,Math.ceil(i/c));let d=!1;for(let n=0;n<h&&!d;n++){try{d=await e.probeReady(t)}catch{d=!1}!d&&n<h-1&&await e.sleep(c)}return d?{args:["--remote",`unix://${t}`],env:{BORG_CODEX_REMOTE_WAKE:"1"},server:{pid:l.pid,socketPath:t,cleanup:f}}:(f(),p(`Codex remote-wake disabled: could not reach a Codex app-server at ${t} within ${i}ms (is Codex up to date? \`codex app-server --listen\` is required). This session only wakes on the ~30min /loop fallback \u2014 run borg:regen manually when you return.`))}function X(){return{spawnAppServer:e=>{const r=A("codex",["app-server",...R(),"--listen",`unix://${e}`],{stdio:"ignore",shell:!1,env:{...process.env,[$]:"1"}});return{pid:r.pid,kill:()=>{try{r.kill()}catch{}}}},probeReady:async e=>{const r=new E(e);try{return await r.connect(),await r.loadedThreadIds(),!0}catch{return!1}finally{try{r.close()}catch{}}},sleep:e=>new Promise(r=>setTimeout(r,e))}}export{N as DEFAULT_CODEX_REMOTE_DIR,W as checkCodexBridgeHealthy,X as defaultCodexRemoteDeps,x as defaultIsAlive,G as prepareCodexRemoteLaunch,L as withCodexCwdArg};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "borgmcp",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Coordinate AI coding agents in shared cubes. Works with Claude Code and Codex. Create projects, assign roles, and share a live activity log.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",