@team-agent/installer 0.5.125 → 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 (144) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/diagnose.rs +0 -137
  4. package/crates/team-agent/src/cli/emit.rs +13 -8
  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 +55 -10
  8. package/crates/team-agent/src/cli/mod.rs +35 -29
  9. package/crates/team-agent/src/cli/models.rs +33 -944
  10. package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
  11. package/crates/team-agent/src/cli/tests/mod.rs +3 -3
  12. package/crates/team-agent/src/cli/tests/run_delegation.rs +8 -7
  13. package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
  14. package/crates/team-agent/src/compiler/tests.rs +54 -12
  15. package/crates/team-agent/src/compiler.rs +7 -205
  16. package/crates/team-agent/src/contract_runtime/backend.rs +97 -38
  17. package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
  18. package/crates/team-agent/src/contract_runtime/config.rs +12 -8
  19. package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
  20. package/crates/team-agent/src/contract_runtime/framework.rs +8 -13
  21. package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
  22. package/crates/team-agent/src/contract_runtime/registry.rs +100 -60
  23. package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
  24. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +54 -16
  25. package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
  26. package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -44
  27. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
  28. package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
  29. package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
  30. package/crates/team-agent/src/leader/start.rs +1 -1
  31. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +2 -195
  32. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
  33. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +22 -200
  34. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
  35. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +5 -496
  36. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
  37. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -26
  38. package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
  39. package/crates/team-agent/src/lifecycle/launch/spawn.rs +26 -51
  40. package/crates/team-agent/src/lifecycle/launch.rs +3 -34
  41. package/crates/team-agent/src/lifecycle/profile_launch.rs +18 -373
  42. package/crates/team-agent/src/lifecycle/restart/common.rs +45 -463
  43. package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
  44. package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
  45. package/crates/team-agent/src/lifecycle/restart.rs +0 -2
  46. package/crates/team-agent/src/lifecycle/role_config.rs +40 -13
  47. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
  48. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
  49. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +38 -236
  50. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
  51. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +106 -186
  52. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +4 -334
  53. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +19 -15
  54. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
  55. package/crates/team-agent/src/lifecycle/tests/core.rs +33 -58
  56. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
  57. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +15 -133
  58. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
  59. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
  60. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
  61. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
  62. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +162 -284
  63. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
  64. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
  65. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
  66. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
  67. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
  68. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
  69. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
  70. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
  71. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
  72. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
  73. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
  74. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +15 -14
  75. package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
  76. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
  77. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
  78. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
  79. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1478
  80. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
  81. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +7 -7
  82. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
  83. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
  84. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
  85. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
  86. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
  87. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
  88. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +74 -19
  89. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +39 -38
  90. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +42 -97
  91. package/crates/team-agent/src/lifecycle/tests.rs +0 -7
  92. package/crates/team-agent/src/lifecycle/types.rs +2 -21
  93. package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
  94. package/crates/team-agent/src/messaging/delivery.rs +14 -195
  95. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
  96. package/crates/team-agent/src/messaging/tests/dup_inject.rs +68 -69
  97. package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
  98. package/crates/team-agent/src/messaging/tests/runtime.rs +5 -5
  99. package/crates/team-agent/src/messaging/tests/spine.rs +30 -32
  100. package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
  101. package/crates/team-agent/src/provider/adapter.rs +71 -572
  102. package/crates/team-agent/src/provider/adapters/mod.rs +6 -8
  103. package/crates/team-agent/src/provider/model_catalog.rs +13 -201
  104. package/crates/team-agent/src/provider/session/capture.rs +11 -211
  105. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -24
  106. package/crates/team-agent/src/provider/session/context_fork.rs +29 -240
  107. package/crates/team-agent/src/provider/session/mod.rs +2 -3
  108. package/crates/team-agent/src/provider/session_scan/common.rs +27 -87
  109. package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
  110. package/crates/team-agent/src/provider/session_scan.rs +7 -23
  111. package/crates/team-agent/src/provider/tests/adapter.rs +66 -204
  112. package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -29
  113. package/crates/team-agent/src/provider/tests/idle.rs +0 -68
  114. package/crates/team-agent/src/provider/types.rs +0 -4
  115. package/crates/team-agent/src/provider/wire.rs +77 -23
  116. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
  117. package/crates/team-agent/src/state/persist.rs +6 -6
  118. package/crates/team-agent/src/state/repository/tests.rs +2 -2
  119. package/crates/team-agent/src/tmux_backend.rs +4 -3
  120. package/package.json +4 -4
  121. package/skills/team-agent/SKILL.md +8 -5
  122. package/skills/team-agent/command-coverage.json +29 -1
  123. package/skills/team-agent/docs/reference/team-agent-operator.md +7 -3
  124. package/skills/team-agent/references/team-agent-operator.md +7 -3
  125. package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
  126. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
  127. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  128. package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
  129. package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
  130. package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
  131. package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
  132. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  133. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
  134. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  135. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  136. package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
  137. package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
  138. package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
  139. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  140. package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
  141. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  142. package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
  143. package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
  144. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
