Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(cyclops-cs): configure production chat (#7169)

r33drichardsde12de9d0cf6
diff --git a/libs/fleet/backend/handlers/config.go b/libs/fleet/backend/handlers/config.go
index 8b68b9a7b0..f6c81aa307 100644
--- a/libs/fleet/backend/handlers/config.go
+++ b/libs/fleet/backend/handlers/config.go
@@ -60,6 +60,7 @@ func (h Handlers) GetConfig(w http.ResponseWriter, r *http.Request) {
slog.WarnContext(ctx, "chat access eval failed; defaulting off", "err", err)
chatEnabled = false
}
+ chatEnabled = chatEnabled && h.Conversations != nil && h.Model != nil
writeJSON(w, http.StatusOK, ConfigResponse{Admin: isAdmin, Billing: billingEnabled, Chat: chatEnabled, Usage: usageEnabled})
}
diff --git a/libs/fleet/backend/handlers/config_test.go b/libs/fleet/backend/handlers/config_test.go
index 4223a28bc5..313b4e1f44 100644
--- a/libs/fleet/backend/handlers/config_test.go
+++ b/libs/fleet/backend/handlers/config_test.go
@@ -8,6 +8,7 @@ import (
"testing"
"cyclops-cs-backend/auth"
+ "cyclops-cs-backend/chat"
"github.com/trycua/cloud/pkg/featureflags"
)
@@ -15,12 +16,16 @@ func TestGetConfigReturnsEffectiveChatAccess(t *testing.T) {
auth.LoadOpa()
user := &auth.User{ID: "user-1", AZP: "cyclops-cs-spa"}
tests := []struct {
- name string
- allowed bool
- want bool
+ name string
+ allowed bool
+ withConversations bool
+ withModel bool
+ want bool
}{
- {name: "globally and personally allowed", allowed: true, want: true},
- {name: "globally or personally denied", allowed: false, want: false},
+ {name: "available and allowed", allowed: true, withConversations: true, withModel: true, want: true},
+ {name: "missing conversation store", allowed: true, withModel: true, want: false},
+ {name: "missing model", allowed: true, withConversations: true, want: false},
+ {name: "not allowed", allowed: false, withConversations: true, withModel: true, want: false},
}
for _, test := range tests {
@@ -30,6 +35,12 @@ func TestGetConfigReturnsEffectiveChatAccess(t *testing.T) {
return test.allowed, nil
},
}
+ if test.withConversations {
+ h.Conversations = chat.NewMemoryConversationStore()
+ }
+ if test.withModel {
+ h.Model = &fakeModel{}
+ }
w := httptest.NewRecorder()
h.GetConfig(w, withUser(httptest.NewRequest(http.MethodGet, "/api/config", nil), user))
diff --git a/libs/fleet/docs/browser-agent.md b/libs/fleet/docs/browser-agent.md
index 274f142e73..8e16dada77 100644
--- a/libs/fleet/docs/browser-agent.md
+++ b/libs/fleet/docs/browser-agent.md
@@ -64,11 +64,12 @@ storage.
- `LITELLM_MODEL` selects the model alias and defaults to `large`.
- `LITELLM_API_KEY` is the backend-only LiteLLM virtual key.
-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.
+Production resolves both chat flags from AWS SSM through OpenFeature and uses
+the in-cluster LiteLLM service with a backend-only virtual key synced from AWS
+Secrets Manager. The `SimpleEnvProvider` maps the flags 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
@@ -90,7 +91,7 @@ not stranded.
## Preview environments
-Chat is enabled only in the preview base at
+Chat is also enabled in the preview base at
`clusters/kopf-k3s/cyclops-cs-previews-base`. Each preview has a Flux
`GitRepository` pinned to the PR head SHA, so manifest and secret-wiring changes
are rendered from the same commit as the frontend/backend images. The backend
@@ -106,8 +107,8 @@ and revoke the credential if any enabled preview becomes untrusted.
An `ExternalSecret` named `cyclops-cs-litellm` reads property `api_key` from
AWS Secrets Manager path `kopf-k3s/cyclops-cs-browser-agent-litellm` and creates
-a namespace-local Secret with the same name. Production manifests are not
-changed by this preview configuration.
+a namespace-local Secret with the same name. Production syncs the same
+restricted browser-agent credential into its own namespace.
The stored value must be a dedicated LiteLLM virtual key restricted to model
alias `large`. Configure a strict spend budget and an expiry, or use a documented