@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,6 +1,6 @@
1
1
  //! purpose: grok 席位角色文件必须显式写 model,缺则拒绝启动
2
2
  //! contract: 缺 model 的 grok 角色启动失败(错误含 model 与原因);写了 model
3
- //! 则该值进入 worker argv 的 `--model <值>`;claude 缺 model 行为不变
3
+ //! 则该值进入 worker argv 的 `--model <值>`;copilot 缺 model 行为不变
4
4
  //! boundary: 只钉 Provider::Grok 的启动契约;不改 claude/codex/copilot 路径
5
5
  //!
6
6
  //! 修之前判红(40e91fba):grok 角色缺 model 仍会成功启动(compiler 填
@@ -97,20 +97,20 @@ fn grok_role_explicit_model_reaches_argv() {
97
97
  );
98
98
  }
99
99
 
100
- /// 3. claude 角色缺 model ⇒ 行为不变(仍能启动,不被 grok 的硬性 model 要求误伤)。
100
+ /// 3. copilot 角色缺 model ⇒ 行为不变(仍能启动,不被 grok 的硬性 model 要求误伤)。
101
101
  #[test]
102
102
  #[serial(env)]
103
- fn claude_role_missing_model_still_starts() {
104
- let _hermetic = enter_hermetic("grok-claude-missing-model");
105
- let ws = tmp_dir("claude-no-model");
103
+ fn copilot_role_missing_model_still_starts() {
104
+ let _hermetic = enter_hermetic("grok-copilot-missing-model");
105
+ let ws = tmp_dir("copilot-no-model");
106
106
  super::launch_spawn::seed_healthy_coordinator(&ws);
107
107
  let team = write_role_team(
108
108
  &ws,
109
- "claudeteam",
110
- "clauder",
111
- "claude",
109
+ "copilotteam",
110
+ "copiloter",
111
+ "copilot",
112
112
  None,
113
- "Claude Worker",
113
+ "Copilot Worker",
114
114
  );
115
115
  let transport = OfflineTransport::new();
116
116
 
@@ -119,17 +119,17 @@ fn claude_role_missing_model_still_starts() {
119
119
  &team,
120
120
  None,
121
121
  true,
122
- Some("claudeteam"),
122
+ Some("copilotteam"),
123
123
  &transport,
124
124
  );
125
125
  assert!(
126
126
  result.is_ok(),
127
- "claude role without model must keep starting; grok-only requirement leaked; err={result:?}"
127
+ "copilot role without model must keep starting; grok-only requirement leaked; err={result:?}"
128
128
  );
129
129
  let argv = first_spawn_argv(&transport);
130
130
  assert!(
131
131
  !argv.is_empty(),
132
- "claude seat must still spawn; argv={argv:?}"
132
+ "copilot seat must still spawn; argv={argv:?}"
133
133
  );
134
134
  }
135
135
 
@@ -10,8 +10,8 @@
10
10
  //! leave a stale .tmp on a failed replace. The contracts assert the original data
11
11
  //! survives / no residue.
12
12
  //! T3 (false green = unrecognized/failed input silently maps to a success value,
13
- //! MUST-NOT-13): normalize_result_status unrecognized -> Success; claude_auth_hint
14
- //! parse failure -> Present; schema_diagnosis missing db -> ok:true; tmux fabricated
13
+ //! MUST-NOT-13): normalize_result_status unrecognized -> Success; schema_diagnosis
14
+ //! missing db -> ok:true; tmux fabricated
15
15
  //! `%0` pane id; packaging install/update constant DoctorStatus::Ok.
16
16
  //! T5: stop_coordinator_bounded spawns a thread + recv_timeout and never joins it —
17
17
  //! a timed-out stop leaves a detached thread. Source grep guard (the bounded-stop
@@ -23,7 +23,7 @@
23
23
  #[allow(dead_code)]
24
24
  mod mcp_sim_harness;
25
25
 
26
- use std::path::{Path, PathBuf};
26
+ use std::path::PathBuf;
27
27
  use std::sync::atomic::{AtomicU64, Ordering};
28
28
 
29
29
  use mcp_sim_harness::McpSimHarness;
@@ -419,45 +419,6 @@ check behind it = false green); it must reflect an actual doctor result"
419
419
  );