@@ -1,247 +0,0 @@
1
- //! ---
2
- //! purpose: grok 席位角色 effort 必须进入 argv;缺字段不发 flag
3
- //! contract:
4
- //! provides:
5
- //! - name: grok-effort-medium-reaches-argv
6
- //! what: effort: medium ⇒ 相邻 `--effort medium`
7
- //! - name: grok-effort-absent-omits-flag
8
- //! what: 角色无 effort 字段 ⇒ argv 中 `--effort` 次数为 0
9
- //! - name: grok-effort-survives-restart
10
- //! what: restart 后仍带同一档
11
- //! - name: grok-effort-no-longer-silently-dropped
12
- //! what: 已废除「grok effort 被静默丢弃 + effort_unsupported」
13
- //! boundary: 只钉 Provider::Grok 的 effort 启动契约;不改 claude/codex/cursor
14
- //! maturity: wired
15
- //! ---
16
-
17
- #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
18
-
19
- #[path = "../../../tests/support/hermetic.rs"]
20
- mod hermetic_guard;
21
- #[allow(dead_code)]
22
- fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
23
-
24
- fn enter_hermetic(tag: &str) -> hermetic_guard::HermeticTestEnv {
25
- hermetic_guard::HermeticTestEnv::enter_with_leader(tag)
26
- }
27
-
28
- use std::path::{Path, PathBuf};
29
- use std::sync::atomic::{AtomicU64, Ordering};
30
-
31
- use serial_test::serial;
32
- use team_agent::lifecycle::{quick_start_with_transport_in_workspace, restart_with_transport};
33
- use team_agent::transport::test_support::OfflineTransport;
34
-
35
- #[test]
36
- #[serial(env)]
37
- fn grok_role_effort_medium_reaches_argv() {
38
- let _hermetic = enter_hermetic("grok-effort-medium");
39
- let (ws, _home, _guard, team) = seed_grok("effort-medium", Some("medium"));
40
- let transport = OfflineTransport::new();
41
- quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &transport)
42
- .expect("grok role with effort: medium must start");
43
- let argv = first_spawn_argv(&transport);
44
- assert!(
45
- argv_contains_adjacent(&argv, &["--effort", "medium"]),
46
- "declared effort must appear as adjacent `--effort medium`; argv={argv:?}"
47
- );
48
- }
49
-
50
- #[test]
51
- #[serial(env)]
52
- fn grok_role_without_effort_emits_zero_effort_flags() {
53
- let _hermetic = enter_hermetic("grok-effort-absent");
54
- let (ws, _home, _guard, team) = seed_grok("effort-absent", None);
55
- let transport = OfflineTransport::new();
56
- quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &transport)
57
- .expect("grok role without effort must start");
58
- let argv = first_spawn_argv(&transport);
59
- let count = argv.iter().filter(|a| *a == "--effort").count();
60
- assert_eq!(
61
- count, 0,
62
- "absent effort must not invent a default flag; argv={argv:?}"
63
- );
64
- }
65
-
66
- #[test]
67
- #[serial(env)]
68
- fn grok_restart_keeps_declared_effort_medium() {
69
- let _hermetic = enter_hermetic("grok-effort-restart");
70
- let (ws, _home, _guard, team) = seed_grok("effort-restart", Some("medium"));
71
- let first = OfflineTransport::new();
72
- quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &first)
73
- .expect("initial grok start");
74
- assert!(
75
- argv_contains_adjacent(&first_spawn_argv(&first), &["--effort", "medium"]),
76
- "precondition: first start must carry medium; argv={:?}",
77
- first_spawn_argv(&first)
78
- );
79
-
80
- seed_healthy_coordinator(&ws);
81
-
82
- let restart = OfflineTransport::new();
83
- restart_with_transport(&ws, true, Some("grokteam"), &restart)
84
- .expect("restart --allow-fresh must start the grok seat");
85
- let argv = first_spawn_argv(&restart);
86
- assert!(
87
- argv_contains_adjacent(&argv, &["--effort", "medium"]),
88
- "restart must keep the persisted effort; argv={argv:?}"
89
- );
90
- }
91
-
92
- #[test]
93
- #[serial(env)]
94
- fn grok_role_effort_max_is_rejected_at_compile() {
95
- let (ws, _home, _guard, team) = seed_grok("effort-max", Some("max"));
96
- let err =
97
- team_agent::compiler::compile_team(&team).expect_err("grok + effort:max must not compile");
98
- let text = err.to_string();
99
- assert!(
100
- text.contains("max") && (text.contains("claude") || text.contains("only supported")),
101
- "max must stay claude-only at compile; err={text}"
102
- );
103
- }
104
-
105
- #[test]
106
- #[serial(env)]
107
- fn grok_medium_effort_no_longer_emits_unsupported_event() {
108
- // 已废除的行为:旧实现把 grok 的 effort 静默丢掉并写 provider.effort_unsupported,
109
- // 此断言证明它确实没了。
110
- let (ws, _home, _guard, team) = seed_grok("effort-tombstone", Some("medium"));
111
- let transport = OfflineTransport::new();
112
- quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("grokteam"), &transport)
113
- .expect("grok role with effort: medium must start");
114
- let events = team_agent::event_log::EventLog::new(&ws)
115
- .tail(0)
116
- .expect("events");
117
- let dropped = events.iter().any(|event| {
118
- event.get("event").and_then(serde_json::Value::as_str)
119
- == Some("provider.effort_unsupported")
120
- });
121
- assert!(
122
- !dropped,
123
- "grok medium must not emit provider.effort_unsupported; events={events:?}"
124
- );
125
- }
126
-
127
- /// restart 的就绪门要求 `coordinator_health().ok`,而单测里 `start_coordinator`
128
- /// spawn 的是 `std::env::current_exe()` —— 也就是 libtest 测试二进制本身,它一启动
129
- /// 就以 `Unrecognized option: 'workspace'` 退出并变成僵尸,`pid_is_running` 的
130
- /// `ps stat=` 一看到 `Z` 就判 not running。于是就绪门只能靠「抢在死婴被看到之前
131
- /// 探到它」这个竞态过关,慢机/高负载上必然超时。这里按本仓既有写法(见
132
- /// `copilot_provider_red.rs` / `restart_build_before_destroy_0540_contract.rs`)
133
- /// 预先把 pid 文件与 metadata 指向测试进程自己,让 `start_coordinator` 走
134
- /// `AlreadyRunning` 早返回,竞态被删掉而不是被调宽。
135
- fn seed_healthy_coordinator(workspace: &Path) {
136
- let workspace = crate::coordinator::WorkspacePath::new(workspace.to_path_buf());
137
- let pid = crate::coordinator::Pid::new(std::process::id());
138
- std::fs::create_dir_all(
139
- crate::coordinator::coordinator_pid_path(&workspace)
140
- .parent()
141
- .unwrap(),
142
- )
143
- .unwrap();
144
- crate::coordinator::write_coordinator_metadata(
145
- &workspace,
146
- pid,
147
- crate::coordinator::MetadataSource::Boot,
148
- )
149
- .expect("write coordinator metadata");
150
- std::fs::write(
151
- crate::coordinator::coordinator_pid_path(&workspace),
152
- pid.to_string(),
153
- )
154
- .expect("write coordinator pid");
155
- }
156
-
157
- fn seed_grok(tag: &str, effort: Option<&str>) -> (PathBuf, PathBuf, HomeGuard, PathBuf) {
158
- let ws = tmp_dir(tag);
159
- super::launch_spawn::seed_healthy_coordinator(&ws);
160
- let home = tmp_dir(&format!("{tag}-home"));
161
- seed_grok_home(&home, Some(&ws));
162
- let guard = HomeGuard::set(&home);
163
- let team = write_grok_role(&ws, effort);
164
- (ws, home, guard, team)
165
- }
166
-
167
- fn first_spawn_argv(transport: &OfflineTransport) -> Vec<String> {
168
- let records = transport.spawn_records();
169
- assert!(
170
- !records.is_empty(),
171
- "expected a worker spawn so argv can be inspected; records={records:?}"
172
- );
173
- records[0].1.clone()
174
- }
175
-
176
- fn argv_contains_adjacent(hay: &[String], needle: &[&str]) -> bool {
177
- hay.windows(needle.len())
178
- .any(|window| window.iter().map(String::as_str).eq(needle.iter().copied()))
179
- }
180
-
181
- fn write_grok_role(ws: &Path, effort: Option<&str>) -> PathBuf {
182
- let team = ws.join("grokteam");
183
- std::fs::create_dir_all(team.join("agents")).unwrap();
184
- std::fs::write(
185
- team.join("TEAM.md"),
186
- "---\nname: grokteam\nobjective: grok effort argv.\nprovider: grok\ndangerously_skip_permissions: false\n---\n\nTeam.\n",
187
- )
188
- .unwrap();
189
- let effort_line = match effort {
190
- Some(value) => format!("effort: {value}\n"),
191
- None => String::new(),
192
- };
193
- std::fs::write(
194
- team.join("agents").join("grok_writer.md"),
195
- format!(
196
- "---\nname: grok_writer\nrole: Grok Writer\nprovider: grok\nmodel: grok-4.6\n{effort_line}auth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
197
- ),
198
- )
199
- .unwrap();
200
- team
201
- }
202
-
203
- fn seed_grok_home(home: &Path, trusted_cwd: Option<&Path>) {
204
- let grok = home.join(".grok");
205
- std::fs::create_dir_all(&grok).unwrap();
206
- std::fs::write(grok.join("auth.json"), r#"{"test":"ok"}"#).unwrap();
207
- if let Some(cwd) = trusted_cwd {
208
- std::fs::write(
209
- grok.join("trusted_folders.toml"),
210
- format!("[folders.\"{}\"]\ntrusted = true\n", cwd.display()),
211
- )
212
- .unwrap();
213
- }
214
- }
215
-
216
- struct HomeGuard {
217
- prev: Option<String>,
218
- }
219
-
220
- impl HomeGuard {
221
- fn set(home: &Path) -> Self {
222
- let prev = std::env::var("HOME").ok();
223
- std::env::set_var("HOME", home);
224
- Self { prev }
225
- }
226
- }
227
-
228
- impl Drop for HomeGuard {
229
- fn drop(&mut self) {
230
- match &self.prev {
231
- Some(value) => std::env::set_var("HOME", value),
232
- None => std::env::remove_var("HOME"),
233
- }
234
- }
235
- }
236
-
237
- fn tmp_dir(tag: &str) -> PathBuf {
238
- static N: AtomicU64 = AtomicU64::new(0);
239
- let dir = std::env::temp_dir().join(format!(
240
- "ta-rs-grok-effort-{tag}-{}-{}",
241
- std::process::id(),
242
- N.fetch_add(1, Ordering::Relaxed)
243
- ));
244
- let _ = std::fs::remove_dir_all(&dir);
245
- std::fs::create_dir_all(&dir).unwrap();
246
- std::fs::canonicalize(dir).unwrap()
247
- }