taskwindow 0.1.12 → 0.2.1

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
@@ -68,11 +68,14 @@ agents. For another MCP client, connect to `http://127.0.0.1:9377/mcp` with
68
68
 
69
69
  ## How the isolation works
70
70
 
71
- - **Task groups**: every tab the agent creates goes into a green tab group
72
- named after the task, in the agent's own window. By default the agent can
73
- only see and act on tabs in its own groups — never yours. You can click a
74
- group in the toolbar popover to watch, and the user can widen access in
75
- settings.
71
+ - **Task groups & sessions**: every tab the agent creates goes into a green tab
72
+ group named after its task (`tabs_create` requires the task name — it says
73
+ what the group is about). Sessions are isolated from each other:
74
+ `tabs_create` returns a secret sessionToken and every browser tool call is
75
+ scoped to that session's groups, so concurrent agents never share tabs —
76
+ even when they pick the same task name. By default the agent can only see
77
+ and act on tabs in its own groups — never yours. You can click a group in
78
+ the toolbar popover to watch, and widen access in settings.
76
79
  - **Pairing**: the daemon listens on 127.0.0.1 only. During setup, the CLI gives
77
80
  the extension a short-lived, single-use code; the long-lived bearer token is
78
81
  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.1.12",
3
+ "version": "0.2.1",
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",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "start": "node src/index.js",
12
- "test": "node --test test/pairing.test.mjs test/extension-bootstrap.test.mjs && node test/run.mjs"
12
+ "test": "node --test test/pairing.test.mjs test/extension-bootstrap.test.mjs test/extension-tabs.test.mjs test/tool-contract.test.mjs && node test/run.mjs"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=18"
package/src/tools.js CHANGED
@@ -1,12 +1,22 @@
1
1
  import { z } from "zod";
2
2
 
3
- const tabId = z.number().int().describe("Tab ID from tabs_list. Defaults to the active tab in the current task's tab group.");
3
+ const tabId = z.number().int().describe("Tab ID from tabs_list. Defaults to the active tab in your session's task groups.");
4
+
5
+ // Injected into every browser tool below (see toolDefs) rather than spread by
6
+ // hand into each schema: one missed spread made read_network_requests
7
+ // uncallable in v0.2.0.
8
+ const sessionToken = z
9
+ .string()
10
+ .optional()
11
+ .describe(
12
+ "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)."
13
+ );
4
14
 
5
15
  // Result contract with the extension: {text?, image?: {data, mimeType}, data?}.
6
16
  // The MCP layer turns `image` into an image content block and everything else
7
17
  // into text blocks.
8
18
 
9
- const toolDefs = [
19
+ const rawDefs = [
10
20
  {
11
21
  name: "taskwindow_status",
12
22
  description:
@@ -17,19 +27,27 @@ const toolDefs = [
17
27
  {
18
28
  name: "tabs_list",
19
29
  description:
20
- "List the tabs the agent may use (id, title, URL, active state) — by default only the tabs it created, grouped by task. Always call this first to discover tab IDs.",
30
+ "List the tabs in your session (id, title, URL, active state) — by default only the tabs it created, grouped by task. Pass the sessionToken returned by tabs_create.",
21
31
  inputSchema: {},
22
32
  timeoutMs: 10_000,
23
33
  },
24
34
  {
25
35
  name: "tabs_create",
26
36
  description:
27
- "Open a new tab. Tabs live in a tab group named after the task they belong to (in the agent's own window); " +
28
- "creating a tab for an existing task name reuses that group instead of duplicating it.",
37
+ "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; " +
38
+ "same task name in the same session reuses that group. Returns a sessionToken — pass it as \"sessionToken\" in every subsequent " +
39
+ "browser tool call; concurrent agents' sessions never share tabs.",
29
40
  inputSchema: {
30
41
  url: z.string().url().describe("URL to open (include the scheme, e.g. https://...)"),
42
+ task: z
43
+ .string()
44
+ .min(1)
45
+ .describe('Task name for the tab group — required; says what the group is about, e.g. "Research competitors".'),
31
46
  active: z.boolean().optional().describe("Bring the new tab to the front (default true)"),
32
- task: z.string().optional().describe("Task name for the tab group, e.g. \"Research competitors\". Reuses an existing group with the same name; defaults to the current task."),
47
+ sessionToken: z
48
+ .string()
49
+ .optional()
50
+ .describe("Your existing session token from an earlier tabs_create, to keep using that session's groups. Omit on your first call — a fresh token is minted and returned."),
33
51
  },
34
52
  timeoutMs: 15_000,
35
53
  },
@@ -229,6 +247,7 @@ const toolDefs = [
229
247
  name: "shortcuts_list",
230
248
  description: "List the extension-defined shortcut macros (named sequences of tool actions).",
231
249
  inputSchema: {},
250
+ noSession: true, // reads the macro registry, never a tab
232
251
  timeoutMs: 10_000,
233
252
  },
234
253
  {
@@ -239,6 +258,18 @@ const toolDefs = [
239
258
  },
240
259
  ];
241
260
 
261
+ /**
262
+ * Every tool that reaches a tab is session-scoped, so `sessionToken` is added
263
+ * here instead of being spread by hand into each schema — a tool whose handler
264
+ * scopes by session but whose schema omitted the param is uncallable, which is
265
+ * how read_network_requests shipped broken in v0.2.0. A tool that never touches
266
+ * a tab opts out with `noSession`; a tool that declares its own sessionToken
267
+ * (tabs_create's has different semantics) keeps it.
268
+ */
269
+ const toolDefs = rawDefs.map((def) =>
270
+ def.local || def.noSession ? def : { ...def, inputSchema: { sessionToken, ...def.inputSchema } }
271
+ );
272
+
242
273
  const toolNames = new Set(toolDefs.filter((tool) => !tool.local).map((tool) => tool.name));
243
274
 
244
275
  function toMcpResult(result) {
@@ -291,7 +322,7 @@ export function registerTools(server, { bridge, version, logger = console }) {
291
322
  }
292
323
  }
293
324
 
294
- async function runBatch({ steps }, bridge, logger) {
325
+ async function runBatch({ steps, sessionToken }, bridge, logger) {
295
326
  const results = [];
296
327
  for (let i = 0; i < steps.length; i++) {
297
328
  const { tool, params } = steps[i];
@@ -309,7 +340,7 @@ async function runBatch({ steps }, bridge, logger) {
309
340
  }
310
341
  try {
311
342
  const def = toolDefs.find((d) => d.name === tool);
312
- const result = await bridge.sendTool(tool, params, def.timeoutMs);
343
+ const result = await bridge.sendTool(tool, { ...params, sessionToken }, def.timeoutMs);
313
344
  results.push({ step: i + 1, tool, ok: true, result });
314
345
  } catch (err) {
315
346
  logger.error(`[mcp] batch step ${i + 1} (${tool}) failed:`, err.message);