Skip to content

fix(clawdbot): inject cliproxy apiKey via activation script - #615

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/clawdbot-cliproxy-apikey
Jan 18, 2026
Merged

fix(clawdbot): inject cliproxy apiKey via activation script#615
shunkakinoki merged 1 commit into
mainfrom
fix/clawdbot-cliproxy-apikey

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jan 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add activation script to inject cliproxy apiKey into clawdbot.json
  • The upstream nix-clawdbot doesn't pass apiKeyFile through configOverrides

Problem

The cliproxy provider was being loaded without authentication because apiKeyFile wasn't being passed through to the generated config. This caused clawdbot models list to show 0 cliproxy models and sub-agents to fall back to the default Anthropic model.

Solution

Added home.activation.clawdbotCliproxyKey that injects the API key from ~/.config/clawdbot/cliproxy-key into the JSON config at .models.providers.cliproxy.apiKey.

Test plan

  • Verified apiKey appears in ~/.clawdbot/clawdbot.json
  • Verified clawdbot-gateway starts successfully

🤖 Generated with Claude Code


Summary by cubic

Inject cliproxy API key into clawdbot.json during activation so the cliproxy provider loads with auth. Fixes missing cliproxy models and prevents sub-agents from falling back to the default Anthropic model.

  • Bug Fixes
    • Add home.activation.clawdbotCliproxyKey to read ~/.config/clawdbot/cliproxy-key and set .models.providers.cliproxy.apiKey.
    • Runs after secrets/config generation on Kyber hosts; verified key appears in config and gateway starts.

Written for commit b97909e. Summary will update on new commits.

Copilot AI review requested due to automatic review settings January 18, 2026 16:50
@mesa-dot-dev

mesa-dot-dev Bot commented Jan 18, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Jan 18, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Chores
    • Enhanced clawdbot configuration automation with improved API key management for supported hosts, streamlining setup on compatible systems.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Adds a new home-manager activation hook that reads a cliproxy API key from a file and injects it into the clawdbot.json configuration on Kyber hosts, following the established remote-token injection pattern.

Changes

Cohort / File(s) Summary
Clawdbot Activation
home-manager/modules/clawdbot/default.nix
New home.activation.clawdbotCliproxyKey hook added (+17 lines) that conditionally injects cliproxy API key into clawdbot.json on Kyber hosts; runs after clawdbotSecrets and clawdbotConfigFiles activations; mirrors existing remote-token injection pattern using jq for in-place JSON updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A cliproxy key hops into place,
Through jq's transforming grace,
On Kyber's turf it finds its home,
In clawdbot.json it'll roam,
No more secrets lost or scattered!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding an activation script to inject a cliproxy API key.
Description check ✅ Passed The description is well-related to the changeset, explaining the problem, solution, and test verification for the cliproxy API key injection feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/clawdbot-cliproxy-apikey

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical configuration gap in clawdbot's integration with the cliproxy provider. By implementing a custom activation script, it ensures that the necessary API key is correctly injected into the clawdbot configuration at runtime. This fix enables proper authentication for cliproxy models, preventing fallback to default models and ensuring the intended functionality of clawdbot's model listing and sub-agent operations.

Highlights

  • API Key Injection: Introduced a new activation script, home.activation.clawdbotCliproxyKey, to dynamically inject the cliproxy API key into the clawdbot.json configuration file.
  • Problem Resolution: This change resolves an issue where the cliproxy provider was not authenticating correctly because the apiKeyFile was not being passed through configOverrides by the upstream nix-clawdbot.
  • Configuration Source: The script reads the cliproxy API key from ~/.config/clawdbot/cliproxy-key and uses jq to insert it into the models.providers.cliproxy.apiKey path within clawdbot.json.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

The upstream nix-clawdbot doesn't pass apiKeyFile through configOverrides,
causing the cliproxy provider to be loaded without authentication.

Added an activation script to inject the apiKey from the key file into
the generated clawdbot.json config (similar to the gateway token injection).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mesa-dot-dev

mesa-dot-dev Bot commented Jan 18, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Add activation script to inject cliproxy apiKey into clawdbot.json. The upstream nix-clawdbot doesn't pass apiKeyFile through configOverrides.

What changed?

