shellway 0.8.1 → 0.8.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Shellway",
4
- "version": "0.8.1",
4
+ "version": "0.8.2",
5
5
  "description": "Lets your AI (ChatGPT, Claude) use this browser through the Shellway app on your computer. Off until you turn it on.",
6
6
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnZWALJr6dwkQu7eX3reFbtgMAErsCyODHKnwz97XMKpR9bAz4+irBlJ2KEXD6ERZFjuKYqNZ2HLe0eQp5y9fWscyWeTUXNTstsFaymsb5C0aRcpW/dXRl2Dy9vQ7y7+ATH4SCxcckncfmEXt4GFQ6TtyPsctuQfYez6o9MHmwGaKwpCPaWmqfYqomy0yjzMCbCg2b0aP2+hDmOhc0KARhGVnzlZBIBSybtkpAmzXfUxMJHDD5ly3g6ScCcR+3Zf7SKyCfLMGSkwYwiJvvS4sNCtBzwKdDdbEh865T7H5NCS8GOhSt0hxkPPxpbTlXrWXINDiSkF00/b7ZToBRTmK4QIDAQAB",
7
7
  "minimum_chrome_version": "116",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shellway",
3
- "version": "0.8.1",
3
+ "version": "0.8.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": {
package/shellway.js CHANGED
@@ -9,7 +9,7 @@ import { readFile, writeFile, appendFile, readdir, stat, lstat, mkdir, rename, c
9
9
  import { createServer as netServer, connect as netConnect } from 'node:net';
10
10
  import { randomBytes, timingSafeEqual, createHash } from 'node:crypto';
11
11
 
12
- const AGENT_VERSION = '0.8.1'; // keep equal to agent/package.json
12
+ const AGENT_VERSION = '0.8.2'; // keep equal to agent/package.json
13
13
  if (Number(process.versions.node.split('.')[0]) < 22) {
14
14
  console.error(`Shellway needs Node.js 22 or newer (you have ${process.versions.node}). Get it at https://nodejs.org`);
15
15
  process.exit(1);
@@ -1512,6 +1512,17 @@ Object.assign(handlers, browserHandlers);
1512
1512
  // token. Only the relay asks for it (it is not one of the AI app's tools).
1513
1513
  // 0.7.8: remembers the HTTPS fallback across restarts (see runAgent). Never holds a token.
1514
1514
  const LINK_STATE = join(CONF_DIR, 'link-state.json');
1515
+ // 0.8.2 (customer 10396, 23 Nov: "service status" said "not running" on Windows while the agent ran and worked; the
1516
+ // process-list check misses some setups): the running agent writes a small heartbeat (pid, version, link, time) every
1517
+ // tick, and "shellway service status" reads it on every system. No token, no paths, no commands in it.
1518
+ const ALIVE_FILE = join(CONF_DIR, 'agent-alive.json');
1519
+ export function writeAlive(extra = {}) { try { mkdirSync(CONF_DIR, { recursive: true }); writeFileSync(ALIVE_FILE, JSON.stringify({ pid: process.pid, v: AGENT_VERSION, t: Date.now(), ...extra })); } catch {} }
1520
+ export function readAlive(maxAgeMs = 90_000, t = Date.now()) {
1521
+ let a; try { a = JSON.parse(readFileSync(ALIVE_FILE, 'utf8')); } catch { return null; }
1522
+ if (!a || !a.pid || !(t - a.t <= maxAgeMs)) return null;
1523
+ try { process.kill(a.pid, 0); } catch (e) { if (e.code !== 'EPERM') return null; }
1524
+ return a;
1525
+ }
1515
1526
  function readLinkState() { try { return JSON.parse(readFileSync(LINK_STATE, 'utf8')) || {}; } catch { return {}; } }
1516
1527
  function writeLinkState(st) { try { mkdirSync(CONF_DIR, { recursive: true }); writeFileSync(LINK_STATE, JSON.stringify(st)); } catch {} }
1517
1528
  const linkState = { transport: 'ws', connectedAt: 0, links: 0, lastClose: null, journal: 0, startedAt: Date.now() };
@@ -1738,8 +1749,10 @@ function start() {
1738
1749
  why = reason; prevCid = cid; cid = null;
1739
1750
  delay = 1000; setTimeout(connect, 500);
1740
1751
  };
1752
+ writeAlive({ link: 'starting' });
1741
1753
  setInterval(() => {
1742
1754
  const t = Date.now(), slept = t - lastTick > Math.max(45_000, TICK * 3); lastTick = t;
1755
+ writeAlive({ link: linkState.transport === 'poll' ? 'https' : 'websocket', up: !!(current && current.readyState === 1) });
1743
1756
  if (connectingSince && t - connectingSince > 30_000) {
1744
1757
  const w = current; current = null; connectingSince = 0;
1745
1758
  if (w) { w.onopen = null; w.onclose = null; w.onmessage = null; try { w.close(); } catch {} }
@@ -1905,11 +1918,14 @@ function service() {
1905
1918
  else if (os === 'darwin') run('launchctl', ['list', 'com.getshellway.agent']);
1906
1919
  else {
1907
1920
  if (!existsSync(winStartup())) throw new Error('not installed');
1908
- let n = 0;
1909
- try { n = Number(run('powershell', ['-NoProfile', '-Command', `(Get-CimInstance Win32_Process | Where-Object { $_.Name -eq 'node.exe' -and $_.CommandLine -like '*${CONF_DIR.replace(/'/g, "''")}*agent.mjs*' }).Count`], { quiet: true }).trim()) || 0; } catch {}
1921
+ let n = readAlive() ? 1 : 0;
1922
+ if (!n) try { n = Number(run('powershell', ['-NoProfile', '-Command', `(Get-CimInstance Win32_Process | Where-Object { $_.Name -eq 'node.exe' -and $_.CommandLine -like '*${CONF_DIR.replace(/'/g, "''")}*agent.mjs*' }).Count`], { quiet: true }).trim()) || 0; } catch {}
1910
1923
  console.log(`Auto-start installed (${winStartup()}). Background agent: ${n > 0 ? 'running' : 'not running - log out and in, or run the install again'}. Log: ${join(CONF_DIR, 'agent.log')}`);
1911
1924
  }
1912
1925
  } catch { console.log('Auto-start is not installed (or not running).'); }
1926
+ const a = readAlive();
1927
+ console.log(a ? `Running agent: version ${a.v}, process ${a.pid}, link ${a.link || '?'}${a.up === false ? ' (reconnecting)' : ''}, last heartbeat ${Math.round((Date.now() - a.t) / 1000)} s ago`
1928
+ : 'Running agent: no heartbeat in the last 90 s (the agent is not running, or it is older than 0.8.2)');
1913
1929
  }
1914
1930
  }
1915
1931