@team-agent/installer 0.5.126 → 0.5.127

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 (107) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/diagnose.rs +0 -69
  4. package/crates/team-agent/src/cli/emit.rs +10 -9
  5. package/crates/team-agent/src/cli/grok_slot.rs +88 -3
  6. package/crates/team-agent/src/cli/intent/runtime.rs +6 -4
  7. package/crates/team-agent/src/cli/intent/runtime_tests.rs +45 -0
  8. package/crates/team-agent/src/cli/mod.rs +13 -1
  9. package/crates/team-agent/src/cli/models.rs +27 -181
  10. package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
  11. package/crates/team-agent/src/cli/tests/mod.rs +2 -2
  12. package/crates/team-agent/src/cli/tests/run_delegation.rs +3 -3
  13. package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
  14. package/crates/team-agent/src/compiler/tests.rs +36 -9
  15. package/crates/team-agent/src/compiler.rs +3 -2
  16. package/crates/team-agent/src/contract_runtime/backend.rs +36 -0
  17. package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
  18. package/crates/team-agent/src/contract_runtime/config.rs +6 -5
  19. package/crates/team-agent/src/contract_runtime/framework.rs +2 -5
  20. package/crates/team-agent/src/contract_runtime/registry.rs +66 -67
  21. package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
  22. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +27 -10
  23. package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
  24. package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -2
  25. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
  26. package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
  27. package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
  28. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +17 -185
  29. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +4 -487
  30. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -2
  31. package/crates/team-agent/src/lifecycle/launch/spawn.rs +8 -21
  32. package/crates/team-agent/src/lifecycle/launch.rs +3 -11
  33. package/crates/team-agent/src/lifecycle/profile_launch.rs +8 -64
  34. package/crates/team-agent/src/lifecycle/restart/common.rs +6 -151
  35. package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
  36. package/crates/team-agent/src/lifecycle/role_config.rs +40 -13
  37. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
  38. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
  39. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +37 -240
  40. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +95 -59
  41. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +20 -35
  42. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
  43. package/crates/team-agent/src/lifecycle/tests/core.rs +22 -48
  44. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
  45. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +6 -124
  46. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
  47. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
  48. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
  49. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +136 -256
  50. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
  51. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
  52. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
  53. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
  54. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +7 -7
  55. package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
  56. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
  57. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
  58. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
  59. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1374
  60. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
  61. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +5 -5
  62. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
  63. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
  64. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
  65. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
  66. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
  67. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +70 -15
  68. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +35 -35
  69. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +36 -82
  70. package/crates/team-agent/src/lifecycle/tests.rs +0 -4
  71. package/crates/team-agent/src/lifecycle/types.rs +2 -5
  72. package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
  73. package/crates/team-agent/src/messaging/delivery.rs +9 -61
  74. package/crates/team-agent/src/messaging/tests/dup_inject.rs +67 -68
  75. package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
  76. package/crates/team-agent/src/messaging/tests/runtime.rs +5 -5
  77. package/crates/team-agent/src/messaging/tests/spine.rs +5 -1
  78. package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
  79. package/crates/team-agent/src/provider/adapter.rs +58 -356
  80. package/crates/team-agent/src/provider/adapters/mod.rs +5 -7
  81. package/crates/team-agent/src/provider/session/capture.rs +5 -105
  82. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -20
  83. package/crates/team-agent/src/provider/session/context_fork.rs +23 -142
  84. package/crates/team-agent/src/provider/session/mod.rs +2 -3
  85. package/crates/team-agent/src/provider/session_scan/common.rs +21 -57
  86. package/crates/team-agent/src/provider/session_scan.rs +6 -16
  87. package/crates/team-agent/src/provider/tests/adapter.rs +37 -118
  88. package/crates/team-agent/src/provider/tests/command_helpers.rs +1 -18
  89. package/crates/team-agent/src/provider/tests/idle.rs +0 -43
  90. package/crates/team-agent/src/provider/types.rs +0 -4
  91. package/crates/team-agent/src/provider/wire.rs +34 -8
  92. package/crates/team-agent/src/tmux_backend.rs +4 -3
  93. package/package.json +4 -4
  94. package/skills/team-agent/SKILL.md +3 -2
  95. package/skills/team-agent/command-coverage.json +14 -0
  96. package/skills/team-agent/docs/reference/team-agent-operator.md +3 -1
  97. package/skills/team-agent/references/team-agent-operator.md +3 -1
  98. package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
  99. package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
  100. package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
  101. package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
  102. package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
  103. package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
  104. package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
  105. package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
  106. package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
  107. package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