Added home.activation.clawdbotCliproxyKey that injects the API key from ~/.config/clawdbot/cliproxy-key into the JSON config at .models.providers.cliproxy.apiKey.

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a home-manager activation script to inject the cliproxy API key into clawdbot.json, addressing an upstream limitation. The approach is sound. My review includes a suggestion to make the script more robust by checking for a non-empty key file, using mktemp for safer file operations, and ensuring accurate success/error reporting.

Comment on lines +53 to +61
if [ -f "$KEY_FILE" ] && [ -f "$CONFIG_FILE" ]; then
KEY=$(${pkgs.coreutils}/bin/cat "$KEY_FILE" | ${pkgs.coreutils}/bin/tr -d '\n')
# Inject apiKey into models.providers.cliproxy
${pkgs.jq}/bin/jq --arg key "$KEY" \
'.models.providers.cliproxy.apiKey = $key' \
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && \
${pkgs.coreutils}/bin/mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
echo "Injected cliproxy API key into clawdbot config"
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This script block can be made more robust and correct. Currently, it reports success even if the mv command fails, and it doesn't handle empty key files. I suggest the following improvements:

  1. Check for non-empty key file: Use [ -s "$KEY_FILE" ] instead of [ -f "$KEY_FILE" ] to prevent injecting an empty API key if extract-secrets.sh doesn't find a key.
  2. Use mktemp: Create a secure temporary file to avoid issues with stale or conflicting temporary files.
  3. Correct Error Handling: Ensure the success message is only printed if the entire operation succeeds, and provide an error message otherwise. This also includes cleaning up the temporary file on failure.
      if [ -s "$KEY_FILE" ] && [ -f "$CONFIG_FILE" ]; then
        KEY=$(${pkgs.coreutils}/bin/cat "$KEY_FILE" | ${pkgs.coreutils}/bin/tr -d '\n')
        TMP_FILE=$(${pkgs.coreutils}/bin/mktemp)
        # Inject apiKey into models.providers.cliproxy
        if ${pkgs.jq}/bin/jq --arg key "$KEY" \
          '.models.providers.cliproxy.apiKey = $key' \
          "$CONFIG_FILE" > "$TMP_FILE" && \
          ${pkgs.coreutils}/bin/mv "$TMP_FILE" "$CONFIG_FILE"; then
          echo "Injected cliproxy API key into clawdbot config"
        else
          echo "Error: Failed to inject cliproxy API key into clawdbot config." >&2
          ${pkgs.coreutils}/bin/rm -f "$TMP_FILE"
        fi
      fi

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds an activation script to inject the cliproxy API key into the clawdbot configuration file, working around the limitation that the upstream nix-clawdbot package doesn't support apiKeyFile in configOverrides.

