Compare commits

..
9 Commits
Author SHA1 Message Date
Andrew S Erwin e718a3d6e9 release 0.3.8: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 5m34s
release / smoke (push) Successful in 10m20s
release / publish (push) Failing after 9m50s
2026-11-25 00:52:22 -06:00
Andrew S Erwin a167e376f7 MCP settings: suggestion catalog for GitHub, HubSpot and Make
The connections list now serves a shipped catalog of well-known hosted
MCP servers (data in the binary, like the entitlements catalog — never a
TIER fork). 'Use' prefills name/url/transport/authKind and shows a
secretHint placeholder; the credential stays the user's to paste
(write-only discipline unchanged).

Verified against vendor docs: GitHub (api.githubcopilot.com/mcp/) and
Make (<zone>.make.com/mcp/v2) accept Bearer tokens and are connectable
today. HubSpot's remote MCP (mcp.hubspot.com) requires OAuth 2.1 + PKCE
with no static-token path — the client speaks none/bearer/header only,
so the entry is shown honestly labeled 'OAuth required' with a note and
docs link, and NO Use button. Go test asserts the catalog; browser
regression covers the prefill and the HubSpot treatment.
2026-11-25 00:51:23 -06:00
Andrew S Erwin c04be7529a release 0.3.7: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 5m34s
release / smoke (push) Successful in 10m20s
release / publish (push) Failing after 9m57s
2026-11-24 16:04:08 -06:00
Andrew S Erwin 4b6a58118e Rename Go module to gitea.federated.computer/Federated_Computer/superbrain
The Gitea repository was renamed brain -> superbrain (server-side redirect
already in place; local origin updated at 0.3.5). Carry the rename through
for accurate identity, the 0.3.2 precedent: go.mod + every internal import,
the agent's outbound User-Agent contact URL, README/RUNNING clone URLs and
local notes. CHANGELOG history entries stay as written. Pure identifier
rename, no runtime behavior change; verified with build + vet + unit tests
and the full database integration suite under -race.
2026-11-24 16:02:01 -06:00
Andrew S Erwin ae7d3852e2 release 0.3.6: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 5m33s
release / smoke (push) Successful in 10m36s
release / publish (push) Failing after 9m57s
2026-11-24 11:35:20 -06:00
Andrew S Erwin 3878dddaa7 WebDAV: survive rate limits on large shares
Nextcloud throttles bursty PROPFIND walks (429) and big trees exceeded the
3-minute sync budget — production's 1000+ file share failed intermittently
with 'unexpected answer (429)' and 'context deadline exceeded'. propfind now
retries 429/503 up to 3 times honoring Retry-After (capped 30s, ctx-bound,
linear backoff without the header), the directory walk paces 100ms between
PROPFINDs, and the engine sync budget grows to 6 minutes. Unit tests cover
recover-after-429 and the bounded attempt count; truncation semantics are
unchanged.
2026-11-24 11:35:06 -06:00
Andrew S Erwin dbf4a896c3 release 0.3.5: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 5m43s
release / smoke (push) Successful in 10m28s
release / publish (push) Failing after 9m54s
2026-11-24 11:13:38 -06:00
Andrew S Erwin 0ce74551ac CalDAV: send comp-filter, not comp, in calendar-query (RFC 4791)
sabre/dav (Nextcloud) silently ignores unknown elements inside <filter>
and 400s with 'The {caldav}filter element is required' when no comp-filter
parses — so every calendar REPORT failed against real Nextcloud while the
fakes (which ignored REPORT bodies) stayed green. Reproduced against
Nextcloud 34.0.3 with a throwaway user: comp -> 400, comp-filter -> 207.
fakeCaldav now validates the REPORT body like sabre and returns the same
400, so the integration suite catches this class of bug.
2026-11-23 21:45:22 -06:00
Andrew S Erwin eff81e4d8d Settings: remove the Contacts sync tab; the sync API remains
The single-config Nextcloud Contacts sync tab is gone — the unified
Nextcloud tab is the UI path for connecting an account. POST
/api/contacts/sync is untouched (Contact rows still feed contact-linking;
the handler is stateless, so no persisted config orphans). Legacy
?tab=nextcloud deep links map to the unified tab on first render and clean
the URL; CardDAV/help wording follows. Regression asserts the tab is gone
and the legacy deep link lands on the Nextcloud form.
2026-11-23 16:09:17 -06:00
89 changed files with 562 additions and 288 deletions
+8 -3
View File
@@ -111,7 +111,7 @@ Bearer / custom-header auth. Stored in `McpConnection` (migration 018).
| Method | Path | Returns |
|---|---|---|
| GET | `/api/mcp/connections` | `{connections:[…]}` — secret masked `••••••••` when set, never plaintext |
| GET | `/api/mcp/connections` | `{connections:[…],suggestions:[…]}` — secret masked `••••••••` when set, never plaintext; suggestions are the shipped catalog of well-known hosted MCP servers (GitHub, HubSpot, Make) with `available:false` marking auth the client cannot satisfy (HubSpot requires OAuth 2.1 + PKCE) |
| POST | `/api/mcp/connections` | 201 masked projection; body `{name,url,transport,authKind,headerName?,secret?}`; secret required for bearer/header; cap 10 per user |
| PATCH | `/api/mcp/connections/{id}` | masked projection; **requires `version`** (409 on stale); a mask or omitted `secret` keeps the stored value; switching `authKind` to `none` clears it |
| DELETE | `/api/mcp/connections/{id}` | `{ok:true}`; 404 for another user's row |
@@ -158,7 +158,10 @@ deleted it, FK SET NULL) re-links every still-tracked file. A truncated
listing (200 dirs / 1000 files / depth 12 caps) creates new members but
never reconciles deletions. Dials are netguard-pinned (ports 80/443 outside
tests), credentials travel only in a Basic `Authorization` header (never the
URL), and redirects are refused outright. Creation AND every sync re-check
URL), and redirects are refused outright. Rate-limited answers (429/503) are
retried up to 3 times honoring `Retry-After` (capped at 30s), directory walks
are paced 100ms apart, and the engine's per-sync budget is 6 minutes — large
shares throttle instead of failing. Creation AND every sync re-check
`AllowConnector("webdav")` from the entitlement catalog; a downgrade
suppresses syncs instead of deleting anything.
@@ -242,7 +245,9 @@ against each protocol (parallel netguard-pinned probes sharing the siblings'
that passes. This is orchestration, not a fourth connector: every sibling's
plan gate, validation (including CardDAV's https/443 pin), caps and projections
apply unchanged, and materialization stays on the siblings' `/sync` surfaces.
The separate Contacts sync is untouched.
The separate Contacts sync API (`POST /api/contacts/sync`) is untouched, but
its settings tab was removed — the unified Nextcloud tab is the UI path, and
legacy `?tab=nextcloud` deep links redirect to it.
| Method | Path | Returns / behavior |
|---|---|---|
+59
View File
@@ -7,6 +7,65 @@ Versions correspond to git tags and to the published image set
(the line was reset to 0.2.x at 0.2.14 — Superbrain is pre-beta).
Dates are tag dates.
## 0.3.8 — 2026-11-25
### Added
- **MCP suggestion catalog**: Settings → MCP offers GitHub, HubSpot and
Make as one-click prefills. The catalog ships as data in the binary
(like the entitlements catalog — never a TIER fork); "Use" prefills
name/url/transport/authKind with a credential hint, and the secret stays
write-only. Verified against vendor docs: GitHub
(`api.githubcopilot.com/mcp/`, PAT) and Make (`<zone>.make.com/mcp/v2`,
API token with `mcp:use`) accept Bearer tokens and are connectable today.
HubSpot's remote MCP (`mcp.hubspot.com`) requires OAuth 2.1 + PKCE with
no static-token path, so it is shown honestly labeled "OAuth required"
with a note and docs link and NO Use button — the client speaks
none/bearer/header only.
## 0.3.7 — 2026-11-24
### Changed
- **Accurate module identity after the Gitea rename**: the repository was
renamed `brain` → `superbrain` on Gitea; the Go module is now
`gitea.federated.computer/Federated_Computer/superbrain` (go.mod + every
internal import), and the agent's outbound User-Agent contact URL and the
README/RUNNING clone URLs follow. Pure identifier rename with no runtime
behavior change; verified with build + vet + unit tests and the full
database integration suite under `-race`.
## 0.3.6 — 2026-11-24
### Fixed
- **WebDAV on large shares**: Nextcloud throttles bursty PROPFIND walks, so
production's 1,000+ file share failed intermittently with "unexpected
answer (429)" and "context deadline exceeded". PROPFIND now retries
429/503 up to 3 times honoring `Retry-After` (capped at 30s, ctx-bound,
linear backoff without the header), the directory walk paces 100ms between
requests, and the engine's per-sync budget grows from 3 to 6 minutes.
Truncation semantics are unchanged (a capped walk still never reconciles
deletions); unit tests cover recover-after-429 and the bounded attempt
count.
## 0.3.5 — 2026-11-24
### Fixed
- **CalDAV against real Nextcloud**: the calendar-query REPORT now sends
`comp-filter` (RFC 4791 §9.8) instead of `comp`. sabre/dav silently ignores
unknown elements inside `<filter>` and answers 400 ("The {caldav}filter
element is required") when no `comp-filter` parses, so every calendar's
event fetch failed against Nextcloud while discovery succeeded — syncs
recorded success with zero events and no `lastError`. Reproduced against
Nextcloud 34.0.3 (`comp` → 400, `comp-filter` → 207); `fakeCaldav` now
validates REPORT bodies like sabre so the integration suite catches this
class of bug.
### Removed
- **Contacts sync settings tab**: the single-config Nextcloud Contacts sync
UI is gone — the unified Nextcloud tab is the UI path.
`POST /api/contacts/sync` is untouched (Contact rows still feed
contact-linking; the handler is stateless). Legacy `?tab=nextcloud` deep
links land on the unified tab.
## 0.3.4 — 2026-11-23
### Changed
+3 -3
View File
@@ -38,7 +38,7 @@ Details: [web/docs/AUTHELIA.md](web/docs/AUTHELIA.md) §7.
Requires Docker with Compose v2 or newer. On a new installation:
```bash
git clone https://gitea.federated.computer/Federated_Computer/brain.git
git clone https://gitea.federated.computer/Federated_Computer/superbrain.git
cd superbrain
cp .env.example .env
docker run --rm node:22-alpine node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"
@@ -490,7 +490,7 @@ federatedcomputer/superbrain-migrate:<version> DB bootstrap (context db, db/D
```
Platforms: `linux/amd64,linux/arm64`. Source of truth: this Gitea repo
(`https://gitea.federated.computer/Federated_Computer/brain.git`) at the
(`https://gitea.federated.computer/Federated_Computer/superbrain.git`) at the
matching tag. The repositories auto-create on first push under the
`federatedcomputer` namespace; keep them **public** so cores can pull
without registry credentials. Never move an existing tag — cut a new
@@ -536,7 +536,7 @@ Watch the run under the repo's Actions tab; verify with
From any Linux machine with Docker, buildx and login rights:
```bash
git clone https://gitea.federated.computer/Federated_Computer/brain.git
git clone https://gitea.federated.computer/Federated_Computer/superbrain.git
cd brain && git checkout 0.2.17 # always build from the tag
# One-time per machine: buildx builder + cross-arch emulation
+1 -1
View File
@@ -26,7 +26,7 @@ Both commands should succeed. On Windows, Docker must be using Linux containers.
## 1. Download the app
```sh
git clone https://gitea.federated.computer/Federated_Computer/brain.git
git clone https://gitea.federated.computer/Federated_Computer/superbrain.git
cd superbrain
```
+1 -1
View File
@@ -48,7 +48,7 @@ SUPERBRAIN_APP_IP="192.168.0.94"
SUPERBRAIN_MIGRATE_IP="192.168.0.95"
# Release to install; the generic `upgrade` flow keeps .env in step with the
# service file's VERSION afterwards.
SUPERBRAIN_IMAGE_VERSION="0.3.4"
SUPERBRAIN_IMAGE_VERSION="0.3.8"
# render_superbrain_compose writes the app-dir compose file. Called by
# config_superbrain (install) and by deploy/federated/update.sh after a lib
+1 -1
View File
@@ -2,7 +2,7 @@ NAME=superbrain
DESCRIPTION="Bookmark & Knowledge Base"
DOCS=https://github.com/andrew/superbrain
CONTAINER=federatedcomputer/superbrain-app
VERSION=0.3.4
VERSION=0.3.8
INTERNAL_IP=192.168.0.93
DEPENDS="postgresql"
PORTS=3000
+1 -1
View File
@@ -1,4 +1,4 @@
module gitea.federated.computer/Federated_Computer/brain
module gitea.federated.computer/Federated_Computer/superbrain
go 1.26.0
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"fmt"
"strings"
"gitea.federated.computer/Federated_Computer/brain/internal/ai"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/ai"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// ErrCompileRejected means the model could not (or refused to) express the
+8 -8
View File
@@ -14,13 +14,13 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/ai"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/mailer"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/brain/internal/notify"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/ai"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/mailer"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/notify"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
"net"
)
@@ -407,7 +407,7 @@ func fetchText(ctx context.Context, rawurl string) (string, error) {
if err != nil {
return "", err
}
req.Header.Set("User-Agent", "Superbrain-agent/1.0 (+https://gitea.federated.computer/Federated_Computer/brain)")
req.Header.Set("User-Agent", "Superbrain-agent/1.0 (+https://gitea.federated.computer/Federated_Computer/superbrain)")
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/json;q=0.9,text/plain;q=0.8")
res, err := fetchClient.Do(req)
if err != nil {
+6 -6
View File
@@ -33,12 +33,12 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
// DefaultModel is the fallback for the server env config (OpenRouter free
+1 -1
View File
@@ -30,7 +30,7 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
const (
+2 -2
View File
@@ -3,8 +3,8 @@ package auth
import (
"encoding/json"
"errors"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"github.com/jackc/pgx/v5/pgconn"
"log"
"net/http"
+3 -3
View File
@@ -3,9 +3,9 @@ package auth
import (
"context"
"errors"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/models"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/models"
"log"
"net/http"
"sync"
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"github.com/golang-jwt/jwt/v5"
)
+3 -3
View File
@@ -32,9 +32,9 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/mailer"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/mailer"
)
const (
+1 -1
View File
@@ -25,7 +25,7 @@ import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"net"
"net/http"
"sort"
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"github.com/golang-jwt/jwt/v5"
)
+4 -4
View File
@@ -4,10 +4,10 @@ import (
"database/sql"
"encoding/json"
"errors"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/handlers"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/handlers"
"log"
"net/http"
"strings"
+8 -3
View File
@@ -29,7 +29,7 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
)
// Conn is the dial-relevant projection of a stored CalDavConnection row plus
@@ -228,12 +228,17 @@ func Events(ctx context.Context, conn Conn, calURL string) (*EventResult, error)
return out, nil
}
// calQueryBody uses comp-filter (RFC 4791 §9.8) — NOT "comp": sabre/dav
// (Nextcloud) silently ignores unknown elements inside <filter>, then 400s
// with "The {caldav}filter element is required" when no comp-filter parsed.
// The fakes once ignored REPORT bodies entirely and missed this; fakeCaldav
// now validates the body like sabre does.
const calQueryBody = `<?xml version="1.0" encoding="utf-8"?>` +
`<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">` +
`<D:prop><D:getetag/><C:calendar-data/></D:prop>` +
`<C:filter><C:comp name="VCALENDAR"><C:comp name="VEVENT">` +
`<C:filter><C:comp-filter name="VCALENDAR"><C:comp-filter name="VEVENT">` +
`<C:time-range start="%s" end="%s"/>` +
`</C:comp></C:comp></C:filter></C:calendar-query>`
`</C:comp-filter></C:comp-filter></C:filter></C:calendar-query>`
// --- PROPFIND plumbing -------------------------------------------------------
+4 -4
View File
@@ -11,10 +11,10 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
const (
+1 -1
View File
@@ -31,7 +31,7 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
)
// Conn is the dial-relevant projection of a stored CardDavConnection row
+4 -4
View File
@@ -10,10 +10,10 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
const (
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
_ "github.com/jackc/pgx/v5/stdlib"
)
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"errors"
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/entitlements"
)
// Tenancy phase 1 (DESIGN_TENANCY_ENTITLEMENTS.md): every user belongs to
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/models"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/models"
)
type UserRepo struct{ db *DB }
+4 -4
View File
@@ -14,10 +14,10 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/agent"
"gitea.federated.computer/Federated_Computer/brain/internal/ai"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/agent"
"gitea.federated.computer/Federated_Computer/superbrain/internal/ai"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// compileLimiter bounds NL compilations per user (each one is an LLM call).
+7 -7
View File
@@ -19,13 +19,13 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/agent"
"gitea.federated.computer/Federated_Computer/brain/internal/ai"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/superbrain/internal/agent"
"gitea.federated.computer/Federated_Computer/superbrain/internal/ai"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/entitlements"
)
// aiKeyMask mirrors the notification-channel mask: write-only secrets.
+2 -2
View File
@@ -20,8 +20,8 @@ import (
"strings"
"unicode/utf8"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// maxAPIKeys caps live keys per user — a product limit against credential
+3 -3
View File
@@ -6,9 +6,9 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/markdown"
"gitea.federated.computer/Federated_Computer/brain/internal/preview"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/markdown"
"gitea.federated.computer/Federated_Computer/superbrain/internal/preview"
"net/http"
"strconv"
"strings"
+6 -6
View File
@@ -22,12 +22,12 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/caldav"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/caldav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
const (
+7 -7
View File
@@ -27,13 +27,13 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/carddav"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/carddav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
const (
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"math"
"net/http"
"regexp"
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"encoding/json"
"errors"
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"github.com/jackc/pgx/v5/pgconn"
"io"
"log"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"net/http"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// Structured export (trust phase): a single owner-scoped JSON archive that is
+2 -2
View File
@@ -2,8 +2,8 @@ package handlers
import (
"database/sql"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/kanban"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/kanban"
"net/http"
"strings"
)
+47 -8
View File
@@ -23,12 +23,12 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/mcpclient"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/mcpclient"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
const (
@@ -59,7 +59,46 @@ func mcpProjection(row object) object {
}
}
// HandleMcpConnectionsList returns the caller's connections, masked.
// mcpSuggestions is the product catalog of well-known hosted MCP servers
// offered on the MCP settings tab — DATA in the shipped binary (like the
// entitlements catalog), not deployment config and never a TIER fork.
// "Use" prefills the connection form; the user still supplies the credential
// and confirms. available=false marks a server whose authentication this
// client cannot satisfy today: HubSpot's remote MCP requires OAuth 2.1 with
// PKCE (no static-token path), while internal/mcpclient speaks none/bearer/
// header only — the entry stays visible, honestly labeled, without a Use
// button. URLs/auth verified against the vendors' docs 2026-11.
var mcpSuggestions = []object{
{
"kind": "github", "name": "GitHub",
"url": "https://api.githubcopilot.com/mcp/",
"transport": "streamable-http", "authKind": "bearer", "available": true,
"description": "Repos, issues, pull requests, code search and Actions.",
"secretHint": "GitHub personal access token (fine-grained recommended)",
"note": "Append /readonly to the URL for read-only tools.",
"docsUrl": "https://github.com/github/github-mcp-server",
},
{
"kind": "hubspot", "name": "HubSpot",
"url": "https://mcp.hubspot.com",
"transport": "streamable-http", "authKind": "bearer", "available": false,
"description": "CRM contacts, companies, deals, tickets and activities.",
"note": "Requires OAuth 2.1 sign-in (PKCE) — HubSpot refuses token-only connections, and Superbrain's MCP client does not do OAuth flows yet.",
"docsUrl": "https://developers.hubspot.com/ai-tools/mcp",
},
{
"kind": "make", "name": "Make",
"url": "https://us1.make.com/mcp/v2",
"transport": "streamable-http", "authKind": "bearer", "available": true,
"description": "Run your Make scenarios as tools; manage scenarios and data stores.",
"secretHint": "Make API token with the mcp:use scope (Profile → API access)",
"note": "Swap in your account's zone: eu1, eu2, us1 or us2.make.com.",
"docsUrl": "https://developers.make.com/mcp-server/",
},
}
// HandleMcpConnectionsList returns the caller's connections, masked, plus
// the suggestion catalog (always an array so clients can map() blindly).
func HandleMcpConnectionsList(w http.ResponseWriter, r *http.Request) {
rows, e := db.Many(r.Context(), database(r),
`SELECT to_jsonb(t) FROM "McpConnection" t WHERE "ownerId"=$1 ORDER BY "createdAt"`, user(r))
@@ -71,7 +110,7 @@ func HandleMcpConnectionsList(w http.ResponseWriter, r *http.Request) {
for _, row := range rows {
out = append(out, mcpProjection(row))
}
respond(w, 200, object{"connections": out}, nil)
respond(w, 200, object{"connections": out, "suggestions": mcpSuggestions}, nil)
}
func cleanMcpFields(b object, create bool) (object, error) {
+6 -6
View File
@@ -5,12 +5,12 @@ import (
"database/sql"
"encoding/xml"
"errors"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/brain/internal/signals"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/signals"
"io"
"net"
"net/http"
+8 -8
View File
@@ -35,14 +35,14 @@ import (
"sync"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/caldav"
"gitea.federated.computer/Federated_Computer/brain/internal/carddav"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/brain/internal/webdav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/caldav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/carddav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/webdav"
)
const nextcloudVerifyTimeout = 25 * time.Second
+4 -4
View File
@@ -19,10 +19,10 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/notify"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/notify"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
// errPlanGate answers 403 for features the tenant's plan does not include.
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"regexp"
"strings"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// Connected pages (Notion-like upgrades phase 3).
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"net/http"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// Page revision history (trust phase). Every committed content version gets
+2 -2
View File
@@ -3,8 +3,8 @@ package handlers
import (
"context"
"database/sql"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/markdown"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/markdown"
"net/http"
"strings"
"time"
+1 -1
View File
@@ -15,7 +15,7 @@ import (
"sort"
"strings"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// profileTextFields maps the allowlisted column names to their rune caps.
+3 -3
View File
@@ -3,9 +3,9 @@ package handlers
import (
"context"
"encoding/json"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/brain/internal/signals"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/signals"
"net/http"
"strings"
"time"
+1 -1
View File
@@ -2,7 +2,7 @@ package handlers
import (
"database/sql"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"net/http"
"strings"
"time"
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"encoding/json"
"net/http"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// Recoverable deletions (trust phase).
+1 -1
View File
@@ -1,7 +1,7 @@
package handlers
import (
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"net/http"
)
+6 -6
View File
@@ -25,12 +25,12 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/brain/internal/webdav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/webdav"
)
const (
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"strings"
"testing"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// machineReq calls the API with an API-key Bearer header and no cookies —
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/scripts"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/scripts"
)
// AUTH_MODE=oidc (core/federated shape): Authelia exclusively. Password
+13 -1
View File
@@ -11,7 +11,7 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// fakeCaldav is a mutable RFC 4791 server for integration tests: a home at
@@ -78,6 +78,18 @@ func (f *fakeCaldav) serve(w http.ResponseWriter, r *http.Request) {
<response><href>%s/personal/</href><propstat><prop xmlns:C="urn:ietf:params:xml:ns:caldav"><resourcetype><C:calendar/></resourcetype><displayname>Personal</displayname></prop></propstat></response>
</multistatus>`, f.root, f.root, f.root)
case "REPORT":
// Validate the query body like sabre/dav does: a calendar-query
// without a <filter> containing <comp-filter> is a 400 ("The
// {caldav}filter element is required"). The old fake ignored the
// body, which let a wrong element name ("comp" instead of
// "comp-filter") ship and fail against real Nextcloud.
raw, _ := io.ReadAll(io.LimitReader(r.Body, 1<<20))
if !strings.Contains(string(raw), "comp-filter") {
w.Header().Set("Content-Type", "application/xml")
w.WriteHeader(http.StatusBadRequest)
io.WriteString(w, `<?xml version="1.0"?><d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><s:exception>Sabre\DAV\Exception\BadRequest</s:exception><s:message>The {urn:ietf:params:xml:ns:caldav}filter element is required for this request</s:message></d:error>`)
return
}
key := strings.Trim(strings.TrimPrefix(r.URL.Path, f.root+"/"), "/")
collection := f.events
if key == "personal" {
+2 -2
View File
@@ -16,8 +16,8 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/signals"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/signals"
"github.com/emersion/go-imap/backend/memory"
imapserver "github.com/emersion/go-imap/server"
"github.com/golang-jwt/jwt/v5"
+4 -4
View File
@@ -3,10 +3,10 @@ package http
import (
"bytes"
"encoding/json"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
"io"
"net/http"
"net/http/cookiejar"
+2 -2
View File
@@ -3,8 +3,8 @@ package http
import (
"context"
"encoding/json"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/signals"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/signals"
"github.com/emersion/go-imap/backend/memory"
imapserver "github.com/emersion/go-imap/server"
"io"
+32
View File
@@ -5,6 +5,7 @@ import (
"net/http"
"net/http/cookiejar"
"net/http/httptest"
"strings"
"testing"
mcpsdk "github.com/modelcontextprotocol/go-sdk/mcp"
@@ -135,3 +136,34 @@ func TestMcpConnections(t *testing.T) {
// maxTestMcpConns mirrors handlers.maxMcpConns.
const maxTestMcpConns = 10
// The suggestion catalog ships with the list: GitHub and Make are
// token-connectable (bearer), HubSpot is honestly flagged unavailable
// because its remote MCP requires OAuth 2.1 + PKCE, which the client
// (none/bearer/header) cannot do.
func TestMcpSuggestions(t *testing.T) {
srv := testServer(t)
c, _ := accountClient(t, srv.URL, "mcp-sugg@superbrain.test")
list := c.request("GET", "/api/mcp/connections", nil, 200)
sugg, _ := list["suggestions"].([]any)
byKind := map[string]map[string]any{}
for _, s := range sugg {
m := s.(map[string]any)
byKind[m["kind"].(string)] = m
}
if len(byKind) != 3 {
t.Fatalf("want github/hubspot/make suggestions, got %v", byKind)
}
gh := byKind["github"]
if gh["url"] != "https://api.githubcopilot.com/mcp/" || gh["authKind"] != "bearer" || gh["available"] != true {
t.Fatalf("github suggestion wrong: %v", gh)
}
mk := byKind["make"]
if mk["authKind"] != "bearer" || mk["available"] != true || !strings.Contains(mk["url"].(string), "make.com/mcp/v2") {
t.Fatalf("make suggestion wrong: %v", mk)
}
hs := byKind["hubspot"]
if hs["available"] != false || hs["url"] != "https://mcp.hubspot.com" {
t.Fatalf("hubspot must be flagged OAuth-only: %v", hs)
}
}
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/entitlements"
)
// fakeNextcloud serves all three DAV protocols on ONE origin with the
+2 -2
View File
@@ -11,8 +11,8 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/notify"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/notify"
)
// fakeWebhook captures one Slack-style POST for the delivery tests.
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/notify"
"gitea.federated.computer/Federated_Computer/superbrain/internal/notify"
)
// fakeSignalBridge mimics a signal-cli REST bridge: POST /v2/send?account=...
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"github.com/golang-jwt/jwt/v5"
)
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// fakeSMTP is a minimal loopback SMTP relay: it speaks just enough of the
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"gitea.federated.computer/Federated_Computer/brain/internal/scripts"
"gitea.federated.computer/Federated_Computer/superbrain/internal/scripts"
"net/http"
"net/http/cookiejar"
"os"
+6 -6
View File
@@ -6,12 +6,12 @@ import (
"os"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/auth"
"gitea.federated.computer/Federated_Computer/brain/internal/authguard"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/handlers"
"gitea.federated.computer/Federated_Computer/brain/internal/oidc"
"gitea.federated.computer/Federated_Computer/superbrain/internal/auth"
"gitea.federated.computer/Federated_Computer/superbrain/internal/authguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/handlers"
"gitea.federated.computer/Federated_Computer/superbrain/internal/oidc"
)
// NewServer builds the HTTP server with all routes registered.
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/entitlements"
)
// Tenancy phase 1: every account-creation path lands the user in the
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"testing"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/notify"
"gitea.federated.computer/Federated_Computer/superbrain/internal/notify"
)
var unsubTokenRx = regexp.MustCompile(`/unsubscribe\?token=([0-9a-f.]+)`)
+3 -3
View File
@@ -10,9 +10,9 @@ import (
"sync"
"testing"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/brain/internal/webdav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/superbrain/internal/webdav"
)
// fakeShare is a mutable minimal RFC 4918 server (Basic-auth erwin/s3cret)
+1 -1
View File
@@ -3,7 +3,7 @@ package kanban
import (
"context"
"database/sql"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
var DefaultColumns = []struct{ Label, Color, Key string }{{"Inbox", "#64748b", "INBOX"}, {"To Do", "#3b82f6", "TODO"}, {"In Progress", "#f59e0b", "IN_PROGRESS"}, {"Done", "#22c55e", "DONE"}}
+2 -2
View File
@@ -32,8 +32,8 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
// ErrNotConfigured means SMTP_HOST/SMTP_FROM are unset; callers surface a
+1 -1
View File
@@ -2,7 +2,7 @@ package markdown
import (
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"net/http"
"regexp"
"strings"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"strings"
"testing"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
)
// Review L-11: link destinations are wrapped and escaped so parentheses or
+2 -2
View File
@@ -23,7 +23,7 @@ import (
mcpsdk "github.com/modelcontextprotocol/go-sdk/mcp"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
)
// Conn is the dial-relevant projection of a stored McpConnection row plus
@@ -91,7 +91,7 @@ func httpClient(conn Conn) *http.Client {
// ListTools connects, initializes and lists the server's tools, then closes
// the session. The context bounds the whole exchange.
func ListTools(ctx context.Context, conn Conn) ([]Tool, error) {
client := mcpsdk.NewClient(&mcpsdk.Implementation{Name: "superbrain", Version: "0.3.4"}, nil)
client := mcpsdk.NewClient(&mcpsdk.Implementation{Name: "superbrain", Version: "0.3.8"}, nil)
var transport mcpsdk.Transport
hc := httpClient(conn)
switch conn.Transport {
+4 -4
View File
@@ -27,10 +27,10 @@ import (
"strings"
"time"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/mailer"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/mailer"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
)
// Kinds is the phase-1 channel set (mirrors the NotificationChannel CHECK).
+4 -4
View File
@@ -28,10 +28,10 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/entitlements"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
const (
+3 -3
View File
@@ -13,9 +13,9 @@ import (
"encoding/hex"
"strings"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/mailer"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/mailer"
)
// unsubscribeDomain separates these MACs from every other use of the
+1 -1
View File
@@ -16,7 +16,7 @@ import (
"regexp"
"strings"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
)
var placeholderPatterns = []*regexp.Regexp{
+2 -2
View File
@@ -3,8 +3,8 @@ package preview
import (
"context"
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
"golang.org/x/net/html"
"io"
"net"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"golang.org/x/crypto/bcrypt"
"os"
"strings"
+1 -1
View File
@@ -2,7 +2,7 @@ package signals
import (
"context"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"log"
"sync"
"time"
+4 -4
View File
@@ -6,10 +6,10 @@ import (
"database/sql"
"errors"
"fmt"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/client"
"log"
+62 -10
View File
@@ -26,10 +26,11 @@ import (
"net/http"
"net/url"
"path"
"strconv"
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/netguard"
"gitea.federated.computer/Federated_Computer/superbrain/internal/netguard"
)
// Conn is the dial-relevant projection of a stored WebDavConnection row plus
@@ -146,6 +147,13 @@ func List(ctx context.Context, conn Conn) (*ListResult, error) {
if rel != "" {
dirURL += "/"
}
if dials > 1 {
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-time.After(walkPace):
}
}
entries, err := propfindEntries(ctx, conn, dirURL)
if err != nil {
return nil, err
@@ -218,18 +226,62 @@ type parsed struct {
// propfind issues a PROPFIND with the given Depth and returns the raw
// response (caller closes the body). Both Check and List build the same
// request; only Depth differs.
//
// Rate limits (429/503 — Nextcloud throttles bursty PROPFIND walks) are
// retried up to rateRetries times, honoring Retry-After (capped at
// rateWaitCap so a hostile server cannot pin the sync); without the header
// a short linear backoff applies. Every wait is ctx-bound.
func propfind(ctx context.Context, conn Conn, target, depth string) (*http.Response, error) {
req, err := http.NewRequestWithContext(ctx, "PROPFIND", target, strings.NewReader(propfindBody))
if err != nil {
return nil, err
for attempt := 0; ; attempt++ {
req, err := http.NewRequestWithContext(ctx, "PROPFIND", target, strings.NewReader(propfindBody))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/xml")
req.Header.Set("Depth", depth)
res, err := httpClient(conn).Do(req)
if err != nil {
return nil, fmt.Errorf("could not reach the WebDAV share: %w", err)
}
if (res.StatusCode == http.StatusTooManyRequests || res.StatusCode == http.StatusServiceUnavailable) && attempt < rateRetries {
wait := rateLimitWait(res.Header.Get("Retry-After"), attempt)
_ = res.Body.Close()
select {
case <-ctx.Done():
return nil, fmt.Errorf("could not reach the WebDAV share: %w", ctx.Err())
case <-time.After(wait):
}
continue
}
return res, nil
}
req.Header.Set("Content-Type", "application/xml")
req.Header.Set("Depth", depth)
res, err := httpClient(conn).Do(req)
if err != nil {
return nil, fmt.Errorf("could not reach the WebDAV share: %w", err)
}
const (
rateRetries = 3
rateWaitCap = 30 * time.Second
rateWaitDefault = 5 * time.Second
// walkPace spaces directory PROPFINDs so a bounded walk stays under
// common server rate limits instead of tripping them and paying
// Retry-After waits on every request.
walkPace = 100 * time.Millisecond
)
// rateLimitWait parses Retry-After (delay-seconds form; the HTTP-date form
// falls back to the default) and caps it. attempt is zero-based.
func rateLimitWait(header string, attempt int) time.Duration {
if secs, err := strconv.Atoi(strings.TrimSpace(header)); err == nil && secs >= 0 {
d := time.Duration(secs) * time.Second
if d > rateWaitCap {
d = rateWaitCap
}
return d
}
return res, nil
d := rateWaitDefault * time.Duration(attempt+1)
if d > rateWaitCap {
d = rateWaitCap
}
return d
}
const propfindBody = `<?xml version="1.0" encoding="utf-8"?>` +
+49
View File
@@ -197,3 +197,52 @@ func TestNormalizeBasePercentSafety(t *testing.T) {
t.Fatalf("double or missing encoding: %q", got)
}
}
// A 429 with Retry-After is retried, not fatal: the walk recovers once the
// throttle window passes (Nextcloud rate-limits bursty PROPFIND walks).
func TestListRetriesRateLimit(t *testing.T) {
allowPrivate(t)
hits := 0
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hits++
if hits == 1 {
w.Header().Set("Retry-After", "1")
http.Error(w, "slow down", http.StatusTooManyRequests)
return
}
w.Header().Set("Content-Type", "application/xml")
w.WriteHeader(http.StatusMultiStatus)
_, _ = w.Write([]byte(`<multistatus xmlns="DAV:">` +
`<response><href>/dav/</href><propstat><prop><resourcetype><collection/></resourcetype></prop></propstat></response>` +
`<response><href>/dav/a.txt</href><propstat><prop><resourcetype/><getetag>"A1"</getetag></prop></propstat></response>` +
`</multistatus>`))
}))
t.Cleanup(ts.Close)
res, err := List(context.Background(), Conn{BaseURL: ts.URL + "/dav", Username: davUser, Password: davPass})
if err != nil {
t.Fatalf("429 then 207 must recover: %v", err)
}
if len(res.Files) != 1 || res.Files[0].Path != "a.txt" || hits != 2 {
t.Fatalf("retry walk wrong: files=%v hits=%d", res.Files, hits)
}
}
// Persistent 429s stay bounded: exactly rateRetries+1 attempts, then the
// server's answer surfaces (no infinite retry loop pinning the sync tick).
func TestListRateLimitBounded(t *testing.T) {
allowPrivate(t)
hits := 0
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hits++
w.Header().Set("Retry-After", "0")
http.Error(w, "slow down", http.StatusTooManyRequests)
}))
t.Cleanup(ts.Close)
_, err := List(context.Background(), Conn{BaseURL: ts.URL + "/dav", Username: davUser, Password: davPass})
if err == nil || !strings.Contains(err.Error(), "429") {
t.Fatalf("persistent 429 must surface: %v", err)
}
if hits != rateRetries+1 {
t.Fatalf("attempts = %d, want %d", hits, rateRetries+1)
}
}
+5 -5
View File
@@ -12,17 +12,17 @@ import (
"strings"
"time"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/brain/internal/crypto"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/outbound"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
crypt "gitea.federated.computer/Federated_Computer/superbrain/internal/crypto"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/outbound"
)
const (
tick = 5 * time.Minute // engine cadence
syncEvery = 30 * time.Minute // per-connection freshness target
perTick = 10 // connections claimed per tick
syncTimeout = 3 * time.Minute // one full reconcile
syncTimeout = 6 * time.Minute // one full reconcile (large walks pace + retry 429s)
lastErrCap = 500
dialBudget = 10 // outbound.Reserve window per owner (tests + syncs)
dialWindow = time.Minute
+10 -10
View File
@@ -3,16 +3,16 @@ package main
import (
"context"
"errors"
"gitea.federated.computer/Federated_Computer/brain/internal/agent"
"gitea.federated.computer/Federated_Computer/brain/internal/caldav"
"gitea.federated.computer/Federated_Computer/brain/internal/carddav"
"gitea.federated.computer/Federated_Computer/brain/internal/config"
"gitea.federated.computer/Federated_Computer/brain/internal/db"
"gitea.federated.computer/Federated_Computer/brain/internal/http"
"gitea.federated.computer/Federated_Computer/brain/internal/notify"
"gitea.federated.computer/Federated_Computer/brain/internal/scripts"
"gitea.federated.computer/Federated_Computer/brain/internal/signals"
"gitea.federated.computer/Federated_Computer/brain/internal/webdav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/agent"
"gitea.federated.computer/Federated_Computer/superbrain/internal/caldav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/carddav"
"gitea.federated.computer/Federated_Computer/superbrain/internal/config"
"gitea.federated.computer/Federated_Computer/superbrain/internal/db"
"gitea.federated.computer/Federated_Computer/superbrain/internal/http"
"gitea.federated.computer/Federated_Computer/superbrain/internal/notify"
"gitea.federated.computer/Federated_Computer/superbrain/internal/scripts"
"gitea.federated.computer/Federated_Computer/superbrain/internal/signals"
"gitea.federated.computer/Federated_Computer/superbrain/internal/webdav"
"log"
stdhttp "net/http"
"os"
+1 -1
View File
@@ -7,7 +7,7 @@ name = "superbrain-mcp"
# Versioned in lockstep with the Superbrain release it speaks to (house
# tooling tracks one version per app); the federated mcpserver gateway
# installs this package and spawns `superbrain-mcp` per linked instance.
version = "0.3.4"
version = "0.3.8"
description = "MCP server for Superbrain — bookmarks, tags and pages over the Superbrain REST API"
readme = "README.md"
requires-python = ">=3.10"
+1 -1
View File
@@ -1,3 +1,3 @@
"""Superbrain MCP server — bookmarks, tags and pages for AI tooling."""
__version__ = "0.3.4"
__version__ = "0.3.8"
+27
View File
@@ -73,6 +73,11 @@ const carddavSuggestions = [{ kind: 'nextcloud', name: 'Nextcloud contacts', url
// Unified Nextcloud connect fixture: mirrors handlers/nextcloud.go — the
// origin is normalized, per-user DAV roots composed server-side, repeat
// connects report "exists", and a wrong password stores nothing.
const mcpSuggestions = [
{ kind: 'github', name: 'GitHub', url: 'https://api.githubcopilot.com/mcp/', transport: 'streamable-http', authKind: 'bearer', available: true, description: 'Repos, issues, pull requests, code search and Actions.', secretHint: 'GitHub personal access token (fine-grained recommended)', note: 'Append /readonly to the URL for read-only tools.' },
{ kind: 'hubspot', name: 'HubSpot', url: 'https://mcp.hubspot.com', transport: 'streamable-http', authKind: 'bearer', available: false, description: 'CRM contacts, companies, deals, tickets and activities.', note: 'Requires OAuth 2.1 sign-in (PKCE) — HubSpot refuses token-only connections, and Superbrain\'s MCP client does not do OAuth flows yet.' },
{ kind: 'make', name: 'Make', url: 'https://us1.make.com/mcp/v2', transport: 'streamable-http', authKind: 'bearer', available: true, description: 'Run your Make scenarios as tools; manage scenarios and data stores.', secretHint: 'Make API token with the mcp:use scope (Profile → API access)', note: 'Swap in your account\'s zone: eu1, eu2, us1 or us2.make.com.' },
]
let lastNextcloudConnect = null
// Automations fixture: the sidebar dropdown and the /automations workspace
// exercise against the same projection handlers/agent.go returns.
@@ -319,6 +324,8 @@ const api = http.createServer(async (req, res) => {
results[key] = { status: 'created', id: conn.id, name: conn.name, url: u }
}
result = { results }
} else if (url.pathname === '/api/mcp/connections') {
result = { connections: [], suggestions: mcpSuggestions }
} else if (url.pathname === '/api/agent/tasks') {
result = agentTasks
} else if (url.pathname === '/api/agent/runs') {
@@ -908,8 +915,28 @@ try {
await page.goto(`${base}/settings`)
await page.getByRole('tab', { name: 'Profile' }).click()
assert.equal(await page.getByRole('tab', { name: 'Automations', exact: true }).count(), 0, 'Automations tab still present in Settings')
// The Contacts sync tab is removed too; its legacy deep link lands on the
// unified Nextcloud tab (the sync API itself remains).
assert.equal(await page.getByRole('tab', { name: 'Contacts sync' }).count(), 0, 'Contacts sync tab still present in Settings')
await page.goto(`${base}/settings?tab=nextcloud`)
await page.getByPlaceholder('https://cloud.example.com').waitFor()
console.log('PASS: Automations lives in the sidebar with a task dropdown, deep-links to /automations, and the legacy settings tab redirects')
// Settings → MCP: the suggestion catalog offers GitHub and Make (token
// auth) with a Use prefill; HubSpot is honestly flagged OAuth-required
// with no Use button — the client speaks none/bearer/header only.
await page.goto(`${base}/settings`)
await page.getByRole('tab', { name: 'MCP' }).click()
await page.getByText('Repos, issues, pull requests, code search and Actions.').waitFor()
assert.equal(await page.getByRole('button', { name: 'Use', exact: true }).count(), 2, 'only token-connectable suggestions may offer Use')
await page.getByText('OAuth required').waitFor()
await page.getByRole('button', { name: 'Use', exact: true }).first().click()
assert.equal(await page.getByPlaceholder('https://mcp.example.tld/mcp').inputValue(), 'https://api.githubcopilot.com/mcp/')
assert.equal(await page.getByPlaceholder('e.g. House gateway, Maps tools…').inputValue(), 'GitHub')
await page.getByPlaceholder('GitHub personal access token (fine-grained recommended)').waitFor()
await page.locator('[role="dialog"]').getByRole('button', { name: 'Cancel' }).click()
console.log('PASS: Settings → MCP offers GitHub/Make suggestions with Use prefill and flags HubSpot as OAuth-required')
// Mobile pass (390x844): the shell becomes a drawer, tables become cards,
// rail screens become master-detail, and NO screen may overflow the
// viewport horizontally. A separate context keeps the desktop session and
+14 -58
View File
@@ -5,9 +5,8 @@ import { useSearchParams, useRouter } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
import { User, Mail, Server, Cloud, CloudCog, Shield, Bell, Bot, KeyRound, PlugZap, FolderSync, CalendarDays, BookUser, ArrowLeft, Check, X, AlertTriangle } from 'lucide-react'
import { User, Mail, Server, CloudCog, Shield, Bell, Bot, KeyRound, PlugZap, FolderSync, CalendarDays, BookUser, ArrowLeft, Check, X, AlertTriangle } from 'lucide-react'
import { toast } from 'sonner'
import { invalidateReference } from '@/lib/reference-data'
import { NotificationsSettings } from '@/components/notifications-settings'
import { ProfileSettings } from '@/components/profile-settings'
import { AiSettings } from '@/components/ai-settings'
@@ -36,7 +35,6 @@ const NAV_GROUPS = [
{ value: 'webdav', label: 'WebDAV', icon: FolderSync },
{ value: 'caldav', label: 'CalDAV', icon: CalendarDays },
{ value: 'carddav', label: 'CardDAV', icon: BookUser },
{ value: 'nextcloud', label: 'Contacts sync', icon: Cloud },
{ value: 'imap', label: 'IMAP', icon: Mail },
] },
{ label: 'AI & Automation', items: [
@@ -57,15 +55,23 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba
const router = useRouter()
// Automations moved out of Settings to its own workspace; legacy deep
// links (?tab=automations) redirect there instead of falling back to profile.
useEffect(() => { if (requestedTab === 'automations') router.replace('/automations') }, [requestedTab, router])
const initialSection = NAV_GROUPS.some(g => g.items.some(i => i.value === requestedTab))
? requestedTab
// The Contacts sync tab was removed — its legacy ?tab=nextcloud deep link
// lands on the unified Nextcloud tab (the sync API itself remains).
useEffect(() => {
if (requestedTab === 'automations') router.replace('/automations')
if (requestedTab === 'nextcloud') router.replace('/settings?tab=nextcloud-connect')
}, [requestedTab, router])
// The Contacts sync tab was removed — its legacy ?tab=nextcloud deep link
// lands on the unified Nextcloud tab (the sync API itself remains). Map the
// legacy value BEFORE deriving the initial section so the tab is selected
// on first render; the effect above only cleans the URL.
const mappedTab = requestedTab === 'nextcloud' ? 'nextcloud-connect' : requestedTab
const initialSection = NAV_GROUPS.some(g => g.items.some(i => i.value === mappedTab))
? mappedTab
: 'profile'
const [imapConfig, setImapConfig] = useState({ host: '', port: 993, tls: true, username: '', password: '', folder: 'INBOX' })
const [ncConfig, setNcConfig] = useState({ nextcloudUrl: '', cardDavPath: '', username: '', password: '' })
const [savingImap, setSavingImap] = useState(false)
const [testingImap, setTestingImap] = useState(false)
const [syncingContacts, setSyncingContacts] = useState(false)
const [section, setSection] = useState(initialSection)
// Below md the grouped nav becomes a list -> detail flow (same
// master-detail pattern as collections/tags/contacts); at md+ the
@@ -113,32 +119,6 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba
finally { setTestingImap(false) }
}
const syncContacts = async () => {
if (!ncConfig.nextcloudUrl || !ncConfig.username || !ncConfig.password) {
toast.error('Fill in Nextcloud URL, username, and password')
return
}
setSyncingContacts(true)
try {
const res = await fetch('/api/contacts/sync', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(ncConfig),
})
const data = await res.json().catch(() => null)
if (res.ok && data?.synced !== undefined) {
// Review CR-07: the sync mirrors the address book — remotely deleted
// contacts are removed too (scoped to this source, never from partial
// responses). Surface both counts so the policy is visible.
const removed = typeof data.removed === 'number' && data.removed > 0 ? `, removed ${data.removed} deleted on the server` : ''
toast.success(`Synced ${data.synced} contacts${removed}`)
invalidateReference('contacts')
}
else toast.error(data?.error ?? 'Sync failed')
} catch { toast.error('Sync failed') }
finally { setSyncingContacts(false) }
}
return (
<div className="max-w-5xl space-y-6">
<div>
@@ -223,30 +203,6 @@ export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callba
</TabsContent>
<TabsContent value="carddav" className="mt-0 space-y-4">
<CardDavSettings />
</TabsContent>
<TabsContent value="nextcloud" className="mt-0 space-y-4">
<div className="rounded-lg border p-4 space-y-3">
<h3 className="font-medium flex items-center gap-2"><Cloud className="h-4 w-4" /> Contacts sync (Nextcloud)</h3>
<div className="grid grid-cols-2 gap-3">
<div className="col-span-2">
<label className="text-xs font-medium text-muted-foreground">Nextcloud URL</label>
<Input value={ncConfig.nextcloudUrl} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, nextcloudUrl: e.target.value }))} placeholder="https://nextcloud.example.com" />
</div>
<div className="col-span-2">
<label className="text-xs font-medium text-muted-foreground">CardDAV Path (optional)</label>
<Input value={ncConfig.cardDavPath} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, cardDavPath: e.target.value }))} placeholder="/remote.php/dav/addressbooks/users/USER/contacts/" />
</div>
<div>
<label className="text-xs font-medium text-muted-foreground">Username</label>
<Input value={ncConfig.username} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, username: e.target.value }))} />
</div>
<div>
<label className="text-xs font-medium text-muted-foreground">App Password</label>
<Input type="password" value={ncConfig.password} onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNcConfig(p => ({ ...p, password: e.target.value }))} />
</div>
</div>
<Button onClick={syncContacts} loading={syncingContacts}>Sync Contacts Now</Button>
</div>
</TabsContent>
<TabsContent value="imap" className="mt-0 space-y-4">
<div className="rounded-lg border p-4 space-y-3">
+1 -1
View File
@@ -94,7 +94,7 @@ const SECTIONS = [
icon: FolderSync,
title: 'Connections',
body: [
'Settings connects Superbrain to your services: WebDAV shares, CalDAV calendars, CardDAV address books, Nextcloud contacts sync, and IMAP mailboxes. Credentials are stored encrypted and are write-only — the app never shows them back to you.',
'Settings connects Superbrain to your services: a unified Nextcloud connect (files, calendars & contacts), WebDAV shares, CalDAV calendars, CardDAV address books, and IMAP mailboxes. Credentials are stored encrypted and are write-only — the app never shows them back to you.',
'On Core deployments with Nextcloud, the connection forms offer a one-click prefill for your account.',
],
where: 'Settings → Connections',
+2 -2
View File
@@ -167,8 +167,8 @@ export function CardDavSettings() {
<p className="text-sm text-muted-foreground mt-1">
Connect an address book from any CardDAV service. Each book becomes a Collection, one
bookmark per contact, re-checked in the background every 30 minutes. Passwords are
encrypted at rest and never shown again. (This is separate from Contacts sync, which
feeds contact-linking.)
encrypted at rest and never shown again. (This is separate from the Contacts page,
which feeds contact-linking.)
</p>
</div>
{allowed && <Button size="sm" onClick={openCreate}><Plus className="h-4 w-4 mr-1" /> Connect address book</Button>}
+41 -3
View File
@@ -23,12 +23,16 @@ type McpConnection = {
id: string; name: string; url: string; transport: string; authKind: string
headerName: string; secret: string; enabled: boolean; version: number
}
type Suggestion = {
kind: string; name: string; url: string; transport: string; authKind: string
available: boolean; description?: string; secretHint?: string; note?: string; docsUrl?: string
}
type TestResult = { ok: boolean; count?: number; tools?: { name: string; description: string }[]; error?: string }
type FormState = {
id: string | null; version: number
name: string; url: string; transport: string; authKind: string; headerName: string
secret: string; hasStoredSecret: boolean
secret: string; hasStoredSecret: boolean; secretHint?: string
}
const emptyForm: FormState = {
@@ -42,6 +46,7 @@ async function api(path: string, init?: RequestInit): Promise<Response> {
export function McpSettings() {
const [connections, setConnections] = useState<McpConnection[]>([])
const [suggestions, setSuggestions] = useState<Suggestion[]>([])
const [loading, setLoading] = useState(true)
const [form, setForm] = useState<FormState | null>(null)
const [saving, setSaving] = useState(false)
@@ -51,13 +56,22 @@ export function McpSettings() {
const reload = useCallback(() =>
api('/api/mcp/connections')
.then(r => r.json())
.then(data => setConnections(Array.isArray(data?.connections) ? data.connections : []))
.then(data => {
setConnections(Array.isArray(data?.connections) ? data.connections : [])
setSuggestions(Array.isArray(data?.suggestions) ? data.suggestions : [])
})
.catch(() => toast.error('Could not load MCP connections'))
.finally(() => setLoading(false)), [])
useEffect(() => { reload() }, [reload])
const openCreate = () => setForm({ ...emptyForm })
// A suggestion prefills everything except the credential — the user still
// pastes their own token and confirms (write-only discipline unchanged).
const openSuggestion = (s: Suggestion) => setForm({
...emptyForm, name: s.name, url: s.url, transport: s.transport,
authKind: s.authKind, secretHint: s.secretHint,
})
const openEdit = (c: McpConnection) => setForm({
id: c.id, version: c.version, name: c.name, url: c.url, transport: c.transport,
authKind: c.authKind, headerName: c.headerName, secret: '', hasStoredSecret: c.secret === KEY_MASK,
@@ -140,6 +154,30 @@ export function McpSettings() {
<Button size="sm" onClick={openCreate}><Plus className="h-4 w-4 mr-1" /> Add connection</Button>
</div>
{suggestions.length > 0 && (
<div className="space-y-2">
{suggestions.map(s => (
<div key={s.kind} className="flex items-start gap-3 rounded-md border border-dashed p-3">
<PlugZap className="mt-0.5 h-5 w-5 shrink-0 text-muted-foreground" />
<div className="min-w-0 flex-1 space-y-0.5">
<p className="text-sm font-medium flex items-center gap-2">
{s.name}
{!s.available && <Badge variant="outline" className="text-[10px] text-amber-600 dark:text-amber-400">OAuth required</Badge>}
</p>
{s.description && <p className="text-xs text-muted-foreground">{s.description}</p>}
<p className="truncate text-xs text-muted-foreground font-mono">{s.url}</p>
{s.note && <p className="text-xs text-muted-foreground">{s.note}</p>}
</div>
{s.available
? <Button size="sm" variant="outline" className="shrink-0" onClick={() => openSuggestion(s)}>Use</Button>
: s.docsUrl && (
<a href={s.docsUrl} target="_blank" rel="noreferrer" className="shrink-0 text-xs text-muted-foreground underline hover:text-foreground">Docs</a>
)}
</div>
))}
</div>
)}
{connections.length === 0 ? (
<p className="text-sm text-muted-foreground">No MCP connections yet.</p>
) : (
@@ -231,7 +269,7 @@ export function McpSettings() {
type="password"
value={form.secret}
onChange={e => setForm({ ...form, secret: e.target.value })}
placeholder={form.hasStoredSecret ? `${KEY_MASK} (leave blank to keep)` : 'Paste the credential'}
placeholder={form.hasStoredSecret ? `${KEY_MASK} (leave blank to keep)` : (form.secretHint || 'Paste the credential')}
maxLength={2000}
/>
{form.hasStoredSecret && <p className="mt-1 text-xs text-muted-foreground">Stored credentials are never shown; blank keeps the current one.</p>}