Add Hermes Workspace compatibility endpoints to api_server - #8772
Add Hermes Workspace compatibility endpoints to api_server#8772zjw200056061816-collab wants to merge 1 commit into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the Workspace compatibility work. The session-control goal has since landed, but this patch needs a focused salvage rather than a direct merge.
Problems
gateway/platforms/api_server.py:1349persists caller-provided session IDs without the traversal/control-character/length validation current main applies atgateway/platforms/api_server.py:1737-1743; this boundary was hardened inea1372d2._serialize_sessionatgateway/platforms/api_server.py:470-474returns full session rows, includingsystem_promptand parsedmodel_config. Current main intentionally uses a safe allowlist atgateway/platforms/api_server.py:1639-1654.PATCH /api/configatgateway/platforms/api_server.py:1835-1844mutates arbitrary config and.enventries, while current/v1/capabilitiesexplicitly advertisesadmin_config_rw: false(gateway/platforms/api_server.py:1502).- The PR changes only
api_server.py; no regression tests accompany the new HTTP surface.
Suggested changes
- Build any remaining Workspace-specific contract on the shipped session API (
f7527b0fd) and current/v1/skillscapability surface. - Preserve the current session-ID validation and response redaction, and split administrative config/environment changes into an explicitly approved design with E2E coverage.
Automated hermes-sweeper review.
| except Exception: | ||
| body = {} | ||
|
|
||
| session_id = str(body.get("id") or body.get("session_id") or uuid.uuid4()).strip() |
There was a problem hiding this comment.
This accepts arbitrary session IDs before persisting them. Current main rejects traversal/control-character/oversized IDs at this API boundary (gateway/platforms/api_server.py:1737-1743), added by security fix ea1372d2; carry that validation here before create_session.
| except Exception: | ||
| return raw | ||
|
|
||
| def _serialize_session(self, session: Dict[str, Any]) -> Dict[str, Any]: |
There was a problem hiding this comment.
Returning a copied full SessionDB row exposes fields that the current API deliberately withholds, including system_prompt and model_config. Reuse a safe-field serializer like current main's _session_response instead of returning the full record.
|
|
||
| if config_patch: | ||
| current = read_raw_config() | ||
| self._deep_merge(current, config_patch) |
There was a problem hiding this comment.
This turns the API-server bearer credential into unrestricted config and .env administration. Current main intentionally advertises admin_config_rw: false; please split this behind an explicitly designed administrative contract rather than including it in the session compatibility surface.
What
This extends
gateway/platforms/api_server.pywith the Hermes-native/api/*endpoints Hermes Workspace expects for enhanced mode.Added:
GET/POST /api/sessionsGET /api/sessions/searchGET/PATCH/DELETE /api/sessions/{session_id}GET /api/sessions/{session_id}/messagesPOST /api/sessions/{session_id}/forkPOST /api/sessions/{session_id}/chatPOST /api/sessions/{session_id}/chat/streamGET /api/skillsGET /api/skills/categoriesGET /api/skills/{name}GET /api/memoryGET /api/configPATCH /api/configAlso included:
Why
Hermes Workspace can already use upstream in portable mode through:
/health/v1/models/v1/chat/completionsBut it needs additional Hermes-native APIs to unlock enhanced mode features like:
This PR adds those APIs by reusing existing upstream components (
SessionDB,tools.skills_tool,hermes_cli.config, andAIAgentstreaming callbacks) instead of introducing a parallel persistence layer.Validation
Validated against a live Hermes deployment:
/api/sessionsworks/api/skillsworks/api/memoryworks/api/configworksHermes Workspace capability probing switched from portable mode to enhanced mode:
sessions: trueenhancedChat: trueskills: truememory: trueconfig: truejobs: trueNotes
/api/memoryis intentionally lightweight in this passAPI_SERVER_KEYauth behavior is unchanged