promethios-bridge 1.7.4 → 1.7.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promethios-bridge",
3
- "version": "1.7.4",
3
+ "version": "1.7.5",
4
4
  "description": "Run Promethios agent frameworks locally on your computer with full file, terminal, browser access, ambient context capture, and the always-on-top floating chat overlay. Native Framework Mode supports OpenClaw and other frameworks via the bridge.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -223,8 +223,10 @@ async function captureLinux(snapshot, log) {
223
223
  * approach via PowerShell — but that's expensive, so we only do it when
224
224
  * the active process is a known browser.
225
225
  */
226
- function extractUrlFromBrowserTitle(title, process) {
227
- const proc = (process || '').toLowerCase();
226
+ // NOTE: parameter renamed from 'process' to 'processName' to avoid shadowing
227
+ // the global Node.js process object (which caused process.pid to be undefined).
228
+ function extractUrlFromBrowserTitle(title, processName) {
229
+ const proc = (processName || '').toLowerCase();
228
230
  const isBrowser = proc.includes('chrome') || proc.includes('msedge') ||
229
231
  proc.includes('firefox') || proc.includes('opera') || proc.includes('brave');
230
232
  if (!isBrowser) return null;
@@ -232,26 +234,37 @@ function extractUrlFromBrowserTitle(title, process) {
232
234
  // Try to get URL from Chrome/Edge via PowerShell UIAutomation (Windows only)
233
235
  // This reads the address bar text directly — works even for SPAs
234
236
  // NOTE: Must use -File (temp script) not -Command to preserve multi-line PS syntax.
237
+ // NOTE: Guard $browserProc.MainWindowHandle against IntPtr.Zero (0) — this happens
238
+ // when Chrome is minimized or has no foreground window. FromHandle(0) throws.
235
239
  if (proc.includes('chrome') || proc.includes('msedge')) {
236
240
  try {
237
241
  const os = require('os');
238
242
  const path = require('path');
239
243
  const fs = require('fs');
240
244
  const browserName = proc.includes('msedge') ? 'msedge' : 'chrome';
245
+ // Use global process.pid (Node built-in) for a unique temp file name.
241
246
  const tmpFile = path.join(os.tmpdir(), `promethios_url_${process.pid}.ps1`);
242
247
  const psLines = [
243
248
  'Add-Type -AssemblyName UIAutomationClient',
244
249
  'Add-Type -AssemblyName UIAutomationTypes',
245
- `$browserProc = Get-Process -Name "${browserName}" -ErrorAction SilentlyContinue | Select-Object -First 1`,
246
- 'if ($browserProc) {',
247
- ' $root = [System.Windows.Automation.AutomationElement]::FromHandle($browserProc.MainWindowHandle)',
248
- ' $cond = New-Object System.Windows.Automation.PropertyCondition(',
249
- ' [System.Windows.Automation.AutomationElement]::NameProperty,',
250
- ' "Address and search bar")',
251
- ' $bar = $root.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond)',
252
- ' if ($bar) {',
253
- ' $vp = $bar.GetCurrentPattern([System.Windows.Automation.ValuePattern]::Pattern)',
254
- ' Write-Output $vp.Current.Value',
250
+ // Get all processes with a non-zero MainWindowHandle (i.e. a visible window)
251
+ `$procs = Get-Process -Name "${browserName}" -ErrorAction SilentlyContinue | Where-Object { $_.MainWindowHandle -ne 0 }`,
252
+ 'if ($procs) {',
253
+ ' $browserProc = $procs | Select-Object -First 1',
254
+ ' try {',
255
+ ' $root = [System.Windows.Automation.AutomationElement]::FromHandle($browserProc.MainWindowHandle)',
256
+ ' if ($root) {',
257
+ ' $cond = New-Object System.Windows.Automation.PropertyCondition(',
258
+ ' [System.Windows.Automation.AutomationElement]::NameProperty,',
259
+ ' "Address and search bar")',
260
+ ' $bar = $root.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond)',
261
+ ' if ($bar) {',
262
+ ' $vp = $bar.GetCurrentPattern([System.Windows.Automation.ValuePattern]::Pattern)',
263
+ ' Write-Output $vp.Current.Value',
264
+ ' }',
265
+ ' }',
266
+ ' } catch {',
267
+ ' # Silently ignore UIAutomation errors (window may have closed, etc.)',
255
268
  ' }',
256
269
  '}',
257
270
  ];
@@ -272,8 +285,8 @@ function extractUrlFromBrowserTitle(title, process) {
272
285
  return null; // URL not extractable from title alone
273
286
  }
274
287
 
275
- function extractTabTitle(windowTitle, process) {
276
- const proc = (process || '').toLowerCase();
288
+ function extractTabTitle(windowTitle, processName) {
289
+ const proc = (processName || '').toLowerCase();
277
290
  // Strip browser suffix from title
278
291
  return windowTitle
279
292
  .replace(/ - Google Chrome$/, '')