Rebrand: TeamClaw -> Clawmates (clawmates.work)
Full-depth rename per the approved plan; the 'claw' product vocabulary (claws, /claws routes, clawId, Claw Chat) stays — it is now the brand. - Display brand: Clawmates (manifest, titles, hero, login/rail logo 'clawmates'); default host app.clawmates.work; registry ghcr.io/clawmates - Crates tc-* -> cm-* (16 crates + all imports); binaries clawmates-server/broker/bundler; images clawmates/*; env prefix CLAWMATES_* (+ CM_TEST_DATABASE_URL / CM_LIVE_LLM); config clawmates.toml; helm chart deploy/helm/clawmates with clawmates-* resources; db names clawmates*; sockets /run/clawmates; cookie cm_session; kind cluster clawmates-test; seccomp node profile clawmates-agent-profile.json - All 9 Playwright brand assertions updated in lockstep; historical spec document left untouched as the only remaining 'TeamClaw' - Local env migrated: dev pg clawmates-dev-pg/clawmates_dev, shared test server clawmates-test-pg, kind cluster recreated with image + profile, compose images rebuilt under clawmates/* Verified end to end: 161 Rust + 68 frontend tests, 29 Playwright journeys, 4 live kind tests, helm/install/LOC/placeholder gates, and the clean-room install rehearsal serving the clawmates login page from a signed bundle of the rebuilt images. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5
parent
8046853feb
commit
add4f79fed
@@ -0,0 +1,108 @@
|
||||
use cm_domain::{AgentId, WorkspaceId};
|
||||
use sqlx::PgPool;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::DbError;
|
||||
|
||||
/// A connected app (spec §14 AppConnection). The credential lives in the
|
||||
/// broker's encrypted store; this row only carries the reference.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct AppConnection {
|
||||
pub id: Uuid,
|
||||
pub workspace_id: Uuid,
|
||||
pub agent_id: Option<Uuid>,
|
||||
pub provider: String,
|
||||
pub auth_type: String,
|
||||
pub status: String,
|
||||
pub secret_ref: Option<Uuid>,
|
||||
}
|
||||
|
||||
pub async fn insert(
|
||||
pool: &PgPool,
|
||||
workspace_id: WorkspaceId,
|
||||
agent_id: Option<AgentId>,
|
||||
provider: &str,
|
||||
auth_type: &str,
|
||||
secret_ref: Uuid,
|
||||
) -> Result<AppConnection, DbError> {
|
||||
let id = Uuid::now_v7();
|
||||
sqlx::query!(
|
||||
"INSERT INTO app_connections
|
||||
(id, workspace_id, agent_id, provider, auth_type, status, secret_ref)
|
||||
VALUES ($1, $2, $3, $4, $5, 'connected', $6)",
|
||||
id,
|
||||
workspace_id.as_uuid(),
|
||||
agent_id.map(|a| a.as_uuid()),
|
||||
provider,
|
||||
auth_type,
|
||||
secret_ref,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
Ok(AppConnection {
|
||||
id,
|
||||
workspace_id: workspace_id.as_uuid(),
|
||||
agent_id: agent_id.map(|a| a.as_uuid()),
|
||||
provider: provider.to_owned(),
|
||||
auth_type: auth_type.to_owned(),
|
||||
status: "connected".into(),
|
||||
secret_ref: Some(secret_ref),
|
||||
})
|
||||
}
|
||||
|
||||
/// Connections visible to an agent: its own plus workspace-wide ones.
|
||||
pub async fn list_for_agent(
|
||||
pool: &PgPool,
|
||||
workspace_id: WorkspaceId,
|
||||
agent_id: AgentId,
|
||||
) -> Result<Vec<AppConnection>, DbError> {
|
||||
let rows = sqlx::query_as!(
|
||||
AppConnection,
|
||||
r#"SELECT id, workspace_id, agent_id, provider, auth_type, status, secret_ref
|
||||
FROM app_connections
|
||||
WHERE workspace_id = $1 AND (agent_id IS NULL OR agent_id = $2)
|
||||
AND status = 'connected'
|
||||
ORDER BY created_at"#,
|
||||
workspace_id.as_uuid(),
|
||||
agent_id.as_uuid(),
|
||||
)
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
/// The agent's live connection for one provider, if any.
|
||||
pub async fn find_provider(
|
||||
pool: &PgPool,
|
||||
workspace_id: WorkspaceId,
|
||||
agent_id: AgentId,
|
||||
provider: &str,
|
||||
) -> Result<Option<AppConnection>, DbError> {
|
||||
let row = sqlx::query_as!(
|
||||
AppConnection,
|
||||
r#"SELECT id, workspace_id, agent_id, provider, auth_type, status, secret_ref
|
||||
FROM app_connections
|
||||
WHERE workspace_id = $1 AND (agent_id IS NULL OR agent_id = $2)
|
||||
AND provider = $3 AND status = 'connected'
|
||||
ORDER BY created_at DESC LIMIT 1"#,
|
||||
workspace_id.as_uuid(),
|
||||
agent_id.as_uuid(),
|
||||
provider,
|
||||
)
|
||||
.fetch_optional(pool)
|
||||
.await?;
|
||||
Ok(row)
|
||||
}
|
||||
|
||||
pub async fn disconnect(pool: &PgPool, id: Uuid) -> Result<(), DbError> {
|
||||
let result = sqlx::query!(
|
||||
"UPDATE app_connections SET status = 'disconnected' WHERE id = $1",
|
||||
id,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(DbError::NotFound);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user