Class: CollavreOpenclaw::SessionAbortService
- Inherits:
-
Object
- Object
- CollavreOpenclaw::SessionAbortService
- Defined in:
- app/services/collavre_openclaw/session_abort_service.rb
Overview
Aborts an in-flight OpenClaw gateway session for a cancelled task. Registered into Collavre::AgentSessionAbort so core stays vendor-agnostic.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(agent:, task:, creative: nil, comment: nil) ⇒ SessionAbortService
constructor
A new instance of SessionAbortService.
Constructor Details
#initialize(agent:, task:, creative: nil, comment: nil) ⇒ SessionAbortService
Returns a new instance of SessionAbortService.
11 12 13 14 15 16 |
# File 'app/services/collavre_openclaw/session_abort_service.rb', line 11 def initialize(agent:, task:, creative: nil, comment: nil) @agent = agent @task = task @creative = creative @comment = comment end |
Class Method Details
.call(agent:, task:, creative: nil, comment: nil) ⇒ Object
7 8 9 |
# File 'app/services/collavre_openclaw/session_abort_service.rb', line 7 def self.call(agent:, task:, creative: nil, comment: nil) new(agent: agent, task: task, creative: creative, comment: comment).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/collavre_openclaw/session_abort_service.rb', line 18 def call return unless defined?(CollavreOpenclaw::ConnectionManager) creative = @creative || @task.creative || Collavre::Creative.find_by(id: payload.dig("creative", "id")) comment = @comment || Collavre::Comment.find_by(id: payload.dig("comment", "id")) adapter = CollavreOpenclaw::OpenclawAdapter.new( user: @agent, system_prompt: "", context: { creative: creative, user: @agent, task: @task, comment: comment } ) conn = CollavreOpenclaw::ConnectionManager.instance.connection_for(@agent) conn.chat_abort(session_key: adapter.session_key) end |