feat(coder/modules/agentapi): enhance start script and configuration options for AgentAPI server
This commit is contained in:
parent
6e18248731
commit
3f68310880
@ -70,10 +70,10 @@ You can configure the AgentAPI server type, terminal dimensions, and initial pro
|
|||||||
```tf
|
```tf
|
||||||
module "agentapi" {
|
module "agentapi" {
|
||||||
# ... other config
|
# ... other config
|
||||||
agentapi_server_type = "claude" # required
|
agentapi_server_type = "claude" # required
|
||||||
agentapi_term_width = 67 # default: 67
|
agentapi_term_width = 67 # default: 67
|
||||||
agentapi_term_height = 1190 # default: 1190
|
agentapi_term_height = 1190 # default: 1190
|
||||||
agentapi_initial_prompt = "You are a helpful assistant." # optional
|
agentapi_initial_prompt = "You are a helpful assistant." # optional
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -95,7 +95,8 @@ Example start script:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
module_path=${1:-"$HOME/.my-module"}
|
# Hardcode your module's path
|
||||||
|
module_path="$HOME/.my-module"
|
||||||
|
|
||||||
cat > "$module_path/agent-command.sh" << 'EOF'
|
cat > "$module_path/agent-command.sh" << 'EOF'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|||||||
@ -112,7 +112,7 @@ export AGENTAPI_CHAT_BASE_PATH="${AGENTAPI_CHAT_BASE_PATH:-}"
|
|||||||
export AGENTAPI_ALLOWED_HOSTS="*"
|
export AGENTAPI_ALLOWED_HOSTS="*"
|
||||||
|
|
||||||
# Call agentapi-start.sh to write agent-command.sh
|
# Call agentapi-start.sh to write agent-command.sh
|
||||||
"$module_path/scripts/agentapi-start.sh" "$module_path"
|
"$module_path/scripts/agentapi-start.sh"
|
||||||
|
|
||||||
# Build agentapi server command arguments
|
# Build agentapi server command arguments
|
||||||
ARGS=(
|
ARGS=(
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
set -o errexit
|
set -o errexit
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
module_path=${1:-"$HOME/.agentapi-module"}
|
module_path="$HOME/.agentapi-module"
|
||||||
|
|
||||||
# Write the agent command to agent-command.sh
|
# Write the agent command to agent-command.sh
|
||||||
cat > "$module_path/agent-command.sh" << 'EOF'
|
cat > "$module_path/agent-command.sh" << 'EOF'
|
||||||
|
|||||||
@ -374,6 +374,7 @@ module "agentapi" {
|
|||||||
cli_app_display_name = var.cli_app ? var.cli_app_display_name : null
|
cli_app_display_name = var.cli_app ? var.cli_app_display_name : null
|
||||||
agentapi_subdomain = var.subdomain
|
agentapi_subdomain = var.subdomain
|
||||||
module_dir_name = local.module_dir_name
|
module_dir_name = local.module_dir_name
|
||||||
|
agentapi_server_type = "claude"
|
||||||
install_agentapi = var.install_agentapi
|
install_agentapi = var.install_agentapi
|
||||||
agentapi_version = var.agentapi_version
|
agentapi_version = var.agentapi_version
|
||||||
pre_install_script = var.pre_install_script
|
pre_install_script = var.pre_install_script
|
||||||
@ -382,6 +383,7 @@ module "agentapi" {
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh
|
echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh
|
||||||
chmod +x /tmp/start.sh
|
chmod +x /tmp/start.sh
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ command_exists() {
|
|||||||
command -v "$1" > /dev/null 2>&1
|
command -v "$1" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MODULE_PATH="$HOME/.claude-module"
|
||||||
ARG_RESUME_SESSION_ID=${ARG_RESUME_SESSION_ID:-}
|
ARG_RESUME_SESSION_ID=${ARG_RESUME_SESSION_ID:-}
|
||||||
ARG_CONTINUE=${ARG_CONTINUE:-false}
|
ARG_CONTINUE=${ARG_CONTINUE:-false}
|
||||||
ARG_DANGEROUSLY_SKIP_PERMISSIONS=${ARG_DANGEROUSLY_SKIP_PERMISSIONS:-}
|
ARG_DANGEROUSLY_SKIP_PERMISSIONS=${ARG_DANGEROUSLY_SKIP_PERMISSIONS:-}
|
||||||
@ -216,6 +217,7 @@ function start_agentapi() {
|
|||||||
|
|
||||||
printf "Running claude code with args: %s\n" "$(printf '%q ' "${ARGS[@]}")"
|
printf "Running claude code with args: %s\n" "$(printf '%q ' "${ARGS[@]}")"
|
||||||
|
|
||||||
|
# Write the agent command to agent-command.sh
|
||||||
if [ "$ARG_ENABLE_BOUNDARY" = "true" ]; then
|
if [ "$ARG_ENABLE_BOUNDARY" = "true" ]; then
|
||||||
install_boundary
|
install_boundary
|
||||||
|
|
||||||
@ -238,12 +240,28 @@ function start_agentapi() {
|
|||||||
BOUNDARY_CMD=("$CODER_NO_CAPS" "boundary")
|
BOUNDARY_CMD=("$CODER_NO_CAPS" "boundary")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
agentapi server --type claude --term-width 67 --term-height 1190 -- \
|
# Build properly quoted command arguments
|
||||||
"${BOUNDARY_CMD[@]}" "${BOUNDARY_ARGS[@]}" -- \
|
boundary_cmd=$(printf '%q ' "${BOUNDARY_CMD[@]}" "${BOUNDARY_ARGS[@]}")
|
||||||
claude "${ARGS[@]}"
|
claude_args=$(printf '%q ' "${ARGS[@]}")
|
||||||
|
|
||||||
|
# Write command to agent-command.sh with boundary
|
||||||
|
cat > "$MODULE_PATH/agent-command.sh" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
${BOUNDARY_CMD[@]} -- claude ${ARGS[@]}
|
||||||
|
EOF
|
||||||
else
|
else
|
||||||
agentapi server --type claude --term-width 67 --term-height 1190 -- claude "${ARGS[@]}"
|
# Build properly quoted command arguments
|
||||||
|
claude_args=$(printf '%q ' "${ARGS[@]}")
|
||||||
|
|
||||||
|
# Write command to agent-command.sh without boundary
|
||||||
|
cat > "$MODULE_PATH/agent-command.sh" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
claude ${ARGS[@]}
|
||||||
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chmod +x "$MODULE_PATH/agent-command.sh"
|
||||||
|
printf "Agent command written to %s\n" "$MODULE_PATH/agent-command.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_claude_installation
|
validate_claude_installation
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user