@team-agent/installer 0.5.123 → 0.5.125

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 -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 -1
  7. package/crates/team-agent/src/cli/emit.rs +41 -15
  8. package/crates/team-agent/src/cli/intent/runtime.rs +30 -54
  9. package/crates/team-agent/src/cli/intent/runtime_tests.rs +59 -118
  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 +6 -5
  13. package/crates/team-agent/src/cli/models.rs +93 -128
  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/status_send.rs +17 -0
  22. package/crates/team-agent/src/compiler/tests.rs +21 -5
  23. package/crates/team-agent/src/compiler.rs +24 -1
  24. package/crates/team-agent/src/contract_runtime/backend.rs +30 -6
  25. package/crates/team-agent/src/contract_runtime/config.rs +34 -24
  26. package/crates/team-agent/src/contract_runtime/discovery.rs +79 -56
  27. package/crates/team-agent/src/contract_runtime/framework.rs +89 -34
  28. package/crates/team-agent/src/contract_runtime/registry.rs +299 -24
  29. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -1
  30. package/crates/team-agent/src/coordinator/tick.rs +89 -1
  31. package/crates/team-agent/src/db/message_store.rs +78 -3
  32. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -1
  33. package/crates/team-agent/src/leader/prompt.rs +1 -2
  34. package/crates/team-agent/src/leader/provider_attribution.rs +0 -52
  35. package/crates/team-agent/src/leader/start.rs +0 -1
  36. package/crates/team-agent/src/leader/tests/prompt_contract.rs +2 -3
  37. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +91 -0
  38. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +14 -1
  39. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -9
  40. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -1
  41. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +2 -2
  42. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +19 -101
  43. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -28
  44. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
  45. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
  46. package/crates/team-agent/src/lifecycle/launch.rs +2 -20
  47. package/crates/team-agent/src/lifecycle/profile_launch.rs +11 -39
  48. package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
  49. package/crates/team-agent/src/lifecycle/restart/common.rs +1 -63
  50. package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
  51. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +43 -13
  52. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +6 -2
  53. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +1 -3
  54. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +4 -16
  55. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +1 -3
  56. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +84 -53
  57. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +19 -1
  58. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +21 -0
  59. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
  60. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -137
  61. package/crates/team-agent/src/lifecycle/tests.rs +0 -3
  62. package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
  63. package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
  64. package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
  65. package/crates/team-agent/src/messaging/delivery.rs +186 -38
  66. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +4 -4
  67. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
  68. package/crates/team-agent/src/messaging/helpers.rs +19 -0
  69. package/crates/team-agent/src/messaging/tests/dup_inject.rs +66 -4
  70. package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
  71. package/crates/team-agent/src/messaging/tests/spine.rs +22 -6
  72. package/crates/team-agent/src/model/enums.rs +1 -8
  73. package/crates/team-agent/src/provider/adapter.rs +1 -67
  74. package/crates/team-agent/src/provider/adapters/mod.rs +0 -1
  75. package/crates/team-agent/src/provider/adapters/pi.rs +4 -4
  76. package/crates/team-agent/src/provider/argv_route.rs +1 -5
  77. package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
  78. package/crates/team-agent/src/provider/classify.rs +68 -3
  79. package/crates/team-agent/src/provider/faults.rs +1 -1
  80. package/crates/team-agent/src/provider/model_catalog.rs +2 -73
  81. package/crates/team-agent/src/provider/session/capture.rs +1 -1
  82. package/crates/team-agent/src/provider/session/context_fork.rs +4 -4
  83. package/crates/team-agent/src/provider/session_scan/common.rs +1 -2
  84. package/crates/team-agent/src/provider/session_scan/pi.rs +32 -19
  85. package/crates/team-agent/src/provider/session_scan.rs +0 -4
  86. package/crates/team-agent/src/provider/submit_now.rs +5 -28
  87. package/crates/team-agent/src/provider/tests/adapter.rs +5 -184
  88. package/crates/team-agent/src/provider/tests/classify.rs +53 -0
  89. package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -6
  90. package/crates/team-agent/src/provider/types.rs +1 -1
  91. package/crates/team-agent/src/provider/wire.rs +48 -8
  92. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
  93. package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
  94. package/crates/team-agent/src/tmux_backend.rs +43 -8
  95. package/crates/team-agent/src/transport/native_input.rs +2 -231
  96. package/npm/install.mjs +40 -3
  97. package/package.json +4 -4
  98. package/skills/team-agent/SKILL.md +1 -1
  99. package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
  100. package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
  101. package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
  102. package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
  103. package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
  104. package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
  105. package/crates/team-agent/src/provider/adapters/cursor_agent.rs +0 -44
  106. package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
  107. package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
