Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/buzz-acp/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ pub struct CliArgs {
#[arg(long, env = "BUZZ_ACP_RELAY_OBSERVER", default_value_t = false)]
pub relay_observer: bool,

/// Publish channel-visible redacted work status (NIP-AW kind 30181,
/// h = d = channel UUID): turn state, model id, and tool-call titles only.
#[arg(long, env = "BUZZ_ACP_PUBLIC_STATUS", default_value_t = false)]
pub public_status: bool,

/// Exit after this many seconds with no dispatched events and no turn in flight.
/// 0 disables inactivity self-termination.
#[arg(long, env = "BUZZ_ACP_EXIT_AFTER_INACTIVITY", default_value_t = 0)]
Expand Down Expand Up @@ -582,6 +587,8 @@ pub struct Config {
pub has_generated_codex_config: bool,
/// Whether to publish encrypted observer frames through the relay.
pub relay_observer: bool,
/// Whether to publish channel-visible redacted work status (NIP-AW kind 30181).
pub public_status: bool,
/// Seconds without dispatched events before an idle harness exits. 0 = disabled.
pub exit_after_inactivity_secs: u64,
/// Whether ACP/LLM subprocess initialization is deferred until accepted work arrives.
Expand Down Expand Up @@ -1137,6 +1144,7 @@ impl Config {
persona_env_vars,
has_generated_codex_config,
relay_observer: args.relay_observer,
public_status: args.public_status,
exit_after_inactivity_secs: args.exit_after_inactivity,
lazy_pool: args.lazy_pool,
idle_pool_sleep_secs: args.idle_pool_sleep,
Expand Down Expand Up @@ -1510,6 +1518,7 @@ mod tests {
persona_env_vars: vec![],
has_generated_codex_config: false,
relay_observer: false,
public_status: false,
exit_after_inactivity_secs: 0,
lazy_pool: false,
idle_pool_sleep_secs: 0,
Expand Down
22 changes: 19 additions & 3 deletions crates/buzz-acp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod filter;
mod observer;
mod pool;
mod pool_lifecycle;
mod public_status;
mod queue;
mod relay;
mod setup_mode;
Expand Down Expand Up @@ -1958,9 +1959,8 @@ async fn tokio_main() -> Result<()> {

tracing::info!("buzz-acp starting: {}", config.summary());

let observer = config
.relay_observer
.then(observer::ObserverHandle::in_process);
let observer =
(config.relay_observer || config.public_status).then(observer::ObserverHandle::in_process);
if let Some(handle) = &observer {
handle.emit(
"harness_started",
Expand Down Expand Up @@ -2162,6 +2162,17 @@ async fn tokio_main() -> Result<()> {
));
}

let mut public_status_task = None;
if config.public_status {
if let Some(observer) = observer.clone() {
public_status_task = Some(public_status::spawn_public_status_publisher(
observer,
relay.rest_client(),
));
tracing::info!("public work status enabled");
}
}

let runtime_start_nonce = std::env::var("BUZZ_MANAGED_AGENT_START_NONCE").unwrap_or_default();
let dedup_mode = config.dedup_mode;
let mut queue =
Expand Down Expand Up @@ -3525,6 +3536,9 @@ async fn tokio_main() -> Result<()> {
if let Some(handle) = relay_observer_publisher_task.take() {
handle.abort();
}
if let Some(handle) = public_status_task.take() {
handle.abort();
}

// Graceful relay shutdown — sends WebSocket close frame and waits up to 5s
// for the background task to finish, rather than aborting immediately (#40).
Expand Down Expand Up @@ -6792,6 +6806,7 @@ mod build_mcp_servers_tests {
persona_env_vars: vec![],
has_generated_codex_config: false,
relay_observer: false,
public_status: false,
exit_after_inactivity_secs: 0,
lazy_pool: false,
idle_pool_sleep_secs: 0,
Expand Down Expand Up @@ -7016,6 +7031,7 @@ mod error_outcome_emission_tests {
persona_env_vars: vec![],
has_generated_codex_config: false,
relay_observer: false,
public_status: false,
exit_after_inactivity_secs: 0,
lazy_pool: false,
idle_pool_sleep_secs: 0,
Expand Down
Loading