Class: LittleGhost::CodeMode::RubyEngine
- Defined in:
- lib/little_ghost/code_mode/ruby_engine.rb
Overview
Runs model-written Ruby in a fresh sandboxed process.
Tool calls cross a bounded protocol to the trusted parent Broker. The engine uses only Ruby's standard library and adds no runtime dependency.
LittleGhost.configure do |config|
config.code_mode = {engine: :ruby, sandbox: :native}
end
Constant Summary collapse
- DEFAULT_LIMITS =
Resource, Tool-call, and program limits applied when the application does not override them.
{ source_bytes: 1_000_000, output_bytes: 1_000_000, memory_bytes: 64 * 1024 * 1024, wall_seconds: 3_600, cpu_seconds: 10, file_bytes: 1_000_000, programs: 8, tool_calls: 1_000, concurrency: 8, cleanup_seconds: 5 }.freeze
Instance Method Summary collapse
-
#instructions(catalog:, prompts: nil) ⇒ Object
Builds Ruby usage instructions and method declarations for
catalog. -
#language ⇒ Object
Returns the
:rubylanguage identifier. -
#open_session(broker:, sandbox_factory:, limits: {}, framework_prompt_scope: {}) ⇒ Object
Opens a Ruby Session with engine defaults merged with
limits.
Instance Method Details
#instructions(catalog:, prompts: nil) ⇒ Object
Builds Ruby usage instructions and method declarations for catalog.
37 38 39 40 |
# File 'lib/little_ghost/code_mode/ruby_engine.rb', line 37 def instructions(catalog:, prompts: nil) renderer = prompts || ->(key, **locals) { FrameworkPrompts.new.render(key, locals:) } renderer.call("code_mode/ruby/instructions", declarations: Ruby::Catalog.new(catalog).declarations) end |
#language ⇒ Object
Returns the :ruby language identifier.
34 |
# File 'lib/little_ghost/code_mode/ruby_engine.rb', line 34 def language = :ruby |
#open_session(broker:, sandbox_factory:, limits: {}, framework_prompt_scope: {}) ⇒ Object
Opens a Ruby Session with engine defaults merged with limits.
Unsupported limit keys raise ArgumentError.
44 45 46 47 48 49 50 51 52 |
# File 'lib/little_ghost/code_mode/ruby_engine.rb', line 44 def open_session(broker:, sandbox_factory:, limits: {}, framework_prompt_scope: {}) Ruby::Session.new( broker:, sandbox_factory:, subprocess_policy: method(:allow_subprocesses_for), limits: normalize_limits(limits, defaults: DEFAULT_LIMITS), framework_prompt_scope: ) end |