@@ -3467,18 +3467,19 @@ pub mod lifecycle_port {
3467
3467
  ) -> Result<Value, CliError> {
3468
3468
  let agent_id = crate::model::ids::AgentId::new(agent);
3469
3469
  let source = (!role_file.is_empty()).then(|| Path::new(role_file));
3470
+ // A contract role is added by the same role transaction; its seat then
3471
+ // starts in the native framework (lifecycle::launch::add_agent).
3470
3472
  #[cfg(unix)]
3471
- {
3473
+ if !crate::contract_runtime::framework::declares_contract(
3474
+ source,
3475
+ role_config.provider.as_deref(),
3476
+ ) {
3472
3477
  crate::contract_runtime::framework::require_legacy_lifecycle(
3473
3478
  workspace,
3474
3479
  team,
3475
3480
  Some(agent),
3476
3481
  "add-agent",
3477
3482
  )?;
3478
- crate::contract_runtime::framework::require_legacy_role(
3479
- source,
3480
- role_config.provider.as_deref(),
3481
- )?;
3482
3483
  }
3483
3484
  match crate::lifecycle::role_config::add_agent_from_role(
3484
3485
  workspace,
@@ -14,17 +14,12 @@ const CATALOG_TIMEOUT: Duration = Duration::from_secs(10);
14
14
  const MAX_CATALOG_BYTES: u64 = 1024 * 1024;
15
15
  type ModelRecord = crate::provider::model_catalog::ModelRecord;
16
16
 
17
- #[cfg(test)]
18
- #[derive(Clone, Copy, Debug, Eq, PartialEq)]
19
- enum CatalogFormat {
20
- Pi,
21
- CursorAgent,
22
- }
23
-
24
17
  pub fn cmd_models(args: &ModelsArgs) -> Result<CmdResult, CliError> {
25
18
  #[cfg(unix)]
26
- if crate::contract_runtime::registry::descriptor(&args.provider).is_some() {
27
- return crate::contract_runtime::discovery::models(args);
19
+ if let Some(descriptor) = crate::contract_runtime::registry::declared(&args.provider, false) {
20
+ // A role's provider names its catalog: `agent` or `cursor-agent` is the Cursor leaf.
21
+ let args = ModelsArgs { provider: descriptor.identity.id.into(), ..args.clone() };
22
+ return crate::contract_runtime::discovery::models(&args);
28
23
  }
29
24
  let records = match crate::provider::model_catalog::discover_model_catalog(&args.provider) {
30
25
  Ok(records) => records,
@@ -107,80 +102,35 @@ fn render_catalog(args: &ModelsArgs, all: Vec<ModelRecord>) -> Result<CmdResult,
107
102
  }
108
103
  }
109
104
 
110
- /// Existing injectable Pi boundary retained for deterministic command/timeout tests.
111
105
  #[cfg(test)]
112
106
  fn cmd_models_with(
113
107
  args: &ModelsArgs,
114
108
  program: &Path,
115
109
  timeout: Duration,
116
110
  max_bytes: u64,
117
- ) -> Result<CmdResult, CliError> {
118
- cmd_models_with_format(args, program, CatalogFormat::Pi, timeout, max_bytes)
119
- }
120
-
121
- #[cfg(test)]
122
- fn cmd_models_with_format(
123
- args: &ModelsArgs,
124
- program: &Path,
125
- format: CatalogFormat,
126
- timeout: Duration,
127
- max_bytes: u64,
128
111
  ) -> Result<CmdResult, CliError> {
129
112
  let bytes = match run_catalog(program, timeout, max_bytes) {
130
113
  Ok(bytes) => bytes,
131
114
  Err(message) => return Ok(failure(args, &message)),
132
115
  };
133
- let all = match parse_catalog(&bytes, format) {
116
+ let all = match crate::provider::model_catalog::parse_pi_catalog(&bytes).map_err(|error| error.message("pi")) {
134
117
  Ok(models) => models,
135
118
  Err(message) => return Ok(failure(args, &message)),
136
119
  };
137
120
  render_catalog(args, all)
138
121
  }
139
122
 
140
- #[cfg(test)]
141
- fn parse_catalog(bytes: &[u8], format: CatalogFormat) -> Result<Vec<ModelRecord>, String> {
142
- let provider = match format {
143
- CatalogFormat::Pi => "pi",
144
- CatalogFormat::CursorAgent => "cursor_agent",
145
- };
146
- let result = match format {
147
- CatalogFormat::Pi => crate::provider::model_catalog::parse_pi_catalog(bytes),
148
- CatalogFormat::CursorAgent => crate::provider::model_catalog::parse_cursor_catalog(bytes),
149
- };
150
- result.map_err(|error| error.message(provider))
151
- }
152
-
153
- #[cfg(test)]
154
- fn parse_cursor_catalog(bytes: &[u8]) -> Result<Vec<ModelRecord>, String> {
155
- crate::provider::model_catalog::parse_cursor_catalog(bytes)
156
- .map_err(|error| error.message("cursor_agent"))
157
- }
158
-
159
123
  #[cfg(test)]
160
124
  fn model_matches(model: &ModelRecord, search: &str) -> bool {
161
125
  crate::provider::model_catalog::model_matches(model, search)
162
126
  }
163
127
 
164
- #[cfg(test)]
165
- fn current_model_for(format: CatalogFormat, models: &[ModelRecord]) -> Option<String> {
166
- match format {
167
- CatalogFormat::Pi => current_role_model(
168
- &models
169
- .iter()
170
- .map(|model| model.id.clone())
171
- .collect::<Vec<_>>(),
172
- ),
173
- CatalogFormat::CursorAgent => None,
174
- }
175
- }
176
-
177
128
  #[cfg(test)]
178
129
  fn failure(args: &ModelsArgs, message: &str) -> CmdResult {
179
130
  let action = if message.starts_with("unsupported model provider") {
180
- "choose a supported provider: pi, cursor_agent, codex, claude, or claude_code".to_string()
131
+ "choose a supported provider: pi, codex, claude, or claude_code".to_string()
181
132
  } else {
182
133
  let executable = match args.provider.as_str() {
183
- "cursor_agent" => "agent",
184
134
  "codex" => "codex",
185
135
  "claude" | "claude_code" => "claude",
186
136
  _ => "pi",
@@ -377,67 +327,6 @@ mod tests {
377
327
  assert_eq!(models[1]["role_model"], "team-agent/gpt-5.6-luna");
378
328
  }
379
329
 
380
- #[cfg(unix)]
381
- #[test]
382
- fn cursor_catalog_parses_copyable_ids_and_multiword_search() {
383
- let path = fixture(
384
- "printf 'Available models\\ngpt-5.6-luna-high - GPT-5.6 Luna 1M High\\ncursor-grok-4.6-high - Cursor Grok 4.6\\nauto - Auto (default)\\n'",
385
- );
386
- let result = cmd_models_with_format(
387
- &ModelsArgs {
388
- provider: "cursor_agent".into(),
389
- search: Some("GPT luna".into()),
390
- json: true,
391
- },
392
- &path,
393
- CatalogFormat::CursorAgent,
394
- Duration::from_secs(1),
395
- MAX_CATALOG_BYTES,
396
- )
397
- .unwrap();
398
- let CmdOutput::Human(text) = result.output else {
399
- panic!("expected JSON projection")
400
- };
401
- let value: Value = serde_json::from_str(&text).unwrap();
402
- assert_eq!(value["ok"], true);
403
- assert_eq!(value["provider"], "cursor_agent");
404
- assert_eq!(value["models"].as_array().unwrap().len(), 1);
405
- assert_eq!(value["models"][0]["role_model"], "gpt-5.6-luna-high");
406
- assert_eq!(value["models"][0]["model_id"], "gpt-5.6-luna-high");
407
- assert_eq!(value["models"][0]["display_name"], "GPT-5.6 Luna 1M High");
408
- assert_eq!(value["models"][0]["current"], Value::Null);
409
- cleanup_fixture(&path);
410
- }
411
-
412
- #[cfg(unix)]
413
- #[test]
414
- fn cursor_native_tip_fixture_works_through_public_cli_once() {
415
- let agent = native_cli_fixture(
416
- "agent",
417
- include_bytes!("../provider/testdata/cursor-list-models-native.stdout"),
418
- );
419
- let output = run_public_models_cli(
420
- &agent.program,
421
- agent.response.as_deref(),
422
- &["models", "--provider", "cursor_agent", "--json"],
423
- );
424
- let text = public_cli_text(&output);
425
- let calls =
426
- std::fs::read_to_string(agent.program.with_extension("count")).unwrap_or_default();
427
- drop(agent);
428
- assert!(output.status.success(), "{text}");
429
- assert_eq!(calls, "1:--list-models\n");
430
- let value: Value = serde_json::from_str(text.trim()).unwrap();
431
- assert_eq!(value["schema_version"], "models.v1");
432
- assert_eq!(value["provider"], "cursor_agent");
433
- let models = value["models"].as_array().unwrap();
434
- for exact in ["gpt-5.6-luna-low", "gpt-5.6-luna-xhigh"] {
435
- assert!(models.iter().any(|model| model["model_id"] == exact));
436
- }
437
- assert_eq!(models[0]["model_id"], "auto");
438
- assert_eq!(models[0]["default"], true);
439
- }
440
-
441
330
  #[cfg(unix)]
442
331
  #[test]
443
332
  fn cursor_contract_catalog_uses_public_launcher_metadata_then_exact_ids() {
@@ -450,7 +339,7 @@ case "$1" in
450
339
  esac"#);
451
340
  let mut cursor = CliFixture::new(program);
452
341
  let response = cursor.program.with_extension("stdout");
453
- std::fs::write(&response, include_bytes!("../provider/testdata/cursor-list-models-native.stdout")).unwrap();
342
+ std::fs::write(&response, include_bytes!("../../../team-agent-contract/tests/fixtures/cursor-2026.10.01-models.txt")).unwrap();
454
343
  cursor.response = Some(response);
455
344
  let output = run_public_models_cli(&cursor.program, cursor.response.as_deref(),
456
345
  &["models", "--provider", "cursor", "--search", "gpt-5.6-luna-xhigh", "--json"]);
@@ -468,6 +357,65 @@ esac"#);
468
357
  assert!(value["current_role_model"].is_null());
469
358
  }
470
359
 
360
+ #[cfg(unix)]
361
+ #[test]
362
+ fn grok_build_contract_catalog_runs_the_public_grok_found_on_path() {
363
+ let program = fixture_program("grok", r#"
364
+ test "$#" = 1 || exit 9
365
+ case "$1" in
366
+ --version) printf '%s\n' 'grok 1.0.52 (0920c8169e27)' ;;
367
+ models) exec /bin/cat "$TEAM_AGENT_MODELS_FIXTURE" ;;
368
+ *) exit 9 ;;
369
+ esac"#);
370
+ let mut grok = CliFixture::new(program);
371
+ let response = grok.program.with_extension("stdout");
372
+ std::fs::write(&response, include_bytes!("../provider/testdata/grok-models-authenticated.stdout")).unwrap();
373
+ grok.response = Some(response);
374
+ let output = run_public_models_cli(&grok.program, grok.response.as_deref(),
375
+ &["models", "--provider", "grok_build", "--json"]);
376
+ let text = public_cli_text(&output);
377
+ let calls = std::fs::read_to_string(grok.program.with_extension("count")).unwrap_or_default();
378
+ assert!(output.status.success(), "{text}");
379
+ // Whatever `grok` PATH selects answers every probe; no install path is assumed.
380
+ assert_eq!(calls, "1:--version\n1:models\n");
381
+ let value: Value = serde_json::from_str(text.trim()).unwrap();
382
+ assert_eq!(value["provider"], "grok_build");
383
+ assert_eq!(value["source"]["executable"], grok.program.to_str().unwrap());
384
+ assert!(value["models"].as_array().unwrap().iter().any(|row| row["model_id"] == "grok-4.7-build-fast"));
385
+ }
386
+
387
+ #[cfg(unix)]
388
+ #[test]
389
+ fn every_cursor_provider_name_reads_the_contract_catalog_through_cursor_agent() {
390
+ use std::os::unix::fs::PermissionsExt;
391
+ for name in ["cursor_agent", "cursor-agent", "agent"] {
392
+ let mut cursor = CliFixture::new(fixture_program("cursor-agent", r#"
393
+ test "$#" = 1 || exit 9
394
+ case "$1" in
395
+ --version) printf '%s\n' '2026.10.01-a1b2c3' ;;
396
+ --list-models) exec /bin/cat "$TEAM_AGENT_MODELS_FIXTURE" ;;
397
+ *) exit 9 ;;
398
+ esac"#));
399
+ let response = cursor.program.with_extension("stdout");
400
+ std::fs::write(&response, include_bytes!("../../../team-agent-contract/tests/fixtures/cursor-2026.10.01-models.txt")).unwrap();
401
+ cursor.response = Some(response);
402
+ // The legacy binary name on PATH is never what runs.
403
+ let legacy = cursor.program.parent().unwrap().join("agent");
404
+ std::fs::write(&legacy, "#!/bin/sh\nprintf 'called' > \"$0.called\"\nexit 9\n").unwrap();
405
+ std::fs::set_permissions(&legacy, std::fs::Permissions::from_mode(0o700)).unwrap();
406
+ let output = run_public_models_cli(&cursor.program, cursor.response.as_deref(),
407
+ &["models", "--provider", name, "--json"]);
408
+ let text = public_cli_text(&output);
409
+ assert!(output.status.success(), "{name}: {text}");
410
+ assert_eq!(std::fs::read_to_string(cursor.program.with_extension("count")).unwrap(),
411
+ "1:--version\n1:--list-models\n", "{name}");
412
+ assert!(!legacy.with_extension("called").exists(), "{name}");
413
+ let value: Value = serde_json::from_str(text.trim()).unwrap();
414
+ assert_eq!(value["provider"], "cursor", "{name}");
415
+ assert!(value["models"].as_array().unwrap().iter().any(|row| row["model_id"] == "gpt-5.6-luna-xhigh"), "{name}");
416
+ }
417
+ }
418
+
471
419
  #[cfg(unix)]
472
420
  #[test]
473
421
  fn cursor_contract_bad_version_has_no_legacy_entrypoint_fallback() {
@@ -694,7 +642,6 @@ esac"#);
694
642
 
695
643
  #[cfg(unix)]
696
644
  fn fixture_program(program: &str, body: &str) -> std::path::PathBuf {
697
- use std::os::unix::fs::PermissionsExt;
698
645
  let sequence = FIXTURE_SEQUENCE.fetch_add(1, Ordering::Relaxed);
699
646
  let root = std::env::current_exe()
700
647
  .unwrap()
@@ -710,17 +657,35 @@ esac"#);
710
657
  ));
711
658
  std::fs::create_dir(&root).unwrap();
712
659
  let path = root.join(program);
713
- std::fs::write(
660
+ install_executable(
714
661
  &path,
715
- format!("#!/bin/sh\nprintf '%s\\n' \"$#:$1\" >> \"$0.count\"\n{body}\n"),
716
- )
717
- .unwrap();
718
- let mut permissions = std::fs::metadata(&path).unwrap().permissions();
719
- permissions.set_mode(0o700);
720
- std::fs::set_permissions(&path, permissions).unwrap();
662
+ &format!("#!/bin/sh\nprintf '%s\\n' \"$#:$1\" >> \"$0.count\"\n{body}\n"),
663
+ );
721
664
  path
722
665
  }
723
666
 
667
+ /// Linux refuses to exec an inode still open for writing anywhere (ETXTBSY),
668
+ /// and a parallel test's fork can briefly inherit our write fd. Only a
669
+ /// short-lived `cp` ever writes the executable, so no test thread holds it.
670
+ #[cfg(unix)]
671
+ fn install_executable(path: &Path, script: &str) {
672
+ use std::os::unix::fs::PermissionsExt;
673
+ let staged = path.with_extension("staged");
674
+ std::fs::write(&staged, script).unwrap();
675
+ let copied = std::process::Command::new("/bin/cp")
676
+ .arg(&staged)
677
+ .arg(path)
678
+ .status()
679
+ .unwrap();
680
+ assert!(
681
+ copied.success(),
682
+ "install fixture executable {}",
683
+ path.display()
684
+ );
685
+ std::fs::remove_file(&staged).unwrap();
686
+ std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o700)).unwrap();
687
+ }
688
+
724
689
  #[cfg(unix)]
725
690
  struct CliFixture {
726
691
  program: std::path::PathBuf,
@@ -800,7 +765,7 @@ esac"#);
800
765
  let script = format!(
801
766
  "#!/bin/sh\nprintf '1\\n' > \"$0.entered\" || :\n{script}body_status=$?\nprintf '1\\n' > \"$0.completed\" || :\nexit \"$body_status\"\n"
802
767
  );
803
- std::fs::write(&path, script).unwrap();
768
+ install_executable(&path, &script);
804
769
  path
805
770
  }
806
771
 
@@ -1373,7 +1338,7 @@ esac"#);
1373
1338
  ),
1374
1339
  ExitCode::Error
1375
1340
  );
