@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
|
@@ -7,17 +7,36 @@ use team_agent_contract::contract::{
|
|
|
7
7
|
types::InstanceIdentity,
|
|
8
8
|
hooks::{PlanHook, ProviderHooks},
|
|
9
9
|
plan::{CatalogObservation, LaunchEntrypoint, LaunchPlan, ResolvedLaunch},
|
|
10
|
+
session::ResumeBinding,
|
|
10
11
|
types::{ContractError, NativeIdentity, Support},
|
|
11
12
|
};
|
|
12
13
|
use team_agent_contract::kiro::{self, KiroAdapter, KIRO_DESCRIPTOR};
|
|
14
|
+
use team_agent_contract::providers::claude::{self, ClaudeAdapter, CLAUDE_DESCRIPTOR};
|
|
15
|
+
use team_agent_contract::providers::codex::{self, CodexAdapter, CODEX_DESCRIPTOR};
|
|
13
16
|
use team_agent_contract::providers::cursor::{self, CursorAdapter, CURSOR_DESCRIPTOR};
|
|
14
17
|
use team_agent_contract::providers::grok_build::{self, GrokAdapter, GROK_BUILD_DESCRIPTOR};
|
|
18
|
+
use team_agent_contract::providers::pi::{self, PiAdapter, PI_DESCRIPTOR};
|
|
15
19
|
use team_agent_contract::runtime::{
|
|
16
20
|
delivery::{ControlDefinition, StartupDefinition},
|
|
17
21
|
native_panel::{NativePanelPolicy, SessionPanelPolicy},
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
const DESCRIPTORS: &[&ProviderDescriptor] = &[&KIRO_DESCRIPTOR, &CURSOR_DESCRIPTOR, &GROK_BUILD_DESCRIPTOR];
|
|
24
|
+
const DESCRIPTORS: &[&ProviderDescriptor] = &[&KIRO_DESCRIPTOR, &CURSOR_DESCRIPTOR, &GROK_BUILD_DESCRIPTOR, &CODEX_DESCRIPTOR, &PI_DESCRIPTOR, &CLAUDE_DESCRIPTOR];
|
|
25
|
+
/// Declared keys the legacy runtime also owns (the Codex worker, leader and
|
|
26
|
+
/// app-server). Only an explicit `contract_runtime: true` maps one to its leaf,
|
|
27
|
+
/// whose distinct canonical id is what compiled specs and state then carry, so
|
|
28
|
+
/// legacy readers never mistake a contract seat for a legacy one.
|
|
29
|
+
const OPT_IN: &[(&str, &ProviderDescriptor)] = &[("codex", &CODEX_DESCRIPTOR)];
|
|
30
|
+
/// Declaration names that select a leaf without opt-in: Cursor's legacy key,
|
|
31
|
+
/// its npm package/public command and its binary; Claude Code's and Pi's public
|
|
32
|
+
/// names (`pi` is also the default role provider). The leaf's distinct id is
|
|
33
|
+
/// what compiled specs and state carry. A persisted legacy state row keeps its
|
|
34
|
+
/// key and is never reclassified ([`descriptor`] does not match it).
|
|
35
|
+
const TRANSITION: &[(&str, &ProviderDescriptor)] = &[
|
|
36
|
+
("cursor_agent", &CURSOR_DESCRIPTOR), ("cursor-agent", &CURSOR_DESCRIPTOR), ("agent", &CURSOR_DESCRIPTOR),
|
|
37
|
+
("claude", &CLAUDE_DESCRIPTOR), ("claude_code", &CLAUDE_DESCRIPTOR), ("claude-code", &CLAUDE_DESCRIPTOR),
|
|
38
|
+
("pi", &PI_DESCRIPTOR),
|
|
39
|
+
];
|
|
21
40
|
|
|
22
41
|
/// One provider's public command route: the PATH-selected entry the pane execs
|
|
23
42
|
/// by bare name and the native image that route must exec into.
|
|
@@ -26,6 +45,9 @@ pub enum NativeRuntime {
|
|
|
26
45
|
Kiro(kiro::native::RuntimeInstallation),
|
|
27
46
|
Cursor(cursor::native::RuntimeInstallation),
|
|
28
47
|
GrokBuild(grok_build::native::RuntimeInstallation),
|
|
48
|
+
Codex(codex::launcher::RuntimeInstallation),
|
|
49
|
+
Pi(pi::launcher::RuntimeInstallation),
|
|
50
|
+
Claude(claude::launcher::RuntimeInstallation),
|
|
29
51
|
}
|
|
30
52
|
|
|
31
53
|
impl NativeRuntime {
|
|
@@ -34,6 +56,9 @@ impl NativeRuntime {
|
|
|
34
56
|
Self::Kiro(runtime) => runtime.launcher(),
|
|
35
57
|
Self::Cursor(runtime) => runtime.launcher(),
|
|
36
58
|
Self::GrokBuild(runtime) => runtime.launcher(),
|
|
59
|
+
Self::Codex(runtime) => runtime.launcher(),
|
|
60
|
+
Self::Pi(runtime) => runtime.launcher(),
|
|
61
|
+
Self::Claude(runtime) => runtime.launcher(),
|
|
37
62
|
}
|
|
38
63
|
}
|
|
39
64
|
|
|
@@ -42,6 +67,9 @@ impl NativeRuntime {
|
|
|
42
67
|
Self::Kiro(runtime) => &runtime.engine,
|
|
43
68
|
Self::Cursor(runtime) => &runtime.engine,
|
|
44
69
|
Self::GrokBuild(runtime) => &runtime.engine,
|
|
70
|
+
Self::Codex(runtime) => &runtime.engine,
|
|
71
|
+
Self::Pi(runtime) => &runtime.engine,
|
|
72
|
+
Self::Claude(runtime) => &runtime.engine,
|
|
45
73
|
}
|
|
46
74
|
}
|
|
47
75
|
|
|
@@ -50,6 +78,9 @@ impl NativeRuntime {
|
|
|
50
78
|
Self::Kiro(runtime) => &runtime.native,
|
|
51
79
|
Self::Cursor(runtime) => &runtime.native,
|
|
52
80
|
Self::GrokBuild(runtime) => &runtime.native,
|
|
81
|
+
Self::Codex(runtime) => &runtime.native,
|
|
82
|
+
Self::Pi(runtime) => &runtime.native,
|
|
83
|
+
Self::Claude(runtime) => &runtime.native,
|
|
53
84
|
}
|
|
54
85
|
}
|
|
55
86
|
|
|
@@ -58,6 +89,9 @@ impl NativeRuntime {
|
|
|
58
89
|
Self::Kiro(runtime) => runtime.bind_catalog(catalog),
|
|
59
90
|
Self::Cursor(runtime) => runtime.bind_catalog(catalog),
|
|
60
91
|
Self::GrokBuild(runtime) => runtime.bind_catalog(catalog),
|
|
92
|
+
Self::Codex(runtime) => runtime.bind_catalog(catalog),
|
|
93
|
+
Self::Pi(runtime) => runtime.bind_catalog(catalog),
|
|
94
|
+
Self::Claude(runtime) => runtime.bind_catalog(catalog),
|
|
61
95
|
}
|
|
62
96
|
}
|
|
63
97
|
}
|
|
@@ -68,6 +102,9 @@ pub(super) enum NativeProvider {
|
|
|
68
102
|
Kiro,
|
|
69
103
|
Cursor,
|
|
70
104
|
GrokBuild,
|
|
105
|
+
Codex,
|
|
106
|
+
Pi,
|
|
107
|
+
Claude,
|
|
71
108
|
}
|
|
72
109
|
|
|
73
110
|
impl NativeProvider {
|
|
@@ -76,13 +113,16 @@ impl NativeProvider {
|
|
|
76
113
|
Self::Kiro => &KIRO_DESCRIPTOR,
|
|
77
114
|
Self::Cursor => &CURSOR_DESCRIPTOR,
|
|
78
115
|
Self::GrokBuild => &GROK_BUILD_DESCRIPTOR,
|
|
116
|
+
Self::Codex => &CODEX_DESCRIPTOR,
|
|
117
|
+
Self::Pi => &PI_DESCRIPTOR,
|
|
118
|
+
Self::Claude => &CLAUDE_DESCRIPTOR,
|
|
79
119
|
}
|
|
80
120
|
}
|
|
81
121
|
|
|
82
122
|
pub fn action_budget(self) -> std::time::Duration {
|
|
83
123
|
// Kiro's existing budget is unchanged; Cursor's measured cold-ready
|
|
84
124
|
// path needs a larger finite bound, not an unbounded readiness wait.
|
|
85
|
-
std::time::Duration::from_secs(match self { Self::Kiro => 30, Self::Cursor | Self::GrokBuild => 90 })
|
|
125
|
+
std::time::Duration::from_secs(match self { Self::Kiro => 30, Self::Cursor | Self::GrokBuild | Self::Codex | Self::Pi | Self::Claude => 90 })
|
|
86
126
|
}
|
|
87
127
|
|
|
88
128
|
pub fn controls(self) -> &'static [ControlDefinition] {
|
|
@@ -90,6 +130,9 @@ impl NativeProvider {
|
|
|
90
130
|
Self::Kiro => kiro::interaction::CONTROLS,
|
|
91
131
|
Self::Cursor => cursor::interaction::CONTROLS,
|
|
92
132
|
Self::GrokBuild => grok_build::interaction::CONTROLS,
|
|
133
|
+
Self::Codex => codex::interaction::CONTROLS,
|
|
134
|
+
Self::Pi => pi::interaction::CONTROLS,
|
|
135
|
+
Self::Claude => claude::interaction::CONTROLS,
|
|
93
136
|
}
|
|
94
137
|
}
|
|
95
138
|
|
|
@@ -102,20 +145,23 @@ impl NativeProvider {
|
|
|
102
145
|
/// These providers use the separately fenced native tool-roundtrip ledger,
|
|
103
146
|
/// never a guessed neutral tools panel or another provider's inspector.
|
|
104
147
|
pub fn uses_tool_roundtrips(self) -> bool {
|
|
105
|
-
matches!(self, Self::Cursor | Self::GrokBuild)
|
|
148
|
+
matches!(self, Self::Cursor | Self::GrokBuild | Self::Codex | Self::Pi | Self::Claude)
|
|
106
149
|
}
|
|
107
150
|
|
|
108
151
|
pub fn startup(self) -> Option<&'static StartupDefinition> {
|
|
109
152
|
match self {
|
|
110
153
|
Self::GrokBuild => Some(&grok_build::interaction::STARTUP),
|
|
111
|
-
|
|
154
|
+
// Claude's folder-trust screen is never answered (focus: No, exit).
|
|
155
|
+
Self::Kiro | Self::Cursor | Self::Codex | Self::Pi | Self::Claude => None,
|
|
112
156
|
}
|
|
113
157
|
}
|
|
114
158
|
|
|
115
159
|
pub fn session_panel(self) -> Option<&'static SessionPanelPolicy> {
|
|
116
160
|
match self {
|
|
117
161
|
Self::GrokBuild => Some(&grok_build::interaction::SESSION_PANEL),
|
|
118
|
-
|
|
162
|
+
// `/status` and `/session` print history cards, not modals: nothing to close.
|
|
163
|
+
// Claude's fresh session ID is preassigned by argv; nothing to close.
|
|
164
|
+
Self::Kiro | Self::Cursor | Self::Codex | Self::Pi | Self::Claude => None,
|
|
119
165
|
}
|
|
120
166
|
}
|
|
121
167
|
|
|
@@ -130,14 +176,44 @@ impl NativeProvider {
|
|
|
130
176
|
field: "Grok Build native Team-tool inspector",
|
|
131
177
|
reason: grok_build::UNVERIFIED,
|
|
132
178
|
}),
|
|
179
|
+
Self::Codex => Err(ContractError::Unverified {
|
|
180
|
+
field: "Codex native Team-tool inspector",
|
|
181
|
+
reason: codex::UNVERIFIED,
|
|
182
|
+
}),
|
|
183
|
+
Self::Pi => Err(ContractError::Unverified {
|
|
184
|
+
field: "Pi native Team-tool inspector",
|
|
185
|
+
reason: pi::UNVERIFIED,
|
|
186
|
+
}),
|
|
187
|
+
Self::Claude => Err(ContractError::Unverified {
|
|
188
|
+
field: "Claude Code native Team-tool inspector",
|
|
189
|
+
reason: claude::UNVERIFIED,
|
|
190
|
+
}),
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/// The exact local backing a native new-seat fork reads, for a leaf that
|
|
195
|
+
/// addresses its parent by path (Claude's transcript). None: the native
|
|
196
|
+
/// CLI resolves the parent by ID itself. Pure; the caller checks the file.
|
|
197
|
+
pub fn native_fork_source(
|
|
198
|
+
self,
|
|
199
|
+
runtime: Option<&NativeRuntime>,
|
|
200
|
+
source: &ResumeBinding,
|
|
201
|
+
) -> Result<Option<PathBuf>, ContractError> {
|
|
202
|
+
match (self, runtime) {
|
|
203
|
+
(Self::Claude, Some(NativeRuntime::Claude(runtime))) => claude::transcript_path(runtime.home(), source).map(Some),
|
|
204
|
+
(Self::Claude, _) => Err(ContractError::Mismatch("native runtime provider")),
|
|
205
|
+
_ => Ok(None),
|
|
133
206
|
}
|
|
134
207
|
}
|
|
135
208
|
|
|
136
209
|
pub fn server_key_for(self, identity: &InstanceIdentity) -> Result<String, ContractError> {
|
|
137
|
-
|
|
138
|
-
|
|
210
|
+
match self {
|
|
211
|
+
Self::GrokBuild => Ok(grok_build::server_key(identity)),
|
|
212
|
+
Self::Codex => Ok(codex::server_key(identity)),
|
|
213
|
+
Self::Pi => Ok(pi::server_key(identity)),
|
|
214
|
+
Self::Claude => Ok(claude::server_key(identity)),
|
|
215
|
+
Self::Kiro | Self::Cursor => Ok(self.server_key()?.into()),
|
|
139
216
|
}
|
|
140
|
-
Ok(self.server_key()?.into())
|
|
141
217
|
}
|
|
142
218
|
|
|
143
219
|
pub fn server_key(self) -> Result<&'static str, ContractError> {
|
|
@@ -163,6 +239,15 @@ impl NativeProvider {
|
|
|
163
239
|
Self::GrokBuild => GrokAdapter::new(grok_build::McpStdio {
|
|
164
240
|
executable, arguments, environment,
|
|
165
241
|
}).map(NativeAdapter::GrokBuild),
|
|
242
|
+
Self::Codex => CodexAdapter::new(codex::McpStdio {
|
|
243
|
+
executable, arguments, environment,
|
|
244
|
+
}).map(NativeAdapter::Codex),
|
|
245
|
+
Self::Pi => PiAdapter::new(pi::McpStdio {
|
|
246
|
+
executable, arguments, environment,
|
|
247
|
+
}).map(NativeAdapter::Pi),
|
|
248
|
+
Self::Claude => ClaudeAdapter::new(claude::McpStdio {
|
|
249
|
+
executable, arguments, environment,
|
|
250
|
+
}).map(NativeAdapter::Claude),
|
|
166
251
|
}
|
|
167
252
|
}
|
|
168
253
|
}
|
|
@@ -171,6 +256,9 @@ pub(super) enum NativeAdapter {
|
|
|
171
256
|
Kiro(KiroAdapter),
|
|
172
257
|
Cursor(CursorAdapter),
|
|
173
258
|
GrokBuild(GrokAdapter),
|
|
259
|
+
Codex(CodexAdapter),
|
|
260
|
+
Pi(PiAdapter),
|
|
261
|
+
Claude(ClaudeAdapter),
|
|
174
262
|
}
|
|
175
263
|
|
|
176
264
|
impl NativeAdapter {
|
|
@@ -199,6 +287,30 @@ impl NativeAdapter {
|
|
|
199
287
|
None => adapter,
|
|
200
288
|
}))
|
|
201
289
|
}
|
|
290
|
+
Self::Codex(adapter) => {
|
|
291
|
+
let adapter = adapter.with_project(project)?;
|
|
292
|
+
Ok(Self::Codex(match runtime {
|
|
293
|
+
Some(NativeRuntime::Codex(runtime)) => adapter.with_runtime(runtime),
|
|
294
|
+
Some(_) => return Err(ContractError::Mismatch("native runtime provider")),
|
|
295
|
+
None => adapter,
|
|
296
|
+
}))
|
|
297
|
+
}
|
|
298
|
+
Self::Pi(adapter) => {
|
|
299
|
+
let adapter = adapter.with_project(project)?;
|
|
300
|
+
Ok(Self::Pi(match runtime {
|
|
301
|
+
Some(NativeRuntime::Pi(runtime)) => adapter.with_runtime(runtime),
|
|
302
|
+
Some(_) => return Err(ContractError::Mismatch("native runtime provider")),
|
|
303
|
+
None => adapter,
|
|
304
|
+
}))
|
|
305
|
+
}
|
|
306
|
+
Self::Claude(adapter) => {
|
|
307
|
+
let adapter = adapter.with_project(project)?;
|
|
308
|
+
Ok(Self::Claude(match runtime {
|
|
309
|
+
Some(NativeRuntime::Claude(runtime)) => adapter.with_runtime(runtime),
|
|
310
|
+
Some(_) => return Err(ContractError::Mismatch("native runtime provider")),
|
|
311
|
+
None => adapter,
|
|
312
|
+
}))
|
|
313
|
+
}
|
|
202
314
|
}
|
|
203
315
|
}
|
|
204
316
|
|
|
@@ -207,6 +319,9 @@ impl NativeAdapter {
|
|
|
207
319
|
Self::Kiro(adapter) => adapter.hooks(),
|
|
208
320
|
Self::Cursor(adapter) => adapter.hooks(),
|
|
209
321
|
Self::GrokBuild(adapter) => adapter.hooks(),
|
|
322
|
+
Self::Codex(adapter) => adapter.hooks(),
|
|
323
|
+
Self::Pi(adapter) => adapter.hooks(),
|
|
324
|
+
Self::Claude(adapter) => adapter.hooks(),
|
|
210
325
|
}
|
|
211
326
|
}
|
|
212
327
|
|
|
@@ -215,6 +330,9 @@ impl NativeAdapter {
|
|
|
215
330
|
Self::Kiro(adapter) => adapter.plan(request),
|
|
216
331
|
Self::Cursor(adapter) => adapter.plan(request),
|
|
217
332
|
Self::GrokBuild(adapter) => adapter.plan(request),
|
|
333
|
+
Self::Codex(adapter) => adapter.plan(request),
|
|
334
|
+
Self::Pi(adapter) => adapter.plan(request),
|
|
335
|
+
Self::Claude(adapter) => adapter.plan(request),
|
|
218
336
|
}
|
|
219
337
|
}
|
|
220
338
|
}
|
|
@@ -225,6 +343,9 @@ pub(super) fn provider(key: &str) -> Result<NativeProvider, ContractError> {
|
|
|
225
343
|
"kiro" => Ok(NativeProvider::Kiro),
|
|
226
344
|
"cursor" => Ok(NativeProvider::Cursor),
|
|
227
345
|
"grok_build" => Ok(NativeProvider::GrokBuild),
|
|
346
|
+
"codex_tui" => Ok(NativeProvider::Codex),
|
|
347
|
+
"pi_tui" => Ok(NativeProvider::Pi),
|
|
348
|
+
"claude_tui" => Ok(NativeProvider::Claude),
|
|
228
349
|
_ => Err(ContractError::Invalid("contract provider dispatcher")),
|
|
229
350
|
}
|
|
230
351
|
}
|
|
@@ -239,18 +360,43 @@ pub fn descriptor(key: &str) -> Option<&'static ProviderDescriptor> {
|
|
|
239
360
|
})
|
|
240
361
|
}
|
|
241
362
|
|
|
363
|
+
/// The leaf a role document selects. Canonical contract keys and transition
|
|
364
|
+
/// names (Cursor, Claude Code, Pi) need no flag; the shared legacy `codex` key
|
|
365
|
+
/// selects its leaf only with `contract_runtime: true` and is otherwise left to
|
|
366
|
+
/// the legacy path unchanged (never re-routed).
|
|
367
|
+
pub fn declared(key: &str, contract_runtime: bool) -> Option<&'static ProviderDescriptor> {
|
|
368
|
+
OPT_IN.iter().find(|(shared, _)| contract_runtime && *shared == key)
|
|
369
|
+
.or_else(|| TRANSITION.iter().find(|(retired, _)| *retired == key))
|
|
370
|
+
.map(|(_, descriptor)| *descriptor)
|
|
371
|
+
.or_else(|| descriptor(key))
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/// The provider name a generated role document records for a leaf. Claude
|
|
375
|
+
/// Code and Pi keep their public command names (`claude`, `pi`), which declare
|
|
376
|
+
/// the leaf; every other leaf is named by its canonical id.
|
|
377
|
+
pub fn public_name(descriptor: &ProviderDescriptor) -> &'static str {
|
|
378
|
+
match descriptor.identity.id {
|
|
379
|
+
"claude_tui" => "claude",
|
|
380
|
+
"pi_tui" => "pi",
|
|
381
|
+
id => id,
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
242
385
|
/// Recognize a misspelled/case-modified contract declaration so it can fail
|
|
243
386
|
/// explicitly instead of accidentally selecting a legacy default provider.
|
|
244
|
-
|
|
387
|
+
/// A shared legacy key is a contract declaration only when opted in.
|
|
388
|
+
pub fn recognizes(key: &str, contract_runtime: bool) -> bool {
|
|
245
389
|
let key = key.trim();
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
390
|
+
(contract_runtime && OPT_IN.iter().any(|(shared, _)| shared.eq_ignore_ascii_case(key)))
|
|
391
|
+
|| TRANSITION.iter().any(|(retired, _)| retired.eq_ignore_ascii_case(key))
|
|
392
|
+
|| DESCRIPTORS.iter().any(|descriptor| {
|
|
393
|
+
descriptor.identity.id.eq_ignore_ascii_case(key)
|
|
394
|
+
|| descriptor
|
|
395
|
+
.identity
|
|
396
|
+
.aliases
|
|
397
|
+
.iter()
|
|
398
|
+
.any(|alias| alias.eq_ignore_ascii_case(key))
|
|
399
|
+
})
|
|
254
400
|
}
|
|
255
401
|
|
|
256
402
|
#[cfg(test)]
|
|
@@ -261,22 +407,154 @@ mod tests {
|
|
|
261
407
|
fn canonical_cursor_does_not_reclassify_legacy_names() {
|
|
262
408
|
assert_eq!(provider("cursor").unwrap(), NativeProvider::Cursor);
|
|
263
409
|
assert_eq!(provider("kiro").unwrap(), NativeProvider::Kiro);
|
|
264
|
-
for legacy in ["
|
|
410
|
+
for legacy in ["codex", "grok"] {
|
|
411
|
+
assert!(descriptor(legacy).is_none());
|
|
412
|
+
assert!(!recognizes(legacy, false));
|
|
413
|
+
assert!(provider(legacy).is_err());
|
|
414
|
+
}
|
|
415
|
+
// Every Cursor name declares the leaf; a persisted legacy row keeps its runtime.
|
|
416
|
+
for name in ["cursor", "cursor_agent", "cursor-agent", "agent"] {
|
|
417
|
+
assert_eq!(declared(name, false).unwrap().identity.id, "cursor");
|
|
418
|
+
assert_eq!(declared(name, true).unwrap().identity.id, "cursor");
|
|
419
|
+
}
|
|
420
|
+
for legacy in ["cursor_agent", "cursor-agent", "agent"] {
|
|
265
421
|
assert!(descriptor(legacy).is_none());
|
|
266
|
-
assert!(!recognizes(legacy));
|
|
267
422
|
assert!(provider(legacy).is_err());
|
|
268
423
|
}
|
|
424
|
+
assert!(recognizes(" Cursor_Agent ", false));
|
|
425
|
+
assert!(declared("Cursor_Agent", false).is_none());
|
|
269
426
|
assert_eq!(provider("grok_build").unwrap(), NativeProvider::GrokBuild);
|
|
270
|
-
assert!(recognizes(" Grok_Build "));
|
|
427
|
+
assert!(recognizes(" Grok_Build ", false));
|
|
271
428
|
assert!(descriptor("Grok_Build").is_none());
|
|
272
429
|
assert!(GROK_BUILD_DESCRIPTOR.identity.aliases.is_empty());
|
|
273
|
-
assert!(recognizes(" Cursor "));
|
|
430
|
+
assert!(recognizes(" Cursor ", false));
|
|
274
431
|
assert!(descriptor("Cursor").is_none());
|
|
275
432
|
for descriptor in descriptors() {
|
|
276
433
|
assert_eq!(provider(descriptor.identity.id).unwrap().descriptor(), *descriptor);
|
|
277
434
|
}
|
|
278
435
|
}
|
|
279
436
|
|
|
437
|
+
#[test]
|
|
438
|
+
fn bare_codex_keeps_its_legacy_meaning_and_only_opt_in_selects_the_leaf() {
|
|
439
|
+
assert_eq!(CODEX_DESCRIPTOR.identity.id, "codex_tui");
|
|
440
|
+
assert_eq!(CODEX_DESCRIPTOR.identity.binary, "codex");
|
|
441
|
+
assert_eq!(provider("codex_tui").unwrap(), NativeProvider::Codex);
|
|
442
|
+
// Legacy state rows, compiled specs and CLI overrides keep `codex`.
|
|
443
|
+
assert!(descriptor("codex").is_none());
|
|
444
|
+
assert!(provider("codex").is_err());
|
|
445
|
+
assert!(declared("codex", false).is_none());
|
|
446
|
+
assert_eq!(declared("codex", true), Some(&CODEX_DESCRIPTOR));
|
|
447
|
+
assert_eq!(declared("codex_tui", false), Some(&CODEX_DESCRIPTOR));
|
|
448
|
+
for spelling in ["codex", " Codex ", "CODEX"] {
|
|
449
|
+
assert!(!recognizes(spelling, false), "{spelling:?}");
|
|
450
|
+
assert!(recognizes(spelling, true), "{spelling:?}");
|
|
451
|
+
}
|
|
452
|
+
// A case variant opted in is recognized (to fail explicitly), never selected.
|
|
453
|
+
assert!(declared("Codex", true).is_none());
|
|
454
|
+
assert_eq!(declared("claude", true), Some(&CLAUDE_DESCRIPTOR));
|
|
455
|
+
assert_eq!(declared("grok_build", true), Some(&GROK_BUILD_DESCRIPTOR));
|
|
456
|
+
let mut identity = InstanceIdentity {
|
|
457
|
+
scope: team_agent_contract::contract::types::ScopeId::new("scope").unwrap(),
|
|
458
|
+
seat: team_agent_contract::contract::types::SeatId::new("worker").unwrap(),
|
|
459
|
+
instance: team_agent_contract::contract::types::InstanceId::new("instance").unwrap(),
|
|
460
|
+
generation: team_agent_contract::contract::types::Generation(1),
|
|
461
|
+
};
|
|
462
|
+
let first = NativeProvider::Codex.server_key_for(&identity).unwrap();
|
|
463
|
+
assert_eq!(first, codex::server_key(&identity));
|
|
464
|
+
assert_ne!(first, grok_build::server_key(&identity));
|
|
465
|
+
identity.generation = team_agent_contract::contract::types::Generation(2);
|
|
466
|
+
assert_ne!(first, NativeProvider::Codex.server_key_for(&identity).unwrap());
|
|
467
|
+
assert!(NativeProvider::Codex.tool_panel().is_err());
|
|
468
|
+
assert!(NativeProvider::Codex.startup().is_none());
|
|
469
|
+
assert!(NativeProvider::Codex.session_panel().is_none());
|
|
470
|
+
assert!(NativeProvider::Codex.uses_tool_roundtrips());
|
|
471
|
+
assert!(NativeProvider::Codex.first_business_bootstrap());
|
|
472
|
+
let kinds: Vec<_> = NativeProvider::Codex.controls().iter().map(|control| control.command).collect();
|
|
473
|
+
assert_eq!(kinds, ["/status", "/exit"]);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
#[test]
|
|
477
|
+
fn claude_leaf_has_a_distinct_key_and_no_startup_or_panel_fallback() {
|
|
478
|
+
use team_agent_contract::contract::types::{Generation, InstanceId, ScopeId, SeatId};
|
|
479
|
+
assert_eq!(CLAUDE_DESCRIPTOR.identity.id, "claude_tui");
|
|
480
|
+
assert_eq!(CLAUDE_DESCRIPTOR.identity.binary, "claude");
|
|
481
|
+
assert_eq!(provider("claude_tui").unwrap(), NativeProvider::Claude);
|
|
482
|
+
assert_eq!(declared("claude_tui", false), Some(&CLAUDE_DESCRIPTOR));
|
|
483
|
+
// Every public Claude name declares the leaf, with or without opt-in;
|
|
484
|
+
// a persisted legacy row keeps its key and is never reclassified.
|
|
485
|
+
for name in ["claude", "claude_code", "claude-code"] {
|
|
486
|
+
assert_eq!(declared(name, false), Some(&CLAUDE_DESCRIPTOR), "{name}");
|
|
487
|
+
assert_eq!(declared(name, true), Some(&CLAUDE_DESCRIPTOR), "{name}");
|
|
488
|
+
assert!(recognizes(name, false), "{name}");
|
|
489
|
+
assert!(descriptor(name).is_none(), "{name}");
|
|
490
|
+
assert!(provider(name).is_err(), "{name}");
|
|
491
|
+
}
|
|
492
|
+
assert!(declared("Claude", false).is_none());
|
|
493
|
+
assert_eq!(public_name(&CLAUDE_DESCRIPTOR), "claude");
|
|
494
|
+
assert_eq!(declared(public_name(&CLAUDE_DESCRIPTOR), false), Some(&CLAUDE_DESCRIPTOR));
|
|
495
|
+
assert!(recognizes(" Claude ", false));
|
|
496
|
+
assert!(recognizes(" Claude_TUI ", false));
|
|
497
|
+
let mut identity = InstanceIdentity {
|
|
498
|
+
scope: ScopeId::new("scope").unwrap(), seat: SeatId::new("worker").unwrap(),
|
|
499
|
+
instance: InstanceId::new("instance").unwrap(), generation: Generation(1),
|
|
500
|
+
};
|
|
501
|
+
let first = NativeProvider::Claude.server_key_for(&identity).unwrap();
|
|
502
|
+
assert_eq!(first, claude::server_key(&identity));
|
|
503
|
+
assert_ne!(first, grok_build::server_key(&identity));
|
|
504
|
+
assert_ne!(first, codex::server_key(&identity));
|
|
505
|
+
assert_ne!(first, pi::server_key(&identity));
|
|
506
|
+
identity.generation = Generation(2);
|
|
507
|
+
assert_ne!(first, NativeProvider::Claude.server_key_for(&identity).unwrap());
|
|
508
|
+
assert!(NativeProvider::Claude.server_key().is_err());
|
|
509
|
+
assert!(NativeProvider::Claude.tool_panel().is_err());
|
|
510
|
+
assert!(NativeProvider::Claude.startup().is_none(), "folder trust is never keyed");
|
|
511
|
+
assert!(NativeProvider::Claude.session_panel().is_none());
|
|
512
|
+
assert!(NativeProvider::Claude.uses_tool_roundtrips());
|
|
513
|
+
assert!(NativeProvider::Claude.first_business_bootstrap());
|
|
514
|
+
let kinds: Vec<_> = NativeProvider::Claude.controls().iter().map(|control| control.command).collect();
|
|
515
|
+
assert_eq!(kinds, ["/exit"]);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
#[test]
|
|
519
|
+
fn bare_pi_selects_the_leaf_and_a_legacy_row_is_never_reclassified() {
|
|
520
|
+
use team_agent_contract::contract::types::{Generation, InstanceId, ScopeId, SeatId};
|
|
521
|
+
assert_eq!(PI_DESCRIPTOR.identity.id, "pi_tui");
|
|
522
|
+
assert_eq!(PI_DESCRIPTOR.identity.binary, "pi");
|
|
523
|
+
assert_eq!(provider("pi_tui").unwrap(), NativeProvider::Pi);
|
|
524
|
+
// `pi` (also the default role provider) declares the leaf with or
|
|
525
|
+
// without opt-in; a persisted legacy `pi` row is never reclassified.
|
|
526
|
+
assert!(descriptor("pi").is_none());
|
|
527
|
+
assert!(provider("pi").is_err());
|
|
528
|
+
assert_eq!(declared("pi", false), Some(&PI_DESCRIPTOR));
|
|
529
|
+
assert_eq!(declared("pi", true), Some(&PI_DESCRIPTOR));
|
|
530
|
+
assert_eq!(declared("pi_tui", false), Some(&PI_DESCRIPTOR));
|
|
531
|
+
for spelling in ["pi", " Pi ", "PI"] {
|
|
532
|
+
assert!(recognizes(spelling, false), "{spelling:?}");
|
|
533
|
+
assert!(recognizes(spelling, true), "{spelling:?}");
|
|
534
|
+
}
|
|
535
|
+
assert!(declared("Pi", true).is_none());
|
|
536
|
+
assert_eq!(public_name(&PI_DESCRIPTOR), "pi");
|
|
537
|
+
assert_eq!(public_name(&CURSOR_DESCRIPTOR), "cursor");
|
|
538
|
+
let mut identity = InstanceIdentity {
|
|
539
|
+
scope: ScopeId::new("scope").unwrap(), seat: SeatId::new("worker").unwrap(),
|
|
540
|
+
instance: InstanceId::new("instance").unwrap(), generation: Generation(1),
|
|
541
|
+
};
|
|
542
|
+
let first = NativeProvider::Pi.server_key_for(&identity).unwrap();
|
|
543
|
+
assert_eq!(first, pi::server_key(&identity));
|
|
544
|
+
assert_ne!(first, codex::server_key(&identity));
|
|
545
|
+
// Pi rejects a tool name over 64 characters.
|
|
546
|
+
assert!(format!("mcp__{first}__report_result").len() <= 64);
|
|
547
|
+
identity.generation = Generation(2);
|
|
548
|
+
assert_ne!(first, NativeProvider::Pi.server_key_for(&identity).unwrap());
|
|
549
|
+
assert!(NativeProvider::Pi.tool_panel().is_err());
|
|
550
|
+
assert!(NativeProvider::Pi.startup().is_none());
|
|
551
|
+
assert!(NativeProvider::Pi.session_panel().is_none());
|
|
552
|
+
assert!(NativeProvider::Pi.uses_tool_roundtrips());
|
|
553
|
+
assert!(NativeProvider::Pi.first_business_bootstrap());
|
|
554
|
+
let kinds: Vec<_> = NativeProvider::Pi.controls().iter().map(|control| control.command).collect();
|
|
555
|
+
assert_eq!(kinds, ["/session", "/quit"]);
|
|
556
|
+
}
|
|
557
|
+
|
|
280
558
|
#[test]
|
|
281
559
|
fn grok_server_key_is_generation_bound_and_has_no_inspector_fallback() {
|
|
282
560
|
use team_agent_contract::contract::types::{Generation, InstanceId, ScopeId, SeatId};
|
|
@@ -583,7 +583,6 @@ fn runtime_event_provider_name(provider: Provider) -> &'static str {
|
|
|
583
583
|
Provider::Copilot => "copilot",
|
|
584
584
|
Provider::GeminiCli => "gemini_cli",
|
|
585
585
|
Provider::Grok => "grok",
|
|
586
|
-
Provider::CursorAgent => "cursor_agent",
|
|
587
586
|
Provider::Pi => "pi",
|
|
588
587
|
Provider::Fake => "fake",
|
|
589
588
|
}
|
|
@@ -8,7 +8,7 @@ use crate::transport::test_support::OfflineTransport;
|
|
|
8
8
|
|
|
9
9
|
#[test]
|
|
10
10
|
fn abnormal_exit_is_reported_without_auto_recovery_intent_or_action() {
|
|
11
|
-
let case = RecoveryCase::new("reported-no-auto");
|
|
11
|
+
let case = RecoveryCase::new("reported-no-auto", "claude_code");
|
|
12
12
|
case.seed_agent("baseline-429");
|
|
13
13
|
let transport = OfflineTransport::new().with_session_present(true);
|
|
14
14
|
let coord = case.coord(transport.clone());
|
|
@@ -61,7 +61,9 @@ fn abnormal_exit_is_reported_without_auto_recovery_intent_or_action() {
|
|
|
61
61
|
|
|
62
62
|
#[test]
|
|
63
63
|
fn first_turn_death_cannot_enter_auto_respawn_loop_and_manual_start_still_recovers() {
|
|
64
|
-
|
|
64
|
+
// A pre-upgrade claude_code row cannot be started any more; Codex keeps
|
|
65
|
+
// both an explicit failed-turn fact and a resumable manual start.
|
|
66
|
+
let case = RecoveryCase::new("first-turn-death-no-loop", "codex");
|
|
65
67
|
case.seed_agent("baseline-429");
|
|
66
68
|
let transport = OfflineTransport::new().with_session_present(true);
|
|
67
69
|
let coord = case.coord(transport.clone());
|
|
@@ -131,10 +133,11 @@ fn first_turn_death_cannot_enter_auto_respawn_loop_and_manual_start_still_recove
|
|
|
131
133
|
|
|
132
134
|
struct RecoveryCase {
|
|
133
135
|
root: std::path::PathBuf,
|
|
136
|
+
provider: &'static str,
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
impl RecoveryCase {
|
|
137
|
-
fn new(tag: &str) -> Self {
|
|
140
|
+
fn new(tag: &str, provider: &'static str) -> Self {
|
|
138
141
|
let base = std::env::var_os("TEAM_AGENT_TEST_TMP")
|
|
139
142
|
.map(std::path::PathBuf::from)
|
|
140
143
|
.unwrap_or_else(std::env::temp_dir);
|
|
@@ -148,7 +151,7 @@ impl RecoveryCase {
|
|
|
148
151
|
.as_nanos()
|
|
149
152
|
));
|
|
150
153
|
std::fs::create_dir_all(&root).unwrap();
|
|
151
|
-
Self { root }
|
|
154
|
+
Self { root, provider }
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
fn coord(&self, transport: OfflineTransport) -> Coordinator {
|
|
@@ -163,7 +166,8 @@ impl RecoveryCase {
|
|
|
163
166
|
|
|
164
167
|
fn seed_agent(&self, uuid: &str) {
|
|
165
168
|
let rollout = self.rollout();
|
|
166
|
-
std::fs::write(&rollout,
|
|
169
|
+
std::fs::write(&rollout, self.error_line(uuid)).unwrap();
|
|
170
|
+
let model = if self.provider == "codex" { "gpt-5.5" } else { "sonnet" };
|
|
167
171
|
let state = serde_json::json!({
|
|
168
172
|
"active_team_key": "research",
|
|
169
173
|
"team_key": "research",
|
|
@@ -179,8 +183,8 @@ impl RecoveryCase {
|
|
|
179
183
|
"fe-admin": {
|
|
180
184
|
"agent_id": "fe-admin",
|
|
181
185
|
"id": "fe-admin",
|
|
182
|
-
"provider":
|
|
183
|
-
"model":
|
|
186
|
+
"provider": self.provider,
|
|
187
|
+
"model": model,
|
|
184
188
|
"status": "running",
|
|
185
189
|
"window": "fe-admin",
|
|
186
190
|
"rollout_path": rollout,
|
|
@@ -236,10 +240,17 @@ impl RecoveryCase {
|
|
|
236
240
|
.append(true)
|
|
237
241
|
.open(self.rollout())
|
|
238
242
|
.unwrap();
|
|
239
|
-
file.write_all(
|
|
243
|
+
file.write_all(self.error_line(uuid).as_bytes())
|
|
240
244
|
.unwrap();
|
|
241
245
|
}
|
|
242
246
|
|
|
247
|
+
fn error_line(&self, uuid: &str) -> String {
|
|
248
|
+
match self.provider {
|
|
249
|
+
"codex" => codex_failed_turn_line(uuid),
|
|
250
|
+
_ => claude_api_error_line(uuid),
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
243
254
|
fn rollout(&self) -> std::path::PathBuf {
|
|
244
255
|
self.root.join("rollout-fe-admin.jsonl")
|
|
245
256
|
}
|
|
@@ -292,6 +303,16 @@ fn claude_api_error_line(uuid: &str) -> String {
|
|
|
292
303
|
)
|
|
293
304
|
}
|
|
294
305
|
|
|
306
|
+
fn codex_failed_turn_line(turn_id: &str) -> String {
|
|
307
|
+
format!(
|
|
308
|
+
"{}\n",
|
|
309
|
+
serde_json::json!({
|
|
310
|
+
"method": "turn/completed",
|
|
311
|
+
"params": {"turn": {"id": turn_id, "status": "failed"}}
|
|
312
|
+
})
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
|
|
295
316
|
fn find_event<'a>(events: &'a [serde_json::Value], name: &str) -> Option<&'a serde_json::Value> {
|
|
296
317
|
events
|
|
297
318
|
.iter()
|
|
@@ -230,48 +230,6 @@ fn spine2_sync_health_records_last_output_at() {
|
|
|
230
230
|
);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
// P1 — capture_missing: an agent with NO session_id but a discoverable transcript under spawn_cwd gets
|
|
234
|
-
// its session_id captured + persisted (real capture_session_id); an agent that already has one is
|
|
235
|
-
// untouched. Golden sessions/capture.py:capture_missing_sessions.
|
|
236
|
-
#[test]
|
|
237
|
-
fn spine2_capture_missing_captures_session_id_for_missing_agent() {
|
|
238
|
-
use std::sync::atomic::{AtomicU64, Ordering};
|
|
239
|
-
static N: AtomicU64 = AtomicU64::new(0);
|
|
240
|
-
let tdir = std::env::temp_dir().join(format!(
|
|
241
|
-
"ta-rs-health-tx-{}-{}",
|
|
242
|
-
std::process::id(),
|
|
243
|
-
N.fetch_add(1, Ordering::Relaxed)
|
|
244
|
-
));
|
|
245
|
-
std::fs::create_dir_all(&tdir).unwrap();
|
|
246
|
-
// lane-046-capture-gap: Claude no-expected_session_id capture now requires
|
|
247
|
-
// positive_agent_id_match (TEAM_AGENT_ID=<id>) OR agent_path_match. Without
|
|
248
|
-
// a worker-identity signal, weak candidates can be leader transcripts and
|
|
249
|
-
// must not be attributed to a worker. The seeded transcript includes the
|
|
250
|
-
// TEAM_AGENT_ID marker for w1.
|
|
251
|
-
std::fs::write(
|
|
252
|
-
tdir.join("session.jsonl"),
|
|
253
|
-
r#"{"type":"user","sessionId":"sess-found","cwd":"x","message":{"content":"TEAM_AGENT_ID=w1 hi"}}"#,
|
|
254
|
-
)
|
|
255
|
-
.unwrap();
|
|
256
|
-
let agents = serde_json::json!({
|
|
257
|
-
"w1": { "provider": "claude_code", "window": "w1", "spawn_cwd": tdir.to_string_lossy() },
|
|
258
|
-
"w2": { "provider": "claude_code", "window": "w2", "session_id": "existing-sess" },
|
|
259
|
-
});
|
|
260
|
-
let (coord, dir) = seeded_health_coord(agents, "");
|
|
261
|
-
coord.tick().expect("tick");
|
|
262
|
-
assert!(
|
|
263
|
-
agent_field(&dir, "w1", "session_id").and_then(|v| v.as_str().map(str::to_string)).is_some(),
|
|
264
|
-
"capture_missing must capture+persist a session_id for an agent with a discoverable transcript; today it's a probe"
|
|
265
|
-
);
|
|
266
|
-
assert_eq!(
|
|
267
|
-
agent_field(&dir, "w2", "session_id")
|
|
268
|
-
.and_then(|v| v.as_str().map(str::to_string))
|
|
269
|
-
.as_deref(),
|
|
270
|
-
Some("existing-sess"),
|
|
271
|
-
"an agent that already has a session_id must be untouched"
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
233
|
// CONTRACT — sync_health runs BEFORE deliver_pending, but turn-level WORKING state must not make an
|
|
276
234
|
// alive worker undeliverable. Busy delivery deferral is lifecycle-only (`state.agents[id].status=="busy"`);
|
|
277
235
|
// activity/agent_health WORKING remains diagnostic turn state.
|