@team-agent/installer 0.5.124 → 0.5.126

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.
Files changed (151) hide show
  1. package/Cargo.lock +1 -8
  2. package/Cargo.toml +1 -1
  3. package/README.md +2 -2
  4. package/README.zh.md +2 -2
  5. package/crates/team-agent/Cargo.toml +0 -1
  6. package/crates/team-agent/src/cli/diagnose.rs +39 -69
  7. package/crates/team-agent/src/cli/emit.rs +45 -15
  8. package/crates/team-agent/src/cli/intent/runtime.rs +5 -53
  9. package/crates/team-agent/src/cli/intent/runtime_tests.rs +10 -130
  10. package/crates/team-agent/src/cli/leader.rs +2 -3
  11. package/crates/team-agent/src/cli/leader_prompt.rs +1 -1
  12. package/crates/team-agent/src/cli/mod.rs +28 -33
  13. package/crates/team-agent/src/cli/models.rs +44 -880
  14. package/crates/team-agent/src/cli/route.rs +1 -1
  15. package/crates/team-agent/src/cli/send/persist.rs +36 -0
  16. package/crates/team-agent/src/cli/send/presentation.rs +7 -1
  17. package/crates/team-agent/src/cli/send.rs +3 -1
  18. package/crates/team-agent/src/cli/spec.rs +1 -2
  19. package/crates/team-agent/src/cli/status_port/brief.rs +66 -0
  20. package/crates/team-agent/src/cli/tests/base.rs +4 -11
  21. package/crates/team-agent/src/cli/tests/mod.rs +1 -1
  22. package/crates/team-agent/src/cli/tests/run_delegation.rs +5 -4
  23. package/crates/team-agent/src/cli/tests/status_send.rs +17 -0
  24. package/crates/team-agent/src/compiler/tests.rs +39 -8
  25. package/crates/team-agent/src/compiler.rs +28 -204
  26. package/crates/team-agent/src/contract_runtime/backend.rs +79 -40
  27. package/crates/team-agent/src/contract_runtime/config.rs +37 -24
  28. package/crates/team-agent/src/contract_runtime/discovery.rs +33 -0
  29. package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
  30. package/crates/team-agent/src/contract_runtime/framework.rs +87 -34
  31. package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
  32. package/crates/team-agent/src/contract_runtime/registry.rs +299 -21
  33. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -1
  34. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +29 -8
  35. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -42
  36. package/crates/team-agent/src/coordinator/tick.rs +89 -1
  37. package/crates/team-agent/src/db/message_store.rs +78 -3
  38. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -1
  39. package/crates/team-agent/src/leader/prompt.rs +1 -2
  40. package/crates/team-agent/src/leader/provider_attribution.rs +0 -52
  41. package/crates/team-agent/src/leader/start.rs +1 -2
  42. package/crates/team-agent/src/leader/tests/prompt_contract.rs +2 -3
  43. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +91 -0
  44. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +15 -195
  45. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -9
  46. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
  47. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +18 -29
  48. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
  49. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +3 -11
  50. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
  51. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -24
  52. package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
  53. package/crates/team-agent/src/lifecycle/launch/spawn.rs +21 -61
  54. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
  55. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
  56. package/crates/team-agent/src/lifecycle/launch.rs +2 -43
  57. package/crates/team-agent/src/lifecycle/profile_launch.rs +21 -348
  58. package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
  59. package/crates/team-agent/src/lifecycle/restart/common.rs +43 -378
  60. package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
  61. package/crates/team-agent/src/lifecycle/restart.rs +0 -2
  62. package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
  63. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +11 -6
  64. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
  65. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +60 -145
  66. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +8 -334
  67. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +30 -11
  68. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
  69. package/crates/team-agent/src/lifecycle/tests/core.rs +17 -16
  70. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +12 -12
  71. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
  72. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +26 -28
  73. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
  74. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
  75. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
  76. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
  77. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
  78. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
  79. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
  80. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +11 -10
  81. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
  82. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +2 -106
  83. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
  84. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
  85. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
  86. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +6 -5
  87. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +7 -153
  88. package/crates/team-agent/src/lifecycle/tests.rs +0 -6
  89. package/crates/team-agent/src/lifecycle/types.rs +2 -18
  90. package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
  91. package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
  92. package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
  93. package/crates/team-agent/src/messaging/delivery.rs +185 -168
  94. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
  95. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
  96. package/crates/team-agent/src/messaging/helpers.rs +19 -0
  97. package/crates/team-agent/src/messaging/tests/dup_inject.rs +67 -5
  98. package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
  99. package/crates/team-agent/src/messaging/tests/spine.rs +46 -36
  100. package/crates/team-agent/src/model/enums.rs +1 -8
  101. package/crates/team-agent/src/provider/adapter.rs +33 -302
  102. package/crates/team-agent/src/provider/adapters/mod.rs +4 -5
  103. package/crates/team-agent/src/provider/argv_route.rs +1 -5
  104. package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
  105. package/crates/team-agent/src/provider/classify.rs +68 -3
  106. package/crates/team-agent/src/provider/faults.rs +1 -1
  107. package/crates/team-agent/src/provider/model_catalog.rs +14 -273
  108. package/crates/team-agent/src/provider/session/capture.rs +7 -107
  109. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -4
  110. package/crates/team-agent/src/provider/session/context_fork.rs +17 -109
  111. package/crates/team-agent/src/provider/session_scan/common.rs +11 -36
  112. package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
  113. package/crates/team-agent/src/provider/session_scan.rs +4 -14
  114. package/crates/team-agent/src/provider/submit_now.rs +5 -28
  115. package/crates/team-agent/src/provider/tests/adapter.rs +39 -275
  116. package/crates/team-agent/src/provider/tests/classify.rs +53 -0
  117. package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -15
  118. package/crates/team-agent/src/provider/tests/idle.rs +0 -25
  119. package/crates/team-agent/src/provider/types.rs +1 -1
  120. package/crates/team-agent/src/provider/wire.rs +79 -11
  121. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
  122. package/crates/team-agent/src/state/persist.rs +6 -6
  123. package/crates/team-agent/src/state/repository/tests.rs +2 -2
  124. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
  125. package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
  126. package/crates/team-agent/src/tmux_backend.rs +43 -8
  127. package/crates/team-agent/src/transport/native_input.rs +2 -231
  128. package/package.json +4 -4
  129. package/skills/team-agent/SKILL.md +7 -5
  130. package/skills/team-agent/command-coverage.json +15 -1
  131. package/skills/team-agent/docs/reference/team-agent-operator.md +5 -3
  132. package/skills/team-agent/references/team-agent-operator.md +5 -3
  133. package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
  134. package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
  135. package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
  136. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
  137. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  138. package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
  139. package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
  140. package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
  141. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  142. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
  143. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  144. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  145. package/crates/team-agent/src/provider/adapters/cursor_agent.rs +0 -44
  146. package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
  147. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  148. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  149. package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
  150. package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
  151. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