@@ -1,260 +0,0 @@
1
- //! ---
2
- //! purpose: 判定 .grok/config.toml env 里哪些键是每席私有
3
- //! contract:
4
- //! provides:
5
- //! - name: is_per_seat_env_key
6
- //! what: TEAM_AGENT_* 除 WORKSPACE 外都是每席键
7
- //! - name: per_seat_keys_in_toml
8
- //! what: 扫描 toml env 表里的每席键
9
- //! - name: strip_per_seat_keys_from_toml
10
- //! what: 从任意 .env 表删掉每席键,留下非框架键
11
- //! - name: non_per_seat_env_in_tables
12
- //! what: 从指定表的 .env 取出非每席键(值原样),供 overlay 保留
13
- //! boundary:
14
- //! - 不写盘
15
- //! - 不数 grok 席位个数
16
- //! - 剥离结果只含键名,不含键值
17
- //! maturity: wired
18
- //! ---
19
-
20
- /// ---
21
- /// purpose: 判断某环境键是否属于每席私有
22
- /// returns: 以 TEAM_AGENT_ 起头且不是 TEAM_AGENT_WORKSPACE 时为 true
23
- /// ---
24
- /// Shared identity keys belong on pane env. The only TEAM_AGENT_* key
25
- /// allowed in the directory-scoped grok toml is WORKSPACE (same cwd).
26
- pub(crate) fn is_per_seat_env_key(key: &str) -> bool {
27
- let key = key.trim();
28
- key.starts_with("TEAM_AGENT_") && key != "TEAM_AGENT_WORKSPACE"
29
- }
30
-
31
- /// ---
32
- /// purpose: 扫出 toml 里所有 env 表中的每席键
33
- /// returns: 首次出现顺序的键值对,值已去掉引号
34
- /// ---
35
- pub(crate) fn per_seat_keys_in_toml(text: &str) -> Vec<(String, String)> {
36
- let mut in_env_table = false;
37
- let mut out = Vec::new();
38
- for line in text.lines() {
39
- let trimmed = line.trim();
40
- if trimmed.starts_with('[') && trimmed.ends_with(']') {
41
- let name = &trimmed[1..trimmed.len() - 1];
42
- in_env_table = name.ends_with(".env");
43
- continue;
44
- }
45
- if !in_env_table {
46
- continue;
47
- }
48
- let Some((key, rest)) = trimmed.split_once('=') else {
49
- continue;
50
- };
51
- let key = key.trim();
52
- if !is_per_seat_env_key(key) {
53
- continue;
54
- }
55
- let rest = rest.trim();
56
- let value = rest
57
- .strip_prefix('"')
58
- .and_then(|s| s.strip_suffix('"'))
59
- .or_else(|| rest.strip_prefix('\'').and_then(|s| s.strip_suffix('\'')))
60
- .unwrap_or(rest);
61
- if out.iter().any(|(existing, _)| existing == key) {
62
- continue;
63
- }
64
- out.push((key.to_string(), value.to_string()));
65
- }
66
- out
67
- }
68
-
69
- /// ---
70
- /// purpose: 从所有 env 表里删掉每席键
71
- /// returns: 删后的全文,以及被删键名的首次出现顺序列表,不含值
72
- /// ---
73
- /// Drop per-seat `TEAM_AGENT_*` assignments from any `*.env` table.
74
- /// Other keys (`TEAM_AGENT_WORKSPACE`, `GROK_FOLDER_TRUST`, user keys) stay.
75
- /// Returned names are first-seen order, values never included.
76
- pub(crate) fn strip_per_seat_keys_from_toml(text: &str) -> (String, Vec<String>) {
77
- let mut in_env_table = false;
78
- let mut out = String::new();
79
- let mut removed = Vec::new();
80
- for line in text.lines() {
81
- let trimmed = line.trim();
82
- if trimmed.starts_with('[') && trimmed.ends_with(']') {
83
- let name = &trimmed[1..trimmed.len() - 1];
84
- in_env_table = name.ends_with(".env");
85
- out.push_str(line);
86
- out.push('\n');
87
- continue;
88
- }
89
- if in_env_table {
90
- if let Some((key, _)) = trimmed.split_once('=') {
91
- let key = key.trim();
92
- if is_per_seat_env_key(key) {
93
- if !removed.iter().any(|existing| existing == key) {
94
- removed.push(key.to_string());
95
- }
96
- continue;
97
- }
98
- }
99
- }
100
- out.push_str(line);
101
- out.push('\n');
102
- }
103
- (out, removed)
104
- }
105
-
106
- fn toml_env_value(rest: &str) -> String {
107
- let rest = rest.trim();
108
- rest.strip_prefix('"')
109
- .and_then(|s| s.strip_suffix('"'))
110
- .or_else(|| rest.strip_prefix('\'').and_then(|s| s.strip_suffix('\'')))
111
- .unwrap_or(rest)
112
- .to_string()
113
- }
114
-
115
- /// ---
116
- /// purpose: 取出指定表的 env 段里非每席的键值
117
- /// params:
118
- /// tables: 目标表名前缀,只看这些表下的 env 段
119
- /// returns: 键到值的有序映射,供覆盖写入时保留用户键
120
- /// ---
121
- /// Keys in `tables*.env` that are **not** per-seat. Unknown keys must be
122
- /// kept — detection failure does not authorize deletion.
123
- pub(crate) fn non_per_seat_env_in_tables(
124
- text: &str,
125
- tables: &[&str],
126
- ) -> std::collections::BTreeMap<String, String> {
127
- let mut in_target_env = false;
128
- let mut out = std::collections::BTreeMap::new();
129
- for line in text.lines() {
130
- let trimmed = line.trim();
131
- if trimmed.starts_with('[') && trimmed.ends_with(']') {
132
- let name = &trimmed[1..trimmed.len() - 1];
133
- in_target_env = name.ends_with(".env")
134
- && tables
135
- .iter()
136
- .any(|table| name == *table || name.starts_with(&format!("{table}.")));
137
- continue;
138
- }
139
- if !in_target_env {
140
- continue;
141
- }
142
- let Some((key, rest)) = trimmed.split_once('=') else {
143
- continue;
144
- };
145
- let key = key.trim();
146
- if key.is_empty() || is_per_seat_env_key(key) {
147
- continue;
148
- }
149
- out.entry(key.to_string())
150
- .or_insert_with(|| toml_env_value(rest));
151
- }
152
- out
153
- }
154
-
155
- #[cfg(test)]
156
- mod tests {
157
- use super::*;
158
-
159
- #[test]
160
- fn workspace_is_shared_other_team_agent_keys_are_per_seat() {
161
- assert!(!is_per_seat_env_key("TEAM_AGENT_WORKSPACE"));
162
- assert!(is_per_seat_env_key("TEAM_AGENT_ID"));
163
- assert!(is_per_seat_env_key("TEAM_AGENT_OWNER_TEAM_ID"));
164
- assert!(is_per_seat_env_key("TEAM_AGENT_AUTH_MODE"));
165
- assert!(is_per_seat_env_key("TEAM_AGENT_FUTURE_SEAT_KEY"));
166
- assert!(!is_per_seat_env_key("GROK_FOLDER_TRUST"));
167
- }
168
-
169
- #[test]
170
- fn scan_finds_per_seat_keys_in_env_table_only() {
171
- let text = r#"
172
- [mcp_servers.other.env]
173
- TEAM_AGENT_ID = "ignore-other-server-still-counts"
174
-
175
- [mcp_servers.team_orchestrator]
176
- command = "/bin/x"
177
-
178
- [mcp_servers.team_orchestrator.env]
179
- TEAM_AGENT_WORKSPACE = "/ws"
180
- TEAM_AGENT_AUTH_MODE = "impostor"
181
- "#;
182
- let keys = per_seat_keys_in_toml(text);
183
- assert!(
184
- keys.iter()
185
- .any(|(k, v)| k == "TEAM_AGENT_AUTH_MODE" && v == "impostor"),
186
- "must see AUTH; keys={keys:?}"
187
- );
188
- assert!(
189
- keys.iter().any(|(k, _)| k == "TEAM_AGENT_ID"),
190
- "any env table per-seat key counts; keys={keys:?}"
191
- );
192
- assert!(
193
- !keys.iter().any(|(k, _)| k == "TEAM_AGENT_WORKSPACE"),
194
- "WORKSPACE is shared; keys={keys:?}"
195
- );
196
- }
197
-
198
- #[test]
199
- fn strip_drops_only_per_seat_keys_and_returns_names() {
200
- let text = r#"
201
- [mcp_servers.keep.env]
202
- GROK_FOLDER_TRUST = "1"
203
- TEAM_AGENT_ID = "impostor"
204
- TEAM_AGENT_WORKSPACE = "/ws"
205
-
206
- [mcp_servers.keep]
207
- command = "/bin/keep"
208
-
209
- [other]
210
- TEAM_AGENT_AUTH_MODE = "not-in-env-table"
211
- "#;
212
- let (cleaned, removed) = strip_per_seat_keys_from_toml(text);
213
- assert_eq!(removed, vec!["TEAM_AGENT_ID".to_string()]);
214
- assert!(
215
- !cleaned.contains("TEAM_AGENT_ID"),
216
- "per-seat key must leave the env table; cleaned={cleaned}"
217
- );
218
- assert!(
219
- cleaned.contains("GROK_FOLDER_TRUST = \"1\"")
220
- && cleaned.contains("TEAM_AGENT_WORKSPACE = \"/ws\"")
221
- && cleaned.contains("TEAM_AGENT_AUTH_MODE = \"not-in-env-table\"")
222
- && cleaned.contains("command = \"/bin/keep\""),
223
- "non-per-seat keys and non-env tables stay; cleaned={cleaned}"
224
- );
225
- assert!(
226
- !cleaned.contains("impostor"),
227
- "stripped values must not be rewritten; cleaned={cleaned}"
228
- );
229
- }
230
-
231
- #[test]
232
- fn non_per_seat_scan_keeps_unknown_keys_from_named_tables_only() {
233
- let text = r#"
234
- [mcp_servers.keep-me.env]
235
- GROK_FOLDER_TRUST = "other-table"
236
-
237
- [mcp_servers.team_orchestrator.env]
238
- TEAM_AGENT_ID = "stale"
239
- GROK_FOLDER_TRUST = "1"
240
- TEAM_AGENT_WORKSPACE = "/ws"
241
- USER_EXTRA = "keep"
242
- "#;
243
- let kept = non_per_seat_env_in_tables(text, &["mcp_servers.team_orchestrator"]);
244
- assert_eq!(kept.get("GROK_FOLDER_TRUST").map(String::as_str), Some("1"));
245
- assert_eq!(kept.get("USER_EXTRA").map(String::as_str), Some("keep"));
246
- assert_eq!(
247
- kept.get("TEAM_AGENT_WORKSPACE").map(String::as_str),
248
- Some("/ws")
249
- );
250
- assert!(
251
- !kept.contains_key("TEAM_AGENT_ID"),
252
- "per-seat keys are not preserved; kept={kept:?}"
253
- );
254
- assert_ne!(
255
- kept.get("GROK_FOLDER_TRUST").map(String::as_str),
256
- Some("other-table"),
257
- "only the named table is read; kept={kept:?}"
258
- );
259
- }
260
- }