@team-agent/installer 0.5.125 → 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 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/src/cli/diagnose.rs +0 -68
- package/crates/team-agent/src/cli/emit.rs +6 -2
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +10 -10
- package/crates/team-agent/src/cli/mod.rs +22 -28
- package/crates/team-agent/src/cli/models.rs +7 -764
- 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/compiler/tests.rs +18 -3
- package/crates/team-agent/src/compiler.rs +4 -203
- package/crates/team-agent/src/contract_runtime/backend.rs +61 -38
- package/crates/team-agent/src/contract_runtime/config.rs +7 -4
- package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
- package/crates/team-agent/src/contract_runtime/framework.rs +8 -10
- package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
- package/crates/team-agent/src/contract_runtime/registry.rs +60 -19
- 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/leader/start.rs +1 -1
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +2 -195
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +18 -28
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +1 -9
- 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 -33
- package/crates/team-agent/src/lifecycle/launch.rs +0 -23
- package/crates/team-agent/src/lifecycle/profile_launch.rs +18 -317
- package/crates/team-agent/src/lifecycle/restart/common.rs +42 -315
- 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/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 +22 -138
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +4 -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_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 -16
- package/crates/team-agent/src/lifecycle/tests.rs +0 -3
- package/crates/team-agent/src/lifecycle/types.rs +2 -18
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +1 -1
- package/crates/team-agent/src/messaging/delivery.rs +12 -141
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +3 -3
- package/crates/team-agent/src/messaging/tests/spine.rs +26 -32
- package/crates/team-agent/src/provider/adapter.rs +35 -238
- package/crates/team-agent/src/provider/adapters/mod.rs +4 -4
- package/crates/team-agent/src/provider/model_catalog.rs +13 -201
- package/crates/team-agent/src/provider/session/capture.rs +6 -106
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -4
- package/crates/team-agent/src/provider/session/context_fork.rs +15 -107
- package/crates/team-agent/src/provider/session_scan/common.rs +10 -34
- package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
- package/crates/team-agent/src/provider/session_scan.rs +4 -10
- package/crates/team-agent/src/provider/tests/adapter.rs +34 -91
- package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -12
- package/crates/team-agent/src/provider/tests/idle.rs +0 -25
- package/crates/team-agent/src/provider/wire.rs +51 -23
- 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/package.json +4 -4
- package/skills/team-agent/SKILL.md +6 -4
- 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/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/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/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/test_support/models_timeout_fixture.rs +0 -144
|
@@ -275,6 +275,17 @@ pub(super) fn spawn_agent_window(
|
|
|
275
275
|
// (agent row → active_team_key) for back-compat with non-restart callers.
|
|
276
276
|
owner_team_id_override: Option<&str>,
|
|
277
277
|
) -> Result<SpawnedAgentWindow, LifecycleError> {
|
|
278
|
+
// A pre-upgrade Claude Code or Pi worker row has no legacy runtime left;
|
|
279
|
+
// refuse before any MCP file, profile or pane side effect.
|
|
280
|
+
if let Some(retired) = agent
|
|
281
|
+
.get("provider")
|
|
282
|
+
.and_then(serde_json::Value::as_str)
|
|
283
|
+
.filter(|provider| crate::provider::wire::is_retired_provider(provider))
|
|
284
|
+
{
|
|
285
|
+
return Err(LifecycleError::Provider(
|
|
286
|
+
crate::provider::wire::retired_provider_error(retired).into(),
|
|
287
|
+
));
|
|
288
|
+
}
|
|
278
289
|
let provider = agent_provider(agent);
|
|
279
290
|
let auth_mode = agent_auth_mode(agent);
|
|
280
291
|
let model = agent.get("model").and_then(|v| v.as_str());
|
|
@@ -337,16 +348,12 @@ pub(super) fn spawn_agent_window(
|
|
|
337
348
|
agent_id.as_str(),
|
|
338
349
|
team_id.as_deref().unwrap_or(""),
|
|
339
350
|
);
|
|
340
|
-
let mcp_config_path =
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
&mcp_config,
|
|
347
|
-
Some(provider),
|
|
348
|
-
)?)
|
|
349
|
-
};
|
|
351
|
+
let mcp_config_path = crate::lifecycle::launch::write_worker_mcp_config_for_provider(
|
|
352
|
+
workspace,
|
|
353
|
+
agent_id.as_str(),
|
|
354
|
+
&mcp_config,
|
|
355
|
+
Some(provider),
|
|
356
|
+
)?;
|
|
350
357
|
let profile_launch =
|
|
351
358
|
crate::lifecycle::profile_launch::prepare_provider_profile_launch_from_json(
|
|
352
359
|
workspace,
|
|
@@ -379,65 +386,18 @@ pub(super) fn spawn_agent_window(
|
|
|
379
386
|
agent_id_hint: Some(agent_id.as_str()),
|
|
380
387
|
effort: restart_effort,
|
|
381
388
|
};
|
|
382
|
-
let
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
.map(std::path::PathBuf::from)
|
|
389
|
-
})
|
|
390
|
-
.flatten();
|
|
391
|
-
let spawn_cwd = spawn_cwd_override
|
|
392
|
-
.or(pi_spawn_cwd.as_deref())
|
|
393
|
-
.unwrap_or(workspace);
|
|
394
|
-
let mut plan = if provider == crate::provider::Provider::Pi {
|
|
395
|
-
let request = crate::lifecycle::launch::pi_mcp::PiMaterializeRequest {
|
|
396
|
-
workspace,
|
|
397
|
-
team_id: team_id.as_deref().unwrap_or(""),
|
|
398
|
-
agent_id: agent_id.as_str(),
|
|
399
|
-
model: command_model,
|
|
400
|
-
effort: restart_effort,
|
|
401
|
-
system_prompt: &system_prompt,
|
|
402
|
-
team_mcp_tools: &["send_message", "report_result", "get_team_status"],
|
|
403
|
-
mcp_config: &mcp_config,
|
|
404
|
-
session_scope: crate::lifecycle::launch::pi_mcp::PiSessionScope::Isolated,
|
|
405
|
-
};
|
|
406
|
-
match resume_session_id {
|
|
407
|
-
Some(session_id) => {
|
|
408
|
-
let rollout_path = agent_rollout_path(agent).ok_or_else(|| {
|
|
409
|
-
LifecycleError::RequirementUnmet(
|
|
410
|
-
"Pi resume requires the persisted exact session path".to_string(),
|
|
411
|
-
)
|
|
412
|
-
})?;
|
|
413
|
-
crate::lifecycle::launch::pi_mcp::materialize_pi_resume_plan(
|
|
414
|
-
request,
|
|
415
|
-
session_id,
|
|
416
|
-
rollout_path.as_path(),
|
|
417
|
-
spawn_cwd,
|
|
418
|
-
)
|
|
419
|
-
}
|
|
420
|
-
None => crate::lifecycle::launch::pi_mcp::materialize_pi_plan(request),
|
|
421
|
-
}
|
|
422
|
-
.map_err(|e| LifecycleError::Provider(e.to_string()))?
|
|
423
|
-
} else {
|
|
424
|
-
match resume_session_id {
|
|
425
|
-
Some(session_id) => adapter
|
|
426
|
-
.build_resume_command_plan(Some(session_id), context)
|
|
427
|
-
.map_err(|e| LifecycleError::Provider(e.to_string()))?,
|
|
428
|
-
None => adapter
|
|
429
|
-
.build_command_plan(context)
|
|
430
|
-
.map_err(|e| LifecycleError::Provider(e.to_string()))?,
|
|
431
|
-
}
|
|
432
|
-
};
|
|
389
|
+
let spawn_cwd = spawn_cwd_override.unwrap_or(workspace);
|
|
390
|
+
let mut plan = match resume_session_id {
|
|
391
|
+
Some(session_id) => adapter.build_resume_command_plan(Some(session_id), context),
|
|
392
|
+
None => adapter.build_command_plan(context),
|
|
393
|
+
}
|
|
394
|
+
.map_err(|e| LifecycleError::Provider(e.to_string()))?;
|
|
433
395
|
if !plan.managed_mcp_config && !profile_launch.managed_mcp_config {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
);
|
|
440
|
-
}
|
|
396
|
+
crate::lifecycle::launch::point_native_mcp_config_at_file(
|
|
397
|
+
&mut plan.argv,
|
|
398
|
+
provider,
|
|
399
|
+
&mcp_config_path,
|
|
400
|
+
);
|
|
441
401
|
}
|
|
442
402
|
crate::lifecycle::launch::fill_spawn_placeholders_full(
|
|
443
403
|
&mut plan.argv,
|
|
@@ -468,12 +428,8 @@ pub(super) fn spawn_agent_window(
|
|
|
468
428
|
crate::lifecycle::launch::ensure_grok_login_and_folder_trust(workspace)?;
|
|
469
429
|
crate::lifecycle::launch::apply_grok_mcp_overlay(workspace, &mcp_config)?;
|
|
470
430
|
}
|
|
471
|
-
//
|
|
472
|
-
// `.team/runtime/<team_key>/`).
|
|
473
|
-
// already resolved above so exact-path header checks match capture.
|
|
474
|
-
// 0.4.x provider effort MVP step 9: scrub CLAUDE_EFFORT for Claude
|
|
475
|
-
// worker spawn so a parent shell env cannot silently override the
|
|
476
|
-
// framework's effort decision.
|
|
431
|
+
// Spawn cwd is override-or-workspace (E56: ignore drifted state
|
|
432
|
+
// `.team/runtime/<team_key>/`).
|
|
477
433
|
let env_unset = crate::layout::worker_env::isolate_worker_spawn_env(
|
|
478
434
|
provider,
|
|
479
435
|
&mut env,
|
|
@@ -665,7 +621,7 @@ pub(super) fn spawn_agent_window(
|
|
|
665
621
|
profile_launch,
|
|
666
622
|
layout_placement: layout_placement.cloned(),
|
|
667
623
|
spawn_cwd: spawn_cwd.to_path_buf(),
|
|
668
|
-
mcp_config_path,
|
|
624
|
+
mcp_config_path: Some(mcp_config_path),
|
|
669
625
|
owner_team_id: team_id,
|
|
670
626
|
})
|
|
671
627
|
}
|
|
@@ -1318,11 +1274,11 @@ pub(crate) fn session_identity_probe_for_agent(
|
|
|
1318
1274
|
}
|
|
1319
1275
|
|
|
1320
1276
|
/// ---
|
|
1321
|
-
/// purpose:
|
|
1277
|
+
/// purpose: 共享会话身份判定(Pi fork 血统随遗留 Pi worker 运行时一并移除)
|
|
1322
1278
|
/// params:
|
|
1323
|
-
/// workspace/state/agent:
|
|
1279
|
+
/// workspace/state/agent: 保留调用形状
|
|
1324
1280
|
/// rollout_path: 当前席位的精确 backing
|
|
1325
|
-
/// returns:
|
|
1281
|
+
/// returns: 字面身份判定结果
|
|
1326
1282
|
/// ---
|
|
1327
1283
|
pub(crate) fn session_identity_probe_for_agent_with_fork_ancestry(
|
|
1328
1284
|
workspace: &Path,
|
|
@@ -1332,102 +1288,8 @@ pub(crate) fn session_identity_probe_for_agent_with_fork_ancestry(
|
|
|
1332
1288
|
provider: Provider,
|
|
1333
1289
|
rollout_path: Option<&RolloutPath>,
|
|
1334
1290
|
) -> SessionIdentityProbeResult {
|
|
1335
|
-
let
|
|
1336
|
-
|
|
1337
|
-
|| !pi_fork_ancestor_identity_is_valid(
|
|
1338
|
-
workspace,
|
|
1339
|
-
state,
|
|
1340
|
-
agent_id,
|
|
1341
|
-
agent,
|
|
1342
|
-
provider,
|
|
1343
|
-
rollout_path,
|
|
1344
|
-
probe.embedded_agent_id.as_deref(),
|
|
1345
|
-
)
|
|
1346
|
-
{
|
|
1347
|
-
return probe;
|
|
1348
|
-
}
|
|
1349
|
-
probe.identity_ok = Some(true);
|
|
1350
|
-
probe
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
fn pi_fork_ancestor_identity_is_valid(
|
|
1354
|
-
workspace: &Path,
|
|
1355
|
-
state: &serde_json::Value,
|
|
1356
|
-
agent_id: &AgentId,
|
|
1357
|
-
agent: &serde_json::Value,
|
|
1358
|
-
provider: Provider,
|
|
1359
|
-
rollout_path: Option<&RolloutPath>,
|
|
1360
|
-
embedded_agent_id: Option<&str>,
|
|
1361
|
-
) -> bool {
|
|
1362
|
-
if provider != Provider::Pi
|
|
1363
|
-
|| agent.get("attribution_ambiguous").and_then(serde_json::Value::as_bool) == Some(true)
|
|
1364
|
-
|| agent.get("capture_state").and_then(serde_json::Value::as_str)
|
|
1365
|
-
== Some("attribution_ambiguous")
|
|
1366
|
-
|| !matches!(
|
|
1367
|
-
agent
|
|
1368
|
-
.get("attribution_confidence")
|
|
1369
|
-
.and_then(serde_json::Value::as_str),
|
|
1370
|
-
Some("high" | "medium")
|
|
1371
|
-
)
|
|
1372
|
-
{
|
|
1373
|
-
return false;
|
|
1374
|
-
}
|
|
1375
|
-
let (Some(embedded_agent_id), Some(forked_from), Some(target_path)) = (
|
|
1376
|
-
embedded_agent_id,
|
|
1377
|
-
agent
|
|
1378
|
-
.get("forked_from")
|
|
1379
|
-
.and_then(serde_json::Value::as_str)
|
|
1380
|
-
.filter(|value| !value.is_empty()),
|
|
1381
|
-
rollout_path.map(RolloutPath::as_path),
|
|
1382
|
-
) else {
|
|
1383
|
-
return false;
|
|
1384
|
-
};
|
|
1385
|
-
if forked_from != embedded_agent_id || forked_from == agent_id.as_str() {
|
|
1386
|
-
return false;
|
|
1387
|
-
}
|
|
1388
|
-
let Some(source_agent) = state
|
|
1389
|
-
.get("agents")
|
|
1390
|
-
.and_then(|agents| agents.get(forked_from))
|
|
1391
|
-
.filter(|source| agent_provider(source) == Provider::Pi)
|
|
1392
|
-
else {
|
|
1393
|
-
return false;
|
|
1394
|
-
};
|
|
1395
|
-
let Some(source_path) = agent_rollout_path(source_agent) else {
|
|
1396
|
-
return false;
|
|
1397
|
-
};
|
|
1398
|
-
if source_path.as_path() == target_path {
|
|
1399
|
-
return false;
|
|
1400
|
-
}
|
|
1401
|
-
let (Some(session_id), Ok(target_path), Some(target_root)) = (
|
|
1402
|
-
agent_session_id(agent),
|
|
1403
|
-
std::fs::canonicalize(target_path),
|
|
1404
|
-
agent
|
|
1405
|
-
.get("claude_projects_root")
|
|
1406
|
-
.and_then(serde_json::Value::as_str)
|
|
1407
|
-
.filter(|path| !path.is_empty())
|
|
1408
|
-
.map(std::path::PathBuf::from),
|
|
1409
|
-
) else {
|
|
1410
|
-
return false;
|
|
1411
|
-
};
|
|
1412
|
-
let Ok(target_root) = std::fs::canonicalize(target_root) else {
|
|
1413
|
-
return false;
|
|
1414
|
-
};
|
|
1415
|
-
if !target_path.starts_with(target_root)
|
|
1416
|
-
|| std::fs::canonicalize(source_path.as_path())
|
|
1417
|
-
.is_ok_and(|source_path| source_path == target_path)
|
|
1418
|
-
|| !resume_backing_probe_for_agent(
|
|
1419
|
-
workspace,
|
|
1420
|
-
agent_id,
|
|
1421
|
-
agent,
|
|
1422
|
-
provider,
|
|
1423
|
-
&session_id,
|
|
1424
|
-
rollout_path,
|
|
1425
|
-
)
|
|
1426
|
-
.exists
|
|
1427
|
-
{
|
|
1428
|
-
return false;
|
|
1429
|
-
}
|
|
1430
|
-
true
|
|
1291
|
+
let _ = (workspace, state, agent);
|
|
1292
|
+
session_identity_probe_for_agent(agent_id, provider, rollout_path)
|
|
1431
1293
|
}
|
|
1432
1294
|
|
|
1433
1295
|
/// ---
|
|
@@ -1465,20 +1327,6 @@ pub(super) fn resume_backing_probe_for_agent(
|
|
|
1465
1327
|
rollout_ok
|
|
1466
1328
|
|| codex_session_transcript_exists_with_roots(session_id.as_str(), &scan_roots)
|
|
1467
1329
|
}
|
|
1468
|
-
Provider::Claude | Provider::ClaudeCode => {
|
|
1469
|
-
let rollout_ok = rollout_path_exists(rollout_path);
|
|
1470
|
-
let projects_root = claude_projects_root_for_agent(agent);
|
|
1471
|
-
if let Some(root) = projects_root.as_ref() {
|
|
1472
|
-
checked_paths.push(root.clone());
|
|
1473
|
-
}
|
|
1474
|
-
let event_log_path = workspace.join(".team/logs/events.jsonl");
|
|
1475
|
-
checked_paths.push(event_log_path);
|
|
1476
|
-
rollout_ok
|
|
1477
|
-
|| event_log_transcript_exists(workspace, agent_id.as_str(), session_id.as_str())
|
|
1478
|
-
|| projects_root.is_some_and(|root| {
|
|
1479
|
-
claude_project_transcript_exists_under(&root, session_id.as_str())
|
|
1480
|
-
})
|
|
1481
|
-
}
|
|
1482
1330
|
Provider::Copilot => {
|
|
1483
1331
|
if let Some(home) = std::env::var_os("HOME").map(PathBuf::from) {
|
|
1484
1332
|
checked_paths.push(home.join(".copilot/session-store.db"));
|
|
@@ -1502,23 +1350,12 @@ pub(super) fn resume_backing_probe_for_agent(
|
|
|
1502
1350
|
None => false,
|
|
1503
1351
|
}
|
|
1504
1352
|
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
.unwrap_or_else(|| workspace.to_path_buf());
|
|
1512
|
-
rollout_path.is_some_and(|path| {
|
|
1513
|
-
crate::provider::session_scan::pi::validate_exact_backing(
|
|
1514
|
-
path.as_path(),
|
|
1515
|
-
session_id,
|
|
1516
|
-
&spawn_cwd,
|
|
1517
|
-
)
|
|
1518
|
-
.is_ok()
|
|
1519
|
-
})
|
|
1520
|
-
}
|
|
1521
|
-
Provider::GeminiCli | Provider::Fake => false,
|
|
1353
|
+
// Claude Code and Pi workers run only through their contract leaves.
|
|
1354
|
+
Provider::Claude
|
|
1355
|
+
| Provider::ClaudeCode
|
|
1356
|
+
| Provider::Pi
|
|
1357
|
+
| Provider::GeminiCli
|
|
1358
|
+
| Provider::Fake => false,
|
|
1522
1359
|
};
|
|
1523
1360
|
|
|
1524
1361
|
// Deduplicate while preserving order (HashSet would lose deterministic
|
|
@@ -1558,73 +1395,6 @@ fn rollout_path_exists(rollout_path: Option<&RolloutPath>) -> bool {
|
|
|
1558
1395
|
.is_some_and(|path| path.as_path().exists())
|
|
1559
1396
|
}
|
|
1560
1397
|
|
|
1561
|
-
fn event_log_transcript_exists(workspace: &Path, agent_id: &str, session_id: &str) -> bool {
|
|
1562
|
-
let Ok(events) = crate::event_log::EventLog::new(workspace).tail(0) else {
|
|
1563
|
-
return false;
|
|
1564
|
-
};
|
|
1565
|
-
events.iter().rev().any(|event| {
|
|
1566
|
-
event.get("event").and_then(serde_json::Value::as_str) == Some("session.captured")
|
|
1567
|
-
&& ["agent_id", "worker_id"]
|
|
1568
|
-
.iter()
|
|
1569
|
-
.any(|key| event.get(*key).and_then(serde_json::Value::as_str) == Some(agent_id))
|
|
1570
|
-
&& event.get("session_id").and_then(serde_json::Value::as_str) == Some(session_id)
|
|
1571
|
-
&& event_transcript_path(event).is_some_and(|path| path.exists())
|
|
1572
|
-
})
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
fn event_transcript_path(event: &serde_json::Value) -> Option<PathBuf> {
|
|
1576
|
-
event
|
|
1577
|
-
.get("rollout_path")
|
|
1578
|
-
.or_else(|| event.get("transcript_path"))
|
|
1579
|
-
.and_then(serde_json::Value::as_str)
|
|
1580
|
-
.filter(|path| !path.is_empty())
|
|
1581
|
-
.map(PathBuf::from)
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
/// E36 fix-B: a real Claude worker writes its session transcript to
|
|
1585
|
-
/// `<claude_projects_root>/<workspace-slug>/<session_id>.jsonl` even when neither
|
|
1586
|
-
/// `rollout_path` was persisted to state nor a `session.captured` event was logged.
|
|
1587
|
-
/// That landed transcript is itself a valid resume backing — restart was wrongly
|
|
1588
|
-
/// refusing resumable workers because it only checked the two paths above. Scan the
|
|
1589
|
-
/// projects root recursively for `<session_id>.jsonl` (session_id is a unique UUID,
|
|
1590
|
-
/// so we avoid recomputing the project-dir slug, which is brittle for non-ASCII
|
|
1591
|
-
/// workspace paths).
|
|
1592
|
-
fn claude_project_transcript_exists(agent: &serde_json::Value, session_id: &str) -> bool {
|
|
1593
|
-
let Some(root) = claude_projects_root_for_agent(agent) else {
|
|
1594
|
-
return false;
|
|
1595
|
-
};
|
|
1596
|
-
claude_project_transcript_exists_under(&root, session_id)
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
fn claude_projects_root_for_agent(agent: &serde_json::Value) -> Option<PathBuf> {
|
|
1600
|
-
agent
|
|
1601
|
-
.get("claude_projects_root")
|
|
1602
|
-
.and_then(serde_json::Value::as_str)
|
|
1603
|
-
.filter(|value| !value.is_empty())
|
|
1604
|
-
.map(PathBuf::from)
|
|
1605
|
-
.or_else(|| {
|
|
1606
|
-
std::env::var_os("HOME")
|
|
1607
|
-
.map(|home| PathBuf::from(home).join(".claude").join("projects"))
|
|
1608
|
-
})
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
fn claude_project_transcript_exists_under(projects_root: &Path, session_id: &str) -> bool {
|
|
1612
|
-
if session_id.is_empty() {
|
|
1613
|
-
return false;
|
|
1614
|
-
}
|
|
1615
|
-
if !projects_root.is_dir() {
|
|
1616
|
-
return false;
|
|
1617
|
-
}
|
|
1618
|
-
let transcript_name = format!("{session_id}.jsonl");
|
|
1619
|
-
let Ok(project_dirs) = std::fs::read_dir(projects_root) else {
|
|
1620
|
-
return false;
|
|
1621
|
-
};
|
|
1622
|
-
project_dirs
|
|
1623
|
-
.flatten()
|
|
1624
|
-
.filter(|entry| entry.path().is_dir())
|
|
1625
|
-
.any(|entry| entry.path().join(&transcript_name).is_file())
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
1398
|
fn codex_session_transcript_exists(
|
|
1629
1399
|
agent: &serde_json::Value,
|
|
1630
1400
|
session_id: &str,
|
|
@@ -2388,49 +2158,6 @@ mod e36_transcript_backing_tests {
|
|
|
2388
2158
|
.is_err());
|
|
2389
2159
|
}
|
|
2390
2160
|
|
|
2391
|
-
// E36 fix-B RED→GREEN: a real Claude worker that sent a message has its session
|
|
2392
|
-
// transcript landed at <projects_root>/<slug>/<session_id>.jsonl, but neither
|
|
2393
|
-
// rollout_path was persisted to state nor a session.captured event was logged.
|
|
2394
|
-
// Before the fix, claude_project_transcript_exists did not exist and restart
|
|
2395
|
-
// refused such a worker. This asserts the landed transcript is recognized.
|
|
2396
|
-
#[test]
|
|
2397
|
-
fn claude_project_transcript_is_recognized_without_rollout_or_capture_event() {
|
|
2398
|
-
let scratch = ScratchDir::new("recognized");
|
|
2399
|
-
let projects_root = scratch.path().join("projects");
|
|
2400
|
-
let slug_dir = projects_root.join("-Users-alauda-Documents-code---rust---9");
|
|
2401
|
-
std::fs::create_dir_all(&slug_dir).expect("mkdir slug");
|
|
2402
|
-
let session_id = "87742d3f-0b4e-4fc1-ad35-447ac2340b65";
|
|
2403
|
-
std::fs::write(slug_dir.join(format!("{session_id}.jsonl")), b"{}\n").expect("transcript");
|
|
2404
|
-
|
|
2405
|
-
let agent = serde_json::json!({
|
|
2406
|
-
"claude_projects_root": projects_root.to_string_lossy(),
|
|
2407
|
-
});
|
|
2408
|
-
assert!(
|
|
2409
|
-
claude_project_transcript_exists(&agent, session_id),
|
|
2410
|
-
"landed claude transcript must count as resume backing (E36 fix-B)"
|
|
2411
|
-
);
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
#[test]
|
|
2415
|
-
fn missing_claude_transcript_is_not_backing() {
|
|
2416
|
-
let scratch = ScratchDir::new("missing");
|
|
2417
|
-
let projects_root = scratch.path().join("projects");
|
|
2418
|
-
std::fs::create_dir_all(&projects_root).expect("mkdir");
|
|
2419
|
-
let agent = serde_json::json!({
|
|
2420
|
-
"claude_projects_root": projects_root.to_string_lossy(),
|
|
2421
|
-
});
|
|
2422
|
-
assert!(
|
|
2423
|
-
!claude_project_transcript_exists(&agent, "deadbeef-0000-0000-0000-000000000000"),
|
|
2424
|
-
"no transcript file => no backing"
|
|
2425
|
-
);
|
|
2426
|
-
}
|
|
2427
|
-
|
|
2428
|
-
#[test]
|
|
2429
|
-
fn empty_session_id_is_not_backing() {
|
|
2430
|
-
let agent = serde_json::json!({});
|
|
2431
|
-
assert!(!claude_project_transcript_exists(&agent, ""));
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
2161
|
#[test]
|
|
2435
2162
|
fn codex_session_transcript_is_recognized_when_rollout_path_is_stale() {
|
|
2436
2163
|
let scratch = ScratchDir::new("codex-recognized");
|
|
@@ -45,7 +45,7 @@ mod contract_route_tests {
|
|
|
45
45
|
fn mixed_team_retains_legacy_classification_without_native_codex_fallback() {
|
|
46
46
|
let state = serde_json::json!({"agents": {
|
|
47
47
|
"native": {"provider":"cursor","status":"running","session_id":"native-id"},
|
|
48
|
-
"legacy": {"provider":"
|
|
48
|
+
"legacy": {"provider":"copilot","status":"running"},
|
|
49
49
|
}});
|
|
50
50
|
let plan = classify_restart_plan(&state, false).unwrap();
|
|
51
51
|
assert_eq!(plan.decisions.len(), 1);
|
|
@@ -61,11 +61,11 @@ mod stopped_restart_tests {
|
|
|
61
61
|
#[test]
|
|
62
62
|
fn stopped_rows_never_enter_validation_or_fresh_spawn_even_with_allow_fresh() {
|
|
63
63
|
let state = serde_json::json!({"agents": {
|
|
64
|
-
"stopped": {"provider":"
|
|
64
|
+
"stopped": {"provider":"copilot","status":"stopped","explicit_stop":true,
|
|
65
65
|
"session_id":"preserved","generation":7,"first_send_at":false},
|
|
66
|
-
"legacy_stopped": {"provider":"
|
|
67
|
-
"marker": {"provider":"
|
|
68
|
-
"active": {"provider":"
|
|
66
|
+
"legacy_stopped": {"provider":"copilot","status":"stopped"},
|
|
67
|
+
"marker": {"provider":"copilot","status":"running","explicit_stop":true},
|
|
68
|
+
"active": {"provider":"copilot","status":"running"}
|
|
69
69
|
}});
|
|
70
70
|
let before = state.clone();
|
|
71
71
|
for allow_fresh in [false, true] {
|
|
@@ -269,14 +269,14 @@ fn d6_compiled_system_prompt_first_section_is_identity() {
|
|
|
269
269
|
&ws,
|
|
270
270
|
&TeamFixture {
|
|
271
271
|
name: "d6team",
|
|
272
|
-
provider: "
|
|
272
|
+
provider: "codex",
|
|
273
273
|
fast: false,
|
|
274
274
|
agents: &[AgentDoc {
|
|
275
275
|
id: "worker_a",
|
|
276
276
|
role: "Prompt Order Worker",
|
|
277
|
-
provider: "
|
|
277
|
+
provider: "codex",
|
|
278
278
|
auth_mode: "subscription",
|
|
279
|
-
model: Some("
|
|
279
|
+
model: Some("gpt-5.5"),
|
|
280
280
|
profile: None,
|
|
281
281
|
tools: &["mcp_team"],
|
|
282
282
|
body: "ROLE BODY SENTINEL for prompt ordering.",
|
|
@@ -287,10 +287,15 @@ fn d6_compiled_system_prompt_first_section_is_identity() {
|
|
|
287
287
|
let transport = RecordingTransport::new();
|
|
288
288
|
|
|
289
289
|
quick_start_with_transport_in_workspace(&ws, &team_dir, None, true, Some("d6team"), &transport)
|
|
290
|
-
.expect("quick-start should spawn the
|
|
290
|
+
.expect("quick-start should spawn the codex worker");
|
|
291
291
|
let spawn = transport.single_spawn();
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
// The identity line has no `\`, `"` or newline, so codex's escaping leaves it verbatim.
|
|
293
|
+
let prompt = spawn
|
|
294
|
+
.argv
|
|
295
|
+
.iter()
|
|
296
|
+
.find_map(|arg| arg.strip_prefix("developer_instructions=\""))
|
|
297
|
+
.expect("codex argv must carry -c developer_instructions")
|
|
298
|
+
.to_string();
|
|
294
299
|
|
|
295
300
|
let identity = "You are Team Agent worker `worker_a` with role `Prompt Order Worker`. \
|
|
296
301
|
When asked about your role or identity, answer with this Team Agent worker identity first, \
|