Skill: godiao/web-llm-chat (version 1.0.2)

--- name: web-llm-chat description: Chat with web-based LLMs through the Chrome Relay extension. Supports Qwen (chat.qwen.ai) and Kimi (kimi.com) via scripts; more sites may be added. Use for web search, deep research, multi-turn chat, a second opinion, or delegating reasoning. Requires the relay extension attached to a matching chat tab. Triggers on phrases like "ask Qwen", "Kimi", "web LLM chat", "browser AI chat", "Qwen search", "deep research". --- # Web LLM Chat Skill Interact with web-based LLMs through the Chrome Relay extension. This skill enables automated conversations with AI models, supporting both simple queries and multi-turn research workflows. **Currently supported:** Qwen AI (`chat.qwen.ai`) and Kimi AI (`kimi.com`) via `scripts/qwen_chat.js` and `scripts/kimi_chat.js`. Additional web LLMs may be added over time. ## Why This Skill? ### The Problem - **Web search APIs are expensive**: Services like Brave Search API and Tavily require API keys and paid subscriptions, creating ongoing costs. - **Limited research capabilities**: Traditional search APIs return raw results, lacking the reasoning and synthesis capabilities of modern LLMs. - **Quality vs. cost tradeoff**: Getting high-quality, well-reasoned research often requires expensive API calls or manual effort. ### The Opportunity Modern web-based LLMs (like Qwen) offer: - **Powerful built-in search**: Native web search with real-time information retrieval - **RAG capabilities**: Automatic retrieval-augmented generation for grounded responses - **Deep research features**: Multi-source synthesis and citation - **Commercial-grade quality**: As products backed by major companies, they're continuously improved ### The Solution This skill leverages OpenClaw's Chrome Relay to: - **Access web LLMs for free**: Use the web interface without API costs - **Automate research workflows**: Let agents conduct multi-turn investigations - **Get higher quality results**: Benefit from commercial LLM capabilities at lower cost - **Enable comparison**: Cross-reference with other AI responses **Bottom line**: Use OpenClaw to orchestrate powerful web-based LLMs at a fraction of the API cost, with better research quality than raw search APIs. ## Features - **Send messages** to web-based LLMs and receive responses - **Multiple output formats**: plain text, Markdown (preserves code blocks, tables, lists), or raw HTML - **Send-ready detection**: waits until the page is ready for the next question - **Smart extraction**: uses anchor-based extraction to get only the latest response - **Research mode**: agent-orchestrated multi-turn conversations ## Supported Models | Model | Status | Script | Notes | |-------|--------|--------|-------| | Qwen AI (`chat.qwen.ai`) | Supported | `scripts/qwen_chat.js` | Text/Markdown/HTML output; `--debug-extract`; send-ready style completion | | Kimi AI (`kimi.com`) | Supported | `scripts/kimi_chat.js` | Lexical editor input; `diag` for DOM signals; completion uses stop/icon state + stability | | Other web LLMs | Not built-in | — | Extend with a new script + selectors; see existing scripts as templates | ## Prerequisites - Chrome Relay extension attached to a supported chat tab (e.g., `chat.qwen.ai/*` or `kimi.com/*`) - Gateway running on `127.0.0.1:18789` (default) - Node.js with `ws` package installed ## Installation Install the `ws` package using your preferred package manager: ```bash # npm npm install ws # yarn yarn add ws # pnpm pnpm add ws ``` ## Quick Start ### Check Connection Status ```bash # Qwen node scripts/qwen_chat.js status # Kimi node scripts/kimi_chat.js status ``` ### Send a Message ```bash # Qwen (supports --format text|markdown|html) node scripts/qwen_chat.js send "What is machine learning?" node scripts/qwen_chat.js send "Explain RAG in detail" --wait 120 node scripts/qwen_chat.js send "Write a Python function" --format markdown # Kimi node scripts/kimi_chat.js send "What is machine learning?" --wait 120 ``` ### Read Current Page Content ```bash node scripts/qwen_chat.js read node scripts/kimi_chat.js read ``` ## Command Reference ### `status` Check if Chrome Relay is connected and Web LLM tab is active. ```bash node scripts/qwen_chat.js status node scripts/kimi_chat.js status ``` Output (example; wording varies by script): ``` Extension: Connected Qwen tab: Active URL: https://chat.qwen.ai/c/... ``` ### `send` Send a message to the web LLM and receive the response. ```bash node scripts/qwen_chat.js send "your message" [options] node scripts/kimi_chat.js send "your message" [options] ``` **Options:** | Option | Description | Default | |--------|-------------|---------| | `--wait N` | Maximum wait time in seconds | 45 | | `--format text\|markdown\|html` | Output format (Qwen only) | text | | `--debug-extract` | Show extraction debugging info (Qwen only) | off | **Output Formats:** - `text` — Plain text output - `markdown` — Preserves code blocks, tables, lists, headers, and formatting (Qwen only) - `html` — Raw HTML from the page (Qwen only) ### `read` Read the current page content (useful for debugging or reviewing conversation history). ```bash node scripts/qwen_chat.js read node scripts/kimi_chat.js read ``` ### `diag` (Kimi) Print best-effort DOM diagnostics for Kimi's current UI (useful when completion detection or extraction breaks due to UI changes). ```bash node scripts/kimi_chat.js diag ``` ## How It Works ### Response Extraction The script uses a robust extraction strategy: 1. **Anchor-based extraction**: Uses the user's message as an anchor to find and extract only the latest response 2. **Completion detection (per-site)**: - Qwen: send-ready style signals + stabilization - Kimi: stop/send icon state inside `.send-button-container` + stabilization 3. **Content stabilization**: Waits for extracted content to remain stable to reduce early returns and truncation #### Kimi completion caveat Kimi may keep the send control disabled when the composer input is empty. Therefore, "send enabled" is **not** a reliable completion signal. The Kimi script treats "stop state cleared" + "response text stable for a short window" as completion. ### Why Not Use Thinking Indicators? - Thinking indicators can get stuck visually while the response is complete - Send-ready detection is more reliable: if you can send the next question, the previous response is done - Works regardless of UI changes to thinking indicators ### Why Not Use Delta by Body Length? - Qwen page may reflow and change `bodyLen` unpredictably - Anchor-based extraction is more robust to page reflows - Only extracts the actual response content, not noise ## Research Mode (Agent-Orchestrated) For multi-turn research, use an agent-orchestrated loop (send → read → analyze → follow-up). This allows the agent to dynamically control the conversation based on the model's responses. ### Workflow ``` 1. Determine research topic 2. Ask first question (open-ended, let Qwen expand) 3. Read Qwen's response 4. Analyze the response: - Which point deserves deeper exploration? - Which claim needs cross-validation? - Any contradictions or gaps? 5. Ask follow-up question based on analysis 6. Repeat steps 3-5 for 5-10 rounds 7. Final round: Ask Qwen to summarize, agent also compiles its own summary ``` ### Example Per-Round Operation ```bash # Agent sends question and waits for response node scripts/qwen_chat.js send "What are the key challenges in RLHF?" --wait 120 # Agent can read full page if needed node scripts/qwen_chat.js read ``` ### Follow-up Strategy Good follow-ups come from Qwen's response: | Response Pattern | Follow-up Direction | |-----------------|---------------------| | Mentions data/statistics | "What's the original source? Sample size?" | | Gives opinion without evidence | "Any research supporting this claim?" | | Mentions controversy | "What are the counter-arguments?" | | Uses "possibly/maybe" | "Under what conditions does this hold?" | | Lists multiple factors | "Which one is most critical? Why?" | | Mentions case study | "Has this case been challenged by other researchers?" | | Goes off-topic | "Back to the core question, specifically..." | ### Best Practices - **Don't pre-plan all questions**: Generate questions dynamically based on responses - **Allow tangents**: If Qwen mentions something unexpected but interesting, pursue it - **Challenge occasionally**: Don't always agree with Qwen; present counter-arguments - **Maintain continuity**: Briefly reference previous points when asking follow-ups - **Control rounds**: 5-10 rounds is optimal; too few lacks depth, too many has diminishing returns - **Handle timeouts honestly**: If the script times out, report it to the user rather than making up content - **Adjust wait time**: Use `--wait 180` for search-heavy questions, `--wait 60` for simple ones ## Debugging ### Enable Extraction Debugging ```bash node scripts/qwen_chat.js send "test message" --wait 90 --debug-extract ``` This shows: - Baseline and latest body length - Number of leaf elements detected - Extraction path used - Raw and final content lengths ### Common Issues | Issue | Solution | |-------|----------| | Extension disconnected | Check Chrome extension badge shows `ON` | | No Qwen tab found | Open `chat.qwen.ai` and attach extension | | No Kimi tab found | Open `kimi.com` and attach extension | | Relay returns `Unauthorized` or non-JSON body | Ensure `gateway.auth.token` in `openclaw.json` matches the Chrome extension; set config path via env (see Configuration). In PowerShell use `$env:OPENCLAW_CONFIG_PATH="..."` (not `set`). | | Response not captured | Increase `--wait` time, use `--debug-extract` (Qwen) or `kimi_chat.js diag` (Kimi) | | Markdown formatting broken | Code blocks use Monaco Editor; extraction handles this automatically | ## Configuration ### Auth Token Scripts derive the relay token from `gateway.auth.token` in OpenClaw’s `openclaw.json` (HMAC per `references/chrome-relay.md`). **Config file resolution order:** 1. **`OPENCLAW_CONFIG_PATH`** (or `OPENCLAW_CONFIG` / `OPENCLAW_JSON`) — absolute path to `openclaw.json` when it is not in the default location. 2. **`~/.openclaw/.openclaw/openclaw.json`** 3. **`~/.openclaw/openclaw.json`** On Windows, `~` is the user profile (e.g. `C:\Users\YourName`). Do not rely on a machine-specific drive letter in docs or scripts. **PowerShell (current session):** ```powershell $env:OPENCLAW_CONFIG_PATH="C:\path\to\openclaw.json" node scripts/kimi_chat.js status ``` **cmd.exe:** ```bat set OPENCLAW_CONFIG_PATH=C:\path\to\openclaw.json node scripts\kimi_chat.js status ``` ### Gateway Ports - Gateway: `18789` - Relay: `18792` (Gateway + 3) ## Limitations - Requires the target site to be logged in in the browser (Qwen and/or Kimi, depending on which script you use) - One tab at a time per script (each script picks a matching attached tab) - No streaming — waits for full response before returning - Kimi completion detection is heuristic and may break with UI changes; use `node scripts/kimi_chat.js diag` to inspect DOM signals ## Quick Start ```bash # Qwen node scripts/qwen_chat.js status node scripts/qwen_chat.js send "Your question" # Kimi node scripts/kimi_chat.js status node scripts/kimi_chat.js send "Your question" ``` ## File Structure ``` web-llm-chat/ ├── SKILL.md # This file ├── SKILL_CN.md # Chinese version ├── scripts/ │ ├── qwen_chat.js # Qwen Chat │ └── kimi_chat.js # Kimi AI └── references/ └── chrome-relay.md # Chrome Relay setup guide ``` ## See Also - [Chrome Relay Setup](references/chrome-relay.md) — detailed relay configuration ## License See [LICENSE](LICENSE) file for details.

path: package.json
content: {
	"dependencies": {
		"ws": "^8.20.0"
	}
}


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector:  ()