taskwindow 0.2.7 → 0.2.9

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
@@ -1,5 +1,7 @@
1
1
  # TaskWindow
2
2
 
3
+ [![Add to Chrome](https://img.shields.io/badge/Chrome_Web_Store-Add_to_Chrome-4285F4?logo=googlechrome&logoColor=white)](https://chromewebstore.google.com/detail/adbfpkbjndcpjihceobeegkokblgifpe)
4
+
3
5
  Let any coding agent drive your real, logged-in Chrome — the tabs you're
4
6
  already signed into — without touching the windows you're working in.
5
7
 
@@ -23,14 +25,16 @@ The guided installer:
23
25
 
24
26
  - shows a checkbox list of detected coding agents (choose any combination, or **None**);
25
27
  - installs the background daemon as a login service;
26
- - downloads the extension to the visible `TaskWindow Extension` folder in your home directory;
27
- - opens `chrome://extensions` and waits for a verified connection.
28
+ - opens the [TaskWindow listing on the Chrome Web Store](https://chromewebstore.google.com/detail/adbfpkbjndcpjihceobeegkokblgifpe)
29
+ and waits for a verified connection.
30
+
31
+ In Chrome, click **Add to Chrome**. That is the only click: the extension
32
+ pairs with the daemon on its own, and the installer prints `ready ✓` once
33
+ Chrome is connected. Chrome keeps the extension up to date from the store.
28
34
 
29
- In Chrome, turn on **Developer mode**, click **Load unpacked**, and choose the
30
- `TaskWindow Extension` folder. Chrome requires these two manual clicks for
31
- unpacked extensions. TaskWindow then pairs automatically with a short-lived,
32
- single-use setup code and the installer prints `ready ✓` only after Chrome is
33
- connected.
35
+ Installed the extension first? A setup guide opens with the two commands
36
+ above and turns green by itself as soon as the daemon is running. Coming from
37
+ the installer, nothing opens.
34
38
 
35
39
  ### Try it
36
40
 
@@ -47,12 +51,17 @@ open by a pinned tab no agent can close. Screenshot done. Now try:
47
51
  taskwindow update # update daemon + extension to the latest release, no clicks
48
52
  taskwindow doctor # diagnose daemon, extension, versions, and agents
49
53
  taskwindow pair # create a manual one-time pairing code
50
- taskwindow install # re-run first-time setup; also repairs the extension
54
+ taskwindow install # re-run first-time setup; reopens the store listing if the extension is missing
51
55
  taskwindow install --claude # add Claude Code without repeating setup
56
+ taskwindow install --codex # add Codex without repeating setup
52
57
  taskwindow install --cursor # add Cursor without repeating setup
53
58
  taskwindow install --opencode # add OpenCode without repeating setup
54
59
  ```
55
60
 
61
+ The Codex option requires the `codex` CLI on PATH. It configures the shared
62
+ user-level MCP connection; restart Codex after registration to load the tools.
63
+ If you use `CODEX_HOME`, that directory is respected.
64
+
56
65
  When a newer release exists, agents are told once per session (in the
57
66
  `tabs_create` result and in `taskwindow_status`) to ask you before running
58
67
  `taskwindow update`. The daemon learns this by asking the npm registry for the
@@ -60,7 +69,13 @@ package's latest version at most once a day; create `~/.taskwindow/no-update-che
60
69
  to turn that off.
61
70
 
62
71
  Use `taskwindow install --no-extension` to install only the daemon and selected
63
- agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
72
+ agents. Developing the extension? `taskwindow install --extension <zip>` unpacks
73
+ a build into the `TaskWindow Extension` folder in your home directory for
74
+ `chrome://extensions` → **Load unpacked**, pairing through a one-time code the
75
+ installer leaves in that folder; `taskwindow update` then refreshes those files
76
+ too. Loaded unpacked before the store listing existed? Remove that copy in
77
+ `chrome://extensions` before adding the store one — two copies would keep
78
+ taking the daemon connection from each other. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
64
79
  `Authorization: Bearer <token>`; the token is stored in `~/.taskwindow/token`.
65
80
 
66
81
  ## What the agent gets
@@ -69,11 +84,37 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
69
84
  |---|---|
70
85
  | Status | `taskwindow_status` (daemon/extension readiness and recovery guidance) |
71
86
  | Tabs | `tabs_list`, `tabs_create`, `tabs_close`, `navigate`, `reload` |
72
- | See | `computer` (screenshot + click/type/key/scroll), `read_page`, `find`, `get_page_text` |
87
+ | See | `computer` (screenshot + click/type/key/scroll/idle, plus `human` mode), `read_page`, `find`, `get_page_text` |
73
88
  | Act | `form_input`, `file_upload`, `upload_image`, `javascript_execute` |
74
89
  | Debug | `read_console_messages`, `read_network_requests` |
75
90
  | Efficiency | `browser_batch` (multi-step in one call), `gif_record`, `set_viewport` (responsive view), `shortcuts_*` |
76
91
 
92
+ ## Wonder: when synthetic input is not enough
93
+
94
+ Some pages ignore a perfect click. A single wheel event carrying 1600px gives
95
+ the page two `scroll` events instead of the ninety-nine a real wheel produces,
96
+ so infinite scroll never loads the next batch and lazy images stay blank. A
97
+ cursor that teleports onto a button never fires the `mouseenter` a hover menu
98
+ opens on. `Input.insertText` fires no key events at all, so a type-ahead search
99
+ box stays empty however right the text looks.
100
+
101
+ Pass `human: true` to `computer` and the action is performed the way a hand
102
+ does it: the pointer travels a curved, decelerating path with an overshoot and
103
+ a dwell before the press, a scroll becomes several uneven wheel gestures, and
104
+ text is typed as real per-character key events. The coordinates and deltas you
105
+ asked for are exact — the variation is in the journey, never the destination.
106
+
107
+ It costs a few hundred milliseconds per action, so it is off by default: reach
108
+ for it when an action silently does nothing.
109
+
110
+ There is also `action: "idle"`, which drifts the cursor around for a moment
111
+ without clicking anything; give it a `dy` and it also rocks the wheel by that
112
+ many pixels and puts it back.
113
+
114
+ The resemblance to a person is a side effect of fixing the events, not a
115
+ promise about bot detection — Bézier-curve cursors are the *labelled bot class*
116
+ in the mouse-dynamics literature, so do not build on it as camouflage.
117
+
77
118
  ## How the isolation works
78
119
 
79
120
  - **Task groups & sessions**: every tab the agent creates goes into a blue tab
@@ -100,10 +141,12 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
100
141
  that way), so nothing ever brings a tab forward. Clicking a group in the
101
142
  popover is the only thing that focuses the agent's window — and that is you
102
143
  asking for it.
103
- - **Pairing**: the daemon listens on 127.0.0.1 only. During setup, the CLI gives
104
- the extension a short-lived, single-use code; the long-lived bearer token is
105
- returned only after the code is claimed. Manual codes are available with
106
- `taskwindow pair`.
144
+ - **Pairing**: the daemon listens on 127.0.0.1 only. Chrome stamps every
145
+ request the store extension makes with its fixed extension id as the origin,
146
+ which no other extension or web page can forge, so the daemon hands the
147
+ bearer token to that origin and nothing else. An unpacked development build
148
+ pairs with a short-lived, single-use code the installer leaves in its
149
+ folder; manual codes are available with `taskwindow pair`.
107
150
  - **Agent actions are visible**: a phantom cursor and glow show where the
108
151
  agent is acting; while it does, Chrome shows a
109
152
  *"started debugging this browser"* infobar — an unavoidable Chrome policy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskwindow",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
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/pairing.test.mjs test/extension-bootstrap.test.mjs test/extension-tabs.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-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"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=18"
package/src/agents.js CHANGED
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * Optional per-agent MCP registration, always explicit:
3
3
  * taskwindow install --claude → Claude Code
4
+ * taskwindow install --codex → Codex
4
5
  * taskwindow install --cursor → Cursor
5
- * Nothing is registered unless the matching flag is given.
6
+ * Registered only when selected in the installer or explicitly requested.
6
7
  */
7
8
  import { homedir } from "node:os";
8
9
  import { join, dirname } from "node:path";
9
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
10
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync, chmodSync, statSync } from "node:fs";
10
11
  import { execFileSync } from "node:child_process";
11
12
 
12
13
  function commandExists(command) {
@@ -26,30 +27,62 @@ function readJson(path) {
26
27
  }
27
28
  }
28
29
 
29
- export function inspectAgents() {
30
- const claudePath = join(homedir(), ".claude.json");
31
- const cursorPath = join(homedir(), ".cursor", "mcp.json");
32
- const openCodePath = join(homedir(), ".config", "opencode", "opencode.json");
30
+ const CODEX_TASKWINDOW_SECTION = /^\[mcp_servers\.(?:taskwindow|"taskwindow")\][ \t]*(?:#[^\r\n]*)?\r?$/m;
31
+
32
+ export function codexConfigHasTaskWindow(contents) {
33
+ return CODEX_TASKWINDOW_SECTION.test(contents);
34
+ }
35
+
36
+ export function addCodexAuthorization(contents, token) {
37
+ const match = CODEX_TASKWINDOW_SECTION.exec(contents);
38
+ if (!match) throw new Error("Codex did not create the taskwindow MCP server entry");
39
+ const newline = contents.includes("\r\n") ? "\r\n" : "\n";
40
+ const lineEnd = contents.indexOf("\n", match.index + match[0].length);
41
+ const insertAt = lineEnd === -1 ? contents.length : lineEnd + 1;
42
+ const prefix = lineEnd === -1 ? newline : "";
43
+ const header = `http_headers = { Authorization = ${JSON.stringify(`Bearer ${token}`)} }${newline}`;
44
+ return contents.slice(0, insertAt) + prefix + header + contents.slice(insertAt);
45
+ }
46
+
47
+ function codexConfigPath(homeDir, codexHome = process.env.CODEX_HOME) {
48
+ return join(codexHome || join(homeDir, ".codex"), "config.toml");
49
+ }
50
+
51
+ export function inspectAgents({ homeDir = homedir(), codexHome, hasCommand = commandExists } = {}) {
52
+ const claudePath = join(homeDir, ".claude.json");
53
+ const codexPath = codexConfigPath(homeDir, codexHome);
54
+ const cursorPath = join(homeDir, ".cursor", "mcp.json");
55
+ const openCodePath = join(homeDir, ".config", "opencode", "opencode.json");
33
56
  const claude = readJson(claudePath);
34
57
  const cursor = readJson(cursorPath);
35
58
  const openCode = readJson(openCodePath);
59
+ let codex = "";
60
+ try {
61
+ codex = readFileSync(codexPath, "utf8");
62
+ } catch {}
36
63
  return [
37
64
  {
38
65
  id: "claude",
39
66
  label: "Claude Code",
40
- detected: commandExists("claude") || existsSync(claudePath),
67
+ detected: hasCommand("claude") || existsSync(claudePath),
41
68
  configured: !!claude.mcpServers?.taskwindow,
42
69
  },
70
+ {
71
+ id: "codex",
72
+ label: "Codex",
73
+ detected: hasCommand("codex"),
74
+ configured: codexConfigHasTaskWindow(codex),
75
+ },
43
76
  {
44
77
  id: "cursor",
45
78
  label: "Cursor",
46
- detected: commandExists("cursor") || existsSync(join(homedir(), ".cursor")),
79
+ detected: hasCommand("cursor") || existsSync(join(homeDir, ".cursor")),
47
80
  configured: !!cursor.mcpServers?.taskwindow,
48
81
  },
49
82
  {
50
83
  id: "opencode",
51
84
  label: "OpenCode",
52
- detected: commandExists("opencode") || existsSync(join(homedir(), ".config", "opencode")),
85
+ detected: hasCommand("opencode") || existsSync(join(homeDir, ".config", "opencode")),
53
86
  configured: !!openCode.mcp?.taskwindow,
54
87
  },
55
88
  ];
@@ -75,6 +108,56 @@ export function registerClaude({ port, token }) {
75
108
  console.log("[taskwindow] registered in Claude Code (user scope: available in every repo)");
76
109
  }
77
110
 
111
+ export function registerCodex(
112
+ { port, token },
113
+ { homeDir = homedir(), codexHome, execFile = execFileSync } = {}
114
+ ) {
115
+ const path = codexConfigPath(homeDir, codexHome);
116
+ const existed = existsSync(path);
117
+ const original = existed ? readFileSync(path, "utf8") : null;
118
+ const originalMode = existed ? statSync(path).mode & 0o777 : null;
119
+ const url = `http://127.0.0.1:${port}/mcp`;
120
+ // Use the same config directory for the CLI and the header edit, even when
121
+ // invoked from a project with its own MCP overrides.
122
+ const options = { cwd: dirname(path), timeout: 15_000, stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" };
123
+ mkdirSync(dirname(path), { recursive: true });
124
+ try {
125
+ // Let Codex own its config-table creation/removal, then add the static
126
+ // Authorization header its CLI does not currently expose as a flag.
127
+ if (codexConfigHasTaskWindow(original || "")) {
128
+ execFile("codex", ["mcp", "remove", "taskwindow"], options);
129
+ }
130
+ execFile(
131
+ "codex",
132
+ ["mcp", "add", "taskwindow", "--url", url],
133
+ options
134
+ );
135
+ const configured = readFileSync(path, "utf8");
136
+ // writeFile's mode applies only to newly created files.
137
+ chmodSync(path, 0o600);
138
+ writeFileSync(path, addCodexAuthorization(configured, token), { mode: 0o600 });
139
+ const saved = JSON.parse(execFile("codex", ["mcp", "get", "taskwindow", "--json"], options));
140
+ if (!saved.enabled || saved.transport?.type !== "streamable_http" ||
141
+ saved.transport.url !== url || saved.transport.http_headers?.Authorization !== `Bearer ${token}`) {
142
+ throw new Error("saved server does not match the requested connection");
143
+ }
144
+ } catch (err) {
145
+ try {
146
+ if (existed) {
147
+ writeFileSync(path, original);
148
+ chmodSync(path, originalMode);
149
+ }
150
+ else rmSync(path, { force: true });
151
+ } catch (rollbackErr) {
152
+ throw new Error(`Codex registration failed; restoring ${path} also failed: ${rollbackErr.code || "filesystem error"}`);
153
+ }
154
+ // CLI/config errors can include the complete config and its credentials.
155
+ const reason = err.code === "ENOENT" ? "install the Codex CLI and ensure it is on PATH" : "check the Codex CLI and config.toml";
156
+ throw new Error(`Codex registration failed (${reason}); original configuration restored`);
157
+ }
158
+ console.log(`[taskwindow] registered in Codex (${path}) — restart Codex to load the tools`);
159
+ }
160
+
78
161
  export function registerCursor({ port, token }) {
79
162
  const path = join(homedir(), ".cursor", "mcp.json");
80
163
  let cfg = {};
@@ -114,6 +197,10 @@ export function unregisterAgents({ port }) {
114
197
  execFileSync("claude", ["mcp", "remove", "taskwindow"], { stdio: "ignore" });
115
198
  console.log("[taskwindow] removed from Claude Code");
116
199
  } catch {}
200
+ try {
201
+ execFileSync("codex", ["mcp", "remove", "taskwindow"], { stdio: "ignore" });
202
+ console.log("[taskwindow] removed from Codex");
203
+ } catch {}
117
204
  try {
118
205
  const path = join(homedir(), ".cursor", "mcp.json");
119
206
  const cfg = JSON.parse(readFileSync(path, "utf8"));
package/src/index.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  removeExtensionBootstrap,
18
18
  } from "./service.js";
19
19
  import { PairingManager } from "./pairing.js";
20
+ import { STORE_EXTENSION_ID, STORE_LISTING_URL, STORE_ORIGIN } from "./store.js";
20
21
  import {
21
22
  readHealth,
22
23
  requestPairCode,
@@ -29,7 +30,7 @@ import { UpdateChecker, fetchLatestVersion, isNewer, readUpdateState, updateChec
29
30
  import { createRequire } from "node:module";
30
31
 
31
32
  const { version: VERSION } = createRequire(import.meta.url)("../package.json");
32
- import { inspectAgents, registerClaude, registerCursor, registerOpenCode, unregisterAgents } from "./agents.js";
33
+ import { inspectAgents, registerClaude, registerCodex, registerCursor, registerOpenCode, unregisterAgents } from "./agents.js";
33
34
  import { clearLine, cursorTo, emitKeypressEvents, moveCursor } from "node:readline";
34
35
 
35
36
  // `taskwindow install` manages the login service and offers to register the
@@ -41,10 +42,13 @@ const flags = args.slice(1);
41
42
 
42
43
  const AGENT_CHOICES = [
43
44
  ["claude", "Claude Code", registerClaude],
45
+ ["codex", "Codex", registerCodex],
44
46
  ["cursor", "Cursor", registerCursor],
45
47
  ["opencode", "OpenCode", registerOpenCode],
46
48
  ];
47
49
 
50
+ const AGENT_FLAGS = AGENT_CHOICES.map(([id]) => `--${id}`).join("|");
51
+
48
52
  function selectCodingAgents() {
49
53
  const agentState = new Map(inspectAgents().map((agent) => [agent.id, agent]));
50
54
  const choices = [
@@ -120,14 +124,14 @@ function selectCodingAgents() {
120
124
 
121
125
  async function pickAndRegisterAgents(config) {
122
126
  if (!process.stdin.isTTY) {
123
- console.log("[taskwindow] non-interactive session — register agents with: taskwindow install --claude|--cursor|--opencode");
127
+ console.log(`[taskwindow] non-interactive session — register agents with: taskwindow install ${AGENT_FLAGS}`);
124
128
  return;
125
129
  }
126
130
  console.log("Which coding agents should use TaskWindow?");
127
131
  console.log("Use ↑/↓ to move, space to select, and enter to confirm.");
128
132
  const picks = await selectCodingAgents();
129
133
  if (picks.length === 0) {
130
- console.log("[taskwindow] skipped coding-agent setup — add one later with taskwindow install --claude|--cursor|--opencode");
134
+ console.log(`[taskwindow] skipped coding-agent setup — add one later with taskwindow install ${AGENT_FLAGS}`);
131
135
  return;
132
136
  }
133
137
  const registered = [];
@@ -163,16 +167,67 @@ async function ensureDaemon(config, { forceInstall = false, allowInstall = true
163
167
  return health;
164
168
  }
165
169
 
170
+ function openInChrome(url) {
171
+ try {
172
+ execFileSync("open", ["-a", "Google Chrome", url]);
173
+ return true;
174
+ } catch {
175
+ return false;
176
+ }
177
+ }
178
+
179
+ // Two-stage wait for the extension. Only a store build old enough to predate
180
+ // origin pairing needs the code, and only the user's Chrome clicks decide when
181
+ // we find out — so offer it once the quiet stretch says something is wrong,
182
+ // not up front where it reads as a step everybody must do.
183
+ const CONNECT_GRACE_MS = 60_000;
184
+ const CONNECT_REMAINING_MS = 4 * 60_000;
185
+
186
+ /**
187
+ * Store install (the default): send the user to the listing and wait. The
188
+ * extension pairs itself — the daemon trusts the store extension's origin —
189
+ * so the only click is "Add to Chrome". A zip path takes the unpacked route
190
+ * (development builds), which pairs through the installer-written code file.
191
+ */
166
192
  async function installAndConnectExtension(config, zipPath) {
167
- const pairing = await requestPairCode(config);
168
- installExtension(zipPath, { port: config.port, pairingCode: pairing.code });
193
+ const before = await readHealth(config.port);
194
+ if (before?.extensionConnected) {
195
+ console.log(`[taskwindow] ready ✓ — daemon v${before.version}, extension v${before.extensionVersion || "unknown"} already connected`);
196
+ return true;
197
+ }
198
+ if (zipPath) {
199
+ const pairing = await requestPairCode(config);
200
+ installExtension(zipPath, { port: config.port, pairingCode: pairing.code });
201
+ } else {
202
+ console.log(
203
+ openInChrome(STORE_LISTING_URL)
204
+ ? `[taskwindow] opened the Chrome Web Store listing — click "Add to Chrome"; TaskWindow connects on its own`
205
+ : `[taskwindow] install the extension from ${STORE_LISTING_URL} — click "Add to Chrome"; TaskWindow connects on its own`
206
+ );
207
+ }
169
208
  console.log("[taskwindow] waiting up to 5 minutes for the extension to connect…");
170
- const health = await waitForExtension(config.port);
209
+ let health = await waitForExtension(config.port, CONNECT_GRACE_MS);
210
+
211
+ // Still nothing from a store install: the build Chrome served may predate
212
+ // origin pairing (the Web Store can lag a release by weeks), and that build
213
+ // has no way to pair itself. A code recovers it in seconds. Never on the
214
+ // unpacked path — issuing a second code would invalidate the one the
215
+ // installer just wrote into the extension's folder.
216
+ if (!health && !zipPath) {
217
+ const pairing = await requestPairCode(config).catch(() => null);
218
+ if (pairing) {
219
+ console.log(`[taskwindow] no connection yet. If Chrome has TaskWindow installed, it is an older build that cannot pair itself:`);
220
+ console.log(`[taskwindow] pairing code: ${pairing.code} — open the TaskWindow extension → Settings, enter it, then click Pair`);
221
+ console.log(`[taskwindow] otherwise just finish "Add to Chrome"; still waiting…`);
222
+ }
223
+ health = await waitForExtension(config.port, CONNECT_REMAINING_MS);
224
+ }
225
+
171
226
  if (!health) {
172
- console.error("[taskwindow] extension not connected yet — finish the Chrome steps, then run: taskwindow doctor");
227
+ console.error("[taskwindow] extension not connected yet — finish the Chrome step, then run: taskwindow doctor");
173
228
  return false;
174
229
  }
175
- removeExtensionBootstrap();
230
+ if (zipPath) removeExtensionBootstrap();
176
231
  console.log(`[taskwindow] ready ✓ — daemon v${health.version}, extension v${health.extensionVersion || "unknown"}`);
177
232
  return true;
178
233
  }
@@ -185,6 +240,16 @@ function installedExtensionVersion() {
185
240
  }
186
241
  }
187
242
 
243
+ /**
244
+ * Whether the extension is an unpacked build that `taskwindow update` must
245
+ * refresh on disk. The connected extension's id settles it; with none
246
+ * connected, a leftover unpacked folder does.
247
+ */
248
+ function extensionIsUnpacked(health) {
249
+ if (health?.extensionId) return health.extensionId !== STORE_EXTENSION_ID;
250
+ return installedExtensionVersion() !== null;
251
+ }
252
+
188
253
  /**
189
254
  * The `taskwindow` that PATH resolves to, if it isn't this one. Global installs
190
255
  * under different Node versions (nvm, Homebrew, /usr/local) leave older copies
@@ -240,21 +305,27 @@ async function runDoctor(config) {
240
305
  } else {
241
306
  console.log("✗ Daemon not running — run: taskwindow install");
242
307
  }
243
- if (installedVersion) console.log(`✓ Extension files installed (v${installedVersion}, ${extensionInstallDir()})`);
244
- else console.log("✗ Extension files not installed — run: taskwindow install");
245
308
  if (health?.extensionConnected) {
246
- const versionNote = installedVersion && health.extensionVersion && installedVersion !== health.extensionVersion
247
- ? ` — installed files are v${installedVersion}; run taskwindow update (or reload the extension in Chrome)`
248
- : "";
249
- console.log(`✓ Chrome extension connected (v${health.extensionVersion || "unknown"})${versionNote}`);
309
+ const unpacked = extensionIsUnpacked(health);
310
+ let note = "";
311
+ if (unpacked && installedVersion && health.extensionVersion && installedVersion !== health.extensionVersion) {
312
+ note = ` — installed files are v${installedVersion}; run taskwindow update (or reload the extension in Chrome)`;
313
+ } else if (unpacked) {
314
+ note = ` — loaded unpacked from ${extensionInstallDir()}; the Web Store build updates itself: remove this one in chrome://extensions, then run taskwindow install`;
315
+ } else if (health.extensionVersion && isNewer(health.version, health.extensionVersion)) {
316
+ note = ` — the daemon is v${health.version}; Chrome updates the extension from the Web Store on its own, or click Update on chrome://extensions`;
317
+ }
318
+ console.log(`✓ Chrome extension connected (v${health.extensionVersion || "unknown"}${unpacked ? ", unpacked" : ", Web Store"})${note}`);
319
+ } else if (installedVersion) {
320
+ console.log(`✗ Chrome extension not connected — unpacked files are v${installedVersion} at ${extensionInstallDir()}; enable it in Chrome, then run: taskwindow pair`);
250
321
  } else {
251
- console.log("✗ Chrome extension not connected — enable it in Chrome, then run: taskwindow pair");
322
+ console.log(`✗ Chrome extension not connected — install it from ${STORE_LISTING_URL} (it pairs on its own); already installed from there? that build predates self-pairing: run taskwindow pair`);
252
323
  }
253
324
  for (const agent of agents) {
254
325
  console.log(`${agent.configured ? "✓" : "○"} ${agent.label}${agent.configured ? " configured" : " not configured"}`);
255
326
  }
256
327
  if (!agents.some((agent) => agent.configured)) {
257
- console.log(" Add an agent with: taskwindow install --claude|--cursor|--opencode");
328
+ console.log(` Add an agent with: taskwindow install ${AGENT_FLAGS}`);
258
329
  }
259
330
  return !!health && health.extensionConnected === true;
260
331
  }
@@ -286,9 +357,10 @@ function printManualReload() {
286
357
  * `taskwindow update`: non-interactive, safe to run mid-session (agents run it
287
358
  * with the user's OK). Stage 1 (old CLI): install the newer npm package into
288
359
  * the owning prefix, then re-exec the NEW CLI for stage 2 so the rest runs on
289
- * current code. Stage 2: refresh the extension files, restart the daemon on
290
- * the new code, then have the extension reload itself — daemon first, because
291
- * only the new daemon knows how to ask.
360
+ * current code. Stage 2: restart the daemon on the new code; for an unpacked
361
+ * extension, first refresh its files and afterwards have it reload itself —
362
+ * daemon first, because only the new daemon knows how to ask. A Web Store
363
+ * extension is Chrome's to update, so stage 2 leaves it alone.
292
364
  */
293
365
  async function runUpdate(config, flags) {
294
366
  const force = flags.includes("--force");
@@ -314,10 +386,10 @@ async function runUpdate(config, flags) {
314
386
  }
315
387
  const health = await readHealth(config.port);
316
388
  const filesVersion = installedExtensionVersion();
389
+ const unpacked = extensionIsUnpacked(health);
317
390
  const current =
318
391
  health?.version === VERSION &&
319
- filesVersion === VERSION &&
320
- (!health?.extensionConnected || health.extensionVersion === VERSION);
392
+ (!unpacked || (filesVersion === VERSION && (!health?.extensionConnected || health.extensionVersion === VERSION)));
321
393
  if (current && !force) {
322
394
  console.log(`[taskwindow] already up to date (v${VERSION})${latest ? "" : " as far as the local install goes"}`);
323
395
  return true;
@@ -325,15 +397,22 @@ async function runUpdate(config, flags) {
325
397
  }
326
398
 
327
399
  // Stage 2 (or nothing newer on npm, but the local pieces disagree).
328
- refreshExtensionFiles(zipArg || downloadExtensionZip(VERSION));
329
- console.log(`[taskwindow] extension files refreshed (v${installedExtensionVersion() || "?"}, ${extensionInstallDir()})`);
400
+ const unpacked = zipArg !== null || extensionIsUnpacked(await readHealth(config.port));
401
+ if (unpacked) {
402
+ refreshExtensionFiles(zipArg || downloadExtensionZip(VERSION));
403
+ console.log(`[taskwindow] extension files refreshed (v${installedExtensionVersion() || "?"}, ${extensionInstallDir()})`);
404
+ }
330
405
  await ensureDaemon(config, { forceInstall: true });
331
406
  const health = await waitForExtension(config.port, 90_000);
332
407
  if (!health) {
333
408
  console.log("[taskwindow] the extension did not reconnect — enable TaskWindow in Chrome, then run: taskwindow doctor");
334
409
  return false;
335
410
  }
336
- if (health.extensionVersion !== VERSION) {
411
+ if (!unpacked) {
412
+ if (health.extensionVersion !== VERSION) {
413
+ console.log(`[taskwindow] the extension is v${health.extensionVersion || "?"}; Chrome updates it from the Web Store on its own (or click Update on chrome://extensions)`);
414
+ }
415
+ } else if (health.extensionVersion !== VERSION) {
337
416
  const reload = await requestExtensionReload(config);
338
417
  if (!reload.ok) {
339
418
  printManualReload();
@@ -353,16 +432,16 @@ try {
353
432
  if (verb === "install") {
354
433
  const config = loadConfig();
355
434
  const extFlag = flags.indexOf("--extension");
356
- const hasAgentFlags = flags.includes("--claude") || flags.includes("--cursor") || flags.includes("--opencode");
435
+ const hasAgentFlags = AGENT_CHOICES.some(([id]) => flags.includes(`--${id}`));
357
436
  const fullInstall = extFlag === -1 && !hasAgentFlags;
358
437
  const wantsExtension = extFlag !== -1 || (fullInstall && !flags.includes("--no-extension"));
359
438
 
360
439
  if (fullInstall) {
361
440
  await pickAndRegisterAgents(config);
362
441
  } else if (hasAgentFlags) {
363
- if (flags.includes("--claude")) registerClaude(config);
364
- if (flags.includes("--cursor")) registerCursor(config);
365
- if (flags.includes("--opencode")) registerOpenCode(config);
442
+ for (const [id, , register] of AGENT_CHOICES) {
443
+ if (flags.includes(`--${id}`)) register(config);
444
+ }
366
445
  }
367
446
 
368
447
  if (fullInstall || wantsExtension) {
@@ -467,6 +546,7 @@ const server = http.createServer(async (req, res) => {
467
546
  latestVersion: updates.latest,
468
547
  extensionConnected: bridge.connected,
469
548
  extensionVersion: bridge.lastHello?.version || null,
549
+ extensionId: bridge.lastHello?.id || null,
470
550
  port: config.port,
471
551
  });
472
552
  return;
@@ -523,6 +603,14 @@ const server = http.createServer(async (req, res) => {
523
603
  return;
524
604
  }
525
605
  const code = String(body?.code || "").trim().toUpperCase();
606
+ if (!code) {
607
+ // No code: only the Web Store extension, recognised by the origin Chrome
608
+ // stamps on its requests, is trusted. Not counted as a failed attempt —
609
+ // nothing was guessed.
610
+ if (req.headers.origin === STORE_ORIGIN) sendJson(res, 200, { token: config.token });
611
+ else sendJson(res, 403, { error: "a pairing code is required" });
612
+ return;
613
+ }
526
614
  if (!pairing.claim(code)) {
527
615
  pairFailures.push(Date.now());
528
616
  sendJson(res, 403, { error: "invalid or expired pairing code" });
package/src/store.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The Chrome Web Store listing. A store install has this fixed extension id,
3
+ * and Chrome stamps every request the extension makes with
4
+ * `Origin: chrome-extension://<id>` — another extension cannot forge it, and a
5
+ * process outside Chrome can already read the token file — so a pairing
6
+ * request from this origin gets the daemon token without a code.
7
+ */
8
+ export const STORE_EXTENSION_ID = "adbfpkbjndcpjihceobeegkokblgifpe";
9
+ export const STORE_LISTING_URL = `https://chromewebstore.google.com/detail/${STORE_EXTENSION_ID}`;
10
+ export const STORE_ORIGIN = `chrome-extension://${STORE_EXTENSION_ID}`;
package/src/tools.js CHANGED
@@ -3,6 +3,7 @@ import { randomUUID } from "node:crypto";
3
3
  import { mkdir, writeFile } from "node:fs/promises";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
+ import { STORE_EXTENSION_ID } from "./store.js";
6
7
 
7
8
  const tabId = z.number().int().describe("Tab ID from tabs_list. Defaults to the active tab in your session's task groups.");
8
9
 
@@ -98,13 +99,18 @@ const rawDefs = [
98
99
  "Actions: screenshot (PNG of the viewport, or full page with fullPage), left_click / right_click / " +
99
100
  "middle_click / double_click / triple_click (at x,y), type (text into the focused element), " +
100
101
  "key (named key press, e.g. Enter, Tab, Escape, ArrowLeft, Backspace), scroll (by dx/dy pixels), " +
101
- "mouse_move, wait. Screenshots are in CSS pixels (1 image pixel = 1 coordinate unit, on any display density), so " +
102
- "read x,y straight off the last screenshot. NOTE: while attached, Chrome shows a " +
102
+ "mouse_move, wait, idle. Screenshots are in CSS pixels (1 image pixel = 1 coordinate unit, on any display density), so " +
103
+ "read x,y straight off the last screenshot. " +
104
+ "Pass human:true on a click, scroll, type or mouse_move when the plain synthetic event is not working: it moves the " +
105
+ "pointer along a real path, scrolls as a real wheel gesture, and types real per-key events. That is what lazy-loading " +
106
+ "lists, infinite scroll, hover-revealed menus and type-ahead inputs are waiting for — they ignore a single jumbo " +
107
+ "scroll delta, a teleported cursor and insertText. It costs a few hundred ms per action, so reach for it when an " +
108
+ "action silently does nothing, not by default. NOTE: while attached, Chrome shows a " +
103
109
  '"TaskWindow started debugging this browser" infobar — this is unavoidable with CDP-based control.',
104
110
  inputSchema: {
105
111
  action: z.enum([
106
112
  "screenshot", "left_click", "right_click", "middle_click", "double_click", "triple_click",
107
- "type", "key", "scroll", "mouse_move", "wait",
113
+ "type", "key", "scroll", "mouse_move", "wait", "idle",
108
114
  ]),
109
115
  tabId: tabId.optional(),
110
116
  x: z.number().int().optional().describe("X coordinate in viewport pixels (clicks, scroll origin, mouse_move)"),
@@ -112,7 +118,27 @@ const rawDefs = [
112
118
  text: z.string().optional().describe('Text for the "type" action'),
113
119
  key: z.string().optional().describe('Key name for the "key" action, e.g. "Enter", "a", "ArrowDown"'),
114
120
  dx: z.number().int().optional().describe("Horizontal scroll delta in pixels"),
115
- dy: z.number().int().optional().describe("Vertical scroll delta in pixels (positive scrolls down)"),
121
+ dy: z
122
+ .number()
123
+ .int()
124
+ .optional()
125
+ .describe(
126
+ 'Vertical scroll delta in pixels (positive scrolls down). For "idle", the amplitude of the scroll jiggle, which is scrolled back so the page ends at the same offset.'
127
+ ),
128
+ human: z
129
+ .boolean()
130
+ .optional()
131
+ .describe(
132
+ "Perform the action the way a hand would: a curved, decelerating pointer path with overshoot and a dwell before the press; a scroll split into uneven wheel bursts so every intermediate position fires; per-character key events instead of a bulk insert. Default false."
133
+ ),
134
+ targetWidth: z
135
+ .number()
136
+ .int()
137
+ .positive()
138
+ .optional()
139
+ .describe(
140
+ "With human:true, the width in pixels of the thing being clicked. Fitts's Law uses it to pick the approach speed — a wide button is caught first time, a small one is approached carefully. Default 24."
141
+ ),
116
142
  ms: z.number().int().min(0).max(10_000).optional().describe('Milliseconds for the "wait" action (max 10000)'),
117
143
  fullPage: z.boolean().optional().describe('For "screenshot": capture the whole scrollable page instead of the viewport'),
118
144
  save_to_disk: z
@@ -127,10 +153,11 @@ const rawDefs = [
127
153
  {
128
154
  name: "set_viewport",
129
155
  description:
130
- "Open a responsive view: a dedicated harness window in the current task's tab group rendering the current page in one fixed-size iframe per viewport (media queries, vw/vh and touch resolve exactly per frame; several breakpoints side by side). " +
131
- "Sites that refuse framing automatically fall back to a dedicated emulated window per viewport. Only these windows are affected — other windows and tab groups are untouched. " +
156
+ "Open a responsive view: a harness tab in the current task's tab group rendering the current page in one fixed-size iframe per viewport (media queries, vw/vh and touch resolve exactly per frame; several breakpoints side by side). " +
157
+ "Sites that refuse framing automatically fall back to a dedicated emulated tab per viewport. Only this session's own tabs are affected — the user's tabs, windows and other sessions' groups are untouched. " +
158
+ "Calling it again reuses the same tabs: it re-points them at the new url or viewports rather than opening more, so iterating on a design costs no extra tabs. " +
132
159
  "Each result reports the page's own innerWidth (trust it over screenshots). Typical flow: set_viewport, computer screenshot / read_page on the returned tabIds, then set_viewport with no arguments to close. " +
133
- "Note: frames may render logged out on cookie-partitioned sites — the emulated-window fallback has full cookies.",
160
+ "Note: frames may render logged out on cookie-partitioned sites — the emulated-tab fallback has full cookies. A file:// page needs \"Allow access to file URLs\" on the extension to frame at all; without it every viewport uses the emulated tab and the result says so.",
134
161
  inputSchema: {
135
162
  viewports: z.array(z.object({
136
163
  width: z.number().int().min(200).max(4000),
@@ -329,7 +356,11 @@ function toMcpResult(result) {
329
356
  }
330
357
 
331
358
  export function registerTools(server, { bridge, version, updates = null, logger = console }) {
332
- const notice = () => updates?.notice({ extensionVersion: bridge.lastHello?.version || null }) ?? null;
359
+ const notice = () =>
360
+ updates?.notice({
361
+ extensionVersion: bridge.lastHello?.version || null,
362
+ extensionStore: bridge.lastHello?.id === STORE_EXTENSION_ID,
363
+ }) ?? null;
333
364
  for (const def of toolDefs) {
334
365
  server.registerTool(def.name, { description: def.description, inputSchema: def.inputSchema }, async (args) => {
335
366
  try {
package/src/updates.js CHANGED
@@ -68,20 +68,34 @@ export function updateCheckDisabled(dir, env = process.env) {
68
68
  return env.TASKWINDOW_NO_UPDATE_CHECK === "1" || existsSync(join(dir, OPT_OUT_FILE));
69
69
  }
70
70
 
71
- /** The line agents get. `null` when everything is current (or unknown). */
72
- export function updateNotice({ version, latest, extensionVersion }) {
71
+ /**
72
+ * The line agents get. `null` when everything is current (or unknown).
73
+ * `extensionStore`: the extension came from the Chrome Web Store, so a version
74
+ * behind the daemon is Chrome's to catch up on, not something to run.
75
+ */
76
+ export function updateNotice({ version, latest, extensionVersion, extensionStore = false }) {
73
77
  const problems = [];
78
+ const notes = [];
74
79
  if (latest && isNewer(latest, version)) {
75
80
  problems.push(`TaskWindow ${latest} is available (this daemon is ${version}).`);
76
81
  }
77
82
  if (extensionVersion && extensionVersion !== version) {
78
- problems.push(`The TaskWindow Chrome extension is ${extensionVersion} while the daemon is ${version}.`);
83
+ if (extensionStore && !isNewer(extensionVersion, version)) {
84
+ notes.push(
85
+ `The TaskWindow Chrome extension is ${extensionVersion} while the daemon is ${version}; ` +
86
+ "Chrome updates it from the Web Store on its own (usually within a day) — no command fixes this, " +
87
+ "though the user can click Update on chrome://extensions."
88
+ );
89
+ } else {
90
+ problems.push(`The TaskWindow Chrome extension is ${extensionVersion} while the daemon is ${version}.`);
91
+ }
79
92
  }
80
- if (problems.length === 0) return null;
93
+ if (problems.length === 0) return notes.length ? notes.join(" ") : null;
81
94
  return (
82
95
  `${problems.join(" ")} Ask the user for permission, then run \`taskwindow update\` in a terminal ` +
83
96
  "(about a minute; open tabs survive, the tools reconnect on their own — check with taskwindow_status). " +
84
- "Never run it without the user's OK."
97
+ "Never run it without the user's OK." +
98
+ (notes.length ? ` ${notes.join(" ")}` : "")
85
99
  );
86
100
  }
87
101
 
@@ -105,8 +119,8 @@ export class UpdateChecker {
105
119
  return this.state.latest;
106
120
  }
107
121
 
108
- notice({ extensionVersion } = {}) {
109
- return updateNotice({ version: this.version, latest: this.disabled ? null : this.latest, extensionVersion });
122
+ notice({ extensionVersion, extensionStore } = {}) {
123
+ return updateNotice({ version: this.version, latest: this.disabled ? null : this.latest, extensionVersion, extensionStore });
110
124
  }
111
125
 
112
126
  /** Refresh if the last check is older than a day (or `force`). Never throws. */