Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "compact_t8mic0r33je6",
"version": 1,
"type": "compacted",
"compactedAt": "2026-09-20T03:15:12.479Z",
"sourceTrajectories": [
"traj_zf263rtkysa2"
],
"dateRange": {
"start": "2026-09-20T01:46:34.623Z",
"end": "2026-09-20T02:40:05.072Z"
},
"summary": {
"totalDecisions": 2,
"totalEvents": 3,
"uniqueAgents": [
"default"
]
},
"decisionGroups": [
{
"category": "api",
"decisions": [
{
"question": "Transferred Muse's credential-free git bundle over numbered Relay DM chunks",
"chosen": "Transferred Muse's credential-free git bundle over numbered Relay DM chunks",
"reasoning": "Dogpatch lacked GitHub credentials, Relay file attachments were broken, HTTP serving was sandbox-blocked, and the user explicitly wanted Relay/Relayfile exercised without SSH. The 9,620-byte reconstruction matched Muse's SHA-256 and passed git bundle verification.",
"fromTrajectory": "traj_zf263rtkysa2"
}
]
},
{
"category": "security",
"decisions": [
{
"question": "Kept Muse approvals enabled while defaulting workspace trust",
"chosen": "Kept Muse approvals enabled while defaulting workspace trust",
"reasoning": "Muse needs --trust-workspace for project skills and rules, but --disable-approval is a separate security weakening and remains caller opt-in.",
"fromTrajectory": "traj_zf263rtkysa2"
}
]
}
],
"keyLearnings": [],
"keyFindings": [],
"filesAffected": [],
"commits": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Trajectory Compaction: Sep 19, 2026 - Sep 19, 2026

## Summary
- Sessions: 1
- Decisions: 2
- Events: 3
- Agents: default
- Files: 0
- Commits: 0

## Api
- Transferred Muse's credential-free git bundle over numbered Relay DM chunks -> Transferred Muse's credential-free git bundle over numbered Relay DM chunks (traj_zf263rtkysa2)

## Security
- Kept Muse approvals enabled while defaulting workspace trust -> Kept Muse approvals enabled while defaulting workspace trust (traj_zf263rtkysa2)

## Key Learnings
- None

## Key Findings
- None
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Trajectory: Merge latest main into Muse CLI support

> **Status:** ✅ Completed
> **Confidence:** 90%
> **Started:** September 20, 2026 at 01:16 AM
> **Completed:** September 20, 2026 at 01:16 AM

---

## Summary

Merged current main into Muse support, reconciled Muse and Devin registry/injection conflicts, updated the merged resume-contract regression, and validated Rust Clippy, Muse/Devin tests, focused Vitest, and monorepo typecheck.

**Approach:** Standard approach

---

## Key Decisions

### Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body
- **Chose:** Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body
- **Reasoning:** Latest main added Devin to the same PTY, fleet, MCP, and observability surfaces. The merged implementation must apply Devin bracketed-paste bytes before the shared delayed-Enter submission helper so neither harness regresses.

---

## Chapters

### 1. Work
*Agent: default*

- Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body: Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"id": "traj_isjrt5pjd97c",
"version": 1,
"task": {
"title": "Merge latest main into Muse CLI support"
},
"status": "completed",
"startedAt": "2026-09-20T08:16:06.146Z",
"completedAt": "2026-09-20T08:16:14.908Z",
"agents": [
{
"name": "default",
"role": "lead",
"joinedAt": "2026-09-20T08:16:10.449Z"
}
],
"chapters": [
{
"id": "chap_o1eno3j3avrl",
"title": "Work",
"agentName": "default",
"startedAt": "2026-09-20T08:16:10.449Z",
"endedAt": "2026-09-20T08:16:14.908Z",
"events": [
{
"ts": 1789892170449,
"type": "decision",
"content": "Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body: Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body",
"raw": {
"question": "Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body",
"chosen": "Preserved both Muse and Devin across overlapping harness registries and centralized injection through submit_injection_body",
"alternatives": [],
"reasoning": "Latest main added Devin to the same PTY, fleet, MCP, and observability surfaces. The merged implementation must apply Devin bracketed-paste bytes before the shared delayed-Enter submission helper so neither harness regresses."
},
"significance": "high"
}
]
}
],
"retrospective": {
"summary": "Merged current main into Muse support, reconciled Muse and Devin registry/injection conflicts, updated the merged resume-contract regression, and validated Rust Clippy, Muse/Devin tests, focused Vitest, and monorepo typecheck.",
"approach": "Standard approach",
"confidence": 0.9
},
"commits": [],
"filesChanged": [],
"projectId": "AgentWorkforce/relay",
"tags": [],
"_trace": {
"startRef": "9091e84af9033f76ec3d26cd9c9267793f89260e",
"endRef": "9091e84af9033f76ec3d26cd9c9267793f89260e"
}
}
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased - Minor]

### Fixed

- MCP `spawn`, `add_agent`, and direct-message calls now coalesce in-flight JSON-RPC replays and accept an `idempotency_key` for safe retries after a lost response, preventing duplicate workers, false duplicate-name failures, and duplicate DMs while keeping later JSON-RPC ID reuse distinct.
- `node agent attach --node` now replaces an expired remote terminal session once and reconnects existing local terminal clients, while transient terminal failures retain the bounded resume budget without minting additional sessions.

### Added

- `fleet spawn`, `node up` capacity, and the `spawn`/`add_agent` MCP tools accept the Muse CLI (`muse`): nodes advertise `spawn:muse`, launches default to `--trust-workspace` so workspace skills and rules load, injected tasks submit without a manual Enter, and each worker gets Agent Relay MCP tools from an isolated per-worker Muse config home. Tool approvals stay on unless `--disable-approval` is passed explicitly.
- Devin CLI is available through Relay PTY, fleet and MCP spawning with isolated worker MCP configuration, preserved approvals, and reliable initial and follow-up message submission.

- `agent-relay fleet nodes list --pretty` renders the fleet roster as a human-readable table; `agent-relay fleet nodes --pretty` is available as a shorter equivalent, while JSON remains the default.

### Fixed

- MCP `spawn`, `add_agent`, and direct-message calls now coalesce in-flight JSON-RPC replays and accept an `idempotency_key` for safe retries after a lost response, preventing duplicate workers, false duplicate-name failures, and duplicate DMs while keeping later JSON-RPC ID reuse distinct.
- `node agent attach --node` now replaces an expired remote terminal session once and reconnects existing local terminal clients, while transient terminal failures retain the bounded resume budget without minting additional sessions.

## [12.3.1] - 2026-09-20

### Added
Expand Down
6 changes: 6 additions & 0 deletions crates/broker/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ pub(crate) struct PtyCommand {
#[arg(long)]
pub(crate) agent_name: Option<String>,

/// Isolated Muse config home for this worker (path only, never a
/// secret): the worker points `XDG_CONFIG_HOME` (plus `MUSE_AUTH_PATH`
/// and `MUSE_NO_AUTO_UPDATE`) at it before spawning Muse.
#[arg(long)]
pub(crate) muse_config_home: Option<String>,

/// Emit delivery_active events when output matches progress patterns.
#[arg(long)]
pub(crate) progress: bool,
Expand Down
51 changes: 25 additions & 26 deletions crates/broker/src/pty_worker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{
collections::{HashSet, VecDeque},
future::Future,
path::Path,
pin::Pin,
sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -45,8 +46,7 @@ use crate::util::terminal::{detect_claude_trust_prompt, detect_codex_trust_promp
use crate::util::utf8_stream::Utf8StreamDecoder;
use crate::worker::detection::ActivityDetector;
use crate::wrap::{
injection_submit_followup_delay, warn_on_auto_response_write, PtyAutoState,
AUTO_SUGGESTION_BLOCK_TIMEOUT,
submit_injection_body, warn_on_auto_response_write, PtyAutoState, AUTO_SUGGESTION_BLOCK_TIMEOUT,
};
use base64::Engine;

Expand Down Expand Up @@ -811,6 +811,22 @@ pub(crate) async fn run_pty_worker(cmd: PtyCommand) -> Result<()> {

let (resolved_cli, inline_cli_args) = parse_cli_command(&cmd.cli)
.with_context(|| format!("invalid CLI command '{}'", cmd.cli))?;
if let Some(home) = cmd.muse_config_home.as_deref().filter(|s| !s.is_empty()) {
// The broker passes this flag only for Muse workers with Relay MCP
// provisioned, but re-check the executable identity defensively: a
// stray flag must never redirect another CLI's config scope.
if crate::snippets::is_muse_executable(&resolved_cli) {
#[allow(deprecated)]
std::env::set_var("XDG_CONFIG_HOME", home);
#[allow(deprecated)]
std::env::set_var(
"MUSE_AUTH_PATH",
Path::new(home).join("muse").join("auth.json"),
);
#[allow(deprecated)]
std::env::set_var("MUSE_NO_AUTO_UPDATE", "1");
}
}
let mut effective_args = inline_cli_args;
effective_args.extend(cmd.args.clone());

Expand Down Expand Up @@ -1994,30 +2010,13 @@ pub(crate) async fn run_pty_worker(cmd: PtyCommand) -> Result<()> {
continue;
}
// Submit the body and mandatory Enter as one FIFO
// command and hold the ack. Claude Code and Codex need Enter as
// a distinct PTY write after its multiline paste
// boundary settles; relay-pty keeps that delayed
// follow-up atomic with the body. Other harnesses keep
// the established body-plus-Enter write. In both cases,
// nothing (passthrough input, an auto-responder, or a
// terminal-query reply) can splice into submission.
// Finalization (emit `delivery_injected`, queue echo
// verification) still waits for this ack in the
// injection-ack arm.
let mut bytes = crate::devin::injection_bytes(&resolved_cli, &injection);
let write = if let Some(delay) =
injection_submit_followup_delay(&resolved_cli)
{
pty.submit_write_paced_with_followup_and_output_boundary(
bytes,
inject_rate,
delay,
b"\r".to_vec(),
)
} else {
bytes.extend_from_slice(b"\r");
pty.submit_write_paced_with_output_boundary(bytes, inject_rate)
};
// command and hold the ack. Devin first applies its
// bracketed-paste body shape; the shared helper then
// selects the harness-specific delayed Enter. Finalization
// still waits for this ack in the injection-ack arm.
let bytes = crate::devin::injection_bytes(&resolved_cli, &injection);
let write =
submit_injection_body(&pty, &resolved_cli, bytes, inject_rate);
match write {
Ok((ack_rx, output_boundary)) => {
inj.injection_text = Some(injection);
Expand Down
28 changes: 26 additions & 2 deletions crates/broker/src/runtime/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2979,7 +2979,7 @@ fn channel_in_list(channels: &[ChannelName], channel: &str) -> bool {
/// One-line skill text prepended for CLI harnesses that need a minimal relay lifecycle hint.
const RELAY_WORKER_ONE_LINER: &str = "\
Call mcp__agent-relay__add_agent(name, cli, task) to spawn a relay worker \
(cli: \"claude\", \"codex\", \"gemini\", \"opencode\", or \"devin\"; add model for Claude tier, \
(cli: \"claude\", \"codex\", \"gemini\", \"aider\", \"goose\", \"grok\", \"muse\", \"opencode\", or \"devin\"; add model for Claude tier, \
e.g. model: \"claude-opus-4-8\"), and mcp__agent-relay__remove_agent(name) to release when done.";

/// Skill text prepended to the task for small/fast models (haiku, mini, flash) that need
Expand All @@ -2992,7 +2992,7 @@ const SMALL_MODEL_RELAY_SKILL: &str = "\
### Spawn a relay worker
To delegate a task to a dedicated relay worker agent, call:
mcp__agent-relay__add_agent(name: \"WorkerName\", cli: \"claude\", task: \"full task instructions\")
Required: name (unique string), cli (\"claude\", \"codex\", \"gemini\", \"opencode\", or \"devin\"), task (complete instructions).
Required: name (unique string), cli (\"claude\", \"codex\", \"gemini\", \"aider\", \"goose\", \"grok\", \"muse\", \"opencode\", or \"devin\"), task (complete instructions).
To pin a Claude model: add model: \"claude-opus-4-8\" (Opus), \"claude-sonnet-4-6\" (Sonnet), or \"claude-haiku-4-5-20251001\" (Haiku).
The relay worker will DM you \"ACK: <understanding>\" when it starts and \"DONE: <result>\" when complete.

Expand Down Expand Up @@ -3090,9 +3090,33 @@ mod skill_injection_tests {
assert!(text.contains("mcp__agent-relay__add_agent"));
assert!(text.contains("mcp__agent-relay__remove_agent"));
assert!(text.contains("relay worker"));
assert!(text.contains("\"muse\""));
assert!(text.contains("\"aider\""));
assert!(text.contains("\"goose\""));
assert!(text.contains("\"grok\""));
assert!(!text.contains("Do it yourself"));
}

#[test]
fn relay_skill_guidance_lists_every_spawnable_cli() {
// Both guidance strings must stay aligned with the add_agent schema:
// every accepted cli value is named so guided callers use valid ones.
for text in [RELAY_WORKER_ONE_LINER, SMALL_MODEL_RELAY_SKILL] {
for cli in [
"\"claude\"",
"\"codex\"",
"\"gemini\"",
"\"aider\"",
"\"goose\"",
"\"grok\"",
"\"muse\"",
"\"opencode\"",
] {
assert!(text.contains(cli), "relay skill guidance must name {cli}");
}
}
}

#[test]
fn cli_specific_harnesses_receive_prefixes() {
assert_eq!(cli_skill_prefix("gemini"), Some(RELAY_WORKER_ONE_LINER));
Expand Down
42 changes: 40 additions & 2 deletions crates/broker/src/runtime/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ fn bracket_ipv6_host(host: &str) -> String {

/// The harnesses the broker advertises `spawn:<harness>` capacity for when
/// `AGENT_RELAY_NODE_HARNESSES` is unset.
const DEFAULT_NODE_HARNESSES: &[&str] = &["claude", "codex", "gemini", "opencode", "devin"];
const DEFAULT_NODE_HARNESSES: &[&str] = &["claude", "codex", "gemini", "opencode", "muse", "devin"];

/// Build the node descriptor the broker registers as the `broker` provider.
///
Expand Down Expand Up @@ -1044,7 +1044,7 @@ mod tests {
use super::*;
use std::ffi::OsString;
use std::net::{Ipv4Addr, Ipv6Addr};
use std::sync::{Mutex, MutexGuard};
use std::sync::{Mutex, MutexGuard, PoisonError};

static NODE_ID_ENV_MUTEX: Mutex<()> = Mutex::new(());

Expand Down Expand Up @@ -1116,6 +1116,44 @@ mod tests {
assert_eq!(std::env::var_os("RELAY_NODE_TOKEN"), original_node_token);
}

static NODE_HARNESSES_ENV_MUTEX: Mutex<()> = Mutex::new(());

#[test]
fn default_node_harnesses_advertise_spawn_muse() {
// `AGENT_RELAY_NODE_HARNESSES` may be preset in the ambient
// environment (notably on nodes that set their own capacity); clear it
// under a lock so this test observes the built-in default.
let _lock = NODE_HARNESSES_ENV_MUTEX
.lock()
.unwrap_or_else(PoisonError::into_inner);
let saved = std::env::var_os("AGENT_RELAY_NODE_HARNESSES");
// SAFETY: NODE_HARNESSES_ENV_MUTEX serializes environment mutations
// for these tests before any code under test observes the value.
unsafe {
std::env::remove_var("AGENT_RELAY_NODE_HARNESSES");
}
let harnesses = node_capacity_harnesses();
let manifest = bootstrap_node_manifest("node-a", "node_a", "relay-broker/9.1.1");
// SAFETY: same lock held; restoring the ambient value on the way out.
unsafe {
match saved {
Some(value) => std::env::set_var("AGENT_RELAY_NODE_HARNESSES", value),
None => std::env::remove_var("AGENT_RELAY_NODE_HARNESSES"),
}
}
assert!(
harnesses.contains(&"muse".to_string()),
"default node capacity must include muse, got {harnesses:?}"
);
assert!(
manifest
.capabilities
.iter()
.any(|cap| cap.name == "spawn:muse"),
"broker manifest must advertise spawn:muse capacity"
);
}

#[test]
fn bootstrap_node_manifest_advertises_capacity_not_bare_spawn() {
// The broker registers its run capacity: `spawn:<harness>` + `release`,
Expand Down
Loading
Loading