From 66801b5d07c1773c38d7f175bb14a7c92ae5911e Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Fri, 23 Jan 2026 14:18:52 -0700 Subject: [PATCH] feat: Added an environment variable that lets users bypass guard operations in bash scripts. This is useful for agent routing --- assets/functions/utils/prompt-utils.sh | 24 +++++++++++--------- docs/ENVIRONMENT-VARIABLES.md | 6 +++++ docs/function-calling/BASH-PROMPT-HELPERS.md | 8 +++++-- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/assets/functions/utils/prompt-utils.sh b/assets/functions/utils/prompt-utils.sh index 2e0d4eb..f78eaea 100755 --- a/assets/functions/utils/prompt-utils.sh +++ b/assets/functions/utils/prompt-utils.sh @@ -507,12 +507,14 @@ open_link() { guard_operation() { if [[ -t 1 ]]; then - ans="$(confirm "${1:-Are you sure you want to continue?}")" + if [[ -z "$AUTO_CONFIRM" ]]; then + ans="$(confirm "${1:-Are you sure you want to continue?}")" - if [[ "$ans" == 0 ]]; then - error "Operation aborted!" 2>&1 - exit 1 - fi + if [[ "$ans" == 0 ]]; then + error "Operation aborted!" 2>&1 + exit 1 + fi + fi fi } @@ -657,13 +659,13 @@ guard_path() { path="$(_to_real_path "$1")" confirmation_prompt="$2" - if [[ ! "$path" == "$(pwd)"* ]]; then - ans="$(confirm "$confirmation_prompt")" + if [[ ! "$path" == "$(pwd)"* && -z "$AUTO_CONFIRM" ]]; then + ans="$(confirm "$confirmation_prompt")" - if [[ "$ans" == 0 ]]; then - error "Operation aborted!" >&2 - exit 1 - fi + if [[ "$ans" == 0 ]]; then + error "Operation aborted!" >&2 + exit 1 + fi fi fi } diff --git a/docs/ENVIRONMENT-VARIABLES.md b/docs/ENVIRONMENT-VARIABLES.md index 9f132ce..3bb52e0 100644 --- a/docs/ENVIRONMENT-VARIABLES.md +++ b/docs/ENVIRONMENT-VARIABLES.md @@ -17,6 +17,7 @@ loki --info | grep 'config_dir' | awk '{print $2}' - [Files and Directory Related Variables](#files-and-directory-related-variables) - [Agent Related Variables](#agent-related-variables) - [Logging Related Variables](#logging-related-variables) +- [Miscellaneous Variables](#miscellaneous-variables) --- @@ -104,3 +105,8 @@ The following variables can be used to change the log level of Loki or the locat **Pro-Tip:** You can always tail the Loki logs using the `--tail-logs` flag. If you need to disable color output, you can also pass the `--disable-log-colors` flag as well. + +## Miscellaneous Variables +| Environment Variable | Description | Default Value | +|----------------------|--------------------------------------------------------------------------------------------------|---------------| +| `AUTO_CONFIRM` | Bypass all `guard_*` checks in the bash prompt helpers; useful for agent composition and routing | | \ No newline at end of file diff --git a/docs/function-calling/BASH-PROMPT-HELPERS.md b/docs/function-calling/BASH-PROMPT-HELPERS.md index 92f22f8..b2d3ed4 100644 --- a/docs/function-calling/BASH-PROMPT-HELPERS.md +++ b/docs/function-calling/BASH-PROMPT-HELPERS.md @@ -207,7 +207,9 @@ open_link https://www.google.com ``` ### guard_operation -Prompt for permission to run an operation +Prompt for permission to run an operation. + +Can be disabled by setting the environment variable `AUTO_CONFIRM`. **Example:** ```bash @@ -216,7 +218,9 @@ _run_sql ``` ### guard_path -Prompt for permission to perform path operations +Prompt for permission to perform path operations. + +Can be disabled by setting the environment variable `AUTO_CONFIRM`. **Example:*** ```bash