@@ -1,8 +1,7 @@
1
- //! Claude compatible-api profile launch contracts for Batch A Lane 2.
1
+ //! Profile launch contracts for Batch A Lane 2.
2
2
  //!
3
- //! The entrypoints are lifecycle/CLI surfaces with a recording transport, plus the S0 public
4
- //! `ProviderProfileLaunch` shape. Before S0 lands this file compile-reds on the shared type; after
5
- //! S0 it behavior-reds on lifecycle/profile wiring.
3
+ //! The Claude compatible-api worker launch these contracts were written for is gone with the
4
+ //! legacy Claude worker runtime; the provider-neutral resolver wiring and doctor contracts remain.
6
5
 
7
6
  #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
8
7
 
@@ -13,117 +12,10 @@ fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
13
12
 
14
13
  #[path = "../../../tests/support/composite_source.rs"]
15
14
  mod composite_source;
16
- use std::collections::{BTreeMap, BTreeSet};
17
15
  use std::path::{Path, PathBuf};
18
16
  use std::process::Command;
19
- use std::sync::atomic::{AtomicU64, Ordering};
20
- use std::sync::Mutex;
21
17
 
22
18
  use serde_json::{json, Value};
23
- use serial_test::serial;
24
- use team_agent::lifecycle::quick_start_with_transport_in_workspace;
25
- use team_agent::provider::{ProviderCommandOverrides, ProviderProfileLaunch};
26
- use team_agent::state::persist::load_runtime_state;
27
- use team_agent::transport::{
28
- AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
29
- InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName, SetEnvOutcome,
30
- SpawnResult, SubmitVerification, Target, Transport, TransportError, TurnVerification,
31
- WindowName,
32
- };
33
-
34
- #[test]
35
- #[serial(env)]
36
- fn compatible_api_profile_quick_start_spawns_claude_with_profile_env_and_state_metadata() {
37
- let _hermetic = hermetic_guard::HermeticTestEnv::enter_with_leader("claude-profile-quick-start");
38
- assert_s0_profile_launch_shape();
39
-
40
- let ws = tmp_dir("profile-launch");
41
- super::launch_spawn::seed_healthy_coordinator(&ws);
42
- let team = write_claude_profile_team(&ws, "claudeprof", "clauder");
43
- let transport = RecordingTransport::default();
44
-
45
- quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("claudeprof"), &transport)
46
- .expect(
47
- "quick-start through recording transport should reach the real lifecycle spawn path",
48
- );
49
-
50
- let spawn = transport.single_spawn();
51
- for (key, expected) in [
52
- ("CLAUDE_CONFIG_DIR", None),
53
- ("ANTHROPIC_BASE_URL", Some("https://llm.local/v1")),
54
- ("ANTHROPIC_AUTH_TOKEN", Some("local-secret")),
55
- ("ANTHROPIC_MODEL", Some("profile-effective-haiku")),
56
- ] {
57
- let got = spawn.env.get(key).map(String::as_str);
58
- match expected {
59
- Some(expected) => assert_eq!(
60
- got,
61
- Some(expected),
62
- "Claude compatible_api profile launch must inject {key} from .team/current/profiles/local.env; env={:?}",
63
- spawn.env
64
- ),
65
- None => assert!(
66
- got.is_some_and(|value| !value.is_empty()),
67
- "Claude compatible_api profile launch must inject non-empty {key}; env={:?}",
68
- spawn.env
69
- ),
70
- }
71
- }
72
- assert!(
73
- !spawn.env.contains_key("ANTHROPIC_API_KEY"),
74
- "compatible_api must unset ANTHROPIC_API_KEY and use ANTHROPIC_AUTH_TOKEN instead; env={:?}",
75
- spawn.env
76
- );
77
- assert!(
78
- argv_contains_adjacent(&spawn.argv, &["--model", "profile-effective-haiku"]),
79
- "profile model must become the effective Claude model when role model is null; argv={:?}",
80
- spawn.argv
81
- );
82
-
83
- let state = load_runtime_state(&ws).unwrap();
84
- let agent = &state["teams"]["claudeprof"]["agents"]["clauder"];
85
- assert!(
86
- agent["_pending_session_id"].as_str().is_some_and(|value| !value.is_empty()),
87
- "lifecycle must persist CommandPlan.expected_session_id as agents[*]._pending_session_id; state={state}"
88
- );
89
- assert!(
90
- agent["claude_projects_root"].as_str().is_some_and(|value| !value.is_empty()),
91
- "lifecycle must persist CommandPlan.provider_projects_root/profile claude_projects_root for capture; state={state}"
92
- );
93
- }
94
-
95
- #[ignore = "flaky under parallel suite, tracked"]
96
- #[test]
97
- #[serial(env)]
98
- fn subscription_profile_keeps_default_claude_config_dir_for_logged_in_quota() {
99
- let ws = tmp_dir("subscription-config");
100
- let team = write_claude_subscription_profile_team(&ws, "subteam", "clauder");
101
- let transport = RecordingTransport::default();
102
-
103
- quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("subteam"), &transport)
104
- .expect("subscription profile should launch without managed config isolation");
105
-
106
- let spawn = transport.single_spawn();
107
- assert!(
108
- !spawn.env.contains_key("CLAUDE_CONFIG_DIR"),
109
- "subscription Claude workers must inherit the user's default ~/.claude login state; env={:?}",
110
- spawn.env
111
- );
112
- assert!(
113
- !spawn.env.contains_key("ANTHROPIC_API_KEY")
114
- && !spawn.env.contains_key("ANTHROPIC_AUTH_TOKEN"),
115
- "subscription launch must not switch into API-token auth via profile env; env={:?}",
116
- spawn.env
117
- );
118
-
119
- let state = load_runtime_state(&ws).unwrap();
120
- let agent = &state["teams"]["subteam"]["agents"]["clauder"];
121
- assert_eq!(
122
- agent.get("claude_projects_root"),
123
- None,
124
- "without a supported fine-grained Claude projects-root env, subscription workers must not fake an isolated transcript root; state={state}"
125
- );
126
- }
127
19
 
