Class: ComposableAgents::Cline::Agent

Inherits:
PromptDrivenAgent show all
Includes:
Mixins::ArtifactContract
Defined in:
lib/composable_agents/cline/agent.rb

Overview

Agent implementation that uses an ai-agent's AgentRunner.

Instance Attribute Summary

Attributes inherited from PromptDrivenAgent

#constraints, #conversation, #objective, #role, #system_instructions

Attributes inherited from Agent

#name

Public API collapse

Methods inherited from PromptDrivenAgent

#run

Methods included from Mixins::Logger

debug?

Internal collapse

Methods included from Mixins::ArtifactContract

#run

Methods inherited from PromptDrivenAgent

#input_artifacts_contracts, #output_artifacts_contracts, #report_error_for_output_artifact, #save_output_artifact

Methods inherited from Agent

#run

Constructor Details

#initialize(*args, strategy: PromptRenderingStrategy::MarkdownHeavy, provider: 'cline', model: 'anthropic/claude-sonnet-4.6', api_key: ENV.fetch('CLINE_API_KEY', nil), configure_provider: nil, configure_global: nil, skills: [], cli_options: {}, **kwargs) ⇒ Agent

Initialize a new agent that uses the Cline CLI in a dedicated config

Parameters:

  • strategy (Module) (defaults to: PromptRenderingStrategy::MarkdownHeavy)

    The prompt rendering strategy

  • provider (String) (defaults to: 'cline')

    Provider to be used

  • model (String) (defaults to: 'anthropic/claude-sonnet-4.6')

    Model to be used

  • api_key (String) (defaults to: ENV.fetch('CLINE_API_KEY', nil))

    API key to be used

  • configure_provider (#call(provider_settings), nil) (defaults to: nil)

    Optional block used to configure the provider settings

    • Param provider_settings [Cline::Providers::ProviderSettings] Settings that can be tuned for this agent
  • configure_global (#call(global_settings), nil) (defaults to: nil)

    Optional block used to configure the global settings

    • Param global_settings [Cline::GlobalSettings] Settings that can be tuned for this agent
  • skills (Array<String>) (defaults to: [])

    List of skills to allow for this agent

  • cli_options (Hash{Symbol => Object}) (defaults to: {})

    Task options to give to Cline CLI (see Cline::Cli.COMMANDS)



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/composable_agents/cline/agent.rb', line 28

def initialize(
  *args,
  strategy: PromptRenderingStrategy::MarkdownHeavy,
  provider: 'cline',
  model: 'anthropic/claude-sonnet-4.6',
  api_key: ENV.fetch('CLINE_API_KEY', nil),
  configure_provider: nil,
  configure_global: nil,
  skills: [],
  cli_options: {},
  **kwargs
)
  super(*args, strategy:, **kwargs)
  @provider = provider
  @model = model
  @api_key = api_key ? ::Cline::SecretString.new(api_key.dup) : nil
  @configure_provider = configure_provider
  @configure_global = configure_global
  @skills = skills
  @cli_options = cli_options
  @context = []
end

Instance Method Details

#export_stateObject

Export the agent state for persistence

Returns:

  • (Object)

    Serialized state that can be marshalled to JSON



65
66
67
# File 'lib/composable_agents/cline/agent.rb', line 65

def export_state
  super.merge(deep_transform_keys(context: @context, &:to_s))
end

#full_nameString

Return the full name of the agent. This method is intended to be overridden by subclasses to give better full names, tailored to the kind of agent. The full name can be used in logs and traces to better identify the agent.

Returns:

  • (String)

    The agent's full name



56
57
58
# File 'lib/composable_agents/cline/agent.rb', line 56

def full_name
  "#{name || 'Unnamed'} (Cline #{@provider}/#{@model})"
end

#import_state(state) ⇒ Object

Import the agent state from persistence

Parameters:

  • state (Object)

    Serialized state



72
73
74
75
# File 'lib/composable_agents/cline/agent.rb', line 72

def import_state(state)
  super
  @context = deep_transform_keys(state, &:to_sym)[:context]
end