Class: RubyCoded::Chat::App

Inherits:
Object
  • Object
show all
Includes:
EventDispatch, LoginHandler, OAuthHandler
Defined in:
lib/ruby_coded/chat/app.rb,
lib/ruby_coded/chat/app/login_handler.rb,
lib/ruby_coded/chat/app/oauth_handler.rb,
lib/ruby_coded/chat/app/event_dispatch.rb

Overview

Main class for the AI chat interface

Defined Under Namespace

Modules: EventDispatch, LoginHandler, OAuthHandler

Constant Summary collapse

IDLE_POLL_TIMEOUT =
0.016
STREAMING_POLL_TIMEOUT =
0.05

Constants included from EventDispatch

EventDispatch::LOGIN_ACTIONS, EventDispatch::PLAN_ACTIONS

Instance Method Summary collapse

Constructor Details

#initialize(model:, user_config: nil, auth_manager: nil, fallback_from_model: nil) ⇒ App

Returns a new instance of App.



31
32
33
34
35
36
37
38
39
40
# File 'lib/ruby_coded/chat/app.rb', line 31

def initialize(model:, user_config: nil, auth_manager: nil, fallback_from_model: nil)
  @model = model
  @user_config = user_config
  @auth_manager = auth_manager
  @fallback_from_model = fallback_from_model
  apply_plugin_extensions!
  build_components!
  enable_default_agent_mode!
  announce_model_fallback
end

Instance Method Details

#build_bridge_factoryObject



60
61
62
63
64
65
66
67
68
# File 'lib/ruby_coded/chat/app.rb', line 60

def build_bridge_factory
  BridgeFactory.new(
    state: @state,
    credentials_store: @credentials_store,
    auth_manager: @auth_manager,
    skill_catalog: @skill_catalog,
    user_config: @user_config
  )
end

#build_catalogs!Object



52
53
54
55
56
57
58
# File 'lib/ruby_coded/chat/app.rb', line 52

def build_catalogs!
  @command_catalog = RubyCoded::Commands::Catalog.new(
    project_root: Dir.pwd,
    plugin_registry: RubyCoded.plugin_registry
  )
  @skill_catalog = RubyCoded::Skills::Catalog.new(project_root: Dir.pwd)
end

#build_components!Object



42
43
44
45
46
47
48
49
50
# File 'lib/ruby_coded/chat/app.rb', line 42

def build_components!
  build_catalogs!
  @state = State.new(model: @model, command_catalog: @command_catalog)
  @credentials_store = Auth::CredentialsStore.new(user_config: @user_config)
  @bridge_factory = build_bridge_factory
  @llm_bridge = @bridge_factory.build
  @input_handler = InputHandler.new(@state)
  @command_handler = build_command_handler
end

#runObject



73
74
75
76
77
78
# File 'lib/ruby_coded/chat/app.rb', line 73

def run
  RatatuiRuby.run do |tui|
    init_tui(tui)
    run_event_loop
  end
end