openclaw-navigator 5.3.2 → 5.3.4

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.
Files changed (2) hide show
  1. package/cli.mjs +128 -8
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * openclaw-navigator v5.3.2
4
+ * openclaw-navigator v5.3.4
5
5
  *
6
6
  * One-command bridge + tunnel for the Navigator browser.
7
7
  * Starts a local bridge, creates a Cloudflare tunnel automatically,
@@ -394,7 +394,8 @@ function handleRequest(req, res) {
394
394
  },
395
395
  routing: {
396
396
  "/ui/*": `localhost:${ocUIPort}`,
397
- "/api/*": `localhost:${ocGatewayPort}`,
397
+ "/api/sessions/*": `localhost:${ocGatewayPort}`,
398
+ "/api/* (other)": `localhost:${ocUIPort} (web UI fallback)`,
398
399
  "/ws": `localhost:${ocGatewayPort} (WebSocket proxy)`,
399
400
  },
400
401
  tunnel: activeTunnelURL
@@ -889,9 +890,11 @@ function handleRequest(req, res) {
889
890
  return;
890
891
  }
891
892
 
892
- // ── Reverse proxy: /api/* → OC Gateway (localhost:ocGatewayPort) ─────
893
- // Keeps /api/ prefix intact all API calls including chat go to the gateway.
894
- if (path.startsWith("/api/")) {
893
+ // ── Reverse proxy: /api/sessions/* → OC Gateway (localhost:ocGatewayPort) ──
894
+ // ONLY proxy known OC gateway paths /api/sessions/* (chat/agent endpoints).
895
+ // Other /api/* paths (e.g. /api/auth/* from NextAuth) fall through to the
896
+ // web UI fallback so login and other web UI API routes work correctly.
897
+ if (path.startsWith("/api/sessions/") || path === "/api/sessions") {
895
898
  const targetURL = `${path}${url.search}`;
896
899
 
897
900
  const proxyOpts = {
@@ -1147,8 +1150,9 @@ ${BOLD}Stability (recommended for production):${RESET}
1147
1150
  --tunnel-hostname <host> Hostname for named tunnel (e.g. nav.yourdomain.com)
1148
1151
 
1149
1152
  ${BOLD}Routing (through Cloudflare tunnel):${RESET}
1150
- /ui/* → localhost:<ui-port> Web UI (proxied to OC gateway's UI server)
1151
- /api/* → localhost:<gateway-port> OC gateway API (chat, sessions, etc.)
1153
+ /ui/* → localhost:<ui-port> Web UI (Next.js on port 4000)
1154
+ /api/sessions/* → localhost:<gateway-port> OC gateway chat/agent API
1155
+ /api/* (other) → localhost:<ui-port> Web UI API routes (auth, etc.)
1152
1156
  /ws, WebSocket → localhost:<gateway-port> WebSocket proxy to OC gateway
1153
1157
  /health → bridge itself Health check
1154
1158
  /navigator/* → bridge itself Navigator control endpoints
@@ -1511,7 +1515,7 @@ module.exports = {
1511
1515
  const uiURL = tunnelURL ? `${tunnelURL}/ui/` : `http://localhost:${port}/ui/`;
1512
1516
  console.log(` ${BOLD}OC Web UI:${RESET} ${CYAN}${uiURL}${RESET}`);
1513
1517
  info(` /ui/* → localhost:${ocUIPort} (web UI proxy)`);
1514
- info(` /api/* → localhost:${ocGatewayPort} (OC gateway)`);
1518
+ info(` /api/sessions/* → localhost:${ocGatewayPort} (OC gateway)`);
1515
1519
  info(` /ws → localhost:${ocGatewayPort} (WebSocket proxy)`);
1516
1520
 
1517
1521
  // ── Startup health checks ──────────────────────────────────────────
@@ -1911,6 +1915,122 @@ module.exports = {
1911
1915
  info(" You can manually configure mcporter for Navigator MCP");
1912
1916
  }
1913
1917
 
1918
+ // ── Inject Navigator section into OC workspace TOOLS.md ──────────────
1919
+ // OC Core reads ~/.openclaw/workspace/TOOLS.md on every agent run.
1920
+ // This ensures the agent ALWAYS knows about Navigator browser integration.
1921
+ try {
1922
+ const toolsMdLocations = [
1923
+ join(homedir(), ".openclaw/workspace"),
1924
+ "/opt/homebrew/lib/node_modules/openclaw/workspace",
1925
+ ];
1926
+ let toolsDir = null;
1927
+ for (const loc of toolsMdLocations) {
1928
+ if (existsSync(loc)) {
1929
+ toolsDir = loc;
1930
+ break;
1931
+ }
1932
+ }
1933
+ if (toolsDir) {
1934
+ const toolsPath = join(toolsDir, "TOOLS.md");
1935
+ const MARKER_START = "<!-- NAVIGATOR-BRIDGE-START -->";
1936
+ const MARKER_END = "<!-- NAVIGATOR-BRIDGE-END -->";
1937
+ const tunnelHint = activeTunnelURL || "https://<tunnel>.trycloudflare.com";
1938
+ const navigatorSection = [
1939
+ MARKER_START,
1940
+ "",
1941
+ "## Navigator Browser (Remote Control via mcporter)",
1942
+ "",
1943
+ "You can control a **remote** Navigator browser instance through MCP tools.",
1944
+ "The Navigator bridge is connected and running — use `mcporter call navigator.<tool>` to interact.",
1945
+ "",
1946
+ "### Connection",
1947
+ `- Bridge: http://localhost:${port}`,
1948
+ `- Tunnel: ${tunnelHint}`,
1949
+ `- Web UI: ${tunnelHint}/ui/`,
1950
+ "- Protocol: mcporter → bridge HTTP → Navigator command queue → CEF browser",
1951
+ "",
1952
+ "### Key Tools (34 total, all prefixed with `navigator_`)",
1953
+ "",
1954
+ "**Browser Control:**",
1955
+ "- `navigator_status` — Check if Navigator is connected",
1956
+ "- `navigator_navigate url=<url>` — Go to a URL in the OpenClaw tab group",
1957
+ "- `navigator_get_ui_url` — Get the OC Web UI URL (open it with navigator_navigate)",
1958
+ "- `navigator_open_tab url=<url>` — Open a new tab",
1959
+ "- `navigator_list_tabs` — List all open tabs",
1960
+ "- `navigator_get_text` — Read visible page text",
1961
+ "- `navigator_get_html` — Get full page HTML",
1962
+ "- `navigator_click selector=<css>` — Click an element",
1963
+ "- `navigator_fill selector=<css> value=<text>` — Fill an input",
1964
+ "- `navigator_submit` — Submit a form",
1965
+ "- `navigator_execute_js code=<js>` — Run JavaScript",
1966
+ "- `navigator_wait_ready` — Wait for page to fully load",
1967
+ "",
1968
+ "**AI Intelligence:**",
1969
+ "- `navigator_analyze_page` — Detect forms, buttons, inputs, links, tables",
1970
+ "- `navigator_find_element intent=<text>` — Find element by description (e.g. 'login button')",
1971
+ "- `navigator_extract_data selector=<css> type=text|table|json` — Extract data",
1972
+ "- `navigator_smart_fill data='{...}'` — Fill forms by field name matching",
1973
+ "",
1974
+ "**Chat Pane:**",
1975
+ "- `navigator_get_chat_messages` — Read chat messages from the Navigator sidebar",
1976
+ "- `navigator_chat_respond message=<text>` — Send a message to the chat pane",
1977
+ "- `navigator_chat_stream text=<partial>` — Stream text (typing effect)",
1978
+ "",
1979
+ "### Common Workflows",
1980
+ "",
1981
+ "**Open OC Dashboard:**",
1982
+ "```bash",
1983
+ "mcporter call navigator.navigator_get_ui_url",
1984
+ "mcporter call navigator.navigator_navigate url=<uiURL>",
1985
+ "```",
1986
+ "",
1987
+ "**Browse a website and read its content:**",
1988
+ "```bash",
1989
+ "mcporter call navigator.navigator_navigate url=https://example.com",
1990
+ "mcporter call navigator.navigator_wait_ready",
1991
+ "mcporter call navigator.navigator_get_text",
1992
+ "```",
1993
+ "",
1994
+ "**Fill and submit a form:**",
1995
+ "```bash",
1996
+ "mcporter call navigator.navigator_analyze_page # see what's on the page",
1997
+ 'mcporter call navigator.navigator_fill selector="#email" value="user@example.com"',
1998
+ 'mcporter call navigator.navigator_click selector="#submit"',
1999
+ "```",
2000
+ "",
2001
+ "### Important Notes",
2002
+ "- All browser actions happen in a dedicated **OpenClaw** tab group — they never interfere with the user's browsing",
2003
+ "- Always call `navigator_wait_ready` after navigation before reading content",
2004
+ "- Use `navigator_analyze_page` before clicking/filling — it shows you what's on the page",
2005
+ "- The bridge polls Navigator every 5 seconds for command results",
2006
+ "",
2007
+ MARKER_END,
2008
+ ].join("\n");
2009
+
2010
+ // Read existing TOOLS.md and replace or append Navigator section
2011
+ let existing = "";
2012
+ try {
2013
+ existing = readFileSync(toolsPath, "utf8");
2014
+ } catch {
2015
+ /* file may not exist yet */
2016
+ }
2017
+ if (existing.includes(MARKER_START)) {
2018
+ // Replace existing Navigator section
2019
+ const before = existing.substring(0, existing.indexOf(MARKER_START));
2020
+ const after = existing.substring(existing.indexOf(MARKER_END) + MARKER_END.length);
2021
+ writeFileSync(toolsPath, before + navigatorSection + after, "utf8");
2022
+ } else {
2023
+ // Append Navigator section
2024
+ writeFileSync(toolsPath, existing + "\n\n" + navigatorSection + "\n", "utf8");
2025
+ }
2026
+ ok("Updated TOOLS.md with Navigator integration docs");
2027
+ info(` Path: ${toolsPath}`);
2028
+ }
2029
+ } catch (err) {
2030
+ // Non-fatal — TOOLS.md update is best-effort
2031
+ warn(`TOOLS.md update failed: ${err.message}`);
2032
+ }
2033
+
1914
2034
  // ── Install launchd auto-start (macOS only) ──────────────────────────
1915
2035
  // Creates ~/Library/LaunchAgents/com.openclaw.navigator-bridge.plist
1916
2036
  // so the bridge + MCP server starts automatically on login.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-navigator",
3
- "version": "5.3.2",
3
+ "version": "5.3.4",
4
4
  "description": "One-command bridge + tunnel for the Navigator browser — works on any machine, any OS",
5
5
  "keywords": [
6
6
  "browser",