34#include <nlohmann/json_fwd.hpp>
43#include <unordered_map>
44#include <unordered_set>
80 const std::filesystem::path& project_dir);
103 const std::filesystem::path&
socket_path()
const {
return socket_path_; }
126 nlohmann::json handle_ask_status(
const nlohmann::json& args);
149 void attach_phase_observer(
const std::string& task_id);
156 void detach_phase_observer();
158 void run_async_ask(
const std::string& prompt,
159 const std::string& task_id,
182 void write_sentinel(
const std::string& task_id,
183 const std::string& status);
200 std::filesystem::path async_sentinel_dir()
const;
215 void set_async_sentinel_root(
const std::filesystem::path& root);
222 void cleanup_expired_tasks();
237 std::string status =
"queued";
238 std::string phase =
"queued";
240 std::chrono::steady_clock::time_point
created;
266 return active_task_id_;
275 void subscribe(
int fd);
283 void unsubscribe(
int fd);
296 void broadcast_notification(
const nlohmann::json& notif);
305 std::lock_guard<std::mutex> lock(subscribers_mutex_);
306 return subscribers_.size();
322 void update_task_phase(
const std::string& task_id,
323 const std::string& status,
324 const std::string& phase);
340 return observer_gen_.load() != attached_gen_;
357 void serve_client(
int client_fd);
367 std::string dispatch(
const std::string& request,
int client_fd);
379 void reap_finished_clients_locked();
383 std::filesystem::path socket_path_;
384 std::string bound_canonical_;
386 std::atomic<bool> running_{
false};
387 std::thread accept_thread_;
397 struct ClientThread {
399 std::atomic<bool> finished{
false};
402 std::vector<std::unique_ptr<ClientThread>> client_threads_;
403 mutable std::mutex client_threads_mutex_;
406 std::unordered_map<std::string, AsyncTask> tasks_;
413 std::unordered_set<int> subscribers_;
414 mutable std::mutex subscribers_mutex_;
421 std::string active_task_id_;
427 std::atomic<uint64_t> observer_gen_{0};
432 uint64_t attached_gen_ = 0;
437 std::filesystem::path async_sentinel_root_override_;
Unix socket MCP bridge for external client access.
std::mutex tasks_mutex_
Async task mutex (public for dispatch_tool access).
const std::string & active_task_id_for_observer() const
Return the currently-active async task_id (if any).
const std::filesystem::path & socket_path() const
Get the socket path (for logging/diagnostics).
bool ask_streaming() const
Whether entropic.ask routes through entropic_run_streaming.
bool observer_call_is_stale() const
Test whether an in-flight observer callback is stale.
std::unordered_map< std::string, AsyncTask > & tasks_for_cancel()
Mutable accessor to the task registry.
size_t subscriber_count() const
Current subscriber count (for diagnostics / testing).
Configuration structs with defaults.
Symbol visibility macro for all exported symbols.
Activate model on GPU (WARM → ACTIVE).
Async task state for background entropic.ask runs.
std::string result
Final text or error message.
std::chrono::steady_clock::time_point created
For TTL cleanup.
External MCP server configuration (Entropic-as-server).
Engine handle struct — owns all subsystems.