# Windows Stack Extras — going live

Builds on the [Local AI Stack on Windows](https://krueng.ai/it/ai/ai_windows_stack.html).
Same Ollama + Hermes 3 + LlamaIndex foundation; four new abilities so the
agent can reach the world:

1. **Web search** — `duckduckgo-search`, wrapped as a Hermes tool.
2. **Image generation** — `diffusers` + Stable Diffusion XL Turbo, running
   on NVIDIA CUDA (or CPU fallback). Offline after the first download.
3. **LINE responses** — Flask webhook that ferries messages from a LINE
   Official Account through the Hermes agent and back.
4. **Event-driven tasks** — Windows Task Scheduler runs a Python script
   on a schedule. Sample: post a daily English word at 7am.

## Files

| File | What it is |
| --- | --- |
| `requirements.txt` | Extra Python packages (search + diffusers + flask) |
| `agent_pro.py` | The original `agent.py` with three new tools wired in |
| `agent_pro_webbridge.py` | Alternative agent — web tool via Kimi WebBridge over MCP instead of `duckduckgo-search` |
| `image_gen.py` | Local SDXL Turbo wrapper — usable standalone or via the agent |
| `line_bot.py` | Flask webhook that lets a LINE user chat with the agent |
| `daily_word.py` | Sample scheduled task — agent picks a word, posts to LINE |
| `run_daily.cmd` | Batch wrapper that Task Scheduler invokes (sets env vars) |
| `KruAI_Daily.xml` | Task Scheduler XML — importable via Task Scheduler GUI |

The four `.py` files are byte-identical to the Mac Stack Extras versions.
Python doesn't care about platform; only the scheduling tooling differs.

## Quick start

```powershell
# Drop the extras alongside the Windows Stack files
cd ~/Downloads/windows_stack
.\.venv\Scripts\Activate.ps1

# If you have an NVIDIA GPU, install the CUDA build of torch first:
pip install torch --index-url https://download.pytorch.org/whl/cu121

# Then the rest:
pip install -r path\to\windows_stack_extras\requirements.txt
Copy-Item path\to\windows_stack_extras\*.py .
Copy-Item path\to\windows_stack_extras\run_daily.cmd .

# 1. Chat with the upgraded agent
python agent_pro.py

# 2. (Optional) Run the LINE bot
$env:LINE_CHANNEL_ACCESS_TOKEN = "..."
$env:LINE_CHANNEL_SECRET = "..."
python line_bot.py                 # then `ngrok http 8000` in another shell

# 3. (Optional) Schedule the daily word job
# Edit run_daily.cmd first to put your LINE token + target ID in.
schtasks /create /tn "KruAI Daily" /tr "C:\Users\%USERNAME%\Downloads\windows_stack\run_daily.cmd" /sc daily /st 07:00
schtasks /run /tn "KruAI Daily"    # run once now to test
```

## Alternative: Kimi WebBridge instead of DuckDuckGo

`agent_pro.py` uses `duckduckgo-search` — a tiny pip package that scrapes
search snippets. Zero setup beyond `pip install`, but only snippets — no
logins, no clicking through, no JS-rendered pages.

`agent_pro_webbridge.py` connects the agent to **Kimi WebBridge**,
Moonshot's local browser-automation service. It drives your real
Chrome/Edge browser through Chrome DevTools Protocol, so the agent can
log in, scroll, click, fill forms. Page content never touches Moonshot's
servers.

### Install (one-time)

1. Download the **Kimi Desktop App**: <https://www.kimi.com/features/webbridge>
2. Install the **Kimi WebBridge** Chrome / Edge extension from the Chrome Web Store
   (search "Kimi WebBridge").
3. Open Kimi Desktop → Settings → WebBridge — pair the desktop app with the extension.
   Both should show as connected.
4. Copy the MCP endpoint URL the WebBridge settings show (looks like
   `http://127.0.0.1:PORT/sse`), then in PowerShell:

```powershell
pip install llama-index-tools-mcp                              # already in requirements.txt
$env:WEBBRIDGE_MCP_URL = "http://127.0.0.1:PORT/sse"           # use the URL from step 4
python agent_pro_webbridge.py
```

Run **both** scripts side by side to compare; pick whichever fits the task.

Full walkthroughs with diagrams: <https://krueng.ai/it/ai/ai_windows_stack_extras.html>.
