@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
|
@@ -12,7 +12,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
|
|
|
12
12
|
use std::sync::{Arc, Mutex};
|
|
13
13
|
|
|
14
14
|
use serde_json::{json, Value};
|
|
15
|
-
use serial_test::file_serial;
|
|
15
|
+
use serial_test::{file_serial, serial};
|
|
16
16
|
use team_agent::lifecycle::{launch_with_transport, restart_with_transport};
|
|
17
17
|
use team_agent::state::persist::{load_runtime_state, save_runtime_state};
|
|
18
18
|
use team_agent::tmux_backend::TmuxBackend;
|
|
@@ -25,9 +25,11 @@ use team_agent::transport::{
|
|
|
25
25
|
|
|
26
26
|
#[test]
|
|
27
27
|
#[ignore = "real-machine: restart/session liveness lifecycle gate"]
|
|
28
|
+
#[serial(env)]
|
|
28
29
|
fn restart_rechecks_session_liveness_before_spawning_second_worker() {
|
|
29
30
|
let fixture = RestartFixture::new("restart-liveness-recording", &["alpha", "bravo"]);
|
|
30
31
|
fixture.seed_resumable_state_with_stale_receiver();
|
|
32
|
+
let _home = HomeGuard::set(&fixture.home());
|
|
31
33
|
let transport = RestartLivenessTransport::new();
|
|
32
34
|
|
|
33
35
|
let result = restart_with_transport(&fixture.team, false, None, &transport);
|
|
@@ -59,9 +61,11 @@ fn restart_rechecks_session_liveness_before_spawning_second_worker() {
|
|
|
59
61
|
|
|
60
62
|
#[test]
|
|
61
63
|
#[ignore = "real-machine: restart/session liveness lifecycle gate"]
|
|
64
|
+
#[serial(env)]
|
|
62
65
|
fn restart_partial_failure_clears_stale_receiver_and_does_not_claim_running_without_pane() {
|
|
63
66
|
let fixture = RestartFixture::new("restart-liveness-state", &["alpha", "bravo"]);
|
|
64
67
|
fixture.seed_resumable_state_with_stale_receiver();
|
|
68
|
+
let _home = HomeGuard::set(&fixture.home());
|
|
65
69
|
let transport = RestartLivenessTransport::new();
|
|
66
70
|
|
|
67
71
|
let _ = restart_with_transport(&fixture.team, false, None, &transport);
|
|
@@ -109,13 +113,13 @@ fn launch_persists_real_pane_id_even_when_pane_pid_is_unavailable() {
|
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
#[test]
|
|
112
|
-
#[ignore = "real-machine: needs real tmux/binary; fake
|
|
116
|
+
#[ignore = "real-machine: needs real tmux/binary; fake copilot exits first resumed worker to reproduce no-server restart"]
|
|
113
117
|
#[file_serial(tmux)]
|
|
114
118
|
fn real_tmux_restart_names_first_resume_agent_when_first_resume_exits_before_second_spawn() {
|
|
115
119
|
let fixture = RestartFixture::new("restart-liveness-real-tmux", &["alpha", "bravo"]);
|
|
116
120
|
fixture.seed_resumable_state_with_stale_receiver();
|
|
117
121
|
let _cleanup = TmuxCleanup::new(&fixture.team);
|
|
118
|
-
let fake_bin = fixture.
|
|
122
|
+
let fake_bin = fixture.install_fake_copilot_that_exits_alpha_resume();
|
|
119
123
|
|
|
120
124
|
let output = Command::new(crate::lifecycle::tests::test_binary_path())
|
|
121
125
|
.args([
|
|
@@ -132,7 +136,8 @@ fn real_tmux_restart_names_first_resume_agent_when_first_resume_exits_before_sec
|
|
|
132
136
|
std::env::var("PATH").unwrap_or_default()
|
|
133
137
|
),
|
|
134
138
|
)
|
|
135
|
-
.env("
|
|
139
|
+
.env("HOME", fixture.home())
|
|
140
|
+
.env("COPILOT_FAKE_LOG", fixture.root.join("fake-copilot.log"))
|
|
136
141
|
.output()
|
|
137
142
|
.expect("run team-agent restart");
|
|
138
143
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
@@ -141,7 +146,7 @@ fn real_tmux_restart_names_first_resume_agent_when_first_resume_exits_before_sec
|
|
|
141
146
|
|
|
142
147
|
assert!(
|
|
143
148
|
!output.status.success(),
|
|
144
|
-
"fixture expects first resumed
|
|
149
|
+
"fixture expects first resumed copilot process to exit and restart to fail honestly; stdout={stdout} stderr={stderr}"
|
|
145
150
|
);
|
|
146
151
|
assert!(
|
|
147
152
|
combined.contains("alpha")
|
|
@@ -492,7 +497,7 @@ impl RestartFixture {
|
|
|
492
497
|
std::fs::write(
|
|
493
498
|
team.join("agents").join(format!("{agent}.md")),
|
|
494
499
|
format!(
|
|
495
|
-
"---\nname: {agent}\nrole: Worker {agent}\nprovider:
|
|
500
|
+
"---\nname: {agent}\nrole: Worker {agent}\nprovider: copilot\nmodel: gpt-5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
496
501
|
),
|
|
497
502
|
)
|
|
498
503
|
.unwrap();
|
|
@@ -519,7 +524,7 @@ impl RestartFixture {
|
|
|
519
524
|
agent.clone(),
|
|
520
525
|
json!({
|
|
521
526
|
"status": "running",
|
|
522
|
-
"provider": "
|
|
527
|
+
"provider": "copilot",
|
|
523
528
|
"role": format!("Worker {agent}"),
|
|
524
529
|
"tools": ["mcp_team"],
|
|
525
530
|
"window": agent,
|
|
@@ -554,18 +559,43 @@ impl RestartFixture {
|
|
|
554
559
|
}),
|
|
555
560
|
)
|
|
556
561
|
.unwrap();
|
|
562
|
+
self.seed_copilot_session_store();
|
|
557
563
|
seed_healthy_coordinator(&self.team);
|
|
558
564
|
}
|
|
559
565
|
|
|
560
|
-
|
|
566
|
+
/// Fixture HOME: copilot resume backing is the `sessions` row in
|
|
567
|
+
/// `$HOME/.copilot/session-store.db`.
|
|
568
|
+
fn home(&self) -> PathBuf {
|
|
569
|
+
self.root.join("home")
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
fn seed_copilot_session_store(&self) {
|
|
573
|
+
let db = self.home().join(".copilot").join("session-store.db");
|
|
574
|
+
std::fs::create_dir_all(db.parent().unwrap()).unwrap();
|
|
575
|
+
let conn = rusqlite::Connection::open(db).unwrap();
|
|
576
|
+
conn.execute_batch(
|
|
577
|
+
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
578
|
+
)
|
|
579
|
+
.unwrap();
|
|
580
|
+
for agent in &self.agents {
|
|
581
|
+
conn.execute(
|
|
582
|
+
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-08T00:00:00Z')",
|
|
583
|
+
rusqlite::params![format!("session-{agent}"), self.team.to_string_lossy()],
|
|
584
|
+
)
|
|
585
|
+
.unwrap();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
fn install_fake_copilot_that_exits_alpha_resume(&self) -> PathBuf {
|
|
561
590
|
let bin = self.root.join("fake-bin");
|
|
562
591
|
std::fs::create_dir_all(&bin).unwrap();
|
|
563
|
-
let script = bin.join("
|
|
592
|
+
let script = bin.join("copilot");
|
|
564
593
|
std::fs::write(
|
|
565
594
|
&script,
|
|
566
595
|
r#"#!/bin/sh
|
|
567
|
-
echo "$@" >> "${
|
|
596
|
+
echo "$@" >> "${COPILOT_FAKE_LOG:-/tmp/team-agent-fake-copilot.log}"
|
|
568
597
|
case "$*" in
|
|
598
|
+
"mcp list") exit 0 ;;
|
|
569
599
|
*session-alpha*) exit 0 ;;
|
|
570
600
|
*) sleep 30 ;;
|
|
571
601
|
esac
|
|
@@ -581,6 +611,25 @@ esac
|
|
|
581
611
|
}
|
|
582
612
|
}
|
|
583
613
|
|
|
614
|
+
struct HomeGuard(Option<std::ffi::OsString>);
|
|
615
|
+
|
|
616
|
+
impl HomeGuard {
|
|
617
|
+
fn set(home: &Path) -> Self {
|
|
618
|
+
let previous = std::env::var_os("HOME");
|
|
619
|
+
std::env::set_var("HOME", home);
|
|
620
|
+
Self(previous)
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
impl Drop for HomeGuard {
|
|
625
|
+
fn drop(&mut self) {
|
|
626
|
+
match self.0.take() {
|
|
627
|
+
Some(previous) => std::env::set_var("HOME", previous),
|
|
628
|
+
None => std::env::remove_var("HOME"),
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
584
633
|
struct TmuxCleanup {
|
|
585
634
|
workspace: PathBuf,
|
|
586
635
|
}
|
|
@@ -49,9 +49,10 @@ const SUB: &str = "sub";
|
|
|
49
49
|
#[serial(env)]
|
|
50
50
|
fn restart_resume_spawns_worker_with_team_dir_cwd_matching_launch() {
|
|
51
51
|
let case = HotfixCase::new("restart-cwd");
|
|
52
|
-
case.write_team(CURRENT, "greeter", Provider::
|
|
52
|
+
case.write_team(CURRENT, "greeter", Provider::Copilot);
|
|
53
53
|
case.seed_restart_state(CURRENT, "greeter", "sess-current", "handled");
|
|
54
54
|
case.seed_healthy_coordinator();
|
|
55
|
+
let _home = case.copilot_home_with_session("sess-current");
|
|
55
56
|
let transport = RecordingTransport::new().with_session_present(false);
|
|
56
57
|
|
|
57
58
|
restart_with_transport(&case.team_dir(CURRENT), false, Some(CURRENT), &transport)
|
|
@@ -62,8 +63,8 @@ fn restart_resume_spawns_worker_with_team_dir_cwd_matching_launch() {
|
|
|
62
63
|
spawn.cwd,
|
|
63
64
|
case.team_dir(CURRENT),
|
|
64
65
|
"RC0: restart/resume must spawn the worker in the same team directory cwd used by first launch. \
|
|
65
|
-
Passing the run workspace root makes
|
|
66
|
-
'Choose working directory to resume this session' prompt. spawn={spawn:?}"
|
|
66
|
+
Passing the run workspace root makes the resumed provider see cwd != session cwd \
|
|
67
|
+
(Codex showed a 'Choose working directory to resume this session' prompt). spawn={spawn:?}"
|
|
67
68
|
);
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -72,9 +73,10 @@ fn restart_resume_spawns_worker_with_team_dir_cwd_matching_launch() {
|
|
|
72
73
|
#[serial(env)]
|
|
73
74
|
fn restart_resets_startup_prompt_state_for_respawn() {
|
|
74
75
|
let case = HotfixCase::new("restart-startup-state");
|
|
75
|
-
case.write_team(CURRENT, "greeter", Provider::
|
|
76
|
+
case.write_team(CURRENT, "greeter", Provider::Copilot);
|
|
76
77
|
case.seed_restart_state(CURRENT, "greeter", "sess-current", "handled");
|
|
77
78
|
case.seed_healthy_coordinator();
|
|
79
|
+
let _home = case.copilot_home_with_session("sess-current");
|
|
78
80
|
let transport = RecordingTransport::new().with_session_present(false);
|
|
79
81
|
|
|
80
82
|
restart_with_transport(&case.team_dir(CURRENT), false, Some(CURRENT), &transport)
|
|
@@ -328,6 +330,26 @@ impl HotfixCase {
|
|
|
328
330
|
self.workspace.join(".team/runtime/team.db")
|
|
329
331
|
}
|
|
330
332
|
|
|
333
|
+
/// Copilot resume backing is the `sessions` row in
|
|
334
|
+
/// `$HOME/.copilot/session-store.db`; seed it under a fixture HOME and
|
|
335
|
+
/// point HOME there for the guard's lifetime (callers are `serial(env)`).
|
|
336
|
+
fn copilot_home_with_session(&self, session_id: &str) -> HomeGuard {
|
|
337
|
+
let home = self.workspace.parent().unwrap().join("home");
|
|
338
|
+
let db = home.join(".copilot").join("session-store.db");
|
|
339
|
+
std::fs::create_dir_all(db.parent().unwrap()).unwrap();
|
|
340
|
+
let conn = rusqlite::Connection::open(db).unwrap();
|
|
341
|
+
conn.execute_batch(
|
|
342
|
+
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
343
|
+
)
|
|
344
|
+
.unwrap();
|
|
345
|
+
conn.execute(
|
|
346
|
+
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-07T01:00:00Z')",
|
|
347
|
+
rusqlite::params![session_id, self.workspace.to_string_lossy()],
|
|
348
|
+
)
|
|
349
|
+
.unwrap();
|
|
350
|
+
HomeGuard::set(&home)
|
|
351
|
+
}
|
|
352
|
+
|
|
331
353
|
fn write_team(&self, team: &str, agent_id: &str, provider: Provider) {
|
|
332
354
|
let dir = self.team_dir(team);
|
|
333
355
|
std::fs::create_dir_all(dir.join("agents")).unwrap();
|
|
@@ -498,7 +520,7 @@ fn restart_agent(
|
|
|
498
520
|
json!({
|
|
499
521
|
"status": "running",
|
|
500
522
|
"agent_id": agent_id,
|
|
501
|
-
"provider": "
|
|
523
|
+
"provider": "copilot",
|
|
502
524
|
"role": "Greeter",
|
|
503
525
|
"tools": ["mcp_team"],
|
|
504
526
|
"window": agent_id,
|
|
@@ -520,7 +542,7 @@ fn team_state(team: &str, agent_id: &str, team_dir: &Path, with_leader_receiver:
|
|
|
520
542
|
"agents": {
|
|
521
543
|
agent_id: {
|
|
522
544
|
"status": "running",
|
|
523
|
-
"provider": "
|
|
545
|
+
"provider": "copilot",
|
|
524
546
|
"window": agent_id,
|
|
525
547
|
"owner_team_id": team,
|
|
526
548
|
"spawn_cwd": team_dir.to_string_lossy(),
|
|
@@ -1016,6 +1038,25 @@ impl ProviderAdapter for StaticCaptureAdapter {
|
|
|
1016
1038
|
}
|
|
1017
1039
|
}
|
|
1018
1040
|
|
|
1041
|
+
struct HomeGuard(Option<std::ffi::OsString>);
|
|
1042
|
+
|
|
1043
|
+
impl HomeGuard {
|
|
1044
|
+
fn set(home: &Path) -> Self {
|
|
1045
|
+
let previous = std::env::var_os("HOME");
|
|
1046
|
+
std::env::set_var("HOME", home);
|
|
1047
|
+
Self(previous)
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
impl Drop for HomeGuard {
|
|
1052
|
+
fn drop(&mut self) {
|
|
1053
|
+
match self.0.take() {
|
|
1054
|
+
Some(previous) => std::env::set_var("HOME", previous),
|
|
1055
|
+
None => std::env::remove_var("HOME"),
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1019
1060
|
fn pane_info(pane_id: &str, session: &str, window: &str, pane_pid: Option<u32>) -> PaneInfo {
|
|
1020
1061
|
PaneInfo {
|
|
1021
1062
|
pane_id: PaneId::new(pane_id),
|