128
20
  #[test]
129
21
  fn launch_restart_start_add_and_fork_all_delegate_to_the_profile_launch_resolver() {
@@ -171,7 +63,7 @@ fn launch_restart_start_add_and_fork_all_delegate_to_the_profile_launch_resolver
171
63
  fn diagnose_missing_profile_is_rc1_ok_false_and_zero_token() {
172
64
  let env = hermetic_guard::HermeticTestEnv::enter("diagnose-missing-profile");
173
65
  let ws = env.workspace("missing-profile");
174
- let team = write_claude_profile_team(&ws, "diagteam", "clauder");
66
+ let team = write_compatible_profile_team(&ws, "diagteam", "copiloter");
175
67
  std::fs::remove_file(
176
68
  ws.join(".team")
177
69
  .join("current")
@@ -212,73 +104,26 @@ fn diagnose_missing_profile_is_rc1_ok_false_and_zero_token() {
212
104
  );
213
105
  }
214
106
 
215
- fn assert_s0_profile_launch_shape() {
216
- let profile = ProviderProfileLaunch {
217
- env_overlay: BTreeMap::from([(
218
- "ANTHROPIC_MODEL".to_string(),
219
- "profile-effective-haiku".to_string(),
220
- )]),
221
- env_unset: BTreeSet::from(["ANTHROPIC_API_KEY".to_string()]),
222
- command_overrides: ProviderCommandOverrides {
223
- model: Some("profile-effective-haiku".to_string()),
224
- ..ProviderCommandOverrides::default()
225
- },
226
- claude_config_dir: Some(PathBuf::from("/tmp/claude-config")),
227
- claude_projects_root: Some(PathBuf::from("/tmp/claude-config/projects")),
228
- managed_mcp_config: true,
229
- };
230
- assert!(profile.managed_mcp_config);
231
- }
232
-
233
- fn write_claude_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> PathBuf {
107
+ fn write_compatible_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> PathBuf {
234
108
  let team = ws.join(team_key);
235
109
  std::fs::create_dir_all(team.join("agents")).unwrap();
236
110
  std::fs::create_dir_all(ws.join(".team").join("current").join("profiles")).unwrap();
237
111
  std::fs::write(
238
112
  ws.join(".team").join("current").join("profiles").join("local.env"),
239
- "ANTHROPIC_BASE_URL=https://llm.local/v1\nANTHROPIC_AUTH_TOKEN=local-secret\nANTHROPIC_MODEL=profile-effective-haiku\nANTHROPIC_API_KEY=\n",
113
+ "BASE_URL=https://llm.local/v1\nAPI_KEY=local-secret\nMODEL=profile-effective-model\n",
240
114
  )
241
115
  .unwrap();
242
116
  std::fs::write(
243
117
  team.join("TEAM.md"),
244
118
  format!(
245
- "---\nname: {team_key}\nobjective: Claude compatible profile launch contract.\nprovider: claude\nauth_mode: compatible_api\ndangerously_skip_permissions: false\n---\n\nTeam.\n"
119
+ "---\nname: {team_key}\nobjective: Compatible profile doctor contract.\nprovider: copilot\nauth_mode: compatible_api\ndangerously_skip_permissions: false\n---\n\nTeam.\n"
246
120
  ),
247
121
  )
248
122
  .unwrap();
249
123
  std::fs::write(
250
124
  team.join("agents").join(format!("{agent_id}.md")),
251
125
  format!(
252
- "---\nname: {agent_id}\nrole: Claude Worker\nprovider: claude\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n"
253
- ),
254
- )
255
- .unwrap();
256
- team
257
- }
258
-
259
- fn write_claude_subscription_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> PathBuf {
260
- let team = ws.join(team_key);
261
- std::fs::create_dir_all(team.join("agents")).unwrap();
262
- std::fs::create_dir_all(ws.join(".team").join("current").join("profiles")).unwrap();
263
- std::fs::write(
264
- ws.join(".team")
265
- .join("current")
266
- .join("profiles")
267
- .join("local.env"),
268
- "AUTH_MODE=subscription\nMODEL=claude-sonnet-4-6\n",
269
- )
270
- .unwrap();
271
- std::fs::write(
272
- team.join("TEAM.md"),
273
- format!(
274
- "---\nname: {team_key}\nobjective: Claude subscription profile launch contract.\nprovider: claude\nauth_mode: subscription\ndangerously_skip_permissions: false\n---\n\nTeam.\n"
275
- ),
276
- )
277
- .unwrap();
278
- std::fs::write(
279
- team.join("agents").join(format!("{agent_id}.md")),
280
- format!(
281
- "---\nname: {agent_id}\nrole: Claude Worker\nprovider: claude\nauth_mode: subscription\ndangerously_skip_permissions: false\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n"
126
+ "---\nname: {agent_id}\nrole: Copilot Worker\nprovider: copilot\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: local\nmodel: profile-effective-model\ntools:\n - mcp_team\n---\n\nWorker.\n"
282
127
  ),
283
128
  )
284
129
  .unwrap();
@@ -288,160 +133,3 @@ fn write_claude_subscription_profile_team(ws: &Path, team_key: &str, agent_id: &
288
133
  fn source(path: &str) -> String {
289
134
  composite_source::composite_source(path)
290
135
  }
291
-
292
- fn argv_contains_adjacent(hay: &[String], needle: &[&str]) -> bool {
293
- hay.windows(needle.len())
294
- .any(|window| window.iter().map(String::as_str).eq(needle.iter().copied()))
295
- }
296
-
297
- fn tmp_dir(tag: &str) -> PathBuf {
298
- static N: AtomicU64 = AtomicU64::new(0);
299
- let dir = std::env::temp_dir().join(format!(
300
- "ta-rs-claude-profile-launch-{tag}-{}-{}",
301
- std::process::id(),
302
- N.fetch_add(1, Ordering::Relaxed)
303
- ));
304
- let _ = std::fs::remove_dir_all(&dir);
305
- std::fs::create_dir_all(&dir).unwrap();
306
- std::fs::canonicalize(dir).unwrap()
307
- }
308
-
309
- #[derive(Debug, Clone)]
310
- struct RecordedSpawn {
311
- argv: Vec<String>,
312
- env: BTreeMap<String, String>,
313
- }
314
-
315
- #[derive(Debug, Default)]
316
- struct RecordingTransport {
317
- spawns: Mutex<Vec<RecordedSpawn>>,
318
- }
319
-
320
- impl RecordingTransport {
321
- fn single_spawn(&self) -> RecordedSpawn {
322
- let spawns = self.spawns.lock().unwrap();
323
- assert_eq!(
324
- spawns.len(),
325
- 1,
326
- "fixture should record one Claude worker spawn; spawns={spawns:?}"
327
- );
328
- spawns[0].clone()
329
- }
330
- }
331
-
332
- impl Transport for RecordingTransport {
333
- fn kind(&self) -> BackendKind {
334
- BackendKind::Tmux
335
- }
336
-
337
- fn spawn_first(
338
- &self,
339
- session: &SessionName,
340
- window: &WindowName,
341
- argv: &[String],
342
- _cwd: &Path,
343
- env: &BTreeMap<String, String>,
344
- ) -> Result<SpawnResult, TransportError> {
345
- self.spawn_into(session, window, argv, _cwd, env)
346
- }
347
-
348
- fn spawn_into(
349
- &self,
350
- session: &SessionName,
351
- window: &WindowName,
352
- argv: &[String],
353
- _cwd: &Path,
354
- env: &BTreeMap<String, String>,
355
- ) -> Result<SpawnResult, TransportError> {
356
- let mut spawns = self.spawns.lock().unwrap();
357
- spawns.push(RecordedSpawn {
358
- argv: argv.to_vec(),
359
- env: env.clone(),
360
- });
361
- Ok(SpawnResult {
362
- pane_id: PaneId::new(format!("%{}", spawns.len())),
363
- session: session.clone(),
364
- window: window.clone(),
365
- child_pid: Some(10_000 + spawns.len() as u32),
366
- })
367
- }
368
-
369
- fn inject(
370
- &self,
371
- _target: &Target,
372
- _payload: &InjectPayload,
373
- _submit: Key,
374
- _bracketed: bool,
375
- ) -> Result<InjectReport, TransportError> {
376
- Ok(InjectReport {
377
- stage_reached: InjectStage::Submit,
378
- inject_verification: InjectVerification::CaptureContainsToken,
379
- submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
380
- turn_verification: TurnVerification::NotYetObserved,
381
- attempts: 1,
382
- submit_diagnostics: None,
383
- })
384
- }
385
-
386
- fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
387
- Ok(())
388
- }
389
-
390
- fn capture(
391
- &self,
392
- _target: &Target,
393
- range: CaptureRange,
394
- ) -> Result<CapturedText, TransportError> {
395
- Ok(CapturedText {
396
- text: String::new(),
397
- range,
398
- })
399
- }
400
-
401
- fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
402
- match field {
403
- PaneField::PaneWidth => Ok(Some("120".to_string())),
404
- _ => Ok(None),
405
- }
406
- }
407
-
408
- fn liveness(
409
- &self,
410
- _pane: &PaneId,
411
- ) -> Result<team_agent::transport::PaneLiveness, TransportError> {
412
- Ok(team_agent::transport::PaneLiveness::Live)
413
- }
414
-
415
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
416
- Ok(Vec::new())
417
- }
418
-
419
- fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
420
- Ok(false)
421
- }
422
-
423
- fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
424
- Ok(Vec::new())
425
- }
426
-
427
- fn set_session_env(
428
- &self,
429
- _session: &SessionName,
430
- _key: &str,
431
- _value: &str,
432
- ) -> Result<SetEnvOutcome, TransportError> {
433
- Ok(SetEnvOutcome::Applied)
434
- }
435
-
436
- fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
437
- Ok(())
438
- }
439
-
440
- fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
441
- Ok(())
442
- }
443
-
444
- fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
445
- Ok(AttachOutcome::Attached)
446
- }
447
- }