28 handlers_[
static_cast<int>(dtype)] = std::move(handler);
41 const std::vector<const Directive*>& directives) {
42 logger->info(
"Processing {} directive(s)", directives.size());
45 for (
const auto* directive : directives) {
46 if (directive ==
nullptr) {
50 auto it = handlers_.find(
static_cast<int>(directive->type));
51 bool has_handler = it != handlers_.end();
54 if (!fire_directive_hook(directive, has_handler)) {
59 logger->info(
"Directive type={}, handler invoked",
60 static_cast<int>(directive->type));
61 it->second(ctx, *directive, result);
68 logger->info(
"Directives: {}/{} processed", processed,
81bool DirectiveProcessor::fire_directive_hook(
82 const Directive* directive,
bool has_handler) {
83 if (hooks_.fire_pre ==
nullptr) {
87 auto point = has_handler
90 std::string json =
"{\"type\":"
91 + std::to_string(
static_cast<int>(directive->
type)) +
"}";
93 int rc = hooks_.fire_pre(hooks_.registry,
94 point, json.c_str(), &mod);
void register_handler(entropic_directive_type_t dtype, DirectiveHandler handler)
Register a handler for a directive type.
DirectiveResult process(LoopContext &ctx, const std::vector< const Directive * > &directives)
Process a list of directives.
Directive processing for tool-to-engine communication.
entropic_directive_type_t
Directive types emitted by MCP tool results.
@ ENTROPIC_HOOK_ON_CUSTOM_DIRECTIVE
19: Unrecognized directive type
@ ENTROPIC_HOOK_ON_DIRECTIVE
18: Before processing a directive
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Activate model on GPU (WARM → ACTIVE).
std::function< void(LoopContext &ctx, const Directive &directive, DirectiveResult &result)> DirectiveHandler
Directive handler function type.
Aggregate result of processing a batch of directives.
bool stop_processing
Halt further processing.
Base directive — all directives carry a type tag.
entropic_directive_type_t type
Discriminant for dispatch.
Mutable state carried through the agentic loop.