Changes:

  • Added home.activation.clawdbotCliproxyKey activation script that reads the API key from ~/.config/clawdbot/cliproxy-key and injects it into the generated clawdbot.json config at the path .models.providers.cliproxy.apiKey

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@home-manager/modules/clawdbot/default.nix`:
- Around line 53-61: The script currently reads KEY from KEY_FILE then
unconditionally runs jq to set .models.providers.cliproxy.apiKey and echoes
success; fix this by validating the KEY is non-empty (test -n "$KEY" after KEY
is assigned) and aborting/ skipping injection if empty, and ensure the echo
"Injected cliproxy API key into clawdbot config" only runs when the jq command
and subsequent mv both succeed (i.e., chain the jq -> mv pipeline and only print
on its success). Use the existing KEY_FILE, CONFIG_FILE, KEY variable and the
jq/mv pipeline to implement these checks so the config is not overwritten with
an empty key and the success log reflects true success.
🧹 Nitpick comments (1)
home-manager/modules/clawdbot/default.nix (1)

41-66: Keep home.activation.* entries alphabetically ordered.

With the new entry, the activation keys are no longer sorted. Consider ordering them as clawdbotCliproxyKey, clawdbotRemoteToken, clawdbotSecrets to comply with the Nix style guideline. As per coding guidelines, ...

Comment on lines +53 to +61
if [ -f "$KEY_FILE" ] && [ -f "$CONFIG_FILE" ]; then
KEY=$(${pkgs.coreutils}/bin/cat "$KEY_FILE" | ${pkgs.coreutils}/bin/tr -d '\n')
# Inject apiKey into models.providers.cliproxy
${pkgs.jq}/bin/jq --arg key "$KEY" \
'.models.providers.cliproxy.apiKey = $key' \
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && \
${pkgs.coreutils}/bin/mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
echo "Injected cliproxy API key into clawdbot config"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard against empty key + avoid false “Injected” logs.

If the key file exists but is empty (or jq fails), the script will overwrite the config with an empty apiKey and still print success, which can silently break authentication. Consider requiring a non-empty key and chaining the success log to the jq/mv pipeline.

🔧 Suggested fix
-      if [ -f "$KEY_FILE" ] && [ -f "$CONFIG_FILE" ]; then
-        KEY=$(${pkgs.coreutils}/bin/cat "$KEY_FILE" | ${pkgs.coreutils}/bin/tr -d '\n')
-        # Inject apiKey into models.providers.cliproxy
-        ${pkgs.jq}/bin/jq --arg key "$KEY" \
-          '.models.providers.cliproxy.apiKey = $key' \
-          "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && \
-          ${pkgs.coreutils}/bin/mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
-        echo "Injected cliproxy API key into clawdbot config"
-      fi
+      if [ -f "$KEY_FILE" ] && [ -f "$CONFIG_FILE" ]; then
+        KEY=$(${pkgs.coreutils}/bin/cat "$KEY_FILE" | ${pkgs.coreutils}/bin/tr -d '\n')
+        if [ -n "$KEY" ]; then
+          # Inject apiKey into models.providers.cliproxy
+          ${pkgs.jq}/bin/jq --arg key "$KEY" \
+            '.models.providers.cliproxy.apiKey = $key' \
+            "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && \
+            ${pkgs.coreutils}/bin/mv "$CONFIG_FILE.tmp" "$CONFIG_FILE" && \
+            echo "Injected cliproxy API key into clawdbot config"
+        else
+          echo "cliproxy key is empty; skipping injection"
+        fi
+      fi
📝 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.

Suggested change
if [ -f "$KEY_FILE" ] && [ -f "$CONFIG_FILE" ]; then
KEY=$(${pkgs.coreutils}/bin/cat "$KEY_FILE" | ${pkgs.coreutils}/bin/tr -d '\n')
# Inject apiKey into models.providers.cliproxy
${pkgs.jq}/bin/jq --arg key "$KEY" \
'.models.providers.cliproxy.apiKey = $key' \
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && \
${pkgs.coreutils}/bin/mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
echo "Injected cliproxy API key into clawdbot config"
fi
if [ -f "$KEY_FILE" ] && [ -f "$CONFIG_FILE" ]; then
KEY=$(${pkgs.coreutils}/bin/cat "$KEY_FILE" | ${pkgs.coreutils}/bin/tr -d '\n')
if [ -n "$KEY" ]; then
# Inject apiKey into models.providers.cliproxy
${pkgs.jq}/bin/jq --arg key "$KEY" \
'.models.providers.cliproxy.apiKey = $key' \
"$CONFIG_FILE" > "$CONFIG_FILE.tmp" && \
${pkgs.coreutils}/bin/mv "$CONFIG_FILE.tmp" "$CONFIG_FILE" && \
echo "Injected cliproxy API key into clawdbot config"
else
echo "cliproxy key is empty; skipping injection"
fi
fi
🤖 Prompt for AI Agents
In `@home-manager/modules/clawdbot/default.nix` around lines 53 - 61, The script
currently reads KEY from KEY_FILE then unconditionally runs jq to set
.models.providers.cliproxy.apiKey and echoes success; fix this by validating the
KEY is non-empty (test -n "$KEY" after KEY is assigned) and aborting/ skipping
injection if empty, and ensure the echo "Injected cliproxy API key into clawdbot
config" only runs when the jq command and subsequent mv both succeed (i.e.,
chain the jq -> mv pipeline and only print on its success). Use the existing
KEY_FILE, CONFIG_FILE, KEY variable and the jq/mv pipeline to implement these
checks so the config is not overwritten with an empty key and the success log
reflects true success.

@shunkakinoki
shunkakinoki merged commit 5bda80d into main Jan 18, 2026
32 checks passed
@shunkakinoki
shunkakinoki deleted the fix/clawdbot-cliproxy-apikey branch January 18, 2026 16:56

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

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.

2 participants