close
Skip to content

feat: add support for sudo and password-requiring commands - #1

Open
bernatfp wants to merge 3 commits into
devfrom
feat/sudo-secure-input
Open

feat: add support for sudo and password-requiring commands#1
bernatfp wants to merge 3 commits into
devfrom
feat/sudo-secure-input

Conversation

@bernatfp

Copy link
Copy Markdown
Owner

Add SecureInput system for handling password prompts in interactive commands (sudo, ssh -t, ansible -K, etc.).

  • Create SecureInput namespace with event-based password request system
  • Add PTY-based execution path in Bash tool for interactive commands
  • Auto-detect commands needing interaction via pattern matching
  • Detect password prompts and request secure input from user
  • Sanitize output to remove password prompts before sending to LLM
  • Add server routes for secure-input submit/cancel
  • Add TUI SecureInputPrompt component
  • Add web app SecureInputPrompt component
  • Integrate secure_input into sync contexts

Security: Password goes directly to PTY, never stored or logged. 60s timeout, max 3 retry attempts.

Refs: anomalyco#9808

What does this PR do?

How did you verify your code works?

bernatfp and others added 3 commits January 21, 2026 10:53
Add SecureInput system for handling password prompts in interactive
commands (sudo, ssh -t, ansible -K, etc.).

- Create SecureInput namespace with event-based password request system
- Add PTY-based execution path in Bash tool for interactive commands
- Auto-detect commands needing interaction via pattern matching
- Detect password prompts and request secure input from user
- Sanitize output to remove password prompts before sending to LLM
- Add server routes for secure-input submit/cancel
- Add TUI SecureInputPrompt component
- Add web app SecureInputPrompt component
- Integrate secure_input into sync contexts

Security: Password goes directly to PTY, never stored or logged.
60s timeout, max 3 retry attempts.

Refs: anomalyco#9808

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…putPrompt

- Remove unsupported `password` prop from textarea
- Implement manual password input handling with useKeyboard
- Display asterisks (*) for each character entered
- Handle Enter to submit, Escape to cancel, Backspace to delete
- Add visual cursor indicator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The SecureInputPrompt's Enter and Escape keys weren't working because
sdk.client.secureInput didn't exist in the JS SDK - the handlers threw
errors before reaching the submit/cancel logic.

Root cause: The secure-input API routes were added to the backend but
the SDK was never regenerated to include the client methods. This caused
silent failures when calling sdk.client.secureInput.submit() and
sdk.client.secureInput.cancel().

SDK changes (regenerated from OpenAPI spec):
- Added SecureInputRequest type and secure-input event payloads
- Added request/response shapes for /secure-input endpoints
- Added SecureInput client with list, listForSession, submit, cancel
- Exposed via OpencodeClient.secureInput

TUI changes:
- Simplified keyboard handling using direct useKeyboard capture
- Removed hidden textarea approach (onInput was not a valid prop)
- Added dialog guard to skip input when dialogs are open
- Changed clear shortcut from Ctrl+Delete to Ctrl+U

Why the original diagnosis missed this: The investigation focused on
the TUI layer (keyboard event handling, textarea props, focus management)
rather than verifying the SDK methods existed. The TypeScript errors for
SecureInputRequest and secureInput were visible but dismissed as
"pre-existing SDK type generation issues" rather than recognized as
the root cause. A simple console.log in the submit/cancel handlers
would have revealed the SDK calls were throwing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant