Module: LittleGhost::CodeMode

Defined in:
lib/little_ghost/code_mode.rb,
lib/little_ghost/code_mode/types.rb,
lib/little_ghost/code_mode/broker.rb,
lib/little_ghost/code_mode/engine.rb,
lib/little_ghost/code_mode/catalog.rb,
lib/little_ghost/code_mode/runtime.rb,
lib/little_ghost/code_mode/session.rb,
lib/little_ghost/code_mode/protocol.rb,
lib/little_ghost/code_mode/ruby/host.rb,
lib/little_ghost/code_mode/ruby_engine.rb,
lib/little_ghost/code_mode/ruby/catalog.rb,
lib/little_ghost/code_mode/ruby/session.rb,
lib/little_ghost/code_mode/javascript/host.rb,
lib/little_ghost/code_mode/javascript/client.rb,
lib/little_ghost/code_mode/javascript_engine.rb,
lib/little_ghost/code_mode/javascript_engine.rb,
lib/little_ghost/code_mode/javascript/catalog.rb,
lib/little_ghost/code_mode/javascript/session.rb

Overview

Runs model-authored orchestration code in a child interpreter. Built-in engines keep Tool authority in the parent process: each Tool call returns to a trusted Broker for catalog validation and ordinary Agent dispatch. Custom engines must preserve the Engine and Session containment contracts.

See the Code Mode guide for the first Ruby program, Broker boundary, lifecycle, limits, optional JavaScript engine, and extension contract.

Defined Under Namespace

Modules: Javascript, Protocol, Ruby Classes: AgentRuntime, Broker, Call, CallResult, Catalog, Engine, ExecTool, JavascriptEngine, ProgramResult, RubyEngine, Session, StopTool, WaitTool

Class Method Summary collapse

Class Method Details

.enginesObject

:nodoc:



35
36
37
# File 'lib/little_ghost/code_mode.rb', line 35

def engines # :nodoc:
  @engines ||= {}
end

.register_engine(name, implementation) ⇒ Object

Registers implementation under a trusted engine name.



17
18
19
20
21
22
23
# File 'lib/little_ghost/code_mode.rb', line 17

def register_engine(name, implementation)
  unless engine_class?(implementation) || implementation.is_a?(Engine)
    raise ArgumentError, "code-mode engine must be an Engine class or instance"
  end

  engines[name.to_sym] = implementation
end

.resolve_engine(value) ⇒ Object

Resolves a registered name or returns an explicit engine object.



26
27
28
29
30
31
32
33
# File 'lib/little_ghost/code_mode.rb', line 26

def resolve_engine(value)
  return engines.fetch(value.to_sym) { raise DependencyError, "code-mode engine :#{value} is not available" } if value.is_a?(Symbol) || value.is_a?(String)
  unless engine_class?(value) || value.is_a?(Engine)
    raise ArgumentError, "code-mode engine must be an Engine class or instance"
  end

  value
end