Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
16#pragma once
17
19
20#include <cstdint>
21#include <string>
22#include <vector>
23#include <optional>
24#include <filesystem>
25#include <unordered_map>
26
27namespace entropic {
28
38enum class MCPAccessLevel : uint8_t {
39 NONE = 0,
40 READ = 1,
41 WRITE = 2,
42};
43
48struct MCPKey {
49 std::string tool_pattern;
51};
52
60const char* mcp_access_level_name(MCPAccessLevel level);
61
70bool parse_mcp_access_level(const std::string& name, MCPAccessLevel& out);
71
81 std::string key;
82 std::string gbnf_content;
83 std::string source;
84 bool validated = false;
85 std::string error;
86};
87
101
112enum class AdapterState : int {
113 COLD = 0,
114 WARM = 1,
115 HOT = 2
116};
117
127 std::string name;
128 std::filesystem::path path;
130 float scale = 1.0f;
131 std::string tier_name;
132 std::string base_model_path;
133 size_t ram_bytes = 0;
134
136 std::unordered_map<std::string, std::string> metadata;
137};
138
149 std::filesystem::path path;
150 std::string adapter = "qwen35";
151 int context_length = 16384;
152 int gpu_layers = -1;
153 bool keep_warm = false;
154 bool use_mlock = true;
155
156 /* ── llama.cpp pass-through ────────────────────────── */
158 std::string cache_type_k = "f16";
159 std::string cache_type_v = "f16";
160 int n_batch = 512;
161 int n_threads = 0;
162 std::string tensor_split;
163 bool flash_attn = true;
164
165 /* ── Tool filtering ────────────────────────────────── */
166 std::optional<std::vector<std::string>> allowed_tools;
167
168 /* ── Vision / multimodal (v1.9.11) ────────────────── */
169
174 std::filesystem::path mmproj_path;
175
176 /* ── Model format (v1.9.13) ───────────────────────── */
177
184 std::string model_format = "gguf";
185};
186
197 size_t max_bytes = 536870912;
198 bool enabled = true;
199 bool log_hits = true;
200};
201
216 std::string name;
217 int n_batch = 512;
218 int n_threads = 0;
220 std::string description;
221};
222
228 float temperature = 0.7f;
229 float top_p = 0.9f;
230 int top_k = 40;
231 float repeat_penalty = 1.1f;
232 int max_tokens = 4096;
233
237 int seed = -1;
239 bool enable_thinking = true;
240 std::string grammar;
245 std::string grammar_key;
246 std::vector<std::string> stop;
247 int logprobs = 0;
248
249 /* ── v1.9.7: Time cap + profile fields ────────────── */
250
255
260 std::string profile;
261
267 bool auto_adapt = true;
268
272 float adapt_headroom = 0.9f;
273};
274
287 std::optional<std::filesystem::path> identity;
288 bool identity_disabled = false;
289 std::optional<std::filesystem::path> grammar;
290 std::optional<std::string> auto_chain;
291 std::optional<bool> routable;
292
296 std::optional<std::filesystem::path> adapter_path;
297
300 float adapter_scale = 1.0f;
301
316 std::vector<std::string> capabilities;
317
325 bool has_capability(const std::string& name) const {
326 for (const auto& c : capabilities) {
327 if (c == name) { return true; }
328 }
329 return false;
330 }
331
344 std::string get_param(const std::string& param_name) const {
345 if (param_name == "explicit_completion") {
346 return auto_chain.has_value() ? "false" : "true";
347 }
348 return "";
349 }
350};
351
357 std::unordered_map<std::string, TierConfig> tiers;
358 std::optional<ModelConfig> router;
359 std::string default_tier = "lead";
360
372 std::string find_tier_by_path(
373 const std::filesystem::path& model_path) const {
374 for (const auto& [name, tier] : tiers) {
375 if (tier.path == model_path) { return name; }
376 }
377 return "";
378 }
379};
380
389 bool enabled = false;
390 std::string fallback_tier = "lead";
391 std::optional<std::string> classification_prompt;
392 std::unordered_map<std::string, std::string> tier_map;
393 std::unordered_map<std::string, std::vector<std::string>> handoff_rules;
394};
395
401 std::vector<std::string> allow;
402 std::vector<std::string> deny;
403 bool auto_approve = false;
404};
405
412 bool fail_on_errors = true;
413 float diagnostics_timeout = 1.0f;
414 bool allow_outside_root = false;
415 std::optional<int> max_read_bytes;
416 float max_read_context_pct = 0.25f;
417};
418
424 bool enabled = false;
425 std::optional<std::filesystem::path> socket_path;
426 int rate_limit = 10;
427};
428
434 uint32_t base_delay_ms = 1000;
435 uint32_t max_delay_ms = 60000;
436 uint32_t max_retries = 5;
437 double backoff_factor = 2.0;
438};
439
445 std::string command;
446 std::vector<std::string> args;
447 std::unordered_map<std::string, std::string> env;
448 std::string url;
449};
450
455struct MCPConfig {
456 bool enable_entropic = true;
457 bool enable_filesystem = true;
458 bool enable_bash = true;
459 bool enable_git = true;
460 bool enable_diagnostics = true;
461 bool enable_web = true;
465 std::string working_dir;
466
467 /* ── v1.8.7: External MCP client settings ──────────── */
468 std::unordered_map<std::string, ExternalServerEntry> external_servers;
471 uint32_t tool_call_timeout_ms = 30000;
472};
473
484 std::filesystem::path log_dir;
485 std::string session_id;
486 bool enabled = true;
488 size_t max_file_size = 0;
489 size_t max_files = 5;
490};
491
497 bool enabled = true;
498 std::filesystem::path db_path;
499 size_t log_max_file_size = 10 * 1024 * 1024;
500 size_t log_max_files = 3;
502};
503
509 bool enabled = true;
510 float threshold_percent = 0.75f;
513 bool notify_user = true;
514 bool save_full_history = true;
517};
518
524 int max_tokens = 4096;
525 float default_temperature = 0.7f;
526 float default_top_p = 0.9f;
527};
528
534 std::string command;
535 std::vector<std::string> args;
536 std::vector<std::string> extensions;
537};
538
543struct LSPConfig {
544 bool enabled = true;
545 bool python_enabled = true;
546 bool c_enabled = true;
547 std::unordered_map<std::string, LSPServerConfig> servers;
548};
549
566 bool enabled = false;
569 float temperature = 0.0f;
570 bool enable_thinking = false;
571 int priority = 100;
572 std::string grammar_key = "constitutional_critique";
574 std::vector<std::string> skip_tiers = {"lead"};
579 std::string critique_tier;
580};
581
620 ModelConfig cfg;
621 cfg.gpu_layers = 0;
622 cfg.flash_attn = false;
623 cfg.context_length = 8192;
624 cfg.n_threads = 4;
625 return cfg;
626}
627
692
705
762
773 float temperature = 0.7f;
774 int max_output_tokens = 4096;
775 bool enable_thinking = false;
776 float repeat_penalty = 1.1f;
777 std::optional<std::vector<std::string>> bash_commands;
778};
779
780} // namespace entropic
Shared enumerations used across .so boundaries.
@ ENTROPIC_MODEL_STATE_WARM
mmap'd + mlock'd in RAM, slow inference
Definition enums.h:29
@ ENTROPIC_MODEL_STATE_COLD
On disk only, no RAM consumed.
Definition enums.h:28
@ ENTROPIC_MODEL_STATE_ACTIVE
GPU layers loaded, full inference speed.
Definition enums.h:30
Activate model on GPU (WARM → ACTIVE).
ModelState
C++ enum class for model VRAM lifecycle states.
Definition config.h:96
@ WARM
mmap'd + mlock'd in RAM
@ ACTIVE
GPU layers loaded, full speed.
@ COLD
On disk only, no RAM consumed.
const char * mcp_access_level_name(MCPAccessLevel level)
Convert MCPAccessLevel to string representation.
Definition config.cpp:21
ModelConfig make_default_draft_model_config()
Speculative decoding configuration (v2.1.11, gh#36).
Definition config.h:619
MCPAccessLevel
MCP tool access level for per-identity authorization.
Definition config.h:38
@ READ
Read-only operations (e.g., read_file, list_directory)
@ NONE
No access (default for ungranted keys)
@ WRITE
Read + write operations (e.g., write_file, execute)
AdapterState
LoRA adapter lifecycle state.
Definition config.h:112
@ COLD
Not loaded. No resources consumed.
@ HOT
Active on context via llama_set_adapter_lora(). Influencing generation.
bool parse_mcp_access_level(const std::string &name, MCPAccessLevel &out)
Parse MCPAccessLevel from string.
Definition config.cpp:35
Metadata for a loaded LoRA adapter.
Definition config.h:126
std::string tier_name
Tier this adapter is assigned to (empty = unassigned)
Definition config.h:131
size_t ram_bytes
RAM consumption when WARM/HOT (0 if COLD)
Definition config.h:133
std::string base_model_path
Path of the base model this adapter targets.
Definition config.h:132
std::filesystem::path path
Resolved path to .gguf adapter file.
Definition config.h:128
AdapterState state
Current lifecycle state.
Definition config.h:129
std::string name
Unique adapter identifier.
Definition config.h:127
std::unordered_map< std::string, std::string > metadata
Adapter-specific metadata for routing decisions.
Definition config.h:136
float scale
LoRA scaling factor (alpha/rank)
Definition config.h:130
Audit log configuration within StorageConfig.
Definition config.h:483
size_t max_file_size
Rotation size in bytes (0 = unlimited)
Definition config.h:488
size_t flush_interval_entries
Flush every N entries (0 = every entry)
Definition config.h:487
std::string session_id
UUID for this session.
Definition config.h:485
std::filesystem::path log_dir
Directory for audit log files.
Definition config.h:484
bool enabled
Master toggle for audit logging.
Definition config.h:486
size_t max_files
Max rotated files to keep.
Definition config.h:489
Auto-compaction configuration.
Definition config.h:508
bool save_full_history
Save full history before compaction.
Definition config.h:514
bool notify_user
Notify user on compaction.
Definition config.h:513
float warning_threshold_percent
Warning trigger (0.3–0.9)
Definition config.h:516
int preserve_recent_turns
Turns to preserve (1–10)
Definition config.h:511
int summary_max_tokens
Summary max tokens (500–4000)
Definition config.h:512
int tool_result_ttl
Tool result TTL in turns (>= 1; v2.1.3 #6: gated on fill, no upper bound)
Definition config.h:515
float threshold_percent
Compaction trigger (0.5–0.99)
Definition config.h:510
bool enabled
Enable auto-compaction.
Definition config.h:509
Constitutional validation pipeline configuration.
Definition config.h:565
int max_revisions
Max re-generation attempts (0 = critique only)
Definition config.h:567
int priority
Hook priority (higher = later)
Definition config.h:571
bool enable_thinking
Enable think-blocks for critique (default OFF)
Definition config.h:570
float temperature
Critique generation temperature.
Definition config.h:569
bool enabled
Global enable/disable (default OFF)
Definition config.h:566
std::string critique_tier
Tier to route critique generation on.
Definition config.h:579
int max_critique_tokens
Token budget for critique generation.
Definition config.h:568
std::string grammar_key
Grammar registry key.
Definition config.h:572
std::vector< std::string > skip_tiers
Tiers exempt from validation (default: lead — streams before hook fires)
Definition config.h:574
External MCP server configuration (Entropic-as-server).
Definition config.h:423
std::optional< std::filesystem::path > socket_path
Socket path (nullopt = derived)
Definition config.h:425
int rate_limit
Requests per minute (1–100)
Definition config.h:426
bool enabled
Enable external MCP.
Definition config.h:424
Configuration for a single external MCP server entry.
Definition config.h:444
std::string command
Stdio command (empty for SSE)
Definition config.h:445
std::vector< std::string > args
Stdio command arguments.
Definition config.h:446
std::string url
SSE endpoint URL (empty for stdio)
Definition config.h:448
std::unordered_map< std::string, std::string > env
Stdio environment variables.
Definition config.h:447
Filesystem MCP server configuration.
Definition config.h:410
bool diagnostics_on_edit
Proactive diagnostics on edit/write.
Definition config.h:411
bool allow_outside_root
Allow file ops outside workspace root.
Definition config.h:414
float diagnostics_timeout
Diagnostics timeout (0.1–5.0)
Definition config.h:413
std::optional< int > max_read_bytes
Max file read size (nullopt = derive from context)
Definition config.h:415
float max_read_context_pct
Max context % for single file read.
Definition config.h:416
bool fail_on_errors
Rollback edit if it introduces errors.
Definition config.h:412
Named GPU resource profile for controlling inference hardware knobs.
Definition config.h:215
int n_threads_batch
CPU threads for batch processing (0 = use n_threads)
Definition config.h:219
int n_batch
Batch size for prompt processing (1-2048)
Definition config.h:217
std::string name
Profile name ("maximum", "balanced", "background", "minimal")
Definition config.h:216
int n_threads
CPU threads for generation (0 = auto-detect)
Definition config.h:218
std::string description
Human-readable description.
Definition config.h:220
Generation parameters configuration (top-level defaults).
Definition config.h:523
int max_tokens
Default max tokens (64–32768)
Definition config.h:524
float default_top_p
Default top_p (0.0–1.0)
Definition config.h:526
float default_temperature
Default temperature (0.0–2.0)
Definition config.h:525
Generation parameters for a single inference call.
Definition config.h:227
int time_limit_ms
Wall-clock time cap in milliseconds.
Definition config.h:254
int reasoning_budget
Per-call think budget override (-1 = unlimited)
Definition config.h:238
std::string grammar
GBNF grammar string (empty = unconstrained)
Definition config.h:240
std::string profile
GPU resource profile name.
Definition config.h:260
int top_k
Top-K sampling.
Definition config.h:230
bool auto_adapt
Enable throughput-based max_tokens auto-adaptation.
Definition config.h:267
float repeat_penalty
Repetition penalty.
Definition config.h:231
float temperature
Sampling temperature.
Definition config.h:228
std::string grammar_key
Grammar registry key.
Definition config.h:245
bool enable_thinking
Enable <think> blocks (false if reasoning_budget == 0)
Definition config.h:239
int logprobs
Top log-probs per token (0 = disabled)
Definition config.h:247
float adapt_headroom
Target time usage fraction for auto-adaptation.
Definition config.h:272
int max_tokens
Maximum tokens to generate.
Definition config.h:232
float top_p
Nucleus sampling threshold.
Definition config.h:229
int seed
RNG seed for reproducible sampling.
Definition config.h:237
std::vector< std::string > stop
Stop sequences.
Definition config.h:246
Metadata for a registered grammar.
Definition config.h:80
std::string source
Origin: "bundled", "file", "runtime", "dynamic".
Definition config.h:83
std::string key
Unique registry key (e.g., "compactor", "chess_executor")
Definition config.h:81
bool validated
true if grammar has passed validation
Definition config.h:84
std::string error
Non-empty if validation failed.
Definition config.h:85
std::string gbnf_content
Raw GBNF grammar string.
Definition config.h:82
Inference-side configuration knobs (v2.1.11).
Definition config.h:702
SpeculativeConfig speculative
Speculative decoding (gh#36)
Definition config.h:703
LSP integration configuration.
Definition config.h:543
bool python_enabled
Enable Python LSP.
Definition config.h:545
bool enabled
Enable LSP integration.
Definition config.h:544
bool c_enabled
Enable C/C++ LSP.
Definition config.h:546
std::unordered_map< std::string, LSPServerConfig > servers
Custom server overrides.
Definition config.h:547
Configuration for a single LSP server.
Definition config.h:533
std::string command
Server command.
Definition config.h:534
std::vector< std::string > args
Command arguments.
Definition config.h:535
std::vector< std::string > extensions
File extensions.
Definition config.h:536
MCP server configuration.
Definition config.h:455
ReconnectConfig reconnect
Reconnection backoff policy.
Definition config.h:469
bool enable_entropic
Enable entropic internal server (handoff, delegate, pipeline)
Definition config.h:456
FilesystemConfig filesystem
Filesystem server config.
Definition config.h:462
bool enable_filesystem
Enable filesystem server.
Definition config.h:457
std::unordered_map< std::string, ExternalServerEntry > external_servers
Named external servers.
Definition config.h:468
bool enable_git
Enable git server.
Definition config.h:459
bool enable_diagnostics
Enable diagnostics server.
Definition config.h:460
int server_timeout_seconds
Server timeout (5–300)
Definition config.h:464
uint32_t health_check_interval_ms
Ping interval (0 = disabled)
Definition config.h:470
uint32_t tool_call_timeout_ms
Per-call timeout for external tools.
Definition config.h:471
bool enable_bash
Enable bash server.
Definition config.h:458
ExternalMCPConfig external
External MCP server config (Entropic-as-server)
Definition config.h:463
std::string working_dir
Server working directory (empty = CWD) (v2.0.4)
Definition config.h:465
bool enable_web
Enable web server.
Definition config.h:461
A single authorized MCP key with access level.
Definition config.h:48
MCPAccessLevel level
Granted access level (READ or WRITE)
Definition config.h:50
std::string tool_pattern
Tool pattern (e.g., "filesystem.*", "git.status")
Definition config.h:49
Model configuration for a single tier.
Definition config.h:148
std::filesystem::path mmproj_path
Vision projector GGUF path.
Definition config.h:174
int gpu_layers
GPU offload layers (-1 = all)
Definition config.h:152
int reasoning_budget
Think token budget (-1 = unlimited)
Definition config.h:157
int context_length
Context window size (512–131072)
Definition config.h:151
std::filesystem::path path
Resolved model file path.
Definition config.h:149
std::string model_format
Expected model format.
Definition config.h:184
int n_threads
CPU threads (0 = auto-detect)
Definition config.h:161
std::string tensor_split
Multi-GPU tensor split ratios (empty = single GPU)
Definition config.h:162
std::string cache_type_k
KV cache key quantization type.
Definition config.h:158
bool keep_warm
Pre-warm model at startup.
Definition config.h:153
std::string cache_type_v
KV cache value quantization type.
Definition config.h:159
int n_batch
Batch size for prompt processing.
Definition config.h:160
bool flash_attn
Enable flash attention.
Definition config.h:163
bool use_mlock
Lock model in system RAM.
Definition config.h:154
std::optional< std::vector< std::string > > allowed_tools
Tool whitelist (nullopt = all)
Definition config.h:166
std::string adapter
Chat adapter name.
Definition config.h:150
Configuration for all models (tiers + router).
Definition config.h:356
std::optional< ModelConfig > router
Router model (separate from tiers)
Definition config.h:358
std::unordered_map< std::string, TierConfig > tiers
Tier name → config.
Definition config.h:357
std::string find_tier_by_path(const std::filesystem::path &model_path) const
Find tier name by model path.
Definition config.h:372
std::string default_tier
Default tier name.
Definition config.h:359
Full parsed configuration.
Definition config.h:714
int vram_reserve_mb
Reserved VRAM headroom (MB, 0–65536)
Definition config.h:735
StorageConfig storage
Storage backend settings (v1.8.8)
Definition config.h:723
PermissionsConfig permissions
Tool permissions.
Definition config.h:718
PromptCacheConfig prompt_cache
Prompt KV cache settings.
Definition config.h:722
std::optional< std::filesystem::path > app_context
App context: nullopt = disabled by default.
Definition config.h:731
CompactionConfig compaction
Auto-compaction settings.
Definition config.h:720
RoutingConfig routing
Routing rules.
Definition config.h:716
InferenceConfig inference
Inference-side knobs (currently speculative decoding only).
Definition config.h:760
ModelsConfig models
Tiers + router.
Definition config.h:715
LSPConfig lsp
LSP integration.
Definition config.h:721
ConstitutionalValidationConfig constitutional_validation
Constitutional validation pipeline settings.
Definition config.h:756
std::filesystem::path log_dir
Session log directory (session.log + session_model.log).
Definition config.h:742
bool ggml_logging
Enable ggml/llama.cpp logging to llama_ggml.log in log_dir.
Definition config.h:746
GenerationConfig generation
Default generation params.
Definition config.h:717
std::string log_level
Log level string.
Definition config.h:724
MCPConfig mcp
MCP server settings.
Definition config.h:719
bool console_logging
Emit engine spdlog output to the stderr console sink.
Definition config.h:753
bool inject_model_context
Auto-inject model context into system prompt.
Definition config.h:734
bool app_context_disabled
true if app_context explicitly disabled
Definition config.h:732
std::optional< std::filesystem::path > constitution
Constitution: nullopt = bundled default, disabled = explicit false.
Definition config.h:727
bool constitution_disabled
true if constitution explicitly disabled
Definition config.h:728
std::filesystem::path config_dir
Config dir — base for bundled data discovery.
Definition config.h:738
Tool permission configuration.
Definition config.h:400
std::vector< std::string > deny
Denied tool patterns (glob)
Definition config.h:402
std::vector< std::string > allow
Allowed tool patterns (glob)
Definition config.h:401
bool auto_approve
Skip confirmation prompts.
Definition config.h:403
Inference parameters for a single identity phase.
Definition config.h:772
int max_output_tokens
Max tokens per generation.
Definition config.h:774
float repeat_penalty
Repetition penalty.
Definition config.h:776
bool enable_thinking
Enable think-block output.
Definition config.h:775
std::optional< std::vector< std::string > > bash_commands
Phase-specific bash commands.
Definition config.h:777
float temperature
Sampling temperature.
Definition config.h:773
Prompt caching configuration.
Definition config.h:196
size_t max_bytes
Maximum cache RAM (512 MB default)
Definition config.h:197
bool log_hits
Log cache hit/miss at INFO level.
Definition config.h:199
bool enabled
Master switch (false = no caching)
Definition config.h:198
Reconnection policy configuration for external MCP servers.
Definition config.h:433
uint32_t max_retries
Max attempts (0 = infinite)
Definition config.h:436
uint32_t base_delay_ms
Initial retry delay.
Definition config.h:434
uint32_t max_delay_ms
Maximum retry delay cap.
Definition config.h:435
double backoff_factor
Exponential backoff multiplier.
Definition config.h:437
Configuration for model routing.
Definition config.h:388
std::string fallback_tier
Fallback when routing fails.
Definition config.h:390
std::unordered_map< std::string, std::vector< std::string > > handoff_rules
Tier handoff rules.
Definition config.h:393
bool enabled
Enable routing.
Definition config.h:389
std::optional< std::string > classification_prompt
Custom prompt (nullopt = auto)
Definition config.h:391
std::unordered_map< std::string, std::string > tier_map
Classification → tier mapping.
Definition config.h:392
Speculative-decoding configuration (inference.speculative.
Definition config.h:672
bool enabled
Master switch (off by default)
Definition config.h:673
int n_draft
Window size (proposed tokens)
Definition config.h:674
ModelConfig draft
Full ModelConfig for the draft model.
Definition config.h:690
Storage backend configuration.
Definition config.h:496
AuditLogConfig audit_log
Audit log settings (v1.9.5)
Definition config.h:501
std::filesystem::path db_path
SQLite database path (derived from config_dir)
Definition config.h:498
size_t log_max_files
Max rotated log files to keep.
Definition config.h:500
size_t log_max_file_size
Max log file size before rotation (10MB)
Definition config.h:499
bool enabled
Enable storage backend.
Definition config.h:497
Tier-specific model configuration.
Definition config.h:286
std::string get_param(const std::string &param_name) const
Get a named parameter derived from tier config fields.
Definition config.h:344
std::optional< bool > routable
None = defer to identity frontmatter.
Definition config.h:291
std::optional< std::filesystem::path > identity
Identity prompt path (nullopt = bundled)
Definition config.h:287
bool has_capability(const std::string &name) const
Return true if this tier declares the named capability.
Definition config.h:325
std::optional< std::string > auto_chain
Target tier name (nullopt = defer to identity)
Definition config.h:290
bool identity_disabled
true if identity explicitly disabled
Definition config.h:288
float adapter_scale
LoRA scaling factor (0.0–2.0, default 1.0).
Definition config.h:300
std::optional< std::filesystem::path > adapter_path
Optional path to LoRA adapter .gguf file.
Definition config.h:296
std::vector< std::string > capabilities
Declared tier capabilities (gh#41).
Definition config.h:316
std::optional< std::filesystem::path > grammar
Grammar file path.
Definition config.h:289