Metadata-Version: 2.5
Name: aicortex-bridge
Version: 0.1.5
Summary: Windows Outlook COM + Chrome CDP HTTP bridge for AICortex pods
Author: AICortex
License: MIT
Requires-Python: >=3.11
Requires-Dist: fastapi>=0.115.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pywin32>=306; sys_platform == 'win32'
Requires-Dist: pyyaml>=6.0
Requires-Dist: uvicorn[standard]>=0.32.0
Requires-Dist: websockets>=12.0
Provides-Extra: windows
Requires-Dist: pywin32>=306; extra == 'windows'
Description-Content-Type: text/markdown

# aicortex-bridge

Windows host HTTP service for Outlook COM and Chrome DevTools (CDP). Lives in the **aicorkit** repo alongside the `aicorkit` package.

## Install (Windows)

```powershell
pip install aicorkit aicortex-bridge
aicortex-bridge serve
aicortex-bridge status
# aicortex-bridge stop
# aicortex-bridge serve --foreground
```

From source (repo root):

```powershell
pip install .
pip install ./bridge
aicortex-bridge serve
```

Requires Outlook desktop signed in for mail/calendar. `serve` also starts a dedicated Chrome on `127.0.0.1:9333` and proxies CDP on the same port as the bridge. Default listen: `0.0.0.0:8766`.

## Release (publish both packages)

```powershell
cd D:\CODE\aicorkit
python -m pip install build
python -m build
python -m build bridge
# twine upload dist/* bridge/dist/*
```

## Pod usage

Windows host（默认后台守护，日志 `~/.aicorkit/logs/bridge.log`）：

```powershell
aicortex-bridge serve
```

Pod env:

```bash
AICORTEX_BRIDGE_URL=http://host.docker.internal:8766
```

Pod Agent / Playwright 连宿主机 Chrome（不要直连 9333，走 bridge 反代）：

```bash
curl -s http://host.docker.internal:8766/json/version
# Playwright: connectOverCDP('http://host.docker.internal:8766')
```

CDP 控制：`GET /v1/cdp/status`、`POST /v1/cdp/start`、`POST /v1/cdp/stop`。  
`--no-cdp` 或 `AICORTEX_CDP_AUTOSTART=0` 可关闭自动拉起 Chrome。  
可选：`AICORTEX_CDP_PORT`、`AICORTEX_CDP_USER_DATA`、`AICORTEX_CDP_CHROME`。

**aicorkit** auto-routes `outlook *` and `graph ingest email --from outlook` when the URL is set (`aicorkit/outlook_bridge.py`).

## HTTP API

| aicorkit CLI | Bridge |
|--------------|--------|
| `outlook list-emails` | `GET /v1/outlook/list-emails` |
| `outlook read-email` | `GET /v1/outlook/read-email?q=...` |
| `outlook send-email` | `POST /v1/outlook/send-email` |
| `outlook list-calendar` | `GET /v1/outlook/list-calendar?d=14` |
| `outlook create-meeting` | `POST /v1/outlook/create-meeting` |
| `outlook free-busy -e ...` | `GET /v1/outlook/free-busy?email=...` |
| `outlook list-rooms` | `GET /v1/outlook/list-rooms` |
| graph ingest (full body) | `GET /v1/outlook/list-emails-full` |

Also: `GET /v1/outlook/new`, `POST /v1/outlook/download-attachments`, `GET /health`, `GET /v1/outlook/ping`.

CDP: `GET /json/version`, `GET /json/list`, WebSocket `/devtools/browser/...`（反代到本机 Chrome）。

## Config

Shared with aicorkit: `~/.aicorkit/config.yaml` (`email.whitelist`), `~/.aicorkit/state/outlook.json`.

Optional auth: `AICORTEX_BRIDGE_TOKEN` / `AICORKIT_OUTLOOK_BRIDGE_TOKEN`.

**Not via bridge:** `aicorkit meeting *`, `resolve_contact` (COM-only).
