-
Notifications
You must be signed in to change notification settings - Fork 0
feat: enhance cliproxyapi with AMP API keys, GLM-4.7 support, and S3 config backup #447
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
Changes from all commits
e965660
a2315b1
ab7652b
b0fb91e
35b618b
6220231
67833c0
4058359
6fc5a70
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,10 +13,9 @@ remote-management: | |||||
| disable-control-panel: false | ||||||
| # Authentication directory (supports ~ for home directory). If you use Windows, please set the directory like this: `C:/cli-proxy-api/` | ||||||
| auth-dir: "~/.cli-proxy-api" | ||||||
| # API keys for authentication | ||||||
| # API keys for client authentication (optional - leave commented for open access) | ||||||
| # api-keys: | ||||||
| # - "your-api-key-1" | ||||||
| # - "your-api-key-2" | ||||||
| # - "your-api-key" | ||||||
|
|
||||||
| # Enable debug logging | ||||||
| debug: true | ||||||
|
|
@@ -34,12 +33,11 @@ quota-exceeded: | |||||
| switch-preview-model: true # Whether to automatically switch to a preview model when a quota is exceeded | ||||||
| # When true, enable authentication for the WebSocket API (/v1/ws). | ||||||
| ws-auth: false | ||||||
| # AMP | ||||||
| # AMP integration | ||||||
| ampcode: | ||||||
| upstream-url: "https://ampcode.com" | ||||||
| restrict-management-to-localhost: true | ||||||
| # amp-upstream-api-key: "" # Optional - use AMP_API_KEY env var or ~/.local/share/amp/secrets.json | ||||||
|
|
||||||
| upstream-api-key: "__AMP_UPSTREAM_API_KEY__" | ||||||
| restrict-management-to-localhost: false | ||||||
|
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: Changing Prompt for AI agents
|
||||||
| restrict-management-to-localhost: false | |
| restrict-management-to-localhost: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,6 +197,9 @@ | |
| "models": { | ||
| "glm-4.6": { | ||
| "name": "GLM-4.6 (via Z-AI)", | ||
|
||
| }, | ||
| "zai-coding-plan/glm-4.7": { | ||
| "name": "GLM-4.7 Coding Plan (via Z-AI)" | ||
| } | ||
| }, | ||
| "options": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,8 @@ set -euo pipefail | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CONFIG_DIR="$HOME/.cli-proxy-api" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TEMPLATE="$CONFIG_DIR/config.template.yaml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CONFIG="$CONFIG_DIR/config.yaml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV_FILE="$HOME/dotfiles/.env" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Use explicit path since $HOME may not be set correctly in launchd context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV_FILE="${HOME:-/Users/shunkakinoki}/dotfiles/.env" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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 hardcoded fallback path
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Use explicit path since $HOME may not be set correctly in launchd context | |
| ENV_FILE="${HOME:-/Users/shunkakinoki}/dotfiles/.env" | |
| # Use explicit path since $HOME may not be set correctly in launchd context | |
| # Fail explicitly if HOME is not set rather than using a hardcoded path | |
| if [ -z "${HOME:-}" ]; then | |
| echo "ERROR: HOME environment variable not set" >&2 | |
| exit 1 | |
| fi | |
| ENV_FILE="$HOME/dotfiles/.env" |
🤖 Prompt for AI Agents
In home-manager/services/cliproxyapi/scripts/start.sh around lines 8-9, remove
the hardcoded fallback /Users/shunkakinoki and instead require a valid HOME:
check if $HOME is set and non-empty and exit with a clear error if it isn't,
then construct ENV_FILE using "$HOME/dotfiles/.env" (no hardcoded user path) so
the script is portable across users and platforms.
Copilot
AI
Dec 25, 2025
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.
The S3 backup check only validates OBJECTSTORE_ENDPOINT and OBJECTSTORE_ACCESS_KEY, but the AWS CLI also requires OBJECTSTORE_SECRET_KEY to function properly. If the secret key is missing, the aws s3 cp command will fail. Add a check for OBJECTSTORE_SECRET_KEY in the condition to prevent attempting uploads that are guaranteed to fail.
| if [ -n "${OBJECTSTORE_ENDPOINT:-}" ] && [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ]; then | |
| if [ -n "${OBJECTSTORE_ENDPOINT:-}" ] && [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ] && [ -n "${OBJECTSTORE_SECRET_KEY:-}" ]; then |
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.
The aws s3 cp command could potentially hang, blocking the service from starting. To improve reliability, consider wrapping the command with timeout to prevent it from running indefinitely. The timeout utility is available since pkgs.coreutils is in the PATH.
| if AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | |
| if timeout 30s AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ |
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.
S3 backup logic has performance and configurability concerns.
Two issues to consider:
-
Synchronous backup delays startup: The S3 upload happens synchronously during service initialization, which can significantly delay startup if there are network issues.
-
Hardcoded bucket name: Line 51 uses a hardcoded bucket name
"cliproxyapi"instead of using the${OBJECTSTORE_BUCKET}variable that's already exported on line 24.
🔎 Suggested improvements
For the hardcoded bucket name, use the environment variable:
- "s3://cliproxyapi/config/config.yaml" 2>&1; then
+ "s3://${OBJECTSTORE_BUCKET}/config/config.yaml" 2>&1; thenFor the startup delay concern, consider:
- Making the S3 backup asynchronous (backgrounded)
- Or moving it to the separate backup service that already runs periodically
- Or adding a timeout to the AWS CLI command
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Upload config to S3 to ensure backup is always correct | |
| # This prevents corrupted configs from persisting across restarts | |
| if [ -n "${OBJECTSTORE_ENDPOINT:-}" ] && [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ]; then | |
| echo "Uploading config to S3 backup..." >&2 | |
| if AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | |
| AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \ | |
| @aws@ s3 cp \ | |
| --endpoint-url="${OBJECTSTORE_ENDPOINT}" \ | |
| --no-progress \ | |
| "$CONFIG" \ | |
| "s3://cliproxyapi/config/config.yaml" 2>&1; then | |
| echo "✅ Config backup uploaded" >&2 | |
| else | |
| echo "⚠️ Config backup failed (continuing anyway)" >&2 | |
| fi | |
| else | |
| echo "⚠️ S3 config backup skipped: missing credentials" >&2 | |
| fi | |
| # Upload config to S3 to ensure backup is always correct | |
| # This prevents corrupted configs from persisting across restarts | |
| if [ -n "${OBJECTSTORE_ENDPOINT:-}" ] && [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ]; then | |
| echo "Uploading config to S3 backup..." >&2 | |
| if AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | |
| AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \ | |
| @aws@ s3 cp \ | |
| --endpoint-url="${OBJECTSTORE_ENDPOINT}" \ | |
| --no-progress \ | |
| "$CONFIG" \ | |
| "s3://${OBJECTSTORE_BUCKET}/config/config.yaml" 2>&1; then | |
| echo "✅ Config backup uploaded" >&2 | |
| else | |
| echo "⚠️ Config backup failed (continuing anyway)" >&2 | |
| fi | |
| else | |
| echo "⚠️ S3 config backup skipped: missing credentials" >&2 | |
| fi |
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.
Changing
restrict-management-to-localhosttofalseallows management access from any remote machine, which significantly increases the attack surface of the service. While access is still protected by a secret key, it's recommended to keep management endpoints restricted to localhost unless remote management is a strict requirement. If remote access is needed, consider firewalling the management port to a trusted set of IP addresses.