Class: ClaudeCodeSDK::Options

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

Overview

Options for configuring Claude Code queries

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Options

Returns a new instance of Options.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/claude_code_sdk/types.rb', line 13

def initialize(**kwargs)
  @allowed_tools = kwargs[:allowed_tools] || []
  @blocked_tools = kwargs[:blocked_tools] || []
  @permission_mode = kwargs[:permission_mode] || "default"
  @max_thinking_tokens = kwargs[:max_thinking_tokens] || 8000
  @system_prompt = kwargs[:system_prompt]
  @cwd = kwargs[:cwd]
  @mcp_servers = kwargs[:mcp_servers] || {}
  @disable_cache = kwargs[:disable_cache] || false
  @no_markdown = kwargs[:no_markdown] || false
  @tree = kwargs[:tree] || []
  @tree_symlinks = kwargs[:tree_symlinks] || false
  @tree_verbose = kwargs[:tree_verbose] || false
  @max_turns = kwargs[:max_turns]
  @model = kwargs[:model]
  @continue_conversation = kwargs[:continue_conversation] || false
  @resume = kwargs[:resume]
  @append_system_prompt = kwargs[:append_system_prompt]
end

Instance Attribute Details

#allowed_toolsObject

Returns the value of attribute allowed_tools.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def allowed_tools
  @allowed_tools
end

#append_system_promptObject

Returns the value of attribute append_system_prompt.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def append_system_prompt
  @append_system_prompt
end

#blocked_toolsObject

Returns the value of attribute blocked_tools.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def blocked_tools
  @blocked_tools
end

#continue_conversationObject

Returns the value of attribute continue_conversation.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def continue_conversation
  @continue_conversation
end

#cwdObject

Returns the value of attribute cwd.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def cwd
  @cwd
end

#disable_cacheObject

Returns the value of attribute disable_cache.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def disable_cache
  @disable_cache
end

#max_thinking_tokensObject

Returns the value of attribute max_thinking_tokens.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def max_thinking_tokens
  @max_thinking_tokens
end

#max_turnsObject

Returns the value of attribute max_turns.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def max_turns
  @max_turns
end

#mcp_serversObject

Returns the value of attribute mcp_servers.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def mcp_servers
  @mcp_servers
end

#modelObject

Returns the value of attribute model.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def model
  @model
end

#no_markdownObject

Returns the value of attribute no_markdown.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def no_markdown
  @no_markdown
end

#permission_modeObject

Returns the value of attribute permission_mode.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def permission_mode
  @permission_mode
end

#resumeObject

Returns the value of attribute resume.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def resume
  @resume
end

#system_promptObject

Returns the value of attribute system_prompt.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def system_prompt
  @system_prompt
end

#treeObject

Returns the value of attribute tree.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def tree
  @tree
end

Returns the value of attribute tree_symlinks.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def tree_symlinks
  @tree_symlinks
end

#tree_verboseObject

Returns the value of attribute tree_verbose.



6
7
8
# File 'lib/claude_code_sdk/types.rb', line 6

def tree_verbose
  @tree_verbose
end

Instance Method Details

#to_cli_argsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/claude_code_sdk/types.rb', line 33

def to_cli_args
  args = ["--output-format", "stream-json", "--verbose"]

  args.push("--system-prompt", system_prompt) if system_prompt
  args.push("--append-system-prompt", append_system_prompt) if append_system_prompt
  args.push("--allowedTools", allowed_tools.join(",")) unless allowed_tools.empty?
  args.push("--disallowedTools", blocked_tools.join(",")) unless blocked_tools.empty?
  args.push("--max-turns", max_turns.to_s) if max_turns
  args.push("--model", model) if model
  args.push("--permission-mode", permission_mode) if permission_mode
  args.push("--continue") if continue_conversation
  args.push("--resume", resume) if resume
  args.push("--add-dir", cwd.to_s) if cwd

  unless mcp_servers.empty?
    require "json"
    mcp_config = { mcpServers: mcp_servers }.to_json
    args.push("--mcp-config", mcp_config)
  end

  args
end