docs: painel Hindsight publicado no Traefik com TLS + basicAuth (card t_a044ce45)
This commit is contained in:
1 parent
7ffea14891
commit
5c49302852
1 file changed
+133
@@ -0,0 +1,133 @@
|
||||
# Painel Hindsight (Control Plane) — publicado no Traefik com TLS + basicAuth
|
||||
|
||||
> Verificado em 2026-11-08 por `jack` (Integrador). Card Kanban `t_a044ce45`.
|
||||
|
||||
## O que é
|
||||
|
||||
O Hindsight é o **memory provider de longo prazo** do Hermes (memórias por perfil,
|
||||
operações retain/recall/reflect). O `Control Plane` (CP) é a UI web dele.
|
||||
|
||||
Antes desta integração o CP existia mas era **inalcançável**: os containers
|
||||
publicam as portas só no loopback e o Traefik não tinha rota para elas — o IP
|
||||
caía no 404 do Traefik.
|
||||
|
||||
## Endereço
|
||||
|
||||
```
|
||||
https://hindsight.srv2032242.hstgr.cloud/
|
||||
```
|
||||
|
||||
- DNS: wildcard `*.srv2032242.hstgr.cloud` → `2.25.234.119` (A e AAAA)
|
||||
- TLS: Let's Encrypt via `certResolver: letsencrypt`, válido até **06/Fev/2027**
|
||||
- HTTP :80 → 308 automático para HTTPS
|
||||
|
||||
## Login
|
||||
|
||||
Usuário `filipe`. Senha = a **mesma** dos painéis Fechamentos / OpenShorts
|
||||
(hash apr1 no Traefik; corresponde à `HERMES_MCP_PASSWORD` do cofre).
|
||||
O browser abre popup nativo porque o basicAuth devolve
|
||||
`WWW-Authenticate: Basic realm="traefik"`.
|
||||
|
||||
## Arquitetura da exposição
|
||||
|
||||
```
|
||||
Internet ──HTTPS──▶ Traefik (:443)
|
||||
│ basicAuth (filipe)
|
||||
▼
|
||||
127.0.0.1:9999 ── Control Plane (Next.js)
|
||||
│ proxy server-side
|
||||
▼
|
||||
127.0.0.1:8888 ── Data Plane API
|
||||
```
|
||||
|
||||
- Só o **Control Plane** é exposto.
|
||||
- A API 8888 **continua presa no loopback** — o CP fala com ela via
|
||||
`HINDSIGHT_CP_DATAPLANE_API_URL=http://localhost:8888` (dentro do container).
|
||||
- As portas 8888 e 9999 **não respondem** no IP público (HTTP 000).
|
||||
Confirmado com `ss -ltnp`: bind em `127.0.0.1` via docker-proxy.
|
||||
|
||||
## Por que basicAuth e não forwardAuth
|
||||
|
||||
O `forwardAuth` do MCP bridge (`127.0.0.1:8900/auth`) responde 401 **sem**
|
||||
`WWW-Authenticate` — de propósito, para o cla.ai não inferir fluxo OAuth.
|
||||
No browser isso dá tela quebrada, sem popup de login. O basicAuth nativo do
|
||||
Traefik devolve o header e o browser abre o popup.
|
||||
|
||||
## ⚠️ Por que o basicAuth é obrigatório
|
||||
|
||||
O Control Plane 1.1.0 sobe com `access_key_auth: false` e loga
|
||||
`No API key configured (public access)`. **Sem o basicAuth do Traefik, os banks
|
||||
do Hermes ficariam públicos na internet** — `hermes-default` sozinho tem 2.254
|
||||
fatos do O Frangão.
|
||||
|
||||
Se alguém criar um router novo apontando direto para 9999/8888 sem middleware,
|
||||
a exposição volta. Para auth no app em vez do proxy, a referência é
|
||||
`HINDSIGHT_CP_ACCESS_KEY` + `HINDSIGHT_CP_DATAPLANE_API_KEY`.
|
||||
|
||||
## Arquivo de rota
|
||||
|
||||
`/docker/traefik-nkif/dynamic/hindsight.yml` — montado em modo **read-only**
|
||||
no container do Traefik (`/docker/traefik-nkif/dynamic` → `/etc/traefik/dynamic`).
|
||||
|
||||
O `hermes-hindsight-sync` (systemd timer, 6h) recria o container do Hindsight
|
||||
mas **não toca** nesse arquivo — a rota sobrevive a recreates.
|
||||
|
||||
## Uso pela API (via proxy, com basicAuth)
|
||||
|
||||
O CP expõe a API do Hindsight no mesmo host. Formato **real** (o CP 1.1.0
|
||||
exige `items[]` — mandar só `content` dá HTTP 500
|
||||
`TypeError: Cannot read properties of undefined (reading 'map')`):
|
||||
|
||||
```bash
|
||||
# 1. criar bank (POST /api/banks) -> 201
|
||||
curl -u "filipe:$SENHA" -X POST https://hindsight.srv2032242.hstgr.cloud/api/banks \
|
||||
-H 'Content-Type: application/json' -d '{"bank_id":"meu-bank","name":"meu-bank"}'
|
||||
|
||||
# 2. gravar (POST /api/memories/retain) -> {"success":true,...}
|
||||
curl -u "filipe:$SENHA" -X POST https://hindsight.srv2032242.hstgr.cloud/api/memories/retain \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"bank_id":"meu-bank","items":[{"content":"fato a guardar"}]}'
|
||||
|
||||
# 3. reler (POST /api/recall) -> {"results":[...]}
|
||||
curl -u "filipe:$SENHA" -X POST https://hindsight.srv2032242.hstgr.cloud/api/recall \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"bank_id":"meu-bank","query":"o que eu guardi?"}'
|
||||
|
||||
# 4. apagar bank (DELETE /api/banks/{id})
|
||||
curl -u "filipe:$SENHA" -X DELETE https://hindsight.srv2032242.hstgr.cloud/api/banks/meu-bank
|
||||
```
|
||||
|
||||
Sem credencial, todos esses endpoints respondem **401** com
|
||||
`WWW-Authenticate: Basic realm="traefik"`.
|
||||
|
||||
### Detalhe importante: bank precisa existir
|
||||
|
||||
`POST /api/memories/retain` num bank inexistente falha com 500
|
||||
(`Bank 'X' not found` no log do container). Crie o bank antes com
|
||||
`POST /api/banks`. Banks são criados pelo CP, não pelo dataplane
|
||||
(`POST /v1/default/banks` → 405).
|
||||
|
||||
## Banks em produção
|
||||
|
||||
| Bank | Memórias |
|
||||
|---|---|
|
||||
| `hermes-default` | 2.254 |
|
||||
| `hermes-viral-finder` | 204 |
|
||||
| `hermes-email-triagem` | 98 |
|
||||
| `hermes-caixa-vigia` | 106 |
|
||||
| `hermes-blog` | 40 |
|
||||
| `hermes-frangao` | 7 |
|
||||
|
||||
## Como validar (checklist)
|
||||
|
||||
```bash
|
||||
# 401 sem credencial
|
||||
curl -sI https://hindsight.srv2032242.hstgr.cloud/ | grep -i 'HTTP/\|www-authenticate'
|
||||
|
||||
# 200 com credencial
|
||||
curl -s -u "filipe:$SENHA" https://hindsight.srv2032242.hstgr.cloud/api/banks | python3 -m json.tool
|
||||
|
||||
# isolamento das portas internas
|
||||
curl -s -o /dev/null -w '%{http_code}\n' http://2.25.234.119:8888/ # 000
|
||||
curl -s -o /dev/null -w '%{http_code}\n' http://2.25.234.119:9999/ # 000
|
||||
```
|
||||
Reference in new issue
Block a user