Skip to content

Commit bd1a36b

Browse files
feat: use coder boundary subcommand (#674)
## Summary of Changes ### Feature: Add `coder boundary` subcommand support as default Adds `coder boundary` subcommand as the default method for running boundary eliminating the need to install boundary separately. **Changes:** 1. **New variable: `use_boundary_directly`** (default: `false`) - `false`: Uses `coder boundary` subcommand (default, no installation) - `true`: Installs boundary binary from release - `compile_boundary_from_source = true`: Compiles from source 2. **Fixed CAP_NET_ADMIN capability issue** - Copies `coder` binary to `coder-no-caps` to strip capabilities (required for boundary) 3. **Removed `boundary-run` wrapper** - no longer used **Files Modified:** - `scripts/start.sh` - main implementation - `main.tf` - added `use_boundary_directly` variable **Behavior:** - **Default**: Uses `coder boundary` subcommand (no installation needed) - **`use_boundary_directly = true`**: Installs boundary from release version - **`compile_boundary_from_source = true`**: Compiles boundary from source <!-- Briefly describe what this PR does and why --> ## Type of Change - [ ] New module - [ ] New template - [ ] Bug fix - [x] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information <!-- Delete this section if not applicable --> **Path:** `registry/coder/modules/claude-code` **New version:** `v4.7.0` **Breaking change:** [ ] Yes [X] No ## Testing & Validation - [ ] Tests pass (`bun test`) - [ ] Code formatted (`bun fmt`) - [ ] Changes tested locally ## Related Issues <!-- Link related issues or write "None" if not applicable -->
1 parent 01d6669 commit bd1a36b

3 files changed

Lines changed: 51 additions & 21 deletions

File tree

registry/coder/modules/claude-code/README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude
1313
```tf
1414
module "claude-code" {
1515
source = "registry.coder.com/coder/claude-code/coder"
16-
version = "4.6.0"
16+
version = "4.7.0"
1717
agent_id = coder_agent.main.id
1818
workdir = "/home/coder/project"
1919
claude_api_key = "xxxx-xxxxx-xxxx"
@@ -42,17 +42,21 @@ By default, Claude Code automatically resumes existing conversations when your w
4242

4343
This example shows how to configure the Claude Code module to run the agent behind a process-level boundary that restricts its network access.
4444

45+
By default, when `enable_boundary = true`, the module uses `coder boundary` subcommand (provided by Coder) without requiring any installation.
46+
4547
```tf
4648
module "claude-code" {
47-
source = "registry.coder.com/coder/claude-code/coder"
48-
version = "4.6.0"
49-
agent_id = coder_agent.main.id
50-
workdir = "/home/coder/project"
51-
enable_boundary = true
52-
boundary_version = "v0.5.1"
49+
source = "registry.coder.com/coder/claude-code/coder"
50+
version = "4.7.0"
51+
agent_id = coder_agent.main.id
52+
workdir = "/home/coder/project"
53+
enable_boundary = true
5354
}
5455
```
5556

57+
> [!NOTE]
58+
> For developers: The module also supports installing boundary from a release version (`use_boundary_directly = true`) or compiling from source (`compile_boundary_from_source = true`). These are escape hatches for development and testing purposes.
59+
5660
### Usage with AI Bridge
5761

5862
[AI Bridge](https://coder.com/docs/ai-coder/ai-bridge) is a Premium Coder feature that provides centralized LLM proxy management. To use AI Bridge, set `enable_aibridge = true`.
@@ -64,7 +68,7 @@ For tasks integration with AI Bridge, add `enable_aibridge = true` to the [Usage
6468
```tf
6569
module "claude-code" {
6670
source = "registry.coder.com/coder/claude-code/coder"
67-
version = "4.6.0"
71+
version = "4.7.0"
6872
agent_id = coder_agent.main.id
6973
workdir = "/home/coder/project"
7074
enable_aibridge = true
@@ -93,7 +97,7 @@ data "coder_task" "me" {}
9397
9498
module "claude-code" {
9599
source = "registry.coder.com/coder/claude-code/coder"
96-
version = "4.6.0"
100+
version = "4.7.0"
97101
agent_id = coder_agent.main.id
98102
workdir = "/home/coder/project"
99103
claude_api_key = "xxxx-xxxxx-xxxx"
@@ -114,7 +118,7 @@ This example shows additional configuration options for version pinning, custom
114118
```tf
115119
module "claude-code" {
116120
source = "registry.coder.com/coder/claude-code/coder"
117-
version = "4.6.0"
121+
version = "4.7.0"
118122
agent_id = coder_agent.main.id
119123
workdir = "/home/coder/project"
120124
@@ -170,7 +174,7 @@ Run and configure Claude Code as a standalone CLI in your workspace.
170174
```tf
171175
module "claude-code" {
172176
source = "registry.coder.com/coder/claude-code/coder"
173-
version = "4.6.0"
177+
version = "4.7.0"
174178
agent_id = coder_agent.main.id
175179
workdir = "/home/coder/project"
176180
install_claude_code = true
@@ -192,7 +196,7 @@ variable "claude_code_oauth_token" {
192196
193197
module "claude-code" {
194198
source = "registry.coder.com/coder/claude-code/coder"
195-
version = "4.6.0"
199+
version = "4.7.0"
196200
agent_id = coder_agent.main.id
197201
workdir = "/home/coder/project"
198202
claude_code_oauth_token = var.claude_code_oauth_token
@@ -265,7 +269,7 @@ resource "coder_env" "bedrock_api_key" {
265269
266270
module "claude-code" {
267271
source = "registry.coder.com/coder/claude-code/coder"
268-
version = "4.6.0"
272+
version = "4.7.0"
269273
agent_id = coder_agent.main.id
270274
workdir = "/home/coder/project"
271275
model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
@@ -322,7 +326,7 @@ resource "coder_env" "google_application_credentials" {
322326
323327
module "claude-code" {
324328
source = "registry.coder.com/coder/claude-code/coder"
325-
version = "4.6.0"
329+
version = "4.7.0"
326330
agent_id = coder_agent.main.id
327331
workdir = "/home/coder/project"
328332
model = "claude-sonnet-4@20250514"

registry/coder/modules/claude-code/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ variable "compile_boundary_from_source" {
234234
default = false
235235
}
236236

237+
variable "use_boundary_directly" {
238+
type = bool
239+
description = "Whether to use boundary binary directly instead of coder boundary subcommand. When false (default), uses coder boundary subcommand. When true, installs and uses boundary binary from release."
240+
default = false
241+
}
242+
237243
variable "enable_aibridge" {
238244
type = bool
239245
description = "Use AI Bridge for Claude Code. https://coder.com/docs/ai-coder/ai-bridge"
@@ -389,6 +395,7 @@ module "agentapi" {
389395
ARG_ENABLE_BOUNDARY='${var.enable_boundary}' \
390396
ARG_BOUNDARY_VERSION='${var.boundary_version}' \
391397
ARG_COMPILE_FROM_SOURCE='${var.compile_boundary_from_source}' \
398+
ARG_USE_BOUNDARY_DIRECTLY='${var.use_boundary_directly}' \
392399
ARG_CODER_HOST='${local.coder_host}' \
393400
/tmp/start.sh
394401
EOT

registry/coder/modules/claude-code/scripts/start.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ARG_REPORT_TASKS=${ARG_REPORT_TASKS:-true}
1616
ARG_ENABLE_BOUNDARY=${ARG_ENABLE_BOUNDARY:-false}
1717
ARG_BOUNDARY_VERSION=${ARG_BOUNDARY_VERSION:-"main"}
1818
ARG_COMPILE_FROM_SOURCE=${ARG_COMPILE_FROM_SOURCE:-false}
19+
ARG_USE_BOUNDARY_DIRECTLY=${ARG_USE_BOUNDARY_DIRECTLY:-false}
1920
ARG_CODER_HOST=${ARG_CODER_HOST:-}
2021

2122
echo "--------------------------------"
@@ -30,12 +31,13 @@ printf "ARG_REPORT_TASKS: %s\n" "$ARG_REPORT_TASKS"
3031
printf "ARG_ENABLE_BOUNDARY: %s\n" "$ARG_ENABLE_BOUNDARY"
3132
printf "ARG_BOUNDARY_VERSION: %s\n" "$ARG_BOUNDARY_VERSION"
3233
printf "ARG_COMPILE_FROM_SOURCE: %s\n" "$ARG_COMPILE_FROM_SOURCE"
34+
printf "ARG_USE_BOUNDARY_DIRECTLY: %s\n" "$ARG_USE_BOUNDARY_DIRECTLY"
3335
printf "ARG_CODER_HOST: %s\n" "$ARG_CODER_HOST"
3436

3537
echo "--------------------------------"
3638

3739
function install_boundary() {
38-
if [ "${ARG_COMPILE_FROM_SOURCE:-false}" = "true" ]; then
40+
if [ "$ARG_COMPILE_FROM_SOURCE" = "true" ]; then
3941
# Install boundary by compiling from source
4042
echo "Compiling boundary from source (version: $ARG_BOUNDARY_VERSION)"
4143

@@ -52,14 +54,16 @@ function install_boundary() {
5254
# Build the binary
5355
make build
5456

55-
# Install binary and wrapper script (optional)
57+
# Install binary
5658
sudo cp boundary /usr/local/bin/
57-
sudo cp scripts/boundary-wrapper.sh /usr/local/bin/boundary-run
58-
sudo chmod +x /usr/local/bin/boundary-run
59-
else
59+
sudo chmod +x /usr/local/bin/boundary
60+
elif [ "$ARG_USE_BOUNDARY_DIRECTLY" = "true" ]; then
6061
# Install boundary using official install script
6162
echo "Installing boundary using official install script (version: $ARG_BOUNDARY_VERSION)"
6263
curl -fsSL https://raw.githubusercontent.com/coder/boundary/main/install.sh | bash -s -- --version "$ARG_BOUNDARY_VERSION"
64+
else
65+
# Use coder boundary subcommand (default) - no installation needed
66+
echo "Using coder boundary subcommand (provided by Coder)"
6367
fi
6468
}
6569

@@ -212,15 +216,30 @@ function start_agentapi() {
212216

213217
printf "Running claude code with args: %s\n" "$(printf '%q ' "${ARGS[@]}")"
214218

215-
if [ "${ARG_ENABLE_BOUNDARY:-false}" = "true" ]; then
219+
if [ "$ARG_ENABLE_BOUNDARY" = "true" ]; then
216220
install_boundary
217221

218222
printf "Starting with coder boundary enabled\n"
219223

220224
BOUNDARY_ARGS+=()
221225

226+
# Determine which boundary command to use
227+
if [ "$ARG_COMPILE_FROM_SOURCE" = "true" ] || [ "$ARG_USE_BOUNDARY_DIRECTLY" = "true" ]; then
228+
# Use boundary binary directly (from compilation or release installation)
229+
BOUNDARY_CMD=("boundary")
230+
else
231+
# Use coder boundary subcommand (default)
232+
# Copy coder binary to coder-no-caps. Copying strips CAP_NET_ADMIN capabilities
233+
# from the binary, which is necessary because boundary doesn't work with
234+
# privileged binaries (you can't launch privileged binaries inside network
235+
# namespaces unless you have sys_admin).
236+
CODER_NO_CAPS="$(dirname "$(which coder)")/coder-no-caps"
237+
cp "$(which coder)" "$CODER_NO_CAPS"
238+
BOUNDARY_CMD=("$CODER_NO_CAPS" "boundary")
239+
fi
240+
222241
agentapi server --type claude --term-width 67 --term-height 1190 -- \
223-
boundary-run "${BOUNDARY_ARGS[@]}" -- \
242+
"${BOUNDARY_CMD[@]}" "${BOUNDARY_ARGS[@]}" -- \
224243
claude "${ARGS[@]}"
225244
else
226245
agentapi server --type claude --term-width 67 --term-height 1190 -- claude "${ARGS[@]}"

0 commit comments

Comments
 (0)