taskwindow 0.2.0 → 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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/tools.js +23 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskwindow",
3
- "version": "0.2.0",
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 test/extension-tabs.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
@@ -2,6 +2,9 @@ import { z } from "zod";
2
2
 
3
3
  const tabId = z.number().int().describe("Tab ID from tabs_list. Defaults to the active tab in your session's task groups.");
4
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.
5
8
  const sessionToken = z
6
9
  .string()
7
10
  .optional()
@@ -13,7 +16,7 @@ const sessionToken = z
13
16
  // The MCP layer turns `image` into an image content block and everything else
14
17
  // into text blocks.
15
18
 
16
- const toolDefs = [
19
+ const rawDefs = [
17
20
  {
18
21
  name: "taskwindow_status",
19
22
  description:
@@ -25,7 +28,7 @@ const toolDefs = [
25
28
  name: "tabs_list",
26
29
  description:
27
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.",
28
- inputSchema: { sessionToken },
31
+ inputSchema: {},
29
32
  timeoutMs: 10_000,
30
33
  },
31
34
  {
@@ -51,14 +54,14 @@ const toolDefs = [
51
54
  {
52
55
  name: "tabs_close",
53
56
  description: "Close a tab.",
54
- inputSchema: { tabId, sessionToken },
57
+ inputSchema: { tabId },
55
58
  timeoutMs: 10_000,
56
59
  },
57
60
  {
58
61
  name: "navigate",
59
62
  description:
60
63
  "Navigate a tab to a URL. Waits (up to 10s) for the load event, then returns the tab's URL and title.",
61
- inputSchema: { url: z.string().url(), tabId: tabId.optional(), sessionToken },
64
+ inputSchema: { url: z.string().url(), tabId: tabId.optional() },
62
65
  timeoutMs: 30_000,
63
66
  },
64
67
  {
@@ -84,7 +87,6 @@ const toolDefs = [
84
87
  dy: z.number().int().optional().describe("Vertical scroll delta in pixels (positive scrolls down)"),
85
88
  ms: z.number().int().min(0).max(10_000).optional().describe('Milliseconds for the "wait" action (max 10000)'),
86
89
  fullPage: z.boolean().optional().describe('For "screenshot": capture the whole scrollable page instead of the viewport'),
87
- sessionToken,
88
90
  },
89
91
  timeoutMs: 30_000,
90
92
  },
@@ -102,7 +104,6 @@ const toolDefs = [
102
104
  })).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."),
103
105
  url: z.string().url().optional().describe("Page to render (defaults to the current tab's URL)"),
104
106
  tabId: tabId.optional(),
105
- sessionToken,
106
107
  },
107
108
  timeoutMs: 30_000,
108
109
  },
@@ -112,7 +113,7 @@ const toolDefs = [
112
113
  "Structured accessibility-style snapshot of the page: a text tree of interactive elements and content, " +
113
114
  "each labelled with a ref (e.g. e42) you can pass to form_input / file_upload. Cheaper and more reliable " +
114
115
  "than a screenshot for forms and navigation.",
115
- inputSchema: { tabId: tabId.optional(), sessionToken },
116
+ inputSchema: { tabId: tabId.optional() },
116
117
  timeoutMs: 20_000,
117
118
  },
118
119
  {
@@ -120,7 +121,7 @@ const toolDefs = [
120
121
  description:
121
122
  "Find elements on the page matching a query (matches role, accessible name and visible text, case-insensitive). " +
122
123
  "Returns matching refs plus enough context to pick between them.",
123
- inputSchema: { query: z.string().min(1), tabId: tabId.optional(), sessionToken },
124
+ inputSchema: { query: z.string().min(1), tabId: tabId.optional() },
124
125
  timeoutMs: 20_000,
125
126
  },
126
127
  {
@@ -129,7 +130,6 @@ const toolDefs = [
129
130
  inputSchema: {
130
131
  tabId: tabId.optional(),
131
132
  maxLength: z.number().int().min(100).max(500_000).optional().describe("Truncate output to this many characters (default 50000)"),
132
- sessionToken,
133
133
  },
134
134
  timeoutMs: 20_000,
135
135
  },
@@ -144,7 +144,6 @@ const toolDefs = [
144
144
  selector: z.string().optional().describe("CSS selector as fallback when no ref is available"),
145
145
  clear: z.boolean().optional().describe("Clear the field before typing (default true for text fields)"),
146
146
  tabId: tabId.optional(),
147
- sessionToken,
148
147
  },
149
148
  timeoutMs: 20_000,
150
149
  },
@@ -162,7 +161,6 @@ const toolDefs = [
162
161
  ref: z.string().optional(),
163
162
  selector: z.string().optional(),
164
163
  tabId: tabId.optional(),
165
- sessionToken,
166
164
  },
167
165
  timeoutMs: 60_000,
168
166
  },
@@ -179,7 +177,6 @@ const toolDefs = [
179
177
  ref: z.string().optional(),
180
178
  selector: z.string().optional(),
181
179
  tabId: tabId.optional(),
182
- sessionToken,
183
180
  },
184
181
  timeoutMs: 30_000,
185
182
  },
