Module: RubyLlmMesh::NativeCore

Defined in:
lib/ruby_llm_mesh/native_core.rb,
sig/ruby_llm_mesh.rbs

Overview

Soft-loaded FFI bridge to the chimera_core native library. When the shared library is missing or ffi is unavailable, methods degrade to pure-Ruby fallbacks instead of crashing on require.

Defined Under Namespace

Modules: Fallback

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/ruby_llm_mesh/native_core.rb', line 11

def available?
  !!@native_loaded
end

.execute_wasm_payload(intent) ⇒ Hash[String, untyped]

Parameters:

  • (String)

Returns:

  • (Hash[String, untyped])


42
43
44
45
46
47
48
49
50
51
# File 'lib/ruby_llm_mesh/native_core.rb', line 42

def execute_wasm_payload(intent)
  ensure_boot_attempted!
  intent = intent.to_s
  raw = if available?
          @lib.execute_wasm_payload_string(intent)
        else
          Fallback.execute_wasm_payload(intent)
        end
  parse_payload(raw)
end

.node_alive?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
# File 'lib/ruby_llm_mesh/native_core.rb', line 33

def node_alive?
  ensure_boot_attempted!
  if available?
    !!@lib.node_alive
  else
    Fallback.node_alive?
  end
end

.reset!Object



60
61
62
63
64
65
66
# File 'lib/ruby_llm_mesh/native_core.rb', line 60

def reset!
  stop_node if node_alive?
  @boot_attempted = false
  @native_loaded = false
  @lib = nil
  Fallback.reset!
end

.start_node(port = RubyLlmMesh.configuration.mesh_port) ⇒ Boolean

Parameters:

  • (Integer)

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
# File 'lib/ruby_llm_mesh/native_core.rb', line 15

def start_node(port = RubyLlmMesh.configuration.mesh_port)
  ensure_boot_attempted!
  if available?
    !!@lib.start_node(Integer(port))
  else
    Fallback.start_node(port)
  end
end

.stop_nodeBoolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
# File 'lib/ruby_llm_mesh/native_core.rb', line 24

def stop_node
  ensure_boot_attempted!
  if available?
    !!@lib.stop_node
  else
    Fallback.stop_node
  end
end

.versionObject



53
54
55
56
57
58
# File 'lib/ruby_llm_mesh/native_core.rb', line 53

def version
  ensure_boot_attempted!
  return @lib.chimera_core_version_string if available?

  "fallback-#{RubyLlmMesh::VERSION}"
end