Skip to content

Named AI provider connections, plus nginx and updater fixes - #141

Merged
jhd3197 merged 6 commits into
mainfrom
dev
Sep 8, 2026
Merged

Named AI provider connections, plus nginx and updater fixes#141
jhd3197 merged 6 commits into
mainfrom
dev

Conversation

@jhd3197

@jhd3197 jhd3197 commented Sep 8, 2026

Copy link
Copy Markdown
Owner

The AI assistant now supports named provider connections with encrypted credentials and a panel default. New chats choose a connection and model; existing conversations retain their original selection. This promotion releases ServerKit 1.10.0.

Changes

  • Discover installed Prompture chat providers and configure native providers or gateways such as OmniRoute, Prompture Hub, and LM Studio. Preserve exact model IDs and routing aliases.
  • Discover models and test connections through bounded real requests. Use Prompture 1.11 native gateway streaming and tool calls.
  • Keep credentials isolated from ambient process configuration. Clear retained credentials when endpoints change, and reject destination changes for connections already used by chats.
  • Migrate existing provider settings into encrypted saved connections and attach compatible historical conversations.
  • Allow authenticated JWT and API-key clients to list connection IDs, names, providers, and models without configuration or secrets. Connection mutations remain admin-only; existing JWT-only routes retain their policy.
  • Keep connection persistence in the service layer and render typed errors through the global handler. Parse decrypted configuration through the shared JSON accessor and fail closed on corrupt or non-object configuration.
  • Serve runtime-extension vendor .mjs shims with a JavaScript MIME type in all shipped nginx vhosts, without intercepting plugin API assets.
  • Exclude SQLite files from updater tree snapshots so the dedicated database backup is not duplicated.
  • Set VERSION to 1.10.0, update the changelog, and regenerate the API surface, controller-boundary baseline, and migration inventory without raising any test ceilings.

Validation

  • 70 targeted backend tests passed locally, covering AI connections and SDK wire behavior, credential isolation, corrupt configuration, API-key access and role enforcement, typed errors, inventories, authorization checks, nginx MIME configuration, and panel version resolution.
  • Full GitHub CI runs on the final PR head gate the merge. The release workflow rechecks backend, frontend, and extensions before building and publishing artifacts.

The backend dependency is pinned to prompture[openai,anthropic]==1.11.0; upgrades must install the updated requirements and run migration 098_ai_provider_connections.

jhd3197 and others added 4 commits September 8, 2026 00:25
Stock nginx (1.18-1.24 on Debian/Ubuntu) has no `.mjs` entry in mime.types,
so the runtime-extension vendor shims the import map points at came back as
application/octet-stream. Browsers refuse to execute an ES module with that
type, so every runtime-loaded extension (WordPress, Git, Mail, Fail2ban, ...)
failed on fresh installs with "Failed to fetch dynamically imported module:
blob:..." (Chrome) or "'application/octet-stream' is not a valid JavaScript
MIME type" (Safari).

