OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Feature]: Web Studio: manual account/user identity in trusted mode + root cross-account data view

Open neurosovereign opened this issue 3 months ago • 0 comments

Issue Origin

Observed or reproduced in a real environment

Problem Statement

Web Studio has no way to connect as a non-default identity in trusted auth mode, and no cross-account data view in api_key mode.

1. Trusted mode: identity is stuck at server defaults. The Studio connection form (web-studio/src/routes/settings/route.tsx) offers exactly three inputs: Base URL, Root API Key, User API Key. The [account/user] badge next to the key field is a derived label, not an input. The identity picker (web-studio/src/hooks/use-identity-directory.ts) is hard-gated:

const available =
  serverMode === 'api_key' &&
  (connectionRole === 'root' || connectionRole === 'admin') &&
  Boolean(controlApiKey)

Meanwhile, in trusted mode without a configured root_api_key, the Admin API is disabled entirely — the server itself answers "Admin API requires api_key mode with root_api_key configured" on GET /api/v1/admin/accounts. So in trusted mode the Studio connects only as default/default (from server.default_account/default_user), which in real deployments is an empty tenant. The dashboard — the natural observability surface for the server — is unusable for the identities that actually hold data.

2. api_key mode: no cross-account observability. Identity is per-key. Inspecting a second account means re-entering that account's user key in settings. A root key unlocks the admin plane (account/user management) but provides no cross-account data-plane view (browse/search memories across accounts). For an operator running multiple teams/tenants on one server, there is no fleet-wide view.

Proposed Solution

  1. Manual identity fields (trusted mode). Add optional Account ID / User ID text inputs to the connection form. When the server reports auth_mode: trusted and no key is configured, send X-OpenViking-Account / X-OpenViking-User (the Studio client already supports identityHeaders) with those values instead of the defaults.
  2. Root-scoped account switching (api_key mode). When the connection has root capability, drive an account/user switcher from GET /api/v1/admin/accounts (+ per-account users) and re-scope data-plane requests to the selected tenant — root can already enumerate tenants, so no new backend privilege is needed, only data-plane scoping (e.g. explicit account_id/user_id URL parameters on read endpoints, or a root-issued impersonation token).

Alternatives Considered

  • Per-account user keys in api_key mode: works for Studio, but forces every local keyless agent integration back to per-agent key management, and still leaves no cross-account view.
  • root_api_key in trusted mode: makes the key mandatory for every request (trusted.py resolve_identity rejects keyless calls once configured), breaking keyless local agent setups — so it's not a viable path to the admin plane for this deployment shape.
  • Local Studio fork: ongoing rebuild/maintenance cost on every server upgrade.

Feature Area

Other (Web Studio)

Use Case

A self-hosted OpenViking server (v0.4.15) holds several team accounts, each with agents reading/writing memories via MCP. The operator wants to observe memory growth, search quality, ingestion/task state, and agent-evolution output across all teams from the Web Studio dashboard. Today this requires either switching the whole server to api_key mode and juggling per-account keys (and even then: one account at a time), or asking an agent to query the REST API by hand.

Example API (Optional)

Trusted-mode connection the Studio could already send today if the form allowed it:

curl http://server:1933/api/v1/search/find \
  -H 'Content-Type: application/json' \
  -H 'X-OpenViking-Account: team-a' \
  -H 'X-OpenViking-User: alice' \
  -d '{"query": "incident review", "limit": 10, "context_type": ["memory"]}'

Root cross-account read (one possible shape):

curl "http://server:1933/api/v1/fs/ls?uri=viking://user/alice/memories/&account_id=team-a" \
  -H 'X-API-Key: <root-key>'

Additional Context

  • Verified against server v0.4.15: trusted mode without root_api_key disables the Admin API; in api_key mode the server strips X-OpenViking-Account/User headers (identity comes from the key), so header-based identity cannot be emulated there either.
  • Related but distinct: #1722 (trusted-mode root key handling), #3801 (header/key mismatch acceptance).

neurosovereign avatar Aug 18 '26 23:08 neurosovereign