Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .agents/scripts/cron-dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ log_success() {

#######################################
# Build curl arguments array for secure requests
# Arguments:
# $1 - protocol (http|https), already resolved by caller
# Populates CURL_ARGS array with auth and SSL options
#######################################
build_curl_args() {
local protocol="${1:-http}"
CURL_ARGS=(-sf)

# Add authentication if configured
Expand All @@ -90,12 +93,10 @@ build_curl_args() {
fi

# Add SSL options for HTTPS
local protocol
protocol=$(get_protocol "$OPENCODE_HOST")
if [[ "$protocol" == "https" ]] && [[ -n "$OPENCODE_INSECURE" ]]; then
# Allow insecure connections (self-signed certs) - use with caution
CURL_ARGS+=(-k)
log_info "WARNING: SSL verification disabled (OPENCODE_INSECURE=1)"
log_warn "WARNING: SSL verification disabled (OPENCODE_INSECURE=1)"
fi
return 0
}
Expand All @@ -108,7 +109,7 @@ check_server() {
protocol=$(get_protocol "$OPENCODE_HOST")
local url="${protocol}://${OPENCODE_HOST}:${OPENCODE_PORT}/global/health"

build_curl_args
build_curl_args "$protocol"

if curl "${CURL_ARGS[@]}" "$url" &>/dev/null; then
return 0
Expand Down Expand Up @@ -158,7 +159,7 @@ create_session() {
protocol=$(get_protocol "$OPENCODE_HOST")
local url="${protocol}://${OPENCODE_HOST}:${OPENCODE_PORT}/session"

build_curl_args
build_curl_args "$protocol"

curl "${CURL_ARGS[@]}" -X POST "$url" \
-H "Content-Type: application/json" \
Expand Down Expand Up @@ -198,7 +199,7 @@ send_prompt() {
parts: [{type: "text", text: $task}]
}')

build_curl_args
build_curl_args "$protocol"

# Send with timeout
timeout "$cmd_timeout" curl "${CURL_ARGS[@]}" -X POST "$url" \
Expand All @@ -217,7 +218,7 @@ delete_session() {
protocol=$(get_protocol "$OPENCODE_HOST")
local url="${protocol}://${OPENCODE_HOST}:${OPENCODE_PORT}/session/${session_id}"

build_curl_args
build_curl_args "$protocol"

curl "${CURL_ARGS[@]}" -X DELETE "$url" &>/dev/null || true
return 0
Expand Down
20 changes: 12 additions & 8 deletions .agents/scripts/cron-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ LOG_PREFIX="CRON"
# Ensure directories and config exist
#######################################
ensure_setup() {
mkdir -p "$CONFIG_DIR" "$CRON_LOG_DIR"
mkdir -p "$CONFIG_DIR" "$CRON_LOG_DIR"

if [[ ! -f "$CONFIG_FILE" ]]; then
cat > "$CONFIG_FILE" << 'EOF'
if [[ ! -f "$CONFIG_FILE" ]]; then
cat >"$CONFIG_FILE" <<'EOF'
{
"version": "1.0",
"jobs": []
}
EOF
log_info "Created config file: $CONFIG_FILE"
fi
log_info "Created config file: $CONFIG_FILE"
fi
}

#######################################
Expand Down Expand Up @@ -96,8 +96,12 @@ get_protocol() {

#######################################
# Build curl arguments array for secure requests
# Arguments:
# $1 - protocol (http|https), already resolved by caller
# Populates CURL_ARGS array with auth and SSL options
#######################################
build_curl_args() {
local protocol="${1:-http}"
CURL_ARGS=(-sf)

# Add authentication if configured
Expand All @@ -107,12 +111,12 @@ build_curl_args() {
fi

# Add SSL options for HTTPS
local protocol
protocol=$(get_protocol "$OPENCODE_HOST")
if [[ "$protocol" == "https" ]] && [[ -n "$OPENCODE_INSECURE" ]]; then
# Allow insecure connections (self-signed certs) - use with caution
CURL_ARGS+=(-k)
log_warn "WARNING: SSL verification disabled (OPENCODE_INSECURE=1)"
fi
return 0
}

#######################################
Expand All @@ -123,7 +127,7 @@ check_server() {
protocol=$(get_protocol "$OPENCODE_HOST")
local url="${protocol}://${OPENCODE_HOST}:${OPENCODE_PORT}/global/health"

build_curl_args
build_curl_args "$protocol"

if curl "${CURL_ARGS[@]}" "$url" &>/dev/null; then
return 0
Expand Down
Loading