taskwindow 0.2.11 → 0.2.13

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,8 +9,8 @@ already signed into — without touching the windows you're working in.
9
9
  [coding agent] --MCP--> [TaskWindow daemon] --WebSocket--> [Chrome extension] --CDP--> [your tab]
10
10
  ```
11
11
 
12
- Works with Claude Code, Cursor, Windsurf, Codex, or any client that speaks
13
- MCP over HTTP.
12
+ Works with Claude Code, Cursor, Windsurf, Codex, OpenCode, OpenClaw, or any
13
+ client that speaks MCP over HTTP.
14
14
 
15
15
  ## Setup (5 minutes)
16
16
 
@@ -56,8 +56,17 @@ taskwindow install --claude # add Claude Code without repeating setup
56
56
  taskwindow install --codex # add Codex without repeating setup
57
57
  taskwindow install --cursor # add Cursor without repeating setup
58
58
  taskwindow install --opencode # add OpenCode without repeating setup
59
+ taskwindow install --openclaw # add OpenClaw without repeating setup
59
60
  ```
60
61
 
62
+ The OpenClaw option requires the `openclaw` CLI on PATH and saves the server
63
+ as `mcp.servers.taskwindow` in the config that CLI uses (`OPENCLAW_CONFIG_PATH`
64
+ and `OPENCLAW_STATE_DIR` are respected). A running Gateway picks it up without
65
+ a restart. The Gateway has to run on the same machine as Chrome, since the
66
+ daemon only listens on 127.0.0.1. `openclaw mcp doctor` warns that the
67
+ Authorization header holds a literal token. That is expected: OpenClaw headers
68
+ cannot read a file, and the token only opens the local daemon.
69
+
61
70
  The Codex option requires the `codex` CLI on PATH. It configures the shared
62
71
  user-level MCP connection; restart Codex after registration to load the tools.
63
72
  If you use `CODEX_HOME`, that directory is respected.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskwindow",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
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-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-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
@@ -3,6 +3,8 @@
3
3
  * taskwindow install --claude → Claude Code
4
4
  * taskwindow install --codex → Codex
5
5
  * taskwindow install --cursor → Cursor
6
+ * taskwindow install --opencode → OpenCode
7
+ * taskwindow install --openclaw → OpenClaw
6
8
  * Registered only when selected in the installer or explicitly requested.
7
9
  */
8
10
  import { homedir } from "node:os";
@@ -48,7 +50,14 @@ function codexConfigPath(homeDir, codexHome = process.env.CODEX_HOME) {
48
50
  return join(codexHome || join(homeDir, ".codex"), "config.toml");
49
51
  }
50
52
 
