Class: Puppeteer::WebMCPTool
- Inherits:
-
Object
- Object
- Puppeteer::WebMCPTool
- Includes:
- EventCallbackable
- Defined in:
- lib/puppeteer/web_mcp.rb,
sig/puppeteer/web_mcp.rbs
Overview
rbs_inline: enabled
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
-
#input_schema ⇒ Object
readonly
Returns the value of attribute input_schema.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#raw_stack_trace ⇒ Object
readonly
Returns the value of attribute raw_stack_trace.
Instance Method Summary collapse
- #execute(input = {}) ⇒ Puppeteer::WebMCPToolCallResult
- #form_element ⇒ Puppeteer::ElementHandle?
- #initialize(web_mcp, tool, frame) ⇒ Object constructor
Methods included from EventCallbackable
#add_event_listener, #emit_event, #observe_first, #off, #on_event, #remove_event_listener
Constructor Details
#initialize(web_mcp, tool, frame) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/puppeteer/web_mcp.rb', line 10 def initialize(web_mcp, tool, frame) @web_mcp = web_mcp @name = tool['name'] @description = tool['description'] @input_schema = tool['inputSchema'] @annotations = tool['annotations'] @frame = frame @backend_node_id = tool['backendNodeId'] @raw_stack_trace = tool['stackTrace'] @form_element = nil call_frame = @raw_stack_trace&.fetch('callFrames', [])&.first if call_frame @location = Puppeteer::ConsoleMessage::Location.new( url: call_frame['url'], line_number: call_frame['lineNumber'], column_number: call_frame['columnNumber'], ) end end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
31 32 33 |
# File 'lib/puppeteer/web_mcp.rb', line 31 def annotations @annotations end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
31 32 33 |
# File 'lib/puppeteer/web_mcp.rb', line 31 def description @description end |
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
31 32 33 |
# File 'lib/puppeteer/web_mcp.rb', line 31 def frame @frame end |
#input_schema ⇒ Object (readonly)
Returns the value of attribute input_schema.
31 32 33 |
# File 'lib/puppeteer/web_mcp.rb', line 31 def input_schema @input_schema end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
31 32 33 |
# File 'lib/puppeteer/web_mcp.rb', line 31 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/puppeteer/web_mcp.rb', line 31 def name @name end |
#raw_stack_trace ⇒ Object (readonly)
Returns the value of attribute raw_stack_trace.
31 32 33 |
# File 'lib/puppeteer/web_mcp.rb', line 31 def raw_stack_trace @raw_stack_trace end |
Instance Method Details
#execute(input = {}) ⇒ Puppeteer::WebMCPToolCallResult
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/puppeteer/web_mcp.rb', line 44 def execute(input = {}) invocation_id = @web_mcp.invoke_tool(self, input).fetch('invocationId') promise = Async::Promise.new listener = nil listener = @web_mcp.add_event_listener('toolresponded') do |result| next unless result.id == invocation_id @web_mcp.remove_event_listener(listener) promise.resolve(result) end promise.wait end |
#form_element ⇒ Puppeteer::ElementHandle?
35 36 37 38 39 40 |
# File 'lib/puppeteer/web_mcp.rb', line 35 def form_element return @form_element if @form_element && !@form_element.disposed? return nil unless @backend_node_id @form_element = @frame.main_world.adopt_backend_node(@backend_node_id) end |