MoonBit-native local proxy and usage statistics gateway for the Moon suite
Platform/application · feature-testing alpha. Read the product contract for provider prerequisites, security, capability status and release gates.
moon run cmd/main -- startmoon run cmd/main -- start --host 127.0.0.1 --port 15721 --model gpt-5moon run cmd/main -- auth login
moon run cmd/main -- auth status
moon run cmd/main -- auth poll --device-code dev_... --user-code USER-CODEmoon run cmd/main -- health
moon run cmd/main -- status
moon run cmd/main -- stats
curl http://127.0.0.1:15721/metrics
moon run cmd/main -- usage logsmoon info
moon fmt
moon check --target native --deny-warn
moon test --target native --deny-warn(cd ../moonclaw && moon test plugin/moongate --target native --deny-warn)
(cd ../moondesk && moon test plugin/moongate --target native --deny-warn)
(cd ../moontown && moon test src/plugin/moongate --target native --deny-warn)
(cd ../moonbook && moon test plugins/moongate --target native --deny-warn)moon run cmd/main -- models fetch --base-url https://api.example.com --api-key sk-...
moon run cmd/main -- usage codex-oauth-models --account-id acct_...
moon run cmd/main -- models candidates --base-url https://api.deepseek.com/anthropicexport MOONSUITE_WORKSPACE_ROOT="$HOME/moonsuite"
moon run cmd/main -- suite manifest
moon run cmd/main -- suite status
moon run cmd/main -- suite constitution --checked-at 2026-07-12T09:00:00+08:00
moon run cmd/main -- suite constitution-negative --checked-at 2026-07-12T09:00:00+08:00
moon run cmd/main -- suite capabilities --root "$MOONSUITE_WORKSPACE_ROOT"
moon run cmd/main -- suite capability-resolve \
--root "$MOONSUITE_WORKSPACE_ROOT" \
--product moonmold \
--operation spatial.operation.execute
moon run cmd/main -- suite write-statuspub struct CostBreakdown {
input_cost_usd : String
output_cost_usd : String
cache_read_cost_usd : String
cache_creation_cost_usd : String
total_cost_usd : String
}pub struct FetchedModel {
id : String
owned_by : String?
}pub struct Gateway {
// private fields
}pub struct ModelPricing {
model_id : String
display_name : String
input_cost_per_million : String
output_cost_per_million : String
cache_read_cost_per_million : String
cache_creation_cost_per_million : String
}pub struct MoonGateAgentClient {
id : String
app_type : String
protocol : String
base_url : String
primary_route : String
setup_command : String?
usage : String?
}pub struct MoonGateClient {
base_url : String
api_key : String?
control_token : String?
user_agent : String?
}async fn MoonGateClient::discover(path? : String, api_key? : String?, control_token? : String?, user_agent? : String?) -> MoonGateClientfn MoonGateClient::from_host(host? : String, port? : Int, api_key? : String?, control_token? : String?, user_agent? : String?) -> MoonGateClientfn MoonGateClient::from_suite_status(status : Json, api_key? : String?, control_token? : String?, user_agent? : String?) -> MoonGateClient?async fn MoonGateClient::model_catalog(self : MoonGateClient) -> Result[Array[MoonGateModel], String]fn MoonGateClient::new(base_url? : String, api_key? : String?, control_token? : String?, user_agent? : String?) -> MoonGateClientasync fn MoonGateClient::post_json(self : MoonGateClient, path : String, request : Json) -> Result[Json, String]async fn MoonGateClient::proxy_add_failover_queue(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::proxy_add_failover_queue_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::proxy_app_config(self : MoonGateClient, app_type : String) -> Result[Json, String]async fn MoonGateClient::proxy_auto_failover_enabled(self : MoonGateClient, app_type : String) -> Result[Json, String]fn MoonGateClient::proxy_auto_failover_enabled_url(self : MoonGateClient, app_type : String) -> Stringasync fn MoonGateClient::proxy_available_failover_providers(self : MoonGateClient, app_type : String) -> Result[Json, String]fn MoonGateClient::proxy_available_failover_providers_url(self : MoonGateClient, app_type : String) -> Stringasync fn MoonGateClient::proxy_circuit_breaker_config(self : MoonGateClient) -> Result[Json, String]async fn MoonGateClient::proxy_circuit_breaker_stats(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::proxy_circuit_breaker_stats_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::proxy_default_cost_multiplier(self : MoonGateClient, app_type : String) -> Result[Json, String]fn MoonGateClient::proxy_default_cost_multiplier_url(self : MoonGateClient, app_type : String) -> Stringasync fn MoonGateClient::proxy_failover_queue(self : MoonGateClient, app_type : String) -> Result[Json, String]async fn MoonGateClient::proxy_pricing_model_source(self : MoonGateClient, app_type : String) -> Result[Json, String]fn MoonGateClient::proxy_pricing_model_source_url(self : MoonGateClient, app_type : String) -> Stringasync fn MoonGateClient::proxy_provider_health(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::proxy_provider_health_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::proxy_remove_failover_queue(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::proxy_remove_failover_queue_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::proxy_reset_circuit_breaker(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::proxy_reset_circuit_breaker_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::proxy_set_auto_failover_enabled(self : MoonGateClient, app_type : String, enabled : String) -> Result[Json, String]fn MoonGateClient::proxy_set_auto_failover_enabled_url(self : MoonGateClient, app_type : String, enabled : String) -> Stringasync fn MoonGateClient::proxy_set_default_cost_multiplier(self : MoonGateClient, app_type : String, value : String) -> Result[Json, String]fn MoonGateClient::proxy_set_default_cost_multiplier_url(self : MoonGateClient, app_type : String, value : String) -> Stringasync fn MoonGateClient::proxy_set_global_url(self : MoonGateClient, url : String) -> Result[Json, String]async fn MoonGateClient::proxy_set_pricing_model_source(self : MoonGateClient, app_type : String, value : String) -> Result[Json, String]fn MoonGateClient::proxy_set_pricing_model_source_url(self : MoonGateClient, app_type : String, value : String) -> Stringasync fn MoonGateClient::proxy_set_takeover_status(self : MoonGateClient, app_type : String, enabled : String) -> Result[Json, String]fn MoonGateClient::proxy_set_takeover_status_url(self : MoonGateClient, app_type : String, enabled : String) -> Stringasync fn MoonGateClient::proxy_switch_provider(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::proxy_switch_provider_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::proxy_test_url(self : MoonGateClient, url : String) -> Result[Json, String]async fn MoonGateClient::proxy_update_app_config(self : MoonGateClient, app_type : String, enabled? : String?, auto_failover_enabled? : String?, max_retries? : String?, streaming_first_byte_timeout? : String?, streaming_idle_timeout? : String?, non_streaming_timeout? : String?, failure_threshold? : String?, success_threshold? : String?, timeout_seconds? : String?, error_rate_threshold? : String?, min_requests? : String?) -> Result[Json, String]fn MoonGateClient::proxy_update_app_config_url(self : MoonGateClient, app_type : String, enabled? : String?, auto_failover_enabled? : String?, max_retries? : String?, streaming_first_byte_timeout? : String?, streaming_idle_timeout? : String?, non_streaming_timeout? : String?, failure_threshold? : String?, success_threshold? : String?, timeout_seconds? : String?, error_rate_threshold? : String?, min_requests? : String?) -> Stringasync fn MoonGateClient::proxy_update_circuit_breaker_config(self : MoonGateClient, failure_threshold : String, success_threshold : String, timeout_seconds : String, error_rate_threshold : String, min_requests : String) -> Result[Json, String]fn MoonGateClient::proxy_update_circuit_breaker_config_url(self : MoonGateClient, failure_threshold : String, success_threshold : String, timeout_seconds : String, error_rate_threshold : String, min_requests : String) -> Stringasync fn MoonGateClient::proxy_update_global_config(self : MoonGateClient, proxy_enabled? : String?, listen_address? : String?, listen_port? : String?, enable_logging? : String?) -> Result[Json, String]fn MoonGateClient::proxy_update_global_config_url(self : MoonGateClient, proxy_enabled? : String?, listen_address? : String?, listen_port? : String?, enable_logging? : String?) -> Stringasync fn MoonGateClient::route_messages(self : MoonGateClient, request : Json) -> Result[Json, String]async fn MoonGateClient::route_openclaw_chat(self : MoonGateClient, request : Json) -> Result[Json, String]async fn MoonGateClient::route_response(self : MoonGateClient, request : Json) -> Result[Json, String]async fn MoonGateClient::route_response_compact(self : MoonGateClient, request : Json) -> Result[Json, String]async fn MoonGateClient::usage_delete_model_pricing(self : MoonGateClient, model_id : String) -> Result[Json, String]fn MoonGateClient::usage_delete_model_pricing_url(self : MoonGateClient, model_id : String) -> Stringasync fn MoonGateClient::usage_logs(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Result[Json, String]async fn MoonGateClient::usage_model_stats(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Result[Json, String]fn MoonGateClient::usage_model_stats_url(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Stringasync fn MoonGateClient::usage_provider_limits(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::usage_provider_limits_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::usage_provider_stats(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Result[Json, String]fn MoonGateClient::usage_provider_stats_url(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Stringasync fn MoonGateClient::usage_provider_usage(self : MoonGateClient, app_type : String, provider_id : String) -> Result[Json, String]fn MoonGateClient::usage_provider_usage_url(self : MoonGateClient, app_type : String, provider_id : String) -> Stringasync fn MoonGateClient::usage_request_detail(self : MoonGateClient, request_id : String) -> Result[Json, String]async fn MoonGateClient::usage_summary(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Result[Json, String]async fn MoonGateClient::usage_summary_by_app(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Result[Json, String]fn MoonGateClient::usage_summary_by_app_url(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Stringasync fn MoonGateClient::usage_summary_typed(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Result[MoonGateUsageSummary, String]async fn MoonGateClient::usage_sync_session(self : MoonGateClient, query? : MoonGateSessionSyncQuery?) -> Result[Json, String]fn MoonGateClient::usage_sync_session_url(self : MoonGateClient, query? : MoonGateSessionSyncQuery?) -> Stringasync fn MoonGateClient::usage_trends(self : MoonGateClient, query? : MoonGateUsageQuery?) -> Result[Json, String]async fn MoonGateClient::usage_update_model_pricing(self : MoonGateClient, pricing : ModelPricing) -> Result[Json, String]pub struct MoonGateModel {
id : String
owner : String?
context_window : Int?
}pub struct MoonGateSessionSyncQuery {
projects_dir : String?
codex_dir : String?
gemini_dir : String?
opencode_export_path : String?
opencode_db_path : String?
}fn MoonGateSessionSyncQuery::new(projects_dir~ : String?, codex_dir~ : String?, gemini_dir~ : String?, opencode_export_path~ : String?, opencode_db_path~ : String?) -> MoonGateSessionSyncQuerypub struct MoonGateUsageQuery {
start_date : String?
end_date : String?
app_type : String?
provider_id : String?
provider_name : String?
model : String?
status_code : String?
page : Int?
page_size : Int?
}fn MoonGateUsageQuery::new(start_date~ : String?, end_date~ : String?, app_type~ : String?, provider_id~ : String?, provider_name~ : String?, model~ : String?, status_code~ : String?, page~ : Int?, page_size~ : Int?) -> MoonGateUsageQuerypub struct MoonGateUsageSummary {
total_requests : Int
total_cost : String
total_input_tokens : Int64
total_output_tokens : Int64
total_cache_creation_tokens : Int64
total_cache_read_tokens : Int64
real_total_tokens : Int64
success_rate : Double
cache_hit_rate : Double
}pub enum MoonProxyError {
AlreadyRunning
NotRunning
UpstreamError(status~ : Int, body~ : String?)
Timeout(String)
StreamIdleTimeout(Int)
ForwardFailed(String)
NoAvailableProvider
AllProvidersCircuitOpenError
NoProvidersConfiguredError
MaxRetriesExceeded
ProviderUnhealthy(String)
ConfigError(String)
InvalidRequest(String)
AuthError(String)
DatabaseError(String)
TransformError(String)
Unknown(String)
}pub struct TokenUsage {
input_tokens : Int
output_tokens : Int
cache_read_tokens : Int
cache_creation_tokens : Int
model : String?
message_id : String?
}fn TokenUsage::new(input_tokens~ : Int, output_tokens~ : Int, cache_read_tokens? : Int, cache_creation_tokens? : Int, model? : String?, message_id? : String?) -> TokenUsagefn build_models_url_candidates(base_url : String, is_full_url : Bool, models_url_override : String?) -> Result[Array[String], String]fn calculate_cost_for_app(app_type : String, usage : TokenUsage, pricing : ModelPricing, cost_multiplier? : String) -> CostBreakdownfn copilot_normalize_to_upstream_id(client_id : String) -> String?async fn copilot_poll_for_account(device_code : String, github_domain : String?) -> Result[Json?, String]fn default_moongate_moonclaw_providers_file_path() -> Stringfn default_moongate_moonclaw_providers_file_path_for_workspace_root(root : String) -> Stringfn default_moongate_suite_status_path_for_workspace_root(root : String) -> Stringasync fn fetch_codex_oauth_models_with_token(token : String, account_id : String) -> Result[Array[FetchedModel], String]async fn fetch_models(base_url : String, api_key : String, is_full_url : Bool, models_url_override : String?, user_agent : String?) -> Result[Array[FetchedModel], String]async fn managed_auth_poll_for_account(provider : String, device_code : String, user_code : String?, github_domain? : String?) -> Result[Json?, String]async fn managed_auth_remove_account(provider : String, account_id : String) -> Result[Json, String]async fn managed_auth_set_default_account(provider : String, account_id : String) -> Result[Json, String]async fn managed_auth_start_login(provider : String, github_domain? : String?) -> Result[Json, String]fn moongate_agent_clients_from_manifest(manifest : Json) -> Result[Array[MoonGateAgentClient], String]fn moongate_agent_clients_from_suite_status(status : Json) -> Result[Array[MoonGateAgentClient], String]fn moongate_product_home_for_workspace_root(root : String) -> Stringfn moongate_rabbita_lepusa_manifest(api_base? : String) -> Stringfn moongate_suite_status_json(host? : String, port? : Int, model? : String, status? : String, ready? : Bool) -> Jsonasync fn write_moongate_moonclaw_providers_file(path? : String, host? : String, port? : Int, model? : String) -> Stringasync fn write_moongate_suite_status(path? : String, host? : String, port? : Int, model? : String, status? : String, ready? : Bool) -> String