Module: SimpleAcp::Server::AgentDSL

Defined in:
lib/simple_acp/server/agent.rb

Overview

DSL module for defining agents with block syntax.

Class Method Summary collapse

Class Method Details

.define(name:, description: nil, **options) {|Context| ... } ⇒ Agent

Define an agent from a block.

Parameters:

  • name (String) —

    agent name (must follow RFC 1123 DNS label format)

  • description (String, nil) (defaults to: nil) —

    human-readable description

  • options (Hash) —

    additional manifest options

Options Hash (**options):

  • :input_content_types (Array<String>) —

    accepted MIME types

  • :output_content_types (Array<String>) —

    produced MIME types

  • :metadata (Hash) —

    agent metadata

Yields:

  • (Context) —

    block that handles agent requests

Returns:

  • (Agent) —

    the created agent



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/simple_acp/server/agent.rb', line 103

def self.define(name:, description: nil, **options, &block)
  manifest = Models::AgentManifest.new(
    name: name,
    description: description,
    input_content_types: options[:input_content_types] || ["text/plain"],
    output_content_types: options[:output_content_types] || ["text/plain"],
    metadata: options[:metadata]
  )

  Agent.new(manifest: manifest, handler: block)
end