@team-agent/installer 0.5.127 → 0.5.128

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 (145) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/README.md +11 -0
  4. package/crates/team-agent/src/cli/adapters.rs +3 -13
  5. package/crates/team-agent/src/cli/arguments.rs +4 -0
  6. package/crates/team-agent/src/cli/diagnose.rs +68 -22
  7. package/crates/team-agent/src/cli/emit.rs +58 -26
  8. package/crates/team-agent/src/cli/intent/runtime.rs +32 -5
  9. package/crates/team-agent/src/cli/intent/runtime_tests.rs +102 -11
  10. package/crates/team-agent/src/cli/intent/tests.rs +10 -12
  11. package/crates/team-agent/src/cli/intent.rs +1 -1
  12. package/crates/team-agent/src/cli/mod.rs +25 -8
  13. package/crates/team-agent/src/cli/models.rs +764 -7
  14. package/crates/team-agent/src/cli/schedule.rs +175 -0
  15. package/crates/team-agent/src/cli/send/persist.rs +0 -36
  16. package/crates/team-agent/src/cli/send/presentation.rs +1 -1
  17. package/crates/team-agent/src/cli/send.rs +108 -110
  18. package/crates/team-agent/src/cli/spec.rs +6 -0
  19. package/crates/team-agent/src/cli/status_port/brief.rs +5 -67
  20. package/crates/team-agent/src/cli/tests/leader_watch.rs +12 -62
  21. package/crates/team-agent/src/cli/tests/mod.rs +1 -1
  22. package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
  23. package/crates/team-agent/src/cli/tests/run_delegation.rs +9 -6
  24. package/crates/team-agent/src/cli/tests/status_send.rs +68 -271
  25. package/crates/team-agent/src/compiler/tests.rs +3 -18
  26. package/crates/team-agent/src/compiler.rs +205 -6
  27. package/crates/team-agent/src/contract_runtime/backend.rs +145 -11
  28. package/crates/team-agent/src/contract_runtime/commands.rs +7 -7
  29. package/crates/team-agent/src/contract_runtime/config.rs +26 -16
  30. package/crates/team-agent/src/contract_runtime/config_tests.rs +24 -4
  31. package/crates/team-agent/src/contract_runtime/discovery.rs +12 -1
  32. package/crates/team-agent/src/contract_runtime/fork.rs +3 -10
  33. package/crates/team-agent/src/contract_runtime/framework.rs +28 -11
  34. package/crates/team-agent/src/contract_runtime/mcp.rs +19 -24
  35. package/crates/team-agent/src/contract_runtime/prompt.rs +2 -2
  36. package/crates/team-agent/src/contract_runtime/registry.rs +56 -92
  37. package/crates/team-agent/src/coordinator/steps/abnormal.rs +11 -11
  38. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +16 -54
  39. package/crates/team-agent/src/coordinator/tests/health_sync.rs +42 -0
  40. package/crates/team-agent/src/coordinator/tick.rs +1 -89
  41. package/crates/team-agent/src/db/message_store.rs +7 -65
  42. package/crates/team-agent/src/direct_delivery.rs +368 -0
  43. package/crates/team-agent/src/inbox_store.rs +169 -0
  44. package/crates/team-agent/src/leader/registry.rs +5 -0
  45. package/crates/team-agent/src/leader/start.rs +2 -1
  46. package/crates/team-agent/src/leader/tests/lease_api.rs +2 -2
  47. package/crates/team-agent/src/leader/tests/prompt_contract.rs +1 -0
  48. package/crates/team-agent/src/lib.rs +2 -0
  49. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +33 -0
  50. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +206 -1
  51. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +28 -2
  52. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +38 -13
  53. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
  54. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +9 -1
  55. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +351 -81
  56. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +3 -4
  57. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +24 -0
  58. package/crates/team-agent/src/lifecycle/launch/spawn.rs +36 -13
  59. package/crates/team-agent/src/lifecycle/launch.rs +24 -1
  60. package/crates/team-agent/src/lifecycle/profile_launch.rs +321 -11
  61. package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -0
  62. package/crates/team-agent/src/lifecycle/restart/avatar.rs +1798 -0
  63. package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +163 -0
  64. package/crates/team-agent/src/lifecycle/restart/common.rs +345 -35
  65. package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
  66. package/crates/team-agent/src/lifecycle/restart.rs +4 -0
  67. package/crates/team-agent/src/lifecycle/role_config.rs +39 -14
  68. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +325 -0
  69. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +320 -8
  70. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +236 -13
  71. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +378 -4
  72. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +5 -4
  73. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
  74. package/crates/team-agent/src/lifecycle/tests/core.rs +47 -18
  75. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +2 -1
  76. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +14 -14
  77. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
  78. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +28 -26
  79. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
  80. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +18 -6
  81. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +70 -52
  82. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +210 -0
  83. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +157 -4
  84. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +526 -10
  85. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1419 -0
  86. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +68 -1
  87. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +34 -12
  88. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +94 -2
  89. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +10 -11
  90. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
  91. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +254 -2
  92. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
  93. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +5 -6
  94. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +16 -7
  95. package/crates/team-agent/src/lifecycle/tests.rs +3 -0
  96. package/crates/team-agent/src/lifecycle/types.rs +18 -2
  97. package/crates/team-agent/src/lifecycle/worker_command_context.rs +43 -50
  98. package/crates/team-agent/src/mcp_server/readiness.rs +130 -149
  99. package/crates/team-agent/src/mcp_server/readiness_tests.rs +98 -119
  100. package/crates/team-agent/src/mcp_server/tests/scoped.rs +21 -31
  101. package/crates/team-agent/src/mcp_server/tests/send.rs +72 -107
  102. package/crates/team-agent/src/mcp_server/tests/tools.rs +10 -12
  103. package/crates/team-agent/src/mcp_server/tools.rs +70 -196
  104. package/crates/team-agent/src/messaging/delivery.rs +160 -218
  105. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
  106. package/crates/team-agent/src/messaging/helpers.rs +1 -19
  107. package/crates/team-agent/src/messaging/mod.rs +1 -0
  108. package/crates/team-agent/src/messaging/reminders.rs +316 -0
  109. package/crates/team-agent/src/messaging/scheduler.rs +7 -1
  110. package/crates/team-agent/src/messaging/tests/dup_inject.rs +191 -85
  111. package/crates/team-agent/src/messaging/tests/runtime.rs +4 -110
  112. package/crates/team-agent/src/messaging/tests/spine.rs +40 -24
  113. package/crates/team-agent/src/messaging/types.rs +1 -0
  114. package/crates/team-agent/src/provider/adapter.rs +303 -51
  115. package/crates/team-agent/src/provider/adapters/claude.rs +78 -0
  116. package/crates/team-agent/src/provider/adapters/claude_fork.rs +131 -0
  117. package/crates/team-agent/src/provider/adapters/mod.rs +7 -5
  118. package/crates/team-agent/src/provider/adapters/pi.rs +106 -0
  119. package/crates/team-agent/src/provider/classify.rs +1 -66
  120. package/crates/team-agent/src/provider/model_catalog.rs +201 -13
  121. package/crates/team-agent/src/provider/session/capture.rs +106 -6
  122. package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
  123. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +4 -0
  124. package/crates/team-agent/src/provider/session/context_fork.rs +150 -18
  125. package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
  126. package/crates/team-agent/src/provider/session_scan/common.rs +44 -8
  127. package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
  128. package/crates/team-agent/src/provider/session_scan.rs +16 -6
  129. package/crates/team-agent/src/provider/tests/adapter.rs +104 -17
  130. package/crates/team-agent/src/provider/tests/classify.rs +0 -53
  131. package/crates/team-agent/src/provider/tests/command_helpers.rs +12 -3
  132. package/crates/team-agent/src/provider/tests/idle.rs +37 -0
  133. package/crates/team-agent/src/provider/wire.rs +22 -34
  134. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
  135. package/crates/team-agent/src/state/persist.rs +6 -6
  136. package/crates/team-agent/src/state/projection.rs +1 -1
  137. package/crates/team-agent/src/state/repository/tests.rs +2 -2
  138. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +144 -0
  139. package/crates/team-agent/src/tmux_backend/tests.rs +0 -151
  140. package/crates/team-agent/src/tmux_backend.rs +5 -40
  141. package/package.json +4 -4
  142. package/skills/team-agent/SKILL.md +5 -7
  143. package/skills/team-agent/command-coverage.json +1 -1
  144. package/skills/team-agent/docs/reference/team-agent-operator.md +3 -3
  145. package/skills/team-agent/references/team-agent-operator.md +3 -3
