feat(claw): provision the workspace git identity at boot
Every forge thread works in a per-thread workspace, and implementer turns end in commits. git commit refuses to run without user.name and user.email, and a fresh workspace carries no gitconfig: the first commit on a fresh image fails, or succeeds with whatever the agent improvised. The agent commits as itself — its own name and address, never the user's, never inferred from whatever accounts happen to exist. The identity store gains an email field beside the name, so what onboarding collects with identity_set and the Agent · General page edits is what commits carry. The config gains an optional git section, an operator's override. Each field resolves independently: config, then identity, then defaults (claw, claw@hostname). The resolved pair is written into the daemon user's global git config at boot, in both run shapes — a cron pass commits too. The write is guarded: the settings store remembers the last pair the daemon wrote, and boot rewrites a field only when the config still holds that pair or nothing. A value anyone else set wins outright; the daemon is a tenant of its user's machine, not the owner of its git config. Provisioning runs from the binary's boot, not daemon assembly, so the tests that build daemons never touch a real gitconfig. An ssh sandbox runs git on another host and stays unprovisioned — a later story. The web UI gains an Email row on Agent · General; the phone's wire model gains the optional field.
This commit is contained in:
1 parent
6a81dfa466
commit
1b85cd8937
17 files changed
+598
-13
No files matched your search
@@ -261,6 +261,7 @@ data class CommandResult(val ok: Boolean, val detail: String? = null)
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class AgentIdentity(
|
data class AgentIdentity(
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
|
val email: String? = null,
|
||||||
val mark: String? = null,
|
val mark: String? = null,
|
||||||
val initials: String? = null,
|
val initials: String? = null,
|
||||||
val tagline: String? = null,
|
val tagline: String? = null,
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ questions, spread across turns.
|
|||||||
Write SOUL.md (your name, tone, purpose) and USER.md (who the user
|
Write SOUL.md (your name, tone, purpose) and USER.md (who the user
|
||||||
is) with the bootstrap_save tool as facts arrive; incrementally is
|
is) with the bootstrap_save tool as facts arrive; incrementally is
|
||||||
fine. Set what you learn about your own presentation with the
|
fine. Set what you learn about your own presentation with the
|
||||||
identity_set tool as well — your name, a mark or initials, a tagline.
|
identity_set tool as well — your name, a mark or initials, a tagline, an
|
||||||
|
email to commit as.
|
||||||
An avatar only if the user hands you an image file; they can also
|
An avatar only if the user hands you an image file; they can also
|
||||||
upload one in the web interface's settings, and saying so beats
|
upload one in the web interface's settings, and saying so beats
|
||||||
hunting one down. Never invent facts the user did not give.
|
hunting one down. Never invent facts the user did not give.
|
||||||
|
|||||||
@@ -182,6 +182,26 @@ pub struct ClawConfig {
|
|||||||
/// `rhema-sandboxd` over HTTP. The settings store owns the live
|
/// `rhema-sandboxd` over HTTP. The settings store owns the live
|
||||||
/// choice; this seeds it at boot, before the first settings write.
|
/// choice; this seeds it at boot, before the first settings write.
|
||||||
pub sandbox: Option<crate::sandbox::SandboxChoice>,
|
pub sandbox: Option<crate::sandbox::SandboxChoice>,
|
||||||
|
/// The git identity the daemon writes into its user's global git
|
||||||
|
/// config at boot, so workspace commits carry the agent as author.
|
||||||
|
/// A field set here wins over the agent's identity (what
|
||||||
|
/// onboarding and the settings page write); both win over
|
||||||
|
/// defaults. See [`crate::git_identity`].
|
||||||
|
pub git: Option<GitIdentity>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One git identity as the config states it: both fields optional, a
|
||||||
|
/// set field winning over the identity store, an unset one falling
|
||||||
|
/// through.
|
||||||
|
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(default, rename_all = "snake_case", deny_unknown_fields)]
|
||||||
|
pub struct GitIdentity {
|
||||||
|
/// The commit author name.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub name: Option<String>,
|
||||||
|
/// The commit author address.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub email: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClawConfig {
|
impl ClawConfig {
|
||||||
@@ -210,6 +230,7 @@ impl Default for ClawConfig {
|
|||||||
ingest_token: None,
|
ingest_token: None,
|
||||||
transcript: None,
|
transcript: None,
|
||||||
sandbox: None,
|
sandbox: None,
|
||||||
|
git: None,
|
||||||
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,6 +465,9 @@ sandbox:
|
|||||||
kind: http
|
kind: http
|
||||||
url: https://box.example:7600
|
url: https://box.example:7600
|
||||||
token: sandbox-secret
|
token: sandbox-secret
|
||||||
|
git:
|
||||||
|
name: Bot
|
||||||
|
email: bot@example.net
|
||||||
";
|
";
|
||||||
let config: ClawConfig = serde_yaml::from_str(raw).expect("parses");
|
let config: ClawConfig = serde_yaml::from_str(raw).expect("parses");
|
||||||
assert_eq!(config.poll_interval_secs, 30);
|
assert_eq!(config.poll_interval_secs, 30);
|
||||||
@@ -464,6 +488,9 @@ sandbox:
|
|||||||
assert_eq!(sandbox.kind, crate::sandbox::SandboxKind::Http);
|
assert_eq!(sandbox.kind, crate::sandbox::SandboxKind::Http);
|
||||||
assert_eq!(sandbox.url.as_deref(), Some("https://box.example:7600"));
|
assert_eq!(sandbox.url.as_deref(), Some("https://box.example:7600"));
|
||||||
assert_eq!(sandbox.token.as_deref(), Some("sandbox-secret"));
|
assert_eq!(sandbox.token.as_deref(), Some("sandbox-secret"));
|
||||||
|
let git = config.git.expect("the git identity parses");
|
||||||
|
assert_eq!(git.name.as_deref(), Some("Bot"));
|
||||||
|
assert_eq!(git.email.as_deref(), Some("bot@example.net"));
|
||||||
|
|
||||||
let config: ClawConfig = serde_yaml::from_str(
|
let config: ClawConfig = serde_yaml::from_str(
|
||||||
"sandbox:\n kind: ssh\n host: me@box.example\n workspace: /srv/claw\n",
|
"sandbox:\n kind: ssh\n host: me@box.example\n workspace: /srv/claw\n",
|
||||||
@@ -524,6 +551,31 @@ sandbox:
|
|||||||
assert!(valid.validate().is_ok(), "a bare login is all ssh needs");
|
assert!(valid.validate().is_ok(), "a bare login is all ssh needs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_git_section_rejects_a_typo_and_carries_partial_identity() {
|
||||||
|
let err = serde_yaml::from_str::<ClawConfig>(
|
||||||
|
"git:
|
||||||
|
nmae: Bot
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.expect_err("a typo inside the section must not read as its default");
|
||||||
|
assert!(
|
||||||
|
err.to_string().contains("nmae"),
|
||||||
|
"the error names the key: {err}"
|
||||||
|
);
|
||||||
|
// One field alone is legal: the other falls through to the
|
||||||
|
// identity store, then defaults.
|
||||||
|
let config: ClawConfig = serde_yaml::from_str(
|
||||||
|
"git:
|
||||||
|
email: bot@example.net
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.expect("parses");
|
||||||
|
let git = config.git.expect("the section parses");
|
||||||
|
assert_eq!(git.email.as_deref(), Some("bot@example.net"));
|
||||||
|
assert_eq!(git.name, None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn an_unknown_key_is_rejected_and_named() {
|
fn an_unknown_key_is_rejected_and_named() {
|
||||||
let err = serde_yaml::from_str::<ClawConfig>("listne: 127.0.0.1:7799\n")
|
let err = serde_yaml::from_str::<ClawConfig>("listne: 127.0.0.1:7799\n")
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ fn bound(raw: &str) -> String {
|
|||||||
/// The hostname: `/etc/hostname`'s first line, else the `hostname`
|
/// The hostname: `/etc/hostname`'s first line, else the `hostname`
|
||||||
/// command, else a stand-in — the file is not portable and the command
|
/// command, else a stand-in — the file is not portable and the command
|
||||||
/// is not guaranteed, so absence is a report line.
|
/// is not guaranteed, so absence is a report line.
|
||||||
fn hostname() -> String {
|
pub(crate) fn hostname() -> String {
|
||||||
if let Ok(raw) = std::fs::read_to_string("/etc/hostname") {
|
if let Ok(raw) = std::fs::read_to_string("/etc/hostname") {
|
||||||
let name = bound(&raw);
|
let name = bound(&raw);
|
||||||
if !name.is_empty() {
|
if !name.is_empty() {
|
||||||
|
|||||||
@@ -0,0 +1,459 @@
|
|||||||
|
//! The workspace git identity: `user.name` and `user.email` in the
|
||||||
|
//! daemon user's global git config, written at boot so every commit a
|
||||||
|
//! workspace makes carries the agent as its author — before any
|
||||||
|
//! conversation happened, on a machine nobody onboarded.
|
||||||
|
//!
|
||||||
|
//! Like the environment report this is deterministic boot code, and
|
||||||
|
//! like every boot probe its failure is one log line, never a failed
|
||||||
|
//! boot. Each field resolves from three sources, first set wins: the
|
||||||
|
//! config file's `git` section (the operator's choice), the agent's
|
||||||
|
//! own presentation identity (`identity.name`, `identity.email` —
|
||||||
|
//! what onboarding and the settings page write), then defaults. The
|
||||||
|
//! values land in the git config the daemon user's `git` reads, so
|
||||||
|
//! thread workspaces, chat scratch repos, and anything the agent
|
||||||
|
//! inits itself all inherit them.
|
||||||
|
//!
|
||||||
|
//! The write is guarded. The settings store remembers the last pair
|
||||||
|
//! the daemon wrote; boot rewrites a field only when the config file
|
||||||
|
//! still holds that pair, or nothing at all. A value anyone else set
|
||||||
|
//! wins outright — the daemon is a tenant of its user's machine, not
|
||||||
|
//! the owner of its git config. An ssh sandbox runs git on another
|
||||||
|
//! host, so it stays out of scope here: those workspaces remain
|
||||||
|
//! unprovisioned until a later story pushes the values remotely.
|
||||||
|
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::process::{Command, Stdio};
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
use crate::config::{ClawConfig, GitIdentity};
|
||||||
|
use crate::identity::{AgentIdentity, IdentityStore};
|
||||||
|
use crate::settings::SettingsStore;
|
||||||
|
|
||||||
|
/// The fallback author name, when the config and the identity are
|
||||||
|
/// both silent. Lowercase on purpose: a stand-in, not a persona.
|
||||||
|
pub const DEFAULT_NAME: &str = "claw";
|
||||||
|
|
||||||
|
/// The settings keys recording the last pair the daemon wrote. The
|
||||||
|
/// guard reads them back on every boot; a mismatch means the field
|
||||||
|
/// was hand-edited and is left alone.
|
||||||
|
const WRITTEN_NAME: &str = "git_identity_written_name";
|
||||||
|
const WRITTEN_EMAIL: &str = "git_identity_written_email";
|
||||||
|
|
||||||
|
/// The per-call budget: a local `git config` is a file operation; the
|
||||||
|
/// budget only bounds a wedged `git`, like any other boot probe.
|
||||||
|
const GIT_BUDGET: Duration = Duration::from_secs(2);
|
||||||
|
|
||||||
|
/// One resolved field: the value and where it came from, for the boot
|
||||||
|
/// log line.
|
||||||
|
pub struct ResolvedField {
|
||||||
|
/// The resolved value, ready for the config file.
|
||||||
|
pub value: String,
|
||||||
|
/// Where it came from: `config`, `identity`, or `default`, for
|
||||||
|
/// the boot log line.
|
||||||
|
pub source: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resolves both fields: config, then identity, then defaults. The
|
||||||
|
/// fields resolve independently — a config name beside an identity
|
||||||
|
/// email is a legal pair.
|
||||||
|
pub fn resolve(
|
||||||
|
git: Option<&GitIdentity>,
|
||||||
|
identity: &AgentIdentity,
|
||||||
|
hostname: &str,
|
||||||
|
) -> (ResolvedField, ResolvedField) {
|
||||||
|
let field = |configured: Option<String>, presented: Option<String>, default: String| {
|
||||||
|
if let Some(value) = configured {
|
||||||
|
ResolvedField {
|
||||||
|
source: "config",
|
||||||
|
value,
|
||||||
|
}
|
||||||
|
} else if let Some(value) = presented {
|
||||||
|
ResolvedField {
|
||||||
|
source: "identity",
|
||||||
|
value,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ResolvedField {
|
||||||
|
source: "default",
|
||||||
|
value: default,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let name = field(
|
||||||
|
git.and_then(|git| git.name.clone()),
|
||||||
|
identity.name.clone(),
|
||||||
|
DEFAULT_NAME.to_owned(),
|
||||||
|
);
|
||||||
|
let email = field(
|
||||||
|
git.and_then(|git| git.email.clone()),
|
||||||
|
identity.email.clone(),
|
||||||
|
format!("{}@{}", DEFAULT_NAME, hostname),
|
||||||
|
);
|
||||||
|
(name, email)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The boot entry point: opens the stores the daemon built, resolves,
|
||||||
|
/// provisions, and returns the log line. Nothing here is fatal — every
|
||||||
|
/// failure becomes the line the caller prints.
|
||||||
|
pub fn boot(config: &ClawConfig) -> String {
|
||||||
|
let outcome = (|| -> Result<String, String> {
|
||||||
|
let file = global_file().ok_or("no home directory known, nowhere to write")?;
|
||||||
|
let db = config.db_path().map_err(|err| err.to_string())?;
|
||||||
|
let settings = Arc::new(SettingsStore::open(&db).map_err(|err| err.to_string())?);
|
||||||
|
let dir = db
|
||||||
|
.parent()
|
||||||
|
.ok_or("the database has no parent directory")?
|
||||||
|
.join("identity");
|
||||||
|
let who = IdentityStore::new(settings.clone(), dir)
|
||||||
|
.get()
|
||||||
|
.map_err(|err| err.to_string())?;
|
||||||
|
Ok(provision_at(&file, config.git.as_ref(), &who, &settings))
|
||||||
|
})();
|
||||||
|
outcome.unwrap_or_else(|reason| format!("git identity not provisioned: {reason}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The global git config the daemon user's `git` reads: the
|
||||||
|
/// `GIT_CONFIG_GLOBAL` override when set (git's own precedence), else
|
||||||
|
/// `.gitconfig` in the home the family's XDG discovery resolves.
|
||||||
|
pub fn global_file() -> Option<PathBuf> {
|
||||||
|
if let Ok(path) = std::env::var("GIT_CONFIG_GLOBAL")
|
||||||
|
&& !path.trim().is_empty()
|
||||||
|
{
|
||||||
|
return Some(PathBuf::from(path));
|
||||||
|
}
|
||||||
|
rhema_config::Home::discover()
|
||||||
|
.ok()
|
||||||
|
.map(|home| home.home.join(".gitconfig"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provisions both fields against one git config file, and returns the
|
||||||
|
/// log line. The guard is per field: a hand-edited name beside an
|
||||||
|
/// email the daemon wrote is updated on the email side and left alone
|
||||||
|
/// on the name side.
|
||||||
|
pub fn provision_at(
|
||||||
|
file: &Path,
|
||||||
|
git: Option<&GitIdentity>,
|
||||||
|
identity: &AgentIdentity,
|
||||||
|
settings: &SettingsStore,
|
||||||
|
) -> String {
|
||||||
|
let (name, email) = resolve(git, identity, &crate::environment::hostname());
|
||||||
|
let mut parts = Vec::new();
|
||||||
|
field(file, "user.name", WRITTEN_NAME, &name, settings, &mut parts);
|
||||||
|
field(
|
||||||
|
file,
|
||||||
|
"user.email",
|
||||||
|
WRITTEN_EMAIL,
|
||||||
|
&email,
|
||||||
|
settings,
|
||||||
|
&mut parts,
|
||||||
|
);
|
||||||
|
format!("git identity: {}", parts.join(", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One field's guard, write, and log phrase:
|
||||||
|
/// - the config file holds someone else's value → kept, untouched;
|
||||||
|
/// - it already holds the resolved value → aligned (the marker too,
|
||||||
|
/// so a later resolution can still update it — a hand edit that
|
||||||
|
/// matches what the daemon resolved counts as the daemon's);
|
||||||
|
/// - it is unset, or it is exactly what the daemon wrote last time →
|
||||||
|
/// written, and the marker follows.
|
||||||
|
fn field(
|
||||||
|
file: &Path,
|
||||||
|
key: &str,
|
||||||
|
setting_key: &str,
|
||||||
|
want: &ResolvedField,
|
||||||
|
settings: &SettingsStore,
|
||||||
|
parts: &mut Vec<String>,
|
||||||
|
) {
|
||||||
|
let mut summary = |action: String| {
|
||||||
|
parts.push(format!(
|
||||||
|
"{} {:?} from {}: {}",
|
||||||
|
key.rsplit_once('.').map(|(_, n)| n).unwrap_or(key),
|
||||||
|
want.value,
|
||||||
|
want.source,
|
||||||
|
action
|
||||||
|
))
|
||||||
|
};
|
||||||
|
let written = settings.get(setting_key).ok().flatten();
|
||||||
|
match read(file, key) {
|
||||||
|
Err(reason) => summary(format!("unreadable ({reason}), left alone")),
|
||||||
|
Ok(Some(current))
|
||||||
|
if Some(current.as_str()) != written.as_deref() && current != want.value =>
|
||||||
|
{
|
||||||
|
summary("kept a hand-edited value".to_owned())
|
||||||
|
}
|
||||||
|
Ok(Some(current)) if current == want.value => {
|
||||||
|
if written.as_deref() != Some(current.as_str()) {
|
||||||
|
record(settings, setting_key, ¤t);
|
||||||
|
}
|
||||||
|
summary("already current".to_owned())
|
||||||
|
}
|
||||||
|
Ok(_) => match write(file, key, &want.value) {
|
||||||
|
Ok(()) => {
|
||||||
|
record(settings, setting_key, &want.value);
|
||||||
|
summary("wrote".to_owned())
|
||||||
|
}
|
||||||
|
Err(reason) => summary(format!("not written ({reason})")),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Records the pair the daemon wrote, so the next boot can tell its
|
||||||
|
/// own values from a hand edit. A store failure leaves the guard
|
||||||
|
/// conservative: the field reads as foreign next boot and is kept.
|
||||||
|
fn record(settings: &SettingsStore, key: &str, value: &str) {
|
||||||
|
let _ = settings.set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One `git` invocation: fixed argv, no shell, stdin null, a short
|
||||||
|
/// budget. The exit code travels — a read's `1` means the key is
|
||||||
|
/// unset, which is an answer, not an error.
|
||||||
|
enum GitRun {
|
||||||
|
Completed { code: i32, stdout: String },
|
||||||
|
NotFound,
|
||||||
|
TimedOut,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn git(args: &[&str]) -> GitRun {
|
||||||
|
let mut child = match Command::new("git")
|
||||||
|
.args(args)
|
||||||
|
.stdin(Stdio::null())
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
{
|
||||||
|
Ok(child) => child,
|
||||||
|
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return GitRun::NotFound,
|
||||||
|
Err(_) => return GitRun::NotFound,
|
||||||
|
};
|
||||||
|
let deadline = Instant::now() + GIT_BUDGET;
|
||||||
|
let code = loop {
|
||||||
|
match child.try_wait() {
|
||||||
|
Ok(Some(status)) => break status.code(),
|
||||||
|
Ok(None) if Instant::now() >= deadline => break None,
|
||||||
|
Ok(None) => std::thread::sleep(Duration::from_millis(10)),
|
||||||
|
Err(_) => break None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let Some(code) = code else {
|
||||||
|
let _ = child.kill();
|
||||||
|
let _ = child.wait();
|
||||||
|
return GitRun::TimedOut;
|
||||||
|
};
|
||||||
|
let stdout = child
|
||||||
|
.stdout
|
||||||
|
.take()
|
||||||
|
.map(|mut pipe| {
|
||||||
|
let mut buf = Vec::new();
|
||||||
|
use std::io::Read;
|
||||||
|
let _ = pipe.read_to_end(&mut buf);
|
||||||
|
String::from_utf8_lossy(&buf).into_owned()
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
GitRun::Completed { code, stdout }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads one key from the config file: `Some` when set, `None` when
|
||||||
|
/// unset (git exits 1 for that), an error when the read cannot be
|
||||||
|
/// trusted (a missing git, a multi-valued key) — and an untrusted read
|
||||||
|
/// is never written over.
|
||||||
|
fn read(file: &Path, key: &str) -> Result<Option<String>, String> {
|
||||||
|
match git(&["config", "--file", &file.to_string_lossy(), "--get", key]) {
|
||||||
|
GitRun::Completed { code: 0, stdout } => {
|
||||||
|
Ok(Some(stdout.trim().to_owned()).filter(|value| !value.is_empty()))
|
||||||
|
}
|
||||||
|
GitRun::Completed { code: 1, .. } => Ok(None),
|
||||||
|
GitRun::Completed { code, .. } => Err(format!("exit {code}")),
|
||||||
|
GitRun::NotFound => Err("git not found".to_owned()),
|
||||||
|
GitRun::TimedOut => Err("no exit in time".to_owned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes one key into the config file, replacing every value the key
|
||||||
|
/// carries (`--replace-all` keeps the field single-valued even over a
|
||||||
|
/// strange starting file).
|
||||||
|
fn write(file: &Path, key: &str, value: &str) -> Result<(), String> {
|
||||||
|
match git(&[
|
||||||
|
"config",
|
||||||
|
"--file",
|
||||||
|
&file.to_string_lossy(),
|
||||||
|
"--replace-all",
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
]) {
|
||||||
|
GitRun::Completed { code: 0, .. } => Ok(()),
|
||||||
|
GitRun::Completed { code, .. } => Err(format!("exit {code}")),
|
||||||
|
GitRun::NotFound => Err("git not found".to_owned()),
|
||||||
|
GitRun::TimedOut => Err("no exit in time".to_owned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::config::GitIdentity;
|
||||||
|
use crate::identity::IdentityTexts;
|
||||||
|
|
||||||
|
/// The fixture: a temp config file, an in-memory settings store,
|
||||||
|
/// and a fresh store handle per test.
|
||||||
|
struct Fixture {
|
||||||
|
file: PathBuf,
|
||||||
|
settings: SettingsStore,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
dir: tempfile::TempDir,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fixture() -> Fixture {
|
||||||
|
let dir = tempfile::tempdir().expect("tempdir");
|
||||||
|
let file = dir.path().join("gitconfig");
|
||||||
|
Fixture {
|
||||||
|
file,
|
||||||
|
settings: SettingsStore::in_memory().expect("the store opens"),
|
||||||
|
dir,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn identity(name: Option<&str>, email: Option<&str>) -> AgentIdentity {
|
||||||
|
let store_settings = crate::settings::SettingsStore::in_memory().expect("the store opens");
|
||||||
|
let images = tempfile::tempdir().expect("tempdir");
|
||||||
|
let store = IdentityStore::new(Arc::new(store_settings), images.path().join("identity"));
|
||||||
|
store
|
||||||
|
.set_texts(&IdentityTexts {
|
||||||
|
name: name.map(str::to_owned),
|
||||||
|
mark: None,
|
||||||
|
initials: None,
|
||||||
|
tagline: None,
|
||||||
|
signoff: None,
|
||||||
|
email: email.map(str::to_owned),
|
||||||
|
})
|
||||||
|
.expect("the identity saves")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn config_git(name: Option<&str>, email: Option<&str>) -> Option<GitIdentity> {
|
||||||
|
Some(GitIdentity {
|
||||||
|
name: name.map(str::to_owned),
|
||||||
|
email: email.map(str::to_owned),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn value_of(file: &Path, key: &str) -> Option<String> {
|
||||||
|
read(file, key).expect("the key reads")
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn defaults_land_when_nothing_is_set() {
|
||||||
|
let fix = fixture();
|
||||||
|
let who = identity(None, None);
|
||||||
|
let line = provision_at(&fix.file, None, &who, &fix.settings);
|
||||||
|
assert_eq!(value_of(&fix.file, "user.name").as_deref(), Some("claw"));
|
||||||
|
assert_eq!(
|
||||||
|
value_of(&fix.file, "user.email").as_deref(),
|
||||||
|
Some(format!("claw@{}", crate::environment::hostname()).as_str()),
|
||||||
|
);
|
||||||
|
assert!(line.contains("from default"), "{line}");
|
||||||
|
assert!(line.contains("wrote"), "{line}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn config_beats_identity_beats_default() {
|
||||||
|
let fix = fixture();
|
||||||
|
let who = identity(Some("Kosmos"), Some("kosmos@example.net"));
|
||||||
|
provision_at(
|
||||||
|
&fix.file,
|
||||||
|
config_git(Some("Bot"), None).as_ref(),
|
||||||
|
&who,
|
||||||
|
&fix.settings,
|
||||||
|
);
|
||||||
|
assert_eq!(value_of(&fix.file, "user.name").as_deref(), Some("Bot"));
|
||||||
|
assert_eq!(
|
||||||
|
value_of(&fix.file, "user.email").as_deref(),
|
||||||
|
Some("kosmos@example.net"),
|
||||||
|
"the fields resolve independently"
|
||||||
|
);
|
||||||
|
|
||||||
|
let other = fixture();
|
||||||
|
provision_at(&other.file, None, &who, &other.settings);
|
||||||
|
assert_eq!(
|
||||||
|
value_of(&other.file, "user.name").as_deref(),
|
||||||
|
Some("Kosmos")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_hand_edited_value_wins_and_is_recorded_as_foreign() {
|
||||||
|
let fix = fixture();
|
||||||
|
write(&fix.file, "user.name", "The Operator").expect("the seed writes");
|
||||||
|
let who = identity(Some("Kosmos"), None);
|
||||||
|
let line = provision_at(&fix.file, None, &who, &fix.settings);
|
||||||
|
assert_eq!(
|
||||||
|
value_of(&fix.file, "user.name").as_deref(),
|
||||||
|
Some("The Operator")
|
||||||
|
);
|
||||||
|
assert!(line.contains("kept"), "{line}");
|
||||||
|
// The daemon did not write it, so no marker was recorded.
|
||||||
|
assert_eq!(fix.settings.get(WRITTEN_NAME).unwrap(), None);
|
||||||
|
// The unset email beside it still provisions: the guard is per field.
|
||||||
|
assert!(value_of(&fix.file, "user.email").is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reruns_update_what_the_daemon_wrote() {
|
||||||
|
let fix = fixture();
|
||||||
|
let first = identity(Some("Kosmos"), None);
|
||||||
|
provision_at(&fix.file, None, &first, &fix.settings);
|
||||||
|
let second = identity(Some("Kosmos Prime"), None);
|
||||||
|
let line = provision_at(&fix.file, None, &second, &fix.settings);
|
||||||
|
assert_eq!(
|
||||||
|
value_of(&fix.file, "user.name").as_deref(),
|
||||||
|
Some("Kosmos Prime"),
|
||||||
|
"the daemon rewrites its own values"
|
||||||
|
);
|
||||||
|
assert!(line.contains("wrote"), "{line}");
|
||||||
|
|
||||||
|
// And a rerun over an already-current pair is a no-op.
|
||||||
|
let before = std::fs::read_to_string(&fix.file).expect("the file reads");
|
||||||
|
let line = provision_at(&fix.file, None, &second, &fix.settings);
|
||||||
|
let after = std::fs::read_to_string(&fix.file).expect("the file reads");
|
||||||
|
assert_eq!(before, after, "nothing to do, nothing written");
|
||||||
|
assert!(line.contains("already current"), "{line}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_config_change_flows_through_on_the_next_boot() {
|
||||||
|
let fix = fixture();
|
||||||
|
let who = identity(None, None);
|
||||||
|
provision_at(
|
||||||
|
&fix.file,
|
||||||
|
config_git(Some("Bot"), Some("bot@example.net")).as_ref(),
|
||||||
|
&who,
|
||||||
|
&fix.settings,
|
||||||
|
);
|
||||||
|
provision_at(
|
||||||
|
&fix.file,
|
||||||
|
config_git(Some("Renamed"), Some("moved@example.net")).as_ref(),
|
||||||
|
&who,
|
||||||
|
&fix.settings,
|
||||||
|
);
|
||||||
|
assert_eq!(value_of(&fix.file, "user.name").as_deref(), Some("Renamed"));
|
||||||
|
assert_eq!(
|
||||||
|
value_of(&fix.file, "user.email").as_deref(),
|
||||||
|
Some("moved@example.net"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_hand_edit_that_matches_the_resolution_counts_as_the_daemons() {
|
||||||
|
let fix = fixture();
|
||||||
|
let who = identity(Some("Kosmos"), None);
|
||||||
|
write(&fix.file, "user.name", "Kosmos").expect("the seed writes");
|
||||||
|
provision_at(&fix.file, None, &who, &fix.settings);
|
||||||
|
// The marker was aligned, so a later resolution updates the field.
|
||||||
|
let renamed = identity(Some("Kosmos II"), None);
|
||||||
|
provision_at(&fix.file, None, &renamed, &fix.settings);
|
||||||
|
assert_eq!(
|
||||||
|
value_of(&fix.file, "user.name").as_deref(),
|
||||||
|
Some("Kosmos II")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2307,6 +2307,7 @@ async fn agent_put(
|
|||||||
};
|
};
|
||||||
let texts = crate::identity::IdentityTexts {
|
let texts = crate::identity::IdentityTexts {
|
||||||
name: field(body["name"].as_str(), ¤t.name),
|
name: field(body["name"].as_str(), ¤t.name),
|
||||||
|
email: field(body["email"].as_str(), ¤t.email),
|
||||||
mark: field(body["mark"].as_str(), ¤t.mark),
|
mark: field(body["mark"].as_str(), ¤t.mark),
|
||||||
initials: field(body["initials"].as_str(), ¤t.initials),
|
initials: field(body["initials"].as_str(), ¤t.initials),
|
||||||
tagline: field(body["tagline"].as_str(), ¤t.tagline),
|
tagline: field(body["tagline"].as_str(), ¤t.tagline),
|
||||||
|
|||||||
@@ -44,9 +44,13 @@ pub const MAX_IMAGE_BYTES: usize = 2 * 1024 * 1024;
|
|||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct AgentIdentity {
|
pub struct AgentIdentity {
|
||||||
/// The agent's display name: message author, window title,
|
/// The agent's display name: message author, window title,
|
||||||
/// notifications.
|
/// notifications, and the commit author name in workspaces.
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
|
/// The address commits carry in workspaces; also the mail-like
|
||||||
|
/// identity other surfaces may quote.
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub email: Option<String>,
|
||||||
/// The glyph or emoji in the rail, the favicon, the empty states.
|
/// The glyph or emoji in the rail, the favicon, the empty states.
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub mark: Option<String>,
|
pub mark: Option<String>,
|
||||||
@@ -69,6 +73,7 @@ pub struct AgentIdentity {
|
|||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct IdentityTexts {
|
pub struct IdentityTexts {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
|
pub email: Option<String>,
|
||||||
pub mark: Option<String>,
|
pub mark: Option<String>,
|
||||||
pub initials: Option<String>,
|
pub initials: Option<String>,
|
||||||
pub tagline: Option<String>,
|
pub tagline: Option<String>,
|
||||||
@@ -120,6 +125,7 @@ impl IdentityStore {
|
|||||||
pub fn get(&self) -> Result<AgentIdentity, IdentityError> {
|
pub fn get(&self) -> Result<AgentIdentity, IdentityError> {
|
||||||
Ok(AgentIdentity {
|
Ok(AgentIdentity {
|
||||||
name: self.text("name")?,
|
name: self.text("name")?,
|
||||||
|
email: self.text("email")?,
|
||||||
mark: self.text("mark")?,
|
mark: self.text("mark")?,
|
||||||
initials: self.text("initials")?,
|
initials: self.text("initials")?,
|
||||||
tagline: self.text("tagline")?,
|
tagline: self.text("tagline")?,
|
||||||
@@ -135,6 +141,7 @@ impl IdentityStore {
|
|||||||
pub fn set_texts(&self, texts: &IdentityTexts) -> Result<AgentIdentity, IdentityError> {
|
pub fn set_texts(&self, texts: &IdentityTexts) -> Result<AgentIdentity, IdentityError> {
|
||||||
let fields = [
|
let fields = [
|
||||||
("name", &texts.name, 64usize),
|
("name", &texts.name, 64usize),
|
||||||
|
("email", &texts.email, 120),
|
||||||
("mark", &texts.mark, 8),
|
("mark", &texts.mark, 8),
|
||||||
("initials", &texts.initials, 4),
|
("initials", &texts.initials, 4),
|
||||||
("tagline", &texts.tagline, 120),
|
("tagline", &texts.tagline, 120),
|
||||||
@@ -263,6 +270,7 @@ impl ToolOp for IdentitySet {
|
|||||||
};
|
};
|
||||||
let texts = IdentityTexts {
|
let texts = IdentityTexts {
|
||||||
name: field(args["name"].as_str(), current.name.as_deref()),
|
name: field(args["name"].as_str(), current.name.as_deref()),
|
||||||
|
email: field(args["email"].as_str(), current.email.as_deref()),
|
||||||
mark: field(args["mark"].as_str(), current.mark.as_deref()),
|
mark: field(args["mark"].as_str(), current.mark.as_deref()),
|
||||||
initials: field(args["initials"].as_str(), current.initials.as_deref()),
|
initials: field(args["initials"].as_str(), current.initials.as_deref()),
|
||||||
tagline: field(args["tagline"].as_str(), current.tagline.as_deref()),
|
tagline: field(args["tagline"].as_str(), current.tagline.as_deref()),
|
||||||
@@ -393,6 +401,7 @@ mod tests {
|
|||||||
let saved = store
|
let saved = store
|
||||||
.set_texts(&IdentityTexts {
|
.set_texts(&IdentityTexts {
|
||||||
name: Some(" Kosmos ".to_owned()),
|
name: Some(" Kosmos ".to_owned()),
|
||||||
|
email: Some("kosmos@example.net".to_owned()),
|
||||||
mark: Some("✦".to_owned()),
|
mark: Some("✦".to_owned()),
|
||||||
initials: None,
|
initials: None,
|
||||||
tagline: Some("order".to_owned()),
|
tagline: Some("order".to_owned()),
|
||||||
@@ -400,6 +409,7 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.expect("the texts save");
|
.expect("the texts save");
|
||||||
assert_eq!(saved.name.as_deref(), Some("Kosmos"), "trimmed");
|
assert_eq!(saved.name.as_deref(), Some("Kosmos"), "trimmed");
|
||||||
|
assert_eq!(saved.email.as_deref(), Some("kosmos@example.net"));
|
||||||
assert_eq!(saved.mark.as_deref(), Some("✦"));
|
assert_eq!(saved.mark.as_deref(), Some("✦"));
|
||||||
assert_eq!(saved.initials, None);
|
assert_eq!(saved.initials, None);
|
||||||
assert_eq!(saved.signoff, None, "an empty string clears");
|
assert_eq!(saved.signoff, None, "an empty string clears");
|
||||||
@@ -409,6 +419,7 @@ mod tests {
|
|||||||
.set_texts(&IdentityTexts::default())
|
.set_texts(&IdentityTexts::default())
|
||||||
.expect("the clear saves");
|
.expect("the clear saves");
|
||||||
assert_eq!(cleared.name, None);
|
assert_eq!(cleared.name, None);
|
||||||
|
assert_eq!(cleared.email, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -485,6 +496,7 @@ mod tests {
|
|||||||
let answer = tool
|
let answer = tool
|
||||||
.invoke(json!({
|
.invoke(json!({
|
||||||
"name": "Kosmos",
|
"name": "Kosmos",
|
||||||
|
"email": "kosmos@example.net",
|
||||||
"mark": "✦",
|
"mark": "✦",
|
||||||
"avatar": "face.png",
|
"avatar": "face.png",
|
||||||
}))
|
}))
|
||||||
@@ -493,6 +505,7 @@ mod tests {
|
|||||||
let answer: Value = serde_json::from_str(&answer).expect("parses");
|
let answer: Value = serde_json::from_str(&answer).expect("parses");
|
||||||
assert_eq!(answer["saved"], true);
|
assert_eq!(answer["saved"], true);
|
||||||
assert_eq!(answer["identity"]["name"], "Kosmos");
|
assert_eq!(answer["identity"]["name"], "Kosmos");
|
||||||
|
assert_eq!(answer["identity"]["email"], "kosmos@example.net");
|
||||||
assert_eq!(answer["identity"]["avatar"], true);
|
assert_eq!(answer["identity"]["avatar"], true);
|
||||||
let (bytes, content_type) = store
|
let (bytes, content_type) = store
|
||||||
.image(ImageKind::Avatar)
|
.image(ImageKind::Avatar)
|
||||||
@@ -506,6 +519,11 @@ mod tests {
|
|||||||
.expect("saves");
|
.expect("saves");
|
||||||
let identity = store.get().expect("reads");
|
let identity = store.get().expect("reads");
|
||||||
assert_eq!(identity.name.as_deref(), Some("Kosmos"), "kept");
|
assert_eq!(identity.name.as_deref(), Some("Kosmos"), "kept");
|
||||||
|
assert_eq!(
|
||||||
|
identity.email.as_deref(),
|
||||||
|
Some("kosmos@example.net"),
|
||||||
|
"kept"
|
||||||
|
);
|
||||||
assert_eq!(identity.tagline.as_deref(), Some("order"), "added");
|
assert_eq!(identity.tagline.as_deref(), Some("order"), "added");
|
||||||
assert!(identity.avatar, "untouched by a text-only save");
|
assert!(identity.avatar, "untouched by a text-only save");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,13 @@
|
|||||||
//! - [`turn_store`] — the turn-history table: what each key's stream
|
//! - [`turn_store`] — the turn-history table: what each key's stream
|
||||||
//! streamed, appended per event, replayed whole after a restart
|
//! streamed, appended per event, replayed whole after a restart
|
||||||
//! - [`hub`] — the event hub: per-key record and broadcast of turn events
|
//! - [`hub`] — the event hub: per-key record and broadcast of turn events
|
||||||
//! - [`identity`] — the agent's presentation identity: name, mark,
|
//! - [`identity`] — the agent's presentation identity: name, email,
|
||||||
//! images, served over `/v1/agent` and settable by the agent itself
|
//! mark, images, served over `/v1/agent` and settable by the agent
|
||||||
//! through the `identity_set` tool
|
//! itself through the `identity_set` tool
|
||||||
|
//! - [`git_identity`] — the boot-time git identity: `user.name` and
|
||||||
|
//! `user.email` into the daemon user's global git config, resolved
|
||||||
|
//! from config, then identity, then defaults, guarded against
|
||||||
|
//! hand-edited values
|
||||||
//! - [`consents`] — the consent table and wake bridge: a running turn
|
//! - [`consents`] — the consent table and wake bridge: a running turn
|
||||||
//! asks the human (a secret to store, permission to act) and waits;
|
//! asks the human (a secret to store, permission to act) and waits;
|
||||||
//! the chat surface answers through the consent routes
|
//! the chat surface answers through the consent routes
|
||||||
@@ -76,6 +80,7 @@ pub mod daemon;
|
|||||||
pub mod environment;
|
pub mod environment;
|
||||||
pub mod extension;
|
pub mod extension;
|
||||||
pub mod forge;
|
pub mod forge;
|
||||||
|
pub mod git_identity;
|
||||||
pub mod handler;
|
pub mod handler;
|
||||||
pub mod http;
|
pub mod http;
|
||||||
pub mod hub;
|
pub mod hub;
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ async fn run(args: Args) -> Result<(), ClawError> {
|
|||||||
} else {
|
} else {
|
||||||
resolve_backends(&config)?
|
resolve_backends(&config)?
|
||||||
};
|
};
|
||||||
|
// The workspace git identity: written in both shapes (a cron pass
|
||||||
|
// commits too), from deterministic boot code, guarded against
|
||||||
|
// hand-edited values. Never fatal — provisioning problems are the
|
||||||
|
// one stderr line this prints.
|
||||||
|
eprintln!("[claw] {}", rhema_claw::git_identity::boot(&config));
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"[claw] active {}/{}, db {}, http {}",
|
"[claw] active {}/{}, db {}, http {}",
|
||||||
backends.active().0,
|
backends.active().0,
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ fn config(dir: &tempfile::TempDir) -> ClawConfig {
|
|||||||
transcript: None,
|
transcript: None,
|
||||||
ingest_token: None,
|
ingest_token: None,
|
||||||
sandbox: None,
|
sandbox: None,
|
||||||
|
git: None,
|
||||||
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ fn config(dir: &tempfile::TempDir) -> ClawConfig {
|
|||||||
transcript: None,
|
transcript: None,
|
||||||
ingest_token: None,
|
ingest_token: None,
|
||||||
sandbox: None,
|
sandbox: None,
|
||||||
|
git: None,
|
||||||
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ fn config(dir: &tempfile::TempDir, token: Option<&str>) -> ClawConfig {
|
|||||||
ingest_token: None,
|
ingest_token: None,
|
||||||
transcript: None,
|
transcript: None,
|
||||||
sandbox: None,
|
sandbox: None,
|
||||||
|
git: None,
|
||||||
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2521,7 +2522,7 @@ async fn the_agent_identity_is_editable_over_the_surface() {
|
|||||||
// A save names the fields it touches.
|
// A save names the fields it touches.
|
||||||
let saved: Value = client
|
let saved: Value = client
|
||||||
.put(format!("{base}/v1/agent"))
|
.put(format!("{base}/v1/agent"))
|
||||||
.json(&json!({"name": "Kosmos", "mark": "✦", "tagline": "order"}))
|
.json(&json!({"name": "Kosmos", "email": "kosmos@example.net", "mark": "✦", "tagline": "order"}))
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.expect("the save posts")
|
.expect("the save posts")
|
||||||
@@ -2530,6 +2531,7 @@ async fn the_agent_identity_is_editable_over_the_surface() {
|
|||||||
.expect("the save parses");
|
.expect("the save parses");
|
||||||
assert_eq!(saved["name"], "Kosmos");
|
assert_eq!(saved["name"], "Kosmos");
|
||||||
assert_eq!(saved["mark"], "✦");
|
assert_eq!(saved["mark"], "✦");
|
||||||
|
assert_eq!(saved["email"], "kosmos@example.net");
|
||||||
assert_eq!(saved["avatar"], false);
|
assert_eq!(saved["avatar"], false);
|
||||||
|
|
||||||
// A partial save leaves the fields it omitted.
|
// A partial save leaves the fields it omitted.
|
||||||
@@ -2544,6 +2546,10 @@ async fn the_agent_identity_is_editable_over_the_surface() {
|
|||||||
.expect("the partial save parses");
|
.expect("the partial save parses");
|
||||||
assert_eq!(partial["name"], "Kosmos Prime");
|
assert_eq!(partial["name"], "Kosmos Prime");
|
||||||
assert_eq!(partial["mark"], "✦", "untouched by the partial save");
|
assert_eq!(partial["mark"], "✦", "untouched by the partial save");
|
||||||
|
assert_eq!(
|
||||||
|
partial["email"], "kosmos@example.net",
|
||||||
|
"untouched by the partial save"
|
||||||
|
);
|
||||||
|
|
||||||
// An empty string clears its field.
|
// An empty string clears its field.
|
||||||
let cleared: Value = client
|
let cleared: Value = client
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ fn config(dir: &tempfile::TempDir) -> ClawConfig {
|
|||||||
transcript: None,
|
transcript: None,
|
||||||
ingest_token: None,
|
ingest_token: None,
|
||||||
sandbox: None,
|
sandbox: None,
|
||||||
|
git: None,
|
||||||
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
disabled_mcp_servers: std::collections::BTreeSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
name: identity_set
|
name: identity_set
|
||||||
description: >-
|
description: >-
|
||||||
Set your own presentation identity: the name, mark, initials,
|
Set your own presentation identity: the name, mark, initials,
|
||||||
tagline, and signoff the interfaces render, and your avatar or logo
|
tagline, and signoff the interfaces render, an email to commit and
|
||||||
images. This is how you look, not who you are — personality lives in
|
write as, and your avatar or logo images. This is how you look, not
|
||||||
SOUL.md. Leave a field out to keep what is set; an empty string
|
who you are — personality lives in SOUL.md. Leave a field out to
|
||||||
clears it. The avatar and logo take a workspace-relative path to an
|
keep what is set; an empty string clears it. The avatar and logo
|
||||||
image file (png, jpeg, gif, or webp, under 2 MiB — svg is refused).
|
take a workspace-relative path to an image file (png, jpeg, gif, or
|
||||||
|
webp, under 2 MiB — svg is refused).
|
||||||
parameters:
|
parameters:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -16,6 +17,11 @@ parameters:
|
|||||||
description: >-
|
description: >-
|
||||||
Display name: message author, window title, notifications. Up
|
Display name: message author, window title, notifications. Up
|
||||||
to 64 chars.
|
to 64 chars.
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
description: >-
|
||||||
|
The author address on the commits your workspaces make. Up to
|
||||||
|
120 chars.
|
||||||
mark:
|
mark:
|
||||||
type: string
|
type: string
|
||||||
description: Glyph or emoji for the rail and favicon. Up to 8 chars.
|
description: Glyph or emoji for the rail and favicon. Up to 8 chars.
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ config:
|
|||||||
# - forge: github
|
# - forge: github
|
||||||
# repo: acme/widgets
|
# repo: acme/widgets
|
||||||
watches: []
|
watches: []
|
||||||
|
# The git identity the daemon writes into its user's global git
|
||||||
|
# config at boot, so workspace commits carry the agent as author.
|
||||||
|
# A field set here wins over the agent's own identity (Agent ·
|
||||||
|
# General in the UI); values the daemon did not write are left
|
||||||
|
# alone. Example:
|
||||||
|
# git:
|
||||||
|
# name: claw
|
||||||
|
# email: claw@example.net
|
||||||
|
|
||||||
service:
|
service:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const emit = defineEmits<{
|
|||||||
// The draft: '' means "clear this field", matching the wire.
|
// The draft: '' means "clear this field", matching the wire.
|
||||||
const draft = ref<IdentityTexts>({
|
const draft = ref<IdentityTexts>({
|
||||||
name: '',
|
name: '',
|
||||||
|
email: '',
|
||||||
mark: '',
|
mark: '',
|
||||||
initials: '',
|
initials: '',
|
||||||
tagline: '',
|
tagline: '',
|
||||||
@@ -35,6 +36,7 @@ const dirty = computed(() => {
|
|||||||
if (!identity) return false
|
if (!identity) return false
|
||||||
return (
|
return (
|
||||||
draft.value.name !== (identity.name ?? '') ||
|
draft.value.name !== (identity.name ?? '') ||
|
||||||
|
draft.value.email !== (identity.email ?? '') ||
|
||||||
draft.value.mark !== (identity.mark ?? '') ||
|
draft.value.mark !== (identity.mark ?? '') ||
|
||||||
draft.value.initials !== (identity.initials ?? '') ||
|
draft.value.initials !== (identity.initials ?? '') ||
|
||||||
draft.value.tagline !== (identity.tagline ?? '') ||
|
draft.value.tagline !== (identity.tagline ?? '') ||
|
||||||
@@ -47,6 +49,7 @@ function discard(): void {
|
|||||||
if (!identity) return
|
if (!identity) return
|
||||||
draft.value = {
|
draft.value = {
|
||||||
name: identity.name ?? '',
|
name: identity.name ?? '',
|
||||||
|
email: identity.email ?? '',
|
||||||
mark: identity.mark ?? '',
|
mark: identity.mark ?? '',
|
||||||
initials: identity.initials ?? '',
|
initials: identity.initials ?? '',
|
||||||
tagline: identity.tagline ?? '',
|
tagline: identity.tagline ?? '',
|
||||||
@@ -66,6 +69,7 @@ watch(
|
|||||||
initialized.value = true
|
initialized.value = true
|
||||||
draft.value = {
|
draft.value = {
|
||||||
name: identity.name ?? '',
|
name: identity.name ?? '',
|
||||||
|
email: identity.email ?? '',
|
||||||
mark: identity.mark ?? '',
|
mark: identity.mark ?? '',
|
||||||
initials: identity.initials ?? '',
|
initials: identity.initials ?? '',
|
||||||
tagline: identity.tagline ?? '',
|
tagline: identity.tagline ?? '',
|
||||||
@@ -97,6 +101,7 @@ function onImageChosen(kind: AgentImageKind, event: Event): void {
|
|||||||
|
|
||||||
const CAPS: Record<keyof IdentityTexts, number> = {
|
const CAPS: Record<keyof IdentityTexts, number> = {
|
||||||
name: 64,
|
name: 64,
|
||||||
|
email: 120,
|
||||||
mark: 8,
|
mark: 8,
|
||||||
initials: 4,
|
initials: 4,
|
||||||
tagline: 120,
|
tagline: 120,
|
||||||
@@ -142,7 +147,7 @@ const CAPS: Record<keyof IdentityTexts, number> = {
|
|||||||
<SettingCard v-if="identity" title="Agent identity">
|
<SettingCard v-if="identity" title="Agent identity">
|
||||||
<SettingRow
|
<SettingRow
|
||||||
title="Display name"
|
title="Display name"
|
||||||
description="Shown as the author of messages, in the window title, and in notifications."
|
description="Shown as the author of messages, in the window title, in notifications, and as the author name on commits in workspaces."
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="draft.name"
|
v-model="draft.name"
|
||||||
@@ -153,6 +158,19 @@ const CAPS: Record<keyof IdentityTexts, number> = {
|
|||||||
:disabled="saving"
|
:disabled="saving"
|
||||||
/>
|
/>
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
|
<SettingRow
|
||||||
|
title="Email"
|
||||||
|
description="The author address on commits the agent makes in its workspaces."
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="draft.email"
|
||||||
|
type="email"
|
||||||
|
:maxlength="CAPS.email"
|
||||||
|
placeholder="claw@example.net"
|
||||||
|
autocomplete="off"
|
||||||
|
:disabled="saving"
|
||||||
|
/>
|
||||||
|
</SettingRow>
|
||||||
<SettingRow
|
<SettingRow
|
||||||
title="Mark"
|
title="Mark"
|
||||||
description="The glyph or emoji in the rail and the empty states. Defaults to ῥ."
|
description="The glyph or emoji in the rail and the empty states. Defaults to ῥ."
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ export interface ProvidersState {
|
|||||||
* unset text fields read as null, the images report presence. */
|
* unset text fields read as null, the images report presence. */
|
||||||
export interface AgentIdentity {
|
export interface AgentIdentity {
|
||||||
name: string | null
|
name: string | null
|
||||||
|
email: string | null
|
||||||
mark: string | null
|
mark: string | null
|
||||||
initials: string | null
|
initials: string | null
|
||||||
tagline: string | null
|
tagline: string | null
|
||||||
@@ -204,6 +205,7 @@ export interface AgentIdentity {
|
|||||||
* string clears the field. */
|
* string clears the field. */
|
||||||
export interface IdentityTexts {
|
export interface IdentityTexts {
|
||||||
name: string
|
name: string
|
||||||
|
email: string
|
||||||
mark: string
|
mark: string
|
||||||
initials: string
|
initials: string
|
||||||
tagline: string
|
tagline: string
|
||||||
|
|||||||
Reference in new issue
Block a user