@team-agent/installer 0.5.60 → 0.5.62
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/adapters.rs +49 -3
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +1 -0
- package/crates/team-agent/src/cli/diagnose.rs +184 -0
- package/crates/team-agent/src/cli/emit.rs +104 -21
- package/crates/team-agent/src/cli/helpers.rs +1 -0
- package/crates/team-agent/src/cli/leader.rs +14 -2
- package/crates/team-agent/src/cli/leaders.rs +2 -0
- package/crates/team-agent/src/cli/mod.rs +296 -8
- package/crates/team-agent/src/cli/named_address.rs +26 -2
- package/crates/team-agent/src/cli/profile.rs +2 -1
- package/crates/team-agent/src/cli/send/coordinator.rs +1 -0
- package/crates/team-agent/src/cli/send/mailbox.rs +3 -0
- package/crates/team-agent/src/cli/send/persist.rs +1 -0
- package/crates/team-agent/src/cli/send/presentation.rs +3 -0
- package/crates/team-agent/src/cli/send/resolve.rs +206 -1
- package/crates/team-agent/src/cli/send.rs +2 -1
- package/crates/team-agent/src/cli/spec.rs +5 -1
- package/crates/team-agent/src/cli/status.rs +2 -1
- package/crates/team-agent/src/cli/status_port/compact.rs +1 -0
- package/crates/team-agent/src/cli/status_port/format.rs +1 -0
- package/crates/team-agent/src/cli/status_port/inbox.rs +1 -0
- package/crates/team-agent/src/cli/status_port/store.rs +7 -3
- package/crates/team-agent/src/cli/tests/named_address.rs +65 -0
- package/crates/team-agent/src/cli/tests/verb_profile.rs +38 -0
- package/crates/team-agent/src/cli/types.rs +36 -2
- package/crates/team-agent/src/communication_mode/mod.rs +54 -0
- package/crates/team-agent/src/compiler/tests.rs +5 -5
- package/crates/team-agent/src/compiler.rs +54 -1
- package/crates/team-agent/src/conpty/backend.rs +1 -0
- package/crates/team-agent/src/conpty/mod.rs +1 -0
- package/crates/team-agent/src/coordinator/backoff.rs +5 -8
- package/crates/team-agent/src/coordinator/conpty_shim.rs +3 -2
- package/crates/team-agent/src/coordinator/health.rs +1 -0
- package/crates/team-agent/src/coordinator/mod.rs +2 -2
- package/crates/team-agent/src/coordinator/orphan.rs +4 -116
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +1 -0
- package/crates/team-agent/src/coordinator/runtime_observation.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +6 -5
- package/crates/team-agent/src/coordinator/steps/delivery.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/mod.rs +2 -0
- package/crates/team-agent/src/coordinator/steps/persist.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +1 -0
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -174
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -9
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -184
- package/crates/team-agent/src/coordinator/tests/mod.rs +2 -17
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -42
- package/crates/team-agent/src/coordinator/tick.rs +24 -28
- package/crates/team-agent/src/coordinator/types.rs +3 -176
- package/crates/team-agent/src/db/agent_health_capture.rs +1 -0
- package/crates/team-agent/src/db/message_store.rs +47 -2
- package/crates/team-agent/src/db/migration.rs +5 -4
- package/crates/team-agent/src/db/mod.rs +1 -0
- package/crates/team-agent/src/db/schema.rs +1 -0
- package/crates/team-agent/src/diagnose/comms.rs +2 -1
- package/crates/team-agent/src/diagnose/mod.rs +1 -0
- package/crates/team-agent/src/diagnose/orphans.rs +1 -0
- package/crates/team-agent/src/fake_worker.rs +21 -1
- package/crates/team-agent/src/layout/manager.rs +3 -7
- package/crates/team-agent/src/layout/mod.rs +2 -2
- package/crates/team-agent/src/layout/overlay.rs +6 -1
- package/crates/team-agent/src/layout/placement.rs +1 -0
- package/crates/team-agent/src/layout/recovery.rs +3 -0
- package/crates/team-agent/src/layout/runtime_sessions.rs +8 -3
- package/crates/team-agent/src/layout/sessions.rs +8 -1
- package/crates/team-agent/src/layout/tmux_endpoint.rs +3 -0
- package/crates/team-agent/src/layout/worker_env.rs +3 -0
- package/crates/team-agent/src/layout/worker_window_helpers.rs +2 -0
- package/crates/team-agent/src/leader/helpers.rs +1 -0
- package/crates/team-agent/src/leader/incident.rs +1 -0
- package/crates/team-agent/src/leader/lease.rs +27 -22
- package/crates/team-agent/src/leader/mod.rs +2 -3
- package/crates/team-agent/src/leader/owner_bind.rs +13 -3
- package/crates/team-agent/src/leader/provider_attribution.rs +1 -0
- package/crates/team-agent/src/leader/rediscover.rs +4 -17
- package/crates/team-agent/src/leader/registry.rs +3 -15
- package/crates/team-agent/src/leader/start.rs +1072 -186
- package/crates/team-agent/src/leader/takeover.rs +10 -232
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +544 -0
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +624 -0
- package/crates/team-agent/src/leader/tests/identity.rs +71 -59
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +42 -0
- package/crates/team-agent/src/leader/tests/idle.rs +0 -193
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -45
- package/crates/team-agent/src/leader/tests/mod.rs +4 -41
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +83 -0
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +1273 -0
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +417 -0
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +22 -103
- package/crates/team-agent/src/leader/types.rs +1 -28
- package/crates/team-agent/src/lib.rs +7 -0
- package/crates/team-agent/src/lifecycle/display.rs +7 -1
- package/crates/team-agent/src/lifecycle/helpers.rs +3 -1
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +1 -1
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/plan.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +4 -26
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -27
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +2 -28
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +4 -32
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch.rs +11 -12
- package/crates/team-agent/src/lifecycle/mod.rs +2 -1
- package/crates/team-agent/src/lifecycle/restart/agent.rs +4 -4
- package/crates/team-agent/src/lifecycle/restart/common.rs +1 -1
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +2 -2
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +13 -5
- package/crates/team-agent/src/lifecycle/restart/remove.rs +1 -1
- package/crates/team-agent/src/lifecycle/restart/selection.rs +3 -3
- package/crates/team-agent/src/lifecycle/restart.rs +13 -11
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1007 -0
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +265 -0
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +459 -0
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +849 -0
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +323 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +423 -0
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +737 -0
- package/crates/team-agent/src/lifecycle/tests/codex_mcp_approval_inheritance_red.rs +1187 -0
- package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +683 -0
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +394 -0
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +1856 -0
- package/crates/team-agent/src/lifecycle/tests/core_034_real_red.rs +917 -0
- package/crates/team-agent/src/lifecycle/tests/display_adaptive_red.rs +481 -0
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +301 -0
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +516 -0
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +986 -0
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +651 -0
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +2 -0
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +332 -0
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +846 -0
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +648 -0
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +910 -0
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +630 -0
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +1083 -0
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +1677 -0
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +410 -0
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +428 -0
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +1032 -0
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +869 -0
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +1249 -0
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +342 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +542 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1103 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +1276 -0
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +145 -0
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +603 -0
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +837 -0
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +928 -0
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +951 -0
- package/crates/team-agent/src/lifecycle/tests/worker_dangerous_bypass_argv_red.rs +327 -0
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +760 -0
- package/crates/team-agent/src/lifecycle/tests.rs +59 -0
- package/crates/team-agent/src/lifecycle/types.rs +0 -9
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +29 -11
- package/crates/team-agent/src/mcp_server/helpers.rs +1 -0
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +1 -0
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +1 -0
- package/crates/team-agent/src/mcp_server/mod.rs +1 -0
- package/crates/team-agent/src/mcp_server/normalize.rs +5 -3
- package/crates/team-agent/src/mcp_server/tests/send.rs +26 -0
- package/crates/team-agent/src/mcp_server/tests/wire.rs +1 -1
- package/crates/team-agent/src/mcp_server/tools.rs +101 -66
- package/crates/team-agent/src/mcp_server/types.rs +6 -18
- package/crates/team-agent/src/mcp_server/wire.rs +32 -26
- package/crates/team-agent/src/messaging/activity.rs +1 -0
- package/crates/team-agent/src/messaging/address.rs +1 -0
- package/crates/team-agent/src/messaging/delivery.rs +109 -41
- package/crates/team-agent/src/messaging/helpers.rs +2 -1
- package/crates/team-agent/src/messaging/leader_channel.rs +34 -10
- package/crates/team-agent/src/messaging/leader_receiver.rs +42 -24
- package/crates/team-agent/src/messaging/mod.rs +10 -14
- package/crates/team-agent/src/messaging/peers.rs +2 -0
- package/crates/team-agent/src/messaging/persist.rs +3 -1
- package/crates/team-agent/src/messaging/presentation.rs +111 -1
- package/crates/team-agent/src/messaging/results.rs +166 -17
- package/crates/team-agent/src/messaging/scheduler.rs +1 -0
- package/crates/team-agent/src/messaging/selftest.rs +1 -1
- package/crates/team-agent/src/messaging/send.rs +135 -89
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +6 -6
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +187 -0
- package/crates/team-agent/src/messaging/tests/mod.rs +5 -0
- package/crates/team-agent/src/messaging/tests/runtime.rs +13 -6
- package/crates/team-agent/src/messaging/types.rs +7 -2
- package/crates/team-agent/src/messaging/watchers.rs +24 -13
- package/crates/team-agent/src/model/enums.rs +1 -0
- package/crates/team-agent/src/model/errors.rs +1 -0
- package/crates/team-agent/src/model/ids.rs +1 -0
- package/crates/team-agent/src/model/mod.rs +2 -0
- package/crates/team-agent/src/model/name_similarity.rs +1 -0
- package/crates/team-agent/src/model/pane_authority_refusal.rs +359 -0
- package/crates/team-agent/src/model/paths.rs +1 -0
- package/crates/team-agent/src/model/permissions.rs +3 -2
- package/crates/team-agent/src/model/routing.rs +1 -0
- package/crates/team-agent/src/model/spec.rs +17 -0
- package/crates/team-agent/src/model/task_graph.rs +1 -0
- package/crates/team-agent/src/model/yaml/tests.rs +1 -0
- package/crates/team-agent/src/model/yaml.rs +1 -0
- package/crates/team-agent/src/packaging/install.rs +9 -147
- package/crates/team-agent/src/packaging/migrate.rs +2 -0
- package/crates/team-agent/src/packaging/mod.rs +1 -0
- package/crates/team-agent/src/packaging/repair.rs +2 -0
- package/crates/team-agent/src/packaging/tests.rs +29 -218
- package/crates/team-agent/src/packaging/types.rs +8 -15
- package/crates/team-agent/src/platform/argv.rs +4 -0
- package/crates/team-agent/src/platform/errors.rs +10 -1
- package/crates/team-agent/src/platform/file_lock.rs +4 -157
- package/crates/team-agent/src/platform/mod.rs +0 -61
- package/crates/team-agent/src/platform/process.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +1 -0
- package/crates/team-agent/src/provider/adapters/claude.rs +1 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +1 -0
- package/crates/team-agent/src/provider/adapters/codex.rs +1 -0
- package/crates/team-agent/src/provider/adapters/copilot.rs +1 -0
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +1 -0
- package/crates/team-agent/src/provider/adapters/fake.rs +1 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +1 -0
- package/crates/team-agent/src/provider/approvals/mod.rs +1 -0
- package/crates/team-agent/src/provider/approvals/parsing.rs +2 -5
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +6 -5
- package/crates/team-agent/src/provider/classify.rs +1 -0
- package/crates/team-agent/src/provider/faults.rs +1 -26
- package/crates/team-agent/src/provider/helpers.rs +1 -0
- package/crates/team-agent/src/provider/mod.rs +1 -1
- package/crates/team-agent/src/provider/session/capture.rs +41 -22
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +1 -0
- package/crates/team-agent/src/provider/session/mod.rs +2 -4
- package/crates/team-agent/src/provider/session/resume.rs +2 -209
- package/crates/team-agent/src/provider/session_scan/claude.rs +93 -3
- package/crates/team-agent/src/provider/session_scan/codex.rs +1 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +24 -7
- package/crates/team-agent/src/provider/session_scan/copilot.rs +1 -0
- package/crates/team-agent/src/provider/session_scan.rs +6 -42
- package/crates/team-agent/src/provider/startup_prompt.rs +1 -0
- package/crates/team-agent/src/provider/types.rs +1 -0
- package/crates/team-agent/src/provider/wire.rs +1 -0
- package/crates/team-agent/src/state/identity.rs +16 -5
- package/crates/team-agent/src/state/identity_keys.rs +1 -0
- package/crates/team-agent/src/state/mod.rs +2 -0
- package/crates/team-agent/src/state/owner_gate.rs +5 -0
- package/crates/team-agent/src/state/ownership.rs +10 -4
- package/crates/team-agent/src/state/paths.rs +12 -0
- package/crates/team-agent/src/state/persist.rs +9 -3
- package/crates/team-agent/src/state/projection.rs +15 -2
- package/crates/team-agent/src/state/repository/intent.rs +1 -0
- package/crates/team-agent/src/state/repository/tests.rs +1 -0
- package/crates/team-agent/src/state/repository.rs +7 -0
- package/crates/team-agent/src/state/selector.rs +1 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +39 -0
- package/crates/team-agent/src/tmux_backend.rs +63 -0
- package/crates/team-agent/src/topology.rs +3 -0
- package/crates/team-agent/src/transport.rs +15 -0
- package/package.json +4 -4
- package/skills/team-agent/command-coverage.json +379 -0
- package/crates/team-agent/src/leader/inject.rs +0 -33
- package/crates/team-agent/src/provider/command.rs +0 -80
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
//! Claude compatible-api profile launch contracts for Batch A Lane 2.
|
|
2
|
+
//!
|
|
3
|
+
//! The entrypoints are lifecycle/CLI surfaces with a recording transport, plus the S0 public
|
|
4
|
+
//! `ProviderProfileLaunch` shape. Before S0 lands this file compile-reds on the shared type; after
|
|
5
|
+
//! S0 it behavior-reds on lifecycle/profile wiring.
|
|
6
|
+
|
|
7
|
+
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
8
|
+
|
|
9
|
+
#[path = "../../../tests/support/hermetic.rs"]
|
|
10
|
+
mod hermetic_guard;
|
|
11
|
+
#[allow(dead_code)]
|
|
12
|
+
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
13
|
+
|
|
14
|
+
#[path = "../../../tests/support/composite_source.rs"]
|
|
15
|
+
mod composite_source;
|
|
16
|
+
use std::collections::{BTreeMap, BTreeSet};
|
|
17
|
+
use std::path::{Path, PathBuf};
|
|
18
|
+
use std::process::Command;
|
|
19
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
20
|
+
use std::sync::Mutex;
|
|
21
|
+
|
|
22
|
+
use serde_json::{json, Value};
|
|
23
|
+
use serial_test::serial;
|
|
24
|
+
use team_agent::lifecycle::quick_start_with_transport_in_workspace;
|
|
25
|
+
use team_agent::provider::{ProviderCommandOverrides, ProviderProfileLaunch};
|
|
26
|
+
use team_agent::state::persist::load_runtime_state;
|
|
27
|
+
use team_agent::transport::{
|
|
28
|
+
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
29
|
+
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName, SetEnvOutcome,
|
|
30
|
+
SpawnResult, SubmitVerification, Target, Transport, TransportError, TurnVerification,
|
|
31
|
+
WindowName,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
#[test]
|
|
35
|
+
#[serial(env)]
|
|
36
|
+
fn compatible_api_profile_quick_start_spawns_claude_with_profile_env_and_state_metadata() {
|
|
37
|
+
assert_s0_profile_launch_shape();
|
|
38
|
+
|
|
39
|
+
let ws = tmp_dir("profile-launch");
|
|
40
|
+
let team = write_claude_profile_team(&ws, "claudeprof", "clauder");
|
|
41
|
+
let transport = RecordingTransport::default();
|
|
42
|
+
|
|
43
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("claudeprof"), &transport)
|
|
44
|
+
.expect(
|
|
45
|
+
"quick-start through recording transport should reach the real lifecycle spawn path",
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
let spawn = transport.single_spawn();
|
|
49
|
+
for (key, expected) in [
|
|
50
|
+
("CLAUDE_CONFIG_DIR", None),
|
|
51
|
+
("ANTHROPIC_BASE_URL", Some("https://llm.local/v1")),
|
|
52
|
+
("ANTHROPIC_AUTH_TOKEN", Some("local-secret")),
|
|
53
|
+
("ANTHROPIC_MODEL", Some("profile-effective-haiku")),
|
|
54
|
+
] {
|
|
55
|
+
let got = spawn.env.get(key).map(String::as_str);
|
|
56
|
+
match expected {
|
|
57
|
+
Some(expected) => assert_eq!(
|
|
58
|
+
got,
|
|
59
|
+
Some(expected),
|
|
60
|
+
"Claude compatible_api profile launch must inject {key} from .team/current/profiles/local.env; env={:?}",
|
|
61
|
+
spawn.env
|
|
62
|
+
),
|
|
63
|
+
None => assert!(
|
|
64
|
+
got.is_some_and(|value| !value.is_empty()),
|
|
65
|
+
"Claude compatible_api profile launch must inject non-empty {key}; env={:?}",
|
|
66
|
+
spawn.env
|
|
67
|
+
),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
assert!(
|
|
71
|
+
!spawn.env.contains_key("ANTHROPIC_API_KEY"),
|
|
72
|
+
"compatible_api must unset ANTHROPIC_API_KEY and use ANTHROPIC_AUTH_TOKEN instead; env={:?}",
|
|
73
|
+
spawn.env
|
|
74
|
+
);
|
|
75
|
+
assert!(
|
|
76
|
+
argv_contains_adjacent(&spawn.argv, &["--model", "profile-effective-haiku"]),
|
|
77
|
+
"profile model must become the effective Claude model when role model is null; argv={:?}",
|
|
78
|
+
spawn.argv
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
let state = load_runtime_state(&ws).unwrap();
|
|
82
|
+
let agent = &state["teams"]["claudeprof"]["agents"]["clauder"];
|
|
83
|
+
assert!(
|
|
84
|
+
agent["_pending_session_id"].as_str().is_some_and(|value| !value.is_empty()),
|
|
85
|
+
"lifecycle must persist CommandPlan.expected_session_id as agents[*]._pending_session_id; state={state}"
|
|
86
|
+
);
|
|
87
|
+
assert!(
|
|
88
|
+
agent["claude_projects_root"].as_str().is_some_and(|value| !value.is_empty()),
|
|
89
|
+
"lifecycle must persist CommandPlan.provider_projects_root/profile claude_projects_root for capture; state={state}"
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#[ignore = "flaky under parallel suite, tracked"]
|
|
94
|
+
#[test]
|
|
95
|
+
#[serial(env)]
|
|
96
|
+
fn subscription_profile_keeps_default_claude_config_dir_for_logged_in_quota() {
|
|
97
|
+
let ws = tmp_dir("subscription-config");
|
|
98
|
+
let team = write_claude_subscription_profile_team(&ws, "subteam", "clauder");
|
|
99
|
+
let transport = RecordingTransport::default();
|
|
100
|
+
|
|
101
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("subteam"), &transport)
|
|
102
|
+
.expect("subscription profile should launch without managed config isolation");
|
|
103
|
+
|
|
104
|
+
let spawn = transport.single_spawn();
|
|
105
|
+
assert!(
|
|
106
|
+
!spawn.env.contains_key("CLAUDE_CONFIG_DIR"),
|
|
107
|
+
"subscription Claude workers must inherit the user's default ~/.claude login state; env={:?}",
|
|
108
|
+
spawn.env
|
|
109
|
+
);
|
|
110
|
+
assert!(
|
|
111
|
+
!spawn.env.contains_key("ANTHROPIC_API_KEY")
|
|
112
|
+
&& !spawn.env.contains_key("ANTHROPIC_AUTH_TOKEN"),
|
|
113
|
+
"subscription launch must not switch into API-token auth via profile env; env={:?}",
|
|
114
|
+
spawn.env
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
let state = load_runtime_state(&ws).unwrap();
|
|
118
|
+
let agent = &state["teams"]["subteam"]["agents"]["clauder"];
|
|
119
|
+
assert_eq!(
|
|
120
|
+
agent.get("claude_projects_root"),
|
|
121
|
+
None,
|
|
122
|
+
"without a supported fine-grained Claude projects-root env, subscription workers must not fake an isolated transcript root; state={state}"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#[test]
|
|
127
|
+
fn launch_restart_start_add_and_fork_all_delegate_to_the_profile_launch_resolver() {
|
|
128
|
+
let launch = source("src/lifecycle/launch.rs");
|
|
129
|
+
let restart_common = source("src/lifecycle/restart/common.rs");
|
|
130
|
+
let restart_agent = source("src/lifecycle/restart/agent.rs");
|
|
131
|
+
|
|
132
|
+
let surfaces = [
|
|
133
|
+
("launch quick-start", &launch, "spawn_agents"),
|
|
134
|
+
("add-agent", &launch, "add_agent_with_transport"),
|
|
135
|
+
("fork-agent", &launch, "fork_agent_with_transport"),
|
|
136
|
+
("restart", &restart_common, "restart_with_transport"),
|
|
137
|
+
("start-agent", &restart_agent, "start_agent_at_paths"),
|
|
138
|
+
];
|
|
139
|
+
for (surface, source, entry) in surfaces {
|
|
140
|
+
let section = source
|
|
141
|
+
.find(entry)
|
|
142
|
+
.map(|idx| &source[idx..])
|
|
143
|
+
.unwrap_or(source.as_str());
|
|
144
|
+
assert!(
|
|
145
|
+
section.contains("prepare_provider_profile_launch"),
|
|
146
|
+
"{surface} must call the single profile resolver before building/spawning provider argv; entry={entry}"
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#[test]
|
|
152
|
+
fn diagnose_missing_profile_is_rc1_ok_false_and_zero_token() {
|
|
153
|
+
let ws = tmp_dir("diagnose-missing-profile");
|
|
154
|
+
let team = write_claude_profile_team(&ws, "diagteam", "clauder");
|
|
155
|
+
std::fs::remove_file(
|
|
156
|
+
ws.join(".team")
|
|
157
|
+
.join("current")
|
|
158
|
+
.join("profiles")
|
|
159
|
+
.join("local.env"),
|
|
160
|
+
)
|
|
161
|
+
.unwrap();
|
|
162
|
+
|
|
163
|
+
let output = Command::new(crate::lifecycle::tests::test_binary_path())
|
|
164
|
+
.args(["diagnose", "--workspace", ws.to_str().unwrap(), "--json"])
|
|
165
|
+
.current_dir(&team)
|
|
166
|
+
.output()
|
|
167
|
+
.expect("diagnose subprocess should run");
|
|
168
|
+
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
169
|
+
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
170
|
+
let json = serde_json::from_str::<Value>(stdout.trim()).unwrap_or_else(|_| json!({}));
|
|
171
|
+
|
|
172
|
+
assert!(
|
|
173
|
+
!output.status.success(),
|
|
174
|
+
"diagnose with missing referenced profile must exit non-zero before any token/provider call; stdout={stdout} stderr={stderr}"
|
|
175
|
+
);
|
|
176
|
+
assert_eq!(
|
|
177
|
+
json["ok"],
|
|
178
|
+
json!(false),
|
|
179
|
+
"diagnose missing profile must emit ok:false JSON; stdout={stdout} stderr={stderr}"
|
|
180
|
+
);
|
|
181
|
+
assert!(
|
|
182
|
+
stdout.contains("profile") || stderr.contains("profile"),
|
|
183
|
+
"diagnose missing profile must name the profile problem without invoking Claude; stdout={stdout} stderr={stderr}"
|
|
184
|
+
);
|
|
185
|
+
assert!(
|
|
186
|
+
!stdout.contains("tokens") && !stderr.contains("tokens"),
|
|
187
|
+
"diagnose dry-run must not consume provider tokens or report token usage; stdout={stdout} stderr={stderr}"
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
fn assert_s0_profile_launch_shape() {
|
|
192
|
+
let profile = ProviderProfileLaunch {
|
|
193
|
+
env_overlay: BTreeMap::from([(
|
|
194
|
+
"ANTHROPIC_MODEL".to_string(),
|
|
195
|
+
"profile-effective-haiku".to_string(),
|
|
196
|
+
)]),
|
|
197
|
+
env_unset: BTreeSet::from(["ANTHROPIC_API_KEY".to_string()]),
|
|
198
|
+
command_overrides: ProviderCommandOverrides {
|
|
199
|
+
model: Some("profile-effective-haiku".to_string()),
|
|
200
|
+
..ProviderCommandOverrides::default()
|
|
201
|
+
},
|
|
202
|
+
claude_config_dir: Some(PathBuf::from("/tmp/claude-config")),
|
|
203
|
+
claude_projects_root: Some(PathBuf::from("/tmp/claude-config/projects")),
|
|
204
|
+
managed_mcp_config: true,
|
|
205
|
+
};
|
|
206
|
+
assert!(profile.managed_mcp_config);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
fn write_claude_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> PathBuf {
|
|
210
|
+
let team = ws.join(team_key);
|
|
211
|
+
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
212
|
+
std::fs::create_dir_all(ws.join(".team").join("current").join("profiles")).unwrap();
|
|
213
|
+
std::fs::write(
|
|
214
|
+
ws.join(".team").join("current").join("profiles").join("local.env"),
|
|
215
|
+
"ANTHROPIC_BASE_URL=https://llm.local/v1\nANTHROPIC_AUTH_TOKEN=local-secret\nANTHROPIC_MODEL=profile-effective-haiku\nANTHROPIC_API_KEY=\n",
|
|
216
|
+
)
|
|
217
|
+
.unwrap();
|
|
218
|
+
std::fs::write(
|
|
219
|
+
team.join("TEAM.md"),
|
|
220
|
+
format!(
|
|
221
|
+
"---\nname: {team_key}\nobjective: Claude compatible profile launch contract.\nprovider: claude\nauth_mode: compatible_api\n---\n\nTeam.\n"
|
|
222
|
+
),
|
|
223
|
+
)
|
|
224
|
+
.unwrap();
|
|
225
|
+
std::fs::write(
|
|
226
|
+
team.join("agents").join(format!("{agent_id}.md")),
|
|
227
|
+
format!(
|
|
228
|
+
"---\nname: {agent_id}\nrole: Claude Worker\nprovider: claude\nauth_mode: compatible_api\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
229
|
+
),
|
|
230
|
+
)
|
|
231
|
+
.unwrap();
|
|
232
|
+
team
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
fn write_claude_subscription_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> PathBuf {
|
|
236
|
+
let team = ws.join(team_key);
|
|
237
|
+
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
238
|
+
std::fs::create_dir_all(ws.join(".team").join("current").join("profiles")).unwrap();
|
|
239
|
+
std::fs::write(
|
|
240
|
+
ws.join(".team")
|
|
241
|
+
.join("current")
|
|
242
|
+
.join("profiles")
|
|
243
|
+
.join("local.env"),
|
|
244
|
+
"AUTH_MODE=subscription\nMODEL=claude-sonnet-4-6\n",
|
|
245
|
+
)
|
|
246
|
+
.unwrap();
|
|
247
|
+
std::fs::write(
|
|
248
|
+
team.join("TEAM.md"),
|
|
249
|
+
format!(
|
|
250
|
+
"---\nname: {team_key}\nobjective: Claude subscription profile launch contract.\nprovider: claude\nauth_mode: subscription\n---\n\nTeam.\n"
|
|
251
|
+
),
|
|
252
|
+
)
|
|
253
|
+
.unwrap();
|
|
254
|
+
std::fs::write(
|
|
255
|
+
team.join("agents").join(format!("{agent_id}.md")),
|
|
256
|
+
format!(
|
|
257
|
+
"---\nname: {agent_id}\nrole: Claude Worker\nprovider: claude\nauth_mode: subscription\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
258
|
+
),
|
|
259
|
+
)
|
|
260
|
+
.unwrap();
|
|
261
|
+
team
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fn source(path: &str) -> String {
|
|
265
|
+
composite_source::composite_source(path)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
fn argv_contains_adjacent(hay: &[String], needle: &[&str]) -> bool {
|
|
269
|
+
hay.windows(needle.len())
|
|
270
|
+
.any(|window| window.iter().map(String::as_str).eq(needle.iter().copied()))
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
fn tmp_dir(tag: &str) -> PathBuf {
|
|
274
|
+
static N: AtomicU64 = AtomicU64::new(0);
|
|
275
|
+
let dir = std::env::temp_dir().join(format!(
|
|
276
|
+
"ta-rs-claude-profile-launch-{tag}-{}-{}",
|
|
277
|
+
std::process::id(),
|
|
278
|
+
N.fetch_add(1, Ordering::Relaxed)
|
|
279
|
+
));
|
|
280
|
+
let _ = std::fs::remove_dir_all(&dir);
|
|
281
|
+
std::fs::create_dir_all(&dir).unwrap();
|
|
282
|
+
std::fs::canonicalize(dir).unwrap()
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
#[derive(Debug, Clone)]
|
|
286
|
+
struct RecordedSpawn {
|
|
287
|
+
argv: Vec<String>,
|
|
288
|
+
env: BTreeMap<String, String>,
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
#[derive(Debug, Default)]
|
|
292
|
+
struct RecordingTransport {
|
|
293
|
+
spawns: Mutex<Vec<RecordedSpawn>>,
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
impl RecordingTransport {
|
|
297
|
+
fn single_spawn(&self) -> RecordedSpawn {
|
|
298
|
+
let spawns = self.spawns.lock().unwrap();
|
|
299
|
+
assert_eq!(
|
|
300
|
+
spawns.len(),
|
|
301
|
+
1,
|
|
302
|
+
"fixture should record one Claude worker spawn; spawns={spawns:?}"
|
|
303
|
+
);
|
|
304
|
+
spawns[0].clone()
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
impl Transport for RecordingTransport {
|
|
309
|
+
fn kind(&self) -> BackendKind {
|
|
310
|
+
BackendKind::Tmux
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
fn spawn_first(
|
|
314
|
+
&self,
|
|
315
|
+
session: &SessionName,
|
|
316
|
+
window: &WindowName,
|
|
317
|
+
argv: &[String],
|
|
318
|
+
_cwd: &Path,
|
|
319
|
+
env: &BTreeMap<String, String>,
|
|
320
|
+
) -> Result<SpawnResult, TransportError> {
|
|
321
|
+
self.spawn_into(session, window, argv, _cwd, env)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
fn spawn_into(
|
|
325
|
+
&self,
|
|
326
|
+
session: &SessionName,
|
|
327
|
+
window: &WindowName,
|
|
328
|
+
argv: &[String],
|
|
329
|
+
_cwd: &Path,
|
|
330
|
+
env: &BTreeMap<String, String>,
|
|
331
|
+
) -> Result<SpawnResult, TransportError> {
|
|
332
|
+
let mut spawns = self.spawns.lock().unwrap();
|
|
333
|
+
spawns.push(RecordedSpawn {
|
|
334
|
+
argv: argv.to_vec(),
|
|
335
|
+
env: env.clone(),
|
|
336
|
+
});
|
|
337
|
+
Ok(SpawnResult {
|
|
338
|
+
pane_id: PaneId::new(format!("%{}", spawns.len())),
|
|
339
|
+
session: session.clone(),
|
|
340
|
+
window: window.clone(),
|
|
341
|
+
child_pid: Some(10_000 + spawns.len() as u32),
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
fn inject(
|
|
346
|
+
&self,
|
|
347
|
+
_target: &Target,
|
|
348
|
+
_payload: &InjectPayload,
|
|
349
|
+
_submit: Key,
|
|
350
|
+
_bracketed: bool,
|
|
351
|
+
) -> Result<InjectReport, TransportError> {
|
|
352
|
+
Ok(InjectReport {
|
|
353
|
+
stage_reached: InjectStage::Submit,
|
|
354
|
+
inject_verification: InjectVerification::CaptureContainsToken,
|
|
355
|
+
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
356
|
+
turn_verification: TurnVerification::NotYetObserved,
|
|
357
|
+
attempts: 1,
|
|
358
|
+
submit_diagnostics: None,
|
|
359
|
+
})
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
363
|
+
Ok(())
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
fn capture(
|
|
367
|
+
&self,
|
|
368
|
+
_target: &Target,
|
|
369
|
+
range: CaptureRange,
|
|
370
|
+
) -> Result<CapturedText, TransportError> {
|
|
371
|
+
Ok(CapturedText {
|
|
372
|
+
text: String::new(),
|
|
373
|
+
range,
|
|
374
|
+
})
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
|
|
378
|
+
match field {
|
|
379
|
+
PaneField::PaneWidth => Ok(Some("120".to_string())),
|
|
380
|
+
_ => Ok(None),
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
fn liveness(
|
|
385
|
+
&self,
|
|
386
|
+
_pane: &PaneId,
|
|
387
|
+
) -> Result<team_agent::transport::PaneLiveness, TransportError> {
|
|
388
|
+
Ok(team_agent::transport::PaneLiveness::Live)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
392
|
+
Ok(Vec::new())
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
396
|
+
Ok(false)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
400
|
+
Ok(Vec::new())
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
fn set_session_env(
|
|
404
|
+
&self,
|
|
405
|
+
_session: &SessionName,
|
|
406
|
+
_key: &str,
|
|
407
|
+
_value: &str,
|
|
408
|
+
) -> Result<SetEnvOutcome, TransportError> {
|
|
409
|
+
Ok(SetEnvOutcome::Applied)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
413
|
+
Ok(())
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
|
|
417
|
+
Ok(())
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
421
|
+
Ok(AttachOutcome::Attached)
|
|
422
|
+
}
|
|
423
|
+
}
|