From a97ddfdbd0331f7af77d06c91028517e120ddea1 Mon Sep 17 00:00:00 2001 From: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:39:16 -0800 Subject: [PATCH] Add name retrieval to bindings --- conversations/src/api.rs | 6 ++++++ nim-bindings/src/bindings.nim | 4 ++++ nim-bindings/src/libchat.nim | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/conversations/src/api.rs b/conversations/src/api.rs index f8c8346..048546a 100644 --- a/conversations/src/api.rs +++ b/conversations/src/api.rs @@ -53,6 +53,12 @@ pub fn create_context(name: String) -> repr_c::Box { Box::new(ContextHandle(Context::new_with_name(name))).into() } +/// Returns the friendly name of the context's identity +#[ffi_export] +pub fn get_friendly_name(ctx: &ContextHandle) -> repr_c::String { + ctx.0.get_friendly_name().to_string().into() +} + /// Destroys a conversation store and frees its memory /// /// # Safety diff --git a/nim-bindings/src/bindings.nim b/nim-bindings/src/bindings.nim index 3c30bc8..e616708 100644 --- a/nim-bindings/src/bindings.nim +++ b/nim-bindings/src/bindings.nim @@ -99,6 +99,10 @@ type ## Returns: Opaque handle to the context. Must be freed with destroy_context() proc create_context*(name: ReprCString): ContextHandle {.importc, dynlib: CONVERSATIONS_LIB.} +## Returns the friendly name of the context's identity +## The result must be freed by the caller (repr_c::String ownership transfers) +proc get_friendly_name*(ctx: ContextHandle): ReprCString {.importc, dynlib: CONVERSATIONS_LIB.} + ## Destroys a context and frees its memory ## - handle must be a valid pointer from create_context() ## - handle must not be used after this call diff --git a/nim-bindings/src/libchat.nim b/nim-bindings/src/libchat.nim index 806e72f..9836813 100644 --- a/nim-bindings/src/libchat.nim +++ b/nim-bindings/src/libchat.nim @@ -20,6 +20,13 @@ proc newConversationsContext*(name: string): LibChat = if result.handle.isNil: raise newException(IOError, "Failed to create context") +## Get the friendly name of this context's installation +proc getInstallationName*(ctx: LibChat): string = + if ctx.handle == nil: + return "" + let name = get_friendly_name(ctx.handle) + result = $name + ## Destroy the context and free resources proc destroy*(ctx: var LibChat) =