Class: LittleGhost::Subagents::Definition
- Inherits:
-
Object
- Object
- LittleGhost::Subagents::Definition
- Defined in:
- lib/little_ghost/subagents/definition.rb
Overview
A Definition describes one kind of agent available for delegation. Most applications create definitions through Agent::Delegation#subagent.
The factory receives the complete agent path and may also accept
runtime:. When accepts_conversation_id is true it receives the durable
conversation UUID as a second positional argument. Factories returning a
LittleGhost::Agent must construct it with the supplied path as
agent_path; the conversation UUID is a separate persistence identifier.
# ResearchAgent is defined by the application.
definition = LittleGhost::Subagents::Definition.new(
kind: "research",
description: "Investigates a bounded question",
factory: ->(agent_path) { ResearchAgent.new(agent_path:) }
)
definition.kind # => "research"
Instance Attribute Summary collapse
-
#accepts_conversation_id ⇒ Object
readonly
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
-
#description ⇒ Object
readonly
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
-
#factory ⇒ Object
readonly
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
-
#kind ⇒ Object
readonly
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
-
#persist ⇒ Object
readonly
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
Instance Method Summary collapse
-
#initialize(kind:, description:, factory:, persist: true, accepts_conversation_id: false) ⇒ Definition
constructor
Validates a definition.
Constructor Details
#initialize(kind:, description:, factory:, persist: true, accepts_conversation_id: false) ⇒ Definition
Validates a definition. persist is effective only when the
manager has a parent session.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/little_ghost/subagents/definition.rb', line 30 def initialize(kind:, description:, factory:, persist: true, accepts_conversation_id: false) @kind = String(kind) @description = String(description) @factory = factory @persist = !!persist @accepts_conversation_id = !!accepts_conversation_id raise ArgumentError, "kind cannot be empty" if @kind.empty? raise ArgumentError, "factory must respond to call" unless @factory.respond_to?(:call) end |
Instance Attribute Details
#accepts_conversation_id ⇒ Object (readonly)
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
26 27 28 |
# File 'lib/little_ghost/subagents/definition.rb', line 26 def accepts_conversation_id @accepts_conversation_id end |
#description ⇒ Object (readonly)
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
26 27 28 |
# File 'lib/little_ghost/subagents/definition.rb', line 26 def description @description end |
#factory ⇒ Object (readonly)
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
26 27 28 |
# File 'lib/little_ghost/subagents/definition.rb', line 26 def factory @factory end |
#kind ⇒ Object (readonly)
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
26 27 28 |
# File 'lib/little_ghost/subagents/definition.rb', line 26 def kind @kind end |
#persist ⇒ Object (readonly)
The model-visible kind and description, callable factory, persistence policy, and factory-arity declaration.
26 27 28 |
# File 'lib/little_ghost/subagents/definition.rb', line 26 def persist @persist end |