Class: Ask::CodingHarness::Runner
- Inherits:
-
Object
- Object
- Ask::CodingHarness::Runner
- Defined in:
- lib/ask/coding_harness/runner.rb
Overview
Headless run of a prompt against the workspace: drives the same
AgentRunner as the web server, prints a readable transcript, and
returns a Result. This is the dogfooding path — the harness builds
itself with ach run.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#initialize(config:, store: nil, runner: nil, approval: :off) ⇒ Runner
constructor
A new instance of Runner.
-
#run(prompt, workspace: nil, model: nil, quiet: false) ⇒ Result
Run a prompt and wait for the turn to finish.
Constructor Details
#initialize(config:, store: nil, runner: nil, approval: :off) ⇒ Runner
Returns a new instance of Runner.
25 26 27 28 29 30 |
# File 'lib/ask/coding_harness/runner.rb', line 25 def initialize(config:, store: nil, runner: nil, approval: :off) @config = config.dup @config.approval = approval @store = store || Store.new(db_path: @config.db_path) @runner = runner || AgentRunner.new(config: @config, store: @store) end |
Instance Method Details
#run(prompt, workspace: nil, model: nil, quiet: false) ⇒ Result
Run a prompt and wait for the turn to finish.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ask/coding_harness/runner.rb', line 39 def run(prompt, workspace: nil, model: nil, quiet: false) @config.workspace = workspace if workspace conversation = @store.build(directory: @config.workspace) conversation = @store.save(conversation) events = [] response = +"" error = nil thread = @runner.start_turn(conversation, prompt, model: model) do |ev| events << ev case ev[:type] when "message.delta" then response << ev[:data][:delta].to_s when "turn.failed" then error = ev[:data][:error] end print_transcript(ev) unless quiet end thread.join Result.new( success: error.nil?, response: response, events: events, conversation_id: conversation["id"], error: error ) end |