shellway 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/shellway.js +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shellway",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Shellway agent: lets ChatGPT, Claude and Cursor work on this computer through the Shellway relay.",
5
5
  "type": "module",
6
6
  "bin": { "shellway": "./shellway.js" },
package/shellway.js CHANGED
@@ -22,7 +22,7 @@ const has = (n) => args.includes(`--${n}`);
22
22
  const cmd = args[0];
23
23
 
24
24
  function loadConf() {
25
- if (!existsSync(CONF)) { console.error('Not paired yet. Run: shellway pair <CODE> --server <URL>'); process.exit(1); }
25
+ if (!existsSync(CONF)) { console.error('Not paired yet. Run: shellway pair <CODE> --server <URL>'); process.exit(78); }
26
26
  return JSON.parse(readFileSync(CONF, 'utf8'));
27
27
  }
28
28
 
@@ -99,7 +99,7 @@ function start() {
99
99
  const wsUrl = conf.server.replace(/^http/, 'ws') + '/agent';
100
100
  let delay = 1000;
101
101
  const connect = async () => {
102
- if (!(await tokenValid(conf))) { console.error('This device was removed or its token is invalid. Pair again.'); process.exit(1); }
102
+ if (!(await tokenValid(conf))) { console.error('This device was removed or its token is invalid. Pair again.'); process.exit(78); }
103
103
  const ws = new WebSocket(wsUrl, { headers: { authorization: `Bearer ${conf.device_token}` } });
104
104
  ws.onopen = () => { delay = 1000; console.log(`Connected as "${conf.device_name}"${readonly ? ' (read-only)' : ''}. Leave this running.`); };
105
105
  ws.onmessage = async (ev) => {
@@ -132,8 +132,8 @@ const run = (c, a, opts = {}) => execFileSync(c, a, { stdio: opts.quiet ? 'pipe'
132
132
 
133
133
  function renderService(os, argv) {
134
134
  const home = process.env.SHELLWAY_HOME ? `Environment=SHELLWAY_HOME=${process.env.SHELLWAY_HOME}\n` : '';
135
- if (os === 'linux') return `[Unit]\nDescription=Shellway agent\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\n${home}ExecStart=${argv.map((a) => (/\s/.test(a) ? `"${a}"` : a)).join(' ')}\nRestart=always\nRestartSec=5\n\n[Install]\nWantedBy=default.target\n`;
136
- if (os === 'darwin') return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0"><dict>\n<key>Label</key><string>com.getshellway.agent</string>\n<key>ProgramArguments</key><array>${argv.map((a) => `<string>${xml(a)}</string>`).join('')}</array>\n${process.env.SHELLWAY_HOME ? `<key>EnvironmentVariables</key><dict><key>SHELLWAY_HOME</key><string>${xml(process.env.SHELLWAY_HOME)}</string></dict>\n` : ''}<key>RunAtLoad</key><true/>\n<key>KeepAlive</key><true/>\n<key>StandardOutPath</key><string>${xml(join(CONF_DIR, 'agent.log'))}</string>\n<key>StandardErrorPath</key><string>${xml(join(CONF_DIR, 'agent.log'))}</string>\n</dict></plist>\n`;
135
+ if (os === 'linux') return `[Unit]\nDescription=Shellway agent\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\n${home}ExecStart=${argv.map((a) => (/\s/.test(a) ? `"${a}"` : a)).join(' ')}\nRestart=always\nRestartSec=5\nRestartPreventExitStatus=78\n\n[Install]\nWantedBy=default.target\n`;
136
+ if (os === 'darwin') return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0"><dict>\n<key>Label</key><string>com.getshellway.agent</string>\n<key>ProgramArguments</key><array>${argv.map((a) => `<string>${xml(a)}</string>`).join('')}</array>\n${process.env.SHELLWAY_HOME ? `<key>EnvironmentVariables</key><dict><key>SHELLWAY_HOME</key><string>${xml(process.env.SHELLWAY_HOME)}</string></dict>\n` : ''}<key>RunAtLoad</key><true/>\n<key>KeepAlive</key><true/>\n<key>ThrottleInterval</key><integer>30</integer>\n<key>StandardOutPath</key><string>${xml(join(CONF_DIR, 'agent.log'))}</string>\n<key>StandardErrorPath</key><string>${xml(join(CONF_DIR, 'agent.log'))}</string>\n</dict></plist>\n`;
137
137
  return null;
138
138
  }
139
139