diff --git a/.github/workflows/template-tauri-build-linux-x64.yml b/.github/workflows/template-tauri-build-linux-x64.yml index bc2144fe6..a7dd27ef2 100644 --- a/.github/workflows/template-tauri-build-linux-x64.yml +++ b/.github/workflows/template-tauri-build-linux-x64.yml @@ -108,9 +108,15 @@ jobs: jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true | .bundle.resources = ["resources/themes/**/*", "resources/pre-install/**/*"] | .bundle.externalBin = ["binaries/cortex-server", "resources/bin/uv"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json if [ "${{ inputs.channel }}" != "stable" ]; then - jq '.bundle.linux.deb.files = {"usr/bin/bun": "resources/bin/bun", "usr/lib/Jan-${{ inputs.channel }}/binaries/engines": "binaries/engines"}' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + jq '.bundle.linux.deb.files = {"usr/bin/bun": "resources/bin/bun", + "usr/lib/Jan-${{ inputs.channel }}/binaries": "binaries/deps", + "usr/lib/Jan-${{ inputs.channel }}/binaries/engines": "binaries/engines", + "usr/lib/Jan-${{ inputs.channel }}/binaries/libvulkan.so": "binaries/libvulkan.so"}' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json else - jq '.bundle.linux.deb.files = {"usr/bin/bun": "resources/bin/bun", "usr/lib/Jan/binaries/engines": "binaries/engines"}' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json + jq '.bundle.linux.deb.files = {"usr/bin/bun": "resources/bin/bun", + "usr/lib/Jan/binaries": "binaries/deps", + "usr/lib/Jan/binaries/engines": "binaries/engines", + "usr/lib/Jan/binaries/libvulkan.so": "binaries/libvulkan.so"}' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json fi mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json jq --arg version "${{ inputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json @@ -148,12 +154,24 @@ jobs: if [ "${{ inputs.channel }}" != "stable" ]; then ls ./src-tauri/target/release/bundle/appimage/ cp ./src-tauri/resources/bin/bun ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir/usr/bin/bun - cp -rf ./src-tauri/binaries/engines ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir/usr/lib/Jan-${{ inputs.channel }}/engines - ./appimagetool ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir $(ls ./src-tauri/target/release/bundle/appimage/ | grep AppImage) + mkdir -p ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir/usr/lib/Jan-${{ inputs.channel }}/binaries/engines + cp -f ./src-tauri/binaries/deps/*.so* ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir/usr/lib/Jan-${{ inputs.channel }}/binaries/ + cp -f ./src-tauri/binaries/*.so* ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir/usr/lib/Jan-${{ inputs.channel }}/binaries/ + cp -rf ./src-tauri/binaries/engines ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir/usr/lib/Jan-${{ inputs.channel }}/binaries/ + APP_IMAGE=./src-tauri/target/release/bundle/appimage/$(ls ./src-tauri/target/release/bundle/appimage/ | grep .AppImage | head -1) + echo $APP_IMAGE + rm -f $APP_IMAGE + ./appimagetool ./src-tauri/target/release/bundle/appimage/Jan-${{ inputs.channel }}.AppDir $APP_IMAGE else cp ./src-tauri/resources/bin/bun ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/bin/bun - cp -rf ./src-tauri/binaries/engines ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/engines - ./appimagetool ./src-tauri/target/release/bundle/appimage/Jan.AppDir $(ls ./src-tauri/target/release/bundle/appimage/ | grep AppImage) + mkdir -p ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/engines + cp -f ./src-tauri/binaries/deps/*.so* ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/ + cp -f ./src-tauri/binaries/*.so* ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/ + cp -rf ./src-tauri/binaries/engines ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/ + APP_IMAGE=./src-tauri/target/release/bundle/appimage/$(ls ./src-tauri/target/release/bundle/appimage/ | grep AppImage | head -1) + echo $APP_IMAGE + rm -f $APP_IMAGE + ./appimagetool ./src-tauri/target/release/bundle/appimage/Jan.AppDir $APP_IMAGE fi env: diff --git a/extensions/inference-cortex-extension/package.json b/extensions/inference-cortex-extension/package.json index 00e7c346e..703b937b9 100644 --- a/extensions/inference-cortex-extension/package.json +++ b/extensions/inference-cortex-extension/package.json @@ -13,8 +13,8 @@ "downloadcortex:linux:darwin": "./download.sh", "downloadcortex:win32": "download.bat", "downloadcortex": "run-script-os", - "build:publish:darwin": "rimraf *.tgz --glob || true && yarn build && yarn downloadcortex && ../../.github/scripts/auto-sign.sh && cpx \"bin/**\" \"dist/bin\" && npm pack && cpx *.tgz ../../pre-install", - "build:publish:win32:linux": "rimraf *.tgz --glob || true && yarn build && yarn downloadcortex && cpx \"bin/**\" \"dist/bin\" && npm pack && cpx *.tgz ../../pre-install", + "build:publish:darwin": "rimraf *.tgz --glob || true && yarn build && ../../.github/scripts/auto-sign.sh && cpx \"bin/**\" \"dist/bin\" && npm pack && cpx *.tgz ../../pre-install", + "build:publish:win32:linux": "rimraf *.tgz --glob || true && yarn build && cpx \"bin/**\" \"dist/bin\" && npm pack && cpx *.tgz ../../pre-install", "build:publish": "run-script-os" }, "exports": { diff --git a/src-tauri/binaries/download.bat b/src-tauri/binaries/download.bat index 18de2bf64..65fdfe98c 100644 --- a/src-tauri/binaries/download.bat +++ b/src-tauri/binaries/download.bat @@ -12,7 +12,7 @@ set DOWNLOAD_TOOL=..\..\extensions\inference-cortex-extension\node_modules\.bin\ @REM Download llama.cpp binaries call %DOWNLOAD_TOOL% -e --strip 1 -o %BIN_PATH% https://github.com/menloresearch/cortex.cpp/releases/download/v%CORTEX_VERSION%/cortex-%CORTEX_VERSION%-windows-amd64.tar.gz call %DOWNLOAD_TOOL% %ENGINE_DOWNLOAD_URL%-avx2-cuda-cu12.0-x64.tar.gz -e --strip 2 -o./engines/llama.cpp/win-avx2-cuda-cu12.0-x64/%ENGINE_VERSION% -@REM call %DOWNLOAD_TOOL% %ENGINE_DOWNLOAD_URL%-avx2-cuda-cu11.7-x64.tar.gz -e --strip 2 -o./engines/llama.cpp/win-avx2-cuda-cu11.7-x64/%ENGINE_VERSION% +call %DOWNLOAD_TOOL% %ENGINE_DOWNLOAD_URL%-avx2-cuda-cu11.7-x64.tar.gz -e --strip 2 -o./engines/llama.cpp/win-avx2-cuda-cu11.7-x64/%ENGINE_VERSION% @REM call %DOWNLOAD_TOOL% %ENGINE_DOWNLOAD_URL%-noavx-cuda-cu12.0-x64.tar.gz -e --strip 2 -o./engines/llama.cpp/win-noavx-cuda-cu12.0-x64/%ENGINE_VERSION% @REM call %DOWNLOAD_TOOL% %ENGINE_DOWNLOAD_URL%-noavx-cuda-cu11.7-x64.tar.gz -e --strip 2 -o./engines/llama.cpp/win-noavx-cuda-cu11.7-x64/%ENGINE_VERSION% call %DOWNLOAD_TOOL% %ENGINE_DOWNLOAD_URL%-noavx-x64.tar.gz -e --strip 2 -o./engines/llama.cpp/win-noavx-x64/%ENGINE_VERSION% diff --git a/src-tauri/binaries/download.sh b/src-tauri/binaries/download.sh index e1ad30db9..f967a110f 100755 --- a/src-tauri/binaries/download.sh +++ b/src-tauri/binaries/download.sh @@ -48,8 +48,8 @@ if [ "$OS_TYPE" == "Linux" ]; then download "${ENGINE_DOWNLOAD_URL}-linux-noavx-cuda-cu12.0-x64.tar.gz" 2 "${SHARED_PATH}/engines/llama.cpp/linux-noavx-cuda-cu12.0-x64/${ENGINE_VERSION}" download "${ENGINE_DOWNLOAD_URL}-linux-noavx-cuda-cu11.7-x64.tar.gz" 2 "${SHARED_PATH}/engines/llama.cpp/linux-noavx-cuda-cu11.7-x64/${ENGINE_VERSION}" download "${ENGINE_DOWNLOAD_URL}-linux-vulkan-x64.tar.gz" 2 "${SHARED_PATH}/engines/llama.cpp/linux-vulkan-x64/${ENGINE_VERSION}" - download "${CUDA_DOWNLOAD_URL}/cudart-llama-bin-linux-cu12.0-x64.tar.gz" 0 "${BIN_PATH}" - download "${CUDA_DOWNLOAD_URL}/cudart-llama-bin-linux-cu11.7-x64.tar.gz" 0 "${BIN_PATH}" + download "${CUDA_DOWNLOAD_URL}/cudart-llama-bin-linux-cu12.0-x64.tar.gz" 0 "${BIN_PATH}/deps" + download "${CUDA_DOWNLOAD_URL}/cudart-llama-bin-linux-cu11.7-x64.tar.gz" 0 "${BIN_PATH}/deps" elif [ "$OS_TYPE" == "Darwin" ]; then # macOS downloads diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 9fbb9e906..36a40f6f3 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -2,9 +2,13 @@ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "default", "description": "enables the default permissions", - "windows": ["main"], + "windows": [ + "main" + ], "remote": { - "urls": ["http://*"] + "urls": [ + "http://*" + ] }, "permissions": [ "core:default", @@ -49,6 +53,19 @@ "validator": "\\S+" }, "--data_folder_path", + { + "validator": "\\S+" + }, + "--cors", + { + "validator": "\\S+" + }, + "--allowed_origins", + { + "validator": "\\S+" + }, + "config", + "--api_keys", { "validator": "\\S+" } @@ -60,4 +77,4 @@ }, "store:default" ] -} +} \ No newline at end of file diff --git a/src-tauri/src/core/setup.rs b/src-tauri/src/core/setup.rs index 8e2f4f7b7..9d1993124 100644 --- a/src-tauri/src/core/setup.rs +++ b/src-tauri/src/core/setup.rs @@ -240,10 +240,14 @@ pub fn setup_sidecar(app: &App) -> Result<(), String> { #[cfg(target_os = "windows")] { cmd = cmd.env("PATH", { - let current_app_data_dir = app_handle.path().app_data_dir().unwrap(); - let dest = current_app_data_dir.to_str().unwrap(); - let path_env = std::env::var("PATH").unwrap_or_default(); - format!("{}{}{}", path_env, std::path::MAIN_SEPARATOR, dest) + let exe_path = env::current_exe().expect("Failed to get current exe path"); + let exe_parent_path = exe_path + .parent() + .expect("Executable must have a parent directory"); + let bin_path = exe_parent_path.to_path_buf(); + let dest = bin_path.display(); + let path = std::env::var("PATH").unwrap_or_default(); + format!("{}{}{}", path, std::path::MAIN_SEPARATOR, dest) }); } @@ -299,6 +303,7 @@ pub fn setup_sidecar(app: &App) -> Result<(), String> { ); let current_command = sidecar_command_builder(); + log::debug!("Sidecar command: {:?}", current_command); match current_command.spawn() { Ok((mut rx, child_instance)) => { log::info!( @@ -432,4 +437,4 @@ pub fn setup_engine_binaries(app: &App) -> Result<(), String> { log::error!("Failed to copy themes: {}", e); } Ok(()) -} \ No newline at end of file +} diff --git a/src-tauri/tauri.bundle.windows.nsis.template b/src-tauri/tauri.bundle.windows.nsis.template index e1169cd8c..70e009c35 100644 --- a/src-tauri/tauri.bundle.windows.nsis.template +++ b/src-tauri/tauri.bundle.windows.nsis.template @@ -637,12 +637,12 @@ Section Install SetOutPath "$INSTDIR\binaries\engines" File /nonfatal /a /r "D:\a\jan\jan\src-tauri\binaries\engines\" SetOutPath $INSTDIR - ; File /a "/oname=cublas64_11.dll" "D:\a\jan\jan\src-tauri\binaries\cublas64_11.dll" + File /a "/oname=cublas64_11.dll" "D:\a\jan\jan\src-tauri\binaries\cublas64_11.dll" File /a "/oname=cublas64_12.dll" "D:\a\jan\jan\src-tauri\binaries\cublas64_12.dll" - ; File /a "/oname=cublasLt64_11.dll" "D:\a\jan\jan\src-tauri\binaries\cublasLt64_11.dll" + File /a "/oname=cublasLt64_11.dll" "D:\a\jan\jan\src-tauri\binaries\cublasLt64_11.dll" File /a "/oname=cublasLt64_12.dll" "D:\a\jan\jan\src-tauri\binaries\cublasLt64_12.dll" File /a "/oname=cudart64_12.dll" "D:\a\jan\jan\src-tauri\binaries\cudart64_12.dll" - ; File /a "/oname=cudart64_110.dll" "D:\a\jan\jan\src-tauri\binaries\cudart64_110.dll" + File /a "/oname=cudart64_110.dll" "D:\a\jan\jan\src-tauri\binaries\cudart64_110.dll" File /a "/oname=msvcp140.dll" "D:\a\jan\jan\src-tauri\binaries\msvcp140.dll" ; File /a "/oname=vcomp140.dll" "D:\a\jan\jan\src-tauri\binaries\vcomp140.dll" File /a "/oname=vcruntime140_1.dll" "D:\a\jan\jan\src-tauri\binaries\vcruntime140_1.dll" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 1a354a06b..4a81ad8c8 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -107,6 +107,7 @@ "deb": { "files": { "usr/bin/bun": "resources/bin/bun", + "usr/lib/Jan/binaries": "binaries/deps", "usr/lib/Jan/binaries/engines": "binaries/engines" } }