shellway 0.7.7 → 0.7.8
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/extension/manifest.json +1 -1
- package/package.json +1 -1
- package/shellway.js +28 -6
package/extension/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Shellway",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.8",
|
|
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
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.7.
|
|
12
|
+
const AGENT_VERSION = '0.7.8'; // 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);
|
|
@@ -1510,6 +1510,10 @@ Object.assign(handlers, browserHandlers);
|
|
|
1510
1510
|
// 0.7.6 R9 ("Report a problem" on the dashboard): a short, safe status of this app for the support message — version,
|
|
1511
1511
|
// Node.js, system, link state and the app's own connection lines from its log. Never command text, output, files or the
|
|
1512
1512
|
// token. Only the relay asks for it (it is not one of the AI app's tools).
|
|
1513
|
+
// 0.7.8: remembers the HTTPS fallback across restarts (see runAgent). Never holds a token.
|
|
1514
|
+
const LINK_STATE = join(CONF_DIR, 'link-state.json');
|
|
1515
|
+
function readLinkState() { try { return JSON.parse(readFileSync(LINK_STATE, 'utf8')) || {}; } catch { return {}; } }
|
|
1516
|
+
function writeLinkState(st) { try { mkdirSync(CONF_DIR, { recursive: true }); writeFileSync(LINK_STATE, JSON.stringify(st)); } catch {} }
|
|
1513
1517
|
const linkState = { transport: 'ws', connectedAt: 0, links: 0, lastClose: null, journal: 0, startedAt: Date.now() };
|
|
1514
1518
|
const STATUS_LINE = /Connected as|Disconnected|reconnecting…|Switching to the HTTPS fallback|Trying the WebSocket link again|Connection error|answers are not reaching|Connecting took too long|token is invalid/;
|
|
1515
1519
|
handlers.shellway_diagnostics = async () => {
|
|
@@ -1665,14 +1669,32 @@ function start() {
|
|
|
1665
1669
|
let conn = null, lastClose = null, blockedRuns = 0;
|
|
1666
1670
|
// 0.7.6 R5: WebSocket first; if its links keep dropping (4 links in a row under 3 minutes) or Shellway's answers are
|
|
1667
1671
|
// blocked twice, use the HTTPS fallback for 30 minutes, then try the WebSocket again. SHELLWAY_TRANSPORT=poll forces it.
|
|
1672
|
+
// 0.7.8 (customer 10396, 22 Nov: a network that freezes every long-lived link ~30 times an hour): if the WebSocket
|
|
1673
|
+
// drops again within a day after the last fallback ended, stay on HTTPS for 24 hours. The choice is kept in
|
|
1674
|
+
// link-state.json, so a restart or reboot does not start the drops again; a WebSocket link that stays up 3+ minutes
|
|
1675
|
+
// clears it.
|
|
1668
1676
|
const forced = process.env.SHELLWAY_TRANSPORT === 'poll';
|
|
1669
|
-
|
|
1677
|
+
const SHORT_POLL_MS = Number(process.env.SHELLWAY_POLL_FOR_MS) || 30 * 60_000;
|
|
1678
|
+
const LONG_POLL_MS = Number(process.env.SHELLWAY_POLL_LONG_MS) || 24 * 3600_000;
|
|
1679
|
+
const saved = forced ? {} : readLinkState();
|
|
1680
|
+
let transport = forced ? 'poll' : 'ws', pollUntil = 0, shortRuns = 0, lastFallbackEnd = Number(saved.lastFallbackEnd) || 0;
|
|
1681
|
+
if (!forced && Number(saved.pollUntil) > Date.now()) {
|
|
1682
|
+
transport = 'poll'; pollUntil = Number(saved.pollUntil);
|
|
1683
|
+
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).`);
|
|
1684
|
+
}
|
|
1670
1685
|
const useFallback = (reason) => {
|
|
1671
1686
|
if (transport === 'poll') return;
|
|
1672
|
-
|
|
1673
|
-
|
|
1687
|
+
const again = lastFallbackEnd > 0 && Date.now() - lastFallbackEnd < 24 * 3600_000;
|
|
1688
|
+
transport = 'poll'; pollUntil = Date.now() + (again ? LONG_POLL_MS : SHORT_POLL_MS); shortRuns = 0;
|
|
1689
|
+
delay = 1000; // connect over HTTPS right away, not after the grown WebSocket retry delay
|
|
1690
|
+
writeLinkState({ pollUntil, lastFallbackEnd, reason, at: Date.now() });
|
|
1691
|
+
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.`);
|
|
1692
|
+
};
|
|
1693
|
+
const linkEnded = (opened, secs) => {
|
|
1694
|
+
if (transport !== 'ws') return;
|
|
1695
|
+
if (!opened || secs < 180) { if (++shortRuns >= 4) useFallback('the WebSocket link keeps dropping'); }
|
|
1696
|
+
else { shortRuns = 0; if (lastFallbackEnd) { lastFallbackEnd = 0; writeLinkState({}); } }
|
|
1674
1697
|
};
|
|
1675
|
-
const linkEnded = (opened, secs) => { if (transport !== 'ws') return; if (!opened || secs < 180) { if (++shortRuns >= 4) useFallback('the WebSocket link keeps dropping'); } else shortRuns = 0; };
|
|
1676
1698
|
// 0.7.6 receipts (customer report 21 Nov): every request from Shellway has an id. This agent remembers the recent ones
|
|
1677
1699
|
// (BOOT identifies this process). If a link drops and Shellway sends the same id again on the new link, a finished
|
|
1678
1700
|
// request gets its stored answer, a running one answers when it finishes, and nothing ever runs twice.
|
|
@@ -1725,7 +1747,7 @@ function start() {
|
|
|
1725
1747
|
const my = ++gen; connectingSince = Date.now();
|
|
1726
1748
|
if (!(await tokenValid(conf))) { console.error('This device was removed or its token is invalid. Pair again.'); process.exit(78); }
|
|
1727
1749
|
if (my !== gen) return; // a newer attempt took over while the check was running
|
|
1728
|
-
if (transport === 'poll' && !forced && Date.now() > pollUntil) { transport = 'ws'; shortRuns = 0; blockedRuns = 0; console.log('Trying the WebSocket link again.'); }
|
|
1750
|
+
if (transport === 'poll' && !forced && Date.now() > pollUntil) { transport = 'ws'; shortRuns = 0; blockedRuns = 0; lastFallbackEnd = Date.now(); writeLinkState({ pollUntil: 0, lastFallbackEnd }); console.log('Trying the WebSocket link again.'); }
|
|
1729
1751
|
const ws = transport === 'poll' ? new PollLink(conf.server, conf.device_token, AGENT_VERSION)
|
|
1730
1752
|
: new WebSocket(wsUrl, { headers: { authorization: `Bearer ${conf.device_token}`, 'x-shellway-version': AGENT_VERSION } });
|
|
1731
1753
|
current = ws;
|