Module: Kward::PromptInterface::ApprovalPrompt
- Included in:
- Kward::PromptInterface
- Defined in:
- lib/kward/prompt_interface/approval_prompt.rb
Overview
Tool-approval overlay built on the structured question modal.
Instance Method Summary collapse
-
#ask_tool_approval(tool_name:, args:, reason: nil) ⇒ Object
Asks the captain to approve a model-requested tool call.
Instance Method Details
#ask_tool_approval(tool_name:, args:, reason: nil) ⇒ Object
Asks the captain to approve a model-requested tool call. Cancellation is intentionally a denial so a closed or interrupted overlay never permits a side effect.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kward/prompt_interface/approval_prompt.rb', line 11 def ask_tool_approval(tool_name:, args:, reason: nil) summary, details = tool_approval_details(tool_name, args) question = (["The agent wants to #{summary}."] + Array(details) + [reason.to_s].reject(&:empty?)).join("\n") answers = ask_user_question([ { header: "Approval required · #{tool_approval_title(tool_name)}", question: question, options: [ { label: "Allow once", description: "Run this tool call." }, { label: "Allow this tool for this session", description: "Run this call and future calls to #{tool_name}." }, { label: "Deny", description: "Do not run this tool call." } ] } ]) answer = answers&.first return { denied_message: answer[:answer] } if answer&.fetch(:custom, false) && !answer[:answer].to_s.empty? case answer&.fetch(:answer, nil) when "Allow once" then true when "Allow this tool for this session" then :allow_for_session else false end end |