Class: RubynCode::IDE::Handlers::PlanInterviewStartHandler
- Inherits:
-
Object
- Object
- RubynCode::IDE::Handlers::PlanInterviewStartHandler
- Defined in:
- lib/rubyn_code/ide/handlers/plan_interview_start_handler.rb
Overview
Handles “plan/interview/start” — kicks off a megaplan interview session. Creates the InterviewSession, fires the first LLM turn, and emits either a plan/interview/question or plan/interview/done notification before returning the new sessionId to the extension.
Constant Summary collapse
- INVALID_INTERVIEW_CODE =
-32_010
Instance Method Summary collapse
- #call(_params) ⇒ Object
-
#initialize(server, factory: nil) ⇒ PlanInterviewStartHandler
constructor
A new instance of PlanInterviewStartHandler.
Constructor Details
#initialize(server, factory: nil) ⇒ PlanInterviewStartHandler
Returns a new instance of PlanInterviewStartHandler.
13 14 15 16 17 18 |
# File 'lib/rubyn_code/ide/handlers/plan_interview_start_handler.rb', line 13 def initialize(server, factory: nil) @server = server @factory = factory || ->(workspace_path:) { Megaplan::InterviewSession.new(workspace_path: workspace_path) } end |
Instance Method Details
#call(_params) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubyn_code/ide/handlers/plan_interview_start_handler.rb', line 20 def call(_params) session = @factory.call(workspace_path: @server.workspace_path || Dir.pwd) @server.register_interview_session(session) outcome = session.start emit_outcome(session, outcome) { 'sessionId' => session.session_id } rescue Megaplan::InterviewSession::MalformedResponseError, Megaplan::PlanProposer::InvalidProposalError => e warn "[PlanInterviewStartHandler] interview failed: #{e.}" raise Protocol::JsonRpcError.new(INVALID_INTERVIEW_CODE, e.) end |