420
420
  }
421
421
 
422
- /// T3-2 (claude_auth_hint parse failure): when `claude auth status` output is
423
- /// unparseable / unsuccessful, the hint must not default to Present (auth misreported
424
- /// as available). PATH-shims a `claude` that prints garbage and exits non-zero.
425
- /// Mutates the process-global PATH/HOME — must not race host_cotenant's ps/tmux
426
- /// shims (P0 pid-probe isolation) or other env-mutating tests, hence
427
- /// `#[serial(env, pid_probe)]`.
428
- #[test]
429
- #[serial(env, pid_probe)]
430
- fn t3_claude_auth_hint_parse_failure_is_not_present() {
431
- let home = tmp_ws("t3-auth-home");
432
- let shim_dir = home.join("bin");
433
- std::fs::create_dir_all(&shim_dir).unwrap();
434
- // claude shim: garbage stdout + non-zero exit (auth status unparseable / failed).
435
- write_shim(
436
- &shim_dir.join("claude"),
437
- "#!/bin/sh\nprintf 'not json at all\\n'\nexit 7\n",
438
- );
439
- let old_path = std::env::var("PATH").unwrap_or_default();
440
- let old_home = std::env::var("HOME").ok();
441
- std::env::set_var("HOME", &home);
442
- std::env::set_var("PATH", format!("{}:{old_path}", shim_dir.to_string_lossy()));
443
-
444
- let status = team_agent::provider::get_adapter(team_agent::provider::Provider::Claude)
445
- .auth_hint(team_agent::provider::AuthMode::Subscription);
446
-
447
- std::env::set_var("PATH", &old_path);
448
- match old_home {
449
- Some(home) => std::env::set_var("HOME", home),
450
- None => std::env::remove_var("HOME"),
451
- }
452
-
453
- assert_ne!(
454
- format!("{status:?}"),
455
- "Present",
456
- "T3-2: a `claude auth status` that prints unparseable output and exits non-zero \
457
- must NOT report Present (auth misreported as available is a false green); got {status:?}"
458
- );
459
- }
460
-
461
422
  // ───────────────────────────────── T5 · thread leak ─────────────────────────────────
462
423
 
463
424
  /// T5 (A2 shutdown thread leak): stop_coordinator_bounded spawns a worker thread and
@@ -484,15 +445,6 @@ stop; body={body}"
484
445
 
485
446
  // ───────────────────────────────────── helpers ─────────────────────────────────────
486
447
 
487
- fn write_shim(path: &Path, body: &str) {
488
- std::fs::write(path, body).unwrap();
489
- #[cfg(unix)]
490
- {
491
- use std::os::unix::fs::PermissionsExt;
492
- std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap();
493
- }
494
- }
495
-
496
448
  /// Crude single-function body extractor: from the `fn name` line to the next
497
449
  /// same-indent ` fn ` (good enough for grep-guard scoping).