1376
- let usage = "team-agent models [--provider pi|cursor|cursor_agent|codex|claude|claude_code|grok|kiro] [QUERY|--search TEXT] [--json]";
1341
+ let usage = "team-agent models [--provider pi|cursor|codex|claude|claude_code|grok|kiro] [QUERY|--search TEXT] [--json]";
1377
1342
  assert_eq!(crate::cli::spec::command_spec("models").unwrap().usage, usage);
1378
1343
  assert!(crate::cli::emit::command_help(Some("models")).contains(usage));
1379
1344
  }
@@ -5,7 +5,7 @@ use crate::provider::argv_route::{self, Config, Mutation, Override, RouteError};
5
5
  use crate::provider::Provider;
6
6
  use serde_json::{json, Value};
7
7
 
8
- pub(crate) const HELP: &str = "Purpose:\nConfigure additional provider launch arguments. Disabled by default.\nUsage: team-agent route [status|enable|disable|show [TOOL]|set TOOL -- ARG...|add TOOL -- ARG...|clear TOOL] [--json]\n\nOptions:\nstatus reports the switch; enable/disable change it; show lists all or one provider's arguments.\nset replaces arguments; add appends; clear removes a provider's arguments. Use --json for structured output.\nTOOL is a supported provider name, such as pi/codex/claude/copilot/grok/cursor_agent.\nEverything after the first -- is a literal provider argument, including --help and --json.\nConfiguration: ~/.team-agent/argv-routing.json. This is host-global, not isolated by workspace or team.\nTEAM_AGENT_CLI_ARGV_ROUTING overrides the persisted switch.\nExamples:\nteam-agent route status\nteam-agent route set pi -- --mode text\nteam-agent route enable\n\nNext Action:\nVerify arguments with route show pi. Changes apply to the next launch, not an existing session.\nWithout an enabled configuration, providers retain their original arguments. Leave routing disabled unless the arguments are understood.";
8
+ pub(crate) const HELP: &str = "Purpose:\nConfigure additional provider launch arguments. Disabled by default.\nUsage: team-agent route [status|enable|disable|show [TOOL]|set TOOL -- ARG...|add TOOL -- ARG...|clear TOOL] [--json]\n\nOptions:\nstatus reports the switch; enable/disable change it; show lists all or one provider's arguments.\nset replaces arguments; add appends; clear removes a provider's arguments. Use --json for structured output.\nTOOL is a supported provider name, such as pi/codex/claude/copilot/grok.\nEverything after the first -- is a literal provider argument, including --help and --json.\nConfiguration: ~/.team-agent/argv-routing.json. This is host-global, not isolated by workspace or team.\nTEAM_AGENT_CLI_ARGV_ROUTING overrides the persisted switch.\nExamples:\nteam-agent route status\nteam-agent route set pi -- --mode text\nteam-agent route enable\n\nNext Action:\nVerify arguments with route show pi. Changes apply to the next launch, not an existing session.\nWithout an enabled configuration, providers retain their original arguments. Leave routing disabled unless the arguments are understood.";
9
9
 
