Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic_identity.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
13#include "engine_handle.h"
14
15#include <entropic/entropic.h>
17#include "json_serializers.h"
18
19static auto logger = entropic::log::get("facade.identity");
20
33
43extern "C" ENTROPIC_EXPORT entropic_error_t
45 entropic_handle_t handle,
46 const char* identity_name) {
47
48 auto rc = check_identity_mgr(handle);
49 if (rc != ENTROPIC_OK || !identity_name) {
51 }
52
53 bool found = handle->identity_manager->has(identity_name);
54 logger->info("load_identity: name='{}' found={}", identity_name, found);
56}
57
67extern "C" ENTROPIC_EXPORT entropic_error_t
69 entropic_handle_t handle,
70 char** identity_json) {
71
72 auto rc = check_identity_mgr(handle);
73 if (rc != ENTROPIC_OK || !identity_json) {
75 }
76
77 auto names = handle->identity_manager->list();
78 auto* cfg = names.empty()
79 ? nullptr : handle->identity_manager->get(names[0]);
80 if (!cfg) { return ENTROPIC_ERROR_IDENTITY_NOT_FOUND; }
81
82 auto j = facade_json::obj();
83 j["name"] = cfg->name;
84 j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC)
85 ? "static" : "dynamic";
86 *identity_json = strdup(j.dump().c_str());
87 return ENTROPIC_OK;
88}
Private definition of the entropic_engine struct.
Public C API for the Entropic inference engine.
ENTROPIC_EXPORT entropic_error_t entropic_load_identity(entropic_handle_t handle, const char *identity_name)
Load an identity by name — verify it exists.
ENTROPIC_EXPORT entropic_error_t entropic_get_identity(entropic_handle_t handle, char **identity_json)
Get an identity's config as JSON.
static entropic_error_t check_identity_mgr(entropic_handle_t h)
Check handle prerequisites for identity manager APIs.
entropic_error_t
Error codes returned by all C API functions.
Definition error.h:35
@ ENTROPIC_OK
Success.
Definition error.h:36
@ ENTROPIC_ERROR_IDENTITY_NOT_FOUND
Identity name not in config (v1.8.9)
Definition error.h:58
@ ENTROPIC_ERROR_INVALID_ARGUMENT
NULL pointer, empty string, out-of-range value.
Definition error.h:37
@ ENTROPIC_ERROR_INVALID_HANDLE
NULL or destroyed handle (v1.8.9)
Definition error.h:55
@ ENTROPIC_ERROR_INVALID_STATE
Operation not valid in current state (e.g., generate before activate)
Definition error.h:39
JSON serialization helpers for the facade.
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
@ STATIC
Loaded from YAML frontmatter file at startup.
Engine handle struct — owns all subsystems.
std::unique_ptr< entropic::IdentityManager > identity_manager
Identity lifecycle.