claude-chrome-parallel 2.3.0 → 3.0.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 (59) hide show
  1. package/README.md +296 -180
  2. package/dist/cdp/client.d.ts +27 -3
  3. package/dist/cdp/client.d.ts.map +1 -1
  4. package/dist/cdp/client.js +67 -3
  5. package/dist/cdp/client.js.map +1 -1
  6. package/dist/cdp/connection-pool.d.ts +5 -1
  7. package/dist/cdp/connection-pool.d.ts.map +1 -1
  8. package/dist/cdp/connection-pool.js +7 -1
  9. package/dist/cdp/connection-pool.js.map +1 -1
  10. package/dist/chrome/launcher.d.ts.map +1 -1
  11. package/dist/chrome/launcher.js +6 -0
  12. package/dist/chrome/launcher.js.map +1 -1
  13. package/dist/orchestration/state-manager.d.ts +117 -0
  14. package/dist/orchestration/state-manager.d.ts.map +1 -0
  15. package/dist/orchestration/state-manager.js +435 -0
  16. package/dist/orchestration/state-manager.js.map +1 -0
  17. package/dist/orchestration/workflow-engine.d.ts +96 -0
  18. package/dist/orchestration/workflow-engine.d.ts.map +1 -0
  19. package/dist/orchestration/workflow-engine.js +326 -0
  20. package/dist/orchestration/workflow-engine.js.map +1 -0
  21. package/dist/session-manager.d.ts +62 -18
  22. package/dist/session-manager.d.ts.map +1 -1
  23. package/dist/session-manager.js +274 -100
  24. package/dist/session-manager.js.map +1 -1
  25. package/dist/tools/computer.d.ts.map +1 -1
  26. package/dist/tools/computer.js +49 -3
  27. package/dist/tools/computer.js.map +1 -1
  28. package/dist/tools/index.d.ts.map +1 -1
  29. package/dist/tools/index.js +13 -1
  30. package/dist/tools/index.js.map +1 -1
  31. package/dist/tools/navigate.d.ts.map +1 -1
  32. package/dist/tools/navigate.js +91 -8
  33. package/dist/tools/navigate.js.map +1 -1
  34. package/dist/tools/orchestration.d.ts +6 -0
  35. package/dist/tools/orchestration.d.ts.map +1 -0
  36. package/dist/tools/orchestration.js +436 -0
  37. package/dist/tools/orchestration.js.map +1 -0
  38. package/dist/tools/tabs-context.d.ts.map +1 -1
  39. package/dist/tools/tabs-context.js +42 -23
  40. package/dist/tools/tabs-context.js.map +1 -1
  41. package/dist/tools/tabs-create.d.ts +1 -1
  42. package/dist/tools/tabs-create.d.ts.map +1 -1
  43. package/dist/tools/tabs-create.js +30 -6
  44. package/dist/tools/tabs-create.js.map +1 -1
  45. package/dist/tools/worker-create.d.ts +7 -0
  46. package/dist/tools/worker-create.d.ts.map +1 -0
  47. package/dist/tools/worker-create.js +62 -0
  48. package/dist/tools/worker-create.js.map +1 -0
  49. package/dist/tools/worker-delete.d.ts +6 -0
  50. package/dist/tools/worker-delete.d.ts.map +1 -0
  51. package/dist/tools/worker-delete.js +80 -0
  52. package/dist/tools/worker-delete.js.map +1 -0
  53. package/dist/tools/worker-list.d.ts +6 -0
  54. package/dist/tools/worker-list.d.ts.map +1 -0
  55. package/dist/tools/worker-list.js +67 -0
  56. package/dist/tools/worker-list.js.map +1 -0
  57. package/dist/types/session.d.ts +35 -2
  58. package/dist/types/session.d.ts.map +1 -1
  59. package/package.json +2 -1
