Class: AgentsControl::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/agents_control/doctor.rb

Overview

Checks that everything is in place.

Main principle: check the environment the daemon will actually get, not the one the user happens to be sitting in. An interactive shell can show a different Ruby, a different PATH, different environment variables than what a separately launched daemon process will see.

Defined Under Namespace

Classes: Check

Constant Summary collapse

NOT_AUTHORISED =

AppleScript's error when the user hasn't granted permission to control the app.

"-1743"
CHECKS =
%i[
  ruby_check terminal_check automation_check agent_binary_check
  token_check chats_check bot_check daemon_check hooks_check
  anchors_check wake_check
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config: nil, secrets: nil, executor: Executor.new, api: nil) ⇒ Doctor

Returns a new instance of Doctor.



21
22
23
24
25
26
# File 'lib/agents_control/doctor.rb', line 21

def initialize(config: nil, secrets: nil, executor: Executor.new, api: nil)
  @config = config || Config.load
  @secrets = secrets || Secrets.new
  @executor = executor
  @api = api
end

Instance Method Details

#runObject

Checks run one at a time, each wrapped: a diagnostic tool has no business crashing. An unexpected error is just another result, not the end of the run — otherwise the first small thing would hide everything after it.



38
39
40
41
42
43
44
45
# File 'lib/agents_control/doctor.rb', line 38

def run
  CHECKS.filter_map do |name|
    send(name)
  rescue StandardError => e
    Check.new(name: name.to_s.sub("_check", ""), status: :fail,
              detail: "check failed: #{e.class}")
  end
end