shellway 0.8.5 → 0.8.7
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 +10 -1
- package/extension/manifest.json +1 -1
- package/package.json +2 -2
- package/shellway.js +71 -22
package/extension/background.js
CHANGED
|
@@ -92,13 +92,22 @@ function disconnect() {
|
|
|
92
92
|
port = null; connected = false; badge(); detachAll();
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// 0.8.6: lets the Shellway app tell Edge and Chrome apart when the extension runs in both at once.
|
|
96
|
+
function browserName() {
|
|
97
|
+
const ua = (self.navigator && navigator.userAgent) || '';
|
|
98
|
+
if (/Edg\//.test(ua)) return 'edge';
|
|
99
|
+
if (/OPR\//.test(ua)) return 'opera';
|
|
100
|
+
if (self.navigator && navigator.brave) return 'brave';
|
|
101
|
+
if (/Chrome\//.test(ua)) return 'chrome';
|
|
102
|
+
return 'browser';
|
|
103
|
+
}
|
|
95
104
|
async function onMessage(m) {
|
|
96
105
|
if (!m || typeof m !== 'object') return;
|
|
97
106
|
if (m.type === 'hello') {
|
|
98
107
|
connected = true; agentVersion = m.version || ''; lastError = ''; badge();
|
|
99
108
|
// 0.7.2: the Shellway app refreshed this extension's folder (a newer version): reload once to use the new files.
|
|
100
109
|
const mine = chrome.runtime.getManifest().version;
|
|
101
|
-
if (port) port.postMessage({ type: 'ext', version: mine }); // 0.7.3:
|
|
110
|
+
if (port) port.postMessage({ type: 'ext', version: mine, browser: browserName() }); // 0.7.3: version; 0.8.6: and which browser
|
|
102
111
|
if (m.extVersion && m.extVersion !== mine) {
|
|
103
112
|
const { reloadedFor } = await chrome.storage.local.get({ reloadedFor: '' });
|
|
104
113
|
if (reloadedFor !== m.extVersion) { await chrome.storage.local.set({ reloadedFor: m.extVersion }); chrome.runtime.reload(); }
|
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.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shellway",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
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.
|
|
32
|
+
"shellwayStable": "0.8.5"
|
|
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.
|
|
13
|
+
const AGENT_VERSION = '0.8.7'; // 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);
|
|
@@ -1003,45 +1003,77 @@ const NATIVE_NAME = 'com.getshellway.agent';
|
|
|
1003
1003
|
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
|
+
'kleaokcionmcpjbblalbhkleljimjjmc', // 0.8.7: the Chrome Web Store version (item ID, 27 Nov 2026)
|
|
1006
1007
|
];
|
|
1007
1008
|
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
|
-
|
|
1009
|
+
// 0.8.6 (27 Nov 2026, beta): one link per browser (e.g. Edge and Chrome at the same time). The browser tools use the
|
|
1010
|
+
// current one: the browser the AI chose with browser_use, otherwise the one that connected last (as before).
|
|
1011
|
+
const STORE_EDGE = 'jaebfnkgmaopbkikeigclembnhbdlldc';
|
|
1012
|
+
const STORE_CHROME = 'kleaokcionmcpjbblalbhkleljimjjmc'; // 0.8.7
|
|
1013
|
+
const NO_PENDING = new Map();
|
|
1014
|
+
const ext = { seq: 0, links: new Map(), cur: null, pinned: '',
|
|
1015
|
+
get sock() { return this.cur ? this.cur.sock : null; },
|
|
1016
|
+
get version() { return this.cur ? this.cur.version : ''; },
|
|
1017
|
+
get pending() { return this.cur ? this.cur.pending : NO_PENDING; } };
|
|
1009
1018
|
const extMode = () => { const p = loadPolicy(); return !!p && p.browser === 'extension'; };
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1019
|
+
const browserLabel = (b) => ({ edge: 'Edge', chrome: 'Chrome', brave: 'Brave', opera: 'Opera', chromium: 'Chromium' }[b] || b);
|
|
1020
|
+
function extUse(L) { if (ext.cur !== L) { ext.cur = L; try { activeTarget = null; } catch {} } }
|
|
1021
|
+
function extAttach(sock, rest, hello = {}) {
|
|
1022
|
+
let name = String(hello.browser || '').toLowerCase().replace(/[^a-z0-9-]/g, '').slice(0, 20);
|
|
1023
|
+
if (!name) { const o = String(hello.origin || ''); name = o.includes(STORE_EDGE) ? 'edge' : o.includes(STORE_CHROME) ? 'chrome' : 'browser'; }
|
|
1024
|
+
const old = ext.links.get(name);
|
|
1025
|
+
if (old && old.sock !== sock) { try { old.sock.destroy(); } catch {} }
|
|
1026
|
+
const L = { sock, browser: name, version: '', pending: new Map(), since: Date.now() };
|
|
1027
|
+
ext.links.set(name, L);
|
|
1028
|
+
if (!ext.pinned || ext.pinned === name || !ext.links.has(ext.pinned)) extUse(L);
|
|
1013
1029
|
let buf = rest || '';
|
|
1014
1030
|
const take = () => {
|
|
1015
1031
|
let i;
|
|
1016
1032
|
while ((i = buf.indexOf('\n')) >= 0) {
|
|
1017
1033
|
const line = buf.slice(0, i); buf = buf.slice(i + 1);
|
|
1018
1034
|
let m; try { m = JSON.parse(line); } catch { continue; }
|
|
1019
|
-
if (m && m.type === 'ext') {
|
|
1020
|
-
|
|
1035
|
+
if (m && m.type === 'ext') { // 0.7.3: version running in the browser; 0.8.6: and which browser it is
|
|
1036
|
+
L.version = String(m.version || '').slice(0, 20);
|
|
1037
|
+
const b = String(m.browser || '').toLowerCase().replace(/[^a-z0-9-]/g, '').slice(0, 20);
|
|
1038
|
+
if (b && b !== L.browser) {
|
|
1039
|
+
if (ext.links.get(L.browser) === L) ext.links.delete(L.browser);
|
|
1040
|
+
const other = ext.links.get(b); if (other && other !== L) { try { other.sock.destroy(); } catch {} }
|
|
1041
|
+
L.browser = b; ext.links.set(b, L);
|
|
1042
|
+
if (ext.pinned === b) extUse(L);
|
|
1043
|
+
}
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
const p = m && m.id !== undefined && L.pending.get(m.id);
|
|
1021
1047
|
if (!p) continue;
|
|
1022
|
-
|
|
1048
|
+
L.pending.delete(m.id); clearTimeout(p.timer);
|
|
1023
1049
|
m.ok ? p.ok(m.result) : p.no(new Error(m.error || 'The browser extension reported an error'));
|
|
1024
1050
|
}
|
|
1025
1051
|
};
|
|
1026
1052
|
sock.on('data', (d) => { buf += d.toString('utf8'); take(); });
|
|
1053
|
+
let done = false;
|
|
1027
1054
|
const gone = () => {
|
|
1028
|
-
if (
|
|
1029
|
-
ext.
|
|
1030
|
-
for (const p of
|
|
1031
|
-
|
|
1055
|
+
if (done) return; done = true;
|
|
1056
|
+
if (ext.links.get(L.browser) === L) ext.links.delete(L.browser);
|
|
1057
|
+
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).')); }
|
|
1058
|
+
L.pending.clear();
|
|
1059
|
+
if (ext.cur === L) { const next = (ext.pinned && ext.links.get(ext.pinned)) || [...ext.links.values()].sort((a, b) => b.since - a.since)[0] || null; ext.cur = null; if (next) extUse(next); else { try { activeTarget = null; } catch {} } }
|
|
1032
1060
|
};
|
|
1033
1061
|
sock.on('close', gone); sock.on('error', gone);
|
|
1034
1062
|
take();
|
|
1035
1063
|
}
|
|
1036
1064
|
function extCall(op, args = {}, ms = 30_000) {
|
|
1037
|
-
|
|
1065
|
+
const L = ext.cur;
|
|
1066
|
+
if (!L || !L.sock) return Promise.reject(new Error(EXT_OFF));
|
|
1038
1067
|
return new Promise((ok, no) => {
|
|
1039
1068
|
const id = ++ext.seq;
|
|
1040
|
-
const timer = setTimeout(() => { if (
|
|
1041
|
-
|
|
1042
|
-
|
|
1069
|
+
const timer = setTimeout(() => { if (L.pending.delete(id)) no(new Error(`The browser did not answer (${op}${args.method ? ' ' + args.method : ''})`)); }, ms);
|
|
1070
|
+
L.pending.set(id, { ok, no, timer });
|
|
1071
|
+
L.sock.write(JSON.stringify({ id, op, args }) + '\n');
|
|
1043
1072
|
});
|
|
1044
1073
|
}
|
|
1074
|
+
function extBrowsers() {
|
|
1075
|
+
return [...ext.links.values()].sort((a, b) => a.since - b.since).map((L) => ({ browser: L.browser, name: browserLabel(L.browser), extension_version: L.version || null, in_use: L === ext.cur, connected_since: new Date(L.since).toISOString() }));
|
|
1076
|
+
}
|
|
1045
1077
|
async function extJson(path) {
|
|
1046
1078
|
if (path === '/json/version') return { ok: true };
|
|
1047
1079
|
if (path === '/json/list') return (await extCall('list')).map((t) => ({ ...t, webSocketDebuggerUrl: 'ext:' + t.id }));
|
|
@@ -1063,11 +1095,11 @@ function startExtBridge() {
|
|
|
1063
1095
|
const i = head.indexOf('\n');
|
|
1064
1096
|
if (i < 0) { if (head.length > 4096) sock.destroy(); return; }
|
|
1065
1097
|
sock.off('data', onHead); clearTimeout(t);
|
|
1066
|
-
let given = '';
|
|
1067
|
-
try {
|
|
1098
|
+
let given = '', hello = {};
|
|
1099
|
+
try { hello = JSON.parse(head.slice(0, i)) || {}; given = String(hello.token || ''); } catch {}
|
|
1068
1100
|
const a = Buffer.from(given), b = Buffer.from(token);
|
|
1069
1101
|
if (a.length !== b.length || !timingSafeEqual(a, b)) { sock.destroy(); return; }
|
|
1070
|
-
extAttach(sock, head.slice(i + 1));
|
|
1102
|
+
extAttach(sock, head.slice(i + 1), { browser: hello.browser, origin: hello.origin });
|
|
1071
1103
|
};
|
|
1072
1104
|
sock.on('data', onHead);
|
|
1073
1105
|
sock.on('error', () => {});
|
|
@@ -1092,7 +1124,8 @@ function nativeHost() {
|
|
|
1092
1124
|
if (!info || !info.port) { frame({ type: 'error', message: 'The Shellway app is not running on this computer.' }); setTimeout(() => process.exit(0), 200); return; }
|
|
1093
1125
|
const sock = netConnect(info.port, '127.0.0.1');
|
|
1094
1126
|
let up = false;
|
|
1095
|
-
|
|
1127
|
+
const origin = process.argv.find((a) => String(a).startsWith('chrome-extension://')) || '';
|
|
1128
|
+
sock.on('connect', () => { up = true; sock.write(JSON.stringify({ token: info.token, origin }) + '\n'); frame({ type: 'hello', version: AGENT_VERSION, extVersion: extFolderVersion() }); });
|
|
1096
1129
|
const bye = (msg) => { if (msg) try { frame({ type: 'error', message: msg }); } catch {} setTimeout(() => process.exit(0), 200); };
|
|
1097
1130
|
sock.on('error', () => bye(up ? '' : 'The Shellway app is not running on this computer.'));
|
|
1098
1131
|
sock.on('close', () => bye(''));
|
|
@@ -1155,7 +1188,7 @@ function installExtensionHost() {
|
|
|
1155
1188
|
}
|
|
1156
1189
|
const extConnected = () => !!ext.sock;
|
|
1157
1190
|
const extVersion = () => ext.version;
|
|
1158
|
-
export { nativeHostManifest, nativeHostTargets, extJson, extCall, startExtBridge, extConnected, extVersion, installExtensionHost, SNAPSHOT_JS };
|
|
1191
|
+
export { nativeHostManifest, nativeHostTargets, extJson, extCall, startExtBridge, extConnected, extVersion, extBrowsers, installExtensionHost, SNAPSHOT_JS };
|
|
1159
1192
|
// 0.7.5: one free trial per computer (owner 21 Nov 2026). The computer's own built-in ID (Windows MachineGuid, Mac
|
|
1160
1193
|
// hardware UUID, Linux machine-id) does not change when the computer or the account is renamed. Only a one-way code
|
|
1161
1194
|
// made from it is sent; the ID itself never leaves the computer.
|
|
@@ -1487,7 +1520,7 @@ const browserHandlers = {
|
|
|
1487
1520
|
}
|
|
1488
1521
|
const list = await browserPages();
|
|
1489
1522
|
if (!list.length) return extMode() ? `No Shellway AI tabs are open${ext.version ? ` (Shellway extension v${ext.version})` : ''}. (In the user's own browser the AI sees only the tabs it opened, unless the owner allows "my other tabs" in the Shellway extension.) Open one with browser_open.` : 'No tabs are open.';
|
|
1490
|
-
if (a === 'list' && extMode()) return `(The user's own browser, Shellway extension${ext.version ? ' v' + ext.version : ''})\n` + list.map((t, i) => `${i + 1}. ${t.id === activeTarget ? '(active) ' : ''}${redactTitle(t.title, t.url) || '(no title)'} — ${redactUrl(t.url)}`).join('\n');
|
|
1523
|
+
if (a === 'list' && extMode()) return `(The user's own browser${ext.links.size > 1 && ext.cur ? ` — ${browserLabel(ext.cur.browser)}, one of ${ext.links.size} connected (browser_select)` : ''}, Shellway extension${ext.version ? ' v' + ext.version : ''})\n` + list.map((t, i) => `${i + 1}. ${t.id === activeTarget ? '(active) ' : ''}${redactTitle(t.title, t.url) || '(no title)'} — ${redactUrl(t.url)}`).join('\n');
|
|
1491
1524
|
if (a === 'list') return list.map((t, i) => `${i + 1}. ${t.id === activeTarget ? '(active) ' : ''}${redactTitle(t.title, t.url) || '(no title)'} — ${redactUrl(t.url)}`).join('\n');
|
|
1492
1525
|
const t = list[(Number(index) | 0) - 1];
|
|
1493
1526
|
if (!t) throw new Error(`No tab number ${index}. Use action "list" to see the tabs.`);
|
|
@@ -1495,6 +1528,22 @@ const browserHandlers = {
|
|
|
1495
1528
|
if (a === 'close') { if (readonly) throw new Error('This computer is in read-only mode'); await cdpJson(`/json/close/${t.id}`); if (activeTarget === t.id) activeTarget = null; return `Closed tab ${index}.`; }
|
|
1496
1529
|
throw new Error('action must be list, switch, new, close, back, forward or reload');
|
|
1497
1530
|
},
|
|
1531
|
+
// 0.8.6 (beta): which browsers have the Shellway extension connected, and which one the browser tools use
|
|
1532
|
+
async browser_browsers() {
|
|
1533
|
+
if (!extMode()) return 'Browser control uses Shellway\'s own browser window on this computer (not the extension), so there is nothing to choose.';
|
|
1534
|
+
const list = extBrowsers();
|
|
1535
|
+
if (!list.length) throw new Error(EXT_OFF);
|
|
1536
|
+
return list.map((b) => `${b.in_use ? '(in use) ' : ''}${b.browser} — ${b.name}${b.extension_version ? `, Shellway extension v${b.extension_version}` : ''}`).join('\n')
|
|
1537
|
+
+ (list.length > 1 ? '\nChoose one with browser_select and browser "<name>".' : '');
|
|
1538
|
+
},
|
|
1539
|
+
async browser_use({ browser }) {
|
|
1540
|
+
if (!extMode()) throw new Error('Choosing the browser works only with the Shellway extension (npx shellway policy browser extension).');
|
|
1541
|
+
const want = String(browser || '').toLowerCase().trim();
|
|
1542
|
+
const L = ext.links.get(want) || [...ext.links.values()].find((x) => browserLabel(x.browser).toLowerCase() === want);
|
|
1543
|
+
if (!L) throw new Error(`"${browser}" is not connected. Connected: ${extBrowsers().map((b) => b.browser).join(', ') || 'none'}.`);
|
|
1544
|
+
ext.pinned = L.browser; extUse(L);
|
|
1545
|
+
return `Browser tools now use ${browserLabel(L.browser)}${L.version ? ` (Shellway extension v${L.version})` : ''}. Open a page with browser_open (tabs from the other browser are not used).`;
|
|
1546
|
+
},
|
|
1498
1547
|
};
|
|
1499
1548
|
const BROWSER_METHODS = new Set(Object.keys(browserHandlers));
|
|
1500
1549
|
function checkBrowser(method, params) {
|