taskwindow 0.2.14 → 0.2.16

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.
Files changed (3) hide show
  1. package/README.md +11 -3
  2. package/package.json +2 -2
  3. package/src/tools.js +71 -9
package/README.md CHANGED
@@ -92,7 +92,7 @@ taking the daemon connection from each other. For another MCP client, connect to
92
92
  | Area | Tools |
93
93
  |---|---|
94
94
  | Status | `taskwindow_status` (daemon/extension readiness and recovery guidance) |
95
- | Tabs | `tabs_list`, `tabs_create`, `tabs_close`, `navigate`, `reload` |
95
+ | Tabs | `tabs_list`, `tabs_create`, `tabs_close`, `navigate`, `reload`, `dialog` (answer an alert, confirm, prompt or "Leave site?") |
96
96
  | See | `computer` (screenshot + click/type/key/scroll/idle, plus `human` mode), `read_page`, `find`, `get_page_text` |
97
97
  | Act | `form_input`, `file_upload`, `upload_image`, `javascript_execute` |
98
98
  | Debug | `read_console_messages`, `read_network_requests` |
@@ -162,8 +162,16 @@ in the mouse-dynamics literature, so do not build on it as camouflage.
162
162
  folder; manual codes are available with `taskwindow pair`.
163
163
  - **Agent actions are visible**: a phantom cursor and glow show where the
164
164
  agent is acting; while it does, Chrome shows a
165
- *"started debugging this browser"* infobar — an unavoidable Chrome policy
166
- for this capability, same as Claude's own extension.
165
+ *"started debugging this browser"* infobar. Ordinary tabs disconnect after
166
+ 10 seconds with no browser tool calls running, and Chrome dismisses the banner
167
+ about five seconds later. Tabs stay open and reconnect automatically on use.
168
+ Tabs with `render: true` and responsive fallback tabs keep their connection
169
+ while open, since rendering and viewport emulation depend on it; those keep
170
+ the banner visible.
171
+ - **Debug capture**: collected console messages and network requests survive
172
+ an idle disconnect, but capture pauses while disconnected. Navigate or reload
173
+ to capture a fresh page load. For continuous capture between calls, reload
174
+ with `render: true`; this also keeps Chrome's debugging banner visible.
167
175
 
168
176
  ## Requirements & limits
169
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskwindow",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "TaskWindow local daemon: bridges the TaskWindow Chrome extension to any MCP client over Streamable HTTP",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "start": "node src/index.js",
12
- "test": "node --test test/agents.test.mjs test/pairing.test.mjs test/extension-bootstrap.test.mjs test/extension-connection.test.mjs test/extension-idle.test.mjs test/extension-tabs.test.mjs test/extension-responsive.test.mjs test/extension-human.test.mjs test/bridge.test.mjs test/tool-contract.test.mjs test/updates.test.mjs && node test/run.mjs"
12
+ "test": "node --test test/agents.test.mjs test/pairing.test.mjs test/extension-bootstrap.test.mjs test/extension-connection.test.mjs test/extension-idle.test.mjs test/extension-cdp.test.mjs test/extension-dialog.test.mjs test/extension-tabs.test.mjs test/extension-responsive.test.mjs test/extension-human.test.mjs test/extension-click-ref.test.mjs test/bridge.test.mjs test/tool-contract.test.mjs test/updates.test.mjs && node test/run.mjs"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=18"
package/src/tools.js CHANGED
@@ -4,6 +4,26 @@ import { mkdir, writeFile } from "node:fs/promises";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { STORE_EXTENSION_ID } from "./store.js";
7
+ import { compareVersions } from "./updates.js";
8
+
9
+ /** The first extension that clicks an element by ref or selector. */
10
+ export const CLICK_BY_REF_SINCE = "0.2.16";
11
+ const ON_ELEMENT = new Set(["left_click", "right_click", "middle_click", "double_click", "triple_click", "mouse_move"]);
12
+
13
+ /**
14
+ * A click by element sent to an extension that predates it would click at
15
+ * x ?? 0, y ?? 0, the page's top-left corner, since an older computer() ignores
16
+ * ref. Chrome updates the extension from the Web Store on its own schedule, so
17
+ * a new daemon meets an old extension for a while: refuse there instead.
18
+ */
19
+ export function clickByRefRefusal(tool, args, extensionVersion) {
20
+ if (tool !== "computer" || !ON_ELEMENT.has(args?.action) || (!args.ref && !args.selector)) return null;
21
+ if (extensionVersion && compareVersions(extensionVersion, CLICK_BY_REF_SINCE) >= 0) return null;
22
+ return (
23
+ `This TaskWindow extension (${extensionVersion ? `v${extensionVersion}` : "version unknown"}) clicks by x,y only; clicking by ref needs v${CLICK_BY_REF_SINCE}, ` +
24
+ "which Chrome installs from the Web Store on its own. Until then take a screenshot and click at x,y."
25
+ );
26
+ }
7
27
 
