Entropic 2.11.1
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic_hooks.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
12#include "engine_handle.h"
13
14#include <entropic/entropic.h>
16
17static auto logger = entropic::log::get("facade.hooks");
18
31 return &handle->hook_registry;
32}
33
42extern "C" ENTROPIC_EXPORT entropic_error_t
44 entropic_handle_t handle,
45 entropic_hook_point_t hook_point,
47 void* user_data,
48 int priority) {
49
50 if (!handle) {
52 }
53 if (!callback) {
55 }
56
57 return get_registry(handle)->register_hook(
58 hook_point, callback, user_data, priority);
59}
60
69extern "C" ENTROPIC_EXPORT entropic_error_t
71 entropic_handle_t handle,
72 entropic_hook_point_t hook_point,
74 void* user_data) {
75
76 if (!handle) {
78 }
79
80 return get_registry(handle)->deregister_hook(
81 hook_point, callback, user_data);
82}
Thread-safe hook registration and dispatch.
entropic_error_t register_hook(entropic_hook_point_t point, entropic_hook_callback_t callback, void *user_data, int priority)
Register a hook callback at a hook point.
entropic_error_t deregister_hook(entropic_hook_point_t point, entropic_hook_callback_t callback, void *user_data)
Deregister a hook callback.
Private definition of the entropic_engine struct.
Public C API for the Entropic inference engine.
static entropic::HookRegistry * get_registry(entropic_handle_t handle)
Resolve HookRegistry from engine handle.
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 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 hook callback for a hook point.
entropic_error_t
Error codes returned by all C API functions.
Definition error.h:37
@ ENTROPIC_ERROR_INVALID_ARGUMENT
NULL pointer, empty string, out-of-range value.
Definition error.h:39
@ ENTROPIC_ERROR_INVALID_HANDLE
NULL or destroyed handle (v1.8.9)
Definition error.h:57
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.
Definition hooks.h:139
entropic_hook_point_t
Hook points in the engine lifecycle.
Definition hooks.h:39
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Definition logging.cpp:211
Engine handle struct — owns all subsystems.
entropic::HookRegistry hook_registry
Hook dispatch.