@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,1655 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: 终端控制面的 Transport trait、typed 载荷,以及 tmux argv 的纯构造函数
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: Transport
|
|
6
|
-
//! what: 后端无关的 spawn / inject / capture / query / liveness / lifecycle 接口;daemon 可达方法一律返回 Result<_, TransportError>
|
|
7
|
-
//! - name: SetEnvOutcome
|
|
8
|
-
//! what: set-env 的能力性拒绝走 typed 变体,不走 Err、不 panic
|
|
9
|
-
//! - name: AttachOutcome
|
|
10
|
-
//! what: attach 的能力性拒绝走 typed 变体,不走 Err、不 panic
|
|
11
|
-
//! - name: tmux_spawn_argv
|
|
12
|
-
//! what: spawn argv 的唯一构造点(first→new-session / 否则 new-window),纯函数可 golden 锁
|
|
13
|
-
//! - name: tmux_inject_text_argv
|
|
14
|
-
//! what: 文本注入三步 argv(装 buffer→paste→删 buffer)的唯一构造点
|
|
15
|
-
//! - name: tmux_send_submit_argv
|
|
16
|
-
//! what: 提交键 argv 的唯一构造点,Enter 保持逻辑 Return 而非 Ctrl-M
|
|
17
|
-
//! - name: tmux_capture_argv
|
|
18
|
-
//! what: capture-pane argv 的唯一构造点
|
|
19
|
-
//! - name: tmux_query_argv
|
|
20
|
-
//! what: display-message 单字段查询 argv 的唯一构造点
|
|
21
|
-
//! - name: tmux_cancel_mode_argv
|
|
22
|
-
//! what: 按 pane mode 分派退出键的 argv 构造点
|
|
23
|
-
//! - name: InjectReport
|
|
24
|
-
//! what: 阶段化注入报告(stage_reached / inject_verification / submit_verification / turn_verification / attempts / submit_diagnostics)
|
|
25
|
-
//! - name: submit_verification_wire
|
|
26
|
-
//! what: SubmitVerification 落 JSON 的唯一拼写来源
|
|
27
|
-
//! - name: turn_verification_wire
|
|
28
|
-
//! what: TurnVerification 落 JSON 的唯一拼写来源
|
|
29
|
-
//! depends:
|
|
30
|
-
//! - crate::model::enums::PaneLiveness
|
|
31
|
-
//! - serde
|
|
32
|
-
//! - thiserror
|
|
33
|
-
//! boundary:
|
|
34
|
-
//! - 不做投递语义(发给谁 / 为何发 / 可见性启发式)——那在 transport 之上的 delivery 层
|
|
35
|
-
//! - 本文件不执行 I/O;真正跑 argv 的是 tmux_backend
|
|
36
|
-
//! - turn_verification 不是投递闸门(Gap42),not_yet_observed 也算成功
|
|
37
|
-
//! - 不透传后端字面键名:抽象 Key 由各后端自行翻译
|
|
38
|
-
//! - submit_diagnostics 不上 typed wire,只在进程内传递
|
|
39
|
-
//! maturity: wired
|
|
40
|
-
//! ---
|
|
41
|
-
//!
|
|
42
|
-
//! step 9 · transport — 控制面 trait + typed payload(ROUND-0 SKELETON).
|
|
43
|
-
//!
|
|
44
|
-
//! 设计真相源:`docs/phase0/transport-backend-design.md` §1(Rust 草图:Target /
|
|
45
|
-
//! InjectPayload / Key / CaptureRange / PaneField / Liveness / SpawnResult /
|
|
46
|
-
//! PaneInfo / Transport trait §1.3 / BackendKind / SetEnvOutcome / TransportError)。
|
|
47
|
-
//! InjectReport 的阶段化字段(InjectStage / InjectVerification / SubmitVerification /
|
|
48
|
-
//! TurnVerification)来自子系统卡 `docs/phase0/subsystems/09-transport.md`(表 §38-42)。
|
|
49
|
-
//!
|
|
50
|
-
//! Python 真相源(`team-agent-public` @ v0.2.11):`messaging/tmux_io.py`、
|
|
51
|
-
//! `messaging/tmux_prompt.py`、`terminal.py`、`sessions/*`(capture/resume/inventory/drift)。
|
|
52
|
-
//!
|
|
53
|
-
//! 本文件**只有类型与方法签名**,无实现(§4 铁律:RED 契约要 name 的 TYPES 先编过)。
|
|
54
|
-
//!
|
|
55
|
-
//! §10:transport 被 coordinator/lifecycle/daemon 调用,所有 daemon 可达方法返
|
|
56
|
-
//! `Result<_, TransportError>`(I/O / 子进程错误);**能力性拒绝**(set-env 不支持事后
|
|
57
|
-
//! 补种、attach 无概念)用 typed `enum` variant 表达(SetEnvOutcome / AttachOutcome),
|
|
58
|
-
//! **不**用 `Result::Err` / `unwrap` / `expect` / `panic`。`#![deny(...)]` 由 leader
|
|
59
|
-
//! 在集成时统一加,本骨架不加。
|
|
60
|
-
|
|
61
|
-
// §10:daemon 可达方法实现层禁 unwrap/expect/panic(unimplemented! 未实现 stub 不算)。
|
|
62
|
-
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
63
|
-
|
|
64
|
-
use std::collections::BTreeMap;
|
|
65
|
-
use std::path::{Path, PathBuf};
|
|
66
|
-
|
|
67
|
-
use serde::{Deserialize, Serialize};
|
|
68
|
-
use thiserror::Error;
|
|
69
|
-
|
|
70
|
-
pub mod enter_rescue;
|
|
71
|
-
pub mod native_input;
|
|
72
|
-
|
|
73
|
-
#[cfg(test)]
|
|
74
|
-
pub mod test_support;
|
|
75
|
-
|
|
76
|
-
// 裁决(transport-backend-design.md §1.2 / 本 lane ADJUDICATION):
|
|
77
|
-
// 文档草图的 `Liveness {Live/Dead/Unknown}` 就是既有的 model::enums::PaneLiveness
|
|
78
|
-
// (`state.py:336-341`,bug-085 穷尽三态)—— REUSE,不重定义。
|
|
79
|
-
pub use crate::model::enums::PaneLiveness;
|
|
80
|
-
|
|
81
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
82
|
-
// id / name newtypes(透明 String 包装,字节 == 裸字符串,沿用 model::ids 风格)
|
|
83
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
/// tmux `#{pane_id}`(如 `%7`)/ wezterm 整数 pane-id / conpty 内部 handle key。
|
|
86
|
-
/// 禁与 window/session 名混传(09-transport.md 表 §30)。
|
|
87
|
-
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
|
88
|
-
#[serde(transparent)]
|
|
89
|
-
pub struct PaneId(pub String);
|
|
90
|
-
|
|
91
|
-
impl PaneId {
|
|
92
|
-
/// ---
|
|
93
|
-
/// purpose: 把已知的 pane 标识字符串包成 PaneId newtype
|
|
94
|
-
/// params:
|
|
95
|
-
/// s: 后端给出的 pane 标识原文;不做校验、不归一化
|
|
96
|
-
/// returns: 与入参字节相同的 PaneId(serde transparent)
|
|
97
|
-
/// boundary: 不校验格式、不区分 tmux/wezterm/conpty 方言;混入 window/session 名由类型系统在调用点挡
|
|
98
|
-
/// ---
|
|
99
|
-
pub fn new(s: impl Into<String>) -> Self {
|
|
100
|
-
Self(s.into())
|
|
101
|
-
}
|
|
102
|
-
/// ---
|
|
103
|
-
/// purpose: 借出 pane 标识的原始字符串,供 argv 拼装
|
|
104
|
-
/// returns: 内部字符串的借用,与构造时字节一致
|
|
105
|
-
/// boundary: 不做转义、不加引号;shell 引用由调用方负责
|
|
106
|
-
/// ---
|
|
107
|
-
pub fn as_str(&self) -> &str {
|
|
108
|
-
&self.0
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
impl std::fmt::Display for PaneId {
|
|
113
|
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
114
|
-
f.write_str(&self.0)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
impl From<&str> for PaneId {
|
|
119
|
-
fn from(s: &str) -> Self {
|
|
120
|
-
Self(s.to_string())
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/// tmux session 名(`tmux_session_exists`,terminal.py:20-33)。
|
|
125
|
-
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
|
126
|
-
#[serde(transparent)]
|
|
127
|
-
pub struct SessionName(pub String);
|
|
128
|
-
|
|
129
|
-
impl SessionName {
|
|
130
|
-
/// ---
|
|
131
|
-
/// purpose: 把 tmux session 名包成 SessionName newtype
|
|
132
|
-
/// params:
|
|
133
|
-
/// s: session 名原文;不做校验、不归一化
|
|
134
|
-
/// returns: 与入参字节相同的 SessionName(serde transparent)
|
|
135
|
-
/// boundary: 不校验 session 是否存在(那是 Transport::has_session)
|
|
136
|
-
/// ---
|
|
137
|
-
pub fn new(s: impl Into<String>) -> Self {
|
|
138
|
-
Self(s.into())
|
|
139
|
-
}
|
|
140
|
-
/// ---
|
|
141
|
-
/// purpose: 借出 session 名原文,供 argv 拼装
|
|
142
|
-
/// returns: 内部字符串的借用,与构造时字节一致
|
|
143
|
-
/// boundary: 不做转义、不加引号
|
|
144
|
-
/// ---
|
|
145
|
-
pub fn as_str(&self) -> &str {
|
|
146
|
-
&self.0
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
impl std::fmt::Display for SessionName {
|
|
151
|
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
152
|
-
f.write_str(&self.0)
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
impl From<&str> for SessionName {
|
|
157
|
-
fn from(s: &str) -> Self {
|
|
158
|
-
Self(s.to_string())
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/// tmux window 名(`tmux_window_exists`,terminal.py:20-33)。
|
|
163
|
-
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
|
164
|
-
#[serde(transparent)]
|
|
165
|
-
pub struct WindowName(pub String);
|
|
166
|
-
|
|
167
|
-
impl WindowName {
|
|
168
|
-
/// ---
|
|
169
|
-
/// purpose: 把 tmux window 名包成 WindowName newtype
|
|
170
|
-
/// params:
|
|
171
|
-
/// s: window 名原文;不做校验、不归一化
|
|
172
|
-
/// returns: 与入参字节相同的 WindowName(serde transparent)
|
|
173
|
-
/// boundary: 不校验 window 是否存在(那是 Transport::list_windows)
|
|
174
|
-
/// ---
|
|
175
|
-
pub fn new(s: impl Into<String>) -> Self {
|
|
176
|
-
Self(s.into())
|
|
177
|
-
}
|
|
178
|
-
/// ---
|
|
179
|
-
/// purpose: 借出 window 名原文,供 argv 拼装
|
|
180
|
-
/// returns: 内部字符串的借用,与构造时字节一致
|
|
181
|
-
/// boundary: 不做转义、不加引号
|
|
182
|
-
/// ---
|
|
183
|
-
pub fn as_str(&self) -> &str {
|
|
184
|
-
&self.0
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
impl std::fmt::Display for WindowName {
|
|
189
|
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
190
|
-
f.write_str(&self.0)
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
impl From<&str> for WindowName {
|
|
195
|
-
fn from(s: &str) -> Self {
|
|
196
|
-
Self(s.to_string())
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
201
|
-
// 关键 typed payload(避免散字符串,§19/§22;transport-backend-design.md §1.2)
|
|
202
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
203
|
-
|
|
204
|
-
/// 注入目标:两种合法寻址,类型上区分(禁混传)。tmux 用 SessionWindow 或 Pane;
|
|
205
|
-
/// WezTerm 只认整数 pane-id(SessionWindow 在后端内部先解析成 pane-id);ConPTY 只认
|
|
206
|
-
/// 自有 pane 的内部 key。
|
|
207
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
208
|
-
pub enum Target {
|
|
209
|
-
/// tmux `%7` / wezterm 整数 pane-id / conpty 内部 handle key。
|
|
210
|
-
Pane(PaneId),
|
|
211
|
-
SessionWindow {
|
|
212
|
-
session: SessionName,
|
|
213
|
-
window: WindowName,
|
|
214
|
-
},
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/// 注入载荷在类型上分流空文本(trust turn-integrity 契约 §3:空文本禁走 buffer,
|
|
218
|
-
/// 直发 Enter;tmux 拒空 buffer 会卡 trust prompt)。
|
|
219
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
220
|
-
pub enum InjectPayload {
|
|
221
|
-
/// → 纯 send submit-key。
|
|
222
|
-
Empty,
|
|
223
|
-
Text(String),
|
|
224
|
-
/// Text payload for human-facing panes that do not consume provider turns.
|
|
225
|
-
TextSkipConsumptionPoll(String),
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
impl InjectPayload {
|
|
229
|
-
/// ---
|
|
230
|
-
/// purpose: 取出载荷正文,把「有正文」与「空载荷」在类型上分开
|
|
231
|
-
/// returns: Text / TextSkipConsumptionPoll 返回 Some(正文);Empty 返回 None
|
|
232
|
-
/// boundary: 不区分两种带正文的变体(要区分用 skip_consumption_poll);不裁剪、不脱敏
|
|
233
|
-
/// ---
|
|
234
|
-
pub fn text(&self) -> Option<&str> {
|
|
235
|
-
match self {
|
|
236
|
-
Self::Text(text) | Self::TextSkipConsumptionPoll(text) => Some(text),
|
|
237
|
-
Self::Empty => None,
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/// ---
|
|
242
|
-
/// purpose: 标出「收件 pane 不消费 provider 回合」的载荷,后端据此跳过 post-Enter 消费轮询
|
|
243
|
-
/// returns: 仅 TextSkipConsumptionPoll 为 true
|
|
244
|
-
/// boundary: 只表达「不轮询消费」这一件事,不表达投递成功;调用方不得据此直接判 delivered
|
|
245
|
-
/// ---
|
|
246
|
-
pub fn skip_consumption_poll(&self) -> bool {
|
|
247
|
-
matches!(self, Self::TextSkipConsumptionPoll(_))
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/// 抽象 Key 枚举(§gap-5):各后端翻译,不透传 tmux 字面量。
|
|
252
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
253
|
-
pub enum Key {
|
|
254
|
-
/// tmux `Enter` / VT `\r`(CR,非 LF —— provider 提交触发的是 \r)。
|
|
255
|
-
Enter,
|
|
256
|
-
/// tmux 名 / VT `\x1b[A..D`(application-cursor-mode `\x1bO?` 风险)。
|
|
257
|
-
Up,
|
|
258
|
-
Down,
|
|
259
|
-
Left,
|
|
260
|
-
Right,
|
|
261
|
-
/// 选项键/数字。
|
|
262
|
-
Char(char),
|
|
263
|
-
/// `\x03`。
|
|
264
|
-
CtrlC,
|
|
265
|
-
/// E46 (0.3.24 bug#5): pre-submit Escape to exit bracketed-paste mode on
|
|
266
|
-
/// fresh provider TUIs (claude). When a bracketed paste lands on a TUI
|
|
267
|
-
/// whose composer is still initialising, the framework's plain `Enter`
|
|
268
|
-
/// gets interpreted as paste content, not submit. Sending `Escape` first
|
|
269
|
-
/// closes the paste bracket so the subsequent `Enter` submits.
|
|
270
|
-
/// Real-machine truth source: macmini demo-director repro.
|
|
271
|
-
Escape,
|
|
272
|
-
/// tmux `-X cancel` / `q` / `d`;非 tmux 后端无 copy-mode 概念 → no-op。
|
|
273
|
-
CancelMode,
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/// capture 范围(tmux `-S -<N>` / `-S -`)。
|
|
277
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
278
|
-
pub enum CaptureRange {
|
|
279
|
-
Tail(u32),
|
|
280
|
-
Head(u32),
|
|
281
|
-
Full,
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/// 单字段查询(display-message -p -F);非 tmux 后端无对应概念的字段返回 typed
|
|
285
|
-
/// 「不适用」(trait `query` 返回 `Option<String>`)。
|
|
286
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
287
|
-
pub enum PaneField {
|
|
288
|
-
PaneId,
|
|
289
|
-
PaneMode,
|
|
290
|
-
PaneWidth,
|
|
291
|
-
PaneCurrentCommand,
|
|
292
|
-
PaneCurrentPath,
|
|
293
|
-
SessionName,
|
|
294
|
-
/// pane's controlling tty (e.g. `/dev/ttys015`). Consumers use it to
|
|
295
|
-
/// flip terminal driver bits like `stty -f <tty> -echo` from outside
|
|
296
|
-
/// tmux's control channel — the query itself still goes through the
|
|
297
|
-
/// backend so N16/CP-1 (single tmux entry point) stays intact.
|
|
298
|
-
PaneTty,
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/// 后端种类(诊断/事件用)。
|
|
302
|
-
///
|
|
303
|
-
/// 裁决(本 lane ADJUDICATION):既有 `model::enums::Backend` 是 `{Tmux, Pty}`
|
|
304
|
-
/// (spec.py:255 的两值 spec 字段),**不等于** `BackendKind {Tmux, WezTerm, ConPty}`
|
|
305
|
-
/// (transport-backend-design.md §1.3 的三后端运行时种类)—— 故此处**新定义**
|
|
306
|
-
/// `BackendKind`,不复用 `Backend`。两者语义不同:`Backend` 是 spec 声明面的粗粒度
|
|
307
|
-
/// 选择(tmux vs pty),`BackendKind` 是 transport 实现面的具体后端(pty 进一步分
|
|
308
|
-
/// WezTerm 外部 mux 与 ConPTY 单机)。NOTE 给 leader 集成时复核映射关系
|
|
309
|
-
/// (Backend::Pty → {WezTerm | ConPty} 的解析在 §5 probe-first 逻辑里)。
|
|
310
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
311
|
-
#[serde(rename_all = "snake_case")]
|
|
312
|
-
pub enum BackendKind {
|
|
313
|
-
Tmux,
|
|
314
|
-
WezTerm,
|
|
315
|
-
ConPty,
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/// spawn 返回:后端把它创建的终端的稳定 id 交回框架,供后续 RIE 寻址 + 身份正向
|
|
319
|
-
/// 登记(§4a)。
|
|
320
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
321
|
-
pub struct SpawnResult {
|
|
322
|
-
pub pane_id: PaneId,
|
|
323
|
-
pub session: SessionName,
|
|
324
|
-
pub window: WindowName,
|
|
325
|
-
/// ConPTY 自有;tmux/wezterm 视 list 是否给 pid([真机])。
|
|
326
|
-
pub child_pid: Option<u32>,
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/// 全局枚举的一行(身份地基)。`leader_env` 在 tmux 后端靠反向读进程 env,在
|
|
330
|
-
/// WezTerm/ConPTY 后端靠正向登记表投影(§4a)。
|
|
331
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
332
|
-
pub struct SessionOwner {
|
|
333
|
-
pub workspace: String,
|
|
334
|
-
pub team: String,
|
|
335
|
-
pub generation: String,
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
339
|
-
pub struct PaneInfo {
|
|
340
|
-
pub pane_id: PaneId,
|
|
341
|
-
pub session: SessionName,
|
|
342
|
-
pub window_index: Option<u32>,
|
|
343
|
-
pub window_name: Option<WindowName>,
|
|
344
|
-
pub pane_index: Option<u32>,
|
|
345
|
-
pub tty: Option<String>,
|
|
346
|
-
/// WezTerm [真机]:list json 未必给前台命令 → GAP-3。
|
|
347
|
-
pub current_command: Option<String>,
|
|
348
|
-
pub current_path: Option<PathBuf>,
|
|
349
|
-
pub active: bool,
|
|
350
|
-
/// WezTerm [真机]:list json 未必给 OS pid → GAP-2。
|
|
351
|
-
pub pane_pid: Option<u32>,
|
|
352
|
-
/// tmux=反向读;wezterm/conpty=正向登记表的投影。
|
|
353
|
-
pub leader_env: BTreeMap<String, String>,
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/// 抓取到的屏幕文本(recognizer 的唯一输入;backend-agnostic,§4b)。
|
|
357
|
-
/// transport 出口处统一规范化(rstrip / `\xa0` 归一),recognizer 不为后端开分支。
|
|
358
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
359
|
-
pub struct CapturedText {
|
|
360
|
-
/// 规范化后的明文(各后端 capture 管线差异在此收口)。
|
|
361
|
-
pub text: String,
|
|
362
|
-
/// 抓取范围(诊断/审计)。
|
|
363
|
-
pub range: CaptureRange,
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
367
|
-
// inject 流水线阶段化报告(09-transport.md InjectOutcome → InjectReport,表 §38-42)
|
|
368
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
369
|
-
|
|
370
|
-
/// 注入流水线各阶段(失败定位;构成 `TransportError::Inject` 的定位字段)。
|
|
371
|
-
/// 字符串值取自 09-transport.md 表 §41(kebab-case,显式 `rename`)。
|
|
372
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
373
|
-
pub enum InjectStage {
|
|
374
|
-
#[serde(rename = "send-keys")]
|
|
375
|
-
SendKeys,
|
|
376
|
-
#[serde(rename = "pre-paste-capture")]
|
|
377
|
-
PrePasteCapture,
|
|
378
|
-
#[serde(rename = "set-buffer")]
|
|
379
|
-
SetBuffer,
|
|
380
|
-
#[serde(rename = "load-buffer")]
|
|
381
|
-
LoadBuffer,
|
|
382
|
-
#[serde(rename = "paste-buffer")]
|
|
383
|
-
PasteBuffer,
|
|
384
|
-
#[serde(rename = "delete-buffer")]
|
|
385
|
-
DeleteBuffer,
|
|
386
|
-
#[serde(rename = "pre-paste-pane-state")]
|
|
387
|
-
PrePastePaneState,
|
|
388
|
-
#[serde(rename = "pane-mode-check")]
|
|
389
|
-
PaneModeCheck,
|
|
390
|
-
#[serde(rename = "submit")]
|
|
391
|
-
Submit,
|
|
392
|
-
#[serde(rename = "visible-check")]
|
|
393
|
-
VisibleCheck,
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/// 注入可见性验证(审计语义;tmux_io.py + tmux_prompt.py 散布字符串穷尽枚举,
|
|
397
|
-
/// 09-transport.md 表 §38)。
|
|
398
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
399
|
-
#[serde(rename_all = "snake_case")]
|
|
400
|
-
pub enum InjectVerification {
|
|
401
|
-
CaptureContainsToken,
|
|
402
|
-
CaptureContainsMessageFragment,
|
|
403
|
-
CaptureContainsNewPastedContentPrompt,
|
|
404
|
-
NoToken,
|
|
405
|
-
CaptureMissingToken,
|
|
406
|
-
/// 空文本走纯 send-keys(InjectPayload::Empty)的验证。
|
|
407
|
-
EmptyTextSendKeys,
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/// 提交键验证(tmux_io.py:214-221, tmux_prompt.py:281-322,09-transport.md 表 §39)。
|
|
411
|
-
/// `{key}_sent_after_visible_token` 是模板 → 用携带 Key 的 variant 表达。
|
|
412
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
413
|
-
pub enum SubmitVerification {
|
|
414
|
-
/// `enter_sent_without_placeholder_check`。MUST-10:此 variant 代表 paste+Enter
|
|
415
|
-
/// 完成且无需 placeholder probe(纯 peer 消息路径)。**保留** ⇒ delivered 语义;
|
|
416
|
-
/// E46 后只有 post-Enter consumption 确认通过(input 清空 / Working 信号)才返回
|
|
417
|
-
/// 此 variant — fresh TUI 未消费走 [`Self::SubmitConsumptionUnverified`]。
|
|
418
|
-
EnterSentWithoutPlaceholderCheck,
|
|
419
|
-
/// `pasted_content_prompt_absent_after_submit`。
|
|
420
|
-
PastedContentPromptAbsentAfterSubmit,
|
|
421
|
-
/// `pasted_content_prompt_still_present_after_submit`。
|
|
422
|
-
PastedContentPromptStillPresentAfterSubmit,
|
|
423
|
-
/// `{key}_sent_after_visible_token`(key 由 variant 携带)。
|
|
424
|
-
KeySentAfterVisibleToken { key: Key },
|
|
425
|
-
/// `send_keys_failed`。
|
|
426
|
-
SendKeysFailed,
|
|
427
|
-
/// E46 (0.3.24 bug#5, demo-director 卡 bracketed paste): Enter 已发但
|
|
428
|
-
/// post-Enter 接收侧消费信号(input 行清空 / provider 进 Working)在 bounded
|
|
429
|
-
/// resend 上限内未观察到。**delivery 不当作 delivered**;走 submitted_unverified /
|
|
430
|
-
/// failed 路径。区别于
|
|
431
|
-
/// [`Self::PastedContentPromptStillPresentAfterSubmit`](claude paste-prompt
|
|
432
|
-
/// 折叠场景)— 本 variant 是结构化 input-empty 检测,适配 demo-director
|
|
433
|
-
/// 直接渲染文本路径。
|
|
434
|
-
SubmitConsumptionUnverified,
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
/// turn-boundary 观测(tmux_io.py:224-260,09-transport.md 表 §40)。
|
|
438
|
-
/// **Gap42**:turn 观测仅 metadata,`not_yet_observed` 也算成功,绝非投递闸门。
|
|
439
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
440
|
-
#[serde(rename_all = "snake_case")]
|
|
441
|
-
pub enum TurnVerification {
|
|
442
|
-
LeaderNewTurnBoundaryVerified,
|
|
443
|
-
LeaderNewTurnBoundaryMissing,
|
|
444
|
-
NotYetObserved,
|
|
445
|
-
NotRequired,
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/// 注入流水线阶段化报告(09-transport.md InjectReport;daemon 路径 typed 返回值)。
|
|
449
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
450
|
-
pub struct InjectReport {
|
|
451
|
-
pub stage_reached: InjectStage,
|
|
452
|
-
pub inject_verification: InjectVerification,
|
|
453
|
-
pub submit_verification: SubmitVerification,
|
|
454
|
-
/// Gap42:仅 metadata,`not_yet_observed` 也算成功。
|
|
455
|
-
pub turn_verification: TurnVerification,
|
|
456
|
-
pub attempts: u32,
|
|
457
|
-
/// E50 PR-1 (0.3.24 P0, pasted-prompt 假阴诊断): per-attempt observations
|
|
458
|
-
/// emitted by the paste-prompt + Enter loop in `tmux_backend.rs::inject`.
|
|
459
|
-
/// `None` when the inject path did not exercise the diagnostic
|
|
460
|
-
/// instrumentation (peer payloads, empty payloads, non-bracketed Text,
|
|
461
|
-
/// or any path that bypasses `capture_has_pasted_content_prompt`). When
|
|
462
|
-
/// present, downstream `send.unverified` / `send.failed` events surface
|
|
463
|
-
/// it as `submit_attempts_detail[]` so operators see live pane state
|
|
464
|
-
/// per attempt (matched literal, where-in-tail offset, scrubbed pane
|
|
465
|
-
/// excerpt, elapsed ms) — the missing forensic data the user has been
|
|
466
|
-
/// asking for for many rounds.
|
|
467
|
-
///
|
|
468
|
-
/// Tests / mocks should default this to `None` via `Default`. Wire
|
|
469
|
-
/// byte-lock (`transport::tests::wire`) is untouched: this field is NOT
|
|
470
|
-
/// serialised on the typed wire — it lives only in the in-process
|
|
471
|
-
/// `InjectReport` and is rendered into JSON manually by the delivery
|
|
472
|
-
/// layer when emitting forensic events.
|
|
473
|
-
pub submit_diagnostics: Option<SubmitDiagnostics>,
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/// E50 PR-1 diagnostic payload — one entry per submit attempt in the
|
|
477
|
-
/// pasted-prompt branch + (informational) for the appear-gate poll.
|
|
478
|
-
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
|
479
|
-
pub struct SubmitDiagnostics {
|
|
480
|
-
/// The concrete branch that produced the post-Enter consumption outcome.
|
|
481
|
-
/// Unknown is retained for paths that do not expose a branch reason.
|
|
482
|
-
pub consumption_reason: SubmitConsumptionReason,
|
|
483
|
-
/// Reserved for a pre-paste baseline; this path has no such capture and emits null.
|
|
484
|
-
pub before_busy_signal_kind: Option<BusySignalKind>,
|
|
485
|
-
/// Structured busy predicate category for the accepted/current capture.
|
|
486
|
-
pub busy_signal_kind: Option<BusySignalKind>,
|
|
487
|
-
/// Bottom-relative non-empty line index of the busy match.
|
|
488
|
-
pub busy_line_from_bottom: Option<u8>,
|
|
489
|
-
/// Whether this message marker is in the bottom 15 non-empty lines.
|
|
490
|
-
pub current_marker_in_bottom_15: Option<bool>,
|
|
491
|
-
/// Whether the tracked paste identity is still in the composer.
|
|
492
|
-
pub paste_identity_in_composer: Option<bool>,
|
|
493
|
-
/// Result of the structural consumption predicate on the current capture.
|
|
494
|
-
pub consumption_from_capture_result: Option<bool>,
|
|
495
|
-
/// Time spent in the appear-gate (poll for the pasted-content placeholder
|
|
496
|
-
/// before Enter). When `saw_pasted_prompt == false` this is the time we
|
|
497
|
-
/// spent polling before falling through to the E46 token path.
|
|
498
|
-
pub appear_gate_elapsed_ms: u64,
|
|
499
|
-
/// Did the appear-gate ever match the `pasted content` / `pasted text`
|
|
500
|
-
/// literal? When `false`, the inject took the E46 token path; the
|
|
501
|
-
/// `attempts_detail` may still capture observations the operator wants.
|
|
502
|
-
pub appear_gate_matched: bool,
|
|
503
|
-
/// Total elapsed across the whole submit gate (appear-gate + Enter
|
|
504
|
-
/// loop). Useful to triage real-machine slow-paste (codex large-paste
|
|
505
|
-
/// collapse can take >100 s while the framework's loop is sub-second).
|
|
506
|
-
pub total_elapsed_ms: u64,
|
|
507
|
-
/// Per-attempt observations of the post-Enter capture in the pasted-
|
|
508
|
-
/// prompt loop. Empty when `saw_pasted_prompt == false` and the inject
|
|
509
|
-
/// went through the E46 token path.
|
|
510
|
-
pub attempts_detail: Vec<SubmitAttemptObservation>,
|
|
511
|
-
/// Token visibility before paste. `None` means this inject did not sample
|
|
512
|
-
/// (honest unknown). Never inferred from later captures.
|
|
513
|
-
pub token_seen_before_paste: Option<bool>,
|
|
514
|
-
/// Token visibility from successful post-paste captures. `None` if every
|
|
515
|
-
/// post-paste capture failed or none ran.
|
|
516
|
-
pub token_seen_after_paste: Option<bool>,
|
|
517
|
-
/// Token visibility from successful post-Enter captures. `None` if none ran
|
|
518
|
-
/// or all failed.
|
|
519
|
-
pub token_seen_after_enter: Option<bool>,
|
|
520
|
-
pub capture_ok_count: u32,
|
|
521
|
-
pub capture_err_count: u32,
|
|
522
|
-
pub capture_sample_count: u32,
|
|
523
|
-
pub last_capture_outcome: CaptureSampleOutcome,
|
|
524
|
-
/// Basename only of `#{pane_current_command}` at inject; never argv.
|
|
525
|
-
pub pane_command_basename: Option<String>,
|
|
526
|
-
pub pane_command_query: QueryOutcome,
|
|
527
|
-
pub input_surface: InputSurfaceProbe,
|
|
528
|
-
pub target_pane_id: Option<String>,
|
|
529
|
-
/// Inject target pane id vs `#{pane_id}` queried on that same target.
|
|
530
|
-
pub target_pane_query_matched: Option<bool>,
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/// Structured category returned by the provider-busy predicate.
|
|
534
|
-
///
|
|
535
|
-
/// This is diagnostic metadata only; it does not change delivery semantics.
|
|
536
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
537
|
-
pub enum BusySignalKind {
|
|
538
|
-
Working,
|
|
539
|
-
Thinking,
|
|
540
|
-
Processing,
|
|
541
|
-
EscToInterrupt,
|
|
542
|
-
SpinnerGlyph,
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
impl BusySignalKind {
|
|
546
|
-
pub fn as_str(self) -> &'static str {
|
|
547
|
-
match self {
|
|
548
|
-
Self::Working => "working",
|
|
549
|
-
Self::Thinking => "thinking",
|
|
550
|
-
Self::Processing => "processing",
|
|
551
|
-
Self::EscToInterrupt => "esc_to_interrupt",
|
|
552
|
-
Self::SpinnerGlyph => "spinner_glyph",
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/// Structured reason for the post-Enter consumption observation.
|
|
558
|
-
///
|
|
559
|
-
/// This is diagnostic metadata only; it does not change delivery semantics.
|
|
560
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
561
|
-
pub enum SubmitConsumptionReason {
|
|
562
|
-
/// The token/input identity disappeared in the consumption capture.
|
|
563
|
-
ConsumptionFromCapture,
|
|
564
|
-
/// Cursor's bounded polling observed a provider-busy signal.
|
|
565
|
-
CursorPollingBusy,
|
|
566
|
-
/// The final fallback capture observed a provider-busy signal.
|
|
567
|
-
FallbackBusy,
|
|
568
|
-
/// The payload had no token marker, so no structural consumption probe ran.
|
|
569
|
-
NoMarker,
|
|
570
|
-
/// The bounded probe did not establish consumption.
|
|
571
|
-
Unverified,
|
|
572
|
-
/// An older or otherwise uncovered path did not provide a reason.
|
|
573
|
-
#[default]
|
|
574
|
-
Unknown,
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
impl SubmitConsumptionReason {
|
|
578
|
-
pub fn as_str(self) -> &'static str {
|
|
579
|
-
match self {
|
|
580
|
-
Self::ConsumptionFromCapture => "consumption_from_capture",
|
|
581
|
-
Self::CursorPollingBusy => "cursor_poll_busy",
|
|
582
|
-
Self::FallbackBusy => "fallback_busy",
|
|
583
|
-
Self::NoMarker => "no_marker",
|
|
584
|
-
Self::Unverified => "unverified",
|
|
585
|
-
Self::Unknown => "unknown",
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/// Last capture sample of the inject token path. Distinguishes "read failed"
|
|
591
|
-
/// from "read succeeded and token was absent". Does not change delivery gates.
|
|
592
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
593
|
-
pub enum CaptureSampleOutcome {
|
|
594
|
-
#[default]
|
|
595
|
-
NotAttempted,
|
|
596
|
-
OkTokenSeen,
|
|
597
|
-
OkTokenMissing,
|
|
598
|
-
Failed,
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
impl CaptureSampleOutcome {
|
|
602
|
-
pub fn as_str(self) -> &'static str {
|
|
603
|
-
match self {
|
|
604
|
-
Self::NotAttempted => "not_attempted",
|
|
605
|
-
Self::OkTokenSeen => "ok_token_seen",
|
|
606
|
-
Self::OkTokenMissing => "ok_token_missing",
|
|
607
|
-
Self::Failed => "failed",
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
613
|
-
pub enum QueryOutcome {
|
|
614
|
-
#[default]
|
|
615
|
-
Unavailable,
|
|
616
|
-
Observed,
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
impl QueryOutcome {
|
|
620
|
-
pub fn as_str(self) -> &'static str {
|
|
621
|
-
match self {
|
|
622
|
-
Self::Unavailable => "unavailable",
|
|
623
|
-
Self::Observed => "observed",
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
/// Typed pane input surface from existing `pane_mode` probe. `Unavailable`
|
|
629
|
-
/// means the query failed; it is not a pass.
|
|
630
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
631
|
-
pub enum InputSurfaceProbe {
|
|
632
|
-
#[default]
|
|
633
|
-
Unavailable,
|
|
634
|
-
Input,
|
|
635
|
-
Copy,
|
|
636
|
-
Tree,
|
|
637
|
-
View,
|
|
638
|
-
Client,
|
|
639
|
-
UnknownMode,
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
impl InputSurfaceProbe {
|
|
643
|
-
pub fn as_str(self) -> &'static str {
|
|
644
|
-
match self {
|
|
645
|
-
Self::Unavailable => "unavailable",
|
|
646
|
-
Self::Input => "input",
|
|
647
|
-
Self::Copy => "copy",
|
|
648
|
-
Self::Tree => "tree",
|
|
649
|
-
Self::View => "view",
|
|
650
|
-
Self::Client => "client",
|
|
651
|
-
Self::UnknownMode => "unknown_mode",
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/// First token of a pane command, basename only. Empty/missing → `None`.
|
|
657
|
-
pub(crate) fn command_basename(raw: &str) -> Option<String> {
|
|
658
|
-
let first = raw.split_whitespace().next()?.trim();
|
|
659
|
-
if first.is_empty() {
|
|
660
|
-
return None;
|
|
661
|
-
}
|
|
662
|
-
std::path::Path::new(first)
|
|
663
|
-
.file_name()
|
|
664
|
-
.and_then(|name| name.to_str())
|
|
665
|
-
.filter(|name| !name.is_empty())
|
|
666
|
-
.map(str::to_string)
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/// E50 PR-1 single attempt observation (one Enter + one capture). All fields
|
|
670
|
-
/// are forensic — they exist to make `send.unverified` / `send.failed` events
|
|
671
|
-
/// self-describing rather than requiring the operator to guess.
|
|
672
|
-
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
|
673
|
-
pub struct SubmitAttemptObservation {
|
|
674
|
-
/// 1-based attempt index (mirrors the `attempts` counter that already
|
|
675
|
-
/// ships in `InjectReport.attempts`).
|
|
676
|
-
pub attempt_index: u32,
|
|
677
|
-
/// Did this attempt's post-Enter capture STILL match the pasted-prompt
|
|
678
|
-
/// literal? `true` means the inject saw the placeholder; `false` means
|
|
679
|
-
/// the placeholder cleared (= submit succeeded by the legacy criterion).
|
|
680
|
-
pub matched: bool,
|
|
681
|
-
/// The matched literal substring (`pasted content` / `pasted text`)
|
|
682
|
-
/// when `matched == true`. `None` otherwise.
|
|
683
|
-
pub matched_literal: Option<String>,
|
|
684
|
-
/// Distance from the bottom of the tail where the match occurred:
|
|
685
|
-
/// `Some(0)` = bottom-most line (composer), `Some(N)` = N lines above
|
|
686
|
-
/// bottom (likely scrollback), `None` = no match. Critical for the
|
|
687
|
-
/// false-negative root cause: a `pasted content` literal in scrollback
|
|
688
|
-
/// is NOT the live composer placeholder.
|
|
689
|
-
pub where_in_tail: Option<u32>,
|
|
690
|
-
/// Scrubbed last 20 / 80 lines of the captured tail, ANSI-stripped,
|
|
691
|
-
/// capped ~1200 bytes. Secrets scrubbed (sk-/ghp_/AKIA/Bearer/hex32+).
|
|
692
|
-
pub pane_tail_excerpt: String,
|
|
693
|
-
/// Number of non-empty lines in `pane_tail_excerpt`.
|
|
694
|
-
pub pane_tail_lines: u32,
|
|
695
|
-
/// Time elapsed for THIS attempt (Enter + capture + match).
|
|
696
|
-
pub elapsed_ms: u64,
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
700
|
-
// 能力性拒绝的 typed 结果(非 Err —— 已知能力差,审计用;§10)
|
|
701
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
702
|
-
|
|
703
|
-
/// `set_session_env` 的 typed 结果(transport-backend-design.md §1.3 / §4c)。
|
|
704
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
705
|
-
pub enum SetEnvOutcome {
|
|
706
|
-
/// tmux:写进 session env。
|
|
707
|
-
Applied,
|
|
708
|
-
/// wezterm/conpty:worker env 已在 spawn 时注入,无需事后补种。
|
|
709
|
-
InternalizedAtSpawn,
|
|
710
|
-
/// 外部 leader pane 无法事后补种 → leader 必须启动时自带 env(§4c)。
|
|
711
|
-
UnsupportedForExternalPane { reason: String },
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
/// `attach_session` 的 typed 结果(transport-backend-design.md §1.3)。
|
|
715
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
716
|
-
pub enum AttachOutcome {
|
|
717
|
-
Attached,
|
|
718
|
-
/// wezterm:GUI 启动即 attach,无独立动作。
|
|
719
|
-
GuiAttachIsImplicit,
|
|
720
|
-
/// conpty:无 attach 概念。
|
|
721
|
-
Unsupported {
|
|
722
|
-
reason: String,
|
|
723
|
-
},
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
727
|
-
// TransportError(thiserror,lib 边界;transport-backend-design.md §1.3)
|
|
728
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
729
|
-
|
|
730
|
-
/// transport 的 I/O / 子进程错误。能力性拒绝**不**走这里(用上面的 typed outcome)。
|
|
731
|
-
#[derive(Debug, Error)]
|
|
732
|
-
pub enum TransportError {
|
|
733
|
-
/// Guard refused before a paste/key; the owned evidence carries any later effect floor.
|
|
734
|
-
#[error("native input not ready: {reason}")]
|
|
735
|
-
NativeInputNotReady { reason: String },
|
|
736
|
-
#[error("spawn failed on {backend:?}: {source}")]
|
|
737
|
-
Spawn {
|
|
738
|
-
backend: BackendKind,
|
|
739
|
-
#[source]
|
|
740
|
-
source: std::io::Error,
|
|
741
|
-
},
|
|
742
|
-
#[error("inject failed at stage {stage:?}: {source}")]
|
|
743
|
-
Inject {
|
|
744
|
-
stage: InjectStage,
|
|
745
|
-
#[source]
|
|
746
|
-
source: std::io::Error,
|
|
747
|
-
},
|
|
748
|
-
#[error("capture failed: {source}")]
|
|
749
|
-
Capture {
|
|
750
|
-
#[source]
|
|
751
|
-
source: std::io::Error,
|
|
752
|
-
},
|
|
753
|
-
/// tmux/wezterm cli 非 0 退出。
|
|
754
|
-
#[error("subprocess {argv:?} exited with {code:?}: {stderr}")]
|
|
755
|
-
Subprocess {
|
|
756
|
-
argv: Vec<String>,
|
|
757
|
-
code: Option<i32>,
|
|
758
|
-
stderr: String,
|
|
759
|
-
},
|
|
760
|
-
/// The final tmux spawn argv is too large for the transport command envelope.
|
|
761
|
-
/// Keep this separate from `Subprocess` so callers do not have to parse a
|
|
762
|
-
/// provider-sized argv dump to learn the actionable limit.
|
|
763
|
-
#[error(
|
|
764
|
-
"command_too_long: backend={backend:?}; segment={segment}; session={session}; window={window}; actual_bytes={actual_bytes}; limit_bytes={limit_bytes}"
|
|
765
|
-
)]
|
|
766
|
-
CommandTooLong {
|
|
767
|
-
backend: BackendKind,
|
|
768
|
-
segment: String,
|
|
769
|
-
session: String,
|
|
770
|
-
window: String,
|
|
771
|
-
actual_bytes: usize,
|
|
772
|
-
limit_bytes: usize,
|
|
773
|
-
},
|
|
774
|
-
/// wezterm mux 连不上 / tmux server 不在。
|
|
775
|
-
#[error("mux unavailable on {backend:?}: {detail}")]
|
|
776
|
-
MuxUnavailable {
|
|
777
|
-
backend: BackendKind,
|
|
778
|
-
detail: String,
|
|
779
|
-
},
|
|
780
|
-
#[error("target not found: {target}")]
|
|
781
|
-
TargetNotFound { target: String },
|
|
782
|
-
#[error(transparent)]
|
|
783
|
-
Io(#[from] std::io::Error),
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
787
|
-
// Transport trait(控制面;transport-backend-design.md §1.3)—— 仅签名,无 body
|
|
788
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
789
|
-
|
|
790
|
-
/// 控制面:把字节送进按稳定 id 寻址的终端 + 枚举/探活/生命周期。
|
|
791
|
-
///
|
|
792
|
-
/// 全部 daemon 可达方法返 `Result<_, TransportError>`(§10:I/O/子进程错误用 `Err`,
|
|
793
|
-
/// 能力性拒绝用 typed outcome variant)。投递语义(发给谁/为何发/可见性验证启发式)
|
|
794
|
-
/// 在 transport **之上**(step 10/11),不进 trait(§gap-recognizer)。
|
|
795
|
-
pub trait Transport: Send + Sync {
|
|
796
|
-
/// 后端种类(诊断/事件用)。
|
|
797
|
-
fn kind(&self) -> BackendKind;
|
|
798
|
-
|
|
799
|
-
/// Only the concrete tmux backend should scan real tmux socket roots.
|
|
800
|
-
/// Test doubles stay hermetic and use their injected probe results.
|
|
801
|
-
fn probes_real_tmux_socket_roots(&self) -> bool {
|
|
802
|
-
false
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
/// This backend implements the owned native composer/submit handshake.
|
|
806
|
-
/// Capability only: no socket discovery, reads, or effects. Unknown/test
|
|
807
|
-
/// backends do not claim a native input protocol by default.
|
|
808
|
-
fn supports_owned_native_input(&self) -> bool {
|
|
809
|
-
false
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
/// Physical tmux endpoint used by this transport when known. For tmux this is
|
|
813
|
-
/// either a full `-S` socket path or a `-L` socket name; non-tmux/test
|
|
814
|
-
/// transports can leave it unknown.
|
|
815
|
-
fn tmux_endpoint(&self) -> Option<String> {
|
|
816
|
-
None
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// —— SPAWN(ST):所有后端天然满足;cwd/env 是 spawn 参数,无独立动词(§gap-setenv)——
|
|
820
|
-
|
|
821
|
-
/// tmux=`new-session -d` / wezterm=`spawn --new-window` / conpty=`openpty`+spawn。
|
|
822
|
-
fn spawn_first(
|
|
823
|
-
&self,
|
|
824
|
-
session: &SessionName,
|
|
825
|
-
window: &WindowName,
|
|
826
|
-
argv: &[String],
|
|
827
|
-
cwd: &Path,
|
|
828
|
-
env: &BTreeMap<String, String>,
|
|
829
|
-
) -> Result<SpawnResult, TransportError>;
|
|
830
|
-
|
|
831
|
-
/// tmux=`new-window` / wezterm=`spawn --pane-id 锚` / conpty=再 `openpty` 进内存表。
|
|
832
|
-
fn spawn_into(
|
|
833
|
-
&self,
|
|
834
|
-
session: &SessionName,
|
|
835
|
-
window: &WindowName,
|
|
836
|
-
argv: &[String],
|
|
837
|
-
cwd: &Path,
|
|
838
|
-
env: &BTreeMap<String, String>,
|
|
839
|
-
) -> Result<SpawnResult, TransportError>;
|
|
840
|
-
|
|
841
|
-
/// D9 (#264): spawn + profile `env_unset` keys that must be REALLY unset in the worker
|
|
842
|
-
/// shell line (Python providers.py:142-145 sources an env file whose first lines are
|
|
843
|
-
/// `unset <KEY>`) — the tmux server environment can carry stale values that plain
|
|
844
|
-
/// env-map removal cannot clear. Default forwards to the plain spawn: backends without
|
|
845
|
-
/// an inherited-shell layer have nothing stale to unset.
|
|
846
|
-
fn spawn_first_with_env_unset(
|
|
847
|
-
&self,
|
|
848
|
-
session: &SessionName,
|
|
849
|
-
window: &WindowName,
|
|
850
|
-
argv: &[String],
|
|
851
|
-
cwd: &Path,
|
|
852
|
-
env: &BTreeMap<String, String>,
|
|
853
|
-
env_unset: &[String],
|
|
854
|
-
) -> Result<SpawnResult, TransportError> {
|
|
855
|
-
let _ = env_unset;
|
|
856
|
-
self.spawn_first(session, window, argv, cwd, env)
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
/// 同 [`Transport::spawn_first_with_env_unset`],对应 `spawn_into`。
|
|
860
|
-
fn spawn_into_with_env_unset(
|
|
861
|
-
&self,
|
|
862
|
-
session: &SessionName,
|
|
863
|
-
window: &WindowName,
|
|
864
|
-
argv: &[String],
|
|
865
|
-
cwd: &Path,
|
|
866
|
-
env: &BTreeMap<String, String>,
|
|
867
|
-
env_unset: &[String],
|
|
868
|
-
) -> Result<SpawnResult, TransportError> {
|
|
869
|
-
let _ = env_unset;
|
|
870
|
-
self.spawn_into(session, window, argv, cwd, env)
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
/// Spawn a worker as an additional pane in an existing session/window.
|
|
874
|
-
/// Backends without a split-pane primitive may conservatively fall back to
|
|
875
|
-
/// `spawn_into`; tmux overrides this with `split-window`.
|
|
876
|
-
fn spawn_split_with_env_unset(
|
|
877
|
-
&self,
|
|
878
|
-
session: &SessionName,
|
|
879
|
-
window: &WindowName,
|
|
880
|
-
argv: &[String],
|
|
881
|
-
cwd: &Path,
|
|
882
|
-
env: &BTreeMap<String, String>,
|
|
883
|
-
env_unset: &[String],
|
|
884
|
-
) -> Result<SpawnResult, TransportError> {
|
|
885
|
-
let _ = env_unset;
|
|
886
|
-
self.spawn_into(session, window, argv, cwd, env)
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
/// 0.5.39 Slice 2 (tmux-server-death-locate §7 Slice 2): worker spawn
|
|
890
|
-
/// variant that reuses the leader-wrapper mechanism so worker provider
|
|
891
|
-
/// exit does not collapse the pane into `[exited]` (which under
|
|
892
|
-
/// upstream tmux 3.6a private-server bugs can cascade into server
|
|
893
|
-
/// death). When the provider exits, the worker pane keeps an explicit
|
|
894
|
-
/// worker exit marker and runs the inert `/bin/sh -c` tail: it ignores
|
|
895
|
-
/// INT/QUIT and does not read pane stdin. Default falls back to plain
|
|
896
|
-
/// `spawn_first_with_env_unset` for backends that have no shell layer
|
|
897
|
-
/// (test-only `OfflineTransport`).
|
|
898
|
-
fn spawn_first_with_worker_shell_wrapper(
|
|
899
|
-
&self,
|
|
900
|
-
session: &SessionName,
|
|
901
|
-
window: &WindowName,
|
|
902
|
-
argv: &[String],
|
|
903
|
-
cwd: &Path,
|
|
904
|
-
env: &BTreeMap<String, String>,
|
|
905
|
-
env_unset: &[String],
|
|
906
|
-
provider_label: &str,
|
|
907
|
-
) -> Result<SpawnResult, TransportError> {
|
|
908
|
-
let _ = provider_label;
|
|
909
|
-
self.spawn_first_with_env_unset(session, window, argv, cwd, env, env_unset)
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
/// 同 [`Transport::spawn_first_with_worker_shell_wrapper`],对应 `spawn_into`。
|
|
913
|
-
fn spawn_into_with_worker_shell_wrapper(
|
|
914
|
-
&self,
|
|
915
|
-
session: &SessionName,
|
|
916
|
-
window: &WindowName,
|
|
917
|
-
argv: &[String],
|
|
918
|
-
cwd: &Path,
|
|
919
|
-
env: &BTreeMap<String, String>,
|
|
920
|
-
env_unset: &[String],
|
|
921
|
-
provider_label: &str,
|
|
922
|
-
) -> Result<SpawnResult, TransportError> {
|
|
923
|
-
let _ = provider_label;
|
|
924
|
-
self.spawn_into_with_env_unset(session, window, argv, cwd, env, env_unset)
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
/// 0.4.x (CR C-2): leader-specific spawn variant. Instead of `exec <cmd>`
|
|
928
|
-
/// (which makes the provider the pane's primary process and turns the
|
|
929
|
-
/// pane into `[exited]` when the provider exits), build a shell line
|
|
930
|
-
/// that runs the provider as a CHILD of a long-lived shell. When the
|
|
931
|
-
/// provider exits, the wrapper records the exit code and marker, then
|
|
932
|
-
/// execs an inert `/bin/sh -c` tail that ignores INT/QUIT and does not
|
|
933
|
-
/// read pane stdin. Default falls back to plain
|
|
934
|
-
/// `spawn_first_with_env_unset` for backends that have no shell layer
|
|
935
|
-
/// (test-only `OfflineTransport`).
|
|
936
|
-
fn spawn_first_with_leader_shell_wrapper(
|
|
937
|
-
&self,
|
|
938
|
-
session: &SessionName,
|
|
939
|
-
window: &WindowName,
|
|
940
|
-
argv: &[String],
|
|
941
|
-
cwd: &Path,
|
|
942
|
-
env: &BTreeMap<String, String>,
|
|
943
|
-
env_unset: &[String],
|
|
944
|
-
provider_label: &str,
|
|
945
|
-
) -> Result<SpawnResult, TransportError> {
|
|
946
|
-
let _ = provider_label;
|
|
947
|
-
self.spawn_first_with_env_unset(session, window, argv, cwd, env, env_unset)
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/// 同 [`Transport::spawn_first_with_leader_shell_wrapper`],对应 `spawn_into`。
|
|
951
|
-
fn spawn_into_with_leader_shell_wrapper(
|
|
952
|
-
&self,
|
|
953
|
-
session: &SessionName,
|
|
954
|
-
window: &WindowName,
|
|
955
|
-
argv: &[String],
|
|
956
|
-
cwd: &Path,
|
|
957
|
-
env: &BTreeMap<String, String>,
|
|
958
|
-
env_unset: &[String],
|
|
959
|
-
provider_label: &str,
|
|
960
|
-
) -> Result<SpawnResult, TransportError> {
|
|
961
|
-
let _ = provider_label;
|
|
962
|
-
self.spawn_into_with_env_unset(session, window, argv, cwd, env, env_unset)
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
// —— INJECT / CAPTURE / QUERY(RIE):按稳定 Target 寻址 ——
|
|
966
|
-
|
|
967
|
-
/// 归并 set/load-buffer + paste-buffer + send submit;空文本走纯 send-keys
|
|
968
|
-
/// (`InjectPayload::Empty`)。仅保证「字节进去了 + 提交键发了」+ typed 阶段化报告;
|
|
969
|
-
/// 可见性验证启发式在 transport 之上(§gap-recognizer)。
|
|
970
|
-
fn inject(
|
|
971
|
-
&self,
|
|
972
|
-
target: &Target,
|
|
973
|
-
payload: &InjectPayload,
|
|
974
|
-
submit: Key,
|
|
975
|
-
bracketed: bool,
|
|
976
|
-
) -> Result<InjectReport, TransportError>;
|
|
977
|
-
|
|
978
|
-
fn inject_with_submit_observer(
|
|
979
|
-
&self,
|
|
980
|
-
target: &Target,
|
|
981
|
-
payload: &InjectPayload,
|
|
982
|
-
submit: Key,
|
|
983
|
-
bracketed: bool,
|
|
984
|
-
observer: Option<&dyn SubmitObserver>,
|
|
985
|
-
) -> Result<InjectReport, TransportError> {
|
|
986
|
-
let report = self.inject(target, payload, submit, bracketed)?;
|
|
987
|
-
if let Some(observer) = observer {
|
|
988
|
-
observer.after_physical_submit();
|
|
989
|
-
}
|
|
990
|
-
Ok(report)
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
/// Observation only; None means this backend/provider has no native parser.
|
|
994
|
-
/// An implemented parser with an incomplete frame returns an error, not absence.
|
|
995
|
-
fn observe_native_input(
|
|
996
|
-
&self,
|
|
997
|
-
_target: &Target,
|
|
998
|
-
_provider: crate::model::enums::Provider,
|
|
999
|
-
) -> Result<Option<native_input::InputFrame>, TransportError> {
|
|
1000
|
-
Ok(None)
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
/// Snapshot the original attempted target without submitting or adopting a capsule.
|
|
1004
|
-
fn snapshot_enter_rescue(
|
|
1005
|
-
&self,
|
|
1006
|
-
_target: &Target,
|
|
1007
|
-
context: &enter_rescue::EnterRescueContext,
|
|
1008
|
-
_rendered_payload: &str,
|
|
1009
|
-
) -> Result<enter_rescue::EnterRescueContext, TransportError> {
|
|
1010
|
-
Ok(context.clone())
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
/// Independent delayed Enter-only watchdog, not native-input admission.
|
|
1014
|
-
fn rescue_enter_guarded(
|
|
1015
|
-
&self,
|
|
1016
|
-
_context: &enter_rescue::EnterRescueContext,
|
|
1017
|
-
_authorize: &dyn Fn() -> bool,
|
|
1018
|
-
_observer: Option<&dyn SubmitObserver>,
|
|
1019
|
-
) -> Result<enter_rescue::EnterRescueOutcome, TransportError> {
|
|
1020
|
-
Ok(enter_rescue::EnterRescueOutcome::NoEffect {
|
|
1021
|
-
reason: "unsupported_backend",
|
|
1022
|
-
reobserve: false,
|
|
1023
|
-
})
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
/// Enter-only recovery; unsupported backends have an explicit zero-effect refusal.
|
|
1027
|
-
fn rescue_enter(&self, _evidence: &native_input::NativeInputEvidence, _authorize: &dyn Fn() -> bool, _observer: Option<&dyn SubmitObserver>)
|
|
1028
|
-
-> Result<native_input::EnterRescueOutcome, TransportError>
|
|
1029
|
-
{
|
|
1030
|
-
Ok(native_input::EnterRescueOutcome::NoEffect { reason: "unsupported_backend", reobserve: false })
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
fn send_keys(&self, target: &Target, keys: &[Key]) -> Result<(), TransportError>;
|
|
1034
|
-
|
|
1035
|
-
fn capture(&self, target: &Target, range: CaptureRange)
|
|
1036
|
-
-> Result<CapturedText, TransportError>;
|
|
1037
|
-
|
|
1038
|
-
/// 非 tmux 后端无对应概念的字段返回 `Ok(None)`(typed「不适用」)。
|
|
1039
|
-
fn query(&self, target: &Target, field: PaneField) -> Result<Option<String>, TransportError>;
|
|
1040
|
-
|
|
1041
|
-
/// pane 存活三态(`PaneLiveness`,bug-085 穷尽 match;unknown ≠ dead ≠ live)。
|
|
1042
|
-
fn liveness(&self, pane: &PaneId) -> Result<PaneLiveness, TransportError>;
|
|
1043
|
-
|
|
1044
|
-
/// Exit status recorded by the provider's supervising wrapper, never inferred
|
|
1045
|
-
/// from terminal text. None means running or no authoritative receipt.
|
|
1046
|
-
fn provider_exit_status(&self, _pane: &PaneId) -> Result<Option<u8>, TransportError> {
|
|
1047
|
-
Ok(None)
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
/// Native dead-pane observation. Only Some(true) proves no live pane
|
|
1051
|
-
/// process; a missing/unsupported sample must remain unknown.
|
|
1052
|
-
fn pane_is_dead(&self, _pane: &PaneId) -> Result<Option<bool>, TransportError> {
|
|
1053
|
-
Ok(None)
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
/// Cheap direct pane existence check when a backend can prove it. `Ok(None)`
|
|
1057
|
-
/// preserves the existing Unknown boundary.
|
|
1058
|
-
fn has_pane(&self, pane: &PaneId) -> Result<Option<bool>, TransportError> {
|
|
1059
|
-
let _ = pane;
|
|
1060
|
-
Ok(None)
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
// —— ENUMERATE / IDENTITY(SL + 进程探测):身份/rebind 地基 ——
|
|
1064
|
-
|
|
1065
|
-
/// 全局枚举所有 pane + 每 pane 的 leader_env。tmux=`list-panes -a` + 读进程 env;
|
|
1066
|
-
/// wezterm=`cli list --format json` + 正向登记表;conpty=daemon 内存表(仅自有,§4a)。
|
|
1067
|
-
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError>;
|
|
1068
|
-
|
|
1069
|
-
/// Write an owner marker at the session scope after a new session is created.
|
|
1070
|
-
/// Backends without a session-local metadata primitive may no-op, but then
|
|
1071
|
-
/// shutdown must treat the missing marker as unknown and refuse destructive work.
|
|
1072
|
-
fn set_session_owner(
|
|
1073
|
-
&self,
|
|
1074
|
-
_session: &SessionName,
|
|
1075
|
-
_workspace: &Path,
|
|
1076
|
-
_team: &str,
|
|
1077
|
-
) -> Result<(), TransportError> {
|
|
1078
|
-
Ok(())
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
/// Write owner metadata including the launch generation when the backend
|
|
1082
|
-
/// can persist one. The default preserves compatibility for non-tmux
|
|
1083
|
-
/// transports, which remain Unknown on reads.
|
|
1084
|
-
fn set_session_owner_with_generation(
|
|
1085
|
-
&self,
|
|
1086
|
-
session: &SessionName,
|
|
1087
|
-
workspace: &Path,
|
|
1088
|
-
team: &str,
|
|
1089
|
-
_generation: &str,
|
|
1090
|
-
) -> Result<(), TransportError> {
|
|
1091
|
-
self.set_session_owner(session, workspace, team)
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
/// Read the session-local owner marker. `None` is an unknown/legacy session,
|
|
1095
|
-
/// never proof that the caller owns it.
|
|
1096
|
-
fn session_owner(
|
|
1097
|
-
&self,
|
|
1098
|
-
_session: &SessionName,
|
|
1099
|
-
) -> Result<Option<SessionOwner>, TransportError> {
|
|
1100
|
-
Ok(None)
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
fn has_session(&self, session: &SessionName) -> Result<bool, TransportError>;
|
|
1104
|
-
|
|
1105
|
-
fn list_windows(&self, session: &SessionName) -> Result<Vec<WindowName>, TransportError>;
|
|
1106
|
-
|
|
1107
|
-
fn configure_adaptive_pane_title(
|
|
1108
|
-
&self,
|
|
1109
|
-
session: &SessionName,
|
|
1110
|
-
window: &WindowName,
|
|
1111
|
-
pane: &PaneId,
|
|
1112
|
-
title: &str,
|
|
1113
|
-
) -> Result<(), TransportError> {
|
|
1114
|
-
let _ = (session, window, pane, title);
|
|
1115
|
-
Ok(())
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
/// tmux=`set-environment`;无 server-env 的后端(WezTerm/ConPTY)对 worker 内化为
|
|
1119
|
-
/// 「spawn 时注入」(`InternalizedAtSpawn`),对外部 leader pane 返回 typed 不支持
|
|
1120
|
-
/// (`UnsupportedForExternalPane`,§4c)。
|
|
1121
|
-
fn set_session_env(
|
|
1122
|
-
&self,
|
|
1123
|
-
session: &SessionName,
|
|
1124
|
-
key: &str,
|
|
1125
|
-
value: &str,
|
|
1126
|
-
) -> Result<SetEnvOutcome, TransportError>;
|
|
1127
|
-
|
|
1128
|
-
/// A-55 (window rename race): set a tmux per-window option (e.g.
|
|
1129
|
-
/// `allow-rename off`, `automatic-rename off`) on an existing window.
|
|
1130
|
-
/// tmux=`set-window-option -t SESSION:WINDOW`; non-tmux backends refuse
|
|
1131
|
-
/// via the default (typed unsupported).
|
|
1132
|
-
fn set_window_option(
|
|
1133
|
-
&self,
|
|
1134
|
-
_session: &SessionName,
|
|
1135
|
-
_window: &WindowName,
|
|
1136
|
-
_option: &str,
|
|
1137
|
-
_value: &str,
|
|
1138
|
-
) -> Result<(), TransportError> {
|
|
1139
|
-
Err(TransportError::MuxUnavailable {
|
|
1140
|
-
backend: self.kind(),
|
|
1141
|
-
detail: "set-window-option is tmux-only".to_string(),
|
|
1142
|
-
})
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
// —— LIFECYCLE(SL)——
|
|
1146
|
-
|
|
1147
|
-
/// Before stopping a seat, preserve its session if removing these targets
|
|
1148
|
-
/// would otherwise destroy it. This is not called by team shutdown/restart.
|
|
1149
|
-
/// Backends whose sessions outlive their panes need no special handling.
|
|
1150
|
-
fn preserve_session_before_stop(
|
|
1151
|
-
&self,
|
|
1152
|
-
_session: &SessionName,
|
|
1153
|
-
_targets: &[Target],
|
|
1154
|
-
) -> Result<(), TransportError> {
|
|
1155
|
-
Ok(())
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
fn kill_server(&self) -> Result<(), TransportError> {
|
|
1159
|
-
Ok(())
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
fn kill_session(&self, session: &SessionName) -> Result<(), TransportError>;
|
|
1163
|
-
|
|
1164
|
-
fn kill_window(&self, target: &Target) -> Result<(), TransportError>;
|
|
1165
|
-
|
|
1166
|
-
fn kill_pane(&self, pane: &PaneId) -> Result<(), TransportError> {
|
|
1167
|
-
self.kill_window(&Target::Pane(pane.clone()))
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
/// 交互前台 attach(leader 用)。tmux=`attach-session`;wezterm=GUI 即 attach
|
|
1171
|
-
/// (`GuiAttachIsImplicit`);conpty=typed 不支持(`Unsupported`)。
|
|
1172
|
-
fn attach_session(&self, session: &SessionName) -> Result<AttachOutcome, TransportError>;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
pub trait SubmitObserver {
|
|
1176
|
-
fn after_physical_submit(&self);
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
1180
|
-
// 命令构造 seam(STEP-9 头号目标:exact tmux command construction).
|
|
1181
|
-
//
|
|
1182
|
-
// trait 只回高层 typed 值(SpawnResult/InjectReport/CapturedText/Option<String>),
|
|
1183
|
-
// 永远拿不到它构的 argv —— 因此「set/load/paste-buffer -p、capture-pane -S -<N>、
|
|
1184
|
-
// display-message -F #{pane_width}、send-keys 键名翻译、CancelMode→-X cancel/q/d」
|
|
1185
|
-
// 这些 golden 在 trait 层**无法断言**。这里引入纯函数构造 seam(无 I/O,可单测):
|
|
1186
|
-
// tmux 后端的实现必须用这些 fn 构 argv,契约则 golden-lock 它们的输出。
|
|
1187
|
-
// 真相源:tmux_io.py / tmux_prompt.py / runtime.py / delivery.py / terminal.py /
|
|
1188
|
-
// provider_cli/codex.py(argv 已 golden-probe via /tmp/transport_cmd_golden.py)。
|
|
1189
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
1190
|
-
|
|
1191
|
-
/// tmux 进入的特殊 mode(CancelMode 退出键分派的输入;tmux_io.py:416-427)。
|
|
1192
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
1193
|
-
pub enum PaneMode {
|
|
1194
|
-
/// `copy-mode` → `-X cancel`。
|
|
1195
|
-
Copy,
|
|
1196
|
-
/// `tree-mode` → `q`。
|
|
1197
|
-
Tree,
|
|
1198
|
-
/// `view-mode` → `q`。
|
|
1199
|
-
View,
|
|
1200
|
-
/// `client-mode` → `d`。
|
|
1201
|
-
Client,
|
|
1202
|
-
/// 其它/未知 → `-X cancel` + warn(`pane_mode_unknown_cancel_attempted`)。
|
|
1203
|
-
Unknown,
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
/// 把抽象 `Key` 翻译成 tmux send-keys 字面键名(各后端翻译,不透传字面量;§gap-5)。
|
|
1207
|
-
/// tmux:Enter/Up/Down/Left/Right/数字字符/C-c;CancelMode 不是单键(走 cancel_mode_argv)。
|
|
1208
|
-
/// 真相源:codex.py:266 `send-keys -t %7 Down Enter`、tmux send-keys 键名约定。
|
|
1209
|
-
/// 菜单/方向键序列继续用这里的 `Enter`。投递提交键走 [`tmux_submit_key_name`]。
|
|
1210
|
-
/// ---
|
|
1211
|
-
/// purpose: 抽象 Key 到 tmux send-keys 字面键名的翻译表
|
|
1212
|
-
/// params:
|
|
1213
|
-
/// key: 抽象按键;CancelMode 与非数字 Char 无单键拼写
|
|
1214
|
-
/// returns: tmux 键名;CancelMode 与未覆盖的 Char 返回空串,由调用方过滤掉
|
|
1215
|
-
/// boundary: 不构 argv、不发键;CancelMode 的真正出口是 tmux_cancel_mode_argv;提交键拼写不在这里(见 tmux_submit_key_name)
|
|
1216
|
-
/// ---
|
|
1217
|
-
pub fn tmux_key_name(key: Key) -> &'static str {
|
|
1218
|
-
match key {
|
|
1219
|
-
Key::Enter => "Enter",
|
|
1220
|
-
Key::Up => "Up",
|
|
1221
|
-
Key::Down => "Down",
|
|
1222
|
-
Key::Left => "Left",
|
|
1223
|
-
Key::Right => "Right",
|
|
1224
|
-
Key::Char('0') => "0",
|
|
1225
|
-
Key::Char('1') => "1",
|
|
1226
|
-
Key::Char('2') => "2",
|
|
1227
|
-
Key::Char('3') => "3",
|
|
1228
|
-
Key::Char('4') => "4",
|
|
1229
|
-
Key::Char('5') => "5",
|
|
1230
|
-
Key::Char('6') => "6",
|
|
1231
|
-
Key::Char('7') => "7",
|
|
1232
|
-
Key::Char('8') => "8",
|
|
1233
|
-
Key::Char('9') => "9",
|
|
1234
|
-
Key::CtrlC => "C-c",
|
|
1235
|
-
// E46 (0.3.24 bug#5): tmux supports `Escape` as a key name; sending
|
|
1236
|
-
// it as a send-keys arg emits `\x1b` to the pane (closes bracketed
|
|
1237
|
-
// paste mode on a stuck TUI composer).
|
|
1238
|
-
Key::Escape => "Escape",
|
|
1239
|
-
Key::CancelMode | Key::Char(_) => "",
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
/// `send-keys -t <target> <k1> <k2> ...`(键名经 `tmux_key_name` 翻译)。
|
|
1244
|
-
/// golden:`[Down, Enter]` → `["tmux","send-keys","-t","%7","Down","Enter"]`(codex.py:266)。
|
|
1245
|
-
/// ---
|
|
1246
|
-
/// purpose: 构造按键序列的 send-keys argv(菜单/方向键路径)
|
|
1247
|
-
/// params:
|
|
1248
|
-
/// pane: 目标 pane 标识,直接进 -t
|
|
1249
|
-
/// keys: 按顺序翻译成键名;翻译为空串的键被丢弃,不占位
|
|
1250
|
-
/// returns: 完整 argv;keys 全为空串时退化成只有前缀的 send-keys(不会报错)
|
|
1251
|
-
/// boundary: 纯构造,不执行;不加 socket 参数(-L/-S 由 tmux_backend 的 run chokepoint 补);此处的 Enter 是菜单键名,不是提交拼写
|
|
1252
|
-
/// ---
|
|
1253
|
-
pub fn tmux_send_keys_argv(pane: &PaneId, keys: &[Key]) -> Vec<String> {
|
|
1254
|
-
let mut argv = vec![
|
|
1255
|
-
"tmux".to_string(),
|
|
1256
|
-
"send-keys".to_string(),
|
|
1257
|
-
"-t".to_string(),
|
|
1258
|
-
pane.as_str().to_string(),
|
|
1259
|
-
];
|
|
1260
|
-
argv.extend(
|
|
1261
|
-
keys.iter()
|
|
1262
|
-
.copied()
|
|
1263
|
-
.map(tmux_key_name)
|
|
1264
|
-
.filter(|k| !k.is_empty())
|
|
1265
|
-
.map(str::to_string),
|
|
1266
|
-
);
|
|
1267
|
-
argv
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
/// 投递提交键的 tmux 拼写。
|
|
1271
|
-
///
|
|
1272
|
-
/// `Enter` 必须保持逻辑 Return,不能替换成控制组合 `C-m`。
|
|
1273
|
-
/// legacy PTY 中两者都是 CR,但启用 extended keys 后 `C-m` 会成为
|
|
1274
|
-
/// CSI-u / modifyOtherKeys Ctrl-M,Pi 不把它当提交;`Enter` 仍发送 CR。
|
|
1275
|
-
/// ---
|
|
1276
|
-
/// purpose: 投递提交键复用通用逻辑键翻译,避免协议相关的控制键别名
|
|
1277
|
-
/// params:
|
|
1278
|
-
/// key: 逻辑提交键
|
|
1279
|
-
/// returns: 与 tmux_key_name 同值(含空串情形)
|
|
1280
|
-
/// boundary: 只管拼写,不管何时提交、提交是否成功;不发送、不验证
|
|
1281
|
-
/// ---
|
|
1282
|
-
pub fn tmux_submit_key_name(key: Key) -> &'static str {
|
|
1283
|
-
tmux_key_name(key)
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
/// 投递提交:`send-keys -t <pane> <submit-spelling>`。
|
|
1287
|
-
/// ---
|
|
1288
|
-
/// purpose: 构造投递提交键的 send-keys argv
|
|
1289
|
-
/// params:
|
|
1290
|
-
/// pane: 目标 pane 标识
|
|
1291
|
-
/// submit: 提交键;经 tmux_submit_key_name 取拼写
|
|
1292
|
-
/// returns: 单条 argv,末位为提交键拼写
|
|
1293
|
-
/// boundary: 纯构造,不执行;tmux 对该 argv 返回 rc=0 不等于回合已提交(copy-mode 会吞键),真伪判定在 tmux_backend 的消费验证
|
|
1294
|
-
/// ---
|
|
1295
|
-
pub fn tmux_send_submit_argv(pane: &PaneId, submit: Key) -> Vec<String> {
|
|
1296
|
-
vec![
|
|
1297
|
-
"tmux".to_string(),
|
|
1298
|
-
"send-keys".to_string(),
|
|
1299
|
-
"-t".to_string(),
|
|
1300
|
-
pane.as_str().to_string(),
|
|
1301
|
-
tmux_submit_key_name(submit).to_string(),
|
|
1302
|
-
]
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
/// 闭合未完成的 bracketed paste:字面 CSI `ESC [ 201 ~`。
|
|
1306
|
-
/// 不是 `Escape` 键(E55:重试只重按回车,绝不送 Escape/C-c)。
|
|
1307
|
-
/// ---
|
|
1308
|
-
/// purpose: 构造「字面写入 CSI 201~」的 argv,闭合 composer 里未收尾的 bracketed paste
|
|
1309
|
-
/// params:
|
|
1310
|
-
/// pane: 目标 pane 标识
|
|
1311
|
-
/// returns: 带 -l 的 send-keys argv,写入的是字面转义序列而非键名
|
|
1312
|
-
/// boundary: 绝不用 Escape / Ctrl-C 代替(E55 红线);纯构造,不执行;不判断 pane 当前是否真处于 paste 中
|
|
1313
|
-
/// ---
|
|
1314
|
-
pub fn tmux_close_bracketed_paste_argv(pane: &PaneId) -> Vec<String> {
|
|
1315
|
-
vec![
|
|
1316
|
-
"tmux".to_string(),
|
|
1317
|
-
"send-keys".to_string(),
|
|
1318
|
-
"-t".to_string(),
|
|
1319
|
-
pane.as_str().to_string(),
|
|
1320
|
-
"-l".to_string(),
|
|
1321
|
-
"\u{1b}[201~".to_string(),
|
|
1322
|
-
]
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
/// CancelMode 在 tmux 上按 pane mode 分派退出键(tmux_io.py:419-426)。
|
|
1326
|
-
/// golden:Copy→`-X cancel`,Tree/View→`q`,Client→`d`,Unknown→`-X cancel`(+warn)。
|
|
1327
|
-
/// ---
|
|
1328
|
-
/// purpose: 按 pane 当前 mode 分派退出键,构造离开特殊 mode 的 argv
|
|
1329
|
-
/// params:
|
|
1330
|
-
/// pane: 目标 pane 标识
|
|
1331
|
-
/// mode: 已探到的 pane mode;Unknown 保守走 -X cancel
|
|
1332
|
-
/// returns: 单条 send-keys argv,尾部按 mode 取 -X cancel / q / d
|
|
1333
|
-
/// boundary: 纯构造,不执行、不探测 mode(探测在 tmux_backend);不保证 mode 真的退出了,调用方需复查
|
|
1334
|
-
/// ---
|
|
1335
|
-
pub fn tmux_cancel_mode_argv(pane: &PaneId, mode: PaneMode) -> Vec<String> {
|
|
1336
|
-
let mut argv = vec![
|
|
1337
|
-
"tmux".to_string(),
|
|
1338
|
-
"send-keys".to_string(),
|
|
1339
|
-
"-t".to_string(),
|
|
1340
|
-
pane.as_str().to_string(),
|
|
1341
|
-
];
|
|
1342
|
-
match mode {
|
|
1343
|
-
PaneMode::Copy | PaneMode::Unknown => {
|
|
1344
|
-
argv.push("-X".to_string());
|
|
1345
|
-
argv.push("cancel".to_string());
|
|
1346
|
-
}
|
|
1347
|
-
PaneMode::Tree | PaneMode::View => argv.push("q".to_string()),
|
|
1348
|
-
PaneMode::Client => argv.push("d".to_string()),
|
|
1349
|
-
}
|
|
1350
|
-
argv
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
/// CaptureRange → `capture-pane -p -S <spec> -t <target>`。
|
|
1354
|
-
/// golden:`Tail(40)` → `-S -40`(tmux_prompt.py:149/tmux_io.py:410);
|
|
1355
|
-
/// `Full` → `-S -`(runtime.py:519)。
|
|
1356
|
-
/// ---
|
|
1357
|
-
/// purpose: 把 CaptureRange 翻成 capture-pane 的起止参数
|
|
1358
|
-
/// params:
|
|
1359
|
-
/// pane: 目标 pane 标识
|
|
1360
|
-
/// range: Tail(n) 取倒数 n 行 -S -n;Head(n) 取 -S 0 并追加 -E n-1;Full 取 -S -
|
|
1361
|
-
/// returns: 完整 capture-pane argv;Head(0) 时 -E 饱和到 0(不会下溢)
|
|
1362
|
-
/// boundary: 纯构造,不执行、不解析输出;抓回来的文本要经 normalize_capture 才交给识别层
|
|
1363
|
-
/// ---
|
|
1364
|
-
pub fn tmux_capture_argv(pane: &PaneId, range: CaptureRange) -> Vec<String> {
|
|
1365
|
-
let spec = match range {
|
|
1366
|
-
CaptureRange::Tail(lines) => format!("-{lines}"),
|
|
1367
|
-
CaptureRange::Head(_) => "0".to_string(),
|
|
1368
|
-
CaptureRange::Full => "-".to_string(),
|
|
1369
|
-
};
|
|
1370
|
-
let mut argv = vec![
|
|
1371
|
-
"tmux".to_string(),
|
|
1372
|
-
"capture-pane".to_string(),
|
|
1373
|
-
"-p".to_string(),
|
|
1374
|
-
"-S".to_string(),
|
|
1375
|
-
spec,
|
|
1376
|
-
"-t".to_string(),
|
|
1377
|
-
pane.as_str().to_string(),
|
|
1378
|
-
];
|
|
1379
|
-
if let CaptureRange::Head(lines) = range {
|
|
1380
|
-
argv.extend(["-E".to_string(), lines.saturating_sub(1).to_string()]);
|
|
1381
|
-
}
|
|
1382
|
-
argv
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
/// PaneField → `display-message -p -t <target> [-F] <fmt>`。
|
|
1386
|
-
/// golden:PaneWidth → `-F '#{pane_width}'`(delivery.py:34);
|
|
1387
|
-
/// PaneMode → `'#{pane_mode}'`(tmux_io.py:403);PaneId → `'#{pane_id}'`(state.py:346)。
|
|
1388
|
-
/// ---
|
|
1389
|
-
/// purpose: 把 PaneField 翻成 display-message 的单字段查询 argv
|
|
1390
|
-
/// params:
|
|
1391
|
-
/// pane: 目标 pane 标识
|
|
1392
|
-
/// field: 待查字段;PaneMode 走不带 -F 的形式,其余字段加 -F
|
|
1393
|
-
/// returns: 完整 display-message argv,末位是 tmux 格式串
|
|
1394
|
-
/// boundary: 纯构造,不执行、不解析;查询失败与「字段不适用」的区分在 Transport::query 的 Option 返回值上
|
|
1395
|
-
/// ---
|
|
1396
|
-
pub fn tmux_query_argv(pane: &PaneId, field: PaneField) -> Vec<String> {
|
|
1397
|
-
let fmt = match field {
|
|
1398
|
-
PaneField::PaneId => "#{pane_id}",
|
|
1399
|
-
PaneField::PaneMode => "#{pane_mode}",
|
|
1400
|
-
PaneField::PaneWidth => "#{pane_width}",
|
|
1401
|
-
PaneField::PaneCurrentCommand => "#{pane_current_command}",
|
|
1402
|
-
PaneField::PaneCurrentPath => "#{pane_current_path}",
|
|
1403
|
-
PaneField::SessionName => "#{session_name}",
|
|
1404
|
-
PaneField::PaneTty => "#{pane_tty}",
|
|
1405
|
-
};
|
|
1406
|
-
let mut argv = vec![
|
|
1407
|
-
"tmux".to_string(),
|
|
1408
|
-
"display-message".to_string(),
|
|
1409
|
-
"-p".to_string(),
|
|
1410
|
-
"-t".to_string(),
|
|
1411
|
-
pane.as_str().to_string(),
|
|
1412
|
-
];
|
|
1413
|
-
if !matches!(field, PaneField::PaneMode) {
|
|
1414
|
-
argv.push("-F".to_string());
|
|
1415
|
-
}
|
|
1416
|
-
argv.push(fmt.to_string());
|
|
1417
|
-
argv
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
/// spawn argv:首个 session 用 new-session,后续 worker 用 new-window。
|
|
1421
|
-
/// golden(terminal.py:44-45 / runtime.py:1019-1020):
|
|
1422
|
-
/// first → `new-session -d -P -F #{pane_id} -s <s> -n <w> sh -lc <cmd>`
|
|
1423
|
-
/// into → `new-window -d -P -F #{pane_id} -t <s> -n <w> sh -lc <cmd>`
|
|
1424
|
-
/// `argv` 被组装成单条 `sh -lc` 命令字符串(provider 启动行)。
|
|
1425
|
-
/// ---
|
|
1426
|
-
/// purpose: 构造 spawn argv:首个席位用 new-session,后续席位用 new-window
|
|
1427
|
-
/// params:
|
|
1428
|
-
/// session: 目标 session 名
|
|
1429
|
-
/// window: 新窗口名
|
|
1430
|
-
/// command: 已拼好的单条 shell 命令行,原样进 sh -lc(本函数不做引用/转义)
|
|
1431
|
-
/// first: true 走 new-session,false 走 new-window
|
|
1432
|
-
/// returns: 完整 argv;两支都带 -d(后台创建,不抢客户端焦点)与 -P -F 使 tmux 回打 pane_id
|
|
1433
|
-
/// boundary: 纯构造,不执行、不校验 session 是否已存在;command 的 shell 引用由调用方(tmux_backend 的 shell wrapper)负责
|
|
1434
|
-
/// ---
|
|
1435
|
-
pub fn tmux_spawn_argv(
|
|
1436
|
-
session: &SessionName,
|
|
1437
|
-
window: &WindowName,
|
|
1438
|
-
command: &str,
|
|
1439
|
-
first: bool,
|
|
1440
|
-
) -> Vec<String> {
|
|
1441
|
-
if first {
|
|
1442
|
-
vec![
|
|
1443
|
-
"tmux".to_string(),
|
|
1444
|
-
"new-session".to_string(),
|
|
1445
|
-
"-d".to_string(),
|
|
1446
|
-
"-P".to_string(),
|
|
1447
|
-
"-F".to_string(),
|
|
1448
|
-
"#{pane_id}".to_string(),
|
|
1449
|
-
"-s".to_string(),
|
|
1450
|
-
session.as_str().to_string(),
|
|
1451
|
-
"-n".to_string(),
|
|
1452
|
-
window.as_str().to_string(),
|
|
1453
|
-
"sh".to_string(),
|
|
1454
|
-
"-lc".to_string(),
|
|
1455
|
-
command.to_string(),
|
|
1456
|
-
]
|
|
1457
|
-
} else {
|
|
1458
|
-
// E53 (0.3.26, adaptive layout same-session tabs): `-d` makes the new
|
|
1459
|
-
// window start without switching the client's active window to it. The
|
|
1460
|
-
// leader stays on its own window; the worker opens as a background tab.
|
|
1461
|
-
// Without `-d` every `new-window` call yanks the leader's terminal to
|
|
1462
|
-
// the freshly spawned worker window, disrupting whatever the leader is
|
|
1463
|
-
// doing. `-d` matches the Python golden: the managed leader and all
|
|
1464
|
-
// workers share the same tmux session (= same terminal window tabs).
|
|
1465
|
-
vec![
|
|
1466
|
-
"tmux".to_string(),
|
|
1467
|
-
"new-window".to_string(),
|
|
1468
|
-
"-d".to_string(),
|
|
1469
|
-
"-P".to_string(),
|
|
1470
|
-
"-F".to_string(),
|
|
1471
|
-
"#{pane_id}".to_string(),
|
|
1472
|
-
"-t".to_string(),
|
|
1473
|
-
session.as_str().to_string(),
|
|
1474
|
-
"-n".to_string(),
|
|
1475
|
-
window.as_str().to_string(),
|
|
1476
|
-
"sh".to_string(),
|
|
1477
|
-
"-lc".to_string(),
|
|
1478
|
-
command.to_string(),
|
|
1479
|
-
]
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
/// inject 文本路径的 buffer 构造序列(空文本不走这里,走 tmux_empty_inject_argv)。
|
|
1484
|
-
/// 返回有序 argv 列表:set-buffer(小)或 load-buffer -(大,>=阈值)→ paste-buffer -p →
|
|
1485
|
-
/// delete-buffer。golden(tmux_io.py:119/303/314/324):
|
|
1486
|
-
/// set-buffer → `set-buffer -b <buf> <text>`
|
|
1487
|
-
/// paste-buffer→ `paste-buffer -t <target> -b <buf> -p`(-p = bracketed)
|
|
1488
|
-
/// delete-buffer→`delete-buffer -b <buf>`
|
|
1489
|
-
/// ---
|
|
1490
|
-
/// purpose: 构造文本注入的三步 argv 序列:装 buffer → 粘到 pane → 删 buffer
|
|
1491
|
-
/// params:
|
|
1492
|
-
/// pane: 目标 pane 标识
|
|
1493
|
-
/// buffer_name: 本次注入独占的 tmux buffer 名,三步共用同一个名字
|
|
1494
|
-
/// text: 待注入正文;长度 >= 16 KiB 改走 load-buffer - (由 stdin 喂),否则 set-buffer 直传
|
|
1495
|
-
/// bracketed: true 时 paste-buffer 加 -p(bracketed paste)
|
|
1496
|
-
/// returns: 有序的三条 argv:[load 或 set, paste, delete];调用方必须按序执行
|
|
1497
|
-
/// boundary: 纯构造,不执行、不发提交键;空文本禁走这条路径(见 tmux_empty_inject_argv);不保证 buffer 名唯一,去重由调用方负责
|
|
1498
|
-
/// ---
|
|
1499
|
-
pub fn tmux_inject_text_argv(
|
|
1500
|
-
pane: &PaneId,
|
|
1501
|
-
buffer_name: &str,
|
|
1502
|
-
text: &str,
|
|
1503
|
-
bracketed: bool,
|
|
1504
|
-
) -> Vec<Vec<String>> {
|
|
1505
|
-
const TMUX_STDIN_BUFFER_THRESHOLD: usize = 16 * 1024;
|
|
1506
|
-
let mut paste = vec![
|
|
1507
|
-
"tmux".to_string(),
|
|
1508
|
-
"paste-buffer".to_string(),
|
|
1509
|
-
"-t".to_string(),
|
|
1510
|
-
pane.as_str().to_string(),
|
|
1511
|
-
"-b".to_string(),
|
|
1512
|
-
buffer_name.to_string(),
|
|
1513
|
-
];
|
|
1514
|
-
if bracketed {
|
|
1515
|
-
paste.push("-p".to_string());
|
|
1516
|
-
}
|
|
1517
|
-
let load = if text.len() >= TMUX_STDIN_BUFFER_THRESHOLD {
|
|
1518
|
-
vec![
|
|
1519
|
-
"tmux".to_string(),
|
|
1520
|
-
"load-buffer".to_string(),
|
|
1521
|
-
"-b".to_string(),
|
|
1522
|
-
buffer_name.to_string(),
|
|
1523
|
-
"-".to_string(),
|
|
1524
|
-
]
|
|
1525
|
-
} else {
|
|
1526
|
-
vec![
|
|
1527
|
-
"tmux".to_string(),
|
|
1528
|
-
"set-buffer".to_string(),
|
|
1529
|
-
"-b".to_string(),
|
|
1530
|
-
buffer_name.to_string(),
|
|
1531
|
-
text.to_string(),
|
|
1532
|
-
]
|
|
1533
|
-
};
|
|
1534
|
-
vec![
|
|
1535
|
-
load,
|
|
1536
|
-
paste,
|
|
1537
|
-
vec![
|
|
1538
|
-
"tmux".to_string(),
|
|
1539
|
-
"delete-buffer".to_string(),
|
|
1540
|
-
"-b".to_string(),
|
|
1541
|
-
buffer_name.to_string(),
|
|
1542
|
-
],
|
|
1543
|
-
]
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
/// 空文本 inject:纯 `send-keys -t <target> <submit_key>`,**禁** buffer 路径
|
|
1547
|
-
/// (tmux 拒空 buffer 会卡 trust prompt;tmux_io.py:42)。
|
|
1548
|
-
/// `Key::Enter` 保持逻辑 `Enter`,不会在 extended keys 下误发 Ctrl-M。
|
|
1549
|
-
/// ---
|
|
1550
|
-
/// purpose: 空载荷注入(唤醒/ping)的 argv:只发提交键,不碰 buffer
|
|
1551
|
-
/// params:
|
|
1552
|
-
/// pane: 目标 pane 标识
|
|
1553
|
-
/// submit: 提交键;转发给 tmux_send_submit_argv 取拼写
|
|
1554
|
-
/// returns: 与 tmux_send_submit_argv 完全相同的单条 argv
|
|
1555
|
-
/// boundary: 禁走 buffer 路径(tmux 拒空 buffer 会卡 trust prompt);纯构造,不执行、不做任何提交验证
|
|
1556
|
-
/// ---
|
|
1557
|
-
pub fn tmux_empty_inject_argv(pane: &PaneId, submit: Key) -> Vec<String> {
|
|
1558
|
-
tmux_send_submit_argv(pane, submit)
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
/// capture 出口规范化(§4b,design line 399-400):逐行 rstrip 行尾空白 +
|
|
1562
|
-
/// `\xa0`(NBSP)→`\x20`,保留 box-drawing。recognizer 不为后端开分支。
|
|
1563
|
-
/// golden:`"line one \nbusy\xa0marker \n \n"` → `"line one\nbusy marker\n\n"`。
|
|
1564
|
-
/// ---
|
|
1565
|
-
/// purpose: capture 出口的统一规范化,让识别层不必为后端开分支
|
|
1566
|
-
/// params:
|
|
1567
|
-
/// raw: 后端抓回的原始屏幕文本
|
|
1568
|
-
/// returns: 逐行去掉行尾空白、NBSP 归一为普通空格的文本;换行位置与行数不变
|
|
1569
|
-
/// boundary: 只做这两件事——不剥 ANSI 转义、不裁剪行数、不脱敏、不改 box-drawing 字符
|
|
1570
|
-
/// ---
|
|
1571
|
-
pub fn normalize_capture(raw: &str) -> String {
|
|
1572
|
-
raw.replace('\u{a0}', " ")
|
|
1573
|
-
.split_inclusive('\n')
|
|
1574
|
-
.map(|line| {
|
|
1575
|
-
if let Some(stripped) = line.strip_suffix('\n') {
|
|
1576
|
-
let mut s = stripped.trim_end().to_string();
|
|
1577
|
-
s.push('\n');
|
|
1578
|
-
s
|
|
1579
|
-
} else {
|
|
1580
|
-
line.trim_end().to_string()
|
|
1581
|
-
}
|
|
1582
|
-
})
|
|
1583
|
-
.collect()
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
/// `SubmitVerification` → wire 字符串(tmux_io.py:64/215-221, tmux_prompt.py:304/313)。
|
|
1587
|
-
/// 模板:`{key}_sent_after_visible_token`(key 由 variant 携带,经 tmux_key_name 取名)。
|
|
1588
|
-
/// 真相源:`enter_sent_without_placeholder_check` /
|
|
1589
|
-
/// `pasted_content_prompt_absent_after_submit` / `send_keys_failed` /
|
|
1590
|
-
/// `Enter_sent_after_visible_token`(submit_key 字面)。
|
|
1591
|
-
/// ---
|
|
1592
|
-
/// purpose: SubmitVerification 判定值落 JSON / 事件的唯一拼写来源
|
|
1593
|
-
/// params:
|
|
1594
|
-
/// v: 后端给出的提交验证判定
|
|
1595
|
-
/// returns: 稳定 wire 字符串;KeySentAfterVisibleToken 由 tmux_key_name 拼成 <键名>_sent_after_visible_token
|
|
1596
|
-
/// boundary:
|
|
1597
|
-
/// - 只翻译不判定:不把 SubmitConsumptionUnverified 折成成功值,也不合并任何两个变体
|
|
1598
|
-
/// - 名与语义已知脱节:enter_sent_without_placeholder_check 实际含义是「消费已确认或跳过消费轮询」,读日志时不可按字面理解成未验证
|
|
1599
|
-
/// - 是否算 delivered 不在这里裁定,由 delivery 层的判定表决定
|
|
1600
|
-
/// ---
|
|
1601
|
-
pub fn submit_verification_wire(v: SubmitVerification) -> String {
|
|
1602
|
-
match v {
|
|
1603
|
-
SubmitVerification::EnterSentWithoutPlaceholderCheck => {
|
|
1604
|
-
"enter_sent_without_placeholder_check".to_string()
|
|
1605
|
-
}
|
|
1606
|
-
SubmitVerification::PastedContentPromptAbsentAfterSubmit => {
|
|
1607
|
-
"pasted_content_prompt_absent_after_submit".to_string()
|
|
1608
|
-
}
|
|
1609
|
-
SubmitVerification::PastedContentPromptStillPresentAfterSubmit => {
|
|
1610
|
-
"pasted_content_prompt_still_present_after_submit".to_string()
|
|
1611
|
-
}
|
|
1612
|
-
SubmitVerification::KeySentAfterVisibleToken { key } => {
|
|
1613
|
-
format!("{}_sent_after_visible_token", tmux_key_name(key))
|
|
1614
|
-
}
|
|
1615
|
-
SubmitVerification::SendKeysFailed => "send_keys_failed".to_string(),
|
|
1616
|
-
SubmitVerification::SubmitConsumptionUnverified => {
|
|
1617
|
-
"submit_consumption_unverified".to_string()
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
/// ---
|
|
1623
|
-
/// purpose: TurnVerification 的 send JSON / persist 用词
|
|
1624
|
-
/// params:
|
|
1625
|
-
/// v: 回合观测判定
|
|
1626
|
-
/// returns: 与 serde snake_case 一致的固定拼写
|
|
1627
|
-
/// contract: 与 serde snake_case 一致;未知必须是 not_yet_observed,不得写成 verified
|
|
1628
|
-
/// boundary: 不是投递闸门(Gap42);只翻译不判定
|
|
1629
|
-
/// ---
|
|
1630
|
-
pub fn turn_verification_wire(v: TurnVerification) -> &'static str {
|
|
1631
|
-
match v {
|
|
1632
|
-
TurnVerification::LeaderNewTurnBoundaryVerified => "leader_new_turn_boundary_verified",
|
|
1633
|
-
TurnVerification::LeaderNewTurnBoundaryMissing => "leader_new_turn_boundary_missing",
|
|
1634
|
-
TurnVerification::NotYetObserved => "not_yet_observed",
|
|
1635
|
-
TurnVerification::NotRequired => "not_required",
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
1640
|
-
// RED contracts — step 9 transport(ROUND-0).
|
|
1641
|
-
//
|
|
1642
|
-
// 真相源:Python team-agent-public @ v0.2.11(`terminal.py` / `messaging/tmux_io.py`
|
|
1643
|
-
// / `runtime.py`)golden-locked via /tmp/transport_golden.py;rust-native parity
|
|
1644
|
-
// 来自 `docs/phase0/transport-backend-design.md` §1/§3 + `contracts-rust-native.yaml`。
|
|
1645
|
-
//
|
|
1646
|
-
// 这些测试通过一个 **每个方法都 `unimplemented!()`** 的 `StubBackend` 驱动 `Transport`
|
|
1647
|
-
// trait(skeleton 无任何 impl),因此跑起来即 panic == 真 RED;porter 填实现后转 GREEN。
|
|
1648
|
-
// 另有一批 **纯 typed-payload / serde 字节锁** 断言(命令面字符串、verification 阶梯、
|
|
1649
|
-
// 寻址稳定性)—— 它们锁住契约形状,porter 改坏类型/serde rename 立即失败。
|
|
1650
|
-
//
|
|
1651
|
-
// [真机] 标记的契约(WezTerm `cli list` / B1 等)`#[ignore]` —— 无法在此完整断言,
|
|
1652
|
-
// 仅锁形状,实现期真机校验。
|
|
1653
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
1654
|
-
#[cfg(test)]
|
|
1655
|
-
mod tests;
|