Skip to content

permissions

Class info

Classes

Name Children Inherits
BasePermissionUpdate
clawd_code_sdk.models.permissions
Permission update configuration.
DirectoryPermissionUpdate
clawd_code_sdk.models.permissions
Permission update configuration.
    ModePermissionUpdate
    clawd_code_sdk.models.permissions
    Permission update configuration.
      PermissionResultAllow
      clawd_code_sdk.models.permissions
      Allow permission result.
        PermissionResultDeny
        clawd_code_sdk.models.permissions
        Deny permission result.
          PermissionRuleValue
          clawd_code_sdk.models.permissions
          Permission rule value.
            RulePermissionUpdate
            clawd_code_sdk.models.permissions
            Permission update configuration.
              ToolPermissionContext
              clawd_code_sdk.models.permissions
              Context information for tool permission callbacks.

                🛈 DocStrings

                Permission system types.

                OnUserQuestion module-attribute

                OnUserQuestion = Callable[
                    [AskUserQuestionInput, ToolPermissionContext], Awaitable[PermissionResult]
                ]
                

                Callback for handling AskUserQuestion elicitation requests.

                Called when Claude asks the user a clarifying question. The callback should return a PermissionResultAllow with updated_input containing the answers, or a PermissionResultDeny to cancel.

                BasePermissionUpdate

                Bases: ClaudeCodeBaseModel

                Permission update configuration.

                Source code in src/clawd_code_sdk/models/permissions.py
                class BasePermissionUpdate(ClaudeCodeBaseModel):
                    """Permission update configuration."""
                
                    destination: PermissionUpdateDestination
                

                DirectoryPermissionUpdate

                Bases: BasePermissionUpdate

                Permission update configuration.

                Source code in src/clawd_code_sdk/models/permissions.py
                class DirectoryPermissionUpdate(BasePermissionUpdate):
                    """Permission update configuration."""
                
                    type: Literal["addDirectories", "removeDirectories"]
                    directories: list[str]
                

                ModePermissionUpdate

                Bases: BasePermissionUpdate

                Permission update configuration.

                Source code in src/clawd_code_sdk/models/permissions.py
                class ModePermissionUpdate(BasePermissionUpdate):
                    """Permission update configuration."""
                
                    type: Literal["setMode"]
                    mode: PermissionMode
                

                PermissionResultAllow

                Bases: ClaudeCodeBaseModel

                Allow permission result.

                Source code in src/clawd_code_sdk/models/permissions.py
                class PermissionResultAllow(ClaudeCodeBaseModel):
                    """Allow permission result."""
                
                    behavior: Literal["allow"] = "allow"
                    updated_input: dict[str, Any] | None = None
                    updated_permissions: list[PermissionUpdate] | None = None
                    decision_classification: PermissionDecisionClassification | None = None
                

                PermissionResultDeny

                Bases: ClaudeCodeBaseModel

                Deny permission result.

                Source code in src/clawd_code_sdk/models/permissions.py
                class PermissionResultDeny(ClaudeCodeBaseModel):
                    """Deny permission result."""
                
                    behavior: Literal["deny"] = "deny"
                    message: str = ""
                    interrupt: bool = False
                    decision_classification: PermissionDecisionClassification | None = None
                

                PermissionRuleValue

                Bases: ClaudeCodeBaseModel

                Permission rule value.

                Source code in src/clawd_code_sdk/models/permissions.py
                class PermissionRuleValue(ClaudeCodeBaseModel):
                    """Permission rule value."""
                
                    tool_name: str
                    rule_content: str | None = None
                

                RulePermissionUpdate

                Bases: BasePermissionUpdate

                Permission update configuration.

                behavior is required: Claude Code rejects a rule update without it and then ignores every update in the same response (upstream #1502). A rule with rule_content=None applies to the whole tool and is sent without a ruleContent key.

                Source code in src/clawd_code_sdk/models/permissions.py
                class RulePermissionUpdate(BasePermissionUpdate):
                    """Permission update configuration.
                
                    ``behavior`` is required: Claude Code rejects a rule update without it and
                    then ignores every update in the same response (upstream #1502). A rule
                    with ``rule_content=None`` applies to the whole tool and is sent without a
                    ``ruleContent`` key.
                    """
                
                    type: Literal["addRules", "replaceRules", "removeRules"]
                    rules: list[PermissionRuleValue]
                    behavior: PermissionBehavior
                

                ToolPermissionContext dataclass

                Context information for tool permission callbacks.

                Source code in src/clawd_code_sdk/models/permissions.py
                @dataclass
                class ToolPermissionContext:
                    """Context information for tool permission callbacks."""
                
                    tool_use_id: str
                    """Unique identifier for this specific tool call within the assistant message.
                
                    Multiple tool calls in the same assistant message will have different tool_use_ids.
                    """
                
                    # signal: Any | None = None
                    # """Reserved for future abort signal support. Currently always None."""
                
                    agent_id: str | None = None
                    """The agent that initiated the tool call, if in a multi-agent setup."""
                
                    decision_reason: str | None = None
                    """Why the CLI triggered the permission check."""
                
                    suggestions: list[PermissionUpdate] = field(default_factory=list)
                    """Permission suggestions from CLI for updating permissions.
                
                    So the user won't be prompted again for this tool during this session.
                    """
                
                    blocked_path: str | None = None
                    """The file path that triggered the permission request, if applicable.
                
                    For example, when a Bash command tries to access a path outside allowed directories.
                    """
                
                    title: str | None = None
                    """Full permission prompt sentence rendered by the bridge.
                
                    E.g. "Claude wants to read foo.txt". Use this as the primary prompt
                    text when present instead of reconstructing from toolName+input.
                    """
                
                    display_name: str | None = None
                    """Short noun phrase for the tool action (e.g. "Read file").
                
                    Suitable for button labels or compact UI.
                    """
                
                    description: str | None = None
                    """Human-readable subtitle from the bridge.
                
                    E.g. "Claude will have read and write access to files in ~/Downloads".
                    """
                
                    tool_name: str | None = None
                    """The name of the tool that generated this permission request."""
                
                    input: dict[str, Any] | None = None
                    """The input to the tool that generated this permission request."""
                
                    @classmethod
                    def from_permission_request(cls, req: SDKControlPermissionRequest) -> Self:
                        """Create a PermissionContext from a permission request."""
                        return cls(
                            tool_use_id=req.tool_use_id,
                            agent_id=req.agent_id,
                            decision_reason=req.decision_reason,
                            suggestions=req.permission_suggestions or [],
                            blocked_path=req.blocked_path,
                            title=req.title,
                            display_name=req.display_name,
                            description=req.description,
                            tool_name=req.tool_name,
                            input=req.input,
                        )
                

                agent_id class-attribute instance-attribute

                agent_id: str | None = None
                

                The agent that initiated the tool call, if in a multi-agent setup.

                blocked_path class-attribute instance-attribute

                blocked_path: str | None = None
                

                The file path that triggered the permission request, if applicable.

                For example, when a Bash command tries to access a path outside allowed directories.

                decision_reason class-attribute instance-attribute

                decision_reason: str | None = None
                

                Why the CLI triggered the permission check.

                description class-attribute instance-attribute

                description: str | None = None
                

                Human-readable subtitle from the bridge.

                E.g. "Claude will have read and write access to files in ~/Downloads".

                display_name class-attribute instance-attribute

                display_name: str | None = None
                

                Short noun phrase for the tool action (e.g. "Read file").

                Suitable for button labels or compact UI.

                input class-attribute instance-attribute

                input: dict[str, Any] | None = None
                

                The input to the tool that generated this permission request.

                suggestions class-attribute instance-attribute

                suggestions: list[PermissionUpdate] = field(default_factory=list)
                

                Permission suggestions from CLI for updating permissions.

                So the user won't be prompted again for this tool during this session.

                title class-attribute instance-attribute

                title: str | None = None
                

                Full permission prompt sentence rendered by the bridge.

                E.g. "Claude wants to read foo.txt". Use this as the primary prompt text when present instead of reconstructing from toolName+input.

                tool_name class-attribute instance-attribute

                tool_name: str | None = None
                

                The name of the tool that generated this permission request.

                tool_use_id instance-attribute

                tool_use_id: str
                

                Unique identifier for this specific tool call within the assistant message.

                Multiple tool calls in the same assistant message will have different tool_use_ids.

                from_permission_request classmethod

                from_permission_request(req: SDKControlPermissionRequest) -> Self
                

                Create a PermissionContext from a permission request.

                Source code in src/clawd_code_sdk/models/permissions.py
                @classmethod
                def from_permission_request(cls, req: SDKControlPermissionRequest) -> Self:
                    """Create a PermissionContext from a permission request."""
                    return cls(
                        tool_use_id=req.tool_use_id,
                        agent_id=req.agent_id,
                        decision_reason=req.decision_reason,
                        suggestions=req.permission_suggestions or [],
                        blocked_path=req.blocked_path,
                        title=req.title,
                        display_name=req.display_name,
                        description=req.description,
                        tool_name=req.tool_name,
                        input=req.input,
                    )