Class: LittleGhost::CodeMode::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/little_ghost/code_mode/engine.rb

Overview

Adapter contract for a code-mode language.

An Engine describes the language shown to the model and opens one Session. Model-authored code must run behind the supplied sandbox_factory. The Broker must remain in the trusted parent process; do not expose it or its application objects inside the child interpreter.

LittleGhost may call one registered Engine instance concurrently for different Agents and RunContexts. Keep mutable program state in the Session returned by #open_session, not on the Engine.

Direct Known Subclasses

JavascriptEngine, RubyEngine

Instance Method Summary collapse

Instance Method Details

#instructions(catalog:) ⇒ Object

Returns model-facing instructions for the supplied Tool Catalog. This method may be called concurrently. Instructions must describe only names and behavior the Session actually implements.



22
# File 'lib/little_ghost/code_mode/engine.rb', line 22

def instructions(catalog:) = raise(AbstractMethodError, "engine must provide instructions")

#languageObject

Returns the engine's language identifier as a Symbol.



17
# File 'lib/little_ghost/code_mode/engine.rb', line 17

def language = raise(AbstractMethodError, "engine must report its language")

#open_session(broker:, sandbox_factory:, limits:) ⇒ Object

Opens and returns a CodeMode::Session.

broker is called only from trusted parent code. sandbox_factory creates the Sandbox that contains model-authored execution. limits is the application's mapping, passed through unchanged. A custom Engine must normalize keys and values, validate supported settings, and merge its own safe defaults. The Session owns every Workspace, Sandbox, process, thread, and channel it creates. This method may be called concurrently; each call must return an independent Session.



33
# File 'lib/little_ghost/code_mode/engine.rb', line 33

def open_session(broker:, sandbox_factory:, limits:) = raise(AbstractMethodError, "engine must open a session")