shellway 0.7.4 → 0.7.6
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 +59 -10
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.6",
|
|
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
|
@@ -7,9 +7,9 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
import { execFileSync, execFile } from 'node:child_process';
|
|
8
8
|
import { readFile, writeFile, appendFile, readdir, stat, lstat, mkdir, rename, cp, rm } from 'node:fs/promises';
|
|
9
9
|
import { createServer as netServer, connect as netConnect } from 'node:net';
|
|
10
|
-
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
10
|
+
import { randomBytes, timingSafeEqual, createHash } from 'node:crypto';
|
|
11
11
|
|
|
12
|
-
const AGENT_VERSION = '0.7.
|
|
12
|
+
const AGENT_VERSION = '0.7.6'; // 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);
|
|
@@ -1134,6 +1134,23 @@ function installExtensionHost() {
|
|
|
1134
1134
|
const extConnected = () => !!ext.sock;
|
|
1135
1135
|
const extVersion = () => ext.version;
|
|
1136
1136
|
export { nativeHostManifest, nativeHostTargets, extJson, extCall, startExtBridge, extConnected, extVersion, installExtensionHost, SNAPSHOT_JS };
|
|
1137
|
+
// 0.7.5: one free trial per computer (owner 21 Nov 2026). The computer's own built-in ID (Windows MachineGuid, Mac
|
|
1138
|
+
// hardware UUID, Linux machine-id) does not change when the computer or the account is renamed. Only a one-way code
|
|
1139
|
+
// made from it is sent; the ID itself never leaves the computer.
|
|
1140
|
+
let machineHashCache;
|
|
1141
|
+
function machineId(os = platform()) {
|
|
1142
|
+
try {
|
|
1143
|
+
if (os === 'win32') { const o = execFileSync('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Cryptography', '/v', 'MachineGuid'], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true }); return (/MachineGuid\s+REG_SZ\s+(\S+)/i.exec(o) || [])[1] || ''; }
|
|
1144
|
+
if (os === 'darwin') { const o = execFileSync('ioreg', ['-rd1', '-c', 'IOPlatformExpertDevice'], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] }); return (/"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(o) || [])[1] || ''; }
|
|
1145
|
+
for (const f of ['/etc/machine-id', '/var/lib/dbus/machine-id']) { try { const v = readFileSync(f, 'utf8').trim(); if (v) return v; } catch {} }
|
|
1146
|
+
} catch {}
|
|
1147
|
+
return '';
|
|
1148
|
+
}
|
|
1149
|
+
function machineHash() {
|
|
1150
|
+
if (machineHashCache === undefined) { const id = String(machineId() || '').trim().toLowerCase(); machineHashCache = id.length >= 8 ? createHash('sha256').update('shellway-machine-v1:' + id).digest('hex').slice(0, 32) : null; }
|
|
1151
|
+
return machineHashCache;
|
|
1152
|
+
}
|
|
1153
|
+
export { machineHash };
|
|
1137
1154
|
const browserPages = async () => (await cdpJson('/json/list')).filter((t) => t.type === 'page' && !String(t.url).startsWith('devtools:'));
|
|
1138
1155
|
async function currentPage() {
|
|
1139
1156
|
await ensureBrowser();
|
|
@@ -1510,13 +1527,26 @@ function start() {
|
|
|
1510
1527
|
// (send-buffer size, timer gaps) are only a fallback for an old relay that never answers. After each new connection the
|
|
1511
1528
|
// agent reports its Node.js version, the reason, and the connection id it left, so the relay drops that one at once.
|
|
1512
1529
|
const TICK = Number(process.env.SHELLWAY_TICK_MS) || 15_000, KA_TIMEOUT = Number(process.env.SHELLWAY_KA_TIMEOUT_MS) || 75_000;
|
|
1530
|
+
// 0.7.6 (customer report 21 Nov: ~2,980 connect/disconnect cycles on Windows, no way to tell why): every log line gets a
|
|
1531
|
+
// UTC time; each closed link logs its close code, reason, wasClean, lifetime and what came back from Shellway, and the
|
|
1532
|
+
// next connection reports that summary to the relay. A link that never gets an answer from Shellway within
|
|
1533
|
+
// NO_REPLY_MS is treated as blocked (antivirus web protection / VPN / proxy) and replaced at once.
|
|
1534
|
+
const NO_REPLY_MS = Number(process.env.SHELLWAY_NO_REPLY_MS) || 20_000;
|
|
1535
|
+
if (!console.__swStamped) {
|
|
1536
|
+
const stamp = (fn) => (...a) => fn(new Date().toISOString().slice(0, 19) + 'Z', ...a);
|
|
1537
|
+
console.log = stamp(console.log.bind(console)); console.error = stamp(console.error.bind(console)); console.__swStamped = true;
|
|
1538
|
+
}
|
|
1513
1539
|
let current = null, lastTick = Date.now(), gen = 0, connectingSince = 0;
|
|
1514
1540
|
let lastMsg = Date.now(), kaSeen = false, cid = null, prevCid = null, why = 'start';
|
|
1541
|
+
let conn = null, lastClose = null, blockedRuns = 0;
|
|
1542
|
+
const clean = (x) => String(x || '').replace(/Bearer\s+\S+/gi, 'Bearer ***').replace(/[\r\n]+/g, ' ').slice(0, 120);
|
|
1543
|
+
const summary = (c, extra = {}) => c ? { secs: Math.round((Date.now() - c.openedAt) / 1000), rx: c.rx, ka: c.ka, tx: c.tx, quiet: Math.round((Date.now() - (c.lastRx || c.openedAt)) / 1000), ...extra } : extra;
|
|
1515
1544
|
const reconnectNow = (reason) => {
|
|
1516
1545
|
const w = current; if (!w) return;
|
|
1517
1546
|
current = null; w.onclose = null; w.onmessage = null;
|
|
1547
|
+
lastClose = summary(conn, { by: 'agent', reason });
|
|
1518
1548
|
try { w.close(); } catch {}
|
|
1519
|
-
console.log(`${reason} — reconnecting
|
|
1549
|
+
console.log(`${reason} — reconnecting… (link lived ${lastClose.secs}s, ${lastClose.rx} messages from Shellway, ${lastClose.ka} keepalive answers)`);
|
|
1520
1550
|
why = reason; prevCid = cid; cid = null;
|
|
1521
1551
|
delay = 1000; setTimeout(connect, 500);
|
|
1522
1552
|
};
|
|
@@ -1531,11 +1561,17 @@ function start() {
|
|
|
1531
1561
|
}
|
|
1532
1562
|
const w = current; if (!w || w.readyState !== 1) return;
|
|
1533
1563
|
const quiet = t - lastMsg;
|
|
1564
|
+
// 0.7.6: keepalives went out but Shellway's answers never arrived on this link -> something between is holding them.
|
|
1565
|
+
if (conn && conn.ka === 0 && conn.tx >= 1 && t - conn.openedAt > NO_REPLY_MS) {
|
|
1566
|
+
blockedRuns++;
|
|
1567
|
+
if (blockedRuns === 3) console.error('Shellway\'s answers are not reaching this computer. An antivirus "web protection / HTTPS scanning", VPN or proxy is probably holding them: add mcp.getshellway.com to its exceptions (or pause it) and Shellway will stay connected.');
|
|
1568
|
+
return reconnectNow('No answers from Shellway on this link');
|
|
1569
|
+
}
|
|
1534
1570
|
if (slept && quiet > 30_000) return reconnectNow('Computer woke up');
|
|
1535
1571
|
if (kaSeen) { if (quiet > KA_TIMEOUT) return reconnectNow('No answer from Shellway'); }
|
|
1536
1572
|
// fallback for a relay without keepalive answers. 0.6.5: check the buffer BEFORE sending (right after send() it always holds the new frame)
|
|
1537
1573
|
else if (w.bufferedAmount > 0) { w._stuck = (w._stuck || 0) + 1; if (w._stuck >= 8) return reconnectNow('Connection stuck'); } else w._stuck = 0;
|
|
1538
|
-
try { w.send('{"type":"keepalive"}'); } catch { return reconnectNow('Connection lost'); }
|
|
1574
|
+
try { w.send('{"type":"keepalive"}'); if (conn) conn.tx++; } catch { return reconnectNow('Connection lost'); }
|
|
1539
1575
|
}, TICK);
|
|
1540
1576
|
const connect = async () => {
|
|
1541
1577
|
const my = ++gen; connectingSince = Date.now();
|
|
@@ -1543,13 +1579,16 @@ function start() {
|
|
|
1543
1579
|
if (my !== gen) return; // a newer attempt took over while the check was running
|
|
1544
1580
|
const ws = new WebSocket(wsUrl, { headers: { authorization: `Bearer ${conf.device_token}`, 'x-shellway-version': AGENT_VERSION } });
|
|
1545
1581
|
current = ws;
|
|
1546
|
-
ws.onopen = () => { if (my !== gen) { try { ws.close(); } catch {} return; } connectingSince = 0;
|
|
1547
|
-
|
|
1548
|
-
|
|
1582
|
+
ws.onopen = () => { if (my !== gen) { try { ws.close(); } catch {} return; } connectingSince = 0; lastMsg = Date.now();
|
|
1583
|
+
// 0.7.6: the retry delay is reset only after a link has really worked for a minute (see onclose), not on every open.
|
|
1584
|
+
conn = { openedAt: Date.now(), rx: 0, ka: 0, tx: 0, lastRx: 0, err: '' };
|
|
1585
|
+
try { ws.send(JSON.stringify({ type: 'info', v: AGENT_VERSION, node: process.versions.node, os: platform(), reason: why, ...(machineHash() ? { mid: machineHash() } : {}), ...(prevCid ? { replaced: prevCid } : {}), ...(lastClose ? { last: lastClose } : {}) })); } catch {}
|
|
1586
|
+
why = 'network'; prevCid = null; lastClose = null; console.log(`Connected as "${conf.device_name}"${readonly ? ' (read-only)' : ''}. Leave this running.`); };
|
|
1549
1587
|
ws.onmessage = async (ev) => {
|
|
1550
1588
|
lastMsg = Date.now();
|
|
1589
|
+
if (conn && current === ws) { conn.rx++; conn.lastRx = lastMsg; }
|
|
1551
1590
|
let m; try { m = JSON.parse(String(ev.data)); } catch { return; }
|
|
1552
|
-
if (m.type === 'ka') { kaSeen = true; return; }
|
|
1591
|
+
if (m.type === 'ka') { kaSeen = true; if (conn && current === ws) { conn.ka++; blockedRuns = 0; } return; }
|
|
1553
1592
|
if (m.type === 'hello') { if (typeof m.cid === 'string') cid = m.cid; return; }
|
|
1554
1593
|
if (!m.id) return;
|
|
1555
1594
|
try {
|
|
@@ -1558,8 +1597,18 @@ function start() {
|
|
|
1558
1597
|
ws.send(JSON.stringify({ id: m.id, error: e.message }));
|
|
1559
1598
|
}
|
|
1560
1599
|
};
|
|
1561
|
-
ws.onclose = () => {
|
|
1562
|
-
|
|
1600
|
+
ws.onclose = (ev) => {
|
|
1601
|
+
if (my !== gen) return;
|
|
1602
|
+
if (current === ws) current = null; connectingSince = 0; prevCid = cid; cid = null;
|
|
1603
|
+
const opened = !!(conn && conn.openedAt);
|
|
1604
|
+
lastClose = summary(opened ? conn : null, { by: 'close', code: Number(ev && ev.code) || 0, why: clean(ev && ev.reason), clean: !!(ev && ev.wasClean), err: conn ? conn.err : '' });
|
|
1605
|
+
if (opened && lastClose.secs >= 60) delay = 1000; // the link worked: start again quickly
|
|
1606
|
+
const wait = Math.round(delay * (1 + Math.random() * 0.3));
|
|
1607
|
+
console.log(`Disconnected (code ${lastClose.code}${lastClose.why ? ' "' + lastClose.why + '"' : ''}, ${lastClose.clean ? 'clean' : 'not clean'}${opened ? `, lived ${lastClose.secs}s, ${lastClose.rx} messages / ${lastClose.ka} keepalive answers from Shellway, last one ${lastClose.quiet}s ago` : ', never opened'}${lastClose.err ? ', error: ' + lastClose.err : ''}). Retrying in ${Math.round(wait / 1000)}s…`);
|
|
1608
|
+
conn = null;
|
|
1609
|
+
setTimeout(connect, wait); delay = Math.min(delay * 2, 30_000);
|
|
1610
|
+
};
|
|
1611
|
+
ws.onerror = (ev) => { const e = clean((ev && (ev.message || (ev.error && (ev.error.code || ev.error.message)))) || 'error'); if (conn && current === ws) conn.err = e; else console.error(`Connection error: ${e}`); };
|
|
1563
1612
|
};
|
|
1564
1613
|
connect();
|
|
1565
1614
|
}
|