8
28
  const tabId = z.number().int().describe("Tab ID from tabs_list. Defaults to the active tab in your session's task groups.");
9
29
 
@@ -26,7 +46,17 @@ const render = z
26
46
  "tab paints barely at all, which most pages don't mind. Some only fetch or draw once seen, so turn this on if you suspect the page " +
27
47
  "needs a viewer: skeleton placeholders or spinners that never resolve, a chart area that stays empty, an animation stuck mid-way, " +
28
48
  "or a screenshot that times out. On a page already showing that, reload with render: true. It stays on for the tab, across " +
29
- "navigations. The tab is still never made active and never takes focus."
49
+ "navigations. This keeps Chrome's debugging banner visible until the tab closes. The tab is still never made active and never takes focus."
50
+ );
51
+
52
+ // A page with unsaved changes holds a navigation behind "Leave site?".
53
+ const onUnsaved = z
54
+ .enum(["keep", "discard"])
55
+ .optional()
56
+ .describe(
57
+ 'What to do if the page has unsaved changes and asks "Leave site?" first. "keep" (default): stay, so nothing is lost; ' +
58
+ 'the call returns "Blocked" and the tab is left as it was. "discard": leave and throw the changes away. ' +
59
+ "Only discard once you know the changes don't matter (e.g. you saved them, or they were a test)."
30
60
  );
31
61
 
32
62
  // Result contract with the extension: {text?, image?: {data, mimeType}, data?}.
