-
Notifications
You must be signed in to change notification settings - Fork 0
cliproxyapi fix #1080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cliproxyapi fix #1080
Changes from all commits
509fc8e
99430b3
d9d6a96
decb44a
b84795f
55d711f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ STATE_DIR="${OPENCLAW_STATE_DIR:-${HOME}/.openclaw}" | |||||||||||||||||||||||||||||||||
| CONFIG="${OPENCLAW_CONFIG_PATH:-${STATE_DIR}/openclaw.json}" | ||||||||||||||||||||||||||||||||||
| TEMPLATE="@template@" | ||||||||||||||||||||||||||||||||||
| SECRETS_DIR="${HOME}/.config/openclaw" | ||||||||||||||||||||||||||||||||||
| CLIPROXY_CONFIG="${OPENCLAW_CLIPROXY_CONFIG_PATH:-${HOME}/.cli-proxy-api/config.yaml}" | ||||||||||||||||||||||||||||||||||
| ENV_FILE="${HOME}/dotfiles/.env" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Source .env if it exists | ||||||||||||||||||||||||||||||||||
|
|
@@ -30,6 +31,23 @@ read_secret() { | |||||||||||||||||||||||||||||||||
| echo "" | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| read_cliproxy_api_key_from_config() { | ||||||||||||||||||||||||||||||||||
| local config_file="$1" | ||||||||||||||||||||||||||||||||||
| [ -f "$config_file" ] || return 0 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| awk ' | ||||||||||||||||||||||||||||||||||
| /^api-keys:/ { in_api_keys = 1; next } | ||||||||||||||||||||||||||||||||||
| in_api_keys && /^ - / { | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This parser only handles Prompt for AI agents |
||||||||||||||||||||||||||||||||||
| value = $0 | ||||||||||||||||||||||||||||||||||
| sub(/^ - "/, "", value) | ||||||||||||||||||||||||||||||||||
| sub(/"$/, "", value) | ||||||||||||||||||||||||||||||||||
| print value | ||||||||||||||||||||||||||||||||||
| exit | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| in_api_keys && /^[^[:space:]]/ { exit } | ||||||||||||||||||||||||||||||||||
| ' "$config_file" | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Load gateway token (required for both modes) | ||||||||||||||||||||||||||||||||||
| GATEWAY_TOKEN="${OPENCLAW_GATEWAY_TOKEN:-${GATEWAY_TOKEN:-$(read_secret "${SECRETS_DIR}/gateway-token")}}" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -42,7 +60,17 @@ mkdir -p "$STATE_DIR" | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if [ "$MODE" = "gateway" ]; then | ||||||||||||||||||||||||||||||||||
| # Gateway mode (Kyber): hydrate full template and start gateway | ||||||||||||||||||||||||||||||||||
| CLIPROXY_API_KEY="${OPENCLAW_CLIPROXY_API_KEY:-${CLIPROXY_API_KEY:-$(read_secret "${SECRETS_DIR}/cliproxy-key")}}" | ||||||||||||||||||||||||||||||||||
| cliproxy_api_key_from_env="${CLIPROXY_API_KEY:-}" | ||||||||||||||||||||||||||||||||||
| CLIPROXY_API_KEY="${OPENCLAW_CLIPROXY_API_KEY:-}" | ||||||||||||||||||||||||||||||||||
| if [ -z "$CLIPROXY_API_KEY" ]; then | ||||||||||||||||||||||||||||||||||
| CLIPROXY_API_KEY="$(read_cliproxy_api_key_from_config "$CLIPROXY_CONFIG")" | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| if [ -z "$CLIPROXY_API_KEY" ]; then | ||||||||||||||||||||||||||||||||||
| CLIPROXY_API_KEY="$cliproxy_api_key_from_env" | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| if [ -z "$CLIPROXY_API_KEY" ]; then | ||||||||||||||||||||||||||||||||||
| CLIPROXY_API_KEY="$(read_secret "${SECRETS_DIR}/cliproxy-key")" | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The chain of
Suggested change
|
||||||||||||||||||||||||||||||||||
| TELEGRAM_TOKEN="${OPENCLAW_TELEGRAM_TOKEN:-${TELEGRAM_TOKEN:-$(read_secret "${SECRETS_DIR}/telegram-token")}}" | ||||||||||||||||||||||||||||||||||
| WHATSAPP_ALLOW_FROM="${OPENCLAW_WHATSAPP_ALLOW_FROM:-${WHATSAPP_ALLOW_FROM:-$(read_secret "${SECRETS_DIR}/whatsapp-allow-from")}}" | ||||||||||||||||||||||||||||||||||
| ANTHROPIC_API_KEY="${OPENCLAW_ANTHROPIC_API_KEY:-${ANTHROPIC_API_KEY:-$(read_secret "${SECRETS_DIR}/anthropic-key")}}" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,17 +9,22 @@ let | |||||||
| config.home.homeDirectory | ||||||||
| or (if pkgs.stdenv.isDarwin then builtins.getEnv "HOME" else "/home/${config.home.username}"); | ||||||||
|
|
||||||||
| hydrateScript = pkgs.replaceVars ./scripts/hydrate.sh { | ||||||||
| commonScript = pkgs.replaceVars ./scripts/common.sh { | ||||||||
| aws = "${pkgs.awscli2}/bin/aws"; | ||||||||
| }; | ||||||||
|
|
||||||||
| hydrateScript = pkgs.replaceVars ./scripts/hydrate.sh { | ||||||||
| common = commonScript; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Prompt for AI agents
Suggested change
|
||||||||
| }; | ||||||||
|
|
||||||||
| backupScript = pkgs.replaceVars ./scripts/backup.sh { | ||||||||
| aws = "${pkgs.awscli2}/bin/aws"; | ||||||||
| common = commonScript; | ||||||||
| }; | ||||||||
|
|
||||||||
| startScript = pkgs.replaceVars ./scripts/start.sh { | ||||||||
| sed = "${pkgs.gnused}/bin/sed"; | ||||||||
| aws = "${pkgs.awscli2}/bin/aws"; | ||||||||
| common = commonScript; | ||||||||
|
|
||||||||
| }; | ||||||||
|
|
||||||||
| # Smart wrapper that handles both NixOS and non-NixOS Linux | ||||||||
|
|
@@ -45,7 +50,7 @@ let | |||||||
| ''; | ||||||||
|
|
||||||||
| wrapperScript = pkgs.replaceVars ./scripts/wrapper.sh { | ||||||||
| aws = "${pkgs.awscli2}/bin/aws"; | ||||||||
| common = commonScript; | ||||||||
| }; | ||||||||
|
|
||||||||
| cliWrapper = pkgs.writeShellScriptBin "cliproxyapi" (builtins.readFile wrapperScript); | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_load_env() { | ||||||||||||||||||||||||||||||||||||||||||||||
| local env_file="${HOME}/dotfiles/.env" | ||||||||||||||||||||||||||||||||||||||||||||||
| if [ -f "$env_file" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| set -a | ||||||||||||||||||||||||||||||||||||||||||||||
| # shellcheck source=/dev/null | ||||||||||||||||||||||||||||||||||||||||||||||
| . "$env_file" | ||||||||||||||||||||||||||||||||||||||||||||||
| set +a | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_strip_quotes() { | ||||||||||||||||||||||||||||||||||||||||||||||
| local value="$1" | ||||||||||||||||||||||||||||||||||||||||||||||
| value="${value%\"}" | ||||||||||||||||||||||||||||||||||||||||||||||
| value="${value#\"}" | ||||||||||||||||||||||||||||||||||||||||||||||
| printf '%s' "$value" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verifies current trimming behavior for double vs single quotes
v='"double-quoted"'; v="${v%\"}"; v="${v#\"}"; printf 'double => <%s>\n' "$v"
v="'single-quoted'"; v="${v%\"}"; v="${v#\"}"; printf 'single => <%s>\n' "$v"Repository: shunkakinoki/dotfiles Length of output: 118 🏁 Script executed: cat -n home-manager/services/cliproxyapi/scripts/common.sh | sed -n '1,30p'Repository: shunkakinoki/dotfiles Length of output: 1155 🏁 Script executed: rg "cliproxy_strip_quotes" -B 2 -A 10 home-manager/services/cliproxyapi/scripts/Repository: shunkakinoki/dotfiles Length of output: 2155 🏁 Script executed: # Check for .env parsing context and how the function is called
rg "\.env|strip_quotes" home-manager/services/cliproxyapi/ -B 2 -A 2Repository: shunkakinoki/dotfiles Length of output: 2534 🏁 Script executed: find home-manager/services/cliproxyapi -name "*.env*" -o -name "README*" | head -20Repository: shunkakinoki/dotfiles Length of output: 108 🏁 Script executed: rg "\.env|quote" home-manager/services/cliproxyapi/README.md -B 1 -A 3Repository: shunkakinoki/dotfiles Length of output: 397 🏁 Script executed: cat home-manager/services/cliproxyapi/README.md | grep -A 20 "Required in"Repository: shunkakinoki/dotfiles Length of output: 469
Lines 12-17 only strip double quotes ( 🔧 Suggested fix cliproxy_strip_quotes() {
local value="$1"
- value="${value%\"}"
- value="${value#\"}"
+ case "$value" in
+ \"*\")
+ value="${value#\"}"
+ value="${value%\"}"
+ ;;
+ \'*\')
+ value="${value#\'}"
+ value="${value%\'}"
+ ;;
+ esac
printf '%s' "$value"
}🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_init_objectstore_env() { | ||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_load_env | ||||||||||||||||||||||||||||||||||||||||||||||
| OBJECTSTORE_ENDPOINT="$(cliproxy_strip_quotes "${OBJECTSTORE_ENDPOINT:-}")" | ||||||||||||||||||||||||||||||||||||||||||||||
| OBJECTSTORE_BUCKET="$(cliproxy_strip_quotes "${OBJECTSTORE_BUCKET:-cliproxyapi}")" | ||||||||||||||||||||||||||||||||||||||||||||||
| OBJECTSTORE_ACCESS_KEY="$(cliproxy_strip_quotes "${OBJECTSTORE_ACCESS_KEY:-}")" | ||||||||||||||||||||||||||||||||||||||||||||||
| OBJECTSTORE_SECRET_KEY="$(cliproxy_strip_quotes "${OBJECTSTORE_SECRET_KEY:-}")" | ||||||||||||||||||||||||||||||||||||||||||||||
| export OBJECTSTORE_ENDPOINT OBJECTSTORE_BUCKET OBJECTSTORE_ACCESS_KEY OBJECTSTORE_SECRET_KEY | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_has_objectstore_credentials() { | ||||||||||||||||||||||||||||||||||||||||||||||
| [ -n "${OBJECTSTORE_ENDPOINT:-}" ] && | ||||||||||||||||||||||||||||||||||||||||||||||
| [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ] && | ||||||||||||||||||||||||||||||||||||||||||||||
| [ -n "${OBJECTSTORE_SECRET_KEY:-}" ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Include Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_auth_s3_uri() { | ||||||||||||||||||||||||||||||||||||||||||||||
| printf 's3://%s/auths/' "${OBJECTSTORE_BUCKET:?OBJECTSTORE_BUCKET is required}" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_s3_sync() { | ||||||||||||||||||||||||||||||||||||||||||||||
| local source_path="$1" | ||||||||||||||||||||||||||||||||||||||||||||||
| local destination_path="$2" | ||||||||||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY:?OBJECTSTORE_ACCESS_KEY is required}" \ | ||||||||||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY:?OBJECTSTORE_SECRET_KEY is required}" \ | ||||||||||||||||||||||||||||||||||||||||||||||
| @aws@ s3 sync \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --no-progress \ | ||||||||||||||||||||||||||||||||||||||||||||||
| "$source_path" \ | ||||||||||||||||||||||||||||||||||||||||||||||
| "$destination_path" || true | ||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Don't swallow S3 sync failures here; the backup/hydrate scripts currently treat failed transfers as success. Prompt for AI agents |
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Inspect where helper return semantics affect flow
rg -nP '\bcliproxy_s3_sync\b|\bcliproxy_sync_auth_(from|to)_s3\b' \
home-manager/services/cliproxyapi/scripts/common.sh \
home-manager/services/cliproxyapi/scripts/start.sh \
home-manager/services/cliproxyapi/scripts/wrapper.shRepository: shunkakinoki/dotfiles Length of output: 924 🏁 Script executed: # Read the common.sh file to see the full context of the helper functions
head -70 home-manager/services/cliproxyapi/scripts/common.sh | tail -35Repository: shunkakinoki/dotfiles Length of output: 1120 🏁 Script executed: # Read start.sh to see how these functions are called
cat home-manager/services/cliproxyapi/scripts/start.shRepository: shunkakinoki/dotfiles Length of output: 5973 🏁 Script executed: # Read wrapper.sh to see how these functions are called
cat home-manager/services/cliproxyapi/scripts/wrapper.shRepository: shunkakinoki/dotfiles Length of output: 689 Remove The 🔧 Suggested change cliproxy_s3_sync() {
local source_path="$1"
local destination_path="$2"
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY:?OBJECTSTORE_ACCESS_KEY is required}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY:?OBJECTSTORE_SECRET_KEY is required}" \
`@aws`@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
--no-progress \
"$source_path" \
- "$destination_path" || true
+ "$destination_path"
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_sync_auth_from_s3() { | ||||||||||||||||||||||||||||||||||||||||||||||
| local auth_dir="$1" | ||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$auth_dir" | ||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_s3_sync "$(cliproxy_auth_s3_uri)" "$auth_dir/" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_sync_auth_to_s3() { | ||||||||||||||||||||||||||||||||||||||||||||||
| local auth_dir="$1" | ||||||||||||||||||||||||||||||||||||||||||||||
| cliproxy_s3_sync "$auth_dir/" "$(cliproxy_auth_s3_uri)" | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: These deny rules are bypassable with Docker's long-form flags (
--all/--force), so equivalent destructive prune commands remain allowed.Prompt for AI agents