@@ -0,0 +1,436 @@
1
+ "use strict";
2
+ /**
3
+ * Orchestration Tools - MCP tools for Chrome-Sisyphus workflow management
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerOrchestrationTools = registerOrchestrationTools;
7
+ const workflow_engine_1 = require("../orchestration/workflow-engine");
8
+ // ============================================
9
+ // workflow_init - Initialize a new workflow
10
+ // ============================================
11
+ const workflowInitDefinition = {
12
+ name: 'workflow_init',
13
+ description: `Initialize a Chrome-Sisyphus workflow with multiple workers.
14
+ Creates isolated browser contexts for each worker and sets up scratchpad files.
15
+
16
+ Use this to prepare parallel browser operations before launching worker agents.`,
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ name: {
21
+ type: 'string',
22
+ description: 'Name of the workflow (e.g., "Price comparison")',
23
+ },
24
+ workers: {
25
+ type: 'array',
26
+ description: 'List of workers to create',
27
+ items: {
28
+ type: 'object',
29
+ properties: {
30
+ name: {
31
+ type: 'string',
32
+ description: 'Worker name (e.g., "coupang", "11st")',
33
+ },
34
+ url: {
35
+ type: 'string',
36
+ description: 'Initial URL to navigate to',
37
+ },
38
+ task: {
39
+ type: 'string',
40
+ description: 'Task description for the worker',
41
+ },
42
+ successCriteria: {
43
+ type: 'string',
44
+ description: 'Criteria for task completion',
45
+ },
46
+ },
47
+ required: ['name', 'url', 'task'],
48
+ },
49
+ },
50
+ },
51
+ required: ['name', 'workers'],
52
+ },
53
+ };
54
+ const workflowInitHandler = async (sessionId, args) => {
55
+ const engine = (0, workflow_engine_1.getWorkflowEngine)();
56
+ const name = args.name;
57
+ const workerDefs = args.workers;
58
+ try {
59
+ // Create workflow definition
60
+ const workflow = {
61
+ id: `wf-${Date.now()}`,
62
+ name,
63
+ steps: workerDefs.map((w, i) => ({
64
+ workerId: `worker-${w.name}`,
65
+ workerName: w.name,
66
+ url: w.url,
67
+ task: w.task,
68
+ successCriteria: w.successCriteria || 'Task completed successfully',
69
+ })),
70
+ parallel: true,
71
+ maxRetries: 3,
72
+ timeout: 300000, // 5 minutes
73
+ };
74
+ // Initialize workflow
75
+ const result = await engine.initWorkflow(sessionId, workflow);
76
+ // Generate worker prompts for reference
77
+ const workerPrompts = result.workers.map((w, i) => ({
78
+ workerName: w.workerName,
79
+ tabId: w.tabId,
80
+ prompt: engine.generateWorkerPrompt(w.workerId, w.workerName, w.tabId, workflow.steps[i].task, workflow.steps[i].successCriteria),
81
+ }));
82
+ return {
83
+ content: [
84
+ {
85
+ type: 'text',
86
+ text: JSON.stringify({
87
+ orchestrationId: result.orchestrationId,
88
+ status: 'INITIALIZED',
89
+ workers: result.workers.map((w, i) => ({
90
+ workerId: w.workerId,
91
+ workerName: w.workerName,
92
+ tabId: w.tabId,
93
+ task: workflow.steps[i].task,
94
+ })),
95
+ scratchpadDir: '.agent/chrome-sisyphus',
96
+ message: `Workflow initialized with ${result.workers.length} workers. Launch Background Tasks for each worker using the Task tool with run_in_background: true.`,
97
+ workerPrompts,
98
+ }, null, 2),
99
+ },
100
+ ],
101
+ };
102
+ }
103
+ catch (error) {
104
+ return {
105
+ content: [
106
+ {
107
+ type: 'text',
108
+ text: `Error initializing workflow: ${error instanceof Error ? error.message : String(error)}`,
109
+ },
110
+ ],
111
+ isError: true,
112
+ };
113
+ }
114
+ };
115
+ // ============================================
116
+ // workflow_status - Get workflow status
117
+ // ============================================
118
+ const workflowStatusDefinition = {
119
+ name: 'workflow_status',
120
+ description: `Get the current status of a Chrome-Sisyphus workflow.
121
+ Returns orchestration state and all worker states.`,
122
+ inputSchema: {
123
+ type: 'object',
124
+ properties: {
125
+ includeWorkerDetails: {
126
+ type: 'boolean',
127
+ description: 'Include full worker scratchpad details (default: false)',
128
+ },
129
+ },
130
+ required: [],
131
+ },
132
+ };
133
+ const workflowStatusHandler = async (_sessionId, args) => {
134
+ const engine = (0, workflow_engine_1.getWorkflowEngine)();
135
+ const includeWorkerDetails = args.includeWorkerDetails ?? false;
136
+ try {
137
+ const orch = await engine.getOrchestrationStatus();
138
+ if (!orch) {
139
+ return {
140
+ content: [
141
+ {
142
+ type: 'text',
143
+ text: JSON.stringify({ status: 'NO_WORKFLOW', message: 'No active workflow found' }),
144
+ },
145
+ ],
146
+ };
147
+ }
148
+ const result = {
149
+ orchestrationId: orch.orchestrationId,
150
+ status: orch.status,
151
+ task: orch.task,
152
+ workers: orch.workers,
153
+ completedWorkers: orch.completedWorkers,
154
+ failedWorkers: orch.failedWorkers,
155
+ duration: Date.now() - orch.createdAt,
156
+ };
157
+ if (includeWorkerDetails) {
158
+ const workerStates = await engine.getAllWorkerStates();
159
+ result.workerDetails = workerStates.map(w => ({
160
+ workerName: w.workerName,
161
+ status: w.status,
162
+ iteration: w.iteration,
163
+ progressLog: w.progressLog,
164
+ extractedData: w.extractedData,
165
+ errors: w.errors,
166
+ }));
167
+ }
168
+ return {
169
+ content: [
170
+ {
171
+ type: 'text',
172
+ text: JSON.stringify(result, null, 2),
173
+ },
174
+ ],
175
+ };
176
+ }
177
+ catch (error) {
178
+ return {
179
+ content: [
180
+ {
181
+ type: 'text',
182
+ text: `Error getting workflow status: ${error instanceof Error ? error.message : String(error)}`,
183
+ },
184
+ ],
185
+ isError: true,
186
+ };
187
+ }
188
+ };
189
+ // ============================================
190
+ // workflow_collect - Collect workflow results
191
+ // ============================================
192
+ const workflowCollectDefinition = {
193
+ name: 'workflow_collect',
194
+ description: `Collect and aggregate results from all workers in the workflow.
195
+ Use this after all worker Background Tasks have completed.`,
196
+ inputSchema: {
197
+ type: 'object',
198
+ properties: {},
199
+ required: [],
200
+ },
201
+ };
202
+ const workflowCollectHandler = async (_sessionId, _args) => {
203
+ const engine = (0, workflow_engine_1.getWorkflowEngine)();
204
+ try {
205
+ const results = await engine.collectResults();
206
+ if (!results) {
207
+ return {
208
+ content: [
209
+ {
210
+ type: 'text',
211
+ text: JSON.stringify({ status: 'NO_RESULTS', message: 'No workflow results found' }),
212
+ },
213
+ ],
214
+ };
215
+ }
216
+ return {
217
+ content: [
218
+ {
219
+ type: 'text',
220
+ text: JSON.stringify(results, null, 2),
221
+ },
222
+ ],
223
+ };
224
+ }
225
+ catch (error) {
226
+ return {
227
+ content: [
228
+ {
229
+ type: 'text',
230
+ text: `Error collecting results: ${error instanceof Error ? error.message : String(error)}`,
231
+ },
232
+ ],
233
+ isError: true,
234
+ };
235
+ }
236
+ };
237
+ // ============================================
238
+ // workflow_cleanup - Cleanup workflow resources
239
+ // ============================================
240
+ const workflowCleanupDefinition = {
241
+ name: 'workflow_cleanup',
242
+ description: `Clean up workflow resources including workers, tabs, and scratchpad files.
243
+ Use this after workflow completion or to abort a workflow.`,
244
+ inputSchema: {
245
+ type: 'object',
246
+ properties: {},
247
+ required: [],
248
+ },
249
+ };
250
+ const workflowCleanupHandler = async (sessionId, _args) => {
251
+ const engine = (0, workflow_engine_1.getWorkflowEngine)();
252
+ try {
253
+ await engine.cleanupWorkflow(sessionId);
254
+ return {
255
+ content: [
256
+ {
257
+ type: 'text',
258
+ text: JSON.stringify({
259
+ status: 'CLEANED',
260
+ message: 'Workflow resources cleaned up successfully',
261
+ }),
262
+ },
263
+ ],
264
+ };
265
+ }
266
+ catch (error) {
267
+ return {
268
+ content: [
269
+ {
270
+ type: 'text',
271
+ text: `Error cleaning up workflow: ${error instanceof Error ? error.message : String(error)}`,
272
+ },
273
+ ],
274
+ isError: true,
275
+ };
276
+ }
277
+ };
278
+ // ============================================
279
+ // worker_update - Update worker progress
280
+ // ============================================
281
+ const workerUpdateDefinition = {
282
+ name: 'worker_update',
283
+ description: `Update a worker's progress in the orchestration scratchpad.
284
+ Call this from worker agents to report progress.`,
285
+ inputSchema: {
286
+ type: 'object',
287
+ properties: {
288
+ workerName: {
289
+ type: 'string',
290
+ description: 'Name of the worker',
291
+ },
292
+ status: {
293
+ type: 'string',
294
+ enum: ['INIT', 'IN_PROGRESS', 'SUCCESS', 'PARTIAL', 'FAIL'],
295
+ description: 'Worker status',
296
+ },
297
+ iteration: {
298
+ type: 'number',
299
+ description: 'Current iteration number',
300
+ },
301
+ action: {
302
+ type: 'string',
303
+ description: 'Action being performed',
304
+ },
305
+ result: {
306
+ type: 'string',
307
+ enum: ['SUCCESS', 'FAIL', 'IN_PROGRESS'],
308
+ description: 'Result of the action',
309
+ },
310
+ extractedData: {
311
+ type: 'object',
312
+ description: 'Data extracted so far',
313
+ },
314
+ error: {
315
+ type: 'string',
316
+ description: 'Error message if any',
317
+ },
318
+ },
319
+ required: ['workerName'],
320
+ },
321
+ };
322
+ const workerUpdateHandler = async (_sessionId, args) => {
323
+ const engine = (0, workflow_engine_1.getWorkflowEngine)();
324
+ const workerName = args.workerName;
325
+ try {
326
+ await engine.updateWorkerProgress(workerName, {
327
+ status: args.status,
328
+ iteration: args.iteration,
329
+ action: args.action,
330
+ result: args.result,
331
+ extractedData: args.extractedData,
332
+ error: args.error,
333
+ });
334
+ return {
335
+ content: [
336
+ {
337
+ type: 'text',
338
+ text: JSON.stringify({
339
+ status: 'UPDATED',
340
+ workerName,
341
+ message: `Worker ${workerName} progress updated`,
342
+ }),
343
+ },
344
+ ],
345
+ };
346
+ }
347
+ catch (error) {
348
+ return {
349
+ content: [
350
+ {
351
+ type: 'text',
352
+ text: `Error updating worker: ${error instanceof Error ? error.message : String(error)}`,
353
+ },
354
+ ],
355
+ isError: true,
356
+ };
357
+ }
358
+ };
359
+ // ============================================
360
+ // worker_complete - Mark worker as complete
361
+ // ============================================
362
+ const workerCompleteDefinition = {
363
+ name: 'worker_complete',
364
+ description: `Mark a worker as complete with final results.
365
+ Call this from worker agents when task is done.`,
366
+ inputSchema: {
367
+ type: 'object',
368
+ properties: {
369
+ workerName: {
370
+ type: 'string',
371
+ description: 'Name of the worker',
372
+ },
373
+ status: {
374
+ type: 'string',
375
+ enum: ['SUCCESS', 'PARTIAL', 'FAIL'],
376
+ description: 'Final status',
377
+ },
378
+ resultSummary: {
379
+ type: 'string',
380
+ description: 'Brief summary of results (max 100 chars)',
381
+ },
382
+ extractedData: {
383
+ type: 'object',
384
+ description: 'Final extracted data',
385
+ },
386
+ },
387
+ required: ['workerName', 'status', 'resultSummary'],
388
+ },
389
+ };
390
+ const workerCompleteHandler = async (_sessionId, args) => {
391
+ const engine = (0, workflow_engine_1.getWorkflowEngine)();
392
+ const workerName = args.workerName;
393
+ const status = args.status;
394
+ const resultSummary = args.resultSummary;
395
+ const extractedData = args.extractedData;
396
+ try {
397
+ await engine.completeWorker(workerName, status, resultSummary, extractedData);
398
+ return {
399
+ content: [
400
+ {
401
+ type: 'text',
402
+ text: JSON.stringify({
403
+ status: 'COMPLETED',
404
+ workerName,
405
+ workerStatus: status,
406
+ message: `Worker ${workerName} marked as ${status}`,
407
+ }),
408
+ },
409
+ ],
410
+ };
411
+ }
412
+ catch (error) {
413
+ return {
414
+ content: [
415
+ {
416
+ type: 'text',
417
+ text: `Error completing worker: ${error instanceof Error ? error.message : String(error)}`,
418
+ },
419
+ ],
420
+ isError: true,
421
+ };
422
+ }
423
+ };
424
+ // ============================================
425
+ // Register all orchestration tools
426
+ // ============================================
427
+ function registerOrchestrationTools(server) {
428
+ server.registerTool('workflow_init', workflowInitHandler, workflowInitDefinition);
429
+ server.registerTool('workflow_status', workflowStatusHandler, workflowStatusDefinition);
430
+ server.registerTool('workflow_collect', workflowCollectHandler, workflowCollectDefinition);
431
+ server.registerTool('workflow_cleanup', workflowCleanupHandler, workflowCleanupDefinition);
432
+ server.registerTool('worker_update', workerUpdateHandler, workerUpdateDefinition);
433
+ server.registerTool('worker_complete', workerCompleteHandler, workerCompleteDefinition);
434
+ console.error('[Orchestration] Registered 6 orchestration tools');
435
+ }
436
+ //# sourceMappingURL=orchestration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration.js","sourceRoot":"","sources":["../../src/tools/orchestration.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAweH,gEASC;AA7eD,sEAAyF;AAGzF,+CAA+C;AAC/C,4CAA4C;AAC5C,+CAA+C;AAE/C,MAAM,sBAAsB,GAAsB;IAChD,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE;;;gFAGiE;IAC9E,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iDAAiD;aAC/D;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,2BAA2B;gBACxC,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,uCAAuC;yBACrD;wBACD,GAAG,EAAE;4BACH,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,4BAA4B;yBAC1C;wBACD,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,iCAAiC;yBAC/C;wBACD,eAAe,EAAE;4BACf,IAA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AE,MAAM;oBACZ,IAAI,EAAE,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBAC3F;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,+CAA+C;AAC/C,mCAAmC;AACnC,+CAA+C;AAE/C,SAAgB,0BAA0B,CAAC,MAAiB;IAC1D,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;IAClF,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,wBAAwB,CAAC,CAAC;IACxF,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,sBAAsB,EAAE,yBAAyB,CAAC,CAAC;IAC3F,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,sBAAsB,EAAE,yBAAyB,CAAC,CAAC;IAC3F,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;IAClF,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,wBAAwB,CAAC,CAAC;IAExF,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACpE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-context.d.ts","sourceRoot":"","sources":["../../src/tools/tabs-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAkF1C,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE/D"}
1
+ {"version":3,"file":"tabs-context.d.ts","sourceRoot":"","sources":["../../src/tools/tabs-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA0G1C,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE/D"}
@@ -7,49 +7,68 @@ exports.registerTabsContextTool = registerTabsContextTool;
7
7
  const session_manager_1 = require("../session-manager");
8
8
  const definition = {
9
9
  name: 'tabs_context_mcp',
10
- description: 'Get context information about the current MCP session tabs. Returns all tab IDs. Use createIfEmpty to create a new tab if none exists.',
10
+ description: 'Get context information about the current MCP session tabs and workers. Returns all tab IDs grouped by worker.',
11
11
  inputSchema: {
12
12
  type: 'object',
13
13
  properties: {
14
- createIfEmpty: {
15
- type: 'boolean',
16
- description: 'Creates a new tab if the session has no tabs',
14
+ workerId: {
15
+ type: 'string',
16
+ description: 'Optional: Get tabs for a specific worker only.',
17
17
  },
18
18
  },
19
19
  required: [],
20
20
  },
21
21
  };
22
22
  const handler = async (sessionId, args) => {
23
- const createIfEmpty = args.createIfEmpty;
24
23
  const sessionManager = (0, session_manager_1.getSessionManager)();
24
+ const requestedWorkerId = args.workerId;
25
25
  try {
26
26
  const session = await sessionManager.getOrCreateSession(sessionId);
27
- let targetIds = sessionManager.getSessionTargetIds(sessionId);
28
- // Create a new tab if requested and none exist
29
- if (createIfEmpty && targetIds.length === 0) {
30
- const { targetId } = await sessionManager.createTarget(sessionId, 'about:blank');
31
- targetIds = [targetId];
32
- }
33
- // Get tab info for each target
34
- const tabInfos = await Promise.all(targetIds.map(async (targetId) => {
35
- const page = await sessionManager.getPage(sessionId, targetId);
36
- if (!page) {
37
- return { tabId: targetId, url: 'unknown', title: 'unknown' };
27
+ const workers = sessionManager.getWorkers(sessionId);
28
+ // Get tab info grouped by worker
29
+ const tabInfos = [];
30
+ const workerTabs = {};
31
+ for (const workerInfo of workers) {
32
+ // Skip if specific worker requested and this isn't it
33
+ if (requestedWorkerId && workerInfo.id !== requestedWorkerId) {
34
+ continue;
35
+ }
36
+ const targetIds = sessionManager.getWorkerTargetIds(sessionId, workerInfo.id);
37
+ workerTabs[workerInfo.id] = [];
38
+ for (const targetId of targetIds) {
39
+ try {
40
+ const page = await sessionManager.getPage(sessionId, targetId, workerInfo.id);
41
+ if (page) {
42
+ const tabInfo = {
43
+ tabId: targetId,
44
+ workerId: workerInfo.id,
45
+ url: page.url(),
46
+ title: await page.title(),
47
+ };
48
+ tabInfos.push(tabInfo);
49
+ workerTabs[workerInfo.id].push(tabInfo);
50
+ }
51
+ }
52
+ catch {
53
+ // Target may have been closed, skip it
54
+ }
38
55
  }
39
- return {
40
- tabId: targetId,
41
- url: page.url(),
42
- title: await page.title(),
43
- };
44
- }));
56
+ }
45
57
  return {
46
58
  content: [
47
59
  {
48
60
  type: 'text',
49
61
  text: JSON.stringify({
50
62
  sessionId,
51
- tabs: tabInfos,
63
+ defaultWorkerId: session.defaultWorkerId,
64
+ workerCount: workers.length,
52
65
  tabCount: tabInfos.length,
66
+ workers: workers.map((w) => ({
67
+ id: w.id,
68
+ name: w.name,
69
+ tabCount: workerTabs[w.id]?.length || 0,
70
+ tabs: workerTabs[w.id] || [],
71
+ })),
53
72
  }, null, 2),
54
73
  },
55
74
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-context.js","sourceRoot":"","sources":["../../src/tools/tabs-context.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAoFH,0DAEC;AAlFD,wDAAuD;AAEvD,MAAM,UAAU,GAAsB;IACpC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,wIAAwI;IAC1I,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,aAAa,EAAE;gBACb,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8CAA8C;aAC5D;SACF;QACD,QAAQ,EAAE,EAAE;KACb;CACF,CAAC;AAEF,MAAM,OAAO,GAAgB,KAAK,EAChC,SAAiB,EACjB,IAA6B,EACT,EAAE;IACtB,MAAM,aAAa,GAAG,IAAI,CAAC,aAAoC,CAAC;IAChE,MAAM,cAAc,GAAG,IAAA,mCAAiB,GAAE,CAAC;IAE3C,IAAI,CAAC;QACH,MAAM,OAAO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AAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC;4BACvC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE;yBAC7B,CAAC,CAAC;qBACJ,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,8BAA8B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBAC7F;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,SAAgB,uBAAuB,CAAC,MAAiB;IACvD,MAAM,CAAC,YAAY,CAAC,kBAAkB,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tabs Create Tool - Create a new tab in the session
2
+ * Tabs Create Tool - Create a new tab in the session with a specific URL
3
3
  */
