taskwindow 0.2.6 → 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 +36 -21
- package/package.json +1 -1
- package/src/index.js +105 -20
- package/src/store.js +10 -0
- package/src/tools.js +35 -10
- 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
|
|
@@ -77,9 +85,13 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
|
|
|
77
85
|
## How the isolation works
|
|
78
86
|
|
|
79
87
|
- **Task groups & sessions**: every tab the agent creates goes into a blue tab
|
|
80
|
-
group named after its task
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
group named after its task — one group per agent session, holding every tab
|
|
89
|
+
of that job however many sub-tasks it spans. The first `tabs_create` names
|
|
90
|
+
it; every later tab joins it. Naming the task also says whether the job
|
|
91
|
+
might take more than an hour (`longRunning`): a group for a shorter job
|
|
92
|
+
closes itself, tabs and all, once it has been idle for an hour, so finished
|
|
93
|
+
work does not pile up in the window; long-running groups stay until unused
|
|
94
|
+
for 30 days. Sessions are isolated from each other:
|
|
83
95
|
`tabs_create` returns a secret sessionToken and every browser tool call is
|
|
84
96
|
scoped to that session's groups, so concurrent agents never share tabs —
|
|
85
97
|
even when they pick the same task name. By default the agent can only see
|
|
@@ -90,15 +102,18 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
|
|
|
90
102
|
`windows.create` focuses the new window by default; TaskWindow always opens
|
|
91
103
|
tabs in the background (a background tab still renders, so screenshots and
|
|
92
104
|
page reads work), creates the agent window unfocused, and hands focus back if
|
|
93
|
-
Chrome raises a window anyway.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
thing that focuses the agent's window — and that is you
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
Chrome raises a window anyway. A background tab also takes mouse, wheel and
|
|
106
|
+
keyboard input over the DevTools protocol (checked in Chrome: click, scroll
|
|
107
|
+
and type all land in a tab that is not its window's active tab, and it stays
|
|
108
|
+
that way), so nothing ever brings a tab forward. Clicking a group in the
|
|
109
|
+
popover is the only thing that focuses the agent's window — and that is you
|
|
110
|
+
asking for it.
|
|
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`.
|
|
102
117
|
- **Agent actions are visible**: a phantom cursor and glow show where the
|
|
103
118
|
agent is acting; while it does, Chrome shows a
|
|
104
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
|
|
|
@@ -13,7 +14,7 @@ const sessionToken = z
|
|
|
13
14
|
.string()
|
|
14
15
|
.optional()
|
|
15
16
|
.describe(
|
|
16
|
-
"Session token returned by tabs_create — pass it in every browser tool call so the call acts only on your session's tabs (sessions are isolated from each other)."
|
|
17
|
+
"Session token returned by tabs_create — pass it in every browser tool call so the call acts only on your session's tabs (sessions are isolated from each other). Every result restates it as a trailing \"session: ...\" line, so the latest one is always at hand."
|
|
17
18
|
);
|
|
18
19
|
|
|
19
20
|
// Result contract with the extension: {text?, image?: {data, mimeType}, data?}.
|
|
@@ -38,11 +39,12 @@ const rawDefs = [
|
|
|
38
39
|
{
|
|
39
40
|
name: "tabs_create",
|
|
40
41
|
description:
|
|
41
|
-
"Open a new tab in
|
|
42
|
-
"the active tab and never takes focus, so the user's window, tab and app stay as they are. Your first call needs a \"task\" name
|
|
43
|
-
"the
|
|
44
|
-
"agents' sessions never share tabs.
|
|
45
|
-
"
|
|
42
|
+
"Open a new tab in your session's task group (in the agent's own window). The tab opens in the background: it never becomes " +
|
|
43
|
+
"the active tab and never takes focus, so the user's window, tab and app stay as they are. Your first call needs a \"task\" name for " +
|
|
44
|
+
"the whole job the user gave you, and returns a sessionToken — pass it as \"sessionToken\" in every subsequent browser tool call; concurrent " +
|
|
45
|
+
"agents' sessions never share tabs. Name the task and you must also pass \"longRunning\": whether the job might need more than an hour; " +
|
|
46
|
+
"a group for a shorter job closes itself after an hour idle. You get one group per session and it holds every tab of the job, however many sub-tasks that spans: " +
|
|
47
|
+
"later calls omit \"task\" (a name passed anyway is ignored, not a second group). Don't open a second tab for a page you already have: " +
|
|
46
48
|
"use reload or navigate on the existing tab (see tabs_list).",
|
|
47
49
|
inputSchema: {
|
|
48
50
|
url: z.string().url().describe("URL to open (include the scheme, e.g. https://...)"),
|
|
@@ -51,7 +53,13 @@ const rawDefs = [
|
|
|
51
53
|
.min(1)
|
|
52
54
|
.optional()
|
|
53
55
|
.describe(
|
|
54
|
-
'
|
|
56
|
+
'Name for your session\'s tab group: the whole job the user asked for, NOT the page you are about to open or the sub-task in front of you — one word if possible, two at most (e.g. "Research" or "Research competitors"). Read once, on your first call; afterwards omit it, since every tab of this session joins that one group.'
|
|
57
|
+
),
|
|
58
|
+
longRunning: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe(
|
|
62
|
+
"Might this job need more than an hour to complete? Required on the first call of your session, the one that names the task. false: the group closes itself (tabs and all) once idle for an hour. true: it stays until unused for 30 days. To change your group's answer later, pass this on its own — passed alongside a \"task\", it is ignored with the name."
|
|
55
63
|
),
|
|
56
64
|
sessionToken: z
|
|
57
65
|
.string()
|
|
@@ -322,10 +330,27 @@ function toMcpResult(result) {
|
|
|
322
330
|
}
|
|
323
331
|
|
|
324
332
|
export function registerTools(server, { bridge, version, updates = null, logger = console }) {
|
|
325
|
-
const notice = () =>
|
|
333
|
+
const notice = () =>
|
|
334
|
+
updates?.notice({
|
|
335
|
+
extensionVersion: bridge.lastHello?.version || null,
|
|
336
|
+
extensionStore: bridge.lastHello?.id === STORE_EXTENSION_ID,
|
|
337
|
+
}) ?? null;
|
|
326
338
|
for (const def of toolDefs) {
|
|
327
339
|
server.registerTool(def.name, { description: def.description, inputSchema: def.inputSchema }, async (args) => {
|
|
328
340
|
try {
|
|
341
|
+
// The sessionToken is stated once, in the first tabs_create result, and
|
|
342
|
+
// the session it names is meant to run for a whole job — so it is
|
|
343
|
+
// exactly the detail an agent loses to context compaction. A later
|
|
344
|
+
// tabs_create without it is a different session: it opens a second tab
|
|
345
|
+
// group instead of joining the one the job already has. Restating it on
|
|
346
|
+
// every session-scoped answer keeps it in recent context, whatever the
|
|
347
|
+
// agent has forgotten. tabs_create names it in its own text already.
|
|
348
|
+
const echoSession = (mcp) => {
|
|
349
|
+
const token = args.sessionToken;
|
|
350
|
+
if (mcp.isError || def.name === "tabs_create" || typeof token !== "string" || !token.trim()) return mcp;
|
|
351
|
+
mcp.content.push({ type: "text", text: `session: ${token}` });
|
|
352
|
+
return mcp;
|
|
353
|
+
};
|
|
329
354
|
if (def.local) {
|
|
330
355
|
const connected = bridge.connected;
|
|
331
356
|
return toMcpResult({
|
|
@@ -342,7 +367,7 @@ export function registerTools(server, { bridge, version, updates = null, logger
|
|
|
342
367
|
},
|
|
343
368
|
});
|
|
344
369
|
}
|
|
345
|
-
if (def.name === "browser_batch") return await runBatch(args, bridge, logger);
|
|
370
|
+
if (def.name === "browser_batch") return echoSession(await runBatch(args, bridge, logger));
|
|
346
371
|
// save_to_disk is a daemon-side concern: the extension has no disk
|
|
347
372
|
// access, so it is stripped here and applied to the returned image.
|
|
348
373
|
const { save_to_disk, ...forwardedArgs } = args;
|
|
@@ -375,7 +400,7 @@ export function registerTools(server, { bridge, version, updates = null, logger
|
|
|
375
400
|
const line = notice();
|
|
376
401
|
if (line) mcp.content.push({ type: "text", text: line });
|
|
377
402
|
}
|
|
378
|
-
return mcp;
|
|
403
|
+
return echoSession(mcp);
|
|
379
404
|
} catch (err) {
|
|
380
405
|
logger.error(`[mcp] ${def.name} failed:`, err.message);
|
|
381
406
|
return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
|
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. */
|