937b825daa49f7717644ff7e725ec847aa21aef8
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a8bd0ab876 |
CalDAV calendars: each server calendar a Collection, each event a URL bookmark
Settings -> CalDAV connects an external CalDAV endpoint (any RFC 4791
service; on Core the deployment's NEXTCLOUD_URL adds a Nextcloud-calendars
one-click prefill alongside the existing files one). Each server calendar
materializes as its own Collection and every in-window event becomes a
Bookmark carrying the event's DAV .ics URL.
internal/caldav mirrors internal/webdav:
- client.go — PROPFIND discovery (accepts a calendar home via
calendar-home-set or a single calendar), REPORT calendar-query over a
rolling window (last 30d .. next 180d), netguard-pinned 80/443, Basic
auth in the header only, redirects refused, bounded (50 calendars /
500 events);
- ics.go — RFC 5545 unfolding + first-VEVENT parse (UID/SUMMARY/DTSTART);
- sync.go — RunLoop/RunOnce under a dedicated advisory lease, reconciling
each calendar to a Collection and each event to a bookmark via the
CalDavEvent ledger. Same tombstone/detach discipline as WebDAV: a
vanished OR out-of-window event detaches membership but keeps the
bookmark; a user-deleted event never resurrects; a re-deleted collection
is recreated and re-linked; a truncated window never reconciles
deletions; one unreadable calendar does not abort the rest.
Three tables (CalDavConnection/CalDavCalendar/CalDavEvent) via migration 021
+ schema.sql. Handlers expose /api/caldav/connections CRUD + /test + /sync
with the house credential (encrypted, masked, write-only), version (409 on
stale), and AllowConnector("caldav") plan gate on creation AND every sync.
Wired as the fifth background loop in main.go.
Settings -> CalDAV tab (web/components/caldav-settings.tsx): masked
write-only password, version on PATCH, per-row calendar list, verbatim
test/sync results, Core suggestion prefill with the viewer's email
local-part, allowed flag drives the plan notice.
Verification: full Go integration suite green incl. four TestCalDav*
(lifecycle, collection-recreation, plan gate + suggestion) on an httptest
fake CalDAV server; make db-converge passes; browser regressions all 18
PASS incl. the new CalDAV settings walkthrough; web lint/SSR-lint/build
clean. API.md, README, .env.example, Core installer and local AGENTS
documents updated.
|
||
|
|
564bdc87b6 |
WebDAV file shares: connect any RFC 4918 service as a Collection of per-file bookmark URLs
Settings -> WebDAV: a user connects an external WebDAV share (any service; on Core the deployment's NEXTCLOUD_URL offers Nextcloud as a one-click prefill - DATA, never a TIER code fork). The share materializes as a Collection and every file becomes a Bookmark carrying the file's DAV URL, reconciled by the WebDavItem path ledger (migration 020 + schema.sql, db-converge proven): - idempotent syncs; etag changes refresh the ledger only, never user-edited title/notes/tags; same-URL bookmarks are reused (URL-identity invariant); - vanished files detach membership but keep the bookmark (sync never destroys user data); a user-deleted bookmark is a tombstone that is never resurrected; a user-removed membership stays removed - unless the whole collection was deleted, when the next sync re-links every live row; - bounded walks (200 dirs / 1000 files / depth 12) and a truncated listing never reconciles deletions; - netguard-pinned dials (80/443, no trusted exemption for user hosts), Basic auth in a header only, redirects refused outright; - the webdav connector entitlement gates creation AND every sync; a downgrade suppresses instead of deleting; - engine tick per notify/agent discipline (jitter, advisory lease, budget, log-not-fatal); /test proves PROPFIND, /sync reconciles on demand; passwords write-only + masked, PATCH carries version (409 on stale), cap 10 per user. internal/webdav (client+engine), handlers/webdav.go + routes, main.go 4th loop, config.NextcloudSuggestion, Settings tab + webdav-settings.tsx, API.md contract section, env docs, Core installer writes NEXTCLOUD_URL. Client unit tests on an httptest fake DAV server; four integration tests cover lifecycle, recreation, plan gate and suggestion; regressions drive the Settings UI end-to-end (masked rows, prefill, connect/sync/test, no secret echo). All suites green. |
||
|
|
9cfd6efa38 |
Outbound MCP connections: Notion-style client integrations (Settings -> MCP)
Superbrain dials external MCP servers as a client (official modelcontextprotocol/go-sdk): Streamable HTTP or SSE, none/bearer/header auth. Management surface /api/mcp/connections (CRUD + test) with the house disciplines: - secrets encrypted at rest (internal/crypto), masked in every response, write-only (mask or omission keeps the stored value); authKind none clears them - mutating PATCH carries version (409 on stale); mask-only PATCH is a documented no-op returning the current projection - dials netguard-pinned (public ranges, ports 80/443 outside tests), no redirect following, header names restricted to RFC 7230 tokens - test endpoint: per-user limiter + shared outbound budget; 502 with an error class on dial/auth failure, never a silent ok; returns the tool list for the UI - cap of 10 connections per user under the user lock UI: Settings -> MCP tab (components/mcp-settings.tsx) — list with enable switch, add/edit dialog (secret never prefilled), Test showing the live tool list or the server's error verbatim. Migration 018 + schema.sql; integration test drives a go-sdk fake MCP server (incl. a Bearer-secured one) end to end. Tool USE by the assistant is phase 2. |
||
|
|
e6ab778bd5 |
Add personal API keys, superbrain-mcp, and fix Markdown prose styling
API keys & MCP (the mcpserver-link prerequisite from STRATEGY.md): - ApiKey table (migration 017 + schema.sql): hash-only storage of personal "sb_..." Bearer credentials, unique keyHash, owner cascade. - internal/auth/apikeys.go + AuthMiddleware fork: keys resolve before the assertion/cookie channels; gated on the mcp-core connector at issuance AND at every use (downgrade 403s); independent of tokenVersion so "sign out everywhere" never breaks a gateway link; view-as stays browser-only. - /api/keys GET/POST/DELETE: plaintext shown exactly once, 10-key cap under the user lock, owner-scoped revocation; Settings -> API Keys tab. - mcp/: superbrain-mcp, a pip-installable stdio MCP server (listmonk-mcp pattern) with bookmarks/tags/pages tools, version-safe updates; the federated gateway spawns it via config_mcpserver_superbrain() in deploy/federated/lib-superbrain.sh (mints the gateway key in-db, points it at http://superbrain-app:8080). STRATEGY.md records the remaining suite-side registry work. - Tests: TestAPIKeys (plan gate, cap, revocation, tokenVersion semantics, downgrade-at-use); full DB-backed suite, db-converge, live MCP-client smoke all pass. Markdown (Gitea issue #3): add @tailwindcss/typography and enable it in tailwind.config.ts. The prose wrapper was a no-op without it, so Tailwind Preflight flattened headings/blockquotes to body text while bold/italic survived - exactly the reported symptom. Verified in the built CSS. Gitea: #2 and #3 closed with reference notes; #1 stays open pending the Superpanel core-AI walkthrough. |
||
|
|
167f74c6b4 |
Separate AI config from implementation: BYO provider, model and key per user
release gate / check (push) Failing after 6m42s
The plan matrix's 'use your own AI' rows, made real. internal/ai is now pure implementation: three provider adapters — openai-compatible (OpenRouter, OpenAI, Grok, Groq, Ollama, any house gateway), native Anthropic (/v1/messages, x-api-key) and native Gemini (generateContent; the key travels in the x-goog-api-key HEADER, never the URL, because Go's HTTP error strings include URLs and errors get logged). One netguard-dialed client, per-source outbound budgets (ai:user:<id> vs ai:server). Configuration is data: UserAiConfig (migration 015) — one row per user with provider, base URL, model and an API key encrypted at rest via internal/crypto (the IMAP-password format), masked in every response; a PUT echoing the mask or leaving the key blank keeps the stored value; version contract on updates. New endpoints: GET/PUT/DELETE /api/ai/config, POST /api/ai/test (one probe completion through the resolved config), GET /api/ai/status (plan-gated availability, no secrets). Resolution chain (ai.ResolveForUser): the user's enabled BYO config first on EVERY plan; else the server env key (AI_API_KEY/AI_MODEL/AI_BASE_URL/ AI_PROVIDER) only when the tenant's plan may spend it — new entitlements.AllowServerAI: premium (credits), core (house gateway) and selfhosted (operator IS the user); free/standard are BYO-only, exactly the matrix. No AI available => 428 with a pointer to Settings -> AI (was a global 503): the precondition is per-user now. Agent compile and url_watch extraction resolve per owner, so different users' tasks can run on different providers. Web: Settings -> AI tab (provider picker with per-provider defaults and model hints, write-only key input, Test button, effective-source badge with plan context, enable switch, remove). The Automations tab reads /api/ai/status for a proactive banner and treats 428 as 'not configured'. Preparatory refactors (behavior-preserving): agent.AutomationSchema extracted as the single spec text shared by the compiler prompt (and the upcoming chat assistant), and ai.CompleteMessages for multi-turn conversations with per-provider role mapping (assistant -> model on Gemini). Tests: all three adapters against one loopback fake (asserting each provider's auth-header shape), masked-key lifecycle incl. mask-echo preservation across a provider switch, encrypted-at-rest verification, plan gate both directions (free refuses the server key, premium/core/ selfhosted allow it), BYO precedence over the server key, validation rejects, 428 paths, and compile resolution through a BYO config. Full suite green (-race), converge green (015), web lint/SSR/build clean. Docs: API.md AI section, RUNNING.md setup rewritten around BYO-first + plan-gated server fallback, .env.example (AI_PROVIDER + the precedence story), compose passthrough, AGENTS.md invariant (config vs implementation, Gemini key-in-header rule). |
||
|
|
2037a04817 |
Add agent automations: 'hey superbrain' NL-compiled watch-and-act tasks
release gate / check (push) Failing after 6m37s
The first real-agent slice (PLAN_PRICING_TIERS step 5, partial): describe
an automation in plain language — 'when the round trip on <url> drops
below $400, email david@…' — and Superbrain compiles it into a task the
user reviews and confirms before anything is stored.
Trust model (the point of the whole design): the LLM only ever PROPOSES.
Compile output and hand-built specs pass the same server-side
agent.ValidateSpec on every write AND on every engine load (a spec that
stops validating is paused, never executed). Actions are a closed set —
notify an owned channel, email one recipient, save one bookmark — with no
destructive or cross-user capability. Fetched page content is untrusted:
delimited in the extraction prompt, schema-checked reply ({found,value,
text,summary}), and no action can be chosen or retargeted by page text.
Multi-step requests (flights AND hotels bundled) are explicitly refused by
the compiler until chaining exists.
internal/ai: OpenAI-compatible gateway (OpenRouter default via AI_API_KEY/
AI_MODEL/AI_BASE_URL; any compatible endpoint works — house Core gateway or
Ollama later). Netguard-dialed, outbound-budgeted, balanced-brace JSON
extraction, provider bodies never echoed wholesale (they can reflect keys).
internal/agent: url_watch (scheduled fetch + one extracted fact + numeric/
text comparison) and signal (new mailbox signals, keyword filter)
conditions; poll floor 15min, once-semantics, per-task email cap 5,
per-owner daily email cap 20, global advisory tick lease, bounded run
history (pruned tail + age horizon). Engine loop joins signals/notify in
main's shutdown contract.
Schema: AgentTask + AgentRun (migration 014, converge-verified).
Entitlements: AITasks cap per plan (free 2 / standard 10 / premium 50 /
core+selfhosted unlimited) + ai_tasks override key — stored-task count is
plan data, never TIER checks.
API: /api/agent/compile (rate-limited, 422 surfaces the model's refusal,
503 when AI unconfigured), task CRUD with the version contract, manual
/run, bounded /runs history. Web: Settings -> Automations with the
composer, human-readable proposal + raw-spec review, channel picker for
notify actions, task list with Run now, and the runs strip (SafeTime for
hydration-safe timestamps).
Tests: loopback fake OpenAI-compatible server + watch target + the SMTP
fake — compile success/refusal/invalid-spec, create-time validation
(javascript: URLs rejected), version contract, url_watch fire with
once-completion, signal fire + no-refire without new signals, plan cap via
ai_tasks override, 503 without a key. Full suite green (-race); converge
green; web lint/SSR-eslint/build clean.
Docs: API.md agent section, RUNNING.md, .env.example (key stays in .env
only), compose passthrough.
|
||
|
|
451312c3cf |
Add notification engine phase 1: channels, rules, plan-gated delivery
release gate / check (push) Failing after 6m54s
When something happens in the brain, tell the user (PLAN_PRICING_TIERS step 3). The engine is a SCANNER, not a hook system: producers are never instrumented; exactly-once comes solely from UNIQUE(ruleId,dedupeKey) + ON CONFLICT DO NOTHING, so rescans are free and restarts are safe. Schema (migration 013 + schema.sql, converge-verified): NotificationChannel (secrets encrypted at rest via internal/crypto, the IMAP-password format), NotificationRule (one channel per rule in phase 1, cooldown, version column), Notification (dedupe ledger + delivery state: pending/sent/failed/suppressed, attempts, backoff timestamp). internal/notify: two triggers — signal_created (fires only for signals newer than the rule, never retro-notifying history) and bookmark_due (lead-hours window, dedupe key carries the UTC due date so moving a dueDate re-notifies and same-day rescans do not). Delivery claims rows in one short transaction (FOR UPDATE SKIP LOCKED, batch 10) so multiple app instances never double-send; exponential backoff to 5 attempts; per-rule cooldown; per-owner pending cap. Channels: email (internal/mailer, falls back to the account email), Slack webhook, Matrix room, Telegram bot — webhooks dial through netguard inside outbound.Reserve budgets. The plan gate re-checks at delivery: a downgraded tenant's rows become 'suppressed' instead of sending. Signal-app delivery deliberately absent (needs a daemon; see plan doc hard truths). API: channel/rule CRUD with the house version contract (409 on stale base), write-only secrets (masked in every response; a PATCH echoing the mask keeps the stored value), test-send endpoint with its own budget, owner-scoped delivery history. Channel kinds gate on the ENTITLEMENT CATALOG (403 'Not available on your plan') — never on TIER, per the tenancy invariant. Web: Settings -> Notifications tab (channels with per-kind forms and Test button, rule builder, recent-delivery strip). Data loading uses the house promise-chain shape; setState only in async callbacks (SSR lint). Fixes along the way: mailer send budget raised 5->20/min (shared by resets and notifications; 5/min would throttle a hosted instance) and outbound gains ResetBudget() wired into the test harness — the global 'smtp' window made password-reset and notification tests collide when the package ran as a whole. Tests: full channel/rule/engine integration pass (masking + encryption round-trip, masked-PATCH preservation, version contract, plan gating via a forced 'free' tenant, dedupe across rescans, cooldown, real SMTP and webhook delivery via loopback fakes, backoff recording, downgrade suppression, history). Full suite green with -race; web lint/SSR-eslint/ build clean. Docs: API.md endpoint table, RUNNING.md, AGENTS.md invariants, DESIGN_NOTIFICATIONS.md (local). |
||
|
|
c432ff57e9 |
Add Authelia identity bridge for NextAuth sessions
release gate / check (push) Failing after 6m40s
Keep NextAuth as the OIDC/session layer and add a trusted Go provisioning endpoint that maps verified Authelia subjects to local users. Existing password accounts require explicit admin linking; new users are provisioned without a password. Enable the Authelia login path and update docs. Also fix test schema search_path so pg_trgm opclasses resolve. |
||
|
|
b9721ff13f |
initial commit on Federted servers
release gate / check (push) Failing after 8m35s
|