Initial commit: email-openclaw bridge v1
Full pipeline: IMAP ingress -> OpenClaw dispatch -> callback -> SMTP reply. SQLite stateful storage with idempotency, threading, and retry logic. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# Checkpoint 003 — OpenClaw Dispatch
|
||||
|
||||
**Ngày:** 2026-04-24
|
||||
**Trạng thái:** ✅ Hoàn thành
|
||||
**Verify:** `go build ./...` thành công
|
||||
|
||||
---
|
||||
|
||||
## Việc đã làm
|
||||
|
||||
### OpenClaw Dispatcher (`internal/ai_client/client.go`)
|
||||
|
||||
**Chức năng chính:**
|
||||
- Gửi HTTP POST đến OpenClaw API với payload theo spec:
|
||||
- `input` = body email
|
||||
- `session_id` = thread_id
|
||||
- `history` = các cặp user/assistant từ tasks COMPLETED cùng thread
|
||||
- `callback_url` = endpoint nhận kết quả
|
||||
- `metadata.task_uuid` = ID để callback tìm lại task
|
||||
|
||||
**Retry logic (đúng requirements 4.2):**
|
||||
- Tối đa 3 lần, backoff: 1s → 5s → 15s
|
||||
- Mỗi lần retry tăng `attempt_openclaw`
|
||||
- Hết retry: `status = FAILED`, ghi `last_error`
|
||||
|
||||
**HTTP Client:**
|
||||
- `Transport.Proxy = nil` — direct connection, không kế thừa proxy hệ thống
|
||||
- Timeout 30s
|
||||
- Bearer token auth (nếu `OPENCLAW_API_KEY` có giá trị)
|
||||
|
||||
### Wiring (`cmd/bridge/main.go`)
|
||||
- `watcher.OnReceived` → `go dispatcher.Dispatch(task)` (async)
|
||||
- Pipeline hoàn chỉnh: IMAP → RECEIVED → AI_PROCESSING → (chờ callback)
|
||||
|
||||
---
|
||||
|
||||
## Files thay đổi
|
||||
|
||||
- **Rewrite:** `internal/ai_client/client.go` (từ stub → full implementation)
|
||||
- **Cập nhật:** `cmd/bridge/main.go` (wire dispatcher)
|
||||
|
||||
## Tiếp theo
|
||||
|
||||
1. **Callback handler** — `POST /callback` + token auth + cập nhật `ai_response`
|
||||
2. **SMTP Egress** — gửi reply với In-Reply-To/References + retry
|
||||
Reference in New Issue
Block a user