@team-agent/installer 0.5.42 → 0.5.44

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 (156) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/adapters.rs +129 -54
  4. package/crates/team-agent/src/cli/diagnose.rs +1 -2
  5. package/crates/team-agent/src/cli/emit.rs +1 -7
  6. package/crates/team-agent/src/cli/helpers.rs +3 -1
  7. package/crates/team-agent/src/cli/leader.rs +2 -1
  8. package/crates/team-agent/src/cli/mod.rs +126 -16
  9. package/crates/team-agent/src/cli/named_address.rs +14 -5
  10. package/crates/team-agent/src/cli/profile.rs +19 -7
  11. package/crates/team-agent/src/cli/send.rs +9 -3
  12. package/crates/team-agent/src/cli/status.rs +8 -30
  13. package/crates/team-agent/src/cli/status_port.rs +1341 -1272
  14. package/crates/team-agent/src/cli/tests/base.rs +738 -660
  15. package/crates/team-agent/src/cli/tests/compile.rs +45 -18
  16. package/crates/team-agent/src/cli/tests/divergence.rs +462 -444
  17. package/crates/team-agent/src/cli/tests/lane_c.rs +365 -282
  18. package/crates/team-agent/src/cli/tests/leader_watch.rs +356 -329
  19. package/crates/team-agent/src/cli/tests/main_preserved.rs +672 -564
  20. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +284 -224
  21. package/crates/team-agent/src/cli/tests/mod.rs +17 -7
  22. package/crates/team-agent/src/cli/tests/named_address.rs +8 -2
  23. package/crates/team-agent/src/cli/tests/peer_allow.rs +10 -2
  24. package/crates/team-agent/src/cli/tests/run_delegation.rs +314 -273
  25. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +26 -15
  26. package/crates/team-agent/src/cli/tests/status_send.rs +707 -629
  27. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +20 -4
  28. package/crates/team-agent/src/cli/tests/verb_profile.rs +46 -17
  29. package/crates/team-agent/src/cli/tests/verb_validate.rs +15 -3
  30. package/crates/team-agent/src/codex_app_server.rs +2 -5
  31. package/crates/team-agent/src/compiler/tests.rs +139 -33
  32. package/crates/team-agent/src/compiler.rs +55 -22
  33. package/crates/team-agent/src/conpty/backend.rs +23 -33
  34. package/crates/team-agent/src/coordinator/backoff.rs +2 -7
  35. package/crates/team-agent/src/coordinator/conpty_shim.rs +55 -67
  36. package/crates/team-agent/src/coordinator/health.rs +46 -31
  37. package/crates/team-agent/src/coordinator/mod.rs +3 -3
  38. package/crates/team-agent/src/coordinator/orphan.rs +22 -10
  39. package/crates/team-agent/src/coordinator/steps/abnormal.rs +51 -56
  40. package/crates/team-agent/src/coordinator/tests/abnormal.rs +55 -19
  41. package/crates/team-agent/src/coordinator/tests/basics.rs +179 -41
  42. package/crates/team-agent/src/coordinator/tests/daemon.rs +53 -13
  43. package/crates/team-agent/src/coordinator/tests/health_sync.rs +78 -19
  44. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +61 -11
  45. package/crates/team-agent/src/coordinator/tests/mod.rs +33 -39
  46. package/crates/team-agent/src/coordinator/tests/spine.rs +52 -12
  47. package/crates/team-agent/src/coordinator/tests/takeover.rs +73 -15
  48. package/crates/team-agent/src/coordinator/tests/tick_core.rs +50 -15
  49. package/crates/team-agent/src/coordinator/tests/watch.rs +74 -20
  50. package/crates/team-agent/src/db/message_store.rs +138 -30
  51. package/crates/team-agent/src/db/migration.rs +249 -61
  52. package/crates/team-agent/src/db/schema.rs +303 -82
  53. package/crates/team-agent/src/diagnose/comms.rs +9 -2
  54. package/crates/team-agent/src/diagnose/mod.rs +1 -3
  55. package/crates/team-agent/src/diagnose/orphans.rs +79 -61
  56. package/crates/team-agent/src/event_log.rs +70 -16
  57. package/crates/team-agent/src/layout/manager.rs +15 -4
  58. package/crates/team-agent/src/layout/mod.rs +4 -4
  59. package/crates/team-agent/src/layout/overlay.rs +10 -3
  60. package/crates/team-agent/src/layout/placement.rs +5 -1
  61. package/crates/team-agent/src/layout/recovery.rs +4 -2
  62. package/crates/team-agent/src/layout/runtime_sessions.rs +7 -7
  63. package/crates/team-agent/src/layout/sessions.rs +17 -9
  64. package/crates/team-agent/src/layout/tmux_endpoint.rs +1 -1
  65. package/crates/team-agent/src/layout/worker_env.rs +87 -19
  66. package/crates/team-agent/src/leader/helpers.rs +7 -1
  67. package/crates/team-agent/src/leader/lease.rs +199 -89
  68. package/crates/team-agent/src/leader/owner_bind.rs +55 -22
  69. package/crates/team-agent/src/leader/provider_attribution.rs +25 -6
  70. package/crates/team-agent/src/leader/rediscover/tests.rs +88 -24
  71. package/crates/team-agent/src/leader/rediscover.rs +74 -25
  72. package/crates/team-agent/src/leader/registry.rs +1 -1
  73. package/crates/team-agent/src/leader/start.rs +75 -54
  74. package/crates/team-agent/src/leader/takeover.rs +46 -11
  75. package/crates/team-agent/src/leader/tests/basics.rs +320 -167
  76. package/crates/team-agent/src/leader/tests/byte_findings.rs +361 -219
  77. package/crates/team-agent/src/leader/tests/identity.rs +428 -356
  78. package/crates/team-agent/src/leader/tests/idle.rs +285 -254
  79. package/crates/team-agent/src/leader/tests/lease_api.rs +338 -274
  80. package/crates/team-agent/src/leader/tests/lease_claim.rs +643 -593
  81. package/crates/team-agent/src/leader/tests/mod.rs +115 -99
  82. package/crates/team-agent/src/leader/tests/rediscover.rs +74 -22
  83. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +237 -211
  84. package/crates/team-agent/src/lib.rs +4 -4
  85. package/crates/team-agent/src/lifecycle/display.rs +7 -3
  86. package/crates/team-agent/src/lifecycle/launch.rs +55 -15
  87. package/crates/team-agent/src/lifecycle/mod.rs +9 -1
  88. package/crates/team-agent/src/lifecycle/profile_launch.rs +77 -34
  89. package/crates/team-agent/src/lifecycle/profile_smoke.rs +3 -1
  90. package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -6
  91. package/crates/team-agent/src/lifecycle/restart/common.rs +6 -2
  92. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +1 -4
  93. package/crates/team-agent/src/lifecycle/restart/preflight.rs +6 -5
  94. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +26 -22
  95. package/crates/team-agent/src/lifecycle/restart/remove.rs +45 -35
  96. package/crates/team-agent/src/lifecycle/restart/team_state.rs +63 -17
  97. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +251 -84
  98. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +198 -48
  99. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +2 -1
  100. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +152 -32
  101. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +1 -5
  102. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +3 -0
  103. package/crates/team-agent/src/lifecycle/tests.rs +2 -2
  104. package/crates/team-agent/src/main.rs +4 -4
  105. package/crates/team-agent/src/mcp_server/lifecycle_tools/agent_ops.rs +47 -20
  106. package/crates/team-agent/src/mcp_server/mod.rs +11 -2
  107. package/crates/team-agent/src/mcp_server/types.rs +14 -3
  108. package/crates/team-agent/src/mcp_server/wire.rs +230 -68
  109. package/crates/team-agent/src/messaging/delivery.rs +20 -18
  110. package/crates/team-agent/src/messaging/helpers.rs +25 -4
  111. package/crates/team-agent/src/messaging/leader_receiver.rs +4 -5
  112. package/crates/team-agent/src/messaging/mod.rs +2 -3
  113. package/crates/team-agent/src/messaging/selftest.rs +46 -26
  114. package/crates/team-agent/src/messaging/tests/main_preserved.rs +47 -12
  115. package/crates/team-agent/src/messaging/tests/runtime.rs +57 -22
  116. package/crates/team-agent/src/messaging/tests/spine.rs +154 -40
  117. package/crates/team-agent/src/messaging/tests/wave2.rs +31 -32
  118. package/crates/team-agent/src/messaging/trust.rs +25 -2
  119. package/crates/team-agent/src/messaging/watchers.rs +37 -9
  120. package/crates/team-agent/src/model/enums.rs +65 -16
  121. package/crates/team-agent/src/model/ids.rs +12 -3
  122. package/crates/team-agent/src/model/paths.rs +28 -7
  123. package/crates/team-agent/src/model/permissions.rs +176 -33
  124. package/crates/team-agent/src/model/routing.rs +66 -20
  125. package/crates/team-agent/src/model/spec.rs +365 -69
  126. package/crates/team-agent/src/model/task_graph.rs +36 -9
  127. package/crates/team-agent/src/model/yaml/tests.rs +24 -6
  128. package/crates/team-agent/src/model/yaml.rs +7 -6
  129. package/crates/team-agent/src/packaging/install.rs +23 -9
  130. package/crates/team-agent/src/packaging/migrate.rs +5 -7
  131. package/crates/team-agent/src/packaging/mod.rs +9 -1
  132. package/crates/team-agent/src/packaging/repair.rs +13 -6
  133. package/crates/team-agent/src/packaging/tests.rs +63 -16
  134. package/crates/team-agent/src/packaging/types.rs +22 -7
  135. package/crates/team-agent/src/platform/argv.rs +4 -1
  136. package/crates/team-agent/src/platform/file_lock.rs +22 -8
  137. package/crates/team-agent/src/platform/process.rs +54 -24
  138. package/crates/team-agent/src/provider/adapters/claude.rs +1 -3
  139. package/crates/team-agent/src/provider/approvals/parsing.rs +134 -26
  140. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +13 -3
  141. package/crates/team-agent/src/provider/classify.rs +127 -42
  142. package/crates/team-agent/src/provider/faults.rs +17 -5
  143. package/crates/team-agent/src/provider/helpers.rs +6 -5
  144. package/crates/team-agent/src/provider/startup_prompt.rs +75 -27
  145. package/crates/team-agent/src/state/persist.rs +28 -0
  146. package/crates/team-agent/src/state/repository.rs +8 -3
  147. package/crates/team-agent/src/tmux_backend/tests.rs +1637 -1398
  148. package/crates/team-agent/src/tmux_backend.rs +80 -44
  149. package/crates/team-agent/src/topology.rs +40 -20
  150. package/crates/team-agent/src/transport/test_support.rs +20 -23
  151. package/crates/team-agent/src/transport/tests/behavior.rs +292 -293
  152. package/crates/team-agent/src/transport/tests/mod.rs +178 -187
  153. package/crates/team-agent/src/transport/tests/wire.rs +561 -525
  154. package/crates/team-agent/src/transport.rs +12 -17
  155. package/crates/team-agent/src/transport_factory.rs +29 -14
  156. package/package.json +4 -4
