* feat(mail): add Microsoft 365 Graph sync source with delta state Adds a GET-only Microsoft Graph source to bin/mail/sync (client-credentials, delta query). Wires it into the CLI (--source m365), the worker pool and the compose stack: - m365.go: M365Client (token cache, delta pagination, message normalization, attachment download) + m365Source adapter (per-mailbox folders + delta link) - sync.go: M365Credentials in SyncConfig; Committer interface so delta links only advance after a fully successful run (no skips on failure) - cli.go: --source m365 with M365_/MS_ env passthrough - Dockerfile: mail-build stage produces /mail-sync into the index image - docker-entrypoint: mail-sync loop (sync -> import -> index, default 10s) - compose.yaml: mail-sync service (index image, kb-var volume, secrets ro) * feat(mail): adapt M365 ETL loop for OO+Gmail bots. Default compose mail-sync to onlyoffice,gmail every 300s with import on new mail; gate full --rebuild behind MAIL_SYNC_INDEX. Fix mail-build stage order and add bin/stack/start-mail-sync.
103 lines
3.4 KiB
Markdown
103 lines
3.4 KiB
Markdown
---
|
|
type: howto
|
|
status: current
|
|
related:
|
|
- docs/README.md
|
|
- PLAN.md
|
|
---
|
|
|
|
# Run 2dph (portable)
|
|
|
|
No laptop-absolute paths. Config lives in env files under `$HOME/.config/brain/`
|
|
(mode 0600), not in git.
|
|
|
|
## Toolchain
|
|
|
|
- Go (see `go.mod`)
|
|
- Python 3.12 + [uv](https://docs.astral.sh/uv)
|
|
- Optional: Docker, Zig CGO via `bin/cgo/zig` (not gcc)
|
|
- Optional: poppler (`pdftotext`/`pdftoppm`) + tesseract `eng+deu` for mail OCR
|
|
|
|
```bash
|
|
uv venv .venv
|
|
uv pip install -r requirements.lock.txt
|
|
eval "$(bin/cgo/zig env)" # when compiling Ladybug read tools
|
|
go test ./...
|
|
uv run python -m unittest discover -s bin/tools -t .
|
|
```
|
|
|
|
## Config
|
|
|
|
| File / env | Purpose |
|
|
|------------|---------|
|
|
| `$BRAIN_SEARCH_ENV` (default `$HOME/.config/brain/search.env`) | `BRAIN_SEARCH_URL` (SearXNG). Optional Basic Auth. |
|
|
| `$HOME/.config/brain/db-profiles.yml` | read-only Postgres profiles (OnlyOffice via tunnel) |
|
|
|
|
If the host already runs SearXNG, point `BRAIN_SEARCH_URL` at it. Do not start
|
|
a second copy (D3). Optional Compose instance:
|
|
|
|
```bash
|
|
SEARXNG_SECRET=$(openssl rand -hex 32) docker compose --profile searxng up -d
|
|
```
|
|
|
|
That binds `127.0.0.1:8888`. JSON format must stay enabled.
|
|
|
|
## Index then search
|
|
|
|
Write path is `bin/brain/add.go` for a leaf (or `POST /ingest`). Bulk
|
|
corpus rebuild remains `bin/brain/index.go --rebuild` (Compose profile
|
|
`index`). Do not DROP INDEX on Ladybug 0.19.
|
|
|
|
```bash
|
|
bin/brain/add.go --text "arc-1 runs Matrix" --root facts --source "compose.yml x docker ps"
|
|
bin/brain/index.go --rebuild --with-facts --with-chats
|
|
bin/brain/search.go "LadybugDB vector index" # facts → info → web (D17)
|
|
bin/brain/search.go "upstream flag" --no-web
|
|
bin/brain/search.go "who works where" --as-of 2025-01-01 # D24 intervals
|
|
source <(./bin/cli/complete.go bash) # D23 flaggy complete
|
|
bin/brain/get.go <id> --body
|
|
bin/brain/stats.go
|
|
```
|
|
|
|
`--hop N` walks File → Commit → Person from each hit. `--as-of YYYY-MM-DD`
|
|
keeps leafs whose `valid_from`/`valid_to` cover that day (empty interval =
|
|
legacy always-on). Empty web results are `throttled`, not absence.
|
|
Gap to v1: [roadmap](roadmap.md) / [epic #16](https://git.produktor.io/eSlider/2dph/issues/16).
|
|
|
|
Ladybug 0.19: never `DROP INDEX` FTS/VECTOR (ghost catalog). Fresh indexes =
|
|
delete `var/kb.lbug` then `--rebuild`.
|
|
|
|
## HTTP / MCP
|
|
|
|
```bash
|
|
bin/stack/start # brain :8630, wait until MCP search/get/audit
|
|
bin/stack/status # YAML: brain / reasoner / picoclaw / mail_sync
|
|
bin/stack/start-mail-sync # compose ETL: OO+Gmail sync→import (300s; no auto-rebuild)
|
|
bin/stack/start-assistant # + qwen3.5:9b + PicoClaw agent (ask the brain)
|
|
bin/stack/start-assistant --no-attach
|
|
bin/stack/stop # compose stop; volumes kept
|
|
```
|
|
|
|
Same Compose services by hand:
|
|
|
|
```bash
|
|
docker compose up -d brain # :8630 Zig CGO serve
|
|
docker compose up -d mail-sync # ETL loop into kb-var
|
|
docker compose --profile index run --rm index # rebuild
|
|
docker compose --profile picoclaw up brain-mcp # MCP 127.0.0.1:8630
|
|
```
|
|
|
|
`GET /openapi.json`, `POST /mcp`. Agent tool order: `search` → `get` → `audit`.
|
|
See [picoclaw.md](picoclaw.md).
|
|
|
|
## Reasoner (optional, D18)
|
|
|
|
CPU sidecar on `127.0.0.1:11435`. Weights are not in the 2dph image.
|
|
|
|
```bash
|
|
docker compose --profile reasoner up -d reasoner
|
|
REASONER_BASE_URL=http://127.0.0.1:11435/v1 ./bin/reasoner/bakeoff.go --json
|
|
```
|
|
|
|
See [reasoner.md](reasoner.md).
|