NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
hook_runtime.h
Go to the documentation of this file.
1
2#pragma once
3
5
6#include <atomic>
7#include <chrono>
8#include <memory>
9#include <optional>
10#include <string>
11
12namespace neograph::graph { class CancelToken; }
13
14namespace neograph {
15
29class NEOGRAPH_API HookRuntime final {
30public:
31 explicit HookRuntime(std::shared_ptr<MandatoryHookRunner> runner,
32 std::chrono::milliseconds default_timeout = std::chrono::seconds(30));
33
41 [[nodiscard]] static std::shared_ptr<HookRuntime> compose(std::shared_ptr<HookRuntime> outer,
42 std::shared_ptr<HookRuntime> inner);
43
44 asio::awaitable<void> emit_async(HookPhase phase, std::string type,
45 std::string owner_scope, std::string run_id, json data,
46 std::shared_ptr<graph::CancelToken> cancellation = {},
47 std::optional<std::chrono::system_clock::time_point> parent_deadline = {},
48 std::optional<std::uint64_t> event_sequence = {});
49
60 asio::awaitable<void> emit_once_async(HookPhase phase, std::string type,
61 std::string owner_scope, std::string run_id,
62 json data,
63 std::shared_ptr<graph::CancelToken> cancellation = {},
64 std::optional<std::chrono::system_clock::time_point> parent_deadline = {});
65
68 [[nodiscard]] static bool executing_hook_target() noexcept;
69
70private:
71 HookRuntime(std::shared_ptr<HookRuntime> outer, std::shared_ptr<HookRuntime> inner);
72
73 std::shared_ptr<MandatoryHookRunner> runner_;
74 std::chrono::milliseconds default_timeout_;
75 std::atomic<std::uint64_t> next_sequence_{0};
78 std::shared_ptr<HookRuntime> outer_;
79 std::shared_ptr<HookRuntime> inner_;
80};
81
82} // namespace neograph
Owns lifecycle-event identity and dispatch for one admitted host runtime.
static bool executing_hook_target() noexcept
Retained for source and binary compatibility.
static std::shared_ptr< HookRuntime > compose(std::shared_ptr< HookRuntime > outer, std::shared_ptr< HookRuntime > inner)
Both runtimes of a nested run, outer first: a subgraph whose engine has its own HookRuntime under a p...
asio::awaitable< void > emit_once_async(HookPhase phase, std::string type, std::string owner_scope, std::string run_id, json data, std::shared_ptr< graph::CancelToken > cancellation={}, std::optional< std::chrono::system_clock::time_point > parent_deadline={})
Emits an event whose data carries a durable identity, such as a tool call's (run, thread,...
Plans, journals, and executes mandatory hooks without owning lifecycle call sites.
Durable hook dispatch contracts and in-memory journal.