@@ -192,7 +189,6 @@ const toolDefs = [
192
189
  code: z.string().describe("JavaScript source to evaluate, e.g. \"document.title\""),
193
190
  awaitPromise: z.boolean().optional().describe("Wait for a returned Promise to settle (default true)"),
194
191
  tabId: tabId.optional(),
195
- sessionToken,
196
192
  },
197
193
  timeoutMs: 30_000,
198
194
  },
@@ -206,7 +202,6 @@ const toolDefs = [
206
202
  pattern: z.string().optional().describe("Only messages matching this regular expression"),
207
203
  level: z.enum(["log", "info", "warning", "error"]).optional().describe("Minimum severity to include"),
208
204
  limit: z.number().int().min(1).max(1000).optional().describe("Max messages to return (default 200, newest last)"),
209
- sessionToken,
210
205
  },
211
206
  timeoutMs: 20_000,
212
207
  },
@@ -232,7 +227,6 @@ const toolDefs = [
232
227
  tool: z.string(),
233
228
  params: z.record(z.any()).optional().default({}),
234
229
  })).min(1).max(20),
235
- sessionToken,
236
230
  },
237
231
  timeoutMs: 300_000,
238
232
  },
@@ -246,7 +240,6 @@ const toolDefs = [
246
240
  duration: z.number().min(0.5).max(30).describe("Seconds to record (max 30)"),
247
241
  fps: z.number().min(1).max(10).optional().describe("Frames per second (default 5)"),
248
242
  maxWidth: z.number().int().min(100).max(1280).optional().describe("Downscale frames to at most this width (default 800)"),
249
- sessionToken,
250
243
  },
251
244
  timeoutMs: 180_000,
252
245
  },
@@ -254,16 +247,29 @@ const toolDefs = [
254
247
  name: "shortcuts_list",
255
248
  description: "List the extension-defined shortcut macros (named sequences of tool actions).",
256
249
  inputSchema: {},
250
+ noSession: true, // reads the macro registry, never a tab
257
251
  timeoutMs: 10_000,
258
252
  },
259
253
  {
260
254
  name: "shortcuts_execute",
261
255
  description: "Run a shortcut macro defined in the extension and return each action's result.",
262
- inputSchema: { name: z.string().min(1), sessionToken },
256
+ inputSchema: { name: z.string().min(1) },
263
257
  timeoutMs: 120_000,
264
258
  },
265
259
  ];
266
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
+
267
273
  const toolNames = new Set(toolDefs.filter((tool) => !tool.local).map((tool) => tool.name));
268
274
 
269
275
  function toMcpResult(result) {