chrome-devtools-mcp-for-extension 0.19.2 → 0.19.3
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/build/src/tools/gemini-web.js +17 -25
- package/package.json +1 -1
|
@@ -171,38 +171,37 @@ export const askGeminiWeb = defineTool({
|
|
|
171
171
|
const project = projectName || path.basename(process.cwd()) || 'unknown-project';
|
|
172
172
|
const page = context.getSelectedPage();
|
|
173
173
|
try {
|
|
174
|
-
response.appendResponseLine('Geminiに接続中...');
|
|
175
|
-
await navigateWithRetry(page, GEMINI_CONFIG.DEFAULT_URL, { waitUntil: 'networkidle2' });
|
|
176
|
-
const needsLogin = await isLoginRequired(page);
|
|
177
|
-
if (needsLogin) {
|
|
178
|
-
response.appendResponseLine('\n❌ Geminiへのログインが必要です');
|
|
179
|
-
response.appendResponseLine('ブラウザでログインしてください。');
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
response.appendResponseLine('✅ ログイン確認完了');
|
|
183
174
|
let isNewChat = false;
|
|
184
175
|
let sessionChatId;
|
|
176
|
+
let targetUrl;
|
|
177
|
+
// Determine target URL first (avoid unnecessary navigation)
|
|
185
178
|
if (!createNewChat) {
|
|
186
179
|
const sessions = await loadChatSessions();
|
|
187
180
|
const projectSessions = sessions[project] || [];
|
|
188
181
|
if (projectSessions.length > 0) {
|
|
189
182
|
const sortedSessions = [...projectSessions].sort((a, b) => new Date(b.lastUsed).getTime() - new Date(a.lastUsed).getTime());
|
|
190
183
|
const latestSession = sortedSessions[0];
|
|
191
|
-
|
|
192
|
-
await navigateWithRetry(page, latestSession.url, { waitUntil: 'networkidle2' });
|
|
184
|
+
targetUrl = latestSession.url;
|
|
193
185
|
sessionChatId = latestSession.chatId;
|
|
194
|
-
|
|
186
|
+
response.appendResponseLine(`既存チャット: ${latestSession.chatId}`);
|
|
195
187
|
}
|
|
196
188
|
else {
|
|
197
189
|
isNewChat = true;
|
|
190
|
+
targetUrl = GEMINI_CONFIG.BASE_URL + 'app';
|
|
198
191
|
}
|
|
199
192
|
}
|
|
200
193
|
else {
|
|
201
194
|
isNewChat = true;
|
|
195
|
+
targetUrl = GEMINI_CONFIG.BASE_URL + 'app';
|
|
202
196
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
197
|
+
// Navigate directly to target URL (skip intermediate navigation)
|
|
198
|
+
response.appendResponseLine('Geminiに接続中...');
|
|
199
|
+
await navigateWithRetry(page, targetUrl, { waitUntil: 'networkidle2' });
|
|
200
|
+
// Check login only once after navigation
|
|
201
|
+
const needsLogin = await isLoginRequired(page);
|
|
202
|
+
if (needsLogin) {
|
|
203
|
+
response.appendResponseLine('❌ ログインが必要です');
|
|
204
|
+
return;
|
|
206
205
|
}
|
|
207
206
|
response.appendResponseLine('質問を送信中...');
|
|
208
207
|
// Input text using the textbox element
|
|
@@ -313,10 +312,9 @@ export const askGeminiWeb = defineTool({
|
|
|
313
312
|
response.appendResponseLine('⚠️ 生成開始を検出できませんでした(続行します)');
|
|
314
313
|
}
|
|
315
314
|
const startTime = Date.now();
|
|
316
|
-
let stableCount = 0;
|
|
317
315
|
let lastResponseText = '';
|
|
318
316
|
while (true) {
|
|
319
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
317
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
320
318
|
const status = await page.evaluate(() => {
|
|
321
319
|
// Check for stop icon (Gemini's thinking/generating indicator)
|
|
322
320
|
// The stop icon is in a div.stop-icon with mat-icon[fonticon="stop"]
|
|
@@ -384,15 +382,9 @@ export const askGeminiWeb = defineTool({
|
|
|
384
382
|
if (status.isComplete && !status.isGenerating) {
|
|
385
383
|
break;
|
|
386
384
|
}
|
|
387
|
-
// If not generating and response text is stable
|
|
385
|
+
// If not generating and response text is stable, we're done
|
|
388
386
|
if (!status.isGenerating && status.responseContent === lastResponseText && status.responseContent.length > 0) {
|
|
389
|
-
|
|
390
|
-
if (stableCount >= 2) {
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
stableCount = 0;
|
|
387
|
+
break; // No need to wait for multiple stable iterations
|
|
396
388
|
}
|
|
397
389
|
lastResponseText = status.responseContent;
|
|
398
390
|
if (Date.now() - startTime > 180000) { // 3 mins timeout
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-devtools-mcp-for-extension",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"description": "MCP server for Chrome extension development with Web Store automation. Fork of chrome-devtools-mcp with extension-specific tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./scripts/cli.mjs",
|