BYO AI settings: custom instructions, model picker, key show/hide
release gate / check (push) Failing after 6m26s
release / smoke (push) Successful in 10m16s
release / publish (push) Failing after 9m57s

Mirrors the BYOK dialog suggested in issue #2:
- UserAiConfig gains an optional instructions column (schema.sql +
  migration 016); PUT validates (<=4000 chars) and full-replaces it.
- Instructions ride along on the assistant chat system prompt only
  (chatSystemWith); the automation compiler and page-extraction prompts
  stay server-owned contracts.
- Settings -> AI: labeled fields, per-provider suggested-model dropdown
  with a custom-model escape hatch, API key show/hide toggle, and the
  instructions textarea.
- Tests: projection echo, omission clears, cap validation, and the
  system-prompt assertion via a recorded fake provider body.
This commit is contained in:
Andrew S Erwin
2026-10-31 19:09:44 -05:00
parent 1dfd41986c
commit 09f8a5d933
10 changed files with 272 additions and 81 deletions
+4 -1
View File
@@ -453,13 +453,16 @@ CREATE INDEX "AgentRun_taskId_createdAt_idx" ON "AgentRun"("taskId", "createdAt"
-- internal/crypto (same versioned format as IMAP passwords and
-- notification channel secrets) and masked in every API response. The
-- server-wide env key (AI_API_KEY) is the fallback and is plan-gated by
-- entitlements.AllowServerAI.
-- entitlements.AllowServerAI. "instructions" holds the user's optional
-- custom system instructions for the in-app assistant; server-owned
-- prompts (automation compiler, page extraction) never include them.
CREATE TABLE "UserAiConfig" (
id text PRIMARY KEY,
"ownerId" text NOT NULL UNIQUE REFERENCES "User"(id) ON DELETE CASCADE,
provider text NOT NULL CHECK (provider IN ('openai-compatible','anthropic','gemini')),
"baseUrl" text NOT NULL DEFAULT '',
model text NOT NULL,
instructions text NOT NULL DEFAULT '',
"apiKey" text NOT NULL,
enabled boolean NOT NULL DEFAULT true,
version integer NOT NULL DEFAULT 1,