@@ -28,6 +28,7 @@ use std::collections::BTreeMap;
28
28
  use std::path::{Path, PathBuf};
29
29
 
30
30
  use crate::model::yaml::Value as YamlValue;
31
+ use crate::provider::Provider;
31
32
 
32
33
  /// Env-key PREFIXES that are stripped from the inherited parent env
33
34
  /// before worker spawn. These carry leader-process identity and must
@@ -52,6 +53,10 @@ const STRIP_EXACT: &[&str] = &[
52
53
  "TMUX_PANE",
53
54
  ];
54
55
 
56
+ const WORKER_IDENTITY_EXACT: &[&str] = &["CLAUDECODE", "CLAUDE_EFFORT", "CODEX_THREAD_ID"];
57
+
58
+ const WORKER_IDENTITY_PREFIXES: &[&str] = &["CLAUDE_CODE_"];
59
+
55
60
  /// Build the worker spawn env per Python inherit-then-strip semantics.
56
61
  ///
57
62
  /// Inputs:
@@ -102,6 +107,30 @@ where
102
107
  env
103
108
  }
104
109
 
110
+ pub(crate) fn isolate_worker_spawn_env(
111
+ _target_provider: Provider,
112
+ env: &mut BTreeMap<String, String>,
113
+ base_env_unset: impl IntoIterator<Item = String>,
114
+ ) -> Vec<String> {
115
+ let mut env_unset = base_env_unset
116
+ .into_iter()
117
+ .collect::<std::collections::BTreeSet<_>>();
118
+ for key in WORKER_IDENTITY_EXACT {
119
+ env.remove(*key);
120
+ env_unset.insert((*key).to_string());
121
+ }
122
+ let dynamic_keys = env
123
+ .keys()
124
+ .filter(|key| is_worker_identity_key(key))
125
+ .cloned()
126
+ .collect::<Vec<_>>();
127
+ for key in dynamic_keys {
128
+ env.remove(&key);
129
+ env_unset.insert(key);
130
+ }
131
+ env_unset.into_iter().collect()
132
+ }
133
+
105
134
  fn is_stripped(key: &str) -> bool {
106
135
  if STRIP_EXACT.iter().any(|exact| *exact == key) {
107
136
  return true;
@@ -112,9 +141,17 @@ fn is_stripped(key: &str) -> bool {
112
141
  false
113
142
  }
114
143
 
144
+ fn is_worker_identity_key(key: &str) -> bool {
145
+ WORKER_IDENTITY_PREFIXES
146
+ .iter()
147
+ .any(|prefix| key.starts_with(prefix))
148
+ }
149
+
115
150
  fn is_posix_shell_identifier(s: &str) -> bool {
116
151
  let mut bytes = s.bytes();
117
- let Some(first) = bytes.next() else { return false };
152
+ let Some(first) = bytes.next() else {
153
+ return false;
154
+ };
118
155
  if !(first.is_ascii_alphabetic() || first == b'_') {
119
156
  return false;
120
157
  }
@@ -147,12 +184,24 @@ mod tests {
147
184
  ("OPENAI_API_KEY".to_string(), "sk-test".to_string()),
148
185
  ("COPILOT_TOKEN".to_string(), "tok".to_string()),
149
186
  // Leader identity — must be stripped.
150
- ("TEAM_AGENT_LEADER_PROVIDER".to_string(), "claude".to_string()),
151
- ("TEAM_AGENT_LEADER_SESSION_UUID".to_string(), "leader-uuid".to_string()),
152
- ("TEAM_AGENT_MACHINE_FINGERPRINT".to_string(), "fp".to_string()),
187
+ (
188
+ "TEAM_AGENT_LEADER_PROVIDER".to_string(),
189
+ "claude".to_string(),
190
+ ),
191
+ (
192
+ "TEAM_AGENT_LEADER_SESSION_UUID".to_string(),
193
+ "leader-uuid".to_string(),
194
+ ),
195
+ (
196
+ "TEAM_AGENT_MACHINE_FINGERPRINT".to_string(),
197
+ "fp".to_string(),
198
+ ),
153
199
  ("TEAM_AGENT_TEAM_ID".to_string(), "alpha".to_string()),
154
200
  ("TEAM_AGENT_LEADER_BYPASS".to_string(), "1".to_string()),
155
- ("COPILOT_DISABLE_TERMINAL_TITLE".to_string(), "1".to_string()),
201
+ (
202
+ "COPILOT_DISABLE_TERMINAL_TITLE".to_string(),
203
+ "1".to_string(),
204
+ ),
156
205
  // Random noise — non-whitelisted prefix.
157
206
  ("RANDOM_NOISE".to_string(), "x".to_string()),
158
207
  ("TMUX".to_string(), "leader-pane".to_string()),
@@ -197,20 +246,27 @@ mod tests {
197
246
  "developer",
198
247
  Some("alpha"),
199
248
  );
200
- assert_eq!(env.get("TEAM_AGENT_ID").map(String::as_str), Some("developer"));
201
- assert_eq!(env.get("TEAM_AGENT_AGENT_ID").map(String::as_str), Some("developer"));
202
- assert_eq!(env.get("TEAM_AGENT_WORKSPACE").map(String::as_str), Some("/ws"));
203
- assert_eq!(env.get("TEAM_AGENT_OWNER_TEAM_ID").map(String::as_str), Some("alpha"));
249
+ assert_eq!(
250
+ env.get("TEAM_AGENT_ID").map(String::as_str),
251
+ Some("developer")
252
+ );
253
+ assert_eq!(
254
+ env.get("TEAM_AGENT_AGENT_ID").map(String::as_str),
255
+ Some("developer")
256
+ );
257
+ assert_eq!(
258
+ env.get("TEAM_AGENT_WORKSPACE").map(String::as_str),
259
+ Some("/ws")
260
+ );
261
+ assert_eq!(
262
+ env.get("TEAM_AGENT_OWNER_TEAM_ID").map(String::as_str),
263
+ Some("alpha")
264
+ );
204
265
  }
205
266
 
206
267
  #[test]
207
268
  fn worker_spawn_env_inherits_parent_env_minus_strip_list() {
208
- let env = worker_spawn_env(
209
- make_parent_env(&[]),
210
- Path::new("/ws"),
211
- "developer",
212
- None,
213
- );
269
+ let env = worker_spawn_env(make_parent_env(&[]), Path::new("/ws"), "developer", None);
214
270
  // Inherit-then-strip: every parent key passes through EXCEPT the
215
271
  // strip list. PATH-like + provider creds + random user vars all
216
272
  // present.
@@ -240,15 +296,24 @@ mod tests {
240
296
  #[test]
241
297
  fn worker_spawn_cwd_returns_workspace_when_no_spec_override() {
242
298
  // YAML agent with no spawn_cwd field.
243
- let agent = YamlValue::Map(vec![("id".to_string(), YamlValue::Str("developer".to_string()))]);
244
- assert_eq!(worker_spawn_cwd(&agent, Path::new("/ws")), PathBuf::from("/ws"));
299
+ let agent = YamlValue::Map(vec![(
300
+ "id".to_string(),
301
+ YamlValue::Str("developer".to_string()),
302
+ )]);
303
+ assert_eq!(
304
+ worker_spawn_cwd(&agent, Path::new("/ws")),
305
+ PathBuf::from("/ws")
306
+ );
245
307
  }
246
308
 
247
309
  #[test]
248
310
  fn worker_spawn_cwd_returns_yaml_override_when_present() {
249
311
  let agent = YamlValue::Map(vec![
250
312
  ("id".to_string(), YamlValue::Str("developer".to_string())),
251
- ("spawn_cwd".to_string(), YamlValue::Str("/explicit/cwd".to_string())),
313
+ (
314
+ "spawn_cwd".to_string(),
315
+ YamlValue::Str("/explicit/cwd".to_string()),
316
+ ),
252
317
  ]);
253
318
  assert_eq!(
254
319
  worker_spawn_cwd(&agent, Path::new("/ws")),
@@ -262,6 +327,9 @@ mod tests {
262
327
  ("id".to_string(), YamlValue::Str("developer".to_string())),
263
328
  ("spawn_cwd".to_string(), YamlValue::Str("".to_string())),
264
329
  ]);
265
- assert_eq!(worker_spawn_cwd(&agent, Path::new("/ws")), PathBuf::from("/ws"));
330
+ assert_eq!(
331
+ worker_spawn_cwd(&agent, Path::new("/ws")),
332
+ PathBuf::from("/ws")
333
+ );
266
334
  }
267
335
  }
@@ -63,7 +63,13 @@ pub(crate) fn resolve_workspace_for_hash(workspace: &Path) -> PathBuf {
63
63
  pub(crate) fn sanitize_session_folder(raw: &str) -> String {
64
64
  let replaced: String = raw
65
65
  .chars()
66
- .map(|c| if c.is_ascii_alphanumeric() || matches!(c, '_' | '-' | '.') { c } else { '_' })
66
+ .map(|c| {
67
+ if c.is_ascii_alphanumeric() || matches!(c, '_' | '-' | '.') {
68
+ c
69
+ } else {
70
+ '_'
71
+ }
72
+ })
67
73
  .take(48)
68
74
  .collect();
69
75
  let trimmed = replaced.trim_matches(|c| matches!(c, '_' | '-' | '.'));