webhelm 1.0.33 → 1.0.35

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 CHANGED
@@ -9,9 +9,11 @@
9
9
  | [`lalalic/webhelm`](https://github.com/lalalic/webhelm) | npm Runtime/CLI (including the Daemon-managed Chrome Extension), Skill (`skills/webhelm`), tests | npm `webhelm@latest`; Skill source separately |
10
10
  | [`lalalic/webhelm-actions`](https://github.com/lalalic/webhelm-actions) | Site manifests, ChatGPT/Z.ai/DeepSeek/XHS/etc. Actions | Git checkout at `~/.local/webhelm` |
11
11
 
12
+ The npm Runtime and bundled Chrome Extension use the **same semantic version**. The GitHub npm publishing workflow stamps the Extension manifest from the final npm version, including publish retries, and refuses mismatched packages. The Chrome toolbar popup displays the installed Extension version in its header. Use `node scripts/sync-extension-version.mjs --check` to verify the checkout before publishing.
13
+
12
14
  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
15
 
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 the daemon IPC `workspace-create`, `workspace-resize`, and `workspace-delete`; they may start Sessions via the daemon `start` operation for those pre-provisioned names. Leasing a missing Workspace fails rather than creating it.
16
+ 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
17
 
16
18
  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
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webhelm",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "Agent browser automation in a visible managed Chrome with persistent JavaScript sessions",
5
5
  "type": "module",
6
6
  "bin": {
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,workspaces,keptSites:chromeApi.storage?.local ? await sitesWithStatus(chromeApi) : []};
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();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "WebHelm",
4
- "version": "0.4.13",
4
+ "version": "1.0.35",
5
5
  "description": "Own named Chrome tab-group workspaces and lazy reusable tab pools for browser agents.",
6
6
  "permissions": [
7
7
  "storage",
@@ -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
+ }
@@ -8,7 +8,8 @@
8
8
  :root { color-scheme: light dark; --ink:#182234; --muted:#5f6d81; --border:#e1e7f0; --accent:#345fd5; --accent-light:#edf2ff; --warning:#ae3849; }
9
9
  * { box-sizing: border-box; }
10
10
  body { width:320px; margin:0; padding:12px 14px; background:light-dark(#fff,#172131); color:light-dark(var(--ink),#edf2f9); font:12px/1.4 system-ui,sans-serif; }
11
- .panel-heading { display:flex; align-items:center; justify-content:flex-end; margin-bottom:3px; }
11
+ .panel-heading { display:flex; align-items:center; justify-content:space-between; margin-bottom:3px; }
12
+ .extension-version { font-size:11px; font-variant-numeric:tabular-nums; color:light-dark(var(--muted),#acb8c9); }
12
13
  .daemon-state { font-size:11px; color:light-dark(var(--muted),#acb8c9); white-space:nowrap; }
13
14
  .daemon-state::before { content:""; display:inline-block; vertical-align:middle; width:6px; height:6px; border-radius:50%; background:#8893a1; margin-right:5px; }
14
15
  .daemon-state.online::before { background:#23915c; }
@@ -68,6 +69,7 @@
68
69
  </head>
69
70
  <body>
70
71
  <header class="panel-heading">
72
+ <span id="extension-version" class="extension-version" aria-label="WebHelm version"></span>
71
73
  <span id="daemon-status" class="daemon-state" role="status">Connecting…</span>
72
74
  </header>
73
75
  <strong>Keep Alive Sites</strong>
@@ -1,5 +1,6 @@
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
+ el('extension-version').textContent = `v${chrome.runtime.getManifest().version}`;
3
4
  let confirming = false;
4
5
  let chosen = null;
5
6
  let lastSignature = '';
@@ -250,7 +251,7 @@ async function refresh() {
250
251
  canControlSites=Array.isArray(state.keptSites);
251
252
  currentSites=await readKeptSites(chrome,state.keptSites);
252
253
  renderKeptSites(currentSites,busy,state.connected);
253
- renderWorkspaces(state.workspaces || [],busy,state.connected);
254
+ renderWorkspaces(await readMenuWorkspaces(chrome,state.workspaces || []),busy,state.connected);
254
255
  currentQueue=state.queue||[];
255
256
  queueBusy=busy;queueConnected=state.connected;
256
257
  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 (!entry || entry.poolSize !== wanted) await this.setPoolSize(normalizedName, wanted);
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
  });
@@ -7,6 +7,7 @@ import {LOCAL_ROOT} from './config-paths.mjs';
7
7
 
8
8
  export const EXTENSION_ID='kkkpgmhpoeceojalkpfdidffdfnlgdog';
9
9
  const SOURCE=fileURLToPath(new URL('./extension/',import.meta.url));
10
+ const RUNTIME_VERSION=JSON.parse(fs.readFileSync(new URL('../package.json',import.meta.url),'utf8')).version;
10
11
  const SOURCE_MODE=process.env.WEBHELM_SOURCE_MODE==='1';
11
12
  export const EXTENSION_HOME=path.resolve(process.env.WEBHELM_EXTENSION_HOME ||
12
13
  (SOURCE_MODE ? SOURCE : path.join(LOCAL_ROOT,'extension')));
@@ -25,6 +26,8 @@ function manifest(dir){
25
26
  return data;
26
27
  }
27
28
  export const extensionVersion=manifest(SOURCE).version;
29
+ if(extensionVersion!==RUNTIME_VERSION)
30
+ throw Error(`Bundled WebHelm version mismatch: Runtime ${RUNTIME_VERSION}, Extension ${extensionVersion}`);
28
31
  function canonicalPath(value) {
29
32
  try { return fs.realpathSync(value || ''); }
30
33
  catch { return path.resolve(value || ''); }
@@ -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. */ });