Skip to content

Give your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.

Merge release/1.6 updates while retaining shared-browser lifecycle

LohseZSaibb3eeba9833e
diff --cc agent_reach/runtime/browser.py
index 6bd900d6,e6a9aae0..83029402
--- a/agent_reach/runtime/browser.py
+++ b/agent_reach/runtime/browser.py
@@@ -328,11 -355,11 +328,11 @@@ def ensure_chrome(*, retry_cloak: bool
def can_load_extension() -> bool:
- """macOS/Linux: the watcher loads the extension over the launch pipe. Windows: Web Store only."""
- return sys.platform != "win32"
+ """Cloak loads extensions everywhere; system Chrome uses pipe loading on POSIX."""
- return _load_state().get("backend") == "cloakbrowser" or os.name != "nt"
++ return _load_state().get("backend") == "cloakbrowser" or sys.platform != "win32"
-def chrome_argv(exe: str, url: str, *, pipe: bool) -> List[str]:
+def chrome_argv(exe: str, url: str, *, pipe: bool, headless: bool = True) -> List[str]:
argv = [
exe,
"--remote-debugging-address=127.0.0.1",
diff --cc agent_reach/runtime/browser_watcher.py
index 17129302,41ef6c7a..a40398f2
--- a/agent_reach/runtime/browser_watcher.py
+++ b/agent_reach/runtime/browser_watcher.py
@@@ -18,13 -21,14 +18,15 @@@ import subproces
import sys
import time
from typing import Optional
+from urllib.parse import unquote, urlsplit
-from . import browser
+from . import bridge, browser
-def _launch_with_pipe(chrome: str, url: str):
+def _launch_with_pipe(chrome: str, url: str, *, headless: bool = True):
"""Start Chrome with the CDP pipe on its fds 3 (commands in) and 4 (replies out)."""
+ if sys.platform == "win32": # pragma: no cover
+ raise NotImplementedError("pipe launch is not supported on Windows")
import fcntl
from .cdp import PipeConnection
diff --cc agent_reach/runtime/result.py
index 977b7fa9,02f66fbd..bd763dc6
--- a/agent_reach/runtime/result.py
+++ b/agent_reach/runtime/result.py
@@@ -30,16 -29,16 +30,16 @@@ NOT_FOUND = "NOT_FOUND
BAD_INPUT = "BAD_INPUT"
#: Codes where trying another backend cannot help.
-FINAL_CODES = frozenset({NOT_FOUND, BAD_INPUT})
+FINAL_CODES = frozenset({NOT_FOUND, BAD_INPUT, PLATFORM_BLOCKED, RATE_LIMITED, NEED_LOGIN, "BUSY"})
DEFAULT_HINTS = {
+ "BUSY": "Another command uses this browser profile. Wait for it to finish; do not switch profiles.",
+ PLATFORM_BLOCKED: "Stop automation. Keep this profile; the user must resolve the platform verification in the official page. Do not switch backends or retry.",
NEED_SETUP: "This backend is not installed. Ask the user to run `agent-reach doctor` for setup steps.",
- NEED_LOGIN: "Login is required or expired. Guide the user to log in themselves; never log in on their behalf.",
- UPSTREAM_BROKEN: ("The upstream tool failed. Suggest the user run `agent-reach update` once (the upstream may "
- "already be fixed); if it still fails, tell them this channel is unavailable right now. "
- "Do not retry in a loop."),
- TIMEOUT: "No backend answered in time. Retry later, or pass a larger --timeout.",
- RATE_LIMITED: "Rate limited by the platform. Wait a while before retrying.",
+ NEED_LOGIN: "The attempted saved/local session did not grant access. Offer site-scoped local reuse or let the user log in themselves; never ask for a password.",
- UPSTREAM_BROKEN: "The upstream tool failed. Tell the user this channel is unavailable right now; do not retry in a loop.",
++ UPSTREAM_BROKEN: "The upstream tool failed. Offer one update from the same installation source after user approval; never update automatically or retry in a loop.",
+ TIMEOUT: "The operation timed out. Inspect channel status and the failed stage; do not reopen login windows or repeat requests in a loop.",
+ RATE_LIMITED: "The platform reported a rate limit. Reach pauses this channel; respect retry_after_seconds and do not switch backends.",
NOT_FOUND: "The requested content does not exist. Check the link or id.",
BAD_INPUT: "Invalid arguments. Run `agent-reach channels` to see valid usage.",
}
diff --cc agent_reach/runtime/run.py
index a7cf2e02,83d8239f..8639ce98
--- a/agent_reach/runtime/run.py
+++ b/agent_reach/runtime/run.py
@@@ -57,26 -53,15 +58,26 @@@ def run_cmd
[exe, *argv[1:]],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
- stdin=subprocess.DEVNULL,
+ stdin=subprocess.PIPE if input_data is not None else subprocess.DEVNULL,
env=run_env,
cwd=cwd or os.path.expanduser("~"),
- start_new_session=(os.name != "nt" and not supervised),
- start_new_session=(sys.platform != "win32"),
++ start_new_session=(sys.platform != "win32" and not supervised),
)
try:
- out, err = proc.communicate(timeout=max(timeout, 0.1))
+ kwargs = {"input": input_data.encode("utf-8")} if input_data is not None else {}
+ out, err = proc.communicate(timeout=max(timeout, 0.1), **kwargs)
except subprocess.TimeoutExpired:
- if os.name == "nt":
- if sys.platform != "win32":
++ if sys.platform == "win32":
+ # Kill this command's descendants too (Playwright driver + Chrome).
+ # Killing only Python leaves the profile locked by orphan browsers.
+ taskkill = str(Path(os.environ.get("SystemRoot", r"C:\Windows")) / "System32/taskkill.exe")
+ try:
+ subprocess.run([taskkill, "/PID", str(proc.pid), "/T", "/F"],
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
+ timeout=5, check=False)
+ except (OSError, subprocess.TimeoutExpired):
+ proc.kill()
+ elif not supervised:
try:
os.killpg(proc.pid, signal.SIGKILL)
except ProcessLookupError:
diff --cc agent_reach/skill/SKILL.md
index 82b1d0c9,a742589f..081ed3ec
--- a/agent_reach/skill/SKILL.md
+++ b/agent_reach/skill/SKILL.md
@@@ -56,9 -30,10 +56,9 @@@ agent-reach read <链接
| error.code | 怎么办 |
|---|---|
- | `UPSTREAM_BROKEN` | 这个渠道暂时不可用,告诉用户,不要反复重试 |
-| `NEED_SETUP` | 告诉用户 hint 里的命令(常见:`agent-reach add <渠道>`) |
-| `NEED_LOGIN` | 让用户自己登录(`agent-reach login <渠道>`),**绝不替用户登录、不读用户浏览器的 Cookie** |
-| `UPSTREAM_BROKEN` | 这个渠道暂时不可用。先建议用户运行一次 `agent-reach update`(上游可能已经修好);还不行就告诉用户,不要反复重试 |
-| `TIMEOUT` / `RATE_LIMITED` | 稍后再试 |
++| `UPSTREAM_BROKEN` | 告诉用户当前故障,可询问是否从原安装来源更新一次;不自动更新、不反复重试 |
+| `TIMEOUT` | 看失败阶段与渠道状态,不反复开窗或立即重试 |
+| `RATE_LIMITED` | 按 `retry_after_seconds` 等待,程序暂停该渠道 |
| `NOT_FOUND` / `BAD_INPUT` | 检查链接或参数,必要时跑 `agent-reach channels` |
## 规则
diff --cc agent_reach/skill/SKILL_en.md
index e084078f,fbf9eb92..fed81fc3
--- a/agent_reach/skill/SKILL_en.md
+++ b/agent_reach/skill/SKILL_en.md
@@@ -57,10 -31,10 +57,10 @@@ Results
| error.code | What to do |
|---|---|
-| `NEED_SETUP` | Tell the user the command in the hint (usually `agent-reach add <channel>`) |
-| `NEED_LOGIN` | The user logs in themselves (`agent-reach login <channel>`). **Never log in for them or read their browser cookies** |
-| `UPSTREAM_BROKEN` | Channel is down right now. Suggest the user run `agent-reach update` once (upstream may already be fixed); if it still fails, tell them, and don't retry in a loop |
-| `TIMEOUT` / `RATE_LIMITED` | Retry later |
+| `NEED_LOGIN` | Keep public results. If the remaining task needs this path, the user logs in; resume using `operation_id` |
- | `UPSTREAM_BROKEN` | Channel is down right now; tell the user, don't retry in a loop |
++| `UPSTREAM_BROKEN` | Report the failure; offer one update from the same source after user approval. Never update automatically or retry in a loop |
+| `TIMEOUT` | Inspect the failed stage and channel status; do not reopen or retry in a loop |
+| `RATE_LIMITED` | Respect `retry_after_seconds`; the runtime pauses this channel |
| `NOT_FOUND` / `BAD_INPUT` | Check the link or args; run `agent-reach channels` if needed |
## Rules