File tree Expand file tree Collapse file tree
lib/roast/cogs/agent/providers/claude
test/roast/cogs/agent/providers/claude Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 roast-ai (1.1.0 )
55 activesupport (~> 8.0 )
66 async (>= 2.34 )
7+ nokogiri (>= 1.18 )
78 rainbow (>= 3.0.0 )
89 ruby_llm (>= 1.13 )
910 type_toolkit (>= 0.0.5 )
108109 net-http (0.9.1 )
109110 uri (>= 0.11.1 )
110111 netrc (0.11.0 )
112+ nokogiri (1.19.3-arm64-darwin )
113+ racc (~> 1.4 )
114+ nokogiri (1.19.3-x86_64-linux-gnu )
115+ racc (~> 1.4 )
111116 notiffany (0.1.3 )
112117 nenv (~> 0.1 )
113118 shellany (~> 0.0 )
Original file line number Diff line number Diff line change 11# typed: true
22# frozen_string_literal: true
33
4+ require "nokogiri"
5+
46module Roast
57 module Cogs
68 class Agent < Cog
@@ -251,6 +253,29 @@ def format_taskcreate
251253 ok_line ( preview )
252254 end
253255
256+ # Formats a TaskOutput tool-result line.
257+ #
258+ # Content: sibling tags carrying the task's state, followed by a
259+ # trailing <output> of arbitrary unescaped text. Parsed leniently
260+ # as an XML fragment, which tolerates the absent single root and the
261+ # unescaped <output> body.
262+ #
263+ # Output: "TASKOUTPUT OK <status>" – the text of <status>, or of
264+ # <retrieval_status> when no <status> tag is present (as on a
265+ # pending retrieval). The status is omitted when neither is present.
266+ #
267+ # Examples:
268+ # TASKOUTPUT OK completed
269+ # TASKOUTPUT OK pending
270+ # TASKOUTPUT OK
271+ #
272+ #: () -> String
273+ def format_taskoutput
274+ fragment = Nokogiri ::XML ::DocumentFragment . parse ( content . to_s )
275+ status = ( fragment . at_xpath ( ".//status" ) || fragment . at_xpath ( ".//retrieval_status" ) ) &.text &.strip
276+ ok_line ( status )
277+ end
278+
254279 #: () -> String
255280 def format_unknown
256281 "UNKNOWN [#{ tool_name } ] OK #{ tool_use_description } \n #{ content } "
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
3333
3434 spec . add_dependency ( "activesupport" , "~> 8.0" )
3535 spec . add_dependency ( "async" , ">= 2.34" )
36+ spec . add_dependency ( "nokogiri" , ">= 1.18" )
3637 spec . add_dependency ( "rainbow" , ">= 3.0.0" )
3738 spec . add_dependency ( "ruby_llm" , ">= 1.13" )
3839 spec . add_dependency ( "type_toolkit" , ">= 0.0.5" )
You can’t perform that action at this time.
0 commit comments