@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,546 +0,0 @@
|
|
|
1
|
-
//! Minimal Codex app-server Unix-socket WebSocket client for leader delivery.
|
|
2
|
-
//!
|
|
3
|
-
//! 0.5.x Windows portability Batch 1: this client is fundamentally
|
|
4
|
-
//! Unix-only (`UnixStream` WebSocket handshake, uid/mode socket
|
|
5
|
-
//! ownership check). On Windows we still expose the same public API
|
|
6
|
-
//! surface so `messaging/delivery.rs`, `cli/send.rs`, `cli/named_address.rs`,
|
|
7
|
-
//! `leader/lease.rs` compile identically. Windows implementations of
|
|
8
|
-
//! `attach_probe` + `submit_to_bound_thread` return
|
|
9
|
-
//! `AppServerError::SocketUnreachable("codex_app_server unix socket not supported on this platform (Windows)")`
|
|
10
|
-
//! (N38 three-line typed unsupported: code+reason+action are baked into
|
|
11
|
-
//! `AppServerError::code()` and the `Display` impl). Truth source:
|
|
12
|
-
//! `.team/artifacts/0.5.x-windows-portability-survey-design.md` §Batch 1.
|
|
13
|
-
//!
|
|
14
|
-
//! Portable pieces below (types, JSON helpers) stay unconditional so
|
|
15
|
-
//! `receiver_is_app_server` / `binding_from_receiver` work identically
|
|
16
|
-
//! everywhere.
|
|
17
|
-
|
|
18
|
-
use serde_json::{json, Value};
|
|
19
|
-
#[cfg(unix)]
|
|
20
|
-
use std::io::{Read, Write};
|
|
21
|
-
#[cfg(unix)]
|
|
22
|
-
use std::os::unix::fs::{FileTypeExt, MetadataExt, PermissionsExt};
|
|
23
|
-
#[cfg(unix)]
|
|
24
|
-
use std::os::unix::net::UnixStream;
|
|
25
|
-
#[cfg(unix)]
|
|
26
|
-
use std::path::Path;
|
|
27
|
-
use std::path::PathBuf;
|
|
28
|
-
#[cfg(unix)]
|
|
29
|
-
use std::time::Duration;
|
|
30
|
-
|
|
31
|
-
pub const APP_SERVER_PROTOCOL_FIXTURE_CLI_MIN: &str = "0.139.0";
|
|
32
|
-
pub const APP_SERVER_PROTOCOL_FIXTURE_CLI_MAX: &str = "0.139.x";
|
|
33
|
-
pub const APP_SERVER_PROTOCOL_REQUIRES_USER_AGENT: bool = true;
|
|
34
|
-
|
|
35
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
36
|
-
pub struct AppServerBinding {
|
|
37
|
-
pub socket: String,
|
|
38
|
-
pub thread_id: String,
|
|
39
|
-
pub session_id: String,
|
|
40
|
-
pub cwd: String,
|
|
41
|
-
pub cli_version: String,
|
|
42
|
-
pub bound_at: String,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
46
|
-
pub struct AppServerSubmit {
|
|
47
|
-
pub turn_id: String,
|
|
48
|
-
pub turn_status: String,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
52
|
-
pub enum AppServerError {
|
|
53
|
-
SocketUnreachable(String),
|
|
54
|
-
SocketOwnershipInvalid(String),
|
|
55
|
-
ThreadNotLive(String),
|
|
56
|
-
ThreadStale { expected: Value, actual: Value },
|
|
57
|
-
LeaderBusy(String),
|
|
58
|
-
ApprovalUnsupported(String),
|
|
59
|
-
ProtocolMismatch(String),
|
|
60
|
-
MissingUserAgent,
|
|
61
|
-
Io(String),
|
|
62
|
-
Json(String),
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
impl AppServerError {
|
|
66
|
-
pub fn code(&self) -> &'static str {
|
|
67
|
-
match self {
|
|
68
|
-
Self::SocketUnreachable(_) => "socket_unreachable",
|
|
69
|
-
Self::SocketOwnershipInvalid(_) => "socket_ownership_invalid",
|
|
70
|
-
Self::ThreadNotLive(_) => "thread_not_live",
|
|
71
|
-
Self::ThreadStale { .. } => "app_server_thread_stale",
|
|
72
|
-
Self::LeaderBusy(_) => "leader_busy",
|
|
73
|
-
Self::ApprovalUnsupported(_) => "approval_unsupported",
|
|
74
|
-
Self::ProtocolMismatch(_) => "protocol_mismatch",
|
|
75
|
-
Self::MissingUserAgent => "protocol_mismatch_missing_user_agent",
|
|
76
|
-
Self::Io(_) => "io_error",
|
|
77
|
-
Self::Json(_) => "json_error",
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
impl std::fmt::Display for AppServerError {
|
|
83
|
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
84
|
-
match self {
|
|
85
|
-
Self::SocketUnreachable(msg)
|
|
86
|
-
| Self::SocketOwnershipInvalid(msg)
|
|
87
|
-
| Self::ThreadNotLive(msg)
|
|
88
|
-
| Self::LeaderBusy(msg)
|
|
89
|
-
| Self::ApprovalUnsupported(msg)
|
|
90
|
-
| Self::ProtocolMismatch(msg)
|
|
91
|
-
| Self::Io(msg)
|
|
92
|
-
| Self::Json(msg) => write!(f, "{}:{msg}", self.code()),
|
|
93
|
-
Self::ThreadStale { expected, actual } => {
|
|
94
|
-
write!(f, "{}:expected={expected},actual={actual}", self.code())
|
|
95
|
-
}
|
|
96
|
-
Self::MissingUserAgent => f.write_str(self.code()),
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
impl std::error::Error for AppServerError {}
|
|
102
|
-
|
|
103
|
-
#[cfg(unix)]
|
|
104
|
-
pub fn attach_probe(endpoint: &str, thread_id: &str) -> Result<AppServerBinding, AppServerError> {
|
|
105
|
-
check_socket_ownership(endpoint)?;
|
|
106
|
-
let socket = socket_path(endpoint)?;
|
|
107
|
-
let mut client = AppServerClient::connect(&socket)?;
|
|
108
|
-
let user_agent = client.initialize()?;
|
|
109
|
-
let resume = client.resume(thread_id)?;
|
|
110
|
-
Ok(AppServerBinding {
|
|
111
|
-
socket: endpoint.to_string(),
|
|
112
|
-
thread_id: resume.thread_id,
|
|
113
|
-
session_id: resume.session_id,
|
|
114
|
-
cwd: resume.cwd,
|
|
115
|
-
cli_version: user_agent,
|
|
116
|
-
bound_at: chrono::Utc::now().to_rfc3339(),
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/// Batch 1 Windows N38 typed-unsupported stub. Callers see the same
|
|
121
|
-
/// `AppServerError` shape as Unix — no silent success, no panic.
|
|
122
|
-
#[cfg(not(unix))]
|
|
123
|
-
pub fn attach_probe(_endpoint: &str, _thread_id: &str) -> Result<AppServerBinding, AppServerError> {
|
|
124
|
-
Err(AppServerError::SocketUnreachable(
|
|
125
|
-
"codex_app_server unix-socket client not supported on this platform \
|
|
126
|
-
(Windows); use codex CLI stdio or ConPTY worker delivery instead"
|
|
127
|
-
.to_string(),
|
|
128
|
-
))
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
#[cfg(unix)]
|
|
132
|
-
pub fn submit_to_bound_thread(
|
|
133
|
-
binding: &AppServerBinding,
|
|
134
|
-
message_id: &str,
|
|
135
|
-
rendered: &str,
|
|
136
|
-
) -> Result<AppServerSubmit, AppServerError> {
|
|
137
|
-
let socket = socket_path(&binding.socket)?;
|
|
138
|
-
let mut client = AppServerClient::connect(&socket)?;
|
|
139
|
-
let user_agent = client.initialize()?;
|
|
140
|
-
let resume = client.resume(&binding.thread_id)?;
|
|
141
|
-
validate_tuple(binding, &user_agent, &resume)?;
|
|
142
|
-
client.turn_start(&binding.thread_id, message_id, rendered)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
#[cfg(not(unix))]
|
|
146
|
-
pub fn submit_to_bound_thread(
|
|
147
|
-
_binding: &AppServerBinding,
|
|
148
|
-
_message_id: &str,
|
|
149
|
-
_rendered: &str,
|
|
150
|
-
) -> Result<AppServerSubmit, AppServerError> {
|
|
151
|
-
Err(AppServerError::SocketUnreachable(
|
|
152
|
-
"codex_app_server unix-socket submit not supported on this platform \
|
|
153
|
-
(Windows); use codex CLI stdio or ConPTY worker delivery instead"
|
|
154
|
-
.to_string(),
|
|
155
|
-
))
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
pub fn binding_from_receiver(receiver: &Value) -> Result<AppServerBinding, AppServerError> {
|
|
159
|
-
let app = receiver
|
|
160
|
-
.get("app_server")
|
|
161
|
-
.ok_or_else(|| AppServerError::ProtocolMismatch("missing app_server".to_string()))?;
|
|
162
|
-
Ok(AppServerBinding {
|
|
163
|
-
socket: required_str(app, "socket")?.to_string(),
|
|
164
|
-
thread_id: required_str(app, "thread_id")?.to_string(),
|
|
165
|
-
session_id: required_str(app, "session_id")?.to_string(),
|
|
166
|
-
cwd: required_str(app, "cwd")?.to_string(),
|
|
167
|
-
cli_version: required_str(app, "cli_version")?.to_string(),
|
|
168
|
-
bound_at: required_str(app, "bound_at")?.to_string(),
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
pub fn receiver_is_app_server(receiver: &Value) -> bool {
|
|
173
|
-
receiver.get("transport_kind").and_then(Value::as_str) == Some("codex_app_server")
|
|
174
|
-
|| receiver.get("mode").and_then(Value::as_str) == Some("codex_app_server")
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
fn required_str<'a>(value: &'a Value, field: &str) -> Result<&'a str, AppServerError> {
|
|
178
|
-
value
|
|
179
|
-
.get(field)
|
|
180
|
-
.and_then(Value::as_str)
|
|
181
|
-
.filter(|s| !s.is_empty())
|
|
182
|
-
.ok_or_else(|| AppServerError::ProtocolMismatch(format!("missing {field}")))
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#[cfg(unix)]
|
|
186
|
-
fn validate_tuple(
|
|
187
|
-
binding: &AppServerBinding,
|
|
188
|
-
user_agent: &str,
|
|
189
|
-
resume: &ThreadResume,
|
|
190
|
-
) -> Result<(), AppServerError> {
|
|
191
|
-
if user_agent != binding.cli_version
|
|
192
|
-
|| resume.thread_id != binding.thread_id
|
|
193
|
-
|| resume.session_id != binding.session_id
|
|
194
|
-
|| resume.cwd != binding.cwd
|
|
195
|
-
{
|
|
196
|
-
return Err(AppServerError::ThreadStale {
|
|
197
|
-
expected: json!({
|
|
198
|
-
"cli_version": binding.cli_version,
|
|
199
|
-
"thread_id": binding.thread_id,
|
|
200
|
-
"session_id": binding.session_id,
|
|
201
|
-
"cwd": binding.cwd,
|
|
202
|
-
}),
|
|
203
|
-
actual: json!({
|
|
204
|
-
"cli_version": user_agent,
|
|
205
|
-
"thread_id": resume.thread_id,
|
|
206
|
-
"session_id": resume.session_id,
|
|
207
|
-
"cwd": resume.cwd,
|
|
208
|
-
}),
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
Ok(())
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
#[cfg(unix)]
|
|
215
|
-
fn check_socket_ownership(endpoint: &str) -> Result<(), AppServerError> {
|
|
216
|
-
let path = socket_path(endpoint)?;
|
|
217
|
-
let meta = std::fs::metadata(&path)
|
|
218
|
-
.map_err(|e| AppServerError::SocketUnreachable(format!("{}:{e}", path.display())))?;
|
|
219
|
-
if !meta.file_type().is_socket() {
|
|
220
|
-
return Err(AppServerError::SocketOwnershipInvalid(format!(
|
|
221
|
-
"not a unix socket: {}",
|
|
222
|
-
path.display()
|
|
223
|
-
)));
|
|
224
|
-
}
|
|
225
|
-
if meta.uid() != unsafe { libc::geteuid() } {
|
|
226
|
-
return Err(AppServerError::SocketOwnershipInvalid(format!(
|
|
227
|
-
"socket owner uid {} != current uid {}",
|
|
228
|
-
meta.uid(),
|
|
229
|
-
unsafe { libc::geteuid() }
|
|
230
|
-
)));
|
|
231
|
-
}
|
|
232
|
-
if meta.permissions().mode() & 0o002 != 0 {
|
|
233
|
-
return Err(AppServerError::SocketOwnershipInvalid(format!(
|
|
234
|
-
"socket is world-writable: {}",
|
|
235
|
-
path.display()
|
|
236
|
-
)));
|
|
237
|
-
}
|
|
238
|
-
Ok(())
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
#[cfg(unix)]
|
|
242
|
-
fn socket_path(endpoint: &str) -> Result<PathBuf, AppServerError> {
|
|
243
|
-
let raw = endpoint.strip_prefix("unix://").unwrap_or(endpoint);
|
|
244
|
-
if raw.is_empty() {
|
|
245
|
-
return Err(AppServerError::SocketUnreachable(
|
|
246
|
-
"missing unix socket path".to_string(),
|
|
247
|
-
));
|
|
248
|
-
}
|
|
249
|
-
Ok(PathBuf::from(raw))
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
#[cfg(unix)]
|
|
253
|
-
struct ThreadResume {
|
|
254
|
-
thread_id: String,
|
|
255
|
-
session_id: String,
|
|
256
|
-
cwd: String,
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
#[cfg(unix)]
|
|
260
|
-
struct AppServerClient {
|
|
261
|
-
stream: UnixStream,
|
|
262
|
-
next_id: u64,
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
#[cfg(unix)]
|
|
266
|
-
impl AppServerClient {
|
|
267
|
-
fn connect(path: &Path) -> Result<Self, AppServerError> {
|
|
268
|
-
let mut stream = UnixStream::connect(path)
|
|
269
|
-
.map_err(|e| AppServerError::SocketUnreachable(format!("{}:{e}", path.display())))?;
|
|
270
|
-
stream
|
|
271
|
-
.set_read_timeout(Some(Duration::from_secs(10)))
|
|
272
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
273
|
-
stream
|
|
274
|
-
.set_write_timeout(Some(Duration::from_secs(10)))
|
|
275
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
276
|
-
let request = concat!(
|
|
277
|
-
"GET / HTTP/1.1\r\n",
|
|
278
|
-
"Host: localhost\r\n",
|
|
279
|
-
"Upgrade: websocket\r\n",
|
|
280
|
-
"Connection: Upgrade\r\n",
|
|
281
|
-
"Sec-WebSocket-Key: dGVhbS1hZ2VudC1jb2RleA==\r\n",
|
|
282
|
-
"Sec-WebSocket-Version: 13\r\n",
|
|
283
|
-
"\r\n"
|
|
284
|
-
);
|
|
285
|
-
stream
|
|
286
|
-
.write_all(request.as_bytes())
|
|
287
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
288
|
-
let response = read_http_response(&mut stream)?;
|
|
289
|
-
if !response.starts_with("HTTP/1.1 101") && !response.starts_with("HTTP/1.0 101") {
|
|
290
|
-
return Err(AppServerError::ProtocolMismatch(format!(
|
|
291
|
-
"websocket upgrade failed: {}",
|
|
292
|
-
response.lines().next().unwrap_or("")
|
|
293
|
-
)));
|
|
294
|
-
}
|
|
295
|
-
Ok(Self { stream, next_id: 1 })
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
fn initialize(&mut self) -> Result<String, AppServerError> {
|
|
299
|
-
let result = self.request(json!({
|
|
300
|
-
"method": "initialize",
|
|
301
|
-
"params": {
|
|
302
|
-
"clientInfo": {
|
|
303
|
-
"name": "codex-appserver-team-agent",
|
|
304
|
-
"title": "Team Agent",
|
|
305
|
-
"version": env!("CARGO_PKG_VERSION")
|
|
306
|
-
},
|
|
307
|
-
"capabilities": {
|
|
308
|
-
"experimentalApi": true,
|
|
309
|
-
"requestAttestation": false
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}))?;
|
|
313
|
-
let _ = self.notify(json!({"method": "initialized"}));
|
|
314
|
-
let user_agent = result
|
|
315
|
-
.get("userAgent")
|
|
316
|
-
.and_then(Value::as_str)
|
|
317
|
-
.filter(|value| !value.is_empty())
|
|
318
|
-
.ok_or(AppServerError::MissingUserAgent)?;
|
|
319
|
-
if !user_agent.to_ascii_lowercase().contains("codex") {
|
|
320
|
-
return Err(AppServerError::ProtocolMismatch(format!(
|
|
321
|
-
"unexpected userAgent: {user_agent}"
|
|
322
|
-
)));
|
|
323
|
-
}
|
|
324
|
-
Ok(user_agent.to_string())
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
fn resume(&mut self, thread_id: &str) -> Result<ThreadResume, AppServerError> {
|
|
328
|
-
let result = self.request(json!({
|
|
329
|
-
"method": "thread/resume",
|
|
330
|
-
"params": {"threadId": thread_id}
|
|
331
|
-
}))?;
|
|
332
|
-
let thread = result
|
|
333
|
-
.get("thread")
|
|
334
|
-
.ok_or_else(|| AppServerError::ProtocolMismatch("missing thread".to_string()))?;
|
|
335
|
-
let actual_thread_id = required_str(thread, "id")?.to_string();
|
|
336
|
-
let session_id = required_str(thread, "sessionId")?.to_string();
|
|
337
|
-
let cwd = result
|
|
338
|
-
.get("cwd")
|
|
339
|
-
.and_then(Value::as_str)
|
|
340
|
-
.or_else(|| thread.get("cwd").and_then(Value::as_str))
|
|
341
|
-
.filter(|s| !s.is_empty())
|
|
342
|
-
.ok_or_else(|| AppServerError::ProtocolMismatch("missing cwd".to_string()))?
|
|
343
|
-
.to_string();
|
|
344
|
-
Ok(ThreadResume {
|
|
345
|
-
thread_id: actual_thread_id,
|
|
346
|
-
session_id,
|
|
347
|
-
cwd,
|
|
348
|
-
})
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
fn turn_start(
|
|
352
|
-
&mut self,
|
|
353
|
-
thread_id: &str,
|
|
354
|
-
message_id: &str,
|
|
355
|
-
rendered: &str,
|
|
356
|
-
) -> Result<AppServerSubmit, AppServerError> {
|
|
357
|
-
let result = self.request(json!({
|
|
358
|
-
"method": "turn/start",
|
|
359
|
-
"params": {
|
|
360
|
-
"threadId": thread_id,
|
|
361
|
-
"clientUserMessageId": message_id,
|
|
362
|
-
"input": [{
|
|
363
|
-
"type": "text",
|
|
364
|
-
"text": rendered,
|
|
365
|
-
"text_elements": []
|
|
366
|
-
}]
|
|
367
|
-
}
|
|
368
|
-
}))?;
|
|
369
|
-
let turn = result
|
|
370
|
-
.get("turn")
|
|
371
|
-
.ok_or_else(|| AppServerError::ProtocolMismatch("missing turn".to_string()))?;
|
|
372
|
-
let turn_id = required_str(turn, "id")?.to_string();
|
|
373
|
-
let status = required_str(turn, "status")?.to_string();
|
|
374
|
-
if status != "inProgress" {
|
|
375
|
-
return Err(AppServerError::ProtocolMismatch(format!(
|
|
376
|
-
"turn/start returned status {status}"
|
|
377
|
-
)));
|
|
378
|
-
}
|
|
379
|
-
Ok(AppServerSubmit {
|
|
380
|
-
turn_id,
|
|
381
|
-
turn_status: status,
|
|
382
|
-
})
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
fn notify(&mut self, mut payload: Value) -> Result<(), AppServerError> {
|
|
386
|
-
if let Some(obj) = payload.as_object_mut() {
|
|
387
|
-
obj.remove("id");
|
|
388
|
-
}
|
|
389
|
-
write_ws_text(&mut self.stream, &payload.to_string())
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
fn request(&mut self, mut payload: Value) -> Result<Value, AppServerError> {
|
|
393
|
-
let method = payload
|
|
394
|
-
.get("method")
|
|
395
|
-
.and_then(Value::as_str)
|
|
396
|
-
.unwrap_or("unknown")
|
|
397
|
-
.to_string();
|
|
398
|
-
let id = self.next_id;
|
|
399
|
-
self.next_id = self.next_id.saturating_add(1);
|
|
400
|
-
if let Some(obj) = payload.as_object_mut() {
|
|
401
|
-
obj.insert("id".to_string(), json!(id));
|
|
402
|
-
}
|
|
403
|
-
write_ws_text(&mut self.stream, &payload.to_string())?;
|
|
404
|
-
loop {
|
|
405
|
-
let frame = read_ws_text(&mut self.stream)?;
|
|
406
|
-
let value: Value = serde_json::from_str(&frame)
|
|
407
|
-
.map_err(|e| AppServerError::Json(format!("{e}: {frame}")))?;
|
|
408
|
-
if let Some(method) = value.get("method").and_then(Value::as_str) {
|
|
409
|
-
if is_approval_method(method) {
|
|
410
|
-
return Err(AppServerError::ApprovalUnsupported(method.to_string()));
|
|
411
|
-
}
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
if value.get("id").and_then(Value::as_u64) != Some(id) {
|
|
415
|
-
continue;
|
|
416
|
-
}
|
|
417
|
-
if let Some(error) = value.get("error") {
|
|
418
|
-
let message = error
|
|
419
|
-
.get("message")
|
|
420
|
-
.and_then(Value::as_str)
|
|
421
|
-
.unwrap_or("app-server request failed")
|
|
422
|
-
.to_string();
|
|
423
|
-
return match method.as_str() {
|
|
424
|
-
"thread/resume" => Err(AppServerError::ThreadNotLive(message)),
|
|
425
|
-
"turn/start" if looks_busy(&message) => {
|
|
426
|
-
Err(AppServerError::LeaderBusy(message))
|
|
427
|
-
}
|
|
428
|
-
"turn/start" => Err(AppServerError::ThreadNotLive(message)),
|
|
429
|
-
_ => Err(AppServerError::ProtocolMismatch(format!(
|
|
430
|
-
"{method} failed: {message}"
|
|
431
|
-
))),
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
return value
|
|
435
|
-
.get("result")
|
|
436
|
-
.cloned()
|
|
437
|
-
.ok_or_else(|| AppServerError::ProtocolMismatch("missing result".to_string()));
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
#[cfg(unix)]
|
|
443
|
-
fn is_approval_method(method: &str) -> bool {
|
|
444
|
-
method.contains("requestApproval")
|
|
445
|
-
|| method.contains("requestUserInput")
|
|
446
|
-
|| method.contains("elicitation/request")
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
#[cfg(unix)]
|
|
450
|
-
fn looks_busy(message: &str) -> bool {
|
|
451
|
-
let lower = message.to_ascii_lowercase();
|
|
452
|
-
lower.contains("active turn") || lower.contains("already has") || lower.contains("busy")
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
#[cfg(unix)]
|
|
456
|
-
fn read_http_response(stream: &mut UnixStream) -> Result<String, AppServerError> {
|
|
457
|
-
let mut data = Vec::new();
|
|
458
|
-
let mut buf = [0u8; 1];
|
|
459
|
-
while !data.ends_with(b"\r\n\r\n") {
|
|
460
|
-
stream
|
|
461
|
-
.read_exact(&mut buf)
|
|
462
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
463
|
-
data.push(buf[0]);
|
|
464
|
-
if data.len() > 64 * 1024 {
|
|
465
|
-
return Err(AppServerError::ProtocolMismatch(
|
|
466
|
-
"oversized websocket handshake".to_string(),
|
|
467
|
-
));
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
Ok(String::from_utf8_lossy(&data).to_string())
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
#[cfg(unix)]
|
|
474
|
-
fn write_ws_text(stream: &mut UnixStream, text: &str) -> Result<(), AppServerError> {
|
|
475
|
-
let payload = text.as_bytes();
|
|
476
|
-
let mut frame = vec![0x81];
|
|
477
|
-
if payload.len() < 126 {
|
|
478
|
-
frame.push(0x80 | payload.len() as u8);
|
|
479
|
-
} else if payload.len() <= u16::MAX as usize {
|
|
480
|
-
frame.push(0x80 | 126);
|
|
481
|
-
frame.extend_from_slice(&(payload.len() as u16).to_be_bytes());
|
|
482
|
-
} else {
|
|
483
|
-
frame.push(0x80 | 127);
|
|
484
|
-
frame.extend_from_slice(&(payload.len() as u64).to_be_bytes());
|
|
485
|
-
}
|
|
486
|
-
let mask = [0x54, 0x41, 0x47, 0x54];
|
|
487
|
-
frame.extend_from_slice(&mask);
|
|
488
|
-
for (idx, byte) in payload.iter().enumerate() {
|
|
489
|
-
frame.push(*byte ^ mask[idx % 4]);
|
|
490
|
-
}
|
|
491
|
-
stream
|
|
492
|
-
.write_all(&frame)
|
|
493
|
-
.map_err(|e| AppServerError::Io(e.to_string()))
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
#[cfg(unix)]
|
|
497
|
-
fn read_ws_text(stream: &mut UnixStream) -> Result<String, AppServerError> {
|
|
498
|
-
loop {
|
|
499
|
-
let mut header = [0u8; 2];
|
|
500
|
-
stream
|
|
501
|
-
.read_exact(&mut header)
|
|
502
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
503
|
-
let opcode = header[0] & 0x0f;
|
|
504
|
-
if opcode == 0x8 {
|
|
505
|
-
return Err(AppServerError::ProtocolMismatch(
|
|
506
|
-
"websocket closed".to_string(),
|
|
507
|
-
));
|
|
508
|
-
}
|
|
509
|
-
let masked = header[1] & 0x80 != 0;
|
|
510
|
-
let mut len = u64::from(header[1] & 0x7f);
|
|
511
|
-
if len == 126 {
|
|
512
|
-
let mut ext = [0u8; 2];
|
|
513
|
-
stream
|
|
514
|
-
.read_exact(&mut ext)
|
|
515
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
516
|
-
len = u64::from(u16::from_be_bytes(ext));
|
|
517
|
-
} else if len == 127 {
|
|
518
|
-
let mut ext = [0u8; 8];
|
|
519
|
-
stream
|
|
520
|
-
.read_exact(&mut ext)
|
|
521
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
522
|
-
len = u64::from_be_bytes(ext);
|
|
523
|
-
}
|
|
524
|
-
let mut mask = [0u8; 4];
|
|
525
|
-
if masked {
|
|
526
|
-
stream
|
|
527
|
-
.read_exact(&mut mask)
|
|
528
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
529
|
-
}
|
|
530
|
-
let size = usize::try_from(len).map_err(|_| {
|
|
531
|
-
AppServerError::ProtocolMismatch("websocket frame too large".to_string())
|
|
532
|
-
})?;
|
|
533
|
-
let mut payload = vec![0u8; size];
|
|
534
|
-
stream
|
|
535
|
-
.read_exact(&mut payload)
|
|
536
|
-
.map_err(|e| AppServerError::Io(e.to_string()))?;
|
|
537
|
-
if masked {
|
|
538
|
-
for (idx, byte) in payload.iter_mut().enumerate() {
|
|
539
|
-
*byte ^= mask[idx % 4];
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
if opcode == 0x1 {
|
|
543
|
-
return Ok(String::from_utf8_lossy(&payload).to_string());
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! Official communication modes shared by configuration and projection consumers.
|
|
3
|
-
|
|
4
|
-
/// The complete product-supported communication-mode catalog.
|
|
5
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
6
|
-
pub enum CommunicationMode {
|
|
7
|
-
LeaderCentric,
|
|
8
|
-
Orchestrated,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const LEADER_CENTRIC_RUNTIME_CONTRACT: &str = r#"# Team Agent communication contract: leader_centric
|
|
12
|
-
|
|
13
|
-
- Progress, blockers, questions: {send_message}(to='leader', content='...')
|
|
14
|
-
|
|
15
|
-
Respond through Team Agent MCP tools only to actionable requests or questions; writing in your terminal does not deliver it.
|
|
16
|
-
|
|
17
|
-
"#;
|
|
18
|
-
|
|
19
|
-
const ORCHESTRATED_RUNTIME_CONTRACT: &str = r#"# Team Agent communication contract: orchestrated
|
|
20
|
-
|
|
21
|
-
- Send progress only through the declared channel for the assigned task.
|
|
22
|
-
- Respond to task-related messages through Team Agent MCP tools.
|
|
23
|
-
- A pure ACK, unrelated status, or non-task message does not require a response."#;
|
|
24
|
-
|
|
25
|
-
impl CommunicationMode {
|
|
26
|
-
pub const ALL: &[Self] = &[Self::LeaderCentric, Self::Orchestrated];
|
|
27
|
-
|
|
28
|
-
pub const fn as_str(self) -> &'static str {
|
|
29
|
-
match self {
|
|
30
|
-
Self::LeaderCentric => "leader_centric",
|
|
31
|
-
Self::Orchestrated => "orchestrated",
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
pub fn parse(value: &str) -> Option<Self> {
|
|
36
|
-
Self::ALL
|
|
37
|
-
.iter()
|
|
38
|
-
.copied()
|
|
39
|
-
.find(|mode| mode.as_str() == value)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
pub fn runtime_contract(self, send_message: &str) -> String {
|
|
43
|
-
match self {
|
|
44
|
-
Self::LeaderCentric => {
|
|
45
|
-
LEADER_CENTRIC_RUNTIME_CONTRACT.replace("{send_message}", send_message)
|
|
46
|
-
}
|
|
47
|
-
Self::Orchestrated => ORCHESTRATED_RUNTIME_CONTRACT.to_string(),
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
impl Default for CommunicationMode {
|
|
53
|
-
fn default() -> Self {
|
|
54
|
-
Self::LeaderCentric
|
|
55
|
-
}
|
|
56
|
-
}
|