@@ -2,15 +2,23 @@
2
2
  use super::{CliError, CmdOutput, CmdResult, ExitCode, ModelsArgs};
3
3
  use serde_json::{json, Value};
4
4
  #[cfg(test)]
5
+ use std::collections::BTreeMap;
6
+ #[cfg(test)]
5
7
  use std::path::Path;
8
+ #[cfg(test)]
9
+ use std::time::Duration;
10
+
11
+ #[cfg(test)]
12
+ const CATALOG_TIMEOUT: Duration = Duration::from_secs(10);
13
+ #[cfg(test)]
14
+ const MAX_CATALOG_BYTES: u64 = 1024 * 1024;
6
15
  type ModelRecord = crate::provider::model_catalog::ModelRecord;
7
16
 
8
17
  pub fn cmd_models(args: &ModelsArgs) -> Result<CmdResult, CliError> {
9
18
  #[cfg(unix)]
10
19
  if let Some(descriptor) = crate::contract_runtime::registry::declared(&args.provider) {
11
20
  // A role's provider names its catalog: `agent` or `cursor-agent` is the
12
- // Cursor leaf; `claude`/`claude_code`, `codex`, `grok` and `pi` are the
13
- // Claude Code, Codex, Grok Build and Pi leaves.
21
+ // Cursor leaf; `codex` and `grok` are the Codex and Grok Build leaves.
14
22
  let args = ModelsArgs { provider: descriptor.identity.id.into(), ..args.clone() };
15
23
  return crate::contract_runtime::discovery::models(&args);
16
24
  }
@@ -35,9 +43,14 @@ fn render_catalog(args: &ModelsArgs, all: Vec<ModelRecord>) -> Result<CmdResult,
35
43
  .collect()
36
44
  },
37
45
  );
