Skip to main content

build_permission_options

Function build_permission_options 

Source
fn build_permission_options(
    ctx: &ToolPermissionContext,
) -> Vec<PermissionOption>
Expand description

Construct the contextual option list for a permission prompt. Derives “Allow always for X” / “Allow always & add dirs” / “Allow always & switch mode” entries from ctx.suggestions; adds the synthesized “Allow with edits” for editable tools and the universal “Tell the agent something else” escape hatch.

Wire reality (captured 2026-05-18; see baselines/sdk/2.1.117/):

  • Read outside workspace -> addRules with {toolName, ruleContent}. macOS sends BOTH //tmp/** AND //private/tmp/** – these collapse into ONE display option whose action carries BOTH rules.
  • Write / Edit outside workspace -> setMode -> acceptEdits + addDirectories (NOT addRules). Different variant mix.
  • ExitPlanMode -> suggestions: [] (empty). Plain Permission.