channel-worker 1.0.25 → 1.0.27

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.
@@ -550,7 +550,7 @@ class CommandPoller {
550
550
  }
551
551
 
552
552
  async handleTypeText(command) {
553
- const { text, profile_id, url_match } = command.payload || {};
553
+ const { text, profile_id, url_match, focus_selector } = command.payload || {};
554
554
  console.log(`[commands] Typing text (${text?.length} chars) for profile: ${profile_id}`);
555
555
  try {
556
556
  const WebSocket = require('ws');
@@ -587,17 +587,26 @@ class CommandPoller {
587
587
  ws.on('open', async () => {
588
588
  try {
589
589
  await send('DOM.enable');
590
- // Focus the contenteditable editor inside dialog via CDP
590
+ // Focus target element via CDP
591
+ const rawSel = (focus_selector || '');
592
+ const isXpath = rawSel.startsWith('xpath:');
593
+ const sel = rawSel.replace('xpath:', '').replace(/'/g, "\\'").replace(/"/g, '\\"');
591
594
  const focusResult = await send('Runtime.evaluate', {
592
595
  expression: `
593
596
  (function() {
594
- // Try dialog editor first
597
+ let el = null;
598
+ if (${isXpath} && '${sel}') {
599
+ el = document.evaluate("${sel}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
600
+ } else if ('${sel}') {
601
+ el = document.querySelector('${sel}');
602
+ }
603
+ if (el) { el.focus(); el.click(); return 'focused: ' + (el.tagName || '') + ' ' + (el.getAttribute('aria-label') || '').substring(0, 30); }
604
+ // Fallback: dialog editor
595
605
  const dialog = document.querySelector('[role="dialog"]');
596
606
  if (dialog) {
597
607
  const editor = dialog.querySelector('[contenteditable="true"], [role="textbox"]');
598
608
  if (editor) { editor.focus(); editor.click(); return 'focused_dialog'; }
599
609
  }
600
- // Fallback
601
610
  const editors = document.querySelectorAll('[contenteditable="true"], [role="textbox"]');
602
611
  for (const e of editors) {
603
612
  if (e.offsetHeight >= 15) { e.focus(); e.click(); return 'focused_fallback'; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {