taskwindow 0.2.5 → 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.
Files changed (3) hide show
  1. package/README.md +18 -2
  2. package/package.json +1 -1
  3. package/src/tools.js +32 -8
package/README.md CHANGED
@@ -77,13 +77,29 @@ 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 (`tabs_create` requires the task name — it says
81
- what the group is about). Sessions are isolated from each other:
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:
82
87
  `tabs_create` returns a secret sessionToken and every browser tool call is
83
88
  scoped to that session's groups, so concurrent agents never share tabs —
84
89
  even when they pick the same task name. By default the agent can only see
85
90
  and act on tabs in its own groups — never yours. You can click a group in
86
91
  the toolbar popover to watch, and widen access in settings.
92
+ - **Your focus is never taken**: nothing the agent does brings a tab or window
93
+ forward on you. Chrome's `tabs.create` makes a new tab active by default and
94
+ `windows.create` focuses the new window by default; TaskWindow always opens
95
+ tabs in the background (a background tab still renders, so screenshots and
96
+ page reads work), creates the agent window unfocused, and hands focus back if
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.
87
103
  - **Pairing**: the daemon listens on 127.0.0.1 only. During setup, the CLI gives
88
104
  the extension a short-lived, single-use code; the long-lived bearer token is
89
105
  returned only after the code is claimed. Manual codes are available with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskwindow",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
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/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,17 +38,28 @@ const rawDefs = [
38
38
  {
39
39
  name: "tabs_create",
40
40
  description:
41
- "Open a new tab in a task-named tab group (in the agent's own window). Requires a \"task\" name saying what the group is about; " +
42
- "same task name in the same session reuses that group. Returns a sessionToken — pass it as \"sessionToken\" in every subsequent " +
43
- "browser tool call; concurrent agents' sessions never share tabs. Don't open a second tab for a page you already have: " +
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: " +
44
47
  "use reload or navigate on the existing tab (see tabs_list).",
45
48
  inputSchema: {
46
49
  url: z.string().url().describe("URL to open (include the scheme, e.g. https://...)"),
47
50
  task: z
48
51
  .string()
49
52
  .min(1)
50
- .describe('Task name for the tab group — required; says what the group is about, e.g. "Research competitors".'),
51
- active: z.boolean().optional().describe("Make it the active tab of the agent window (default true). Never focuses that window: the user's window and app keep focus."),
53
+ .optional()
54
+ .describe(
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."
62
+ ),
52
63
  sessionToken: z
53
64
  .string()
54
65
  .optional()
@@ -322,6 +333,19 @@ export function registerTools(server, { bridge, version, updates = null, logger
322
333
  for (const def of toolDefs) {
323
334
  server.registerTool(def.name, { description: def.description, inputSchema: def.inputSchema }, async (args) => {
324
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
+ };
325
349
  if (def.local) {
326
350
  const connected = bridge.connected;
327
351
  return toMcpResult({
@@ -338,7 +362,7 @@ export function registerTools(server, { bridge, version, updates = null, logger
338
362
  },
339
363
  });
340
364
  }
341
- if (def.name === "browser_batch") return await runBatch(args, bridge, logger);
365
+ if (def.name === "browser_batch") return echoSession(await runBatch(args, bridge, logger));
342
366
  // save_to_disk is a daemon-side concern: the extension has no disk
343
367
  // access, so it is stripped here and applied to the returned image.
344
368
  const { save_to_disk, ...forwardedArgs } = args;
@@ -371,7 +395,7 @@ export function registerTools(server, { bridge, version, updates = null, logger
371
395
  const line = notice();
372
396
  if (line) mcp.content.push({ type: "text", text: line });
373
397
  }
374
- return mcp;
398
+ return echoSession(mcp);
375
399
  } catch (err) {
376
400
  logger.error(`[mcp] ${def.name} failed:`, err.message);
377
401
  return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };