@team-agent/installer 0.5.127 → 0.5.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +11 -0
- package/crates/team-agent/src/cli/adapters.rs +3 -13
- package/crates/team-agent/src/cli/arguments.rs +4 -0
- package/crates/team-agent/src/cli/diagnose.rs +68 -22
- package/crates/team-agent/src/cli/emit.rs +58 -26
- package/crates/team-agent/src/cli/intent/runtime.rs +32 -5
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +102 -11
- package/crates/team-agent/src/cli/intent/tests.rs +10 -12
- package/crates/team-agent/src/cli/intent.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +25 -8
- package/crates/team-agent/src/cli/models.rs +764 -7
- package/crates/team-agent/src/cli/schedule.rs +175 -0
- package/crates/team-agent/src/cli/send/persist.rs +0 -36
- package/crates/team-agent/src/cli/send/presentation.rs +1 -1
- package/crates/team-agent/src/cli/send.rs +108 -110
- package/crates/team-agent/src/cli/spec.rs +6 -0
- package/crates/team-agent/src/cli/status_port/brief.rs +5 -67
- package/crates/team-agent/src/cli/tests/leader_watch.rs +12 -62
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
- package/crates/team-agent/src/cli/tests/run_delegation.rs +9 -6
- package/crates/team-agent/src/cli/tests/status_send.rs +68 -271
- package/crates/team-agent/src/compiler/tests.rs +3 -18
- package/crates/team-agent/src/compiler.rs +205 -6
- package/crates/team-agent/src/contract_runtime/backend.rs +145 -11
- package/crates/team-agent/src/contract_runtime/commands.rs +7 -7
- package/crates/team-agent/src/contract_runtime/config.rs +26 -16
- package/crates/team-agent/src/contract_runtime/config_tests.rs +24 -4
- package/crates/team-agent/src/contract_runtime/discovery.rs +12 -1
- package/crates/team-agent/src/contract_runtime/fork.rs +3 -10
- package/crates/team-agent/src/contract_runtime/framework.rs +28 -11
- package/crates/team-agent/src/contract_runtime/mcp.rs +19 -24
- package/crates/team-agent/src/contract_runtime/prompt.rs +2 -2
- package/crates/team-agent/src/contract_runtime/registry.rs +56 -92
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +11 -11
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +16 -54
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +42 -0
- package/crates/team-agent/src/coordinator/tick.rs +1 -89
- package/crates/team-agent/src/db/message_store.rs +7 -65
- package/crates/team-agent/src/direct_delivery.rs +368 -0
- package/crates/team-agent/src/inbox_store.rs +169 -0
- package/crates/team-agent/src/leader/registry.rs +5 -0
- package/crates/team-agent/src/leader/start.rs +2 -1
- package/crates/team-agent/src/leader/tests/lease_api.rs +2 -2
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +1 -0
- package/crates/team-agent/src/lib.rs +2 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +33 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +206 -1
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +28 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +38 -13
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +9 -1
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +351 -81
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +3 -4
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +24 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +36 -13
- package/crates/team-agent/src/lifecycle/launch.rs +24 -1
- package/crates/team-agent/src/lifecycle/profile_launch.rs +321 -11
- package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -0
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +1798 -0
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +163 -0
- package/crates/team-agent/src/lifecycle/restart/common.rs +345 -35
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +4 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +39 -14
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +325 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +320 -8
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +236 -13
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +378 -4
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +5 -4
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
- package/crates/team-agent/src/lifecycle/tests/core.rs +47 -18
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +2 -1
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +14 -14
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +28 -26
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +18 -6
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +70 -52
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +210 -0
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +157 -4
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +526 -10
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1419 -0
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +68 -1
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +34 -12
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +94 -2
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +10 -11
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +254 -2
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +5 -6
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +16 -7
- package/crates/team-agent/src/lifecycle/tests.rs +3 -0
- package/crates/team-agent/src/lifecycle/types.rs +18 -2
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +43 -50
- package/crates/team-agent/src/mcp_server/readiness.rs +130 -149
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +98 -119
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +21 -31
- package/crates/team-agent/src/mcp_server/tests/send.rs +72 -107
- package/crates/team-agent/src/mcp_server/tests/tools.rs +10 -12
- package/crates/team-agent/src/mcp_server/tools.rs +70 -196
- package/crates/team-agent/src/messaging/delivery.rs +160 -218
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/helpers.rs +1 -19
- package/crates/team-agent/src/messaging/mod.rs +1 -0
- package/crates/team-agent/src/messaging/reminders.rs +316 -0
- package/crates/team-agent/src/messaging/scheduler.rs +7 -1
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +191 -85
- package/crates/team-agent/src/messaging/tests/runtime.rs +4 -110
- package/crates/team-agent/src/messaging/tests/spine.rs +40 -24
- package/crates/team-agent/src/messaging/types.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +303 -51
- package/crates/team-agent/src/provider/adapters/claude.rs +78 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +131 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +7 -5
- package/crates/team-agent/src/provider/adapters/pi.rs +106 -0
- package/crates/team-agent/src/provider/classify.rs +1 -66
- package/crates/team-agent/src/provider/model_catalog.rs +201 -13
- package/crates/team-agent/src/provider/session/capture.rs +106 -6
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +4 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +150 -18
- package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +44 -8
- package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
- package/crates/team-agent/src/provider/session_scan.rs +16 -6
- package/crates/team-agent/src/provider/tests/adapter.rs +104 -17
- package/crates/team-agent/src/provider/tests/classify.rs +0 -53
- package/crates/team-agent/src/provider/tests/command_helpers.rs +12 -3
- package/crates/team-agent/src/provider/tests/idle.rs +37 -0
- package/crates/team-agent/src/provider/wire.rs +22 -34
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/projection.rs +1 -1
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +144 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -151
- package/crates/team-agent/src/tmux_backend.rs +5 -40
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +5 -7
- package/skills/team-agent/command-coverage.json +1 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +3 -3
- package/skills/team-agent/references/team-agent-operator.md +3 -3
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
//! Read-only addressing and a synchronous tmux actuator. No coordinator, ledger or receipts.
|
|
2
|
+
|
|
3
|
+
use std::io::Write;
|
|
4
|
+
use std::path::{Path, PathBuf};
|
|
5
|
+
use std::process::{Command, Stdio};
|
|
6
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
7
|
+
use std::time::Duration;
|
|
8
|
+
|
|
9
|
+
use serde::Serialize;
|
|
10
|
+
use serde_json::{json, Value};
|
|
11
|
+
|
|
12
|
+
#[derive(Debug, Clone, Serialize)]
|
|
13
|
+
pub struct Endpoint {
|
|
14
|
+
pub agent: String,
|
|
15
|
+
pub socket: String,
|
|
16
|
+
pub pane_id: String,
|
|
17
|
+
pub dialect: String,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
pub struct Directory {
|
|
21
|
+
pub workspace: PathBuf,
|
|
22
|
+
pub team: Option<String>,
|
|
23
|
+
pub state: Value,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// Read the published JSON snapshot without migrations, locks, SQLite or self-healing writes.
|
|
27
|
+
pub fn snapshot(workspace: &Path) -> Result<Value, String> {
|
|
28
|
+
let runtime = workspace.join(".team/runtime/state.json");
|
|
29
|
+
let path = if runtime.exists() {
|
|
30
|
+
runtime
|
|
31
|
+
} else {
|
|
32
|
+
workspace.join(".team/state.json")
|
|
33
|
+
};
|
|
34
|
+
let bytes = std::fs::read(&path).map_err(|e| format!("{}: {e}", path.display()))?;
|
|
35
|
+
serde_json::from_slice(&bytes).map_err(|e| format!("{}: {e}", path.display()))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
pub fn directory(workspace: &Path, team: Option<&str>) -> Result<Directory, String> {
|
|
39
|
+
let workspace =
|
|
40
|
+
crate::model::paths::canonical_run_workspace(workspace).map_err(|e| e.to_string())?;
|
|
41
|
+
let snapshot = snapshot(&workspace)?;
|
|
42
|
+
let Some(teams) = snapshot
|
|
43
|
+
.get("teams")
|
|
44
|
+
.and_then(Value::as_object)
|
|
45
|
+
.filter(|teams| !teams.is_empty())
|
|
46
|
+
else {
|
|
47
|
+
if let Some(requested) = team {
|
|
48
|
+
let matches = crate::state::projection::team_selector_matches(
|
|
49
|
+
requested, field(&snapshot, "team_key").or_else(|| field(&snapshot, "active_team_key")).unwrap_or(""), &snapshot,
|
|
50
|
+
) || ["team_id", "team_name", "tmux_session", "team_dir"]
|
|
51
|
+
.iter()
|
|
52
|
+
.any(|key| field(&snapshot, key) == Some(requested));
|
|
53
|
+
if !matches {
|
|
54
|
+
return Err(format!("unknown team: {requested}"));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return Ok(Directory {
|
|
58
|
+
workspace,
|
|
59
|
+
team: team.map(str::to_string),
|
|
60
|
+
state: snapshot,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
let requested = team.or_else(|| field(&snapshot, "active_team_key"));
|
|
64
|
+
let matches: Vec<_> = teams
|
|
65
|
+
.iter()
|
|
66
|
+
.filter(|(key, value)| {
|
|
67
|
+
requested.map_or(teams.len() == 1, |requested| {
|
|
68
|
+
crate::state::projection::team_selector_matches(requested, key, value)
|
|
69
|
+
|| ["team_id", "team_name", "tmux_session", "team_dir"]
|
|
70
|
+
.iter()
|
|
71
|
+
.any(|field_name| field(value, field_name) == Some(requested))
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
.collect();
|
|
75
|
+
if matches.len() != 1 {
|
|
76
|
+
return Err(format!(
|
|
77
|
+
"team selection is unknown or ambiguous: {}",
|
|
78
|
+
requested.unwrap_or("(none)")
|
|
79
|
+
));
|
|
80
|
+
}
|
|
81
|
+
let (key, selected) = matches[0];
|
|
82
|
+
let mut state = selected.clone();
|
|
83
|
+
if let Some(object) = state.as_object_mut() {
|
|
84
|
+
for name in ["tmux_socket", "tmux_endpoint", "leader", "leader_receiver"] {
|
|
85
|
+
if matches!(name, "leader" | "leader_receiver")
|
|
86
|
+
&& teams.len() > 1
|
|
87
|
+
&& field(&snapshot, "active_team_key") != Some(key.as_str())
|
|
88
|
+
{
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if !object.contains_key(name) {
|
|
92
|
+
if let Some(value) = snapshot.get(name) {
|
|
93
|
+
object.insert(name.into(), value.clone());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
Ok(Directory {
|
|
99
|
+
workspace,
|
|
100
|
+
team: Some(key.clone()),
|
|
101
|
+
state,
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fn field<'a>(value: &'a Value, key: &str) -> Option<&'a str> {
|
|
106
|
+
value
|
|
107
|
+
.get(key)
|
|
108
|
+
.and_then(Value::as_str)
|
|
109
|
+
.filter(|s| !s.is_empty())
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
impl Directory {
|
|
113
|
+
fn recipient(&self, agent: &str) -> Result<&Value, String> {
|
|
114
|
+
if agent == "leader" {
|
|
115
|
+
self.state.get("leader_receiver").or_else(|| self.state.get("leader"))
|
|
116
|
+
} else {
|
|
117
|
+
self.state
|
|
118
|
+
.get("agents")
|
|
119
|
+
.and_then(|agents| agents.get(agent))
|
|
120
|
+
}
|
|
121
|
+
.ok_or_else(|| format!("unknown recipient: {agent}"))
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
pub fn endpoint(&self, agent: &str) -> Result<Endpoint, String> {
|
|
125
|
+
let info = self.recipient(agent)?;
|
|
126
|
+
let pane_id = field(info, "pane_id").or_else(|| field(info, "native_pane"))
|
|
127
|
+
.ok_or_else(|| format!("{agent} has no tmux pane"))?;
|
|
128
|
+
let socket = field(info, "native_endpoint").map(str::to_string)
|
|
129
|
+
.or_else(|| crate::tmux_backend::runtime_tmux_endpoint_from_state_pub(Some(info)).map(|(socket, _)| socket))
|
|
130
|
+
.or_else(|| crate::tmux_backend::runtime_tmux_endpoint_from_state_pub(Some(&self.state)).map(|(socket, _)| socket))
|
|
131
|
+
.unwrap_or_else(|| crate::tmux_backend::socket_name_for_workspace(&self.workspace));
|
|
132
|
+
Ok(Endpoint {
|
|
133
|
+
agent: agent.to_string(),
|
|
134
|
+
socket,
|
|
135
|
+
pane_id: pane_id.to_string(),
|
|
136
|
+
dialect: endpoint_dialect(field(info, "provider"), field(info, "dialect")),
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// Actuate the selected live pane; advisory session/window/PID metadata
|
|
141
|
+
/// cannot veto delivery or create a parked message.
|
|
142
|
+
pub fn send(&self, agent: &str, text: &str) -> Result<Value, String> {
|
|
143
|
+
let endpoint = self.endpoint(agent)?;
|
|
144
|
+
let output = tmux(&endpoint.socket)
|
|
145
|
+
.args(["display-message", "-p", "-t", &endpoint.pane_id, "#{pane_dead}"])
|
|
146
|
+
.output().map_err(|error| error.to_string())?;
|
|
147
|
+
if !output.status.success() || String::from_utf8_lossy(&output.stdout).trim() != "0" {
|
|
148
|
+
return Err("recipient pane is not live on the selected socket".into());
|
|
149
|
+
}
|
|
150
|
+
send(&endpoint, text)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
pub fn agents(&self) -> Vec<String> {
|
|
154
|
+
self.state
|
|
155
|
+
.get("agents")
|
|
156
|
+
.and_then(Value::as_object)
|
|
157
|
+
.map(|agents| agents.keys().cloned().collect())
|
|
158
|
+
.unwrap_or_default()
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
fn canonical_dialect(name: &str) -> String {
|
|
163
|
+
let normalized = name.trim().to_ascii_lowercase().replace('-', "_");
|
|
164
|
+
match normalized.as_str() {
|
|
165
|
+
"claude" | "claude_code" | "claudecode" | "claude_tui" => "claude".into(),
|
|
166
|
+
"pi" | "pi_tui" => "pi".into(),
|
|
167
|
+
"cursor" | "cursor_agent" | "agent" => "cursor".into(),
|
|
168
|
+
"codex" | "codex_cli" => "codex".into(),
|
|
169
|
+
"grok" | "grok_build" => "grok".into(),
|
|
170
|
+
"double_enter" => "double-enter".into(),
|
|
171
|
+
"cursor_double_enter" => "cursor-double-enter".into(),
|
|
172
|
+
_ => name.trim().to_string(),
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fn endpoint_dialect(provider: Option<&str>, configured: Option<&str>) -> String {
|
|
177
|
+
let provider = canonical_dialect(provider.unwrap_or("enter"));
|
|
178
|
+
match configured.map(canonical_dialect).as_deref() {
|
|
179
|
+
// A key-count override must not discard Cursor's native paste floor. The resolved
|
|
180
|
+
// dialect is self-contained, so `locate` -> raw `send` preserves the same sequence.
|
|
181
|
+
Some("double-enter") if provider == "cursor" => "cursor-double-enter".into(),
|
|
182
|
+
Some("enter") | None => provider,
|
|
183
|
+
Some(dialect) => dialect.to_string(),
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
fn submit_sequence(dialect: &str) -> (Duration, usize) {
|
|
188
|
+
// Keep the legacy tmux executor's ordering: completed paste -> native floor -> Enter.
|
|
189
|
+
// Cursor's in-tree interaction profile and ac30977b's Claude profile specify 100ms,
|
|
190
|
+
// one Enter, and retry-never. The approved direct-actuator map intentionally uses
|
|
191
|
+
// Pi/Codex=0 and Grok=150ms; Grok's contract uses 150ms for *queue flush*, not its
|
|
192
|
+
// 100ms paste floor. Do not copy receipt/queue keys or claim these maps are identical.
|
|
193
|
+
match canonical_dialect(dialect).as_str() {
|
|
194
|
+
"claude" | "cursor" => (Duration::from_millis(100), 1),
|
|
195
|
+
"grok" => (Duration::from_millis(150), 1),
|
|
196
|
+
"cursor-double-enter" => (Duration::from_millis(100), 2),
|
|
197
|
+
"double-enter" => (Duration::ZERO, 2),
|
|
198
|
+
_ => (Duration::ZERO, 1),
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
fn tmux(socket: &str) -> Command {
|
|
203
|
+
let mut command = Command::new("tmux");
|
|
204
|
+
if socket != "default" && !socket.is_empty() {
|
|
205
|
+
command
|
|
206
|
+
.arg(if socket.contains('/') { "-S" } else { "-L" })
|
|
207
|
+
.arg(socket);
|
|
208
|
+
}
|
|
209
|
+
command
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
fn check_output(output: std::process::Output) -> Result<(), String> {
|
|
213
|
+
if output.status.success() {
|
|
214
|
+
Ok(())
|
|
215
|
+
} else {
|
|
216
|
+
Err(format!(
|
|
217
|
+
"tmux delivery failed: {}",
|
|
218
|
+
String::from_utf8_lossy(&output.stderr).trim()
|
|
219
|
+
))
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/// Physical success means paste + submit only, never provider acceptance or task completion.
|
|
224
|
+
/// Provider names/aliases select their native paste floor and one Enter. Only an explicit
|
|
225
|
+
/// double-enter dialect adds a second key; there is no observation-driven retry or third Enter.
|
|
226
|
+
pub fn direct_send(socket: &str, pane_id: &str, dialect: &str, text: &str) -> Result<(), String> {
|
|
227
|
+
if !pane_id
|
|
228
|
+
.strip_prefix('%')
|
|
229
|
+
.is_some_and(|id| !id.is_empty() && id.bytes().all(|b| b.is_ascii_digit()))
|
|
230
|
+
{
|
|
231
|
+
return Err("a concrete tmux pane id (%N) is required".into());
|
|
232
|
+
}
|
|
233
|
+
if text.is_empty() {
|
|
234
|
+
return Err("message must not be empty".into());
|
|
235
|
+
}
|
|
236
|
+
// Never allow payload bytes to terminate bracketed paste and inject a submit key.
|
|
237
|
+
if text.contains('\x1b') || text.contains('\0') {
|
|
238
|
+
return Err("message must not contain ESC or NUL bytes".into());
|
|
239
|
+
}
|
|
240
|
+
static NEXT_BUFFER: AtomicU64 = AtomicU64::new(0);
|
|
241
|
+
let buffer = format!(
|
|
242
|
+
"team-agent-direct-{}-{}",
|
|
243
|
+
std::process::id(),
|
|
244
|
+
NEXT_BUFFER.fetch_add(1, Ordering::Relaxed)
|
|
245
|
+
);
|
|
246
|
+
let mut child = tmux(socket)
|
|
247
|
+
.args(["load-buffer", "-b", &buffer, "-"])
|
|
248
|
+
.stdin(Stdio::piped())
|
|
249
|
+
.stdout(Stdio::null())
|
|
250
|
+
.stderr(Stdio::piped())
|
|
251
|
+
.spawn()
|
|
252
|
+
.map_err(|e| format!("tmux: {e}"))?;
|
|
253
|
+
let write_result = child.stdin.take().unwrap().write_all(text.as_bytes());
|
|
254
|
+
let loaded = child.wait_with_output().map_err(|e| e.to_string())?;
|
|
255
|
+
if let Err(error) = write_result {
|
|
256
|
+
let _ = tmux(socket).args(["delete-buffer", "-b", &buffer]).output();
|
|
257
|
+
return Err(error.to_string());
|
|
258
|
+
}
|
|
259
|
+
check_output(loaded)?;
|
|
260
|
+
let pasted = tmux(socket)
|
|
261
|
+
.args([
|
|
262
|
+
"paste-buffer",
|
|
263
|
+
"-p",
|
|
264
|
+
"-r",
|
|
265
|
+
"-d",
|
|
266
|
+
"-b",
|
|
267
|
+
&buffer,
|
|
268
|
+
"-t",
|
|
269
|
+
pane_id,
|
|
270
|
+
])
|
|
271
|
+
.output()
|
|
272
|
+
.map_err(|e| e.to_string())
|
|
273
|
+
.and_then(check_output);
|
|
274
|
+
if let Err(error) = pasted {
|
|
275
|
+
let _ = tmux(socket).args(["delete-buffer", "-b", &buffer]).output();
|
|
276
|
+
return Err(error);
|
|
277
|
+
}
|
|
278
|
+
let (floor, enter_count) = submit_sequence(dialect);
|
|
279
|
+
if !floor.is_zero() {
|
|
280
|
+
std::thread::sleep(floor);
|
|
281
|
+
}
|
|
282
|
+
let mut command = tmux(socket);
|
|
283
|
+
command.args(["send-keys", "-t", pane_id, "Enter"]);
|
|
284
|
+
if enter_count == 2 {
|
|
285
|
+
command.args([";", "send-keys", "-t", pane_id, "Enter"]);
|
|
286
|
+
}
|
|
287
|
+
command
|
|
288
|
+
.output()
|
|
289
|
+
.map_err(|e| e.to_string())
|
|
290
|
+
.and_then(check_output)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
pub fn send(endpoint: &Endpoint, text: &str) -> Result<Value, String> {
|
|
294
|
+
direct_send(&endpoint.socket, &endpoint.pane_id, &endpoint.dialect, text)?;
|
|
295
|
+
Ok(
|
|
296
|
+
json!({"status": "sent", "recipient": endpoint.agent, "pane_id": endpoint.pane_id,
|
|
297
|
+
"dialect": endpoint.dialect, "delivery": "physical", "accepted": null}),
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/// Enumerate each published team, retaining only physically live panes.
|
|
302
|
+
pub fn locate(workspace: &Path, team: Option<&str>) -> Result<Value, String> {
|
|
303
|
+
let snapshot = snapshot(workspace)?;
|
|
304
|
+
let selectors: Vec<Option<String>> = if let Some(team) = team {
|
|
305
|
+
vec![Some(team.to_string())]
|
|
306
|
+
} else if let Some(teams) = snapshot
|
|
307
|
+
.get("teams")
|
|
308
|
+
.and_then(Value::as_object)
|
|
309
|
+
.filter(|t| !t.is_empty())
|
|
310
|
+
{
|
|
311
|
+
teams.keys().cloned().map(Some).collect()
|
|
312
|
+
} else {
|
|
313
|
+
vec![None]
|
|
314
|
+
};
|
|
315
|
+
let mut endpoints = Vec::new();
|
|
316
|
+
for team in selectors {
|
|
317
|
+
let directory = directory(workspace, team.as_deref())?;
|
|
318
|
+
for agent in std::iter::once("leader".to_string()).chain(directory.agents()) {
|
|
319
|
+
let Ok(endpoint) = directory.endpoint(&agent) else {
|
|
320
|
+
continue;
|
|
321
|
+
};
|
|
322
|
+
let output = tmux(&endpoint.socket)
|
|
323
|
+
.args([
|
|
324
|
+
"display-message",
|
|
325
|
+
"-p",
|
|
326
|
+
"-t",
|
|
327
|
+
&endpoint.pane_id,
|
|
328
|
+
"#{pane_dead}",
|
|
329
|
+
])
|
|
330
|
+
.output()
|
|
331
|
+
.map_err(|e| e.to_string())?;
|
|
332
|
+
if output.status.success() && output.stdout == b"0\n" {
|
|
333
|
+
endpoints.push(
|
|
334
|
+
json!({"workspace": directory.workspace, "team": directory.team,
|
|
335
|
+
"agent": endpoint.agent, "socket": endpoint.socket,
|
|
336
|
+
"pane_id": endpoint.pane_id, "dialect": endpoint.dialect}),
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
Ok(json!({"endpoints": endpoints}))
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
#[cfg(test)]
|
|
345
|
+
mod tests {
|
|
346
|
+
use super::*;
|
|
347
|
+
|
|
348
|
+
#[test]
|
|
349
|
+
fn authoritative_leader_receiver_and_endpoint_take_precedence() {
|
|
350
|
+
let directory = Directory { workspace: PathBuf::from("/controlled-workspace"), team: Some("a".into()), state: json!({
|
|
351
|
+
"leader": {"pane_id": "%1", "tmux_socket": "stale"},
|
|
352
|
+
"leader_receiver": {"pane_id": "%2", "tmux_endpoint": "/tmp/owned-socket", "tmux_socket": "older"}
|
|
353
|
+
}) };
|
|
354
|
+
let endpoint = directory.endpoint("leader").unwrap();
|
|
355
|
+
assert_eq!(endpoint.pane_id, "%2");
|
|
356
|
+
assert_eq!(endpoint.socket, "/tmp/owned-socket");
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
#[test]
|
|
360
|
+
fn missing_socket_uses_the_existing_workspace_namespace_not_the_default_server() {
|
|
361
|
+
let mut directory = Directory { workspace: PathBuf::from("/controlled-workspace"), team: Some("a".into()), state: json!({
|
|
362
|
+
"agents": {"worker": {"pane_id": "%3"}}
|
|
363
|
+
}) };
|
|
364
|
+
assert_eq!(directory.endpoint("worker").unwrap().socket, crate::tmux_backend::socket_name_for_workspace(&directory.workspace));
|
|
365
|
+
directory.state["tmux_socket"] = json!("default");
|
|
366
|
+
assert_eq!(directory.endpoint("worker").unwrap().socket, "default");
|
|
367
|
+
}
|
|
368
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
//! An append-only inbound log, independent of delivery queues and coordinator state.
|
|
2
|
+
|
|
3
|
+
use std::collections::VecDeque;
|
|
4
|
+
use std::fs::{File, OpenOptions};
|
|
5
|
+
use std::io::{BufRead, BufReader, Write};
|
|
6
|
+
use std::path::{Path, PathBuf};
|
|
7
|
+
|
|
8
|
+
use serde_json::{json, Value};
|
|
9
|
+
|
|
10
|
+
fn path(workspace: &Path, recipient: &str) -> Result<PathBuf, String> {
|
|
11
|
+
if recipient.is_empty()
|
|
12
|
+
|| !recipient
|
|
13
|
+
.bytes()
|
|
14
|
+
.all(|b| b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.'))
|
|
15
|
+
|| matches!(recipient, "." | "..")
|
|
16
|
+
{
|
|
17
|
+
return Err("invalid inbox recipient".into());
|
|
18
|
+
}
|
|
19
|
+
Ok(workspace
|
|
20
|
+
.join(".team/inbox")
|
|
21
|
+
.join(format!("{recipient}.jsonl")))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pub fn append(workspace: &Path, recipient: &str, record: &Value) -> Result<(), String> {
|
|
25
|
+
let path = path(workspace, recipient)?;
|
|
26
|
+
std::fs::create_dir_all(path.parent().unwrap()).map_err(|e| e.to_string())?;
|
|
27
|
+
let mut line = serde_json::to_vec(record).map_err(|e| e.to_string())?;
|
|
28
|
+
line.push(b'\n');
|
|
29
|
+
let mut file = OpenOptions::new()
|
|
30
|
+
.create(true)
|
|
31
|
+
.append(true)
|
|
32
|
+
.open(&path)
|
|
33
|
+
.map_err(|e| e.to_string())?;
|
|
34
|
+
// Serialize full records across concurrent MCP processes, including partial write retries.
|
|
35
|
+
// This lock belongs only to this inbox file, never a delivery or runtime-state lock.
|
|
36
|
+
#[cfg(unix)]
|
|
37
|
+
{
|
|
38
|
+
use std::os::fd::AsRawFd;
|
|
39
|
+
if unsafe { libc::flock(file.as_raw_fd(), libc::LOCK_EX) } != 0 {
|
|
40
|
+
return Err(std::io::Error::last_os_error().to_string());
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
file.write_all(&line).map_err(|e| e.to_string())?;
|
|
44
|
+
file.sync_data().map_err(|e| e.to_string())
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pub fn record(
|
|
48
|
+
sender: &str,
|
|
49
|
+
recipient: &str,
|
|
50
|
+
content: &str,
|
|
51
|
+
team: Option<&str>,
|
|
52
|
+
kind: &str,
|
|
53
|
+
) -> Value {
|
|
54
|
+
static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
|
55
|
+
let id = format!(
|
|
56
|
+
"inbox-{}-{}-{}",
|
|
57
|
+
std::process::id(),
|
|
58
|
+
chrono::Utc::now().timestamp_nanos_opt().unwrap_or_default(),
|
|
59
|
+
NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed)
|
|
60
|
+
);
|
|
61
|
+
json!({"message_id": id,
|
|
62
|
+
"created_at": chrono::Utc::now().to_rfc3339(), "sender": sender, "recipient": recipient,
|
|
63
|
+
"content": content, "team": team, "kind": kind})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// No acknowledgement, compaction, state transition, or filesystem creation on read.
|
|
67
|
+
pub fn read(
|
|
68
|
+
workspace: &Path,
|
|
69
|
+
recipient: &str,
|
|
70
|
+
limit: usize,
|
|
71
|
+
team: Option<&str>,
|
|
72
|
+
) -> Result<Value, String> {
|
|
73
|
+
let path = path(workspace, recipient)?;
|
|
74
|
+
let file = match File::open(&path) {
|
|
75
|
+
Ok(file) => file,
|
|
76
|
+
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
|
|
77
|
+
return Ok(json!({"recipient": recipient, "messages": []}))
|
|
78
|
+
}
|
|
79
|
+
Err(e) => return Err(format!("{}: {e}", path.display())),
|
|
80
|
+
};
|
|
81
|
+
let mut messages = VecDeque::new();
|
|
82
|
+
let mut reader = BufReader::new(file);
|
|
83
|
+
let mut line = String::new();
|
|
84
|
+
let mut line_number = 0;
|
|
85
|
+
loop {
|
|
86
|
+
line.clear();
|
|
87
|
+
if reader.read_line(&mut line).map_err(|e| e.to_string())? == 0 {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
line_number += 1;
|
|
91
|
+
// A concurrent appender may not have completed its last record yet.
|
|
92
|
+
if !line.ends_with('\n') {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if line.trim().is_empty() {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
let value: Value = serde_json::from_str(&line)
|
|
99
|
+
.map_err(|e| format!("{}:{line_number}: {e}", path.display()))?;
|
|
100
|
+
if team.is_some_and(|team| {
|
|
101
|
+
value
|
|
102
|
+
.get("team")
|
|
103
|
+
.and_then(Value::as_str)
|
|
104
|
+
.is_some_and(|record_team| record_team != team)
|
|
105
|
+
}) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if limit > 0 {
|
|
109
|
+
if messages.len() == limit {
|
|
110
|
+
messages.pop_front();
|
|
111
|
+
}
|
|
112
|
+
messages.push_back(value);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
Ok(json!({"recipient": recipient, "messages": messages}))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#[cfg(test)]
|
|
119
|
+
mod tests {
|
|
120
|
+
use super::*;
|
|
121
|
+
struct TempWorkspace(PathBuf);
|
|
122
|
+
impl TempWorkspace {
|
|
123
|
+
fn new(label: &str) -> Self {
|
|
124
|
+
let path = std::env::temp_dir().join(format!(
|
|
125
|
+
"{label}-{}-{}",
|
|
126
|
+
std::process::id(),
|
|
127
|
+
chrono::Utc::now().timestamp_nanos_opt().unwrap()
|
|
128
|
+
));
|
|
129
|
+
std::fs::create_dir_all(&path).unwrap();
|
|
130
|
+
Self(path)
|
|
131
|
+
}
|
|
132
|
+
fn path(&self) -> &Path {
|
|
133
|
+
&self.0
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
impl Drop for TempWorkspace {
|
|
137
|
+
fn drop(&mut self) {
|
|
138
|
+
let _ = std::fs::remove_dir_all(&self.0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#[test]
|
|
143
|
+
fn read_missing_inbox_is_side_effect_free() {
|
|
144
|
+
let ws = TempWorkspace::new("direct-inbox-missing");
|
|
145
|
+
assert_eq!(
|
|
146
|
+
read(ws.path(), "leader", 3, None).unwrap()["messages"],
|
|
147
|
+
json!([])
|
|
148
|
+
);
|
|
149
|
+
assert!(!ws.path().join(".team/inbox").exists());
|
|
150
|
+
assert!(read(ws.path(), "../escape", 3, None).is_err());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#[test]
|
|
154
|
+
fn tails_records_and_does_not_consume_them() {
|
|
155
|
+
let ws = TempWorkspace::new("direct-inbox-tail");
|
|
156
|
+
for n in 0..5 {
|
|
157
|
+
append(ws.path(), "leader", &json!({"content": n})).unwrap();
|
|
158
|
+
}
|
|
159
|
+
let expected = json!([{"content": 2}, {"content": 3}, {"content": 4}]);
|
|
160
|
+
assert_eq!(
|
|
161
|
+
read(ws.path(), "leader", 3, None).unwrap()["messages"],
|
|
162
|
+
expected
|
|
163
|
+
);
|
|
164
|
+
assert_eq!(
|
|
165
|
+
read(ws.path(), "leader", 3, None).unwrap()["messages"],
|
|
166
|
+
expected
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -621,6 +621,11 @@ fn read_all_entries() -> Vec<(PathBuf, LeaderRegistryEntry)> {
|
|
|
621
621
|
.collect()
|
|
622
622
|
}
|
|
623
623
|
|
|
624
|
+
/// Read discovery records without classifying or mutating canonical runtime state.
|
|
625
|
+
pub(crate) fn snapshots() -> Vec<LeaderRegistryEntry> {
|
|
626
|
+
read_all_entries().into_iter().map(|(_, entry)| entry).collect()
|
|
627
|
+
}
|
|
628
|
+
|
|
624
629
|
/// Validate a registry entry against its canonical workspace state.
|
|
625
630
|
/// Returns the wire status label — LIVE when canonical `leader_receiver`
|
|
626
631
|
/// matches, STALE otherwise. This is the pruning gate for GC and the
|
|
@@ -336,6 +336,7 @@ fn leader_start_plan_with_ambient_authority(
|
|
|
336
336
|
external_path,
|
|
337
337
|
allow_nested_attach,
|
|
338
338
|
),
|
|
339
|
+
session_dir: parsed.session_dir.as_deref(),
|
|
339
340
|
},
|
|
340
341
|
)
|
|
341
342
|
.map_err(|error| LeaderError::Start(error.to_string()))?;
|
|
@@ -3538,7 +3539,7 @@ mod tests {
|
|
|
3538
3539
|
std::fs::write(&path, serde_json::json!({
|
|
3539
3540
|
"active_team_key":"current", "session_name":"team-existing-workers",
|
|
3540
3541
|
"spec_path":"/fixture/spec.yml", "team_dir":"/fixture/roles",
|
|
3541
|
-
"agents":{"worker":{"agent_id":"worker","provider":"
|
|
3542
|
+
"agents":{"worker":{"agent_id":"worker","provider":"pi","status":status}},
|
|
3542
3543
|
"tasks":[{"task_id":"existing-task"}],
|
|
3543
3544
|
}).to_string()).unwrap();
|
|
3544
3545
|
persist_exec_provider_leader_binding(&plan, &workspace, &authority, false).unwrap();
|
|
@@ -23,8 +23,8 @@ fn attach_leader_errors_when_pane_not_resolvable() {
|
|
|
23
23
|
"Validation 错误须含目标 pane id,got {msg}"
|
|
24
24
|
);
|
|
25
25
|
assert!(
|
|
26
|
-
msg.contains("not found"),
|
|
27
|
-
"
|
|
26
|
+
msg.contains("not found") || msg.contains("leader pane validation failed"),
|
|
27
|
+
"missing pane must fail physical validation, got {msg}"
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
Err(other) => panic!("期望 Validation(pane not found),got {other:?}"),
|
|
@@ -153,6 +153,7 @@ fn leader_prompt_plans_preserve_absent_baseline_append_only_leaders_and_never_ma
|
|
|
153
153
|
workspace: &workspace, team_id: "current", agent_id: "worker", model: None,
|
|
154
154
|
effort: None, system_prompt: "Compiled Worker contract; unchanged", team_mcp_tools: &["report_result"],
|
|
155
155
|
mcp_config: &mcp, session_scope: PiSessionScope::Isolated,
|
|
156
|
+
session_dir: None,
|
|
156
157
|
}).unwrap();
|
|
157
158
|
assert!(!worker.argv.iter().any(|arg| arg.contains(SENTINEL)));
|
|
158
159
|
assert!(!mcp.raw.to_string().contains(SENTINEL));
|
|
@@ -86,6 +86,8 @@ pub mod coordinator;
|
|
|
86
86
|
pub mod diagnose;
|
|
87
87
|
pub mod leader;
|
|
88
88
|
pub mod messaging;
|
|
89
|
+
pub mod direct_delivery;
|
|
90
|
+
pub mod inbox_store;
|
|
89
91
|
|
|
90
92
|
// step 13-15 (lifecycle/mcp_server/cli/packaging) — ROUND-0.5b behavioral-rich 骨架(entry-fn 签名 +
|
|
91
93
|
// 富返回类型,fn body unimplemented!(),P2 porter 落实现)。lifecycle=quick-start/restart/display;
|
|
@@ -274,6 +274,7 @@ pub fn add_agent(
|
|
|
274
274
|
&transport,
|
|
275
275
|
Some(reservation),
|
|
276
276
|
false,
|
|
277
|
+
None,
|
|
277
278
|
)
|
|
278
279
|
}
|
|
279
280
|
|
|
@@ -364,6 +365,7 @@ pub(crate) fn add_agent_with_transport(
|
|
|
364
365
|
transport,
|
|
365
366
|
Some(reservation),
|
|
366
367
|
false,
|
|
368
|
+
None,
|
|
367
369
|
)
|
|
368
370
|
}
|
|
369
371
|
|
|
@@ -542,6 +544,7 @@ pub(super) fn add_agent_with_transport_at_paths(
|
|
|
542
544
|
transport,
|
|
543
545
|
None,
|
|
544
546
|
false,
|
|
547
|
+
None,
|
|
545
548
|
)
|
|
546
549
|
}
|
|
547
550
|
|
|
@@ -565,6 +568,34 @@ pub(crate) fn add_agent_with_transport_at_paths_locked(
|
|
|
565
568
|
transport,
|
|
566
569
|
None,
|
|
567
570
|
true,
|
|
571
|
+
None,
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/// fork-agent's new seat under the held lifecycle lock: the ordinary add-agent
|
|
576
|
+
/// transaction (and rollback), whose first spawn natively forks `parent`.
|
|
577
|
+
#[allow(clippy::too_many_arguments)]
|
|
578
|
+
pub(crate) fn add_forked_agent_locked(
|
|
579
|
+
run_workspace: &Path,
|
|
580
|
+
team_dir: &Path,
|
|
581
|
+
agent_id: &AgentId,
|
|
582
|
+
role_file_path: &Path,
|
|
583
|
+
open_display: bool,
|
|
584
|
+
team: Option<&str>,
|
|
585
|
+
transport: &dyn Transport,
|
|
586
|
+
parent: &crate::provider::SessionId,
|
|
587
|
+
) -> Result<AddAgentReport, LifecycleError> {
|
|
588
|
+
add_agent_with_transport_at_paths_reserved(
|
|
589
|
+
run_workspace,
|
|
590
|
+
team_dir,
|
|
591
|
+
agent_id,
|
|
592
|
+
role_file_path,
|
|
593
|
+
open_display,
|
|
594
|
+
team,
|
|
595
|
+
transport,
|
|
596
|
+
None,
|
|
597
|
+
true,
|
|
598
|
+
Some(parent),
|
|
568
599
|
)
|
|
569
600
|
}
|
|
570
601
|
|
|
@@ -579,6 +610,7 @@ fn add_agent_with_transport_at_paths_reserved(
|
|
|
579
610
|
transport: &dyn Transport,
|
|
580
611
|
reservation: Option<AgentReservation>,
|
|
581
612
|
lifecycle_lock_held: bool,
|
|
613
|
+
fork_parent: Option<&crate::provider::SessionId>,
|
|
582
614
|
) -> Result<AddAgentReport, LifecycleError> {
|
|
583
615
|
let runtime_state = crate::state::persist::load_runtime_state(run_workspace)
|
|
584
616
|
.map_err(|e| LifecycleError::StatePersist(e.to_string()))?;
|
|
@@ -699,6 +731,7 @@ fn add_agent_with_transport_at_paths_reserved(
|
|
|
699
731
|
agent_id,
|
|
700
732
|
&meta,
|
|
701
733
|
role_file_path,
|
|
734
|
+
fork_parent,
|
|
702
735
|
) {
|
|
703
736
|
rollback_add_agent_atomic(
|
|
704
737
|
run_workspace,
|