Entropic 2.11.1
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
44extern "C" ENTROPIC_EXPORT entropic_error_t
46 entropic_handle_t handle,
47 const char* identity_name) {
48
49 auto rc = check_identity_mgr(handle);
50 if (rc != ENTROPIC_OK || !identity_name) {
52 }
53
54 bool found = handle->identity_manager->has(identity_name);
55 logger->info("load_identity: name='{}' found={}", identity_name, found);
57}
58
70extern "C" ENTROPIC_EXPORT entropic_error_t
72 entropic_handle_t handle,
73 char** identity_json) {
74
75 auto rc = check_identity_mgr(handle);
76 if (rc != ENTROPIC_OK || !identity_json) {
78 }
79
80 auto names = handle->identity_manager->list();
81 auto* cfg = names.empty()
82 ? nullptr : handle->identity_manager->get(names[0]);
83 if (!cfg) { return ENTROPIC_ERROR_IDENTITY_NOT_FOUND; }
84
85 auto j = facade_json::obj();
86 j["name"] = cfg->name;
87 j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC)
88 ? "static" : "dynamic";
89 *identity_json = strdup(j.dump().c_str());
90 return ENTROPIC_OK;
91}
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:37
@ ENTROPIC_OK
Success.
Definition error.h:38
@ ENTROPIC_ERROR_IDENTITY_NOT_FOUND
Identity name not in config (v1.8.9)
Definition error.h:60
@ ENTROPIC_ERROR_INVALID_ARGUMENT
NULL pointer, empty string, out-of-range value.
Definition error.h:39
@ ENTROPIC_ERROR_INVALID_HANDLE
NULL or destroyed handle (v1.8.9)
Definition error.h:57
@ ENTROPIC_ERROR_INVALID_STATE
Operation not valid in current state (e.g., generate before activate)
Definition error.h:41
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.