@messenger-agent/client 0.32.0 → 0.32.1-alpha.0
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.
- package/dist/service.js +3 -3
- package/package.json +5 -5
package/dist/service.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{access as f,chmod as u,mkdir as d,unlink as m,writeFile as g}from"node:fs/promises";import{userInfo as h}from"node:os";import{dirname as w,join as i}from"node:path";import{runCommand as a}from"./exec.js";const n="coding-agent-client",
|
|
2
|
-
`)}function p(e){return e.replaceAll("\\","\\\\").replaceAll(" ","\\x20")}function v(e,t){return`${e}=${t.replaceAll("\\","\\\\").replaceAll('"','\\"')}`}function
|
|
3
|
-
`)}async function c(e){const t=(process.env.PATH??"").split(":").filter(Boolean);for(const r of t)try{return await f(i(r,e)),!0}catch{}return!1}const
|
|
1
|
+
import{access as f,chmod as u,mkdir as d,unlink as m,writeFile as g}from"node:fs/promises";import{userInfo as h}from"node:os";import{dirname as w,join as i}from"node:path";import{runCommand as a}from"./exec.js";const n="coding-agent-client",s="vip.elevo.coding-agent.client";function T(e){return`'${e.replaceAll("'","'\\''")}'`}function $(e){return["[Unit]","Description=Coding Agent Client","After=network-online.target","","[Service]","Type=simple",`ExecStart=${p(e.serviceCommandPath)}`,"Restart=always","RestartSec=5",`WorkingDirectory=${p(e.workspacePath)}`,`Environment=${v("AGENT_CONFIG_PATH",e.configPath)}`,"","[Install]","WantedBy=default.target",""].join(`
|
|
2
|
+
`)}function p(e){return e.replaceAll("\\","\\\\").replaceAll(" ","\\x20")}function v(e,t){return`${e}=${t.replaceAll("\\","\\\\").replaceAll('"','\\"')}`}function o(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function E(e){const t=i(e.dataDir,"logs","client-service.out.log"),r=i(e.dataDir,"logs","client-service.err.log");return['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">','<plist version="1.0">',"<dict>"," <key>Label</key>",` <string>${o(s)}</string>`," <key>ProgramArguments</key>"," <array>",` <string>${o(e.serviceCommandPath)}</string>`," </array>"," <key>WorkingDirectory</key>",` <string>${o(e.workspacePath)}</string>`," <key>EnvironmentVariables</key>"," <dict>"," <key>AGENT_CONFIG_PATH</key>",` <string>${o(e.configPath)}</string>`," </dict>"," <key>RunAtLoad</key>"," <true/>"," <key>KeepAlive</key>"," <true/>"," <key>StandardOutPath</key>",` <string>${o(t)}</string>`," <key>StandardErrorPath</key>",` <string>${o(r)}</string>`,"</dict>","</plist>",""].join(`
|
|
3
|
+
`)}async function c(e){const t=(process.env.PATH??"").split(":").filter(Boolean);for(const r of t)try{return await f(i(r,e)),!0}catch{}return!1}const k={commandExists:c,runCommand:a};async function b(e,t=k){if(!await t.commandExists("loginctl"))throw new Error(`loginctl is required to keep the user service running after logout. Enable linger for ${e} and retry installation.`);if(await y(e,t.runCommand))return;if(console.log(`Enabling login persistence for ${e}`),(await t.runCommand("loginctl",["enable-linger",e],{allowFailure:!0,interactive:!0})).status!==0)throw new Error(`Unable to enable login persistence for ${e}. Run 'sudo loginctl enable-linger ${e}' and retry installation.`);if(!await y(e,t.runCommand))throw new Error(`Login persistence is still disabled for ${e}. Run 'sudo loginctl enable-linger ${e}' and retry installation.`)}async function y(e,t){const r=await t("loginctl",["show-user",e,"-p","Linger"],{allowFailure:!0});return r.status===0&&r.stdout.trim()==="Linger=yes"}async function F(e){const t=e.platform??process.platform;if(t==="linux")return A(e);if(t==="darwin")return L(e);throw new Error("Only Linux and macOS are supported")}async function A(e){if(!await c("systemctl"))throw new Error("systemctl is required to install the user service");const t=e.user??process.env.USER??h().username;await b(t);const r=i(process.env.HOME??"",".config","systemd","user",`${n}.service`);return await d(w(r),{recursive:!0,mode:448}),await g(r,$(e),{mode:384}),await u(r,384),await a("systemctl",["--user","daemon-reload"]),await a("systemctl",["--user","enable","--now",`${n}.service`]),await a("systemctl",["--user","restart",`${n}.service`]),{servicePath:r,commands:P(),warnings:[]}}async function L(e){if(!await c("launchctl"))throw new Error("launchctl is required to install the LaunchAgent");const t=i(process.env.HOME??"","Library","LaunchAgents",`${s}.plist`);await d(w(t),{recursive:!0,mode:448}),await g(t,E(e),{mode:384}),await u(t,384);const r=e.uid??process.getuid?.();if(r===void 0)throw new Error("Unable to determine current uid for launchctl");const l=`gui/${r}`;return await a("launchctl",["bootout",l,t],{allowFailure:!0}),await a("launchctl",["bootstrap",l,t]),await a("launchctl",["kickstart","-k",`${l}/${s}`]),{servicePath:t,commands:x(),warnings:[]}}function P(){return{status:`systemctl --user status ${n}.service`,logs:`journalctl --user -u ${n}.service -n 100 -f`,start:`systemctl --user start ${n}.service`,restart:`systemctl --user restart ${n}.service`,stop:`systemctl --user stop ${n}.service`,uninstall:`systemctl --user disable --now ${n}.service && rm -f ~/.config/systemd/user/${n}.service && systemctl --user daemon-reload`}}function x(){const e="gui/$(id -u)",t=`~/Library/LaunchAgents/${s}.plist`;return{status:`launchctl print ${e}/${s}`,logs:"tail -f ~/.coding-agent/data/logs/client-service.out.log ~/.coding-agent/data/logs/client-service.err.log",start:`launchctl bootstrap ${e} ${t}`,restart:`launchctl kickstart -k ${e}/${s} 2>/dev/null || launchctl bootstrap ${e} ${t}`,stop:`launchctl bootout ${e} ${t}`,uninstall:`launchctl bootout ${e} ${t}; rm -f ${t}`}}async function N(e=process.platform){if(e==="linux"){await a("systemctl",["--user","disable","--now",`${n}.service`],{allowFailure:!0}),await m(i(process.env.HOME??"",".config","systemd","user",`${n}.service`)).catch(t=>{if(t.code!=="ENOENT")throw t}),await a("systemctl",["--user","daemon-reload"],{allowFailure:!0});return}if(e==="darwin"){const t=process.getuid?.();if(t===void 0)throw new Error("Unable to determine current uid for launchctl");const r=i(process.env.HOME??"","Library","LaunchAgents",`${s}.plist`);await a("launchctl",["bootout",`gui/${t}`,r],{allowFailure:!0}),await m(r).catch(l=>{if(l.code!=="ENOENT")throw l});return}throw new Error("Only Linux and macOS are supported")}export{E as createLaunchdPlist,$ as createSystemdService,x as darwinCommands,b as ensureSystemdUserLinger,F as installService,s as launchdLabel,P as linuxCommands,n as serviceName,T as shellEscape,N as uninstallService};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@messenger-agent/client",
|
|
3
|
-
"version": "0.32.0",
|
|
3
|
+
"version": "0.32.1-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"cac": "^7.0.0",
|
|
22
22
|
"yaml": "^2.9.0",
|
|
23
|
-
"@messenger-agent/claude-agent": "0.32.0",
|
|
24
|
-
"@messenger-agent/
|
|
25
|
-
"@messenger-agent/
|
|
26
|
-
"@messenger-agent/shared": "0.32.0"
|
|
23
|
+
"@messenger-agent/claude-agent": "0.32.1-alpha.0",
|
|
24
|
+
"@messenger-agent/codex-agent": "0.32.1-alpha.0",
|
|
25
|
+
"@messenger-agent/messenger-agent": "0.32.1-alpha.0",
|
|
26
|
+
"@messenger-agent/shared": "0.32.1-alpha.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "rm -rf dist && tsc -p tsconfig.json && node ../../scripts/copy-client-assets.mjs && chmod +x dist/index.js",
|