taskwindow 0.2.6 → 0.2.7
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 +13 -8
- package/package.json +1 -1
- package/src/tools.js +29 -9
package/README.md
CHANGED
|
@@ -77,9 +77,13 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
|
|
|
77
77
|
## How the isolation works
|
|
78
78
|
|
|
79
79
|
- **Task groups & sessions**: every tab the agent creates goes into a blue tab
|
|
80
|
-
group named after its task
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
group named after its task — one group per agent session, holding every tab
|
|
81
|
+
of that job however many sub-tasks it spans. The first `tabs_create` names
|
|
82
|
+
it; every later tab joins it. Naming the task also says whether the job
|
|
83
|
+
might take more than an hour (`longRunning`): a group for a shorter job
|
|
84
|
+
closes itself, tabs and all, once it has been idle for an hour, so finished
|
|
85
|
+
work does not pile up in the window; long-running groups stay until unused
|
|
86
|
+
for 30 days. Sessions are isolated from each other:
|
|
83
87
|
`tabs_create` returns a secret sessionToken and every browser tool call is
|
|
84
88
|
scoped to that session's groups, so concurrent agents never share tabs —
|
|
85
89
|
even when they pick the same task name. By default the agent can only see
|
|
@@ -90,11 +94,12 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
|
|
|
90
94
|
`windows.create` focuses the new window by default; TaskWindow always opens
|
|
91
95
|
tabs in the background (a background tab still renders, so screenshots and
|
|
92
96
|
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
|
|
97
|
+
Chrome raises a window anyway. A background tab also takes mouse, wheel and
|
|
98
|
+
keyboard input over the DevTools protocol (checked in Chrome: click, scroll
|
|
99
|
+
and type all land in a tab that is not its window's active tab, and it stays
|
|
100
|
+
that way), so nothing ever brings a tab forward. Clicking a group in the
|
|
101
|
+
popover is the only thing that focuses the agent's window — and that is you
|
|
102
|
+
asking for it.
|
|
98
103
|
- **Pairing**: the daemon listens on 127.0.0.1 only. During setup, the CLI gives
|
|
99
104
|
the extension a short-lived, single-use code; the long-lived bearer token is
|
|
100
105
|
returned only after the code is claimed. Manual codes are available with
|
package/package.json
CHANGED
package/src/tools.js
CHANGED
|
@@ -13,7 +13,7 @@ const sessionToken = z
|
|
|
13
13
|
.string()
|
|
14
14
|
.optional()
|
|
15
15
|
.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)."
|
|
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). Every result restates it as a trailing \"session: ...\" line, so the latest one is always at hand."
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
// Result contract with the extension: {text?, image?: {data, mimeType}, data?}.
|
|
@@ -38,11 +38,12 @@ const rawDefs = [
|
|
|
38
38
|
{
|
|
39
39
|
name: "tabs_create",
|
|
40
40
|
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
|
-
"
|
|
41
|
+
"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 " +
|
|
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 for " +
|
|
43
|
+
"the whole job the user gave you, and returns a sessionToken — pass it as \"sessionToken\" in every subsequent browser tool call; concurrent " +
|
|
44
|
+
"agents' sessions never share tabs. Name the task and you must also pass \"longRunning\": whether the job might need more than an hour; " +
|
|
45
|
+
"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: " +
|
|
46
|
+
"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
47
|
"use reload or navigate on the existing tab (see tabs_list).",
|
|
47
48
|
inputSchema: {
|
|
48
49
|
url: z.string().url().describe("URL to open (include the scheme, e.g. https://...)"),
|
|
@@ -51,7 +52,13 @@ const rawDefs = [
|
|
|
51
52
|
.min(1)
|
|
52
53
|
.optional()
|
|
53
54
|
.describe(
|
|
54
|
-
'
|
|
55
|
+
'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.'
|
|
56
|
+
),
|
|
57
|
+
longRunning: z
|
|
58
|
+
.boolean()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe(
|
|
61
|
+
"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
62
|
),
|
|
56
63
|
sessionToken: z
|
|
57
64
|
.string()
|
|
@@ -326,6 +333,19 @@ export function registerTools(server, { bridge, version, updates = null, logger
|
|
|
326
333
|
for (const def of toolDefs) {
|
|
327
334
|
server.registerTool(def.name, { description: def.description, inputSchema: def.inputSchema }, async (args) => {
|
|
328
335
|
try {
|
|
336
|
+
// The sessionToken is stated once, in the first tabs_create result, and
|
|
337
|
+
// the session it names is meant to run for a whole job — so it is
|
|
338
|
+
// exactly the detail an agent loses to context compaction. A later
|
|
339
|
+
// tabs_create without it is a different session: it opens a second tab
|
|
340
|
+
// group instead of joining the one the job already has. Restating it on
|
|
341
|
+
// every session-scoped answer keeps it in recent context, whatever the
|
|
342
|
+
// agent has forgotten. tabs_create names it in its own text already.
|
|
343
|
+
const echoSession = (mcp) => {
|
|
344
|
+
const token = args.sessionToken;
|
|
345
|
+
if (mcp.isError || def.name === "tabs_create" || typeof token !== "string" || !token.trim()) return mcp;
|
|
346
|
+
mcp.content.push({ type: "text", text: `session: ${token}` });
|
|
347
|
+
return mcp;
|
|
348
|
+
};
|
|
329
349
|
if (def.local) {
|
|
330
350
|
const connected = bridge.connected;
|
|
331
351
|
return toMcpResult({
|
|
@@ -342,7 +362,7 @@ export function registerTools(server, { bridge, version, updates = null, logger
|
|
|
342
362
|
},
|
|
343
363
|
});
|
|
344
364
|
}
|
|
345
|
-
if (def.name === "browser_batch") return await runBatch(args, bridge, logger);
|
|
365
|
+
if (def.name === "browser_batch") return echoSession(await runBatch(args, bridge, logger));
|
|
346
366
|
// save_to_disk is a daemon-side concern: the extension has no disk
|
|
347
367
|
// access, so it is stripped here and applied to the returned image.
|
|
348
368
|
const { save_to_disk, ...forwardedArgs } = args;
|
|
@@ -375,7 +395,7 @@ export function registerTools(server, { bridge, version, updates = null, logger
|
|
|
375
395
|
const line = notice();
|
|
376
396
|
if (line) mcp.content.push({ type: "text", text: line });
|
|
377
397
|
}
|
|
378
|
-
return mcp;
|
|
398
|
+
return echoSession(mcp);
|
|
379
399
|
} catch (err) {
|
|
380
400
|
logger.error(`[mcp] ${def.name} failed:`, err.message);
|
|
381
401
|
return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
|