taskwindow 0.1.12 → 0.2.0

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 +8 -5
  2. package/package.json +2 -2
  3. package/src/tools.js +38 -13
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.0",
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 && node test/run.mjs"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=18"
package/src/tools.js CHANGED
@@ -1,6 +1,13 @@
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
+ const sessionToken = z
6
+ .string()
7
+ .optional()
8
+ .describe(
9
+ "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)."
10
+ );
4
11
 
5
12
  // Result contract with the extension: {text?, image?: {data, mimeType}, data?}.
6
13
  // The MCP layer turns `image` into an image content block and everything else
@@ -17,33 +24,41 @@ const toolDefs = [
17
24
  {
18
25
  name: "tabs_list",
19
26
  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.",
21
- inputSchema: {},
27
+ "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.",
28
+ inputSchema: { sessionToken },
22
29
  timeoutMs: 10_000,
23
30
  },
24
31
  {
25
32
  name: "tabs_create",
26
33
  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.",
34
+ "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; " +
35
+ "same task name in the same session reuses that group. Returns a sessionToken — pass it as \"sessionToken\" in every subsequent " +
36
+ "browser tool call; concurrent agents' sessions never share tabs.",
29
37
  inputSchema: {
30
38
  url: z.string().url().describe("URL to open (include the scheme, e.g. https://...)"),
39
+ task: z
40
+ .string()
41
+ .min(1)
42
+ .describe('Task name for the tab group — required; says what the group is about, e.g. "Research competitors".'),
31
43
  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."),
44
+ sessionToken: z
45
+ .string()
46
+ .optional()
47
+ .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
48
  },
34
49
  timeoutMs: 15_000,
35
50
  },
36
51
  {
37
52
  name: "tabs_close",
38
53
  description: "Close a tab.",
39
- inputSchema: { tabId },
54
+ inputSchema: { tabId, sessionToken },
40
55
  timeoutMs: 10_000,
41
56
  },
42
57
  {
43
58
  name: "navigate",
44
59
  description:
45
60
  "Navigate a tab to a URL. Waits (up to 10s) for the load event, then returns the tab's URL and title.",
46
- inputSchema: { url: z.string().url(), tabId: tabId.optional() },
61
+ inputSchema: { url: z.string().url(), tabId: tabId.optional(), sessionToken },
47
62
  timeoutMs: 30_000,
48
63
  },
49
64
  {
@@ -69,6 +84,7 @@ const toolDefs = [
69
84
  dy: z.number().int().optional().describe("Vertical scroll delta in pixels (positive scrolls down)"),
70
85
  ms: z.number().int().min(0).max(10_000).optional().describe('Milliseconds for the "wait" action (max 10000)'),
71
86
  fullPage: z.boolean().optional().describe('For "screenshot": capture the whole scrollable page instead of the viewport'),
87
+ sessionToken,
72
88
  },
73
89
  timeoutMs: 30_000,
74
90
  },
@@ -86,6 +102,7 @@ const toolDefs = [
86
102
  })).min(1).max(4).optional().describe("Sizes to render side by side, e.g. [{\"width\":390,\"height\":844},{\"width\":1280,\"height\":800}]. Omit to close the responsive view."),
87
103
  url: z.string().url().optional().describe("Page to render (defaults to the current tab's URL)"),
88
104
  tabId: tabId.optional(),
105
+ sessionToken,
89
106
  },
90
107
  timeoutMs: 30_000,
91
108
  },
@@ -95,7 +112,7 @@ const toolDefs = [
95
112
  "Structured accessibility-style snapshot of the page: a text tree of interactive elements and content, " +
96
113
  "each labelled with a ref (e.g. e42) you can pass to form_input / file_upload. Cheaper and more reliable " +
97
114
  "than a screenshot for forms and navigation.",
98
- inputSchema: { tabId: tabId.optional() },
115
+ inputSchema: { tabId: tabId.optional(), sessionToken },
99
116
  timeoutMs: 20_000,
100
117
  },
