auto-webmcp 0.3.1 → 0.3.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/README.md +156 -38
- package/dist/auto-webmcp.cjs.js +3 -76
- package/dist/auto-webmcp.cjs.js.map +3 -3
- package/dist/auto-webmcp.esm.js +3 -76
- package/dist/auto-webmcp.esm.js.map +3 -3
- package/dist/auto-webmcp.iife.js +1 -9
- package/dist/auto-webmcp.iife.js.map +4 -4
- package/dist/config.d.ts +0 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/interceptor.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/auto-webmcp.esm.js
CHANGED
|
@@ -83,7 +83,6 @@ function resolveConfig(userConfig) {
|
|
|
83
83
|
return {
|
|
84
84
|
exclude: userConfig?.exclude ?? [],
|
|
85
85
|
autoSubmit: userConfig?.autoSubmit ?? false,
|
|
86
|
-
enhance: userConfig?.enhance ?? null,
|
|
87
86
|
overrides: userConfig?.overrides ?? {},
|
|
88
87
|
debug: userConfig?.debug ?? false
|
|
89
88
|
};
|
|
@@ -411,7 +410,7 @@ function inferToolDescription(form) {
|
|
|
411
410
|
const heading = getNearestHeadingText(form);
|
|
412
411
|
const pageTitle = document.title?.trim();
|
|
413
412
|
if (heading && pageTitle)
|
|
414
|
-
return `${heading}
|
|
413
|
+
return `${heading}: ${pageTitle}`;
|
|
415
414
|
if (heading)
|
|
416
415
|
return heading;
|
|
417
416
|
if (pageTitle)
|
|
@@ -940,6 +939,7 @@ function buildExecuteHandler(form, config, toolName, metadata) {
|
|
|
940
939
|
attachSubmitInterceptor(form, toolName);
|
|
941
940
|
return async (params) => {
|
|
942
941
|
pendingFillWarnings.set(form, []);
|
|
942
|
+
pendingWarnings.delete(form);
|
|
943
943
|
fillFormFields(form, params);
|
|
944
944
|
const missingNow = getMissingRequired(metadata, params);
|
|
945
945
|
if (missingNow.length > 0)
|
|
@@ -1365,74 +1365,6 @@ function getMissingRequired(metadata, params) {
|
|
|
1365
1365
|
return metadata.inputSchema.required.filter((fieldKey) => !(fieldKey in params));
|
|
1366
1366
|
}
|
|
1367
1367
|
|
|
1368
|
-
// src/enhancer.ts
|
|
1369
|
-
async function enrichMetadata(metadata, enhancer) {
|
|
1370
|
-
try {
|
|
1371
|
-
const enriched = await callLLM(metadata, enhancer);
|
|
1372
|
-
return { ...metadata, description: enriched };
|
|
1373
|
-
} catch (err) {
|
|
1374
|
-
console.warn("[auto-webmcp] Enrichment failed, using heuristic description:", err);
|
|
1375
|
-
return metadata;
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
async function callLLM(metadata, config) {
|
|
1379
|
-
const prompt = buildPrompt(metadata);
|
|
1380
|
-
if (config.provider === "claude") {
|
|
1381
|
-
return callClaude(prompt, config);
|
|
1382
|
-
} else {
|
|
1383
|
-
return callGemini(prompt, config);
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
function buildPrompt(metadata) {
|
|
1387
|
-
const fields = Object.entries(metadata.inputSchema.properties).map(([name, prop]) => `- ${prop.title ?? name} (${prop.type}): ${prop.description ?? ""}`).join("\n");
|
|
1388
|
-
return `You are helping describe a web form as an AI tool. Given this form information:
|
|
1389
|
-
|
|
1390
|
-
Name: ${metadata.name}
|
|
1391
|
-
Current description: ${metadata.description}
|
|
1392
|
-
Fields:
|
|
1393
|
-
${fields}
|
|
1394
|
-
|
|
1395
|
-
Write a concise (1-2 sentence) description of what this tool does and when an AI agent should use it. Be specific and actionable. Respond with only the description, no preamble.`;
|
|
1396
|
-
}
|
|
1397
|
-
async function callClaude(prompt, config) {
|
|
1398
|
-
const model = config.model ?? "claude-haiku-4-5-20251001";
|
|
1399
|
-
const response = await fetch("https://api.anthropic.com/v1/messages", {
|
|
1400
|
-
method: "POST",
|
|
1401
|
-
headers: {
|
|
1402
|
-
"x-api-key": config.apiKey,
|
|
1403
|
-
"anthropic-version": "2023-06-01",
|
|
1404
|
-
"content-type": "application/json"
|
|
1405
|
-
},
|
|
1406
|
-
body: JSON.stringify({
|
|
1407
|
-
model,
|
|
1408
|
-
max_tokens: 150,
|
|
1409
|
-
messages: [{ role: "user", content: prompt }]
|
|
1410
|
-
})
|
|
1411
|
-
});
|
|
1412
|
-
if (!response.ok) {
|
|
1413
|
-
throw new Error(`Claude API error: ${response.status}`);
|
|
1414
|
-
}
|
|
1415
|
-
const data = await response.json();
|
|
1416
|
-
return data.content.filter((block) => block.type === "text").map((block) => block.text).join("").trim();
|
|
1417
|
-
}
|
|
1418
|
-
async function callGemini(prompt, config) {
|
|
1419
|
-
const model = config.model ?? "gemini-1.5-flash";
|
|
1420
|
-
const url = `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${config.apiKey}`;
|
|
1421
|
-
const response = await fetch(url, {
|
|
1422
|
-
method: "POST",
|
|
1423
|
-
headers: { "content-type": "application/json" },
|
|
1424
|
-
body: JSON.stringify({
|
|
1425
|
-
contents: [{ parts: [{ text: prompt }] }],
|
|
1426
|
-
generationConfig: { maxOutputTokens: 150, temperature: 0.2 }
|
|
1427
|
-
})
|
|
1428
|
-
});
|
|
1429
|
-
if (!response.ok) {
|
|
1430
|
-
throw new Error(`Gemini API error: ${response.status}`);
|
|
1431
|
-
}
|
|
1432
|
-
const data = await response.json();
|
|
1433
|
-
return data.candidates[0]?.content.parts.map((p) => p.text).join("").trim() ?? "";
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
1368
|
// src/discovery.ts
|
|
1437
1369
|
function emit(type, form, toolName) {
|
|
1438
1370
|
window.dispatchEvent(
|
|
@@ -1464,12 +1396,7 @@ async function registerForm(form, config) {
|
|
|
1464
1396
|
} catch {
|
|
1465
1397
|
}
|
|
1466
1398
|
}
|
|
1467
|
-
|
|
1468
|
-
if (config.enhance) {
|
|
1469
|
-
if (config.debug)
|
|
1470
|
-
console.debug(`[auto-webmcp] Enriching: ${metadata.name}\u2026`);
|
|
1471
|
-
metadata = await enrichMetadata(metadata, config.enhance);
|
|
1472
|
-
}
|
|
1399
|
+
const metadata = analyzeForm(form, override);
|
|
1473
1400
|
if (config.debug) {
|
|
1474
1401
|
warnToolQuality(metadata.name, metadata.description);
|
|
1475
1402
|
}
|