4
4
  import { MCPServer } from '../mcp-server';
5
5
  export declare function registerTabsCreateTool(server: MCPServer): void;
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-create.d.ts","sourceRoot":"","sources":["../../src/tools/tabs-create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAoD1C,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE9D"}
1
+ {"version":3,"file":"tabs-create.d.ts","sourceRoot":"","sources":["../../src/tools/tabs-create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA6E1C,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE9D"}
@@ -1,29 +1,53 @@
1
1
  "use strict";
2
2
  /**
3
- * Tabs Create Tool - Create a new tab in the session
3
+ * Tabs Create Tool - Create a new tab in the session with a specific URL
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerTabsCreateTool = registerTabsCreateTool;
7
7
  const session_manager_1 = require("../session-manager");
8
8
  const definition = {
9
9
  name: 'tabs_create_mcp',
10
- description: 'Creates a new empty tab in the MCP session.',
10
+ description: 'Creates a new tab with the specified URL. URL is required to prevent about:blank tab accumulation. Use workerId for parallel browser operations.',
11
11
  inputSchema: {
12
12
  type: 'object',
13
- properties: {},
14
- required: [],
13
+ properties: {
14
+ url: {
15
+ type: 'string',
16
+ description: 'URL to open in the new tab (required)',
17
+ },
18
+ workerId: {
19
+ type: 'string',
20
+ description: 'Worker ID for parallel operations. Uses default worker if not specified.',
21
+ },
22
+ },
23
+ required: ['url'],
15
24
  },
16
25
  };
17
- const handler = async (sessionId, _args) => {
26
+ const handler = async (sessionId, args) => {
18
27
  const sessionManager = (0, session_manager_1.getSessionManager)();
28
+ const url = args.url;
29
+ const workerId = args.workerId;
30
+ // URL is required
31
+ if (!url) {
32
+ return {
33
+ content: [
34
+ {
35
+ type: 'text',
36
+ text: 'Error: url is required. Use navigate tool without tabId to create a new tab with a URL.',
37
+ },
38
+ ],
39
+ isError: true,
40
+ };
41
+ }
19
42
  try {
20
- const { targetId, page } = await sessionManager.createTarget(sessionId, 'about:blank');
43
+ const { targetId, page, workerId: assignedWorkerId } = await sessionManager.createTarget(sessionId, url, workerId);
21
44
  return {
22
45
  content: [
23
46
  {
24
47
  type: 'text',
25
48
  text: JSON.stringify({
26
49
  tabId: targetId,
50
+ workerId: assignedWorkerId,
27
51
  url: page.url(),
28
52
  title: await page.title(),
29
53
  }, null, 2),
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-create.js","sourceRoot":"","sources":["../../src/tools/tabs-create.ts"],"names":[],"mappings":";AAAA;;GAEG;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E;qBAC1B,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,uBAAuB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBACtF;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,SAAgB,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Worker Create Tool - Create a new isolated worker within a session
3
+ * Each worker has its own browser context (cookies, localStorage, sessionStorage)
4
+ */
5
+ import { MCPServer } from '../mcp-server';
6
+ export declare function registerWorkerCreateTool(server: MCPServer): void;
7
+ //# sourceMappingURL=worker-create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-create.d.ts","sourceRoot":"","sources":["../../src/tools/worker-create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAgE1C,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAEhE"}