ClaudeAgentSDK.Permission.RuleValue (claude_agent_sdk v0.11.0)

Copy Markdown View Source

Permission rule value struct.

Represents a single permission rule with a tool name and optional rule content that defines the permission pattern.

Examples

# Simple tool permission
RuleValue.new("Bash")

# Tool permission with pattern
RuleValue.new("Bash", "echo *")

# File write permission with path pattern
RuleValue.new("Write", "/tmp/**")

Summary

Types

t()

Permission rule value struct.

Functions

Creates a new rule value.

Converts a rule value to a map for the control protocol.

Types

t()

@type t() :: %ClaudeAgentSDK.Permission.RuleValue{
  rule_content: String.t() | nil,
  tool_name: String.t()
}

Permission rule value struct.

Functions

new(tool_name, rule_content \\ nil)

@spec new(String.t(), String.t() | nil) :: t()

Creates a new rule value.

Parameters

  • tool_name - Name of the tool this rule applies to
  • rule_content - Optional content pattern for the rule

Examples

iex> RuleValue.new("Bash")
%RuleValue{tool_name: "Bash", rule_content: nil}

iex> RuleValue.new("Bash", "echo *")
%RuleValue{tool_name: "Bash", rule_content: "echo *"}

to_map(rule_value)

@spec to_map(t()) :: map()

Converts a rule value to a map for the control protocol.

Examples

iex> RuleValue.new("Bash", "echo *") |> RuleValue.to_map()
%{"toolName" => "Bash", "ruleContent" => "echo *"}

iex> RuleValue.new("Bash") |> RuleValue.to_map()
%{"toolName" => "Bash", "ruleContent" => nil}