@team-agent/installer 0.5.102 → 0.5.104

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 (33) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/emit.rs +2 -1
  4. package/crates/team-agent/src/cli/models.rs +92 -226
  5. package/crates/team-agent/src/cli/spec.rs +2 -2
  6. package/crates/team-agent/src/compiler/tests.rs +19 -27
  7. package/crates/team-agent/src/compiler.rs +11 -105
  8. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +4 -2
  9. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +2 -5
  10. package/crates/team-agent/src/lifecycle/launch/identity.rs +9 -13
  11. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +37 -161
  12. package/crates/team-agent/src/lifecycle/launch/role_source.rs +1 -25
  13. package/crates/team-agent/src/lifecycle/launch/spawn.rs +1 -0
  14. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -12
  15. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1
  16. package/crates/team-agent/src/lifecycle/restart/common.rs +1 -1
  17. package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +7 -19
  18. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +8 -41
  19. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +14 -8
  20. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +8 -4
  21. package/crates/team-agent/src/lifecycle/worker_command_context.rs +4 -4
  22. package/crates/team-agent/src/messaging/results.rs +11 -42
  23. package/crates/team-agent/src/model/enums.rs +0 -9
  24. package/crates/team-agent/src/model/spec.rs +2 -2
  25. package/crates/team-agent/src/provider/adapters/cursor_agent.rs +7 -8
  26. package/crates/team-agent/src/provider/adapters/grok.rs +5 -18
  27. package/crates/team-agent/src/provider/mod.rs +1 -0
  28. package/crates/team-agent/src/provider/model_catalog.rs +650 -0
  29. package/crates/team-agent/src/provider/tests/adapter.rs +15 -24
  30. package/crates/team-agent/src/provider/wire.rs +2 -29
  31. package/package.json +4 -4
  32. package/skills/team-agent/SKILL.md +48 -33
  33. package/skills/team-agent/references/team-agent-operator.md +49 -526
@@ -15,11 +15,8 @@
15
15
  //! comparing byte-for-byte to Python golden. The absolute `workspace` path (env-
16
16
  //! dependent) is templated to `__WS__` on both sides so every other byte is pinned.
17
17
  //!
18
- //! SCOPE (this wave): no-profile `subscription` role docs only. The `.env`
19
- //! profile machinery (`profiles/`, `_profile_model`/`load_profile`) and the
20
- //! `rust_core` inline-secret *detection* (`contains_inline_secret` / the secret-
21
- //! lint rejection test) are DEFERRED to a follow-on — the compile path here only
22
- //! needs `contains_inline_secret` to return `false` for clean (non-secret) input.
18
+ //! Profile references are carried as role metadata; profile files and secrets are
19
+ //! handled by lifecycle/profile_launch, not loaded or inspected by this compiler.
23
20
  //!
24
21
  //! §10: pure lib layer — no panic on malformed input; every parse/validate path
25
22
  //! returns `Result<_, ModelError>` (mirrors Python `ValidationError`).
@@ -31,10 +28,7 @@ use crate::communication_mode::CommunicationMode;
31
28
  use crate::model::enums::{Provider, ProviderEffort};
32
29
  use crate::model::yaml::Value;
33
30
  use crate::model::{paths, spec, yaml, ModelError};
34
- use crate::provider::wire::{
35
- builtin_provider_model as wire_builtin_provider_model, parse_canonical_provider,
36
- provider_model_keys,
37
- };
31
+ use crate::provider::wire::parse_canonical_provider;
38
32
 
39
33
  pub const IGNORED_OWNER_TEAM_ID_FIELD: &str = "owner_team_id";
40
34
 
