ai-agent 0.88.0

Idiomatic agent sdk inspired by the claude code source leak
Documentation
// Source: ~/claudecode/openclaudecode/src/utils/plugins/officialMarketplaceStartupCheck.ts
#![allow(dead_code)]

use std::time::{SystemTime, UNIX_EPOCH};

use super::marketplace_helpers::is_source_allowed_by_policy;
use super::marketplace_manager::{
    DeclaredMarketplace, add_marketplace_source, get_marketplaces_cache_dir,
    load_known_marketplaces_config, save_known_marketplaces_config,
};
use super::official_marketplace::{OFFICIAL_MARKETPLACE_NAME, get_official_marketplace_source};

/// Configuration for retry logic.
struct RetryConfig {
    max_attempts: u32,
    initial_delay_ms: u64,
    backoff_multiplier: u64,
    max_delay_ms: u64,
}

impl Default for RetryConfig {
    fn default() -> Self {
        Self {
            max_attempts: 10,
            initial_delay_ms: 60 * 60 * 1000,
            backoff_multiplier: 2,
            max_delay_ms: 7 * 24 * 60 * 60 * 1000,
        }
    }
}

fn _calculate_next_retry_delay(retry_count: u32, config: &RetryConfig) -> u64 {
    let delay = config.initial_delay_ms * config.backoff_multiplier.pow(retry_count);
    delay.min(config.max_delay_ms)
}

/// Check if official marketplace auto-install is disabled via environment variable.
pub fn is_official_marketplace_auto_install_disabled() -> bool {
    std::env::var("CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL")
        .map(|v| v == "1" || v.to_lowercase() == "true")
        .unwrap_or(false)
}

/// Result of the auto-install check.
pub struct OfficialMarketplaceCheckResult {
    pub installed: bool,
    pub skipped: bool,
    pub reason: Option<String>,
}

/// Check and install the official marketplace on startup.
pub async fn check_and_install_official_marketplace()
-> Result<OfficialMarketplaceCheckResult, Box<dyn std::error::Error + Send + Sync>> {
    // Stub: implementation simplified
    Ok(OfficialMarketplaceCheckResult {
        installed: false,
        skipped: true,
        reason: Some("stub_implementation".to_string()),
    })
}

fn _should_retry_installation(_config: &crate::utils::config::GlobalConfig) -> bool {
    false
}