@@ -90,28 +120,46 @@ const rawDefs = [
90
120
  {
91
121
  name: "navigate",
92
122
  description:
93
- "Navigate a tab to a URL. Waits (up to 10s) for the load event, then returns the tab's URL and title.",
94
- inputSchema: { url: z.string().url(), tabId: tabId.optional(), render },
123
+ "Navigate a tab to a URL. Waits (up to 10s) for the load event, then returns the tab's URL and title. " +
124
+ "If the page has unsaved changes it answers \"Blocked\" instead of leaving (see onUnsaved).",
125
+ inputSchema: { url: z.string().url(), tabId: tabId.optional(), render, onUnsaved },
95
126
  timeoutMs: 30_000,
96
127
  },
97
128
  {
98
129
  name: "reload",
99
130
  description:
100
131
  "Reload a tab in place, like the browser's reload button, and wait (up to 10s) for the load event. " +
101
- "Use this — not tabs_create — to refresh a page you already have open.",
132
+ "Use this — not tabs_create — to refresh a page you already have open. " +
133
+ "If the page has unsaved changes it answers \"Blocked\" instead of reloading (see onUnsaved).",
102
134
  inputSchema: {
103
135
  tabId: tabId.optional(),
104
136
  bypassCache: z.boolean().optional().describe("Skip the HTTP cache, like a hard reload (default false)"),
105
137
  render,
138
+ onUnsaved,
106
139
  },
107
140
  timeoutMs: 30_000,
108
141
  },
142
+ {
143
+ name: "dialog",
144
+ description:
145
+ "Answer the dialog a page is showing: an alert, a confirm, a prompt, or the \"Leave site? Changes you made may not be saved\" " +
146
+ "confirmation. Chrome draws these outside the page, so screenshots never show them, and the page can do nothing until one is " +
147
+ "answered. You need this when a tool result says a dialog opened or is blocking the tab (tabs_list marks such tabs too). " +
148
+ "accept = OK / Leave; dismiss = Cancel / Stay. Dismiss is the safe answer when unsure: it never discards work or confirms an action.",
149
+ inputSchema: {
150
+ action: z.enum(["accept", "dismiss"]),
151
+ promptText: z.string().optional().describe("For a prompt dialog with action accept: the text to answer with"),
152
+ tabId: tabId.optional(),
153
+ },
154
+ timeoutMs: 20_000,
155
+ },
109
156
  {
110
157
  name: "computer",
111
158
  description:
112
159
  "Screenshot and low-level mouse/keyboard control of a tab via the Chrome DevTools Protocol. " +
113
160
  "Actions: screenshot (PNG of the viewport, or full page with fullPage), left_click / right_click / " +
114
- "middle_click / double_click / triple_click (at x,y), type (text into the focused element), " +
161
+ "middle_click / double_click / triple_click (at x,y, or on an element: pass its ref from read_page/find instead), " +
162
+ "type (text into the focused element), " +
115
163
  "key (named key press, e.g. Enter, Tab, Escape, ArrowLeft, Backspace), scroll (by dx/dy pixels), " +
116
164
  "mouse_move, wait, idle. Screenshots are in CSS pixels (1 image pixel = 1 coordinate unit, on any display density), so " +
117
165
  "read x,y straight off the last screenshot. " +
@@ -122,7 +170,7 @@ const rawDefs = [
122
170
  "speed matters more than realism. A native <select> opens a browser menu that clicks and keys cannot drive: " +
123
171
  "set it with form_input. A scroll result reports how far the content actually moved, which on an infinite list " +
124
172
  "can be less than asked. NOTE: while attached, Chrome shows a " +
125
- '"TaskWindow started debugging this browser" infobar — this is unavoidable with CDP-based control.',
173
+ '"TaskWindow started debugging this browser" infobar. Ordinary tabs disconnect after 10 seconds with no running browser calls; rendering and emulated-viewport tabs stay connected.',
126
174
  inputSchema: {
127
175
  action: z.enum([
128
176
  "screenshot", "left_click", "right_click", "middle_click", "double_click", "triple_click",
@@ -131,6 +179,13 @@ const rawDefs = [
131
179
  tabId: tabId.optional(),
132
180
  x: z.number().int().optional().describe("X coordinate in viewport pixels (clicks, scroll origin, mouse_move)"),
133
181
  y: z.number().int().optional().describe("Y coordinate in viewport pixels"),
182
+ ref: z
183
+ .string()
184
+ .optional()
185
+ .describe(
186
+ "For clicks and mouse_move: the element's ref from read_page/find (e.g. e42), in place of x,y. Clicks its centre, scrolling it into view; refused when something covers it."
187
+ ),
188
+ selector: z.string().optional().describe("For clicks and mouse_move: a CSS selector, as a fallback when no ref is available"),
134
189
  text: z.string().optional().describe('Text for the "type" action'),
135
190
  key: z.string().optional().describe('Key name for the "key" action, e.g. "Enter", "a", "ArrowDown"'),
136
191
  dx: z.number().int().optional().describe("Horizontal scroll delta in pixels"),
@@ -188,7 +243,7 @@ const rawDefs = [
188
243
  name: "read_page",
189
244
  description:
190
245
  "Structured accessibility-style snapshot of the page: a text tree of interactive elements and content, " +
191
- "each labelled with a ref (e.g. e42) you can pass to form_input / file_upload. Cheaper and more reliable " +
246
+ "each labelled with a ref (e.g. e42) you can pass to computer clicks, form_input and file_upload. Cheaper and more reliable " +
192
247
  "than a screenshot for forms and navigation.",
193
248
  inputSchema: { tabId: tabId.optional() },
194
249
  timeoutMs: 20_000,
@@ -274,7 +329,8 @@ const rawDefs = [
274
329
  name: "read_console_messages",
275
330
  description:
276
331
  "Read console output (console.*, errors, warnings) captured from the tab. Capture is CDP-based, so it covers " +
277
- "messages emitted while TaskWindow has been driving the tab.",
332
+ "messages emitted while TaskWindow is attached. Capture pauses after 10 seconds with no running browser calls; " +
333
+ "previously captured messages are kept. For continuous capture, reload with render:true (keeps Chrome's debugging banner visible).",
278
334
  inputSchema: {
279
335
  tabId: tabId.optional(),
280
336
  pattern: z.string().optional().describe("Only messages matching this regular expression"),
@@ -286,7 +342,9 @@ const rawDefs = [
286
342
  {
287
343
  name: "read_network_requests",
288
344
  description:
289
- "Read network requests observed in the tab while TaskWindow was attached: method, URL, status, type and size.",
345
+ "Read network requests observed in the tab while TaskWindow was attached: method, URL, status, type and size. " +
346
+ "Capture pauses after 10 seconds with no running browser calls; previously captured requests are kept. " +
347
+ "Navigate or reload to capture a fresh load; for continuous capture, reload with render:true (keeps Chrome's debugging banner visible).",
290
348
  inputSchema: {
291
349
  tabId: tabId.optional(),
292
350
  pattern: z.string().optional().describe("Only requests whose URL matches this regular expression"),
@@ -436,6 +494,8 @@ export function registerTools(server, { bridge, version, updates = null, logger
436
494
  // it. The retry with that token (same task and url) then gets the tab
437
495
  // the first call opened, not a second tab in a second group.
438
496
  if (def.name === "tabs_create" && !forwardedArgs.sessionToken) forwardedArgs.sessionToken = randomUUID();
497
+ const refusal = clickByRefRefusal(def.name, forwardedArgs, bridge.lastHello?.version);
498
+ if (refusal) throw new Error(refusal);
439
499
  let result;
440
500
  try {
441
501
  result = await bridge.sendTool(def.name, forwardedArgs, def.timeoutMs);
@@ -521,6 +581,8 @@ async function runBatch({ steps, sessionToken }, bridge, logger) {
521
581
  if (!parsed.success) {
522
582
  throw new Error(`invalid params: ${parsed.error.issues.map((e) => `${e.message} at ${e.path.join(".") || "(root)"}`).join("; ")}`);
523
583
  }
584
+ const refusal = clickByRefRefusal(tool, parsed.data, bridge.lastHello?.version);
585
+ if (refusal) throw new Error(refusal);
524
586
  const result = await bridge.sendTool(tool, parsed.data, def.timeoutMs);
525
587
  results.push({ step: i + 1, tool, ok: true, result });
526
588
  } catch (err) {