Class: PromptObjects::Connectors::Base
- Inherits:
-
Object
- Object
- PromptObjects::Connectors::Base
- Defined in:
- lib/prompt_objects/connectors/base.rb
Overview
Base class for connectors that provide different interfaces to environments. Each connector (MCP, API, Web, etc.) inherits from this class.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
Instance Method Summary collapse
-
#initialize(runtime:, config: {}) ⇒ Base
constructor
A new instance of Base.
-
#inject(target_po:, content:, workspace_session_id: nil, thread_id: nil, client_request_id: nil) ⇒ String
Route an inbound external event to a PO through the unified entry point.
-
#running? ⇒ Boolean
Whether the connector is currently running.
-
#source_name ⇒ String
Connector identifier for session source tracking.
-
#start ⇒ Object
Start the connector (may be blocking or non-blocking depending on implementation).
-
#stop ⇒ Object
Stop the connector gracefully.
Constructor Details
#initialize(runtime:, config: {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 |
# File 'lib/prompt_objects/connectors/base.rb', line 12 def initialize(runtime:, config: {}) @runtime = runtime @config = config @running = false end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/prompt_objects/connectors/base.rb', line 8 def config @config end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
8 9 10 |
# File 'lib/prompt_objects/connectors/base.rb', line 8 def runtime @runtime end |
Instance Method Details
#inject(target_po:, content:, workspace_session_id: nil, thread_id: nil, client_request_id: nil) ⇒ String
Route an inbound external event to a PO through the unified entry point. The message is tagged with this connector's source, so its provenance shows up in the timeline (e.g. "← discord"). This is how a Discord/Slack/ webhook connector forwards an incoming message to a Prompt-Object.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/prompt_objects/connectors/base.rb', line 46 def inject(target_po:, content:, workspace_session_id: nil, thread_id: nil, client_request_id: nil) runtime.( target_po: target_po, content: content, from_source: "service:#{source_name}", workspace_session_id: workspace_session_id, thread_id: thread_id, client_request_id: client_request_id ) end |
#running? ⇒ Boolean
Whether the connector is currently running
29 30 31 |
# File 'lib/prompt_objects/connectors/base.rb', line 29 def running? @running end |
#source_name ⇒ String
Connector identifier for session source tracking
35 36 37 |
# File 'lib/prompt_objects/connectors/base.rb', line 35 def source_name raise NotImplementedError, "#{self.class} must implement #source_name" end |
#start ⇒ Object
Start the connector (may be blocking or non-blocking depending on implementation)
19 20 21 |
# File 'lib/prompt_objects/connectors/base.rb', line 19 def start raise NotImplementedError, "#{self.class} must implement #start" end |
#stop ⇒ Object
Stop the connector gracefully
24 25 26 |
# File 'lib/prompt_objects/connectors/base.rb', line 24 def stop @running = false end |