@team-agent/installer 0.5.127 → 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 +15 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +41 -26
- package/skills/team-agent/command-coverage.json +170 -184
- package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +66 -32
- 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 -1298
- package/crates/team-agent/src/cli/arguments.rs +0 -401
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1675
- package/crates/team-agent/src/cli/emit.rs +0 -2898
- 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 -1189
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
- package/crates/team-agent/src/cli/intent/tests.rs +0 -691
- 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 -6528
- package/crates/team-agent/src/cli/models.rs +0 -449
- 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/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 -192
- 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 -201
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -159
- 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 -2043
- 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 -372
- 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 -760
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
- 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 -1091
- 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 -842
- package/crates/team-agent/src/compiler.rs +0 -691
- 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 -1610
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -354
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
- 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 -589
- 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 -338
- 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 -461
- 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 -3112
- 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 -1585
- 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/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- 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 -883
- package/crates/team-agent/src/leader/start.rs +0 -4500
- 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 -267
- 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 -145
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
- 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 -152
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
- 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 -450
- 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 -534
- 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 -757
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
- 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 -223
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
- 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_profile_launch_red.rs +0 -135
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
- 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 -396
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
- 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 -71
- 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 -472
- 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 -3981
- 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 -152
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
- 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 -90
- 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 -996
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
- package/crates/team-agent/src/lifecycle/tests.rs +0 -102
- package/crates/team-agent/src/lifecycle/types.rs +0 -861
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
- 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 -546
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
- 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 -168
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
- 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 -1015
- 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 -3785
- 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 -354
- 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 -166
- 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/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 -217
- 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 -551
- 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 -3655
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
- 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 -471
- 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 -898
- 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 -28
- 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 -773
- 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 -722
- package/crates/team-agent/src/provider/session/capture.rs +0 -2631
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
- 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/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
- package/crates/team-agent/src/provider/session_scan.rs +0 -61
- 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 -354
- package/crates/team-agent/src/provider/tests/classify.rs +0 -201
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
- 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 -140
- 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 -406
- 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/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 -4254
- package/crates/team-agent/src/tmux_backend.rs +0 -4527
- 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,798 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: 三个只读运行时探测——上下文压缩、Codex session 漂移、leader 端 API 错误——全部值变才发事件
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: observe_runtime
|
|
6
|
-
//! what: 对本 tick 的每条捕获事实跑三个探测,收集结果并写变化驱动的事件
|
|
7
|
-
//! depends:
|
|
8
|
-
//! - super::runtime_observation
|
|
9
|
-
//! - super::types
|
|
10
|
-
//! - crate::event_log
|
|
11
|
-
//! - crate::state::projection
|
|
12
|
-
//! - crate::state::ownership
|
|
13
|
-
//! - crate::model::enums
|
|
14
|
-
//! boundary:
|
|
15
|
-
//! - 只分类不动作:不重启 agent、不清 session、不投递任何消息,只给 recommendation 文案
|
|
16
|
-
//! - 事件是 change-driven:计数/指纹不变的那一 tick 不重发,去重键存在 state 里
|
|
17
|
-
//! - 只读 scrollback 尾与已存 session id,不与 provider 进程交互
|
|
18
|
-
//! maturity: wired
|
|
19
|
-
//! ---
|
|
20
|
-
//!
|
|
21
|
-
use std::collections::BTreeMap;
|
|
22
|
-
use std::path::Path;
|
|
23
|
-
|
|
24
|
-
use serde_json::{json, Map, Value};
|
|
25
|
-
|
|
26
|
-
use crate::event_log::EventLog;
|
|
27
|
-
use crate::model::enums::Provider;
|
|
28
|
-
use crate::model::ids::AgentId;
|
|
29
|
-
|
|
30
|
-
use super::runtime_observation::{
|
|
31
|
-
CapturedRuntimeFact, LeaderCaptureFact, RuntimeObservationResults,
|
|
32
|
-
};
|
|
33
|
-
use super::types::{CompactionResult, LeaderApiError, SessionDriftResult};
|
|
34
|
-
|
|
35
|
-
const COMPACTION_RESET_THRESHOLD_DEFAULT: i64 = 3;
|
|
36
|
-
|
|
37
|
-
/// ---
|
|
38
|
-
/// purpose: 对本 tick 的全部捕获事实依次跑 compaction / session-drift / leader-api-error 三个探测
|
|
39
|
-
/// params:
|
|
40
|
-
/// workspace: workspace 根,用于打开事件日志
|
|
41
|
-
/// state: 可变运行时状态;探测在其中读写压缩计数、漂移标记与 api-error 指纹这些跨 tick 去重键
|
|
42
|
-
/// captures_by_agent: 本 tick 的 per-agent 捕获事实,按 agent_id 有序
|
|
43
|
-
/// leader_capture: leader 侧捕获;为 None 时 api-error 结果为空,且不清除既有指纹
|
|
44
|
-
/// returns: 捕获事实原样带回,附三组探测结果;未命中的探测对应空 Vec
|
|
45
|
-
/// ---
|
|
46
|
-
pub fn observe_runtime(
|
|
47
|
-
workspace: &Path,
|
|
48
|
-
state: &mut Value,
|
|
49
|
-
captures_by_agent: BTreeMap<AgentId, CapturedRuntimeFact>,
|
|
50
|
-
leader_capture: Option<LeaderCaptureFact>,
|
|
51
|
-
) -> RuntimeObservationResults {
|
|
52
|
-
let event_log = EventLog::new(workspace);
|
|
53
|
-
let mut compaction = Vec::new();
|
|
54
|
-
let mut session_drift = Vec::new();
|
|
55
|
-
for fact in captures_by_agent.values() {
|
|
56
|
-
if let Some(result) = detect_compaction(state, &event_log, fact) {
|
|
57
|
-
compaction.push(result);
|
|
58
|
-
}
|
|
59
|
-
if let Some(result) = detect_session_drift(state, &event_log, fact) {
|
|
60
|
-
session_drift.push(result);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
let api_errors = detect_leader_api_error(state, &event_log, leader_capture.as_ref());
|
|
64
|
-
RuntimeObservationResults {
|
|
65
|
-
captures_by_agent,
|
|
66
|
-
compaction,
|
|
67
|
-
session_drift,
|
|
68
|
-
api_errors,
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
fn detect_compaction(
|
|
73
|
-
state: &mut Value,
|
|
74
|
-
event_log: &EventLog,
|
|
75
|
-
fact: &CapturedRuntimeFact,
|
|
76
|
-
) -> Option<CompactionResult> {
|
|
77
|
-
let count = count_compaction_markers(&fact.scrollback_tail);
|
|
78
|
-
if count <= 0 {
|
|
79
|
-
return None;
|
|
80
|
-
}
|
|
81
|
-
let team = fact
|
|
82
|
-
.team_key
|
|
83
|
-
.as_ref()
|
|
84
|
-
.map(|team| team.as_str().to_string())
|
|
85
|
-
.unwrap_or_else(|| crate::state::projection::team_state_key(state));
|
|
86
|
-
let (previous, current) = update_compaction_count(state, &team, &fact.agent_id, count);
|
|
87
|
-
let provider = fact.provider;
|
|
88
|
-
// P4 (C-P4-1, N35 anti-nag): the event is CHANGE-driven — an unchanged compaction
|
|
89
|
-
// count must not re-emit every tick (live sample: 1037 identical events / 19.5min).
|
|
90
|
-
// A changed value still emits (value-keyed dedup, not blanket suppression).
|
|
91
|
-
if current != previous {
|
|
92
|
-
let _ = event_log.write(
|
|
93
|
-
"coordinator.compaction_observed",
|
|
94
|
-
json!({
|
|
95
|
-
"agent_id": fact.agent_id.as_str(),
|
|
96
|
-
"provider": provider.map(runtime_event_provider_name),
|
|
97
|
-
"team": team,
|
|
98
|
-
"compaction_count": current,
|
|
99
|
-
"stuck_loop": false,
|
|
100
|
-
}),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
let threshold = compaction_reset_threshold(state);
|
|
104
|
-
let recommendation = if provider == Some(Provider::Codex) && current >= threshold {
|
|
105
|
-
let message = format!(
|
|
106
|
-
"agent {} crossed Codex compaction threshold; run team-agent reset-agent {} --discard-session",
|
|
107
|
-
fact.agent_id.as_str(),
|
|
108
|
-
fact.agent_id.as_str()
|
|
109
|
-
);
|
|
110
|
-
let _ = event_log.write(
|
|
111
|
-
"compaction_threshold_crossed.recommend_reset",
|
|
112
|
-
json!({
|
|
113
|
-
"agent_id": fact.agent_id.as_str(),
|
|
114
|
-
"provider": provider.map(runtime_event_provider_name),
|
|
115
|
-
"team": team,
|
|
116
|
-
"compaction_count": current,
|
|
117
|
-
"threshold": threshold,
|
|
118
|
-
"leader_visible_message": message,
|
|
119
|
-
}),
|
|
120
|
-
);
|
|
121
|
-
Some(message)
|
|
122
|
-
} else {
|
|
123
|
-
None
|
|
124
|
-
};
|
|
125
|
-
Some(CompactionResult {
|
|
126
|
-
agent_id: fact.agent_id.clone(),
|
|
127
|
-
provider,
|
|
128
|
-
observed: true,
|
|
129
|
-
reason: Some("compaction_observed".to_string()),
|
|
130
|
-
recommendation,
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
fn detect_session_drift(
|
|
135
|
-
state: &mut Value,
|
|
136
|
-
event_log: &EventLog,
|
|
137
|
-
fact: &CapturedRuntimeFact,
|
|
138
|
-
) -> Option<SessionDriftResult> {
|
|
139
|
-
if fact.provider != Some(Provider::Codex) {
|
|
140
|
-
return None;
|
|
141
|
-
}
|
|
142
|
-
let stored = fact
|
|
143
|
-
.stored_session_id
|
|
144
|
-
.as_deref()
|
|
145
|
-
.filter(|s| !s.trim().is_empty())?;
|
|
146
|
-
let actual = extract_thread_id_from_scrollback(&fact.scrollback_tail)?;
|
|
147
|
-
if actual.eq_ignore_ascii_case(stored) {
|
|
148
|
-
if agent_has_session_drift(state, &fact.agent_id)
|
|
149
|
-
|| fact
|
|
150
|
-
.agent_state_snapshot
|
|
151
|
-
.get("status")
|
|
152
|
-
.and_then(Value::as_str)
|
|
153
|
-
== Some("session_drift")
|
|
154
|
-
{
|
|
155
|
-
clear_agent_session_drift(state, &fact.agent_id);
|
|
156
|
-
let _ = event_log.write(
|
|
157
|
-
"coordinator.session_drift_cleared",
|
|
158
|
-
json!({
|
|
159
|
-
"agent_id": fact.agent_id.as_str(),
|
|
160
|
-
"stored_session_id": stored,
|
|
161
|
-
"actual_thread_id": actual,
|
|
162
|
-
"status": "running",
|
|
163
|
-
"provider": "codex",
|
|
164
|
-
}),
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
return None;
|
|
168
|
-
}
|
|
169
|
-
if fact
|
|
170
|
-
.agent_state_snapshot
|
|
171
|
-
.get("status")
|
|
172
|
-
.and_then(Value::as_str)
|
|
173
|
-
== Some("session_drift")
|
|
174
|
-
{
|
|
175
|
-
return None;
|
|
176
|
-
}
|
|
177
|
-
let detected_at = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Micros, false);
|
|
178
|
-
let remediation = "team-agent reset-agent --discard-session <agent>";
|
|
179
|
-
let _ = event_log.write(
|
|
180
|
-
"coordinator.session_drift_detected",
|
|
181
|
-
json!({
|
|
182
|
-
"agent_id": fact.agent_id.as_str(),
|
|
183
|
-
"stored_session_id": stored,
|
|
184
|
-
"actual_thread_id": actual,
|
|
185
|
-
"status": "session_drift",
|
|
186
|
-
"provider": "codex",
|
|
187
|
-
"ts": detected_at,
|
|
188
|
-
"remediation": remediation,
|
|
189
|
-
}),
|
|
190
|
-
);
|
|
191
|
-
mark_agent_session_drift(
|
|
192
|
-
state,
|
|
193
|
-
&fact.agent_id,
|
|
194
|
-
stored,
|
|
195
|
-
&actual,
|
|
196
|
-
&detected_at,
|
|
197
|
-
remediation,
|
|
198
|
-
);
|
|
199
|
-
Some(SessionDriftResult {
|
|
200
|
-
agent_id: fact.agent_id.clone(),
|
|
201
|
-
stored_session_id: Some(stored.to_string()),
|
|
202
|
-
observed_session_id: Some(actual),
|
|
203
|
-
status: "session_drift".to_string(),
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
fn detect_leader_api_error(
|
|
208
|
-
state: &mut Value,
|
|
209
|
-
event_log: &EventLog,
|
|
210
|
-
leader_capture: Option<&LeaderCaptureFact>,
|
|
211
|
-
) -> Vec<LeaderApiError> {
|
|
212
|
-
let Some(capture) = leader_capture else {
|
|
213
|
-
return Vec::new();
|
|
214
|
-
};
|
|
215
|
-
let Some((error_class, snippet)) = match_api_error(&capture.scrollback_tail) else {
|
|
216
|
-
clear_last_api_error_fingerprint(state);
|
|
217
|
-
return Vec::new();
|
|
218
|
-
};
|
|
219
|
-
let fingerprint = format!("{error_class}::{}", tail_chars(&snippet, 120));
|
|
220
|
-
if get_coordinator(state)
|
|
221
|
-
.and_then(|c| c.get("last_api_error_fingerprint"))
|
|
222
|
-
.and_then(Value::as_str)
|
|
223
|
-
== Some(fingerprint.as_str())
|
|
224
|
-
{
|
|
225
|
-
return Vec::new();
|
|
226
|
-
}
|
|
227
|
-
let Some(coordinator) = coordinator_object_mut(state) else {
|
|
228
|
-
return Vec::new();
|
|
229
|
-
};
|
|
230
|
-
coordinator.insert(
|
|
231
|
-
"last_api_error_fingerprint".to_string(),
|
|
232
|
-
Value::String(fingerprint.clone()),
|
|
233
|
-
);
|
|
234
|
-
let provider = leader_receiver_provider(capture.leader_receiver.as_ref())
|
|
235
|
-
.or_else(|| leader_receiver_provider(state.get("leader_receiver")));
|
|
236
|
-
let pane_id = capture
|
|
237
|
-
.pane_id
|
|
238
|
-
.as_ref()
|
|
239
|
-
.map(|pane| pane.as_str().to_string())
|
|
240
|
-
.or_else(|| {
|
|
241
|
-
capture
|
|
242
|
-
.leader_receiver
|
|
243
|
-
.as_ref()
|
|
244
|
-
.and_then(|r| r.get("pane_id"))
|
|
245
|
-
.and_then(Value::as_str)
|
|
246
|
-
.map(ToString::to_string)
|
|
247
|
-
});
|
|
248
|
-
// Stage 3a (identity-boundary unified plan, architect direction
|
|
249
|
-
// 2026-06-23): route owner read through the ownership repository.
|
|
250
|
-
// The coordinator state here is the workspace runtime state — Stage 5
|
|
251
|
-
// will swap to per-team state and this read follows automatically.
|
|
252
|
-
// capture.leader_receiver fallback is kept as evidence, not owner truth
|
|
253
|
-
// (architect §4 cross-module risk: capture fallback is evidence-only).
|
|
254
|
-
let leader_session_uuid = crate::state::ownership::read_owner_value(state, "")
|
|
255
|
-
.and_then(|owner| owner.get("leader_session_uuid"))
|
|
256
|
-
.or_else(|| {
|
|
257
|
-
capture
|
|
258
|
-
.leader_receiver
|
|
259
|
-
.as_ref()
|
|
260
|
-
.and_then(|receiver| receiver.get("leader_session_uuid"))
|
|
261
|
-
})
|
|
262
|
-
.and_then(Value::as_str)
|
|
263
|
-
.map(ToString::to_string);
|
|
264
|
-
let partial_response_streamed =
|
|
265
|
-
scrollback_has_partial_response(&capture.scrollback_tail, &snippet);
|
|
266
|
-
let _ = event_log.write(
|
|
267
|
-
"leader.api_error",
|
|
268
|
-
json!({
|
|
269
|
-
"leader_session_uuid": leader_session_uuid,
|
|
270
|
-
"error_class": error_class,
|
|
271
|
-
"provider": provider.map(runtime_event_provider_name),
|
|
272
|
-
"partial_response_streamed": partial_response_streamed,
|
|
273
|
-
"worker_dispatch_just_before": [],
|
|
274
|
-
"retry_count": 0,
|
|
275
|
-
"matched_pattern_snippet": snippet.chars().take(160).collect::<String>(),
|
|
276
|
-
}),
|
|
277
|
-
);
|
|
278
|
-
vec![LeaderApiError {
|
|
279
|
-
provider,
|
|
280
|
-
pane_id,
|
|
281
|
-
fingerprint,
|
|
282
|
-
message: snippet,
|
|
283
|
-
}]
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
fn count_compaction_markers(scrollback: &str) -> i64 {
|
|
287
|
-
let lower = scrollback.to_ascii_lowercase();
|
|
288
|
-
lower.matches("context compacted").count() as i64
|
|
289
|
-
+ lower.matches("compaction occurred").count() as i64
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/// Returns `(previous, current)` so the caller can emit change-driven events (P4).
|
|
293
|
-
fn update_compaction_count(
|
|
294
|
-
state: &mut Value,
|
|
295
|
-
team: &str,
|
|
296
|
-
agent_id: &AgentId,
|
|
297
|
-
count: i64,
|
|
298
|
-
) -> (i64, i64) {
|
|
299
|
-
let Some(coordinator) = coordinator_object_mut(state) else {
|
|
300
|
-
return (0, count);
|
|
301
|
-
};
|
|
302
|
-
let Some(counts) = object_field_mut(coordinator, "compaction_counts") else {
|
|
303
|
-
return (0, count);
|
|
304
|
-
};
|
|
305
|
-
let Some(team_counts) = object_field_mut(counts, team) else {
|
|
306
|
-
return (0, count);
|
|
307
|
-
};
|
|
308
|
-
let previous = team_counts
|
|
309
|
-
.get(agent_id.as_str())
|
|
310
|
-
.and_then(Value::as_i64)
|
|
311
|
-
.unwrap_or(0);
|
|
312
|
-
let current = previous.max(count);
|
|
313
|
-
team_counts.insert(agent_id.as_str().to_string(), json!(current));
|
|
314
|
-
(previous, current)
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
fn compaction_reset_threshold(state: &Value) -> i64 {
|
|
318
|
-
state
|
|
319
|
-
.get("runtime")
|
|
320
|
-
.and_then(|runtime| runtime.get("compaction_reset_threshold"))
|
|
321
|
-
.and_then(Value::as_i64)
|
|
322
|
-
.filter(|value| *value > 0)
|
|
323
|
-
.unwrap_or(COMPACTION_RESET_THRESHOLD_DEFAULT)
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
fn extract_thread_id_from_scrollback(scrollback: &str) -> Option<String> {
|
|
327
|
-
let mut found = None;
|
|
328
|
-
let lower = scrollback.to_ascii_lowercase();
|
|
329
|
-
for needle in ["switched to thread", "resume", "thread"] {
|
|
330
|
-
let mut offset = 0;
|
|
331
|
-
while let Some(pos) = lower.get(offset..).and_then(|tail| tail.find(needle)) {
|
|
332
|
-
let start = offset + pos + needle.len();
|
|
333
|
-
if let Some(token) = first_token(scrollback.get(start..).unwrap_or_default()) {
|
|
334
|
-
if is_uuid_token(&token) {
|
|
335
|
-
found = Some(token.to_ascii_lowercase());
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
offset = start;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
found
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
fn first_token(text: &str) -> Option<String> {
|
|
345
|
-
let trimmed =
|
|
346
|
-
text.trim_start_matches(|c: char| c.is_whitespace() || matches!(c, ':' | '=' | '#'));
|
|
347
|
-
let trimmed = trimmed
|
|
348
|
-
.strip_prefix("id")
|
|
349
|
-
.map(|rest| {
|
|
350
|
-
rest.trim_start_matches(|c: char| c.is_whitespace() || matches!(c, ':' | '=' | '#'))
|
|
351
|
-
})
|
|
352
|
-
.unwrap_or(trimmed);
|
|
353
|
-
let token: String = trimmed
|
|
354
|
-
.chars()
|
|
355
|
-
.take_while(|c| c.is_ascii_alphanumeric() || *c == '-')
|
|
356
|
-
.collect();
|
|
357
|
-
(!token.is_empty()).then_some(token)
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
fn is_uuid_token(token: &str) -> bool {
|
|
361
|
-
let bytes = token.as_bytes();
|
|
362
|
-
if bytes.len() != 36 {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
for (idx, byte) in bytes.iter().enumerate() {
|
|
366
|
-
match idx {
|
|
367
|
-
8 | 13 | 18 | 23 => {
|
|
368
|
-
if *byte != b'-' {
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
_ => {
|
|
373
|
-
if !byte.is_ascii_hexdigit() {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
true
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
fn mark_agent_session_drift(
|
|
383
|
-
state: &mut Value,
|
|
384
|
-
agent_id: &AgentId,
|
|
385
|
-
stored: &str,
|
|
386
|
-
actual: &str,
|
|
387
|
-
detected_at: &str,
|
|
388
|
-
remediation: &str,
|
|
389
|
-
) {
|
|
390
|
-
let drift = json!({
|
|
391
|
-
"stored_session_id": stored,
|
|
392
|
-
"actual_thread_id": actual,
|
|
393
|
-
"detected_at": detected_at,
|
|
394
|
-
"remediation": remediation,
|
|
395
|
-
});
|
|
396
|
-
if let Some(agent) = agent_object_mut(state, agent_id) {
|
|
397
|
-
agent.insert(
|
|
398
|
-
"status".to_string(),
|
|
399
|
-
Value::String("session_drift".to_string()),
|
|
400
|
-
);
|
|
401
|
-
agent.insert("session_drift".to_string(), drift.clone());
|
|
402
|
-
}
|
|
403
|
-
if let Some(teams) = state.get_mut("teams").and_then(Value::as_object_mut) {
|
|
404
|
-
for team in teams.values_mut() {
|
|
405
|
-
if let Some(agent) = team
|
|
406
|
-
.get_mut("agents")
|
|
407
|
-
.and_then(Value::as_object_mut)
|
|
408
|
-
.and_then(|agents| agents.get_mut(agent_id.as_str()))
|
|
409
|
-
.and_then(Value::as_object_mut)
|
|
410
|
-
{
|
|
411
|
-
agent.insert(
|
|
412
|
-
"status".to_string(),
|
|
413
|
-
Value::String("session_drift".to_string()),
|
|
414
|
-
);
|
|
415
|
-
agent.insert("session_drift".to_string(), drift.clone());
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
fn clear_agent_session_drift(state: &mut Value, agent_id: &AgentId) {
|
|
422
|
-
if let Some(agent) = agent_object_mut(state, agent_id) {
|
|
423
|
-
agent.insert("status".to_string(), Value::String("running".to_string()));
|
|
424
|
-
agent.remove("session_drift");
|
|
425
|
-
}
|
|
426
|
-
if let Some(teams) = state.get_mut("teams").and_then(Value::as_object_mut) {
|
|
427
|
-
for team in teams.values_mut() {
|
|
428
|
-
if let Some(agent) = team
|
|
429
|
-
.get_mut("agents")
|
|
430
|
-
.and_then(Value::as_object_mut)
|
|
431
|
-
.and_then(|agents| agents.get_mut(agent_id.as_str()))
|
|
432
|
-
.and_then(Value::as_object_mut)
|
|
433
|
-
{
|
|
434
|
-
agent.insert("status".to_string(), Value::String("running".to_string()));
|
|
435
|
-
agent.remove("session_drift");
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
fn agent_has_session_drift(state: &Value, agent_id: &AgentId) -> bool {
|
|
442
|
-
state
|
|
443
|
-
.get("agents")
|
|
444
|
-
.and_then(Value::as_object)
|
|
445
|
-
.and_then(|agents| agents.get(agent_id.as_str()))
|
|
446
|
-
.and_then(|agent| agent.get("status"))
|
|
447
|
-
.and_then(Value::as_str)
|
|
448
|
-
== Some("session_drift")
|
|
449
|
-
|| state
|
|
450
|
-
.get("teams")
|
|
451
|
-
.and_then(Value::as_object)
|
|
452
|
-
.is_some_and(|teams| {
|
|
453
|
-
teams.values().any(|team| {
|
|
454
|
-
team.get("agents")
|
|
455
|
-
.and_then(Value::as_object)
|
|
456
|
-
.and_then(|agents| agents.get(agent_id.as_str()))
|
|
457
|
-
.and_then(|agent| agent.get("status"))
|
|
458
|
-
.and_then(Value::as_str)
|
|
459
|
-
== Some("session_drift")
|
|
460
|
-
})
|
|
461
|
-
})
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
fn match_api_error(scrollback: &str) -> Option<(String, String)> {
|
|
465
|
-
let lines: Vec<String> = scrollback
|
|
466
|
-
.lines()
|
|
467
|
-
.rev()
|
|
468
|
-
.take(100)
|
|
469
|
-
.map(str::trim)
|
|
470
|
-
.map(ToString::to_string)
|
|
471
|
-
.collect::<Vec<_>>()
|
|
472
|
-
.into_iter()
|
|
473
|
-
.rev()
|
|
474
|
-
.collect();
|
|
475
|
-
let mut best = None;
|
|
476
|
-
for start in 0..lines.len() {
|
|
477
|
-
for size in 1..=3 {
|
|
478
|
-
if start + size > lines.len() {
|
|
479
|
-
break;
|
|
480
|
-
}
|
|
481
|
-
let mut window = lines[start..start + size]
|
|
482
|
-
.iter()
|
|
483
|
-
.filter(|line| !line.is_empty())
|
|
484
|
-
.cloned()
|
|
485
|
-
.collect::<Vec<_>>()
|
|
486
|
-
.join(" ");
|
|
487
|
-
if window.len() > 400 {
|
|
488
|
-
window = tail_chars(&window, 400);
|
|
489
|
-
}
|
|
490
|
-
let lower = window.to_ascii_lowercase();
|
|
491
|
-
let class = if lower.contains("api error: overloaded") {
|
|
492
|
-
Some("Overloaded")
|
|
493
|
-
} else if lower.contains("429 too many requests")
|
|
494
|
-
|| (has_api_context(&lower) && lower.contains("429"))
|
|
495
|
-
{
|
|
496
|
-
Some("RateLimit")
|
|
497
|
-
} else if lower.contains("etimedout")
|
|
498
|
-
|| (has_api_context(&lower)
|
|
499
|
-
&& (lower.contains("request timed out")
|
|
500
|
-
|| lower.contains("request timeout")
|
|
501
|
-
|| lower.contains("connection timed out")
|
|
502
|
-
|| lower.contains("connection timeout")))
|
|
503
|
-
{
|
|
504
|
-
Some("Timeout")
|
|
505
|
-
} else if has_api_context(&lower)
|
|
506
|
-
&& (lower.contains("500")
|
|
507
|
-
|| lower.contains("502")
|
|
508
|
-
|| lower.contains("503")
|
|
509
|
-
|| lower.contains("504")
|
|
510
|
-
|| lower.contains("fetch failed"))
|
|
511
|
-
{
|
|
512
|
-
Some("NetworkError")
|
|
513
|
-
} else {
|
|
514
|
-
None
|
|
515
|
-
};
|
|
516
|
-
if let Some(class) = class {
|
|
517
|
-
best = Some((
|
|
518
|
-
start,
|
|
519
|
-
class.to_string(),
|
|
520
|
-
window.chars().take(240).collect::<String>(),
|
|
521
|
-
));
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
best.map(|(_, class, snippet)| (class, snippet))
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
fn has_api_context(lower: &str) -> bool {
|
|
529
|
-
lower.contains("api error")
|
|
530
|
-
|| lower.contains("http error")
|
|
531
|
-
|| lower.contains("httperror")
|
|
532
|
-
|| lower.contains("request failed")
|
|
533
|
-
|| lower.contains("codex")
|
|
534
|
-
|| lower.contains("claude")
|
|
535
|
-
|| lower.contains("anthropic")
|
|
536
|
-
|| lower.contains("openai")
|
|
537
|
-
|| lower.contains("typeerror")
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
fn scrollback_has_partial_response(scrollback: &str, snippet: &str) -> bool {
|
|
541
|
-
let Some(idx) = scrollback.rfind(snippet) else {
|
|
542
|
-
return false;
|
|
543
|
-
};
|
|
544
|
-
let start = idx.saturating_sub(4000);
|
|
545
|
-
let head = scrollback
|
|
546
|
-
.get(start..idx)
|
|
547
|
-
.unwrap_or_default()
|
|
548
|
-
.to_ascii_lowercase();
|
|
549
|
-
[
|
|
550
|
-
"assistant",
|
|
551
|
-
"i'll ",
|
|
552
|
-
"i will ",
|
|
553
|
-
"i'm ",
|
|
554
|
-
"i am ",
|
|
555
|
-
"let me ",
|
|
556
|
-
"> ",
|
|
557
|
-
]
|
|
558
|
-
.iter()
|
|
559
|
-
.any(|hint| head.contains(hint))
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
fn clear_last_api_error_fingerprint(state: &mut Value) {
|
|
563
|
-
if let Some(coordinator) = get_coordinator_mut(state) {
|
|
564
|
-
if coordinator.get("last_api_error_fingerprint").is_some() {
|
|
565
|
-
coordinator.insert("last_api_error_fingerprint".to_string(), Value::Null);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
fn leader_receiver_provider(receiver: Option<&Value>) -> Option<Provider> {
|
|
571
|
-
let raw = receiver
|
|
572
|
-
.and_then(|receiver| receiver.get("provider"))
|
|
573
|
-
.and_then(Value::as_str)?;
|
|
574
|
-
serde_json::from_value(Value::String(raw.to_string())).ok()
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
// Event-field grammar, not provider identity parsing.
|
|
578
|
-
fn runtime_event_provider_name(provider: Provider) -> &'static str {
|
|
579
|
-
match provider {
|
|
580
|
-
Provider::Claude => "claude",
|
|
581
|
-
Provider::ClaudeCode => "claude_code",
|
|
582
|
-
Provider::Codex => "codex",
|
|
583
|
-
Provider::Copilot => "copilot",
|
|
584
|
-
Provider::GeminiCli => "gemini_cli",
|
|
585
|
-
Provider::Grok => "grok",
|
|
586
|
-
Provider::Pi => "pi",
|
|
587
|
-
Provider::Fake => "fake",
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
fn coordinator_object_mut(state: &mut Value) -> Option<&mut Map<String, Value>> {
|
|
592
|
-
if !state.is_object() {
|
|
593
|
-
*state = json!({});
|
|
594
|
-
}
|
|
595
|
-
let obj = state.as_object_mut()?;
|
|
596
|
-
if !obj.get("coordinator").is_some_and(Value::is_object) {
|
|
597
|
-
obj.insert("coordinator".to_string(), json!({}));
|
|
598
|
-
}
|
|
599
|
-
obj.get_mut("coordinator").and_then(Value::as_object_mut)
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
fn get_coordinator(state: &Value) -> Option<&Map<String, Value>> {
|
|
603
|
-
state.get("coordinator").and_then(Value::as_object)
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
fn get_coordinator_mut(state: &mut Value) -> Option<&mut Map<String, Value>> {
|
|
607
|
-
state.get_mut("coordinator").and_then(Value::as_object_mut)
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
fn object_field_mut<'a>(
|
|
611
|
-
obj: &'a mut Map<String, Value>,
|
|
612
|
-
key: &str,
|
|
613
|
-
) -> Option<&'a mut Map<String, Value>> {
|
|
614
|
-
if !obj.get(key).is_some_and(Value::is_object) {
|
|
615
|
-
obj.insert(key.to_string(), json!({}));
|
|
616
|
-
}
|
|
617
|
-
obj.get_mut(key).and_then(Value::as_object_mut)
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
fn agent_object_mut<'a>(
|
|
621
|
-
state: &'a mut Value,
|
|
622
|
-
agent_id: &AgentId,
|
|
623
|
-
) -> Option<&'a mut Map<String, Value>> {
|
|
624
|
-
state
|
|
625
|
-
.get_mut("agents")
|
|
626
|
-
.and_then(Value::as_object_mut)
|
|
627
|
-
.and_then(|agents| agents.get_mut(agent_id.as_str()))
|
|
628
|
-
.and_then(Value::as_object_mut)
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
fn tail_chars(text: &str, max_chars: usize) -> String {
|
|
632
|
-
let chars: Vec<char> = text.chars().collect();
|
|
633
|
-
let start = chars.len().saturating_sub(max_chars);
|
|
634
|
-
chars[start..].iter().collect()
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
#[cfg(test)]
|
|
638
|
-
mod tests {
|
|
639
|
-
use super::*;
|
|
640
|
-
use std::collections::BTreeMap;
|
|
641
|
-
use std::path::PathBuf;
|
|
642
|
-
use std::sync::atomic::{AtomicU64, Ordering};
|
|
643
|
-
|
|
644
|
-
use crate::model::ids::{AgentId, TeamKey};
|
|
645
|
-
|
|
646
|
-
const STORED: &str = "11111111-1111-4111-8111-111111111111";
|
|
647
|
-
const OTHER: &str = "22222222-2222-4222-8222-222222222222";
|
|
648
|
-
|
|
649
|
-
#[test]
|
|
650
|
-
fn session_drift_ignores_plain_text_after_marker_words() {
|
|
651
|
-
let workspace = temp_workspace("plain-text");
|
|
652
|
-
let mut state = state_with_agent("running", None);
|
|
653
|
-
let captures = captures("w1", STORED, "Need resume confirmation before changing anything.\nSeveral threads mention evidence.\n");
|
|
654
|
-
|
|
655
|
-
let observed = observe_runtime(&workspace, &mut state, captures, None);
|
|
656
|
-
|
|
657
|
-
assert!(
|
|
658
|
-
observed.session_drift.is_empty(),
|
|
659
|
-
"plain prose must not be treated as a runtime id observation: {observed:?}"
|
|
660
|
-
);
|
|
661
|
-
assert_eq!(
|
|
662
|
-
state.pointer("/agents/w1/status").and_then(Value::as_str),
|
|
663
|
-
Some("running")
|
|
664
|
-
);
|
|
665
|
-
assert!(state.pointer("/agents/w1/session_drift").is_none());
|
|
666
|
-
let _ = std::fs::remove_dir_all(workspace);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
#[test]
|
|
670
|
-
fn session_drift_marks_real_uuid_mismatch() {
|
|
671
|
-
let workspace = temp_workspace("uuid-mismatch");
|
|
672
|
-
let mut state = state_with_agent("running", None);
|
|
673
|
-
let captures = captures(
|
|
674
|
-
"w1",
|
|
675
|
-
STORED,
|
|
676
|
-
&format!("Codex resumed. Switched to thread {OTHER}\n"),
|
|
677
|
-
);
|
|
678
|
-
|
|
679
|
-
let observed = observe_runtime(&workspace, &mut state, captures, None);
|
|
680
|
-
|
|
681
|
-
assert_eq!(observed.session_drift.len(), 1, "{observed:?}");
|
|
682
|
-
assert_eq!(
|
|
683
|
-
state.pointer("/agents/w1/status").and_then(Value::as_str),
|
|
684
|
-
Some("session_drift")
|
|
685
|
-
);
|
|
686
|
-
assert_eq!(
|
|
687
|
-
state
|
|
688
|
-
.pointer("/agents/w1/session_drift/actual_thread_id")
|
|
689
|
-
.and_then(Value::as_str),
|
|
690
|
-
Some(OTHER)
|
|
691
|
-
);
|
|
692
|
-
let _ = std::fs::remove_dir_all(workspace);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
#[test]
|
|
696
|
-
fn session_drift_clears_existing_marker_when_uuid_matches() {
|
|
697
|
-
let workspace = temp_workspace("uuid-match-clear");
|
|
698
|
-
let mut state = state_with_agent(
|
|
699
|
-
"session_drift",
|
|
700
|
-
Some(json!({
|
|
701
|
-
"stored_session_id": STORED,
|
|
702
|
-
"actual_thread_id": OTHER,
|
|
703
|
-
"detected_at": "2026-06-13T00:00:00Z",
|
|
704
|
-
"remediation": "old"
|
|
705
|
-
})),
|
|
706
|
-
);
|
|
707
|
-
let captures = captures("w1", STORED, &format!("resume {STORED}\n"));
|
|
708
|
-
|
|
709
|
-
let observed = observe_runtime(&workspace, &mut state, captures, None);
|
|
710
|
-
|
|
711
|
-
assert!(
|
|
712
|
-
observed.session_drift.is_empty(),
|
|
713
|
-
"matching observation clears state instead of reporting a new drift: {observed:?}"
|
|
714
|
-
);
|
|
715
|
-
assert_eq!(
|
|
716
|
-
state.pointer("/agents/w1/status").and_then(Value::as_str),
|
|
717
|
-
Some("running")
|
|
718
|
-
);
|
|
719
|
-
assert!(state.pointer("/agents/w1/session_drift").is_none());
|
|
720
|
-
assert_eq!(
|
|
721
|
-
state
|
|
722
|
-
.pointer("/teams/current/agents/w1/status")
|
|
723
|
-
.and_then(Value::as_str),
|
|
724
|
-
Some("running")
|
|
725
|
-
);
|
|
726
|
-
assert!(state
|
|
727
|
-
.pointer("/teams/current/agents/w1/session_drift")
|
|
728
|
-
.is_none());
|
|
729
|
-
let _ = std::fs::remove_dir_all(workspace);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
fn captures(
|
|
733
|
-
agent_id: &str,
|
|
734
|
-
stored_session_id: &str,
|
|
735
|
-
scrollback_tail: &str,
|
|
736
|
-
) -> BTreeMap<AgentId, CapturedRuntimeFact> {
|
|
737
|
-
let agent_id = AgentId::new(agent_id);
|
|
738
|
-
let snapshot = json!({
|
|
739
|
-
"provider": "codex",
|
|
740
|
-
"status": "running",
|
|
741
|
-
"session_id": stored_session_id,
|
|
742
|
-
});
|
|
743
|
-
BTreeMap::from([(
|
|
744
|
-
agent_id.clone(),
|
|
745
|
-
CapturedRuntimeFact {
|
|
746
|
-
team_key: Some(TeamKey::new("current")),
|
|
747
|
-
agent_id,
|
|
748
|
-
provider: Some(Provider::Codex),
|
|
749
|
-
session_name: None,
|
|
750
|
-
window: None,
|
|
751
|
-
pane_id: None,
|
|
752
|
-
scrollback_tail: scrollback_tail.to_string(),
|
|
753
|
-
pane_info: None,
|
|
754
|
-
agent_state_snapshot: snapshot,
|
|
755
|
-
stored_session_id: Some(stored_session_id.to_string()),
|
|
756
|
-
last_output_at: None,
|
|
757
|
-
rollout_path: None,
|
|
758
|
-
process_liveness: None,
|
|
759
|
-
},
|
|
760
|
-
)])
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
fn state_with_agent(status: &str, session_drift: Option<Value>) -> Value {
|
|
764
|
-
let mut agent = json!({
|
|
765
|
-
"provider": "codex",
|
|
766
|
-
"status": status,
|
|
767
|
-
"session_id": STORED,
|
|
768
|
-
});
|
|
769
|
-
if let Some(drift) = session_drift {
|
|
770
|
-
agent["session_drift"] = drift;
|
|
771
|
-
}
|
|
772
|
-
json!({
|
|
773
|
-
"active_team_key": "current",
|
|
774
|
-
"agents": {
|
|
775
|
-
"w1": agent.clone()
|
|
776
|
-
},
|
|
777
|
-
"teams": {
|
|
778
|
-
"current": {
|
|
779
|
-
"agents": {
|
|
780
|
-
"w1": agent
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
})
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
fn temp_workspace(tag: &str) -> PathBuf {
|
|
788
|
-
static COUNTER: AtomicU64 = AtomicU64::new(0);
|
|
789
|
-
let dir = std::env::temp_dir().join(format!(
|
|
790
|
-
"ta-rs-e28-{tag}-{}-{}",
|
|
791
|
-
std::process::id(),
|
|
792
|
-
COUNTER.fetch_add(1, Ordering::Relaxed)
|
|
793
|
-
));
|
|
794
|
-
let _ = std::fs::remove_dir_all(&dir);
|
|
795
|
-
std::fs::create_dir_all(&dir).unwrap();
|
|
796
|
-
std::fs::canonicalize(dir).unwrap()
|
|
797
|
-
}
|
|
798
|
-
}
|