Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
directives.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
15#pragma once
16
20
21#include <functional>
22#include <string>
23#include <unordered_map>
24#include <vector>
25
26namespace entropic {
27
28struct LoopContext; // forward declaration
29
30// ── Directive structs ────────────────────────────────────
31
39
53
59 std::string tier;
60 std::string reason;
61
68 TierChangeDirective(std::string t = "", std::string r = "")
69 : tier(std::move(t)), reason(std::move(r)) {
71 }
72};
73
84struct ContextRef {
85 std::string path;
86 std::string lines;
87 std::string note;
88};
89
107 std::string target;
108 std::string task;
109 int max_turns = -1;
111 std::vector<ContextRef> context;
115 bool resume_by_target = false;
116
125 DelegateDirective(std::string tgt = "",
126 std::string tsk = "",
127 int mt = -1,
128 std::string resume_id = "")
129 : target(std::move(tgt)),
130 task(std::move(tsk)),
131 max_turns(mt),
134 }
135};
136
142 std::vector<std::string> stages;
143 std::string task;
144 std::vector<ContextRef> context;
145
152 PipelineDirective(std::vector<std::string> s = {},
153 std::string t = "")
154 : stages(std::move(s)), task(std::move(t)) {
156 }
157};
158
174 std::string summary;
175 bool coverage_gap = false;
176 std::string gap_description;
177 std::vector<std::string> suggested_files;
178
184 explicit CompleteDirective(std::string s = "")
185 : summary(std::move(s)) {
187 }
188};
189
203
209 std::string content;
210 std::string role = "user";
211
218 InjectContextDirective(std::string c = "",
219 std::string r = "user")
220 : content(std::move(c)), role(std::move(r)) {
222 }
223};
224
242
248 std::string key;
249 std::string content;
250
257 ContextAnchorDirective(std::string k = "",
258 std::string c = "")
259 : key(std::move(k)), content(std::move(c)) {
261 }
262};
263
269 std::string phase;
270
276 explicit PhaseChangeDirective(std::string p = "")
277 : phase(std::move(p)) {
279 }
280};
281
287 std::string key;
288 std::string data_json;
289
296 NotifyPresenterDirective(std::string k = "",
297 std::string d = "")
298 : key(std::move(k)), data_json(std::move(d)) {
300 }
301};
302
303// ── DirectiveResult ──────────────────────────────────────
304
310 bool stop_processing = false;
311 bool tier_changed = false;
312 std::vector<Message> injected_messages;
313};
314
315// ── DirectiveHandler type ────────────────────────────────
316
325using DirectiveHandler = std::function<void(
327 const Directive& directive,
328 DirectiveResult& result)>;
329
330// ── DirectiveProcessor ───────────────────────────────────
331
341public:
350
360 const std::vector<const Directive*>& directives);
361
368 void set_hooks(const HookInterface& hooks) { hooks_ = hooks; }
369
370private:
378 bool fire_directive_hook(const Directive* directive,
379 bool has_handler);
380
381 std::unordered_map<int, DirectiveHandler> handlers_;
382 HookInterface hooks_;
383};
384
385} // namespace entropic
Processes tool directives via registry-based dispatch.
Definition directives.h:340
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.
void set_hooks(const HookInterface &hooks)
Set the hook dispatch interface.
Definition directives.h:368
Shared enumerations used across .so boundaries.
entropic_directive_type_t
Directive types emitted by MCP tool results.
Definition enums.h:58
@ ENTROPIC_DIRECTIVE_TIER_CHANGE
Switch active tier.
Definition enums.h:60
@ ENTROPIC_DIRECTIVE_STOP_PROCESSING
Halt directive processing.
Definition enums.h:59
@ ENTROPIC_DIRECTIVE_PRUNE_MESSAGES
Prune old tool results.
Definition enums.h:66
@ ENTROPIC_DIRECTIVE_INJECT_CONTEXT
Inject message into context.
Definition enums.h:65
@ ENTROPIC_DIRECTIVE_COMPLETE
Mark task complete.
Definition enums.h:63
@ ENTROPIC_DIRECTIVE_NOTIFY_PRESENTER
Generic UI notification passthrough.
Definition enums.h:69
@ ENTROPIC_DIRECTIVE_CLEAR_SELF_TODOS
Clear self-directed todos (engine no-op)
Definition enums.h:64
@ ENTROPIC_DIRECTIVE_PHASE_CHANGE
Switch active inference phase.
Definition enums.h:68
@ ENTROPIC_DIRECTIVE_PIPELINE
Multi-stage sequential execution.
Definition enums.h:62
@ ENTROPIC_DIRECTIVE_CONTEXT_ANCHOR
Replace context anchor.
Definition enums.h:67
@ ENTROPIC_DIRECTIVE_DELEGATE
Route to another identity.
Definition enums.h:61
Hook dispatch interface injected into engine subsystems.
Message struct for conversation history.
Activate model on GPU (WARM → ACTIVE).
@ optional
optional: every escape asks the host's path approver
std::function< void(LoopContext &ctx, const Directive &directive, DirectiveResult &result)> DirectiveHandler
Directive handler function type.
Definition directives.h:328
Clear self-directed todos (engine no-op).
Definition directives.h:194
ClearSelfTodosDirective()
Construct a ClearSelfTodos directive.
Definition directives.h:199
Signal explicit completion.
Definition directives.h:173
std::string summary
Completion summary.
Definition directives.h:174
bool coverage_gap
Suppresses auto-relay (#10, v2.1.4)
Definition directives.h:175
std::string gap_description
What the gap IS (#10, v2.1.4)
Definition directives.h:176
CompleteDirective(std::string s="")
Construct a Complete directive.
Definition directives.h:184
std::vector< std::string > suggested_files
Files for lead to inspect (#10, v2.1.4)
Definition directives.h:177
Update a keyed persistent context anchor.
Definition directives.h:247
std::string content
Anchor content (empty = remove)
Definition directives.h:249
ContextAnchorDirective(std::string k="", std::string c="")
Construct a ContextAnchor directive.
Definition directives.h:257
std::string key
Anchor key (unique, update-in-place)
Definition directives.h:248
One file the lead already paid to find (gh#162, v2.13.0).
Definition directives.h:84
std::string lines
Optional line range, e.g. "40-95" ("" = whole file)
Definition directives.h:86
std::string path
Repo-relative (or absolute) file path.
Definition directives.h:85
std::string note
Optional one-line reason this file matters.
Definition directives.h:87
Delegate a task to a child inference loop.
Definition directives.h:106
int max_turns
Max turns (-1 = default)
Definition directives.h:109
std::vector< ContextRef > context
gh#162 (v2.13.0): seeded file references
Definition directives.h:111
std::string target
Target tier for delegation.
Definition directives.h:107
std::string task
Task description.
Definition directives.h:108
bool resume_by_target
gh#162 (v2.13.0): resume the most recent delegation to target instead of naming a storage id.
Definition directives.h:115
std::string resume_from_delegation_id
gh#32 (v2.1.6): empty = fresh delegate
Definition directives.h:110
DelegateDirective(std::string tgt="", std::string tsk="", int mt=-1, std::string resume_id="")
Construct a Delegate directive.
Definition directives.h:125
Aggregate result of processing a batch of directives.
Definition directives.h:309
std::vector< Message > injected_messages
Messages to inject.
Definition directives.h:312
bool stop_processing
Halt further processing.
Definition directives.h:310
bool tier_changed
Tier was switched.
Definition directives.h:311
Base directive — all directives carry a type tag.
Definition directives.h:36
entropic_directive_type_t type
Discriminant for dispatch.
Definition directives.h:37
Inject a message into the conversation context.
Definition directives.h:208
std::string content
Content to inject.
Definition directives.h:209
std::string role
Message role.
Definition directives.h:210
InjectContextDirective(std::string c="", std::string r="user")
Construct an InjectContext directive.
Definition directives.h:218
Mutable state carried through the agentic loop.
Generic UI notification passthrough.
Definition directives.h:286
std::string key
Notification key.
Definition directives.h:287
NotifyPresenterDirective(std::string k="", std::string d="")
Construct a NotifyPresenter directive.
Definition directives.h:296
std::string data_json
Arbitrary JSON payload.
Definition directives.h:288
Switch the active inference phase.
Definition directives.h:268
std::string phase
Target phase name.
Definition directives.h:269
PhaseChangeDirective(std::string p="")
Construct a PhaseChange directive.
Definition directives.h:276
Execute a multi-stage delegation pipeline.
Definition directives.h:141
std::vector< ContextRef > context
gh#162 (v2.13.0): seeded file references
Definition directives.h:144
std::string task
Task description.
Definition directives.h:143
std::vector< std::string > stages
Tier names in order.
Definition directives.h:142
PipelineDirective(std::vector< std::string > s={}, std::string t="")
Construct a Pipeline directive.
Definition directives.h:152
Prune old tool results from context.
Definition directives.h:229
PruneMessagesDirective(int k=2)
Construct a PruneMessages directive.
Definition directives.h:237
int keep_recent
How many recent results to keep.
Definition directives.h:230
Stop processing remaining tool calls.
Definition directives.h:44
StopProcessingDirective()
Construct a StopProcessing directive.
Definition directives.h:49
Request a tier change.
Definition directives.h:58
std::string reason
Why the change was requested.
Definition directives.h:60
std::string tier
Target tier name.
Definition directives.h:59
TierChangeDirective(std::string t="", std::string r="")
Construct a TierChange directive.
Definition directives.h:68