@team-agent/installer 0.5.124 → 0.5.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -8
- package/Cargo.toml +1 -1
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/crates/team-agent/Cargo.toml +0 -1
- package/crates/team-agent/src/cli/diagnose.rs +39 -69
- package/crates/team-agent/src/cli/emit.rs +45 -15
- package/crates/team-agent/src/cli/intent/runtime.rs +5 -53
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +10 -130
- package/crates/team-agent/src/cli/leader.rs +2 -3
- package/crates/team-agent/src/cli/leader_prompt.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +28 -33
- package/crates/team-agent/src/cli/models.rs +44 -880
- package/crates/team-agent/src/cli/route.rs +1 -1
- package/crates/team-agent/src/cli/send/persist.rs +36 -0
- package/crates/team-agent/src/cli/send/presentation.rs +7 -1
- package/crates/team-agent/src/cli/send.rs +3 -1
- package/crates/team-agent/src/cli/spec.rs +1 -2
- package/crates/team-agent/src/cli/status_port/brief.rs +66 -0
- package/crates/team-agent/src/cli/tests/base.rs +4 -11
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/run_delegation.rs +5 -4
- package/crates/team-agent/src/cli/tests/status_send.rs +17 -0
- package/crates/team-agent/src/compiler/tests.rs +39 -8
- package/crates/team-agent/src/compiler.rs +28 -204
- package/crates/team-agent/src/contract_runtime/backend.rs +79 -40
- package/crates/team-agent/src/contract_runtime/config.rs +37 -24
- package/crates/team-agent/src/contract_runtime/discovery.rs +33 -0
- package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
- package/crates/team-agent/src/contract_runtime/framework.rs +87 -34
- package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
- package/crates/team-agent/src/contract_runtime/registry.rs +299 -21
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -1
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +29 -8
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -42
- package/crates/team-agent/src/coordinator/tick.rs +89 -1
- package/crates/team-agent/src/db/message_store.rs +78 -3
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -1
- package/crates/team-agent/src/leader/prompt.rs +1 -2
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -52
- package/crates/team-agent/src/leader/start.rs +1 -2
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +2 -3
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +91 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +15 -195
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -9
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +18 -29
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +3 -11
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -24
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +21 -61
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
- package/crates/team-agent/src/lifecycle/launch.rs +2 -43
- package/crates/team-agent/src/lifecycle/profile_launch.rs +21 -348
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
- package/crates/team-agent/src/lifecycle/restart/common.rs +43 -378
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +0 -2
- package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +11 -6
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +60 -145
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +8 -334
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +30 -11
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +17 -16
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +12 -12
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +26 -28
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +11 -10
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +2 -106
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +6 -5
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +7 -153
- package/crates/team-agent/src/lifecycle/tests.rs +0 -6
- package/crates/team-agent/src/lifecycle/types.rs +2 -18
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
- package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
- package/crates/team-agent/src/messaging/delivery.rs +185 -168
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
- package/crates/team-agent/src/messaging/helpers.rs +19 -0
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +67 -5
- package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
- package/crates/team-agent/src/messaging/tests/spine.rs +46 -36
- package/crates/team-agent/src/model/enums.rs +1 -8
- package/crates/team-agent/src/provider/adapter.rs +33 -302
- package/crates/team-agent/src/provider/adapters/mod.rs +4 -5
- package/crates/team-agent/src/provider/argv_route.rs +1 -5
- package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
- package/crates/team-agent/src/provider/classify.rs +68 -3
- package/crates/team-agent/src/provider/faults.rs +1 -1
- package/crates/team-agent/src/provider/model_catalog.rs +14 -273
- package/crates/team-agent/src/provider/session/capture.rs +7 -107
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -4
- package/crates/team-agent/src/provider/session/context_fork.rs +17 -109
- package/crates/team-agent/src/provider/session_scan/common.rs +11 -36
- package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
- package/crates/team-agent/src/provider/session_scan.rs +4 -14
- package/crates/team-agent/src/provider/submit_now.rs +5 -28
- package/crates/team-agent/src/provider/tests/adapter.rs +39 -275
- package/crates/team-agent/src/provider/tests/classify.rs +53 -0
- package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -15
- package/crates/team-agent/src/provider/tests/idle.rs +0 -25
- package/crates/team-agent/src/provider/types.rs +1 -1
- package/crates/team-agent/src/provider/wire.rs +79 -11
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
- package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
- package/crates/team-agent/src/tmux_backend.rs +43 -8
- package/crates/team-agent/src/transport/native_input.rs +2 -231
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +7 -5
- package/skills/team-agent/command-coverage.json +15 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +5 -3
- package/skills/team-agent/references/team-agent-operator.md +5 -3
- package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
- package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
- package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
- package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
- package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- package/crates/team-agent/src/provider/adapters/cursor_agent.rs +0 -44
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
- package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
package/Cargo.lock
CHANGED
|
@@ -420,12 +420,6 @@ version = "0.4.34"
|
|
|
420
420
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
421
421
|
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
|
422
422
|
|
|
423
|
-
[[package]]
|
|
424
|
-
name = "md5"
|
|
425
|
-
version = "0.7.0"
|
|
426
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
427
|
-
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
|
|
428
|
-
|
|
429
423
|
[[package]]
|
|
430
424
|
name = "memchr"
|
|
431
425
|
version = "2.8.3"
|
|
@@ -727,13 +721,12 @@ dependencies = [
|
|
|
727
721
|
|
|
728
722
|
[[package]]
|
|
729
723
|
name = "team-agent"
|
|
730
|
-
version = "0.5.
|
|
724
|
+
version = "0.5.126"
|
|
731
725
|
dependencies = [
|
|
732
726
|
"anyhow",
|
|
733
727
|
"chrono",
|
|
734
728
|
"conpty-transport",
|
|
735
729
|
"libc",
|
|
736
|
-
"md5",
|
|
737
730
|
"regex",
|
|
738
731
|
"rusqlite",
|
|
739
732
|
"serde",
|
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -131,8 +131,8 @@ The default is OFF. `~/.team-agent/argv-routing.json` stores the switch and mapp
|
|
|
131
131
|
`enable`/`disable` preserve mappings; `set` replaces, `add` appends, and `clear` removes one mapping.
|
|
132
132
|
Commands report both persisted and effective states, including an active environment override.
|
|
133
133
|
|
|
134
|
-
Provider keys: `claude`, `codex`, `copilot`, `gemini_cli`, `grok`, `
|
|
135
|
-
Claude/Claude Code share one mapping; `claude_code`/`claude-code`
|
|
134
|
+
Provider keys: `claude`, `codex`, `copilot`, `gemini_cli`, `grok`, `pi`.
|
|
135
|
+
Claude/Claude Code share one mapping; `claude_code`/`claude-code` are accepted aliases.
|
|
136
136
|
Everything after the first `--` is literal argv data, including `--help`, `--json`, empty strings
|
|
137
137
|
and `{workspace}`; no shell expansion is performed. Arguments are inserted immediately after
|
|
138
138
|
the native executable, before its original arguments. Do not store secrets or override framework-managed
|
package/README.zh.md
CHANGED
|
@@ -130,8 +130,8 @@ team-agent route disable
|
|
|
130
130
|
(忽略大小写和两侧空白),无效值安全关闭。`enable/disable` 不清映射,`set` 精确替换、
|
|
131
131
|
`add` 按序追加、`clear` 删除一个映射。结果同时报告持久化态、实际有效态与环境覆盖。
|
|
132
132
|
|
|
133
|
-
Provider 键为 `claude`、`codex`、`copilot`、`gemini_cli`、`grok`、`
|
|
134
|
-
Claude/Claude Code 共用映射;支持 `claude_code/claude-code`
|
|
133
|
+
Provider 键为 `claude`、`codex`、`copilot`、`gemini_cli`、`grok`、`pi`。
|
|
134
|
+
Claude/Claude Code 共用映射;支持 `claude_code/claude-code` 别名。
|
|
135
135
|
第一个 `--` 后全部是字面 argv,包括 `--help`、`--json`、空字符串、`{workspace}`,不会二次 shell 展开。
|
|
136
136
|
注入位置为原生 executable 之后、原有参数之前。不要保存密码/token,或覆盖框架管理的
|
|
137
137
|
session/MCP/权限参数;既有身份、认证与安全检查不变。
|
|
@@ -9,74 +9,6 @@ use crate::model::pane_authority_refusal::{
|
|
|
9
9
|
use crate::provider::wire::{command_name, parse_provider, provider_wire};
|
|
10
10
|
use crate::transport::Transport;
|
|
11
11
|
|
|
12
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
|
|
13
|
-
#[serde(rename_all = "snake_case")]
|
|
14
|
-
pub(crate) enum PiBackingStatus {
|
|
15
|
-
Pending,
|
|
16
|
-
Captured,
|
|
17
|
-
Missing,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
|
|
21
|
-
#[serde(rename_all = "snake_case")]
|
|
22
|
-
pub(crate) enum PiMcpStatus {
|
|
23
|
-
Unavailable,
|
|
24
|
-
ConfiguredLazy,
|
|
25
|
-
RoundtripVerified,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
pub(crate) struct PiDoctorInput {
|
|
29
|
-
pub executable_chain_verified: bool,
|
|
30
|
-
pub pi_version: Option<String>,
|
|
31
|
-
pub adapter_version: Option<String>,
|
|
32
|
-
pub catalog_sha256: Option<String>,
|
|
33
|
-
pub selected_model: Option<String>,
|
|
34
|
-
pub candidate_executable: Option<std::path::PathBuf>,
|
|
35
|
-
pub wrapper: Option<std::path::PathBuf>,
|
|
36
|
-
pub mcp_roundtrip_at: Option<String>,
|
|
37
|
-
pub backing: PiBackingStatus,
|
|
38
|
-
pub activity: crate::provider::TurnState,
|
|
39
|
-
pub activity_source: crate::provider::ClassifySource,
|
|
40
|
-
pub env_key_names: Vec<String>,
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)]
|
|
44
|
-
pub(crate) struct PiDoctorFacts {
|
|
45
|
-
pub mcp: PiMcpStatus,
|
|
46
|
-
pub mcp_connected: bool,
|
|
47
|
-
pub backing: PiBackingStatus,
|
|
48
|
-
pub activity: crate::provider::TurnState,
|
|
49
|
-
pub activity_source: crate::provider::ClassifySource,
|
|
50
|
-
pub auth_hint: crate::provider::AuthHintStatus,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
pub(crate) fn pi_doctor_facts(input: PiDoctorInput) -> PiDoctorFacts {
|
|
54
|
-
let mcp = if input.mcp_roundtrip_at.is_some() {
|
|
55
|
-
PiMcpStatus::RoundtripVerified
|
|
56
|
-
} else if input.wrapper.is_some() {
|
|
57
|
-
PiMcpStatus::ConfiguredLazy
|
|
58
|
-
} else {
|
|
59
|
-
PiMcpStatus::Unavailable
|
|
60
|
-
};
|
|
61
|
-
let _ = (
|
|
62
|
-
input.executable_chain_verified,
|
|
63
|
-
input.pi_version,
|
|
64
|
-
input.adapter_version,
|
|
65
|
-
input.catalog_sha256,
|
|
66
|
-
input.selected_model,
|
|
67
|
-
input.candidate_executable,
|
|
68
|
-
input.env_key_names,
|
|
69
|
-
);
|
|
70
|
-
PiDoctorFacts {
|
|
71
|
-
mcp,
|
|
72
|
-
mcp_connected: mcp == PiMcpStatus::RoundtripVerified,
|
|
73
|
-
backing: input.backing,
|
|
74
|
-
activity: input.activity,
|
|
75
|
-
activity_source: input.activity_source,
|
|
76
|
-
auth_hint: crate::provider::AuthHintStatus::Unknown,
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
12
|
/// 0.5.39 Slice 1 (tmux-server-death-locate §11.1 B): classify a tmux
|
|
81
13
|
/// transport error string into a diagnose issue id. When the underlying
|
|
82
14
|
/// tmux subprocess stderr contains `server exited unexpectedly`, the
|
|
@@ -117,6 +49,23 @@ fn is_public_window_name(provider: &str, window: &str) -> bool {
|
|
|
117
49
|
if provider == "grok_build" && window == "grok" {
|
|
118
50
|
return true;
|
|
119
51
|
}
|
|
52
|
+
// An npm-installed Codex runs its vendor launcher under PATH's `node`, so
|
|
53
|
+
// tmux names the pane after that process instead of `codex`.
|
|
54
|
+
if provider == "codex_tui" && matches!(window, "codex" | "node") {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
// The same holds for npm-installed Pi; legacy `pi` keeps its own rule.
|
|
58
|
+
if provider == "pi_tui" && matches!(window, "pi" | "node") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
// tmux names a Claude pane after the image its `claude` route execs: an npm
|
|
62
|
+
// `claude.exe`, or the native installer's version-named `<semver>` file.
|
|
63
|
+
if provider == "claude_tui"
|
|
64
|
+
&& (matches!(window, "claude" | "claude.exe")
|
|
65
|
+
|| team_agent_contract::providers::claude::catalog::semver(window))
|
|
66
|
+
{
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
120
69
|
parse_provider(provider).is_some_and(|parsed| {
|
|
121
70
|
command_name(parsed) == window
|
|
122
71
|
|| crate::layout::worker_window_helpers::provider_window_name(parsed) == window
|
|
@@ -1445,6 +1394,28 @@ mod tests {
|
|
|
1445
1394
|
);
|
|
1446
1395
|
}
|
|
1447
1396
|
|
|
1397
|
+
#[test]
|
|
1398
|
+
fn codex_contract_window_may_carry_its_public_or_node_launcher_name() {
|
|
1399
|
+
assert!(is_public_window_name("codex_tui", "codex"));
|
|
1400
|
+
assert!(is_public_window_name("codex_tui", "node"));
|
|
1401
|
+
assert!(!is_public_window_name("codex_tui", "grok"));
|
|
1402
|
+
assert!(!is_public_window_name("grok_build", "node"));
|
|
1403
|
+
assert!(is_public_window_name("pi_tui", "pi"));
|
|
1404
|
+
assert!(is_public_window_name("pi_tui", "node"));
|
|
1405
|
+
assert!(!is_public_window_name("pi_tui", "codex"));
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
#[test]
|
|
1409
|
+
fn claude_contract_window_may_carry_its_npm_or_version_named_image() {
|
|
1410
|
+
for window in ["claude", "claude.exe", "2.1.309", "2.1.282"] {
|
|
1411
|
+
assert!(is_public_window_name("claude_tui", window), "{window}");
|
|
1412
|
+
}
|
|
1413
|
+
for window in ["2.1", "claude-wrapper", "node", "grok"] {
|
|
1414
|
+
assert!(!is_public_window_name("claude_tui", window), "{window}");
|
|
1415
|
+
}
|
|
1416
|
+
assert!(!is_public_window_name("grok_build", "2.1.309"));
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1448
1419
|
#[test]
|
|
1449
1420
|
fn doctor_accepts_public_window_name_when_no_pane_id_is_recorded() {
|
|
1450
1421
|
let state = grok_state(json!({}));
|
|
@@ -1721,7 +1692,6 @@ pub(crate) fn provider_doctor_checks() -> Value {
|
|
|
1721
1692
|
crate::provider::Provider::Codex,
|
|
1722
1693
|
crate::provider::Provider::GeminiCli,
|
|
1723
1694
|
crate::provider::Provider::Grok,
|
|
1724
|
-
crate::provider::Provider::CursorAgent,
|
|
1725
1695
|
crate::provider::Provider::Fake,
|
|
1726
1696
|
] {
|
|
1727
1697
|
let adapter = crate::provider::get_adapter(provider);
|
|
@@ -48,7 +48,7 @@ fn emit_with_json_order(
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
///
|
|
51
|
-
/// `main(argv)`(`parser.py:84`):**CLI 唯一进程入口**。codex/claude/copilot/grok
|
|
51
|
+
/// `main(argv)`(`parser.py:84`):**CLI 唯一进程入口**。codex/claude/copilot/grok passthrough 早返回 →
|
|
52
52
|
/// 解析 argv 到 subcommand → 调对应 handler → 异常落盘 + 信封 + `ExitCode::Error` →
|
|
53
53
|
/// `consume_leader_inbox_summary` → `emit` → `result.ok is False ? Error : Ok`。
|
|
54
54
|
/// **行为入口**:契约可端到端跑 argv→(stdout, exit code)。
|
|
@@ -330,7 +330,7 @@ fn dispatch_machine(command: &str, args: &[String], cwd: &Path) -> Result<ExitCo
|
|
|
330
330
|
// Command grammar, not provider identity parsing: these are top-level CLI
|
|
331
331
|
// passthrough verbs for starting a leader under a provider executable.
|
|
332
332
|
const LEADER_PASSTHROUGH_COMMANDS: &[&str] =
|
|
333
|
-
&["codex", "claude", "copilot", "grok", "
|
|
333
|
+
&["codex", "claude", "copilot", "grok", "pi"];
|
|
334
334
|
|
|
335
335
|
pub(crate) fn is_leader_passthrough_command(command: &str) -> bool {
|
|
336
336
|
LEADER_PASSTHROUGH_COMMANDS.contains(&command)
|
|
@@ -388,7 +388,7 @@ pub(crate) fn default_help() -> String {
|
|
|
388
388
|
append_help_section(
|
|
389
389
|
&mut out,
|
|
390
390
|
"Leader launch",
|
|
391
|
-
&["pi", "codex", "claude", "copilot", "grok", "
|
|
391
|
+
&["pi", "codex", "claude", "copilot", "grok", "kiro"],
|
|
392
392
|
);
|
|
393
393
|
out.push_str("\nCommand arguments and examples: team-agent <command> --help");
|
|
394
394
|
out
|
|
@@ -457,7 +457,7 @@ pub(super) fn command_help(command: Option<&str>) -> String {
|
|
|
457
457
|
"team-agent inbox leader -n 3\nteam-agent inbox worker --limit 5\nteam-agent inbox leader --workspace . --team help-demo --json", "Wait for a natural reply, then check team-agent status if needed. Do not inspect worker terminal content."),
|
|
458
458
|
"status" => ("Optional <agent> selects one agent. --summary/--detail retain compatibility and do not add fields.\nNine fields: name/provider/model/effort/runtime_status/activity/health/session_name/tmux_command.\nRuntime, activity and health are distinct. unknown means insufficient evidence; null means unset. No default model is guessed.",
|
|
459
459
|
"team-agent status\nteam-agent status worker\nteam-agent status --workspace . --team help-demo --json", "Read replies with team-agent inbox leader -n 3; diagnose problems with team-agent doctor --workspace ."),
|
|
460
|
-
"models" => ("--provider selects the provider, default pi. QUERY or --search performs keyword search; they are mutually exclusive.\nUse cursor for the contract-native Cursor catalog
|
|
460
|
+
"models" => ("--provider selects the provider, default pi. QUERY or --search performs keyword search; they are mutually exclusive.\nUse cursor (or cursor-agent, agent, cursor_agent) for the contract-native Cursor catalog. Copilot has no model discovery entrypoint here. Results come from the native catalog, not guesses.",
|
|
461
461
|
"team-agent models --provider pi\nteam-agent models --provider pi --search luna\nteam-agent models --provider cursor --json", "Use the exact returned model in a role file or team-agent start AGENT --model MODEL; stop a running seat before changing its settings."),
|
|
462
462
|
"restart" => ("restart AGENT and team restart default to --session auto; bare/explicit-path restart keeps preserve.\n--session preserve requires continuation evidence; auto permits only the original legal fresh fallback, not guaranteed saved memory.\n--dry-run plans without lifecycle effects. --allow-fresh is the legacy authorized opt-in; --session-converge-deadline is in seconds.",
|
|
463
463
|
"team-agent restart worker --dry-run --json\nteam-agent restart worker --session preserve --workspace . --dry-run --json", "Use team-agent team restart for deliberate team recovery; choose --session preserve when context must be retained. Team restart leaves explicitly stopped/paused seats alone; team-agent start intentionally activates the non-paused roster. Inspect partial/unknown outcomes with status/doctor, never blind reset or retry."),
|
|
@@ -499,7 +499,7 @@ pub(super) fn command_help(command: Option<&str>) -> String {
|
|
|
499
499
|
"", "Prepare complete TEAM.md/roles with explicit user choices, then run team-agent start in the opened Leader's tool context, never an ordinary worker conversation."),
|
|
500
500
|
};
|
|
501
501
|
let examples = if matches!(spec.kind, CommandKind::LeaderPassthrough { .. }) {
|
|
502
|
-
let native =
|
|
502
|
+
let native = name;
|
|
503
503
|
if name == "pi" {
|
|
504
504
|
"team-agent pi\nteam-agent pi -- --model openai-codex/gpt-6-luna\npi --help".to_string()
|
|
505
505
|
} else {
|
|
@@ -525,9 +525,6 @@ pub(super) fn command_help(command: Option<&str>) -> String {
|
|
|
525
525
|
if name == "restart" {
|
|
526
526
|
out.push_str("\nRestart forms: restart AGENT selects one registered agent (default session auto); use agent restart ID to disambiguate a same-named directory. Legacy bare or explicit-path restart retains preserve and original receipts. New team restart defaults to auto. auto never means reset; native capability refusals remain authoritative.");
|
|
527
527
|
}
|
|
528
|
-
if name == "cursor" {
|
|
529
|
-
out.push_str("\nDiscover models with team-agent models --provider cursor_agent.");
|
|
530
|
-
}
|
|
531
528
|
if name == "copilot" {
|
|
532
529
|
out.push_str(
|
|
533
530
|
"\nCopilot has no team-agent models entrypoint; consult native provider help.",
|
|
@@ -1646,9 +1643,21 @@ fn role_agent_args(
|
|
|
1646
1643
|
}
|
|
1647
1644
|
match flag {
|
|
1648
1645
|
"--provider" => {
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1646
|
+
// A contract name is written as the leaf's public name (`agent` →
|
|
1647
|
+
// `cursor`, `claude_code` → `claude`); it declares the same leaf.
|
|
1648
|
+
#[cfg(unix)]
|
|
1649
|
+
let contract = crate::contract_runtime::registry::declared(&value, false)
|
|
1650
|
+
.map(crate::contract_runtime::registry::public_name);
|
|
1651
|
+
#[cfg(not(unix))]
|
|
1652
|
+
let contract: Option<&str> = None;
|
|
1653
|
+
let provider = match contract {
|
|
1654
|
+
Some(id) => id,
|
|
1655
|
+
None => crate::provider::wire::provider_wire(
|
|
1656
|
+
crate::provider::wire::parse_provider(&value)
|
|
1657
|
+
.ok_or_else(|| CliError::Usage(format!("unknown provider: {value}")))?,
|
|
1658
|
+
),
|
|
1659
|
+
};
|
|
1660
|
+
role.provider = Some(provider.to_string());
|
|
1652
1661
|
}
|
|
1653
1662
|
"--bypass" => {
|
|
1654
1663
|
role.bypass = Some(match value.as_str() {
|
|
@@ -1735,6 +1744,27 @@ mod role_cli_tests {
|
|
|
1735
1744
|
assert_eq!(patch.bypass, Some(false));
|
|
1736
1745
|
}
|
|
1737
1746
|
|
|
1747
|
+
#[cfg(unix)]
|
|
1748
|
+
#[test]
|
|
1749
|
+
fn provider_accepts_contract_names_as_their_leaf_id() {
|
|
1750
|
+
for (name, leaf) in [
|
|
1751
|
+
("cursor", "cursor"), ("cursor-agent", "cursor"), ("agent", "cursor"),
|
|
1752
|
+
("cursor_agent", "cursor"), ("kiro", "kiro"), ("codex_tui", "codex_tui"),
|
|
1753
|
+
// Claude Code and Pi keep their public command names, which declare the leaf.
|
|
1754
|
+
("claude", "claude"), ("claude_code", "claude"), ("claude-code", "claude"),
|
|
1755
|
+
("claude_tui", "claude"), ("pi", "pi"), ("pi_tui", "pi"),
|
|
1756
|
+
] {
|
|
1757
|
+
let (_, patch) = role_agent_args(
|
|
1758
|
+
&strings(&["w", "--provider", name, "--bypass", "true"]), true,
|
|
1759
|
+
).unwrap_or_else(|error| panic!("{name}: {error}"));
|
|
1760
|
+
assert_eq!(patch.provider.as_deref(), Some(leaf), "{name}");
|
|
1761
|
+
}
|
|
1762
|
+
let (_, patch) =
|
|
1763
|
+
role_agent_args(&strings(&["w", "--provider", "codex", "--bypass", "true"]), true).unwrap();
|
|
1764
|
+
assert_eq!(patch.provider.as_deref(), Some("codex"), "a bare shared key stays legacy");
|
|
1765
|
+
assert!(role_agent_args(&strings(&["w", "--provider", "Cursor", "--bypass", "true"]), true).is_err());
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1738
1768
|
#[test]
|
|
1739
1769
|
fn strict_role_options_reject_ambiguous_values() {
|
|
1740
1770
|
for args in [
|
|
@@ -2189,8 +2219,8 @@ mod tests {
|
|
|
2189
2219
|
.collect();
|
|
2190
2220
|
assert_eq!(
|
|
2191
2221
|
expected.len(),
|
|
2192
|
-
|
|
2193
|
-
"the public catalog adds the four canonical lifecycle surfaces"
|
|
2222
|
+
34,
|
|
2223
|
+
"the public catalog adds the four canonical lifecycle surfaces and retires the Cursor launcher"
|
|
2194
2224
|
);
|
|
2195
2225
|
for spec_name in &expected {
|
|
2196
2226
|
assert!(
|
|
@@ -2522,12 +2552,12 @@ mod tests {
|
|
|
2522
2552
|
|
|
2523
2553
|
let cursor = models_args(&cli_argv(&[
|
|
2524
2554
|
"--provider",
|
|
2525
|
-
"
|
|
2555
|
+
"cursor",
|
|
2526
2556
|
"--search",
|
|
2527
2557
|
"GPT Luna",
|
|
2528
2558
|
]))
|
|
2529
2559
|
.unwrap();
|
|
2530
|
-
assert_eq!(cursor.provider, "
|
|
2560
|
+
assert_eq!(cursor.provider, "cursor");
|
|
2531
2561
|
assert_eq!(cursor.search.as_deref(), Some("GPT Luna"));
|
|
2532
2562
|
|
|
2533
2563
|
let both = models_args(&cli_argv(&["luna", "--search", "gpt"])).unwrap_err();
|
|
@@ -481,32 +481,14 @@ fn stop_args(plan: &Plan, id: &str) -> StopAgentArgs {
|
|
|
481
481
|
json: true,
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
fn check_incarnation_cwd(
|
|
485
|
-
selected: &SelectedTeam,
|
|
486
|
-
id: &str,
|
|
487
|
-
row: &Value,
|
|
488
|
-
provider: crate::provider::Provider,
|
|
489
|
-
) -> Result<(), CliError> {
|
|
484
|
+
fn check_incarnation_cwd(selected: &SelectedTeam, row: &Value) -> Result<(), CliError> {
|
|
490
485
|
if let Some(cwd) = row
|
|
491
486
|
.get("spawn_cwd")
|
|
492
487
|
.and_then(Value::as_str)
|
|
493
488
|
.filter(|cwd| !cwd.is_empty())
|
|
494
489
|
{
|
|
495
|
-
let
|
|
496
|
-
|
|
497
|
-
let inside = cwd.starts_with(&selected.run_workspace);
|
|
498
|
-
#[cfg(unix)]
|
|
499
|
-
let owned_cursor_primary = !inside
|
|
500
|
-
&& provider == crate::provider::Provider::CursorAgent
|
|
501
|
-
&& checked(crate::lifecycle::launch::cursor_mcp_primary_matches_scope(
|
|
502
|
-
&selected.run_workspace,
|
|
503
|
-
&selected.team_key,
|
|
504
|
-
id,
|
|
505
|
-
declared_cwd,
|
|
506
|
-
))?;
|
|
507
|
-
#[cfg(not(unix))]
|
|
508
|
-
let owned_cursor_primary = false;
|
|
509
|
-
if !cwd.is_dir() || !(inside || owned_cursor_primary) {
|
|
490
|
+
let cwd = checked(Path::new(cwd).canonicalize())?;
|
|
491
|
+
if !cwd.is_dir() || !cwd.starts_with(&selected.run_workspace) {
|
|
510
492
|
return Err(refusal("legacy incarnation cwd is outside the selected workspace; no context or scope fallback"));
|
|
511
493
|
}
|
|
512
494
|
}
|
|
@@ -589,7 +571,7 @@ fn preflight_start(
|
|
|
589
571
|
{
|
|
590
572
|
return Err(refusal("resume metadata lacks the scoped spawn cwd"));
|
|
591
573
|
}
|
|
592
|
-
check_incarnation_cwd(selected,
|
|
574
|
+
check_incarnation_cwd(selected, row)?;
|
|
593
575
|
if row
|
|
594
576
|
.get("task_prompt_delivered")
|
|
595
577
|
.is_some_and(|value| !value.is_null() && !value.is_boolean())
|
|
@@ -649,13 +631,7 @@ fn add(
|
|
|
649
631
|
{
|
|
650
632
|
return Err(usage("role creation requires explicit provider and dangerously_skip_permissions decisions"));
|
|
651
633
|
}
|
|
652
|
-
|
|
653
|
-
#[cfg(unix)]
|
|
654
|
-
if crate::contract_runtime::registry::descriptor(provider(&compiled)).is_some() {
|
|
655
|
-
return Err(refusal(
|
|
656
|
-
"native dynamic add is not admitted; no legacy fallback",
|
|
657
|
-
));
|
|
658
|
-
}
|
|
634
|
+
role(plan, selected, id, Some(&path))?;
|
|
659
635
|
path.to_string_lossy().into_owned()
|
|
660
636
|
}
|
|
661
637
|
None => {
|
|
@@ -664,16 +640,6 @@ fn add(
|
|
|
664
640
|
"unknown agent: supply a complete --role-file or --provider and --bypass",
|
|
665
641
|
));
|
|
666
642
|
}
|
|
667
|
-
#[cfg(unix)]
|
|
668
|
-
if patch
|
|
669
|
-
.provider
|
|
670
|
-
.as_deref()
|
|
671
|
-
.is_some_and(|p| crate::contract_runtime::registry::descriptor(p).is_some())
|
|
672
|
-
{
|
|
673
|
-
return Err(refusal(
|
|
674
|
-
"native dynamic add is not admitted; no legacy fallback",
|
|
675
|
-
));
|
|
676
|
-
}
|
|
677
643
|
String::new()
|
|
678
644
|
}
|
|
679
645
|
};
|
|
@@ -1216,20 +1182,6 @@ pub(super) fn recheck(plan: &Plan, step: &Step, after_stop: bool) -> Result<(),
|
|
|
1216
1182
|
}
|
|
1217
1183
|
}
|
|
1218
1184
|
}
|
|
1219
|
-
#[cfg(unix)]
|
|
1220
|
-
if !crate::contract_runtime::framework::is_contract(row)
|
|
1221
|
-
&& crate::provider::wire::parse_provider(provider(row))
|
|
1222
|
-
== Some(crate::provider::Provider::CursorAgent)
|
|
1223
|
-
&& (matches!(step, Step::StartAgent(_))
|
|
1224
|
-
|| (plan.intent.verb == Verb::Restart && matches!(step, Step::StopAgent(_)))
|
|
1225
|
-
|| (matches!(step, Step::RestartTeam(_))
|
|
1226
|
-
&& row.get("status").and_then(Value::as_str) == Some("running")
|
|
1227
|
-
&& !crate::state::projection::agent_explicit_stop(row)))
|
|
1228
|
-
{
|
|
1229
|
-
// Reopen the same ownership proof at the existing execution recheck,
|
|
1230
|
-
// before effects; a planning-time receipt is not a filesystem lease.
|
|
1231
|
-
check_incarnation_cwd(&selected, id, row, crate::provider::Provider::CursorAgent)?;
|
|
1232
|
-
}
|
|
1233
1185
|
}
|
|
1234
1186
|
Ok(())
|
|
1235
1187
|
}
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
use super::super::tests::Sandbox;
|
|
3
3
|
use super::*;
|
|
4
4
|
|
|
5
|
-
#[cfg(unix)]
|
|
6
|
-
#[path = "../../../tests/support/hermetic.rs"]
|
|
7
|
-
mod hermetic_guard;
|
|
8
|
-
|
|
9
5
|
fn fixture(ids: &[&str]) -> (Sandbox, Intent) {
|
|
10
6
|
let root = Sandbox::new();
|
|
11
7
|
std::fs::create_dir(root.path().join("agents")).unwrap();
|
|
@@ -24,10 +20,10 @@ fn fixture(ids: &[&str]) -> (Sandbox, Intent) {
|
|
|
24
20
|
(root, intent)
|
|
25
21
|
}
|
|
26
22
|
fn write_role(root: &Path, id: &str) {
|
|
27
|
-
std::fs::write(root.join("agents").join(format!("{id}.md")),format!("---\nname: {id}\nprovider:
|
|
23
|
+
std::fs::write(root.join("agents").join(format!("{id}.md")),format!("---\nname: {id}\nprovider: copilot\nmodel: gpt-6-luna\neffort: high\ndangerously_skip_permissions: true\n---\nFixture\n")).unwrap();
|
|
28
24
|
}
|
|
29
25
|
fn install(root: &Path, ids: &[(&str, &str, bool)]) {
|
|
30
|
-
let agents:serde_json::Map<String,Value>=ids.iter().map(|(id,status,explicit)|((*id).into(),json!({"provider":"
|
|
26
|
+
let agents:serde_json::Map<String,Value>=ids.iter().map(|(id,status,explicit)|((*id).into(),json!({"provider":"copilot","status":status,"explicit_stop":explicit,"pane_pid":std::process::id(),"pane_id":format!("%{id}"),"window":id}))).collect();
|
|
31
27
|
let entry = json!({"team_key":"fixture","team_dir":root,"status":"alive","session_name":"team-fixture","agents":agents,"tasks":{}});
|
|
32
28
|
let mut raw = entry.clone();
|
|
33
29
|
raw["active_team_key"] = json!("fixture");
|
|
@@ -431,14 +427,14 @@ fn preserve_rejects_known_missing_backing_before_stop_auto_uses_existing_decisio
|
|
|
431
427
|
let selected =
|
|
432
428
|
resolve_active_team_readonly(root.path(), Some("fixture"), SelectorMode::RuntimeOnly)
|
|
433
429
|
.unwrap();
|
|
434
|
-
let row = json!({"provider":"
|
|
430
|
+
let row = json!({"provider":"copilot","session_id":"missing-session","rollout_path":root.path().join("missing.jsonl"),"spawn_cwd":root.path()});
|
|
435
431
|
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Preserve).is_err());
|
|
436
432
|
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Auto).is_ok());
|
|
437
433
|
assert!(
|
|
438
434
|
preflight_start(
|
|
439
435
|
&selected,
|
|
440
436
|
"one",
|
|
441
|
-
&json!({"provider":"
|
|
437
|
+
&json!({"provider":"copilot"}),
|
|
442
438
|
SessionPolicy::Preserve
|
|
443
439
|
)
|
|
444
440
|
.is_ok(),
|
|
@@ -452,116 +448,6 @@ fn preserve_rejects_known_missing_backing_before_stop_auto_uses_existing_decisio
|
|
|
452
448
|
}
|
|
453
449
|
}
|
|
454
450
|
|
|
455
|
-
#[cfg(unix)]
|
|
456
|
-
fn cursor_scope_fixture() -> (
|
|
457
|
-
hermetic_guard::HermeticTestEnv,
|
|
458
|
-
Sandbox,
|
|
459
|
-
SelectedTeam,
|
|
460
|
-
PathBuf,
|
|
461
|
-
Value,
|
|
462
|
-
) {
|
|
463
|
-
let env = hermetic_guard::HermeticTestEnv::enter("cursor-intent-scope");
|
|
464
|
-
let (root, _) = fixture(&["one"]);
|
|
465
|
-
install(root.path(), &[("one", "stopped", true)]);
|
|
466
|
-
let selected =
|
|
467
|
-
resolve_active_team_readonly(root.path(), Some("fixture"), SelectorMode::RuntimeOnly)
|
|
468
|
-
.unwrap();
|
|
469
|
-
let config = crate::provider::McpConfig {
|
|
470
|
-
raw: json!({"team_orchestrator": {
|
|
471
|
-
"command": std::env::current_exe().unwrap(),
|
|
472
|
-
"args": ["mcp-server", "--workspace", root.path()],
|
|
473
|
-
"env": {"TEAM_AGENT_WORKSPACE": root.path(), "TEAM_AGENT_ID": "one", "TEAM_AGENT_OWNER_TEAM_ID": "fixture", "TEAM_AGENT_AUTH_MODE": "subscription"}
|
|
474
|
-
}}),
|
|
475
|
-
};
|
|
476
|
-
let primary = crate::lifecycle::launch::prepare_cursor_seat_mcp(root.path(), "one", &config)
|
|
477
|
-
.unwrap()
|
|
478
|
-
.unwrap();
|
|
479
|
-
let sid = "af3ce55e-2ee9-4bc5-8dae-b628e7447286";
|
|
480
|
-
let archive = env
|
|
481
|
-
.home()
|
|
482
|
-
.join(".cursor/chats")
|
|
483
|
-
.join(format!(
|
|
484
|
-
"{:x}",
|
|
485
|
-
md5::compute(primary.to_string_lossy().as_bytes())
|
|
486
|
-
))
|
|
487
|
-
.join(sid);
|
|
488
|
-
std::fs::create_dir_all(&archive).unwrap();
|
|
489
|
-
std::fs::write(archive.join("meta.json"), b"{}").unwrap();
|
|
490
|
-
let row = json!({"provider":"cursor_agent","status":"stopped","explicit_stop":true,"session_id":sid,"rollout_path":archive,"spawn_cwd":primary});
|
|
491
|
-
(env, root, selected, primary, row)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
#[test]
|
|
495
|
-
#[cfg(unix)]
|
|
496
|
-
#[serial_test::serial(env)]
|
|
497
|
-
fn issue342_cursor_owned_primary_scope_is_readonly_and_exact() {
|
|
498
|
-
let (_env, root, selected, primary, row) = cursor_scope_fixture();
|
|
499
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
500
|
-
let record = root
|
|
501
|
-
.path()
|
|
502
|
-
.join(".team/runtime/provider-config/one/cursor-project.json");
|
|
503
|
-
let paths = [state, record, primary.join(".cursor/mcp.json")];
|
|
504
|
-
let before: Vec<_> = paths.iter().map(|p| std::fs::read(p).unwrap()).collect();
|
|
505
|
-
assert!(!primary.starts_with(root.path()));
|
|
506
|
-
for policy in [SessionPolicy::Preserve, SessionPolicy::Auto] {
|
|
507
|
-
assert!(preflight_start(&selected, "one", &row, policy).is_ok());
|
|
508
|
-
}
|
|
509
|
-
let after: Vec<_> = paths.iter().map(|p| std::fs::read(p).unwrap()).collect();
|
|
510
|
-
assert_eq!(
|
|
511
|
-
before, after,
|
|
512
|
-
"scope preflight must not write state, record or MCP config"
|
|
513
|
-
);
|
|
514
|
-
|
|
515
|
-
let mut foreign_provider = row.clone();
|
|
516
|
-
foreign_provider["provider"] = json!("pi");
|
|
517
|
-
assert!(preflight_start(&selected, "one", &foreign_provider, SessionPolicy::Auto).is_err());
|
|
518
|
-
let mut other_team = selected.clone();
|
|
519
|
-
other_team.team_key = "foreign-team".into();
|
|
520
|
-
assert!(preflight_start(&other_team, "one", &row, SessionPolicy::Preserve).is_err());
|
|
521
|
-
assert!(preflight_start(&selected, "two", &row, SessionPolicy::Preserve).is_err());
|
|
522
|
-
let outside = Sandbox::new();
|
|
523
|
-
let mut other_workspace = selected.clone();
|
|
524
|
-
other_workspace.run_workspace = outside.path().to_owned();
|
|
525
|
-
assert!(preflight_start(&other_workspace, "one", &row, SessionPolicy::Preserve).is_err());
|
|
526
|
-
assert!(!outside.path().join(".team").exists());
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
#[test]
|
|
530
|
-
#[cfg(unix)]
|
|
531
|
-
#[serial_test::serial(env)]
|
|
532
|
-
fn issue342_cursor_scope_refuses_unrecorded_alias_and_replaced_incarnation() {
|
|
533
|
-
use std::os::unix::fs::{symlink, DirBuilderExt};
|
|
534
|
-
let (_env, root, selected, primary, row) = cursor_scope_fixture();
|
|
535
|
-
let record = root
|
|
536
|
-
.path()
|
|
537
|
-
.join(".team/runtime/provider-config/one/cursor-project.json");
|
|
538
|
-
let bytes = std::fs::read(&record).unwrap();
|
|
539
|
-
let retained = record.with_extension("retained");
|
|
540
|
-
std::fs::rename(&record, &retained).unwrap();
|
|
541
|
-
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Preserve).is_err());
|
|
542
|
-
assert!(
|
|
543
|
-
!record.exists(),
|
|
544
|
-
"a same-named external directory is not authority to create a record"
|
|
545
|
-
);
|
|
546
|
-
std::fs::rename(retained, &record).unwrap();
|
|
547
|
-
let mut forged = row.clone();
|
|
548
|
-
let arbitrary = Sandbox::new();
|
|
549
|
-
forged["spawn_cwd"] = json!(arbitrary.path());
|
|
550
|
-
assert!(preflight_start(&selected, "one", &forged, SessionPolicy::Auto).is_err());
|
|
551
|
-
let alias = root.path().join("primary-alias");
|
|
552
|
-
symlink(&primary, &alias).unwrap();
|
|
553
|
-
forged["spawn_cwd"] = json!(alias);
|
|
554
|
-
assert!(preflight_start(&selected, "one", &forged, SessionPolicy::Preserve).is_err());
|
|
555
|
-
let old = primary.with_extension("retained");
|
|
556
|
-
std::fs::rename(&primary, old).unwrap();
|
|
557
|
-
std::fs::DirBuilder::new()
|
|
558
|
-
.mode(0o700)
|
|
559
|
-
.create(&primary)
|
|
560
|
-
.unwrap();
|
|
561
|
-
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Auto).is_err());
|
|
562
|
-
assert_eq!(std::fs::read(record).unwrap(), bytes);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
451
|
#[test]
|
|
566
452
|
#[serial_test::serial(env)]
|
|
567
453
|
fn changed_role_and_socket_refuse_in_the_real_readonly_recheck() {
|
|
@@ -602,7 +488,7 @@ fn stopped_text_without_physical_identity_is_unknown_and_standalone_source_keeps
|
|
|
602
488
|
observe(
|
|
603
489
|
&selected,
|
|
604
490
|
"one",
|
|
605
|
-
&json!({"status":"stopped","provider":"
|
|
491
|
+
&json!({"status":"stopped","provider":"copilot"})
|
|
606
492
|
)
|
|
607
493
|
.unwrap(),
|
|
608
494
|
Observation::Unknown
|
|
@@ -611,7 +497,7 @@ fn stopped_text_without_physical_identity_is_unknown_and_standalone_source_keeps
|
|
|
611
497
|
observe(
|
|
612
498
|
&selected,
|
|
613
499
|
"one",
|
|
614
|
-
&json!({"status":"stopped","provider":"
|
|
500
|
+
&json!({"status":"stopped","provider":"copilot","pane_pid":std::process::id()})
|
|
615
501
|
)
|
|
616
502
|
.unwrap(),
|
|
617
503
|
Observation::Unknown
|
|
@@ -637,10 +523,6 @@ fn stopped_text_without_physical_identity_is_unknown_and_standalone_source_keeps
|
|
|
637
523
|
|
|
638
524
|
#[test]
|
|
639
525
|
fn declared_provider_aliases_do_not_create_false_drift_or_absorb_native_routes() {
|
|
640
|
-
assert!(!drift(
|
|
641
|
-
&json!({"provider":"agent"}),
|
|
642
|
-
&json!({"provider":"cursor_agent"})
|
|
643
|
-
));
|
|
644
526
|
assert!(same_provider("claude-code", "claude_code"));
|
|
645
527
|
assert!(!same_provider("cursor", "cursor_agent"));
|
|
646
528
|
assert!(!same_provider("grok_build", "grok"));
|
|
@@ -712,8 +594,6 @@ fn provider_argv0_is_exact_basename_not_substring() {
|
|
|
712
594
|
for argv0 in ["2.1.309", "claude-wrapper", "team-agent", "node", ""] {
|
|
713
595
|
assert!(!argv0_names(argv0, Provider::Claude), "{argv0}");
|
|
714
596
|
}
|
|
715
|
-
assert!(argv0_names("agent", Provider::CursorAgent));
|
|
716
|
-
assert!(!argv0_names("team-agent", Provider::CursorAgent));
|
|
717
597
|
}
|
|
718
598
|
|
|
719
599
|
#[test]
|
|
@@ -821,7 +701,7 @@ fn preserve_context_preflight_and_corrupt_metadata_refuse_before_stop() {
|
|
|
821
701
|
json!({"task_prompt_delivered":true}),
|
|
822
702
|
json!({"last_result_at":"2026-10-19T00:00:00Z"}),
|
|
823
703
|
] {
|
|
824
|
-
let mut row = json!({"provider":"
|
|
704
|
+
let mut row = json!({"provider":"copilot"});
|
|
825
705
|
row.as_object_mut()
|
|
826
706
|
.unwrap()
|
|
827
707
|
.extend(signal.as_object().unwrap().clone());
|
|
@@ -836,7 +716,7 @@ fn preserve_context_preflight_and_corrupt_metadata_refuse_before_stop() {
|
|
|
836
716
|
"first_send_at",
|
|
837
717
|
"task_prompt_delivered",
|
|
838
718
|
] {
|
|
839
|
-
let mut row = json!({"provider":"
|
|
719
|
+
let mut row = json!({"provider":"copilot"});
|
|
840
720
|
row[field] = json!([]);
|
|
841
721
|
for policy in [SessionPolicy::Auto, SessionPolicy::Preserve] {
|
|
842
722
|
assert!(
|
|
@@ -849,14 +729,14 @@ fn preserve_context_preflight_and_corrupt_metadata_refuse_before_stop() {
|
|
|
849
729
|
assert!(preflight_start(
|
|
850
730
|
&selected,
|
|
851
731
|
"one",
|
|
852
|
-
&json!({"provider":"
|
|
732
|
+
&json!({"provider":"copilot", "spawn_cwd":outside.path()}),
|
|
853
733
|
SessionPolicy::Auto
|
|
854
734
|
)
|
|
855
735
|
.is_err());
|
|
856
736
|
assert!(preflight_start(
|
|
857
737
|
&selected,
|
|
858
738
|
"one",
|
|
859
|
-
&json!({"provider":"
|
|
739
|
+
&json!({"provider":"copilot", "session_id":"captured"}),
|
|
860
740
|
SessionPolicy::Auto
|
|
861
741
|
)
|
|
862
742
|
.is_err());
|