@@ -494,18 +488,12 @@ fn compile_role_agent_with_mode(
494
488
  let provider = string_field(&meta, "provider")
495
489
  .filter(|provider| !provider.trim().is_empty())
496
490
  .unwrap_or_else(|| "pi".to_string());
497
- require_explicit_grok_role_model(&meta, role_path, &provider)?;
498
- require_explicit_cursor_role_model(&meta, role_path, &provider)?;
499
- validate_pi_role_fields(&meta, role_path, &provider)?;
500
491
  let is_pi = parse_canonical_provider(&provider) == Some(Provider::Pi);
501
- let model = if is_pi {
502
- string_field(&meta, "model")
503
- .filter(|value| !value.trim().is_empty())
504
- .map(Value::Str)
505
- .unwrap_or_else(|| Value::Str("openai-codex/gpt-6-luna".to_string()))
506
- } else {
507
- resolve_model(&meta, team_meta, &provider)
508
- };
492
+ validate_pi_role_fields(&meta, role_path, &provider)?;
493
+ let model = string_field(&meta, "model")
494
+ .filter(|value| !value.trim().is_empty())
495
+ .map(Value::Str)
496
+ .unwrap_or(Value::Null);
509
497
  let auth_mode = string_field(&meta, "auth_mode")
510
498
  .or_else(|| string_field(team_meta, "default_auth_mode"))
511
499
  .unwrap_or_else(|| "subscription".to_string());
@@ -557,15 +545,11 @@ fn compile_role_agent_with_mode(
557
545
  ]),
558
546
  ),
559
547
  ];
560
- if let Some(label) = string_field(&meta, "label") {
561
- agent_items.insert(1, ("label", Value::Str(label)));
562
- }
563
548
  if let Some(profile) = string_field(&meta, "profile") {
564
549
  agent_items.push(("profile", Value::Str(profile)));
565
550
  }
566
- // 0.4.x provider effort MVP step 3: resolve effort with role > team > none
567
- // (Pi uses only explicit role effort). Validate syntax and provider support
568
- // here so unsupported combinations fail at compile, not at runtime.
551
+ // Role effort wins; Pi uses only an explicit role value. Other providers may
552
+ // inherit TEAM provider_effort for Issue #238 compatibility.
569
553
  let role_effort = match string_field(&meta, "effort") {
570
554
  Some(raw) if !raw.trim().is_empty() => {
571
555
  let value = raw.trim();
@@ -577,7 +561,6 @@ fn compile_role_agent_with_mode(
577
561
  })?;
578
562
  Some(parsed)
579
563
  }
580
- _ if is_pi => Some(ProviderEffort::Max),
581
564
  _ => None,
582
565
  };
