48#include <entropic/entropic_config.h>
99 const char* config_json);
120 const char* config_path);
149 const char* project_dir);
308 void (*on_token)(
const char* token,
size_t len,
void* user_data),
350 const char* messages_json,
373 const char* messages_json,
374 void (*on_token)(
const char* token,
size_t len,
void* user_data),
409 void (*observer)(
const char* token,
size_t len,
void* user_data),
434 void (*observer)(
int state,
void* user_data),
475 void (*start_cb)(
void* user_data),
476 void (*end_cb)(
void* user_data),
539 const char* message);
602 void (*observer)(
const char* consumed,
680 const char* tier_name,
681 const char* model_path,
682 size_t footprint_bytes,
794 char** messages_json);
871 ENT_DECISION_ACCEPT = 0,
872 ENT_DECISION_REJECT = 1
1004 int attempt_n,
void* user_data);
1117 const char* config_json);
1178 const char* db_path);
1217 const char* identity_name);
1240 char** identity_json);
1316 const char* adapter_name,
1317 const char* adapter_path,
1318 const char* base_model_path,
1334 const char* adapter_name);
1352 const char* adapter_name);
1366 const char* adapter_name);
1384 const char* adapter_name);
1420 const char* gbnf_content);
1531 const char* profile_json);
1596 const char* model_path);
1609 const char* model_path);
1642 const char* identity_name,
1643 const char* pattern,
1662 const char* identity_name,
1663 const char* pattern);
1679 const char* identity_name,
1680 const char* tool_name,
1699 const char* identity_name);
1721 const char* granter,
1722 const char* grantee,
1723 const char* pattern,
1815 const char* filter_json,
1816 char** result_json);
1843 const char* config_json);
1864 const char* config_json);
1967 const char* messages_json,
1968 const char* config_json,
1969 char** out_messages,
1992 const char* identity,
1993 char** result_json);
2018 const char* identity,
2038 const char* identity);
2114 const char* model_id,
2115 const int32_t* tokens,
2138 const char* model_id,
2139 const int32_t* tokens,
2191 const char* identity_name,
2231 const char* model_id);
ENTROPIC_EXPORT entropic_error_t entropic_profile_register(entropic_handle_t handle, const char *profile_json)
Register a custom GPU resource profile.
ENTROPIC_EXPORT entropic_error_t entropic_context_usage(entropic_handle_t handle, size_t *tokens_used, size_t *capacity)
Read current context-window pressure for the active tier.
ENTROPIC_EXPORT entropic_error_t entropic_run_messages_streaming(entropic_handle_t handle, const char *messages_json, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming variant of entropic_run_messages (gh#37).
ENTROPIC_EXPORT entropic_error_t entropic_set_attempt_boundary_cb(entropic_handle_t handle, ent_validation_attempt_boundary_cb cb, void *user_data)
Register an attempt-boundary callback for the validator.
struct entropic_logprob_result entropic_logprob_result_t
Per-token log-probability result.
ENTROPIC_EXPORT entropic_error_t entropic_grammar_register_file(entropic_handle_t handle, const char *key, const char *path)
Register a grammar from a file path.
ENTROPIC_EXPORT entropic_error_t entropic_register_compactor(entropic_handle_t handle, const char *identity, entropic_compactor_fn compactor, void *user_data)
Register a custom compactor for an identity.
ENTROPIC_EXPORT char * entropic_grammar_validate(const char *gbnf_content)
Validate a GBNF grammar string without registering.
ENTROPIC_EXPORT entropic_error_t entropic_deserialize_mcp_keys(entropic_handle_t handle, const char *json)
Deserialize all identity key sets from JSON.
ENTROPIC_EXPORT int64_t entropic_seconds_since_last_activity(entropic_handle_t handle)
Seconds since the engine last serviced a run (gh#35, v2.3.0).
ENTROPIC_EXPORT void * entropic_alloc(size_t size)
Allocate memory using the engine's allocator.
ENTROPIC_EXPORT char * entropic_grammar_list(entropic_handle_t handle)
List all registered grammars as JSON array.
ENTROPIC_EXPORT entropic_error_t entropic_load_identity(entropic_handle_t handle, const char *identity_name)
Load an identity by name from the configuration.
ENTROPIC_EXPORT entropic_error_t entropic_validation_accept_last(entropic_handle_t handle)
Finalize the last attempt as the turn's response.
ENTROPIC_EXPORT entropic_error_t entropic_set_state_observer(entropic_handle_t handle, void(*observer)(int state, void *user_data), void *user_data)
Register an engine state-change observer.
ENTROPIC_EXPORT entropic_error_t entropic_context_count(entropic_handle_t handle, size_t *count)
Get the number of messages in the conversation.
ENTROPIC_EXPORT entropic_error_t entropic_configure_dir(entropic_handle_t handle, const char *project_dir)
Configure engine using layered config resolution.
ENTROPIC_EXPORT entropic_error_t entropic_get_default_compactor(entropic_handle_t handle, entropic_compactor_fn *compactor, void **user_data)
Get the built-in default compactor function pointer.
ENTROPIC_EXPORT entropic_error_t entropic_register_mcp_server(entropic_handle_t handle, const char *name, const char *config_json)
Register an external MCP server at runtime.
ENTROPIC_EXPORT entropic_error_t entropic_storage_open(entropic_handle_t handle, const char *db_path)
Open or create a SQLite storage backend.
ent_decision_t(* ent_delegation_start_cb)(const ent_delegation_request_t *req, void *user_data)
Callback fired before a delegation runs.
ent_decision_t(* ent_delegation_complete_cb)(const ent_delegation_result_t *res, void *user_data)
Callback fired after a delegation produces a patch.
ENTROPIC_EXPORT char * entropic_grammar_get(entropic_handle_t handle, const char *key)
Get grammar content by key.
ENTROPIC_EXPORT entropic_error_t entropic_residency_snapshot(entropic_handle_t handle, char **out_json)
Snapshot of the engine's current VRAM residency set.
ENTROPIC_EXPORT entropic_error_t entropic_validation_resume_retry(entropic_handle_t handle)
Opt the engine into running the constitutional revision pass.
ENTROPIC_EXPORT int entropic_api_version(void)
Get the C API version number.
ENTROPIC_EXPORT entropic_error_t entropic_adapter_swap(entropic_handle_t handle, const char *adapter_name)
Swap the active LoRA adapter.
ENTROPIC_EXPORT entropic_error_t entropic_audit_flush(entropic_handle_t handle)
Flush the audit logger to disk immediately.
ENTROPIC_EXPORT entropic_error_t entropic_set_stream_observer(entropic_handle_t handle, void(*observer)(const char *token, size_t len, void *user_data), void *user_data)
Set a global stream observer callback.
ENTROPIC_EXPORT char * entropic_adapter_info(entropic_handle_t handle, const char *adapter_name)
Get adapter info as JSON.
ENTROPIC_EXPORT entropic_error_t entropic_context_clear(entropic_handle_t handle)
Clear conversation history, starting a new session.
ENTROPIC_EXPORT entropic_error_t entropic_adapter_load(entropic_handle_t handle, const char *adapter_name, const char *adapter_path, const char *base_model_path, float scale)
Load a LoRA adapter into RAM.
ENTROPIC_EXPORT entropic_error_t entropic_profile_deregister(entropic_handle_t handle, const char *name)
Remove a GPU resource profile.
ENTROPIC_EXPORT entropic_error_t entropic_get_logprobs(entropic_handle_t handle, const char *model_id, const int32_t *tokens, int n_tokens, entropic_logprob_result_t *result)
Evaluate per-token log-probabilities for a token sequence.
ENTROPIC_EXPORT entropic_error_t entropic_update_identity(entropic_handle_t handle, const char *name, const char *config_json)
Update a dynamic identity.
ent_decision_t
Consumer decision returned from delegation callbacks.
ENTROPIC_EXPORT entropic_error_t entropic_configure(entropic_handle_t handle, const char *config_json)
Configure the engine from a JSON config string.
ENTROPIC_EXPORT entropic_error_t entropic_validation_set_auto_retry(entropic_handle_t handle, int enabled)
Toggle automatic constitutional revision after rejection.
ENTROPIC_EXPORT entropic_error_t entropic_identity_count(entropic_handle_t handle, size_t *total, size_t *dynamic)
Get identity count.
ENTROPIC_EXPORT entropic_error_t entropic_compute_perplexity(entropic_handle_t handle, const char *model_id, const int32_t *tokens, int n_tokens, float *perplexity)
Compute perplexity for a token sequence.
ENTROPIC_EXPORT void entropic_destroy(entropic_handle_t handle)
Destroy an engine instance and free all resources.
ENTROPIC_EXPORT void entropic_throughput_reset(entropic_handle_t handle, const char *model_path)
Reset throughput tracking data for a model.
ENTROPIC_EXPORT entropic_error_t entropic_run(entropic_handle_t handle, const char *input, char **result_json)
Synchronous agentic loop.
ENTROPIC_EXPORT entropic_error_t entropic_grammar_register(entropic_handle_t handle, const char *key, const char *gbnf_content)
Register a grammar by key from a GBNF content string.
ENTROPIC_EXPORT entropic_error_t entropic_queue_user_message(entropic_handle_t handle, const char *message)
Queue a user message to be injected at the next top-level turn boundary.
ENTROPIC_EXPORT char * entropic_list_identities(entropic_handle_t handle)
List all identity names as JSON array.
ENTROPIC_EXPORT int entropic_check_mcp_key(entropic_handle_t handle, const char *identity_name, const char *tool_name, entropic_mcp_access_level_t level)
Check if a tool call is authorized for an identity.
ENTROPIC_EXPORT char * entropic_profile_get(entropic_handle_t handle, const char *name)
Get a profile by name as JSON.
ENTROPIC_EXPORT entropic_error_t entropic_deregister_compactor(entropic_handle_t handle, const char *identity)
Deregister a custom compactor for an identity.
ENTROPIC_EXPORT entropic_error_t entropic_grant_mcp_key(entropic_handle_t handle, const char *identity_name, const char *pattern, entropic_mcp_access_level_t level)
Grant an MCP tool key to an identity.
ENTROPIC_EXPORT char * entropic_profile_list(entropic_handle_t handle)
List all registered profiles as JSON array.
void(* entropic_residency_observer_t)(entropic_residency_event_t event, const char *tier_name, const char *model_path, size_t footprint_bytes, void *user_data)
Residency observer callback.
ENTROPIC_EXPORT entropic_error_t entropic_create_identity(entropic_handle_t handle, const char *config_json)
Create a dynamic identity.
ENTROPIC_EXPORT entropic_error_t entropic_destroy_identity(entropic_handle_t handle, const char *name)
Destroy a dynamic identity.
ENTROPIC_EXPORT entropic_error_t entropic_audit_read(entropic_handle_t handle, const char *path, const char *filter_json, char **result_json)
Read audit log entries from a JSONL file.
ENTROPIC_EXPORT int entropic_adapter_state(entropic_handle_t handle, const char *adapter_name)
Query adapter state.
ENTROPIC_EXPORT entropic_error_t entropic_set_critique_callbacks(entropic_handle_t handle, void(*start_cb)(void *user_data), void(*end_cb)(void *user_data), void *user_data)
Register start/end callbacks for constitutional critique generation (gh#50, v2.1.12).
ENTROPIC_EXPORT entropic_error_t entropic_get_diagnostic_prompt(entropic_handle_t handle, char **prompt_out)
Get the diagnostic prompt text for /diagnose command.
ENTROPIC_EXPORT entropic_error_t entropic_audit_count(entropic_handle_t handle, size_t *count)
Get the number of audit log entries recorded this session.
ENTROPIC_EXPORT entropic_error_t entropic_speculative_compat(entropic_handle_t handle, int *compatible, char **diagnostic)
Query whether the configured target/draft pair is compatible for speculative decoding.
ENTROPIC_EXPORT entropic_error_t entropic_metrics_json(entropic_handle_t handle, char **out)
Get loop metrics from the most recent run as JSON.
ENTROPIC_EXPORT entropic_error_t entropic_validation_set_identity(entropic_handle_t handle, const char *identity_name, bool enabled)
Set per-identity validation override.
ENTROPIC_EXPORT int entropic_model_has_vision(entropic_handle_t handle, const char *model_id)
Check if a model has vision capability.
ENTROPIC_EXPORT entropic_error_t entropic_user_message_queue_depth(entropic_handle_t handle, size_t *count)
Query the current depth of the mid-gen user-message queue.
ENTROPIC_EXPORT entropic_error_t entropic_revoke_mcp_key(entropic_handle_t handle, const char *identity_name, const char *pattern)
Revoke an MCP tool key from an identity.
ENTROPIC_EXPORT char * entropic_serialize_mcp_keys(entropic_handle_t handle)
Serialize all identity key sets to JSON.
ENTROPIC_EXPORT char * entropic_get_identity_config(entropic_handle_t handle, const char *name)
Get identity configuration as JSON by name.
entropic_residency_event_t
Reasons fired by entropic_residency_observer_t.
@ ENTROPIC_RESIDENCY_EVICTED
Tier model just unloaded to free VRAM.
@ ENTROPIC_RESIDENCY_LOADED
Tier model just loaded into VRAM.
@ ENTROPIC_RESIDENCY_ACTIVATION_SWAP
Active tier swapped without unload (multi-resident hit)
ENTROPIC_EXPORT const char * entropic_version(void)
Get the library version string.
ENTROPIC_EXPORT char * entropic_validation_last_result(entropic_handle_t handle)
Get the last validation result as JSON.
ENTROPIC_EXPORT entropic_error_t entropic_interrupt(entropic_handle_t handle)
Interrupt a running generation.
ENTROPIC_EXPORT entropic_error_t entropic_deregister_hook(entropic_handle_t handle, entropic_hook_point_t hook_point, entropic_hook_callback_t callback, void *user_data)
Deregister a previously registered hook callback.
ENTROPIC_EXPORT char * entropic_list_mcp_servers(entropic_handle_t handle)
List all MCP servers with status information.
ENTROPIC_EXPORT void entropic_free(void *ptr)
Free memory allocated by the engine or entropic_alloc().
int(* entropic_compactor_fn)(const char *messages_json, const char *config_json, char **out_messages, char **out_summary, void *user_data)
Compactor function type.
ENTROPIC_EXPORT entropic_error_t entropic_set_delegation_callbacks(entropic_handle_t handle, ent_delegation_start_cb on_start, ent_delegation_complete_cb on_complete, void *user_data)
Register start/complete callbacks for delegations.
ENTROPIC_EXPORT char * entropic_list_mcp_keys(entropic_handle_t handle, const char *identity_name)
List all MCP keys for an identity as JSON.
ENTROPIC_EXPORT entropic_error_t entropic_grammar_deregister(entropic_handle_t handle, const char *key)
Remove a grammar from the registry.
ENTROPIC_EXPORT entropic_error_t entropic_grant_mcp_key_from(entropic_handle_t handle, const char *granter, const char *grantee, const char *pattern, entropic_mcp_access_level_t level)
Grant a key from one identity to another.
ENTROPIC_EXPORT entropic_error_t entropic_adapter_unload(entropic_handle_t handle, const char *adapter_name)
Unload a LoRA adapter.
ENTROPIC_EXPORT entropic_error_t entropic_clear_user_message_queue(entropic_handle_t handle)
Drop all queued user messages.
ENTROPIC_EXPORT void entropic_free_logprob_result(entropic_logprob_result_t *result)
Free internal arrays of a logprob result.
ENTROPIC_EXPORT entropic_error_t entropic_set_queue_observer(entropic_handle_t handle, void(*observer)(const char *consumed, size_t remaining, void *user_data), void *user_data)
Register an observer for queue-consumption events.
ENTROPIC_EXPORT entropic_error_t entropic_get_identity(entropic_handle_t handle, char **identity_json)
Get the current active identity as a JSON string.
ENTROPIC_EXPORT entropic_error_t entropic_run_messages(entropic_handle_t handle, const char *messages_json, char **result_json)
Multimodal-aware agentic run with messages-array input (gh#37).
ENTROPIC_EXPORT entropic_error_t entropic_validation_set_enabled(entropic_handle_t handle, bool enabled)
Enable or disable constitutional validation.
ENTROPIC_EXPORT entropic_error_t entropic_context_get(entropic_handle_t handle, char **messages_json)
Get the current conversation history as a JSON array.
ENTROPIC_EXPORT entropic_error_t entropic_compact(entropic_handle_t handle, const char *identity, char **result_json)
Trigger compaction on the current context.
ENTROPIC_EXPORT entropic_error_t entropic_create(entropic_handle_t *handle)
Create a new engine instance.
ENTROPIC_EXPORT entropic_error_t entropic_register_hook(entropic_handle_t handle, entropic_hook_point_t hook_point, entropic_hook_callback_t callback, void *user_data, int priority)
Register a callback for an engine hook point.
ENTROPIC_EXPORT double entropic_throughput_tok_per_sec(entropic_handle_t handle, const char *model_path)
Get current throughput estimate for a model.
entropic_mcp_access_level_t
Access level enum for MCP authorization.
@ ENTROPIC_MCP_ACCESS_WRITE
Read + write operations.
@ ENTROPIC_MCP_ACCESS_NONE
No access.
@ ENTROPIC_MCP_ACCESS_READ
Read-only operations.
ENTROPIC_EXPORT entropic_error_t entropic_set_residency_observer(entropic_handle_t handle, entropic_residency_observer_t observer, void *user_data)
Register a residency observer on a handle.
ENTROPIC_EXPORT entropic_error_t entropic_run_streaming(entropic_handle_t handle, const char *input, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming agentic loop with token callback.
void(* ent_validation_attempt_boundary_cb)(int attempt_n, void *user_data)
Stream-side callback fired between constitutional revision passes.
ENTROPIC_EXPORT entropic_error_t entropic_configure_from_file(entropic_handle_t handle, const char *config_path)
Configure engine from a YAML or JSON config file.
ENTROPIC_EXPORT char * entropic_adapter_list(entropic_handle_t handle)
List all adapters as JSON array.
ENTROPIC_EXPORT entropic_error_t entropic_storage_close(entropic_handle_t handle)
Close the storage backend and flush pending writes.
ENTROPIC_EXPORT entropic_error_t entropic_deregister_mcp_server(entropic_handle_t handle, const char *name)
Deregister an external MCP server.
Symbol visibility macro for all exported symbols.
Error types for cross-.so error reporting.
entropic_error_t
Error codes returned by all C API functions.
Hook point enum and callback types for engine lifecycle hooks.
int(* entropic_hook_callback_t)(entropic_hook_point_t hook_point, const char *context_json, char **modified_json, void *user_data)
Hook callback function type.
entropic_hook_point_t
Hook points in the engine lifecycle.
Request describing a delegation that is about to run.
const char * target_tier
Tier name (e.g. "researcher")
const char * delegation_id
Short id ("d1", "d2", "pipeline")
int is_pipeline
1 for pipeline stages, 0 for single
const char * task
Task description text.
int depth
Delegation depth (1 = top-level child)
Result of a finalized delegation, delivered to the consumer.
const char * patch
Unified diff (may be empty string)
const char * delegation_id
Short id (matches request)
size_t patch_len
Byte length of patch (excluding NUL)
const char * target_tier
Tier that executed.
int success
1 if child reached COMPLETE, 0 otherwise
size_t files_touched_len
Count (excluding the NULL terminator)
const char * summary
Final summary text from the child.
const char *const * files_touched
NULL-terminated array of relpaths.
Engine handle struct — owns all subsystems.
Per-token log-probability result.
float perplexity
exp(-mean(logprobs)) over the sequence.
int32_t * tokens
Input tokens echoed back (N values).
int n_logprobs
Number of logprob values (n_tokens - 1).
int n_tokens
Number of input tokens.
float * logprobs
Per-token log-probabilities (N-1 values).
float total_logprob
Sum of all logprob values.