Skip to content

Commit a30ef22

Browse files
committed
init simple integration
1 parent 056937a commit a30ef22

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ variable "claude_md_path" {
192192
default = "$HOME/.claude/CLAUDE.md"
193193
}
194194

195+
variable "enable_boundary" {
196+
type = bool
197+
description = "Whether to enable coder boundary for network filtering"
198+
default = false
199+
}
200+
201+
variable "boundary_log_dir" {
202+
type = string
203+
description = "Directory for boundary logs"
204+
default = "/tmp/boundary_logs"
205+
}
206+
195207
resource "coder_env" "claude_code_md_path" {
196208
count = var.claude_md_path == "" ? 0 : 1
197209

@@ -231,6 +243,8 @@ locals {
231243
start_script = file("${path.module}/scripts/start.sh")
232244
module_dir_name = ".claude-module"
233245
remove_last_session_id_script_b64 = base64encode(file("${path.module}/scripts/remove-last-session-id.sh"))
246+
# Extract hostname from access_url for boundary --allow flag
247+
coder_host = replace(replace(data.coder_workspace.me.access_url, "https://", ""), "http://", "")
234248
}
235249

236250
module "agentapi" {
@@ -270,6 +284,9 @@ module "agentapi" {
270284
ARG_PERMISSION_MODE='${var.permission_mode}' \
271285
ARG_WORKDIR='${local.workdir}' \
272286
ARG_AI_PROMPT='${base64encode(var.ai_prompt)}' \
287+
ARG_ENABLE_BOUNDARY='${var.enable_boundary}' \
288+
ARG_BOUNDARY_LOG_DIR='${var.boundary_log_dir}' \
289+
ARG_CODER_HOST='${local.coder_host}' \
273290
/tmp/start.sh
274291
EOT
275292

registry/coder/modules/claude-code/main.tftest.hcl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,29 @@ run "test_claude_code_permission_mode_validation" {
187187
error_message = "Permission mode should be one of the valid options"
188188
}
189189
}
190+
191+
run "test_claude_code_with_boundary" {
192+
command = plan
193+
194+
variables {
195+
agent_id = "test-agent-boundary"
196+
workdir = "/home/coder/boundary-test"
197+
enable_boundary = true
198+
boundary_log_dir = "/tmp/test-boundary-logs"
199+
}
200+
201+
assert {
202+
condition = var.enable_boundary == true
203+
error_message = "Boundary should be enabled"
204+
}
205+
206+
assert {
207+
condition = var.boundary_log_dir == "/tmp/test-boundary-logs"
208+
error_message = "Boundary log dir should be set correctly"
209+
}
210+
211+
assert {
212+
condition = local.coder_host != ""
213+
error_message = "Coder host should be extracted from access URL"
214+
}
215+
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ ARG_DANGEROUSLY_SKIP_PERMISSIONS=${ARG_DANGEROUSLY_SKIP_PERMISSIONS:-}
1515
ARG_PERMISSION_MODE=${ARG_PERMISSION_MODE:-}
1616
ARG_WORKDIR=${ARG_WORKDIR:-"$HOME"}
1717
ARG_AI_PROMPT=$(echo -n "${ARG_AI_PROMPT:-}" | base64 -d)
18+
ARG_ENABLE_BOUNDARY=${ARG_ENABLE_BOUNDARY:-false}
19+
ARG_BOUNDARY_LOG_DIR=${ARG_BOUNDARY_LOG_DIR:-"/tmp/boundary_logs"}
20+
ARG_CODER_HOST=${ARG_CODER_HOST:-}
1821

1922
echo "--------------------------------"
2023

@@ -25,6 +28,9 @@ printf "ARG_DANGEROUSLY_SKIP_PERMISSIONS: %s\n" "$ARG_DANGEROUSLY_SKIP_PERMISSIO
2528
printf "ARG_PERMISSION_MODE: %s\n" "$ARG_PERMISSION_MODE"
2629
printf "ARG_AI_PROMPT: %s\n" "$ARG_AI_PROMPT"
2730
printf "ARG_WORKDIR: %s\n" "$ARG_WORKDIR"
31+
printf "ARG_ENABLE_BOUNDARY: %s\n" "$ARG_ENABLE_BOUNDARY"
32+
printf "ARG_BOUNDARY_LOG_DIR: %s\n" "$ARG_BOUNDARY_LOG_DIR"
33+
printf "ARG_CODER_HOST: %s\n" "$ARG_CODER_HOST"
2834

2935
echo "--------------------------------"
3036

@@ -74,7 +80,17 @@ function start_agentapi() {
7480
fi
7581
fi
7682
printf "Running claude code with args: %s\n" "$(printf '%q ' "${ARGS[@]}")"
77-
agentapi server --type claude --term-width 67 --term-height 1190 -- claude "${ARGS[@]}"
83+
84+
if [ "${ARG_ENABLE_BOUNDARY:-false}" = "true" ]; then
85+
mkdir -p "$ARG_BOUNDARY_LOG_DIR"
86+
printf "Starting with coder boundary enabled\n"
87+
agentapi server --type claude --term-width 67 --term-height 1190 -- \
88+
coder boundary --log-dir "$ARG_BOUNDARY_LOG_DIR" \
89+
--allow "*.anthropic.com" --allow "$ARG_CODER_HOST" -- \
90+
claude "${ARGS[@]}"
91+
else
92+
agentapi server --type claude --term-width 67 --term-height 1190 -- claude "${ARGS[@]}"
93+
fi
7894
}
7995

8096
validate_claude_installation

0 commit comments

Comments
 (0)