T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/.cursor-server/bin/b753cece5c67c47cb5637199a5a5de2b7100c180/bin/remote-cli/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/.cursor-server/bin/b753cece5c67c47cb5637199a5a5de2b7100c180/bin/remote-cli/cursor
#!/usr/bin/env sh
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
ROOT="$(dirname "$(dirname "$(dirname "$(readlink -f "$0")")")")"

APP_NAME="cursor"
VERSION="1.6.35"
COMMIT="b753cece5c67c47cb5637199a5a5de2b7100c180"
EXEC_NAME="cursor"
CLI_SCRIPT="$ROOT/out/server-cli.js"

find_cursor_cli() {
	# Clear the output variables
	CURSOR_CLI=""
	CURSOR_CLI_MODE=""

	# For remote CLI, we're already in the remote context
	CURSOR_CLI="\"$ROOT/node\" \"$CLI_SCRIPT\" \"$APP_NAME\" \"$VERSION\" \"$COMMIT\" \"$EXEC_NAME\""
	CURSOR_CLI_MODE="remote"
	return 0
}

fallback_to_cursor_cli() {
	if [ -n "$CURSOR_CLI" ]; then
		# Falling back to direct CLI execution
		eval "$CURSOR_CLI" "$@"
		exit $?
	else
		echo "Error: Neither cursor-agent nor fallback CLI found. Please install Cursor properly." 1>&2
		exit 1
	fi
}

# Main execution
export VSCODE_NODE_OPTIONS=$NODE_OPTIONS
export VSCODE_NODE_REPL_EXTERNAL_MODULE=$NODE_REPL_EXTERNAL_MODULE
unset NODE_OPTIONS
unset NODE_REPL_EXTERNAL_MODULE

# Try to find CURSOR_CLI for potential fallback
find_cursor_cli 2>/dev/null
if [ -n "$CURSOR_CLI" ]; then
	export CURSOR_CLI
	export CURSOR_CLI_MODE
fi

if [ "$CURSOR_CLI_BLOCK_CURSOR_AGENT" = "true" ]; then
  # cursor-agent is forbidden, call cursor CLI directly
	fallback_to_cursor_cli "$@"
fi

# Check if cursor-agent is available
AGENT_JUST_INSTALLED=false
if ! command -v ~/.local/bin/cursor-agent >/dev/null 2>&1; then
	# Check if bash is available for installation
	if command -v bash >/dev/null 2>&1 && [ ! -f ~/.cursor/skip-cursor-agent-download ]; then
		echo "cursor-agent not found, installing via https://cursor.com/install ..."
		curl -sS https://cursor.com/install | bash >/dev/null 2>&1
		# Remove the previous log line from the terminal output
		if command -v tput >/dev/null 2>&1; then
			tput cuu1 && tput el
		fi
		AGENT_JUST_INSTALLED=true
		# Try to use cursor-agent after installation
		if command -v ~/.local/bin/cursor-agent >/dev/null 2>&1; then
			export CURSOR_CLI_COMPAT=1
			exec ~/.local/bin/cursor-agent "$@"
		fi
	fi
	touch ~/.cursor/skip-cursor-agent-download >/dev/null 2>&1
	# Fallback: if cursor-agent is not available and we can't install it,
	# or installation failed, use CURSOR_CLI directly if available
	fallback_to_cursor_cli "$@"
else
	# Check current cursor-agent version meets minimum version requirement
	# If it fails with exit code 2 (version too old), update and retry
	OUTPUT=$({ ~/.local/bin/cursor-agent --min-version=2025.09.04 status; } 2>&1)
	EXIT_CODE=$?

	# Update and retry if cursor was not just installed and:
	#  - exit code is 2 (version too old), OR
	#  - exit code is 1 and output contains "unknown option" (old agent CLI version doesn't have the --min-version option)
	if { [ "$EXIT_CODE" -eq 2 ] || { [ "$EXIT_CODE" -eq 1 ] && echo "$OUTPUT" | grep -qi "unknown option"; }; }; then
		echo "cursor-agent version is outdated, updating..."
		~/.local/bin/cursor-agent update >/dev/null 2>&1
		# Remove the previous log line from the terminal output
		if command -v tput >/dev/null 2>&1; then
			tput cuu1 && tput el
		fi
		# Check new version to see if minimum version requirement is met
		OUTPUT2=$({ ~/.local/bin/cursor-agent --min-version=2025.09.04 status; } 2>&1)
		EXIT_CODE2=$?
		if { [ "$EXIT_CODE2" -eq 2 ] || { [ "$EXIT_CODE2" -eq 1 ] && echo "$OUTPUT2" | grep -qi "unknown option"; }; }; then
			# If the second attempt also fails, just try CURSOR_CLI as a fallback
			fallback_to_cursor_cli "$@"
		else
			# min-version is met, run cursor-agent
			export CURSOR_CLI_COMPAT=1
			exec ~/.local/bin/cursor-agent "$@"
		fi
	else
		# min-version is met, run cursor-agent
		export CURSOR_CLI_COMPAT=1
		exec ~/.local/bin/cursor-agent "$@"
	fi
fi

CasperSecurity Mini