101
118
  {
@@ -103,7 +120,7 @@ const toolDefs = [
103
120
  description:
104
121
  "Find elements on the page matching a query (matches role, accessible name and visible text, case-insensitive). " +
105
122
  "Returns matching refs plus enough context to pick between them.",
106
- inputSchema: { query: z.string().min(1), tabId: tabId.optional() },
123
+ inputSchema: { query: z.string().min(1), tabId: tabId.optional(), sessionToken },
107
124
  timeoutMs: 20_000,
108
125
  },
109
126
  {
@@ -112,6 +129,7 @@ const toolDefs = [
112
129
  inputSchema: {
113
130
  tabId: tabId.optional(),
114
131
  maxLength: z.number().int().min(100).max(500_000).optional().describe("Truncate output to this many characters (default 50000)"),
132
+ sessionToken,
115
133
  },
116
134
  timeoutMs: 20_000,
117
135
  },
@@ -126,6 +144,7 @@ const toolDefs = [
126
144
  selector: z.string().optional().describe("CSS selector as fallback when no ref is available"),
127
145
  clear: z.boolean().optional().describe("Clear the field before typing (default true for text fields)"),
128
146
  tabId: tabId.optional(),
147
+ sessionToken,
129
148
  },
130
149
  timeoutMs: 20_000,
131
150
  },
@@ -143,6 +162,7 @@ const toolDefs = [
143
162
  ref: z.string().optional(),
144
163
  selector: z.string().optional(),
145
164
  tabId: tabId.optional(),
165
+ sessionToken,
146
166
  },
147
167
  timeoutMs: 60_000,
148
168
  },
@@ -159,6 +179,7 @@ const toolDefs = [
159
179
  ref: z.string().optional(),
160
180
  selector: z.string().optional(),
161
181
  tabId: tabId.optional(),
182
+ sessionToken,
162
183
  },
163
184
  timeoutMs: 30_000,
164
185
  },
@@ -171,6 +192,7 @@ const toolDefs = [
171
192
  code: z.string().describe("JavaScript source to evaluate, e.g. \"document.title\""),
172
193
  awaitPromise: z.boolean().optional().describe("Wait for a returned Promise to settle (default true)"),
173
194
  tabId: tabId.optional(),
195
+ sessionToken,
174
196
  },
175
197
  timeoutMs: 30_000,
176
198
  },
@@ -184,6 +206,7 @@ const toolDefs = [
184
206
  pattern: z.string().optional().describe("Only messages matching this regular expression"),
185
207
  level: z.enum(["log", "info", "warning", "error"]).optional().describe("Minimum severity to include"),
186
208
  limit: z.number().int().min(1).max(1000).optional().describe("Max messages to return (default 200, newest last)"),
209
+ sessionToken,
187
210
  },
188
211
  timeoutMs: 20_000,
189
212
  },
@@ -209,6 +232,7 @@ const toolDefs = [
209
232
  tool: z.string(),
210
233
  params: z.record(z.any()).optional().default({}),
211
234
  })).min(1).max(20),
235
+ sessionToken,
212
236
  },
213
237
  timeoutMs: 300_000,
214
238
  },
@@ -222,6 +246,7 @@ const toolDefs = [
222
246
  duration: z.number().min(0.5).max(30).describe("Seconds to record (max 30)"),
223
247
  fps: z.number().min(1).max(10).optional().describe("Frames per second (default 5)"),
224
248
  maxWidth: z.number().int().min(100).max(1280).optional().describe("Downscale frames to at most this width (default 800)"),
249
+ sessionToken,
225
250
  },
226
251
  timeoutMs: 180_000,
227
252
  },
@@ -234,7 +259,7 @@ const toolDefs = [
234
259
  {
235
260
  name: "shortcuts_execute",
236
261
  description: "Run a shortcut macro defined in the extension and return each action's result.",
237
- inputSchema: { name: z.string().min(1) },
262
+ inputSchema: { name: z.string().min(1), sessionToken },
238
263
  timeoutMs: 120_000,
239
264
  },
240
265
  ];
@@ -291,7 +316,7 @@ export function registerTools(server, { bridge, version, logger = console }) {
291
316
  }
292
317
  }
293
318
 
294
- async function runBatch({ steps }, bridge, logger) {
319
+ async function runBatch({ steps, sessionToken }, bridge, logger) {
295
320
  const results = [];
296
321
  for (let i = 0; i < steps.length; i++) {
297
322
  const { tool, params } = steps[i];
@@ -309,7 +334,7 @@ async function runBatch({ steps }, bridge, logger) {
309
334
  }
310
335
  try {
311
336
  const def = toolDefs.find((d) => d.name === tool);
312
- const result = await bridge.sendTool(tool, params, def.timeoutMs);
337
+ const result = await bridge.sendTool(tool, { ...params, sessionToken }, def.timeoutMs);
313
338
  results.push({ step: i + 1, tool, ok: true, result });
314
339
  } catch (err) {
315
340
  logger.error(`[mcp] batch step ${i + 1} (${tool}) failed:`, err.message);