Files
zeekay db80c16b10 feat(widget): per-key model allowlist (WIDGET_KEY_MODELS) for public widget keys
Bind a public hz_ widget key to EXACTLY the models its owner provisioned — the
docs Ask AI key to enso only — so a leaked key cannot reach arbitrary or
expensive models the coarse global widget allowlist happens to permit.

- object.WidgetKeyModels(token): per-key model allowlist over WIDGET_KEY_MODELS
  (KMS-first, env fallback), mirroring WidgetKeyOwner exactly; the two share one
  parser (loadKeyMap), so a widget key is configured the one way everywhere.
- resolveProviderFromWidgetKey: a key with an explicit binding is restricted to
  that set; a key with no binding falls back to the global cheap-model allowlist.
  Fail-secure: an enso-bound key can never fall through to other models.
- Tests: object + controller gate (bound key = enso-only, cannot reach premium;
  unbound key falls back to global; case-insensitive; JSON + comma-list forms).

Guardrail for the docs.hanzo.ai support-AI: with rate limit (per-owner-org) and
the prepaid balance gate already enforced, this caps WHICH models a leaked docs
key can call. No behavior change for existing widget keys (no WIDGET_KEY_MODELS).
2026-07-24 23:57:57 -07:00
..