@team-agent/installer 0.5.127 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +41 -26
- package/skills/team-agent/command-coverage.json +170 -184
- package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +66 -32
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1298
- package/crates/team-agent/src/cli/arguments.rs +0 -401
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1675
- package/crates/team-agent/src/cli/emit.rs +0 -2898
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1189
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
- package/crates/team-agent/src/cli/intent/tests.rs +0 -691
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6528
- package/crates/team-agent/src/cli/models.rs +0 -449
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -192
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -201
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -159
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -2043
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -372
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -760
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -1091
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -842
- package/crates/team-agent/src/compiler.rs +0 -691
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1610
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -354
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -589
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -338
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -461
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3112
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1585
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -883
- package/crates/team-agent/src/leader/start.rs +0 -4500
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -267
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -145
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -152
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -450
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -534
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -757
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -223
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -135
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -396
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -71
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -472
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3981
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -152
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -90
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -996
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
- package/crates/team-agent/src/lifecycle/tests.rs +0 -102
- package/crates/team-agent/src/lifecycle/types.rs +0 -861
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -546
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -168
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -1015
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3785
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -354
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -166
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -217
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -551
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3655
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -471
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -898
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -28
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -773
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -722
- package/crates/team-agent/src/provider/session/capture.rs +0 -2631
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
- package/crates/team-agent/src/provider/session_scan.rs +0 -61
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -354
- package/crates/team-agent/src/provider/tests/classify.rs +0 -201
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -140
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -406
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4254
- package/crates/team-agent/src/tmux_backend.rs +0 -4527
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,722 +0,0 @@
|
|
|
1
|
-
//! Provider model discovery, bounded native catalog queries, and shared fuzzy search.
|
|
2
|
-
use std::collections::HashSet;
|
|
3
|
-
use std::ffi::OsString;
|
|
4
|
-
use std::io::{Read, Write};
|
|
5
|
-
use std::path::Path;
|
|
6
|
-
use std::process::{Child, Command, ExitStatus, Stdio};
|
|
7
|
-
use std::sync::mpsc;
|
|
8
|
-
use std::time::{Duration, Instant};
|
|
9
|
-
|
|
10
|
-
use crate::model::enums::Provider;
|
|
11
|
-
use crate::provider::wire::{parse_canonical_provider, provider_wire};
|
|
12
|
-
|
|
13
|
-
const CATALOG_TIMEOUT: Duration = Duration::from_secs(10);
|
|
14
|
-
const MAX_CATALOG_BYTES: u64 = 1024 * 1024;
|
|
15
|
-
|
|
16
|
-
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
17
|
-
pub struct ModelRecord {
|
|
18
|
-
pub provider: String,
|
|
19
|
-
pub vendor: String,
|
|
20
|
-
pub id: String,
|
|
21
|
-
pub display_name: String,
|
|
22
|
-
pub default: Option<bool>,
|
|
23
|
-
pub aliases: Vec<String>,
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
27
|
-
pub enum CatalogError {
|
|
28
|
-
UnsupportedProvider,
|
|
29
|
-
ExecutableUnavailable,
|
|
30
|
-
Timeout,
|
|
31
|
-
CommandFailed,
|
|
32
|
-
OutputUnavailable,
|
|
33
|
-
OutputReadFailed,
|
|
34
|
-
OutputTooLarge,
|
|
35
|
-
InputWriteFailed,
|
|
36
|
-
InvalidUtf8,
|
|
37
|
-
EmptyInput,
|
|
38
|
-
Malformed,
|
|
39
|
-
MalformedPiHeader,
|
|
40
|
-
MalformedPiRow(usize),
|
|
41
|
-
DuplicateIdentity(String),
|
|
42
|
-
Empty,
|
|
43
|
-
UnsupportedSchema,
|
|
44
|
-
InvalidProtocol,
|
|
45
|
-
TemporaryDirectoryUnavailable,
|
|
46
|
-
CommandCouldNotBeObserved,
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
impl CatalogError {
|
|
50
|
-
pub fn message(&self, provider: &str) -> String {
|
|
51
|
-
let name = display_provider(provider);
|
|
52
|
-
match self {
|
|
53
|
-
Self::UnsupportedProvider => format!("unsupported model provider {provider:?}"),
|
|
54
|
-
Self::ExecutableUnavailable => format!("{name} executable is unavailable on PATH"),
|
|
55
|
-
Self::Timeout => format!("{name} model catalog command timed out"),
|
|
56
|
-
Self::CommandFailed => format!("{name} model catalog command failed"),
|
|
57
|
-
Self::OutputUnavailable => format!("{name} model catalog output unavailable"),
|
|
58
|
-
Self::OutputReadFailed => format!("{name} model catalog could not be read"),
|
|
59
|
-
Self::OutputTooLarge => format!("{name} model catalog exceeds the bounded output limit"),
|
|
60
|
-
Self::InputWriteFailed => format!("{name} model catalog request could not be written"),
|
|
61
|
-
Self::InvalidUtf8 => format!("{name} model catalog is not valid UTF-8"),
|
|
62
|
-
Self::EmptyInput => "Pi model catalog is empty".into(),
|
|
63
|
-
Self::Malformed => format!("{name} model catalog is malformed"),
|
|
64
|
-
Self::MalformedPiHeader => "Pi model catalog has an unexpected header".into(),
|
|
65
|
-
Self::MalformedPiRow(row) => format!("Pi model catalog row {row} is malformed"),
|
|
66
|
-
Self::DuplicateIdentity(_) => format!("{name} model catalog contains duplicate model ids"),
|
|
67
|
-
Self::Empty => format!("{name} model catalog is empty"),
|
|
68
|
-
Self::UnsupportedSchema => format!("{name} model catalog uses an unsupported schema"),
|
|
69
|
-
Self::InvalidProtocol => format!("{name} model catalog returned an invalid protocol response"),
|
|
70
|
-
Self::TemporaryDirectoryUnavailable => "Claude model catalog could not create an isolated temporary directory".into(),
|
|
71
|
-
Self::CommandCouldNotBeObserved => format!("{name} model catalog command could not be observed"),
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
pub fn action(&self, provider: &str) -> String {
|
|
76
|
-
let executable = match provider {
|
|
77
|
-
"pi" => "pi",
|
|
78
|
-
"codex" => "codex",
|
|
79
|
-
"claude" | "claude_code" => "claude",
|
|
80
|
-
"grok" => "grok",
|
|
81
|
-
_ => "provider CLI",
|
|
82
|
-
};
|
|
83
|
-
match self {
|
|
84
|
-
Self::UnsupportedProvider => "choose a supported provider: pi, codex, claude, claude_code, or grok".into(),
|
|
85
|
-
Self::ExecutableUnavailable => format!("install or repair the PATH-first `{executable}` executable, then retry `team-agent models --provider {provider}`"),
|
|
86
|
-
Self::UnsupportedSchema => format!("upgrade `{executable}` to a version that supports its model catalog protocol, then retry `team-agent models --provider {provider}`"),
|
|
87
|
-
Self::CommandFailed => format!("run `{executable}` directly to check catalog/account access, then retry `team-agent models --provider {provider}`"),
|
|
88
|
-
_ => format!("check the native `{executable}` catalog command, then retry `team-agent models --provider {provider}`"),
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
pub(crate) fn pi_legacy_message(&self) -> String {
|
|
93
|
-
match self {
|
|
94
|
-
Self::ExecutableUnavailable => "Pi executable is unavailable on PATH".into(),
|
|
95
|
-
Self::Timeout => "Pi model catalog command timed out".into(),
|
|
96
|
-
Self::CommandFailed => "Pi model catalog command failed".into(),
|
|
97
|
-
Self::OutputUnavailable => "Pi model catalog output unavailable".into(),
|
|
98
|
-
Self::OutputReadFailed => "Pi model catalog could not be read".into(),
|
|
99
|
-
Self::OutputTooLarge => "Pi model catalog exceeds the bounded output limit".into(),
|
|
100
|
-
Self::InputWriteFailed => "Pi model catalog request could not be written".into(),
|
|
101
|
-
Self::InvalidUtf8 => "Pi model catalog is not UTF-8".into(),
|
|
102
|
-
Self::EmptyInput => "Pi model catalog is empty".into(),
|
|
103
|
-
Self::MalformedPiHeader => "Pi model catalog has an unexpected header".into(),
|
|
104
|
-
Self::MalformedPiRow(row) => format!("Pi model catalog row {row} is malformed"),
|
|
105
|
-
Self::DuplicateIdentity(id) => format!("Pi model catalog contains duplicate exact id {id:?}"),
|
|
106
|
-
Self::Empty => "Pi model catalog contains no models".into(),
|
|
107
|
-
Self::CommandCouldNotBeObserved => "Pi model catalog command could not be observed".into(),
|
|
108
|
-
_ => "Pi model catalog is invalid".into(),
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
fn display_provider(provider: &str) -> &str {
|
|
114
|
-
match provider {
|
|
115
|
-
"pi" => "Pi",
|
|
116
|
-
"codex" => "Codex",
|
|
117
|
-
"claude" | "claude_code" => "Claude",
|
|
118
|
-
"grok" => "Grok",
|
|
119
|
-
_ => provider,
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/// Only the documented catalog names are accepted; launch aliases stay unchanged.
|
|
124
|
-
pub fn parse_catalog_provider(name: &str) -> Option<Provider> {
|
|
125
|
-
parse_canonical_provider(name).filter(|provider| catalog_source(*provider).is_some())
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
#[derive(Clone, Copy)]
|
|
129
|
-
enum CatalogSource {
|
|
130
|
-
Codex,
|
|
131
|
-
Grok,
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Exhaustive by design: a new Provider variant must make an explicit catalog decision.
|
|
135
|
-
// `team-agent models --provider claude|claude_code|pi` reads the contract
|
|
136
|
-
// leaf's catalog (contract_runtime::discovery) before reaching this table.
|
|
137
|
-
fn catalog_source(provider: Provider) -> Option<CatalogSource> {
|
|
138
|
-
match provider {
|
|
139
|
-
Provider::Codex => Some(CatalogSource::Codex),
|
|
140
|
-
Provider::Grok => Some(CatalogSource::Grok),
|
|
141
|
-
Provider::Claude
|
|
142
|
-
| Provider::ClaudeCode
|
|
143
|
-
| Provider::Pi
|
|
144
|
-
| Provider::Copilot
|
|
145
|
-
| Provider::GeminiCli
|
|
146
|
-
| Provider::Fake => None,
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
pub fn discover_model_catalog(provider_name: &str) -> Result<Vec<ModelRecord>, CatalogError> {
|
|
151
|
-
let provider = parse_catalog_provider(provider_name).ok_or(CatalogError::UnsupportedProvider)?;
|
|
152
|
-
let source = catalog_source(provider).ok_or(CatalogError::UnsupportedProvider)?;
|
|
153
|
-
let requested_provider = provider_wire(provider);
|
|
154
|
-
let records = match source {
|
|
155
|
-
CatalogSource::Codex => {
|
|
156
|
-
let bytes = run_native("codex", &["debug", "models"], None, None, &[], CATALOG_TIMEOUT, MAX_CATALOG_BYTES, &mut NoopObserver)?;
|
|
157
|
-
parse_codex_catalog(&bytes, requested_provider)?
|
|
158
|
-
}
|
|
159
|
-
CatalogSource::Grok => {
|
|
160
|
-
let bytes = run_native("grok", &["models"], None, None, &[], CATALOG_TIMEOUT, MAX_CATALOG_BYTES, &mut NoopObserver)?;
|
|
161
|
-
parse_grok_catalog(&bytes)?
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
Ok(records)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/// One shared token-AND/field-OR, case-insensitive substring matcher.
|
|
168
|
-
pub fn model_matches(record: &ModelRecord, query: &str) -> bool {
|
|
169
|
-
let fields = std::iter::once(record.provider.as_str())
|
|
170
|
-
.chain(std::iter::once(record.vendor.as_str()))
|
|
171
|
-
.chain(std::iter::once(record.id.as_str()))
|
|
172
|
-
.chain(std::iter::once(record.display_name.as_str()))
|
|
173
|
-
.chain(record.aliases.iter().map(String::as_str))
|
|
174
|
-
.map(str::to_lowercase)
|
|
175
|
-
.collect::<Vec<_>>();
|
|
176
|
-
query
|
|
177
|
-
.split_whitespace()
|
|
178
|
-
.map(str::to_lowercase)
|
|
179
|
-
.all(|token| fields.iter().any(|field| field.contains(&token)))
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
pub(crate) fn parse_pi_catalog(bytes: &[u8]) -> Result<Vec<ModelRecord>, CatalogError> {
|
|
183
|
-
let text = std::str::from_utf8(bytes).map_err(|_| CatalogError::InvalidUtf8)?;
|
|
184
|
-
let mut lines = text.lines();
|
|
185
|
-
let header = lines.next().ok_or(CatalogError::EmptyInput)?;
|
|
186
|
-
let columns = header.split_whitespace().collect::<Vec<_>>();
|
|
187
|
-
if columns.get(0) != Some(&"provider") || columns.get(1) != Some(&"model") {
|
|
188
|
-
return Err(CatalogError::MalformedPiHeader);
|
|
189
|
-
}
|
|
190
|
-
let mut seen = HashSet::new();
|
|
191
|
-
let mut records = Vec::new();
|
|
192
|
-
for (index, line) in lines.enumerate() {
|
|
193
|
-
if line.trim().is_empty() {
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
let malformed = || CatalogError::MalformedPiRow(index + 2);
|
|
197
|
-
let (vendor, rest) = line.trim().split_once(char::is_whitespace).ok_or_else(malformed)?;
|
|
198
|
-
let mut id = rest.trim();
|
|
199
|
-
for _ in 2..columns.len() {
|
|
200
|
-
id = id.rsplit_once(char::is_whitespace).ok_or_else(malformed)?.0.trim_end();
|
|
201
|
-
}
|
|
202
|
-
if id.is_empty() {
|
|
203
|
-
return Err(malformed());
|
|
204
|
-
}
|
|
205
|
-
let exact = format!("{vendor}/{id}");
|
|
206
|
-
if !seen.insert(exact.clone()) {
|
|
207
|
-
return Err(CatalogError::DuplicateIdentity(exact));
|
|
208
|
-
}
|
|
209
|
-
records.push(ModelRecord {
|
|
210
|
-
provider: "pi".into(), vendor: vendor.into(), display_name: exact.clone(), id: exact,
|
|
211
|
-
default: None, aliases: Vec::new(),
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
if records.is_empty() { return Err(CatalogError::Empty); }
|
|
215
|
-
Ok(records)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
fn parse_grok_catalog(bytes: &[u8]) -> Result<Vec<ModelRecord>, CatalogError> {
|
|
219
|
-
let text = std::str::from_utf8(bytes).map_err(|_| CatalogError::InvalidUtf8)?;
|
|
220
|
-
let mut has_auth_notice = false;
|
|
221
|
-
let mut has_models_header = false;
|
|
222
|
-
let mut declared_default: Option<String> = None;
|
|
223
|
-
let mut starred_default: Option<String> = None;
|
|
224
|
-
let mut marked_default: Option<String> = None;
|
|
225
|
-
let mut seen = HashSet::new();
|
|
226
|
-
let mut records = Vec::new();
|
|
227
|
-
|
|
228
|
-
for line in text.lines() {
|
|
229
|
-
let line = line.trim();
|
|
230
|
-
if line.is_empty() {
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
if !has_models_header {
|
|
234
|
-
if matches!(line, "You are logged in with grok.com." | "You are not authenticated.") {
|
|
235
|
-
if has_auth_notice {
|
|
236
|
-
return Err(CatalogError::Malformed);
|
|
237
|
-
}
|
|
238
|
-
has_auth_notice = true;
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
if let Some(id) = line.strip_prefix("Default model: ") {
|
|
242
|
-
if declared_default.is_some() || id.is_empty() {
|
|
243
|
-
return Err(CatalogError::Malformed);
|
|
244
|
-
}
|
|
245
|
-
validate_identity(id)?;
|
|
246
|
-
declared_default = Some(id.to_string());
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
if line == "Available models:" {
|
|
250
|
-
has_models_header = true;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
return Err(CatalogError::Malformed);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
let (is_starred, row) = if let Some(row) = line.strip_prefix("- ") {
|
|
257
|
-
(false, row)
|
|
258
|
-
} else if let Some(row) = line.strip_prefix("* ") {
|
|
259
|
-
(true, row)
|
|
260
|
-
} else {
|
|
261
|
-
return Err(CatalogError::Malformed);
|
|
262
|
-
};
|
|
263
|
-
if row == "(default)" {
|
|
264
|
-
return Err(CatalogError::Malformed);
|
|
265
|
-
}
|
|
266
|
-
let (id, has_default_marker) = row
|
|
267
|
-
.strip_suffix(" (default)")
|
|
268
|
-
.map_or((row, false), |id| (id, true));
|
|
269
|
-
if id.is_empty() {
|
|
270
|
-
return Err(CatalogError::Malformed);
|
|
271
|
-
}
|
|
272
|
-
validate_identity(id)?;
|
|
273
|
-
if !seen.insert(id.to_string()) {
|
|
274
|
-
return Err(CatalogError::DuplicateIdentity(id.to_string()));
|
|
275
|
-
}
|
|
276
|
-
if is_starred {
|
|
277
|
-
if starred_default.as_deref().is_some_and(|current| current != id) {
|
|
278
|
-
return Err(CatalogError::Malformed);
|
|
279
|
-
}
|
|
280
|
-
starred_default = Some(id.to_string());
|
|
281
|
-
}
|
|
282
|
-
if has_default_marker {
|
|
283
|
-
if marked_default.as_deref().is_some_and(|current| current != id) {
|
|
284
|
-
return Err(CatalogError::Malformed);
|
|
285
|
-
}
|
|
286
|
-
marked_default = Some(id.to_string());
|
|
287
|
-
}
|
|
288
|
-
records.push(ModelRecord {
|
|
289
|
-
provider: "grok".into(),
|
|
290
|
-
vendor: "xai".into(),
|
|
291
|
-
id: id.into(),
|
|
292
|
-
display_name: id.into(),
|
|
293
|
-
default: None,
|
|
294
|
-
aliases: Vec::new(),
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
if !has_models_header {
|
|
298
|
-
return Err(CatalogError::Malformed);
|
|
299
|
-
}
|
|
300
|
-
if records.is_empty() {
|
|
301
|
-
return Err(CatalogError::Empty);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
let mut default_id: Option<&str> = None;
|
|
305
|
-
for candidate in [
|
|
306
|
-
declared_default.as_deref(),
|
|
307
|
-
starred_default.as_deref(),
|
|
308
|
-
marked_default.as_deref(),
|
|
309
|
-
]
|
|
310
|
-
.into_iter()
|
|
311
|
-
.flatten()
|
|
312
|
-
{
|
|
313
|
-
if default_id.is_some_and(|current| current != candidate) {
|
|
314
|
-
return Err(CatalogError::Malformed);
|
|
315
|
-
}
|
|
316
|
-
default_id = Some(candidate);
|
|
317
|
-
}
|
|
318
|
-
if let Some(default_id) = default_id {
|
|
319
|
-
if !seen.contains(default_id) {
|
|
320
|
-
return Err(CatalogError::Malformed);
|
|
321
|
-
}
|
|
322
|
-
for record in &mut records {
|
|
323
|
-
record.default = Some(record.id.as_str() == default_id);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
Ok(records)
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
fn parse_codex_catalog(bytes: &[u8], provider: &str) -> Result<Vec<ModelRecord>, CatalogError> {
|
|
330
|
-
let value: serde_json::Value = serde_json::from_slice(bytes).map_err(|_| CatalogError::Malformed)?;
|
|
331
|
-
let rows = value.get("models").and_then(serde_json::Value::as_array).ok_or(CatalogError::UnsupportedSchema)?;
|
|
332
|
-
if rows.is_empty() { return Err(CatalogError::Empty); }
|
|
333
|
-
let mut seen = HashSet::new();
|
|
334
|
-
let mut visible = Vec::new();
|
|
335
|
-
for row in rows {
|
|
336
|
-
let row = row.as_object().ok_or(CatalogError::Malformed)?;
|
|
337
|
-
let slug = required_string(row.get("slug"))?;
|
|
338
|
-
let display = required_string(row.get("display_name"))?;
|
|
339
|
-
let visibility = required_string(row.get("visibility"))?;
|
|
340
|
-
validate_identity(slug)?;
|
|
341
|
-
validate_display(display)?;
|
|
342
|
-
if !seen.insert(slug.to_string()) { return Err(CatalogError::DuplicateIdentity(slug.into())); }
|
|
343
|
-
match visibility {
|
|
344
|
-
"list" => visible.push(ModelRecord { provider: provider.into(), vendor: "openai".into(), id: slug.into(), display_name: display.into(), default: None, aliases: Vec::new() }),
|
|
345
|
-
"hide" | "none" => {},
|
|
346
|
-
_ => return Err(CatalogError::UnsupportedSchema),
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
if visible.is_empty() { return Err(CatalogError::Empty); }
|
|
350
|
-
Ok(visible)
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
fn required_string(value: Option<&serde_json::Value>) -> Result<&str, CatalogError> {
|
|
354
|
-
let value = value.and_then(serde_json::Value::as_str).ok_or(CatalogError::UnsupportedSchema)?;
|
|
355
|
-
if value.trim().is_empty() { return Err(CatalogError::UnsupportedSchema); }
|
|
356
|
-
Ok(value)
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
fn validate_identity(value: &str) -> Result<(), CatalogError> {
|
|
360
|
-
if value.chars().any(|ch| ch.is_whitespace() || ch.is_control()) { Err(CatalogError::Malformed) } else { Ok(()) }
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
fn validate_display(value: &str) -> Result<(), CatalogError> {
|
|
364
|
-
if value.chars().any(char::is_control) { Err(CatalogError::Malformed) } else { Ok(()) }
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
pub(crate) trait CatalogObserver {
|
|
368
|
-
fn spawned(&mut self, _pid: u32) {}
|
|
369
|
-
fn exited(&mut self, _status: &ExitStatus) {}
|
|
370
|
-
fn output_timeout(&mut self) {}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
pub(crate) struct NoopObserver;
|
|
374
|
-
impl CatalogObserver for NoopObserver {}
|
|
375
|
-
|
|
376
|
-
fn run_native(
|
|
377
|
-
program: &str,
|
|
378
|
-
args: &[&str],
|
|
379
|
-
input: Option<&[u8]>,
|
|
380
|
-
cwd: Option<&Path>,
|
|
381
|
-
remove_env: &[&str],
|
|
382
|
-
timeout: Duration,
|
|
383
|
-
max_bytes: u64,
|
|
384
|
-
observer: &mut dyn CatalogObserver,
|
|
385
|
-
) -> Result<Vec<u8>, CatalogError> {
|
|
386
|
-
run_command(Path::new(program), args, input, cwd, remove_env, &[], timeout, max_bytes, observer)
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
pub(crate) fn run_command(
|
|
390
|
-
program: &Path,
|
|
391
|
-
args: &[&str],
|
|
392
|
-
input: Option<&[u8]>,
|
|
393
|
-
cwd: Option<&Path>,
|
|
394
|
-
remove_env: &[&str],
|
|
395
|
-
extra_env: &[(OsString, OsString)],
|
|
396
|
-
timeout: Duration,
|
|
397
|
-
max_bytes: u64,
|
|
398
|
-
observer: &mut dyn CatalogObserver,
|
|
399
|
-
) -> Result<Vec<u8>, CatalogError> {
|
|
400
|
-
let started = Instant::now();
|
|
401
|
-
let mut command = Command::new(program);
|
|
402
|
-
command.args(args).stdin(if input.is_some() { Stdio::piped() } else { Stdio::null() }).stdout(Stdio::piped()).stderr(Stdio::null());
|
|
403
|
-
if let Some(cwd) = cwd { command.current_dir(cwd); }
|
|
404
|
-
for name in remove_env { command.env_remove(name); }
|
|
405
|
-
command.envs(extra_env.iter().cloned());
|
|
406
|
-
#[cfg(unix)]
|
|
407
|
-
{
|
|
408
|
-
use std::os::unix::process::CommandExt;
|
|
409
|
-
command.process_group(0);
|
|
410
|
-
}
|
|
411
|
-
let mut child = command.spawn().map_err(|_| CatalogError::ExecutableUnavailable)?;
|
|
412
|
-
let pid = child.id();
|
|
413
|
-
observer.spawned(pid);
|
|
414
|
-
let stdout = match child.stdout.take() {
|
|
415
|
-
Some(stdout) => stdout,
|
|
416
|
-
None => { terminate(&mut child, pid); return Err(CatalogError::OutputUnavailable); }
|
|
417
|
-
};
|
|
418
|
-
let (reader_tx, reader_rx) = mpsc::channel();
|
|
419
|
-
let reader = match std::thread::Builder::new().name("model-catalog-reader".into()).spawn(move || {
|
|
420
|
-
let mut bytes = Vec::new();
|
|
421
|
-
let result = stdout.take(max_bytes.saturating_add(1)).read_to_end(&mut bytes);
|
|
422
|
-
let _ = reader_tx.send(result.map(|_| bytes));
|
|
423
|
-
}) {
|
|
424
|
-
Ok(reader) => reader,
|
|
425
|
-
Err(_) => { terminate(&mut child, pid); return Err(CatalogError::OutputReadFailed); }
|
|
426
|
-
};
|
|
427
|
-
let writer = if let Some(input) = input {
|
|
428
|
-
let Some(mut stdin) = child.stdin.take() else { terminate(&mut child, pid); return Err(CatalogError::InputWriteFailed); };
|
|
429
|
-
let input = input.to_vec();
|
|
430
|
-
let (tx, rx) = mpsc::channel();
|
|
431
|
-
let writer = match std::thread::Builder::new().name("model-catalog-writer".into()).spawn(move || {
|
|
432
|
-
let result = stdin.write_all(&input);
|
|
433
|
-
drop(stdin);
|
|
434
|
-
let _ = tx.send(result.is_ok());
|
|
435
|
-
}) {
|
|
436
|
-
Ok(writer) => writer,
|
|
437
|
-
Err(_) => { terminate(&mut child, pid); return Err(CatalogError::InputWriteFailed); }
|
|
438
|
-
};
|
|
439
|
-
Some((writer, rx))
|
|
440
|
-
} else { None };
|
|
441
|
-
let mut output = None;
|
|
442
|
-
let mut pending_output = None;
|
|
443
|
-
let mut output_ready_at: Option<Instant> = None;
|
|
444
|
-
let mut too_large_at = None;
|
|
445
|
-
let status = loop {
|
|
446
|
-
match pending_output.take().map_or_else(|| reader_rx.try_recv(), Ok) {
|
|
447
|
-
Ok(Ok(bytes)) => {
|
|
448
|
-
if bytes.len() as u64 > max_bytes {
|
|
449
|
-
too_large_at.get_or_insert_with(Instant::now);
|
|
450
|
-
} else {
|
|
451
|
-
output = Some(bytes);
|
|
452
|
-
}
|
|
453
|
-
output_ready_at = Some(Instant::now());
|
|
454
|
-
}
|
|
455
|
-
Ok(Err(_)) => { terminate(&mut child, pid); return Err(CatalogError::OutputReadFailed); }
|
|
456
|
-
Err(mpsc::TryRecvError::Disconnected) if output.is_none() && too_large_at.is_none() => { terminate(&mut child, pid); return Err(CatalogError::OutputReadFailed); }
|
|
457
|
-
Err(mpsc::TryRecvError::Disconnected) | Err(mpsc::TryRecvError::Empty) => {}
|
|
458
|
-
}
|
|
459
|
-
match child.try_wait() {
|
|
460
|
-
Ok(Some(status)) => {
|
|
461
|
-
observer.exited(&status);
|
|
462
|
-
if !status.success() { terminate(&mut child, pid); return Err(CatalogError::CommandFailed); }
|
|
463
|
-
if too_large_at.is_some() { terminate(&mut child, pid); return Err(CatalogError::OutputTooLarge); }
|
|
464
|
-
break status;
|
|
465
|
-
}
|
|
466
|
-
Ok(None) if too_large_at.is_some_and(|at| at.elapsed() >= Duration::from_millis(100)) => {
|
|
467
|
-
terminate(&mut child, pid);
|
|
468
|
-
return Err(CatalogError::OutputTooLarge);
|
|
469
|
-
}
|
|
470
|
-
Ok(None) if started.elapsed() < timeout => {
|
|
471
|
-
let mut wait = timeout.saturating_sub(started.elapsed()).min(Duration::from_millis(10));
|
|
472
|
-
if let Some(over_at) = too_large_at {
|
|
473
|
-
wait = wait.min(Duration::from_millis(100).saturating_sub(over_at.elapsed()));
|
|
474
|
-
}
|
|
475
|
-
if output.is_none() && too_large_at.is_none() {
|
|
476
|
-
// Reader completion wakes us instead of trailing a blind 10ms sleep.
|
|
477
|
-
if let Ok(result) = reader_rx.recv_timeout(wait) {
|
|
478
|
-
pending_output = Some(result);
|
|
479
|
-
}
|
|
480
|
-
} else {
|
|
481
|
-
// stdout can close before exit; never busy-poll a disconnected channel.
|
|
482
|
-
let interval = output_ready_at.map_or(Duration::from_millis(10), |at| {
|
|
483
|
-
catalog_exit_poll_interval(at.elapsed())
|
|
484
|
-
});
|
|
485
|
-
std::thread::sleep(wait.min(interval));
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
Ok(None) if too_large_at.is_some() => { terminate(&mut child, pid); return Err(CatalogError::OutputTooLarge); }
|
|
489
|
-
Ok(None) => { terminate(&mut child, pid); return Err(CatalogError::Timeout); }
|
|
490
|
-
Err(_) => { terminate(&mut child, pid); return Err(CatalogError::CommandCouldNotBeObserved); }
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
let _ = status;
|
|
494
|
-
if let Some((writer, result)) = writer {
|
|
495
|
-
let remaining = timeout.saturating_sub(started.elapsed());
|
|
496
|
-
match result.recv_timeout(remaining) {
|
|
497
|
-
Ok(true) => { let _ = writer.join(); }
|
|
498
|
-
Ok(false) | Err(mpsc::RecvTimeoutError::Disconnected) => { terminate(&mut child, pid); return Err(CatalogError::InputWriteFailed); }
|
|
499
|
-
Err(mpsc::RecvTimeoutError::Timeout) => { terminate(&mut child, pid); return Err(CatalogError::Timeout); }
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
if output.is_none() {
|
|
503
|
-
let remaining = timeout.saturating_sub(started.elapsed());
|
|
504
|
-
match reader_rx.recv_timeout(remaining) {
|
|
505
|
-
Ok(Ok(bytes)) if bytes.len() as u64 <= max_bytes => output = Some(bytes),
|
|
506
|
-
Ok(Ok(_)) => { terminate(&mut child, pid); return Err(CatalogError::OutputTooLarge); }
|
|
507
|
-
Ok(Err(_)) | Err(mpsc::RecvTimeoutError::Disconnected) => return Err(CatalogError::OutputReadFailed),
|
|
508
|
-
Err(mpsc::RecvTimeoutError::Timeout) => { observer.output_timeout(); terminate(&mut child, pid); return Err(CatalogError::Timeout); }
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
let _ = reader.join();
|
|
512
|
-
output.ok_or(CatalogError::OutputReadFailed)
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
fn catalog_exit_poll_interval(elapsed: Duration) -> Duration {
|
|
516
|
-
[1, 3, 6, 10]
|
|
517
|
-
.into_iter()
|
|
518
|
-
.map(Duration::from_millis)
|
|
519
|
-
.find(|checkpoint| *checkpoint > elapsed)
|
|
520
|
-
.map_or(Duration::from_millis(10), |checkpoint| {
|
|
521
|
-
checkpoint.saturating_sub(elapsed)
|
|
522
|
-
})
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
fn terminate(child: &mut Child, pid: u32) {
|
|
526
|
-
#[cfg(unix)]
|
|
527
|
-
unsafe {
|
|
528
|
-
// The process group was created for this one native catalog invocation.
|
|
529
|
-
let _ = libc::kill(-(pid as i32), libc::SIGKILL);
|
|
530
|
-
}
|
|
531
|
-
let _ = child.kill();
|
|
532
|
-
let _ = child.wait();
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
#[cfg(all(test, unix))]
|
|
536
|
-
mod command_wait_regressions {
|
|
537
|
-
use super::*;
|
|
538
|
-
|
|
539
|
-
#[derive(Default)]
|
|
540
|
-
struct Observer {
|
|
541
|
-
pid: Option<u32>,
|
|
542
|
-
exits: Vec<Option<i32>>,
|
|
543
|
-
output_timeouts: usize,
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
impl CatalogObserver for Observer {
|
|
547
|
-
fn spawned(&mut self, pid: u32) { self.pid = Some(pid); }
|
|
548
|
-
fn exited(&mut self, status: &ExitStatus) { self.exits.push(status.code()); }
|
|
549
|
-
fn output_timeout(&mut self) { self.output_timeouts += 1; }
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
fn run(
|
|
553
|
-
script: &str,
|
|
554
|
-
input: Option<&[u8]>,
|
|
555
|
-
timeout: Duration,
|
|
556
|
-
max_bytes: u64,
|
|
557
|
-
observer: &mut Observer,
|
|
558
|
-
) -> Result<Vec<u8>, CatalogError> {
|
|
559
|
-
run_command(
|
|
560
|
-
Path::new("/bin/sh"), &["-c", script], input, None, &[], &[],
|
|
561
|
-
timeout, max_bytes, observer,
|
|
562
|
-
)
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
fn assert_owned_child_gone(observer: &Observer) {
|
|
566
|
-
let pid = observer.pid.unwrap();
|
|
567
|
-
assert!(pid > 1);
|
|
568
|
-
let status = Command::new("/bin/kill")
|
|
569
|
-
.args(["-0", &pid.to_string()])
|
|
570
|
-
.stdout(Stdio::null())
|
|
571
|
-
.stderr(Stdio::null())
|
|
572
|
-
.status()
|
|
573
|
-
.unwrap();
|
|
574
|
-
assert!(!status.success(), "owned child must be reaped");
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
#[test]
|
|
578
|
-
fn eof_and_success_preserve_input_and_raw_output() {
|
|
579
|
-
let mut observer = Observer::default();
|
|
580
|
-
let input = b"catalog\0\xff\n";
|
|
581
|
-
let output = run(
|
|
582
|
-
"exec /bin/cat", Some(input), CATALOG_TIMEOUT, MAX_CATALOG_BYTES, &mut observer,
|
|
583
|
-
).unwrap();
|
|
584
|
-
assert_eq!(output, input.to_vec());
|
|
585
|
-
assert_eq!(observer.exits, vec![Some(0)]);
|
|
586
|
-
assert_eq!(observer.output_timeouts, 0);
|
|
587
|
-
assert_owned_child_gone(&observer);
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
#[test]
|
|
591
|
-
fn stdout_eof_does_not_hide_a_later_nonzero_exit() {
|
|
592
|
-
let mut observer = Observer::default();
|
|
593
|
-
let error = run(
|
|
594
|
-
"printf 'partial'; exec 1>&-; /bin/sleep 0.03; exit 17",
|
|
595
|
-
None, CATALOG_TIMEOUT, MAX_CATALOG_BYTES, &mut observer,
|
|
596
|
-
).unwrap_err();
|
|
597
|
-
assert_eq!(error, CatalogError::CommandFailed);
|
|
598
|
-
assert_eq!(observer.exits, vec![Some(17)]);
|
|
599
|
-
assert_eq!(observer.output_timeouts, 0);
|
|
600
|
-
assert_owned_child_gone(&observer);
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
#[test]
|
|
604
|
-
fn stdout_eof_does_not_disable_the_ten_second_process_timeout() {
|
|
605
|
-
let mut observer = Observer::default();
|
|
606
|
-
let started = Instant::now();
|
|
607
|
-
let error = run(
|
|
608
|
-
"exec 1>&-; exec /bin/sleep 30", None, CATALOG_TIMEOUT,
|
|
609
|
-
MAX_CATALOG_BYTES, &mut observer,
|
|
610
|
-
).unwrap_err();
|
|
611
|
-
let elapsed = started.elapsed();
|
|
612
|
-
assert_eq!(CATALOG_TIMEOUT, Duration::from_secs(10));
|
|
613
|
-
assert_eq!(error, CatalogError::Timeout);
|
|
614
|
-
assert!(elapsed >= CATALOG_TIMEOUT);
|
|
615
|
-
assert!(elapsed < CATALOG_TIMEOUT + Duration::from_secs(2));
|
|
616
|
-
assert!(observer.exits.is_empty());
|
|
617
|
-
assert_eq!(observer.output_timeouts, 0);
|
|
618
|
-
assert_owned_child_gone(&observer);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
#[test]
|
|
622
|
-
fn exact_one_mib_is_allowed_and_one_more_byte_is_rejected() {
|
|
623
|
-
assert_eq!(MAX_CATALOG_BYTES, 1024 * 1024);
|
|
624
|
-
let mut observer = Observer::default();
|
|
625
|
-
let script = format!("exec /usr/bin/head -c {MAX_CATALOG_BYTES} /dev/zero");
|
|
626
|
-
let output = run(
|
|
627
|
-
&script, None, CATALOG_TIMEOUT, MAX_CATALOG_BYTES, &mut observer,
|
|
628
|
-
).unwrap();
|
|
629
|
-
assert_eq!(output.len() as u64, MAX_CATALOG_BYTES);
|
|
630
|
-
assert_owned_child_gone(&observer);
|
|
631
|
-
let mut observer = Observer::default();
|
|
632
|
-
let script = format!("exec /usr/bin/head -c {} /dev/zero", MAX_CATALOG_BYTES + 1);
|
|
633
|
-
assert_eq!(
|
|
634
|
-
run(&script, None, CATALOG_TIMEOUT, MAX_CATALOG_BYTES, &mut observer),
|
|
635
|
-
Err(CatalogError::OutputTooLarge)
|
|
636
|
-
);
|
|
637
|
-
assert_owned_child_gone(&observer);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
#[test]
|
|
641
|
-
fn oversized_output_keeps_one_hundred_millisecond_exit_grace() {
|
|
642
|
-
let mut observer = Observer::default();
|
|
643
|
-
let started = Instant::now();
|
|
644
|
-
let error = run(
|
|
645
|
-
"printf '%65s' x; exec /bin/sleep 30", None, CATALOG_TIMEOUT, 64, &mut observer,
|
|
646
|
-
).unwrap_err();
|
|
647
|
-
assert_eq!(error, CatalogError::OutputTooLarge);
|
|
648
|
-
assert!(started.elapsed() >= Duration::from_millis(100));
|
|
649
|
-
assert!(started.elapsed() < Duration::from_secs(2));
|
|
650
|
-
assert_owned_child_gone(&observer);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
#[test]
|
|
654
|
-
fn exited_child_with_inherited_stdout_keeps_output_timeout_observation() {
|
|
655
|
-
let mut observer = Observer::default();
|
|
656
|
-
let error = run(
|
|
657
|
-
"/bin/sleep 30 & exit 0", None, Duration::from_millis(200),
|
|
658
|
-
MAX_CATALOG_BYTES, &mut observer,
|
|
659
|
-
).unwrap_err();
|
|
660
|
-
assert_eq!(error, CatalogError::Timeout);
|
|
661
|
-
assert_eq!(observer.exits, vec![Some(0)]);
|
|
662
|
-
assert_eq!(observer.output_timeouts, 1);
|
|
663
|
-
assert_owned_child_gone(&observer);
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
#[test]
|
|
667
|
-
fn early_eof_polling_keeps_ten_millisecond_anchor_and_then_old_cadence() {
|
|
668
|
-
let mut elapsed = Duration::ZERO;
|
|
669
|
-
for (sleep_ms, check_ms) in [(1, 1), (2, 3), (3, 6), (4, 10), (10, 20)] {
|
|
670
|
-
let interval = catalog_exit_poll_interval(elapsed);
|
|
671
|
-
assert_eq!(interval, Duration::from_millis(sleep_ms));
|
|
672
|
-
elapsed += interval;
|
|
673
|
-
assert_eq!(elapsed, Duration::from_millis(check_ms));
|
|
674
|
-
}
|
|
675
|
-
assert_eq!(catalog_exit_poll_interval(Duration::from_micros(9500)), Duration::from_micros(500));
|
|
676
|
-
assert_eq!(catalog_exit_poll_interval(Duration::from_millis(50)), Duration::from_millis(10));
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
#[cfg(test)]
|
|
681
|
-
mod tests {
|
|
682
|
-
use super::*;
|
|
683
|
-
|
|
684
|
-
#[test]
|
|
685
|
-
fn provider_capability_is_explicit_and_exact() {
|
|
686
|
-
for (name, provider) in [
|
|
687
|
-
("codex", Provider::Codex),
|
|
688
|
-
("grok", Provider::Grok),
|
|
689
|
-
] {
|
|
690
|
-
assert_eq!(parse_catalog_provider(name), Some(provider));
|
|
691
|
-
assert_eq!(provider_wire(provider), name);
|
|
692
|
-
assert!(catalog_source(provider).is_some());
|
|
693
|
-
}
|
|
694
|
-
// Claude Code and Pi catalogs are read through their contract leaves.
|
|
695
|
-
for name in ["", "cloud", "pi", "claude", "claude_code", "cursor", "cursor_agent", "agent", "claude-code", "copilot", "gemini_cli", "fake", "Pi", "CODEX", " pi", "pi ", "pi/model", "codex:model", "claude_code_extra"] {
|
|
696
|
-
assert_eq!(parse_catalog_provider(name), None);
|
|
697
|
-
}
|
|
698
|
-
for provider in [Provider::Claude, Provider::ClaudeCode, Provider::Pi, Provider::Copilot, Provider::GeminiCli, Provider::Fake] {
|
|
699
|
-
assert!(catalog_source(provider).is_none());
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
#[test]
|
|
704
|
-
fn codex_visibility_and_validation_are_fail_closed() {
|
|
705
|
-
let bytes = br#"{"models":[{"slug":"gpt-6-luna","display_name":"GPT Luna","visibility":"list"},{"slug":"hidden","display_name":"Hidden","visibility":"hide"}]}"#;
|
|
706
|
-
let rows = parse_codex_catalog(bytes, "codex").unwrap();
|
|
707
|
-
assert_eq!(rows.len(), 1);
|
|
708
|
-
assert_eq!(rows[0].id, "gpt-6-luna");
|
|
709
|
-
assert_eq!(rows[0].vendor, "openai");
|
|
710
|
-
let duplicate = br#"{"models":[{"slug":"x","display_name":"X","visibility":"hide"},{"slug":"x","display_name":"X","visibility":"list"}]}"#;
|
|
711
|
-
assert!(matches!(parse_codex_catalog(duplicate, "codex"), Err(CatalogError::DuplicateIdentity(_))));
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
#[test]
|
|
715
|
-
fn matcher_uses_and_tokens_and_all_catalog_fields() {
|
|
716
|
-
let row = ModelRecord { provider: "codex".into(), vendor: "openai".into(), id: "gpt-6-luna".into(), display_name: "GPT Luna".into(), default: None, aliases: vec![] };
|
|
717
|
-
assert!(model_matches(&row, "LUNA GPT"));
|
|
718
|
-
assert!(!model_matches(&row, "LUNA absent"));
|
|
719
|
-
assert!(model_matches(&row, " "));
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
}
|