10
10
  struct Request {
11
11
  operation: String,
@@ -56,10 +56,46 @@ pub(super) fn persist_resolved_target(
56
56
  };
57
57
  let outcome = messaging::send_message(&selected.run_workspace, target, content, &opts)?;
58
58
  let mut value = delivery_outcome_json(&outcome, target, content, &opts);
59
+ attach_mcp_handshake_wait(&mut value, &selected, target, &outcome);
59
60
  append_loud_ensure_fields(&mut value, coordinator_ensure.as_ref());
60
61
  Ok(value)
61
62
  }
62
63
 
64
+ /// #372: name the readiness gate a queued worker message is waiting on.
65
+ /// Observation only; the coordinator owns retry, parking, and notice.
66
+ pub(super) fn attach_mcp_handshake_wait(
67
+ value: &mut Value,
68
+ selected: &crate::state::selector::SelectedTeam,
69
+ target: &MessageTarget,
70
+ outcome: &DeliveryOutcome,
71
+ ) {
72
+ #[cfg(unix)]
73
+ if let (MessageTarget::Single(agent), DeliveryStatus::Queued, Some(object)) =
74
+ (target, outcome.status, value.as_object_mut())
75
+ {
76
+ // A contract seat's MCP binding is the framework's own; the legacy
77
+ // handshake gate does not apply and must not report a wait.
78
+ let contract = selected
79
+ .state
80
+ .get("agents")
81
+ .and_then(|agents| agents.get(agent.as_str()))
82
+ .is_some_and(crate::contract_runtime::framework::is_contract);
83
+ if contract {
84
+ return;
85
+ }
86
+ if let Err(reason) = crate::mcp_server::readiness::preflight(
87
+ &selected.run_workspace,
88
+ Some(selected.team_key.as_str()),
89
+ agent,
90
+ &selected.state,
91
+ ) {
92
+ object.insert("deferred_reason".to_string(), json!(reason));
93
+ }
94
+ }
95
+ #[cfg(not(unix))]
96
+ let _ = (value, selected, target, outcome);
97
+ }
98
+
63
99
  pub(super) fn routing_ambiguous_value(
64
100
  workspace: &Path,
65
101
  args: &SendArgs,
@@ -232,7 +232,13 @@ pub(super) fn send_human_output(value: &Value) -> String {
232
232
  if value.get("delivered").and_then(Value::as_bool) == Some(true) {
233
233
  format!("Delivered to {agent}. {}", crate::cli::SEND_REMINDER)
234
234
  } else {
235
- "Task accepted, but delivery to the agent's conversation is still pending.\nNext: check team-agent status or team-agent doctor --workspace .; wait for an actual reply without repeated sends.".to_string()
235
+ let waiting = value
236
+ .get("deferred_reason")
237
+ .and_then(Value::as_str)
238
+ .filter(|reason| reason.starts_with("mcp_handshake_"))
239
+ .map(|reason| format!(": {agent}'s MCP server has not completed its handshake ({reason}); after 5 minutes the message is parked and the leader is notified"))
240
+ .unwrap_or_default();
241
+ format!("Task accepted, but delivery to the agent's conversation is still pending{waiting}.\nNext: check team-agent status or team-agent doctor --workspace .; wait for an actual reply without repeated sends.")
236
242
  }
237
243
  }
238
244
 
@@ -17,7 +17,8 @@ use coordinator::{
17
17
  };
18
18
  pub use persist::send_options_from_args;
19
19
  use persist::{
20
- initial_delivery_allows_watch, observe_initial_delivery_for_watch, routing_ambiguous_value,
20
+ attach_mcp_handshake_wait, initial_delivery_allows_watch, observe_initial_delivery_for_watch,
21
+ routing_ambiguous_value,
21
22
  };
22
23
  use presentation::{
23
24
  add_send_reminder_if_ok, attach_positional_typo_suggestions, cmd_send_result,
@@ -123,6 +124,7 @@ pub fn cmd_send(args: &SendArgs) -> Result<CmdResult, CliError> {
123
124
  outcome = observe_initial_delivery_for_watch(&selected, &target, &outcome, &opts)?;
124
125
  }
125
126
  let mut value = delivery_outcome_json(&outcome, &target, &content, &opts);
127
+ attach_mcp_handshake_wait(&mut value, &selected, &target, &outcome);
126
128
  // 0.5.45 naming-addressing (design §3.5, RED-2/RED-3 positional):
127
129
  // when the refusal reason is `target_not_in_team` AND the target
128
130
  // was a Single non-special short id, attach scope-safe
@@ -125,7 +125,7 @@ pub(crate) const COMMAND_SPECS: &[CommandSpec] = &[
125
125
  CommandSpec { name: "quick-start", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::Dispatch(DispatchKind::QuickStart), summary: "Compatibility creation bridge; prefer start for daily activation", usage: "team-agent quick-start [TEAMDIR] [--workspace WORKSPACE] [--team TEAM] [--name NAME] [--team-id TEAM] [--yes] [--backend tmux|conpty] [--json] [--detail]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::Conditional, sunset: None, action: None, governance: None },
126
126
  CommandSpec { name: "send", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::Dispatch(DispatchKind::Send), summary: "Send a task to a specified agent", usage: "team-agent send <agent> MESSAGE... [--workspace WORKSPACE] [--team TEAM] [--mailbox] [--json]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::Conditional, sunset: Some("a future compatibility release"), action: Some("Use team-agent send <agent> 'task message'; select scope with --workspace and --team"), governance: None },
127
127
  CommandSpec { name: "status", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::Dispatch(DispatchKind::Status), summary: "Check agent status without reading conversation content", usage: "team-agent status [<agent>] [--workspace WORKSPACE] [--team TEAM] [--json] [--summary|--detail]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::No, sunset: None, action: None, governance: None },
128
- CommandSpec { name: "models", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::Dispatch(DispatchKind::Models), summary: "Discover model names supported by the native provider", usage: "team-agent models [--provider pi|cursor|cursor_agent|codex|claude|claude_code|grok|kiro] [QUERY|--search TEXT] [--json]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::No, sunset: None, action: None, governance: None },
128
+ CommandSpec { name: "models", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::Dispatch(DispatchKind::Models), summary: "Discover model names supported by the native provider", usage: "team-agent models [--provider pi|cursor|codex|claude|claude_code|grok|kiro] [QUERY|--search TEXT] [--json]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::No, sunset: None, action: None, governance: None },
129
129
  CommandSpec { name: "inbox", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::Dispatch(DispatchKind::Inbox), summary: "Read agent replies", usage: "team-agent inbox <agent> [-n N|--limit N] [--workspace WORKSPACE] [--team TEAM] [--json]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::No, sunset: None, action: None, governance: None },
130
130
  CommandSpec { name: "restart", tier: CommandTier::Core, category: CommandCategory::TeamLifecycle, kind: CommandKind::Dispatch(DispatchKind::Restart), summary: "Restart one agent, or use the frozen bare/path team bridge", usage: "team-agent restart [AGENT|./WORKSPACE] [--workspace WORKSPACE] [--team TEAM] [--session auto|preserve] [--dry-run] [--allow-fresh] [--session-converge-deadline SECONDS] [--json] [--detail]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::Conditional, sunset: None, action: None, governance: None },
131
131
  CommandSpec { name: "shutdown", tier: CommandTier::Core, category: CommandCategory::TeamLifecycle, kind: CommandKind::Dispatch(DispatchKind::Shutdown), summary: "Compatibility: shut down the selected team; prefer stop", usage: "team-agent shutdown [--workspace WORKSPACE] [--team TEAM] [--keep-logs] [--json]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::No, sunset: None, action: None, governance: None },
@@ -152,7 +152,6 @@ pub(crate) const COMMAND_SPECS: &[CommandSpec] = &[
152
152
  CommandSpec { name: "claude", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::LeaderPassthrough { provider: "claude" }, summary: "Open a leader session with Claude Code", usage: "team-agent claude [--attach-existing] [--confirm] [--attach-session SESSION] [--external-leader] [--allow-nested-attach] [--json] [-- TOOL_ARGS...]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::Conditional, sunset: None, action: None, governance: None },
153
153
  CommandSpec { name: "copilot", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::LeaderPassthrough { provider: "copilot" }, summary: "Open a leader session with Copilot", usage: "team-agent copilot [--attach-existing] [--confirm] [--attach-session SESSION] [--external-leader] [--allow-nested-attach] [--json] [-- TOOL_ARGS...]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::Conditional, sunset: None, action: None, governance: None },
154
154
  CommandSpec { name: "grok", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::LeaderPassthrough { provider: "grok" }, summary: "Open a leader session with Grok", usage: "team-agent grok [--attach-existing] [--confirm] [--attach-session SESSION] [--external-leader] [--allow-nested-attach] [--json] [-- TOOL_ARGS...]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::Conditional, sunset: None, action: None, governance: None },
155
- CommandSpec { name: "cursor", tier: CommandTier::Core, category: CommandCategory::Start, kind: CommandKind::LeaderPassthrough { provider: "cursor_agent" }, summary: "Open a leader session with Cursor agent", usage: "team-agent cursor [--attach-existing] [--confirm] [--attach-session SESSION] [--external-leader] [--allow-nested-attach] [--json] [-- TOOL_ARGS...]", default_help: true, command_help: true, suggestion_index: true, token_usage: TokenUsage::Conditional, sunset: None, action: None, governance: None },
156
155
  ];
157
156
 
158
157
  pub(crate) fn command_spec(name: &str) -> Option<&'static CommandSpec> {
@@ -89,6 +89,7 @@ struct RegisteredNode {
89
89
  window: Option<String>,
90
90
  pane: Option<String>,
91
91
  lifecycle: Option<String>,
92
+ claude_registry: Option<(std::path::PathBuf, String)>,
92
93
  }
93
94
 
94
95
  #[derive(Clone, Debug, PartialEq, Eq)]
@@ -534,6 +535,7 @@ fn registered_node(name: &str, value: &Value, state: &Value) -> RegisteredNode {
534
535
  .or_else(|| first_string(display, &["pane_id"]))
535
536
  .or_else(|| first_string(target, &["pane_id"])),
536
537
  lifecycle: string_at(value, &["status"]).map(|status| status.to_ascii_lowercase()),
538
+ claude_registry: crate::provider::claude_registry_key(value),
537
539
  }
538
540
  }
539
541
 
@@ -1325,6 +1327,8 @@ fn project_node_with_attach(
1325
1327
  let native_tmux = observed.evidence_method.as_deref() == Some("native_tmux");
1326
1328
  let activity = if observed.provider.eq_ignore_ascii_case("pi") && !pi_channel && !native_tmux {
1327
1329
  "unknown"
1330
+ } else if native_tmux && claude_node(node) {
1331
+ claude_registry_activity(node)
1328
1332
  } else {
1329
1333
  valid_activity(&observed.activity)
1330
1334
  };
@@ -1395,6 +1399,24 @@ fn matches_registered(node: &RegisteredNode, observed: &ProbeNode) -> bool {
1395
1399
  && node.pane.as_deref() == Some(observed.pane.as_str())
1396
1400
  }
1397
1401
 
1402
+ fn claude_node(node: &RegisteredNode) -> bool {
1403
+ crate::provider::wire::parse_provider(&node.provider)
1404
+ .is_some_and(crate::provider::wire::is_claude_family)
1405
+ }
1406
+
1407
+ /// #379: a live Claude pane always runs the Claude process, so its command
1408
+ /// name says nothing about the turn; Claude's own session registry does.
1409
+ fn claude_registry_activity(node: &RegisteredNode) -> &'static str {
1410
+ let state = node.claude_registry.as_ref().and_then(|(sessions, session_id)| {
1411
+ crate::provider::claude_registry_turn_state(sessions, session_id, node.pane.as_deref())
1412
+ });
1413
+ match state {
1414
+ Some(crate::provider::TurnState::Working) => "working",
1415
+ Some(crate::provider::TurnState::Idle) => "idle",
1416
+ _ => "unknown",
1417
+ }
1418
+ }
1419
+
1398
1420
  fn valid_activity(value: &str) -> &str {
1399
1421
  match value {
1400
1422
  "working" | "idle" => value,
@@ -1506,6 +1528,7 @@ mod native_ps_batch_regressions {
1506
1528
  window: Some("w".into()),
1507
1529
  pane: Some(pane.into()),
1508
1530
  lifecycle: None,
1531
+ claude_registry: None,
1509
1532
  }
1510
1533
  }
1511
1534
 
@@ -1770,6 +1793,7 @@ mod tests {
1770
1793
  window: Some("win".to_string()),
1771
1794
  pane: Some("%7".to_string()),
1772
1795
  lifecycle: None,
1796
+ claude_registry: None,
1773
1797
  }
1774
1798
  }
1775
1799
 
@@ -1878,6 +1902,48 @@ mod tests {
1878
1902
  );
1879
1903
  }
1880
1904
 
1905
+ // #379: a live Claude pane always runs Claude; its registry names the turn.
1906
+ #[cfg(unix)]
1907
+ #[test]
1908
+ fn issue379_claude_activity_comes_from_its_session_registry_not_the_pane_command() {
1909
+ let config = std::env::temp_dir().join(format!("ta-379-brief-{}", std::process::id()));
1910
+ let _ = std::fs::remove_dir_all(&config);
1911
+ let sid = "33333333-4444-4555-8666-777777777777";
1912
+ let projects = config.join("projects").join("-owned-cwd");
1913
+ std::fs::create_dir_all(&projects).unwrap();
1914
+ std::fs::create_dir_all(config.join("sessions")).unwrap();
1915
+ let rollout = projects.join(format!("{sid}.jsonl"));
1916
+ std::fs::write(&rollout, "").unwrap();
1917
+ let record = config.join("sessions").join(format!("{}.json", std::process::id()));
1918
+ let mut node = registered();
1919
+ node.provider = "claude".to_string();
1920
+ node.claude_registry = crate::provider::claude_registry_key(&json!({"rollout_path": rollout}));
1921
+ let mut observed = probe("native_tmux");
1922
+ observed.provider = "claude".to_string();
1923
+ observed.activity = "working".to_string();
1924
+ let sample = Some(ProbeResult { nodes: vec![observed], ..Default::default() });
1925
+ for (status, expected) in [("busy", "working"), ("idle", "idle"), ("waiting", "unknown")] {
1926
+ let body = json!({"pid": std::process::id(), "sessionId": sid, "tmux": "sess:@1.%7", "status": status});
1927
+ std::fs::write(&record, body.to_string()).unwrap();
1928
+ assert_eq!(project_node(&node, Some(&sample)).activity, expected, "{status}");
1929
+ }
1930
+ // Cold start: the ready prompt before any transcript is captured.
1931
+ let body = json!({"pid": std::process::id(), "sessionId": sid, "tmux": "sess:@1.%7", "status": "idle"});
1932
+ std::fs::write(&record, body.to_string()).unwrap();
1933
+ let cold = registered_node(
1934
+ "worker",
1935
+ &json!({"provider": "claude", "_pending_session_id": sid, "claude_projects_root": config.join("projects")}),
1936
+ &json!({}),
1937
+ );
1938
+ node.claude_registry = cold.claude_registry;
1939
+ assert_eq!(project_node(&node, Some(&sample)).activity, "idle");
1940
+ std::fs::remove_file(&record).unwrap();
1941
+ let projected = project_node(&node, Some(&sample));
1942
+ assert_eq!(projected.activity, "unknown", "the process name is not a turn state");
1943
+ assert_eq!(projected.observation_reason, Some("activity_or_health_not_observed"));
1944
+ let _ = std::fs::remove_dir_all(&config);
1945
+ }
1946
+
1881
1947
  #[test]
1882
1948
  fn stopped_registration_is_retained_without_sample() {
1883
1949
  let mut node = registered();
@@ -730,7 +730,7 @@ fn cmd_leader_passthrough_help_is_pure_human_guidance() {
730
730
  let env = crate::cli::hermetic_test_support::HermeticTestEnv::enter("launcher-help-unit");
731
731
  let cwd = env.workspace("empty");
732
732
  let tools = [
733
- "pi", "codex", "claude", "copilot", "grok", "agent", "cursor",
733
+ "pi", "codex", "claude", "copilot", "grok",
734
734
  ];
735
735
  let bin = env.root().join("canaries");
736
736
  std::fs::create_dir(&bin).unwrap();
@@ -744,7 +744,7 @@ fn cmd_leader_passthrough_help_is_pure_human_guidance() {
744
744
  }
745
745
  env.with_env("PATH", &bin.to_string_lossy())
746
746
  };
747
- for provider in ["pi", "codex", "claude", "copilot", "grok", "cursor"] {
747
+ for provider in ["pi", "codex", "claude", "copilot", "grok"] {
748
748
  for alias in ["-h", "--help"] {
749
749
  let result = cmd_leader_passthrough(provider, &[alias.into()], &cwd).unwrap();
750
750
  assert_eq!(result.exit, ExitCode::Ok);
@@ -780,19 +780,12 @@ fn cmd_leader_passthrough_maps_copilot_provider() {
780
780
  }
781
781
 
782
782
  #[test]
783
- fn cmd_leader_passthrough_maps_grok_and_cursor_not_claude() {
783
+ fn cmd_leader_passthrough_maps_grok_and_rejects_retired_cursor_names() {
784
784
  assert_eq!(
785
785
  leader_passthrough_provider("grok"),
786
786
  Some(crate::model::enums::Provider::Grok)
787
787
  );
788
- assert_eq!(
789
- leader_passthrough_provider("cursor"),
790
- Some(crate::model::enums::Provider::CursorAgent)
791
- );
792
- assert_ne!(
793
- leader_passthrough_provider("cursor"),
794
- Some(crate::model::enums::Provider::ClaudeCode)
795
- );
788
+ assert_eq!(leader_passthrough_provider("cursor"), None);
796
789
  assert_eq!(leader_passthrough_provider("agent"), None);
797
790
  assert_eq!(leader_passthrough_provider("cursor_agent"), None);
798
791
  assert_eq!(leader_passthrough_provider("not-a-passthrough"), None);
@@ -705,6 +705,23 @@ fn cmd_send_default_human_output_is_brief_without_false_delivered() {
705
705
  }
706
706
  }
707
707
 
708
+ #[test]
709
+ #[cfg(unix)]
710
+ fn issue372_queued_send_names_the_mcp_handshake_it_waits_on() {
711
+ let r = cmd_send(&queued_send_args_fixture(true)).expect("cmd_send returns CmdResult");
712
+ let CmdOutput::Json(v) = r.output else {
713
+ panic!("--json send must emit Json");
714
+ };
715
+ assert_eq!(v["deferred_reason"], json!("mcp_handshake_config_missing"), "{v}");
716
+ let r = cmd_send(&queued_send_args_fixture(false)).expect("cmd_send returns CmdResult");
717
+ let text = emit(&r.output, r.as_json).expect("send should render human text");
718
+ assert!(
719
+ text.contains("w1's MCP server has not completed its handshake (mcp_handshake_config_missing)")
720
+ && text.contains("after 5 minutes the message is parked"),
721
+ "{text}"
722
+ );
723
+ }
724
+
708
725
  #[test]
709
726
  fn cmd_send_json_shape_keeps_056_fields() {
710
727
  let args = queued_send_args_fixture(true);