diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-17 23:55:08 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-17 23:59:56 +0300 |
| commit | e0758c32118f2aa006db3d8fa4b41833fe6e7ead (patch) | |
| tree | 2b29dd61ebf870db8d0ac95cc0b4515178c834c4 /src/app/api_helpers.rs | |
| parent | 040956531f673c8fb7720037494ed4e61b123c6c (diff) | |
feat: harden named agent cli workflows
refs #1525
Diffstat (limited to 'src/app/api_helpers.rs')
| -rw-r--r-- | src/app/api_helpers.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/app/api_helpers.rs b/src/app/api_helpers.rs index c0a98357..c7dc39d2 100644 --- a/src/app/api_helpers.rs +++ b/src/app/api_helpers.rs @@ -48,6 +48,35 @@ pub(super) fn encode_api_keys( Ok(encoded_keys) } +pub(super) fn encode_api_submission( + runtime: &crate::terminal::TerminalRuntime, + text: &str, +) -> Vec<u8> { + let mut bytes = encode_api_text(runtime, text); + let enter = crossterm::event::KeyEvent::new( + crossterm::event::KeyCode::Enter, + crossterm::event::KeyModifiers::NONE, + ); + bytes.extend_from_slice(&runtime.encode_terminal_key(enter.into())); + bytes +} + +pub(super) fn encode_api_input( + runtime: &crate::terminal::TerminalRuntime, + text: &str, + keys: &[String], +) -> Result<Vec<u8>, String> { + let mut bytes = if text.is_empty() { + Vec::new() + } else { + encode_api_text(runtime, text) + }; + for encoded in encode_api_keys(runtime, keys)? { + bytes.extend_from_slice(&encoded); + } + Ok(bytes) +} + pub(super) fn detect_state_from_api( state: crate::api::schema::PaneAgentState, ) -> crate::detect::AgentState { |
