--- id: "7fa0d712-5c99-4ef5-8326-226915ea9aa9" name: "Function Discovery" micro_summary: "**Required reading:** discover which helpers are available before writing browser-harness commands" status: "resolved" see_also: [] scope: "How to discover all callable helpers available in the browser-harness execution context." warnings: "Navigation preference: use `list_tabs()` → `switch_tab(tab)` to reuse an existing matching tab before any `new_tab(url)`/`goto_url(url)` call. New tabs are only for no suitable tab or explicit user request." --- ## Function Discovery When you need to discover all callable helpers available in the browser-harness execution context, use `globals()` inside a `browser-harness -c` call: ```bash browser-harness -c ' funcs = sorted([name for name in globals() if callable(globals()[name]) and not name.startswith("_")]) print(", ".join(funcs)) ' ``` This works because `browser-harness -c` runs your code in the same `globals()` namespace that the daemon exposes. The `from .helpers import *` in `run.py` imports all public functions into this namespace. ### What's available - **Core helpers** (from `helpers.py`): `goto_url`, `new_tab`, `capture_screenshot`, `click_at_xy`, `js`, `page_info`, `list_tabs`, `wait`, `wait_for_load`, etc. - **Admin helpers** (from `admin.py`): `daemon_alive`, `ensure_daemon`, `run_doctor`, `run_update`, `list_cloud_profiles`, `list_local_profiles` - **Agent helpers** (from `agent-workspace/agent_helpers.py`): `canvas_get_assignments`, `canvas_get_weekly_assignments` - **Stdlib**: `os`, `sys`, `json`, `datetime`, `Path`, `base64`, `urllib`, `importlib`, `math`, `time` ### Quick peek ```bash browser-harness -c 'print(dir())' ``` --- ### 2026-08-15 01:34 UTC ## 2026-08-15 — v0.1.8 correction The older `browser-harness -c` examples above are historical: v0.1.8 accepts executable Python only on stdin. Discover helpers with: ```bash browser-harness <<'PY' print(", ".join(sorted(name for name, value in globals().items() if callable(value) and not name.startswith("_")))) PY ``` Agent helpers now load from `$BH_AGENT_WORKSPACE/agent_helpers.py`, defaulting to `~/.config/browser-harness/agent-workspace/agent_helpers.py`, not the repository workspace.