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.cjs.js
CHANGED
|
@@ -1459,6 +1459,11 @@ async function registerForm(form, config) {
|
|
|
1459
1459
|
await registerFormTool(form, metadata, execute);
|
|
1460
1460
|
registeredForms.add(form);
|
|
1461
1461
|
registeredFormCount++;
|
|
1462
|
+
const formSubmitBtn = form.querySelector(
|
|
1463
|
+
'[type="submit"], button[data-variant="primary"], button:not([type])'
|
|
1464
|
+
) ?? null;
|
|
1465
|
+
const pendingBtns = window["__pendingSubmitBtns"] ??= {};
|
|
1466
|
+
pendingBtns[metadata.name] = formSubmitBtn;
|
|
1462
1467
|
if (config.debug) {
|
|
1463
1468
|
console.log(`[auto-webmcp] Registered: ${metadata.name}`, metadata);
|
|
1464
1469
|
}
|
|
@@ -1572,8 +1577,8 @@ var ORPHAN_EXCLUDED_TYPES = /* @__PURE__ */ new Set([
|
|
|
1572
1577
|
async function scanOrphanInputs(config) {
|
|
1573
1578
|
if (!isWebMCPSupported())
|
|
1574
1579
|
return;
|
|
1575
|
-
const SUBMIT_BTN_SELECTOR = '[type="submit"]:not([disabled]), button
|
|
1576
|
-
const SUBMIT_BTN_GROUPING_SELECTOR = '[type="submit"]';
|
|
1580
|
+
const SUBMIT_BTN_SELECTOR = '[type="submit"]:not([disabled]), button[data-variant="primary"]:not([disabled])';
|
|
1581
|
+
const SUBMIT_BTN_GROUPING_SELECTOR = '[type="submit"], button[data-variant="primary"]';
|
|
1577
1582
|
const SUBMIT_TEXT_RE = /subscribe|submit|sign[\s-]?up|send|join|go|search/i;
|
|
1578
1583
|
const orphanInputs = Array.from(
|
|
1579
1584
|
document.querySelectorAll(
|
|
@@ -1622,11 +1627,16 @@ async function scanOrphanInputs(config) {
|
|
|
1622
1627
|
return r.width > 0 && r.height > 0;
|
|
1623
1628
|
});
|
|
1624
1629
|
let submitBtn = allCandidates[allCandidates.length - 1] ?? null;
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
+
if (!submitBtn) {
|
|
1631
|
+
const disabledCandidates = Array.from(
|
|
1632
|
+
container.querySelectorAll(SUBMIT_BTN_GROUPING_SELECTOR)
|
|
1633
|
+
).filter((b) => {
|
|
1634
|
+
const r = b.getBoundingClientRect();
|
|
1635
|
+
return r.width > 0 && r.height > 0 && b.disabled;
|
|
1636
|
+
});
|
|
1637
|
+
submitBtn = disabledCandidates[disabledCandidates.length - 1] ?? null;
|
|
1638
|
+
if (submitBtn)
|
|
1639
|
+
console.log(`[auto-webmcp] orphan: using disabled submit button as reference: "${submitBtn.textContent?.trim()}"`);
|
|
1630
1640
|
}
|
|
1631
1641
|
if (!submitBtn) {
|
|
1632
1642
|
const pageBtns = Array.from(document.querySelectorAll("button")).filter(
|
|
@@ -1656,6 +1666,10 @@ async function scanOrphanInputs(config) {
|
|
|
1656
1666
|
}
|
|
1657
1667
|
}
|
|
1658
1668
|
console.log(`[auto-webmcp] orphan: ${inputPairs.length}/${inputs.length} input(s) mapped to schema keys`);
|
|
1669
|
+
if (inputPairs.length === 0) {
|
|
1670
|
+
console.log(`[auto-webmcp] orphan: skipping group "${metadata.name}" \u2014 no inputs mapped to schema keys`);
|
|
1671
|
+
continue;
|
|
1672
|
+
}
|
|
1659
1673
|
const toolName = metadata.name;
|
|
1660
1674
|
const execute = async (params) => {
|
|
1661
1675
|
console.log(`[auto-webmcp] orphan execute: tool="${toolName}" params=`, params);
|
|
@@ -1670,7 +1684,8 @@ async function scanOrphanInputs(config) {
|
|
|
1670
1684
|
}
|
|
1671
1685
|
}
|
|
1672
1686
|
window.dispatchEvent(new CustomEvent("toolactivated", { detail: { toolName } }));
|
|
1673
|
-
|
|
1687
|
+
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;
|
|
1688
|
+
if (!shouldAutoSubmit) {
|
|
1674
1689
|
console.log(`[auto-webmcp] orphan execute: autoSubmit=false, returning without clicking submit`);
|
|
1675
1690
|
return { content: [{ type: "text", text: "Fields filled. Ready to submit." }] };
|
|
1676
1691
|
}
|
|
@@ -1710,6 +1725,8 @@ async function scanOrphanInputs(config) {
|
|
|
1710
1725
|
toolDef.annotations = metadata.annotations;
|
|
1711
1726
|
}
|
|
1712
1727
|
await navigator.modelContext.registerTool(toolDef);
|
|
1728
|
+
const pendingBtns = window["__pendingSubmitBtns"] ??= {};
|
|
1729
|
+
pendingBtns[metadata.name] = submitBtn;
|
|
1713
1730
|
if (config.debug) {
|
|
1714
1731
|
console.log(`[auto-webmcp] Orphan tool registered: ${metadata.name}`, metadata);
|
|
1715
1732
|
}
|