birth script + POST /api/users endpoint

- scripts/birth.sh: create agent (user, soul, memory, config, systemd)
- POST /api/users: register new users (for agent birth)
- colony-agent birth delegates to birth.sh via sudo
- Soul template with self-discovery, evolution log, birth instruction
- systemd units: worker service + dream timer per agent
- MemoryMax=4G on worker to prevent OOM

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 23:11:08 +02:00
parent d47905a68f
commit 39ba317e5e
4 changed files with 253 additions and 4 deletions

View File

@@ -40,7 +40,7 @@ async fn main() {
let app = Router::new()
.route("/api/health", get(routes::health))
.route("/api/users", get(routes::list_users))
.route("/api/users", get(routes::list_users).post(routes::create_user))
.route("/api/me", get(routes::get_me))
.route(
"/api/channels",

View File

@@ -107,6 +107,39 @@ pub async fn get_me(
}
}
#[derive(Debug, serde::Deserialize)]
pub struct CreateUser {
pub username: String,
pub display_name: String,
pub role: String,
}
pub async fn create_user(
State(state): State<AppState>,
Json(body): Json<CreateUser>,
) -> Result<impl IntoResponse> {
let id = uuid::Uuid::new_v4().to_string();
let role = match body.role.as_str() {
"agent" => "agent",
_ => "ape",
};
sqlx::query("INSERT INTO users (id, username, display_name, role) VALUES (?, ?, ?, ?)")
.bind(&id)
.bind(&body.username)
.bind(&body.display_name)
.bind(role)
.execute(&state.db)
.await?;
let row = sqlx::query_as::<_, UserRow>("SELECT * FROM users WHERE id = ?")
.bind(&id)
.fetch_one(&state.db)
.await?;
Ok((StatusCode::CREATED, Json(row.to_api())))
}
pub async fn create_channel(
State(state): State<AppState>,
Query(user_param): Query<UserParam>,