@team-agent/installer 0.5.128 → 0.6.0
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,336 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! 私有内部 helpers (status wire / envelope 校验 / scheduled kind 解析 / activity 信号
|
|
3
|
-
//! 解析 / id 生成 / MessageStatusShadow 占位)。跨子模块/测试可见者升 `pub(crate)`。
|
|
4
|
-
|
|
5
|
-
use std::sync::atomic::{AtomicU64, Ordering};
|
|
6
|
-
|
|
7
|
-
use rusqlite::{params, OptionalExtension};
|
|
8
|
-
|
|
9
|
-
use crate::message_store::MessageStore;
|
|
10
|
-
|
|
11
|
-
use super::{
|
|
12
|
-
ActivityStatus, AgentActivity, DeliveryOutcome, DeliveryRefusal, DeliveryStatus,
|
|
13
|
-
MessagingError, ScheduledKind,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/// **PLACEHOLDER** — step 7 `messages.status` 行态 enum (`message_store` lane 的 `MessageStatus`)。
|
|
17
|
-
/// step 7 已落地 core 但尚未导出该 enum (当前用裸 `&str`);本 lane 不猜其精确 variant 集,
|
|
18
|
-
/// 用本地最小占位让 [`DeliveryOutcome::message_status`] 编得过。leader 集成时换成 step 7 的
|
|
19
|
-
/// 权威 `MessageStatus`(`accepted`/`target_resolved`/`injected`/`visible`/`submitted`/
|
|
20
|
-
/// `submitted_unverified`/`delivered`/`acknowledged`/`failed`/`queued_*` …)。
|
|
21
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
22
|
-
pub struct MessageStatusShadow(pub String);
|
|
23
|
-
|
|
24
|
-
static RESULT_COUNTER: AtomicU64 = AtomicU64::new(0);
|
|
25
|
-
|
|
26
|
-
pub(crate) fn status_wire(status: DeliveryStatus) -> &'static str {
|
|
27
|
-
match status {
|
|
28
|
-
DeliveryStatus::Delivered => "delivered",
|
|
29
|
-
DeliveryStatus::StoredOnly => "stored_only",
|
|
30
|
-
DeliveryStatus::Failed => "failed",
|
|
31
|
-
DeliveryStatus::Queued => "queued",
|
|
32
|
-
DeliveryStatus::Blocked => "blocked",
|
|
33
|
-
DeliveryStatus::Refused => "refused",
|
|
34
|
-
DeliveryStatus::Degraded => "degraded",
|
|
35
|
-
DeliveryStatus::RetryScheduled => "retry_scheduled",
|
|
36
|
-
DeliveryStatus::TrustAutoAnswerExhausted => "trust_auto_answer_exhausted",
|
|
37
|
-
DeliveryStatus::AlreadyDelivered => "already_delivered",
|
|
38
|
-
DeliveryStatus::FallbackLog => "fallback_log",
|
|
39
|
-
DeliveryStatus::BroadcastDelivered => "broadcast_delivered",
|
|
40
|
-
DeliveryStatus::BroadcastPartial => "broadcast_partial",
|
|
41
|
-
DeliveryStatus::FanoutDelivered => "fanout_delivered",
|
|
42
|
-
DeliveryStatus::FanoutPartial => "fanout_partial",
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
pub(crate) fn message_exists(
|
|
47
|
-
store: &MessageStore,
|
|
48
|
-
message_id: &str,
|
|
49
|
-
) -> Result<bool, MessagingError> {
|
|
50
|
-
let conn = crate::db::schema::open_db(store.db_path())?;
|
|
51
|
-
let found: Option<String> = conn
|
|
52
|
-
.query_row(
|
|
53
|
-
"select message_id from messages where message_id = ?1",
|
|
54
|
-
params![message_id],
|
|
55
|
-
|row| row.get(0),
|
|
56
|
-
)
|
|
57
|
-
.optional()?;
|
|
58
|
-
Ok(found.is_some())
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
pub(crate) fn next_result_id() -> String {
|
|
62
|
-
let n = RESULT_COUNTER.fetch_add(1, Ordering::Relaxed);
|
|
63
|
-
let nanos = std::time::SystemTime::now()
|
|
64
|
-
.duration_since(std::time::UNIX_EPOCH)
|
|
65
|
-
.map_or(0, |d| d.as_nanos());
|
|
66
|
-
format!("res_{:012x}", (nanos ^ u128::from(n)) & 0xFFFF_FFFF_FFFF)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
pub(crate) fn next_run_id() -> String {
|
|
70
|
-
let id = next_result_id();
|
|
71
|
-
id.chars().filter(|c| *c != '_').take(12).collect()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
pub(crate) fn required_str<'a>(
|
|
75
|
-
value: &'a serde_json::Value,
|
|
76
|
-
key: &str,
|
|
77
|
-
) -> Result<&'a str, MessagingError> {
|
|
78
|
-
value
|
|
79
|
-
.get(key)
|
|
80
|
-
.and_then(|v| v.as_str())
|
|
81
|
-
.filter(|s| !s.is_empty())
|
|
82
|
-
.ok_or_else(|| MessagingError::Validation(format!("missing required field: {key}")))
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
pub(crate) fn validate_result_envelope(envelope: &serde_json::Value) -> Result<(), MessagingError> {
|
|
86
|
-
let schema = required_str(envelope, "schema_version")?;
|
|
87
|
-
if schema != "result_envelope_v1" {
|
|
88
|
-
return Err(MessagingError::Validation(format!(
|
|
89
|
-
"unsupported schema_version: {schema}"
|
|
90
|
-
)));
|
|
91
|
-
}
|
|
92
|
-
for key in ["task_id", "agent_id", "status", "summary"] {
|
|
93
|
-
let _ = required_str(envelope, key)?;
|
|
94
|
-
}
|
|
95
|
-
for key in ["changes", "tests", "risks", "artifacts", "next_actions"] {
|
|
96
|
-
if !envelope.get(key).is_some_and(serde_json::Value::is_array) {
|
|
97
|
-
return Err(MessagingError::Validation(format!(
|
|
98
|
-
"missing required array field: {key}"
|
|
99
|
-
)));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
Ok(())
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
pub(crate) fn parse_scheduled_kind(kind: &str) -> Result<ScheduledKind, MessagingError> {
|
|
106
|
-
match kind {
|
|
107
|
-
"send" => Ok(ScheduledKind::Send),
|
|
108
|
-
"reminder" => Ok(ScheduledKind::Reminder),
|
|
109
|
-
"health_ping" => Ok(ScheduledKind::HealthPing),
|
|
110
|
-
"trust_retry" => Ok(ScheduledKind::TrustRetry),
|
|
111
|
-
"enter_rescue" => Ok(ScheduledKind::EnterRescue),
|
|
112
|
-
other => Err(MessagingError::Validation(format!(
|
|
113
|
-
"unknown scheduled event kind: {other}"
|
|
114
|
-
))),
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
pub(crate) fn working_seconds(scrollback: &str) -> Option<u64> {
|
|
119
|
-
// E47 ROOT-FIX#1 (0.3.24 P0, idle/busy 假阳): the pre-fix `lower.find(...)`
|
|
120
|
-
// scanned the WHOLE scrollback (Tail(40) lines) and matched historical
|
|
121
|
-
// working markers — e.g. an old `• Working (514s · esc to interrupt)`
|
|
122
|
-
// still in the 40-line window after the worker idled. That stale token
|
|
123
|
-
// flipped a truly-idle agent to Stuck whenever the historical seconds
|
|
124
|
-
// exceeded 300. Real fix: only consult the LIVE composer / status line
|
|
125
|
-
// (last non-empty line). If the current bottom line is something like
|
|
126
|
-
// `❯ Run /review`, `Worked for 8m 34s`, or an empty composer prompt,
|
|
127
|
-
// there is no LIVE working indicator and we return None — handing off
|
|
128
|
-
// to the structural latest_prompt_signal / IRON LAW Uncertain path.
|
|
129
|
-
let last_non_empty = scrollback
|
|
130
|
-
.lines()
|
|
131
|
-
.rev()
|
|
132
|
-
.find(|line| !line.trim().is_empty())?;
|
|
133
|
-
let lower = last_non_empty.to_ascii_lowercase();
|
|
134
|
-
let start = lower.find("working (")?;
|
|
135
|
-
let rest = last_non_empty.get(start + "Working (".len()..)?;
|
|
136
|
-
let seconds = rest.split_once('s')?.0;
|
|
137
|
-
seconds.parse::<u64>().ok()
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
pub(crate) fn non_provider_command(command: &str) -> Option<&str> {
|
|
141
|
-
// Activity command grammar, not provider identity parsing.
|
|
142
|
-
let base = command.rsplit('/').next().unwrap_or(command);
|
|
143
|
-
let normalized = base.to_ascii_lowercase();
|
|
144
|
-
match normalized.as_str() {
|
|
145
|
-
"" | "codex" | "claude" | "copilot" | "gemini" | "openai" | "team-agent" => None,
|
|
146
|
-
_ => Some(base),
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
pub(crate) fn latest_prompt_signal(scrollback: &str) -> Option<AgentActivity> {
|
|
151
|
-
// E47 ROOT-FIX#2 (0.3.24 P0, idle/busy 假阳): limit the scan to the
|
|
152
|
-
// BOTTOM ACTIVE REGION (last 1-5 non-empty lines = composer / status
|
|
153
|
-
// line). The pre-fix `rfind` across the whole Tail(40) buffer let a
|
|
154
|
-
// historical spinner/`Working` token out-position the live `❯`/`›`
|
|
155
|
-
// composer (the rfind-recency family bug — same shape as the #320
|
|
156
|
-
// codex prompt residue). When the composer line is `❯ Run /review`
|
|
157
|
-
// (idle), a scrollback `Working (514s)` 20 lines up should NOT win.
|
|
158
|
-
//
|
|
159
|
-
// IRON LAW (activity.rs:3 / bug-071/077/085): no-signal in the bottom
|
|
160
|
-
// region must be Uncertain (caller treats None here as "no decisive
|
|
161
|
-
// signal" and surfaces Uncertain), NEVER silently flipped to Idle.
|
|
162
|
-
let active_region: Vec<&str> = scrollback
|
|
163
|
-
.lines()
|
|
164
|
-
.rev()
|
|
165
|
-
.filter(|line| !line.trim().is_empty())
|
|
166
|
-
.take(5)
|
|
167
|
-
.collect();
|
|
168
|
-
if active_region.is_empty() {
|
|
169
|
-
return None;
|
|
170
|
-
}
|
|
171
|
-
let mut has_idle_prompt = false;
|
|
172
|
-
let mut has_live_working_indicator = false;
|
|
173
|
-
let mut has_fake_ready_structural = false;
|
|
174
|
-
for line in &active_region {
|
|
175
|
-
let lower = line.to_ascii_lowercase();
|
|
176
|
-
if line.contains('❯') || line.contains('›') {
|
|
177
|
-
has_idle_prompt = true;
|
|
178
|
-
}
|
|
179
|
-
// 0.5.34 (`0532-r1-real-fail-triage.md` §6/§7 + te msg_94957b9c55b0):
|
|
180
|
-
// fake provider owns explicit READY/WORKING markers (fake_worker.rs:47/59).
|
|
181
|
-
// - READY is a STRUCTURAL non-busy signal that suppresses the
|
|
182
|
-
// `recent_provider_output` false-busy on first post-restart capture,
|
|
183
|
-
// but must NOT resolve to Idle (unknown-never-idle discipline —
|
|
184
|
-
// post-restart READY is the fake worker's boot heartbeat, not proof
|
|
185
|
-
// of an idle prompt). Route it through Uncertain with a distinct
|
|
186
|
-
// rationale so callers can trace the source.
|
|
187
|
-
// - WORKING is a structural busy signal (parity with the codex
|
|
188
|
-
// `• Working (` composer indicator).
|
|
189
|
-
// Scope: literal `TEAM_AGENT_FAKE_*` tokens only — do NOT infer that
|
|
190
|
-
// arbitrary "ready" prose from real providers means either idle or
|
|
191
|
-
// non-busy.
|
|
192
|
-
if line.contains("TEAM_AGENT_FAKE_READY") {
|
|
193
|
-
has_fake_ready_structural = true;
|
|
194
|
-
}
|
|
195
|
-
if line.contains("TEAM_AGENT_FAKE_WORKING") {
|
|
196
|
-
has_live_working_indicator = true;
|
|
197
|
-
}
|
|
198
|
-
// codex live spinner shapes (provider/adapter.rs:875-876 markers):
|
|
199
|
-
// braille spinner, `• Working (`, `Thinking`; claude `✶`/`✢`/`✻`
|
|
200
|
-
// and Claude Code tool-progress verbs. We look for STRUCTURAL
|
|
201
|
-
// composer/status signals in the active region only.
|
|
202
|
-
if [
|
|
203
|
-
"working (",
|
|
204
|
-
"thinking",
|
|
205
|
-
"⠋",
|
|
206
|
-
"⠙",
|
|
207
|
-
"⠹",
|
|
208
|
-
"⠸",
|
|
209
|
-
"⠼",
|
|
210
|
-
"⠴",
|
|
211
|
-
"⠦",
|
|
212
|
-
"⠧",
|
|
213
|
-
"⠇",
|
|
214
|
-
"⠏",
|
|
215
|
-
"✶",
|
|
216
|
-
"✢",
|
|
217
|
-
"✻",
|
|
218
|
-
"analyzing",
|
|
219
|
-
"reading",
|
|
220
|
-
"writing",
|
|
221
|
-
"searching",
|
|
222
|
-
"running",
|
|
223
|
-
"editing",
|
|
224
|
-
]
|
|
225
|
-
.iter()
|
|
226
|
-
.any(|needle| lower.contains(needle))
|
|
227
|
-
{
|
|
228
|
-
has_live_working_indicator = true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
// Working indicator IN the active region wins over a stale `❯`/`›`
|
|
232
|
-
// (composer may show a prompt char before the live spinner refreshes).
|
|
233
|
-
if has_live_working_indicator {
|
|
234
|
-
return Some(AgentActivity {
|
|
235
|
-
status: ActivityStatus::Working,
|
|
236
|
-
confidence: 0.9,
|
|
237
|
-
rationale: "working_indicator".to_string(),
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
if has_idle_prompt {
|
|
241
|
-
return Some(idle_activity());
|
|
242
|
-
}
|
|
243
|
-
// 0.5.34: fake READY is structural but not decisive. Return Uncertain
|
|
244
|
-
// so the classifier short-circuits (avoiding recent_provider_output
|
|
245
|
-
// false-busy) without asserting idle. `latest_pane_signal_is_structural`
|
|
246
|
-
// in coordinator/tick.rs treats `Some(_)` as structural.
|
|
247
|
-
if has_fake_ready_structural {
|
|
248
|
-
return Some(AgentActivity {
|
|
249
|
-
status: ActivityStatus::Uncertain,
|
|
250
|
-
confidence: 0.6,
|
|
251
|
-
rationale: "fake_ready_structural".to_string(),
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
// No structural signal in the bottom region → caller (activity.rs:184)
|
|
255
|
-
// gets None and treats as no-decisive-signal → Uncertain (IRON LAW).
|
|
256
|
-
None
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
fn idle_activity() -> AgentActivity {
|
|
260
|
-
AgentActivity {
|
|
261
|
-
status: ActivityStatus::Idle,
|
|
262
|
-
confidence: 0.9,
|
|
263
|
-
rationale: "idle_prompt".to_string(),
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/// `_fail_leader_delivery` (`leader.py:394`) — **diagnostic ONLY** (#230 I-4 退化):
|
|
268
|
-
/// 历史上返回 `ok=True/status=FallbackLog/channel="fallback_inbox"` 被上游误读为
|
|
269
|
-
/// "已交付的 fallback log"。现新 leader-delivery primitive(`leader_receiver::send_to_leader_receiver`)
|
|
270
|
-
/// 不再调本函数。本函数保留只供老代码路径(scheduler / 兼容旧测试)使用,且其
|
|
271
|
-
/// outcome **不被视为 success**(I-3 反向断言要求 `leader_receiver.rs` 源文件不得含
|
|
272
|
-
/// `DeliveryStatus::FallbackLog` 或 `fallback_inbox` 字面量,所以本函数从 `leader_receiver.rs`
|
|
273
|
-
/// 搬到本 helpers 模块,字面量在此被允许)。
|
|
274
|
-
pub(crate) fn fail_leader_delivery(
|
|
275
|
-
workspace: &std::path::Path,
|
|
276
|
-
payload: &serde_json::Value,
|
|
277
|
-
reason: DeliveryRefusal,
|
|
278
|
-
error: Option<&str>,
|
|
279
|
-
) -> Result<DeliveryOutcome, MessagingError> {
|
|
280
|
-
let store = MessageStore::open(workspace)?;
|
|
281
|
-
let Some(message_id) = payload
|
|
282
|
-
.get("message_id")
|
|
283
|
-
.and_then(serde_json::Value::as_str)
|
|
284
|
-
.map(ToOwned::to_owned)
|
|
285
|
-
else {
|
|
286
|
-
crate::event_log::EventLog::new(workspace).write(
|
|
287
|
-
"leader_receiver.delivery_failed_without_message",
|
|
288
|
-
serde_json::json!({"reason": serde_json::to_value(reason).ok(), "error": error}),
|
|
289
|
-
)?;
|
|
290
|
-
return Ok(DeliveryOutcome {
|
|
291
|
-
ok: false,
|
|
292
|
-
status: DeliveryStatus::FallbackLog,
|
|
293
|
-
message_status: MessageStatusShadow("failed".to_string()),
|
|
294
|
-
message_id: None,
|
|
295
|
-
verification: None,
|
|
296
|
-
stage: None,
|
|
297
|
-
reason: Some(reason),
|
|
298
|
-
channel: Some("fallback_log".to_string()),
|
|
299
|
-
ack_forced_off: false,
|
|
300
|
-
turn_verification: None,
|
|
301
|
-
});
|
|
302
|
-
};
|
|
303
|
-
store.mark(&message_id, "failed", error)?;
|
|
304
|
-
crate::event_log::EventLog::new(workspace).write(
|
|
305
|
-
"leader_receiver.delivery_failed",
|
|
306
|
-
serde_json::json!({"message_id": message_id, "reason": serde_json::to_value(reason).ok(), "error": error}),
|
|
307
|
-
)?;
|
|
308
|
-
Ok(DeliveryOutcome {
|
|
309
|
-
ok: true,
|
|
310
|
-
status: DeliveryStatus::FallbackLog,
|
|
311
|
-
message_status: MessageStatusShadow("failed".to_string()),
|
|
312
|
-
message_id: Some(message_id),
|
|
313
|
-
verification: None,
|
|
314
|
-
stage: None,
|
|
315
|
-
reason: Some(reason),
|
|
316
|
-
channel: Some("fallback_inbox".to_string()),
|
|
317
|
-
ack_forced_off: false,
|
|
318
|
-
turn_verification: None,
|
|
319
|
-
})
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
pub(crate) fn recent_rfc3339(ts: &str, max_age_seconds: i64) -> bool {
|
|
323
|
-
let Ok(parsed) = chrono::DateTime::parse_from_rfc3339(ts) else {
|
|
324
|
-
return false;
|
|
325
|
-
};
|
|
326
|
-
let age = chrono::Utc::now().signed_duration_since(parsed.with_timezone(&chrono::Utc));
|
|
327
|
-
age.num_seconds() <= max_age_seconds
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
pub(crate) fn stale_rfc3339(ts: &str, min_age_seconds: i64) -> bool {
|
|
331
|
-
let Ok(parsed) = chrono::DateTime::parse_from_rfc3339(ts) else {
|
|
332
|
-
return false;
|
|
333
|
-
};
|
|
334
|
-
let age = chrono::Utc::now().signed_duration_since(parsed.with_timezone(&chrono::Utc));
|
|
335
|
-
age.num_seconds() >= min_age_seconds
|
|
336
|
-
}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
use std::path::Path;
|
|
3
|
-
|
|
4
|
-
use serde_json::Value;
|
|
5
|
-
|
|
6
|
-
use crate::codex_app_server::AppServerBinding;
|
|
7
|
-
use crate::model::pane_authority_refusal::PaneWorkspaceMismatchFacts;
|
|
8
|
-
use crate::transport::{PaneInfo, Transport};
|
|
9
|
-
|
|
10
|
-
/// Scope authority written by a fresh quick-start caller binding. It is distinct
|
|
11
|
-
/// from an operator-initiated explicit claim, but uses the same pane-instance
|
|
12
|
-
/// nonce and exact workspace checks at delivery.
|
|
13
|
-
pub(crate) const FRESH_CALLER_SCOPE_AUTHORITY: &str = "fresh_caller";
|
|
14
|
-
|
|
15
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
16
|
-
pub enum LiveLeaderChannel {
|
|
17
|
-
DirectTmux(DirectTmuxLeaderChannel),
|
|
18
|
-
CodexAppServer(AppServerBinding),
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
22
|
-
pub struct DirectTmuxLeaderChannel {
|
|
23
|
-
pub pane_id: String,
|
|
24
|
-
pub tmux_socket: Option<String>,
|
|
25
|
-
pub observed: PaneInfo,
|
|
26
|
-
pub metadata_drift: Vec<&'static str>,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
30
|
-
pub enum LeaderChannelResolution {
|
|
31
|
-
Live(LiveLeaderChannel),
|
|
32
|
-
Unbound(LeaderChannelUnbound),
|
|
33
|
-
ProbeFailed(String),
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
37
|
-
pub enum LeaderChannelUnbound {
|
|
38
|
-
ReceiverNotAttached,
|
|
39
|
-
TransportConflict,
|
|
40
|
-
MissingPaneId,
|
|
41
|
-
NonCanonicalTmuxSocket,
|
|
42
|
-
EndpointMismatch,
|
|
43
|
-
PaneNotLive,
|
|
44
|
-
PaneWorkspaceMismatch(PaneWorkspaceMismatchFacts),
|
|
45
|
-
AppServerBindingInvalid,
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
impl LeaderChannelUnbound {
|
|
49
|
-
pub const fn reason_code(&self) -> &'static str {
|
|
50
|
-
match self {
|
|
51
|
-
Self::ReceiverNotAttached => "ReceiverNotAttached",
|
|
52
|
-
Self::TransportConflict => "TransportConflict",
|
|
53
|
-
Self::MissingPaneId => "MissingPaneId",
|
|
54
|
-
Self::NonCanonicalTmuxSocket => "NonCanonicalTmuxSocket",
|
|
55
|
-
Self::EndpointMismatch => "EndpointMismatch",
|
|
56
|
-
Self::PaneNotLive => "PaneNotLive",
|
|
57
|
-
Self::PaneWorkspaceMismatch(_) => "PaneWorkspaceMismatch",
|
|
58
|
-
Self::AppServerBindingInvalid => "AppServerBindingInvalid",
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/// Resolve the canonical receiver's live physical channel without mutating
|
|
64
|
-
/// ownership. For direct tmux, `(absolute socket, pane id)` plus an available
|
|
65
|
-
/// pane cwd inside the target workspace is the authority. Session/window/tty/
|
|
66
|
-
/// fingerprint are observations and can only report drift.
|
|
67
|
-
pub fn resolve_live_leader_channel(
|
|
68
|
-
workspace: &Path,
|
|
69
|
-
receiver: &Value,
|
|
70
|
-
transport: &dyn Transport,
|
|
71
|
-
) -> LeaderChannelResolution {
|
|
72
|
-
if receiver
|
|
73
|
-
.get("status")
|
|
74
|
-
.and_then(Value::as_str)
|
|
75
|
-
.is_some_and(|status| status != "attached")
|
|
76
|
-
{
|
|
77
|
-
return LeaderChannelResolution::Unbound(LeaderChannelUnbound::ReceiverNotAttached);
|
|
78
|
-
}
|
|
79
|
-
if receiver_transport_conflicts(receiver) {
|
|
80
|
-
return LeaderChannelResolution::Unbound(LeaderChannelUnbound::TransportConflict);
|
|
81
|
-
}
|
|
82
|
-
if crate::codex_app_server::receiver_is_app_server(receiver) {
|
|
83
|
-
return match crate::codex_app_server::binding_from_receiver(receiver) {
|
|
84
|
-
Ok(binding) => {
|
|
85
|
-
LeaderChannelResolution::Live(LiveLeaderChannel::CodexAppServer(binding))
|
|
86
|
-
}
|
|
87
|
-
Err(_) => {
|
|
88
|
-
LeaderChannelResolution::Unbound(LeaderChannelUnbound::AppServerBindingInvalid)
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
let Some(pane_id) = receiver
|
|
94
|
-
.get("pane_id")
|
|
95
|
-
.and_then(Value::as_str)
|
|
96
|
-
.filter(|pane| !pane.is_empty())
|
|
97
|
-
else {
|
|
98
|
-
return LeaderChannelResolution::Unbound(LeaderChannelUnbound::MissingPaneId);
|
|
99
|
-
};
|
|
100
|
-
let tmux_socket = receiver
|
|
101
|
-
.get("tmux_socket")
|
|
102
|
-
.and_then(Value::as_str)
|
|
103
|
-
.filter(|socket| !socket.is_empty());
|
|
104
|
-
let transport_endpoint = transport.tmux_endpoint();
|
|
105
|
-
if tmux_socket.is_some_and(|socket| !std::path::Path::new(socket).is_absolute()) {
|
|
106
|
-
return LeaderChannelResolution::Unbound(LeaderChannelUnbound::NonCanonicalTmuxSocket);
|
|
107
|
-
}
|
|
108
|
-
if let Some(expected) = tmux_socket {
|
|
109
|
-
if transport_endpoint.as_deref() != Some(expected) {
|
|
110
|
-
return LeaderChannelResolution::Unbound(LeaderChannelUnbound::EndpointMismatch);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
let targets = match transport.list_targets() {
|
|
114
|
-
Ok(targets) => targets,
|
|
115
|
-
Err(error) => return LeaderChannelResolution::ProbeFailed(error.to_string()),
|
|
116
|
-
};
|
|
117
|
-
let Some(observed) = targets
|
|
118
|
-
.into_iter()
|
|
119
|
-
.find(|target| target.pane_id.as_str() == pane_id)
|
|
120
|
-
else {
|
|
121
|
-
return LeaderChannelResolution::Unbound(LeaderChannelUnbound::PaneNotLive);
|
|
122
|
-
};
|
|
123
|
-
if let Some(observed_pane_workspace) = observed.current_path.clone() {
|
|
124
|
-
if !path_is_in_workspace(&observed_pane_workspace, workspace)
|
|
125
|
-
&& !scoped_authority_matches(workspace, receiver, &observed)
|
|
126
|
-
{
|
|
127
|
-
return LeaderChannelResolution::Unbound(LeaderChannelUnbound::PaneWorkspaceMismatch(
|
|
128
|
-
PaneWorkspaceMismatchFacts {
|
|
129
|
-
requested_workspace: canonical_path(workspace),
|
|
130
|
-
observed_pane_id: observed.pane_id.as_str().to_string(),
|
|
131
|
-
observed_pane_workspace,
|
|
132
|
-
endpoint: transport_endpoint.unwrap_or_else(|| "default".to_string()),
|
|
133
|
-
},
|
|
134
|
-
));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
let metadata_drift = receiver_metadata_drift(receiver, &observed);
|
|
138
|
-
LeaderChannelResolution::Live(LiveLeaderChannel::DirectTmux(DirectTmuxLeaderChannel {
|
|
139
|
-
pane_id: pane_id.to_string(),
|
|
140
|
-
tmux_socket: tmux_socket.map(str::to_string),
|
|
141
|
-
observed,
|
|
142
|
-
metadata_drift,
|
|
143
|
-
}))
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
fn scoped_authority_matches(
|
|
147
|
-
workspace: &Path,
|
|
148
|
-
receiver: &Value,
|
|
149
|
-
observed: &PaneInfo,
|
|
150
|
-
) -> bool {
|
|
151
|
-
let authority = string_field(receiver, "scope_authority");
|
|
152
|
-
if !matches!(
|
|
153
|
-
authority,
|
|
154
|
-
Some("explicit_claim") | Some(FRESH_CALLER_SCOPE_AUTHORITY)
|
|
155
|
-
) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
let Some(authorized_workspace) = string_field(receiver, "authorized_team_workspace") else {
|
|
159
|
-
return false;
|
|
160
|
-
};
|
|
161
|
-
if canonical_path(Path::new(authorized_workspace)) != canonical_path(workspace) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
let Some(recorded_nonce) = string_field(receiver, "binding_nonce") else {
|
|
165
|
-
return false;
|
|
166
|
-
};
|
|
167
|
-
observed
|
|
168
|
-
.leader_env
|
|
169
|
-
.get(crate::tmux_backend::PANE_BINDING_NONCE_METADATA_KEY)
|
|
170
|
-
.filter(|nonce| !nonce.is_empty())
|
|
171
|
-
.is_some_and(|live_nonce| live_nonce == recorded_nonce)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
pub(crate) fn path_is_in_workspace(path: &Path, workspace: &Path) -> bool {
|
|
175
|
-
let path = canonical_path(path);
|
|
176
|
-
let workspace = canonical_path(workspace);
|
|
177
|
-
path == workspace || path.starts_with(workspace)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
fn canonical_path(path: &Path) -> std::path::PathBuf {
|
|
181
|
-
path.canonicalize().unwrap_or_else(|_| path.to_path_buf())
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
fn receiver_transport_conflicts(receiver: &Value) -> bool {
|
|
185
|
-
let mode = receiver.get("mode").and_then(Value::as_str);
|
|
186
|
-
let transport_kind = receiver.get("transport_kind").and_then(Value::as_str);
|
|
187
|
-
matches!((mode, transport_kind), (Some(mode), Some(kind)) if !mode.is_empty() && !kind.is_empty() && mode != kind)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
fn receiver_metadata_drift(receiver: &Value, observed: &PaneInfo) -> Vec<&'static str> {
|
|
191
|
-
let mut drift = Vec::new();
|
|
192
|
-
if string_field(receiver, "session_name")
|
|
193
|
-
.is_some_and(|expected| expected != observed.session.as_str())
|
|
194
|
-
{
|
|
195
|
-
drift.push("session_name");
|
|
196
|
-
}
|
|
197
|
-
if string_field(receiver, "window_name").is_some_and(|expected| {
|
|
198
|
-
observed.window_name.as_ref().map(|value| value.as_str()) != Some(expected)
|
|
199
|
-
}) {
|
|
200
|
-
drift.push("window_name");
|
|
201
|
-
}
|
|
202
|
-
if string_field(receiver, "pane_tty")
|
|
203
|
-
.is_some_and(|expected| observed.tty.as_deref() != Some(expected))
|
|
204
|
-
{
|
|
205
|
-
drift.push("pane_tty");
|
|
206
|
-
}
|
|
207
|
-
let observed_fingerprint = format!(
|
|
208
|
-
"{}|{}|{}|{}",
|
|
209
|
-
observed.session.as_str(),
|
|
210
|
-
observed
|
|
211
|
-
.window_index
|
|
212
|
-
.map_or_else(String::new, |value| value.to_string()),
|
|
213
|
-
observed
|
|
214
|
-
.pane_index
|
|
215
|
-
.map_or_else(String::new, |value| value.to_string()),
|
|
216
|
-
observed.tty.as_deref().unwrap_or("")
|
|
217
|
-
);
|
|
218
|
-
if string_field(receiver, "fingerprint")
|
|
219
|
-
.is_some_and(|expected| expected != observed_fingerprint)
|
|
220
|
-
{
|
|
221
|
-
drift.push("fingerprint");
|
|
222
|
-
}
|
|
223
|
-
drift
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
fn string_field<'a>(value: &'a Value, key: &str) -> Option<&'a str> {
|
|
227
|
-
value
|
|
228
|
-
.get(key)
|
|
229
|
-
.and_then(Value::as_str)
|
|
230
|
-
.filter(|value| !value.is_empty())
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
#[cfg(test)]
|
|
234
|
-
mod claim_rework_live_tests {
|
|
235
|
-
use super::*;
|
|
236
|
-
use crate::transport::test_support::OfflineTransport;
|
|
237
|
-
use crate::transport::{PaneId, PaneInfo, SessionName};
|
|
238
|
-
use serde_json::json;
|
|
239
|
-
use std::path::PathBuf;
|
|
240
|
-
|
|
241
|
-
#[test]
|
|
242
|
-
fn pending_receiver_is_not_a_live_channel() {
|
|
243
|
-
let workspace = PathBuf::from("/tmp/claim-rework-a3-pending");
|
|
244
|
-
let receiver = json!({
|
|
245
|
-
"mode": "direct_tmux",
|
|
246
|
-
"status": "pending",
|
|
247
|
-
"pane_id": "%1",
|
|
248
|
-
"tmux_socket": "/tmp/ta-offline.sock"
|
|
249
|
-
});
|
|
250
|
-
let transport = OfflineTransport::default().with_tmux_endpoint("/tmp/ta-offline.sock");
|
|
251
|
-
match resolve_live_leader_channel(&workspace, &receiver, &transport) {
|
|
252
|
-
LeaderChannelResolution::Unbound(LeaderChannelUnbound::ReceiverNotAttached) => {}
|
|
253
|
-
other => panic!("pending seed must not be live; got {other:?}"),
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
#[test]
|
|
258
|
-
fn dead_pane_with_matching_endpoint_is_pane_not_live() {
|
|
259
|
-
let workspace = PathBuf::from("/tmp/claim-rework-a3-dead");
|
|
260
|
-
let endpoint = "/tmp/ta-claim-rework-a3.sock";
|
|
261
|
-
let receiver = json!({
|
|
262
|
-
"mode": "direct_tmux",
|
|
263
|
-
"status": "attached",
|
|
264
|
-
"pane_id": "%missing",
|
|
265
|
-
"tmux_socket": endpoint
|
|
266
|
-
});
|
|
267
|
-
let transport = OfflineTransport::default()
|
|
268
|
-
.with_tmux_endpoint(endpoint)
|
|
269
|
-
.with_targets(vec![PaneInfo {
|
|
270
|
-
pane_id: PaneId::new("%other"),
|
|
271
|
-
session: SessionName::new("team"),
|
|
272
|
-
window_index: None,
|
|
273
|
-
window_name: None,
|
|
274
|
-
pane_index: None,
|
|
275
|
-
tty: None,
|
|
276
|
-
current_command: None,
|
|
277
|
-
current_path: None,
|
|
278
|
-
active: true,
|
|
279
|
-
pane_pid: None,
|
|
280
|
-
leader_env: Default::default(),
|
|
281
|
-
}]);
|
|
282
|
-
match resolve_live_leader_channel(&workspace, &receiver, &transport) {
|
|
283
|
-
LeaderChannelResolution::Unbound(LeaderChannelUnbound::PaneNotLive) => {}
|
|
284
|
-
other => panic!("matching endpoint + missing pane must be PaneNotLive; got {other:?}"),
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|