shellway 0.8.10 → 0.8.11
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/background.js +8 -4
- package/extension/manifest.json +1 -1
- package/extension/popup.html +5 -0
- package/extension/popup.js +11 -0
- package/package.json +1 -1
- package/shellway.js +32 -9
package/extension/background.js
CHANGED
|
@@ -33,6 +33,8 @@ let port = null;
|
|
|
33
33
|
let connected = false;
|
|
34
34
|
let agentVersion = '';
|
|
35
35
|
let lastError = '';
|
|
36
|
+
// 0.8.7 (Konstantin KO18): separate statuses for the popup
|
|
37
|
+
let lastErrorAt = 0, lastHandshakeAt = 0, serverLink = null, appPid = null;
|
|
36
38
|
const attached = new Set();
|
|
37
39
|
const groupByWindow = new Map();
|
|
38
40
|
let idleTimer = null;
|
|
@@ -82,7 +84,7 @@ async function connect() {
|
|
|
82
84
|
port.onMessage.addListener(onMessage);
|
|
83
85
|
port.onDisconnect.addListener(() => {
|
|
84
86
|
const err = chrome.runtime.lastError && chrome.runtime.lastError.message;
|
|
85
|
-
if (err) lastError = /not found/i.test(err) ? 'The Shellway app is not set up for the extension on this computer. Run: npx shellway@beta policy browser extension' : err;
|
|
87
|
+
if (err) { lastError = /not found/i.test(err) ? 'The Shellway app is not set up for the extension on this computer. Run: npx shellway@beta policy browser extension' : /forbidden/i.test(err) ? 'This copy of the extension is not allowed by the Shellway app (different extension ID). Load the folder the app created (Shellway Extension in your user folder) or use the store version.' : err; lastErrorAt = Date.now(); }
|
|
86
88
|
port = null; connected = false; badge(); detachAll();
|
|
87
89
|
});
|
|
88
90
|
badge();
|
|
@@ -104,7 +106,7 @@ function browserName() {
|
|
|
104
106
|
async function onMessage(m) {
|
|
105
107
|
if (!m || typeof m !== 'object') return;
|
|
106
108
|
if (m.type === 'hello') {
|
|
107
|
-
connected = true; agentVersion = m.version || ''; lastError = ''; badge();
|
|
109
|
+
connected = true; agentVersion = m.version || ''; lastError = ''; lastHandshakeAt = Date.now(); serverLink = m.server || null; appPid = m.pid || null; badge();
|
|
108
110
|
// 0.7.2: the Shellway app refreshed this extension's folder (a newer version): reload once to use the new files.
|
|
109
111
|
const mine = chrome.runtime.getManifest().version;
|
|
110
112
|
if (port) port.postMessage({ type: 'ext', version: mine, browser: browserName() }); // 0.7.3: version; 0.8.6: and which browser
|
|
@@ -114,7 +116,9 @@ async function onMessage(m) {
|
|
|
114
116
|
}
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
117
|
-
if (m.type === '
|
|
119
|
+
if (m.type === 'status') { serverLink = m.server || null; return; }
|
|
120
|
+
if (m.type === 'refused') { lastError = m.message || 'The Shellway app refused the link.'; lastErrorAt = Date.now(); connected = false; badge(); return; }
|
|
121
|
+
if (m.type === 'error') { lastError = m.message || 'error'; lastErrorAt = Date.now(); return; }
|
|
118
122
|
if (m.id === undefined) return;
|
|
119
123
|
try {
|
|
120
124
|
const result = await handle(m.op, m.args || {});
|
|
@@ -229,7 +233,7 @@ chrome.runtime.onMessage.addListener((msg, _sender, reply) => {
|
|
|
229
233
|
if (msg.cmd === 'clear-activity') await chrome.storage.session.set({ activity: [] });
|
|
230
234
|
const s = await getSettings();
|
|
231
235
|
const { activity = [] } = await chrome.storage.session.get({ activity: [] });
|
|
232
|
-
reply({ enabled: s.enabled, blocked: s.blocked, allTabs: s.allTabs, connected, connecting: !!port && !connected, agentVersion, lastError, working: attached.size, activity, version: chrome.runtime.getManifest().version });
|
|
236
|
+
reply({ enabled: s.enabled, blocked: s.blocked, allTabs: s.allTabs, connected, connecting: !!port && !connected, agentVersion, lastError, lastErrorAt, lastHandshakeAt, serverLink, appPid, working: attached.size, activity, version: chrome.runtime.getManifest().version });
|
|
233
237
|
})();
|
|
234
238
|
return true;
|
|
235
239
|
});
|
package/extension/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Shellway",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.7",
|
|
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/extension/popup.html
CHANGED
|
@@ -25,12 +25,17 @@
|
|
|
25
25
|
.act li { padding: 3px 0; border-bottom: 1px solid #f0f0f2; display: flex; gap: 6px; }
|
|
26
26
|
.act time { color: #888; min-width: 62px; white-space: nowrap; }
|
|
27
27
|
.ver { color: #999; font-weight: 400; font-size: 11px; margin-left: auto; }
|
|
28
|
+
.checks { list-style: none; padding: 0; margin: 0 0 10px; font-size: 12px; }
|
|
29
|
+
.checks li { padding: 2px 0; display: flex; gap: 6px; }
|
|
30
|
+
.checks b { min-width: 14px; }
|
|
31
|
+
.checks .y { color: #0a7d4f; } .checks .n { color: #b00020; } .checks .q { color: #888; }
|
|
28
32
|
</style>
|
|
29
33
|
</head>
|
|
30
34
|
<body>
|
|
31
35
|
<h1><img src="icons/icon32.png" alt="">Shellway<span id="ver" class="ver"></span></h1>
|
|
32
36
|
<div class="row"><span>Let my AI use this browser</span><label class="switch"><input id="on" type="checkbox"><span class="slider"></span></label></div>
|
|
33
37
|
<div id="status" class="status">…</div>
|
|
38
|
+
<ul id="checks" class="checks"></ul>
|
|
34
39
|
<p class="note">Your AI (ChatGPT, Claude) can open tabs, read pages, click, type and take screenshots here, with the sites you are already signed in to. It never types passwords or card numbers. While it works, the browser shows a "debugging this browser" bar: press <b>Cancel</b> on it to stop and turn Shellway off.</p>
|
|
35
40
|
<div class="row" style="margin-top:8px"><span>AI can also use my other tabs<br><span class="note" style="margin:0">Off: only the tabs the AI opened</span></span><label class="switch"><input id="all" type="checkbox"><span class="slider"></span></label></div>
|
|
36
41
|
<details open>
|
package/extension/popup.js
CHANGED
|
@@ -8,6 +8,17 @@ function render(s) {
|
|
|
8
8
|
if (!s.enabled) st.textContent = 'Off. Turn it on to let your AI use this browser.';
|
|
9
9
|
else if (s.connected) { st.className = 'status ok'; st.textContent = `Connected to the Shellway app${s.agentVersion ? ` (${s.agentVersion})` : ''}.${s.working ? ' The AI is working in a tab now.' : ''}`; }
|
|
10
10
|
else { st.className = 'status warn'; st.textContent = s.lastError || (s.connecting ? 'Connecting to the Shellway app…' : 'Not connected. Is the Shellway app running on this computer?'); }
|
|
11
|
+
// 0.8.7 (KO18): one line per link, so "on" and "really connected" are not mixed up
|
|
12
|
+
const ago = (t) => { if (!t) return 'never'; const m = Math.round((Date.now() - t) / 60000); return m < 1 ? 'just now' : m < 60 ? `${m} min ago` : new Date(t).toLocaleString([], { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' }); };
|
|
13
|
+
const rows = [
|
|
14
|
+
[s.enabled, `Browser control: ${s.enabled ? 'on' : 'off'}`],
|
|
15
|
+
[s.connected, `Shellway app on this computer: ${s.connected ? `connected${s.agentVersion ? ' (' + s.agentVersion + ')' : ''}` : s.connecting ? 'connecting…' : 'not connected'}`],
|
|
16
|
+
[s.connected && s.serverLink ? !!s.serverLink.up : null, `App's link to the Shellway server: ${!s.connected || !s.serverLink ? 'unknown' : s.serverLink.up ? `connected (${s.serverLink.link === 'https' ? 'HTTPS fallback' : 'WebSocket'})` : 'not connected'}`],
|
|
17
|
+
[s.lastHandshakeAt ? true : null, `Last successful handshake: ${ago(s.lastHandshakeAt)}`],
|
|
18
|
+
[s.lastError ? false : null, `Last error: ${s.lastError ? s.lastError + ' (' + ago(s.lastErrorAt) + ')' : 'none'}`],
|
|
19
|
+
];
|
|
20
|
+
const ck = $('checks'); ck.textContent = '';
|
|
21
|
+
for (const [ok, t] of rows) { const li = document.createElement('li'); const b = document.createElement('b'); b.className = ok === true ? 'y' : ok === false ? 'n' : 'q'; b.textContent = ok === true ? '✓' : ok === false ? '✗' : '•'; const sp = document.createElement('span'); sp.textContent = t; li.append(b, sp); ck.append(li); }
|
|
11
22
|
if (!blockedShown) { $('blocked').value = s.blocked.join('\n'); blockedShown = true; }
|
|
12
23
|
$('all').checked = !!s.allTabs;
|
|
13
24
|
$('ver').textContent = s.version ? 'v' + s.version : '';
|
package/package.json
CHANGED
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.
|
|
13
|
+
const AGENT_VERSION = '0.8.11'; // 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);
|
|
@@ -1066,9 +1066,10 @@ function extAttach(sock, rest, hello = {}) {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
};
|
|
1068
1068
|
sock.on('data', (d) => { buf += d.toString('utf8'); take(); });
|
|
1069
|
+
const statusTimer = setInterval(() => { try { sock.write(JSON.stringify({ type: 'status', server: serverStatus() }) + '\n'); } catch {} }, 15_000); statusTimer.unref?.();
|
|
1069
1070
|
let done = false;
|
|
1070
1071
|
const gone = () => {
|
|
1071
|
-
if (done) return; done = true;
|
|
1072
|
+
if (done) return; done = true; clearInterval(statusTimer);
|
|
1072
1073
|
if (ext.links.get(L.browser) === L) ext.links.delete(L.browser);
|
|
1073
1074
|
for (const p of L.pending.values()) { clearTimeout(p.timer); p.no(new Error('The browser extension disconnected (the browser was closed or Shellway was turned off there).')); }
|
|
1074
1075
|
L.pending.clear();
|
|
@@ -1100,6 +1101,8 @@ async function extJson(path) {
|
|
|
1100
1101
|
}
|
|
1101
1102
|
const extSession = (id) => ({ send: (method, params = {}, ms = 20_000) => extCall('cdp', { id, method, params }, ms), close: () => {} });
|
|
1102
1103
|
// Local endpoint for the native-messaging helper: 127.0.0.1 only, random port, a new random secret every start.
|
|
1104
|
+
// 0.8.11 (Konstantin KO18): the app's own link to the Shellway server, for the extension popup and doctor
|
|
1105
|
+
function serverStatus() { try { return { link: linkState.transport === 'poll' ? 'https' : 'websocket', up: !!linkState.up, since: linkState.connectedAt || null }; } catch { return { link: 'unknown', up: false, since: null }; } }
|
|
1103
1106
|
function startExtBridge() {
|
|
1104
1107
|
const token = randomBytes(24).toString('hex');
|
|
1105
1108
|
const srv = netServer((sock) => {
|
|
@@ -1114,7 +1117,9 @@ function startExtBridge() {
|
|
|
1114
1117
|
let given = '', hello = {};
|
|
1115
1118
|
try { hello = JSON.parse(head.slice(0, i)) || {}; given = String(hello.token || ''); } catch {}
|
|
1116
1119
|
const a = Buffer.from(given), b = Buffer.from(token);
|
|
1117
|
-
if (a.length !== b.length || !timingSafeEqual(a, b)) { sock.destroy(); return; }
|
|
1120
|
+
if (a.length !== b.length || !timingSafeEqual(a, b)) { sock.destroy(); return; } // the native helper reports a link closed before the greeting
|
|
1121
|
+
try { sock.write(JSON.stringify({ type: 'hello', version: AGENT_VERSION, extVersion: extFolderVersion(), pid: process.pid, server: serverStatus(), browsers: [...ext.links.keys()] }) + '\n'); } catch {}
|
|
1122
|
+
if (hello.origin === 'doctor') { setTimeout(() => { try { sock.destroy(); } catch {} }, 200); return; } // doctor only checks the greeting
|
|
1118
1123
|
extAttach(sock, head.slice(i + 1), { browser: hello.browser, origin: hello.origin });
|
|
1119
1124
|
};
|
|
1120
1125
|
sock.on('data', onHead);
|
|
@@ -1141,12 +1146,13 @@ function nativeHost() {
|
|
|
1141
1146
|
const sock = netConnect(info.port, '127.0.0.1');
|
|
1142
1147
|
let up = false;
|
|
1143
1148
|
const origin = process.argv.find((a) => String(a).startsWith('chrome-extension://')) || '';
|
|
1144
|
-
|
|
1149
|
+
let welcomed = false; // 0.8.11: the app greets after checking the key; a link without a greeting is reported
|
|
1150
|
+
sock.on('connect', () => { up = true; sock.write(JSON.stringify({ token: info.token, origin }) + '\n'); setTimeout(() => { if (!welcomed) frame({ type: 'error', message: 'The Shellway app on this computer did not answer the browser link. Restart it once (run the same service install command you used to set it up, or restart the computer).' }); }, 5000).unref?.(); });
|
|
1145
1151
|
const bye = (msg) => { if (msg) try { frame({ type: 'error', message: msg }); } catch {} setTimeout(() => process.exit(0), 200); };
|
|
1146
|
-
sock.on('error', () => bye(up ? '' :
|
|
1147
|
-
sock.on('close', () => bye(''));
|
|
1152
|
+
sock.on('error', () => bye(up ? '' : `The Shellway app is not running on this computer (nothing answers on its browser link, port ${info.port}). Start it (the service install command you used to set it up, or restart the computer).`));
|
|
1153
|
+
sock.on('close', () => bye(welcomed ? '' : 'The Shellway app closed the browser link before it was ready. Restart it once (run the same service install command you used to set it up, or restart the computer), then close and reopen the browser.'));
|
|
1148
1154
|
let lb = '';
|
|
1149
|
-
sock.on('data', (d) => { lb += d.toString('utf8'); let i; while ((i = lb.indexOf('\n')) >= 0) { const line = lb.slice(0, i); lb = lb.slice(i + 1); if (line) frame(line); } });
|
|
1155
|
+
sock.on('data', (d) => { lb += d.toString('utf8'); let i; while ((i = lb.indexOf('\n')) >= 0) { const line = lb.slice(0, i); lb = lb.slice(i + 1); if (!line) continue; if (!welcomed && /"type":"(hello|refused)"/.test(line)) welcomed = true; frame(line); } });
|
|
1150
1156
|
let ib = Buffer.alloc(0);
|
|
1151
1157
|
process.stdin.on('data', (d) => {
|
|
1152
1158
|
ib = Buffer.concat([ib, d]);
|
|
@@ -2056,7 +2062,8 @@ function start() {
|
|
|
2056
2062
|
writeAlive({ link: 'starting' });
|
|
2057
2063
|
setInterval(() => {
|
|
2058
2064
|
const t = Date.now(), slept = t - lastTick > Math.max(45_000, TICK * 3); lastTick = t;
|
|
2059
|
-
|
|
2065
|
+
linkState.up = !!(current && current.readyState === 1); // 0.8.11: shown in the extension popup
|
|
2066
|
+
writeAlive({ link: linkState.transport === 'poll' ? 'https' : 'websocket', up: linkState.up });
|
|
2060
2067
|
if (connectingSince && t - connectingSince > 30_000) {
|
|
2061
2068
|
const w = current; current = null; connectingSince = 0;
|
|
2062
2069
|
if (w) { w.onopen = null; w.onclose = null; w.onmessage = null; try { w.close(); } catch {} }
|
|
@@ -2091,7 +2098,7 @@ function start() {
|
|
|
2091
2098
|
// 0.7.6: the retry delay is reset only after a link has really worked for a minute (see onclose), not on every open.
|
|
2092
2099
|
conn = { openedAt: Date.now(), rx: 0, ka: 0, tx: 0, lastRx: 0, err: '' };
|
|
2093
2100
|
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 } : {}), caps: ['receipts'], boot: BOOT, t: transport })); } catch {}
|
|
2094
|
-
linkState.transport = transport; linkState.connectedAt = Date.now(); linkState.links++; linkState.lastClose = lastClose; linkState.journal = journal.size;
|
|
2101
|
+
linkState.transport = transport; linkState.connectedAt = Date.now(); linkState.links++; linkState.lastClose = lastClose; linkState.journal = journal.size; linkState.up = true;
|
|
2095
2102
|
why = 'network'; prevCid = null; lastClose = null; console.log(`Connected as "${conf.device_name}"${readonly ? ' (read-only)' : ''}${transport === 'poll' ? ' over the HTTPS fallback' : ''}. Leave this running.`); };
|
|
2096
2103
|
ws.onmessage = async (ev) => {
|
|
2097
2104
|
lastMsg = Date.now();
|
|
@@ -2310,6 +2317,22 @@ export async function doctor(opts = {}) {
|
|
|
2310
2317
|
fetch(`${server}/agent/poll/close?sid=${sid}`, { method: 'POST', headers: H, signal: AbortSignal.timeout(5000) }).catch(() => {});
|
|
2311
2318
|
add(got, `HTTPS fallback: ${got ? 'works' : 'no answer'} (${Date.now() - s} ms)`, 'Even plain HTTPS requests to Shellway are held. A firewall or proxy blocks mcp.getshellway.com.');
|
|
2312
2319
|
} catch (e) { add(null, `HTTPS fallback: ${err(e)}`); }
|
|
2320
|
+
// 0.8.11 (Konstantin KO18): the browser extension link, tested the way the extension's helper connects
|
|
2321
|
+
try {
|
|
2322
|
+
let info = null; try { info = JSON.parse(readFileSync(EXT_BRIDGE, 'utf8')); } catch {}
|
|
2323
|
+
if (!info || !info.port) add(null, 'Browser extension link: not set up on this computer (only needed for the browser tools)');
|
|
2324
|
+
else {
|
|
2325
|
+
const r = await new Promise((resolve) => {
|
|
2326
|
+
const sk = netConnect(info.port, '127.0.0.1'); let b = '', done = false; const end = (x) => { if (done) return; done = true; try { sk.destroy(); } catch {} resolve(x); };
|
|
2327
|
+
const t = setTimeout(() => end({ err: 'no answer in 4 s' }), 4000);
|
|
2328
|
+
sk.on('connect', () => sk.write(JSON.stringify({ token: info.token, origin: 'doctor' }) + '\n'));
|
|
2329
|
+
sk.on('data', (d) => { b += d.toString('utf8'); const i = b.indexOf('\n'); if (i >= 0) { clearTimeout(t); let m = {}; try { m = JSON.parse(b.slice(0, i)); } catch {} end(m.type === 'hello' ? { hello: m } : { err: m.message || 'unexpected answer' }); } });
|
|
2330
|
+
sk.on('error', (e) => { clearTimeout(t); end({ err: e.code === 'ECONNREFUSED' ? `nothing listens on port ${info.port} (the app that wrote the link file is not running; pid ${info.pid})` : e.message }); });
|
|
2331
|
+
});
|
|
2332
|
+
if (r.hello) add(true, `Browser extension link: the Shellway app ${r.hello.version} (pid ${r.hello.pid}) answers${r.hello.browsers && r.hello.browsers.length ? '; connected browsers: ' + r.hello.browsers.join(', ') : '; no browser connected right now'}`);
|
|
2333
|
+
else add(false, `Browser extension link: ${r.err}`, 'The browser extension cannot reach the Shellway app. Run the service install command again (it restarts the app and rewrites the link), then close the browser completely and open it again.');
|
|
2334
|
+
}
|
|
2335
|
+
} catch (e) { add(null, `Browser extension link: ${err(e)}`); }
|
|
2313
2336
|
// the background app's log
|
|
2314
2337
|
try {
|
|
2315
2338
|
const log = join(CONF_DIR, 'agent.log');
|