claude-chrome-parallel 2.1.1 → 2.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.
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ /**
3
+ * Network Tool - Network simulation and throttling
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerNetworkTool = registerNetworkTool;
7
+ const session_manager_1 = require("../session-manager");
8
+ // Predefined network conditions
9
+ const NETWORK_PRESETS = {
10
+ offline: {
11
+ downloadThroughput: 0,
12
+ uploadThroughput: 0,
13
+ latency: 0,
14
+ },
15
+ 'slow-2g': {
16
+ downloadThroughput: (50 * 1024) / 8, // 50 Kbps
17
+ uploadThroughput: (20 * 1024) / 8,
18
+ latency: 2000,
19
+ },
20
+ '2g': {
21
+ downloadThroughput: (250 * 1024) / 8, // 250 Kbps
22
+ uploadThroughput: (50 * 1024) / 8,
23
+ latency: 300,
24
+ },
25
+ '3g': {
26
+ downloadThroughput: (1.5 * 1024 * 1024) / 8, // 1.5 Mbps
27
+ uploadThroughput: (750 * 1024) / 8,
28
+ latency: 100,
29
+ },
30
+ '4g': {
31
+ downloadThroughput: (20 * 1024 * 1024) / 8, // 20 Mbps
32
+ uploadThroughput: (10 * 1024 * 1024) / 8,
33
+ latency: 20,
34
+ },
35
+ 'fast-wifi': {
36
+ downloadThroughput: (100 * 1024 * 1024) / 8, // 100 Mbps
37
+ uploadThroughput: (50 * 1024 * 1024) / 8,
38
+ latency: 2,
39
+ },
40
+ };
41
+ const definition = {
42
+ name: 'network',
43
+ description: `Simulate network conditions for testing.
44
+ Presets: offline, slow-2g, 2g, 3g, 4g, fast-wifi
45
+ Use "clear" to remove throttling.
46
+ Use "custom" with downloadKbps, uploadKbps, and latencyMs for custom conditions.`,
47
+ inputSchema: {
48
+ type: 'object',
49
+ properties: {
50
+ tabId: {
51
+ type: 'string',
52
+ description: 'Tab ID to apply network conditions to',
53
+ },
54
+ preset: {
55
+ type: 'string',
56
+ description: 'Network preset: offline, slow-2g, 2g, 3g, 4g, fast-wifi, custom, or clear',
57
+ enum: ['offline', 'slow-2g', '2g', '3g', '4g', 'fast-wifi', 'custom', 'clear'],
58
+ },
59
+ downloadKbps: {
60
+ type: 'number',
61
+ description: 'Custom download speed in Kbps (only for preset=custom)',
62
+ },
63
+ uploadKbps: {
64
+ type: 'number',
65
+ description: 'Custom upload speed in Kbps (only for preset=custom)',
66
+ },
67
+ latencyMs: {
68
+ type: 'number',
69
+ description: 'Custom latency in milliseconds (only for preset=custom)',
70
+ },
71
+ },
72
+ required: ['tabId', 'preset'],
73
+ },
74
+ };
75
+ const handler = async (sessionId, args) => {
76
+ const tabId = args.tabId;
77
+ const preset = args.preset;
78
+ const downloadKbps = args.downloadKbps;
79
+ const uploadKbps = args.uploadKbps;
80
+ const latencyMs = args.latencyMs;
81
+ const sessionManager = (0, session_manager_1.getSessionManager)();
82
+ if (!tabId) {
83
+ return {
84
+ content: [{ type: 'text', text: 'Error: tabId is required' }],
85
+ isError: true,
86
+ };
87
+ }
88
+ if (!preset) {
89
+ return {
90
+ content: [{ type: 'text', text: 'Error: preset is required' }],
91
+ isError: true,
92
+ };
93
+ }
94
+ try {
95
+ const page = await sessionManager.getPage(sessionId, tabId);
96
+ if (!page) {
97
+ return {
98
+ content: [{ type: 'text', text: `Error: Tab ${tabId} not found` }],
99
+ isError: true,
100
+ };
101
+ }
102
+ // Get CDP session
103
+ const client = await page.createCDPSession();
104
+ // Clear network conditions
105
+ if (preset === 'clear') {
106
+ await client.send('Network.emulateNetworkConditions', {
107
+ offline: false,
108
+ downloadThroughput: -1,
109
+ uploadThroughput: -1,
110
+ latency: 0,
111
+ });
112
+ await client.detach();
113
+ return {
114
+ content: [
115
+ {
116
+ type: 'text',
117
+ text: JSON.stringify({
118
+ action: 'network_clear',
119
+ message: 'Network throttling cleared',
120
+ }),
121
+ },
122
+ ],
123
+ };
124
+ }
125
+ // Custom network conditions
126
+ if (preset === 'custom') {
127
+ if (downloadKbps === undefined || uploadKbps === undefined || latencyMs === undefined) {
128
+ return {
129
+ content: [
130
+ {
131
+ type: 'text',
132
+ text: 'Error: custom preset requires downloadKbps, uploadKbps, and latencyMs',
133
+ },
134
+ ],
135
+ isError: true,
136
+ };
137
+ }
138
+ await client.send('Network.emulateNetworkConditions', {
139
+ offline: false,
140
+ downloadThroughput: (downloadKbps * 1024) / 8,
141
+ uploadThroughput: (uploadKbps * 1024) / 8,
142
+ latency: latencyMs,
143
+ });
144
+ await client.detach();
145
+ return {
146
+ content: [
147
+ {
148
+ type: 'text',
149
+ text: JSON.stringify({
150
+ action: 'network_custom',
151
+ downloadKbps,
152
+ uploadKbps,
153
+ latencyMs,
154
+ message: `Custom network conditions applied: ${downloadKbps}Kbps down, ${uploadKbps}Kbps up, ${latencyMs}ms latency`,
155
+ }),
156
+ },
157
+ ],
158
+ };
159
+ }
160
+ // Preset network conditions
161
+ const presetConfig = NETWORK_PRESETS[preset];
162
+ if (!presetConfig) {
163
+ return {
164
+ content: [
165
+ {
166
+ type: 'text',
167
+ text: `Error: Unknown preset "${preset}". Available: ${Object.keys(NETWORK_PRESETS).join(', ')}`,
168
+ },
169
+ ],
170
+ isError: true,
171
+ };
172
+ }
173
+ await client.send('Network.emulateNetworkConditions', {
174
+ offline: preset === 'offline',
175
+ downloadThroughput: presetConfig.downloadThroughput,
176
+ uploadThroughput: presetConfig.uploadThroughput,
177
+ latency: presetConfig.latency,
178
+ });
179
+ await client.detach();
180
+ const downloadMbps = ((presetConfig.downloadThroughput * 8) / 1024 / 1024).toFixed(2);
181
+ const uploadMbps = ((presetConfig.uploadThroughput * 8) / 1024 / 1024).toFixed(2);
182
+ return {
183
+ content: [
184
+ {
185
+ type: 'text',
186
+ text: JSON.stringify({
187
+ action: 'network_throttle',
188
+ preset,
189
+ downloadMbps: Number(downloadMbps),
190
+ uploadMbps: Number(uploadMbps),
191
+ latencyMs: presetConfig.latency,
192
+ message: preset === 'offline'
193
+ ? 'Network set to offline mode'
194
+ : `Network throttled to ${preset}: ${downloadMbps}Mbps down, ${uploadMbps}Mbps up, ${presetConfig.latency}ms latency`,
195
+ }),
196
+ },
197
+ ],
198
+ };
199
+ }
200
+ catch (error) {
201
+ return {
202
+ content: [
203
+ {
204
+ type: 'text',
205
+ text: `Network error: ${error instanceof Error ? error.message : String(error)}`,
206
+ },
207
+ ],
208
+ isError: true,
209
+ };
210
+ }
211
+ };
212
+ function registerNetworkTool(server) {
213
+ server.registerTool('network', handler, definition);
214
+ }
215
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/tools/network.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA6OH,kDAEC;AA3OD,wDAAuD;AAEvD,gCAAgC;AAChC,MAAM,eAAe,GAGjB;IACF,OAAO,EAAE;QACP,kBAAkB,EAAE,CAAC;QACrB,gBAAgB,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;KACX;IACD,SAAS,EAAE;QACT,kBAAkB,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU;QAC/C,gBAAgB,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QACjC,OAAO,EAAE,IAAI;KACd;IACD,IAAI,EAAE;QACJ,kBAAkB,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,WAAW;QACjD,gBAAgB,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QACjC,OAAO,EAAE,GAAG;KACb;IACD,IAAI,EAAE;QACJ,kBAAkB,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,WAAW;QACxD,gBAAgB,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QAClC,OAAO,EAAE,GAAG;KACb;IACD,IAAI,EAAE;QACJ,kBAAkB,EAAE,CAAC,EAAE,GAAG,IAAI,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;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,kBAAkB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBACjF;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,SAAgB,mBAAmB,CAAC,MAAiB;IACnD,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACtD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-chrome-parallel",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "MCP server for parallel Claude Code browser sessions - no more 'Detached' errors",
5
5
  "main": "dist/index.js",
6
6
  "bin": {