@team-agent/installer 0.5.126 → 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 -91
- package/crates/team-agent/src/cli/emit.rs +61 -28
- package/crates/team-agent/src/cli/grok_slot.rs +88 -3
- package/crates/team-agent/src/cli/intent/runtime.rs +38 -9
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +147 -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 +38 -9
- package/crates/team-agent/src/cli/models.rs +789 -186
- 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 +3 -3
- package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
- package/crates/team-agent/src/cli/tests/run_delegation.rs +12 -9
- package/crates/team-agent/src/cli/tests/status_send.rs +70 -273
- package/crates/team-agent/src/compiler/tests.rs +39 -27
- package/crates/team-agent/src/compiler.rs +206 -6
- package/crates/team-agent/src/contract_runtime/backend.rs +181 -11
- package/crates/team-agent/src/contract_runtime/commands.rs +338 -7
- package/crates/team-agent/src/contract_runtime/config.rs +30 -19
- 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 -14
- 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 +93 -130
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +8 -29
- package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +44 -2
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
- package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
- 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 +36 -179
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +13 -488
- 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 +26 -2
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +41 -31
- package/crates/team-agent/src/lifecycle/launch.rs +27 -12
- package/crates/team-agent/src/lifecycle/profile_launch.rs +318 -64
- 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 +298 -133
- package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
- 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 +79 -27
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +37 -240
- 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 +329 -70
- 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 +25 -39
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
- package/crates/team-agent/src/lifecycle/tests/core.rs +39 -36
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
- 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 +15 -133
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +164 -282
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
- 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 +14 -15
- package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1374
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +254 -2
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +74 -19
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +38 -39
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +51 -88
- package/crates/team-agent/src/lifecycle/tests.rs +3 -4
- package/crates/team-agent/src/lifecycle/types.rs +18 -5
- 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 +86 -109
- 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 +143 -253
- 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 +255 -150
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/messaging/tests/runtime.rs +9 -115
- package/crates/team-agent/src/messaging/tests/spine.rs +44 -24
- package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
- package/crates/team-agent/src/messaging/types.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +208 -254
- 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 -7
- 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 +111 -111
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +10 -18
- package/crates/team-agent/src/provider/session/context_fork.rs +87 -74
- package/crates/team-agent/src/provider/session/mod.rs +2 -3
- package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +47 -47
- package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
- package/crates/team-agent/src/provider/session_scan.rs +13 -13
- package/crates/team-agent/src/provider/tests/adapter.rs +127 -121
- package/crates/team-agent/src/provider/tests/classify.rs +0 -53
- package/crates/team-agent/src/provider/tests/command_helpers.rs +11 -19
- package/crates/team-agent/src/provider/tests/idle.rs +13 -19
- package/crates/team-agent/src/provider/types.rs +0 -4
- package/crates/team-agent/src/provider/wire.rs +34 -20
- 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 +9 -43
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +7 -8
- package/skills/team-agent/command-coverage.json +15 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +5 -3
- package/skills/team-agent/references/team-agent-operator.md +5 -3
- package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
- package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
- package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
- package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
- package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
- package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
- package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
- package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
- package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
//! `swallow-batch4-cr-verdict.md` (workspace artifacts; BOTH points APPROVE'd,
|
|
5
5
|
//! 8 constraints C1-C8 + 6 reverse cases — folded below).
|
|
6
6
|
//!
|
|
7
|
-
//! Point 1 (C1-C4)
|
|
8
|
-
//!
|
|
7
|
+
//! Point 1 (C1-C4): a corrupt provider-config JSON must FAIL EXPLICITLY — today
|
|
8
|
+
//! profile_launch.rs:639-649 `read_json_object` turns any parse failure into an
|
|
9
|
+
//! empty map and `write_json_object` then flattens the user's file (silent
|
|
10
|
+
//! destructive rewrite; MUST-NOT-9 / MUST-NOT-13 violation).
|
|
9
11
|
//! Point 2 (C5-C8): MCP scope validation must FAIL CLOSED when the runtime state is
|
|
10
12
|
//! unreadable — today `load_runtime_state(..).unwrap_or(json!({}))`
|
|
11
13
|
//! (mcp_server/tools.rs:574/:232) silently substitutes an empty state, so a
|
|
@@ -23,9 +25,75 @@ mod hermetic_guard;
|
|
|
23
25
|
#[allow(dead_code)]
|
|
24
26
|
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
25
27
|
|
|
28
|
+
use std::path::{Path, PathBuf};
|
|
29
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
30
|
+
|
|
26
31
|
use mcp_sim_harness::McpSimHarness;
|
|
27
32
|
use serde_json::json;
|
|
28
33
|
use serial_test::serial;
|
|
34
|
+
use team_agent::lifecycle::launch_with_transport;
|
|
35
|
+
|
|
36
|
+
/// C1-C4 + reverse cases `profile_invalid_json_returns_error_and_does_not_overwrite_file`
|
|
37
|
+
/// / `..._includes_path_and_parse_detail_and_next_action`: launching a claude
|
|
38
|
+
/// compatible_api profile over a CORRUPT `.claude.json` must return a structured error
|
|
39
|
+
/// (path + parse detail + next action) and leave the corrupt file byte-identical —
|
|
40
|
+
/// never rewrite it with a flattened empty object.
|
|
41
|
+
#[test]
|
|
42
|
+
#[serial(b4_mcp)]
|
|
43
|
+
fn b4_profile_invalid_json_fails_explicit_and_never_flattens_the_file() {
|
|
44
|
+
// Pin a neutral process ancestry so the launch path is deterministic regardless of
|
|
45
|
+
// which provider flags this test process inherited (same guard as the #264 batch).
|
|
46
|
+
std::env::set_var(
|
|
47
|
+
"TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON",
|
|
48
|
+
"[\"/bin/zsh\"]",
|
|
49
|
+
);
|
|
50
|
+
let ws = tmp_ws("b4-profile");
|
|
51
|
+
let team_dir = write_claude_compatible_team(&ws);
|
|
52
|
+
let config_dir = ws.join(".team/runtime/provider-config/worker_a/claude");
|
|
53
|
+
std::fs::create_dir_all(&config_dir).unwrap();
|
|
54
|
+
let corrupt = b"{ this is the user's corrupt claude state".to_vec();
|
|
55
|
+
std::fs::write(config_dir.join(".claude.json"), &corrupt).unwrap();
|
|
56
|
+
|
|
57
|
+
let result = launch_with_transport(
|
|
58
|
+
&team_dir.join("team.spec.yaml"),
|
|
59
|
+
false,
|
|
60
|
+
true,
|
|
61
|
+
true,
|
|
62
|
+
&offline_transport::RecordingTransport::new(),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
let mut failures = Vec::new();
|
|
66
|
+
match &result {
|
|
67
|
+
Ok(report) => failures.push(format!(
|
|
68
|
+
"C1/C2: a corrupt provider-config JSON must fail the launch with a \
|
|
69
|
+
structured profile_invalid_json error, not silently continue; got Ok({report:?})"
|
|
70
|
+
)),
|
|
71
|
+
Err(error) => {
|
|
72
|
+
let text = error.to_string();
|
|
73
|
+
if !text.contains(".claude.json") {
|
|
74
|
+
failures.push(format!(
|
|
75
|
+
"C1/N38: the error must name the offending path; got {text}"
|
|
76
|
+
));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let after = std::fs::read(config_dir.join(".claude.json")).unwrap_or_default();
|
|
81
|
+
if after != corrupt {
|
|
82
|
+
failures.push(format!(
|
|
83
|
+
"C3/C4: the user's corrupt file must stay byte-identical (framework never \
|
|
84
|
+
flattens user files on load failure — MUST-NOT-9); before={} bytes, after={} bytes: {:?}",
|
|
85
|
+
corrupt.len(),
|
|
86
|
+
after.len(),
|
|
87
|
+
String::from_utf8_lossy(&after)
|
|
88
|
+
));
|
|
89
|
+
}
|
|
90
|
+
std::env::remove_var("TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON");
|
|
91
|
+
assert!(
|
|
92
|
+
failures.is_empty(),
|
|
93
|
+
"batch4 point-1 profile fail-explicit contract failed:\n{}",
|
|
94
|
+
failures.join("\n")
|
|
95
|
+
);
|
|
96
|
+
}
|
|
29
97
|
|
|
30
98
|
/// C5-C8 + reverse cases `scope_unverifiable_when_state_read_fails_returns_structured_refusal`
|
|
31
99
|
/// / `scope_unverifiable_state_recovers_retry_passes`: with the runtime state
|
|
@@ -88,3 +156,187 @@ gate (owner-required refusal), not some degraded path; body={}",
|
|
|
88
156
|
failures.join("\n")
|
|
89
157
|
);
|
|
90
158
|
}
|
|
159
|
+
|
|
160
|
+
// ───────────────────────────────────── fixtures ─────────────────────────────────────
|
|
161
|
+
|
|
162
|
+
/// Compiled claude compatible_api team with a profile (the path that maintains the
|
|
163
|
+
/// managed `.claude.json`). Mirrors the #264 profile fixture, claude flavor.
|
|
164
|
+
fn write_claude_compatible_team(ws: &Path) -> PathBuf {
|
|
165
|
+
let team = ws.join("teamdir");
|
|
166
|
+
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
167
|
+
std::fs::create_dir_all(team.join("profiles")).unwrap();
|
|
168
|
+
std::fs::write(
|
|
169
|
+
team.join("TEAM.md"),
|
|
170
|
+
"---\nname: b4team\nobjective: batch4 profile fixture.\nprovider: claude\n---\n\nTeam.\n",
|
|
171
|
+
)
|
|
172
|
+
.unwrap();
|
|
173
|
+
std::fs::write(
|
|
174
|
+
team.join("agents/worker_a.md"),
|
|
175
|
+
"---\nname: worker_a\nrole: Compat Worker\nprovider: claude\nmodel: claude-haiku\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: relay\ntools:\n - mcp_team\n---\n\nCompat worker.\n",
|
|
176
|
+
)
|
|
177
|
+
.unwrap();
|
|
178
|
+
std::fs::write(
|
|
179
|
+
team.join("profiles/relay.env"),
|
|
180
|
+
"AUTH_MODE=compatible_api\nBASE_URL=https://relay.example/v1\nAPI_KEY=sk-relay-b4\nMODEL=claude-haiku\n",
|
|
181
|
+
)
|
|
182
|
+
.unwrap();
|
|
183
|
+
let spec = team_agent::compiler::compile_team(&team).expect("compile fixture team");
|
|
184
|
+
std::fs::write(
|
|
185
|
+
team.join("team.spec.yaml"),
|
|
186
|
+
team_agent::model::yaml::dumps(&spec),
|
|
187
|
+
)
|
|
188
|
+
.unwrap();
|
|
189
|
+
team
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
mod offline_transport {
|
|
193
|
+
use super::*;
|
|
194
|
+
use std::collections::BTreeMap;
|
|
195
|
+
use std::sync::Mutex;
|
|
196
|
+
use team_agent::transport::{
|
|
197
|
+
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
198
|
+
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName,
|
|
199
|
+
SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
|
|
200
|
+
TurnVerification, WindowName,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
#[derive(Default)]
|
|
204
|
+
pub struct RecordingTransport {
|
|
205
|
+
session_present: Mutex<bool>,
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
impl RecordingTransport {
|
|
209
|
+
pub fn new() -> Self {
|
|
210
|
+
Self::default()
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
impl Transport for RecordingTransport {
|
|
215
|
+
fn kind(&self) -> BackendKind {
|
|
216
|
+
BackendKind::Tmux
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fn spawn_first(
|
|
220
|
+
&self,
|
|
221
|
+
session: &SessionName,
|
|
222
|
+
window: &WindowName,
|
|
223
|
+
_argv: &[String],
|
|
224
|
+
_cwd: &Path,
|
|
225
|
+
_env: &BTreeMap<String, String>,
|
|
226
|
+
) -> Result<SpawnResult, TransportError> {
|
|
227
|
+
*self.session_present.lock().unwrap() = true;
|
|
228
|
+
Ok(SpawnResult {
|
|
229
|
+
pane_id: PaneId::new("%1"),
|
|
230
|
+
session: session.clone(),
|
|
231
|
+
window: window.clone(),
|
|
232
|
+
child_pid: None,
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
fn spawn_into(
|
|
237
|
+
&self,
|
|
238
|
+
session: &SessionName,
|
|
239
|
+
window: &WindowName,
|
|
240
|
+
argv: &[String],
|
|
241
|
+
cwd: &Path,
|
|
242
|
+
env: &BTreeMap<String, String>,
|
|
243
|
+
) -> Result<SpawnResult, TransportError> {
|
|
244
|
+
self.spawn_first(session, window, argv, cwd, env)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
fn inject(
|
|
248
|
+
&self,
|
|
249
|
+
_target: &Target,
|
|
250
|
+
_payload: &InjectPayload,
|
|
251
|
+
_submit: Key,
|
|
252
|
+
_bracketed: bool,
|
|
253
|
+
) -> Result<InjectReport, TransportError> {
|
|
254
|
+
Ok(InjectReport {
|
|
255
|
+
stage_reached: InjectStage::Submit,
|
|
256
|
+
inject_verification: InjectVerification::CaptureContainsToken,
|
|
257
|
+
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
258
|
+
turn_verification: TurnVerification::NotYetObserved,
|
|
259
|
+
attempts: 1,
|
|
260
|
+
submit_diagnostics: None,
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
265
|
+
Ok(())
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
fn capture(
|
|
269
|
+
&self,
|
|
270
|
+
_target: &Target,
|
|
271
|
+
range: CaptureRange,
|
|
272
|
+
) -> Result<CapturedText, TransportError> {
|
|
273
|
+
Ok(CapturedText {
|
|
274
|
+
text: "Claude Code\n> ".to_string(),
|
|
275
|
+
range,
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
fn query(
|
|
280
|
+
&self,
|
|
281
|
+
_target: &Target,
|
|
282
|
+
field: PaneField,
|
|
283
|
+
) -> Result<Option<String>, TransportError> {
|
|
284
|
+
match field {
|
|
285
|
+
PaneField::PaneWidth => Ok(Some("120".to_string())),
|
|
286
|
+
_ => Ok(None),
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
fn liveness(
|
|
291
|
+
&self,
|
|
292
|
+
_pane: &PaneId,
|
|
293
|
+
) -> Result<team_agent::transport::PaneLiveness, TransportError> {
|
|
294
|
+
Ok(team_agent::transport::PaneLiveness::Live)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
298
|
+
Ok(Vec::new())
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
302
|
+
Ok(*self.session_present.lock().unwrap())
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
306
|
+
Ok(Vec::new())
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
fn set_session_env(
|
|
310
|
+
&self,
|
|
311
|
+
_session: &SessionName,
|
|
312
|
+
_key: &str,
|
|
313
|
+
_value: &str,
|
|
314
|
+
) -> Result<SetEnvOutcome, TransportError> {
|
|
315
|
+
Ok(SetEnvOutcome::Applied)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
319
|
+
Ok(())
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
|
|
323
|
+
Ok(())
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
327
|
+
Ok(AttachOutcome::Attached)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
fn tmp_ws(tag: &str) -> PathBuf {
|
|
333
|
+
static N: AtomicU64 = AtomicU64::new(0);
|
|
334
|
+
let dir = std::env::temp_dir().join(format!(
|
|
335
|
+
"ta-rs-swallow-{tag}-{}-{}",
|
|
336
|
+
std::process::id(),
|
|
337
|
+
N.fetch_add(1, Ordering::Relaxed)
|
|
338
|
+
));
|
|
339
|
+
let _ = std::fs::remove_dir_all(&dir);
|
|
340
|
+
std::fs::create_dir_all(&dir).unwrap();
|
|
341
|
+
std::fs::canonicalize(dir).unwrap()
|
|
342
|
+
}
|
|
@@ -245,7 +245,7 @@ fn write_team_dir(root: &Path, dir_name: &str, agent: &str) -> PathBuf {
|
|
|
245
245
|
|
|
246
246
|
fn role_doc(agent: &str) -> String {
|
|
247
247
|
format!(
|
|
248
|
-
"---\nname: {agent}\nrole: Worker\nprovider:
|
|
248
|
+
"---\nname: {agent}\nrole: Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
249
249
|
)
|
|
250
250
|
}
|
|
251
251
|
|
|
@@ -288,7 +288,7 @@ fn agent_state(team: &str, agent: &str) -> Value {
|
|
|
288
288
|
"agent_id": agent,
|
|
289
289
|
"owner_team_id": team,
|
|
290
290
|
"status": "running",
|
|
291
|
-
"provider": "
|
|
291
|
+
"provider": "fake",
|
|
292
292
|
"role": "Worker",
|
|
293
293
|
"window": agent
|
|
294
294
|
})
|
|
@@ -881,7 +881,7 @@ fn team_dir_with_name(root: &Path, dir_name: &str, spec_name: &str, agent_id: &s
|
|
|
881
881
|
|
|
882
882
|
fn role_doc(name: &str) -> String {
|
|
883
883
|
format!(
|
|
884
|
-
"---\nname: {name}\nrole: Worker\nprovider:
|
|
884
|
+
"---\nname: {name}\nrole: Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
885
885
|
)
|
|
886
886
|
}
|
|
887
887
|
|
|
@@ -881,7 +881,7 @@ fn team_entry(
|
|
|
881
881
|
json!({
|
|
882
882
|
"agent_id": agent_id,
|
|
883
883
|
"status": status,
|
|
884
|
-
"provider": "
|
|
884
|
+
"provider": "fake",
|
|
885
885
|
"auth_mode": "subscription",
|
|
886
886
|
"role": agent_id,
|
|
887
887
|
"window": agent_id,
|
|
@@ -1057,7 +1057,7 @@ fn team_dir(root: &Path, name: &str, agents: &[(&str, &str)]) -> PathBuf {
|
|
|
1057
1057
|
|
|
1058
1058
|
fn role_doc(name: &str, role: &str) -> String {
|
|
1059
1059
|
format!(
|
|
1060
|
-
"---\nname: {name}\nrole: {role}\nprovider:
|
|
1060
|
+
"---\nname: {name}\nrole: {role}\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{role}.\n"
|
|
1061
1061
|
)
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
@@ -274,7 +274,7 @@ impl RollbackFixture {
|
|
|
274
274
|
"agents": {
|
|
275
275
|
"alpha": {
|
|
276
276
|
"status": "stopped",
|
|
277
|
-
"provider": "
|
|
277
|
+
"provider": "fake",
|
|
278
278
|
"auth_mode": "subscription",
|
|
279
279
|
"window": "alpha",
|
|
280
280
|
"session_id": "sess-alpha",
|
|
@@ -285,7 +285,7 @@ impl RollbackFixture {
|
|
|
285
285
|
},
|
|
286
286
|
"bravo": {
|
|
287
287
|
"status": "running",
|
|
288
|
-
"provider": "
|
|
288
|
+
"provider": "fake",
|
|
289
289
|
"auth_mode": "subscription",
|
|
290
290
|
"window": "bravo",
|
|
291
291
|
"session_id": "sess-bravo",
|
|
@@ -322,7 +322,7 @@ impl RollbackFixture {
|
|
|
322
322
|
"agents": {
|
|
323
323
|
"newfork": {
|
|
324
324
|
"status": "running",
|
|
325
|
-
"provider": "
|
|
325
|
+
"provider": "fake",
|
|
326
326
|
"pane_id": "%sibling-newfork",
|
|
327
327
|
"owner_team_id": "sibling"
|
|
328
328
|
}
|
|
@@ -390,7 +390,7 @@ impl RollbackFixture {
|
|
|
390
390
|
|
|
391
391
|
fn agent_doc(name: &str, role: &str) -> String {
|
|
392
392
|
format!(
|
|
393
|
-
"---\nname: {name}\nrole: {role}\nprovider:
|
|
393
|
+
"---\nname: {name}\nrole: {role}\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{role}.\n"
|
|
394
394
|
)
|
|
395
395
|
}
|
|
396
396
|
|
|
@@ -248,7 +248,7 @@ fn upgrade_restart_plan_uses_persisted_session_id() {
|
|
|
248
248
|
"agents": {
|
|
249
249
|
"w1": {
|
|
250
250
|
"status": "running",
|
|
251
|
-
"provider": "
|
|
251
|
+
"provider": "copilot",
|
|
252
252
|
"session_id": "sess-upgrade",
|
|
253
253
|
"rollout_path": rollout.to_string_lossy(),
|
|
254
254
|
"first_send_at": "2026-06-07T01:00:00+00:00"
|
|
@@ -276,7 +276,7 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
276
276
|
"agents": {
|
|
277
277
|
"never_captured": {
|
|
278
278
|
"status": "running",
|
|
279
|
-
"provider": "
|
|
279
|
+
"provider": "claude",
|
|
280
280
|
"session_id": null,
|
|
281
281
|
"first_send_at": null
|
|
282
282
|
}
|
|
@@ -302,15 +302,15 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
302
302
|
/// state — restart without --allow-fresh must STILL Refuse, never
|
|
303
303
|
/// silently fresh (architect rule: 绝不静默 fresh). This is what the
|
|
304
304
|
/// existing `upgrade_restart_refuses_interacted_worker_without_session_id`
|
|
305
|
-
/// test pins; this test pins the SAME guard for
|
|
305
|
+
/// test pins; this test pins the SAME guard for Claude (the partial-resume
|
|
306
306
|
/// change must not weaken it for any provider).
|
|
307
307
|
#[test]
|
|
308
|
-
fn
|
|
308
|
+
fn restart_refuses_interacted_claude_worker_without_session_id_partial_resume_preserves_guard() {
|
|
309
309
|
let state = json!({
|
|
310
310
|
"agents": {
|
|
311
311
|
"interacted_no_sid": {
|
|
312
312
|
"status": "running",
|
|
313
|
-
"provider": "
|
|
313
|
+
"provider": "claude",
|
|
314
314
|
"session_id": null,
|
|
315
315
|
"first_send_at": "2026-06-26T01:00:00+00:00"
|
|
316
316
|
}
|
|
@@ -332,7 +332,7 @@ fn upgrade_restart_refuses_interacted_worker_without_session_id() {
|
|
|
332
332
|
"agents": {
|
|
333
333
|
"w1": {
|
|
334
334
|
"status": "running",
|
|
335
|
-
"provider": "
|
|
335
|
+
"provider": "fake",
|
|
336
336
|
"session_id": null,
|
|
337
337
|
"first_send_at": "2026-06-07T01:00:00+00:00"
|
|
338
338
|
}
|
|
@@ -358,6 +358,7 @@ fn upgrade_rust_mcp_config_uses_current_binary_and_runtime_key() {
|
|
|
358
358
|
fixture.write_spec(TEAM_KEY, LEGACY_NAME);
|
|
359
359
|
fixture.seed_restartable_state();
|
|
360
360
|
fixture.seed_healthy_coordinator();
|
|
361
|
+
let _home = fixture.copilot_home_with_session("sess-upgrade");
|
|
361
362
|
let transport = RecordingTransport::new().with_session_present(false);
|
|
362
363
|
|
|
363
364
|
let report = restart_with_transport(&fixture.team_dir, false, Some(TEAM_KEY), &transport)
|
|
@@ -373,22 +374,37 @@ fn upgrade_rust_mcp_config_uses_current_binary_and_runtime_key() {
|
|
|
373
374
|
format!("{report:?}").contains("Resumed"),
|
|
374
375
|
"restart report must show resume path for persisted session_id; report={report:?}"
|
|
375
376
|
);
|
|
377
|
+
// Copilot reads its MCP config from `--additional-mcp-config @<file>`.
|
|
378
|
+
let mcp_config_path = spawn
|
|
379
|
+
.argv
|
|
380
|
+
.windows(2)
|
|
381
|
+
.find(|pair| pair[0] == "--additional-mcp-config")
|
|
382
|
+
.and_then(|pair| pair[1].strip_prefix('@'))
|
|
383
|
+
.map(PathBuf::from)
|
|
384
|
+
.unwrap_or_else(|| {
|
|
385
|
+
panic!("restarted copilot worker must point --additional-mcp-config at its MCP file; command_line={command_line:?}")
|
|
386
|
+
});
|
|
387
|
+
let mcp_text = std::fs::read_to_string(&mcp_config_path).unwrap();
|
|
388
|
+
let mcp_config: Value = serde_json::from_str(&mcp_text).unwrap();
|
|
376
389
|
assert!(
|
|
377
|
-
|
|
378
|
-
"restarted worker MCP command must use the current Rust candidate binary path; current_exe={current_exe}
|
|
390
|
+
mcp_text.contains(¤t_exe),
|
|
391
|
+
"restarted worker MCP command must use the current Rust candidate binary path; current_exe={current_exe} mcp_config={mcp_text}"
|
|
379
392
|
);
|
|
380
393
|
assert!(
|
|
381
394
|
command_line.contains("TEAM_AGENT_OWNER_TEAM_ID=upgrade-key")
|
|
382
|
-
&&
|
|
383
|
-
|
|
395
|
+
&& mcp_config
|
|
396
|
+
.pointer("/mcpServers/team_orchestrator/env/TEAM_AGENT_OWNER_TEAM_ID")
|
|
397
|
+
.and_then(Value::as_str)
|
|
398
|
+
== Some("upgrade-key"),
|
|
399
|
+
"spawn env and MCP config must both use runtime team key upgrade-key; command_line={command_line:?} mcp_config={mcp_text}"
|
|
384
400
|
);
|
|
385
401
|
assert!(
|
|
386
|
-
spawn
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
"restart must resume persisted provider session, not fresh start; command_line={command_line:?}"
|
|
402
|
+
spawn.argv.iter().any(|arg| arg == "copilot")
|
|
403
|
+
&& spawn
|
|
404
|
+
.argv
|
|
405
|
+
.windows(2)
|
|
406
|
+
.any(|pair| pair[0] == "--resume" && pair[1] == "sess-upgrade"),
|
|
407
|
+
"restart must resume persisted provider session (`copilot ... --resume <sid>`), not fresh start; command_line={command_line:?}"
|
|
392
408
|
);
|
|
393
409
|
}
|
|
394
410
|
|
|
@@ -443,7 +459,7 @@ impl UpgradeFixture {
|
|
|
443
459
|
std::fs::create_dir_all(self.team_dir.join("agents")).unwrap();
|
|
444
460
|
std::fs::write(
|
|
445
461
|
self.team_dir.join("agents").join("upgrade_worker.md"),
|
|
446
|
-
"---\nname: upgrade_worker\nrole: Upgrade Worker\nprovider:
|
|
462
|
+
"---\nname: upgrade_worker\nrole: Upgrade Worker\nprovider: copilot\nmodel: gpt-5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n",
|
|
447
463
|
)
|
|
448
464
|
.unwrap();
|
|
449
465
|
let spec = team_agent::compiler::compile_team(&self.team_dir).unwrap();
|
|
@@ -471,7 +487,7 @@ impl UpgradeFixture {
|
|
|
471
487
|
"agents": {
|
|
472
488
|
"upgrade_worker": {
|
|
473
489
|
"status": "running",
|
|
474
|
-
"provider": "
|
|
490
|
+
"provider": "copilot",
|
|
475
491
|
"role": "Upgrade Worker",
|
|
476
492
|
"tools": ["mcp_team"],
|
|
477
493
|
"window": "upgrade_worker",
|
|
@@ -492,7 +508,7 @@ impl UpgradeFixture {
|
|
|
492
508
|
"agents": {
|
|
493
509
|
"upgrade_worker": {
|
|
494
510
|
"status": "running",
|
|
495
|
-
"provider": "
|
|
511
|
+
"provider": "copilot",
|
|
496
512
|
"role": "Upgrade Worker",
|
|
497
513
|
"tools": ["mcp_team"],
|
|
498
514
|
"window": "upgrade_worker",
|
|
@@ -511,6 +527,26 @@ impl UpgradeFixture {
|
|
|
511
527
|
.unwrap();
|
|
512
528
|
}
|
|
513
529
|
|
|
530
|
+
/// Copilot resume backing is the `sessions` row in
|
|
531
|
+
/// `$HOME/.copilot/session-store.db`; seed it under a fixture HOME and point
|
|
532
|
+
/// HOME there for the guard's lifetime (callers are `serial(env)`).
|
|
533
|
+
fn copilot_home_with_session(&self, session_id: &str) -> HomeGuard {
|
|
534
|
+
let home = self.workspace.parent().unwrap().join("home");
|
|
535
|
+
let db = home.join(".copilot").join("session-store.db");
|
|
536
|
+
std::fs::create_dir_all(db.parent().unwrap()).unwrap();
|
|
537
|
+
let conn = rusqlite::Connection::open(db).unwrap();
|
|
538
|
+
conn.execute_batch(
|
|
539
|
+
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
540
|
+
)
|
|
541
|
+
.unwrap();
|
|
542
|
+
conn.execute(
|
|
543
|
+
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-07T01:00:00Z')",
|
|
544
|
+
params![session_id, self.team_dir.to_string_lossy()],
|
|
545
|
+
)
|
|
546
|
+
.unwrap();
|
|
547
|
+
HomeGuard::set(&home)
|
|
548
|
+
}
|
|
549
|
+
|
|
514
550
|
fn dual_team_state(&self, active: &str) -> Value {
|
|
515
551
|
let upgrade = json!({
|
|
516
552
|
"status": "alive",
|
|
@@ -657,6 +693,25 @@ impl UpgradeFixture {
|
|
|
657
693
|
}
|
|
658
694
|
}
|
|
659
695
|
|
|
696
|
+
struct HomeGuard(Option<std::ffi::OsString>);
|
|
697
|
+
|
|
698
|
+
impl HomeGuard {
|
|
699
|
+
fn set(home: &Path) -> Self {
|
|
700
|
+
let previous = std::env::var_os("HOME");
|
|
701
|
+
std::env::set_var("HOME", home);
|
|
702
|
+
Self(previous)
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
impl Drop for HomeGuard {
|
|
707
|
+
fn drop(&mut self) {
|
|
708
|
+
match self.0.take() {
|
|
709
|
+
Some(previous) => std::env::set_var("HOME", previous),
|
|
710
|
+
None => std::env::remove_var("HOME"),
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
660
715
|
#[derive(Debug, Clone)]
|
|
661
716
|
struct RecordedSpawn {
|
|
662
717
|
argv: Vec<String>,
|