feat(coder/modules/agentapi): enhance start script and configuration options for AgentAPI server
This commit is contained in:
parent
6e18248731
commit
3f68310880
@ -95,7 +95,8 @@ Example start script:
|
||||
|
||||
```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'
|
||||
#!/bin/bash
|
||||
|
||||
@ -112,7 +112,7 @@ export AGENTAPI_CHAT_BASE_PATH="${AGENTAPI_CHAT_BASE_PATH:-}"
|
||||
export AGENTAPI_ALLOWED_HOSTS="*"
|
||||
|
||||
# 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
|
||||
ARGS=(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
module_path=${1:-"$HOME/.agentapi-module"}
|
||||
module_path="$HOME/.agentapi-module"
|
||||
|
||||
# Write the agent command to agent-command.sh
|
||||
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
|
||||
agentapi_subdomain = var.subdomain
|
||||
module_dir_name = local.module_dir_name
|
||||
agentapi_server_type = "claude"
|
||||
install_agentapi = var.install_agentapi
|
||||
agentapi_version = var.agentapi_version
|
||||
pre_install_script = var.pre_install_script
|
||||
@ -382,6 +383,7 @@ module "agentapi" {
|
||||
#!/bin/bash
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh
|
||||
chmod +x /tmp/start.sh
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ command_exists() {
|
||||
command -v "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
MODULE_PATH="$HOME/.claude-module"
|
||||
ARG_RESUME_SESSION_ID=${ARG_RESUME_SESSION_ID:-}
|
||||
ARG_CONTINUE=${ARG_CONTINUE:-false}
|
||||
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[@]}")"
|
||||
|
||||
# Write the agent command to agent-command.sh
|
||||
if [ "$ARG_ENABLE_BOUNDARY" = "true" ]; then
|
||||
install_boundary
|
||||
|
||||
@ -238,12 +240,28 @@ function start_agentapi() {
|
||||
BOUNDARY_CMD=("$CODER_NO_CAPS" "boundary")
|
||||
fi
|
||||
|
||||
agentapi server --type claude --term-width 67 --term-height 1190 -- \
|
||||
"${BOUNDARY_CMD[@]}" "${BOUNDARY_ARGS[@]}" -- \
|
||||
claude "${ARGS[@]}"
|
||||
# Build properly quoted command arguments
|
||||
boundary_cmd=$(printf '%q ' "${BOUNDARY_CMD[@]}" "${BOUNDARY_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
|
||||
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
|
||||
|
||||
chmod +x "$MODULE_PATH/agent-command.sh"
|
||||
printf "Agent command written to %s\n" "$MODULE_PATH/agent-command.sh"
|
||||
}
|
||||
|
||||
validate_claude_installation
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user