Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(cyclops-cs): move chat access to OpenFeature (#7145)
r33drichardsc77f0652819d
diff --git a/libs/fleet/backend/auth/flags_test.go b/libs/fleet/backend/auth/flags_test.goindex f4a399d5fd..725165592a 100644--- a/libs/fleet/backend/auth/flags_test.go+++ b/libs/fleet/backend/auth/flags_test.go@@ -4,6 +4,7 @@ import ("context""net/http""net/http/httptest"+ "os""reflect""testing""time"@@ -22,6 +23,68 @@ func resetFlagsCache() {flagsSF.Forget("flags")}+func unsetEnv(t *testing.T, key string) {+ t.Helper()+ value, present := os.LookupEnv(key)+ if err := os.Unsetenv(key); err != nil {+ t.Fatalf("unset %s: %v", key, err)+ }+ t.Cleanup(func() {+ if present {+ _ = os.Setenv(key, value)+ return+ }+ _ = os.Unsetenv(key)+ })+}++func TestEvalChatEnabledResolvesGlobalAccessFlag(t *testing.T) {+ LoadOpa()+ tests := []struct {+ name string+ access *string+ chatSubs string+ user string+ wantEnable bool+ }{+ {name: "absent defaults to restricted allowed", chatSubs: `["allowed-user"]`, user: "allowed-user", wantEnable: true},+ {name: "absent defaults to restricted denied", chatSubs: `[]`, user: "other-user", wantEnable: false},+ {name: "disabled", access: stringPointer("disabled"), chatSubs: `["allowed-user"]`, user: "allowed-user", wantEnable: false},+ {name: "restricted allowed", access: stringPointer("restricted"), chatSubs: `["allowed-user"]`, user: "allowed-user", wantEnable: true},+ {name: "restricted denied", access: stringPointer("restricted"), chatSubs: `[]`, user: "other-user", wantEnable: false},+ {name: "all", access: stringPointer("all"), chatSubs: `[]`, user: "other-user", wantEnable: true},+ {name: "invalid falls back to restricted allowed", access: stringPointer("not-a-mode"), chatSubs: `["allowed-user"]`, user: "allowed-user", wantEnable: true},+ {name: "invalid falls back to restricted denied", access: stringPointer("not-a-mode"), chatSubs: `[]`, user: "other-user", wantEnable: false},+ }++ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ unsetEnv(t, "CYCLOPS_CS_CHAT_ACCESS")+ if test.access != nil {+ t.Setenv("CYCLOPS_CS_CHAT_ACCESS", *test.access)+ }+ t.Setenv("CYCLOPS_CS_ADMIN_SUBS", `[]`)+ t.Setenv("CYCLOPS_CS_CHAT_SUBS", test.chatSubs)+ if err := featureflags.SetupProvider(context.Background(), "development", featureflags.AWSCredentials{}); err != nil {+ t.Fatalf("setup dev provider: %v", err)+ }+ resetFlagsCache()++ got, err := EvalChatEnabled(context.Background(), &User{ID: test.user, AZP: "cyclops-cs-spa"})+ if err != nil {+ t.Fatalf("EvalChatEnabled() error = %v", err)+ }+ if got != test.wantEnable {+ t.Fatalf("EvalChatEnabled() = %v, want %v", got, test.wantEnable)+ }+ })+ }+}++func stringPointer(value string) *string {+ return &value+}+func TestInvalidateFeatureFlagsPreventsInFlightRefreshFromPublishingStaleData(t *testing.T) {resetFlagsCache()originalCompute := computeFlagsDataFndiff --git a/libs/fleet/backend/auth/middlewares.go b/libs/fleet/backend/auth/middlewares.goindex 874f89b7a4..985a857831 100644--- a/libs/fleet/backend/auth/middlewares.go+++ b/libs/fleet/backend/auth/middlewares.go@@ -130,10 +130,19 @@ const (billingFlag = flagPrefix + "billing-enabled"cardAdmissionFlag = flagPrefix + "require-card-for-custom-resource-creation"cardRequirementExemptSubsFlag = flagPrefix + "card-requirement-exempt-subs"+ chatAccessFlag = flagPrefix + "chat-access"chatSubsFlag = flagPrefix + "chat-subs"usageSubsFlag = flagPrefix + "usage-subs")+type chatAccessMode string++const (+ chatAccessDisabled chatAccessMode = "disabled"+ chatAccessRestricted chatAccessMode = "restricted"+ chatAccessAll chatAccessMode = "all"+)+// flagsTTL bounds how long flagsData returns its last computed result// before re-resolving via OpenFeature. Refresh is lazy and ad-hoc: the// next caller that arrives after expiry triggers a re-resolve on the@@ -402,10 +411,50 @@ func EvalIsAdminFresh(ctx context.Context, user *User) (bool, error) {return evalUserDecision(ctx, user, opaAdminQuery, freshAdminFlags(ctx))}-// EvalChatEnabled returns the restricted-mode chat decision: administrators-// and users listed in input.flags.chat_subs are enabled.+// EvalChatEnabled resolves the global chat access mode and applies the+// restricted-mode administrator/chat-subs policy when needed. Missing,+// malformed, or unsupported values default to restricted.func EvalChatEnabled(ctx context.Context, user *User) (bool, error) {- return evalUserDecision(ctx, user, opaChatQuery, flagsData())+ if user == nil || user.ID == "" {+ return false, nil+ }+ switch resolveChatAccessMode(ctx, user.ID) {+ case chatAccessDisabled:+ return false, nil+ case chatAccessAll:+ return true, nil+ default:+ return evalUserDecision(ctx, user, opaChatQuery, flagsData())+ }+}++func resolveChatAccessMode(ctx context.Context, targetingKey string) chatAccessMode {+ ffClientOnce.Do(func() {+ ffClient = openfeature.NewClient("cyclops-cs-auth")+ })+ callCtx, cancel := context.WithTimeout(ctx, 3*time.Second)+ defer cancel()+ raw, err := ffClient.StringValue(+ callCtx,+ chatAccessFlag,+ string(chatAccessRestricted),+ openfeature.NewEvaluationContext(targetingKey, nil),+ )+ if err != nil {+ slog.WarnContext(ctx, "auth: chat access flag eval failed; using restricted", "flag", chatAccessFlag, "err", err)+ return chatAccessRestricted+ }+ switch chatAccessMode(strings.ToLower(strings.TrimSpace(raw))) {+ case chatAccessDisabled:+ return chatAccessDisabled+ case chatAccessRestricted:+ return chatAccessRestricted+ case chatAccessAll:+ return chatAccessAll+ default:+ slog.WarnContext(ctx, "auth: invalid chat access flag; using restricted", "flag", chatAccessFlag, "value", raw)+ return chatAccessRestricted+ }}func EvalUsageEnabled(ctx context.Context, user *User) (bool, error) {diff --git a/libs/fleet/backend/config/config.go b/libs/fleet/backend/config/config.goindex 768faab82d..be35361c9d 100644--- a/libs/fleet/backend/config/config.go+++ b/libs/fleet/backend/config/config.go@@ -105,20 +105,7 @@ type DatabaseConfiguration struct {StateQueryTenantPassword string // STATE_QUERY_TENANT_PASSWORD — shared tenant query login password}-type ChatAccessMode string--const (- ChatAccessDisabled ChatAccessMode = "disabled"- ChatAccessRestricted ChatAccessMode = "restricted"- ChatAccessAll ChatAccessMode = "all"-)--func (mode ChatAccessMode) Enabled() bool {- return mode == ChatAccessRestricted || mode == ChatAccessAll-}-type ChatConfiguration struct {- Access ChatAccessModeBaseURL stringAPIKey stringModel string@@ -210,8 +197,6 @@ var specs = []flagSpec{{"stripe.checkout-success-url", "stripe-checkout-success-url", "STRIPE_CHECKOUT_SUCCESS_URL", "", "Stripe Checkout success redirect URL"},{"stripe.checkout-cancel-url", "stripe-checkout-cancel-url", "STRIPE_CHECKOUT_CANCEL_URL", "", "Stripe Checkout cancel redirect URL"},{"stripe.portal-return-url", "stripe-portal-return-url", "STRIPE_PORTAL_RETURN_URL", "", "Stripe Billing Portal return URL"},- {"chat.access", "chat-access", "CYCLOPS_CS_CHAT_ACCESS", "", "chat access mode: disabled, restricted, or all"},- {"chat.enabled", "chat-enabled", "CYCLOPS_CS_CHAT_ENABLED", "false", "legacy browser bash chat toggle"},{"chat.base-url", "litellm-base-url", "LITELLM_BASE_URL", "", "LiteLLM OpenAI-compatible base URL"},{"chat.api-key", "litellm-api-key", "LITELLM_API_KEY", "", "LiteLLM virtual key"},{"chat.model", "litellm-model", "LITELLM_MODEL", "large", "LiteLLM model alias"},@@ -321,7 +306,6 @@ func LoadConfig() (*Configuration, error) {PortalReturnURL: viper.GetString("stripe.portal-return-url"),},Chat: ChatConfiguration{- Access: chatAccessMode(viper.GetString("chat.access"), viper.GetBool("chat.enabled")),BaseURL: viper.GetString("chat.base-url"),APIKey: viper.GetString("chat.api-key"),Model: viper.GetString("chat.model"),@@ -351,8 +335,8 @@ func LoadConfig() (*Configuration, error) {if cfg.Keycloak.AdminClientSecret == "" {return nil, fmt.Errorf("KC_ADMIN_CLIENT_SECRET is required")}- if cfg.Chat.Access.Enabled() && (cfg.Chat.BaseURL == "" || cfg.Chat.APIKey == "") {- return nil, fmt.Errorf("enabled chat access requires LITELLM_BASE_URL and LITELLM_API_KEY")+ if (cfg.Chat.BaseURL == "") != (cfg.Chat.APIKey == "") {+ return nil, fmt.Errorf("chat configuration requires both LITELLM_BASE_URL and LITELLM_API_KEY")}if err := validateUsageConfiguration(cfg.Usage); err != nil {return nil, err@@ -360,22 +344,6 @@ func LoadConfig() (*Configuration, error) {return cfg, nil}-func chatAccessMode(access string, legacyEnabled bool) ChatAccessMode {- switch ChatAccessMode(strings.ToLower(strings.TrimSpace(access))) {- case ChatAccessDisabled:- return ChatAccessDisabled- case ChatAccessRestricted:- return ChatAccessRestricted- case ChatAccessAll:- return ChatAccessAll- case "":- if legacyEnabled {- return ChatAccessAll- }- }- return ChatAccessDisabled-}-func validateUsageConfiguration(cfg UsageConfiguration) error {if cfg.QueryTimeout < minUsageQueryTimeout || cfg.QueryTimeout > maxUsageQueryTimeout {return fmt.Errorf("USAGE_QUERY_TIMEOUT must be between 1s and 2m")diff --git a/libs/fleet/backend/config/config_test.go b/libs/fleet/backend/config/config_test.goindex 488476a023..66ba63ec2c 100644--- a/libs/fleet/backend/config/config_test.go+++ b/libs/fleet/backend/config/config_test.go@@ -193,49 +193,7 @@ func loadChatTestConfig(t *testing.T) (*Configuration, error) {return LoadConfig()}-func TestLoadConfig_ChatAccessModes(t *testing.T) {- tests := []struct {- name string- access string- legacy string- wantAccess ChatAccessMode- }{- {name: "default disabled", wantAccess: ChatAccessDisabled},- {name: "disabled", access: "disabled", wantAccess: ChatAccessDisabled},- {name: "restricted", access: "restricted", wantAccess: ChatAccessRestricted},- {name: "all", access: "all", wantAccess: ChatAccessAll},- {name: "invalid fails closed", access: "unexpected", legacy: "true", wantAccess: ChatAccessDisabled},- {name: "new mode overrides legacy", access: "restricted", legacy: "false", wantAccess: ChatAccessRestricted},- {name: "legacy true maps to all", legacy: "true", wantAccess: ChatAccessAll},- {name: "legacy false maps to disabled", legacy: "false", wantAccess: ChatAccessDisabled},- }-- for _, test := range tests {- t.Run(test.name, func(t *testing.T) {- if test.access != "" {- t.Setenv("CYCLOPS_CS_CHAT_ACCESS", test.access)- }- if test.legacy != "" {- t.Setenv("CYCLOPS_CS_CHAT_ENABLED", test.legacy)- }- if test.wantAccess.Enabled() {- t.Setenv("LITELLM_BASE_URL", "https://litellm.example/v1")- t.Setenv("LITELLM_API_KEY", "secret")- }-- cfg, err := loadChatTestConfig(t)- if err != nil {- t.Fatalf("LoadConfig() error = %v", err)- }- if cfg.Chat.Access != test.wantAccess {- t.Fatalf("Chat.Access = %q, want %q", cfg.Chat.Access, test.wantAccess)- }- })- }-}--func TestLoadConfig_ChatAccessWithCredentials(t *testing.T) {- t.Setenv("CYCLOPS_CS_CHAT_ACCESS", "all")+func TestLoadConfig_ChatConfiguration(t *testing.T) {t.Setenv("LITELLM_BASE_URL", "https://litellm.example/v1")t.Setenv("LITELLM_API_KEY", "secret")t.Setenv("LITELLM_MODEL", "browser-bash")@@ -243,35 +201,31 @@ func TestLoadConfig_ChatAccessWithCredentials(t *testing.T) {if err != nil {t.Fatalf("LoadConfig() error = %v", err)}- if cfg.Chat.Access != ChatAccessAll || cfg.Chat.BaseURL != "https://litellm.example/v1" || cfg.Chat.APIKey != "secret" || cfg.Chat.Model != "browser-bash" {- t.Fatalf("Chat = %#v, want all-users configuration", cfg.Chat)+ if cfg.Chat.BaseURL != "https://litellm.example/v1" || cfg.Chat.APIKey != "secret" || cfg.Chat.Model != "browser-bash" {+ t.Fatalf("Chat = %#v, want configured LiteLLM client", cfg.Chat)}}-func TestLoadConfig_ChatAccessRequiresCredentials(t *testing.T) {+func TestLoadConfig_ChatCredentialsMustBePaired(t *testing.T) {for name, env := range map[string]map[string]string{- "restricted missing base URL": {"CYCLOPS_CS_CHAT_ACCESS": "restricted", "LITELLM_API_KEY": "secret"},- "restricted missing API key": {"CYCLOPS_CS_CHAT_ACCESS": "restricted", "LITELLM_BASE_URL": "https://litellm.example/v1"},- "all missing base URL": {"CYCLOPS_CS_CHAT_ACCESS": "all", "LITELLM_API_KEY": "secret"},- "all missing API key": {"CYCLOPS_CS_CHAT_ACCESS": "all", "LITELLM_BASE_URL": "https://litellm.example/v1"},- "legacy missing base URL": {"CYCLOPS_CS_CHAT_ENABLED": "true", "LITELLM_API_KEY": "secret"},+ "missing base URL": {"LITELLM_API_KEY": "secret"},+ "missing API key": {"LITELLM_BASE_URL": "https://litellm.example/v1"},} {t.Run(name, func(t *testing.T) {for key, value := range env {t.Setenv(key, value)}_, err := loadChatTestConfig(t)- if err == nil || !strings.Contains(err.Error(), "chat") {+ if err == nil || !strings.Contains(err.Error(), "chat configuration") {t.Fatalf("LoadConfig() error = %v, want chat credential error", err)}})}}-func TestLoadConfig_ChatDisabledDoesNotRequireCredentials(t *testing.T) {- t.Setenv("CYCLOPS_CS_CHAT_ACCESS", "disabled")+func TestLoadConfig_ChatCredentialsAreOptional(t *testing.T) {if _, err := loadChatTestConfig(t); err != nil {- t.Fatalf("LoadConfig() error = %v, want disabled mode without credentials", err)+ t.Fatalf("LoadConfig() error = %v, want optional chat credentials", err)}}diff --git a/libs/fleet/backend/handlers/chat.go b/libs/fleet/backend/handlers/chat.goindex 0c34cd5324..cfb1d29aff 100644--- a/libs/fleet/backend/handlers/chat.go+++ b/libs/fleet/backend/handlers/chat.go@@ -39,10 +39,6 @@ type turnEvent struct {}func (h Handlers) chatUser(w http.ResponseWriter, r *http.Request) *auth.User {- if !h.ChatAccess.Enabled() {- writeErr(w, http.StatusNotFound, "chat is disabled")- return nil- }user := currentUser(r)if user == nil || user.ID == "" {writeErr(w, http.StatusUnauthorized, "missing user")diff --git a/libs/fleet/backend/handlers/chat_test.go b/libs/fleet/backend/handlers/chat_test.goindex 4e1fc1b2d1..0c32b7fb41 100644--- a/libs/fleet/backend/handlers/chat_test.go+++ b/libs/fleet/backend/handlers/chat_test.go@@ -13,7 +13,6 @@ import ("cyclops-cs-backend/auth""cyclops-cs-backend/chat"- "cyclops-cs-backend/config")type fakeModel struct {@@ -48,7 +47,14 @@ func (f *fakeModel) Complete(_ context.Context, messages []chat.Message, onDeltafunc newChatHandlers(responses ...chat.Message) (Handlers, *chat.MemoryConversationStore, *fakeModel) {store := chat.NewMemoryConversationStore()model := &fakeModel{responses: responses}- return Handlers{ChatAccess: config.ChatAccessAll, Conversations: store, Model: model, chatLocks: newConversationLockRegistry()}, store, model+ return Handlers{+ Conversations: store,+ Model: model,+ chatAccessEvaluator: func(context.Context, *auth.User) (bool, error) {+ return true, nil+ },+ chatLocks: newConversationLockRegistry(),+ }, store, model}func createChatConversation(t *testing.T, h Handlers, user *auth.User) *chat.Conversation {@@ -99,7 +105,8 @@ func TestChatConversationsCreateListGetOwnership(t *testing.T) {func TestChatRequiresEnabledFeatureAndUser(t *testing.T) {w := httptest.NewRecorder()- Handlers{}.ListConversations(w, newReq(http.MethodGet, "/api/chat/conversations", "", alice))+ disabled := Handlers{chatAccessEvaluator: func(context.Context, *auth.User) (bool, error) { return false, nil }}+ disabled.ListConversations(w, newReq(http.MethodGet, "/api/chat/conversations", "", alice))if w.Code != http.StatusNotFound {t.Fatalf("disabled status = %d, want 404", w.Code)}@@ -363,7 +370,7 @@ func TestChatTurnSerializesConcurrentTurnsPerConversation(t *testing.T) {secondStarted: make(chan struct{}),releaseFirst: make(chan struct{}),}- h := Handlers{ChatAccess: config.ChatAccessAll, Conversations: store, Model: model}+ h := Handlers{Conversations: store, Model: model, chatAccessEvaluator: func(context.Context, *auth.User) (bool, error) { return true, nil }}conversation := createChatConversation(t, h, alice)statuses := make(chan int, 2)@@ -410,10 +417,12 @@ func TestChatConversationArchiveWaitsForActiveTurn(t *testing.T) {releaseFirst: make(chan struct{}),}h := Handlers{- ChatAccess: config.ChatAccessAll,Conversations: store,Model: model,- chatLocks: newConversationLockRegistry(),+ chatAccessEvaluator: func(context.Context, *auth.User) (bool, error) {+ return true, nil+ },+ chatLocks: newConversationLockRegistry(),}conversation := createChatConversation(t, h, alice)@@ -558,7 +567,7 @@ func TestConversationLockRegistryEvictsReleasedLocks(t *testing.T) {func TestCreateConversationReportsStoreLimit(t *testing.T) {store := chat.NewMemoryConversationStore()- h := Handlers{ChatAccess: config.ChatAccessAll, Conversations: store, Model: &fakeModel{}}+ h := Handlers{Conversations: store, Model: &fakeModel{}, chatAccessEvaluator: func(context.Context, *auth.User) (bool, error) { return true, nil }}for index := 0; index < 100; index++ {w := httptest.NewRecorder()h.CreateConversation(w, newReq(http.MethodPost, "/api/chat/conversations", "", alice))@@ -578,24 +587,20 @@ func TestChatEndpointsEnforceEffectiveAccess(t *testing.T) {user := &auth.User{ID: "restricted-user", AZP: "cyclops-cs-spa"}tests := []struct {name string- access config.ChatAccessMode- restricted bool+ allowed boolwantStatus int}{- {name: "disabled", access: config.ChatAccessDisabled, restricted: true, wantStatus: http.StatusNotFound},- {name: "all", access: config.ChatAccessAll, restricted: false, wantStatus: http.StatusCreated},- {name: "restricted allowed", access: config.ChatAccessRestricted, restricted: true, wantStatus: http.StatusCreated},- {name: "restricted denied", access: config.ChatAccessRestricted, restricted: false, wantStatus: http.StatusNotFound},+ {name: "allowed", allowed: true, wantStatus: http.StatusCreated},+ {name: "denied", allowed: false, wantStatus: http.StatusNotFound},}for _, test := range tests {t.Run(test.name, func(t *testing.T) {h := Handlers{- ChatAccess: test.access,Conversations: store,Model: &fakeModel{},chatAccessEvaluator: func(context.Context, *auth.User) (bool, error) {- return test.restricted, nil+ return test.allowed, nil},}w := httptest.NewRecorder()diff --git a/libs/fleet/backend/handlers/config_test.go b/libs/fleet/backend/handlers/config_test.goindex 7e5c43c276..4223a28bc5 100644--- a/libs/fleet/backend/handlers/config_test.go+++ b/libs/fleet/backend/handlers/config_test.go@@ -8,7 +8,6 @@ import ("testing""cyclops-cs-backend/auth"- "cyclops-cs-backend/config""github.com/trycua/cloud/pkg/featureflags")@@ -16,23 +15,19 @@ func TestGetConfigReturnsEffectiveChatAccess(t *testing.T) {auth.LoadOpa()user := &auth.User{ID: "user-1", AZP: "cyclops-cs-spa"}tests := []struct {- name string- access config.ChatAccessMode- restricted bool- want bool+ name string+ allowed bool+ want bool}{- {name: "disabled", access: config.ChatAccessDisabled, restricted: true, want: false},- {name: "all", access: config.ChatAccessAll, restricted: false, want: true},- {name: "restricted allowed", access: config.ChatAccessRestricted, restricted: true, want: true},- {name: "restricted denied", access: config.ChatAccessRestricted, restricted: false, want: false},+ {name: "globally and personally allowed", allowed: true, want: true},+ {name: "globally or personally denied", allowed: false, want: false},}for _, test := range tests {t.Run(test.name, func(t *testing.T) {h := Handlers{- ChatAccess: test.access,chatAccessEvaluator: func(context.Context, *auth.User) (bool, error) {- return test.restricted, nil+ return test.allowed, nil},}w := httptest.NewRecorder()diff --git a/libs/fleet/backend/handlers/handlers.go b/libs/fleet/backend/handlers/handlers.goindex febff76b5a..5af8067589 100644--- a/libs/fleet/backend/handlers/handlers.go+++ b/libs/fleet/backend/handlers/handlers.go@@ -47,7 +47,6 @@ type Handlers struct {FeatureFlags *featureflagadmin.Service- ChatAccess config.ChatAccessModeConversations chat.ConversationStoreModel chat.ModelClientchatAccessEvaluator func(context.Context, *auth.User) (bool, error)@@ -72,7 +71,6 @@ func New(admin *keycloak.Admin, cfg *config.Configuration) Handlers {AuthCfg: cfg.Auth,KC: cfg.Keycloak,Stripe: cfg.Stripe,- ChatAccess: cfg.Chat.Access,chatLocks: newConversationLockRegistry(),}}@@ -97,18 +95,11 @@ func (h Handlers) chatEnabled(ctx context.Context, user *auth.User) (bool, errorif user == nil || user.ID == "" {return false, nil}- switch h.ChatAccess {- case config.ChatAccessAll:- return true, nil- case config.ChatAccessRestricted:- evaluator := h.chatAccessEvaluator- if evaluator == nil {- evaluator = auth.EvalChatEnabled- }- return evaluator(ctx, user)- default:- return false, nil+ evaluator := h.chatAccessEvaluator+ if evaluator == nil {+ evaluator = auth.EvalChatEnabled}+ return evaluator(ctx, user)}var dnsLabel = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)diff --git a/libs/fleet/backend/main.go b/libs/fleet/backend/main.goindex cfe28b2b78..a416d8bbb5 100644--- a/libs/fleet/backend/main.go+++ b/libs/fleet/backend/main.go@@ -390,10 +390,12 @@ func run() error {progress := initializeDatabaseFeatures(ctx, cfg.Database, &h, databaseFeatures)go retryDatabaseFeatures(ctx, cfg.Database, &h, databaseFeatures, progress, databaseRetryInterval)- if cfg.Chat.Access.Enabled() {+ if cfg.Chat.BaseURL != "" {h.Conversations = chat.NewMemoryConversationStore()h.Model = chat.NewLiteLLMClient(cfg.Chat.BaseURL, cfg.Chat.APIKey, cfg.Chat.Model)- slog.Info("chat: enabled", "access", cfg.Chat.Access, "base_url", cfg.Chat.BaseURL, "model", cfg.Chat.Model)+ slog.Info("chat: configured", "base_url", cfg.Chat.BaseURL, "model", cfg.Chat.Model)+ } else {+ slog.Info("chat: not configured (LITELLM_BASE_URL and LITELLM_API_KEY unset)")}router := setupRouter(h)diff --git a/libs/fleet/docs/browser-agent.md b/libs/fleet/docs/browser-agent.mdindex 9751a02057..274f142e73 100644--- a/libs/fleet/docs/browser-agent.md+++ b/libs/fleet/docs/browser-agent.md@@ -44,6 +44,7 @@ Run the Go backend with chat enabled in a separate terminal:```bashcd cyclops-cs/backend+ENVIRONMENT=development \CYCLOPS_CS_CHAT_ACCESS=all \LITELLM_BASE_URL=http://localhost:4000/v1 \LITELLM_MODEL=large \@@ -57,15 +58,17 @@ storage.## Backend configuration-- `CYCLOPS_CS_CHAT_ACCESS` selects `disabled`, `restricted`, or `all`.-- `CYCLOPS_CS_CHAT_SUBS` is a JSON array of non-admin Keycloak `sub` values used in `restricted` mode; admins are enabled automatically.+- `/feature-flags/cyclops-cs/chat-access` selects `disabled`, `restricted`, or `all`. Missing or invalid values default to `restricted`.+- `/feature-flags/cyclops-cs/chat-subs` is a JSON array of non-admin Keycloak `sub` values used in `restricted` mode; admins are enabled automatically.- `LITELLM_BASE_URL` is the OpenAI-compatible API base URL, including `/v1`.- `LITELLM_MODEL` selects the model alias and defaults to `large`.- `LITELLM_API_KEY` is the backend-only LiteLLM virtual key.-In `restricted` and `all` modes, both `LITELLM_BASE_URL` and-`LITELLM_API_KEY` are required. `CYCLOPS_CS_CHAT_ENABLED=true` remains a-legacy fallback for `all` only when `CYCLOPS_CS_CHAT_ACCESS` is unset.+Production resolves both chat flags from AWS SSM through OpenFeature. The+`SimpleEnvProvider` maps them to `CYCLOPS_CS_CHAT_ACCESS` and+`CYCLOPS_CS_CHAT_SUBS` for development and previews. Set both+`LITELLM_BASE_URL` and `LITELLM_API_KEY`, or leave both unset to run without a+configured chat model.## API routes