shellway 0.8.4 → 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.4",
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.4",
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.3"
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.4'; // 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);
@@ -1683,6 +1683,7 @@ export class PollLink {
1683
1683
  const r = await this._req('/agent/poll/open', { method: 'POST' }, 15_000);
1684
1684
  if (!r.ok) return this._end(r.status === 401 ? 4001 : r.status === 429 ? 4003 : 1006, `HTTP ${r.status}`);
1685
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
1686
1687
  } catch (e) { if (this.readyState === 0) { this._fail(e); this._end(1006, ''); } return; }
1687
1688
  if (this.readyState !== 0) return;
1688
1689
  this.readyState = 1;
@@ -1708,13 +1709,27 @@ export class PollLink {
1708
1709
  }
1709
1710
  }
1710
1711
  }
1711
- 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
+ }
1712
1724
  async _flush() {
1713
1725
  if (this.sending) return; this.sending = true;
1714
1726
  let fails = 0;
1715
1727
  try {
1716
1728
  while (this.outq.length && this.readyState === 1) {
1717
- 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
1718
1733
  try {
1719
1734
  // 0.8.1 (customer 10396, 23 Nov): on his network about 1 upload in 10 stalls and never arrives (relay logged
1720
1735
  // HTTP 408 after 60 s). Answers and keepalives waited 30 s per try, so commands timed out and the link was
@@ -1799,11 +1814,11 @@ function start() {
1799
1814
  // clears it.
1800
1815
  const forced = process.env.SHELLWAY_TRANSPORT === 'poll';
1801
1816
  const SHORT_POLL_MS = Number(process.env.SHELLWAY_POLL_FOR_MS) || 30 * 60_000;
1802
- 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
1803
1818
  const saved = forced ? {} : readLinkState();
1804
1819
  let transport = forced ? 'poll' : 'ws', pollUntil = 0, shortRuns = 0, lastFallbackEnd = Number(saved.lastFallbackEnd) || 0;
1805
1820
  if (!forced && Number(saved.pollUntil) > Date.now()) {
1806
- 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
1807
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).`);
1808
1823
  }
1809
1824
  const useFallback = (reason) => {
@@ -1812,7 +1827,8 @@ function start() {
1812
1827
  transport = 'poll'; pollUntil = Date.now() + (again ? LONG_POLL_MS : SHORT_POLL_MS); shortRuns = 0;
1813
1828
  delay = 1000; // connect over HTTPS right away, not after the grown WebSocket retry delay
1814
1829
  writeLinkState({ pollUntil, lastFallbackEnd, reason, at: Date.now() });
1815
- 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.`);
1816
1832
  };
1817
1833
  const linkEnded = (opened, secs) => {
1818
1834
  if (transport !== 'ws') return;