@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
|
@@ -276,7 +276,7 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
276
276
|
"agents": {
|
|
277
277
|
"never_captured": {
|
|
278
278
|
"status": "running",
|
|
279
|
-
"provider": "
|
|
279
|
+
"provider": "copilot",
|
|
280
280
|
"session_id": null,
|
|
281
281
|
"first_send_at": null
|
|
282
282
|
}
|
|
@@ -302,15 +302,15 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
302
302
|
/// state — restart without --allow-fresh must STILL Refuse, never
|
|
303
303
|
/// silently fresh (architect rule: 绝不静默 fresh). This is what the
|
|
304
304
|
/// existing `upgrade_restart_refuses_interacted_worker_without_session_id`
|
|
305
|
-
/// test pins; this test pins the SAME guard for
|
|
305
|
+
/// test pins; this test pins the SAME guard for Copilot (the partial-resume
|
|
306
306
|
/// change must not weaken it for any provider).
|
|
307
307
|
#[test]
|
|
308
|
-
fn
|
|
308
|
+
fn restart_refuses_interacted_copilot_worker_without_session_id_partial_resume_preserves_guard() {
|
|
309
309
|
let state = json!({
|
|
310
310
|
"agents": {
|
|
311
311
|
"interacted_no_sid": {
|
|
312
312
|
"status": "running",
|
|
313
|
-
"provider": "
|
|
313
|
+
"provider": "copilot",
|
|
314
314
|
"session_id": null,
|
|
315
315
|
"first_send_at": "2026-06-26T01:00:00+00:00"
|
|
316
316
|
}
|
|
@@ -41,7 +41,7 @@ const TEAM_MD: &str =
|
|
|
41
41
|
|
|
42
42
|
const CODEX_ROLE: &str = "---\nname: codexer\nrole: Codex Worker\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nCodex worker.\n";
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
const COPILOT_ROLE: &str = "---\nname: copiloter\nrole: Copilot Worker\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nCopilot worker.\n";
|
|
45
45
|
|
|
46
46
|
#[test]
|
|
47
47
|
#[serial(env)]
|
|
@@ -50,7 +50,7 @@ fn worker_mcp_owner_team_scope_must_match_runtime_team_key_not_spec_name() {
|
|
|
50
50
|
let team = mixed_provider_team_dir(&hermetic, "mcp-owner-scope");
|
|
51
51
|
super::launch_spawn::seed_healthy_coordinator(team.parent().unwrap());
|
|
52
52
|
let transport = RecordingTransport::new()
|
|
53
|
-
.with_windows(vec![WindowName::new("
|
|
53
|
+
.with_windows(vec![WindowName::new("copiloter"), WindowName::new("codexer")]);
|
|
54
54
|
let launch = ready_launch(
|
|
55
55
|
quick_start_with_transport(&team, None, true, None, &transport)
|
|
56
56
|
.expect("quick-start should reach worker spawn path"),
|
|
@@ -194,7 +194,8 @@ fn running_worker_state_must_only_be_written_for_windows_that_exist_after_launch
|
|
|
194
194
|
let spec_path = team.join("team.spec.yaml");
|
|
195
195
|
std::fs::write(&spec_path, team_agent::model::yaml::dumps(&spec)).expect("write spec");
|
|
196
196
|
|
|
197
|
-
// Simulates the Mac mini final capture: the codex window exists, the
|
|
197
|
+
// Simulates the Mac mini final capture: the codex window exists, the other worker's
|
|
198
|
+
// (originally Claude, here Copilot) window does not.
|
|
198
199
|
// launch_with_transport currently never verifies the post-spawn window set before persisting
|
|
199
200
|
// `status=running`, so this fixture pins the state/physical invariant directly.
|
|
200
201
|
let transport = RecordingTransport::new().with_windows(vec![WindowName::new("codexer")]);
|
|
@@ -742,8 +743,8 @@ fn mixed_provider_team_dir(hermetic: &HermeticTestEnv, tag: &str) -> PathBuf {
|
|
|
742
743
|
let team = hermetic.workspace(tag).join("teamdir");
|
|
743
744
|
std::fs::create_dir_all(team.join("agents")).expect("create agents dir");
|
|
744
745
|
std::fs::write(team.join("TEAM.md"), TEAM_MD).expect("write TEAM.md");
|
|
745
|
-
std::fs::write(team.join("agents").join("
|
|
746
|
-
.expect("write
|
|
746
|
+
std::fs::write(team.join("agents").join("copiloter.md"), COPILOT_ROLE)
|
|
747
|
+
.expect("write copiloter role");
|
|
747
748
|
std::fs::write(team.join("agents").join("codexer.md"), CODEX_ROLE).expect("write codexer role");
|
|
748
749
|
team
|
|
749
750
|
}
|
|
@@ -95,103 +95,6 @@ fn worker_spawn_inherits_parent_process_env_for_proxy_and_ca() {
|
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
#[test]
|
|
99
|
-
#[serial(env)]
|
|
100
|
-
fn cursor_subscription_proxy_profile_reaches_fresh_and_restart_transport_final_env() {
|
|
101
|
-
let _guard = EnvGuard::set([
|
|
102
|
-
("HTTPS_PROXY", "https://upper-https:1"),
|
|
103
|
-
("HTTP_PROXY", "http://upper-http:1"),
|
|
104
|
-
("ALL_PROXY", "socks5://upper-all:1"),
|
|
105
|
-
("https_proxy", "https://lower-https:1"),
|
|
106
|
-
("http_proxy", "http://lower-http:1"),
|
|
107
|
-
("all_proxy", "socks5://lower-all:1"),
|
|
108
|
-
("NO_PROXY", "localhost,127.0.0.1"),
|
|
109
|
-
("no_proxy", "localhost,127.0.0.1"),
|
|
110
|
-
("GLOBAL_AGENT_HTTPS_PROXY", "https://global-https:1"),
|
|
111
|
-
("GLOBAL_AGENT_HTTP_PROXY", "http://global-http:1"),
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
|
-
let launch_direct = compiled_cursor_profile_team("cursor-direct-launch", "direct");
|
|
115
|
-
let launch_transport = RecordingTransport::new().with_session_present(false);
|
|
116
|
-
launch_with_transport(
|
|
117
|
-
&launch_direct.join("team.spec.yaml"),
|
|
118
|
-
false,
|
|
119
|
-
true,
|
|
120
|
-
true,
|
|
121
|
-
&launch_transport,
|
|
122
|
-
)
|
|
123
|
-
.expect("direct Cursor launch fixture should spawn");
|
|
124
|
-
assert_cursor_proxy_spawn(&launch_transport.single_spawn(), true);
|
|
125
|
-
|
|
126
|
-
let restart_direct = compiled_cursor_profile_team("cursor-direct-restart", "direct");
|
|
127
|
-
seed_restart_state_with_profile(&restart_direct, "worker_a", "cursor_proxy");
|
|
128
|
-
let restart_transport = RecordingTransport::new().with_session_present(false);
|
|
129
|
-
restart_with_transport(&restart_direct, true, None, &restart_transport)
|
|
130
|
-
.expect("direct Cursor restart fixture should spawn");
|
|
131
|
-
assert_cursor_proxy_spawn(&restart_transport.single_spawn(), true);
|
|
132
|
-
|
|
133
|
-
let launch_inherit = compiled_cursor_profile_team("cursor-inherit-launch", "inherit");
|
|
134
|
-
let inherit_transport = RecordingTransport::new().with_session_present(false);
|
|
135
|
-
launch_with_transport(
|
|
136
|
-
&launch_inherit.join("team.spec.yaml"),
|
|
137
|
-
false,
|
|
138
|
-
true,
|
|
139
|
-
true,
|
|
140
|
-
&inherit_transport,
|
|
141
|
-
)
|
|
142
|
-
.expect("inherit Cursor launch fixture should spawn");
|
|
143
|
-
assert_cursor_proxy_spawn(&inherit_transport.single_spawn(), false);
|
|
144
|
-
|
|
145
|
-
let restart_inherit = compiled_cursor_profile_team("cursor-inherit-restart", "inherit");
|
|
146
|
-
seed_restart_state_with_profile(&restart_inherit, "worker_a", "cursor_proxy");
|
|
147
|
-
let restart_inherit_transport = RecordingTransport::new().with_session_present(false);
|
|
148
|
-
restart_with_transport(
|
|
149
|
-
&restart_inherit,
|
|
150
|
-
true,
|
|
151
|
-
None,
|
|
152
|
-
&restart_inherit_transport,
|
|
153
|
-
)
|
|
154
|
-
.expect("inherit Cursor restart fixture should spawn");
|
|
155
|
-
assert_cursor_proxy_spawn(&restart_inherit_transport.single_spawn(), false);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
fn assert_cursor_proxy_spawn(spawn: &RecordedSpawn, direct: bool) {
|
|
159
|
-
let keys = [
|
|
160
|
-
"HTTPS_PROXY",
|
|
161
|
-
"HTTP_PROXY",
|
|
162
|
-
"ALL_PROXY",
|
|
163
|
-
"https_proxy",
|
|
164
|
-
"http_proxy",
|
|
165
|
-
"all_proxy",
|
|
166
|
-
"GLOBAL_AGENT_HTTPS_PROXY",
|
|
167
|
-
"GLOBAL_AGENT_HTTP_PROXY",
|
|
168
|
-
];
|
|
169
|
-
for key in keys {
|
|
170
|
-
if direct {
|
|
171
|
-
assert!(!spawn.env.contains_key(key), "direct env must omit {key}");
|
|
172
|
-
assert!(
|
|
173
|
-
spawn.env_unset.iter().any(|candidate| candidate == key),
|
|
174
|
-
"direct env_unset must contain {key}; got {:?}",
|
|
175
|
-
spawn.env_unset
|
|
176
|
-
);
|
|
177
|
-
} else {
|
|
178
|
-
assert!(spawn.env.contains_key(key), "inherit env must preserve {key}");
|
|
179
|
-
assert!(
|
|
180
|
-
spawn.env_unset.iter().all(|candidate| candidate != key),
|
|
181
|
-
"inherit env_unset must not contain {key}; got {:?}",
|
|
182
|
-
spawn.env_unset
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
for key in ["NO_PROXY", "no_proxy"] {
|
|
187
|
-
assert!(spawn.env.contains_key(key), "NO_PROXY bypass key must remain: {key}");
|
|
188
|
-
assert!(
|
|
189
|
-
spawn.env_unset.iter().all(|candidate| candidate != key),
|
|
190
|
-
"NO_PROXY bypass key must not be unset: {key}"
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
98
|
#[test]
|
|
196
99
|
fn tmux_control_filter_uses_env_keys_not_substring_in_inherited_values() {
|
|
197
100
|
let mut env = BTreeMap::from([
|
|
@@ -264,8 +167,8 @@ fn worker_spawn_scrubs_cross_provider_process_identity_but_keeps_config_env() {
|
|
|
264
167
|
("NODE_EXTRA_CA_CERTS", "/canary/ca.pem"),
|
|
265
168
|
]);
|
|
266
169
|
|
|
267
|
-
|
|
268
|
-
|
|
170
|
+
// The identity scrub is provider-agnostic; a Codex worker exercises every spawn surface.
|
|
171
|
+
let launch_team = compiled_team_dir("cross-launch", &[("worker_a", "Launch Worker")]);
|
|
269
172
|
let launch_transport = RecordingTransport::new().with_session_present(false);
|
|
270
173
|
launch_with_transport(
|
|
271
174
|
&launch_team.join("team.spec.yaml"),
|
|
@@ -276,25 +179,16 @@ fn worker_spawn_scrubs_cross_provider_process_identity_but_keeps_config_env() {
|
|
|
276
179
|
)
|
|
277
180
|
.expect("launch fixture should spawn worker");
|
|
278
181
|
|
|
279
|
-
let restart_team =
|
|
280
|
-
|
|
281
|
-
&[("worker_a", "Restart Worker")],
|
|
282
|
-
"claude",
|
|
283
|
-
);
|
|
284
|
-
seed_restart_state_as(&restart_team, "worker_a", "claude");
|
|
182
|
+
let restart_team = compiled_team_dir("cross-restart", &[("worker_a", "Restart Worker")]);
|
|
183
|
+
seed_restart_state(&restart_team, "worker_a");
|
|
285
184
|
let restart_transport = RecordingTransport::new().with_session_present(false);
|
|
286
185
|
restart_with_transport(&restart_team, true, None, &restart_transport)
|
|
287
186
|
.expect("restart fixture should spawn worker");
|
|
288
187
|
|
|
289
|
-
let add_team =
|
|
290
|
-
|
|
291
|
-
seed_running_add_agent_state_as(&add_team, "worker_a", "claude");
|
|
188
|
+
let add_team = compiled_team_dir("cross-add", &[("worker_a", "Existing Worker")]);
|
|
189
|
+
seed_running_add_agent_state(&add_team, "worker_a");
|
|
292
190
|
let role_file = add_team.parent().unwrap().join("worker_b.md");
|
|
293
|
-
std::fs::write(
|
|
294
|
-
&role_file,
|
|
295
|
-
role_doc_for_provider("worker_b", "Added Worker", "claude"),
|
|
296
|
-
)
|
|
297
|
-
.unwrap();
|
|
191
|
+
std::fs::write(&role_file, role_doc("worker_b", "Added Worker")).unwrap();
|
|
298
192
|
let add_transport = RecordingTransport::new().with_session_present(true);
|
|
299
193
|
add_agent_with_transport(
|
|
300
194
|
&add_team,
|
|
@@ -507,39 +401,6 @@ fn compiled_team_dir(label: &str, agents: &[(&str, &str)]) -> PathBuf {
|
|
|
507
401
|
compiled_team_dir_for_provider(label, agents, "codex")
|
|
508
402
|
}
|
|
509
403
|
|
|
510
|
-
fn compiled_cursor_profile_team(label: &str, proxy_mode: &str) -> PathBuf {
|
|
511
|
-
let team = tmp_dir(label).join("teamdir");
|
|
512
|
-
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
513
|
-
std::fs::write(
|
|
514
|
-
team.join("TEAM.md"),
|
|
515
|
-
"---\nname: envteam\nobjective: Cursor proxy environment contract.\nprovider: cursor_agent\n---\n\nTeam.\n",
|
|
516
|
-
)
|
|
517
|
-
.unwrap();
|
|
518
|
-
std::fs::write(
|
|
519
|
-
team.join("agents").join("worker_a.md"),
|
|
520
|
-
"---\nname: worker_a\nrole: Cursor Worker\nprovider: cursor_agent\nmodel: sonnet-4-thinking\nauth_mode: subscription\nprofile: cursor_proxy\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nCursor worker.\n",
|
|
521
|
-
)
|
|
522
|
-
.unwrap();
|
|
523
|
-
for directory in [
|
|
524
|
-
team.join("profiles"),
|
|
525
|
-
team.join(".team/current/profiles"),
|
|
526
|
-
] {
|
|
527
|
-
std::fs::create_dir_all(&directory).unwrap();
|
|
528
|
-
std::fs::write(
|
|
529
|
-
directory.join("cursor_proxy.env"),
|
|
530
|
-
format!("AUTH_MODE=subscription\nPROFILE_NAME=cursor_proxy\nPROXY_MODE={proxy_mode}\n"),
|
|
531
|
-
)
|
|
532
|
-
.unwrap();
|
|
533
|
-
}
|
|
534
|
-
let spec = team_agent::compiler::compile_team(&team).unwrap();
|
|
535
|
-
std::fs::write(
|
|
536
|
-
team.join("team.spec.yaml"),
|
|
537
|
-
team_agent::model::yaml::dumps(&spec),
|
|
538
|
-
)
|
|
539
|
-
.unwrap();
|
|
540
|
-
team
|
|
541
|
-
}
|
|
542
|
-
|
|
543
404
|
fn compiled_team_dir_for_provider(label: &str, agents: &[(&str, &str)], provider: &str) -> PathBuf {
|
|
544
405
|
let team = tmp_dir(label).join("teamdir");
|
|
545
406
|
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
@@ -580,13 +441,6 @@ fn seed_restart_state(team: &Path, agent_id: &str) {
|
|
|
580
441
|
seed_restart_state_as(team, agent_id, "codex");
|
|
581
442
|
}
|
|
582
443
|
|
|
583
|
-
fn seed_restart_state_with_profile(team: &Path, agent_id: &str, profile: &str) {
|
|
584
|
-
seed_restart_state_as(team, agent_id, "cursor_agent");
|
|
585
|
-
let mut state = team_agent::state::persist::load_runtime_state(team).unwrap();
|
|
586
|
-
state["agents"][agent_id]["profile"] = json!(profile);
|
|
587
|
-
team_agent::state::persist::save_runtime_state(team, &state).unwrap();
|
|
588
|
-
}
|
|
589
|
-
|
|
590
444
|
fn seed_restart_state_as(team: &Path, agent_id: &str, provider: &str) {
|
|
591
445
|
team_agent::state::persist::save_runtime_state(
|
|
592
446
|
team,
|
|
@@ -50,7 +50,6 @@ mod agent_ops;
|
|
|
50
50
|
mod b0_legacy_snapshot_nonauthority_contract;
|
|
51
51
|
mod b0_reader_hideone_audit_contract;
|
|
52
52
|
mod behavioral_diff_264_red;
|
|
53
|
-
mod claude_compatible_config_red;
|
|
54
53
|
mod claude_profile_launch_red;
|
|
55
54
|
mod cli_argv_routing_red;
|
|
56
55
|
mod clone_agent_preserves_source_tools;
|
|
@@ -59,9 +58,6 @@ mod codex_weak_window_attribution_red;
|
|
|
59
58
|
mod communication_mode_runtime_contract_red;
|
|
60
59
|
mod copilot_provider_red;
|
|
61
60
|
mod core;
|
|
62
|
-
mod cursor_mcp_overlay;
|
|
63
|
-
mod cursor_require_explicit_model_red;
|
|
64
|
-
mod cursor_restart_resume_red;
|
|
65
61
|
mod f032_startup_prompt_best_effort_red;
|
|
66
62
|
mod grok_effort_argv_red;
|
|
67
63
|
mod grok_mcp_overlay_red;
|
|
@@ -80,10 +76,8 @@ mod phase_b_contracts;
|
|
|
80
76
|
mod phase_golden;
|
|
81
77
|
mod pi_catalog_red;
|
|
82
78
|
mod pi_command_red;
|
|
83
|
-
mod pi_compiler_red;
|
|
84
79
|
mod pi_dual_entry_red;
|
|
85
80
|
mod pi_executable_mcp_red;
|
|
86
|
-
mod pi_fork_session_inheritance_red;
|
|
87
81
|
mod pi_lifecycle_doctor_red;
|
|
88
82
|
mod pi_native_mcp_capability_red;
|
|
89
83
|
mod pi_session_delivery_red;
|
|
@@ -396,14 +396,6 @@ pub enum LifecycleError {
|
|
|
396
396
|
/// 编译 spec / role doc 失败(`compile_team`/`compile_role_doc_agent`)。
|
|
397
397
|
#[error("spec compile failed: {0}")]
|
|
398
398
|
Compile(String),
|
|
399
|
-
/// Pi model/schema admission failed before lifecycle reservation or writes.
|
|
400
|
-
#[error("pi model preflight failed: {requested}")]
|
|
401
|
-
PiModelPreflight {
|
|
402
|
-
requested: String,
|
|
403
|
-
candidates: Vec<String>,
|
|
404
|
-
action: String,
|
|
405
|
-
not_ready: bool,
|
|
406
|
-
},
|
|
407
399
|
/// provider 命令构造 / resume 不可用(`ResumeUnavailable`)。
|
|
408
400
|
#[error("provider error: {0}")]
|
|
409
401
|
Provider(String),
|
|
@@ -618,8 +610,8 @@ pub struct AddAgentReport {
|
|
|
618
610
|
pub role_file: PathBuf,
|
|
619
611
|
}
|
|
620
612
|
|
|
621
|
-
/// `fork_agent(...)`
|
|
622
|
-
///
|
|
613
|
+
/// `fork_agent(...)` 结果(legacy 窗口内分身)。Claude Code / Pi 的新席位 fork
|
|
614
|
+
/// 由 contract 管道直接给出回执,不经过这里。
|
|
623
615
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
624
616
|
pub struct ForkAgentReport {
|
|
625
617
|
pub source_agent_id: AgentId,
|
|
@@ -627,14 +619,6 @@ pub struct ForkAgentReport {
|
|
|
627
619
|
pub env: AgentActionEnvelope,
|
|
628
620
|
pub session_id: Option<SessionId>,
|
|
629
621
|
pub backing_state: ForkBackingState,
|
|
630
|
-
pub pi_fork: Option<PiForkDetails>,
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
634
|
-
pub struct PiForkDetails {
|
|
635
|
-
pub source_session_id: SessionId,
|
|
636
|
-
pub session_id: SessionId,
|
|
637
|
-
pub backing_path: RolloutPath,
|
|
638
622
|
}
|
|
639
623
|
|
|
640
624
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
@@ -226,10 +226,8 @@ fn mcp_tool_name(provider: Provider, server: &str, tool: &str) -> String {
|
|
|
226
226
|
Provider::Grok => format!("{server}__{tool}"),
|
|
227
227
|
// Pi's owned extension binds these logical operations to the observed MCP call surface.
|
|
228
228
|
Provider::Pi => tool.to_string(),
|
|
229
|
-
//
|
|
230
|
-
|
|
231
|
-
Provider::CursorAgent
|
|
232
|
-
| Provider::Codex
|
|
229
|
+
// Codex / Copilot / GeminiCli / Fake: 未验证,沿用现状点号。
|
|
230
|
+
Provider::Codex
|
|
233
231
|
| Provider::Copilot
|
|
234
232
|
| Provider::GeminiCli
|
|
235
233
|
| Provider::Fake => format!("{server}.{tool}"),
|
|
@@ -5,7 +5,7 @@ use std::fs::{File, OpenOptions};
|
|
|
5
5
|
use std::io::{Read, Write};
|
|
6
6
|
use std::os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt};
|
|
7
7
|
use std::path::{Path, PathBuf};
|
|
8
|
-
use std::time::
|
|
8
|
+
use std::time::Duration;
|
|
9
9
|
|
|
10
10
|
use chrono::{DateTime, Utc};
|
|
11
11
|
use serde::{Deserialize, Serialize};
|
|
@@ -105,34 +105,26 @@ fn read_json(path: &Path, require_private: bool) -> Result<Value> {
|
|
|
105
105
|
serde_json::from_slice(&data).map_err(|_| "mcp_handshake_invalid")
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
108
|
+
/// Per-server receipts plus the pre-#372 single-slot file, if one remains.
|
|
109
|
+
fn receipt_paths(dir: &Path, name: &str) -> Vec<PathBuf> {
|
|
110
|
+
let Ok(entries) = std::fs::read_dir(dir) else {
|
|
111
|
+
return Vec::new();
|
|
112
|
+
};
|
|
113
|
+
entries
|
|
114
|
+
.flatten()
|
|
115
|
+
.filter_map(|entry| {
|
|
116
|
+
let file = entry.file_name().into_string().ok()?;
|
|
117
|
+
let rest = file.strip_prefix(name)?.strip_suffix(".json")?;
|
|
118
|
+
let per_server = rest
|
|
119
|
+
.strip_prefix('.')
|
|
120
|
+
.is_some_and(|pid| pid.parse::<u32>().is_ok());
|
|
121
|
+
(rest.is_empty() || per_server).then(|| entry.path())
|
|
122
|
+
})
|
|
123
|
+
.collect()
|
|
113
124
|
}
|
|
114
125
|
|
|
115
|
-
fn
|
|
116
|
-
|
|
117
|
-
.create(true)
|
|
118
|
-
.truncate(false)
|
|
119
|
-
.read(true)
|
|
120
|
-
.write(true)
|
|
121
|
-
.mode(0o600)
|
|
122
|
-
.custom_flags(libc::O_NOFOLLOW)
|
|
123
|
-
.open(path)
|
|
124
|
-
.map_err(|_| "mcp_handshake_lock")?;
|
|
125
|
-
private_metadata(path, false)?;
|
|
126
|
-
let start = Instant::now();
|
|
127
|
-
loop {
|
|
128
|
-
match crate::platform::file_lock::try_lock_once_nonblocking(&file) {
|
|
129
|
-
Ok(true) => return Ok(ReceiptLock(file)),
|
|
130
|
-
Ok(false) if start.elapsed() < Duration::from_millis(500) => {
|
|
131
|
-
std::thread::sleep(Duration::from_millis(10));
|
|
132
|
-
}
|
|
133
|
-
_ => return Err("mcp_handshake_lock"),
|
|
134
|
-
}
|
|
135
|
-
}
|
|
126
|
+
fn read_receipt(path: &Path) -> Result<Handshake> {
|
|
127
|
+
serde_json::from_value(read_json(path, true)?).map_err(|_| "mcp_handshake_invalid")
|
|
136
128
|
}
|
|
137
129
|
|
|
138
130
|
/// Only the actual stdio writer calls this after initialize and tools/list flush.
|
|
@@ -198,28 +190,28 @@ pub(crate) fn publish(
|
|
|
198
190
|
let dir = directory(&workspace, true)?;
|
|
199
191
|
let before = private_metadata(&dir, true)?;
|
|
200
192
|
let name = key(owner, agent);
|
|
201
|
-
|
|
202
|
-
|
|
193
|
+
// #372: each server owns its receipt, so a foreign or exited server that
|
|
194
|
+
// inherited this seat's identity can never erase the seat's live evidence.
|
|
195
|
+
let path = dir.join(format!("{name}.{}.json", std::process::id()));
|
|
203
196
|
match std::fs::symlink_metadata(&path) {
|
|
204
197
|
Ok(_) => {
|
|
205
|
-
|
|
206
|
-
.map_err(|_| "mcp_handshake_invalid")?;
|
|
207
|
-
if old.workspace != workspace
|
|
208
|
-
|| old.owner != owner
|
|
209
|
-
|| old.agent != agent
|
|
210
|
-
|| old.schema != 1
|
|
211
|
-
{
|
|
212
|
-
return Err("mcp_handshake_scope_mismatch");
|
|
213
|
-
}
|
|
214
|
-
let old_started = DateTime::parse_from_rfc3339(&old.started_at)
|
|
215
|
-
.map_err(|_| "mcp_handshake_invalid")?;
|
|
216
|
-
if old_started > started_at {
|
|
217
|
-
return Ok(());
|
|
218
|
-
}
|
|
198
|
+
private_metadata(&path, false)?;
|
|
219
199
|
}
|
|
220
200
|
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {}
|
|
221
201
|
Err(_) => return Err("mcp_handshake_invalid"),
|
|
222
202
|
}
|
|
203
|
+
for sibling in receipt_paths(&dir, &name) {
|
|
204
|
+
let exited = sibling != path
|
|
205
|
+
&& read_receipt(&sibling).is_ok_and(|old| {
|
|
206
|
+
matches!(
|
|
207
|
+
sample_process(&old.server),
|
|
208
|
+
ProcessState::Exited | ProcessState::Replaced
|
|
209
|
+
)
|
|
210
|
+
});
|
|
211
|
+
if exited {
|
|
212
|
+
let _ = std::fs::remove_file(&sibling);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
223
215
|
let temp = dir.join(format!(
|
|
224
216
|
"{name}.{}-{}.tmp",
|
|
225
217
|
std::process::id(),
|
|
@@ -247,10 +239,23 @@ pub(crate) fn publish(
|
|
|
247
239
|
})();
|
|
248
240
|
if result.is_err() {
|
|
249
241
|
let _ = std::fs::remove_file(&temp);
|
|
242
|
+
return result;
|
|
250
243
|
}
|
|
244
|
+
resume_parked(&workspace, owner, agent);
|
|
251
245
|
result
|
|
252
246
|
}
|
|
253
247
|
|
|
248
|
+
/// A fresh receipt resumes this seat's parked messages. A foreign server's
|
|
249
|
+
/// receipt only causes one cheap re-park: delivery re-runs full preflight.
|
|
250
|
+
fn resume_parked(workspace: &Path, owner: &str, agent: &str) {
|
|
251
|
+
if !workspace.join(".team/runtime/team.db").exists() {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if let Ok(store) = crate::message_store::MessageStore::open(workspace) {
|
|
255
|
+
let _ = store.requeue_parked_deliveries(agent, owner);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
254
259
|
#[derive(Debug)]
|
|
255
260
|
pub(crate) struct Admission {
|
|
256
261
|
server: ProcessStamp,
|
|
@@ -293,30 +298,11 @@ pub(crate) fn preflight(
|
|
|
293
298
|
.canonicalize()
|
|
294
299
|
.map_err(|_| "mcp_handshake_workspace")?;
|
|
295
300
|
let dir = directory(&workspace, false)?;
|
|
296
|
-
let receipt: Handshake = serde_json::from_value(read_json(
|
|
297
|
-
&dir.join(format!("{}.json", key(owner, agent_id))),
|
|
298
|
-
true,
|
|
299
|
-
)?)
|
|
300
|
-
.map_err(|_| "mcp_handshake_invalid")?;
|
|
301
|
-
if receipt.schema != 1
|
|
302
|
-
|| receipt.workspace != workspace
|
|
303
|
-
|| receipt.owner != owner
|
|
304
|
-
|| receipt.agent != agent_id
|
|
305
|
-
{
|
|
306
|
-
return Err("mcp_handshake_scope_mismatch");
|
|
307
|
-
}
|
|
308
301
|
let spawned_at = agent
|
|
309
302
|
.get("spawned_at")
|
|
310
303
|
.and_then(Value::as_str)
|
|
311
304
|
.and_then(|s| DateTime::parse_from_rfc3339(s).ok())
|
|
312
305
|
.ok_or("mcp_handshake_spawn_missing")?;
|
|
313
|
-
let started_at =
|
|
314
|
-
DateTime::parse_from_rfc3339(&receipt.started_at).map_err(|_| "mcp_handshake_invalid")?;
|
|
315
|
-
let flushed_at =
|
|
316
|
-
DateTime::parse_from_rfc3339(&receipt.flushed_at).map_err(|_| "mcp_handshake_invalid")?;
|
|
317
|
-
if started_at < spawned_at || flushed_at < started_at {
|
|
318
|
-
return Err("mcp_handshake_stale_spawn");
|
|
319
|
-
}
|
|
320
306
|
let expected_config = workspace
|
|
321
307
|
.join(".team/runtime/mcp")
|
|
322
308
|
.join(format!("{agent_id}.json"));
|
|
@@ -341,14 +327,12 @@ pub(crate) fn preflight(
|
|
|
341
327
|
.get("command")
|
|
342
328
|
.and_then(Value::as_str)
|
|
343
329
|
.ok_or("mcp_handshake_config_missing")?;
|
|
344
|
-
if !Path::new(expected).is_absolute()
|
|
345
|
-
|| Path::new(expected)
|
|
346
|
-
.canonicalize()
|
|
347
|
-
.map_err(|_| "mcp_handshake_image")?
|
|
348
|
-
!= receipt.server.identity.executable
|
|
349
|
-
{
|
|
330
|
+
if !Path::new(expected).is_absolute() {
|
|
350
331
|
return Err("mcp_handshake_image");
|
|
351
332
|
}
|
|
333
|
+
let expected = Path::new(expected)
|
|
334
|
+
.canonicalize()
|
|
335
|
+
.map_err(|_| "mcp_handshake_image")?;
|
|
352
336
|
let env = server_config
|
|
353
337
|
.get("env")
|
|
354
338
|
.ok_or("mcp_handshake_config_missing")?;
|
|
@@ -375,32 +359,99 @@ pub(crate) fn preflight(
|
|
|
375
359
|
.ok_or("mcp_handshake_carrier_missing")?;
|
|
376
360
|
let carrier_birth =
|
|
377
361
|
process_birth_identity(carrier).map_err(|_| "mcp_handshake_carrier_missing")?;
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
for ancestor in receipt.ancestors.iter().take(MAX_NATIVE_PARENT_HOPS) {
|
|
384
|
-
if ancestor.pid != parent
|
|
385
|
-
|| process_birth_identity(parent).ok().as_deref() != Some(ancestor.birth.as_str())
|
|
362
|
+
let admit = |receipt: &Handshake| -> Result<()> {
|
|
363
|
+
if receipt.schema != 1
|
|
364
|
+
|| receipt.workspace != workspace
|
|
365
|
+
|| receipt.owner != owner
|
|
366
|
+
|| receipt.agent != agent_id
|
|
386
367
|
{
|
|
368
|
+
return Err("mcp_handshake_scope_mismatch");
|
|
369
|
+
}
|
|
370
|
+
let started_at = DateTime::parse_from_rfc3339(&receipt.started_at)
|
|
371
|
+
.map_err(|_| "mcp_handshake_invalid")?;
|
|
372
|
+
let flushed_at = DateTime::parse_from_rfc3339(&receipt.flushed_at)
|
|
373
|
+
.map_err(|_| "mcp_handshake_invalid")?;
|
|
374
|
+
if started_at < spawned_at || flushed_at < started_at {
|
|
375
|
+
return Err("mcp_handshake_stale_spawn");
|
|
376
|
+
}
|
|
377
|
+
if receipt.server.identity.executable != expected {
|
|
378
|
+
return Err("mcp_handshake_image");
|
|
379
|
+
}
|
|
380
|
+
if sample_process(&receipt.server) != ProcessState::Alive {
|
|
381
|
+
return Err("mcp_handshake_server_not_live");
|
|
382
|
+
}
|
|
383
|
+
let mut parent = receipt.server.parent;
|
|
384
|
+
let mut matched = false;
|
|
385
|
+
for ancestor in receipt.ancestors.iter().take(MAX_NATIVE_PARENT_HOPS) {
|
|
386
|
+
if ancestor.pid != parent
|
|
387
|
+
|| process_birth_identity(parent).ok().as_deref() != Some(ancestor.birth.as_str())
|
|
388
|
+
{
|
|
389
|
+
return Err("mcp_handshake_ancestry");
|
|
390
|
+
}
|
|
391
|
+
if parent == carrier {
|
|
392
|
+
matched = true;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
parent = crate::platform::argv::parent_pid(parent).unwrap_or(0);
|
|
396
|
+
}
|
|
397
|
+
if !matched || sample_process(&receipt.server) != ProcessState::Alive {
|
|
387
398
|
return Err("mcp_handshake_ancestry");
|
|
388
399
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
400
|
+
Ok(())
|
|
401
|
+
};
|
|
402
|
+
// #372: admit the newest live receipt descended from this seat's pane.
|
|
403
|
+
// Receipts of foreign servers (inherited identity, other process trees)
|
|
404
|
+
// are dropped before any process probe; they cannot mask the seat's own.
|
|
405
|
+
let mut receipts: Vec<_> = receipt_paths(&dir, &key(owner, agent_id))
|
|
406
|
+
.into_iter()
|
|
407
|
+
.map(|path| read_receipt(&path))
|
|
408
|
+
.collect();
|
|
409
|
+
receipts.sort_by_key(|receipt| {
|
|
410
|
+
std::cmp::Reverse(
|
|
411
|
+
receipt
|
|
412
|
+
.as_ref()
|
|
413
|
+
.ok()
|
|
414
|
+
.and_then(|r| DateTime::parse_from_rfc3339(&r.started_at).ok()),
|
|
415
|
+
)
|
|
416
|
+
});
|
|
417
|
+
let (mut own_refusal, mut refusal) = (None, None);
|
|
418
|
+
for receipt in receipts {
|
|
419
|
+
let receipt = match receipt {
|
|
420
|
+
Ok(receipt) => receipt,
|
|
421
|
+
Err(reason) => {
|
|
422
|
+
refusal = refusal.or(Some(reason));
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
if !receipt.ancestors.iter().any(|ancestor| ancestor.pid == carrier) {
|
|
427
|
+
refusal = refusal.or(Some("mcp_handshake_ancestry"));
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
match admit(&receipt) {
|
|
431
|
+
Ok(()) => {
|
|
432
|
+
return Ok(Some(Admission {
|
|
433
|
+
server: receipt.server,
|
|
434
|
+
carrier,
|
|
435
|
+
carrier_birth,
|
|
436
|
+
pane_id: pane_id.to_string(),
|
|
437
|
+
}))
|
|
438
|
+
}
|
|
439
|
+
Err(reason) => own_refusal = own_refusal.or(Some(reason)),
|
|
392
440
|
}
|
|
393
|
-
parent = crate::platform::argv::parent_pid(parent).unwrap_or(0);
|
|
394
|
-
}
|
|
395
|
-
if !matched || sample_process(&receipt.server) != ProcessState::Alive {
|
|
396
|
-
return Err("mcp_handshake_ancestry");
|
|
397
441
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
442
|
+
Err(own_refusal.or(refusal).unwrap_or("mcp_handshake_missing"))
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/// Diagnostic only, never admission: live `mcp-server` processes under a pane.
|
|
446
|
+
pub(crate) fn live_servers_under(carrier: u32) -> Vec<u32> {
|
|
447
|
+
crate::platform::process::process_tree(carrier)
|
|
448
|
+
.unwrap_or_default()
|
|
449
|
+
.into_iter()
|
|
450
|
+
.filter(|pid| {
|
|
451
|
+
crate::platform::argv::argv_tokens(*pid)
|
|
452
|
+
.is_some_and(|argv| argv.iter().any(|arg| arg == "mcp-server"))
|
|
453
|
+
})
|
|
454
|
+
.collect()
|
|
404
455
|
}
|
|
405
456
|
|
|
406
457
|
/// Recheck against the actual resolved target immediately before the input path.
|
|
@@ -478,15 +529,15 @@ pub(crate) fn test_ready_worker(
|
|
|
478
529
|
pane_pid: Some(carrier),
|
|
479
530
|
leader_env: Default::default(),
|
|
480
531
|
};
|
|
481
|
-
|
|
482
|
-
|
|
532
|
+
// Like delivery, a provider without a worker handshake gate has nothing to revalidate.
|
|
533
|
+
if let Some(admission) = preflight(&workspace, Some(owner), agent, state).unwrap() {
|
|
534
|
+
revalidate(
|
|
535
|
+
&admission,
|
|
536
|
+
&Target::Pane(target.pane_id.clone()),
|
|
537
|
+
std::slice::from_ref(&target),
|
|
538
|
+
)
|
|
483
539
|
.unwrap();
|
|
484
|
-
|
|
485
|
-
&admission,
|
|
486
|
-
&Target::Pane(target.pane_id.clone()),
|
|
487
|
-
std::slice::from_ref(&target),
|
|
488
|
-
)
|
|
489
|
-
.unwrap();
|
|
540
|
+
}
|
|
490
541
|
target
|
|
491
542
|
}
|
|
492
543
|
|