@team-agent/installer 0.5.126 → 0.5.127
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 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/src/cli/diagnose.rs +0 -69
- package/crates/team-agent/src/cli/emit.rs +10 -9
- package/crates/team-agent/src/cli/grok_slot.rs +88 -3
- package/crates/team-agent/src/cli/intent/runtime.rs +6 -4
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +45 -0
- package/crates/team-agent/src/cli/mod.rs +13 -1
- package/crates/team-agent/src/cli/models.rs +27 -181
- package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
- package/crates/team-agent/src/cli/tests/mod.rs +2 -2
- package/crates/team-agent/src/cli/tests/run_delegation.rs +3 -3
- package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
- package/crates/team-agent/src/compiler/tests.rs +36 -9
- package/crates/team-agent/src/compiler.rs +3 -2
- package/crates/team-agent/src/contract_runtime/backend.rs +36 -0
- package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
- package/crates/team-agent/src/contract_runtime/config.rs +6 -5
- package/crates/team-agent/src/contract_runtime/framework.rs +2 -5
- package/crates/team-agent/src/contract_runtime/registry.rs +66 -67
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +27 -10
- package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -2
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
- package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +17 -185
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +4 -487
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +8 -21
- package/crates/team-agent/src/lifecycle/launch.rs +3 -11
- package/crates/team-agent/src/lifecycle/profile_launch.rs +8 -64
- package/crates/team-agent/src/lifecycle/restart/common.rs +6 -151
- package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +40 -13
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +37 -240
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +95 -59
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +20 -35
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +22 -48
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +6 -124
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +136 -256
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1374
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +5 -5
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +70 -15
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +35 -35
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +36 -82
- package/crates/team-agent/src/lifecycle/tests.rs +0 -4
- package/crates/team-agent/src/lifecycle/types.rs +2 -5
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
- package/crates/team-agent/src/messaging/delivery.rs +9 -61
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +67 -68
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/messaging/tests/runtime.rs +5 -5
- package/crates/team-agent/src/messaging/tests/spine.rs +5 -1
- package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
- package/crates/team-agent/src/provider/adapter.rs +58 -356
- package/crates/team-agent/src/provider/adapters/mod.rs +5 -7
- package/crates/team-agent/src/provider/session/capture.rs +5 -105
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -20
- package/crates/team-agent/src/provider/session/context_fork.rs +23 -142
- package/crates/team-agent/src/provider/session/mod.rs +2 -3
- package/crates/team-agent/src/provider/session_scan/common.rs +21 -57
- package/crates/team-agent/src/provider/session_scan.rs +6 -16
- package/crates/team-agent/src/provider/tests/adapter.rs +37 -118
- package/crates/team-agent/src/provider/tests/command_helpers.rs +1 -18
- package/crates/team-agent/src/provider/tests/idle.rs +0 -43
- package/crates/team-agent/src/provider/types.rs +0 -4
- package/crates/team-agent/src/provider/wire.rs +34 -8
- package/crates/team-agent/src/tmux_backend.rs +4 -3
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +3 -2
- package/skills/team-agent/command-coverage.json +14 -0
- package/skills/team-agent/docs/reference/team-agent-operator.md +3 -1
- package/skills/team-agent/references/team-agent-operator.md +3 -1
- package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
- package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
- package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
- package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
- package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
- package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
- package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
- package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
- package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
|
@@ -1,91 +1,32 @@
|
|
|
1
1
|
//! ---
|
|
2
|
-
//! purpose: legacy
|
|
2
|
+
//! purpose: legacy 席位的 fork 入口;legacy 席位一律拒绝,新席位 fork 只走 contract 管道
|
|
3
3
|
//! contract:
|
|
4
4
|
//! provides:
|
|
5
5
|
//! - name: fork_agent_with_transport
|
|
6
|
-
//! what:
|
|
7
|
-
//! - name: in_window_fork
|
|
8
|
-
//! what: 已验证的 provider+subscription 给出 command+screen_mark;未验证返回 None
|
|
6
|
+
//! what: 持席位生命周期锁读取源席;升级前遗留的 claude/codex/grok/pi worker 行按退役拒绝,其余 legacy provider 报未验证
|
|
9
7
|
//! depends:
|
|
10
8
|
//! - crate::lifecycle::lock
|
|
11
|
-
//! - crate::lifecycle::pane_input_lock
|
|
12
|
-
//! - crate::lifecycle::profile_launch
|
|
13
|
-
//! - crate::transport::Transport
|
|
14
9
|
//! boundary:
|
|
15
|
-
//! - 新席位 fork 只由 contract_runtime::fork
|
|
16
|
-
//! -
|
|
17
|
-
//! - 重试只重按回车,不重粘 /fork
|
|
18
|
-
//! - 不把 pane 锁超时从 200ms 调大
|
|
10
|
+
//! - 新席位 fork 只由 contract_runtime::fork 管道完成,这里不注册新席位、不注入窗口
|
|
11
|
+
//! - 不 spawn pane,不改 TEAM_AGENT_ID / MCP / 席位名
|
|
19
12
|
//! - 未验证的 provider 不猜斜杠命令
|
|
20
13
|
//! maturity: wired
|
|
21
14
|
//! ---
|
|
22
15
|
|
|
23
16
|
use super::*;
|
|
24
|
-
use crate::lifecycle::pane_input_lock::{
|
|
25
|
-
acquire_or_proceed, PaneInputLockRequest, PANE_INPUT_LOCK_TIMEOUT_EVENT,
|
|
26
|
-
};
|
|
27
|
-
use crate::lifecycle::profile_launch::{parse_auth_mode, parse_provider};
|
|
28
|
-
use crate::model::enums::{AuthMode, Provider};
|
|
29
|
-
|
|
30
|
-
const MAX_ENTER_RETRIES: u32 = 8;
|
|
31
|
-
|
|
32
|
-
/// Injected slash command + the screen mark that proves it landed.
|
|
33
|
-
/// Difference between providers lives only in this data.
|
|
34
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
35
|
-
pub struct InWindowFork {
|
|
36
|
-
pub command: &'static str,
|
|
37
|
-
pub screen_mark: &'static str,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/// ---
|
|
41
|
-
/// purpose: 给出该 provider 与鉴权方式下窗口内 fork 用的斜杠命令与成功标记
|
|
42
|
-
/// returns: 已实测验证的组合返回命令与屏幕标记,其余一律 None
|
|
43
|
-
/// ---
|
|
44
|
-
/// Official in-window fork. None = unverified or unsupported-auth.
|
|
45
|
-
/// grok `/fork` mark `forked from` (2026-08-17).
|
|
46
|
-
/// Claude's `/branch` is retired here: it moves the SOURCE process onto the
|
|
47
|
-
/// branch (renamed "<title> (Branch)") while the seat's captured tuple still
|
|
48
|
-
/// names the old session, and creates no seat. Claude Code and Pi fork only
|
|
49
|
-
/// into a new seat through the contract pipeline (`contract_runtime::fork`).
|
|
50
|
-
pub fn in_window_fork(provider: Provider, auth: AuthMode) -> Option<InWindowFork> {
|
|
51
|
-
match (provider, auth) {
|
|
52
|
-
(Provider::Grok, AuthMode::Subscription) => Some(InWindowFork {
|
|
53
|
-
command: "/fork",
|
|
54
|
-
screen_mark: "forked from",
|
|
55
|
-
}),
|
|
56
|
-
_ => None,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/// ---
|
|
61
|
-
/// purpose: 只取窗口内 fork 的斜杠命令
|
|
62
|
-
/// returns: 有已验证组合时返回命令,否则 None
|
|
63
|
-
/// ---
|
|
64
|
-
pub fn in_window_fork_command(provider: Provider, auth: AuthMode) -> Option<&'static str> {
|
|
65
|
-
in_window_fork(provider, auth).map(|spec| spec.command)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
fn refuse_missing_in_window_fork(provider: Provider, provider_raw: &str) -> LifecycleError {
|
|
69
|
-
if matches!(provider, Provider::Grok | Provider::Pi) {
|
|
70
|
-
LifecycleError::Provider(format!(
|
|
71
|
-
"{provider_raw} does not support native session fork"
|
|
72
|
-
))
|
|
73
|
-
} else {
|
|
74
|
-
LifecycleError::Provider(format!(
|
|
75
|
-
"{provider_raw} in-window fork is unverified (未验证)"
|
|
76
|
-
))
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
17
|
|
|
80
18
|
/// ---
|
|
81
|
-
/// purpose:
|
|
19
|
+
/// purpose: legacy 席位的 fork:只读源席后拒绝,不做任何副作用
|
|
82
20
|
/// params:
|
|
83
21
|
/// source_agent_id: 被 fork 的席位
|
|
84
22
|
/// as_agent_id: 新席位名
|
|
85
|
-
/// transport: 目标 team 实际使用的 transport
|
|
86
|
-
/// returns:
|
|
87
|
-
/// errors: 选不到 team 返回 TeamSelect
|
|
23
|
+
/// transport: 目标 team 实际使用的 transport(legacy 席位不再注入)
|
|
24
|
+
/// returns: 不返回成功;contract 席位在此之前已由 contract 管道处理
|
|
25
|
+
/// errors: 选不到 team 返回 TeamSelect,退役 provider 行与其余 legacy provider 返回 Provider
|
|
88
26
|
/// ---
|
|
27
|
+
/// The Grok in-window `/fork` was the last legacy fork; Claude Code, Codex,
|
|
28
|
+
/// Grok and Pi fork only into a new seat through the contract pipeline
|
|
29
|
+
/// (`contract_runtime::fork`).
|
|
89
30
|
pub fn fork_agent_with_transport(
|
|
90
31
|
workspace: &Path,
|
|
91
32
|
source_agent_id: &AgentId,
|
|
@@ -95,6 +36,7 @@ pub fn fork_agent_with_transport(
|
|
|
95
36
|
team: Option<&str>,
|
|
96
37
|
transport: &dyn Transport,
|
|
97
38
|
) -> Result<ForkAgentReport, LifecycleError> {
|
|
39
|
+
let _ = (as_agent_id, label, open_display, transport);
|
|
98
40
|
let selected = crate::state::selector::resolve_active_team(
|
|
99
41
|
workspace,
|
|
100
42
|
team,
|
|
@@ -115,7 +57,6 @@ pub fn fork_agent_with_transport(
|
|
|
115
57
|
crate::state::selector::SelectorMode::RequireSpec,
|
|
116
58
|
)
|
|
117
59
|
.map_err(|e| LifecycleError::TeamSelect(e.to_string()))?;
|
|
118
|
-
let run_ws = selected.run_workspace.clone();
|
|
119
60
|
let agent = selected
|
|
120
61
|
.state
|
|
121
62
|
.get("agents")
|
|
@@ -127,124 +68,15 @@ pub fn fork_agent_with_transport(
|
|
|
127
68
|
.get("provider")
|
|
128
69
|
.and_then(serde_json::Value::as_str)
|
|
129
70
|
.unwrap_or("unknown");
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.unwrap_or("subscription");
|
|
134
|
-
// A pre-upgrade Claude Code or Pi row has no legacy runtime to fork from;
|
|
135
|
-
// contract seats fork through the contract pipeline before this point.
|
|
71
|
+
// A pre-upgrade Claude Code, Codex, Grok or Pi row has no legacy runtime
|
|
72
|
+
// to fork from; contract seats fork through the contract pipeline before
|
|
73
|
+
// this point.
|
|
136
74
|
if crate::provider::wire::is_retired_provider(provider_raw) {
|
|
137
75
|
return Err(LifecycleError::Provider(
|
|
138
76
|
crate::provider::wire::retired_provider_error(provider_raw).into(),
|
|
139
77
|
));
|
|
140
78
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
let auth = parse_auth_mode(auth_raw).unwrap_or(AuthMode::Subscription);
|
|
144
|
-
let Some(spec) = in_window_fork(provider, auth) else {
|
|
145
|
-
return Err(refuse_missing_in_window_fork(provider, provider_raw));
|
|
146
|
-
};
|
|
147
|
-
if as_agent_id.as_str() != source_agent_id.as_str() {
|
|
148
|
-
return Err(LifecycleError::RequirementUnmet(format!(
|
|
149
|
-
"in-place fork refuses --as {as_agent_id}: session stays on {source_agent_id}"
|
|
150
|
-
)));
|
|
151
|
-
}
|
|
152
|
-
let pane_raw = agent
|
|
153
|
-
.get("pane_id")
|
|
154
|
-
.and_then(serde_json::Value::as_str)
|
|
155
|
-
.filter(|s| !s.is_empty())
|
|
156
|
-
.ok_or_else(|| {
|
|
157
|
-
LifecycleError::RequirementUnmet(format!(
|
|
158
|
-
"source agent {source_agent_id} has no pane_id"
|
|
159
|
-
))
|
|
160
|
-
})?;
|
|
161
|
-
let target = Target::Pane(PaneId::new(pane_raw));
|
|
162
|
-
let lock = acquire_or_proceed(PaneInputLockRequest {
|
|
163
|
-
workspace: Some(&run_ws),
|
|
164
|
-
target_key: pane_raw,
|
|
165
|
-
operation: "fork-inject",
|
|
166
|
-
});
|
|
167
|
-
if lock.is_none() {
|
|
168
|
-
let _ = crate::event_log::EventLog::new(&run_ws).write(
|
|
169
|
-
PANE_INPUT_LOCK_TIMEOUT_EVENT,
|
|
170
|
-
serde_json::json!({
|
|
171
|
-
"during": "fork-inject",
|
|
172
|
-
"agent_id": source_agent_id.as_str(),
|
|
173
|
-
"pane_id": pane_raw,
|
|
174
|
-
"observed_at": chrono::Utc::now().to_rfc3339(),
|
|
175
|
-
}),
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
inject_clean_command(transport, &target, spec.command)?;
|
|
179
|
-
wait_for_screen_mark(transport, &target, spec.screen_mark)?;
|
|
180
|
-
drop(lock);
|
|
181
|
-
crate::event_log::EventLog::new(&run_ws)
|
|
182
|
-
.write(
|
|
183
|
-
"lifecycle.fork.in_place",
|
|
184
|
-
serde_json::json!({
|
|
185
|
-
"source_agent_id": source_agent_id.as_str(),
|
|
186
|
-
"agent_id": source_agent_id.as_str(),
|
|
187
|
-
"pane_id": pane_raw,
|
|
188
|
-
"command": spec.command,
|
|
189
|
-
"screen_mark": spec.screen_mark,
|
|
190
|
-
}),
|
|
191
|
-
)
|
|
192
|
-
.map_err(|e| LifecycleError::StatePersist(format!("fork audit write failed: {e}")))?;
|
|
193
|
-
Ok(ForkAgentReport {
|
|
194
|
-
source_agent_id: source_agent_id.clone(),
|
|
195
|
-
new_agent_id: source_agent_id.clone(),
|
|
196
|
-
env: AgentActionEnvelope {
|
|
197
|
-
agent_id: source_agent_id.clone(),
|
|
198
|
-
state_file: crate::state::persist::runtime_state_path(&run_ws),
|
|
199
|
-
coordinator_started: false,
|
|
200
|
-
},
|
|
201
|
-
session_id: None,
|
|
202
|
-
backing_state: ForkBackingState::Verified,
|
|
203
|
-
})
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
fn inject_clean_command(
|
|
207
|
-
transport: &dyn Transport,
|
|
208
|
-
target: &Target,
|
|
209
|
-
command: &str,
|
|
210
|
-
) -> Result<(), LifecycleError> {
|
|
211
|
-
transport
|
|
212
|
-
.inject(
|
|
213
|
-
target,
|
|
214
|
-
&crate::transport::InjectPayload::TextSkipConsumptionPoll(command.to_string()),
|
|
215
|
-
crate::transport::Key::Enter,
|
|
216
|
-
false,
|
|
217
|
-
)
|
|
218
|
-
.map_err(|e| LifecycleError::Transport(e.to_string()))?;
|
|
219
|
-
Ok(())
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const NO_CONVERSATION_TO_BRANCH: &str = "Failed to branch conversation: No conversation to branch";
|
|
223
|
-
|
|
224
|
-
fn wait_for_screen_mark(
|
|
225
|
-
transport: &dyn Transport,
|
|
226
|
-
target: &Target,
|
|
227
|
-
screen_mark: &str,
|
|
228
|
-
) -> Result<(), LifecycleError> {
|
|
229
|
-
for attempt in 0..MAX_ENTER_RETRIES {
|
|
230
|
-
let cap = transport
|
|
231
|
-
.capture(target, crate::transport::CaptureRange::Tail(40))
|
|
232
|
-
.map_err(|e| LifecycleError::Transport(e.to_string()))?;
|
|
233
|
-
if cap.text.contains(screen_mark) {
|
|
234
|
-
return Ok(());
|
|
235
|
-
}
|
|
236
|
-
if cap.text.contains(NO_CONVERSATION_TO_BRANCH) {
|
|
237
|
-
return Err(LifecycleError::RequirementUnmet(
|
|
238
|
-
NO_CONVERSATION_TO_BRANCH.to_string(),
|
|
239
|
-
));
|
|
240
|
-
}
|
|
241
|
-
if attempt + 1 < MAX_ENTER_RETRIES {
|
|
242
|
-
// Mixed text in the box is not failure. Retry Enter only — never re-paste the slash command.
|
|
243
|
-
let _ = transport.send_keys(target, &[crate::transport::Key::Enter]);
|
|
244
|
-
std::thread::sleep(std::time::Duration::from_millis(80));
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
Err(LifecycleError::RequirementUnmet(format!(
|
|
248
|
-
"fork inject did not produce {screen_mark:?} on screen"
|
|
79
|
+
Err(LifecycleError::Provider(format!(
|
|
80
|
+
"{provider_raw} native session fork is unverified (未验证); no legacy fork or fresh replacement was performed"
|
|
249
81
|
)))
|
|
250
82
|
}
|