@team-agent/installer 0.5.128 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +37 -20
- package/skills/team-agent/command-coverage.json +169 -183
- package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +64 -30
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1288
- package/crates/team-agent/src/cli/arguments.rs +0 -405
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1721
- package/crates/team-agent/src/cli/emit.rs +0 -2930
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
- package/crates/team-agent/src/cli/intent/tests.rs +0 -689
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6545
- package/crates/team-agent/src/cli/models.rs +0 -1206
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/schedule.rs +0 -175
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -156
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -199
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -165
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -827
- package/crates/team-agent/src/compiler.rs +0 -890
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -364
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3024
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1527
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/direct_delivery.rs +0 -368
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/inbox_store.rs +0 -169
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -888
- package/crates/team-agent/src/leader/start.rs +0 -4501
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -147
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -557
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -227
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
- package/crates/team-agent/src/lifecycle/tests.rs +0 -105
- package/crates/team-agent/src/lifecycle/types.rs +0 -877
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -889
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3727
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -336
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -167
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/reminders.rs +0 -316
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -223
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -472
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -1150
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -708
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -910
- package/crates/team-agent/src/provider/session/capture.rs +0 -2731
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
- package/crates/team-agent/src/provider/session_scan.rs +0 -71
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
- package/crates/team-agent/src/provider/tests/classify.rs +0 -148
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -177
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -394
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
- package/crates/team-agent/src/tmux_backend.rs +0 -4492
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,1206 +0,0 @@
|
|
|
1
|
-
//! Read-only provider model catalog discovery for `team-agent models`.
|
|
2
|
-
use super::{CliError, CmdOutput, CmdResult, ExitCode, ModelsArgs};
|
|
3
|
-
use serde_json::{json, Value};
|
|
4
|
-
#[cfg(test)]
|
|
5
|
-
use std::collections::BTreeMap;
|
|
6
|
-
#[cfg(test)]
|
|
7
|
-
use std::path::Path;
|
|
8
|
-
#[cfg(test)]
|
|
9
|
-
use std::time::Duration;
|
|
10
|
-
|
|
11
|
-
#[cfg(test)]
|
|
12
|
-
const CATALOG_TIMEOUT: Duration = Duration::from_secs(10);
|
|
13
|
-
#[cfg(test)]
|
|
14
|
-
const MAX_CATALOG_BYTES: u64 = 1024 * 1024;
|
|
15
|
-
type ModelRecord = crate::provider::model_catalog::ModelRecord;
|
|
16
|
-
|
|
17
|
-
pub fn cmd_models(args: &ModelsArgs) -> Result<CmdResult, CliError> {
|
|
18
|
-
#[cfg(unix)]
|
|
19
|
-
if let Some(descriptor) = crate::contract_runtime::registry::declared(&args.provider) {
|
|
20
|
-
// A role's provider names its catalog: `agent` or `cursor-agent` is the
|
|
21
|
-
// Cursor leaf; `codex` and `grok` are the Codex and Grok Build leaves.
|
|
22
|
-
let args = ModelsArgs { provider: descriptor.identity.id.into(), ..args.clone() };
|
|
23
|
-
return crate::contract_runtime::discovery::models(&args);
|
|
24
|
-
}
|
|
25
|
-
let records = match crate::provider::model_catalog::discover_model_catalog(&args.provider) {
|
|
26
|
-
Ok(records) => records,
|
|
27
|
-
Err(error) => {
|
|
28
|
-
let message = error.message(&args.provider);
|
|
29
|
-
let action = error.action(&args.provider);
|
|
30
|
-
return Ok(failure_with_action(args, &message, &action));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
render_catalog(args, records)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
fn render_catalog(args: &ModelsArgs, all: Vec<ModelRecord>) -> Result<CmdResult, CliError> {
|
|
37
|
-
let visible = args.search.as_deref().map_or_else(
|
|
38
|
-
|| all.clone(),
|
|
39
|
-
|search| {
|
|
40
|
-
all.iter()
|
|
41
|
-
.filter(|model| crate::provider::model_catalog::model_matches(model, search))
|
|
42
|
-
.cloned()
|
|
43
|
-
.collect()
|
|
44
|
-
},
|
|
45
|
-
);
|
|
46
|
-
let current = if args.provider == "pi" {
|
|
47
|
-
current_role_model(&all.iter().map(|model| model.id.clone()).collect::<Vec<_>>())
|
|
48
|
-
} else {
|
|
49
|
-
None
|
|
50
|
-
};
|
|
51
|
-
let entries: Vec<Value> = visible.iter().map(|model| json!({
|
|
52
|
-
"role_model": model.id,
|
|
53
|
-
"current": if args.provider == "pi" { json!(current.as_deref() == Some(model.id.as_str())) } else { Value::Null },
|
|
54
|
-
"provider": model.provider,
|
|
55
|
-
"vendor": model.vendor,
|
|
56
|
-
"model_id": model.id,
|
|
57
|
-
"display_name": model.display_name,
|
|
58
|
-
"default": model.default,
|
|
59
|
-
"aliases": model.aliases,
|
|
60
|
-
})).collect();
|
|
61
|
-
let provider = args.provider.as_str();
|
|
62
|
-
let value = json!({
|
|
63
|
-
"schema_version": "models.v1", "ok": true, "provider": provider, "models": entries,
|
|
64
|
-
"auth": "ok", "auth_basis": "catalog_visibility", "current_role_model": current, "search": args.search,
|
|
65
|
-
});
|
|
66
|
-
if args.json {
|
|
67
|
-
Ok(CmdResult {
|
|
68
|
-
output: CmdOutput::Human(serde_json::to_string_pretty(&value)?),
|
|
69
|
-
exit: ExitCode::Ok,
|
|
70
|
-
as_json: false,
|
|
71
|
-
preserve_json_order: true,
|
|
72
|
-
})
|
|
73
|
-
} else {
|
|
74
|
-
let mut lines = vec![format!(
|
|
75
|
-
"models.v1 | {provider} models (copyable model_id):"
|
|
76
|
-
)];
|
|
77
|
-
lines.push("PROVIDER VENDOR MODEL_ID DISPLAY_NAME CURRENT DEFAULT".to_string());
|
|
78
|
-
lines.extend(visible.iter().map(|model| {
|
|
79
|
-
format!(
|
|
80
|
-
"{} {} {} {} {} {}",
|
|
81
|
-
model.provider,
|
|
82
|
-
model.vendor,
|
|
83
|
-
model.id,
|
|
84
|
-
model.display_name,
|
|
85
|
-
if args.provider == "pi" {
|
|
86
|
-
(current.as_deref() == Some(model.id.as_str())).to_string()
|
|
87
|
-
} else {
|
|
88
|
-
"—".to_string()
|
|
89
|
-
},
|
|
90
|
-
model
|
|
91
|
-
.default
|
|
92
|
-
.map_or_else(|| "—".to_string(), |value| value.to_string()),
|
|
93
|
-
)
|
|
94
|
-
}));
|
|
95
|
-
lines.push(format!(
|
|
96
|
-
"auth: ok (catalog_visibility); {} model(s)",
|
|
97
|
-
visible.len()
|
|
98
|
-
));
|
|
99
|
-
if visible.is_empty() {
|
|
100
|
-
lines.push("No models matched --search/query; rerun without a search to list the full catalog.".to_string());
|
|
101
|
-
}
|
|
102
|
-
Ok(CmdResult::human(lines.join("\n")))
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
#[cfg(test)]
|
|
107
|
-
fn cmd_models_with(
|
|
108
|
-
args: &ModelsArgs,
|
|
109
|
-
program: &Path,
|
|
110
|
-
timeout: Duration,
|
|
111
|
-
max_bytes: u64,
|
|
112
|
-
) -> Result<CmdResult, CliError> {
|
|
113
|
-
let bytes = match run_catalog(program, timeout, max_bytes) {
|
|
114
|
-
Ok(bytes) => bytes,
|
|
115
|
-
Err(message) => return Ok(failure(args, &message)),
|
|
116
|
-
};
|
|
117
|
-
let all = match crate::provider::model_catalog::parse_pi_catalog(&bytes).map_err(|error| error.message("pi")) {
|
|
118
|
-
Ok(models) => models,
|
|
119
|
-
Err(message) => return Ok(failure(args, &message)),
|
|
120
|
-
};
|
|
121
|
-
render_catalog(args, all)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
#[cfg(test)]
|
|
125
|
-
fn model_matches(model: &ModelRecord, search: &str) -> bool {
|
|
126
|
-
crate::provider::model_catalog::model_matches(model, search)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
#[cfg(test)]
|
|
130
|
-
fn failure(args: &ModelsArgs, message: &str) -> CmdResult {
|
|
131
|
-
let action = if message.starts_with("unsupported model provider") {
|
|
132
|
-
"choose a supported provider: pi, codex, claude, or claude_code".to_string()
|
|
133
|
-
} else {
|
|
134
|
-
let executable = match args.provider.as_str() {
|
|
135
|
-
"codex" => "codex",
|
|
136
|
-
"claude" | "claude_code" => "claude",
|
|
137
|
-
_ => "pi",
|
|
138
|
-
};
|
|
139
|
-
format!("install or repair the PATH-first `{executable}` executable, then retry `team-agent models --provider {}`", args.provider)
|
|
140
|
-
};
|
|
141
|
-
failure_with_action(args, message, &action)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
fn failure_with_action(args: &ModelsArgs, message: &str, action: &str) -> CmdResult {
|
|
145
|
-
let value = json!({ "schema_version": "models.v1", "ok": false, "provider": args.provider, "auth": "not_ready", "auth_basis": "catalog_visibility", "models": Value::Array(Vec::new()), "current_role_model": Value::Null, "error": message, "action": action });
|
|
146
|
-
if args.json {
|
|
147
|
-
let text = serde_json::to_string_pretty(&value)
|
|
148
|
-
.unwrap_or_else(|_| "{\"schema_version\":\"models.v1\",\"ok\":false}".to_string());
|
|
149
|
-
CmdResult {
|
|
150
|
-
output: CmdOutput::Human(text),
|
|
151
|
-
exit: ExitCode::Error,
|
|
152
|
-
as_json: false,
|
|
153
|
-
preserve_json_order: true,
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
CmdResult { output: CmdOutput::Human(format!("models.v1 | error: {message}\naction: {action}\nauth: not_ready (catalog_visibility)")), exit: ExitCode::Error, as_json: false, preserve_json_order: false }
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
fn current_role_model(models: &[String]) -> Option<String> {
|
|
160
|
-
current_role_model_from(
|
|
161
|
-
models,
|
|
162
|
-
std::env::var("PI_PROVIDER").ok().as_deref(),
|
|
163
|
-
std::env::var("PI_MODEL").ok().as_deref(),
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
fn current_role_model_from(
|
|
167
|
-
models: &[String],
|
|
168
|
-
provider: Option<&str>,
|
|
169
|
-
model: Option<&str>,
|
|
170
|
-
) -> Option<String> {
|
|
171
|
-
let exact = format!("{}/{}", provider?, model?);
|
|
172
|
-
models
|
|
173
|
-
.iter()
|
|
174
|
-
.any(|candidate| candidate == &exact)
|
|
175
|
-
.then_some(exact)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/// Injectable executable, deadline, and byte-limit boundary for deterministic tests.
|
|
179
|
-
#[cfg(test)]
|
|
180
|
-
fn run_catalog(program: &Path, timeout: Duration, max_bytes: u64) -> Result<Vec<u8>, String> {
|
|
181
|
-
crate::lifecycle::launch::pi_mcp::run_pi_catalog(program, timeout, max_bytes)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
#[cfg(test)]
|
|
185
|
-
mod tests {
|
|
186
|
-
use super::*;
|
|
187
|
-
#[cfg(unix)]
|
|
188
|
-
use std::io::Write;
|
|
189
|
-
#[cfg(unix)]
|
|
190
|
-
use std::sync::atomic::{AtomicU64, Ordering};
|
|
191
|
-
use std::time::Instant;
|
|
192
|
-
|
|
193
|
-
#[cfg(unix)]
|
|
194
|
-
static FIXTURE_SEQUENCE: AtomicU64 = AtomicU64::new(0);
|
|
195
|
-
|
|
196
|
-
#[cfg(unix)]
|
|
197
|
-
#[test]
|
|
198
|
-
fn real_dispatcher_child_helper() {
|
|
199
|
-
if std::env::var_os("TEAM_AGENT_MODELS_CHILD").is_none() {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
let args: Vec<String> =
|
|
203
|
-
serde_json::from_str(&std::env::var("TEAM_AGENT_MODELS_ARGS").unwrap()).unwrap();
|
|
204
|
-
print!("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n");
|
|
205
|
-
use std::io::Write;
|
|
206
|
-
std::io::stdout().flush().unwrap();
|
|
207
|
-
let exit = crate::cli::emit::run(&args, Path::new("/tmp"));
|
|
208
|
-
std::process::exit(exit.code());
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
#[cfg(unix)]
|
|
212
|
-
#[test]
|
|
213
|
-
fn real_dispatcher_isolated_success_json_human_and_no_match() {
|
|
214
|
-
let pi = fixture("printf 'provider model\\nopenai-codex gpt-5.6-sol\\n'");
|
|
215
|
-
let dir = pi.parent().unwrap().to_path_buf();
|
|
216
|
-
let run_child = |args: &[&str], model: &str| {
|
|
217
|
-
std::process::Command::new(std::env::current_exe().unwrap())
|
|
218
|
-
.args([
|
|
219
|
-
"--exact",
|
|
220
|
-
"cli::models::tests::real_dispatcher_child_helper",
|
|
221
|
-
"--nocapture",
|
|
222
|
-
])
|
|
223
|
-
.env("TEAM_AGENT_MODELS_CHILD", "1")
|
|
224
|
-
.env(
|
|
225
|
-
"TEAM_AGENT_MODELS_ARGS",
|
|
226
|
-
serde_json::to_string(args).unwrap(),
|
|
227
|
-
)
|
|
228
|
-
.env("PATH", &dir)
|
|
229
|
-
.env("PI_PROVIDER", "openai-codex")
|
|
230
|
-
.env("PI_MODEL", model)
|
|
231
|
-
.output()
|
|
232
|
-
.unwrap()
|
|
233
|
-
};
|
|
234
|
-
let json = run_child(&["models", "--provider", "pi", "--json"], "gpt-5.6-sol");
|
|
235
|
-
assert!(json.status.success());
|
|
236
|
-
let output = String::from_utf8(json.stdout).unwrap();
|
|
237
|
-
let cli_output = output
|
|
238
|
-
.split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
|
|
239
|
-
.nth(1)
|
|
240
|
-
.unwrap();
|
|
241
|
-
let value: Value = serde_json::from_str(cli_output.trim()).unwrap();
|
|
242
|
-
assert_eq!(value["schema_version"], "models.v1");
|
|
243
|
-
assert_eq!(value["models"][0]["role_model"], "openai-codex/gpt-5.6-sol");
|
|
244
|
-
assert_eq!(value["models"][0]["current"], true);
|
|
245
|
-
let human = run_child(
|
|
246
|
-
&["models", "--provider", "pi", "--search", "absent"],
|
|
247
|
-
"missing",
|
|
248
|
-
);
|
|
249
|
-
assert!(human.status.success());
|
|
250
|
-
let human_output = String::from_utf8(human.stdout).unwrap();
|
|
251
|
-
let text = human_output
|
|
252
|
-
.split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
|
|
253
|
-
.nth(1)
|
|
254
|
-
.unwrap();
|
|
255
|
-
assert!(text.contains("No models matched --search") && text.contains("auth: ok"));
|
|
256
|
-
let null = run_child(&["models", "--provider", "pi", "--json"], "missing");
|
|
257
|
-
let null_output = String::from_utf8(null.stdout).unwrap();
|
|
258
|
-
let null_cli = null_output
|
|
259
|
-
.split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
|
|
260
|
-
.nth(1)
|
|
261
|
-
.unwrap();
|
|
262
|
-
let null_value: Value = serde_json::from_str(null_cli.trim()).unwrap();
|
|
263
|
-
assert!(null.status.success() && null_value["current_role_model"].is_null());
|
|
264
|
-
std::fs::write(&pi, "#!/bin/sh\nprintf 'sensitive-stderr' >&2\nexit 7\n").unwrap();
|
|
265
|
-
let failed = run_child(&["models", "--provider", "pi", "--json"], "missing");
|
|
266
|
-
assert!(!failed.status.success());
|
|
267
|
-
let failed_output = String::from_utf8(failed.stdout).unwrap();
|
|
268
|
-
let failed_cli = failed_output
|
|
269
|
-
.split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
|
|
270
|
-
.nth(1)
|
|
271
|
-
.unwrap();
|
|
272
|
-
assert!(!failed_cli.contains("sensitive-stderr"));
|
|
273
|
-
assert_eq!(
|
|
274
|
-
std::fs::read_to_string(pi.with_extension("count"))
|
|
275
|
-
.unwrap()
|
|
276
|
-
.lines()
|
|
277
|
-
.count(),
|
|
278
|
-
3
|
|
279
|
-
);
|
|
280
|
-
cleanup_fixture(&pi);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
#[test]
|
|
284
|
-
fn current_model_is_deterministic() {
|
|
285
|
-
let models = vec!["openai-codex/gpt-5.6-sol".into()];
|
|
286
|
-
assert_eq!(
|
|
287
|
-
current_role_model_from(&models, Some("openai-codex"), Some("gpt-5.6-sol")),
|
|
288
|
-
Some("openai-codex/gpt-5.6-sol".into())
|
|
289
|
-
);
|
|
290
|
-
assert_eq!(
|
|
291
|
-
current_role_model_from(&models, Some("openai-codex"), Some("other")),
|
|
292
|
-
None
|
|
293
|
-
);
|
|
294
|
-
assert_eq!(
|
|
295
|
-
current_role_model_from(&models, None, Some("gpt-5.6-sol")),
|
|
296
|
-
None
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
#[cfg(unix)]
|
|
301
|
-
#[test]
|
|
302
|
-
fn search_survives_unrelated_spaced_model_ids() {
|
|
303
|
-
let catalog =
|
|
304
|
-
include_str!("../lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt");
|
|
305
|
-
let path = fixture(&format!("printf '%s' '{catalog}'"));
|
|
306
|
-
let result = cmd_models_with(
|
|
307
|
-
&ModelsArgs {
|
|
308
|
-
provider: "pi".into(),
|
|
309
|
-
search: Some("gpt-5.6-luna".into()),
|
|
310
|
-
json: true,
|
|
311
|
-
},
|
|
312
|
-
&path,
|
|
313
|
-
Duration::from_secs(10),
|
|
314
|
-
MAX_CATALOG_BYTES,
|
|
315
|
-
)
|
|
316
|
-
.unwrap();
|
|
317
|
-
cleanup_fixture(&path);
|
|
318
|
-
assert_eq!(result.exit, ExitCode::Ok);
|
|
319
|
-
let CmdOutput::Human(text) = result.output else {
|
|
320
|
-
panic!("expected JSON projection")
|
|
321
|
-
};
|
|
322
|
-
let value: Value = serde_json::from_str(&text).unwrap();
|
|
323
|
-
assert_eq!(value["ok"], true);
|
|
324
|
-
assert_eq!(value["auth"], "ok");
|
|
325
|
-
let models = value["models"].as_array().unwrap();
|
|
326
|
-
assert_eq!(models.len(), 2);
|
|
327
|
-
assert_eq!(models[0]["role_model"], "openai-codex/gpt-5.6-luna");
|
|
328
|
-
assert_eq!(models[1]["role_model"], "team-agent/gpt-5.6-luna");
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
#[cfg(unix)]
|
|
332
|
-
#[test]
|
|
333
|
-
fn cursor_contract_catalog_uses_public_launcher_metadata_then_exact_ids() {
|
|
334
|
-
let program = fixture_program("cursor-agent", r#"
|
|
335
|
-
test "$#" = 1 || exit 9
|
|
336
|
-
case "$1" in
|
|
337
|
-
--version) printf '%s\n' '2026.10.01-a1b2c3' ;;
|
|
338
|
-
--list-models) exec /bin/cat "$TEAM_AGENT_MODELS_FIXTURE" ;;
|
|
339
|
-
*) exit 9 ;;
|
|
340
|
-
esac"#);
|
|
341
|
-
let mut cursor = CliFixture::new(program);
|
|
342
|
-
let response = cursor.program.with_extension("stdout");
|
|
343
|
-
std::fs::write(&response, include_bytes!("../../../team-agent-contract/tests/fixtures/cursor-2026.10.01-models.txt")).unwrap();
|
|
344
|
-
cursor.response = Some(response);
|
|
345
|
-
let output = run_public_models_cli(&cursor.program, cursor.response.as_deref(),
|
|
346
|
-
&["models", "--provider", "cursor", "--search", "gpt-5.6-luna-xhigh", "--json"]);
|
|
347
|
-
let text = public_cli_text(&output);
|
|
348
|
-
let calls = std::fs::read_to_string(cursor.program.with_extension("count")).unwrap();
|
|
349
|
-
assert!(output.status.success(), "{text}");
|
|
350
|
-
assert_eq!(calls, "1:--version\n1:--list-models\n");
|
|
351
|
-
let value: Value = serde_json::from_str(text.trim()).unwrap();
|
|
352
|
-
assert_eq!(value["provider"], "cursor");
|
|
353
|
-
assert_eq!(value["auth"], "unknown");
|
|
354
|
-
assert_eq!(value["source"]["schema"], "cursor-list-models-text-v1");
|
|
355
|
-
assert_eq!(value["source"]["identity_scope"], "catalog_only");
|
|
356
|
-
assert!(value["models"].as_array().unwrap().iter().any(|row| row["model_id"] == "gpt-5.6-luna-xhigh"));
|
|
357
|
-
assert!(value["models"].as_array().unwrap().iter().all(|row| row["role_model"] == row["model_id"]));
|
|
358
|
-
assert!(value["current_role_model"].is_null());
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
#[cfg(unix)]
|
|
362
|
-
#[test]
|
|
363
|
-
fn grok_build_contract_catalog_runs_the_public_grok_found_on_path() {
|
|
364
|
-
// The public `grok` provider name declares the Grok Build leaf; both
|
|
365
|
-
// names read the same contract catalog.
|
|
366
|
-
for name in ["grok_build", "grok"] {
|
|
367
|
-
let program = fixture_program("grok", r#"
|
|
368
|
-
test "$#" = 1 || exit 9
|
|
369
|
-
case "$1" in
|
|
370
|
-
--version) printf '%s\n' 'grok 1.0.52 (0920c8169e27)' ;;
|
|
371
|
-
models) exec /bin/cat "$TEAM_AGENT_MODELS_FIXTURE" ;;
|
|
372
|
-
*) exit 9 ;;
|
|
373
|
-
esac"#);
|
|
374
|
-
let mut grok = CliFixture::new(program);
|
|
375
|
-
let response = grok.program.with_extension("stdout");
|
|
376
|
-
std::fs::write(&response, include_bytes!("../provider/testdata/grok-models-authenticated.stdout")).unwrap();
|
|
377
|
-
grok.response = Some(response);
|
|
378
|
-
let output = run_public_models_cli(&grok.program, grok.response.as_deref(),
|
|
379
|
-
&["models", "--provider", name, "--json"]);
|
|
380
|
-
let text = public_cli_text(&output);
|
|
381
|
-
let calls = std::fs::read_to_string(grok.program.with_extension("count")).unwrap_or_default();
|
|
382
|
-
assert!(output.status.success(), "{name}: {text}");
|
|
383
|
-
// Whatever `grok` PATH selects answers every probe; no install path is assumed.
|
|
384
|
-
assert_eq!(calls, "1:--version\n1:models\n", "{name}");
|
|
385
|
-
let value: Value = serde_json::from_str(text.trim()).unwrap();
|
|
386
|
-
assert_eq!(value["provider"], "grok_build", "{name}");
|
|
387
|
-
assert_eq!(value["source"]["executable"], grok.program.to_str().unwrap(), "{name}");
|
|
388
|
-
assert!(value["models"].as_array().unwrap().iter().any(|row| row["model_id"] == "grok-4.7-build-fast"), "{name}");
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
#[cfg(unix)]
|
|
393
|
-
#[test]
|
|
394
|
-
fn every_cursor_provider_name_reads_the_contract_catalog_through_cursor_agent() {
|
|
395
|
-
use std::os::unix::fs::PermissionsExt;
|
|
396
|
-
for name in ["cursor_agent", "cursor-agent", "agent"] {
|
|
397
|
-
let mut cursor = CliFixture::new(fixture_program("cursor-agent", r#"
|
|
398
|
-
test "$#" = 1 || exit 9
|
|
399
|
-
case "$1" in
|
|
400
|
-
--version) printf '%s\n' '2026.10.01-a1b2c3' ;;
|
|
401
|
-
--list-models) exec /bin/cat "$TEAM_AGENT_MODELS_FIXTURE" ;;
|
|
402
|
-
*) exit 9 ;;
|
|
403
|
-
esac"#));
|
|
404
|
-
let response = cursor.program.with_extension("stdout");
|
|
405
|
-
std::fs::write(&response, include_bytes!("../../../team-agent-contract/tests/fixtures/cursor-2026.10.01-models.txt")).unwrap();
|
|
406
|
-
cursor.response = Some(response);
|
|
407
|
-
// The legacy binary name on PATH is never what runs.
|
|
408
|
-
let legacy = cursor.program.parent().unwrap().join("agent");
|
|
409
|
-
std::fs::write(&legacy, "#!/bin/sh\nprintf 'called' > \"$0.called\"\nexit 9\n").unwrap();
|
|
410
|
-
std::fs::set_permissions(&legacy, std::fs::Permissions::from_mode(0o700)).unwrap();
|
|
411
|
-
let output = run_public_models_cli(&cursor.program, cursor.response.as_deref(),
|
|
412
|
-
&["models", "--provider", name, "--json"]);
|
|
413
|
-
let text = public_cli_text(&output);
|
|
414
|
-
assert!(output.status.success(), "{name}: {text}");
|
|
415
|
-
assert_eq!(std::fs::read_to_string(cursor.program.with_extension("count")).unwrap(),
|
|
416
|
-
"1:--version\n1:--list-models\n", "{name}");
|
|
417
|
-
assert!(!legacy.with_extension("called").exists(), "{name}");
|
|
418
|
-
let value: Value = serde_json::from_str(text.trim()).unwrap();
|
|
419
|
-
assert_eq!(value["provider"], "cursor", "{name}");
|
|
420
|
-
assert!(value["models"].as_array().unwrap().iter().any(|row| row["model_id"] == "gpt-5.6-luna-xhigh"), "{name}");
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
#[cfg(unix)]
|
|
425
|
-
#[test]
|
|
426
|
-
fn cursor_contract_bad_version_has_no_legacy_entrypoint_fallback() {
|
|
427
|
-
use std::os::unix::fs::PermissionsExt;
|
|
428
|
-
let cursor = CliFixture::new(fixture_program("cursor-agent", "printf '%s\\n' 'Cursor release unknown'"));
|
|
429
|
-
let legacy = cursor.program.parent().unwrap().join("agent");
|
|
430
|
-
std::fs::write(&legacy, "#!/bin/sh\nprintf 'called' > \"$0.called\"\nexit 9\n").unwrap();
|
|
431
|
-
std::fs::set_permissions(&legacy, std::fs::Permissions::from_mode(0o700)).unwrap();
|
|
432
|
-
let output = run_public_models_cli(&cursor.program, None,
|
|
433
|
-
&["models", "--provider", "cursor", "--json"]);
|
|
434
|
-
let text = public_cli_text(&output);
|
|
435
|
-
assert!(!output.status.success(), "{text}");
|
|
436
|
-
assert_eq!(std::fs::read_to_string(cursor.program.with_extension("count")).unwrap(), "1:--version\n");
|
|
437
|
-
assert!(!legacy.with_extension("called").exists());
|
|
438
|
-
let value: Value = serde_json::from_str(text.trim()).unwrap();
|
|
439
|
-
assert_eq!(value["provider"], "cursor");
|
|
440
|
-
assert_eq!(value["ok"], false);
|
|
441
|
-
assert_eq!(value["models"], json!([]));
|
|
442
|
-
assert!(value["error"].as_str().unwrap().contains("Cursor release unknown"));
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
#[cfg(unix)]
|
|
446
|
-
#[test]
|
|
447
|
-
fn grok_failure_help_and_unsupported_action_are_publicly_diagnostic() {
|
|
448
|
-
let missing = CliFixture::new(fixture_program("not-grok", "exit 0"));
|
|
449
|
-
let output = run_public_models_cli(
|
|
450
|
-
&missing.program,
|
|
451
|
-
None,
|
|
452
|
-
&["models", "--provider", "grok", "--json"],
|
|
453
|
-
);
|
|
454
|
-
let text = public_cli_text(&output);
|
|
455
|
-
let value: Value = serde_json::from_str(text.trim()).unwrap();
|
|
456
|
-
// `grok` reads the Grok Build leaf catalog; a missing PATH `grok` fails
|
|
457
|
-
// closed there with no legacy catalog fallback.
|
|
458
|
-
assert_eq!(value["ok"], false);
|
|
459
|
-
assert_eq!(value["provider"], "grok_build", "{text}");
|
|
460
|
-
assert_eq!(value["models"], json!([]), "{text}");
|
|
461
|
-
assert!(
|
|
462
|
-
value["error"]
|
|
463
|
-
.as_str()
|
|
464
|
-
.unwrap()
|
|
465
|
-
.to_ascii_lowercase()
|
|
466
|
-
.contains("grok"),
|
|
467
|
-
"{text}"
|
|
468
|
-
);
|
|
469
|
-
assert!(crate::cli::emit::default_help().contains("grok"));
|
|
470
|
-
assert!(crate::cli::spec::command_spec("models")
|
|
471
|
-
.unwrap()
|
|
472
|
-
.usage
|
|
473
|
-
.contains("grok"));
|
|
474
|
-
|
|
475
|
-
let unsupported = run_public_models_cli(
|
|
476
|
-
&missing.program,
|
|
477
|
-
None,
|
|
478
|
-
&["models", "--provider", "cloud", "--json"],
|
|
479
|
-
);
|
|
480
|
-
let unsupported_text = public_cli_text(&unsupported);
|
|
481
|
-
let unsupported_value: Value = serde_json::from_str(unsupported_text.trim()).unwrap();
|
|
482
|
-
drop(missing);
|
|
483
|
-
assert!(!output.status.success());
|
|
484
|
-
assert!(!unsupported.status.success());
|
|
485
|
-
assert!(
|
|
486
|
-
unsupported_value["action"]
|
|
487
|
-
.as_str()
|
|
488
|
-
.unwrap()
|
|
489
|
-
.contains("grok"),
|
|
490
|
-
"{unsupported_text}"
|
|
491
|
-
);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
#[cfg(unix)]
|
|
495
|
-
fn fixture(body: &str) -> std::path::PathBuf {
|
|
496
|
-
fixture_program("pi", body)
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
#[cfg(unix)]
|
|
500
|
-
fn fixture_program(program: &str, body: &str) -> std::path::PathBuf {
|
|
501
|
-
let sequence = FIXTURE_SEQUENCE.fetch_add(1, Ordering::Relaxed);
|
|
502
|
-
let root = std::env::current_exe()
|
|
503
|
-
.unwrap()
|
|
504
|
-
.parent()
|
|
505
|
-
.unwrap()
|
|
506
|
-
.join(format!(
|
|
507
|
-
"team-agent-{program}-fixture-{}-{}-{sequence}",
|
|
508
|
-
std::process::id(),
|
|
509
|
-
std::time::SystemTime::now()
|
|
510
|
-
.duration_since(std::time::UNIX_EPOCH)
|
|
511
|
-
.unwrap()
|
|
512
|
-
.as_nanos()
|
|
513
|
-
));
|
|
514
|
-
std::fs::create_dir(&root).unwrap();
|
|
515
|
-
let path = root.join(program);
|
|
516
|
-
install_executable(
|
|
517
|
-
&path,
|
|
518
|
-
&format!("#!/bin/sh\nprintf '%s\\n' \"$#:$1\" >> \"$0.count\"\n{body}\n"),
|
|
519
|
-
);
|
|
520
|
-
path
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/// Linux refuses to exec an inode still open for writing anywhere (ETXTBSY),
|
|
524
|
-
/// and a parallel test's fork can briefly inherit our write fd. Only a
|
|
525
|
-
/// short-lived `cp` ever writes the executable, so no test thread holds it.
|
|
526
|
-
#[cfg(unix)]
|
|
527
|
-
fn install_executable(path: &Path, script: &str) {
|
|
528
|
-
use std::os::unix::fs::PermissionsExt;
|
|
529
|
-
let staged = path.with_extension("staged");
|
|
530
|
-
std::fs::write(&staged, script).unwrap();
|
|
531
|
-
let copied = std::process::Command::new("/bin/cp")
|
|
532
|
-
.arg(&staged)
|
|
533
|
-
.arg(path)
|
|
534
|
-
.status()
|
|
535
|
-
.unwrap();
|
|
536
|
-
assert!(
|
|
537
|
-
copied.success(),
|
|
538
|
-
"install fixture executable {}",
|
|
539
|
-
path.display()
|
|
540
|
-
);
|
|
541
|
-
std::fs::remove_file(&staged).unwrap();
|
|
542
|
-
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o700)).unwrap();
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
#[cfg(unix)]
|
|
546
|
-
struct CliFixture {
|
|
547
|
-
program: std::path::PathBuf,
|
|
548
|
-
response: Option<std::path::PathBuf>,
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
#[cfg(unix)]
|
|
552
|
-
impl CliFixture {
|
|
553
|
-
fn new(program: std::path::PathBuf) -> Self {
|
|
554
|
-
Self {
|
|
555
|
-
program,
|
|
556
|
-
response: None,
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
#[cfg(unix)]
|
|
562
|
-
impl Drop for CliFixture {
|
|
563
|
-
fn drop(&mut self) {
|
|
564
|
-
cleanup_fixture(&self.program);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
#[cfg(unix)]
|
|
569
|
-
fn run_public_models_cli(
|
|
570
|
-
path: &Path,
|
|
571
|
-
response: Option<&Path>,
|
|
572
|
-
args: &[&str],
|
|
573
|
-
) -> std::process::Output {
|
|
574
|
-
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
|
|
575
|
-
command
|
|
576
|
-
.args([
|
|
577
|
-
"--exact",
|
|
578
|
-
"cli::models::tests::real_dispatcher_child_helper",
|
|
579
|
-
"--nocapture",
|
|
580
|
-
])
|
|
581
|
-
.env("TEAM_AGENT_MODELS_CHILD", "1")
|
|
582
|
-
.env(
|
|
583
|
-
"TEAM_AGENT_MODELS_ARGS",
|
|
584
|
-
serde_json::to_string(args).unwrap(),
|
|
585
|
-
)
|
|
586
|
-
.env("PATH", path.parent().unwrap())
|
|
587
|
-
.env_remove("PI_PROVIDER")
|
|
588
|
-
.env_remove("PI_MODEL")
|
|
589
|
-
.env_remove("TEAM_AGENT_MODELS_FIXTURE");
|
|
590
|
-
if let Some(response) = response {
|
|
591
|
-
command.env("TEAM_AGENT_MODELS_FIXTURE", response);
|
|
592
|
-
}
|
|
593
|
-
command.output().unwrap()
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
#[cfg(unix)]
|
|
597
|
-
fn public_cli_text(output: &std::process::Output) -> String {
|
|
598
|
-
String::from_utf8(output.stdout.clone())
|
|
599
|
-
.unwrap()
|
|
600
|
-
.split("__TEAM_AGENT_MODELS_CLI_OUTPUT_v1__\n")
|
|
601
|
-
.nth(1)
|
|
602
|
-
.expect("public CLI child output marker")
|
|
603
|
-
.to_string()
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
#[cfg(unix)]
|
|
607
|
-
fn fixture_with_sidecars(body: &str) -> std::path::PathBuf {
|
|
608
|
-
let path = fixture(body);
|
|
609
|
-
let script = std::fs::read_to_string(&path).unwrap();
|
|
610
|
-
let script = script.strip_prefix("#!/bin/sh\n").unwrap();
|
|
611
|
-
let script = format!(
|
|
612
|
-
"#!/bin/sh\nprintf '1\\n' > \"$0.entered\" || :\n{script}body_status=$?\nprintf '1\\n' > \"$0.completed\" || :\nexit \"$body_status\"\n"
|
|
613
|
-
);
|
|
614
|
-
install_executable(&path, &script);
|
|
615
|
-
path
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
#[cfg(unix)]
|
|
619
|
-
fn cleanup_fixture(path: &Path) {
|
|
620
|
-
let _ = std::fs::remove_dir_all(path.parent().unwrap());
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
#[cfg(unix)]
|
|
624
|
-
fn native_timeout_fixture() -> std::path::PathBuf {
|
|
625
|
-
let path = std::path::PathBuf::from(env!("TEAM_AGENT_MODELS_TIMEOUT_FIXTURE"));
|
|
626
|
-
assert!(path.is_file(), "prebuilt models timeout fixture is missing");
|
|
627
|
-
path
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
#[cfg(unix)]
|
|
631
|
-
fn native_timeout_receipt() -> std::path::PathBuf {
|
|
632
|
-
let stamp = std::time::SystemTime::now()
|
|
633
|
-
.duration_since(std::time::UNIX_EPOCH)
|
|
634
|
-
.unwrap()
|
|
635
|
-
.as_nanos();
|
|
636
|
-
std::path::PathBuf::from("/tmp").join(format!(
|
|
637
|
-
"team-agent-models-timeout-{}-{stamp}.receipt",
|
|
638
|
-
std::process::id()
|
|
639
|
-
))
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
#[cfg(unix)]
|
|
643
|
-
fn native_timeout_stage_receipt(receipt: &Path) -> std::path::PathBuf {
|
|
644
|
-
receipt.with_extension("stage")
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
#[cfg(unix)]
|
|
648
|
-
fn parse_native_timeout_receipt(path: &Path) -> Option<BTreeMap<String, String>> {
|
|
649
|
-
let mut fields = BTreeMap::new();
|
|
650
|
-
for line in std::fs::read_to_string(path).ok()?.lines() {
|
|
651
|
-
let (key, value) = line.split_once('=')?;
|
|
652
|
-
if fields.insert(key.to_string(), value.to_string()).is_some() {
|
|
653
|
-
return None;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
let keys = fields.keys().map(String::as_str).collect::<Vec<_>>();
|
|
657
|
-
(keys
|
|
658
|
-
== vec![
|
|
659
|
-
"child_argv_exact",
|
|
660
|
-
"child_pid",
|
|
661
|
-
"child_spawn_attempts",
|
|
662
|
-
"descendant_pid",
|
|
663
|
-
"descendant_started",
|
|
664
|
-
"descendant_stdout_inherited",
|
|
665
|
-
"parent_argv_exact",
|
|
666
|
-
"parent_pid",
|
|
667
|
-
"parent_started_once",
|
|
668
|
-
])
|
|
669
|
-
.then_some(fields)
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
#[cfg(unix)]
|
|
673
|
-
fn wait_native_timeout_receipt(path: &Path) -> BTreeMap<String, String> {
|
|
674
|
-
let deadline = Instant::now() + Duration::from_millis(500);
|
|
675
|
-
loop {
|
|
676
|
-
if let Some(fields) = parse_native_timeout_receipt(path) {
|
|
677
|
-
return fields;
|
|
678
|
-
}
|
|
679
|
-
if Instant::now() >= deadline {
|
|
680
|
-
panic!("native timeout receipt did not become complete after runner return");
|
|
681
|
-
}
|
|
682
|
-
std::thread::sleep(Duration::from_millis(1));
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
#[cfg(unix)]
|
|
687
|
-
fn with_native_mode<T>(
|
|
688
|
-
mode: &str,
|
|
689
|
-
action: impl FnOnce() -> T,
|
|
690
|
-
) -> (
|
|
691
|
-
T,
|
|
692
|
-
crate::lifecycle::launch::pi_mcp::PiCatalogTestObservation,
|
|
693
|
-
) {
|
|
694
|
-
let receipt = native_timeout_receipt();
|
|
695
|
-
assert!(!receipt.exists());
|
|
696
|
-
let result = crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
|
|
697
|
-
&receipt,
|
|
698
|
-
Some(mode),
|
|
699
|
-
action,
|
|
700
|
-
);
|
|
701
|
-
assert!(!receipt.exists());
|
|
702
|
-
let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
|
|
703
|
-
result
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
#[cfg(unix)]
|
|
707
|
-
fn safe_fixture_sidecar(path: &Path, expected: &str) -> &'static str {
|
|
708
|
-
match std::fs::read_to_string(path) {
|
|
709
|
-
Ok(text) if text == expected => "present_expected",
|
|
710
|
-
Ok(_) => "present_unexpected",
|
|
711
|
-
Err(error) if error.kind() == std::io::ErrorKind::NotFound => "missing",
|
|
712
|
-
Err(_) => "unavailable",
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
#[cfg(unix)]
|
|
717
|
-
fn safe_runner_fixture_observation(path: &Path) -> String {
|
|
718
|
-
format!(
|
|
719
|
-
"fixture_entered={} fixture_completed={} fixture_count={}",
|
|
720
|
-
safe_fixture_sidecar(&path.with_extension("entered"), "1\n"),
|
|
721
|
-
safe_fixture_sidecar(&path.with_extension("completed"), "1\n"),
|
|
722
|
-
safe_fixture_sidecar(&path.with_extension("count"), "1:--list-models\n"),
|
|
723
|
-
)
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
#[cfg(unix)]
|
|
727
|
-
fn safe_runner_observation(
|
|
728
|
-
elapsed: Duration,
|
|
729
|
-
observation: &crate::lifecycle::launch::pi_mcp::PiCatalogTestObservation,
|
|
730
|
-
) -> String {
|
|
731
|
-
format!(
|
|
732
|
-
"elapsed_ms={} spawn_count={} argv={:?} parent_pid={:?} parent_exit_success={:?} parent_exit_code={:?} reader_timeout={}",
|
|
733
|
-
elapsed.as_millis(),
|
|
734
|
-
observation.spawn_count,
|
|
735
|
-
observation.argv,
|
|
736
|
-
observation.parent_pid,
|
|
737
|
-
observation.parent_exit_success,
|
|
738
|
-
observation.parent_exit_code,
|
|
739
|
-
observation.reader_timeout,
|
|
740
|
-
)
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
#[cfg(unix)]
|
|
744
|
-
fn safe_models_result_class(result: &CmdResult) -> &'static str {
|
|
745
|
-
let CmdOutput::Human(text) = &result.output else {
|
|
746
|
-
return "non_human_output";
|
|
747
|
-
};
|
|
748
|
-
let Ok(value) = serde_json::from_str::<Value>(text) else {
|
|
749
|
-
return "non_json_output";
|
|
750
|
-
};
|
|
751
|
-
match value.get("ok").and_then(Value::as_bool) {
|
|
752
|
-
Some(true) => "success_json",
|
|
753
|
-
Some(false) => match value.get("error").and_then(Value::as_str) {
|
|
754
|
-
Some(error) if error.contains("unavailable") => "runner_unavailable",
|
|
755
|
-
Some(error) if error.contains("timed out") => "runner_timeout",
|
|
756
|
-
Some(error) if error.contains("command failed") => "runner_exit",
|
|
757
|
-
Some(error) if error.contains("could not be read") => "reader_error",
|
|
758
|
-
Some(error) if error.contains("exceeds") => "reader_oversize",
|
|
759
|
-
Some(error) if error.contains("catalog") => "parser_catalog_error",
|
|
760
|
-
Some(_) => "failure_json",
|
|
761
|
-
None => "failure_json_missing_error",
|
|
762
|
-
},
|
|
763
|
-
None => "json_missing_ok",
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
#[cfg(unix)]
|
|
768
|
-
fn safe_models_observation(
|
|
769
|
-
elapsed: Duration,
|
|
770
|
-
result: &CmdResult,
|
|
771
|
-
observation: &crate::lifecycle::launch::pi_mcp::PiCatalogTestObservation,
|
|
772
|
-
) -> String {
|
|
773
|
-
format!(
|
|
774
|
-
"class={} elapsed_ms={} parent_pid={:?} parent_exit_success={:?} parent_exit_code={:?} reader_timeout={}",
|
|
775
|
-
safe_models_result_class(result),
|
|
776
|
-
elapsed.as_millis(),
|
|
777
|
-
observation.parent_pid,
|
|
778
|
-
observation.parent_exit_success,
|
|
779
|
-
observation.parent_exit_code,
|
|
780
|
-
observation.reader_timeout,
|
|
781
|
-
)
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
#[cfg(unix)]
|
|
785
|
-
#[test]
|
|
786
|
-
fn runner_invokes_exact_argv_once_and_drains() {
|
|
787
|
-
let path = fixture_with_sidecars(
|
|
788
|
-
"test \"$1\" = --list-models && echo provider model && echo openai-codex gpt-5.6-sol",
|
|
789
|
-
);
|
|
790
|
-
let receipt = native_timeout_receipt();
|
|
791
|
-
assert!(!receipt.exists());
|
|
792
|
-
let started = Instant::now();
|
|
793
|
-
let (result, observation) =
|
|
794
|
-
crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
|
|
795
|
-
&receipt,
|
|
796
|
-
None,
|
|
797
|
-
|| run_catalog(&path, Duration::from_secs(1), 1024),
|
|
798
|
-
);
|
|
799
|
-
let elapsed = started.elapsed();
|
|
800
|
-
let fixture_observation = safe_runner_fixture_observation(&path);
|
|
801
|
-
assert!(
|
|
802
|
-
result
|
|
803
|
-
.as_ref()
|
|
804
|
-
.is_ok_and(|bytes| bytes.starts_with(b"provider model")),
|
|
805
|
-
"runner observation: {}; {}",
|
|
806
|
-
safe_runner_observation(elapsed, &observation),
|
|
807
|
-
fixture_observation
|
|
808
|
-
);
|
|
809
|
-
let _ = result.unwrap();
|
|
810
|
-
let _ = std::fs::remove_file(&receipt);
|
|
811
|
-
let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
|
|
812
|
-
assert_eq!(
|
|
813
|
-
std::fs::read_to_string(path.with_extension("count")).unwrap(),
|
|
814
|
-
"1:--list-models\n"
|
|
815
|
-
);
|
|
816
|
-
cleanup_fixture(&path);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
#[cfg(unix)]
|
|
820
|
-
const NATIVE_STAGE_KEYS: [&str; 5] = [
|
|
821
|
-
"parent_entry_ms",
|
|
822
|
-
"parent_before_child_spawn_ms",
|
|
823
|
-
"parent_after_child_spawn_ms",
|
|
824
|
-
"parent_before_exit_ms",
|
|
825
|
-
"test_spawn_return_ms",
|
|
826
|
-
];
|
|
827
|
-
|
|
828
|
-
#[cfg(unix)]
|
|
829
|
-
// Match the native helper's UNIX epoch millisecond clock exactly.
|
|
830
|
-
fn append_native_stage(path: &Path, key: &str) {
|
|
831
|
-
if !NATIVE_STAGE_KEYS.contains(&key) {
|
|
832
|
-
return;
|
|
833
|
-
}
|
|
834
|
-
let Some(milliseconds) = std::time::SystemTime::now()
|
|
835
|
-
.duration_since(std::time::UNIX_EPOCH)
|
|
836
|
-
.ok()
|
|
837
|
-
.map(|duration| duration.as_millis())
|
|
838
|
-
else {
|
|
839
|
-
return;
|
|
840
|
-
};
|
|
841
|
-
let Ok(mut file) = std::fs::OpenOptions::new()
|
|
842
|
-
.create(true)
|
|
843
|
-
.append(true)
|
|
844
|
-
.open(path)
|
|
845
|
-
else {
|
|
846
|
-
return;
|
|
847
|
-
};
|
|
848
|
-
let _ = writeln!(file, "{key}={milliseconds}");
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
#[cfg(unix)]
|
|
852
|
-
fn safe_native_stage(path: &Path) -> String {
|
|
853
|
-
let (read_state, text) = match std::fs::read_to_string(path) {
|
|
854
|
-
Ok(text) => ("ok", Some(text)),
|
|
855
|
-
Err(error) if error.kind() == std::io::ErrorKind::NotFound => ("missing", None),
|
|
856
|
-
Err(_) => ("unavailable", None),
|
|
857
|
-
};
|
|
858
|
-
let mut fields = BTreeMap::new();
|
|
859
|
-
if let Some(ref text) = text {
|
|
860
|
-
for line in text.lines() {
|
|
861
|
-
let Some((key, value)) = line.split_once('=') else {
|
|
862
|
-
continue;
|
|
863
|
-
};
|
|
864
|
-
if NATIVE_STAGE_KEYS.contains(&key)
|
|
865
|
-
&& value.len() <= 20
|
|
866
|
-
&& value.bytes().all(|byte| byte.is_ascii_digit())
|
|
867
|
-
{
|
|
868
|
-
fields.entry(key).or_insert(value);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
let field = |key: &str| fields.get(key).copied().unwrap_or("unknown");
|
|
873
|
-
format!(
|
|
874
|
-
"stage_read={read_state} parent_entry_ms={} parent_before_child_spawn_ms={} parent_after_child_spawn_ms={} parent_before_exit_ms={} test_spawn_return_ms={}",
|
|
875
|
-
field("parent_entry_ms"),
|
|
876
|
-
field("parent_before_child_spawn_ms"),
|
|
877
|
-
field("parent_after_child_spawn_ms"),
|
|
878
|
-
field("parent_before_exit_ms"),
|
|
879
|
-
field("test_spawn_return_ms"),
|
|
880
|
-
)
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
#[cfg(unix)]
|
|
884
|
-
fn wait_for_native_parent_exit(
|
|
885
|
-
child: &mut std::process::Child,
|
|
886
|
-
stage: &Path,
|
|
887
|
-
) -> std::process::ExitStatus {
|
|
888
|
-
let deadline = Instant::now() + Duration::from_millis(500);
|
|
889
|
-
loop {
|
|
890
|
-
match child.try_wait() {
|
|
891
|
-
Ok(Some(status)) => return status,
|
|
892
|
-
Ok(None) if Instant::now() < deadline => {
|
|
893
|
-
std::thread::sleep(Duration::from_millis(1));
|
|
894
|
-
}
|
|
895
|
-
Ok(None) => {
|
|
896
|
-
let before_kill = safe_native_stage(stage);
|
|
897
|
-
let _ = child.kill();
|
|
898
|
-
let _ = child.wait();
|
|
899
|
-
let after_wait = safe_native_stage(stage);
|
|
900
|
-
panic!(
|
|
901
|
-
"native parent did not exit before test setup deadline; stage_before_kill={before_kill}; stage_after_wait={after_wait}"
|
|
902
|
-
);
|
|
903
|
-
}
|
|
904
|
-
Err(_) => {
|
|
905
|
-
let before_kill = safe_native_stage(stage);
|
|
906
|
-
let _ = child.kill();
|
|
907
|
-
let _ = child.wait();
|
|
908
|
-
let after_wait = safe_native_stage(stage);
|
|
909
|
-
panic!(
|
|
910
|
-
"native parent status could not be observed; stage_before_kill={before_kill}; stage_after_wait={after_wait}"
|
|
911
|
-
);
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
/// Read/drain seam only: public `run_catalog` spawn coverage remains in the
|
|
918
|
-
/// normal success and fail-closed tests.
|
|
919
|
-
#[cfg(unix)]
|
|
920
|
-
#[test]
|
|
921
|
-
fn reader_deadline_is_bounded_after_parent_exit_with_descendant_pipe() {
|
|
922
|
-
let path = native_timeout_fixture();
|
|
923
|
-
let receipt = native_timeout_receipt();
|
|
924
|
-
let stage = native_timeout_stage_receipt(&receipt);
|
|
925
|
-
assert!(!receipt.exists());
|
|
926
|
-
assert!(!stage.exists());
|
|
927
|
-
let mut parent = std::process::Command::new(&path)
|
|
928
|
-
.arg("--list-models")
|
|
929
|
-
.env("TEAM_AGENT_MODELS_TIMEOUT_RECEIPT", &receipt)
|
|
930
|
-
.env("TEAM_AGENT_MODELS_TIMEOUT_STAGE_RECEIPT", &stage)
|
|
931
|
-
.env("TEAM_AGENT_MODELS_TIMEOUT_MODE", "descendant")
|
|
932
|
-
.stdin(std::process::Stdio::null())
|
|
933
|
-
.stdout(std::process::Stdio::piped())
|
|
934
|
-
.stderr(std::process::Stdio::null())
|
|
935
|
-
.spawn()
|
|
936
|
-
.unwrap();
|
|
937
|
-
append_native_stage(&stage, "test_spawn_return_ms");
|
|
938
|
-
let parent_pid = parent.id();
|
|
939
|
-
let parent_status = wait_for_native_parent_exit(&mut parent, &stage);
|
|
940
|
-
let stdout = parent.stdout.take().expect("native parent stdout pipe");
|
|
941
|
-
let started = Instant::now();
|
|
942
|
-
let (result, observation) =
|
|
943
|
-
crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
|
|
944
|
-
&receipt,
|
|
945
|
-
Some("descendant"),
|
|
946
|
-
|| {
|
|
947
|
-
crate::lifecycle::launch::pi_mcp::run_pi_catalog_after_parent_exit_for_test(
|
|
948
|
-
stdout,
|
|
949
|
-
parent_pid,
|
|
950
|
-
parent_status,
|
|
951
|
-
Duration::from_millis(40),
|
|
952
|
-
1024,
|
|
953
|
-
)
|
|
954
|
-
},
|
|
955
|
-
);
|
|
956
|
-
let elapsed = started.elapsed();
|
|
957
|
-
assert!(
|
|
958
|
-
elapsed < Duration::from_millis(500),
|
|
959
|
-
"runner observation: {}",
|
|
960
|
-
safe_runner_observation(elapsed, &observation)
|
|
961
|
-
);
|
|
962
|
-
assert!(result.unwrap_err().contains("timed out"));
|
|
963
|
-
assert_eq!(
|
|
964
|
-
observation.parent_exit_success,
|
|
965
|
-
Some(true),
|
|
966
|
-
"runner observation: {}",
|
|
967
|
-
safe_runner_observation(elapsed, &observation)
|
|
968
|
-
);
|
|
969
|
-
assert_eq!(observation.parent_exit_code, Some(0));
|
|
970
|
-
assert!(observation.reader_timeout);
|
|
971
|
-
|
|
972
|
-
let fields = wait_native_timeout_receipt(&receipt);
|
|
973
|
-
assert_eq!(fields["parent_started_once"], "1");
|
|
974
|
-
assert_eq!(fields["parent_argv_exact"], "1");
|
|
975
|
-
assert_eq!(fields["child_spawn_attempts"], "1");
|
|
976
|
-
assert_eq!(fields["child_argv_exact"], "1");
|
|
977
|
-
assert_eq!(fields["descendant_started"], "1");
|
|
978
|
-
assert_eq!(fields["descendant_stdout_inherited"], "1");
|
|
979
|
-
assert_eq!(
|
|
980
|
-
fields["parent_pid"],
|
|
981
|
-
observation.parent_pid.unwrap().to_string()
|
|
982
|
-
);
|
|
983
|
-
assert_eq!(fields["child_pid"], fields["descendant_pid"]);
|
|
984
|
-
let _ = std::fs::remove_file(&receipt);
|
|
985
|
-
let _ = std::fs::remove_file(&stage);
|
|
986
|
-
let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
#[cfg(unix)]
|
|
990
|
-
#[test]
|
|
991
|
-
#[serial_test::serial(env)]
|
|
992
|
-
fn command_boundary_connects_runner_parser_search_and_contract() {
|
|
993
|
-
let path = fixture(
|
|
994
|
-
"printf 'provider model\\nopenai-codex gpt-5.6-sol\\nopenai-codex gpt-5.6-luna\\n'",
|
|
995
|
-
);
|
|
996
|
-
let args = ModelsArgs {
|
|
997
|
-
provider: "pi".into(),
|
|
998
|
-
search: Some("sol".into()),
|
|
999
|
-
json: true,
|
|
1000
|
-
};
|
|
1001
|
-
let receipt = native_timeout_receipt();
|
|
1002
|
-
assert!(!receipt.exists());
|
|
1003
|
-
let started = Instant::now();
|
|
1004
|
-
let (result, observation) =
|
|
1005
|
-
crate::lifecycle::launch::pi_mcp::with_pi_catalog_test_observation(
|
|
1006
|
-
&receipt,
|
|
1007
|
-
None,
|
|
1008
|
-
|| cmd_models_with(&args, &path, Duration::from_secs(1), 1024),
|
|
1009
|
-
);
|
|
1010
|
-
let elapsed = started.elapsed();
|
|
1011
|
-
let result = match result {
|
|
1012
|
-
Ok(result) => result,
|
|
1013
|
-
Err(_) => panic!(
|
|
1014
|
-
"command boundary returned a CLI error; class=cli_error elapsed_ms={} parent_pid={:?} parent_exit_success={:?} parent_exit_code={:?} reader_timeout={}",
|
|
1015
|
-
elapsed.as_millis(),
|
|
1016
|
-
observation.parent_pid,
|
|
1017
|
-
observation.parent_exit_success,
|
|
1018
|
-
observation.parent_exit_code,
|
|
1019
|
-
observation.reader_timeout,
|
|
1020
|
-
),
|
|
1021
|
-
};
|
|
1022
|
-
let CmdOutput::Human(text) = &result.output else {
|
|
1023
|
-
panic!(
|
|
1024
|
-
"expected JSON projection; {}",
|
|
1025
|
-
safe_models_observation(elapsed, &result, &observation)
|
|
1026
|
-
)
|
|
1027
|
-
};
|
|
1028
|
-
let value: Value = serde_json::from_str(text).unwrap_or_else(|_| {
|
|
1029
|
-
panic!(
|
|
1030
|
-
"expected valid JSON projection; {}",
|
|
1031
|
-
safe_models_observation(elapsed, &result, &observation)
|
|
1032
|
-
)
|
|
1033
|
-
});
|
|
1034
|
-
assert_eq!(
|
|
1035
|
-
value["schema_version"],
|
|
1036
|
-
"models.v1",
|
|
1037
|
-
"{}",
|
|
1038
|
-
safe_models_observation(elapsed, &result, &observation)
|
|
1039
|
-
);
|
|
1040
|
-
assert_eq!(
|
|
1041
|
-
value["models"][0]["role_model"],
|
|
1042
|
-
"openai-codex/gpt-5.6-sol",
|
|
1043
|
-
"{}",
|
|
1044
|
-
safe_models_observation(elapsed, &result, &observation)
|
|
1045
|
-
);
|
|
1046
|
-
assert_eq!(
|
|
1047
|
-
value["models"][0]["current"],
|
|
1048
|
-
false,
|
|
1049
|
-
"{}",
|
|
1050
|
-
safe_models_observation(elapsed, &result, &observation)
|
|
1051
|
-
);
|
|
1052
|
-
assert_eq!(
|
|
1053
|
-
value["auth"],
|
|
1054
|
-
"ok",
|
|
1055
|
-
"{}",
|
|
1056
|
-
safe_models_observation(elapsed, &result, &observation)
|
|
1057
|
-
);
|
|
1058
|
-
let model_count = value["models"].as_array().map(|models| models.len());
|
|
1059
|
-
assert_eq!(
|
|
1060
|
-
model_count,
|
|
1061
|
-
Some(1),
|
|
1062
|
-
"{}",
|
|
1063
|
-
safe_models_observation(elapsed, &result, &observation)
|
|
1064
|
-
);
|
|
1065
|
-
let _ = std::fs::remove_file(&receipt);
|
|
1066
|
-
let _ = std::fs::remove_file(format!("{}.sock", receipt.display()));
|
|
1067
|
-
let human = cmd_models_with(
|
|
1068
|
-
&ModelsArgs {
|
|
1069
|
-
provider: "pi".into(),
|
|
1070
|
-
search: Some("absent".into()),
|
|
1071
|
-
json: false,
|
|
1072
|
-
},
|
|
1073
|
-
&path,
|
|
1074
|
-
Duration::from_secs(1),
|
|
1075
|
-
1024,
|
|
1076
|
-
)
|
|
1077
|
-
.unwrap();
|
|
1078
|
-
let CmdOutput::Human(text) = human.output else {
|
|
1079
|
-
panic!("expected human projection")
|
|
1080
|
-
};
|
|
1081
|
-
assert!(text.contains("No models matched --search") && text.contains("auth: ok"));
|
|
1082
|
-
let refusal = crate::cli::emit::__test_dispatch(
|
|
1083
|
-
"models",
|
|
1084
|
-
&["--provider".into(), "cloud".into()],
|
|
1085
|
-
Path::new("/tmp"),
|
|
1086
|
-
);
|
|
1087
|
-
assert!(matches!(refusal, Ok(ExitCode::Error)));
|
|
1088
|
-
cleanup_fixture(&path);
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
#[cfg(unix)]
|
|
1092
|
-
#[test]
|
|
1093
|
-
fn runner_fails_closed_for_nonzero_oversize_timeout_and_unavailable() {
|
|
1094
|
-
let fail = native_timeout_fixture();
|
|
1095
|
-
let started = Instant::now();
|
|
1096
|
-
let (failed_result, fail_observation) =
|
|
1097
|
-
with_native_mode("exit7", || run_catalog(&fail, Duration::from_secs(1), 1024));
|
|
1098
|
-
let elapsed = started.elapsed();
|
|
1099
|
-
assert_eq!(
|
|
1100
|
-
failed_result.unwrap_err(),
|
|
1101
|
-
"Pi model catalog command failed",
|
|
1102
|
-
"runner observation: {}",
|
|
1103
|
-
safe_runner_observation(elapsed, &fail_observation)
|
|
1104
|
-
);
|
|
1105
|
-
assert_eq!(fail_observation.spawn_count, 1);
|
|
1106
|
-
assert_eq!(fail_observation.argv, vec!["--list-models"]);
|
|
1107
|
-
assert_eq!(fail_observation.parent_exit_success, Some(false));
|
|
1108
|
-
assert_eq!(fail_observation.parent_exit_code, Some(7));
|
|
1109
|
-
assert!(!fail_observation.reader_timeout);
|
|
1110
|
-
let (failed, failed_observation) = with_native_mode("exit7", || {
|
|
1111
|
-
cmd_models_with(
|
|
1112
|
-
&ModelsArgs {
|
|
1113
|
-
provider: "pi".into(),
|
|
1114
|
-
search: None,
|
|
1115
|
-
json: false,
|
|
1116
|
-
},
|
|
1117
|
-
&fail,
|
|
1118
|
-
Duration::from_secs(1),
|
|
1119
|
-
1024,
|
|
1120
|
-
)
|
|
1121
|
-
});
|
|
1122
|
-
let failed = failed.unwrap();
|
|
1123
|
-
assert_eq!(failed_observation.spawn_count, 1);
|
|
1124
|
-
assert_eq!(failed_observation.argv, vec!["--list-models"]);
|
|
1125
|
-
assert_eq!(failed_observation.parent_exit_success, Some(false));
|
|
1126
|
-
assert_eq!(failed_observation.parent_exit_code, Some(7));
|
|
1127
|
-
assert!(!failed_observation.reader_timeout);
|
|
1128
|
-
let CmdOutput::Human(text) = failed.output else {
|
|
1129
|
-
panic!("expected failure projection")
|
|
1130
|
-
};
|
|
1131
|
-
assert_eq!(failed.exit, ExitCode::Error);
|
|
1132
|
-
assert!(!text.contains("sensitive-token"));
|
|
1133
|
-
let big = native_timeout_fixture();
|
|
1134
|
-
let (big_result, big_observation) =
|
|
1135
|
-
with_native_mode("oversize", || run_catalog(&big, Duration::from_secs(1), 8));
|
|
1136
|
-
assert!(big_result.unwrap_err().contains("bounded output"));
|
|
1137
|
-
assert_eq!(big_observation.spawn_count, 1);
|
|
1138
|
-
assert_eq!(big_observation.argv, vec!["--list-models"]);
|
|
1139
|
-
assert_eq!(big_observation.parent_exit_success, Some(true));
|
|
1140
|
-
assert_eq!(big_observation.parent_exit_code, Some(0));
|
|
1141
|
-
assert!(!big_observation.reader_timeout);
|
|
1142
|
-
let slow = native_timeout_fixture();
|
|
1143
|
-
let (slow_result, slow_observation) = with_native_mode("sleep", || {
|
|
1144
|
-
run_catalog(&slow, Duration::from_millis(20), 1024)
|
|
1145
|
-
});
|
|
1146
|
-
assert!(slow_result.unwrap_err().contains("timed out"));
|
|
1147
|
-
assert_eq!(slow_observation.spawn_count, 1);
|
|
1148
|
-
assert_eq!(slow_observation.argv, vec!["--list-models"]);
|
|
1149
|
-
assert_eq!(slow_observation.parent_exit_success, None);
|
|
1150
|
-
assert!(!slow_observation.reader_timeout);
|
|
1151
|
-
assert!(run_catalog(
|
|
1152
|
-
std::path::Path::new("/does/not/exist"),
|
|
1153
|
-
Duration::from_secs(1),
|
|
1154
|
-
1024
|
|
1155
|
-
)
|
|
1156
|
-
.unwrap_err()
|
|
1157
|
-
.contains("unavailable"));
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
#[test]
|
|
1161
|
-
fn public_failure_and_help_contracts_are_versioned() {
|
|
1162
|
-
let args = ModelsArgs {
|
|
1163
|
-
provider: "pi".into(),
|
|
1164
|
-
search: None,
|
|
1165
|
-
json: true,
|
|
1166
|
-
};
|
|
1167
|
-
let result = failure(&args, "safe failure");
|
|
1168
|
-
let CmdOutput::Human(text) = result.output else {
|
|
1169
|
-
panic!("json contract must render")
|
|
1170
|
-
};
|
|
1171
|
-
let value: Value = serde_json::from_str(&text).unwrap();
|
|
1172
|
-
assert_eq!(value["schema_version"], "models.v1");
|
|
1173
|
-
assert_eq!(value["models"], Value::Array(vec![]));
|
|
1174
|
-
assert_eq!(result.exit, ExitCode::Error);
|
|
1175
|
-
assert!(crate::cli::emit::default_help().contains("models"));
|
|
1176
|
-
assert_eq!(
|
|
1177
|
-
crate::cli::run(&["models".into(), "--help".into()], Path::new("/tmp")),
|
|
1178
|
-
ExitCode::Ok
|
|
1179
|
-
);
|
|
1180
|
-
assert_eq!(
|
|
1181
|
-
crate::cli::run(
|
|
1182
|
-
&["models".into(), "--provider".into(), "cloud".into()],
|
|
1183
|
-
Path::new("/tmp")
|
|
1184
|
-
),
|
|
1185
|
-
ExitCode::Error
|
|
1186
|
-
);
|
|
1187
|
-
let usage = "team-agent models [--provider pi|cursor|codex|claude|claude_code|grok|kiro] [QUERY|--search TEXT] [--json]";
|
|
1188
|
-
assert_eq!(crate::cli::spec::command_spec("models").unwrap().usage, usage);
|
|
1189
|
-
assert!(crate::cli::emit::command_help(Some("models")).contains(usage));
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
#[test]
|
|
1193
|
-
fn parser_contract_fixtures() {
|
|
1194
|
-
let parse =
|
|
1195
|
-
|input: &[u8]| crate::lifecycle::launch::pi_mcp::parse_pi_list_models_table(input);
|
|
1196
|
-
assert_eq!(
|
|
1197
|
-
parse(b"provider model\r\nopenai-codex gpt-5.6-sol\r\n").unwrap(),
|
|
1198
|
-
vec!["openai-codex/gpt-5.6-sol"]
|
|
1199
|
-
);
|
|
1200
|
-
assert!(parse(b"provider model\n").is_err());
|
|
1201
|
-
assert!(parse(b"provider model\na b\na b\n").is_err());
|
|
1202
|
-
assert!(parse(b"wrong model\na b\n").is_err());
|
|
1203
|
-
assert!(parse(b"provider model\na\n").is_err());
|
|
1204
|
-
assert!(parse(&[b'p', b'r', 0xff]).is_err());
|
|
1205
|
-
}
|
|
1206
|
-
}
|