auto-webmcp 0.3.8 → 0.3.9
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/dist/auto-webmcp.cjs.js +25 -8
- package/dist/auto-webmcp.cjs.js.map +2 -2
- package/dist/auto-webmcp.esm.js +25 -8
- package/dist/auto-webmcp.esm.js.map +2 -2
- package/dist/auto-webmcp.iife.js +1 -1
- package/dist/auto-webmcp.iife.js.map +3 -3
- package/dist/discovery.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/auto-webmcp.esm.js
CHANGED
|
@@ -1440,6 +1440,11 @@ async function registerForm(form, config) {
|
|
|
1440
1440
|
await registerFormTool(form, metadata, execute);
|
|
1441
1441
|
registeredForms.add(form);
|
|
1442
1442
|
registeredFormCount++;
|
|
1443
|
+
const formSubmitBtn = form.querySelector(
|
|
1444
|
+
'[type="submit"], button[data-variant="primary"], button:not([type])'
|
|
1445
|
+
) ?? null;
|
|
1446
|
+
const pendingBtns = window["__pendingSubmitBtns"] ??= {};
|
|
1447
|
+
pendingBtns[metadata.name] = formSubmitBtn;
|
|
1443
1448
|
if (config.debug) {
|
|
1444
1449
|
console.log(`[auto-webmcp] Registered: ${metadata.name}`, metadata);
|
|
1445
1450
|
}
|
|
@@ -1553,8 +1558,8 @@ var ORPHAN_EXCLUDED_TYPES = /* @__PURE__ */ new Set([
|
|
|
1553
1558
|
async function scanOrphanInputs(config) {
|
|
1554
1559
|
if (!isWebMCPSupported())
|
|
1555
1560
|
return;
|
|
1556
|
-
const SUBMIT_BTN_SELECTOR = '[type="submit"]:not([disabled]), button
|
|
1557
|
-
const SUBMIT_BTN_GROUPING_SELECTOR = '[type="submit"]';
|
|
1561
|
+
const SUBMIT_BTN_SELECTOR = '[type="submit"]:not([disabled]), button[data-variant="primary"]:not([disabled])';
|
|
1562
|
+
const SUBMIT_BTN_GROUPING_SELECTOR = '[type="submit"], button[data-variant="primary"]';
|
|
1558
1563
|
const SUBMIT_TEXT_RE = /subscribe|submit|sign[\s-]?up|send|join|go|search/i;
|
|
1559
1564
|
const orphanInputs = Array.from(
|
|
1560
1565
|
document.querySelectorAll(
|
|
@@ -1603,11 +1608,16 @@ async function scanOrphanInputs(config) {
|
|
|
1603
1608
|
return r.width > 0 && r.height > 0;
|
|
1604
1609
|
});
|
|
1605
1610
|
let submitBtn = allCandidates[allCandidates.length - 1] ?? null;
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
+
if (!submitBtn) {
|
|
1612
|
+
const disabledCandidates = Array.from(
|
|
1613
|
+
container.querySelectorAll(SUBMIT_BTN_GROUPING_SELECTOR)
|
|
1614
|
+
).filter((b) => {
|
|
1615
|
+
const r = b.getBoundingClientRect();
|
|
1616
|
+
return r.width > 0 && r.height > 0 && b.disabled;
|
|
1617
|
+
});
|
|
1618
|
+
submitBtn = disabledCandidates[disabledCandidates.length - 1] ?? null;
|
|
1619
|
+
if (submitBtn)
|
|
1620
|
+
console.log(`[auto-webmcp] orphan: using disabled submit button as reference: "${submitBtn.textContent?.trim()}"`);
|
|
1611
1621
|
}
|
|
1612
1622
|
if (!submitBtn) {
|
|
1613
1623
|
const pageBtns = Array.from(document.querySelectorAll("button")).filter(
|
|
@@ -1637,6 +1647,10 @@ async function scanOrphanInputs(config) {
|
|
|
1637
1647
|
}
|
|
1638
1648
|
}
|
|
1639
1649
|
console.log(`[auto-webmcp] orphan: ${inputPairs.length}/${inputs.length} input(s) mapped to schema keys`);
|
|
1650
|
+
if (inputPairs.length === 0) {
|
|
1651
|
+
console.log(`[auto-webmcp] orphan: skipping group "${metadata.name}" \u2014 no inputs mapped to schema keys`);
|
|
1652
|
+
continue;
|
|
1653
|
+
}
|
|
1640
1654
|
const toolName = metadata.name;
|
|
1641
1655
|
const execute = async (params) => {
|
|
1642
1656
|
console.log(`[auto-webmcp] orphan execute: tool="${toolName}" params=`, params);
|
|
@@ -1651,7 +1665,8 @@ async function scanOrphanInputs(config) {
|
|
|
1651
1665
|
}
|
|
1652
1666
|
}
|
|
1653
1667
|
window.dispatchEvent(new CustomEvent("toolactivated", { detail: { toolName } }));
|
|
1654
|
-
|
|
1668
|
+
const shouldAutoSubmit = config.autoSubmit || !!submitBtn?.hasAttribute("toolautosubmit") || submitBtn instanceof HTMLElement && submitBtn.dataset["webmcpAutosubmit"] !== void 0 || container.hasAttribute("toolautosubmit") || container instanceof HTMLElement && container.dataset["webmcpAutosubmit"] !== void 0;
|
|
1669
|
+
if (!shouldAutoSubmit) {
|
|
1655
1670
|
console.log(`[auto-webmcp] orphan execute: autoSubmit=false, returning without clicking submit`);
|
|
1656
1671
|
return { content: [{ type: "text", text: "Fields filled. Ready to submit." }] };
|
|
1657
1672
|
}
|
|
@@ -1691,6 +1706,8 @@ async function scanOrphanInputs(config) {
|
|
|
1691
1706
|
toolDef.annotations = metadata.annotations;
|
|
1692
1707
|
}
|
|
1693
1708
|
await navigator.modelContext.registerTool(toolDef);
|
|
1709
|
+
const pendingBtns = window["__pendingSubmitBtns"] ??= {};
|
|
1710
|
+
pendingBtns[metadata.name] = submitBtn;
|
|
1694
1711
|
if (config.debug) {
|
|
1695
1712
|
console.log(`[auto-webmcp] Orphan tool registered: ${metadata.name}`, metadata);
|
|
1696
1713
|
}
|