498
450
  fn fn_body(src: &str, marker: &str) -> String {
@@ -41,7 +41,6 @@ fn launch_source() -> String {
41
41
  const QS_TEAM_MD: &str =
42
42
  "---\nname: quickteam\nobjective: Quick start.\nprovider: codex\n---\n\nQuick-start team.\n";
43
43
  pub(super) const QS_VALID_ROLE: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
44
- const QS_ROLE_NO_PROVIDER: &str = "---\nname: implementer\nrole: Implementation Engineer\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
45
44
 
46
45
  /// A REAL team dir `<base>/teamdir/{TEAM.md, agents/implementer.md}` — already in team-dir
47
46
  /// layout, so quick_start's prepare_quick_start_team returns it as-is and writes the compiled
@@ -476,25 +475,23 @@ fn quick_start_default_workspace_compiled_spec_uses_project_root() {
476
475
  );
477
476
  }
478
477
 
479
- // P0 — quick_start over an INVALID role doc (missing `provider`) must surface the REAL compile
480
- // error, distinct from the stub's hardcoded "no role docs found". Golden: compile_team raises
481
- // "missing front matter field provider" (compiler.py:_validate_role_doc), before preflight.
478
+ // An omitted role `provider` is the default `pi`, which declares the Pi contract leaf: the
479
+ // compiled spec carries the leaf id, so quick-start never produces a legacy `pi` worker row.
480
+ #[cfg(unix)]
482
481
  #[test]
483
- fn quick_start_invalid_role_doc_surfaces_real_compile_error() {
484
- let team = quick_start_team_dir(QS_ROLE_NO_PROVIDER);
485
- let transport = OfflineTransport::new();
486
- let result = quick_start_with_transport(&team, None, true, None, &transport);
487
-
488
- let text = format!("{result:?}");
489
- assert!(
490
- text.contains("provider"),
491
- "an invalid role doc (missing provider) must surface the real compile error mentioning \
492
- 'provider'; got {text}"
493
- );
494
- assert!(
495
- !text.contains("no role docs found"),
496
- "must NOT be the hardcoded stub blocker — real preflight/compile distinguishes the cause"
482
+ fn quick_start_role_without_provider_compiles_to_the_pi_leaf() {
483
+ let team = quick_start_team_dir(
484
+ "---\nname: implementer\nrole: Implementation Engineer\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n",
497
485
  );
486
+ let spec = crate::compiler::compile_team(&team).expect("an omitted provider is the default pi");
487
+ let providers = spec
488
+ .get("agents")
489
+ .and_then(crate::model::yaml::Value::as_list)
490
+ .expect("compiled agents")
491
+ .iter()
492
+ .map(|agent| agent.get("provider").and_then(crate::model::yaml::Value::as_str))
493
+ .collect::<Vec<_>>();
494
+ assert_eq!(providers, vec![Some("pi_tui")]);
498
495
  }
499
496
 
500
497
  // P0 — launch (dry_run) over a real compiled spec must resolve the REAL route/permission plan
@@ -2704,21 +2701,22 @@ fn restart_allow_fresh_copilot_keeps_session_id_null_until_capture_confirms() {
2704
2701
  let _ = plan; // shape verified above; details depend on classifier internals.
2705
2702
  }
2706
2703
 
2707
- /// 0.4.6 tuple-atomic contract (audit, line 268): Claude fresh restart
2708
- /// leaves session_id=null even when input row had a stale session_id.
2704
+ /// 0.4.6 tuple-atomic contract (audit, line 268): a fresh restart of a
2705
+ /// preassigned-session worker (Copilot) leaves session_id=null even when the
2706
+ /// input row had a stale session_id.
2709
2707
  /// The poisoned-row scenario (Bug 045 release-engineer state).
2710
2708
  #[test]
2711
- fn restart_allow_fresh_claude_clears_poisoned_session_id() {
2712
- let ws = temp_ws().join("restartclaude046");
2709
+ fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
2710
+ let ws = temp_ws().join("restartcopilot046");
2713
2711
  std::fs::create_dir_all(ws.join("agents")).unwrap();
2714
2712
  std::fs::write(
2715
2713
  ws.join("TEAM.md"),
2716
- "---\nname: restartclaude046\nobjective: 0.4.6 contract.\nprovider: claude\n---\n\nteam.\n",
2714
+ "---\nname: restartcopilot046\nobjective: 0.4.6 contract.\nprovider: claude\n---\n\nteam.\n",
2717
2715
  )
2718
2716
  .unwrap();
2719
2717
  std::fs::write(
2720
2718
  ws.join("agents").join("alpha.md"),
2721
- "---\nname: alpha\nrole: Alpha\nprovider: claude\nmodel: sonnet\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlpha.\n",
2719
+ "---\nname: alpha\nrole: Alpha\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlpha.\n",
2722
2720
  )
2723
2721
  .unwrap();
2724
2722
  let spec = crate::compiler::compile_team(&ws).expect("compile");
@@ -2727,11 +2725,11 @@ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
2727
2725
  crate::state::persist::save_runtime_state(
2728
2726
  &ws,
2729
2727
  &json!({
2730
- "session_name": "team-restartclaude046",
2728
+ "session_name": "team-restartcopilot046",
2731
2729
  "agents": {
2732
2730
  "alpha": {
2733
2731
  "status": "running",
2734
- "provider": "claude",
2732
+ "provider": "copilot",
2735
2733
  "window": "alpha",
2736
2734
  "first_send_at": "2026-06-23T10:00:00+00:00",
2737
2735
  "session_id": stale_uuid,
@@ -2749,7 +2747,7 @@ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
2749
2747
  let result = restart_with_transport(&ws, true, None, &transport);
2750
2748
  assert!(
2751
2749
  matches!(result, Ok(RestartReport::Restarted { .. })),
2752
- "allow-fresh restart should fresh-spawn the claude worker; got {result:?}"
2750
+ "allow-fresh restart should fresh-spawn the copilot worker; got {result:?}"
2753
2751
  );
2754
2752
 
2755
2753
  let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
@@ -2757,7 +2755,7 @@ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
2757
2755
  assert_eq!(
2758
2756
  agent.get("session_id"),
2759
2757
  Some(&serde_json::Value::Null),
2760
- "0.4.6 contract: Claude fresh restart must clear stale session_id; agent={agent}"
2758
+ "0.4.6 contract: fresh restart must clear stale session_id; agent={agent}"
2761
2759
  );
2762
2760
  // C1 dual-projection: teams.<key>.agents.alpha.session_id must also be null.
2763
2761
  if let Some(teams) = state.get("teams").and_then(serde_json::Value::as_object) {
@@ -2,10 +2,9 @@ use std::collections::BTreeSet;
2
2
  use std::path::Path;
3
3
 
4
4
  use crate::lifecycle::launch::pi_mcp::{
5
- parse_pi_list_models_table, select_exact_pi_model, verify_started_pi_model,
5
+ build_pi_command_argv, parse_pi_list_models_table, select_exact_pi_model, PiCommandRequest,
6
6
  };
7
7
  use crate::model::enums::ProviderEffort;
8
- use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
9
8
 
10
9
  const CATALOG: &[u8] = include_bytes!("fixtures/pi_list_models_g0.stdout.txt");
11
10
  // Public pi --list-models rows captured for issue #186, preserving column widths.
@@ -87,13 +86,12 @@ fn argv_has_pair(argv: &[String], flag: &str, value: &str) -> bool {
87
86
 
88
87
  fn command_for_model(model: &str) -> Vec<String> {
89
88
  build_pi_command_argv(PiCommandRequest {
90
- extension: Path::new("/workspace/.team/runtime/pi/t1/w1/team-mcp.ts"),
89
+ extension: Path::new("/workspace/.team/runtime/pi/t1/leader/team-mcp.ts"),
91
90
  model: Some(model),
92
91
  effort: Some(ProviderEffort::Medium),
93
- system_prompt: "worker contract",
94
- session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/w1/sessions")),
95
- session: PiSessionSelector::Fresh,
96
- agent_id: "w1",
92
+ system_prompt: "leader contract",
93
+ session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/leader/sessions")),
94
+ agent_id: "leader",
97
95
  })
98
96
  .expect("catalog member must build a semantic Pi argv")
99
97
  }
@@ -134,7 +132,7 @@ fn pi_catalog_discovers_all_exact_ids_and_rejects_invalid_or_ambiguous_selection
134
132
  }
135
133
 
136
134
  #[test]
137
- fn pi_exact_catalog_id_is_forwarded_and_started_identity_must_match() {
135
+ fn pi_exact_catalog_id_is_forwarded_byte_for_byte() {
138
136
  let models = parse_pi_list_models_table(CATALOG).expect("frozen unfiltered table must parse");
139
137
  assert_eq!(models.len(), 221);
140
138
 
@@ -151,14 +149,4 @@ fn pi_exact_catalog_id_is_forwarded_and_started_identity_must_match() {
151
149
  "model selector must occur exactly once: {argv:?}"
152
150
  );
153
151
  }
154
-
155
- assert!(verify_started_pi_model("team-agent/qwen3.8-27b", "team-agent/qwen3.8-27b").is_ok());
156
- assert!(
157
- verify_started_pi_model("team-agent/qwen3.8-27b", "xai/grok-4.6").is_err(),
158
- "started identity mismatch must refuse rather than trust pane chrome"
159
- );
160
- assert!(
161
- verify_started_pi_model("team-agent/qwen3.8-27b", "").is_err(),
162
- "missing objective started-model evidence must not pass"
163
- );
164
152
  }
@@ -1,26 +1,26 @@
1
1
  use std::path::Path;
2
2
 
3
- use crate::lifecycle::launch::pi_mcp::{pi_leader_session_scope, PiSessionScope};
3
+ use crate::lifecycle::launch::pi_mcp::{
4
+ build_pi_command_argv, pi_leader_session_scope, PiCommandRequest, PiSessionScope,
5
+ };
4
6
  use crate::model::enums::ProviderEffort;
5
- use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
6
7
 
7
- fn request(session: PiSessionSelector<'static>) -> PiCommandRequest<'static> {
8
+ fn isolated_leader_request() -> PiCommandRequest<'static> {
8
9
  PiCommandRequest {
9
- extension: Path::new("/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts"),
10
+ extension: Path::new("/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts"),
10
11
  model: Some("team-agent/qwen3.8-27b"),
11
12
  effort: Some(ProviderEffort::High),
12
- system_prompt: "frozen worker prompt",
13
+ system_prompt: "frozen leader prompt",
13
14
  session_dir: Some(Path::new(
14
- "/workspace/.team/runtime/pi/team-a/worker-a/sessions",
15
+ "/workspace/.team/runtime/pi/team-a/leader/sessions",
15
16
  )),
16
- session,
17
- agent_id: "worker-a",
17
+ agent_id: "leader",
18
18
  }
19
19
  }
20
20
 
21
21
  #[test]
22
22
  fn pi_command_omits_unset_model_and_thinking_flags() {
23
- let mut request = request(PiSessionSelector::Fresh);
23
+ let mut request = isolated_leader_request();
24
24
  request.model = None;
25
25
  request.effort = None;
26
26
  let argv = build_pi_command_argv(request).expect("Pi provider defaults");
@@ -36,7 +36,6 @@ fn leader_request() -> PiCommandRequest<'static> {
36
36
  effort: None,
37
37
  system_prompt: "frozen leader prompt",
38
38
  session_dir: None,
39
- session: PiSessionSelector::Fresh,
40
39
  agent_id: "leader",
41
40
  }
42
41
  }
@@ -92,84 +91,67 @@ fn pi_leader_session_scope_keeps_explicit_and_external_routes_isolated() {
92
91
 
93
92
  #[test]
94
93
  fn pi_command_preserves_direct_pi_defaults_with_only_team_runtime_additions() {
95
- let fresh = build_pi_command_argv(request(PiSessionSelector::Fresh))
96
- .expect("fresh Pi command");
94
+ let fresh = build_pi_command_argv(isolated_leader_request()).expect("fresh Pi command");
97
95
  assert_eq!(
98
96
  fresh,
99
97
  [
100
98
  "pi",
101
99
  "-e",
102
- "/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
100
+ "/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts",
103
101
  "--model",
104
102
  "team-agent/qwen3.8-27b",
105
103
  "--thinking",
106
104
  "high",
107
105
  "--append-system-prompt",
108
- "frozen worker prompt",
106
+ "frozen leader prompt",
109
107
  "--session-dir",
110
- "/workspace/.team/runtime/pi/team-a/worker-a/sessions",
108
+ "/workspace/.team/runtime/pi/team-a/leader/sessions",
111
109
  "--name",
112
- "worker-a",
110
+ "leader",
113
111
  ]
114
112
  .map(str::to_string)
115
113
  );
116
114
 
117
- let resume = build_pi_command_argv(request(PiSessionSelector::Resume {
118
- path: Path::new(
119
- "/workspace/.team/runtime/pi/team-a/worker-a/sessions/2026/08/session.jsonl",
120
- ),
121
- }))
122
- .expect("resume Pi command");
123
- assert!(resume.windows(2).any(|pair| {
124
- pair == [
125
- "--session",
126
- "/workspace/.team/runtime/pi/team-a/worker-a/sessions/2026/08/session.jsonl",
127
- ]
128
- }));
129
- assert!(!resume.iter().any(|arg| arg == "--session-id"));
130
-
131
- for argv in [&fresh, &resume] {
132
- assert_eq!(argv.first().map(String::as_str), Some("pi"));
133
- for forbidden in [
134
- "rpc",
135
- "--mode",
136
- "--print",
137
- "-p",
138
- "-r",
139
- "--resume",
140
- "-c",
141
- "--continue",
142
- "--mcp-config",
143
- "--provider",
144
- "--fork",
145
- "--workspace",
146
- "--cwd",
147
- "--rules",
148
- "--always-approve",
149
- "--force",
150
- "--trust",
151
- "--sandbox",
152
- "--no-extensions",
153
- "--no-approve",
154
- "--no-context-files",
155
- "--no-skills",
156
- "--no-prompt-templates",
157
- "--tui-mode",
158
- "--tools",
159
- "--system-prompt",
160
- ] {
161
- assert!(
162
- !argv.iter().any(|arg| arg == forbidden),
163
- "materializer-owned Pi argv must not inherit {forbidden}: {argv:?}"
164
- );
165
- }
115
+ for forbidden in [
116
+ "rpc",
117
+ "--mode",
118
+ "--print",
119
+ "-p",
120
+ "-r",
121
+ "--resume",
122
+ "-c",
123
+ "--continue",
124
+ "--session",
125
+ "--session-id",
126
+ "--mcp-config",
127
+ "--provider",
128
+ "--fork",
129
+ "--workspace",
130
+ "--cwd",
131
+ "--rules",
132
+ "--always-approve",
133
+ "--force",
134
+ "--trust",
135
+ "--sandbox",
136
+ "--no-extensions",
137
+ "--no-approve",
138
+ "--no-context-files",
139
+ "--no-skills",
140
+ "--no-prompt-templates",
141
+ "--tui-mode",
142
+ "--tools",
143
+ "--system-prompt",
144
+ ] {
145
+ assert!(
146
+ !fresh.iter().any(|arg| arg == forbidden),
147
+ "materializer-owned Pi argv must not inherit {forbidden}: {fresh:?}"
148
+ );
166
149
  }
167
150
  }
168
151
 
169
152
  #[test]
170
153
  fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
171
- let argv = build_pi_command_argv(request(PiSessionSelector::Fresh))
172
- .expect("fresh Pi command");
154
+ let argv = build_pi_command_argv(isolated_leader_request()).expect("fresh Pi command");
173
155
 
174
156
  for forbidden in [
175
157
  "--no-context-files",
@@ -184,17 +166,17 @@ fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
184
166
  assert_eq!(
185
167
  argv.iter().filter(|arg| arg.as_str() == forbidden).count(),
186
168
  0,
187
- "TeamMate Pi must preserve the direct Pi default instead of adding {forbidden}; argv={argv:?}"
169
+ "Pi leader must preserve the direct Pi default instead of adding {forbidden}; argv={argv:?}"
188
170
  );
189
171
  }
190
172
  assert!(argv.windows(2).any(|pair| {
191
173
  pair == [
192
174
  "-e",
193
- "/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
175
+ "/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts",
194
176
  ]
195
177
  }));
196
178
  assert_eq!(argv.iter().filter(|arg| arg.as_str() == "-e").count(), 1);
197
179
  assert!(argv
198
180
  .windows(2)
199
- .any(|pair| pair == ["--append-system-prompt", "frozen worker prompt"]));
181
+ .any(|pair| pair == ["--append-system-prompt", "frozen leader prompt"]));
200
182
  }