Skip to main content

matrixcode_core/
constants.rs

1//! Core constants and configuration defaults
2//!
3//! Centralizes hardcoded values for easier maintenance.
4
5/// MatrixCode configuration directory name
6pub const MATRIX_DIR: &str = ".matrix";
7
8/// Default max tokens for responses
9pub const DEFAULT_MAX_TOKENS: u32 = 16384;
10
11/// Max tokens for quick actions/compression
12pub const QUICK_ACTION_MAX_TOKENS: u32 = 4096;
13
14/// Max tokens for compress role (shorter output)
15pub const COMPRESS_MAX_TOKENS: u32 = 1024;
16
17/// Max tokens for fast role (quick actions)
18pub const FAST_MAX_TOKENS: u32 = 2048;
19
20/// Max tokens for memory extraction
21pub const MEMORY_EXTRACTION_MAX_TOKENS: u32 = 512;
22
23/// Max tokens for AI memory selection
24pub const AI_MEMORY_SELECTION_MAX_TOKENS: u32 = 100;
25
26/// Default connect timeout in seconds
27pub const DEFAULT_CONNECT_TIMEOUT_SECS: u64 = 10;
28
29/// Default total request timeout in seconds
30pub const DEFAULT_REQUEST_TIMEOUT_SECS: u64 = 300;
31
32/// Default read timeout for streaming chunks (seconds)
33pub const DEFAULT_READ_TIMEOUT_SECS: u64 = 60;
34
35/// Default content timeout in seconds (for slow APIs)
36pub const DEFAULT_CONTENT_TIMEOUT_SECS: u64 = 300;
37
38/// Thinking budget for new models (2025+)
39pub const THINKING_BUDGET_NEW_MODELS: u32 = 10000;
40
41/// Thinking budget for older models
42pub const THINKING_BUDGET_OLD_MODELS: u32 = 5000;
43
44/// Max tool result size (bytes)
45pub const MAX_TOOL_RESULT_SIZE: usize = 50_000;
46
47/// Max file size for read without warning (bytes)
48pub const MAX_READ_FILE_SIZE: u64 = 5_000_000;
49
50/// Default read limit (lines)
51pub const DEFAULT_READ_LIMIT: usize = 500;
52
53/// Default search timeout (seconds)
54pub const DEFAULT_SEARCH_TIMEOUT_SECS: u64 = 30;
55
56/// Max files for search
57pub const MAX_SEARCH_FILES: usize = 500;
58
59/// Default grep head limit
60pub const DEFAULT_GREP_HEAD_LIMIT: usize = 100;
61
62/// Max output for bash commands (bytes)
63pub const MAX_BASH_OUTPUT: usize = 30_000;
64
65/// Default bash timeout (milliseconds)
66pub const DEFAULT_BASH_TIMEOUT_MS: u64 = 30_000;
67
68/// Lock acquire timeout (milliseconds)
69pub const LOCK_ACQUIRE_TIMEOUT_MS: u64 = 5000;
70
71/// Retry delay for streaming (milliseconds)
72pub const STREAMING_RETRY_DELAY_MS: u64 = 1000;
73
74/// Max retries for streaming
75pub const MAX_STREAMING_RETRIES: u32 = 5;
76
77/// Anthropic API version header
78pub const ANTHROPIC_API_VERSION: &str = "2025-04-15";
79
80/// Default base URLs
81pub const ANTHROPIC_DEFAULT_BASE_URL: &str = "https://api.anthropic.com";
82pub const OPENAI_DEFAULT_BASE_URL: &str = "https://api.openai.com/v1";
83
84/// CodeGraph CLI command timeout (seconds)
85pub const CODEGRAPH_CLI_TIMEOUT_SECS: u64 = 120;
86
87/// CodeGraph auto-sync debounce interval (seconds)
88/// Increased to reduce Node.js process frequency
89pub const CODEGRAPH_SYNC_INTERVAL_SECS: u64 = 10;