hypha-debugger 0.2.4 → 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
CHANGED
|
@@ -14009,9 +14009,11 @@
|
|
|
14009
14009
|
takeScreenshot.__schema__ = {
|
|
14010
14010
|
name: "takeScreenshot",
|
|
14011
14011
|
description: "Capture a screenshot of the current viewport, a specific element, or the full page. " +
|
|
14012
|
-
"
|
|
14013
|
-
"
|
|
14014
|
-
"
|
|
14012
|
+
"Downscaled to fit within max_width × max_height (default 1024px) to keep the payload " +
|
|
14013
|
+
"small enough for AI agents. Defaults to JPEG at 0.75 quality. " +
|
|
14014
|
+
"Returns: { data: 'data:image/jpeg;base64,...', format, width, height, size_kb }. " +
|
|
14015
|
+
"Note: the image is in the `data` field as a full data: URL — strip the `data:...;base64,` " +
|
|
14016
|
+
"prefix before base64-decoding.",
|
|
14015
14017
|
parameters: {
|
|
14016
14018
|
type: "object",
|
|
14017
14019
|
properties: {
|
|
@@ -14141,7 +14143,11 @@
|
|
|
14141
14143
|
}
|
|
14142
14144
|
executeScript.__schema__ = {
|
|
14143
14145
|
name: "executeScript",
|
|
14144
|
-
description: 'Execute arbitrary JavaScript code in the page context. Supports async/await.
|
|
14146
|
+
description: 'Execute arbitrary JavaScript code in the page context. Supports async/await. ' +
|
|
14147
|
+
'The last expression is auto-returned (no need for explicit "return"). ' +
|
|
14148
|
+
'Examples: "document.title", "document.querySelectorAll(\'a\').length", ' +
|
|
14149
|
+
'"await fetch(\'/api/data\').then(r => r.json())". ' +
|
|
14150
|
+
'Returns: { result, type } on success, or { error } on exception.',
|
|
14145
14151
|
parameters: {
|
|
14146
14152
|
type: "object",
|
|
14147
14153
|
properties: {
|
|
@@ -14750,6 +14756,28 @@
|
|
|
14750
14756
|
"",
|
|
14751
14757
|
"- **GET** for functions with no required parameters",
|
|
14752
14758
|
"- **POST** with JSON body for functions with parameters",
|
|
14759
|
+
"- Append `?_mode=last` to resolve the most recent instance (recommended after page reloads where the clientId changes)",
|
|
14760
|
+
"",
|
|
14761
|
+
"## Response format",
|
|
14762
|
+
"",
|
|
14763
|
+
"All functions return JSON. There are three patterns:",
|
|
14764
|
+
"",
|
|
14765
|
+
"**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:",
|
|
14766
|
+
"",
|
|
14767
|
+
"- `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`)",
|
|
14768
|
+
"- `execute_script` → `{result, type}` (or `{error}` on exception)",
|
|
14769
|
+
"- `get_browser_state` → `{url, title, header, content, footer, element_count}`",
|
|
14770
|
+
"- `get_page_info` → `{url, title, viewport_width, viewport_height, ...}`",
|
|
14771
|
+
"- `get_html` → `{html, length, truncated}`",
|
|
14772
|
+
"",
|
|
14773
|
+
"**2. Action functions** (e.g. `click_*`, `input_text`, `select_option`, `scroll`, `navigate`) return:",
|
|
14774
|
+
"",
|
|
14775
|
+
"- `{success: true, message: \"...\"}` — action succeeded",
|
|
14776
|
+
"- `{success: false, message: \"...\"}` — action failed (element not found, etc.)",
|
|
14777
|
+
"",
|
|
14778
|
+
"**3. Errors from the Hypha gateway** (NOT from the service itself) return:",
|
|
14779
|
+
"",
|
|
14780
|
+
"- `{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.",
|
|
14753
14781
|
"",
|
|
14754
14782
|
].join("\n");
|
|
14755
14783
|
// Build the function reference
|
|
@@ -14771,11 +14799,15 @@
|
|
|
14771
14799
|
for (const [param, info] of Object.entries(props)) {
|
|
14772
14800
|
const isRequired = required.includes(param);
|
|
14773
14801
|
let typeStr = info.type ?? "any";
|
|
14774
|
-
if (info.enum)
|
|
14775
|
-
|
|
14802
|
+
if (info.enum) {
|
|
14803
|
+
// Use HTML-escaped "or" separator; "|" breaks Markdown tables.
|
|
14804
|
+
typeStr = info.enum.map((e) => `"${e}"`).join(" / ");
|
|
14805
|
+
}
|
|
14776
14806
|
if (info.items)
|
|
14777
14807
|
typeStr = `${info.items.type}[]`;
|
|
14778
|
-
|
|
14808
|
+
// Escape pipes in descriptions to avoid breaking table layout
|
|
14809
|
+
const desc = (info.description ?? "").replace(/\|/g, "\\|");
|
|
14810
|
+
functionDocs.push(`| \`${param}\` | ${typeStr} | ${isRequired ? "Yes" : "No"} | ${desc} |`);
|
|
14779
14811
|
}
|
|
14780
14812
|
functionDocs.push("");
|
|
14781
14813
|
// Example curl
|
|
@@ -14817,14 +14849,17 @@
|
|
|
14817
14849
|
const tips = [
|
|
14818
14850
|
"## Tips",
|
|
14819
14851
|
"",
|
|
14820
|
-
"- **`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.",
|
|
14852
|
+
"- **`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}`.",
|
|
14821
14853
|
"- **`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.",
|
|
14822
14854
|
"- **After each action, call `get_browser_state` again** — element indices change when the DOM updates.",
|
|
14823
|
-
"- **Use `take_screenshot`** to visually verify the page state.
|
|
14855
|
+
"- **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.",
|
|
14856
|
+
"- **Use `remove_highlights`** before a screenshot for a clean view.",
|
|
14824
14857
|
"- **Use `scroll`** with an element index to scroll inside a specific container (e.g. a chat window, sidebar).",
|
|
14825
14858
|
"- **Use `get_page_info` with `include_logs=true`** to check for JavaScript errors or debug output.",
|
|
14826
14859
|
"- **Use `get_react_tree`** if the page uses React — it gives you component names, props, and state without needing DevTools.",
|
|
14827
14860
|
"- **Use `navigate`** to go to other pages — same-origin navigation auto-reconnects the debugger.",
|
|
14861
|
+
"- **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.",
|
|
14862
|
+
"- **Append `?_mode=last`** to the URL if the service clientId changed (e.g. after page reload) — resolves to the most recent instance.",
|
|
14828
14863
|
"- All POST endpoints accept JSON body with the parameter names as keys.",
|
|
14829
14864
|
"",
|
|
14830
14865
|
].join("\n");
|