taskwindow 0.2.7 → 0.2.8
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 +23 -13
- package/package.json +1 -1
- package/src/index.js +105 -20
- package/src/store.js +10 -0
- package/src/tools.js +6 -1
- package/src/updates.js +21 -7
package/README.md
CHANGED
|
@@ -23,14 +23,16 @@ The guided installer:
|
|
|
23
23
|
|
|
24
24
|
- shows a checkbox list of detected coding agents (choose any combination, or **None**);
|
|
25
25
|
- installs the background daemon as a login service;
|
|
26
|
-
-
|
|
27
|
-
|
|
26
|
+
- opens the [TaskWindow listing on the Chrome Web Store](https://chromewebstore.google.com/detail/adbfpkbjndcpjihceobeegkokblgifpe)
|
|
27
|
+
and waits for a verified connection.
|
|
28
28
|
|
|
29
|
-
In Chrome,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
In Chrome, click **Add to Chrome**. That is the only click: the extension
|
|
30
|
+
pairs with the daemon on its own, and the installer prints `ready ✓` once
|
|
31
|
+
Chrome is connected. Chrome keeps the extension up to date from the store.
|
|
32
|
+
|
|
33
|
+
Installed the extension first? A setup guide opens with the two commands
|
|
34
|
+
above and turns green by itself as soon as the daemon is running. Coming from
|
|
35
|
+
the installer, nothing opens.
|
|
34
36
|
|
|
35
37
|
### Try it
|
|
36
38
|
|
|
@@ -47,7 +49,7 @@ open by a pinned tab no agent can close. Screenshot done. Now try:
|
|
|
47
49
|
taskwindow update # update daemon + extension to the latest release, no clicks
|
|
48
50
|
taskwindow doctor # diagnose daemon, extension, versions, and agents
|
|
49
51
|
taskwindow pair # create a manual one-time pairing code
|
|
50
|
-
taskwindow install # re-run first-time setup;
|
|
52
|
+
taskwindow install # re-run first-time setup; reopens the store listing if the extension is missing
|
|
51
53
|
taskwindow install --claude # add Claude Code without repeating setup
|
|
52
54
|
taskwindow install --cursor # add Cursor without repeating setup
|
|
53
55
|
taskwindow install --opencode # add OpenCode without repeating setup
|
|
@@ -60,7 +62,13 @@ package's latest version at most once a day; create `~/.taskwindow/no-update-che
|
|
|
60
62
|
to turn that off.
|
|
61
63
|
|
|
62
64
|
Use `taskwindow install --no-extension` to install only the daemon and selected
|
|
63
|
-
agents.
|
|
65
|
+
agents. Developing the extension? `taskwindow install --extension <zip>` unpacks
|
|
66
|
+
a build into the `TaskWindow Extension` folder in your home directory for
|
|
67
|
+
`chrome://extensions` → **Load unpacked**, pairing through a one-time code the
|
|
68
|
+
installer leaves in that folder; `taskwindow update` then refreshes those files
|
|
69
|
+
too. Loaded unpacked before the store listing existed? Remove that copy in
|
|
70
|
+
`chrome://extensions` before adding the store one — two copies would keep
|
|
71
|
+
taking the daemon connection from each other. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
|
|
64
72
|
`Authorization: Bearer <token>`; the token is stored in `~/.taskwindow/token`.
|
|
65
73
|
|
|
66
74
|
## What the agent gets
|
|
@@ -100,10 +108,12 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
|
|
|
100
108
|
that way), so nothing ever brings a tab forward. Clicking a group in the
|
|
101
109
|
popover is the only thing that focuses the agent's window — and that is you
|
|
102
110
|
asking for it.
|
|
103
|
-
- **Pairing**: the daemon listens on 127.0.0.1 only.
|
|
104
|
-
the extension
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
- **Pairing**: the daemon listens on 127.0.0.1 only. Chrome stamps every
|
|
112
|
+
request the store extension makes with its fixed extension id as the origin,
|
|
113
|
+
which no other extension or web page can forge, so the daemon hands the
|
|
114
|
+
bearer token to that origin and nothing else. An unpacked development build
|
|
115
|
+
pairs with a short-lived, single-use code the installer leaves in its
|
|
116
|
+
folder; manual codes are available with `taskwindow pair`.
|
|
107
117
|
- **Agent actions are visible**: a phantom cursor and glow show where the
|
|
108
118
|
agent is acting; while it does, Chrome shows a
|
|
109
119
|
*"started debugging this browser"* infobar — an unavoidable Chrome policy
|
package/package.json
CHANGED
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,
|
|
@@ -163,16 +164,67 @@ async function ensureDaemon(config, { forceInstall = false, allowInstall = true
|
|
|
163
164
|
return health;
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
function openInChrome(url) {
|
|
168
|
+
try {
|
|
169
|
+
execFileSync("open", ["-a", "Google Chrome", url]);
|
|
170
|
+
return true;
|
|
171
|
+
} catch {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Two-stage wait for the extension. Only a store build old enough to predate
|
|
177
|
+
// origin pairing needs the code, and only the user's Chrome clicks decide when
|
|
178
|
+
// we find out — so offer it once the quiet stretch says something is wrong,
|
|
179
|
+
// not up front where it reads as a step everybody must do.
|
|
180
|
+
const CONNECT_GRACE_MS = 60_000;
|
|
181
|
+
const CONNECT_REMAINING_MS = 4 * 60_000;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Store install (the default): send the user to the listing and wait. The
|
|
185
|
+
* extension pairs itself — the daemon trusts the store extension's origin —
|
|
186
|
+
* so the only click is "Add to Chrome". A zip path takes the unpacked route
|
|
187
|
+
* (development builds), which pairs through the installer-written code file.
|
|
188
|
+
*/
|
|
166
189
|
async function installAndConnectExtension(config, zipPath) {
|
|
167
|
-
const
|
|
168
|
-
|
|
190
|
+
const before = await readHealth(config.port);
|
|
191
|
+
if (before?.extensionConnected) {
|
|
192
|
+
console.log(`[taskwindow] ready ✓ — daemon v${before.version}, extension v${before.extensionVersion || "unknown"} already connected`);
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
if (zipPath) {
|
|
196
|
+
const pairing = await requestPairCode(config);
|
|
197
|
+
installExtension(zipPath, { port: config.port, pairingCode: pairing.code });
|
|
198
|
+
} else {
|
|
199
|
+
console.log(
|
|
200
|
+
openInChrome(STORE_LISTING_URL)
|
|
201
|
+
? `[taskwindow] opened the Chrome Web Store listing — click "Add to Chrome"; TaskWindow connects on its own`
|
|
202
|
+
: `[taskwindow] install the extension from ${STORE_LISTING_URL} — click "Add to Chrome"; TaskWindow connects on its own`
|
|
203
|
+
);
|
|
204
|
+
}
|
|
169
205
|
console.log("[taskwindow] waiting up to 5 minutes for the extension to connect…");
|
|
170
|
-
|
|
206
|
+
let health = await waitForExtension(config.port, CONNECT_GRACE_MS);
|
|
207
|
+
|
|
208
|
+
// Still nothing from a store install: the build Chrome served may predate
|
|
209
|
+
// origin pairing (the Web Store can lag a release by weeks), and that build
|
|
210
|
+
// has no way to pair itself. A code recovers it in seconds. Never on the
|
|
211
|
+
// unpacked path — issuing a second code would invalidate the one the
|
|
212
|
+
// installer just wrote into the extension's folder.
|
|
213
|
+
if (!health && !zipPath) {
|
|
214
|
+
const pairing = await requestPairCode(config).catch(() => null);
|
|
215
|
+
if (pairing) {
|
|
216
|
+
console.log(`[taskwindow] no connection yet. If Chrome has TaskWindow installed, it is an older build that cannot pair itself:`);
|
|
217
|
+
console.log(`[taskwindow] pairing code: ${pairing.code} — open the TaskWindow extension → Settings, enter it, then click Pair`);
|
|
218
|
+
console.log(`[taskwindow] otherwise just finish "Add to Chrome"; still waiting…`);
|
|
219
|
+
}
|
|
220
|
+
health = await waitForExtension(config.port, CONNECT_REMAINING_MS);
|
|
221
|
+
}
|
|
222
|
+
|
|
171
223
|
if (!health) {
|
|
172
|
-
console.error("[taskwindow] extension not connected yet — finish the Chrome
|
|
224
|
+
console.error("[taskwindow] extension not connected yet — finish the Chrome step, then run: taskwindow doctor");
|
|
173
225
|
return false;
|
|
174
226
|
}
|
|
175
|
-
removeExtensionBootstrap();
|
|
227
|
+
if (zipPath) removeExtensionBootstrap();
|
|
176
228
|
console.log(`[taskwindow] ready ✓ — daemon v${health.version}, extension v${health.extensionVersion || "unknown"}`);
|
|
177
229
|
return true;
|
|
178
230
|
}
|
|
@@ -185,6 +237,16 @@ function installedExtensionVersion() {
|
|
|
185
237
|
}
|
|
186
238
|
}
|
|
187
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Whether the extension is an unpacked build that `taskwindow update` must
|
|
242
|
+
* refresh on disk. The connected extension's id settles it; with none
|
|
243
|
+
* connected, a leftover unpacked folder does.
|
|
244
|
+
*/
|
|
245
|
+
function extensionIsUnpacked(health) {
|
|
246
|
+
if (health?.extensionId) return health.extensionId !== STORE_EXTENSION_ID;
|
|
247
|
+
return installedExtensionVersion() !== null;
|
|
248
|
+
}
|
|
249
|
+
|
|
188
250
|
/**
|
|
189
251
|
* The `taskwindow` that PATH resolves to, if it isn't this one. Global installs
|
|
190
252
|
* under different Node versions (nvm, Homebrew, /usr/local) leave older copies
|
|
@@ -240,15 +302,21 @@ async function runDoctor(config) {
|
|
|
240
302
|
} else {
|
|
241
303
|
console.log("✗ Daemon not running — run: taskwindow install");
|
|
242
304
|
}
|
|
243
|
-
if (installedVersion) console.log(`✓ Extension files installed (v${installedVersion}, ${extensionInstallDir()})`);
|
|
244
|
-
else console.log("✗ Extension files not installed — run: taskwindow install");
|
|
245
305
|
if (health?.extensionConnected) {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
306
|
+
const unpacked = extensionIsUnpacked(health);
|
|
307
|
+
let note = "";
|
|
308
|
+
if (unpacked && installedVersion && health.extensionVersion && installedVersion !== health.extensionVersion) {
|
|
309
|
+
note = ` — installed files are v${installedVersion}; run taskwindow update (or reload the extension in Chrome)`;
|
|
310
|
+
} else if (unpacked) {
|
|
311
|
+
note = ` — loaded unpacked from ${extensionInstallDir()}; the Web Store build updates itself: remove this one in chrome://extensions, then run taskwindow install`;
|
|
312
|
+
} else if (health.extensionVersion && isNewer(health.version, health.extensionVersion)) {
|
|
313
|
+
note = ` — the daemon is v${health.version}; Chrome updates the extension from the Web Store on its own, or click Update on chrome://extensions`;
|
|
314
|
+
}
|
|
315
|
+
console.log(`✓ Chrome extension connected (v${health.extensionVersion || "unknown"}${unpacked ? ", unpacked" : ", Web Store"})${note}`);
|
|
316
|
+
} else if (installedVersion) {
|
|
317
|
+
console.log(`✗ Chrome extension not connected — unpacked files are v${installedVersion} at ${extensionInstallDir()}; enable it in Chrome, then run: taskwindow pair`);
|
|
250
318
|
} else {
|
|
251
|
-
console.log(
|
|
319
|
+
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
320
|
}
|
|
253
321
|
for (const agent of agents) {
|
|
254
322
|
console.log(`${agent.configured ? "✓" : "○"} ${agent.label}${agent.configured ? " configured" : " not configured"}`);
|
|
@@ -286,9 +354,10 @@ function printManualReload() {
|
|
|
286
354
|
* `taskwindow update`: non-interactive, safe to run mid-session (agents run it
|
|
287
355
|
* with the user's OK). Stage 1 (old CLI): install the newer npm package into
|
|
288
356
|
* the owning prefix, then re-exec the NEW CLI for stage 2 so the rest runs on
|
|
289
|
-
* current code. Stage 2:
|
|
290
|
-
*
|
|
291
|
-
* only the new daemon knows how to ask.
|
|
357
|
+
* current code. Stage 2: restart the daemon on the new code; for an unpacked
|
|
358
|
+
* extension, first refresh its files and afterwards have it reload itself —
|
|
359
|
+
* daemon first, because only the new daemon knows how to ask. A Web Store
|
|
360
|
+
* extension is Chrome's to update, so stage 2 leaves it alone.
|
|
292
361
|
*/
|
|
293
362
|
async function runUpdate(config, flags) {
|
|
294
363
|
const force = flags.includes("--force");
|
|
@@ -314,10 +383,10 @@ async function runUpdate(config, flags) {
|
|
|
314
383
|
}
|
|
315
384
|
const health = await readHealth(config.port);
|
|
316
385
|
const filesVersion = installedExtensionVersion();
|
|
386
|
+
const unpacked = extensionIsUnpacked(health);
|
|
317
387
|
const current =
|
|
318
388
|
health?.version === VERSION &&
|
|
319
|
-
filesVersion === VERSION &&
|
|
320
|
-
(!health?.extensionConnected || health.extensionVersion === VERSION);
|
|
389
|
+
(!unpacked || (filesVersion === VERSION && (!health?.extensionConnected || health.extensionVersion === VERSION)));
|
|
321
390
|
if (current && !force) {
|
|
322
391
|
console.log(`[taskwindow] already up to date (v${VERSION})${latest ? "" : " as far as the local install goes"}`);
|
|
323
392
|
return true;
|
|
@@ -325,15 +394,22 @@ async function runUpdate(config, flags) {
|
|
|
325
394
|
}
|
|
326
395
|
|
|
327
396
|
// Stage 2 (or nothing newer on npm, but the local pieces disagree).
|
|
328
|
-
|
|
329
|
-
|
|
397
|
+
const unpacked = zipArg !== null || extensionIsUnpacked(await readHealth(config.port));
|
|
398
|
+
if (unpacked) {
|
|
399
|
+
refreshExtensionFiles(zipArg || downloadExtensionZip(VERSION));
|
|
400
|
+
console.log(`[taskwindow] extension files refreshed (v${installedExtensionVersion() || "?"}, ${extensionInstallDir()})`);
|
|
401
|
+
}
|
|
330
402
|
await ensureDaemon(config, { forceInstall: true });
|
|
331
403
|
const health = await waitForExtension(config.port, 90_000);
|
|
332
404
|
if (!health) {
|
|
333
405
|
console.log("[taskwindow] the extension did not reconnect — enable TaskWindow in Chrome, then run: taskwindow doctor");
|
|
334
406
|
return false;
|
|
335
407
|
}
|
|
336
|
-
if (
|
|
408
|
+
if (!unpacked) {
|
|
409
|
+
if (health.extensionVersion !== VERSION) {
|
|
410
|
+
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)`);
|
|
411
|
+
}
|
|
412
|
+
} else if (health.extensionVersion !== VERSION) {
|
|
337
413
|
const reload = await requestExtensionReload(config);
|
|
338
414
|
if (!reload.ok) {
|
|
339
415
|
printManualReload();
|
|
@@ -467,6 +543,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
467
543
|
latestVersion: updates.latest,
|
|
468
544
|
extensionConnected: bridge.connected,
|
|
469
545
|
extensionVersion: bridge.lastHello?.version || null,
|
|
546
|
+
extensionId: bridge.lastHello?.id || null,
|
|
470
547
|
port: config.port,
|
|
471
548
|
});
|
|
472
549
|
return;
|
|
@@ -523,6 +600,14 @@ const server = http.createServer(async (req, res) => {
|
|
|
523
600
|
return;
|
|
524
601
|
}
|
|
525
602
|
const code = String(body?.code || "").trim().toUpperCase();
|
|
603
|
+
if (!code) {
|
|
604
|
+
// No code: only the Web Store extension, recognised by the origin Chrome
|
|
605
|
+
// stamps on its requests, is trusted. Not counted as a failed attempt —
|
|
606
|
+
// nothing was guessed.
|
|
607
|
+
if (req.headers.origin === STORE_ORIGIN) sendJson(res, 200, { token: config.token });
|
|
608
|
+
else sendJson(res, 403, { error: "a pairing code is required" });
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
526
611
|
if (!pairing.claim(code)) {
|
|
527
612
|
pairFailures.push(Date.now());
|
|
528
613
|
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
|
|
|
@@ -329,7 +330,11 @@ function toMcpResult(result) {
|
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
export function registerTools(server, { bridge, version, updates = null, logger = console }) {
|
|
332
|
-
const notice = () =>
|
|
333
|
+
const notice = () =>
|
|
334
|
+
updates?.notice({
|
|
335
|
+
extensionVersion: bridge.lastHello?.version || null,
|
|
336
|
+
extensionStore: bridge.lastHello?.id === STORE_EXTENSION_ID,
|
|
337
|
+
}) ?? null;
|
|
333
338
|
for (const def of toolDefs) {
|
|
334
339
|
server.registerTool(def.name, { description: def.description, inputSchema: def.inputSchema }, async (args) => {
|
|
335
340
|
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
|
-
/**
|
|
72
|
-
|
|
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
|
-
|
|
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. */
|