Class: ClaudeAgentSDK::ClaudeAgentOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Claude Agent Options for configuring queries

Constant Summary collapse

OPTION_DEFAULTS =

Non-nil defaults for options that need them. Keys absent from here default to nil.

{
  allowed_tools: [], disallowed_tools: [], add_dirs: [],
  mcp_servers: {}, env: {}, extra_args: {},
  continue_conversation: false, include_partial_messages: false,
  fork_session: false, enable_file_checkpointing: false
}.freeze
VALID_OPTIONS =

Valid option names derived from attr_accessor declarations.

instance_methods.grep(/=\z/).map { |m| m.to_s.chomp('=').to_sym }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ ClaudeAgentOptions

Using **kwargs lets us distinguish “caller passed allowed_tools: []” from “caller omitted allowed_tools” — critical for correct merge with configured defaults.

Raises:

  • (ArgumentError)


802
803
804
805
806
807
808
809
810
# File 'lib/claude_agent_sdk/types.rb', line 802

def initialize(**kwargs)
  unknown = kwargs.keys - VALID_OPTIONS
  raise ArgumentError, "unknown keyword#{'s' if unknown.size > 1}: #{unknown.join(', ')}" if unknown.any?

  merged = merge_with_defaults(kwargs)
  OPTION_DEFAULTS.merge(merged).each do |key, value|
    instance_variable_set(:"@#{key}", value)
  end
end

Instance Attribute Details

#add_dirsObject

Returns the value of attribute add_dirs.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def add_dirs
  @add_dirs
end

#agentsObject

Returns the value of attribute agents.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def agents
  @agents
end

#allowed_toolsObject

Returns the value of attribute allowed_tools.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def allowed_tools
  @allowed_tools
end

#append_allowed_toolsObject

Returns the value of attribute append_allowed_tools.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def append_allowed_tools
  @append_allowed_tools
end

#betasObject

Returns the value of attribute betas.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def betas
  @betas
end

#can_use_toolObject

Returns the value of attribute can_use_tool.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def can_use_tool
  @can_use_tool
end

#cli_pathObject

Returns the value of attribute cli_path.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def cli_path
  @cli_path
end

#continue_conversationObject

Returns the value of attribute continue_conversation.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def continue_conversation
  @continue_conversation
end

#cwdObject

Returns the value of attribute cwd.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def cwd
  @cwd
end

#debug_stderrObject

Returns the value of attribute debug_stderr.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def debug_stderr
  @debug_stderr
end

#disallowed_toolsObject

Returns the value of attribute disallowed_tools.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def disallowed_tools
  @disallowed_tools
end

#enable_file_checkpointingObject

Returns the value of attribute enable_file_checkpointing.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def enable_file_checkpointing
  @enable_file_checkpointing
end

#envObject

Returns the value of attribute env.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def env
  @env
end

#extra_argsObject

Returns the value of attribute extra_args.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def extra_args
  @extra_args
end

#fallback_modelObject

Returns the value of attribute fallback_model.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def fallback_model
  @fallback_model
end

#fork_sessionObject

Returns the value of attribute fork_session.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def fork_session
  @fork_session
end

#hooksObject

Returns the value of attribute hooks.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def hooks
  @hooks
end

#include_partial_messagesObject

Returns the value of attribute include_partial_messages.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def include_partial_messages
  @include_partial_messages
end

#max_budget_usdObject

Returns the value of attribute max_budget_usd.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def max_budget_usd
  @max_budget_usd
end

#max_buffer_sizeObject

Returns the value of attribute max_buffer_size.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def max_buffer_size
  @max_buffer_size
end

#max_thinking_tokensObject

Returns the value of attribute max_thinking_tokens.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def max_thinking_tokens
  @max_thinking_tokens
end

#max_turnsObject

Returns the value of attribute max_turns.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def max_turns
  @max_turns
end

#mcp_serversObject

Returns the value of attribute mcp_servers.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def mcp_servers
  @mcp_servers
end

#modelObject

Returns the value of attribute model.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def model
  @model
end

#output_formatObject

Returns the value of attribute output_format.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def output_format
  @output_format
end

#permission_modeObject

Returns the value of attribute permission_mode.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def permission_mode
  @permission_mode
end

#permission_prompt_tool_nameObject

Returns the value of attribute permission_prompt_tool_name.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def permission_prompt_tool_name
  @permission_prompt_tool_name
end

#pluginsObject

Returns the value of attribute plugins.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def plugins
  @plugins
end

#resumeObject

Returns the value of attribute resume.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def resume
  @resume
end

#sandboxObject

Returns the value of attribute sandbox.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def sandbox
  @sandbox
end

#setting_sourcesObject

Returns the value of attribute setting_sources.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def setting_sources
  @setting_sources
end

#settingsObject

Returns the value of attribute settings.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def settings
  @settings
end

#stderrObject

Returns the value of attribute stderr.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def stderr
  @stderr
end

#system_promptObject

Returns the value of attribute system_prompt.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def system_prompt
  @system_prompt
end

#toolsObject

Returns the value of attribute tools.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def tools
  @tools
end

#userObject

Returns the value of attribute user.



777
778
779
# File 'lib/claude_agent_sdk/types.rb', line 777

def user
  @user
end

Instance Method Details

#dup_with(**changes) ⇒ Object



812
813
814
815
816
# File 'lib/claude_agent_sdk/types.rb', line 812

def dup_with(**changes)
  new_options = self.dup
  changes.each { |key, value| new_options.send(:"#{key}=", value) }
  new_options
end