Add a location block to the shipped vhosts (and the container frontend
config) that forces text/javascript for /serverkit-vendor/*.mjs. The regex is
anchored to that folder: a bare `\.mjs$` would also capture the
/api/v1/plugins/<slug>/assets/dist/index.mjs route and 404 every bundle.
update.sh already re-copies these vhosts, so existing installs pick it up on
their next update.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NWc84WDsWR7M55Mn7qtpie
…endor shim MIME

The tree backup rsync copied backend/instance/serverkit.db even though the
same database had just been written as the pre-upgrade copy, and rollback
only ever restores from that copy. On a 450 MB database that made every
update cost ~900 MB of backups, which is how small VPSes kept filling up.
Exclude the SQLite files from the tree snapshot. Retention is unchanged
(SERVERKIT_BACKUP_RETENTION, default 3, plus the 15% disk budget).

Add a test that every shipped nginx vhost forces a JavaScript MIME type for
/serverkit-vendor/*.mjs and that the regex cannot capture the
/api/v1/plugins/<slug>/assets/... route.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NWc84WDsWR7M55Mn7qtpie
Copilot AI lite review requested due to automatic review settings September 8, 2026 05:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are a couple of confirmed issues in the updated code (UI state handling and an inaccurate updater comment) that should be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR upgrades the AI assistant configuration model from a single global provider/key to named, encrypted provider connections with per-chat affinity, and includes operational fixes for nginx .mjs MIME handling and update backup size.

Changes:

  • Add backend connection catalog/save/probe plumbing (Prompture descriptor–driven) plus DB migration to pin conversations to a connection and widen model IDs.
  • Update frontend settings + chat drawer to manage/select connections and models, and adjust i18n to the new ai.connections namespace.
  • Fix shipped nginx vhosts to serve /serverkit-vendor/*.mjs as JavaScript and reduce updater backup footprint by excluding SQLite DB files from rsync tree snapshots.
File summaries
File Description
scripts/update.sh Exclude SQLite DB files from rsync install-tree snapshot to avoid double backup size.
ROADMAP.md Document implemented “Prompture Provider Connections” feature and scope notes.
nginx/sites-available/serverkit.conf Force correct JS MIME for /serverkit-vendor/*.mjs shims.
nginx/sites-available/serverkit-insecure.conf Force correct JS MIME for /serverkit-vendor/*.mjs shims.
frontend/src/styles/components/_ai-assistant.scss Add styling for the in-chat connection/model selector row.
frontend/src/services/api/ai.js Add API methods for connection CRUD and probe endpoints.
frontend/src/i18n/locales/ar.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/bn.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/de.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/en.json Add ai.connections.* strings and remove old AI settings strings no longer used.
frontend/src/i18n/locales/es.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/fr.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/id.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/it.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/ko.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/pl.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/pt.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/ru.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/th.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/tr.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/vi.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/zh-Hans.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/i18n/locales/zh-Hant.json Remove obsolete AI settings keys; rely on new namespace fallbacks.
frontend/src/contexts/AIContext.jsx Track available connections + selected connection/model and send on first message.
frontend/src/components/settings/AISettingsTab.jsx Replace legacy provider/key UI with the new AIConnectionsSettings panel.
frontend/src/components/settings/AIConnectionsSettings.jsx New connection editor UI with provider-driven fields + discover/test/save flows.
frontend/src/components/ai/ConnectionSelector.jsx New pre-chat selector to choose connection and optionally override model.
frontend/src/components/ai/ChatDrawer.jsx Render the new connection selector before chat start.
frontend/nginx.conf Force correct JS MIME for /serverkit-vendor/*.mjs shims (frontend container vhost).
docs/AI_PROVIDERS.md New documentation for configuring providers/gateways and connection semantics.
CHANGELOG.md Note nginx .mjs MIME fix for runtime-loaded extensions.
backend/tests/test_vendor_shim_mime.py New tests asserting vhosts include correct .mjs location block and regex scope.
backend/tests/test_ai_connections.py New tests for connection behavior, probes, migration, and driver boundary rules.
backend/requirements.txt Pin Prompture + include OpenAI/Anthropic extras for supported drivers.
backend/migrations/versions/098_ai_provider_connections.py New migration adding connection table, FK, indexes, and model_name widening + legacy import.
backend/app/services/ai_service.py Route provider/model selection through saved connections and inject configured driver on resume.
backend/app/services/ai_connections.py New service for provider catalog, draft validation, secret handling, driver build, and probe requests.
backend/app/models/ai.py Add AiProviderConnection model; add conversation connection_id and widen model_name.
backend/app/api/ai.py Add connection CRUD/probe endpoints and plumb connection/model into conversation creation/chat routes.
Review details
  • Files reviewed: 39/39 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread frontend/src/components/settings/AIConnectionsSettings.jsx
Comment thread scripts/update.sh
Keep connection persistence behind the service boundary, use typed errors and shared JSON parsing, and refresh reviewed inventories. The new GET connection catalog accepts API keys so API clients managing connections can discover IDs without exposing credentials; existing JWT-only routes stay unchanged. Add regression coverage and release notes.
@jhd3197
jhd3197 merged commit b962614 into main Sep 8, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants