Class: Roast::Cogs::Agent::Providers::Claude::ClaudeInvocation
- Inherits:
-
Object
- Object
- Roast::Cogs::Agent::Providers::Claude::ClaudeInvocation
- Defined in:
- lib/roast/cogs/agent/providers/claude/claude_invocation.rb
Defined Under Namespace
Classes: ClaudeAlreadyStartedError, ClaudeFailedError, ClaudeInvocationError, ClaudeNotCompletedError, ClaudeNotStartedError, Context, Result
Instance Method Summary collapse
-
#completed? ⇒ Boolean
: () -> bool.
-
#failed? ⇒ Boolean
: () -> bool.
-
#initialize(config, prompt, session, fork_session: true) ⇒ ClaudeInvocation
constructor
: (Agent::Config, String, String?, ?fork_session: bool) -> void.
-
#result ⇒ Object
: () -> Result.
-
#run! ⇒ Object
: () -> void.
-
#running? ⇒ Boolean
: () -> bool.
-
#started? ⇒ Boolean
: () -> bool.
Constructor Details
#initialize(config, prompt, session, fork_session: true) ⇒ ClaudeInvocation
: (Agent::Config, String, String?, ?fork_session: bool) -> void
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/roast/cogs/agent/providers/claude/claude_invocation.rb', line 57 def initialize(config, prompt, session, fork_session: true) @base_command = config.valid_command #: (String | Array[String])? @model = config.valid_model #: String? @append_system_prompt = config.valid_append_system_prompt #: String? @replace_system_prompt = config.valid_replace_system_prompt #: String? @apply_permissions = config. #: bool @working_directory = config.valid_working_directory #: Pathname? @context = Context.new #: Context @result = Result.new #: Result @raw_dump_file = config. #: Pathname? @show_prompt = config.show_prompt? #: bool @show_progress = config.show_progress? #: bool @show_response = config.show_response? #: bool @prompt = prompt @session = session @fork_session = fork_session #: bool end |
Instance Method Details
#completed? ⇒ Boolean
: () -> bool
110 111 112 |
# File 'lib/roast/cogs/agent/providers/claude/claude_invocation.rb', line 110 def completed? @completed ||= false end |
#failed? ⇒ Boolean
: () -> bool
115 116 117 |
# File 'lib/roast/cogs/agent/providers/claude/claude_invocation.rb', line 115 def failed? @failed ||= false end |
#result ⇒ Object
: () -> Result
120 121 122 123 124 125 126 |
# File 'lib/roast/cogs/agent/providers/claude/claude_invocation.rb', line 120 def result raise ClaudeNotStartedError unless started? raise ClaudeFailedError, @result.response if failed? raise ClaudeNotCompletedError, @result.response unless completed? @result end |
#run! ⇒ Object
: () -> void
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/roast/cogs/agent/providers/claude/claude_invocation.rb', line 76 def run! raise ClaudeAlreadyStartedError if started? @started = true Event << { block: { header: "USER PROMPT", content: @prompt } } if @show_prompt _stdout, stderr, status = CommandRunner.execute( command_line, working_directory: @working_directory, stdin_content: @prompt, stdout_handler: lambda { |line| handle_stdout(line) }, ) if status.success? @completed = true Event << { block: { header: "AGENT RESPONSE", content: @result.response } } if @show_response else @failed = true @result.success = false @result.response += "\n" unless @result.response.blank? || @result.response.ends_with?("\n") @result.response += stderr end end |
#running? ⇒ Boolean
: () -> bool
105 106 107 |
# File 'lib/roast/cogs/agent/providers/claude/claude_invocation.rb', line 105 def running? started? && !completed? && !failed? end |
#started? ⇒ Boolean
: () -> bool
100 101 102 |
# File 'lib/roast/cogs/agent/providers/claude/claude_invocation.rb', line 100 def started? @started ||= false end |