Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(ai): satisfy release gates and prepare 1.10.0 [skip version]

Juan Denisfde0acee6d33
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a709861a..829212e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,9 +18,17 @@ Earlier development history remains in
The [agent](https://github.com/jhd3197/serverkit-agent/releases) has its own
release history; historical `agent-v*` tags are not panel releases.
-## [Unreleased]
+## [1.10.0] - 2026-09-08
-Changes after 1.9.28 on the development branch.
+### Added
+
+- Save named AI provider connections with encrypted credentials, a default
+ connection, and a connection/model selector for new chats. Existing chats
+ retain their original connection and model.
+- Discover Prompture providers and gateway models, including OmniRoute,
+ Prompture Hub and LM Studio, and test connections with a real chat request.
+- Use Prompture 1.11 native gateway streaming and tool calls while preserving
+ exact model IDs and routing aliases.
### Fixed
@@ -29,6 +37,15 @@ Changes after 1.9.28 on the development branch.
MIME entry and returned `application/octet-stream`, so every runtime-loaded
extension (WordPress, Git, Mail, Fail2ban, ...) failed with "Failed to fetch
dynamically imported module: blob:..." on fresh installs.
+- Exclude SQLite database files from the updater's install-tree snapshot so
+ the dedicated database backup does not duplicate them.
+
+[Source changes since 1.9.29](https://github.com/jhd3197/ServerKit/compare/v1.9.29...v1.10.0).
+
+## [1.9.29] - 2026-09-08
+
+### Fixed
+
- Evaluate fleet alert thresholds every minute and send opened/resolved alerts
to administrators through the notification bus.
- Preserve memory, disk and network measurements from agent heartbeats through
@@ -50,7 +67,7 @@ Changes after 1.9.28 on the development branch.
- Close the container inspector when opening Logs or Exec so it can no longer
cover those surfaces (PR #137).
-[Source changes since 1.9.28](https://github.com/jhd3197/ServerKit/compare/v1.9.28...dev).
+[Source changes since 1.9.28](https://github.com/jhd3197/ServerKit/compare/v1.9.28...v1.9.29).
## [1.9.28] - 2026-09-05
@@ -913,7 +930,8 @@ require their matching extensions. Review the installed extensions after updatin
- Established the earliest published panel release covered by this backfill, with the Flask/React control panel, application and database management, Docker operations, backups and server monitoring.
- Moved the agent into the separate serverkit-agent repository and introduced a dedicated panel release workflow.
-[Unreleased]: https://github.com/jhd3197/ServerKit/compare/v1.9.28...dev
+[1.10.0]: https://github.com/jhd3197/ServerKit/releases/tag/v1.10.0
+[1.9.29]: https://github.com/jhd3197/ServerKit/releases/tag/v1.9.29
[1.9.28]: https://github.com/jhd3197/ServerKit/releases/tag/v1.9.28
[1.9.25]: https://github.com/jhd3197/ServerKit/releases/tag/v1.9.25
[1.9.24]: https://github.com/jhd3197/ServerKit/releases/tag/v1.9.24
diff --git a/VERSION b/VERSION
index 5620bb83..81c871de 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.9.29
+1.10.0
diff --git a/backend/app/api/ai.py b/backend/app/api/ai.py
index 7b730ec0..a8ccddaf 100644
--- a/backend/app/api/ai.py
+++ b/backend/app/api/ai.py
@@ -32,7 +32,7 @@ from flask_jwt_extended import get_jwt, jwt_required
from werkzeug.exceptions import RequestEntityTooLarge, TooManyRequests
from app import db
-from app.middleware.rbac import admin_required, get_current_user
+from app.middleware.rbac import admin_required, auth_required, get_current_user
from app.models.ai import AiConversation, AiMessage, AiPendingAction
from app.services import ai_service
from app.services import ai_connections
@@ -168,8 +168,7 @@ def get_settings():
'injection_detection': bool(SettingsService.get('ai_injection_detection', True)),
# Never return the key itself — only whether one is configured.
'api_key_set': bool(SettingsService.get('ai_api_key_encrypted', '')),
- 'connections': [ai_connections.public_connection(r, details=True)
- for r in ai_connections.AiProviderConnection.query.order_by(ai_connections.AiProviderConnection.name).all()],
+ 'connections': ai_connections.list_connections(details=True),
'default_connection_id': ai_connections.default_id(),
})
@@ -240,11 +239,10 @@ def providers():
@ai_bp.route('/connections', methods=['GET'])
-@jwt_required()
+@auth_required()
def connections():
# The chat selector needs names/models only, never configuration or keys.
- rows = ai_connections.AiProviderConnection.query.order_by(ai_connections.AiProviderConnection.name).all()
- return jsonify({'connections': [ai_connections.public_connection(r) for r in rows],
+ return jsonify({'connections': ai_connections.list_connections(),
'default_connection_id': ai_connections.default_id()})
@@ -255,32 +253,24 @@ def add_connection():
row = ai_connections.save(request.get_json(silent=True))
return jsonify(ai_connections.public_connection(row, details=True)), 201
except ValueError as exc:
- return jsonify({'error': str(exc)}), 400
+ raise ValidationError(str(exc)) from exc
@ai_bp.route('/connections/<connection_id>', methods=['PUT'])
@admin_required
def update_connection(connection_id):
- row = db.session.get(ai_connections.AiProviderConnection, connection_id)
- if row is None:
- return jsonify({'error': 'Connection not found'}), 404
+ row = ai_connections.require_connection(connection_id)
try:
row = ai_connections.save(request.get_json(silent=True), row)
return jsonify(ai_connections.public_connection(row, details=True))
except ValueError as exc:
- return jsonify({'error': str(exc)}), 400
+ raise ValidationError(str(exc)) from exc
@ai_bp.route('/connections/<connection_id>', methods=['DELETE'])
@admin_required
def delete_connection(connection_id):
- row = db.session.get(ai_connections.AiProviderConnection, connection_id)
- if row is None:
- return jsonify({'error': 'Connection not found'}), 404
- if row.conversations or ai_connections.default_id() == row.id:
- return jsonify({'error': 'Choose another default and delete conversations using this connection before removing it.'}), 409
- db.session.delete(row)
- db.session.commit()
+ ai_connections.delete_connection(connection_id)
return jsonify({'ok': True})
@@ -289,18 +279,16 @@ def delete_connection(connection_id):
def probe_connection():
data = request.get_json(silent=True)
if not isinstance(data, dict):
- return jsonify({'error': 'Connection must be an object.'}), 400
+ raise ValidationError('Connection must be an object.')
existing = None
if data.get('id'):
if not isinstance(data['id'], str) or len(data['id']) > 64:
- return jsonify({'error': 'Invalid connection ID'}), 400
- existing = db.session.get(ai_connections.AiProviderConnection, data['id'])
- if existing is None:
- return jsonify({'error': 'Connection not found'}), 404
+ raise ValidationError('Invalid connection ID')
+ existing = ai_connections.require_connection(data['id'])
try:
return jsonify(ai_connections.probe(data, existing, test=data.get('test') is True))
except ValueError as exc:
- return jsonify({'error': str(exc)}), 400
+ raise ValidationError(str(exc)) from exc
@ai_bp.route('/models', methods=['GET'])
diff --git a/backend/app/models/ai.py b/backend/app/models/ai.py
index cfc7d957..7bf8d72d 100644
--- a/backend/app/models/ai.py
+++ b/backend/app/models/ai.py
@@ -82,7 +82,7 @@ class AiConversation(JsonColumnMixin, TimestampMixin, db.Model):
return data
-class AiProviderConnection(TimestampMixin, db.Model):
+class AiProviderConnection(JsonColumnMixin, TimestampMixin, db.Model):
"""Admin-managed AI connection. All driver configuration is encrypted."""
__tablename__ = 'ai_provider_connections'
@@ -95,8 +95,15 @@ class AiProviderConnection(TimestampMixin, db.Model):
@property
def config(self):
+ config = self._json_read('_decrypted_config_json', None, expect=dict)
+ if config is None:
+ raise ValueError('Invalid saved AI connection configuration.')
+ return config
+
+ @property
+ def _decrypted_config_json(self):
from app.utils.crypto import decrypt_secret
- return json.loads(decrypt_secret(self.config_encrypted))
+ return decrypt_secret(self.config_encrypted)
@config.setter
def config(self, value):
diff --git a/backend/app/services/ai_connections.py b/backend/app/services/ai_connections.py
index bb61c9b8..ee7cb13d 100644
--- a/backend/app/services/ai_connections.py
+++ b/backend/app/services/ai_connections.py
@@ -9,6 +9,7 @@ import os
from urllib.parse import urlsplit
from app import db
+from app.exceptions import ConflictError, NotFoundError
from app.models.ai import AiProviderConnection
from app.models.system_settings import SystemSettings
@@ -104,6 +105,26 @@ def default_id():
return SystemSettings.get('ai_default_connection_id', '') or ''
+def list_connections(*, details=False):
+ rows = AiProviderConnection.query.order_by(AiProviderConnection.name).all()
+ return [public_connection(row, details=details) for row in rows]
+
+
+def require_connection(connection_id):
+ row = db.session.get(AiProviderConnection, connection_id)
+ if row is None:
+ raise NotFoundError('Connection not found')
+ return row
+
+
+def delete_connection(connection_id):
+ row = require_connection(connection_id)
+ if row.conversations or default_id() == row.id:
+ raise ConflictError('Choose another default and delete conversations using this connection before removing it.')
+ db.session.delete(row)
+ db.session.commit()
+
+
def get_connection(connection_id=None):
selected = connection_id if connection_id is not None else default_id()
row = db.session.get(AiProviderConnection, selected) if selected else None
diff --git a/backend/tests/api_controller_boundary_baseline.json b/backend/tests/api_controller_boundary_baseline.json
index 2ea63144..ef5e6bca 100644
--- a/backend/tests/api_controller_boundary_baseline.json
+++ b/backend/tests/api_controller_boundary_baseline.json
@@ -3,7 +3,7 @@
"policy": "Exact reviewed inventory of direct persistence, subprocess, and filesystem mutation calls in Flask API controllers. New calls are forbidden; remove entries as controllers delegate to services.",
"counts": {
"filesystem": 8,
- "persistence": 488
+ "persistence": 487
},
"owners": {
"api/admin.py": {
@@ -245,7 +245,6 @@
"api/ai.py::chat_confirm::persistence::db.session.get(AiPendingAction, token)::1",
"api/ai.py::chat_stream.producer::persistence::db.session.get(AiConversation, conversation_id)::1",
"api/ai.py::chat_stream.producer::persistence::db.session.get(AiConversation, conversation_id)::2",
- "api/ai.py::create_conversation::persistence::db.session.add(row)::1",
"api/ai.py::create_conversation::persistence::db.session.commit()::1",
"api/ai.py::delete_conversation::persistence::db.session.commit()::1",
"api/ai.py::delete_conversation::persistence::db.session.delete(row)::1",
diff --git a/backend/tests/test_ai_connections.py b/backend/tests/test_ai_connections.py
index b059658f..d400b651 100644
--- a/backend/tests/test_ai_connections.py
+++ b/backend/tests/test_ai_connections.py
@@ -17,6 +17,45 @@ def draft(**overrides):
'config': {'endpoint': 'http://gateway.local:20128/v1', 'api_key': 'private-test-key'}, **overrides}
[email protected]('raw', ['', '{broken', '[]', 'null'])
+def test_corrupt_saved_config_fails_closed(app, raw):
+ from app.utils.crypto import encrypt_secret
+ with app.app_context():
+ row = AiProviderConnection(config_encrypted=encrypt_secret(raw))
+ with pytest.raises(ValueError, match='Invalid saved AI connection'):
+ _ = row.config
+
+
+def test_connection_errors_use_shared_contract(client, auth_headers):
+ for method in ('put', 'delete'):
+ response = getattr(client, method)('/api/v1/ai/connections/missing',
+ json={}, headers=auth_headers)
+ assert response.status_code == 404
+ assert response.get_json()['code'] == 'not_found'
+ response = client.post('/api/v1/ai/connections', json={}, headers=auth_headers)
+ assert response.status_code == 400
+ assert response.get_json()['code'] == 'validation_error'
+
+
+def test_connection_catalog_supports_api_key_clients_without_secrets(app, client, auth_headers):
+ from app.models import User
+ from app.services.api_key_service import ApiKeyService
+ created = client.post('/api/v1/ai/connections', json=draft(), headers=auth_headers)
+ assert created.status_code == 201
+ with app.app_context():
+ viewer = User(username='connection_viewer', email='[email protected]',
+ password_hash='unused', role=User.ROLE_VIEWER, is_active=True)
+ db.session.add(viewer)
+ db.session.commit()
+ _, key = ApiKeyService.create_key(viewer.id, name='connection selector', scopes=['*'])
+ headers = {'X-API-Key': key}
+ response = client.get('/api/v1/ai/connections', headers=headers)
+ assert response.status_code == 200
+ assert set(response.get_json()['connections'][0]) == {'id', 'name', 'provider', 'model'}
+ assert 'private-test-key' not in response.get_data(as_text=True)
+ assert client.post('/api/v1/ai/connections', json=draft(), headers=headers).status_code == 403
+
+
def test_catalog_uses_prompture_descriptors_and_deduplicates():
from prompture.drivers.provider_descriptors import PROVIDER_DESCRIPTORS
catalog = service.catalog()
diff --git a/docs/API_SURFACE.md b/docs/API_SURFACE.md
index d59e8bb2..aae92c0c 100644
--- a/docs/API_SURFACE.md
+++ b/docs/API_SURFACE.md
@@ -9,6 +9,7 @@ Regenerate (backend/):
- `DELETE /admin/users/{user_id}`
- `DELETE /agent-plugins/installs/{install_id}`
- `DELETE /agent-plugins/{plugin_id}`
+- `DELETE /ai/connections/{connection_id}`
- `DELETE /ai/conversations/{conversation_id}`
- `DELETE /api-keys/{key_id}`
- `DELETE /apps/{app_id}`
@@ -137,6 +138,7 @@ Regenerate (backend/):
- `GET /agent-plugins/spec`
- `GET /agent-plugins/{plugin_id}`
- `GET /agent-plugins/{plugin_id}/installations`
+- `GET /ai/connections`
- `GET /ai/conversations`
- `GET /ai/conversations/{conversation_id}`
- `GET /ai/models`
@@ -748,6 +750,8 @@ Regenerate (backend/):
- `POST /ai/chat/cancel`
- `POST /ai/chat/confirm`
- `POST /ai/chat/stream`
+- `POST /ai/connections`
+- `POST /ai/connections/probe`
- `POST /ai/conversations`
- `POST /ai/settings/test`
- `POST /api-keys/`
@@ -1263,6 +1267,7 @@ Regenerate (backend/):
- `PUT /admin/users/{user_id}/permissions`
- `PUT /agent-plugins/installs/{install_id}/config`
- `PUT /agent-plugins/{plugin_id}`
+- `PUT /ai/connections/{connection_id}`
- `PUT /ai/settings`
- `PUT /api-keys/{key_id}`
- `PUT /apps/{app_id}`
diff --git a/docs/MIGRATION_INVENTORY.md b/docs/MIGRATION_INVENTORY.md
index a20d6894..15135958 100644
--- a/docs/MIGRATION_INVENTORY.md
+++ b/docs/MIGRATION_INVENTORY.md
@@ -16,12 +16,12 @@ debt. Regenerate with `python scripts/generate-migration-inventory.py`.
| Routes on bare @jwt_required() | auth_required() / role decorators | 608 | 608 | REGISTERED EXCEPTION: JWT-only is the deliberate default; conversion grants API-key access and happens per route, on decision |
| HTTP statuses chosen by sniffing error text | typed errors from app.exceptions | 0 | 0 | INVARIANT at 0 - migration completed 2026-08-19 |
| API crashes swallowed without recording | app.error_reporting | 0 | 0 | INVARIANT at 0 |
-| Hand-shaped {'error': ...} bodies in app/api | typed errors + the global handler | 1141 | 1150 | migrate when touched; new endpoints raise |
+| Hand-shaped {'error': ...} bodies in app/api | typed errors + the global handler | 1144 | 1150 | migrate when touched; new endpoints raise |
| Raw subprocess calls outside the runners | app/utils/system.py runners | 24 | 24 | migrate when touched |
-| Controller-boundary violations (routes doing service work) | service layer extraction | 496 | 496 | migrate when touched (first-wave ratchet) |
+| Controller-boundary violations (routes doing service work) | service layer extraction | 495 | 495 | migrate when touched (first-wave ratchet) |
| raw api.* calls in pages/ | E1: useServerQuery/useServerMutation | 398 | 398 | migrate when touched |
| per-page toast.error extractions in pages/ | E1: query-layer error presentation | 206 | 206 | migrate when touched |
-| hand-rolled form-group blocks | F2: FormField/useForm | 321 | 321 | migrate when touched |
+| hand-rolled form-group blocks | F2: FormField/useForm | 317 | 321 | migrate when touched |
| unencoded ?k=${v} query interpolations in services/api | C4: buildQuery/encoding template | 0 | 0 | INVARIANT at 0 |
| raw setInterval pollers | E2: usePolling/refetchInterval | 7 | 7 | DELIBERATE RESIDUE: clock ticks, socket-fallback hooks, and sibling-repo extension timers - each listed per file |
| direct navigator.clipboard call sites | F3: copyToClipboard | 0 | 0 | INVARIANT at 0 |