46
+ let current = if args.provider == "pi" {
47
+ current_role_model(&all.iter().map(|model| model.id.clone()).collect::<Vec<_>>())
48
+ } else {
49
+ None
50
+ };
38
51
  let entries: Vec<Value> = visible.iter().map(|model| json!({
39
52
  "role_model": model.id,
40
- "current": Value::Null,
53
+ "current": if args.provider == "pi" { json!(current.as_deref() == Some(model.id.as_str())) } else { Value::Null },
41
54
  "provider": model.provider,
42
55
  "vendor": model.vendor,
43
56
  "model_id": model.id,
@@ -48,7 +61,7 @@ fn render_catalog(args: &ModelsArgs, all: Vec<ModelRecord>) -> Result<CmdResult,
48
61
  let provider = args.provider.as_str();
49
62
  let value = json!({
50
63
  "schema_version": "models.v1", "ok": true, "provider": provider, "models": entries,
51
- "auth": "ok", "auth_basis": "catalog_visibility", "current_role_model": Value::Null, "search": args.search,
64
+ "auth": "ok", "auth_basis": "catalog_visibility", "current_role_model": current, "search": args.search,
52
65
  });
53
66
  if args.json {
54
67
  Ok(CmdResult {
@@ -69,7 +82,11 @@ fn render_catalog(args: &ModelsArgs, all: Vec<ModelRecord>) -> Result<CmdResult,
69
82
  model.vendor,
70
83
  model.id,
71
84
  model.display_name,
72
- "—",
85
+ if args.provider == "pi" {
86
+ (current.as_deref() == Some(model.id.as_str())).to_string()
87
+ } else {
88
+ "—".to_string()
89
+ },
73
90
  model
74
91
  .default
75
92
  .map_or_else(|| "—".to_string(), |value| value.to_string()),
@@ -86,6 +103,44 @@ fn render_catalog(args: &ModelsArgs, all: Vec<ModelRecord>) -> Result<CmdResult,
86
103
  }
87
104
  }
88
105
 
106
+ #[cfg(test)]
107
+ fn cmd_models_with(
108
+ args: &ModelsArgs,
109
+ program: &Path,
110
+ timeout: Duration,
111
+ max_bytes: u64,
112
+ ) -> Result<CmdResult, CliError> {
113
+ let bytes = match run_catalog(program, timeout, max_bytes) {
114
+ Ok(bytes) => bytes,
115
+ Err(message) => return Ok(failure(args, &message)),
116
+ };
117
+ let all = match crate::provider::model_catalog::parse_pi_catalog(&bytes).map_err(|error| error.message("pi")) {
118
+ Ok(models) => models,
119
+ Err(message) => return Ok(failure(args, &message)),
120
+ };
121
+ render_catalog(args, all)
122
+ }
123
+
124
+ #[cfg(test)]
125
+ fn model_matches(model: &ModelRecord, search: &str) -> bool {
126
+ crate::provider::model_catalog::model_matches(model, search)
127
+ }
128
+
129
+ #[cfg(test)]
130
+ fn failure(args: &ModelsArgs, message: &str) -> CmdResult {
131
+ let action = if message.starts_with("unsupported model provider") {
132
+ "choose a supported provider: pi, codex, claude, or claude_code".to_string()
133
+ } else {
134
+ let executable = match args.provider.as_str() {
135
+ "codex" => "codex",
136
+ "claude" | "claude_code" => "claude",
137
+ _ => "pi",
138
+ };
139
+ format!("install or repair the PATH-first `{executable}` executable, then retry `team-agent models --provider {}`", args.provider)
140
+ };
141
+ failure_with_action(args, message, &action)
142
+ }
143
+
89
144
  fn failure_with_action(args: &ModelsArgs, message: &str, action: &str) -> CmdResult {
90
145
  let value = json!({ "schema_version": "models.v1", "ok": false, "provider": args.provider, "auth": "not_ready", "auth_basis": "catalog_visibility", "models": Value::Array(Vec::new()), "current_role_model": Value::Null, "error": message, "action": action });
91
146
  if args.json {
@@ -101,11 +156,39 @@ fn failure_with_action(args: &ModelsArgs, message: &str, action: &str) -> CmdRes
101
156
  CmdResult { output: CmdOutput::Human(format!("models.v1 | error: {message}\naction: {action}\nauth: not_ready (catalog_visibility)")), exit: ExitCode::Error, as_json: false, preserve_json_order: false }
102
157
  }
103
158
  }
159
+ fn current_role_model(models: &[String]) -> Option<String> {
160
+ current_role_model_from(
161
+ models,
162
+ std::env::var("PI_PROVIDER").ok().as_deref(),
163
+ std::env::var("PI_MODEL").ok().as_deref(),
164
+ )
165
+ }
166
+ fn current_role_model_from(
167
+ models: &[String],
168
+ provider: Option<&str>,
169
+ model: Option<&str>,
170
+ ) -> Option<String> {
171
+ let exact = format!("{}/{}", provider?, model?);
172
+ models
173
+ .iter()
174
+ .any(|candidate| candidate == &exact)
175
+ .then_some(exact)
176
+ }
177
+
178
+ /// Injectable executable, deadline, and byte-limit boundary for deterministic tests.
179
+ #[cfg(test)]
180
+ fn run_catalog(program: &Path, timeout: Duration, max_bytes: u64) -> Result<Vec<u8>, String> {
181
+ crate::lifecycle::launch::pi_mcp::run_pi_catalog(program, timeout, max_bytes)
182
+ }
183
+
104
184
  #[cfg(test)]
105
185
  mod tests {
106
186
  use super::*;
107
187
  #[cfg(unix)]
188
+ use std::io::Write;
189
+ #[cfg(unix)]
108
190
  use std::sync::atomic::{AtomicU64, Ordering};
191
+ use std::time::Instant;
109
192
 
110
193
  #[cfg(unix)]
111
194
  static FIXTURE_SEQUENCE: AtomicU64 = AtomicU64::new(0);
@@ -125,6 +208,126 @@ mod tests {
125
208
  std::process::exit(exit.code());
126
209
  }
127
210
 
211
+ #[cfg(unix)]
212
+ #[test]
213
+ fn real_dispatcher_isolated_success_json_human_and_no_match() {
214
+ let pi = fixture("printf 'provider model\\nopenai-codex gpt-5.6-sol\\n'");
215
+ let dir = pi.parent().unwrap().to_path_buf();
216
+ let run_child = |args: &[&str], model: &str| {
217
+ std::process::Command::new(std::env::current_exe().unwrap())
218
+ .args([
219
+ "--exact",
220
+ "cli::models::tests::real_dispatcher_child_helper",
221
+ "--nocapture",
222
+ ])
223
+ .env("TEAM_AGENT_MODELS_CHILD", "1")
224
+ .env(
225
+ "TEAM_AGENT_MODELS_ARGS",
226
+ serde_json::to_string(args).unwrap(),
227
+ )
228
+ .env("PATH", &dir)
229
+ .env("PI_PROVIDER", "openai-codex")
230
+ .env("PI_MODEL", model)
231
+ .output()
232
+ .unwrap()
233
+ };
234
+ let json = run_child(&["models", "--provider", "pi", "--json"], "gpt-5.6-sol");
235
+ assert!(json.status.success());
236
+ let output = String::from_utf8(json.stdout).unwrap();
237
+ let cli_output = output
238
+ .split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
239
+ .nth(1)
240
+ .unwrap();
241
+ let value: Value = serde_json::from_str(cli_output.trim()).unwrap();
242
+ assert_eq!(value["schema_version"], "models.v1");
243
+ assert_eq!(value["models"][0]["role_model"], "openai-codex/gpt-5.6-sol");
244
+ assert_eq!(value["models"][0]["current"], true);
245
+ let human = run_child(
246
+ &["models", "--provider", "pi", "--search", "absent"],
247
+ "missing",
248
+ );
249
+ assert!(human.status.success());
250
+ let human_output = String::from_utf8(human.stdout).unwrap();
251
+ let text = human_output
252
+ .split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
253
+ .nth(1)
254
+ .unwrap();
255
+ assert!(text.contains("No models matched --search") && text.contains("auth: ok"));
256
+ let null = run_child(&["models", "--provider", "pi", "--json"], "missing");
257
+ let null_output = String::from_utf8(null.stdout).unwrap();
258
+ let null_cli = null_output
259
+ .split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
260
+ .nth(1)
261
+ .unwrap();
262
+ let null_value: Value = serde_json::from_str(null_cli.trim()).unwrap();
263
+ assert!(null.status.success() && null_value["current_role_model"].is_null());
264
+ std::fs::write(&pi, "#!/bin/sh\nprintf 'sensitive-stderr' >&2\nexit 7\n").unwrap();
265
+ let failed = run_child(&["models", "--provider", "pi", "--json"], "missing");
266
+ assert!(!failed.status.success());
267
+ let failed_output = String::from_utf8(failed.stdout).unwrap();
268
+ let failed_cli = failed_output
269
+ .split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
270
+ .nth(1)
271
+ .unwrap();
272
+ assert!(!failed_cli.contains("sensitive-stderr"));
273
+ assert_eq!(
274
+ std::fs::read_to_string(pi.with_extension("count"))
275
+ .unwrap()
276
+ .lines()
277
+ .count(),
278
+ 3
279
+ );
280
+ cleanup_fixture(&pi);
281
+ }
282
+
283
+ #[test]
284
+ fn current_model_is_deterministic() {
285
+ let models = vec!["openai-codex/gpt-5.6-sol".into()];
286
+ assert_eq!(
287
+ current_role_model_from(&models, Some("openai-codex"), Some("gpt-5.6-sol")),
288
+ Some("openai-codex/gpt-5.6-sol".into())
289
+ );
290
+ assert_eq!(
291
+ current_role_model_from(&models, Some("openai-codex"), Some("other")),
292
+ None
293
+ );
294
+ assert_eq!(
295
+ current_role_model_from(&models, None, Some("gpt-5.6-sol")),
296
+ None
297
+ );
298
+ }
299
+
300
+ #[cfg(unix)]
301
+ #[test]
302
+ fn search_survives_unrelated_spaced_model_ids() {
303
+ let catalog =
304
+ include_str!("../lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt");
305
+ let path = fixture(&format!("printf '%s' '{catalog}'"));
306
+ let result = cmd_models_with(
307
+ &ModelsArgs {
308
+ provider: "pi".into(),
309
+ search: Some("gpt-5.6-luna".into()),
310
+ json: true,
311
+ },
312
+ &path,
313
+ Duration::from_secs(10),
314
+ MAX_CATALOG_BYTES,
315
+ )
316
+ .unwrap();
317
+ cleanup_fixture(&path);
318
+ assert_eq!(result.exit, ExitCode::Ok);
319
+ let CmdOutput::Human(text) = result.output else {
320
+ panic!("expected JSON projection")
321
+ };
322
+ let value: Value = serde_json::from_str(&text).unwrap();
323
+ assert_eq!(value["ok"], true);
324
+ assert_eq!(value["auth"], "ok");
325
+ let models = value["models"].as_array().unwrap();
326
+ assert_eq!(models.len(), 2);
327
+ assert_eq!(models[0]["role_model"], "openai-codex/gpt-5.6-luna");
328
+ assert_eq!(models[1]["role_model"], "team-agent/gpt-5.6-luna");
329
+ }
330
+
128
331
  #[cfg(unix)]
129
332
  #[test]
130
333
  fn cursor_contract_catalog_uses_public_launcher_metadata_then_exact_ids() {
@@ -288,6 +491,11 @@ esac"#));
288
491
  );
289
492
  }
290
493
 
494
+ #[cfg(unix)]
495
+ fn fixture(body: &str) -> std::path::PathBuf {
496
+ fixture_program("pi", body)
497
+ }
498
+
291
499
  #[cfg(unix)]
292
500
  fn fixture_program(program: &str, body: &str) -> std::path::PathBuf {
293
501
  let sequence = FIXTURE_SEQUENCE.fetch_add(1, Ordering::Relaxed);
@@ -395,19 +603,568 @@ esac"#));
395
603
  .to_string()
396
604
  }
397
605
 
606
+ #[cfg(unix)]
607
+ fn fixture_with_sidecars(body: &str) -> std::path::PathBuf {
608
+ let path = fixture(body);
609
+ let script = std::fs::read_to_string(&path).unwrap();
610
+ let script = script.strip_prefix("#!/bin/sh\n").unwrap();
611
+ let script = format!(
612
+ "#!/bin/sh\nprintf '1\\n' > \"$0.entered\" || :\n{script}body_status=$?\nprintf '1\\n' > \"$0.completed\" || :\nexit \"$body_status\"\n"
613
+ );
614
+ install_executable(&path, &script);
615
+ path
616
+ }
617
+
398
618
  #[cfg(unix)]
399
619
  fn cleanup_fixture(path: &Path) {
400
620
  let _ = std::fs::remove_dir_all(path.parent().unwrap());
401
621
  }
402
622
 
623
+ #[cfg(unix)]
624
+ fn native_timeout_fixture() -> std::path::PathBuf {
625
+ let path = std::path::PathBuf::from(env!("TEAM_AGENT_MODELS_TIMEOUT_FIXTURE"));
626
+ assert!(path.is_file(), "prebuilt models timeout fixture is missing");
627
+ path
628
+ }
629
+
630
+ #[cfg(unix)]
631
+ fn native_timeout_receipt() -> std::path::PathBuf {
632
+ let stamp = std::time::SystemTime::now()
633
+ .duration_since(std::time::UNIX_EPOCH)
634
+ .unwrap()
635
+ .as_nanos();
636
+ std::path::PathBuf::from("/tmp").join(format!(
637
+ "team-agent-models-timeout-{}-{stamp}.receipt",
638
+ std::process::id()
639
+ ))
640
+ }
641
+
642
+ #[cfg(unix)]
643
+ fn native_timeout_stage_receipt(receipt: &Path) -> std::path::PathBuf {
644
+ receipt.with_extension("stage")
645
+ }
646
+
647
+ #[cfg(unix)]
648
+ fn parse_native_timeout_receipt(path: &Path) -> Option<BTreeMap<String, String>> {
649
+ let mut fields = BTreeMap::new();
650
+ for line in std::fs::read_to_string(path).ok()?.lines() {
651
+ let (key, value) = line.split_once('=')?;
652
+ if fields.insert(key.to_string(), value.to_string()).is_some() {
653
+ return None;
654
+ }
655
+ }
656
+ let keys = fields.keys().map(String::as_str).collect::<Vec<_>>();
657
+ (keys
658
+ == vec![
659
+ "child_argv_exact",
660
+ "child_pid",
661
+ "child_spawn_attempts",
662
+ "descendant_pid",
663
+ "descendant_started",
664
+ "descendant_stdout_inherited",
665
+ "parent_argv_exact",
666
+ "parent_pid",
667
+ "parent_started_once",
668
+ ])
669
+ .then_some(fields)
670
+ }
671
+
672
+ #[cfg(unix)]
673
+ fn wait_native_timeout_receipt(path: &Path) -> BTreeMap<String, String> {
674
+ let deadline = Instant::now() + Duration::from_millis(500);
675
+ loop {
676
+ if let Some(fields) = parse_native_timeout_receipt(path) {
677
+ return fields;
678
+ }
679
+ if Instant::now() >= deadline {
680
+ panic!("native timeout receipt did not become complete after runner return");
681
+ }
682
+ std::thread::sleep(Duration::from_millis(1));
683
+ }
684
+ }
685
+
686
+ #[cfg(unix)]
687
+ fn with_native_mode<T>(
688
+ mode: &str,
689
+ action: impl FnOnce() -> T,
690
+ ) -> (
691
+ T,
692
+ crate::lifecycle::launch::pi_mcp::PiCatalogTestObservation,
693
+ ) {
694
+ let receipt = native_timeout_receipt();
695
+ assert!(!receipt.exists());
696
+ let result = crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
697
+ &receipt,
698
+ Some(mode),
699
+ action,
700
+ );
701
+ assert!(!receipt.exists());
702
+ let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
703
+ result
704
+ }
705
+
706
+ #[cfg(unix)]
707
+ fn safe_fixture_sidecar(path: &Path, expected: &str) -> &'static str {
708
+ match std::fs::read_to_string(path) {
709
+ Ok(text) if text == expected => "present_expected",
710
+ Ok(_) => "present_unexpected",
711
+ Err(error) if error.kind() == std::io::ErrorKind::NotFound => "missing",
712
+ Err(_) => "unavailable",
713
+ }
714
+ }
715
+
716
+ #[cfg(unix)]
717
+ fn safe_runner_fixture_observation(path: &Path) -> String {
718
+ format!(
719
+ "fixture_entered={} fixture_completed={} fixture_count={}",
720
+ safe_fixture_sidecar(&path.with_extension("entered"), "1\n"),
721
+ safe_fixture_sidecar(&path.with_extension("completed"), "1\n"),
722
+ safe_fixture_sidecar(&path.with_extension("count"), "1:--list-models\n"),
723
+ )
724
+ }
725
+
726
+ #[cfg(unix)]
727
+ fn safe_runner_observation(
728
+ elapsed: Duration,
729
+ observation: &crate::lifecycle::launch::pi_mcp::PiCatalogTestObservation,
730
+ ) -> String {
731
+ format!(
732
+ "elapsed_ms={} spawn_count={} argv={:?} parent_pid={:?} parent_exit_success={:?} parent_exit_code={:?} reader_timeout={}",
733
+ elapsed.as_millis(),
734
+ observation.spawn_count,
735
+ observation.argv,
736
+ observation.parent_pid,
737
+ observation.parent_exit_success,
738
+ observation.parent_exit_code,
739
+ observation.reader_timeout,
740
+ )
741
+ }
742
+
743
+ #[cfg(unix)]
744
+ fn safe_models_result_class(result: &CmdResult) -> &'static str {
745
+ let CmdOutput::Human(text) = &result.output else {
746
+ return "non_human_output";
747
+ };
748
+ let Ok(value) = serde_json::from_str::<Value>(text) else {
749
+ return "non_json_output";
750
+ };
751
+ match value.get("ok").and_then(Value::as_bool) {
752
+ Some(true) => "success_json",
753
+ Some(false) => match value.get("error").and_then(Value::as_str) {
754
+ Some(error) if error.contains("unavailable") => "runner_unavailable",
755
+ Some(error) if error.contains("timed out") => "runner_timeout",
756
+ Some(error) if error.contains("command failed") => "runner_exit",
757
+ Some(error) if error.contains("could not be read") => "reader_error",
758
+ Some(error) if error.contains("exceeds") => "reader_oversize",
759
+ Some(error) if error.contains("catalog") => "parser_catalog_error",
760
+ Some(_) => "failure_json",
761
+ None => "failure_json_missing_error",
762
+ },
763
+ None => "json_missing_ok",
764
+ }
765
+ }
766
+
767
+ #[cfg(unix)]
768
+ fn safe_models_observation(
769
+ elapsed: Duration,
770
+ result: &CmdResult,
771
+ observation: &crate::lifecycle::launch::pi_mcp::PiCatalogTestObservation,
772
+ ) -> String {
773
+ format!(
774
+ "class={} elapsed_ms={} parent_pid={:?} parent_exit_success={:?} parent_exit_code={:?} reader_timeout={}",
775
+ safe_models_result_class(result),
776
+ elapsed.as_millis(),
777
+ observation.parent_pid,
778
+ observation.parent_exit_success,
779
+ observation.parent_exit_code,
780
+ observation.reader_timeout,
781
+ )
782
+ }
783
+
784
+ #[cfg(unix)]
785
+ #[test]
786
+ fn runner_invokes_exact_argv_once_and_drains() {
787
+ let path = fixture_with_sidecars(
788
+ "test \"$1\" = --list-models && echo provider model && echo openai-codex gpt-5.6-sol",
789
+ );
790
+ let receipt = native_timeout_receipt();
791
+ assert!(!receipt.exists());
792
+ let started = Instant::now();
793
+ let (result, observation) =
794
+ crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
795
+ &receipt,
796
+ None,
797
+ || run_catalog(&path, Duration::from_secs(1), 1024),
798
+ );
799
+ let elapsed = started.elapsed();
800
+ let fixture_observation = safe_runner_fixture_observation(&path);
801
+ assert!(
802
+ result
803
+ .as_ref()
804
+ .is_ok_and(|bytes| bytes.starts_with(b"provider model")),
805
+ "runner observation: {}; {}",
806
+ safe_runner_observation(elapsed, &observation),
807
+ fixture_observation
808
+ );
809
+ let _ = result.unwrap();
810
+ let _ = std::fs::remove_file(&receipt);
811
+ let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
812
+ assert_eq!(
813
+ std::fs::read_to_string(path.with_extension("count")).unwrap(),
814
+ "1:--list-models\n"
815
+ );
816
+ cleanup_fixture(&path);
817
+ }
818
+
819
+ #[cfg(unix)]
820
+ const NATIVE_STAGE_KEYS: [&str; 5] = [
821
+ "parent_entry_ms",
822
+ "parent_before_child_spawn_ms",
823
+ "parent_after_child_spawn_ms",
824
+ "parent_before_exit_ms",
825
+ "test_spawn_return_ms",
826
+ ];
827
+
828
+ #[cfg(unix)]
829
+ // Match the native helper's UNIX epoch millisecond clock exactly.
830
+ fn append_native_stage(path: &Path, key: &str) {
831
+ if !NATIVE_STAGE_KEYS.contains(&key) {
832
+ return;
833
+ }
834
+ let Some(milliseconds) = std::time::SystemTime::now()
835
+ .duration_since(std::time::UNIX_EPOCH)
836
+ .ok()
837
+ .map(|duration| duration.as_millis())
838
+ else {
839
+ return;
840
+ };
841
+ let Ok(mut file) = std::fs::OpenOptions::new()
842
+ .create(true)
843
+ .append(true)
844
+ .open(path)
845
+ else {
846
+ return;
847
+ };
848
+ let _ = writeln!(file, "{key}={milliseconds}");
849
+ }
850
+
851
+ #[cfg(unix)]
852
+ fn safe_native_stage(path: &Path) -> String {
853
+ let (read_state, text) = match std::fs::read_to_string(path) {
854
+ Ok(text) => ("ok", Some(text)),
855
+ Err(error) if error.kind() == std::io::ErrorKind::NotFound => ("missing", None),
856
+ Err(_) => ("unavailable", None),
857
+ };
858
+ let mut fields = BTreeMap::new();
859
+ if let Some(ref text) = text {
860
+ for line in text.lines() {
861
+ let Some((key, value)) = line.split_once('=') else {
862
+ continue;
863
+ };
864
+ if NATIVE_STAGE_KEYS.contains(&key)
865
+ && value.len() <= 20
866
+ && value.bytes().all(|byte| byte.is_ascii_digit())
867
+ {
868
+ fields.entry(key).or_insert(value);
869
+ }
870
+ }
871
+ }
872
+ let field = |key: &str| fields.get(key).copied().unwrap_or("unknown");
873
+ format!(
874
+ "stage_read={read_state} parent_entry_ms={} parent_before_child_spawn_ms={} parent_after_child_spawn_ms={} parent_before_exit_ms={} test_spawn_return_ms={}",
875
+ field("parent_entry_ms"),
876
+ field("parent_before_child_spawn_ms"),
877
+ field("parent_after_child_spawn_ms"),
878
+ field("parent_before_exit_ms"),
879
+ field("test_spawn_return_ms"),
880
+ )
881
+ }
882
+
883
+ #[cfg(unix)]
884
+ fn wait_for_native_parent_exit(
885
+ child: &mut std::process::Child,
886
+ stage: &Path,
887
+ ) -> std::process::ExitStatus {
888
+ let deadline = Instant::now() + Duration::from_millis(500);
889
+ loop {
890
+ match child.try_wait() {
891
+ Ok(Some(status)) => return status,
892
+ Ok(None) if Instant::now() < deadline => {
893
+ std::thread::sleep(Duration::from_millis(1));
894
+ }
895
+ Ok(None) => {
896
+ let before_kill = safe_native_stage(stage);
897
+ let _ = child.kill();
898
+ let _ = child.wait();
899
+ let after_wait = safe_native_stage(stage);
900
+ panic!(
901
+ "native parent did not exit before test setup deadline; stage_before_kill={before_kill}; stage_after_wait={after_wait}"
902
+ );
903
+ }
904
+ Err(_) => {
905
+ let before_kill = safe_native_stage(stage);
906
+ let _ = child.kill();
907
+ let _ = child.wait();
908
+ let after_wait = safe_native_stage(stage);
909
+ panic!(
910
+ "native parent status could not be observed; stage_before_kill={before_kill}; stage_after_wait={after_wait}"
911
+ );
912
+ }
913
+ }
914
+ }
915
+ }
916
+
917
+ /// Read/drain seam only: public `run_catalog` spawn coverage remains in the
918
+ /// normal success and fail-closed tests.
919
+ #[cfg(unix)]
920
+ #[test]
921
+ fn reader_deadline_is_bounded_after_parent_exit_with_descendant_pipe() {
922
+ let path = native_timeout_fixture();
923
+ let receipt = native_timeout_receipt();
924
+ let stage = native_timeout_stage_receipt(&receipt);
925
+ assert!(!receipt.exists());
926
+ assert!(!stage.exists());
927
+ let mut parent = std::process::Command::new(&path)
928
+ .arg("--list-models")
929
+ .env("TEAM_AGENT_MODELS_TIMEOUT_RECEIPT", &receipt)
930
+ .env("TEAM_AGENT_MODELS_TIMEOUT_STAGE_RECEIPT", &stage)
931
+ .env("TEAM_AGENT_MODELS_TIMEOUT_MODE", "descendant")
932
+ .stdin(std::process::Stdio::null())
933
+ .stdout(std::process::Stdio::piped())
934
+ .stderr(std::process::Stdio::null())
935
+ .spawn()
936
+ .unwrap();
937
+ append_native_stage(&stage, "test_spawn_return_ms");
938
+ let parent_pid = parent.id();
939
+ let parent_status = wait_for_native_parent_exit(&mut parent, &stage);
940
+ let stdout = parent.stdout.take().expect("native parent stdout pipe");
941
+ let started = Instant::now();
942
+ let (result, observation) =
943
+ crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
944
+ &receipt,
945
+ Some("descendant"),
946
+ || {
947
+ crate::lifecycle::launch::pi_mcp::run_pi_catalog_after_parent_exit_for_test(
948
+ stdout,
949
+ parent_pid,
950
+ parent_status,
951
+ Duration::from_millis(40),
952
+ 1024,
953
+ )
954
+ },
955
+ );
956
+ let elapsed = started.elapsed();
957
+ assert!(
958
+ elapsed < Duration::from_millis(500),
959
+ "runner observation: {}",
960
+ safe_runner_observation(elapsed, &observation)
961
+ );
962
+ assert!(result.unwrap_err().contains("timed out"));
963
+ assert_eq!(
964
+ observation.parent_exit_success,
965
+ Some(true),
966
+ "runner observation: {}",
967
+ safe_runner_observation(elapsed, &observation)
968
+ );
969
+ assert_eq!(observation.parent_exit_code, Some(0));
970
+ assert!(observation.reader_timeout);
971
+
972
+ let fields = wait_native_timeout_receipt(&receipt);
973
+ assert_eq!(fields["parent_started_once"], "1");
974
+ assert_eq!(fields["parent_argv_exact"], "1");
975
+ assert_eq!(fields["child_spawn_attempts"], "1");
976
+ assert_eq!(fields["child_argv_exact"], "1");
977
+ assert_eq!(fields["descendant_started"], "1");
978
+ assert_eq!(fields["descendant_stdout_inherited"], "1");
979
+ assert_eq!(
980
+ fields["parent_pid"],
981
+ observation.parent_pid.unwrap().to_string()
982
+ );
983
+ assert_eq!(fields["child_pid"], fields["descendant_pid"]);
984
+ let _ = std::fs::remove_file(&receipt);
985
+ let _ = std::fs::remove_file(&stage);
986
+ let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
987
+ }
988
+
989
+ #[cfg(unix)]
990
+ #[test]
991
+ #[serial_test::serial(env)]
992
+ fn command_boundary_connects_runner_parser_search_and_contract() {
993
+ let path = fixture(
994
+ "printf 'provider model\\nopenai-codex gpt-5.6-sol\\nopenai-codex gpt-5.6-luna\\n'",
995
+ );
996
+ let args = ModelsArgs {
997
+ provider: "pi".into(),
998
+ search: Some("sol".into()),
999
+ json: true,
1000
+ };
1001
+ let receipt = native_timeout_receipt();
1002
+ assert!(!receipt.exists());
1003
+ let started = Instant::now();
1004
+ let (result, observation) =
1005
+ crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
1006
+ &receipt,
1007
+ None,
1008
+ || cmd_models_with(&args, &path, Duration::from_secs(1), 1024),
1009
+ );
1010
+ let elapsed = started.elapsed();
1011
+ let result = match result {
1012
+ Ok(result) => result,
1013
+ Err(_) => panic!(
1014
+ "command boundary returned a CLI error; class=cli_error elapsed_ms={} parent_pid={:?} parent_exit_success={:?} parent_exit_code={:?} reader_timeout={}",
1015
+ elapsed.as_millis(),
1016
+ observation.parent_pid,
1017
+ observation.parent_exit_success,
1018
+ observation.parent_exit_code,
1019
+ observation.reader_timeout,
1020
+ ),
1021
+ };
1022
+ let CmdOutput::Human(text) = &result.output else {
1023
+ panic!(
1024
+ "expected JSON projection; {}",
1025
+ safe_models_observation(elapsed, &result, &observation)
1026
+ )
1027
+ };
1028
+ let value: Value = serde_json::from_str(text).unwrap_or_else(|_| {
1029
+ panic!(
1030
+ "expected valid JSON projection; {}",
1031
+ safe_models_observation(elapsed, &result, &observation)
1032
+ )
1033
+ });
1034
+ assert_eq!(
1035
+ value["schema_version"],
1036
+ "models.v1",
1037
+ "{}",
1038
+ safe_models_observation(elapsed, &result, &observation)
1039
+ );
1040
+ assert_eq!(
1041
+ value["models"][0]["role_model"],
1042
+ "openai-codex/gpt-5.6-sol",
1043
+ "{}",
1044
+ safe_models_observation(elapsed, &result, &observation)
1045
+ );
1046
+ assert_eq!(
1047
+ value["models"][0]["current"],
1048
+ false,
1049
+ "{}",
1050
+ safe_models_observation(elapsed, &result, &observation)
1051
+ );
1052
+ assert_eq!(
1053
+ value["auth"],
1054
+ "ok",
1055
+ "{}",
1056
+ safe_models_observation(elapsed, &result, &observation)
1057
+ );
1058
+ let model_count = value["models"].as_array().map(|models| models.len());
1059
+ assert_eq!(
1060
+ model_count,
1061
+ Some(1),
1062
+ "{}",
1063
+ safe_models_observation(elapsed, &result, &observation)
1064
+ );
1065
+ let _ = std::fs::remove_file(&receipt);
1066
+ let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
1067
+ let human = cmd_models_with(
1068
+ &ModelsArgs {
1069
+ provider: "pi".into(),
1070
+ search: Some("absent".into()),
1071
+ json: false,
1072
+ },
1073
+ &path,
1074
+ Duration::from_secs(1),
1075
+ 1024,
1076
+ )
1077
+ .unwrap();
1078
+ let CmdOutput::Human(text) = human.output else {
1079
+ panic!("expected human projection")
1080
+ };
1081
+ assert!(text.contains("No models matched --search") && text.contains("auth: ok"));
1082
+ let refusal = crate::cli::emit::__test_dispatch(
1083
+ "models",
1084
+ &["--provider".into(), "cloud".into()],
1085
+ Path::new("/tmp"),
1086
+ );
1087
+ assert!(matches!(refusal, Ok(ExitCode::Error)));
1088
+ cleanup_fixture(&path);
1089
+ }
1090
+
1091
+ #[cfg(unix)]
1092
+ #[test]
1093
+ fn runner_fails_closed_for_nonzero_oversize_timeout_and_unavailable() {
1094
+ let fail = native_timeout_fixture();
1095
+ let started = Instant::now();
1096
+ let (failed_result, fail_observation) =
1097
+ with_native_mode("exit7", || run_catalog(&fail, Duration::from_secs(1), 1024));
1098
+ let elapsed = started.elapsed();
1099
+ assert_eq!(
1100
+ failed_result.unwrap_err(),
1101
+ "Pi model catalog command failed",
1102
+ "runner observation: {}",
1103
+ safe_runner_observation(elapsed, &fail_observation)
1104
+ );
1105
+ assert_eq!(fail_observation.spawn_count, 1);
1106
+ assert_eq!(fail_observation.argv, vec!["--list-models"]);
1107
+ assert_eq!(fail_observation.parent_exit_success, Some(false));
1108
+ assert_eq!(fail_observation.parent_exit_code, Some(7));
1109
+ assert!(!fail_observation.reader_timeout);
1110
+ let (failed, failed_observation) = with_native_mode("exit7", || {
1111
+ cmd_models_with(
1112
+ &ModelsArgs {
1113
+ provider: "pi".into(),
1114
+ search: None,
1115
+ json: false,
1116
+ },
1117
+ &fail,
1118
+ Duration::from_secs(1),
1119
+ 1024,
1120
+ )
1121
+ });
1122
+ let failed = failed.unwrap();
1123
+ assert_eq!(failed_observation.spawn_count, 1);
1124
+ assert_eq!(failed_observation.argv, vec!["--list-models"]);
1125
+ assert_eq!(failed_observation.parent_exit_success, Some(false));
1126
+ assert_eq!(failed_observation.parent_exit_code, Some(7));
1127
+ assert!(!failed_observation.reader_timeout);
1128
+ let CmdOutput::Human(text) = failed.output else {
1129
+ panic!("expected failure projection")
1130
+ };
1131
+ assert_eq!(failed.exit, ExitCode::Error);
1132
+ assert!(!text.contains("sensitive-token"));
1133
+ let big = native_timeout_fixture();
1134
+ let (big_result, big_observation) =
1135
+ with_native_mode("oversize", || run_catalog(&big, Duration::from_secs(1), 8));
1136
+ assert!(big_result.unwrap_err().contains("bounded output"));
1137
+ assert_eq!(big_observation.spawn_count, 1);
1138
+ assert_eq!(big_observation.argv, vec!["--list-models"]);
1139
+ assert_eq!(big_observation.parent_exit_success, Some(true));
1140
+ assert_eq!(big_observation.parent_exit_code, Some(0));
1141
+ assert!(!big_observation.reader_timeout);
1142
+ let slow = native_timeout_fixture();
1143
+ let (slow_result, slow_observation) = with_native_mode("sleep", || {
1144
+ run_catalog(&slow, Duration::from_millis(20), 1024)
1145
+ });
1146
+ assert!(slow_result.unwrap_err().contains("timed out"));
1147
+ assert_eq!(slow_observation.spawn_count, 1);
1148
+ assert_eq!(slow_observation.argv, vec!["--list-models"]);
1149
+ assert_eq!(slow_observation.parent_exit_success, None);
1150
+ assert!(!slow_observation.reader_timeout);
1151
+ assert!(run_catalog(
1152
+ std::path::Path::new("/does/not/exist"),
1153
+ Duration::from_secs(1),
1154
+ 1024
1155
+ )
1156
+ .unwrap_err()
1157
+ .contains("unavailable"));
1158
+ }
1159
+
403
1160
  #[test]
404
1161
  fn public_failure_and_help_contracts_are_versioned() {
405
1162
  let args = ModelsArgs {
406
- provider: "codex".into(),
1163
+ provider: "pi".into(),
407
1164
  search: None,
408
1165
  json: true,
409
1166
  };
410
- let result = failure_with_action(&args, "safe failure", "safe action");
1167
+ let result = failure(&args, "safe failure");
411
1168
  let CmdOutput::Human(text) = result.output else {
412
1169
  panic!("json contract must render")
413
1170
  };