583
566
  let team_effort = match string_field(team_meta, "provider_effort") {
@@ -674,54 +657,6 @@ fn string_field(meta: &Value, key: &str) -> Option<String> {
674
657
  .map(ToString::to_string)
675
658
  }
676
659
 
677
- /// 缺 model 时框架会填内建默认(grok 上是 grok-4),席位因此静默拿到
678
- /// 与角色文件无关的模型和上下文窗口,而 argv 看起来完全正常。
679
- /// 角色文件必须自己写死;内建默认、team 级默认、CLI 全局默认都是隐式来源。
680
- fn require_explicit_grok_role_model(
681
- meta: &Value,
682
- path: &Path,
683
- provider: &str,
684
- ) -> Result<(), ModelError> {
685
- if parse_canonical_provider(provider) != Some(Provider::Grok) {
686
- return Ok(());
687
- }
688
- if string_field(meta, "model").is_some_and(|value| !value.trim().is_empty()) {
689
- return Ok(());
690
- }
691
- Err(ModelError::Validation(format!(
692
- "{}: missing front matter field model. \
693
- Without an explicit model the framework fills a built-in default (grok-4 for grok), \
694
- so the seat silently gets a model and context window that are not in the role file, \
695
- while argv still looks normal. The role file must name the model itself; \
696
- built-in defaults, team-level defaults, and the Grok CLI global default are all implicit sources. Example:\n\
697
- model: grok-4.6",
698
- path.display()
699
- )))
700
- }
701
-
702
- /// 缺 model 时框架曾填 builtin `sonnet-4-thinking`,本机 shim 还会剥掉该默认。
703
- /// 角色必须自己写死;内建默认、team 级默认、CLI 全局默认都是隐式来源。
704
- fn require_explicit_cursor_role_model(
705
- meta: &Value,
706
- path: &Path,
707
- provider: &str,
708
- ) -> Result<(), ModelError> {
709
- if parse_canonical_provider(provider) != Some(Provider::CursorAgent) {
710
- return Ok(());
711
- }
712
- if string_field(meta, "model").is_some_and(|value| !value.trim().is_empty()) {
713
- return Ok(());
714
- }
715
- Err(ModelError::Validation(format!(
716
- "{}: missing front matter field model. \
717
- Without an explicit model the framework fills a built-in default (sonnet-4-thinking for cursor_agent), \
718
- so the seat silently gets a model that is not in the role file, while argv still looks normal. \
719
- The role file must name the model itself; built-in defaults, team-level defaults, and the Cursor CLI default are all implicit sources. Example:\n\
720
- model: sonnet-4-thinking",
721
- path.display()
722
- )))
723
- }
724
-
725
660
  fn validate_pi_role_fields(meta: &Value, path: &Path, provider: &str) -> Result<(), ModelError> {
726
661
  if parse_canonical_provider(provider) != Some(Provider::Pi) {
727
662
  return Ok(());
@@ -746,7 +681,7 @@ fn validate_pi_role_fields(meta: &Value, path: &Path, provider: &str) -> Result<
746
681
  fn optional_dangerously_skip_permissions(meta: &Value) -> bool {
747
682
  match meta.get("dangerously_skip_permissions") {
748
683
  Some(Value::Bool(value)) => *value,
749
- _ => true,
684
+ _ => false,
750
685
  }
751
686
  }
752
687
 
@@ -830,35 +765,6 @@ fn py_int_value(value: &Value) -> Option<i64> {
830
765
  }
831
766
  }
832
767
 
833
- fn resolve_model(role_meta: &Value, team_meta: &Value, provider: &str) -> Value {
834
- if let Some(model) = string_field(role_meta, "model") {
835
- return Value::Str(model);
836
- }
837
- if let Some(model) =
838
- provider_model(team_meta, provider).or_else(|| string_field(team_meta, "default_model"))
839
- {
840
- return Value::Str(model);
841
- }
842
- if role_meta.get("profile").is_some() {
843
- return Value::Null;
844
- }
845
- builtin_provider_model(provider)
846
- .map(|m| Value::Str(m.to_string()))
847
- .unwrap_or(Value::Null)
848
- }
849
-
850
- fn provider_model(team_meta: &Value, provider: &str) -> Option<String> {
851
- let models = team_meta.get("provider_models")?;
852
- let provider = parse_canonical_provider(provider)?;
853
- provider_model_keys(provider)
854
- .iter()
855
- .find_map(|key| string_field(models, key))
856
- }
857
-
858
- fn builtin_provider_model(provider: &str) -> Option<&'static str> {
859
- parse_canonical_provider(provider).and_then(wire_builtin_provider_model)
860
- }
861
-
862
768
  fn non_empty_trimmed(text: &str) -> Option<String> {
863
769
  let trimmed = text.trim();
864
770
  if trimmed.is_empty() {
@@ -390,7 +390,8 @@ fn starting_agent_entry(
390
390
  let provider = meta
391
391
  .get("provider")
392
392
  .and_then(Value::as_str)
393
- .unwrap_or("codex");
393
+ .filter(|provider| !provider.trim().is_empty())
394
+ .unwrap_or("pi");
394
395
  let auth_mode = meta
395
396
  .get("auth_mode")
396
397
  .and_then(Value::as_str)
@@ -438,8 +439,9 @@ fn starting_agent_entry(
438
439
  let meta_provider = meta
439
440
  .get("provider")
440
441
  .and_then(Value::as_str)
442
+ .filter(|provider| !provider.trim().is_empty())
441
443
  .and_then(crate::provider::wire::parse_provider)
442
- .unwrap_or(Provider::Codex);
444
+ .unwrap_or(Provider::Pi);
443
445
  persist_effective_approval_policy_from_yaml_agent(obj, meta, meta_provider);
444
446
  }
445
447
  entry
@@ -59,12 +59,9 @@ pub fn clone_agent(
59
59
  source_agent_id,
60
60
  as_agent_id,
61
61
  label,
62
- None,
63
62
  )?;
64
- // The materialized role carries the source role's DECLARED tools verbatim —
65
- // a clone must preserve the source seat's full tools set (add-agent does
66
- // the same; no leader-ceiling clamp). See role_source.rs for the removed
67
- // clamp_materialized_role_to_leader.
63
+ // Materialization preserves the role body and legacy metadata; the compiler
64
+ // only maps supported fields, so ignored header keys remain behaviorally inert.
68
65
  let added = add_agent(
69
66
  &selected.run_workspace,
70
67
  as_agent_id,
@@ -168,25 +168,21 @@ pub(crate) fn provider_effort_event_payload(
168
168
  }
169
169
 
170
170
  /// ---
171
- /// purpose: 对 claude 系 provider 兜底确保 CLAUDE_EFFORT 进入待清除环境变量表
171
+ /// purpose: 仅在存在显式 effort override 时清除继承的 CLAUDE_EFFORT
172
172
  /// params:
173
173
  /// base: 已有的待清除变量名列表
174
- /// returns: 非 claude 系原样返回;claude 系在缺失时补上 CLAUDE_EFFORT
175
- /// ---
176
- /// 0.4.x provider effort MVP step 9: defensive guarantee that `CLAUDE_EFFORT`
177
- /// is unset in the Claude/ClaudeCode worker spawn env. As of the
178
- /// `profile_launch::provider_env_unsets` update, the base list already
179
- /// includes `CLAUDE_EFFORT` for Claude — so this function is idempotent
180
- /// (returns input unchanged). Kept as a belt-and-braces guard so a future
181
- /// refactor that bypasses provider_env_unsets cannot silently drop the
182
- /// scrub. The structural win is in `tmux_backend::shell_command` which now
183
- /// filters env exports by env_unset (preventing inherited values from
184
- /// re-introducing keys we just unset).
174
+ /// has_effort_override: 本次启动是否实际施加 effort
175
+ /// returns: 无显式 override 或非 claude 系时原样返回
176
+ /// ---
177
+ /// Preserve provider-native `CLAUDE_EFFORT` unless a supported explicit role
178
+ /// effort is applied; in that case prevent the inherited environment from
179
+ /// overriding the requested value.
185
180
  pub(crate) fn extend_worker_env_unset_for_effort(
186
181
  base: Vec<String>,
187
182
  provider: Provider,
183
+ has_effort_override: bool,
188
184
  ) -> Vec<String> {
189
- if !matches!(provider, Provider::Claude | Provider::ClaudeCode) {
185
+ if !has_effort_override || !matches!(provider, Provider::Claude | Provider::ClaudeCode) {
190
186
  return base;
191
187
  }
192
188
  let mut out = base;
@@ -15,14 +15,13 @@
15
15
 
16
16
  use std::collections::BTreeSet;
17
17
  use std::fs::OpenOptions;
18
- use std::io::{Read, Write};
18
+ use std::io::Write;
19
19
  #[cfg(test)]
20
20
  use std::cell::RefCell;
21
21
  use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
22
22
  use std::path::{Path, PathBuf};
23
- use std::process::{Command, Stdio};
24
- use std::sync::mpsc;
25
- use std::time::{Duration, Instant};
23
+ use std::process::Command;
24
+ use std::time::Duration;
26
25
 
27
26
  use sha2::{Digest, Sha256};
28
27
 
@@ -132,62 +131,9 @@ pub(crate) fn new_pi_session_id() -> SessionId {
132
131
  /// errors: 非 UTF-8、header/row 异常、重复或空 catalog 时返回 ProviderError
133
132
  /// ---
134
133
  pub(crate) fn parse_pi_list_models_table(bytes: &[u8]) -> Result<Vec<String>, ProviderError> {
135
- let text = std::str::from_utf8(bytes).map_err(|error| {
136
- ProviderError::Command(format!("Pi model catalog is not UTF-8: {error}"))
137
- })?;
138
- let mut lines = text.lines();
139
- let header = lines
140
- .next()
141
- .ok_or_else(|| ProviderError::Command("Pi model catalog is empty".to_string()))?;
142
- let header_columns = header.split_whitespace().collect::<Vec<_>>();
143
- if header_columns.get(0) != Some(&"provider") || header_columns.get(1) != Some(&"model") {
144
- return Err(ProviderError::Command(
145
- "Pi model catalog has an unexpected header".to_string(),
146
- ));
147
- }
148
- let mut seen = BTreeSet::new();
149
- let mut models = Vec::new();
150
- for (index, line) in lines.enumerate() {
151
- if line.trim().is_empty() {
152
- continue;
153
- }
154
- let malformed = || {
155
- ProviderError::Command(format!(
156
- "Pi model catalog row {} is malformed",
157
- index + 2
158
- ))
159
- };
160
- let (provider, model) = line
161
- .trim()
162
- .split_once(char::is_whitespace)
163
- .ok_or_else(malformed)?;
164
- let mut model = model.trim();
165
- // Pi prints the raw model id, which may contain spaces. Only the
166
- // capability columns following it are single whitespace-free values.
167
- for _ in 2..header_columns.len() {
168
- model = model
169
- .rsplit_once(char::is_whitespace)
170
- .ok_or_else(malformed)?
171
- .0
172
- .trim_end();
173
- }
174
- if model.is_empty() {
175
- return Err(malformed());
176
- }
177
- let exact = format!("{provider}/{model}");
178
- if !seen.insert(exact.clone()) {
179
- return Err(ProviderError::Command(format!(
180
- "Pi model catalog contains duplicate exact id {exact:?}"
181
- )));
182
- }
183
- models.push(exact);
184
- }
185
- if models.is_empty() {
186
- return Err(ProviderError::Command(
187
- "Pi model catalog contains no models".to_string(),
188
- ));
189
- }
190
- Ok(models)
134
+ crate::provider::model_catalog::parse_pi_catalog(bytes)
135
+ .map(|records| records.into_iter().map(|record| record.id).collect())
136
+ .map_err(|error| ProviderError::Command(error.pi_legacy_message()))
191
137
  }
192
138
 
193
139
  /// ---
@@ -658,43 +604,6 @@ fn observe_pi_catalog_test(f: impl FnOnce(&mut PiCatalogTestContext)) {
658
604
  });
659
605
  }
660
606
 
661
- fn spawn_catalog_reader(
662
- stdout: std::process::ChildStdout,
663
- max_bytes: u64,
664
- ) -> mpsc::Receiver<(std::io::Result<usize>, Vec<u8>)> {
665
- let (sender, receiver) = mpsc::channel();
666
- std::thread::spawn(move || {
667
- let mut bytes = Vec::new();
668
- let result = stdout.take(max_bytes + 1).read_to_end(&mut bytes);
669
- let _ = sender.send((result, bytes));
670
- });
671
- receiver
672
- }
673
-
674
- fn finish_catalog_reader(
675
- receiver: mpsc::Receiver<(std::io::Result<usize>, Vec<u8>)>,
676
- status: std::process::ExitStatus,
677
- timeout: Duration,
678
- max_bytes: u64,
679
- ) -> Result<Vec<u8>, String> {
680
- let (result, bytes) = match receiver.recv_timeout(timeout) {
681
- Ok(value) => value,
682
- Err(_) => {
683
- #[cfg(test)]
684
- observe_pi_catalog_test(|context| context.observation.reader_timeout = true);
685
- return Err("Pi model catalog command timed out".to_string());
686
- }
687
- };
688
- if !status.success() {
689
- return Err("Pi model catalog command failed".into());
690
- }
691
- result.map_err(|_| "Pi model catalog could not be read".to_string())?;
692
- if bytes.len() as u64 > max_bytes {
693
- return Err("Pi model catalog exceeds the bounded output limit".into());
694
- }
695
- Ok(bytes)
696
- }
697
-
698
607
  #[cfg(test)]
699
608
  pub(crate) fn run_pi_catalog_after_parent_exit_for_test(
700
609
  stdout: std::process::ChildStdout,
@@ -708,86 +617,53 @@ pub(crate) fn run_pi_catalog_after_parent_exit_for_test(
708
617
  context.observation.parent_exit_success = Some(status.success());
709
618
  context.observation.parent_exit_code = status.code();
710
619
  });
711
- finish_catalog_reader(
712
- spawn_catalog_reader(stdout, max_bytes),
713
- status,
714
- timeout,
715
- max_bytes,
620
+ crate::provider::model_catalog::finish_stdout_after_exit(
621
+ stdout, status, timeout, max_bytes, &mut PiCatalogObserver,
716
622
  )
623
+ .map_err(|error| error.pi_legacy_message())
717
624
  }
718
625
 
719
- /// Discover candidates with one PATH-first catalog observation. This deliberately
720
- /// does not resolve adapters or scan wrapper chains; callers use it only for
721
- /// rejecting an unqualified role model before lifecycle mutation.
626
+ /// Shared bounded native-command runner; launch preflight keeps its exact model gate.
722
627
  pub(crate) fn run_pi_catalog(
723
628
  executable: &Path,
724
629
  timeout: Duration,
725
630
  max_bytes: u64,
726
631
  ) -> Result<Vec<u8>, String> {
727
- let mut command = Command::new(executable);
728
- command.arg("--list-models");
632
+ let mut extra_env = Vec::new();
729
633
  #[cfg(test)]
730
634
  observe_pi_catalog_test(|context| {
731
635
  context.observation.spawn_count += 1;
732
636
  context.observation.argv.push("--list-models".to_string());
733
- command.env("TEAM_AGENT_MODELS_TIMEOUT_RECEIPT", &context.receipt);
637
+ extra_env.push(("TEAM_AGENT_MODELS_TIMEOUT_RECEIPT".into(), context.receipt.as_os_str().into()));
734
638
  if let Some(mode) = context.helper_mode.as_deref() {
735
- command.env("TEAM_AGENT_MODELS_TIMEOUT_MODE", mode);
639
+ extra_env.push(("TEAM_AGENT_MODELS_TIMEOUT_MODE".into(), mode.into()));
736
640
  }
737
641
  });
738
- let mut child = command
739
- .stdin(Stdio::null())
740
- .stdout(Stdio::piped())
741
- .stderr(Stdio::null())
742
- .spawn()
743
- .map_err(|error| {
744
- #[cfg(test)]
745
- {
746
- eprintln!(
747
- "run_pi_catalog spawn failed kind={:?} raw_os_error={:?}",
748
- error.kind(),
749
- error.raw_os_error()
750
- );
751
- }
752
- let _ = error;
753
- "Pi executable is unavailable on PATH".to_string()
754
- })?;
642
+ crate::provider::model_catalog::run_command(
643
+ executable, &["--list-models"], None, None, &[], &extra_env, timeout, max_bytes,
644
+ &mut PiCatalogObserver,
645
+ )
646
+ .map_err(|error| error.pi_legacy_message())
647
+ }
648
+
649
+ struct PiCatalogObserver;
650
+ impl crate::provider::model_catalog::CatalogObserver for PiCatalogObserver {
755
651
  #[cfg(test)]
756
- observe_pi_catalog_test(|context| context.observation.parent_pid = Some(child.id()));
757
- let stdout = child.stdout.take().ok_or_else(|| {
758
- let _ = child.kill();
759
- let _ = child.wait();
760
- "Pi model catalog output unavailable".to_string()
761
- })?;
762
- let receiver = spawn_catalog_reader(stdout, max_bytes);
763
- let start = Instant::now();
764
- loop {
765
- match child.try_wait() {
766
- Ok(Some(status)) => {
767
- #[cfg(test)]
768
- observe_pi_catalog_test(|context| {
769
- context.observation.parent_exit_success = Some(status.success());
770
- context.observation.parent_exit_code = status.code();
771
- });
772
- return finish_catalog_reader(
773
- receiver,
774
- status,
775
- timeout.saturating_sub(start.elapsed()),
776
- max_bytes,
777
- );
778
- }
779
- Ok(None) if start.elapsed() < timeout => std::thread::sleep(Duration::from_millis(20)),
780
- Ok(None) => {
781
- let _ = child.kill();
782
- let _ = child.wait();
783
- return Err("Pi model catalog command timed out".into());
784
- }
785
- Err(_) => {
786
- let _ = child.kill();
787
- let _ = child.wait();
788
- return Err("Pi model catalog command could not be observed".into());
789
- }
790
- }
652
+ fn spawned(&mut self, pid: u32) {
653
+ observe_pi_catalog_test(|context| context.observation.parent_pid = Some(pid));
654
+ }
655
+
656
+ #[cfg(test)]
657
+ fn exited(&mut self, status: &std::process::ExitStatus) {
658
+ observe_pi_catalog_test(|context| {
659
+ context.observation.parent_exit_success = Some(status.success());
660
+ context.observation.parent_exit_code = status.code();
661
+ });
662
+ }
663
+
664
+ #[cfg(test)]
665
+ fn output_timeout(&mut self) {
666
+ observe_pi_catalog_test(|context| context.observation.reader_timeout = true);
791
667
  }
792
668
  }
793
669
 
@@ -132,9 +132,8 @@ impl Drop for MaterializedRole {
132
132
  /// state: 用于找源席的 dynamic_role_file,找不到时退到 team 目录下的同名 md
133
133
  /// as_agent_id: 新席位名,写进 front matter 的 name
134
134
  /// label: 非空时覆盖 front matter 的 role
135
- /// agent_label: 非空时写入 front matter 的 label
136
135
  /// returns: 物化结果,未调用 keep 时 Drop 会删掉该文件
137
- /// errors: 源文件缺失、未声明 name 或声明与源席不符时返回 Compile;目标已存在返回 RequirementUnmet;建目录或写盘失败返回 StatePersist
136
+ /// errors: 源文件缺失时返回 Compile;目标已存在返回 RequirementUnmet;建目录或写盘失败返回 StatePersist
138
137
  /// ---
139
138
  pub(crate) fn materialize_latest_role(
140
139
  run_workspace: &Path,
@@ -143,27 +142,10 @@ pub(crate) fn materialize_latest_role(
143
142
  source_agent_id: &AgentId,
144
143
  as_agent_id: &AgentId,
145
144
  label: Option<&str>,
146
- agent_label: Option<&str>,
147
145
  ) -> Result<MaterializedRole, LifecycleError> {
148
146
  let source_path = resolve_role_source(run_workspace, team_dir, state, source_agent_id)?;
149
147
  let (mut meta, body) = crate::compiler::read_front_matter(&source_path)
150
148
  .map_err(|error| LifecycleError::Compile(error.to_string()))?;
151
- let declared = meta
152
- .get("name")
153
- .and_then(Value::as_str)
154
- .filter(|name| !name.is_empty())
155
- .ok_or_else(|| {
156
- LifecycleError::Compile(format!(
157
- "source role file does not declare name: {}",
158
- source_path.display()
159
- ))
160
- })?;
161
- if declared != source_agent_id.as_str() {
162
- return Err(LifecycleError::Compile(format!(
163
- "source role file declares name '{}' but source agent is '{}'",
164
- declared, source_agent_id
165
- )));
166
- }
167
149
  set_yaml_map_value(
168
150
  &mut meta,
169
151
  "name",
@@ -175,12 +157,6 @@ pub(crate) fn materialize_latest_role(
175
157
  {
176
158
  set_yaml_map_value(&mut meta, "role", Value::Str(label.to_string()))?;
177
159
  }
178
- if let Some(agent_label) = agent_label
179
- .map(strip_label_quotes)
180
- .filter(|value| !value.is_empty())
181
- {
182
- set_yaml_map_value(&mut meta, "label", Value::Str(agent_label.to_string()))?;
183
- }
184
160
  if let Some(role) = meta.get("role").and_then(Value::as_str).map(str::to_string) {
185
161
  let role_without_quotes = strip_label_quotes(&role);
186
162
  if !role_without_quotes.is_empty() && role_without_quotes != role {
@@ -255,6 +255,7 @@ pub(super) fn spawn_agents(
255
255
  extend_worker_env_unset_for_effort(
256
256
  profile_launch.env_unset.iter().cloned().collect(),
257
257
  provider,
258
+ agent_effort.is_some(),
258
259
  ),
259
260
  );
260
261
  // The provider is the final typed value after profile overlays. Keep it
@@ -578,18 +578,6 @@ pub(crate) fn provider_env_unsets(provider: Provider, auth_mode: AuthMode) -> BT
578
578
  unsets.insert("CLAUDE_CODE_ENTRYPOINT".to_string());
579
579
  unsets.insert("CLAUDE_CODE_EXECPATH".to_string());
580
580
  unsets.insert("CLAUDECODE".to_string());
581
- // 0.4.x provider effort MVP step 9: CLAUDE_EFFORT carried from the
582
- // launching shell would silently override the framework's effort
583
- // decision (or, when no spec effort is configured, override the
584
- // documented "provider default"). Scrubbing here is the single
585
- // source — `extend_worker_env_unset_for_effort` is a thin alias
586
- // that calls into this list. Applies to BOTH worker spawn AND
587
- // leader spawn (leader_env_unset_for_provider also reads this).
588
- // MVP scope: leader-effort is not configured yet, but if a
589
- // launching shell already carries CLAUDE_EFFORT, the leader
590
- // inheriting it would conflict with future leader-effort
591
- // semantics. Scrub uniformly for predictability.
592
- unsets.insert("CLAUDE_EFFORT".to_string());
593
581
  if auth_mode == AuthMode::CompatibleApi {
594
582
  unsets.insert("ANTHROPIC_API_KEY".to_string());
595
583
  }
@@ -315,7 +315,6 @@ pub(crate) fn fork_pi_new_seat_locked(
315
315
  source_agent_id,
316
316
  target_agent_id,
317
317
  label,
318
- Some(target_agent_id.as_str()),
319
318
  )?;
320
319
  role = Some(target_role);
321
320
  let target_role_path = role
@@ -510,6 +510,7 @@ pub(super) fn spawn_agent_window(
510
510
  crate::lifecycle::launch::extend_worker_env_unset_for_effort(
511
511
  profile_launch.env_unset.iter().cloned().collect(),
512
512
  provider,
513
+ restart_effort.is_some(),
513
514
  ),
514
515
  );
515
516
  // Keep the launcher-known typed provider independent from inherited
@@ -748,7 +749,6 @@ fn merge_command_context_fields(
748
749
  "auth_mode",
749
750
  "effort",
750
751
  "profile",
751
- "permission_mode",
752
752
  // 0.5.66 bypass 单源:rehydrate 同步合入,restart 的 safety 构造读到新值。
753
753
  "dangerously_skip_permissions",
754
754
  ] {
@@ -31,35 +31,23 @@ use team_agent::transport::test_support::OfflineTransport;
31
31
 
32
32
  #[test]
33
33
  #[serial(env)]
34
- fn cursor_role_missing_model_refuses_to_start() {
34
+ fn cursor_role_missing_model_uses_provider_default() {
35
35
  let ws = tmp_dir("cursor-no-model");
36
36
  let team = write_role_team(&ws, "cursortm", "cursor_writer", None, None);
37
37
  let transport = OfflineTransport::new();
38
- let result = quick_start_with_transport_in_workspace(
38
+ quick_start_with_transport_in_workspace(
39
39
  &ws,
40
40
  &team,
41
41
  None,
42
42
  true,
43
43
  Some("cursortm"),
44
44
  &transport,
45
- );
46
- let err = match result {
47
- Ok(report) => panic!("cursor role without model must refuse; report={report:?}"),
48
- Err(error) => error.to_string(),
49
- };
50
- let lower = err.to_ascii_lowercase();
51
- assert!(
52
- lower.contains("model"),
53
- "error must name the missing field; err={err}"
54
- );
55
- assert!(
56
- lower.contains("built-in") || lower.contains("builtin") || err.contains("内建"),
57
- "error must name the built-in default; err={err}"
58
- );
45
+ )
46
+ .expect("Cursor may use its provider-native model default");
47
+ let argv = first_spawn_argv(&transport);
59
48
  assert!(
60
- transport.spawn_records().is_empty(),
61
- "refusal must happen before spawn; records={:?}",
62
- transport.spawn_records()
49
+ !argv.iter().any(|arg| arg == "--model"),
50
+ "an omitted model must not fabricate a --model argument: {argv:?}"
63
51
  );
64
52
  }
65
53