taskwindow 0.1.8 → 0.1.10

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
@@ -12,34 +12,30 @@ MCP over HTTP.
12
12
 
13
13
  ## Setup (5 minutes)
14
14
 
15
- ### 1. Start the daemon
15
+ ### 1. Install and start the daemon
16
16
 
17
17
  Requires Node 18+.
18
18
 
19
19
  ```bash
20
- npx taskwindow
20
+ npm install -g taskwindow
21
+ taskwindow install
21
22
  ```
22
23
 
23
- You'll see:
24
+ That installs a login service (the daemon starts now and after every laptop
25
+ restart — no terminal needed) and prints:
24
26
 
25
27
  ```
26
- [taskwindow] daemon listening on http://127.0.0.1:9377
28
+ [taskwindow] login service installed (~/Library/LaunchAgents/com.clawnify.taskwindow.plist)
27
29
  [taskwindow] pairing code: A6LU5X — enter it in the TaskWindow extension options
28
- [taskwindow] claude code: claude mcp add taskwindow --transport http http://127.0.0.1:9377/mcp --header "Authorization: Bearer …"
29
30
  ```
30
31
 
31
- The daemon is what your agent talks to, so it needs to stay running.
32
- To make it survive laptop restarts (installs a login service):
33
-
34
- ```bash
35
- npm install -g taskwindow
36
- taskwindow install
37
- ```
38
-
39
- Or just keep `npx taskwindow` running in a terminal — both work.
32
+ Keep the pairing code for step 3. (Prefer running it by hand? `npx taskwindow`
33
+ in a terminal works too — it just won't survive a restart.)
40
34
 
41
35
  ### 2. Install the Chrome extension
42
36
 
37
+ You already have the CLI — add the extension:
38
+
43
39
  ```bash
44
40
  taskwindow install --extension
45
41
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskwindow",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
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",
package/src/index.js CHANGED
@@ -12,6 +12,15 @@ const { version: VERSION } = createRequire(import.meta.url)("../package.json");
12
12
  import { registerClaude, registerCursor, registerOpenCode, unregisterAgents } from "./agents.js";
13
13
  import { createInterface } from "node:readline";
14
14
 
15
+ // One-time pairing: the daemon prints a short code at startup; the extension
16
+ // exchanges it for the real token via POST /pair (loopback-only). This defends
17
+ // the pairing endpoint against other local user accounts; a same-user process
18
+ // could read the token file directly, so the code adds no obstacle there.
19
+ const PAIR_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; // no 0/O/1/I
20
+ const pairCode = Array.from(randomBytes(6))
21
+ .map((b) => PAIR_ALPHABET[b % PAIR_ALPHABET.length])
22
+ .join("");
23
+
15
24
  // `taskwindow install` manages the login service and — only with an explicit
16
25
  // per-agent flag — registers the MCP server in that agent.
17
26
  const args = process.argv.slice(2);
@@ -52,37 +61,39 @@ async function pickAndRegisterAgents(config) {
52
61
  );
53
62
  }
54
63
 
55
- if (verb === "install") {
56
- const config = loadConfig();
57
- if (!flags.includes("--no-service")) {
58
- installService(fileURLToPath(new URL("./index.js", import.meta.url)));
59
- }
60
- const extFlag = flags.indexOf("--extension");
61
- if (extFlag !== -1) {
62
- installExtension(flags[extFlag + 1] && !flags[extFlag + 1].startsWith("--") ? flags[extFlag + 1] : null);
64
+ try {
65
+ if (verb === "install") {
66
+ const config = loadConfig();
67
+ if (!flags.includes("--no-service")) {
68
+ installService(fileURLToPath(new URL("./index.js", import.meta.url)));
69
+ }
70
+ const extFlag = flags.indexOf("--extension");
71
+ if (extFlag !== -1) {
72
+ installExtension(flags[extFlag + 1] && !flags[extFlag + 1].startsWith("--") ? flags[extFlag + 1] : null);
73
+ }
74
+ if (flags.includes("--claude") || flags.includes("--cursor") || flags.includes("--opencode")) {
75
+ if (flags.includes("--claude")) registerClaude(config);
76
+ if (flags.includes("--cursor")) registerCursor(config);
77
+ if (flags.includes("--opencode")) registerOpenCode(config);
78
+ } else {
79
+ await pickAndRegisterAgents(config);
80
+ }
81
+ process.exit(0);
63
82
  }
64
- if (flags.includes("--claude") || flags.includes("--cursor") || flags.includes("--opencode")) {
65
- if (flags.includes("--claude")) registerClaude(config);
66
- if (flags.includes("--cursor")) registerCursor(config);
67
- if (flags.includes("--opencode")) registerOpenCode(config);
68
- } else {
69
- await pickAndRegisterAgents(config);
83
+ if (verb === "uninstall") {
84
+ if (!flags.includes("--keep-agents")) unregisterAgents({ port: 9377 });
85
+ if (!flags.includes("--no-service")) uninstallService();
86
+ process.exit(0);
70
87
  }
71
- process.exit(0);
72
- }
73
- if (verb === "uninstall") {
74
- if (!flags.includes("--keep-agents")) unregisterAgents({ port: 9377 });
75
- if (!flags.includes("--no-service")) uninstallService();
76
- process.exit(0);
88
+ } catch (err) {
89
+ console.error(`[taskwindow] ${verb || "install"} failed: ${err.message}`);
90
+ console.error(`[taskwindow] if the problem persists: taskwindow uninstall, then taskwindow install`);
91
+ process.exit(1);
77
92
  }
78
93
 
79
94
  const config = loadConfig();
80
95
  const bridge = new Bridge({ token: config.token });
81
96
 
82
- const PAIR_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; // no 0/O/1/I
83
- const pairCode = Array.from(randomBytes(6))
84
- .map((b) => PAIR_ALPHABET[b % PAIR_ALPHABET.length])
85
- .join("");
86
97
  const handleMcp = createMcpRequestHandler({ bridge, version: VERSION });
87
98
 
88
99
  // One-time pairing: the daemon prints a short code at startup; the extension
package/src/service.js CHANGED
@@ -20,6 +20,8 @@ export function installService(daemonEntryPath, port) {
20
20
  mkdirSync(join(homedir(), ".taskwindow"), { recursive: true });
21
21
 
22
22
  if (system === "darwin") {
23
+ const uid = process.getuid?.() ?? 501;
24
+ const labelTarget = `gui/${uid}/${LABEL}`;
23
25
  const plistPath = join(homedir(), "Library", "LaunchAgents", `${LABEL}.plist`);
24
26
  const plist = `<?xml version="1.0" encoding="UTF-8"?>
25
27
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -39,11 +41,33 @@ export function installService(daemonEntryPath, port) {
39
41
  </plist>
40
42
  `;
41
43
  writeFileSync(plistPath, plist);
42
- const uid = process.getuid?.() ?? 501;
44
+
45
+ // Unload any previously loaded instance. launchd is asynchronous about
46
+ // bootout: bootstrap immediately after it fails with EIO, so wait until
47
+ // the label is really gone (up to 5s).
43
48
  try {
44
- execSync(`launchctl bootout gui/${uid}/${LABEL} 2>/dev/null`, { shell: "/bin/bash" });
49
+ execSync(`launchctl bootout ${labelTarget} 2>/dev/null`);
45
50
  } catch {}
46
- execSync(`launchctl bootstrap gui/${uid} "${plistPath}"`);
51
+ const unloaded = () => {
52
+ try {
53
+ execSync(`launchctl print ${labelTarget}`, { stdio: "pipe" });
54
+ return false;
55
+ } catch {
56
+ return true;
57
+ }
58
+ };
59
+ const deadline = Date.now() + 5000;
60
+ while (!unloaded() && Date.now() < deadline) {
61
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, Date.now() + 300);
62
+ }
63
+ if (!unloaded()) {
64
+ throw new Error(`couldn't unload the previous service — run: launchctl bootout ${labelTarget}`);
65
+ }
66
+ try {
67
+ execSync(`launchctl bootstrap gui/${uid} "${plistPath}"`, { stdio: "pipe" });
68
+ } catch (err) {
69
+ throw new Error(`launchctl bootstrap failed (${err.status ?? "?"}) — try: launchctl bootout ${labelTarget}, then re-run`);
70
+ }
47
71
  console.log(`[taskwindow] login service installed (${plistPath})`);
48
72
  console.log(`[taskwindow] daemon starts at login, restarts on crash, logs to ${logPath}`);
49
73
  return;