shellway 0.8.3 → 0.8.5

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.3",
4
+ "version": "0.8.5",
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.3",
3
+ "version": "0.8.5",
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": {
@@ -29,5 +29,5 @@
29
29
  },
30
30
  "author": "Sandeep Kumar Saini",
31
31
  "license": "UNLICENSED",
32
- "shellwayStable": "0.8.2"
32
+ "shellwayStable": "0.8.4"
33
33
  }
package/shellway.js CHANGED
@@ -10,7 +10,7 @@ import { readFile, writeFile, appendFile, readdir, stat, lstat, mkdir, rename, c
10
10
  import { createServer as netServer, connect as netConnect } from 'node:net';
11
11
  import { randomBytes, timingSafeEqual, createHash } from 'node:crypto';
12
12
 
13
- const AGENT_VERSION = '0.8.3'; // keep equal to agent/package.json
13
+ const AGENT_VERSION = '0.8.5'; // keep equal to agent/package.json
14
14
  if (Number(process.versions.node.split('.')[0]) < 22) {
15
15
  console.error(`Shellway needs Node.js 22 or newer (you have ${process.versions.node}). Get it at https://nodejs.org`);
16
16
  process.exit(1);
@@ -685,12 +685,12 @@ function policyCli() {
685
685
  p.browser = 'extension';
686
686
  const r = installExtensionHost();
687
687
  console.log(`Browser control ON, in YOUR OWN Edge/Chrome through the Shellway extension (your sign-ins are used; banking, trading,
688
- payment and password sites are blocked in the extension).${r.agentFile.includes('_npx') ? '\nNote: run "npx shellway@beta service install" first so the extension can always reach Shellway.' : ''}
688
+ payment and password sites are blocked in the extension).${r.agentFile.includes('_npx') ? '\nNote: run "npx shellway@latest service install" first so the extension can always reach Shellway.' : ''}
689
689
  One-time setup in the browser:
690
- 1. Open edge://extensions (Edge) or chrome://extensions (Chrome)
691
- 2. Turn on "Developer mode"
692
- 3. Click "Load unpacked" and choose the folder: ${r.extDest || '(extension folder missing in this package)'}
693
- 4. Click the Shellway icon in the toolbar (puzzle piece -> pin it) and turn it on.
690
+ Edge: install "Shellway" from the Edge Add-ons store: https://microsoftedge.microsoft.com/addons/detail/jaebfnkgmaopbkikeigclembnhbdlldc
691
+ Chrome: open chrome://extensions, turn on "Developer mode", click "Load unpacked" and choose the folder:
692
+ ${r.extDest || '(extension folder missing in this package)'}
693
+ Then click the Shellway icon in the toolbar (puzzle piece -> pin it) and turn it on.
694
694
  To stop at any time: turn it off in the Shellway icon, press Cancel on the "debugging this browser" bar, or: shellway policy browser off`);
695
695
  }
696
696
  else if (sub === 'browser' && (val === 'on' || val === 'off')) {
@@ -1004,7 +1004,7 @@ const EXT_IDS = [
1004
1004
  'cepfcfgajaghchkamfmnhgcelblihndk', // the unpacked extension (fixed by the key in its manifest)
1005
1005
  'jaebfnkgmaopbkikeigclembnhbdlldc', // 0.7.4: the Edge Add-ons store version (Partner Center CRX ID, 21 Nov 2026)
1006
1006
  ];
1007
- const EXT_OFF = 'The Shellway extension is not connected. On that computer: open Edge or Chrome, click the Shellway extension icon and turn it on. (First time: npx shellway@beta policy browser extension, then load the extension as shown.)';
1007
+ const EXT_OFF = 'The Shellway extension is not connected. On that computer: open Edge or Chrome, click the Shellway extension icon and turn it on. (First time: npx shellway@latest policy browser extension; on Edge install Shellway from the Edge Add-ons store: https://microsoftedge.microsoft.com/addons/detail/jaebfnkgmaopbkikeigclembnhbdlldc)';
1008
1008
  const ext = { sock: null, seq: 0, pending: new Map(), version: '' };
1009
1009
  const extMode = () => { const p = loadPolicy(); return !!p && p.browser === 'extension'; };
1010
1010
  function extAttach(sock, rest) {
@@ -1662,6 +1662,7 @@ async function tokenValid(conf) {
1662
1662
  // keepalives, receipts and reconnects work the same. Messages from Shellway carry a number and are acknowledged on the
1663
1663
  // next poll, so an answer lost on the way is sent again and a repeat is ignored.
1664
1664
  const POLL_SEND_MS = Number(process.env.SHELLWAY_POLL_SEND_MS) || 10_000;
1665
+ const POLL_GRACE_MS = Number(process.env.SHELLWAY_POLL_GRACE_MS) || 5_000;
1665
1666
  export class PollLink {
1666
1667
  constructor(base, token, version) {
1667
1668
  this.base = base; this.h = { authorization: `Bearer ${token}`, 'x-shellway-version': version };
@@ -1682,6 +1683,7 @@ export class PollLink {
1682
1683
  const r = await this._req('/agent/poll/open', { method: 'POST' }, 15_000);
1683
1684
  if (!r.ok) return this._end(r.status === 401 ? 4001 : r.status === 429 ? 4003 : 1006, `HTTP ${r.status}`);
1684
1685
  const j = await r.json(); this.sid = j.sid; this.wait = Number(j.wait) || 25_000;
1686
+ this.piece = Math.max(0, Number(j.pieces) || 0); // 0.8.5: relay joins pieces; 0 = old relay, send whole messages
1685
1687
  } catch (e) { if (this.readyState === 0) { this._fail(e); this._end(1006, ''); } return; }
1686
1688
  if (this.readyState !== 0) return;
1687
1689
  this.readyState = 1;
@@ -1692,7 +1694,9 @@ export class PollLink {
1692
1694
  let fails = 0;
1693
1695
  while (this.readyState === 1) {
1694
1696
  try {
1695
- const r = await this._req(`/agent/poll?sid=${this.sid}&ack=${this.ack}`, { method: 'GET' }, this.wait + 15_000);
1697
+ // 0.8.4 (26 Nov 2026): on networks that need this fallback about 1 request in 20 stalls on the way (relay nginx 499).
1698
+ // A poll held by Shellway for `wait` ms is given up 5 s after that (was 15 s), so a stalled one is re-sent ~10 s sooner.
1699
+ const r = await this._req(`/agent/poll?sid=${this.sid}&ack=${this.ack}`, { method: 'GET' }, this.wait + POLL_GRACE_MS);
1696
1700
  if (r.status === 410) return this._end(1006, 'closed by Shellway');
1697
1701
  if (!r.ok) throw new Error(`HTTP ${r.status}`);
1698
1702
  const j = await r.json(); fails = 0;
@@ -1705,13 +1709,27 @@ export class PollLink {
1705
1709
  }
1706
1710
  }
1707
1711
  }
1708
- send(text) { if (this.readyState !== 1) throw new Error('not connected'); this.outq.push(String(text)); this._flush(); }
1712
+ send(text) {
1713
+ if (this.readyState !== 1) throw new Error('not connected');
1714
+ const s = String(text);
1715
+ // 0.8.5 (26 Nov 2026, customer 10396: 16 KiB answers arrive, 32 KiB stall on his network): a message larger than the
1716
+ // relay's piece size goes out as pieces, each in its own small upload; the relay joins them.
1717
+ if (this.piece && Buffer.byteLength(s) > this.piece) {
1718
+ const per = Math.max(1000, Math.floor(this.piece / 3)); // a JS char is at most 3 UTF-8 bytes (pairs: 4 bytes / 2 chars)
1719
+ const n = Math.ceil(s.length / per), pid = 'p' + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
1720
+ for (let i = 0; i < n; i++) this.outq.push(JSON.stringify({ type: 'piece', pid, i, n, d: s.slice(i * per, (i + 1) * per) }));
1721
+ } else this.outq.push(s);
1722
+ this._flush();
1723
+ }
1709
1724
  async _flush() {
1710
1725
  if (this.sending) return; this.sending = true;
1711
1726
  let fails = 0;
1712
1727
  try {
1713
1728
  while (this.outq.length && this.readyState === 1) {
1714
- const batch = this.outq.splice(0, 50);
1729
+ let take = 1;
1730
+ if (this.piece) { let bytes = Buffer.byteLength(this.outq[0]); while (take < this.outq.length && take < 50) { const b = Buffer.byteLength(this.outq[take]); if (bytes + b > this.piece) break; bytes += b; take++; } }
1731
+ else take = Math.min(50, this.outq.length);
1732
+ const batch = this.outq.splice(0, take); // 0.8.5: with pieces, one upload stays within the piece size
1715
1733
  try {
1716
1734
  // 0.8.1 (customer 10396, 23 Nov): on his network about 1 upload in 10 stalls and never arrives (relay logged
1717
1735
  // HTTP 408 after 60 s). Answers and keepalives waited 30 s per try, so commands timed out and the link was
@@ -1796,11 +1814,11 @@ function start() {
1796
1814
  // clears it.
1797
1815
  const forced = process.env.SHELLWAY_TRANSPORT === 'poll';
1798
1816
  const SHORT_POLL_MS = Number(process.env.SHELLWAY_POLL_FOR_MS) || 30 * 60_000;
1799
- const LONG_POLL_MS = Number(process.env.SHELLWAY_POLL_LONG_MS) || 24 * 3600_000;
1817
+ const LONG_POLL_MS = Number(process.env.SHELLWAY_POLL_LONG_MS) || 2 * 3600_000; // 0.8.5: was 24 h; retry the faster WebSocket link sooner
1800
1818
  const saved = forced ? {} : readLinkState();
1801
1819
  let transport = forced ? 'poll' : 'ws', pollUntil = 0, shortRuns = 0, lastFallbackEnd = Number(saved.lastFallbackEnd) || 0;
1802
1820
  if (!forced && Number(saved.pollUntil) > Date.now()) {
1803
- transport = 'poll'; pollUntil = Number(saved.pollUntil);
1821
+ transport = 'poll'; pollUntil = Math.min(Number(saved.pollUntil), Date.now() + LONG_POLL_MS); // older apps saved up to 24 h
1804
1822
  console.log(`Using the HTTPS fallback until ${new Date(pollUntil).toISOString().slice(0, 16).replace('T', ' ')} UTC (the WebSocket link kept dropping on this network).`);
1805
1823
  }
1806
1824
  const useFallback = (reason) => {
@@ -1809,7 +1827,8 @@ function start() {
1809
1827
  transport = 'poll'; pollUntil = Date.now() + (again ? LONG_POLL_MS : SHORT_POLL_MS); shortRuns = 0;
1810
1828
  delay = 1000; // connect over HTTPS right away, not after the grown WebSocket retry delay
1811
1829
  writeLinkState({ pollUntil, lastFallbackEnd, reason, at: Date.now() });
1812
- console.log(`Switching to the HTTPS fallback for ${again ? '24 hours' : '30 minutes'} (${reason}${again ? '; it dropped again after the last retry' : ''}). Shellway keeps working; this is slower but gets through antivirus/VPN filters.`);
1830
+ const dur = (ms) => (ms >= 3600_000 ? `${Math.round(ms / 3600_000)} hour${ms >= 7200_000 ? 's' : ''}` : `${Math.round(ms / 60_000)} minutes`);
1831
+ console.log(`Switching to the HTTPS fallback for ${again ? dur(LONG_POLL_MS) : '30 minutes'} (${reason}${again ? '; it dropped again after the last retry' : ''}). Shellway keeps working; this is slower but gets through antivirus/VPN filters.`);
1813
1832
  };
1814
1833
  const linkEnded = (opened, secs) => {
1815
1834
  if (transport !== 'ws') return;