From 0d03fa4e580d998c8998d88f64e268a3bb6e95b2 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 3 Dec 2025 18:34:46 +0530 Subject: [PATCH] wip --- registry/coder/modules/claude-code/main.tf | 3 +- .../modules/claude-code/scripts/start.sh | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index aa78875d..fee1e8c4 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -255,7 +255,7 @@ variable "compile_boundary_from_source" { variable "cli_command" { type = string description = "The command to run for the Claude Code CLI app when tasks are disabled." - default = "claude" + default = "" } resource "coder_env" "claude_code_md_path" { @@ -345,6 +345,7 @@ resource "coder_script" "install_agent" { agent_id = var.agent_id display_name = "Install agent" run_on_start = true + log_path = "${path.module}/install.log" script = <<-EOT #!/bin/bash set -o errexit diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index 59983b9e..85058b12 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -1,9 +1,5 @@ #!/bin/bash -if [ -f "$HOME/.bashrc" ]; then - source "$HOME"/.bashrc -fi - # Set strict error handling AFTER sourcing bashrc to avoid unbound variable errors from user dotfiles set -euo pipefail @@ -58,6 +54,11 @@ bash "/tmp/remove-last-session-id.sh" "$(pwd)" 2> /dev/null session_cleanup_exit_code=$? set -e +CORE_COMMAND=() +if [[ "${ARG_REPORT_TASKS}" == "true" ]]; then + CORE_COMMAND+=(agentapi server --type claude --term-width 67 --term-height 1190 --) +fi + case $session_cleanup_exit_code in 0) CAN_CONTINUE_CONVERSATION=true @@ -186,8 +187,8 @@ function start_agentapi() { ARGS+=(--session-id "$TASK_SESSION_ID") fi fi - if [ -n "$ARG_AI_PROMPT" ]; then - if [ "$ARG_REPORT_TASKS" = "true" ]; then + if [[ -n "${ARG_AI_PROMPT}" ]]; then + if [[ "${ARG_REPORT_TASKS}" = "true" ]]; then ARGS+=(--dangerously-skip-permissions -- "$ARG_AI_PROMPT") else if [ "$ARG_DANGEROUSLY_SKIP_PERMISSIONS" = "true" ]; then @@ -218,31 +219,35 @@ function start_agentapi() { BOUNDARY_ARGS+=(--allow "domain=anthropic.com" --allow "domain=registry.npmjs.org" --allow "domain=sentry.io" --allow "domain=claude.ai" --allow "domain=$ARG_CODER_HOST") # Add any additional allowed URLs from the variable - if [ -n "$ARG_BOUNDARY_ADDITIONAL_ALLOWED_URLS" ]; then - IFS='|' read -ra ADDITIONAL_URLS <<< "$ARG_BOUNDARY_ADDITIONAL_ALLOWED_URLS" + if [[ -n "${ARG_BOUNDARY_ADDITIONAL_ALLOWED_URLS}" ]]; then + IFS='|' read -ra ADDITIONAL_URLS <<< "${ARG_BOUNDARY_ADDITIONAL_ALLOWED_URLS}" for url in "${ADDITIONAL_URLS[@]}"; do # Quote the URL to preserve spaces within the allow rule - BOUNDARY_ARGS+=(--allow "$url") + BOUNDARY_ARGS+=(--allow "${url}") done fi # Set HTTP Proxy port used by Boundary - BOUNDARY_ARGS+=(--proxy-port "$ARG_BOUNDARY_PROXY_PORT") + BOUNDARY_ARGS+=(--proxy-port "${ARG_BOUNDARY_PROXY_PORT}") # Set log level for boundary - BOUNDARY_ARGS+=(--log-level "$ARG_BOUNDARY_LOG_LEVEL") + BOUNDARY_ARGS+=(--log-level "${ARG_BOUNDARY_LOG_LEVEL}") - if [ "${ARG_ENABLE_BOUNDARY_PPROF:-false}" = "true" ]; then + if [[ "${ARG_ENABLE_BOUNDARY_PPROF:-false}" = "true" ]]; then # Enable boundary pprof server on specified port BOUNDARY_ARGS+=(--pprof) - BOUNDARY_ARGS+=(--pprof-port "$ARG_BOUNDARY_PPROF_PORT") + BOUNDARY_ARGS+=(--pprof-port "${ARG_BOUNDARY_PPROF_PORT}") fi - agentapi server --type claude --term-width 67 --term-height 1190 -- \ - boundary-run "${BOUNDARY_ARGS[@]}" -- \ - claude "${ARGS[@]}" +# if [[ "${ARG_REPORT_TASKS}" == "true" ]]; then +# boundary-run "${BOUNDARY_ARGS[@]}" -- \ +# claude "${ARGS[@]}" +# else + "${CORE_COMMAND[@]}" boundary-run "${BOUNDARY_ARGS[@]}" -- \ + claude "${ARGS[@]}" +# fi else - agentapi server --type claude --term-width 67 --term-height 1190 -- claude "${ARGS[@]}" + "${CORE_COMMAND[@]}" claude "${ARGS[@]}" fi }