@team-agent/installer 0.5.128 → 0.6.1
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/README.md +4 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +37 -20
- package/skills/team-agent/command-coverage.json +169 -183
- package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +64 -30
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1288
- package/crates/team-agent/src/cli/arguments.rs +0 -405
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1721
- package/crates/team-agent/src/cli/emit.rs +0 -2930
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
- package/crates/team-agent/src/cli/intent/tests.rs +0 -689
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6545
- package/crates/team-agent/src/cli/models.rs +0 -1206
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/schedule.rs +0 -175
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -156
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -199
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -165
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -827
- package/crates/team-agent/src/compiler.rs +0 -890
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -364
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3024
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1527
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/direct_delivery.rs +0 -368
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/inbox_store.rs +0 -169
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -888
- package/crates/team-agent/src/leader/start.rs +0 -4501
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -147
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -557
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -227
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
- package/crates/team-agent/src/lifecycle/tests.rs +0 -105
- package/crates/team-agent/src/lifecycle/types.rs +0 -877
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -889
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3727
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -336
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -167
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/reminders.rs +0 -316
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -223
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -472
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -1150
- 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/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -708
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -910
- package/crates/team-agent/src/provider/session/capture.rs +0 -2731
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
- package/crates/team-agent/src/provider/session_scan.rs +0 -71
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
- package/crates/team-agent/src/provider/tests/classify.rs +0 -148
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -177
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -394
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
- package/crates/team-agent/src/tmux_backend.rs +0 -4492
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,1062 +0,0 @@
|
|
|
1
|
-
use std::os::unix::fs::PermissionsExt;
|
|
2
|
-
use std::path::{Path, PathBuf};
|
|
3
|
-
use std::sync::atomic::{AtomicU32, Ordering};
|
|
4
|
-
|
|
5
|
-
use crate::lifecycle::launch::launch_with_transport_in_workspace;
|
|
6
|
-
use crate::lifecycle::launch::pi_mcp::{
|
|
7
|
-
PiExecutableChain, PiMaterializeRequest, PiSessionScope,
|
|
8
|
-
PiWrapperRequest, materialize_pi_plan, materialize_pi_resume_plan,
|
|
9
|
-
parse_pi_list_models_table, pi_seat_paths, resolve_pi_executable_chain,
|
|
10
|
-
validate_pi_executable_chain, validate_pi_wrapper_source, write_pi_wrapper,
|
|
11
|
-
write_pi_wrapper_with_publish,
|
|
12
|
-
};
|
|
13
|
-
use crate::lifecycle::start_agent_with_transport;
|
|
14
|
-
use crate::model::enums::ProviderEffort;
|
|
15
|
-
use crate::provider::session_scan::{CaptureSessionContext, scan_session_candidates_once};
|
|
16
|
-
use crate::provider::{McpConfig, Provider, SessionId};
|
|
17
|
-
use crate::transport::test_support::OfflineTransport;
|
|
18
|
-
|
|
19
|
-
#[path = "../../../tests/support/hermetic.rs"]
|
|
20
|
-
mod hermetic_guard;
|
|
21
|
-
use hermetic_guard::HermeticTestEnv;
|
|
22
|
-
|
|
23
|
-
const CATALOG_DIGEST: &str = "726cedb6c3f6fe80a0d7b98918d8ed5063695e01f510a48f46c4bad5daab49fe";
|
|
24
|
-
static NEXT_ROOT: AtomicU32 = AtomicU32::new(0);
|
|
25
|
-
const PI_WRAPPER_CHILD: &str = "TEAM_AGENT_TEST_PI_WRAPPER_CHILD";
|
|
26
|
-
const PI_WRAPPER_AMBIENT_CHILD: &str = "TEAM_AGENT_TEST_PI_WRAPPER_AMBIENT_CHILD";
|
|
27
|
-
const PI_SYMLINK_CHILD: &str = "TEAM_AGENT_TEST_PI_SYMLINK_CHILD";
|
|
28
|
-
const PI_WRAPPER_PARENT_PID: &str = "TEAM_AGENT_TEST_PI_WRAPPER_PARENT_PID";
|
|
29
|
-
const PI_WRAPPER_TEST: &str = concat!(
|
|
30
|
-
"lifecycle::tests::pi_executable_mcp_red::",
|
|
31
|
-
"pi_wrapper_is_atomic_per_seat_and_embeds_exact_candidate"
|
|
32
|
-
);
|
|
33
|
-
const PI_WRAPPER_AMBIENT_TEST: &str = concat!(
|
|
34
|
-
"lifecycle::tests::pi_executable_mcp_red::",
|
|
35
|
-
"pi_wrapper_runtime_registration_does_not_copy_ambient_config"
|
|
36
|
-
);
|
|
37
|
-
const PI_SYMLINK_TEST: &str = concat!(
|
|
38
|
-
"lifecycle::tests::pi_executable_mcp_red::",
|
|
39
|
-
"pi_standard_npm_symlink_is_a_verified_launch_entry"
|
|
40
|
-
);
|
|
41
|
-
const PI_MATERIALIZER_CHILD: &str = "TEAM_AGENT_TEST_PI_MATERIALIZER_CHILD";
|
|
42
|
-
const PI_MATERIALIZER_TEST: &str = concat!(
|
|
43
|
-
"lifecycle::tests::pi_executable_mcp_red::",
|
|
44
|
-
"pi_materializer_and_worker_routes_use_the_recorded_scope"
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
fn run_process_isolated(marker: &str, test_name: &str, body: impl FnOnce()) {
|
|
48
|
-
if std::env::var_os(marker).is_some() {
|
|
49
|
-
body();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let output =
|
|
54
|
-
std::process::Command::new(std::env::current_exe().expect("current lib-test executable"))
|
|
55
|
-
.args(["--exact", test_name, "--nocapture", "--test-threads=1"])
|
|
56
|
-
.env(marker, "1")
|
|
57
|
-
.env(PI_WRAPPER_PARENT_PID, std::process::id().to_string())
|
|
58
|
-
.output()
|
|
59
|
-
.expect("run Pi wrapper send_message fixture in isolated child test process");
|
|
60
|
-
assert!(
|
|
61
|
-
output.status.success(),
|
|
62
|
-
"isolated Pi wrapper child failed: test={test_name} status={:?}\nstdout:\n{}\nstderr:\n{}",
|
|
63
|
-
output.status.code(),
|
|
64
|
-
String::from_utf8_lossy(&output.stdout),
|
|
65
|
-
String::from_utf8_lossy(&output.stderr),
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
fn assert_isolated_child() {
|
|
70
|
-
let parent_pid = std::env::var(PI_WRAPPER_PARENT_PID)
|
|
71
|
-
.expect("isolated child receives the parent test process id");
|
|
72
|
-
assert_ne!(
|
|
73
|
-
std::process::id().to_string(),
|
|
74
|
-
parent_pid,
|
|
75
|
-
"Pi wrapper send_message fixture must not run in the parent lib-test process"
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
fn temp_root(label: &str) -> PathBuf {
|
|
80
|
-
let seq = NEXT_ROOT.fetch_add(1, Ordering::Relaxed);
|
|
81
|
-
let root = std::env::temp_dir().join(format!(
|
|
82
|
-
"team-agent-pi-{label}-{}-{seq}",
|
|
83
|
-
std::process::id()
|
|
84
|
-
));
|
|
85
|
-
std::fs::create_dir_all(&root).expect("create fixture root");
|
|
86
|
-
root
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
fn mcp_config(candidate: &Path, workspace: &Path, agent_id: &str) -> McpConfig {
|
|
90
|
-
McpConfig {
|
|
91
|
-
raw: serde_json::json!({
|
|
92
|
-
"team_orchestrator": {
|
|
93
|
-
"command": candidate,
|
|
94
|
-
"args": ["mcp-server"],
|
|
95
|
-
"env": {
|
|
96
|
-
"TEAM_AGENT_WORKSPACE": workspace,
|
|
97
|
-
"TEAM_AGENT_ID": agent_id,
|
|
98
|
-
"TEAM_AGENT_AGENT_ID": agent_id,
|
|
99
|
-
"TEAM_AGENT_OWNER_TEAM_ID": "team-a",
|
|
100
|
-
"TEAM_AGENT_AUTH_MODE": "subscription"
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
#[test]
|
|
108
|
-
fn pi_executable_chain_accepts_any_first_path_entry_and_freezes_catalog() {
|
|
109
|
-
let chain = PiExecutableChain {
|
|
110
|
-
path_entry: PathBuf::from("/Users/fixture/.local/bin/pi"),
|
|
111
|
-
pi_version: "0.84.3".to_string(),
|
|
112
|
-
catalog_sha256: CATALOG_DIGEST.to_string(),
|
|
113
|
-
};
|
|
114
|
-
validate_pi_executable_chain(&chain).expect("the PATH wrapper entry is valid");
|
|
115
|
-
|
|
116
|
-
// A plain binary or compiled wrapper first on PATH is what bare `pi` runs.
|
|
117
|
-
let mut direct_binary = chain.clone();
|
|
118
|
-
direct_binary.path_entry = PathBuf::from("/opt/homebrew/bin/pi");
|
|
119
|
-
validate_pi_executable_chain(&direct_binary)
|
|
120
|
-
.expect("a direct binary first on PATH is the native launch entry");
|
|
121
|
-
|
|
122
|
-
let mut newer = chain.clone();
|
|
123
|
-
newer.pi_version = "0.84.4".to_string();
|
|
124
|
-
validate_pi_executable_chain(&newer)
|
|
125
|
-
.expect("an arbitrary newer Pi version with the same public protocol is valid");
|
|
126
|
-
|
|
127
|
-
for bad in ["", "pi", "/opt/homebrew/bin/pi-native"] {
|
|
128
|
-
let mut wrong = chain.clone();
|
|
129
|
-
wrong.path_entry = PathBuf::from(bad);
|
|
130
|
-
assert!(validate_pi_executable_chain(&wrong).is_err(), "{bad:?}");
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
let mut wrong_catalog = chain.clone();
|
|
134
|
-
wrong_catalog.catalog_sha256 = "00".repeat(32);
|
|
135
|
-
assert!(validate_pi_executable_chain(&wrong_catalog).is_err());
|
|
136
|
-
|
|
137
|
-
assert!(parse_pi_list_models_table(b"provider model\nopenai-codex gpt-5.6-luna\n").is_ok());
|
|
138
|
-
assert!(parse_pi_list_models_table(b"provider model\n").is_err());
|
|
139
|
-
assert!(parse_pi_list_models_table(b"provider model\nmalformed\n").is_err());
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
#[test]
|
|
143
|
-
fn pi_standard_npm_symlink_is_a_verified_launch_entry() {
|
|
144
|
-
run_process_isolated(PI_SYMLINK_CHILD, PI_SYMLINK_TEST, || {
|
|
145
|
-
assert_isolated_child();
|
|
146
|
-
let root = temp_root("npm-symlink");
|
|
147
|
-
let bin = root.join("bin");
|
|
148
|
-
let later_bin = root.join("later-bin");
|
|
149
|
-
std::fs::create_dir_all(&bin).expect("create bin");
|
|
150
|
-
std::fs::create_dir_all(&later_bin).expect("create later bin");
|
|
151
|
-
let real = root.join("cli.js");
|
|
152
|
-
let script = "#!/bin/sh\ncase \"$1\" in\n --version) printf '0.84.4\\n' ;;\n --list-models) printf 'provider model\\nteam-agent qwen3.8-27b\\n' ;;\n list) exit 64 ;;\n *) exit 64 ;;\nesac\n";
|
|
153
|
-
std::fs::write(&real, &script).expect("write protocol-capable Pi entry");
|
|
154
|
-
std::fs::set_permissions(&real, std::fs::Permissions::from_mode(0o755))
|
|
155
|
-
.expect("make Pi entry executable");
|
|
156
|
-
std::os::unix::fs::symlink(&real, bin.join("pi")).expect("create npm-style symlink");
|
|
157
|
-
std::fs::write(later_bin.join("pi"), script).expect("write later Pi wrapper");
|
|
158
|
-
std::fs::set_permissions(later_bin.join("pi"), std::fs::Permissions::from_mode(0o755))
|
|
159
|
-
.expect("make later Pi wrapper executable");
|
|
160
|
-
unsafe {
|
|
161
|
-
std::env::set_var(
|
|
162
|
-
"PATH",
|
|
163
|
-
std::env::join_paths([&bin, &later_bin]).expect("join fixture PATH"),
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let (chain, models) = resolve_pi_executable_chain()
|
|
168
|
-
.expect("the first PATH Pi entry must define direct Pi behavior");
|
|
169
|
-
assert_eq!(chain.path_entry, bin.join("pi"), "the npm symlink is kept as found");
|
|
170
|
-
assert_eq!(models, ["team-agent/qwen3.8-27b"]);
|
|
171
|
-
|
|
172
|
-
// A user wrapper prepended to PATH is the entry, and every probe runs it.
|
|
173
|
-
let wrappers = root.join("wrappers");
|
|
174
|
-
std::fs::create_dir_all(&wrappers).expect("create wrapper dir");
|
|
175
|
-
let marker = root.join("wrapper-invocations");
|
|
176
|
-
std::fs::write(
|
|
177
|
-
wrappers.join("pi"),
|
|
178
|
-
format!(
|
|
179
|
-
"#!/bin/sh\nprintf '%s\\n' \"$*\" >> '{}'\nexec '{}' \"$@\"\n",
|
|
180
|
-
marker.display(),
|
|
181
|
-
bin.join("pi").display()
|
|
182
|
-
),
|
|
183
|
-
)
|
|
184
|
-
.expect("write user Pi wrapper");
|
|
185
|
-
std::fs::set_permissions(wrappers.join("pi"), std::fs::Permissions::from_mode(0o755))
|
|
186
|
-
.expect("make user Pi wrapper executable");
|
|
187
|
-
unsafe {
|
|
188
|
-
std::env::set_var(
|
|
189
|
-
"PATH",
|
|
190
|
-
std::env::join_paths([&wrappers, &bin, &later_bin]).expect("join wrapper PATH"),
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
let (chain, models) =
|
|
194
|
-
resolve_pi_executable_chain().expect("a user wrapper first on PATH is accepted");
|
|
195
|
-
assert_eq!(chain.path_entry, wrappers.join("pi"));
|
|
196
|
-
assert_eq!(models, ["team-agent/qwen3.8-27b"]);
|
|
197
|
-
assert_eq!(
|
|
198
|
-
std::fs::read_to_string(&marker).expect("the wrapper genuinely ran"),
|
|
199
|
-
"--version\n--list-models\n"
|
|
200
|
-
);
|
|
201
|
-
std::fs::remove_dir_all(root).expect("remove symlink fixture");
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
#[test]
|
|
206
|
-
fn pi_wrapper_is_atomic_per_seat_and_embeds_exact_candidate() {
|
|
207
|
-
run_process_isolated(PI_WRAPPER_CHILD, PI_WRAPPER_TEST, || {
|
|
208
|
-
let hermetic = HermeticTestEnv::enter("pi-wrapper-send");
|
|
209
|
-
assert_isolated_child();
|
|
210
|
-
pi_wrapper_is_atomic_body(&hermetic);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
fn pi_wrapper_is_atomic_body(hermetic: &HermeticTestEnv) {
|
|
215
|
-
let root = hermetic.workspace("wrapper");
|
|
216
|
-
let workspace = root.join("workspace");
|
|
217
|
-
let candidate = root.join("candidate/team-agent");
|
|
218
|
-
std::fs::create_dir_all(candidate.parent().expect("candidate parent"))
|
|
219
|
-
.expect("create candidate parent");
|
|
220
|
-
std::fs::write(&candidate, b"candidate").expect("write candidate fixture");
|
|
221
|
-
let destination = workspace.join(".team/runtime/pi/team-a/worker-a/team-mcp.ts");
|
|
222
|
-
|
|
223
|
-
let written = write_pi_wrapper(PiWrapperRequest {
|
|
224
|
-
destination: &destination,
|
|
225
|
-
candidate_executable: &candidate,
|
|
226
|
-
mcp_config: &mcp_config(&candidate, &workspace, "worker-a"),
|
|
227
|
-
team_id: "team-a",
|
|
228
|
-
agent_id: "worker-a",
|
|
229
|
-
workspace: &workspace,
|
|
230
|
-
include_tools: &["send_message", "report_result"],
|
|
231
|
-
})
|
|
232
|
-
.expect("atomic wrapper write");
|
|
233
|
-
assert_eq!(written, destination);
|
|
234
|
-
assert_eq!(
|
|
235
|
-
std::fs::metadata(&written)
|
|
236
|
-
.expect("wrapper metadata")
|
|
237
|
-
.permissions()
|
|
238
|
-
.mode()
|
|
239
|
-
& 0o777,
|
|
240
|
-
0o600
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
let source = std::fs::read_to_string(&written).expect("read wrapper");
|
|
244
|
-
assert!(source.contains(candidate.to_string_lossy().as_ref()));
|
|
245
|
-
assert!(source.contains("TEAM_AGENT_ID") && source.contains("worker-a"));
|
|
246
|
-
assert!(source.contains("TEAM_AGENT_OWNER_TEAM_ID") && source.contains("team-a"));
|
|
247
|
-
assert!(source.contains("pi.registerMcpServer(alias"));
|
|
248
|
-
assert!(source.contains("pi.unregisterMcpServer(alias"));
|
|
249
|
-
assert!(source.contains("toolExposure"));
|
|
250
|
-
assert!(source.contains("session_start") && source.contains("session_shutdown"));
|
|
251
|
-
assert!(!source.contains("pi-mcp-adapter"));
|
|
252
|
-
assert!(!source.contains("MCP_RUNTIME_REGISTER_EVENT"));
|
|
253
|
-
assert!(source.contains("includeTools"));
|
|
254
|
-
assert!(source.contains("send_message") && source.contains("report_result"));
|
|
255
|
-
assert!(!source.contains("createMcpAdapter"));
|
|
256
|
-
assert!(!source.contains("directTools"));
|
|
257
|
-
assert!(!source.contains("toolPrefix"));
|
|
258
|
-
assert!(!source.contains("\"lifecycle\""));
|
|
259
|
-
assert!(!source.contains("command: \"team-agent\""));
|
|
260
|
-
assert!(!source.contains("--mcp-config"));
|
|
261
|
-
|
|
262
|
-
let other_destination = workspace.join(".team/runtime/pi/team-a/worker-b/team-mcp.ts");
|
|
263
|
-
write_pi_wrapper(PiWrapperRequest {
|
|
264
|
-
destination: &other_destination,
|
|
265
|
-
candidate_executable: &candidate,
|
|
266
|
-
mcp_config: &mcp_config(&candidate, &workspace, "worker-b"),
|
|
267
|
-
team_id: "team-a",
|
|
268
|
-
agent_id: "worker-b",
|
|
269
|
-
workspace: &workspace,
|
|
270
|
-
include_tools: &["send_message", "report_result"],
|
|
271
|
-
})
|
|
272
|
-
.expect("write second seat wrapper");
|
|
273
|
-
let other_source = std::fs::read_to_string(&other_destination).expect("read second wrapper");
|
|
274
|
-
assert!(source.contains("worker-a") && !source.contains("worker-b"));
|
|
275
|
-
assert!(other_source.contains("worker-b") && !other_source.contains("worker-a"));
|
|
276
|
-
assert_ne!(written, other_destination);
|
|
277
|
-
|
|
278
|
-
let entries = std::fs::read_dir(destination.parent().expect("wrapper parent"))
|
|
279
|
-
.expect("list wrapper parent")
|
|
280
|
-
.map(|entry| entry.expect("entry").file_name())
|
|
281
|
-
.collect::<Vec<_>>();
|
|
282
|
-
assert_eq!(
|
|
283
|
-
entries,
|
|
284
|
-
[std::ffi::OsString::from("team-mcp.ts")],
|
|
285
|
-
"atomic write must not leave a temporary or backup sibling"
|
|
286
|
-
);
|
|
287
|
-
std::fs::remove_dir_all(root).expect("remove wrapper fixture");
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
#[test]
|
|
291
|
-
fn pi_leader_wrapper_materializes_from_empty_unicode_wsl_workspace() {
|
|
292
|
-
let root = temp_root("empty-unicode-leader");
|
|
293
|
-
let workspace = root.join("mnt/f/测试基础设施");
|
|
294
|
-
let candidate = root.join("candidate/team-agent");
|
|
295
|
-
std::fs::create_dir_all(&workspace).expect("create empty Unicode workspace");
|
|
296
|
-
std::fs::create_dir_all(candidate.parent().expect("candidate parent"))
|
|
297
|
-
.expect("create candidate parent");
|
|
298
|
-
std::fs::write(&candidate, b"candidate").expect("write candidate fixture");
|
|
299
|
-
assert!(
|
|
300
|
-
!workspace.join(".team").exists(),
|
|
301
|
-
"fixture must begin without a .team directory"
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
let paths = pi_seat_paths(&workspace, "current", "leader");
|
|
305
|
-
let written = write_pi_wrapper(PiWrapperRequest {
|
|
306
|
-
destination: &paths.wrapper,
|
|
307
|
-
candidate_executable: &candidate,
|
|
308
|
-
mcp_config: &mcp_config(&candidate, &workspace, "leader"),
|
|
309
|
-
team_id: "current",
|
|
310
|
-
agent_id: "leader",
|
|
311
|
-
workspace: &workspace,
|
|
312
|
-
include_tools: &["send_message", "report_result", "get_team_status"],
|
|
313
|
-
})
|
|
314
|
-
.expect("materialize Pi leader wrapper from an empty Unicode workspace");
|
|
315
|
-
|
|
316
|
-
assert_eq!(written, paths.wrapper);
|
|
317
|
-
assert!(written.is_file(), "published leader wrapper must exist");
|
|
318
|
-
assert!(
|
|
319
|
-
paths.runtime_root.is_dir(),
|
|
320
|
-
"leader runtime root must be created recursively"
|
|
321
|
-
);
|
|
322
|
-
let source = std::fs::read_to_string(&written).expect("read complete leader wrapper");
|
|
323
|
-
validate_pi_wrapper_source(&source, &candidate)
|
|
324
|
-
.expect("published leader wrapper must be complete and valid");
|
|
325
|
-
assert!(source.contains("TEAM_AGENT_ID") && source.contains("leader"));
|
|
326
|
-
assert!(source.contains("TEAM_AGENT_OWNER_TEAM_ID") && source.contains("current"));
|
|
327
|
-
std::fs::remove_dir_all(root).expect("remove Unicode leader fixture");
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
#[test]
|
|
331
|
-
fn pi_wrapper_permissions_are_finalized_before_atomic_publish() {
|
|
332
|
-
let source = include_str!("../launch/pi_mcp.rs");
|
|
333
|
-
let write_start = source
|
|
334
|
-
.find("pub(crate) fn write_pi_wrapper")
|
|
335
|
-
.expect("write_pi_wrapper source");
|
|
336
|
-
let write_source = &source[write_start..];
|
|
337
|
-
let permissions = write_source
|
|
338
|
-
.find("file.set_permissions")
|
|
339
|
-
.expect("wrapper permissions must use the open temp-file handle");
|
|
340
|
-
let publish = write_source
|
|
341
|
-
.find("publish(&temp, request.destination)")
|
|
342
|
-
.expect("atomic wrapper publish");
|
|
343
|
-
|
|
344
|
-
assert!(
|
|
345
|
-
permissions < publish,
|
|
346
|
-
"DrvFS may not resolve the destination immediately after rename; finalize mode through the open temp-file handle before publishing"
|
|
347
|
-
);
|
|
348
|
-
assert!(
|
|
349
|
-
!write_source.contains("std::fs::set_permissions(request.destination"),
|
|
350
|
-
"atomic publish must not require a second destination-path lookup"
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
#[test]
|
|
355
|
-
fn pi_wrapper_publish_needs_no_final_path_metadata_lookup() {
|
|
356
|
-
let root = temp_root("publish-path-enoent");
|
|
357
|
-
let workspace = root.join("mnt/f/测试基础设施");
|
|
358
|
-
let candidate = root.join("candidate/team-agent");
|
|
359
|
-
std::fs::create_dir_all(&workspace).expect("create Unicode workspace");
|
|
360
|
-
std::fs::create_dir_all(candidate.parent().expect("candidate parent"))
|
|
361
|
-
.expect("create candidate parent");
|
|
362
|
-
std::fs::write(&candidate, b"candidate").expect("write candidate fixture");
|
|
363
|
-
|
|
364
|
-
let paths = pi_seat_paths(&workspace, "current", "leader");
|
|
365
|
-
let published_parent = paths.runtime_root.clone();
|
|
366
|
-
let hidden_parent = published_parent.with_file_name("leader-after-rename");
|
|
367
|
-
write_pi_wrapper_with_publish(
|
|
368
|
-
PiWrapperRequest {
|
|
369
|
-
destination: &paths.wrapper,
|
|
370
|
-
candidate_executable: &candidate,
|
|
371
|
-
mcp_config: &mcp_config(&candidate, &workspace, "leader"),
|
|
372
|
-
team_id: "current",
|
|
373
|
-
agent_id: "leader",
|
|
374
|
-
workspace: &workspace,
|
|
375
|
-
include_tools: &["send_message", "report_result", "get_team_status"],
|
|
376
|
-
},
|
|
377
|
-
|temp, destination| {
|
|
378
|
-
std::fs::rename(temp, destination)?;
|
|
379
|
-
std::fs::rename(&published_parent, &hidden_parent)?;
|
|
380
|
-
assert_eq!(
|
|
381
|
-
std::fs::metadata(destination)
|
|
382
|
-
.expect_err("simulate DrvFS final-path metadata ENOENT after rename")
|
|
383
|
-
.kind(),
|
|
384
|
-
std::io::ErrorKind::NotFound
|
|
385
|
-
);
|
|
386
|
-
Ok(())
|
|
387
|
-
},
|
|
388
|
-
)
|
|
389
|
-
.expect("successful publish must not perform final-path metadata operations");
|
|
390
|
-
|
|
391
|
-
let published = hidden_parent.join("team-mcp.ts");
|
|
392
|
-
assert!(published.is_file(), "rename published a complete wrapper");
|
|
393
|
-
assert_eq!(
|
|
394
|
-
std::fs::metadata(&published)
|
|
395
|
-
.expect("published wrapper metadata through converged path")
|
|
396
|
-
.permissions()
|
|
397
|
-
.mode()
|
|
398
|
-
& 0o777,
|
|
399
|
-
0o600
|
|
400
|
-
);
|
|
401
|
-
std::fs::remove_dir_all(root).expect("remove publish-path fixture");
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
#[test]
|
|
405
|
-
fn pi_wrapper_runtime_registration_does_not_copy_ambient_config() {
|
|
406
|
-
run_process_isolated(PI_WRAPPER_AMBIENT_CHILD, PI_WRAPPER_AMBIENT_TEST, || {
|
|
407
|
-
let hermetic = HermeticTestEnv::enter("pi-wrapper-negative-send");
|
|
408
|
-
assert_isolated_child();
|
|
409
|
-
pi_wrapper_import_failure_body(&hermetic);
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
fn pi_wrapper_import_failure_body(hermetic: &HermeticTestEnv) {
|
|
414
|
-
let root = hermetic.workspace("wrapper-negative");
|
|
415
|
-
let workspace = root.join("workspace");
|
|
416
|
-
let candidate = root.join("candidate/team-agent");
|
|
417
|
-
std::fs::create_dir_all(candidate.parent().expect("candidate parent"))
|
|
418
|
-
.expect("create candidate parent");
|
|
419
|
-
std::fs::write(&candidate, b"candidate").expect("write candidate fixture");
|
|
420
|
-
std::fs::create_dir_all(&workspace).expect("create workspace");
|
|
421
|
-
std::fs::write(
|
|
422
|
-
workspace.join(".mcp.json"),
|
|
423
|
-
r#"{"mcpServers":{"team_orchestrator":{"command":"/tmp/ambient-evil"}}}"#,
|
|
424
|
-
)
|
|
425
|
-
.expect("write malicious ambient config");
|
|
426
|
-
|
|
427
|
-
let destination = workspace.join(".team/runtime/pi/team-a/worker-a/team-mcp.ts");
|
|
428
|
-
write_pi_wrapper(PiWrapperRequest {
|
|
429
|
-
destination: &destination,
|
|
430
|
-
candidate_executable: &candidate,
|
|
431
|
-
mcp_config: &mcp_config(&candidate, &workspace, "worker-a"),
|
|
432
|
-
team_id: "team-a",
|
|
433
|
-
agent_id: "worker-a",
|
|
434
|
-
workspace: &workspace,
|
|
435
|
-
include_tools: &["send_message", "report_result"],
|
|
436
|
-
})
|
|
437
|
-
.expect("runtime wrapper leaves ambient config to direct Pi");
|
|
438
|
-
let source = std::fs::read_to_string(&destination).expect("wrapper source");
|
|
439
|
-
assert!(!source.contains("ambient-evil"));
|
|
440
|
-
validate_pi_wrapper_source(&source, &candidate)
|
|
441
|
-
.expect("runtime registration and exact candidate");
|
|
442
|
-
assert!(source.contains("pi.registerMcpServer(alias"));
|
|
443
|
-
assert!(!source.contains("createMcpAdapter"));
|
|
444
|
-
assert!(!source.contains("pi-mcp-adapter"));
|
|
445
|
-
assert!(!source.contains("--mcp-config"));
|
|
446
|
-
|
|
447
|
-
let other_candidate = root.join("candidate/other-team-agent");
|
|
448
|
-
validate_pi_wrapper_source(&source, &other_candidate)
|
|
449
|
-
.expect_err("wrapper bound to a different candidate must refuse");
|
|
450
|
-
|
|
451
|
-
std::fs::remove_dir_all(root).expect("remove wrapper fixture");
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
#[test]
|
|
455
|
-
fn pi_materializer_and_worker_routes_use_the_recorded_scope() {
|
|
456
|
-
run_process_isolated(PI_MATERIALIZER_CHILD, PI_MATERIALIZER_TEST, || {
|
|
457
|
-
let hermetic = HermeticTestEnv::enter("pi-materializer-scope");
|
|
458
|
-
assert_isolated_child();
|
|
459
|
-
pi_materializer_and_worker_routes_body(&hermetic);
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
fn pi_materializer_and_worker_routes_body(hermetic: &HermeticTestEnv) {
|
|
464
|
-
let fixture_root = hermetic.root().join("materializer-fixture");
|
|
465
|
-
let bin = fixture_root.join("bin");
|
|
466
|
-
let candidate = fixture_root.join("candidate/team-agent");
|
|
467
|
-
let real = fixture_root.join("pi-real");
|
|
468
|
-
std::fs::create_dir_all(&bin).expect("create Pi fixture bin");
|
|
469
|
-
std::fs::create_dir_all(candidate.parent().expect("candidate parent"))
|
|
470
|
-
.expect("create candidate parent");
|
|
471
|
-
std::fs::write(&candidate, b"candidate").expect("write candidate fixture");
|
|
472
|
-
let pi_script = "#!/bin/sh\ncase \"${1-}\" in\n --version) printf '0.84.4\\n' ;;\n --list-models) printf 'provider model\\nteam-agent qwen3.8-27b\\n' ;;\n list) exit 64 ;;\n *) exit 0 ;;\nesac\n";
|
|
473
|
-
std::fs::write(&real, pi_script).expect("write Pi real fixture");
|
|
474
|
-
std::fs::set_permissions(&real, std::fs::Permissions::from_mode(0o755))
|
|
475
|
-
.expect("make Pi real fixture executable");
|
|
476
|
-
std::os::unix::fs::symlink(&real, bin.join("pi")).expect("create Pi PATH symlink");
|
|
477
|
-
let _path = hermetic.with_env(
|
|
478
|
-
"PATH",
|
|
479
|
-
std::env::join_paths([&bin])
|
|
480
|
-
.expect("join Pi fixture PATH")
|
|
481
|
-
.to_str()
|
|
482
|
-
.expect("Pi fixture PATH is UTF-8"),
|
|
483
|
-
);
|
|
484
|
-
|
|
485
|
-
let native_workspace = hermetic.workspace("native");
|
|
486
|
-
let native_paths = pi_seat_paths(&native_workspace, "team-a", "leader");
|
|
487
|
-
let native_config = mcp_config(&candidate, &native_workspace, "leader");
|
|
488
|
-
let native = materialize_pi_plan(PiMaterializeRequest {
|
|
489
|
-
workspace: &native_workspace,
|
|
490
|
-
team_id: "team-a",
|
|
491
|
-
agent_id: "leader",
|
|
492
|
-
model: None,
|
|
493
|
-
effort: None,
|
|
494
|
-
system_prompt: "native leader fixture",
|
|
495
|
-
team_mcp_tools: &["send_message"],
|
|
496
|
-
mcp_config: &native_config,
|
|
497
|
-
session_scope: PiSessionScope::NativeDefault,
|
|
498
|
-
session_dir: None,
|
|
499
|
-
})
|
|
500
|
-
.expect("NativeDefault materializer");
|
|
501
|
-
assert!(
|
|
502
|
-
native.provider_projects_root.is_none(),
|
|
503
|
-
"NativeDefault must not expose a provider capture root: {native:?}"
|
|
504
|
-
);
|
|
505
|
-
assert!(
|
|
506
|
-
!native_paths.sessions.exists(),
|
|
507
|
-
"NativeDefault must not create the Team Agent seat session root"
|
|
508
|
-
);
|
|
509
|
-
assert_eq!(native.argv.first().map(String::as_str), Some("pi"));
|
|
510
|
-
for forbidden in ["--session-dir", "--cwd", "--workspace", "--session"] {
|
|
511
|
-
assert!(
|
|
512
|
-
!native.argv.iter().any(|arg| arg == forbidden),
|
|
513
|
-
"NativeDefault fresh argv must omit {forbidden}: {:?}",
|
|
514
|
-
native.argv
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
let isolated_workspace = hermetic.workspace("isolated");
|
|
519
|
-
let isolated_paths = pi_seat_paths(&isolated_workspace, "team-a", "worker-a");
|
|
520
|
-
assert_eq!(
|
|
521
|
-
isolated_paths.sessions.parent(),
|
|
522
|
-
Some(
|
|
523
|
-
hermetic
|
|
524
|
-
.home()
|
|
525
|
-
.canonicalize()
|
|
526
|
-
.unwrap()
|
|
527
|
-
.join(".pi/agent/sessions")
|
|
528
|
-
.as_path()
|
|
529
|
-
)
|
|
530
|
-
);
|
|
531
|
-
assert!(!isolated_paths.sessions.starts_with(&isolated_workspace));
|
|
532
|
-
assert!(isolated_paths
|
|
533
|
-
.wrapper
|
|
534
|
-
.starts_with(isolated_workspace.join(".team")));
|
|
535
|
-
assert_eq!(
|
|
536
|
-
isolated_paths.sessions,
|
|
537
|
-
pi_seat_paths(&isolated_workspace, "team-a", "worker-b").sessions
|
|
538
|
-
);
|
|
539
|
-
assert_eq!(
|
|
540
|
-
isolated_paths.sessions,
|
|
541
|
-
pi_seat_paths(&isolated_workspace, "team-b", "worker-a").sessions
|
|
542
|
-
);
|
|
543
|
-
let encoded_cwd = format!(
|
|
544
|
-
"--{}--",
|
|
545
|
-
isolated_workspace
|
|
546
|
-
.to_string_lossy()
|
|
547
|
-
.trim_start_matches('/')
|
|
548
|
-
.replace(['/', '\\', ':'], "-")
|
|
549
|
-
);
|
|
550
|
-
assert_eq!(
|
|
551
|
-
isolated_paths.sessions.file_name().unwrap(),
|
|
552
|
-
encoded_cwd.as_str()
|
|
553
|
-
);
|
|
554
|
-
assert_ne!(
|
|
555
|
-
isolated_paths.sessions,
|
|
556
|
-
pi_seat_paths(&native_workspace, "team-a", "worker-a").sessions
|
|
557
|
-
);
|
|
558
|
-
assert!(!isolated_paths.runtime_root.join("sessions").exists());
|
|
559
|
-
let isolated_config = mcp_config(&candidate, &isolated_workspace, "worker-a");
|
|
560
|
-
let isolated = materialize_pi_plan(PiMaterializeRequest {
|
|
561
|
-
workspace: &isolated_workspace,
|
|
562
|
-
team_id: "team-a",
|
|
563
|
-
agent_id: "worker-a",
|
|
564
|
-
model: Some("team-agent/qwen3.8-27b"),
|
|
565
|
-
effort: Some(ProviderEffort::Medium),
|
|
566
|
-
system_prompt: "isolated worker fixture",
|
|
567
|
-
team_mcp_tools: &["send_message"],
|
|
568
|
-
mcp_config: &isolated_config,
|
|
569
|
-
session_scope: PiSessionScope::Isolated,
|
|
570
|
-
session_dir: None,
|
|
571
|
-
})
|
|
572
|
-
.expect("Isolated materializer");
|
|
573
|
-
assert_eq!(
|
|
574
|
-
isolated.provider_projects_root.as_deref(),
|
|
575
|
-
Some(isolated_paths.sessions.as_path())
|
|
576
|
-
);
|
|
577
|
-
assert_eq!(isolated.argv.first().map(String::as_str), Some("pi"));
|
|
578
|
-
assert_session_pair(&isolated.argv, &isolated_paths.sessions);
|
|
579
|
-
let fresh_id = isolated
|
|
580
|
-
.expected_session_id
|
|
581
|
-
.as_ref()
|
|
582
|
-
.expect("native UUID selector");
|
|
583
|
-
assert!(isolated
|
|
584
|
-
.argv
|
|
585
|
-
.windows(2)
|
|
586
|
-
.any(|pair| pair == ["--session-id", fresh_id.as_str()]));
|
|
587
|
-
assert!(!isolated.argv.iter().any(|arg| arg == "--cwd"));
|
|
588
|
-
assert!(!isolated.argv.iter().any(|arg| arg == "--workspace"));
|
|
589
|
-
|
|
590
|
-
let session_id = SessionId::new("pi-materializer-resume");
|
|
591
|
-
let exact = isolated_paths.sessions.join("2026/09/exact.jsonl");
|
|
592
|
-
std::fs::create_dir_all(exact.parent().expect("exact session parent"))
|
|
593
|
-
.expect("create exact session parent");
|
|
594
|
-
write_pi_session_header(
|
|
595
|
-
&exact,
|
|
596
|
-
session_id.as_str(),
|
|
597
|
-
&isolated_workspace,
|
|
598
|
-
"2026-09-01T00:00:01Z",
|
|
599
|
-
);
|
|
600
|
-
let resumed = materialize_pi_resume_plan(
|
|
601
|
-
PiMaterializeRequest {
|
|
602
|
-
workspace: &isolated_workspace,
|
|
603
|
-
team_id: "team-a",
|
|
604
|
-
agent_id: "worker-a",
|
|
605
|
-
model: None,
|
|
606
|
-
effort: None,
|
|
607
|
-
system_prompt: "isolated resume fixture",
|
|
608
|
-
team_mcp_tools: &["send_message"],
|
|
609
|
-
mcp_config: &isolated_config,
|
|
610
|
-
session_scope: PiSessionScope::Isolated,
|
|
611
|
-
session_dir: None,
|
|
612
|
-
},
|
|
613
|
-
&session_id,
|
|
614
|
-
&exact,
|
|
615
|
-
&isolated_workspace,
|
|
616
|
-
)
|
|
617
|
-
.expect("Isolated exact-path resume materializer");
|
|
618
|
-
assert_eq!(
|
|
619
|
-
resumed.provider_projects_root.as_deref(),
|
|
620
|
-
Some(isolated_paths.sessions.as_path())
|
|
621
|
-
);
|
|
622
|
-
assert_eq!(resumed.argv.first().map(String::as_str), Some("pi"));
|
|
623
|
-
assert_session_pair(&resumed.argv, &isolated_paths.sessions);
|
|
624
|
-
assert!(
|
|
625
|
-
resumed
|
|
626
|
-
.argv
|
|
627
|
-
.windows(2)
|
|
628
|
-
.any(|pair| { pair == ["--session", exact.to_string_lossy().as_ref()] })
|
|
629
|
-
);
|
|
630
|
-
|
|
631
|
-
// Existing installations keep their exact backing; changing the native
|
|
632
|
-
// home must not force a new session or strand previously captured seats.
|
|
633
|
-
let legacy_root = isolated_paths.runtime_root.join("sessions");
|
|
634
|
-
let legacy_exact = legacy_root.join("legacy.jsonl");
|
|
635
|
-
std::fs::create_dir_all(&legacy_root).unwrap();
|
|
636
|
-
write_pi_session_header(
|
|
637
|
-
&legacy_exact,
|
|
638
|
-
session_id.as_str(),
|
|
639
|
-
&isolated_workspace,
|
|
640
|
-
"2026-09-01T00:00:01Z",
|
|
641
|
-
);
|
|
642
|
-
{
|
|
643
|
-
let _override = hermetic.with_env("PI_CODING_AGENT_DIR", "~/custom-pi");
|
|
644
|
-
let customized = pi_seat_paths(&isolated_workspace, "team-a", "worker-a");
|
|
645
|
-
assert_eq!(
|
|
646
|
-
customized.sessions.parent(),
|
|
647
|
-
Some(
|
|
648
|
-
hermetic
|
|
649
|
-
.home()
|
|
650
|
-
.canonicalize()
|
|
651
|
-
.unwrap()
|
|
652
|
-
.join("custom-pi/sessions")
|
|
653
|
-
.as_path()
|
|
654
|
-
)
|
|
655
|
-
);
|
|
656
|
-
assert_eq!(
|
|
657
|
-
customized.sessions.file_name(),
|
|
658
|
-
isolated_paths.sessions.file_name()
|
|
659
|
-
);
|
|
660
|
-
for (path, root) in [
|
|
661
|
-
(&exact, &isolated_paths.sessions),
|
|
662
|
-
(&legacy_exact, &legacy_root),
|
|
663
|
-
] {
|
|
664
|
-
let resumed = materialize_pi_resume_plan(
|
|
665
|
-
PiMaterializeRequest {
|
|
666
|
-
workspace: &isolated_workspace,
|
|
667
|
-
team_id: "team-a",
|
|
668
|
-
agent_id: "worker-a",
|
|
669
|
-
model: None,
|
|
670
|
-
effort: None,
|
|
671
|
-
system_prompt: "retained backing",
|
|
672
|
-
team_mcp_tools: &["send_message"],
|
|
673
|
-
mcp_config: &isolated_config,
|
|
674
|
-
session_scope: PiSessionScope::Isolated,
|
|
675
|
-
session_dir: Some(root),
|
|
676
|
-
},
|
|
677
|
-
&session_id,
|
|
678
|
-
path,
|
|
679
|
-
&isolated_workspace,
|
|
680
|
-
)
|
|
681
|
-
.expect("resume exact backing across native storage migration/home changes");
|
|
682
|
-
assert_eq!(resumed.provider_projects_root.as_ref(), Some(root));
|
|
683
|
-
assert_session_pair(&resumed.argv, root);
|
|
684
|
-
assert!(resumed
|
|
685
|
-
.argv
|
|
686
|
-
.windows(2)
|
|
687
|
-
.any(|pair| pair == ["--session", path.to_string_lossy().as_ref()]));
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
{
|
|
691
|
-
let _override = hermetic.with_env("PI_CODING_AGENT_DIR", "relative-pi");
|
|
692
|
-
let customized = pi_seat_paths(&isolated_workspace, "team-a", "worker-a");
|
|
693
|
-
assert_eq!(
|
|
694
|
-
customized.sessions.parent(),
|
|
695
|
-
Some(isolated_workspace.join("relative-pi/sessions").as_path())
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
let global_settings = hermetic.home().join(".pi/agent/settings.json");
|
|
700
|
-
let project_settings = isolated_workspace.join(".pi/settings.json");
|
|
701
|
-
std::fs::create_dir_all(project_settings.parent().unwrap()).unwrap();
|
|
702
|
-
std::fs::write(&global_settings, r#"{"sessionDir":"global-sessions"}"#).unwrap();
|
|
703
|
-
for (project, expected) in [
|
|
704
|
-
("{}", isolated_workspace.join("global-sessions")),
|
|
705
|
-
(
|
|
706
|
-
r#"{"sessionDir":"project-sessions"}"#,
|
|
707
|
-
isolated_workspace.join("project-sessions"),
|
|
708
|
-
),
|
|
709
|
-
("invalid JSON", isolated_workspace.join("global-sessions")),
|
|
710
|
-
(r#"{"sessionDir":""}"#, isolated_paths.sessions.clone()),
|
|
711
|
-
(r#"{"sessionDir":null}"#, isolated_paths.sessions.clone()),
|
|
712
|
-
] {
|
|
713
|
-
std::fs::write(&project_settings, project).unwrap();
|
|
714
|
-
let plan = materialize_pi_plan(PiMaterializeRequest {
|
|
715
|
-
workspace: &isolated_workspace,
|
|
716
|
-
team_id: "team-a",
|
|
717
|
-
agent_id: "worker-a",
|
|
718
|
-
model: None,
|
|
719
|
-
effort: None,
|
|
720
|
-
system_prompt: "native settings precedence",
|
|
721
|
-
team_mcp_tools: &["send_message"],
|
|
722
|
-
mcp_config: &isolated_config,
|
|
723
|
-
session_scope: PiSessionScope::Isolated,
|
|
724
|
-
session_dir: None,
|
|
725
|
-
})
|
|
726
|
-
.expect("native settings sessionDir");
|
|
727
|
-
assert_eq!(plan.provider_projects_root.as_ref(), Some(&expected));
|
|
728
|
-
assert_session_pair(&plan.argv, &expected);
|
|
729
|
-
}
|
|
730
|
-
{
|
|
731
|
-
let custom_agent = isolated_workspace.join("custom-agent");
|
|
732
|
-
std::fs::create_dir_all(&custom_agent).unwrap();
|
|
733
|
-
std::fs::write(
|
|
734
|
-
custom_agent.join("settings.json"),
|
|
735
|
-
r#"{"sessionDir":"custom-global"}"#,
|
|
736
|
-
)
|
|
737
|
-
.unwrap();
|
|
738
|
-
std::fs::write(&project_settings, "{}").unwrap();
|
|
739
|
-
let _agent_dir = hermetic.with_env("PI_CODING_AGENT_DIR", custom_agent.to_str().unwrap());
|
|
740
|
-
assert_eq!(
|
|
741
|
-
pi_seat_paths(&isolated_workspace, "team-a", "worker-a").sessions,
|
|
742
|
-
isolated_workspace.join("custom-global")
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
std::fs::write(&project_settings, r#"{"sessionDir":"project-sessions"}"#).unwrap();
|
|
746
|
-
{
|
|
747
|
-
let _agent_dir = hermetic.with_env("PI_CODING_AGENT_DIR", "~/ignored-agent-dir");
|
|
748
|
-
let _session_dir =
|
|
749
|
-
hermetic.with_env("PI_CODING_AGENT_SESSION_DIR", "~/native-session-override");
|
|
750
|
-
let expected = hermetic
|
|
751
|
-
.home()
|
|
752
|
-
.canonicalize()
|
|
753
|
-
.unwrap()
|
|
754
|
-
.join("native-session-override");
|
|
755
|
-
assert_eq!(
|
|
756
|
-
pi_seat_paths(&isolated_workspace, "team-a", "worker-a").sessions,
|
|
757
|
-
expected
|
|
758
|
-
);
|
|
759
|
-
let explicit = isolated_workspace.join("explicit-sessions");
|
|
760
|
-
let parsed = crate::lifecycle::launch::pi_mcp::parse_pi_leader_args(&[
|
|
761
|
-
"--session-dir".into(),
|
|
762
|
-
explicit.to_string_lossy().into_owned(),
|
|
763
|
-
])
|
|
764
|
-
.expect("native --session-dir accepted");
|
|
765
|
-
for root in [None, parsed.session_dir.as_deref()] {
|
|
766
|
-
let plan = materialize_pi_plan(PiMaterializeRequest {
|
|
767
|
-
workspace: &isolated_workspace,
|
|
768
|
-
team_id: "team-a",
|
|
769
|
-
agent_id: "worker-a",
|
|
770
|
-
model: None,
|
|
771
|
-
effort: None,
|
|
772
|
-
system_prompt: "native directory precedence",
|
|
773
|
-
team_mcp_tools: &["send_message"],
|
|
774
|
-
mcp_config: &isolated_config,
|
|
775
|
-
session_scope: PiSessionScope::Isolated,
|
|
776
|
-
session_dir: root,
|
|
777
|
-
})
|
|
778
|
-
.expect("native session directory override");
|
|
779
|
-
let expected_root = root.unwrap_or(&expected);
|
|
780
|
-
assert_eq!(plan.provider_projects_root.as_deref(), Some(expected_root));
|
|
781
|
-
assert_session_pair(&plan.argv, expected_root);
|
|
782
|
-
assert_ne!(plan.expected_session_id, isolated.expected_session_id);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
std::fs::remove_file(&project_settings).unwrap();
|
|
787
|
-
std::fs::remove_file(&global_settings).unwrap();
|
|
788
|
-
|
|
789
|
-
let native_resume = materialize_pi_resume_plan(
|
|
790
|
-
PiMaterializeRequest {
|
|
791
|
-
workspace: &native_workspace,
|
|
792
|
-
team_id: "team-a",
|
|
793
|
-
agent_id: "leader",
|
|
794
|
-
model: None,
|
|
795
|
-
effort: None,
|
|
796
|
-
system_prompt: "native resume fixture",
|
|
797
|
-
team_mcp_tools: &["send_message"],
|
|
798
|
-
mcp_config: &native_config,
|
|
799
|
-
session_scope: PiSessionScope::NativeDefault,
|
|
800
|
-
session_dir: None,
|
|
801
|
-
},
|
|
802
|
-
&session_id,
|
|
803
|
-
&exact,
|
|
804
|
-
&native_workspace,
|
|
805
|
-
);
|
|
806
|
-
assert!(
|
|
807
|
-
matches!(
|
|
808
|
-
native_resume,
|
|
809
|
-
Err(crate::provider::ProviderError::ResumeUnavailable(_))
|
|
810
|
-
),
|
|
811
|
-
"NativeDefault resume must fail closed before emitting a native HOME path: {native_resume:?}"
|
|
812
|
-
);
|
|
813
|
-
|
|
814
|
-
let home_candidate = hermetic.home().join(".pi/agent/sessions/home.jsonl");
|
|
815
|
-
std::fs::create_dir_all(home_candidate.parent().expect("home session parent"))
|
|
816
|
-
.expect("create home session parent");
|
|
817
|
-
std::fs::write(&home_candidate, b"{}\n").expect("write home candidate");
|
|
818
|
-
let other_paths = pi_seat_paths(&isolated_workspace, "team-a", "worker-b");
|
|
819
|
-
let other_candidate = other_paths.sessions.join("other.jsonl");
|
|
820
|
-
std::fs::create_dir_all(other_candidate.parent().expect("other session parent"))
|
|
821
|
-
.expect("create other session parent");
|
|
822
|
-
write_pi_session_header(
|
|
823
|
-
&other_candidate,
|
|
824
|
-
"other-seat-session",
|
|
825
|
-
&isolated_workspace,
|
|
826
|
-
"2026-09-01T00:00:01Z",
|
|
827
|
-
);
|
|
828
|
-
for (label, outside) in [("HOME", &home_candidate), ("other seat", &other_candidate)] {
|
|
829
|
-
let refused = materialize_pi_resume_plan(
|
|
830
|
-
PiMaterializeRequest {
|
|
831
|
-
workspace: &isolated_workspace,
|
|
832
|
-
team_id: "team-a",
|
|
833
|
-
agent_id: "worker-a",
|
|
834
|
-
model: None,
|
|
835
|
-
effort: None,
|
|
836
|
-
system_prompt: "isolated negative resume fixture",
|
|
837
|
-
team_mcp_tools: &["send_message"],
|
|
838
|
-
mcp_config: &isolated_config,
|
|
839
|
-
session_scope: PiSessionScope::Isolated,
|
|
840
|
-
session_dir: None,
|
|
841
|
-
},
|
|
842
|
-
&session_id,
|
|
843
|
-
&outside,
|
|
844
|
-
&isolated_workspace,
|
|
845
|
-
);
|
|
846
|
-
assert!(
|
|
847
|
-
matches!(
|
|
848
|
-
refused,
|
|
849
|
-
Err(crate::provider::ProviderError::ResumeUnavailable(_))
|
|
850
|
-
),
|
|
851
|
-
"{label} candidate must be refused by the exact root/id/cwd check: {refused:?}"
|
|
852
|
-
);
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
let worker_workspace = hermetic.workspace("worker-spawn");
|
|
856
|
-
let spec_path = worker_workspace
|
|
857
|
-
.join(".team")
|
|
858
|
-
.join("team-a")
|
|
859
|
-
.join("team.spec.yaml");
|
|
860
|
-
std::fs::create_dir_all(spec_path.parent().expect("worker Pi spec parent"))
|
|
861
|
-
.expect("create worker Pi spec parent");
|
|
862
|
-
let spec = crate::model::yaml::loads(
|
|
863
|
-
"team:\n name: team-a\nruntime:\n session_name: team-workers\nagents:\n - id: worker-a\n role: Worker A\n provider: pi\n model: team-agent/qwen3.8-27b\n auth_mode: subscription\n dangerously_skip_permissions: false\n tools:\n - mcp_team\n - id: worker-b\n role: Worker B\n provider: pi\n model: team-agent/qwen3.8-27b\n auth_mode: subscription\n dangerously_skip_permissions: false\n tools:\n - mcp_team\n",
|
|
864
|
-
)
|
|
865
|
-
.expect("parse worker Pi spec");
|
|
866
|
-
std::fs::write(&spec_path, crate::model::yaml::dumps(&spec)).expect("write worker Pi spec");
|
|
867
|
-
let transport = OfflineTransport::new();
|
|
868
|
-
let started = launch_with_transport_in_workspace(
|
|
869
|
-
&worker_workspace,
|
|
870
|
-
&spec_path,
|
|
871
|
-
false,
|
|
872
|
-
true,
|
|
873
|
-
true,
|
|
874
|
-
&transport,
|
|
875
|
-
)
|
|
876
|
-
.expect("worker fresh spawn construction")
|
|
877
|
-
.started;
|
|
878
|
-
assert_eq!(started.len(), 2, "both Pi worker seats must be spawned");
|
|
879
|
-
for worker in ["worker-a", "worker-b"] {
|
|
880
|
-
let paths = pi_seat_paths(&worker_workspace, "team-a", worker);
|
|
881
|
-
let started_agent = started
|
|
882
|
-
.iter()
|
|
883
|
-
.find(|entry| entry.agent_id.as_str() == worker)
|
|
884
|
-
.expect("started worker entry");
|
|
885
|
-
assert_eq!(
|
|
886
|
-
started_agent.provider_projects_root.as_deref(),
|
|
887
|
-
Some(paths.sessions.as_path()),
|
|
888
|
-
"fresh worker must expose its exact seat capture root"
|
|
889
|
-
);
|
|
890
|
-
let record = transport
|
|
891
|
-
.spawn_records()
|
|
892
|
-
.into_iter()
|
|
893
|
-
.find(|(_, argv)| {
|
|
894
|
-
argv.iter()
|
|
895
|
-
.any(|arg| arg.as_str() == paths.wrapper.to_string_lossy().as_ref())
|
|
896
|
-
})
|
|
897
|
-
.expect("transport spawn record for worker seat");
|
|
898
|
-
assert_eq!(record.1.first().map(String::as_str), Some("pi"));
|
|
899
|
-
assert_session_pair(&record.1, &paths.sessions);
|
|
900
|
-
assert!(
|
|
901
|
-
!record
|
|
902
|
-
.1
|
|
903
|
-
.iter()
|
|
904
|
-
.any(|arg| arg.as_str() == home_candidate.to_string_lossy().as_ref())
|
|
905
|
-
);
|
|
906
|
-
assert!(
|
|
907
|
-
!record
|
|
908
|
-
.1
|
|
909
|
-
.iter()
|
|
910
|
-
.any(|arg| arg.as_str() == other_candidate.to_string_lossy().as_ref())
|
|
911
|
-
);
|
|
912
|
-
|
|
913
|
-
let pending_id = started_agent
|
|
914
|
-
.pending_session_id
|
|
915
|
-
.as_ref()
|
|
916
|
-
.expect("fresh Pi UUID selector");
|
|
917
|
-
assert!(record
|
|
918
|
-
.1
|
|
919
|
-
.windows(2)
|
|
920
|
-
.any(|pair| pair == ["--session-id", pending_id.as_str()]));
|
|
921
|
-
let foreign_session_id = format!("{worker}-foreign");
|
|
922
|
-
write_pi_session_header(
|
|
923
|
-
&home_candidate,
|
|
924
|
-
&foreign_session_id,
|
|
925
|
-
&worker_workspace,
|
|
926
|
-
"2099-01-01T00:00:00Z",
|
|
927
|
-
);
|
|
928
|
-
let other_worker = if worker == "worker-a" {
|
|
929
|
-
"worker-b"
|
|
930
|
-
} else {
|
|
931
|
-
"worker-a"
|
|
932
|
-
};
|
|
933
|
-
let cross_seat = pi_seat_paths(&worker_workspace, "team-a", other_worker)
|
|
934
|
-
.sessions
|
|
935
|
-
.join("foreign.jsonl");
|
|
936
|
-
write_pi_session_header(
|
|
937
|
-
&cross_seat,
|
|
938
|
-
&foreign_session_id,
|
|
939
|
-
&worker_workspace,
|
|
940
|
-
"2099-01-01T00:00:00Z",
|
|
941
|
-
);
|
|
942
|
-
let context = CaptureSessionContext {
|
|
943
|
-
agent_id: worker.to_string(),
|
|
944
|
-
spawn_cwd: worker_workspace.clone(),
|
|
945
|
-
pane_id: None,
|
|
946
|
-
pane_pid: None,
|
|
947
|
-
spawned_at: Some(started_agent.spawned_at.clone()),
|
|
948
|
-
expected_session_id: Some(pending_id.clone()),
|
|
949
|
-
provider_projects_root: Some(paths.sessions.clone()),
|
|
950
|
-
};
|
|
951
|
-
let candidates = scan_session_candidates_once(Provider::Pi, &context)
|
|
952
|
-
.expect("scan the recorded worker seat only");
|
|
953
|
-
assert!(
|
|
954
|
-
candidates.is_empty(),
|
|
955
|
-
"HOME and another worker seat must not become capture candidates: {candidates:?}"
|
|
956
|
-
);
|
|
957
|
-
// Positive control: Pi's own header inside the recorded seat is captured.
|
|
958
|
-
let own = paths.sessions.join("own.jsonl");
|
|
959
|
-
write_pi_session_header(
|
|
960
|
-
&own,
|
|
961
|
-
pending_id.as_str(),
|
|
962
|
-
&worker_workspace,
|
|
963
|
-
"2099-01-01T00:00:00Z",
|
|
964
|
-
);
|
|
965
|
-
let candidates = scan_session_candidates_once(Provider::Pi, &context)
|
|
966
|
-
.expect("scan the recorded worker seat only");
|
|
967
|
-
assert_eq!(candidates.len(), 1, "{candidates:?}");
|
|
968
|
-
assert_eq!(
|
|
969
|
-
candidates[0]
|
|
970
|
-
.captured
|
|
971
|
-
.session_id
|
|
972
|
-
.as_ref()
|
|
973
|
-
.map(SessionId::as_str),
|
|
974
|
-
Some(pending_id.as_str())
|
|
975
|
-
);
|
|
976
|
-
std::fs::remove_file(&cross_seat).expect("clear foreign header from the other seat");
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
let restart_workspace = hermetic.workspace("worker-restart");
|
|
980
|
-
let restart_paths = pi_seat_paths(&restart_workspace, "team-a", "worker-a");
|
|
981
|
-
let restart_exact = restart_paths.sessions.join("2026/09/restart.jsonl");
|
|
982
|
-
write_pi_session_header(
|
|
983
|
-
&restart_exact,
|
|
984
|
-
"pi-restart-session",
|
|
985
|
-
&restart_workspace,
|
|
986
|
-
"2026-09-01T00:00:01Z",
|
|
987
|
-
);
|
|
988
|
-
crate::state::persist::save_runtime_state(
|
|
989
|
-
&restart_workspace,
|
|
990
|
-
&serde_json::json!({
|
|
991
|
-
"session_name": "team-workers",
|
|
992
|
-
"active_team_key": "team-a",
|
|
993
|
-
"agents": {
|
|
994
|
-
"worker-a": {
|
|
995
|
-
"id": "worker-a",
|
|
996
|
-
"status": "running",
|
|
997
|
-
"provider": "pi",
|
|
998
|
-
"role": "Worker A",
|
|
999
|
-
"model": "team-agent/qwen3.8-27b",
|
|
1000
|
-
"auth_mode": "subscription",
|
|
1001
|
-
"tools": ["mcp_team"],
|
|
1002
|
-
"session_id": "pi-restart-session",
|
|
1003
|
-
"rollout_path": restart_exact.to_string_lossy(),
|
|
1004
|
-
"spawn_cwd": restart_workspace.to_string_lossy(),
|
|
1005
|
-
"first_send_at": "2026-09-01T00:00:00Z"
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
}),
|
|
1009
|
-
)
|
|
1010
|
-
.expect("write restart state");
|
|
1011
|
-
let restart_transport = OfflineTransport::new();
|
|
1012
|
-
let _ = start_agent_with_transport(
|
|
1013
|
-
&restart_workspace,
|
|
1014
|
-
&crate::model::ids::AgentId::new("worker-a"),
|
|
1015
|
-
false,
|
|
1016
|
-
false,
|
|
1017
|
-
false,
|
|
1018
|
-
None,
|
|
1019
|
-
&restart_transport,
|
|
1020
|
-
);
|
|
1021
|
-
let restart_record = restart_transport
|
|
1022
|
-
.spawn_records()
|
|
1023
|
-
.into_iter()
|
|
1024
|
-
.next()
|
|
1025
|
-
.expect("restart must reach the worker spawn construction");
|
|
1026
|
-
assert_eq!(restart_record.1.first().map(String::as_str), Some("pi"));
|
|
1027
|
-
assert_session_pair(&restart_record.1, &restart_paths.sessions);
|
|
1028
|
-
assert!(
|
|
1029
|
-
restart_record
|
|
1030
|
-
.1
|
|
1031
|
-
.windows(2)
|
|
1032
|
-
.any(|pair| { pair == ["--session", restart_exact.to_string_lossy().as_ref()] })
|
|
1033
|
-
);
|
|
1034
|
-
assert!(
|
|
1035
|
-
!restart_record
|
|
1036
|
-
.1
|
|
1037
|
-
.iter()
|
|
1038
|
-
.any(|arg| arg.as_str() == home_candidate.to_string_lossy().as_ref())
|
|
1039
|
-
);
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
fn assert_session_pair(argv: &[String], session_root: &Path) {
|
|
1043
|
-
let expected = session_root.to_string_lossy();
|
|
1044
|
-
assert!(
|
|
1045
|
-
argv.windows(2)
|
|
1046
|
-
.any(|pair| pair[0] == "--session-dir" && pair[1].as_str() == expected.as_ref()),
|
|
1047
|
-
"argv must contain exact --session-dir pair for {}: {argv:?}",
|
|
1048
|
-
session_root.display()
|
|
1049
|
-
);
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
fn write_pi_session_header(path: &Path, id: &str, cwd: &Path, timestamp: &str) {
|
|
1053
|
-
std::fs::create_dir_all(path.parent().expect("session parent")).expect("create session parent");
|
|
1054
|
-
let header = serde_json::json!({
|
|
1055
|
-
"type": "session",
|
|
1056
|
-
"version": 3,
|
|
1057
|
-
"id": id,
|
|
1058
|
-
"cwd": cwd,
|
|
1059
|
-
"timestamp": timestamp,
|
|
1060
|
-
});
|
|
1061
|
-
std::fs::write(path, format!("{header}\n")).expect("write Pi session header");
|
|
1062
|
-
}
|