simplify: auto-everything in install command
Changes: 1. browser-cookie3 now in default deps (no separate pip install) 2. install --env=auto now auto-imports cookies on local computers 3. install auto-detects EXA_API_KEY from environment variables 4. install.md cut from 100 lines to 60 lines — two steps not five Before: pip install → agent-eyes install → 'want search?' → 'want cookies?' → configure each After: pip install → agent-eyes install (does everything automatically) → only ask about what's missing Docker clean-room test: all passing, 0 bugs.
This commit is contained in:
+37
-6
@@ -128,6 +128,7 @@ def main():
|
|||||||
|
|
||||||
def _cmd_install(args):
|
def _cmd_install(args):
|
||||||
"""One-shot deterministic installer."""
|
"""One-shot deterministic installer."""
|
||||||
|
import os
|
||||||
from agent_eyes.config import Config
|
from agent_eyes.config import Config
|
||||||
from agent_eyes.doctor import check_all, format_report
|
from agent_eyes.doctor import check_all, format_report
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ def _cmd_install(args):
|
|||||||
else:
|
else:
|
||||||
print(f"💻 Environment: Local computer (auto-detected)")
|
print(f"💻 Environment: Local computer (auto-detected)")
|
||||||
|
|
||||||
# Apply flags
|
# Apply explicit flags
|
||||||
if args.exa_key:
|
if args.exa_key:
|
||||||
config.set("exa_api_key", args.exa_key)
|
config.set("exa_api_key", args.exa_key)
|
||||||
print(f"✅ Exa search key configured")
|
print(f"✅ Exa search key configured")
|
||||||
@@ -156,8 +157,39 @@ def _cmd_install(args):
|
|||||||
config.set("bilibili_proxy", args.proxy)
|
config.set("bilibili_proxy", args.proxy)
|
||||||
print(f"✅ Proxy configured for Reddit + Bilibili")
|
print(f"✅ Proxy configured for Reddit + Bilibili")
|
||||||
|
|
||||||
|
# Auto-detect Exa key from environment
|
||||||
|
if not config.get("exa_api_key") and not args.exa_key:
|
||||||
|
env_key = os.environ.get("EXA_API_KEY") or os.environ.get("exa_api_key")
|
||||||
|
if env_key:
|
||||||
|
config.set("exa_api_key", env_key)
|
||||||
|
print(f"✅ Exa key auto-detected from environment")
|
||||||
|
|
||||||
|
# Auto-import cookies on local computers
|
||||||
|
if env == "local":
|
||||||
|
print()
|
||||||
|
print("🍪 Trying to import cookies from browser...")
|
||||||
|
try:
|
||||||
|
from agent_eyes.cookie_extract import configure_from_browser
|
||||||
|
results = configure_from_browser("chrome", config)
|
||||||
|
found = False
|
||||||
|
for platform, success, message in results:
|
||||||
|
if success:
|
||||||
|
print(f" ✅ {platform}: {message}")
|
||||||
|
found = True
|
||||||
|
if not found:
|
||||||
|
# Try firefox
|
||||||
|
results = configure_from_browser("firefox", config)
|
||||||
|
for platform, success, message in results:
|
||||||
|
if success:
|
||||||
|
print(f" ✅ {platform}: {message}")
|
||||||
|
found = True
|
||||||
|
if not found:
|
||||||
|
print(" ⬜ No cookies found (normal if you haven't logged into these sites)")
|
||||||
|
except Exception:
|
||||||
|
print(" ⬜ Could not read browser cookies (browser might be open)")
|
||||||
|
|
||||||
# Environment-specific advice
|
# Environment-specific advice
|
||||||
if env == "server" and not args.proxy:
|
if env == "server":
|
||||||
print()
|
print()
|
||||||
print("💡 Tip: Reddit and Bilibili block server IPs.")
|
print("💡 Tip: Reddit and Bilibili block server IPs.")
|
||||||
print(" Reddit search still works via Exa (free).")
|
print(" Reddit search still works via Exa (free).")
|
||||||
@@ -170,10 +202,9 @@ def _cmd_install(args):
|
|||||||
results = check_all(config)
|
results = check_all(config)
|
||||||
ok = sum(1 for r in results.values() if r["status"] == "ok")
|
ok = sum(1 for r in results.values() if r["status"] == "ok")
|
||||||
total = len(results)
|
total = len(results)
|
||||||
print(f"✅ {ok}/{total} channels active")
|
|
||||||
|
|
||||||
# What's missing
|
# What's missing — only mention Exa if not configured
|
||||||
if args.search == "yes" and not args.exa_key and not config.get("exa_api_key"):
|
if not config.get("exa_api_key"):
|
||||||
print()
|
print()
|
||||||
print("🔍 Recommended: unlock search with a free Exa API key")
|
print("🔍 Recommended: unlock search with a free Exa API key")
|
||||||
print(" agent-eyes configure exa-key YOUR_KEY")
|
print(" agent-eyes configure exa-key YOUR_KEY")
|
||||||
@@ -183,7 +214,7 @@ def _cmd_install(args):
|
|||||||
print()
|
print()
|
||||||
print(format_report(results))
|
print(format_report(results))
|
||||||
print()
|
print()
|
||||||
print("✅ Installation complete!")
|
print(f"✅ Installation complete! {ok}/{total} channels active.")
|
||||||
|
|
||||||
|
|
||||||
def _detect_environment():
|
def _detect_environment():
|
||||||
|
|||||||
+31
-68
@@ -5,100 +5,64 @@
|
|||||||
Copy this to your AI Agent:
|
Copy this to your AI Agent:
|
||||||
|
|
||||||
```
|
```
|
||||||
Install Agent Eyes: https://raw.githubusercontent.com/Panniantong/agent-eyes/main/docs/install.md
|
帮我安装 Agent Eyes:https://raw.githubusercontent.com/Panniantong/agent-eyes/main/docs/install.md
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## For AI Agents
|
## For AI Agents
|
||||||
|
|
||||||
Install Agent Eyes with minimal user effort. Goal: fewest questions, fewest steps.
|
### Step 1: Install
|
||||||
|
|
||||||
### Step 1: Install and detect
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install https://github.com/Panniantong/agent-eyes/archive/main.zip || pip3 install https://github.com/Panniantong/agent-eyes/archive/main.zip
|
pip install https://github.com/Panniantong/agent-eyes/archive/main.zip || pip3 install https://github.com/Panniantong/agent-eyes/archive/main.zip
|
||||||
agent-eyes install --env=auto
|
agent-eyes install --env=auto
|
||||||
```
|
```
|
||||||
|
|
||||||
Read the output. It tells you the detected environment (local/server) and what's already working.
|
This single command does everything automatically:
|
||||||
|
- Detects local computer vs server
|
||||||
|
- Auto-imports browser cookies on local (Twitter, XiaoHongShu, Bilibili)
|
||||||
|
- Auto-detects Exa API key if already in environment
|
||||||
|
- Tests all channels
|
||||||
|
- Shows what's working and what needs setup
|
||||||
|
|
||||||
### Step 2: Set up search (highest value, free)
|
**Read the output carefully.** It tells you exactly what happened and what's next.
|
||||||
|
|
||||||
> "Want to unlock web search? One free API key lets me search the web, Reddit, and Twitter.
|
### Step 2: Only if needed — configure what's missing
|
||||||
> Go to https://exa.ai → sign up (free, 1000 searches/month) → send me the key.
|
|
||||||
> Or say 'skip' — I can still read any URL you give me."
|
Based on the install output, you may need to configure one or two things.
|
||||||
|
Only ask the user for items the install output says are missing.
|
||||||
|
|
||||||
|
**If search is not configured:**
|
||||||
|
> "Want to unlock web search? Go to https://exa.ai → sign up (free) → send me the API key."
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
agent-eyes configure exa-key THE_KEY
|
agent-eyes configure exa-key THE_KEY
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 3: Set up cookies (the approach depends on environment)
|
**If cookies were not auto-imported (server users):**
|
||||||
|
> "To unlock Twitter and XiaoHongShu, install the Cookie-Editor Chrome extension, go to the site, click Export → Header String, and paste it to me."
|
||||||
|
> Extension: https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm
|
||||||
|
|
||||||
#### Path A: Local computer (auto-detected)
|
|
||||||
|
|
||||||
Offer one-click import:
|
|
||||||
|
|
||||||
> "I can grab your browser cookies automatically to unlock Twitter, XiaoHongShu, and Bilibili — all at once. Just close Chrome first, then say 'go'."
|
|
||||||
|
|
||||||
If user agrees:
|
|
||||||
```bash
|
```bash
|
||||||
pip install browser-cookie3 2>/dev/null; agent-eyes configure --from-browser chrome
|
agent-eyes configure twitter-cookies "PASTED_STRING"
|
||||||
|
agent-eyes configure xhs-cookie "PASTED_STRING"
|
||||||
```
|
```
|
||||||
|
|
||||||
If user uses another browser: replace `chrome` with `firefox`, `edge`, `brave`, or `opera`.
|
**If on server and wants Reddit/Bilibili full access:**
|
||||||
|
> "Reddit and Bilibili block server IPs. Get a proxy at https://webshare.io ($1/month) and send me the address."
|
||||||
If it fails or user declines, fall through to Path B.
|
|
||||||
|
|
||||||
#### Path B: Server, or auto-import didn't work
|
|
||||||
|
|
||||||
Tell the user the easiest manual method:
|
|
||||||
|
|
||||||
> "I need cookies from your browser to unlock some platforms. Here's the fastest way (30 seconds per site):
|
|
||||||
>
|
|
||||||
> 1. Install the **Cookie-Editor** Chrome extension: https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm
|
|
||||||
> 2. Go to the site (e.g. x.com) — make sure you're logged in
|
|
||||||
> 3. Click the Cookie-Editor icon → **Export** → **Header String**
|
|
||||||
> 4. Paste the result to me
|
|
||||||
>
|
|
||||||
> Which platforms do you use? I'll tell you which ones to export."
|
|
||||||
|
|
||||||
For each platform the user wants:
|
|
||||||
|
|
||||||
**Twitter/X** — export from https://x.com :
|
|
||||||
```bash
|
|
||||||
agent-eyes configure twitter-cookies "PASTED_COOKIE_STRING"
|
|
||||||
```
|
|
||||||
(Accepts both: full cookie string OR just `auth_token ct0` as two values)
|
|
||||||
|
|
||||||
**XiaoHongShu** — export from https://www.xiaohongshu.com :
|
|
||||||
```bash
|
|
||||||
agent-eyes configure xhs-cookie "PASTED_COOKIE_STRING"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Bilibili** — export from https://www.bilibili.com :
|
|
||||||
(On local computers Bilibili already works without cookies. On servers it needs a proxy — see Step 4.)
|
|
||||||
|
|
||||||
### Step 4: Server-only — proxy for Reddit/Bilibili
|
|
||||||
|
|
||||||
Only mention if environment was detected as server:
|
|
||||||
|
|
||||||
> "On servers, Reddit and Bilibili block direct access. Reddit *search* still works via Exa (free), but for reading full Reddit posts or using Bilibili, you'd need a residential proxy (~$1/month).
|
|
||||||
> Get one at https://webshare.io if you want. Or skip — not required."
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
agent-eyes configure proxy http://user:pass@ip:port
|
agent-eyes configure proxy http://user:pass@ip:port
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 5: Done
|
### Step 3: Verify
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
agent-eyes doctor
|
agent-eyes doctor
|
||||||
```
|
```
|
||||||
|
|
||||||
> "✅ All set! [list active channels]. Try: 'search Reddit for ...' or 'read this URL'"
|
Report what's active. Users can configure more anytime by asking.
|
||||||
|
|
||||||
Users can configure more channels anytime — just say "set up Twitter" or "add proxy".
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -106,12 +70,11 @@ Users can configure more channels anytime — just say "set up Twitter" or "add
|
|||||||
|
|
||||||
| Command | What it does |
|
| Command | What it does |
|
||||||
|---------|-------------|
|
|---------|-------------|
|
||||||
| `agent-eyes configure --from-browser chrome` | Auto-import ALL cookies at once (local only) |
|
| `agent-eyes install --env=auto` | Full auto-setup |
|
||||||
| `agent-eyes configure exa-key KEY` | Unlock search (web + Reddit + Twitter) |
|
| `agent-eyes doctor` | Show status |
|
||||||
| `agent-eyes configure twitter-cookies "COOKIE_STRING"` | Unlock Twitter (cookie string or auth_token + ct0) |
|
| `agent-eyes configure exa-key KEY` | Unlock search |
|
||||||
| `agent-eyes configure xhs-cookie "COOKIE_STRING"` | Unlock XiaoHongShu |
|
| `agent-eyes configure twitter-cookies "..."` | Unlock Twitter |
|
||||||
| `agent-eyes configure youtube-cookies chrome` | Unlock age-restricted YouTube |
|
| `agent-eyes configure xhs-cookie "..."` | Unlock XiaoHongShu |
|
||||||
| `agent-eyes configure proxy URL` | Unlock Reddit reader + Bilibili (server) |
|
| `agent-eyes configure proxy URL` | Unlock Reddit + Bilibili (server) |
|
||||||
| `agent-eyes doctor` | Show all channels and their status |
|
|
||||||
| `agent-eyes read URL` | Read any URL |
|
| `agent-eyes read URL` | Read any URL |
|
||||||
| `agent-eyes search "query"` | Search the web |
|
| `agent-eyes search "query"` | Search the web |
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ dependencies = [
|
|||||||
"pyyaml>=6.0",
|
"pyyaml>=6.0",
|
||||||
"rich>=13.0",
|
"rich>=13.0",
|
||||||
"yt-dlp>=2024.0",
|
"yt-dlp>=2024.0",
|
||||||
|
"browser-cookie3>=0.19",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user