webhelm 1.0.33 → 1.0.34
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/README.md +1 -1
- package/package.json +1 -1
- package/runtime/admin.mjs +2 -1
- package/runtime/extension/control-rpc.mjs +3 -1
- package/runtime/extension/manifest.json +1 -1
- package/runtime/extension/popup-data.mjs +14 -0
- package/runtime/extension/popup.mjs +2 -2
- package/runtime/extension/service-worker.mjs +1 -1
- package/runtime/extension/workspace-manager.mjs +28 -5
- package/runtime/extension/workspace-summary.mjs +2 -1
- package/runtime/node-daemon.mjs +5 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
The npm package **does not include** the Skill or site Actions. The Skill's executable uses `npm exec --yes --package=webhelm@latest -- webhelm` to avoid inherited npm lifecycle variable conflicts; its contents may update without a Runtime release.
|
|
13
13
|
|
|
14
|
-
The agent-facing `webhelm` CLI uses only the `WebHelm` Workspace. It intentionally does not accept `--workspace` or expose Workspace management helpers in `session exec`. `session stop --all` only stops WebHelm Sessions. Application services such as Relay provision their own named Workspaces through
|
|
14
|
+
The agent-facing `webhelm` CLI uses only the `WebHelm` Workspace. It intentionally does not accept `--workspace` or expose Workspace management helpers in `session exec`. `session stop --all` only stops WebHelm Sessions. Application services such as Relay provision their own named Workspaces through daemon IPC `workspace-create`, `workspace-resize`, `workspace-configure`, and `workspace-delete`; they may start Sessions via the daemon `start` operation for those pre-provisioned names. To hide a group from the extension toolbar menu without removing its Chrome tab group or Sessions, send `{ "op": "workspace-configure", "name": "WeChat", "show_in_menu": false }`. On creation, `workspace-create` also accepts optional `show_in_menu: false`. The setting is persisted in the Chrome profile; omitted values preserve existing visibility, and the default is visible. `workspace.list` and `workspace.status` still expose hidden groups and their `showInMenu` property; only `workspace.control.status().workspaces` filters hidden groups for the menu. Leasing a missing Workspace fails rather than creating it.
|
|
15
15
|
|
|
16
16
|
Neo Master development uses the Git checkout directly via local symlinks for the CLI, Skill, and Extension; production nodes use published npm Runtime installations. Set `WEBHELM_SOURCE_MODE=1` when running the checkout directly; this loads the Extension from the repository and creates a LaunchAgent that references the repository's CLI without staging an npm Runtime copy.
|
|
17
17
|
|
package/package.json
CHANGED
package/runtime/admin.mjs
CHANGED
|
@@ -3,5 +3,6 @@ import { RUNTIME_DIR } from './config-paths.mjs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
const socketPath=()=>process.env.WEBHELM_SOCKET||path.join(process.env.WEBHELM_RUNTIME_DIR||RUNTIME_DIR,'session-node.sock');
|
|
5
5
|
function request(payload){return new Promise((resolve,reject)=>{const s=net.createConnection(socketPath());let buf='';s.setEncoding('utf8');s.on('connect',()=>s.write(JSON.stringify(payload)+'\n'));s.on('data',d=>{buf+=d;if(!buf.includes('\n'))return;s.end();try{const v=JSON.parse(buf);v.error?reject(Error(v.error)):resolve(v)}catch(e){reject(e)}});s.on('error',reject)})}
|
|
6
|
-
export async function ensureWorkspace(name,size=5){if(typeof name!=='string'||!name.trim())throw TypeError('workspace name must be a non-empty string');if(!Number.isInteger(size)||size<1)throw TypeError('workspace size must be a positive integer');return request({op:'workspace-create',name:name.trim(),pool_size:size})}
|
|
6
|
+
export async function ensureWorkspace(name,size=5,{showInMenu}={}){if(typeof name!=='string'||!name.trim())throw TypeError('workspace name must be a non-empty string');if(!Number.isInteger(size)||size<1)throw TypeError('workspace size must be a positive integer');if(showInMenu!==undefined&&typeof showInMenu!=='boolean')throw TypeError('showInMenu must be a boolean');return request({op:'workspace-create',name:name.trim(),pool_size:size,...(showInMenu===undefined?{}:{show_in_menu:showInMenu})})}
|
|
7
|
+
export async function configureWorkspace(name,{showInMenu}={}){if(typeof name!=='string'||!name.trim())throw TypeError('workspace name must be a non-empty string');if(typeof showInMenu!=='boolean')throw TypeError('showInMenu must be a boolean');return request({op:'workspace-configure',name:name.trim(),show_in_menu:showInMenu})}
|
|
7
8
|
export async function deleteWorkspace(name,{force=false}={}){if(typeof name!=='string'||!name.trim())throw TypeError('workspace name must be a non-empty string');return request({op:'workspace-delete',name:name.trim(),force:Boolean(force)})}
|
|
@@ -22,7 +22,9 @@ export function createControlRpc({control, manager, summarizeWorkspaces, schedul
|
|
|
22
22
|
} catch { return {...session, tabId:null}; }
|
|
23
23
|
})),
|
|
24
24
|
})));
|
|
25
|
-
return {...state,...summary,
|
|
25
|
+
return {...state,...summary,
|
|
26
|
+
workspaces:workspaces.filter(workspace => workspace.showInMenu !== false),
|
|
27
|
+
keptSites:chromeApi.storage?.local ? await sitesWithStatus(chromeApi) : []};
|
|
26
28
|
}
|
|
27
29
|
case "workspace.control.activateTab": {
|
|
28
30
|
const state = await control.status();
|
|
@@ -71,3 +71,17 @@ export function compactQueue(items, {expanded=false,maxHeads=8}={}) {
|
|
|
71
71
|
return {visible,total:all.length,threads:threads.size,behind,
|
|
72
72
|
hidden:all.length-visible.length,uncertain,blocked};
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
// Keep hidden groups out of the toolbar even if a running older worker has
|
|
76
|
+
// not yet reloaded its control RPC. Do not mutate the persisted configuration.
|
|
77
|
+
export const WORKSPACE_STORAGE_KEY='browserWorkspaceManager.v1';
|
|
78
|
+
export function menuWorkspaces(workspaces,config={}) {
|
|
79
|
+
return (Array.isArray(workspaces)?workspaces:[]).filter(workspace =>
|
|
80
|
+
workspace.showInMenu !== false && config?.workspaces?.[workspace.name]?.showInMenu !== false);
|
|
81
|
+
}
|
|
82
|
+
export async function readMenuWorkspaces(chromeApi,workspaces) {
|
|
83
|
+
try {
|
|
84
|
+
const record=await chromeApi.storage.local.get(WORKSPACE_STORAGE_KEY);
|
|
85
|
+
return menuWorkspaces(workspaces,record[WORKSPACE_STORAGE_KEY]);
|
|
86
|
+
} catch { return menuWorkspaces(workspaces); }
|
|
87
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {readKeptSites, setStoredSite, compactQueue} from './popup-data.mjs';
|
|
1
|
+
import {readKeptSites, setStoredSite, compactQueue, readMenuWorkspaces} from './popup-data.mjs';
|
|
2
2
|
const el = id => document.getElementById(id);
|
|
3
3
|
let confirming = false;
|
|
4
4
|
let chosen = null;
|
|
@@ -250,7 +250,7 @@ async function refresh() {
|
|
|
250
250
|
canControlSites=Array.isArray(state.keptSites);
|
|
251
251
|
currentSites=await readKeptSites(chrome,state.keptSites);
|
|
252
252
|
renderKeptSites(currentSites,busy,state.connected);
|
|
253
|
-
renderWorkspaces(state.workspaces || [],busy,state.connected);
|
|
253
|
+
renderWorkspaces(await readMenuWorkspaces(chrome,state.workspaces || []),busy,state.connected);
|
|
254
254
|
currentQueue=state.queue||[];
|
|
255
255
|
queueBusy=busy;queueConnected=state.connected;
|
|
256
256
|
renderQueue(currentQueue,busy,state.connected);
|
|
@@ -89,7 +89,7 @@ globalThis.browserWorkspaceManagerRpc = async (request) => {
|
|
|
89
89
|
// or restore Workspace identities. A browser Session on an extension page must
|
|
90
90
|
// not gain management rights through chrome.runtime.sendMessage().
|
|
91
91
|
const APPLICATION_ONLY_METHODS = new Set([
|
|
92
|
-
"workspace.create", "workspace.resize", "workspace.delete",
|
|
92
|
+
"workspace.create", "workspace.resize", "workspace.configure", "workspace.delete",
|
|
93
93
|
"workspace.ensure", "workspace.migrateDefault",
|
|
94
94
|
"workspace.acquire", "workspace.acquireIdentity",
|
|
95
95
|
"workspace.release", "workspace.releaseAll",
|
|
@@ -208,6 +208,19 @@ export class WorkspaceManager {
|
|
|
208
208
|
await this.saveConfig(config);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
async configure(name, {showInMenu} = {}) {
|
|
212
|
+
const normalizedName = normalizeWorkspaceName(name);
|
|
213
|
+
if (typeof showInMenu !== 'boolean') throw Error('showInMenu must be a boolean');
|
|
214
|
+
return this.workspaceLock(normalizedName).run(async () => {
|
|
215
|
+
const { config, entry } = await this.configuredWorkspace(normalizedName);
|
|
216
|
+
if (!entry) throw Error(`Workspace ${normalizedName} does not exist`);
|
|
217
|
+
config.workspaces[normalizedName] = {...entry, showInMenu};
|
|
218
|
+
await this.saveConfig(config);
|
|
219
|
+
// Visibility is presentation-only: never navigate, close or regroup tabs.
|
|
220
|
+
return this.status(normalizedName);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
211
224
|
async removeConfig(name) {
|
|
212
225
|
const config = await this.loadConfig();
|
|
213
226
|
delete config.workspaces[name];
|
|
@@ -506,11 +519,18 @@ export class WorkspaceManager {
|
|
|
506
519
|
return await this.status(name);
|
|
507
520
|
}
|
|
508
521
|
|
|
509
|
-
async ensureWorkspace(name, poolSize = null) {
|
|
522
|
+
async ensureWorkspace(name, poolSize = null, showInMenu = undefined) {
|
|
510
523
|
const normalizedName = normalizeWorkspaceName(name);
|
|
511
524
|
const { entry } = await this.configuredWorkspace(normalizedName);
|
|
512
525
|
const wanted = normalizePoolSize(poolSize, entry?.poolSize ?? 8);
|
|
513
|
-
if (
|
|
526
|
+
if (showInMenu !== undefined && typeof showInMenu !== 'boolean')
|
|
527
|
+
throw Error('showInMenu must be a boolean');
|
|
528
|
+
if (!entry || entry.poolSize !== wanted || (showInMenu !== undefined && entry.showInMenu !== showInMenu)) {
|
|
529
|
+
const {config} = await this.configuredWorkspace(normalizedName);
|
|
530
|
+
config.workspaces[normalizedName] = {...(entry || {}), poolSize:wanted,
|
|
531
|
+
...(showInMenu === undefined ? {} : {showInMenu})};
|
|
532
|
+
await this.saveConfig(config);
|
|
533
|
+
}
|
|
514
534
|
|
|
515
535
|
const group = await this.workspaceGroup(normalizedName);
|
|
516
536
|
if (!group) return await this.createGroup(normalizedName, wanted);
|
|
@@ -545,6 +565,7 @@ export class WorkspaceManager {
|
|
|
545
565
|
name: normalizedName,
|
|
546
566
|
initialized: false,
|
|
547
567
|
poolSize: entry.poolSize,
|
|
568
|
+
showInMenu: entry.showInMenu !== false,
|
|
548
569
|
reason: "group-missing",
|
|
549
570
|
};
|
|
550
571
|
}
|
|
@@ -556,6 +577,7 @@ export class WorkspaceManager {
|
|
|
556
577
|
initialized: true,
|
|
557
578
|
groupId: group.id,
|
|
558
579
|
poolSize: entry.poolSize,
|
|
580
|
+
showInMenu: entry.showInMenu !== false,
|
|
559
581
|
maxCapacity: entry.poolSize,
|
|
560
582
|
physicalTabs: tabs.length,
|
|
561
583
|
idle: idle.length,
|
|
@@ -640,8 +662,8 @@ export class WorkspaceManager {
|
|
|
640
662
|
);
|
|
641
663
|
}
|
|
642
664
|
|
|
643
|
-
async create(name, poolSize = 8) {
|
|
644
|
-
return await this.ensureWorkspace(name, normalizePoolSize(poolSize));
|
|
665
|
+
async create(name, poolSize = 8, showInMenu = undefined) {
|
|
666
|
+
return await this.ensureWorkspace(name, normalizePoolSize(poolSize), showInMenu);
|
|
645
667
|
}
|
|
646
668
|
|
|
647
669
|
async resize(name, poolSize) {
|
|
@@ -833,7 +855,8 @@ export class WorkspaceManager {
|
|
|
833
855
|
async rpc(request) {
|
|
834
856
|
const method = String(request?.method || "");
|
|
835
857
|
const args = request?.args || {};
|
|
836
|
-
if (method === "workspace.create") return await this.create(args.name, args.poolSize);
|
|
858
|
+
if (method === "workspace.create") return await this.create(args.name, args.poolSize, args.showInMenu);
|
|
859
|
+
if (method === "workspace.configure") return await this.configure(args.name, {showInMenu:args.showInMenu});
|
|
837
860
|
if (method === "workspace.ensure") return await this.ensure(args.name, args.poolSize);
|
|
838
861
|
if (method === "workspace.status") return await this.status(args.name);
|
|
839
862
|
if (method === "workspace.list") return await this.list();
|
|
@@ -3,6 +3,7 @@ export function summarizeWorkspaces(workspaces, sessions = []) {
|
|
|
3
3
|
const configured = workspaces.map(workspace => ({
|
|
4
4
|
name: workspace.name,
|
|
5
5
|
initialized: Boolean(workspace.initialized),
|
|
6
|
+
showInMenu: workspace.showInMenu !== false,
|
|
6
7
|
poolSize: Number.isInteger(workspace.poolSize) ? workspace.poolSize : null,
|
|
7
8
|
idleTabs: workspace.initialized ? workspace.idle : null,
|
|
8
9
|
leasedTabs: workspace.initialized ? workspace.leased : null,
|
|
@@ -17,7 +18,7 @@ export function summarizeWorkspaces(workspaces, sessions = []) {
|
|
|
17
18
|
if (configuredNames.has(session.workspace)) continue;
|
|
18
19
|
configuredNames.add(session.workspace);
|
|
19
20
|
configured.push({
|
|
20
|
-
name: session.workspace, initialized: false, poolSize: null, idleTabs: null,
|
|
21
|
+
name: session.workspace, initialized: false, showInMenu: true, poolSize: null, idleTabs: null,
|
|
21
22
|
leasedTabs: null, available: null, sessions: sessions.filter(s => s.workspace === session.workspace),
|
|
22
23
|
reason: 'not-configured',
|
|
23
24
|
});
|
package/runtime/node-daemon.mjs
CHANGED
|
@@ -569,7 +569,10 @@ function heartbeatSession(sid){
|
|
|
569
569
|
async function workspaceOp(req) {
|
|
570
570
|
if (typeof req.name !== 'string' || !req.name.trim()) throw Error('workspace name required');
|
|
571
571
|
if (req.op === 'workspace-create')
|
|
572
|
-
return extensionCall(null,'workspace.create',{name:req.name,poolSize:req.pool_size ?? 8
|
|
572
|
+
return extensionCall(null,'workspace.create',{name:req.name,poolSize:req.pool_size ?? 8,
|
|
573
|
+
showInMenu:req.show_in_menu});
|
|
574
|
+
if (req.op === 'workspace-configure')
|
|
575
|
+
return extensionCall(null,'workspace.configure',{name:req.name,showInMenu:req.show_in_menu});
|
|
573
576
|
if (req.op === 'workspace-resize')
|
|
574
577
|
return extensionCall(null,'workspace.resize',{name:req.name,poolSize:req.pool_size});
|
|
575
578
|
if (req.op === 'workspace-delete')
|
|
@@ -735,7 +738,7 @@ const siteKeepalive = createSiteKeepaliveScheduler({
|
|
|
735
738
|
},
|
|
736
739
|
});
|
|
737
740
|
|
|
738
|
-
export async function handle(req){switch(req.op){case'ping':return {ok:true,pid:process.pid,version:PACKAGE_VERSION,queue_paused:process.env.WEBHELM_CHATGPT_QUEUE_PAUSED==='1',session_count:sessions.size,managed_chrome:managedChrome||{profile_dir:PROFILE_DIR, endpoint:process.env.WEBHELM_CDP_URL||'http://127.0.0.1:9222',reused:true},chrome_guard:managedChromeGuard.status()};case'guard-check':{let status=await managedChromeGuard.tick();for(let retry=0;retry<6 && status.status!=='healthy' && !status.skipped;retry++){await delay(800);status=await managedChromeGuard.tick();}if(status.status!=='healthy' && !status.skipped)throw Error(`WebHelm Chrome health degraded: ${status.error||status.status}`);return {ok:true,chrome_guard:status};}case'heartbeat':return heartbeatSession(req.session_id);case'list':return {session_count:sessions.size,sessions:[...sessions.values()].map(s=>({session_id:s.session_id,workspace:s.workspace,target_id:s.targetId,last_used_at:s.last_used_at}))};case'start':return createSession(req);case'exec':return execute(req);case'stop':return stopSession(req.session_id);case'stop-all':return stopAllSessions();case'stop-workspace':{if(typeof req.workspace!=='string'||!req.workspace.trim())throw Error('workspace required');return stopWorkspaceSessions(req.workspace)}case'capacity':return workspaceCapacity(req);case'workspace-create':case'workspace-resize':case'workspace-delete':return workspaceOp(req);case'chatgpt-new-turn-enqueue':return getChatGPTQueue().enqueue(req.config);case'queue-list':return getChatGPTQueue().list();case'queue-cancel':return getChatGPTQueue().cancel(req.queue_id);case'platform-run':return runPlatform(req);default:throw Error(`unknown op: ${req.op}`)}}
|
|
741
|
+
export async function handle(req){switch(req.op){case'ping':return {ok:true,pid:process.pid,version:PACKAGE_VERSION,queue_paused:process.env.WEBHELM_CHATGPT_QUEUE_PAUSED==='1',session_count:sessions.size,managed_chrome:managedChrome||{profile_dir:PROFILE_DIR, endpoint:process.env.WEBHELM_CDP_URL||'http://127.0.0.1:9222',reused:true},chrome_guard:managedChromeGuard.status()};case'guard-check':{let status=await managedChromeGuard.tick();for(let retry=0;retry<6 && status.status!=='healthy' && !status.skipped;retry++){await delay(800);status=await managedChromeGuard.tick();}if(status.status!=='healthy' && !status.skipped)throw Error(`WebHelm Chrome health degraded: ${status.error||status.status}`);return {ok:true,chrome_guard:status};}case'heartbeat':return heartbeatSession(req.session_id);case'list':return {session_count:sessions.size,sessions:[...sessions.values()].map(s=>({session_id:s.session_id,workspace:s.workspace,target_id:s.targetId,last_used_at:s.last_used_at}))};case'start':return createSession(req);case'exec':return execute(req);case'stop':return stopSession(req.session_id);case'stop-all':return stopAllSessions();case'stop-workspace':{if(typeof req.workspace!=='string'||!req.workspace.trim())throw Error('workspace required');return stopWorkspaceSessions(req.workspace)}case'capacity':return workspaceCapacity(req);case'workspace-create':case'workspace-configure':case'workspace-resize':case'workspace-delete':return workspaceOp(req);case'chatgpt-new-turn-enqueue':return getChatGPTQueue().enqueue(req.config);case'queue-list':return getChatGPTQueue().list();case'queue-cancel':return getChatGPTQueue().cancel(req.queue_id);case'platform-run':return runPlatform(req);default:throw Error(`unknown op: ${req.op}`)}}
|
|
739
742
|
export function serve(conn) {
|
|
740
743
|
let buffer = '', dispatched = false;
|
|
741
744
|
conn.on('error',()=>{ /* A disconnected client must not crash the daemon. */ });
|