hypha-debugger 0.2.3 → 0.2.5
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/hypha-debugger.js +18140 -14570
- package/dist/hypha-debugger.js.map +1 -1
- package/dist/hypha-debugger.min.js +48 -39
- package/dist/hypha-debugger.min.js.map +1 -1
- package/dist/hypha-debugger.mjs +44 -9
- package/dist/hypha-debugger.mjs.map +1 -1
- package/package.json +2 -2
package/dist/hypha-debugger.mjs
CHANGED
|
@@ -2129,9 +2129,11 @@ async function takeScreenshot(selector, format, quality, max_width, max_height,
|
|
|
2129
2129
|
takeScreenshot.__schema__ = {
|
|
2130
2130
|
name: "takeScreenshot",
|
|
2131
2131
|
description: "Capture a screenshot of the current viewport, a specific element, or the full page. " +
|
|
2132
|
-
"
|
|
2133
|
-
"
|
|
2134
|
-
"
|
|
2132
|
+
"Downscaled to fit within max_width × max_height (default 1024px) to keep the payload " +
|
|
2133
|
+
"small enough for AI agents. Defaults to JPEG at 0.75 quality. " +
|
|
2134
|
+
"Returns: { data: 'data:image/jpeg;base64,...', format, width, height, size_kb }. " +
|
|
2135
|
+
"Note: the image is in the `data` field as a full data: URL — strip the `data:...;base64,` " +
|
|
2136
|
+
"prefix before base64-decoding.",
|
|
2135
2137
|
parameters: {
|
|
2136
2138
|
type: "object",
|
|
2137
2139
|
properties: {
|
|
@@ -2261,7 +2263,11 @@ async function executeScript(code, timeout_ms) {
|
|
|
2261
2263
|
}
|
|
2262
2264
|
executeScript.__schema__ = {
|
|
2263
2265
|
name: "executeScript",
|
|
2264
|
-
description: 'Execute arbitrary JavaScript code in the page context. Supports async/await.
|
|
2266
|
+
description: 'Execute arbitrary JavaScript code in the page context. Supports async/await. ' +
|
|
2267
|
+
'The last expression is auto-returned (no need for explicit "return"). ' +
|
|
2268
|
+
'Examples: "document.title", "document.querySelectorAll(\'a\').length", ' +
|
|
2269
|
+
'"await fetch(\'/api/data\').then(r => r.json())". ' +
|
|
2270
|
+
'Returns: { result, type } on success, or { error } on exception.',
|
|
2265
2271
|
parameters: {
|
|
2266
2272
|
type: "object",
|
|
2267
2273
|
properties: {
|
|
@@ -2870,6 +2876,28 @@ function generateSkillMd(serviceFunctions, serviceUrl) {
|
|
|
2870
2876
|
"",
|
|
2871
2877
|
"- **GET** for functions with no required parameters",
|
|
2872
2878
|
"- **POST** with JSON body for functions with parameters",
|
|
2879
|
+
"- Append `?_mode=last` to resolve the most recent instance (recommended after page reloads where the clientId changes)",
|
|
2880
|
+
"",
|
|
2881
|
+
"## Response format",
|
|
2882
|
+
"",
|
|
2883
|
+
"All functions return JSON. There are three patterns:",
|
|
2884
|
+
"",
|
|
2885
|
+
"**1. Data-returning functions** (e.g. `take_screenshot`, `get_page_info`, `execute_script`, `get_browser_state`, `get_html`, `get_react_tree`) return function-specific keys:",
|
|
2886
|
+
"",
|
|
2887
|
+
"- `take_screenshot` → `{data, format, width, height, size_kb}` where `data` is a `data:image/jpeg;base64,...` URL (note: field is `data`, not `screenshot` or `image`)",
|
|
2888
|
+
"- `execute_script` → `{result, type}` (or `{error}` on exception)",
|
|
2889
|
+
"- `get_browser_state` → `{url, title, header, content, footer, element_count}`",
|
|
2890
|
+
"- `get_page_info` → `{url, title, viewport_width, viewport_height, ...}`",
|
|
2891
|
+
"- `get_html` → `{html, length, truncated}`",
|
|
2892
|
+
"",
|
|
2893
|
+
"**2. Action functions** (e.g. `click_*`, `input_text`, `select_option`, `scroll`, `navigate`) return:",
|
|
2894
|
+
"",
|
|
2895
|
+
"- `{success: true, message: \"...\"}` — action succeeded",
|
|
2896
|
+
"- `{success: false, message: \"...\"}` — action failed (element not found, etc.)",
|
|
2897
|
+
"",
|
|
2898
|
+
"**3. Errors from the Hypha gateway** (NOT from the service itself) return:",
|
|
2899
|
+
"",
|
|
2900
|
+
"- `{success: false, detail: \"...\"}` — e.g. service not found, call timed out, disconnected. If you see this, the browser tab is probably closed or the debugger crashed.",
|
|
2873
2901
|
"",
|
|
2874
2902
|
].join("\n");
|
|
2875
2903
|
// Build the function reference
|
|
@@ -2891,11 +2919,15 @@ function generateSkillMd(serviceFunctions, serviceUrl) {
|
|
|
2891
2919
|
for (const [param, info] of Object.entries(props)) {
|
|
2892
2920
|
const isRequired = required.includes(param);
|
|
2893
2921
|
let typeStr = info.type ?? "any";
|
|
2894
|
-
if (info.enum)
|
|
2895
|
-
|
|
2922
|
+
if (info.enum) {
|
|
2923
|
+
// Use HTML-escaped "or" separator; "|" breaks Markdown tables.
|
|
2924
|
+
typeStr = info.enum.map((e) => `"${e}"`).join(" / ");
|
|
2925
|
+
}
|
|
2896
2926
|
if (info.items)
|
|
2897
2927
|
typeStr = `${info.items.type}[]`;
|
|
2898
|
-
|
|
2928
|
+
// Escape pipes in descriptions to avoid breaking table layout
|
|
2929
|
+
const desc = (info.description ?? "").replace(/\|/g, "\\|");
|
|
2930
|
+
functionDocs.push(`| \`${param}\` | ${typeStr} | ${isRequired ? "Yes" : "No"} | ${desc} |`);
|
|
2899
2931
|
}
|
|
2900
2932
|
functionDocs.push("");
|
|
2901
2933
|
// Example curl
|
|
@@ -2937,14 +2969,17 @@ function generateSkillMd(serviceFunctions, serviceUrl) {
|
|
|
2937
2969
|
const tips = [
|
|
2938
2970
|
"## Tips",
|
|
2939
2971
|
"",
|
|
2940
|
-
"- **`execute_script` is the most versatile** — use it for reading state, calling APIs, DOM queries, or anything not covered by other functions. The last expression is auto-returned.",
|
|
2972
|
+
"- **`execute_script` is the most versatile** — use it for reading state, calling APIs, DOM queries, or anything not covered by other functions. The last expression is auto-returned. Returns `{result, type}`.",
|
|
2941
2973
|
"- **`get_browser_state` is the best way to see what's on the page** — it detects all interactive elements and shows them as indexed items.",
|
|
2942
2974
|
"- **After each action, call `get_browser_state` again** — element indices change when the DOM updates.",
|
|
2943
|
-
"- **Use `take_screenshot`** to visually verify the page state.
|
|
2975
|
+
"- **Use `take_screenshot`** to visually verify the page state. The image is returned in the `data` field as a `data:image/jpeg;base64,...` URL — strip the `data:...;base64,` prefix before decoding.",
|
|
2976
|
+
"- **Use `remove_highlights`** before a screenshot for a clean view.",
|
|
2944
2977
|
"- **Use `scroll`** with an element index to scroll inside a specific container (e.g. a chat window, sidebar).",
|
|
2945
2978
|
"- **Use `get_page_info` with `include_logs=true`** to check for JavaScript errors or debug output.",
|
|
2946
2979
|
"- **Use `get_react_tree`** if the page uses React — it gives you component names, props, and state without needing DevTools.",
|
|
2947
2980
|
"- **Use `navigate`** to go to other pages — same-origin navigation auto-reconnects the debugger.",
|
|
2981
|
+
"- **If you get `{success: false, detail: \"Service not found\"}`** — the browser tab was closed or the debugger disconnected. The user needs to re-click the bookmarklet.",
|
|
2982
|
+
"- **Append `?_mode=last`** to the URL if the service clientId changed (e.g. after page reload) — resolves to the most recent instance.",
|
|
2948
2983
|
"- All POST endpoints accept JSON body with the parameter names as keys.",
|
|
2949
2984
|
"",
|
|
2950
2985
|
].join("\n");
|