51
- export function inspectAgents({ homeDir = homedir(), codexHome, hasCommand = commandExists } = {}) {
53
+ // OpenClaw's own resolution, minus profiles: OPENCLAW_CONFIG_PATH wins, else
54
+ // openclaw.json in OPENCLAW_STATE_DIR (default ~/.openclaw).
55
+ function openClawConfigPath(homeDir, env = process.env) {
56
+ if (env.OPENCLAW_CONFIG_PATH?.trim()) return env.OPENCLAW_CONFIG_PATH.trim();
57
+ return join(env.OPENCLAW_STATE_DIR?.trim() || join(homeDir, ".openclaw"), "openclaw.json");
58
+ }
59
+
60
+ export function inspectAgents({ homeDir = homedir(), codexHome, hasCommand = commandExists, env = process.env } = {}) {
52
61
  const claudePath = join(homeDir, ".claude.json");
53
62
  const codexPath = codexConfigPath(homeDir, codexHome);
54
63
  const cursorPath = join(homeDir, ".cursor", "mcp.json");
@@ -56,6 +65,8 @@ export function inspectAgents({ homeDir = homedir(), codexHome, hasCommand = com
56
65
  const claude = readJson(claudePath);
57
66
  const cursor = readJson(cursorPath);
58
67
  const openCode = readJson(openCodePath);
68
+ // OpenClaw writes plain JSON; a hand-edited JSON5 file reads as unconfigured.
69
+ const openClaw = readJson(openClawConfigPath(homeDir, env));
59
70
  let codex = "";
60
71
  try {
61
72
  codex = readFileSync(codexPath, "utf8");
@@ -85,6 +96,12 @@ export function inspectAgents({ homeDir = homedir(), codexHome, hasCommand = com
85
96
  detected: hasCommand("opencode") || existsSync(join(homeDir, ".config", "opencode")),
86
97
  configured: !!openCode.mcp?.taskwindow,
87
98
  },
99
+ {
100
+ id: "openclaw",
101
+ label: "OpenClaw",
102
+ detected: hasCommand("openclaw") || existsSync(join(homeDir, ".openclaw")),
103
+ configured: !!openClaw.mcp?.servers?.taskwindow,
104
+ },
88
105
  ];
89
106
  }
90
107
 
@@ -192,6 +209,33 @@ export function registerOpenCode({ port, token }) {
192
209
  console.log(`[taskwindow] registered in OpenCode (${path})`);
193
210
  }
194
211
 
212
+ const OPENCLAW_OPTIONS = { timeout: 60_000, stdio: ["pipe", "pipe", "pipe"], encoding: "utf8" };
213
+
214
+ export function registerOpenClaw({ port, token }, { execFile = execFileSync } = {}) {
215
+ const url = `http://127.0.0.1:${port}/mcp`;
216
+ // Without `transport`, OpenClaw falls back to SSE, which this daemon does not serve.
217
+ const server = { url, transport: "streamable-http", headers: { Authorization: `Bearer ${token}` } };
218
+ try {
219
+ // `config patch` writes while a Gateway runs (newer `mcp set` refuses to)
220
+ // and the Gateway hot-reloads mcp.* changes. stdin keeps the token out of
221
+ // argv; --replace-path drops fields left over from an older entry.
222
+ execFile("openclaw", ["config", "patch", "--stdin", "--replace-path", "mcp.servers.taskwindow"], {
223
+ ...OPENCLAW_OPTIONS,
224
+ input: JSON.stringify({ mcp: { servers: { taskwindow: server } } }),
225
+ });
226
+ const saved = JSON.parse(execFile("openclaw", ["mcp", "show", "taskwindow", "--json"], OPENCLAW_OPTIONS));
227
+ if (saved.url !== url || saved.transport !== "streamable-http" ||
228
+ saved.headers?.Authorization !== `Bearer ${token}`) {
229
+ throw new Error("saved server does not match the requested connection");
230
+ }
231
+ } catch (err) {
232
+ // CLI output can include the saved server, credentials and all.
233
+ const reason = err.code === "ENOENT" ? "install the OpenClaw CLI and ensure it is on PATH" : "run openclaw mcp doctor taskwindow";
234
+ throw new Error(`OpenClaw registration failed (${reason})`);
235
+ }
236
+ console.log("[taskwindow] registered in OpenClaw (mcp.servers.taskwindow) — the Gateway picks it up without a restart");
237
+ }
238
+
195
239
  export function unregisterAgents({ port }) {
196
240
  try {
197
241
  execFileSync("claude", ["mcp", "remove", "taskwindow"], { stdio: "ignore" });
@@ -210,4 +254,8 @@ export function unregisterAgents({ port }) {
210
254
  console.log("[taskwindow] removed from Cursor");
211
255
  }
212
256
  } catch {}
257
+ try {
258
+ execFileSync("openclaw", ["config", "unset", "mcp.servers.taskwindow"], { stdio: "ignore", timeout: 60_000 });
259
+ console.log("[taskwindow] removed from OpenClaw");
260
+ } catch {}
213
261
  }
package/src/index.js CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  downloadExtensionZip,
16
16
  refreshExtensionFiles,
17
17
  removeExtensionBootstrap,
18
+ systemUnitPath,
19
+ systemUnitMessage,
18
20
  } from "./service.js";
19
21
  import { PairingManager } from "./pairing.js";
20
22
  import { STORE_EXTENSION_ID, STORE_LISTING_URL, STORE_ORIGIN } from "./store.js";
@@ -30,7 +32,7 @@ import { UpdateChecker, fetchLatestVersion, isNewer, readUpdateState, updateChec
30
32
  import { createRequire } from "node:module";
31
33
 
32
34
  const { version: VERSION } = createRequire(import.meta.url)("../package.json");
33
- import { inspectAgents, registerClaude, registerCodex, registerCursor, registerOpenCode, unregisterAgents } from "./agents.js";
35
+ import { inspectAgents, registerClaude, registerCodex, registerCursor, registerOpenCode, registerOpenClaw, unregisterAgents } from "./agents.js";
34
36
  import { clearLine, cursorTo, emitKeypressEvents, moveCursor } from "node:readline";
35
37
 
36
38
  // `taskwindow install` manages the login service and offers to register the
@@ -45,6 +47,7 @@ const AGENT_CHOICES = [
45
47
  ["codex", "Codex", registerCodex],
46
48
  ["cursor", "Cursor", registerCursor],
47
49
  ["opencode", "OpenCode", registerOpenCode],
50
+ ["openclaw", "OpenClaw", registerOpenClaw],
48
51
  ];
49
52
 
50
53
  const AGENT_FLAGS = AGENT_CHOICES.map(([id]) => `--${id}`).join("|");
@@ -368,6 +371,9 @@ async function runUpdate(config, flags) {
368
371
  const extFlag = flags.indexOf("--extension");
369
372
  const zipArg = extFlag !== -1 && flags[extFlag + 1] && !flags[extFlag + 1].startsWith("--") ? flags[extFlag + 1] : null;
370
373
 
374
+ const managed = systemUnitPath();
375
+ if (managed) throw new Error(systemUnitMessage(managed));
376
+
371
377
  if (!staged) {
372
378
  warnIfShadowed();
373
379
  let latest = null;
package/src/service.js CHANGED
@@ -3,9 +3,9 @@
3
3
  * terminal. macOS uses launchd; Linux uses a systemd user unit; anything else
4
4
  * gets manual instructions.
5
5
  */
6
- import { homedir, platform } from "node:os";
6
+ import { homedir, platform, userInfo } from "node:os";
7
7
  import { join } from "node:path";
8
- import { chmodSync, writeFileSync, unlinkSync, mkdirSync, readdirSync, rmSync } from "node:fs";
8
+ import { chmodSync, existsSync, writeFileSync, unlinkSync, mkdirSync, readdirSync, rmSync } from "node:fs";
9
9
  import { execFileSync, execSync } from "node:child_process";
10
10
 
11
11
  const LABEL = "com.clawnify.taskwindow";
@@ -26,10 +26,59 @@ export function removeExtensionBootstrap(home = homedir()) {
26
26
  } catch {}
27
27
  }
28
28
 
29
+ const SYSTEM_UNIT_DIRS = ["/etc/systemd/system", "/usr/lib/systemd/system", "/lib/systemd/system"];
30
+
31
+ /**
32
+ * A provisioned box (the Clawnify fleet) runs the daemon from a system unit
33
+ * as root installed it. A user unit next to it would start a second daemon
34
+ * fighting for the port, and restarting it would never move the real one onto
35
+ * new code, so install and update leave such a box to its system unit.
36
+ */
37
+ export function systemUnitPath(dirs = SYSTEM_UNIT_DIRS) {
38
+ if (platform() !== "linux") return null;
39
+ return dirs.map((dir) => join(dir, "taskwindow.service")).find((path) => existsSync(path)) || null;
40
+ }
41
+
42
+ export function systemUnitMessage(path) {
43
+ return `this daemon is run by the system unit ${path}. Update the package as root, then: sudo systemctl restart taskwindow`;
44
+ }
45
+
29
46
  function nodePath() {
30
47
  return process.execPath;
31
48
  }
32
49
 
50
+ /**
51
+ * A systemd user unit runs only while its user manager does, and without
52
+ * lingering that manager exists only while the user has a login session. On a
53
+ * headless box the daemon is SIGTERMed seconds after the last ssh/su session
54
+ * ends and comes back only at the next login. Lingering keeps the manager up
55
+ * from boot. Returns the environment `systemctl --user` needs to reach it,
56
+ * which a service or `su` context does not set.
57
+ */
58
+ function systemdUserEnv() {
59
+ const { username, uid } = userInfo();
60
+ if (!existsSync(join("/var/lib/systemd/linger", username))) {
61
+ try {
62
+ execFileSync("loginctl", ["enable-linger", username], { stdio: "pipe" });
63
+ } catch {
64
+ throw new Error(
65
+ `without lingering the daemon stops whenever ${username} has no login session. ` +
66
+ `Run: sudo loginctl enable-linger ${username}, then re-run this command`
67
+ );
68
+ }
69
+ }
70
+ const runtimeDir = process.env.XDG_RUNTIME_DIR || `/run/user/${uid}`;
71
+ // enable-linger starts the user manager asynchronously; wait for its bus.
72
+ const deadline = Date.now() + 10_000;
73
+ while (!existsSync(join(runtimeDir, "bus")) && Date.now() < deadline) {
74
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 200);
75
+ }
76
+ if (!existsSync(join(runtimeDir, "bus"))) {
77
+ throw new Error(`the systemd user manager for ${username} is not running (no ${runtimeDir}/bus)`);
78
+ }
79
+ return { ...process.env, XDG_RUNTIME_DIR: runtimeDir };
80
+ }
81
+
33
82
  export function installService(daemonEntryPath, port) {
34
83
  const system = platform();
35
84
  const logPath = join(homedir(), ".taskwindow", "daemon.log");
@@ -90,6 +139,8 @@ export function installService(daemonEntryPath, port) {
90
139
  }
91
140
 
92
141
  if (system === "linux") {
142
+ const managed = systemUnitPath();
143
+ if (managed) throw new Error(systemUnitMessage(managed));
93
144
  const unitPath = join(homedir(), ".config", "systemd", "user", "taskwindow.service");
94
145
  mkdirSync(join(homedir(), ".config", "systemd", "user"), { recursive: true });
95
146
  const unit = `[Unit]
@@ -97,7 +148,8 @@ Description=TaskWindow daemon
97
148
 
98
149
  [Service]
99
150
  ExecStart=${nodePath()} ${daemonEntryPath}
100
- Restart=on-failure
151
+ Restart=always
152
+ RestartSec=2
101
153
  StandardOutput=append:${logPath}
102
154
  StandardError=append:${logPath}
103
155
 
@@ -105,9 +157,13 @@ StandardError=append:${logPath}
105
157
  WantedBy=default.target
106
158
  `;
107
159
  writeFileSync(unitPath, unit);
108
- execSync("systemctl --user daemon-reload");
109
- execSync("systemctl --user enable --now taskwindow.service");
160
+ const env = systemdUserEnv();
161
+ execSync("systemctl --user daemon-reload", { env, stdio: "pipe" });
162
+ execSync("systemctl --user enable taskwindow.service", { env, stdio: "pipe" });
163
+ // restart, not start: an update must swap a running daemon onto the new code.
164
+ execSync("systemctl --user restart taskwindow.service", { env, stdio: "pipe" });
110
165
  console.log(`[taskwindow] login service installed (${unitPath})`);
166
+ console.log(`[taskwindow] daemon starts at boot, restarts on exit, logs to ${logPath}`);
111
167
  return;
112
168
  }
113
169
 
package/src/tools.js CHANGED
@@ -105,7 +105,9 @@ const rawDefs = [
105
105
  "as a real wheel gesture, and text as real per-key events. That is what lazy-loading lists, infinite scroll, " +
106
106
  "hover-revealed menus and type-ahead inputs are waiting for — they ignore a single jumbo scroll delta, a teleported " +
107
107
  "cursor and insertText. It costs a few hundred ms per action; pass human:false for one instant synthetic event when " +
108
- "speed matters more than realism. NOTE: while attached, Chrome shows a " +
108
+ "speed matters more than realism. A native <select> opens a browser menu that clicks and keys cannot drive: " +
109
+ "set it with form_input. A scroll result reports how far the content actually moved, which on an infinite list " +
110
+ "can be less than asked. NOTE: while attached, Chrome shows a " +
109
111
  '"TaskWindow started debugging this browser" infobar — this is unavoidable with CDP-based control.',
110
112
  inputSchema: {
111
113
  action: z.enum([